buefy 0.9.26 → 0.9.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 (259) hide show
  1. package/README.md +3 -1
  2. package/dist/buefy.css +15904 -0
  3. package/dist/buefy.esm.js +17883 -0
  4. package/dist/buefy.esm.min.js +2 -0
  5. package/dist/buefy.js +17967 -0
  6. package/dist/buefy.min.css +1 -0
  7. package/dist/buefy.min.js +2 -0
  8. package/dist/cjs/Autocomplete-7a39c5ce.js +673 -0
  9. package/dist/cjs/Button-01827709.js +114 -0
  10. package/dist/cjs/CheckRadioMixin-c910f2ed.js +45 -0
  11. package/dist/cjs/Checkbox-43f54cc7.js +70 -0
  12. package/dist/cjs/Datepicker-680659bc.js +1679 -0
  13. package/dist/cjs/DropdownItem-422f8c34.js +559 -0
  14. package/dist/cjs/Field-4557b10c.js +315 -0
  15. package/dist/cjs/FormElementMixin-193a88b8.js +163 -0
  16. package/dist/cjs/Icon-78961800.js +189 -0
  17. package/dist/cjs/Image-c4bcd9b3.js +299 -0
  18. package/dist/cjs/InjectedChildMixin-d6bf7f91.js +135 -0
  19. package/dist/cjs/Input-e5a72d97.js +248 -0
  20. package/dist/cjs/Loading-6f2c7075.js +150 -0
  21. package/dist/cjs/MessageMixin-8d959514.js +146 -0
  22. package/dist/cjs/Modal-4cf07210.js +278 -0
  23. package/dist/cjs/NoticeMixin-01121bd2.js +154 -0
  24. package/dist/cjs/Pagination-d6b3fb85.js +413 -0
  25. package/dist/cjs/Select-2b3879bc.js +100 -0
  26. package/dist/cjs/SlotComponent-4fb48389.js +53 -0
  27. package/dist/cjs/TabbedChildMixin-907cad32.js +222 -0
  28. package/dist/cjs/Tag-437f65fb.js +154 -0
  29. package/dist/cjs/Timepicker-498fa02b.js +67 -0
  30. package/dist/cjs/TimepickerMixin-6c1a4ab4.js +661 -0
  31. package/dist/cjs/Tooltip-c1df7ee3.js +370 -0
  32. package/dist/cjs/_rollupPluginBabelHelpers-8b2e54ad.js +365 -0
  33. package/dist/cjs/autocomplete.js +22 -0
  34. package/dist/cjs/breadcrumb.js +139 -0
  35. package/dist/cjs/button.js +20 -0
  36. package/dist/cjs/carousel.js +662 -0
  37. package/dist/cjs/checkbox.js +86 -0
  38. package/dist/cjs/clockpicker.js +461 -0
  39. package/dist/cjs/collapse.js +128 -0
  40. package/dist/cjs/colorpicker.js +23 -0
  41. package/dist/cjs/config-8cfb5a4a.js +81 -0
  42. package/dist/cjs/config.js +18 -0
  43. package/dist/cjs/datepicker.js +27 -0
  44. package/dist/cjs/datetimepicker.js +377 -0
  45. package/dist/cjs/dialog.js +308 -0
  46. package/dist/cjs/dropdown.js +23 -0
  47. package/dist/cjs/field.js +18 -0
  48. package/dist/cjs/helpers.js +375 -0
  49. package/dist/cjs/icon.js +19 -0
  50. package/dist/cjs/image.js +19 -0
  51. package/dist/cjs/index-99d1c930.js +1633 -0
  52. package/dist/cjs/index.js +216 -0
  53. package/dist/cjs/input.js +21 -0
  54. package/dist/cjs/loading.js +38 -0
  55. package/dist/cjs/menu.js +304 -0
  56. package/dist/cjs/message.js +67 -0
  57. package/dist/cjs/modal.js +59 -0
  58. package/dist/cjs/navbar.js +679 -0
  59. package/dist/cjs/notification.js +181 -0
  60. package/dist/cjs/numberinput.js +278 -0
  61. package/dist/cjs/pagination.js +22 -0
  62. package/dist/cjs/plugins-7f41b028.js +94 -0
  63. package/dist/cjs/progress.js +239 -0
  64. package/dist/cjs/radio.js +130 -0
  65. package/dist/cjs/rate.js +156 -0
  66. package/dist/cjs/select.js +21 -0
  67. package/dist/cjs/sidebar.js +303 -0
  68. package/dist/cjs/skeleton.js +111 -0
  69. package/dist/cjs/slider.js +603 -0
  70. package/dist/cjs/snackbar.js +132 -0
  71. package/dist/cjs/ssr-20dba236.js +10 -0
  72. package/dist/cjs/steps.js +278 -0
  73. package/dist/cjs/switch.js +139 -0
  74. package/dist/cjs/table.js +1695 -0
  75. package/dist/cjs/tabs.js +214 -0
  76. package/dist/cjs/tag.js +70 -0
  77. package/dist/cjs/taginput.js +331 -0
  78. package/dist/cjs/timepicker.js +28 -0
  79. package/dist/cjs/toast.js +106 -0
  80. package/dist/cjs/tooltip.js +19 -0
  81. package/dist/cjs/trapFocus-261420b0.js +49 -0
  82. package/dist/cjs/upload.js +205 -0
  83. package/dist/components/autocomplete/index.js +1620 -0
  84. package/dist/components/autocomplete/index.min.js +2 -0
  85. package/dist/components/breadcrumb/index.js +297 -0
  86. package/dist/components/breadcrumb/index.min.js +2 -0
  87. package/dist/components/button/index.js +569 -0
  88. package/dist/components/button/index.min.js +2 -0
  89. package/dist/components/carousel/index.js +1629 -0
  90. package/dist/components/carousel/index.min.js +2 -0
  91. package/dist/components/checkbox/index.js +279 -0
  92. package/dist/components/checkbox/index.min.js +2 -0
  93. package/dist/components/clockpicker/index.js +3131 -0
  94. package/dist/components/clockpicker/index.min.js +2 -0
  95. package/dist/components/collapse/index.js +217 -0
  96. package/dist/components/collapse/index.min.js +2 -0
  97. package/dist/components/colorpicker/index.js +4249 -0
  98. package/dist/components/colorpicker/index.min.js +2 -0
  99. package/dist/components/datepicker/index.js +3845 -0
  100. package/dist/components/datepicker/index.min.js +2 -0
  101. package/dist/components/datetimepicker/index.js +4902 -0
  102. package/dist/components/datetimepicker/index.min.js +2 -0
  103. package/dist/components/dialog/index.js +1168 -0
  104. package/dist/components/dialog/index.min.js +2 -0
  105. package/dist/components/dropdown/index.js +1043 -0
  106. package/dist/components/dropdown/index.min.js +2 -0
  107. package/dist/components/field/index.js +511 -0
  108. package/dist/components/field/index.min.js +2 -0
  109. package/dist/components/icon/index.js +463 -0
  110. package/dist/components/icon/index.min.js +2 -0
  111. package/dist/components/image/index.js +513 -0
  112. package/dist/components/image/index.min.js +2 -0
  113. package/dist/components/input/index.js +862 -0
  114. package/dist/components/input/index.min.js +2 -0
  115. package/dist/components/loading/index.js +366 -0
  116. package/dist/components/loading/index.min.js +2 -0
  117. package/dist/components/menu/index.js +748 -0
  118. package/dist/components/menu/index.min.js +2 -0
  119. package/dist/components/message/index.js +650 -0
  120. package/dist/components/message/index.min.js +2 -0
  121. package/dist/components/modal/index.js +624 -0
  122. package/dist/components/modal/index.min.js +2 -0
  123. package/dist/components/navbar/index.js +805 -0
  124. package/dist/components/navbar/index.min.js +2 -0
  125. package/dist/components/notification/index.js +923 -0
  126. package/dist/components/notification/index.min.js +2 -0
  127. package/dist/components/numberinput/index.js +1119 -0
  128. package/dist/components/numberinput/index.min.js +2 -0
  129. package/dist/components/pagination/index.js +868 -0
  130. package/dist/components/pagination/index.min.js +2 -0
  131. package/dist/components/progress/index.js +621 -0
  132. package/dist/components/progress/index.min.js +2 -0
  133. package/dist/components/radio/index.js +260 -0
  134. package/dist/components/radio/index.min.js +2 -0
  135. package/dist/components/rate/index.js +600 -0
  136. package/dist/components/rate/index.min.js +2 -0
  137. package/dist/components/select/index.js +715 -0
  138. package/dist/components/select/index.min.js +2 -0
  139. package/dist/components/sidebar/index.js +467 -0
  140. package/dist/components/sidebar/index.min.js +2 -0
  141. package/dist/components/skeleton/index.js +200 -0
  142. package/dist/components/skeleton/index.min.js +2 -0
  143. package/dist/components/slider/index.js +1264 -0
  144. package/dist/components/slider/index.min.js +2 -0
  145. package/dist/components/snackbar/index.js +527 -0
  146. package/dist/components/snackbar/index.min.js +2 -0
  147. package/dist/components/steps/index.js +1180 -0
  148. package/dist/components/steps/index.min.js +2 -0
  149. package/dist/components/switch/index.js +297 -0
  150. package/dist/components/switch/index.min.js +2 -0
  151. package/dist/components/table/index.js +3480 -0
  152. package/dist/components/table/index.min.js +2 -0
  153. package/dist/components/tabs/index.js +1116 -0
  154. package/dist/components/tabs/index.min.js +2 -0
  155. package/dist/components/tag/index.js +307 -0
  156. package/dist/components/tag/index.min.js +2 -0
  157. package/dist/components/taginput/index.js +2104 -0
  158. package/dist/components/taginput/index.min.js +2 -0
  159. package/dist/components/timepicker/index.js +2843 -0
  160. package/dist/components/timepicker/index.min.js +2 -0
  161. package/dist/components/toast/index.js +501 -0
  162. package/dist/components/toast/index.min.js +2 -0
  163. package/dist/components/tooltip/index.js +630 -0
  164. package/dist/components/tooltip/index.min.js +2 -0
  165. package/dist/components/upload/index.js +525 -0
  166. package/dist/components/upload/index.min.js +2 -0
  167. package/dist/esm/Autocomplete-1a6e8770.js +671 -0
  168. package/dist/esm/Button-521f6efc.js +112 -0
  169. package/dist/esm/CheckRadioMixin-e726a83c.js +43 -0
  170. package/dist/esm/Checkbox-1d02686e.js +68 -0
  171. package/dist/esm/Datepicker-0ae1e826.js +1677 -0
  172. package/dist/esm/DropdownItem-55682322.js +556 -0
  173. package/dist/esm/Field-3ceba31e.js +313 -0
  174. package/dist/esm/FormElementMixin-b223d3c7.js +161 -0
  175. package/dist/esm/Icon-60d47b31.js +187 -0
  176. package/dist/esm/Image-75808acb.js +297 -0
  177. package/dist/esm/InjectedChildMixin-b4220787.js +130 -0
  178. package/dist/esm/Input-20612b63.js +246 -0
  179. package/dist/esm/Loading-ae028ea5.js +148 -0
  180. package/dist/esm/MessageMixin-d577a9f5.js +144 -0
  181. package/dist/esm/Modal-7da7641f.js +276 -0
  182. package/dist/esm/NoticeMixin-bd6f61d9.js +152 -0
  183. package/dist/esm/Pagination-68f12c1e.js +409 -0
  184. package/dist/esm/Select-97781d4e.js +98 -0
  185. package/dist/esm/SlotComponent-8871a20f.js +51 -0
  186. package/dist/esm/TabbedChildMixin-bcb13767.js +219 -0
  187. package/dist/esm/Tag-6365aa46.js +152 -0
  188. package/dist/esm/Timepicker-38480bbc.js +65 -0
  189. package/dist/esm/TimepickerMixin-d736b0a9.js +659 -0
  190. package/dist/esm/Tooltip-d98a769c.js +368 -0
  191. package/dist/esm/_rollupPluginBabelHelpers-df313029.js +350 -0
  192. package/dist/esm/autocomplete.js +18 -0
  193. package/dist/esm/breadcrumb.js +133 -0
  194. package/dist/esm/button.js +16 -0
  195. package/dist/esm/carousel.js +655 -0
  196. package/dist/esm/checkbox.js +81 -0
  197. package/dist/esm/clockpicker.js +456 -0
  198. package/dist/esm/collapse.js +123 -0
  199. package/dist/esm/colorpicker.js +14 -0
  200. package/dist/esm/config-e7d4b9c2.js +78 -0
  201. package/dist/esm/config.js +14 -0
  202. package/dist/esm/datepicker.js +23 -0
  203. package/dist/esm/datetimepicker.js +372 -0
  204. package/dist/esm/dialog.js +302 -0
  205. package/dist/esm/dropdown.js +18 -0
  206. package/dist/esm/field.js +14 -0
  207. package/dist/esm/helpers.js +348 -0
  208. package/dist/esm/icon.js +15 -0
  209. package/dist/esm/image.js +15 -0
  210. package/dist/esm/index-903f63ea.js +1629 -0
  211. package/dist/esm/index.js +182 -0
  212. package/dist/esm/input.js +17 -0
  213. package/dist/esm/loading.js +33 -0
  214. package/dist/esm/menu.js +297 -0
  215. package/dist/esm/message.js +62 -0
  216. package/dist/esm/modal.js +54 -0
  217. package/dist/esm/navbar.js +672 -0
  218. package/dist/esm/notification.js +175 -0
  219. package/dist/esm/numberinput.js +273 -0
  220. package/dist/esm/pagination.js +17 -0
  221. package/dist/esm/plugins-218aea86.js +89 -0
  222. package/dist/esm/progress.js +233 -0
  223. package/dist/esm/radio.js +124 -0
  224. package/dist/esm/rate.js +151 -0
  225. package/dist/esm/select.js +17 -0
  226. package/dist/esm/sidebar.js +298 -0
  227. package/dist/esm/skeleton.js +106 -0
  228. package/dist/esm/slider.js +597 -0
  229. package/dist/esm/snackbar.js +126 -0
  230. package/dist/esm/ssr-b847d137.js +7 -0
  231. package/dist/esm/steps.js +272 -0
  232. package/dist/esm/switch.js +134 -0
  233. package/dist/esm/table.js +1689 -0
  234. package/dist/esm/tabs.js +208 -0
  235. package/dist/esm/tag.js +65 -0
  236. package/dist/esm/taginput.js +326 -0
  237. package/dist/esm/timepicker.js +24 -0
  238. package/dist/esm/toast.js +100 -0
  239. package/dist/esm/tooltip.js +15 -0
  240. package/dist/esm/trapFocus-f0736873.js +47 -0
  241. package/dist/esm/upload.js +200 -0
  242. package/dist/vetur/attributes.json +3238 -0
  243. package/dist/vetur/tags.json +1183 -0
  244. package/package.json +3 -3
  245. package/src/components/autocomplete/Autocomplete.spec.js +16 -0
  246. package/src/components/autocomplete/Autocomplete.vue +9 -3
  247. package/src/components/colorpicker/ColorpickerHSLRepresentationSquare.vue +2 -0
  248. package/src/components/colorpicker/ColorpickerHSLRepresentationTriangle.vue +2 -0
  249. package/src/components/dropdown/Dropdown.vue +51 -3
  250. package/src/components/numberinput/Numberinput.vue +4 -0
  251. package/src/components/sidebar/Sidebar.vue +1 -0
  252. package/src/components/slider/Slider.vue +7 -2
  253. package/src/components/slider/SliderThumb.vue +8 -0
  254. package/src/components/table/Table.vue +4 -1
  255. package/src/components/table/TableColumn.spec.js +51 -0
  256. package/src/components/table/TableColumn.vue +8 -1
  257. package/src/components/taginput/Taginput.vue +7 -2
  258. package/src/components/tooltip/Tooltip.vue +10 -3
  259. package/src/scss/components/_dropdown.scss +4 -2
