grommet 2.57.0 → 2.58.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.
Files changed (124) hide show
  1. package/components/Box/StyledBox.js +1 -1
  2. package/components/Box/stories/ColorContrast.stories.js +36 -0
  3. package/components/Button/BusyAnimation.js +7 -1
  4. package/components/Button/Button.js +12 -3
  5. package/components/DataTable/StyledDataTable.js +1 -1
  6. package/components/DateInput/DateInput.js +3 -3
  7. package/components/DateTimeInput/DateTimeInput.js +17 -11
  8. package/components/FocusedContainer.js +2 -1
  9. package/components/FormField/FormField.js +31 -10
  10. package/components/FormField/FormFieldContext.js +12 -0
  11. package/components/Grommet/Grommet.js +4 -1
  12. package/components/Grommet/StyledGrommet.js +3 -3
  13. package/components/Grommet/index.d.ts +6 -0
  14. package/components/Grommet/propTypes.js +2 -0
  15. package/components/Menu/Menu.js +1 -1
  16. package/components/Select/SelectContainer.js +2 -2
  17. package/components/Select/StyledSelect.js +3 -1
  18. package/components/TextArea/StyledTextArea.js +3 -1
  19. package/components/TextInput/CopyButton.js +23 -6
  20. package/components/TextInput/StyledTextInput.js +19 -25
  21. package/components/TextInput/TextInput.js +75 -28
  22. package/components/TextInput/index.d.ts +12 -3
  23. package/components/TextInput/propTypes.js +2 -0
  24. package/components/TextInput/stories/Copy.stories.tsx +42 -0
  25. package/components/TextInput/stories/CopySecret.stories.tsx +44 -0
  26. package/components/TimeInput/README.md +24 -1
  27. package/components/TimeInput/StyledTimeInput.js +91 -27
  28. package/components/TimeInput/TimeInput.js +185 -120
  29. package/components/TimeInput/TimeInputPopup.js +114 -117
  30. package/components/TimeInput/index.d.ts +2 -0
  31. package/components/TimeInput/propTypes.js +2 -0
  32. package/components/TimeInput/stories/Controlled.stories.tsx +2 -2
  33. package/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
  34. package/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
  35. package/components/TimeInput/stories/Form.stories.tsx +1 -0
  36. package/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
  37. package/components/TimeInput/useSectionedTimeField.js +2 -2
  38. package/components/TimeInput/utils.js +13 -62
  39. package/components/Wizard/Wizard.js +396 -210
  40. package/components/Wizard/WizardContent.js +61 -35
  41. package/components/Wizard/WizardContext.js +3 -0
  42. package/components/Wizard/WizardFooter.js +14 -15
  43. package/components/Wizard/WizardHeader.js +12 -7
  44. package/components/Wizard/WizardProgress.js +27 -2
  45. package/components/Wizard/index.d.ts +35 -4
  46. package/components/Wizard/propTypes.js +6 -1
  47. package/components/Wizard/stories/BasicLinear.stories.js +12 -10
  48. package/components/Wizard/stories/ClickableSteps.stories.js +104 -0
  49. package/components/Wizard/stories/ExternalForm.stories.js +114 -0
  50. package/components/Wizard/stories/NonClosableHeader.stories.js +68 -0
  51. package/components/Wizard/stories/Validation.stories.js +18 -8
  52. package/es6/components/Box/StyledBox.js +1 -1
  53. package/es6/components/Box/stories/ColorContrast.stories.js +31 -0
  54. package/es6/components/Button/BusyAnimation.js +7 -1
  55. package/es6/components/Button/Button.js +12 -3
  56. package/es6/components/DataTable/StyledDataTable.js +2 -2
  57. package/es6/components/DateInput/DateInput.js +3 -3
  58. package/es6/components/DateTimeInput/DateTimeInput.js +17 -11
  59. package/es6/components/FocusedContainer.js +2 -1
  60. package/es6/components/FormField/FormField.js +31 -10
  61. package/es6/components/FormField/FormFieldContext.js +7 -0
  62. package/es6/components/Grommet/Grommet.js +4 -1
  63. package/es6/components/Grommet/StyledGrommet.js +4 -4
  64. package/es6/components/Grommet/index.d.ts +6 -0
  65. package/es6/components/Grommet/propTypes.js +2 -0
  66. package/es6/components/Menu/Menu.js +1 -1
  67. package/es6/components/Select/SelectContainer.js +2 -2
  68. package/es6/components/Select/StyledSelect.js +4 -2
  69. package/es6/components/TextArea/StyledTextArea.js +4 -2
  70. package/es6/components/TextInput/CopyButton.js +22 -6
  71. package/es6/components/TextInput/StyledTextInput.js +20 -26
  72. package/es6/components/TextInput/TextInput.js +76 -29
  73. package/es6/components/TextInput/index.d.ts +12 -3
  74. package/es6/components/TextInput/propTypes.js +2 -0
  75. package/es6/components/TextInput/stories/Copy.stories.tsx +42 -0
  76. package/es6/components/TextInput/stories/CopySecret.stories.tsx +44 -0
  77. package/es6/components/TimeInput/README.md +24 -1
  78. package/es6/components/TimeInput/StyledTimeInput.js +92 -28
  79. package/es6/components/TimeInput/TimeInput.js +187 -122
  80. package/es6/components/TimeInput/TimeInputPopup.js +115 -118
  81. package/es6/components/TimeInput/index.d.ts +2 -0
  82. package/es6/components/TimeInput/propTypes.js +2 -0
  83. package/es6/components/TimeInput/stories/Controlled.stories.tsx +2 -2
  84. package/es6/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
  85. package/es6/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
  86. package/es6/components/TimeInput/stories/Form.stories.tsx +1 -0
  87. package/es6/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
  88. package/es6/components/TimeInput/useSectionedTimeField.js +2 -2
  89. package/es6/components/TimeInput/utils.js +12 -61
  90. package/es6/components/Wizard/Wizard.js +397 -211
  91. package/es6/components/Wizard/WizardContent.js +62 -36
  92. package/es6/components/Wizard/WizardContext.js +3 -0
  93. package/es6/components/Wizard/WizardFooter.js +14 -15
  94. package/es6/components/Wizard/WizardHeader.js +12 -7
  95. package/es6/components/Wizard/WizardProgress.js +27 -2
  96. package/es6/components/Wizard/index.d.ts +35 -4
  97. package/es6/components/Wizard/propTypes.js +6 -1
  98. package/es6/components/Wizard/stories/BasicLinear.stories.js +11 -11
  99. package/es6/components/Wizard/stories/ClickableSteps.stories.js +99 -0
  100. package/es6/components/Wizard/stories/ExternalForm.stories.js +111 -0
  101. package/es6/components/Wizard/stories/NonClosableHeader.stories.js +63 -0
  102. package/es6/components/Wizard/stories/Validation.stories.js +18 -9
  103. package/es6/languages/default.json +2 -0
  104. package/es6/themes/base.d.ts +79 -59
  105. package/es6/themes/base.js +65 -34
  106. package/es6/utils/DOM.js +10 -7
  107. package/es6/utils/background.js +9 -7
  108. package/es6/utils/colors.js +84 -12
  109. package/es6/utils/legacyColorIsDark.js +17 -0
  110. package/es6/utils/styles.js +13 -5
  111. package/grommet.min.js +1 -1
  112. package/grommet.min.js.map +1 -1
  113. package/languages/default.json +2 -0
  114. package/package.json +3 -3
  115. package/themes/base.d.ts +79 -59
  116. package/themes/base.js +65 -34
  117. package/tools/draft-release-version-pr.js +1 -0
  118. package/tools/generate-release-notes.js +1 -1
  119. package/tools/release-notes-utils.js +1 -0
  120. package/utils/DOM.js +10 -7
  121. package/utils/background.js +9 -7
  122. package/utils/colors.js +84 -12
  123. package/utils/legacyColorIsDark.js +21 -0
  124. package/utils/styles.js +14 -6
