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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.StyledTextInputContainer = exports.StyledTextInput = exports.StyledSuggestions = exports.StyledPlaceholder = exports.StyledInlineIcon = exports.StyledInlineButton = exports.StyledIcon = void 0;
4
+ exports.StyledTextInputContainer = exports.StyledTextInput = exports.StyledSuggestions = exports.StyledPlaceholder = exports.StyledIcon = exports.StyledActionsGroup = void 0;
5
5
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
6
6
  var _utils = require("../../utils");
7
7
  var _styles = require("../../utils/styles");
@@ -10,37 +10,28 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
10
10
  // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
11
11
  // SPDX-License-Identifier: Apache-2.0
12
12
 
13
- var getInlineButtonPad = function getInlineButtonPad(props) {
14
- var rightInset = Number.parseFloat((0, _utils.getInputPadBySide)(props, 'right'));
15
- var iconPad = Number.parseFloat((0, _styles.getInputIconPad)(props));
16
- var trailingIconPad = props.hasTrailingIcon ? iconPad : 0;
17
- // Reserve both the icon space and the control's edge inset so text clears
18
- // the flush-right password toggle, and the reversed icon when both coexist.
19
- return iconPad + trailingIconPad + rightInset + "px";
20
- };
21
13
  var getPlainStyle = function getPlainStyle(plain) {
22
14
  if (plain === 'full') {
23
- return (0, _styledComponents.css)(["", " padding:0;"], _utils.plainInputStyle);
15
+ return (0, _styledComponents.css)(["", ";padding:0;"], _utils.plainInputStyle);
24
16
  }
25
17
  return plain && _utils.plainInputStyle;
26
18
  };
27
19
  var StyledTextInput = exports.StyledTextInput = _styledComponents["default"].input.withConfig(_utils.styledComponentsConfig).withConfig({
28
20
  displayName: "StyledTextInput",
29
21
  componentId: "sc-1x30a0s-0"
30
- })(["", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ";"], _utils.inputStyle, function (props) {
22
+ })(["", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ";"], _utils.inputStyle, function (props) {
31
23
  return (props.hasButton || props.readOnlyCopy) && 'flex: 1 1 auto;';
32
24
  }, function (props) {
33
25
  return (props.hasButton || props.readOnlyCopy) && 'min-width: 0;';
34
26
  }, function (props) {
35
- return props.readOnlyCopy || props.hasButton ? "padding-" + (props.reverse ? 'left' : 'right') + ": 0px;" : '';
27
+ if (!(props.readOnlyCopy || props.hasButton)) return '';
28
+ return 'padding-right: 0px;';
36
29
  }, function (props) {
37
- return props.readOnly && "border: none;";
30
+ return (props.readOnly || props.hasButton) && "border: none;";
38
31
  }, function (props) {
39
32
  return getPlainStyle(props.plain);
40
33
  }, function (props) {
41
- return props.icon && _styles.inputPadForIcon;
42
- }, function (props) {
43
- return props.hasInlineButton && "padding-right: " + getInlineButtonPad(props) + ";";
34
+ return props.icon && !props.hasActionsGroup && _styles.inputPadForIcon;
44
35
  }, function (props) {
45
36
  return props.disabled && (0, _utils.disabledStyle)(props.theme.textInput.disabled && props.theme.textInput.disabled.opacity);
46
37
  }, function (props) {
@@ -56,7 +47,11 @@ var StyledTextInputContainer = exports.StyledTextInputContainer = _styledCompone
56
47
  })(["position:relative;width:100%;", " ", ";", ";", " ", ";"], function (props) {
57
48
  return props.widthProp && props.readOnlyProp && (0, _utils.widthStyle)(props.widthProp, props.theme);
58
49
  }, function (props) {
59
- return props.readOnlyProp && !props.plain && _utils.controlBorderStyle;
50
+ return (
51
+ // The container owns the border so the actions group remains inside
52
+ // the field.
53
+ (props.readOnlyProp || props.hasButton) && !props.plain && _utils.controlBorderStyle
54
+ );
60
55
  }, function (props) {
61
56
  return (props.readOnlyCopy || props.hasButton) && "\n box-sizing: border-box;\n flex-direction: row;\n display: flex;\n align-items: stretch;\n ";
62
57
  }, function (props) {
@@ -76,19 +71,18 @@ var StyledIcon = exports.StyledIcon = _styledComponents["default"].div.withConfi
76
71
  displayName: "StyledTextInput__StyledIcon",
77
72
  componentId: "sc-1x30a0s-3"
78
73
  })(["position:absolute;display:flex;justify:center;top:50%;transform:translateY(-50%);pointer-events:none;", ""], function (props) {
74
+ if (props.hasActionsGroup) {
75
+ return "\n position: static;\n align-items: center;\n transform: none;\n padding-left: " + (0, _utils.getInputPadBySide)(props, 'left') + ";\n padding-right: " + (0, _utils.getInputPadBySide)(props, 'right') + ";\n ";
76
+ }
79
77
  return props.reverse ? "right: " + (0, _utils.getInputPadBySide)(props, 'right') + ";" : "left: " + (0, _utils.getInputPadBySide)(props, 'left') + ";";
80
78
  });
