grommet 2.57.0 → 2.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/components/Box/StyledBox.js +1 -1
  2. package/components/Box/stories/ColorContrast.stories.js +36 -0
  3. package/components/Button/BusyAnimation.js +7 -1
  4. package/components/Button/Button.js +12 -3
  5. package/components/DataTable/StyledDataTable.js +1 -1
  6. package/components/DateInput/DateInput.js +3 -3
  7. package/components/DateTimeInput/DateTimeInput.js +17 -11
  8. package/components/FocusedContainer.js +2 -1
  9. package/components/FormField/FormField.js +31 -10
  10. package/components/FormField/FormFieldContext.js +12 -0
  11. package/components/Grommet/Grommet.js +4 -1
  12. package/components/Grommet/StyledGrommet.js +3 -3
  13. package/components/Grommet/index.d.ts +6 -0
  14. package/components/Grommet/propTypes.js +2 -0
  15. package/components/Menu/Menu.js +1 -1
  16. package/components/Select/SelectContainer.js +2 -2
  17. package/components/Select/StyledSelect.js +3 -1
  18. package/components/TextArea/StyledTextArea.js +3 -1
  19. package/components/TextInput/CopyButton.js +23 -6
  20. package/components/TextInput/StyledTextInput.js +19 -25
  21. package/components/TextInput/TextInput.js +75 -28
  22. package/components/TextInput/index.d.ts +12 -3
  23. package/components/TextInput/propTypes.js +2 -0
  24. package/components/TextInput/stories/Copy.stories.tsx +42 -0
  25. package/components/TextInput/stories/CopySecret.stories.tsx +44 -0
  26. package/components/TimeInput/README.md +24 -1
  27. package/components/TimeInput/StyledTimeInput.js +91 -27
  28. package/components/TimeInput/TimeInput.js +185 -120
  29. package/components/TimeInput/TimeInputPopup.js +114 -117
  30. package/components/TimeInput/index.d.ts +2 -0
  31. package/components/TimeInput/propTypes.js +2 -0
  32. package/components/TimeInput/stories/Controlled.stories.tsx +2 -2
  33. package/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
  34. package/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
  35. package/components/TimeInput/stories/Form.stories.tsx +1 -0
  36. package/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
  37. package/components/TimeInput/useSectionedTimeField.js +2 -2
  38. package/components/TimeInput/utils.js +13 -62
  39. package/components/Wizard/Wizard.js +396 -210
  40. package/components/Wizard/WizardContent.js +61 -35
  41. package/components/Wizard/WizardContext.js +3 -0
  42. package/components/Wizard/WizardFooter.js +14 -15
  43. package/components/Wizard/WizardHeader.js +12 -7
  44. package/components/Wizard/WizardProgress.js +27 -2
  45. package/components/Wizard/index.d.ts +35 -4
  46. package/components/Wizard/propTypes.js +6 -1
  47. package/components/Wizard/stories/BasicLinear.stories.js +12 -10
  48. package/components/Wizard/stories/ClickableSteps.stories.js +104 -0
  49. package/components/Wizard/stories/ExternalForm.stories.js +114 -0
  50. package/components/Wizard/stories/NonClosableHeader.stories.js +68 -0
  51. package/components/Wizard/stories/Validation.stories.js +18 -8
  52. package/es6/components/Box/StyledBox.js +1 -1
  53. package/es6/components/Box/stories/ColorContrast.stories.js +31 -0
  54. package/es6/components/Button/BusyAnimation.js +7 -1
  55. package/es6/components/Button/Button.js +12 -3
  56. package/es6/components/DataTable/StyledDataTable.js +2 -2
  57. package/es6/components/DateInput/DateInput.js +3 -3
  58. package/es6/components/DateTimeInput/DateTimeInput.js +17 -11
  59. package/es6/components/FocusedContainer.js +2 -1
  60. package/es6/components/FormField/FormField.js +31 -10
  61. package/es6/components/FormField/FormFieldContext.js +7 -0
  62. package/es6/components/Grommet/Grommet.js +4 -1
  63. package/es6/components/Grommet/StyledGrommet.js +4 -4
  64. package/es6/components/Grommet/index.d.ts +6 -0
  65. package/es6/components/Grommet/propTypes.js +2 -0
  66. package/es6/components/Menu/Menu.js +1 -1
  67. package/es6/components/Select/SelectContainer.js +2 -2
  68. package/es6/components/Select/StyledSelect.js +4 -2
  69. package/es6/components/TextArea/StyledTextArea.js +4 -2
  70. package/es6/components/TextInput/CopyButton.js +22 -6
  71. package/es6/components/TextInput/StyledTextInput.js +20 -26
  72. package/es6/components/TextInput/TextInput.js +76 -29
  73. package/es6/components/TextInput/index.d.ts +12 -3
  74. package/es6/components/TextInput/propTypes.js +2 -0
  75. package/es6/components/TextInput/stories/Copy.stories.tsx +42 -0
  76. package/es6/components/TextInput/stories/CopySecret.stories.tsx +44 -0
  77. package/es6/components/TimeInput/README.md +24 -1
  78. package/es6/components/TimeInput/StyledTimeInput.js +92 -28
  79. package/es6/components/TimeInput/TimeInput.js +187 -122
  80. package/es6/components/TimeInput/TimeInputPopup.js +115 -118
  81. package/es6/components/TimeInput/index.d.ts +2 -0
  82. package/es6/components/TimeInput/propTypes.js +2 -0
  83. package/es6/components/TimeInput/stories/Controlled.stories.tsx +2 -2
  84. package/es6/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
  85. package/es6/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
  86. package/es6/components/TimeInput/stories/Form.stories.tsx +1 -0
  87. package/es6/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
  88. package/es6/components/TimeInput/useSectionedTimeField.js +2 -2
  89. package/es6/components/TimeInput/utils.js +12 -61
  90. package/es6/components/Wizard/Wizard.js +397 -211
  91. package/es6/components/Wizard/WizardContent.js +62 -36
  92. package/es6/components/Wizard/WizardContext.js +3 -0
  93. package/es6/components/Wizard/WizardFooter.js +14 -15
  94. package/es6/components/Wizard/WizardHeader.js +12 -7
  95. package/es6/components/Wizard/WizardProgress.js +27 -2
  96. package/es6/components/Wizard/index.d.ts +35 -4
  97. package/es6/components/Wizard/propTypes.js +6 -1
  98. package/es6/components/Wizard/stories/BasicLinear.stories.js +11 -11
  99. package/es6/components/Wizard/stories/ClickableSteps.stories.js +99 -0
  100. package/es6/components/Wizard/stories/ExternalForm.stories.js +111 -0
  101. package/es6/components/Wizard/stories/NonClosableHeader.stories.js +63 -0
  102. package/es6/components/Wizard/stories/Validation.stories.js +18 -9
  103. package/es6/languages/default.json +2 -0
  104. package/es6/themes/base.d.ts +79 -59
  105. package/es6/themes/base.js +65 -34
  106. package/es6/utils/DOM.js +10 -7
  107. package/es6/utils/background.js +9 -7
  108. package/es6/utils/colors.js +84 -12
  109. package/es6/utils/legacyColorIsDark.js +17 -0
  110. package/es6/utils/styles.js +13 -5
  111. package/grommet.min.js +1 -1
  112. package/grommet.min.js.map +1 -1
  113. package/languages/default.json +2 -0
  114. package/package.json +3 -3
  115. package/themes/base.d.ts +79 -59
  116. package/themes/base.js +65 -34
  117. package/tools/draft-release-version-pr.js +1 -0
  118. package/tools/generate-release-notes.js +1 -1
  119. package/tools/release-notes-utils.js +1 -0
  120. package/utils/DOM.js +10 -7
  121. package/utils/background.js +9 -7
  122. package/utils/colors.js +84 -12
  123. package/utils/legacyColorIsDark.js +21 -0
  124. package/utils/styles.js +14 -6
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = exports.ExternalForm = void 0;
5
+ var _react = _interopRequireWildcard(require("react"));
6
+ var _grommet = require("grommet");
7
+ var _Wizard = require("../Wizard");
8
+ var _WizardFooter = require("../WizardFooter");
9
+ var _WizardContext = require("../WizardContext");
10
+ 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); }
11
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
12
+ // SPDX-License-Identifier: Apache-2.0
13
+ var validate = function validate(value) {
14
+ var _value$name;
15
+ return {
16
+ details: (_value$name = value.name) != null && _value$name.trim() ? undefined : 'A request name is required.'
17
+ };
18
+ };
19
+ var ExternalFormFooter = function ExternalFormFooter(_ref) {
20
+ var errors = _ref.errors;
21
+ var _useWizard = (0, _WizardContext.useWizard)(),
22
+ complete = _useWizard.complete,
23
+ currentStep = _useWizard.currentStep,
24
+ currentStepIndex = _useWizard.currentStepIndex,
25
+ next = _useWizard.next,
26
+ previous = _useWizard.previous,
27
+ totalSteps = _useWizard.totalSteps;
28
+ var isFirstStep = currentStepIndex === 0;
29
+ var isLastStep = currentStepIndex === totalSteps - 1;
30
+ var hasError = !!errors[currentStep];
31
+ return /*#__PURE__*/_react["default"].createElement(_WizardFooter.WizardFooter, null, !isFirstStep && /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
32
+ label: "Previous",
33
+ secondary: true,
34
+ onClick: previous
35
+ }), /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
36
+ label: isLastStep ? 'Complete' : 'Next',
37
+ primary: true,
38
+ disabled: hasError,
39
+ onClick: isLastStep ? complete : next
40
+ }));
41
+ };
42
+ var ExternalForm = exports.ExternalForm = function ExternalForm() {
43
+ var _useState = (0, _react.useState)(),
44
+ submittedValue = _useState[0],
45
+ setSubmittedValue = _useState[1];
46
+ var _useState2 = (0, _react.useState)({
47
+ name: ''
48
+ }),
49
+ value = _useState2[0],
50
+ setValue = _useState2[1];
51
+ var errors = validate(value);
52
+ var steps = [{
53
+ id: 'details',
54
+ title: 'Details',
55
+ status: errors.details ? 'error' : 'completed',
56
+ errorMessage: errors.details,
57
+ render: function render() {
58
+ return /*#__PURE__*/_react["default"].createElement(_grommet.FormField, {
59
+ htmlFor: "request-name",
60
+ label: "Request name",
61
+ name: "name",
62
+ error: errors.details
63
+ }, /*#__PURE__*/_react["default"].createElement(_grommet.TextInput, {
64
+ id: "request-name",
65
+ name: "name",
66
+ value: value.name,
67
+ onChange: function onChange(event) {
68
+ return setValue(function (currentValue) {
69
+ return _extends({}, currentValue, {
70
+ name: event.target.value
71
+ });
72
+ });
73
+ }
74
+ }));
75
+ }
76
+ }, {
77
+ id: 'review',
78
+ title: 'Review',
79
+ render: function render() {
80
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Paragraph, null, "Review the request for ", value.name || 'an unnamed request', ".");
81
+ }
82
+ }];
83
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
84
+ fill: true
85
+ }, /*#__PURE__*/_react["default"].createElement(_Wizard.Wizard, {
86
+ "aria-label": "New request",
87
+ form: false,
88
+ title: "New request",
89
+ showProgress: "vertical",
90
+ steps: steps,
91
+ footer: /*#__PURE__*/_react["default"].createElement(ExternalFormFooter, {
92
+ errors: errors
93
+ }),
94
+ onComplete: function onComplete() {
95
+ return setSubmittedValue(value);
96
+ }
97
+ }), submittedValue && /*#__PURE__*/_react["default"].createElement(_grommet.Notification, {
98
+ toast: {
99
+ position: 'top'
100
+ },
101
+ status: "normal",
102
+ title: "Request submitted",
103
+ message: "Created request " + submittedValue.name + ".",
104
+ onClose: function onClose() {
105
+ return setSubmittedValue(undefined);
106
+ }
107
+ }));
108
+ };
109
+ ExternalForm.args = {
110
+ full: true
111
+ };
112
+ var _default = exports["default"] = {
113
+ title: 'Layout/Wizard/External Form'
114
+ };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = exports.NonClosableHeader = void 0;
5
+ var _react = _interopRequireWildcard(require("react"));
6
+ var _grommet = require("grommet");
7
+ var _Wizard = require("../Wizard");
8
+ 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
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
10
+ // SPDX-License-Identifier: Apache-2.0
11
+
12
+ var steps = [{
13
+ id: 'details',
14
+ title: 'Details',
15
+ render: function render() {
16
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Paragraph, null, "Enter the request details.");
17
+ }
18
+ }, {
19
+ id: 'review',
20
+ title: 'Review',
21
+ render: function render() {
22
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Paragraph, null, "Review the request before submitting.");
23
+ }
24
+ }];
25
+ var NonClosableHeader = exports.NonClosableHeader = function NonClosableHeader() {
26
+ var _useState = (0, _react.useState)(false),
27
+ saved = _useState[0],
28
+ setSaved = _useState[1];
29
+ var title = /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
30
+ direction: "row",
31
+ align: "center",
32
+ gap: "medium",
33
+ flex: true
34
+ }, /*#__PURE__*/_react["default"].createElement(_grommet.Heading, {
35
+ level: 1,
36
+ size: "small",
37
+ margin: "none"
38
+ }, "New request"), /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
39
+ label: "Save draft",
40
+ onClick: function onClick() {
41
+ return setSaved(true);
42
+ }
43
+ }));
44
+ return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
45
+ fill: true
46
+ }, /*#__PURE__*/_react["default"].createElement(_Wizard.Wizard, {
47
+ "aria-label": "New request",
48
+ closable: false,
49
+ title: title,
50
+ showProgress: "horizontal",
51
+ steps: steps
52
+ }), saved && /*#__PURE__*/_react["default"].createElement(_grommet.Notification, {
53
+ toast: {
54
+ position: 'top'
55
+ },
56
+ status: "normal",
57
+ title: "Draft saved",
58
+ onClose: function onClose() {
59
+ return setSaved(false);
60
+ }
61
+ }));
62
+ };
63
+ NonClosableHeader.args = {
64
+ full: true
65
+ };
66
+ var _default = exports["default"] = {
67
+ title: 'Layout/Wizard/Non Closable Header'
68
+ };
@@ -20,7 +20,7 @@ var validatePassword = function validatePassword(password) {
20
20
  }
