goodteditor-ui 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/.eslintrc.js +7 -7
  2. package/.prettierrc +14 -14
  3. package/README.md +35 -35
  4. package/babel.config.js +5 -5
  5. package/index.js +53 -53
  6. package/jsconfig.json +13 -13
  7. package/package.json +67 -67
  8. package/src/App.vue +36 -36
  9. package/src/components/ui/Avatar.md +68 -68
  10. package/src/components/ui/Avatar.vue +180 -180
  11. package/src/components/ui/Badge.md +20 -20
  12. package/src/components/ui/Badge.vue +75 -75
  13. package/src/components/ui/Collapse.md +90 -90
  14. package/src/components/ui/Collapse.vue +86 -86
  15. package/src/components/ui/ColorPicker/Alpha.vue +114 -114
  16. package/src/components/ui/ColorPicker/Colors.vue +117 -117
  17. package/src/components/ui/ColorPicker/Hue.vue +113 -113
  18. package/src/components/ui/ColorPicker/Preview.vue +55 -55
  19. package/src/components/ui/ColorPicker/Saturation.vue +123 -123
  20. package/src/components/ui/ColorPicker/mixin.js +105 -105
  21. package/src/components/ui/ColorPicker.md +17 -17
  22. package/src/components/ui/ColorPicker.vue +314 -314
  23. package/src/components/ui/Datalist.md +41 -41
  24. package/src/components/ui/Datalist.vue +164 -164
  25. package/src/components/ui/DatePicker.md +168 -168
  26. package/src/components/ui/DatePicker.vue +527 -527
  27. package/src/components/ui/FileSelector.md +105 -105
  28. package/src/components/ui/FileSelector.vue +82 -82
  29. package/src/components/ui/Grid.md +130 -130
  30. package/src/components/ui/Grid.vue +92 -92
  31. package/src/components/ui/Image.md +59 -59
  32. package/src/components/ui/Image.vue +57 -57
  33. package/src/components/ui/InputAutocomplete.md +115 -115
  34. package/src/components/ui/InputAutocomplete.vue +374 -349
  35. package/src/components/ui/InputColorPicker.md +51 -51
  36. package/src/components/ui/InputColorPicker.vue +151 -151
  37. package/src/components/ui/InputDatePicker.md +121 -121
  38. package/src/components/ui/InputDatePicker.vue +326 -326
  39. package/src/components/ui/InputTags.md +51 -51
  40. package/src/components/ui/InputTags.vue +184 -184
  41. package/src/components/ui/InputTimePicker.md +25 -25
  42. package/src/components/ui/InputTimePicker.vue +253 -253
  43. package/src/components/ui/InputUnits.md +20 -20
  44. package/src/components/ui/InputUnits.vue +257 -257
  45. package/src/components/ui/Lazy.md +37 -37
  46. package/src/components/ui/Lazy.vue +92 -92
  47. package/src/components/ui/Pagination.md +74 -74
  48. package/src/components/ui/Pagination.vue +138 -138
  49. package/src/components/ui/Paginator.md +34 -34
  50. package/src/components/ui/Paginator.vue +83 -83
  51. package/src/components/ui/Popover.md +34 -34
  52. package/src/components/ui/Popover.vue +274 -274
  53. package/src/components/ui/Popup.md +59 -59
  54. package/src/components/ui/Popup.vue +150 -150
  55. package/src/components/ui/ResponsiveContainer.md +58 -58
  56. package/src/components/ui/ResponsiveContainer.vue +99 -99
  57. package/src/components/ui/Select.md +187 -187
  58. package/src/components/ui/Select.vue +421 -421
  59. package/src/components/ui/TimePicker.md +50 -50
  60. package/src/components/ui/TimePicker.vue +252 -252
  61. package/src/components/ui/Tooltip.md +54 -54
  62. package/src/components/ui/Tooltip.vue +113 -113
  63. package/src/components/ui/WysiwygEditor/WysiwygEditor.d.ts +128 -128
  64. package/src/components/ui/WysiwygEditor/constants.js +273 -273
  65. package/src/components/ui/WysiwygEditor/extensions/blockquote.js +15 -15
  66. package/src/components/ui/WysiwygEditor/extensions/bold.js +15 -15
  67. package/src/components/ui/WysiwygEditor/extensions/bullet-list.js +15 -15
  68. package/src/components/ui/WysiwygEditor/extensions/code-block.js +13 -13
  69. package/src/components/ui/WysiwygEditor/extensions/code.js +13 -13
  70. package/src/components/ui/WysiwygEditor/extensions/font-size.js +34 -34
  71. package/src/components/ui/WysiwygEditor/extensions/formatting.js +14 -14
  72. package/src/components/ui/WysiwygEditor/extensions/heading.js +13 -13
  73. package/src/components/ui/WysiwygEditor/extensions/horizontal-rule.js +15 -15
  74. package/src/components/ui/WysiwygEditor/extensions/image.js +37 -33
  75. package/src/components/ui/WysiwygEditor/extensions/index.d.ts +32 -32
  76. package/src/components/ui/WysiwygEditor/extensions/index.js +32 -32
  77. package/src/components/ui/WysiwygEditor/extensions/italic.js +15 -15
  78. package/src/components/ui/WysiwygEditor/extensions/link.js +16 -16
  79. package/src/components/ui/WysiwygEditor/extensions/list-item.js +15 -15
  80. package/src/components/ui/WysiwygEditor/extensions/ordered-list.js +15 -15
  81. package/src/components/ui/WysiwygEditor/extensions/paragraph.js +23 -23
  82. package/src/components/ui/WysiwygEditor/extensions/strike.js +15 -15
  83. package/src/components/ui/WysiwygEditor/extensions/table-cell.js +13 -13
  84. package/src/components/ui/WysiwygEditor/extensions/table-header.js +15 -15
  85. package/src/components/ui/WysiwygEditor/extensions/table-row.js +15 -15
  86. package/src/components/ui/WysiwygEditor/extensions/table.js +29 -29
  87. package/src/components/ui/WysiwygEditor/extensions/text-align.js +6 -6
  88. package/src/components/ui/WysiwygEditor/extensions/text-style.js +12 -12
  89. package/src/components/ui/WysiwygEditor/extensions/underline.js +15 -15
  90. package/src/components/ui/WysiwygEditor/index.d.ts +4 -4
  91. package/src/components/ui/WysiwygEditor/index.js +4 -4
  92. package/src/components/ui/WysiwygEditor/renders/Button.vue +28 -28
  93. package/src/components/ui/WysiwygEditor/renders/ColorPicker.vue +41 -41
  94. package/src/components/ui/WysiwygEditor/renders/Image.vue +200 -162
  95. package/src/components/ui/WysiwygEditor/renders/InputAuto.vue +34 -34
  96. package/src/components/ui/WysiwygEditor/renders/InputUnits.vue +37 -37
  97. package/src/components/ui/WysiwygEditor/renders/Link.vue +82 -82
  98. package/src/components/ui/WysiwygEditor/renders/Select.vue +47 -47
  99. package/src/components/ui/WysiwygEditor/renders/ToolbarPopover.vue +49 -49
  100. package/src/components/ui/WysiwygEditor/renders/components/Popover.vue +15 -0
  101. package/src/components/ui/WysiwygEditor/renders/components/WithPopover.vue +35 -35
  102. package/src/components/ui/WysiwygEditor/renders/index.d.ts +8 -8
  103. package/src/components/ui/WysiwygEditor/renders/index.js +8 -8
  104. package/src/components/ui/WysiwygEditor/renders/mixins/RenderMixin.js +39 -39
  105. package/src/components/ui/WysiwygEditor/renders/mixins/index.js +1 -1
  106. package/src/components/ui/WysiwygEditor/tools-and-commands.js +709 -702
  107. package/src/components/ui/WysiwygEditor/utils.js +72 -72
  108. package/src/components/ui/WysiwygEditor.md +18 -18
  109. package/src/components/ui/WysiwygEditor.vue +266 -266
  110. package/src/components/ui/utils/FormComponent.js +107 -107
  111. package/src/components/ui/utils/Helpers.js +84 -84
  112. package/src/components/ui/utils/WithPopover.js +81 -81
  113. package/src/main.js +8 -8
  114. package/styleguide.config.js +37 -37
  115. package/vue.config.js +8 -8
  116. package/dist/js.png +0 -0
