@xaui/native 0.9.1-alpha.3 → 0.9.1-alpha.31

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.
Files changed (149) hide show
  1. package/dist/chunk-3FV4COTM.js +68 -0
  2. package/dist/chunk-423RQBOX.js +21 -0
  3. package/dist/chunk-42FMGB5M.js +661 -0
  4. package/dist/chunk-4GTAZM2C.js +174 -0
  5. package/dist/chunk-4XPLPQLM.cjs +147 -0
  6. package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
  7. package/dist/chunk-5GO7MAVY.cjs +74 -0
  8. package/dist/chunk-5PTBRJM7.cjs +346 -0
  9. package/dist/chunk-5RQ7AZPN.cjs +455 -0
  10. package/dist/chunk-5Z4P6WHR.cjs +525 -0
  11. package/dist/chunk-7DPL3ZDS.cjs +21 -0
  12. package/dist/chunk-7EIHHOHP.cjs +42 -0
  13. package/dist/chunk-7SEZGVTY.js +62 -0
  14. package/dist/chunk-7XKQJQF2.cjs +70 -0
  15. package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
  16. package/dist/chunk-A5OCK3C2.js +525 -0
  17. package/dist/chunk-AETWQQWU.cjs +92 -0
  18. package/dist/chunk-ANNUYP55.cjs +431 -0
  19. package/dist/chunk-BA2DBSAN.js +102 -0
  20. package/dist/chunk-BFMTUMTU.js +669 -0
  21. package/dist/chunk-BVJQ3UPZ.js +62 -0
  22. package/dist/chunk-DFME724B.js +147 -0
  23. package/dist/chunk-E2CWBQTV.js +119 -0
  24. package/dist/chunk-EGLLDKN6.js +9 -0
  25. package/dist/chunk-EJQCQPET.cjs +9 -0
  26. package/dist/chunk-F6CQ6CBI.cjs +112 -0
  27. package/dist/chunk-F6W3JQ7K.js +42 -0
  28. package/dist/chunk-FNEUOBCV.cjs +174 -0
  29. package/dist/chunk-G7K652GC.js +145 -0
  30. package/dist/chunk-GGW42MY4.js +20 -0
  31. package/dist/chunk-GLGU2WFL.cjs +190 -0
  32. package/dist/chunk-GPVNCJ3Z.cjs +696 -0
  33. package/dist/chunk-GVQOD3VW.js +74 -0
  34. package/dist/chunk-IHOCANCQ.js +293 -0
  35. package/dist/chunk-JDFV4W6N.cjs +700 -0
  36. package/dist/chunk-KOC3KQIT.js +124 -0
  37. package/dist/chunk-KPWZLUES.cjs +124 -0
  38. package/dist/chunk-L7JN6OBQ.cjs +314 -0
  39. package/dist/chunk-MC7SY2QH.cjs +20 -0
  40. package/dist/chunk-MDVSCWJI.js +314 -0
  41. package/dist/chunk-N527BTY4.cjs +366 -0
  42. package/dist/chunk-NYRXUGVL.js +104 -0
  43. package/dist/{chunk-AW63PTQ4.cjs → chunk-OHEHPQLC.cjs} +72 -72
  44. package/dist/chunk-Q3WFY5N3.js +366 -0
  45. package/dist/chunk-QGN2BBJO.cjs +104 -0
  46. package/dist/chunk-RDTKAAHX.js +346 -0
  47. package/dist/chunk-TGZZ3RZU.cjs +86 -0
  48. package/dist/{chunk-2KXQATVL.js → chunk-TZG3DERP.js} +46 -46
  49. package/dist/chunk-URSKA2VR.js +190 -0
  50. package/dist/chunk-V4WDMM6Z.js +86 -0
  51. package/dist/chunk-VJEER76X.js +455 -0
  52. package/dist/chunk-VZBWYWEI.cjs +736 -0
  53. package/dist/chunk-WR7YLDVV.cjs +68 -0
  54. package/dist/chunk-X4HQ4H2V.js +701 -0
  55. package/dist/chunk-XFSW3ZNI.cjs +145 -0
  56. package/dist/chunk-XQFAUDR2.cjs +62 -0
  57. package/dist/chunk-ZH5XVNHG.js +92 -0
  58. package/dist/chunk-ZH6BHLQR.js +431 -0
  59. package/dist/chunk-ZP2E2H2G.cjs +119 -0
  60. package/dist/chunk-ZVWXM3UK.cjs +293 -0
  61. package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
  62. package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
  63. package/dist/components/alert/index.cjs +20 -0
  64. package/dist/components/alert/index.d.cts +169 -0
  65. package/dist/components/alert/index.d.ts +169 -0
  66. package/dist/components/alert/index.js +20 -0
  67. package/dist/components/button/index.cjs +21 -0
  68. package/dist/components/button/index.d.cts +613 -0
  69. package/dist/components/button/index.d.ts +613 -0
  70. package/dist/components/button/index.js +21 -0
  71. package/dist/components/card/index.cjs +22 -0
  72. package/dist/components/card/index.d.cts +620 -0
  73. package/dist/components/card/index.d.ts +620 -0
  74. package/dist/components/card/index.js +22 -0
  75. package/dist/components/checkbox/index.cjs +26 -0
  76. package/dist/components/checkbox/index.d.cts +1136 -0
  77. package/dist/components/checkbox/index.d.ts +1136 -0
  78. package/dist/components/checkbox/index.js +26 -0
  79. package/dist/components/chip/index.cjs +20 -0
  80. package/dist/components/chip/index.d.cts +608 -0
  81. package/dist/components/chip/index.d.ts +608 -0
  82. package/dist/components/chip/index.js +20 -0
  83. package/dist/components/divider/index.cjs +13 -0
  84. package/dist/components/divider/index.d.cts +117 -0
  85. package/dist/components/divider/index.d.ts +117 -0
  86. package/dist/components/divider/index.js +13 -0
  87. package/dist/components/input/index.cjs +25 -0
  88. package/dist/components/input/index.d.cts +205 -0
  89. package/dist/components/input/index.d.ts +205 -0
  90. package/dist/components/input/index.js +25 -0
  91. package/dist/components/input-group/index.cjs +27 -0
  92. package/dist/components/input-group/index.d.cts +270 -0
  93. package/dist/components/input-group/index.d.ts +270 -0
  94. package/dist/components/input-group/index.js +27 -0
  95. package/dist/components/input-otp/index.cjs +29 -0
  96. package/dist/components/input-otp/index.d.cts +325 -0
  97. package/dist/components/input-otp/index.d.ts +325 -0
  98. package/dist/components/input-otp/index.js +29 -0
  99. package/dist/components/radio/index.cjs +26 -0
  100. package/dist/components/radio/index.d.cts +1102 -0
  101. package/dist/components/radio/index.d.ts +1102 -0
  102. package/dist/components/radio/index.js +26 -0
  103. package/dist/components/spinner/index.cjs +16 -0
  104. package/dist/components/spinner/index.d.cts +104 -0
  105. package/dist/components/spinner/index.d.ts +104 -0
  106. package/dist/components/spinner/index.js +16 -0
  107. package/dist/components/switch/index.cjs +27 -0
  108. package/dist/components/switch/index.d.cts +1154 -0
  109. package/dist/components/switch/index.d.ts +1154 -0
  110. package/dist/components/switch/index.js +27 -0
  111. package/dist/components/text-area/index.cjs +14 -0
  112. package/dist/components/text-area/index.d.cts +73 -0
  113. package/dist/components/text-area/index.d.ts +73 -0
  114. package/dist/components/text-area/index.js +14 -0
  115. package/dist/components/typography/index.cjs +15 -0
  116. package/dist/components/typography/index.d.cts +116 -0
  117. package/dist/components/typography/index.d.ts +116 -0
  118. package/dist/components/typography/index.js +15 -0
  119. package/dist/components/view/index.cjs +17 -0
  120. package/dist/components/view/index.d.cts +152 -0
  121. package/dist/components/view/index.d.ts +152 -0
  122. package/dist/components/view/index.js +17 -0
  123. package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
  124. package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
  125. package/dist/icon.type-Kml72iSz.d.ts +73 -0
  126. package/dist/icon.type-d_i9ma-i.d.cts +73 -0
  127. package/dist/index.cjs +252 -4
  128. package/dist/index.d.cts +110 -4
  129. package/dist/index.d.ts +110 -4
  130. package/dist/index.js +271 -23
  131. package/dist/input.type-BUMDlzL9.d.cts +167 -0
  132. package/dist/input.type-D2qgi03E.d.ts +167 -0
  133. package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
  134. package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
  135. package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
  136. package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
  137. package/dist/system/index.cjs +60 -3
  138. package/dist/system/index.d.cts +347 -181
  139. package/dist/system/index.d.ts +347 -181
  140. package/dist/system/index.js +71 -14
  141. package/dist/theme/index.cjs +4 -3
  142. package/dist/theme/index.d.cts +34 -23
  143. package/dist/theme/index.d.ts +34 -23
  144. package/dist/theme/index.js +3 -2
  145. package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
  146. package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
  147. package/package.json +184 -18
  148. package/dist/chunk-QAMNNTGM.js +0 -637
  149. package/dist/chunk-V63JO65F.cjs +0 -637
