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/languages/default.json
CHANGED
|
@@ -147,6 +147,7 @@
|
|
|
147
147
|
"input": {
|
|
148
148
|
"readOnlyCopy": {
|
|
149
149
|
"prompt": "Copy to clipboard",
|
|
150
|
+
"promptWithValue": "Copy to clipboard {value}",
|
|
150
151
|
"validation": "Copied"
|
|
151
152
|
}
|
|
152
153
|
},
|
|
@@ -240,6 +241,7 @@
|
|
|
240
241
|
"inputLabel": "Time input",
|
|
241
242
|
"chooseTime": "Choose time",
|
|
242
243
|
"currentValue": "Current time {hour}:{minute}:{second}{period}",
|
|
244
|
+
"currentValueWithoutSeconds": "Current time {hour}:{minute}{period}",
|
|
243
245
|
"activeSection": "{section} selected",
|
|
244
246
|
"activeSectionValue": "{value} {section}",
|
|
245
247
|
"activePeriodValue": "{period} period",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grommet",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.58.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "es6/index.js",
|
|
6
6
|
"jsnext:main": "es6/index.js",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"eslint-plugin-testing-library": "^7.16.2",
|
|
126
126
|
"fs-extra": "^11.4.0",
|
|
127
127
|
"globals": "^17.11.0",
|
|
128
|
-
"grommet-theme-hpe": "^8.
|
|
128
|
+
"grommet-theme-hpe": "^8.2.0",
|
|
129
129
|
"jest": "^30.4.2",
|
|
130
130
|
"jest-axe": "^11.0.0",
|
|
131
131
|
"jest-cli": "^30.4.2",
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
"bundlesize": [
|
|
219
219
|
{
|
|
220
220
|
"path": "./dist/grommet.min.js",
|
|
221
|
-
"maxSize": "
|
|
221
|
+
"maxSize": "222 kB"
|
|
222
222
|
}
|
|
223
223
|
],
|
|
224
224
|
"keywords": [
|
package/themes/base.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FlattenSimpleInterpolation,
|
|
6
|
-
ThemedStyledProps,
|
|
7
|
-
} from 'styled-components';
|
|
8
|
-
import { ReactComponentElement } from 'react';
|
|
3
|
+
import { Interpolation } from 'styled-components';
|
|
4
|
+
import { ReactElement } from 'react';
|
|
9
5
|
import { Icon } from 'grommet-icons';
|
|
10
6
|
|
|
11
7
|
import {
|
|
@@ -51,6 +47,30 @@ import { HeadingProps } from '../components/Heading';
|
|
|
51
47
|
import { ParagraphProps } from '../components/Paragraph';
|
|
52
48
|
import { SkeletonProps } from '../components/Skeleton/index';
|
|
53
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Themeable visual properties shared by component parts rendered as a Box.
|
|
52
|
+
* Keep structural, behavioral, and accessibility props out of theme parts.
|
|
53
|
+
*/
|
|
54
|
+
type BoxPartThemeType = Pick<
|
|
55
|
+
BoxProps,
|
|
56
|
+
| 'background'
|
|
57
|
+
| 'border'
|
|
58
|
+
| 'elevation'
|
|
59
|
+
| 'height'
|
|
60
|
+
| 'margin'
|
|
61
|
+
| 'pad'
|
|
62
|
+
| 'round'
|
|
63
|
+
| 'width'
|
|
64
|
+
>;
|
|
65
|
+
|
|
66
|
+
type BoxStateThemeType = Pick<
|
|
67
|
+
BoxPartThemeType,
|
|
68
|
+
'background' | 'border' | 'elevation' | 'pad' | 'round'
|
|
69
|
+
>;
|
|
70
|
+
|
|
71
|
+
/** Text presentation properties shared by themeable component text parts. */
|
|
72
|
+
type TextThemeType = Pick<TextProps, 'color' | 'size' | 'weight'>;
|
|
73
|
+
|
|
54
74
|
export declare const base: DeepReadonly<ThemeType>;
|
|
55
75
|
export declare const generate: (
|
|
56
76
|
baseSpacing?: number,
|
|
@@ -60,23 +80,25 @@ export declare const generate: (
|
|
|
60
80
|
/**
|
|
61
81
|
* ExtendProps represents the props that will be provided to an ExtendType.
|
|
62
82
|
*/
|
|
63
|
-
type ExtendProps<TProps> =
|
|
83
|
+
type ExtendProps<TProps> = TProps & { theme: ThemeType };
|
|
64
84
|
|
|
65
85
|
/**
|
|
66
86
|
* ExtendValue represents a valid `extend` value, which can be a CSS string or a
|
|
67
87
|
* styled-components interpolation. In the theme an ExtendValue can be provided
|
|
68
88
|
* directly to `extend` or it can be computed as the result of an ExtendFn.
|
|
69
89
|
*/
|
|
70
|
-
type ExtendValue<TProps> =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
90
|
+
type ExtendValue<TProps> = Exclude<
|
|
91
|
+
Interpolation<ExtendProps<TProps>>,
|
|
92
|
+
(...args: any[]) => any
|
|
93
|
+
>;
|
|
74
94
|
|
|
75
95
|
/**
|
|
76
96
|
* ExtendFn represents a function passed to `extend`. These functions receive
|
|
77
97
|
* props and produce an ExtendValue.
|
|
78
98
|
*/
|
|
79
|
-
type ExtendFn<TProps> =
|
|
99
|
+
type ExtendFn<TProps> = {
|
|
100
|
+
bivarianceHack(props: ExtendProps<TProps>): ExtendValue<TProps>;
|
|
101
|
+
}['bivarianceHack'];
|
|
80
102
|
|
|
81
103
|
/**
|
|
82
104
|
* ExtendType represents the type for `extend` values in the theme.
|
|
@@ -281,7 +303,7 @@ interface ButtonType {
|
|
|
281
303
|
};
|
|
282
304
|
}
|
|
283
305
|
interface FormFieldLabelType extends TextProps {
|
|
284
|
-
requiredIndicator?: boolean |
|
|
306
|
+
requiredIndicator?: boolean | ReactElement<unknown> | string;
|
|
285
307
|
}
|
|
286
308
|
|
|
287
309
|
type DigitalTexts =
|
|
@@ -342,6 +364,43 @@ interface StepperStatusWithHelperTextStateType extends StepperStatusStateType {
|
|
|
342
364
|
};
|
|
343
365
|
}
|
|
344
366
|
|
|
367
|
+
type TimeInputOptionThemeType = {
|
|
368
|
+
container?: BoxPartThemeType & {
|
|
369
|
+
hover?: BoxStateThemeType;
|
|
370
|
+
selected?: BoxStateThemeType & {
|
|
371
|
+
hover?: BoxStateThemeType;
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
text?: TextThemeType & {
|
|
375
|
+
selected?: TextThemeType;
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
type TimeInputButtonIconType = React.ReactNode | Icon;
|
|
380
|
+
|
|
381
|
+
type TimeInputDropButtonThemeType =
|
|
382
|
+
| string
|
|
383
|
+
| { kind: string; icon?: TimeInputButtonIconType }
|
|
384
|
+
| (ButtonType & { icon?: TimeInputButtonIconType });
|
|
385
|
+
|
|
386
|
+
type TimeInputThemeType = {
|
|
387
|
+
container?: BoxPartThemeType;
|
|
388
|
+
value?: BoxPartThemeType;
|
|
389
|
+
segment?: BoxPartThemeType &
|
|
390
|
+
TextThemeType & {
|
|
391
|
+
placeholder?: TextThemeType;
|
|
392
|
+
active?: BoxStateThemeType & TextThemeType;
|
|
393
|
+
};
|
|
394
|
+
dropButton?: TimeInputDropButtonThemeType;
|
|
395
|
+
drop?: BoxPartThemeType & {
|
|
396
|
+
gap?: GapType;
|
|
397
|
+
column?: BoxPartThemeType & {
|
|
398
|
+
gap?: GapType;
|
|
399
|
+
};
|
|
400
|
+
option?: TimeInputOptionThemeType;
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
|
|
345
404
|
export interface ThemeType {
|
|
346
405
|
global?: {
|
|
347
406
|
active?: {
|
|
@@ -414,6 +473,9 @@ export interface ThemeType {
|
|
|
414
473
|
computer?: string;
|
|
415
474
|
};
|
|
416
475
|
colors?: Colors;
|
|
476
|
+
scrollbar?: {
|
|
477
|
+
width?: 'auto' | 'thin' | 'none';
|
|
478
|
+
};
|
|
417
479
|
control?: {
|
|
418
480
|
border?: {
|
|
419
481
|
width?: string;
|
|
@@ -456,7 +518,7 @@ export interface ThemeType {
|
|
|
456
518
|
medium?: string;
|
|
457
519
|
large?: string;
|
|
458
520
|
xlarge?: string;
|
|
459
|
-
[x: string]: string;
|
|
521
|
+
[x: string]: string | undefined;
|
|
460
522
|
};
|
|
461
523
|
dark?: {
|
|
462
524
|
none?: string;
|
|
@@ -465,7 +527,7 @@ export interface ThemeType {
|
|
|
465
527
|
medium?: string;
|
|
466
528
|
large?: string;
|
|
467
529
|
xlarge?: string;
|
|
468
|
-
[x: string]: string;
|
|
530
|
+
[x: string]: string | undefined;
|
|
469
531
|
};
|
|
470
532
|
};
|
|
471
533
|
focus?: {
|
|
@@ -2046,8 +2108,7 @@ export interface ThemeType {
|
|
|
2046
2108
|
search?: {
|
|
2047
2109
|
pad?: PadType;
|
|
2048
2110
|
};
|
|
2049
|
-
|
|
2050
|
-
searchInput?: ReactComponentElement<any>;
|
|
2111
|
+
searchInput?: ReactElement<any>;
|
|
2051
2112
|
step?: number;
|
|
2052
2113
|
};
|
|
2053
2114
|
selectMultiple?: {
|
|
@@ -2412,48 +2473,7 @@ export interface ThemeType {
|
|
|
2412
2473
|
extend?: ExtendType;
|
|
2413
2474
|
};
|
|
2414
2475
|
};
|
|
2415
|
-
timeInput?:
|
|
2416
|
-
button?: {
|
|
2417
|
-
margin?: MarginType;
|
|
2418
|
-
};
|
|
2419
|
-
container?: {
|
|
2420
|
-
round?: RoundType;
|
|
2421
|
-
};
|
|
2422
|
-
active?: {
|
|
2423
|
-
background?: ColorType;
|
|
2424
|
-
pad?: string;
|
|
2425
|
-
indicator?: {
|
|
2426
|
-
color?: ColorType;
|
|
2427
|
-
size?: string;
|
|
2428
|
-
};
|
|
2429
|
-
};
|
|
2430
|
-
drop?: {
|
|
2431
|
-
gap?: GapType;
|
|
2432
|
-
option?: {
|
|
2433
|
-
background?: ColorType;
|
|
2434
|
-
gap?: GapType;
|
|
2435
|
-
size?: string;
|
|
2436
|
-
pad?: PadType;
|
|
2437
|
-
round?: RoundType;
|
|
2438
|
-
hover?: {
|
|
2439
|
-
background?: ColorType;
|
|
2440
|
-
};
|
|
2441
|
-
selected?: {
|
|
2442
|
-
background?: ColorType;
|
|
2443
|
-
color?: ColorType;
|
|
2444
|
-
text?: {
|
|
2445
|
-
weight?: string | number;
|
|
2446
|
-
};
|
|
2447
|
-
hover?: {
|
|
2448
|
-
background?: ColorType;
|
|
2449
|
-
};
|
|
2450
|
-
};
|
|
2451
|
-
};
|
|
2452
|
-
};
|
|
2453
|
-
icon?: {
|
|
2454
|
-
clock?: React.ReactNode | Icon;
|
|
2455
|
-
};
|
|
2456
|
-
};
|
|
2476
|
+
timeInput?: TimeInputThemeType;
|
|
2457
2477
|
tip?: {
|
|
2458
2478
|
content?: BoxProps;
|
|
2459
2479
|
drop?: DropProps;
|
package/themes/base.js
CHANGED
|
@@ -67,6 +67,7 @@ var colors = {
|
|
|
67
67
|
dark: 'rgba(255, 255, 255, 0.33)',
|
|
68
68
|
light: 'rgba(0, 0, 0, 0.33)'
|
|
69
69
|
},
|
|
70
|
+
scrollbar: 'border',
|
|
70
71
|
brand: brandColor,
|
|
71
72
|
control: {
|
|
72
73
|
dark: 'accent-1',
|
|
@@ -224,6 +225,9 @@ var generate = exports.generate = function generate(baseSpacing, scale) {
|
|
|
224
225
|
computer: 'large'
|
|
225
226
|
},
|
|
226
227
|
colors: colors,
|
|
228
|
+
scrollbar: {
|
|
229
|
+
// width: undefined,
|
|
230
|
+
},
|
|
227
231
|
control: {
|
|
228
232
|
border: {
|
|
229
233
|
width: controlBorderWidth + "px",
|
|
@@ -1152,6 +1156,7 @@ var generate = exports.generate = function generate(baseSpacing, scale) {
|
|
|
1152
1156
|
}
|
|
1153
1157
|
},
|
|
1154
1158
|
drop: {
|
|
1159
|
+
height: 'medium',
|
|
1155
1160
|
pad: 'small',
|
|
1156
1161
|
gap: 'small',
|
|
1157
1162
|
border: {
|
|
@@ -2901,53 +2906,79 @@ var generate = exports.generate = function generate(baseSpacing, scale) {
|
|
|
2901
2906
|
}
|
|
2902
2907
|
},
|
|
2903
2908
|
timeInput: {
|
|
2904
|
-
button: {
|
|
2905
|
-
margin: {
|
|
2906
|
-
right: 'small'
|
|
2907
|
-
}
|
|
2908
|
-
},
|
|
2909
2909
|
container: {
|
|
2910
|
+
// any BoxPartThemeType
|
|
2910
2911
|
round: 'xxsmall'
|
|
2911
2912
|
},
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2913
|
+
// value: {
|
|
2914
|
+
// any BoxPartThemeType
|
|
2915
|
+
// },
|
|
2916
|
+
segment: {
|
|
2917
|
+
// any BoxPartThemeType
|
|
2918
|
+
// any TextThemeType
|
|
2919
|
+
pad: {
|
|
2920
|
+
horizontal: 'xxsmall'
|
|
2921
|
+
},
|
|
2922
|
+
active: {
|
|
2923
|
+
// any BoxPartThemeType
|
|
2924
|
+
// any TextThemeType
|
|
2925
|
+
background: 'active-background',
|
|
2926
|
+
border: {
|
|
2927
|
+
color: {
|
|
2928
|
+
dark: 'white',
|
|
2929
|
+
light: 'black'
|
|
2930
|
+
},
|
|
2931
|
+
side: 'bottom',
|
|
2932
|
+
size: 'small'
|
|
2933
|
+
}
|
|
2921
2934
|
}
|
|
2922
2935
|
},
|
|
2936
|
+
// dropButton: {
|
|
2937
|
+
// // any ButtonType
|
|
2938
|
+
// icon: undefined,
|
|
2939
|
+
// },
|
|
2923
2940
|
drop: {
|
|
2924
|
-
//
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2941
|
+
// any BoxPartThemeType
|
|
2942
|
+
height: 'small',
|
|
2943
|
+
gap: 'none',
|
|
2944
|
+
pad: {
|
|
2945
|
+
horizontal: 'xsmall',
|
|
2946
|
+
vertical: 'small'
|
|
2947
|
+
},
|
|
2948
|
+
column: {
|
|
2949
|
+
height: '100%',
|
|
2950
|
+
gap: 'xxsmall',
|
|
2929
2951
|
pad: {
|
|
2930
|
-
vertical: 'xxsmall',
|
|
2931
2952
|
horizontal: 'xsmall'
|
|
2932
|
-
}
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
text: {
|
|
2941
|
-
weight: 500
|
|
2953
|
+
}
|
|
2954
|
+
},
|
|
2955
|
+
option: {
|
|
2956
|
+
container: {
|
|
2957
|
+
// any BoxPartThemeType
|
|
2958
|
+
pad: {
|
|
2959
|
+
vertical: 'xxsmall',
|
|
2960
|
+
horizontal: 'xsmall'
|
|
2942
2961
|
},
|
|
2962
|
+
round: baseSpacing / 6 + "px",
|
|
2963
|
+
// 4px
|
|
2943
2964
|
hover: {
|
|
2944
|
-
//
|
|
2965
|
+
// any BoxPartThemeType
|
|
2966
|
+
background: 'active-background'
|
|
2967
|
+
},
|
|
2968
|
+
selected: {
|
|
2969
|
+
// any BoxPartThemeType
|
|
2970
|
+
background: 'selected'
|
|
2971
|
+
}
|
|
2972
|
+
},
|
|
2973
|
+
text: {
|
|
2974
|
+
// any TextThemeType
|
|
2975
|
+
selected: {
|
|
2976
|
+
// any TextThemeType
|
|
2977
|
+
color: 'white',
|
|
2978
|
+
weight: 500
|
|
2945
2979
|
}
|
|
2946
2980
|
}
|
|
2947
2981
|
}
|
|
2948
|
-
},
|
|
2949
|
-
icon: {
|
|
2950
|
-
// clock: undefined,
|
|
2951
2982
|
}
|
|
2952
2983
|
},
|
|
2953
2984
|
tip: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync,writeFileSync,appendFileSync}from"fs";const NOTES_PATH="RELEASE_NOTES_DRAFT.md",CHECKLIST_PATH="RELEASE_CHECKLIST.md",PACKAGE_PATH="package.json",CHANGELOG_PATH="CHANGELOG.md";function suggestBump(e){const n=e.match(/── Suggested semver bump ─+\n\n(MAJOR|MINOR|PATCH)\b/);if(!n)throw new Error("Could not find a suggested semver bump in RELEASE_CHECKLIST.md");return n[1].toLowerCase()}function bumpVersion(e,n){const[t,r,i]=e.split(".").map(Number);return"major"===n?`${t+1}.0.0`:"minor"===n?`${t}.${r+1}.0`:`${t}.${r}.${i+1}`}function setGithubOutput(e,n){const t=process.env.GITHUB_OUTPUT;t&&appendFileSync(t,`${e}=${n}\n`)}const notes=readFileSync(NOTES_PATH,"utf8").trim(),checklist=readFileSync(CHECKLIST_PATH,"utf8"),override=process.env.BUMP_OVERRIDE,bump=override&&"auto"!==override?override:suggestBump(checklist),pkg=JSON.parse(readFileSync(PACKAGE_PATH,"utf8")),nextVersion=bumpVersion(pkg.version,bump);pkg.version=nextVersion,writeFileSync(PACKAGE_PATH,`${JSON.stringify(pkg,null,2)}\n`,"utf8");const changelog=readFileSync("CHANGELOG.md","utf8"),entry=`# ${nextVersion}\n\n${notes}\n\n`;writeFileSync("CHANGELOG.md",entry+changelog,"utf8"),console.log(`Suggested bump: ${bump} -> v${nextVersion}`),setGithubOutput("version",nextVersion),setGithubOutput("bump",bump);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync,readdirSync,readFileSync,statSync,writeFileSync}from"fs";import{join}from"path";const OWNER="grommet",REPO="grommet",API=`https://api.github.com/repos/${OWNER}/${REPO}`,GH_PR_URL=`https://github.com/${OWNER}/${REPO}/pull`,GH_RELEASE_URL=`https://github.com/${OWNER}/${REPO}/releases/tag`,GH_COMPARE_URL=`https://github.com/${OWNER}/${REPO}/compare`,DEFAULT_CHANGELOG_FILE="CHANGELOG.md",PLACEHOLDER_VERSION="X.X.X",LABEL_SECTION_MAP=new Map([["DataTable","DataTable"],["DateInput","DateInput"],["DateTimeInput","DateTimeInput"],["TimeInput","TimeInput"],["FileInput","FileInput"],["Select","Select / SelectMultiple"],["SelectMultiple","Select / SelectMultiple"],["List","List"],["RadioButton","RadioButton / RadioButtonGroup"],["RadioButtonGroup","RadioButton / RadioButtonGroup"],["RangeSelector","RangeSelector"],["TypeScript","TypeScript"],["typescript","TypeScript"],["Beta","Beta"],["beta","Beta"],["Calendar","Calendar"],["TextInput","TextInput"],["MaskedInput","MaskedInput"],["Notification","Notification"],["Layer","Layer"],["Button","Button"],["Form","Form"],["FormField","FormField"],["Stepper","Stepper"],["Wizard","Wizard"],["Tabs","Tabs"],["Pagination","Pagination"],["Menu","Menu"],["Anchor","Anchor"],["CheckBox","CheckBox / CheckBoxGroup"],["CheckBoxGroup","CheckBoxGroup / CheckBox"],["Data","Data"],["DataChart","Chart / DataChart"],["Chart","Chart / DataChart"],["DataFilter","DataFilter"]]),SECTION_ORDER=["General","Anchor","Button","Calendar","Chart / DataChart","CheckBox","Data","DataFilter","DataTable","DateInput","DateTimeInput","FileInput","Form","FormField","Layer","List","MaskedInput","Menu","Notification","Pagination","RadioButton / RadioButtonGroup","RangeSelector","Select / SelectMultiple","Stepper","Tabs","TextInput","TimeInput","TypeScript","Beta"],SKIP_LABELS=new Set(["skip-release-notes","no-release-notes","internal","dependencies","chore","ci","documentation"]),BETA_LABELS=new Set(["beta","Beta"]),DEFAULT_BETA_COMPONENT_SECTIONS=new Set(["DateTimeInput","Stepper","TimeInput","Wizard"]),MIN_COMPONENT_SECTION_SIZE=3,BETA_WARNING_PATTERN=/currently in beta[\s\S]*api is subject\s+to\s+change/i;function getSourceBetaComponentSections(){const e=join(process.cwd(),"src","js","components");if(!existsSync(e))return new Set;const t=new Set,n=readdirSync(e);for(const o of n){const n=join(e,o);if(!statSync(n).isDirectory())continue;const r=join(n,`${o}.js`);if(existsSync(r))try{const e=readFileSync(r,"utf8");BETA_WARNING_PATTERN.test(e)&&t.add(o)}catch{}}return t}const BETA_COMPONENT_SECTIONS=new Set([...Array.from(DEFAULT_BETA_COMPONENT_SECTIONS),...Array.from(getSourceBetaComponentSections())]);function parseArgs(){const e=process.argv.slice(2),t={from:null,to:null,format:(process.argv[1]||"").includes("announcement")?"announcement":"release-notes",output:null,changelog:null,version:null,token:process.env.GH_TOKEN||null};for(let n=0;n<e.length;n++){const o=e[n];if("--from"===o)t.from=e[++n];else if("--to"===o)t.to=e[++n];else if("--format"===o)t.format=e[++n];else if("--output"===o)t.output=e[++n];else if("--changelog"===o){const o=e[n+1];t.changelog=o&&!o.startsWith("--")?e[++n]:"CHANGELOG.md"}else"--no-changelog"===o?t.changelog=!1:"--version"===o?t.version=e[++n]:"--token"===o?t.token=e[++n]:o.startsWith("--")||t.from?o.startsWith("--")||t.to||(t.to=o):t.from=o}return t}function getRequestHeaders(e){return{...e?{Authorization:`Bearer ${e}`}:{},Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}async function ghGet(e,t){const n=await fetch(e,{headers:getRequestHeaders(t)});if(!n.ok){const t=await n.text();if(403===n.status&&t.includes("API rate limit exceeded"))throw new Error("GitHub API rate limit exceeded. Set GH_TOKEN or pass --token to generate release output.");throw new Error(`GitHub API ${n.status} at ${e}:\n${t}`)}return n.json()}async function resolveRef(e,t){if(!e||"HEAD"===e){const e=await ghGet(`${API}`,t),n=await ghGet(`${API}/branches/${e.default_branch}`,t);return{sha:n.commit.sha,date:n.commit.commit.committer.date}}try{const n=await ghGet(`${API}/git/refs/tags/${e}`,t);let{sha:o}=n.object;return"tag"===n.object.type&&(o=(await ghGet(`${API}/git/tags/${o}`,t)).object.sha),{sha:o,date:(await ghGet(`${API}/commits/${o}`,t)).commit.committer.date}}catch{const n=await ghGet(`${API}/commits/${e}`,t);return{sha:n.sha,date:n.commit.committer.date}}}async function getLatestTag(e){const t=await ghGet(`${API}/tags?per_page=5`,e);if(!t.length)throw new Error("No tags found in repository.");return t[0].name}function includeByBody(e){if(!e)return!0;const t=e.toLowerCase().indexOf("should this pr be mentioned in the release notes?");if(-1===t)return!0;const n=e.slice(t+49),o=n.indexOf("####"),r=(-1===o?n:n.slice(0,o)).trim().split("\n")[0].trim().toLowerCase().replace(/[.!?]+$/,"");return!r||!new Set(["no","n","n/a","na","-","nope","false"]).has(r)}function shouldSkipByContent(e){const t=(e.title||"").toLowerCase(),n=(e.body||"").toLowerCase(),o=`${t}\n${n}`;return[/\bupdate\b.*\bdependenc(y|ies)\b/,/\bdependenc(y|ies)\b.*\bupdate\b/,/\bupdate styled components\b/,/\bbump\b.*\b(dependency|dependencies)\b/,/\bupgrade\b.*\b(dependency|dependencies|styled-components)\b/].some((e=>e.test(o)))?{skip:!0,reason:"dependency"}:[/\bchore\s*[:(]/,/^new chore\b/].some((e=>e.test(t)))?{skip:!0,reason:"chore"}:[/\bstorybook\b/,/\bchromatic\b/,/\bstories\b/].some((e=>e.test(t)))?{skip:!0,reason:"storybook"}:{skip:!1,reason:null}}function getSection(e){const t=e.labels.map((e=>e.name));if(t.some((e=>BETA_LABELS.has(e))))return"Beta";if(t.some((e=>"TypeScript"===e||"typescript"===e)))return"TypeScript";for(const e of t){const t=LABEL_SECTION_MAP.get(e);if(t)return t}const n=e.title.match(/^[A-Za-z]+\(([^)]+)\):/);if(n){const e=n[1].trim();for(const[t,n]of LABEL_SECTION_MAP)if(t.toLowerCase()===e.toLowerCase())return n}const o=e.title.toLowerCase();for(const[e,t]of LABEL_SECTION_MAP){const n=e.toLowerCase();if(o.startsWith(`${n} `)||o.startsWith(`${n}:`)||o.startsWith(`${n}-`)||o.startsWith(`${n},`))return t}return"General"}function formatEntry(e){return`- ${formatReleaseSentence(e).replace(/[.!?]+$/,"")}. [#${e.number}](${GH_PR_URL}/${e.number})`}function lowerFirst(e){return e?e.charAt(0).toLowerCase()+e.slice(1):e}function formatReleaseSentence(e){const t=e.title.trim().replace(/[.!?]+$/,""),n=t.match(/^fix\(([^)]+)\):\s*(.+)$/i);if(n){const[,e,t]=n;return`Fixed ${e} ${lowerFirst(t)}`}const o=t.match(/^feat\(([^)]+)\):\s*(.+)$/i);if(o){const[,e,t]=o;return`Added ${e} ${lowerFirst(t)}`}const r=t.match(/^(enhance|enhanced|improve|improved)\(([^)]+)\):\s*(.+)$/i);if(r){const[,,e,t]=r;return`Enhanced ${e} ${lowerFirst(t)}`}const s=t.match(/^([A-Za-z][A-Za-z0-9/\s-]*)\s*-\s*(fix|feat|add|improve|enhance)\s*(.+)$/i);if(s){const[,e,t,n]=s;return/fix/i.test(t)?`Fixed ${e.trim()} ${n.trim()}`:/feat|add/i.test(t)?`Added ${e.trim()} ${n.trim()}`:`Enhanced ${e.trim()} ${n.trim()}`}return/^fix\b/i.test(t)?`Fixed ${t.replace(/^fix\b[:\s-]*/i,"")}`:/^feat\b/i.test(t)?`Added ${t.replace(/^feat\b[:\s-]*/i,"")}`:/^(add|added)\b/i.test(t)?`Added ${t.replace(/^(add|added)\b[:\s-]*/i,"")}`:/^(improve|improved|enhance|enhanced)\b/i.test(t)?`Enhanced ${t.replace(/^(improve|improved|enhance|enhanced)\b[:\s-]*/i,"")}`:t.charAt(0).toUpperCase()+t.slice(1)}function formatTitlePhrase(e){const t=e.trim().replace(/[.!?]+$/,"");return t.charAt(0).toLowerCase()+t.slice(1)}function humanJoin(e){return 0===e.length?"":1===e.length?e[0]:2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`}function unique(e){return e.filter(((t,n)=>t&&e.indexOf(t)===n))}function getAnnouncementHighlights(e){const t=[/^added\b/i,/^enhanced\b/i,/^improved\b/i];return e.filter((e=>t.some((t=>t.test(e.title))))).slice(0,2).map((e=>formatTitlePhrase(e.title)))}function getFixSummary(e){const t=unique(e.filter((e=>/^fixed\b/i.test(e.title))).map((e=>e.section)).filter((e=>e&&"General"!==e&&"Beta"!==e)));if(0===t.length)return null;const n=t.slice(0,5),o=t.length>5?", and more":"";return`There are also fixes across ${humanJoin(n)}${o}.`}function formatContributors(e){const t=unique(e.map((e=>e.user?.login)).filter((e=>e&&"app/dependabot"!==e)));return 0===t.length?null:`Thank you to everyone who contributed to this release ${humanJoin(t.map((e=>`<https://github.com/${e}|${e}>`)))}!`}function inferNextReleaseTag(e,t){if(t&&/^v\d+\.\d+\.\d+$/i.test(t))return t;const n=(e||"").match(/^v(\d+)\./i);return n?`v${n[1]}.x.x`:"v2.x.x"}function extractComponentName(e){const t=(e.title||"").trim(),n=t.match(/^[A-Za-z]+\(([^)]+)\):/);if(n)return n[1].trim();const o=t.match(/^([A-Za-z][A-Za-z0-9]+)/);return o?o[1].trim():null}function inferComponentFromText(e){const t=e.title||"";for(const[e,n]of LABEL_SECTION_MAP)if(new RegExp(`\\b${e}\\b`,"i").test(t))return n;return null}function resolveHighlightComponent(e){return e.section&&"General"!==e.section?e.section:extractComponentName(e)||inferComponentFromText(e)||e.section}function getFixComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(!/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function getEnhancementComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function formatBetaDescription(e){const t=(e.title||"").trim().replace(/[.!?]+$/,"").toLowerCase(),n=extractComponentName(e)||"Component";return/feat\(|\badd\b/.test(t)?`${n} - allows you to guide users through multi-step forms.`:/fix/.test(t)?`${n} - includes important bug fixes.`:`${n} - includes beta updates.`}function getNewBetaComponentLines(e){const t=e.filter((e=>{const t=(e.title||"").toLowerCase();return!("Beta"!==e.section||!t.startsWith("feat(")&&(!t.startsWith("add")||!t.includes("component")))})),n=new Set,o=[];for(const e of t){const t=extractComponentName(e);t&&!n.has(t.toLowerCase())&&(n.add(t.toLowerCase()),o.push(`- **${t}** - allows you to guide users through multi-step forms.`))}return o}function normalizeSection(e){return BETA_COMPONENT_SECTIONS.has(e)?"Beta":e}function mentionsBetaComponent(e){const t=`${e.title||""}\n${e.body||""}`.toLowerCase();return Array.from(BETA_COMPONENT_SECTIONS).some((e=>t.includes(e.toLowerCase())))}function shouldForceIncludeAsBeta(e){return!!mentionsBetaComponent(e)||"Beta"===normalizeSection(getSection(e))}function buildReleaseSections(e){const t=new Map(SECTION_ORDER.map((e=>[e,[]]))),n=new Map;for(const t of e){const e=normalizeSection(t.section);n.set(e,(n.get(e)||0)+1)}for(const o of e){const e=normalizeSection(o.section);let r=e;!("General"===e||"Beta"===e||"TypeScript"===e)&&(n.get(e)||0)<3&&(r="General"),t.has(r)||t.set(r,[]),t.get(r).push(formatEntry(o))}return t}function buildSectionOrder(e){const t=new Set(SECTION_ORDER),n=Array.from(e.keys()).filter((e=>!t.has(e))).sort();return[...SECTION_ORDER.slice(0,-2),...n,...SECTION_ORDER.slice(-2)]}function formatReleaseNotes(e){const t=buildSectionOrder(e),n=[];for(const o of t){const t=e.get(o);if(!t||0===t.length)continue;const r="Beta"===o?"Beta - APIs are subject to change:":`${o}:`;n.push({heading:r,entries:t})}const o=[];if(1===n.length&&"General:"===n[0].heading)for(const e of n[0].entries)o.push(e);else for(const{heading:e,entries:t}of n){o.push(e),o.push("");for(const e of t)o.push(e);o.push("")}return o.join("\n").trim()}function normalizeVersionHeading(e){return String(e).trim().replace(/^v/i,"")}function updateChangelog(e,t,n){const o=`# ${normalizeVersionHeading(t)}`,r=`${o}\n\n${n}\n`,s=existsSync(e)?readFileSync(e,"utf8"):"",i=s.split("\n"),a=i.findIndex((e=>e.trim()===o));let c;if(-1===a)c=`${r}\n${s}`;else{let e=a+1;for(;e<i.length&&!/^# /.test(i[e]);)e+=1;const t=i.slice(0,a).join("\n");c=`${t&&!t.endsWith("\n")?`${t}\n`:t}${r}\n${i.slice(e).join("\n")}`}writeFileSync(e,c,"utf8"),console.error(`Changelog updated at ${e} under "${o}".`)}function describeHighlightGroup(e,t,n,o){return 0===e.length?null:1===e.length?`${o} ${t} to ${e[0]}`:`${n} to ${humanJoin(e)}`}function formatAnnouncement(e){const t=getFixComponents(e.prs),n=getEnhancementComponents(e.prs),o=getNewBetaComponentLines(e.prs),r=[describeHighlightGroup(t,"fix","fixes","a"),describeHighlightGroup(n,"enhancement","enhancements","an")].filter(Boolean),s=r.length>0?`This release included ${r.join(" as well as ")}. Check out the full <${e.releaseUrl}|release notes> for details.`:`Check out the full <${e.releaseUrl}|release notes> for details.`,i=[`Grommet ${e.releaseLabel} is released`,"",s];return o.length>0&&(i.push(""),i.push("**New BETA components** *(APIs are subject to change)*:"),i.push(""),i.push(...o)),i.join("\n").trim()}const args=parseArgs();(async()=>{let e=args.from;e||(e=await getLatestTag(args.token),console.error(`Auto-detected --from: ${e}`));const t=args.to||"HEAD";console.error(`Resolving refs: ${e} → ${t}`);const n=await resolveRef(e,args.token),o=await resolveRef(t,args.token);console.error(`Fetching commits between ${e} and ${t}...`);const r=await ghGet(`${API}/compare/${n.sha}...${o.sha}`,args.token);if(r.total_commits>r.commits.length)throw new Error(`Compare API returned only ${r.commits.length} of ${r.total_commits} commits. The release range is too large; please choose a smaller range or switch to a paginated strategy.`);const s=new Set;for(const e of r.commits){const t=e.commit.message.matchAll(/#(\d+)/g);for(const e of t)s.add(Number(e[1]))}0===s.size?console.error("No PR references found in commits. Output will be empty."):console.error(`Found ${s.size} PR reference(s) in commits.`);const i=Array.from(s),a=[],c=[];for(let e=0;e<i.length;e+=5){const t=i.slice(e,e+5),n=await Promise.all(t.map((e=>ghGet(`${API}/pulls/${e}`,args.token).then((e=>({pr:e}))).catch((t=>({error:t,number:e}))))));a.push(...n.filter((e=>e.pr)).map((e=>e.pr))),c.push(...n.filter((e=>e.error)).map((e=>e.error)))}if(0===a.length&&c.length>0)throw c[0];c.length>0&&console.error(`Warning: failed to fetch ${c.length} PR(s).`);const l=[];let u=0,m=0;for(const e of a){if(e.labels.map((e=>e.name)).some((e=>SKIP_LABELS.has(e)))){console.error(` skip [label] #${e.number}: ${e.title}`),m++;continue}const t=shouldForceIncludeAsBeta(e);if(!t&&!includeByBody(e.body)){console.error(` skip [body] #${e.number}: ${e.title}`),m++;continue}const n=shouldSkipByContent(e);if(n.skip){console.error(` skip [${n.reason}] #${e.number}: ${e.title}`),m++;continue}t&&!includeByBody(e.body)&&console.error(` include [beta-override] #${e.number}: ${e.title}`);const o=t?"Beta":getSection(e);console.error(` include [${o}] #${e.number}: ${e.title}`),l.push({...e,section:o}),u++}const p=buildReleaseSections(l);console.error(`\nSummary: ${u} included, ${m} skipped.\n`);const h=inferNextReleaseTag(e,t),d="HEAD"!==t&&/^v\d/.test(t)?t:h||`changes through ${t}`,f="HEAD"!==t&&/^v\d/.test(t)?`${GH_RELEASE_URL}/${t}`:`${GH_COMPARE_URL}/${e}...${o.sha}`,g="announcement"===args.format?formatAnnouncement({prs:l,releaseLabel:d,releaseUrl:f,sections:p}):formatReleaseNotes(p);args.output?(writeFileSync(args.output,`${g}\n`,"utf8"),console.error(`Release notes written to ${args.output}`)):process.stdout.write(`${g}\n`);const $=!1===args.changelog||"announcement"===args.format?null:args.changelog||(args.output?null:"CHANGELOG.md");$&&updateChangelog($,args.version||(/^v?\d+\.\d+\.\d+$/i.test(t)?t:"X.X.X"),g)})().catch((e=>{console.error(e.message||e),process.exit(1)}));
|
|
1
|
+
import{existsSync,readdirSync,readFileSync,statSync,writeFileSync}from"fs";import{join}from"path";import{formatReleaseSentence,getSkipReason,isTypeScriptChange}from"./release-notes-utils";const OWNER="grommet",REPO="grommet",API=`https://api.github.com/repos/${OWNER}/${REPO}`,GH_PR_URL=`https://github.com/${OWNER}/${REPO}/pull`,GH_RELEASE_URL=`https://github.com/${OWNER}/${REPO}/releases/tag`,GH_COMPARE_URL=`https://github.com/${OWNER}/${REPO}/compare`,DEFAULT_CHANGELOG_FILE="CHANGELOG.md",PLACEHOLDER_VERSION="X.X.X",LABEL_SECTION_MAP=new Map([["DataTable","DataTable"],["DateInput","DateInput"],["DateTimeInput","DateTimeInput"],["TimeInput","TimeInput"],["FileInput","FileInput"],["Select","Select / SelectMultiple"],["SelectMultiple","Select / SelectMultiple"],["List","List"],["RadioButton","RadioButton / RadioButtonGroup"],["RadioButtonGroup","RadioButton / RadioButtonGroup"],["RangeSelector","RangeSelector"],["TypeScript","TypeScript"],["typescript","TypeScript"],["Beta","Beta"],["beta","Beta"],["Calendar","Calendar"],["TextInput","TextInput"],["MaskedInput","MaskedInput"],["Notification","Notification"],["Layer","Layer"],["Button","Button"],["Form","Form"],["FormField","FormField"],["Stepper","Stepper"],["Wizard","Wizard"],["Tabs","Tabs"],["Pagination","Pagination"],["Menu","Menu"],["Anchor","Anchor"],["CheckBox","CheckBox / CheckBoxGroup"],["CheckBoxGroup","CheckBoxGroup / CheckBox"],["Data","Data"],["DataChart","Chart / DataChart"],["Chart","Chart / DataChart"],["DataFilter","DataFilter"]]),SECTION_ORDER=["General","Anchor","Button","Calendar","Chart / DataChart","CheckBox","Data","DataFilter","DataTable","DateInput","DateTimeInput","FileInput","Form","FormField","Layer","List","MaskedInput","Menu","Notification","Pagination","RadioButton / RadioButtonGroup","RangeSelector","Select / SelectMultiple","Stepper","Tabs","TextInput","TimeInput","TypeScript","Beta"],BETA_LABELS=new Set(["beta","Beta"]),DEFAULT_BETA_COMPONENT_SECTIONS=new Set(["DateTimeInput","Stepper","TimeInput","Wizard"]),MIN_COMPONENT_SECTION_SIZE=3,BETA_WARNING_PATTERN=/currently in beta[\s\S]*api is subject\s+to\s+change/i;function getSourceBetaComponentSections(){const e=join(process.cwd(),"src","js","components");if(!existsSync(e))return new Set;const t=new Set,n=readdirSync(e);for(const o of n){const n=join(e,o);if(!statSync(n).isDirectory())continue;const r=join(n,`${o}.js`);if(existsSync(r))try{const e=readFileSync(r,"utf8");BETA_WARNING_PATTERN.test(e)&&t.add(o)}catch{}}return t}const BETA_COMPONENT_SECTIONS=new Set([...Array.from(DEFAULT_BETA_COMPONENT_SECTIONS),...Array.from(getSourceBetaComponentSections())]);function parseArgs(){const e=process.argv.slice(2),t={from:null,to:null,format:(process.argv[1]||"").includes("announcement")?"announcement":"release-notes",output:null,changelog:null,version:null,token:process.env.GH_TOKEN||null};for(let n=0;n<e.length;n++){const o=e[n];if("--from"===o)t.from=e[++n];else if("--to"===o)t.to=e[++n];else if("--format"===o)t.format=e[++n];else if("--output"===o)t.output=e[++n];else if("--changelog"===o){const o=e[n+1];t.changelog=o&&!o.startsWith("--")?e[++n]:"CHANGELOG.md"}else"--no-changelog"===o?t.changelog=!1:"--version"===o?t.version=e[++n]:"--token"===o?t.token=e[++n]:o.startsWith("--")||t.from?o.startsWith("--")||t.to||(t.to=o):t.from=o}return t}function getRequestHeaders(e){return{...e?{Authorization:`Bearer ${e}`}:{},Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}async function ghGet(e,t){const n=await fetch(e,{headers:getRequestHeaders(t)});if(!n.ok){const t=await n.text();if(403===n.status&&t.includes("API rate limit exceeded"))throw new Error("GitHub API rate limit exceeded. Set GH_TOKEN or pass --token to generate release output.");throw new Error(`GitHub API ${n.status} at ${e}:\n${t}`)}return n.json()}async function resolveRef(e,t){if(!e||"HEAD"===e){const e=await ghGet(`${API}`,t),n=await ghGet(`${API}/branches/${e.default_branch}`,t);return{sha:n.commit.sha,date:n.commit.commit.committer.date}}try{const n=await ghGet(`${API}/git/refs/tags/${e}`,t);let{sha:o}=n.object;return"tag"===n.object.type&&(o=(await ghGet(`${API}/git/tags/${o}`,t)).object.sha),{sha:o,date:(await ghGet(`${API}/commits/${o}`,t)).commit.committer.date}}catch{const n=await ghGet(`${API}/commits/${e}`,t);return{sha:n.sha,date:n.commit.committer.date}}}async function getLatestTag(e){const t=await ghGet(`${API}/tags?per_page=5`,e);if(!t.length)throw new Error("No tags found in repository.");return t[0].name}function getSection(e){const t=e.labels.map((e=>e.name));if(isTypeScriptChange(e))return"TypeScript";if(t.some((e=>BETA_LABELS.has(e))))return"Beta";for(const e of t){const t=LABEL_SECTION_MAP.get(e);if(t)return t}const n=e.title.match(/^[A-Za-z]+\(([^)]+)\):/);if(n){const e=n[1].trim();for(const[t,n]of LABEL_SECTION_MAP)if(t.toLowerCase()===e.toLowerCase())return n}const o=e.title.toLowerCase();for(const[e,t]of LABEL_SECTION_MAP){const n=e.toLowerCase();if(o.startsWith(`${n} `)||o.startsWith(`${n}:`)||o.startsWith(`${n}-`)||o.startsWith(`${n},`))return t}return"General"}function formatEntry(e){return`- ${formatReleaseSentence(e).replace(/[.!?]+$/,"")}. ([#${e.number}](${GH_PR_URL}/${e.number}))`}function formatTitlePhrase(e){const t=e.trim().replace(/[.!?]+$/,"");return t.charAt(0).toLowerCase()+t.slice(1)}function humanJoin(e){return 0===e.length?"":1===e.length?e[0]:2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`}function unique(e){return e.filter(((t,n)=>t&&e.indexOf(t)===n))}function getAnnouncementHighlights(e){const t=[/^added\b/i,/^enhanced\b/i,/^improved\b/i];return e.filter((e=>t.some((t=>t.test(e.title))))).slice(0,2).map((e=>formatTitlePhrase(e.title)))}function getFixSummary(e){const t=unique(e.filter((e=>/^fixed\b/i.test(e.title))).map((e=>e.section)).filter((e=>e&&"General"!==e&&"Beta"!==e)));if(0===t.length)return null;const n=t.slice(0,5),o=t.length>5?", and more":"";return`There are also fixes across ${humanJoin(n)}${o}.`}function formatContributors(e){const t=unique(e.map((e=>e.user?.login)).filter((e=>e&&"app/dependabot"!==e)));return 0===t.length?null:`Thank you to everyone who contributed to this release ${humanJoin(t.map((e=>`<https://github.com/${e}|${e}>`)))}!`}function inferNextReleaseTag(e,t){if(t&&/^v\d+\.\d+\.\d+$/i.test(t))return t;const n=(e||"").match(/^v(\d+)\./i);return n?`v${n[1]}.x.x`:"v2.x.x"}function extractComponentName(e){const t=(e.title||"").trim(),n=t.match(/^[A-Za-z]+\(([^)]+)\):/);if(n)return n[1].trim();const o=t.match(/^([A-Za-z][A-Za-z0-9]+)/);return o?o[1].trim():null}function inferComponentFromText(e){const t=e.title||"";for(const[e,n]of LABEL_SECTION_MAP)if(new RegExp(`\\b${e}\\b`,"i").test(t))return n;return null}function resolveHighlightComponent(e){return e.section&&"General"!==e.section?e.section:extractComponentName(e)||inferComponentFromText(e)||e.section}function getFixComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(!/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function getEnhancementComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function formatBetaDescription(e){const t=(e.title||"").trim().replace(/[.!?]+$/,"").toLowerCase(),n=extractComponentName(e)||"Component";return/feat\(|\badd\b/.test(t)?`${n} - allows you to guide users through multi-step forms.`:/fix/.test(t)?`${n} - includes important bug fixes.`:`${n} - includes beta updates.`}function getNewBetaComponentLines(e){const t=e.filter((e=>{const t=(e.title||"").toLowerCase();return!("Beta"!==e.section||!t.startsWith("feat(")&&(!t.startsWith("add")||!t.includes("component")))})),n=new Set,o=[];for(const e of t){const t=extractComponentName(e);t&&!n.has(t.toLowerCase())&&(n.add(t.toLowerCase()),o.push(`- **${t}** - allows you to guide users through multi-step forms.`))}return o}function normalizeSection(e){return BETA_COMPONENT_SECTIONS.has(e)?"Beta":e}function mentionsBetaComponent(e){const t=`${e.title||""}\n${e.body||""}`.toLowerCase();return Array.from(BETA_COMPONENT_SECTIONS).some((e=>t.includes(e.toLowerCase())))}function shouldForceIncludeAsBeta(e){return!isTypeScriptChange(e)&&(!!mentionsBetaComponent(e)||"Beta"===normalizeSection(getSection(e)))}function buildReleaseSections(e){const t=new Map(SECTION_ORDER.map((e=>[e,[]]))),n=new Map;for(const t of e){const e=normalizeSection(t.section);n.set(e,(n.get(e)||0)+1)}for(const o of e){const e=normalizeSection(o.section);let r=e;!("General"===e||"Beta"===e||"TypeScript"===e)&&(n.get(e)||0)<3&&(r="General"),t.has(r)||t.set(r,[]),t.get(r).push(formatEntry(o))}return t}function buildSectionOrder(e){const t=new Set(SECTION_ORDER),n=Array.from(e.keys()).filter((e=>!t.has(e))).sort();return[...SECTION_ORDER.slice(0,-2),...n,...SECTION_ORDER.slice(-2)]}function formatReleaseNotes(e){const t=buildSectionOrder(e),n=[];for(const o of t){const t=e.get(o);if(!t||0===t.length)continue;const r="Beta"===o?"Beta - APIs are subject to change:":`${o}:`;n.push({heading:r,entries:t})}const o=[];if(1===n.length&&"General:"===n[0].heading)for(const e of n[0].entries)o.push(e);else for(const{heading:e,entries:t}of n){o.push(e),o.push("");for(const e of t)o.push(e);o.push("")}return o.join("\n").trim()}function normalizeVersionHeading(e){return String(e).trim().replace(/^v/i,"")}function updateChangelog(e,t,n){const o=`# ${normalizeVersionHeading(t)}`,r=`${o}\n\n${n}\n`,s=existsSync(e)?readFileSync(e,"utf8"):"",a=s.split("\n"),i=a.findIndex((e=>e.trim()===o));let c;if(-1===i)c=`${r}\n${s}`;else{let e=i+1;for(;e<a.length&&!/^# /.test(a[e]);)e+=1;const t=a.slice(0,i).join("\n");c=`${t&&!t.endsWith("\n")?`${t}\n`:t}${r}\n${a.slice(e).join("\n")}`}writeFileSync(e,c,"utf8"),console.error(`Changelog updated at ${e} under "${o}".`)}function describeHighlightGroup(e,t,n,o){return 0===e.length?null:1===e.length?`${o} ${t} to ${e[0]}`:`${n} to ${humanJoin(e)}`}function formatAnnouncement(e){const t=getFixComponents(e.prs),n=getEnhancementComponents(e.prs),o=getNewBetaComponentLines(e.prs),r=[describeHighlightGroup(t,"fix","fixes","a"),describeHighlightGroup(n,"enhancement","enhancements","an")].filter(Boolean),s=r.length>0?`This release included ${r.join(" as well as ")}. Check out the full <${e.releaseUrl}|release notes> for details.`:`Check out the full <${e.releaseUrl}|release notes> for details.`,a=[`Grommet ${e.releaseLabel} is released`,"",s];return o.length>0&&(a.push(""),a.push("**New BETA components** *(APIs are subject to change)*:"),a.push(""),a.push(...o)),a.join("\n").trim()}const args=parseArgs();(async()=>{let e=args.from;e||(e=await getLatestTag(args.token),console.error(`Auto-detected --from: ${e}`));const t=args.to||"HEAD";console.error(`Resolving refs: ${e} → ${t}`);const n=await resolveRef(e,args.token),o=await resolveRef(t,args.token);console.error(`Fetching commits between ${e} and ${t}...`);const r=await ghGet(`${API}/compare/${n.sha}...${o.sha}`,args.token);if(r.total_commits>r.commits.length)throw new Error(`Compare API returned only ${r.commits.length} of ${r.total_commits} commits. The release range is too large; please choose a smaller range or switch to a paginated strategy.`);const s=new Set;for(const e of r.commits){const t=e.commit.message.matchAll(/#(\d+)/g);for(const e of t)s.add(Number(e[1]))}0===s.size?console.error("No PR references found in commits. Output will be empty."):console.error(`Found ${s.size} PR reference(s) in commits.`);const a=Array.from(s),i=[],c=[];for(let e=0;e<a.length;e+=5){const t=a.slice(e,e+5),n=await Promise.all(t.map((e=>ghGet(`${API}/pulls/${e}`,args.token).then((e=>({pr:e}))).catch((t=>({error:t,number:e}))))));i.push(...n.filter((e=>e.pr)).map((e=>e.pr))),c.push(...n.filter((e=>e.error)).map((e=>e.error)))}if(0===i.length&&c.length>0)throw c[0];c.length>0&&console.error(`Warning: failed to fetch ${c.length} PR(s).`);const l=[];let u=0,m=0;for(const e of i){const t=getSkipReason(e);if(t){console.error(` skip [${t}] #${e.number}: ${e.title}`),m++;continue}const n=shouldForceIncludeAsBeta(e)?"Beta":getSection(e);console.error(` include [${n}] #${e.number}: ${e.title}`),l.push({...e,section:n}),u++}const h=buildReleaseSections(l);console.error(`\nSummary: ${u} included, ${m} skipped.\n`);const p=inferNextReleaseTag(e,t),f="HEAD"!==t&&/^v\d/.test(t)?t:p||`changes through ${t}`,g="HEAD"!==t&&/^v\d/.test(t)?`${GH_RELEASE_URL}/${t}`:`${GH_COMPARE_URL}/${e}...${o.sha}`,d="announcement"===args.format?formatAnnouncement({prs:l,releaseLabel:f,releaseUrl:g,sections:h}):formatReleaseNotes(h);args.output?(writeFileSync(args.output,`${d}\n`,"utf8"),console.error(`Release notes written to ${args.output}`)):process.stdout.write(`${d}\n`);const $=!1===args.changelog||"announcement"===args.format?null:args.changelog||(args.output?null:"CHANGELOG.md");$&&updateChangelog($,args.version||(/^v?\d+\.\d+\.\d+$/i.test(t)?t:"X.X.X"),d)})().catch((e=>{console.error(e.message||e),process.exit(1)}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const EXCLUDED_LABELS=new Map([["dependencies","dependency"],["dependency","dependency"],["storybook","storybook"],["chromatic","storybook"],["ci","automation"],["ci/cd","automation"],["automation","automation"],["release automation","automation"]]);export function getDescription(e){let t,s=e||"";do{t=s,s=s.replace(/<!--[\s\S]*?-->/g,"")}while(s!==t);s=s.replace(/\r\n/g,"\n").trim();const i=s.split(/^#{1,6}\s+(.+?)\s*#*\s*$/m);let o=i[0];for(let e=1;e<i.length;e+=2)if(/^(what does this pr do\??|summary|description)\s*$/i.test(i[e])){o=i[e+1];break}return o.replace(/```[\s\S]*?```/g,"").replace(/!\[[^\]]*\]\([^)]*\)/g,"").split("\n").filter((e=>!/^\s*[-*]\s+\[[ x]\]/i.test(e))).map((e=>e.replace(/^\s*(?:[-*+]\s+|\d+\.\s+)/,"").trim())).filter(Boolean).join(" ").trim()}export function isTypeScriptChange(e){if((e.labels||[]).some((e=>/^typescript$/i.test(e.name))))return!0;const t=e.title||"";return/\b(?:typescript|type declarations?|type definitions?|type errors?|typings)\b|\b[\w-]+\.d\.ts\b/i.test(t)||/\b(?:add(?:ed)?|fix(?:ed)?|update(?:d)?)\b.*\btypes\b/i.test(t)}export function formatReleaseSentence(e){let t=(getDescription(e.body)||e.title||"").trim().replace(/[.!?]+$/,"");t=t.replace(/^(fix|feat|add|enhance|improve)\(([^)]+)\):\s*(.+)$/i,"$1 $2 $3"),t=t.replace(/^\[(?:fix|feat|enhancement)\]\s*/i,"").replace(/^this (?:pr|pull request)\s+/i,"").replace(/^([A-Z][A-Za-z0-9]*)\s*[:-]\s*(fix(?:es|ed)?|add(?:s|ed)?|enhance(?:s|d)?|improve(?:s|d)?)\s+/i,"$2 $1 ");const s=[["Fixed",/^(?:fix(?:es|ed)?|correct(?:s|ed)?|resolv(?:e|es|ed)|prevent(?:s|ed)?)\b[:\s-]*/i],["Added",/^(?:add(?:s|ed)?|feat|introduc(?:e|es|ed))\b[:\s-]*/i],["Enhanced",/^(?:enhance(?:s|d)?|improv(?:e|es|ed)|updat(?:e|es|ed)|refactor(?:s|ed)?|simplif(?:y|ies|ied)|remove(?:s|d)?)\b[:\s-]*/i]].find((([,e])=>e.test(t)));if(s)return/^remove(?:s|d)?\b/i.test(t)?`Enhanced implementation by removing ${t.replace(s[1],"")}`:`${s[0]} ${t.replace(s[1],"")}`;const i=e.title||"";let o="Enhanced";return/\bfix(?:es|ed)?\b|\bbug\b/i.test(i)?o="Fixed":/\b(?:feat|add(?:ed)?|introduc(?:e|es|ed))\b/i.test(i)&&(o="Added"),`${o} ${t}`}export function getSkipReason(e){const t=e.user||{};if("Bot"===t.type||/\[bot\]$/i.test(t.login||"")||/^app\//i.test(t.login||""))return"bot";const s=(e.labels||[]).map((e=>e.name.toLowerCase())).find((e=>EXCLUDED_LABELS.has(e)));if(s)return EXCLUDED_LABELS.get(s);const i=[e.title||"",getDescription(e.body)],o=[/\b(?:update|upgrade|bump)\b.*\b(?:dependenc(?:y|ies)|styled[- ]components)\b/i,/\bdependenc(?:y|ies)\b.*\b(?:update|upgrade|bump)\b/i,/^(?:chore(?:\([^)]*\))?:\s*)?bump\s+\S+\s+from\s+\S+\s+to\s+/i,/^(?:build|chore)\(deps(?:-dev)?\):/i,/^(?:update|upgrade|bump)\s+\S+\s+(?:to\s+)?(?:v|\^|~)?\d+\.\d+/i];if(i.some((e=>o.some((t=>t.test(e))))))return"dependency";if(/\b(?:storybook|stories|chromatic)\b/i.test(e.title||"")||/^(?:(?:fix|feat|chore|docs|build)\((?:storybook|stories|chromatic)\):|(?:storybook|stories|chromatic)\b|(?:fix(?:ed|es)?|update[sd]?|improve[sd]?|enhance[sd]?|add(?:ed|s)?|upgrade[sd]?)\s+(?:the\s+)?(?:storybook|stories|chromatic)\b)/i.test(i[1]))return"storybook";const r=[/^(?:ci(?:\([^)]*\))?:|(?:build|chore|fix|feat)\((?:ci|release|automation|github-actions)\):)/i,/\b(?:ci|continuous integration|github actions?|release automation|release workflow|release pipeline|automated releases?)\b/i,/^(?:automate|automating)\b.*\brelease\b/i,/^release\s+v?\d+\.\d+\.\d+\b/i];return i.some((e=>r.some((t=>t.test(e)))))?"automation":null}
|
package/utils/DOM.js
CHANGED
|
@@ -82,17 +82,20 @@ var withinDropPortal = exports.withinDropPortal = function withinDropPortal(node
|
|
|
82
82
|
return true;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
var isFocusable = exports.isFocusable = function isFocusable(element) {
|
|
85
|
+
// FormField focus-styling predicate, not a general DOM focusability check.
|
|
86
|
+
// Excludes buttons and links so they retain their own focus indicators.
|
|
87
|
+
// Include negative tabIndex when checking an already-focused element;
|
|
88
|
+
// descendant discovery requires a non-negative tabIndex.
|
|
89
|
+
var isFocusable = exports.isFocusable = function isFocusable(element, includeNegativeTabIndex) {
|
|
90
|
+
if (includeNegativeTabIndex === void 0) {
|
|
91
|
+
includeNegativeTabIndex = false;
|
|
92
|
+
}
|
|
90
93
|
if (!element || element.disabled) return false;
|
|
91
94
|
var tagName = element.tagName.toLowerCase();
|
|
92
95
|
if (tagName === 'input' || tagName === 'select' || tagName === 'textarea') return true;
|
|
93
96
|
// Only non-native-interactive elements with an explicit tabindex attribute
|
|
94
97
|
var isNativeInteractive = tagName === 'button' || tagName === 'a';
|
|
95
|
-
return !isNativeInteractive && element.tabIndex >= 0 && element.hasAttribute('tabindex');
|
|
98
|
+
return !isNativeInteractive && (includeNegativeTabIndex || element.tabIndex >= 0) && element.hasAttribute('tabindex');
|
|
96
99
|
};
|
|
97
100
|
|
|
98
101
|
// Get the first element that can receive focus
|
|
@@ -108,7 +111,7 @@ var getFirstFocusableDescendant = exports.getFirstFocusableDescendant = function
|
|
|
108
111
|
};
|
|
109
112
|
var shouldKeepFocus = exports.shouldKeepFocus = function shouldKeepFocus(root) {
|
|
110
113
|
var element = root.activeElement;
|
|
111
|
-
if (isFocusable(element)) return true;
|
|
114
|
+
if (isFocusable(element, true)) return true;
|
|
112
115
|
return !!getFirstFocusableDescendant(element);
|
|
113
116
|
};
|
|
114
117
|
var getNewContainer = exports.getNewContainer = function getNewContainer(target, targetChildPosition) {
|
package/utils/background.js
CHANGED
|
@@ -79,20 +79,20 @@ var backgroundIsDark = exports.backgroundIsDark = function backgroundIsDark(back
|
|
|
79
79
|
!opacity || opacity !== 'weak')) {
|
|
80
80
|
var backgroundColor = (0, _colors.normalizeColor)(background.color, theme);
|
|
81
81
|
if (backgroundColor) {
|
|
82
|
-
result = (0, _colors.colorIsDark)(backgroundColor);
|
|
82
|
+
result = (0, _colors.colorIsDark)(backgroundColor, theme);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
} else {
|
|
86
86
|
var _color = (0, _colors.normalizeColor)(background, theme);
|
|
87
87
|
if (_color) {
|
|
88
|
-
result = (0, _colors.colorIsDark)(_color);
|
|
88
|
+
result = (0, _colors.colorIsDark)(_color, theme);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
return result;
|
|
93
93
|
};
|
|
94
|
-
var darkContext = function darkContext(backgroundColor) {
|
|
95
|
-
var isDark = (0, _colors.colorIsDark)(backgroundColor);
|
|
94
|
+
var darkContext = function darkContext(backgroundColor, theme, text) {
|
|
95
|
+
var isDark = (0, _colors.colorIsDark)(backgroundColor, theme, text);
|
|
96
96
|
if (isDark === undefined) return undefined;
|
|
97
97
|
return isDark ? 'dark' : 'light';
|
|
98
98
|
};
|
|
@@ -122,13 +122,15 @@ var backgroundAndTextColors = exports.backgroundAndTextColors = function backgro
|
|
|
122
122
|
// set the textColor to have the best contrast against the background
|
|
123
123
|
// color.
|
|
124
124
|
if (!textColor && (opacity === undefined || opacity > 0.3)) {
|
|
125
|
-
var shade = darkContext(backgroundColor, theme);
|
|
126
|
-
|
|
125
|
+
var shade = darkContext(backgroundColor, theme, text);
|
|
126
|
+
// preserve undefined (unknown shade) so normalizeColor falls back
|
|
127
|
+
// to the ambient theme.dark instead of forcing the light side
|
|
128
|
+
textColor = (0, _colors.normalizeColor)(shade && text[shade] || text, theme, shade === undefined ? undefined : shade === 'dark');
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
} else {
|
|
130
132
|
backgroundColor = normalizeBackgroundColor(background, theme);
|
|
131
|
-
var _shade = darkContext(backgroundColor, theme);
|
|
133
|
+
var _shade = darkContext(backgroundColor, theme, text);
|
|
132
134
|
var transparent;
|
|
133
135
|
if (backgroundColor && (0, _colors.canExtractRGBArray)(backgroundColor)) {
|
|
134
136
|
var colorArray = (0, _colors.getRGBArray)(backgroundColor);
|