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
@@ -11,7 +11,10 @@ var _Box = require("../Box");
11
11
  var _Drop = require("../Drop");
12
12
  var _Text = require("../Text");
13
13
  var _utils2 = require("./utils");
14
- var _excluded = ["activeSection", "align", "format", "formatMessage", "hoursOptions", "focusOnOpen", "id", "incrementSection", "messages", "minuteOptions", "onClose", "onFocusLeave", "secondOptions", "sectionOrder", "sections", "setActiveSection", "setSectionValue", "target", "dropProps", "label", "inline", "onKeyDown"]; // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
14
+ var _excluded = ["hover", "selected"],
15
+ _excluded2 = ["hover"],
16
+ _excluded3 = ["activeSection", "align", "format", "formatMessage", "hoursOptions", "focusOnOpen", "id", "incrementSection", "messages", "minuteOptions", "onClose", "onFocusLeave", "secondOptions", "sectionOrder", "sections", "setActiveSection", "setSectionValue", "target", "dropProps", "label", "inline", "onKeyDown"],
17
+ _excluded4 = ["column", "option"]; // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
15
18
  // SPDX-License-Identifier: Apache-2.0
16
19
  /* eslint-disable max-len */
17
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -21,36 +24,22 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
21
24
  var PopupColumnBox = (0, _styledComponents["default"])(_Box.Box).withConfig({
22
25
  displayName: "TimeInputPopup__PopupColumnBox",
23
26
  componentId: "sc-r2j8uh-0"
24
- })(["scrollbar-gutter:stable;scrollbar-width:thin;"]);
25
- var PopupOption = _styledComponents["default"].div.withConfig({
27
+ })(["scrollbar-gutter:stable;"]);
28
+ var PopupOption = (0, _styledComponents["default"])(_Box.Box).withConfig({
26
29
  displayName: "TimeInputPopup__PopupOption",
27
30
  componentId: "sc-r2j8uh-1"
28
- })(["box-sizing:border-box;cursor:pointer;display:flex;justify-content:center;", " ", " background:", ";&:hover{background:", ";}&:focus-visible{", "}"], function (props) {
29
- var _props$theme$timeInpu;
30
- var optionPad = (_props$theme$timeInpu = props.theme.timeInput) == null || (_props$theme$timeInpu = _props$theme$timeInpu.drop) == null || (_props$theme$timeInpu = _props$theme$timeInpu.option) == null ? void 0 : _props$theme$timeInpu.pad;
31
- return optionPad && (0, _utils.edgeStyle)('padding', optionPad, false, props.theme.box.responsiveBreakpoint, props.theme);
32
- }, function (props) {
33
- var _props$theme$timeInpu2, _props$theme$global$c;
34
- var round = ((_props$theme$timeInpu2 = props.theme.timeInput) == null || (_props$theme$timeInpu2 = _props$theme$timeInpu2.drop) == null || (_props$theme$timeInpu2 = _props$theme$timeInpu2.option) == null ? void 0 : _props$theme$timeInpu2.round) || ((_props$theme$global$c = props.theme.global.control) == null || (_props$theme$global$c = _props$theme$global$c.border) == null ? void 0 : _props$theme$global$c.radius);
35
- return round && (0, _utils.roundStyle)(round, false, props.theme);
36
- }, function (props) {
37
- var _props$theme$timeInpu5;
38
- if (props.$selected) {
39
- var _props$theme$timeInpu3;
40
- return (0, _utils.normalizeColor)((_props$theme$timeInpu3 = props.theme.timeInput) == null || (_props$theme$timeInpu3 = _props$theme$timeInpu3.drop) == null || (_props$theme$timeInpu3 = _props$theme$timeInpu3.option) == null || (_props$theme$timeInpu3 = _props$theme$timeInpu3.selected) == null ? void 0 : _props$theme$timeInpu3.background, props.theme);
41
- }
42
- if (props.$active) {
43
- var _props$theme$timeInpu4;
44
- return (0, _utils.normalizeColor)((_props$theme$timeInpu4 = props.theme.timeInput) == null || (_props$theme$timeInpu4 = _props$theme$timeInpu4.drop) == null || (_props$theme$timeInpu4 = _props$theme$timeInpu4.option) == null || (_props$theme$timeInpu4 = _props$theme$timeInpu4.hover) == null ? void 0 : _props$theme$timeInpu4.background, props.theme);
45
- }
46
- return (0, _utils.normalizeColor)((_props$theme$timeInpu5 = props.theme.timeInput) == null || (_props$theme$timeInpu5 = _props$theme$timeInpu5.drop) == null || (_props$theme$timeInpu5 = _props$theme$timeInpu5.option) == null ? void 0 : _props$theme$timeInpu5.background, props.theme);
47
- }, function (props) {
48
- var _props$theme$timeInpu8;
49
- if (props.$selected) {
50
- var _props$theme$timeInpu6, _props$theme$timeInpu7;
51
- return (0, _utils.normalizeColor)(((_props$theme$timeInpu6 = props.theme.timeInput) == null || (_props$theme$timeInpu6 = _props$theme$timeInpu6.drop) == null || (_props$theme$timeInpu6 = _props$theme$timeInpu6.option) == null || (_props$theme$timeInpu6 = _props$theme$timeInpu6.selected) == null || (_props$theme$timeInpu6 = _props$theme$timeInpu6.hover) == null ? void 0 : _props$theme$timeInpu6.background) || ((_props$theme$timeInpu7 = props.theme.timeInput) == null || (_props$theme$timeInpu7 = _props$theme$timeInpu7.drop) == null || (_props$theme$timeInpu7 = _props$theme$timeInpu7.option) == null || (_props$theme$timeInpu7 = _props$theme$timeInpu7.selected) == null ? void 0 : _props$theme$timeInpu7.background), props.theme);
52
- }
53
- return (0, _utils.normalizeColor)((_props$theme$timeInpu8 = props.theme.timeInput) == null || (_props$theme$timeInpu8 = _props$theme$timeInpu8.drop) == null || (_props$theme$timeInpu8 = _props$theme$timeInpu8.option) == null || (_props$theme$timeInpu8 = _props$theme$timeInpu8.hover) == null ? void 0 : _props$theme$timeInpu8.background, props.theme);
31
+ })(["cursor:pointer;&:hover{", "}&:focus-visible{", "}"], function (props) {
32
+ var theme = props.theme,
33
+ $hoverState = props.$hoverState,
34
+ $hoverBackground = props.$hoverBackground;
35
+ var responsive = props.responsive === undefined ? true : props.responsive;
36
+ var styles = [];
37
+ if ($hoverBackground !== undefined) styles.push((0, _utils.backgroundStyle)($hoverBackground, theme));
38
+ if (($hoverState == null ? void 0 : $hoverState.border) !== undefined) styles.push((0, _utils.borderStyle)($hoverState.border, responsive, theme));
39
+ if (($hoverState == null ? void 0 : $hoverState.elevation) !== undefined) styles.push((0, _utils.elevationStyle)($hoverState.elevation));
40
+ if (($hoverState == null ? void 0 : $hoverState.pad) !== undefined) styles.push((0, _utils.edgeStyle)('padding', $hoverState.pad, responsive, theme.box.responsiveBreakpoint, theme));
41
+ if (($hoverState == null ? void 0 : $hoverState.round) !== undefined) styles.push($hoverState.round === false ? 'border-radius: 0;' : (0, _utils.roundStyle)($hoverState.round, responsive, theme));
42
+ return styles;
54
43
  }, (0, _utils.focusStyle)({
55
44
  inset: true
56
45
  }));