21
21
  return undefined;
22
22
  };
23
- var Validation = exports.Validation = function Validation() {
23
+ var ValidationExample = function ValidationExample() {
24
24
  var _useState = (0, _react.useState)(null),
25
25
  result = _useState[0],
26
26
  setResult = _useState[1];
@@ -81,6 +81,10 @@ var Validation = exports.Validation = function Validation() {
81
81
  id: 'confirm',
82
82
  title: 'Confirm',
83
83
  description: 'Ready to submit.',
84
+ skippable: true,
85
+ validate: function validate(value) {
86
+ return validateEmail(value.email);
87
+ },
84
88
  render: function render(step, api) {
85
89
  return /*#__PURE__*/_react["default"].createElement(_grommet.Paragraph, null, "Confirm sign-up for ", api.formValue.email, ".");
86
90
  }
@@ -91,16 +95,17 @@ var Validation = exports.Validation = function Validation() {
91
95
  "aria-label": "Sign up",
92
96
  title: "Create your account",
93
97
  showProgress: "vertical",
98
+ clickableSteps: true,
94
99
  steps: steps,
95
100
  defaultValue: {
96
101
  email: '',
97
102
  password: ''
98
103
  },
99
- onComplete: function onComplete(_ref) {
100
- var value = _ref.value;
101
- return setResult({
104
+ onComplete: function onComplete(results) {
105
+ console.log('Wizard complete with results:', results);
106
+ setResult({
102
107
  status: 'complete',
103
- value: value
108
+ value: results.value
104
109
  });
105
110
  }
106
111
  }), result && /*#__PURE__*/_react["default"].createElement(_grommet.Notification, {
@@ -115,9 +120,14 @@ var Validation = exports.Validation = function Validation() {
115
120
  }
116
121
  }));
117
122
  };
118
- Validation.args = {
119
- full: true
120
- };
121
123
  var _default = exports["default"] = {
122
124
  title: 'Layout/Wizard/Validation'
125
+ };
126
+ var Validation = exports.Validation = {
127
+ args: {
128
+ full: true
129
+ },
130
+ render: function render() {
131
+ return /*#__PURE__*/_react["default"].createElement(ValidationExample, null);
132
+ }
123
133
  };
@@ -204,7 +204,7 @@ var StyledBox = styled.div.withConfig({
204
204
  }, function (props) {
205
205
  return props.wrapProp && wrapStyle;
206
206
  }, function (props) {
207
- return props.overflowProp && overflowStyle(props.overflowProp);
207
+ return props.overflowProp && overflowStyle(props.overflowProp, props.theme);
208
208
  }, function (props) {
209
209
  return props.elevationProp && elevationStyle(props.elevationProp);
210
210
  }, function (props) {
@@ -0,0 +1,31 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+ import { Box, Text } from 'grommet';
5
+
6
+ // Colors whose light/dark classification flips between the legacy
7
+ // perceived-brightness formula and WCAG 2.2 relative luminance, evaluated
8
+ // against the default theme's actual text colors (#f8f8f8 / #444444),
9
+ // which raise the equal-contrast threshold to ~0.2766.
10
+ // https://github.com/grommet/grommet/issues/8151
11
+ var flippedColors = ['#00a4b3', '#17a398', '#00aaaa', '#00a0be'];
12
+
13
+ // Colors that classify the same under both formulas, used as anchors.
14
+ var stableColors = ['#000000', '#666666', '#999999', '#FFFFFF'];
15
+ export var ColorContrast = function ColorContrast() {
16
+ return /*#__PURE__*/React.createElement(Box, {
17
+ pad: "small",
18
+ gap: "small",
19
+ align: "start"
20
+ }, [].concat(flippedColors, stableColors).map(function (color) {
21
+ return /*#__PURE__*/React.createElement(Box, {
22
+ key: color,
23
+ pad: "small",
24
+ background: color,
25
+ width: "medium"
26
+ }, /*#__PURE__*/React.createElement(Text, null, color));
27
+ }));
28
+ };
29
+ export default {
30
+ title: 'Layout/Box/Color Contrast'
31
+ };
@@ -26,14 +26,20 @@ export var EllipsisAnimation = function EllipsisAnimation() {
26
26
  alignContent: "center",
27
27
  justify: "center"
28
28
  }, /*#__PURE__*/React.createElement(Box, {
29
+ flex: false,
30
+ basis: "auto",
29
31
  alignSelf: "center",
30
32
  direction: "row",
31
33
  gap: (_theme$button = theme.button) == null || (_theme$button = _theme$button.busy) == null ? void 0 : _theme$button.gap
32
34
  }, /*#__PURE__*/React.createElement(Dot, {
35
+ flex: false,
33
36
  delay: "-0.32s"
34
37
  }), /*#__PURE__*/React.createElement(Dot, {
38
+ flex: false,
35
39
  delay: "-0.16s"
36
- }), /*#__PURE__*/React.createElement(Dot, null)));
40
+ }), /*#__PURE__*/React.createElement(Dot, {
41
+ flex: false
42
+ })));
37
43
  };