@@ -13,6 +13,7 @@ var _sectionHelpers = require("../../utils/sectionHelpers");
13
13
  var _Box = require("../Box");
14
14
  var _Button = require("../Button");
15
15
  var _Form = require("../Form");
16
+ var _FormFieldContext = require("../FormField/FormFieldContext");
16
17
  var _Keyboard = require("../Keyboard");
17
18
  var _StyledTimeInput = require("./StyledTimeInput");
18
19
  var _TimeInputPopup = require("./TimeInputPopup");
@@ -20,44 +21,50 @@ var _propTypes = require("./propTypes");
20
21
  var _useSectionedTimeField = require("./useSectionedTimeField");
21
22
  var _utils2 = require("./utils");
22
23
  var _excluded = ["defaultValue", "disabled", "focusOnOpen", "format", "id", "inline", "messages", "minuteStep", "name", "onChange", "onPartialChange", "readOnly", "showSeconds", "value"],
23
- _excluded2 = ["plain", "focusIndicator"]; // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
24
+ _excluded2 = ["plain", "focusIndicator", "aria-describedby", "aria-invalid"],
25
+ _excluded3 = ["icon", "kind"]; // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
24
26
  // SPDX-License-Identifier: Apache-2.0
25
27
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
26
28
  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); }
27
29
  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; }
28
- var getDisplaySectionKey = function getDisplaySectionKey(section) {
29
- if (section === _utils2.SECTION_HOUR) return 'hour';
30
- if (section === _utils2.SECTION_MINUTE) return 'minute';
31
- if (section === _utils2.SECTION_SECOND) return 'second';
32
- return 'period';
33
- };
34
30
  var getDisplaySectionPrefix = function getDisplaySectionPrefix(section, index) {
35
31
  if (index === 0) return '';
36
32
  return section === _utils2.SECTION_PERIOD ? ' ' : ':';
37
33
  };