81
- var StyledInlineButton = exports.StyledInlineButton = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
82
- displayName: "StyledTextInput__StyledInlineButton",
79
+ var StyledActionsGroup = exports.StyledActionsGroup = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
80
+ displayName: "StyledTextInput__StyledActionsGroup",
83
81
  componentId: "sc-1x30a0s-4"
84
- })(["position:absolute;display:flex;align-items:stretch;top:0;right:0;bottom:0;z-index:1;"]);
85
- var StyledInlineIcon = exports.StyledInlineIcon = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({
86
- displayName: "StyledTextInput__StyledInlineIcon",
87
- componentId: "sc-1x30a0s-5"
88
- })(["display:flex;align-items:center;justify-content:center;pointer-events:none;"]);
82
+ })(["display:flex;align-items:stretch;z-index:1;"]);
89
83
  var StyledSuggestions = exports.StyledSuggestions = _styledComponents["default"].ol.withConfig(_utils.styledComponentsConfig).withConfig({
90
84
  displayName: "StyledTextInput__StyledSuggestions",
91
- componentId: "sc-1x30a0s-6"
85
+ componentId: "sc-1x30a0s-5"
92
86
  })(["border-top-left-radius:0;border-top-right-radius:0;margin:0;padding:0;list-style-type:none;", ";"], function (props) {
93
87
  return props.theme.textInput && props.theme.textInput.suggestions && props.theme.textInput.suggestions.extend;
94
88
  });
@@ -17,11 +17,15 @@ var _MessageContext = require("../../contexts/MessageContext");
17
17
  var _propTypes = require("./propTypes");
18
18
  var _CopyButton = require("./CopyButton");
19
19
  var _useThemeValue2 = require("../../utils/useThemeValue");
20
- var _excluded = ["a11yTitle", "defaultSuggestion", "defaultValue", "disabled", "dropAlign", "dropHeight", "dropTarget", "dropProps", "focusIndicator", "icon", "id", "messages", "name", "onBlur", "onChange", "onFocus", "onKeyDown", "onSelect", "onSuggestionSelect", "onSuggestionsClose", "onSuggestionsOpen", "password", "placeholder", "plain", "readOnly", "readOnlyCopy", "reverse", "suggestions", "textAlign", "type", "value", "width"]; // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
20
+ var _excluded = ["a11yTitle", "copy", "defaultSuggestion", "defaultValue", "disabled", "dropAlign", "dropHeight", "dropProps", "dropTarget", "focusIndicator", "icon", "id", "messages", "name", "onBlur", "onChange", "onClickCopy", "onFocus", "onKeyDown", "onSelect", "onSuggestionSelect", "onSuggestionsClose", "onSuggestionsOpen", "password", "placeholder", "plain", "readOnly", "readOnlyCopy", "reverse", "suggestions", "textAlign", "type", "value", "width"]; // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
21
21
  // SPDX-License-Identifier: Apache-2.0
