@xaui/native 0.2.8 → 0.9.1-alpha.1

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 (234) hide show
  1. package/dist/chunk-KFCORXWW.cjs +150 -0
  2. package/dist/chunk-M7P46XKI.cjs +100 -0
  3. package/dist/chunk-N357EQCZ.js +150 -0
  4. package/dist/chunk-NHPQQQ7P.cjs +734 -0
  5. package/dist/chunk-PBVPOX7D.js +734 -0
  6. package/dist/chunk-RBNCR5KB.js +100 -0
  7. package/dist/index.cjs +40 -1
  8. package/dist/index.d.cts +5 -2
  9. package/dist/index.d.ts +5 -2
  10. package/dist/index.js +40 -0
  11. package/dist/system/index.cjs +7 -0
  12. package/dist/system/index.d.cts +83 -0
  13. package/dist/system/index.d.ts +83 -0
  14. package/dist/system/index.js +7 -0
  15. package/dist/theme/index.cjs +36 -0
  16. package/dist/theme/index.d.cts +539 -0
  17. package/dist/theme/index.d.ts +539 -0
  18. package/dist/theme/index.js +36 -0
  19. package/dist/theme.type-B3ODSLbB.d.cts +153 -0
  20. package/dist/theme.type-B3ODSLbB.d.ts +153 -0
  21. package/package.json +30 -248
  22. package/README.md +0 -178
  23. package/dist/alert/index.cjs +0 -340
  24. package/dist/alert/index.d.cts +0 -46
  25. package/dist/alert/index.d.ts +0 -46
  26. package/dist/alert/index.js +0 -340
  27. package/dist/app-bar/index.cjs +0 -148
  28. package/dist/app-bar/index.d.cts +0 -59
  29. package/dist/app-bar/index.d.ts +0 -59
  30. package/dist/app-bar/index.js +0 -148
  31. package/dist/autocomplete/index.cjs +0 -1122
  32. package/dist/autocomplete/index.d.cts +0 -88
  33. package/dist/autocomplete/index.d.ts +0 -88
  34. package/dist/autocomplete/index.js +0 -1122
  35. package/dist/avatar/index.cjs +0 -281
  36. package/dist/avatar/index.d.cts +0 -123
  37. package/dist/avatar/index.d.ts +0 -123
  38. package/dist/avatar/index.js +0 -281
  39. package/dist/badge/index.cjs +0 -197
  40. package/dist/badge/index.d.cts +0 -94
  41. package/dist/badge/index.d.ts +0 -94
  42. package/dist/badge/index.js +0 -197
  43. package/dist/bottom-sheet/index.cjs +0 -9
  44. package/dist/bottom-sheet/index.d.cts +0 -84
  45. package/dist/bottom-sheet/index.d.ts +0 -84
  46. package/dist/bottom-sheet/index.js +0 -9
  47. package/dist/bottom-tab-bar/index.cjs +0 -497
  48. package/dist/bottom-tab-bar/index.d.cts +0 -211
  49. package/dist/bottom-tab-bar/index.d.ts +0 -211
  50. package/dist/bottom-tab-bar/index.js +0 -497
  51. package/dist/button/index.cjs +0 -392
  52. package/dist/button/index.d.cts +0 -174
  53. package/dist/button/index.d.ts +0 -174
  54. package/dist/button/index.js +0 -392
  55. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  56. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  57. package/dist/card/index.cjs +0 -338
  58. package/dist/card/index.d.cts +0 -191
  59. package/dist/card/index.d.ts +0 -191
  60. package/dist/card/index.js +0 -338
  61. package/dist/carousel/index.cjs +0 -381
  62. package/dist/carousel/index.d.cts +0 -147
  63. package/dist/carousel/index.d.ts +0 -147
  64. package/dist/carousel/index.js +0 -381
  65. package/dist/chart/index.cjs +0 -1026
  66. package/dist/chart/index.d.cts +0 -218
  67. package/dist/chart/index.d.ts +0 -218
  68. package/dist/chart/index.js +0 -1026
  69. package/dist/checkbox/index.cjs +0 -443
  70. package/dist/checkbox/index.d.cts +0 -73
  71. package/dist/checkbox/index.d.ts +0 -73
  72. package/dist/checkbox/index.js +0 -443
  73. package/dist/chip/index.cjs +0 -503
  74. package/dist/chip/index.d.cts +0 -195
  75. package/dist/chip/index.d.ts +0 -195
  76. package/dist/chip/index.js +0 -503
  77. package/dist/chunk-4JFWQ5XT.js +0 -368
  78. package/dist/chunk-56RPWZD2.cjs +0 -9
  79. package/dist/chunk-7UFBLUMV.cjs +0 -136
  80. package/dist/chunk-A45TVXU5.js +0 -337
  81. package/dist/chunk-BYWUAPC4.cjs +0 -368
  82. package/dist/chunk-DECMUMCI.js +0 -0
  83. package/dist/chunk-DHSTKO3K.cjs +0 -19
  84. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  85. package/dist/chunk-EUQDGTST.cjs +0 -1
  86. package/dist/chunk-GBHQCAKW.js +0 -19
  87. package/dist/chunk-RBSA4NH4.js +0 -136
  88. package/dist/chunk-SHBDANQN.js +0 -9
  89. package/dist/chunk-UGEINZM7.cjs +0 -290
  90. package/dist/chunk-UU4HHBDN.js +0 -290
  91. package/dist/chunk-VSZEXOUN.js +0 -384
  92. package/dist/chunk-YIEUN3G5.cjs +0 -384
  93. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  94. package/dist/chunk-ZY7IUTAT.js +0 -75
  95. package/dist/color-picker/index.cjs +0 -457
  96. package/dist/color-picker/index.d.cts +0 -124
  97. package/dist/color-picker/index.d.ts +0 -124
  98. package/dist/color-picker/index.js +0 -457
  99. package/dist/core/index.cjs +0 -24
  100. package/dist/core/index.d.cts +0 -28
  101. package/dist/core/index.d.ts +0 -28
  102. package/dist/core/index.js +0 -24
  103. package/dist/datepicker/index.cjs +0 -1625
  104. package/dist/datepicker/index.d.cts +0 -45
  105. package/dist/datepicker/index.d.ts +0 -45
  106. package/dist/datepicker/index.js +0 -1625
  107. package/dist/dialog/index.cjs +0 -372
  108. package/dist/dialog/index.d.cts +0 -151
  109. package/dist/dialog/index.d.ts +0 -151
  110. package/dist/dialog/index.js +0 -372
  111. package/dist/divider/index.cjs +0 -8
  112. package/dist/divider/index.d.cts +0 -30
  113. package/dist/divider/index.d.ts +0 -30
  114. package/dist/divider/index.js +0 -8
  115. package/dist/drawer/index.cjs +0 -237
  116. package/dist/drawer/index.d.cts +0 -58
  117. package/dist/drawer/index.d.ts +0 -58
  118. package/dist/drawer/index.js +0 -237
  119. package/dist/expansion-panel/index.cjs +0 -441
  120. package/dist/expansion-panel/index.d.cts +0 -153
  121. package/dist/expansion-panel/index.d.ts +0 -153
  122. package/dist/expansion-panel/index.js +0 -441
  123. package/dist/fab/index.cjs +0 -9
  124. package/dist/fab/index.d.cts +0 -10
  125. package/dist/fab/index.d.ts +0 -10
  126. package/dist/fab/index.js +0 -9
  127. package/dist/fab-menu/index.cjs +0 -330
  128. package/dist/fab-menu/index.d.cts +0 -125
  129. package/dist/fab-menu/index.d.ts +0 -125
  130. package/dist/fab-menu/index.js +0 -330
  131. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  132. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  133. package/dist/feature-discovery/index.cjs +0 -464
  134. package/dist/feature-discovery/index.d.cts +0 -82
  135. package/dist/feature-discovery/index.d.ts +0 -82
  136. package/dist/feature-discovery/index.js +0 -464
  137. package/dist/indicator/index.cjs +0 -8
  138. package/dist/indicator/index.d.cts +0 -47
  139. package/dist/indicator/index.d.ts +0 -47
  140. package/dist/indicator/index.js +0 -8
  141. package/dist/input/index.cjs +0 -1462
  142. package/dist/input/index.d.cts +0 -522
  143. package/dist/input/index.d.ts +0 -522
  144. package/dist/input/index.js +0 -1462
  145. package/dist/input-trigger/index.cjs +0 -197
  146. package/dist/input-trigger/index.d.cts +0 -11
  147. package/dist/input-trigger/index.d.ts +0 -11
  148. package/dist/input-trigger/index.js +0 -197
  149. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  150. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  151. package/dist/list/index.cjs +0 -395
  152. package/dist/list/index.d.cts +0 -188
  153. package/dist/list/index.d.ts +0 -188
  154. package/dist/list/index.js +0 -395
  155. package/dist/menu/index.cjs +0 -316
  156. package/dist/menu/index.d.cts +0 -115
  157. package/dist/menu/index.d.ts +0 -115
  158. package/dist/menu/index.js +0 -316
  159. package/dist/menubox/index.cjs +0 -297
  160. package/dist/menubox/index.d.cts +0 -98
  161. package/dist/menubox/index.d.ts +0 -98
  162. package/dist/menubox/index.js +0 -297
  163. package/dist/pager/index.cjs +0 -205
  164. package/dist/pager/index.d.cts +0 -93
  165. package/dist/pager/index.d.ts +0 -93
  166. package/dist/pager/index.js +0 -205
  167. package/dist/picker/index.cjs +0 -244
  168. package/dist/picker/index.d.cts +0 -121
  169. package/dist/picker/index.d.ts +0 -121
  170. package/dist/picker/index.js +0 -244
  171. package/dist/progress/index.cjs +0 -219
  172. package/dist/progress/index.d.cts +0 -47
  173. package/dist/progress/index.d.ts +0 -47
  174. package/dist/progress/index.js +0 -219
  175. package/dist/radio/index.cjs +0 -465
  176. package/dist/radio/index.d.cts +0 -145
  177. package/dist/radio/index.d.ts +0 -145
  178. package/dist/radio/index.js +0 -465
  179. package/dist/refresh-control/index.cjs +0 -45
  180. package/dist/refresh-control/index.d.cts +0 -55
  181. package/dist/refresh-control/index.d.ts +0 -55
  182. package/dist/refresh-control/index.js +0 -45
  183. package/dist/segment-button/index.cjs +0 -405
  184. package/dist/segment-button/index.d.cts +0 -141
  185. package/dist/segment-button/index.d.ts +0 -141
  186. package/dist/segment-button/index.js +0 -405
  187. package/dist/select/index.cjs +0 -878
  188. package/dist/select/index.d.cts +0 -192
  189. package/dist/select/index.d.ts +0 -192
  190. package/dist/select/index.js +0 -878
  191. package/dist/skeleton/index.cjs +0 -89
  192. package/dist/skeleton/index.d.cts +0 -45
  193. package/dist/skeleton/index.d.ts +0 -45
  194. package/dist/skeleton/index.js +0 -89
  195. package/dist/slider/index.cjs +0 -576
  196. package/dist/slider/index.d.cts +0 -171
  197. package/dist/slider/index.d.ts +0 -171
  198. package/dist/slider/index.js +0 -576
  199. package/dist/snackbar/index.cjs +0 -436
  200. package/dist/snackbar/index.d.cts +0 -174
  201. package/dist/snackbar/index.d.ts +0 -174
  202. package/dist/snackbar/index.js +0 -436
  203. package/dist/snippet/index.cjs +0 -314
  204. package/dist/snippet/index.d.cts +0 -95
  205. package/dist/snippet/index.d.ts +0 -95
  206. package/dist/snippet/index.js +0 -314
  207. package/dist/stepper/index.cjs +0 -550
  208. package/dist/stepper/index.d.cts +0 -137
  209. package/dist/stepper/index.d.ts +0 -137
  210. package/dist/stepper/index.js +0 -550
  211. package/dist/switch/index.cjs +0 -358
  212. package/dist/switch/index.d.cts +0 -28
  213. package/dist/switch/index.d.ts +0 -28
  214. package/dist/switch/index.js +0 -358
  215. package/dist/tabs/index.cjs +0 -440
  216. package/dist/tabs/index.d.cts +0 -180
  217. package/dist/tabs/index.d.ts +0 -180
  218. package/dist/tabs/index.js +0 -440
  219. package/dist/timepicker/index.cjs +0 -823
  220. package/dist/timepicker/index.d.cts +0 -215
  221. package/dist/timepicker/index.d.ts +0 -215
  222. package/dist/timepicker/index.js +0 -823
  223. package/dist/toolbar/index.cjs +0 -333
  224. package/dist/toolbar/index.d.cts +0 -100
  225. package/dist/toolbar/index.d.ts +0 -100
  226. package/dist/toolbar/index.js +0 -333
  227. package/dist/typography/index.cjs +0 -238
  228. package/dist/typography/index.d.cts +0 -113
  229. package/dist/typography/index.d.ts +0 -113
  230. package/dist/typography/index.js +0 -238
  231. package/dist/view/index.cjs +0 -1361
  232. package/dist/view/index.d.cts +0 -833
  233. package/dist/view/index.d.ts +0 -833
  234. package/dist/view/index.js +0 -1361