38
- var getDisplaySectionText = function getDisplaySectionText(_ref) {
39
- var key = _ref.key,
40
- section = _ref.section,
41
- sections = _ref.sections;
42
- if (sections[key] === undefined) return (0, _sectionHelpers.getSectionTokenFromType)((0, _utils2.sectionTypeFromSection)(section));
43
- if (section === _utils2.SECTION_PERIOD) return sections[key];
44
- return (0, _utils2.pad)(sections[key]);
45
- };
46
34
  var getSectionOrder = function getSectionOrder(format, showSeconds) {
47
- if (showSeconds === void 0) {
48
- showSeconds = format === '12';
49
- }
50
35
  var numericSections = showSeconds ? [_utils2.SECTION_HOUR, _utils2.SECTION_MINUTE, _utils2.SECTION_SECOND] : [_utils2.SECTION_HOUR, _utils2.SECTION_MINUTE];
51
36
  if (format === '12') {
52
37
  return [].concat(numericSections, [_utils2.SECTION_PERIOD]);
53
38
  }
54
39
  return numericSections;
55
40
  };
41
+ var getContainerFill = function getContainerFill(container) {
42
+ if (container === void 0) {
43
+ container = {};
44
+ }
45
+ var fillWidth = container.width === undefined;
46
+ var fillHeight = container.height === undefined;
47
+ if (fillWidth && fillHeight) return true;
48
+ if (fillWidth) return 'horizontal';
49
+ if (fillHeight) return 'vertical';
50
+ return false;
51
+ };
52
+ var resolveDropButtonIcon = function resolveDropButtonIcon(icon) {
53
+ if (/*#__PURE__*/_react["default"].isValidElement(icon)) {
54
+ var _icon$props$ariaHidd;
55
+ return /*#__PURE__*/_react["default"].cloneElement(icon, {
56
+ 'aria-hidden': (_icon$props$ariaHidd = icon.props['aria-hidden']) != null ? _icon$props$ariaHidd : true
57
+ });
58
+ }
59
+ if (typeof icon === 'function' || icon != null && icon.$$typeof) return /*#__PURE__*/_react["default"].createElement(icon, {
60
+ 'aria-hidden': true
61
+ });
62
+ return icon;
63
+ };
56
64
  var buildPlaceholder = function buildPlaceholder(sectionOrder) {
57
65
  return sectionOrder.map(function (section, index) {
58
66
  var token = (0, _sectionHelpers.getSectionTokenFromType)((0, _utils2.sectionTypeFromSection)(section));
59
- if (index === 0) return token;
60
- return "" + (section === _utils2.SECTION_PERIOD ? ' ' : ':') + token;
67
+ return "" + getDisplaySectionPrefix(section, index) + token;
61
68
  }).join('');
62
69
  };
63
70
 
@@ -75,28 +82,29 @@ var getDefaultFormat = function getDefaultFormat() {
75
82
  }
76
83
  };
77
84
  var DEFAULT_FORMAT = getDefaultFormat();
