@xaui/native 0.9.1-alpha.26 → 0.9.1-alpha.28

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 (57) hide show
  1. package/dist/chunk-3YN7JQ55.js +342 -0
  2. package/dist/{chunk-PQHC65AG.js → chunk-56KVKM27.js} +15 -15
  3. package/dist/chunk-5A4M6X5B.cjs +289 -0
  4. package/dist/{chunk-BULNTP5N.cjs → chunk-63TWVWHG.cjs} +9 -45
  5. package/dist/chunk-7EIHHOHP.cjs +42 -0
  6. package/dist/{chunk-WVCAFORA.cjs → chunk-CQRUNV6S.cjs} +15 -15
  7. package/dist/chunk-E6EFYPJR.cjs +41 -0
  8. package/dist/chunk-EYJEUXXC.js +98 -0
  9. package/dist/chunk-F6W3JQ7K.js +42 -0
  10. package/dist/chunk-LKB3RIR2.js +289 -0
  11. package/dist/{chunk-I6UCYAO2.js → chunk-N4UJYDOW.js} +23 -56
  12. package/dist/chunk-V6DGGDHF.cjs +342 -0
  13. package/dist/components/alert/index.cjs +1 -1
  14. package/dist/components/alert/index.d.cts +1 -1
  15. package/dist/components/alert/index.d.ts +1 -1
  16. package/dist/components/alert/index.js +1 -1
  17. package/dist/components/button/index.cjs +3 -3
  18. package/dist/components/button/index.d.cts +1 -1
  19. package/dist/components/button/index.d.ts +1 -1
  20. package/dist/components/button/index.js +2 -2
  21. package/dist/components/card/index.d.cts +1 -1
  22. package/dist/components/card/index.d.ts +1 -1
  23. package/dist/components/checkbox/index.cjs +24 -0
  24. package/dist/components/checkbox/index.d.cts +1136 -0
  25. package/dist/components/checkbox/index.d.ts +1136 -0
  26. package/dist/components/checkbox/index.js +24 -0
  27. package/dist/components/chip/index.cjs +3 -3
  28. package/dist/components/chip/index.d.cts +1 -1
  29. package/dist/components/chip/index.d.ts +1 -1
  30. package/dist/components/chip/index.js +2 -2
  31. package/dist/components/input/index.d.cts +3 -3
  32. package/dist/components/input/index.d.ts +3 -3
  33. package/dist/components/input-otp/index.cjs +3 -2
  34. package/dist/components/input-otp/index.d.cts +3 -3
  35. package/dist/components/input-otp/index.d.ts +3 -3
  36. package/dist/components/input-otp/index.js +2 -1
  37. package/dist/components/radio/index.cjs +24 -0
  38. package/dist/components/radio/index.d.cts +1102 -0
  39. package/dist/components/radio/index.d.ts +1102 -0
  40. package/dist/components/radio/index.js +24 -0
  41. package/dist/components/typography/index.d.cts +1 -1
  42. package/dist/components/typography/index.d.ts +1 -1
  43. package/dist/{create-recipe-dBN_ewZc.d.cts → create-recipe-CWvI5ot3.d.cts} +8 -1
  44. package/dist/{create-recipe-C4JkINrA.d.ts → create-recipe-DUo8doTt.d.ts} +8 -1
  45. package/dist/index.cjs +45 -11
  46. package/dist/index.d.cts +4 -2
  47. package/dist/index.d.ts +4 -2
  48. package/dist/index.js +50 -16
  49. package/dist/system/index.cjs +7 -3
  50. package/dist/system/index.d.cts +36 -3
  51. package/dist/system/index.d.ts +36 -3
  52. package/dist/system/index.js +6 -2
  53. package/package.json +21 -1
  54. package/dist/{chunk-3WISQT22.js → chunk-EHARM2EN.js} +3 -3
  55. package/dist/{chunk-I7G77Q65.cjs → chunk-H7DVR52Z.cjs} +2 -2
  56. /package/dist/{chunk-6HXWQ5AU.cjs → chunk-VZGBEGDV.cjs} +0 -0
  57. /package/dist/{chunk-AKXG43S4.js → chunk-Y4BPKSD3.js} +0 -0
