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,50 +1,50 @@
1
- Simple example
2
-
3
- ```vue
4
- <template>
5
- <div class="pad-l5">
6
- <p>
7
- <input
8
- class="input input-small"
9
- type="number"
10
- v-model.number="model.h"
11
- v-bind="inputs.h"
12
- style="width:4rem"
13
- />
14
- <span>:</span>
15
- <input
16
- class="input input-small"
17
- type="number"
18
- v-model.number="model.m"
19
- v-bind="inputs.m"
20
- style="width:4rem"
21
- />
22
- </p>
23
- <p>value: {{ model }}</p>
24
- <time-picker v-model="model" v-bind="props" style="width:10rem"></time-picker>
25
- </div>
26
- </template>
27
- <script>
28
- export default {
29
- data() {
30
- return {
31
- model: { h: 18, m: 50 },
32
- props: {
33
- step: { h: 1, m: 10 },
34
- min: { h: 10, m: 0 },
35
- max: { h: 18, m: 59 },
36
- },
37
- };
38
- },
39
- computed: {
40
- inputs() {
41
- const { step, min, max } = this.props;
42
- return {
43
- h: { step: step.h, min: min.h, max: max.h },
44
- m: { step: step.m, min: min.m, max: max.m },
45
- };
46
- },
47
- },
48
- };
49
- </script>
50
- ```
1
+ Simple example
2
+
3
+ ```vue
4
+ <template>
5
+ <div class="pad-l5">
6
+ <p>
7
+ <input
8
+ class="input input-small"
9
+ type="number"
10
+ v-model.number="model.h"
11
+ v-bind="inputs.h"
12
+ style="width:4rem"
13
+ />
14
+ <span>:</span>
15
+ <input
16
+ class="input input-small"
17
+ type="number"
18
+ v-model.number="model.m"
19
+ v-bind="inputs.m"
20
+ style="width:4rem"
21
+ />
22
+ </p>
23
+ <p>value: {{ model }}</p>
24
+ <time-picker v-model="model" v-bind="props" style="width:10rem"></time-picker>
25
+ </div>
26
+ </template>
27
+ <script>
28
+ export default {
29
+ data() {
30
+ return {
31
+ model: { h: 18, m: 50 },
32
+ props: {
33
+ step: { h: 1, m: 10 },
34
+ min: { h: 10, m: 0 },
35
+ max: { h: 18, m: 59 },
36
+ },
37
+ };
38
+ },
39
+ computed: {
40
+ inputs() {
41
+ const { step, min, max } = this.props;
42
+ return {
43
+ h: { step: step.h, min: min.h, max: max.h },
44
+ m: { step: step.m, min: min.m, max: max.m },
45
+ };
46
+ },
47
+ },
48
+ };
49
+ </script>
50
+ ```
@@ -1,252 +1,252 @@
1
- <template>
2
- <div class="ui-time-picker panel">
3
- <ui-datalist
4
- class="ui-time-picker-datalist shadow-none radius-none w-6-12"
5
- v-bind="{ cursorIndex: hCursorIndex, options: hourOptions }"
6
- >
7
- <template #header>
8
- <!--
9
- @slot Hour label slot
10
- -->
11
- <slot name="hour-label">
12
- <div class="bg-primary color-white text-small text-center pad-3">Час</div>
13
- </slot>
14
- </template>
15
- <template #option="{ option, index, cursorIndex }">
16
- <!--
17
- @slot Hour option slot
18
- @binding {Boolean} isActive whether the option is active (selected)
19
- @binding {Number} option the hour option
20
- @binding {Number} index options' index
21
- @binding {Number} cursorIndex the current cursor index position
22
- @binding {Function} select function which selects the option function(option)
23
- -->
24
- <slot
25
- name="hour-option"
26
- v-bind="{
27
- isActive: option === h,
28
- option,
29
- index,
30
- cursorIndex,
31
- select: selectHour,
32
- }"
33
- >
34
- <li :class="{ active: option === h }" @click="selectHour(option)">
35
- <div class="text-small text-center text-truncate">{{ lz(option) }}</div>
36
- </li>
37
- </slot>
38
- </template>
39
- </ui-datalist>
40
- <ui-datalist
41
- class="ui-time-picker-datalist shadow-none radius-none w-6-12"
42
- v-bind="{ cursorIndex: mCursorIndex, options: minOptions }"
43
- >
44
- <template #header>
45
- <!--
46
- @slot Minute label slot
47
- -->
48
- <slot name="min-label">
49
- <div class="bg-primary color-white text-small text-center pad-3">Мин</div>
50
- </slot>
51
- </template>
52
- <template #option="{ option, index, cursorIndex }">
53
- <!--
54
- @slot Minute option slot
55
- @binding {Boolean} isActive whether the option is active (selected)
56
- @binding {Number} option the min option
57
- @binding {Number} index options' index
58
- @binding {Number} cursorIndex the current cursor index position
59
- @binding {Function} select function which selects the option function(option)
60
- -->
61
- <slot
62
- name="min-option"
63
- v-bind="{
64
- isActive: option === m,
65
- option,
66
- index,
67
- cursorIndex,
68
- select: selectMin,
69
- }"
70
- >
71
- <li :class="{ active: option === m }" @click="selectMin(option)">
72
- <div class="text-small text-center text-truncate">{{ lz(option) }}</div>
73
- </li>
74
- </slot>
75
- </template>
76
- </ui-datalist>
77
- </div>
78
- </template>
79
- <style lang="less" scoped>
80
- .ui-time-picker {
81
- --ui-time-picker-item-size: calc(1rem + var(--font-size-smaller) * 1.5);
82
- --ui-time-picker-datalist-min-items: 3;
83
- --ui-time-picker-datalist-max-items: 5;
84
- display: inline-flex;
85
- overflow: hidden;
86
- &-datalist {
87
- z-index: auto;
88
- min-width: 3em;
89
- ::v-deep > ul {
90
- min-height: calc(
91
- var(--ui-time-picker-item-size) * var(--ui-time-picker-datalist-min-items)
92
- );
93
- max-height: calc(
94
- var(--ui-time-picker-item-size) * var(--ui-time-picker-datalist-max-items)
95
- );
96
- scroll-behavior: smooth;
97
- }
98
- }
99
- }
100
- </style>
101
- <script>
102
- import UiDatalist from './Datalist.vue';
103
-
104
- export default {
105
- components: { UiDatalist },
106
- props: {
107
- /**
108
- * @model Object { h:Number, m:Number } where h stands for 'hour'; m stands for 'minute'
109
- */
110
- value: {
111
- type: Object,
112
- default() {
113
- return null;
114
- },
115
- },
116
- /**
117
- * Hour/minute step size Object (works similar to how input step attribute works)
118
- * { h:Number, m:Number } where h stands for 'hour step'; m stands for 'minute step'
119
- */
120
- step: {
121
- type: Object,
122
- default() {
123
- return { h: 1, m: 15 };
124
- },
125
- },
126
- /**
127
- * Hour/minute min limit Object (works similar to how input min attribute works)
128
- * { h:Number, m:Number } where h stands for 'min hour'; m stands for 'min minute'
129
- */
130
- min: {
131
- type: Object,
132
- default() {
133
- return { h: 0, m: 0 };
134
- },
135
- },
136
- /**
137
- * Hour/minute max limit Object (works similar to how input max attribute works)
138
- * { h:Number, m:Number } where h stands for 'max hour'; m stands for 'max minute'
139
- */
140
- max: {
141
- type: Object,
142
- default() {
143
- return { h: 23, m: 59 };
144
- },
145
- },
146
- /**
147
- * Hour/minute cursor indexes Object
148
- * { h:Number, m:Number } where h stands for 'hour cursor index'; m stands for 'minute cursor index'
149
- */
150
- cursorIndex: {
151
- type: Object,
152
- default() {
153
- return { h: 0, m: 0 };
154
- },
155
- },
156
- },
157
- data() {
158
- return {
159
- h: -1,
160
- m: -1,
161
- hCursorIndex: -1,
162
- mCursorIndex: -1,
163
- lz(n) {
164
- return n < 10 ? `0${n}` : `${n}`;
165
- },
166
- };
167
- },
168
- watch: {
169
- value: {
170
- handler(val) {
171
- this.$nextTick(() => {
172
- this.m = val ? val.m : -1;
173
- this.h = val ? val.h : -1;
174
- });
175
- },
176
- immediate: true,
177
- deep: true,
178
- },
179
- h: {
180
- handler(val) {
181
- this.hCursorIndex = this.hourOptions.findIndex(i => i === val);
182
- },
183
- immediate: true,
184
- },
185
- m: {
186
- handler(val) {
187
- this.mCursorIndex = this.minOptions.findIndex(i => i === val);
188
- },
189
- immediate: true,
190
- },
191
- cursorIndex: {
192
- handler({ h, m }) {
193
- h = parseInt(h);
194
- m = parseInt(m);
195
- this.hCursorIndex = isNaN(h) ? this.hCursorIndex : h;
196
- this.mCursorIndex = isNaN(m) ? this.mCursorIndex : m;
197
- },
198
- immediate: true,
199
- deep: true,
200
- },
201
- },
202
- computed: {
203
- hourOptions() {
204
- let a = [];
205
- let n = Math.floor(24 / this.step.h);
206
- for (let i = 0; i < n; ++i) {
207
- let v = i * this.step.h;
208
- if (v >= this.min.h && v <= this.max.h) {
209
- a.push(v);
210
- }
211
- }
212
- return a;
213
- },
214
- minOptions() {
215
- let a = [];
216
- let n = Math.floor(60 / this.step.m);
217
- for (let i = 0; i < n; ++i) {
218
- let v = i * this.step.m;
219
- if (v >= this.min.m && v <= this.max.m) {
220
- a.push(v);
221
- }
222
- }
223
- return a;
224
- },
225
- },
226
- methods: {
227
- selectHour(val) {
228
- this.h = val;
229
- this._triggerValueChange();
230
- },
231
- selectMin(val) {
232
- this.m = val;
233
- this._triggerValueChange();
234
- },
235
- _triggerValueChange() {
236
- if (this.h >= 0 && this.m >= 0) {
237
- let obj = { h: this.h, m: this.m };
238
- /**
239
- * Input event
240
- * @property {Object} option
241
- */
242
- this.$emit('input', obj);
243
- /**
244
- * Change event
245
- * @property {Object} option
246
- */
247
- this.$emit('change', obj);
248
- }
249
- },
250
- },
251
- };
252
- </script>
1
+ <template>
2
+ <div class="ui-time-picker panel">
3
+ <ui-datalist
4
+ class="ui-time-picker-datalist shadow-none radius-none w-6-12"
5
+ v-bind="{ cursorIndex: hCursorIndex, options: hourOptions }"
6
+ >
7
+ <template #header>
8
+ <!--
9
+ @slot Hour label slot
10
+ -->
11
+ <slot name="hour-label">
12
+ <div class="bg-primary color-white text-small text-center pad-3">Час</div>
13
+ </slot>
14
+ </template>
15
+ <template #option="{ option, index, cursorIndex }">
16
+ <!--
17
+ @slot Hour option slot
18
+ @binding {Boolean} isActive whether the option is active (selected)
19
+ @binding {Number} option the hour option
20
+ @binding {Number} index options' index
21
+ @binding {Number} cursorIndex the current cursor index position
22
+ @binding {Function} select function which selects the option function(option)
23
+ -->
24
+ <slot
25
+ name="hour-option"
26
+ v-bind="{
27
+ isActive: option === h,
28
+ option,
29
+ index,
30
+ cursorIndex,
31
+ select: selectHour,
32
+ }"
33
+ >
34
+ <li :class="{ active: option === h }" @click="selectHour(option)">
35
+ <div class="text-small text-center text-truncate">{{ lz(option) }}</div>
36
+ </li>
37
+ </slot>
38
+ </template>
39
+ </ui-datalist>
40
+ <ui-datalist
41
+ class="ui-time-picker-datalist shadow-none radius-none w-6-12"
42
+ v-bind="{ cursorIndex: mCursorIndex, options: minOptions }"
43
+ >
44
+ <template #header>
45
+ <!--
46
+ @slot Minute label slot
47
+ -->
48
+ <slot name="min-label">
49
+ <div class="bg-primary color-white text-small text-center pad-3">Мин</div>
50
+ </slot>
51
+ </template>
52
+ <template #option="{ option, index, cursorIndex }">
53
+ <!--
54
+ @slot Minute option slot
55
+ @binding {Boolean} isActive whether the option is active (selected)
56
+ @binding {Number} option the min option
57
+ @binding {Number} index options' index
58
+ @binding {Number} cursorIndex the current cursor index position
59
+ @binding {Function} select function which selects the option function(option)
60
+ -->
61
+ <slot
62
+ name="min-option"
63
+ v-bind="{
64
+ isActive: option === m,
65
+ option,
66
+ index,
67
+ cursorIndex,
68
+ select: selectMin,
69
+ }"
70
+ >
71
+ <li :class="{ active: option === m }" @click="selectMin(option)">
72
+ <div class="text-small text-center text-truncate">{{ lz(option) }}</div>
73
+ </li>
74
+ </slot>
75
+ </template>
76
+ </ui-datalist>
77
+ </div>
78
+ </template>
79
+ <style lang="less" scoped>
80
+ .ui-time-picker {
81
+ --ui-time-picker-item-size: calc(1rem + var(--font-size-smaller) * 1.5);
82
+ --ui-time-picker-datalist-min-items: 3;
83
+ --ui-time-picker-datalist-max-items: 5;
84
+ display: inline-flex;
85
+ overflow: hidden;
86
+ &-datalist {
87
+ z-index: auto;
88
+ min-width: 3em;
89
+ ::v-deep > ul {
90
+ min-height: calc(
91
+ var(--ui-time-picker-item-size) * var(--ui-time-picker-datalist-min-items)
92
+ );
93
+ max-height: calc(
94
+ var(--ui-time-picker-item-size) * var(--ui-time-picker-datalist-max-items)
95
+ );
96
+ scroll-behavior: smooth;
97
+ }
98
+ }
99
+ }
100
+ </style>
101
+ <script>
102
+ import UiDatalist from './Datalist.vue';
103
+
104
+ export default {
105
+ components: { UiDatalist },
106
+ props: {
107
+ /**
108
+ * @model Object { h:Number, m:Number } where h stands for 'hour'; m stands for 'minute'
109
+ */
110
+ value: {
111
+ type: Object,
112
+ default() {
113
+ return null;
114
+ },
115
+ },
116
+ /**
117
+ * Hour/minute step size Object (works similar to how input step attribute works)
118
+ * { h:Number, m:Number } where h stands for 'hour step'; m stands for 'minute step'
119
+ */
120
+ step: {
121
+ type: Object,
122
+ default() {
123
+ return { h: 1, m: 15 };
124
+ },
125
+ },
126
+ /**
127
+ * Hour/minute min limit Object (works similar to how input min attribute works)
128
+ * { h:Number, m:Number } where h stands for 'min hour'; m stands for 'min minute'
129
+ */
130
+ min: {
131
+ type: Object,
132
+ default() {
133
+ return { h: 0, m: 0 };
134
+ },
135
+ },
136
+ /**
137
+ * Hour/minute max limit Object (works similar to how input max attribute works)
138
+ * { h:Number, m:Number } where h stands for 'max hour'; m stands for 'max minute'
139
+ */
140
+ max: {
141
+ type: Object,
142
+ default() {
143
+ return { h: 23, m: 59 };
144
+ },
145
+ },
146
+ /**
147
+ * Hour/minute cursor indexes Object
148
+ * { h:Number, m:Number } where h stands for 'hour cursor index'; m stands for 'minute cursor index'
149
+ */
150
+ cursorIndex: {
151
+ type: Object,
152
+ default() {
153
+ return { h: 0, m: 0 };
154
+ },
155
+ },
156
+ },
157
+ data() {
158
+ return {
159
+ h: -1,
160
+ m: -1,
161
+ hCursorIndex: -1,
162
+ mCursorIndex: -1,
163
+ lz(n) {
164
+ return n < 10 ? `0${n}` : `${n}`;
165
+ },
166
+ };
167
+ },
168
+ watch: {
169
+ value: {
170
+ handler(val) {
171
+ this.$nextTick(() => {
172
+ this.m = val ? val.m : -1;
173
+ this.h = val ? val.h : -1;
174
+ });
175
+ },
176
+ immediate: true,
177
+ deep: true,
178
+ },
179
+ h: {
180
+ handler(val) {
181
+ this.hCursorIndex = this.hourOptions.findIndex(i => i === val);
182
+ },
183
+ immediate: true,
184
+ },
185
+ m: {
186
+ handler(val) {
187
+ this.mCursorIndex = this.minOptions.findIndex(i => i === val);
188
+ },
189
+ immediate: true,
190
+ },
191
+ cursorIndex: {
192
+ handler({ h, m }) {
193
+ h = parseInt(h);
194
+ m = parseInt(m);
195
+ this.hCursorIndex = isNaN(h) ? this.hCursorIndex : h;
196
+ this.mCursorIndex = isNaN(m) ? this.mCursorIndex : m;
197
+ },
198
+ immediate: true,
199
+ deep: true,
200
+ },
201
+ },
202
+ computed: {
203
+ hourOptions() {
204
+ let a = [];
205
+ let n = Math.floor(24 / this.step.h);
206
+ for (let i = 0; i < n; ++i) {
207
+ let v = i * this.step.h;
208
+ if (v >= this.min.h && v <= this.max.h) {
209
+ a.push(v);
210
+ }
211
+ }
212
+ return a;
213
+ },
214
+ minOptions() {
215
+ let a = [];
216
+ let n = Math.floor(60 / this.step.m);
217
+ for (let i = 0; i < n; ++i) {
218
+ let v = i * this.step.m;
219
+ if (v >= this.min.m && v <= this.max.m) {
220
+ a.push(v);
221
+ }
222
+ }
223
+ return a;
224
+ },
225
+ },
226
+ methods: {
227
+ selectHour(val) {
228
+ this.h = val;
229
+ this._triggerValueChange();
230
+ },
231
+ selectMin(val) {
232
+ this.m = val;
233
+ this._triggerValueChange();
234
+ },
235
+ _triggerValueChange() {
236
+ if (this.h >= 0 && this.m >= 0) {
237
+ let obj = { h: this.h, m: this.m };
238
+ /**
239
+ * Input event
240
+ * @property {Object} option
241
+ */
242
+ this.$emit('input', obj);
243
+ /**
244
+ * Change event
245
+ * @property {Object} option
246
+ */
247
+ this.$emit('change', obj);
248
+ }
249
+ },
250
+ },
251
+ };
252
+ </script>