@@ -69,7 +58,7 @@ var getDefaultPopupOption = function getDefaultPopupOption(_ref) {
69
58
  return options[0];
70
59
  };
71
60
  var PopupColumn = function PopupColumn(_ref2) {
72
- var _theme$global$size, _theme$timeInput, _theme$timeInput2;
61
+ var _theme$timeInput;
73
62
  var activeSection = _ref2.activeSection,
74
63
  format = _ref2.format,
75
64
  formatMessage = _ref2.formatMessage,
@@ -77,37 +66,40 @@ var PopupColumn = function PopupColumn(_ref2) {
77
66
  label = _ref2.label,
78
67
  messages = _ref2.messages,
79
68
  onClickCommitOption = _ref2.onClickCommitOption,
80
- onPointerCommitOption = _ref2.onPointerCommitOption,
81
69
  onSetSection = _ref2.onSetSection,
82
70
  options = _ref2.options,
83
71
  section = _ref2.section,
84
72
  sections = _ref2.sections,
85
- theme = _ref2.theme;
86
- // When inline (in DateTimeInput), use 'medium' to match Calendar height.
87
- // Otherwise use timeInput drop maxHeight with fallback to 'small'.
88
- var maxHeightToken = inline ? 'medium' : null;
89
- var maxHeight = maxHeightToken && ((_theme$global$size = theme.global.size) == null ? void 0 : _theme$global$size[maxHeightToken]) || ((_theme$timeInput = theme.timeInput) == null || (_theme$timeInput = _theme$timeInput.drop) == null || (_theme$timeInput = _theme$timeInput.column) == null ? void 0 : _theme$timeInput.maxHeight) || theme.global.size.small;
90
- return /*#__PURE__*/_react["default"].createElement(PopupColumnBox, {
73
+ theme = _ref2.theme,
74
+ passThemeFlag = _ref2.passThemeFlag;
75
+ var columnTheme = ((_theme$timeInput = theme.timeInput) == null || (_theme$timeInput = _theme$timeInput.drop) == null ? void 0 : _theme$timeInput.column) || {};
76
+ return /*#__PURE__*/_react["default"].createElement(PopupColumnBox, _extends({
91
77
  role: "listbox",
92
78
  "aria-label": label,
93
- gap: ((_theme$timeInput2 = theme.timeInput) == null || (_theme$timeInput2 = _theme$timeInput2.drop) == null || (_theme$timeInput2 = _theme$timeInput2.option) == null ? void 0 : _theme$timeInput2.gap) || 'xxsmall',
94
- height: {
95
- max: maxHeight
96
- },
97
79
  overflow: "auto",
98
80
  flex: {
99
81
  grow: 0,
100
82
  shrink: 0
101
83
  }
102
- }, options.map(function (option) {
103
- var _theme$timeInput3, _theme$timeInput4, _theme$timeInput5;
84
+ }, columnTheme, passThemeFlag), options.map(function (option) {
85
+ var _theme$timeInput2, _theme$timeInput3, _theme$timeInput4, _theme$timeInput5, _ref3, _hoverState$backgroun, _theme$timeInput6, _theme$timeInput7, _theme$timeInput8, _theme$timeInput$drop, _theme$timeInput9, _theme$timeInput0, _theme$timeInput1;
104
86
  var key = optionKey(label, option);
105
87
  var sectionHasValue = section === _utils2.SECTION_HOUR && sections.hour !== undefined || section === _utils2.SECTION_MINUTE && sections.minute !== undefined || section === _utils2.SECTION_SECOND && sections.second !== undefined || section === _utils2.SECTION_PERIOD && sections.period !== undefined;
106
88
 
107
89
  // In empty state, keep focus defaults but avoid visually selecting
108
90
  // options until the user makes an explicit choice.
109
91
  var selected = section === _utils2.SECTION_HOUR && sections.hour === option || section === _utils2.SECTION_MINUTE && sections.minute === option || section === _utils2.SECTION_SECOND && sections.second === option || section === _utils2.SECTION_PERIOD && sections.period === option;
110
- var optionColor = selected ? ((_theme$timeInput3 = theme.timeInput) == null || (_theme$timeInput3 = _theme$timeInput3.drop) == null || (_theme$timeInput3 = _theme$timeInput3.option) == null || (_theme$timeInput3 = _theme$timeInput3.selected) == null ? void 0 : _theme$timeInput3.color) || 'text' : 'text';
92
+ var optionColor = selected ? ((_theme$timeInput2 = theme.timeInput) == null || (_theme$timeInput2 = _theme$timeInput2.drop) == null || (_theme$timeInput2 = _theme$timeInput2.option) == null || (_theme$timeInput2 = _theme$timeInput2.text) == null || (_theme$timeInput2 = _theme$timeInput2.selected) == null ? void 0 : _theme$timeInput2.color) || ((_theme$timeInput3 = theme.timeInput) == null || (_theme$timeInput3 = _theme$timeInput3.drop) == null || (_theme$timeInput3 = _theme$timeInput3.option) == null || (_theme$timeInput3 = _theme$timeInput3.text) == null ? void 0 : _theme$timeInput3.color) || 'text' : ((_theme$timeInput4 = theme.timeInput) == null || (_theme$timeInput4 = _theme$timeInput4.drop) == null || (_theme$timeInput4 = _theme$timeInput4.option) == null || (_theme$timeInput4 = _theme$timeInput4.text) == null ? void 0 : _theme$timeInput4.color) || 'text';
93
+ var optionContainer = ((_theme$timeInput5 = theme.timeInput) == null || (_theme$timeInput5 = _theme$timeInput5.drop) == null || (_theme$timeInput5 = _theme$timeInput5.option) == null ? void 0 : _theme$timeInput5.container) || {};
94
+ var optionHover = optionContainer.hover,
95
+ _optionContainer$sele = optionContainer.selected,
96
+ selectedContainer = _optionContainer$sele === void 0 ? {} : _optionContainer$sele,
97
+ baseOptionStyles = _objectWithoutPropertiesLoose(optionContainer, _excluded);
98
+ var selectedHover = selectedContainer.hover,
99
+ selectedOptionStyles = _objectWithoutPropertiesLoose(selectedContainer, _excluded2);
100
+ var optionStyles = selected ? _extends({}, baseOptionStyles, selectedOptionStyles) : baseOptionStyles;
101
+ var hoverState = selected ? selectedHover : optionHover;
102
+ var hoverBackground = selected ? (_ref3 = (_hoverState$backgroun = hoverState == null ? void 0 : hoverState.background) != null ? _hoverState$backgroun : selectedContainer.background) != null ? _ref3 : baseOptionStyles.background : hoverState == null ? void 0 : hoverState.background;
111
103
  var isActive = selected && activeSection === section;
112
104
  var optionTabIndex = -1;
113
105
  if (inline) {
@@ -124,66 +116,66 @@ var PopupColumn = function PopupColumn(_ref2) {
124
116
  } else if (isActive) {
125
117
  optionTabIndex = 0;
126
118
  }
127
- return /*#__PURE__*/_react["default"].createElement(PopupOption, {
119
+ return /*#__PURE__*/_react["default"].createElement(PopupOption, _extends({
128
120
  key: key,
129
- "data-option-key": key,
130
121
  role: "option",
122
+ "data-option-key": key,
131
123
  "aria-selected": selected,
132
124
  tabIndex: optionTabIndex,
133
125
  "aria-label": (section === _utils2.SECTION_PERIOD ? option : (0, _utils2.pad)(option)) + " " + (0, _utils2.getSectionName)(section, format, formatMessage, messages),
134
- $active: isActive,
135
- $selected: selected,
136
- onMouseDown: function onMouseDown(event) {
137
- if (event.button !== 0) return;
138
- // Commit on pointer press so momentum scroll does not swallow
139
- // the first click commit on some trackpad/mouse flows.
140
- onPointerCommitOption(section, option);
141
- },
126
+ flex: false,
127
+ $hoverState: hoverState,
128
+ $hoverBackground: hoverBackground
129
+ }, optionStyles, {
130
+ // This option owns its inset :focus-visible indicator. Box's
131
+ // focus tracking can retain state when tabIndex becomes -1.
132
+ focusIndicator: false,
142
133
  onClick: function onClick() {
143
134
  return onClickCommitOption(section, option);
144
135
  },
145
136
  onFocus: function onFocus() {
146
137
  return onSetSection(section);
147
138
  }
148
- }, /*#__PURE__*/_react["default"].createElement(_Text.Text, {
149
- size: ((_theme$timeInput4 = theme.timeInput) == null || (_theme$timeInput4 = _theme$timeInput4.drop) == null || (_theme$timeInput4 = _theme$timeInput4.option) == null ? void 0 : _theme$timeInput4.size) || theme.global.input.font.size || 'small',
150
- weight: selected ? (_theme$timeInput5 = theme.timeInput) == null || (_theme$timeInput5 = _theme$timeInput5.drop) == null || (_theme$timeInput5 = _theme$timeInput5.option) == null || (_theme$timeInput5 = _theme$timeInput5.selected) == null || (_theme$timeInput5 = _theme$timeInput5.text) == null ? void 0 : _theme$timeInput5.weight : undefined,
151
- color: optionColor
139
+ }), /*#__PURE__*/_react["default"].createElement(_Text.Text, {
140
+ size: selected ? ((_theme$timeInput6 = theme.timeInput) == null || (_theme$timeInput6 = _theme$timeInput6.drop) == null || (_theme$timeInput6 = _theme$timeInput6.option) == null || (_theme$timeInput6 = _theme$timeInput6.text) == null || (_theme$timeInput6 = _theme$timeInput6.selected) == null ? void 0 : _theme$timeInput6.size) || ((_theme$timeInput7 = theme.timeInput) == null || (_theme$timeInput7 = _theme$timeInput7.drop) == null || (_theme$timeInput7 = _theme$timeInput7.option) == null || (_theme$timeInput7 = _theme$timeInput7.text) == null ? void 0 : _theme$timeInput7.size) || theme.global.input.font.size || 'small' : ((_theme$timeInput8 = theme.timeInput) == null || (_theme$timeInput8 = _theme$timeInput8.drop) == null || (_theme$timeInput8 = _theme$timeInput8.option) == null || (_theme$timeInput8 = _theme$timeInput8.text) == null ? void 0 : _theme$timeInput8.size) || theme.global.input.font.size || 'small',
141
+ weight: selected ? (_theme$timeInput$drop = (_theme$timeInput9 = theme.timeInput) == null || (_theme$timeInput9 = _theme$timeInput9.drop) == null || (_theme$timeInput9 = _theme$timeInput9.option) == null || (_theme$timeInput9 = _theme$timeInput9.text) == null || (_theme$timeInput9 = _theme$timeInput9.selected) == null ? void 0 : _theme$timeInput9.weight) != null ? _theme$timeInput$drop : (_theme$timeInput0 = theme.timeInput) == null || (_theme$timeInput0 = _theme$timeInput0.drop) == null || (_theme$timeInput0 = _theme$timeInput0.option) == null || (_theme$timeInput0 = _theme$timeInput0.text) == null ? void 0 : _theme$timeInput0.weight : (_theme$timeInput1 = theme.timeInput) == null || (_theme$timeInput1 = _theme$timeInput1.drop) == null || (_theme$timeInput1 = _theme$timeInput1.option) == null || (_theme$timeInput1 = _theme$timeInput1.text) == null ? void 0 : _theme$timeInput1.weight,
142
+ color: optionColor,
143
+ textAlign: "center"
152
144
  }, section === _utils2.SECTION_PERIOD ? option : (0, _utils2.pad)(option)));
153
145
  }));
154
146
  };
155
- var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
156
- var _theme$timeInput6, _theme$timeInput7, _theme$timeInput8, _theme$timeInput9;
157
- var activeSection = _ref3.activeSection,
158
- align = _ref3.align,
159
- format = _ref3.format,
160
- formatMessage = _ref3.formatMessage,
161
- hoursOptions = _ref3.hoursOptions,
162
- _ref3$focusOnOpen = _ref3.focusOnOpen,
163
- focusOnOpen = _ref3$focusOnOpen === void 0 ? true : _ref3$focusOnOpen,
164
- id = _ref3.id,
165
- incrementSection = _ref3.incrementSection,
166
- messages = _ref3.messages,
167
- minuteOptions = _ref3.minuteOptions,
168
- onClose = _ref3.onClose,
169
- onFocusLeave = _ref3.onFocusLeave,
170
- secondOptions = _ref3.secondOptions,
171
- sectionOrder = _ref3.sectionOrder,
172
- sections = _ref3.sections,
173
- setActiveSection = _ref3.setActiveSection,
174
- setSectionValue = _ref3.setSectionValue,
175
- target = _ref3.target,
176
- dropProps = _ref3.dropProps,
177
- label = _ref3.label,
178
- _ref3$inline = _ref3.inline,
179
- inline = _ref3$inline === void 0 ? false : _ref3$inline,
180
- onKeyDownProp = _ref3.onKeyDown,
181
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
147
+ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref4) {
148
+ var _theme$timeInput10, _dropWidth$max;
149
+ var activeSection = _ref4.activeSection,
150
+ align = _ref4.align,
151
+ format = _ref4.format,
152
+ formatMessage = _ref4.formatMessage,
153
+ hoursOptions = _ref4.hoursOptions,
154
+ _ref4$focusOnOpen = _ref4.focusOnOpen,
155
+ focusOnOpen = _ref4$focusOnOpen === void 0 ? true : _ref4$focusOnOpen,
156
+ id = _ref4.id,
157
+ incrementSection = _ref4.incrementSection,
158
+ messages = _ref4.messages,
159
+ minuteOptions = _ref4.minuteOptions,
160
+ onClose = _ref4.onClose,
161
+ onFocusLeave = _ref4.onFocusLeave,
162
+ secondOptions = _ref4.secondOptions,
163
+ sectionOrder = _ref4.sectionOrder,
164
+ sections = _ref4.sections,
165
+ setActiveSection = _ref4.setActiveSection,
166
+ setSectionValue = _ref4.setSectionValue,
167
+ target = _ref4.target,
168
+ dropProps = _ref4.dropProps,
169
+ label = _ref4.label,
170
+ _ref4$inline = _ref4.inline,
171
+ inline = _ref4$inline === void 0 ? false : _ref4$inline,
172
+ onKeyDownProp = _ref4.onKeyDown,
173
+ rest = _objectWithoutPropertiesLoose(_ref4, _excluded3);
182
174
  var _useThemeValue = (0, _useThemeValue2.useThemeValue)(),
183
- theme = _useThemeValue.theme;
175
+ theme = _useThemeValue.theme,
176
+ passThemeFlag = _useThemeValue.passThemeFlag;
184
177
  var dialogRef = (0, _react.useRef)();
185
178
  var pointerDownInsideRef = (0, _react.useRef)(false);
186
- var pointerSelectionCommittedRef = (0, _react.useRef)(false);
187
179
  var suppressNextAutoScrollRef = (0, _react.useRef)(false);
188
180
  var wheelInteractionTimeoutRef = (0, _react.useRef)();
189
181
  var pointerReleaseTimeoutRef = (0, _react.useRef)();
@@ -219,18 +211,14 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
219
211
  setActiveSection(section);
220
212
  setSectionValue(section, option);
221
213
  }, [setActiveSection, setSectionValue]);
222
- var commitPointerOptionSelection = (0, _react.useCallback)(function (section, option) {
223
- pointerSelectionCommittedRef.current = true;
214
+
215
+ // Commit on the up-event (click), not mousedown - see WCAG 2.5.2 (Pointer
216
+ // Cancellation). Committing on press would leave no way to abort by
217
+ // moving the pointer off-target before releasing.
218
+ var commitClickOptionSelection = (0, _react.useCallback)(function (section, option) {
224
219
  suppressNextAutoScroll();
225
220
  commitOptionSelection(section, option);
226
221
  }, [commitOptionSelection, suppressNextAutoScroll]);
227
- var commitClickOptionSelection = (0, _react.useCallback)(function (section, option) {
228
- if (pointerSelectionCommittedRef.current) {
229
- pointerSelectionCommittedRef.current = false;
230
- return;
231
- }
232
- commitOptionSelection(section, option);
233
- }, [commitOptionSelection]);
234
222
  var onPopupWheelCapture = (0, _react.useCallback)(function () {
235
223
  pointerDownInsideRef.current = true;
236
224
  if (wheelInteractionTimeoutRef.current) {
@@ -269,8 +257,8 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
269
257
  label: 'period',
270
258
  options: ['AM', 'PM']
271
259
  }];
272
- var visiblePopupSections = popupSections.filter(function (_ref4) {
273
- var section = _ref4.section;
260
+ var visiblePopupSections = popupSections.filter(function (_ref5) {
261
+ var section = _ref5.section;
274
262
  return sectionOrder.includes(section);
275
263
  });
276
264
  var getSectionFromLabel = (0, _react.useCallback)(function (listboxLabel) {
@@ -315,8 +303,8 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
315
303
  format: format,
316
304
  options: secondOptions
317
305
  }), _sectionValue[_utils2.SECTION_PERIOD] = sections.period || 'AM', _sectionValue);
318
- visiblePopupSections.forEach(function (_ref5) {
319
- var section = _ref5.section;
306
+ visiblePopupSections.forEach(function (_ref6) {
307
+ var section = _ref6.section;
320
308
  var labelValue = sectionLabel[section];
321
309
  if (!labelValue) return;
322
310
  var listboxNode = popupNode.querySelector("[role=\"listbox\"][aria-label=\"" + labelValue + "\"]");
@@ -402,27 +390,36 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
402
390
  if (rafB) window.cancelAnimationFrame(rafB);
403
391
  };
404
392
  }, [focusCurrentPopupOption, focusOnOpen, scrollSelectedOptionsIntoView]);
393
+ var dropTheme = (_theme$timeInput10 = theme.timeInput) == null ? void 0 : _theme$timeInput10.drop;
394
+ var column = dropTheme.column,
395
+ option = dropTheme.option,
396
+ dropBoxTheme = _objectWithoutPropertiesLoose(dropTheme, _excluded4);
397
+ var dropWidth = dropBoxTheme.width;
398
+ var popupWidth = typeof dropWidth === 'object' ? _extends({}, dropWidth, {
399
+ max: (_dropWidth$max = dropWidth.max) != null ? _dropWidth$max : '100%'
400
+ }) : {
401
+ width: dropWidth,
402
+ max: '100%'
403
+ };
405
404
  var popupContent = /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
406
405
  ref: dialogRef,
407
406
  role: inline ? undefined : 'dialog',
408
407
  "aria-label": inline ? undefined : label,
409
408
  direction: "row",
410
- width: {
411
- width: (_theme$timeInput6 = theme.timeInput) == null || (_theme$timeInput6 = _theme$timeInput6.drop) == null ? void 0 : _theme$timeInput6.width,
412
- max: '100%'
413
- },
414
- minHeight: (_theme$timeInput7 = theme.timeInput) == null || (_theme$timeInput7 = _theme$timeInput7.drop) == null ? void 0 : _theme$timeInput7.minHeight,
415
- gap: ((_theme$timeInput8 = theme.timeInput) == null || (_theme$timeInput8 = _theme$timeInput8.drop) == null ? void 0 : _theme$timeInput8.gap) || 'xsmall',
416
- pad: inline ? 'none' : ((_theme$timeInput9 = theme.timeInput) == null || (_theme$timeInput9 = _theme$timeInput9.drop) == null ? void 0 : _theme$timeInput9.pad) || 'small',
409
+ width: popupWidth
410
+ }, dropBoxTheme, {
411
+ height: inline ? '100%' : dropBoxTheme.height,
412
+ pad: inline ? 'none' : dropBoxTheme.pad,
413
+ responsive: false,
417
414
  onPointerDownCapture: markInteractionInProgress,
418
415
  onPointerUpCapture: releaseInteractionAfterClick,
419
416
  onPointerCancelCapture: clearInteractionInProgress,
420
417
  onWheelCapture: onPopupWheelCapture,
421
418
  onKeyDown: function onKeyDown(event) {
422
- var _ref6;
419
+ var _ref7;
423
420
  var eventSectionFromTarget = getSectionFromEventTarget(event.target);
424
421
  var eventSectionFromActiveElement = getSectionFromEventTarget(document.activeElement);
425
- var eventSection = (_ref6 = eventSectionFromTarget != null ? eventSectionFromTarget : eventSectionFromActiveElement) != null ? _ref6 : activeSection;
422
+ var eventSection = (_ref7 = eventSectionFromTarget != null ? eventSectionFromTarget : eventSectionFromActiveElement) != null ? _ref7 : activeSection;
426
423
  if (event.key === 'Escape') {
427
424
  if (onClose) {
428
425
  event.preventDefault();
@@ -451,10 +448,10 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
451
448
  setActiveSection(getAdjacentSection(eventSection, 1));
452
449
  } else if (event.key === 'ArrowUp') {
453
450
  event.preventDefault();
454
- incrementSection(eventSection, 1);
451
+ incrementSection(eventSection, -1, true);
455
452
  } else if (event.key === 'ArrowDown') {
456
453
  event.preventDefault();
457
- incrementSection(eventSection, -1);
454
+ incrementSection(eventSection, 1, true);
458
455
  }
459
456
  onKeyDownProp == null || onKeyDownProp(event);
460
457
  },
@@ -474,10 +471,10 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
474
471
  onFocusLeave == null || onFocusLeave();
475
472
  }
476
473
  }
477
- }, rest), visiblePopupSections.map(function (_ref7) {
478
- var section = _ref7.section,
479
- sectionLabel = _ref7.label,
480
- options = _ref7.options;
474
+ }, rest), visiblePopupSections.map(function (_ref8) {
475
+ var section = _ref8.section,
476
+ sectionLabel = _ref8.label,
477
+ options = _ref8.options;
481
478
  return /*#__PURE__*/_react["default"].createElement(PopupColumn, {
482
479
  key: sectionLabel,
483
480
  activeSection: activeSection,
@@ -487,12 +484,12 @@ var TimeInputPopup = exports.TimeInputPopup = function TimeInputPopup(_ref3) {
487
484
  label: sectionLabel,
488
485
  messages: messages,
489
486
  onClickCommitOption: commitClickOptionSelection,
490
- onPointerCommitOption: commitPointerOptionSelection,
491
487
  onSetSection: setActiveSection,
492
488
  options: options,
493
489
  section: section,
494
490
  sections: sections,
495
- theme: theme
491
+ theme: theme,
492
+ passThemeFlag: passThemeFlag
496
493
  });
497
494
  }));
498
495
  if (inline) return popupContent;
@@ -7,12 +7,14 @@ export interface TimeInputProps {
7
7
  disabled?: boolean;
8
8
  format?: '12' | '24';
9
9
  id?: string;
10
+ inline?: boolean;
10
11
  messages?: {
11
12
  activePeriodValue?: string;
12
13
  activeSection?: string;
13
14
  activeSectionValue?: string;
14
15
  chooseTime?: string;
15
16
  currentValue?: string;
17
+ currentValueWithoutSeconds?: string;
16
18
  inputLabel?: string;
17
19
  invalidTime?: string;
18
20
  openDrop?: string;
@@ -14,12 +14,14 @@ if (process.env.NODE_ENV !== 'production') {
14
14
  disabled: _propTypes["default"].bool,
15
15
  format: _propTypes["default"].oneOf(['12', '24']),
16
16
  id: _propTypes["default"].string,
17
+ inline: _propTypes["default"].bool,
17
18
  messages: _propTypes["default"].shape({
18
19
  activePeriodValue: _propTypes["default"].string,
19
20
  activeSection: _propTypes["default"].string,
20
21
  activeSectionValue: _propTypes["default"].string,
21
22
  chooseTime: _propTypes["default"].string,
22
23
  currentValue: _propTypes["default"].string,
24
+ currentValueWithoutSeconds: _propTypes["default"].string,
23
25
  inputLabel: _propTypes["default"].string,
24
26
  invalidTime: _propTypes["default"].string,
25
27
  openDrop: _propTypes["default"].string,
@@ -5,7 +5,7 @@ import React from 'react';
5
5
  import { Box, Button, Text, TimeInput } from 'grommet';
6
6
 
7
7
  export const Controlled = () => {
8
- const [value, setValue] = React.useState('12:34:56');
8
+ const [value, setValue] = React.useState('12:34');
9
9
 
10
10
  const onChange = ({ value: next }: { value?: string }) => {
11
11
  console.log('onChange iso time:', next);
@@ -19,7 +19,7 @@ export const Controlled = () => {
19
19
  </Text>
20
20
  <TimeInput format="12" value={value} onChange={onChange} />
21
21
  <Box direction="row" gap="small">
22
- <Button label="Set 01:02:03 PM" onClick={() => setValue('13:02:03')} />
22
+ <Button label="Set 01:02 PM" onClick={() => setValue('13:02')} />
23
23
  <Button label="Clear" onClick={() => setValue('')} />
24
24
  </Box>
25
25
  </Box>
@@ -0,0 +1,79 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+ import { Box, Grommet, Heading, TimeInput, ThemeType } from 'grommet';
5
+ import { FormClock } from 'grommet-icons';
6
+
7
+ const theme: ThemeType = {
8
+ timeInput: {
9
+ container: {
10
+ border: { color: 'brand', size: 'small' },
11
+ round: 'small',
12
+ },
13
+ value: {
14
+ pad: { horizontal: 'small' },
15
+ background: 'background-front',
16
+ round: 'xsmall',
17
+ },
18
+ segment: {
19
+ color: 'text',
20
+ placeholder: { color: 'text-weak' },
21
+ size: 'medium',
22
+ weight: 500,
23
+ pad: 'xxsmall',
24
+ active: {
25
+ background: 'background-contrast',
26
+ border: { color: 'brand', side: 'bottom', size: 'small' },
27
+ },
28
+ },
29
+ dropButton: {
30
+ icon: <FormClock />,
31
+ background: 'brand',
32
+ color: 'white',
33
+ padding: { vertical: 'xsmall', horizontal: 'small' },
34
+ },
35
+ drop: {
36
+ background: 'background-front',
37
+ border: { color: 'border', size: 'small' },
38
+ round: 'small',
39
+ pad: 'xsmall',
40
+ width: '20rem',
41
+ column: {
42
+ height: { max: 'medium' },
43
+ gap: 'xxsmall',
44
+ pad: { horizontal: 'xsmall' },
45
+ round: 'small',
46
+ },
47
+ option: {
48
+ container: {
49
+ pad: { vertical: 'xsmall', horizontal: 'small' },
50
+ round: 'xsmall',
51
+ hover: { background: 'background-contrast' },
52
+ selected: {
53
+ background: 'selected',
54
+ hover: { background: 'brand' },
55
+ },
56
+ },
57
+ text: {
58
+ size: 'small',
59
+ selected: { color: 'white', weight: 600 },
60
+ },
61
+ },
62
+ },
63
+ },
64
+ };
65
+
66
+ export const CustomThemed = () => (
67
+ <Grommet theme={theme}>
68
+ <Box gap="medium" pad="large" width="medium">
69
+ <Heading level={3} margin="none">
70
+ Custom themed time input
71
+ </Heading>
72
+ <TimeInput format="12" defaultValue="10:15:20" />
73
+ </Box>
74
+ </Grommet>
75
+ );
76
+
77
+ export default {
78
+ title: 'Input/TimeInput/Custom Themed',
79
+ };
@@ -0,0 +1,115 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+
5
+ import { hpe } from 'grommet-theme-hpe';
6
+ import {
7
+ Box,
8
+ Grommet,
9
+ Heading,
10
+ ThemeContext,
11
+ ThemeType,
12
+ TimeInput,
13
+ } from 'grommet';
14
+ import { deepMerge } from 'grommet/utils';
15
+ import {
16
+ components,
17
+ dimension,
18
+ global as globalTokens,
19
+ } from 'hpe-design-tokens/grommet';
20
+
21
+ const { hpe: hpeComponents } = components;
22
+ const { hpe: hpeDimension } = dimension;
23
+ const { hpe: hpeGlobal } = globalTokens;
24
+
25
+ const theme: ThemeType = deepMerge({}, hpe);
26
+ theme.timeInput = {
27
+ container: {
28
+ round: hpeComponents.formField.default.medium.input.container.borderRadius,
29
+ },
30
+ segment: {
31
+ pad: {
32
+ start: hpeDimension.spacing['5xsmall'],
33
+ end: hpeDimension.spacing['5xsmall'],
34
+ },
35
+ active: {
36
+ background: 'background-active',
37
+ border: {
38
+ size: 'small',
39
+ color: 'focus',
40
+ },
41
+ pad: {
42
+ start: hpeDimension.spacing['5xsmall'],
43
+ end: hpeDimension.spacing['5xsmall'],
44
+ },
45
+ },
46
+ },
47
+ drop: {
48
+ column: {
49
+ gap: hpeDimension.spacing['4xsmall'],
50
+ pad: { horizontal: '3xsmall' },
51
+ },
52
+ pad: { horizontal: '3xsmall', vertical: 'xsmall' },
53
+ option: {
54
+ container: {
55
+ pad: {
56
+ vertical: hpeComponents.element.medium.paddingY,
57
+ horizontal: hpeComponents.element.medium.paddingX.default,
58
+ },
59
+ round: hpeDimension.radius.xxsmall,
60
+ hover: {
61
+ background: 'background-active',
62
+ },
63
+ selected: {
64
+ background: 'background-selected-primary-strong',
65
+ hover: {
66
+ background: 'background-selected-primary-strong-hover',
67
+ },
68
+ },
69
+ },
70
+ text: {
71
+ size: hpeDimension.text.medium.fontSize,
72
+ selected: {
73
+ color: 'text-onSelectedPrimaryStrong',
74
+ weight: hpeGlobal.fontWeight.medium,
75
+ },
76
+ },
77
+ },
78
+ },
79
+ };
80
+
81
+ export const CustomThemedHpe = () => (
82
+ <Grommet theme={theme}>
83
+ <Box gap="xlarge" pad="large">
84
+ <Box width="medium" gap="medium">
85
+ <Heading level={3} margin="none">
86
+ Full TimeInput theme, extending grommet-theme-hpe
87
+ </Heading>
88
+ <TimeInput format="12" showSeconds />
89
+ <TimeInput format="12" />
90
+ <TimeInput format="24" showSeconds />
91
+ <TimeInput format="24" />
92
+ </Box>
93
+ <ThemeContext.Extend value={{ dark: true }}>
94
+ <Box
95
+ width="medium"
96
+ gap="medium"
97
+ pad="large"
98
+ background="background-front"
99
+ >
100
+ <Heading level={3} margin="none">
101
+ Dark Theme
102
+ </Heading>
103
+ <TimeInput format="12" showSeconds />
104
+ <TimeInput format="12" />
105
+ <TimeInput format="24" showSeconds />
106
+ <TimeInput format="24" />
107
+ </Box>
108
+ </ThemeContext.Extend>
109
+ </Box>
110
+ </Grommet>
111
+ );
112
+
113
+ export default {
114
+ title: 'Input/TimeInput/Custom Themed/Hpe',
115
+ };
@@ -16,6 +16,7 @@ export const TimeForm = () => {
16
16
  value={value}
17
17
  onChange={onChange}
18
18
  onSubmit={() => {
19
+ console.log('Form submitted with value:', value);
19
20
  setValue({ value: '' });
20
21
  }}
21
22
  >