@@ -0,0 +1,342 @@
1
+ import {
2
+ useControllableState
3
+ } from "./chunk-F6W3JQ7K.js";
4
+ import {
5
+ SelectionFill
6
+ } from "./chunk-EYJEUXXC.js";
7
+ import {
8
+ PressableFeedback,
9
+ usePressState
10
+ } from "./chunk-4HELPMAK.js";
11
+ import {
12
+ createRecipe,
13
+ radiusAxis
14
+ } from "./chunk-3JATAB7S.js";
15
+ import {
16
+ childrenToString,
17
+ createSlotContext,
18
+ useStyleProps
19
+ } from "./chunk-PMO62QK4.js";
20
+ import {
21
+ useXAUITheme
22
+ } from "./chunk-A3EGFI6T.js";
23
+
24
+ // src/components/checkbox/checkbox-indicator.tsx
25
+ import { forwardRef } from "react";
26
+ import { View } from "react-native";
27
+
28
+ // src/components/checkbox/checkbox.context.ts
29
+ var [CheckboxProvider, useCheckbox] = createSlotContext("Checkbox");
30
+
31
+ // src/components/checkbox/checkbox-indicator.tsx
32
+ import { jsx } from "react/jsx-runtime";
33
+ var CheckboxIndicator = forwardRef(
34
+ function CheckboxIndicator2({ children, animation = true, style, ...props }, ref) {
35
+ const { indicatorStyle, fillStyle, isSelected, isIndeterminate } = useCheckbox();
36
+ const [styleProps, rest] = useStyleProps(props);
37
+ const isFilled = isSelected || isIndeterminate;
38
+ const mark = children ?? (isIndeterminate ? /* @__PURE__ */ jsx(Dash, {}) : /* @__PURE__ */ jsx(Check, {}));
39
+ return /* @__PURE__ */ jsx(View, { ref, ...rest, style: [indicatorStyle, styleProps, style], children: /* @__PURE__ */ jsx(SelectionFill, { isVisible: isFilled, style: fillStyle, animation, children: mark }) });
40
+ }
41
+ );
42
+ CheckboxIndicator.displayName = "XAUI.Checkbox.Indicator";
43
+ function Check() {
44
+ const { checkStyle } = useCheckbox();
45
+ return /* @__PURE__ */ jsx(View, { style: checkStyle });
46
+ }
47
+ function Dash() {
48
+ const { dashStyle } = useCheckbox();
49
+ return /* @__PURE__ */ jsx(View, { style: dashStyle });
50
+ }
51
+
52
+ // src/components/checkbox/checkbox-label.tsx
53
+ import { forwardRef as forwardRef2 } from "react";
54
+ import { Text } from "react-native";
55
+ import { jsx as jsx2 } from "react/jsx-runtime";
56
+ var CheckboxLabel = forwardRef2(
57
+ function CheckboxLabel2({ children, style, ...props }, ref) {
58
+ const { labelStyle } = useCheckbox();
59
+ const [styleProps, rest] = useStyleProps(props);
60
+ return /* @__PURE__ */ jsx2(Text, { ref, style: [labelStyle, styleProps, style], ...rest, children });
61
+ }
62
+ );
63
+ CheckboxLabel.displayName = "XAUI.Checkbox.Label";
64
+
65
+ // src/components/checkbox/checkbox.tsx
66
+ import { forwardRef as forwardRef3, useCallback, useMemo } from "react";
67
+
68
+ // src/components/checkbox/checkbox.recipe.ts
69
+ var SLOTS = ["root", "indicator", "fill", "check", "dash", "label"];
70
+ var VARIANT_TOKENS = {
71
+ primary: {
72
+ bg: "fieldBackground",
73
+ border: "fieldBorder",
74
+ bgSelected: "accent",
75
+ fgSelected: "accentForeground"
76
+ },
77
+ // `bg: 'default'` is the neutral *token*, not this variant's name — the two namespaces
78
+ // meet here as they do on the `Input`, and for the same reason: on a card,
79
+ // `fieldBackground` is the card's own colour and the box would vanish into it.
80
+ secondary: {
81
+ bg: "default",
82
+ border: "fieldBorder",
83
+ bgSelected: "accent",
84
+ fgSelected: "accentForeground"
85
+ },
86
+ tertiary: {
87
+ border: "fieldBorder",
88
+ bgSelected: "accent",
89
+ fgSelected: "accentForeground"
90
+ }
91
+ };
92
+ function sizeAxis(step) {
93
+ const { box, radius, label, gap, stroke } = step;
94
+ return (theme) => {
95
+ const side = theme.spacing(box);
96
+ return {
97
+ root: { gap: theme.spacing(gap) },
98
+ indicator: { width: side, height: side, borderRadius: theme.radius[radius] },
99
+ check: {
100
+ width: side * CHECK_WIDTH,
101
+ height: side * CHECK_HEIGHT,
102
+ borderStartWidth: stroke,
103
+ borderBottomWidth: stroke,
104
+ // An "L" has its ink in one corner, not in the middle of its box, so rotating it
105
+ // about that box's centre leaves the tick sitting low. Rotating by −45° maps a
106
+ // point to `(dy − dx)·√2/2`, and over the two strokes that spans `H` at the top
107
+ // and `H − t − W` at the bottom — an ink centre `(H − t)·√2/4` **below** the box
108
+ // centre, which flexbox then dutifully centres. Lifting by exactly that is what
109
+ // makes the mark look centred rather than measure centred.
110
+ //
111
+ // Both transforms live here, and not half here and half in a sheet, because
112
+ // `transform` is a whole value: the recipe's merge replaces it rather than
113
+ // blending, so a second step would drop the first.
114
+ transform: [
115
+ { translateY: -((side * CHECK_HEIGHT - stroke) * Math.SQRT2) / 4 },
116
+ { rotate: "-45deg" }
117
+ ]
118
+ },
119
+ // The third state's mark: the check's long stroke, on its own and level.
120
+ dash: {
121
+ width: side * CHECK_WIDTH,
122
+ height: stroke,
123
+ borderRadius: stroke / 2
124
+ },
125
+ label: {
126
+ fontSize: theme.fontSizes[label],
127
+ lineHeight: theme.lineHeights[label]
128
+ }
129
+ };
130
+ };
131
+ }
132
+ var CHECK_WIDTH = 0.5;
133
+ var CHECK_HEIGHT = 0.25;
134
+ var SIZES = {
135
+ sm: { box: 5, radius: "sm", gap: 2, label: "sm", stroke: 2 },
136
+ md: { box: 6, radius: "md", gap: 2, label: "md", stroke: 2 },
137
+ lg: { box: 7, radius: "md", gap: 2.5, label: "lg", stroke: 2.5 }
138
+ };
139
+ var checkboxRecipe = createRecipe({
140
+ slots: SLOTS,
141
+ base: (theme) => ({
142
+ root: { flexDirection: "row", alignItems: "center", alignSelf: "flex-start" },
143
+ indicator: {
144
+ alignItems: "center",
145
+ justifyContent: "center",
146
+ borderWidth: theme.borderWidth.field,
147
+ borderCurve: "continuous",
148
+ // The fill is laid inside the box and has to stop at its corners.
149
+ overflow: "hidden"
150
+ },
151
+ // Laid over the box rather than sized to it: the two corners are the indicator's, and
152
+ // an inset of zero is what keeps the fill inside the border it is clipped by.
153
+ fill: {
154
+ position: "absolute",
155
+ top: 0,
156
+ bottom: 0,
157
+ start: 0,
158
+ end: 0,
159
+ alignItems: "center",
160
+ justifyContent: "center"
161
+ },
162
+ label: {
163
+ fontFamily: theme.fontFamilies.body,
164
+ color: theme.colors.foreground
165
+ }
166
+ }),
167
+ variantTokens: VARIANT_TOKENS,
168
+ /**
169
+ * Where the variant's colours land. The border width follows the *presence* of the
170
+ * border role, exactly as on the `Input`.
171
+ *
172
+ * `bgSelected` and `fgSelected` are painted unconditionally, on two slots the indicator
173
+ * only mounts while it is ticked — which is what keeps selection out of the cache key
174
+ * and inside the tint pass at the same time. An axis would have given up the second.
175
+ */
176
+ paint: (theme, colors) => ({
177
+ indicator: {
178
+ backgroundColor: colors.bg,
179
+ borderColor: colors.border,
180
+ borderWidth: colors.border ? theme.borderWidth.field : 0
181
+ },
182
+ fill: { backgroundColor: colors.bgSelected },
183
+ check: { borderColor: colors.fgSelected },
184
+ dash: { backgroundColor: colors.fgSelected }
185
+ }),
186
+ variants: {
187
+ size: {
188
+ sm: sizeAxis(SIZES.sm),
189
+ md: sizeAxis(SIZES.md),
190
+ lg: sizeAxis(SIZES.lg)
191
+ },
192
+ radius: radiusAxis("indicator"),
193
+ /**
194
+ * Declared after `size` so its border wins. The resting fill is dropped rather than
195
+ * repainted — `undefined` over a colour is what RN reads as "no background" — because
196
+ * a box that is wrong should read as an outline, not as a filled control that happens
197
+ * to be red at the edge. HeroUI reaches the same shape with a compound.
198
+ */
199
+ isInvalid: {
200
+ true: (theme) => ({
201
+ indicator: { borderColor: theme.colors.danger, backgroundColor: void 0 },
202
+ fill: { backgroundColor: theme.colors.danger },
203
+ check: { borderColor: theme.colors.dangerForeground },
204
+ dash: { backgroundColor: theme.colors.dangerForeground },
205
+ // The label turns with it: on a long form the field that is wrong has to be
206
+ // findable without reading every message.
207
+ label: { color: theme.colors.danger }
208
+ })
209
+ }
210
+ },
211
+ /** What `primary` adds to a filled box — the `Input`'s compound, on a smaller field. */
212
+ compoundVariants: [
213
+ {
214
+ when: { variant: "primary" },
215
+ style: (theme) => ({ indicator: theme.shadows.field })
216
+ }
217
+ ],
218
+ states: {
219
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
220
+ },
221
+ defaultVariants: { variant: "secondary", size: "md" }
222
+ });
223
+
224
+ // src/components/checkbox/checkbox.tsx
225
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
226
+ var CheckboxRoot = forwardRef3(function Checkbox({
227
+ children,
228
+ variant,
229
+ size,
230
+ radius,
231
+ color,
232
+ isSelected,
233
+ defaultSelected = false,
234
+ onSelectedChange,
235
+ isIndeterminate = false,
236
+ isInvalid = false,
237
+ isDisabled = false,
238
+ asChild = false,
239
+ accessibilityRole,
240
+ accessibilityState,
241
+ animation,
242
+ style,
243
+ onPress,
244
+ onPressIn,
245
+ onPressOut,
246
+ ...props
247
+ }, ref) {
248
+ const theme = useXAUITheme();
249
+ const [styleProps, rest] = useStyleProps(props);
250
+ const [isPressed, press] = usePressState({ onPressIn, onPressOut });
251
+ const [selected, setSelected] = useControllableState({
252
+ value: isSelected,
253
+ defaultValue: defaultSelected,
254
+ onChange: onSelectedChange
255
+ });
256
+ const handlePress = useCallback(
257
+ (event) => {
258
+ setSelected((current) => isIndeterminate ? true : !current);
259
+ onPress?.(event);
260
+ },
261
+ [setSelected, isIndeterminate, onPress]
262
+ );
263
+ const selection = {
264
+ variant,
265
+ size,
266
+ radius,
267
+ isInvalid: isInvalid ? "true" : void 0
268
+ };
269
+ const states = { pressed: isPressed, disabled: isDisabled };
270
+ const styles = checkboxRecipe.resolve({ theme, selection, states });
271
+ const tint = color && !isInvalid ? checkboxRecipe.tint({ theme, color, selection, states }) : void 0;
272
+ const context = useMemo(
273
+ () => ({
274
+ // The tint never reaches the box **at rest**, only the two nodes that say the box
275
+ // is ticked. `paint` writes the resting fill from `bg` and the tint pass re-runs
276
+ // `paint`, so applying `tint.indicator` here would paint an unticked box in the
277
+ // caller's brand colour — which reads as ticked, which is the one thing it is not.
278
+ indicatorStyle: styles.indicator,
279
+ fillStyle: tint ? [styles.fill, tint.fill] : styles.fill,
280
+ checkStyle: tint ? [styles.check, tint.check] : styles.check,
281
+ dashStyle: tint ? [styles.dash, tint.dash] : styles.dash,
282
+ labelStyle: styles.label,
283
+ isSelected: selected,
284
+ isIndeterminate,
285
+ isDisabled,
286
+ isInvalid
287
+ }),
288
+ [styles, tint, selected, isIndeterminate, isDisabled, isInvalid]
289
+ );
290
+ const rootStyle = [
291
+ styles.root,
292
+ tint?.root,
293
+ styleProps,
294
+ typeof style === "function" ? style({ pressed: isPressed }) : style
295
+ ];
296
+ const text = childrenToString(children);
297
+ const content = text !== null ? /* @__PURE__ */ jsxs(Fragment, { children: [
298
+ /* @__PURE__ */ jsx3(CheckboxIndicator, {}),
299
+ /* @__PURE__ */ jsx3(CheckboxLabel, { children: text })
300
+ ] }) : children ?? /* @__PURE__ */ jsx3(CheckboxIndicator, {});
301
+ return /* @__PURE__ */ jsx3(CheckboxProvider, { value: context, children: /* @__PURE__ */ jsx3(
302
+ PressableFeedback,
303
+ {
304
+ ref,
305
+ isPressed,
306
+ isDisabled,
307
+ asChild,
308
+ animation,
309
+ accessibilityRole: accessibilityRole ?? "checkbox",
310
+ accessibilityState: {
311
+ // `'mixed'` is the platform's own word for the third state, and it is the only
312
+ // thing that tells a screen reader this box speaks for rows it cannot see.
313
+ checked: isIndeterminate ? "mixed" : selected,
314
+ disabled: isDisabled,
315
+ ...accessibilityState
316
+ },
317
+ "aria-invalid": isInvalid,
318
+ ...rest,
319
+ style: rootStyle,
320
+ onPress: handlePress,
321
+ onPressIn: press.onPressIn,
322
+ onPressOut: press.onPressOut,
323
+ children: asChild ? children : content
324
+ }
325
+ ) });
326
+ });
327
+ CheckboxRoot.displayName = "XAUI.Checkbox.Root";
328
+
329
+ // src/components/checkbox/index.ts
330
+ var Checkbox2 = Object.assign(CheckboxRoot, {
331
+ Indicator: CheckboxIndicator,
332
+ Label: CheckboxLabel
333
+ });
334
+
335
+ export {
336
+ useCheckbox,
337
+ CheckboxIndicator,
338
+ CheckboxLabel,
339
+ checkboxRecipe,
340
+ CheckboxRoot,
341
+ Checkbox2 as Checkbox
342
+ };
@@ -1,6 +1,6 @@
1
1
  import { PressableFeedback, usePressState } from "./chunk-4HELPMAK.js";
