@xaui/native 0.9.1-alpha.21 → 0.9.1-alpha.22
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-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-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 +193 -244
- package/dist/components/button/index.d.ts +193 -244
- package/dist/components/button/index.js +5 -6
- package/dist/components/card/index.cjs +5 -6
- package/dist/components/card/index.d.cts +193 -193
- package/dist/components/card/index.d.ts +193 -193
- 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/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-CbXika57.d.ts} +4 -3
- package/dist/{create-recipe-CPBFg7ym.d.cts → create-recipe-jHlk434p.d.cts} +4 -3
- 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 +36 -14
- package/dist/index.d.cts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +55 -33
- 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 +174 -100
- package/dist/system/index.d.ts +174 -100
- 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 +21 -1
- package/dist/chunk-RRRGLRRP.cjs +0 -28
- package/dist/chunk-SGHP76GU.js +0 -28
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CloseButton,
|
|
3
|
+
closeButtonBase
|
|
4
|
+
} from "./chunk-ZQ3JSWRO.js";
|
|
5
|
+
import {
|
|
6
|
+
Icon
|
|
7
|
+
} from "./chunk-FVP5FUVS.js";
|
|
8
|
+
import {
|
|
9
|
+
createRecipe,
|
|
10
|
+
radiusAxis
|
|
11
|
+
} from "./chunk-3JATAB7S.js";
|
|
12
|
+
import {
|
|
13
|
+
useXAUITheme
|
|
14
|
+
} from "./chunk-A3EGFI6T.js";
|
|
15
|
+
import {
|
|
16
|
+
Slot,
|
|
17
|
+
childrenToString,
|
|
18
|
+
createSlotContext,
|
|
19
|
+
useStyleProps
|
|
20
|
+
} from "./chunk-PMO62QK4.js";
|
|
21
|
+
|
|
22
|
+
// src/components/alert/alert-close.tsx
|
|
23
|
+
import { forwardRef } from "react";
|
|
24
|
+
|
|
25
|
+
// src/components/alert/alert.context.ts
|
|
26
|
+
var [AlertProvider, useAlert] = createSlotContext("Alert");
|
|
27
|
+
|
|
28
|
+
// src/components/alert/alert-close.tsx
|
|
29
|
+
import { jsx } from "react/jsx-runtime";
|
|
30
|
+
var AlertClose = forwardRef(function AlertClose2({ isDisabled, ...props }, ref) {
|
|
31
|
+
const { closeStyle, closeGlyphStyle, isDisabled: isAlertDisabled } = useAlert();
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
CloseButton,
|
|
34
|
+
{
|
|
35
|
+
ref,
|
|
36
|
+
name: "Alert.Close",
|
|
37
|
+
baseStyle: closeStyle,
|
|
38
|
+
glyphStyle: closeGlyphStyle,
|
|
39
|
+
isDisabled: isDisabled ?? isAlertDisabled,
|
|
40
|
+
...props
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
AlertClose.displayName = "XAUI.Alert.Close";
|
|
45
|
+
|
|
46
|
+
// src/components/alert/alert-content.tsx
|
|
47
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
48
|
+
import { View } from "react-native";
|
|
49
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
50
|
+
var AlertContent = forwardRef2(
|
|
51
|
+
function AlertContent2({ children, style, ...props }, ref) {
|
|
52
|
+
const { contentStyle } = useAlert();
|
|
53
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
54
|
+
return /* @__PURE__ */ jsx2(View, { ref, style: [contentStyle, styleProps, style], ...rest, children });
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
AlertContent.displayName = "XAUI.Alert.Content";
|
|
58
|
+
|
|
59
|
+
// src/components/alert/alert-description.tsx
|
|
60
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
61
|
+
import { Text } from "react-native";
|
|
62
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
63
|
+
var AlertDescription = forwardRef3(
|
|
64
|
+
function AlertDescription2({ children, style, ...props }, ref) {
|
|
65
|
+
const { descriptionStyle } = useAlert();
|
|
66
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
67
|
+
return /* @__PURE__ */ jsx3(Text, { ref, style: [descriptionStyle, styleProps, style], ...rest, children });
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
AlertDescription.displayName = "XAUI.Alert.Description";
|
|
71
|
+
|
|
72
|
+
// src/components/alert/alert-icon.tsx
|
|
73
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
74
|
+
import { View as View2 } from "react-native";
|
|
75
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
76
|
+
var AlertIcon = forwardRef4(function AlertIcon2({ as, children, source, size, color, style, ...props }, ref) {
|
|
77
|
+
const { iconStyle, icon } = useAlert();
|
|
78
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
79
|
+
const glyphSize = size ?? icon.size;
|
|
80
|
+
const glyphColor = color ?? icon.color;
|
|
81
|
+
return /* @__PURE__ */ jsx4(View2, { ref, style: [iconStyle, styleProps, style], ...rest, children: as ? /* @__PURE__ */ jsx4(Icon, { as, size: glyphSize, color: glyphColor }) : source ? /* @__PURE__ */ jsx4(Icon, { source, size: glyphSize, color: glyphColor }) : /* @__PURE__ */ jsx4(Icon, { size: glyphSize, color: glyphColor, children }) });
|
|
82
|
+
});
|
|
83
|
+
AlertIcon.displayName = "XAUI.Alert.Icon";
|
|
84
|
+
|
|
85
|
+
// src/components/alert/alert-title.tsx
|
|
86
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
87
|
+
import { Text as Text2 } from "react-native";
|
|
88
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
89
|
+
var AlertTitle = forwardRef5(function AlertTitle2({ children, style, ...props }, ref) {
|
|
90
|
+
const { titleStyle } = useAlert();
|
|
91
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
92
|
+
return /* @__PURE__ */ jsx5(Text2, { ref, style: [titleStyle, styleProps, style], ...rest, children });
|
|
93
|
+
});
|
|
94
|
+
AlertTitle.displayName = "XAUI.Alert.Title";
|
|
95
|
+
|
|
96
|
+
// src/components/alert/alert.tsx
|
|
97
|
+
import { forwardRef as forwardRef6, useMemo } from "react";
|
|
98
|
+
import { StyleSheet, View as View3 } from "react-native";
|
|
99
|
+
|
|
100
|
+
// src/components/alert/alert.recipe.ts
|
|
101
|
+
var SLOTS = [
|
|
102
|
+
"root",
|
|
103
|
+
"icon",
|
|
104
|
+
"iconGlyph",
|
|
105
|
+
"content",
|
|
106
|
+
"title",
|
|
107
|
+
"description",
|
|
108
|
+
"close",
|
|
109
|
+
"closeGlyph"
|
|
110
|
+
];
|
|
111
|
+
var VARIANT_TOKENS = {
|
|
112
|
+
default: { bg: "surface", fg: "surfaceForeground" },
|
|
113
|
+
primary: { bg: "accent", fg: "accentForeground" },
|
|
114
|
+
secondary: { bg: "accentSoft", fg: "accentSoftForeground" },
|
|
115
|
+
success: { bg: "success", fg: "successForeground" },
|
|
116
|
+
"success-soft": { bg: "successSoft", fg: "successSoftForeground" },
|
|
117
|
+
warning: { bg: "warning", fg: "warningForeground" },
|
|
118
|
+
"warning-soft": { bg: "warningSoft", fg: "warningSoftForeground" },
|
|
119
|
+
danger: { bg: "danger", fg: "dangerForeground" },
|
|
120
|
+
"danger-soft": { bg: "dangerSoft", fg: "dangerSoftForeground" }
|
|
121
|
+
};
|
|
122
|
+
var DESCRIPTION_OPACITY = 0.6;
|
|
123
|
+
function sizeAxis(step) {
|
|
124
|
+
const { padding, gap, contentGap, title, description, glyph, cross, radius } = step;
|
|
125
|
+
return (theme) => ({
|
|
126
|
+
root: {
|
|
127
|
+
padding: theme.spacing(padding),
|
|
128
|
+
gap: theme.spacing(gap),
|
|
129
|
+
borderRadius: theme.radius[radius]
|
|
130
|
+
},
|
|
131
|
+
icon: { paddingTop: (theme.lineHeights[title] - theme.fontSizes[glyph]) / 2 },
|
|
132
|
+
iconGlyph: { fontSize: theme.fontSizes[glyph] },
|
|
133
|
+
content: { gap: theme.spacing(contentGap) },
|
|
134
|
+
title: {
|
|
135
|
+
fontSize: theme.fontSizes[title],
|
|
136
|
+
lineHeight: theme.lineHeights[title]
|
|
137
|
+
},
|
|
138
|
+
description: {
|
|
139
|
+
fontSize: theme.fontSizes[description],
|
|
140
|
+
lineHeight: theme.lineHeights[description]
|
|
141
|
+
},
|
|
142
|
+
// The touch target is the glyph's box; the shared `CloseButton` grows it outwards
|
|
143
|
+
// with `hitSlop`, because a cross big enough to hit is a cross too big to look right.
|
|
144
|
+
close: { width: theme.fontSizes[glyph], height: theme.fontSizes[glyph] },
|
|
145
|
+
closeGlyph: { width: theme.spacing(cross) }
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
var SIZES = {
|
|
149
|
+
xs: {
|
|
150
|
+
padding: 2,
|
|
151
|
+
gap: 2,
|
|
152
|
+
contentGap: 0.5,
|
|
153
|
+
title: "xs",
|
|
154
|
+
description: "xs",
|
|
155
|
+
glyph: "sm",
|
|
156
|
+
cross: 2,
|
|
157
|
+
radius: "lg"
|
|
158
|
+
},
|
|
159
|
+
sm: {
|
|
160
|
+
padding: 2.5,
|
|
161
|
+
gap: 2.5,
|
|
162
|
+
contentGap: 0.5,
|
|
163
|
+
title: "sm",
|
|
164
|
+
description: "xs",
|
|
165
|
+
glyph: "md",
|
|
166
|
+
cross: 2,
|
|
167
|
+
radius: "xl"
|
|
168
|
+
},
|
|
169
|
+
md: {
|
|
170
|
+
padding: 3,
|
|
171
|
+
gap: 3,
|
|
172
|
+
contentGap: 1,
|
|
173
|
+
title: "md",
|
|
174
|
+
description: "sm",
|
|
175
|
+
glyph: "lg",
|
|
176
|
+
cross: 2.5,
|
|
177
|
+
radius: "2xl"
|
|
178
|
+
},
|
|
179
|
+
lg: {
|
|
180
|
+
padding: 4,
|
|
181
|
+
gap: 3.5,
|
|
182
|
+
contentGap: 1,
|
|
183
|
+
title: "lg",
|
|
184
|
+
description: "md",
|
|
185
|
+
glyph: "xl",
|
|
186
|
+
cross: 3,
|
|
187
|
+
radius: "3xl"
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var alertRecipe = createRecipe({
|
|
191
|
+
slots: SLOTS,
|
|
192
|
+
// The cross's own geometry — thickness and centring — belongs to the shared
|
|
193
|
+
// `CloseButton`; what stays below is the box and bar size this component's scale sets.
|
|
194
|
+
base: (theme) => ({
|
|
195
|
+
...closeButtonBase(theme),
|
|
196
|
+
root: {
|
|
197
|
+
flexDirection: "row",
|
|
198
|
+
// Top-aligned, not centred: an alert's message can run to three lines, and an icon
|
|
199
|
+
// floating beside the middle of a paragraph reads as decoration rather than as the
|
|
200
|
+
// mark of what the paragraph is. A single-line alert centres itself with
|
|
201
|
+
// `alignItems="center"` on the root — one prop, and it is the caller's call.
|
|
202
|
+
alignItems: "flex-start",
|
|
203
|
+
borderWidth: 0,
|
|
204
|
+
// iOS's squircle. Free on Android, and it is what makes a radius this large read as
|
|
205
|
+
// a shape rather than as four arcs meeting straight edges.
|
|
206
|
+
borderCurve: "continuous"
|
|
207
|
+
// Deliberately no `overflow: 'hidden'`: on iOS it clips the node's own shadow, so a
|
|
208
|
+
// `default` alert would lose the elevation the variant just gave it.
|
|
209
|
+
},
|
|
210
|
+
// `flex: 1` and not `flexGrow`: the root is a row, so the content has to be measured
|
|
211
|
+
// from a zero basis to take exactly what the icon and the close leave — the opposite
|
|
212
|
+
// of the `Card`'s body, which grows in a column where a zero basis collapses it.
|
|
213
|
+
content: { flex: 1 },
|
|
214
|
+
// `medium`, not `semibold`. An alert's title sits in prose rather than on a control:
|
|
215
|
+
// one weight above the description is enough to rank them.
|
|
216
|
+
title: {
|
|
217
|
+
fontFamily: theme.fontFamilies.heading,
|
|
218
|
+
fontWeight: theme.fontWeights.medium
|
|
219
|
+
},
|
|
220
|
+
description: {
|
|
221
|
+
fontFamily: theme.fontFamilies.body,
|
|
222
|
+
fontWeight: theme.fontWeights.regular,
|
|
223
|
+
opacity: DESCRIPTION_OPACITY
|
|
224
|
+
}
|
|
225
|
+
}),
|
|
226
|
+
variantTokens: VARIANT_TOKENS,
|
|
227
|
+
/**
|
|
228
|
+
* Where the variant's colours land, for every variant at once.
|
|
229
|
+
*
|
|
230
|
+
* The icon takes the **title's** colour rather than a status colour of its own — on a
|
|
231
|
+
* `danger` alert the readable colour is the one the title already uses, and on a
|
|
232
|
+
* `danger-soft` one that token *is* the red. HeroUI arrives at the same place from the
|
|
233
|
+
* other direction, colouring the icon by status on a neutral surface; here the variant
|
|
234
|
+
* decides both, and an icon that has to disagree with its alert says so itself with
|
|
235
|
+
* `<Alert.Icon color={…} />`.
|
|
236
|
+
*/
|
|
237
|
+
paint: (theme, colors) => ({
|
|
238
|
+
root: {
|
|
239
|
+
backgroundColor: colors.bg,
|
|
240
|
+
borderColor: colors.border,
|
|
241
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
242
|
+
},
|
|
243
|
+
iconGlyph: { color: colors.fg },
|
|
244
|
+
title: { color: colors.fg },
|
|
245
|
+
description: { color: colors.fg },
|
|
246
|
+
closeGlyph: { backgroundColor: colors.fg }
|
|
247
|
+
}),
|
|
248
|
+
/** Declaration order is application order: `radius` overrides the radius `size` set. */
|
|
249
|
+
variants: {
|
|
250
|
+
size: {
|
|
251
|
+
xs: sizeAxis(SIZES.xs),
|
|
252
|
+
sm: sizeAxis(SIZES.sm),
|
|
253
|
+
md: sizeAxis(SIZES.md),
|
|
254
|
+
lg: sizeAxis(SIZES.lg)
|
|
255
|
+
},
|
|
256
|
+
radius: radiusAxis("root")
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* The elevation belongs to the one variant that is a surface standing on the background,
|
|
260
|
+
* exactly as on the `Card`. A tinted alert already separates itself by its fill, and a
|
|
261
|
+
* shadow under it would read as dirt. In dark mode the theme's `surface` shadow is
|
|
262
|
+
* already nothing (§4), which is why this names the role instead of a set of numbers.
|
|
263
|
+
*/
|
|
264
|
+
compoundVariants: [
|
|
265
|
+
{
|
|
266
|
+
when: { variant: "default" },
|
|
267
|
+
style: (theme) => ({ root: theme.shadows.surface })
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
states: {
|
|
271
|
+
disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
|
|
272
|
+
},
|
|
273
|
+
defaultVariants: { variant: "default", size: "md" }
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// src/components/alert/alert.tsx
|
|
277
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
278
|
+
var AlertRoot = forwardRef6(function Alert({
|
|
279
|
+
children,
|
|
280
|
+
variant,
|
|
281
|
+
size,
|
|
282
|
+
radius,
|
|
283
|
+
color,
|
|
284
|
+
isDisabled = false,
|
|
285
|
+
asChild = false,
|
|
286
|
+
accessibilityRole = "alert",
|
|
287
|
+
// Android reads a live region aloud when its content changes, which is what makes an
|
|
288
|
+
// alert that *appears* announce itself instead of waiting to be found. `'polite'`
|
|
289
|
+
// rather than `'assertive'`: it queues behind whatever is being read instead of
|
|
290
|
+
// cutting it off. A static alert that is part of the page sets `'none'`.
|
|
291
|
+
accessibilityLiveRegion = "polite",
|
|
292
|
+
style,
|
|
293
|
+
...props
|
|
294
|
+
}, ref) {
|
|
295
|
+
const theme = useXAUITheme();
|
|
296
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
297
|
+
const selection = { variant, size, radius };
|
|
298
|
+
const states = { disabled: isDisabled };
|
|
299
|
+
const styles = alertRecipe.resolve({ theme, selection, states });
|
|
300
|
+
const tint = color ? alertRecipe.tint({ theme, color, selection, states }) : void 0;
|
|
301
|
+
const context = useMemo(() => {
|
|
302
|
+
const glyph = StyleSheet.flatten([styles.iconGlyph, tint?.iconGlyph]);
|
|
303
|
+
return {
|
|
304
|
+
iconStyle: styles.icon,
|
|
305
|
+
contentStyle: styles.content,
|
|
306
|
+
titleStyle: tint ? [styles.title, tint.title] : styles.title,
|
|
307
|
+
descriptionStyle: tint ? [styles.description, tint.description] : styles.description,
|
|
308
|
+
closeStyle: styles.close,
|
|
309
|
+
closeGlyphStyle: tint ? [styles.closeGlyph, tint.closeGlyph] : styles.closeGlyph,
|
|
310
|
+
icon: {
|
|
311
|
+
size: glyph.fontSize,
|
|
312
|
+
// `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
|
|
313
|
+
// hand to a third-party component expecting a string.
|
|
314
|
+
color: typeof glyph.color === "string" ? glyph.color : void 0
|
|
315
|
+
},
|
|
316
|
+
isDisabled
|
|
317
|
+
};
|
|
318
|
+
}, [styles, tint, isDisabled]);
|
|
319
|
+
const rootStyle = [styles.root, tint?.root, styleProps, style];
|
|
320
|
+
const text = childrenToString(children);
|
|
321
|
+
const content = text !== null ? /* @__PURE__ */ jsx6(AlertDescription, { children: text }) : children;
|
|
322
|
+
const surface = asChild ? (
|
|
323
|
+
// R12 — the caller's element *is* the alert, so it takes the children it was written
|
|
324
|
+
// with and the auto-wrap does not apply.
|
|
325
|
+
/* @__PURE__ */ jsx6(
|
|
326
|
+
Slot,
|
|
327
|
+
{
|
|
328
|
+
ref,
|
|
329
|
+
accessibilityRole,
|
|
330
|
+
accessibilityLiveRegion,
|
|
331
|
+
...rest,
|
|
332
|
+
style: rootStyle,
|
|
333
|
+
children
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
) : /* @__PURE__ */ jsx6(
|
|
337
|
+
View3,
|
|
338
|
+
{
|
|
339
|
+
ref,
|
|
340
|
+
accessibilityRole,
|
|
341
|
+
accessibilityLiveRegion,
|
|
342
|
+
...rest,
|
|
343
|
+
style: rootStyle,
|
|
344
|
+
children: content
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
return /* @__PURE__ */ jsx6(AlertProvider, { value: context, children: surface });
|
|
348
|
+
});
|
|
349
|
+
AlertRoot.displayName = "XAUI.Alert.Root";
|
|
350
|
+
|
|
351
|
+
// src/components/alert/index.ts
|
|
352
|
+
var Alert2 = Object.assign(AlertRoot, {
|
|
353
|
+
Icon: AlertIcon,
|
|
354
|
+
Content: AlertContent,
|
|
355
|
+
Title: AlertTitle,
|
|
356
|
+
Description: AlertDescription,
|
|
357
|
+
Close: AlertClose
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
export {
|
|
361
|
+
useAlert,
|
|
362
|
+
alertRecipe,
|
|
363
|
+
Alert2 as Alert
|
|
364
|
+
};
|
|
@@ -2,6 +2,102 @@ import {
|
|
|
2
2
|
stableHash
|
|
3
3
|
} from "./chunk-GGW42MY4.js";
|
|
4
4
|
|
|
5
|
+
// src/system/slot/create-slot-context.ts
|
|
6
|
+
import { createContext, useContext } from "react";
|
|
7
|
+
function createSlotContext(name) {
|
|
8
|
+
const Context = createContext(null);
|
|
9
|
+
Context.displayName = `XAUI.${name}.Context`;
|
|
10
|
+
function useSlotContext() {
|
|
11
|
+
const value = useContext(Context);
|
|
12
|
+
if (value === null) {
|
|
13
|
+
const error = new Error(
|
|
14
|
+
`XAUI: use${name} must be called inside <${name}>. A slot reads the values its root resolved, so it can only be rendered as a child of one.`
|
|
15
|
+
);
|
|
16
|
+
Error.captureStackTrace?.(
|
|
17
|
+
error,
|
|
18
|
+
useSlotContext
|
|
19
|
+
);
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
return [Context.Provider, useSlotContext];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/system/slot/merge-refs.ts
|
|
28
|
+
function mergeRefs(...refs) {
|
|
29
|
+
return (value) => {
|
|
30
|
+
for (const ref of refs) {
|
|
31
|
+
if (typeof ref === "function") ref(value);
|
|
32
|
+
else if (ref) ref.current = value;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/system/slot/merge-props.ts
|
|
38
|
+
var EVENT_HANDLER = /^on[A-Z]/;
|
|
39
|
+
function mergeProps(ours, theirs) {
|
|
40
|
+
const merged = { ...ours };
|
|
41
|
+
for (const key of Object.keys(theirs)) {
|
|
42
|
+
const ourValue = ours[key];
|
|
43
|
+
const theirValue = theirs[key];
|
|
44
|
+
if (EVENT_HANDLER.test(key)) {
|
|
45
|
+
merged[key] = composeHandlers(ourValue, theirValue);
|
|
46
|
+
} else if (key === "style") {
|
|
47
|
+
merged[key] = mergeStyles(ourValue, theirValue);
|
|
48
|
+
} else if (key === "ref") {
|
|
49
|
+
merged[key] = mergeRefs(
|
|
50
|
+
ourValue,
|
|
51
|
+
theirValue
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
merged[key] = theirValue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return merged;
|
|
58
|
+
}
|
|
59
|
+
function composeHandlers(ours, theirs) {
|
|
60
|
+
if (typeof ours !== "function") return theirs;
|
|
61
|
+
if (typeof theirs !== "function") return ours;
|
|
62
|
+
return (...args) => {
|
|
63
|
+
;
|
|
64
|
+
ours(...args);
|
|
65
|
+
return theirs(...args);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function mergeStyles(ours, theirs) {
|
|
69
|
+
if (typeof ours === "function" || typeof theirs === "function") {
|
|
70
|
+
return (state) => [
|
|
71
|
+
resolveStyle(ours, state),
|
|
72
|
+
resolveStyle(theirs, state)
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
return [ours, theirs];
|
|
76
|
+
}
|
|
77
|
+
function resolveStyle(style, state) {
|
|
78
|
+
return typeof style === "function" ? style(state) : style;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/system/slot/slot.tsx
|
|
82
|
+
import { cloneElement, forwardRef, isValidElement } from "react";
|
|
83
|
+
var Slot = forwardRef(function Slot2({ children, ...ours }, ref) {
|
|
84
|
+
if (!isValidElement(children)) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
"XAUI: asChild expects exactly one React element as its child, and merges the component's props into it. Text, a fragment, several children or none give it nothing to merge into \u2014 drop `asChild` to render the component itself."
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const child = children;
|
|
90
|
+
const merged = mergeProps(ours, child.props);
|
|
91
|
+
merged.ref = mergeRefs(ref, refOf(child));
|
|
92
|
+
return cloneElement(child, merged);
|
|
93
|
+
});
|
|
94
|
+
Slot.displayName = "XAUI.Slot";
|
|
95
|
+
function refOf(element) {
|
|
96
|
+
const fromProps = element.props.ref;
|
|
97
|
+
const fromElement = element.ref;
|
|
98
|
+
return fromProps ?? fromElement;
|
|
99
|
+
}
|
|
100
|
+
|
|
5
101
|
// src/system/style-props/use-style-props.ts
|
|
6
102
|
import { useMemo } from "react";
|
|
7
103
|
|
|
@@ -175,7 +271,7 @@ function useStyleProps(props) {
|
|
|
175
271
|
}
|
|
176
272
|
|
|
177
273
|
// src/system/slot/children-to-string.ts
|
|
178
|
-
import { isValidElement } from "react";
|
|
274
|
+
import { isValidElement as isValidElement2 } from "react";
|
|
179
275
|
function childrenToString(children) {
|
|
180
276
|
const text = stringify(children);
|
|
181
277
|
return text === null || text === "" ? null : text;
|
|
@@ -184,7 +280,7 @@ function stringify(node) {
|
|
|
184
280
|
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
185
281
|
if (typeof node === "string") return node;
|
|
186
282
|
if (typeof node === "number") return String(node);
|
|
187
|
-
if (
|
|
283
|
+
if (isValidElement2(node)) return null;
|
|
188
284
|
if (Array.isArray(node)) {
|
|
189
285
|
let text = "";
|
|
190
286
|
for (const child of node) {
|
|
@@ -197,107 +293,11 @@ function stringify(node) {
|
|
|
197
293
|
return null;
|
|
198
294
|
}
|
|
199
295
|
|
|
200
|
-
// src/system/slot/create-slot-context.ts
|
|
201
|
-
import { createContext, useContext } from "react";
|
|
202
|
-
function createSlotContext(name) {
|
|
203
|
-
const Context = createContext(null);
|
|
204
|
-
Context.displayName = `XAUI.${name}.Context`;
|
|
205
|
-
function useSlotContext() {
|
|
206
|
-
const value = useContext(Context);
|
|
207
|
-
if (value === null) {
|
|
208
|
-
const error = new Error(
|
|
209
|
-
`XAUI: use${name} must be called inside <${name}>. A slot reads the values its root resolved, so it can only be rendered as a child of one.`
|
|
210
|
-
);
|
|
211
|
-
Error.captureStackTrace?.(
|
|
212
|
-
error,
|
|
213
|
-
useSlotContext
|
|
214
|
-
);
|
|
215
|
-
throw error;
|
|
216
|
-
}
|
|
217
|
-
return value;
|
|
218
|
-
}
|
|
219
|
-
return [Context.Provider, useSlotContext];
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/system/slot/merge-refs.ts
|
|
223
|
-
function mergeRefs(...refs) {
|
|
224
|
-
return (value) => {
|
|
225
|
-
for (const ref of refs) {
|
|
226
|
-
if (typeof ref === "function") ref(value);
|
|
227
|
-
else if (ref) ref.current = value;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// src/system/slot/merge-props.ts
|
|
233
|
-
var EVENT_HANDLER = /^on[A-Z]/;
|
|
234
|
-
function mergeProps(ours, theirs) {
|
|
235
|
-
const merged = { ...ours };
|
|
236
|
-
for (const key of Object.keys(theirs)) {
|
|
237
|
-
const ourValue = ours[key];
|
|
238
|
-
const theirValue = theirs[key];
|
|
239
|
-
if (EVENT_HANDLER.test(key)) {
|
|
240
|
-
merged[key] = composeHandlers(ourValue, theirValue);
|
|
241
|
-
} else if (key === "style") {
|
|
242
|
-
merged[key] = mergeStyles(ourValue, theirValue);
|
|
243
|
-
} else if (key === "ref") {
|
|
244
|
-
merged[key] = mergeRefs(
|
|
245
|
-
ourValue,
|
|
246
|
-
theirValue
|
|
247
|
-
);
|
|
248
|
-
} else {
|
|
249
|
-
merged[key] = theirValue;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return merged;
|
|
253
|
-
}
|
|
254
|
-
function composeHandlers(ours, theirs) {
|
|
255
|
-
if (typeof ours !== "function") return theirs;
|
|
256
|
-
if (typeof theirs !== "function") return ours;
|
|
257
|
-
return (...args) => {
|
|
258
|
-
;
|
|
259
|
-
ours(...args);
|
|
260
|
-
return theirs(...args);
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function mergeStyles(ours, theirs) {
|
|
264
|
-
if (typeof ours === "function" || typeof theirs === "function") {
|
|
265
|
-
return (state) => [
|
|
266
|
-
resolveStyle(ours, state),
|
|
267
|
-
resolveStyle(theirs, state)
|
|
268
|
-
];
|
|
269
|
-
}
|
|
270
|
-
return [ours, theirs];
|
|
271
|
-
}
|
|
272
|
-
function resolveStyle(style, state) {
|
|
273
|
-
return typeof style === "function" ? style(state) : style;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// src/system/slot/slot.tsx
|
|
277
|
-
import { cloneElement, forwardRef, isValidElement as isValidElement2 } from "react";
|
|
278
|
-
var Slot = forwardRef(function Slot2({ children, ...ours }, ref) {
|
|
279
|
-
if (!isValidElement2(children)) {
|
|
280
|
-
throw new Error(
|
|
281
|
-
"XAUI: asChild expects exactly one React element as its child, and merges the component's props into it. Text, a fragment, several children or none give it nothing to merge into \u2014 drop `asChild` to render the component itself."
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
const child = children;
|
|
285
|
-
const merged = mergeProps(ours, child.props);
|
|
286
|
-
merged.ref = mergeRefs(ref, refOf(child));
|
|
287
|
-
return cloneElement(child, merged);
|
|
288
|
-
});
|
|
289
|
-
Slot.displayName = "XAUI.Slot";
|
|
290
|
-
function refOf(element) {
|
|
291
|
-
const fromProps = element.props.ref;
|
|
292
|
-
const fromElement = element.ref;
|
|
293
|
-
return fromProps ?? fromElement;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
296
|
export {
|
|
297
|
-
useStyleProps,
|
|
298
|
-
childrenToString,
|
|
299
297
|
createSlotContext,
|
|
300
298
|
mergeRefs,
|
|
301
299
|
mergeProps,
|
|
302
|
-
Slot
|
|
300
|
+
Slot,
|
|
301
|
+
useStyleProps,
|
|
302
|
+
childrenToString
|
|
303
303
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkYXVKQMCKcjs = require('./chunk-YXVKQMCK.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
|
|
6
7
|
|
|
7
|
-
var _chunkEVXZGNPAcjs = require('./chunk-EVXZGNPA.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkHUZ4AUM2cjs = require('./chunk-HUZ4AUM2.cjs');
|
|
11
11
|
|
|
12
12
|
// src/components/typography/typography.tsx
|
|
13
13
|
var _react = require('react');
|
|
@@ -60,7 +60,7 @@ function metricsOf({ step, weight, family, letterSpacing, chip }) {
|
|
|
60
60
|
var ROLE_AXIS = Object.fromEntries(
|
|
61
61
|
Object.entries(ROLES).map(([name, spec]) => [name, metricsOf(spec)])
|
|
62
62
|
);
|
|
63
|
-
var typographyRecipe =
|
|
63
|
+
var typographyRecipe = _chunkYXVKQMCKcjs.createRecipe.call(void 0, {
|
|
64
64
|
slots: SLOTS,
|
|
65
65
|
variantTokens: VARIANT_TOKENS,
|
|
66
66
|
// Ink only. The chip's fill is a token, not a role, so it belongs to the metrics above —
|
|
@@ -74,12 +74,12 @@ var typographyRecipe = _chunkUVO4GFSWcjs.createRecipe.call(void 0, {
|
|
|
74
74
|
var _jsxruntime = require('react/jsx-runtime');
|
|
75
75
|
var Typography = _react.forwardRef.call(void 0, function Typography2({ children, variant, color, asChild = false, style, ...props }, ref) {
|
|
76
76
|
const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
|
|
77
|
-
const [styleProps, rest] =
|
|
77
|
+
const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
|
|
78
78
|
const selection = { variant };
|
|
79
79
|
const styles = typographyRecipe.resolve({ theme, selection });
|
|
80
80
|
const tint = color ? typographyRecipe.tint({ theme, color, selection }) : void 0;
|
|
81
81
|
const rootStyle = [styles.root, _optionalChain([tint, 'optionalAccess', _ => _.root]), styleProps, style];
|
|
82
|
-
const Root = asChild ?
|
|
82
|
+
const Root = asChild ? _chunkHUZ4AUM2cjs.Slot : _reactnative.Text;
|
|
83
83
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: rootStyle, ...rest, children });
|
|
84
84
|
});
|
|
85
85
|
Typography.displayName = "XAUI.Typography";
|
|
@@ -89,8 +89,8 @@ Typography.displayName = "XAUI.Typography";
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
var TextSpan = _react.forwardRef.call(void 0, function TextSpan2({ children, asChild = false, style, ...props }, ref) {
|
|
92
|
-
const [styleProps, rest] =
|
|
93
|
-
const Root = asChild ?
|
|
92
|
+
const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
|
|
93
|
+
const Root = asChild ? _chunkHUZ4AUM2cjs.Slot : _reactnative.Text;
|
|
94
94
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [styleProps, style], ...rest, children });
|
|
95
95
|
});
|
|
96
96
|
TextSpan.displayName = "XAUI.TextSpan";
|