@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
package/lib/Tags/Tags.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 _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
13
15
|
|
|
14
16
|
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
@@ -35,6 +37,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
35
37
|
|
|
36
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
39
|
|
|
40
|
+
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); }
|
|
41
|
+
|
|
42
|
+
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; }
|
|
43
|
+
|
|
38
44
|
const selectIconTextTokens = ({
|
|
39
45
|
icon,
|
|
40
46
|
iconPosition,
|
|
@@ -71,7 +77,7 @@ const selectIconTextTokens = ({
|
|
|
71
77
|
}
|
|
72
78
|
});
|
|
73
79
|
|
|
74
|
-
const Tags = ({
|
|
80
|
+
const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
75
81
|
variant,
|
|
76
82
|
tokens,
|
|
77
83
|
items = [],
|
|
@@ -86,7 +92,7 @@ const Tags = ({
|
|
|
86
92
|
default: 'none'
|
|
87
93
|
}),
|
|
88
94
|
...rest
|
|
89
|
-
}) => {
|
|
95
|
+
}, ref) => {
|
|
90
96
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
91
97
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Tags', tokens, variant, {
|
|
92
98
|
viewport
|
|
@@ -117,14 +123,17 @@ const Tags = ({
|
|
|
117
123
|
});
|
|
118
124
|
|
|
119
125
|
const itemA11yRole = 'checkbox';
|
|
120
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, {
|
|
126
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, {
|
|
127
|
+
ref: ref,
|
|
128
|
+
...a11y,
|
|
121
129
|
space: space,
|
|
122
130
|
direction: direction,
|
|
123
131
|
tokens: stackTokens,
|
|
124
132
|
children: items.map(({
|
|
125
133
|
label,
|
|
126
134
|
id = label,
|
|
127
|
-
accessibilityLabel
|
|
135
|
+
accessibilityLabel,
|
|
136
|
+
ref: itemRef
|
|
128
137
|
}, index) => {
|
|
129
138
|
const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
130
139
|
|
|
@@ -134,9 +143,9 @@ const Tags = ({
|
|
|
134
143
|
currentValues
|
|
135
144
|
}]);
|
|
136
145
|
|
|
137
|
-
const handlePress =
|
|
146
|
+
const handlePress = event => {
|
|
138
147
|
if (pressHandlers.onPress) pressHandlers.onPress();
|
|
139
|
-
toggleOneValue(id);
|
|
148
|
+
toggleOneValue(id, event);
|
|
140
149
|
};
|
|
141
150
|
|
|
142
151
|
const itemA11y = {
|
|
@@ -147,7 +156,9 @@ const Tags = ({
|
|
|
147
156
|
accessibilityLabel,
|
|
148
157
|
..._propTypes2.a11yProps.getPositionInSet(items.length, index)
|
|
149
158
|
};
|
|
150
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
159
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
160
|
+
ref: itemRef,
|
|
161
|
+
...pressHandlers,
|
|
151
162
|
onPress: handlePress,
|
|
152
163
|
tokens: getButtonTokens,
|
|
153
164
|
selected: isSelected,
|
|
@@ -189,8 +200,8 @@ const Tags = ({
|
|
|
189
200
|
}, id);
|
|
190
201
|
})
|
|
191
202
|
});
|
|
192
|
-
};
|
|
193
|
-
|
|
203
|
+
});
|
|
204
|
+
Tags.displayName = 'Tags';
|
|
194
205
|
Tags.propTypes = { ..._propTypes2.a11yProps.propTypes,
|
|
195
206
|
..._propTypes2.pressProps.propTypes,
|
|
196
207
|
tokens: (0, _propTypes2.getTokensPropType)('Tags'),
|
|
@@ -222,7 +233,12 @@ Tags.propTypes = { ..._propTypes2.a11yProps.propTypes,
|
|
|
222
233
|
* which will be used in code and passed to any onChange function.
|
|
223
234
|
* If not provided, the label is used.
|
|
224
235
|
*/
|
|
225
|
-
id: _propTypes.default.string
|
|
236
|
+
id: _propTypes.default.string,
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* An optional ref for one individual Tag button in the tags
|
|
240
|
+
*/
|
|
241
|
+
ref: _airbnbPropTypes.default.ref()
|
|
226
242
|
})),
|
|
227
243
|
|
|
228
244
|
/**
|
|
@@ -53,11 +53,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
53
53
|
* or an indicator that the field is optional.
|
|
54
54
|
* It is a more usable and accessible option than the HTML `placeholder` attribute.
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
const TextArea = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
57
57
|
tokens,
|
|
58
58
|
variant = {},
|
|
59
59
|
...remainingProps
|
|
60
|
-
}) {
|
|
60
|
+
}, ref) => {
|
|
61
61
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('TextArea', tokens, variant);
|
|
62
62
|
const [inputHeight, setInputHeight] = (0, _react.useState)(); // adjust the text area's height as new lines are added to the content
|
|
63
63
|
|
|
@@ -92,13 +92,15 @@ function TextArea({
|
|
|
92
92
|
children: ({
|
|
93
93
|
a11yProps,
|
|
94
94
|
inputId
|
|
95
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
95
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
96
|
+
ref: ref,
|
|
97
|
+
...inputProps,
|
|
96
98
|
...a11yProps,
|
|
97
99
|
nativeID: inputId
|
|
98
100
|
})
|
|
99
101
|
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
+
});
|
|
103
|
+
TextArea.displayName = 'TextArea';
|
|
102
104
|
TextArea.propTypes = { ..._propTypes.default.types,
|
|
103
105
|
..._propTypes2.default,
|
|
104
106
|
tokens: (0, _utils.getTokensPropType)('TextArea', 'TextInput'),
|
|
@@ -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 _utils = require("../utils");
|
|
11
11
|
|
|
@@ -21,6 +21,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
24
28
|
/**
|
|
25
29
|
* A basic text input component. Use in forms or individually to receive user's input.
|
|
26
30
|
* Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
|
|
@@ -39,11 +43,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
39
43
|
* supported props and <a href="https://reactnative.dev/docs/textinput" target="_blank">React Native Web documentation</a> for
|
|
40
44
|
* their implementation on the web.
|
|
41
45
|
*/
|
|
42
|
-
|
|
46
|
+
const TextInput = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
43
47
|
tokens,
|
|
44
48
|
variant = {},
|
|
45
49
|
...remainingProps
|
|
46
|
-
}) {
|
|
50
|
+
}, ref) => {
|
|
47
51
|
const {
|
|
48
52
|
props: supportsProps,
|
|
49
53
|
rest
|
|
@@ -59,13 +63,15 @@ function TextInput({
|
|
|
59
63
|
children: ({
|
|
60
64
|
a11yProps,
|
|
61
65
|
inputId
|
|
62
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
66
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
67
|
+
ref: ref,
|
|
68
|
+
...inputProps,
|
|
63
69
|
...a11yProps,
|
|
64
70
|
nativeID: inputId
|
|
65
71
|
})
|
|
66
72
|
});
|
|
67
|
-
}
|
|
68
|
-
|
|
73
|
+
});
|
|
74
|
+
TextInput.displayName = 'TextInput';
|
|
69
75
|
TextInput.propTypes = { ..._propTypes.default.types,
|
|
70
76
|
..._propTypes2.default,
|
|
71
77
|
tokens: (0, _utils.getTokensPropType)('TextInput'),
|
|
@@ -130,7 +130,7 @@ const selectIconContainerStyles = ({
|
|
|
130
130
|
paddingBottom
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
134
134
|
value,
|
|
135
135
|
height,
|
|
136
136
|
initialValue,
|
|
@@ -145,7 +145,7 @@ function TextInputBase({
|
|
|
145
145
|
tokens,
|
|
146
146
|
variant = {},
|
|
147
147
|
...remainingProps
|
|
148
|
-
}) {
|
|
148
|
+
}, ref) => {
|
|
149
149
|
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
150
150
|
|
|
151
151
|
const handleFocus = event => {
|
|
@@ -181,9 +181,12 @@ function TextInputBase({
|
|
|
181
181
|
readOnly
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
const handleChangeText =
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
const handleChangeText = event => {
|
|
185
|
+
var _event$nativeEvent, _event$target;
|
|
186
|
+
|
|
187
|
+
const text = ((_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.text) || ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
|
|
188
|
+
setValue(text, event);
|
|
189
|
+
if (typeof onChangeText === 'function') onChangeText(text, event);
|
|
187
190
|
};
|
|
188
191
|
|
|
189
192
|
const states = {
|
|
@@ -201,7 +204,7 @@ function TextInputBase({
|
|
|
201
204
|
onBlur: handleBlur,
|
|
202
205
|
onMouseOver: handleMouseOver,
|
|
203
206
|
onMouseOut: handleMouseOut,
|
|
204
|
-
|
|
207
|
+
onChange: handleChangeText,
|
|
205
208
|
defaultValue: initialValue,
|
|
206
209
|
// currentValue is being updated even if the input is not controlled, passing it down to the
|
|
207
210
|
// Input could lead to changing its state from uncontrolled to controlled
|
|
@@ -213,6 +216,7 @@ function TextInputBase({
|
|
|
213
216
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
214
217
|
style: selectOuterBorderStyles(themeTokens),
|
|
215
218
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInput.default, {
|
|
219
|
+
ref: ref,
|
|
216
220
|
style: nativeInputStyle,
|
|
217
221
|
...inputProps
|
|
218
222
|
}), IconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
@@ -223,8 +227,8 @@ function TextInputBase({
|
|
|
223
227
|
})
|
|
224
228
|
})]
|
|
225
229
|
});
|
|
226
|
-
}
|
|
227
|
-
|
|
230
|
+
});
|
|
231
|
+
TextInputBase.displayName = 'TextInputBase';
|
|
228
232
|
TextInputBase.propTypes = {
|
|
229
233
|
value: _propTypes.default.string,
|
|
230
234
|
height: _propTypes.default.number,
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.
|
|
6
|
+
exports.default = exports.ThemeSetterContext = exports.ThemeContext = exports.uninitialisedError = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
|
|
12
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -21,18 +23,18 @@ const uninitialisedError = new Error('Theme context used outside of ThemeProvide
|
|
|
21
23
|
exports.uninitialisedError = uninitialisedError;
|
|
22
24
|
const ThemeContext = /*#__PURE__*/(0, _react.createContext)(uninitialisedError);
|
|
23
25
|
exports.ThemeContext = ThemeContext;
|
|
24
|
-
const ThemeSetterContext = /*#__PURE__*/(0, _react.createContext)(uninitialisedError);
|
|
25
|
-
// https://github.com/telus/universal-design-system/issues/92
|
|
26
|
-
|
|
26
|
+
const ThemeSetterContext = /*#__PURE__*/(0, _react.createContext)(uninitialisedError);
|
|
27
27
|
exports.ThemeSetterContext = ThemeSetterContext;
|
|
28
|
-
const themeType = _propTypes.default.object;
|
|
29
|
-
exports.themeType = themeType;
|
|
30
28
|
|
|
31
29
|
const ThemeProvider = ({
|
|
32
30
|
children,
|
|
33
31
|
defaultTheme
|
|
34
32
|
}) => {
|
|
35
|
-
const [theme, setTheme] = (0, _react.useState)(defaultTheme);
|
|
33
|
+
const [theme, setTheme] = (0, _react.useState)(defaultTheme); // Validate the theme tokens version on every render.
|
|
34
|
+
// This will intentionally break the application when attempting to use an invalid theme.
|
|
35
|
+
// This will surface an incompatibility quickly rather than allowing the potential for strange bugs due to missing or incompatible tokens.
|
|
36
|
+
|
|
37
|
+
(0, _utils.validateThemeTokensVersion)(theme);
|
|
36
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeSetterContext.Provider, {
|
|
37
39
|
value: setTheme,
|
|
38
40
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeContext.Provider, {
|
|
@@ -43,10 +45,12 @@ const ThemeProvider = ({
|
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
ThemeProvider.propTypes = {
|
|
46
|
-
// TODO: implement a custom propType that validates schema version
|
|
47
|
-
// https://github.com/telus/universal-design-system/issues/92
|
|
48
48
|
children: _propTypes.default.node.isRequired,
|
|
49
|
-
defaultTheme:
|
|
49
|
+
defaultTheme: _propTypes.default.shape({
|
|
50
|
+
metadata: _propTypes.default.shape({
|
|
51
|
+
themeTokensVersion: _propTypes.default.string.isRequired
|
|
52
|
+
}).isRequired
|
|
53
|
+
}).isRequired
|
|
50
54
|
};
|
|
51
55
|
var _default = ThemeProvider;
|
|
52
56
|
exports.default = _default;
|
|
@@ -11,7 +11,12 @@ var _ThemeProvider = require("./ThemeProvider");
|
|
|
11
11
|
|
|
12
12
|
const useSetTheme = () => {
|
|
13
13
|
// Replace current theme with provided object
|
|
14
|
-
const setTheme = (0, _react.useContext)(_ThemeProvider.ThemeSetterContext); //
|
|
14
|
+
const setTheme = (0, _react.useContext)(_ThemeProvider.ThemeSetterContext); // Fail fast if dev uses useSetTheme outside of ThemeProvider
|
|
15
|
+
|
|
16
|
+
if (setTheme instanceof Error) {
|
|
17
|
+
throw setTheme;
|
|
18
|
+
} // Merge provided object into current theme
|
|
19
|
+
|
|
15
20
|
|
|
16
21
|
const editTheme = (0, _react.useCallback)(newTheme => setTheme((oldTheme = {}) => ({ ...oldTheme,
|
|
17
22
|
...newTheme
|
|
@@ -50,7 +50,7 @@ function applyTextStyles({
|
|
|
50
50
|
if (fontName) {
|
|
51
51
|
// Don't set undefined font families. May need some validation here that the font is available.
|
|
52
52
|
// Android doesn't recognise font weights natively so apply custom font weights via `fontFamily`.
|
|
53
|
-
styles.fontFamily =
|
|
53
|
+
styles.fontFamily = `${fontName}${fontWeight}${fontStyle}`;
|
|
54
54
|
} else if (fontWeight) {
|
|
55
55
|
// If using system default font, apply the font weight directly.
|
|
56
56
|
// Font weight support in Android is limited to 'bold' or anything else === 'normal'.
|
|
@@ -99,7 +99,7 @@ function applyWebShadow({
|
|
|
99
99
|
}) {
|
|
100
100
|
const insetString = inset ? 'inset ' : '';
|
|
101
101
|
const boxShadow = {
|
|
102
|
-
boxShadow:
|
|
102
|
+
boxShadow: `${insetString}${offsetX}px ${offsetY}px ${blur}px ${spread}px ${color}`
|
|
103
103
|
};
|
|
104
104
|
return boxShadow;
|
|
105
105
|
}
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.toArray = exports.getThemeTokens = exports.mergeAppearances = exports.validateThemeTokens = exports.resolveThemeTokens = exports.doesThemeRuleApply = exports.doesThemeConditionApply = exports.getComponentTheme = void 0;
|
|
6
|
+
exports.validateThemeTokensVersion = exports.toArray = exports.getThemeTokens = exports.mergeAppearances = exports.validateThemeTokens = exports.resolveThemeTokens = exports.doesThemeRuleApply = exports.doesThemeConditionApply = exports.getComponentTheme = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _satisfies = _interopRequireDefault(require("semver/functions/satisfies"));
|
|
11
|
+
|
|
12
|
+
var _package = _interopRequireDefault(require("../../../package.json"));
|
|
13
|
+
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -24,19 +28,19 @@ const getComponentTheme = (theme, componentName) => {
|
|
|
24
28
|
// Give clear and understandable error messages for common dev errors, for example,
|
|
25
29
|
// typo in component name, missing export or accessing old version of theme
|
|
26
30
|
if (!theme) {
|
|
27
|
-
throw new Error(
|
|
31
|
+
throw new Error(`Called useTheme's getStyle on "${componentName}" with no theme provided`);
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
const themeName = ((_theme$metadata = theme.metadata) === null || _theme$metadata === void 0 ? void 0 : _theme$metadata.name) || '';
|
|
31
35
|
|
|
32
36
|
if (!theme.components) {
|
|
33
|
-
throw new Error(
|
|
37
|
+
throw new Error(`Theme "${themeName}" has no components defined (looking for "${componentName}")`);
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
const componentTheme = theme.components[componentName];
|
|
37
41
|
|
|
38
42
|
if (!componentTheme) {
|
|
39
|
-
throw new Error(
|
|
43
|
+
throw new Error(`Theme "${themeName}" does not have styles for component "${componentName}"`);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
return componentTheme;
|
|
@@ -45,10 +49,8 @@ const getComponentTheme = (theme, componentName) => {
|
|
|
45
49
|
exports.getComponentTheme = getComponentTheme;
|
|
46
50
|
|
|
47
51
|
const doesThemeConditionApply = ([key, value], appearances) => {
|
|
48
|
-
var _appearances$key;
|
|
49
|
-
|
|
50
52
|
// use null rather than undefined so we can serialise the value in themes
|
|
51
|
-
const appearanceValue =
|
|
53
|
+
const appearanceValue = appearances[key] ?? null;
|
|
52
54
|
return Array.isArray(value) ? value.includes(appearanceValue) : value === appearanceValue;
|
|
53
55
|
};
|
|
54
56
|
|
|
@@ -154,5 +156,34 @@ const getThemeTokens = ({
|
|
|
154
156
|
exports.getThemeTokens = getThemeTokens;
|
|
155
157
|
|
|
156
158
|
const toArray = strOrArr => Array.isArray(strOrArr) ? strOrArr : [strOrArr];
|
|
159
|
+
/**
|
|
160
|
+
* Throws an error if the theme was built with an incompatible version of @telus-uds/system-theme-tokens
|
|
161
|
+
*
|
|
162
|
+
* This is used internally by the ThemeProvider to force a fast failure when an incompatible version is detected.
|
|
163
|
+
*
|
|
164
|
+
* Version compatibility is calculated with semver.satisfies.
|
|
165
|
+
* Refer to https://github.com/npm/node-semver and https://semver.npmjs.com/ for details about how
|
|
166
|
+
* semver compatibility.
|
|
167
|
+
*
|
|
168
|
+
* @param {object} theme - UDS theme built for react-native
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
exports.toArray = toArray;
|
|
173
|
+
|
|
174
|
+
const validateThemeTokensVersion = theme => {
|
|
175
|
+
var _theme$metadata2;
|
|
176
|
+
|
|
177
|
+
const expectedThemeTokensVersion = _package.default.dependencies['@telus-uds/system-theme-tokens'];
|
|
178
|
+
const actualThemeTokensVersion = theme === null || theme === void 0 ? void 0 : (_theme$metadata2 = theme.metadata) === null || _theme$metadata2 === void 0 ? void 0 : _theme$metadata2.themeTokensVersion;
|
|
179
|
+
|
|
180
|
+
if (!(0, _satisfies.default)(actualThemeTokensVersion, expectedThemeTokensVersion)) {
|
|
181
|
+
throw new Error(`Invalid UDS token schema version detected.
|
|
182
|
+
|
|
183
|
+
The UDS base components ${_package.default.name} v${_package.default.version} are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ${expectedThemeTokensVersion}. The current theme was built with @telus-uds/system-theme-tokens v${actualThemeTokensVersion}.
|
|
184
|
+
|
|
185
|
+
If you see this error than most likely you have attempted to install ${_package.default.name} and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/packages/docs-uds/docs/multi-brand-usage.md`);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
157
188
|
|
|
158
|
-
exports.
|
|
189
|
+
exports.validateThemeTokensVersion = validateThemeTokensVersion;
|
|
@@ -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,6 +27,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
27
27
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
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
|
+
|
|
30
34
|
const selectButtonTokens = tokens => (0, _propTypes2.selectTokens)('Button', { ...tokens,
|
|
31
35
|
// Width tokens are applied to our inner track. Disable Button width token so it wraps our track width.
|
|
32
36
|
width: null
|
|
@@ -76,7 +80,7 @@ const selectSwitchStyles = ({
|
|
|
76
80
|
})
|
|
77
81
|
});
|
|
78
82
|
|
|
79
|
-
const ToggleSwitch = ({
|
|
83
|
+
const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
80
84
|
value,
|
|
81
85
|
initialValue,
|
|
82
86
|
onChange,
|
|
@@ -84,7 +88,7 @@ const ToggleSwitch = ({
|
|
|
84
88
|
tokens,
|
|
85
89
|
variant,
|
|
86
90
|
accessibilityRole = 'switch'
|
|
87
|
-
}) => {
|
|
91
|
+
}, ref) => {
|
|
88
92
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ToggleSwitch', tokens, variant);
|
|
89
93
|
const {
|
|
90
94
|
currentValue,
|
|
@@ -95,11 +99,12 @@ const ToggleSwitch = ({
|
|
|
95
99
|
onChange
|
|
96
100
|
});
|
|
97
101
|
|
|
98
|
-
const handlePress =
|
|
102
|
+
const handlePress = event => setValue(!currentValue, event);
|
|
99
103
|
|
|
100
104
|
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
|
|
101
105
|
|
|
102
106
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
107
|
+
ref: ref,
|
|
103
108
|
selected: currentValue,
|
|
104
109
|
inactive: inactive,
|
|
105
110
|
tokens: getButtonTokens,
|
|
@@ -134,8 +139,8 @@ const ToggleSwitch = ({
|
|
|
134
139
|
});
|
|
135
140
|
}
|
|
136
141
|
});
|
|
137
|
-
};
|
|
138
|
-
|
|
142
|
+
});
|
|
143
|
+
ToggleSwitch.displayName = 'ToggleSwitch';
|
|
139
144
|
ToggleSwitch.propTypes = { ..._propTypes2.a11yProps.propTypes,
|
|
140
145
|
..._propTypes2.pressProps.propTypes,
|
|
141
146
|
tokens: (0, _propTypes2.getTokensPropType)('ToggleSwitch'),
|
package/lib/Tooltip/Backdrop.js
CHANGED
|
@@ -19,7 +19,15 @@ function createPortalNode(nodeId) {
|
|
|
19
19
|
// this way the backdrop stays in place when scrolling the window - that's why we need to
|
|
20
20
|
// position it at the scroll position when rendering
|
|
21
21
|
|
|
22
|
-
node.style.cssText =
|
|
22
|
+
node.style.cssText = `
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: ${window.scrollY}px;
|
|
25
|
+
left: ${window.scrollX}px;
|
|
26
|
+
right: 0;
|
|
27
|
+
bottom: 0;
|
|
28
|
+
z-index: 9999;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
`;
|
|
23
31
|
document.body.appendChild(node);
|
|
24
32
|
return node;
|
|
25
33
|
}
|
|
@@ -39,7 +47,7 @@ function Backdrop({
|
|
|
39
47
|
}) {
|
|
40
48
|
const [portalNode, setPortalNode] = (0, _react.useState)();
|
|
41
49
|
(0, _react.useEffect)(() => {
|
|
42
|
-
const nodeId =
|
|
50
|
+
const nodeId = `tooltip-backdrop-${Date.now()}`;
|
|
43
51
|
const node = createPortalNode(nodeId);
|
|
44
52
|
setPortalNode(node);
|
|
45
53
|
return () => {
|
package/lib/Tooltip/Tooltip.js
CHANGED
|
@@ -161,14 +161,14 @@ const defaultControl = (pressableState, variant) => /*#__PURE__*/(0, _jsxRuntime
|
|
|
161
161
|
*/
|
|
162
162
|
|
|
163
163
|
|
|
164
|
-
const Tooltip = ({
|
|
164
|
+
const Tooltip = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
165
165
|
children,
|
|
166
166
|
content,
|
|
167
167
|
position = 'auto',
|
|
168
168
|
copy = 'en',
|
|
169
169
|
tokens,
|
|
170
170
|
variant
|
|
171
|
-
}) => {
|
|
171
|
+
}, ref) => {
|
|
172
172
|
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
173
173
|
const controlRef = (0, _react.useRef)();
|
|
174
174
|
const [controlLayout, setControlLayout] = (0, _react.useState)(null);
|
|
@@ -292,6 +292,7 @@ const Tooltip = ({
|
|
|
292
292
|
}), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Backdrop.default, {
|
|
293
293
|
onPress: close,
|
|
294
294
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
295
|
+
ref: ref,
|
|
295
296
|
style: [staticStyles.tooltip, selectTooltipShadowStyles(themeTokens), // applied separately so that it doesn't cover the arrow
|
|
296
297
|
tooltipPosition && selectTooltipPositionStyles(tooltipPosition), (tooltipPosition === null || (tooltipPosition === null || tooltipPosition === void 0 ? void 0 : tooltipPosition.isNormalized)) && staticStyles.tooltipHidden // visually hide the tooltip until we have a final measurement
|
|
297
298
|
],
|
|
@@ -309,8 +310,8 @@ const Tooltip = ({
|
|
|
309
310
|
})
|
|
310
311
|
})]
|
|
311
312
|
});
|
|
312
|
-
};
|
|
313
|
-
|
|
313
|
+
});
|
|
314
|
+
Tooltip.displayName = 'Tooltip';
|
|
314
315
|
Tooltip.propTypes = {
|
|
315
316
|
/**
|
|
316
317
|
* Used to render the control (i.e. tooltip trigger). If a render function is used it will receive the
|