2
- import { Icon } from "./chunk-ICR42HHG.js";
3
2
  import { warnDev } from "./chunk-EGLLDKN6.js";
3
+ import { Icon } from "./chunk-ICR42HHG.js";
4
4
  import { createRecipe, radiusAxis } from "./chunk-3JATAB7S.js";
5
5
  import { childrenToString, createSlotContext, useStyleProps } from "./chunk-PMO62QK4.js";
6
6
  import { useXAUITheme } from "./chunk-A3EGFI6T.js";
@@ -74,10 +74,10 @@ function ButtonSpinner({
74
74
  });
75
75
  }
76
76
  ButtonSpinner.displayName = "XAUI.Button.Spinner";
77
- const _worklet_146491499400_init_data = {
78
- code: "function chunkPQHC65AGJs1(){const{angle}=this.__closure;return{transform:[{rotate:angle.value+\"deg\"}]};}",
79
- location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-PQHC65AG.js",
80
- sourceMap: "{\"version\":3,\"names\":[\"chunkPQHC65AGJs1\",\"angle\",\"__closure\",\"transform\",\"rotate\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-PQHC65AG.js\"],\"mappings\":\"AAqFyC,SAAAA,gBAAMA,CAAA,QAAAC,KAAA,OAAAC,SAAA,CAE3C,MAAO,CAAEC,SAAS,CAAE,CAAC,CAAEC,MAAM,CAAKH,KAAK,CAACI,KAAK,MAAM,CAAC,CAAE,CAAC,CACzD\",\"ignoreList\":[]}"
77
+ const _worklet_633469242714_init_data = {
78
+ code: "function chunk56KVKM27Js1(){const{angle}=this.__closure;return{transform:[{rotate:angle.value+\"deg\"}]};}",
79
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-56KVKM27.js",
80
+ sourceMap: "{\"version\":3,\"names\":[\"chunk56KVKM27Js1\",\"angle\",\"__closure\",\"transform\",\"rotate\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-56KVKM27.js\"],\"mappings\":\"AAqFyC,SAAAA,gBAAMA,CAAA,QAAAC,KAAA,OAAAC,SAAA,CAE3C,MAAO,CAAEC,SAAS,CAAE,CAAC,CAAEC,MAAM,CAAKH,KAAK,CAACI,KAAK,MAAM,CAAC,CAAE,CAAC,CACzD\",\"ignoreList\":[]}"
81
81
  };
82
82
  function SpinningRing({
83
83
  style
@@ -90,28 +90,28 @@ function SpinningRing({
90
90
  }), -1, false);
91
91
  return () => cancelAnimation(angle);
92
92
  }, [angle]);
