@telus-uds/components-base 3.8.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -3
- package/lib/cjs/Autocomplete/Autocomplete.js +5 -1
- package/lib/cjs/Button/ButtonBase.js +39 -21
- package/lib/cjs/Button/ButtonGroup.js +25 -3
- package/lib/cjs/MultiSelectFilter/ModalOverlay.js +7 -2
- package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +13 -7
- package/lib/cjs/ToggleSwitch/ToggleSwitch.js +13 -2
- package/lib/cjs/Validator/Validator.js +135 -64
- package/lib/esm/Autocomplete/Autocomplete.js +5 -1
- package/lib/esm/Button/ButtonBase.js +39 -21
- package/lib/esm/Button/ButtonGroup.js +25 -3
- package/lib/esm/MultiSelectFilter/ModalOverlay.js +7 -2
- package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +13 -7
- package/lib/esm/ToggleSwitch/ToggleSwitch.js +13 -2
- package/lib/esm/Validator/Validator.js +135 -64
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +5 -1
- package/src/Button/ButtonBase.jsx +23 -0
- package/src/Button/ButtonGroup.jsx +29 -3
- package/src/MultiSelectFilter/ModalOverlay.jsx +3 -2
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +12 -8
- package/src/ToggleSwitch/ToggleSwitch.jsx +17 -2
- package/src/Validator/Validator.jsx +172 -85
|
@@ -44,7 +44,7 @@ const Validator = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
44
44
|
supportsProps
|
|
45
45
|
} = selectProps(rest);
|
|
46
46
|
const strValidation = supportsProps.validation;
|
|
47
|
-
const [
|
|
47
|
+
const [, setIndividualCodes] = _react.default.useState({});
|
|
48
48
|
const [text, setText] = _react.default.useState(value);
|
|
49
49
|
const validatorsLength = 6;
|
|
50
50
|
const prefix = 'code';
|
|
@@ -62,64 +62,85 @@ const Validator = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
62
62
|
const [codeReferences, singleCodes] = _react.default.useMemo(() => {
|
|
63
63
|
const codes = [];
|
|
64
64
|
const valueCodes = {};
|
|
65
|
-
|
|
65
|
+
Array.from({
|
|
66
|
+
length: validatorsLength
|
|
67
|
+
}, (_, i) => {
|
|
66
68
|
codes[prefix + i] = /*#__PURE__*/_react.default.createRef();
|
|
67
69
|
valueCodes[prefix + i] = '';
|
|
68
70
|
valueCodes[prefix + i + sufixValidation] = '';
|
|
69
|
-
|
|
71
|
+
return null;
|
|
72
|
+
});
|
|
70
73
|
return [codes, valueCodes];
|
|
71
|
-
}, []);
|
|
72
|
-
const handleSingleCodes = (codeId, val, validation) => {
|
|
74
|
+
}, [validatorsLength, prefix, sufixValidation]);
|
|
75
|
+
const handleSingleCodes = _react.default.useCallback((codeId, val, validation) => {
|
|
73
76
|
singleCodes[codeId] = val;
|
|
74
77
|
singleCodes[codeId + sufixValidation] = validation;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...individualCodes,
|
|
78
|
+
setIndividualCodes(prev => ({
|
|
79
|
+
...prev,
|
|
78
80
|
[codeId]: val
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
const changeDataMasking = boxElement => {
|
|
81
|
+
}));
|
|
82
|
+
}, [singleCodes, sufixValidation]);
|
|
83
|
+
const changeDataMasking = _react.default.useCallback(boxElement => {
|
|
82
84
|
let charMasking = '';
|
|
83
85
|
const element = boxElement;
|
|
84
|
-
if (mask && mask.length === 1)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
if (mask && mask.length === 1) {
|
|
87
|
+
charMasking = mask;
|
|
88
|
+
} else if (mask && mask.length > 1) {
|
|
89
|
+
charMasking = mask.substring(0, 1);
|
|
90
|
+
}
|
|
91
|
+
if (charMasking && element) {
|
|
92
|
+
element.value = charMasking;
|
|
93
|
+
}
|
|
94
|
+
}, [mask]);
|
|
95
|
+
const handleChangeCode = _react.default.useCallback(() => {
|
|
96
|
+
const code = Array.from({
|
|
97
|
+
length: validatorsLength
|
|
98
|
+
}, (_, i) => singleCodes[prefix + i] || '').join('');
|
|
99
|
+
if (typeof onChange === 'function') {
|
|
100
|
+
onChange(code, singleCodes);
|
|
101
|
+
}
|
|
102
|
+
}, [validatorsLength, singleCodes, prefix, onChange]);
|
|
103
|
+
const handleChangeCodeValues = _react.default.useCallback((event, codeId, nextIndex) => {
|
|
93
104
|
const codeElement = codeReferences[codeId]?.current;
|
|
94
105
|
const val = event.nativeEvent?.value || event.target?.value;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
|
|
107
|
+
// Only allow numeric characters and limit to single digit
|
|
108
|
+
const numericOnly = val.replace(/\D/g, '').substring(0, 1);
|
|
109
|
+
if (codeElement && codeElement.value) {
|
|
110
|
+
codeElement.value = numericOnly;
|
|
98
111
|
}
|
|
99
|
-
handleSingleCodes(codeId,
|
|
112
|
+
handleSingleCodes(codeId, numericOnly, numericOnly ? 'success' : '');
|
|
100
113
|
handleChangeCode();
|
|
101
114
|
if (nextIndex === validatorsLength) {
|
|
102
|
-
codeElement
|
|
115
|
+
codeElement?.blur();
|
|
103
116
|
changeDataMasking(codeElement);
|
|
104
117
|
return;
|
|
105
118
|
}
|
|
106
|
-
if (
|
|
107
|
-
codeReferences[prefix + nextIndex]
|
|
119
|
+
if (numericOnly.length > 0) {
|
|
120
|
+
const nextElement = codeReferences[prefix + nextIndex]?.current;
|
|
121
|
+
nextElement?.focus();
|
|
108
122
|
changeDataMasking(codeElement);
|
|
109
123
|
}
|
|
110
|
-
};
|
|
124
|
+
}, [codeReferences, handleSingleCodes, handleChangeCode, validatorsLength, changeDataMasking, prefix]);
|
|
111
125
|
const handleKeyPress = (event, currentIndex, previousIndex) => {
|
|
112
|
-
if (!(event.keyCode === 8 || event.code === 'Backspace'))
|
|
126
|
+
if (!(event.keyCode === 8 || event.code === 'Backspace')) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
113
129
|
if (currentIndex > 0) {
|
|
114
|
-
codeReferences[prefix + currentIndex]
|
|
115
|
-
codeReferences[prefix + previousIndex]
|
|
130
|
+
const currentElement = codeReferences[prefix + currentIndex]?.current;
|
|
131
|
+
const previousElement = codeReferences[prefix + previousIndex]?.current;
|
|
132
|
+
if (currentElement && currentElement.value) {
|
|
133
|
+
currentElement.value = '';
|
|
134
|
+
}
|
|
135
|
+
previousElement?.focus();
|
|
116
136
|
}
|
|
117
137
|
handleSingleCodes(prefix + currentIndex, '', '');
|
|
118
138
|
handleChangeCode();
|
|
119
139
|
};
|
|
120
140
|
const getCodeComponents = () => {
|
|
121
|
-
|
|
122
|
-
|
|
141
|
+
return Array.from({
|
|
142
|
+
length: validatorsLength
|
|
143
|
+
}, (_, i) => {
|
|
123
144
|
const codeId = prefix + i;
|
|
124
145
|
const codeInputProps = {
|
|
125
146
|
nativeID: codeId,
|
|
@@ -127,65 +148,115 @@ const Validator = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
127
148
|
ref: codeReferences[codeId] ?? null,
|
|
128
149
|
validation: strValidation || singleCodes[codeId + sufixValidation],
|
|
129
150
|
tokens: selectCodeTextInputTokens(themeTokens),
|
|
130
|
-
onFocus: () =>
|
|
151
|
+
onFocus: () => {
|
|
152
|
+
const element = codeReferences[codeId]?.current;
|
|
153
|
+
if (_Platform.default.OS === 'web' && element?.select) {
|
|
154
|
+
return element.select() ?? null;
|
|
155
|
+
}
|
|
156
|
+
if (element?.focus) {
|
|
157
|
+
return element.focus() ?? null;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
},
|
|
131
161
|
onKeyPress: event => handleKeyPress(event, i, i - 1),
|
|
132
162
|
onMouseOver: handleMouseOver,
|
|
133
163
|
onMouseOut: handleMouseOut,
|
|
134
164
|
inactive
|
|
135
165
|
};
|
|
136
|
-
codeInputProps.validation
|
|
137
|
-
|
|
166
|
+
if (!codeInputProps.validation) {
|
|
167
|
+
delete codeInputProps.validation;
|
|
168
|
+
}
|
|
169
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
138
170
|
style: staticStyles.codeInputWidth,
|
|
139
171
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInput.TextInput, {
|
|
140
172
|
...codeInputProps
|
|
141
173
|
})
|
|
142
|
-
}, codeId)
|
|
143
|
-
}
|
|
144
|
-
return components;
|
|
174
|
+
}, codeId);
|
|
175
|
+
});
|
|
145
176
|
};
|
|
146
177
|
_react.default.useEffect(() => {
|
|
147
|
-
|
|
148
|
-
|
|
178
|
+
if (Number(value).toString() !== 'NaN') {
|
|
179
|
+
setText(value);
|
|
180
|
+
}
|
|
149
181
|
}, [value]);
|
|
150
|
-
|
|
151
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
152
182
|
_react.default.useEffect(() => {
|
|
153
|
-
|
|
154
|
-
|
|
183
|
+
Array.from({
|
|
184
|
+
length: validatorsLength
|
|
185
|
+
}, (_, i) => {
|
|
186
|
+
const element = codeReferences[prefix + i]?.current;
|
|
187
|
+
if (element && element.value !== undefined) {
|
|
188
|
+
if (mask && text[i]) {
|
|
189
|
+
element.value = mask;
|
|
190
|
+
} else {
|
|
191
|
+
element.value = text[i] ?? '';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
155
194
|
handleSingleCodes(prefix + i, text[i] ?? '', text[i] ? 'success' : '');
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
195
|
+
return null;
|
|
196
|
+
});
|
|
197
|
+
}, [text, mask, validatorsLength, prefix, codeReferences, handleSingleCodes]);
|
|
160
198
|
_react.default.useEffect(() => {
|
|
161
199
|
const handlePasteCode = event => {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
|
|
202
|
+
// Clear current state first
|
|
162
203
|
setText('');
|
|
204
|
+
|
|
205
|
+
// Clear all individual input fields and their state
|
|
206
|
+
Array.from({
|
|
207
|
+
length: validatorsLength
|
|
208
|
+
}, (_, i) => {
|
|
209
|
+
const element = codeReferences[prefix + i]?.current;
|
|
210
|
+
if (element && element.value !== undefined) {
|
|
211
|
+
element.value = '';
|
|
212
|
+
}
|
|
213
|
+
handleSingleCodes(prefix + i, '', '');
|
|
214
|
+
return null;
|
|
215
|
+
});
|
|
163
216
|
const clipBoardText = event.clipboardData.getData('text');
|
|
164
|
-
|
|
217
|
+
|
|
218
|
+
// Validate that input contains only digits and truncate to 6 characters
|
|
219
|
+
const numericOnly = clipBoardText.replace(/\D/g, '').substring(0, validatorsLength);
|
|
220
|
+
if (numericOnly.length > 0) {
|
|
221
|
+
setText(numericOnly);
|
|
222
|
+
}
|
|
165
223
|
};
|
|
166
224
|
const handleCopy = event => {
|
|
167
|
-
|
|
168
|
-
|
|
225
|
+
const clipBoardText = Array.from({
|
|
226
|
+
length: validatorsLength
|
|
227
|
+
}, (_, i) => singleCodes[prefix + i] || '').join('');
|
|
169
228
|
event.clipboardData.setData('text/plain', clipBoardText);
|
|
170
229
|
event.preventDefault();
|
|
171
230
|
};
|
|
172
231
|
if (_Platform.default.OS === 'web') {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
codeReferences[prefix + i]
|
|
177
|
-
|
|
232
|
+
Array.from({
|
|
233
|
+
length: validatorsLength
|
|
234
|
+
}, (_, i) => {
|
|
235
|
+
const element = codeReferences[prefix + i]?.current;
|
|
236
|
+
if (element && typeof element.addEventListener === 'function') {
|
|
237
|
+
element.addEventListener('paste', handlePasteCode);
|
|
238
|
+
element.addEventListener('copy', handleCopy);
|
|
239
|
+
element.addEventListener('input', event => handleChangeCodeValues(event, prefix + i, i + 1));
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
});
|
|
178
243
|
}
|
|
179
244
|
return () => {
|
|
180
|
-
if (_Platform.default.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
codeReferences[prefix + i]?.current
|
|
185
|
-
|
|
245
|
+
if (_Platform.default.OS === 'web') {
|
|
246
|
+
Array.from({
|
|
247
|
+
length: validatorsLength
|
|
248
|
+
}, (_, i) => {
|
|
249
|
+
const element = codeReferences[prefix + i]?.current;
|
|
250
|
+
if (element && typeof element.removeEventListener === 'function') {
|
|
251
|
+
element.removeEventListener('paste', handlePasteCode);
|
|
252
|
+
element.removeEventListener('copy', handleCopy);
|
|
253
|
+
element.removeEventListener('input', event => handleChangeCodeValues(event, prefix + i, i + 1));
|
|
254
|
+
}
|
|
255
|
+
return null;
|
|
256
|
+
});
|
|
186
257
|
}
|
|
187
258
|
};
|
|
188
|
-
}, []);
|
|
259
|
+
}, [validatorsLength, prefix, codeReferences, handleChangeCodeValues, handleSingleCodes, singleCodes]);
|
|
189
260
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, {
|
|
190
261
|
...supportsProps,
|
|
191
262
|
feedbackProps: {
|
|
@@ -401,7 +401,10 @@ const dictionaryContentShape = PropTypes.shape({
|
|
|
401
401
|
Autocomplete.propTypes = {
|
|
402
402
|
...selectedSystemPropTypes,
|
|
403
403
|
/**
|
|
404
|
-
* Can be used to provide a function that renders a custom input
|
|
404
|
+
* Can be used to provide a function that renders a custom input.
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```jsx
|
|
405
408
|
* <Autocomplete items={items} value={currentValue}>
|
|
406
409
|
* {({ inputId, inputRef, onChange, onKeyPress, readOnly, tokens, value }) => (
|
|
407
410
|
* <Search
|
|
@@ -415,6 +418,7 @@ Autocomplete.propTypes = {
|
|
|
415
418
|
* />
|
|
416
419
|
* )}
|
|
417
420
|
* </Autocomplete>
|
|
421
|
+
* ```
|
|
418
422
|
*/
|
|
419
423
|
children: PropTypes.func,
|
|
420
424
|
tokens: getTokensPropType('Autocomplete'),
|
|
@@ -17,7 +17,23 @@ const getOuterBorderOffset = _ref => {
|
|
|
17
17
|
} = _ref;
|
|
18
18
|
return outerBorderGap + outerBorderWidth;
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const selectFlexAndWidthStyles = _ref2 => {
|
|
21
|
+
let {
|
|
22
|
+
width,
|
|
23
|
+
flex
|
|
24
|
+
} = _ref2;
|
|
25
|
+
const styles = {};
|
|
26
|
+
if (width !== undefined && width !== null) {
|
|
27
|
+
styles.width = width;
|
|
28
|
+
}
|
|
29
|
+
if (width === '100%') {
|
|
30
|
+
styles.flex = 1;
|
|
31
|
+
} else if (flex !== undefined && flex !== null) {
|
|
32
|
+
styles.flex = flex;
|
|
33
|
+
}
|
|
34
|
+
return styles;
|
|
35
|
+
};
|
|
36
|
+
const selectOuterContainerStyles = _ref3 => {
|
|
21
37
|
let {
|
|
22
38
|
opacity,
|
|
23
39
|
outerBorderColor,
|
|
@@ -25,7 +41,7 @@ const selectOuterContainerStyles = _ref2 => {
|
|
|
25
41
|
outerBorderGap,
|
|
26
42
|
borderRadius,
|
|
27
43
|
outerBackgroundColor
|
|
28
|
-
} =
|
|
44
|
+
} = _ref3;
|
|
29
45
|
return {
|
|
30
46
|
...Platform.select({
|
|
31
47
|
native: {
|
|
@@ -42,13 +58,13 @@ const selectOuterContainerStyles = _ref2 => {
|
|
|
42
58
|
})
|
|
43
59
|
};
|
|
44
60
|
};
|
|
45
|
-
const selectOuterSizeStyles =
|
|
61
|
+
const selectOuterSizeStyles = _ref4 => {
|
|
46
62
|
let {
|
|
47
63
|
outerBorderGap,
|
|
48
64
|
outerBorderWidth,
|
|
49
65
|
width,
|
|
50
66
|
height
|
|
51
|
-
} =
|
|
67
|
+
} = _ref4;
|
|
52
68
|
// The inner container's bounding box is the bounding box of the button overall
|
|
53
69
|
// so this many device pixels will sit outside of the overall bounding box
|
|
54
70
|
const outerBorderOffset = getOuterBorderOffset({
|
|
@@ -93,7 +109,7 @@ const selectOuterSizeStyles = _ref3 => {
|
|
|
93
109
|
sizeStyles.height = height;
|
|
94
110
|
return sizeStyles;
|
|
95
111
|
};
|
|
96
|
-
const selectInnerContainerStyles =
|
|
112
|
+
const selectInnerContainerStyles = _ref5 => {
|
|
97
113
|
let {
|
|
98
114
|
backgroundColor,
|
|
99
115
|
paddingLeft,
|
|
@@ -107,14 +123,14 @@ const selectInnerContainerStyles = _ref4 => {
|
|
|
107
123
|
borderTopWidth,
|
|
108
124
|
borderBottomWidth,
|
|
109
125
|
minWidth
|
|
110
|
-
} =
|
|
126
|
+
} = _ref5;
|
|
111
127
|
// Subtract border width from padding so overall button width/height doesn't
|
|
112
128
|
// jump around if the border width changes (avoiding NaN and negative padding)
|
|
113
|
-
const offsetBorder =
|
|
129
|
+
const offsetBorder = _ref6 => {
|
|
114
130
|
let {
|
|
115
131
|
value,
|
|
116
132
|
borderSize = borderWidth
|
|
117
|
-
} =
|
|
133
|
+
} = _ref6;
|
|
118
134
|
return typeof value === 'number' && typeof borderSize === 'number' ? Math.max(0, value - borderSize) : value;
|
|
119
135
|
};
|
|
120
136
|
return {
|
|
@@ -139,7 +155,7 @@ const selectInnerContainerStyles = _ref4 => {
|
|
|
139
155
|
...applyShadowToken(shadow)
|
|
140
156
|
};
|
|
141
157
|
};
|
|
142
|
-
const selectBorderStyles =
|
|
158
|
+
const selectBorderStyles = _ref7 => {
|
|
143
159
|
let {
|
|
144
160
|
borderColor,
|
|
145
161
|
borderWidth,
|
|
@@ -148,7 +164,7 @@ const selectBorderStyles = _ref6 => {
|
|
|
148
164
|
borderRightWidth,
|
|
149
165
|
borderTopWidth,
|
|
150
166
|
borderBottomWidth
|
|
151
|
-
} =
|
|
167
|
+
} = _ref7;
|
|
152
168
|
return {
|
|
153
169
|
borderColor,
|
|
154
170
|
borderWidth,
|
|
@@ -159,7 +175,7 @@ const selectBorderStyles = _ref6 => {
|
|
|
159
175
|
borderBottomWidth
|
|
160
176
|
};
|
|
161
177
|
};
|
|
162
|
-
const selectTextStyles = (
|
|
178
|
+
const selectTextStyles = (_ref8, themeOptions) => {
|
|
163
179
|
let {
|
|
164
180
|
fontSize,
|
|
165
181
|
color,
|
|
@@ -169,7 +185,7 @@ const selectTextStyles = (_ref7, themeOptions) => {
|
|
|
169
185
|
textAlign,
|
|
170
186
|
textLine,
|
|
171
187
|
textLineStyle
|
|
172
|
-
} =
|
|
188
|
+
} = _ref8;
|
|
173
189
|
return applyTextStyles({
|
|
174
190
|
fontSize,
|
|
175
191
|
color,
|
|
@@ -182,10 +198,10 @@ const selectTextStyles = (_ref7, themeOptions) => {
|
|
|
182
198
|
textDecorationStyle: textLineStyle
|
|
183
199
|
});
|
|
184
200
|
};
|
|
185
|
-
const selectWebOnlyStyles = (inactive, themeTokens,
|
|
201
|
+
const selectWebOnlyStyles = (inactive, themeTokens, _ref9) => {
|
|
186
202
|
let {
|
|
187
203
|
accessibilityRole
|
|
188
|
-
} =
|
|
204
|
+
} = _ref9;
|
|
189
205
|
return Platform.select({
|
|
190
206
|
web: {
|
|
191
207
|
// if it would overflow the container, wraps instead
|
|
@@ -198,27 +214,27 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref8) => {
|
|
|
198
214
|
default: {}
|
|
199
215
|
});
|
|
200
216
|
};
|
|
201
|
-
const selectButtonStyles =
|
|
217
|
+
const selectButtonStyles = _ref10 => {
|
|
202
218
|
let {
|
|
203
219
|
textAlign
|
|
204
|
-
} =
|
|
220
|
+
} = _ref10;
|
|
205
221
|
return {
|
|
206
222
|
flexDirection: 'row',
|
|
207
223
|
justifyContent: textAlign
|
|
208
224
|
};
|
|
209
225
|
};
|
|
210
|
-
const selectItemIconTokens =
|
|
226
|
+
const selectItemIconTokens = _ref11 => {
|
|
211
227
|
let {
|
|
212
228
|
color,
|
|
213
229
|
iconColor,
|
|
214
230
|
iconSize
|
|
215
|
-
} =
|
|
231
|
+
} = _ref11;
|
|
216
232
|
return {
|
|
217
233
|
size: iconSize,
|
|
218
234
|
color: iconColor || color
|
|
219
235
|
};
|
|
220
236
|
};
|
|
221
|
-
const ButtonBase = /*#__PURE__*/React.forwardRef((
|
|
237
|
+
const ButtonBase = /*#__PURE__*/React.forwardRef((_ref12, ref) => {
|
|
222
238
|
let {
|
|
223
239
|
id,
|
|
224
240
|
href,
|
|
@@ -233,7 +249,7 @@ const ButtonBase = /*#__PURE__*/React.forwardRef((_ref11, ref) => {
|
|
|
233
249
|
iconPosition = icon ? 'left' : undefined,
|
|
234
250
|
iconProps,
|
|
235
251
|
...rawRest
|
|
236
|
-
} =
|
|
252
|
+
} = _ref12;
|
|
237
253
|
const {
|
|
238
254
|
onPress,
|
|
239
255
|
...rest
|
|
@@ -247,7 +263,9 @@ const ButtonBase = /*#__PURE__*/React.forwardRef((_ref11, ref) => {
|
|
|
247
263
|
const systemProps = selectProps(rest);
|
|
248
264
|
const getPressableStyle = pressableState => {
|
|
249
265
|
const themeTokens = resolveButtonTokens(pressableState);
|
|
250
|
-
|
|
266
|
+
// Only apply flex and width styles when they are explicitly set (e.g., from ButtonGroup with width: 'equal') to not to affect other use cases
|
|
267
|
+
const flexAndWidthStyles = themeTokens.width === '100%' && themeTokens.flex === 1 ? selectFlexAndWidthStyles(themeTokens) : {};
|
|
268
|
+
return [staticStyles.row, selectWebOnlyStyles(inactive, themeTokens, systemProps), selectOuterContainerStyles(themeTokens), ...(Object.keys(flexAndWidthStyles).length > 0 ? [flexAndWidthStyles] : []), selectOuterSizeStyles(themeTokens)];
|
|
251
269
|
};
|
|
252
270
|
const {
|
|
253
271
|
themeOptions
|
|
@@ -12,6 +12,15 @@ import { getPressHandlersWithArgs } from '../utils/pressability';
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
14
14
|
const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, pressProps, viewProps]);
|
|
15
|
+
const getStackWrapTokens = variant => {
|
|
16
|
+
return Platform.select({
|
|
17
|
+
web: {
|
|
18
|
+
justifyContent: variant?.width === 'equal' ? 'space-evenly' : 'flex-start',
|
|
19
|
+
width: variant?.width === 'equal' ? '100%' : 'auto'
|
|
20
|
+
},
|
|
21
|
+
default: {}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
15
24
|
const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
16
25
|
let {
|
|
17
26
|
variant,
|
|
@@ -44,7 +53,12 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
44
53
|
const themeTokens = useThemeTokens('ButtonGroup', tokens, variant, {
|
|
45
54
|
viewport
|
|
46
55
|
});
|
|
47
|
-
const
|
|
56
|
+
const themeStackTokens = selectTokens('StackView', themeTokens);
|
|
57
|
+
const variantStackTokens = getStackWrapTokens(variant);
|
|
58
|
+
const stackTokens = {
|
|
59
|
+
...themeStackTokens,
|
|
60
|
+
...variantStackTokens
|
|
61
|
+
};
|
|
48
62
|
const {
|
|
49
63
|
direction,
|
|
50
64
|
space,
|
|
@@ -54,7 +68,15 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
54
68
|
padding,
|
|
55
69
|
gap
|
|
56
70
|
} = themeTokens;
|
|
57
|
-
const
|
|
71
|
+
const themeButtonTokensCallback = useThemeTokensCallback('ButtonGroupItem', tokens, variant);
|
|
72
|
+
const getButtonTokens = state => {
|
|
73
|
+
const themeButtonTokens = themeButtonTokensCallback(state);
|
|
74
|
+
return {
|
|
75
|
+
...themeButtonTokens,
|
|
76
|
+
width: variant?.width === 'equal' ? '100%' : 'auto',
|
|
77
|
+
flex: variant?.width === 'equal' ? 1 : undefined
|
|
78
|
+
};
|
|
79
|
+
};
|
|
58
80
|
const {
|
|
59
81
|
currentValues,
|
|
60
82
|
toggleOneValue
|
|
@@ -97,7 +119,7 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
97
119
|
padding,
|
|
98
120
|
...(Platform.OS === 'web' ? {
|
|
99
121
|
gap,
|
|
100
|
-
width: 'fit-content'
|
|
122
|
+
width: variant?.width === 'equal' ? '100%' : 'fit-content'
|
|
101
123
|
} : {
|
|
102
124
|
alignSelf: 'flex-start'
|
|
103
125
|
})
|
|
@@ -56,6 +56,7 @@ const staticStyles = StyleSheet.create({
|
|
|
56
56
|
});
|
|
57
57
|
const selectContainerStyle = (enableFullscreen, themeTokens) => ({
|
|
58
58
|
borderColor: themeTokens.borderColor,
|
|
59
|
+
backgroundColor: themeTokens.backgroundColor,
|
|
59
60
|
...Platform.select({
|
|
60
61
|
web: {
|
|
61
62
|
position: enableFullscreen ? 'fixed' : 'absolute'
|
|
@@ -107,7 +108,8 @@ const ModalOverlay = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
107
108
|
maxHeight: maxHeightSize
|
|
108
109
|
};
|
|
109
110
|
const {
|
|
110
|
-
closeIcon: CloseIconComponent
|
|
111
|
+
closeIcon: CloseIconComponent,
|
|
112
|
+
backgroundColor
|
|
111
113
|
} = themeTokens;
|
|
112
114
|
const getCopy = useCopy({
|
|
113
115
|
dictionary,
|
|
@@ -120,7 +122,10 @@ const ModalOverlay = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
120
122
|
onLayout: onLayout,
|
|
121
123
|
style: [overlaidPosition, containerWidthHeight, staticStyles.positioner, !isReady && staticStyles.hidden, selectContainerStyle(enableFullscreen, themeTokens)],
|
|
122
124
|
children: /*#__PURE__*/_jsxs(Card, {
|
|
123
|
-
tokens:
|
|
125
|
+
tokens: {
|
|
126
|
+
...staticStyles.card,
|
|
127
|
+
backgroundColor
|
|
128
|
+
},
|
|
124
129
|
children: [/*#__PURE__*/_jsx(View, {
|
|
125
130
|
style: [staticStyles.closeButtonContainer, selectCloseButtonContainerStyles(themeTokens)],
|
|
126
131
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
@@ -135,6 +135,7 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
135
135
|
buttonBackgroundColor,
|
|
136
136
|
iconColorSelected,
|
|
137
137
|
buttonBackgroundColorSelected,
|
|
138
|
+
containerBorderColor,
|
|
138
139
|
...restTokens
|
|
139
140
|
} = useThemeTokens('MultiSelectFilter', tokens, {
|
|
140
141
|
...variant,
|
|
@@ -280,7 +281,7 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
280
281
|
...headerStyles,
|
|
281
282
|
lineHeight: headerLineHeight
|
|
282
283
|
},
|
|
283
|
-
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label
|
|
284
|
+
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label)
|
|
284
285
|
})
|
|
285
286
|
})
|
|
286
287
|
}), subtitle && /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -301,6 +302,7 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
301
302
|
style: styles.options,
|
|
302
303
|
children: /*#__PURE__*/_jsx(ScrollView, {
|
|
303
304
|
onLayout: handleScrollViewLayout,
|
|
305
|
+
style: styles.scrollContainer,
|
|
304
306
|
children: /*#__PURE__*/_jsx(Row, {
|
|
305
307
|
distribute: "between",
|
|
306
308
|
onLayout: handleRowLayout,
|
|
@@ -319,12 +321,11 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
319
321
|
})]
|
|
320
322
|
});
|
|
321
323
|
const controlsContent = /*#__PURE__*/_jsxs(_Fragment, {
|
|
322
|
-
children: [isScrolling
|
|
324
|
+
children: [isScrolling && /*#__PURE__*/_jsx(Divider, {
|
|
323
325
|
tokens: {
|
|
324
326
|
color: dividerColor
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
}) : /*#__PURE__*/_jsx(Spacer, {
|
|
327
|
+
}
|
|
328
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
328
329
|
space: 4
|
|
329
330
|
}), /*#__PURE__*/_jsx(View, {
|
|
330
331
|
style: selectControlsTokens(restTokens),
|
|
@@ -381,7 +382,8 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
381
382
|
minWidth: windowWidth,
|
|
382
383
|
tokens: {
|
|
383
384
|
...tokens,
|
|
384
|
-
maxWidth: true
|
|
385
|
+
maxWidth: true,
|
|
386
|
+
borderColor: containerBorderColor
|
|
385
387
|
},
|
|
386
388
|
copy: copy,
|
|
387
389
|
isReady: isReady,
|
|
@@ -407,7 +409,8 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
407
409
|
minWidth: minWidth,
|
|
408
410
|
tokens: {
|
|
409
411
|
...tokens,
|
|
410
|
-
maxWidth: items.length > MAX_ITEMS_THRESHOLD ? true : maxWidth
|
|
412
|
+
maxWidth: items.length > MAX_ITEMS_THRESHOLD ? true : maxWidth,
|
|
413
|
+
borderColor: containerBorderColor
|
|
411
414
|
},
|
|
412
415
|
copy: copy,
|
|
413
416
|
isReady: isReady,
|
|
@@ -435,6 +438,9 @@ const styles = StyleSheet.create({
|
|
|
435
438
|
},
|
|
436
439
|
options: {
|
|
437
440
|
flex: 1
|
|
441
|
+
},
|
|
442
|
+
scrollContainer: {
|
|
443
|
+
padding: 1
|
|
438
444
|
}
|
|
439
445
|
});
|
|
440
446
|
|
|
@@ -94,6 +94,17 @@ const selectSwitchStyles = _ref6 => {
|
|
|
94
94
|
})
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
|
+
const selectMobileTokens = tokens => ({
|
|
98
|
+
...Platform.select({
|
|
99
|
+
web: {},
|
|
100
|
+
default: {
|
|
101
|
+
switchSize: tokens?.mobileSwitchSize,
|
|
102
|
+
trackHeight: tokens?.mobileTrackHeight,
|
|
103
|
+
width: tokens?.mobileWidth,
|
|
104
|
+
trackBorderWidth: tokens?.mobileTrackBorderWidth
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
});
|
|
97
108
|
const selectLabelStyles = _ref7 => {
|
|
98
109
|
let {
|
|
99
110
|
labelMarginLeft
|
|
@@ -146,7 +157,7 @@ const ToggleSwitch = /*#__PURE__*/React.forwardRef((_ref9, ref) => {
|
|
|
146
157
|
onChange
|
|
147
158
|
});
|
|
148
159
|
const handlePress = event => setValue(!currentValue, event);
|
|
149
|
-
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState), getTokens(themeTokens));
|
|
160
|
+
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState, selectMobileTokens(themeTokens)), getTokens(themeTokens, selectMobileTokens(themeTokens)));
|
|
150
161
|
const uniqueId = useUniqueId('toggleSwitch');
|
|
151
162
|
const inputId = id ?? uniqueId;
|
|
152
163
|
return /*#__PURE__*/_jsxs(StackView, {
|
|
@@ -179,7 +190,7 @@ const ToggleSwitch = /*#__PURE__*/React.forwardRef((_ref9, ref) => {
|
|
|
179
190
|
onPress: handlePress,
|
|
180
191
|
...selectProps(rest),
|
|
181
192
|
children: buttonState => {
|
|
182
|
-
const stateTokens = getTokens(buttonState);
|
|
193
|
+
const stateTokens = getTokens(buttonState, selectMobileTokens(themeTokens));
|
|
183
194
|
const IconComponent = stateTokens.icon;
|
|
184
195
|
const switchStyles = selectSwitchStyles(stateTokens);
|
|
185
196
|
const trackStyles = selectTrackStyles(stateTokens);
|