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