@coinbase/cds-mobile 8.28.2 → 8.30.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 +15 -0
- package/dts/alpha/combobox/Combobox.d.ts +73 -0
- package/dts/alpha/combobox/Combobox.d.ts.map +1 -0
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts +20 -0
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts.map +1 -0
- package/dts/alpha/select/DefaultSelectControl.d.ts +1 -0
- package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
- package/dts/alpha/select/DefaultSelectDropdown.d.ts.map +1 -1
- package/dts/alpha/select/types.d.ts +4 -1
- package/dts/alpha/select/types.d.ts.map +1 -1
- package/dts/alpha/select-chip/SelectChip.d.ts +12 -6
- package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -1
- package/dts/alpha/select-chip/SelectChipControl.d.ts +1 -0
- package/dts/alpha/select-chip/SelectChipControl.d.ts.map +1 -1
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts +5 -0
- package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
- package/dts/chips/Chip.d.ts +1 -1
- package/dts/chips/Chip.d.ts.map +1 -1
- package/dts/chips/ChipProps.d.ts +1 -1
- package/dts/chips/ChipProps.d.ts.map +1 -1
- package/dts/chips/InputChip.d.ts +1 -1
- package/dts/chips/InputChip.d.ts.map +1 -1
- package/dts/chips/MediaChip.d.ts +1 -1
- package/dts/chips/MediaChip.d.ts.map +1 -1
- package/dts/hooks/useHorizontalScrollToTarget.d.ts +10 -0
- package/dts/hooks/useHorizontalScrollToTarget.d.ts.map +1 -1
- package/dts/overlays/drawer/Drawer.d.ts.map +1 -1
- package/dts/overlays/tray/Tray.d.ts +8 -0
- package/dts/overlays/tray/Tray.d.ts.map +1 -1
- package/esm/alpha/combobox/Combobox.js +194 -0
- package/esm/alpha/combobox/DefaultComboboxControl.js +80 -0
- package/esm/alpha/combobox/__stories__/Combobox.stories.js +1019 -0
- package/esm/alpha/select/DefaultSelectControl.js +25 -23
- package/esm/alpha/select/DefaultSelectDropdown.js +80 -75
- package/esm/alpha/select/__stories__/AlphaSelect.stories.js +24 -4
- package/esm/alpha/select-chip/SelectChip.js +8 -5
- package/esm/alpha/select-chip/SelectChipControl.js +6 -2
- package/esm/alpha/select-chip/__stories__/{SelectChip.stories.js → AlphaSelectChip.stories.js} +42 -0
- package/esm/alpha/tabbed-chips/TabbedChips.js +12 -5
- package/esm/alpha/tabbed-chips/__stories__/AlphaTabbedChips.stories.js +9 -1
- package/esm/buttons/__stories__/SlideButton.stories.js +11 -6
- package/esm/carousel/__stories__/Carousel.stories.js +5 -4
- package/esm/hooks/useHorizontalScrollToTarget.js +16 -5
- package/esm/overlays/drawer/Drawer.js +14 -3
- package/esm/overlays/tray/Tray.js +17 -5
- package/esm/visualizations/__stories__/ProgressCircle.stories.js +3 -3
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["type", "options", "value", "onChange", "open", "placeholder", "disabled", "setOpen", "variant", "helperText", "label", "labelVariant", "startNode", "endNode", "compact", "maxSelectedOptionsToShow", "accessibilityLabel", "accessibilityHint", "hiddenSelectedOptionsLabel", "removeSelectedOptionAccessibilityLabel", "style", "styles"];
|
|
1
|
+
const _excluded = ["type", "options", "value", "onChange", "open", "placeholder", "disabled", "setOpen", "variant", "helperText", "label", "labelVariant", "contentNode", "startNode", "endNode", "compact", "maxSelectedOptionsToShow", "accessibilityLabel", "accessibilityHint", "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';
|
|
@@ -43,6 +43,7 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
43
43
|
helperText,
|
|
44
44
|
label,
|
|
45
45
|
labelVariant,
|
|
46
|
+
contentNode,
|
|
46
47
|
startNode,
|
|
47
48
|
endNode: customEndNode,
|
|
48
49
|
compact,
|
|
@@ -111,15 +112,13 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
111
112
|
onPress: () => setOpen(s => !s),
|
|
112
113
|
style: styles == null ? void 0 : styles.controlLabelNode,
|
|
113
114
|
children: /*#__PURE__*/_jsx(InputLabel, {
|
|
114
|
-
alignSelf: labelVariant === 'inside' ? 'flex-start' : undefined,
|
|
115
115
|
color: "fg",
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
paddingY: shouldShowCompactLabel || labelVariant === 'inside' ? 0 : 0.5,
|
|
116
|
+
paddingEnd: 0,
|
|
117
|
+
paddingStart: labelVariant === 'inside' ? 2 : 0,
|
|
118
|
+
paddingY: labelVariant === 'inside' || compact ? 0 : 0.5,
|
|
120
119
|
children: label
|
|
121
120
|
})
|
|
122
|
-
}) : label, [disabled, label, labelVariant, setOpen,
|
|
121
|
+
}) : label, [compact, disabled, label, labelVariant, setOpen, styles == null ? void 0 : styles.controlLabelNode]);
|
|
123
122
|
const valueNode = useMemo(() => {
|
|
124
123
|
var _ref5, _ref6, _option$label2;
|
|
125
124
|
if (hasValue && isMultiSelect) {
|
|
@@ -135,7 +134,7 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
135
134
|
compact: true,
|
|
136
135
|
accessibilityLabel: removeSelectedOptionAccessibilityLabel + " " + accessibilityLabel,
|
|
137
136
|
borderWidth: 0,
|
|
138
|
-
disabled: option.disabled,
|
|
137
|
+
disabled: disabled || option.disabled,
|
|
139
138
|
invertColorScheme: false,
|
|
140
139
|
maxWidth: 200,
|
|
141
140
|
onPress: event => {
|
|
@@ -160,10 +159,10 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
160
159
|
color: hasValue ? 'fg' : 'fgMuted',
|
|
161
160
|
ellipsize: "tail",
|
|
162
161
|
font: "body",
|
|
163
|
-
textAlign:
|
|
162
|
+
textAlign: "left",
|
|
164
163
|
children: content
|
|
165
164
|
}) : content;
|
|
166
|
-
}, [hasValue, isMultiSelect, optionsMap, placeholder,
|
|
165
|
+
}, [hasValue, isMultiSelect, optionsMap, placeholder, value, maxSelectedOptionsToShow, hiddenSelectedOptionsLabel, removeSelectedOptionAccessibilityLabel, disabled, onChange]);
|
|
167
166
|
const inputNode = useMemo(() => /*#__PURE__*/_jsx(TouchableOpacity, _extends({
|
|
168
167
|
ref: ref,
|
|
169
168
|
accessibilityHint: accessibilityHint,
|
|
@@ -180,7 +179,7 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
180
179
|
justifyContent: "space-between",
|
|
181
180
|
minHeight: labelVariant === 'inside' ? LABEL_VARIANT_INSIDE_HEIGHT : compact ? COMPACT_HEIGHT : DEFAULT_HEIGHT,
|
|
182
181
|
paddingStart: startNode ? 0 : 2,
|
|
183
|
-
paddingY: labelVariant === 'inside' ? 0 : compact ?
|
|
182
|
+
paddingY: labelVariant === 'inside' ? 0 : compact ? 1 : 1.5,
|
|
184
183
|
children: /*#__PURE__*/_jsxs(HStack, {
|
|
185
184
|
alignItems: "center",
|
|
186
185
|
flexGrow: 1,
|
|
@@ -191,30 +190,33 @@ export const DefaultSelectControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forw
|
|
|
191
190
|
children: startNode
|
|
192
191
|
}), shouldShowCompactLabel ? /*#__PURE__*/_jsx(HStack, {
|
|
193
192
|
alignItems: "center",
|
|
193
|
+
maxWidth: "40%",
|
|
194
194
|
paddingEnd: 1,
|
|
195
|
-
width: "40%",
|
|
196
195
|
children: labelNode
|
|
197
|
-
}) : null, /*#__PURE__*/
|
|
196
|
+
}) : null, /*#__PURE__*/_jsxs(VStack, {
|
|
198
197
|
justifyContent: "center",
|
|
199
|
-
maxWidth:
|
|
198
|
+
maxWidth: startNode ? '70%' : '85%',
|
|
200
199
|
style: styles == null ? void 0 : styles.controlValueNode,
|
|
201
|
-
children: valueNode
|
|
200
|
+
children: [valueNode, contentNode]
|
|
202
201
|
})]
|
|
203
202
|
})
|
|
204
203
|
})
|
|
205
|
-
})), [ref, accessibilityHint, accessibilityLabel, disabled, styles == null ? void 0 : styles.controlInputNode, styles == null ? void 0 : styles.controlStartNode, styles == null ? void 0 : styles.controlValueNode, props,
|
|
206
|
-
const endNode = useMemo(() => /*#__PURE__*/_jsx(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
})), [ref, accessibilityHint, accessibilityLabel, 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]);
|
|
205
|
+
const endNode = useMemo(() => /*#__PURE__*/_jsx(Pressable, {
|
|
206
|
+
disabled: disabled,
|
|
207
|
+
onPress: () => setOpen(s => !s),
|
|
208
|
+
children: /*#__PURE__*/_jsx(HStack, {
|
|
209
|
+
alignItems: "center",
|
|
210
|
+
flexGrow: 1,
|
|
211
|
+
paddingX: 2,
|
|
212
|
+
paddingY: compact ? 1 : 1.5,
|
|
213
|
+
style: styles == null ? void 0 : styles.controlEndNode,
|
|
212
214
|
children: customEndNode ? customEndNode : /*#__PURE__*/_jsx(AnimatedCaret, {
|
|
213
215
|
color: !open ? 'fg' : variant ? variantColor[variant] : 'fgPrimary',
|
|
214
216
|
rotate: open ? 0 : 180
|
|
215
217
|
})
|
|
216
218
|
})
|
|
217
|
-
}), [
|
|
219
|
+
}), [compact, styles == null ? void 0 : styles.controlEndNode, disabled, customEndNode, open, variant, setOpen]);
|
|
218
220
|
return /*#__PURE__*/_jsx(InputStack, _extends({
|
|
219
221
|
borderFocusedStyle: borderFocusedStyle,
|
|
220
222
|
borderStyle: borderUnfocusedStyle,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["type", "options", "value", "onChange", "open", "setOpen", "controlRef", "disabled", "style", "styles", "compact", "label", "end", "selectAllLabel", "emptyOptionsLabel", "clearAllLabel", "hideSelectAll", "accessory", "media", "SelectOptionComponent", "SelectAllOptionComponent", "SelectEmptyDropdownContentsComponent", "SelectOptionGroupComponent", "accessibilityRoles"],
|
|
1
|
+
const _excluded = ["type", "options", "value", "onChange", "onVisibilityChange", "open", "setOpen", "controlRef", "disabled", "style", "styles", "compact", "header", "footer", "label", "end", "selectAllLabel", "emptyOptionsLabel", "clearAllLabel", "hideSelectAll", "accessory", "media", "SelectOptionComponent", "SelectAllOptionComponent", "SelectEmptyDropdownContentsComponent", "SelectOptionGroupComponent", "accessibilityRoles"],
|
|
2
2
|
_excluded2 = ["Component", "media", "accessory", "end", "disabled"];
|
|
3
3
|
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); }
|
|
4
4
|
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; }
|
|
@@ -21,12 +21,15 @@ const DefaultSelectDropdownComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef
|
|
|
21
21
|
options,
|
|
22
22
|
value,
|
|
23
23
|
onChange,
|
|
24
|
+
onVisibilityChange,
|
|
24
25
|
open,
|
|
25
26
|
setOpen,
|
|
26
27
|
disabled,
|
|
27
28
|
style,
|
|
28
29
|
styles,
|
|
29
30
|
compact,
|
|
31
|
+
header,
|
|
32
|
+
footer,
|
|
30
33
|
label,
|
|
31
34
|
end,
|
|
32
35
|
selectAllLabel = 'Select all',
|
|
@@ -132,6 +135,7 @@ const DefaultSelectDropdownComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef
|
|
|
132
135
|
indeterminate: indeterminate,
|
|
133
136
|
label: selectAllLabel + " (" + flatOptionsForSelectAll.filter(o => o.value !== null).length + ")",
|
|
134
137
|
media: media != null ? media : /*#__PURE__*/_jsx(Checkbox, {
|
|
138
|
+
accessible: false,
|
|
135
139
|
checked: isAllOptionsSelected,
|
|
136
140
|
indeterminate: indeterminate,
|
|
137
141
|
onPress: toggleSelectAll,
|
|
@@ -148,87 +152,88 @@ const DefaultSelectDropdownComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef
|
|
|
148
152
|
return /*#__PURE__*/_jsx(Tray, {
|
|
149
153
|
ref: ref,
|
|
150
154
|
disableCapturePanGestureToDismiss: true,
|
|
155
|
+
footer: footer,
|
|
156
|
+
header: header,
|
|
151
157
|
onCloseComplete: () => setOpen(false),
|
|
152
158
|
onDismiss: () => setOpen(false),
|
|
159
|
+
onVisibilityChange: onVisibilityChange,
|
|
153
160
|
style: dropdownStyles,
|
|
154
161
|
title: label,
|
|
155
162
|
verticalDrawerPercentageOfView: 0.9,
|
|
156
|
-
children: /*#__PURE__*/_jsx(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
children:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
SelectOptionComponent: SelectOptionComponent,
|
|
168
|
-
accessibilityRole: accessibilityRoles == null ? void 0 : accessibilityRoles.option,
|
|
169
|
-
accessory: accessory,
|
|
170
|
-
compact: compact,
|
|
171
|
-
disabled: (_group$disabled = group.disabled) != null ? _group$disabled : disabled,
|
|
172
|
-
end: end,
|
|
173
|
-
label: group.label,
|
|
174
|
-
media: media,
|
|
175
|
-
onChange: onChange,
|
|
176
|
-
options: group.options,
|
|
177
|
-
setOpen: setOpen,
|
|
178
|
-
styles: optionGroupStyles,
|
|
179
|
-
type: type,
|
|
180
|
-
value: value
|
|
181
|
-
}, "group-" + group.label);
|
|
182
|
-
}
|
|
183
|
-
const option = optionOrGroup;
|
|
184
|
-
const {
|
|
185
|
-
Component: optionComponent,
|
|
186
|
-
media: optionMedia,
|
|
187
|
-
accessory: optionAccessory,
|
|
188
|
-
end: optionEnd,
|
|
189
|
-
disabled: optionDisabled
|
|
190
|
-
} = option,
|
|
191
|
-
optionProps = _objectWithoutPropertiesLoose(option, _excluded2);
|
|
192
|
-
const RenderedComponent = optionComponent != null ? optionComponent : SelectOptionComponent;
|
|
193
|
-
const selected = optionProps.value !== null && isMultiSelect ? value.includes(optionProps.value) : value === optionProps.value;
|
|
194
|
-
/** onPress handlers are passed so that when the media is pressed,
|
|
195
|
-
* the onChange handler is called. Since the <RenderedSelectOption>
|
|
196
|
-
* has an accessibilityRole, the inner media won't be detected by a screen reader
|
|
197
|
-
* so this behavior matches web
|
|
198
|
-
* */
|
|
199
|
-
const defaultMedia = isMultiSelect ? /*#__PURE__*/_jsx(Checkbox, {
|
|
200
|
-
"aria-hidden": true,
|
|
201
|
-
checked: selected,
|
|
202
|
-
onChange: () => handleOptionPress(optionProps.value),
|
|
203
|
-
tabIndex: -1,
|
|
204
|
-
value: (_optionProps$value = optionProps.value) == null ? void 0 : _optionProps$value.toString()
|
|
205
|
-
}) : /*#__PURE__*/_jsx(Radio, {
|
|
206
|
-
"aria-hidden": true,
|
|
207
|
-
checked: selected,
|
|
208
|
-
onChange: () => handleOptionPress(optionProps.value),
|
|
209
|
-
tabIndex: -1,
|
|
210
|
-
value: (_optionProps$value2 = optionProps.value) == null ? void 0 : _optionProps$value2.toString()
|
|
211
|
-
});
|
|
212
|
-
return /*#__PURE__*/_jsx(RenderedComponent, _extends({
|
|
163
|
+
children: /*#__PURE__*/_jsx(ScrollView, {
|
|
164
|
+
showsVerticalScrollIndicator: true,
|
|
165
|
+
children: /*#__PURE__*/_jsxs(VStack, _extends({}, props, {
|
|
166
|
+
children: [!hideSelectAll && isMultiSelect && options.length > 0 && SelectAllOption, options.length > 0 ? options.map(optionOrGroup => {
|
|
167
|
+
var _optionProps$value, _optionProps$value2, _ref3;
|
|
168
|
+
// Check if it's a group (has 'options' property and 'label')
|
|
169
|
+
if (isSelectOptionGroup(optionOrGroup)) {
|
|
170
|
+
var _group$disabled;
|
|
171
|
+
const group = optionOrGroup;
|
|
172
|
+
return /*#__PURE__*/_jsx(SelectOptionGroupComponent, {
|
|
173
|
+
SelectOptionComponent: SelectOptionComponent,
|
|
213
174
|
accessibilityRole: accessibilityRoles == null ? void 0 : accessibilityRoles.option,
|
|
214
|
-
accessory:
|
|
215
|
-
blendStyles: styles == null ? void 0 : styles.optionBlendStyles,
|
|
175
|
+
accessory: accessory,
|
|
216
176
|
compact: compact,
|
|
217
|
-
disabled:
|
|
218
|
-
end:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
label
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
177
|
+
disabled: (_group$disabled = group.disabled) != null ? _group$disabled : disabled,
|
|
178
|
+
end: end,
|
|
179
|
+
label: group.label,
|
|
180
|
+
media: media,
|
|
181
|
+
onChange: onChange,
|
|
182
|
+
options: group.options,
|
|
183
|
+
setOpen: setOpen,
|
|
184
|
+
styles: optionGroupStyles,
|
|
185
|
+
type: type,
|
|
186
|
+
value: value
|
|
187
|
+
}, "group-" + group.label);
|
|
188
|
+
}
|
|
189
|
+
const option = optionOrGroup;
|
|
190
|
+
const {
|
|
191
|
+
Component: optionComponent,
|
|
192
|
+
media: optionMedia,
|
|
193
|
+
accessory: optionAccessory,
|
|
194
|
+
end: optionEnd,
|
|
195
|
+
disabled: optionDisabled
|
|
196
|
+
} = option,
|
|
197
|
+
optionProps = _objectWithoutPropertiesLoose(option, _excluded2);
|
|
198
|
+
const RenderedComponent = optionComponent != null ? optionComponent : SelectOptionComponent;
|
|
199
|
+
const selected = optionProps.value !== null && isMultiSelect ? value.includes(optionProps.value) : value === optionProps.value;
|
|
200
|
+
/** onPress handlers are passed so that when the media is pressed,
|
|
201
|
+
* the onChange handler is called. Since the <RenderedSelectOption>
|
|
202
|
+
* has an accessibilityRole, the inner media won't be detected by a screen reader
|
|
203
|
+
* so this behavior matches web
|
|
204
|
+
* */
|
|
205
|
+
const defaultMedia = isMultiSelect ? /*#__PURE__*/_jsx(Checkbox, {
|
|
206
|
+
"aria-hidden": true,
|
|
207
|
+
checked: selected,
|
|
208
|
+
onChange: () => handleOptionPress(optionProps.value),
|
|
209
|
+
tabIndex: -1,
|
|
210
|
+
value: (_optionProps$value = optionProps.value) == null ? void 0 : _optionProps$value.toString()
|
|
211
|
+
}) : /*#__PURE__*/_jsx(Radio, {
|
|
212
|
+
"aria-hidden": true,
|
|
213
|
+
checked: selected,
|
|
214
|
+
onChange: () => handleOptionPress(optionProps.value),
|
|
215
|
+
tabIndex: -1,
|
|
216
|
+
value: (_optionProps$value2 = optionProps.value) == null ? void 0 : _optionProps$value2.toString()
|
|
217
|
+
});
|
|
218
|
+
return /*#__PURE__*/_jsx(RenderedComponent, _extends({
|
|
219
|
+
accessibilityRole: accessibilityRoles == null ? void 0 : accessibilityRoles.option,
|
|
220
|
+
accessory: optionAccessory != null ? optionAccessory : accessory,
|
|
221
|
+
blendStyles: styles == null ? void 0 : styles.optionBlendStyles,
|
|
222
|
+
compact: compact,
|
|
223
|
+
disabled: optionDisabled || disabled,
|
|
224
|
+
end: optionEnd != null ? optionEnd : end,
|
|
225
|
+
media: (_ref3 = optionMedia != null ? optionMedia : media) != null ? _ref3 : defaultMedia,
|
|
226
|
+
onPress: handleOptionPress,
|
|
227
|
+
selected: selected,
|
|
228
|
+
style: styles == null ? void 0 : styles.option,
|
|
229
|
+
styles: optionStyles,
|
|
230
|
+
type: type
|
|
231
|
+
}, optionProps), optionProps.value);
|
|
232
|
+
}) : /*#__PURE__*/_jsx(SelectEmptyDropdownContentsComponent, {
|
|
233
|
+
label: emptyOptionsLabel,
|
|
234
|
+
styles: emptyDropdownContentsStyles
|
|
235
|
+
})]
|
|
236
|
+
}))
|
|
232
237
|
})
|
|
233
238
|
});
|
|
234
239
|
}));
|
|
@@ -324,10 +324,10 @@ const CompactExample = () => {
|
|
|
324
324
|
value: value
|
|
325
325
|
});
|
|
326
326
|
};
|
|
327
|
-
const
|
|
327
|
+
const InsideLabelVariantExample = () => {
|
|
328
328
|
const [value, setValue] = useState('1');
|
|
329
329
|
return /*#__PURE__*/_jsx(Select, {
|
|
330
|
-
label: "
|
|
330
|
+
label: "Inside label variant",
|
|
331
331
|
labelVariant: "inside",
|
|
332
332
|
onChange: setValue,
|
|
333
333
|
options: exampleOptions,
|
|
@@ -720,6 +720,23 @@ const MultiSelectCompactExample = () => {
|
|
|
720
720
|
value: value
|
|
721
721
|
});
|
|
722
722
|
};
|
|
723
|
+
const MultiSelectInsideLabelVariantExample = () => {
|
|
724
|
+
const {
|
|
725
|
+
value,
|
|
726
|
+
onChange
|
|
727
|
+
} = useMultiSelect({
|
|
728
|
+
initialValue: ['1']
|
|
729
|
+
});
|
|
730
|
+
return /*#__PURE__*/_jsx(Select, {
|
|
731
|
+
label: "Multi select - inside label variant",
|
|
732
|
+
labelVariant: "inside",
|
|
733
|
+
onChange: onChange,
|
|
734
|
+
options: exampleOptions,
|
|
735
|
+
placeholder: "Empty value",
|
|
736
|
+
type: "multi",
|
|
737
|
+
value: value
|
|
738
|
+
});
|
|
739
|
+
};
|
|
723
740
|
const MultiSelectHideSelectAllExample = () => {
|
|
724
741
|
const {
|
|
725
742
|
value,
|
|
@@ -1186,8 +1203,8 @@ const SelectV3Screen = () => {
|
|
|
1186
1203
|
title: "Compact",
|
|
1187
1204
|
children: /*#__PURE__*/_jsx(CompactExample, {})
|
|
1188
1205
|
}), /*#__PURE__*/_jsx(Example, {
|
|
1189
|
-
title: "
|
|
1190
|
-
children: /*#__PURE__*/_jsx(
|
|
1206
|
+
title: "Compact with inside label variant",
|
|
1207
|
+
children: /*#__PURE__*/_jsx(InsideLabelVariantExample, {})
|
|
1191
1208
|
}), /*#__PURE__*/_jsx(Example, {
|
|
1192
1209
|
title: "With Helper Text",
|
|
1193
1210
|
children: /*#__PURE__*/_jsx(WithHelperTextExample, {})
|
|
@@ -1269,6 +1286,9 @@ const SelectV3Screen = () => {
|
|
|
1269
1286
|
}), /*#__PURE__*/_jsx(Example, {
|
|
1270
1287
|
title: "Multi Select Compact",
|
|
1271
1288
|
children: /*#__PURE__*/_jsx(MultiSelectCompactExample, {})
|
|
1289
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
1290
|
+
title: "Multi Select Inside Label Variant",
|
|
1291
|
+
children: /*#__PURE__*/_jsx(MultiSelectInsideLabelVariantExample, {})
|
|
1272
1292
|
}), /*#__PURE__*/_jsx(Example, {
|
|
1273
1293
|
title: "Multi Select Hide Select All",
|
|
1274
1294
|
children: /*#__PURE__*/_jsx(MultiSelectHideSelectAllExample, {})
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
const _excluded = ["invertColorScheme", "numberOfLines"];
|
|
1
|
+
const _excluded = ["invertColorScheme", "numberOfLines", "maxWidth", "displayValue"];
|
|
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 React, { forwardRef, memo, useCallback } from 'react';
|
|
5
5
|
import { Select } from '../select/Select';
|
|
6
6
|
import { SelectChipControl } from './SelectChipControl';
|
|
7
|
-
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
/**
|
|
9
9
|
* Chip-styled Select control built on top of the Alpha Select.
|
|
10
10
|
* Supports both single and multi selection via Select's `type` prop.
|
|
11
11
|
*/
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
const SelectChipComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
13
|
let {
|
|
15
14
|
invertColorScheme,
|
|
16
|
-
numberOfLines
|
|
15
|
+
numberOfLines,
|
|
16
|
+
maxWidth,
|
|
17
|
+
displayValue
|
|
17
18
|
} = _ref,
|
|
18
19
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
20
|
const SelectChipControlComponent = useCallback(props => {
|
|
20
21
|
return /*#__PURE__*/_jsx(SelectChipControl, _extends({
|
|
22
|
+
displayValue: displayValue,
|
|
21
23
|
invertColorScheme: invertColorScheme,
|
|
24
|
+
maxWidth: maxWidth,
|
|
22
25
|
numberOfLines: numberOfLines
|
|
23
26
|
}, props));
|
|
24
|
-
}, [invertColorScheme, numberOfLines]);
|
|
27
|
+
}, [displayValue, invertColorScheme, maxWidth, numberOfLines]);
|
|
25
28
|
return /*#__PURE__*/_jsx(Select, _extends({
|
|
26
29
|
ref: ref,
|
|
27
30
|
SelectControlComponent: SelectChipControlComponent
|
|
@@ -21,7 +21,9 @@ const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_r
|
|
|
21
21
|
label,
|
|
22
22
|
compact,
|
|
23
23
|
invertColorScheme,
|
|
24
|
-
numberOfLines
|
|
24
|
+
numberOfLines,
|
|
25
|
+
maxWidth,
|
|
26
|
+
displayValue
|
|
25
27
|
} = _ref;
|
|
26
28
|
const isMultiSelect = type === 'multi';
|
|
27
29
|
const hasValue = value !== null && !(Array.isArray(value) && value.length === 0);
|
|
@@ -64,6 +66,7 @@ const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_r
|
|
|
64
66
|
const labelContent = useMemo(() => {
|
|
65
67
|
var _ref3, _ref6, _ref7, _ref8, _opt$label2;
|
|
66
68
|
if (!hasValue) return (_ref3 = label != null ? label : placeholder) != null ? _ref3 : null;
|
|
69
|
+
if (displayValue) return displayValue;
|
|
67
70
|
if (isMultiSelect) {
|
|
68
71
|
const values = value;
|
|
69
72
|
const visible = values.slice(0, maxSelectedOptionsToShow);
|
|
@@ -77,7 +80,7 @@ const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_r
|
|
|
77
80
|
}
|
|
78
81
|
const opt = optionsMap.get(value);
|
|
79
82
|
return (_ref6 = (_ref7 = (_ref8 = (_opt$label2 = opt == null ? void 0 : opt.label) != null ? _opt$label2 : opt == null ? void 0 : opt.description) != null ? _ref8 : opt == null ? void 0 : opt.value) != null ? _ref7 : placeholder) != null ? _ref6 : null;
|
|
80
|
-
}, [hasValue, label, placeholder, isMultiSelect, optionsMap, value, maxSelectedOptionsToShow, hiddenSelectedOptionsLabel]);
|
|
83
|
+
}, [hasValue, label, placeholder, displayValue, isMultiSelect, optionsMap, value, maxSelectedOptionsToShow, hiddenSelectedOptionsLabel]);
|
|
81
84
|
const endNode = useMemo(() => {
|
|
82
85
|
return customEndNode != null ? customEndNode : /*#__PURE__*/_jsx(AnimatedCaret, {
|
|
83
86
|
active: true,
|
|
@@ -102,6 +105,7 @@ const SelectChipControlComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_r
|
|
|
102
105
|
disabled: disabled,
|
|
103
106
|
end: endNode,
|
|
104
107
|
invertColorScheme: invertColorScheme,
|
|
108
|
+
maxWidth: maxWidth,
|
|
105
109
|
numberOfLines: numberOfLines,
|
|
106
110
|
onPress: () => setOpen(s => !s),
|
|
107
111
|
start: startNode,
|
package/esm/alpha/select-chip/__stories__/{SelectChip.stories.js → AlphaSelectChip.stories.js}
RENAMED
|
@@ -491,6 +491,45 @@ export const WithDescriptions = () => {
|
|
|
491
491
|
})]
|
|
492
492
|
});
|
|
493
493
|
};
|
|
494
|
+
export const WithDisplayValue = () => {
|
|
495
|
+
const exampleOptions = [{
|
|
496
|
+
value: '1',
|
|
497
|
+
label: 'Option 1'
|
|
498
|
+
}, {
|
|
499
|
+
value: '2',
|
|
500
|
+
label: 'Option 2'
|
|
501
|
+
}, {
|
|
502
|
+
value: '3',
|
|
503
|
+
label: 'Option 3'
|
|
504
|
+
}, {
|
|
505
|
+
value: '4',
|
|
506
|
+
label: 'Option 4'
|
|
507
|
+
}, {
|
|
508
|
+
value: '5',
|
|
509
|
+
label: 'Option 5'
|
|
510
|
+
}];
|
|
511
|
+
const {
|
|
512
|
+
value,
|
|
513
|
+
onChange
|
|
514
|
+
} = useMultiSelect({
|
|
515
|
+
initialValue: []
|
|
516
|
+
});
|
|
517
|
+
const displayValue = Array.isArray(value) && value.length > 0 ? value.length + " " + (value.length === 1 ? 'option' : 'options') + " selected" : undefined;
|
|
518
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
519
|
+
gap: 2,
|
|
520
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
521
|
+
children: "Select with custom displayed value:"
|
|
522
|
+
}), /*#__PURE__*/_jsx(SelectChip, {
|
|
523
|
+
accessibilityLabel: "Select multiple values",
|
|
524
|
+
displayValue: displayValue,
|
|
525
|
+
onChange: onChange,
|
|
526
|
+
options: exampleOptions,
|
|
527
|
+
placeholder: "Choose options",
|
|
528
|
+
type: "multi",
|
|
529
|
+
value: value
|
|
530
|
+
})]
|
|
531
|
+
});
|
|
532
|
+
};
|
|
494
533
|
const SelectChipScreen = () => {
|
|
495
534
|
return /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
496
535
|
children: [/*#__PURE__*/_jsx(Example, {
|
|
@@ -532,6 +571,9 @@ const SelectChipScreen = () => {
|
|
|
532
571
|
}), /*#__PURE__*/_jsx(Example, {
|
|
533
572
|
title: "With Descriptions",
|
|
534
573
|
children: /*#__PURE__*/_jsx(WithDescriptions, {})
|
|
574
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
575
|
+
title: "With Display Value",
|
|
576
|
+
children: /*#__PURE__*/_jsx(WithDisplayValue, {})
|
|
535
577
|
})]
|
|
536
578
|
});
|
|
537
579
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const _excluded = ["label", "id"],
|
|
2
|
-
_excluded2 = ["tabs", "activeTab", "testID", "TabComponent", "onChange", "width", "gap", "compact", "styles"];
|
|
2
|
+
_excluded2 = ["tabs", "activeTab", "testID", "TabComponent", "onChange", "width", "gap", "compact", "styles", "autoScrollOffset"];
|
|
3
3
|
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); }
|
|
4
4
|
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; }
|
|
5
5
|
import React, { forwardRef, memo, useCallback, useMemo, useState } from 'react';
|
|
@@ -45,19 +45,22 @@ const TabbedChipsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function
|
|
|
45
45
|
width,
|
|
46
46
|
gap = 1,
|
|
47
47
|
compact,
|
|
48
|
-
styles
|
|
48
|
+
styles,
|
|
49
|
+
autoScrollOffset = 30
|
|
49
50
|
} = _ref2,
|
|
50
51
|
accessibilityProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
51
52
|
const [scrollTarget, setScrollTarget] = useState(null);
|
|
52
53
|
const {
|
|
53
54
|
scrollRef,
|
|
54
55
|
isScrollContentOverflowing,
|
|
56
|
+
isScrollContentOffscreenLeft,
|
|
55
57
|
isScrollContentOffscreenRight,
|
|
56
58
|
handleScroll,
|
|
57
59
|
handleScrollContainerLayout,
|
|
58
60
|
handleScrollContentSizeChange
|
|
59
61
|
} = useHorizontalScrollToTarget({
|
|
60
|
-
activeTarget: scrollTarget
|
|
62
|
+
activeTarget: scrollTarget,
|
|
63
|
+
autoScrollOffset
|
|
61
64
|
});
|
|
62
65
|
const TabComponentWithCompact = useCallback(props => {
|
|
63
66
|
return /*#__PURE__*/_jsx(TabComponent, _extends({
|
|
@@ -66,7 +69,7 @@ const TabbedChipsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function
|
|
|
66
69
|
}, [TabComponent, compact]);
|
|
67
70
|
return /*#__PURE__*/_jsxs(Box, {
|
|
68
71
|
ref: ref,
|
|
69
|
-
overflow: isScrollContentOverflowing
|
|
72
|
+
overflow: isScrollContentOverflowing ? undefined : 'visible',
|
|
70
73
|
style: styles == null ? void 0 : styles.root,
|
|
71
74
|
testID: testID,
|
|
72
75
|
width: width,
|
|
@@ -88,7 +91,11 @@ const TabbedChipsComponent = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function
|
|
|
88
91
|
style: styles == null ? void 0 : styles.tabs,
|
|
89
92
|
tabs: tabs
|
|
90
93
|
}, accessibilityProps))
|
|
91
|
-
}), isScrollContentOverflowing &&
|
|
94
|
+
}), isScrollContentOverflowing && isScrollContentOffscreenLeft && /*#__PURE__*/_jsx(OverflowGradient, {
|
|
95
|
+
pin: "left"
|
|
96
|
+
}), isScrollContentOverflowing && isScrollContentOffscreenRight && /*#__PURE__*/_jsx(OverflowGradient, {
|
|
97
|
+
pin: "right"
|
|
98
|
+
})]
|
|
92
99
|
});
|
|
93
100
|
}));
|
|
94
101
|
TabbedChipsComponent.displayName = 'TabbedChips';
|
|
@@ -21,11 +21,13 @@ const Demo = _ref => {
|
|
|
21
21
|
let {
|
|
22
22
|
tabs = defaultTabs,
|
|
23
23
|
compact = false,
|
|
24
|
-
width
|
|
24
|
+
width,
|
|
25
|
+
autoScrollOffset
|
|
25
26
|
} = _ref;
|
|
26
27
|
const [value, setValue] = useState(tabs[0]);
|
|
27
28
|
return /*#__PURE__*/_jsx(TabbedChips, {
|
|
28
29
|
activeTab: value,
|
|
30
|
+
autoScrollOffset: autoScrollOffset,
|
|
29
31
|
compact: compact,
|
|
30
32
|
onChange: setValue,
|
|
31
33
|
tabs: tabs,
|
|
@@ -94,6 +96,12 @@ const TabbedChipsScreen = () => {
|
|
|
94
96
|
compact: true,
|
|
95
97
|
tabs: compactTabsWithStart
|
|
96
98
|
})
|
|
99
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
100
|
+
title: "With auto scroll offset",
|
|
101
|
+
children: /*#__PURE__*/_jsx(Demo, {
|
|
102
|
+
autoScrollOffset: 100,
|
|
103
|
+
tabs: sampleTabs
|
|
104
|
+
})
|
|
97
105
|
})]
|
|
98
106
|
});
|
|
99
107
|
};
|
|
@@ -9,7 +9,7 @@ import { Example, ExampleScreen } from '../../examples/ExampleScreen';
|
|
|
9
9
|
import { Icon } from '../../icons';
|
|
10
10
|
import { HStack, VStack } from '../../layout';
|
|
11
11
|
import { Pressable } from '../../system';
|
|
12
|
-
import {
|
|
12
|
+
import { Text } from '../../typography';
|
|
13
13
|
import { SlideButton } from '../SlideButton';
|
|
14
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
const SlideButtonExample = _ref => {
|
|
@@ -28,7 +28,8 @@ const SlideButtonExample = _ref => {
|
|
|
28
28
|
gap: 1,
|
|
29
29
|
justifyContent: "flex-end",
|
|
30
30
|
paddingBottom: 2,
|
|
31
|
-
children: [/*#__PURE__*/_jsx(
|
|
31
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
32
|
+
font: "label1",
|
|
32
33
|
children: "Reset"
|
|
33
34
|
}), /*#__PURE__*/_jsx(IconButton, {
|
|
34
35
|
compact: true,
|
|
@@ -64,7 +65,8 @@ const CustomHandle = _ref2 => {
|
|
|
64
65
|
height: "100%",
|
|
65
66
|
padding: 2,
|
|
66
67
|
pin: "right",
|
|
67
|
-
children: /*#__PURE__*/_jsx(
|
|
68
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
69
|
+
font: "label1",
|
|
68
70
|
children: "\u27A1\uFE0F"
|
|
69
71
|
})
|
|
70
72
|
})
|
|
@@ -85,7 +87,8 @@ const CustomBackground = _ref3 => {
|
|
|
85
87
|
height: "100%",
|
|
86
88
|
justifyContent: "center",
|
|
87
89
|
width: "100%",
|
|
88
|
-
children: /*#__PURE__*/_jsx(
|
|
90
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
91
|
+
font: "headline",
|
|
89
92
|
children: "Slide me"
|
|
90
93
|
})
|
|
91
94
|
}));
|
|
@@ -132,11 +135,13 @@ export const SlideButtonStories = () => {
|
|
|
132
135
|
}), /*#__PURE__*/_jsx(Example, {
|
|
133
136
|
title: "Labels as nodes",
|
|
134
137
|
children: /*#__PURE__*/_jsx(SlideButtonExample, {
|
|
135
|
-
checkedLabel: /*#__PURE__*/_jsx(
|
|
138
|
+
checkedLabel: /*#__PURE__*/_jsx(Text, {
|
|
136
139
|
color: "fgInverse",
|
|
140
|
+
font: "label2",
|
|
137
141
|
children: "Node checked label"
|
|
138
142
|
}),
|
|
139
|
-
uncheckedLabel: /*#__PURE__*/_jsx(
|
|
143
|
+
uncheckedLabel: /*#__PURE__*/_jsx(Text, {
|
|
144
|
+
font: "label2",
|
|
140
145
|
children: "Node label"
|
|
141
146
|
})
|
|
142
147
|
})
|