78
- var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, refArg) {
79
- var _theme$timeInput, _theme$global, _theme$timeInput2;
80
- var defaultValue = _ref2.defaultValue,
81
- disabled = _ref2.disabled,
82
- _ref2$focusOnOpen = _ref2.focusOnOpen,
83
- focusOnOpen = _ref2$focusOnOpen === void 0 ? true : _ref2$focusOnOpen,
84
- _ref2$format = _ref2.format,
85
- format = _ref2$format === void 0 ? DEFAULT_FORMAT : _ref2$format,
86
- id = _ref2.id,
87
- _ref2$inline = _ref2.inline,
88
- inline = _ref2$inline === void 0 ? false : _ref2$inline,
89
- messages = _ref2.messages,
90
- _ref2$minuteStep = _ref2.minuteStep,
91
- minuteStep = _ref2$minuteStep === void 0 ? 1 : _ref2$minuteStep,
92
- name = _ref2.name,
93
- onChange = _ref2.onChange,
94
- onPartialChange = _ref2.onPartialChange,
95
- _ref2$readOnly = _ref2.readOnly,
96
- readOnly = _ref2$readOnly === void 0 ? false : _ref2$readOnly,
97
- showSeconds = _ref2.showSeconds,
98
- valueArg = _ref2.value,
99
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
85
+ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
86
+ var _theme$timeInput, _theme$timeInput2, _theme$timeInput$cont, _theme$timeInput3, _theme$global, _theme$timeInput4;
87
+ var defaultValue = _ref.defaultValue,
88
+ disabled = _ref.disabled,
89
+ _ref$focusOnOpen = _ref.focusOnOpen,
90
+ focusOnOpen = _ref$focusOnOpen === void 0 ? true : _ref$focusOnOpen,
91
+ _ref$format = _ref.format,
92
+ format = _ref$format === void 0 ? DEFAULT_FORMAT : _ref$format,
93
+ id = _ref.id,
94
+ _ref$inline = _ref.inline,
95
+ inline = _ref$inline === void 0 ? false : _ref$inline,
96
+ messages = _ref.messages,
97
+ _ref$minuteStep = _ref.minuteStep,
98
+ minuteStep = _ref$minuteStep === void 0 ? 1 : _ref$minuteStep,
99
+ name = _ref.name,
100
+ onChange = _ref.onChange,
101
+ onPartialChange = _ref.onPartialChange,
102
+ _ref$readOnly = _ref.readOnly,
103
+ readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
104
+ _ref$showSeconds = _ref.showSeconds,
105
+ showSeconds = _ref$showSeconds === void 0 ? false : _ref$showSeconds,
106
+ valueArg = _ref.value,
107
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
100
108
  var _useThemeValue = (0, _useThemeValue2.useThemeValue)(),
101
109
  theme = _useThemeValue.theme,
102
110
  passThemeFlag = _useThemeValue.passThemeFlag;
@@ -104,6 +112,8 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
104
112
  var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
105
113
  formatMessage = _useContext.format;
106
114
  var formContext = (0, _react.useContext)(_Form.FormContext);
115
+ var _useContext2 = (0, _react.useContext)(_FormFieldContext.FormFieldContext),
116
+ setFieldFocusIndicator = _useContext2.setFocusIndicator;
107
117
  var useFormInput = formContext.useFormInput;
108
118
  var inputRef = (0, _utils.useForwardedRef)(refArg);
109
119
  var containerRef = (0, _react.useRef)();
@@ -114,11 +124,9 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
114
124
  }),
115
125
  value = _useFormInput[0],
116
126
  setValue = _useFormInput[1];
117
- (0, _react.useEffect)(function () {
118
- if (process.env.NODE_ENV !== 'production') {
119
- console.warn('Warning: TimeInput is currently in beta. The API is subject ' + 'to change in future releases.');
120
- }
121
- }, []);
127
+ if (inline && (disabled || readOnly)) {
128
+ console.warn('TimeInput is rendered inline and is either disabled or read-only. ' + 'TimeInput ignores disabled and readOnly props when rendered inline.');
129
+ }
122
130
  var _formContext$useFormF = formContext.useFormField({}),
123
131
  inForm = _formContext$useFormF.inForm;
124
132
  var formFieldLabelId = inForm && id ? "grommet-" + id + "__label" : undefined;
@@ -138,11 +146,23 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
138
146
  var segmentRefs = (0, _react.useRef)({});
139
147
  var plainProp = rest.plain,
140
148
  focusIndicatorProp = rest.focusIndicator,
149
+ ariaDescribedBy = rest['aria-describedby'],
150
+ ariaInvalid = rest['aria-invalid'],
141
151
  inputRest = _objectWithoutPropertiesLoose(rest, _excluded2);
152
+
153
+ // FormField merges its generated error id into aria-describedby
154
+ // alongside any id the consumer already had on the child. Split those
155
+ // back apart so a pre-existing description stays on every segment,
156
+ // while the error id itself is only added to the segment(s) it's about.
157
+ var errorId = id ? "grommet-" + id + "__error" : undefined;
158
+ var describedByTokens = ariaDescribedBy ? ariaDescribedBy.split(' ').filter(Boolean) : [];
159
+ var hasErrorDescribedBy = !!errorId && describedByTokens.includes(errorId);
160
+ var consumerDescribedBy = describedByTokens.filter(function (token) {
161
+ return token !== errorId;
162
+ }).join(' ') || undefined;
142
163
  var normalizedMinuteStep = (0, _react.useMemo)(function () {
143
164
  return (0, _dates.normalizeStep)(minuteStep);
144
165
  }, [minuteStep]);