22
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
23
23
  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); }
24
24
  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); }
25
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
26
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
27
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
28
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
25
29
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
26
30
  var renderLabel = function renderLabel(suggestion) {
27
31
  if (suggestion && typeof suggestion === 'object') {
@@ -49,21 +53,26 @@ var ContainerBox = (0, _styledComponents["default"])(_Box.Box).withConfig({
49
53
  })(["", ";@media screen and (-ms-high-contrast:active),(-ms-high-contrast:none){width:100%;}"], function (props) {
50
54
  return props.dropHeight ? (0, _utils.sizeStyle)('max-height', props.dropHeight, props.theme) : 'max-height: inherit;';
51
55
  });
56
+ var StyledPasswordToggleButton = (0, _styledComponents["default"])(_Button.Button).withConfig({
57
+ displayName: "TextInput__StyledPasswordToggleButton",
58
+ componentId: "sc-1ai0c08-1"
59
+ })(["padding-top:0;padding-bottom:0;"]);
52
60
  var defaultDropAlign = {
53
61
  top: 'bottom',
54
62
  left: 'left'
55
63
  };
56
64
  var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
57
- var _inputRef$current, _inputRef$current2, _theme$textInput, _theme$textInput2;
65
+ var _inputRef$current2, _inputRef$current3, _theme$textInput, _theme$textInput2;
58
66
  var a11yTitle = _ref.a11yTitle,
67
+ copy = _ref.copy,
59
68
  defaultSuggestion = _ref.defaultSuggestion,
60
69
  defaultValue = _ref.defaultValue,
61
70
  disabled = _ref.disabled,
62
71
  _ref$dropAlign = _ref.dropAlign,
63
72
  dropAlign = _ref$dropAlign === void 0 ? defaultDropAlign : _ref$dropAlign,
64
73
  dropHeight = _ref.dropHeight,
65
- dropTarget = _ref.dropTarget,
66
74
  dropProps = _ref.dropProps,
75
+ dropTarget = _ref.dropTarget,
67
76
  _ref$focusIndicator = _ref.focusIndicator,
68
77
  focusIndicator = _ref$focusIndicator === void 0 ? true : _ref$focusIndicator,
69
78
  icon = _ref.icon,
@@ -72,6 +81,7 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
72
81
  name = _ref.name,
73
82
  _onBlur = _ref.onBlur,
74
83
  onChange = _ref.onChange,
84
+ onClickCopy = _ref.onClickCopy,
75
85
  _onFocus = _ref.onFocus,
76
86
  onKeyDown = _ref.onKeyDown,
77
87
  onSelect = _ref.onSelect,
@@ -146,11 +156,40 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
146
156
  id: 'textInput.hidePassword',
147
157
  messages: messages
148
158
  });
149
- var onClickCopy = function onClickCopy() {
150
- navigator.clipboard.writeText(value);
151
- announce(readOnlyCopyValidation, 'assertive');
152
- setTip(readOnlyCopyValidation);
153
- };
159
+ var handleCopyClick = /*#__PURE__*/function () {
160
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
161
+ var _ref3, _inputRef$current$val, _inputRef$current;
162
+ var currentValue;
163
+ return _regenerator().w(function (_context) {
164
+ while (1) switch (_context.n) {
165
+ case 0:
166
+ // uncontrolled inputs keep their current text on the DOM node, not
167
+ // in `value`, which stays undefined outside a Form
168
+ currentValue = (_ref3 = (_inputRef$current$val = (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.value) != null ? _inputRef$current$val : value) != null ? _ref3 : '';
169
+ if (!onClickCopy) {
170
+ _context.n = 2;
171
+ break;
172
+ }
173
+ _context.n = 1;
174
+ return onClickCopy(event, currentValue);
175
+ case 1:
176
+ _context.n = 3;
177
+ break;
178
+ case 2:
179
+ _context.n = 3;
180
+ return navigator.clipboard.writeText(currentValue);
181
+ case 3:
182
+ announce(readOnlyCopyValidation, 'assertive');
183
+ setTip(readOnlyCopyValidation);
184
+ case 4:
185
+ return _context.a(2);
186
+ }
187
+ }, _callee);
188
+ }));
189
+ return function handleCopyClick(_x) {
190
+ return _ref2.apply(this, arguments);
191
+ };
192
+ }();
154
193
  var onBlurCopy = function onBlurCopy() {
155
194
  if (tip === readOnlyCopyValidation) setTip(readOnlyCopyPrompt);
156
195
  };
