grommet 2.56.0 → 2.56.1

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 (118) hide show
  1. package/COPYRIGHT.md +3 -1
  2. package/components/Calendar/Calendar.js +2 -1
  3. package/components/Cards/Cards.js +1 -2
  4. package/components/DateTimeInput/DateTimeInput.js +1093 -0
  5. package/components/DateTimeInput/README.md +2 -0
  6. package/components/DateTimeInput/StyledDateTimeInput.js +74 -0
  7. package/components/DateTimeInput/index.d.ts +47 -0
  8. package/components/DateTimeInput/index.js +6 -0
  9. package/components/DateTimeInput/propTypes.js +42 -0
  10. package/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
  11. package/components/DateTimeInput/stories/Form.stories.tsx +44 -0
  12. package/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
  13. package/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
  14. package/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
  15. package/components/Form/Form.js +7 -4
  16. package/components/Form/index.d.ts +3 -0
  17. package/components/Form/stories/AggregateValidation.stories.js +6 -8
  18. package/components/FormField/FormField.js +164 -91
  19. package/components/Stepper/StepConnector.js +19 -49
  20. package/components/Stepper/Stepper.js +5 -11
  21. package/components/Stepper/StepperStep.js +14 -4
  22. package/components/Stepper/StyledStepper.js +59 -21
  23. package/components/TimeInput/TimeInput.js +50 -47
  24. package/components/TimeInput/TimeInputPopup.js +172 -76
  25. package/components/TimeInput/index.d.ts +3 -0
  26. package/components/TimeInput/propTypes.js +4 -0
  27. package/components/TimeInput/useSectionedTimeField.js +33 -34
  28. package/components/TimeInput/utils.js +31 -26
  29. package/components/Wizard/StyledWizard.js +16 -0
  30. package/components/Wizard/Wizard.js +770 -0
  31. package/components/Wizard/WizardContent.js +90 -0
  32. package/components/Wizard/WizardContext.js +35 -0
  33. package/components/Wizard/WizardFooter.js +123 -0
  34. package/components/Wizard/WizardHeader.js +63 -0
  35. package/components/Wizard/WizardProgress.js +84 -0
  36. package/components/Wizard/WizardStepHeader.js +55 -0
  37. package/components/Wizard/index.d.ts +171 -0
  38. package/components/Wizard/index.js +19 -0
  39. package/components/Wizard/propTypes.js +56 -0
  40. package/components/Wizard/stories/BasicLinear.stories.js +71 -0
  41. package/components/Wizard/stories/Branching.stories.js +96 -0
  42. package/components/Wizard/stories/Composable.stories.js +75 -0
  43. package/components/Wizard/stories/Controlled.stories.js +136 -0
  44. package/components/Wizard/stories/LongContent.stories.js +118 -0
  45. package/components/Wizard/stories/Modal.stories.js +143 -0
  46. package/components/Wizard/stories/NestedSubSteps.stories.js +79 -0
  47. package/components/Wizard/stories/Validation.stories.js +123 -0
  48. package/components/index.d.ts +4 -0
  49. package/components/index.js +12 -0
  50. package/es6/components/Calendar/Calendar.js +2 -0
  51. package/es6/components/Cards/Cards.js +1 -2
  52. package/es6/components/DateTimeInput/DateTimeInput.js +1090 -0
  53. package/es6/components/DateTimeInput/README.md +2 -0
  54. package/es6/components/DateTimeInput/StyledDateTimeInput.js +68 -0
  55. package/es6/components/DateTimeInput/index.d.ts +47 -0
  56. package/es6/components/DateTimeInput/index.js +3 -0
  57. package/es6/components/DateTimeInput/propTypes.js +36 -0
  58. package/es6/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
  59. package/es6/components/DateTimeInput/stories/Form.stories.tsx +44 -0
  60. package/es6/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
  61. package/es6/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
  62. package/es6/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
  63. package/es6/components/Form/Form.js +7 -3
  64. package/es6/components/Form/index.d.ts +3 -0
  65. package/es6/components/Form/stories/AggregateValidation.stories.js +6 -9
  66. package/es6/components/FormField/FormField.js +165 -91
  67. package/es6/components/Stepper/StepConnector.js +18 -48
  68. package/es6/components/Stepper/Stepper.js +5 -10
  69. package/es6/components/Stepper/StepperStep.js +15 -4
  70. package/es6/components/Stepper/StyledStepper.js +57 -21
  71. package/es6/components/TimeInput/TimeInput.js +50 -46
  72. package/es6/components/TimeInput/TimeInputPopup.js +172 -76
  73. package/es6/components/TimeInput/index.d.ts +3 -0
  74. package/es6/components/TimeInput/propTypes.js +3 -0
  75. package/es6/components/TimeInput/useSectionedTimeField.js +34 -35
  76. package/es6/components/TimeInput/utils.js +25 -21
  77. package/es6/components/Wizard/StyledWizard.js +11 -0
  78. package/es6/components/Wizard/Wizard.js +768 -0
  79. package/es6/components/Wizard/WizardContent.js +87 -0
  80. package/es6/components/Wizard/WizardContext.js +31 -0
  81. package/es6/components/Wizard/WizardFooter.js +120 -0
  82. package/es6/components/Wizard/WizardHeader.js +60 -0
  83. package/es6/components/Wizard/WizardProgress.js +80 -0
  84. package/es6/components/Wizard/WizardStepHeader.js +51 -0
  85. package/es6/components/Wizard/index.d.ts +171 -0
  86. package/es6/components/Wizard/index.js +7 -0
  87. package/es6/components/Wizard/propTypes.js +51 -0
  88. package/es6/components/Wizard/stories/BasicLinear.stories.js +67 -0
  89. package/es6/components/Wizard/stories/Branching.stories.js +93 -0
  90. package/es6/components/Wizard/stories/Composable.stories.js +72 -0
  91. package/es6/components/Wizard/stories/Controlled.stories.js +133 -0
  92. package/es6/components/Wizard/stories/LongContent.stories.js +115 -0
  93. package/es6/components/Wizard/stories/Modal.stories.js +141 -0
  94. package/es6/components/Wizard/stories/NestedSubSteps.stories.js +76 -0
  95. package/es6/components/Wizard/stories/Validation.stories.js +118 -0
  96. package/es6/components/index.d.ts +4 -0
  97. package/es6/components/index.js +4 -0
  98. package/es6/index.d.ts +4 -0
  99. package/es6/languages/default.json +28 -0
  100. package/es6/themes/base.d.ts +115 -0
  101. package/es6/themes/base.js +158 -0
  102. package/es6/utils/DOM.js +11 -2
  103. package/es6/utils/dates.js +10 -0
  104. package/es6/utils/sectionHelpers.js +57 -0
  105. package/es6/utils/useSectionedField.js +45 -0
  106. package/grommet.min.js +2 -1
  107. package/grommet.min.js.LICENSE.txt +1 -0
  108. package/grommet.min.js.map +1 -1
  109. package/index.d.ts +4 -0
  110. package/languages/default.json +28 -0
  111. package/package.json +35 -31
  112. package/themes/base.d.ts +115 -0
  113. package/themes/base.js +158 -1
  114. package/tools/license-header.js +2 -0
  115. package/utils/DOM.js +11 -2
  116. package/utils/dates.js +11 -1
  117. package/utils/sectionHelpers.js +61 -0
  118. package/utils/useSectionedField.js +50 -0