@@ -1,1462 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }require('../chunk-56RPWZD2.cjs');
2
-
3
-
4
- var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
5
-
6
- // src/components/input/input.tsx
7
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
8
-
9
-
10
-
11
-
12
-
13
-
14
- var _reactnative = require('react-native');
15
- var _icons = require('@xaui/icons');
16
-
17
- // src/components/input/input.hook.ts
18
-
19
- var _core = require('@xaui/core');
20
- var useTextInputSizeStyles = (size) => {
21
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
22
- return _react.useMemo.call(void 0, () => {
23
- const sizeMap = {
24
- sm: {
25
- minHeight: theme.componentSizes.sm,
26
- fontSize: 14,
27
- paddingHorizontal: 12,
28
- paddingVertical: 8,
29
- slotGap: 8,
30
- labelSize: 13,
31
- helperSize: 12
32
- },
33
- md: {
34
- minHeight: theme.componentSizes.md,
35
- fontSize: 16,
36
- paddingHorizontal: 14,
37
- paddingVertical: 10,
38
- slotGap: 10,
39
- labelSize: 14,
40
- helperSize: 13
41
- },
42
- lg: {
43
- minHeight: theme.componentSizes.lg,
44
- fontSize: 17,
45
- paddingHorizontal: 16,
46
- paddingVertical: 12,
47
- slotGap: 12,
48
- labelSize: 15,
49
- helperSize: 15
50
- }
51
- };
52
- return sizeMap[size];
53
- }, [size, theme]);
54
- };
55
- var useTextInputRadiusStyles = (radius) => {
56
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
57
- return _react.useMemo.call(void 0, () => {
58
- if (radius === "full") {
59
- return { borderRadius: theme.borderRadius.full };
60
- }
61
- return { borderRadius: theme.borderRadius[radius] };
62
- }, [radius, theme.borderRadius]);
63
- };
64
- var useTextInputVariantStyles = ({
65
- themeColor,
66
- variant,
67
- isFocused,
68
- isInvalid,
69
- isDisabled
70
- }) => {
71
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
72
- const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
73
- const colorScheme = theme.colors[safeThemeColor];
74
- return _react.useMemo.call(void 0, () => {
75
- const focusColor = isInvalid ? theme.colors.danger.main : colorScheme.main;
76
- const neutralBorder = _core.withOpacity.call(void 0, theme.colors.foreground, 0.1);
77
- const textColor = isDisabled ? _core.withOpacity.call(void 0, theme.colors.foreground, 0.55) : theme.colors.foreground;
78
- const placeholderColor = _core.withOpacity.call(void 0, theme.colors.foreground, 0.45);
79
- const labelColor = isInvalid ? theme.colors.danger.main : isFocused ? colorScheme.main : _core.withOpacity.call(void 0, theme.colors.foreground, 0.8);
80
- const helperColor = isInvalid ? theme.colors.danger.main : _core.withOpacity.call(void 0, theme.colors.foreground, 0.72);
81
- if (variant === "underlined") {
82
- return {
83
- container: {
84
- backgroundColor: "transparent",
85
- borderColor: focusColor,
86
- borderBottomWidth: isFocused || isInvalid ? 2 : 1
87
- },
88
- unfocusedBorderColor: neutralBorder,
89
- focusedBorderColor: focusColor,
90
- textColor,
91
- placeholderColor,
92
- labelColor,
93
- helperColor
94
- };
95
- }
96
- if (variant === "bordered") {
97
- return {
98
- container: {
99
- backgroundColor: theme.colors.background,
100
- borderColor: isFocused || isInvalid ? focusColor : neutralBorder,
101
- borderWidth: theme.borderWidth.md
102
- },
103
- unfocusedBorderColor: neutralBorder,
104
- focusedBorderColor: focusColor,
105
- textColor,
106
- placeholderColor,
107
- labelColor,
108
- helperColor
109
- };
110
- }
111
- if (variant === "light") {
112
- return {
113
- container: {
114
- borderColor: isFocused || isInvalid ? focusColor : "transparent",
115
- borderWidth: isFocused || isInvalid ? theme.borderWidth.md : 0
116
- },
117
- unfocusedBorderColor: "transparent",
118
- focusedBorderColor: focusColor,
119
- textColor,
120
- placeholderColor,
121
- labelColor,
122
- helperColor
123
- };
124
- }
125
- return {
126
- container: {
127
- backgroundColor: _core.withOpacity.call(void 0, colorScheme.container, 0.5),
128
- borderColor: isFocused || isInvalid ? _core.withPaletteNumber.call(void 0, focusColor, 500) : "transparent",
129
- borderWidth: isFocused || isInvalid ? theme.borderWidth.md : 0
130
- },
131
- unfocusedBorderColor: "transparent",
132
- focusedBorderColor: _core.withPaletteNumber.call(void 0, focusColor, 500),
133
- textColor,
134
- placeholderColor,
135
- labelColor,
136
- helperColor
137
- };
138
- }, [colorScheme, isDisabled, isFocused, isInvalid, theme, variant]);
139
- };
140
-
141
- // src/components/input/input.style.ts
142
-
143
- var styles = _reactnative.StyleSheet.create({
144
- container: {
145
- width: "100%",
146
- gap: 6
147
- },
148
- noFullWidth: {
149
- alignSelf: "flex-start"
150
- },
151
- inputContainer: {
152
- gap: 6
153
- },
154
- label: {
155
- fontWeight: "500"
156
- },
157
- inputWrapper: {
158
- flexDirection: "row",
159
- alignItems: "center"
160
- },
161
- underlinedWrapper: {
162
- borderBottomLeftRadius: 0,
163
- borderBottomRightRadius: 0,
164
- paddingHorizontal: 0
165
- },
166
- slot: {
167
- justifyContent: "center",
168
- alignItems: "center"
169
- },
170
- input: {
171
- flex: 1,
172
- padding: 0,
173
- includeFontPadding: false
174
- },
175
- clearButton: {
176
- justifyContent: "center",
177
- alignItems: "center",
178
- marginLeft: 6
179
- },
180
- helperText: {
181
- fontWeight: "400"
182
- },
183
- disabled: {
184
- opacity: 0.6
185
- }
186
- });
187
-
188
- // src/components/input/input.tsx
189
- var TextInput = _react.forwardRef.call(void 0,
190
- ({
191
- value,
192
- defaultValue,
193
- onValueChange,
194
- onChangeText,
195
- onFocus,
196
- onBlur,
197
- label,
198
- labelPlacement = "outside",
199
- description,
200
- errorMessage,
201
- startContent,
202
- endContent,
203
- themeColor = "primary",
204
- variant = "colored",
205
- size = "md",
206
- radius = "md",
207
- isSecured = false,
208
- isClearable = false,
209
- isDisabled = false,
210
- isReadOnly = false,
211
- isInvalid = false,
212
- fullWidth = true,
213
- customAppearance,
214
- ...nativeProps
215
- }, forwardedRef) => {
216
- const isControlled = typeof value === "string";
217
- const [internalValue, setInternalValue] = _react.useState.call(void 0, _nullishCoalesce(defaultValue, () => ( "")));
218
- const [isFocused, setIsFocused] = _react.useState.call(void 0, false);
219
- const internalRef = _react.useRef.call(void 0, null);
220
- const borderAnimation = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
221
- const inputValue = isControlled ? _nullishCoalesce(value, () => ( "")) : internalValue;
222
- const secureTextEntry = _nullishCoalesce(nativeProps.secureTextEntry, () => ( isSecured));
223
- const sizeStyles = useTextInputSizeStyles(size);
224
- const radiusStyles = useTextInputRadiusStyles(radius);
225
- const variantStyles = useTextInputVariantStyles({
226
- themeColor,
227
- variant,
228
- isFocused,
229
- isInvalid,
230
- isDisabled
231
- });
232
- _react.useEffect.call(void 0, () => {
233
- _reactnative.Animated.timing(borderAnimation, {
234
- toValue: isFocused || isInvalid ? 1 : 0,
235
- duration: 200,
236
- useNativeDriver: false
237
- }).start();
238
- }, [borderAnimation, isFocused, isInvalid]);
239
- const showClearButton = isClearable && !!inputValue && !isDisabled && !isReadOnly && !secureTextEntry && nativeProps.editable !== false;
240
- const editable = _nullishCoalesce(nativeProps.editable, () => ( (!isDisabled && !isReadOnly)));
241
- const helperText = _react.useMemo.call(void 0, () => {
242
- if (isInvalid && errorMessage) {
243
- return errorMessage;
244
- }
245
- return description;
246
- }, [description, errorMessage, isInvalid]);
247
- const handleChangeText = (text) => {
248
- if (!isControlled) {
249
- setInternalValue(text);
250
- }
251
- _optionalChain([onValueChange, 'optionalCall', _2 => _2(text)]);
252
- _optionalChain([onChangeText, 'optionalCall', _3 => _3(text)]);
253
- };
254
- const handleClear = () => {
255
- if (!isControlled) {
256
- setInternalValue("");
257
- }
258
- _optionalChain([onValueChange, 'optionalCall', _4 => _4("")]);
259
- _optionalChain([onChangeText, 'optionalCall', _5 => _5("")]);
260
- };
261
- const handleWrapperPress = () => {
262
- if (isDisabled || isReadOnly || nativeProps.editable === false) return;
263
- const inputRef = forwardedRef || internalRef;
264
- if (typeof forwardedRef === "function") {
265
- _optionalChain([internalRef, 'access', _6 => _6.current, 'optionalAccess', _7 => _7.focus, 'call', _8 => _8()]);
266
- } else if (_optionalChain([inputRef, 'optionalAccess', _9 => _9.current])) {
267
- inputRef.current.focus();
268
- }
269
- };
270
- return /* @__PURE__ */ _react2.default.createElement(
271
- _reactnative.View,
272
- {
273
- style: [
274
- styles.container,
275
- !fullWidth && styles.noFullWidth,
276
- isDisabled && styles.disabled,
277
- _optionalChain([customAppearance, 'optionalAccess', _10 => _10.container])
278
- ]
279
- },
280
- /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.inputContainer, _optionalChain([customAppearance, 'optionalAccess', _11 => _11.inputContainer])] }, label && labelPlacement === "outside" && /* @__PURE__ */ _react2.default.createElement(
281
- _reactnative.Text,
282
- {
283
- style: [
284
- styles.label,
285
- {
286
- color: variantStyles.labelColor,
287
- fontSize: sizeStyles.labelSize
288
- },
289
- _optionalChain([customAppearance, 'optionalAccess', _12 => _12.label])
290
- ]
291
- },
292
- label
293
- ), /* @__PURE__ */ _react2.default.createElement(
294
- _reactnative.Pressable,
295
- {
296
- onPress: handleWrapperPress,
297
- disabled: isDisabled || isReadOnly
298
- },
299
- /* @__PURE__ */ _react2.default.createElement(
300
- _reactnative.Animated.View,
301
- {
302
- style: [
303
- styles.inputWrapper,
304
- {
305
- minHeight: sizeStyles.minHeight,
306
- paddingVertical: sizeStyles.paddingVertical,
307
- paddingHorizontal: sizeStyles.paddingHorizontal,
308
- gap: sizeStyles.slotGap,
309
- backgroundColor: variantStyles.container.backgroundColor,
310
- borderWidth: variant === "underlined" ? 0 : variantStyles.container.borderWidth,
311
- ...variant === "underlined" && {
312
- borderBottomWidth: variantStyles.container.borderBottomWidth
313
- },
314
- borderRadius: variant === "underlined" ? 0 : radiusStyles.borderRadius,
315
- ...variant === "underlined" ? {
316
- borderBottomColor: borderAnimation.interpolate({
317
- inputRange: [0, 1],
318
- outputRange: [
319
- variantStyles.unfocusedBorderColor,
320
- variantStyles.focusedBorderColor
321
- ]
322
- })
323
- } : {
324
- borderColor: borderAnimation.interpolate({
325
- inputRange: [0, 1],
326
- outputRange: [
327
- variantStyles.unfocusedBorderColor,
328
- variantStyles.focusedBorderColor
329
- ]
330
- })
331
- }
332
- },
333
- variant === "underlined" && styles.underlinedWrapper,
334
- _optionalChain([customAppearance, 'optionalAccess', _13 => _13.inputWrapper])
335
- ]
336
- },
337
- startContent && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.slot }, startContent),
338
- /* @__PURE__ */ _react2.default.createElement(
339
- _reactnative.View,
340
- {
341
- style: {
342
- flex: 1,
343
- gap: labelPlacement === "inside" && label ? 2 : 0
344
- }
345
- },
346
- label && labelPlacement === "inside" && /* @__PURE__ */ _react2.default.createElement(
347
- _reactnative.Text,
348
- {
349
- style: [
350
- styles.label,
351
- {
352
- color: variantStyles.labelColor,
353
- fontSize: sizeStyles.helperSize,
354
- paddingBottom: 2
355
- },
356
- _optionalChain([customAppearance, 'optionalAccess', _14 => _14.label])
357
- ]
358
- },
359
- label
360
- ),
361
- /* @__PURE__ */ _react2.default.createElement(
362
- _reactnative.TextInput,
363
- {
364
- ref: typeof forwardedRef === "function" ? internalRef : forwardedRef || internalRef,
365
- value: inputValue,
366
- onChangeText: handleChangeText,
367
- onFocus: (event) => {
368
- setIsFocused(true);
369
- _optionalChain([onFocus, 'optionalCall', _15 => _15(event)]);
370
- },
371
- onBlur: (event) => {
372
- setIsFocused(false);
373
- _optionalChain([onBlur, 'optionalCall', _16 => _16(event)]);
374
- },
375
- editable,
376
- secureTextEntry,
377
- placeholderTextColor: variantStyles.placeholderColor,
378
- style: [
379
- styles.input,
380
- {
381
- color: variantStyles.textColor,
382
- fontSize: sizeStyles.fontSize
383
- },
384
- _optionalChain([customAppearance, 'optionalAccess', _17 => _17.input])
385
- ],
386
- ...nativeProps
387
- }
388
- )
389
- ),
390
- showClearButton ? /* @__PURE__ */ _react2.default.createElement(
391
- _reactnative.Pressable,
392
- {
393
- onPress: handleClear,
394
- accessibilityLabel: "Clear input",
395
- accessibilityRole: "button",
396
- style: styles.clearButton
397
- },
398
- /* @__PURE__ */ _react2.default.createElement(_icons.CloseIcon, { size: 16, color: variantStyles.placeholderColor })
399
- ) : endContent && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.slot }, endContent)
400
- )
401
- )),
402
- helperText && /* @__PURE__ */ _react2.default.createElement(
403
- _reactnative.Text,
404
- {
405
- style: [
406
- styles.helperText,
407
- {
408
- color: variantStyles.helperColor,
409
- fontSize: sizeStyles.helperSize
410
- },
411
- _optionalChain([customAppearance, 'optionalAccess', _18 => _18.helperText])
412
- ]
413
- },
414
- helperText
415
- )
416
- );
417
- }
418
- );
419
- TextInput.displayName = "TextInput";
420
-
421
- // src/components/input/textarea.tsx
422
-
423
-
424
- // src/components/input/textarea.style.ts
425
-
426
- var textAreaStyles = _reactnative.StyleSheet.create({
427
- inputWrapper: {
428
- alignItems: "flex-start"
429
- },
430
- input: {
431
- textAlignVertical: "top"
432
- }
433
- });
434
-
435
- // src/components/input/textarea.tsx
436
- var TextArea = ({
437
- minRows = 3,
438
- maxRows,
439
- size = "md",
440
- customAppearance,
441
- numberOfLines,
442
- textAlignVertical,
443
- scrollEnabled,
444
- ...props
445
- }) => {
446
- const sizeStyles = useTextInputSizeStyles(size);
447
- const lineHeight = Math.round(sizeStyles.fontSize * 1.35);
448
- const verticalPadding = sizeStyles.paddingVertical * 2;
449
- const normalizedMaxRows = typeof maxRows === "number" ? Math.max(maxRows, minRows) : void 0;
450
- const minHeight = minRows * lineHeight + verticalPadding;
451
- const maxHeight = typeof normalizedMaxRows === "number" ? normalizedMaxRows * lineHeight + verticalPadding : void 0;
452
- return /* @__PURE__ */ _react2.default.createElement(
453
- TextInput,
454
- {
455
- ...props,
456
- size,
457
- multiline: true,
458
- numberOfLines: _nullishCoalesce(numberOfLines, () => ( minRows)),
459
- textAlignVertical: _nullishCoalesce(textAlignVertical, () => ( "top")),
460
- scrollEnabled: _nullishCoalesce(scrollEnabled, () => ( !!maxHeight)),
461
- customAppearance: {
462
- ...customAppearance,
463
- inputWrapper: [
464
- textAreaStyles.inputWrapper,
465
- {
466
- minHeight,
467
- ...maxHeight ? { maxHeight } : {}
468
- },
469
- _optionalChain([customAppearance, 'optionalAccess', _19 => _19.inputWrapper])
470
- ],
471
- input: [
472
- textAreaStyles.input,
473
- {
474
- lineHeight
475
- },
476
- _optionalChain([customAppearance, 'optionalAccess', _20 => _20.input])
477
- ]
478
- }
479
- }
480
- );
481
- };
482
-
483
- // src/components/input/date-time-input.tsx
484
-
485
-
486
- // src/components/input/date-time-input.hook.ts
487
- var YMD_LOCALES = ["ja", "zh", "ko", "hu", "lt", "mn"];
488
- var MDY_LOCALES = ["en-US", "en-PH", "en-BZ"];
489
- var getDateOrder = (locale) => {
490
- try {
491
- const formatter = new Intl.DateTimeFormat(locale, {
492
- year: "numeric",
493
- month: "2-digit",
494
- day: "2-digit"
495
- });
496
- const parts = formatter.formatToParts(new Date(2e3, 0, 2));
497
- const order = parts.filter((p) => p.type === "year" || p.type === "month" || p.type === "day").map((p) => p.type);
498
- if (order[0] === "year") return "YMD";
499
- if (order[0] === "month") return "MDY";
500
- return "DMY";
501
- } catch (e2) {
502
- const lang = locale.split("-")[0];
503
- if (YMD_LOCALES.includes(locale) || YMD_LOCALES.includes(lang)) return "YMD";
504
- if (MDY_LOCALES.includes(locale)) return "MDY";
505
- return "DMY";
506
- }
507
- };
508
- var insertAtPositions = (digits, positions, char) => {
509
- let result = "";
510
- let digitIndex = 0;
511
- for (let i = 0; i < positions.length; i++) {
512
- const segLen = positions[i];
513
- const segment = digits.slice(digitIndex, digitIndex + segLen);
514
- if (!segment) break;
515
- if (i > 0) result += char;
516
- result += segment;
517
- digitIndex += segLen;
518
- }
519
- return result;
520
- };
521
- var formatDateInput = (text, dateOrder, separator) => {
522
- const digits = text.replace(/\D/g, "").slice(0, 8);
523
- const segments = dateOrder === "YMD" ? [4, 2, 2] : [2, 2, 4];
524
- return insertAtPositions(digits, segments, separator);
525
- };
526
- var formatTimeInput = (text, granularity, hourCycle) => {
527
- const cleaned = text.replace(/[^0-9aApPmM ]/g, "");
528
- const digits = cleaned.replace(/\D/g, "");
529
- const maxDigits = granularity === "second" ? 6 : 4;
530
- const trimmed = digits.slice(0, maxDigits);
531
- const segments = granularity === "second" ? [2, 2, 2] : [2, 2];
532
- let result = insertAtPositions(trimmed, segments, ":");
533
- if (hourCycle === 12 && trimmed.length >= 4) {
534
- const ampmMatch = cleaned.match(/[aApP][mM]?/i);
535
- if (ampmMatch) {
536
- const period = ampmMatch[0].toUpperCase().startsWith("P") ? "PM" : "AM";
537
- result += " " + period;
538
- }
539
- }
540
- return result;
541
- };
542
- var formatDateTimeInput = (text, dateOrder, separator, granularity, hourCycle) => {
543
- const digits = text.replace(/[^0-9aApPmM]/g, "").replace(/[aApPmM]/g, "");
544
- const dateDigitCount = 8;
545
- const timeDigitCount = granularity === "second" ? 6 : 4;
546
- const maxDigits = dateDigitCount + timeDigitCount;
547
- const trimmed = digits.replace(/\D/g, "").slice(0, maxDigits);
548
- const datePart = trimmed.slice(0, dateDigitCount);
549
- const timePart = trimmed.slice(dateDigitCount);
550
- let result = formatDateInput(datePart, dateOrder, separator);
551
- if (timePart) {
552
- const timeSegments = granularity === "second" ? [2, 2, 2] : [2, 2];
553
- result += " " + insertAtPositions(timePart, timeSegments, ":");
554
- if (hourCycle === 12 && timePart.length >= 4) {
555
- const ampmMatch = text.match(/[aApP][mM]?/i);
556
- if (ampmMatch) {
557
- const period = ampmMatch[0].toUpperCase().startsWith("P") ? "PM" : "AM";
558
- result += " " + period;
559
- }
560
- }
561
- }
562
- return result;
563
- };
564
- var getDatePlaceholder = (dateOrder, separator) => {
565
- const parts = {
566
- YMD: ["YYYY", "MM", "DD"],
567
- DMY: ["DD", "MM", "YYYY"],
568
- MDY: ["MM", "DD", "YYYY"]
569
- };
570
- return parts[dateOrder].join(separator);
571
- };
572
- var getTimePlaceholder = (granularity, hourCycle) => {
573
- const hour = hourCycle === 12 ? "hh" : "HH";
574
- const base = `${hour}:mm`;
575
- const withSeconds = granularity === "second" ? `${base}:ss` : base;
576
- return hourCycle === 12 ? `${withSeconds} AM` : withSeconds;
577
- };
578
- var getDateTimePlaceholder = (dateOrder, separator, granularity, hourCycle) => {
579
- return `${getDatePlaceholder(dateOrder, separator)} ${getTimePlaceholder(granularity, hourCycle)}`;
580
- };
581
- var getDateMaxLength = (separator) => {
582
- return 8 + 2 * separator.length;
583
- };
584
- var getTimeMaxLength = (granularity, hourCycle) => {
585
- const base = granularity === "second" ? 8 : 5;
586
- return hourCycle === 12 ? base + 3 : base;
587
- };
588
- var getDateTimeMaxLength = (separator, granularity, hourCycle) => {
589
- return getDateMaxLength(separator) + 1 + getTimeMaxLength(granularity, hourCycle);
590
- };
591
- var pad = (n) => String(n).padStart(2, "0");
592
- var dateInputValueToDate = (value, dateOrder, separator) => {
593
- const parts = value.split(separator);
594
- if (parts.length !== 3) return null;
595
- let year, month, day;
596
- if (dateOrder === "YMD") {
597
- year = parseInt(parts[0], 10);
598
- month = parseInt(parts[1], 10);
599
- day = parseInt(parts[2], 10);
600
- } else if (dateOrder === "MDY") {
601
- month = parseInt(parts[0], 10);
602
- day = parseInt(parts[1], 10);
603
- year = parseInt(parts[2], 10);
604
- } else {
605
- day = parseInt(parts[0], 10);
606
- month = parseInt(parts[1], 10);
607
- year = parseInt(parts[2], 10);
608
- }
609
- if (isNaN(year) || isNaN(month) || isNaN(day)) return null;
610
- const date = new Date(year, month - 1, day);
611
- if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day)
612
- return null;
613
- return date;
614
- };
615
- var dateToDateInputValue = (date, dateOrder, separator) => {
616
- const d = typeof date === "string" ? new Date(date) : date;
617
- if (isNaN(d.getTime())) return "";
618
- const year = String(d.getFullYear());
619
- const month = pad(d.getMonth() + 1);
620
- const day = pad(d.getDate());
621
- if (dateOrder === "YMD") return [year, month, day].join(separator);
622
- if (dateOrder === "MDY") return [month, day, year].join(separator);
623
- return [day, month, year].join(separator);
624
- };
625
- var timeInputValueToDate = (value, options = {}) => {
626
- const { hourCycle = 24 } = options;
627
- const isPM = /pm$/i.test(value);
628
- const isAM = /am$/i.test(value);
629
- const cleaned = value.replace(/\s*(am|pm)$/i, "").trim();
630
- const segments = cleaned.split(":");
631
- let hours = parseInt(segments[0], 10);
632
- const minutes = parseInt(_nullishCoalesce(segments[1], () => ( "0")), 10);
633
- const seconds = parseInt(_nullishCoalesce(segments[2], () => ( "0")), 10);
634
- if (isNaN(hours) || isNaN(minutes) || isNaN(seconds)) return null;
635
- if (hourCycle === 12) {
636
- if (isPM && hours !== 12) hours += 12;
637
- if (isAM && hours === 12) hours = 0;
638
- }
639
- const date = /* @__PURE__ */ new Date();
640
- date.setHours(hours, minutes, seconds, 0);
641
- return date;
642
- };
643
- var dateToTimeInputValue = (date, options = {}) => {
644
- const { granularity = "minute", hourCycle = 24 } = options;
645
- const d = typeof date === "string" ? new Date(date) : date;
646
- if (isNaN(d.getTime())) return "";
647
- let hours = d.getHours();
648
- const minutes = pad(d.getMinutes());
649
- const seconds = pad(d.getSeconds());
650
- if (hourCycle === 12) {
651
- const period = hours >= 12 ? "PM" : "AM";
652
- hours = hours % 12 || 12;
653
- const base2 = `${pad(hours)}:${minutes}`;
654
- return granularity === "second" ? `${base2}:${seconds} ${period}` : `${base2} ${period}`;
655
- }
656
- const base = `${pad(hours)}:${minutes}`;
657
- return granularity === "second" ? `${base}:${seconds}` : base;
658
- };
659
- var dateTimeInputValueToDate = (value, dateOrder, options = {}) => {
660
- const { separator = "-", hourCycle = 24 } = options;
661
- const spaceIndex = value.indexOf(" ");
662
- if (spaceIndex === -1) return null;
663
- const date = dateInputValueToDate(value.slice(0, spaceIndex), dateOrder, separator);
664
- if (!date) return null;
665
- const timePart = value.slice(spaceIndex + 1);
666
- const timed = timeInputValueToDate(timePart, { hourCycle });
667
- if (!timed) return null;
668
- date.setHours(timed.getHours(), timed.getMinutes(), timed.getSeconds(), 0);
669
- return date;
670
- };
671
- var dateToDateTimeInputValue = (date, dateOrder, options = {}) => {
672
- const { separator = "-", granularity = "minute", hourCycle = 24 } = options;
673
- const d = typeof date === "string" ? new Date(date) : date;
674
- if (isNaN(d.getTime())) return "";
675
- const datePart = dateToDateInputValue(d, dateOrder, separator);
676
- const timePart = dateToTimeInputValue(d, { granularity, hourCycle });
677
- return `${datePart} ${timePart}`;
678
- };
679
-
680
- // src/components/input/date-time-input.tsx
681
- var DateInput = _react.forwardRef.call(void 0,
682
- ({
683
- separator = "-",
684
- dateOrder,
685
- locale = "en-US",
686
- placeholder,
687
- maxLength,
688
- onChangeText,
689
- onValueChange,
690
- ...props
691
- }, ref) => {
692
- const resolvedOrder = _react.useMemo.call(void 0,
693
- () => _nullishCoalesce(dateOrder, () => ( getDateOrder(locale))),
694
- [dateOrder, locale]
695
- );
696
- const handleChangeText = _react.useCallback.call(void 0,
697
- (text) => {
698
- const formatted = formatDateInput(text, resolvedOrder, separator);
699
- _optionalChain([onChangeText, 'optionalCall', _21 => _21(formatted)]);
700
- _optionalChain([onValueChange, 'optionalCall', _22 => _22(formatted)]);
701
- },
702
- [resolvedOrder, separator, onChangeText, onValueChange]
703
- );
704
- return /* @__PURE__ */ _react2.default.createElement(
705
- TextInput,
706
- {
707
- ref,
708
- placeholder: _nullishCoalesce(placeholder, () => ( getDatePlaceholder(resolvedOrder, separator))),
709
- keyboardType: "number-pad",
710
- autoCapitalize: "none",
711
- autoCorrect: false,
712
- maxLength: _nullishCoalesce(maxLength, () => ( getDateMaxLength(separator))),
713
- onChangeText: handleChangeText,
714
- ...props
715
- }
716
- );
717
- }
718
- );
719
- var TimeInput = _react.forwardRef.call(void 0,
720
- ({
721
- granularity = "minute",
722
- hourCycle = 24,
723
- placeholder,
724
- maxLength,
725
- onChangeText,
726
- onValueChange,
727
- ...props
728
- }, ref) => {
729
- const handleChangeText = _react.useCallback.call(void 0,
730
- (text) => {
731
- const formatted = formatTimeInput(text, granularity, hourCycle);
732
- _optionalChain([onChangeText, 'optionalCall', _23 => _23(formatted)]);
733
- _optionalChain([onValueChange, 'optionalCall', _24 => _24(formatted)]);
734
- },
735
- [granularity, hourCycle, onChangeText, onValueChange]
736
- );
737
- return /* @__PURE__ */ _react2.default.createElement(
738
- TextInput,
739
- {
740
- ref,
741
- placeholder: _nullishCoalesce(placeholder, () => ( getTimePlaceholder(granularity, hourCycle))),
742
- keyboardType: "number-pad",
743
- autoCapitalize: "none",
744
- autoCorrect: false,
745
- maxLength: _nullishCoalesce(maxLength, () => ( getTimeMaxLength(granularity, hourCycle))),
746
- onChangeText: handleChangeText,
747
- ...props
748
- }
749
- );
750
- }
751
- );
752
- var DateTimeInput = _react.forwardRef.call(void 0,
753
- ({
754
- separator = "-",
755
- dateOrder,
756
- locale = "en-US",
757
- granularity = "minute",
758
- hourCycle = 24,
759
- placeholder,
760
- maxLength,
761
- onChangeText,
762
- onValueChange,
763
- ...props
764
- }, ref) => {
765
- const resolvedOrder = _react.useMemo.call(void 0,
766
- () => _nullishCoalesce(dateOrder, () => ( getDateOrder(locale))),
767
- [dateOrder, locale]
768
- );
769
- const handleChangeText = _react.useCallback.call(void 0,
770
- (text) => {
771
- const formatted = formatDateTimeInput(
772
- text,
773
- resolvedOrder,
774
- separator,
775
- granularity,
776
- hourCycle
777
- );
778
- _optionalChain([onChangeText, 'optionalCall', _25 => _25(formatted)]);
779
- _optionalChain([onValueChange, 'optionalCall', _26 => _26(formatted)]);
780
- },
781
- [resolvedOrder, separator, granularity, hourCycle, onChangeText, onValueChange]
782
- );
783
- return /* @__PURE__ */ _react2.default.createElement(
784
- TextInput,
785
- {
786
- ref,
787
- placeholder: _nullishCoalesce(placeholder, () => ( getDateTimePlaceholder(resolvedOrder, separator, granularity, hourCycle))),
788
- keyboardType: "number-pad",
789
- autoCapitalize: "none",
790
- autoCorrect: false,
791
- maxLength: _nullishCoalesce(maxLength, () => ( getDateTimeMaxLength(separator, granularity, hourCycle))),
792
- onChangeText: handleChangeText,
793
- ...props
794
- }
795
- );
796
- }
797
- );
798
- DateInput.displayName = "DateInput";
799
- TimeInput.displayName = "TimeInput";
800
- DateTimeInput.displayName = "DateTimeInput";
801
-
802
- // src/components/input/otp-input.tsx
803
-
804
-
805
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
- // src/components/input/otp-input.hook.ts
814
-
815
- var segmentSizeMap = {
816
- sm: { width: 40, height: 40, fontSize: 16 },
817
- md: { width: 48, height: 48, fontSize: 20 },
818
- lg: { width: 56, height: 56, fontSize: 24 }
819
- };
820
- var useOTPSegmentSizeStyles = (size) => {
821
- return _react.useMemo.call(void 0, () => segmentSizeMap[size], [size]);
822
- };
823
- var useOTPInputState = ({
824
- length,
825
- value,
826
- defaultValue,
827
- onValueChange,
828
- onComplete,
829
- allowedKeys
830
- }) => {
831
- const isControlled = typeof value === "string";
832
- const [internalValue, setInternalValue] = _react.useState.call(void 0, _nullishCoalesce(defaultValue, () => ( "")));
833
- const [activeIndex, setActiveIndex] = _react.useState.call(void 0, -1);
834
- const refs = _react.useRef.call(void 0, []);
835
- const currentValue = isControlled ? value : internalValue;
836
- const segments = _react.useMemo.call(void 0, () => {
837
- const chars = currentValue.split("");
838
- return Array.from({ length }, (_, i) => _nullishCoalesce(chars[i], () => ( "")));
839
- }, [currentValue, length]);
840
- const updateValue = _react.useCallback.call(void 0,
841
- (newValue) => {
842
- if (!isControlled) {
843
- setInternalValue(newValue);
844
- }
845
- _optionalChain([onValueChange, 'optionalCall', _27 => _27(newValue)]);
846
- if (newValue.length === length) {
847
- _optionalChain([onComplete, 'optionalCall', _28 => _28(newValue)]);
848
- }
849
- },
850
- [isControlled, length, onValueChange, onComplete]
851
- );
852
- const handleSegmentChange = _react.useCallback.call(void 0,
853
- (index, text) => {
854
- if (!text) return;
855
- const char = text.slice(-1);
856
- if (!allowedKeys.test(char)) return;
857
- const chars = currentValue.split("");
858
- while (chars.length < length) chars.push("");
859
- chars[index] = char;
860
- const newValue = chars.join("").replace(/\s+$/, "");
861
- updateValue(newValue);
862
- if (index < length - 1) {
863
- _optionalChain([refs, 'access', _29 => _29.current, 'access', _30 => _30[index + 1], 'optionalAccess', _31 => _31.focus, 'call', _32 => _32()]);
864
- }
865
- },
866
- [allowedKeys, currentValue, length, updateValue]
867
- );
868
- const handleSegmentKeyPress = _react.useCallback.call(void 0,
869
- (index, key) => {
870
- if (key !== "Backspace") return;
871
- const chars = currentValue.split("");
872
- while (chars.length < length) chars.push("");
873
- if (chars[index]) {
874
- chars[index] = "";
875
- updateValue(chars.join("").replace(/\s+$/, ""));
876
- return;
877
- }
878
- if (index > 0) {
879
- chars[index - 1] = "";
880
- updateValue(chars.join("").replace(/\s+$/, ""));
881
- _optionalChain([refs, 'access', _33 => _33.current, 'access', _34 => _34[index - 1], 'optionalAccess', _35 => _35.focus, 'call', _36 => _36()]);
882
- }
883
- },
884
- [currentValue, length, updateValue]
885
- );
886
- const handleSegmentFocus = _react.useCallback.call(void 0, (index) => {
887
- setActiveIndex(index);
888
- }, []);
889
- const handleSegmentBlur = _react.useCallback.call(void 0, () => {
890
- setActiveIndex(-1);
891
- }, []);
892
- return {
893
- segments,
894
- activeIndex,
895
- refs,
896
- handleSegmentChange,
897
- handleSegmentKeyPress,
898
- handleSegmentFocus,
899
- handleSegmentBlur
900
- };
901
- };
902
-
903
- // src/components/input/otp-input.style.ts
904
-
905
- var otpStyles = _reactnative.StyleSheet.create({
906
- container: {
907
- gap: 6
908
- },
909
- fullWidth: {
910
- width: "100%"
911
- },
912
- segmentContainer: {
913
- flexDirection: "row",
914
- gap: 8
915
- },
916
- segment: {
917
- justifyContent: "center",
918
- alignItems: "center",
919
- overflow: "hidden"
920
- },
921
- segmentText: {
922
- fontWeight: "600",
923
- textAlign: "center"
924
- },
925
- securedDot: {
926
- width: 10,
927
- height: 10,
928
- borderRadius: 5
929
- },
930
- hiddenInput: {
931
- position: "absolute",
932
- width: 1,
933
- height: 1,
934
- opacity: 0
935
- },
936
- underline: {
937
- position: "absolute",
938
- left: 0,
939
- right: 0,
940
- bottom: 0
941
- },
942
- label: {
943
- fontWeight: "500"
944
- },
945
- helperText: {
946
- fontWeight: "400"
947
- },
948
- disabled: {
949
- opacity: 0.6
950
- }
951
- });
952
-
953
- // src/components/input/otp-input.tsx
954
- var OTPSegment = ({
955
- char,
956
- isActive,
957
- isSecured,
958
- isDisabled,
959
- variantStyles,
960
- sizeStyles,
961
- radiusStyles,
962
- customSegment,
963
- customSegmentText,
964
- inputRef,
965
- onChangeText,
966
- onKeyPress,
967
- onFocus,
968
- onBlur,
969
- onPress
970
- }) => {
971
- const borderAnimation = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
972
- const isUnderlined = variantStyles.container.borderBottomWidth !== void 0;
973
- _react.useEffect.call(void 0, () => {
974
- _reactnative.Animated.timing(borderAnimation, {
975
- toValue: isActive ? 1 : 0,
976
- duration: 200,
977
- useNativeDriver: false
978
- }).start();
979
- }, [borderAnimation, isActive]);
980
- const unfocusedLineColor = isUnderlined ? _core.withOpacity.call(void 0, variantStyles.focusedBorderColor, 0.35) : variantStyles.unfocusedBorderColor;
981
- const animatedBorderColor = borderAnimation.interpolate({
982
- inputRange: [0, 1],
983
- outputRange: [unfocusedLineColor, variantStyles.focusedBorderColor]
984
- });
985
- return /* @__PURE__ */ _react2.default.createElement(
986
- _reactnative.Pressable,
987
- {
988
- onPress: () => {
989
- if (!isDisabled) {
990
- onPress();
991
- }
992
- },
993
- disabled: isDisabled
994
- },
995
- /* @__PURE__ */ _react2.default.createElement(
996
- _reactnative.Animated.View,
997
- {
998
- style: [
999
- otpStyles.segment,
1000
- {
1001
- width: sizeStyles.width,
1002
- height: sizeStyles.height,
1003
- backgroundColor: variantStyles.container.backgroundColor,
1004
- borderRadius: isUnderlined ? 0 : radiusStyles.borderRadius,
1005
- borderWidth: isUnderlined ? 0 : _nullishCoalesce(variantStyles.container.borderWidth, () => ( 0)),
1006
- borderColor: isUnderlined ? void 0 : animatedBorderColor
1007
- },
1008
- _optionalChain([customSegment, 'optionalAccess', _37 => _37.segment])
1009
- ]
1010
- },
1011
- char && isSecured ? /* @__PURE__ */ _react2.default.createElement(
1012
- _reactnative.View,
1013
- {
1014
- style: [
1015
- otpStyles.securedDot,
1016
- { backgroundColor: variantStyles.textColor }
1017
- ]
1018
- }
1019
- ) : /* @__PURE__ */ _react2.default.createElement(
1020
- _reactnative.Text,
1021
- {
1022
- style: [
1023
- otpStyles.segmentText,
1024
- {
1025
- color: variantStyles.textColor,
1026
- fontSize: sizeStyles.fontSize
1027
- },
1028
- _optionalChain([customSegmentText, 'optionalAccess', _38 => _38.segmentText])
1029
- ]
1030
- },
1031
- char
1032
- ),
1033
- /* @__PURE__ */ _react2.default.createElement(
1034
- _reactnative.TextInput,
1035
- {
1036
- ref: inputRef,
1037
- style: otpStyles.hiddenInput,
1038
- value: char,
1039
- onChangeText,
1040
- onKeyPress: (e) => onKeyPress(e.nativeEvent.key),
1041
- onFocus,
1042
- onBlur,
1043
- maxLength: 2,
1044
- keyboardType: "number-pad",
1045
- editable: !isDisabled,
1046
- caretHidden: true
1047
- }
1048
- ),
1049
- isUnderlined && /* @__PURE__ */ _react2.default.createElement(
1050
- _reactnative.Animated.View,
1051
- {
1052
- style: [
1053
- otpStyles.underline,
1054
- {
1055
- height: _nullishCoalesce(variantStyles.container.borderBottomWidth, () => ( 1)),
1056
- backgroundColor: animatedBorderColor
1057
- }
1058
- ]
1059
- }
1060
- )
1061
- )
1062
- );
1063
- };
1064
- var OTPInput = ({
1065
- length = 4,
1066
- value,
1067
- defaultValue,
1068
- onValueChange,
1069
- onComplete,
1070
- variant = "colored",
1071
- size = "md",
1072
- radius = "md",
1073
- themeColor = "primary",
1074
- isDisabled = false,
1075
- isInvalid = false,
1076
- isSecured = false,
1077
- errorMessage,
1078
- description,
1079
- label,
1080
- allowedKeys = /^[0-9]$/,
1081
- customAppearance,
1082
- fullWidth = false
1083
- }) => {
1084
- const sizeStyles = useOTPSegmentSizeStyles(size);
1085
- const radiusStyles = useTextInputRadiusStyles(radius);
1086
- const variantStyles = useTextInputVariantStyles({
1087
- themeColor,
1088
- variant,
1089
- isFocused: false,
1090
- isInvalid,
1091
- isDisabled
1092
- });
1093
- const {
1094
- segments,
1095
- activeIndex,
1096
- refs,
1097
- handleSegmentChange,
1098
- handleSegmentKeyPress,
1099
- handleSegmentFocus,
1100
- handleSegmentBlur
1101
- } = useOTPInputState({
1102
- length,
1103
- value,
1104
- defaultValue,
1105
- onValueChange,
1106
- onComplete,
1107
- allowedKeys
1108
- });
1109
- const helperText = isInvalid && errorMessage ? errorMessage : description;
1110
- const helperColor = isInvalid ? variantStyles.helperColor : variantStyles.helperColor;
1111
- const activeVariantStyles = useTextInputVariantStyles({
1112
- themeColor,
1113
- variant,
1114
- isFocused: true,
1115
- isInvalid,
1116
- isDisabled
1117
- });
1118
- const focusSegment = _react.useCallback.call(void 0,
1119
- (index) => {
1120
- if (isDisabled) return;
1121
- _optionalChain([refs, 'access', _39 => _39.current, 'access', _40 => _40[index], 'optionalAccess', _41 => _41.focus, 'call', _42 => _42()]);
1122
- },
1123
- [isDisabled, refs]
1124
- );
1125
- const handleContainerPress = _react.useCallback.call(void 0, () => {
1126
- const firstEmptyIndex = segments.findIndex((segment) => !segment);
1127
- const targetIndex = firstEmptyIndex === -1 ? length - 1 : firstEmptyIndex;
1128
- focusSegment(targetIndex);
1129
- }, [focusSegment, length, segments]);
1130
- return /* @__PURE__ */ _react2.default.createElement(
1131
- _reactnative.View,
1132
- {
1133
- style: [
1134
- otpStyles.container,
1135
- fullWidth && otpStyles.fullWidth,
1136
- isDisabled && otpStyles.disabled,
1137
- _optionalChain([customAppearance, 'optionalAccess', _43 => _43.container])
1138
- ]
1139
- },
1140
- label && /* @__PURE__ */ _react2.default.createElement(
1141
- _reactnative.Text,
1142
- {
1143
- style: [
1144
- otpStyles.label,
1145
- {
1146
- color: variantStyles.labelColor,
1147
- fontSize: 14
1148
- },
1149
- _optionalChain([customAppearance, 'optionalAccess', _44 => _44.label])
1150
- ]
1151
- },
1152
- label
1153
- ),
1154
- /* @__PURE__ */ _react2.default.createElement(
1155
- _reactnative.Pressable,
1156
- {
1157
- onPress: handleContainerPress,
1158
- disabled: isDisabled,
1159
- style: [otpStyles.segmentContainer, _optionalChain([customAppearance, 'optionalAccess', _45 => _45.segmentContainer])]
1160
- },
1161
- segments.map((char, index) => /* @__PURE__ */ _react2.default.createElement(
1162
- OTPSegment,
1163
- {
1164
- key: index,
1165
- char,
1166
- isActive: activeIndex === index,
1167
- isSecured,
1168
- isDisabled,
1169
- variantStyles: activeIndex === index ? activeVariantStyles : variantStyles,
1170
- sizeStyles,
1171
- radiusStyles,
1172
- customSegment: customAppearance,
1173
- customSegmentText: customAppearance,
1174
- inputRef: (ref) => {
1175
- refs.current[index] = ref;
1176
- },
1177
- onChangeText: (text) => handleSegmentChange(index, text),
1178
- onKeyPress: (key) => handleSegmentKeyPress(index, key),
1179
- onFocus: () => handleSegmentFocus(index),
1180
- onBlur: handleSegmentBlur,
1181
- onPress: () => focusSegment(index)
1182
- }
1183
- ))
1184
- ),
1185
- helperText && /* @__PURE__ */ _react2.default.createElement(
1186
- _reactnative.Text,
1187
- {
1188
- style: [
1189
- otpStyles.helperText,
1190
- { color: helperColor, fontSize: 13 },
1191
- _optionalChain([customAppearance, 'optionalAccess', _46 => _46.helperText])
1192
- ]
1193
- },
1194
- helperText
1195
- )
1196
- );
1197
- };
1198
- OTPInput.displayName = "OTPInput";
1199
-
1200
- // src/components/input/number-input.tsx
1201
-
1202
-
1203
-
1204
-
1205
-
1206
- // src/components/input/number-input.hook.ts
1207
-
1208
- var useNumberInputState = ({
1209
- value,
1210
- defaultValue,
1211
- onValueChange,
1212
- minValue,
1213
- maxValue,
1214
- step,
1215
- formatOptions,
1216
- locale
1217
- }) => {
1218
- const isControlled = typeof value === "number";
1219
- const [internalValue, setInternalValue] = _react.useState.call(void 0,
1220
- defaultValue
1221
- );
1222
- const [isEditing, setIsEditing] = _react.useState.call(void 0, false);
1223
- const [rawText, setRawText] = _react.useState.call(void 0, "");
1224
- const currentValue = isControlled ? value : internalValue;
1225
- const formatter = _react.useMemo.call(void 0, () => {
1226
- if (!formatOptions) return null;
1227
- return new Intl.NumberFormat(locale, formatOptions);
1228
- }, [formatOptions, locale]);
1229
- const displayValue = _react.useMemo.call(void 0, () => {
1230
- if (isEditing) return rawText;
1231
- if (currentValue === void 0) return "";
1232
- if (formatter) return formatter.format(currentValue);
1233
- return String(currentValue);
1234
- }, [currentValue, formatter, isEditing, rawText]);
1235
- const updateValue = _react.useCallback.call(void 0,
1236
- (newValue) => {
1237
- if (!isControlled) {
1238
- setInternalValue(newValue);
1239
- }
1240
- _optionalChain([onValueChange, 'optionalCall', _47 => _47(newValue)]);
1241
- },
1242
- [isControlled, onValueChange]
1243
- );
1244
- const clamp = _react.useCallback.call(void 0,
1245
- (num) => {
1246
- let clamped = num;
1247
- if (minValue !== void 0 && clamped < minValue) clamped = minValue;
1248
- if (maxValue !== void 0 && clamped > maxValue) clamped = maxValue;
1249
- return clamped;
1250
- },
1251
- [minValue, maxValue]
1252
- );
1253
- const handleTextChange = _react.useCallback.call(void 0,
1254
- (text) => {
1255
- setRawText(text);
1256
- if (text === "" || text === "-") return;
1257
- const parsed = parseFloat(text);
1258
- if (isNaN(parsed)) return;
1259
- updateValue(parsed);
1260
- },
1261
- [updateValue]
1262
- );
1263
- const handleFocus = _react.useCallback.call(void 0, () => {
1264
- setIsEditing(true);
1265
- setRawText(currentValue !== void 0 ? String(currentValue) : "");
1266
- }, [currentValue]);
1267
- const handleBlur = _react.useCallback.call(void 0, () => {
1268
- setIsEditing(false);
1269
- if (rawText === "" || rawText === "-") {
1270
- updateValue(void 0);
1271
- return;
1272
- }
1273
- const parsed = parseFloat(rawText);
1274
- if (isNaN(parsed)) {
1275
- updateValue(void 0);
1276
- return;
1277
- }
1278
- updateValue(clamp(parsed));
1279
- }, [rawText, clamp, updateValue]);
1280
- const handleClear = _react.useCallback.call(void 0, () => {
1281
- setRawText("");
1282
- updateValue(void 0);
1283
- }, [updateValue]);
1284
- const canIncrement = maxValue === void 0 || (_nullishCoalesce(currentValue, () => ( 0))) + step <= maxValue;
1285
- const canDecrement = minValue === void 0 || (_nullishCoalesce(currentValue, () => ( 0))) - step >= minValue;
1286
- const handleIncrement = _react.useCallback.call(void 0, () => {
1287
- const base = _nullishCoalesce(currentValue, () => ( 0));
1288
- const newValue = clamp(base + step);
1289
- updateValue(newValue);
1290
- }, [currentValue, step, clamp, updateValue]);
1291
- const handleDecrement = _react.useCallback.call(void 0, () => {
1292
- const base = _nullishCoalesce(currentValue, () => ( 0));
1293
- const newValue = clamp(base - step);
1294
- updateValue(newValue);
1295
- }, [currentValue, step, clamp, updateValue]);
1296
- return {
1297
- displayValue,
1298
- handleTextChange,
1299
- handleFocus,
1300
- handleBlur,
1301
- handleClear,
1302
- handleIncrement,
1303
- handleDecrement,
1304
- canIncrement,
1305
- canDecrement
1306
- };
1307
- };
1308
-
1309
- // src/components/input/number-input.style.ts
1310
-
1311
- var numberInputStyles = _reactnative.StyleSheet.create({
1312
- stepperContainer: {
1313
- flexDirection: "row",
1314
- alignItems: "center",
1315
- gap: 4
1316
- },
1317
- stepperButton: {
1318
- justifyContent: "center",
1319
- alignItems: "center",
1320
- width: 28,
1321
- height: 28,
1322
- borderRadius: 6
1323
- },
1324
- stepperDisabled: {
1325
- opacity: 0.4
1326
- }
1327
- });
1328
-
1329
- // src/components/input/number-input.tsx
1330
- var NumberInput = _react.forwardRef.call(void 0,
1331
- ({
1332
- value,
1333
- defaultValue,
1334
- onValueChange,
1335
- minValue,
1336
- maxValue,
1337
- step = 1,
1338
- hideStepper = false,
1339
- formatOptions,
1340
- locale = "en-US",
1341
- label,
1342
- labelPlacement = "outside",
1343
- description,
1344
- errorMessage,
1345
- placeholder,
1346
- themeColor = "primary",
1347
- variant = "colored",
1348
- size = "md",
1349
- radius = "md",
1350
- isDisabled = false,
1351
- isReadOnly = false,
1352
- isInvalid = false,
1353
- isClearable = false,
1354
- fullWidth = true,
1355
- customAppearance
1356
- }, ref) => {
1357
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
1358
- const {
1359
- displayValue,
1360
- handleTextChange,
1361
- handleFocus,
1362
- handleBlur,
1363
- handleIncrement,
1364
- handleDecrement,
1365
- canIncrement,
1366
- canDecrement
1367
- } = useNumberInputState({
1368
- value,
1369
- defaultValue,
1370
- onValueChange,
1371
- minValue,
1372
- maxValue,
1373
- step,
1374
- formatOptions,
1375
- locale
1376
- });
1377
- const iconColor = _core.withOpacity.call(void 0, theme.colors.foreground, 0.7);
1378
- const stepperContent = hideStepper || isReadOnly ? void 0 : /* @__PURE__ */ _react2.default.createElement(
1379
- _reactnative.View,
1380
- {
1381
- style: [
1382
- numberInputStyles.stepperContainer,
1383
- _optionalChain([customAppearance, 'optionalAccess', _48 => _48.stepperContainer])
1384
- ]
1385
- },
1386
- /* @__PURE__ */ _react2.default.createElement(
1387
- _reactnative.Pressable,
1388
- {
1389
- onPress: handleDecrement,
1390
- disabled: isDisabled || !canDecrement,
1391
- accessibilityLabel: "Decrease value",
1392
- accessibilityRole: "button",
1393
- style: [
1394
- numberInputStyles.stepperButton,
1395
- (!canDecrement || isDisabled) && numberInputStyles.stepperDisabled,
1396
- _optionalChain([customAppearance, 'optionalAccess', _49 => _49.stepperButton])
1397
- ]
1398
- },
1399
- /* @__PURE__ */ _react2.default.createElement(_icons.RemoveIcon, { size: 16, color: iconColor })
1400
- ),
1401
- /* @__PURE__ */ _react2.default.createElement(
1402
- _reactnative.Pressable,
1403
- {
1404
- onPress: handleIncrement,
1405
- disabled: isDisabled || !canIncrement,
1406
- accessibilityLabel: "Increase value",
1407
- accessibilityRole: "button",
1408
- style: [
1409
- numberInputStyles.stepperButton,
1410
- (!canIncrement || isDisabled) && numberInputStyles.stepperDisabled,
1411
- _optionalChain([customAppearance, 'optionalAccess', _50 => _50.stepperButton])
1412
- ]
1413
- },
1414
- /* @__PURE__ */ _react2.default.createElement(_icons.AddIcon, { size: 16, color: iconColor })
1415
- )
1416
- );
1417
- return /* @__PURE__ */ _react2.default.createElement(
1418
- TextInput,
1419
- {
1420
- ref,
1421
- value: displayValue,
1422
- onChangeText: handleTextChange,
1423
- onFocus: handleFocus,
1424
- onBlur: handleBlur,
1425
- label,
1426
- labelPlacement,
1427
- description,
1428
- errorMessage,
1429
- placeholder,
1430
- themeColor,
1431
- variant,
1432
- size,
1433
- radius,
1434
- isDisabled,
1435
- isReadOnly,
1436
- isInvalid,
1437
- isClearable,
1438
- fullWidth,
1439
- keyboardType: "numeric",
1440
- endContent: stepperContent,
1441
- customAppearance
1442
- }
1443
- );
1444
- }
1445
- );
1446
- NumberInput.displayName = "NumberInput";
1447
-
1448
-
1449
-
1450
-
1451
-
1452
-
1453
-
1454
-
1455
-
1456
-
1457
-
1458
-
1459
-
1460
-
1461
-
1462
- exports.DateInput = DateInput; exports.DateTimeInput = DateTimeInput; exports.NumberInput = NumberInput; exports.OTPInput = OTPInput; exports.TextArea = TextArea; exports.TextInput = TextInput; exports.TimeInput = TimeInput; exports.dateInputValueToDate = dateInputValueToDate; exports.dateTimeInputValueToDate = dateTimeInputValueToDate; exports.dateToDateInputValue = dateToDateInputValue; exports.dateToDateTimeInputValue = dateToDateTimeInputValue; exports.dateToTimeInputValue = dateToTimeInputValue; exports.getDateOrder = getDateOrder; exports.timeInputValueToDate = timeInputValueToDate;