@plexui/react-native 0.2.1 → 0.2.2
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.
|
@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
|
|
|
3
3
|
import { Animated, Easing, Platform, Pressable, StyleSheet, View } from "react-native";
|
|
4
4
|
import ChevronDownSm from "../../icons/plex/ChevronDownSm";
|
|
5
5
|
import CloseBold from "../../icons/plex/CloseBold";
|
|
6
|
+
import XCircleFilled from "../../icons/plex/XCircleFilled";
|
|
6
7
|
import { spaceToggles } from "../../internal/a11y";
|
|
7
8
|
import { Glass } from "../../internal/Glass";
|
|
8
9
|
import { withAlpha } from "../../theme/material";
|
|
@@ -17,14 +18,46 @@ import { Text, textStyle } from "../Text/Text";
|
|
|
17
18
|
* one in the app's accent (its tint) with a white label. The web has
|
|
18
19
|
* no Chip; the props follow Toggle-like controls (`selected`, `onSelectedChange`) and Badge's `onRemove`.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
/** The chosen token's way to let go, so that choosing another lets it go */
|
|
22
|
+
let disarmToken = null;
|
|
23
|
+
export function Chip({ children, selected: selectedProp, defaultSelected, onSelectedChange, onPress, icon, trailingIcon, menu, expanded, accessibilityLabel, appearance = "tag", onRemove, removeLabel = "Remove", removeStyle = "token", disabled = false, testID, style, }) {
|
|
21
24
|
const theme = useTheme();
|
|
22
25
|
const [own, setOwn] = useState(defaultSelected ?? false);
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
// iOS's token: an input chip with no cross, chosen by a first press and removed by a second (or by Delete); it is
|
|
27
|
+
// never a filter as well
|
|
28
|
+
const token = !theme.isAndroid && onRemove != null && removeStyle === "token";
|
|
29
|
+
const filter = !token && (selectedProp !== undefined || defaultSelected !== undefined || onSelectedChange !== undefined);
|
|
30
|
+
const [armed, setArmedState] = useState(false);
|
|
31
|
+
// One token is chosen at a time, as in a token field: choosing one lets the last one go (a tap on a native view
|
|
32
|
+
// never moves focus, so a blur alone cannot)
|
|
33
|
+
const [disarm] = useState(() => () => setArmedState(false));
|
|
34
|
+
const setArmed = (on) => {
|
|
35
|
+
if (on) {
|
|
36
|
+
if (disarmToken !== disarm)
|
|
37
|
+
disarmToken?.();
|
|
38
|
+
disarmToken = disarm;
|
|
39
|
+
}
|
|
40
|
+
else if (disarmToken === disarm) {
|
|
41
|
+
disarmToken = null;
|
|
42
|
+
}
|
|
43
|
+
setArmedState(on);
|
|
44
|
+
};
|
|
45
|
+
useEffect(() => () => {
|
|
46
|
+
if (disarmToken === disarm)
|
|
47
|
+
disarmToken = null;
|
|
48
|
+
}, [disarm]);
|
|
49
|
+
const selected = filter ? (selectedProp ?? own) : token && armed;
|
|
25
50
|
const press = () => {
|
|
26
51
|
if (disabled)
|
|
27
52
|
return;
|
|
53
|
+
if (token) {
|
|
54
|
+
if (armed) {
|
|
55
|
+
setArmed(false);
|
|
56
|
+
onRemove?.();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
setArmed(true);
|
|
60
|
+
}
|
|
28
61
|
if (filter) {
|
|
29
62
|
if (selectedProp === undefined)
|
|
30
63
|
setOwn(!selected);
|
|
@@ -85,6 +118,9 @@ export function Chip({ children, selected: selectedProp, defaultSelected, onSele
|
|
|
85
118
|
const leadingColor = color;
|
|
86
119
|
// A symbol alone (Maps' filter button before its chips): a circle as tall as the chip, named by accessibilityLabel
|
|
87
120
|
const symbolOnly = leading != null && (children == null || children === "") && trailing == null && !onRemove;
|
|
121
|
+
// An input chip's cross stands in a target of its own after the chip's press: on iOS the field's clear button
|
|
122
|
+
const cross = onRemove != null && !token;
|
|
123
|
+
const clearSize = 17 * 1.2;
|
|
88
124
|
// The chip is drawn 32 (34) tall inside a 48dp (44pt) touch target, as Compose's minimum interactive size and the
|
|
89
125
|
// HIG ask: the target is the layout box, the chip a layer inside it, so every press in the target reaches it
|
|
90
126
|
const target = android ? 48 : 44;
|
|
@@ -103,14 +139,14 @@ export function Chip({ children, selected: selectedProp, defaultSelected, onSele
|
|
|
103
139
|
// Android: 12 at the sides, 8 before an icon and 6 after it
|
|
104
140
|
paddingLeft: symbolOnly ? (height - iconSize) / 2 : leading != null ? (android ? 8 : 12) : android ? 12 : 16,
|
|
105
141
|
// Android: 8 after a trailing icon (Compose's FilterChip), iOS 12
|
|
106
|
-
paddingRight: symbolOnly ? (height - iconSize) / 2 :
|
|
142
|
+
paddingRight: symbolOnly ? (height - iconSize) / 2 : cross ? 0 : trailing != null ? (android ? 8 : 12) : android ? 12 : 16,
|
|
107
143
|
gap: 6,
|
|
108
144
|
opacity: !android && pressed ? 0.7 : 1,
|
|
109
145
|
};
|
|
110
146
|
const body = (_jsxs(_Fragment, { children: [leading != null ? (_jsx(View, { children: _jsx(IconDefaultsProvider, { size: iconSize, color: leadingColor, children: leading }) })) : null, symbolOnly ? null : android ? (
|
|
111
147
|
// Text's own face and tracking, in a color that blends
|
|
112
|
-
_jsx(Animated.Text, { numberOfLines: 1, style: [textStyle(theme, { weight: "regular" }), { fontSize: label.fontSize, lineHeight: label.lineHeight, letterSpacing: theme.tracking(label.fontSize), color: labelPaint }], children: children })) : (_jsx(Text, { color: color, weight: "regular", numberOfLines: 1, style: { fontSize: label.fontSize, lineHeight: label.lineHeight }, children: children })), trailing != null ? (_jsx(View, { children: _jsx(IconDefaultsProvider, { size: iconSize, color: leadingColor, children: trailing }) })) : null] }));
|
|
113
|
-
const interactive = filter || !!onPress;
|
|
148
|
+
_jsx(Animated.Text, { numberOfLines: 1, selectable: false, style: [textStyle(theme, { weight: "regular" }), { fontSize: label.fontSize, lineHeight: label.lineHeight, letterSpacing: theme.tracking(label.fontSize), color: labelPaint }], children: children })) : (_jsx(Text, { color: color, weight: "regular", numberOfLines: 1, selectable: false, style: { fontSize: label.fontSize, lineHeight: label.lineHeight }, children: children })), trailing != null ? (_jsx(View, { children: _jsx(IconDefaultsProvider, { size: iconSize, color: leadingColor, children: trailing }) })) : null] }));
|
|
149
|
+
const interactive = filter || !!onPress || token;
|
|
114
150
|
// Android dims a disabled chip, its fill with it, to half (as its other disabled controls)
|
|
115
151
|
const dim = android && disabled ? styles.dim : null;
|
|
116
152
|
const handlers = {
|
|
@@ -118,19 +154,43 @@ export function Chip({ children, selected: selectedProp, defaultSelected, onSele
|
|
|
118
154
|
// A menu chip is a button that opens its menu, even when it shows a chosen filter
|
|
119
155
|
accessibilityRole: filter && !menu ? "checkbox" : "button",
|
|
120
156
|
accessibilityLabel,
|
|
121
|
-
accessibilityState: {
|
|
157
|
+
accessibilityState: {
|
|
158
|
+
disabled,
|
|
159
|
+
checked: filter && !menu ? selected : undefined,
|
|
160
|
+
// A chosen token says so before the next press removes it
|
|
161
|
+
selected: token ? armed : filter && menu && Platform.OS !== "web" ? selected : undefined,
|
|
162
|
+
expanded,
|
|
163
|
+
},
|
|
122
164
|
"aria-checked": filter && !menu ? selected : undefined,
|
|
165
|
+
// react-native-web drops `selected` on a button: the web reads a chosen token as pressed
|
|
166
|
+
"aria-pressed": token && Platform.OS === "web" ? armed : undefined,
|
|
123
167
|
"aria-haspopup": menu ? (menu === true ? "menu" : menu) : undefined,
|
|
124
168
|
"aria-expanded": menu ? expanded : undefined,
|
|
125
169
|
disabled,
|
|
126
170
|
onPress: press,
|
|
171
|
+
// A token: VoiceOver's action and a keyboard's Delete remove it; leaving it lets the selection go
|
|
172
|
+
...(token
|
|
173
|
+
? {
|
|
174
|
+
accessibilityActions: [{ name: "delete", label: removeLabel }],
|
|
175
|
+
onAccessibilityAction: (event) => {
|
|
176
|
+
if (event.nativeEvent.actionName === "delete" && !disabled)
|
|
177
|
+
onRemove?.();
|
|
178
|
+
},
|
|
179
|
+
onBlur: () => armed && setArmed(false),
|
|
180
|
+
onKeyDown: (event) => {
|
|
181
|
+
if ((event.nativeEvent.key === "Backspace" || event.nativeEvent.key === "Delete") && !disabled)
|
|
182
|
+
onRemove?.();
|
|
183
|
+
},
|
|
184
|
+
"aria-keyshortcuts": "Delete Backspace",
|
|
185
|
+
}
|
|
186
|
+
: {}),
|
|
127
187
|
onPressIn: () => setPressed(true),
|
|
128
188
|
onPressOut: () => setPressed(false),
|
|
129
189
|
};
|
|
130
190
|
// An input chip holds its cross beside the chip's own press, never a button inside a button; each takes the
|
|
131
191
|
// target's full height
|
|
132
|
-
if (
|
|
133
|
-
return (_jsxs(View, { testID: testID, style: [styles.chip, { minHeight: target }, dim, style], children: [layer, interactive ? (_jsx(Pressable, { ...handlers, style: [styles.part, box], children: body })) : (_jsx(View, { style: [styles.part, box], children: body })), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: removeLabel, disabled: disabled, onPress: onRemove, style: [styles.part,
|
|
192
|
+
if (cross) {
|
|
193
|
+
return (_jsxs(View, { testID: testID, style: [styles.chip, { minHeight: target }, dim, style], children: [layer, interactive ? (_jsx(Pressable, { ...handlers, style: [styles.part, box], children: body })) : (_jsx(View, { style: [styles.part, box], children: body })), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: removeLabel, disabled: disabled, onPress: onRemove, style: [styles.part, android ? { paddingLeft: 4, paddingRight: 8 } : { width: 44, justifyContent: "center" }], children: android ? _jsx(CloseBold, { size: 18, color: color }) : _jsx(XCircleFilled, { size: clearSize, color: theme.color("--mobile-label-tertiary") }) })] }));
|
|
134
194
|
}
|
|
135
195
|
if (!interactive) {
|
|
136
196
|
return (_jsxs(View, { testID: testID, style: [styles.chip, styles.part, box, dim, style], children: [layer, body] }));
|
|
@@ -28,19 +28,21 @@ export type ChipProps = {
|
|
|
28
28
|
* either. @default "tag"
|
|
29
29
|
*/
|
|
30
30
|
appearance?: "tag" | "glass";
|
|
31
|
-
/** An input chip: a cross
|
|
31
|
+
/** An input chip: called when the reader takes the value back (a cross on Android; see `removeStyle` on iOS). */
|
|
32
32
|
onRemove?: () => void;
|
|
33
|
-
/** @default "Remove" */
|
|
33
|
+
/** The remove action's name, for screen readers. @default "Remove" */
|
|
34
34
|
removeLabel?: string;
|
|
35
|
+
/**
|
|
36
|
+
* How an input chip is removed on iOS. `token`, as Apple's tokens (search tokens in Mail, Photos and Files; Mail's
|
|
37
|
+
* recipients): no cross; a press selects the chip in the accent (and lets the last chosen token go) and a second press, or Delete on a
|
|
38
|
+
* keyboard on the web, removes
|
|
39
|
+
* it; VoiceOver offers `removeLabel` as an action. `button`: a cross after the label in the field's clear button
|
|
40
|
+
* (xmark.circle.fill, 17pt in the tertiary label, a 44pt target). Android keeps Material's 18dp cross with either.
|
|
41
|
+
* @default "token"
|
|
42
|
+
*/
|
|
43
|
+
removeStyle?: "token" | "button";
|
|
35
44
|
disabled?: boolean;
|
|
36
45
|
testID?: string;
|
|
37
46
|
style?: StyleProp<ViewStyle>;
|
|
38
47
|
};
|
|
39
|
-
|
|
40
|
-
* A compact choice or action. Android: a chip (a 32dp capsule filled with the text color at 5%, Regular 14; a
|
|
41
|
-
* selected one in the Plex primary). iOS has no chip control: the filter capsules of iOS 26 apps (Maps), measured on
|
|
42
|
-
* an iPhone: a `tag` 40pt tall in the gray fill, or a `glass` capsule 44pt tall, the label 17/22 Regular; a selected
|
|
43
|
-
* one in the app's accent (its tint) with a white label. The web has
|
|
44
|
-
* no Chip; the props follow Toggle-like controls (`selected`, `onSelectedChange`) and Badge's `onRemove`.
|
|
45
|
-
*/
|
|
46
|
-
export declare function Chip({ children, selected: selectedProp, defaultSelected, onSelectedChange, onPress, icon, trailingIcon, menu, expanded, accessibilityLabel, appearance, onRemove, removeLabel, disabled, testID, style, }: ChipProps): import("react").JSX.Element;
|
|
48
|
+
export declare function Chip({ children, selected: selectedProp, defaultSelected, onSelectedChange, onPress, icon, trailingIcon, menu, expanded, accessibilityLabel, appearance, onRemove, removeLabel, removeStyle, disabled, testID, style, }: ChipProps): import("react").JSX.Element;
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { useEffect, useState, type ReactNode } from "react"
|
|
|
2
2
|
import { Animated, Easing, Platform, Pressable, StyleSheet, View, type StyleProp, type ViewStyle } from "react-native"
|
|
3
3
|
import ChevronDownSm from "../../icons/plex/ChevronDownSm"
|
|
4
4
|
import CloseBold from "../../icons/plex/CloseBold"
|
|
5
|
+
import XCircleFilled from "../../icons/plex/XCircleFilled"
|
|
5
6
|
import { spaceToggles } from "../../internal/a11y"
|
|
6
7
|
import { Glass } from "../../internal/Glass"
|
|
7
8
|
import { withAlpha } from "../../theme/material"
|
|
@@ -38,10 +39,19 @@ export type ChipProps = {
|
|
|
38
39
|
* either. @default "tag"
|
|
39
40
|
*/
|
|
40
41
|
appearance?: "tag" | "glass"
|
|
41
|
-
/** An input chip: a cross
|
|
42
|
+
/** An input chip: called when the reader takes the value back (a cross on Android; see `removeStyle` on iOS). */
|
|
42
43
|
onRemove?: () => void
|
|
43
|
-
/** @default "Remove" */
|
|
44
|
+
/** The remove action's name, for screen readers. @default "Remove" */
|
|
44
45
|
removeLabel?: string
|
|
46
|
+
/**
|
|
47
|
+
* How an input chip is removed on iOS. `token`, as Apple's tokens (search tokens in Mail, Photos and Files; Mail's
|
|
48
|
+
* recipients): no cross; a press selects the chip in the accent (and lets the last chosen token go) and a second press, or Delete on a
|
|
49
|
+
* keyboard on the web, removes
|
|
50
|
+
* it; VoiceOver offers `removeLabel` as an action. `button`: a cross after the label in the field's clear button
|
|
51
|
+
* (xmark.circle.fill, 17pt in the tertiary label, a 44pt target). Android keeps Material's 18dp cross with either.
|
|
52
|
+
* @default "token"
|
|
53
|
+
*/
|
|
54
|
+
removeStyle?: "token" | "button"
|
|
45
55
|
disabled?: boolean
|
|
46
56
|
testID?: string
|
|
47
57
|
style?: StyleProp<ViewStyle>
|
|
@@ -54,6 +64,9 @@ export type ChipProps = {
|
|
|
54
64
|
* one in the app's accent (its tint) with a white label. The web has
|
|
55
65
|
* no Chip; the props follow Toggle-like controls (`selected`, `onSelectedChange`) and Badge's `onRemove`.
|
|
56
66
|
*/
|
|
67
|
+
/** The chosen token's way to let go, so that choosing another lets it go */
|
|
68
|
+
let disarmToken: (() => void) | null = null
|
|
69
|
+
|
|
57
70
|
export function Chip({
|
|
58
71
|
children,
|
|
59
72
|
selected: selectedProp,
|
|
@@ -68,16 +81,47 @@ export function Chip({
|
|
|
68
81
|
appearance = "tag",
|
|
69
82
|
onRemove,
|
|
70
83
|
removeLabel = "Remove",
|
|
84
|
+
removeStyle = "token",
|
|
71
85
|
disabled = false,
|
|
72
86
|
testID,
|
|
73
87
|
style,
|
|
74
88
|
}: ChipProps) {
|
|
75
89
|
const theme = useTheme()
|
|
76
90
|
const [own, setOwn] = useState(defaultSelected ?? false)
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
// iOS's token: an input chip with no cross, chosen by a first press and removed by a second (or by Delete); it is
|
|
92
|
+
// never a filter as well
|
|
93
|
+
const token = !theme.isAndroid && onRemove != null && removeStyle === "token"
|
|
94
|
+
const filter = !token && (selectedProp !== undefined || defaultSelected !== undefined || onSelectedChange !== undefined)
|
|
95
|
+
const [armed, setArmedState] = useState(false)
|
|
96
|
+
// One token is chosen at a time, as in a token field: choosing one lets the last one go (a tap on a native view
|
|
97
|
+
// never moves focus, so a blur alone cannot)
|
|
98
|
+
const [disarm] = useState(() => () => setArmedState(false))
|
|
99
|
+
const setArmed = (on: boolean) => {
|
|
100
|
+
if (on) {
|
|
101
|
+
if (disarmToken !== disarm) disarmToken?.()
|
|
102
|
+
disarmToken = disarm
|
|
103
|
+
} else if (disarmToken === disarm) {
|
|
104
|
+
disarmToken = null
|
|
105
|
+
}
|
|
106
|
+
setArmedState(on)
|
|
107
|
+
}
|
|
108
|
+
useEffect(
|
|
109
|
+
() => () => {
|
|
110
|
+
if (disarmToken === disarm) disarmToken = null
|
|
111
|
+
},
|
|
112
|
+
[disarm],
|
|
113
|
+
)
|
|
114
|
+
const selected = filter ? (selectedProp ?? own) : token && armed
|
|
79
115
|
const press = () => {
|
|
80
116
|
if (disabled) return
|
|
117
|
+
if (token) {
|
|
118
|
+
if (armed) {
|
|
119
|
+
setArmed(false)
|
|
120
|
+
onRemove?.()
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
setArmed(true)
|
|
124
|
+
}
|
|
81
125
|
if (filter) {
|
|
82
126
|
if (selectedProp === undefined) setOwn(!selected)
|
|
83
127
|
onSelectedChange?.(!selected)
|
|
@@ -137,6 +181,9 @@ export function Chip({
|
|
|
137
181
|
const leadingColor = color
|
|
138
182
|
// A symbol alone (Maps' filter button before its chips): a circle as tall as the chip, named by accessibilityLabel
|
|
139
183
|
const symbolOnly = leading != null && (children == null || children === "") && trailing == null && !onRemove
|
|
184
|
+
// An input chip's cross stands in a target of its own after the chip's press: on iOS the field's clear button
|
|
185
|
+
const cross = onRemove != null && !token
|
|
186
|
+
const clearSize = 17 * 1.2
|
|
140
187
|
// The chip is drawn 32 (34) tall inside a 48dp (44pt) touch target, as Compose's minimum interactive size and the
|
|
141
188
|
// HIG ask: the target is the layout box, the chip a layer inside it, so every press in the target reaches it
|
|
142
189
|
const target = android ? 48 : 44
|
|
@@ -164,7 +211,7 @@ export function Chip({
|
|
|
164
211
|
// Android: 12 at the sides, 8 before an icon and 6 after it
|
|
165
212
|
paddingLeft: symbolOnly ? (height - iconSize) / 2 : leading != null ? (android ? 8 : 12) : android ? 12 : 16,
|
|
166
213
|
// Android: 8 after a trailing icon (Compose's FilterChip), iOS 12
|
|
167
|
-
paddingRight: symbolOnly ? (height - iconSize) / 2 :
|
|
214
|
+
paddingRight: symbolOnly ? (height - iconSize) / 2 : cross ? 0 : trailing != null ? (android ? 8 : 12) : android ? 12 : 16,
|
|
168
215
|
gap: 6,
|
|
169
216
|
opacity: !android && pressed ? 0.7 : 1,
|
|
170
217
|
}
|
|
@@ -182,12 +229,13 @@ export function Chip({
|
|
|
182
229
|
// Text's own face and tracking, in a color that blends
|
|
183
230
|
<Animated.Text
|
|
184
231
|
numberOfLines={1}
|
|
232
|
+
selectable={false}
|
|
185
233
|
style={[textStyle(theme, { weight: "regular" }), { fontSize: label.fontSize, lineHeight: label.lineHeight, letterSpacing: theme.tracking(label.fontSize), color: labelPaint }]}
|
|
186
234
|
>
|
|
187
235
|
{children}
|
|
188
236
|
</Animated.Text>
|
|
189
237
|
) : (
|
|
190
|
-
<Text color={color} weight="regular" numberOfLines={1} style={{ fontSize: label.fontSize, lineHeight: label.lineHeight }}>
|
|
238
|
+
<Text color={color} weight="regular" numberOfLines={1} selectable={false} style={{ fontSize: label.fontSize, lineHeight: label.lineHeight }}>
|
|
191
239
|
{children}
|
|
192
240
|
</Text>
|
|
193
241
|
)}
|
|
@@ -200,7 +248,7 @@ export function Chip({
|
|
|
200
248
|
) : null}
|
|
201
249
|
</>
|
|
202
250
|
)
|
|
203
|
-
const interactive = filter || !!onPress
|
|
251
|
+
const interactive = filter || !!onPress || token
|
|
204
252
|
// Android dims a disabled chip, its fill with it, to half (as its other disabled controls)
|
|
205
253
|
const dim = android && disabled ? styles.dim : null
|
|
206
254
|
const handlers = {
|
|
@@ -208,18 +256,40 @@ export function Chip({
|
|
|
208
256
|
// A menu chip is a button that opens its menu, even when it shows a chosen filter
|
|
209
257
|
accessibilityRole: filter && !menu ? ("checkbox" as const) : ("button" as const),
|
|
210
258
|
accessibilityLabel,
|
|
211
|
-
accessibilityState: {
|
|
259
|
+
accessibilityState: {
|
|
260
|
+
disabled,
|
|
261
|
+
checked: filter && !menu ? selected : undefined,
|
|
262
|
+
// A chosen token says so before the next press removes it
|
|
263
|
+
selected: token ? armed : filter && menu && Platform.OS !== "web" ? selected : undefined,
|
|
264
|
+
expanded,
|
|
265
|
+
},
|
|
212
266
|
"aria-checked": filter && !menu ? selected : undefined,
|
|
267
|
+
// react-native-web drops `selected` on a button: the web reads a chosen token as pressed
|
|
268
|
+
"aria-pressed": token && Platform.OS === "web" ? armed : undefined,
|
|
213
269
|
"aria-haspopup": menu ? (menu === true ? ("menu" as const) : menu) : undefined,
|
|
214
270
|
"aria-expanded": menu ? expanded : undefined,
|
|
215
271
|
disabled,
|
|
216
272
|
onPress: press,
|
|
273
|
+
// A token: VoiceOver's action and a keyboard's Delete remove it; leaving it lets the selection go
|
|
274
|
+
...(token
|
|
275
|
+
? {
|
|
276
|
+
accessibilityActions: [{ name: "delete", label: removeLabel }],
|
|
277
|
+
onAccessibilityAction: (event: { nativeEvent: { actionName: string } }) => {
|
|
278
|
+
if (event.nativeEvent.actionName === "delete" && !disabled) onRemove?.()
|
|
279
|
+
},
|
|
280
|
+
onBlur: () => armed && setArmed(false),
|
|
281
|
+
onKeyDown: (event: { nativeEvent: { key?: string } }) => {
|
|
282
|
+
if ((event.nativeEvent.key === "Backspace" || event.nativeEvent.key === "Delete") && !disabled) onRemove?.()
|
|
283
|
+
},
|
|
284
|
+
"aria-keyshortcuts": "Delete Backspace",
|
|
285
|
+
}
|
|
286
|
+
: {}),
|
|
217
287
|
onPressIn: () => setPressed(true),
|
|
218
288
|
onPressOut: () => setPressed(false),
|
|
219
289
|
}
|
|
220
290
|
// An input chip holds its cross beside the chip's own press, never a button inside a button; each takes the
|
|
221
291
|
// target's full height
|
|
222
|
-
if (
|
|
292
|
+
if (cross) {
|
|
223
293
|
return (
|
|
224
294
|
<View testID={testID} style={[styles.chip, { minHeight: target }, dim, style]}>
|
|
225
295
|
{layer}
|
|
@@ -235,9 +305,9 @@ export function Chip({
|
|
|
235
305
|
accessibilityLabel={removeLabel}
|
|
236
306
|
disabled={disabled}
|
|
237
307
|
onPress={onRemove}
|
|
238
|
-
style={[styles.part,
|
|
308
|
+
style={[styles.part, android ? { paddingLeft: 4, paddingRight: 8 } : { width: 44, justifyContent: "center" }]}
|
|
239
309
|
>
|
|
240
|
-
<CloseBold size={
|
|
310
|
+
{android ? <CloseBold size={18} color={color} /> : <XCircleFilled size={clearSize} color={theme.color("--mobile-label-tertiary")} />}
|
|
241
311
|
</Pressable>
|
|
242
312
|
</View>
|
|
243
313
|
)
|