@xaui/native 0.9.1-alpha.4 → 0.9.1-alpha.41

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 (209) hide show
  1. package/dist/chunk-2EGR4LWD.js +145 -0
  2. package/dist/chunk-2NRZKJG7.js +531 -0
  3. package/dist/chunk-2PMXMKS5.js +67 -0
  4. package/dist/chunk-2XPG2243.js +586 -0
  5. package/dist/chunk-36PRYGAM.js +13 -0
  6. package/dist/chunk-3E7CDKFO.cjs +696 -0
  7. package/dist/chunk-3GFRSZYR.js +54 -0
  8. package/dist/chunk-423RQBOX.js +21 -0
  9. package/dist/chunk-4CUZZWFW.js +92 -0
  10. package/dist/chunk-4GTAZM2C.js +174 -0
  11. package/dist/chunk-4KFKWBN5.cjs +89 -0
  12. package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
  13. package/dist/chunk-5R26NM4M.cjs +402 -0
  14. package/dist/chunk-5VKYNBNA.js +607 -0
  15. package/dist/chunk-64MXEVT3.js +66 -0
  16. package/dist/chunk-6DOLGZVV.cjs +147 -0
  17. package/dist/chunk-6L2TS2R3.cjs +92 -0
  18. package/dist/chunk-6UEZJRVI.js +669 -0
  19. package/dist/chunk-734MFAX4.js +27 -0
  20. package/dist/chunk-73RKQC5X.js +104 -0
  21. package/dist/chunk-7DPL3ZDS.cjs +21 -0
  22. package/dist/chunk-7EIHHOHP.cjs +42 -0
  23. package/dist/chunk-7GHM4GKL.cjs +119 -0
  24. package/dist/chunk-7YF5NAHQ.cjs +74 -0
  25. package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
  26. package/dist/chunk-ABAGZTXZ.cjs +736 -0
  27. package/dist/{chunk-AW63PTQ4.cjs → chunk-ACAPTWE3.cjs} +85 -81
  28. package/dist/chunk-AMCSSOJT.cjs +104 -0
  29. package/dist/chunk-BA2DBSAN.js +102 -0
  30. package/dist/chunk-BRRXFOBY.js +431 -0
  31. package/dist/chunk-C5YLPCFC.cjs +293 -0
  32. package/dist/chunk-DA3OKXHV.cjs +700 -0
  33. package/dist/chunk-DD4276RF.js +366 -0
  34. package/dist/chunk-DG2I4PJG.js +701 -0
  35. package/dist/chunk-DHGLGSH6.js +661 -0
  36. package/dist/chunk-DIBUQ46Y.js +346 -0
  37. package/dist/chunk-EGLLDKN6.js +9 -0
  38. package/dist/chunk-EJQCQPET.cjs +9 -0
  39. package/dist/chunk-EKS3W46M.cjs +66 -0
  40. package/dist/chunk-EZEYMLO3.js +402 -0
  41. package/dist/chunk-F6CQ6CBI.cjs +112 -0
  42. package/dist/chunk-F6W3JQ7K.js +42 -0
  43. package/dist/chunk-FHUYHV6J.js +89 -0
  44. package/dist/chunk-FNEUOBCV.cjs +174 -0
  45. package/dist/chunk-G3CCT4EY.js +518 -0
  46. package/dist/chunk-G7P3ERYF.cjs +478 -0
  47. package/dist/chunk-GA6PBWNT.js +147 -0
  48. package/dist/chunk-GFUZ3MUT.cjs +455 -0
  49. package/dist/chunk-GGW43Q37.cjs +1 -0
  50. package/dist/chunk-GTR5X65M.cjs +27 -0
  51. package/dist/chunk-H4E4HDEP.cjs +13 -0
  52. package/dist/chunk-H7DS4IO7.js +198 -0
  53. package/dist/chunk-HDVVZG4S.cjs +198 -0
  54. package/dist/chunk-IKJVLJKT.js +151 -0
  55. package/dist/chunk-J3MB4PI5.cjs +531 -0
  56. package/dist/chunk-K72UDPVN.js +119 -0
  57. package/dist/chunk-KCMYU7WF.js +86 -0
  58. package/dist/chunk-LRN3RNDO.js +940 -0
  59. package/dist/chunk-LTX6TB5I.js +124 -0
  60. package/dist/chunk-LUPCPLND.cjs +145 -0
  61. package/dist/chunk-M63GFNKV.js +194 -0
  62. package/dist/chunk-N3KTZMPG.js +293 -0
  63. package/dist/chunk-NCTOTTVW.js +13 -0
  64. package/dist/chunk-NWGLP6JX.cjs +410 -0
  65. package/dist/chunk-R73XQK7X.cjs +314 -0
  66. package/dist/chunk-RU7JCMWC.cjs +881 -0
  67. package/dist/chunk-SNIHUKDA.cjs +184 -0
  68. package/dist/chunk-T5FV5F7A.cjs +607 -0
  69. package/dist/chunk-TDTUAIFF.cjs +153 -0
  70. package/dist/chunk-TJ74XVZN.cjs +431 -0
  71. package/dist/chunk-TK44VBIE.cjs +194 -0
  72. package/dist/chunk-UAWBAD4E.cjs +346 -0
  73. package/dist/chunk-UFTCTTKK.js +381 -0
  74. package/dist/chunk-VLKBESEV.cjs +407 -0
  75. package/dist/chunk-WDDXU3OH.cjs +67 -0
  76. package/dist/chunk-WFEMJCXO.cjs +13 -0
  77. package/dist/chunk-WHJTBTYM.js +0 -0
  78. package/dist/{chunk-2KXQATVL.js → chunk-WKCQ6VGW.js} +59 -55
  79. package/dist/chunk-XFPQFCEK.js +455 -0
  80. package/dist/chunk-XSQPVDFH.cjs +60 -0
  81. package/dist/chunk-XTC2SLFT.js +153 -0
  82. package/dist/chunk-XV735BSA.cjs +366 -0
  83. package/dist/chunk-XWNG2U4K.cjs +124 -0
  84. package/dist/chunk-YGYYJ3LQ.js +314 -0
  85. package/dist/chunk-YVHT2UVW.js +74 -0
  86. package/dist/chunk-ZFOOJK37.cjs +86 -0
  87. package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
  88. package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
  89. package/dist/components/accordion/index.cjs +35 -0
  90. package/dist/components/accordion/index.d.cts +299 -0
  91. package/dist/components/accordion/index.d.ts +299 -0
  92. package/dist/components/accordion/index.js +35 -0
  93. package/dist/components/alert/index.cjs +20 -0
  94. package/dist/components/alert/index.d.cts +169 -0
  95. package/dist/components/alert/index.d.ts +169 -0
  96. package/dist/components/alert/index.js +20 -0
  97. package/dist/components/avatar/index.cjs +16 -0
  98. package/dist/components/avatar/index.d.cts +131 -0
  99. package/dist/components/avatar/index.d.ts +131 -0
  100. package/dist/components/avatar/index.js +16 -0
  101. package/dist/components/badge/index.cjs +15 -0
  102. package/dist/components/badge/index.d.cts +157 -0
  103. package/dist/components/badge/index.d.ts +157 -0
  104. package/dist/components/badge/index.js +15 -0
  105. package/dist/components/button/index.cjs +22 -0
  106. package/dist/components/button/index.d.cts +613 -0
  107. package/dist/components/button/index.d.ts +613 -0
  108. package/dist/components/button/index.js +22 -0
  109. package/dist/components/card/index.cjs +22 -0
  110. package/dist/components/card/index.d.cts +620 -0
  111. package/dist/components/card/index.d.ts +620 -0
  112. package/dist/components/card/index.js +22 -0
  113. package/dist/components/checkbox/index.cjs +26 -0
  114. package/dist/components/checkbox/index.d.cts +1136 -0
  115. package/dist/components/checkbox/index.d.ts +1136 -0
  116. package/dist/components/checkbox/index.js +26 -0
  117. package/dist/components/chip/index.cjs +20 -0
  118. package/dist/components/chip/index.d.cts +608 -0
  119. package/dist/components/chip/index.d.ts +608 -0
  120. package/dist/components/chip/index.js +20 -0
  121. package/dist/components/divider/index.cjs +13 -0
  122. package/dist/components/divider/index.d.cts +117 -0
  123. package/dist/components/divider/index.d.ts +117 -0
  124. package/dist/components/divider/index.js +13 -0
  125. package/dist/components/field-group/index.cjs +27 -0
  126. package/dist/components/field-group/index.d.cts +270 -0
  127. package/dist/components/field-group/index.d.ts +270 -0
  128. package/dist/components/field-group/index.js +27 -0
  129. package/dist/components/input-otp/index.cjs +29 -0
  130. package/dist/components/input-otp/index.d.cts +325 -0
  131. package/dist/components/input-otp/index.d.ts +325 -0
  132. package/dist/components/input-otp/index.js +29 -0
  133. package/dist/components/menu/index.cjs +49 -0
  134. package/dist/components/menu/index.d.cts +351 -0
  135. package/dist/components/menu/index.d.ts +351 -0
  136. package/dist/components/menu/index.js +49 -0
  137. package/dist/components/popover/index.cjs +38 -0
  138. package/dist/components/popover/index.d.cts +254 -0
  139. package/dist/components/popover/index.d.ts +254 -0
  140. package/dist/components/popover/index.js +38 -0
  141. package/dist/components/radio/index.cjs +26 -0
  142. package/dist/components/radio/index.d.cts +1102 -0
  143. package/dist/components/radio/index.d.ts +1102 -0
  144. package/dist/components/radio/index.js +26 -0
  145. package/dist/components/select/index.cjs +50 -0
  146. package/dist/components/select/index.d.cts +498 -0
  147. package/dist/components/select/index.d.ts +498 -0
  148. package/dist/components/select/index.js +50 -0
  149. package/dist/components/skeleton/index.cjs +11 -0
  150. package/dist/components/skeleton/index.d.cts +111 -0
  151. package/dist/components/skeleton/index.d.ts +111 -0
  152. package/dist/components/skeleton/index.js +11 -0
  153. package/dist/components/spinner/index.cjs +17 -0
  154. package/dist/components/spinner/index.d.cts +104 -0
  155. package/dist/components/spinner/index.d.ts +104 -0
  156. package/dist/components/spinner/index.js +17 -0
  157. package/dist/components/switch/index.cjs +27 -0
  158. package/dist/components/switch/index.d.cts +1154 -0
  159. package/dist/components/switch/index.d.ts +1154 -0
  160. package/dist/components/switch/index.js +27 -0
  161. package/dist/components/tabs/index.cjs +33 -0
  162. package/dist/components/tabs/index.d.cts +261 -0
  163. package/dist/components/tabs/index.d.ts +261 -0
  164. package/dist/components/tabs/index.js +33 -0
  165. package/dist/components/text-area/index.cjs +14 -0
  166. package/dist/components/text-area/index.d.cts +73 -0
  167. package/dist/components/text-area/index.d.ts +73 -0
  168. package/dist/components/text-area/index.js +14 -0
  169. package/dist/components/text-field/index.cjs +25 -0
  170. package/dist/components/text-field/index.d.cts +205 -0
  171. package/dist/components/text-field/index.d.ts +205 -0
  172. package/dist/components/text-field/index.js +25 -0
  173. package/dist/components/typography/index.cjs +15 -0
  174. package/dist/components/typography/index.d.cts +116 -0
  175. package/dist/components/typography/index.d.ts +116 -0
  176. package/dist/components/typography/index.js +15 -0
  177. package/dist/components/view/index.cjs +17 -0
  178. package/dist/components/view/index.d.cts +152 -0
  179. package/dist/components/view/index.d.ts +152 -0
  180. package/dist/components/view/index.js +17 -0
  181. package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
  182. package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
  183. package/dist/icon.type-Kml72iSz.d.ts +73 -0
  184. package/dist/icon.type-d_i9ma-i.d.cts +73 -0
  185. package/dist/index.cjs +423 -5
  186. package/dist/index.d.cts +119 -4
  187. package/dist/index.d.ts +119 -4
  188. package/dist/index.js +445 -27
  189. package/dist/placement-DHa0Rrh1.d.cts +38 -0
  190. package/dist/placement-DHa0Rrh1.d.ts +38 -0
  191. package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
  192. package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
  193. package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
  194. package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
  195. package/dist/system/index.cjs +73 -4
  196. package/dist/system/index.d.cts +379 -193
  197. package/dist/system/index.d.ts +379 -193
  198. package/dist/system/index.js +87 -18
  199. package/dist/text-field.type-0l73acce.d.ts +167 -0
  200. package/dist/text-field.type-DBh06DU5.d.cts +167 -0
  201. package/dist/theme/index.cjs +5 -3
  202. package/dist/theme/index.d.cts +55 -24
  203. package/dist/theme/index.d.ts +55 -24
  204. package/dist/theme/index.js +4 -2
  205. package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
  206. package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
  207. package/package.json +264 -18
  208. package/dist/chunk-ECDWSSHJ.js +0 -688
  209. package/dist/chunk-IYFGO523.cjs +0 -688