@@ -11,9 +11,13 @@ var _Box = require("../Box");
11
11
  var _Drop = require("../Drop");
12
12
  var _Text = require("../Text");
13
13
  var _utils2 = require("./utils");
14
+ var _excluded = ["activeSection", "align", "format", "formatMessage", "hoursOptions", "id", "incrementSection", "messages", "minuteOptions", "onClose", "onFocusLeave", "secondOptions", "sectionOrder", "sections", "setActiveSection", "setSectionValue", "target", "dropProps", "label", "inline", "onKeyDown"]; // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
15
+ // SPDX-License-Identifier: Apache-2.0
16
+ /* eslint-disable max-len */
14
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
18
  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); }
16
- 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); } /* eslint-disable max-len */
19
+ 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); }
20
+ 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; }
17
21
  var PopupColumnBox = (0, _styledComponents["default"])(_Box.Box).withConfig({
18
22
  displayName: "TimeInputPopup__PopupColumnBox",
19
23
  componentId: "sc-r2j8uh-0"
@@ -50,26 +54,42 @@ var PopupOption = _styledComponents["default"].div.withConfig({
50
54
  var optionKey = function optionKey(label, option) {
51
55
  return label.toLowerCase() + "-" + option;
52
56
  };
53
- var PopupColumn = function PopupColumn(_ref) {
54
- var _theme$timeInput;
55
- var activeSection = _ref.activeSection,
57
+ var getDefaultPopupOption = function getDefaultPopupOption(_ref) {
58
+ var section = _ref.section,
56
59
  format = _ref.format,
57
- formatMessage = _ref.formatMessage,
58
- label = _ref.label,
59
- messages = _ref.messages,
60
- onClickCommitOption = _ref.onClickCommitOption,
61
- onPointerCommitOption = _ref.onPointerCommitOption,
62
- onSetSection = _ref.onSetSection,
63
- options = _ref.options,
64
- section = _ref.section,
65
- sections = _ref.sections,
66
- theme = _ref.theme;
60
+ options = _ref.options;
61
+ if (section === _utils2.SECTION_HOUR) {
62
+ var defaultHour = (0, _utils2.defaultHourForFormat)(format);
63
+ return options.includes(defaultHour) ? defaultHour : options[0];
64
+ }
65
+ if (section === _utils2.SECTION_PERIOD) return 'AM';
66
+ return options[0];
67
+ };
68
+ var PopupColumn = function PopupColumn(_ref2) {
69
+ var _theme$global$size, _theme$timeInput;
70
+ var activeSection = _ref2.activeSection,
71
+ format = _ref2.format,
72
+ formatMessage = _ref2.formatMessage,
73
+ inline = _ref2.inline,
74
+ label = _ref2.label,
75
+ messages = _ref2.messages,
76
+ onClickCommitOption = _ref2.onClickCommitOption,
77
+ onPointerCommitOption = _ref2.onPointerCommitOption,
78
+ onSetSection = _ref2.onSetSection,
79
+ options = _ref2.options,
80
+ section = _ref2.section,
81
+ sections = _ref2.sections,
82
+ theme = _ref2.theme;
83
+ // When inline (in DateTimeInput), use 'medium' to match Calendar height.
84
+ // Otherwise use timeInput drop maxHeight with fallback to 'small'.
85
+ var maxHeightToken = inline ? 'medium' : null;
86
+ var maxHeight = maxHeightToken && ((_theme$global$size = theme.global.size) == null ? void 0 : _theme$global$size[maxHeightToken]) || ((_theme$timeInput = theme.timeInput) == null || (_theme$timeInput = _theme$timeInput.drop) == null || (_theme$timeInput = _theme$timeInput.column) == null ? void 0 : _theme$timeInput.maxHeight) || theme.global.size.small;
67
87
  return /*#__PURE__*/_react["default"].createElement(PopupColumnBox, {
68
88
  role: "listbox",
69
89
  "aria-label": label,
70
90
  gap: "xxsmall",
71
91
  height: {
72
- max: ((_theme$timeInput = theme.timeInput) == null || (_theme$timeInput = _theme$timeInput.drop) == null || (_theme$timeInput = _theme$timeInput.column) == null ? void 0 : _theme$timeInput.maxHeight) || theme.global.size.small
92
+ max: maxHeight
73
93
  },
74
94
  overflow: "auto",
75
95
  flex: {
@@ -79,15 +99,34 @@ var PopupColumn = function PopupColumn(_ref) {
79
99
  }, options.map(function (option) {
80
100
  var _theme$timeInput2;
81
101
  var key = optionKey(label, option);
102
+ var sectionHasValue = section === _utils2.SECTION_HOUR && sections.hour !== undefined || section === _utils2.SECTION_MINUTE && sections.minute !== undefined || section === _utils2.SECTION_SECOND && sections.second !== undefined || section === _utils2.SECTION_PERIOD && sections.period !== undefined;
103
+
104
+ // In empty state, keep focus defaults but avoid visually selecting
105
+ // options until the user makes an explicit choice.
82
106
  var selected = section === _utils2.SECTION_HOUR && sections.hour === option || section === _utils2.SECTION_MINUTE && sections.minute === option || section === _utils2.SECTION_SECOND && sections.second === option || section === _utils2.SECTION_PERIOD && sections.period === option;
83
107
  var optionColor = selected ? ((_theme$timeInput2 = theme.timeInput) == null || (_theme$timeInput2 = _theme$timeInput2.drop) == null || (_theme$timeInput2 = _theme$timeInput2.option) == null || (_theme$timeInput2 = _theme$timeInput2.selected) == null ? void 0 : _theme$timeInput2.color) || 'text' : 'text';
84
108
  var isActive = selected && activeSection === section;
109
+ var optionTabIndex = -1;
110
+ if (inline) {
111
+ // In inline mode each column needs exactly one tabbable option so Tab
112
+ // key lands on the option (with Grommet focus style) instead of the
113
+ // listbox container (which has no theme focus style). Use the selected
114
+ // value when set, otherwise fall back to the column's first option.
115
+ var defaultOption = getDefaultPopupOption({
116
+ section: section,
117
+ format: format,
118
+ options: options
119
+ });
120
+ optionTabIndex = selected || !sectionHasValue && option === defaultOption ? 0 : -1;
121
+ } else if (isActive) {
122
+ optionTabIndex = 0;
123
+ }
85
124
  return /*#__PURE__*/_react["default"].createElement(PopupOption, {
86
125
  key: key,
87
126
  "data-option-key": key,
88
127
  role: "option",
89
128
  "aria-selected": selected,
90
- tabIndex: isActive ? 0 : -1,
129
+ tabIndex: optionTabIndex,
91
130
  "aria-label": (section === _utils2.SECTION_PERIOD ? option : (0, _utils2.pad)(option)) + " " + (0, _utils2.getSectionName)(section, format, formatMessage, messages),
92
131
  $active: isActive,
93
132
  $selected: selected,
@@ -106,34 +145,35 @@ var PopupColumn = function PopupColumn(_ref) {
106
145
  }
107
146
  }, /*#__PURE__*/_react["default"].createElement(_Text.Text, {
108
147
  size: theme.global.input.font.size || 'small',
109
- weight: selected ? 'bold' : 'normal',
110
148
  color: optionColor
111
149
  }, section === _utils2.SECTION_PERIOD ? option : (0, _utils2.pad)(option)));
112
150
  }));
113
151
  };
114
- var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
115
- var _theme$timeInput3, _theme$timeInput4;
116
- var activeSection = _ref2.activeSection,
117
- align = _ref2.align,
118
- format = _ref2.format,
119
- formatMessage = _ref2.formatMessage,
120
- hoursOptions = _ref2.hoursOptions,
121
- id = _ref2.id,
122
- incrementSection = _ref2.incrementSection,
123
- messages = _ref2.messages,
124
- minuteOptions = _ref2.minuteOptions,
125
- moveSection = _ref2.moveSection,
126
- onAccept = _ref2.onAccept,
127
- onClose = _ref2.onClose,
128
- onFocusLeave = _ref2.onFocusLeave,
129
- secondOptions = _ref2.secondOptions,
130
- sectionOrder = _ref2.sectionOrder,
131
- sections = _ref2.sections,
132
- setActiveSection = _ref2.setActiveSection,
133
- setSectionValue = _ref2.setSectionValue,
134
- target = _ref2.target,
135
- dropProps = _ref2.dropProps,
136
- label = _ref2.label;
152
+ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
153
+ var _theme$timeInput3, _theme$timeInput4, _theme$timeInput5;
154
+ var activeSection = _ref3.activeSection,
155
+ align = _ref3.align,
156
+ format = _ref3.format,
157
+ formatMessage = _ref3.formatMessage,
158
+ hoursOptions = _ref3.hoursOptions,
159
+ id = _ref3.id,
160
+ incrementSection = _ref3.incrementSection,
161
+ messages = _ref3.messages,
162
+ minuteOptions = _ref3.minuteOptions,
163
+ onClose = _ref3.onClose,
164
+ onFocusLeave = _ref3.onFocusLeave,
165
+ secondOptions = _ref3.secondOptions,
166
+ sectionOrder = _ref3.sectionOrder,
167
+ sections = _ref3.sections,
168
+ setActiveSection = _ref3.setActiveSection,
169
+ setSectionValue = _ref3.setSectionValue,
170
+ target = _ref3.target,
171
+ dropProps = _ref3.dropProps,
172
+ label = _ref3.label,
173
+ _ref3$inline = _ref3.inline,
174
+ inline = _ref3$inline === void 0 ? false : _ref3$inline,
175
+ onKeyDownProp = _ref3.onKeyDown,
176
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
137
177
  var _useThemeValue = (0, _useThemeValue2.useThemeValue)(),
138
178
  theme = _useThemeValue.theme;
139
179
  var dialogRef = (0, _react.useRef)();
@@ -224,10 +264,29 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
224
264
  label: 'period',
225
265
  options: ['AM', 'PM']
226
266
  }];
227
- var visiblePopupSections = popupSections.filter(function (_ref3) {
228
- var section = _ref3.section;
267
+ var visiblePopupSections = popupSections.filter(function (_ref4) {
268
+ var section = _ref4.section;
229
269
  return sectionOrder.includes(section);
230
270
  });
271
+ var getSectionFromLabel = (0, _react.useCallback)(function (listboxLabel) {
272
+ if (listboxLabel === 'hour') return _utils2.SECTION_HOUR;
273
+ if (listboxLabel === 'minute') return _utils2.SECTION_MINUTE;
274
+ if (listboxLabel === 'second') return _utils2.SECTION_SECOND;
275
+ if (listboxLabel === 'period') return _utils2.SECTION_PERIOD;
276
+ return undefined;
277
+ }, []);
278
+ var getSectionFromEventTarget = (0, _react.useCallback)(function (eventTarget) {
279
+ var listboxNode = eventTarget == null || eventTarget.closest == null ? void 0 : eventTarget.closest('[role="listbox"]');
280
+ var ariaLabel = listboxNode == null || listboxNode.getAttribute == null ? void 0 : listboxNode.getAttribute('aria-label');
281
+ return getSectionFromLabel(ariaLabel);
282
+ }, [getSectionFromLabel]);
283
+ var getAdjacentSection = (0, _react.useCallback)(function (section, delta) {
284
+ var _sectionOrder$, _sectionOrder$nextInd;
285
+ var currentIndex = sectionOrder.indexOf(section);
286
+ if (currentIndex === -1) return (_sectionOrder$ = sectionOrder[0]) != null ? _sectionOrder$ : section;
287
+ var nextIndex = (currentIndex + delta + sectionOrder.length) % sectionOrder.length;
288
+ return (_sectionOrder$nextInd = sectionOrder[nextIndex]) != null ? _sectionOrder$nextInd : section;
289
+ }, [sectionOrder]);
231
290
  var scrollSelectedOptionsIntoView = (0, _react.useCallback)(function () {
232
291
  var _sectionLabel, _sectionValue;
233
292
  if (pointerDownInsideRef.current) return;
@@ -238,9 +297,21 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
238
297
  var popupNode = dialogRef.current;
239
298
  if (!popupNode) return;
240
299
  var sectionLabel = (_sectionLabel = {}, _sectionLabel[_utils2.SECTION_HOUR] = 'hour', _sectionLabel[_utils2.SECTION_MINUTE] = 'minute', _sectionLabel[_utils2.SECTION_SECOND] = 'second', _sectionLabel[_utils2.SECTION_PERIOD] = 'period', _sectionLabel);
241
- var sectionValue = (_sectionValue = {}, _sectionValue[_utils2.SECTION_HOUR] = sections.hour !== undefined ? sections.hour : hoursOptions[0], _sectionValue[_utils2.SECTION_MINUTE] = sections.minute !== undefined ? sections.minute : minuteOptions[0], _sectionValue[_utils2.SECTION_SECOND] = sections.second !== undefined ? sections.second : secondOptions[0], _sectionValue[_utils2.SECTION_PERIOD] = sections.period || 'AM', _sectionValue);
242
- visiblePopupSections.forEach(function (_ref4) {
243
- var section = _ref4.section;
300
+ var sectionValue = (_sectionValue = {}, _sectionValue[_utils2.SECTION_HOUR] = sections.hour !== undefined ? sections.hour : getDefaultPopupOption({
301
+ section: _utils2.SECTION_HOUR,
302
+ format: format,
303
+ options: hoursOptions
304
+ }), _sectionValue[_utils2.SECTION_MINUTE] = sections.minute !== undefined ? sections.minute : getDefaultPopupOption({
305
+ section: _utils2.SECTION_MINUTE,
306
+ format: format,
307
+ options: minuteOptions
308
+ }), _sectionValue[_utils2.SECTION_SECOND] = sections.second !== undefined ? sections.second : getDefaultPopupOption({
309
+ section: _utils2.SECTION_SECOND,
310
+ format: format,
311
+ options: secondOptions
312
+ }), _sectionValue[_utils2.SECTION_PERIOD] = sections.period || 'AM', _sectionValue);
313
+ visiblePopupSections.forEach(function (_ref5) {
314
+ var section = _ref5.section;
244
315
  var labelValue = sectionLabel[section];
245
316
  if (!labelValue) return;
246
317
  var listboxNode = popupNode.querySelector("[role=\"listbox\"][aria-label=\"" + labelValue + "\"]");
@@ -261,11 +332,23 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
261
332
  listboxNode.scrollTop = Math.max(0, targetScrollTop);
262
333
  }
263
334
  });
264
- }, [hoursOptions, minuteOptions, secondOptions, sections, visiblePopupSections]);
335
+ }, [format, hoursOptions, minuteOptions, secondOptions, sections, visiblePopupSections]);
265
336
  var focusCurrentPopupOption = (0, _react.useCallback)(function () {
266
337
  var _labelMap, _keyMap, _dialogRef$current, _dialogRef$current2;
267
338
  var labelMap = (_labelMap = {}, _labelMap[_utils2.SECTION_HOUR] = 'hour', _labelMap[_utils2.SECTION_MINUTE] = 'minute', _labelMap[_utils2.SECTION_SECOND] = 'second', _labelMap[_utils2.SECTION_PERIOD] = 'period', _labelMap);
268
- var keyMap = (_keyMap = {}, _keyMap[_utils2.SECTION_HOUR] = optionKey('hour', sections.hour !== undefined ? sections.hour : hoursOptions[0]), _keyMap[_utils2.SECTION_MINUTE] = optionKey('minute', sections.minute !== undefined ? sections.minute : minuteOptions[0]), _keyMap[_utils2.SECTION_SECOND] = optionKey('second', sections.second !== undefined ? sections.second : secondOptions[0]), _keyMap[_utils2.SECTION_PERIOD] = optionKey('period', sections.period || 'AM'), _keyMap);
339
+ var keyMap = (_keyMap = {}, _keyMap[_utils2.SECTION_HOUR] = optionKey('hour', sections.hour !== undefined ? sections.hour : getDefaultPopupOption({
340
+ section: _utils2.SECTION_HOUR,
341
+ format: format,
342
+ options: hoursOptions
343
+ })), _keyMap[_utils2.SECTION_MINUTE] = optionKey('minute', sections.minute !== undefined ? sections.minute : getDefaultPopupOption({
344
+ section: _utils2.SECTION_MINUTE,
345
+ format: format,
346
+ options: minuteOptions
347
+ })), _keyMap[_utils2.SECTION_SECOND] = optionKey('second', sections.second !== undefined ? sections.second : getDefaultPopupOption({
348
+ section: _utils2.SECTION_SECOND,
349
+ format: format,
350
+ options: secondOptions
351
+ })), _keyMap[_utils2.SECTION_PERIOD] = optionKey('period', sections.period || 'AM'), _keyMap);
269
352
  var selector = "[data-option-key=\"" + keyMap[activeSection] + "\"]";
270
353
  var node = (_dialogRef$current = dialogRef.current) == null ? void 0 : _dialogRef$current.querySelector(selector);
271
354
  if (node) {
@@ -283,7 +366,7 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
283
366
  return true;
284
367
  }
285
368
  return false;
286
- }, [activeSection, hoursOptions, minuteOptions, secondOptions, sections]);
369
+ }, [activeSection, format, hoursOptions, minuteOptions, secondOptions, sections]);
287
370
  (0, _useIsomorphicLayoutEffect.useLayoutEffect)(function () {
288
371
  // Avoid stealing pointer interactions: while the user is actively
289
372
  // clicking inside the popup, let that click settle before refocusing.
@@ -309,16 +392,10 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
309
392
  if (rafB) window.cancelAnimationFrame(rafB);
310
393
  };
311
394
  }, [focusCurrentPopupOption, scrollSelectedOptionsIntoView]);
312
- return /*#__PURE__*/_react["default"].createElement(_Drop.Drop, _extends({
313
- id: id ? id + "__drop" : undefined,
314
- target: target,
315
- align: align,
316
- onEsc: onClose,
317
- onClickOutside: onClose
318
- }, dropProps), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
395
+ var popupContent = /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
319
396
  ref: dialogRef,
320
- role: "dialog",
321
- "aria-label": label,
397
+ role: inline ? undefined : 'dialog',
398
+ "aria-label": inline ? undefined : label,
322
399
  direction: "row",
323
400
  width: {
324
401
  width: (_theme$timeInput3 = theme.timeInput) == null || (_theme$timeInput3 = _theme$timeInput3.drop) == null ? void 0 : _theme$timeInput3.width,
@@ -326,40 +403,50 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
326
403
  },
327
404
  minHeight: (_theme$timeInput4 = theme.timeInput) == null || (_theme$timeInput4 = _theme$timeInput4.drop) == null ? void 0 : _theme$timeInput4.minHeight,
328
405
  gap: "xsmall",
329
- pad: "small",
406
+ pad: inline ? 'none' : ((_theme$timeInput5 = theme.timeInput) == null || (_theme$timeInput5 = _theme$timeInput5.drop) == null ? void 0 : _theme$timeInput5.pad) || 'small',
330
407
  onPointerDownCapture: markInteractionInProgress,
331
408
  onPointerUpCapture: releaseInteractionAfterClick,
332
409
  onPointerCancelCapture: clearInteractionInProgress,
333
410
  onWheelCapture: onPopupWheelCapture,
334
411
  onKeyDown: function onKeyDown(event) {
412
+ var _ref6;
413
+ var eventSectionFromTarget = getSectionFromEventTarget(event.target);
414
+ var eventSectionFromActiveElement = getSectionFromEventTarget(document.activeElement);
415
+ var eventSection = (_ref6 = eventSectionFromTarget != null ? eventSectionFromTarget : eventSectionFromActiveElement) != null ? _ref6 : activeSection;
335
416
  if (event.key === 'Escape') {
336
- event.preventDefault();
337
- onClose();
338
- } else if (event.key === ' ' || event.key === 'Spacebar') {
417
+ if (onClose) {
418
+ event.preventDefault();
419
+ onClose();
420
+ }
421
+ } else if (event.key === 'Enter') {
339
422
  var _event$target, _document$activeEleme;
340
423
  event.preventDefault();
341
424
  var focusedOption = ((_event$target = event.target) == null || _event$target.closest == null ? void 0 : _event$target.closest('[role="option"]')) || ((_document$activeEleme = document.activeElement) == null || _document$activeEleme.closest == null ? void 0 : _document$activeEleme.closest('[role="option"]'));
342
425
  focusedOption == null || focusedOption.click == null || focusedOption.click();
343
- } else if (event.key === 'Tab') {
426
+ } else if (event.key === ' ' || event.key === 'Spacebar') {
427
+ var _event$target2, _document$activeEleme2;
344
428
  event.preventDefault();
345
- setActiveSection(moveSection(event.shiftKey ? -1 : 1));
429
+ var _focusedOption = ((_event$target2 = event.target) == null || _event$target2.closest == null ? void 0 : _event$target2.closest('[role="option"]')) || ((_document$activeEleme2 = document.activeElement) == null || _document$activeEleme2.closest == null ? void 0 : _document$activeEleme2.closest('[role="option"]'));
430
+ _focusedOption == null || _focusedOption.click == null || _focusedOption.click();
431
+ } else if (event.key === 'Tab') {
432
+ if (!inline) {
433
+ event.preventDefault();
434
+ setActiveSection(getAdjacentSection(eventSection, event.shiftKey ? -1 : 1));
435
+ }
346
436
  } else if (event.key === 'ArrowLeft') {
347
437
  event.preventDefault();
348
- setActiveSection(moveSection(-1));
438
+ setActiveSection(getAdjacentSection(eventSection, -1));
349
439
  } else if (event.key === 'ArrowRight') {
350
440
  event.preventDefault();
351
- setActiveSection(moveSection(1));
441
+ setActiveSection(getAdjacentSection(eventSection, 1));
352
442
  } else if (event.key === 'ArrowUp') {
353
443
  event.preventDefault();
354
- incrementSection(activeSection, -1);
444
+ incrementSection(eventSection, -1);
355
445
  } else if (event.key === 'ArrowDown') {
356
446
  event.preventDefault();
357
- incrementSection(activeSection, 1);
358
- } else if (event.key === 'Enter') {
359
- event.preventDefault();
360
- onAccept == null || onAccept();
361
- onClose();
447
+ incrementSection(eventSection, 1);
362
448
  }
449
+ onKeyDownProp == null || onKeyDownProp(event);
363
450
  },
364
451
  onBlurCapture: function onBlurCapture(event) {
365
452
  var nextFocusTarget = event.relatedTarget;
@@ -370,15 +457,16 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
370
457
  onFocusLeave == null || onFocusLeave();
371
458
  }
372
459
  }
373
- }, visiblePopupSections.map(function (_ref5) {
374
- var section = _ref5.section,
375
- sectionLabel = _ref5.label,
376
- options = _ref5.options;
460
+ }, rest), visiblePopupSections.map(function (_ref7) {
461
+ var section = _ref7.section,
462
+ sectionLabel = _ref7.label,
463
+ options = _ref7.options;
377
464
  return /*#__PURE__*/_react["default"].createElement(PopupColumn, {
378
465
  key: sectionLabel,
379
466
  activeSection: activeSection,
380
467
  format: format,
381
468
  formatMessage: formatMessage,
469
+ inline: inline,
382
470
  label: sectionLabel,
383
471
  messages: messages,
384
472
  onClickCommitOption: commitClickOptionSelection,
@@ -389,5 +477,13 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref2) {
389
477
  sections: sections,
390
478
  theme: theme
391
479
  });
392
- })));
480
+ }));
481
+ if (inline) return popupContent;
482
+ return /*#__PURE__*/_react["default"].createElement(_Drop.Drop, _extends({
483
+ id: id ? id + "__drop" : undefined,
484
+ target: target,
485
+ align: align,
486
+ onEsc: onClose,
487
+ onClickOutside: onClose
488
+ }, dropProps), popupContent);
393
489
  };
