@jobber/components 4.67.2-JOB-84261.6 → 4.67.2-pre.25
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/AnimatedSwitcher/index.js +2 -2
- package/dist/{AnimatedSwitcher-d1e1ddcf.js → AnimatedSwitcher-879d0d6f.js} +1 -1
- package/dist/Autocomplete/index.js +13 -15
- package/dist/Avatar/index.js +2 -3
- package/dist/{Avatar-76a799fa.js → Avatar-765d6e45.js} +1 -4
- package/dist/Banner/index.js +4 -9
- package/dist/Button/index.js +3 -4
- package/dist/Button-8bde6560.js +54 -0
- package/dist/ButtonDismiss/index.js +4 -5
- package/dist/{ButtonDismiss-2b98d075.js → ButtonDismiss-af17d76d.js} +1 -1
- package/dist/Card/index.js +7 -8
- package/dist/Card-9dfc98d3.js +88 -0
- package/dist/Checkbox/index.js +5 -7
- package/dist/{Checkbox-ad7ec2e7.js → Checkbox-2d7c43d9.js} +5 -8
- package/dist/Chip/index.js +8 -7
- package/dist/Chip-dca6c22b.js +86 -0
- package/dist/Chips/index.js +12 -16
- package/dist/ClientOnly-4f3e136d.js +23 -0
- package/dist/Combobox/index.js +11 -10
- package/dist/{Combobox-eb1e5817.js → Combobox-35a3ea22.js} +43 -24
- package/dist/ConfirmationModal/index.js +14 -13
- package/dist/{ConfirmationModal-0f85d96c.js → ConfirmationModal-f6c0afc7.js} +3 -3
- package/dist/Content/index.js +1 -2
- package/dist/{Content-2ca1ffe1.js → Content-80486307.js} +0 -5
- package/dist/DataDump/index.js +9 -10
- package/dist/DataList/components/DataListHeader/DataListHeaderCheckbox.d.ts +1 -2
- package/dist/DataList/components/DataListHeaderTile/DataListSortingArrows.d.ts +1 -1
- package/dist/DataList/hooks/useMediaQuery.d.ts +3 -1
- package/dist/DataList/index.js +31 -56
- package/dist/DataTable/DataTable.d.ts +1 -1
- package/dist/DataTable/index.js +18 -22
- package/dist/DatePicker/index.js +4 -5
- package/dist/DatePicker-9399cc69.js +131 -0
- package/dist/DescriptionList/index.js +1 -4
- package/dist/Disclosure/index.js +2 -5
- package/dist/Divider/index.js +0 -3
- package/dist/Drawer/index.js +5 -10
- package/dist/Emphasis/index.js +2 -3
- package/dist/{Emphasis-b2d1b3aa.js → Emphasis-7a2893bb.js} +1 -1
- package/dist/FeatureSwitch/index.js +11 -13
- package/dist/Flex/index.js +6 -4
- package/dist/Form/index.js +1 -1
- package/dist/FormField/FormFieldTypes.d.ts +8 -0
- package/dist/FormField/FormFieldWrapper.d.ts +3 -1
- package/dist/FormField/components/ClearAction.d.ts +9 -0
- package/dist/FormField/index.js +9 -10
- package/dist/FormField-18eda132.js +252 -0
- package/dist/FormatDate/index.js +1 -1
- package/dist/FormatEmail/index.js +0 -3
- package/dist/FormatFile/index.js +17 -17
- package/dist/FormatFile-317b158a.js +116 -0
- package/dist/FormatTime/FormatTime.d.ts +1 -2
- package/dist/FormatTime/index.js +11 -6
- package/dist/Gallery/index.js +18 -20
- package/dist/Glimmer/index.js +3 -4
- package/dist/Glimmer-f5c31401.js +68 -0
- package/dist/Grid/index.js +0 -7
- package/dist/Heading/index.js +2 -3
- package/dist/{Heading-0f4ecb0c.js → Heading-f066883a.js} +1 -1
- package/dist/Icon/index.js +1 -1
- package/dist/InlineLabel/index.js +2 -3
- package/dist/InlineLabel-4c2fec47.js +25 -0
- package/dist/InputAvatar/index.js +8 -12
- package/dist/InputDate/InputDate.d.ts +1 -1
- package/dist/InputDate/index.js +10 -11
- package/dist/InputEmail/index.js +9 -10
- package/dist/InputFile/InputFile.d.ts +5 -1
- package/dist/InputFile/index.js +6 -8
- package/dist/{InputFile-540c1657.js → InputFile-5c44f0b4.js} +8 -11
- package/dist/InputGroup/index.js +1 -2
- package/dist/InputGroup-88bec8c9.js +30 -0
- package/dist/InputNumber/index.js +10 -11
- package/dist/{InputNumber-d9ebabaa.js → InputNumber-ed655bae.js} +1 -1
- package/dist/InputPassword/index.js +9 -10
- package/dist/InputPhoneNumber/index.js +9 -12
- package/dist/InputText/InputText.d.ts +2 -0
- package/dist/InputText/index.js +11 -11
- package/dist/InputText/useSafeLayoutEffect.d.ts +2 -0
- package/dist/{InputText-f7c45ee5.js → InputText-c68964ff.js} +3 -2
- package/dist/InputTime/InputTime.d.ts +3 -1
- package/dist/InputTime/InputTime.disabledTest.d.ts +1 -0
- package/dist/InputTime/InputTimeProps.d.ts +1 -1
- package/dist/InputTime/InternalInputTime.d.ts +3 -0
- package/dist/InputTime/SupportsTimePolyfill.d.ts +2 -0
- package/dist/InputTime/TimeInputPolyfill.client.d.ts +2 -0
- package/dist/InputTime/index.js +58 -724
- package/dist/InputValidation/index.js +4 -5
- package/dist/{InputValidation-179f0926.js → InputValidation-fdc891af.js} +2 -5
- package/dist/LightBox/ClientOnly.d.ts +6 -0
- package/dist/LightBox/LightBox.d.ts +2 -2
- package/dist/LightBox/index.js +6 -6
- package/dist/{LightBox-3f4dbc33.js → LightBox-d5aea313.js} +5 -6
- package/dist/List/index.js +9 -15
- package/dist/Markdown/Markdown.d.ts +1 -1
- package/dist/Markdown/index.js +8 -8
- package/dist/Markdown-10fc9d3e.js +90 -0
- package/dist/Menu/Menu.d.ts +4 -4
- package/dist/Menu/index.js +5 -6
- package/dist/{Menu-d7ea093c.js → Menu-7b7aa325.js} +7 -10
- package/dist/Modal/Modal.d.ts +2 -2
- package/dist/Modal/index.js +7 -7
- package/dist/{Modal-70daa0e2.js → Modal-357fd1df.js} +6 -9
- package/dist/MultiSelect/index.js +5 -11
- package/dist/{Option-469029b5.js → Option-c84f28a6.js} +1 -1
- package/dist/Page/index.js +12 -14
- package/dist/Popover/Popover.d.ts +2 -2
- package/dist/Popover/index.js +8 -8
- package/dist/ProgressBar/index.js +1 -2
- package/dist/ProgressBar-5c577dc0.js +38 -0
- package/dist/RadioGroup/index.js +3 -5
- package/dist/RadioGroup-9dded55d.js +44 -0
- package/dist/RecurringSelect/components/DayOfMonthSelect.d.ts +2 -2
- package/dist/RecurringSelect/components/WeeklySelect.d.ts +2 -2
- package/dist/RecurringSelect/index.js +16 -29
- package/dist/Select/index.js +10 -11
- package/dist/Spinner/index.js +1 -2
- package/dist/Spinner-cac356ee.js +21 -0
- package/dist/StatusLabel/index.js +2 -5
- package/dist/SupportsTimePolyfill-466a30f9.js +21 -0
- package/dist/Switch/index.js +2 -3
- package/dist/Switch-588c5e70.js +53 -0
- package/dist/Table/index.js +0 -5
- package/dist/Tabs/index.js +1 -4
- package/dist/Text/index.js +2 -3
- package/dist/{Text-4a2bc89f.js → Text-9f261dde.js} +1 -1
- package/dist/TimeInputPolyfill.client-1dfc8ab1.js +687 -0
- package/dist/Toast/index.js +3 -6
- package/dist/Tooltip/index.js +3 -2
- package/dist/{Tooltip-6b12f1c2.js → Tooltip-99440954.js} +14 -12
- package/dist/Typography/index.js +1 -2
- package/dist/Typography-75f58b60.js +43 -0
- package/dist/styles.css +8107 -0
- package/dist/useSafeLayoutEffect-b63708b1.js +16 -0
- package/package.json +4 -4
- package/rollup.config.js +3 -1
- package/dist/Button-163a0641.js +0 -57
- package/dist/Card-3178033c.js +0 -93
- package/dist/Chip-168acf3e.js +0 -89
- package/dist/DatePicker-c18f1739.js +0 -134
- package/dist/FormField-dfc061ca.js +0 -227
- package/dist/FormatFile-3b650d02.js +0 -121
- package/dist/Glimmer-cfa92a88.js +0 -77
- package/dist/InlineLabel-9a517c19.js +0 -28
- package/dist/InputGroup-8d4fd4eb.js +0 -33
- package/dist/Markdown-96070121.js +0 -62
- package/dist/ProgressBar-b68edc8f.js +0 -43
- package/dist/RadioGroup-ebaa4f87.js +0 -47
- package/dist/Spinner-9d8fc7ff.js +0 -24
- package/dist/Switch-b85272bf.js +0 -56
- package/dist/Typography-973b122e.js +0 -62
- package/dist/style-inject.es-9d2f5f4e.js +0 -30
- /package/dist/{FormatDate-70ea5b43.js → FormatDate-6fc94218.js} +0 -0
- /package/dist/{Icon-405a216c.js → Icon-361343e0.js} +0 -0
- /package/dist/{tslib.es6-5b8768b7.js → tslib.es6-a575af05.js} +0 -0
package/dist/InputTime/index.js
CHANGED
|
@@ -2,724 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-5b8768b7.js');
|
|
6
5
|
var React = require('react');
|
|
6
|
+
var tslib_es6 = require('../tslib.es6-a575af05.js');
|
|
7
7
|
var debounce = require('lodash/debounce');
|
|
8
8
|
var temporal = require('@std-proposal/temporal');
|
|
9
|
-
var FormField = require('../FormField-
|
|
10
|
-
require('
|
|
9
|
+
var FormField = require('../FormField-18eda132.js');
|
|
10
|
+
var useSafeLayoutEffect = require('../useSafeLayoutEffect-b63708b1.js');
|
|
11
|
+
var ClientOnly = require('../ClientOnly-4f3e136d.js');
|
|
11
12
|
require('react-hook-form');
|
|
12
|
-
require('../style-inject.es-9d2f5f4e.js');
|
|
13
13
|
require('classnames');
|
|
14
|
-
require('
|
|
14
|
+
require('@jobber/hooks/useShowClear');
|
|
15
|
+
require('../Button-8bde6560.js');
|
|
15
16
|
require('react-router-dom');
|
|
16
|
-
require('../Icon-
|
|
17
|
+
require('../Icon-361343e0.js');
|
|
17
18
|
require('@jobber/design');
|
|
18
|
-
require('../Typography-
|
|
19
|
-
require('../Text-
|
|
20
|
-
require('../InputValidation-
|
|
19
|
+
require('../Typography-75f58b60.js');
|
|
20
|
+
require('../Text-9f261dde.js');
|
|
21
|
+
require('../InputValidation-fdc891af.js');
|
|
21
22
|
require('framer-motion');
|
|
22
|
-
require('../Spinner-
|
|
23
|
+
require('../Spinner-cac356ee.js');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
26
|
|
|
26
27
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
28
|
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
28
29
|
|
|
29
|
-
// https://stackoverflow.com/a/10199306/1611058
|
|
30
|
-
function get_time_support() {
|
|
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;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var timeSupport = get_time_support();
|
|
39
|
-
if (window) window.supportsTime = timeSupport;
|
|
40
|
-
|
|
41
|
-
var supportsTime = timeSupport;
|
|
42
|
-
|
|
43
|
-
function leading_zero(number) {
|
|
44
|
-
if (isNaN(number)) return number;
|
|
45
|
-
var purified = parseInt(number);
|
|
46
|
-
return purified < 10 ? '0' + purified : number;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function convert_to_24hr_time(timeString_12hr) {
|
|
50
|
-
if (/-/.test(timeString_12hr)) return '';
|
|
51
|
-
var isPM = timeString_12hr.indexOf('PM') > -1;
|
|
52
|
-
var timeResult = /^([0-9]{2})/.exec(timeString_12hr);
|
|
53
|
-
var hrs = timeResult ? parseInt(timeResult[1]) : '';
|
|
54
|
-
var newHrs;
|
|
55
|
-
|
|
56
|
-
if (hrs === 12) {
|
|
57
|
-
newHrs = isPM ? 12 : 0;
|
|
58
|
-
} else {
|
|
59
|
-
newHrs = isPM ? hrs + 12 : hrs;
|
|
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
|
-
}
|
|
172
|
-
|
|
173
|
-
var ranges = {
|
|
174
|
-
hrs: {
|
|
175
|
-
start: 0,
|
|
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
|
-
}
|
|
207
|
-
|
|
208
|
-
return 'hrs';
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
var manual_entry_log = [];
|
|
212
|
-
|
|
213
|
-
function clear() {
|
|
214
|
-
manual_entry_log = [];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function add(entry) {
|
|
218
|
-
manual_entry_log.push(entry);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function items() {
|
|
222
|
-
return manual_entry_log;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
var manual_entry_log$1 = {
|
|
226
|
-
items: items,
|
|
227
|
-
clear: clear,
|
|
228
|
-
add: add
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
var segments = Object.keys(ranges);
|
|
232
|
-
|
|
233
|
-
function get_values($input, timeString) {
|
|
234
|
-
var value = timeString ? timeString : $input.value;
|
|
235
|
-
var regEx = /([0-9-]{1,2})\:([0-9-]{1,2})\s?(AM|PM|\-\-)?/;
|
|
236
|
-
var result = regEx.exec(value);
|
|
237
|
-
return {
|
|
238
|
-
hrs: convert_number(result[1]),
|
|
239
|
-
min: convert_number(result[2]),
|
|
240
|
-
mode: result[3]
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function update_a11y($input, announcementArray) {
|
|
245
|
-
// Timeout helps ensure that the input has stabilized
|
|
246
|
-
setTimeout(function () {
|
|
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;
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
function switch_times($input, format) {
|
|
447
|
-
var is12hr = /\s/.test($input.value);
|
|
448
|
-
|
|
449
|
-
if (format != 12 && format != 24) {
|
|
450
|
-
format = is12hr ? 24 : 12;
|
|
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
|
-
}
|
|
467
|
-
|
|
468
|
-
function handle_tab($input, e) {
|
|
469
|
-
var current_segment = get_current_segment($input);
|
|
470
|
-
var backwards_and_first = e.shiftKey && current_segment === 'hrs';
|
|
471
|
-
var forwards_and_last = !e.shiftKey && current_segment === 'mode';
|
|
472
|
-
|
|
473
|
-
if (!backwards_and_first && !forwards_and_last) {
|
|
474
|
-
e.preventDefault();
|
|
475
|
-
|
|
476
|
-
if (e.shiftKey) {
|
|
477
|
-
prev_segment($input);
|
|
478
|
-
} else {
|
|
479
|
-
next_segment($input);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
var named_keys = {
|
|
485
|
-
ArrowDown: 40,
|
|
486
|
-
ArrowRight: 39,
|
|
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
|
-
}
|
|
535
|
-
|
|
536
|
-
update_a11y($input, ['initial', 'select']);
|
|
537
|
-
});
|
|
538
|
-
$input.addEventListener('keydown', function (e) {
|
|
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
|
-
}
|
|
550
|
-
|
|
551
|
-
if (is_number_key) {
|
|
552
|
-
manual_number_entry($input, e.which);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if (is_delete_key) {
|
|
556
|
-
var segment = get_current_segment($input);
|
|
557
|
-
clear_segment($input, segment);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
switch (e.which) {
|
|
561
|
-
case named_keys.ArrowRight:
|
|
562
|
-
next_segment($input);
|
|
563
|
-
break;
|
|
564
|
-
|
|
565
|
-
case named_keys.ArrowLeft:
|
|
566
|
-
prev_segment($input);
|
|
567
|
-
break;
|
|
568
|
-
|
|
569
|
-
case named_keys.ArrowUp:
|
|
570
|
-
increment_current_segment($input);
|
|
571
|
-
break;
|
|
572
|
-
|
|
573
|
-
case named_keys.ArrowDown:
|
|
574
|
-
decrement_current_segment($input);
|
|
575
|
-
break;
|
|
576
|
-
|
|
577
|
-
case named_keys.Escape:
|
|
578
|
-
reset($input);
|
|
579
|
-
break;
|
|
580
|
-
|
|
581
|
-
case named_keys.a:
|
|
582
|
-
set_mode($input, 'AM');
|
|
583
|
-
break;
|
|
584
|
-
|
|
585
|
-
case named_keys.p:
|
|
586
|
-
set_mode($input, 'PM');
|
|
587
|
-
break;
|
|
588
|
-
|
|
589
|
-
case named_keys.Tab:
|
|
590
|
-
handle_tab($input, e);
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
function auto_swap($input) {
|
|
597
|
-
if ($input.polyfill.autoSwap) {
|
|
598
|
-
switch_times($input, 24);
|
|
599
|
-
setTimeout(function () {
|
|
600
|
-
switch_times($input, 12);
|
|
601
|
-
}, 1);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
// selector is optional, it allows for an early exit
|
|
606
|
-
var get_ancestors = function ($input, selectorString) {
|
|
607
|
-
var $elem = $input; // https://stackoverflow.com/a/8729274/1611058
|
|
608
|
-
|
|
609
|
-
var ancestors = [];
|
|
610
|
-
|
|
611
|
-
while ($elem) {
|
|
612
|
-
ancestors.push($elem);
|
|
613
|
-
var matchesSelector = $elem.msMatchesSelector ? $elem.msMatchesSelector(selectorString) : $elem.matches(selectorString);
|
|
614
|
-
|
|
615
|
-
if (matchesSelector) {
|
|
616
|
-
return ancestors;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
$elem = $elem.parentElement;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
return ancestors;
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
function get_label($input) {
|
|
626
|
-
var labelText = aria_labelledby($input) || aria_label($input) || for_attribute($input) || label_wrapper_element($input) || title_attribute($input);
|
|
627
|
-
if (labelText) return labelText;
|
|
628
|
-
console.error('Label text for input not found.', $input);
|
|
629
|
-
throw new Error('Cannot polyfill time input due to a missing label.');
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
function aria_labelledby($input) {
|
|
633
|
-
var ariaLabelByID = $input.getAttribute('aria-labelledby');
|
|
634
|
-
|
|
635
|
-
if (ariaLabelByID) {
|
|
636
|
-
var $ariaLabelBy = document.getElementById(ariaLabelByID);
|
|
637
|
-
if ($ariaLabelBy) return $ariaLabelBy.textContent;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
return false;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
function aria_label($input) {
|
|
644
|
-
var ariaLabel = $input.getAttribute('aria-label');
|
|
645
|
-
if (ariaLabel) return ariaLabel;
|
|
646
|
-
return false;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
function for_attribute($input) {
|
|
650
|
-
if ($input.id) {
|
|
651
|
-
var $forLabel = document.querySelector('label[for="' + $input.id + '"]');
|
|
652
|
-
if ($forLabel) return $forLabel.textContent;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
function label_wrapper_element($input) {
|
|
659
|
-
var ancestors = get_ancestors($input, 'label');
|
|
660
|
-
var $parentLabel = ancestors[ancestors.length - 1];
|
|
661
|
-
if ($parentLabel.nodeName == 'LABEL') return $parentLabel.textContent;
|
|
662
|
-
return false;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
function title_attribute($input) {
|
|
666
|
-
var titleLabel = $input.getAttribute('title');
|
|
667
|
-
if (titleLabel) return titleLabel;
|
|
668
|
-
return false;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
function create_accessibility_block() {
|
|
672
|
-
var $block = document.createElement('div');
|
|
673
|
-
$block.setAttribute('aria-live', 'assertive');
|
|
674
|
-
$block.setAttribute('style', 'position: absolute; opacity: 0; height: 0; width: 0; overflow: hidden; pointer-events: none;');
|
|
675
|
-
$block.classList.add('time-input-polyfill-accessibility-block');
|
|
676
|
-
document.querySelector('body').appendChild($block);
|
|
677
|
-
return $block;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
var accessibility_block_created = false;
|
|
681
|
-
var $a11y;
|
|
682
|
-
|
|
683
|
-
function TimePolyfill($input, $label) {
|
|
684
|
-
$input.setAttribute('autocomplete', 'off'); // Prevent screen reader from announcing the default stuff
|
|
685
|
-
|
|
686
|
-
$input.setAttribute('aria-hidden', true);
|
|
687
|
-
|
|
688
|
-
if (!accessibility_block_created) {
|
|
689
|
-
$a11y = create_accessibility_block();
|
|
690
|
-
accessibility_block_created = true;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
var label = $label ? $label.textContent : get_label($input);
|
|
694
|
-
$input.polyfill = {
|
|
695
|
-
$a11y: $a11y,
|
|
696
|
-
label: label,
|
|
697
|
-
autoSwap: true,
|
|
698
|
-
update: function update() {
|
|
699
|
-
update_time($input);
|
|
700
|
-
},
|
|
701
|
-
swap: function swap(forcedFormat) {
|
|
702
|
-
switch_times($input, forcedFormat);
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
if ($input.value === '' || /--/.test($input.value)) {
|
|
707
|
-
apply_default($input);
|
|
708
|
-
set_data_attribute($input, '');
|
|
709
|
-
} else {
|
|
710
|
-
update_time($input);
|
|
711
|
-
set_data_attribute($input, $input.value);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
bind_events($input);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
if (window) {
|
|
718
|
-
window.TimePolyfill = TimePolyfill;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
var index_cjs = TimePolyfill;
|
|
722
|
-
|
|
723
30
|
function civilTimeToHTMLTime(civilTime) {
|
|
724
31
|
if (civilTime == undefined) {
|
|
725
32
|
return "";
|
|
@@ -737,40 +44,50 @@ function htmlTimeToCivilTime(timeString) {
|
|
|
737
44
|
}
|
|
738
45
|
|
|
739
46
|
function InputTimeSafari(_a) {
|
|
47
|
+
var _b, _c;
|
|
740
48
|
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
741
49
|
const inputTime = React__default["default"].createRef();
|
|
742
50
|
const debouncedHandleChange = debounce__default["default"](handleChange, 1000);
|
|
743
51
|
const changeHandler = generateEventHandler(debouncedHandleChange);
|
|
744
52
|
const blurHandler = generateEventHandler(handleChange);
|
|
745
|
-
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
input
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
53
|
+
useSafeLayoutEffect.useSafeLayoutEffect(() => {
|
|
54
|
+
const setupTimePolyfill = () => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const input = inputTime.current;
|
|
57
|
+
const { TimePolyfill } = yield Promise.resolve().then(function () { return require('../TimeInputPolyfill.client-1dfc8ab1.js'); });
|
|
58
|
+
new TimePolyfill(input);
|
|
59
|
+
if (value && input.polyfill) {
|
|
60
|
+
input.value = civilTimeToHTMLTime(value);
|
|
61
|
+
(_a = input.polyfill) === null || _a === void 0 ? void 0 : _a.update();
|
|
62
|
+
}
|
|
63
|
+
if (defaultValue && input.polyfill) {
|
|
64
|
+
input.value = civilTimeToHTMLTime(defaultValue);
|
|
65
|
+
(_b = input.polyfill) === null || _b === void 0 ? void 0 : _b.update();
|
|
66
|
+
}
|
|
67
|
+
input.addEventListener("change", changeHandler);
|
|
68
|
+
input.addEventListener("blur", blurHandler);
|
|
69
|
+
});
|
|
70
|
+
setupTimePolyfill();
|
|
758
71
|
return () => {
|
|
759
72
|
window.removeEventListener("change", changeHandler);
|
|
760
73
|
window.removeEventListener("blur", blurHandler);
|
|
761
74
|
};
|
|
762
|
-
}, []);
|
|
763
|
-
|
|
75
|
+
}, [(_b = inputTime.current) === null || _b === void 0 ? void 0 : _b.polyfill]);
|
|
76
|
+
useSafeLayoutEffect.useSafeLayoutEffect(() => {
|
|
764
77
|
const input = inputTime.current;
|
|
765
|
-
if (value) {
|
|
78
|
+
if (value && input.polyfill) {
|
|
766
79
|
input.value = civilTimeToHTMLTime(value);
|
|
767
80
|
input.polyfill.update();
|
|
768
81
|
}
|
|
769
|
-
if (defaultValue) {
|
|
82
|
+
if (defaultValue && input.polyfill) {
|
|
770
83
|
input.value = civilTimeToHTMLTime(defaultValue);
|
|
771
84
|
input.polyfill.update();
|
|
772
85
|
}
|
|
773
|
-
}, [
|
|
86
|
+
}, [
|
|
87
|
+
value,
|
|
88
|
+
defaultValue,
|
|
89
|
+
(_c = inputTime.current) === null || _c === void 0 ? void 0 : _c.polyfill,
|
|
90
|
+
]);
|
|
774
91
|
return React__default["default"].createElement(FormField.FormField, Object.assign({ inputRef: inputTime, type: "time" }, params));
|
|
775
92
|
function handleChange(newValue) {
|
|
776
93
|
onChange && onChange(htmlTimeToCivilTime(newValue));
|
|
@@ -785,13 +102,21 @@ function InputTimeSafari(_a) {
|
|
|
785
102
|
}
|
|
786
103
|
}
|
|
787
104
|
|
|
788
|
-
function
|
|
105
|
+
function InternalInputTime(_a) {
|
|
789
106
|
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
107
|
+
const [supportsTime, setSupportsTime] = React.useState(false);
|
|
790
108
|
const handleChange = (newValue) => {
|
|
791
109
|
onChange && onChange(htmlTimeToCivilTime(newValue));
|
|
792
110
|
};
|
|
111
|
+
React.useEffect(() => {
|
|
112
|
+
const getTime = () => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const { supportsTime: externalSupportsTime } = yield Promise.resolve().then(function () { return require('../SupportsTimePolyfill-466a30f9.js'); });
|
|
114
|
+
setSupportsTime(externalSupportsTime);
|
|
115
|
+
});
|
|
116
|
+
getTime();
|
|
117
|
+
}, []);
|
|
793
118
|
if (supportsTime) {
|
|
794
|
-
const fieldProps = Object.assign(Object.assign(Object.assign({ onChange: handleChange }, (defaultValue && { defaultValue: civilTimeToHTMLTime(defaultValue) })), (!defaultValue && { value: civilTimeToHTMLTime(value) })), params);
|
|
119
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({ onChange: onChange && handleChange }, (defaultValue && { defaultValue: civilTimeToHTMLTime(defaultValue) })), (!defaultValue && onChange && { value: civilTimeToHTMLTime(value) })), params);
|
|
795
120
|
return React__default["default"].createElement(FormField.FormField, Object.assign({ type: "time" }, fieldProps));
|
|
796
121
|
}
|
|
797
122
|
else {
|
|
@@ -799,4 +124,13 @@ function InputTime(_a) {
|
|
|
799
124
|
}
|
|
800
125
|
}
|
|
801
126
|
|
|
127
|
+
const canUseDom = !!(typeof window !== "undefined" &&
|
|
128
|
+
window.document &&
|
|
129
|
+
window.document.createElement);
|
|
130
|
+
function InputTimeSafe(props) {
|
|
131
|
+
return (React__default["default"].createElement(ClientOnly.ClientOnly, null,
|
|
132
|
+
React__default["default"].createElement(InternalInputTime, Object.assign({}, props))));
|
|
133
|
+
}
|
|
134
|
+
const InputTime = canUseDom ? InputTimeSafe : () => null;
|
|
135
|
+
|
|
802
136
|
exports.InputTime = InputTime;
|