@telus-uds/components-base 1.4.0 → 1.6.1
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/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-lint.log +13 -0
- package/CHANGELOG.json +140 -1
- package/CHANGELOG.md +42 -2
- package/__tests__/FlexGrid/Row.test.jsx +100 -25
- package/__tests__/utils/containUniqueFields.test.js +25 -0
- package/component-docs.json +94 -16
- package/generate-component-docs.js +20 -7
- package/lib/Button/ButtonBase.js +1 -1
- package/lib/Button/ButtonGroup.js +20 -12
- package/lib/Card/PressableCardBase.js +1 -1
- package/lib/Checkbox/Checkbox.js +27 -16
- package/lib/Checkbox/CheckboxGroup.js +19 -5
- package/lib/ExpandCollapse/Panel.js +10 -10
- package/lib/FlexGrid/Col/Col.js +13 -3
- package/lib/FlexGrid/Row/Row.js +8 -2
- package/lib/HorizontalScroll/HorizontalScroll.js +0 -1
- package/lib/HorizontalScroll/HorizontalScrollButton.js +23 -49
- package/lib/InputLabel/InputLabel.js +27 -25
- package/lib/Link/LinkBase.js +19 -6
- package/lib/Link/TextButton.js +1 -10
- package/lib/Modal/Modal.js +18 -18
- package/lib/Radio/Radio.js +23 -12
- package/lib/Radio/RadioGroup.js +12 -3
- package/lib/RadioCard/RadioCard.js +1 -1
- package/lib/RadioCard/RadioCardGroup.js +11 -2
- package/lib/Select/Select.js +2 -3
- package/lib/Tags/Tags.js +23 -17
- package/lib/TextInput/TextArea.js +2 -2
- package/lib/TextInput/TextInput.js +12 -2
- package/lib/TextInput/TextInputBase.js +1 -1
- package/lib/TextInput/propTypes.js +8 -1
- package/lib/ToggleSwitch/ToggleSwitch.js +5 -2
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +20 -12
- package/lib/utils/containUniqueFields.js +34 -0
- package/lib/utils/index.js +10 -1
- package/lib/utils/props/handlerProps.js +72 -0
- package/lib/utils/props/index.js +14 -0
- package/lib/utils/props/inputSupportsProps.js +3 -5
- package/lib/utils/props/linkProps.js +3 -7
- package/lib-module/Button/ButtonBase.js +2 -2
- package/lib-module/Button/ButtonGroup.js +15 -6
- package/lib-module/Card/PressableCardBase.js +2 -2
- package/lib-module/Checkbox/Checkbox.js +28 -17
- package/lib-module/Checkbox/CheckboxGroup.js +20 -7
- package/lib-module/ExpandCollapse/Panel.js +10 -10
- package/lib-module/FlexGrid/Col/Col.js +13 -3
- package/lib-module/FlexGrid/Row/Row.js +8 -2
- package/lib-module/HorizontalScroll/HorizontalScroll.js +0 -1
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +24 -49
- package/lib-module/InputLabel/InputLabel.js +28 -25
- package/lib-module/Link/LinkBase.js +19 -6
- package/lib-module/Link/TextButton.js +1 -10
- package/lib-module/Modal/Modal.js +19 -19
- package/lib-module/Radio/Radio.js +24 -13
- package/lib-module/Radio/RadioGroup.js +13 -4
- package/lib-module/RadioCard/RadioCard.js +2 -2
- package/lib-module/RadioCard/RadioCardGroup.js +12 -3
- package/lib-module/Select/Select.js +2 -3
- package/lib-module/Tags/Tags.js +18 -11
- package/lib-module/TextInput/TextArea.js +3 -3
- package/lib-module/TextInput/TextInput.js +11 -3
- package/lib-module/TextInput/TextInputBase.js +2 -2
- package/lib-module/TextInput/propTypes.js +7 -1
- package/lib-module/ToggleSwitch/ToggleSwitch.js +6 -3
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +15 -6
- package/lib-module/utils/containUniqueFields.js +26 -0
- package/lib-module/utils/index.js +2 -1
- package/lib-module/utils/props/handlerProps.js +59 -0
- package/lib-module/utils/props/index.js +1 -0
- package/lib-module/utils/props/inputSupportsProps.js +3 -5
- package/lib-module/utils/props/linkProps.js +3 -7
- package/package.json +5 -5
- package/src/Button/ButtonBase.jsx +8 -2
- package/src/Button/ButtonGroup.jsx +51 -34
- package/src/Card/PressableCardBase.jsx +6 -1
- package/src/Checkbox/Checkbox.jsx +35 -23
- package/src/Checkbox/CheckboxGroup.jsx +52 -22
- package/src/ExpandCollapse/Panel.jsx +9 -9
- package/src/FlexGrid/Col/Col.jsx +11 -2
- package/src/FlexGrid/Row/Row.jsx +8 -2
- package/src/HorizontalScroll/HorizontalScroll.jsx +1 -1
- package/src/HorizontalScroll/HorizontalScrollButton.jsx +21 -58
- package/src/InputLabel/InputLabel.jsx +36 -27
- package/src/Link/LinkBase.jsx +20 -4
- package/src/Link/TextButton.jsx +1 -19
- package/src/Modal/Modal.jsx +30 -26
- package/src/Radio/Radio.jsx +26 -14
- package/src/Radio/RadioGroup.jsx +39 -21
- package/src/RadioCard/RadioCard.jsx +6 -1
- package/src/RadioCard/RadioCardGroup.jsx +17 -1
- package/src/Select/Select.jsx +2 -2
- package/src/Tags/Tags.jsx +23 -9
- package/src/TextInput/TextArea.jsx +5 -1
- package/src/TextInput/TextInput.jsx +13 -3
- package/src/TextInput/TextInputBase.jsx +6 -1
- package/src/TextInput/propTypes.js +7 -1
- package/src/ToggleSwitch/ToggleSwitch.jsx +11 -2
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +19 -6
- package/src/utils/containUniqueFields.js +32 -0
- package/src/utils/index.js +1 -0
- package/src/utils/props/handlerProps.js +47 -0
- package/src/utils/props/index.js +1 -0
- package/src/utils/props/inputSupportsProps.js +3 -4
- package/src/utils/props/linkProps.js +3 -6
- package/stories/InputLabel/InputLabel.stories.jsx +25 -28
- package/stories/Modal/Modal.stories.jsx +25 -0
- package/stories/Search/Search.stories.jsx +4 -1
- package/stories/TextInput/TextInput.stories.jsx +40 -2
- package/__tests__/Link/LinkBase.test.jsx +0 -22
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
4
3
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
4
|
+
import View from "react-native-web/dist/exports/View";
|
|
5
|
+
import { variantProp, getTokensPropType, useCopy, copyPropTypes, a11yProps } from '../utils';
|
|
6
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
7
|
+
import IconButton from '../IconButton';
|
|
9
8
|
import dictionary from './dictionary';
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
padding
|
|
18
|
-
}, direction) => [staticStyles.absolute, staticStyles[direction], {
|
|
19
|
-
borderRadius,
|
|
20
|
-
backgroundColor,
|
|
21
|
-
borderColor,
|
|
22
|
-
borderWidth,
|
|
23
|
-
padding
|
|
24
|
-
}];
|
|
11
|
+
const selectContainerStyles = ({
|
|
12
|
+
offset
|
|
13
|
+
}) => ({
|
|
14
|
+
marginTop: offset ? -offset : 0
|
|
15
|
+
});
|
|
25
16
|
/**
|
|
26
17
|
* Button within a Tabs component showing users that content is available to the left or
|
|
27
18
|
* right, scrolling a screen's worth of content left or right when pressed.
|
|
@@ -35,47 +26,31 @@ const selectButtonStyles = ({
|
|
|
35
26
|
const HorizontalScrollButton = /*#__PURE__*/forwardRef(({
|
|
36
27
|
direction = 'next',
|
|
37
28
|
icon,
|
|
38
|
-
onPress,
|
|
39
29
|
offset,
|
|
30
|
+
onPress,
|
|
40
31
|
variant,
|
|
41
32
|
tokens,
|
|
42
33
|
copy
|
|
43
34
|
}, ref) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const resolveButtonTokens = pressableState => resolvePressableTokens(getTokens, pressableState);
|
|
47
|
-
|
|
48
|
-
const getPressableStyle = pressableState => [selectButtonStyles(resolveButtonTokens(pressableState), direction), {
|
|
49
|
-
marginTop: -1 * (offset || 0)
|
|
50
|
-
}];
|
|
51
|
-
|
|
35
|
+
const themeTokens = useThemeTokens('HorizontalScrollButton', tokens, variant);
|
|
52
36
|
const getCopy = useCopy({
|
|
53
37
|
dictionary,
|
|
54
38
|
copy
|
|
55
39
|
});
|
|
56
40
|
const label = direction === 'previous' ? getCopy('previousText') : getCopy('nextText');
|
|
57
|
-
return /*#__PURE__*/_jsx(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}) : /*#__PURE__*/_jsx(Typography, {
|
|
71
|
-
tokens: {
|
|
72
|
-
fontSize: iconTokens.size,
|
|
73
|
-
lineHeight: 1,
|
|
74
|
-
color: iconTokens.color
|
|
75
|
-
},
|
|
76
|
-
children: direction === 'next' ? '→' : '←'
|
|
77
|
-
});
|
|
78
|
-
}
|
|
41
|
+
return /*#__PURE__*/_jsx(View, {
|
|
42
|
+
style: [staticStyles.absolute, staticStyles[direction], selectContainerStyles({
|
|
43
|
+
offset
|
|
44
|
+
})],
|
|
45
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
46
|
+
accessibilityLabel: label,
|
|
47
|
+
icon: icon,
|
|
48
|
+
onPress: onPress,
|
|
49
|
+
ref: ref,
|
|
50
|
+
tokens: themeTokens,
|
|
51
|
+
variant: variant,
|
|
52
|
+
...a11yProps.nonFocusableProps
|
|
53
|
+
})
|
|
79
54
|
});
|
|
80
55
|
});
|
|
81
56
|
HorizontalScrollButton.displayName = 'HorizontalScrollButton';
|
|
@@ -9,6 +9,7 @@ import LabelContent from './LabelContent';
|
|
|
9
9
|
import Tooltip from '../Tooltip';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
13
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
13
14
|
|
|
14
15
|
const selectLabelStyles = tokens => applyTextStyles(selectTokens('Typography', tokens));
|
|
@@ -47,25 +48,29 @@ const InputLabel = /*#__PURE__*/forwardRef(({
|
|
|
47
48
|
const themeTokens = useThemeTokens('InputLabel', tokens, variant);
|
|
48
49
|
const hasTooltip = tooltip !== undefined;
|
|
49
50
|
const isHintInline = hintPosition === 'inline';
|
|
50
|
-
return /*#__PURE__*/_jsxs(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
52
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
53
|
+
ref: ref,
|
|
54
|
+
style: staticStyles.container,
|
|
55
|
+
...selectProps(rest),
|
|
56
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
57
|
+
style: [selectLabelStyles(themeTokens), selectGapStyles(themeTokens), staticStyles.label],
|
|
58
|
+
children: /*#__PURE__*/_jsx(LabelContent, {
|
|
59
|
+
forId: forId,
|
|
60
|
+
children: label
|
|
61
|
+
})
|
|
62
|
+
}), hint && isHintInline && /*#__PURE__*/_jsx(Text, {
|
|
63
|
+
style: [selectHintStyles(themeTokens), hasTooltip && selectGapStyles(themeTokens), staticStyles.label],
|
|
64
|
+
nativeID: hintId,
|
|
65
|
+
children: hint
|
|
66
|
+
}), hasTooltip && /*#__PURE__*/_jsx(View, {
|
|
67
|
+
style: [staticStyles.tooltipAlign, {
|
|
68
|
+
height: themeTokens.fontSize * themeTokens.lineHeight
|
|
69
|
+
}],
|
|
70
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
71
|
+
content: tooltip
|
|
72
|
+
})
|
|
73
|
+
})]
|
|
69
74
|
}), hint && !isHintInline && /*#__PURE__*/_jsx(Text, {
|
|
70
75
|
style: [selectHintStyles(themeTokens), staticStyles.hintBelow],
|
|
71
76
|
nativeID: hintId,
|
|
@@ -111,21 +116,19 @@ InputLabel.propTypes = { ...selectedSystemPropTypes,
|
|
|
111
116
|
export default InputLabel;
|
|
112
117
|
const staticStyles = StyleSheet.create({
|
|
113
118
|
container: {
|
|
114
|
-
|
|
119
|
+
flexShrink: 1,
|
|
115
120
|
flexDirection: 'row',
|
|
116
121
|
alignItems: 'baseline'
|
|
117
122
|
},
|
|
118
|
-
containerWithHintBelow: {
|
|
119
|
-
flexWrap: 'wrap'
|
|
120
|
-
},
|
|
121
123
|
label: {
|
|
122
|
-
flexShrink:
|
|
124
|
+
flexShrink: 1
|
|
123
125
|
},
|
|
124
126
|
hintBelow: {
|
|
125
127
|
flexBasis: '100%',
|
|
126
128
|
flexShrink: 0
|
|
127
129
|
},
|
|
128
130
|
tooltipAlign: {
|
|
129
|
-
alignSelf: '
|
|
131
|
+
alignSelf: 'flex-start',
|
|
132
|
+
justifyContent: 'center'
|
|
130
133
|
}
|
|
131
134
|
});
|
|
@@ -35,13 +35,9 @@ Platform.OS === 'web' ? {
|
|
|
35
35
|
} : {};
|
|
36
36
|
|
|
37
37
|
const selectTextStyles = ({
|
|
38
|
-
color
|
|
39
|
-
textLine,
|
|
40
|
-
textLineStyle
|
|
38
|
+
color
|
|
41
39
|
}) => ({
|
|
42
40
|
color,
|
|
43
|
-
textDecorationLine: textLine,
|
|
44
|
-
textDecorationStyle: textLineStyle,
|
|
45
41
|
...Platform.select({
|
|
46
42
|
web: {
|
|
47
43
|
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
@@ -62,6 +58,22 @@ const selectBlockStyles = ({
|
|
|
62
58
|
fontName: blockFontName
|
|
63
59
|
});
|
|
64
60
|
|
|
61
|
+
const selectDecorationStyles = ({
|
|
62
|
+
color,
|
|
63
|
+
textLine,
|
|
64
|
+
textLineStyle
|
|
65
|
+
}) => ({
|
|
66
|
+
color,
|
|
67
|
+
textDecorationLine: textLine,
|
|
68
|
+
textDecorationStyle: textLineStyle,
|
|
69
|
+
...Platform.select({
|
|
70
|
+
web: {
|
|
71
|
+
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
72
|
+
transition: 'color 200ms'
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
|
|
65
77
|
const selectIconTokens = ({
|
|
66
78
|
color,
|
|
67
79
|
iconSize,
|
|
@@ -138,8 +150,9 @@ const LinkBase = /*#__PURE__*/forwardRef(({
|
|
|
138
150
|
style: linkState => {
|
|
139
151
|
const themeTokens = resolveLinkTokens(linkState);
|
|
140
152
|
const outerBorderStyles = selectOuterBorderStyles(themeTokens);
|
|
153
|
+
const decorationStyles = selectDecorationStyles(themeTokens);
|
|
141
154
|
const hasIcon = Boolean(icon || themeTokens.icon);
|
|
142
|
-
return [outerBorderStyles, blockLeftStyle, hasIcon && staticStyles.rowContainer];
|
|
155
|
+
return [outerBorderStyles, blockLeftStyle, decorationStyles, hasIcon && staticStyles.rowContainer];
|
|
143
156
|
},
|
|
144
157
|
children: linkState => {
|
|
145
158
|
const themeTokens = resolveLinkTokens(linkState);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var _TextButton$propTypes;
|
|
2
|
-
|
|
3
1
|
import React, { forwardRef } from 'react';
|
|
4
2
|
import PropTypes from 'prop-types';
|
|
5
3
|
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
@@ -16,8 +14,6 @@ const TextButton = /*#__PURE__*/forwardRef(({
|
|
|
16
14
|
children,
|
|
17
15
|
variant,
|
|
18
16
|
tokens,
|
|
19
|
-
// TODO: this may need to use `link` role on Web in the case of being passed both `href` and
|
|
20
|
-
// `onPress` in an omniplatform app that uses React Navigation's useLinkProps for internal nav.
|
|
21
17
|
accessibilityRole = 'button',
|
|
22
18
|
...linkProps
|
|
23
19
|
}, ref) => {
|
|
@@ -34,10 +30,5 @@ const TextButton = /*#__PURE__*/forwardRef(({
|
|
|
34
30
|
TextButton.displayName = 'TextButton';
|
|
35
31
|
TextButton.propTypes = { ...LinkBase.propTypes,
|
|
36
32
|
onPress: PropTypes.func.isRequired
|
|
37
|
-
};
|
|
38
|
-
// TODO: test if this works with web navigation in omniplatform React Navigation
|
|
39
|
-
// https://github.com/telus/universal-design-system/issues/665
|
|
40
|
-
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
41
|
-
|
|
42
|
-
if ((_TextButton$propTypes = TextButton.propTypes) !== null && _TextButton$propTypes !== void 0 && _TextButton$propTypes.href) delete TextButton.propTypes.href;
|
|
33
|
+
};
|
|
43
34
|
export default TextButton;
|
|
@@ -6,9 +6,9 @@ import NativeModal from "react-native-web/dist/exports/Modal";
|
|
|
6
6
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { applyShadowToken, useThemeTokens } from '../ThemeProvider';
|
|
9
|
-
import { a11yProps, copyPropTypes, getTokensPropType, selectSystemProps, useCopy, variantProp, viewProps } from '../utils';
|
|
9
|
+
import { a11yProps, copyPropTypes, getTokensPropType, selectSystemProps, useCopy, variantProp, viewProps, selectTokens } from '../utils';
|
|
10
10
|
import { useViewport } from '../ViewportProvider';
|
|
11
|
-
import
|
|
11
|
+
import IconButton from '../IconButton';
|
|
12
12
|
import dictionary from './dictionary';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -65,14 +65,6 @@ const selectCloseButtonContainerStyles = ({
|
|
|
65
65
|
paddingRight,
|
|
66
66
|
paddingTop
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
const selectCloseIconProps = ({
|
|
70
|
-
closeIconSize,
|
|
71
|
-
closeIconColor
|
|
72
|
-
}) => ({
|
|
73
|
-
size: closeIconSize,
|
|
74
|
-
color: closeIconColor
|
|
75
|
-
});
|
|
76
68
|
/**
|
|
77
69
|
* A modal window is a secondary window that opens on top of the main one.
|
|
78
70
|
* Users have to interact with it before they can carry out their task and return to the main window.
|
|
@@ -97,6 +89,7 @@ const Modal = /*#__PURE__*/forwardRef(({
|
|
|
97
89
|
tokens,
|
|
98
90
|
variant,
|
|
99
91
|
copy,
|
|
92
|
+
closeButton,
|
|
100
93
|
...rest
|
|
101
94
|
}, ref) => {
|
|
102
95
|
const viewport = useViewport();
|
|
@@ -119,12 +112,15 @@ const Modal = /*#__PURE__*/forwardRef(({
|
|
|
119
112
|
|
|
120
113
|
const handleKeyUp = event => {
|
|
121
114
|
if (event.key === 'Escape') onClose();
|
|
122
|
-
};
|
|
115
|
+
}; // Show the custom react node passed to `closedButton` or the default close button if `closeButton` is `undefined`.
|
|
116
|
+
// Hide the close button if `closeButton` is `null`.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const showCloseButton = closeButton !== null;
|
|
123
120
|
|
|
124
121
|
if (!isOpen) {
|
|
125
122
|
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
123
|
+
}
|
|
128
124
|
|
|
129
125
|
return /*#__PURE__*/_jsx(NativeModal, {
|
|
130
126
|
transparent: true,
|
|
@@ -139,15 +135,14 @@ const Modal = /*#__PURE__*/forwardRef(({
|
|
|
139
135
|
ref: ref,
|
|
140
136
|
style: [staticStyles.modal, selectModalStyles(themeTokens)],
|
|
141
137
|
onKeyUp: handleKeyUp,
|
|
142
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
138
|
+
children: [showCloseButton && /*#__PURE__*/_jsx(View, {
|
|
143
139
|
style: [staticStyles.closeButtonContainer, selectCloseButtonContainerStyles(themeTokens)],
|
|
144
|
-
children: /*#__PURE__*/_jsx(
|
|
140
|
+
children: closeButton || /*#__PURE__*/_jsx(IconButton, {
|
|
145
141
|
onPress: handleClose,
|
|
142
|
+
icon: CloseIconComponent,
|
|
146
143
|
accessibilityRole: "button",
|
|
147
144
|
accessibilityLabel: closeLabel,
|
|
148
|
-
|
|
149
|
-
() => /*#__PURE__*/_jsx(CloseIconComponent, { ...selectCloseIconProps(themeTokens)
|
|
150
|
-
})
|
|
145
|
+
tokens: selectTokens('IconButton', themeTokens, 'close')
|
|
151
146
|
})
|
|
152
147
|
}), children]
|
|
153
148
|
})
|
|
@@ -168,7 +163,12 @@ Modal.propTypes = { ...selectedSystemPropTypes,
|
|
|
168
163
|
onClose: PropTypes.func,
|
|
169
164
|
maxWidth: PropTypes.bool,
|
|
170
165
|
tokens: getTokensPropType('Modal'),
|
|
171
|
-
variant: variantProp.propType
|
|
166
|
+
variant: variantProp.propType,
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Pass a react node to override the default close button or pass `null` to hide the close button.
|
|
170
|
+
*/
|
|
171
|
+
closeButton: PropTypes.node
|
|
172
172
|
};
|
|
173
173
|
export default Modal;
|
|
174
174
|
const staticStyles = StyleSheet.create({
|
|
@@ -7,11 +7,11 @@ import View from "react-native-web/dist/exports/View";
|
|
|
7
7
|
import RadioLabel from '../InputLabel/LabelContent';
|
|
8
8
|
import RadioButton, { selectRadioButtonTokens } from './RadioButton';
|
|
9
9
|
import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider';
|
|
10
|
-
import { a11yProps, getTokensPropType, selectSystemProps, useInputValue, useUniqueId, variantProp, viewProps } from '../utils';
|
|
10
|
+
import { a11yProps, focusHandlerProps, getTokensPropType, selectSystemProps, useInputValue, useUniqueId, variantProp, viewProps } from '../utils';
|
|
11
11
|
import StackView from '../StackView';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
14
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
|
|
15
15
|
|
|
16
16
|
const selectContainerStyles = ({
|
|
17
17
|
containerBackgroundColor,
|
|
@@ -162,22 +162,29 @@ const Radio = /*#__PURE__*/forwardRef(({
|
|
|
162
162
|
hover,
|
|
163
163
|
pressed
|
|
164
164
|
});
|
|
165
|
+
const labelStyles = selectLabelStyles(stateTokens);
|
|
166
|
+
const alignWithLabel = label ? [staticStyles.alignWithLabel, {
|
|
167
|
+
height: labelStyles.lineHeight
|
|
168
|
+
}] : null;
|
|
165
169
|
return /*#__PURE__*/_jsxs(StackView, {
|
|
166
170
|
space: 0,
|
|
167
171
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
168
172
|
style: [staticStyles.container, selectContainerStyles(stateTokens)],
|
|
169
|
-
children: [/*#__PURE__*/_jsx(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
174
|
+
style: alignWithLabel,
|
|
175
|
+
children: /*#__PURE__*/_jsx(RadioButton, {
|
|
176
|
+
tokens: selectRadioButtonTokens(stateTokens),
|
|
177
|
+
isControlled: isControlled,
|
|
178
|
+
isChecked: isChecked,
|
|
179
|
+
inactive: inactive,
|
|
180
|
+
defaultChecked: defaultChecked,
|
|
181
|
+
inputId: inputId,
|
|
182
|
+
handleChange: handleChange,
|
|
183
|
+
name: inputName,
|
|
184
|
+
value: value
|
|
185
|
+
})
|
|
179
186
|
}), Boolean(label) && /*#__PURE__*/_jsx(Text, {
|
|
180
|
-
style:
|
|
187
|
+
style: labelStyles,
|
|
181
188
|
children: /*#__PURE__*/_jsx(RadioLabel, {
|
|
182
189
|
forId: inputId,
|
|
183
190
|
children: label
|
|
@@ -259,5 +266,9 @@ const staticStyles = StyleSheet.create({
|
|
|
259
266
|
container: {
|
|
260
267
|
flexDirection: 'row',
|
|
261
268
|
alignItems: 'center'
|
|
269
|
+
},
|
|
270
|
+
alignWithLabel: {
|
|
271
|
+
alignSelf: 'flex-start',
|
|
272
|
+
justifyContent: 'center'
|
|
262
273
|
}
|
|
263
274
|
});
|
|
@@ -3,12 +3,13 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import ABBPropTypes from 'airbnb-prop-types';
|
|
4
4
|
import { useViewport } from '../ViewportProvider';
|
|
5
5
|
import { useThemeTokens } from '../ThemeProvider';
|
|
6
|
-
import { a11yProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
|
|
6
|
+
import { a11yProps, containUniqueFields, focusHandlerProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
|
|
7
7
|
import { getStackedContent } from '../StackView';
|
|
8
8
|
import Radio from './Radio';
|
|
9
9
|
import Fieldset from '../Fieldset';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
12
|
+
const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
|
|
12
13
|
/**
|
|
13
14
|
* A group of Radios that behave as a radio group. Use when users select a single choice from mutually
|
|
14
15
|
* exclusive options.
|
|
@@ -92,11 +93,18 @@ const RadioGroup = /*#__PURE__*/forwardRef(({
|
|
|
92
93
|
onChange,
|
|
93
94
|
readOnly: readOnly || inactive
|
|
94
95
|
});
|
|
96
|
+
const uniqueFields = ['id', 'label'];
|
|
97
|
+
|
|
98
|
+
if (!containUniqueFields(items, uniqueFields)) {
|
|
99
|
+
throw new Error(`RadioGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
95
102
|
const radios = items.map(({
|
|
96
103
|
label,
|
|
97
104
|
id,
|
|
98
105
|
onChange: itemOnChange,
|
|
99
|
-
ref: itemRef
|
|
106
|
+
ref: itemRef,
|
|
107
|
+
...itemRest
|
|
100
108
|
}, index) => {
|
|
101
109
|
const radioId = id || `Radio[${index}]`;
|
|
102
110
|
const isChecked = currentValue === radioId;
|
|
@@ -115,7 +123,8 @@ const RadioGroup = /*#__PURE__*/forwardRef(({
|
|
|
115
123
|
label: label,
|
|
116
124
|
name: inputGroupName,
|
|
117
125
|
tokens: radioTokens,
|
|
118
|
-
variant: variant
|
|
126
|
+
variant: variant,
|
|
127
|
+
...selectItemProps(itemRest)
|
|
119
128
|
}, radioId);
|
|
120
129
|
});
|
|
121
130
|
return /*#__PURE__*/_jsx(Fieldset, {
|
|
@@ -157,7 +166,7 @@ RadioGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
157
166
|
/**
|
|
158
167
|
* Array of objects containing specifics for each Radio to be rendered in the group.
|
|
159
168
|
*/
|
|
160
|
-
items: PropTypes.arrayOf(PropTypes.exact({
|
|
169
|
+
items: PropTypes.arrayOf(PropTypes.exact({ ...selectedItemPropTypes,
|
|
161
170
|
label: PropTypes.string,
|
|
162
171
|
id: PropTypes.string,
|
|
163
172
|
onChange: PropTypes.func,
|
|
@@ -4,13 +4,13 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
|
4
4
|
import Text from "react-native-web/dist/exports/Text";
|
|
5
5
|
import View from "react-native-web/dist/exports/View";
|
|
6
6
|
import { useThemeTokensCallback, applyTextStyles } from '../ThemeProvider';
|
|
7
|
-
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, useInputValue, useUniqueId, variantProp, viewProps } from '../utils';
|
|
7
|
+
import { a11yProps, focusHandlerProps, getTokensPropType, selectSystemProps, selectTokens, useInputValue, useUniqueId, variantProp, viewProps } from '../utils';
|
|
8
8
|
import { PressableCardBase, selectPressableCardTokens } from '../Card';
|
|
9
9
|
import StackView from '../StackView';
|
|
10
10
|
import RadioButton, { selectRadioButtonTokens } from '../Radio/RadioButton';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
13
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
|
|
14
14
|
/**
|
|
15
15
|
* A Card that behaves like a radio button. Use when users select a single choice from mutually exclusive options
|
|
16
16
|
* with need to show additional information for each option. The whole card is interactive as one item.
|
|
@@ -2,12 +2,13 @@ import React, { forwardRef } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useViewport } from '../ViewportProvider';
|
|
4
4
|
import { useThemeTokens } from '../ThemeProvider';
|
|
5
|
-
import { a11yProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
|
|
5
|
+
import { a11yProps, containUniqueFields, focusHandlerProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
|
|
6
6
|
import StackView, { StackWrap } from '../StackView';
|
|
7
7
|
import RadioCard from './RadioCard';
|
|
8
8
|
import Fieldset from '../Fieldset';
|
|
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, viewProps]);
|
|
11
12
|
/**
|
|
12
13
|
* A group of Cards that behave as a radio button group. Use when users select a single choice from mutually
|
|
13
14
|
* exclusive options with need to show additional information for each option. The whole cards are each
|
|
@@ -98,6 +99,12 @@ const RadioCardGroup = /*#__PURE__*/forwardRef(({
|
|
|
98
99
|
// and also needs 'radiogroup' role on fieldset for correct description on focusing the set.
|
|
99
100
|
// TODO: test this on more web screen readers.
|
|
100
101
|
|
|
102
|
+
const uniqueFields = ['id'];
|
|
103
|
+
|
|
104
|
+
if (!containUniqueFields(items, uniqueFields)) {
|
|
105
|
+
throw new Error(`RadioCardGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
101
108
|
return /*#__PURE__*/_jsx(Fieldset, {
|
|
102
109
|
ref: ref,
|
|
103
110
|
name: inputGroupName,
|
|
@@ -117,7 +124,8 @@ const RadioCardGroup = /*#__PURE__*/forwardRef(({
|
|
|
117
124
|
title,
|
|
118
125
|
content,
|
|
119
126
|
id,
|
|
120
|
-
onChange: itemOnChange
|
|
127
|
+
onChange: itemOnChange,
|
|
128
|
+
...itemRest
|
|
121
129
|
}, index) => {
|
|
122
130
|
const cardId = id || `RadioCard[${index}]`;
|
|
123
131
|
|
|
@@ -136,6 +144,7 @@ const RadioCardGroup = /*#__PURE__*/forwardRef(({
|
|
|
136
144
|
tokens: radioCardTokens,
|
|
137
145
|
variant: variant,
|
|
138
146
|
readOnly: readOnly,
|
|
147
|
+
...selectItemProps(itemRest),
|
|
139
148
|
...props,
|
|
140
149
|
children: content
|
|
141
150
|
}, cardId);
|
|
@@ -164,7 +173,7 @@ RadioCardGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
164
173
|
/**
|
|
165
174
|
* Array of objects containing specifics for each RadioCard to be rendered in the group.
|
|
166
175
|
*/
|
|
167
|
-
items: PropTypes.arrayOf(PropTypes.exact({
|
|
176
|
+
items: PropTypes.arrayOf(PropTypes.exact({ ...selectedItemPropTypes,
|
|
168
177
|
title: PropTypes.string,
|
|
169
178
|
content: PropTypes.node,
|
|
170
179
|
id: PropTypes.string,
|
|
@@ -197,7 +197,7 @@ const Select = /*#__PURE__*/forwardRef(({
|
|
|
197
197
|
const handleMouseOut = () => setIsHovered(false);
|
|
198
198
|
|
|
199
199
|
const {
|
|
200
|
-
|
|
200
|
+
supportsProps,
|
|
201
201
|
...selectedProps
|
|
202
202
|
} = selectProps(rest);
|
|
203
203
|
const themeTokens = useThemeTokens('Select', tokens, variant, {
|
|
@@ -238,8 +238,7 @@ const Select = /*#__PURE__*/forwardRef(({
|
|
|
238
238
|
}), ValidationIconComponent && /*#__PURE__*/_jsx(View, {
|
|
239
239
|
pointerEvents: "none",
|
|
240
240
|
style: [staticStyles.iconContainer, selectValidationIconContainerStyles(themeTokens)],
|
|
241
|
-
children: /*#__PURE__*/_jsx(ValidationIconComponent, {
|
|
242
|
-
tokens: selectValidationIconTokens(themeTokens)
|
|
241
|
+
children: /*#__PURE__*/_jsx(ValidationIconComponent, { ...selectValidationIconTokens(themeTokens)
|
|
243
242
|
})
|
|
244
243
|
}), IconComponent && Platform.OS !== 'android' &&
|
|
245
244
|
/*#__PURE__*/
|
package/lib-module/Tags/Tags.js
CHANGED
|
@@ -9,11 +9,11 @@ import Icon from '../Icon';
|
|
|
9
9
|
import { StackWrap, getStackedContent } from '../StackView';
|
|
10
10
|
import { useViewport } from '../ViewportProvider';
|
|
11
11
|
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
12
|
-
import { a11yProps, getTokensPropType, pressProps, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils
|
|
13
|
-
import { useMultipleInputValues } from '../utils/input';
|
|
12
|
+
import { a11yProps, containUniqueFields, focusHandlerProps, getTokensPropType, pressProps, selectSystemProps, selectTokens, useMultipleInputValues, variantProp, viewProps } from '../utils';
|
|
14
13
|
import { getPressHandlersWithArgs } from '../utils/pressability';
|
|
15
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps,
|
|
15
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
16
|
+
const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, pressProps, viewProps]);
|
|
17
17
|
|
|
18
18
|
const selectIconTextTokens = ({
|
|
19
19
|
icon,
|
|
@@ -95,6 +95,12 @@ const Tags = /*#__PURE__*/forwardRef(({
|
|
|
95
95
|
...rest
|
|
96
96
|
});
|
|
97
97
|
const itemA11yRole = 'checkbox';
|
|
98
|
+
const uniqueFields = ['id', 'label'];
|
|
99
|
+
|
|
100
|
+
if (!containUniqueFields(items, uniqueFields)) {
|
|
101
|
+
throw new Error(`Tags items must have unique ${uniqueFields.join(', ')}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
98
104
|
return /*#__PURE__*/_jsx(StackWrap, {
|
|
99
105
|
ref: ref,
|
|
100
106
|
...selectedProps,
|
|
@@ -104,8 +110,8 @@ const Tags = /*#__PURE__*/forwardRef(({
|
|
|
104
110
|
children: items.map(({
|
|
105
111
|
label,
|
|
106
112
|
id = label,
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
ref: itemRef,
|
|
114
|
+
...itemRest
|
|
109
115
|
}, index) => {
|
|
110
116
|
const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
111
117
|
|
|
@@ -116,17 +122,17 @@ const Tags = /*#__PURE__*/forwardRef(({
|
|
|
116
122
|
}]);
|
|
117
123
|
|
|
118
124
|
const handlePress = event => {
|
|
119
|
-
if (pressHandlers.onPress) pressHandlers.onPress();
|
|
125
|
+
if (pressHandlers.onPress) pressHandlers.onPress(event);
|
|
120
126
|
toggleOneValue(id, event);
|
|
121
127
|
};
|
|
122
128
|
|
|
123
|
-
const
|
|
129
|
+
const itemProps = {
|
|
124
130
|
accessibilityState: {
|
|
125
131
|
checked: isSelected
|
|
126
132
|
},
|
|
127
133
|
accessibilityRole: itemA11yRole,
|
|
128
|
-
|
|
129
|
-
...
|
|
134
|
+
...a11yProps.getPositionInSet(items.length, index),
|
|
135
|
+
...selectItemProps(itemRest)
|
|
130
136
|
};
|
|
131
137
|
return /*#__PURE__*/_jsx(ButtonBase, {
|
|
132
138
|
ref: itemRef,
|
|
@@ -135,7 +141,7 @@ const Tags = /*#__PURE__*/forwardRef(({
|
|
|
135
141
|
tokens: getButtonTokens,
|
|
136
142
|
selected: isSelected,
|
|
137
143
|
inactive: inactive,
|
|
138
|
-
...
|
|
144
|
+
...itemProps,
|
|
139
145
|
children: ({
|
|
140
146
|
textStyles,
|
|
141
147
|
...buttonState
|
|
@@ -188,7 +194,8 @@ Tags.propTypes = { ...selectedSystemPropTypes,
|
|
|
188
194
|
/**
|
|
189
195
|
* The options a user may select
|
|
190
196
|
*/
|
|
191
|
-
items: PropTypes.arrayOf(PropTypes.shape({
|
|
197
|
+
items: PropTypes.arrayOf(PropTypes.shape({ ...selectedItemPropTypes,
|
|
198
|
+
|
|
192
199
|
/**
|
|
193
200
|
* The text displayed to the user in the button, describing this option,
|
|
194
201
|
* passed to the button as its child.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef, useState } from 'react';
|
|
2
2
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
3
|
-
import { a11yProps, getTokensPropType, inputSupportsProps, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
3
|
+
import { a11yProps, focusHandlerProps, getTokensPropType, inputSupportsProps, selectSystemProps, textInputHandlerProps, variantProp, viewProps } from '../utils';
|
|
4
4
|
import InputSupports from '../InputSupports';
|
|
5
5
|
import TextInputBase from './TextInputBase';
|
|
6
6
|
import { useThemeTokens } from '../ThemeProvider';
|
|
7
7
|
import textInputPropTypes from './propTypes';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, inputSupportsProps, viewProps]);
|
|
9
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, inputSupportsProps, textInputHandlerProps, viewProps]);
|
|
10
10
|
/**
|
|
11
11
|
* Use to collect long-form information such as product feedback or support queries.
|
|
12
12
|
* Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
|
|
@@ -54,7 +54,7 @@ const TextArea = /*#__PURE__*/forwardRef(({
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const {
|
|
57
|
-
|
|
57
|
+
supportsProps,
|
|
58
58
|
...selectedProps
|
|
59
59
|
} = selectProps(rest);
|
|
60
60
|
const inputProps = { ...selectedProps,
|