@@ -1,3 +1,5 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  import * as React from 'react';
2
4
 
3
5
  export interface TimeInputProps {
@@ -23,6 +25,7 @@ export interface TimeInputProps {
23
25
  name?: string;
24
26
  onChange?: (event: { value?: string }) => void;
25
27
  readOnly?: boolean;
28
+ showSeconds?: boolean;
26
29
  value?: string;
27
30
  }
28
31
 
@@ -4,6 +4,9 @@ exports.__esModule = true;
4
4
  exports.TimeInputPropTypes = void 0;
5
5
  var _propTypes = _interopRequireDefault(require("prop-types"));
6
6
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
7
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
8
+ // SPDX-License-Identifier: Apache-2.0
9
+
7
10
  var PropType = {};
8
11
  if (process.env.NODE_ENV !== 'production') {
9
12
  PropType = {
@@ -29,6 +32,7 @@ if (process.env.NODE_ENV !== 'production') {
29
32
  name: _propTypes["default"].string,
30
33
  onChange: _propTypes["default"].func,
31
34
  readOnly: _propTypes["default"].bool,
35
+ showSeconds: _propTypes["default"].bool,
32
36
  value: _propTypes["default"].string
33
37
  };
34
38
  }
@@ -3,8 +3,11 @@
3
3
  exports.__esModule = true;
4
4
  exports.useSectionedTimeField = void 0;
5
5
  var _react = require("react");
6
+ var _useSectionedField2 = require("../../utils/useSectionedField");
6
7
  var _utils = require("./utils");
7
- 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); } /* eslint-disable no-nested-ternary */
8
+ 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); } // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
9
+ // SPDX-License-Identifier: Apache-2.0
10
+ /* eslint-disable no-nested-ternary */
8
11
  var separatorBeforeSection = function separatorBeforeSection(section) {
9
12
  return section === _utils.SECTION_PERIOD ? ' ' : ':';
10
13
  };