38
44
  var grow = keyframes(["0%{opacity:0;transform:scale(.3);}20%{opacity:1;transform:scale(1.15);}30%{transform:scale(.9);}45%{transform:scale(1.05);}55%{transform:scale(1);}100%{transform:scale(1);}"]);
39
45
  export var GrowCheckmark = styled(Checkmark).withConfig({
@@ -291,7 +291,16 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
291
291
  // only used when theme does not have button.default
292
292
  var isDarkBackground = function isDarkBackground() {
293
293
  var backgroundColor = normalizeBackground(normalizeColor(color || theme.button.primary && theme.button.primary.color || theme.global.colors.control || 'brand', theme), theme);
294
- return colorIsDark(backgroundColor, theme);
294
+ return colorIsDark(backgroundColor, theme, theme.button.color);
295
+ };
296
+
297
+ // matches the text color backgroundStyle() selects for the label, so
298
+ // icon/animation colors stay in sync with an explicit theme.button.color.
299
+ // isDarkBackground() may be undefined (unknown shade); normalizeColor()
300
+ // then falls back to the ambient theme.dark, matching backgroundStyle().
301
+ var primaryTextColor = function primaryTextColor() {
302
+ var text = theme.button.color || theme.global.colors.text;
303
+ return normalizeColor(text, theme, isDarkBackground());
295
304
  };
296
305
  var onMouseOverButton = function onMouseOverButton(event) {
297
306
  setHover(true);
@@ -319,7 +328,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
319
328
  }
320
329
  } else if (primary) {
321
330
  buttonIcon = /*#__PURE__*/cloneElement(icon, {
322
- color: theme.global.colors.text[isDarkBackground() ? 'dark' : 'light']
331
+ color: primaryTextColor()
323
332
  });
324
333
  }
325
334
  } else if (kindIcon && !plain) {
@@ -383,7 +392,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
383
392
  animationColor = hover && getIconColor(themePaths.hover, theme) || getIconColor(themePaths.base, theme, color, kind);
384
393
  }
