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
@@ -8,10 +8,12 @@ if (process.env.NODE_ENV !== 'production') {
8
8
  data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.shape({})])),
9
9
  children: PropTypes.func,
10
10
  onMore: PropTypes.func,
11
+ onOrder: PropTypes.func,
11
12
  paginate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
12
13
  show: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
13
14
  page: PropTypes.number
14
15
  })]),
16
+ sizeKey: PropTypes.string,
15
17
  step: PropTypes.number
16
18
  });
17
19
  }
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { Box, Card, CardBody, Heading, Text } from 'grommet';
3
+ import { Cards } from '../Cards';
4
+ var data = [{
5
+ city: 'Boise',
6
+ state: 'Idaho',
7
+ size: {
8
+ columns: 2,
9
+ rows: 1
10
+ }
11
+ }, {
12
+ city: 'Fort Collins',
13
+ state: 'Colorado'
14
+ }, {
15
+ city: 'Bay Area',
16
+ state: 'California'
17
+ }, {
18
+ city: 'San Diego',
19
+ state: 'California',
20
+ size: {
21
+ columns: 2,
22
+ rows: 1
23
+ }
24
+ }, {
25
+ city: 'San Francisco',
26
+ state: 'California',
27
+ size: {
28
+ columns: 1,
29
+ rows: 2
30
+ }
31
+ }, {
32
+ city: 'Los Angeles',
33
+ state: 'California'
34
+ }, {
35
+ city: 'Portland',
36
+ state: 'Oregon'
37
+ }, {
38
+ city: 'Seattle',
39
+ state: 'Washington'
40
+ }];
41
+ export var Sizable = function Sizable() {
42
+ return /*#__PURE__*/React.createElement(Box, {
43
+ fill: true
44
+ }, /*#__PURE__*/React.createElement(Cards, {
45
+ id: "myGrid",
46
+ data: data,
47
+ pad: "medium",
48
+ columns: ['flex', 'flex', 'flex'],
49
+ rows: "xsmall",
50
+ sizeKey: "size"
51
+ }, function (datum) {
52
+ return /*#__PURE__*/React.createElement(Card, {
53
+ key: datum.city,
54
+ pad: "small",
55
+ elevation: "medium"
56
+ }, /*#__PURE__*/React.createElement(CardBody, null, /*#__PURE__*/React.createElement(Heading, {
57
+ level: 2,
58
+ size: "small",
59
+ margin: "none"
60
+ }, datum.city), /*#__PURE__*/React.createElement(Text, null, datum.state)));
61
+ }));
62
+ };
63
+ export default {
64
+ title: 'Visualizations/Cards/Sizable'
65
+ };
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { Box, Card, CardBody, Heading, Text } from 'grommet';
3
+ import { Cards } from '../Cards';
4
+ var data = [{
5
+ id: 'bo',
6
+ city: 'Boise',
7
+ state: 'Idaho'
8
+ }, {
9
+ id: 'fc',
10
+ city: 'Fort Collins',
11
+ state: 'Colorado'
12
+ }, {
13
+ id: 'ba',
14
+ city: 'Bay Area',
15
+ state: 'California'
16
+ }, {
17
+ id: 'sd',
18
+ city: 'San Diego',
19
+ state: 'California'
20
+ }, {
21
+ id: 'sf',
22
+ city: 'San Francisco',
23
+ state: 'California'
24
+ }, {
25
+ id: 'la',
26
+ city: 'Los Angeles',
27
+ state: 'California'
28
+ }, {
29
+ id: 'pt',
30
+ city: 'Portland',
31
+ state: 'Oregon'
32
+ }, {
33
+ id: 'se',
34
+ city: 'Seattle',
35
+ state: 'Washington'
36
+ }];
37
+ export var OnOrder = function OnOrder() {
38
+ var _React$useState = React.useState(data),
39
+ orderedData = _React$useState[0],
40
+ setOrderedData = _React$useState[1];
41
+ return /*#__PURE__*/React.createElement(Box, {
42
+ fill: true
43
+ }, /*#__PURE__*/React.createElement(Cards, {
44
+ id: "myGrid",
45
+ data: orderedData,
46
+ pad: "medium",
47
+ columns: ['flex', 'flex', 'flex'],
48
+ onOrder: setOrderedData
49
+ }, function (datum) {
50
+ return /*#__PURE__*/React.createElement(Card, {
51
+ key: datum.city,
52
+ pad: "medium",
53
+ elevation: "medium"
54
+ }, /*#__PURE__*/React.createElement(CardBody, null, /*#__PURE__*/React.createElement(Heading, {
55
+ level: 2,
56
+ size: "small",
57
+ margin: "none"
58
+ }, datum.city), /*#__PURE__*/React.createElement(Text, null, datum.state)));
59
+ }));
60
+ };
61
+ OnOrder.storyName = 'onOrder';
62
+ export default {
63
+ title: 'Visualizations/Cards/onOrder'
64
+ };
@@ -39,26 +39,6 @@ var generateOptions = function generateOptions(data, property) {
39
39
  return 0;
40
40
  });
