@jobber/components 4.1.3-pre.14 → 4.1.4
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.
- package/dist/Autocomplete/index.js +12 -12
- package/dist/Avatar/index.js +2 -2
- package/dist/{Avatar-01c5ba8b.js → Avatar-89cfd0a6.js} +3 -3
- package/dist/Banner/index.js +8 -8
- package/dist/Button/index.js +3 -3
- package/dist/Button-16e043ec.js +57 -0
- package/dist/ButtonDismiss/index.js +4 -4
- package/dist/{ButtonDismiss-d2d16622.js → ButtonDismiss-3fb1eaf9.js} +1 -1
- package/dist/Card/index.js +6 -6
- package/dist/Card-edab9c3c.js +93 -0
- package/dist/Checkbox/index.js +4 -4
- package/dist/Checkbox-c1efc2f6.js +40 -0
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +1 -1
- package/dist/Chips/index.js +11 -11
- package/dist/ConfirmationModal/index.js +11 -11
- package/dist/{ConfirmationModal-ac668c46.js → ConfirmationModal-6a7beee2.js} +3 -3
- package/dist/Content/index.js +2 -2
- package/dist/{Content-af82acba.js → Content-05df8f7f.js} +5 -5
- package/dist/DataDump/index.js +8 -8
- package/dist/DataTable/index.js +17 -17
- package/dist/DatePicker/index.js +4 -4
- package/dist/DatePicker-0696b0f0.js +106 -0
- package/dist/DescriptionList/index.js +4 -4
- package/dist/Disclosure/index.js +5 -5
- package/dist/Divider/index.js +3 -3
- package/dist/Drawer/index.js +9 -9
- package/dist/Emphasis/index.js +3 -3
- package/dist/{Emphasis-53e963b5.js → Emphasis-23dc2a0a.js} +1 -1
- package/dist/FeatureSwitch/index.js +11 -11
- package/dist/Form/index.js +2 -2
- package/dist/FormField/index.js +8 -8
- package/dist/{FormField-aff52a1d.js → FormField-79a0a375.js} +13 -21
- package/dist/FormatEmail/index.js +3 -3
- package/dist/FormatFile/index.js +13 -13
- package/dist/FormatFile-3512f838.js +105 -0
- package/dist/Gallery/index.js +16 -16
- package/dist/Heading/index.js +3 -3
- package/dist/{Heading-8c6e4e0b.js → Heading-7b203f7f.js} +1 -1
- package/dist/InlineLabel/index.js +4 -4
- package/dist/InputAvatar/index.js +10 -10
- package/dist/InputDate/index.js +9 -9
- package/dist/InputEmail/index.js +8 -8
- package/dist/InputFile/index.js +6 -6
- package/dist/{InputFile-e7c15211.js → InputFile-5e0ed2b5.js} +7 -7
- package/dist/InputGroup/index.js +3 -3
- package/dist/InputNumber/index.js +8 -8
- package/dist/InputPassword/index.js +8 -8
- package/dist/InputText/InputText.d.ts +17 -74
- package/dist/InputText/index.js +9 -9
- package/dist/{InputText-90bf6056.js → InputText-95ea24f9.js} +1 -1
- package/dist/InputTime/index.js +812 -652
- package/dist/InputValidation/index.js +4 -4
- package/dist/{InputValidation-e09f5d20.js → InputValidation-97dd0dcf.js} +4 -4
- package/dist/LightBox/index.js +5 -5
- package/dist/{LightBox-8472bc9d.js → LightBox-dd1afa97.js} +5 -5
- package/dist/List/index.js +13 -13
- package/dist/Markdown/index.js +7 -7
- package/dist/{Markdown-5d86d6e7.js → Markdown-be2dcd0c.js} +4 -4
- package/dist/Menu/index.js +4 -4
- package/dist/{Menu-b5e8d8f9.js → Menu-d6a7d17b.js} +5 -5
- package/dist/Modal/index.js +6 -6
- package/dist/{Modal-e41f9284.js → Modal-757e83fd.js} +8 -8
- package/dist/MultiSelect/index.js +8 -8
- package/dist/{Option-9aa09e72.js → Option-4b665afd.js} +1 -1
- package/dist/Page/index.js +11 -11
- package/dist/Popover/index.js +6 -6
- package/dist/ProgressBar/index.js +2 -2
- package/dist/ProgressBar-f028b159.js +28 -0
- package/dist/RadioGroup/index.js +5 -5
- package/dist/Select/index.js +9 -9
- package/dist/Spinner/index.js +2 -2
- package/dist/Spinner-ae4c8a85.js +24 -0
- package/dist/StatusLabel/index.js +5 -5
- package/dist/Switch/index.js +3 -3
- package/dist/Switch-7ac32f7b.js +56 -0
- package/dist/Table/index.js +5 -5
- package/dist/Tabs/index.js +4 -4
- package/dist/Text/index.js +3 -3
- package/dist/{Text-4c04ddc3.js → Text-7ce00adb.js} +1 -1
- package/dist/Toast/index.js +5 -5
- package/dist/Tooltip/index.js +4 -4
- package/dist/{Tooltip-27720f96.js → Tooltip-1090a43d.js} +4 -4
- package/dist/Typography/index.js +2 -2
- package/dist/Typography-9262511f.js +62 -0
- package/dist/{tslib.es6-5b8768b7.js → tslib.es6-efe27175.js} +13 -16
- package/package.json +7 -7
- package/dist/Button-186ef2c1.js +0 -57
- package/dist/Card-c0f88c0f.js +0 -93
- package/dist/Checkbox-1df46a4a.js +0 -40
- package/dist/DatePicker-e085dff4.js +0 -106
- package/dist/FormatFile-42ea7a6a.js +0 -105
- package/dist/ProgressBar-d3178aa9.js +0 -28
- package/dist/Spinner-35cee923.js +0 -24
- package/dist/Switch-21d7093a.js +0 -56
- package/dist/Typography-dd9717e7.js +0 -62
- /package/dist/{style-inject.es-9d2f5f4e.js → style-inject.es-dcee06b6.js} +0 -0
package/dist/InputTime/index.js
CHANGED
|
@@ -2,723 +2,883 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-efe27175.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var debounce = require('lodash/debounce');
|
|
8
8
|
var temporal = require('@std-proposal/temporal');
|
|
9
|
-
var FormField = require('../FormField-
|
|
9
|
+
var FormField = require('../FormField-79a0a375.js');
|
|
10
10
|
require('uuid');
|
|
11
11
|
require('react-hook-form');
|
|
12
|
-
require('../style-inject.es-
|
|
12
|
+
require('../style-inject.es-dcee06b6.js');
|
|
13
13
|
require('classnames');
|
|
14
|
-
require('../Button-
|
|
14
|
+
require('../Button-16e043ec.js');
|
|
15
15
|
require('react-router-dom');
|
|
16
16
|
require('../Icon-405a216c.js');
|
|
17
17
|
require('@jobber/design');
|
|
18
|
-
require('../Typography-
|
|
19
|
-
require('../Text-
|
|
20
|
-
require('../InputValidation-
|
|
18
|
+
require('../Typography-9262511f.js');
|
|
19
|
+
require('../Text-7ce00adb.js');
|
|
20
|
+
require('../InputValidation-97dd0dcf.js');
|
|
21
21
|
require('framer-motion');
|
|
22
|
-
require('../Spinner-
|
|
22
|
+
require('../Spinner-ae4c8a85.js');
|
|
23
23
|
|
|
24
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
25
|
|
|
26
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
27
|
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var input = document.createElement('input');
|
|
32
|
-
input.setAttribute('type', 'time');
|
|
33
|
-
var notValid = 'not-a-time';
|
|
34
|
-
input.setAttribute('value', notValid);
|
|
35
|
-
return input.value !== notValid;
|
|
29
|
+
function getDefaultExportFromCjs (x) {
|
|
30
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
var
|
|
39
|
-
if (window) window.supportsTime = timeSupport;
|
|
33
|
+
var supportsTime$2 = {exports: {}};
|
|
40
34
|
|
|
41
|
-
var supportsTime =
|
|
35
|
+
var supportsTime$1 = {exports: {}};
|
|
42
36
|
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var finalHrs = newHrs === 24 ? 0 : newHrs;
|
|
63
|
-
var timeRegEx = /^[0-9]{2}:([0-9]{2}) (AM|PM)/;
|
|
64
|
-
return timeString_12hr.replace(timeRegEx, leading_zero(finalHrs) + ':$1');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function set_data_attribute($input, timeString_12hr) {
|
|
68
|
-
var filteredString = timeString_12hr.indexOf('-') > -1 ? '' : timeString_12hr;
|
|
69
|
-
var time24hr = convert_to_24hr_time(filteredString);
|
|
70
|
-
$input.setAttribute('data-value', time24hr);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function create_event(eventName) {
|
|
74
|
-
var event = document.createEvent('Event');
|
|
75
|
-
event.initEvent(eventName, true, true);
|
|
76
|
-
return event;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
var inputEvent = create_event('input');
|
|
80
|
-
var changeEvent = create_event('change');
|
|
81
|
-
function trigger_event($input, eventName) {
|
|
82
|
-
var event = {
|
|
83
|
-
input: inputEvent,
|
|
84
|
-
change: changeEvent
|
|
85
|
-
}[eventName];
|
|
86
|
-
|
|
87
|
-
if (can_trigger_change($input)) {
|
|
88
|
-
$input.dispatchEvent(event);
|
|
89
|
-
}
|
|
90
|
-
} // Browsers only send out input and change events if the time element has a full valid value
|
|
91
|
-
|
|
92
|
-
function can_trigger_change($input) {
|
|
93
|
-
return !/--/.test($input.value);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function trigger_both_events($input) {
|
|
97
|
-
// the event only ever fires if there is a full valid value available
|
|
98
|
-
trigger_event($input, 'input');
|
|
99
|
-
trigger_event($input, 'change');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// I need to keep this separate from reset so that
|
|
103
|
-
// I can reset without attracting focus
|
|
104
|
-
function apply_default($input) {
|
|
105
|
-
$input.value = '--:-- --';
|
|
106
|
-
set_data_attribute($input, '');
|
|
107
|
-
trigger_both_events($input);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function convert_number(number) {
|
|
111
|
-
return isNaN(number) ? number : parseInt(number);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function convert_hours_to_12hr_time(hours) {
|
|
115
|
-
return hours <= 12 ? hours === 0 ? 12 : hours : hours - 12;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function convert_to_12hr_time(timeString_24hr) {
|
|
119
|
-
if (timeString_24hr === '') return '--:-- --';
|
|
120
|
-
var twentyFour_regex = /([0-9]{2})\:([0-9]{2})/;
|
|
121
|
-
var result = twentyFour_regex.exec(timeString_24hr);
|
|
122
|
-
var hrs_24 = convert_number(result[1]);
|
|
123
|
-
var min = result[2];
|
|
124
|
-
var hrs_12 = convert_hours_to_12hr_time(hrs_24);
|
|
125
|
-
var isPM = hrs_24 >= 12;
|
|
126
|
-
var mode = isPM ? 'PM' : 'AM';
|
|
127
|
-
return [leading_zero(hrs_12), ':', min, ' ', mode].join('');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function set_time($input, time_string_24hr) {
|
|
131
|
-
var twelveHr = convert_to_12hr_time(time_string_24hr);
|
|
132
|
-
$input.value = twelveHr;
|
|
133
|
-
set_data_attribute($input, time_string_24hr);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function update_time($input) {
|
|
137
|
-
set_time($input, $input.value);
|
|
138
|
-
return $input;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// IE11 doesn't support Object.values()
|
|
142
|
-
function values(obj) {
|
|
143
|
-
var key_values = [];
|
|
144
|
-
|
|
145
|
-
for (var key in obj) {
|
|
146
|
-
key_values.push(obj[key]);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return key_values;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function select_segment($input, segment) {
|
|
153
|
-
set_input_type();
|
|
154
|
-
var actions = {
|
|
155
|
-
hrs: select(0, 2),
|
|
156
|
-
min: select(3, 5),
|
|
157
|
-
mode: select(6, 8)
|
|
158
|
-
};
|
|
159
|
-
actions[segment]($input);
|
|
160
|
-
|
|
161
|
-
function set_input_type() {
|
|
162
|
-
var type = segment === 'mode' ? 'text' : 'tel';
|
|
163
|
-
$input.setAttribute('type', type);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function select(start, end) {
|
|
167
|
-
return function () {
|
|
168
|
-
$input.setSelectionRange(start, end);
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
37
|
+
(function (module) {
|
|
38
|
+
// https://stackoverflow.com/a/10199306/1611058
|
|
39
|
+
function get_time_support () {
|
|
40
|
+
var input = document.createElement('input');
|
|
41
|
+
input.setAttribute('type','time');
|
|
42
|
+
|
|
43
|
+
var notValid = 'not-a-time';
|
|
44
|
+
input.setAttribute('value', notValid);
|
|
45
|
+
|
|
46
|
+
return (input.value !== notValid);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var timeSupport = get_time_support();
|
|
50
|
+
|
|
51
|
+
if (window) window.supportsTime = timeSupport;
|
|
52
|
+
if (module) module.exports = timeSupport;
|
|
53
|
+
} (supportsTime$1));
|
|
172
54
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
end: 2
|
|
177
|
-
},
|
|
178
|
-
min: {
|
|
179
|
-
start: 3,
|
|
180
|
-
end: 5
|
|
181
|
-
},
|
|
182
|
-
mode: {
|
|
183
|
-
start: 6,
|
|
184
|
-
end: 8
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
function get_selected_range($input) {
|
|
189
|
-
return {
|
|
190
|
-
start: $input.selectionStart,
|
|
191
|
-
end: $input.selectionEnd
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function get_current_segment($input) {
|
|
196
|
-
var selection = get_selected_range($input);
|
|
197
|
-
|
|
198
|
-
for (var segment in ranges) {
|
|
199
|
-
var range = ranges[segment];
|
|
200
|
-
var aboveMin = range.start <= selection.start;
|
|
201
|
-
var belowMax = range.end >= selection.end;
|
|
202
|
-
|
|
203
|
-
if (aboveMin && belowMax) {
|
|
204
|
-
return segment;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
55
|
+
(function (module) {
|
|
56
|
+
module.exports = supportsTime$1.exports;
|
|
57
|
+
} (supportsTime$2));
|
|
207
58
|
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
var manual_entry_log = [];
|
|
59
|
+
var supportsTime = /*@__PURE__*/getDefaultExportFromCjs(supportsTime$2.exports);
|
|
212
60
|
|
|
213
|
-
|
|
214
|
-
manual_entry_log = [];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function add(entry) {
|
|
218
|
-
manual_entry_log.push(entry);
|
|
219
|
-
}
|
|
61
|
+
var timeInputPolyfill = {exports: {}};
|
|
220
62
|
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
var manual_entry_log$1 = {
|
|
226
|
-
items: items,
|
|
227
|
-
clear: clear,
|
|
228
|
-
add: add
|
|
63
|
+
var leading_zero$4 = function leading_zero (number) {
|
|
64
|
+
if (isNaN(number)) return number;
|
|
65
|
+
var purified = parseInt(number);
|
|
66
|
+
return purified < 10 ? '0' + purified : number;
|
|
229
67
|
};
|
|
230
68
|
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
var current_segment = get_current_segment($input);
|
|
248
|
-
var values = get_values($input);
|
|
249
|
-
var value = values[current_segment];
|
|
250
|
-
var finalValue = value == '--' ? 'blank' : value;
|
|
251
|
-
var segmentName = {
|
|
252
|
-
hrs: 'Hours',
|
|
253
|
-
min: 'Minutes',
|
|
254
|
-
mode: 'AM/PM'
|
|
255
|
-
}[current_segment];
|
|
256
|
-
var announcements = {
|
|
257
|
-
initial: '$label grouping $fullValue.',
|
|
258
|
-
select: '$segmentName spin button $segmentValue.',
|
|
259
|
-
update: '$segmentValue.'
|
|
260
|
-
};
|
|
261
|
-
var textArray = announcementArray.map(function (providedString) {
|
|
262
|
-
if (announcements[providedString]) {
|
|
263
|
-
return announcements[providedString];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return providedString;
|
|
267
|
-
});
|
|
268
|
-
var fullValue = $input.value.replace(/--/g, 'blank');
|
|
269
|
-
var html = '<p>' + textArray.join('</p><p>') + '</p>';
|
|
270
|
-
html = html.replace(/\$label/g, $input.polyfill.label);
|
|
271
|
-
html = html.replace(/\$segmentName/g, segmentName);
|
|
272
|
-
html = html.replace(/\$segmentValue/g, finalValue);
|
|
273
|
-
html = html.replace(/\$fullValue/g, fullValue);
|
|
274
|
-
$input.polyfill.$a11y.innerHTML = html;
|
|
275
|
-
}, 1);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function traverse($input, direction) {
|
|
279
|
-
var segment = get_current_segment($input);
|
|
280
|
-
var modifier = direction === 'next' ? 1 : -1;
|
|
281
|
-
var next_segment_index = segments.indexOf(segment) + modifier;
|
|
282
|
-
var next_segment = {
|
|
283
|
-
next: segments[next_segment_index] || 'mode',
|
|
284
|
-
prev: next_segment_index < 0 ? 'hrs' : segments[next_segment_index]
|
|
285
|
-
}[direction];
|
|
286
|
-
select_segment($input, next_segment);
|
|
287
|
-
manual_entry_log$1.clear();
|
|
288
|
-
update_a11y($input, ['select']);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function next_segment($input) {
|
|
292
|
-
traverse($input, 'next');
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function prev_segment($input) {
|
|
296
|
-
traverse($input, 'prev');
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function select_cursor_segment($input) {
|
|
300
|
-
var current_segment = get_current_segment($input);
|
|
301
|
-
select_segment($input, current_segment);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function reset($input) {
|
|
305
|
-
apply_default($input);
|
|
306
|
-
select_segment($input, 'hrs');
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function set_segment($input, segment, value) {
|
|
310
|
-
var values = get_values($input);
|
|
311
|
-
values[segment] = value;
|
|
312
|
-
var newInputVal = [leading_zero(values.hrs), ':', leading_zero(values.min), ' ', values.mode].join('');
|
|
313
|
-
$input.value = newInputVal;
|
|
314
|
-
select_segment($input, segment);
|
|
315
|
-
set_data_attribute($input, newInputVal);
|
|
316
|
-
trigger_both_events($input);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/*eslint indent: 0 */
|
|
320
|
-
// prettier-ignore
|
|
321
|
-
var all_number_keys = [// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
322
|
-
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105];
|
|
323
|
-
|
|
324
|
-
var sorted_number_keys = {}; // sorted_number_keys = { 48: 0, 49: 1, 96: 0, 97: 1, ... };
|
|
325
|
-
|
|
326
|
-
all_number_keys.forEach(function (key, index) {
|
|
327
|
-
var number_val = index > 9 ? index - 10 : index;
|
|
328
|
-
sorted_number_keys[key] = number_val;
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
function manual_number_entry($input, key) {
|
|
332
|
-
var key_value = sorted_number_keys[key];
|
|
333
|
-
var segment = get_current_segment($input);
|
|
334
|
-
|
|
335
|
-
if (segment !== 'mode') {
|
|
336
|
-
var entry_count = manual_entry_log$1.items().length;
|
|
337
|
-
var upper_limits = {
|
|
338
|
-
hrs: [1, 2],
|
|
339
|
-
min: [5, 9]
|
|
340
|
-
};
|
|
341
|
-
var limit = upper_limits[segment][entry_count];
|
|
342
|
-
|
|
343
|
-
if (entry_count < 2) {
|
|
344
|
-
manual_entry_log$1.add(key_value);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
var full_limit = parseInt(upper_limits[segment].join(''));
|
|
348
|
-
var full_entry = parseInt(manual_entry_log$1.items().join(''));
|
|
349
|
-
|
|
350
|
-
if (full_limit >= full_entry) {
|
|
351
|
-
set_segment($input, segment, full_entry);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
var at_limit = key_value > limit || manual_entry_log$1.items().length === 2;
|
|
355
|
-
|
|
356
|
-
if (at_limit) {
|
|
357
|
-
next_segment($input);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function clear_segment($input, segment) {
|
|
363
|
-
set_segment($input, segment, '--');
|
|
364
|
-
update_a11y($input, ['update']);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function switch_mode($input, default_mode) {
|
|
368
|
-
default_mode = default_mode || 'AM';
|
|
369
|
-
var current_mode = get_values($input).mode;
|
|
370
|
-
var new_mode = {
|
|
371
|
-
'--': default_mode,
|
|
372
|
-
AM: 'PM',
|
|
373
|
-
PM: 'AM'
|
|
374
|
-
}[current_mode];
|
|
375
|
-
set_segment($input, 'mode', new_mode);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function nudge_time_segment($input, segment, direction) {
|
|
379
|
-
var current_values = get_values($input);
|
|
380
|
-
var time;
|
|
381
|
-
var modifier = direction === 'up' ? 1 : -1;
|
|
382
|
-
|
|
383
|
-
if (current_values[segment] === '--') {
|
|
384
|
-
var current_time = new Date();
|
|
385
|
-
time = {
|
|
386
|
-
hrs: convert_hours_to_12hr_time(current_time.getHours()),
|
|
387
|
-
min: current_time.getMinutes()
|
|
388
|
-
};
|
|
389
|
-
} else {
|
|
390
|
-
var minutes = {
|
|
391
|
-
up: current_values.min < 59 ? current_values.min + modifier : 0,
|
|
392
|
-
down: current_values.min === 0 ? 59 : current_values.min + modifier
|
|
393
|
-
};
|
|
394
|
-
time = {
|
|
395
|
-
hrs: convert_hours_to_12hr_time(current_values.hrs + modifier),
|
|
396
|
-
min: minutes[direction]
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
set_segment($input, segment, leading_zero(time[segment]));
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function increment($input, segment) {
|
|
404
|
-
if (segment === 'mode') {
|
|
405
|
-
switch_mode($input, 'AM');
|
|
406
|
-
} else {
|
|
407
|
-
nudge_time_segment($input, segment, 'up');
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
update_a11y($input, ['update']);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function increment_current_segment($input) {
|
|
414
|
-
var current_segment = get_current_segment($input);
|
|
415
|
-
increment($input, current_segment);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function decrement($input, segment) {
|
|
419
|
-
if (segment === 'mode') {
|
|
420
|
-
switch_mode($input, 'PM');
|
|
421
|
-
} else {
|
|
422
|
-
nudge_time_segment($input, segment, 'down');
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
update_a11y($input, ['update']);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
function decrement_current_segment($input) {
|
|
429
|
-
var current_segment = get_current_segment($input);
|
|
430
|
-
decrement($input, current_segment);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
function set_mode($input, type) {
|
|
434
|
-
var segment = get_current_segment($input);
|
|
435
|
-
|
|
436
|
-
if (segment === 'mode') {
|
|
437
|
-
set_segment($input, segment, type);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
var switch_to_data_value = function ($input) {
|
|
442
|
-
var replacementVal = $input.dataset.value;
|
|
443
|
-
$input.value = replacementVal;
|
|
69
|
+
var leading_zero$3 = leading_zero$4;
|
|
70
|
+
|
|
71
|
+
var convert_to_24hr_time$1 = function convert_to_24hr_time (timeString_12hr) {
|
|
72
|
+
if (/-/.test(timeString_12hr)) return '';
|
|
73
|
+
var isPM = timeString_12hr.indexOf('PM') > -1;
|
|
74
|
+
var timeResult = /^([0-9]{2})/.exec(timeString_12hr);
|
|
75
|
+
var hrs = timeResult ? parseInt(timeResult[1]) : '';
|
|
76
|
+
var newHrs;
|
|
77
|
+
if (hrs === 12) {
|
|
78
|
+
newHrs = isPM ? 12 : 0;
|
|
79
|
+
} else {
|
|
80
|
+
newHrs = isPM ? hrs + 12 : hrs;
|
|
81
|
+
}
|
|
82
|
+
var finalHrs = newHrs === 24 ? 0 : newHrs;
|
|
83
|
+
var timeRegEx = /^[0-9]{2}:([0-9]{2}) (AM|PM)/;
|
|
84
|
+
return timeString_12hr.replace(timeRegEx, leading_zero$3(finalHrs)+':$1');
|
|
444
85
|
};
|
|
445
86
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
var actions = {
|
|
454
|
-
12: function _() {
|
|
455
|
-
if (!is12hr) {
|
|
456
|
-
set_time($input, $input.dataset.value);
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
24: function _() {
|
|
460
|
-
if (is12hr) {
|
|
461
|
-
switch_to_data_value($input);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
actions[format]();
|
|
466
|
-
}
|
|
87
|
+
var convert_to_24hr_time = convert_to_24hr_time$1;
|
|
88
|
+
|
|
89
|
+
var set_data_attribute$3 = function set_data_attribute($input, timeString_12hr){
|
|
90
|
+
var filteredString = timeString_12hr.indexOf('-') > -1 ? '' : timeString_12hr;
|
|
91
|
+
var time24hr = convert_to_24hr_time(filteredString);
|
|
92
|
+
$input.setAttribute('data-value', time24hr);
|
|
93
|
+
};
|
|
467
94
|
|
|
468
|
-
function
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
95
|
+
var create_event$1 = function create_event(eventName){
|
|
96
|
+
var event = document.createEvent('Event');
|
|
97
|
+
event.initEvent(eventName, true, true);
|
|
98
|
+
return event;
|
|
99
|
+
};
|
|
472
100
|
|
|
473
|
-
|
|
474
|
-
|
|
101
|
+
var create_event = create_event$1;
|
|
102
|
+
|
|
103
|
+
var inputEvent = create_event('input');
|
|
104
|
+
var changeEvent = create_event('change');
|
|
105
|
+
|
|
106
|
+
var trigger_event$1 = function trigger_event($input, eventName) {
|
|
107
|
+
var event = {
|
|
108
|
+
input: inputEvent,
|
|
109
|
+
change: changeEvent,
|
|
110
|
+
}[eventName];
|
|
111
|
+
|
|
112
|
+
if (can_trigger_change($input)) {
|
|
113
|
+
$input.dispatchEvent(event);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Browsers only send out input and change events if the time element has a full valid value
|
|
118
|
+
function can_trigger_change ($input) {
|
|
119
|
+
return !/--/.test($input.value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var trigger_event = trigger_event$1;
|
|
123
|
+
|
|
124
|
+
// It seems that oninput and onchange are treated the same way by browsers :/
|
|
125
|
+
var trigger_both_events$2 = function trigger_both_events($input) {
|
|
126
|
+
// the event only ever fires if there is a full valid value available
|
|
127
|
+
trigger_event($input, 'input');
|
|
128
|
+
trigger_event($input,'change');
|
|
129
|
+
};
|
|
475
130
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
131
|
+
// I need to keep this separate from reset so that
|
|
132
|
+
// I can reset without attracting focus
|
|
133
|
+
|
|
134
|
+
var set_data_attribute$2 = set_data_attribute$3;
|
|
135
|
+
var trigger_both_events$1 = trigger_both_events$2;
|
|
136
|
+
|
|
137
|
+
var apply_default$1 = function apply_default ($input) {
|
|
138
|
+
$input.value = '--:-- --';
|
|
139
|
+
set_data_attribute$2($input, '');
|
|
140
|
+
trigger_both_events$1($input);
|
|
141
|
+
};
|
|
483
142
|
|
|
484
|
-
var
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
ArrowUp: 38,
|
|
488
|
-
ArrowLeft: 37,
|
|
489
|
-
Backspace: 8,
|
|
490
|
-
Delete: 46,
|
|
491
|
-
Tab: 9,
|
|
492
|
-
Shift: 16,
|
|
493
|
-
Escape: 27,
|
|
494
|
-
a: 65,
|
|
495
|
-
p: 80
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
function bind_events($input) {
|
|
499
|
-
var shiftKey = false;
|
|
500
|
-
document.addEventListener('keydown', function (e) {
|
|
501
|
-
shiftKey = e.shiftKey;
|
|
502
|
-
});
|
|
503
|
-
document.addEventListener('keyup', function (e) {
|
|
504
|
-
shiftKey = e.shiftKey;
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
if ($input.form) {
|
|
508
|
-
$input.form.addEventListener('submit', function () {
|
|
509
|
-
auto_swap($input);
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
var focused_via_click = false;
|
|
514
|
-
$input.addEventListener('mousedown', function () {
|
|
515
|
-
focused_via_click = true;
|
|
516
|
-
}); // Turns the IE clear button into a reset button
|
|
517
|
-
|
|
518
|
-
$input.addEventListener('mouseup', function () {
|
|
519
|
-
setTimeout(function () {
|
|
520
|
-
if ($input.value === '') reset($input);
|
|
521
|
-
}, 1);
|
|
522
|
-
});
|
|
523
|
-
$input.addEventListener('click', function (e) {
|
|
524
|
-
select_cursor_segment($input);
|
|
525
|
-
});
|
|
526
|
-
$input.addEventListener('blur', function () {
|
|
527
|
-
focused_via_click = false;
|
|
528
|
-
});
|
|
529
|
-
$input.addEventListener('focus', function (e) {
|
|
530
|
-
if (!focused_via_click) {
|
|
531
|
-
e.preventDefault();
|
|
532
|
-
var segment = shiftKey ? 'mode' : 'hrs';
|
|
533
|
-
select_segment($input, segment);
|
|
534
|
-
}
|
|
143
|
+
var convert_number$2 = function convert_number (number) {
|
|
144
|
+
return isNaN(number) ? number : parseInt(number);
|
|
145
|
+
};
|
|
535
146
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
var is_enter_key = e.which === 13;
|
|
540
|
-
if (is_enter_key) return true;
|
|
541
|
-
var is_number_key = all_number_keys.indexOf(e.which) > -1;
|
|
542
|
-
var is_named_key = values(named_keys).indexOf(e.which) > -1;
|
|
543
|
-
var is_arrow_key = [named_keys.ArrowDown, named_keys.ArrowRight, named_keys.ArrowUp, named_keys.ArrowLeft].indexOf(e.which) > -1;
|
|
544
|
-
var is_mode_key = [named_keys.a, named_keys.p].indexOf(e.which) > -1;
|
|
545
|
-
var is_delete_key = [named_keys.Delete, named_keys.Backspace].indexOf(e.which) > -1;
|
|
546
|
-
|
|
547
|
-
if (!is_named_key || is_arrow_key || is_number_key || is_mode_key || is_delete_key) {
|
|
548
|
-
e.preventDefault();
|
|
549
|
-
}
|
|
147
|
+
var convert_hours_to_12hr_time$2 = function convert_hours_to_12hr_time (hours) {
|
|
148
|
+
return hours <= 12 ? hours === 0 ? 12 : hours : hours - 12;
|
|
149
|
+
};
|
|
550
150
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
151
|
+
var convert_number$1 = convert_number$2;
|
|
152
|
+
var convert_hours_to_12hr_time$1 = convert_hours_to_12hr_time$2;
|
|
153
|
+
var leading_zero$2 = leading_zero$4;
|
|
154
|
+
|
|
155
|
+
var convert_to_12hr_time$1 = function convert_to_12hr_time (timeString_24hr) {
|
|
156
|
+
if (timeString_24hr === '') return '--:-- --';
|
|
157
|
+
var twentyFour_regex = /([0-9]{2})\:([0-9]{2})/;
|
|
158
|
+
var result = twentyFour_regex.exec(timeString_24hr);
|
|
159
|
+
var hrs_24 = convert_number$1(result[1]);
|
|
160
|
+
var min = result[2];
|
|
161
|
+
var hrs_12 = convert_hours_to_12hr_time$1(hrs_24);
|
|
162
|
+
var isPM = hrs_24 > 12;
|
|
163
|
+
var mode = isPM ? 'PM' : 'AM';
|
|
164
|
+
return [leading_zero$2(hrs_12), ':', min, ' ', mode].join('');
|
|
165
|
+
};
|
|
554
166
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
167
|
+
var convert_to_12hr_time = convert_to_12hr_time$1;
|
|
168
|
+
var set_data_attribute$1 = set_data_attribute$3;
|
|
169
|
+
|
|
170
|
+
var set_time$2 = function set_time($input, time_string_24hr) {
|
|
171
|
+
var twelveHr = convert_to_12hr_time(time_string_24hr);
|
|
172
|
+
$input.value = twelveHr;
|
|
173
|
+
set_data_attribute$1($input, time_string_24hr);
|
|
174
|
+
};
|
|
559
175
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
176
|
+
var set_time$1 = set_time$2;
|
|
177
|
+
|
|
178
|
+
var update_time = function update_time($input) {
|
|
179
|
+
set_time$1($input, $input.value);
|
|
180
|
+
return $input;
|
|
181
|
+
};
|
|
564
182
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
183
|
+
// IE11 doesn't support Object.values()
|
|
184
|
+
var values$1 = function values (obj) {
|
|
185
|
+
var key_values = [];
|
|
186
|
+
for (var key in obj) {
|
|
187
|
+
key_values.push(obj[key]);
|
|
188
|
+
}
|
|
189
|
+
return key_values;
|
|
190
|
+
};
|
|
568
191
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
192
|
+
var select_segment$5 = function select_segment ($input, segment) {
|
|
193
|
+
|
|
194
|
+
set_input_type();
|
|
195
|
+
|
|
196
|
+
var actions = {
|
|
197
|
+
hrs: select(0, 2),
|
|
198
|
+
min: select(3, 5),
|
|
199
|
+
mode: select(6, 8),
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
actions[segment]($input);
|
|
203
|
+
|
|
204
|
+
function set_input_type() {
|
|
205
|
+
var type = segment === 'mode' ? 'text' : 'tel';
|
|
206
|
+
$input.setAttribute('type', type);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function select (start, end) {
|
|
210
|
+
return function () {
|
|
211
|
+
$input.setSelectionRange(start, end);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
572
215
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
216
|
+
var ranges$2 = {
|
|
217
|
+
hrs : { start: 0, end: 2 },
|
|
218
|
+
min : { start: 3, end: 5 },
|
|
219
|
+
mode : { start: 6, end: 8 },
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var ranges_1 = ranges$2;
|
|
576
223
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
224
|
+
var get_selected_range$1 = function get_selected_range ($input) {
|
|
225
|
+
return { start: $input.selectionStart, end: $input.selectionEnd };
|
|
226
|
+
};
|
|
580
227
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
228
|
+
var ranges$1 = ranges_1;
|
|
229
|
+
var get_selected_range = get_selected_range$1;
|
|
230
|
+
|
|
231
|
+
var get_current_segment$9 = function get_current_segment ($input) {
|
|
232
|
+
var selection = get_selected_range($input);
|
|
233
|
+
for (var segment in ranges$1) {
|
|
234
|
+
var range = ranges$1[segment];
|
|
235
|
+
var aboveMin = range.start <= selection.start;
|
|
236
|
+
var belowMax = range.end >= selection.end;
|
|
237
|
+
if (aboveMin && belowMax) {
|
|
238
|
+
return segment;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return 'hrs';
|
|
242
|
+
};
|
|
584
243
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
244
|
+
var manual_entry_log$2 = [];
|
|
245
|
+
|
|
246
|
+
function clear () {
|
|
247
|
+
manual_entry_log$2 = [];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function add (entry) {
|
|
251
|
+
manual_entry_log$2.push(entry);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function items(){
|
|
255
|
+
return manual_entry_log$2;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
var manual_entry_log_1 = {
|
|
259
|
+
items: items,
|
|
260
|
+
clear: clear,
|
|
261
|
+
add: add,
|
|
262
|
+
};
|
|
588
263
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
264
|
+
var ranges = ranges_1;
|
|
265
|
+
|
|
266
|
+
var segments$1 = Object.keys(ranges);
|
|
267
|
+
|
|
268
|
+
var segments_1 = segments$1;
|
|
269
|
+
|
|
270
|
+
var convert_number = convert_number$2;
|
|
271
|
+
|
|
272
|
+
var get_values$4 = function get_values ($input, timeString) {
|
|
273
|
+
var value = timeString ? timeString : $input.value;
|
|
274
|
+
var regEx = /([0-9-]{1,2})\:([0-9-]{1,2})\s?(AM|PM|\-\-)?/;
|
|
275
|
+
var result = regEx.exec(value);
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
hrs: convert_number(result[1]),
|
|
279
|
+
min: convert_number(result[2]),
|
|
280
|
+
mode: result[3],
|
|
281
|
+
}
|
|
282
|
+
};
|
|
595
283
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
284
|
+
var get_current_segment$8 = get_current_segment$9;
|
|
285
|
+
var get_values$3 = get_values$4;
|
|
286
|
+
|
|
287
|
+
var update_a11y$5 = function update_a11y ($input, announcementArray) {
|
|
288
|
+
// Timeout helps ensure that the input has stabilized
|
|
289
|
+
setTimeout(function(){
|
|
290
|
+
var current_segment = get_current_segment$8($input);
|
|
291
|
+
var values = get_values$3($input);
|
|
292
|
+
var value = values[current_segment];
|
|
293
|
+
var finalValue = value == '--' ? 'blank' : value;
|
|
294
|
+
|
|
295
|
+
var segmentName = {
|
|
296
|
+
hrs: 'Hours',
|
|
297
|
+
min: 'Minutes',
|
|
298
|
+
mode: 'AM/PM'
|
|
299
|
+
}[current_segment];
|
|
300
|
+
|
|
301
|
+
var announcements = {
|
|
302
|
+
initial: '$label grouping $fullValue.',
|
|
303
|
+
select: '$segmentName spin button $segmentValue.',
|
|
304
|
+
update: '$segmentValue.',
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
var textArray = announcementArray.map(function(providedString){
|
|
308
|
+
if (announcements[providedString]) {
|
|
309
|
+
return announcements[providedString];
|
|
310
|
+
}
|
|
311
|
+
return providedString;
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
var fullValue = $input.value.replace(/--/g,'blank');
|
|
315
|
+
|
|
316
|
+
var html = '<p>' + textArray.join('</p><p>') + '</p>';
|
|
317
|
+
html = html.replace(/\$label/g, $input.polyfill.label);
|
|
318
|
+
html = html.replace(/\$segmentName/g, segmentName);
|
|
319
|
+
html = html.replace(/\$segmentValue/g, finalValue);
|
|
320
|
+
html = html.replace(/\$fullValue/g, fullValue);
|
|
321
|
+
|
|
322
|
+
$input.polyfill.$a11y.innerHTML = html;
|
|
323
|
+
}, 1);
|
|
324
|
+
};
|
|
604
325
|
|
|
605
|
-
|
|
606
|
-
var
|
|
607
|
-
|
|
326
|
+
var get_current_segment$7 = get_current_segment$9;
|
|
327
|
+
var select_segment$4 = select_segment$5;
|
|
328
|
+
|
|
329
|
+
var manual_entry_log$1 = manual_entry_log_1;
|
|
330
|
+
var segments = segments_1;
|
|
331
|
+
|
|
332
|
+
var update_a11y$4 = update_a11y$5;
|
|
333
|
+
|
|
334
|
+
var traverse$2 = function traverse ($input, direction) {
|
|
335
|
+
var segment = get_current_segment$7($input);
|
|
336
|
+
|
|
337
|
+
var modifier = direction === 'next' ? 1 : -1;
|
|
338
|
+
var next_segment_index = segments.indexOf(segment) + modifier;
|
|
339
|
+
|
|
340
|
+
var next_segment = {
|
|
341
|
+
next: segments[next_segment_index] || 'mode',
|
|
342
|
+
prev: next_segment_index < 0 ? 'hrs' : segments[next_segment_index],
|
|
343
|
+
}[direction];
|
|
344
|
+
|
|
345
|
+
select_segment$4($input, next_segment);
|
|
346
|
+
manual_entry_log$1.clear();
|
|
347
|
+
update_a11y$4($input, ['select']);
|
|
348
|
+
};
|
|
608
349
|
|
|
609
|
-
|
|
350
|
+
var traverse$1 = traverse$2;
|
|
351
|
+
|
|
352
|
+
var next_segment$3 = function next_segment ($input) {
|
|
353
|
+
traverse$1($input, 'next');
|
|
354
|
+
};
|
|
610
355
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
356
|
+
var traverse = traverse$2;
|
|
357
|
+
|
|
358
|
+
var prev_segment$2 = function prev_segment ($input) {
|
|
359
|
+
traverse($input, 'prev');
|
|
360
|
+
};
|
|
614
361
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
362
|
+
var get_current_segment$6 = get_current_segment$9;
|
|
363
|
+
var select_segment$3 = select_segment$5;
|
|
364
|
+
|
|
365
|
+
var select_cursor_segment$1 = function select_cursor_segment ($input) {
|
|
366
|
+
var current_segment = get_current_segment$6($input);
|
|
367
|
+
select_segment$3($input, current_segment);
|
|
368
|
+
};
|
|
618
369
|
|
|
619
|
-
|
|
620
|
-
|
|
370
|
+
var apply_default = apply_default$1;
|
|
371
|
+
var select_segment$2 = select_segment$5;
|
|
372
|
+
|
|
373
|
+
var reset$1 = function reset ($input) {
|
|
374
|
+
apply_default($input);
|
|
375
|
+
select_segment$2($input, 'hrs');
|
|
376
|
+
};
|
|
621
377
|
|
|
622
|
-
|
|
378
|
+
var get_values$2 = get_values$4;
|
|
379
|
+
var leading_zero$1 = leading_zero$4;
|
|
380
|
+
var select_segment$1 = select_segment$5;
|
|
381
|
+
var set_data_attribute = set_data_attribute$3;
|
|
382
|
+
var trigger_both_events = trigger_both_events$2;
|
|
383
|
+
|
|
384
|
+
var set_segment$5 = function set_segment ($input, segment, value) {
|
|
385
|
+
var values = get_values$2($input);
|
|
386
|
+
values[segment] = value;
|
|
387
|
+
var newInputVal = [
|
|
388
|
+
leading_zero$1(values.hrs),':',
|
|
389
|
+
leading_zero$1(values.min),' ',
|
|
390
|
+
values.mode
|
|
391
|
+
].join('');
|
|
392
|
+
$input.value = newInputVal;
|
|
393
|
+
select_segment$1($input, segment);
|
|
394
|
+
set_data_attribute($input, newInputVal);
|
|
395
|
+
trigger_both_events($input);
|
|
623
396
|
};
|
|
624
397
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
398
|
+
var all_number_keys$2 = [
|
|
399
|
+
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
400
|
+
48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
|
|
401
|
+
96, 97, 98, 99,100,101,102,103,104,105
|
|
402
|
+
];
|
|
403
|
+
|
|
404
|
+
var all_number_keys_1 = all_number_keys$2;
|
|
405
|
+
|
|
406
|
+
var all_number_keys$1 = all_number_keys_1;
|
|
407
|
+
|
|
408
|
+
var sorted_number_keys$1 = {};
|
|
409
|
+
// sorted_number_keys = { 48: 0, 49: 1, 96: 0, 97: 1, ... };
|
|
410
|
+
all_number_keys$1.forEach(function(key, index) {
|
|
411
|
+
var number_val = index > 9 ? index - 10 : index;
|
|
412
|
+
sorted_number_keys$1[key] = number_val;
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
var sorted_number_keys_1 = sorted_number_keys$1;
|
|
416
|
+
|
|
417
|
+
var get_current_segment$5 = get_current_segment$9;
|
|
418
|
+
var set_segment$4 = set_segment$5;
|
|
419
|
+
var next_segment$2 = next_segment$3;
|
|
420
|
+
|
|
421
|
+
var manual_entry_log = manual_entry_log_1;
|
|
422
|
+
var sorted_number_keys = sorted_number_keys_1;
|
|
423
|
+
|
|
424
|
+
var manual_number_entry$1 = function manual_number_entry($input, key) {
|
|
425
|
+
var key_value = sorted_number_keys[key];
|
|
426
|
+
var segment = get_current_segment$5($input);
|
|
427
|
+
|
|
428
|
+
if (segment !== 'mode') {
|
|
429
|
+
var entry_count = manual_entry_log.items().length;
|
|
430
|
+
|
|
431
|
+
var upper_limits = {
|
|
432
|
+
hrs: [1,2],
|
|
433
|
+
min: [5,9],
|
|
434
|
+
};
|
|
435
|
+
var limit = upper_limits[segment][entry_count];
|
|
436
|
+
|
|
437
|
+
if (entry_count < 2) {
|
|
438
|
+
manual_entry_log.add(key_value);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
var full_limit = parseInt(upper_limits[segment].join(''));
|
|
442
|
+
var full_entry = parseInt(manual_entry_log.items().join(''));
|
|
443
|
+
|
|
444
|
+
if (full_limit >= full_entry) {
|
|
445
|
+
set_segment$4($input, segment, full_entry);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
var at_limit = key_value > limit || manual_entry_log.items().length === 2;
|
|
449
|
+
|
|
450
|
+
if (at_limit) {
|
|
451
|
+
next_segment$2($input);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
631
455
|
|
|
632
|
-
|
|
633
|
-
|
|
456
|
+
var set_segment$3 = set_segment$5;
|
|
457
|
+
var update_a11y$3 = update_a11y$5;
|
|
458
|
+
|
|
459
|
+
var clear_segment$1 = function clear_segment ($input, segment) {
|
|
460
|
+
set_segment$3($input, segment, '--');
|
|
461
|
+
update_a11y$3($input, ['update']);
|
|
462
|
+
};
|
|
634
463
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
464
|
+
var get_values$1 = get_values$4;
|
|
465
|
+
var set_segment$2 = set_segment$5;
|
|
466
|
+
|
|
467
|
+
var switch_mode$2 = function switch_mode ($input, default_mode) {
|
|
468
|
+
default_mode = default_mode || 'AM';
|
|
469
|
+
var current_mode = get_values$1($input).mode;
|
|
470
|
+
var new_mode = {
|
|
471
|
+
'--' : default_mode,
|
|
472
|
+
'AM' : 'PM',
|
|
473
|
+
'PM' : 'AM',
|
|
474
|
+
}[current_mode];
|
|
475
|
+
set_segment$2($input, 'mode', new_mode);
|
|
476
|
+
};
|
|
639
477
|
|
|
640
|
-
|
|
641
|
-
|
|
478
|
+
var get_values = get_values$4;
|
|
479
|
+
var convert_hours_to_12hr_time = convert_hours_to_12hr_time$2;
|
|
480
|
+
var leading_zero = leading_zero$4;
|
|
481
|
+
var set_segment$1 = set_segment$5;
|
|
482
|
+
|
|
483
|
+
var nudge_time_segment$2 = function nudge_time_segment ($input, segment, direction) {
|
|
484
|
+
var current_values = get_values($input);
|
|
485
|
+
var time;
|
|
486
|
+
|
|
487
|
+
var modifier = direction === 'up' ? 1 : -1;
|
|
488
|
+
|
|
489
|
+
if (current_values[segment] === '--') {
|
|
490
|
+
var current_time = new Date();
|
|
491
|
+
time = {
|
|
492
|
+
hrs: convert_hours_to_12hr_time(current_time.getHours()),
|
|
493
|
+
min: current_time.getMinutes(),
|
|
494
|
+
};
|
|
495
|
+
} else {
|
|
496
|
+
var minutes = {
|
|
497
|
+
up : current_values.min < 59 ? current_values.min + modifier : 0,
|
|
498
|
+
down : current_values.min === 0 ? 59 : current_values.min + modifier,
|
|
499
|
+
};
|
|
500
|
+
time = {
|
|
501
|
+
hrs: convert_hours_to_12hr_time(current_values.hrs + modifier),
|
|
502
|
+
min: minutes[direction],
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
set_segment$1($input, segment, leading_zero(time[segment]) );
|
|
507
|
+
};
|
|
642
508
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
509
|
+
var switch_mode$1 = switch_mode$2;
|
|
510
|
+
var nudge_time_segment$1 = nudge_time_segment$2;
|
|
511
|
+
var update_a11y$2 = update_a11y$5;
|
|
512
|
+
|
|
513
|
+
var increment$1 = function increment ($input, segment) {
|
|
514
|
+
if (segment === 'mode') {
|
|
515
|
+
switch_mode$1($input, 'AM');
|
|
516
|
+
} else {
|
|
517
|
+
nudge_time_segment$1($input, segment, 'up');
|
|
518
|
+
}
|
|
519
|
+
update_a11y$2($input, ['update']);
|
|
520
|
+
};
|
|
648
521
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
522
|
+
var get_current_segment$4 = get_current_segment$9;
|
|
523
|
+
var increment = increment$1;
|
|
524
|
+
|
|
525
|
+
var increment_current_segment$1 = function increment_current_segment ($input) {
|
|
526
|
+
var current_segment = get_current_segment$4($input);
|
|
527
|
+
increment($input, current_segment);
|
|
528
|
+
};
|
|
654
529
|
|
|
655
|
-
|
|
656
|
-
|
|
530
|
+
var switch_mode = switch_mode$2;
|
|
531
|
+
var nudge_time_segment = nudge_time_segment$2;
|
|
532
|
+
var update_a11y$1 = update_a11y$5;
|
|
533
|
+
|
|
534
|
+
var decrement$1 = function decrement ($input, segment) {
|
|
535
|
+
if (segment === 'mode') {
|
|
536
|
+
switch_mode($input, 'PM');
|
|
537
|
+
} else {
|
|
538
|
+
nudge_time_segment($input, segment, 'down');
|
|
539
|
+
}
|
|
540
|
+
update_a11y$1($input, ['update']);
|
|
541
|
+
};
|
|
657
542
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
543
|
+
var get_current_segment$3 = get_current_segment$9;
|
|
544
|
+
var decrement = decrement$1;
|
|
545
|
+
|
|
546
|
+
var decrement_current_segment$1 = function decrement_current_segment ($input){
|
|
547
|
+
var current_segment = get_current_segment$3($input);
|
|
548
|
+
decrement($input, current_segment);
|
|
549
|
+
};
|
|
664
550
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
551
|
+
var get_current_segment$2 = get_current_segment$9;
|
|
552
|
+
var set_segment = set_segment$5;
|
|
553
|
+
|
|
554
|
+
var set_mode$1 = function set_mode ($input, type) {
|
|
555
|
+
var segment = get_current_segment$2($input);
|
|
556
|
+
if (segment === 'mode') {
|
|
557
|
+
set_segment($input, segment, type);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
670
560
|
|
|
671
|
-
function
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
$block.classList.add('time-input-polyfill-accessibility-block');
|
|
676
|
-
document.querySelector('body').appendChild($block);
|
|
677
|
-
return $block;
|
|
678
|
-
}
|
|
561
|
+
var switch_to_data_value$1 = function($input) {
|
|
562
|
+
var replacementVal = $input.dataset.value;
|
|
563
|
+
$input.value = replacementVal;
|
|
564
|
+
};
|
|
679
565
|
|
|
680
|
-
var
|
|
681
|
-
var $
|
|
682
|
-
|
|
683
|
-
function
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
};
|
|
566
|
+
var switch_to_data_value = switch_to_data_value$1;
|
|
567
|
+
var set_time = set_time$2;
|
|
568
|
+
|
|
569
|
+
var switch_times$1 = function switch_times ($input, format) {
|
|
570
|
+
var is12hr = /\s/.test($input.value);
|
|
571
|
+
|
|
572
|
+
if (format != 12 && format != 24) {
|
|
573
|
+
format = is12hr ? 24 : 12;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
var actions = {
|
|
577
|
+
12: function(){
|
|
578
|
+
if (!is12hr) {
|
|
579
|
+
set_time($input, $input.dataset.value);
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
24: function(){
|
|
583
|
+
if (is12hr) {
|
|
584
|
+
switch_to_data_value($input);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
actions[format]();
|
|
589
|
+
};
|
|
705
590
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
591
|
+
var get_current_segment$1 = get_current_segment$9;
|
|
592
|
+
var prev_segment$1 = prev_segment$2;
|
|
593
|
+
var next_segment$1 = next_segment$3;
|
|
594
|
+
|
|
595
|
+
var handle_tab$1 = function handle_tab($input, e) {
|
|
596
|
+
var current_segment = get_current_segment$1($input);
|
|
597
|
+
var backwards_and_first = e.shiftKey && current_segment === 'hrs';
|
|
598
|
+
var forwards_and_last = !e.shiftKey && current_segment === 'mode';
|
|
599
|
+
|
|
600
|
+
if (!backwards_and_first && !forwards_and_last) {
|
|
601
|
+
e.preventDefault();
|
|
602
|
+
if (e.shiftKey) {
|
|
603
|
+
prev_segment$1($input);
|
|
604
|
+
} else {
|
|
605
|
+
next_segment$1($input);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
};
|
|
713
609
|
|
|
714
|
-
|
|
715
|
-
|
|
610
|
+
var named_keys$1 = {
|
|
611
|
+
ArrowDown: 40,
|
|
612
|
+
ArrowRight: 39,
|
|
613
|
+
ArrowUp: 38,
|
|
614
|
+
ArrowLeft: 37,
|
|
615
|
+
Backspace: 8,
|
|
616
|
+
Delete: 46,
|
|
617
|
+
Tab: 9,
|
|
618
|
+
Shift: 16,
|
|
619
|
+
Escape: 27,
|
|
620
|
+
a: 65,
|
|
621
|
+
p: 80,
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
var named_keys_1 = named_keys$1;
|
|
625
|
+
|
|
626
|
+
var values = values$1;
|
|
627
|
+
|
|
628
|
+
var select_segment = select_segment$5;
|
|
629
|
+
|
|
630
|
+
var next_segment = next_segment$3;
|
|
631
|
+
var prev_segment = prev_segment$2;
|
|
632
|
+
var select_cursor_segment = select_cursor_segment$1;
|
|
633
|
+
|
|
634
|
+
var get_current_segment = get_current_segment$9;
|
|
635
|
+
|
|
636
|
+
var reset = reset$1;
|
|
637
|
+
var manual_number_entry = manual_number_entry$1;
|
|
638
|
+
var clear_segment = clear_segment$1;
|
|
639
|
+
var increment_current_segment = increment_current_segment$1;
|
|
640
|
+
var decrement_current_segment = decrement_current_segment$1;
|
|
641
|
+
var set_mode = set_mode$1;
|
|
642
|
+
var switch_times = switch_times$1;
|
|
643
|
+
|
|
644
|
+
var handle_tab = handle_tab$1;
|
|
645
|
+
|
|
646
|
+
var all_number_keys = all_number_keys_1;
|
|
647
|
+
var named_keys = named_keys_1;
|
|
648
|
+
|
|
649
|
+
var update_a11y = update_a11y$5;
|
|
650
|
+
|
|
651
|
+
var bind_events = function bind_events ($input) {
|
|
652
|
+
|
|
653
|
+
var shiftKey = false;
|
|
654
|
+
|
|
655
|
+
document.addEventListener('keydown', function(e){
|
|
656
|
+
shiftKey = e.shiftKey;
|
|
657
|
+
});
|
|
658
|
+
document.addEventListener('keyup', function(e){
|
|
659
|
+
shiftKey = e.shiftKey;
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
if ($input.form) {
|
|
663
|
+
$input.form.addEventListener('submit', function(){
|
|
664
|
+
auto_swap($input);
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
var focused_via_click = false;
|
|
669
|
+
|
|
670
|
+
$input.addEventListener('mousedown', function(){
|
|
671
|
+
focused_via_click = true;
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
// Turns the IE clear button into a reset button
|
|
675
|
+
$input.addEventListener('mouseup', function(){
|
|
676
|
+
setTimeout(function(){
|
|
677
|
+
if ($input.value === '') reset($input);
|
|
678
|
+
}, 1);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
$input.addEventListener('click', function(e){
|
|
682
|
+
select_cursor_segment($input);
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
$input.addEventListener('blur', function(){
|
|
686
|
+
$input.dataset.value;
|
|
687
|
+
focused_via_click = false;
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
$input.addEventListener('focus', function(e){
|
|
691
|
+
if (!focused_via_click) {
|
|
692
|
+
e.preventDefault();
|
|
693
|
+
var segment = shiftKey ? 'mode' : 'hrs';
|
|
694
|
+
select_segment($input, segment);
|
|
695
|
+
}
|
|
696
|
+
update_a11y($input, [
|
|
697
|
+
'initial',
|
|
698
|
+
'select'
|
|
699
|
+
]);
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
$input.addEventListener('keydown', function(e) {
|
|
703
|
+
var is_enter_key = e.which === 13;
|
|
704
|
+
if (is_enter_key) return true;
|
|
705
|
+
|
|
706
|
+
var is_number_key = all_number_keys.indexOf(e.which) > -1;
|
|
707
|
+
var is_named_key = values(named_keys).indexOf(e.which) > -1;
|
|
708
|
+
var is_arrow_key = [named_keys.ArrowDown, named_keys.ArrowRight, named_keys.ArrowUp, named_keys.ArrowLeft].indexOf(e.which) > -1;
|
|
709
|
+
var is_mode_key = [named_keys.a, named_keys.p].indexOf(e.which) > -1;
|
|
710
|
+
var is_delete_key = [named_keys.Delete, named_keys.Backspace].indexOf(e.which) > -1;
|
|
711
|
+
|
|
712
|
+
if (!is_named_key || is_arrow_key || is_number_key || is_mode_key || is_delete_key) { e.preventDefault(); }
|
|
713
|
+
|
|
714
|
+
if (is_number_key) {
|
|
715
|
+
manual_number_entry($input, e.which);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (is_delete_key) {
|
|
719
|
+
var segment = get_current_segment($input);
|
|
720
|
+
clear_segment($input, segment);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
switch (e.which) {
|
|
724
|
+
case named_keys.ArrowRight: next_segment($input); break;
|
|
725
|
+
case named_keys.ArrowLeft: prev_segment($input); break;
|
|
726
|
+
case named_keys.ArrowUp: increment_current_segment($input); break;
|
|
727
|
+
case named_keys.ArrowDown: decrement_current_segment($input); break;
|
|
728
|
+
case named_keys.Escape: reset($input); break;
|
|
729
|
+
case named_keys.a: set_mode($input, 'AM'); break;
|
|
730
|
+
case named_keys.p: set_mode($input, 'PM'); break;
|
|
731
|
+
case named_keys.Tab: handle_tab($input, e); break;
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
function auto_swap($input) {
|
|
737
|
+
if ($input.polyfill.autoSwap) {
|
|
738
|
+
switch_times($input, 24);
|
|
739
|
+
setTimeout(function(){
|
|
740
|
+
switch_times($input, 12);
|
|
741
|
+
}, 1);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// selector is optional, it allows for an early exit
|
|
746
|
+
var get_ancestors$1 = function ($input, selectorString) {
|
|
747
|
+
var $elem = $input;
|
|
748
|
+
|
|
749
|
+
// https://stackoverflow.com/a/8729274/1611058
|
|
750
|
+
var ancestors = [];
|
|
751
|
+
while ($elem) {
|
|
752
|
+
ancestors.push($elem);
|
|
753
|
+
var matchesSelector = $elem.msMatchesSelector ?
|
|
754
|
+
$elem.msMatchesSelector(selectorString) :
|
|
755
|
+
$elem.matches(selectorString);
|
|
756
|
+
if (matchesSelector) {
|
|
757
|
+
return ancestors;
|
|
758
|
+
}
|
|
759
|
+
$elem = $elem.parentElement;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
return ancestors;
|
|
763
|
+
};
|
|
716
764
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
765
|
+
var get_ancestors = get_ancestors$1;
|
|
766
|
+
|
|
767
|
+
var get_label = function get_label ($input) {
|
|
768
|
+
|
|
769
|
+
var labelText =
|
|
770
|
+
aria_labelledby($input) ||
|
|
771
|
+
aria_label($input) ||
|
|
772
|
+
for_attribute($input) ||
|
|
773
|
+
label_wrapper_element($input) ||
|
|
774
|
+
title_attribute($input);
|
|
775
|
+
|
|
776
|
+
if (labelText) return labelText;
|
|
777
|
+
|
|
778
|
+
console.error('Label text for input not found.', $input);
|
|
779
|
+
throw new Error('Cannot polyfill time input due to a missing label.');
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
function aria_labelledby($input){
|
|
783
|
+
var ariaLabelByID = $input.getAttribute('aria-labelledby');
|
|
784
|
+
if (ariaLabelByID) {
|
|
785
|
+
var $ariaLabelBy = document.getElementById(ariaLabelByID);
|
|
786
|
+
if ($ariaLabelBy) return $ariaLabelBy.textContent;
|
|
787
|
+
}
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
function aria_label($input){
|
|
792
|
+
var ariaLabel = $input.getAttribute('aria-label');
|
|
793
|
+
if (ariaLabel) return ariaLabel;
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function for_attribute($input){
|
|
798
|
+
if ($input.id) {
|
|
799
|
+
var $forLabel = document.querySelector('label[for="'+$input.id+'"]');
|
|
800
|
+
if ($forLabel) return $forLabel.textContent;
|
|
801
|
+
}
|
|
802
|
+
return false;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function label_wrapper_element($input){
|
|
806
|
+
var ancestors = get_ancestors($input, 'label');
|
|
807
|
+
var $parentLabel = ancestors[ancestors.length - 1];
|
|
808
|
+
if ($parentLabel.nodeName == 'LABEL') return $parentLabel.textContent;
|
|
809
|
+
return false
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function title_attribute($input){
|
|
813
|
+
var titleLabel = $input.getAttribute('title');
|
|
814
|
+
if (titleLabel) return titleLabel;
|
|
815
|
+
return false
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
var create_a11y_block = function create_accessibility_block () {
|
|
819
|
+
var $block = document.createElement('div');
|
|
820
|
+
$block.setAttribute('aria-live', 'assertive');
|
|
821
|
+
$block.setAttribute('style', 'position: absolute; opacity: 0; height: 0; width: 0; overflow: hidden; pointer-events: none;');
|
|
822
|
+
$block.classList.add('time-input-polyfill-accessibility-block');
|
|
823
|
+
document.querySelector('body').appendChild($block);
|
|
824
|
+
return $block;
|
|
825
|
+
};
|
|
720
826
|
|
|
721
|
-
|
|
827
|
+
(function (module) {
|
|
828
|
+
var apply_default = apply_default$1;
|
|
829
|
+
var update_time$1 = update_time;
|
|
830
|
+
var set_data_attribute = set_data_attribute$3;
|
|
831
|
+
var bind_events$1 = bind_events;
|
|
832
|
+
var switch_times = switch_times$1;
|
|
833
|
+
var get_label$1 = get_label;
|
|
834
|
+
|
|
835
|
+
var create_a11y_block$1 = create_a11y_block;
|
|
836
|
+
|
|
837
|
+
var accessibility_block_created = false;
|
|
838
|
+
var $a11y;
|
|
839
|
+
|
|
840
|
+
function TimePolyfill($input) {
|
|
841
|
+
|
|
842
|
+
$input.setAttribute('autocomplete','off');
|
|
843
|
+
|
|
844
|
+
// Prevent screen reader from announcing the default stuff
|
|
845
|
+
$input.setAttribute('aria-hidden', true);
|
|
846
|
+
|
|
847
|
+
if (!accessibility_block_created) {
|
|
848
|
+
$a11y = create_a11y_block$1();
|
|
849
|
+
accessibility_block_created = true;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
var label = get_label$1($input);
|
|
853
|
+
|
|
854
|
+
$input.polyfill = {
|
|
855
|
+
$a11y: $a11y,
|
|
856
|
+
label: label,
|
|
857
|
+
autoSwap: true,
|
|
858
|
+
update: function() {
|
|
859
|
+
update_time$1($input);
|
|
860
|
+
},
|
|
861
|
+
swap: function(forcedFormat) {
|
|
862
|
+
switch_times($input, forcedFormat);
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
if ($input.value === '' || /--/.test($input.value)) {
|
|
867
|
+
apply_default($input);
|
|
868
|
+
set_data_attribute($input, '');
|
|
869
|
+
} else {
|
|
870
|
+
update_time$1($input);
|
|
871
|
+
set_data_attribute($input, $input.value);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
bind_events$1($input);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (window) window.TimePolyfill = TimePolyfill;
|
|
878
|
+
if (module) module.exports = TimePolyfill;
|
|
879
|
+
} (timeInputPolyfill));
|
|
880
|
+
|
|
881
|
+
var TimePolyfill = timeInputPolyfill.exports;
|
|
722
882
|
|
|
723
883
|
function civilTimeToHTMLTime(civilTime) {
|
|
724
884
|
if (civilTime == undefined) {
|
|
@@ -744,7 +904,7 @@ function InputTimeSafari(_a) {
|
|
|
744
904
|
const blurHandler = generateEventHandler(handleChange);
|
|
745
905
|
React.useLayoutEffect(() => {
|
|
746
906
|
const input = inputTime.current;
|
|
747
|
-
new
|
|
907
|
+
new TimePolyfill(input);
|
|
748
908
|
if (value) {
|
|
749
909
|
input.value = civilTimeToHTMLTime(value);
|
|
750
910
|
input.polyfill.update();
|