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
@@ -19,6 +19,7 @@ export interface DateInputProps {
19
19
  messages?: {
20
20
  enterCalendar?: string;
21
21
  exitCalendar?: string;
22
+ outOfBounds?: string;
22
23
  };
23
24
  name?: string;
24
25
  onChange?: (event: { value: string | string[] }) => void;
@@ -122,7 +122,7 @@ var pullDigits = function pullDigits(text, index) {
122
122
  return text.slice(index, end);
123
123
  };
124
124
  var validateBounds = exports.validateBounds = function validateBounds(dateBounds, selectedDate) {
125
- if (!dateBounds || !selectedDate) return selectedDate;
125
+ if (!dateBounds || !selectedDate) return true;
126
126
  var _dateBounds$map = dateBounds.map(function (date) {
127
127
  return (0, _utils.setHoursWithOffset)(date).toISOString();
128
128
  }),
@@ -134,7 +134,7 @@ var validateBounds = exports.validateBounds = function validateBounds(dateBounds
134
134
  var validSelection = isoSelectedDates.every(function (isoSelectedDate) {
135
135
  return !endDate && startDate === isoSelectedDate || isoSelectedDate >= startDate && isoSelectedDate <= endDate;
136
136
  });
137
- return validSelection ? selectedDate : undefined;
137
+ return validSelection;
138
138
  };
139
139
  var textToValue = exports.textToValue = function textToValue(text, schema, range, reference, outputFormat) {
140
140
  if (!text) return range ? [] : undefined;
@@ -178,9 +178,10 @@ var DropContainer = exports.DropContainer = /*#__PURE__*/(0, _react.forwardRef)(
178
178
 
179
179
  /* If responsive is true and the Drop doesn't have enough room
180
180
  to be fully visible and there is more room in the other
181
- direction, change the Drop to display above/below. If there is
182
- less room in the other direction leave the Drop in its current
183
- position. */
181
+ direction, change the Drop to display above/below. If neither
182
+ direction has enough room for the full Drop, prefer the side
183
+ with more available space rather than clamping to the side
184
+ originally requested. */
184
185
  if (responsive &&
185
186
  // drop is above target
186
187
  align.bottom === 'top' &&
@@ -225,6 +226,61 @@ var DropContainer = exports.DropContainer = /*#__PURE__*/(0, _react.forwardRef)(
225
226
  // top of drop is aligned to top of target
226
227
  top = targetRect.top;
227
228
  maxHeight = bottom;
229
+ } else if (responsive &&
230
+ // top of drop is aligned to bottom of target (open below)
231
+ align.top === 'bottom' &&
232
+ // drop is overflowing below window
233
+ targetRect.bottom + containerRect.height >= windowHeight &&
234
+ // the flip anchor (target's top) is on-screen — otherwise
235
+ // flipping pins the drop's bottom off-screen
236
+ targetRect.top > 0 &&
237
+ // there is more room above the target than below it — neither
238
+ // side fits the full drop, so prefer the larger side rather
239
+ // than clamping to the smaller requested side.
240
+ targetRect.top > windowHeight - targetRect.bottom) {
241
+ // bottom of drop is aligned to top of target
242
+ bottom = targetRect.top;
243
+ maxHeight = bottom;
244
+ } else if (responsive &&
245
+ // top of drop is aligned to top of target (open below)
246
+ align.top === 'top' &&
247
+ // drop is overflowing below window
248
+ targetRect.top + containerRect.height >= windowHeight &&
249
+ // height of the drop is larger than the target — otherwise the
250
+ // drop already fits inside the target's vertical span and a
251
+ // flip would pin its bottom to a potentially off-screen
252
+ // target.bottom (mirrors the safety in branch #2 above).
253
+ targetRect.top + containerRect.height > targetRect.bottom &&
254
+ // there is more room above the target than below it
255
+ targetRect.bottom > windowHeight - targetRect.top) {
256
+ // bottom of drop is aligned to bottom of target
257
+ bottom = targetRect.bottom;
258
+ maxHeight = bottom;
259
+ } else if (responsive &&
260
+ // bottom of drop is aligned to top of target (open above)
261
+ align.bottom === 'top' &&
262
+ // drop is overflowing above window
263
+ targetRect.top - containerRect.height <= 0 &&
264
+ // the flip anchor (target's bottom) is on-screen
265
+ targetRect.bottom < windowHeight &&
266
+ // there is more room below the target than above it
267
+ windowHeight - targetRect.bottom > targetRect.top) {
268
+ // top of drop is aligned to bottom of target
269
+ top = targetRect.bottom;
270
+ maxHeight = windowHeight - top;
271
+ } else if (responsive &&
272
+ // bottom of drop is aligned to bottom of target (open above)
273
+ align.bottom === 'bottom' &&
274
+ // drop is overflowing above window
275
+ targetRect.bottom - containerRect.height <= 0 &&
276
+ // height of the drop is larger than the target (mirrors the
277
+ // safety in branch #4 above)
278
+ targetRect.bottom - containerRect.height < targetRect.top &&
279
+ // there is more room below the target than above it
280
+ windowHeight - targetRect.top > targetRect.bottom) {
281
+ // top of drop is aligned to top of target
282
+ top = targetRect.top;
283
+ maxHeight = windowHeight - top;
228
284
  } else if (align.top === 'top') {
229
285
  top = targetRect.top;
230
286
  maxHeight = windowHeight - top;
@@ -293,6 +293,9 @@ var FileInput = exports.FileInput = /*#__PURE__*/(0, _react.forwardRef)(function
293
293
  onChange: function onChange(event) {
294
294
  event.persist();
295
295
  var fileList = event.target.files;
296
+ // If the user cancelled the file picker, fileList will be empty
297
+ // and we should not clear any previously selected files.
298
+ if (!fileList.length && files.length) return;
296
299
  var nextFiles = multiple ? [].concat(files) : [];
297
300
  var _loop = function _loop(i) {
298
301
  // avoid duplicates
@@ -67,7 +67,13 @@ var customTheme = (0, _utils.deepMerge)(_grommet.grommet, {
67
67
  var FieldCustomStates = exports.FieldCustomStates = function FieldCustomStates() {
68
68
  var inputRef = (0, _react.useRef)();
69
69
  (0, _react.useEffect)(function () {
70
- inputRef.current.focus();
70
+ var focusTimeout = setTimeout(function () {
71
+ var _inputRef$current;
72
+ (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
73
+ });
74
+ return function () {
75
+ return clearTimeout(focusTimeout);
76
+ };
71
77
  }, []);
72
78
  return /*#__PURE__*/_react["default"].createElement(_grommet.Grommet, {
73
79
  theme: customTheme
@@ -8,7 +8,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
8
8
  var FieldStates = exports.FieldStates = function FieldStates() {
9
9
  var inputRef = (0, _react.useRef)();
10
10
  (0, _react.useEffect)(function () {
11
- inputRef.current.focus();
11
+ var focusTimeout = setTimeout(function () {
12
+ var _inputRef$current;
13
+ (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
14
+ });
15
+ return function () {
16
+ return clearTimeout(focusTimeout);
17
+ };
12
18
  }, []);
13
19
  return (
14
20
  /*#__PURE__*/
@@ -27,7 +27,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
27
27
  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); }
28
28
  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; }
29
29
  var grommetInputFocusNames = ['CheckBox', 'CheckBoxGroup', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
30
- var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'SelectMultiple', 'TextArea', 'DateInput', 'FileInput', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
30
+ var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'SelectMultiple', 'TextArea', 'DateInput', 'TimeInput', 'FileInput', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
31
31
  var grommetInputPadNames = ['CheckBox', 'CheckBoxGroup', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector'];
32
32
  var isGrommetInput = function isGrommetInput(comp) {
33
33
  return comp && (grommetInputNames.indexOf(comp.displayName) !== -1 || grommetInputPadNames.indexOf(comp.displayName) !== -1);
@@ -79,7 +79,8 @@ var Grommet = exports.Grommet = /*#__PURE__*/(0, _react.forwardRef)(function (pr
79
79
  }, [messagesProp]);
80
80
  (0, _react.useEffect)(function () {
81
81
  var onResize = function onResize() {
82
- setResponsive((0, _utils.getBreakpoint)(document.body.clientWidth, theme));
82
+ var _document$body$client, _document$body;
83
+ setResponsive((0, _utils.getBreakpoint)((_document$body$client = (_document$body = document.body) == null ? void 0 : _document$body.clientWidth) != null ? _document$body$client : window.innerWidth, theme));
83
84
  };
84
85
  window.addEventListener('resize', onResize);
85
86
  onResize();
@@ -9,6 +9,7 @@ export interface GrommetProps {
9
9
  dir?: 'rtl';
10
10
  full?: boolean | 'min';
11
11
  options?: {
12
+ button?: { childrenPlain?: boolean };
12
13
  box?: {
13
14
  cssGap?: boolean;
14
15
  };
@@ -31,6 +32,11 @@ export interface GrommetProps {
31
32
  nextMove?: string;
32
33
  next?: string;
33
34
  };
35
+ cards?: {
36
+ moved?: string;
37
+ reorderHint?: string;
38
+ description?: string;
39
+ };
34
40
  carousel?: {
35
41
  previous?: string;
36
42
  next?: string;
@@ -40,6 +46,7 @@ export interface GrommetProps {
40
46
  openCalendar?: string;
41
47
  enterCalendar?: string;
42
48
  exitCalendar?: string;
49
+ outOfBounds?: string;
43
50
  };
44
51
  dataChart?: {
45
52
  detailTitle?: string;
@@ -213,9 +220,29 @@ export interface GrommetProps {
213
220
  skipLinks?: {
214
221
  skipTo?: string;
215
222
  };
223
+ stepper?: {
224
+ progress?: string;
225
+ step?: string;
226
+ };
216
227
  tabs?: {
228
+ nextTab?: string;
229
+ previousTab?: string;
217
230
  tabContents?: string;
218
231
  };
232
+ timeInput?: {
233
+ activePeriodValue?: string;
234
+ activeSection?: string;
235
+ activeSectionValue?: string;
236
+ chooseTime?: string;
237
+ currentValue?: string;
238
+ inputLabel?: string;
239
+ invalidTime?: string;
240
+ openDrop?: string;
241
+ sectionHours?: string;
242
+ sectionMeridiem?: string;
243
+ sectionMinutes?: string;
244
+ sectionSeconds?: string;
245
+ };
219
246
  textInput?: {
220
247
  enterSelect?: string;
221
248
  suggestionsCount?: string;
@@ -12,6 +12,12 @@ if (process.env.NODE_ENV !== 'production') {
12
12
  dir: _propTypes["default"].oneOf(['rtl']),
13
13
  full: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].oneOf(['min'])]),
14
14
  options: _propTypes["default"].shape({
15
+ box: _propTypes["default"].shape({
16
+ cssGap: _propTypes["default"].bool
17
+ }),
18
+ button: _propTypes["default"].shape({
19
+ childrenPlain: _propTypes["default"].bool
20
+ }),
15
21
  layer: _propTypes["default"].shape({
16
22
  singleId: _propTypes["default"].bool
17
23
  }),
@@ -38,6 +44,11 @@ if (process.env.NODE_ENV !== 'production') {
38
44
  nextMove: _propTypes["default"].string,
39
45
  next: _propTypes["default"].string
40
46
  }),
47
+ cards: _propTypes["default"].shape({
48
+ moved: _propTypes["default"].string,
49
+ reorderHint: _propTypes["default"].string,
50
+ description: _propTypes["default"].string
51
+ }),
41
52
  carousel: _propTypes["default"].shape({
42
53
  previous: _propTypes["default"].string,
43
54
  next: _propTypes["default"].string,
@@ -46,7 +57,8 @@ if (process.env.NODE_ENV !== 'production') {
46
57
  dateInput: _propTypes["default"].shape({
47
58
  openCalendar: _propTypes["default"].string,
48
59
  enterCalendar: _propTypes["default"].string,
49
- exitCalendar: _propTypes["default"].string
60
+ exitCalendar: _propTypes["default"].string,
61
+ outOfBounds: _propTypes["default"].string
50
62
  }),
51
63
  dataChart: _propTypes["default"].shape({
52
64
  detailTitle: _propTypes["default"].string,
@@ -214,7 +226,13 @@ if (process.env.NODE_ENV !== 'production') {
214
226
  skipLinks: _propTypes["default"].shape({
215
227
  skipTo: _propTypes["default"].string
216
228
  }),
229
+ stepper: _propTypes["default"].shape({
230
+ progress: _propTypes["default"].string,
231
+ step: _propTypes["default"].string
232
+ }),
217
233
  tabs: _propTypes["default"].shape({
234
+ nextTab: _propTypes["default"].string,
235
+ previousTab: _propTypes["default"].string,
218
236
  tabContents: _propTypes["default"].string
219
237
  }),
220
238
  tag: _propTypes["default"].shape({
@@ -229,6 +247,20 @@ if (process.env.NODE_ENV !== 'production') {
229
247
  suggestionsExist: _propTypes["default"].string,
230
248
  suggestionIsOpen: _propTypes["default"].string
231
249
  }),
250
+ timeInput: _propTypes["default"].shape({
251
+ activePeriodValue: _propTypes["default"].string,
252
+ activeSection: _propTypes["default"].string,
253
+ activeSectionValue: _propTypes["default"].string,
254
+ chooseTime: _propTypes["default"].string,
255
+ currentValue: _propTypes["default"].string,
256
+ inputLabel: _propTypes["default"].string,
257
+ invalidTime: _propTypes["default"].string,
258
+ openDrop: _propTypes["default"].string,
259
+ sectionHours: _propTypes["default"].string,
260
+ sectionMeridiem: _propTypes["default"].string,
261
+ sectionMinutes: _propTypes["default"].string,
262
+ sectionSeconds: _propTypes["default"].string
263
+ }),
232
264
  video: _propTypes["default"].shape({
233
265
  audioDescriptions: _propTypes["default"].string,
234
266
  captions: _propTypes["default"].string,
@@ -0,0 +1,40 @@
1
+ import {
2
+ AnimateType,
3
+ BackgroundType,
4
+ KeyboardType,
5
+ MarginType,
6
+ } from 'grommet/utils';
7
+ import * as React from 'react';
8
+ import { LayerPositionType } from '.';
9
+
10
+ interface LayerContainerProps {
11
+ animate?: AnimateType;
12
+ animation?: 'none' | 'slide' | 'fadeIn' | boolean;
13
+ background?: BackgroundType;
14
+ children?: React.ReactNode;
15
+ full?: boolean | 'vertical' | 'horizontal';
16
+ id?: string;
17
+ margin?: MarginType;
18
+ modal?: boolean;
19
+ onClickOutside?: (
20
+ event: React.MouseEvent<HTMLDivElement, MouseEvent>,
21
+ ) => void;
22
+ onEsc?: KeyboardType;
23
+ plain?: boolean;
24
+ position?: LayerPositionType;
25
+ responsive?: boolean;
26
+ target?: object;
27
+ }
28
+
29
+ type divProps = React.DetailedHTMLProps<
30
+ React.HTMLAttributes<HTMLDivElement>,
31
+ HTMLDivElement
32
+ >;
33
+
34
+ interface LayerContainerExtendedProps extends LayerContainerProps, divProps {}
35
+
36
+ declare const LayerContainer: React.ForwardRefExoticComponent<
37
+ LayerContainerExtendedProps & React.RefAttributes<HTMLDivElement>
38
+ >;
39
+
40
+ export { LayerContainer };
@@ -3,7 +3,6 @@
3
3
  exports.__esModule = true;
4
4
  exports["default"] = exports.Children = void 0;
5
5
  var _react = _interopRequireWildcard(require("react"));
6
- var _grommetIcons = require("grommet-icons");
7
6
  var _grommet = require("grommet");
8
7
  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); }
9
8
  var allSeasons = ['S01', 'S02', 'S03', 'S04', 'S05', 'S06', 'S07', 'S08', 'S09', 'S10'];
@@ -16,49 +15,13 @@ var Children = exports.Children = function Children() {
16
15
  return selectedSeason !== season;
17
16
  }));
18
17
  };
19
- var renderSeason = function renderSeason(season) {
20
- return /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
21
- key: "season_tag_" + season,
22
- href: "#",
23
- onClick: function onClick(event) {
24
- event.preventDefault();
25
- event.stopPropagation();
26
- onRemoveSeason(season);
27
- },
28
- onFocus: function onFocus(event) {
29
- return event.stopPropagation();
30
- }
31
- }, /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
32
- align: "center",
33
- direction: "row",
34
- gap: "xsmall",
35
- pad: {
36
- vertical: 'xsmall',
37
- horizontal: 'small'
38
- },
39
- margin: "xsmall",
40
- background: "brand",
41
- round: "large"
42
- }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
43
- size: "small"
44
- }, season), /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
45
- round: "full",
46
- margin: {
47
- left: 'xsmall'
48
- }
49
- }, /*#__PURE__*/_react["default"].createElement(_grommetIcons.FormClose, {
50
- size: "small",
51
- style: {
52
- width: '12px',
53
- height: '12px'
54
- }
55
- }))));
56
- };
57
- var renderOption = function renderOption(option, state) {
18
+ var renderOption = function renderOption(option, index, options, state) {
58
19
  return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
59
20
  pad: "small",
60
- background: state.active ? 'active' : undefined
61
- }, option);
21
+ background: state.selected ? 'brand' : undefined
22
+ }, /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
23
+ color: state.disabled ? 'text-disabled' : 'text-strong'
24
+ }, option));
62
25
  };
63
26
  return (
64
27
  /*#__PURE__*/
@@ -71,19 +34,29 @@ var Children = exports.Children = function Children() {
71
34
  }, /*#__PURE__*/_react["default"].createElement(_grommet.Select, {
72
35
  closeOnChange: false,
73
36
  multiple: true,
74
- valueLabel: /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
75
- wrap: true,
76
- direction: "row",
77
- width: "small"
78
- }, selected && selected.length ? selected.map(function (value) {
79
- return renderSeason(value);
80
- }) : /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
81
- pad: {
82
- vertical: 'xsmall',
83
- horizontal: 'small'
84
- },
85
- margin: "xsmall"
86
- }, "Select Season")),
37
+ placeholder: "Select Season",
38
+ valueLabel: function valueLabel(options) {
39
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
40
+ wrap: true,
41
+ direction: "row",
42
+ pad: "xsmall",
43
+ gap: "xsmall",
44
+ cssGap: true,
45
+ width: "small"
46
+ }, options && options.length ? options.map(function (season) {
47
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Tag, {
48
+ key: "season_tag_" + season,
49
+ value: season,
50
+ onRemove: function onRemove(event) {
51
+ event.preventDefault();
52
+ event.stopPropagation();
53
+ onRemoveSeason(season);
54
+ }
55
+ });
56
+ }) : /*#__PURE__*/_react["default"].createElement(_grommet.Text, {
57
+ color: "text-weak"
58
+ }, "Select Season"));
59
+ },
87
60
  options: allSeasons,
88
61
  value: selected,
89
62
  disabled: [2, 6],
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
 
3
- import { FormClose } from 'grommet-icons';
4
- import { Box, Button, Text } from 'grommet';
3
+ import { Box, Tag, Text } from 'grommet';
5
4
  import { SelectMultiple } from '../../SelectMultiple.js';
6
5
 
7
6
  const allSeasons = [
@@ -18,41 +17,13 @@ const allSeasons = [
18
17
  ];
19
18
 
20
19
  export const Children = () => {
21
- const [selected, setSelected] = useState([]);
20
+ const [selected, setSelected] = useState<string[]>([]);
22
21
 
23
- const onRemoveSeason = (season) => {
22
+ const onRemoveSeason = (season: string) => {
24
23
  setSelected(selected.filter((selectedSeason) => selectedSeason !== season));
25
24
  };
26
25
 
27
- const renderSeason = (season) => (
28
- <Button
29
- key={`season_tag_${season}`}
30
- onClick={(event) => {
31
- event.preventDefault();
32
- event.stopPropagation();
33
- onRemoveSeason(season);
34
- }}
35
- onFocus={(event) => event.stopPropagation()}
36
- a11yTitle={season}
37
- >
38
- <Box
39
- align="center"
40
- direction="row"
41
- gap="xsmall"
42
- pad={{ vertical: 'xsmall', horizontal: 'small' }}
43
- margin="xsmall"
44
- background="light-3"
45
- round="large"
46
- >
47
- <Text size="small">{season}</Text>
48
- <Box round="full" margin={{ left: 'xsmall' }}>
49
- <FormClose size="small" style={{ width: '12px', height: '12px' }} />
50
- </Box>
51
- </Box>
52
- </Button>
53
- );
54
-
55
- const renderOption = (option, state) => (
26
+ const renderOption = (option: string, _index: number, _options: string[], state: { active: boolean }) => (
56
27
  <Box pad="small" background={state.active ? 'active' : undefined}>
57
28
  {option}
58
29
  </Box>
@@ -66,25 +37,30 @@ export const Children = () => {
66
37
  <SelectMultiple
67
38
  sortSelectedOnClose={false}
68
39
  showSelectedInline
69
- valueLabel={(option) => (
70
- <Box wrap direction="row" width="small">
71
- {option && option.length ? (
72
- <>
73
- {option.map((i) => {
74
- console.log(option);
75
- return renderSeason(i);
76
- })}
77
- </>
78
- ) : (
79
- <Text color="text-weak">Select Season</Text>
80
- )}
40
+ placeholder="Select Season"
41
+ width="medium"
42
+ valueLabel={(options: any[]) => (
43
+ <Box
44
+ wrap
45
+ direction="row"
46
+ pad="xsmall"
47
+ gap="xsmall"
48
+ cssGap
49
+ >
50
+ {options && options.length &&
51
+ options.map((season) => (
52
+ <Tag
53
+ key={`season_tag_${season}`}
54
+ value={season}
55
+ onRemove={() => onRemoveSeason(season)}
56
+ />
57
+ ))
58
+ }
81
59
  </Box>
82
60
  )}
83
61
  options={allSeasons}
84
62
  value={selected}
85
- onChange={({ value }) => {
86
- setSelected([...value]);
87
- }}
63
+ onChange={({ value }: { value: any[] }) => setSelected([...value])}
88
64
  >
89
65
  {renderOption}
90
66
  </SelectMultiple>
@@ -0,0 +1,88 @@
1
+ import React, { useRef, useState } from 'react';
2
+
3
+ import { Box, Tag, Text } from 'grommet';
4
+ import { SelectMultiple } from '../../SelectMultiple.js';
5
+
6
+ const tags = [
7
+ 'Production',
8
+ 'Test',
9
+ 'Integration',
10
+ 'Analytics',
11
+ 'Development',
12
+ 'Staging',
13
+ 'QA',
14
+ 'UAT',
15
+ 'Performance',
16
+ 'Crash and bash',
17
+ ].sort();
18
+
19
+ export const ValueLabel = () => {
20
+ const [selected, setSelected] = useState(tags.slice(0, 3));
21
+ const valuesRef = useRef(undefined as unknown as HTMLDivElement);
22
+ const onRemoveTag = (tag: string) => {
23
+ const nextSelected = selected.filter((selectedTag) => selectedTag !== tag);
24
+ if (nextSelected.length > 0) {
25
+ const index = selected.indexOf(tag);
26
+ // update focus to the next tag's remove button
27
+ // if there is one, otherwise the previous one
28
+ const nextFocusIndex = index < nextSelected.length ? index : index - 1;
29
+ if (nextFocusIndex >= 0 && valuesRef.current) {
30
+ setTimeout(() => {
31
+ const element = valuesRef.current as HTMLElement;
32
+ const buttons = element?.querySelectorAll('button');
33
+ buttons[nextFocusIndex].focus();
34
+ }, 200);
35
+ }
36
+ }
37
+ setSelected(nextSelected);
38
+ };
39
+
40
+ return (
41
+ // Uncomment <Grommet> lines when using outside of storybook
42
+ // <Grommet theme={...}>
43
+ <Box fill align="center" pad="large" gap="large">
44
+ <Text>SelectMultiple with custom valueLabel</Text>
45
+ <SelectMultiple
46
+ showSelectedInline
47
+ placeholder="Select tag"
48
+ width="medium"
49
+ valueLabel={(options: any[]) => (
50
+ <Box
51
+ ref={valuesRef}
52
+ wrap
53
+ direction="row"
54
+ pad="xsmall"
55
+ gap="xsmall"
56
+ cssGap
57
+ >
58
+ {options && options.length &&
59
+ options.map((tag) => (
60
+ <Tag
61
+ key={`tag_${tag}`}
62
+ value={tag}
63
+ onRemove={() => onRemoveTag(tag)}
64
+ />
65
+ ))
66
+ }
67
+ </Box>
68
+ )}
69
+ options={tags}
70
+ value={selected}
71
+ onChange={({ value }: { value: string[] }) => setSelected([...value])}
72
+ />
73
+ </Box>
74
+ // </Grommet>
75
+ );
76
+ };
77
+
78
+ ValueLabel.parameters = {
79
+ chromatic: { disable: true },
80
+ };
81
+
82
+ ValueLabel.args = {
83
+ full: true,
84
+ };
85
+
86
+ export default {
87
+ title: 'Input/SelectMultiple/Value Label',
88
+ };