@telus-uds/components-base 0.0.2-prerelease.9 → 1.1.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/.eslintrc.js +9 -0
- package/.storybook/main.js +4 -0
- package/.storybook/preview.js +37 -0
- package/.ultra.cache.json +1 -1
- package/CHANGELOG.md +50 -0
- package/README.md +4 -2
- package/__fixtures__/test-utils.js +25 -0
- package/__fixtures__/testTheme.js +4 -2
- package/__tests__/Button/ButtonGroup.test.jsx +4 -5
- package/__tests__/Checkbox/Checkbox.test.jsx +2 -2
- package/__tests__/Checkbox/CheckboxGroup.test.jsx +4 -5
- package/__tests__/ExpandCollapse/ExpandCollapse.test.jsx +2 -2
- package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +164 -0
- package/__tests__/Link/LinkBase.test.jsx +0 -14
- package/__tests__/Radio/Radio.test.jsx +2 -2
- package/__tests__/Radio/RadioGroup.test.jsx +4 -5
- package/__tests__/RadioCard/RadioCard.test.jsx +2 -2
- package/__tests__/RadioCard/RadioCardGroup.test.jsx +4 -5
- package/__tests__/Search/Search.test.jsx +9 -8
- package/__tests__/Select/Select.test.jsx +3 -2
- package/__tests__/Tabs/Tabs.test.jsx +1 -161
- package/__tests__/Tags/Tags.test.jsx +4 -5
- package/__tests__/TextInput/TextArea.test.jsx +3 -2
- package/__tests__/TextInput/TextInputBase.test.jsx +10 -5
- package/__tests__/ThemeProvider/ThemeProvider.test.jsx +77 -0
- package/__tests__/ThemeProvider/useThemeTokens.test.jsx +9 -5
- package/__tests__/ThemeProvider/utils/theme-tokens.test.js +41 -0
- package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +3 -2
- package/__tests__/utils/children.test.jsx +128 -0
- package/__tests__/utils/input.test.js +1 -1
- package/__tests__/utils/semantics.test.jsx +43 -0
- package/babel.config.js +9 -16
- package/component-docs.json +10313 -0
- package/generate-component-docs.js +56 -0
- package/lib/A11yText/index.js +10 -5
- package/lib/ActivityIndicator/Spinner.js +16 -13
- package/lib/ActivityIndicator/Spinner.native.js +12 -8
- package/lib/Box/Box.js +103 -8
- package/lib/Button/Button.js +9 -8
- package/lib/Button/ButtonBase.js +14 -7
- package/lib/Button/ButtonGroup.js +25 -10
- package/lib/Button/ButtonLink.js +10 -7
- package/lib/Card/Card.js +2 -0
- package/lib/Card/CardBase.js +13 -5
- package/lib/Card/PressableCardBase.js +12 -8
- package/lib/Checkbox/Checkbox.js +25 -14
- package/lib/Checkbox/CheckboxGroup.js +22 -12
- package/lib/Divider/Divider.js +12 -7
- package/lib/ExpandCollapse/Accordion.js +10 -4
- package/lib/ExpandCollapse/Control.js +12 -6
- package/lib/ExpandCollapse/ExpandCollapse.js +10 -5
- package/lib/ExpandCollapse/Panel.js +8 -7
- package/lib/Feedback/Feedback.js +10 -5
- package/lib/Fieldset/Fieldset.js +10 -5
- package/lib/Fieldset/FieldsetContainer.js +10 -5
- package/lib/Fieldset/FieldsetContainer.native.js +10 -5
- package/lib/Fieldset/Legend.js +10 -5
- package/lib/Fieldset/Legend.native.js +10 -5
- package/lib/FlexGrid/Col/Col.js +8 -5
- package/lib/FlexGrid/FlexGrid.js +31 -6
- package/lib/FlexGrid/Row/Row.js +12 -5
- package/lib/{Tabs → HorizontalScroll}/HorizontalScroll.js +5 -4
- package/lib/{Tabs/TabsScrollButton.js → HorizontalScroll/HorizontalScrollButton.js} +14 -8
- package/lib/{Tabs → HorizontalScroll}/ScrollViewEnd.js +0 -0
- package/lib/{Tabs → HorizontalScroll}/ScrollViewEnd.native.js +0 -0
- package/lib/{Tabs → HorizontalScroll}/dictionary.js +0 -0
- package/lib/HorizontalScroll/index.js +35 -0
- package/lib/{Tabs → HorizontalScroll}/itemPositions.js +0 -0
- package/lib/Icon/Icon.js +16 -9
- package/lib/Icon/IconText.js +8 -7
- package/lib/IconButton/IconButton.js +10 -5
- package/lib/InputLabel/InputLabel.js +33 -5
- package/lib/InputLabel/LabelContent.js +22 -12
- package/lib/InputLabel/LabelContent.native.js +23 -5
- package/lib/InputSupports/InputSupports.js +10 -5
- package/lib/Link/ChevronLink.js +12 -5
- package/lib/Link/InlinePressable.js +10 -4
- package/lib/Link/InlinePressable.native.js +5 -4
- package/lib/Link/Link.js +12 -5
- package/lib/Link/LinkBase.js +12 -5
- package/lib/Link/TextButton.js +10 -5
- package/lib/List/List.js +6 -6
- package/lib/List/ListItem.js +28 -33
- package/lib/List/index.js +15 -0
- package/lib/Modal/Modal.js +10 -5
- package/lib/Notification/Notification.js +21 -5
- package/lib/Pagination/PageButton.js +16 -11
- package/lib/Pagination/Pagination.js +12 -7
- package/lib/Pagination/SideButton.js +12 -7
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/Progress.js +10 -5
- package/lib/Progress/ProgressBar.js +21 -10
- package/lib/Progress/ProgressBarBackground.js +12 -8
- package/lib/Radio/Radio.js +14 -13
- package/lib/Radio/RadioButton.js +20 -9
- package/lib/Radio/RadioGroup.js +24 -13
- package/lib/RadioCard/RadioCard.js +14 -10
- package/lib/RadioCard/RadioCardGroup.js +13 -12
- package/lib/Search/Search.js +29 -18
- package/lib/Select/Picker.js +11 -6
- package/lib/Select/Picker.native.js +21 -6
- package/lib/Select/Select.js +46 -4
- package/lib/SideNav/Item.js +10 -5
- package/lib/SideNav/ItemsGroup.js +10 -5
- package/lib/SideNav/SideNav.js +11 -7
- package/lib/Skeleton/Skeleton.js +15 -15
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/Spacer/Spacer.js +19 -7
- package/lib/StackView/StackView.js +26 -7
- package/lib/StackView/StackWrap.js +24 -13
- package/lib/StackView/StackWrapBox.js +34 -8
- package/lib/StackView/StackWrapGap.js +16 -7
- package/lib/StackView/common.js +4 -2
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/StepTracker/StepTracker.js +10 -5
- package/lib/Tabs/Tabs.js +26 -19
- package/lib/Tabs/TabsItem.js +16 -12
- package/lib/Tags/Tags.js +27 -11
- package/lib/TextInput/TextArea.js +7 -5
- package/lib/TextInput/TextInput.js +12 -6
- package/lib/TextInput/TextInputBase.js +12 -8
- package/lib/ThemeProvider/ThemeProvider.js +14 -10
- package/lib/ThemeProvider/useSetTheme.js +6 -1
- package/lib/ThemeProvider/utils/styles.js +2 -2
- package/lib/ThemeProvider/utils/theme-tokens.js +39 -8
- package/lib/ToggleSwitch/ToggleSwitch.js +11 -6
- package/lib/Tooltip/Backdrop.js +10 -2
- package/lib/Tooltip/Tooltip.js +5 -4
- package/lib/Typography/Typography.js +40 -24
- package/lib/index.js +36 -1
- package/lib/utils/a11y/index.js +13 -0
- package/lib/utils/a11y/propTypes.js +61 -0
- package/lib/utils/a11y/propTypes.native.js +47 -0
- package/lib/utils/a11y/semantics.js +173 -0
- package/lib/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib/utils/children.js +55 -8
- package/lib/utils/input.js +27 -17
- package/lib/utils/propTypes.js +40 -68
- package/lib/utils/useCopy.js +1 -1
- package/lib/utils/useHash.js +8 -4
- package/lib/utils/useSpacingScale.js +1 -3
- package/lib/utils/useUniqueId.js +1 -1
- package/package.json +14 -6
- package/release-context.json +4 -4
- package/src/A11yText/index.jsx +6 -4
- package/src/ActivityIndicator/Spinner.jsx +5 -3
- package/src/ActivityIndicator/Spinner.native.jsx +5 -3
- package/src/Box/Box.jsx +125 -39
- package/src/Button/Button.jsx +7 -4
- package/src/Button/ButtonBase.jsx +86 -77
- package/src/Button/ButtonGroup.jsx +81 -69
- package/src/Button/ButtonLink.jsx +18 -13
- package/src/Card/Card.jsx +2 -2
- package/src/Card/CardBase.jsx +6 -4
- package/src/Card/PressableCardBase.jsx +71 -64
- package/src/Checkbox/Checkbox.jsx +118 -108
- package/src/Checkbox/CheckboxGroup.jsx +72 -62
- package/src/Divider/Divider.jsx +7 -4
- package/src/ExpandCollapse/Accordion.jsx +3 -2
- package/src/ExpandCollapse/Control.jsx +40 -43
- package/src/ExpandCollapse/ExpandCollapse.jsx +26 -23
- package/src/ExpandCollapse/Panel.jsx +69 -63
- package/src/Feedback/Feedback.jsx +36 -33
- package/src/Fieldset/Fieldset.jsx +63 -56
- package/src/Fieldset/FieldsetContainer.jsx +14 -5
- package/src/Fieldset/FieldsetContainer.native.jsx +7 -4
- package/src/Fieldset/Legend.jsx +7 -2
- package/src/Fieldset/Legend.native.jsx +7 -2
- package/src/FlexGrid/Col/Col.jsx +139 -132
- package/src/FlexGrid/FlexGrid.jsx +79 -51
- package/src/FlexGrid/Row/Row.jsx +55 -48
- package/src/HorizontalScroll/HorizontalScroll.jsx +168 -0
- package/src/HorizontalScroll/HorizontalScrollButton.jsx +105 -0
- package/src/{Tabs → HorizontalScroll}/ScrollViewEnd.jsx +0 -0
- package/src/{Tabs → HorizontalScroll}/ScrollViewEnd.native.jsx +0 -0
- package/src/{Tabs → HorizontalScroll}/dictionary.js +0 -0
- package/src/HorizontalScroll/index.js +17 -0
- package/src/{Tabs → HorizontalScroll}/itemPositions.js +0 -0
- package/src/Icon/Icon.jsx +37 -35
- package/src/Icon/IconText.jsx +22 -17
- package/src/IconButton/IconButton.jsx +49 -42
- package/src/InputLabel/InputLabel.jsx +53 -38
- package/src/InputLabel/LabelContent.jsx +14 -6
- package/src/InputLabel/LabelContent.native.jsx +11 -2
- package/src/InputSupports/InputSupports.jsx +29 -34
- package/src/Link/ChevronLink.jsx +26 -16
- package/src/Link/InlinePressable.jsx +5 -3
- package/src/Link/InlinePressable.native.jsx +5 -3
- package/src/Link/Link.jsx +22 -16
- package/src/Link/LinkBase.jsx +67 -58
- package/src/Link/TextButton.jsx +30 -23
- package/src/List/List.jsx +6 -7
- package/src/List/ListItem.jsx +70 -90
- package/src/List/index.js +5 -0
- package/src/Modal/Modal.jsx +9 -4
- package/src/Notification/Notification.jsx +58 -43
- package/src/Pagination/PageButton.jsx +37 -34
- package/src/Pagination/Pagination.jsx +88 -92
- package/src/Pagination/SideButton.jsx +44 -41
- package/src/Progress/Progress.jsx +5 -4
- package/src/Progress/ProgressBar.jsx +42 -29
- package/src/Progress/ProgressBarBackground.jsx +5 -3
- package/src/Radio/Radio.jsx +85 -78
- package/src/Radio/RadioButton.jsx +54 -43
- package/src/Radio/RadioGroup.jsx +74 -63
- package/src/RadioCard/RadioCard.jsx +75 -68
- package/src/RadioCard/RadioCardGroup.jsx +82 -75
- package/src/Search/Search.jsx +127 -106
- package/src/Select/Picker.jsx +49 -42
- package/src/Select/Picker.native.jsx +56 -49
- package/src/Select/Select.jsx +115 -72
- package/src/SideNav/Item.jsx +53 -46
- package/src/SideNav/ItemsGroup.jsx +50 -43
- package/src/SideNav/SideNav.jsx +68 -60
- package/src/Skeleton/Skeleton.jsx +9 -13
- package/src/Spacer/Spacer.jsx +11 -4
- package/src/StackView/StackView.jsx +47 -23
- package/src/StackView/StackWrap.jsx +14 -12
- package/src/StackView/StackWrapBox.jsx +62 -28
- package/src/StackView/StackWrapGap.jsx +46 -24
- package/src/StackView/common.jsx +3 -2
- package/src/StepTracker/StepTracker.jsx +73 -62
- package/src/Tabs/Tabs.jsx +70 -62
- package/src/Tabs/TabsItem.jsx +111 -103
- package/src/Tags/Tags.jsx +114 -102
- package/src/TextInput/TextArea.jsx +5 -4
- package/src/TextInput/TextInput.jsx +5 -4
- package/src/TextInput/TextInputBase.jsx +84 -77
- package/src/ThemeProvider/ThemeProvider.jsx +11 -7
- package/src/ThemeProvider/useSetTheme.js +4 -0
- package/src/ThemeProvider/utils/theme-tokens.js +28 -0
- package/src/ToggleSwitch/ToggleSwitch.jsx +49 -50
- package/src/Tooltip/Tooltip.jsx +134 -130
- package/src/Typography/Typography.jsx +67 -44
- package/src/index.js +3 -1
- package/src/utils/a11y/index.js +1 -0
- package/src/utils/a11y/propTypes.js +61 -0
- package/src/utils/a11y/propTypes.native.js +39 -0
- package/src/utils/a11y/semantics.js +162 -0
- package/src/utils/children.jsx +60 -7
- package/src/utils/input.js +20 -17
- package/src/utils/propTypes.js +30 -76
- package/src/utils/useCopy.js +1 -1
- package/src/utils/useHash.js +8 -3
- package/stories/A11yText/A11yText.stories.jsx +3 -3
- package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +2 -2
- package/stories/Box/Box.stories.jsx +2 -2
- package/stories/Button/Button.stories.jsx +3 -3
- package/stories/Button/ButtonGroup.stories.jsx +2 -2
- package/stories/Button/ButtonLink.stories.jsx +2 -2
- package/stories/Card/Card.stories.jsx +2 -2
- package/stories/Checkbox/Checkbox.stories.jsx +2 -2
- package/stories/Divider/Divider.stories.jsx +2 -2
- package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +3 -3
- package/stories/Feedback/Feedback.stories.jsx +2 -2
- package/stories/FlexGrid/01 FlexGrid.stories.jsx +2 -2
- package/stories/FlexGrid/02 Row.stories.jsx +2 -2
- package/stories/FlexGrid/03 Col.stories.jsx +2 -2
- package/stories/Icon/Icon.stories.jsx +2 -2
- package/stories/IconButton/IconButton.stories.jsx +2 -2
- package/stories/InputLabel/InputLabel.stories.jsx +2 -2
- package/stories/Link/ChevronLink.stories.jsx +2 -2
- package/stories/Link/Link.stories.jsx +2 -2
- package/stories/Link/TextButton.stories.jsx +2 -2
- package/stories/List/List.stories.jsx +2 -2
- package/stories/Modal/Modal.stories.jsx +2 -2
- package/stories/Notification/Notification.stories.jsx +2 -2
- package/stories/Pagination/Pagination.stories.jsx +2 -2
- package/stories/Progress/Progress.stories.jsx +2 -2
- package/stories/Radio/Radio.stories.jsx +2 -2
- package/stories/RadioCard/RadioCard.stories.jsx +2 -2
- package/stories/Search/Search.stories.jsx +2 -2
- package/stories/Select/Select.stories.jsx +2 -2
- package/stories/SideNav/SideNav.stories.jsx +2 -2
- package/stories/SideNav/SideNavItem.stories.jsx +2 -2
- package/stories/SideNav/SideNavItemsGroup.stories.jsx +2 -2
- package/stories/Skeleton/Skeleton.stories.jsx +3 -3
- package/stories/Spacer/Spacer.stories.jsx +2 -2
- package/stories/StackView/StackView.stories.jsx +2 -2
- package/stories/StackView/StackWrap.stories.jsx +2 -2
- package/stories/StepTracker/StepTracker.stories.jsx +2 -2
- package/stories/Tabs/Tabs.stories.jsx +2 -2
- package/stories/Tags/Tags.stories.jsx +2 -2
- package/stories/TextInput/TextArea.stories.jsx +2 -2
- package/stories/TextInput/TextInput.stories.jsx +2 -2
- package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +2 -2
- package/stories/Tooltip/Tooltip.stories.jsx +2 -2
- package/stories/TooltipButton/TooltipButton.stories.jsx +2 -2
- package/stories/Typography/Typography.stories.jsx +2 -2
- package/stories/platform-supports.jsx +1 -1
- package/stories/supports.jsx +4 -5
- package/src/Tabs/HorizontalScroll.jsx +0 -165
- package/src/Tabs/TabsScrollButton.jsx +0 -100
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
13
|
+
|
|
12
14
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
13
15
|
|
|
14
16
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
@@ -25,6 +27,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
27
|
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
29
|
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
28
34
|
const selectBarStyles = ({
|
|
29
35
|
backgroundColor,
|
|
30
36
|
borderRadius,
|
|
@@ -35,7 +41,7 @@ const selectBarStyles = ({
|
|
|
35
41
|
borderRadius,
|
|
36
42
|
outlineWidth,
|
|
37
43
|
outlineColor,
|
|
38
|
-
width:
|
|
44
|
+
width: `${percentage}%`
|
|
39
45
|
});
|
|
40
46
|
/**
|
|
41
47
|
* The `ProgressBar` is a visual representation of linear progression.
|
|
@@ -73,13 +79,13 @@ const selectBarStyles = ({
|
|
|
73
79
|
*/
|
|
74
80
|
|
|
75
81
|
|
|
76
|
-
const ProgressBar = ({
|
|
82
|
+
const ProgressBar = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
77
83
|
children = null,
|
|
78
84
|
percentage = 0,
|
|
79
85
|
tokens,
|
|
80
86
|
variant,
|
|
81
87
|
...rest
|
|
82
|
-
}) => {
|
|
88
|
+
}, ref) => {
|
|
83
89
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('ProgressBar', tokens, variant);
|
|
84
90
|
|
|
85
91
|
if (percentage < 0) {
|
|
@@ -94,19 +100,20 @@ const ProgressBar = ({
|
|
|
94
100
|
min: 0,
|
|
95
101
|
max: 100,
|
|
96
102
|
now: percentage,
|
|
97
|
-
text:
|
|
103
|
+
text: `${percentage}%`
|
|
98
104
|
},
|
|
99
105
|
..._propTypes2.a11yProps.select(rest)
|
|
100
106
|
};
|
|
101
107
|
return percentage > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
108
|
+
ref: ref,
|
|
102
109
|
style: [staticStyles.bar, selectBarStyles(themeTokens, percentage)],
|
|
103
110
|
...accessibilityProps,
|
|
104
|
-
children: children
|
|
111
|
+
children: children ?? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProgressBarBackground.default, {
|
|
105
112
|
variant: variant
|
|
106
113
|
})
|
|
107
114
|
}) : null;
|
|
108
|
-
};
|
|
109
|
-
|
|
115
|
+
});
|
|
116
|
+
ProgressBar.displayName = 'ProgressBar';
|
|
110
117
|
ProgressBar.propTypes = {
|
|
111
118
|
/**
|
|
112
119
|
* Optional children that can be used to customize the progress bar filling.
|
|
@@ -139,8 +146,12 @@ exports.default = _default;
|
|
|
139
146
|
const staticStyles = _StyleSheet.default.create({
|
|
140
147
|
bar: {
|
|
141
148
|
height: '100%',
|
|
142
|
-
outlineStyle: 'solid',
|
|
143
149
|
overflow: 'hidden',
|
|
144
|
-
position: 'absolute'
|
|
150
|
+
position: 'absolute',
|
|
151
|
+
..._Platform.default.select({
|
|
152
|
+
web: {
|
|
153
|
+
outlineStyle: 'solid'
|
|
154
|
+
}
|
|
155
|
+
})
|
|
145
156
|
}
|
|
146
157
|
});
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _ImageBackground = _interopRequireDefault(require("react-native-web/dist/cjs/exports/ImageBackground"));
|
|
11
11
|
|
|
@@ -17,12 +17,15 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
const negativeBackground = "%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='NegativeProgress6' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23C12335'%3E%3C/rect%3E%3Cpath d='M 0,8 l 8,-8 M -2,2 l 4,-4 M 6,10 l 4,-4' stroke-width='2' shape-rendering='auto' stroke='%23e7adb4' stroke-linecap='square'%3E%3C/path%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23NegativeProgress6");'%3E%3C/path%3E%3C/svg%3E";
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
24
|
+
const inactiveBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='DisabledProgress7' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23B2B9BF'%3E%3C/rect%3E%3Ccircle cx='4' cy='4' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23DisabledProgress7");'%3E%3C/path%3E%3C/svg%3E`;
|
|
25
|
+
const negativeBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='NegativeProgress6' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23C12335'%3E%3C/rect%3E%3Cpath d='M 0,8 l 8,-8 M -2,2 l 4,-4 M 6,10 l 4,-4' stroke-width='2' shape-rendering='auto' stroke='%23e7adb4' stroke-linecap='square'%3E%3C/path%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23NegativeProgress6");'%3E%3C/path%3E%3C/svg%3E`;
|
|
26
|
+
const ProgressBarBackground = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
24
27
|
variant
|
|
25
|
-
}) => {
|
|
28
|
+
}, ref) => {
|
|
26
29
|
let source = null;
|
|
27
30
|
|
|
28
31
|
if (variant !== null && variant !== void 0 && variant.inactive) {
|
|
@@ -34,13 +37,14 @@ const ProgressBarBackground = ({
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageBackground.default, {
|
|
40
|
+
ref: ref,
|
|
37
41
|
source: {
|
|
38
|
-
uri:
|
|
42
|
+
uri: `data:image/svg+xml,${source}`
|
|
39
43
|
},
|
|
40
44
|
style: staticStyles.imageBackground
|
|
41
45
|
});
|
|
42
|
-
};
|
|
43
|
-
|
|
46
|
+
});
|
|
47
|
+
ProgressBarBackground.displayName = 'ProgressBarBackground';
|
|
44
48
|
ProgressBarBackground.propTypes = {
|
|
45
49
|
/**
|
|
46
50
|
* Progress bar variant.
|
package/lib/Radio/Radio.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -31,12 +31,12 @@ var _StackView = _interopRequireDefault(require("../StackView"));
|
|
|
31
31
|
|
|
32
32
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
33
|
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
+
|
|
34
36
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
37
|
|
|
36
38
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
39
|
|
|
38
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
-
|
|
40
40
|
// @todo move `LabelContent` outside of the `InputLabel` and fix
|
|
41
41
|
// the issue with the cursor not being pointer on Web
|
|
42
42
|
const selectContainerStyles = ({
|
|
@@ -67,7 +67,7 @@ const selectDescriptionStyles = ({
|
|
|
67
67
|
inputSize,
|
|
68
68
|
labelMarginLeft = 0
|
|
69
69
|
}) => ({
|
|
70
|
-
marginLeft: descriptionMarginLeft
|
|
70
|
+
marginLeft: descriptionMarginLeft ?? containerPaddingLeft + inputSize + labelMarginLeft,
|
|
71
71
|
...(0, _ThemeProvider.applyTextStyles)({
|
|
72
72
|
fontSize: descriptionFontSize,
|
|
73
73
|
lineHeight: descriptionLineHeight
|
|
@@ -123,7 +123,7 @@ const selectLabelStyles = ({
|
|
|
123
123
|
*/
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
const Radio = ({
|
|
126
|
+
const Radio = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
127
127
|
checked,
|
|
128
128
|
defaultChecked,
|
|
129
129
|
description,
|
|
@@ -137,7 +137,7 @@ const Radio = ({
|
|
|
137
137
|
value,
|
|
138
138
|
variant,
|
|
139
139
|
...rest
|
|
140
|
-
}) => {
|
|
140
|
+
}, ref) => {
|
|
141
141
|
const {
|
|
142
142
|
currentValue: isChecked,
|
|
143
143
|
setValue: setIsChecked,
|
|
@@ -154,22 +154,23 @@ const Radio = ({
|
|
|
154
154
|
...variant
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
-
const handleChange =
|
|
157
|
+
const handleChange = event => {
|
|
158
158
|
if (!inactive && !isChecked) {
|
|
159
|
-
setIsChecked(true);
|
|
159
|
+
setIsChecked(true, event);
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const handleKeyDown =
|
|
163
|
+
const handleKeyDown = event => {
|
|
164
164
|
// The expected keyboard shortcut for activating a radio is the Space key
|
|
165
|
-
if ((
|
|
165
|
+
if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
|
|
166
166
|
};
|
|
167
167
|
|
|
168
168
|
const accessibilityProps = _propTypes2.a11yProps.select(rest);
|
|
169
169
|
|
|
170
170
|
const uniqueId = (0, _utils.useUniqueId)('radio');
|
|
171
|
-
const inputId = id
|
|
171
|
+
const inputId = id ?? uniqueId;
|
|
172
172
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
173
|
+
ref: ref,
|
|
173
174
|
disabled: inactive,
|
|
174
175
|
onKeyDown: handleKeyDown,
|
|
175
176
|
onPress: handleChange,
|
|
@@ -217,8 +218,8 @@ const Radio = ({
|
|
|
217
218
|
});
|
|
218
219
|
}
|
|
219
220
|
});
|
|
220
|
-
};
|
|
221
|
-
|
|
221
|
+
});
|
|
222
|
+
Radio.displayName = 'Radio';
|
|
222
223
|
Radio.propTypes = { ..._propTypes2.a11yProps.propTypes,
|
|
223
224
|
|
|
224
225
|
/**
|
package/lib/Radio/RadioButton.js
CHANGED
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.selectRadioButtonTokens = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
13
|
+
|
|
12
14
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
13
15
|
|
|
14
16
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
@@ -23,6 +25,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
27
|
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
|
|
26
32
|
// TODO: roll out a standard approach to token sets
|
|
27
33
|
// https://github.com/telus/universal-design-system/issues/782
|
|
28
34
|
const tokenKeys = ['checkedBackgroundColor', 'checkedSize', 'inputBackgroundColor', 'inputBorderColor', 'inputBorderWidth', 'inputOutlineColor', 'inputOutlineWidth', 'inputSize', 'outerBorderColor', 'outerBorderWidth', 'outerBorderGap', 'inputSize'];
|
|
@@ -55,11 +61,15 @@ const selectInputStyles = ({
|
|
|
55
61
|
borderRadius: getBorderRadius(inputSize),
|
|
56
62
|
borderWidth: inputBorderWidth,
|
|
57
63
|
backgroundColor: inputBackgroundColor,
|
|
58
|
-
outlineStyle: 'solid',
|
|
59
|
-
outlineColor: inputOutlineColor,
|
|
60
|
-
outlineWidth: inputOutlineWidth,
|
|
61
64
|
height: inputSize,
|
|
62
|
-
width: inputSize
|
|
65
|
+
width: inputSize,
|
|
66
|
+
..._Platform.default.select({
|
|
67
|
+
web: {
|
|
68
|
+
outlineStyle: 'solid',
|
|
69
|
+
outlineColor: inputOutlineColor,
|
|
70
|
+
outlineWidth: inputOutlineWidth
|
|
71
|
+
}
|
|
72
|
+
})
|
|
63
73
|
});
|
|
64
74
|
|
|
65
75
|
const selectOuterBorderStyles = ({
|
|
@@ -80,7 +90,7 @@ const selectOuterBorderStyles = ({
|
|
|
80
90
|
*/
|
|
81
91
|
|
|
82
92
|
|
|
83
|
-
const RadioButton = ({
|
|
93
|
+
const RadioButton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
84
94
|
isChecked,
|
|
85
95
|
tokens,
|
|
86
96
|
inactive,
|
|
@@ -90,7 +100,7 @@ const RadioButton = ({
|
|
|
90
100
|
handleChange,
|
|
91
101
|
name: inputName,
|
|
92
102
|
value
|
|
93
|
-
}) => {
|
|
103
|
+
}, ref) => {
|
|
94
104
|
const themeTokens = (0, _ThemeProvider.validateThemeTokens)((0, _ThemeProvider.resolveThemeTokens)(tokens, {
|
|
95
105
|
checked: isChecked
|
|
96
106
|
}), (0, _utils.getTokensSetPropType)(tokenKeys), 'RadioButton');
|
|
@@ -100,6 +110,7 @@ const RadioButton = ({
|
|
|
100
110
|
style: [staticStyles.defaultInputStyles, selectInputStyles(themeTokens, isChecked)],
|
|
101
111
|
testID: "Radio-Input",
|
|
102
112
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioInput.default, {
|
|
113
|
+
ref: ref,
|
|
103
114
|
checked: isChecked,
|
|
104
115
|
defaultChecked: defaultChecked,
|
|
105
116
|
disabled: inactive,
|
|
@@ -114,8 +125,8 @@ const RadioButton = ({
|
|
|
114
125
|
})]
|
|
115
126
|
})
|
|
116
127
|
});
|
|
117
|
-
};
|
|
118
|
-
|
|
128
|
+
});
|
|
129
|
+
RadioButton.displayName = 'RadioButton';
|
|
119
130
|
RadioButton.propTypes = {
|
|
120
131
|
isChecked: _propTypes.default.bool,
|
|
121
132
|
tokens: (0, _utils.getTokensSetPropType)(tokenKeys, {
|
package/lib/Radio/RadioGroup.js
CHANGED
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _airbnbPropTypes = _interopRequireDefault(require("airbnb-prop-types"));
|
|
13
|
+
|
|
12
14
|
var _ViewportProvider = require("../ViewportProvider");
|
|
13
15
|
|
|
14
16
|
var _ThemeProvider = require("../ThemeProvider");
|
|
@@ -25,6 +27,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
27
|
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
29
|
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* A group of Radios that behave as a radio group. Use when users select a single choice from mutually
|
|
30
36
|
* exclusive options.
|
|
@@ -73,7 +79,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
73
79
|
* />
|
|
74
80
|
* ```
|
|
75
81
|
*/
|
|
76
|
-
const RadioGroup = ({
|
|
82
|
+
const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
77
83
|
tokens,
|
|
78
84
|
radioTokens,
|
|
79
85
|
variant,
|
|
@@ -89,7 +95,7 @@ const RadioGroup = ({
|
|
|
89
95
|
readOnly,
|
|
90
96
|
name: inputGroupName,
|
|
91
97
|
inactive
|
|
92
|
-
}) => {
|
|
98
|
+
}, ref) => {
|
|
93
99
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
94
100
|
const {
|
|
95
101
|
space,
|
|
@@ -109,18 +115,21 @@ const RadioGroup = ({
|
|
|
109
115
|
const radios = items.map(({
|
|
110
116
|
label,
|
|
111
117
|
id,
|
|
112
|
-
onChange: itemOnChange
|
|
118
|
+
onChange: itemOnChange,
|
|
119
|
+
ref: itemRef
|
|
113
120
|
}, index) => {
|
|
114
|
-
const radioId = id ||
|
|
121
|
+
const radioId = id || `Radio[${index}]`;
|
|
122
|
+
const isChecked = currentValue === radioId;
|
|
115
123
|
|
|
116
|
-
const handleChange = (
|
|
117
|
-
if (typeof itemOnChange === 'function') itemOnChange(
|
|
118
|
-
setValue(radioId);
|
|
124
|
+
const handleChange = (newCheckedState, event) => {
|
|
125
|
+
if (typeof itemOnChange === 'function') itemOnChange(newCheckedState, event);
|
|
126
|
+
if (newCheckedState) setValue(radioId, event);
|
|
119
127
|
};
|
|
120
128
|
|
|
121
129
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Radio.default, {
|
|
130
|
+
ref: itemRef,
|
|
122
131
|
id: radioId,
|
|
123
|
-
checked:
|
|
132
|
+
checked: isChecked,
|
|
124
133
|
onChange: handleChange,
|
|
125
134
|
inactive: inactive,
|
|
126
135
|
label: label,
|
|
@@ -130,6 +139,7 @@ const RadioGroup = ({
|
|
|
130
139
|
}, radioId);
|
|
131
140
|
});
|
|
132
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
|
|
142
|
+
ref: ref,
|
|
133
143
|
name: inputGroupName,
|
|
134
144
|
legend: legend,
|
|
135
145
|
tooltip: tooltip,
|
|
@@ -137,15 +147,15 @@ const RadioGroup = ({
|
|
|
137
147
|
space: fieldSpace,
|
|
138
148
|
feedback: feedback,
|
|
139
149
|
inactive: inactive,
|
|
140
|
-
|
|
150
|
+
validation: validation,
|
|
141
151
|
accessibilityRole: "radiogroup",
|
|
142
152
|
children: (0, _StackView.getStackedContent)(radios, {
|
|
143
153
|
space,
|
|
144
154
|
direction: 'column'
|
|
145
155
|
})
|
|
146
156
|
});
|
|
147
|
-
};
|
|
148
|
-
|
|
157
|
+
});
|
|
158
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
149
159
|
RadioGroup.propTypes = {
|
|
150
160
|
/**
|
|
151
161
|
* Optional theme token overrides for the outer RadioGroup component
|
|
@@ -168,7 +178,8 @@ RadioGroup.propTypes = {
|
|
|
168
178
|
items: _propTypes.default.arrayOf(_propTypes.default.exact({
|
|
169
179
|
label: _propTypes.default.string,
|
|
170
180
|
id: _propTypes.default.string,
|
|
171
|
-
onChange: _propTypes.default.func
|
|
181
|
+
onChange: _propTypes.default.func,
|
|
182
|
+
ref: _airbnbPropTypes.default.ref()
|
|
172
183
|
})),
|
|
173
184
|
|
|
174
185
|
/**
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -27,12 +27,12 @@ var _RadioButton = _interopRequireWildcard(require("../Radio/RadioButton"));
|
|
|
27
27
|
|
|
28
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
29
|
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
30
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
33
|
|
|
32
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
35
|
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
36
|
/**
|
|
37
37
|
* A Card that behaves like a radio button. Use when users select a single choice from mutually exclusive options
|
|
38
38
|
* with need to show additional information for each option. The whole card is interactive as one item.
|
|
@@ -68,7 +68,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
68
68
|
* accessibility role `'radio'` and accessibility state that depends on the other props (`checked`, `inactive`)
|
|
69
69
|
* or the internal state in case of uncontrolled radio button.
|
|
70
70
|
*/
|
|
71
|
-
const RadioCard = ({
|
|
71
|
+
const RadioCard = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
72
72
|
tokens,
|
|
73
73
|
variant,
|
|
74
74
|
title,
|
|
@@ -81,7 +81,7 @@ const RadioCard = ({
|
|
|
81
81
|
id,
|
|
82
82
|
onChange,
|
|
83
83
|
...rest
|
|
84
|
-
}) => {
|
|
84
|
+
}, ref) => {
|
|
85
85
|
const {
|
|
86
86
|
currentValue: isChecked,
|
|
87
87
|
setValue: setIsChecked,
|
|
@@ -92,21 +92,22 @@ const RadioCard = ({
|
|
|
92
92
|
onChange
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
const handleChange =
|
|
95
|
+
const handleChange = event => {
|
|
96
96
|
if (!inactive && !isChecked) {
|
|
97
|
-
setIsChecked(true);
|
|
97
|
+
setIsChecked(true, event);
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
const a11y = _utils.a11yProps.select(rest);
|
|
102
102
|
|
|
103
103
|
const uniqueId = (0, _utils.useUniqueId)('RadioCard');
|
|
104
|
-
const inputId = id
|
|
104
|
+
const inputId = id ?? uniqueId;
|
|
105
105
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('RadioCard', tokens, variant);
|
|
106
106
|
|
|
107
107
|
const getCardTokens = cardState => (0, _Card.selectPressableCardTokens)(getTokens(cardState));
|
|
108
108
|
|
|
109
109
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.PressableCardBase, {
|
|
110
|
+
ref: ref,
|
|
110
111
|
inactive: inactive,
|
|
111
112
|
checked: isChecked,
|
|
112
113
|
tokens: getCardTokens,
|
|
@@ -147,6 +148,9 @@ const RadioCard = ({
|
|
|
147
148
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
148
149
|
direction: "column",
|
|
149
150
|
space: contentSpace,
|
|
151
|
+
tokens: {
|
|
152
|
+
flexShrink: 1
|
|
153
|
+
},
|
|
150
154
|
children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
151
155
|
style: textStyle,
|
|
152
156
|
children: title
|
|
@@ -155,8 +159,8 @@ const RadioCard = ({
|
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
161
|
});
|
|
158
|
-
};
|
|
159
|
-
|
|
162
|
+
});
|
|
163
|
+
RadioCard.displayName = 'RadioCard';
|
|
160
164
|
RadioCard.propTypes = { ..._utils.a11yProps.propTypes,
|
|
161
165
|
|
|
162
166
|
/**
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -23,12 +23,12 @@ var _Fieldset = _interopRequireDefault(require("../Fieldset"));
|
|
|
23
23
|
|
|
24
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
25
|
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
26
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
29
|
|
|
28
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
31
|
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
32
|
/**
|
|
33
33
|
* A group of Cards that behave as a radio button group. Use when users select a single choice from mutually
|
|
34
34
|
* exclusive options with need to show additional information for each option. The whole cards are each
|
|
@@ -79,7 +79,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
79
79
|
* />
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
const RadioCardGroup = ({
|
|
82
|
+
const RadioCardGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
83
83
|
tokens,
|
|
84
84
|
radioCardTokens,
|
|
85
85
|
variant,
|
|
@@ -95,7 +95,7 @@ const RadioCardGroup = ({
|
|
|
95
95
|
readOnly,
|
|
96
96
|
name: inputGroupName,
|
|
97
97
|
inactive
|
|
98
|
-
}) => {
|
|
98
|
+
}, ref) => {
|
|
99
99
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
100
100
|
const {
|
|
101
101
|
space,
|
|
@@ -118,6 +118,7 @@ const RadioCardGroup = ({
|
|
|
118
118
|
// TODO: test this on more web screen readers.
|
|
119
119
|
|
|
120
120
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
|
|
121
|
+
ref: ref,
|
|
121
122
|
name: inputGroupName,
|
|
122
123
|
legend: legend,
|
|
123
124
|
tooltip: tooltip,
|
|
@@ -125,7 +126,7 @@ const RadioCardGroup = ({
|
|
|
125
126
|
space: fieldSpace,
|
|
126
127
|
feedback: feedback,
|
|
127
128
|
inactive: inactive || readOnly,
|
|
128
|
-
|
|
129
|
+
validation: validation,
|
|
129
130
|
accessibilityRole: "radiogroup",
|
|
130
131
|
children: ({
|
|
131
132
|
a11yProps
|
|
@@ -138,11 +139,11 @@ const RadioCardGroup = ({
|
|
|
138
139
|
id,
|
|
139
140
|
onChange: itemOnChange
|
|
140
141
|
}, index) => {
|
|
141
|
-
const cardId = id ||
|
|
142
|
+
const cardId = id || `RadioCard[${index}]`;
|
|
142
143
|
|
|
143
|
-
const handleChange = (
|
|
144
|
-
if (typeof itemOnChange === 'function') itemOnChange(
|
|
145
|
-
setValue(cardId);
|
|
144
|
+
const handleChange = (newCheckedState, event) => {
|
|
145
|
+
if (typeof itemOnChange === 'function') itemOnChange(newCheckedState, event);
|
|
146
|
+
if (newCheckedState) setValue(cardId, event);
|
|
146
147
|
};
|
|
147
148
|
|
|
148
149
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioCard.default, {
|
|
@@ -161,8 +162,8 @@ const RadioCardGroup = ({
|
|
|
161
162
|
})
|
|
162
163
|
})
|
|
163
164
|
});
|
|
164
|
-
};
|
|
165
|
-
|
|
165
|
+
});
|
|
166
|
+
RadioCardGroup.displayName = 'RadioCardGroup';
|
|
166
167
|
RadioCardGroup.propTypes = {
|
|
167
168
|
/**
|
|
168
169
|
* Optional theme token overrides for the outer RadioCardGroup component
|