@xaui/native 0.0.7 → 0.0.9

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 (49) hide show
  1. package/dist/accordion/index.cjs +86 -68
  2. package/dist/accordion/index.js +2 -2
  3. package/dist/autocomplete/index.cjs +1503 -0
  4. package/dist/autocomplete/index.d.cts +70 -0
  5. package/dist/autocomplete/index.d.ts +70 -0
  6. package/dist/autocomplete/index.js +11 -0
  7. package/dist/button/index.cjs +87 -69
  8. package/dist/button/index.js +2 -2
  9. package/dist/checkbox/index.cjs +48 -30
  10. package/dist/checkbox/index.js +1 -1
  11. package/dist/{chunk-B2VGVZ3J.js → chunk-63LRW4QD.js} +1 -1
  12. package/dist/chunk-6HUSEZDJ.js +1138 -0
  13. package/dist/chunk-7LXW4BXD.js +606 -0
  14. package/dist/chunk-GBHQCAKW.js +19 -0
  15. package/dist/{chunk-R34CVLCX.js → chunk-GNJIET26.js} +1 -1
  16. package/dist/chunk-NBRASCX4.js +145 -0
  17. package/dist/chunk-ZYTBRHLJ.js +150 -0
  18. package/dist/core/index.cjs +68 -10
  19. package/dist/core/index.d.cts +9 -1
  20. package/dist/core/index.d.ts +9 -1
  21. package/dist/core/index.js +5 -1
  22. package/dist/divider/index.cjs +31 -13
  23. package/dist/divider/index.js +2 -2
  24. package/dist/icon/index.cjs +680 -0
  25. package/dist/icon/index.d.cts +36 -0
  26. package/dist/icon/index.d.ts +36 -0
  27. package/dist/icon/index.js +13 -0
  28. package/dist/index.cjs +1641 -53
  29. package/dist/index.d.cts +3 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +16 -4
  32. package/dist/indicator/index.cjs +60 -42
  33. package/dist/indicator/index.js +2 -2
  34. package/dist/progress/index.cjs +45 -27
  35. package/dist/progress/index.js +1 -1
  36. package/dist/select/index.cjs +107 -89
  37. package/dist/select/index.js +10 -23
  38. package/dist/switch/index.cjs +58 -40
  39. package/dist/switch/index.js +1 -1
  40. package/dist/typography/index.cjs +223 -0
  41. package/dist/typography/index.d.cts +43 -0
  42. package/dist/typography/index.d.ts +43 -0
  43. package/dist/typography/index.js +7 -0
  44. package/dist/view/index.cjs +966 -0
  45. package/dist/view/index.d.cts +527 -0
  46. package/dist/view/index.d.ts +527 -0
  47. package/dist/view/index.js +923 -0
  48. package/package.json +21 -1
  49. package/dist/chunk-ORMNMNOK.js +0 -89
