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.
Files changed (177) hide show
  1. package/components/Button/Button.js +7 -4
  2. package/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +86 -0
  3. package/components/Calendar/Calendar.js +24 -16
  4. package/components/Calendar/index.d.ts +1 -1
  5. package/components/Calendar/stories/CustomHeader.stories.js +6 -1
  6. package/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
  7. package/components/Calendar/stories/Dual.stories.js +23 -11
  8. package/components/Calendar/stories/HeaderLevel.stories.js +6 -1
  9. package/components/Calendar/stories/Multiple.stories.js +8 -3
  10. package/components/Calendar/stories/Simple.stories.js +6 -1
  11. package/components/Cards/Cards.js +164 -10
  12. package/components/Cards/StyledCellContainer.js +29 -0
  13. package/components/Cards/index.d.ts +4 -1
  14. package/components/Cards/propTypes.js +2 -0
  15. package/components/Cards/stories/Sizable.stories.js +70 -0
  16. package/components/Cards/stories/onOrder.stories.js +69 -0
  17. package/components/DataFilter/DataFilter.js +21 -28
  18. package/components/DateInput/DateInput.js +57 -24
  19. package/components/DateInput/index.d.ts +1 -0
  20. package/components/DateInput/utils.js +2 -2
  21. package/components/Drop/DropContainer.js +59 -3
  22. package/components/FileInput/FileInput.js +3 -0
  23. package/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
  24. package/components/Form/stories/FieldStates.stories.js +7 -1
  25. package/components/FormField/FormField.js +1 -1
  26. package/components/Grommet/Grommet.js +2 -1
  27. package/components/Grommet/index.d.ts +27 -0
  28. package/components/Grommet/propTypes.js +33 -1
  29. package/components/Layer/LayerContainer.d.ts +40 -0
  30. package/components/Select/stories/ChildrenRender.stories.js +28 -55
  31. package/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
  32. package/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
  33. package/components/Stepper/StepConnector.js +68 -0
  34. package/components/Stepper/Stepper.js +309 -0
  35. package/components/Stepper/StepperContext.js +43 -0
  36. package/components/Stepper/StepperDescription.js +26 -0
  37. package/components/Stepper/StepperHelperText.js +44 -0
  38. package/components/Stepper/StepperIndicator.js +74 -0
  39. package/components/Stepper/StepperLabel.js +41 -0
  40. package/components/Stepper/StepperStep.js +127 -0
  41. package/components/Stepper/StyledStepper.js +124 -0
  42. package/components/Stepper/index.d.ts +80 -0
  43. package/components/Stepper/index.js +18 -0
  44. package/components/Stepper/propTypes.js +35 -0
  45. package/components/Stepper/stories/DisabledSteps.stories.js +45 -0
  46. package/components/Stepper/stories/ErrorStates.stories.js +45 -0
  47. package/components/Stepper/stories/HorizontalSteps.stories.js +50 -0
  48. package/components/Stepper/stories/Interactive.stories.js +60 -0
  49. package/components/Stepper/stories/KeyboardNavigation.stories.js +64 -0
  50. package/components/Stepper/stories/NestedSubSteps.stories.js +70 -0
  51. package/components/Stepper/stories/ReadOnly.stories.js +43 -0
  52. package/components/Stepper/stories/ThemingLightDark.stories.js +58 -0
  53. package/components/Stepper/stories/VerticalSteps.stories.js +67 -0
  54. package/components/Tab/Tab.js +19 -6
  55. package/components/Tabs/Tabs.js +156 -22
  56. package/components/Tag/Tag.js +4 -3
  57. package/components/Tag/index.d.ts +5 -4
  58. package/components/Tag/propTypes.js +3 -2
  59. package/components/TextInput/StyledTextInput.js +4 -2
  60. package/components/TextInput/TextInput.js +1 -0
  61. package/components/TimeInput/README.md +2 -0
  62. package/components/TimeInput/StyledTimeInput.js +73 -0
  63. package/components/TimeInput/TimeInput.js +689 -0
  64. package/components/TimeInput/TimeInputPopup.js +393 -0
  65. package/components/TimeInput/index.d.ts +41 -0
  66. package/components/TimeInput/index.js +6 -0
  67. package/components/TimeInput/propTypes.js +35 -0
  68. package/components/TimeInput/stories/Controlled.stories.tsx +29 -0
  69. package/components/TimeInput/stories/Disabled.stories.tsx +13 -0
  70. package/components/TimeInput/stories/Form.stories.tsx +38 -0
  71. package/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
  72. package/components/TimeInput/stories/Simple.stories.tsx +19 -0
  73. package/components/TimeInput/stories/Step.stories.tsx +14 -0
  74. package/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
  75. package/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
  76. package/components/TimeInput/useSectionedTimeField.js +359 -0
  77. package/components/TimeInput/utils.js +187 -0
  78. package/components/index.d.ts +2 -0
  79. package/components/index.js +12 -0
  80. package/es6/components/Button/Button.js +7 -4
  81. package/es6/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +81 -0
  82. package/es6/components/Calendar/Calendar.js +24 -16
  83. package/es6/components/Calendar/index.d.ts +1 -1
  84. package/es6/components/Calendar/stories/CustomHeader.stories.js +6 -1
  85. package/es6/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
  86. package/es6/components/Calendar/stories/Dual.stories.js +23 -11
  87. package/es6/components/Calendar/stories/HeaderLevel.stories.js +6 -1
  88. package/es6/components/Calendar/stories/Multiple.stories.js +8 -3
  89. package/es6/components/Calendar/stories/Simple.stories.js +6 -1
  90. package/es6/components/Cards/Cards.js +165 -12
  91. package/es6/components/Cards/StyledCellContainer.js +24 -0
  92. package/es6/components/Cards/index.d.ts +4 -1
  93. package/es6/components/Cards/propTypes.js +2 -0
  94. package/es6/components/Cards/stories/Sizable.stories.js +65 -0
  95. package/es6/components/Cards/stories/onOrder.stories.js +64 -0
  96. package/es6/components/DataFilter/DataFilter.js +21 -28
  97. package/es6/components/DateInput/DateInput.js +57 -24
  98. package/es6/components/DateInput/index.d.ts +1 -0
  99. package/es6/components/DateInput/utils.js +2 -2
  100. package/es6/components/Drop/DropContainer.js +59 -3
  101. package/es6/components/FileInput/FileInput.js +3 -0
  102. package/es6/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
  103. package/es6/components/Form/stories/FieldStates.stories.js +7 -1
  104. package/es6/components/FormField/FormField.js +1 -1
  105. package/es6/components/Grommet/Grommet.js +2 -1
  106. package/es6/components/Grommet/index.d.ts +27 -0
  107. package/es6/components/Grommet/propTypes.js +33 -1
  108. package/es6/components/Layer/LayerContainer.d.ts +40 -0
  109. package/es6/components/Select/stories/ChildrenRender.stories.js +29 -56
  110. package/es6/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
  111. package/es6/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
  112. package/es6/components/Stepper/StepConnector.js +63 -0
  113. package/es6/components/Stepper/Stepper.js +306 -0
  114. package/es6/components/Stepper/StepperContext.js +39 -0
  115. package/es6/components/Stepper/StepperDescription.js +21 -0
  116. package/es6/components/Stepper/StepperHelperText.js +39 -0
  117. package/es6/components/Stepper/StepperIndicator.js +69 -0
  118. package/es6/components/Stepper/StepperLabel.js +36 -0
  119. package/es6/components/Stepper/StepperStep.js +122 -0
  120. package/es6/components/Stepper/StyledStepper.js +120 -0
  121. package/es6/components/Stepper/index.d.ts +80 -0
  122. package/es6/components/Stepper/index.js +6 -0
  123. package/es6/components/Stepper/propTypes.js +30 -0
  124. package/es6/components/Stepper/stories/DisabledSteps.stories.js +41 -0
  125. package/es6/components/Stepper/stories/ErrorStates.stories.js +41 -0
  126. package/es6/components/Stepper/stories/HorizontalSteps.stories.js +46 -0
  127. package/es6/components/Stepper/stories/Interactive.stories.js +56 -0
  128. package/es6/components/Stepper/stories/KeyboardNavigation.stories.js +60 -0
  129. package/es6/components/Stepper/stories/NestedSubSteps.stories.js +66 -0
  130. package/es6/components/Stepper/stories/ReadOnly.stories.js +39 -0
  131. package/es6/components/Stepper/stories/ThemingLightDark.stories.js +54 -0
  132. package/es6/components/Stepper/stories/VerticalSteps.stories.js +63 -0
  133. package/es6/components/Tab/Tab.js +19 -6
  134. package/es6/components/Tabs/Tabs.js +157 -23
  135. package/es6/components/Tag/Tag.js +4 -3
  136. package/es6/components/Tag/index.d.ts +5 -4
  137. package/es6/components/Tag/propTypes.js +3 -2
  138. package/es6/components/TextInput/StyledTextInput.js +4 -2
  139. package/es6/components/TextInput/TextInput.js +1 -0
  140. package/es6/components/TimeInput/README.md +2 -0
  141. package/es6/components/TimeInput/StyledTimeInput.js +68 -0
  142. package/es6/components/TimeInput/TimeInput.js +685 -0
  143. package/es6/components/TimeInput/TimeInputPopup.js +389 -0
  144. package/es6/components/TimeInput/index.d.ts +41 -0
  145. package/es6/components/TimeInput/index.js +1 -0
  146. package/es6/components/TimeInput/propTypes.js +30 -0
  147. package/es6/components/TimeInput/stories/Controlled.stories.tsx +29 -0
  148. package/es6/components/TimeInput/stories/Disabled.stories.tsx +13 -0
  149. package/es6/components/TimeInput/stories/Form.stories.tsx +38 -0
  150. package/es6/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
  151. package/es6/components/TimeInput/stories/Simple.stories.tsx +19 -0
  152. package/es6/components/TimeInput/stories/Step.stories.tsx +14 -0
  153. package/es6/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
  154. package/es6/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
  155. package/es6/components/TimeInput/useSectionedTimeField.js +356 -0
  156. package/es6/components/TimeInput/utils.js +183 -0
  157. package/es6/components/index.d.ts +2 -0
  158. package/es6/components/index.js +2 -0
  159. package/es6/index.d.ts +2 -0
  160. package/es6/languages/default.json +27 -1
  161. package/es6/themes/base.d.ts +109 -0
  162. package/es6/themes/base.js +208 -0
  163. package/es6/utils/index.d.ts +1 -0
  164. package/es6/utils/styles.js +23 -12
  165. package/grommet.min.js +1 -1
  166. package/grommet.min.js.map +1 -1
  167. package/index.d.ts +2 -0
  168. package/languages/default.json +27 -1
  169. package/package.json +51 -53
  170. package/themes/base.d.ts +109 -0
  171. package/themes/base.js +208 -0
  172. package/utils/index.d.ts +1 -0
  173. package/utils/styles.js +23 -12
  174. package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
  175. package/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -79
  176. package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
  177. package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -74