@@ -0,0 +1,701 @@
1
+ import { useControllableState } from "./chunk-F6W3JQ7K.js";
2
+ import { createRecipe, radiusAxis } from "./chunk-4GTAZM2C.js";
3
+ import { useXAUITheme } from "./chunk-A3EGFI6T.js";
4
+ import { createSlotContext } from "./chunk-K72UDPVN.js";
5
+ import { useStyleProps } from "./chunk-M63GFNKV.js";
6
+
7
+ // src/components/input-otp/input-otp-box.tsx
8
+ import { forwardRef as forwardRef3, useMemo } from "react";
9
+ import { View as View2 } from "react-native";
10
+
11
+ // src/components/input-otp/input-otp.context.ts
12
+ var [InputOTPProvider, useInputOTP] = createSlotContext("InputOTP");
13
+ var [InputOTPBoxProvider, useInputOTPBox] = createSlotContext("InputOTP.Box");
14
+
15
+ // src/components/input-otp/input-otp-caret.tsx
16
+ import { useEffect } from "react";
17
+ import { View } from "react-native";
18
+ import Animated, { Easing, cancelAnimation, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from "react-native-reanimated";
19
+ import { jsx } from "react/jsx-runtime";
20
+ var BLINK_DURATION = 530;
21
+ function InputOTPCaret({
22
+ style,
23
+ animation = true,
24
+ ...props
25
+ }) {
26
+ const {
27
+ caretStyle
28
+ } = useInputOTP();
29
+ const {
30
+ slot
31
+ } = useInputOTPBox();
32
+ const [styleProps] = useStyleProps(props);
33
+ const barStyle = [caretStyle, styleProps, style];
34
+ if (!slot?.isCaretVisible) return null;
35
+ if (!animation) return /* @__PURE__ */jsx(View, {
36
+ style: barStyle
37
+ });
38
+ return /* @__PURE__ */jsx(BlinkingCaret, {
39
+ style: barStyle
40
+ });
41
+ }
42
+ InputOTPCaret.displayName = "XAUI.InputOTP.Caret";
43
+ const _worklet_16670090179149_init_data = {
44
+ code: "function chunkDG2I4PJGJs1(){const{opacity}=this.__closure;return{opacity:opacity.value};}",
45
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-DG2I4PJG.js",
46
+ sourceMap: "{\"version\":3,\"names\":[\"chunkDG2I4PJGJs1\",\"opacity\",\"__closure\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-DG2I4PJG.js\"],\"mappings\":\"AA8DyC,SAAAA,gBAAMA,CAAA,QAAAC,OAAA,OAAAC,SAAA,CAE3C,MAAO,CAAED,OAAO,CAAEA,OAAO,CAACE,KAAM,CAAC,CACnC\",\"ignoreList\":[]}"
47
+ };
48
+ function BlinkingCaret({
49
+ style
50
+ }) {
51
+ const opacity = useSharedValue(1);
52
+ useEffect(() => {
53
+ opacity.value = withRepeat(withTiming(0, {
54
+ duration: BLINK_DURATION,
55
+ easing: Easing.ease
56
+ }), -1, true);
57
+ return () => cancelAnimation(opacity);
58
+ }, [opacity]);
59
+ const animatedStyle = useAnimatedStyle(function chunkDG2I4PJGJs1Factory({
60
+ _worklet_16670090179149_init_data,
61
+ opacity
62
+ }) {
63
+ const _e = [new global.Error(), -2, -27];
64
+ const chunkDG2I4PJGJs1 = function () {
65
+ return {
66
+ opacity: opacity.value
67
+ };
68
+ };
69
+ chunkDG2I4PJGJs1.__closure = {
70
+ opacity
71
+ };
72
+ chunkDG2I4PJGJs1.__workletHash = 16670090179149;
73
+ chunkDG2I4PJGJs1.__pluginVersion = "0.7.4";
74
+ chunkDG2I4PJGJs1.__initData = _worklet_16670090179149_init_data;
75
+ chunkDG2I4PJGJs1.__stackDetails = _e;
76
+ return chunkDG2I4PJGJs1;
77
+ }({
78
+ _worklet_16670090179149_init_data,
79
+ opacity
80
+ }), [opacity]);
81
+ return /* @__PURE__ */jsx(Animated.View, {
82
+ style: [style, animatedStyle]
83
+ });
84
+ }
85
+
86
+ // src/components/input-otp/input-otp-placeholder.tsx
87
+ import { forwardRef } from "react";
88
+ import { Text } from "react-native";
89
+ import { jsx as jsx2 } from "react/jsx-runtime";
90
+ var InputOTPPlaceholder = forwardRef(function InputOTPPlaceholder2({
91
+ children,
92
+ style,
93
+ maxFontSizeMultiplier = 1.6,
94
+ ...props
95
+ }, ref) {
96
+ const {
97
+ placeholderStyle
98
+ } = useInputOTP();
99
+ const {
100
+ slot
101
+ } = useInputOTPBox();
102
+ const [styleProps, rest] = useStyleProps(props);
103
+ const char = children ?? slot?.placeholderChar;
104
+ if (!char) return null;
105
+ return /* @__PURE__ */jsx2(Text, {
106
+ ref,
107
+ maxFontSizeMultiplier,
108
+ style: [placeholderStyle, styleProps, style],
109
+ ...rest,
110
+ children: char
111
+ });
112
+ });
113
+ InputOTPPlaceholder.displayName = "XAUI.InputOTP.Placeholder";
114
+
115
+ // src/components/input-otp/input-otp-value.tsx
116
+ import { forwardRef as forwardRef2 } from "react";
117
+ import { Text as Text2 } from "react-native";
118
+ import { jsx as jsx3 } from "react/jsx-runtime";
119
+ var InputOTPValue = forwardRef2(function InputOTPValue2({
120
+ children,
121
+ style,
122
+ maxFontSizeMultiplier = 1.6,
123
+ ...props
124
+ }, ref) {
125
+ const {
126
+ valueStyle
127
+ } = useInputOTP();
128
+ const {
129
+ slot
130
+ } = useInputOTPBox();
131
+ const [styleProps, rest] = useStyleProps(props);
132
+ const char = children ?? slot?.char;
133
+ if (!char) return null;
134
+ return /* @__PURE__ */jsx3(Text2, {
135
+ ref,
136
+ maxFontSizeMultiplier,
137
+ style: [valueStyle, styleProps, style],
138
+ ...rest,
139
+ children: char
140
+ });
141
+ });
142
+ InputOTPValue.displayName = "XAUI.InputOTP.Value";
143
+
144
+ // src/components/input-otp/input-otp-box.tsx
145
+ import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
146
+ var InputOTPBox = forwardRef3(function InputOTPBox2({
147
+ index,
148
+ children,
149
+ style,
150
+ ...props
151
+ }, ref) {
152
+ const {
153
+ boxStyle,
154
+ boxActiveStyle,
155
+ slots
156
+ } = useInputOTP();
157
+ const [styleProps, rest] = useStyleProps(props);
158
+ const slot = slots[index];
159
+ const context = useMemo(() => ({
160
+ slot
161
+ }), [slot]);
162
+ return /* @__PURE__ */jsx4(InputOTPBoxProvider, {
163
+ value: context,
164
+ children: /* @__PURE__ */jsx4(View2, {
165
+ ref,
166
+ style: [slot?.isActive ? boxActiveStyle : boxStyle, styleProps, style],
167
+ ...rest,
168
+ children: children ?? /* @__PURE__ */jsxs(Fragment, {
169
+ children: [/* @__PURE__ */jsx4(InputOTPPlaceholder, {}), /* @__PURE__ */jsx4(InputOTPValue, {}), /* @__PURE__ */jsx4(InputOTPCaret, {})]
170
+ })
171
+ })
172
+ });
173
+ });
174
+ InputOTPBox.displayName = "XAUI.InputOTP.Box";
175
+
176
+ // src/components/input-otp/input-otp-group.tsx
177
+ import { forwardRef as forwardRef4 } from "react";
178
+ import { View as View3 } from "react-native";
179
+ import { jsx as jsx5 } from "react/jsx-runtime";
180
+ var InputOTPGroup = forwardRef4(function InputOTPGroup2({
181
+ children,
182
+ style,
183
+ ...props
184
+ }, ref) {
185
+ const {
186
+ groupStyle,
187
+ slots,
188
+ value,
189
+ maxLength,
190
+ isFocused,
191
+ isDisabled,
192
+ isInvalid
193
+ } = useInputOTP();
194
+ const [styleProps, rest] = useStyleProps(props);
195
+ const content = typeof children === "function" ? children({
196
+ slots,
197
+ value,
198
+ maxLength,
199
+ isFocused,
200
+ isDisabled,
201
+ isInvalid
202
+ }) : children;
203
+ return /* @__PURE__ */jsx5(View3, {
204
+ ref,
205
+ style: [groupStyle, styleProps, style],
206
+ ...rest,
207
+ children: content
208
+ });
209
+ });
210
+ InputOTPGroup.displayName = "XAUI.InputOTP.Group";
211
+
212
+ // src/components/input-otp/input-otp-separator.tsx
213
+ import { forwardRef as forwardRef5 } from "react";
214
+ import { View as View4 } from "react-native";
215
+ import { jsx as jsx6 } from "react/jsx-runtime";
216
+ var InputOTPSeparator = forwardRef5(function InputOTPSeparator2({
217
+ children,
218
+ style,
219
+ ...props
220
+ }, ref) {
221
+ const {
222
+ separatorStyle
223
+ } = useInputOTP();
224
+ const [styleProps, rest] = useStyleProps(props);
225
+ return /* @__PURE__ */jsx6(View4, {
226
+ ref,
227
+ accessibilityElementsHidden: true,
228
+ importantForAccessibility: "no-hide-descendants",
229
+ style: [separatorStyle, styleProps, style],
230
+ ...rest,
231
+ children
232
+ });
233
+ });
234
+ InputOTPSeparator.displayName = "XAUI.InputOTP.Separator";
235
+
236
+ // src/components/input-otp/input-otp.tsx
237
+ import { forwardRef as forwardRef6, useImperativeHandle, useMemo as useMemo3 } from "react";
238
+ import { TextInput, View as View5 } from "react-native";
239
+
240
+ // src/components/input-otp/input-otp.hook.ts
241
+ import { useCallback, useMemo as useMemo2, useRef, useState } from "react";
242
+
243
+ // src/components/input-otp/input-otp.utils.ts
244
+ function buildSlots({
245
+ value,
246
+ maxLength,
247
+ isFocused,
248
+ placeholder
249
+ }) {
250
+ return Array.from({
251
+ length: maxLength
252
+ }, (_, index) => {
253
+ const char = value[index] ?? null;
254
+ const isActive = isFocused && index === value.length;
255
+ return {
256
+ index,
257
+ char,
258
+ // A box shows its placeholder only when it has neither a character nor the caret.
259
+ placeholderChar: char === null && !isActive ? placeholderFor(placeholder, index) : null,
260
+ isActive,
261
+ isCaretVisible: isActive && char === null
262
+ };
263
+ });
264
+ }
265
+ function placeholderFor(placeholder, index) {
266
+ if (!placeholder) return null;
267
+ return placeholder.length === 1 ? placeholder : placeholder[index] ?? null;
268
+ }
269
+ function extractPastedCode(pasted, maxLength) {
270
+ const match = pasted.match(new RegExp(`(?<!\\d)(\\d{${maxLength}})(?!\\d)`));
271
+ return match?.[1] ?? "";
272
+ }
273
+ function isPaste(text, previous) {
274
+ return text.length > previous.length + 1;
275
+ }
276
+ var OTP_DIGITS = "^\\d+$";
277
+ var OTP_LETTERS = "^[a-zA-Z]+$";
278
+ var OTP_ALPHANUMERIC = "^[a-zA-Z0-9]+$";
279
+
280
+ // src/components/input-otp/input-otp.hook.ts
281
+ function useInputOTPState({
282
+ maxLength,
283
+ value: valueProp,
284
+ defaultValue = "",
285
+ onChangeText: onChangeTextProp,
286
+ onComplete,
287
+ pattern,
288
+ placeholder
289
+ }) {
290
+ const [value, setValue] = useControllableState({
291
+ value: valueProp,
292
+ defaultValue,
293
+ onChange: onChangeTextProp
294
+ });
295
+ const [isFocused, setIsFocused] = useState(false);
296
+ const inputRef = useRef(null);
297
+ const regexp = useMemo2(() => {
298
+ if (!pattern) return null;
299
+ return typeof pattern === "string" ? new RegExp(pattern) : pattern;
300
+ }, [pattern]);
301
+ const slots = useMemo2(() => buildSlots({
302
+ value,
303
+ maxLength,
304
+ isFocused,
305
+ placeholder
306
+ }), [value, maxLength, isFocused, placeholder]);
307
+ const latest = useRef({
308
+ value,
309
+ maxLength,
310
+ regexp,
311
+ onComplete,
312
+ setValue
313
+ });
314
+ latest.current = {
315
+ value,
316
+ maxLength,
317
+ regexp,
318
+ onComplete,
319
+ setValue
320
+ };
321
+ const onChangeText = useCallback(text => {
322
+ const current = latest.current;
323
+ const candidate = isPaste(text, current.value) ? extractPastedCode(text, current.maxLength) : text;
324
+ const next = candidate.slice(0, current.maxLength);
325
+ if (next.length > 0 && current.regexp && !current.regexp.test(next)) return;
326
+ current.setValue(next);
327
+ if (next.length === current.maxLength) current.onComplete?.(next);
328
+ }, []);
329
+ const onFocus = useCallback(() => setIsFocused(true), []);
330
+ const onBlur = useCallback(() => setIsFocused(false), []);
331
+ const handle = useMemo2(() => ({
332
+ focus: () => inputRef.current?.focus(),
333
+ blur: () => inputRef.current?.blur(),
334
+ // Both halves: the native buffer and our value. Clearing one and not the other is
335
+ // how a cleared field comes back on the next keystroke.
336
+ clear: () => {
337
+ inputRef.current?.clear();
338
+ latest.current.setValue("");
339
+ }
340
+ }), []);
341
+ return {
342
+ value,
343
+ slots,
344
+ isFocused,
345
+ inputRef,
346
+ handle,
347
+ onChangeText,
348
+ onFocus,
349
+ onBlur
350
+ };
351
+ }
352
+
353
+ // src/components/input-otp/input-otp.recipe.ts
354
+ var SLOTS = ["root", "group", "box", "value", "placeholder", "caret", "separator"];
355
+ var VARIANT_TOKENS = {
356
+ primary: {
357
+ bg: "fieldBackground",
358
+ border: "fieldBorder",
359
+ borderFocus: "accent",
360
+ fg: "fieldForeground"
361
+ },
362
+ secondary: {
363
+ bg: "default",
364
+ border: "fieldBorder",
365
+ borderFocus: "accent",
366
+ fg: "fieldForeground"
367
+ },
368
+ tertiary: {
369
+ border: "fieldBorder",
370
+ borderFocus: "accent",
371
+ fg: "fieldForeground"
372
+ }
373
+ };
374
+ var PLACEHOLDER_OPACITY = 0.5;
375
+ var ACTIVE_BORDER_WIDTH = 2;
376
+ function sizeAxis(step) {
377
+ const {
378
+ control,
379
+ gap,
380
+ glyph
381
+ } = step;
382
+ return theme => {
383
+ const height = theme.controlHeights[control];
384
+ const type = {
385
+ fontSize: theme.fontSizes[glyph],
386
+ lineHeight: theme.lineHeights[glyph]
387
+ };
388
+ return {
389
+ root: {
390
+ gap: theme.spacing(gap)
391
+ },
392
+ group: {
393
+ gap: theme.spacing(gap)
394
+ },
395
+ box: {
396
+ height,
397
+ width: height - theme.spacing(1)
398
+ },
399
+ value: type,
400
+ placeholder: type,
401
+ // As tall as the character it stands in for, so the box does not change shape
402
+ // between an empty state and a typed one.
403
+ caret: {
404
+ height: theme.lineHeights[glyph],
405
+ width: theme.spacing(CARET_WIDTH)
406
+ },
407
+ separator: {
408
+ height: theme.spacing(CARET_WIDTH),
409
+ width: theme.spacing(SEPARATOR_WIDTH)
410
+ }
411
+ };
412
+ };
413
+ }
414
+ var CARET_WIDTH = 0.5;
415
+ var SEPARATOR_WIDTH = 2;
416
+ var SIZES = {
417
+ sm: {
418
+ control: "sm",
419
+ gap: 2,
420
+ glyph: "md"
421
+ },
422
+ md: {
423
+ control: "md",
424
+ gap: 2,
425
+ glyph: "lg"
426
+ },
427
+ lg: {
428
+ control: "lg",
429
+ gap: 2.5,
430
+ glyph: "xl"
431
+ }
432
+ };
433
+ var inputOTPRecipe = createRecipe({
434
+ slots: SLOTS,
435
+ base: theme => ({
436
+ root: {
437
+ flexDirection: "row",
438
+ alignItems: "center"
439
+ },
440
+ group: {
441
+ flexDirection: "row",
442
+ alignItems: "center"
443
+ },
444
+ box: {
445
+ alignItems: "center",
446
+ justifyContent: "center",
447
+ // `lg` and not `field`, though the two are the same twelve points at the default
448
+ // base. The keys are kept apart on purpose: `field` is the corner a theme moves when
449
+ // it wants rounder *fields*, and a field is wide — a code box is very nearly square,
450
+ // 44 by 48 at `md`, where the geometric maximum is 22 and anything near it is a pill
451
+ // in all but name. Following `field` here would hand this component a shape that was
452
+ // never decided for it.
453
+ borderRadius: theme.radius.lg,
454
+ borderCurve: "continuous",
455
+ // The one root in the library that clips: the box has no shadow to lose and a
456
+ // character wider than it would otherwise spill onto its neighbour.
457
+ overflow: "hidden"
458
+ },
459
+ // `semibold`, where a field's own text is `regular`. A code is read at a glance and
460
+ // then compared character by character, which is the one thing weight helps with.
461
+ value: {
462
+ fontFamily: theme.fontFamilies.body,
463
+ fontWeight: theme.fontWeights.semibold
464
+ },
465
+ placeholder: {
466
+ fontFamily: theme.fontFamilies.body,
467
+ fontWeight: theme.fontWeights.semibold,
468
+ color: theme.colors.fieldPlaceholder,
469
+ opacity: PLACEHOLDER_OPACITY
470
+ },
471
+ caret: {
472
+ position: "absolute",
473
+ borderRadius: theme.radius.full,
474
+ backgroundColor: theme.colors.fieldPlaceholder
475
+ },
476
+ // The theme's second separator level rather than the first at half opacity: it is
477
+ // already the lighter of the two, and it composites the same way in both modes.
478
+ separator: {
479
+ borderRadius: theme.radius.full,
480
+ backgroundColor: theme.colors.separatorSecondary
481
+ }
482
+ }),
483
+ variantTokens: VARIANT_TOKENS,
484
+ /**
485
+ * Where the variant's colours land. The border width follows the *presence* of the
486
+ * border role, so a variant that names none needs no rule of its own to say so.
487
+ *
488
+ * The active box takes the ring whichever variant it is: the `focused` state sets the
489
+ * width as well as the colour. The box has a fixed width and height and centres what it
490
+ * holds, so an edge appearing moves nothing.
491
+ */
492
+ paint: (theme, colors) => ({
493
+ box: {
494
+ backgroundColor: colors.bg,
495
+ borderColor: colors.border,
496
+ borderWidth: colors.border ? theme.borderWidth.field : 0
497
+ },
498
+ value: {
499
+ color: colors.fg
500
+ }
501
+ }),
502
+ variants: {
503
+ size: {
504
+ sm: sizeAxis(SIZES.sm),
505
+ md: sizeAxis(SIZES.md),
506
+ lg: sizeAxis(SIZES.lg)
507
+ },
508
+ radius: radiusAxis("box"),
509
+ /**
510
+ * Declared after `size` and before the states, so a code that is wrong stays wrong
511
+ * under the finger: the ring below reads `borderFocus`, and the root hands it the
512
+ * danger colour by suppressing the active state and painting every box instead.
513
+ */
514
+ isInvalid: {
515
+ true: theme => ({
516
+ box: {
517
+ borderColor: theme.colors.danger,
518
+ borderWidth: ACTIVE_BORDER_WIDTH
519
+ }
520
+ })
521
+ }
522
+ },
523
+ compoundVariants: [{
524
+ when: {
525
+ variant: "primary"
526
+ },
527
+ style: theme => ({
528
+ box: theme.shadows.field
529
+ })
530
+ }],
531
+ /**
532
+ * `focused` here means **this box is the active one**, not that the component has the
533
+ * keyboard: the root resolves the recipe twice, once each way, and hands both to the
534
+ * boxes so none of them resolves anything itself (R5).
535
+ */
536
+ states: {
537
+ focused: (_theme, colors) => ({
538
+ box: {
539
+ borderColor: colors.borderFocus,
540
+ borderWidth: ACTIVE_BORDER_WIDTH
541
+ }
542
+ }),
543
+ disabled: theme => ({
544
+ root: {
545
+ opacity: theme.opacity.disabled
546
+ }
547
+ })
548
+ },
549
+ defaultVariants: {
550
+ variant: "secondary",
551
+ size: "md"
552
+ }
553
+ });
554
+
555
+ // src/components/input-otp/input-otp.style.ts
556
+ import { Platform, StyleSheet } from "react-native";
557
+ var inputOTPSheet = StyleSheet.create({
558
+ hiddenInput: {
559
+ ...StyleSheet.absoluteFillObject,
560
+ color: "transparent",
561
+ // A caret of our own is drawn in the active box; the platform's would sit wherever
562
+ // the invisible text happens to end.
563
+ ...Platform.select({
564
+ ios: {
565
+ opacity: 0.02
566
+ },
567
+ default: {
568
+ opacity: 0
569
+ }
570
+ })
571
+ }
572
+ });
573
+
574
+ // src/components/input-otp/input-otp.tsx
575
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
576
+ var InputOTPRoot = forwardRef6(function InputOTP({
577
+ children,
578
+ maxLength,
579
+ variant,
580
+ size,
581
+ radius,
582
+ color,
583
+ value: valueProp,
584
+ defaultValue,
585
+ onChangeText,
586
+ onComplete,
587
+ pattern,
588
+ placeholder,
589
+ isInvalid = false,
590
+ isDisabled = false,
591
+ inputMode = "numeric",
592
+ textInputProps,
593
+ style,
594
+ ...props
595
+ }, ref) {
596
+ const theme = useXAUITheme();
597
+ const [styleProps, rest] = useStyleProps(props);
598
+ const state = useInputOTPState({
599
+ maxLength,
600
+ value: valueProp,
601
+ defaultValue,
602
+ onChangeText,
603
+ onComplete,
604
+ pattern,
605
+ placeholder
606
+ });
607
+ useImperativeHandle(ref, () => state.handle, [state.handle]);
608
+ const selection = {
609
+ variant,
610
+ size,
611
+ radius,
612
+ isInvalid: isInvalid ? "true" : void 0
613
+ };
614
+ const states = {
615
+ disabled: isDisabled
616
+ };
617
+ const styles = inputOTPRecipe.resolve({
618
+ theme,
619
+ selection,
620
+ states
621
+ });
622
+ const activeStyles = isInvalid ? styles : inputOTPRecipe.resolve({
623
+ theme,
624
+ selection,
625
+ states: {
626
+ ...states,
627
+ focused: true
628
+ }
629
+ });
630
+ const tint = color ? inputOTPRecipe.tint({
631
+ theme,
632
+ color,
633
+ selection,
634
+ states
635
+ }) : void 0;
636
+ const activeTint = color && !isInvalid ? inputOTPRecipe.tint({
637
+ theme,
638
+ color,
639
+ selection,
640
+ states: {
641
+ ...states,
642
+ focused: true
643
+ }
644
+ }) : tint;
645
+ const context = useMemo3(() => ({
646
+ groupStyle: styles.group,
647
+ boxStyle: tint ? [styles.box, tint.box] : styles.box,
648
+ boxActiveStyle: activeTint ? [activeStyles.box, activeTint.box] : activeStyles.box,
649
+ valueStyle: tint ? [styles.value, tint.value] : styles.value,
650
+ placeholderStyle: styles.placeholder,
651
+ caretStyle: styles.caret,
652
+ separatorStyle: styles.separator,
653
+ slots: state.slots,
654
+ value: state.value,
655
+ maxLength,
656
+ isFocused: state.isFocused,
657
+ isDisabled,
658
+ isInvalid,
659
+ inputRef: state.inputRef
660
+ }), [styles, activeStyles, tint, activeTint, state.slots, state.value, state.isFocused, state.inputRef, maxLength, isDisabled, isInvalid]);
661
+ return /* @__PURE__ */jsx7(InputOTPProvider, {
662
+ value: context,
663
+ children: /* @__PURE__ */jsxs2(View5, {
664
+ style: [styles.root, tint?.root, styleProps, style],
665
+ ...rest,
666
+ children: [children, /* @__PURE__ */jsx7(TextInput, {
667
+ ref: state.inputRef,
668
+ style: inputOTPSheet.hiddenInput,
669
+ value: state.value,
670
+ onChangeText: state.onChangeText,
671
+ onFocus: state.onFocus,
672
+ onBlur: state.onBlur,
673
+ editable: !isDisabled,
674
+ inputMode,
675
+ caretHidden: true,
676
+ autoComplete: "one-time-code",
677
+ textContentType: "oneTimeCode",
678
+ accessibilityLabel: `${maxLength}-character code`,
679
+ accessibilityState: {
680
+ disabled: isDisabled
681
+ },
682
+ accessibilityValue: {
683
+ text: `${state.value.length} of ${maxLength} entered`
684
+ },
685
+ ...textInputProps
686
+ })]
687
+ })
688
+ });
689
+ });
690
+ InputOTPRoot.displayName = "XAUI.InputOTP.Root";
691
+
692
+ // src/components/input-otp/index.ts
693
+ var InputOTP2 = Object.assign(InputOTPRoot, {
694
+ Group: InputOTPGroup,
695
+ Box: InputOTPBox,
696
+ Value: InputOTPValue,
697
+ Placeholder: InputOTPPlaceholder,
698
+ Caret: InputOTPCaret,
699
+ Separator: InputOTPSeparator
700
+ });
701
+ export { useInputOTP, useInputOTPBox, buildSlots, extractPastedCode, OTP_DIGITS, OTP_LETTERS, OTP_ALPHANUMERIC, inputOTPRecipe, InputOTP2 as InputOTP };