@telus-uds/components-base 1.14.1 → 1.15.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/CHANGELOG.md +33 -2
- package/__tests17__/A11yText/A11yText.test.jsx +34 -0
- package/__tests17__/ActivityIndicator/ActivityIndicator.test.jsx +68 -0
- package/__tests17__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +299 -0
- package/__tests17__/Box/Box.test.jsx +111 -0
- package/__tests17__/Button/Button.test.jsx +86 -0
- package/__tests17__/Button/ButtonBase.test.jsx +82 -0
- package/__tests17__/Button/ButtonGroup.test.jsx +347 -0
- package/__tests17__/Button/ButtonLink.test.jsx +61 -0
- package/__tests17__/Card/Card.test.jsx +63 -0
- package/__tests17__/Carousel/Carousel.test.jsx +128 -0
- package/__tests17__/Carousel/CarouselTabs.test.jsx +142 -0
- package/__tests17__/Checkbox/Checkbox.test.jsx +94 -0
- package/__tests17__/Checkbox/CheckboxGroup.test.jsx +246 -0
- package/__tests17__/Divider/Divider.test.jsx +91 -0
- package/__tests17__/ExpandCollapse/ExpandCollapse.test.jsx +109 -0
- package/__tests17__/Feedback/Feedback.test.jsx +42 -0
- package/__tests17__/FlexGrid/Col.test.jsx +261 -0
- package/__tests17__/FlexGrid/FlexGrid.test.jsx +136 -0
- package/__tests17__/FlexGrid/Row.test.jsx +273 -0
- package/__tests17__/HorizontalScroll/HorizontalScroll.test.jsx +165 -0
- package/__tests17__/Icon/Icon.test.jsx +61 -0
- package/__tests17__/IconButton/IconButton.test.jsx +52 -0
- package/__tests17__/InputLabel/InputLabel.test.jsx +28 -0
- package/__tests17__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +3 -0
- package/__tests17__/InputSupports/InputSupports.test.jsx +60 -0
- package/__tests17__/Link/Link.test.jsx +63 -0
- package/__tests17__/Link/TextButton.test.jsx +35 -0
- package/__tests17__/List/List.test.jsx +82 -0
- package/__tests17__/Modal/Modal.test.jsx +47 -0
- package/__tests17__/Notification/Notification.test.jsx +20 -0
- package/__tests17__/Pagination/Pagination.test.jsx +160 -0
- package/__tests17__/Progress/Progress.test.jsx +79 -0
- package/__tests17__/Radio/Radio.test.jsx +87 -0
- package/__tests17__/Radio/RadioGroup.test.jsx +220 -0
- package/__tests17__/RadioCard/RadioCard.test.jsx +87 -0
- package/__tests17__/RadioCard/RadioCardGroup.test.jsx +246 -0
- package/__tests17__/Search/Search.test.jsx +87 -0
- package/__tests17__/Select/Select.test.jsx +94 -0
- package/__tests17__/SideNav/SideNav.test.jsx +110 -0
- package/__tests17__/Skeleton/Skeleton.test.jsx +61 -0
- package/__tests17__/SkipLink/SkipLink.test.jsx +61 -0
- package/__tests17__/Spacer/Spacer.test.jsx +63 -0
- package/__tests17__/StackView/StackView.test.jsx +211 -0
- package/__tests17__/StackView/StackWrap.test.jsx +47 -0
- package/__tests17__/StackView/getStackedContent.test.jsx +295 -0
- package/__tests17__/StepTracker/StepTracker.test.jsx +108 -0
- package/__tests17__/Tabs/Tabs.test.jsx +49 -0
- package/__tests17__/Tags/Tags.test.jsx +327 -0
- package/__tests17__/TextInput/TextArea.test.jsx +35 -0
- package/__tests17__/TextInput/TextInputBase.test.jsx +125 -0
- package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +80 -0
- package/__tests17__/ThemeProvider/useThemeTokens.test.jsx +514 -0
- package/__tests17__/ThemeProvider/utils/theme-tokens.test.js +41 -0
- package/__tests17__/ToggleSwitch/ToggleSwitch.test.jsx +82 -0
- package/__tests17__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
- package/__tests17__/Tooltip/Tooltip.test.jsx +65 -0
- package/__tests17__/Tooltip/getTooltipPosition.test.js +79 -0
- package/__tests17__/Typography/typography.test.jsx +90 -0
- package/__tests17__/utils/children.test.jsx +128 -0
- package/__tests17__/utils/containUniqueFields.test.js +25 -0
- package/__tests17__/utils/input.test.js +375 -0
- package/__tests17__/utils/props.test.js +36 -0
- package/__tests17__/utils/semantics.test.jsx +34 -0
- package/__tests17__/utils/useCopy.test.js +42 -0
- package/__tests17__/utils/useResponsiveProp.test.jsx +202 -0
- package/__tests17__/utils/useSpacingScale.test.jsx +273 -0
- package/__tests17__/utils/useUniqueId.test.js +31 -0
- package/component-docs.json +95 -438
- package/lib/A11yInfoProvider/index.js +14 -5
- package/lib/Button/ButtonGroup.js +3 -2
- package/lib/Checkbox/Checkbox.js +9 -6
- package/lib/ExpandCollapse/Control.js +6 -5
- package/lib/ExpandCollapse/Panel.js +5 -4
- package/lib/List/ListItem.js +10 -236
- package/lib/List/ListItemBase.js +162 -0
- package/lib/List/ListItemContent.js +85 -0
- package/lib/List/ListItemMark.js +158 -0
- package/lib/List/PressableListItemBase.js +147 -0
- package/lib/Notification/Notification.js +2 -1
- package/lib/Pagination/Pagination.js +4 -3
- package/lib/Pagination/SideButton.js +17 -7
- package/lib/Radio/Radio.js +9 -6
- package/lib/RadioCard/RadioCard.js +9 -6
- package/lib/Select/Select.js +1 -0
- package/lib/Tabs/Tabs.js +12 -3
- package/lib/Tags/Tags.js +3 -3
- package/lib/TextInput/TextInput.js +5 -4
- package/lib/ViewportProvider/useViewportListener.js +11 -5
- package/lib/utils/hasOwnProperty.js +18 -0
- package/lib/utils/props/a11yProps.js +212 -45
- package/lib/utils/props/getPropSelector.js +47 -5
- package/lib/utils/ssr.js +116 -1
- package/lib/utils/useResponsiveProp.js +5 -3
- package/lib/utils/withLinkRouter.js +3 -5
- package/lib-module/A11yInfoProvider/index.js +14 -4
- package/lib-module/Button/ButtonGroup.js +3 -2
- package/lib-module/Checkbox/Checkbox.js +9 -6
- package/lib-module/ExpandCollapse/Control.js +6 -5
- package/lib-module/ExpandCollapse/Panel.js +5 -4
- package/lib-module/List/ListItem.js +13 -235
- package/lib-module/List/ListItemBase.js +139 -0
- package/lib-module/List/ListItemContent.js +66 -0
- package/lib-module/List/ListItemMark.js +143 -0
- package/lib-module/List/PressableListItemBase.js +117 -0
- package/lib-module/Notification/Notification.js +2 -1
- package/lib-module/Pagination/Pagination.js +5 -3
- package/lib-module/Pagination/SideButton.js +18 -8
- package/lib-module/Radio/Radio.js +9 -6
- package/lib-module/RadioCard/RadioCard.js +9 -6
- package/lib-module/Select/Select.js +1 -0
- package/lib-module/Tabs/Tabs.js +13 -4
- package/lib-module/Tags/Tags.js +3 -3
- package/lib-module/TextInput/TextInput.js +5 -4
- package/lib-module/ViewportProvider/useViewportListener.js +10 -4
- package/lib-module/utils/hasOwnProperty.js +11 -0
- package/lib-module/utils/props/a11yProps.js +210 -45
- package/lib-module/utils/props/getPropSelector.js +44 -5
- package/lib-module/utils/ssr.js +106 -0
- package/lib-module/utils/useResponsiveProp.js +3 -4
- package/lib-module/utils/withLinkRouter.js +3 -5
- package/package.json +12 -17
- package/src/A11yInfoProvider/index.jsx +20 -4
- package/src/Button/ButtonGroup.jsx +4 -2
- package/src/Checkbox/Checkbox.jsx +7 -3
- package/src/ExpandCollapse/Control.jsx +8 -5
- package/src/ExpandCollapse/Panel.jsx +7 -5
- package/src/List/ListItem.jsx +12 -191
- package/src/List/ListItemBase.jsx +118 -0
- package/src/List/ListItemContent.jsx +52 -0
- package/src/List/ListItemMark.jsx +99 -0
- package/src/List/PressableListItemBase.jsx +102 -0
- package/src/Notification/Notification.jsx +1 -1
- package/src/Pagination/Pagination.jsx +6 -1
- package/src/Pagination/SideButton.jsx +4 -1
- package/src/Radio/Radio.jsx +7 -3
- package/src/RadioCard/RadioCard.jsx +7 -3
- package/src/Select/Select.jsx +1 -1
- package/src/Tabs/Tabs.jsx +19 -2
- package/src/Tags/Tags.jsx +3 -3
- package/src/TextInput/TextInput.jsx +4 -4
- package/src/ViewportProvider/useViewportListener.js +10 -5
- package/src/utils/hasOwnProperty.js +11 -0
- package/src/utils/props/a11yProps.js +168 -55
- package/src/utils/props/getPropSelector.js +45 -4
- package/src/utils/ssr.jsx +124 -0
- package/src/utils/useResponsiveProp.js +3 -3
- package/src/utils/withLinkRouter.jsx +1 -3
- package/src/utils/ssr.js +0 -35
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ABBPropTypes from 'airbnb-prop-types';
|
|
4
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
5
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
6
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
7
|
+
import { resolvePressableTokens, clickProps, linkProps, hrefAttrsProp, withLinkRouter } from '../utils';
|
|
8
|
+
import ListItemBase from './ListItemBase';
|
|
9
|
+
import ListItemContent, { tokenTypes as contentTokenTypes } from './ListItemContent';
|
|
10
|
+
import ListItemMark, { tokenTypes as markTokenTypes } from './ListItemMark';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
|
|
15
|
+
const selectPressableStyles = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
backgroundColor,
|
|
18
|
+
paddingLeft,
|
|
19
|
+
paddingRight,
|
|
20
|
+
paddingTop,
|
|
21
|
+
paddingBottom,
|
|
22
|
+
interItemMargin
|
|
23
|
+
} = _ref;
|
|
24
|
+
return {
|
|
25
|
+
backgroundColor,
|
|
26
|
+
paddingLeft,
|
|
27
|
+
paddingRight,
|
|
28
|
+
paddingTop,
|
|
29
|
+
paddingBottom,
|
|
30
|
+
marginBottom: interItemMargin,
|
|
31
|
+
...Platform.select({
|
|
32
|
+
web: {
|
|
33
|
+
outline: 'none'
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const PressableListItemBase = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
40
|
+
let {
|
|
41
|
+
href,
|
|
42
|
+
tokens,
|
|
43
|
+
icon,
|
|
44
|
+
children,
|
|
45
|
+
listItemRef,
|
|
46
|
+
...rest
|
|
47
|
+
} = _ref2;
|
|
48
|
+
const {
|
|
49
|
+
onPress,
|
|
50
|
+
...props
|
|
51
|
+
} = clickProps.toPressProps(rest);
|
|
52
|
+
const {
|
|
53
|
+
hrefAttrs,
|
|
54
|
+
rest: listItemProps
|
|
55
|
+
} = hrefAttrsProp.bundle(props);
|
|
56
|
+
const handlePress = linkProps.handleHref({
|
|
57
|
+
href,
|
|
58
|
+
onPress
|
|
59
|
+
});
|
|
60
|
+
return /*#__PURE__*/_jsx(ListItemBase, {
|
|
61
|
+
ref: listItemRef,
|
|
62
|
+
tokens: tokens(),
|
|
63
|
+
...listItemProps,
|
|
64
|
+
children: _ref3 => {
|
|
65
|
+
let {
|
|
66
|
+
isLastItem
|
|
67
|
+
} = _ref3;
|
|
68
|
+
|
|
69
|
+
const getTokens = pressableState => resolvePressableTokens(tokens, pressableState, {
|
|
70
|
+
last: isLastItem
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const getPressableStyle = pressableState => [staticStyles.itemContainer, selectPressableStyles(getTokens(pressableState))];
|
|
74
|
+
|
|
75
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
76
|
+
onPress: handlePress,
|
|
77
|
+
href: href,
|
|
78
|
+
hrefAttrs: hrefAttrs,
|
|
79
|
+
style: getPressableStyle,
|
|
80
|
+
ref: ref,
|
|
81
|
+
children: pressableState => {
|
|
82
|
+
const themeTokens = getTokens(pressableState);
|
|
83
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
84
|
+
children: [/*#__PURE__*/_jsx(ListItemMark, {
|
|
85
|
+
icon: icon,
|
|
86
|
+
tokens: themeTokens
|
|
87
|
+
}), /*#__PURE__*/_jsx(ListItemContent, {
|
|
88
|
+
tokens: themeTokens,
|
|
89
|
+
children: typeof children === 'function' ? children(pressableState) : children
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
PressableListItemBase.displayName = 'PressableListItemBase';
|
|
98
|
+
const staticStyles = StyleSheet.create({
|
|
99
|
+
itemContainer: {
|
|
100
|
+
flexDirection: 'row',
|
|
101
|
+
flex: 1
|
|
102
|
+
},
|
|
103
|
+
tokens: { ...contentTokenTypes,
|
|
104
|
+
...markTokenTypes
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
PressableListItemBase.propTypes = {
|
|
108
|
+
href: PropTypes.string,
|
|
109
|
+
onPress: PropTypes.func,
|
|
110
|
+
// TODO - type this better, maybe import the subcomponent token types and run it through util
|
|
111
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
112
|
+
tokens: PropTypes.any,
|
|
113
|
+
icon: PropTypes.elementType,
|
|
114
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
115
|
+
listItemRef: ABBPropTypes.ref()
|
|
116
|
+
};
|
|
117
|
+
export default withLinkRouter(PressableListItemBase);
|
|
@@ -143,7 +143,8 @@ const Notification = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
143
143
|
|
|
144
144
|
const textStyles = selectTextStyles(themeTokens, themeOptions);
|
|
145
145
|
const content = wrapStringsInText(typeof children === 'function' ? children({
|
|
146
|
-
textStyles
|
|
146
|
+
textStyles,
|
|
147
|
+
variant
|
|
147
148
|
}) : children, {
|
|
148
149
|
style: textStyles
|
|
149
150
|
});
|
|
@@ -10,6 +10,7 @@ import usePagination from './usePagination';
|
|
|
10
10
|
import PageButton from './PageButton';
|
|
11
11
|
import SideButton from './SideButton';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { createElement as _createElement } from "react";
|
|
13
14
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
14
15
|
|
|
15
16
|
const selectTextStyles = (_ref, themeOptions) => {
|
|
@@ -93,12 +94,13 @@ const Pagination = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
93
94
|
};
|
|
94
95
|
|
|
95
96
|
if (shouldRenderButton(itemIndex)) {
|
|
96
|
-
return /*#__PURE__*/
|
|
97
|
+
return /*#__PURE__*/_createElement(PageButton, { ...itemProps,
|
|
97
98
|
LinkRouter: ItemLinkRouter,
|
|
98
99
|
linkRouterProps: itemLinkRouterProps,
|
|
99
100
|
label: buttonLabel,
|
|
100
101
|
copy: copy,
|
|
101
|
-
isActive: isItemActive(itemIndex)
|
|
102
|
+
isActive: isItemActive(itemIndex),
|
|
103
|
+
key: buttonLabel
|
|
102
104
|
});
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -106,7 +108,7 @@ const Pagination = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
106
108
|
return /*#__PURE__*/_jsx(Text, {
|
|
107
109
|
style: ellipsisTextStyles,
|
|
108
110
|
children: "..."
|
|
109
|
-
});
|
|
111
|
+
}, "...");
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
return null;
|
|
@@ -7,15 +7,25 @@ import { useThemeTokensCallback } from '../ThemeProvider';
|
|
|
7
7
|
import { useViewport } from '../ViewportProvider';
|
|
8
8
|
import { copyPropTypes, hrefAttrsProp, linkProps, selectTokens, withLinkRouter } from '../utils';
|
|
9
9
|
import dictionary from './dictionary';
|
|
10
|
-
import useCopy from '../utils/useCopy';
|
|
10
|
+
import useCopy from '../utils/useCopy'; // We need to drop the icon here since it gets rendered via children and not
|
|
11
|
+
// `ButtonBase` in order to tap into the state of the button
|
|
12
|
+
|
|
11
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
14
|
|
|
13
|
-
const
|
|
15
|
+
const selectButtonTokens = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
icon: _,
|
|
18
|
+
...rest
|
|
19
|
+
} = _ref;
|
|
20
|
+
return selectTokens('Button', rest);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const selectIconTokens = (_ref2, direction) => {
|
|
14
24
|
let {
|
|
15
25
|
color,
|
|
16
26
|
iconSize,
|
|
17
27
|
iconDisplace
|
|
18
|
-
} =
|
|
28
|
+
} = _ref2;
|
|
19
29
|
return {
|
|
20
30
|
color,
|
|
21
31
|
size: iconSize,
|
|
@@ -27,7 +37,7 @@ const directionToSide = {
|
|
|
27
37
|
previous: 'left',
|
|
28
38
|
next: 'right'
|
|
29
39
|
};
|
|
30
|
-
const SideButton = /*#__PURE__*/forwardRef((
|
|
40
|
+
const SideButton = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
31
41
|
let {
|
|
32
42
|
direction = 'previous',
|
|
33
43
|
onPress,
|
|
@@ -36,7 +46,7 @@ const SideButton = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
36
46
|
variant,
|
|
37
47
|
tokens,
|
|
38
48
|
...props
|
|
39
|
-
} =
|
|
49
|
+
} = _ref3;
|
|
40
50
|
const viewport = useViewport();
|
|
41
51
|
const buttonVariant = {
|
|
42
52
|
direction,
|
|
@@ -52,7 +62,7 @@ const SideButton = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
52
62
|
icon
|
|
53
63
|
} = getTokens(tokens, buttonVariant);
|
|
54
64
|
|
|
55
|
-
const getButtonTokens = buttonState =>
|
|
65
|
+
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
|
|
56
66
|
|
|
57
67
|
const getIconTokens = buttonState => selectIconTokens(getTokens(buttonState), direction);
|
|
58
68
|
|
|
@@ -76,11 +86,11 @@ const SideButton = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
76
86
|
ref: ref,
|
|
77
87
|
...buttonProps,
|
|
78
88
|
tokens: getButtonTokens,
|
|
79
|
-
children:
|
|
89
|
+
children: _ref4 => {
|
|
80
90
|
let {
|
|
81
91
|
textStyles,
|
|
82
92
|
...buttonState
|
|
83
|
-
} =
|
|
93
|
+
} = _ref4;
|
|
84
94
|
const iconProps = {
|
|
85
95
|
tokens: getIconTokens(buttonState)
|
|
86
96
|
};
|
|
@@ -151,17 +151,20 @@ const Radio = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
|
151
151
|
|
|
152
152
|
const uniqueId = useUniqueId('radio');
|
|
153
153
|
const inputId = id !== null && id !== void 0 ? id : uniqueId;
|
|
154
|
+
const selectedProps = selectProps({
|
|
155
|
+
accessibilityRole: 'radio',
|
|
156
|
+
accessibilityState: {
|
|
157
|
+
checked: isChecked,
|
|
158
|
+
disabled: inactive
|
|
159
|
+
},
|
|
160
|
+
...rest
|
|
161
|
+
});
|
|
154
162
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
155
163
|
ref: ref,
|
|
156
164
|
disabled: inactive,
|
|
157
165
|
onKeyDown: handleKeyDown,
|
|
158
166
|
onPress: handleChange,
|
|
159
|
-
|
|
160
|
-
accessibilityState: {
|
|
161
|
-
checked: isChecked,
|
|
162
|
-
disabled: inactive
|
|
163
|
-
},
|
|
164
|
-
...selectProps(rest),
|
|
167
|
+
...selectedProps,
|
|
165
168
|
children: _ref5 => {
|
|
166
169
|
let {
|
|
167
170
|
focused: focus,
|
|
@@ -87,18 +87,21 @@ const RadioCard = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
87
87
|
const {
|
|
88
88
|
themeOptions
|
|
89
89
|
} = useTheme();
|
|
90
|
+
const selectedProps = selectProps({
|
|
91
|
+
accessibilityRole: 'radio',
|
|
92
|
+
accessibilityState: {
|
|
93
|
+
checked: isChecked,
|
|
94
|
+
disabled: inactive
|
|
95
|
+
},
|
|
96
|
+
...rest
|
|
97
|
+
});
|
|
90
98
|
return /*#__PURE__*/_jsx(PressableCardBase, {
|
|
91
99
|
ref: ref,
|
|
92
100
|
inactive: inactive,
|
|
93
101
|
checked: isChecked,
|
|
94
102
|
tokens: getCardTokens,
|
|
95
103
|
onPress: handleChange,
|
|
96
|
-
|
|
97
|
-
accessibilityState: {
|
|
98
|
-
checked: isChecked,
|
|
99
|
-
disabled: inactive
|
|
100
|
-
},
|
|
101
|
-
...selectProps(rest),
|
|
104
|
+
...selectedProps,
|
|
102
105
|
children: cardState => {
|
|
103
106
|
const {
|
|
104
107
|
radioSpace,
|
package/lib-module/Tabs/Tabs.js
CHANGED
|
@@ -3,11 +3,12 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import ABBPropTypes from 'airbnb-prop-types';
|
|
4
4
|
import { useThemeTokens } from '../ThemeProvider';
|
|
5
5
|
import StackView from '../StackView';
|
|
6
|
-
import { a11yProps, getTokensPropType, selectSystemProps, useHash, useInputValue, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
6
|
+
import { a11yProps, getTokensPropType, focusHandlerProps, pressProps, selectSystemProps, useHash, useInputValue, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
7
7
|
import HorizontalScroll, { horizontalScrollUtils, HorizontalScrollButton } from '../HorizontalScroll';
|
|
8
8
|
import TabsItem from './TabsItem';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
11
|
+
const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, pressProps, viewProps]);
|
|
11
12
|
const {
|
|
12
13
|
selectHorizontalScrollTokens,
|
|
13
14
|
useItemPositions
|
|
@@ -94,15 +95,21 @@ const Tabs = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
94
95
|
label,
|
|
95
96
|
id,
|
|
96
97
|
accessibilityRole = defaultTabItemAccessibiltyRole,
|
|
98
|
+
onPress,
|
|
97
99
|
ref: itemRef,
|
|
98
100
|
LinkRouter: ItemLinkRouter = LinkRouter,
|
|
99
|
-
linkRouterProps: itemLinkRouterProps
|
|
101
|
+
linkRouterProps: itemLinkRouterProps,
|
|
102
|
+
...itemRest
|
|
100
103
|
} = _ref3;
|
|
101
104
|
const itemId = id !== null && id !== void 0 ? id : label;
|
|
102
105
|
const isSelected = Boolean(currentValue && currentValue === itemId);
|
|
103
106
|
|
|
104
|
-
const handlePress = event =>
|
|
107
|
+
const handlePress = event => {
|
|
108
|
+
if (typeof onPress === 'function') onPress(event);
|
|
109
|
+
setValue(itemId, event);
|
|
110
|
+
};
|
|
105
111
|
|
|
112
|
+
const itemProps = selectItemProps(itemRest);
|
|
106
113
|
return /*#__PURE__*/_jsx(TabsItem, {
|
|
107
114
|
ref: itemRef,
|
|
108
115
|
href: href,
|
|
@@ -117,6 +124,7 @@ const Tabs = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
117
124
|
linkRouterProps: { ...linkRouterProps,
|
|
118
125
|
...itemLinkRouterProps
|
|
119
126
|
},
|
|
127
|
+
...itemProps,
|
|
120
128
|
children: label
|
|
121
129
|
}, itemId);
|
|
122
130
|
})
|
|
@@ -126,7 +134,8 @@ const Tabs = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
126
134
|
Tabs.displayName = 'Tabs';
|
|
127
135
|
Tabs.propTypes = { ...selectedSystemPropTypes,
|
|
128
136
|
...withLinkRouter.PropTypes,
|
|
129
|
-
items: PropTypes.arrayOf(PropTypes.shape({ ...
|
|
137
|
+
items: PropTypes.arrayOf(PropTypes.shape({ ...selectedItemPropTypes,
|
|
138
|
+
...withLinkRouter.PropTypes,
|
|
130
139
|
href: PropTypes.string,
|
|
131
140
|
label: PropTypes.string,
|
|
132
141
|
id: PropTypes.string,
|
package/lib-module/Tags/Tags.js
CHANGED
|
@@ -131,14 +131,14 @@ const Tags = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
131
131
|
toggleOneValue(id, event);
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
const itemProps = {
|
|
134
|
+
const itemProps = selectItemProps({
|
|
135
135
|
accessibilityState: {
|
|
136
136
|
checked: isSelected
|
|
137
137
|
},
|
|
138
138
|
accessibilityRole: itemA11yRole,
|
|
139
139
|
...a11yProps.getPositionInSet(items.length, index),
|
|
140
|
-
...
|
|
141
|
-
};
|
|
140
|
+
...itemRest
|
|
141
|
+
});
|
|
142
142
|
return /*#__PURE__*/_jsx(ButtonBase, {
|
|
143
143
|
ref: itemRef,
|
|
144
144
|
...pressHandlers,
|
|
@@ -27,6 +27,7 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, foc
|
|
|
27
27
|
const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
28
28
|
let {
|
|
29
29
|
tokens,
|
|
30
|
+
nativeID,
|
|
30
31
|
variant = {},
|
|
31
32
|
...rest
|
|
32
33
|
} = _ref;
|
|
@@ -41,18 +42,18 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
return /*#__PURE__*/_jsx(InputSupports, {
|
|
44
|
-
nativeID:
|
|
45
|
+
nativeID: nativeID,
|
|
45
46
|
...supportsProps,
|
|
46
47
|
children: _ref2 => {
|
|
47
48
|
let {
|
|
48
49
|
inputId,
|
|
49
|
-
...
|
|
50
|
+
...propsFromInputSupports
|
|
50
51
|
} = _ref2;
|
|
51
52
|
return /*#__PURE__*/_jsx(TextInputBase, {
|
|
52
53
|
ref: ref,
|
|
53
|
-
...inputProps,
|
|
54
54
|
nativeID: inputId,
|
|
55
|
-
...
|
|
55
|
+
...propsFromInputSupports,
|
|
56
|
+
...inputProps
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
});
|
|
@@ -33,10 +33,16 @@ const useViewportListenerCSR = setViewport => {
|
|
|
33
33
|
return setViewport(viewports.select(window.width));
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
const listener = Dimensions.addEventListener('change', onChange);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const listener = Dimensions.addEventListener('change', onChange);
|
|
37
|
+
return () => {
|
|
38
|
+
if (typeof (listener === null || listener === void 0 ? void 0 : listener.remove) === 'function') {
|
|
39
|
+
// Can't just return listener.remove because listener.emitter disappears, causing an internal error.
|
|
40
|
+
// See https://github.com/facebook/react-native/issues/34508
|
|
41
|
+
listener.remove(); // From RN 0.65.0, Dimensions.removeEventListener is deprecated for `remove` on addEventListener return value
|
|
42
|
+
} else if (typeof Dimensions.removeEventListener === 'function') {
|
|
43
|
+
Dimensions.removeEventListener('change', onChange);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
40
46
|
}, [setViewport]);
|
|
41
47
|
}; // Window is a defined global object in both Web and Native client-side, and undefined in SSR
|
|
42
48
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linter disallows object instance prototype methods like someObject.hasOwnProperty(key),
|
|
3
|
+
* but we can use this instead.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} object
|
|
6
|
+
* @param {String} key
|
|
7
|
+
* @returns {Boolean}
|
|
8
|
+
*/
|
|
9
|
+
export default function hasOwnProperty(object, key) {
|
|
10
|
+
return Object.prototype.hasOwnProperty.call(object, key);
|
|
11
|
+
}
|