@@ -267,7 +306,7 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
267
306
  if (readOnly && inputRef != null && inputRef.current && inputRef.current.scrollLeft > 0) {
268
307
  inputRef.current.scrollLeft = 0;
269
308
  }
270
- }, [readOnly, inputRef, inputRef == null || (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.scrollLeft]);
309
+ }, [readOnly, inputRef, inputRef == null || (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.scrollLeft]);
271
310
  var setValueFromSuggestion = function setValueFromSuggestion(event, suggestion) {
272
311
  // if we stole the focus in the drop, perhaps by interacting with
273
312
  // a suggestion button or the scrollbar, give it back
@@ -296,7 +335,7 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
296
335
  }, [activeSuggestionIndex]);
297
336
 
298
337
  // account for input value in both controlled and uncontrolled scenarios
299
- var hasValue = value || ((_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.value);
338
+ var hasValue = value || ((_inputRef$current3 = inputRef.current) == null ? void 0 : _inputRef$current3.value);
300
339
  var showStyledPlaceholder = (0, _react.useMemo)(function () {
301
340
  return placeholder && typeof placeholder !== 'string' && !hasValue;
302
341
  }, [hasValue, placeholder]);
@@ -423,17 +462,16 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
423
462
  inputType = passwordRevealed ? 'text' : 'password';
424
463
  }
425
464
  var showTextInputIcon = !!textInputIcon && !readOnlyCopy;
