@telus-uds/components-base 1.0.1 → 1.3.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/.storybook/main.js +4 -0
- package/.storybook/preview.js +37 -0
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +32 -0
- package/README.md +1 -1
- package/__fixtures__/Accessible.js +4 -2
- package/__fixtures__/Accessible.native.js +5 -2
- package/__fixtures__/testTheme.js +9 -0
- package/__tests__/FlexGrid/Col.test.jsx +6 -10
- package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
- package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
- package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
- package/__tests__/utils/props.test.js +36 -0
- package/__tests__/utils/semantics.test.jsx +1 -10
- package/babel.config.js +9 -16
- package/component-docs.json +10142 -0
- package/generate-component-docs.js +59 -0
- package/lib/A11yText/index.js +2 -2
- package/lib/ActivityIndicator/index.js +3 -3
- package/lib/Box/Box.js +4 -4
- package/lib/Button/Button.js +2 -2
- package/lib/Button/ButtonBase.js +20 -6
- package/lib/Button/ButtonGroup.js +10 -12
- package/lib/Button/ButtonLink.js +4 -4
- package/lib/Button/propTypes.js +4 -2
- package/lib/Card/Card.js +2 -2
- package/lib/Card/CardBase.js +6 -9
- package/lib/Card/PressableCardBase.js +12 -6
- package/lib/Checkbox/Checkbox.js +3 -5
- package/lib/Divider/Divider.js +2 -2
- package/lib/FlexGrid/FlexGrid.js +4 -4
- package/lib/FlexGrid/helpers/index.js +1 -4
- package/lib/IconButton/IconButton.js +11 -6
- package/lib/Link/LinkBase.js +19 -12
- package/lib/List/List.js +4 -5
- package/lib/List/ListItem.js +14 -27
- package/lib/List/index.js +15 -0
- package/lib/Pagination/PageButton.js +4 -8
- package/lib/Pagination/Pagination.js +16 -4
- package/lib/Pagination/SideButton.js +3 -1
- package/lib/Progress/Progress.js +2 -2
- package/lib/Progress/ProgressBar.js +2 -2
- package/lib/Radio/Radio.js +3 -5
- package/lib/Spacer/Spacer.js +2 -2
- package/lib/StackView/StackWrap.js +9 -5
- package/lib/StackView/getStackedContent.js +1 -1
- package/lib/StepTracker/StepTracker.js +2 -2
- package/lib/Tabs/Tabs.js +12 -4
- package/lib/Tabs/TabsItem.js +12 -6
- package/lib/Tags/Tags.js +9 -9
- package/lib/ThemeProvider/useThemeTokens.js +3 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +3 -3
- package/lib/ToggleSwitch/ToggleSwitch.js +105 -43
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +230 -0
- package/lib/ToggleSwitch/index.js +14 -4
- package/lib/index.js +28 -9
- package/lib/utils/a11y/semantics.js +4 -3
- package/lib/utils/index.js +14 -5
- package/lib/utils/pressability.js +2 -2
- package/lib/utils/props/a11yProps.js +153 -0
- package/lib/utils/props/clickProps.js +36 -0
- package/lib/utils/props/componentPropType.js +70 -0
- package/lib/utils/props/copyPropTypes.js +14 -0
- package/lib/utils/props/getPropSelector.js +13 -0
- package/lib/utils/props/hrefAttrsProp.js +41 -0
- package/lib/utils/props/index.js +149 -0
- package/lib/utils/props/linkProps.js +64 -0
- package/lib/utils/props/paddingProp.js +20 -0
- package/lib/utils/props/pressProps.js +57 -0
- package/lib/utils/props/rectProp.js +20 -0
- package/lib/utils/props/responsiveProps.js +40 -0
- package/lib/utils/props/selectSystemProps.js +31 -0
- package/lib/utils/props/spacingProps.js +71 -0
- package/lib/utils/props/tokens.js +145 -0
- package/lib/utils/props/variantProp.js +28 -0
- package/lib/utils/props/viewProps.js +34 -0
- package/lib/utils/useResponsiveProp.js +1 -1
- package/lib/utils/useSpacingScale.js +4 -4
- package/lib/utils/withLinkRouter.js +98 -0
- package/package.json +9 -5
- package/release-context.json +4 -4
- package/src/A11yText/index.jsx +1 -1
- package/src/ActivityIndicator/index.jsx +1 -1
- package/src/Box/Box.jsx +5 -4
- package/src/Button/Button.jsx +1 -1
- package/src/Button/ButtonBase.jsx +11 -4
- package/src/Button/ButtonGroup.jsx +17 -8
- package/src/Button/ButtonLink.jsx +1 -1
- package/src/Button/propTypes.js +2 -1
- package/src/Card/Card.jsx +1 -1
- package/src/Card/CardBase.jsx +6 -5
- package/src/Card/PressableCardBase.jsx +7 -5
- package/src/Checkbox/Checkbox.jsx +1 -3
- package/src/Divider/Divider.jsx +2 -2
- package/src/FlexGrid/FlexGrid.jsx +11 -5
- package/src/FlexGrid/helpers/index.js +1 -3
- package/src/IconButton/IconButton.jsx +7 -5
- package/src/Link/LinkBase.jsx +7 -5
- package/src/List/List.jsx +2 -4
- package/src/List/ListItem.jsx +11 -26
- package/src/List/index.js +5 -0
- package/src/Pagination/PageButton.jsx +5 -8
- package/src/Pagination/Pagination.jsx +29 -2
- package/src/Pagination/SideButton.jsx +2 -2
- package/src/Progress/Progress.jsx +1 -1
- package/src/Progress/ProgressBar.jsx +1 -1
- package/src/Radio/Radio.jsx +1 -3
- package/src/Spacer/Spacer.jsx +2 -2
- package/src/StackView/StackWrap.jsx +7 -6
- package/src/StackView/getStackedContent.jsx +1 -1
- package/src/StepTracker/StepTracker.jsx +1 -1
- package/src/Tabs/Tabs.jsx +49 -22
- package/src/Tabs/TabsItem.jsx +11 -7
- package/src/Tags/Tags.jsx +1 -7
- package/src/ThemeProvider/useThemeTokens.js +3 -3
- package/src/ThemeProvider/utils/theme-tokens.js +3 -3
- package/src/ToggleSwitch/ToggleSwitch.jsx +93 -41
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +203 -0
- package/src/ToggleSwitch/index.js +2 -1
- package/src/index.js +2 -2
- package/src/utils/a11y/semantics.js +3 -2
- package/src/utils/index.js +2 -1
- package/src/utils/pressability.js +1 -1
- package/src/utils/props/a11yProps.js +151 -0
- package/src/utils/props/clickProps.js +31 -0
- package/src/utils/props/componentPropType.js +67 -0
- package/src/utils/props/copyPropTypes.js +3 -0
- package/src/utils/props/getPropSelector.js +14 -0
- package/src/utils/props/hrefAttrsProp.js +25 -0
- package/src/utils/props/index.js +15 -0
- package/src/utils/props/linkProps.js +43 -0
- package/src/utils/props/paddingProp.js +10 -0
- package/src/utils/props/pressProps.js +45 -0
- package/src/utils/props/rectProp.js +10 -0
- package/src/utils/props/responsiveProps.js +30 -0
- package/src/utils/props/selectSystemProps.js +25 -0
- package/src/utils/props/spacingProps.js +58 -0
- package/src/utils/props/tokens.js +150 -0
- package/src/utils/props/variantProp.js +20 -0
- package/src/utils/props/viewProps.js +23 -0
- package/src/utils/useResponsiveProp.js +1 -1
- package/src/utils/useSpacingScale.js +4 -4
- package/src/utils/withLinkRouter.jsx +68 -0
- package/stories/A11yText/A11yText.stories.jsx +1 -1
- package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
- package/stories/Box/Box.stories.jsx +1 -1
- package/stories/Button/Button.stories.jsx +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +2 -1
- package/stories/TextInput/TextInput.stories.jsx +1 -1
- package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +6 -2
- package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
- 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/supports.jsx +2 -3
- package/.ultra.cache.json +0 -1
- package/lib/utils/propTypes.js +0 -623
- package/src/utils/propTypes.js +0 -640
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
import ButtonBase from './ButtonBase'
|
|
3
3
|
import buttonPropTypes, { textAndA11yText } from './propTypes'
|
|
4
|
-
import { a11yProps, hrefAttrsProp, linkProps } from '../utils/
|
|
4
|
+
import { a11yProps, hrefAttrsProp, linkProps } from '../utils/props'
|
|
5
5
|
import { useThemeTokensCallback } from '../ThemeProvider'
|
|
6
6
|
|
|
7
7
|
/**
|
package/src/Button/propTypes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
2
|
import ABBPropTypes from 'airbnb-prop-types'
|
|
3
|
-
import { variantProp } from '../utils/
|
|
3
|
+
import { variantProp, getTokensPropType } from '../utils/props'
|
|
4
4
|
import A11yText from '../A11yText'
|
|
5
5
|
|
|
6
6
|
export const textAndA11yText = ABBPropTypes.childrenOf(
|
|
@@ -8,6 +8,7 @@ export const textAndA11yText = ABBPropTypes.childrenOf(
|
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
const buttonPropTypes = {
|
|
11
|
+
tokens: getTokensPropType('Button'),
|
|
11
12
|
/**
|
|
12
13
|
* If true, prevents the button from being pressed, changes the cursor (on web) and accessibility
|
|
13
14
|
* attributes to communicate this to the user, and applies `inactive: true` appearances from the theme
|
package/src/Card/Card.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import { useThemeTokens } from '../ThemeProvider'
|
|
5
5
|
import { getTokensPropType, variantProp } from '../utils'
|
|
6
6
|
import { useViewport } from '../ViewportProvider'
|
|
7
|
-
import { a11yProps } from '../utils/
|
|
7
|
+
import { a11yProps } from '../utils/props'
|
|
8
8
|
import CardBase from './CardBase'
|
|
9
9
|
|
|
10
10
|
/**
|
package/src/Card/CardBase.jsx
CHANGED
|
@@ -4,7 +4,9 @@ import { View } from 'react-native'
|
|
|
4
4
|
|
|
5
5
|
import { applyShadowToken } from '../ThemeProvider'
|
|
6
6
|
import { getTokensPropType } from '../utils'
|
|
7
|
-
import { a11yProps, viewProps } from '../utils/
|
|
7
|
+
import { a11yProps, viewProps, selectSystemProps } from '../utils/props'
|
|
8
|
+
|
|
9
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
8
10
|
|
|
9
11
|
// Ensure explicit selection of tokens
|
|
10
12
|
const selectStyles = ({
|
|
@@ -39,7 +41,7 @@ const selectStyles = ({
|
|
|
39
41
|
*/
|
|
40
42
|
const CardBase = forwardRef(({ children, tokens, dataSet, ...rest }, ref) => {
|
|
41
43
|
const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens)
|
|
42
|
-
const props =
|
|
44
|
+
const props = selectProps(rest)
|
|
43
45
|
|
|
44
46
|
return (
|
|
45
47
|
<View style={cardStyle} dataSet={dataSet} ref={ref} {...props}>
|
|
@@ -50,10 +52,9 @@ const CardBase = forwardRef(({ children, tokens, dataSet, ...rest }, ref) => {
|
|
|
50
52
|
CardBase.displayName = 'CardBase'
|
|
51
53
|
|
|
52
54
|
CardBase.propTypes = {
|
|
55
|
+
...selectedSystemPropTypes,
|
|
53
56
|
children: PropTypes.node,
|
|
54
|
-
tokens: getTokensPropType('Card')
|
|
55
|
-
...viewProps.types,
|
|
56
|
-
...a11yProps.types
|
|
57
|
+
tokens: getTokensPropType('Card')
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export default CardBase
|
|
@@ -11,9 +11,11 @@ import {
|
|
|
11
11
|
getTokenNames,
|
|
12
12
|
getTokensSetPropType,
|
|
13
13
|
variantProp,
|
|
14
|
-
linkProps
|
|
14
|
+
linkProps,
|
|
15
|
+
clickProps,
|
|
16
|
+
withLinkRouter
|
|
15
17
|
} from '../utils'
|
|
16
|
-
import { a11yProps } from '../utils/
|
|
18
|
+
import { a11yProps } from '../utils/props'
|
|
17
19
|
import CardBase from './CardBase'
|
|
18
20
|
|
|
19
21
|
const tokenKeys = [
|
|
@@ -43,12 +45,12 @@ const PressableCardBase = forwardRef(
|
|
|
43
45
|
inactive,
|
|
44
46
|
href,
|
|
45
47
|
hrefAttrs,
|
|
46
|
-
onPress,
|
|
47
48
|
accessibilityRole = href ? 'link' : undefined,
|
|
48
|
-
...
|
|
49
|
+
...rawRest
|
|
49
50
|
},
|
|
50
51
|
ref
|
|
51
52
|
) => {
|
|
53
|
+
const { onPress, ...rest } = clickProps.toPressProps(rawRest)
|
|
52
54
|
const viewport = useViewport()
|
|
53
55
|
const a11y = a11yProps.select({
|
|
54
56
|
...rest,
|
|
@@ -116,4 +118,4 @@ PressableCardBase.propTypes = {
|
|
|
116
118
|
...a11yProps.types
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
export default PressableCardBase
|
|
121
|
+
export default withLinkRouter(PressableCardBase)
|
|
@@ -3,14 +3,12 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import { Platform, Pressable, StyleSheet, Text, View } from 'react-native'
|
|
4
4
|
|
|
5
5
|
import CheckboxInput from './CheckboxInput'
|
|
6
|
-
// @todo move `LabelContent` outside of the `InputLabel` and fix
|
|
7
|
-
// the issue with the cursor not being pointer on Web
|
|
8
6
|
import CheckboxLabel from '../InputLabel/LabelContent'
|
|
9
7
|
import Feedback from '../Feedback'
|
|
10
8
|
import StackView from '../StackView'
|
|
11
9
|
import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider'
|
|
12
10
|
import { getTokensPropType, useInputValue, variantProp } from '../utils'
|
|
13
|
-
import { a11yProps } from '../utils/
|
|
11
|
+
import { a11yProps } from '../utils/props'
|
|
14
12
|
import useUniqueId from '../utils/useUniqueId'
|
|
15
13
|
|
|
16
14
|
const selectInputStyles = (
|
package/src/Divider/Divider.jsx
CHANGED
|
@@ -5,8 +5,8 @@ import { useThemeTokens } from '../ThemeProvider'
|
|
|
5
5
|
import Spacer from '../Spacer'
|
|
6
6
|
import { getTokensPropType, variantProp, spacingProps } from '../utils'
|
|
7
7
|
/**
|
|
8
|
-
* @typedef {import('../utils/
|
|
9
|
-
* @typedef {import('../utils/
|
|
8
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingIndex} SpacingIndex
|
|
9
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -8,7 +8,15 @@ import Col from './Col'
|
|
|
8
8
|
import { useViewport } from '../ViewportProvider'
|
|
9
9
|
import GutterContext from './providers/GutterContext'
|
|
10
10
|
import applyInheritance from './helpers'
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
a11yProps,
|
|
13
|
+
viewProps,
|
|
14
|
+
getA11yPropsFromHtmlTag,
|
|
15
|
+
layoutTags,
|
|
16
|
+
selectSystemProps
|
|
17
|
+
} from '../utils'
|
|
18
|
+
|
|
19
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
12
20
|
|
|
13
21
|
/**
|
|
14
22
|
* A mobile-first flexbox grid.
|
|
@@ -62,8 +70,7 @@ const FlexGrid = forwardRef(
|
|
|
62
70
|
|
|
63
71
|
const props = {
|
|
64
72
|
...getA11yPropsFromHtmlTag(tag, accessibilityRole),
|
|
65
|
-
...
|
|
66
|
-
...viewProps.select(rest)
|
|
73
|
+
...selectProps(rest)
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
return (
|
|
@@ -91,8 +98,7 @@ const styles = StyleSheet.create({
|
|
|
91
98
|
})
|
|
92
99
|
|
|
93
100
|
FlexGrid.propTypes = {
|
|
94
|
-
...
|
|
95
|
-
...viewProps.types,
|
|
101
|
+
...selectedSystemPropTypes,
|
|
96
102
|
/**
|
|
97
103
|
* Whether or not to give the grid a fixed width. This also centres the grid horizontally.
|
|
98
104
|
*/
|
|
@@ -5,13 +5,15 @@ import { Pressable, Platform, StyleSheet, View } from 'react-native'
|
|
|
5
5
|
import { applyOuterBorder, useThemeTokensCallback, applyShadowToken } from '../ThemeProvider'
|
|
6
6
|
import {
|
|
7
7
|
variantProp,
|
|
8
|
+
clickProps,
|
|
8
9
|
linkProps,
|
|
9
10
|
resolvePressableState,
|
|
10
11
|
hrefAttrsProp,
|
|
11
12
|
getTokensPropType,
|
|
12
|
-
selectTokens
|
|
13
|
+
selectTokens,
|
|
14
|
+
withLinkRouter
|
|
13
15
|
} from '../utils'
|
|
14
|
-
import { a11yProps } from '../utils/
|
|
16
|
+
import { a11yProps } from '../utils/props'
|
|
15
17
|
import Icon from '../Icon'
|
|
16
18
|
|
|
17
19
|
const selectOuterStyle = ({
|
|
@@ -52,12 +54,12 @@ const IconButton = forwardRef(
|
|
|
52
54
|
icon: IconComponent,
|
|
53
55
|
href,
|
|
54
56
|
hrefAttrs,
|
|
55
|
-
onPress,
|
|
56
57
|
accessibilityRole = href ? 'link' : 'button',
|
|
57
|
-
...
|
|
58
|
+
...rawRest
|
|
58
59
|
},
|
|
59
60
|
ref
|
|
60
61
|
) => {
|
|
62
|
+
const { onPress, ...rest } = clickProps.toPressProps(rawRest)
|
|
61
63
|
const a11y = a11yProps.select({
|
|
62
64
|
...rest,
|
|
63
65
|
accessibilityRole
|
|
@@ -111,4 +113,4 @@ const staticStyles = StyleSheet.create({
|
|
|
111
113
|
}
|
|
112
114
|
})
|
|
113
115
|
|
|
114
|
-
export default IconButton
|
|
116
|
+
export default withLinkRouter(IconButton)
|
package/src/Link/LinkBase.jsx
CHANGED
|
@@ -6,9 +6,11 @@ import {
|
|
|
6
6
|
hrefAttrsProp,
|
|
7
7
|
variantProp,
|
|
8
8
|
linkProps,
|
|
9
|
-
getTokensPropType
|
|
10
|
-
|
|
9
|
+
getTokensPropType,
|
|
10
|
+
clickProps
|
|
11
|
+
} from '../utils/props'
|
|
11
12
|
import { resolvePressableTokens } from '../utils/pressability'
|
|
13
|
+
import { withLinkRouter } from '../utils'
|
|
12
14
|
|
|
13
15
|
import InlinePressable from './InlinePressable'
|
|
14
16
|
import { applyTextStyles, applyOuterBorder } from '../ThemeProvider'
|
|
@@ -92,7 +94,6 @@ const LinkBase = forwardRef(
|
|
|
92
94
|
(
|
|
93
95
|
{
|
|
94
96
|
href,
|
|
95
|
-
onPress,
|
|
96
97
|
icon,
|
|
97
98
|
iconPosition = icon ? 'left' : undefined,
|
|
98
99
|
iconProps,
|
|
@@ -101,10 +102,11 @@ const LinkBase = forwardRef(
|
|
|
101
102
|
children,
|
|
102
103
|
accessibilityRole = 'link',
|
|
103
104
|
dataSet,
|
|
104
|
-
...
|
|
105
|
+
...rawRest
|
|
105
106
|
},
|
|
106
107
|
ref
|
|
107
108
|
) => {
|
|
109
|
+
const { onPress, ...props } = clickProps.toPressProps(rawRest)
|
|
108
110
|
const { hrefAttrs, rest } = hrefAttrsProp.bundle(props)
|
|
109
111
|
const linkPropSet = linkProps.select({
|
|
110
112
|
accessibilityRole,
|
|
@@ -200,4 +202,4 @@ const staticStyles = StyleSheet.create({
|
|
|
200
202
|
}
|
|
201
203
|
})
|
|
202
204
|
|
|
203
|
-
export default LinkBase
|
|
205
|
+
export default withLinkRouter(LinkBase)
|
package/src/List/List.jsx
CHANGED
|
@@ -2,11 +2,11 @@ import React, { cloneElement, forwardRef, Children } from 'react'
|
|
|
2
2
|
import { View, Platform } from 'react-native'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import { getTokensPropType, variantProp, componentPropType } from '../utils'
|
|
5
|
-
import { a11yProps } from '../utils/
|
|
5
|
+
import { a11yProps } from '../utils/props'
|
|
6
6
|
import ListItem from './ListItem'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* An unordered List component has a child a ListItem that
|
|
10
10
|
* allows icon, dividers and customized typography
|
|
11
11
|
*/
|
|
12
12
|
const List = forwardRef(({ children, showDivider, tokens, variant, ...rest }, ref) => {
|
|
@@ -32,8 +32,6 @@ const List = forwardRef(({ children, showDivider, tokens, variant, ...rest }, re
|
|
|
32
32
|
})
|
|
33
33
|
List.displayName = 'List'
|
|
34
34
|
|
|
35
|
-
List.Item = ListItem
|
|
36
|
-
|
|
37
35
|
List.propTypes = {
|
|
38
36
|
...a11yProps.types,
|
|
39
37
|
tokens: getTokensPropType('List'),
|
package/src/List/ListItem.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
|
-
import { View, Platform,
|
|
2
|
+
import { View, Platform, StyleSheet } from 'react-native'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import { useThemeTokens, applyTextStyles } from '../ThemeProvider'
|
|
5
|
-
import { getTokensPropType, variantProp } from '../utils'
|
|
5
|
+
import { getTokensPropType, variantProp, wrapStringsInText } from '../utils'
|
|
6
6
|
|
|
7
7
|
const selectBulletStyles = ({ itemBulletWidth, itemBulletHeight, itemBulletColor }) => ({
|
|
8
8
|
width: itemBulletWidth,
|
|
@@ -22,6 +22,10 @@ const selectItemIconTokens = ({ itemIconSize, itemIconColor }) => ({
|
|
|
22
22
|
color: itemIconColor
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
+
const selectCommonIconStyles = ({ iconMarginTop }) => ({
|
|
26
|
+
marginTop: iconMarginTop
|
|
27
|
+
})
|
|
28
|
+
|
|
25
29
|
const selectSideItemContainerStyles = ({ listGutter }) => ({
|
|
26
30
|
marginRight: listGutter
|
|
27
31
|
})
|
|
@@ -58,24 +62,13 @@ const ListItem = forwardRef(
|
|
|
58
62
|
const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens)
|
|
59
63
|
const itemBulletStyles = selectBulletStyles(themeTokens)
|
|
60
64
|
const iconTokens = selectItemIconTokens(themeTokens)
|
|
65
|
+
const commonIconStyles = selectCommonIconStyles(themeTokens)
|
|
61
66
|
const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens)
|
|
62
67
|
const accessibilityRole = Platform.select({ web: 'listitem', default: 'item' })
|
|
63
68
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return typeof children === 'string'
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const renderItem = () => {
|
|
73
|
-
if (areChildrenStrings()) {
|
|
74
|
-
return <Text style={itemStyles}>{children}</Text>
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return <View style={staticStyles.wrap}>{children}</View>
|
|
78
|
-
}
|
|
69
|
+
const renderItem = () => (
|
|
70
|
+
<View style={staticStyles.wrap}>{wrapStringsInText(children, { style: itemStyles })}</View>
|
|
71
|
+
)
|
|
79
72
|
|
|
80
73
|
/**
|
|
81
74
|
* Function responsible returning styling, in case the item is the last shouldn't
|
|
@@ -104,12 +97,7 @@ const ListItem = forwardRef(
|
|
|
104
97
|
|
|
105
98
|
if (icon) {
|
|
106
99
|
return (
|
|
107
|
-
<View
|
|
108
|
-
style={[
|
|
109
|
-
sideItemContainerStyles,
|
|
110
|
-
areChildrenStrings() ? staticStyles.centeredIcons : undefined
|
|
111
|
-
]}
|
|
112
|
-
>
|
|
100
|
+
<View style={[sideItemContainerStyles, commonIconStyles]}>
|
|
113
101
|
<IconComponent
|
|
114
102
|
size={iconSize || iconTokens.size}
|
|
115
103
|
color={iconColor || iconTokens.color}
|
|
@@ -143,9 +131,6 @@ const staticStyles = StyleSheet.create({
|
|
|
143
131
|
itemContainer: {
|
|
144
132
|
flexDirection: 'row'
|
|
145
133
|
},
|
|
146
|
-
centeredIcons: {
|
|
147
|
-
justifyContent: 'center'
|
|
148
|
-
},
|
|
149
134
|
wrap: {
|
|
150
135
|
flex: 1
|
|
151
136
|
}
|
package/src/List/index.js
CHANGED
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
copyPropTypes,
|
|
9
9
|
getTokensPropType,
|
|
10
10
|
hrefAttrsProp,
|
|
11
|
+
linkProps,
|
|
11
12
|
selectTokens,
|
|
12
|
-
variantProp
|
|
13
|
+
variantProp,
|
|
14
|
+
withLinkRouter
|
|
13
15
|
} from '../utils'
|
|
14
16
|
|
|
15
17
|
import useCopy from '../utils/useCopy'
|
|
@@ -57,12 +59,7 @@ const PageButton = forwardRef(
|
|
|
57
59
|
PageButton.displayName = 'PageButton'
|
|
58
60
|
|
|
59
61
|
PageButton.propTypes = {
|
|
60
|
-
|
|
61
|
-
// crashes a Docusaurus props table, but only in production, not in development
|
|
62
|
-
onPress: PropTypes.func,
|
|
63
|
-
href: PropTypes.string,
|
|
64
|
-
// If the above is fixed, the above can be replaced with this which includes full a11y etc:
|
|
65
|
-
// ...linkProps.types,
|
|
62
|
+
...linkProps.types,
|
|
66
63
|
label: PropTypes.string,
|
|
67
64
|
isActive: PropTypes.bool,
|
|
68
65
|
copy: copyPropTypes,
|
|
@@ -70,4 +67,4 @@ PageButton.propTypes = {
|
|
|
70
67
|
tokens: getTokensPropType('PaginationPageButton')
|
|
71
68
|
}
|
|
72
69
|
|
|
73
|
-
export default PageButton
|
|
70
|
+
export default withLinkRouter(PageButton)
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
import { View, Text, StyleSheet } from 'react-native'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
componentPropType,
|
|
6
|
+
copyPropTypes,
|
|
7
|
+
getTokensPropType,
|
|
8
|
+
variantProp,
|
|
9
|
+
withLinkRouter
|
|
10
|
+
} from '../utils'
|
|
5
11
|
import { applyTextStyles, useThemeTokens } from '../ThemeProvider'
|
|
6
12
|
import { useViewport } from '../ViewportProvider'
|
|
7
13
|
import Box from '../Box'
|
|
@@ -20,7 +26,19 @@ const selectTextStyles = ({ color, fontName, fontSize, fontWeight, lineHeight })
|
|
|
20
26
|
})
|
|
21
27
|
|
|
22
28
|
const Pagination = forwardRef(
|
|
23
|
-
(
|
|
29
|
+
(
|
|
30
|
+
{
|
|
31
|
+
children,
|
|
32
|
+
copy = 'en',
|
|
33
|
+
variant,
|
|
34
|
+
tokens,
|
|
35
|
+
sideButtonVariant,
|
|
36
|
+
sideButtonTokens,
|
|
37
|
+
LinkRouter,
|
|
38
|
+
linkRouterProps
|
|
39
|
+
},
|
|
40
|
+
ref
|
|
41
|
+
) => {
|
|
24
42
|
const viewport = useViewport()
|
|
25
43
|
const { truncateAbove, gap, ...themeTokens } = useThemeTokens('Pagination', tokens, variant, {
|
|
26
44
|
viewport
|
|
@@ -58,16 +76,22 @@ const Pagination = forwardRef(
|
|
|
58
76
|
copy={copy}
|
|
59
77
|
variant={sideButtonVariant}
|
|
60
78
|
tokens={sideButtonTokens}
|
|
79
|
+
LinkRouter={LinkRouter}
|
|
80
|
+
linkRouterProps={linkRouterProps}
|
|
61
81
|
/>
|
|
62
82
|
),
|
|
63
83
|
...items.map((child, itemIndex) => {
|
|
64
84
|
const buttonLabel = `${itemIndex + 1}`
|
|
65
85
|
const itemProps = getItemProps(itemIndex)
|
|
86
|
+
const ItemLinkRouter = itemProps.LinkRouter ?? LinkRouter
|
|
87
|
+
const itemLinkRouterProps = { ...linkRouterProps, ...itemProps.linkRouterProps }
|
|
66
88
|
|
|
67
89
|
if (shouldRenderButton(itemIndex)) {
|
|
68
90
|
return (
|
|
69
91
|
<PageButton
|
|
70
92
|
{...itemProps}
|
|
93
|
+
LinkRouter={ItemLinkRouter}
|
|
94
|
+
linkRouterProps={itemLinkRouterProps}
|
|
71
95
|
label={buttonLabel}
|
|
72
96
|
copy={copy}
|
|
73
97
|
isActive={isItemActive(itemIndex)}
|
|
@@ -88,6 +112,8 @@ const Pagination = forwardRef(
|
|
|
88
112
|
copy={copy}
|
|
89
113
|
variant={sideButtonVariant}
|
|
90
114
|
tokens={sideButtonTokens}
|
|
115
|
+
LinkRouter={LinkRouter}
|
|
116
|
+
linkRouterProps={linkRouterProps}
|
|
91
117
|
/>
|
|
92
118
|
)
|
|
93
119
|
]
|
|
@@ -112,6 +138,7 @@ PageButton.displayName = 'PageButton'
|
|
|
112
138
|
Pagination.PageButton = PageButton
|
|
113
139
|
|
|
114
140
|
Pagination.propTypes = {
|
|
141
|
+
...withLinkRouter.propTypes,
|
|
115
142
|
children: componentPropType('PageButton'),
|
|
116
143
|
copy: copyPropTypes,
|
|
117
144
|
variant: variantProp.propType,
|
|
@@ -7,7 +7,7 @@ import ButtonBase from '../Button/ButtonBase'
|
|
|
7
7
|
import { IconText } from '../Icon'
|
|
8
8
|
import { useThemeTokensCallback } from '../ThemeProvider'
|
|
9
9
|
import { useViewport } from '../ViewportProvider'
|
|
10
|
-
import { copyPropTypes, hrefAttrsProp, linkProps, selectTokens } from '../utils'
|
|
10
|
+
import { copyPropTypes, hrefAttrsProp, linkProps, selectTokens, withLinkRouter } from '../utils'
|
|
11
11
|
|
|
12
12
|
import dictionary from './dictionary'
|
|
13
13
|
import useCopy from '../utils/useCopy'
|
|
@@ -82,4 +82,4 @@ SideButton.propTypes = {
|
|
|
82
82
|
...linkProps.types
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export default SideButton
|
|
85
|
+
export default withLinkRouter(SideButton)
|
|
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { View } from 'react-native'
|
|
4
4
|
|
|
5
|
-
import { a11yProps } from '../utils/
|
|
5
|
+
import { a11yProps } from '../utils/props'
|
|
6
6
|
import { useThemeTokens } from '../ThemeProvider'
|
|
7
7
|
import { getTokensPropType, variantProp } from '../utils'
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import { Platform, StyleSheet, View } from 'react-native'
|
|
4
4
|
|
|
5
5
|
import ProgressBarBackground from './ProgressBarBackground'
|
|
6
|
-
import { a11yProps } from '../utils/
|
|
6
|
+
import { a11yProps } from '../utils/props'
|
|
7
7
|
import { useThemeTokens } from '../ThemeProvider'
|
|
8
8
|
import { getTokensPropType, variantProp } from '../utils'
|
|
9
9
|
|
package/src/Radio/Radio.jsx
CHANGED
|
@@ -2,13 +2,11 @@ import React, { forwardRef } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { Pressable, StyleSheet, Text, View } from 'react-native'
|
|
4
4
|
|
|
5
|
-
// @todo move `LabelContent` outside of the `InputLabel` and fix
|
|
6
|
-
// the issue with the cursor not being pointer on Web
|
|
7
5
|
import RadioLabel from '../InputLabel/LabelContent'
|
|
8
6
|
import RadioButton, { selectRadioButtonTokens } from './RadioButton'
|
|
9
7
|
import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider'
|
|
10
8
|
import { getTokensPropType, useInputValue, useUniqueId, variantProp } from '../utils'
|
|
11
|
-
import { a11yProps } from '../utils/
|
|
9
|
+
import { a11yProps } from '../utils/props'
|
|
12
10
|
import StackView from '../StackView'
|
|
13
11
|
|
|
14
12
|
const selectContainerStyles = ({
|
package/src/Spacer/Spacer.jsx
CHANGED
|
@@ -4,8 +4,8 @@ import { StyleSheet, View } from 'react-native'
|
|
|
4
4
|
|
|
5
5
|
import { useSpacingScale, spacingProps } from '../utils'
|
|
6
6
|
/**
|
|
7
|
-
* @typedef {import('../utils/
|
|
8
|
-
* @typedef {import('../utils/
|
|
7
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
|
|
8
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
const selectSizeStyle = (size, direction) => ({
|
|
@@ -4,6 +4,12 @@ import { Platform } from 'react-native'
|
|
|
4
4
|
import StackWrapBox from './StackWrapBox'
|
|
5
5
|
import StackWrapGap from './StackWrapGap'
|
|
6
6
|
|
|
7
|
+
// In Jest/CI/SSR, global CSS isn't always available and doesn't always have .supports method
|
|
8
|
+
const cssSupports = (...args) =>
|
|
9
|
+
typeof window !== 'undefined' &&
|
|
10
|
+
typeof window.CSS?.supports === 'function' &&
|
|
11
|
+
window.CSS.supports(...args)
|
|
12
|
+
|
|
7
13
|
// CSS.supports needs an example of the type of value you intend to use.
|
|
8
14
|
// Will be an integer appended `px` after hooks and JSX styles are resolved.
|
|
9
15
|
const exampleGapValue = '1px'
|
|
@@ -20,12 +26,7 @@ const StackWrap = forwardRef((props, ref) => {
|
|
|
20
26
|
// Don't apply separate gap if `null` or `undefined`, so can be unset in Storybook etc
|
|
21
27
|
const gap = props.gap ?? space
|
|
22
28
|
|
|
23
|
-
const canUseCSSGap =
|
|
24
|
-
Platform.OS === 'web' &&
|
|
25
|
-
gap === space &&
|
|
26
|
-
// In Jest/CI, global CSS isn't always available and doesn't always have .supports method
|
|
27
|
-
typeof CSS?.supports === 'function' &&
|
|
28
|
-
CSS.supports('gap', exampleGapValue)
|
|
29
|
+
const canUseCSSGap = Platform.OS === 'web' && gap === space && cssSupports('gap', exampleGapValue)
|
|
29
30
|
|
|
30
31
|
return canUseCSSGap ? (
|
|
31
32
|
// If possible, use the cleaner implementation that applies CSS `gap` styles to the container.
|
|
@@ -7,7 +7,7 @@ import Spacer from '../Spacer'
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {import('react').ReactChildren} ReactChildren
|
|
9
9
|
* @typedef {import('react').ReactElement} ReactElement
|
|
10
|
-
* @typedef {import('../utils/
|
|
10
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -5,7 +5,7 @@ import { StyleSheet, Text, View } from 'react-native'
|
|
|
5
5
|
import StackView from '../StackView'
|
|
6
6
|
import { applyTextStyles, useThemeTokens } from '../ThemeProvider'
|
|
7
7
|
import { getTokensPropType, variantProp } from '../utils'
|
|
8
|
-
import { a11yProps } from '../utils/
|
|
8
|
+
import { a11yProps } from '../utils/props'
|
|
9
9
|
import { useViewport } from '../ViewportProvider'
|
|
10
10
|
import useCopy from '../utils/useCopy'
|
|
11
11
|
|