41
41
  };
42
-
43
- // ensure floating point calculations are in integers
44
- var alignMax = function alignMax(value, interval) {
45
- var multiplier = Math.pow(10, Math.max(getDecimalCount(value), getDecimalCount(interval)));
46
- var integerValue = value * multiplier;
47
- var integerInterval = interval * multiplier;
48
- if (value > 0) return (integerValue - integerValue % integerInterval + integerInterval) / multiplier;
49
- if (value < 0) return (integerValue + integerValue % integerInterval) / multiplier;
50
- return value;
51
- };
52
-
53
- // ensure floating point calculations are in integers
54
- var alignMin = function alignMin(value, interval) {
55
- var multiplier = Math.pow(10, Math.max(getDecimalCount(value), getDecimalCount(interval)));
56
- var integerValue = value * multiplier;
57
- var integerInterval = interval * multiplier;
58
- if (value > 0) return (integerValue - integerValue % integerInterval) / multiplier;
59
- if (value < 0) return (integerValue - integerValue % integerInterval - integerInterval) / multiplier;
60
- return value;
61
- };
62
42
  var booleanOptions = [{
63
43
  label: 'true',
64
44
  value: true
@@ -96,21 +76,24 @@ export var DataFilter = function DataFilter(_ref) {
96
76
 
97
77
  // generate options from all values for property
98
78
  var uniqueValues = generateOptions(unfilteredData || data, property);
99
- // if less than two values, nothing to filter
100
- if (uniqueValues.length < 2) return [undefined, undefined];
79
+ // if no values, nothing to filter
80
+ // uniqueValues.length === 0 allows single item/value filters to render
81
+ if (uniqueValues.length === 0) return [undefined, undefined];
101
82
  // if any values aren't numeric, treat as options
102
83
  if (uniqueValues.some(function (v) {
103
84
  return v !== undefined && typeof v !== 'number';
104
85
  })) return [uniqueValues, undefined];
105
86
  // all values are numeric, treat as range
106
- var delta = uniqueValues[uniqueValues.length - 1] - uniqueValues[0];
107
- var interval = Number.parseFloat((delta / 3).toPrecision(1));
108
87
  var min = uniqueValues[0];
109
88
  var max = uniqueValues[uniqueValues.length - 1];
110
- // normalize to make it friendler, so [1.3, 4.895] becomes [1, 5]
111
- if (getDecimalCount(min) > 0 || getDecimalCount(max) > 0) {
112
- min = alignMin(min, interval);
113
- max = alignMax(max, interval);
89
+ // Clean up floating-point precision artifacts, capped to 2 decimal places.
90
+ // Use floor for min and ceil for max so actual data values always fall
91
+ // within the computed range (e.g. -4.859 stays inside [-19.99, -4.85]).
92
+ var maxDecimalPlaces = Math.max(getDecimalCount(uniqueValues[0]), getDecimalCount(uniqueValues[uniqueValues.length - 1]));
93
+ if (maxDecimalPlaces > 0) {
94
+ var multiplier = Math.pow(10, Math.min(maxDecimalPlaces, 2));
95
+ min = Math.floor(min * multiplier) / multiplier;
96
+ max = Math.ceil(max * multiplier) / multiplier;
114
97
  }
115
98
  return [undefined, [min, max]];
116
99
  }, [children, data, optionsProp, properties, property, rangeProp, unfilteredData]),
@@ -158,6 +141,16 @@ export var DataFilter = function DataFilter(_ref) {
158
141
  var multiplier = Math.pow(10, decimalCount);
159
142
  step = multiplier * delta / (multiplier * defaultRangeSteps);
160
143
  } else step = delta / defaultRangeSteps;
144
+
145
+ // Cap step to maximum 2 decimal places to avoid long
146
+ // precision artifacts
147
+ var stepMultiplier = Math.pow(10, 2);
148
+ step = Math.round(step * stepMultiplier) / stepMultiplier;
149
+
150
+ // Ensure step is never 0 or negative (required for RangeSelector)
151
+ if (step <= 0) {
152
+ step = Math.pow(10, -(Math.max(getDecimalCount(range[0]), getDecimalCount(range[1])) || 1));
153
+ }
161
154
  }
162
155
  content = /*#__PURE__*/React.createElement(RangeSelector, _extends({
163
156
  "aria-label": ariaLabel,
@@ -84,18 +84,45 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
84
84
  var ref = useForwardedRef(refArg);
85
85
  var containerRef = useRef();
86
86
  var readOnly = readOnlyProp || readOnlyCopy;
87
+ var bounds = calendarProps == null ? void 0 : calendarProps.bounds;
88
+ var validateBoundsForForm = useCallback(function (fieldValue) {
89
+ if (!bounds || !fieldValue) return undefined;
90
+ var isValid = validateBounds(bounds, fieldValue);
91
+ if (!isValid) {
92
+ var _bounds$map = bounds.map(function (date) {
93
+ return setHoursWithOffset(date).toISOString();
94
+ }),
95
+ startBound = _bounds$map[0],
96
+ endBound = _bounds$map[1];
97
+ if (startBound && endBound) {
98
+ return formatMessage({
99
+ id: 'dateInput.outOfBounds',
100
+ messages: messages,
101
+ values: {
102
+ start: new Date(startBound).toLocaleDateString(),
103
+ end: new Date(endBound).toLocaleDateString()
104
+ }
105
+ });
106
+ }
107
+ }
108
+ return undefined;
109
+ }, [bounds, formatMessage, messages]);
87
110
  var _useFormInput = useFormInput({
88
111
  name: name,
89
112
  value: valueArg,
90
- initialValue: defaultValue
113
+ initialValue: defaultValue,
114
+ validate: bounds ? validateBoundsForForm : undefined
91
115
  }),
92
116
  value = _useFormInput[0],
93
117
  setValue = _useFormInput[1];
94
118
  var usingKeyboard = useKeyboard();
95
119
  var CalendarIcon = ((_theme$dateInput$icon2 = theme.dateInput.icon) == null ? void 0 : _theme$dateInput$icon2.calendar) || GrommetCalendarIcon;
96
- var _useState = useState(getOutputFormat(value)),
97
- outputFormat = _useState[0],
98
- setOutputFormat = _useState[1];
120
+ var _useState = useState(true),
121
+ withinBounds = _useState[0],
122
+ setWithinBounds = _useState[1];
123
+ var _useState2 = useState(getOutputFormat(value)),
124
+ outputFormat = _useState2[0],
125
+ setOutputFormat = _useState2[1];
99
126
  useEffect(function () {
100
127
  setOutputFormat(function (previousFormat) {
101
128
  var nextFormat = getOutputFormat(value);
@@ -105,11 +132,19 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
105
132
  return previousFormat !== nextFormat ? previousFormat : nextFormat;
106
133
  });
107
134
  }, [value]);
135
+ useEffect(function () {
136
+ if (value === undefined || bounds === undefined) {
137
+ setWithinBounds(true);
138
+ } else {
139
+ var validNextValue = validateBounds(bounds, value);
140
+ setWithinBounds(validNextValue);
141
+ }
142
+ }, [value, bounds]);
108
143
 
109
144
  // keep track of timestamp from original date(s)
110
- var _useState2 = useState(getReference(value)),
111
- reference = _useState2[0],
112
- setReference = _useState2[1];
145
+ var _useState3 = useState(getReference(value)),
146
+ reference = _useState3[0],
147
+ setReference = _useState3[1];
113
148
 
114
149
  // do we expect multiple dates?
115
150
  var range = Array.isArray(value) || format && format.includes('-');
@@ -125,9 +160,9 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
125
160
  }, [schema]);
126
161
 
127
162
  // textValue is only used when a format is provided
128
- var _useState3 = useState(schema ? valueToText(value, schema) : undefined),
129
- textValue = _useState3[0],
130
- setTextValue = _useState3[1];
163
+ var _useState4 = useState(schema ? valueToText(value, schema) : undefined),
164
+ textValue = _useState4[0],
165
+ setTextValue = _useState4[1];
131
166
  var readOnlyCopyValidation = formatMessage({
132
167
  id: 'input.readOnlyCopy.validation',
133
168
  messages: messages
@@ -136,9 +171,9 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
136
171
  id: 'input.readOnlyCopy.prompt',
137
172
  messages: messages
138
173
  });
139
- var _useState4 = useState(readOnlyCopyPrompt),
140
- tip = _useState4[0],
141
- setTip = _useState4[1];
174
+ var _useState5 = useState(readOnlyCopyPrompt),
175
+ tip = _useState5[0],
176
+ setTip = _useState5[1];
142
177
 
143
178
  // Setting the icon through `inputProps` is deprecated.
144
179
  // The `icon` prop should be used instead.
@@ -190,9 +225,9 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
190
225
  }, [schema, ref]);