426
- var showLeadingIcon = showTextInputIcon && !reverse;
427
- var showTrailingIcon = showTextInputIcon && reverse;
428
- var ReadOnlyCopyButton = /*#__PURE__*/_react["default"].createElement(_CopyButton.CopyButton, {
465
+ var copyButtonElement = /*#__PURE__*/_react["default"].createElement(_CopyButton.CopyButton, {
466
+ authoredType: authoredType,
429
467
  disabled: disabled,
468
+ messages: messages,
430
469
  onBlurCopy: onBlurCopy,
431
- onClickCopy: onClickCopy,
432
- readOnlyCopyPrompt: readOnlyCopyPrompt,
470
+ onCopy: handleCopyClick,
433
471
  tip: tip,
434
472
  value: value
435
473
  });
436
- var PasswordToggleButton = passwordToggle ? /*#__PURE__*/_react["default"].createElement(_Button.Button, {
474
+ var passwordToggleButton = passwordToggle ? /*#__PURE__*/_react["default"].createElement(StyledPasswordToggleButton, _extends({
437
475
  disabled: disabled,
438
476
  kind: "toolbar",
439
477
  icon: passwordRevealed ? renderIcon(hidePasswordIcon, {
@@ -447,10 +485,17 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
447
485
  });
448
486
  },
449
487
  "aria-label": passwordRevealed ? hidePasswordMessage : showPasswordMessage
450
- }) : undefined;
451
- var textInputButton = readOnlyCopy ? ReadOnlyCopyButton : undefined;
488
+ }, passThemeFlag)) : undefined;
489
+ var copyButton = readOnlyCopy || copy ? copyButtonElement : undefined;
490
+ // Keep state-changing password visibility before the non-destructive
491
+ // copy action.
492
+ var actionsGroup = passwordToggleButton || copyButton ? /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledActionsGroup, passThemeFlag, passwordToggleButton, copyButton) : undefined;
493
+ var hasActionsGroup = !!actionsGroup;
494
+ var iconOnRight = reverse;
495
+ var showLeadingIcon = showTextInputIcon && !iconOnRight;
496
+ var showTrailingIcon = showTextInputIcon && iconOnRight;
452
497
  return /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledTextInputContainer, _extends({
453
- hasButton: !!textInputButton,
498
+ hasButton: !!actionsGroup,
454
499
  readOnlyProp: readOnly // readOnlyProp to avoid passing to DOM
455
500
  ,
456
501
  readOnlyCopy: readOnlyCopy,
@@ -460,8 +505,9 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
460
505
  onMouseMove: function onMouseMove() {
461
506
  return setMouseMovedSinceLastKey(true);
462
507
  }
463
- }, passThemeFlag), reverse && textInputButton, showStyledPlaceholder && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledPlaceholder, passThemeFlag, placeholder), showLeadingIcon && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledIcon, {
464
- reverse: reverse,
508
+ }, passThemeFlag), showStyledPlaceholder && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledPlaceholder, passThemeFlag, placeholder), showLeadingIcon && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledIcon, {
509
+ reverse: iconOnRight,
510
+ hasActionsGroup: hasActionsGroup,
465
511
  theme: theme
466
512
  }, textInputIcon), /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, _extends({
467
513
  target: focus ? 'document' : undefined
@@ -474,11 +520,11 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
474
520
  disabled: disabled,
475
521
  plain: plain,
476
522
  placeholder: typeof placeholder === 'string' ? placeholder : undefined,
477
- icon: showTextInputIcon ? icon : undefined,
478
- reverse: reverse,
523
+ icon: showTextInputIcon && !hasActionsGroup ? icon : undefined,
524
+ reverse: iconOnRight,
479
525
  focus: focus,
480
- hasButton: !!textInputButton,
481
- hasInlineButton: passwordToggle,
526
+ hasButton: hasActionsGroup,
527
+ hasActionsGroup: hasActionsGroup,
482
528
  hasTrailingIcon: showTrailingIcon,
483
529
  focusIndicator: focusIndicator,
484
530
  textAlign: textAlign,
@@ -527,10 +573,11 @@ var TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function
527
573
  setActiveSuggestionIndex(resetSuggestionIndex);
528
574
  if (onChange) onChange(event);
529
575
  }
530
- }))), PasswordToggleButton && !readOnlyCopy && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledInlineButton, passThemeFlag, showTrailingIcon && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledInlineIcon, passThemeFlag, textInputIcon), PasswordToggleButton), showTrailingIcon && !PasswordToggleButton && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledIcon, {
531
- reverse: reverse,
576
+ }))), showTrailingIcon && /*#__PURE__*/_react["default"].createElement(_StyledTextInput.StyledIcon, {
577
+ reverse: iconOnRight,
578
+ hasActionsGroup: hasActionsGroup,
532
579
  theme: theme
533
- }, textInputIcon), !reverse && textInputButton, !readOnly && drop);
580
+ }, textInputIcon), actionsGroup, !readOnly && drop);
534
581
  });
535
582
  TextInput.displayName = 'TextInput';
536
583
  TextInput.propTypes = _propTypes.TextInputPropTypes;
@@ -13,6 +13,8 @@ export interface TextInputProps
13
13
  'onSelect' | 'size' | 'placeholder' | 'width'