145
- var resolvedShowSeconds = showSeconds !== undefined ? showSeconds : format === '12';
146
166
  var handleInvalid = (0, _react.useCallback)(function () {
147
167
  var error = formatMessage({
148
168
  id: 'timeInput.invalidTime',
@@ -151,22 +171,25 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
151
171
  announce(error, 'assertive');
152
172
  }, [announce, formatMessage, messages]);
153
173
  var announceCurrentValue = (0, _react.useCallback)(function (nextSections) {
154
- if (nextSections.hour === undefined || nextSections.minute === undefined || nextSections.second === undefined) return;
174
+ if (nextSections.hour === undefined || nextSections.minute === undefined || showSeconds && nextSections.second === undefined) return;
155
175
  var period = format === '12' ? " " + (nextSections.period || 'AM') : '';
176
+ var messageId = showSeconds ? 'timeInput.currentValue' : 'timeInput.currentValueWithoutSeconds';
156
177
  announce(formatMessage({
157
- id: 'timeInput.currentValue',
178
+ id: messageId,
158
179
  messages: messages,
159
- values: {
180
+ values: _extends({
160
181
  hour: nextSections.hour,
161
- minute: nextSections.minute,
162
- second: nextSections.second,
182
+ minute: nextSections.minute
183
+ }, showSeconds ? {
184
+ second: nextSections.second
185
+ } : {}, {
163
186
  period: period
164
- }
187
+ })
165
188
  }), 'polite');
166
- }, [announce, format, formatMessage, messages]);
189
+ }, [announce, format, formatMessage, messages, showSeconds]);
167
190
  var sectionOrder = (0, _react.useMemo)(function () {
168
- return getSectionOrder(format, resolvedShowSeconds);
169
- }, [format, resolvedShowSeconds]);
191
+ return getSectionOrder(format, showSeconds);
192
+ }, [format, showSeconds]);
170
193
  var firstSection = sectionOrder[0] || _utils2.SECTION_HOUR;
171
194
  var lastSection = sectionOrder[sectionOrder.length - 1] || _utils2.SECTION_HOUR;
172
195
  var _useSectionedTimeFiel = (0, _useSectionedTimeField.useSectionedTimeField)({
@@ -231,8 +254,7 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
231
254
  }
232
255
  });
233
256
  }
234
- var sectionKey = (0, _sectionHelpers.getSectionKeyFromType)((0, _utils2.sectionTypeFromSection)(section));
235
- var sectionValue = sections[sectionKey];
257
+ var sectionValue = sections[(0, _utils2.sectionKey)(section)];
236
258
  if (sectionValue === undefined) {
237
259
  return formatMessage({
238
260
  id: 'timeInput.activeSection',
@@ -270,19 +292,36 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
270
292
  displaySectionsData[pendingSection] = pendingDigits[pendingSection];
271
293
  }
272
294
  return sectionOrder.map(function (section, index) {
273
- var key = getDisplaySectionKey(section);
295
+ var key = (0, _utils2.sectionKey)(section);
296
+ var sectionValue = displaySectionsData[key];
297
+ var text;
298
+ if (sectionValue === undefined) {
299
+ text = (0, _sectionHelpers.getSectionTokenFromType)((0, _utils2.sectionTypeFromSection)(section));
300
+ } else if (section === _utils2.SECTION_PERIOD) {
301
+ text = sectionValue;
302
+ } else {
303
+ text = (0, _utils2.pad)(sectionValue);
304
+ }
274
305
  return {
275
- section: section,
276
- prefix: getDisplaySectionPrefix(section, index),
277
- text: getDisplaySectionText({
278
- key: key,
306
+ ariaMeta: (0, _utils2.getSectionAriaMeta)({
279
307
  section: section,
280
- sections: displaySectionsData
308
+ format: format,
309
+ sections: sections
281
310
  }),
282
- filled: displaySectionsData[key] !== undefined
311
+ section: section,
312
+ prefix: getDisplaySectionPrefix(section, index),
313
+ text: text,
314
+ filled: sectionValue !== undefined
283
315
  };
284
316
  });
285
- }, [sectionOrder, sections, pendingDigits]);
317
+ }, [format, pendingDigits, sectionOrder, sections]);
318
+
319
+ // A required-field error is caused by whichever section(s) are still
320
+ // empty, so only announce it there; once every section has a value the
321
+ // error must be about the value as a whole, so announce it everywhere.
322
+ var allSectionsFilled = displaySections.every(function (entry) {
323
+ return entry.filled;
324
+ });
286
325
  var onDisplaySectionMouseDown = (0, _react.useCallback)(function (section, event) {
287
326
  if (readOnly) return;
288
327
  if (disabled) return;
@@ -319,8 +358,8 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
319
358
  }).sort(function (a, b) {
320
359
  return a.rect.left - b.rect.left;
321
360
  });