@@ -0,0 +1,659 @@
1
+ import { F as FormElementMixin } from './FormElementMixin-b223d3c7.js';
2
+ import { isMobile, matchWithGroups } from './helpers.js';
3
+ import { c as config } from './config-e7d4b9c2.js';
4
+
5
+ var AM = 'AM';
6
+ var PM = 'PM';
7
+ var HOUR_FORMAT_24 = '24';
8
+ var HOUR_FORMAT_12 = '12';
9
+ var defaultTimeFormatter = function defaultTimeFormatter(date, vm) {
10
+ return vm.dtf.format(date);
11
+ };
12
+ var defaultTimeParser = function defaultTimeParser(timeString, vm) {
13
+ if (timeString) {
14
+ var d = null;
15
+ if (vm.computedValue && !isNaN(vm.computedValue)) {
16
+ d = new Date(vm.computedValue);
17
+ } else {
18
+ d = vm.timeCreator();
19
+ d.setMilliseconds(0);
20
+ }
21
+ if (vm.dtf.formatToParts && typeof vm.dtf.formatToParts === 'function') {
22
+ var formatRegex = vm.dtf.formatToParts(d).map(function (part) {
23
+ if (part.type === 'literal') {
24
+ return part.value.replace(/ /g, '\\s?');
25
+ } else if (part.type === 'dayPeriod') {
26
+ return "((?!=<".concat(part.type, ">)(").concat(vm.amString, "|").concat(vm.pmString, "|").concat(AM, "|").concat(PM, "|").concat(AM.toLowerCase(), "|").concat(PM.toLowerCase(), ")?)");
27
+ }
28
+ return "((?!=<".concat(part.type, ">)\\d+)");
29
+ }).join('');
30
+ var timeGroups = matchWithGroups(formatRegex, timeString);
31
+
32
+ // We do a simple validation for the group.
33
+ // If it is not valid, it will fallback to Date.parse below
34
+ timeGroups.hour = timeGroups.hour ? parseInt(timeGroups.hour, 10) : null;
35
+ timeGroups.minute = timeGroups.minute ? parseInt(timeGroups.minute, 10) : null;
36
+ timeGroups.second = timeGroups.second ? parseInt(timeGroups.second, 10) : null;
37
+ if (timeGroups.hour && timeGroups.hour >= 0 && timeGroups.hour < 24 && timeGroups.minute && timeGroups.minute >= 0 && timeGroups.minute < 59) {
38
+ if (timeGroups.dayPeriod && (timeGroups.dayPeriod.toLowerCase() === vm.pmString.toLowerCase() || timeGroups.dayPeriod.toLowerCase() === PM.toLowerCase()) && timeGroups.hour < 12) {
39
+ timeGroups.hour += 12;
40
+ }
41
+ d.setHours(timeGroups.hour);
42
+ d.setMinutes(timeGroups.minute);
43
+ d.setSeconds(timeGroups.second || 0);
44
+ return d;
45
+ }
46
+ }
47
+
48
+ // Fallback if formatToParts is not supported or if we were not able to parse a valid date
49
+ var am = false;
50
+ if (vm.hourFormat === HOUR_FORMAT_12) {
51
+ var dateString12 = timeString.split(' ');
52
+ timeString = dateString12[0];
53
+ am = dateString12[1] === vm.amString || dateString12[1] === AM;
54
+ }
55
+ var time = timeString.split(':');
56
+ var hours = parseInt(time[0], 10);
57
+ var minutes = parseInt(time[1], 10);
58
+ var seconds = vm.enableSeconds ? parseInt(time[2], 10) : 0;
59
+ if (isNaN(hours) || hours < 0 || hours > 23 || vm.hourFormat === HOUR_FORMAT_12 && (hours < 1 || hours > 12) || isNaN(minutes) || minutes < 0 || minutes > 59) {
60
+ return null;
61
+ }
62
+ d.setSeconds(seconds);
63
+ d.setMinutes(minutes);
64
+ if (vm.hourFormat === HOUR_FORMAT_12) {
65
+ if (am && hours === 12) {
66
+ hours = 0;
67
+ } else if (!am && hours !== 12) {
68
+ hours += 12;
69
+ }
70
+ }
71
+ d.setHours(hours);
72
+ return new Date(d.getTime());
73
+ }
74
+ return null;
75
+ };
76
+ var TimepickerMixin = {
77
+ mixins: [FormElementMixin],
78
+ inheritAttrs: false,
79
+ props: {
80
+ value: Date,
81
+ inline: Boolean,
82
+ minTime: Date,
83
+ maxTime: Date,
84
+ placeholder: String,
85
+ editable: Boolean,
86
+ disabled: Boolean,
87
+ hourFormat: {
88
+ type: String,
89
+ validator: function validator(value) {
90
+ return value === HOUR_FORMAT_24 || value === HOUR_FORMAT_12;
91
+ }
92
+ },
93
+ incrementHours: {
94
+ type: Number,
95
+ default: 1
96
+ },
97
+ incrementMinutes: {
98
+ type: Number,
99
+ default: 1
100
+ },
101
+ incrementSeconds: {
102
+ type: Number,
103
+ default: 1
104
+ },
105
+ timeFormatter: {
106
+ type: Function,
107
+ default: function _default(date, vm) {
108
+ if (typeof config.defaultTimeFormatter === 'function') {
109
+ return config.defaultTimeFormatter(date);
110
+ } else {
111
+ return defaultTimeFormatter(date, vm);
112
+ }
113
+ }
114
+ },
115
+ timeParser: {
116
+ type: Function,
117
+ default: function _default(date, vm) {
118
+ if (typeof config.defaultTimeParser === 'function') {
119
+ return config.defaultTimeParser(date);
120
+ } else {
121
+ return defaultTimeParser(date, vm);
122
+ }
123
+ }
124
+ },
125
+ mobileNative: {
126
+ type: Boolean,
127
+ default: function _default() {
128
+ return config.defaultTimepickerMobileNative;
129
+ }
130
+ },
131
+ mobileModal: {
132
+ type: Boolean,
133
+ default: function _default() {
134
+ return config.defaultTimepickerMobileModal;
135
+ }
136
+ },
137
+ timeCreator: {
138
+ type: Function,
139
+ default: function _default() {
140
+ if (typeof config.defaultTimeCreator === 'function') {
141
+ return config.defaultTimeCreator();
142
+ } else {
143
+ return new Date();
144
+ }
145
+ }
146
+ },
147
+ position: String,
148
+ unselectableTimes: Array,
149
+ openOnFocus: Boolean,
150
+ enableSeconds: Boolean,
151
+ defaultMinutes: Number,
152
+ defaultSeconds: Number,
153
+ focusable: {
154
+ type: Boolean,
155
+ default: true
156
+ },
157
+ tzOffset: {
158
+ type: Number,
159
+ default: 0
160
+ },
161
+ appendToBody: Boolean,
162
+ resetOnMeridianChange: {
163
+ type: Boolean,
164
+ default: false
165
+ }
166
+ },
167
+ data: function data() {
168
+ return {
169
+ dateSelected: this.value,
170
+ hoursSelected: null,
171
+ minutesSelected: null,
172
+ secondsSelected: null,
173
+ meridienSelected: null,
174
+ _elementRef: 'input',
175
+ AM: AM,
176
+ PM: PM,
177
+ HOUR_FORMAT_24: HOUR_FORMAT_24,
178
+ HOUR_FORMAT_12: HOUR_FORMAT_12
179
+ };
180
+ },
181
+ computed: {
182
+ computedValue: {
183
+ get: function get() {
184
+ return this.dateSelected;
185
+ },
186
+ set: function set(value) {
187
+ this.dateSelected = value;
188
+ this.$emit('input', this.dateSelected);
189
+ }
190
+ },
191
+ localeOptions: function localeOptions() {
192
+ return new Intl.DateTimeFormat(this.locale, {
193
+ hour: 'numeric',
194
+ minute: 'numeric',
195
+ second: this.enableSeconds ? 'numeric' : undefined
196
+ }).resolvedOptions();
197
+ },
198
+ dtf: function dtf() {
199
+ return new Intl.DateTimeFormat(this.locale, {
200
+ hour: this.localeOptions.hour || 'numeric',
201
+ minute: this.localeOptions.minute || 'numeric',
202
+ second: this.enableSeconds ? this.localeOptions.second || 'numeric' : undefined,
203
+ // Fixes 12 hour display github.com/buefy/buefy/issues/3418
204
+ hourCycle: !this.isHourFormat24 ? 'h12' : 'h23'
205
+ });
206
+ },
207
+ newHourFormat: function newHourFormat() {
208
+ return this.hourFormat || (this.localeOptions.hour12 ? HOUR_FORMAT_12 : HOUR_FORMAT_24);
209
+ },
210
+ sampleTime: function sampleTime() {
211
+ var d = this.timeCreator();
212
+ d.setHours(10);
213
+ d.setSeconds(0);
214
+ d.setMinutes(0);
215
+ d.setMilliseconds(0);
216
+ return d;
217
+ },
218
+ hourLiteral: function hourLiteral() {
219
+ if (this.dtf.formatToParts && typeof this.dtf.formatToParts === 'function') {
220
+ var d = this.sampleTime;
221
+ var parts = this.dtf.formatToParts(d);
222
+ var literal = parts.find(function (part, idx) {
223
+ return idx > 0 && parts[idx - 1].type === 'hour';
224
+ });
225
+ if (literal) {
226
+ return literal.value;
227
+ }
228
+ }
229
+ return ':';
230
+ },
231
+ minuteLiteral: function minuteLiteral() {
232
+ if (this.dtf.formatToParts && typeof this.dtf.formatToParts === 'function') {
233
+ var d = this.sampleTime;
234
+ var parts = this.dtf.formatToParts(d);
235
+ var literal = parts.find(function (part, idx) {
236
+ return idx > 0 && parts[idx - 1].type === 'minute';
237
+ });
238
+ if (literal) {
239
+ return literal.value;
240
+ }
241
+ }
242
+ return ':';
243
+ },
244
+ secondLiteral: function secondLiteral() {
245
+ if (this.dtf.formatToParts && typeof this.dtf.formatToParts === 'function') {
246
+ var d = this.sampleTime;
247
+ var parts = this.dtf.formatToParts(d);
248
+ var literal = parts.find(function (part, idx) {
249
+ return idx > 0 && parts[idx - 1].type === 'second';
250
+ });
251
+ if (literal) {
252
+ return literal.value;
253
+ }
254
+ }
255
+ },
256
+ amString: function amString() {
257
+ if (this.dtf.formatToParts && typeof this.dtf.formatToParts === 'function') {
258
+ var d = this.sampleTime;
259
+ d.setHours(10);
260
+ var dayPeriod = this.dtf.formatToParts(d).find(function (part) {
261
+ return part.type === 'dayPeriod';
262
+ });
263
+ if (dayPeriod) {
264
+ return dayPeriod.value;
265
+ }
266
+ }
267
+ return AM;
268
+ },
269
+ pmString: function pmString() {
270
+ if (this.dtf.formatToParts && typeof this.dtf.formatToParts === 'function') {
271
+ var d = this.sampleTime;
272
+ d.setHours(20);
273
+ var dayPeriod = this.dtf.formatToParts(d).find(function (part) {
274
+ return part.type === 'dayPeriod';
275
+ });
276
+ if (dayPeriod) {
277
+ return dayPeriod.value;
278
+ }
279
+ }
280
+ return PM;
281
+ },
282
+ hours: function hours() {
283
+ if (!this.incrementHours || this.incrementHours < 1) throw new Error('Hour increment cannot be null or less than 1.');
284
+ var hours = [];
285
+ var numberOfHours = this.isHourFormat24 ? 24 : 12;
286
+ for (var i = 0; i < numberOfHours; i += this.incrementHours) {
287
+ var value = i;
288
+ var label = value;
289
+ if (!this.isHourFormat24) {
290
+ value = i + 1;
291
+ label = value;
292
+ if (this.meridienSelected === this.amString) {
293
+ if (value === 12) {
294
+ value = 0;
295
+ }
296
+ } else if (this.meridienSelected === this.pmString) {
297
+ if (value !== 12) {
298
+ value += 12;
299
+ }
300
+ }
301
+ }
302
+ hours.push({
303
+ label: this.formatNumber(label),
304
+ value: value
305
+ });
306
+ }
307
+ return hours;
308
+ },
309
+ minutes: function minutes() {
310
+ if (!this.incrementMinutes || this.incrementMinutes < 1) throw new Error('Minute increment cannot be null or less than 1.');
311
+ var minutes = [];
312
+ for (var i = 0; i < 60; i += this.incrementMinutes) {
313
+ minutes.push({
314
+ label: this.formatNumber(i, true),
315
+ value: i
316
+ });
317
+ }
318
+ return minutes;
319
+ },
320
+ seconds: function seconds() {
321
+ if (!this.incrementSeconds || this.incrementSeconds < 1) throw new Error('Second increment cannot be null or less than 1.');
322
+ var seconds = [];
323
+ for (var i = 0; i < 60; i += this.incrementSeconds) {
324
+ seconds.push({
325
+ label: this.formatNumber(i, true),
326
+ value: i
327
+ });
328
+ }
329
+ return seconds;
330
+ },
331
+ meridiens: function meridiens() {
332
+ return [this.amString, this.pmString];
333
+ },
334
+ isMobile: function isMobile$1() {
335
+ return this.mobileNative && isMobile.any();
336
+ },
337
+ isHourFormat24: function isHourFormat24() {
338
+ return this.newHourFormat === HOUR_FORMAT_24;
339
+ }
340
+ },
341
+ watch: {
342
+ hourFormat: function hourFormat() {
343
+ if (this.hoursSelected !== null) {
344
+ this.meridienSelected = this.hoursSelected >= 12 ? this.pmString : this.amString;
345
+ }
346
+ },
347
+ locale: function locale() {
348
+ // see updateInternalState default
349
+ if (!this.value) {
350
+ this.meridienSelected = this.amString;
351
+ }
352
+ },
353
+ /**
354
+ * When v-model is changed:
355
+ * 1. Update internal value.
356
+ * 2. If it's invalid, validate again.
357
+ */
358
+ value: {
359
+ handler: function handler(value) {
360
+ this.updateInternalState(value);
361
+ !this.isValid && this.$refs.input.checkHtml5Validity();
362
+ },
363
+ immediate: true
364
+ }
365
+ },
366
+ methods: {
367
+ onMeridienChange: function onMeridienChange(value) {
368
+ if (this.hoursSelected !== null && this.resetOnMeridianChange) {
369
+ this.hoursSelected = null;
370
+ this.minutesSelected = null;
371
+ this.secondsSelected = null;
372
+ this.computedValue = null;
373
+ } else if (this.hoursSelected !== null) {
374
+ if (value === this.pmString) {
375
+ this.hoursSelected += 12;
376
+ } else if (value === this.amString) {
377
+ this.hoursSelected -= 12;
378
+ }
379
+ }
380
+ this.updateDateSelected(this.hoursSelected, this.minutesSelected, this.enableSeconds ? this.secondsSelected : 0, value);
381
+ },
382
+ onHoursChange: function onHoursChange(value) {
383
+ if (!this.minutesSelected && typeof this.defaultMinutes !== 'undefined') {
384
+ this.minutesSelected = this.defaultMinutes;
385
+ }
386
+ if (!this.secondsSelected && typeof this.defaultSeconds !== 'undefined') {
387
+ this.secondsSelected = this.defaultSeconds;
388
+ }
389
+ this.updateDateSelected(parseInt(value, 10), this.minutesSelected, this.enableSeconds ? this.secondsSelected : 0, this.meridienSelected);
390
+ },
391
+ onMinutesChange: function onMinutesChange(value) {
392
+ if (!this.secondsSelected && this.defaultSeconds) {
393
+ this.secondsSelected = this.defaultSeconds;
394
+ }
395
+ this.updateDateSelected(this.hoursSelected, parseInt(value, 10), this.enableSeconds ? this.secondsSelected : 0, this.meridienSelected);
396
+ },
397
+ onSecondsChange: function onSecondsChange(value) {
398
+ this.updateDateSelected(this.hoursSelected, this.minutesSelected, parseInt(value, 10), this.meridienSelected);
399
+ },
400
+ updateDateSelected: function updateDateSelected(hours, minutes, seconds, meridiens) {
401
+ if (hours != null && minutes != null && (!this.isHourFormat24 && meridiens !== null || this.isHourFormat24)) {
402
+ var time = null;
403
+ if (this.computedValue && !isNaN(this.computedValue)) {
404
+ time = new Date(this.computedValue);
405
+ } else {
406
+ time = this.timeCreator();
407
+ time.setMilliseconds(0);
408
+ }
409
+ time.setHours(hours);
410
+ time.setMinutes(minutes);
411
+ time.setSeconds(seconds);
412
+ if (!isNaN(time.getTime())) this.computedValue = new Date(time.getTime());
413
+ }
414
+ },
415
+ updateInternalState: function updateInternalState(value) {
416
+ if (value) {
417
+ this.hoursSelected = value.getHours();
418
+ this.minutesSelected = value.getMinutes();
419
+ this.secondsSelected = value.getSeconds();
420
+ this.meridienSelected = value.getHours() >= 12 ? this.pmString : this.amString;
421
+ } else {
422
+ this.hoursSelected = null;
423
+ this.minutesSelected = null;
424
+ this.secondsSelected = null;
425
+ this.meridienSelected = this.amString;
426
+ }
427
+ this.dateSelected = value;
428
+ },
429
+ isHourDisabled: function isHourDisabled(hour) {
430
+ var _this = this;
431
+ var disabled = false;
432
+ if (this.minTime) {
433
+ var minHours = this.minTime.getHours();
434
+ var noMinutesAvailable = this.minutes.every(function (minute) {
435
+ return _this.isMinuteDisabledForHour(hour, minute.value);
436
+ });
437
+ disabled = hour < minHours || noMinutesAvailable;
438
+ }
439
+ if (this.maxTime) {
440
+ if (!disabled) {
441
+ var maxHours = this.maxTime.getHours();
442
+ disabled = hour > maxHours;
443
+ }
444
+ }
445
+ if (this.unselectableTimes) {
446
+ if (!disabled) {
447
+ var unselectable = this.unselectableTimes.filter(function (time) {
448
+ if (_this.enableSeconds && _this.secondsSelected !== null) {
449
+ return time.getHours() === hour && time.getMinutes() === _this.minutesSelected && time.getSeconds() === _this.secondsSelected;
450
+ } else if (_this.minutesSelected !== null) {
451
+ return time.getHours() === hour && time.getMinutes() === _this.minutesSelected;
452
+ }
453
+ return false;
454
+ });
455
+ if (unselectable.length > 0) {
456
+ disabled = true;
457
+ } else {
458
+ disabled = this.minutes.every(function (minute) {
459
+ return _this.unselectableTimes.filter(function (time) {
460
+ return time.getHours() === hour && time.getMinutes() === minute.value;
461
+ }).length > 0;
462
+ });
463
+ }
464
+ }
465
+ }
466
+ return disabled;
467
+ },
468
+ isMinuteDisabledForHour: function isMinuteDisabledForHour(hour, minute) {
469
+ var disabled = false;
470
+ if (this.minTime) {
471
+ var minHours = this.minTime.getHours();
472
+ var minMinutes = this.minTime.getMinutes();
473
+ disabled = hour === minHours && minute < minMinutes;
474
+ }
475
+ if (this.maxTime) {
476
+ if (!disabled) {
477
+ var maxHours = this.maxTime.getHours();
478
+ var maxMinutes = this.maxTime.getMinutes();
479
+ disabled = hour === maxHours && minute > maxMinutes;
480
+ }
481
+ }
482
+ return disabled;
483
+ },
484
+ isMinuteDisabled: function isMinuteDisabled(minute) {
485
+ var _this2 = this;
486
+ var disabled = false;
487
+ if (this.hoursSelected !== null) {
488
+ if (this.isHourDisabled(this.hoursSelected)) {
489
+ disabled = true;
490
+ } else {
491
+ disabled = this.isMinuteDisabledForHour(this.hoursSelected, minute);
492
+ }
493
+ if (this.unselectableTimes) {
494
+ if (!disabled) {
495
+ var unselectable = this.unselectableTimes.filter(function (time) {
496
+ if (_this2.enableSeconds && _this2.secondsSelected !== null) {
497
+ return time.getHours() === _this2.hoursSelected && time.getMinutes() === minute && time.getSeconds() === _this2.secondsSelected;
498
+ } else {
499
+ return time.getHours() === _this2.hoursSelected && time.getMinutes() === minute;
500
+ }
501
+ });
502
+ disabled = unselectable.length > 0;
503
+ }
504
+ }
505
+ }
506
+ return disabled;
507
+ },
508
+ isSecondDisabled: function isSecondDisabled(second) {
509
+ var _this3 = this;
510
+ var disabled = false;
511
+ if (this.minutesSelected !== null) {
512
+ if (this.isMinuteDisabled(this.minutesSelected)) {
513
+ disabled = true;
514
+ } else {
515
+ if (this.minTime) {
516
+ var minHours = this.minTime.getHours();
517
+ var minMinutes = this.minTime.getMinutes();
518
+ var minSeconds = this.minTime.getSeconds();
519
+ disabled = this.hoursSelected === minHours && this.minutesSelected === minMinutes && second < minSeconds;
520
+ }
521
+ if (this.maxTime) {
522
+ if (!disabled) {
523
+ var maxHours = this.maxTime.getHours();
524
+ var maxMinutes = this.maxTime.getMinutes();
525
+ var maxSeconds = this.maxTime.getSeconds();
526
+ disabled = this.hoursSelected === maxHours && this.minutesSelected === maxMinutes && second > maxSeconds;
527
+ }
528
+ }
529
+ }
530
+ if (this.unselectableTimes) {
531
+ if (!disabled) {
532
+ var unselectable = this.unselectableTimes.filter(function (time) {
533
+ return time.getHours() === _this3.hoursSelected && time.getMinutes() === _this3.minutesSelected && time.getSeconds() === second;
534
+ });
535
+ disabled = unselectable.length > 0;
536
+ }
537
+ }
538
+ }
539
+ return disabled;
540
+ },
541
+ /*
542
+ * Parse string into date
543
+ */
544
+ onChange: function onChange(value) {
545
+ var date = this.timeParser(value, this);
546
+ this.updateInternalState(date);
547
+ if (date && !isNaN(date)) {
548
+ this.computedValue = date;
549
+ } else {
550
+ // Force refresh input value when not valid date
551
+ this.computedValue = null;
552
+ this.$refs.input.newValue = this.computedValue;
553
+ }
554
+ },
555
+ /*
556
+ * Toggle timepicker
557
+ */
558
+ toggle: function toggle(active) {
559
+ if (this.$refs.dropdown) {
560
+ this.$refs.dropdown.isActive = typeof active === 'boolean' ? active : !this.$refs.dropdown.isActive;
561
+ }
562
+ },
563
+ /*
564
+ * Close timepicker
565
+ */
566
+ close: function close() {
567
+ this.toggle(false);
568
+ },
569
+ /*
570
+ * Call default onFocus method and show timepicker
571
+ */
572
+ handleOnFocus: function handleOnFocus() {
573
+ this.onFocus();
574
+ if (this.openOnFocus) {
575
+ this.toggle(true);
576
+ }
577
+ },
578
+ /*
579
+ * Format date into string 'HH-MM-SS'
580
+ */
581
+ formatHHMMSS: function formatHHMMSS(value) {
582
+ var date = new Date(value);
583
+ if (value && !isNaN(date)) {
584
+ var hours = date.getHours();
585
+ var minutes = date.getMinutes();
586
+ var seconds = date.getSeconds();
587
+ return this.formatNumber(hours, true) + ':' + this.formatNumber(minutes, true) + ':' + this.formatNumber(seconds, true);
588
+ }
589
+ return '';
590
+ },
591
+ /*
592
+ * Parse time from string
593
+ */
594
+ onChangeNativePicker: function onChangeNativePicker(event) {
595
+ var date = event.target.value;
596
+ if (date) {
597
+ var time = null;
598
+ if (this.computedValue && !isNaN(this.computedValue)) {
599
+ time = new Date(this.computedValue);
600
+ } else {
601
+ time = new Date();
602
+ time.setMilliseconds(0);
603
+ }
604
+ var t = date.split(':');
605
+ time.setHours(parseInt(t[0], 10));
606
+ time.setMinutes(parseInt(t[1], 10));
607
+ time.setSeconds(t[2] ? parseInt(t[2], 10) : 0);
608
+ this.computedValue = new Date(time.getTime());
609
+ } else {
610
+ this.computedValue = null;
611
+ }
612
+ },
613
+ formatNumber: function formatNumber(value, prependZero) {
614
+ return this.isHourFormat24 || prependZero ? this.pad(value) : value;
615
+ },
616
+ pad: function pad(value) {
617
+ return (value < 10 ? '0' : '') + value;
618
+ },
619
+ /*
620
+ * Format date into string
621
+ */
622
+ formatValue: function formatValue(date) {
623
+ if (date && !isNaN(date)) {
624
+ return this.timeFormatter(date, this);
625
+ } else {
626
+ return null;
627
+ }
628
+ },
629
+ /**
630
+ * Keypress event that is bound to the document.
631
+ */
632
+ keyPress: function keyPress(_ref) {
633
+ var key = _ref.key;
634
+ if (this.$refs.dropdown && this.$refs.dropdown.isActive && (key === 'Escape' || key === 'Esc')) {
635
+ this.toggle(false);
636
+ }
637
+ },
638
+ /**
639
+ * Emit 'blur' event on dropdown is not active (closed)
640
+ */
641
+ onActiveChange: function onActiveChange(value) {
642
+ if (!value) {
643
+ this.onBlur();
644
+ }
645
+ }
646
+ },
647
+ created: function created() {
648
+ if (typeof window !== 'undefined') {
649
+ document.addEventListener('keyup', this.keyPress);
650
+ }
651
+ },
652
+ beforeDestroy: function beforeDestroy() {
653
+ if (typeof window !== 'undefined') {
654
+ document.removeEventListener('keyup', this.keyPress);
655
+ }
656
+ }
657
+ };
658
+
659
+ export { TimepickerMixin as T };