@telus-uds/components-base 1.5.0 → 1.6.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/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-lint.log +13 -0
- package/CHANGELOG.json +98 -1
- package/CHANGELOG.md +24 -2
- package/__tests__/FlexGrid/Row.test.jsx +100 -25
- package/__tests__/utils/containUniqueFields.test.js +25 -0
- package/component-docs.json +18 -2
- 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/InputLabel/InputLabel.js +27 -25
- package/lib/Link/LinkBase.js +19 -6
- 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-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/InputLabel/InputLabel.js +28 -25
- package/lib-module/Link/LinkBase.js +19 -6
- 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/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/InputLabel/InputLabel.jsx +36 -27
- package/src/Link/LinkBase.jsx +20 -4
- 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/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/lib/Tags/Tags.js
CHANGED
|
@@ -27,9 +27,7 @@ var _ViewportProvider = require("../ViewportProvider");
|
|
|
27
27
|
|
|
28
28
|
var _ThemeProvider = require("../ThemeProvider");
|
|
29
29
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var _input = require("../utils/input");
|
|
30
|
+
var _utils = require("../utils");
|
|
33
31
|
|
|
34
32
|
var _pressability = require("../utils/pressability");
|
|
35
33
|
|
|
@@ -41,7 +39,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
41
39
|
|
|
42
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
41
|
|
|
44
|
-
const [selectProps, selectedSystemPropTypes] = (0,
|
|
42
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
43
|
+
const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.pressProps, _utils.viewProps]);
|
|
45
44
|
|
|
46
45
|
const selectIconTextTokens = ({
|
|
47
46
|
icon,
|
|
@@ -99,19 +98,19 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
99
98
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Tags', tokens, variant, {
|
|
100
99
|
viewport
|
|
101
100
|
});
|
|
102
|
-
const stackTokens = (0,
|
|
101
|
+
const stackTokens = (0, _utils.selectTokens)('StackView', themeTokens);
|
|
103
102
|
const {
|
|
104
103
|
direction,
|
|
105
104
|
space
|
|
106
105
|
} = themeTokens;
|
|
107
106
|
const getItemTokens = (0, _ThemeProvider.useThemeTokensCallback)('TagsItem', tokens, variant);
|
|
108
107
|
|
|
109
|
-
const getButtonTokens = buttonState => (0,
|
|
108
|
+
const getButtonTokens = buttonState => (0, _utils.selectTokens)('Button', getItemTokens(buttonState));
|
|
110
109
|
|
|
111
110
|
const {
|
|
112
111
|
currentValues,
|
|
113
112
|
toggleOneValue
|
|
114
|
-
} = (0,
|
|
113
|
+
} = (0, _utils.useMultipleInputValues)({
|
|
115
114
|
initialValues,
|
|
116
115
|
values,
|
|
117
116
|
maxValues,
|
|
@@ -123,6 +122,12 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
123
122
|
...rest
|
|
124
123
|
});
|
|
125
124
|
const itemA11yRole = 'checkbox';
|
|
125
|
+
const uniqueFields = ['id', 'label'];
|
|
126
|
+
|
|
127
|
+
if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
|
|
128
|
+
throw new Error(`Tags items must have unique ${uniqueFields.join(', ')}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
126
131
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, {
|
|
127
132
|
ref: ref,
|
|
128
133
|
...selectedProps,
|
|
@@ -132,8 +137,8 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
132
137
|
children: items.map(({
|
|
133
138
|
label,
|
|
134
139
|
id = label,
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
ref: itemRef,
|
|
141
|
+
...itemRest
|
|
137
142
|
}, index) => {
|
|
138
143
|
const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
139
144
|
|
|
@@ -144,17 +149,17 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
144
149
|
}]);
|
|
145
150
|
|
|
146
151
|
const handlePress = event => {
|
|
147
|
-
if (pressHandlers.onPress) pressHandlers.onPress();
|
|
152
|
+
if (pressHandlers.onPress) pressHandlers.onPress(event);
|
|
148
153
|
toggleOneValue(id, event);
|
|
149
154
|
};
|
|
150
155
|
|
|
151
|
-
const
|
|
156
|
+
const itemProps = {
|
|
152
157
|
accessibilityState: {
|
|
153
158
|
checked: isSelected
|
|
154
159
|
},
|
|
155
160
|
accessibilityRole: itemA11yRole,
|
|
156
|
-
|
|
157
|
-
...
|
|
161
|
+
..._utils.a11yProps.getPositionInSet(items.length, index),
|
|
162
|
+
...selectItemProps(itemRest)
|
|
158
163
|
};
|
|
159
164
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
160
165
|
ref: itemRef,
|
|
@@ -163,7 +168,7 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
163
168
|
tokens: getButtonTokens,
|
|
164
169
|
selected: isSelected,
|
|
165
170
|
inactive: inactive,
|
|
166
|
-
...
|
|
171
|
+
...itemProps,
|
|
167
172
|
children: ({
|
|
168
173
|
textStyles,
|
|
169
174
|
...buttonState
|
|
@@ -203,8 +208,8 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
203
208
|
});
|
|
204
209
|
Tags.displayName = 'Tags';
|
|
205
210
|
Tags.propTypes = { ...selectedSystemPropTypes,
|
|
206
|
-
tokens: (0,
|
|
207
|
-
variant:
|
|
211
|
+
tokens: (0, _utils.getTokensPropType)('Tags'),
|
|
212
|
+
variant: _utils.variantProp.propType,
|
|
208
213
|
|
|
209
214
|
/**
|
|
210
215
|
* If provided, sets a maximum number of items a user may select at once.
|
|
@@ -214,7 +219,8 @@ Tags.propTypes = { ...selectedSystemPropTypes,
|
|
|
214
219
|
/**
|
|
215
220
|
* The options a user may select
|
|
216
221
|
*/
|
|
217
|
-
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
222
|
+
items: _propTypes.default.arrayOf(_propTypes.default.shape({ ...selectedItemPropTypes,
|
|
223
|
+
|
|
218
224
|
/**
|
|
219
225
|
* The text displayed to the user in the button, describing this option,
|
|
220
226
|
* passed to the button as its child.
|
|
@@ -27,7 +27,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
27
|
|
|
28
28
|
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; }
|
|
29
29
|
|
|
30
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.inputSupportsProps, _utils.viewProps]);
|
|
30
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.viewProps]);
|
|
31
31
|
/**
|
|
32
32
|
* Use to collect long-form information such as product feedback or support queries.
|
|
33
33
|
* Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
|
|
@@ -75,7 +75,7 @@ const TextArea = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
const {
|
|
78
|
-
|
|
78
|
+
supportsProps,
|
|
79
79
|
...selectedProps
|
|
80
80
|
} = selectProps(rest);
|
|
81
81
|
const inputProps = { ...selectedProps,
|
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
+
|
|
10
12
|
var _utils = require("../utils");
|
|
11
13
|
|
|
12
14
|
var _InputSupports = _interopRequireDefault(require("../InputSupports"));
|
|
@@ -23,7 +25,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
23
25
|
|
|
24
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; }
|
|
25
27
|
|
|
26
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.inputSupportsProps, _utils.viewProps]);
|
|
28
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.viewProps]);
|
|
27
29
|
/**
|
|
28
30
|
* A basic text input component. Use in forms or individually to receive user's input.
|
|
29
31
|
* Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
|
|
@@ -46,10 +48,18 @@ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_u
|
|
|
46
48
|
const TextInput = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
47
49
|
tokens,
|
|
48
50
|
variant = {},
|
|
51
|
+
pattern,
|
|
49
52
|
...rest
|
|
50
53
|
}, ref) => {
|
|
54
|
+
_react.default.useEffect(() => {
|
|
55
|
+
if (_Platform.default.OS === 'web' && pattern && ref.current) {
|
|
56
|
+
// eslint-disable-next-line no-param-reassign
|
|
57
|
+
ref.current.pattern = pattern;
|
|
58
|
+
}
|
|
59
|
+
}, [ref, pattern]);
|
|
60
|
+
|
|
51
61
|
const {
|
|
52
|
-
|
|
62
|
+
supportsProps,
|
|
53
63
|
...selectedProps
|
|
54
64
|
} = selectProps(rest);
|
|
55
65
|
const inputProps = { ...selectedProps,
|
|
@@ -29,7 +29,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
29
29
|
|
|
30
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
31
|
|
|
32
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
32
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.textInputHandlerProps, _utils.viewProps]);
|
|
33
33
|
|
|
34
34
|
const selectInputStyles = ({
|
|
35
35
|
backgroundColor,
|
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
+
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
13
|
|
|
12
14
|
const textInputPropTypes = {
|
|
@@ -36,7 +38,12 @@ const textInputPropTypes = {
|
|
|
36
38
|
* Use to react upon input's value changes. Required when the `value` prop is set.
|
|
37
39
|
* Will receive the input's value as an argument.
|
|
38
40
|
*/
|
|
39
|
-
onChange: _propTypes.default.func
|
|
41
|
+
onChange: _propTypes.default.func,
|
|
42
|
+
..._Platform.default.select({
|
|
43
|
+
web: {
|
|
44
|
+
pattern: _propTypes.default.string
|
|
45
|
+
}
|
|
46
|
+
})
|
|
40
47
|
};
|
|
41
48
|
var _default = textInputPropTypes;
|
|
42
49
|
exports.default = _default;
|
|
@@ -35,7 +35,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
35
35
|
|
|
36
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
37
|
|
|
38
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.pressProps, _utils.viewProps]);
|
|
38
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.pressProps, _utils.viewProps]);
|
|
39
39
|
|
|
40
40
|
const selectButtonTokens = tokens => (0, _utils.selectTokens)('Button', { ...tokens,
|
|
41
41
|
// Width tokens are applied to our inner track. Disable Button width token so it wraps our track width.
|
|
@@ -141,7 +141,7 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
141
141
|
space: 2,
|
|
142
142
|
direction: "row",
|
|
143
143
|
children: [Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
144
|
-
style: selectLabelStyles(themeTokens),
|
|
144
|
+
style: [selectLabelStyles(themeTokens), staticStyles.containText],
|
|
145
145
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, {
|
|
146
146
|
forId: inputId,
|
|
147
147
|
label: label,
|
|
@@ -244,6 +244,9 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
244
244
|
switch: {
|
|
245
245
|
alignItems: 'center',
|
|
246
246
|
justifyContent: 'center'
|
|
247
|
+
},
|
|
248
|
+
containText: {
|
|
249
|
+
flexShrink: 1
|
|
247
250
|
}
|
|
248
251
|
});
|
|
249
252
|
|
|
@@ -23,9 +23,7 @@ var _ViewportProvider = require("../ViewportProvider");
|
|
|
23
23
|
|
|
24
24
|
var _ThemeProvider = require("../ThemeProvider");
|
|
25
25
|
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
var _input = require("../utils/input");
|
|
26
|
+
var _utils = require("../utils");
|
|
29
27
|
|
|
30
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
29
|
|
|
@@ -35,7 +33,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
35
33
|
|
|
36
34
|
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
35
|
|
|
38
|
-
const [selectProps, selectedSystemPropTypes] = (0,
|
|
36
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
37
|
+
const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
|
|
39
38
|
const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
40
39
|
variant,
|
|
41
40
|
tokens,
|
|
@@ -70,7 +69,7 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
70
69
|
const {
|
|
71
70
|
currentValues,
|
|
72
71
|
toggleOneValue
|
|
73
|
-
} = (0,
|
|
72
|
+
} = (0, _utils.useMultipleInputValues)({
|
|
74
73
|
initialValues,
|
|
75
74
|
values,
|
|
76
75
|
maxValues,
|
|
@@ -82,13 +81,20 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
82
81
|
...rest
|
|
83
82
|
});
|
|
84
83
|
const itemA11yRole = selectedProps.accessibilityRole === 'radiogroup' ? 'radio' : 'switch';
|
|
84
|
+
const uniqueFields = ['id', 'label'];
|
|
85
|
+
|
|
86
|
+
if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
|
|
87
|
+
throw new Error(`ToggleSwitchGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
85
90
|
const toggleSwitches = items.map(({
|
|
86
91
|
label,
|
|
87
92
|
id = label,
|
|
88
93
|
accessibilityLabel = label,
|
|
89
94
|
onChange: itemOnChange,
|
|
90
95
|
ref: itemRef,
|
|
91
|
-
tooltip: itemTooltip
|
|
96
|
+
tooltip: itemTooltip,
|
|
97
|
+
...itemRest
|
|
92
98
|
}, index) => {
|
|
93
99
|
const isSelected = currentValues.includes(id);
|
|
94
100
|
|
|
@@ -103,7 +109,7 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
103
109
|
},
|
|
104
110
|
accessibilityRole: itemA11yRole,
|
|
105
111
|
accessibilityLabel,
|
|
106
|
-
...
|
|
112
|
+
..._utils.a11yProps.getPositionInSet(items.length, index)
|
|
107
113
|
};
|
|
108
114
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleSwitch.default, {
|
|
109
115
|
id: id,
|
|
@@ -114,7 +120,8 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
114
120
|
inactive: inactive,
|
|
115
121
|
label: label,
|
|
116
122
|
tooltip: itemTooltip,
|
|
117
|
-
...itemA11y
|
|
123
|
+
...itemA11y,
|
|
124
|
+
...selectItemProps(itemRest)
|
|
118
125
|
}, id);
|
|
119
126
|
});
|
|
120
127
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
|
|
@@ -136,8 +143,8 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
136
143
|
});
|
|
137
144
|
ToggleSwitchGroup.displayName = 'ToggleSwitchGroup';
|
|
138
145
|
ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
|
|
139
|
-
tokens: (0,
|
|
140
|
-
variant:
|
|
146
|
+
tokens: (0, _utils.getTokensPropType)('ToggleSwitchGroup'),
|
|
147
|
+
variant: _utils.variantProp.propType,
|
|
141
148
|
|
|
142
149
|
/**
|
|
143
150
|
* The maximum number of items a user may select at once. Defaults to 1 and behaves
|
|
@@ -148,7 +155,8 @@ ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
148
155
|
/**
|
|
149
156
|
* The options a user may select
|
|
150
157
|
*/
|
|
151
|
-
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
158
|
+
items: _propTypes.default.arrayOf(_propTypes.default.shape({ ...selectedItemPropTypes,
|
|
159
|
+
|
|
152
160
|
/**
|
|
153
161
|
* The text displayed to the user on the label.
|
|
154
162
|
*/
|
|
@@ -217,7 +225,7 @@ ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
217
225
|
/**
|
|
218
226
|
* Toggle switch token overrides.
|
|
219
227
|
*/
|
|
220
|
-
toggleSwitchTokens: (0,
|
|
228
|
+
toggleSwitchTokens: (0, _utils.getTokensPropType)('ToggleSwitch'),
|
|
221
229
|
|
|
222
230
|
/**
|
|
223
231
|
* Current validation status of the group, passed to the feedback element if there is one.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
// Returns true if there are no duplicate values of the fields listed
|
|
9
|
+
// in the `fields` array across the objects in the `items` array, false
|
|
10
|
+
// otherwise.
|
|
11
|
+
// Note that if a value of a field in an item is not set, it will be
|
|
12
|
+
// excluded from comparison.
|
|
13
|
+
const containUniqueFields = (items, fields) => {
|
|
14
|
+
const map = [];
|
|
15
|
+
const itemsHaveDuplicateFields = items.some(item => fields.some(field => {
|
|
16
|
+
if (!map[field]) {
|
|
17
|
+
map[field] = [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!item[field]) {
|
|
21
|
+
// We exclude empty values from comparison
|
|
22
|
+
return false;
|
|
23
|
+
} // Duplicate found!
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if (map[field][item[field]]) return true;
|
|
27
|
+
map[field][item[field]] = true;
|
|
28
|
+
return false;
|
|
29
|
+
}));
|
|
30
|
+
return !itemsHaveDuplicateFields;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var _default = containUniqueFields;
|
|
34
|
+
exports.default = _default;
|
package/lib/utils/index.js
CHANGED
|
@@ -10,7 +10,8 @@ var _exportNames = {
|
|
|
10
10
|
useSpacingScale: true,
|
|
11
11
|
useResponsiveProp: true,
|
|
12
12
|
useUniqueId: true,
|
|
13
|
-
withLinkRouter: true
|
|
13
|
+
withLinkRouter: true,
|
|
14
|
+
containUniqueFields: true
|
|
14
15
|
};
|
|
15
16
|
Object.defineProperty(exports, "info", {
|
|
16
17
|
enumerable: true,
|
|
@@ -54,6 +55,12 @@ Object.defineProperty(exports, "withLinkRouter", {
|
|
|
54
55
|
return _withLinkRouter.default;
|
|
55
56
|
}
|
|
56
57
|
});
|
|
58
|
+
Object.defineProperty(exports, "containUniqueFields", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return _containUniqueFields.default;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
57
64
|
|
|
58
65
|
var _a11y = require("./a11y");
|
|
59
66
|
|
|
@@ -179,6 +186,8 @@ Object.keys(_ssr).forEach(function (key) {
|
|
|
179
186
|
});
|
|
180
187
|
});
|
|
181
188
|
|
|
189
|
+
var _containUniqueFields = _interopRequireDefault(require("./containUniqueFields"));
|
|
190
|
+
|
|
182
191
|
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); }
|
|
183
192
|
|
|
184
193
|
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; }
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.textInputHandlerProps = exports.focusHandlerProps = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const focusHandlerProps = {
|
|
13
|
+
types: {
|
|
14
|
+
/**
|
|
15
|
+
* onBlur handler
|
|
16
|
+
*/
|
|
17
|
+
onBlur: _propTypes.default.func,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* onFocus handler
|
|
21
|
+
*/
|
|
22
|
+
onFocus: _propTypes.default.func
|
|
23
|
+
},
|
|
24
|
+
select: ({
|
|
25
|
+
onBlur,
|
|
26
|
+
onFocus
|
|
27
|
+
}) => ({
|
|
28
|
+
onBlur,
|
|
29
|
+
onFocus
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
exports.focusHandlerProps = focusHandlerProps;
|
|
33
|
+
const textInputHandlerProps = {
|
|
34
|
+
types: {
|
|
35
|
+
/**
|
|
36
|
+
* onChange handler
|
|
37
|
+
*/
|
|
38
|
+
onChange: _propTypes.default.func,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* onChangeText handler
|
|
42
|
+
*/
|
|
43
|
+
onChangeText: _propTypes.default.func,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* onSubmit handler
|
|
47
|
+
*/
|
|
48
|
+
onSubmit: _propTypes.default.func,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* onSubmitEditing handler
|
|
52
|
+
*/
|
|
53
|
+
onSubmitEditing: _propTypes.default.func
|
|
54
|
+
},
|
|
55
|
+
select: ({
|
|
56
|
+
onChange,
|
|
57
|
+
onChangeText,
|
|
58
|
+
onSubmit,
|
|
59
|
+
onSubmitEditing
|
|
60
|
+
}) => ({
|
|
61
|
+
onChange,
|
|
62
|
+
onChangeText,
|
|
63
|
+
onSubmit,
|
|
64
|
+
onSubmitEditing
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
exports.textInputHandlerProps = textInputHandlerProps;
|
|
68
|
+
var _default = {
|
|
69
|
+
focusHandlerProps,
|
|
70
|
+
textInputHandlerProps
|
|
71
|
+
};
|
|
72
|
+
exports.default = _default;
|
package/lib/utils/props/index.js
CHANGED
|
@@ -125,6 +125,20 @@ Object.keys(_tokens).forEach(function (key) {
|
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
var _handlerProps = require("./handlerProps");
|
|
129
|
+
|
|
130
|
+
Object.keys(_handlerProps).forEach(function (key) {
|
|
131
|
+
if (key === "default" || key === "__esModule") return;
|
|
132
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
133
|
+
if (key in exports && exports[key] === _handlerProps[key]) return;
|
|
134
|
+
Object.defineProperty(exports, key, {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function () {
|
|
137
|
+
return _handlerProps[key];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
128
142
|
var _a11yProps = _interopRequireDefault(require("./a11yProps"));
|
|
129
143
|
|
|
130
144
|
var _clickProps = _interopRequireDefault(require("./clickProps"));
|
|
@@ -48,18 +48,16 @@ var _default = {
|
|
|
48
48
|
hintPosition,
|
|
49
49
|
feedback,
|
|
50
50
|
tooltip,
|
|
51
|
-
validation
|
|
52
|
-
...rest
|
|
51
|
+
validation
|
|
53
52
|
}) => ({
|
|
54
|
-
|
|
53
|
+
supportsProps: {
|
|
55
54
|
label,
|
|
56
55
|
hint,
|
|
57
56
|
hintPosition,
|
|
58
57
|
feedback,
|
|
59
58
|
tooltip,
|
|
60
59
|
validation
|
|
61
|
-
}
|
|
62
|
-
...rest
|
|
60
|
+
}
|
|
63
61
|
})
|
|
64
62
|
};
|
|
65
63
|
exports.default = _default;
|
|
@@ -6,9 +6,9 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
|
6
6
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
7
7
|
import { applyTextStyles, applyShadowToken, applyOuterBorder } from '../ThemeProvider/utils';
|
|
8
8
|
import buttonPropTypes from './propTypes';
|
|
9
|
-
import { a11yProps,
|
|
9
|
+
import { a11yProps, clickProps, focusHandlerProps, getCursorStyle, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, viewProps, wrapStringsInText, withLinkRouter } from '../utils';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps]);
|
|
11
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, linkProps, viewProps]);
|
|
12
12
|
|
|
13
13
|
const getOuterBorderOffset = ({
|
|
14
14
|
outerBorderGap = 0,
|
|
@@ -6,11 +6,11 @@ import ButtonBase from './ButtonBase';
|
|
|
6
6
|
import { StackWrap } from '../StackView';
|
|
7
7
|
import { useViewport } from '../ViewportProvider';
|
|
8
8
|
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
9
|
-
import { a11yProps, pressProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils
|
|
10
|
-
import { useMultipleInputValues } from '../utils/input';
|
|
9
|
+
import { a11yProps, containUniqueFields, focusHandlerProps, pressProps, getTokensPropType, selectSystemProps, selectTokens, useMultipleInputValues, variantProp, viewProps } from '../utils';
|
|
11
10
|
import { getPressHandlersWithArgs } from '../utils/pressability';
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps,
|
|
12
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
13
|
+
const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, pressProps, viewProps]);
|
|
14
14
|
const ButtonGroup = /*#__PURE__*/forwardRef(({
|
|
15
15
|
variant,
|
|
16
16
|
tokens,
|
|
@@ -53,6 +53,12 @@ const ButtonGroup = /*#__PURE__*/forwardRef(({
|
|
|
53
53
|
...rest
|
|
54
54
|
});
|
|
55
55
|
const itemA11yRole = systemProps.accessibilityRole === 'radiogroup' ? 'radio' : 'checkbox';
|
|
56
|
+
const uniqueFields = ['id', 'label'];
|
|
57
|
+
|
|
58
|
+
if (!containUniqueFields(items, uniqueFields)) {
|
|
59
|
+
throw new Error(`ButtonGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
return /*#__PURE__*/_jsx(StackWrap, { ...systemProps,
|
|
57
63
|
space: space,
|
|
58
64
|
direction: direction,
|
|
@@ -62,7 +68,8 @@ const ButtonGroup = /*#__PURE__*/forwardRef(({
|
|
|
62
68
|
label,
|
|
63
69
|
id = label,
|
|
64
70
|
accessibilityLabel,
|
|
65
|
-
ref: itemRef
|
|
71
|
+
ref: itemRef,
|
|
72
|
+
...itemRest
|
|
66
73
|
}, index) => {
|
|
67
74
|
const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
68
75
|
|
|
@@ -73,7 +80,7 @@ const ButtonGroup = /*#__PURE__*/forwardRef(({
|
|
|
73
80
|
}]);
|
|
74
81
|
|
|
75
82
|
const handlePress = event => {
|
|
76
|
-
if (pressHandlers.onPress) pressHandlers.onPress();
|
|
83
|
+
if (pressHandlers.onPress) pressHandlers.onPress(event);
|
|
77
84
|
toggleOneValue(id, event);
|
|
78
85
|
};
|
|
79
86
|
|
|
@@ -95,6 +102,7 @@ const ButtonGroup = /*#__PURE__*/forwardRef(({
|
|
|
95
102
|
selected: isSelected,
|
|
96
103
|
inactive: inactive,
|
|
97
104
|
...itemA11y,
|
|
105
|
+
...selectItemProps(itemRest),
|
|
98
106
|
children: label
|
|
99
107
|
}, id);
|
|
100
108
|
})
|
|
@@ -114,7 +122,8 @@ ButtonGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
114
122
|
/**
|
|
115
123
|
* The options a user may select
|
|
116
124
|
*/
|
|
117
|
-
items: PropTypes.arrayOf(PropTypes.shape({
|
|
125
|
+
items: PropTypes.arrayOf(PropTypes.shape({ ...selectedItemPropTypes,
|
|
126
|
+
|
|
118
127
|
/**
|
|
119
128
|
* The text displayed to the user in the button, describing this option,
|
|
120
129
|
* passed to the button as its child.
|
|
@@ -4,10 +4,10 @@ import Pressable from "react-native-web/dist/exports/Pressable";
|
|
|
4
4
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
5
|
import { useViewport } from '../ViewportProvider';
|
|
6
6
|
import { applyOuterBorder, validateThemeTokens } from '../ThemeProvider';
|
|
7
|
-
import { a11yProps, clickProps, getTokenNames, getTokensSetPropType, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
7
|
+
import { a11yProps, clickProps, focusHandlerProps, getTokenNames, getTokensSetPropType, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
8
8
|
import CardBase from './CardBase';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
|
|
11
11
|
const tokenKeys = [...getTokenNames('Card'), // Outer border tokens. TODO: centralise common token sets like these as part of
|
|
12
12
|
// https://github.com/telus/universal-design-system/issues/782
|
|
13
13
|
'outerBorderColor', 'outerBorderWidth', 'outerBorderGap'];
|