@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
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const schema = require('@telus-uds/system-theme-tokens')
|
|
3
|
+
const allExports = require('./src')
|
|
4
|
+
|
|
5
|
+
const { a11yProps } = allExports
|
|
6
|
+
const a11yPropTypes = Object.keys(a11yProps.types)
|
|
7
|
+
|
|
8
|
+
const parseComponentDocs = (name, generated) => {
|
|
9
|
+
const { description } = generated // TODO parse markdown and split by heading
|
|
10
|
+
const props = {} // store derived prop data
|
|
11
|
+
const attributes = {
|
|
12
|
+
// any other computed attributes
|
|
13
|
+
acceptsRNA11yProps: a11yPropTypes.every((key) => key in generated.props)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Object.entries(generated.props).forEach(([propName, prop]) => {
|
|
17
|
+
if (prop.description?.includes('@ignore')) {
|
|
18
|
+
return // remove ignored props
|
|
19
|
+
}
|
|
20
|
+
if (attributes.acceptsRNA11yProps && a11yPropTypes.includes(propName)) {
|
|
21
|
+
return // remove a11y props if all supported (there are 30+, instead we have the above attribute to show this)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const out = { ...prop }
|
|
25
|
+
|
|
26
|
+
// check if this prop references the tokens schema
|
|
27
|
+
const tokensProp = out.type?.raw?.match(/getTokensPropType\('([A-z]+)'\)/)?.[1]
|
|
28
|
+
if (tokensProp) {
|
|
29
|
+
if (!schema.components[tokensProp]) {
|
|
30
|
+
throw new Error(`Unknown schema component reference: ${tokensProp} from component: ${name}`)
|
|
31
|
+
}
|
|
32
|
+
out.type = { ...out.type, raw: schema.components[tokensProp] }
|
|
33
|
+
}
|
|
34
|
+
props[propName] = out
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return { docs: { description, props, attributes } }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const components = {}
|
|
41
|
+
|
|
42
|
+
Object.entries(allExports).forEach(([name, exp]) => {
|
|
43
|
+
if (exp.__docgenInfo) {
|
|
44
|
+
// populated by babel-plugin-react-docgen
|
|
45
|
+
components[name] = parseComponentDocs(name, exp.__docgenInfo)
|
|
46
|
+
|
|
47
|
+
// check for second-level components e.g List.Item (can only be on a component)
|
|
48
|
+
Object.entries(exp).forEach(([subComponentName, prop]) => {
|
|
49
|
+
if (prop.__docgenInfo) {
|
|
50
|
+
components[name][subComponentName] = parseComponentDocs(subComponentName, prop.__docgenInfo)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}, {})
|
|
55
|
+
|
|
56
|
+
fs.writeFileSync('./component-docs.json', JSON.stringify({ schema, components }, null, 2))
|
package/lib/A11yText/index.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 _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
11
|
|
|
@@ -21,17 +21,21 @@ 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
|
* A11yText is a zero-size invisible element that adds text to be read by screen readers.
|
|
26
30
|
*
|
|
27
31
|
* It should be used to add selectable screen-reader-only text to the main document flow,
|
|
28
32
|
* as a sibling to blocks of text like paragraphs and interactive elements like buttons.
|
|
29
33
|
*/
|
|
30
|
-
const A11yText = ({
|
|
34
|
+
const A11yText = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
31
35
|
text,
|
|
32
36
|
heading,
|
|
33
37
|
...rest
|
|
34
|
-
}) => {
|
|
38
|
+
}, ref) => {
|
|
35
39
|
const a11y = _propTypes2.a11yProps.select({
|
|
36
40
|
// On iOS, needs `accessible` to be true to be focusable without non-a11y content.
|
|
37
41
|
// On Web, `accessible` causes RNW to set attributes that may make the element be treated as a group.
|
|
@@ -45,10 +49,11 @@ const A11yText = ({
|
|
|
45
49
|
|
|
46
50
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
47
51
|
style: styles.invisible,
|
|
52
|
+
ref: ref,
|
|
48
53
|
...a11y
|
|
49
54
|
});
|
|
50
|
-
};
|
|
51
|
-
|
|
55
|
+
});
|
|
56
|
+
A11yText.displayName = 'A11yText';
|
|
52
57
|
A11yText.propTypes = {
|
|
53
58
|
text: _propTypes.default.string.isRequired,
|
|
54
59
|
heading: _propTypes.default.bool
|
|
@@ -5,13 +5,15 @@ 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 _shared = require("./shared");
|
|
11
11
|
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
|
|
14
|
-
function
|
|
14
|
+
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); }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
15
17
|
|
|
16
18
|
const SVG_RADIUS = 20;
|
|
17
19
|
const SVG_CIRCUMFERENCE = SVG_RADIUS * 2 * Math.PI;
|
|
@@ -19,25 +21,26 @@ const MIN_SVG_LENGTH = _shared.MIN_STROKE_ANGLE / 360 * SVG_CIRCUMFERENCE;
|
|
|
19
21
|
const MAX_SVG_LENGTH = (1 - _shared.MIN_EMPTY_ANGLE / 360) * SVG_CIRCUMFERENCE;
|
|
20
22
|
const animationProps = {
|
|
21
23
|
begin: '0s',
|
|
22
|
-
dur:
|
|
24
|
+
dur: `${_shared.DURATION}ms`,
|
|
23
25
|
fill: 'freeze',
|
|
24
26
|
repeatCount: 'indefinite'
|
|
25
27
|
};
|
|
26
28
|
const bezierProps = {
|
|
27
29
|
calcMode: 'spline',
|
|
28
30
|
keyTimes: '0; 0.5; 1',
|
|
29
|
-
keySplines:
|
|
31
|
+
keySplines: `${_shared.BEZIER.join(', ')} ; ${_shared.BEZIER.join(', ')}`
|
|
30
32
|
}; // We're using svg rather than css here to define the animation to avoid needing to introduce css injection mechanism
|
|
31
33
|
// It's possible to replicate this functionality with RNW animations, but it snags on chrome at least, see https://github.com/telus/universal-design-system/pull/477 for details.
|
|
32
34
|
|
|
33
|
-
const Spinner = ({
|
|
35
|
+
const Spinner = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
34
36
|
size,
|
|
35
37
|
color,
|
|
36
38
|
thickness,
|
|
37
39
|
label
|
|
38
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
}, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
41
|
+
ref: ref,
|
|
42
|
+
width: `${size}px`,
|
|
43
|
+
height: `${size}px`,
|
|
41
44
|
viewBox: "0 0 48 48",
|
|
42
45
|
"aria-valuetext": label,
|
|
43
46
|
role: "progressbar",
|
|
@@ -46,7 +49,7 @@ const Spinner = ({
|
|
|
46
49
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("animateTransform", {
|
|
47
50
|
attributeName: "transform",
|
|
48
51
|
type: "rotate",
|
|
49
|
-
values:
|
|
52
|
+
values: `-180 24 24;${360 + _shared.MIN_STROKE_ANGLE - 180} 24 24`,
|
|
50
53
|
...animationProps
|
|
51
54
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("circle", {
|
|
52
55
|
fill: "none",
|
|
@@ -60,19 +63,19 @@ const Spinner = ({
|
|
|
60
63
|
strokeDashoffset: 0,
|
|
61
64
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("animate", {
|
|
62
65
|
attributeName: "stroke-dashoffset",
|
|
63
|
-
values:
|
|
66
|
+
values: `0;-10;${MIN_SVG_LENGTH - SVG_CIRCUMFERENCE}`,
|
|
64
67
|
...animationProps,
|
|
65
68
|
...bezierProps
|
|
66
69
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("animate", {
|
|
67
70
|
attributeName: "stroke-dasharray",
|
|
68
|
-
values:
|
|
71
|
+
values: `${MIN_SVG_LENGTH}, 200;${MAX_SVG_LENGTH}, 200;${MIN_SVG_LENGTH}, 200`,
|
|
69
72
|
...animationProps,
|
|
70
73
|
...bezierProps
|
|
71
74
|
})]
|
|
72
75
|
})]
|
|
73
76
|
})
|
|
74
|
-
});
|
|
75
|
-
|
|
77
|
+
}));
|
|
78
|
+
Spinner.displayName = 'Spinner';
|
|
76
79
|
Spinner.propTypes = _shared.propTypes;
|
|
77
80
|
var _default = Spinner;
|
|
78
81
|
exports.default = _default;
|
|
@@ -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 _Animated = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Animated"));
|
|
11
11
|
|
|
@@ -21,15 +21,18 @@ 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
|
const ea = _shared.MIN_EMPTY_ANGLE / 2;
|
|
25
29
|
const sa = _shared.MIN_STROKE_ANGLE / 2;
|
|
26
|
-
|
|
27
|
-
const Spinner = ({
|
|
30
|
+
const Spinner = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
28
31
|
size,
|
|
29
32
|
color,
|
|
30
33
|
thickness,
|
|
31
34
|
label
|
|
32
|
-
}) => {
|
|
35
|
+
}, ref) => {
|
|
33
36
|
const {
|
|
34
37
|
current: timer
|
|
35
38
|
} = _react.default.useRef(new _Animated.default.Value(0));
|
|
@@ -58,6 +61,7 @@ const Spinner = ({
|
|
|
58
61
|
}; // Credit to https://github.com/n4kz/react-native-indicators and https://github.com/callstack/react-native-paper for this
|
|
59
62
|
|
|
60
63
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
64
|
+
ref: ref,
|
|
61
65
|
style: [styles.container],
|
|
62
66
|
accessible: true,
|
|
63
67
|
accessibilityLabel: label,
|
|
@@ -82,7 +86,7 @@ const Spinner = ({
|
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
const direction = index ? -1 : +1;
|
|
85
|
-
return
|
|
89
|
+
return `${direction * (180 - (sa + ea)) * easing(progress) + rotation}deg`;
|
|
86
90
|
});
|
|
87
91
|
const layerStyle = {
|
|
88
92
|
width: size,
|
|
@@ -90,7 +94,7 @@ const Spinner = ({
|
|
|
90
94
|
transform: [{
|
|
91
95
|
rotate: timer.interpolate({
|
|
92
96
|
inputRange: [0, 1],
|
|
93
|
-
outputRange: [
|
|
97
|
+
outputRange: [`${0 + ea + sa}deg`, `${2 * 360 + ea + sa}deg`]
|
|
94
98
|
})
|
|
95
99
|
}]
|
|
96
100
|
};
|
|
@@ -139,8 +143,8 @@ const Spinner = ({
|
|
|
139
143
|
})
|
|
140
144
|
})
|
|
141
145
|
});
|
|
142
|
-
};
|
|
143
|
-
|
|
146
|
+
});
|
|
147
|
+
Spinner.displayName = 'Spinner';
|
|
144
148
|
Spinner.propTypes = _shared.propTypes;
|
|
145
149
|
|
|
146
150
|
const styles = _StyleSheet.default.create({
|
package/lib/Box/Box.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
|
|
|
@@ -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
|
* @typedef {import('../utils/propTypes.js').SpacingValue} SpacingValue
|
|
26
30
|
* @typedef {import('../utils/propTypes.js').SpacingIndex} SpacingIndex
|
|
@@ -107,7 +111,7 @@ const selectBoxStyles = tokens => {
|
|
|
107
111
|
*/
|
|
108
112
|
|
|
109
113
|
|
|
110
|
-
const Box = ({
|
|
114
|
+
const Box = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
111
115
|
space,
|
|
112
116
|
horizontal = space,
|
|
113
117
|
vertical = space,
|
|
@@ -115,18 +119,24 @@ const Box = ({
|
|
|
115
119
|
bottom = vertical,
|
|
116
120
|
left = horizontal,
|
|
117
121
|
right = horizontal,
|
|
122
|
+
flex,
|
|
118
123
|
children,
|
|
119
124
|
variant,
|
|
120
125
|
tokens,
|
|
121
126
|
scroll,
|
|
127
|
+
tag,
|
|
128
|
+
accessibilityRole,
|
|
122
129
|
testID,
|
|
130
|
+
dataSet,
|
|
123
131
|
...rest
|
|
124
|
-
}) => {
|
|
125
|
-
const props = { ..._utils.
|
|
132
|
+
}, ref) => {
|
|
133
|
+
const props = { ...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
134
|
+
..._utils.a11yProps.select(rest),
|
|
126
135
|
..._utils.viewProps.select(rest)
|
|
127
136
|
};
|
|
128
137
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Box', tokens, variant);
|
|
129
138
|
const styles = {
|
|
139
|
+
flex,
|
|
130
140
|
paddingLeft: (0, _utils.useSpacingScale)(left),
|
|
131
141
|
paddingRight: (0, _utils.useSpacingScale)(right),
|
|
132
142
|
paddingTop: (0, _utils.useSpacingScale)(top),
|
|
@@ -140,6 +150,8 @@ const Box = ({
|
|
|
140
150
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollView.default, { ...scrollProps,
|
|
141
151
|
...props,
|
|
142
152
|
testID: testID,
|
|
153
|
+
dataSet: dataSet,
|
|
154
|
+
ref: ref,
|
|
143
155
|
children: children
|
|
144
156
|
});
|
|
145
157
|
}
|
|
@@ -147,22 +159,105 @@ const Box = ({
|
|
|
147
159
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, { ...props,
|
|
148
160
|
style: styles,
|
|
149
161
|
testID: testID,
|
|
162
|
+
dataSet: dataSet,
|
|
163
|
+
ref: ref,
|
|
150
164
|
children: children
|
|
151
165
|
});
|
|
152
|
-
};
|
|
166
|
+
});
|
|
167
|
+
Box.displayName = 'Box';
|
|
168
|
+
Box.propTypes = { ..._utils.a11yProps.propTypes,
|
|
169
|
+
..._utils.viewProps.types,
|
|
170
|
+
variant: _utils.variantProp.propType,
|
|
171
|
+
tokens: (0, _utils.getTokensPropType)('Box'),
|
|
153
172
|
|
|
154
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Sets default padding on all sides of the box using the theme's spacing scale.
|
|
175
|
+
*
|
|
176
|
+
* @see {@link SpacingValue}
|
|
177
|
+
*/
|
|
155
178
|
space: _utils.spacingProps.types.spacingValue,
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Sets top and bottom padding using the theme's spacing scale.
|
|
182
|
+
*
|
|
183
|
+
* @see {@link SpacingValue}
|
|
184
|
+
*/
|
|
156
185
|
vertical: _utils.spacingProps.types.spacingValue,
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Sets left and right padding using the theme's spacing scale.
|
|
189
|
+
*
|
|
190
|
+
* @see {@link SpacingValue}
|
|
191
|
+
*/
|
|
157
192
|
horizontal: _utils.spacingProps.types.spacingValue,
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Sets bottom padding using the theme's spacing scale.
|
|
196
|
+
*
|
|
197
|
+
* @see {@link SpacingValue}
|
|
198
|
+
*/
|
|
158
199
|
bottom: _utils.spacingProps.types.spacingValue,
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Sets left padding using the theme's spacing scale.
|
|
203
|
+
*
|
|
204
|
+
* @see {@link SpacingValue}
|
|
205
|
+
*/
|
|
159
206
|
left: _utils.spacingProps.types.spacingValue,
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Sets right padding using the theme's spacing scale.
|
|
210
|
+
*
|
|
211
|
+
* @see {@link SpacingValue}
|
|
212
|
+
*/
|
|
160
213
|
right: _utils.spacingProps.types.spacingValue,
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Sets top padding using the theme's spacing scale.
|
|
217
|
+
*
|
|
218
|
+
* @see {@link SpacingValue}
|
|
219
|
+
*/
|
|
161
220
|
top: _utils.spacingProps.types.spacingValue,
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Sets the `flex` style, which controls `flexGrow`, `flexShrink` and `flexBasis` styles.
|
|
224
|
+
*
|
|
225
|
+
* Set as 1 for the box to stretch and grow to fit in the available space, or another number to share
|
|
226
|
+
* space disproportionately with siblings. See https://reactnative.dev/docs/flexbox#flex for details.
|
|
227
|
+
*
|
|
228
|
+
* With the default `0`, the box takes its minimum width from its content.
|
|
229
|
+
*/
|
|
230
|
+
flex: _propTypes.default.number,
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Renders a scrollable ScrollView instead of an unscrollable View.
|
|
234
|
+
*
|
|
235
|
+
* May take an object of ScrollView props which are passed to the rendered ScrollView.
|
|
236
|
+
*/
|
|
162
237
|
scroll: _propTypes.default.oneOfType([_propTypes.default.bool, _ScrollView.default.propTypes ? _propTypes.default.shape(_ScrollView.default.propTypes) : _propTypes.default.object]),
|
|
163
|
-
|
|
164
|
-
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Optional semantic HTML tag, to apply to the container on web. Does not change styling.
|
|
241
|
+
*
|
|
242
|
+
* In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop
|
|
243
|
+
* is not defined, the accessibilityRole will default to "heading".
|
|
244
|
+
*/
|
|
245
|
+
tag: _propTypes.default.oneOf(_utils.layoutTags),
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Use in tests if the box itself needs to be targetted and no other way of selecting the
|
|
249
|
+
* box is available (e.g. it cannot be targetted using an appropriate `accessibilityRole`).
|
|
250
|
+
*/
|
|
165
251
|
testID: _propTypes.default.string,
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @ignore
|
|
255
|
+
*/
|
|
256
|
+
dataSet: _propTypes.default.object,
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Box accepts any content as children.
|
|
260
|
+
*/
|
|
166
261
|
children: _propTypes.default.node.isRequired
|
|
167
262
|
};
|
|
168
263
|
var _default = Box;
|
package/lib/Button/Button.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 _ButtonBase = _interopRequireDefault(require("./ButtonBase"));
|
|
11
11
|
|
|
@@ -17,25 +17,26 @@ var _propTypes2 = require("../utils/propTypes");
|
|
|
17
17
|
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
20
22
|
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); }
|
|
21
23
|
|
|
22
24
|
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
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const Button = ({
|
|
26
|
+
const Button = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
27
27
|
accessibilityRole = 'button',
|
|
28
28
|
tokens,
|
|
29
29
|
variant,
|
|
30
30
|
...props
|
|
31
|
-
}) => {
|
|
31
|
+
}, ref) => {
|
|
32
32
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('Button', tokens, variant);
|
|
33
33
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, { ...props,
|
|
34
34
|
tokens: getTokens,
|
|
35
|
-
accessibilityRole: accessibilityRole
|
|
35
|
+
accessibilityRole: accessibilityRole,
|
|
36
|
+
ref: ref
|
|
36
37
|
});
|
|
37
|
-
};
|
|
38
|
-
|
|
38
|
+
});
|
|
39
|
+
Button.displayName = 'Button';
|
|
39
40
|
Button.propTypes = { ..._propTypes2.a11yProps.types,
|
|
40
41
|
..._propTypes.default,
|
|
41
42
|
children: _propTypes.textAndA11yText
|
package/lib/Button/ButtonBase.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 _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
11
11
|
|
|
@@ -25,6 +25,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
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
|
+
|
|
28
32
|
const getOuterBorderOffset = ({
|
|
29
33
|
outerBorderGap = 0,
|
|
30
34
|
outerBorderWidth = 0
|
|
@@ -83,7 +87,7 @@ const selectOuterWidthStyles = ({
|
|
|
83
87
|
|
|
84
88
|
|
|
85
89
|
if (_Platform.default.OS === 'web') {
|
|
86
|
-
widthStyles.width =
|
|
90
|
+
widthStyles.width = `calc(${width} + ${outerBorderOffset * 2}px)`;
|
|
87
91
|
return widthStyles;
|
|
88
92
|
} // Can't use calc() on native but (unlike on web) flexGrow fills the container width here
|
|
89
93
|
|
|
@@ -156,7 +160,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, {
|
|
|
156
160
|
return _Platform.default.select({
|
|
157
161
|
web: {
|
|
158
162
|
// if it would overflow the container, wraps instead
|
|
159
|
-
maxWidth:
|
|
163
|
+
maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
|
|
160
164
|
outline: 'none',
|
|
161
165
|
// removes the default browser :focus outline
|
|
162
166
|
...(0, _utils2.getCursorStyle)(inactive, accessibilityRole)
|
|
@@ -165,7 +169,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, {
|
|
|
165
169
|
});
|
|
166
170
|
};
|
|
167
171
|
|
|
168
|
-
const ButtonBase = ({
|
|
172
|
+
const ButtonBase = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
169
173
|
href,
|
|
170
174
|
hrefAttrs,
|
|
171
175
|
children,
|
|
@@ -175,8 +179,9 @@ const ButtonBase = ({
|
|
|
175
179
|
// alias for inactive
|
|
176
180
|
inactive = disabled,
|
|
177
181
|
selected = false,
|
|
182
|
+
dataSet,
|
|
178
183
|
...rest
|
|
179
|
-
}) => {
|
|
184
|
+
}, ref) => {
|
|
180
185
|
const extraButtonState = {
|
|
181
186
|
inactive,
|
|
182
187
|
selected
|
|
@@ -192,6 +197,7 @@ const ButtonBase = ({
|
|
|
192
197
|
};
|
|
193
198
|
|
|
194
199
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
200
|
+
ref: ref,
|
|
195
201
|
href: href,
|
|
196
202
|
onPress: _utils2.linkProps.handleHref({
|
|
197
203
|
href,
|
|
@@ -199,6 +205,7 @@ const ButtonBase = ({
|
|
|
199
205
|
}),
|
|
200
206
|
style: getPressableStyle,
|
|
201
207
|
disabled: inactive,
|
|
208
|
+
dataSet: dataSet,
|
|
202
209
|
hrefAttrs: hrefAttrs,
|
|
203
210
|
...a11y,
|
|
204
211
|
children: pressableState => {
|
|
@@ -226,8 +233,8 @@ const ButtonBase = ({
|
|
|
226
233
|
});
|
|
227
234
|
}
|
|
228
235
|
});
|
|
229
|
-
};
|
|
230
|
-
|
|
236
|
+
});
|
|
237
|
+
ButtonBase.displayName = 'ButtonBase';
|
|
231
238
|
ButtonBase.propTypes = { ..._utils2.a11yProps.types,
|
|
232
239
|
..._propTypes.default,
|
|
233
240
|
..._utils2.linkProps.types
|
|
@@ -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 _ButtonBase = _interopRequireDefault(require("./ButtonBase"));
|
|
@@ -29,7 +31,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
29
31
|
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
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
|
+
|
|
36
|
+
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
|
+
|
|
38
|
+
const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
33
39
|
variant,
|
|
34
40
|
tokens,
|
|
35
41
|
items = [],
|
|
@@ -45,7 +51,7 @@ const ButtonGroup = ({
|
|
|
45
51
|
default: 'none'
|
|
46
52
|
}),
|
|
47
53
|
...rest
|
|
48
|
-
}) => {
|
|
54
|
+
}, ref) => {
|
|
49
55
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
50
56
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('ButtonGroup', tokens, variant, {
|
|
51
57
|
viewport
|
|
@@ -77,10 +83,12 @@ const ButtonGroup = ({
|
|
|
77
83
|
space: space,
|
|
78
84
|
direction: direction,
|
|
79
85
|
tokens: stackTokens,
|
|
86
|
+
ref: ref,
|
|
80
87
|
children: items.map(({
|
|
81
88
|
label,
|
|
82
89
|
id = label,
|
|
83
|
-
accessibilityLabel
|
|
90
|
+
accessibilityLabel,
|
|
91
|
+
ref: itemRef
|
|
84
92
|
}, index) => {
|
|
85
93
|
const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
86
94
|
|
|
@@ -90,9 +98,9 @@ const ButtonGroup = ({
|
|
|
90
98
|
currentValues
|
|
91
99
|
}]);
|
|
92
100
|
|
|
93
|
-
const handlePress =
|
|
101
|
+
const handlePress = event => {
|
|
94
102
|
if (pressHandlers.onPress) pressHandlers.onPress();
|
|
95
|
-
toggleOneValue(id);
|
|
103
|
+
toggleOneValue(id, event);
|
|
96
104
|
};
|
|
97
105
|
|
|
98
106
|
const itemA11y = {
|
|
@@ -105,7 +113,9 @@ const ButtonGroup = ({
|
|
|
105
113
|
}; // Ensure button is direct child of group as MacOS voiceover only applies "X of Y" to
|
|
106
114
|
// "radio" if it's a direct child of "radiogroup", even if aria-posinset etc exists
|
|
107
115
|
|
|
108
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
116
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
117
|
+
ref: itemRef,
|
|
118
|
+
...pressHandlers,
|
|
109
119
|
onPress: handlePress,
|
|
110
120
|
tokens: getButtonTokens,
|
|
111
121
|
selected: isSelected,
|
|
@@ -115,8 +125,8 @@ const ButtonGroup = ({
|
|
|
115
125
|
}, id);
|
|
116
126
|
})
|
|
117
127
|
});
|
|
118
|
-
};
|
|
119
|
-
|
|
128
|
+
});
|
|
129
|
+
ButtonGroup.displayName = 'ButtonGroup';
|
|
120
130
|
ButtonGroup.propTypes = { ..._propTypes2.a11yProps.propTypes,
|
|
121
131
|
..._propTypes2.pressProps.propTypes,
|
|
122
132
|
tokens: (0, _propTypes2.getTokensPropType)('ButtonGroup'),
|
|
@@ -149,7 +159,12 @@ ButtonGroup.propTypes = { ..._propTypes2.a11yProps.propTypes,
|
|
|
149
159
|
* which will be used in code and passed to any onChange function.
|
|
150
160
|
* If not provided, the label is used.
|
|
151
161
|
*/
|
|
152
|
-
id: _propTypes.default.string
|
|
162
|
+
id: _propTypes.default.string,
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* An optional ref for one individual button in the ButtonGroup
|
|
166
|
+
*/
|
|
167
|
+
ref: _airbnbPropTypes.default.ref()
|
|
153
168
|
})),
|
|
154
169
|
|
|
155
170
|
/**
|