191
226
 
192
227
  // when format and not inline, whether to show the Calendar in a Drop
193
- var _useState5 = useState(),
194
- open = _useState5[0],
195
- setOpen = _useState5[1];
228
+ var _useState6 = useState(),
229
+ open = _useState6[0],
230
+ setOpen = _useState6[1];
196
231
  var openCalendar = useCallback(function () {
197
232
  setOpen(true);
198
233
  announce(formatMessage({
@@ -322,6 +357,7 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
322
357
  readOnlyProp: readOnly,
323
358
  fill: true
324
359
  }, passThemeFlag), reverse && (!readOnly || readOnlyCopy) && DateInputButton, /*#__PURE__*/React.createElement(MaskedInput, _extends({
360
+ "aria-invalid": bounds && !withinBounds ? true : undefined,
325
361
  readOnly: readOnly,
326
362
  ref: ref,
327
363
  id: id,
@@ -336,17 +372,15 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
336
372
  var nextTextValue = event.target.value;
337
373
  setTextValue(nextTextValue);
338
374
  var nextValue = textToValue(nextTextValue, schema, range, reference, outputFormat);
339
- var validatedNextValue = validateBounds(calendarProps == null ? void 0 : calendarProps.bounds, nextValue);
340
- if (!validatedNextValue && nextValue) {
341
- setTextValue('');
342
- }
343
- if (validatedNextValue !== undefined) setReference(getReference(validatedNextValue));
375
+ var validNextValue = validateBounds(bounds, nextValue);
376
+ setWithinBounds(validNextValue);
377
+ if (nextValue !== undefined) setReference(getReference(nextValue));
344
378
  // update value even when undefined
345
- setValue(validatedNextValue);
379
+ setValue(nextValue);
346
380
  if (_onChange) {
347
381
  event.persist(); // extract from React synthetic event pool
348
382
  var adjustedEvent = event;
349
- adjustedEvent.value = validatedNextValue;
383
+ adjustedEvent.value = nextValue;
350
384
  _onChange(adjustedEvent);
351
385
  }
352
386
  },
@@ -366,7 +400,6 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
366
400
  if (open && !readOnly) {
367
401
  return [input, /*#__PURE__*/React.createElement(Drop, _extends({
368
402
  key: "drop",
369
- overflow: "visible",
370
403
  id: id ? id + "__drop" : undefined,
371
404
  target: containerRef.current,
372
405
  align: _extends({}, calendarDropdownAlign, dropProps),
@@ -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;
@@ -119,7 +119,7 @@ var pullDigits = function pullDigits(text, index) {
119
119
  return text.slice(index, end);
120
120
  };
121
121
  export var validateBounds = function validateBounds(dateBounds, selectedDate) {
122
- if (!dateBounds || !selectedDate) return selectedDate;
122
+ if (!dateBounds || !selectedDate) return true;
123
123
  var _dateBounds$map = dateBounds.map(function (date) {
124
124
  return setHoursWithOffset(date).toISOString();
125
125
  }),
@@ -131,7 +131,7 @@ export var validateBounds = function validateBounds(dateBounds, selectedDate) {
131
131
  var validSelection = isoSelectedDates.every(function (isoSelectedDate) {
132
132
  return !endDate && startDate === isoSelectedDate || isoSelectedDate >= startDate && isoSelectedDate <= endDate;
133
133
  });
134
- return validSelection ? selectedDate : undefined;
134
+ return validSelection;
135
135
  };
136
136
  export var textToValue = function textToValue(text, schema, range, reference, outputFormat) {
137
137
  if (!text) return range ? [] : undefined;
@@ -174,9 +174,10 @@ var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
174
174
 
175
175
  /* If responsive is true and the Drop doesn't have enough room
176
176
  to be fully visible and there is more room in the other
177
- direction, change the Drop to display above/below. If there is
178
- less room in the other direction leave the Drop in its current
179
- position. */
177
+ direction, change the Drop to display above/below. If neither
178
+ direction has enough room for the full Drop, prefer the side
179
+ with more available space rather than clamping to the side
180
+ originally requested. */
180
181
  if (responsive &&
181
182
  // drop is above target
182
183
  align.bottom === 'top' &&
@@ -221,6 +222,61 @@ var DropContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
221
222
  // top of drop is aligned to top of target
222
223
  top = targetRect.top;
223
224
  maxHeight = bottom;
225
+ } else if (responsive &&
226
+ // top of drop is aligned to bottom of target (open below)
227
+ align.top === 'bottom' &&
228
+ // drop is overflowing below window
229
+ targetRect.bottom + containerRect.height >= windowHeight &&
230
+ // the flip anchor (target's top) is on-screen — otherwise
231
+ // flipping pins the drop's bottom off-screen
232
+ targetRect.top > 0 &&
233
+ // there is more room above the target than below it — neither
234
+ // side fits the full drop, so prefer the larger side rather
235
+ // than clamping to the smaller requested side.
236
+ targetRect.top > windowHeight - targetRect.bottom) {
237
+ // bottom of drop is aligned to top of target
238
+ bottom = targetRect.top;
239
+ maxHeight = bottom;
240
+ } else if (responsive &&
241
+ // top of drop is aligned to top of target (open below)
242
+ align.top === 'top' &&
243
+ // drop is overflowing below window
244
+ targetRect.top + containerRect.height >= windowHeight &&
245
+ // height of the drop is larger than the target — otherwise the
246
+ // drop already fits inside the target's vertical span and a
247
+ // flip would pin its bottom to a potentially off-screen
248
+ // target.bottom (mirrors the safety in branch #2 above).
249
+ targetRect.top + containerRect.height > targetRect.bottom &&
250
+ // there is more room above the target than below it
251
+ targetRect.bottom > windowHeight - targetRect.top) {
252
+ // bottom of drop is aligned to bottom of target
253
+ bottom = targetRect.bottom;
254
+ maxHeight = bottom;
255
+ } else if (responsive &&
256
+ // bottom of drop is aligned to top of target (open above)
257
+ align.bottom === 'top' &&
258
+ // drop is overflowing above window
259
+ targetRect.top - containerRect.height <= 0 &&
260
+ // the flip anchor (target's bottom) is on-screen
261
+ targetRect.bottom < windowHeight &&
262
+ // there is more room below the target than above it
263
+ windowHeight - targetRect.bottom > targetRect.top) {
264
+ // top of drop is aligned to bottom of target
265
+ top = targetRect.bottom;
266
+ maxHeight = windowHeight - top;
267
+ } else if (responsive &&
268
+ // bottom of drop is aligned to bottom of target (open above)
269
+ align.bottom === 'bottom' &&
270
+ // drop is overflowing above window
271
+ targetRect.bottom - containerRect.height <= 0 &&
272
+ // height of the drop is larger than the target (mirrors the
273
+ // safety in branch #4 above)
274
+ targetRect.bottom - containerRect.height < targetRect.top &&
275
+ // there is more room below the target than above it
276
+ windowHeight - targetRect.top > targetRect.bottom) {
277
+ // top of drop is aligned to top of target
278
+ top = targetRect.top;
279
+ maxHeight = windowHeight - top;
224
280
  } else if (align.top === 'top') {
225
281
  top = targetRect.top;
226
282
  maxHeight = windowHeight - top;
@@ -287,6 +287,9 @@ var FileInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
287
287
  onChange: function onChange(event) {
288
288
  event.persist();
289
289
  var fileList = event.target.files;
290
+ // If the user cancelled the file picker, fileList will be empty
291
+ // and we should not clear any previously selected files.
292
+ if (!fileList.length && files.length) return;
290
293
  var nextFiles = multiple ? [].concat(files) : [];
291
294
  var _loop = function _loop(i) {
292
295
  // avoid duplicates
@@ -62,7 +62,13 @@ var customTheme = deepMerge(grommet, {
62
62
  export var FieldCustomStates = function FieldCustomStates() {
63
63
  var inputRef = useRef();
64
64
  useEffect(function () {
65
- inputRef.current.focus();
65
+ var focusTimeout = setTimeout(function () {
66
+ var _inputRef$current;
67
+ (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
68
+ });
69
+ return function () {
70
+ return clearTimeout(focusTimeout);
71
+ };
66
72
  }, []);
67
73
  return /*#__PURE__*/React.createElement(Grommet, {
68
74
  theme: customTheme
@@ -3,7 +3,13 @@ import { Box, Form, FormField, TextInput } from 'grommet';
3
3
  export var FieldStates = function FieldStates() {
4
4
  var inputRef = useRef();
5
5
  useEffect(function () {
6
- inputRef.current.focus();
6
+ var focusTimeout = setTimeout(function () {
7
+ var _inputRef$current;
8
+ (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
9
+ });
10
+ return function () {
11
+ return clearTimeout(focusTimeout);
12
+ };
7
13
  }, []);
8
14
  return (
9
15
  /*#__PURE__*/
@@ -21,7 +21,7 @@ import { FormFieldPropTypes } from './propTypes';
21
21
  import { useThemeValue } from '../../utils/useThemeValue';
22
22
  import { AnnounceContext } from '../../contexts/AnnounceContext';
23
23
  var grommetInputFocusNames = ['CheckBox', 'CheckBoxGroup', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
24
- var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'SelectMultiple', 'TextArea', 'DateInput', 'FileInput', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
24
+ var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'SelectMultiple', 'TextArea', 'DateInput', 'TimeInput', 'FileInput', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
25
25
  var grommetInputPadNames = ['CheckBox', 'CheckBoxGroup', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector'];
26
26
  var isGrommetInput = function isGrommetInput(comp) {
27
27
  return comp && (grommetInputNames.indexOf(comp.displayName) !== -1 || grommetInputPadNames.indexOf(comp.displayName) !== -1);
@@ -73,7 +73,8 @@ var Grommet = /*#__PURE__*/forwardRef(function (props, ref) {
73
73
  }, [messagesProp]);
74
74
  useEffect(function () {
75
75
  var onResize = function onResize() {
76
- setResponsive(getBreakpoint(document.body.clientWidth, theme));
76
+ var _document$body$client, _document$body;
77
+ setResponsive(getBreakpoint((_document$body$client = (_document$body = document.body) == null ? void 0 : _document$body.clientWidth) != null ? _document$body$client : window.innerWidth, theme));
77
78
  };
78
79
  window.addEventListener('resize', onResize);
79
80
  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;
@@ -7,6 +7,12 @@ if (process.env.NODE_ENV !== 'production') {
7
7
  dir: PropTypes.oneOf(['rtl']),
8
8
  full: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['min'])]),
9
9
  options: PropTypes.shape({
10
+ box: PropTypes.shape({
11
+ cssGap: PropTypes.bool
12
+ }),
13
+ button: PropTypes.shape({
14
+ childrenPlain: PropTypes.bool
15
+ }),
10
16
  layer: PropTypes.shape({
11
17
  singleId: PropTypes.bool
12
18
  }),
@@ -33,6 +39,11 @@ if (process.env.NODE_ENV !== 'production') {
33
39
  nextMove: PropTypes.string,
34
40
  next: PropTypes.string
35
41
  }),
42
+ cards: PropTypes.shape({
43
+ moved: PropTypes.string,
44
+ reorderHint: PropTypes.string,
45
+ description: PropTypes.string
46
+ }),
36
47
  carousel: PropTypes.shape({
37
48
  previous: PropTypes.string,
38
49
  next: PropTypes.string,
@@ -41,7 +52,8 @@ if (process.env.NODE_ENV !== 'production') {
41
52
  dateInput: PropTypes.shape({
42
53
  openCalendar: PropTypes.string,
43
54
  enterCalendar: PropTypes.string,
44
- exitCalendar: PropTypes.string
55
+ exitCalendar: PropTypes.string,
56
+ outOfBounds: PropTypes.string
45
57
  }),
46
58
  dataChart: PropTypes.shape({
47
59
  detailTitle: PropTypes.string,
@@ -209,7 +221,13 @@ if (process.env.NODE_ENV !== 'production') {
209
221
  skipLinks: PropTypes.shape({
210
222
  skipTo: PropTypes.string
211
223
  }),
224
+ stepper: PropTypes.shape({
225
+ progress: PropTypes.string,
226
+ step: PropTypes.string
227
+ }),
212
228
  tabs: PropTypes.shape({
229
+ nextTab: PropTypes.string,
230
+ previousTab: PropTypes.string,
213
231
  tabContents: PropTypes.string
214
232
  }),
215
233
  tag: PropTypes.shape({
@@ -224,6 +242,20 @@ if (process.env.NODE_ENV !== 'production') {
224
242
  suggestionsExist: PropTypes.string,
225
243
  suggestionIsOpen: PropTypes.string
226
244
  }),
245
+ timeInput: PropTypes.shape({
246
+ activePeriodValue: PropTypes.string,
247
+ activeSection: PropTypes.string,
248
+ activeSectionValue: PropTypes.string,
249
+ chooseTime: PropTypes.string,
250
+ currentValue: PropTypes.string,
251
+ inputLabel: PropTypes.string,
252
+ invalidTime: PropTypes.string,
253
+ openDrop: PropTypes.string,
254
+ sectionHours: PropTypes.string,
255
+ sectionMeridiem: PropTypes.string,
256
+ sectionMinutes: PropTypes.string,
257
+ sectionSeconds: PropTypes.string
258
+ }),
227
259
  video: PropTypes.shape({
228
260
  audioDescriptions: PropTypes.string,
229
261
  captions: PropTypes.string,