@@ -83,32 +86,25 @@ var useSectionedTimeField = exports.useSectionedTimeField = function useSectione
83
86
  previousValue: undefined,
84
87
  firstDigit: undefined
85
88
  });
86
- var preserveIncompleteSectionsRef = (0, _react.useRef)(false);
87
- // Track pending single digit for display without committing
88
- var _useState = (0, _react.useState)({}),
89
- pendingDigits = _useState[0],
90
- setPendingDigits = _useState[1];
91
- var parsedValue = (0, _react.useMemo)(function () {
92
- return (0, _utils.isoTimeToSections)((0, _utils.normalizeToIsoTime)(value), format);
93
- }, [format, value]);
94
- var _useState2 = (0, _react.useState)(parsedValue || (0, _utils.defaultSections)(format)),
95
- sections = _useState2[0],
96
- setSections = _useState2[1];
97
- var _useState3 = (0, _react.useState)(sectionOrder[0] || _utils.SECTION_HOUR),
98
- activeSection = _useState3[0],
99
- setActiveSection = _useState3[1];
100
- (0, _react.useEffect)(function () {
101
- if (!sectionOrder.includes(activeSection)) {
102
- setActiveSection(sectionOrder[0] || _utils.SECTION_HOUR);
103
- }
104
- }, [activeSection, sectionOrder]);
105
- (0, _react.useEffect)(function () {
106
- if (!parsedValue && preserveIncompleteSectionsRef.current) {
107
- preserveIncompleteSectionsRef.current = false;
108
- return;
109
- }
110
- setSections(parsedValue || (0, _utils.defaultSections)(format));
111
- }, [parsedValue, format]);
89
+ var parseValue = (0, _react.useCallback)(function (nextValue) {
90
+ return (0, _utils.isoTimeToSections)((0, _utils.normalizeToIsoTime)(nextValue), format);
91
+ }, [format]);
92
+ var getDefaultValue = (0, _react.useCallback)(function () {
93
+ return (0, _utils.defaultSections)(format);
94
+ }, [format]);
95
+ var _useSectionedField = (0, _useSectionedField2.useSectionedField)({
96
+ value: value,
97
+ parseValue: parseValue,
98
+ defaultValue: getDefaultValue,
99
+ sectionOrder: sectionOrder
100
+ }),
101
+ activeSection = _useSectionedField.activeSection,
102
+ pendingDigits = _useSectionedField.pendingDigits,
103
+ preserveIncompleteSectionsRef = _useSectionedField.preserveIncompleteSectionsRef,
104
+ sections = _useSectionedField.sections,
105
+ setActiveSection = _useSectionedField.setActiveSection,
106
+ setPendingDigits = _useSectionedField.setPendingDigits,
107
+ setSections = _useSectionedField.setSections;
112
108
  var displayValue = (0, _react.useMemo)(function () {
113
109
  if (!(0, _utils.hasAnyValue)(sections)) return '';
114
110
 
@@ -124,7 +120,7 @@ var useSectionedTimeField = exports.useSectionedTimeField = function useSectione
124
120
  includeTokens: true
125
121
  });