14
14
  > {
15
15
  a11yTitle?: A11yTitleType;
16
+ copy?: boolean;
17
+ defaultSuggestion?: number;
16
18
  dropAlign?: {
17
19
  top?: 'top' | 'bottom';
18
20
  bottom?: 'top' | 'bottom';
@@ -20,10 +22,9 @@ export interface TextInputProps
20
22
  left?: 'left' | 'right';
21
23
  };
22
24
  dropHeight?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | string;
23
- dropTarget?: object;
24
25
  dropProps?: DropType;
26
+ dropTarget?: object;
25
27
  focusIndicator?: boolean;
26
- defaultSuggestion?: number;
27
28
  icon?: React.ReactNode;
28
29
  id?: string;
29
30
  messages?: {
@@ -35,6 +36,14 @@ export interface TextInputProps
35
36
  suggestionIsOpen?: string;
36
37
  };
37
38
  name?: string;
39
+ /**
40
+ * Called when the copy button is activated. The value is unmasked; do not
41
+ * log, persist, or transmit it unless explicitly required.
42
+ */
43
+ onClickCopy?: (
44
+ event: React.MouseEvent<HTMLButtonElement>,
45
+ value: string,
46
+ ) => void | Promise<void>;
38
47
  onSelect?: (x: {
39
48
  target: React.RefObject<HTMLElement | null>['current'];
40
49
  suggestion: any;
@@ -43,8 +52,8 @@ export interface TextInputProps
43
52
  target: React.RefObject<HTMLElement | null>['current'];
44
53
  suggestion: any;
45
54
  }) => void;
46
- onSuggestionsOpen?: () => void;
47
55
  onSuggestionsClose?: () => void;
56
+ onSuggestionsOpen?: () => void;
48
57
  password?: boolean;
49
58
  placeholder?: string | React.ReactNode;
50
59
  plain?: boolean | 'full';
@@ -35,6 +35,7 @@ if (process.env.NODE_ENV !== 'production') {
35
35
  }),
36
36
  name: _propTypes["default"].string,
37
37
  onChange: _propTypes["default"].func,
38
+ onClickCopy: _propTypes["default"].func,
38
39
  onSelect: _propTypes["default"].func,
39
40
  onSuggestionSelect: _propTypes["default"].func,
40
41
  onSuggestionsOpen: _propTypes["default"].func,
@@ -42,6 +43,7 @@ if (process.env.NODE_ENV !== 'production') {
42
43
  password: _propTypes["default"].bool,
43
44
  placeholder: _propTypes["default"].node,
44
45
  plain: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].oneOf(['full'])]),
46
+ copy: _propTypes["default"].bool,
45
47
  readOnlyCopy: _propTypes["default"].bool,
46
48
  reverse: _propTypes["default"].bool,
47
49
  size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge', '2xl', '3xl', '4xl', '5xl', '6xl']), _propTypes["default"].string]),
@@ -0,0 +1,42 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+
5
+ import { Box, Text, TextInput } from 'grommet';
6
+
7
+ export const Copy = () => {
8
+ const [value, setValue] = React.useState<string>('Editable value');
9
+ const [status, setStatus] = React.useState<string>('');
10
+
11
+ return (
12
+ // Uncomment <Grommet> lines when using outside of storybook
13
+ // <Grommet theme={...}>
14
+ <Box fill align="center" justify="start" pad="large" gap="medium">
15
+ <Box width="medium" gap="small">
16
+ <TextInput
17
+ value={value}
18
+ onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
19
+ setValue(event.target.value)
20
+ }
21
+ copy
22
+ aria-label="Editable value"
23
+ />
24
+ <TextInput
25
+ value="Custom copy handler"
26
+ copy
27
+ onClickCopy={(
28
+ _event: React.MouseEvent<HTMLButtonElement>,
29
+ copiedValue: string,
30
+ ) => setStatus(`Custom copy handler called with "${copiedValue}"`)}
31
+ aria-label="Custom copy handler"
32
+ />
33
+ {status && <Text>{status}</Text>}
34
+ </Box>
35
+ </Box>
36
+ // </Grommet>
37
+ );
38
+ };
39
+
40
+ export default {
41
+ title: 'Input/TextInput/Copy',
42
+ };
@@ -0,0 +1,44 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+
5
+ import { Box, Text, TextInput } from 'grommet';
6
+
7
+ // Stands in for retrieving the real secret from a secure store/API,
8
+ // fetched only at copy time so it never lives in component state or the DOM.
9
+ const fetchSecret = async () => 'secret-value';
10
+
11
+ // Caller-supplied mask; the input never displays or holds the real value.
12
+ const MASK = '••••••••••••';
13
+
14
+ export const CopySecret = () => {
15
+ const [status, setStatus] = React.useState<string>('');
16
+
17
+ return (
18
+ // Uncomment <Grommet> lines when using outside of storybook
19
+ // <Grommet theme={...}>
20
+ <Box fill align="center" justify="start" pad="large" gap="medium">
21
+ <Box width="medium" gap="small">
22
+ <TextInput
23
+ value={MASK}
24
+ copy
25
+ // onClickCopy fetches, copies, and discards the secret itself;
26
+ // the masked value passed by TextInput is ignored.
27
+ onClickCopy={async () => {
28
+ const secret = await fetchSecret();
29
+ await navigator.clipboard.writeText(secret);
30
+ setStatus('Secret copied to clipboard');
31
+ // `secret` falls out of scope here and is not retained.
32
+ }}
33
+ aria-label="Secret"
34
+ />
35
+ {status && <Text>{status}</Text>}
36
+ </Box>
37
+ </Box>
38
+ // </Grommet>
39
+ );
40
+ };
41
+
42
+ export default {
43
+ title: 'Input/TextInput/Copy Secret',
44
+ };
@@ -1,2 +1,25 @@
1
1
  ## TimeInput