@@ -0,0 +1,314 @@
1
+ import {
2
+ useRotation
3
+ } from "./chunk-BVJQ3UPZ.js";
4
+ import {
5
+ PressableFeedback
6
+ } from "./chunk-BFMTUMTU.js";
7
+ import {
8
+ usePressState
9
+ } from "./chunk-423RQBOX.js";
10
+ import {
11
+ warnDev
12
+ } from "./chunk-EGLLDKN6.js";
13
+ import {
14
+ Icon
15
+ } from "./chunk-3FV4COTM.js";
16
+ import {
17
+ createRecipe,
18
+ radiusAxis
19
+ } from "./chunk-4GTAZM2C.js";
20
+ import {
21
+ useXAUITheme
22
+ } from "./chunk-A3EGFI6T.js";
23
+ import {
24
+ childrenToString,
25
+ createSlotContext
26
+ } from "./chunk-E2CWBQTV.js";
27
+ import {
28
+ useStyleProps
29
+ } from "./chunk-URSKA2VR.js";
30
+
31
+ // src/components/button/button.context.ts
32
+ var [ButtonProvider, useButton] = createSlotContext("Button");
33
+
34
+ // src/components/button/button-icon.tsx
35
+ import { jsx } from "react/jsx-runtime";
36
+ function ButtonIcon({ size, color, ...rest }) {
37
+ const { icon } = useButton();
38
+ return /* @__PURE__ */ jsx(Icon, { size: size ?? icon.size, color: color ?? icon.color, ...rest });
39
+ }
40
+ ButtonIcon.displayName = "XAUI.Button.Icon";
41
+
42
+ // src/components/button/button-label.tsx
43
+ import { forwardRef } from "react";
44
+ import { Text } from "react-native";
45
+ import { jsx as jsx2 } from "react/jsx-runtime";
46
+ var ButtonLabel = forwardRef(function ButtonLabel2({ children, style, numberOfLines = 1, ...props }, ref) {
47
+ const { labelStyle } = useButton();
48
+ const [styleProps, rest] = useStyleProps(props);
49
+ return /* @__PURE__ */ jsx2(
50
+ Text,
51
+ {
52
+ ref,
53
+ numberOfLines,
54
+ style: [labelStyle, styleProps, style],
55
+ ...rest,
56
+ children
57
+ }
58
+ );
59
+ });
60
+ ButtonLabel.displayName = "XAUI.Button.Label";
61
+
62
+ // src/components/button/button-spinner.tsx
63
+ import { View } from "react-native";
64
+ import Animated from "react-native-reanimated";
65
+ import { jsx as jsx3 } from "react/jsx-runtime";
66
+ function ButtonSpinner({
67
+ style,
68
+ animation = true,
69
+ ...props
70
+ }) {
71
+ const { spinnerStyle } = useButton();
72
+ const [styleProps] = useStyleProps(props);
73
+ const ringStyle = [spinnerStyle, styleProps, style];
74
+ if (!animation) return /* @__PURE__ */ jsx3(View, { style: ringStyle });
75
+ return /* @__PURE__ */ jsx3(SpinningRing, { style: ringStyle });
76
+ }
77
+ ButtonSpinner.displayName = "XAUI.Button.Spinner";
78
+ function SpinningRing({ style }) {
79
+ const rotation = useRotation();
80
+ return /* @__PURE__ */ jsx3(Animated.View, { style: [style, rotation] });
81
+ }
82
+
83
+ // src/components/button/button.tsx
84
+ import { forwardRef as forwardRef2, useMemo } from "react";
85
+ import { StyleSheet } from "react-native";
86
+
87
+ // src/components/button/button.recipe.ts
88
+ var SLOTS = ["root", "label", "icon", "spinner"];
89
+ var VARIANT_TOKENS = {
90
+ primary: { bg: "accent", bgPressed: "accentPressed", fg: "accentForeground" },
91
+ // The accent's soft slice, not a second neutral: `secondary` is to `primary` what
92
+ // `danger-soft` is to `danger`, and it reads as the same family at lower emphasis.
93
+ secondary: {
94
+ bg: "accentSoft",
95
+ bgPressed: "accentSoftPressed",
96
+ fg: "accentSoftForeground"
97
+ },
98
+ default: { bg: "default", bgPressed: "defaultPressed", fg: "defaultForeground" },
99
+ tertiary: {
100
+ border: "border",
101
+ bgPressed: "defaultSoftPressed",
102
+ fg: "foreground"
103
+ },
104
+ ghost: { bgPressed: "defaultSoftPressed", fg: "foreground" },
105
+ danger: { bg: "danger", bgPressed: "dangerPressed", fg: "dangerForeground" },
106
+ "danger-soft": {
107
+ bg: "dangerSoft",
108
+ bgPressed: "dangerSoftPressed",
109
+ fg: "dangerSoftForeground"
110
+ }
111
+ };
112
+ function ring(theme, size) {
113
+ return {
114
+ width: size,
115
+ height: size,
116
+ borderRadius: size / 2,
117
+ borderWidth: theme.borderWidth.default * 2,
118
+ borderTopColor: "transparent"
119
+ };
120
+ }
121
+ function sizeAxis(step) {
122
+ const { size, padding, gap, glyph, radius } = step;
123
+ return (theme) => ({
124
+ root: {
125
+ height: theme.controlHeights[size],
126
+ paddingHorizontal: theme.spacing(padding),
127
+ gap: theme.spacing(gap),
128
+ borderRadius: theme.radius[radius]
129
+ },
130
+ label: {
131
+ fontSize: theme.fontSizes[size],
132
+ lineHeight: theme.lineHeights[size]
133
+ },
134
+ icon: { fontSize: theme.fontSizes[glyph] },
135
+ spinner: ring(theme, theme.fontSizes[glyph])
136
+ });
137
+ }
138
+ var buttonRecipe = createRecipe({
139
+ slots: SLOTS,
140
+ base: (theme) => ({
141
+ root: {
142
+ flexDirection: "row",
143
+ alignItems: "center",
144
+ justifyContent: "center",
145
+ borderWidth: 0,
146
+ // iOS's squircle. Free on Android, and it is what makes a large radius read as a
147
+ // shape rather than as two arcs meeting a straight edge.
148
+ borderCurve: "continuous"
149
+ },
150
+ label: {
151
+ fontFamily: theme.fontFamilies.body,
152
+ fontWeight: theme.fontWeights.medium
153
+ }
154
+ }),
155
+ variantTokens: VARIANT_TOKENS,
156
+ /**
157
+ * Where the variant's colours land, for every variant at once. The border width follows
158
+ * the *presence* of the border role rather than a per-variant flag — `tertiary` is the
159
+ * only variant that names one, and that fact is already in the table above.
160
+ */
161
+ paint: (theme, colors) => ({
162
+ root: {
163
+ backgroundColor: colors.bg,
164
+ borderColor: colors.border,
165
+ borderWidth: colors.border ? theme.borderWidth.default : 0
166
+ },
167
+ label: { color: colors.fg },
168
+ icon: { color: colors.fg },
169
+ spinner: { borderColor: colors.fg }
170
+ }),
171
+ /**
172
+ * Declaration order is application order: `radius` overrides the radius `size` set, and
173
+ * `isIconOnly` overrides its padding. Both are axes rather than a static sheet merged
174
+ * at the call site, so they stay inside the cache key and a press still allocates
175
+ * nothing.
176
+ */
177
+ variants: {
178
+ size: {
179
+ xs: sizeAxis({ size: "xs", padding: 3, gap: 1, glyph: "sm", radius: "3xl" }),
180
+ sm: sizeAxis({
181
+ size: "sm",
182
+ padding: 3.5,
183
+ gap: 1.5,
184
+ glyph: "md",
185
+ radius: "3xl"
186
+ }),
187
+ md: sizeAxis({ size: "md", padding: 4, gap: 2, glyph: "lg", radius: "3xl" }),
188
+ lg: sizeAxis({ size: "lg", padding: 5, gap: 2.5, glyph: "xl", radius: "4xl" })
189
+ },
190
+ radius: radiusAxis("root"),
191
+ // A square on a fixed height. No width is computed, and none needs to be.
192
+ isIconOnly: {
193
+ true: () => ({ root: { paddingHorizontal: 0, aspectRatio: 1 } })
194
+ }
195
+ },
196
+ /**
197
+ * The pressed colour lives here rather than in a `PressableFeedback.Highlight`, because
198
+ * a control picks one treatment or the other — both, and a pressed button darkens
199
+ * twice. This one is the variant's own `…Pressed` token, so the press reads as the
200
+ * button's colour going down rather than as a neutral film over it, and a tinted button
201
+ * presses through the same OKLab formula as a token one.
202
+ */
203
+ states: {
204
+ pressed: (_theme, colors) => ({ root: { backgroundColor: colors.bgPressed } }),
205
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
206
+ },
207
+ defaultVariants: { variant: "primary", size: "md" }
208
+ });
209
+
210
+ // src/components/button/button.utils.ts
211
+ import { Children, isValidElement } from "react";
212
+ function containsElementOfType(children, type) {
213
+ return Children.toArray(children).some(
214
+ (child) => isValidElement(child) && child.type === type
215
+ );
216
+ }
217
+
218
+ // src/components/button/button.tsx
219
+ import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
220
+ var ButtonRoot = forwardRef2(function Button({
221
+ children,
222
+ variant,
223
+ size,
224
+ radius,
225
+ color,
226
+ isDisabled = false,
227
+ isLoading = false,
228
+ isIconOnly = false,
229
+ asChild = false,
230
+ accessibilityRole = "button",
231
+ accessibilityState,
232
+ style,
233
+ onPressIn,
234
+ onPressOut,
235
+ ...props
236
+ }, ref) {
237
+ const theme = useXAUITheme();
238
+ const [styleProps, rest] = useStyleProps(props);
239
+ const [isPressed, press] = usePressState({ onPressIn, onPressOut });
240
+ const selection = {
241
+ variant,
242
+ size,
243
+ radius,
244
+ isIconOnly: isIconOnly ? "true" : void 0
245
+ };
246
+ const states = { pressed: isPressed, disabled: isDisabled || isLoading };
247
+ const styles = buttonRecipe.resolve({ theme, selection, states });
248
+ const tint = color ? buttonRecipe.tint({ theme, color, selection, states }) : void 0;
249
+ const context = useMemo(() => {
250
+ const icon = StyleSheet.flatten([styles.icon, tint?.icon]);
251
+ return {
252
+ labelStyle: tint ? [styles.label, tint.label] : styles.label,
253
+ spinnerStyle: tint ? [styles.spinner, tint.spinner] : styles.spinner,
254
+ icon: {
255
+ size: icon.fontSize,
256
+ // `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
257
+ // hand to a third-party component expecting a string.
258
+ color: typeof icon.color === "string" ? icon.color : void 0
259
+ },
260
+ isDisabled,
261
+ isLoading
262
+ };
263
+ }, [styles, tint, isDisabled, isLoading]);
264
+ const rootStyle = [
265
+ styles.root,
266
+ tint?.root,
267
+ styleProps,
268
+ typeof style === "function" ? style({ pressed: isPressed }) : style
269
+ ];
270
+ const text = childrenToString(children);
271
+ const showSpinner = isLoading && !containsElementOfType(children, ButtonSpinner);
272
+ if (isIconOnly && !rest.accessibilityLabel && !rest["aria-label"]) {
273
+ warnDev(
274
+ "Button: an icon-only button needs an `accessibilityLabel` \u2014 there is no text for a screen reader to read, so it announces as an unlabelled button."
275
+ );
276
+ }
277
+ return /* @__PURE__ */ jsx4(ButtonProvider, { value: context, children: /* @__PURE__ */ jsx4(
278
+ PressableFeedback,
279
+ {
280
+ ref,
281
+ isPressed,
282
+ isDisabled: isDisabled || isLoading,
283
+ asChild,
284
+ accessibilityRole,
285
+ accessibilityState: {
286
+ disabled: isDisabled,
287
+ busy: isLoading,
288
+ ...accessibilityState
289
+ },
290
+ ...rest,
291
+ style: rootStyle,
292
+ onPressIn: press.onPressIn,
293
+ onPressOut: press.onPressOut,
294
+ children: asChild ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
295
+ showSpinner ? /* @__PURE__ */ jsx4(ButtonSpinner, {}) : null,
296
+ text !== null ? /* @__PURE__ */ jsx4(ButtonLabel, { children: text }) : children
297
+ ] })
298
+ }
299
+ ) });
300
+ });
301
+ ButtonRoot.displayName = "XAUI.Button.Root";
302
+
303
+ // src/components/button/index.ts
304
+ var Button2 = Object.assign(ButtonRoot, {
305
+ Label: ButtonLabel,
306
+ Icon: ButtonIcon,
307
+ Spinner: ButtonSpinner
308
+ });
309
+
310
+ export {
311
+ useButton,
312
+ buttonRecipe,
313
+ Button2 as Button
314
+ };
@@ -0,0 +1,366 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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
+
3
+
4
+ var _chunkTGZZ3RZUcjs = require('./chunk-TGZZ3RZU.cjs');
5
+
6
+
7
+ var _chunkWR7YLDVVcjs = require('./chunk-WR7YLDVV.cjs');
8
+
9
+
10
+
11
+ var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
12
+
13
+
14
+ var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
15
+
16
+
17
+
18
+
19
+ var _chunkZP2E2H2Gcjs = require('./chunk-ZP2E2H2G.cjs');
20
+
21
+
22
+ var _chunkGLGU2WFLcjs = require('./chunk-GLGU2WFL.cjs');
23
+
24
+ // src/components/alert/alert-close.tsx
25
+ var _react = require('react');
26
+
27
+ // src/components/alert/alert.context.ts
28
+ var [AlertProvider, useAlert] = _chunkZP2E2H2Gcjs.createSlotContext.call(void 0, "Alert");
29
+
30
+ // src/components/alert/alert-close.tsx
31
+ var _jsxruntime = require('react/jsx-runtime');
32
+ var AlertClose = _react.forwardRef.call(void 0, function AlertClose2({ isDisabled, ...props }, ref) {
33
+ const { closeStyle, closeGlyphStyle, isDisabled: isAlertDisabled } = useAlert();
34
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
35
+ _chunkTGZZ3RZUcjs.CloseButton,
36
+ {
37
+ ref,
38
+ name: "Alert.Close",
39
+ baseStyle: closeStyle,
40
+ glyphStyle: closeGlyphStyle,
41
+ isDisabled: _nullishCoalesce(isDisabled, () => ( isAlertDisabled)),
42
+ ...props
43
+ }
44
+ );
45
+ });
46
+ AlertClose.displayName = "XAUI.Alert.Close";
47
+
48
+ // src/components/alert/alert-content.tsx
49
+
50
+ var _reactnative = require('react-native');
51
+
52
+ var AlertContent = _react.forwardRef.call(void 0,
53
+ function AlertContent2({ children, style, ...props }, ref) {
54
+ const { contentStyle } = useAlert();
55
+ const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
56
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, style: [contentStyle, styleProps, style], ...rest, children });
57
+ }
58
+ );
59
+ AlertContent.displayName = "XAUI.Alert.Content";
60
+
61
+ // src/components/alert/alert-description.tsx
62
+
63
+
64
+
65
+ var AlertDescription = _react.forwardRef.call(void 0,
66
+ function AlertDescription2({ children, style, ...props }, ref) {
67
+ const { descriptionStyle } = useAlert();
68
+ const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
69
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, style: [descriptionStyle, styleProps, style], ...rest, children });
70
+ }
71
+ );
72
+ AlertDescription.displayName = "XAUI.Alert.Description";
73
+
74
+ // src/components/alert/alert-icon.tsx
75
+
76
+
77
+
78
+ var AlertIcon = _react.forwardRef.call(void 0, function AlertIcon2({ as, children, source, size, color, style, ...props }, ref) {
79
+ const { iconStyle, icon } = useAlert();
80
+ const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
81
+ const glyphSize = _nullishCoalesce(size, () => ( icon.size));
82
+ const glyphColor = _nullishCoalesce(color, () => ( icon.color));
83
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, style: [iconStyle, styleProps, style], ...rest, children: as ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWR7YLDVVcjs.Icon, { as, size: glyphSize, color: glyphColor }) : source ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWR7YLDVVcjs.Icon, { source, size: glyphSize, color: glyphColor }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWR7YLDVVcjs.Icon, { size: glyphSize, color: glyphColor, children }) });
84
+ });
85
+ AlertIcon.displayName = "XAUI.Alert.Icon";
86
+
87
+ // src/components/alert/alert-title.tsx
88
+
89
+
90
+
91
+ var AlertTitle = _react.forwardRef.call(void 0, function AlertTitle2({ children, style, ...props }, ref) {
92
+ const { titleStyle } = useAlert();
93
+ const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
94
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, style: [titleStyle, styleProps, style], ...rest, children });
95
+ });
96
+ AlertTitle.displayName = "XAUI.Alert.Title";
97
+
98
+ // src/components/alert/alert.tsx
99
+
100
+
101
+
102
+ // src/components/alert/alert.recipe.ts
103
+ var SLOTS = [
104
+ "root",
105
+ "icon",
106
+ "iconGlyph",
107
+ "content",
108
+ "title",
109
+ "description",
110
+ "close",
111
+ "closeGlyph"
112
+ ];
113
+ var VARIANT_TOKENS = {
114
+ default: { bg: "surface", fg: "surfaceForeground" },
115
+ primary: { bg: "accent", fg: "accentForeground" },
116
+ secondary: { bg: "accentSoft", fg: "accentSoftForeground" },
117
+ success: { bg: "success", fg: "successForeground" },
118
+ "success-soft": { bg: "successSoft", fg: "successSoftForeground" },
119
+ warning: { bg: "warning", fg: "warningForeground" },
120
+ "warning-soft": { bg: "warningSoft", fg: "warningSoftForeground" },
121
+ danger: { bg: "danger", fg: "dangerForeground" },
122
+ "danger-soft": { bg: "dangerSoft", fg: "dangerSoftForeground" }
123
+ };
124
+ var DESCRIPTION_OPACITY = 0.6;
125
+ function sizeAxis(step) {
126
+ const { padding, gap, contentGap, title, description, glyph, cross, radius } = step;
127
+ return (theme) => ({
128
+ root: {
129
+ padding: theme.spacing(padding),
130
+ gap: theme.spacing(gap),
131
+ borderRadius: theme.radius[radius]
132
+ },
133
+ icon: { paddingTop: (theme.lineHeights[title] - theme.fontSizes[glyph]) / 2 },
134
+ iconGlyph: { fontSize: theme.fontSizes[glyph] },
135
+ content: { gap: theme.spacing(contentGap) },
136
+ title: {
137
+ fontSize: theme.fontSizes[title],
138
+ lineHeight: theme.lineHeights[title]
139
+ },
140
+ description: {
141
+ fontSize: theme.fontSizes[description],
142
+ lineHeight: theme.lineHeights[description]
143
+ },
144
+ // The touch target is the glyph's box; the shared `CloseButton` grows it outwards
145
+ // with `hitSlop`, because a cross big enough to hit is a cross too big to look right.
146
+ close: { width: theme.fontSizes[glyph], height: theme.fontSizes[glyph] },
147
+ closeGlyph: { width: theme.spacing(cross) }
148
+ });
149
+ }
150
+ var SIZES = {
151
+ xs: {
152
+ padding: 2,
153
+ gap: 2,
154
+ contentGap: 0.5,
155
+ title: "xs",
156
+ description: "xs",
157
+ glyph: "sm",
158
+ cross: 2,
159
+ radius: "lg"
160
+ },
161
+ sm: {
162
+ padding: 2.5,
163
+ gap: 2.5,
164
+ contentGap: 0.5,
165
+ title: "sm",
166
+ description: "xs",
167
+ glyph: "md",
168
+ cross: 2,
169
+ radius: "xl"
170
+ },
171
+ md: {
172
+ padding: 3,
173
+ gap: 3,
174
+ contentGap: 1,
175
+ title: "md",
176
+ description: "sm",
177
+ glyph: "lg",
178
+ cross: 2.5,
179
+ radius: "2xl"
180
+ },
181
+ lg: {
182
+ padding: 4,
183
+ gap: 3.5,
184
+ contentGap: 1,
185
+ title: "lg",
186
+ description: "md",
187
+ glyph: "xl",
188
+ cross: 3,
189
+ radius: "3xl"
190
+ }
191
+ };
192
+ var alertRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
193
+ slots: SLOTS,
194
+ // The cross's own geometry — thickness and centring — belongs to the shared
195
+ // `CloseButton`; what stays below is the box and bar size this component's scale sets.
196
+ base: (theme) => ({
197
+ ..._chunkTGZZ3RZUcjs.closeButtonBase.call(void 0, theme),
198
+ root: {
199
+ flexDirection: "row",
200
+ // Top-aligned, not centred: an alert's message can run to three lines, and an icon
201
+ // floating beside the middle of a paragraph reads as decoration rather than as the
202
+ // mark of what the paragraph is. A single-line alert centres itself with
203
+ // `alignItems="center"` on the root — one prop, and it is the caller's call.
204
+ alignItems: "flex-start",
205
+ borderWidth: 0,
206
+ // iOS's squircle. Free on Android, and it is what makes a radius this large read as
207
+ // a shape rather than as four arcs meeting straight edges.
208
+ borderCurve: "continuous"
209
+ // Deliberately no `overflow: 'hidden'`: on iOS it clips the node's own shadow, so a
210
+ // `default` alert would lose the elevation the variant just gave it.
211
+ },
212
+ // `flex: 1` and not `flexGrow`: the root is a row, so the content has to be measured
213
+ // from a zero basis to take exactly what the icon and the close leave — the opposite
214
+ // of the `Card`'s body, which grows in a column where a zero basis collapses it.
215
+ content: { flex: 1 },
216
+ // `medium`, not `semibold`. An alert's title sits in prose rather than on a control:
217
+ // one weight above the description is enough to rank them.
218
+ title: {
219
+ fontFamily: theme.fontFamilies.heading,
220
+ fontWeight: theme.fontWeights.medium
221
+ },
222
+ description: {
223
+ fontFamily: theme.fontFamilies.body,
224
+ fontWeight: theme.fontWeights.regular,
225
+ opacity: DESCRIPTION_OPACITY
226
+ }
227
+ }),
228
+ variantTokens: VARIANT_TOKENS,
229
+ /**
230
+ * Where the variant's colours land, for every variant at once.
231
+ *
232
+ * The icon takes the **title's** colour rather than a status colour of its own — on a
233
+ * `danger` alert the readable colour is the one the title already uses, and on a
234
+ * `danger-soft` one that token *is* the red. HeroUI arrives at the same place from the
235
+ * other direction, colouring the icon by status on a neutral surface; here the variant
236
+ * decides both, and an icon that has to disagree with its alert says so itself with
237
+ * `<Alert.Icon color={…} />`.
238
+ */
239
+ paint: (theme, colors) => ({
240
+ root: {
241
+ backgroundColor: colors.bg,
242
+ borderColor: colors.border,
243
+ borderWidth: colors.border ? theme.borderWidth.default : 0
244
+ },
245
+ iconGlyph: { color: colors.fg },
246
+ title: { color: colors.fg },
247
+ description: { color: colors.fg },
248
+ closeGlyph: { backgroundColor: colors.fg }
249
+ }),
250
+ /** Declaration order is application order: `radius` overrides the radius `size` set. */
251
+ variants: {
252
+ size: {
253
+ xs: sizeAxis(SIZES.xs),
254
+ sm: sizeAxis(SIZES.sm),
255
+ md: sizeAxis(SIZES.md),
256
+ lg: sizeAxis(SIZES.lg)
257
+ },
258
+ radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "root")
259
+ },
260
+ /**
261
+ * The elevation belongs to the one variant that is a surface standing on the background,
262
+ * exactly as on the `Card`. A tinted alert already separates itself by its fill, and a
263
+ * shadow under it would read as dirt. In dark mode the theme's `surface` shadow is
264
+ * already nothing (§4), which is why this names the role instead of a set of numbers.
265
+ */
266
+ compoundVariants: [
267
+ {
268
+ when: { variant: "default" },
269
+ style: (theme) => ({ root: theme.shadows.surface })
270
+ }
271
+ ],
272
+ states: {
273
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
274
+ },
275
+ defaultVariants: { variant: "default", size: "md" }
276
+ });
277
+
278
+ // src/components/alert/alert.tsx
279
+
280
+ var AlertRoot = _react.forwardRef.call(void 0, function Alert({
281
+ children,
282
+ variant,
283
+ size,
284
+ radius,
285
+ color,
286
+ isDisabled = false,
287
+ asChild = false,
288
+ accessibilityRole = "alert",
289
+ // Android reads a live region aloud when its content changes, which is what makes an
290
+ // alert that *appears* announce itself instead of waiting to be found. `'polite'`
291
+ // rather than `'assertive'`: it queues behind whatever is being read instead of
292
+ // cutting it off. A static alert that is part of the page sets `'none'`.
293
+ accessibilityLiveRegion = "polite",
294
+ style,
295
+ ...props
296
+ }, ref) {
297
+ const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
298
+ const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
299
+ const selection = { variant, size, radius };
300
+ const states = { disabled: isDisabled };
301
+ const styles = alertRecipe.resolve({ theme, selection, states });
302
+ const tint = color ? alertRecipe.tint({ theme, color, selection, states }) : void 0;
303
+ const context = _react.useMemo.call(void 0, () => {
304
+ const glyph = _reactnative.StyleSheet.flatten([styles.iconGlyph, _optionalChain([tint, 'optionalAccess', _ => _.iconGlyph])]);
305
+ return {
306
+ iconStyle: styles.icon,
307
+ contentStyle: styles.content,
308
+ titleStyle: tint ? [styles.title, tint.title] : styles.title,
309
+ descriptionStyle: tint ? [styles.description, tint.description] : styles.description,
310
+ closeStyle: styles.close,
311
+ closeGlyphStyle: tint ? [styles.closeGlyph, tint.closeGlyph] : styles.closeGlyph,
312
+ icon: {
313
+ size: glyph.fontSize,
314
+ // `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
315
+ // hand to a third-party component expecting a string.
316
+ color: typeof glyph.color === "string" ? glyph.color : void 0
317
+ },
318
+ isDisabled
319
+ };
320
+ }, [styles, tint, isDisabled]);
321
+ const rootStyle = [styles.root, _optionalChain([tint, 'optionalAccess', _2 => _2.root]), styleProps, style];
322
+ const text = _chunkZP2E2H2Gcjs.childrenToString.call(void 0, children);
323
+ const content = text !== null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertDescription, { children: text }) : children;
324
+ const surface = asChild ? (
325
+ // R12 — the caller's element *is* the alert, so it takes the children it was written
326
+ // with and the auto-wrap does not apply.
327
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
328
+ _chunkZP2E2H2Gcjs.Slot,
329
+ {
330
+ ref,
331
+ accessibilityRole,
332
+ accessibilityLiveRegion,
333
+ ...rest,
334
+ style: rootStyle,
335
+ children
336
+ }
337
+ )
338
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
339
+ _reactnative.View,
340
+ {
341
+ ref,
342
+ accessibilityRole,
343
+ accessibilityLiveRegion,
344
+ ...rest,
345
+ style: rootStyle,
346
+ children: content
347
+ }
348
+ );
349
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertProvider, { value: context, children: surface });
350
+ });
351
+ AlertRoot.displayName = "XAUI.Alert.Root";
352
+
353
+ // src/components/alert/index.ts
354
+ var Alert2 = Object.assign(AlertRoot, {
355
+ Icon: AlertIcon,
356
+ Content: AlertContent,
357
+ Title: AlertTitle,
358
+ Description: AlertDescription,
359
+ Close: AlertClose
360
+ });
361
+
362
+
363
+
364
+
365
+
366
+ exports.useAlert = useAlert; exports.alertRecipe = alertRecipe; exports.Alert = Alert2;