ColumnWrapper.vue
2 years ago
CxVuiCollapseMini.vue
2 years ago
CxVuiDate.vue
2 years ago
CxVuiFSelect.vue
2 years ago
CxVuiPopup.vue
2 years ago
CxVuiSelect.vue
2 years ago
CxVuiTabs.vue
2 years ago
CxVuiTabsPanel.vue
2 years ago
Delimiter.vue
2 years ago
DetailsTable.vue
2 years ago
DetailsTableRow.vue
2 years ago
DetailsTableRowValue.vue
2 years ago
ExternalLink.vue
2 years ago
ListComponents.vue
2 years ago
PrintButton.vue
2 years ago
RowWrapper.vue
2 years ago
Tooltip.vue
2 years ago
CxVuiDate.vue
60 lines
| 1 | <template> |
| 2 | <input |
| 3 | type="date" |
| 4 | :name="elementId" |
| 5 | :id="elementId" |
| 6 | class="cx-vui-input size-fullwidth" |
| 7 | :value="value" |
| 8 | @input="handleInput" |
| 9 | :max="max" |
| 10 | :min="min" |
| 11 | > |
| 12 | </template> |
| 13 | |
| 14 | <script> |
| 15 | |
| 16 | let now = new Date( Date.now() - 8640000 ).toJSON(); |
| 17 | [ now ] = now.split( 'T' ); |
| 18 | |
| 19 | const dateValidator = ( value ) => { |
| 20 | if ( [ 'now' ].includes( value ) ) { |
| 21 | return true; |
| 22 | } |
| 23 | |
| 24 | return !Number.isNaN( new Date( value ).getTime() ); |
| 25 | }; |
| 26 | |
| 27 | export default { |
| 28 | name: 'CxVuiDate', |
| 29 | props: { |
| 30 | value: { |
| 31 | type: String, |
| 32 | }, |
| 33 | maxDate: { |
| 34 | validator: dateValidator, |
| 35 | }, |
| 36 | minDate: { |
| 37 | validator: dateValidator, |
| 38 | }, |
| 39 | elementId: { |
| 40 | type: String, |
| 41 | }, |
| 42 | }, |
| 43 | data() { |
| 44 | return { |
| 45 | max: 'now' === this.maxDate ? now : this.maxDate, |
| 46 | min: 'now' === this.minDate ? now : this.minDate, |
| 47 | }; |
| 48 | }, |
| 49 | methods: { |
| 50 | handleInput( event ) { |
| 51 | this.$emit( 'input', event.target.value ); |
| 52 | }, |
| 53 | }, |
| 54 | inject: [ 'elementId' ], |
| 55 | }; |
| 56 | </script> |
| 57 | |
| 58 | <style scoped> |
| 59 | |
| 60 | </style> |