2
- Documentation for this component: https://v2.grommet.io/timeinput
2
+ Documentation for this component: https://v2.grommet.io/timeinput
3
+
4
+ ### Theme
5
+
6
+ TimeInput is in beta, so its theme API is subject to breaking changes. The
7
+ theme is organized by the part it styles:
8
+
9
+ | Theme path | Part and supported values |
10
+ | --- | --- |
11
+ | `timeInput.container` | The field frame. Supports Box appearance and sizing values such as `background`, `border`, `margin`, `pad`, and `round`. |
12
+ | `timeInput.value` | The visible value frame. Supports Box-part appearance and sizing values `background`, `border`, `elevation`, `height`, `margin`, `pad`, `round`, and `width`. |
13
+ | `timeInput.segment` | Time sections and separators. Supports Box-part appearance values `background`, `border`, `elevation`, `height`, `margin`, `pad`, `round`, and `width`, plus text `color`, `size`, `weight`, and placeholder `color`, `size`, and `weight`. Its `active` state supports Box-state values `background`, `border`, `elevation`, `pad`, and `round`, plus text `color`, `size`, and `weight`. The active underline is styled through `active.border` (default side: `bottom`). A scalar `pad` applies to all edges; the base theme uses horizontal-only padding to preserve the default appearance. |
14
+ | `timeInput.dropButton` | The popup trigger button. Accepts a named Button kind string, `{ kind, icon }`, or a Button theme object with an optional `icon`. The defaults are the clock icon and `toolbar` kind. |
15
+ | `timeInput.drop` | The popup frame. Supports Box appearance values, `width` (Box `WidthType`), `height` (including `height.min`), and `gap`. The base theme defines the default width; an omitted `width.max` defaults to `100%` to constrain the popup to available space. |
16
+ | `timeInput.drop.column` | Each popup list. Supports Box-part appearance and sizing values (`background`, `border`, `elevation`, `height`, `margin`, `pad`, `round`, and `width`), plus `gap`. When `height` is omitted, the list retains its responsive default max height. |
17
+ | `timeInput.drop.option.container` | The Box-backed option surface. Supports Box-part values `background`, `border`, `elevation`, `height`, `margin`, `pad`, `round`, and `width`. Its `hover`, `selected`, and `selected.hover` states support Box-state values `background`, `border`, `elevation`, `pad`, and `round`. Missing selected values inherit the base container style. |
18
+ | `timeInput.drop.option.text` | Option label text. Supports `color`, `size`, and `weight`; its `selected` state supports the same values and overrides the base text values individually. |
19
+
20
+ TimeInput themes only style the parts above. Option role, selection semantics,
21
+ layout alignment, and interaction behavior remain implementation-owned.
22
+ FormField continues to own its surrounding validation frame; option
23
+ focus-visible and general focus indicators continue to use Grommet's global
24
+ focus theme. Inline TimeInput styling is used
25
+ inside DateTimeInput and shares the popup column and option theme.