385
394
  } else if (primary) {
386
- animationColor = theme.global.colors.text[isDarkBackground() ? 'dark' : 'light'];
395
+ animationColor = primaryTextColor();
387
396
  }
388
397
  contents =
389
398
  /*#__PURE__*/
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import styled, { css } from 'styled-components';
4
- import { backgroundStyle, fillStyle, focusStyle, unfocusStyle, genericStyles, normalizeColor, styledComponentsConfig } from '../../utils';
4
+ import { backgroundStyle, fillStyle, focusStyle, unfocusStyle, genericStyles, overflowStyle, normalizeColor, styledComponentsConfig } from '../../utils';
5
5
  import { Box } from '../Box';
6
6
  import { TableRow } from '../TableRow';
7
7
  import { Table } from '../Table';
@@ -56,7 +56,7 @@ var StyledDataTableBody = styled(TableBody).withConfig({
56
56
  displayName: "StyledDataTable__StyledDataTableBody",
57
57
  componentId: "sc-xrlyjm-4"
58
58
  })(["", " &:focus{", "}&:focus:not(:focus-visible){", "}"], function (props) {
59
- return props.size && "\n display: block;\n width: 100%;\n max-height: " + (props.theme.global.size[props.size] || props.size) + ";\n overflow: auto;\n ";
59
+ return props.size && css(["display:block;width:100%;max-height:", ";", ""], props.theme.global.size[props.size] || props.size, overflowStyle('auto', props.theme));
60
60
  }, focusStyle({
61
61
  skipSvgChildren: true,
62
62
  forceOutline: true
@@ -305,7 +305,7 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
305
305
  })
306
306
  }, buttonProps));
