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

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 (143) hide show
  1. package/dist/chunk-27ZRTZEE.js +293 -0
  2. package/dist/chunk-3FV4COTM.js +68 -0
  3. package/dist/chunk-423RQBOX.js +21 -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-5RQ7AZPN.cjs +455 -0
  9. package/dist/chunk-5Z4P6WHR.cjs +525 -0
  10. package/dist/chunk-6RVCGLKZ.js +661 -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-BA2DBSAN.js +102 -0
  18. package/dist/chunk-BFMTUMTU.js +669 -0
  19. package/dist/chunk-BVJQ3UPZ.js +62 -0
  20. package/dist/chunk-DFME724B.js +147 -0
  21. package/dist/chunk-E2CWBQTV.js +119 -0
  22. package/dist/chunk-E4TS6632.cjs +314 -0
  23. package/dist/chunk-EGLLDKN6.js +9 -0
  24. package/dist/chunk-EJQCQPET.cjs +9 -0
  25. package/dist/chunk-F6CQ6CBI.cjs +112 -0
  26. package/dist/chunk-F6W3JQ7K.js +42 -0
  27. package/dist/chunk-FMZQW35T.js +431 -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-GI24YJPE.js +314 -0
  32. package/dist/chunk-GLGU2WFL.cjs +190 -0
  33. package/dist/chunk-GPVNCJ3Z.cjs +696 -0
  34. package/dist/chunk-GVQOD3VW.js +74 -0
  35. package/dist/chunk-KOC3KQIT.js +124 -0
  36. package/dist/chunk-KPWZLUES.cjs +124 -0
  37. package/dist/chunk-KWCHSIMI.cjs +293 -0
  38. package/dist/chunk-MC7SY2QH.cjs +20 -0
  39. package/dist/chunk-N527BTY4.cjs +366 -0
  40. package/dist/chunk-NBFWWQFW.cjs +346 -0
  41. package/dist/chunk-NYRXUGVL.js +104 -0
  42. package/dist/{chunk-AW63PTQ4.cjs → chunk-OHEHPQLC.cjs} +72 -72
  43. package/dist/chunk-Q3WFY5N3.js +366 -0
  44. package/dist/chunk-QGN2BBJO.cjs +104 -0
  45. package/dist/chunk-TGZZ3RZU.cjs +86 -0
  46. package/dist/{chunk-2KXQATVL.js → chunk-TZG3DERP.js} +46 -46
  47. package/dist/chunk-UBQLKIZC.cjs +431 -0
  48. package/dist/chunk-URSKA2VR.js +190 -0
  49. package/dist/chunk-V4WDMM6Z.js +86 -0
  50. package/dist/chunk-VJEER76X.js +455 -0
  51. package/dist/chunk-VZBWYWEI.cjs +736 -0
  52. package/dist/chunk-WR7YLDVV.cjs +68 -0
  53. package/dist/chunk-X4HQ4H2V.js +701 -0
  54. package/dist/chunk-XFSW3ZNI.cjs +145 -0
  55. package/dist/chunk-XQFAUDR2.cjs +62 -0
  56. package/dist/chunk-YKL6XHM6.js +346 -0
  57. package/dist/chunk-ZP2E2H2G.cjs +119 -0
  58. package/dist/chunk-ZSLNGBDS.cjs +700 -0
  59. package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
  60. package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
  61. package/dist/components/alert/index.cjs +20 -0
  62. package/dist/components/alert/index.d.cts +169 -0
  63. package/dist/components/alert/index.d.ts +169 -0
  64. package/dist/components/alert/index.js +20 -0
  65. package/dist/components/button/index.cjs +21 -0
  66. package/dist/components/button/index.d.cts +613 -0
  67. package/dist/components/button/index.d.ts +613 -0
  68. package/dist/components/button/index.js +21 -0
  69. package/dist/components/card/index.cjs +22 -0
  70. package/dist/components/card/index.d.cts +620 -0
  71. package/dist/components/card/index.d.ts +620 -0
  72. package/dist/components/card/index.js +22 -0
  73. package/dist/components/checkbox/index.cjs +26 -0
  74. package/dist/components/checkbox/index.d.cts +1136 -0
  75. package/dist/components/checkbox/index.d.ts +1136 -0
  76. package/dist/components/checkbox/index.js +26 -0
  77. package/dist/components/chip/index.cjs +20 -0
  78. package/dist/components/chip/index.d.cts +608 -0
  79. package/dist/components/chip/index.d.ts +608 -0
  80. package/dist/components/chip/index.js +20 -0
  81. package/dist/components/input/index.cjs +25 -0
  82. package/dist/components/input/index.d.cts +205 -0
  83. package/dist/components/input/index.d.ts +205 -0
  84. package/dist/components/input/index.js +25 -0
  85. package/dist/components/input-group/index.cjs +27 -0
  86. package/dist/components/input-group/index.d.cts +270 -0
  87. package/dist/components/input-group/index.d.ts +270 -0
  88. package/dist/components/input-group/index.js +27 -0
  89. package/dist/components/input-otp/index.cjs +29 -0
  90. package/dist/components/input-otp/index.d.cts +325 -0
  91. package/dist/components/input-otp/index.d.ts +325 -0
  92. package/dist/components/input-otp/index.js +29 -0
  93. package/dist/components/radio/index.cjs +26 -0
  94. package/dist/components/radio/index.d.cts +1102 -0
  95. package/dist/components/radio/index.d.ts +1102 -0
  96. package/dist/components/radio/index.js +26 -0
  97. package/dist/components/spinner/index.cjs +16 -0
  98. package/dist/components/spinner/index.d.cts +104 -0
  99. package/dist/components/spinner/index.d.ts +104 -0
  100. package/dist/components/spinner/index.js +16 -0
  101. package/dist/components/switch/index.cjs +27 -0
  102. package/dist/components/switch/index.d.cts +1154 -0
  103. package/dist/components/switch/index.d.ts +1154 -0
  104. package/dist/components/switch/index.js +27 -0
  105. package/dist/components/text-area/index.cjs +14 -0
  106. package/dist/components/text-area/index.d.cts +73 -0
  107. package/dist/components/text-area/index.d.ts +73 -0
  108. package/dist/components/text-area/index.js +14 -0
  109. package/dist/components/typography/index.cjs +15 -0
  110. package/dist/components/typography/index.d.cts +116 -0
  111. package/dist/components/typography/index.d.ts +116 -0
  112. package/dist/components/typography/index.js +15 -0
  113. package/dist/components/view/index.cjs +17 -0
  114. package/dist/components/view/index.d.cts +152 -0
  115. package/dist/components/view/index.d.ts +152 -0
  116. package/dist/components/view/index.js +17 -0
  117. package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
  118. package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
  119. package/dist/icon.type-Kml72iSz.d.ts +73 -0
  120. package/dist/icon.type-d_i9ma-i.d.cts +73 -0
  121. package/dist/index.cjs +246 -4
  122. package/dist/index.d.cts +109 -4
  123. package/dist/index.d.ts +109 -4
  124. package/dist/index.js +266 -24
  125. package/dist/input.type-BUMDlzL9.d.cts +167 -0
  126. package/dist/input.type-D2qgi03E.d.ts +167 -0
  127. package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
  128. package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
  129. package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
  130. package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
  131. package/dist/system/index.cjs +60 -3
  132. package/dist/system/index.d.cts +347 -181
  133. package/dist/system/index.d.ts +347 -181
  134. package/dist/system/index.js +71 -14
  135. package/dist/theme/index.cjs +4 -3
  136. package/dist/theme/index.d.cts +34 -23
  137. package/dist/theme/index.d.ts +34 -23
  138. package/dist/theme/index.js +3 -2
  139. package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
  140. package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
  141. package/package.json +174 -18
  142. package/dist/chunk-QAMNNTGM.js +0 -637
  143. package/dist/chunk-V63JO65F.cjs +0 -637
