grommet 2.57.0 → 2.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Box/StyledBox.js +1 -1
- package/components/Box/stories/ColorContrast.stories.js +36 -0
- package/components/Button/BusyAnimation.js +7 -1
- package/components/Button/Button.js +12 -3
- package/components/DataTable/StyledDataTable.js +1 -1
- package/components/DateInput/DateInput.js +3 -3
- package/components/DateTimeInput/DateTimeInput.js +17 -11
- package/components/FocusedContainer.js +2 -1
- package/components/FormField/FormField.js +31 -10
- package/components/FormField/FormFieldContext.js +12 -0
- package/components/Grommet/Grommet.js +4 -1
- package/components/Grommet/StyledGrommet.js +3 -3
- package/components/Grommet/index.d.ts +6 -0
- package/components/Grommet/propTypes.js +2 -0
- package/components/Menu/Menu.js +1 -1
- package/components/Select/SelectContainer.js +2 -2
- package/components/Select/StyledSelect.js +3 -1
- package/components/TextArea/StyledTextArea.js +3 -1
- package/components/TextInput/CopyButton.js +23 -6
- package/components/TextInput/StyledTextInput.js +19 -25
- package/components/TextInput/TextInput.js +75 -28
- package/components/TextInput/index.d.ts +12 -3
- package/components/TextInput/propTypes.js +2 -0
- package/components/TextInput/stories/Copy.stories.tsx +42 -0
- package/components/TextInput/stories/CopySecret.stories.tsx +44 -0
- package/components/TimeInput/README.md +24 -1
- package/components/TimeInput/StyledTimeInput.js +91 -27
- package/components/TimeInput/TimeInput.js +185 -120
- package/components/TimeInput/TimeInputPopup.js +114 -117
- package/components/TimeInput/index.d.ts +2 -0
- package/components/TimeInput/propTypes.js +2 -0
- package/components/TimeInput/stories/Controlled.stories.tsx +2 -2
- package/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
- package/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
- package/components/TimeInput/stories/Form.stories.tsx +1 -0
- package/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
- package/components/TimeInput/useSectionedTimeField.js +2 -2
- package/components/TimeInput/utils.js +13 -62
- package/components/Wizard/Wizard.js +396 -210
- package/components/Wizard/WizardContent.js +61 -35
- package/components/Wizard/WizardContext.js +3 -0
- package/components/Wizard/WizardFooter.js +14 -15
- package/components/Wizard/WizardHeader.js +12 -7
- package/components/Wizard/WizardProgress.js +27 -2
- package/components/Wizard/index.d.ts +35 -4
- package/components/Wizard/propTypes.js +6 -1
- package/components/Wizard/stories/BasicLinear.stories.js +12 -10
- package/components/Wizard/stories/ClickableSteps.stories.js +104 -0
- package/components/Wizard/stories/ExternalForm.stories.js +114 -0
- package/components/Wizard/stories/NonClosableHeader.stories.js +68 -0
- package/components/Wizard/stories/Validation.stories.js +18 -8
- package/es6/components/Box/StyledBox.js +1 -1
- package/es6/components/Box/stories/ColorContrast.stories.js +31 -0
- package/es6/components/Button/BusyAnimation.js +7 -1
- package/es6/components/Button/Button.js +12 -3
- package/es6/components/DataTable/StyledDataTable.js +2 -2
- package/es6/components/DateInput/DateInput.js +3 -3
- package/es6/components/DateTimeInput/DateTimeInput.js +17 -11
- package/es6/components/FocusedContainer.js +2 -1
- package/es6/components/FormField/FormField.js +31 -10
- package/es6/components/FormField/FormFieldContext.js +7 -0
- package/es6/components/Grommet/Grommet.js +4 -1
- package/es6/components/Grommet/StyledGrommet.js +4 -4
- package/es6/components/Grommet/index.d.ts +6 -0
- package/es6/components/Grommet/propTypes.js +2 -0
- package/es6/components/Menu/Menu.js +1 -1
- package/es6/components/Select/SelectContainer.js +2 -2
- package/es6/components/Select/StyledSelect.js +4 -2
- package/es6/components/TextArea/StyledTextArea.js +4 -2
- package/es6/components/TextInput/CopyButton.js +22 -6
- package/es6/components/TextInput/StyledTextInput.js +20 -26
- package/es6/components/TextInput/TextInput.js +76 -29
- package/es6/components/TextInput/index.d.ts +12 -3
- package/es6/components/TextInput/propTypes.js +2 -0
- package/es6/components/TextInput/stories/Copy.stories.tsx +42 -0
- package/es6/components/TextInput/stories/CopySecret.stories.tsx +44 -0
- package/es6/components/TimeInput/README.md +24 -1
- package/es6/components/TimeInput/StyledTimeInput.js +92 -28
- package/es6/components/TimeInput/TimeInput.js +187 -122
- package/es6/components/TimeInput/TimeInputPopup.js +115 -118
- package/es6/components/TimeInput/index.d.ts +2 -0
- package/es6/components/TimeInput/propTypes.js +2 -0
- package/es6/components/TimeInput/stories/Controlled.stories.tsx +2 -2
- package/es6/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
- package/es6/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
- package/es6/components/TimeInput/stories/Form.stories.tsx +1 -0
- package/es6/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +2 -2
- package/es6/components/TimeInput/utils.js +12 -61
- package/es6/components/Wizard/Wizard.js +397 -211
- package/es6/components/Wizard/WizardContent.js +62 -36
- package/es6/components/Wizard/WizardContext.js +3 -0
- package/es6/components/Wizard/WizardFooter.js +14 -15
- package/es6/components/Wizard/WizardHeader.js +12 -7
- package/es6/components/Wizard/WizardProgress.js +27 -2
- package/es6/components/Wizard/index.d.ts +35 -4
- package/es6/components/Wizard/propTypes.js +6 -1
- package/es6/components/Wizard/stories/BasicLinear.stories.js +11 -11
- package/es6/components/Wizard/stories/ClickableSteps.stories.js +99 -0
- package/es6/components/Wizard/stories/ExternalForm.stories.js +111 -0
- package/es6/components/Wizard/stories/NonClosableHeader.stories.js +63 -0
- package/es6/components/Wizard/stories/Validation.stories.js +18 -9
- package/es6/languages/default.json +2 -0
- package/es6/themes/base.d.ts +79 -59
- package/es6/themes/base.js +65 -34
- package/es6/utils/DOM.js +10 -7
- package/es6/utils/background.js +9 -7
- package/es6/utils/colors.js +84 -12
- package/es6/utils/legacyColorIsDark.js +17 -0
- package/es6/utils/styles.js +13 -5
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +2 -0
- package/package.json +3 -3
- package/themes/base.d.ts +79 -59
- package/themes/base.js +65 -34
- package/tools/draft-release-version-pr.js +1 -0
- package/tools/generate-release-notes.js +1 -1
- package/tools/release-notes-utils.js +1 -0
- package/utils/DOM.js +10 -7
- package/utils/background.js +9 -7
- package/utils/colors.js +84 -12
- package/utils/legacyColorIsDark.js +21 -0
- package/utils/styles.js +14 -6
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { Box, Button, FormField, Notification, Paragraph, TextInput } from 'grommet';
|
|
6
|
+
import { Wizard } from '../Wizard';
|
|
7
|
+
import { WizardFooter } from '../WizardFooter';
|
|
8
|
+
import { useWizard } from '../WizardContext';
|
|
9
|
+
var validate = function validate(value) {
|
|
10
|
+
var _value$name;
|
|
11
|
+
return {
|
|
12
|
+
details: (_value$name = value.name) != null && _value$name.trim() ? undefined : 'A request name is required.'
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
var ExternalFormFooter = function ExternalFormFooter(_ref) {
|
|
16
|
+
var errors = _ref.errors;
|
|
17
|
+
var _useWizard = useWizard(),
|
|
18
|
+
complete = _useWizard.complete,
|
|
19
|
+
currentStep = _useWizard.currentStep,
|
|
20
|
+
currentStepIndex = _useWizard.currentStepIndex,
|
|
21
|
+
next = _useWizard.next,
|
|
22
|
+
previous = _useWizard.previous,
|
|
23
|
+
totalSteps = _useWizard.totalSteps;
|
|
24
|
+
var isFirstStep = currentStepIndex === 0;
|
|
25
|
+
var isLastStep = currentStepIndex === totalSteps - 1;
|
|
26
|
+
var hasError = !!errors[currentStep];
|
|
27
|
+
return /*#__PURE__*/React.createElement(WizardFooter, null, !isFirstStep && /*#__PURE__*/React.createElement(Button, {
|
|
28
|
+
label: "Previous",
|
|
29
|
+
secondary: true,
|
|
30
|
+
onClick: previous
|
|
31
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
32
|
+
label: isLastStep ? 'Complete' : 'Next',
|
|
33
|
+
primary: true,
|
|
34
|
+
disabled: hasError,
|
|
35
|
+
onClick: isLastStep ? complete : next
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
var ExternalForm = function ExternalForm() {
|
|
39
|
+
var _useState = useState(),
|
|
40
|
+
submittedValue = _useState[0],
|
|
41
|
+
setSubmittedValue = _useState[1];
|
|
42
|
+
var _useState2 = useState({
|
|
43
|
+
name: ''
|
|
44
|
+
}),
|
|
45
|
+
value = _useState2[0],
|
|
46
|
+
setValue = _useState2[1];
|
|
47
|
+
var errors = validate(value);
|
|
48
|
+
var steps = [{
|
|
49
|
+
id: 'details',
|
|
50
|
+
title: 'Details',
|
|
51
|
+
status: errors.details ? 'error' : 'completed',
|
|
52
|
+
errorMessage: errors.details,
|
|
53
|
+
render: function render() {
|
|
54
|
+
return /*#__PURE__*/React.createElement(FormField, {
|
|
55
|
+
htmlFor: "request-name",
|
|
56
|
+
label: "Request name",
|
|
57
|
+
name: "name",
|
|
58
|
+
error: errors.details
|
|
59
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
60
|
+
id: "request-name",
|
|
61
|
+
name: "name",
|
|
62
|
+
value: value.name,
|
|
63
|
+
onChange: function onChange(event) {
|
|
64
|
+
return setValue(function (currentValue) {
|
|
65
|
+
return _extends({}, currentValue, {
|
|
66
|
+
name: event.target.value
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
id: 'review',
|
|
74
|
+
title: 'Review',
|
|
75
|
+
render: function render() {
|
|
76
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Review the request for ", value.name || 'an unnamed request', ".");
|
|
77
|
+
}
|
|
78
|
+
}];
|
|
79
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
80
|
+
fill: true
|
|
81
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
82
|
+
"aria-label": "New request",
|
|
83
|
+
form: false,
|
|
84
|
+
title: "New request",
|
|
85
|
+
showProgress: "vertical",
|
|
86
|
+
steps: steps,
|
|
87
|
+
footer: /*#__PURE__*/React.createElement(ExternalFormFooter, {
|
|
88
|
+
errors: errors
|
|
89
|
+
}),
|
|
90
|
+
onComplete: function onComplete() {
|
|
91
|
+
return setSubmittedValue(value);
|
|
92
|
+
}
|
|
93
|
+
}), submittedValue && /*#__PURE__*/React.createElement(Notification, {
|
|
94
|
+
toast: {
|
|
95
|
+
position: 'top'
|
|
96
|
+
},
|
|
97
|
+
status: "normal",
|
|
98
|
+
title: "Request submitted",
|
|
99
|
+
message: "Created request " + submittedValue.name + ".",
|
|
100
|
+
onClose: function onClose() {
|
|
101
|
+
return setSubmittedValue(undefined);
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
};
|
|
105
|
+
ExternalForm.args = {
|
|
106
|
+
full: true
|
|
107
|
+
};
|
|
108
|
+
export default {
|
|
109
|
+
title: 'Layout/Wizard/External Form'
|
|
110
|
+
};
|
|
111
|
+
export { ExternalForm };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { Box, Button, Heading, Notification, Paragraph } from 'grommet';
|
|
5
|
+
import { Wizard } from '../Wizard';
|
|
6
|
+
var steps = [{
|
|
7
|
+
id: 'details',
|
|
8
|
+
title: 'Details',
|
|
9
|
+
render: function render() {
|
|
10
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Enter the request details.");
|
|
11
|
+
}
|
|
12
|
+
}, {
|
|
13
|
+
id: 'review',
|
|
14
|
+
title: 'Review',
|
|
15
|
+
render: function render() {
|
|
16
|
+
return /*#__PURE__*/React.createElement(Paragraph, null, "Review the request before submitting.");
|
|
17
|
+
}
|
|
18
|
+
}];
|
|
19
|
+
var NonClosableHeader = function NonClosableHeader() {
|
|
20
|
+
var _useState = useState(false),
|
|
21
|
+
saved = _useState[0],
|
|
22
|
+
setSaved = _useState[1];
|
|
23
|
+
var title = /*#__PURE__*/React.createElement(Box, {
|
|
24
|
+
direction: "row",
|
|
25
|
+
align: "center",
|
|
26
|
+
gap: "medium",
|
|
27
|
+
flex: true
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
29
|
+
level: 1,
|
|
30
|
+
size: "small",
|
|
31
|
+
margin: "none"
|
|
32
|
+
}, "New request"), /*#__PURE__*/React.createElement(Button, {
|
|
33
|
+
label: "Save draft",
|
|
34
|
+
onClick: function onClick() {
|
|
35
|
+
return setSaved(true);
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
39
|
+
fill: true
|
|
40
|
+
}, /*#__PURE__*/React.createElement(Wizard, {
|
|
41
|
+
"aria-label": "New request",
|
|
42
|
+
closable: false,
|
|
43
|
+
title: title,
|
|
44
|
+
showProgress: "horizontal",
|
|
45
|
+
steps: steps
|
|
46
|
+
}), saved && /*#__PURE__*/React.createElement(Notification, {
|
|
47
|
+
toast: {
|
|
48
|
+
position: 'top'
|
|
49
|
+
},
|
|
50
|
+
status: "normal",
|
|
51
|
+
title: "Draft saved",
|
|
52
|
+
onClose: function onClose() {
|
|
53
|
+
return setSaved(false);
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
NonClosableHeader.args = {
|
|
58
|
+
full: true
|
|
59
|
+
};
|
|
60
|
+
export default {
|
|
61
|
+
title: 'Layout/Wizard/Non Closable Header'
|
|
62
|
+
};
|
|
63
|
+
export { NonClosableHeader };
|
|
@@ -14,7 +14,7 @@ var validatePassword = function validatePassword(password) {
|
|
|
14
14
|
}
|
|
15
15
|
return undefined;
|
|
16
16
|
};
|
|
17
|
-
var
|
|
17
|
+
var ValidationExample = function ValidationExample() {
|
|
18
18
|
var _useState = useState(null),
|
|
19
19
|
result = _useState[0],
|
|
20
20
|
setResult = _useState[1];
|
|
@@ -75,6 +75,10 @@ var Validation = function Validation() {
|
|
|
75
75
|
id: 'confirm',
|
|
76
76
|
title: 'Confirm',
|
|
77
77
|
description: 'Ready to submit.',
|
|
78
|
+
skippable: true,
|
|
79
|
+
validate: function validate(value) {
|
|
80
|
+
return validateEmail(value.email);
|
|
81
|
+
},
|
|
78
82
|
render: function render(step, api) {
|
|
79
83
|
return /*#__PURE__*/React.createElement(Paragraph, null, "Confirm sign-up for ", api.formValue.email, ".");
|
|
80
84
|
}
|
|
@@ -85,16 +89,17 @@ var Validation = function Validation() {
|
|
|
85
89
|
"aria-label": "Sign up",
|
|
86
90
|
title: "Create your account",
|
|
87
91
|
showProgress: "vertical",
|
|
92
|
+
clickableSteps: true,
|
|
88
93
|
steps: steps,
|
|
89
94
|
defaultValue: {
|
|
90
95
|
email: '',
|
|
91
96
|
password: ''
|
|
92
97
|
},
|
|
93
|
-
onComplete: function onComplete(
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
onComplete: function onComplete(results) {
|
|
99
|
+
console.log('Wizard complete with results:', results);
|
|
100
|
+
setResult({
|
|
96
101
|
status: 'complete',
|
|
97
|
-
value: value
|
|
102
|
+
value: results.value
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
105
|
}), result && /*#__PURE__*/React.createElement(Notification, {
|
|
@@ -109,10 +114,14 @@ var Validation = function Validation() {
|
|
|
109
114
|
}
|
|
110
115
|
}));
|
|
111
116
|
};
|
|
112
|
-
Validation.args = {
|
|
113
|
-
full: true
|
|
114
|
-
};
|
|
115
117
|
export default {
|
|
116
118
|
title: 'Layout/Wizard/Validation'
|
|
117
119
|
};
|
|
118
|
-
export
|
|
120
|
+
export var Validation = {
|
|
121
|
+
args: {
|
|
122
|
+
full: true
|
|
123
|
+
},
|
|
124
|
+
render: function render() {
|
|
125
|
+
return /*#__PURE__*/React.createElement(ValidationExample, null);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
@@ -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/es6/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/es6/themes/base.js
CHANGED
|
@@ -64,6 +64,7 @@ var colors = {
|
|
|
64
64
|
dark: 'rgba(255, 255, 255, 0.33)',
|
|
65
65
|
light: 'rgba(0, 0, 0, 0.33)'
|
|
66
66
|
},
|
|
67
|
+
scrollbar: 'border',
|
|
67
68
|
brand: brandColor,
|
|
68
69
|
control: {
|
|
69
70
|
dark: 'accent-1',
|
|
@@ -221,6 +222,9 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
221
222
|
computer: 'large'
|
|
222
223
|
},
|
|
223
224
|
colors: colors,
|
|
225
|
+
scrollbar: {
|
|
226
|
+
// width: undefined,
|
|
227
|
+
},
|
|
224
228
|
control: {
|
|
225
229
|
border: {
|
|
226
230
|
width: controlBorderWidth + "px",
|
|
@@ -1149,6 +1153,7 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
1149
1153
|
}
|
|
1150
1154
|
},
|
|
1151
1155
|
drop: {
|
|
1156
|
+
height: 'medium',
|
|
1152
1157
|
pad: 'small',
|
|
1153
1158
|
gap: 'small',
|
|
1154
1159
|
border: {
|
|
@@ -2898,53 +2903,79 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
2898
2903
|
}
|
|
2899
2904
|
},
|
|
2900
2905
|
timeInput: {
|
|
2901
|
-
button: {
|
|
2902
|
-
margin: {
|
|
2903
|
-
right: 'small'
|
|
2904
|
-
}
|
|
2905
|
-
},
|
|
2906
2906
|
container: {
|
|
2907
|
+
// any BoxPartThemeType
|
|
2907
2908
|
round: 'xxsmall'
|
|
2908
2909
|
},
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2910
|
+
// value: {
|
|
2911
|
+
// any BoxPartThemeType
|
|
2912
|
+
// },
|
|
2913
|
+
segment: {
|
|
2914
|
+
// any BoxPartThemeType
|
|
2915
|
+
// any TextThemeType
|
|
2916
|
+
pad: {
|
|
2917
|
+
horizontal: 'xxsmall'
|
|
2918
|
+
},
|
|
2919
|
+
active: {
|
|
2920
|
+
// any BoxPartThemeType
|
|
2921
|
+
// any TextThemeType
|
|
2922
|
+
background: 'active-background',
|
|
2923
|
+
border: {
|
|
2924
|
+
color: {
|
|
2925
|
+
dark: 'white',
|
|
2926
|
+
light: 'black'
|
|
2927
|
+
},
|
|
2928
|
+
side: 'bottom',
|
|
2929
|
+
size: 'small'
|
|
2930
|
+
}
|
|
2918
2931
|
}
|
|
2919
2932
|
},
|
|
2933
|
+
// dropButton: {
|
|
2934
|
+
// // any ButtonType
|
|
2935
|
+
// icon: undefined,
|
|
2936
|
+
// },
|
|
2920
2937
|
drop: {
|
|
2921
|
-
//
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2938
|
+
// any BoxPartThemeType
|
|
2939
|
+
height: 'small',
|
|
2940
|
+
gap: 'none',
|
|
2941
|
+
pad: {
|
|
2942
|
+
horizontal: 'xsmall',
|
|
2943
|
+
vertical: 'small'
|
|
2944
|
+
},
|
|
2945
|
+
column: {
|
|
2946
|
+
height: '100%',
|
|
2947
|
+
gap: 'xxsmall',
|
|
2926
2948
|
pad: {
|
|
2927
|
-
vertical: 'xxsmall',
|
|
2928
2949
|
horizontal: 'xsmall'
|
|
2929
|
-
}
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
text: {
|
|
2938
|
-
weight: 500
|
|
2950
|
+
}
|
|
2951
|
+
},
|
|
2952
|
+
option: {
|
|
2953
|
+
container: {
|
|
2954
|
+
// any BoxPartThemeType
|
|
2955
|
+
pad: {
|
|
2956
|
+
vertical: 'xxsmall',
|
|
2957
|
+
horizontal: 'xsmall'
|
|
2939
2958
|
},
|
|
2959
|
+
round: baseSpacing / 6 + "px",
|
|
2960
|
+
// 4px
|
|
2940
2961
|
hover: {
|
|
2941
|
-
//
|
|
2962
|
+
// any BoxPartThemeType
|
|
2963
|
+
background: 'active-background'
|
|
2964
|
+
},
|
|
2965
|
+
selected: {
|
|
2966
|
+
// any BoxPartThemeType
|
|
2967
|
+
background: 'selected'
|
|
2968
|
+
}
|
|
2969
|
+
},
|
|
2970
|
+
text: {
|
|
2971
|
+
// any TextThemeType
|
|
2972
|
+
selected: {
|
|
2973
|
+
// any TextThemeType
|
|
2974
|
+
color: 'white',
|
|
2975
|
+
weight: 500
|
|
2942
2976
|
}
|
|
2943
2977
|
}
|
|
2944
2978
|
}
|
|
2945
|
-
},
|
|
2946
|
-
icon: {
|
|
2947
|
-
// clock: undefined,
|
|
2948
2979
|
}
|
|
2949
2980
|
},
|
|
2950
2981
|
tip: {
|
package/es6/utils/DOM.js
CHANGED
|
@@ -78,17 +78,20 @@ export var withinDropPortal = function withinDropPortal(node, portalContext) {
|
|
|
78
78
|
return true;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
export var isFocusable = function isFocusable(element) {
|
|
81
|
+
// FormField focus-styling predicate, not a general DOM focusability check.
|
|
82
|
+
// Excludes buttons and links so they retain their own focus indicators.
|
|
83
|
+
// Include negative tabIndex when checking an already-focused element;
|
|
84
|
+
// descendant discovery requires a non-negative tabIndex.
|
|
85
|
+
export var isFocusable = function isFocusable(element, includeNegativeTabIndex) {
|
|
86
|
+
if (includeNegativeTabIndex === void 0) {
|
|
87
|
+
includeNegativeTabIndex = false;
|
|
88
|
+
}
|
|
86
89
|
if (!element || element.disabled) return false;
|
|
87
90
|
var tagName = element.tagName.toLowerCase();
|
|
88
91
|
if (tagName === 'input' || tagName === 'select' || tagName === 'textarea') return true;
|
|
89
92
|
// Only non-native-interactive elements with an explicit tabindex attribute
|
|
90
93
|
var isNativeInteractive = tagName === 'button' || tagName === 'a';
|
|
91
|
-
return !isNativeInteractive && element.tabIndex >= 0 && element.hasAttribute('tabindex');
|
|
94
|
+
return !isNativeInteractive && (includeNegativeTabIndex || element.tabIndex >= 0) && element.hasAttribute('tabindex');
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
// Get the first element that can receive focus
|
|
@@ -104,7 +107,7 @@ export var getFirstFocusableDescendant = function getFirstFocusableDescendant(el
|
|
|
104
107
|
};
|
|
105
108
|
export var shouldKeepFocus = function shouldKeepFocus(root) {
|
|
106
109
|
var element = root.activeElement;
|
|
107
|
-
if (isFocusable(element)) return true;
|
|
110
|
+
if (isFocusable(element, true)) return true;
|
|
108
111
|
return !!getFirstFocusableDescendant(element);
|
|
109
112
|
};
|
|
110
113
|
export var getNewContainer = function getNewContainer(target, targetChildPosition) {
|
package/es6/utils/background.js
CHANGED
|
@@ -75,20 +75,20 @@ export var backgroundIsDark = function backgroundIsDark(backgroundArg, theme) {
|
|
|
75
75
|
!opacity || opacity !== 'weak')) {
|
|
76
76
|
var backgroundColor = normalizeColor(background.color, theme);
|
|
77
77
|
if (backgroundColor) {
|
|
78
|
-
result = colorIsDark(backgroundColor);
|
|
78
|
+
result = colorIsDark(backgroundColor, theme);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
} else {
|
|
82
82
|
var _color = normalizeColor(background, theme);
|
|
83
83
|
if (_color) {
|
|
84
|
-
result = colorIsDark(_color);
|
|
84
|
+
result = colorIsDark(_color, theme);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return result;
|
|
89
89
|
};
|
|
90
|
-
var darkContext = function darkContext(backgroundColor) {
|
|
91
|
-
var isDark = colorIsDark(backgroundColor);
|
|
90
|
+
var darkContext = function darkContext(backgroundColor, theme, text) {
|
|
91
|
+
var isDark = colorIsDark(backgroundColor, theme, text);
|
|
92
92
|
if (isDark === undefined) return undefined;
|
|
93
93
|
return isDark ? 'dark' : 'light';
|
|
94
94
|
};
|
|
@@ -118,13 +118,15 @@ export var backgroundAndTextColors = function backgroundAndTextColors(background
|
|
|
118
118
|
// set the textColor to have the best contrast against the background
|
|
119
119
|
// color.
|
|
120
120
|
if (!textColor && (opacity === undefined || opacity > 0.3)) {
|
|
121
|
-
var shade = darkContext(backgroundColor, theme);
|
|
122
|
-
|
|
121
|
+
var shade = darkContext(backgroundColor, theme, text);
|
|
122
|
+
// preserve undefined (unknown shade) so normalizeColor falls back
|
|
123
|
+
// to the ambient theme.dark instead of forcing the light side
|
|
124
|
+
textColor = normalizeColor(shade && text[shade] || text, theme, shade === undefined ? undefined : shade === 'dark');
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
} else {
|
|
126
128
|
backgroundColor = normalizeBackgroundColor(background, theme);
|
|
127
|
-
var _shade = darkContext(backgroundColor, theme);
|
|
129
|
+
var _shade = darkContext(backgroundColor, theme, text);
|
|
128
130
|
var transparent;
|
|
129
131
|
if (backgroundColor && canExtractRGBArray(backgroundColor)) {
|
|
130
132
|
var colorArray = getRGBArray(backgroundColor);
|