307
307
  }
308
- var onClickCopy = function onClickCopy() {
308
+ var onCopy = function onCopy() {
309
309
  navigator.clipboard.writeText(textValue);
310
310
  announce(readOnlyCopyValidation, 'assertive');
311
311
  setTip(readOnlyCopyValidation);
@@ -315,9 +315,9 @@ var DateInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
315
315
  };
316
316
  var DateInputButton = readOnlyCopy ? /*#__PURE__*/React.createElement(CopyButton, {
317
317
  disabled: disabled,
318
+ messages: messages,
318
319
  onBlurCopy: onBlurCopy,
319
- onClickCopy: onClickCopy,
320
- readOnlyCopyPrompt: readOnlyCopyPrompt,
320
+ onCopy: onCopy,
321
321
  tip: tip,
322
322
  value: value
323
323
  }) : /*#__PURE__*/React.createElement(Button, {
@@ -330,7 +330,7 @@ var formatSectionText = function formatSectionText(section, value) {
330
330
  return pad(value);
331
331
  };
332
332
  var DateTimeInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
333
- var _theme$dateTimeInput, _theme$global$edgeSiz, _theme$global$edgeSiz2, _theme$dateTimeInput2, _theme$dateTimeInput3, _theme$dateTimeInput4, _theme$dateTimeInput5, _theme$calendar, _theme$dateTimeInput6, _theme$dateTimeInput7, _theme$dateTimeInput8, _theme$dateTimeInput9;
333
+ var _theme$dateTimeInput, _theme$global$edgeSiz, _theme$global$edgeSiz2, _theme$dateTimeInput2, _theme$dateTimeInput3, _theme$dateTimeInput4, _theme$dateTimeInput5, _theme$dateTimeInput6, _theme$calendar, _theme$dateTimeInput7, _theme$dateTimeInput8, _theme$dateTimeInput9, _theme$dateTimeInput0;
334
334
  var defaultValue = _ref.defaultValue,
335
335
  disabled = _ref.disabled,
336
336
  format = _ref.format,
@@ -951,29 +951,34 @@ var DateTimeInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
951
951
  "aria-label": groupLabel,
952
952
  "aria-labelledby": formFieldLabelId,
953
953
  direction: "row",
954
+ cssGap: true,
954
955
  pad: (_theme$dateTimeInput3 = theme.dateTimeInput) == null || (_theme$dateTimeInput3 = _theme$dateTimeInput3.drop) == null ? void 0 : _theme$dateTimeInput3.pad,
955
- gap: (_theme$dateTimeInput4 = theme.dateTimeInput) == null || (_theme$dateTimeInput4 = _theme$dateTimeInput4.drop) == null ? void 0 : _theme$dateTimeInput4.gap
956
+ gap: (_theme$dateTimeInput4 = theme.dateTimeInput) == null || (_theme$dateTimeInput4 = _theme$dateTimeInput4.drop) == null ? void 0 : _theme$dateTimeInput4.gap,
957
+ height: (_theme$dateTimeInput5 = theme.dateTimeInput) == null || (_theme$dateTimeInput5 = _theme$dateTimeInput5.drop) == null ? void 0 : _theme$dateTimeInput5.height
956
958
  }, /*#__PURE__*/React.createElement(ThemeContext.Extend, {
957
959
  value: {
958
960
  calendar: {
959
961
  day: {
960
962
  selected: {
961
- background: ((_theme$dateTimeInput5 = theme.dateTimeInput) == null || (_theme$dateTimeInput5 = _theme$dateTimeInput5.calendar) == null || (_theme$dateTimeInput5 = _theme$dateTimeInput5.day) == null || (_theme$dateTimeInput5 = _theme$dateTimeInput5.selected) == null ? void 0 : _theme$dateTimeInput5.background) || ((_theme$calendar = theme.calendar) == null || (_theme$calendar = _theme$calendar.day) == null || (_theme$calendar = _theme$calendar.selected) == null ? void 0 : _theme$calendar.background)
963
+ background: ((_theme$dateTimeInput6 = theme.dateTimeInput) == null || (_theme$dateTimeInput6 = _theme$dateTimeInput6.calendar) == null || (_theme$dateTimeInput6 = _theme$dateTimeInput6.day) == null || (_theme$dateTimeInput6 = _theme$dateTimeInput6.selected) == null ? void 0 : _theme$dateTimeInput6.background) || ((_theme$calendar = theme.calendar) == null || (_theme$calendar = _theme$calendar.day) == null || (_theme$calendar = _theme$calendar.selected) == null ? void 0 : _theme$calendar.background)
962
964
  }
963
965
  }
964
966
  }
965
967
  }
968
+ }, /*#__PURE__*/React.createElement(Box, {
969
+ width: "medium",
970
+ flex: false
966
971
  }, /*#__PURE__*/React.createElement(Calendar, {
967
972
  date: getCalendarDate(sections),
968
973
  initialFocus: inline ? undefined : 'days',
969
- onSelect: disabled || readOnly ? undefined : handleCalendarSelect
970
- })), /*#__PURE__*/React.createElement(Box, {
974
+ onSelect: disabled || readOnly ? undefined : handleCalendarSelect,
975
+ fill: true
976
+ }))), /*#__PURE__*/React.createElement(Box, {
971
977
  alignSelf: "stretch",
972
- flex: false,
973
978
  border: {
974
979
  side: 'start',
975
- color: (_theme$dateTimeInput6 = theme.dateTimeInput) == null || (_theme$dateTimeInput6 = _theme$dateTimeInput6.drop) == null || (_theme$dateTimeInput6 = _theme$dateTimeInput6.border) == null ? void 0 : _theme$dateTimeInput6.color,
976
- size: (_theme$dateTimeInput7 = theme.dateTimeInput) == null || (_theme$dateTimeInput7 = _theme$dateTimeInput7.drop) == null || (_theme$dateTimeInput7 = _theme$dateTimeInput7.border) == null ? void 0 : _theme$dateTimeInput7.size
980
+ color: (_theme$dateTimeInput7 = theme.dateTimeInput) == null || (_theme$dateTimeInput7 = _theme$dateTimeInput7.drop) == null || (_theme$dateTimeInput7 = _theme$dateTimeInput7.border) == null ? void 0 : _theme$dateTimeInput7.color,
981
+ size: (_theme$dateTimeInput8 = theme.dateTimeInput) == null || (_theme$dateTimeInput8 = _theme$dateTimeInput8.drop) == null || (_theme$dateTimeInput8 = _theme$dateTimeInput8.border) == null ? void 0 : _theme$dateTimeInput8.size
977
982
  }
978
983
  }), /*#__PURE__*/React.createElement(TimeInput, {
979
984
  inline: true,
@@ -986,7 +991,8 @@ var DateTimeInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
986
991
  disabled: disabled,
987
992
  readOnly: readOnly,
988
993
  onChange: disabled || readOnly ? undefined : handleTimeSelect,
989
- onPartialChange: disabled || readOnly ? undefined : handleTimePartialChange
994
+ onPartialChange: disabled || readOnly ? undefined : handleTimePartialChange,
995
+ fill: true
990
996
  }));
