@telus-uds/components-base 1.3.1 → 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 +142 -1
- package/CHANGELOG.md +51 -2
- package/__tests__/FlexGrid/Row.test.jsx +100 -25
- package/__tests__/utils/containUniqueFields.test.js +25 -0
- package/component-docs.json +50 -15
- 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/Modal/Modal.js +18 -18
- package/lib/Notification/Notification.js +5 -6
- 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/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/Modal/Modal.js +19 -19
- package/lib-module/Notification/Notification.js +6 -6
- 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/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/Modal/Modal.jsx +30 -26
- package/src/Notification/Notification.jsx +7 -4
- 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/Modal/Modal.js
CHANGED
|
@@ -25,7 +25,7 @@ var _utils = require("../utils");
|
|
|
25
25
|
|
|
26
26
|
var _ViewportProvider = require("../ViewportProvider");
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _IconButton = _interopRequireDefault(require("../IconButton"));
|
|
29
29
|
|
|
30
30
|
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
31
31
|
|
|
@@ -90,14 +90,6 @@ const selectCloseButtonContainerStyles = ({
|
|
|
90
90
|
paddingRight,
|
|
91
91
|
paddingTop
|
|
92
92
|
});
|
|
93
|
-
|
|
94
|
-
const selectCloseIconProps = ({
|
|
95
|
-
closeIconSize,
|
|
96
|
-
closeIconColor
|
|
97
|
-
}) => ({
|
|
98
|
-
size: closeIconSize,
|
|
99
|
-
color: closeIconColor
|
|
100
|
-
});
|
|
101
93
|
/**
|
|
102
94
|
* A modal window is a secondary window that opens on top of the main one.
|
|
103
95
|
* Users have to interact with it before they can carry out their task and return to the main window.
|
|
@@ -122,6 +114,7 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
122
114
|
tokens,
|
|
123
115
|
variant,
|
|
124
116
|
copy,
|
|
117
|
+
closeButton,
|
|
125
118
|
...rest
|
|
126
119
|
}, ref) => {
|
|
127
120
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
@@ -144,12 +137,15 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
144
137
|
|
|
145
138
|
const handleKeyUp = event => {
|
|
146
139
|
if (event.key === 'Escape') onClose();
|
|
147
|
-
};
|
|
140
|
+
}; // Show the custom react node passed to `closedButton` or the default close button if `closeButton` is `undefined`.
|
|
141
|
+
// Hide the close button if `closeButton` is `null`.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
const showCloseButton = closeButton !== null;
|
|
148
145
|
|
|
149
146
|
if (!isOpen) {
|
|
150
147
|
return null;
|
|
151
|
-
}
|
|
152
|
-
|
|
148
|
+
}
|
|
153
149
|
|
|
154
150
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.default, {
|
|
155
151
|
transparent: true,
|
|
@@ -164,15 +160,14 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
164
160
|
ref: ref,
|
|
165
161
|
style: [staticStyles.modal, selectModalStyles(themeTokens)],
|
|
166
162
|
onKeyUp: handleKeyUp,
|
|
167
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
163
|
+
children: [showCloseButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
168
164
|
style: [staticStyles.closeButtonContainer, selectCloseButtonContainerStyles(themeTokens)],
|
|
169
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
165
|
+
children: closeButton || /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
170
166
|
onPress: handleClose,
|
|
167
|
+
icon: CloseIconComponent,
|
|
171
168
|
accessibilityRole: "button",
|
|
172
169
|
accessibilityLabel: closeLabel,
|
|
173
|
-
|
|
174
|
-
() => /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseIconComponent, { ...selectCloseIconProps(themeTokens)
|
|
175
|
-
})
|
|
170
|
+
tokens: (0, _utils.selectTokens)('IconButton', themeTokens, 'close')
|
|
176
171
|
})
|
|
177
172
|
}), children]
|
|
178
173
|
})
|
|
@@ -193,7 +188,12 @@ Modal.propTypes = { ...selectedSystemPropTypes,
|
|
|
193
188
|
onClose: _propTypes.default.func,
|
|
194
189
|
maxWidth: _propTypes.default.bool,
|
|
195
190
|
tokens: (0, _utils.getTokensPropType)('Modal'),
|
|
196
|
-
variant: _utils.variantProp.propType
|
|
191
|
+
variant: _utils.variantProp.propType,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Pass a react node to override the default close button or pass `null` to hide the close button.
|
|
195
|
+
*/
|
|
196
|
+
closeButton: _propTypes.default.node
|
|
197
197
|
};
|
|
198
198
|
var _default = Modal;
|
|
199
199
|
exports.default = _default;
|
|
@@ -9,8 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
11
|
|
|
12
|
-
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
13
|
-
|
|
14
12
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
15
13
|
|
|
16
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -143,10 +141,11 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
143
141
|
}
|
|
144
142
|
|
|
145
143
|
const textStyles = selectTextStyles(themeTokens);
|
|
146
|
-
const content = typeof children === '
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
const content = (0, _utils.wrapStringsInText)(typeof children === 'function' ? children({
|
|
145
|
+
textStyles
|
|
146
|
+
}) : children, {
|
|
147
|
+
style: textStyles
|
|
148
|
+
});
|
|
150
149
|
const {
|
|
151
150
|
icon: IconComponent,
|
|
152
151
|
dismissIcon: DismissIconComponent
|
package/lib/Radio/Radio.js
CHANGED
|
@@ -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.viewProps]);
|
|
38
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
|
|
39
39
|
|
|
40
40
|
const selectContainerStyles = ({
|
|
41
41
|
containerBackgroundColor,
|
|
@@ -186,22 +186,29 @@ const Radio = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
186
186
|
hover,
|
|
187
187
|
pressed
|
|
188
188
|
});
|
|
189
|
+
const labelStyles = selectLabelStyles(stateTokens);
|
|
190
|
+
const alignWithLabel = label ? [staticStyles.alignWithLabel, {
|
|
191
|
+
height: labelStyles.lineHeight
|
|
192
|
+
}] : null;
|
|
189
193
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
190
194
|
space: 0,
|
|
191
195
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
192
196
|
style: [staticStyles.container, selectContainerStyles(stateTokens)],
|
|
193
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
198
|
+
style: alignWithLabel,
|
|
199
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioButton.default, {
|
|
200
|
+
tokens: (0, _RadioButton.selectRadioButtonTokens)(stateTokens),
|
|
201
|
+
isControlled: isControlled,
|
|
202
|
+
isChecked: isChecked,
|
|
203
|
+
inactive: inactive,
|
|
204
|
+
defaultChecked: defaultChecked,
|
|
205
|
+
inputId: inputId,
|
|
206
|
+
handleChange: handleChange,
|
|
207
|
+
name: inputName,
|
|
208
|
+
value: value
|
|
209
|
+
})
|
|
203
210
|
}), Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
204
|
-
style:
|
|
211
|
+
style: labelStyles,
|
|
205
212
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelContent.default, {
|
|
206
213
|
forId: inputId,
|
|
207
214
|
children: label
|
|
@@ -285,5 +292,9 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
285
292
|
container: {
|
|
286
293
|
flexDirection: 'row',
|
|
287
294
|
alignItems: 'center'
|
|
295
|
+
},
|
|
296
|
+
alignWithLabel: {
|
|
297
|
+
alignSelf: 'flex-start',
|
|
298
|
+
justifyContent: 'center'
|
|
288
299
|
}
|
|
289
300
|
});
|
package/lib/Radio/RadioGroup.js
CHANGED
|
@@ -32,6 +32,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
32
32
|
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; }
|
|
33
33
|
|
|
34
34
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
35
|
+
const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
|
|
35
36
|
/**
|
|
36
37
|
* A group of Radios that behave as a radio group. Use when users select a single choice from mutually
|
|
37
38
|
* exclusive options.
|
|
@@ -115,11 +116,18 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
115
116
|
onChange,
|
|
116
117
|
readOnly: readOnly || inactive
|
|
117
118
|
});
|
|
119
|
+
const uniqueFields = ['id', 'label'];
|
|
120
|
+
|
|
121
|
+
if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
|
|
122
|
+
throw new Error(`RadioGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
118
125
|
const radios = items.map(({
|
|
119
126
|
label,
|
|
120
127
|
id,
|
|
121
128
|
onChange: itemOnChange,
|
|
122
|
-
ref: itemRef
|
|
129
|
+
ref: itemRef,
|
|
130
|
+
...itemRest
|
|
123
131
|
}, index) => {
|
|
124
132
|
const radioId = id || `Radio[${index}]`;
|
|
125
133
|
const isChecked = currentValue === radioId;
|
|
@@ -138,7 +146,8 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
138
146
|
label: label,
|
|
139
147
|
name: inputGroupName,
|
|
140
148
|
tokens: radioTokens,
|
|
141
|
-
variant: variant
|
|
149
|
+
variant: variant,
|
|
150
|
+
...selectItemProps(itemRest)
|
|
142
151
|
}, radioId);
|
|
143
152
|
});
|
|
144
153
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
|
|
@@ -180,7 +189,7 @@ RadioGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
180
189
|
/**
|
|
181
190
|
* Array of objects containing specifics for each Radio to be rendered in the group.
|
|
182
191
|
*/
|
|
183
|
-
items: _propTypes.default.arrayOf(_propTypes.default.exact({
|
|
192
|
+
items: _propTypes.default.arrayOf(_propTypes.default.exact({ ...selectedItemPropTypes,
|
|
184
193
|
label: _propTypes.default.string,
|
|
185
194
|
id: _propTypes.default.string,
|
|
186
195
|
onChange: _propTypes.default.func,
|
|
@@ -33,7 +33,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
33
33
|
|
|
34
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; }
|
|
35
35
|
|
|
36
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
36
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
|
|
37
37
|
/**
|
|
38
38
|
* A Card that behaves like a radio button. Use when users select a single choice from mutually exclusive options
|
|
39
39
|
* with need to show additional information for each option. The whole card is interactive as one item.
|
|
@@ -30,6 +30,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
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
32
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
33
|
+
const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
|
|
33
34
|
/**
|
|
34
35
|
* A group of Cards that behave as a radio button group. Use when users select a single choice from mutually
|
|
35
36
|
* exclusive options with need to show additional information for each option. The whole cards are each
|
|
@@ -120,6 +121,12 @@ const RadioCardGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
120
121
|
// and also needs 'radiogroup' role on fieldset for correct description on focusing the set.
|
|
121
122
|
// TODO: test this on more web screen readers.
|
|
122
123
|
|
|
124
|
+
const uniqueFields = ['id'];
|
|
125
|
+
|
|
126
|
+
if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
|
|
127
|
+
throw new Error(`RadioCardGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
|
|
124
131
|
ref: ref,
|
|
125
132
|
name: inputGroupName,
|
|
@@ -139,7 +146,8 @@ const RadioCardGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
139
146
|
title,
|
|
140
147
|
content,
|
|
141
148
|
id,
|
|
142
|
-
onChange: itemOnChange
|
|
149
|
+
onChange: itemOnChange,
|
|
150
|
+
...itemRest
|
|
143
151
|
}, index) => {
|
|
144
152
|
const cardId = id || `RadioCard[${index}]`;
|
|
145
153
|
|
|
@@ -158,6 +166,7 @@ const RadioCardGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
158
166
|
tokens: radioCardTokens,
|
|
159
167
|
variant: variant,
|
|
160
168
|
readOnly: readOnly,
|
|
169
|
+
...selectItemProps(itemRest),
|
|
161
170
|
...props,
|
|
162
171
|
children: content
|
|
163
172
|
}, cardId);
|
|
@@ -186,7 +195,7 @@ RadioCardGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
186
195
|
/**
|
|
187
196
|
* Array of objects containing specifics for each RadioCard to be rendered in the group.
|
|
188
197
|
*/
|
|
189
|
-
items: _propTypes.default.arrayOf(_propTypes.default.exact({
|
|
198
|
+
items: _propTypes.default.arrayOf(_propTypes.default.exact({ ...selectedItemPropTypes,
|
|
190
199
|
title: _propTypes.default.string,
|
|
191
200
|
content: _propTypes.default.node,
|
|
192
201
|
id: _propTypes.default.string,
|
package/lib/Select/Select.js
CHANGED
|
@@ -221,7 +221,7 @@ const Select = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
221
221
|
const handleMouseOut = () => setIsHovered(false);
|
|
222
222
|
|
|
223
223
|
const {
|
|
224
|
-
|
|
224
|
+
supportsProps,
|
|
225
225
|
...selectedProps
|
|
226
226
|
} = selectProps(rest);
|
|
227
227
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Select', tokens, variant, {
|
|
@@ -262,8 +262,7 @@ const Select = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
262
262
|
}), ValidationIconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
263
263
|
pointerEvents: "none",
|
|
264
264
|
style: [staticStyles.iconContainer, selectValidationIconContainerStyles(themeTokens)],
|
|
265
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ValidationIconComponent, {
|
|
266
|
-
tokens: selectValidationIconTokens(themeTokens)
|
|
265
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ValidationIconComponent, { ...selectValidationIconTokens(themeTokens)
|
|
267
266
|
})
|
|
268
267
|
}), IconComponent && _Platform.default.OS !== 'android' &&
|
|
269
268
|
/*#__PURE__*/
|
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.
|