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.
- package/components/Box/StyledBox.js +1 -1
- package/components/Box/stories/ColorContrast.stories.js +36 -0
- package/components/Button/BusyAnimation.js +7 -1
- package/components/Button/Button.js +12 -3
- package/components/DataTable/StyledDataTable.js +1 -1
- package/components/DateInput/DateInput.js +3 -3
- package/components/DateTimeInput/DateTimeInput.js +17 -11
- package/components/FocusedContainer.js +2 -1
- package/components/FormField/FormField.js +31 -10
- package/components/FormField/FormFieldContext.js +12 -0
- package/components/Grommet/Grommet.js +4 -1
- package/components/Grommet/StyledGrommet.js +3 -3
- package/components/Grommet/index.d.ts +6 -0
- package/components/Grommet/propTypes.js +2 -0
- package/components/Menu/Menu.js +1 -1
- package/components/Select/SelectContainer.js +2 -2
- package/components/Select/StyledSelect.js +3 -1
- package/components/TextArea/StyledTextArea.js +3 -1
- package/components/TextInput/CopyButton.js +23 -6
- package/components/TextInput/StyledTextInput.js +19 -25
- package/components/TextInput/TextInput.js +75 -28
- package/components/TextInput/index.d.ts +12 -3
- package/components/TextInput/propTypes.js +2 -0
- package/components/TextInput/stories/Copy.stories.tsx +42 -0
- package/components/TextInput/stories/CopySecret.stories.tsx +44 -0
- package/components/TimeInput/README.md +24 -1
- package/components/TimeInput/StyledTimeInput.js +91 -27
- package/components/TimeInput/TimeInput.js +185 -120
- package/components/TimeInput/TimeInputPopup.js +114 -117
- package/components/TimeInput/index.d.ts +2 -0
- package/components/TimeInput/propTypes.js +2 -0
- package/components/TimeInput/stories/Controlled.stories.tsx +2 -2
- package/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
- package/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
- package/components/TimeInput/stories/Form.stories.tsx +1 -0
- package/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
- package/components/TimeInput/useSectionedTimeField.js +2 -2
- package/components/TimeInput/utils.js +13 -62
- package/components/Wizard/Wizard.js +396 -210
- package/components/Wizard/WizardContent.js +61 -35
- package/components/Wizard/WizardContext.js +3 -0
- package/components/Wizard/WizardFooter.js +14 -15
- package/components/Wizard/WizardHeader.js +12 -7
- package/components/Wizard/WizardProgress.js +27 -2
- package/components/Wizard/index.d.ts +35 -4
- package/components/Wizard/propTypes.js +6 -1
- package/components/Wizard/stories/BasicLinear.stories.js +12 -10
- package/components/Wizard/stories/ClickableSteps.stories.js +104 -0
- package/components/Wizard/stories/ExternalForm.stories.js +114 -0
- package/components/Wizard/stories/NonClosableHeader.stories.js +68 -0
- package/components/Wizard/stories/Validation.stories.js +18 -8
- package/es6/components/Box/StyledBox.js +1 -1
- package/es6/components/Box/stories/ColorContrast.stories.js +31 -0
- package/es6/components/Button/BusyAnimation.js +7 -1
- package/es6/components/Button/Button.js +12 -3
- package/es6/components/DataTable/StyledDataTable.js +2 -2
- package/es6/components/DateInput/DateInput.js +3 -3
- package/es6/components/DateTimeInput/DateTimeInput.js +17 -11
- package/es6/components/FocusedContainer.js +2 -1
- package/es6/components/FormField/FormField.js +31 -10
- package/es6/components/FormField/FormFieldContext.js +7 -0
- package/es6/components/Grommet/Grommet.js +4 -1
- package/es6/components/Grommet/StyledGrommet.js +4 -4
- package/es6/components/Grommet/index.d.ts +6 -0
- package/es6/components/Grommet/propTypes.js +2 -0
- package/es6/components/Menu/Menu.js +1 -1
- package/es6/components/Select/SelectContainer.js +2 -2
- package/es6/components/Select/StyledSelect.js +4 -2
- package/es6/components/TextArea/StyledTextArea.js +4 -2
- package/es6/components/TextInput/CopyButton.js +22 -6
- package/es6/components/TextInput/StyledTextInput.js +20 -26
- package/es6/components/TextInput/TextInput.js +76 -29
- package/es6/components/TextInput/index.d.ts +12 -3
- package/es6/components/TextInput/propTypes.js +2 -0
- package/es6/components/TextInput/stories/Copy.stories.tsx +42 -0
- package/es6/components/TextInput/stories/CopySecret.stories.tsx +44 -0
- package/es6/components/TimeInput/README.md +24 -1
- package/es6/components/TimeInput/StyledTimeInput.js +92 -28
- package/es6/components/TimeInput/TimeInput.js +187 -122
- package/es6/components/TimeInput/TimeInputPopup.js +115 -118
- package/es6/components/TimeInput/index.d.ts +2 -0
- package/es6/components/TimeInput/propTypes.js +2 -0
- package/es6/components/TimeInput/stories/Controlled.stories.tsx +2 -2
- package/es6/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
- package/es6/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
- package/es6/components/TimeInput/stories/Form.stories.tsx +1 -0
- package/es6/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +2 -2
- package/es6/components/TimeInput/utils.js +12 -61
- package/es6/components/Wizard/Wizard.js +397 -211
- package/es6/components/Wizard/WizardContent.js +62 -36
- package/es6/components/Wizard/WizardContext.js +3 -0
- package/es6/components/Wizard/WizardFooter.js +14 -15
- package/es6/components/Wizard/WizardHeader.js +12 -7
- package/es6/components/Wizard/WizardProgress.js +27 -2
- package/es6/components/Wizard/index.d.ts +35 -4
- package/es6/components/Wizard/propTypes.js +6 -1
- package/es6/components/Wizard/stories/BasicLinear.stories.js +11 -11
- package/es6/components/Wizard/stories/ClickableSteps.stories.js +99 -0
- package/es6/components/Wizard/stories/ExternalForm.stories.js +111 -0
- package/es6/components/Wizard/stories/NonClosableHeader.stories.js +63 -0
- package/es6/components/Wizard/stories/Validation.stories.js +18 -9
- package/es6/languages/default.json +2 -0
- package/es6/themes/base.d.ts +79 -59
- package/es6/themes/base.js +65 -34
- package/es6/utils/DOM.js +10 -7
- package/es6/utils/background.js +9 -7
- package/es6/utils/colors.js +84 -12
- package/es6/utils/legacyColorIsDark.js +17 -0
- package/es6/utils/styles.js +13 -5
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +2 -0
- package/package.json +3 -3
- package/themes/base.d.ts +79 -59
- package/themes/base.js +65 -34
- package/tools/draft-release-version-pr.js +1 -0
- package/tools/generate-release-notes.js +1 -1
- package/tools/release-notes-utils.js +1 -0
- package/utils/DOM.js +10 -7
- package/utils/background.js +9 -7
- package/utils/colors.js +84 -12
- package/utils/legacyColorIsDark.js +21 -0
- 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
|
+
};
|
|
@@ -163,7 +163,7 @@ var useSectionedTimeField = exports.useSectionedTimeField = function useSectione
|
|
|
163
163
|
setActiveSection(nextSection);
|
|
164
164
|
return nextSection;
|
|
165
165
|
}, [activeSection, sectionOrder, setActiveSection]);
|
|
166
|
-
var incrementSection = (0, _react.useCallback)(function (section, delta) {
|
|
166
|
+
var incrementSection = (0, _react.useCallback)(function (section, delta, isDrop) {
|
|
167
167
|
if (section === _utils.SECTION_PERIOD) {
|
|
168
168
|
setSectionValue(section, sections.period === 'AM' ? 'PM' : 'AM');
|
|
169
169
|
return;
|
|
@@ -173,7 +173,7 @@ var useSectionedTimeField = exports.useSectionedTimeField = function useSectione
|
|
|
173
173
|
var key = (0, _utils.sectionKey)(section);
|
|
174
174
|
var current = sections[key];
|
|
175
175
|
if (current === undefined) {
|
|
176
|
-
setSectionValue(section, delta > 0 ? minValue : maxValue);
|
|
176
|
+
setSectionValue(section, isDrop ? minValue : delta > 0 ? minValue : maxValue);
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
179
|
var step = section === _utils.SECTION_MINUTE ? minuteStep : section === _utils.SECTION_SECOND ? 1 : 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.sectionsToIsoTime = exports.sectionTypeFromSection = exports.sectionMin = exports.sectionMax = exports.sectionKey = exports.
|
|
4
|
+
exports.sectionsToIsoTime = exports.sectionTypeFromSection = exports.sectionMin = exports.sectionMax = exports.sectionKey = exports.normalizeToIsoTime = exports.isoTimeToSections = exports.hasAnyValue = exports.getSectionName = exports.getSectionAriaMeta = exports.defaultSections = exports.defaultHourForFormat = exports.SECTION_SECOND = exports.SECTION_PERIOD = exports.SECTION_MINUTE = exports.SECTION_HOUR = exports.ISO_TIME_REGEX = exports.ISO_TIME_NO_SECONDS_REGEX = void 0;
|
|
5
5
|
var _sectionHelpers = require("../../utils/sectionHelpers");
|
|
6
6
|
var _dates = require("../../utils/dates");
|
|
7
7
|
exports.pad = _dates.pad;
|
|
@@ -29,21 +29,19 @@ var getSectionName = exports.getSectionName = function getSectionName(section, f
|
|
|
29
29
|
if (format !== '12' && sectionType === 'meridiem') return undefined;
|
|
30
30
|
return sectionName;
|
|
31
31
|
};
|
|
32
|
-
var getRanges = exports.getRanges = function getRanges(format) {
|
|
33
|
-
if (format === '12') {
|
|
34
|
-
return [[0, 2], [3, 5], [6, 8], [9, 11]];
|
|
35
|
-
}
|
|
36
|
-
return [[0, 2], [3, 5], [6, 8]];
|
|
37
|
-
};
|
|
38
32
|
|
|
39
33
|
// TimeInput always transacts (value/defaultValue/onChange) in a canonical
|
|
40
34
|
// 24-hour ISO time string ("HH:MM:SS"), regardless of the display `format`
|
|
41
|
-
// prop.
|
|
35
|
+
// prop. Input may also be passed as "HH:MM" (without seconds); it's
|
|
36
|
+
// normalized to "HH:MM:00" so the rest of the component only ever deals
|
|
37
|
+
// with one shape.
|
|
42
38
|
var ISO_TIME_REGEX = exports.ISO_TIME_REGEX = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/;
|
|
39
|
+
var ISO_TIME_NO_SECONDS_REGEX = exports.ISO_TIME_NO_SECONDS_REGEX = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
|
43
40
|
var normalizeToIsoTime = exports.normalizeToIsoTime = function normalizeToIsoTime(value) {
|
|
44
41
|
if (typeof value !== 'string' || !value.trim()) return undefined;
|
|
45
42
|
var trimmed = value.trim();
|
|
46
43
|
if (ISO_TIME_REGEX.test(trimmed)) return trimmed;
|
|
44
|
+
if (ISO_TIME_NO_SECONDS_REGEX.test(trimmed)) return trimmed + ":00";
|
|
47
45
|
var parsed = new Date(trimmed);
|
|
48
46
|
if (Number.isNaN(parsed.getTime())) return undefined;
|
|
49
47
|
return (0, _dates.pad)(parsed.getHours()) + ":" + (0, _dates.pad)(parsed.getMinutes()) + ":" + (0, _dates.pad)(parsed.getSeconds());
|
|
@@ -87,47 +85,6 @@ var sectionsToIsoTime = exports.sectionsToIsoTime = function sectionsToIsoTime(s
|
|
|
87
85
|
}
|
|
88
86
|
return (0, _dates.pad)(hour24) + ":" + (0, _dates.pad)(sections.minute) + ":" + (0, _dates.pad)(sections.second);
|
|
89
87
|
};
|
|
90
|
-
var parseTime = exports.parseTime = function parseTime(value, format) {
|
|
91
|
-
if (!value || typeof value !== 'string') return undefined;
|
|
92
|
-
var trimmed = value.trim().toUpperCase();
|
|
93
|
-
if (format === '12') {
|
|
94
|
-
var _match = trimmed.match(/^(\d{1,2}):(\d{2}):(\d{2})\s*(AM|PM)$/);
|
|
95
|
-
if (!_match) return undefined;
|
|
96
|
-
var _hour = Number(_match[1]);
|
|
97
|
-
var _minute = Number(_match[2]);
|
|
98
|
-
var _second = Number(_match[3]);
|
|
99
|
-
var period = _match[4];
|
|
100
|
-
if (Number.isNaN(_hour) || Number.isNaN(_minute) || Number.isNaN(_second) || _hour < 1 || _hour > 12 || _minute < 0 || _minute > 59 || _second < 0 || _second > 59) {
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
hour: _hour,
|
|
105
|
-
minute: _minute,
|
|
106
|
-
second: _second,
|
|
107
|
-
period: period
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
var match = trimmed.match(/^(\d{1,2}):(\d{2}):(\d{2})$/);
|
|
111
|
-
if (!match) return undefined;
|
|
112
|
-
var hour = Number(match[1]);
|
|
113
|
-
var minute = Number(match[2]);
|
|
114
|
-
var second = Number(match[3]);
|
|
115
|
-
if (Number.isNaN(hour) || Number.isNaN(minute) || Number.isNaN(second) || hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
hour: hour,
|
|
120
|
-
minute: minute,
|
|
121
|
-
second: second
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
var formatTime = exports.formatTime = function formatTime(time, format) {
|
|
125
|
-
if (!time) return undefined;
|
|
126
|
-
if (format === '12') {
|
|
127
|
-
return (0, _dates.pad)(time.hour) + ":" + (0, _dates.pad)(time.minute) + ":" + (0, _dates.pad)(time.second) + " " + (time.period || 'AM');
|
|
128
|
-
}
|
|
129
|
-
return (0, _dates.pad)(time.hour) + ":" + (0, _dates.pad)(time.minute) + ":" + (0, _dates.pad)(time.second);
|
|
130
|
-
};
|
|
131
88
|
var defaultSections = exports.defaultSections = function defaultSections(format) {
|
|
132
89
|
return format === '12' ? {
|
|
133
90
|
hour: undefined,
|
|
@@ -159,13 +116,14 @@ var sectionKey = exports.sectionKey = function sectionKey(section) {
|
|
|
159
116
|
return (0, _sectionHelpers.getSectionKeyFromType)(sectionType);
|
|
160
117
|
};
|
|
161
118
|
var getSectionAriaMeta = exports.getSectionAriaMeta = function getSectionAriaMeta(_ref) {
|
|
162
|
-
var _sections$key;
|
|
163
119
|
var section = _ref.section,
|
|
164
120
|
format = _ref.format,
|
|
165
121
|
sections = _ref.sections;
|
|
166
122
|
if (section === SECTION_PERIOD) {
|
|
123
|
+
var _now;
|
|
124
|
+
if (sections.period !== undefined) _now = sections.period === 'PM' ? 1 : 0;
|
|
167
125
|
return {
|
|
168
|
-
now:
|
|
126
|
+
now: _now,
|
|
169
127
|
min: 0,
|
|
170
128
|
max: 1
|
|
171
129
|
};
|
|
@@ -173,20 +131,13 @@ var getSectionAriaMeta = exports.getSectionAriaMeta = function getSectionAriaMet
|
|
|
173
131
|
var key = sectionKey(section);
|
|
174
132
|
var min = sectionMin(section, format);
|
|
175
133
|
var max = sectionMax(section, format);
|
|
176
|
-
|
|
134
|
+
// Omit aria-valuenow entirely when the section has no value yet, rather
|
|
135
|
+
// than defaulting to a real number (e.g. 0) that would misrepresent an
|
|
136
|
+
// empty segment as having an actual value (WCAG 4.1.2).
|
|
137
|
+
var now = sections[key];
|
|
177
138
|
return {
|
|
178
139
|
now: now,
|
|
179
140
|
min: min,
|
|
180
141
|
max: max
|
|
181
142
|
};
|
|
182
|
-
};
|
|
183
|
-
var getActiveSectionAriaMeta = exports.getActiveSectionAriaMeta = function getActiveSectionAriaMeta(_ref2) {
|
|
184
|
-
var activeSection = _ref2.activeSection,
|
|
185
|
-
format = _ref2.format,
|
|
186
|
-
sections = _ref2.sections;
|
|
187
|
-
return getSectionAriaMeta({
|
|
188
|
-
section: activeSection,
|
|
189
|
-
format: format,
|
|
190
|
-
sections: sections
|
|
191
|
-
});
|
|
192
143
|
};
|