991
997
  if (inline) {
992
998
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", _extends({}, rest, {
@@ -1007,7 +1013,7 @@ var DateTimeInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
1007
1013
  direction: "row",
1008
1014
  border: !plainProp,
1009
1015
  fill: true,
1010
- round: (_theme$dateTimeInput8 = theme.dateTimeInput) == null || (_theme$dateTimeInput8 = _theme$dateTimeInput8.container) == null ? void 0 : _theme$dateTimeInput8.round,
1016
+ round: (_theme$dateTimeInput9 = theme.dateTimeInput) == null || (_theme$dateTimeInput9 = _theme$dateTimeInput9.container) == null ? void 0 : _theme$dateTimeInput9.round,
1011
1017
  disabled: disabled,
1012
1018
  readOnlyProp: readOnly,
1013
1019
  focusIndicator: focusIndicatorProp != null ? focusIndicatorProp : true
@@ -1075,7 +1081,7 @@ var DateTimeInput = /*#__PURE__*/forwardRef(function (_ref, refArg) {
1075
1081
  icon: /*#__PURE__*/React.createElement(CalendarIcon, null),
1076
1082
  plain: true,
1077
1083
  disabled: disabled,
1078
- margin: (_theme$dateTimeInput9 = theme.dateTimeInput) == null || (_theme$dateTimeInput9 = _theme$dateTimeInput9.button) == null ? void 0 : _theme$dateTimeInput9.margin,
1084
+ margin: (_theme$dateTimeInput0 = theme.dateTimeInput) == null || (_theme$dateTimeInput0 = _theme$dateTimeInput0.button) == null ? void 0 : _theme$dateTimeInput0.margin,
1079
1085
  "aria-label": formatMessage({
1080
1086
  id: 'dateTimeInput.chooseDateTime',
1081
1087
  messages: messages
@@ -6,6 +6,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
6
6
  import React, { useEffect, useRef, useState } from 'react';
7
7
  import { makeNodeFocusable, makeNodeUnfocusable } from '../utils';
8
8
  import { RootsContext, useRoots } from '../contexts/RootsContext';
9
+ import { useLayoutEffect } from '../utils/use-isomorphic-layout-effect';
9
10
  var isFocusable = function isFocusable(element) {
10
11
  if ((element == null ? void 0 : element.tabIndex) < 0 || element != null && element.disabled) {
11
12
  return false;
@@ -47,7 +48,7 @@ export var FocusedContainer = function FocusedContainer(_ref) {
47
48
  // set this to true so handleTrapFocus doesn't focus the element.
48
49
  var ignoreUtilFocusRef = useRef(false);
49
50
  var lastFocusRef = useRef(null);
50
- useEffect(function () {
51
+ useLayoutEffect(function () {
51
52
  var container = ref.current;
52
53
  var roots = contextRoots.current;
53
54
  var attemptFocus = function attemptFocus(element) {
@@ -23,6 +23,7 @@ import { Text } from '../Text';
23
23
  import { TextInput } from '../TextInput';
24
24
  import { FormContext } from '../Form/FormContext';
25
25
  import { FormFieldPropTypes } from './propTypes';
26
+ import { FormFieldContext } from './FormFieldContext';
26
27
  import { useThemeValue } from '../../utils/useThemeValue';
27
28
  import { AnnounceContext } from '../../contexts/AnnounceContext';
28
29
  var grommetInputFocusNames = ['CheckBox', 'CheckBoxGroup', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
@@ -36,9 +37,10 @@ var getFocusStyle = function getFocusStyle(props) {
36
37
  if (props.focus && props.containerFocus === false && ((_props$theme$formFiel = props.theme.formField) == null || (_props$theme$formFiel = _props$theme$formFiel.focus) == null ? void 0 : _props$theme$formFiel.containerFocus) === false) {
37
38
  return null;
38
39
  }
39
- return props.focus ? focusStyle({
40
+ if (!props.focus) return undefined;
41
+ return focusStyle({
40
42
  justBorder: true
41
- }) : undefined;
43
+ });
42
44
  };
43
45
 
44
46
  // The border color has to be painted by whichever element owns the border,
@@ -279,6 +281,15 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
279
281
  var _useState = useState(),
280
282
  focus = _useState[0],
281
283
  setFocus = _useState[1];
284
+ var _useState2 = useState(true),
285
+ focusIndicator = _useState2[0],
286
+ setFocusIndicator = _useState2[1];
287
+ var fieldFocus = focus && focusIndicator;
288
+ var fieldContext = useMemo(function () {
289
+ return {
290
+ setFocusIndicator: setFocusIndicator
291
+ };
292
+ }, []);
282
293
  var formFieldRef = useForwardedRef(ref);
283
294
  var formFieldTheme = theme.formField;
284
295
  var themeBorder = formFieldTheme.border;
@@ -441,7 +452,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
441
452
  } else if (formFieldTheme.error.border && formFieldTheme.error.border.color) {
442
453
  borderColor = formFieldTheme.error.border.color || 'status-critical';
443
454
  }
444
- } else if (focus && formFieldTheme.focus && formFieldTheme.focus.border && formFieldTheme.focus.border.color) {
455
+ } else if (fieldFocus && formFieldTheme.focus && formFieldTheme.focus.border && formFieldTheme.focus.border.color) {
445
456
  borderColor = formFieldTheme.focus.border.color;
446
457
  } else {
447
458
  borderColor = themeBorder && themeBorder.color || 'border';
@@ -474,7 +485,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
474
485
  color: borderColor
475
486
  }),
476
487
  round: formFieldTheme.round,
477
- focus: isFileInputComponent ? undefined : focus
488
+ focus: isFileInputComponent ? undefined : fieldFocus
478
489
  } : {};
479
490
  contents = /*#__PURE__*/React.createElement(FormFieldContentBox, _extends({
480
491
  disabledProp: disabled,
@@ -502,8 +513,8 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
502
513
  };
503
514
  }
504
515
  outerStyle = _extends({
505
- position: focus ? 'relative' : undefined,
506
- zIndex: focus ? 10 : undefined
516
+ position: fieldFocus ? 'relative' : undefined,
517
+ zIndex: fieldFocus ? 10 : undefined
507
518
  }, style);
508
519
  }
509
520
  }
@@ -511,7 +522,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
511
522
  if (themeBorder && themeBorder.position === 'outer') {
512
523
  if (error && formFieldTheme.error && formFieldTheme.error.background) {
513
524
  outerBackground = formFieldTheme.error.background;
514
- } else if (focus && formFieldTheme.focus && formFieldTheme.focus.background && formFieldTheme.focus.background.color) {
525
+ } else if (fieldFocus && formFieldTheme.focus && formFieldTheme.focus.background && formFieldTheme.focus.background.color) {
515
526
  outerBackground = formFieldTheme.focus.background.color;
516
527
  } else if (disabled && formFieldTheme.disabled && formFieldTheme.disabled.background) {
517
528
  outerBackground = formFieldTheme.disabled.background;
@@ -522,7 +533,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
522
533
  color: borderColor
523
534
  }),
524
535
  round: formFieldTheme.round,
525
- focus: focus
536
+ focus: fieldFocus
526
537
  } : {};
527
538
  var requiredIndicator = theme.formField.label.requiredIndicator;
528
539
  if (requiredIndicator === true)
@@ -547,6 +558,9 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
547
558
  ,
548
559
  allowHover: allowHover // internal prop
549
560
  ,
561
+ onFocusCapture: function onFocusCapture() {
562
+ return setFocusIndicator(true);
563
+ },
550
564
  onFocus: function onFocus(event) {
551
565
  var _formFieldRef$current;
552
566
  var root = (_formFieldRef$current = formFieldRef.current) == null ? void 0 : _formFieldRef$current.getRootNode();
@@ -556,7 +570,12 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
556
570
  if (_onFocus) _onFocus(event);
557
571
  },
558
572
  onBlur: function onBlur(event) {
559
- setFocus(false);
573
+ var _formFieldRef$current2;
574
+ var focusRemainsInside = (_formFieldRef$current2 = formFieldRef.current) == null ? void 0 : _formFieldRef$current2.contains(event.relatedTarget);
575
+ if (!focusRemainsInside) {
576
+ setFocus(false);
577
+ setFocusIndicator(true);
578
+ }
560
579
 
561
580
  // if input has a drop and focus is within drop
562
581
  // prevent onBlur validation from running until
@@ -581,7 +600,9 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
581
600
  htmlFor: adjustedHtmlFor
582
601
  }, labelStyle), label, showRequiredIndicator ? requiredIndicator : undefined), /*#__PURE__*/React.createElement(Message, _extends({
583
602
  message: help
584
- }, themeHelpProps))) : undefined, contents, /*#__PURE__*/React.createElement(Message, _extends({
603
+ }, themeHelpProps))) : undefined, /*#__PURE__*/React.createElement(FormFieldContext.Provider, {
604
+ value: fieldContext
605
+ }, contents), /*#__PURE__*/React.createElement(Message, _extends({
585
606
  type: "error",
586
607
  message: error
587
608
  }, formFieldTheme.error, {
@@ -0,0 +1,7 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+
5
+ // Internal focus-indicator ownership contract. Descendants can keep normal
6
+ // focus/blur events while opting to display their own indicator.
7
+ export var FormFieldContext = /*#__PURE__*/React.createContext({});
@@ -15,6 +15,7 @@ import { format as _format, MessageContext } from '../../contexts/MessageContext
15
15
  import defaultMessages from '../../languages/default.json';
16
16
  import { GrommetPropTypes } from './propTypes';
17
17
  import { AnalyticsProvider } from '../../contexts/AnalyticsContext';
18
+ import { LEGACY_COLOR_IS_DARK } from '../../utils/legacyColorIsDark';
18
19
  var FullGlobalStyle = createGlobalStyle(["body{margin:0;}"]);
19
20
  var defaultOptions = {};
20
21
  var Grommet = /*#__PURE__*/forwardRef(function (props, ref) {
@@ -32,11 +33,13 @@ var Grommet = /*#__PURE__*/forwardRef(function (props, ref) {
32
33
  dir = props.dir,
33
34
  themeMode = props.themeMode,
34
35
  userAgent = props.userAgent;
36
+ var legacyColorIsDark = options.legacyColorIsDark === true;
35
37
  var _useState = useState(),
36
38
  stateResponsive = _useState[0],
37
39
  setResponsive = _useState[1];
38
40
  var theme = useMemo(function () {
39
41
  var nextTheme = deepMerge(baseTheme, themeProp || {});
42
+ nextTheme[LEGACY_COLOR_IS_DARK] = legacyColorIsDark;
40
43
 
41
44
  // if user provides specific menu alignment, we don't want
42
45
  // the defaults to be included at all (can cause issues with controlMirror)
@@ -60,7 +63,7 @@ var Grommet = /*#__PURE__*/forwardRef(function (props, ref) {
60
63
  nextTheme.dir = dir;
61
64
  }
62
65
  return nextTheme;
63
- }, [background, dir, themeMode, themeProp]);
66
+ }, [background, dir, legacyColorIsDark, themeMode, themeProp]);
64
67
  var messages = useMemo(function () {
65
68
  // combine the passed in messages, if any, with the default
66
69
  // messages and format function.