@telus-uds/components-base 0.0.2-prerelease.9 → 1.0.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/.ultra.cache.json +1 -1
- package/CHANGELOG.md +32 -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/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 +102 -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 +12 -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 +5 -4
- package/lib/List/ListItem.js +16 -8
- package/lib/Modal/Modal.js +10 -5
- package/lib/Notification/Notification.js +21 -5
- package/lib/Pagination/PageButton.js +21 -10
- 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 +25 -7
- package/lib/StackView/StackWrap.js +16 -9
- package/lib/StackView/StackWrapBox.js +33 -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 +21 -0
- package/lib/utils/a11y/index.js +13 -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 +82 -29
- 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 +9 -5
- 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 +124 -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 +5 -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 +5 -4
- package/src/List/ListItem.jsx +77 -82
- package/src/Modal/Modal.jsx +9 -4
- package/src/Notification/Notification.jsx +58 -43
- package/src/Pagination/PageButton.jsx +42 -35
- 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 +46 -23
- package/src/StackView/StackWrap.jsx +7 -6
- package/src/StackView/StackWrapBox.jsx +61 -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 +2 -0
- package/src/utils/a11y/index.js +1 -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 +101 -39
- package/src/utils/useCopy.js +1 -1
- package/src/utils/useHash.js +8 -3
- package/stories/A11yText/A11yText.stories.jsx +2 -2
- package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
- package/stories/Box/Box.stories.jsx +1 -1
- package/stories/Button/Button.stories.jsx +2 -2
- package/stories/Button/ButtonGroup.stories.jsx +1 -1
- package/stories/Button/ButtonLink.stories.jsx +1 -1
- package/stories/Card/Card.stories.jsx +1 -1
- package/stories/Checkbox/Checkbox.stories.jsx +1 -1
- package/stories/Divider/Divider.stories.jsx +1 -1
- package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +2 -2
- package/stories/Feedback/Feedback.stories.jsx +1 -1
- package/stories/FlexGrid/01 FlexGrid.stories.jsx +1 -1
- package/stories/FlexGrid/02 Row.stories.jsx +1 -1
- package/stories/FlexGrid/03 Col.stories.jsx +1 -1
- package/stories/Icon/Icon.stories.jsx +1 -1
- package/stories/IconButton/IconButton.stories.jsx +1 -1
- package/stories/InputLabel/InputLabel.stories.jsx +1 -1
- package/stories/Link/ChevronLink.stories.jsx +1 -1
- package/stories/Link/Link.stories.jsx +1 -1
- package/stories/Link/TextButton.stories.jsx +1 -1
- package/stories/List/List.stories.jsx +1 -1
- package/stories/Modal/Modal.stories.jsx +1 -1
- package/stories/Notification/Notification.stories.jsx +1 -1
- package/stories/Pagination/Pagination.stories.jsx +1 -1
- package/stories/Progress/Progress.stories.jsx +1 -1
- package/stories/Radio/Radio.stories.jsx +1 -1
- package/stories/RadioCard/RadioCard.stories.jsx +1 -1
- package/stories/Search/Search.stories.jsx +1 -1
- package/stories/Select/Select.stories.jsx +1 -1
- package/stories/SideNav/SideNav.stories.jsx +1 -1
- package/stories/SideNav/SideNavItem.stories.jsx +1 -1
- package/stories/SideNav/SideNavItemsGroup.stories.jsx +1 -1
- package/stories/Skeleton/Skeleton.stories.jsx +2 -2
- package/stories/Spacer/Spacer.stories.jsx +1 -1
- package/stories/StackView/StackView.stories.jsx +1 -1
- package/stories/StackView/StackWrap.stories.jsx +1 -1
- package/stories/StepTracker/StepTracker.stories.jsx +1 -1
- package/stories/Tabs/Tabs.stories.jsx +1 -1
- package/stories/Tags/Tags.stories.jsx +1 -1
- package/stories/TextInput/TextArea.stories.jsx +1 -1
- package/stories/TextInput/TextInput.stories.jsx +1 -1
- package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +1 -1
- package/stories/Tooltip/Tooltip.stories.jsx +1 -1
- package/stories/TooltipButton/TooltipButton.stories.jsx +1 -1
- package/stories/Typography/Typography.stories.jsx +1 -1
- package/stories/platform-supports.jsx +1 -1
- package/stories/supports.jsx +2 -2
- package/src/Tabs/HorizontalScroll.jsx +0 -165
- package/src/Tabs/TabsScrollButton.jsx +0 -100
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
|
package/lib/Search/Search.js
CHANGED
|
@@ -87,7 +87,7 @@ const selectIconTokens = ({
|
|
|
87
87
|
*/
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
const Search = ({
|
|
90
|
+
const Search = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
91
91
|
initialValue = '',
|
|
92
92
|
placeholder = 'Search',
|
|
93
93
|
inactive,
|
|
@@ -98,7 +98,7 @@ const Search = ({
|
|
|
98
98
|
copy = 'en',
|
|
99
99
|
tokens,
|
|
100
100
|
variant
|
|
101
|
-
}) => {
|
|
101
|
+
}, ref) => {
|
|
102
102
|
const [value, setValue] = (0, _react.useState)(initialValue);
|
|
103
103
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Search', tokens, variant);
|
|
104
104
|
const buttonTokens = (0, _ThemeProvider.useThemeTokens)('SearchButton', tokens, variant);
|
|
@@ -118,26 +118,28 @@ const Search = ({
|
|
|
118
118
|
|
|
119
119
|
const buttonsGapSize = (0, _utils.useSpacingScale)(buttonsGap);
|
|
120
120
|
|
|
121
|
-
const handleSubmit =
|
|
121
|
+
const handleSubmit = event => {
|
|
122
122
|
if (onSubmit !== undefined) {
|
|
123
|
-
onSubmit(value);
|
|
123
|
+
onSubmit(value, event);
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
const handleChange = currentValue => {
|
|
128
|
-
setValue(currentValue);
|
|
129
|
-
if (onChange !== undefined) onChange(currentValue);
|
|
127
|
+
const handleChange = (currentValue, event) => {
|
|
128
|
+
setValue(currentValue, event);
|
|
129
|
+
if (onChange !== undefined) onChange(currentValue, event);
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
const handleClear =
|
|
133
|
-
setValue('');
|
|
134
|
-
if (onClear !== undefined) onClear();
|
|
135
|
-
if (onChange !== undefined) onChange('');
|
|
132
|
+
const handleClear = event => {
|
|
133
|
+
setValue('', event);
|
|
134
|
+
if (onClear !== undefined) onClear('', event);
|
|
135
|
+
if (onChange !== undefined) onChange('', event);
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
const isEmpty = value === '';
|
|
139
139
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
140
|
+
style: staticStyles.container,
|
|
140
141
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
142
|
+
ref: ref,
|
|
141
143
|
tokens: appearances => selectInputTokens({
|
|
142
144
|
searchTokens: getThemeTokens(appearances),
|
|
143
145
|
buttonTokens,
|
|
@@ -164,8 +166,7 @@ const Search = ({
|
|
|
164
166
|
accessibilityRole: "button",
|
|
165
167
|
accessibilityLabel: getCopy('clearButtonAccessibilityLabel'),
|
|
166
168
|
tokens: appearances => selectButtonTokens(getButtonTokens(appearances)),
|
|
167
|
-
children: buttonState => /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearButtonIcon, {
|
|
168
|
-
tokens: selectIconTokens(getButtonTokens(buttonState))
|
|
169
|
+
children: buttonState => /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearButtonIcon, { ...selectIconTokens(getButtonTokens(buttonState))
|
|
169
170
|
})
|
|
170
171
|
}), SubmitButtonIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
171
172
|
onPress: handleSubmit,
|
|
@@ -175,8 +176,7 @@ const Search = ({
|
|
|
175
176
|
tokens: buttonState => selectButtonTokens(getButtonTokens({ ...buttonState,
|
|
176
177
|
priority: 'high'
|
|
177
178
|
})),
|
|
178
|
-
children: buttonState => /*#__PURE__*/(0, _jsxRuntime.jsx)(SubmitButtonIcon, {
|
|
179
|
-
tokens: selectIconTokens(getButtonTokens({ ...buttonState,
|
|
179
|
+
children: buttonState => /*#__PURE__*/(0, _jsxRuntime.jsx)(SubmitButtonIcon, { ...selectIconTokens(getButtonTokens({ ...buttonState,
|
|
180
180
|
priority: 'high'
|
|
181
181
|
}))
|
|
182
182
|
})
|
|
@@ -184,8 +184,8 @@ const Search = ({
|
|
|
184
184
|
})
|
|
185
185
|
})]
|
|
186
186
|
});
|
|
187
|
-
};
|
|
188
|
-
|
|
187
|
+
});
|
|
188
|
+
Search.displayName = 'Search';
|
|
189
189
|
Search.propTypes = {
|
|
190
190
|
/**
|
|
191
191
|
* Use this to set the initial value of the search input.
|
|
@@ -225,7 +225,16 @@ Search.propTypes = {
|
|
|
225
225
|
* Use to provide an accessible label for the input (visually hidden).
|
|
226
226
|
*/
|
|
227
227
|
accessibilityLabel: _propTypes.default.string,
|
|
228
|
-
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Select english or french copy for the accessible labels.
|
|
231
|
+
* You may also pass in a custom dictionary object.
|
|
232
|
+
*/
|
|
233
|
+
copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), _propTypes.default.shape({
|
|
234
|
+
accessibilityLabel: _propTypes.default.string,
|
|
235
|
+
clearButtonAccessibilityLabel: _propTypes.default.string,
|
|
236
|
+
submitButtonAccessibilityLabel: _propTypes.default.string
|
|
237
|
+
})]),
|
|
229
238
|
tokens: (0, _utils.getTokensPropType)('Search'),
|
|
230
239
|
variant: _utils.variantProp.propType
|
|
231
240
|
};
|
|
@@ -233,6 +242,8 @@ var _default = Search;
|
|
|
233
242
|
exports.default = _default;
|
|
234
243
|
|
|
235
244
|
const staticStyles = _StyleSheet.default.create({
|
|
245
|
+
container: {// No styles needed here except the View defaults (position: relative etc)
|
|
246
|
+
},
|
|
236
247
|
iconsContainer: {
|
|
237
248
|
position: 'absolute',
|
|
238
249
|
right: 0,
|
package/lib/Select/Picker.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
|
|
|
@@ -15,7 +15,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
const Picker = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
19
23
|
value,
|
|
20
24
|
onChange,
|
|
21
25
|
onFocus,
|
|
@@ -29,13 +33,14 @@ const Picker = ({
|
|
|
29
33
|
nativeID,
|
|
30
34
|
testID,
|
|
31
35
|
...rest
|
|
32
|
-
}) => {
|
|
36
|
+
}, ref) => {
|
|
33
37
|
const {
|
|
34
38
|
accessibilityLabel,
|
|
35
39
|
accessibilityDescribedBy,
|
|
36
40
|
accessibilityInvalid
|
|
37
41
|
} = rest;
|
|
38
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
|
|
43
|
+
ref: ref,
|
|
39
44
|
style: style,
|
|
40
45
|
onMouseOver: onMouseOver,
|
|
41
46
|
onMouseOut: onMouseOut,
|
|
@@ -43,7 +48,7 @@ const Picker = ({
|
|
|
43
48
|
onBlur: onBlur,
|
|
44
49
|
disabled: inactive,
|
|
45
50
|
value: value || (placeholder !== undefined ? placeholder.value : undefined),
|
|
46
|
-
onChange: event => onChange(event.target.value),
|
|
51
|
+
onChange: event => onChange(event.target.value, event),
|
|
47
52
|
id: nativeID,
|
|
48
53
|
"aria-label": accessibilityLabel,
|
|
49
54
|
"aria-describedby": accessibilityDescribedBy,
|
|
@@ -56,8 +61,8 @@ const Picker = ({
|
|
|
56
61
|
children: placeholder.label
|
|
57
62
|
}), children]
|
|
58
63
|
});
|
|
59
|
-
};
|
|
60
|
-
|
|
64
|
+
});
|
|
65
|
+
Picker.displayName = 'Picker';
|
|
61
66
|
var _default = Picker;
|
|
62
67
|
exports.default = _default;
|
|
63
68
|
Picker.propTypes = {
|