@@ -0,0 +1,1503 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/autocomplete/index.ts
31
+ var autocomplete_exports = {};
32
+ __export(autocomplete_exports, {
33
+ Autocomplete: () => Autocomplete,
34
+ AutocompleteItem: () => AutocompleteItem
35
+ });
36
+ module.exports = __toCommonJS(autocomplete_exports);
37
+
38
+ // src/components/autocomplete/autocomplete.tsx
39
+ var import_react18 = __toESM(require("react"), 1);
40
+ var import_react_native14 = require("react-native");
41
+
42
+ // src/components/autocomplete/autocomplete-context.ts
43
+ var import_react = require("react");
44
+ var AutocompleteContext = (0, import_react.createContext)({
45
+ size: "md",
46
+ themeColor: "default",
47
+ isDisabled: false
48
+ });
49
+
50
+ // src/components/autocomplete/autocomplete.hook.ts
51
+ var import_react7 = require("react");
52
+ var import_core = require("@xaui/core");
53
+ var import_palette2 = require("@xaui/core/palette");
54
+
55
+ // src/core/theme-context.tsx
56
+ var import_react5 = __toESM(require("react"), 1);
57
+ var import_react_native2 = require("react-native");
58
+ var import_theme = require("@xaui/core/theme");
59
+ var import_palette = require("@xaui/core/palette");
60
+
61
+ // src/core/portal/portal.tsx
62
+ var import_react3 = require("react");
63
+
64
+ // src/core/portal/portal-context.ts
65
+ var import_react2 = require("react");
66
+ var PortalContext = (0, import_react2.createContext)(null);
67
+
68
+ // src/core/portal/portal.tsx
69
+ var portalId = 0;
70
+ var Portal = ({ children }) => {
71
+ const context = (0, import_react3.useContext)(PortalContext);
72
+ const keyRef = (0, import_react3.useRef)(`portal-${++portalId}`);
73
+ (0, import_react3.useLayoutEffect)(() => {
74
+ if (!context) return;
75
+ context.addPortal(keyRef.current, children);
76
+ }, [children, context]);
77
+ (0, import_react3.useEffect)(() => {
78
+ if (!context) return;
79
+ const key = keyRef.current;
80
+ return () => {
81
+ context.removePortal(key);
82
+ };
83
+ }, [context]);
84
+ return null;
85
+ };
86
+
87
+ // src/core/portal/portal-host.tsx
88
+ var import_react4 = __toESM(require("react"), 1);
89
+ var import_react_native = require("react-native");
90
+ var hostStyles = import_react_native.StyleSheet.create({
91
+ container: {
92
+ flex: 1
93
+ }
94
+ });
95
+
96
+ // src/core/theme-context.tsx
97
+ var XUIThemeContext = (0, import_react5.createContext)(null);
98
+
99
+ // src/core/theme-hooks.ts
100
+ var import_react6 = require("react");
101
+ var import_react_native3 = require("react-native");
102
+ function useXUITheme() {
103
+ const theme = (0, import_react6.useContext)(XUIThemeContext);
104
+ if (!theme) {
105
+ throw new Error("useXUITheme must be used within XUIProvider");
106
+ }
107
+ return theme;
108
+ }
109
+
110
+ // src/core/index.ts
111
+ var import_theme2 = require("@xaui/core/theme");
112
+
113
+ // src/components/autocomplete/autocomplete.hook.ts
114
+ var useAutocompleteColorScheme = (themeColor) => {
115
+ const theme = useXUITheme();
116
+ const safeThemeColor = (0, import_core.getSafeThemeColor)(themeColor);
117
+ const colorScheme = theme.colors[safeThemeColor];
118
+ return { theme, colorScheme };
119
+ };
120
+ var useAutocompleteSizeStyles = (size) => {
121
+ const theme = useXUITheme();
122
+ return (0, import_react7.useMemo)(() => {
123
+ const sizes = {
124
+ xs: {
125
+ minHeight: 34,
126
+ paddingHorizontal: theme.spacing.sm,
127
+ paddingVertical: theme.spacing.xs,
128
+ fontSize: theme.fontSizes.xs,
129
+ labelSize: theme.fontSizes.xs
130
+ },
131
+ sm: {
132
+ minHeight: 38,
133
+ paddingHorizontal: theme.spacing.md,
134
+ paddingVertical: theme.spacing.xs,
135
+ fontSize: theme.fontSizes.sm,
136
+ labelSize: theme.fontSizes.xs
137
+ },
138
+ md: {
139
+ minHeight: 42,
140
+ paddingHorizontal: theme.spacing.md,
141
+ paddingVertical: theme.spacing.sm,
142
+ fontSize: theme.fontSizes.md,
143
+ labelSize: theme.fontSizes.sm
144
+ },
145
+ lg: {
146
+ minHeight: 50,
147
+ paddingHorizontal: theme.spacing.lg,
148
+ paddingVertical: theme.spacing.md,
149
+ fontSize: theme.fontSizes.lg,
150
+ labelSize: theme.fontSizes.md
151
+ }
152
+ };
153
+ return sizes[size];
154
+ }, [size, theme]);
155
+ };
156
+ var useAutocompleteRadiusStyles = (radius) => {
157
+ const theme = useXUITheme();
158
+ const radiusStyles = (0, import_react7.useMemo)(() => {
159
+ const radii = {
160
+ none: theme.borderRadius.none,
161
+ sm: theme.borderRadius.sm,
162
+ md: theme.borderRadius.md,
163
+ lg: theme.borderRadius.lg,
164
+ full: theme.borderRadius.full
165
+ };
166
+ return { borderRadius: radii[radius] };
167
+ }, [radius, theme]);
168
+ const listboxRadius = (0, import_react7.useMemo)(() => {
169
+ const radii = {
170
+ none: theme.borderRadius.none,
171
+ sm: theme.borderRadius.sm,
172
+ md: theme.borderRadius.md,
173
+ lg: theme.borderRadius.lg,
174
+ full: theme.borderRadius.full
175
+ };
176
+ return Math.min(radii[radius], theme.borderRadius.lg);
177
+ }, [radius, theme]);
178
+ return { radiusStyles, listboxRadius };
179
+ };
180
+ var useAutocompleteVariantStyles = (themeColor, variant, isInvalid) => {
181
+ const { theme, colorScheme } = useAutocompleteColorScheme(themeColor);
182
+ return (0, import_react7.useMemo)(() => {
183
+ let borderColor = isInvalid ? theme.colors.danger.main : colorScheme.main;
184
+ if ((variant === "outlined" || variant === "faded") && themeColor === "default") {
185
+ borderColor = import_palette2.colors.gray[300];
186
+ }
187
+ const styles4 = {
188
+ outlined: {
189
+ backgroundColor: "transparent",
190
+ borderWidth: theme.borderWidth.md,
191
+ borderColor
192
+ },
193
+ flat: {
194
+ backgroundColor: colorScheme.background,
195
+ borderWidth: 0
196
+ },
197
+ light: {
198
+ backgroundColor: "transparent",
199
+ borderWidth: 0
200
+ },
201
+ faded: {
202
+ backgroundColor: `${colorScheme.background}90`,
203
+ borderWidth: theme.borderWidth.md,
204
+ borderColor
205
+ },
206
+ underlined: {
207
+ backgroundColor: "transparent",
208
+ borderBottomWidth: theme.borderWidth.md,
209
+ borderColor
210
+ }
211
+ };
212
+ return styles4[variant];
213
+ }, [variant, theme, colorScheme, isInvalid, themeColor]);
214
+ };
215
+ var useAutocompleteLabelStyle = (themeColor, isInvalid, labelSize) => {
216
+ const { theme, colorScheme } = useAutocompleteColorScheme(themeColor);
217
+ return (0, import_react7.useMemo)(() => {
218
+ let baseColor = theme.colors.foreground;
219
+ if (isInvalid) {
220
+ baseColor = theme.colors.danger.main;
221
+ } else if (themeColor !== "default") {
222
+ baseColor = colorScheme.main;
223
+ }
224
+ return {
225
+ fontSize: labelSize,
226
+ color: baseColor
227
+ };
228
+ }, [isInvalid, labelSize, theme, themeColor, colorScheme]);
229
+ };
230
+ var useAutocompleteHelperColor = (isInvalid) => {
231
+ const theme = useXUITheme();
232
+ return (0, import_react7.useMemo)(() => {
233
+ if (isInvalid) {
234
+ return theme.colors.danger.main;
235
+ }
236
+ return import_palette2.colors.gray[600];
237
+ }, [isInvalid, theme]);
238
+ };
239
+
240
+ // src/components/autocomplete/autocomplete.style.ts
241
+ var import_react_native4 = require("react-native");
242
+ var styles = import_react_native4.StyleSheet.create({
243
+ container: {
244
+ gap: 6,
245
+ position: "relative"
246
+ },
247
+ fullWidth: {
248
+ flexShrink: 1,
249
+ flexBasis: "auto",
250
+ width: "100%"
251
+ },
252
+ minWidth: {
253
+ minWidth: 170
254
+ },
255
+ label: {
256
+ fontWeight: "500"
257
+ },
258
+ trigger: {
259
+ flexDirection: "row",
260
+ alignItems: "center",
261
+ justifyContent: "space-between",
262
+ gap: 8
263
+ },
264
+ triggerText: {
265
+ flex: 1
266
+ },
267
+ triggerWrapper: {
268
+ position: "relative"
269
+ },
270
+ triggerContent: {
271
+ flexDirection: "row",
272
+ alignItems: "center",
273
+ flex: 1,
274
+ gap: 8
275
+ },
276
+ triggerContentColumn: {
277
+ flexDirection: "column",
278
+ alignItems: "flex-start"
279
+ },
280
+ inputWrapper: {
281
+ flex: 1,
282
+ gap: 2
283
+ },
284
+ input: {
285
+ flexShrink: 1,
286
+ padding: 0
287
+ },
288
+ endSlot: {
289
+ flexDirection: "row",
290
+ alignItems: "center",
291
+ gap: 8
292
+ },
293
+ clearButton: {
294
+ padding: 2,
295
+ paddingLeft: 4,
296
+ marginRight: -4
297
+ },
298
+ helperText: {
299
+ fontSize: 12
300
+ },
301
+ disabled: {
302
+ opacity: 0.5
303
+ },
304
+ listbox: {
305
+ overflow: "hidden",
306
+ marginTop: 0,
307
+ position: "absolute",
308
+ left: 0,
309
+ right: 0,
310
+ zIndex: 50,
311
+ elevation: 4
312
+ },
313
+ listboxContent: {
314
+ flexShrink: 1
315
+ },
316
+ emptyMessage: {
317
+ paddingHorizontal: 16,
318
+ paddingVertical: 12,
319
+ textAlign: "center"
320
+ },
321
+ outsideLeftRow: {
322
+ flexDirection: "row",
323
+ alignItems: "center",
324
+ gap: 12
325
+ }
326
+ });
327
+
328
+ // src/components/autocomplete/autocomplete.state.hook.ts
329
+ var import_react8 = require("react");
330
+ var useAutocompleteOpenState = ({
331
+ isOpened,
332
+ isDisabled,
333
+ onOpenChange,
334
+ onClose
335
+ }) => {
336
+ const [internalIsOpen, setInternalIsOpen] = (0, import_react8.useState)(false);
337
+ const isOpen = isOpened !== void 0 ? isOpened : internalIsOpen;
338
+ const setOpen = (0, import_react8.useCallback)(
339
+ (open) => {
340
+ if (isDisabled) {
341
+ return;
342
+ }
343
+ if (isOpened === void 0) {
344
+ setInternalIsOpen(open);
345
+ }
346
+ onOpenChange?.(open);
347
+ if (!open) {
348
+ onClose?.();
349
+ }
350
+ },
351
+ [isDisabled, isOpened, onOpenChange, onClose]
352
+ );
353
+ return { isOpen, setOpen };
354
+ };
355
+ var useAutocompleteInputState = ({
356
+ inputValue,
357
+ defaultInputValue,
358
+ selectedKey,
359
+ onInputChange
360
+ }) => {
361
+ const [internalInputValue, setInternalInputValue] = (0, import_react8.useState)(defaultInputValue ?? "");
362
+ const currentInputValue = inputValue !== void 0 ? inputValue : internalInputValue;
363
+ const updateInputValue = (0, import_react8.useCallback)(
364
+ (value) => {
365
+ if (inputValue === void 0) {
366
+ setInternalInputValue(value);
367
+ }
368
+ onInputChange?.(value);
369
+ },
370
+ [inputValue, onInputChange]
371
+ );
372
+ (0, import_react8.useEffect)(() => {
373
+ if (selectedKey === null && inputValue === void 0) {
374
+ setInternalInputValue("");
375
+ }
376
+ }, [selectedKey, inputValue]);
377
+ return { currentInputValue, updateInputValue };
378
+ };
379
+ var useAutocompleteSelection = ({
380
+ onSelectionChange
381
+ }) => {
382
+ const [currentSelectedKey, setCurrentSelectedKey] = (0, import_react8.useState)(null);
383
+ const updateSelection = (0, import_react8.useCallback)(
384
+ (key) => {
385
+ setCurrentSelectedKey(key);
386
+ onSelectionChange?.(key);
387
+ },
388
+ [onSelectionChange]
389
+ );
390
+ return { currentSelectedKey, updateSelection };
391
+ };
392
+
393
+ // src/components/autocomplete/autocomplete.utils.ts
394
+ var getTextValue = (node) => {
395
+ if (typeof node === "string" || typeof node === "number") {
396
+ return String(node);
397
+ }
398
+ return null;
399
+ };
400
+ var defaultFilterFunction = (textValue, inputValue) => {
401
+ const normalizedText = textValue.toLowerCase().trim();
402
+ const normalizedInput = inputValue.toLowerCase().trim();
403
+ return normalizedText.includes(normalizedInput);
404
+ };
405
+
406
+ // src/components/dialogs/autocomplete-dialog/autocomplete-dialog.tsx
407
+ var import_react16 = __toESM(require("react"), 1);
408
+ var import_react_native12 = require("react-native");
409
+
410
+ // src/components/select/checkmark-icon.tsx
411
+ var import_react9 = __toESM(require("react"), 1);
412
+ var import_react_native_svg = __toESM(require("react-native-svg"), 1);
413
+ function CheckmarkIcon({ color, size }) {
414
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_native_svg.default, { width: size, height: size, viewBox: "0 0 17 18", fill: "none" }, /* @__PURE__ */ import_react9.default.createElement(
415
+ import_react_native_svg.Polyline,
416
+ {
417
+ points: "1 9 7 14 15 4",
418
+ stroke: color,
419
+ strokeWidth: 2,
420
+ strokeLinecap: "round",
421
+ strokeLinejoin: "round"
422
+ }
423
+ ));
424
+ }
425
+
426
+ // src/components/dialogs/autocomplete-dialog/autocomplete-dialog-header.tsx
427
+ var import_react14 = __toESM(require("react"), 1);
428
+ var import_react_native10 = require("react-native");
429
+
430
+ // src/components/icon/icons/arrow-back.tsx
431
+ var import_react10 = __toESM(require("react"), 1);
432
+ var import_react_native5 = require("react-native");
433
+ var import_react_native_svg2 = __toESM(require("react-native-svg"), 1);
434
+
435
+ // src/components/icon/icon.utils.ts
436
+ var isThemeColor = (color) => {
437
+ const themeColors = [
438
+ "primary",
439
+ "secondary",
440
+ "tertiary",
441
+ "danger",
442
+ "warning",
443
+ "success",
444
+ "default"
445
+ ];
446
+ return themeColors.includes(color);
447
+ };
448
+
449
+ // src/components/icon/icons/arrow-back.tsx
450
+ var AnimatedPath = import_react_native5.Animated.createAnimatedComponent(import_react_native_svg2.Path);
451
+ var ArrowBackIcon = ({
452
+ variant = "baseline",
453
+ size = 24,
454
+ color = "default",
455
+ isAnimated = false
456
+ }) => {
457
+ const theme = useXUITheme();
458
+ const scaleAnim = (0, import_react10.useRef)(new import_react_native5.Animated.Value(isAnimated ? 0 : 1)).current;
459
+ const opacityAnim = (0, import_react10.useRef)(new import_react_native5.Animated.Value(isAnimated ? 0 : 1)).current;
460
+ const resolvedColor = (0, import_react10.useMemo)(() => {
461
+ if (typeof color === "string" && isThemeColor(color)) {
462
+ return theme.colors[color].main;
463
+ }
464
+ return color;
465
+ }, [color, theme]);
466
+ (0, import_react10.useEffect)(() => {
467
+ if (isAnimated) {
468
+ import_react_native5.Animated.parallel([
469
+ import_react_native5.Animated.spring(scaleAnim, {
470
+ toValue: 1,
471
+ useNativeDriver: true,
472
+ tension: 50,
473
+ friction: 7
474
+ }),
475
+ import_react_native5.Animated.timing(opacityAnim, {
476
+ toValue: 1,
477
+ duration: 200,
478
+ useNativeDriver: true
479
+ })
480
+ ]).start();
481
+ }
482
+ }, [isAnimated, scaleAnim, opacityAnim]);
483
+ const animatedProps = isAnimated ? {
484
+ transform: [{ scale: scaleAnim }],
485
+ opacity: opacityAnim
486
+ } : void 0;
487
+ const renderArrow = () => /* @__PURE__ */ import_react10.default.createElement(
488
+ AnimatedPath,
489
+ {
490
+ fill: "none",
491
+ stroke: resolvedColor,
492
+ strokeLinecap: "round",
493
+ strokeLinejoin: "round",
494
+ strokeWidth: 48,
495
+ d: "M244 400L100 256l144-144M120 256h292",
496
+ ...animatedProps
497
+ }
498
+ );
499
+ const renderDuotone = () => /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(
500
+ import_react_native_svg2.Path,
501
+ {
502
+ fill: resolvedColor,
503
+ opacity: 0.3,
504
+ d: "M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48z"
505
+ }
506
+ ), renderArrow());
507
+ const renderRoundOutlined = () => /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(
508
+ import_react_native_svg2.Circle,
509
+ {
510
+ cx: "256",
511
+ cy: "256",
512
+ r: "192",
513
+ fill: "none",
514
+ stroke: resolvedColor,
515
+ strokeWidth: 32
516
+ }
517
+ ), renderArrow());
518
+ const renderSquareOutlined = () => /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(
519
+ import_react_native_svg2.Rect,
520
+ {
521
+ x: "64",
522
+ y: "64",
523
+ width: "384",
524
+ height: "384",
525
+ rx: "48",
526
+ fill: "none",
527
+ stroke: resolvedColor,
528
+ strokeWidth: 32
529
+ }
530
+ ), renderArrow());
531
+ const renderVariant = () => {
532
+ switch (variant) {
533
+ case "duotone":
534
+ return renderDuotone();
535
+ case "round-outlined":
536
+ return renderRoundOutlined();
537
+ case "square-outlined":
538
+ return renderSquareOutlined();
539
+ case "filled":
540
+ case "round-filled":
541
+ case "square-filled":
542
+ case "baseline":
543
+ default:
544
+ return renderArrow();
545
+ }
546
+ };
547
+ return /* @__PURE__ */ import_react10.default.createElement(import_react_native_svg2.default, { width: size, height: size, viewBox: "0 0 512 512" }, renderVariant());
548
+ };
549
+
550
+ // src/components/icon/icons/checkmark.tsx
551
+ var import_react11 = __toESM(require("react"), 1);
552
+ var import_react_native6 = require("react-native");
553
+ var import_react_native_svg3 = __toESM(require("react-native-svg"), 1);
554
+ var AnimatedPath2 = import_react_native6.Animated.createAnimatedComponent(import_react_native_svg3.Path);
555
+
556
+ // src/components/icon/icons/chevron-down.tsx
557
+ var import_react12 = __toESM(require("react"), 1);
558
+ var import_react_native7 = require("react-native");
559
+ var import_react_native_svg4 = __toESM(require("react-native-svg"), 1);
560
+ var AnimatedPath3 = import_react_native7.Animated.createAnimatedComponent(import_react_native_svg4.Path);
561
+
562
+ // src/components/icon/icons/close.tsx
563
+ var import_react13 = __toESM(require("react"), 1);
564
+ var import_react_native8 = require("react-native");
565
+ var import_react_native_svg5 = __toESM(require("react-native-svg"), 1);
566
+ var AnimatedPath4 = import_react_native8.Animated.createAnimatedComponent(import_react_native_svg5.Path);
567
+ var CloseIcon = ({
568
+ variant = "baseline",
569
+ size = 24,
570
+ color = "default",
571
+ isAnimated = false
572
+ }) => {
573
+ const theme = useXUITheme();
574
+ const scaleAnim = (0, import_react13.useRef)(new import_react_native8.Animated.Value(isAnimated ? 0 : 1)).current;
575
+ const opacityAnim = (0, import_react13.useRef)(new import_react_native8.Animated.Value(isAnimated ? 0 : 1)).current;
576
+ const resolvedColor = (0, import_react13.useMemo)(() => {
577
+ if (typeof color === "string" && isThemeColor(color)) {
578
+ return theme.colors[color].main;
579
+ }
580
+ return color;
581
+ }, [color, theme]);
582
+ (0, import_react13.useEffect)(() => {
583
+ if (isAnimated) {
584
+ import_react_native8.Animated.parallel([
585
+ import_react_native8.Animated.spring(scaleAnim, {
586
+ toValue: 1,
587
+ useNativeDriver: true,
588
+ tension: 50,
589
+ friction: 7
590
+ }),
591
+ import_react_native8.Animated.timing(opacityAnim, {
592
+ toValue: 1,
593
+ duration: 200,
594
+ useNativeDriver: true
595
+ })
596
+ ]).start();
597
+ }
598
+ }, [isAnimated, scaleAnim, opacityAnim]);
599
+ const animatedProps = isAnimated ? {
600
+ transform: [{ scale: scaleAnim }],
601
+ opacity: opacityAnim
602
+ } : void 0;
603
+ const renderBaseline = () => /* @__PURE__ */ import_react13.default.createElement(
604
+ AnimatedPath4,
605
+ {
606
+ fill: resolvedColor,
607
+ d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
608
+ ...animatedProps
609
+ }
610
+ );
611
+ const renderFilled = () => /* @__PURE__ */ import_react13.default.createElement(
612
+ AnimatedPath4,
613
+ {
614
+ fill: resolvedColor,
615
+ d: "M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm75.31 260.69a16 16 0 1 1-22.62 22.62L256 278.63l-52.69 52.68a16 16 0 0 1-22.62-22.62L233.37 256l-52.68-52.69a16 16 0 0 1 22.62-22.62L256 233.37l52.69-52.68a16 16 0 0 1 22.62 22.62L278.63 256z",
616
+ ...animatedProps
617
+ }
618
+ );
619
+ const renderDuotone = () => /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
620
+ import_react_native_svg5.Path,
621
+ {
622
+ fill: resolvedColor,
623
+ opacity: 0.3,
624
+ d: "M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48z"
625
+ }
626
+ ), /* @__PURE__ */ import_react13.default.createElement(
627
+ AnimatedPath4,
628
+ {
629
+ fill: resolvedColor,
630
+ d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
631
+ ...animatedProps
632
+ }
633
+ ));
634
+ const renderRoundOutlined = () => /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
635
+ import_react_native_svg5.Circle,
636
+ {
637
+ cx: "256",
638
+ cy: "256",
639
+ r: "192",
640
+ fill: "none",
641
+ stroke: resolvedColor,
642
+ strokeWidth: 32
643
+ }
644
+ ), /* @__PURE__ */ import_react13.default.createElement(
645
+ AnimatedPath4,
646
+ {
647
+ fill: resolvedColor,
648
+ d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
649
+ ...animatedProps
650
+ }
651
+ ));
652
+ const renderSquareOutlined = () => /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
653
+ import_react_native_svg5.Rect,
654
+ {
655
+ x: "64",
656
+ y: "64",
657
+ width: "384",
658
+ height: "384",
659
+ rx: "48",
660
+ fill: "none",
661
+ stroke: resolvedColor,
662
+ strokeWidth: 32
663
+ }
664
+ ), /* @__PURE__ */ import_react13.default.createElement(
665
+ AnimatedPath4,
666
+ {
667
+ fill: resolvedColor,
668
+ d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
669
+ ...animatedProps
670
+ }
671
+ ));
672
+ const renderRoundFilled = () => /* @__PURE__ */ import_react13.default.createElement(
673
+ AnimatedPath4,
674
+ {
675
+ fill: resolvedColor,
676
+ d: "M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm75.31 260.69a16 16 0 1 1-22.62 22.62L256 278.63l-52.69 52.68a16 16 0 0 1-22.62-22.62L233.37 256l-52.68-52.69a16 16 0 0 1 22.62-22.62L256 233.37l52.69-52.68a16 16 0 0 1 22.62 22.62L278.63 256z",
677
+ ...animatedProps
678
+ }
679
+ );
680
+ const renderSquareFilled = () => /* @__PURE__ */ import_react13.default.createElement(
681
+ AnimatedPath4,
682
+ {
683
+ fill: resolvedColor,
684
+ d: "M400 64H112a48 48 0 0 0-48 48v288a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V112a48 48 0 0 0-48-48zm-59.31 244.69a16 16 0 1 1-22.62 22.62L256 278.63l-62.07 52.68a16 16 0 0 1-22.62-22.62L223.37 256l-52.06-52.69a16 16 0 0 1 22.62-22.62L256 233.37l62.07-52.68a16 16 0 0 1 22.62 22.62L288.63 256z",
685
+ ...animatedProps
686
+ }
687
+ );
688
+ const renderVariant = () => {
689
+ switch (variant) {
690
+ case "filled":
691
+ return renderFilled();
692
+ case "duotone":
693
+ return renderDuotone();
694
+ case "round-outlined":
695
+ return renderRoundOutlined();
696
+ case "square-outlined":
697
+ return renderSquareOutlined();
698
+ case "round-filled":
699
+ return renderRoundFilled();
700
+ case "square-filled":
701
+ return renderSquareFilled();
702
+ case "baseline":
703
+ default:
704
+ return renderBaseline();
705
+ }
706
+ };
707
+ return /* @__PURE__ */ import_react13.default.createElement(import_react_native_svg5.default, { width: size, height: size, viewBox: "0 0 512 512" }, renderVariant());
708
+ };
709
+
710
+ // src/components/dialogs/autocomplete-dialog/autocomplete-dialog.style.ts
711
+ var import_react_native9 = require("react-native");
712
+ var styles2 = import_react_native9.StyleSheet.create({
713
+ backdrop: {
714
+ ...import_react_native9.StyleSheet.absoluteFillObject,
715
+ backgroundColor: "rgba(0, 0, 0, 0.5)"
716
+ },
717
+ dialogContainer: {
718
+ flex: 1,
719
+ zIndex: 1
720
+ },
721
+ container: {
722
+ flex: 1,
723
+ paddingTop: 55,
724
+ paddingHorizontal: 16
725
+ },
726
+ header: {
727
+ marginBottom: 12
728
+ },
729
+ titleRow: {
730
+ flexDirection: "row",
731
+ alignItems: "center",
732
+ gap: 8,
733
+ marginBottom: 16
734
+ },
735
+ backButton: {
736
+ padding: 4
737
+ },
738
+ title: {
739
+ fontSize: 20,
740
+ fontWeight: "600"
741
+ },
742
+ inputContainer: {
743
+ flexDirection: "row",
744
+ alignItems: "center",
745
+ gap: 8
746
+ },
747
+ inputWrapper: {
748
+ flex: 1,
749
+ flexDirection: "row",
750
+ alignItems: "center",
751
+ position: "relative"
752
+ },
753
+ input: {
754
+ flex: 1,
755
+ paddingVertical: 12,
756
+ paddingHorizontal: 16,
757
+ paddingRight: 40,
758
+ borderRadius: 8,
759
+ fontSize: 16
760
+ },
761
+ clearInputButton: {
762
+ position: "absolute",
763
+ right: 8,
764
+ padding: 4
765
+ },
766
+ listContainer: {
767
+ flex: 1
768
+ },
769
+ listContentContainer: {
770
+ paddingBottom: 80
771
+ },
772
+ checkmarkButtonContainer: {
773
+ position: "absolute",
774
+ bottom: 24,
775
+ right: 24
776
+ },
777
+ checkmarkButton: {
778
+ width: 54,
779
+ height: 54,
780
+ borderRadius: 27,
781
+ justifyContent: "center",
782
+ alignItems: "center",
783
+ elevation: 8
784
+ }
785
+ });
786
+
787
+ // src/components/dialogs/autocomplete-dialog/autocomplete-dialog-header.tsx
788
+ var addOpacityToColor = (color, opacity) => {
789
+ const hex = color.replace("#", "");
790
+ const r = parseInt(hex.substring(0, 2), 16);
791
+ const g = parseInt(hex.substring(2, 4), 16);
792
+ const b = parseInt(hex.substring(4, 6), 16);
793
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
794
+ };
795
+ var AutocompleteDialogHeader = ({
796
+ title,
797
+ inputValue,
798
+ placeholder = "Search...",
799
+ inputRef,
800
+ inputAnimatedStyle,
801
+ inputTextStyle,
802
+ onInputChange,
803
+ onClose,
804
+ onCheckmarkPress,
805
+ onFocus,
806
+ onBlur
807
+ }) => {
808
+ const theme = useXUITheme();
809
+ return /* @__PURE__ */ import_react14.default.createElement(import_react_native10.View, { style: styles2.header }, title ? /* @__PURE__ */ import_react14.default.createElement(import_react_native10.View, { style: styles2.titleRow }, /* @__PURE__ */ import_react14.default.createElement(
810
+ import_react_native10.Pressable,
811
+ {
812
+ style: styles2.backButton,
813
+ onPress: onClose,
814
+ accessibilityLabel: "Back",
815
+ accessibilityRole: "button"
816
+ },
817
+ /* @__PURE__ */ import_react14.default.createElement(ArrowBackIcon, { size: 20, color: theme.colors.foreground })
818
+ ), /* @__PURE__ */ import_react14.default.createElement(import_react_native10.Text, { style: [styles2.title, { color: theme.colors.foreground }] }, title)) : null, /* @__PURE__ */ import_react14.default.createElement(import_react_native10.View, { style: styles2.inputContainer }, /* @__PURE__ */ import_react14.default.createElement(import_react_native10.Animated.View, { style: [styles2.inputWrapper, inputAnimatedStyle] }, /* @__PURE__ */ import_react14.default.createElement(
819
+ import_react_native10.TextInput,
820
+ {
821
+ ref: inputRef,
822
+ value: inputValue,
823
+ onChangeText: onInputChange,
824
+ placeholder,
825
+ placeholderTextColor: addOpacityToColor(
826
+ theme.colors.foreground,
827
+ 0.5
828
+ ),
829
+ style: [
830
+ styles2.input,
831
+ {
832
+ backgroundColor: theme.colors.default.background,
833
+ color: theme.colors.foreground
834
+ },
835
+ inputTextStyle
836
+ ],
837
+ autoFocus: true,
838
+ returnKeyType: "done",
839
+ onSubmitEditing: onCheckmarkPress,
840
+ onFocus,
841
+ onBlur
842
+ }
843
+ ), inputValue ? /* @__PURE__ */ import_react14.default.createElement(
844
+ import_react_native10.Pressable,
845
+ {
846
+ style: styles2.clearInputButton,
847
+ onPress: () => onInputChange?.(""),
848
+ accessibilityLabel: "Clear input",
849
+ accessibilityRole: "button"
850
+ },
851
+ /* @__PURE__ */ import_react14.default.createElement(CloseIcon, { color: theme.colors.foreground })
852
+ ) : null)));
853
+ };
854
+
855
+ // src/components/dialogs/autocomplete-dialog/autocomplete-dialog.animation.ts
856
+ var import_react15 = require("react");
857
+ var import_react_native11 = require("react-native");
858
+ var useAutocompleteDialogAnimation = ({
859
+ visible,
860
+ fadeAnim,
861
+ slideAnim,
862
+ scaleAnim
863
+ }) => {
864
+ (0, import_react15.useEffect)(() => {
865
+ if (visible) {
866
+ import_react_native11.Animated.parallel([
867
+ import_react_native11.Animated.timing(fadeAnim, {
868
+ toValue: 1,
869
+ duration: 250,
870
+ useNativeDriver: true
871
+ }),
872
+ import_react_native11.Animated.spring(slideAnim, {
873
+ toValue: 1,
874
+ useNativeDriver: true,
875
+ tension: 65,
876
+ friction: 10
877
+ }),
878
+ import_react_native11.Animated.spring(scaleAnim, {
879
+ toValue: 1,
880
+ useNativeDriver: true,
881
+ tension: 50,
882
+ friction: 8
883
+ })
884
+ ]).start();
885
+ } else {
886
+ fadeAnim.setValue(0);
887
+ slideAnim.setValue(0);
888
+ scaleAnim.setValue(0);
889
+ }
890
+ }, [visible, fadeAnim, slideAnim, scaleAnim]);
891
+ };
892
+
893
+ // src/components/dialogs/autocomplete-dialog/autocomplete-dialog.tsx
894
+ var AutocompleteDialog = ({
895
+ visible,
896
+ inputValue,
897
+ placeholder = "Search...",
898
+ title,
899
+ themeColor = "primary",
900
+ children,
901
+ showCheckmark = true,
902
+ checkmarkIcon,
903
+ inputTextStyle,
904
+ style,
905
+ onInputChange,
906
+ onClose,
907
+ onCheckmark,
908
+ onFocus,
909
+ onBlur
910
+ }) => {
911
+ const theme = useXUITheme();
912
+ const { width: screenWidth, height: screenHeight } = (0, import_react_native12.useWindowDimensions)();
913
+ const fadeAnim = (0, import_react16.useRef)(new import_react_native12.Animated.Value(0)).current;
914
+ const slideAnim = (0, import_react16.useRef)(new import_react_native12.Animated.Value(0)).current;
915
+ const scaleAnim = (0, import_react16.useRef)(new import_react_native12.Animated.Value(0)).current;
916
+ const inputRef = (0, import_react16.useRef)(null);
917
+ const [keyboardHeight, setKeyboardHeight] = (0, import_react16.useState)(0);
918
+ (0, import_react16.useEffect)(() => {
919
+ const showEvent = import_react_native12.Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow";
920
+ const hideEvent = import_react_native12.Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide";
921
+ const showSub = import_react_native12.Keyboard.addListener(showEvent, (e) => {
922
+ setKeyboardHeight(e.endCoordinates.height);
923
+ });
924
+ const hideSub = import_react_native12.Keyboard.addListener(hideEvent, () => {
925
+ setKeyboardHeight(0);
926
+ });
927
+ return () => {
928
+ showSub.remove();
929
+ hideSub.remove();
930
+ };
931
+ }, []);
932
+ const items = (0, import_react16.useMemo)(
933
+ () => import_react16.default.Children.toArray(children).filter(
934
+ import_react16.default.isValidElement
935
+ ),
936
+ [children]
937
+ );
938
+ const checkmarkColor = theme.colors[themeColor].main;
939
+ const checkmarkBackgroundColor = theme.colors[themeColor].background;
940
+ useAutocompleteDialogAnimation({ visible, fadeAnim, slideAnim, scaleAnim });
941
+ (0, import_react16.useEffect)(() => {
942
+ if (!visible) return;
943
+ const sub = import_react_native12.BackHandler.addEventListener("hardwareBackPress", () => {
944
+ onClose?.();
945
+ return true;
946
+ });
947
+ return () => sub.remove();
948
+ }, [visible, onClose]);
949
+ const focusInput = (0, import_react16.useCallback)(() => {
950
+ const delay = import_react_native12.Platform.OS === "android" ? 300 : 100;
951
+ import_react_native12.InteractionManager.runAfterInteractions(() => {
952
+ setTimeout(() => {
953
+ inputRef.current?.focus();
954
+ }, delay);
955
+ });
956
+ }, []);
957
+ const handleCheckmarkPress = () => {
958
+ onCheckmark?.();
959
+ import_react_native12.Keyboard.dismiss();
960
+ };
961
+ (0, import_react16.useEffect)(() => {
962
+ if (!visible) {
963
+ import_react_native12.Keyboard.dismiss();
964
+ return;
965
+ }
966
+ focusInput();
967
+ }, [focusInput, visible]);
968
+ const listBottomPadding = (0, import_react16.useMemo)(() => {
969
+ const basePadding = showCheckmark ? 96 : 64;
970
+ return (keyboardHeight > 0 ? keyboardHeight : 0) + basePadding;
971
+ }, [keyboardHeight, showCheckmark]);
972
+ if (!visible) return null;
973
+ const overlayStyle = {
974
+ position: "absolute",
975
+ top: 0,
976
+ left: 0,
977
+ width: screenWidth,
978
+ height: screenHeight
979
+ };
980
+ const containerAnimatedStyle = {
981
+ transform: [
982
+ {
983
+ translateY: slideAnim.interpolate({
984
+ inputRange: [0, 1],
985
+ outputRange: [screenHeight, 0]
986
+ })
987
+ }
988
+ ]
989
+ };
990
+ const inputAnimatedStyle = {
991
+ transform: [{ scaleX: scaleAnim }]
992
+ };
993
+ const listHeader = /* @__PURE__ */ import_react16.default.createElement(
994
+ AutocompleteDialogHeader,
995
+ {
996
+ title,
997
+ inputValue,
998
+ placeholder,
999
+ inputRef,
1000
+ inputAnimatedStyle,
1001
+ inputTextStyle,
1002
+ onInputChange,
1003
+ onClose,
1004
+ onCheckmarkPress: handleCheckmarkPress,
1005
+ onFocus,
1006
+ onBlur
1007
+ }
1008
+ );
1009
+ return /* @__PURE__ */ import_react16.default.createElement(Portal, null, /* @__PURE__ */ import_react16.default.createElement(import_react_native12.View, { style: [overlayStyle, style] }, /* @__PURE__ */ import_react16.default.createElement(import_react_native12.Animated.View, { style: [styles2.backdrop, { opacity: fadeAnim }] }), /* @__PURE__ */ import_react16.default.createElement(import_react_native12.Animated.View, { style: [styles2.dialogContainer, containerAnimatedStyle] }, /* @__PURE__ */ import_react16.default.createElement(
1010
+ import_react_native12.View,
1011
+ {
1012
+ style: [styles2.container, { backgroundColor: theme.colors.background }]
1013
+ },
1014
+ listHeader,
1015
+ /* @__PURE__ */ import_react16.default.createElement(
1016
+ import_react_native12.FlatList,
1017
+ {
1018
+ data: items,
1019
+ renderItem: ({ item }) => item,
1020
+ keyExtractor: (_, index) => String(index),
1021
+ style: styles2.listContainer,
1022
+ contentContainerStyle: {
1023
+ paddingBottom: listBottomPadding
1024
+ },
1025
+ keyboardShouldPersistTaps: "always",
1026
+ keyboardDismissMode: "none",
1027
+ showsVerticalScrollIndicator: false
1028
+ }
1029
+ ),
1030
+ showCheckmark ? /* @__PURE__ */ import_react16.default.createElement(import_react_native12.View, { style: styles2.checkmarkButtonContainer }, /* @__PURE__ */ import_react16.default.createElement(
1031
+ import_react_native12.Pressable,
1032
+ {
1033
+ style: [
1034
+ styles2.checkmarkButton,
1035
+ { backgroundColor: checkmarkBackgroundColor }
1036
+ ],
1037
+ onPress: handleCheckmarkPress,
1038
+ accessibilityLabel: "Confirm",
1039
+ accessibilityRole: "button"
1040
+ },
1041
+ checkmarkIcon ?? /* @__PURE__ */ import_react16.default.createElement(CheckmarkIcon, { color: checkmarkColor, size: 20 })
1042
+ )) : null
1043
+ ))));
1044
+ };
1045
+
1046
+ // src/components/autocomplete/autocomplete-trigger.tsx
1047
+ var import_react17 = __toESM(require("react"), 1);
1048
+ var import_react_native13 = require("react-native");
1049
+ var AutocompleteTrigger = ({
1050
+ triggerRef,
1051
+ isDisabled,
1052
+ currentSelectedKey,
1053
+ currentInputValue,
1054
+ displayValue,
1055
+ sizeStyles,
1056
+ radiusStyles,
1057
+ variantStyles,
1058
+ theme,
1059
+ isClearable,
1060
+ label,
1061
+ labelText,
1062
+ isLabelInside,
1063
+ clearIcon,
1064
+ style,
1065
+ textStyle,
1066
+ onPress: handleTriggerPress,
1067
+ onClear: handleClear,
1068
+ onLayout: handleTriggerLayout
1069
+ }) => {
1070
+ const renderLabel = isLabelInside && label;
1071
+ return /* @__PURE__ */ import_react17.default.createElement(
1072
+ import_react_native13.Pressable,
1073
+ {
1074
+ ref: triggerRef,
1075
+ onPress: handleTriggerPress,
1076
+ onLayout: handleTriggerLayout,
1077
+ disabled: isDisabled,
1078
+ style: [
1079
+ styles.trigger,
1080
+ {
1081
+ minHeight: sizeStyles.minHeight,
1082
+ paddingHorizontal: sizeStyles.paddingHorizontal,
1083
+ paddingVertical: sizeStyles.paddingVertical
1084
+ },
1085
+ radiusStyles,
1086
+ variantStyles,
1087
+ isDisabled && styles.disabled,
1088
+ style
1089
+ ],
1090
+ accessibilityLabel: labelText ?? (typeof label === "string" ? label : void 0),
1091
+ accessibilityRole: "button",
1092
+ accessibilityState: { disabled: isDisabled }
1093
+ },
1094
+ /* @__PURE__ */ import_react17.default.createElement(import_react_native13.View, { style: styles.triggerContent }, isLabelInside && renderLabel, /* @__PURE__ */ import_react17.default.createElement(
1095
+ import_react_native13.Text,
1096
+ {
1097
+ style: [
1098
+ styles.triggerText,
1099
+ { fontSize: sizeStyles.fontSize, color: theme.colors.foreground },
1100
+ !currentSelectedKey && !currentInputValue && { opacity: 0.5 },
1101
+ textStyle
1102
+ ],
1103
+ numberOfLines: 1,
1104
+ ellipsizeMode: "tail"
1105
+ },
1106
+ displayValue
1107
+ )),
1108
+ isClearable && (currentSelectedKey || currentInputValue) ? /* @__PURE__ */ import_react17.default.createElement(
1109
+ import_react_native13.TouchableOpacity,
1110
+ {
1111
+ onPress: handleClear,
1112
+ style: styles.clearButton,
1113
+ hitSlop: { top: 8, right: 8, bottom: 8, left: 8 }
1114
+ },
1115
+ clearIcon ?? /* @__PURE__ */ import_react17.default.createElement(CloseIcon, { color: theme.colors.foreground, size: 20 })
1116
+ ) : null
1117
+ );
1118
+ };
1119
+
1120
+ // src/components/autocomplete/autocomplete.tsx
1121
+ var defaultPlaceholder = "Search...";
1122
+ var Autocomplete = ({
1123
+ children,
1124
+ variant = "flat",
1125
+ themeColor = "default",
1126
+ size = "md",
1127
+ radius = "md",
1128
+ placeholder = defaultPlaceholder,
1129
+ labelPlacement = "outside",
1130
+ label,
1131
+ description,
1132
+ errorMessage,
1133
+ clearIcon,
1134
+ fullWidth = false,
1135
+ isDisabled = false,
1136
+ isInvalid = false,
1137
+ isClearable = true,
1138
+ allowsCustomValue = false,
1139
+ forceSelection = false,
1140
+ allowsEmptyCollection = true,
1141
+ disableLocalFilter = false,
1142
+ inputValue,
1143
+ defaultInputValue,
1144
+ style,
1145
+ textStyle,
1146
+ onClose,
1147
+ onOpenChange,
1148
+ onSelectionChange,
1149
+ onInputChange,
1150
+ onClear
1151
+ }) => {
1152
+ const { currentSelectedKey, updateSelection } = useAutocompleteSelection({
1153
+ onSelectionChange
1154
+ });
1155
+ const { currentInputValue, updateInputValue } = useAutocompleteInputState({
1156
+ inputValue,
1157
+ defaultInputValue,
1158
+ selectedKey: currentSelectedKey,
1159
+ onInputChange
1160
+ });
1161
+ const { isOpen, setOpen } = useAutocompleteOpenState({
1162
+ isOpened: void 0,
1163
+ isDisabled,
1164
+ onOpenChange,
1165
+ onClose
1166
+ });
1167
+ const triggerRef = (0, import_react18.useRef)(null);
1168
+ const [triggerLayout, setTriggerLayout] = (0, import_react18.useState)();
1169
+ const handleTriggerLayout = (0, import_react18.useCallback)(() => {
1170
+ triggerRef.current?.measureInWindow((x, y, width, height) => {
1171
+ setTriggerLayout({ x, y, width, height });
1172
+ });
1173
+ }, []);
1174
+ const items = (0, import_react18.useMemo)(() => {
1175
+ const elements = import_react18.default.Children.toArray(children).filter(Boolean);
1176
+ return elements.map((child, index) => {
1177
+ if (!import_react18.default.isValidElement(child)) {
1178
+ return null;
1179
+ }
1180
+ const key = child.props.value ?? String(index);
1181
+ const labelText = getTextValue(child.props.label) ?? key;
1182
+ return {
1183
+ key,
1184
+ element: child,
1185
+ labelText
1186
+ };
1187
+ }).filter((item) => item !== null);
1188
+ }, [children]);
1189
+ const filteredItems = (0, import_react18.useMemo)(() => {
1190
+ if (disableLocalFilter || !currentInputValue.trim()) {
1191
+ return items;
1192
+ }
1193
+ return items.filter(
1194
+ (item) => defaultFilterFunction(item.labelText, currentInputValue)
1195
+ );
1196
+ }, [disableLocalFilter, items, currentInputValue]);
1197
+ const theme = useXUITheme();
1198
+ const sizeStyles = useAutocompleteSizeStyles(size);
1199
+ const { radiusStyles } = useAutocompleteRadiusStyles(radius);
1200
+ const variantStyles = useAutocompleteVariantStyles(themeColor, variant, isInvalid);
1201
+ const labelStyle = useAutocompleteLabelStyle(
1202
+ themeColor,
1203
+ isInvalid,
1204
+ sizeStyles.labelSize
1205
+ );
1206
+ const helperColor = useAutocompleteHelperColor(isInvalid);
1207
+ const selectedItem = items.find((item) => item.key === currentSelectedKey);
1208
+ const displayValue = forceSelection ? selectedItem?.labelText || placeholder : currentInputValue || placeholder;
1209
+ const handleInputChange = (0, import_react18.useCallback)(
1210
+ (text) => {
1211
+ updateInputValue(text);
1212
+ const selectedLabel = selectedItem?.labelText ?? "";
1213
+ const shouldClearSelection = !text.trim() && !allowsCustomValue || currentSelectedKey !== null && text !== selectedLabel;
1214
+ if (shouldClearSelection) {
1215
+ updateSelection(null);
1216
+ }
1217
+ },
1218
+ [
1219
+ updateInputValue,
1220
+ allowsCustomValue,
1221
+ updateSelection,
1222
+ selectedItem,
1223
+ currentSelectedKey
1224
+ ]
1225
+ );
1226
+ const handleItemSelection = (0, import_react18.useCallback)(
1227
+ (key, itemLabel) => {
1228
+ if (isDisabled) {
1229
+ return;
1230
+ }
1231
+ updateSelection(key);
1232
+ updateInputValue(itemLabel);
1233
+ setTimeout(() => {
1234
+ import_react_native14.Keyboard.dismiss();
1235
+ setOpen(false);
1236
+ }, 50);
1237
+ },
1238
+ [isDisabled, updateSelection, updateInputValue, setOpen]
1239
+ );
1240
+ const handleCheckmark = (0, import_react18.useCallback)(() => {
1241
+ setOpen(false);
1242
+ }, [setOpen]);
1243
+ const handleClear = (0, import_react18.useCallback)(() => {
1244
+ if (isDisabled) {
1245
+ return;
1246
+ }
1247
+ updateSelection(null);
1248
+ updateInputValue("");
1249
+ onClear?.();
1250
+ }, [isDisabled, updateSelection, updateInputValue, onClear]);
1251
+ const handleTriggerPress = (0, import_react18.useCallback)(() => {
1252
+ if (!isDisabled) {
1253
+ if (selectedItem && !currentInputValue) {
1254
+ updateInputValue(selectedItem.labelText);
1255
+ }
1256
+ setOpen(true);
1257
+ }
1258
+ }, [isDisabled, setOpen, selectedItem, currentInputValue, updateInputValue]);
1259
+ const listItems = filteredItems.map((item) => {
1260
+ const itemProps = item.element.props;
1261
+ const itemDisabled = isDisabled || itemProps.isDisabled;
1262
+ const itemSelected = itemProps.isSelected ?? currentSelectedKey === item.key;
1263
+ const handleItemSelected = () => {
1264
+ if (itemDisabled || itemProps.isReadOnly) {
1265
+ return;
1266
+ }
1267
+ handleItemSelection(item.key, item.labelText);
1268
+ itemProps.onSelected?.();
1269
+ };
1270
+ return import_react18.default.cloneElement(item.element, {
1271
+ key: item.key,
1272
+ isDisabled: itemDisabled,
1273
+ isSelected: itemSelected,
1274
+ onSelected: handleItemSelected
1275
+ });
1276
+ });
1277
+ const showEmptyMessage = !allowsEmptyCollection && listItems.length === 0;
1278
+ const isLabelInside = labelPlacement === "inside";
1279
+ const isLabelOutsideLeft = labelPlacement === "outside-left";
1280
+ const isLabelOutside = labelPlacement === "outside" || labelPlacement === "outside-top";
1281
+ const renderLabel = label ? typeof label === "string" || typeof label === "number" ? /* @__PURE__ */ import_react18.default.createElement(import_react_native14.Text, { style: [styles.label, labelStyle] }, label) : /* @__PURE__ */ import_react18.default.createElement(import_react_native14.View, null, label) : null;
1282
+ const shouldShowHelper = Boolean(description || errorMessage);
1283
+ const helperContent = isInvalid && errorMessage ? errorMessage : description;
1284
+ const triggerContent = /* @__PURE__ */ import_react18.default.createElement(
1285
+ AutocompleteTrigger,
1286
+ {
1287
+ triggerRef,
1288
+ isDisabled,
1289
+ currentSelectedKey,
1290
+ currentInputValue,
1291
+ displayValue,
1292
+ sizeStyles,
1293
+ radiusStyles,
1294
+ variantStyles,
1295
+ theme,
1296
+ isClearable,
1297
+ label: renderLabel,
1298
+ labelText: typeof label === "string" ? label : void 0,
1299
+ isLabelInside,
1300
+ clearIcon,
1301
+ style,
1302
+ textStyle,
1303
+ onPress: handleTriggerPress,
1304
+ onClear: handleClear,
1305
+ onLayout: handleTriggerLayout
1306
+ }
1307
+ );
1308
+ const labelBlock = isLabelOutside || isLabelInside ? renderLabel : null;
1309
+ return /* @__PURE__ */ import_react18.default.createElement(import_react_native14.View, { style: [styles.container, fullWidth ? styles.fullWidth : styles.minWidth] }, isLabelOutside && labelBlock, isLabelOutsideLeft ? /* @__PURE__ */ import_react18.default.createElement(import_react_native14.View, { style: styles.outsideLeftRow }, renderLabel, triggerContent) : triggerContent, shouldShowHelper && helperContent ? typeof helperContent === "string" || typeof helperContent === "number" ? /* @__PURE__ */ import_react18.default.createElement(import_react_native14.Text, { style: [styles.helperText, { color: helperColor }] }, helperContent) : /* @__PURE__ */ import_react18.default.createElement(import_react_native14.View, null, helperContent) : null, /* @__PURE__ */ import_react18.default.createElement(
1310
+ AutocompleteDialog,
1311
+ {
1312
+ visible: isOpen,
1313
+ inputValue: currentInputValue,
1314
+ placeholder,
1315
+ title: typeof label === "string" ? label : void 0,
1316
+ themeColor,
1317
+ _triggerLayout: triggerLayout,
1318
+ showCheckmark: false,
1319
+ onInputChange: handleInputChange,
1320
+ onClose: () => setOpen(false),
1321
+ onCheckmark: handleCheckmark
1322
+ },
1323
+ /* @__PURE__ */ import_react18.default.createElement(AutocompleteContext.Provider, { value: { size, themeColor, isDisabled } }, showEmptyMessage ? /* @__PURE__ */ import_react18.default.createElement(import_react_native14.Text, { style: [styles.emptyMessage, { color: theme.colors.foreground }] }, "No results found") : listItems)
1324
+ ));
1325
+ };
1326
+
1327
+ // src/components/autocomplete/autocomplete-item.tsx
1328
+ var import_react20 = __toESM(require("react"), 1);
1329
+ var import_react_native16 = require("react-native");
1330
+
1331
+ // src/components/autocomplete/autocomplete-item.style.ts
1332
+ var import_react_native15 = require("react-native");
1333
+ var styles3 = import_react_native15.StyleSheet.create({
1334
+ item: {
1335
+ flexDirection: "row",
1336
+ alignItems: "center",
1337
+ gap: 8
1338
+ },
1339
+ content: {
1340
+ flex: 1,
1341
+ gap: 2
1342
+ },
1343
+ title: {
1344
+ fontWeight: "500"
1345
+ },
1346
+ description: {
1347
+ opacity: 0.7
1348
+ },
1349
+ disabled: {
1350
+ opacity: 0.5
1351
+ }
1352
+ });
1353
+
1354
+ // src/components/autocomplete/autocomplete-item.hook.ts
1355
+ var import_react19 = require("react");
1356
+ var import_core10 = require("@xaui/core");
1357
+ var useAutocompleteItemSizeStyles = (size) => {
1358
+ const theme = useXUITheme();
1359
+ return (0, import_react19.useMemo)(() => {
1360
+ const sizes = {
1361
+ xs: {
1362
+ paddingVertical: theme.spacing.sm,
1363
+ paddingHorizontal: theme.spacing.sm,
1364
+ titleSize: theme.fontSizes.xs,
1365
+ descriptionSize: theme.fontSizes.xs
1366
+ },
1367
+ sm: {
1368
+ paddingVertical: theme.spacing.sm,
1369
+ paddingHorizontal: theme.spacing.sm,
1370
+ titleSize: theme.fontSizes.sm,
1371
+ descriptionSize: theme.fontSizes.xs
1372
+ },
1373
+ md: {
1374
+ paddingVertical: theme.spacing.sm,
1375
+ paddingHorizontal: theme.spacing.sm,
1376
+ titleSize: theme.fontSizes.md,
1377
+ descriptionSize: theme.fontSizes.xs
1378
+ },
1379
+ lg: {
1380
+ paddingVertical: theme.spacing.sm,
1381
+ paddingHorizontal: theme.spacing.sm,
1382
+ titleSize: theme.fontSizes.lg,
1383
+ descriptionSize: theme.fontSizes.md
1384
+ }
1385
+ };
1386
+ return sizes[size];
1387
+ }, [size, theme]);
1388
+ };
1389
+ var useAutocompleteItemBackgroundColor = (themeColor, isSelected) => {
1390
+ const theme = useXUITheme();
1391
+ const safeThemeColor = (0, import_core10.getSafeThemeColor)(themeColor);
1392
+ const colorScheme = theme.colors[safeThemeColor];
1393
+ return (0, import_react19.useMemo)(() => {
1394
+ return "transparent";
1395
+ }, [isSelected, colorScheme]);
1396
+ };
1397
+ var useAutocompleteItemTextColors = () => {
1398
+ const theme = useXUITheme();
1399
+ return (0, import_react19.useMemo)(() => {
1400
+ return {
1401
+ textColor: theme.colors.foreground,
1402
+ descriptionColor: theme.colors.foreground
1403
+ };
1404
+ }, [theme]);
1405
+ };
1406
+ var useAutocompleteItemCheckmarkColor = (themeColor) => {
1407
+ const theme = useXUITheme();
1408
+ const safeThemeColor = (0, import_core10.getSafeThemeColor)(themeColor);
1409
+ const colorScheme = theme.colors[safeThemeColor];
1410
+ return (0, import_react19.useMemo)(() => {
1411
+ if (themeColor === "default") {
1412
+ return theme.colors.primary.main;
1413
+ }
1414
+ return colorScheme.main;
1415
+ }, [themeColor, colorScheme, theme]);
1416
+ };
1417
+ var useAutocompleteItemStyles = (isSelected, _isDisabled) => {
1418
+ const context = (0, import_react19.useContext)(AutocompleteContext);
1419
+ const backgroundColor = useAutocompleteItemBackgroundColor(
1420
+ context.themeColor,
1421
+ isSelected
1422
+ );
1423
+ const { textColor, descriptionColor } = useAutocompleteItemTextColors();
1424
+ const checkmarkColor = useAutocompleteItemCheckmarkColor(context.themeColor);
1425
+ return {
1426
+ backgroundColor,
1427
+ labelColor: textColor,
1428
+ descriptionColor,
1429
+ checkmarkColor
1430
+ };
1431
+ };
1432
+
1433
+ // src/components/autocomplete/autocomplete-item.tsx
1434
+ var defaultSize = "md";
1435
+ var AutocompleteItem = ({
1436
+ label,
1437
+ description,
1438
+ startContent,
1439
+ endContent,
1440
+ selectedIcon: _selectedIcon,
1441
+ isDisabled = false,
1442
+ isSelected = false,
1443
+ isReadOnly = false,
1444
+ style,
1445
+ textStyle,
1446
+ onSelected
1447
+ }) => {
1448
+ const context = (0, import_react20.useContext)(AutocompleteContext);
1449
+ const size = context?.size ?? defaultSize;
1450
+ const isItemDisabled = context?.isDisabled ? true : isDisabled;
1451
+ const sizeStyles = useAutocompleteItemSizeStyles(size);
1452
+ const { backgroundColor, labelColor, descriptionColor } = useAutocompleteItemStyles(isSelected, isItemDisabled);
1453
+ const handlePress = () => {
1454
+ if (isItemDisabled || isReadOnly) {
1455
+ return;
1456
+ }
1457
+ onSelected?.();
1458
+ };
1459
+ return /* @__PURE__ */ import_react20.default.createElement(
1460
+ import_react_native16.Pressable,
1461
+ {
1462
+ onPress: handlePress,
1463
+ disabled: isItemDisabled,
1464
+ style: [
1465
+ styles3.item,
1466
+ {
1467
+ paddingVertical: sizeStyles.paddingVertical,
1468
+ paddingHorizontal: sizeStyles.paddingHorizontal,
1469
+ backgroundColor
1470
+ },
1471
+ isItemDisabled && styles3.disabled,
1472
+ style
1473
+ ]
1474
+ },
1475
+ startContent,
1476
+ /* @__PURE__ */ import_react20.default.createElement(import_react_native16.View, { style: styles3.content }, /* @__PURE__ */ import_react20.default.createElement(
1477
+ import_react_native16.Text,
1478
+ {
1479
+ style: [
1480
+ styles3.title,
1481
+ { fontSize: sizeStyles.titleSize, color: labelColor },
1482
+ textStyle
1483
+ ]
1484
+ },
1485
+ label
1486
+ ), description && /* @__PURE__ */ import_react20.default.createElement(
1487
+ import_react_native16.Text,
1488
+ {
1489
+ style: [
1490
+ styles3.description,
1491
+ { fontSize: sizeStyles.descriptionSize, color: descriptionColor }
1492
+ ]
1493
+ },
1494
+ description
1495
+ )),
1496
+ endContent
1497
+ );
1498
+ };
1499
+ // Annotate the CommonJS export names for ESM import in node:
1500
+ 0 && (module.exports = {
1501
+ Autocomplete,
1502
+ AutocompleteItem
1503
+ });