322
- var sectionFromBounds = sectionsWithRects.find(function (_ref3) {
323
- var rect = _ref3.rect;
361
+ var sectionFromBounds = sectionsWithRects.find(function (_ref2) {
362
+ var rect = _ref2.rect;
324
363
  return x >= rect.left && x <= rect.right;
325
364
  });
326
365
  if ((sectionFromBounds == null || (_sectionFromBounds$no = sectionFromBounds.node) == null || (_sectionFromBounds$no = _sectionFromBounds$no.dataset) == null ? void 0 : _sectionFromBounds$no.section) !== undefined) {
@@ -330,8 +369,8 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
330
369
  return;
331
370
  }
332
371
  }
333
- var zones = sectionsWithRects.map(function (_ref4, index) {
334
- var rect = _ref4.rect;
372
+ var zones = sectionsWithRects.map(function (_ref3, index) {
373
+ var rect = _ref3.rect;
335
374
  var prev = sectionsWithRects[index - 1];
336
375
  var next = sectionsWithRects[index + 1];
337
376
  var start = prev !== undefined ? (prev.rect.right + rect.left) / 2 : Number.NEGATIVE_INFINITY;
@@ -342,9 +381,9 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
342
381
  end: end
343
382
  };
344
383
  });
345
- var zone = zones.find(function (_ref5) {
346
- var start = _ref5.start,
347
- end = _ref5.end;
384
+ var zone = zones.find(function (_ref4) {
385
+ var start = _ref4.start,
386
+ end = _ref4.end;
348
387
  return x >= start && x <= end;
349
388
  }) || zones[0] || null;
350
389
  if (zone) {
@@ -376,6 +415,7 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
376
415
  }, 0);
377
416
  }, [activeSection, focusSection]);
378
417
  var onSegmentFocus = (0, _react.useCallback)(function (section) {
418
+ setFieldFocusIndicator == null || setFieldFocusIndicator(true);
379
419
  if (!segmentFocused && !readOnly && !disabled && !open) {
380
420
  announce(formatMessage({
381
421
  id: 'timeInput.openDrop',
@@ -385,24 +425,26 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
385
425
  setSegmentFocused(true);
386
426
  if (readOnly || disabled) return;
387
427
  setActiveSection(section);
388
- }, [announce, disabled, formatMessage, messages, open, readOnly, segmentFocused, setActiveSection]);
428
+ }, [announce, disabled, formatMessage, messages, open, readOnly, segmentFocused, setFieldFocusIndicator, setActiveSection]);
389
429
  var onSegmentBlur = (0, _react.useCallback)(function () {
390
430
  requestAnimationFrame(function () {
431
+ var _containerRef$current;
391
432
  var _document = document,
392
433
  activeElement = _document.activeElement;
393
434
  var isSegmentFocused = Object.values(segmentRefs.current).includes(activeElement);
394
- if (!isSegmentFocused && activeElement === document.body && !readOnly && !disabled) {
395
- focusSection(activeSection);
396
- return;
397
- }
398
- if (!isSegmentFocused) {
435
+ var isInsideTimeInput = (_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.contains(activeElement);
436
+ if (!isSegmentFocused || !isInsideTimeInput) {
399
437
  setSegmentFocused(false);
400
438
  }
401
439
  });
402
- }, [activeSection, disabled, focusSection, readOnly]);
440
+ }, []);
403
441
  var onSegmentKeyDown = (0, _react.useCallback)(function (section, event) {
404
442
  if (readOnly || disabled) return;
405
- var key = event.key;
443
+ var key = event.key,
444
+ ctrlKey = event.ctrlKey,
445
+ metaKey = event.metaKey,
446
+ altKey = event.altKey;
447
+ if (ctrlKey || metaKey || altKey && key !== 'ArrowDown') return;
406
448
  if (activeSection !== section) {
407
449
  setActiveSection(section);
408
450
  }
@@ -411,10 +453,12 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
411
453
  var next = moveSection(1);
412
454
  setActiveSection(next);
413
455
  focusSection(next);
456
+ event.stopPropagation();
414
457
  return;
415
458
  }
416
459
  if (key === 'ArrowLeft') {
417
460
  event.preventDefault();
461
+ event.stopPropagation();
418
462
  var _next = moveSection(-1);
419
463
  setActiveSection(_next);
420
464
  focusSection(_next);
@@ -422,48 +466,51 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
422
466
  }
423
467
  if (key === 'Home') {
424
468
  event.preventDefault();
469
+ event.stopPropagation();
425
470
  setActiveSection(firstSection);
426
471
  focusSection(firstSection);
427
472
  return;
428
473
  }
429
474
  if (key === 'End') {
430
475
  event.preventDefault();
476
+ event.stopPropagation();
431
477
  setActiveSection(lastSection);
432
478
  focusSection(lastSection);
433
479
  return;
434
480
  }
435
481
  if (key === 'ArrowUp') {
436
482
  event.preventDefault();
483
+ event.stopPropagation();
437
484
  incrementSection(section, open ? -1 : 1);
438
485
  return;
439
486
  }
440
487
  if (key === 'ArrowDown') {
441
- if (event.altKey) {
488
+ if (altKey) {
442
489
  event.preventDefault();
490
+ event.stopPropagation();
443
491
  openPicker();
444
492
  return;
445
493
  }
446
494
  event.preventDefault();
495
+ event.stopPropagation();
447
496
  incrementSection(section, open ? 1 : -1);
448
497
  return;
449
498
  }
450
499
  if (key === 'Delete' || key === 'Backspace') {
451
500
  event.preventDefault();
501
+ event.stopPropagation();
452
502
  clearActiveSection();
453
503
  return;
454
504
  }
455
- if (key === 'Enter') {
456
- event.preventDefault();
457
- if (open) closePicker();
458
- return;
459
- }
460
- if (key === 'Escape' && open) {
505
+ if ((key === 'Enter' || key === 'Escape') && open) {
461
506
  event.preventDefault();
507
+ event.stopPropagation();
462
508
  closePicker();
463
509
  return;
464
510
  }
465
511
  if (key === ' ' || key === 'Spacebar') {
466
512
  event.preventDefault();
513
+ event.stopPropagation();
467
514
  openPicker();
468
515
  return;
469
516
  }
@@ -471,21 +518,23 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
471
518
  var lower = key.toLowerCase();
472
519
  if (lower === 'a') {
473
520
  event.preventDefault();
521
+ event.stopPropagation();
474
522
  setSectionValue(_utils2.SECTION_PERIOD, 'AM');
475
523
  } else if (lower === 'p') {
476
524
  event.preventDefault();
525
+ event.stopPropagation();
477
526
  setSectionValue(_utils2.SECTION_PERIOD, 'PM');
478
527
  }
479
528
  return;
480
529
  }
481
530
  if (/^\d$/.test(key)) {
482
531
  event.preventDefault();
532
+ event.stopPropagation();
483
533
  var _next2 = applyDigit(Number(key));
484
534
  var targetSection = _next2 != null ? _next2 : section;
485
535
  setActiveSection(targetSection);
486
- if (targetSection === section) {
487
- event.currentTarget.focus();
488
- } else {
536
+ if (targetSection !== section) {
537
+ // moving to a different section focus for digit',
489
538
  focusSection(targetSection);
490
539
  }
491
540
  }
@@ -541,13 +590,33 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
541
590
  });
542
591
  }, []);
543
592
  var showActiveSection = (segmentFocused || open) && !readOnly && !disabled;
593
+ var containerTheme = (_theme$timeInput = theme.timeInput) == null ? void 0 : _theme$timeInput.container;
594
+ var dropButtonTheme = (_theme$timeInput2 = theme.timeInput) == null ? void 0 : _theme$timeInput2.dropButton;
595
+ var dropButtonKind = 'toolbar';
596
+ var dropButtonIcon = /*#__PURE__*/_react["default"].createElement(_Clock.Clock, {
597
+ "aria-hidden": "true"
598
+ });
599
+ if (typeof dropButtonTheme === 'string') {
600
+ dropButtonKind = dropButtonTheme;
601
+ } else if (dropButtonTheme && typeof dropButtonTheme === 'object' && ! /*#__PURE__*/_react["default"].isValidElement(dropButtonTheme) && !dropButtonTheme.$$typeof) {
602
+ var icon = dropButtonTheme.icon,
603
+ kind = dropButtonTheme.kind,
604
+ buttonTheme = _objectWithoutPropertiesLoose(dropButtonTheme, _excluded3);
605
+ dropButtonIcon = resolveDropButtonIcon(icon != null ? icon : dropButtonIcon);
606
+ if (kind) {
607
+ dropButtonKind = kind;
608
+ } else {
609
+ var hasButtonTheme = Object.keys(buttonTheme).length > 0;
610
+ dropButtonKind = hasButtonTheme ? buttonTheme : 'toolbar';
611
+ }
612
+ }
544
613
  if (inline) {
545
614
  return /*#__PURE__*/_react["default"].createElement(_TimeInputPopup.TimeInputPopup, _extends({
546
615
  inline: true,
547
616
  activeSection: activeSection,
548
617
  format: format,
549
618
  formatMessage: formatMessage,
550
- focusOnOpen: focusOnOpen,
619
+ focusOnOpen: inline ? false : focusOnOpen,
551
620
  hoursOptions: hoursOptions,
552
621
  incrementSection: incrementSection,
553
622
  messages: messages,
@@ -565,21 +634,27 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
565
634
  ref: containerRef,
566
635
  direction: "row",
567
636
  border: !plainProp,
568
- fill: true,
569
- 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),
637
+ fill: getContainerFill(containerTheme)
638
+ }, containerTheme, {
639
+ round: (_theme$timeInput$cont = (_theme$timeInput3 = theme.timeInput) == null || (_theme$timeInput3 = _theme$timeInput3.container) == null ? void 0 : _theme$timeInput3.round) != null ? _theme$timeInput$cont : (_theme$global = theme.global) == null || (_theme$global = _theme$global.control) == null || (_theme$global = _theme$global.border) == null ? void 0 : _theme$global.radius,
570
640
  disabled: disabled,
571
641
  readOnlyProp: readOnly,
572
642
  focusIndicator: (focusIndicatorProp != null ? focusIndicatorProp : true) && !iconFocused
573
- }, passThemeFlag), /*#__PURE__*/_react["default"].createElement(_StyledTimeInput.StyledTimeInputField, passThemeFlag, /*#__PURE__*/_react["default"].createElement(_StyledTimeInput.StyledTimeInputDisplay, _extends({
643
+ }, passThemeFlag), /*#__PURE__*/_react["default"].createElement(_StyledTimeInput.StyledTimeInputField, passThemeFlag, /*#__PURE__*/_react["default"].createElement(_StyledTimeInput.StyledTimeInputDisplay, _extends({}, (_theme$timeInput4 = theme.timeInput) == null ? void 0 : _theme$timeInput4.value, {
644
+ align: "center",
645
+ direction: "row",
646
+ overflow: "hidden",
574
647
  role: "group",
575
648
  "aria-label": groupLabel,
576
649
  "aria-labelledby": formFieldLabelId,
577
650
  onMouseDown: onDisplayMouseDown
578
- }, passThemeFlag), displaySections.map(function (_ref6) {
579
- var section = _ref6.section,
580
- prefix = _ref6.prefix,
581
- text = _ref6.text,
582
- filled = _ref6.filled;
651
+ }, passThemeFlag), displaySections.map(function (_ref5) {
652
+ var ariaMeta = _ref5.ariaMeta,
653
+ section = _ref5.section,
654
+ prefix = _ref5.prefix,
655
+ text = _ref5.text,
656
+ filled = _ref5.filled;
657
+ var describeSegment = !filled || allSectionsFilled;
583
658
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
584
659
  key: section
585
660
  }, !!prefix && /*#__PURE__*/_react["default"].createElement(_StyledTimeInput.StyledTimeInputSeparator, _extends({
@@ -588,6 +663,7 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
588
663
  ref: function ref(segmentNode) {
589
664
  segmentRefs.current[section] = segmentNode;
590
665
  },
666
+ responsive: false,
591
667
  tabIndex: !readOnly && !disabled && activeSection === section ? 0 : -1,
592
668
  $active: showActiveSection && activeSection === section,
593
669
  $filled: filled,
@@ -600,28 +676,17 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
600
676
  },
601
677
  onPaste: onSegmentPaste,
602
678
  "data-active": showActiveSection && activeSection === section,
603
- "data-testid": showActiveSection && activeSection === section ? 'time-input-active-section' : undefined,
604
679
  "data-section": section
605
680
  }, passThemeFlag, {
606
681
  "aria-label": (0, _utils2.getSectionName)(section, format, formatMessage, messages),
607
682
  role: "spinbutton",
608
683
  "aria-disabled": disabled || undefined,
609
684
  "aria-readonly": readOnly || undefined,
610
- "aria-valuenow": (0, _utils2.getSectionAriaMeta)({
611
- section: section,
612
- format: format,
613
- sections: sections
614
- }).now,
615
- "aria-valuemin": (0, _utils2.getSectionAriaMeta)({
616
- section: section,
617
- format: format,
618
- sections: sections
619
- }).min,
620
- "aria-valuemax": (0, _utils2.getSectionAriaMeta)({
621
- section: section,
622
- format: format,
623
- sections: sections
624
- }).max,
685
+ "aria-invalid": ariaInvalid && describeSegment || undefined,
686
+ "aria-describedby": [consumerDescribedBy, describeSegment && hasErrorDescribedBy ? errorId : undefined].filter(Boolean).join(' ') || undefined,
687
+ "aria-valuenow": ariaMeta.now,
688
+ "aria-valuemin": ariaMeta.min,
689
+ "aria-valuemax": ariaMeta.max,
625
690
  "aria-valuetext": getSectionValueAnnouncement(section)
626
691
  }), text));
627
692
  })), /*#__PURE__*/_react["default"].createElement(_StyledTimeInput.StyledTimeInput, _extends({
@@ -643,10 +708,9 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
643
708
  type: "hidden",
644
709
  value: value || ''
645
710
  }), !readOnly && /*#__PURE__*/_react["default"].createElement(_Button.Button, {
646
- icon: /*#__PURE__*/_react["default"].createElement(_Clock.Clock, null),
647
- plain: true,
711
+ kind: dropButtonKind,
712
+ icon: dropButtonIcon,
648
713
  disabled: disabled,
649
- margin: (_theme$timeInput2 = theme.timeInput) == null || (_theme$timeInput2 = _theme$timeInput2.button) == null ? void 0 : _theme$timeInput2.margin,
650
714
  "aria-label": formatMessage({
651
715
  id: 'timeInput.chooseTime',
652
716
  messages: messages
@@ -656,6 +720,7 @@ var TimeInput = exports.TimeInput = /*#__PURE__*/(0, _react.forwardRef)(function
656
720
  "aria-controls": id ? id + "__drop" : undefined,
657
721
  onFocus: function onFocus() {
658
722
  setIconFocused(true);
723
+ setFieldFocusIndicator == null || setFieldFocusIndicator(false);
659
724
  },
660
725
  onBlur: function onBlur() {
661
726
  setIconFocused(false);