126
122
  }, [sectionOrder, sections, pendingDigits]);
127
- var commitSections = (0, _react.useCallback)(function (nextSections) {
123
+ var commitSections = (0, _react.useCallback)(function (nextSections, changedSection) {
128
124
  var _nextSections$second;
129
125
  setSections(nextSections);
130
126
  var complete = sectionOrder.every(function (section) {
@@ -147,14 +143,17 @@ var useSectionedTimeField = exports.useSectionedTimeField = function useSectione
147
143
  // Mark as incomplete if: sections incomplete OR some invalid
148
144
  var hasIncompleteSections = !complete || !allValid;
149
145
  preserveIncompleteSectionsRef.current = hasIncompleteSections && (0, _utils.hasAnyValue)(nextSections);
150
- onCommit(nextSections, nextValue);
151
- }, [onCommit, sectionOrder, format]);
146
+ onCommit(nextSections, nextValue, changedSection);
147
+ }, [format, onCommit, preserveIncompleteSectionsRef, sectionOrder, setSections]);
152
148
  var setSectionValue = (0, _react.useCallback)(function (section, rawValue) {
153
149
  var _extends2;
154
150
  var key = (0, _utils.sectionKey)(section);
155
151
  var next = _extends({}, sections, (_extends2 = {}, _extends2[key] = rawValue, _extends2));
156
- commitSections(next);
157
- }, [commitSections, sections]);
152
+ commitSections(next, section);
153
+ // Clear any pending first-digit overlay, since it's now stale
154
+ // relative to the section value we just committed.
155
+ setPendingDigits({});
156
+ }, [commitSections, sections, setPendingDigits]);
158
157
  var moveSection = (0, _react.useCallback)(function (direction) {
159
158
  if (!sectionOrder.length) return activeSection;
160
159
  var activeIndex = Math.max(0, sectionOrder.indexOf(activeSection));
@@ -163,7 +162,7 @@ var useSectionedTimeField = exports.useSectionedTimeField = function useSectione
163
162
  var nextSection = sectionOrder[nextIndex];
164
163
  setActiveSection(nextSection);
165
164
  return nextSection;
166
- }, [activeSection, sectionOrder]);
165
+ }, [activeSection, sectionOrder, setActiveSection]);
167
166
  var incrementSection = (0, _react.useCallback)(function (section, delta) {
168
167
  if (section === _utils.SECTION_PERIOD) {
169
168
  setSectionValue(section, sections.period === 'AM' ? 'PM' : 'AM');
@@ -200,7 +199,7 @@ var useSectionedTimeField = exports.useSectionedTimeField = function useSectione
200
199
  })) != null ? _descending$find : options[options.length - 1];