@@ -0,0 +1,293 @@
1
+ import {
2
+ SelectionFill
3
+ } from "./chunk-BA2DBSAN.js";
4
+ import {
5
+ PressableFeedback
6
+ } from "./chunk-BFMTUMTU.js";
7
+ import {
8
+ usePressState
9
+ } from "./chunk-423RQBOX.js";
10
+ import {
11
+ useControllableState
12
+ } from "./chunk-F6W3JQ7K.js";
13
+ import {
14
+ createRecipe,
15
+ radiusAxis
16
+ } from "./chunk-4GTAZM2C.js";
17
+ import {
18
+ useXAUITheme
19
+ } from "./chunk-A3EGFI6T.js";
20
+ import {
21
+ childrenToString,
22
+ createSlotContext
23
+ } from "./chunk-E2CWBQTV.js";
24
+ import {
25
+ useStyleProps
26
+ } from "./chunk-URSKA2VR.js";
27
+
28
+ // src/components/radio/radio-indicator.tsx
29
+ import { forwardRef } from "react";
30
+ import { View } from "react-native";
31
+
32
+ // src/components/radio/radio.context.ts
33
+ var [RadioProvider, useRadio] = createSlotContext("Radio");
34
+
35
+ // src/components/radio/radio-indicator.tsx
36
+ import { jsx } from "react/jsx-runtime";
37
+ var RadioIndicator = forwardRef(
38
+ function RadioIndicator2({ children, animation = true, style, ...props }, ref) {
39
+ const { indicatorStyle, fillStyle, isSelected } = useRadio();
40
+ const [styleProps, rest] = useStyleProps(props);
41
+ return /* @__PURE__ */ jsx(View, { ref, ...rest, style: [indicatorStyle, styleProps, style], children: /* @__PURE__ */ jsx(
42
+ SelectionFill,
43
+ {
44
+ isVisible: isSelected,
45
+ style: fillStyle,
46
+ animation,
47
+ children: children ?? /* @__PURE__ */ jsx(Thumb, {})
48
+ }
49
+ ) });
50
+ }
51
+ );
52
+ RadioIndicator.displayName = "XAUI.Radio.Indicator";
53
+ function Thumb() {
54
+ const { thumbStyle } = useRadio();
55
+ return /* @__PURE__ */ jsx(View, { style: thumbStyle });
56
+ }
57
+
58
+ // src/components/radio/radio-label.tsx
59
+ import { forwardRef as forwardRef2 } from "react";
60
+ import { Text } from "react-native";
61
+ import { jsx as jsx2 } from "react/jsx-runtime";
62
+ var RadioLabel = forwardRef2(function RadioLabel2({ children, style, ...props }, ref) {
63
+ const { labelStyle } = useRadio();
64
+ const [styleProps, rest] = useStyleProps(props);
65
+ return /* @__PURE__ */ jsx2(Text, { ref, style: [labelStyle, styleProps, style], ...rest, children });
66
+ });
67
+ RadioLabel.displayName = "XAUI.Radio.Label";
68
+
69
+ // src/components/radio/radio.tsx
70
+ import { forwardRef as forwardRef3, useCallback, useMemo } from "react";
71
+
72
+ // src/components/radio/radio.recipe.ts
73
+ var SLOTS = ["root", "indicator", "fill", "thumb", "label"];
74
+ var VARIANT_TOKENS = {
75
+ primary: {
76
+ bg: "fieldBackground",
77
+ border: "fieldBorder",
78
+ bgSelected: "accent",
79
+ fgSelected: "accentForeground"
80
+ },
81
+ secondary: {
82
+ bg: "default",
83
+ border: "fieldBorder",
84
+ bgSelected: "accent",
85
+ fgSelected: "accentForeground"
86
+ },
87
+ tertiary: {
88
+ border: "fieldBorder",
89
+ bgSelected: "accent",
90
+ fgSelected: "accentForeground"
91
+ }
92
+ };
93
+ function sizeAxis(step) {
94
+ const { box, label, gap } = step;
95
+ return (theme) => {
96
+ const side = theme.spacing(box);
97
+ const dot = Math.round(side * THUMB_RATIO);
98
+ return {
99
+ root: { gap: theme.spacing(gap) },
100
+ indicator: { width: side, height: side },
101
+ thumb: { width: dot, height: dot, borderRadius: dot / 2 },
102
+ label: {
103
+ fontSize: theme.fontSizes[label],
104
+ lineHeight: theme.lineHeights[label]
105
+ }
106
+ };
107
+ };
108
+ }
109
+ var THUMB_RATIO = 10 / 24;
110
+ var SIZES = {
111
+ sm: { box: 5, gap: 2, label: "sm" },
112
+ md: { box: 6, gap: 2, label: "md" },
113
+ lg: { box: 7, gap: 2.5, label: "lg" }
114
+ };
115
+ var radioRecipe = createRecipe({
116
+ slots: SLOTS,
117
+ base: (theme) => ({
118
+ root: { flexDirection: "row", alignItems: "center", alignSelf: "flex-start" },
119
+ indicator: {
120
+ alignItems: "center",
121
+ justifyContent: "center",
122
+ borderWidth: theme.borderWidth.field,
123
+ // The one shape decision this component makes, and the whole difference between it
124
+ // and the `Checkbox`: a radio is round, at every size. `radius` still overrides it.
125
+ borderRadius: theme.radius.full,
126
+ overflow: "hidden"
127
+ },
128
+ fill: {
129
+ position: "absolute",
130
+ top: 0,
131
+ bottom: 0,
132
+ start: 0,
133
+ end: 0,
134
+ alignItems: "center",
135
+ justifyContent: "center"
136
+ },
137
+ label: {
138
+ fontFamily: theme.fontFamilies.body,
139
+ color: theme.colors.foreground
140
+ }
141
+ }),
142
+ variantTokens: VARIANT_TOKENS,
143
+ /** The `Checkbox`'s paint, with a dot where the check was. */
144
+ paint: (theme, colors) => ({
145
+ indicator: {
146
+ backgroundColor: colors.bg,
147
+ borderColor: colors.border,
148
+ borderWidth: colors.border ? theme.borderWidth.field : 0
149
+ },
150
+ fill: { backgroundColor: colors.bgSelected },
151
+ thumb: { backgroundColor: colors.fgSelected }
152
+ }),
153
+ variants: {
154
+ size: {
155
+ sm: sizeAxis(SIZES.sm),
156
+ md: sizeAxis(SIZES.md),
157
+ lg: sizeAxis(SIZES.lg)
158
+ },
159
+ radius: radiusAxis("indicator"),
160
+ /** Declared after `size` so its border wins. The `Checkbox`'s rule, to the letter. */
161
+ isInvalid: {
162
+ true: (theme) => ({
163
+ indicator: { borderColor: theme.colors.danger, backgroundColor: void 0 },
164
+ fill: { backgroundColor: theme.colors.danger },
165
+ thumb: { backgroundColor: theme.colors.dangerForeground },
166
+ label: { color: theme.colors.danger }
167
+ })
168
+ }
169
+ },
170
+ compoundVariants: [
171
+ {
172
+ when: { variant: "primary" },
173
+ style: (theme) => ({ indicator: theme.shadows.field })
174
+ }
175
+ ],
176
+ states: {
177
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
178
+ },
179
+ defaultVariants: { variant: "secondary", size: "md" }
180
+ });
181
+
182
+ // src/components/radio/radio.tsx
183
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
184
+ var RadioRoot = forwardRef3(function Radio({
185
+ children,
186
+ variant,
187
+ size,
188
+ radius,
189
+ color,
190
+ isSelected,
191
+ defaultSelected = false,
192
+ onSelectedChange,
193
+ isInvalid = false,
194
+ isDisabled = false,
195
+ asChild = false,
196
+ accessibilityRole,
197
+ accessibilityState,
198
+ animation,
199
+ style,
200
+ onPress,
201
+ onPressIn,
202
+ onPressOut,
203
+ ...props
204
+ }, ref) {
205
+ const theme = useXAUITheme();
206
+ const [styleProps, rest] = useStyleProps(props);
207
+ const [isPressed, press] = usePressState({ onPressIn, onPressOut });
208
+ const [selected, setSelected] = useControllableState({
209
+ value: isSelected,
210
+ defaultValue: defaultSelected,
211
+ onChange: onSelectedChange
212
+ });
213
+ const handlePress = useCallback(
214
+ (event) => {
215
+ setSelected(true);
216
+ onPress?.(event);
217
+ },
218
+ [setSelected, onPress]
219
+ );
220
+ const selection = {
221
+ variant,
222
+ size,
223
+ radius,
224
+ isInvalid: isInvalid ? "true" : void 0
225
+ };
226
+ const states = { pressed: isPressed, disabled: isDisabled };
227
+ const styles = radioRecipe.resolve({ theme, selection, states });
228
+ const tint = color && !isInvalid ? radioRecipe.tint({ theme, color, selection, states }) : void 0;
229
+ const context = useMemo(
230
+ () => ({
231
+ // The tint never reaches the circle at rest — only the fill and the dot that say it
232
+ // is the chosen one. The `Checkbox` says why, at the same line.
233
+ indicatorStyle: styles.indicator,
234
+ fillStyle: tint ? [styles.fill, tint.fill] : styles.fill,
235
+ thumbStyle: tint ? [styles.thumb, tint.thumb] : styles.thumb,
236
+ labelStyle: styles.label,
237
+ isSelected: selected,
238
+ isDisabled,
239
+ isInvalid
240
+ }),
241
+ [styles, tint, selected, isDisabled, isInvalid]
242
+ );
243
+ const rootStyle = [
244
+ styles.root,
245
+ tint?.root,
246
+ styleProps,
247
+ typeof style === "function" ? style({ pressed: isPressed }) : style
248
+ ];
249
+ const text = childrenToString(children);
250
+ const content = text !== null ? /* @__PURE__ */ jsxs(Fragment, { children: [
251
+ /* @__PURE__ */ jsx3(RadioIndicator, {}),
252
+ /* @__PURE__ */ jsx3(RadioLabel, { children: text })
253
+ ] }) : children ?? /* @__PURE__ */ jsx3(RadioIndicator, {});
254
+ return /* @__PURE__ */ jsx3(RadioProvider, { value: context, children: /* @__PURE__ */ jsx3(
255
+ PressableFeedback,
256
+ {
257
+ ref,
258
+ isPressed,
259
+ isDisabled,
260
+ asChild,
261
+ animation,
262
+ accessibilityRole: accessibilityRole ?? "radio",
263
+ accessibilityState: {
264
+ checked: selected,
265
+ disabled: isDisabled,
266
+ ...accessibilityState
267
+ },
268
+ "aria-invalid": isInvalid,
269
+ ...rest,
270
+ style: rootStyle,
271
+ onPress: handlePress,
272
+ onPressIn: press.onPressIn,
273
+ onPressOut: press.onPressOut,
274
+ children: asChild ? children : content
275
+ }
276
+ ) });
277
+ });
278
+ RadioRoot.displayName = "XAUI.Radio.Root";
279
+
280
+ // src/components/radio/index.ts
281
+ var Radio2 = Object.assign(RadioRoot, {
282
+ Indicator: RadioIndicator,
283
+ Label: RadioLabel
284
+ });
285
+
286
+ export {
287
+ useRadio,
288
+ RadioIndicator,
289
+ RadioLabel,
290
+ radioRecipe,
291
+ RadioRoot,
292
+ Radio2 as Radio
293
+ };
@@ -0,0 +1,68 @@
1
+ import {
2
+ useXAUITheme
3
+ } from "./chunk-A3EGFI6T.js";
4
+ import {
5
+ useStyleProps
6
+ } from "./chunk-URSKA2VR.js";
7
+
8
+ // src/system/icon/icon-context.ts
9
+ import { createContext, useContext } from "react";
10
+ var IconContext = createContext({});
11
+ IconContext.displayName = "XAUI.Icon.Context";
12
+ function useIconContext() {
13
+ return useContext(IconContext);
14
+ }
15
+
16
+ // src/system/icon/icon.tsx
17
+ import { cloneElement, isValidElement } from "react";
18
+ import { Image } from "react-native";
19
+ import { jsx } from "react/jsx-runtime";
20
+ function Icon(props) {
21
+ const inherited = useIconContext();
22
+ const theme = useXAUITheme();
23
+ const size = props.size ?? inherited.size ?? theme.fontSizes.md;
24
+ const color = props.color ?? inherited.color ?? theme.colors.foreground;
25
+ if (props.as) {
26
+ const Component = props.as;
27
+ return /* @__PURE__ */ jsx(Component, { size, color });
28
+ }
29
+ if (isValidElement(props.children)) {
30
+ return cloneElement(props.children, {
31
+ width: size,
32
+ height: size,
33
+ color
34
+ });
35
+ }
36
+ if (props.source) return /* @__PURE__ */ jsx(IconImage, { ...props, resolved: { size, color } });
37
+ throw new Error(
38
+ "XAUI: Icon needs one of `as` (an icon component), a raw SVG element as its child, or `source` (an image). It renders nothing on its own."
39
+ );
40
+ }
41
+ Icon.displayName = "XAUI.Icon";
42
+ function IconImage({
43
+ source,
44
+ style,
45
+ resolved,
46
+ size: _size,
47
+ color: _color,
48
+ ...props
49
+ }) {
50
+ const [styleProps] = useStyleProps(props);
51
+ return /* @__PURE__ */ jsx(
52
+ Image,
53
+ {
54
+ source,
55
+ style: [
56
+ { width: resolved.size, height: resolved.size, tintColor: resolved.color },
57
+ styleProps,
58
+ style
59
+ ]
60
+ }
61
+ );
62
+ }
63
+
64
+ export {
65
+ IconContext,
66
+ useIconContext,
67
+ Icon
68
+ };
@@ -0,0 +1,21 @@
1
+ // src/hooks/use-press-state.ts
2
+ import { useCallback, useRef, useState } from "react";
3
+ function usePressState(handlers = {}) {
4
+ const [isPressed, setIsPressed] = useState(false);
5
+ const latest = useRef(handlers);
6
+ latest.current = handlers;
7
+ const onPressIn = useCallback((event) => {
8
+ setIsPressed(true);
9
+ latest.current.onPressIn?.(event);
10
+ }, []);
11
+ const onPressOut = useCallback((event) => {
12
+ setIsPressed(false);
13
+ latest.current.onPressOut?.(event);
14
+ }, []);
15
+ const press = useRef({ onPressIn, onPressOut }).current;
16
+ return [isPressed, press];
17
+ }
18
+
19
+ export {
20
+ usePressState
21
+ };
@@ -0,0 +1,174 @@
1
+ import {
2
+ deriveTint
3
+ } from "./chunk-A3EGFI6T.js";
4
+
5
+ // src/system/recipe/resolve-tint.ts
6
+ var TINT_SLICE_BY_SUFFIX = [
7
+ [/SoftForeground$/, "softForeground"],
8
+ [/SoftPressed$/, "softPressed"],
9
+ [/Soft$/, "soft"],
10
+ [/Foreground$/, "foreground"],
11
+ [/Pressed$/, "pressed"]
12
+ ];
13
+ function tintSliceFor(token) {
14
+ for (const [suffix, slice] of TINT_SLICE_BY_SUFFIX) {
15
+ if (suffix.test(token)) return slice;
16
+ }
17
+ return "base";
18
+ }
19
+ function resolveTint(tokens, color, theme) {
20
+ const tint = deriveTint(color, theme);
21
+ const colors = {};
22
+ for (const [role, token] of Object.entries(tokens ?? {})) {
23
+ colors[role] = tint[tintSliceFor(token)];
24
+ }
25
+ return colors;
26
+ }
27
+
28
+ // src/system/recipe/style-cache.ts
29
+ import { StyleSheet } from "react-native";
30
+
31
+ // src/system/recipe/variant-map.ts
32
+ var STATE_ORDER = ["focused", "pressed", "disabled"];
33
+ function resolveSelection(defaultVariants, selection) {
34
+ const resolved = { ...defaultVariants };
35
+ for (const [axis, value] of Object.entries(selection ?? {})) {
36
+ if (value !== void 0) resolved[axis] = value;
37
+ }
38
+ return resolved;
39
+ }
40
+ function resolveVariantColors(tokens, theme) {
41
+ const colors = {};
42
+ for (const [role, token] of entriesOf(tokens)) {
43
+ const value = theme.colors[token];
44
+ if (value === void 0) {
45
+ throw new Error(
46
+ `XAUI: the recipe names "${token}" for its "${role}" role, but the theme has no such colour token. Check the spelling against XAUIColors.`
47
+ );
48
+ }
49
+ colors[role] = value;
50
+ }
51
+ return colors;
52
+ }
53
+ function activeStateFns(states, active) {
54
+ const fns = [];
55
+ for (const state of STATE_ORDER) {
56
+ const fn = active[state] ? states?.[state] : void 0;
57
+ if (fn) fns.push(fn);
58
+ }
59
+ return fns;
60
+ }
61
+ function collectStyleFns(config, selection, states) {
62
+ const fns = [];
63
+ if (config.base) fns.push(config.base);
64
+ if (config.paint) fns.push(config.paint);
65
+ for (const [axis, values] of Object.entries(config.variants ?? {})) {
66
+ const value = selection[axis];
67
+ const fn = value === void 0 ? void 0 : values[value];
68
+ if (fn) fns.push(fn);
69
+ }
70
+ for (const compound of config.compoundVariants ?? []) {
71
+ if (appliesTo(compound.when, selection)) fns.push(compound.style);
72
+ }
73
+ return [...fns, ...activeStateFns(config.states, states)];
74
+ }
75
+ function appliesTo(when, selection) {
76
+ return Object.entries(when).every(([axis, value]) => selection[axis] === value);
77
+ }
78
+ function entriesOf(tokens) {
79
+ return Object.entries(tokens ?? {});
80
+ }
81
+
82
+ // src/system/recipe/style-cache.ts
83
+ function createStyleCache(slots) {
84
+ const entries = /* @__PURE__ */ new Map();
85
+ return {
86
+ read(key, build) {
87
+ const hit = entries.get(key);
88
+ if (hit) return hit;
89
+ const built = build();
90
+ const complete = {};
91
+ for (const slot of slots) complete[slot] = built[slot] ?? {};
92
+ const created = StyleSheet.create(complete);
93
+ entries.set(key, created);
94
+ return created;
95
+ },
96
+ get size() {
97
+ return entries.size;
98
+ },
99
+ clear() {
100
+ entries.clear();
101
+ }
102
+ };
103
+ }
104
+ function cacheKey(theme, selection, states) {
105
+ const axes = Object.keys(selection).sort().map((axis) => `${axis}:${selection[axis] ?? "-"}`).join("|");
106
+ const active = STATE_ORDER.filter((state) => states[state]).join(",");
107
+ return `${theme.id}|${theme.mode}|${axes}|${active}`;
108
+ }
109
+
110
+ // src/system/recipe/create-recipe.ts
111
+ function createRecipe(config) {
112
+ const cache = createStyleCache(config.slots);
113
+ const tokensFor = (variant) => variant === void 0 ? void 0 : config.variantTokens?.[variant];
114
+ return {
115
+ slots: config.slots,
116
+ resolve({ theme, selection, states = {} }) {
117
+ const resolved = resolveSelection(config.defaultVariants, selection);
118
+ return cache.read(cacheKey(theme, resolved, states), () => {
119
+ const colors = resolveVariantColors(tokensFor(resolved.variant), theme);
120
+ return apply(collectStyleFns(config, resolved, states), theme, colors);
121
+ });
122
+ },
123
+ tint({ theme, color, selection, states = {} }) {
124
+ if (!config.paint) return {};
125
+ const resolved = resolveSelection(config.defaultVariants, selection);
126
+ const tokens = tokensFor(resolved.variant);
127
+ if (!tokens) return {};
128
+ const colors = resolveTint(tokens, color, theme);
129
+ const fns = [config.paint, ...activeStateFns(config.states, states)];
130
+ return apply(fns, theme, colors);
131
+ }
132
+ };
133
+ }
134
+ function apply(fns, theme, colors) {
135
+ const merged = {};
136
+ for (const fn of fns) {
137
+ const produced = fn(theme, colors);
138
+ for (const slot of Object.keys(produced)) {
139
+ const style = produced[slot];
140
+ if (!style) continue;
141
+ const previous = merged[slot];
142
+ merged[slot] = previous ? { ...previous, ...style } : style;
143
+ }
144
+ }
145
+ return merged;
146
+ }
147
+
148
+ // src/system/recipe/radius-axis.ts
149
+ function radiusAxis(...slots) {
150
+ const axis = {};
151
+ for (const key of RADIUS_KEYS) {
152
+ axis[key] = (theme) => Object.fromEntries(
153
+ slots.map((slot) => [slot, { borderRadius: theme.radius[key] }])
154
+ );
155
+ }
156
+ return axis;
157
+ }
158
+ var RADIUS_KEYS = [
159
+ "xs",
160
+ "sm",
161
+ "md",
162
+ "lg",
163
+ "xl",
164
+ "2xl",
165
+ "3xl",
166
+ "4xl",
167
+ "field",
168
+ "full"
169
+ ];
170
+
171
+ export {
172
+ createRecipe,
173
+ radiusAxis
174
+ };
@@ -0,0 +1,147 @@
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 _chunk5Z4P6WHRcjs = require('./chunk-5Z4P6WHR.cjs');
5
+
6
+
7
+ var _chunkWR7YLDVVcjs = require('./chunk-WR7YLDVV.cjs');
8
+
9
+
10
+
11
+ var _chunkZP2E2H2Gcjs = require('./chunk-ZP2E2H2G.cjs');
12
+
13
+
14
+ var _chunkGLGU2WFLcjs = require('./chunk-GLGU2WFL.cjs');
15
+
16
+ // src/components/input-group/input-group-field.tsx
17
+ var _react = require('react');
18
+
19
+ // src/components/input-group/input-group.context.ts
20
+ var [InputGroupProvider, useInputGroup] = _chunkZP2E2H2Gcjs.createSlotContext.call(void 0, "InputGroup");
21
+
22
+ // src/components/input-group/input-group.utils.ts
23
+ function decoratorPadding(prefixWidth, suffixWidth) {
24
+ const paddingStart = prefixWidth > 0 ? prefixWidth : void 0;
25
+ const paddingEnd = suffixWidth > 0 ? suffixWidth : void 0;
26
+ if (paddingStart === void 0 && paddingEnd === void 0) return void 0;
27
+ return { paddingStart, paddingEnd };
28
+ }
29
+
30
+ // src/components/input-group/input-group-field.tsx
31
+ var _jsxruntime = require('react/jsx-runtime');
32
+ var InputGroupField = _react.forwardRef.call(void 0,
33
+ function InputGroupField2({ style, ...props }, ref) {
34
+ const { prefixWidth, suffixWidth } = useInputGroup();
35
+ const padding = _react.useMemo.call(void 0,
36
+ () => decoratorPadding(prefixWidth, suffixWidth),
37
+ [prefixWidth, suffixWidth]
38
+ );
39
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5Z4P6WHRcjs.InputField, { ref, ...props, style: [padding, style] });
40
+ }
41
+ );
42
+ InputGroupField.displayName = "XAUI.InputGroup.Field";
43
+
44
+ // src/components/input-group/input-group-icon.tsx
45
+
46
+ function InputGroupIcon({ size, color, ...rest }) {
47
+ const { icon } = _chunk5Z4P6WHRcjs.useInput.call(void 0, );
48
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWR7YLDVVcjs.Icon, { size: _nullishCoalesce(size, () => ( icon.size)), color: _nullishCoalesce(color, () => ( icon.color)), ...rest });
49
+ }
50
+ InputGroupIcon.displayName = "XAUI.InputGroup.Icon";
51
+
52
+ // src/components/input-group/input-group-prefix.tsx
53
+
54
+
55
+ // src/components/input-group/input-group-decorator.tsx
56
+
57
+ var _reactnative = require('react-native');
58
+
59
+ var InputGroupDecorator = _react.forwardRef.call(void 0,
60
+ function InputGroupDecorator2({ side, children, isDecorative = false, onLayout, style, ...props }, ref) {
61
+ const { prefixStyle, suffixStyle, isDisabled } = _chunk5Z4P6WHRcjs.useInput.call(void 0, );
62
+ const { setPrefixWidth, setSuffixWidth } = useInputGroup();
63
+ const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
64
+ const report = side === "prefix" ? setPrefixWidth : setSuffixWidth;
65
+ const handleLayout = _react.useCallback.call(void 0,
66
+ (event) => {
67
+ report(event.nativeEvent.layout.width);
68
+ _optionalChain([onLayout, 'optionalCall', _ => _(event)]);
69
+ },
70
+ [report, onLayout]
71
+ );
72
+ const isInert = isDecorative || isDisabled;
73
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
74
+ _reactnative.View,
75
+ {
76
+ ref,
77
+ accessibilityElementsHidden: isDecorative || void 0,
78
+ importantForAccessibility: isDecorative ? "no-hide-descendants" : void 0,
79
+ pointerEvents: isInert ? "none" : void 0,
80
+ ...rest,
81
+ style: [side === "prefix" ? prefixStyle : suffixStyle, styleProps, style],
82
+ onLayout: handleLayout,
83
+ children
84
+ }
85
+ );
86
+ }
87
+ );
88
+ InputGroupDecorator.displayName = "XAUI.InputGroup.Decorator";
89
+
90
+ // src/components/input-group/input-group-prefix.tsx
91
+
92
+ var InputGroupPrefix = _react.forwardRef.call(void 0,
93
+ function InputGroupPrefix2(props, ref) {
94
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InputGroupDecorator, { ref, side: "prefix", ...props });
95
+ }
96
+ );
97
+ InputGroupPrefix.displayName = "XAUI.InputGroup.Prefix";
98
+
99
+ // src/components/input-group/input-group-suffix.tsx
100
+
101
+
102
+ var InputGroupSuffix = _react.forwardRef.call(void 0,
103
+ function InputGroupSuffix2(props, ref) {
104
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InputGroupDecorator, { ref, side: "suffix", ...props });
105
+ }
106
+ );
107
+ InputGroupSuffix.displayName = "XAUI.InputGroup.Suffix";
108
+
109
+ // src/components/input-group/input-group.tsx
110
+
111
+
112
+
113
+ var InputGroupRoot = _react.forwardRef.call(void 0, function InputGroup({ children, asChild = false, style, ...props }, ref) {
114
+ const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
115
+ const [prefixWidth, setPrefixWidth] = _react.useState.call(void 0, 0);
116
+ const [suffixWidth, setSuffixWidth] = _react.useState.call(void 0, 0);
117
+ const context = _react.useMemo.call(void 0,
118
+ () => ({ prefixWidth, suffixWidth, setPrefixWidth, setSuffixWidth }),
119
+ [prefixWidth, suffixWidth]
120
+ );
121
+ const rootStyle = [styleProps, style];
122
+ const surface = asChild ? (
123
+ // R12 — the caller's element *is* the row.
124
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZP2E2H2Gcjs.Slot, { ref, ...rest, style: rootStyle, children })
125
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, ...rest, style: rootStyle, children });
126
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InputGroupProvider, { value: context, children: surface });
127
+ });
128
+ InputGroupRoot.displayName = "XAUI.InputGroup.Root";
129
+
130
+ // src/components/input-group/index.ts
131
+ var InputGroup2 = Object.assign(InputGroupRoot, {
132
+ Prefix: InputGroupPrefix,
133
+ Field: InputGroupField,
134
+ Suffix: InputGroupSuffix,
135
+ Icon: InputGroupIcon
136
+ });
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ exports.useInputGroup = useInputGroup; exports.decoratorPadding = decoratorPadding; exports.InputGroupField = InputGroupField; exports.InputGroupIcon = InputGroupIcon; exports.InputGroupPrefix = InputGroupPrefix; exports.InputGroupSuffix = InputGroupSuffix; exports.InputGroupRoot = InputGroupRoot; exports.InputGroup = InputGroup2;