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,28 @@
1
+ // SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React, { useState } from 'react';
4
+
5
+ import { Box, CheckBox, TimeInput } from 'grommet';
6
+
7
+ export const ShowSeconds = () => {
8
+ const [showSeconds, setShowSeconds] = useState(false);
9
+
10
+ return (
11
+ <Box pad="large" width="medium" gap="small">
12
+ <TimeInput
13
+ format="12"
14
+ showSeconds={showSeconds}
15
+ defaultValue="12:34:56"
16
+ />
17
+ <CheckBox
18
+ label="Show seconds"
19
+ checked={showSeconds}
20
+ onChange={(event) => setShowSeconds(event.target.checked)}
21
+ />
22
+ </Box>
23
+ );
24
+ };
25
+
26
+ export default {
27
+ title: 'Input/TimeInput/ShowSeconds',
28
+ };
@@ -160,7 +160,7 @@ export var useSectionedTimeField = function useSectionedTimeField(_ref2) {
160
160
  setActiveSection(nextSection);
161
161
  return nextSection;
162
162
  }, [activeSection, sectionOrder, setActiveSection]);
163
- var incrementSection = useCallback(function (section, delta) {
163
+ var incrementSection = useCallback(function (section, delta, isDrop) {
164
164
  if (section === SECTION_PERIOD) {
165
165
  setSectionValue(section, sections.period === 'AM' ? 'PM' : 'AM');
166
166
  return;
@@ -170,7 +170,7 @@ export var useSectionedTimeField = function useSectionedTimeField(_ref2) {
170
170
  var key = sectionKey(section);
171
171
  var current = sections[key];
172
172
  if (current === undefined) {
173
- setSectionValue(section, delta > 0 ? minValue : maxValue);
173
+ setSectionValue(section, isDrop ? minValue : delta > 0 ? minValue : maxValue);
174
174
  return;
175
175
  }
176
176
  var step = section === SECTION_MINUTE ? minuteStep : section === SECTION_SECOND ? 1 : 1;
@@ -24,21 +24,19 @@ export var getSectionName = function getSectionName(section, format, formatMessa
24
24
  if (format !== '12' && sectionType === 'meridiem') return undefined;
25
25
  return sectionName;
26
26
  };
27
- export var getRanges = function getRanges(format) {
28
- if (format === '12') {
29
- return [[0, 2], [3, 5], [6, 8], [9, 11]];
30
- }
31
- return [[0, 2], [3, 5], [6, 8]];
32
- };
33
27
 
34
28
  // TimeInput always transacts (value/defaultValue/onChange) in a canonical
35
29
  // 24-hour ISO time string ("HH:MM:SS"), regardless of the display `format`
36
- // prop.
30
+ // prop. Input may also be passed as "HH:MM" (without seconds); it's
31
+ // normalized to "HH:MM:00" so the rest of the component only ever deals
32
+ // with one shape.
37
33
  export var ISO_TIME_REGEX = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/;
34
+ export var ISO_TIME_NO_SECONDS_REGEX = /^([01]\d|2[0-3]):([0-5]\d)$/;
38
35
  export var normalizeToIsoTime = function normalizeToIsoTime(value) {
39
36
  if (typeof value !== 'string' || !value.trim()) return undefined;
40
37
  var trimmed = value.trim();
41
38
  if (ISO_TIME_REGEX.test(trimmed)) return trimmed;
39
+ if (ISO_TIME_NO_SECONDS_REGEX.test(trimmed)) return trimmed + ":00";
42
40
  var parsed = new Date(trimmed);
43
41
  if (Number.isNaN(parsed.getTime())) return undefined;
44
42
  return pad(parsed.getHours()) + ":" + pad(parsed.getMinutes()) + ":" + pad(parsed.getSeconds());
@@ -82,47 +80,6 @@ export var sectionsToIsoTime = function sectionsToIsoTime(sections, format) {
82
80
  }
83
81
  return pad(hour24) + ":" + pad(sections.minute) + ":" + pad(sections.second);
84
82
  };
85
- export var parseTime = function parseTime(value, format) {
86
- if (!value || typeof value !== 'string') return undefined;
87
- var trimmed = value.trim().toUpperCase();
88
- if (format === '12') {
89
- var _match = trimmed.match(/^(\d{1,2}):(\d{2}):(\d{2})\s*(AM|PM)$/);
90
- if (!_match) return undefined;
91
- var _hour = Number(_match[1]);
92
- var _minute = Number(_match[2]);
93
- var _second = Number(_match[3]);
94
- var period = _match[4];
95
- if (Number.isNaN(_hour) || Number.isNaN(_minute) || Number.isNaN(_second) || _hour < 1 || _hour > 12 || _minute < 0 || _minute > 59 || _second < 0 || _second > 59) {
96
- return undefined;
97
- }
98
- return {
99
- hour: _hour,
100
- minute: _minute,
101
- second: _second,
102
- period: period
103
- };
104
- }
105
- var match = trimmed.match(/^(\d{1,2}):(\d{2}):(\d{2})$/);
106
- if (!match) return undefined;
107
- var hour = Number(match[1]);
108
- var minute = Number(match[2]);
109
- var second = Number(match[3]);
110
- if (Number.isNaN(hour) || Number.isNaN(minute) || Number.isNaN(second) || hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {
111
- return undefined;
112
- }
113
- return {
114
- hour: hour,
115
- minute: minute,
116
- second: second
117
- };
118
- };
119
- export var formatTime = function formatTime(time, format) {
120
- if (!time) return undefined;
121
- if (format === '12') {
122
- return pad(time.hour) + ":" + pad(time.minute) + ":" + pad(time.second) + " " + (time.period || 'AM');
123
- }
124
- return pad(time.hour) + ":" + pad(time.minute) + ":" + pad(time.second);
125
- };
126
83
  export var defaultSections = function defaultSections(format) {
127
84
  return format === '12' ? {
128
85
  hour: undefined,
@@ -154,13 +111,14 @@ export var sectionKey = function sectionKey(section) {
154
111
  return getSectionKeyFromType(sectionType);
155
112
  };
156
113
  export var getSectionAriaMeta = function getSectionAriaMeta(_ref) {
157
- var _sections$key;
158
114
  var section = _ref.section,
159
115
  format = _ref.format,
160
116
  sections = _ref.sections;
161
117
  if (section === SECTION_PERIOD) {
118
+ var _now;
119
+ if (sections.period !== undefined) _now = sections.period === 'PM' ? 1 : 0;
162
120
  return {
163
- now: sections.period === 'PM' ? 1 : 0,
121
+ now: _now,
164
122
  min: 0,
165
123
  max: 1
166
124
  };
@@ -168,20 +126,13 @@ export var getSectionAriaMeta = function getSectionAriaMeta(_ref) {
168
126
  var key = sectionKey(section);
169
127
  var min = sectionMin(section, format);
170
128
  var max = sectionMax(section, format);
171
- var now = (_sections$key = sections[key]) != null ? _sections$key : section === SECTION_HOUR ? defaultHourForFormat(format) : min;
129
+ // Omit aria-valuenow entirely when the section has no value yet, rather
130
+ // than defaulting to a real number (e.g. 0) that would misrepresent an
131
+ // empty segment as having an actual value (WCAG 4.1.2).
132
+ var now = sections[key];
172
133
  return {
173
134
  now: now,
174
135
  min: min,
175
136
  max: max
176
137
  };
177
- };
178
- export var getActiveSectionAriaMeta = function getActiveSectionAriaMeta(_ref2) {
179
- var activeSection = _ref2.activeSection,
180
- format = _ref2.format,
181
- sections = _ref2.sections;
182
- return getSectionAriaMeta({
183
- section: activeSection,
184
- format: format,
185
- sections: sections
186
- });
187
138
  };