@kanso-labs/react-native-kanso-ui 0.0.0-stage → 0.1.1
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/LICENSE.md +20 -0
- package/README.md +205 -2
- package/dist/button/index.d.ts +56 -0
- package/dist/button/index.js +169 -0
- package/dist/button/index.js.map +1 -0
- package/dist/button/palettes.js +47 -0
- package/dist/button/palettes.js.map +1 -0
- package/dist/chip/index.js +194 -0
- package/dist/chip/index.js.map +1 -0
- package/dist/chip/styles.js +36 -0
- package/dist/chip/styles.js.map +1 -0
- package/dist/clipboard/index.js +58 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/components/avatar/index.d.ts +82 -0
- package/dist/components/avatar/index.js +62 -0
- package/dist/components/avatar/index.js.map +1 -0
- package/dist/components/button/index.d.ts +87 -0
- package/dist/components/button/index.js +377 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/card/index.d.ts +78 -0
- package/dist/components/card/index.js +315 -0
- package/dist/components/card/index.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +76 -0
- package/dist/components/checkbox/index.js +360 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/chip/index.d.ts +84 -0
- package/dist/components/chip/index.js +257 -0
- package/dist/components/chip/index.js.map +1 -0
- package/dist/components/chip-group/index.d.ts +143 -0
- package/dist/components/chip-group/index.js +669 -0
- package/dist/components/chip-group/index.js.map +1 -0
- package/dist/components/copy-field/index.d.ts +60 -0
- package/dist/components/copy-field/index.js +277 -0
- package/dist/components/copy-field/index.js.map +1 -0
- package/dist/components/currency/index.d.ts +69 -0
- package/dist/components/currency/index.js +162 -0
- package/dist/components/currency/index.js.map +1 -0
- package/dist/components/form/index.d.ts +84 -0
- package/dist/components/form/index.js +95 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/icon-button/index.d.ts +68 -0
- package/dist/components/icon-button/index.js +289 -0
- package/dist/components/icon-button/index.js.map +1 -0
- package/dist/components/link/index.d.ts +59 -0
- package/dist/components/link/index.js +191 -0
- package/dist/components/link/index.js.map +1 -0
- package/dist/components/number-field/index.d.ts +151 -0
- package/dist/components/number-field/index.js +832 -0
- package/dist/components/number-field/index.js.map +1 -0
- package/dist/components/product-icon/index.d.ts +70 -0
- package/dist/components/product-icon/index.js +60 -0
- package/dist/components/product-icon/index.js.map +1 -0
- package/dist/components/radio-group/index.d.ts +105 -0
- package/dist/components/radio-group/index.js +597 -0
- package/dist/components/radio-group/index.js.map +1 -0
- package/dist/components/search-field/index.d.ts +98 -0
- package/dist/components/search-field/index.js +521 -0
- package/dist/components/search-field/index.js.map +1 -0
- package/dist/components/segmented-button/index.d.ts +113 -0
- package/dist/components/segmented-button/index.js +937 -0
- package/dist/components/segmented-button/index.js.map +1 -0
- package/dist/components/separator/index.d.ts +45 -0
- package/dist/components/separator/index.js +109 -0
- package/dist/components/separator/index.js.map +1 -0
- package/dist/components/stack/index.d.ts +70 -0
- package/dist/components/stack/index.js +107 -0
- package/dist/components/stack/index.js.map +1 -0
- package/dist/components/switch/index.d.ts +76 -0
- package/dist/components/switch/index.js +591 -0
- package/dist/components/switch/index.js.map +1 -0
- package/dist/components/text/index.d.ts +44 -0
- package/dist/components/text/index.js +78 -0
- package/dist/components/text/index.js.map +1 -0
- package/dist/components/text-field/index.d.ts +146 -0
- package/dist/components/text-field/index.js +228 -0
- package/dist/components/text-field/index.js.map +1 -0
- package/dist/control/index.js +117 -0
- package/dist/control/index.js.map +1 -0
- package/dist/control/styles.js +36 -0
- package/dist/control/styles.js.map +1 -0
- package/dist/field/index.d.ts +13 -0
- package/dist/field/index.js +1007 -0
- package/dist/field/index.js.map +1 -0
- package/dist/field/styles.js +131 -0
- package/dist/field/styles.js.map +1 -0
- package/dist/form/index.d.ts +24 -0
- package/dist/form/index.js +209 -0
- package/dist/form/index.js.map +1 -0
- package/dist/glyphs/icon-style.d.ts +25 -0
- package/dist/glyphs/icon-style.js +22 -0
- package/dist/glyphs/icon-style.js.map +1 -0
- package/dist/glyphs/index.js +170 -0
- package/dist/glyphs/index.js.map +1 -0
- package/dist/glyphs/styles.js +7 -0
- package/dist/glyphs/styles.js.map +1 -0
- package/dist/hooks/useWindowSizeClass.d.ts +25 -0
- package/dist/hooks/useWindowSizeClass.js +39 -0
- package/dist/hooks/useWindowSizeClass.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +27 -0
- package/dist/mark/image.js +61 -0
- package/dist/mark/image.js.map +1 -0
- package/dist/mark/index.d.ts +9 -0
- package/dist/mark/index.js +234 -0
- package/dist/mark/index.js.map +1 -0
- package/dist/mark/initials.js +65 -0
- package/dist/mark/initials.js.map +1 -0
- package/dist/mark/styles.d.ts +1 -0
- package/dist/mark/styles.js +73 -0
- package/dist/mark/styles.js.map +1 -0
- package/dist/number/parser.js +321 -0
- package/dist/number/parser.js.map +1 -0
- package/dist/number/state.js +235 -0
- package/dist/number/state.js.map +1 -0
- package/dist/overlay/host.js +111 -0
- package/dist/overlay/host.js.map +1 -0
- package/dist/press/index.js +350 -0
- package/dist/press/index.js.map +1 -0
- package/dist/press/styles.js +31 -0
- package/dist/press/styles.js.map +1 -0
- package/dist/router/index.d.ts +28 -0
- package/dist/router/index.js +82 -0
- package/dist/router/index.js.map +1 -0
- package/dist/theme/color.js +25 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/resolve.d.ts +6 -0
- package/dist/theme/resolve.js +310 -0
- package/dist/theme/resolve.js.map +1 -0
- package/dist/theme/scope.d.ts +42 -0
- package/dist/theme/scope.js +80 -0
- package/dist/theme/scope.js.map +1 -0
- package/dist/theme/styles.js +39 -0
- package/dist/theme/styles.js.map +1 -0
- package/dist/theme-scope.d.ts +56 -0
- package/dist/theme-scope.js +127 -0
- package/dist/theme-scope.js.map +1 -0
- package/dist/tokens/defaults.d.ts +407 -0
- package/dist/tokens/defaults.js +403 -0
- package/dist/tokens/defaults.js.map +1 -0
- package/dist/typography/fonts.js +84 -0
- package/dist/typography/fonts.js.map +1 -0
- package/dist/typography/roles.d.ts +10 -0
- package/dist/typography/roles.js +82 -0
- package/dist/typography/roles.js.map +1 -0
- package/package.json +132 -4
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import { CloseGlyph } from "../../glyphs/index.js";
|
|
2
|
+
import { useTheme } from "../../theme/scope.js";
|
|
3
|
+
import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
4
|
+
import { useTypeRole } from "../../typography/roles.js";
|
|
5
|
+
import { AnimatedPressable, toggleState } from "../../button/index.js";
|
|
6
|
+
import { usePressFeedback } from "../../press/index.js";
|
|
7
|
+
import { stylesOf } from "../../chip/styles.js";
|
|
8
|
+
import { ChipGlyph, ChipLabel, measureThen, paintOf, targetOf, useEasedColors } from "../../chip/index.js";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import { Platform, Pressable, StyleSheet, Text, View } from "react-native";
|
|
11
|
+
import { useId, useState } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import Animated from "react-native-reanimated";
|
|
14
|
+
import { useListState } from "react-stately/useListState";
|
|
15
|
+
//#region src/components/chip-group/index.tsx
|
|
16
|
+
const REMOVE_REACH = {
|
|
17
|
+
bottom: 3,
|
|
18
|
+
left: 3,
|
|
19
|
+
right: 3,
|
|
20
|
+
top: 3
|
|
21
|
+
};
|
|
22
|
+
const styles = StyleSheet.create({
|
|
23
|
+
chip: { maxWidth: "100%" },
|
|
24
|
+
layer: {
|
|
25
|
+
bottom: 0,
|
|
26
|
+
left: 0,
|
|
27
|
+
position: "absolute",
|
|
28
|
+
right: 0,
|
|
29
|
+
top: 0
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const groupStylesOf = themedStyles(({ colors, radii, sizing, spacing, stateLayerOpacity }) => StyleSheet.create({
|
|
33
|
+
label: { color: colors.onSurfaceVariant },
|
|
34
|
+
labelError: { color: colors.error },
|
|
35
|
+
list: {
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
flexDirection: "row",
|
|
38
|
+
flexWrap: "wrap",
|
|
39
|
+
gap: spacing.sm,
|
|
40
|
+
minHeight: sizing.controlXs
|
|
41
|
+
},
|
|
42
|
+
message: { color: colors.onSurfaceVariant },
|
|
43
|
+
messageError: { color: colors.error },
|
|
44
|
+
messageLine: { marginTop: spacing.xs },
|
|
45
|
+
removable: { paddingEnd: spacing.lg + 18 },
|
|
46
|
+
remove: {
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
borderRadius: radii.circle,
|
|
49
|
+
end: 1 + spacing.lg - spacing.sm,
|
|
50
|
+
height: 18,
|
|
51
|
+
justifyContent: "center",
|
|
52
|
+
marginTop: -9,
|
|
53
|
+
position: "absolute",
|
|
54
|
+
top: "50%",
|
|
55
|
+
width: 18
|
|
56
|
+
},
|
|
57
|
+
removeHovered: { opacity: stateLayerOpacity.hover },
|
|
58
|
+
removeLayer: {
|
|
59
|
+
borderRadius: radii.circle,
|
|
60
|
+
opacity: 0
|
|
61
|
+
},
|
|
62
|
+
removePressed: { opacity: stateLayerOpacity.pressed },
|
|
63
|
+
root: {
|
|
64
|
+
flexDirection: "column",
|
|
65
|
+
rowGap: spacing.xs
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
/**
|
|
69
|
+
* A labelled set of chips, one or more of which can be chosen, each of which
|
|
70
|
+
* can be removed. Selection is React Stately's: set `selectionMode` to
|
|
71
|
+
* `single` or `multiple`, and pass `selectedKeys` with `onSelectionChange` to
|
|
72
|
+
* control it, or `defaultSelectedKeys` to let the group keep its own.
|
|
73
|
+
*
|
|
74
|
+
* ```tsx
|
|
75
|
+
* <ChipGroup label="Label" onRemove={remove} selectionMode="multiple">
|
|
76
|
+
* <ChipGroup.Chip id="first">First item</ChipGroup.Chip>
|
|
77
|
+
* </ChipGroup>
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* Give the group `onRemove` and each chip draws a close target. A chip that
|
|
81
|
+
* toggles nothing else is Chip; this is for a set that shares a value.
|
|
82
|
+
*
|
|
83
|
+
* A screen reader hears a group named by its label, and each chip as a button
|
|
84
|
+
* named by its label, selected or not. On the web the line under the group
|
|
85
|
+
* describes it, as web's does; on iOS and Android it is read after the chips,
|
|
86
|
+
* where it sits. `style`, `ref` and `testID` land on the group as a whole,
|
|
87
|
+
* which is the element a layout positions.
|
|
88
|
+
*/
|
|
89
|
+
function ChipGroup(t0) {
|
|
90
|
+
const $ = c(52);
|
|
91
|
+
let children;
|
|
92
|
+
let defaultSelectedKeys;
|
|
93
|
+
let description;
|
|
94
|
+
let disabledKeys;
|
|
95
|
+
let disallowEmptySelection;
|
|
96
|
+
let error;
|
|
97
|
+
let items;
|
|
98
|
+
let label;
|
|
99
|
+
let onRemove;
|
|
100
|
+
let onSelectionChange;
|
|
101
|
+
let props;
|
|
102
|
+
let renderEmptyState;
|
|
103
|
+
let selectedKeys;
|
|
104
|
+
let style;
|
|
105
|
+
let t1;
|
|
106
|
+
let t2;
|
|
107
|
+
if ($[0] !== t0) {
|
|
108
|
+
({children, defaultSelectedKeys, description, disabledKeys, disallowEmptySelection, error, items, label, onRemove, onSelectionChange, removeLabel: t1, renderEmptyState, selectedKeys, selectionMode: t2, style, ...props} = t0);
|
|
109
|
+
$[0] = t0;
|
|
110
|
+
$[1] = children;
|
|
111
|
+
$[2] = defaultSelectedKeys;
|
|
112
|
+
$[3] = description;
|
|
113
|
+
$[4] = disabledKeys;
|
|
114
|
+
$[5] = disallowEmptySelection;
|
|
115
|
+
$[6] = error;
|
|
116
|
+
$[7] = items;
|
|
117
|
+
$[8] = label;
|
|
118
|
+
$[9] = onRemove;
|
|
119
|
+
$[10] = onSelectionChange;
|
|
120
|
+
$[11] = props;
|
|
121
|
+
$[12] = renderEmptyState;
|
|
122
|
+
$[13] = selectedKeys;
|
|
123
|
+
$[14] = style;
|
|
124
|
+
$[15] = t1;
|
|
125
|
+
$[16] = t2;
|
|
126
|
+
} else {
|
|
127
|
+
children = $[1];
|
|
128
|
+
defaultSelectedKeys = $[2];
|
|
129
|
+
description = $[3];
|
|
130
|
+
disabledKeys = $[4];
|
|
131
|
+
disallowEmptySelection = $[5];
|
|
132
|
+
error = $[6];
|
|
133
|
+
items = $[7];
|
|
134
|
+
label = $[8];
|
|
135
|
+
onRemove = $[9];
|
|
136
|
+
onSelectionChange = $[10];
|
|
137
|
+
props = $[11];
|
|
138
|
+
renderEmptyState = $[12];
|
|
139
|
+
selectedKeys = $[13];
|
|
140
|
+
style = $[14];
|
|
141
|
+
t1 = $[15];
|
|
142
|
+
t2 = $[16];
|
|
143
|
+
}
|
|
144
|
+
const removeLabel = t1 === void 0 ? "Remove" : t1;
|
|
145
|
+
const selectionMode = t2 === void 0 ? "none" : t2;
|
|
146
|
+
const theme = useTheme();
|
|
147
|
+
const t3 = children;
|
|
148
|
+
let t4;
|
|
149
|
+
if ($[17] !== defaultSelectedKeys || $[18] !== disabledKeys || $[19] !== disallowEmptySelection || $[20] !== items || $[21] !== onSelectionChange || $[22] !== selectedKeys || $[23] !== selectionMode || $[24] !== t3) {
|
|
150
|
+
t4 = {
|
|
151
|
+
children: t3,
|
|
152
|
+
defaultSelectedKeys,
|
|
153
|
+
disabledKeys,
|
|
154
|
+
disallowEmptySelection,
|
|
155
|
+
items,
|
|
156
|
+
onSelectionChange,
|
|
157
|
+
selectedKeys,
|
|
158
|
+
selectionMode
|
|
159
|
+
};
|
|
160
|
+
$[17] = defaultSelectedKeys;
|
|
161
|
+
$[18] = disabledKeys;
|
|
162
|
+
$[19] = disallowEmptySelection;
|
|
163
|
+
$[20] = items;
|
|
164
|
+
$[21] = onSelectionChange;
|
|
165
|
+
$[22] = selectedKeys;
|
|
166
|
+
$[23] = selectionMode;
|
|
167
|
+
$[24] = t3;
|
|
168
|
+
$[25] = t4;
|
|
169
|
+
} else t4 = $[25];
|
|
170
|
+
const state = useListState(t4);
|
|
171
|
+
const labelId = useId();
|
|
172
|
+
const messageId = useId();
|
|
173
|
+
const labelRole = useTypeRole("labelLarge");
|
|
174
|
+
const messageRole = useTypeRole("bodySmall");
|
|
175
|
+
let t5;
|
|
176
|
+
if ($[26] !== description || $[27] !== error || $[28] !== label || $[29] !== labelId || $[30] !== labelRole || $[31] !== messageId || $[32] !== messageRole || $[33] !== onRemove || $[34] !== props || $[35] !== removeLabel || $[36] !== renderEmptyState || $[37] !== state || $[38] !== style || $[39] !== theme) {
|
|
177
|
+
const own = groupStylesOf(theme);
|
|
178
|
+
const invalid = error !== void 0;
|
|
179
|
+
const message = error ?? description;
|
|
180
|
+
let t6;
|
|
181
|
+
if ($[41] !== state.collection) {
|
|
182
|
+
t6 = [...state.collection];
|
|
183
|
+
$[41] = state.collection;
|
|
184
|
+
$[42] = t6;
|
|
185
|
+
} else t6 = $[42];
|
|
186
|
+
const nodes = t6;
|
|
187
|
+
let t7;
|
|
188
|
+
if ($[43] !== message || $[44] !== messageId) {
|
|
189
|
+
t7 = lineOf(messageId, message);
|
|
190
|
+
$[43] = message;
|
|
191
|
+
$[44] = messageId;
|
|
192
|
+
$[45] = t7;
|
|
193
|
+
} else t7 = $[45];
|
|
194
|
+
let t8;
|
|
195
|
+
if ($[46] !== nodes || $[47] !== onRemove || $[48] !== removeLabel || $[49] !== renderEmptyState || $[50] !== state) {
|
|
196
|
+
t8 = nodes.length === 0 ? renderEmptyState?.() : nodes.map((node) => /* @__PURE__ */ jsx(GroupChip, {
|
|
197
|
+
node,
|
|
198
|
+
onRemove,
|
|
199
|
+
removeLabel,
|
|
200
|
+
state
|
|
201
|
+
}, node.key));
|
|
202
|
+
$[46] = nodes;
|
|
203
|
+
$[47] = onRemove;
|
|
204
|
+
$[48] = removeLabel;
|
|
205
|
+
$[49] = renderEmptyState;
|
|
206
|
+
$[50] = state;
|
|
207
|
+
$[51] = t8;
|
|
208
|
+
} else t8 = $[51];
|
|
209
|
+
t5 = /* @__PURE__ */ jsxs(View, {
|
|
210
|
+
...props,
|
|
211
|
+
"aria-labelledby": labelId,
|
|
212
|
+
role: "group",
|
|
213
|
+
...t7,
|
|
214
|
+
style: composeStyles(own.root, style),
|
|
215
|
+
children: [
|
|
216
|
+
/* @__PURE__ */ jsx(Text, {
|
|
217
|
+
id: labelId,
|
|
218
|
+
style: composeStyles(labelRole, own.label, invalid ? own.labelError : void 0),
|
|
219
|
+
children: label
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ jsx(View, {
|
|
222
|
+
style: own.list,
|
|
223
|
+
children: t8
|
|
224
|
+
}),
|
|
225
|
+
message === void 0 ? null : /* @__PURE__ */ jsx(View, {
|
|
226
|
+
style: own.messageLine,
|
|
227
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
228
|
+
id: messageId,
|
|
229
|
+
style: composeStyles(messageRole, own.message, invalid ? own.messageError : void 0),
|
|
230
|
+
children: message
|
|
231
|
+
})
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
});
|
|
235
|
+
$[26] = description;
|
|
236
|
+
$[27] = error;
|
|
237
|
+
$[28] = label;
|
|
238
|
+
$[29] = labelId;
|
|
239
|
+
$[30] = labelRole;
|
|
240
|
+
$[31] = messageId;
|
|
241
|
+
$[32] = messageRole;
|
|
242
|
+
$[33] = onRemove;
|
|
243
|
+
$[34] = props;
|
|
244
|
+
$[35] = removeLabel;
|
|
245
|
+
$[36] = renderEmptyState;
|
|
246
|
+
$[37] = state;
|
|
247
|
+
$[38] = style;
|
|
248
|
+
$[39] = theme;
|
|
249
|
+
$[40] = t5;
|
|
250
|
+
} else t5 = $[40];
|
|
251
|
+
return t5;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* One chip of a `ChipGroup`, which draws it: the group builds its set from
|
|
255
|
+
* these, so one renders nothing on its own. Give every chip an `id`, which is
|
|
256
|
+
* the key selection and removal report it by.
|
|
257
|
+
*/
|
|
258
|
+
function ChipGroupChip(_props) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
ChipGroupChip.getCollectionNode = function* getCollectionNode(props) {
|
|
262
|
+
yield {
|
|
263
|
+
"aria-label": props["aria-label"],
|
|
264
|
+
hasChildNodes: false,
|
|
265
|
+
key: props.id,
|
|
266
|
+
props,
|
|
267
|
+
rendered: props.children,
|
|
268
|
+
textValue: props.textValue ?? (typeof props.children === "string" ? props.children : ""),
|
|
269
|
+
type: "item"
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* A chip as the group draws it, from its entry in the collection: the pill,
|
|
274
|
+
* which is a button while the group selects, and the close target over its
|
|
275
|
+
* end while the group removes.
|
|
276
|
+
*/
|
|
277
|
+
function GroupChip(t0) {
|
|
278
|
+
const $ = c(78);
|
|
279
|
+
const { node, onRemove, removeLabel, state } = t0;
|
|
280
|
+
const theme = useTheme();
|
|
281
|
+
let children;
|
|
282
|
+
let hitSlop;
|
|
283
|
+
let icon;
|
|
284
|
+
let onBlur;
|
|
285
|
+
let onFocus;
|
|
286
|
+
let onHoverIn;
|
|
287
|
+
let onHoverOut;
|
|
288
|
+
let onLayout;
|
|
289
|
+
let onPress;
|
|
290
|
+
let onPressIn;
|
|
291
|
+
let onPressOut;
|
|
292
|
+
let props;
|
|
293
|
+
let style;
|
|
294
|
+
if ($[0] !== node.props) {
|
|
295
|
+
const { children: t1, hitSlop: t2, icon: t3, id: _id, isDisabled: _isDisabled, onBlur: t4, onFocus: t5, onHoverIn: t6, onHoverOut: t7, onLayout: t8, onPress: t9, onPressIn: t10, onPressOut: t11, style: t12, textValue: _textValue, ...t13 } = node.props;
|
|
296
|
+
children = t1;
|
|
297
|
+
hitSlop = t2;
|
|
298
|
+
icon = t3;
|
|
299
|
+
onBlur = t4;
|
|
300
|
+
onFocus = t5;
|
|
301
|
+
onHoverIn = t6;
|
|
302
|
+
onHoverOut = t7;
|
|
303
|
+
onLayout = t8;
|
|
304
|
+
onPress = t9;
|
|
305
|
+
onPressIn = t10;
|
|
306
|
+
onPressOut = t11;
|
|
307
|
+
style = t12;
|
|
308
|
+
props = t13;
|
|
309
|
+
$[0] = node.props;
|
|
310
|
+
$[1] = children;
|
|
311
|
+
$[2] = hitSlop;
|
|
312
|
+
$[3] = icon;
|
|
313
|
+
$[4] = onBlur;
|
|
314
|
+
$[5] = onFocus;
|
|
315
|
+
$[6] = onHoverIn;
|
|
316
|
+
$[7] = onHoverOut;
|
|
317
|
+
$[8] = onLayout;
|
|
318
|
+
$[9] = onPress;
|
|
319
|
+
$[10] = onPressIn;
|
|
320
|
+
$[11] = onPressOut;
|
|
321
|
+
$[12] = props;
|
|
322
|
+
$[13] = style;
|
|
323
|
+
} else {
|
|
324
|
+
children = $[1];
|
|
325
|
+
hitSlop = $[2];
|
|
326
|
+
icon = $[3];
|
|
327
|
+
onBlur = $[4];
|
|
328
|
+
onFocus = $[5];
|
|
329
|
+
onHoverIn = $[6];
|
|
330
|
+
onHoverOut = $[7];
|
|
331
|
+
onLayout = $[8];
|
|
332
|
+
onPress = $[9];
|
|
333
|
+
onPressIn = $[10];
|
|
334
|
+
onPressOut = $[11];
|
|
335
|
+
props = $[12];
|
|
336
|
+
style = $[13];
|
|
337
|
+
}
|
|
338
|
+
const [width, setWidth] = useState(48);
|
|
339
|
+
const { selectionManager } = state;
|
|
340
|
+
let isDisabled;
|
|
341
|
+
let selectable;
|
|
342
|
+
let selected;
|
|
343
|
+
let t1;
|
|
344
|
+
if ($[14] !== node.key || $[15] !== selectionManager || $[16] !== theme) {
|
|
345
|
+
isDisabled = selectionManager.isDisabled(node.key);
|
|
346
|
+
selectable = selectionManager.selectionMode !== "none";
|
|
347
|
+
selected = selectionManager.isSelected(node.key);
|
|
348
|
+
t1 = paintOf(theme, {
|
|
349
|
+
assist: false,
|
|
350
|
+
disabled: isDisabled,
|
|
351
|
+
elevated: false,
|
|
352
|
+
selected
|
|
353
|
+
});
|
|
354
|
+
$[14] = node.key;
|
|
355
|
+
$[15] = selectionManager;
|
|
356
|
+
$[16] = theme;
|
|
357
|
+
$[17] = isDisabled;
|
|
358
|
+
$[18] = selectable;
|
|
359
|
+
$[19] = selected;
|
|
360
|
+
$[20] = t1;
|
|
361
|
+
} else {
|
|
362
|
+
isDisabled = $[17];
|
|
363
|
+
selectable = $[18];
|
|
364
|
+
selected = $[19];
|
|
365
|
+
t1 = $[20];
|
|
366
|
+
}
|
|
367
|
+
const paint = t1;
|
|
368
|
+
const eased = useEasedColors(paint);
|
|
369
|
+
let t2;
|
|
370
|
+
if ($[21] !== theme.radii.sm) {
|
|
371
|
+
t2 = { borderRadius: theme.radii.sm };
|
|
372
|
+
$[21] = theme.radii.sm;
|
|
373
|
+
$[22] = t2;
|
|
374
|
+
} else t2 = $[22];
|
|
375
|
+
let t3;
|
|
376
|
+
if ($[23] !== isDisabled || $[24] !== onBlur || $[25] !== onFocus || $[26] !== onHoverIn || $[27] !== onHoverOut || $[28] !== onPressIn || $[29] !== onPressOut || $[30] !== paint.layer || $[31] !== t2) {
|
|
377
|
+
t3 = {
|
|
378
|
+
color: paint.layer,
|
|
379
|
+
corners: t2,
|
|
380
|
+
disabled: isDisabled,
|
|
381
|
+
onBlur,
|
|
382
|
+
onFocus,
|
|
383
|
+
onHoverIn,
|
|
384
|
+
onHoverOut,
|
|
385
|
+
onPressIn,
|
|
386
|
+
onPressOut
|
|
387
|
+
};
|
|
388
|
+
$[23] = isDisabled;
|
|
389
|
+
$[24] = onBlur;
|
|
390
|
+
$[25] = onFocus;
|
|
391
|
+
$[26] = onHoverIn;
|
|
392
|
+
$[27] = onHoverOut;
|
|
393
|
+
$[28] = onPressIn;
|
|
394
|
+
$[29] = onPressOut;
|
|
395
|
+
$[30] = paint.layer;
|
|
396
|
+
$[31] = t2;
|
|
397
|
+
$[32] = t3;
|
|
398
|
+
} else t3 = $[32];
|
|
399
|
+
const feedback = usePressFeedback(t3);
|
|
400
|
+
let t4;
|
|
401
|
+
if ($[33] !== eased.container || $[34] !== feedback.ring || $[35] !== onRemove || $[36] !== style || $[37] !== theme) {
|
|
402
|
+
t4 = composeStyles(stylesOf(theme).pill, eased.container, onRemove === void 0 ? void 0 : groupStylesOf(theme).removable, feedback.ring, style);
|
|
403
|
+
$[33] = eased.container;
|
|
404
|
+
$[34] = feedback.ring;
|
|
405
|
+
$[35] = onRemove;
|
|
406
|
+
$[36] = style;
|
|
407
|
+
$[37] = theme;
|
|
408
|
+
$[38] = t4;
|
|
409
|
+
} else t4 = $[38];
|
|
410
|
+
const pill = t4;
|
|
411
|
+
const t5 = selectable ? feedback.layer : null;
|
|
412
|
+
let t6;
|
|
413
|
+
if ($[39] !== icon || $[40] !== paint.glyph || $[41] !== selected) {
|
|
414
|
+
t6 = /* @__PURE__ */ jsx(ChipGlyph, {
|
|
415
|
+
color: paint.glyph,
|
|
416
|
+
icon,
|
|
417
|
+
selected
|
|
418
|
+
});
|
|
419
|
+
$[39] = icon;
|
|
420
|
+
$[40] = paint.glyph;
|
|
421
|
+
$[41] = selected;
|
|
422
|
+
$[42] = t6;
|
|
423
|
+
} else t6 = $[42];
|
|
424
|
+
let t7;
|
|
425
|
+
if ($[43] !== children || $[44] !== eased.label) {
|
|
426
|
+
t7 = /* @__PURE__ */ jsx(ChipLabel, {
|
|
427
|
+
color: eased.label,
|
|
428
|
+
children
|
|
429
|
+
});
|
|
430
|
+
$[43] = children;
|
|
431
|
+
$[44] = eased.label;
|
|
432
|
+
$[45] = t7;
|
|
433
|
+
} else t7 = $[45];
|
|
434
|
+
let t8;
|
|
435
|
+
if ($[46] !== t5 || $[47] !== t6 || $[48] !== t7) {
|
|
436
|
+
t8 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
437
|
+
t5,
|
|
438
|
+
t6,
|
|
439
|
+
t7
|
|
440
|
+
] });
|
|
441
|
+
$[46] = t5;
|
|
442
|
+
$[47] = t6;
|
|
443
|
+
$[48] = t7;
|
|
444
|
+
$[49] = t8;
|
|
445
|
+
} else t8 = $[49];
|
|
446
|
+
const content = t8;
|
|
447
|
+
let t9;
|
|
448
|
+
if ($[50] !== hitSlop || $[51] !== theme || $[52] !== width) {
|
|
449
|
+
t9 = hitSlop ?? targetOf(width, theme);
|
|
450
|
+
$[50] = hitSlop;
|
|
451
|
+
$[51] = theme;
|
|
452
|
+
$[52] = width;
|
|
453
|
+
$[53] = t9;
|
|
454
|
+
} else t9 = $[53];
|
|
455
|
+
const target = t9;
|
|
456
|
+
const t10 = selectable ? target : void 0;
|
|
457
|
+
let t11;
|
|
458
|
+
if ($[54] !== content || $[55] !== feedback.handlers || $[56] !== isDisabled || $[57] !== node.key || $[58] !== onLayout || $[59] !== onPress || $[60] !== pill || $[61] !== props || $[62] !== selectable || $[63] !== selected || $[64] !== state || $[65] !== target) {
|
|
459
|
+
t11 = selectable ? /* @__PURE__ */ jsx(AnimatedPressable, {
|
|
460
|
+
role: "button",
|
|
461
|
+
...toggleState(selected),
|
|
462
|
+
...props,
|
|
463
|
+
...feedback.handlers,
|
|
464
|
+
disabled: isDisabled,
|
|
465
|
+
hitSlop: target,
|
|
466
|
+
onLayout: measureThen(setWidth, onLayout),
|
|
467
|
+
onPress: selectThen(state, node.key, onPress),
|
|
468
|
+
style: pill,
|
|
469
|
+
children: content
|
|
470
|
+
}) : /* @__PURE__ */ jsx(Animated.View, {
|
|
471
|
+
...props,
|
|
472
|
+
"aria-disabled": isDisabled,
|
|
473
|
+
onLayout: onLayout ?? void 0,
|
|
474
|
+
style: pill,
|
|
475
|
+
children: content
|
|
476
|
+
});
|
|
477
|
+
$[54] = content;
|
|
478
|
+
$[55] = feedback.handlers;
|
|
479
|
+
$[56] = isDisabled;
|
|
480
|
+
$[57] = node.key;
|
|
481
|
+
$[58] = onLayout;
|
|
482
|
+
$[59] = onPress;
|
|
483
|
+
$[60] = pill;
|
|
484
|
+
$[61] = props;
|
|
485
|
+
$[62] = selectable;
|
|
486
|
+
$[63] = selected;
|
|
487
|
+
$[64] = state;
|
|
488
|
+
$[65] = target;
|
|
489
|
+
$[66] = t11;
|
|
490
|
+
} else t11 = $[66];
|
|
491
|
+
let t12;
|
|
492
|
+
if ($[67] !== isDisabled || $[68] !== node.key || $[69] !== node.textValue || $[70] !== onRemove || $[71] !== paint.content || $[72] !== removeLabel) {
|
|
493
|
+
t12 = onRemove === void 0 ? null : /* @__PURE__ */ jsx(RemoveButton, {
|
|
494
|
+
color: paint.content,
|
|
495
|
+
isDisabled,
|
|
496
|
+
label: node.textValue === "" ? removeLabel : `${removeLabel} ${node.textValue}`,
|
|
497
|
+
onPress: removeThen(onRemove, node.key)
|
|
498
|
+
});
|
|
499
|
+
$[67] = isDisabled;
|
|
500
|
+
$[68] = node.key;
|
|
501
|
+
$[69] = node.textValue;
|
|
502
|
+
$[70] = onRemove;
|
|
503
|
+
$[71] = paint.content;
|
|
504
|
+
$[72] = removeLabel;
|
|
505
|
+
$[73] = t12;
|
|
506
|
+
} else t12 = $[73];
|
|
507
|
+
let t13;
|
|
508
|
+
if ($[74] !== t10 || $[75] !== t11 || $[76] !== t12) {
|
|
509
|
+
t13 = /* @__PURE__ */ jsxs(View, {
|
|
510
|
+
hitSlop: t10,
|
|
511
|
+
style: styles.chip,
|
|
512
|
+
children: [t11, t12]
|
|
513
|
+
});
|
|
514
|
+
$[74] = t10;
|
|
515
|
+
$[75] = t11;
|
|
516
|
+
$[76] = t12;
|
|
517
|
+
$[77] = t13;
|
|
518
|
+
} else t13 = $[77];
|
|
519
|
+
return t13;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* How the group is described by the line under it. On the web it points at
|
|
523
|
+
* the line with `aria-describedby`, as web's group does. iOS and Android
|
|
524
|
+
* focus the chips rather than the group, so there the line is left where a
|
|
525
|
+
* screen reader reaches it in order, after the last chip.
|
|
526
|
+
*/
|
|
527
|
+
function lineOf(id, message) {
|
|
528
|
+
return Platform.OS === "web" && message !== void 0 ? { "aria-describedby": id } : void 0;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* A chip's close target: the close glyph in the label's colour, with a hover
|
|
532
|
+
* and a pressed layer of its own and a ring for focus from a key, as the
|
|
533
|
+
* header sets out.
|
|
534
|
+
*/
|
|
535
|
+
function RemoveButton(t0) {
|
|
536
|
+
const $ = c(38);
|
|
537
|
+
const { color, isDisabled, label, onPress } = t0;
|
|
538
|
+
const theme = useTheme();
|
|
539
|
+
let t1;
|
|
540
|
+
if ($[0] !== color || $[1] !== isDisabled) {
|
|
541
|
+
t1 = {
|
|
542
|
+
color,
|
|
543
|
+
disabled: isDisabled,
|
|
544
|
+
disableRipple: true
|
|
545
|
+
};
|
|
546
|
+
$[0] = color;
|
|
547
|
+
$[1] = isDisabled;
|
|
548
|
+
$[2] = t1;
|
|
549
|
+
} else t1 = $[2];
|
|
550
|
+
const feedback = usePressFeedback(t1);
|
|
551
|
+
let T0;
|
|
552
|
+
let T1;
|
|
553
|
+
let t2;
|
|
554
|
+
let t3;
|
|
555
|
+
let t4;
|
|
556
|
+
let t5;
|
|
557
|
+
let t6;
|
|
558
|
+
let t7;
|
|
559
|
+
let t8;
|
|
560
|
+
let t9;
|
|
561
|
+
if ($[3] !== color || $[4] !== feedback.handlers || $[5] !== feedback.hovered || $[6] !== feedback.pressed || $[7] !== feedback.ring || $[8] !== isDisabled || $[9] !== label || $[10] !== onPress || $[11] !== theme) {
|
|
562
|
+
const own = groupStylesOf(theme);
|
|
563
|
+
T1 = Pressable;
|
|
564
|
+
t3 = label;
|
|
565
|
+
t4 = "button";
|
|
566
|
+
t5 = feedback.handlers;
|
|
567
|
+
t6 = isDisabled;
|
|
568
|
+
t7 = REMOVE_REACH;
|
|
569
|
+
t8 = onPress;
|
|
570
|
+
t9 = composeStyles(own.remove, feedback.ring === void 0 ? void 0 : ringOf(color));
|
|
571
|
+
T0 = View;
|
|
572
|
+
t2 = composeStyles(styles.layer, own.removeLayer, { backgroundColor: color }, feedback.hovered ? own.removeHovered : void 0, feedback.pressed ? own.removePressed : void 0);
|
|
573
|
+
$[3] = color;
|
|
574
|
+
$[4] = feedback.handlers;
|
|
575
|
+
$[5] = feedback.hovered;
|
|
576
|
+
$[6] = feedback.pressed;
|
|
577
|
+
$[7] = feedback.ring;
|
|
578
|
+
$[8] = isDisabled;
|
|
579
|
+
$[9] = label;
|
|
580
|
+
$[10] = onPress;
|
|
581
|
+
$[11] = theme;
|
|
582
|
+
$[12] = T0;
|
|
583
|
+
$[13] = T1;
|
|
584
|
+
$[14] = t2;
|
|
585
|
+
$[15] = t3;
|
|
586
|
+
$[16] = t4;
|
|
587
|
+
$[17] = t5;
|
|
588
|
+
$[18] = t6;
|
|
589
|
+
$[19] = t7;
|
|
590
|
+
$[20] = t8;
|
|
591
|
+
$[21] = t9;
|
|
592
|
+
} else {
|
|
593
|
+
T0 = $[12];
|
|
594
|
+
T1 = $[13];
|
|
595
|
+
t2 = $[14];
|
|
596
|
+
t3 = $[15];
|
|
597
|
+
t4 = $[16];
|
|
598
|
+
t5 = $[17];
|
|
599
|
+
t6 = $[18];
|
|
600
|
+
t7 = $[19];
|
|
601
|
+
t8 = $[20];
|
|
602
|
+
t9 = $[21];
|
|
603
|
+
}
|
|
604
|
+
let t10;
|
|
605
|
+
if ($[22] !== T0 || $[23] !== t2) {
|
|
606
|
+
t10 = /* @__PURE__ */ jsx(T0, { style: t2 });
|
|
607
|
+
$[22] = T0;
|
|
608
|
+
$[23] = t2;
|
|
609
|
+
$[24] = t10;
|
|
610
|
+
} else t10 = $[24];
|
|
611
|
+
let t11;
|
|
612
|
+
if ($[25] !== color) {
|
|
613
|
+
t11 = /* @__PURE__ */ jsx(CloseGlyph, {
|
|
614
|
+
color,
|
|
615
|
+
size: 18
|
|
616
|
+
});
|
|
617
|
+
$[25] = color;
|
|
618
|
+
$[26] = t11;
|
|
619
|
+
} else t11 = $[26];
|
|
620
|
+
let t12;
|
|
621
|
+
if ($[27] !== T1 || $[28] !== t10 || $[29] !== t11 || $[30] !== t3 || $[31] !== t4 || $[32] !== t5 || $[33] !== t6 || $[34] !== t7 || $[35] !== t8 || $[36] !== t9) {
|
|
622
|
+
t12 = /* @__PURE__ */ jsxs(T1, {
|
|
623
|
+
"aria-label": t3,
|
|
624
|
+
role: t4,
|
|
625
|
+
...t5,
|
|
626
|
+
disabled: t6,
|
|
627
|
+
hitSlop: t7,
|
|
628
|
+
onPress: t8,
|
|
629
|
+
style: t9,
|
|
630
|
+
children: [t10, t11]
|
|
631
|
+
});
|
|
632
|
+
$[27] = T1;
|
|
633
|
+
$[28] = t10;
|
|
634
|
+
$[29] = t11;
|
|
635
|
+
$[30] = t3;
|
|
636
|
+
$[31] = t4;
|
|
637
|
+
$[32] = t5;
|
|
638
|
+
$[33] = t6;
|
|
639
|
+
$[34] = t7;
|
|
640
|
+
$[35] = t8;
|
|
641
|
+
$[36] = t9;
|
|
642
|
+
$[37] = t12;
|
|
643
|
+
} else t12 = $[37];
|
|
644
|
+
return t12;
|
|
645
|
+
}
|
|
646
|
+
function removeThen(onRemove, key) {
|
|
647
|
+
return () => {
|
|
648
|
+
onRemove(/* @__PURE__ */ new Set([key]));
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
function ringOf(color) {
|
|
652
|
+
return {
|
|
653
|
+
outlineColor: color,
|
|
654
|
+
outlineOffset: 1,
|
|
655
|
+
outlineStyle: "solid",
|
|
656
|
+
outlineWidth: 2
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function selectThen(state, key, onPress) {
|
|
660
|
+
return (event) => {
|
|
661
|
+
onPress?.(event);
|
|
662
|
+
state.selectionManager.select(key);
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
ChipGroup.Chip = ChipGroupChip;
|
|
666
|
+
//#endregion
|
|
667
|
+
export { ChipGroup, ChipGroupChip };
|
|
668
|
+
|
|
669
|
+
//# sourceMappingURL=index.js.map
|