@@ -0,0 +1,359 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.useSectionedTimeField = void 0;
5
+ var _react = require("react");
6
+ 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
+ var separatorBeforeSection = function separatorBeforeSection(section) {
9
+ return section === _utils.SECTION_PERIOD ? ' ' : ':';
10
+ };
11
+ var sectionToken = function sectionToken(section) {
12
+ if (section === _utils.SECTION_HOUR) return 'hh';
13
+ if (section === _utils.SECTION_MINUTE) return 'mm';
14
+ if (section === _utils.SECTION_SECOND) return 'ss';
15
+ return 'aa';
16
+ };
17
+ var sectionPattern = function sectionPattern(section) {
18
+ if (section === _utils.SECTION_PERIOD) return '(AM|PM)';
19
+ return '(\\d{1,2})';
20
+ };
21
+ var isNumericSection = function isNumericSection(section) {
22
+ return section !== _utils.SECTION_PERIOD;
23
+ };
24
+ var parseSectionsValue = function parseSectionsValue(value, format, sectionOrder) {
25
+ if (!value || typeof value !== 'string') return undefined;
26
+ var normalized = value.trim().toUpperCase();
27
+ if (!normalized || !sectionOrder.length) return undefined;
28
+ var pattern = sectionOrder.map(function (section, index) {
29
+ var sectionRegex = sectionPattern(section);
30
+ if (index === 0) return sectionRegex;
31
+ return separatorBeforeSection(section) + "\\s*" + sectionRegex;
32
+ }).join('');
33
+ var regex = new RegExp("^" + pattern + "$");
34
+ var match = normalized.match(regex);
35
+ if (!match) return undefined;
36
+ var parsed = (0, _utils.defaultSections)(format);
37
+ sectionOrder.forEach(function (section, index) {
38
+ var key = (0, _utils.sectionKey)(section);
39
+ var captured = match[index + 1];
40
+ if (section === _utils.SECTION_PERIOD) {
41
+ parsed[key] = captured;
42
+ } else {
43
+ var next = Number(captured);
44
+ if (!Number.isNaN(next)) parsed[key] = next;
45
+ }
46
+ });
47
+ for (var i = 0; i < sectionOrder.length; i += 1) {
48
+ var section = sectionOrder[i];
49
+ if (isNumericSection(section)) {
50
+ var key = (0, _utils.sectionKey)(section);
51
+ var next = parsed[key];
52
+ if (next === undefined || next < (0, _utils.sectionMin)(section, format) || next > (0, _utils.sectionMax)(section, format)) {
53
+ return undefined;
54
+ }
55
+ }
56
+ }
57
+ return parsed;
58
+ };
59
+ var formatSectionsValue = function formatSectionsValue(_ref) {
60
+ var sections = _ref.sections,
61
+ sectionOrder = _ref.sectionOrder,
62
+ _ref$includeTokens = _ref.includeTokens,
63
+ includeTokens = _ref$includeTokens === void 0 ? false : _ref$includeTokens;
64
+ return sectionOrder.map(function (section, index) {
65
+ var key = (0, _utils.sectionKey)(section);
66
+ var rawValue = sections[key];
67
+ var rendered = rawValue === undefined ? includeTokens ? sectionToken(section) : '' : section === _utils.SECTION_PERIOD ? rawValue : (0, _utils.pad)(rawValue);
68
+ if (index === 0) return rendered;
69
+ return "" + separatorBeforeSection(section) + rendered;
70
+ }).join('');
71
+ };
72
+ var useSectionedTimeField = exports.useSectionedTimeField = function useSectionedTimeField(_ref2) {
73
+ var format = _ref2.format,
74
+ sectionOrder = _ref2.sectionOrder,
75
+ _ref2$minuteStep = _ref2.minuteStep,
76
+ minuteStep = _ref2$minuteStep === void 0 ? 1 : _ref2$minuteStep,
77
+ value = _ref2.value,
78
+ onCommit = _ref2.onCommit,
79
+ onInvalid = _ref2.onInvalid;
80
+ var editStateRef = (0, _react.useRef)({
81
+ section: _utils.SECTION_HOUR,
82
+ digits: 0,
83
+ previousValue: undefined,
84
+ firstDigit: undefined
85
+ });
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]);
112
+ var displayValue = (0, _react.useMemo)(function () {
113
+ if (!(0, _utils.hasAnyValue)(sections)) return '';
114
+
115
+ // Create a copy of sections with pending digits overlaid for display
116
+ var displaySections = _extends({}, sections);
117
+ var pendingSection = Object.keys(pendingDigits)[0];
118
+ if (pendingSection && pendingDigits[pendingSection] !== undefined) {
119
+ displaySections[pendingSection] = pendingDigits[pendingSection];
120
+ }
121
+ return formatSectionsValue({
122
+ sections: displaySections,
123
+ sectionOrder: sectionOrder,
124
+ includeTokens: true
125
+ });
126
+ }, [sectionOrder, sections, pendingDigits]);
127
+ var commitSections = (0, _react.useCallback)(function (nextSections) {
128
+ var _nextSections$second;
129
+ setSections(nextSections);
130
+ var complete = sectionOrder.every(function (section) {
131
+ return nextSections[(0, _utils.sectionKey)(section)] !== undefined;
132
+ });
133
+
134
+ // Check if all numeric sections are valid
135
+ var allValid = sectionOrder.every(function (section) {
136
+ if (!isNumericSection(section)) return true; // skip period
137
+ var key = (0, _utils.sectionKey)(section);
138
+ var sectionValue = nextSections[key];
139
+ var min = (0, _utils.sectionMin)(section, format);
140
+ var max = (0, _utils.sectionMax)(section, format);
141
+ return sectionValue >= min && sectionValue <= max;
142
+ });
143
+ var nextValue = complete && sectionOrder.length && allValid ? (0, _utils.sectionsToIsoTime)(_extends({}, nextSections, {
144
+ second: (_nextSections$second = nextSections.second) != null ? _nextSections$second : 0
145
+ }), format) : undefined;
146
+
147
+ // Mark as incomplete if: sections incomplete OR some invalid
148
+ var hasIncompleteSections = !complete || !allValid;
149
+ preserveIncompleteSectionsRef.current = hasIncompleteSections && (0, _utils.hasAnyValue)(nextSections);
150
+ onCommit(nextSections, nextValue);
151
+ }, [onCommit, sectionOrder, format]);
152
+ var setSectionValue = (0, _react.useCallback)(function (section, rawValue) {
153
+ var _extends2;
154
+ var key = (0, _utils.sectionKey)(section);
155
+ var next = _extends({}, sections, (_extends2 = {}, _extends2[key] = rawValue, _extends2));
156
+ commitSections(next);
157
+ }, [commitSections, sections]);
158
+ var moveSection = (0, _react.useCallback)(function (direction) {
159
+ if (!sectionOrder.length) return activeSection;
160
+ var activeIndex = Math.max(0, sectionOrder.indexOf(activeSection));
161
+ var count = sectionOrder.length;
162
+ var nextIndex = (activeIndex + direction + count) % count;
163
+ var nextSection = sectionOrder[nextIndex];
164
+ setActiveSection(nextSection);
165
+ return nextSection;
166
+ }, [activeSection, sectionOrder]);
167
+ var incrementSection = (0, _react.useCallback)(function (section, delta) {
168
+ if (section === _utils.SECTION_PERIOD) {
169
+ setSectionValue(section, sections.period === 'AM' ? 'PM' : 'AM');
170
+ return;
171
+ }
172
+ var minValue = (0, _utils.sectionMin)(section, format);
173
+ var maxValue = (0, _utils.sectionMax)(section, format);
174
+ var key = (0, _utils.sectionKey)(section);
175
+ var current = sections[key];
176
+ var step = section === _utils.SECTION_MINUTE ? minuteStep : section === _utils.SECTION_SECOND ? 1 : 1;
177
+ var next;
178
+ if (step > 1 && (section === _utils.SECTION_MINUTE || section === _utils.SECTION_SECOND)) {
179
+ var options = Array.from({
180
+ length: Math.ceil((maxValue - minValue + 1) / step)
181
+ }, function (_, index) {
182
+ return minValue + index * step;
183
+ }).filter(function (valueAtIndex) {
184
+ return valueAtIndex <= maxValue;
185
+ });
186
+ var currentIndex = options.indexOf(current);
187
+ if (currentIndex !== -1) {
188
+ var wrappedIndex = ((currentIndex + delta) % options.length + options.length) % options.length;
189
+ next = options[wrappedIndex];
190
+ } else if (delta > 0) {
191
+ var _options$find;
192
+ next = (_options$find = options.find(function (option) {
193
+ return option > (current != null ? current : minValue - 1);
194
+ })) != null ? _options$find : options[0];
195
+ } else {
196
+ var _descending$find;
197
+ var descending = [].concat(options).reverse();
198
+ next = (_descending$find = descending.find(function (option) {
199
+ return option < (current != null ? current : maxValue + 1);
200
+ })) != null ? _descending$find : options[options.length - 1];
201
+ }
202
+ } else {
203
+ var base = current === undefined ? minValue : current;
204
+ next = base + delta;
205
+ if (next > maxValue) next = minValue;
206
+ if (next < minValue) next = maxValue;
207
+ }
208
+ setSectionValue(section, next);
209
+ }, [format, minuteStep, sections, setSectionValue]);
210
+ var applyDigit = (0, _react.useCallback)(function (digit) {
211
+ if (activeSection === _utils.SECTION_PERIOD) return undefined;
212
+ var minValue = (0, _utils.sectionMin)(activeSection, format);
213
+ var maxValue = (0, _utils.sectionMax)(activeSection, format);
214
+ var key = (0, _utils.sectionKey)(activeSection);
215
+ var isSameSection = editStateRef.current.section === activeSection;
216
+ var isSecondDigit = isSameSection && editStateRef.current.digits === 1;
217
+ var currentRaw = sections[key] === undefined ? 0 : sections[key];
218
+ var nextValue;
219
+ if (isSecondDigit) {
220
+ var _editStateRef$current;
221
+ // Use the stored first digit from editState
222
+ var firstDigit = (_editStateRef$current = editStateRef.current.firstDigit) != null ? _editStateRef$current : currentRaw % 10;
223
+ nextValue = firstDigit * 10 + digit;
224
+ editStateRef.current = {
225
+ section: activeSection,
226
+ digits: 0,
227
+ previousValue: editStateRef.current.previousValue,
228
+ firstDigit: undefined
229
+ };
230
+ // Clear pending digits since we're committing now
231
+ setPendingDigits({});
232
+ } else {
233
+ var _setPendingDigits;
234
+ // First digit: store in pending for display only
235
+ nextValue = digit;
236
+ editStateRef.current = {
237
+ section: activeSection,
238
+ digits: 1,
239
+ previousValue: sections[key],
240
+ firstDigit: digit
241
+ };
242
+ // Show the first digit in pending state
243
+ setPendingDigits((_setPendingDigits = {}, _setPendingDigits[key] = digit, _setPendingDigits));
244
+ }
245
+
246
+ // For 2nd digit: validate combined value, but allow invalid 1st digit
247
+ // (allows "0X" patterns in formats where single "0" is invalid)
248
+ if (isSecondDigit && (nextValue < minValue || nextValue > maxValue)) {
249
+ var _editStateRef$current2;
250
+ // Combined value invalid. Try to use first digit for current section
251
+ // and apply second digit to next section (MUI behavior)
252
+ var _firstDigit = (_editStateRef$current2 = editStateRef.current.firstDigit) != null ? _editStateRef$current2 : currentRaw % 10;
253
+ if (_firstDigit >= minValue && _firstDigit <= maxValue) {
254
+ setSectionValue(activeSection, _firstDigit);
255
+
256
+ // Get next section and check if second digit is valid there
257
+ var currentSectionIndex = sectionOrder.indexOf(activeSection);
258
+ var nextSection = sectionOrder[currentSectionIndex + 1];
259
+ if (nextSection && isNumericSection(nextSection)) {
260
+ var nextMinValue = (0, _utils.sectionMin)(nextSection, format);
261
+ var nextMaxValue = (0, _utils.sectionMax)(nextSection, format);
262
+
263
+ // If second digit is valid for next section, apply it there
264
+ if (digit >= nextMinValue && digit <= nextMaxValue) {
265
+ setSectionValue(nextSection, digit);
266
+ // Now move to section after that
267
+ return moveSection(2);
268
+ }
269
+ }
270
+
271
+ // If second digit not valid for next section, just move to next
272
+ return moveSection(1);
273
+ }
274
+
275
+ // If even first digit alone is invalid, reject the entry
276
+ onInvalid == null || onInvalid();
277
+ setPendingDigits({});
278
+ return undefined;
279
+ }
280
+
281
+ // MUI Pattern: Determine if we should commit and move to next section
282
+ // shouldGoToNextSection = nextValue * 10 > max || digitCount === 2
283
+ var shouldMoveToNextSection = nextValue * 10 > maxValue || isSecondDigit;
284
+ setSectionValue(activeSection, nextValue);
285
+ if (shouldMoveToNextSection) {
286
+ // Don't move past the last section during digit entry
287
+ // (Tab navigation can still wrap, but digit entry stops at last
288
+ // section)
289
+ var currentIndex = sectionOrder.indexOf(activeSection);
290
+ var isLastSection = currentIndex === sectionOrder.length - 1;
291
+ if (!isLastSection) {
292
+ return moveSection(1);
293
+ }
294
+ }
295
+ return activeSection;
296
+ }, [activeSection, format, moveSection, onInvalid, sections, setSectionValue, setPendingDigits, sectionOrder]);
297
+ var clearActiveSection = (0, _react.useCallback)(function () {
298
+ setSectionValue(activeSection, undefined);
299
+ }, [activeSection, setSectionValue]);
300
+ var parsePasted = (0, _react.useCallback)(function (pasted) {
301
+ var parsed = parseSectionsValue(pasted, format, sectionOrder);
302
+ if (parsed) {
303
+ return parsed;
304
+ }
305
+ var digits = pasted.replace(/\D/g, '');
306
+ var numericSections = sectionOrder.filter(function (section) {
307
+ return section !== _utils.SECTION_PERIOD;
308
+ });
309
+ var hasExplicitPeriod = /\b(AM|PM)\b/i.test(pasted);
310
+ var shouldInferPeriod = format === '12' && sectionOrder.includes(_utils.SECTION_PERIOD) && !hasExplicitPeriod;
311
+ if (digits.length >= numericSections.length * 2 && numericSections.length) {
312
+ var next = _extends({}, sections);
313
+ for (var i = 0; i < numericSections.length; i += 1) {
314
+ var section = numericSections[i];
315
+ var parsedNumber = Number(digits.slice(i * 2, i * 2 + 2));
316
+ var minValue = section === _utils.SECTION_HOUR && shouldInferPeriod ? 0 : (0, _utils.sectionMin)(section, format);
317
+ var maxValue = section === _utils.SECTION_HOUR && shouldInferPeriod ? 23 : (0, _utils.sectionMax)(section, format);
318
+ if (Number.isNaN(parsedNumber) || parsedNumber < minValue || parsedNumber > maxValue) {
319
+ return undefined;
320
+ }
321
+ next[(0, _utils.sectionKey)(section)] = parsedNumber;
322
+ }
323
+ if (sectionOrder.includes(_utils.SECTION_PERIOD)) {
324
+ if (hasExplicitPeriod) {
325
+ next.period = /\bPM\b/i.test(pasted) ? 'PM' : 'AM';
326
+ } else if (shouldInferPeriod) {
327
+ var normalizedHour = next.hour;
328
+ if (normalizedHour === 0) {
329
+ next.hour = 12;
330
+ next.period = 'AM';
331
+ } else if (normalizedHour === 12) {
332
+ next.period = 'PM';
333
+ } else if (normalizedHour > 12) {
334
+ next.hour = normalizedHour - 12;
335
+ next.period = 'PM';
336
+ } else {
337
+ next.period = 'AM';
338
+ }
339
+ }
340
+ }
341
+ return next;
342
+ }
343
+ return undefined;
344
+ }, [format, sectionOrder, sections]);
345
+ return {
346
+ activeSection: activeSection,
347
+ clearActiveSection: clearActiveSection,
348
+ displayValue: displayValue,
349
+ incrementSection: incrementSection,
350
+ moveSection: moveSection,
351
+ parsePasted: parsePasted,
352
+ sections: sections,
353
+ setActiveSection: setActiveSection,
354
+ setSectionValue: setSectionValue,
355
+ applyDigit: applyDigit,
356
+ commitSections: commitSections,
357
+ pendingDigits: pendingDigits
358
+ };
359
+ };
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+
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;
5
+ var SECTION_HOUR = exports.SECTION_HOUR = 0;
6
+ var SECTION_MINUTE = exports.SECTION_MINUTE = 1;
7
+ var SECTION_SECOND = exports.SECTION_SECOND = 2;
8
+ 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';
17
+ };
18
+ 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];
27
+ };
28
+ var getRanges = exports.getRanges = function getRanges(format) {
29
+ if (format === '12') {
30
+ return [[0, 2], [3, 5], [6, 8], [9, 11]];
31
+ }
32
+ return [[0, 2], [3, 5], [6, 8]];
33
+ };
34
+
35
+ // TimeInput always transacts (value/defaultValue/onChange) in a canonical
36
+ // 24-hour ISO time string ("HH:MM:SS"), regardless of the display `format`
37
+ // prop.
38
+ var ISO_TIME_REGEX = exports.ISO_TIME_REGEX = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/;
39
+ var normalizeToIsoTime = exports.normalizeToIsoTime = function normalizeToIsoTime(value) {
40
+ if (typeof value !== 'string' || !value.trim()) return undefined;
41
+ var trimmed = value.trim();
42
+ if (ISO_TIME_REGEX.test(trimmed)) return trimmed;
43
+ var parsed = new Date(trimmed);
44
+ if (Number.isNaN(parsed.getTime())) return undefined;
45
+ return pad(parsed.getHours()) + ":" + pad(parsed.getMinutes()) + ":" + pad(parsed.getSeconds());
46
+ };
47
+
48
+ // Converts a canonical 24-hour ISO time string into the section shape the
49
+ // sectioned editor uses for display, deriving 12-hour + period fields when
50
+ // needed.
51
+ var isoTimeToSections = exports.isoTimeToSections = function isoTimeToSections(isoTime, format) {
52
+ if (typeof isoTime !== 'string') return undefined;
53
+ var match = isoTime.match(ISO_TIME_REGEX);
54
+ if (!match) return undefined;
55
+ var hour24 = Number(match[1]);
56
+ var minute = Number(match[2]);
57
+ var second = Number(match[3]);
58
+ if (format === '12') {
59
+ var period = hour24 < 12 ? 'AM' : 'PM';
60
+ var hour = hour24 % 12 || 12;
61
+ return {
62
+ hour: hour,
63
+ minute: minute,
64
+ second: second,
65
+ period: period
66
+ };
67
+ }
68
+ return {
69
+ hour: hour24,
70
+ minute: minute,
71
+ second: second
72
+ };
73
+ };
74
+ var sectionsToIsoTime = exports.sectionsToIsoTime = function sectionsToIsoTime(sections, format) {
75
+ if (sections.hour === undefined || sections.minute === undefined || sections.second === undefined) {
76
+ return undefined;
77
+ }
78
+ var hour24 = sections.hour;
79
+ if (format === '12') {
80
+ var period = sections.period || 'AM';
81
+ hour24 = sections.hour % 12;
82
+ if (period === 'PM') hour24 += 12;
83
+ }
84
+ return pad(hour24) + ":" + pad(sections.minute) + ":" + pad(sections.second);
85
+ };
86
+ var parseTime = exports.parseTime = function parseTime(value, format) {
87
+ if (!value || typeof value !== 'string') return undefined;
88
+ var trimmed = value.trim().toUpperCase();
89
+ if (format === '12') {
90
+ var _match = trimmed.match(/^(\d{1,2}):(\d{2}):(\d{2})\s*(AM|PM)$/);
91
+ if (!_match) return undefined;
92
+ var _hour = Number(_match[1]);
93
+ var _minute = Number(_match[2]);
94
+ var _second = Number(_match[3]);
95
+ var period = _match[4];
96
+ if (Number.isNaN(_hour) || Number.isNaN(_minute) || Number.isNaN(_second) || _hour < 1 || _hour > 12 || _minute < 0 || _minute > 59 || _second < 0 || _second > 59) {
97
+ return undefined;
98
+ }
99
+ return {
100
+ hour: _hour,
101
+ minute: _minute,
102
+ second: _second,
103
+ period: period
104
+ };
105
+ }
106
+ var match = trimmed.match(/^(\d{1,2}):(\d{2}):(\d{2})$/);
107
+ if (!match) return undefined;
108
+ var hour = Number(match[1]);
109
+ var minute = Number(match[2]);
110
+ var second = Number(match[3]);
111
+ if (Number.isNaN(hour) || Number.isNaN(minute) || Number.isNaN(second) || hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {
112
+ return undefined;
113
+ }
114
+ return {
115
+ hour: hour,
116
+ minute: minute,
117
+ second: second
118
+ };
119
+ };
120
+ var formatTime = exports.formatTime = function formatTime(time, format) {
121
+ if (!time) return undefined;
122
+ if (format === '12') {
123
+ return pad(time.hour) + ":" + pad(time.minute) + ":" + pad(time.second) + " " + (time.period || 'AM');
124
+ }
125
+ return pad(time.hour) + ":" + pad(time.minute) + ":" + pad(time.second);
126
+ };
127
+ var defaultSections = exports.defaultSections = function defaultSections(format) {
128
+ return format === '12' ? {
129
+ hour: undefined,
130
+ minute: undefined,
131
+ second: undefined,
132
+ period: undefined
133
+ } : {
134
+ hour: undefined,
135
+ minute: undefined,
136
+ second: undefined
137
+ };
138
+ };
139
+ var hasAnyValue = exports.hasAnyValue = function hasAnyValue(sections) {
140
+ return sections.hour !== undefined || sections.minute !== undefined || sections.second !== undefined || sections.period !== undefined;
141
+ };
142
+ var sectionMax = exports.sectionMax = function sectionMax(section, format) {
143
+ if (section === SECTION_HOUR) return format === '12' ? 12 : 23;
144
+ return 59;
145
+ };
146
+ var sectionMin = exports.sectionMin = function sectionMin(section, format) {
147
+ if (section === SECTION_HOUR) return format === '12' ? 1 : 0;
148
+ return 0;
149
+ };
150
+ 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';
155
+ };
156
+ var getSectionAriaMeta = exports.getSectionAriaMeta = function getSectionAriaMeta(_ref) {
157
+ var _sections$key;
158
+ var section = _ref.section,
159
+ format = _ref.format,
160
+ sections = _ref.sections;
161
+ if (section === SECTION_PERIOD) {
162
+ return {
163
+ now: sections.period === 'PM' ? 1 : 0,
164
+ min: 0,
165
+ max: 1
166
+ };
167
+ }
168
+ var key = sectionKey(section);
169
+ var min = sectionMin(section, format);
170
+ var max = sectionMax(section, format);
171
+ var now = (_sections$key = sections[key]) != null ? _sections$key : min;
172
+ return {
173
+ now: now,
174
+ min: min,
175
+ max: max
176
+ };
177
+ };
178
+ var getActiveSectionAriaMeta = exports.getActiveSectionAriaMeta = function getActiveSectionAriaMeta(_ref2) {
179
+ var activeSection = _ref2.activeSection,
180
+ format = _ref2.format,
181
+ sections = _ref2.sections;
182
+ return getSectionAriaMeta({
183
+ section: activeSection,
184
+ format: format,
185
+ sections: sections
186
+ });
187
+ };
@@ -75,6 +75,7 @@ export * from './SkipLinkTarget';
75
75
  export * from './Spinner';
