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
package/utils/colors.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.normalizeColor = exports.getRGBArray = exports.getRGBA = exports.colorIsDark = exports.canExtractRGBArray = void 0;
|
|
5
|
+
var _legacyColorIsDark = require("./legacyColorIsDark");
|
|
5
6
|
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
6
7
|
// SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
|
|
7
9
|
// Track which deprecated colors have already been warned about
|
|
8
10
|
var warnedColors = new Set();
|
|
9
11
|
var checkColorDeprecation = function checkColorDeprecation(color, theme, dark) {
|
|
@@ -139,29 +141,99 @@ var getRGBArray = exports.getRGBArray = function getRGBArray(color) {
|
|
|
139
141
|
}
|
|
140
142
|
return color;
|
|
141
143
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
|
|
145
|
+
// sRGB-to-linear conversion constants.
|
|
146
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
147
|
+
var SRGB_LINEAR_THRESHOLD = 0.04045;
|
|
148
|
+
var SRGB_LINEAR_DIVISOR = 12.92;
|
|
149
|
+
var SRGB_GAMMA_OFFSET = 0.055;
|
|
150
|
+
var SRGB_GAMMA_DIVISOR = 1.055;
|
|
151
|
+
var SRGB_GAMMA_EXPONENT = 2.4;
|
|
152
|
+
|
|
153
|
+
// Linearizes an sRGB channel (0-255) per the WCAG relative luminance spec.
|
|
154
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
155
|
+
var linearizeChannel = function linearizeChannel(value) {
|
|
156
|
+
var c = value / 255;
|
|
157
|
+
return c <= SRGB_LINEAR_THRESHOLD ? c / SRGB_LINEAR_DIVISOR : Math.pow((c + SRGB_GAMMA_OFFSET) / SRGB_GAMMA_DIVISOR, SRGB_GAMMA_EXPONENT);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// WCAG relative luminance coefficients for linearized sRGB channels.
|
|
161
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
162
|
+
var RED_LUMINANCE_COEFFICIENT = 0.2126;
|
|
163
|
+
var GREEN_LUMINANCE_COEFFICIENT = 0.7152;
|
|
164
|
+
var BLUE_LUMINANCE_COEFFICIENT = 0.0722;
|
|
165
|
+
var relativeLuminance = function relativeLuminance(red, green, blue) {
|
|
166
|
+
return RED_LUMINANCE_COEFFICIENT * linearizeChannel(red) + GREEN_LUMINANCE_COEFFICIENT * linearizeChannel(green) + BLUE_LUMINANCE_COEFFICIENT * linearizeChannel(blue);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Offset added to luminance values in the WCAG contrast ratio formula:
|
|
170
|
+
// (L1 + 0.05) / (L2 + 0.05). https://www.w3.org/TR/WCAG22/#dfn-contrast-ratio
|
|
171
|
+
var WCAG_CONTRAST_OFFSET = 0.05;
|
|
172
|
+
|
|
173
|
+
// Luminance at which black and white text have equal WCAG contrast ratios
|
|
174
|
+
// against the background: solving (1.05 / (L+0.05)) = ((L+0.05) / 0.05).
|
|
175
|
+
var EQUAL_CONTRAST_LUMINANCE = 0.179;
|
|
176
|
+
var luminanceOf = function luminanceOf(color, theme, dark) {
|
|
177
|
+
var resolved = theme && _normalizeColor(color, theme, dark) || color;
|
|
178
|
+
if (resolved && canExtractRGBArray(resolved)) {
|
|
179
|
+
var _getRGBArray = getRGBArray(resolved),
|
|
145
180
|
red = _getRGBArray[0],
|
|
146
181
|
green = _getRGBArray[1],
|
|
147
|
-
blue = _getRGBArray[2]
|
|
148
|
-
|
|
149
|
-
// if there is an alpha and it's greater than 50%, we can't really tell
|
|
150
|
-
if (alpha < 0.5) return undefined;
|
|
151
|
-
var brightness = (299 * red + 587 * green + 114 * blue) / 1000;
|
|
152
|
-
// From: http://www.had2know.com/technology/color-contrast-calculator-web-design.html
|
|
153
|
-
// Above domain is no longer registered.
|
|
154
|
-
return brightness < 125;
|
|
182
|
+
blue = _getRGBArray[2];
|
|
183
|
+
return relativeLuminance(red, green, blue);
|
|
155
184
|
}
|
|
156
185
|
return undefined;
|
|
157
186
|
};
|
|
158
|
-
|
|
187
|
+
|
|
188
|
+
// Luminance at which a pair of light/dark text colors have equal WCAG
|
|
189
|
+
// contrast against the background. text.light is the (typically darker)
|
|
190
|
+
// text used against light backgrounds and text.dark is the (typically
|
|
191
|
+
// lighter) text used against dark backgrounds. text defaults to
|
|
192
|
+
// theme.global.colors.text so callers that select an alternate text color
|
|
193
|
+
// pair (e.g. Button's explicit color prop) can pass it in and get a
|
|
194
|
+
// threshold that matches what will actually be selected. Falls back to the
|
|
195
|
+
// black/white derived EQUAL_CONTRAST_LUMINANCE when no usable text colors
|
|
196
|
+
// are available, preserving prior behavior for callers that don't pass one.
|
|
197
|
+
var equalContrastLuminance = function equalContrastLuminance(theme, text) {
|
|
198
|
+
if (text === void 0) {
|
|
199
|
+
var _theme$global;
|
|
200
|
+
text = theme == null || (_theme$global = theme.global) == null || (_theme$global = _theme$global.colors) == null ? void 0 : _theme$global.text;
|
|
201
|
+
}
|
|
202
|
+
if (!text) return EQUAL_CONTRAST_LUMINANCE;
|
|
203
|
+
// resolve both sides directly from text (a color name, a raw color, or a
|
|
204
|
+
// { dark, light } pair) with explicit dark args, so named theme colors
|
|
205
|
+
// (e.g. 'text') and aliases (e.g. text.dark: 'text-strong') resolve to
|
|
206
|
+
// the intended side rather than the theme's current mode
|
|
207
|
+
var darkTextLuminance = luminanceOf(text, theme, false);
|
|
208
|
+
var lightTextLuminance = luminanceOf(text, theme, true);
|
|
209
|
+
if (darkTextLuminance === undefined || lightTextLuminance === undefined) {
|
|
210
|
+
return EQUAL_CONTRAST_LUMINANCE;
|
|
211
|
+
}
|
|
212
|
+
return Math.sqrt((darkTextLuminance + WCAG_CONTRAST_OFFSET) * (lightTextLuminance + WCAG_CONTRAST_OFFSET)) - WCAG_CONTRAST_OFFSET;
|
|
213
|
+
};
|
|
214
|
+
var colorIsDark = exports.colorIsDark = function colorIsDark(color, theme, text) {
|
|
159
215
|
if (color && canExtractRGBArray(color)) {
|
|
160
216
|
var _getRGBArray2 = getRGBArray(color),
|
|
161
217
|
red = _getRGBArray2[0],
|
|
162
218
|
green = _getRGBArray2[1],
|
|
163
219
|
blue = _getRGBArray2[2],
|
|
164
220
|
alpha = _getRGBArray2[3];
|
|
221
|
+
// if there is an alpha and it's greater than 50%, we can't really tell
|
|
222
|
+
if (alpha < 0.5) return undefined;
|
|
223
|
+
if (theme != null && theme[_legacyColorIsDark.LEGACY_COLOR_IS_DARK]) {
|
|
224
|
+
return (0, _legacyColorIsDark.legacyColorIsDark)(red, green, blue);
|
|
225
|
+
}
|
|
226
|
+
return relativeLuminance(red, green, blue) < equalContrastLuminance(theme, text);
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
};
|
|
230
|
+
var getRGBA = exports.getRGBA = function getRGBA(color, opacity) {
|
|
231
|
+
if (color && canExtractRGBArray(color)) {
|
|
232
|
+
var _getRGBArray3 = getRGBArray(color),
|
|
233
|
+
red = _getRGBArray3[0],
|
|
234
|
+
green = _getRGBArray3[1],
|
|
235
|
+
blue = _getRGBArray3[2],
|
|
236
|
+
alpha = _getRGBArray3[3];
|
|
165
237
|
var normalizedAlpha;
|
|
166
238
|
if (opacity !== undefined) {
|
|
167
239
|
normalizedAlpha = opacity;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.legacyColorIsDark = exports.LEGACY_COLOR_IS_DARK = void 0;
|
|
5
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
var LEGACY_COLOR_IS_DARK = exports.LEGACY_COLOR_IS_DARK = Symbol('legacyColorIsDark');
|
|
8
|
+
|
|
9
|
+
// Brightness weights documented by Had2Know's legacy contrast calculator.
|
|
10
|
+
// https://www.had2know.org/technology/color-contrast-calculator-web-design.html
|
|
11
|
+
var RED_BRIGHTNESS_COEFFICIENT = 299;
|
|
12
|
+
var GREEN_BRIGHTNESS_COEFFICIENT = 587;
|
|
13
|
+
var BLUE_BRIGHTNESS_COEFFICIENT = 114;
|
|
14
|
+
var BRIGHTNESS_COEFFICIENT_DIVISOR = 1000;
|
|
15
|
+
|
|
16
|
+
// Legacy cutoff; the source's 125 threshold is for color-pair difference.
|
|
17
|
+
var DARK_BRIGHTNESS_THRESHOLD = 125;
|
|
18
|
+
var legacyColorIsDark = exports.legacyColorIsDark = function legacyColorIsDark(red, green, blue) {
|
|
19
|
+
var brightness = (RED_BRIGHTNESS_COEFFICIENT * red + GREEN_BRIGHTNESS_COEFFICIENT * green + BLUE_BRIGHTNESS_COEFFICIENT * blue) / BRIGHTNESS_COEFFICIENT_DIVISOR;
|
|
20
|
+
return brightness < DARK_BRIGHTNESS_THRESHOLD;
|
|
21
|
+
};
|
package/utils/styles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.widthStyle = exports.unfocusStyle = exports.textAlignStyle = exports.styledComponentsConfig = exports.sizeStyle = exports.roundStyle = exports.plainInputStyle = exports.overflowStyle = exports.kindPartStyles = exports.inputStyle = exports.inputPadForIcon = exports.heightStyle = exports.getInputPadBySide = exports.getInputIconPad = exports.genericStyles = exports.focusStyle = exports.fillStyle = exports.elevationStyle = exports.edgeStyle = exports.disabledStyle = exports.controlBorderStyle = exports.baseStyle = exports.alignStyle = exports.alignContentStyle = void 0;
|
|
4
|
+
exports.widthStyle = exports.unfocusStyle = exports.textAlignStyle = exports.styledComponentsConfig = exports.sizeStyle = exports.scrollbarStyle = exports.roundStyle = exports.plainInputStyle = exports.overflowStyle = exports.kindPartStyles = exports.inputStyle = exports.inputPadForIcon = exports.heightStyle = exports.getInputPadBySide = exports.getInputIconPad = exports.genericStyles = exports.focusStyle = exports.fillStyle = exports.elevationStyle = exports.edgeStyle = exports.disabledStyle = exports.controlBorderStyle = exports.baseStyle = exports.alignStyle = exports.alignContentStyle = void 0;
|
|
5
5
|
var _styledComponents = require("styled-components");
|
|
6
6
|
var _isPropValid = _interopRequireDefault(require("@emotion/is-prop-valid"));
|
|
7
7
|
var _background = require("./background");
|
|
@@ -322,11 +322,19 @@ var inputPadForIcon = exports.inputPadForIcon = (0, _styledComponents.css)(["",
|
|
|
322
322
|
var pad = getInputIconPad(props);
|
|
323
323
|
return props.reverse ? "padding-right: " + pad + ";" : "padding-left: " + pad + ";";
|
|
324
324
|
});
|
|
325
|
-
var
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
325
|
+
var scrollbarStyle = exports.scrollbarStyle = function scrollbarStyle(theme) {
|
|
326
|
+
var _theme$global$scrollb;
|
|
327
|
+
var width = theme.global && ((_theme$global$scrollb = theme.global.scrollbar) == null ? void 0 : _theme$global$scrollb.width);
|
|
328
|
+
var color = (0, _colors.normalizeColor)('scrollbar', theme);
|
|
329
|
+
if (!color && !width) return undefined;
|
|
330
|
+
return (0, _styledComponents.css)(["", " ", ""], color && "scrollbar-color: " + color + " transparent;", width !== undefined && "scrollbar-width: " + width + ";");
|
|
331
|
+
};
|
|
332
|
+
var overflowStyle = exports.overflowStyle = function overflowStyle(overflowProp, theme) {
|
|
333
|
+
var overflow = typeof overflowProp === 'string' ? "overflow: " + overflowProp + ";" : [overflowProp.horizontal && "overflow-x: " + overflowProp.horizontal + ";", overflowProp.vertical && "overflow-y: " + overflowProp.vertical + ";"].filter(Boolean).join(' ');
|
|
334
|
+
var scrollable = ['auto', 'scroll', 'overlay'].some(function (value) {
|
|
335
|
+
return overflow.includes(": " + value + ";");
|
|
336
|
+
});
|
|
337
|
+
return (0, _styledComponents.css)(["", " ", ""], overflow, scrollable && scrollbarStyle(theme));
|
|
330
338
|
};
|
|
331
339
|
var ALIGN_SELF_MAP = {
|
|
332
340
|
center: 'center',
|