grommet 2.54.0 → 2.56.0
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/components/Button/Button.js +7 -4
- package/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +86 -0
- package/components/Calendar/Calendar.js +24 -16
- package/components/Calendar/index.d.ts +1 -1
- package/components/Calendar/stories/CustomHeader.stories.js +6 -1
- package/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
- package/components/Calendar/stories/Dual.stories.js +23 -11
- package/components/Calendar/stories/HeaderLevel.stories.js +6 -1
- package/components/Calendar/stories/Multiple.stories.js +8 -3
- package/components/Calendar/stories/Simple.stories.js +6 -1
- package/components/Cards/Cards.js +164 -10
- package/components/Cards/StyledCellContainer.js +29 -0
- package/components/Cards/index.d.ts +4 -1
- package/components/Cards/propTypes.js +2 -0
- package/components/Cards/stories/Sizable.stories.js +70 -0
- package/components/Cards/stories/onOrder.stories.js +69 -0
- package/components/DataFilter/DataFilter.js +21 -28
- package/components/DateInput/DateInput.js +57 -24
- package/components/DateInput/index.d.ts +1 -0
- package/components/DateInput/utils.js +2 -2
- package/components/Drop/DropContainer.js +59 -3
- package/components/FileInput/FileInput.js +3 -0
- package/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
- package/components/Form/stories/FieldStates.stories.js +7 -1
- package/components/FormField/FormField.js +1 -1
- package/components/Grommet/Grommet.js +2 -1
- package/components/Grommet/index.d.ts +27 -0
- package/components/Grommet/propTypes.js +33 -1
- package/components/Layer/LayerContainer.d.ts +40 -0
- package/components/Select/stories/ChildrenRender.stories.js +28 -55
- package/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
- package/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
- package/components/Stepper/StepConnector.js +68 -0
- package/components/Stepper/Stepper.js +309 -0
- package/components/Stepper/StepperContext.js +43 -0
- package/components/Stepper/StepperDescription.js +26 -0
- package/components/Stepper/StepperHelperText.js +44 -0
- package/components/Stepper/StepperIndicator.js +74 -0
- package/components/Stepper/StepperLabel.js +41 -0
- package/components/Stepper/StepperStep.js +127 -0
- package/components/Stepper/StyledStepper.js +124 -0
- package/components/Stepper/index.d.ts +80 -0
- package/components/Stepper/index.js +18 -0
- package/components/Stepper/propTypes.js +35 -0
- package/components/Stepper/stories/DisabledSteps.stories.js +45 -0
- package/components/Stepper/stories/ErrorStates.stories.js +45 -0
- package/components/Stepper/stories/HorizontalSteps.stories.js +50 -0
- package/components/Stepper/stories/Interactive.stories.js +60 -0
- package/components/Stepper/stories/KeyboardNavigation.stories.js +64 -0
- package/components/Stepper/stories/NestedSubSteps.stories.js +70 -0
- package/components/Stepper/stories/ReadOnly.stories.js +43 -0
- package/components/Stepper/stories/ThemingLightDark.stories.js +58 -0
- package/components/Stepper/stories/VerticalSteps.stories.js +67 -0
- package/components/Tab/Tab.js +19 -6
- package/components/Tabs/Tabs.js +156 -22
- package/components/Tag/Tag.js +4 -3
- package/components/Tag/index.d.ts +5 -4
- package/components/Tag/propTypes.js +3 -2
- package/components/TextInput/StyledTextInput.js +4 -2
- package/components/TextInput/TextInput.js +1 -0
- package/components/TimeInput/README.md +2 -0
- package/components/TimeInput/StyledTimeInput.js +73 -0
- package/components/TimeInput/TimeInput.js +689 -0
- package/components/TimeInput/TimeInputPopup.js +393 -0
- package/components/TimeInput/index.d.ts +41 -0
- package/components/TimeInput/index.js +6 -0
- package/components/TimeInput/propTypes.js +35 -0
- package/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/components/TimeInput/useSectionedTimeField.js +359 -0
- package/components/TimeInput/utils.js +187 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +12 -0
- package/es6/components/Button/Button.js +7 -4
- package/es6/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +81 -0
- package/es6/components/Calendar/Calendar.js +24 -16
- package/es6/components/Calendar/index.d.ts +1 -1
- package/es6/components/Calendar/stories/CustomHeader.stories.js +6 -1
- package/es6/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
- package/es6/components/Calendar/stories/Dual.stories.js +23 -11
- package/es6/components/Calendar/stories/HeaderLevel.stories.js +6 -1
- package/es6/components/Calendar/stories/Multiple.stories.js +8 -3
- package/es6/components/Calendar/stories/Simple.stories.js +6 -1
- package/es6/components/Cards/Cards.js +165 -12
- package/es6/components/Cards/StyledCellContainer.js +24 -0
- package/es6/components/Cards/index.d.ts +4 -1
- package/es6/components/Cards/propTypes.js +2 -0
- package/es6/components/Cards/stories/Sizable.stories.js +65 -0
- package/es6/components/Cards/stories/onOrder.stories.js +64 -0
- package/es6/components/DataFilter/DataFilter.js +21 -28
- package/es6/components/DateInput/DateInput.js +57 -24
- package/es6/components/DateInput/index.d.ts +1 -0
- package/es6/components/DateInput/utils.js +2 -2
- package/es6/components/Drop/DropContainer.js +59 -3
- package/es6/components/FileInput/FileInput.js +3 -0
- package/es6/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
- package/es6/components/Form/stories/FieldStates.stories.js +7 -1
- package/es6/components/FormField/FormField.js +1 -1
- package/es6/components/Grommet/Grommet.js +2 -1
- package/es6/components/Grommet/index.d.ts +27 -0
- package/es6/components/Grommet/propTypes.js +33 -1
- package/es6/components/Layer/LayerContainer.d.ts +40 -0
- package/es6/components/Select/stories/ChildrenRender.stories.js +29 -56
- package/es6/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
- package/es6/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
- package/es6/components/Stepper/StepConnector.js +63 -0
- package/es6/components/Stepper/Stepper.js +306 -0
- package/es6/components/Stepper/StepperContext.js +39 -0
- package/es6/components/Stepper/StepperDescription.js +21 -0
- package/es6/components/Stepper/StepperHelperText.js +39 -0
- package/es6/components/Stepper/StepperIndicator.js +69 -0
- package/es6/components/Stepper/StepperLabel.js +36 -0
- package/es6/components/Stepper/StepperStep.js +122 -0
- package/es6/components/Stepper/StyledStepper.js +120 -0
- package/es6/components/Stepper/index.d.ts +80 -0
- package/es6/components/Stepper/index.js +6 -0
- package/es6/components/Stepper/propTypes.js +30 -0
- package/es6/components/Stepper/stories/DisabledSteps.stories.js +41 -0
- package/es6/components/Stepper/stories/ErrorStates.stories.js +41 -0
- package/es6/components/Stepper/stories/HorizontalSteps.stories.js +46 -0
- package/es6/components/Stepper/stories/Interactive.stories.js +56 -0
- package/es6/components/Stepper/stories/KeyboardNavigation.stories.js +60 -0
- package/es6/components/Stepper/stories/NestedSubSteps.stories.js +66 -0
- package/es6/components/Stepper/stories/ReadOnly.stories.js +39 -0
- package/es6/components/Stepper/stories/ThemingLightDark.stories.js +54 -0
- package/es6/components/Stepper/stories/VerticalSteps.stories.js +63 -0
- package/es6/components/Tab/Tab.js +19 -6
- package/es6/components/Tabs/Tabs.js +157 -23
- package/es6/components/Tag/Tag.js +4 -3
- package/es6/components/Tag/index.d.ts +5 -4
- package/es6/components/Tag/propTypes.js +3 -2
- package/es6/components/TextInput/StyledTextInput.js +4 -2
- package/es6/components/TextInput/TextInput.js +1 -0
- package/es6/components/TimeInput/README.md +2 -0
- package/es6/components/TimeInput/StyledTimeInput.js +68 -0
- package/es6/components/TimeInput/TimeInput.js +685 -0
- package/es6/components/TimeInput/TimeInputPopup.js +389 -0
- package/es6/components/TimeInput/index.d.ts +41 -0
- package/es6/components/TimeInput/index.js +1 -0
- package/es6/components/TimeInput/propTypes.js +30 -0
- package/es6/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/es6/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/es6/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/es6/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/es6/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/es6/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +356 -0
- package/es6/components/TimeInput/utils.js +183 -0
- package/es6/components/index.d.ts +2 -0
- package/es6/components/index.js +2 -0
- package/es6/index.d.ts +2 -0
- package/es6/languages/default.json +27 -1
- package/es6/themes/base.d.ts +109 -0
- package/es6/themes/base.js +208 -0
- package/es6/utils/index.d.ts +1 -0
- package/es6/utils/styles.js +23 -12
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +2 -0
- package/languages/default.json +27 -1
- package/package.json +51 -53
- package/themes/base.d.ts +109 -0
- package/themes/base.js +208 -0
- package/utils/index.d.ts +1 -0
- package/utils/styles.js +23 -12
- package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -79
- package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -74
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
var _excluded = ["defaultValue", "disabled", "format", "id", "messages", "minuteStep", "name", "onChange", "readOnly", "value"],
|
|
2
|
+
_excluded2 = ["plain", "focusIndicator"];
|
|
3
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
5
|
+
import React, { forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { Clock as GrommetClockIcon } from 'grommet-icons/icons/Clock';
|
|
7
|
+
import { AnnounceContext } from '../../contexts/AnnounceContext';
|
|
8
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
9
|
+
import { useForwardedRef } from '../../utils';
|
|
10
|
+
import { useThemeValue } from '../../utils/useThemeValue';
|
|
11
|
+
import { Box } from '../Box';
|
|
12
|
+
import { Button } from '../Button';
|
|
13
|
+
import { FormContext } from '../Form';
|
|
14
|
+
import { Keyboard } from '../Keyboard';
|
|
15
|
+
import { StyledTimeInputDisplay, StyledTimeInputField, StyledTimeInputSegment, StyledTimeInputSeparator, StyledTimeInputContainer, StyledTimeInput } from './StyledTimeInput';
|
|
16
|
+
import { TimeInputPopup } from './TimeInputPopup';
|
|
17
|
+
import { TimeInputPropTypes } from './propTypes';
|
|
18
|
+
import { useSectionedTimeField } from './useSectionedTimeField';
|
|
19
|
+
import { getSectionAriaMeta, getSectionName, pad, SECTION_HOUR, SECTION_MINUTE, SECTION_PERIOD, SECTION_SECOND } from './utils';
|
|
20
|
+
var sectionTypeToSection = {
|
|
21
|
+
hours: SECTION_HOUR,
|
|
22
|
+
minutes: SECTION_MINUTE,
|
|
23
|
+
seconds: SECTION_SECOND,
|
|
24
|
+
meridiem: SECTION_PERIOD
|
|
25
|
+
};
|
|
26
|
+
var getSectionKey = function getSectionKey(section) {
|
|
27
|
+
if (section === SECTION_HOUR) return 'hour';
|
|
28
|
+
if (section === SECTION_MINUTE) return 'minute';
|
|
29
|
+
if (section === SECTION_SECOND) return 'second';
|
|
30
|
+
return 'period';
|
|
31
|
+
};
|
|
32
|
+
var getSectionToken = function getSectionToken(section) {
|
|
33
|
+
if (section === SECTION_HOUR) return 'hh';
|
|
34
|
+
if (section === SECTION_MINUTE) return 'mm';
|
|
35
|
+
if (section === SECTION_SECOND) return 'ss';
|
|
36
|
+
return 'aa';
|
|
37
|
+
};
|
|
38
|
+
var getDisplaySectionKey = function getDisplaySectionKey(section) {
|
|
39
|
+
if (section === SECTION_HOUR) return 'hour';
|
|
40
|
+
if (section === SECTION_MINUTE) return 'minute';
|
|
41
|
+
if (section === SECTION_SECOND) return 'second';
|
|
42
|
+
return 'period';
|
|
43
|
+
};
|
|
44
|
+
var getDisplaySectionPrefix = function getDisplaySectionPrefix(section, index) {
|
|
45
|
+
if (index === 0) return '';
|
|
46
|
+
return section === SECTION_PERIOD ? ' ' : ':';
|
|
47
|
+
};
|
|
48
|
+
var getDisplaySectionText = function getDisplaySectionText(_ref) {
|
|
49
|
+
var key = _ref.key,
|
|
50
|
+
section = _ref.section,
|
|
51
|
+
sections = _ref.sections;
|
|
52
|
+
if (sections[key] === undefined) return getSectionToken(section);
|
|
53
|
+
if (section === SECTION_PERIOD) return sections[key];
|
|
54
|
+
return pad(sections[key]);
|
|
55
|
+
};
|
|
56
|
+
var getSectionOrder = function getSectionOrder(format, views) {
|
|
57
|
+
var normalizedViews = Array.isArray(views) && views.length ? views : ['hours', 'minutes', 'seconds'];
|
|
58
|
+
var numericSections = normalizedViews.filter(function (view) {
|
|
59
|
+
return view !== 'meridiem';
|
|
60
|
+
}).map(function (view) {
|
|
61
|
+
return sectionTypeToSection[view];
|
|
62
|
+
}).filter(function (section) {
|
|
63
|
+
return section !== undefined;
|
|
64
|
+
});
|
|
65
|
+
if (format === '12') {
|
|
66
|
+
var includePeriod = normalizedViews.includes('meridiem') || normalizedViews.includes('hours');
|
|
67
|
+
if (includePeriod) return [].concat(numericSections, [SECTION_PERIOD]);
|
|
68
|
+
}
|
|
69
|
+
return numericSections;
|
|
70
|
+
};
|
|
71
|
+
var buildPlaceholder = function buildPlaceholder(sectionOrder) {
|
|
72
|
+
return sectionOrder.map(function (section, index) {
|
|
73
|
+
var token = getSectionToken(section);
|
|
74
|
+
if (index === 0) return token;
|
|
75
|
+
return "" + (section === SECTION_PERIOD ? ' ' : ':') + token;
|
|
76
|
+
}).join('');
|
|
77
|
+
};
|
|
78
|
+
var normalizeStep = function normalizeStep(step) {
|
|
79
|
+
var parsed = Number(step);
|
|
80
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 1;
|
|
81
|
+
return Math.max(1, Math.floor(parsed));
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// When `format` isn't explicitly provided, default to the 12/24-hour
|
|
85
|
+
// convention the browser's default locale uses, rather than hardcoding one.
|
|
86
|
+
var getDefaultFormat = function getDefaultFormat() {
|
|
87
|
+
try {
|
|
88
|
+
var _Intl$DateTimeFormat$ = new Intl.DateTimeFormat(undefined, {
|
|
89
|
+
hour: 'numeric'
|
|
90
|
+
}).resolvedOptions(),
|
|
91
|
+
hour12 = _Intl$DateTimeFormat$.hour12;
|
|
92
|
+
return hour12 ? '12' : '24';
|
|
93
|
+
} catch (_unused) {
|
|
94
|
+
return '24';
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var DEFAULT_FORMAT = getDefaultFormat();
|
|
98
|
+
var TimeInput = /*#__PURE__*/forwardRef(function (_ref2, refArg) {
|
|
99
|
+
var _theme$timeInput, _theme$global, _theme$timeInput2;
|
|
100
|
+
var defaultValue = _ref2.defaultValue,
|
|
101
|
+
disabled = _ref2.disabled,
|
|
102
|
+
_ref2$format = _ref2.format,
|
|
103
|
+
format = _ref2$format === void 0 ? DEFAULT_FORMAT : _ref2$format,
|
|
104
|
+
id = _ref2.id,
|
|
105
|
+
messages = _ref2.messages,
|
|
106
|
+
_ref2$minuteStep = _ref2.minuteStep,
|
|
107
|
+
minuteStep = _ref2$minuteStep === void 0 ? 1 : _ref2$minuteStep,
|
|
108
|
+
name = _ref2.name,
|
|
109
|
+
onChange = _ref2.onChange,
|
|
110
|
+
_ref2$readOnly = _ref2.readOnly,
|
|
111
|
+
readOnly = _ref2$readOnly === void 0 ? false : _ref2$readOnly,
|
|
112
|
+
valueArg = _ref2.value,
|
|
113
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
114
|
+
var _useThemeValue = useThemeValue(),
|
|
115
|
+
theme = _useThemeValue.theme,
|
|
116
|
+
passThemeFlag = _useThemeValue.passThemeFlag;
|
|
117
|
+
var announce = useContext(AnnounceContext);
|
|
118
|
+
var _useContext = useContext(MessageContext),
|
|
119
|
+
formatMessage = _useContext.format;
|
|
120
|
+
var formContext = useContext(FormContext);
|
|
121
|
+
var useFormInput = formContext.useFormInput;
|
|
122
|
+
var inputRef = useForwardedRef(refArg);
|
|
123
|
+
var containerRef = useRef();
|
|
124
|
+
var _useFormInput = useFormInput({
|
|
125
|
+
name: name,
|
|
126
|
+
value: valueArg,
|
|
127
|
+
initialValue: defaultValue || ''
|
|
128
|
+
}),
|
|
129
|
+
value = _useFormInput[0],
|
|
130
|
+
setValue = _useFormInput[1];
|
|
131
|
+
useEffect(function () {
|
|
132
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
133
|
+
console.warn('Warning: TimeInput is currently in beta. The API is subject ' + 'to change in future releases.');
|
|
134
|
+
}
|
|
135
|
+
}, []);
|
|
136
|
+
var _formContext$useFormF = formContext.useFormField({}),
|
|
137
|
+
inForm = _formContext$useFormF.inForm;
|
|
138
|
+
var formFieldLabelId = inForm && id ? "grommet-" + id + "__label" : undefined;
|
|
139
|
+
var groupLabel = formFieldLabelId ? undefined : formatMessage({
|
|
140
|
+
id: 'timeInput.inputLabel',
|
|
141
|
+
messages: messages
|
|
142
|
+
});
|
|
143
|
+
var _useState = useState(false),
|
|
144
|
+
open = _useState[0],
|
|
145
|
+
setOpen = _useState[1];
|
|
146
|
+
var _useState2 = useState(false),
|
|
147
|
+
iconFocused = _useState2[0],
|
|
148
|
+
setIconFocused = _useState2[1];
|
|
149
|
+
var _useState3 = useState(false),
|
|
150
|
+
segmentFocused = _useState3[0],
|
|
151
|
+
setSegmentFocused = _useState3[1];
|
|
152
|
+
var segmentRefs = useRef({});
|
|
153
|
+
var plainProp = rest.plain,
|
|
154
|
+
focusIndicatorProp = rest.focusIndicator,
|
|
155
|
+
inputRest = _objectWithoutPropertiesLoose(rest, _excluded2);
|
|
156
|
+
var normalizedMinuteStep = useMemo(function () {
|
|
157
|
+
return normalizeStep(minuteStep);
|
|
158
|
+
}, [minuteStep]);
|
|
159
|
+
var handleInvalid = useCallback(function () {
|
|
160
|
+
var error = formatMessage({
|
|
161
|
+
id: 'timeInput.invalidTime',
|
|
162
|
+
messages: messages
|
|
163
|
+
});
|
|
164
|
+
announce(error, 'assertive');
|
|
165
|
+
}, [announce, formatMessage, messages]);
|
|
166
|
+
var announceCurrentValue = useCallback(function (nextSections) {
|
|
167
|
+
if (nextSections.hour === undefined || nextSections.minute === undefined || nextSections.second === undefined) return;
|
|
168
|
+
var period = format === '12' ? " " + (nextSections.period || 'AM') : '';
|
|
169
|
+
announce(formatMessage({
|
|
170
|
+
id: 'timeInput.currentValue',
|
|
171
|
+
messages: messages,
|
|
172
|
+
values: {
|
|
173
|
+
hour: nextSections.hour,
|
|
174
|
+
minute: nextSections.minute,
|
|
175
|
+
second: nextSections.second,
|
|
176
|
+
period: period
|
|
177
|
+
}
|
|
178
|
+
}), 'polite');
|
|
179
|
+
}, [announce, format, formatMessage, messages]);
|
|
180
|
+
var sectionOrder = useMemo(function () {
|
|
181
|
+
return getSectionOrder(format);
|
|
182
|
+
}, [format]);
|
|
183
|
+
var firstSection = sectionOrder[0] || SECTION_HOUR;
|
|
184
|
+
var lastSection = sectionOrder[sectionOrder.length - 1] || SECTION_HOUR;
|
|
185
|
+
var _useSectionedTimeFiel = useSectionedTimeField({
|
|
186
|
+
format: format,
|
|
187
|
+
sectionOrder: sectionOrder,
|
|
188
|
+
minuteStep: normalizedMinuteStep,
|
|
189
|
+
value: value,
|
|
190
|
+
onCommit: function onCommit(_nextSections, nextValue) {
|
|
191
|
+
if (!nextValue) {
|
|
192
|
+
setValue('');
|
|
193
|
+
onChange == null || onChange({
|
|
194
|
+
value: undefined
|
|
195
|
+
});
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
setValue(nextValue);
|
|
199
|
+
onChange == null || onChange({
|
|
200
|
+
value: nextValue
|
|
201
|
+
});
|
|
202
|
+
announceCurrentValue(_nextSections);
|
|
203
|
+
},
|
|
204
|
+
onInvalid: handleInvalid
|
|
205
|
+
}),
|
|
206
|
+
activeSection = _useSectionedTimeFiel.activeSection,
|
|
207
|
+
applyDigit = _useSectionedTimeFiel.applyDigit,
|
|
208
|
+
clearActiveSection = _useSectionedTimeFiel.clearActiveSection,
|
|
209
|
+
commitSections = _useSectionedTimeFiel.commitSections,
|
|
210
|
+
displayValue = _useSectionedTimeFiel.displayValue,
|
|
211
|
+
incrementSection = _useSectionedTimeFiel.incrementSection,
|
|
212
|
+
moveSection = _useSectionedTimeFiel.moveSection,
|
|
213
|
+
parsePasted = _useSectionedTimeFiel.parsePasted,
|
|
214
|
+
sections = _useSectionedTimeFiel.sections,
|
|
215
|
+
setActiveSection = _useSectionedTimeFiel.setActiveSection,
|
|
216
|
+
setSectionValue = _useSectionedTimeFiel.setSectionValue,
|
|
217
|
+
pendingDigits = _useSectionedTimeFiel.pendingDigits;
|
|
218
|
+
|
|
219
|
+
// Builds the announcement text for a given section: its current value
|
|
220
|
+
// (e.g. "3 hours") if it has one, or just the section name (e.g. "hours
|
|
221
|
+
// selected") when it doesn't yet. Called explicitly on every navigation
|
|
222
|
+
// and edit interaction so screen readers hear meaningful feedback instead
|
|
223
|
+
// of the raw separator/placeholder characters in the native input value.
|
|
224
|
+
var getSectionValueAnnouncement = useCallback(function (section) {
|
|
225
|
+
var sectionName = getSectionName(section, format, formatMessage, messages);
|
|
226
|
+
if (section === SECTION_PERIOD) {
|
|
227
|
+
if (sections.period === undefined) {
|
|
228
|
+
return formatMessage({
|
|
229
|
+
id: 'timeInput.activeSection',
|
|
230
|
+
messages: messages,
|
|
231
|
+
values: {
|
|
232
|
+
section: sectionName
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return formatMessage({
|
|
237
|
+
id: 'timeInput.activePeriodValue',
|
|
238
|
+
messages: messages,
|
|
239
|
+
values: {
|
|
240
|
+
period: sections.period
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
var sectionKey = getSectionKey(section);
|
|
245
|
+
var sectionValue = sections[sectionKey];
|
|
246
|
+
if (sectionValue === undefined) {
|
|
247
|
+
return formatMessage({
|
|
248
|
+
id: 'timeInput.activeSection',
|
|
249
|
+
messages: messages,
|
|
250
|
+
values: {
|
|
251
|
+
section: sectionName
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return formatMessage({
|
|
256
|
+
id: 'timeInput.activeSectionValue',
|
|
257
|
+
messages: messages,
|
|
258
|
+
values: {
|
|
259
|
+
value: sectionValue,
|
|
260
|
+
section: sectionName
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}, [format, formatMessage, messages, sections]);
|
|
264
|
+
var focusSection = useCallback(function (section) {
|
|
265
|
+
var target = segmentRefs.current[section];
|
|
266
|
+
if (target) {
|
|
267
|
+
target.focus();
|
|
268
|
+
}
|
|
269
|
+
}, []);
|
|
270
|
+
var placeholder = useMemo(function () {
|
|
271
|
+
return buildPlaceholder(sectionOrder);
|
|
272
|
+
}, [sectionOrder]);
|
|
273
|
+
var inputValue = displayValue || placeholder;
|
|
274
|
+
var hasDisplayValue = !!displayValue;
|
|
275
|
+
var displaySections = useMemo(function () {
|
|
276
|
+
// Merge sections with pending digits for display
|
|
277
|
+
var displaySectionsData = _extends({}, sections);
|
|
278
|
+
var pendingSection = Object.keys(pendingDigits)[0];
|
|
279
|
+
if (pendingSection && pendingDigits[pendingSection] !== undefined) {
|
|
280
|
+
displaySectionsData[pendingSection] = pendingDigits[pendingSection];
|
|
281
|
+
}
|
|
282
|
+
return sectionOrder.map(function (section, index) {
|
|
283
|
+
var key = getDisplaySectionKey(section);
|
|
284
|
+
return {
|
|
285
|
+
section: section,
|
|
286
|
+
prefix: getDisplaySectionPrefix(section, index),
|
|
287
|
+
text: getDisplaySectionText({
|
|
288
|
+
key: key,
|
|
289
|
+
section: section,
|
|
290
|
+
sections: displaySectionsData
|
|
291
|
+
}),
|
|
292
|
+
filled: displaySectionsData[key] !== undefined
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
}, [sectionOrder, sections, pendingDigits]);
|
|
296
|
+
var onDisplaySectionMouseDown = useCallback(function (section, event) {
|
|
297
|
+
if (readOnly) return;
|
|
298
|
+
if (disabled) return;
|
|
299
|
+
if (event.button !== 0) return;
|
|
300
|
+
if (event.defaultPrevented) return;
|
|
301
|
+
event.preventDefault();
|
|
302
|
+
event.stopPropagation();
|
|
303
|
+
setSegmentFocused(true);
|
|
304
|
+
setActiveSection(section);
|
|
305
|
+
focusSection(section);
|
|
306
|
+
}, [disabled, focusSection, readOnly, setSegmentFocused, setActiveSection]);
|
|
307
|
+
var onDisplayMouseDown = useCallback(function (event) {
|
|
308
|
+
var _sectionNode$dataset;
|
|
309
|
+
if (readOnly) return;
|
|
310
|
+
if (event.button !== 0) return;
|
|
311
|
+
if (event.defaultPrevented) return;
|
|
312
|
+
var sectionNode = event.target.closest == null ? void 0 : event.target.closest('[data-section]');
|
|
313
|
+
if ((sectionNode == null || (_sectionNode$dataset = sectionNode.dataset) == null ? void 0 : _sectionNode$dataset.section) !== undefined) {
|
|
314
|
+
var section = Number(sectionNode.dataset.section);
|
|
315
|
+
if (!Number.isNaN(section)) {
|
|
316
|
+
onDisplaySectionMouseDown(section, event);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
var nodes = Array.from(event.currentTarget.querySelectorAll('[data-section]'));
|
|
321
|
+
if (nodes.length) {
|
|
322
|
+
var _sectionFromBounds$no;
|
|
323
|
+
var x = event.clientX;
|
|
324
|
+
var sectionsWithRects = nodes.map(function (node) {
|
|
325
|
+
return {
|
|
326
|
+
node: node,
|
|
327
|
+
rect: node.getBoundingClientRect()
|
|
328
|
+
};
|
|
329
|
+
}).sort(function (a, b) {
|
|
330
|
+
return a.rect.left - b.rect.left;
|
|
331
|
+
});
|
|
332
|
+
var sectionFromBounds = sectionsWithRects.find(function (_ref3) {
|
|
333
|
+
var rect = _ref3.rect;
|
|
334
|
+
return x >= rect.left && x <= rect.right;
|
|
335
|
+
});
|
|
336
|
+
if ((sectionFromBounds == null || (_sectionFromBounds$no = sectionFromBounds.node) == null || (_sectionFromBounds$no = _sectionFromBounds$no.dataset) == null ? void 0 : _sectionFromBounds$no.section) !== undefined) {
|
|
337
|
+
var _section = Number(sectionFromBounds.node.dataset.section);
|
|
338
|
+
if (!Number.isNaN(_section)) {
|
|
339
|
+
onDisplaySectionMouseDown(_section, event);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
var zones = sectionsWithRects.map(function (_ref4, index) {
|
|
344
|
+
var rect = _ref4.rect;
|
|
345
|
+
var prev = sectionsWithRects[index - 1];
|
|
346
|
+
var next = sectionsWithRects[index + 1];
|
|
347
|
+
var start = prev !== undefined ? (prev.rect.right + rect.left) / 2 : Number.NEGATIVE_INFINITY;
|
|
348
|
+
var end = next !== undefined ? (rect.right + next.rect.left) / 2 : Number.POSITIVE_INFINITY;
|
|
349
|
+
return {
|
|
350
|
+
index: index,
|
|
351
|
+
start: start,
|
|
352
|
+
end: end
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
var zone = zones.find(function (_ref5) {
|
|
356
|
+
var start = _ref5.start,
|
|
357
|
+
end = _ref5.end;
|
|
358
|
+
return x >= start && x <= end;
|
|
359
|
+
}) || zones[0] || null;
|
|
360
|
+
if (zone) {
|
|
361
|
+
var _sectionsWithRects$zo, _matched$dataset;
|
|
362
|
+
var matched = (_sectionsWithRects$zo = sectionsWithRects[zone.index]) == null ? void 0 : _sectionsWithRects$zo.node;
|
|
363
|
+
if ((matched == null || (_matched$dataset = matched.dataset) == null ? void 0 : _matched$dataset.section) !== undefined) {
|
|
364
|
+
var _section2 = Number(matched.dataset.section);
|
|
365
|
+
if (!Number.isNaN(_section2)) {
|
|
366
|
+
onDisplaySectionMouseDown(_section2, event);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
event.preventDefault();
|
|
373
|
+
setSegmentFocused(true);
|
|
374
|
+
setActiveSection(firstSection);
|
|
375
|
+
focusSection(firstSection);
|
|
376
|
+
}, [firstSection, focusSection, onDisplaySectionMouseDown, readOnly, setSegmentFocused, setActiveSection]);
|
|
377
|
+
var openPicker = useCallback(function () {
|
|
378
|
+
if (disabled || readOnly) return;
|
|
379
|
+
setActiveSection(firstSection);
|
|
380
|
+
setOpen(true);
|
|
381
|
+
}, [disabled, firstSection, readOnly, setActiveSection]);
|
|
382
|
+
var closePicker = useCallback(function () {
|
|
383
|
+
setOpen(false);
|
|
384
|
+
setTimeout(function () {
|
|
385
|
+
focusSection(activeSection);
|
|
386
|
+
}, 0);
|
|
387
|
+
}, [activeSection, focusSection]);
|
|
388
|
+
var onSegmentFocus = useCallback(function (section) {
|
|
389
|
+
if (!segmentFocused && !readOnly && !disabled && !open) {
|
|
390
|
+
announce(formatMessage({
|
|
391
|
+
id: 'timeInput.openDrop',
|
|
392
|
+
messages: messages
|
|
393
|
+
}));
|
|
394
|
+
}
|
|
395
|
+
setSegmentFocused(true);
|
|
396
|
+
if (readOnly || disabled) return;
|
|
397
|
+
setActiveSection(section);
|
|
398
|
+
}, [announce, disabled, formatMessage, messages, open, readOnly, segmentFocused, setActiveSection]);
|
|
399
|
+
var onSegmentBlur = useCallback(function () {
|
|
400
|
+
requestAnimationFrame(function () {
|
|
401
|
+
var _document = document,
|
|
402
|
+
activeElement = _document.activeElement;
|
|
403
|
+
var isSegmentFocused = Object.values(segmentRefs.current).includes(activeElement);
|
|
404
|
+
if (!isSegmentFocused && activeElement === document.body && !readOnly && !disabled) {
|
|
405
|
+
focusSection(activeSection);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (!isSegmentFocused) {
|
|
409
|
+
setSegmentFocused(false);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}, [activeSection, disabled, focusSection, readOnly]);
|
|
413
|
+
var onSegmentKeyDown = useCallback(function (section, event) {
|
|
414
|
+
if (readOnly || disabled) return;
|
|
415
|
+
var key = event.key;
|
|
416
|
+
if (activeSection !== section) {
|
|
417
|
+
setActiveSection(section);
|
|
418
|
+
}
|
|
419
|
+
if (key === 'ArrowRight') {
|
|
420
|
+
event.preventDefault();
|
|
421
|
+
var next = moveSection(1);
|
|
422
|
+
setActiveSection(next);
|
|
423
|
+
focusSection(next);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (key === 'ArrowLeft') {
|
|
427
|
+
event.preventDefault();
|
|
428
|
+
var _next = moveSection(-1);
|
|
429
|
+
setActiveSection(_next);
|
|
430
|
+
focusSection(_next);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (key === 'Home') {
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
setActiveSection(firstSection);
|
|
436
|
+
focusSection(firstSection);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (key === 'End') {
|
|
440
|
+
event.preventDefault();
|
|
441
|
+
setActiveSection(lastSection);
|
|
442
|
+
focusSection(lastSection);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (key === 'ArrowUp') {
|
|
446
|
+
event.preventDefault();
|
|
447
|
+
incrementSection(section, open ? -1 : 1);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (key === 'ArrowDown') {
|
|
451
|
+
if (event.altKey) {
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
openPicker();
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
event.preventDefault();
|
|
457
|
+
incrementSection(section, open ? 1 : -1);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (key === 'Delete' || key === 'Backspace') {
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
clearActiveSection();
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (key === 'Enter') {
|
|
466
|
+
event.preventDefault();
|
|
467
|
+
if (open) closePicker();
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (key === 'Escape' && open) {
|
|
471
|
+
event.preventDefault();
|
|
472
|
+
closePicker();
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (key === ' ' || key === 'Spacebar') {
|
|
476
|
+
event.preventDefault();
|
|
477
|
+
openPicker();
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
if (format === '12' && section === SECTION_PERIOD) {
|
|
481
|
+
var lower = key.toLowerCase();
|
|
482
|
+
if (lower === 'a') {
|
|
483
|
+
event.preventDefault();
|
|
484
|
+
setSectionValue(SECTION_PERIOD, 'AM');
|
|
485
|
+
} else if (lower === 'p') {
|
|
486
|
+
event.preventDefault();
|
|
487
|
+
setSectionValue(SECTION_PERIOD, 'PM');
|
|
488
|
+
}
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (/^\d$/.test(key)) {
|
|
492
|
+
event.preventDefault();
|
|
493
|
+
var _next2 = applyDigit(Number(key));
|
|
494
|
+
var targetSection = _next2 != null ? _next2 : section;
|
|
495
|
+
setActiveSection(targetSection);
|
|
496
|
+
if (targetSection === section) {
|
|
497
|
+
event.currentTarget.focus();
|
|
498
|
+
} else {
|
|
499
|
+
focusSection(targetSection);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}, [activeSection, applyDigit, clearActiveSection, closePicker, disabled, firstSection, focusSection, format, incrementSection, lastSection, moveSection, open, openPicker, readOnly, setActiveSection, setSectionValue]);
|
|
503
|
+
useEffect(function () {
|
|
504
|
+
if (!segmentFocused) return;
|
|
505
|
+
if (readOnly || disabled) return;
|
|
506
|
+
var activeSegment = segmentRefs.current[activeSection];
|
|
507
|
+
if (activeSegment && document.activeElement !== activeSegment) {
|
|
508
|
+
activeSegment.focus();
|
|
509
|
+
}
|
|
510
|
+
}, [activeSection, disabled, readOnly, segmentFocused]);
|
|
511
|
+
var onSegmentPaste = useCallback(function (event) {
|
|
512
|
+
if (readOnly) {
|
|
513
|
+
event.preventDefault();
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
var pasted = event.clipboardData.getData('text');
|
|
517
|
+
var parsed = parsePasted(pasted);
|
|
518
|
+
if (!parsed) {
|
|
519
|
+
handleInvalid();
|
|
520
|
+
event.preventDefault();
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
commitSections(parsed);
|
|
524
|
+
event.preventDefault();
|
|
525
|
+
}, [commitSections, handleInvalid, parsePasted, readOnly]);
|
|
526
|
+
var hoursOptions = useMemo(function () {
|
|
527
|
+
return Array.from({
|
|
528
|
+
length: format === '12' ? 12 : 24
|
|
529
|
+
}, function (_, index) {
|
|
530
|
+
return format === '12' ? index + 1 : index;
|
|
531
|
+
});
|
|
532
|
+
}, [format]);
|
|
533
|
+
var minuteOptions = useMemo(function () {
|
|
534
|
+
return Array.from({
|
|
535
|
+
length: Math.ceil(60 / normalizedMinuteStep)
|
|
536
|
+
}, function (_, index) {
|
|
537
|
+
return index * normalizedMinuteStep;
|
|
538
|
+
}).filter(function (valueAtIndex) {
|
|
539
|
+
return valueAtIndex < 60;
|
|
540
|
+
});
|
|
541
|
+
}, [normalizedMinuteStep]);
|
|
542
|
+
var secondOptions = useMemo(function () {
|
|
543
|
+
return Array.from({
|
|
544
|
+
length: 60
|
|
545
|
+
}, function (_, index) {
|
|
546
|
+
return index;
|
|
547
|
+
});
|
|
548
|
+
}, []);
|
|
549
|
+
var showActiveSection = (segmentFocused || open) && !readOnly && !disabled;
|
|
550
|
+
return /*#__PURE__*/React.createElement(Keyboard, {
|
|
551
|
+
onEsc: open ? closePicker : undefined
|
|
552
|
+
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(StyledTimeInputContainer, _extends({
|
|
553
|
+
ref: containerRef,
|
|
554
|
+
direction: "row",
|
|
555
|
+
border: !plainProp,
|
|
556
|
+
fill: true,
|
|
557
|
+
round: ((_theme$timeInput = theme.timeInput) == null || (_theme$timeInput = _theme$timeInput.container) == null ? void 0 : _theme$timeInput.round) || ((_theme$global = theme.global) == null || (_theme$global = _theme$global.control) == null || (_theme$global = _theme$global.border) == null ? void 0 : _theme$global.radius),
|
|
558
|
+
disabled: disabled,
|
|
559
|
+
readOnlyProp: readOnly,
|
|
560
|
+
focusIndicator: (focusIndicatorProp != null ? focusIndicatorProp : true) && !iconFocused
|
|
561
|
+
}, passThemeFlag), /*#__PURE__*/React.createElement(StyledTimeInputField, passThemeFlag, /*#__PURE__*/React.createElement(StyledTimeInputDisplay, _extends({
|
|
562
|
+
role: "group",
|
|
563
|
+
"aria-label": groupLabel,
|
|
564
|
+
"aria-labelledby": formFieldLabelId,
|
|
565
|
+
onMouseDown: onDisplayMouseDown
|
|
566
|
+
}, passThemeFlag), displaySections.map(function (_ref6) {
|
|
567
|
+
var section = _ref6.section,
|
|
568
|
+
prefix = _ref6.prefix,
|
|
569
|
+
text = _ref6.text,
|
|
570
|
+
filled = _ref6.filled;
|
|
571
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
572
|
+
key: section
|
|
573
|
+
}, !!prefix && /*#__PURE__*/React.createElement(StyledTimeInputSeparator, _extends({
|
|
574
|
+
$filled: hasDisplayValue
|
|
575
|
+
}, passThemeFlag), prefix), /*#__PURE__*/React.createElement(StyledTimeInputSegment, _extends({
|
|
576
|
+
ref: function ref(segmentNode) {
|
|
577
|
+
segmentRefs.current[section] = segmentNode;
|
|
578
|
+
},
|
|
579
|
+
tabIndex: !readOnly && !disabled && activeSection === section ? 0 : -1,
|
|
580
|
+
$active: showActiveSection && activeSection === section,
|
|
581
|
+
$filled: filled,
|
|
582
|
+
onFocus: function onFocus() {
|
|
583
|
+
return onSegmentFocus(section);
|
|
584
|
+
},
|
|
585
|
+
onBlur: onSegmentBlur,
|
|
586
|
+
onKeyDown: function onKeyDown(event) {
|
|
587
|
+
return onSegmentKeyDown(section, event);
|
|
588
|
+
},
|
|
589
|
+
onPaste: onSegmentPaste,
|
|
590
|
+
"data-active": showActiveSection && activeSection === section,
|
|
591
|
+
"data-testid": showActiveSection && activeSection === section ? 'time-input-active-section' : undefined,
|
|
592
|
+
"data-section": section
|
|
593
|
+
}, passThemeFlag, {
|
|
594
|
+
"aria-label": getSectionName(section, format, formatMessage, messages),
|
|
595
|
+
role: "spinbutton",
|
|
596
|
+
"aria-disabled": disabled || undefined,
|
|
597
|
+
"aria-readonly": readOnly || undefined,
|
|
598
|
+
"aria-valuenow": getSectionAriaMeta({
|
|
599
|
+
section: section,
|
|
600
|
+
format: format,
|
|
601
|
+
sections: sections
|
|
602
|
+
}).now,
|
|
603
|
+
"aria-valuemin": getSectionAriaMeta({
|
|
604
|
+
section: section,
|
|
605
|
+
format: format,
|
|
606
|
+
sections: sections
|
|
607
|
+
}).min,
|
|
608
|
+
"aria-valuemax": getSectionAriaMeta({
|
|
609
|
+
section: section,
|
|
610
|
+
format: format,
|
|
611
|
+
sections: sections
|
|
612
|
+
}).max,
|
|
613
|
+
"aria-valuetext": getSectionValueAnnouncement(section)
|
|
614
|
+
}), text));
|
|
615
|
+
})), /*#__PURE__*/React.createElement(StyledTimeInput, _extends({
|
|
616
|
+
tabIndex: -1
|
|
617
|
+
}, inputRest, {
|
|
618
|
+
id: id,
|
|
619
|
+
ref: inputRef,
|
|
620
|
+
value: inputValue,
|
|
621
|
+
"aria-hidden": "true",
|
|
622
|
+
disabled: disabled,
|
|
623
|
+
readOnly: true,
|
|
624
|
+
focusIndicator: false,
|
|
625
|
+
plain: true
|
|
626
|
+
}))), name && /*#__PURE__*/React.createElement("input", {
|
|
627
|
+
"aria-hidden": "true",
|
|
628
|
+
name: name,
|
|
629
|
+
readOnly: true,
|
|
630
|
+
tabIndex: -1,
|
|
631
|
+
type: "hidden",
|
|
632
|
+
value: value || ''
|
|
633
|
+
}), !readOnly && /*#__PURE__*/React.createElement(Button, {
|
|
634
|
+
icon: /*#__PURE__*/React.createElement(GrommetClockIcon, null),
|
|
635
|
+
plain: true,
|
|
636
|
+
disabled: disabled,
|
|
637
|
+
margin: (_theme$timeInput2 = theme.timeInput) == null || (_theme$timeInput2 = _theme$timeInput2.button) == null ? void 0 : _theme$timeInput2.margin,
|
|
638
|
+
"aria-label": formatMessage({
|
|
639
|
+
id: 'timeInput.chooseTime',
|
|
640
|
+
messages: messages
|
|
641
|
+
}),
|
|
642
|
+
"aria-haspopup": "dialog",
|
|
643
|
+
"aria-expanded": open,
|
|
644
|
+
"aria-controls": id ? id + "__drop" : undefined,
|
|
645
|
+
onFocus: function onFocus() {
|
|
646
|
+
setIconFocused(true);
|
|
647
|
+
},
|
|
648
|
+
onBlur: function onBlur() {
|
|
649
|
+
setIconFocused(false);
|
|
650
|
+
},
|
|
651
|
+
onClick: open ? closePicker : openPicker
|
|
652
|
+
})), open && /*#__PURE__*/React.createElement(TimeInputPopup, {
|
|
653
|
+
activeSection: activeSection,
|
|
654
|
+
align: {
|
|
655
|
+
top: 'bottom',
|
|
656
|
+
left: 'left'
|
|
657
|
+
},
|
|
658
|
+
dropProps: {
|
|
659
|
+
stretch: false
|
|
660
|
+
},
|
|
661
|
+
format: format,
|
|
662
|
+
formatMessage: formatMessage,
|
|
663
|
+
hoursOptions: hoursOptions,
|
|
664
|
+
id: id,
|
|
665
|
+
incrementSection: incrementSection,
|
|
666
|
+
label: formatMessage({
|
|
667
|
+
id: 'timeInput.chooseTime',
|
|
668
|
+
messages: messages
|
|
669
|
+
}),
|
|
670
|
+
messages: messages,
|
|
671
|
+
minuteOptions: minuteOptions,
|
|
672
|
+
moveSection: moveSection,
|
|
673
|
+
sectionOrder: sectionOrder,
|
|
674
|
+
onClose: closePicker,
|
|
675
|
+
onFocusLeave: closePicker,
|
|
676
|
+
secondOptions: secondOptions,
|
|
677
|
+
sections: sections,
|
|
678
|
+
setActiveSection: setActiveSection,
|
|
679
|
+
setSectionValue: setSectionValue,
|
|
680
|
+
target: containerRef.current
|
|
681
|
+
})));
|
|
682
|
+
});
|
|
683
|
+
TimeInput.displayName = 'TimeInput';
|
|
684
|
+
TimeInput.propTypes = TimeInputPropTypes;
|
|
685
|
+
export { TimeInput };
|