201
200
  }
202
201
  } else {
203
- var base = current === undefined ? minValue : current;
202
+ var base = current === undefined ? section === _utils.SECTION_HOUR ? (0, _utils.defaultHourForFormat)(format) : minValue : current;
204
203
  next = base + delta;
205
204
  if (next > maxValue) next = minValue;
206
205
  if (next < minValue) next = maxValue;
@@ -1,29 +1,33 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.sectionsToIsoTime = exports.sectionMin = exports.sectionMax = exports.sectionKey = exports.parseTime = exports.pad = exports.normalizeToIsoTime = exports.isoTimeToSections = exports.hasAnyValue = exports.getSectionName = exports.getSectionAriaMeta = exports.getRanges = exports.getActiveSectionAriaMeta = exports.formatTime = exports.defaultSections = exports.SECTION_SECOND = exports.SECTION_PERIOD = exports.SECTION_MINUTE = exports.SECTION_HOUR = exports.ISO_TIME_REGEX = void 0;
4
+ exports.sectionsToIsoTime = exports.sectionTypeFromSection = exports.sectionMin = exports.sectionMax = exports.sectionKey = exports.parseTime = exports.normalizeToIsoTime = exports.isoTimeToSections = exports.hasAnyValue = exports.getSectionName = exports.getSectionAriaMeta = exports.getRanges = exports.getActiveSectionAriaMeta = exports.formatTime = exports.defaultSections = exports.defaultHourForFormat = exports.SECTION_SECOND = exports.SECTION_PERIOD = exports.SECTION_MINUTE = exports.SECTION_HOUR = exports.ISO_TIME_REGEX = void 0;
5
+ var _sectionHelpers = require("../../utils/sectionHelpers");
6
+ var _dates = require("../../utils/dates");
7
+ exports.pad = _dates.pad;
8
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
9
+ // SPDX-License-Identifier: Apache-2.0
10
+
5
11
  var SECTION_HOUR = exports.SECTION_HOUR = 0;
6
12
  var SECTION_MINUTE = exports.SECTION_MINUTE = 1;
7
13
  var SECTION_SECOND = exports.SECTION_SECOND = 2;
8
14
  var SECTION_PERIOD = exports.SECTION_PERIOD = 3;
9
- var pad = exports.pad = function pad(value) {
10
- return value.toString().padStart(2, '0');
11
- };
12
- var sectionMessageId = function sectionMessageId(section) {
13
- if (section === SECTION_HOUR) return 'timeInput.sectionHours';
14
- if (section === SECTION_MINUTE) return 'timeInput.sectionMinutes';
15
- if (section === SECTION_SECOND) return 'timeInput.sectionSeconds';
16
- return 'timeInput.sectionMeridiem';
15
+ var sectionTypeFromSection = exports.sectionTypeFromSection = function sectionTypeFromSection(section) {
16
+ if (section === SECTION_HOUR) return 'hours';
17
+ if (section === SECTION_MINUTE) return 'minutes';
18
+ if (section === SECTION_SECOND) return 'seconds';
19
+ return 'meridiem';
17
20
  };
18
21
  var getSectionName = exports.getSectionName = function getSectionName(section, format, formatMessage, messages) {
19
- if (formatMessage) {
20
- return formatMessage({
21
- id: sectionMessageId(section),
22
- messages: messages
23
- });
24
- }
25
- var names = format === '12' ? ['hours', 'minutes', 'seconds', 'meridiem'] : ['hours', 'minutes', 'seconds'];
26
- return names[section];
22
+ var sectionType = sectionTypeFromSection(section);
23
+ var sectionName = (0, _sectionHelpers.getSectionNameFromType)({
24
+ sectionType: sectionType,
25
+ messagePrefix: 'timeInput',
26
+ formatMessage: formatMessage,
27
+ messages: messages
28
+ });
29
+ if (format !== '12' && sectionType === 'meridiem') return undefined;
30
+ return sectionName;
27
31
  };
28
32
  var getRanges = exports.getRanges = function getRanges(format) {
29
33
  if (format === '12') {
@@ -42,7 +46,7 @@ var normalizeToIsoTime = exports.normalizeToIsoTime = function normalizeToIsoTim
42
46
  if (ISO_TIME_REGEX.test(trimmed)) return trimmed;
43
47
  var parsed = new Date(trimmed);
44
48
  if (Number.isNaN(parsed.getTime())) return undefined;
45
- return pad(parsed.getHours()) + ":" + pad(parsed.getMinutes()) + ":" + pad(parsed.getSeconds());
49
+ return (0, _dates.pad)(parsed.getHours()) + ":" + (0, _dates.pad)(parsed.getMinutes()) + ":" + (0, _dates.pad)(parsed.getSeconds());
46
50
  };
47
51
 
48
52
  // Converts a canonical 24-hour ISO time string into the section shape the
@@ -81,7 +85,7 @@ var sectionsToIsoTime = exports.sectionsToIsoTime = function sectionsToIsoTime(s
81
85
  hour24 = sections.hour % 12;
82
86
  if (period === 'PM') hour24 += 12;
83
87
  }
84
- return pad(hour24) + ":" + pad(sections.minute) + ":" + pad(sections.second);
88
+ return (0, _dates.pad)(hour24) + ":" + (0, _dates.pad)(sections.minute) + ":" + (0, _dates.pad)(sections.second);
85
89
  };
86
90
  var parseTime = exports.parseTime = function parseTime(value, format) {
87
91
  if (!value || typeof value !== 'string') return undefined;
@@ -120,9 +124,9 @@ var parseTime = exports.parseTime = function parseTime(value, format) {
120
124
  var formatTime = exports.formatTime = function formatTime(time, format) {
121
125
  if (!time) return undefined;
122
126
  if (format === '12') {
123
- return pad(time.hour) + ":" + pad(time.minute) + ":" + pad(time.second) + " " + (time.period || 'AM');
127
+ return (0, _dates.pad)(time.hour) + ":" + (0, _dates.pad)(time.minute) + ":" + (0, _dates.pad)(time.second) + " " + (time.period || 'AM');
124
128
  }
125
- return pad(time.hour) + ":" + pad(time.minute) + ":" + pad(time.second);
129
+ return (0, _dates.pad)(time.hour) + ":" + (0, _dates.pad)(time.minute) + ":" + (0, _dates.pad)(time.second);
126
130
  };
127
131
  var defaultSections = exports.defaultSections = function defaultSections(format) {
128
132
  return format === '12' ? {
@@ -147,11 +151,12 @@ var sectionMin = exports.sectionMin = function sectionMin(section, format) {
147
151
  if (section === SECTION_HOUR) return format === '12' ? 1 : 0;
148
152
  return 0;
149
153
  };
154
+ var defaultHourForFormat = exports.defaultHourForFormat = function defaultHourForFormat(format) {
155
+ return format === '12' ? 12 : 0;
156
+ };
150
157
  var sectionKey = exports.sectionKey = function sectionKey(section) {
151
- if (section === SECTION_HOUR) return 'hour';
152
- if (section === SECTION_MINUTE) return 'minute';
153
- if (section === SECTION_SECOND) return 'second';
154
- return 'period';
158
+ var sectionType = sectionTypeFromSection(section);
159
+ return (0, _sectionHelpers.getSectionKeyFromType)(sectionType);
155
160
  };
156
161
  var getSectionAriaMeta = exports.getSectionAriaMeta = function getSectionAriaMeta(_ref) {
157
162
  var _sections$key;
@@ -168,7 +173,7 @@ var getSectionAriaMeta = exports.getSectionAriaMeta = function getSectionAriaMet
168
173
  var key = sectionKey(section);
169
174
  var min = sectionMin(section, format);
170
175
  var max = sectionMax(section, format);
171
- var now = (_sections$key = sections[key]) != null ? _sections$key : min;
176
+ var now = (_sections$key = sections[key]) != null ? _sections$key : section === SECTION_HOUR ? defaultHourForFormat(format) : min;
172
177
  return {
173
178
  now: now,
174
179
  min: min,