@coinbase/cds-mobile 8.38.4 → 8.38.5
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 +6 -0
- package/dts/alpha/combobox/Combobox.d.ts.map +1 -1
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts +1 -0
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts.map +1 -1
- package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
- package/esm/alpha/combobox/Combobox.js +3 -2
- package/esm/alpha/combobox/DefaultComboboxControl.js +12 -3
- package/esm/alpha/combobox/__stories__/Combobox.stories.js +20 -0
- package/esm/alpha/select/DefaultSelectControl.js +29 -15
- package/esm/alpha/select/Select.js +1 -1
- package/esm/alpha/select/__stories__/AlphaSelect.stories.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
<!-- template-start -->
|
|
10
10
|
|
|
11
|
+
## 8.38.5 (1/23/2026 PST)
|
|
12
|
+
|
|
13
|
+
#### 🐞 Fixes
|
|
14
|
+
|
|
15
|
+
- Update ARIA labels used for Select and Combobox. [[#250](https://github.com/coinbase/cds/pull/250)]
|
|
16
|
+
|
|
11
17
|
## 8.38.4 ((1/22/2026, 01:55 PM PST))
|
|
12
18
|
|
|
13
19
|
This is an artificial version bump with no new change.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../../src/alpha/combobox/Combobox.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAkC,KAAK,SAAS,EAAQ,MAAM,cAAc,CAAC;AAQpF,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,kBAAk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D,cAAc,CAAC,EAAE,CACf,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAClD,UAAU,EAAE,MAAM,KACf,YAAY,CAAC,iBAAiB,CAAC,EAAE,CAAC;IACvC,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,CACvB,IAAI,SAAS,UAAU,GAAG,QAAQ,EAClC,iBAAiB,SAAS,MAAM,GAAG,MAAM,IACvC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAC5C,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAAE,QAAQ,CAAC,GAAG;IACrD,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,yBAAyB,CAAC,EAAE,uBAAuB,CAAC;CACrD,CAAC;AAEJ,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC;AAEpC,KAAK,iBAAiB,GAAG,CACvB,IAAI,SAAS,UAAU,GAAG,QAAQ,EAClC,iBAAiB,SAAS,MAAM,GAAG,MAAM,EAEzC,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;CAAE,KAC7E,KAAK,CAAC,YAAY,CAAC;AA+OxB,eAAO,MAAM,QAAQ,EAAmB,iBAAiB,CAAC"}
|
|
@@ -15,6 +15,7 @@ export declare const DefaultComboboxControl: <
|
|
|
15
15
|
onSearch,
|
|
16
16
|
searchInputRef,
|
|
17
17
|
hideSearchInput,
|
|
18
|
+
accessibilityLabel,
|
|
18
19
|
...props
|
|
19
20
|
}: ComboboxControlProps<Type, SelectOptionValue>) => import('react/jsx-runtime').JSX.Element;
|
|
20
21
|
//# sourceMappingURL=DefaultComboboxControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultComboboxControl.d.ts","sourceRoot":"","sources":["../../../src/alpha/combobox/DefaultComboboxControl.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DefaultComboboxControl.d.ts","sourceRoot":"","sources":["../../../src/alpha/combobox/DefaultComboboxControl.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOvD,eAAO,MAAM,sBAAsB,GACjC,IAAI,SAAS,UAAU,GAAG,QAAQ,EAClC,iBAAiB,SAAS,MAAM,GAAG,MAAM,EACzC,uKAcC,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,CAAC,4CAuE/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultSelectControl.d.ts","sourceRoot":"","sources":["../../../src/alpha/select/DefaultSelectControl.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAc3D,OAAO,KAAK,EAAE,kBAAkB,EAAgB,UAAU,EAAE,MAAM,UAAU,CAAC;AAkB7E,KAAK,6BAA6B,GAAG,CACnC,IAAI,SAAS,UAAU,EACvB,iBAAiB,SAAS,MAAM,GAAG,MAAM,EAEzC,KAAK,EAAE,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;CAAE,KACvF,KAAK,CAAC,YAAY,CAAC;AAExB,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DefaultSelectControl.d.ts","sourceRoot":"","sources":["../../../src/alpha/select/DefaultSelectControl.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAc3D,OAAO,KAAK,EAAE,kBAAkB,EAAgB,UAAU,EAAE,MAAM,UAAU,CAAC;AAkB7E,KAAK,6BAA6B,GAAG,CACnC,IAAI,SAAS,UAAU,EACvB,iBAAiB,SAAS,MAAM,GAAG,MAAM,EAEzC,KAAK,EAAE,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;CAAE,KACvF,KAAK,CAAC,YAAY,CAAC;AAExB,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;wBA4OF,CAAC;wBAEb,CAAC;wBAEc,CAAC;wBAI1B,CAAC;6BAGD,CAAC;sBAED,CAAC;;qDAgGlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAoC,6BAA6B,CAAC"}
|
|
@@ -64,7 +64,7 @@ const ComboboxBase = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
64
64
|
variant,
|
|
65
65
|
startNode,
|
|
66
66
|
endNode,
|
|
67
|
-
accessibilityLabel = 'Combobox control',
|
|
67
|
+
accessibilityLabel = typeof label === 'string' ? label : 'Combobox control',
|
|
68
68
|
defaultOpen,
|
|
69
69
|
searchText: searchTextProp,
|
|
70
70
|
onSearch: onSearchProp,
|
|
@@ -152,6 +152,7 @@ const ComboboxBase = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
152
152
|
header: /*#__PURE__*/_jsx(Box, {
|
|
153
153
|
paddingX: 3,
|
|
154
154
|
children: /*#__PURE__*/_jsx(ComboboxControl, _extends({
|
|
155
|
+
accessibilityLabel: accessibilityLabel,
|
|
155
156
|
endNode: endNode,
|
|
156
157
|
placeholder: placeholder,
|
|
157
158
|
startNode: startNode,
|
|
@@ -162,7 +163,7 @@ const ComboboxBase = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
162
163
|
}))
|
|
163
164
|
}),
|
|
164
165
|
onVisibilityChange: handleTrayVisibilityChange
|
|
165
|
-
})), [ComboboxControl, SelectDropdownComponent, closeButtonLabel, endNode, handleTrayVisibilityChange, label, placeholder, setOpen, startNode, variant]);
|
|
166
|
+
})), [ComboboxControl, SelectDropdownComponent, accessibilityLabel, closeButtonLabel, endNode, handleTrayVisibilityChange, label, placeholder, setOpen, startNode, variant]);
|
|
166
167
|
return /*#__PURE__*/_jsx(ComboboxContext.Provider, {
|
|
167
168
|
value: {
|
|
168
169
|
searchText,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const _excluded = ["SelectControlComponent", "value", "placeholder", "open", "setOpen", "disabled", "options", "searchText", "onSearch", "searchInputRef", "hideSearchInput"];
|
|
1
|
+
const _excluded = ["SelectControlComponent", "value", "placeholder", "open", "setOpen", "disabled", "options", "searchText", "onSearch", "searchInputRef", "hideSearchInput", "accessibilityLabel"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
import { useMemo } from 'react';
|
|
4
5
|
import { StyleSheet } from 'react-native';
|
|
5
6
|
import { NativeInput } from '../../controls/NativeInput';
|
|
6
7
|
import { useTheme } from '../../hooks/useTheme';
|
|
@@ -22,13 +23,22 @@ export const DefaultComboboxControl = _ref => {
|
|
|
22
23
|
searchText,
|
|
23
24
|
onSearch,
|
|
24
25
|
searchInputRef,
|
|
25
|
-
hideSearchInput
|
|
26
|
+
hideSearchInput,
|
|
27
|
+
accessibilityLabel
|
|
26
28
|
} = _ref,
|
|
27
29
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
28
30
|
const theme = useTheme();
|
|
29
31
|
const hasValue = hasSelectedValue(value);
|
|
30
32
|
const shouldRenderSearchInput = !hideSearchInput && (!hasValue || open);
|
|
33
|
+
const computedAccessibilityLabel = useMemo(() => {
|
|
34
|
+
let label = accessibilityLabel;
|
|
35
|
+
if (!hasValue && typeof placeholder === 'string') {
|
|
36
|
+
label = label + ", " + placeholder;
|
|
37
|
+
}
|
|
38
|
+
return label;
|
|
39
|
+
}, [hasValue, accessibilityLabel, placeholder]);
|
|
31
40
|
return /*#__PURE__*/_jsx(SelectControlComponent, _extends({
|
|
41
|
+
accessibilityLabel: computedAccessibilityLabel,
|
|
32
42
|
disabled: disabled,
|
|
33
43
|
open: open,
|
|
34
44
|
options: options,
|
|
@@ -67,7 +77,6 @@ export const DefaultComboboxControl = _ref => {
|
|
|
67
77
|
children: typeof placeholder === 'string' ? placeholder : ''
|
|
68
78
|
})
|
|
69
79
|
}),
|
|
70
|
-
placeholder: null,
|
|
71
80
|
styles: _extends({}, props.styles, {
|
|
72
81
|
controlEndNode: _extends({}, StyleSheet.flatten((_props$styles = props.styles) == null ? void 0 : _props$styles.controlEndNode), {
|
|
73
82
|
alignItems: hasValue && shouldRenderSearchInput ? 'flex-end' : 'center'
|
|
@@ -285,6 +285,23 @@ const ControlledSearchExample = () => {
|
|
|
285
285
|
})]
|
|
286
286
|
});
|
|
287
287
|
};
|
|
288
|
+
const AccessibilityLabelExample = () => {
|
|
289
|
+
const {
|
|
290
|
+
value,
|
|
291
|
+
onChange
|
|
292
|
+
} = useMultiSelect({
|
|
293
|
+
initialValue: []
|
|
294
|
+
});
|
|
295
|
+
return /*#__PURE__*/_jsx(Combobox, {
|
|
296
|
+
accessibilityLabel: "Custom accessibility label",
|
|
297
|
+
label: "Accessible combobox",
|
|
298
|
+
onChange: onChange,
|
|
299
|
+
options: fruitOptions,
|
|
300
|
+
placeholder: "Has accessibility label...",
|
|
301
|
+
type: "multi",
|
|
302
|
+
value: value
|
|
303
|
+
});
|
|
304
|
+
};
|
|
288
305
|
const WithDescriptionsExample = () => {
|
|
289
306
|
const {
|
|
290
307
|
value,
|
|
@@ -952,6 +969,9 @@ const Default = () => {
|
|
|
952
969
|
}), /*#__PURE__*/_jsx(Example, {
|
|
953
970
|
title: "Controlled search",
|
|
954
971
|
children: /*#__PURE__*/_jsx(ControlledSearchExample, {})
|
|
972
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
973
|
+
title: "Custom accessibility label",
|
|
974
|
+
children: /*#__PURE__*/_jsx(AccessibilityLabelExample, {})
|
|
955
975
|
}), /*#__PURE__*/_jsx(Example, {
|
|
956
976
|
title: "Options with descriptions",
|
|
957
977
|
children: /*#__PURE__*/_jsx(WithDescriptionsExample, {})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["type", "options", "value", "onChange", "open", "placeholder", "disabled", "setOpen", "variant", "helperText", "label", "labelVariant", "contentNode", "startNode", "endNode", "compact", "bordered", "borderWidth", "focusedBorderWidth", "maxSelectedOptionsToShow", "accessibilityLabel", "
|
|
1
|
+
const _excluded = ["type", "options", "value", "onChange", "open", "placeholder", "disabled", "setOpen", "variant", "helperText", "label", "labelVariant", "contentNode", "startNode", "endNode", "compact", "bordered", "borderWidth", "focusedBorderWidth", "maxSelectedOptionsToShow", "accessibilityLabel", "hiddenSelectedOptionsLabel", "removeSelectedOptionAccessibilityLabel", "style", "styles"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import { forwardRef, memo, useMemo } from 'react';
|
|
@@ -52,7 +52,6 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
52
52
|
focusedBorderWidth = bordered ? undefined : 200,
|
|
53
53
|
maxSelectedOptionsToShow = 3,
|
|
54
54
|
accessibilityLabel,
|
|
55
|
-
accessibilityHint,
|
|
56
55
|
hiddenSelectedOptionsLabel = 'more',
|
|
57
56
|
removeSelectedOptionAccessibilityLabel = 'Remove',
|
|
58
57
|
styles
|
|
@@ -97,6 +96,25 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
97
96
|
});
|
|
98
97
|
return map;
|
|
99
98
|
}, [options]);
|
|
99
|
+
const singleValueContent = useMemo(() => {
|
|
100
|
+
var _ref3, _ref4, _option$label;
|
|
101
|
+
const option = !isMultiSelect ? optionsMap.get(value) : undefined;
|
|
102
|
+
const label = (_ref3 = (_ref4 = (_option$label = option == null ? void 0 : option.label) != null ? _option$label : option == null ? void 0 : option.description) != null ? _ref4 : option == null ? void 0 : option.value) != null ? _ref3 : placeholder;
|
|
103
|
+
return hasValue ? label : placeholder;
|
|
104
|
+
}, [hasValue, isMultiSelect, optionsMap, placeholder, value]);
|
|
105
|
+
const computedControlAccessibilityLabel = useMemo(() => {
|
|
106
|
+
// For multi-select, set the label to the content of each selected value and the hidden selected options label
|
|
107
|
+
if (isMultiSelect) {
|
|
108
|
+
const selectedValues = value.map(v => {
|
|
109
|
+
var _ref5, _ref6, _option$label2;
|
|
110
|
+
const option = optionsMap.get(v);
|
|
111
|
+
return (_ref5 = (_ref6 = (_option$label2 = option == null ? void 0 : option.label) != null ? _option$label2 : option == null ? void 0 : option.description) != null ? _ref6 : option == null ? void 0 : option.value) != null ? _ref5 : v;
|
|
112
|
+
}).slice(0, maxSelectedOptionsToShow).join(', ');
|
|
113
|
+
return accessibilityLabel + ", " + (value.length > 0 ? selectedValues : placeholder != null ? placeholder : '') + (value.length > maxSelectedOptionsToShow ? ', ' + hiddenSelectedOptionsLabel : '');
|
|
114
|
+
}
|
|
115
|
+
// If value is React node, fallback to only using passed in accessibility label
|
|
116
|
+
return "" + (accessibilityLabel != null ? accessibilityLabel : '') + (typeof singleValueContent === 'string' ? ', ' + singleValueContent : '');
|
|
117
|
+
}, [accessibilityLabel, hiddenSelectedOptionsLabel, isMultiSelect, maxSelectedOptionsToShow, optionsMap, placeholder, singleValueContent, value]);
|
|
100
118
|
|
|
101
119
|
// Prop value doesn't have default value because it affects the color of the
|
|
102
120
|
// animated caret
|
|
@@ -123,7 +141,6 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
123
141
|
})
|
|
124
142
|
}) : label, [compact, disabled, label, labelVariant, setOpen, styles == null ? void 0 : styles.controlLabelNode]);
|
|
125
143
|
const valueNode = useMemo(() => {
|
|
126
|
-
var _ref5, _ref6, _option$label2;
|
|
127
144
|
if (hasValue && isMultiSelect) {
|
|
128
145
|
const valuesToShow = value.length <= maxSelectedOptionsToShow ? value : value.slice(0, maxSelectedOptionsToShow);
|
|
129
146
|
const optionsToShow = valuesToShow.map(value => optionsMap.get(value)).filter(option => option !== undefined);
|
|
@@ -131,7 +148,7 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
131
148
|
flexWrap: "wrap",
|
|
132
149
|
gap: 1,
|
|
133
150
|
children: [optionsToShow.map(option => {
|
|
134
|
-
var _option$value,
|
|
151
|
+
var _option$value, _ref7, _ref8, _option$label3;
|
|
135
152
|
const accessibilityLabel = typeof option.label === 'string' ? option.label : typeof option.description === 'string' ? option.description : (_option$value = option.value) != null ? _option$value : '';
|
|
136
153
|
return /*#__PURE__*/_jsx(InputChip, {
|
|
137
154
|
compact: true,
|
|
@@ -144,7 +161,7 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
144
161
|
event == null || event.stopPropagation();
|
|
145
162
|
onChange == null || onChange(option.value);
|
|
146
163
|
},
|
|
147
|
-
children: (
|
|
164
|
+
children: (_ref7 = (_ref8 = (_option$label3 = option.label) != null ? _option$label3 : option.description) != null ? _ref8 : option.value) != null ? _ref7 : ''
|
|
148
165
|
}, option.value);
|
|
149
166
|
}), value.length - maxSelectedOptionsToShow > 0 && /*#__PURE__*/_jsx(InputChip, {
|
|
150
167
|
compact: true,
|
|
@@ -155,21 +172,17 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
155
172
|
})]
|
|
156
173
|
});
|
|
157
174
|
}
|
|
158
|
-
|
|
159
|
-
const label = (_ref5 = (_ref6 = (_option$label2 = option == null ? void 0 : option.label) != null ? _option$label2 : option == null ? void 0 : option.description) != null ? _ref6 : option == null ? void 0 : option.value) != null ? _ref5 : placeholder;
|
|
160
|
-
const content = hasValue ? label : placeholder;
|
|
161
|
-
return typeof content === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
175
|
+
return typeof singleValueContent === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
162
176
|
color: hasValue ? 'fg' : 'fgMuted',
|
|
163
177
|
ellipsize: "tail",
|
|
164
178
|
font: "body",
|
|
165
179
|
textAlign: "left",
|
|
166
|
-
children:
|
|
167
|
-
}) :
|
|
168
|
-
}, [hasValue, isMultiSelect,
|
|
180
|
+
children: singleValueContent
|
|
181
|
+
}) : singleValueContent;
|
|
182
|
+
}, [hasValue, isMultiSelect, singleValueContent, value, maxSelectedOptionsToShow, hiddenSelectedOptionsLabel, optionsMap, removeSelectedOptionAccessibilityLabel, disabled, onChange]);
|
|
169
183
|
const inputNode = useMemo(() => /*#__PURE__*/_jsx(TouchableOpacity, _extends({
|
|
170
184
|
ref: ref,
|
|
171
|
-
|
|
172
|
-
accessibilityLabel: accessibilityLabel,
|
|
185
|
+
accessibilityLabel: computedControlAccessibilityLabel,
|
|
173
186
|
accessibilityRole: "button",
|
|
174
187
|
disabled: disabled,
|
|
175
188
|
onPress: () => setOpen(s => !s),
|
|
@@ -204,8 +217,9 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
204
217
|
})]
|
|
205
218
|
})
|
|
206
219
|
})
|
|
207
|
-
})), [ref,
|
|
220
|
+
})), [ref, computedControlAccessibilityLabel, disabled, styles == null ? void 0 : styles.controlInputNode, styles == null ? void 0 : styles.controlStartNode, styles == null ? void 0 : styles.controlValueNode, props, labelVariant, compact, startNode, shouldShowCompactLabel, labelNode, valueNode, contentNode, setOpen]);
|
|
208
221
|
const endNode = useMemo(() => /*#__PURE__*/_jsx(Pressable, {
|
|
222
|
+
accessible: customEndNode ? true : false,
|
|
209
223
|
disabled: disabled,
|
|
210
224
|
onPress: () => setOpen(s => !s),
|
|
211
225
|
children: /*#__PURE__*/_jsx(HStack, {
|
|
@@ -31,7 +31,7 @@ const SelectBase = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
31
31
|
compact,
|
|
32
32
|
label,
|
|
33
33
|
labelVariant,
|
|
34
|
-
accessibilityLabel =
|
|
34
|
+
accessibilityLabel = typeof label === 'string' ? label : 'Select control',
|
|
35
35
|
accessibilityHint,
|
|
36
36
|
accessibilityRoles = defaultAccessibilityRoles,
|
|
37
37
|
selectAllLabel,
|
|
@@ -379,7 +379,7 @@ const WithNoLabelOrDescriptionExample = () => {
|
|
|
379
379
|
const AccessibilityLabelExample = () => {
|
|
380
380
|
const [value, setValue] = useState('1');
|
|
381
381
|
return /*#__PURE__*/_jsx(Select, {
|
|
382
|
-
accessibilityLabel: "
|
|
382
|
+
accessibilityLabel: "Custom accessibility label",
|
|
383
383
|
label: "Single select - accessibility label",
|
|
384
384
|
onChange: setValue,
|
|
385
385
|
options: exampleOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "8.38.
|
|
3
|
+
"version": "8.38.5",
|
|
4
4
|
"description": "Coinbase Design System - Mobile",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"react-native-svg": "^14.1.0"
|
|
199
199
|
},
|
|
200
200
|
"dependencies": {
|
|
201
|
-
"@coinbase/cds-common": "^8.38.
|
|
201
|
+
"@coinbase/cds-common": "^8.38.5",
|
|
202
202
|
"@coinbase/cds-icons": "^5.9.0",
|
|
203
203
|
"@coinbase/cds-illustrations": "^4.29.0",
|
|
204
204
|
"@coinbase/cds-lottie-files": "^3.3.4",
|