@@ -1,326 +1,326 @@
1
- <template>
2
- <div
3
- class="ui-input-date-picker form-elem"
4
- :class="cssClass"
5
- @focus="onRootFocus"
6
- tabindex="0"
7
- :data-popover="popoverTargetId"
8
- >
9
- <div class="ui-input-date-picker-wrapper d-flex flex-v-center w-100">
10
- <div style="flex: 1 0 0">
11
- <!--
12
- @slot Custom input slot
13
- @binding {String} id input id attribute value
14
- @binding {String} value input value
15
- @binding {String} valueLabel input value label
16
- @binding {Object} inputBinds input props (use v-bind)
17
- @binding {Object} inputEvents input events (use v-on)
18
- -->
19
- <slot
20
- name="input"
21
- v-bind="{ id: inputId, value, valueLabel, inputBinds, inputEvents }"
22
- >
23
- <input
24
- :id="inputId"
25
- class="ui-input-date-picker-input w-100"
26
- type="text"
27
- :value="valueLabel"
28
- v-bind="inputBinds"
29
- v-on="inputEvents"
30
- />
31
- </slot>
32
- </div>
33
- <!--
34
- @slot Custom clear icon slot
35
- @binding {Function} clear function that clears the value
36
- -->
37
- <slot name="clear" v-bind="{ clear }" v-if="value && value.length && allowClear">
38
- <div class="icon cursor-pointer w-auto h-auto mar-left-2" @click="clear">
39
- <i class="mdi mdi-close"></i>
40
- </div>
41
- </slot>
42
- <!--
43
- @slot Icon slot
44
- @binding {Function} toggle function that toggles the datepicker
45
- -->
46
- <slot name="icon" v-bind="{ toggle: togglePopover }">
47
- <div class="icon cursor-pointer w-auto h-auto mar-left-2" @click="togglePopover">
48
- <i class="mdi mdi-calendar"></i>
49
- </div>
50
- </slot>
51
- </div>
52
- <ui-popover :show.sync="popoverShow" v-bind="popoverOptions">
53
- <date-picker
54
- class="ui-input-date-picker-dp pull-left"
55
- @change="onDpChange"
56
- @set-date="onDpSetDate"
57
- v-bind="{ value: date, ...datepicker }"
58
- >
59
- <template #header="scope">
60
- <!--
61
- @slot @see [DatePicker.slots.header](#datepicker)
62
- -->
63
- <slot name="dp-header" v-bind="scope"></slot>
64
- </template>
65
- <template #cell-day="scope">
66
- <!--
67
- @slot @see [DatePicker.slots.cell-day](#datepicker)
68
- -->
69
- <slot name="dp-cell-day" v-bind="scope"></slot>
70
- </template>
71
- <template #cell-date="scope">
72
- <!--
73
- @slot @see [DatePicker.slots.cell-date](#datepicker)
74
- -->
75
- <slot name="dp-cell-date" v-bind="scope"></slot>
76
- </template>
77
- <template #left>
78
- <!--
79
- @slot @see [DatePicker.slots.left](#datepicker)
80
- -->
81
- <slot name="dp-left"></slot>
82
- </template>
83
- <template #right>
84
- <!--
85
- @slot @see [DatePicker.slots.right](#datepicker)
86
- -->
87
- <slot name="dp-right"></slot>
88
- </template>
89
- </date-picker>
90
- </ui-popover>
91
- </div>
92
- </template>
93
- <style lang="less" scoped>
94
- .ui-input-date-picker {
95
- display: inline-flex;
96
- &-input {
97
- border: none;
98
- margin: 0;
99
- padding: 0;
100
- line-height: 1.5;
101
- color: inherit;
102
- background: transparent;
103
- outline: none;
104
- }
105
- }
106
- </style>
107
- <script>
108
- import DatePicker from './DatePicker.vue';
109
- import UiPopover from './Popover.vue';
110
- import FormComponent from './utils/FormComponent';
111
- import WithPopover from './utils/WithPopover';
112
- import { isDateValid } from './utils/Helpers';
113
-
114
- let lz = n => (n < 10 ? `0${n}` : `${n}`);
115
- export default {
116
- mixins: [FormComponent, WithPopover],
117
- components: { DatePicker, UiPopover },
118
- props: {
119
- /**
120
- * @model
121
- */
122
- value: {
123
- type: [String, Array],
124
- default: '',
125
- },
126
- /**
127
- * Whether the input is editable
128
- */
129
- editable: {
130
- type: Boolean,
131
- default: true,
132
- },
133
- /**
134
- * Allow clearing the date
135
- */
136
- allowClear: {
137
- type: Boolean,
138
- default: true,
139
- },
140
- /**
141
- * Datepicker options
142
- * @see [DatePicker.props](#datepicker)
143
- */
144
- datepicker: {
145
- type: Object,
146
- default() {
147
- return {};
148
- },
149
- },
150
- /**
151
- * Date range delimiter (only if datepicker.range = true)
152
- */
153
- delimiter: {
154
- type: String,
155
- default: ' – ',
156
- },
157
- /**
158
- * Function which parses date String -> Date
159
- * function(str:String):Date
160
- */
161
- toDate: {
162
- type: Function,
163
- default(str) {
164
- if (!str) {
165
- return null;
166
- }
167
- let mt = str.match(/^(\d{1,}).(\d{1,}).(\d{1,})$/);
168
- if (mt) {
169
- mt.shift();
170
- let [d, m, y] = mt.map(v => parseInt(v));
171
- if (d > 0 && m > 0 && y >= 0) {
172
- return new Date(y, m - 1, d);
173
- }
174
- }
175
- return null;
176
- },
177
- },
178
- /**
179
- * Function which formats date Date -> String
180
- * function(date:Date):String
181
- */
182
- toValue: {
183
- type: Function,
184
- default(date) {
185
- if (!isDateValid(date)) {
186
- return '';
187
- }
188
- return `${lz(date.getDate())}.${lz(date.getMonth() + 1)}.${lz(date.getFullYear())}`;
189
- },
190
- },
191
- },
192
- data() {
193
- return {
194
- date: null,
195
- inputBinds: {
196
- placeholder: this.placeholder,
197
- readonly: this.readonly || !this.editable,
198
- },
199
- inputEvents: {
200
- input: this.onInputInput,
201
- change: this.onInputChange,
202
- focus: this.onInputFocus,
203
- blur: this.onInputBlur,
204
- },
205
- inputValue: '',
206
- inputValueRaw: '',
207
- };
208
- },
209
- watch: {
210
- value: {
211
- handler(val) {
212
- this.inputValueRaw = val;
213
-
214
- if (this.isRange) {
215
- const d = Array.isArray(val) ? val.map(this.toDate) : [];
216
- const [s, e] = d;
217
- if (s && e && isDateValid(s) && isDateValid(e) && s < e) {
218
- this.date = d;
219
- } else {
220
- this.date = [];
221
- }
222
- } else {
223
- const d = this.toDate(val);
224
- this.date = isDateValid(d) ? d : null;
225
- }
226
- },
227
- immediate: true,
228
- },
229
- isRange(val) {
230
- /**
231
- * Input event
232
- * @property {String} date
233
- */
234
- this.$emit('input', val ? [] : '');
235
- },
236
- placeholder(placeholder) {
237
- this.inputBinds = { ...this.inputBinds, placeholder };
238
- },
239
- },
240
- computed: {
241
- isRange() {
242
- return !!this.datepicker.range;
243
- },
244
- valueLabel() {
245
- return Array.isArray(this.value) ? this.value.join(this.delimiter) : this.value;
246
- },
247
- },
248
- methods: {
249
- clear() {
250
- /**
251
- * Input event
252
- * @property {String} date
253
- */
254
- this.$emit('input', this.isRange ? [] : '');
255
- /**
256
- * Clear event
257
- */
258
- this.$emit('clear');
259
- },
260
- onRootFocus(e) {
261
- let input = this.getInputRef();
262
- input && input.focus();
263
- },
264
- onInputInput({ target }) {
265
- this.inputValueRaw = target.value;
266
- },
267
- onInputChange(e) {
268
- this.setDateFromString(e.target.value);
269
- },
270
- onInputFocus(e) {
271
- this.rootHasFocus = true;
272
- },
273
- onInputBlur(e) {
274
- this.rootHasFocus = false;
275
- this.setDateFromString(this.inputValueRaw);
276
- },
277
- onDpChange(date) {
278
- const model = Array.isArray(date) ? date.map(this.toValue) : this.toValue(date);
279
- /**
280
- * Input event
281
- * @property {String|Array} value
282
- */
283
- this.$emit('input', model);
284
- /**
285
- * Change event
286
- * @property {String|Array} value
287
- */
288
- this.$emit('change', model);
289
- },
290
- onDpSetDate(date) {
291
- /**
292
- * Set date event
293
- * @property {Date} date
294
- */
295
- this.$emit('set-date', date);
296
- },
297
- setDateFromString(value) {
298
- if (value == this.inputValue) {
299
- return;
300
- }
301
- this.inputValue = value;
302
-
303
- let model = null;
304
-
305
- if (this.isRange) {
306
- const d = value.split(this.delimiter).map(this.toDate);
307
- const [s, e] = d;
308
- model = isDateValid(s) && isDateValid(e) && s < e ? d.map(this.toValue) : [];
309
- } else {
310
- const d = this.toDate(value);
311
- model = isDateValid(d) ? this.toValue(d) : '';
312
- }
313
- /**
314
- * Input event
315
- * @property {String|Array} value
316
- */
317
- this.$emit('input', model);
318
- /**
319
- * Change event
320
- * @property {String|Array} value
321
- */
322
- this.$emit('change', model);
323
- },
324
- },
325
- };
326
- </script>
1
+ <template>
2
+ <div
3
+ class="ui-input-date-picker form-elem"
4
+ :class="cssClass"
5
+ @focus="onRootFocus"
6
+ tabindex="0"
7
+ :data-popover="popoverTargetId"
8
+ >
9
+ <div class="ui-input-date-picker-wrapper d-flex flex-v-center w-100">
10
+ <div style="flex: 1 0 0">
11
+ <!--
12
+ @slot Custom input slot
13
+ @binding {String} id input id attribute value
14
+ @binding {String} value input value
15
+ @binding {String} valueLabel input value label
16
+ @binding {Object} inputBinds input props (use v-bind)
17
+ @binding {Object} inputEvents input events (use v-on)
18
+ -->
19
+ <slot
20
+ name="input"
21
+ v-bind="{ id: inputId, value, valueLabel, inputBinds, inputEvents }"
22
+ >
23
+ <input
24
+ :id="inputId"
25
+ class="ui-input-date-picker-input w-100"
26
+ type="text"
27
+ :value="valueLabel"
28
+ v-bind="inputBinds"
29
+ v-on="inputEvents"
30
+ />
31
+ </slot>
32
+ </div>
33
+ <!--
34
+ @slot Custom clear icon slot
35
+ @binding {Function} clear function that clears the value
36
+ -->
37
+ <slot name="clear" v-bind="{ clear }" v-if="value && value.length && allowClear">
38
+ <div class="icon cursor-pointer w-auto h-auto mar-left-2" @click="clear">
39
+ <i class="mdi mdi-close"></i>
40
+ </div>
41
+ </slot>
42
+ <!--
43
+ @slot Icon slot
44
+ @binding {Function} toggle function that toggles the datepicker
45
+ -->
46
+ <slot name="icon" v-bind="{ toggle: togglePopover }">
47
+ <div class="icon cursor-pointer w-auto h-auto mar-left-2" @click="togglePopover">
48
+ <i class="mdi mdi-calendar"></i>
49
+ </div>
50
+ </slot>
51
+ </div>
52
+ <ui-popover :show.sync="popoverShow" v-bind="popoverOptions">
53
+ <date-picker
54
+ class="ui-input-date-picker-dp pull-left"
55
+ @change="onDpChange"
56
+ @set-date="onDpSetDate"
57
+ v-bind="{ value: date, ...datepicker }"
58
+ >
59
+ <template #header="scope">
60
+ <!--
61
+ @slot @see [DatePicker.slots.header](#datepicker)
62
+ -->
63
+ <slot name="dp-header" v-bind="scope"></slot>
64
+ </template>
65
+ <template #cell-day="scope">
66
+ <!--
67
+ @slot @see [DatePicker.slots.cell-day](#datepicker)
68
+ -->
69
+ <slot name="dp-cell-day" v-bind="scope"></slot>
70
+ </template>
71
+ <template #cell-date="scope">
72
+ <!--
73
+ @slot @see [DatePicker.slots.cell-date](#datepicker)
74
+ -->
75
+ <slot name="dp-cell-date" v-bind="scope"></slot>
76
+ </template>
77
+ <template #left>
78
+ <!--
79
+ @slot @see [DatePicker.slots.left](#datepicker)
80
+ -->
81
+ <slot name="dp-left"></slot>
82
+ </template>
83
+ <template #right>
84
+ <!--
85
+ @slot @see [DatePicker.slots.right](#datepicker)
86
+ -->
87
+ <slot name="dp-right"></slot>
88
+ </template>
89
+ </date-picker>
90
+ </ui-popover>
91
+ </div>
92
+ </template>
93
+ <style lang="less" scoped>
94
+ .ui-input-date-picker {
95
+ display: inline-flex;
96
+ &-input {
97
+ border: none;
98
+ margin: 0;
99
+ padding: 0;
100
+ line-height: 1.5;
101
+ color: inherit;
102
+ background: transparent;
103
+ outline: none;
104
+ }
105
+ }
106
+ </style>
107
+ <script>
108
+ import DatePicker from './DatePicker.vue';
109
+ import UiPopover from './Popover.vue';
110
+ import FormComponent from './utils/FormComponent';
111
+ import WithPopover from './utils/WithPopover';
112
+ import { isDateValid } from './utils/Helpers';
113
+
114
+ let lz = n => (n < 10 ? `0${n}` : `${n}`);
115
+ export default {
116
+ mixins: [FormComponent, WithPopover],
117
+ components: { DatePicker, UiPopover },
118
+ props: {
119
+ /**
120
+ * @model
121
+ */
122
+ value: {
123
+ type: [String, Array],
124
+ default: '',
125
+ },
126
+ /**
127
+ * Whether the input is editable
128
+ */
129
+ editable: {
130
+ type: Boolean,
131
+ default: true,
132
+ },
133
+ /**
134
+ * Allow clearing the date
135
+ */
136
+ allowClear: {
137
+ type: Boolean,
138
+ default: true,
139
+ },
140
+ /**
141
+ * Datepicker options
142
+ * @see [DatePicker.props](#datepicker)
143
+ */
144
+ datepicker: {
145
+ type: Object,
146
+ default() {
147
+ return {};
148
+ },
149
+ },
150
+ /**
151
+ * Date range delimiter (only if datepicker.range = true)
152
+ */
153
+ delimiter: {
154
+ type: String,
155
+ default: ' – ',
156
+ },
157
+ /**
158
+ * Function which parses date String -> Date
159
+ * function(str:String):Date
160
+ */
161
+ toDate: {
162
+ type: Function,
163
+ default(str) {
164
+ if (!str) {
165
+ return null;
166
+ }
167
+ let mt = str.match(/^(\d{1,}).(\d{1,}).(\d{1,})$/);
168
+ if (mt) {
169
+ mt.shift();
170
+ let [d, m, y] = mt.map(v => parseInt(v));
171
+ if (d > 0 && m > 0 && y >= 0) {
172
+ return new Date(y, m - 1, d);
173
+ }
174
+ }
175
+ return null;
176
+ },
177
+ },
178
+ /**
179
+ * Function which formats date Date -> String
180
+ * function(date:Date):String
181
+ */
182
+ toValue: {
183
+ type: Function,
184
+ default(date) {
185
+ if (!isDateValid(date)) {
186
+ return '';
187
+ }
188
+ return `${lz(date.getDate())}.${lz(date.getMonth() + 1)}.${lz(date.getFullYear())}`;
189
+ },
190
+ },
191
+ },
192
+ data() {
193
+ return {
194
+ date: null,
195
+ inputBinds: {
196
+ placeholder: this.placeholder,
197
+ readonly: this.readonly || !this.editable,
198
+ },
199
+ inputEvents: {
200
+ input: this.onInputInput,
201
+ change: this.onInputChange,
202
+ focus: this.onInputFocus,
203
+ blur: this.onInputBlur,
204
+ },
205
+ inputValue: '',
206
+ inputValueRaw: '',
207
+ };
208
+ },
209
+ watch: {
210
+ value: {
211
+ handler(val) {
212
+ this.inputValueRaw = val;
213
+
214
+ if (this.isRange) {
215
+ const d = Array.isArray(val) ? val.map(this.toDate) : [];
216
+ const [s, e] = d;
217
+ if (s && e && isDateValid(s) && isDateValid(e) && s < e) {
218
+ this.date = d;
219
+ } else {
220
+ this.date = [];
221
+ }
222
+ } else {
223
+ const d = this.toDate(val);
224
+ this.date = isDateValid(d) ? d : null;
225
+ }
226
+ },
227
+ immediate: true,
228
+ },
229
+ isRange(val) {
230
+ /**
231
+ * Input event
232
+ * @property {String} date
233
+ */
234
+ this.$emit('input', val ? [] : '');
235
+ },
236
+ placeholder(placeholder) {
237
+ this.inputBinds = { ...this.inputBinds, placeholder };
238
+ },
239
+ },
240
+ computed: {
241
+ isRange() {
242
+ return !!this.datepicker.range;
243
+ },
244
+ valueLabel() {
245
+ return Array.isArray(this.value) ? this.value.join(this.delimiter) : this.value;
246
+ },
247
+ },
248
+ methods: {
249
+ clear() {
250
+ /**
251
+ * Input event
252
+ * @property {String} date
253
+ */
254
+ this.$emit('input', this.isRange ? [] : '');
255
+ /**
256
+ * Clear event
257
+ */
258
+ this.$emit('clear');
259
+ },
260
+ onRootFocus(e) {
261
+ let input = this.getInputRef();
262
+ input && input.focus();
263
+ },
264
+ onInputInput({ target }) {
265
+ this.inputValueRaw = target.value;
266
+ },
267
+ onInputChange(e) {
268
+ this.setDateFromString(e.target.value);
269
+ },
270
+ onInputFocus(e) {
271
+ this.rootHasFocus = true;
272
+ },
273
+ onInputBlur(e) {
274
+ this.rootHasFocus = false;
275
+ this.setDateFromString(this.inputValueRaw);
276
+ },
277
+ onDpChange(date) {
278
+ const model = Array.isArray(date) ? date.map(this.toValue) : this.toValue(date);
279
+ /**
280
+ * Input event
281
+ * @property {String|Array} value
282
+ */
283
+ this.$emit('input', model);
284
+ /**
285
+ * Change event
286
+ * @property {String|Array} value
287
+ */
288
+ this.$emit('change', model);
289
+ },
290
+ onDpSetDate(date) {
291
+ /**
292
+ * Set date event
293
+ * @property {Date} date
294
+ */
295
+ this.$emit('set-date', date);
296
+ },
297
+ setDateFromString(value) {
298
+ if (value == this.inputValue) {
299
+ return;
300
+ }
301
+ this.inputValue = value;
302
+
303
+ let model = null;
304
+
305
+ if (this.isRange) {
306
+ const d = value.split(this.delimiter).map(this.toDate);
307
+ const [s, e] = d;
308
+ model = isDateValid(s) && isDateValid(e) && s < e ? d.map(this.toValue) : [];
309
+ } else {
310
+ const d = this.toDate(value);
311
+ model = isDateValid(d) ? this.toValue(d) : '';
312
+ }
313
+ /**
314
+ * Input event
315
+ * @property {String|Array} value
316
+ */
317
+ this.$emit('input', model);
318
+ /**
319
+ * Change event
320
+ * @property {String|Array} value
321
+ */
322
+ this.$emit('change', model);
323
+ },
324
+ },
325
+ };
326
+ </script>