@xaui/native 0.9.1-alpha.21 → 0.9.1-alpha.23
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/dist/{chunk-RMLFMRWL.js → chunk-2U6JR7BF.js} +5 -5
- package/dist/{chunk-N7C4UNUL.js → chunk-3JATAB7S.js} +23 -1
- package/dist/chunk-4MHJOWM4.cjs +364 -0
- package/dist/{chunk-2WMVDMFV.cjs → chunk-6HXWQ5AU.cjs} +2 -2
- package/dist/chunk-6WW4CSPY.cjs +82 -0
- package/dist/chunk-AHL33YAO.js +425 -0
- package/dist/{chunk-XHZBXYVU.js → chunk-AKXG43S4.js} +1 -1
- package/dist/{chunk-4NE3SLTM.cjs → chunk-BH5DSJVX.cjs} +102 -73
- package/dist/{chunk-BPBY7ON7.cjs → chunk-BNWS26PX.cjs} +19 -21
- package/dist/{chunk-5LC6KVL3.cjs → chunk-DXGQ43IV.cjs} +3 -3
- package/dist/chunk-E3LXUXE7.js +451 -0
- package/dist/{chunk-ISVUXVFL.js → chunk-FNQF4KQV.js} +19 -71
- package/dist/{chunk-YRCUALUQ.js → chunk-FTCTTBLG.js} +7 -9
- package/dist/{chunk-JL27KVRT.js → chunk-FVP5FUVS.js} +3 -3
- package/dist/{chunk-UL263KGM.cjs → chunk-GBPWTFTU.cjs} +10 -10
- package/dist/{chunk-TUJBDS5M.js → chunk-GG2WWCBK.js} +10 -10
- package/dist/{chunk-EVXZGNPA.cjs → chunk-HUZ4AUM2.cjs} +98 -98
- package/dist/chunk-I6PE5UUH.cjs +425 -0
- package/dist/{chunk-33QILJJH.cjs → chunk-IBEX4XGV.cjs} +11 -11
- package/dist/{chunk-IBRVMLUF.js → chunk-KM2TI5IC.js} +107 -80
- package/dist/chunk-OGC4RKE3.js +364 -0
- package/dist/{chunk-JXLRHKCQ.js → chunk-OYZYWWJ6.js} +1 -1
- package/dist/{chunk-EXX6ATAS.js → chunk-PMO62QK4.js} +101 -101
- package/dist/{chunk-UBA6AEY6.cjs → chunk-RAWOJ3N3.cjs} +8 -8
- package/dist/chunk-TIP3T7JJ.cjs +451 -0
- package/dist/{chunk-APCBIHLR.cjs → chunk-VDRRD6GM.cjs} +29 -81
- package/dist/{chunk-UVO4GFSW.cjs → chunk-YXVKQMCK.cjs} +23 -1
- package/dist/chunk-ZQ3JSWRO.js +82 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/alert/index.cjs +17 -0
- package/dist/components/alert/index.d.cts +169 -0
- package/dist/components/alert/index.d.ts +169 -0
- package/dist/components/alert/index.js +17 -0
- package/dist/components/button/index.cjs +6 -7
- package/dist/components/button/index.d.cts +74 -125
- package/dist/components/button/index.d.ts +74 -125
- package/dist/components/button/index.js +5 -6
- package/dist/components/card/index.cjs +5 -6
- package/dist/components/card/index.d.cts +74 -74
- package/dist/components/card/index.d.ts +74 -74
- package/dist/components/card/index.js +4 -5
- package/dist/components/chip/index.cjs +17 -0
- package/dist/components/chip/index.d.cts +608 -0
- package/dist/components/chip/index.d.ts +608 -0
- package/dist/components/chip/index.js +17 -0
- package/dist/components/input/index.cjs +14 -0
- package/dist/components/input/index.d.cts +213 -0
- package/dist/components/input/index.d.ts +213 -0
- package/dist/components/input/index.js +14 -0
- package/dist/components/typography/index.cjs +4 -4
- package/dist/components/typography/index.d.cts +4 -4
- package/dist/components/typography/index.d.ts +4 -4
- package/dist/components/typography/index.js +3 -3
- package/dist/components/view/index.cjs +3 -3
- package/dist/components/view/index.d.cts +7 -7
- package/dist/components/view/index.d.ts +7 -7
- package/dist/components/view/index.js +2 -2
- package/dist/{create-recipe-CC3NNCqF.d.ts → create-recipe-C4JkINrA.d.ts} +18 -5
- package/dist/{create-recipe-CPBFg7ym.d.cts → create-recipe-dBN_ewZc.d.cts} +18 -5
- package/dist/{icon.type-Cs1tMX0W.d.cts → icon.type-CF4KiMKl.d.cts} +1 -1
- package/dist/{icon.type-BkcEPJbK.d.ts → icon.type-Dq4_qePa.d.ts} +1 -1
- package/dist/index.cjs +44 -14
- package/dist/index.d.cts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +74 -44
- package/dist/{pressable-feedback.type-wfeiJz5m.d.cts → pressable-feedback.type-BA2C9sSz.d.cts} +1 -1
- package/dist/{pressable-feedback.type-DsvWZXWC.d.ts → pressable-feedback.type-Bs4dQlGj.d.ts} +1 -1
- package/dist/{style-props.type-B1BG5TCm.d.cts → style-props.type-CfnoGEP7.d.cts} +1 -1
- package/dist/{style-props.type-B1BG5TCm.d.ts → style-props.type-CfnoGEP7.d.ts} +1 -1
- package/dist/system/index.cjs +15 -7
- package/dist/system/index.d.cts +175 -101
- package/dist/system/index.d.ts +175 -101
- package/dist/system/index.js +15 -7
- package/dist/theme/index.cjs +2 -2
- package/dist/theme/index.d.cts +10 -10
- package/dist/theme/index.d.ts +10 -10
- package/dist/theme/index.js +1 -1
- package/package.json +31 -1
- package/dist/chunk-RRRGLRRP.cjs +0 -28
- package/dist/chunk-SGHP76GU.js +0 -28
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CloseButton,
|
|
3
|
+
closeButtonBase
|
|
4
|
+
} from "./chunk-ZQ3JSWRO.js";
|
|
5
|
+
import {
|
|
6
|
+
Icon
|
|
7
|
+
} from "./chunk-FVP5FUVS.js";
|
|
8
|
+
import {
|
|
9
|
+
PressableFeedback,
|
|
10
|
+
usePressState,
|
|
11
|
+
warnDev
|
|
12
|
+
} from "./chunk-KM2TI5IC.js";
|
|
13
|
+
import {
|
|
14
|
+
createRecipe,
|
|
15
|
+
radiusAxis
|
|
16
|
+
} from "./chunk-3JATAB7S.js";
|
|
17
|
+
import {
|
|
18
|
+
useXAUITheme
|
|
19
|
+
} from "./chunk-A3EGFI6T.js";
|
|
20
|
+
import {
|
|
21
|
+
Slot,
|
|
22
|
+
childrenToString,
|
|
23
|
+
createSlotContext,
|
|
24
|
+
useStyleProps
|
|
25
|
+
} from "./chunk-PMO62QK4.js";
|
|
26
|
+
|
|
27
|
+
// src/components/chip/chip-avatar.tsx
|
|
28
|
+
import { forwardRef } from "react";
|
|
29
|
+
import { Image, View } from "react-native";
|
|
30
|
+
|
|
31
|
+
// src/components/chip/chip.context.ts
|
|
32
|
+
var [ChipProvider, useChip] = createSlotContext("Chip");
|
|
33
|
+
|
|
34
|
+
// src/components/chip/chip.style.ts
|
|
35
|
+
import { StyleSheet } from "react-native";
|
|
36
|
+
var chipSheet = StyleSheet.create({
|
|
37
|
+
avatarImage: { width: "100%", height: "100%" }
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// src/components/chip/chip-avatar.tsx
|
|
41
|
+
import { jsx } from "react/jsx-runtime";
|
|
42
|
+
var ChipAvatar = forwardRef(function ChipAvatar2({ children, source, style, ...props }, ref) {
|
|
43
|
+
const { avatarStyle } = useChip();
|
|
44
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
45
|
+
return /* @__PURE__ */ jsx(View, { ref, style: [avatarStyle, styleProps, style], ...rest, children: source ? /* @__PURE__ */ jsx(Image, { source, style: chipSheet.avatarImage }) : children });
|
|
46
|
+
});
|
|
47
|
+
ChipAvatar.displayName = "XAUI.Chip.Avatar";
|
|
48
|
+
|
|
49
|
+
// src/components/chip/chip-close.tsx
|
|
50
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
51
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
52
|
+
var ChipClose = forwardRef2(function ChipClose2({ isDisabled, ...props }, ref) {
|
|
53
|
+
const { closeStyle, closeGlyphStyle, isDisabled: isChipDisabled } = useChip();
|
|
54
|
+
return /* @__PURE__ */ jsx2(
|
|
55
|
+
CloseButton,
|
|
56
|
+
{
|
|
57
|
+
ref,
|
|
58
|
+
name: "Chip.Close",
|
|
59
|
+
baseStyle: closeStyle,
|
|
60
|
+
glyphStyle: closeGlyphStyle,
|
|
61
|
+
isDisabled: isDisabled ?? isChipDisabled,
|
|
62
|
+
...props
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
ChipClose.displayName = "XAUI.Chip.Close";
|
|
67
|
+
|
|
68
|
+
// src/components/chip/chip-dot.tsx
|
|
69
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
70
|
+
import { View as View2 } from "react-native";
|
|
71
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
72
|
+
var ChipDot = forwardRef3(function ChipDot2({ style, ...props }, ref) {
|
|
73
|
+
const { dotStyle } = useChip();
|
|
74
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
75
|
+
return /* @__PURE__ */ jsx3(View2, { ref, style: [dotStyle, styleProps, style], ...rest });
|
|
76
|
+
});
|
|
77
|
+
ChipDot.displayName = "XAUI.Chip.Dot";
|
|
78
|
+
|
|
79
|
+
// src/components/chip/chip-icon.tsx
|
|
80
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
81
|
+
function ChipIcon({ size, color, ...rest }) {
|
|
82
|
+
const { icon } = useChip();
|
|
83
|
+
return /* @__PURE__ */ jsx4(Icon, { size: size ?? icon.size, color: color ?? icon.color, ...rest });
|
|
84
|
+
}
|
|
85
|
+
ChipIcon.displayName = "XAUI.Chip.Icon";
|
|
86
|
+
|
|
87
|
+
// src/components/chip/chip-label.tsx
|
|
88
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
89
|
+
import { Text } from "react-native";
|
|
90
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
91
|
+
var ChipLabel = forwardRef4(function ChipLabel2({ children, style, numberOfLines = 1, ...props }, ref) {
|
|
92
|
+
const { labelStyle } = useChip();
|
|
93
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
94
|
+
return /* @__PURE__ */ jsx5(
|
|
95
|
+
Text,
|
|
96
|
+
{
|
|
97
|
+
ref,
|
|
98
|
+
numberOfLines,
|
|
99
|
+
style: [labelStyle, styleProps, style],
|
|
100
|
+
...rest,
|
|
101
|
+
children
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
ChipLabel.displayName = "XAUI.Chip.Label";
|
|
106
|
+
|
|
107
|
+
// src/components/chip/chip.tsx
|
|
108
|
+
import { forwardRef as forwardRef5, useMemo } from "react";
|
|
109
|
+
import { StyleSheet as StyleSheet2, View as View3 } from "react-native";
|
|
110
|
+
|
|
111
|
+
// src/components/chip/chip.recipe.ts
|
|
112
|
+
var SLOTS = [
|
|
113
|
+
"root",
|
|
114
|
+
"label",
|
|
115
|
+
"icon",
|
|
116
|
+
"dot",
|
|
117
|
+
"avatar",
|
|
118
|
+
"close",
|
|
119
|
+
"closeGlyph"
|
|
120
|
+
];
|
|
121
|
+
var VARIANT_TOKENS = {
|
|
122
|
+
primary: { bg: "accent", bgPressed: "accentPressed", fg: "accentForeground" },
|
|
123
|
+
secondary: {
|
|
124
|
+
bg: "accentSoft",
|
|
125
|
+
bgPressed: "accentSoftPressed",
|
|
126
|
+
fg: "accentSoftForeground"
|
|
127
|
+
},
|
|
128
|
+
default: { bg: "default", bgPressed: "defaultPressed", fg: "defaultForeground" },
|
|
129
|
+
tertiary: { border: "border", bgPressed: "defaultSoftPressed", fg: "foreground" },
|
|
130
|
+
ghost: { bgPressed: "defaultSoftPressed", fg: "foreground" },
|
|
131
|
+
success: { bg: "success", bgPressed: "successPressed", fg: "successForeground" },
|
|
132
|
+
"success-soft": {
|
|
133
|
+
bg: "successSoft",
|
|
134
|
+
bgPressed: "successSoftPressed",
|
|
135
|
+
fg: "successSoftForeground"
|
|
136
|
+
},
|
|
137
|
+
warning: { bg: "warning", bgPressed: "warningPressed", fg: "warningForeground" },
|
|
138
|
+
"warning-soft": {
|
|
139
|
+
bg: "warningSoft",
|
|
140
|
+
bgPressed: "warningSoftPressed",
|
|
141
|
+
fg: "warningSoftForeground"
|
|
142
|
+
},
|
|
143
|
+
danger: { bg: "danger", bgPressed: "dangerPressed", fg: "dangerForeground" },
|
|
144
|
+
"danger-soft": {
|
|
145
|
+
bg: "dangerSoft",
|
|
146
|
+
bgPressed: "dangerSoftPressed",
|
|
147
|
+
fg: "dangerSoftForeground"
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
function sizeAxis(step) {
|
|
151
|
+
const { height, padding, gap, label, glyph, dot, avatar, cross } = step;
|
|
152
|
+
return (theme) => {
|
|
153
|
+
const diameter = theme.spacing(avatar);
|
|
154
|
+
const box = theme.fontSizes[glyph];
|
|
155
|
+
const inset = theme.spacing(padding);
|
|
156
|
+
const cap = (theme.spacing(height) - diameter) / 2;
|
|
157
|
+
return {
|
|
158
|
+
root: {
|
|
159
|
+
height: theme.spacing(height),
|
|
160
|
+
paddingHorizontal: inset,
|
|
161
|
+
gap: theme.spacing(gap)
|
|
162
|
+
},
|
|
163
|
+
label: {
|
|
164
|
+
fontSize: theme.fontSizes[label],
|
|
165
|
+
lineHeight: theme.lineHeights[label]
|
|
166
|
+
},
|
|
167
|
+
icon: { fontSize: box },
|
|
168
|
+
dot: circle(theme.spacing(dot)),
|
|
169
|
+
avatar: {
|
|
170
|
+
...circle(diameter),
|
|
171
|
+
// **The one margin on a slot in this component**, and R4 is about spacing between
|
|
172
|
+
// slots — this is not that. The root's horizontal padding is set for text, several
|
|
173
|
+
// times the gap the height leaves above the avatar, so a face sits visibly pushed
|
|
174
|
+
// into the chip while a label beside it looks right. Cancelling the difference
|
|
175
|
+
// seats it in the capsule's rounded end instead. Clamped at zero, because a theme
|
|
176
|
+
// with tighter padding than that gap needs no pull at all.
|
|
177
|
+
//
|
|
178
|
+
// R13 — `marginStart`, so it is the leading edge in RTL too. `Chip.Avatar` is a
|
|
179
|
+
// leading slot by contract, which is what makes a leading-only correction sound.
|
|
180
|
+
marginStart: -Math.max(0, inset - cap)
|
|
181
|
+
},
|
|
182
|
+
// The touch target is the glyph's box; `hitSlop` on the slot is what makes it
|
|
183
|
+
// reachable, because a cross big enough to hit is a cross too big to look right.
|
|
184
|
+
close: { width: box, height: box },
|
|
185
|
+
closeGlyph: { width: theme.spacing(cross) }
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function circle(diameter) {
|
|
190
|
+
return { width: diameter, height: diameter, borderRadius: diameter / 2 };
|
|
191
|
+
}
|
|
192
|
+
var SIZES = {
|
|
193
|
+
xs: {
|
|
194
|
+
height: 5,
|
|
195
|
+
padding: 2,
|
|
196
|
+
gap: 1,
|
|
197
|
+
label: "xs",
|
|
198
|
+
glyph: "sm",
|
|
199
|
+
dot: 1,
|
|
200
|
+
avatar: 3.5,
|
|
201
|
+
cross: 2
|
|
202
|
+
},
|
|
203
|
+
sm: {
|
|
204
|
+
height: 6,
|
|
205
|
+
padding: 2.5,
|
|
206
|
+
gap: 1,
|
|
207
|
+
label: "xs",
|
|
208
|
+
glyph: "sm",
|
|
209
|
+
dot: 1.25,
|
|
210
|
+
avatar: 4.5,
|
|
211
|
+
cross: 2
|
|
212
|
+
},
|
|
213
|
+
md: {
|
|
214
|
+
height: 7,
|
|
215
|
+
padding: 3,
|
|
216
|
+
gap: 1,
|
|
217
|
+
label: "sm",
|
|
218
|
+
glyph: "md",
|
|
219
|
+
dot: 1.5,
|
|
220
|
+
avatar: 5.5,
|
|
221
|
+
cross: 2.5
|
|
222
|
+
},
|
|
223
|
+
lg: {
|
|
224
|
+
height: 9,
|
|
225
|
+
padding: 4,
|
|
226
|
+
gap: 1.5,
|
|
227
|
+
label: "md",
|
|
228
|
+
glyph: "lg",
|
|
229
|
+
dot: 2,
|
|
230
|
+
avatar: 7,
|
|
231
|
+
cross: 3
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var chipRecipe = createRecipe({
|
|
235
|
+
slots: SLOTS,
|
|
236
|
+
// The cross's own geometry — thickness and centring — belongs to the shared
|
|
237
|
+
// `CloseButton`; what stays below is the box and bar size this component's scale sets.
|
|
238
|
+
base: (theme) => ({
|
|
239
|
+
...closeButtonBase(theme),
|
|
240
|
+
root: {
|
|
241
|
+
// A chip hugs its content where a `Button` fills its column. The difference is what
|
|
242
|
+
// the two are: a button is a control the layout sizes, a chip is a token *about*
|
|
243
|
+
// something, and a tag stretched across a screen has stopped being one. It is also
|
|
244
|
+
// the one line of HeroUI's chip that is not a measurement.
|
|
245
|
+
alignSelf: "flex-start",
|
|
246
|
+
flexDirection: "row",
|
|
247
|
+
alignItems: "center",
|
|
248
|
+
justifyContent: "center",
|
|
249
|
+
borderWidth: 0,
|
|
250
|
+
// The capsule the name means, at every size. HeroUI reaches it through a radius
|
|
251
|
+
// ladder that React Native would clamp to the same pill anyway; saying `full` says
|
|
252
|
+
// it once, and `radius` is still there for the tag that wants square corners.
|
|
253
|
+
borderRadius: theme.radius.full,
|
|
254
|
+
// Squircle corners for when `radius` overrides the pill. Free on Android.
|
|
255
|
+
borderCurve: "continuous"
|
|
256
|
+
// Deliberately no `overflow: 'hidden'`, where HeroUI clips: the press overlays
|
|
257
|
+
// carry their own corners (`system/pressable-feedback/`), so nothing needs the clip
|
|
258
|
+
// — and clipping here would cut a badge or a shadow a caller hangs off the chip.
|
|
259
|
+
},
|
|
260
|
+
label: {
|
|
261
|
+
fontFamily: theme.fontFamilies.body,
|
|
262
|
+
fontWeight: theme.fontWeights.medium
|
|
263
|
+
},
|
|
264
|
+
avatar: { overflow: "hidden", alignItems: "center", justifyContent: "center" }
|
|
265
|
+
}),
|
|
266
|
+
variantTokens: VARIANT_TOKENS,
|
|
267
|
+
/**
|
|
268
|
+
* Where the variant's colours land, for every variant at once. The border width follows
|
|
269
|
+
* the *presence* of the border role rather than a per-variant flag — `tertiary` is the
|
|
270
|
+
* only variant that names one, and that fact is already in the table above.
|
|
271
|
+
*
|
|
272
|
+
* The dot and the cross take the foreground rather than a status token of their own: on
|
|
273
|
+
* a filled `success` chip the readable colour is the one the label already uses, and on
|
|
274
|
+
* a `success-soft` one it is the green that token resolves to. One rule, eleven
|
|
275
|
+
* variants, and a tinted chip gets it for free.
|
|
276
|
+
*/
|
|
277
|
+
paint: (theme, colors) => ({
|
|
278
|
+
root: {
|
|
279
|
+
backgroundColor: colors.bg,
|
|
280
|
+
borderColor: colors.border,
|
|
281
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
282
|
+
},
|
|
283
|
+
label: { color: colors.fg },
|
|
284
|
+
icon: { color: colors.fg },
|
|
285
|
+
dot: { backgroundColor: colors.fg },
|
|
286
|
+
closeGlyph: { backgroundColor: colors.fg }
|
|
287
|
+
}),
|
|
288
|
+
/** Declaration order is application order: `radius` overrides the capsule `base` set. */
|
|
289
|
+
variants: {
|
|
290
|
+
size: {
|
|
291
|
+
xs: sizeAxis(SIZES.xs),
|
|
292
|
+
sm: sizeAxis(SIZES.sm),
|
|
293
|
+
md: sizeAxis(SIZES.md),
|
|
294
|
+
lg: sizeAxis(SIZES.lg)
|
|
295
|
+
},
|
|
296
|
+
radius: radiusAxis("root")
|
|
297
|
+
},
|
|
298
|
+
/**
|
|
299
|
+
* The pressed colour is the variant's own `…Pressed` token, as on the `Button` and not
|
|
300
|
+
* as on the `Card`: a chip is small enough that a wash over it reads as a smudge, while
|
|
301
|
+
* the fill going one step down reads as the thing itself being pushed. A tinted chip
|
|
302
|
+
* presses through the same OKLab formula as a token one.
|
|
303
|
+
*/
|
|
304
|
+
states: {
|
|
305
|
+
pressed: (_theme, colors) => ({ root: { backgroundColor: colors.bgPressed } }),
|
|
306
|
+
disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
|
|
307
|
+
},
|
|
308
|
+
defaultVariants: { variant: "primary", size: "md" }
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// src/components/chip/chip.tsx
|
|
312
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
313
|
+
var ChipRoot = forwardRef5(function Chip({
|
|
314
|
+
children,
|
|
315
|
+
variant,
|
|
316
|
+
size,
|
|
317
|
+
radius,
|
|
318
|
+
color,
|
|
319
|
+
isDisabled = false,
|
|
320
|
+
isPressable = false,
|
|
321
|
+
asChild = false,
|
|
322
|
+
accessibilityRole,
|
|
323
|
+
accessibilityState,
|
|
324
|
+
animation,
|
|
325
|
+
style,
|
|
326
|
+
onPressIn,
|
|
327
|
+
onPressOut,
|
|
328
|
+
...props
|
|
329
|
+
}, ref) {
|
|
330
|
+
const theme = useXAUITheme();
|
|
331
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
332
|
+
const [isPressed, press] = usePressState({ onPressIn, onPressOut });
|
|
333
|
+
const selection = { variant, size, radius };
|
|
334
|
+
const states = { pressed: isPressed, disabled: isDisabled };
|
|
335
|
+
const styles = chipRecipe.resolve({ theme, selection, states });
|
|
336
|
+
const tint = color ? chipRecipe.tint({ theme, color, selection, states }) : void 0;
|
|
337
|
+
const context = useMemo(() => {
|
|
338
|
+
const icon = StyleSheet2.flatten([styles.icon, tint?.icon]);
|
|
339
|
+
return {
|
|
340
|
+
labelStyle: tint ? [styles.label, tint.label] : styles.label,
|
|
341
|
+
dotStyle: tint ? [styles.dot, tint.dot] : styles.dot,
|
|
342
|
+
avatarStyle: styles.avatar,
|
|
343
|
+
closeStyle: styles.close,
|
|
344
|
+
closeGlyphStyle: tint ? [styles.closeGlyph, tint.closeGlyph] : styles.closeGlyph,
|
|
345
|
+
icon: {
|
|
346
|
+
size: icon.fontSize,
|
|
347
|
+
// `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
|
|
348
|
+
// hand to a third-party component expecting a string.
|
|
349
|
+
color: typeof icon.color === "string" ? icon.color : void 0
|
|
350
|
+
},
|
|
351
|
+
isDisabled
|
|
352
|
+
};
|
|
353
|
+
}, [styles, tint, isDisabled]);
|
|
354
|
+
const rootStyle = [
|
|
355
|
+
styles.root,
|
|
356
|
+
tint?.root,
|
|
357
|
+
styleProps,
|
|
358
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
359
|
+
];
|
|
360
|
+
const text = childrenToString(children);
|
|
361
|
+
const content = text !== null ? /* @__PURE__ */ jsx6(ChipLabel, { children: text }) : children;
|
|
362
|
+
if (!isPressable && !asChild && (onPressIn || onPressOut || rest.onPress || rest.onLongPress)) {
|
|
363
|
+
warnDev(
|
|
364
|
+
"Chip: a press handler needs `isPressable`. Without it the chip renders a View, which never receives the touch \u2014 add `isPressable` to make it a control. A `Chip.Close` is its own control and needs neither."
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
const surface = isPressable ? /* @__PURE__ */ jsx6(
|
|
368
|
+
PressableFeedback,
|
|
369
|
+
{
|
|
370
|
+
ref,
|
|
371
|
+
isPressed,
|
|
372
|
+
isDisabled,
|
|
373
|
+
asChild,
|
|
374
|
+
animation,
|
|
375
|
+
accessibilityRole: accessibilityRole ?? "button",
|
|
376
|
+
accessibilityState: { disabled: isDisabled, ...accessibilityState },
|
|
377
|
+
...rest,
|
|
378
|
+
style: rootStyle,
|
|
379
|
+
onPressIn: press.onPressIn,
|
|
380
|
+
onPressOut: press.onPressOut,
|
|
381
|
+
children: asChild ? children : content
|
|
382
|
+
}
|
|
383
|
+
) : asChild ? (
|
|
384
|
+
// R12 — the caller's element is the chip, so it takes the children it was written
|
|
385
|
+
// with and the auto-wrap does not apply.
|
|
386
|
+
/* @__PURE__ */ jsx6(
|
|
387
|
+
Slot,
|
|
388
|
+
{
|
|
389
|
+
ref,
|
|
390
|
+
accessibilityRole,
|
|
391
|
+
accessibilityState,
|
|
392
|
+
...rest,
|
|
393
|
+
style: rootStyle,
|
|
394
|
+
children
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
) : /* @__PURE__ */ jsx6(
|
|
398
|
+
View3,
|
|
399
|
+
{
|
|
400
|
+
ref,
|
|
401
|
+
accessibilityRole,
|
|
402
|
+
accessibilityState,
|
|
403
|
+
...rest,
|
|
404
|
+
style: rootStyle,
|
|
405
|
+
children: content
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
return /* @__PURE__ */ jsx6(ChipProvider, { value: context, children: surface });
|
|
409
|
+
});
|
|
410
|
+
ChipRoot.displayName = "XAUI.Chip.Root";
|
|
411
|
+
|
|
412
|
+
// src/components/chip/index.ts
|
|
413
|
+
var Chip2 = Object.assign(ChipRoot, {
|
|
414
|
+
Label: ChipLabel,
|
|
415
|
+
Icon: ChipIcon,
|
|
416
|
+
Dot: ChipDot,
|
|
417
|
+
Avatar: ChipAvatar,
|
|
418
|
+
Close: ChipClose
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
export {
|
|
422
|
+
useChip,
|
|
423
|
+
chipRecipe,
|
|
424
|
+
Chip2 as Chip
|
|
425
|
+
};
|