93
- const animatedStyle = useAnimatedStyle(function chunkPQHC65AGJs1Factory({
94
- _worklet_146491499400_init_data,
93
+ const animatedStyle = useAnimatedStyle(function chunk56KVKM27Js1Factory({
94
+ _worklet_633469242714_init_data,
95
95
  angle
96
96
  }) {
97
97
  const _e = [new global.Error(), -2, -27];
98
- const chunkPQHC65AGJs1 = function () {
98
+ const chunk56KVKM27Js1 = function () {
99
99
  return {
100
100
  transform: [{
101
101
  rotate: `${angle.value}deg`
102
102
  }]
103
103
  };
104
104
  };
105
- chunkPQHC65AGJs1.__closure = {
105
+ chunk56KVKM27Js1.__closure = {
106
106
  angle
107
107
  };
108
- chunkPQHC65AGJs1.__workletHash = 146491499400;
109
- chunkPQHC65AGJs1.__pluginVersion = "0.7.4";
110
- chunkPQHC65AGJs1.__initData = _worklet_146491499400_init_data;
111
- chunkPQHC65AGJs1.__stackDetails = _e;
112
- return chunkPQHC65AGJs1;
108
+ chunk56KVKM27Js1.__workletHash = 633469242714;
109
+ chunk56KVKM27Js1.__pluginVersion = "0.7.4";
110
+ chunk56KVKM27Js1.__initData = _worklet_633469242714_init_data;
111
+ chunk56KVKM27Js1.__stackDetails = _e;
112
+ return chunk56KVKM27Js1;
113
113
  }({
114
- _worklet_146491499400_init_data,
114
+ _worklet_633469242714_init_data,
115
115
  angle
116
116
  }), [angle]);
117
117
  return /* @__PURE__ */jsx3(Animated.View, {
@@ -0,0 +1,289 @@
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
+ var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
4
+
5
+
6
+ var _chunkE6EFYPJRcjs = require('./chunk-E6EFYPJR.cjs');
7
+
8
+
9
+
10
+ var _chunkIG4Q3WQOcjs = require('./chunk-IG4Q3WQO.cjs');
11
+
12
+
13
+
14
+ var _chunkYXVKQMCKcjs = require('./chunk-YXVKQMCK.cjs');
15
+
16
+
17
+
18
+
19
+ var _chunkHUZ4AUM2cjs = require('./chunk-HUZ4AUM2.cjs');
20
+
21
+
22
+ var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
23
+
24
+ // src/components/radio/radio-indicator.tsx
25
+ var _react = require('react');
26
+ var _reactnative = require('react-native');
27
+
28
+ // src/components/radio/radio.context.ts
29
+ var [RadioProvider, useRadio] = _chunkHUZ4AUM2cjs.createSlotContext.call(void 0, "Radio");
30
+
31
+ // src/components/radio/radio-indicator.tsx
32
+ var _jsxruntime = require('react/jsx-runtime');
33
+ var RadioIndicator = _react.forwardRef.call(void 0,
34
+ function RadioIndicator2({ children, animation = true, style, ...props }, ref) {
35
+ const { indicatorStyle, fillStyle, isSelected } = useRadio();
36
+ const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
37
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, ...rest, style: [indicatorStyle, styleProps, style], children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
38
+ _chunkE6EFYPJRcjs.SelectionFill,
39
+ {
40
+ isVisible: isSelected,
41
+ style: fillStyle,
42
+ animation,
43
+ children: _nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Thumb, {})))
44
+ }
45
+ ) });
46
+ }
47
+ );
48
+ RadioIndicator.displayName = "XAUI.Radio.Indicator";
49
+ function Thumb() {
50
+ const { thumbStyle } = useRadio();
51
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: thumbStyle });
52
+ }
53
+
54
+ // src/components/radio/radio-label.tsx
55
+
56
+
57
+
58
+ var RadioLabel = _react.forwardRef.call(void 0, function RadioLabel2({ children, style, ...props }, ref) {
59
+ const { labelStyle } = useRadio();
60
+ const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
61
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, style: [labelStyle, styleProps, style], ...rest, children });
62
+ });
63
+ RadioLabel.displayName = "XAUI.Radio.Label";
64
+
65
+ // src/components/radio/radio.tsx
66
+
67
+
68
+ // src/components/radio/radio.recipe.ts
69
+ var SLOTS = ["root", "indicator", "fill", "thumb", "label"];
70
+ var VARIANT_TOKENS = {
71
+ primary: {
72
+ bg: "fieldBackground",
73
+ border: "fieldBorder",
74
+ bgSelected: "accent",
75
+ fgSelected: "accentForeground"
76
+ },
77
+ secondary: {
78
+ bg: "default",
79
+ border: "fieldBorder",
80
+ bgSelected: "accent",
81
+ fgSelected: "accentForeground"
82
+ },
83
+ tertiary: {
84
+ border: "fieldBorder",
85
+ bgSelected: "accent",
86
+ fgSelected: "accentForeground"
87
+ }
88
+ };
89
+ function sizeAxis(step) {
90
+ const { box, label, gap } = step;
91
+ return (theme) => {
92
+ const side = theme.spacing(box);
93
+ const dot = Math.round(side * THUMB_RATIO);
94
+ return {
95
+ root: { gap: theme.spacing(gap) },
96
+ indicator: { width: side, height: side },
97
+ thumb: { width: dot, height: dot, borderRadius: dot / 2 },
98
+ label: {
99
+ fontSize: theme.fontSizes[label],
100
+ lineHeight: theme.lineHeights[label]
101
+ }
102
+ };
103
+ };
104
+ }
105
+ var THUMB_RATIO = 10 / 24;
106
+ var SIZES = {
107
+ sm: { box: 5, gap: 2, label: "sm" },
108
+ md: { box: 6, gap: 2, label: "md" },
109
+ lg: { box: 7, gap: 2.5, label: "lg" }
110
+ };
111
+ var radioRecipe = _chunkYXVKQMCKcjs.createRecipe.call(void 0, {
112
+ slots: SLOTS,
113
+ base: (theme) => ({
114
+ root: { flexDirection: "row", alignItems: "center", alignSelf: "flex-start" },
115
+ indicator: {
116
+ alignItems: "center",
117
+ justifyContent: "center",
118
+ borderWidth: theme.borderWidth.field,
119
+ // The one shape decision this component makes, and the whole difference between it
120
+ // and the `Checkbox`: a radio is round, at every size. `radius` still overrides it.
121
+ borderRadius: theme.radius.full,
122
+ overflow: "hidden"
123
+ },
124
+ fill: {
125
+ position: "absolute",
126
+ top: 0,
127
+ bottom: 0,
128
+ start: 0,
129
+ end: 0,
130
+ alignItems: "center",
131
+ justifyContent: "center"
132
+ },
133
+ label: {
134
+ fontFamily: theme.fontFamilies.body,
135
+ color: theme.colors.foreground
136
+ }
137
+ }),
138
+ variantTokens: VARIANT_TOKENS,
139
+ /** The `Checkbox`'s paint, with a dot where the check was. */
140
+ paint: (theme, colors) => ({
141
+ indicator: {
142
+ backgroundColor: colors.bg,
143
+ borderColor: colors.border,
144
+ borderWidth: colors.border ? theme.borderWidth.field : 0
145
+ },
146
+ fill: { backgroundColor: colors.bgSelected },
147
+ thumb: { backgroundColor: colors.fgSelected }
148
+ }),
149
+ variants: {
150
+ size: {
151
+ sm: sizeAxis(SIZES.sm),
152
+ md: sizeAxis(SIZES.md),
153
+ lg: sizeAxis(SIZES.lg)
154
+ },
155
+ radius: _chunkYXVKQMCKcjs.radiusAxis.call(void 0, "indicator"),
156
+ /** Declared after `size` so its border wins. The `Checkbox`'s rule, to the letter. */
157
+ isInvalid: {
158
+ true: (theme) => ({
159
+ indicator: { borderColor: theme.colors.danger, backgroundColor: void 0 },
160
+ fill: { backgroundColor: theme.colors.danger },
161
+ thumb: { backgroundColor: theme.colors.dangerForeground },
162
+ label: { color: theme.colors.danger }
163
+ })
164
+ }
165
+ },
166
+ compoundVariants: [
167
+ {
168
+ when: { variant: "primary" },
169
+ style: (theme) => ({ indicator: theme.shadows.field })
170
+ }
171
+ ],
172
+ states: {
173
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
174
+ },
175
+ defaultVariants: { variant: "secondary", size: "md" }
176
+ });
177
+
178
+ // src/components/radio/radio.tsx
179
+
180
+ var RadioRoot = _react.forwardRef.call(void 0, function Radio({
181
+ children,
182
+ variant,
183
+ size,
184
+ radius,
185
+ color,
186
+ isSelected,
187
+ defaultSelected = false,
188
+ onSelectedChange,
189
+ isInvalid = false,
190
+ isDisabled = false,
191
+ asChild = false,
192
+ accessibilityRole,
193
+ accessibilityState,
194
+ animation,
195
+ style,
196
+ onPress,
197
+ onPressIn,
198
+ onPressOut,
199
+ ...props
200
+ }, ref) {
201
+ const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
202
+ const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
203
+ const [isPressed, press] = _chunkIG4Q3WQOcjs.usePressState.call(void 0, { onPressIn, onPressOut });
204
+ const [selected, setSelected] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
205
+ value: isSelected,
206
+ defaultValue: defaultSelected,
207
+ onChange: onSelectedChange
208
+ });
209
+ const handlePress = _react.useCallback.call(void 0,
210
+ (event) => {
211
+ setSelected(true);
212
+ _optionalChain([onPress, 'optionalCall', _ => _(event)]);
213
+ },
214
+ [setSelected, onPress]
215
+ );
216
+ const selection = {
217
+ variant,
218
+ size,
219
+ radius,
220
+ isInvalid: isInvalid ? "true" : void 0
221
+ };
222
+ const states = { pressed: isPressed, disabled: isDisabled };
223
+ const styles = radioRecipe.resolve({ theme, selection, states });
224
+ const tint = color && !isInvalid ? radioRecipe.tint({ theme, color, selection, states }) : void 0;
225
+ const context = _react.useMemo.call(void 0,
226
+ () => ({
227
+ // The tint never reaches the circle at rest — only the fill and the dot that say it
228
+ // is the chosen one. The `Checkbox` says why, at the same line.
229
+ indicatorStyle: styles.indicator,
230
+ fillStyle: tint ? [styles.fill, tint.fill] : styles.fill,
231
+ thumbStyle: tint ? [styles.thumb, tint.thumb] : styles.thumb,
232
+ labelStyle: styles.label,
233
+ isSelected: selected,
234
+ isDisabled,
235
+ isInvalid
236
+ }),
237
+ [styles, tint, selected, isDisabled, isInvalid]
238
+ );
239
+ const rootStyle = [
240
+ styles.root,
241
+ _optionalChain([tint, 'optionalAccess', _2 => _2.root]),
242
+ styleProps,
243
+ typeof style === "function" ? style({ pressed: isPressed }) : style
244
+ ];
245
+ const text = _chunkHUZ4AUM2cjs.childrenToString.call(void 0, children);
246
+ const content = text !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
247
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RadioIndicator, {}),
248
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RadioLabel, { children: text })
249
+ ] }) : _nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RadioIndicator, {})));
250
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RadioProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
251
+ _chunkIG4Q3WQOcjs.PressableFeedback,
252
+ {
253
+ ref,
254
+ isPressed,
255
+ isDisabled,
256
+ asChild,
257
+ animation,
258
+ accessibilityRole: _nullishCoalesce(accessibilityRole, () => ( "radio")),
259
+ accessibilityState: {
260
+ checked: selected,
261
+ disabled: isDisabled,
262
+ ...accessibilityState
263
+ },
264
+ "aria-invalid": isInvalid,
265
+ ...rest,
266
+ style: rootStyle,
267
+ onPress: handlePress,
268
+ onPressIn: press.onPressIn,
269
+ onPressOut: press.onPressOut,
270
+ children: asChild ? children : content
271
+ }
272
+ ) });
273
+ });
274
+ RadioRoot.displayName = "XAUI.Radio.Root";
275
+
276
+ // src/components/radio/index.ts
277
+ var Radio2 = Object.assign(RadioRoot, {
278
+ Indicator: RadioIndicator,
279
+ Label: RadioLabel
280
+ });
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+ exports.useRadio = useRadio; exports.RadioIndicator = RadioIndicator; exports.RadioLabel = RadioLabel; exports.radioRecipe = radioRecipe; exports.RadioRoot = RadioRoot; exports.Radio = Radio2;