76
76
  export * from './Stack';
77
77
  export * from './StarRating';
78
+ export * from './Stepper';
78
79
  export * from './Table';
79
80
  export * from './TableBody';
80
81
  export * from './TableCell';
@@ -87,6 +88,7 @@ export * from './Tag';
87
88
  export * from './Text';
88
89
  export * from './TextArea';
89
90
  export * from './TextInput';
91
+ export * from './TimeInput';
90
92
  export * from './ThumbsRating';
91
93
  export * from './Tip';
92
94
  export * from './ToggleGroup';
@@ -469,6 +469,12 @@ Object.keys(_StarRating).forEach(function (key) {
469
469
  if (key in exports && exports[key] === _StarRating[key]) return;
470
470
  exports[key] = _StarRating[key];
471
471
  });
472
+ var _Stepper = require("./Stepper");
473
+ Object.keys(_Stepper).forEach(function (key) {
474
+ if (key === "default" || key === "__esModule") return;
475
+ if (key in exports && exports[key] === _Stepper[key]) return;
476
+ exports[key] = _Stepper[key];
477
+ });
472
478
  var _Table = require("./Table");
473
479
  Object.keys(_Table).forEach(function (key) {
474
480
  if (key === "default" || key === "__esModule") return;
@@ -541,6 +547,12 @@ Object.keys(_TextInput).forEach(function (key) {
541
547
  if (key in exports && exports[key] === _TextInput[key]) return;
542
548
  exports[key] = _TextInput[key];
543
549
  });
550
+ var _TimeInput = require("./TimeInput");
551
+ Object.keys(_TimeInput).forEach(function (key) {
552
+ if (key === "default" || key === "__esModule") return;
553
+ if (key in exports && exports[key] === _TimeInput[key]) return;
554
+ exports[key] = _TimeInput[key];
555
+ });
544
556
  var _Tip = require("./Tip");
545
557
  Object.keys(_Tip).forEach(function (key) {
546
558
  if (key === "default" || key === "__esModule") return;
@@ -7,6 +7,7 @@ import { backgroundAndTextColors, colorIsDark, findButtonParent, useSizedIcon, n
7
7
  import { ButtonPropTypes } from './propTypes';
8
8
  import { AnnounceContext } from '../../contexts/AnnounceContext';
9
9
  import { MessageContext } from '../../contexts/MessageContext';
10
+ import { OptionsContext } from '../../contexts/OptionsContext';
10
11
  import { Box } from '../Box';
11
12
  import { Tip } from '../Tip';
12
13
  import { Badge } from './Badge';
@@ -182,6 +183,8 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
182
183
  var _useThemeValue = useThemeValue(),
183
184
  theme = _useThemeValue.theme,
184
185
  passThemeFlag = _useThemeValue.passThemeFlag;
186
+ var _useContext = useContext(OptionsContext),
187
+ buttonOptions = _useContext.button;
185
188
  var _useState = useState(),
186
189
  focus = _useState[0],
187
190
  setFocus = _useState[1];
@@ -189,8 +192,8 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
189
192
  hover = _useState2[0],
190
193
  setHover = _useState2[1];
191
194
  var announce = useContext(AnnounceContext);
192
- var _useContext = useContext(MessageContext),
193
- format = _useContext.format;
195
+ var _useContext2 = useContext(MessageContext),
196
+ format = _useContext2.format;
194
197
  if (busy && success) {
195
198
  console.warn('Button cannot have both busy and success set to true.');
196
199
  }
@@ -435,7 +438,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
435
438
  onMouseOver: onMouseOverButton,
436
439
  onMouseOut: onMouseOutButton,
437
440
  pad: pad,
438
- plain: plain || Children.count(children) > 0,
441
+ plain: plain || (buttonOptions == null ? void 0 : buttonOptions.childrenPlain) !== false && Children.count(children) > 0,
439
442
  primary: primary,
440
443
  selected: selected,
441
444
  sizeProp: size,
@@ -473,7 +476,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
473
476
  onMouseOver: onMouseOverButton,
474
477
  onMouseOut: onMouseOutButton,
475
478
  pad: pad || !plain,
476
- plain: typeof plain !== 'undefined' ? plain : Children.count(children) > 0 || icon && !label,
479
+ plain: typeof plain !== 'undefined' ? plain : (buttonOptions == null ? void 0 : buttonOptions.childrenPlain) !== false && Children.count(children) > 0 || icon && !label,
477
480
  primary: primary,
478
481
  sizeProp: size,
479
482
  success: success,