@xsolla/xui-autocomplete 0.64.0-pr56.1768440195

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.
@@ -0,0 +1,817 @@
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/index.tsx
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Autocomplete: () => Autocomplete
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/Autocomplete.tsx
38
+ var import_react4 = require("react");
39
+
40
+ // ../primitives-native/src/Box.tsx
41
+ var import_react_native = require("react-native");
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var Box = ({
44
+ children,
45
+ onPress,
46
+ onLayout,
47
+ onMoveShouldSetResponder,
48
+ onResponderGrant,
49
+ onResponderMove,
50
+ onResponderRelease,
51
+ onResponderTerminate,
52
+ backgroundColor,
53
+ borderColor,
54
+ borderWidth,
55
+ borderBottomWidth,
56
+ borderBottomColor,
57
+ borderTopWidth,
58
+ borderTopColor,
59
+ borderLeftWidth,
60
+ borderLeftColor,
61
+ borderRightWidth,
62
+ borderRightColor,
63
+ borderRadius,
64
+ borderStyle,
65
+ height,
66
+ padding,
67
+ paddingHorizontal,
68
+ paddingVertical,
69
+ margin,
70
+ marginTop,
71
+ marginBottom,
72
+ marginLeft,
73
+ marginRight,
74
+ flexDirection,
75
+ alignItems,
76
+ justifyContent,
77
+ position,
78
+ top,
79
+ bottom,
80
+ left,
81
+ right,
82
+ width,
83
+ flex,
84
+ overflow,
85
+ zIndex,
86
+ hoverStyle,
87
+ pressStyle,
88
+ style,
89
+ "data-testid": dataTestId,
90
+ testID,
91
+ as,
92
+ src,
93
+ alt,
94
+ ...rest
95
+ }) => {
96
+ const getContainerStyle = (pressed) => ({
97
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
98
+ borderColor,
99
+ borderWidth,
100
+ borderBottomWidth,
101
+ borderBottomColor,
102
+ borderTopWidth,
103
+ borderTopColor,
104
+ borderLeftWidth,
105
+ borderLeftColor,
106
+ borderRightWidth,
107
+ borderRightColor,
108
+ borderRadius,
109
+ borderStyle,
110
+ overflow,
111
+ zIndex,
112
+ height,
113
+ width,
114
+ padding,
115
+ paddingHorizontal,
116
+ paddingVertical,
117
+ margin,
118
+ marginTop,
119
+ marginBottom,
120
+ marginLeft,
121
+ marginRight,
122
+ flexDirection,
123
+ alignItems,
124
+ justifyContent,
125
+ position,
126
+ top,
127
+ bottom,
128
+ left,
129
+ right,
130
+ flex,
131
+ ...style
132
+ });
133
+ const finalTestID = dataTestId || testID;
134
+ const {
135
+ role,
136
+ tabIndex,
137
+ onKeyDown,
138
+ onKeyUp,
139
+ "aria-label": _ariaLabel,
140
+ "aria-labelledby": _ariaLabelledBy,
141
+ "aria-current": _ariaCurrent,
142
+ "aria-disabled": _ariaDisabled,
143
+ "aria-live": _ariaLive,
144
+ className,
145
+ "data-testid": _dataTestId,
146
+ ...nativeRest
147
+ } = rest;
148
+ if (as === "img" && src) {
149
+ const imageStyle = {
150
+ width,
151
+ height,
152
+ borderRadius,
153
+ position,
154
+ top,
155
+ bottom,
156
+ left,
157
+ right,
158
+ ...style
159
+ };
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
+ import_react_native.Image,
162
+ {
163
+ source: { uri: src },
164
+ style: imageStyle,
165
+ testID: finalTestID,
166
+ resizeMode: "cover",
167
+ ...nativeRest
168
+ }
169
+ );
170
+ }
171
+ if (onPress) {
172
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ import_react_native.Pressable,
174
+ {
175
+ onPress,
176
+ onLayout,
177
+ onMoveShouldSetResponder,
178
+ onResponderGrant,
179
+ onResponderMove,
180
+ onResponderRelease,
181
+ onResponderTerminate,
182
+ style: ({ pressed }) => getContainerStyle(pressed),
183
+ testID: finalTestID,
184
+ ...nativeRest,
185
+ children
186
+ }
187
+ );
188
+ }
189
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
190
+ import_react_native.View,
191
+ {
192
+ style: getContainerStyle(),
193
+ testID: finalTestID,
194
+ onLayout,
195
+ onMoveShouldSetResponder,
196
+ onResponderGrant,
197
+ onResponderMove,
198
+ onResponderRelease,
199
+ onResponderTerminate,
200
+ ...nativeRest,
201
+ children
202
+ }
203
+ );
204
+ };
205
+
206
+ // ../primitives-native/src/Text.tsx
207
+ var import_react_native2 = require("react-native");
208
+ var import_jsx_runtime2 = require("react/jsx-runtime");
209
+ var roleMap = {
210
+ alert: "alert",
211
+ heading: "header",
212
+ button: "button",
213
+ link: "link",
214
+ text: "text"
215
+ };
216
+ var Text = ({
217
+ children,
218
+ color,
219
+ fontSize,
220
+ fontWeight,
221
+ fontFamily,
222
+ id,
223
+ role,
224
+ ...props
225
+ }) => {
226
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
227
+ if (resolvedFontFamily === "Pilat Wide Bold") {
228
+ resolvedFontFamily = void 0;
229
+ }
230
+ const style = {
231
+ color,
232
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
233
+ fontWeight,
234
+ fontFamily: resolvedFontFamily,
235
+ textDecorationLine: props.textDecoration
236
+ };
237
+ const accessibilityRole = role ? roleMap[role] : void 0;
238
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
239
+ };
240
+
241
+ // ../primitives-native/src/Spinner.tsx
242
+ var import_react_native3 = require("react-native");
243
+ var import_jsx_runtime3 = require("react/jsx-runtime");
244
+ var Spinner = ({
245
+ color,
246
+ size,
247
+ role,
248
+ "aria-label": ariaLabel,
249
+ "aria-live": ariaLive,
250
+ "aria-describedby": ariaDescribedBy,
251
+ testID
252
+ }) => {
253
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
254
+ import_react_native3.View,
255
+ {
256
+ accessible: true,
257
+ accessibilityRole: role === "status" ? "none" : void 0,
258
+ accessibilityLabel: ariaLabel,
259
+ accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
260
+ testID,
261
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
262
+ import_react_native3.ActivityIndicator,
263
+ {
264
+ color,
265
+ size: typeof size === "number" ? size : "small"
266
+ }
267
+ )
268
+ }
269
+ );
270
+ };
271
+ Spinner.displayName = "Spinner";
272
+
273
+ // ../primitives-native/src/Icon.tsx
274
+ var import_react = __toESM(require("react"));
275
+ var import_react_native4 = require("react-native");
276
+ var import_jsx_runtime4 = require("react/jsx-runtime");
277
+ var Icon = ({ children, color, size }) => {
278
+ const style = {
279
+ width: typeof size === "number" ? size : void 0,
280
+ height: typeof size === "number" ? size : void 0,
281
+ alignItems: "center",
282
+ justifyContent: "center"
283
+ };
284
+ const childrenWithProps = import_react.default.Children.map(children, (child) => {
285
+ if (import_react.default.isValidElement(child)) {
286
+ return import_react.default.cloneElement(child, {
287
+ color: child.props.color || color,
288
+ // Also pass size if child seems to be an icon that needs it
289
+ size: child.props.size || size
290
+ });
291
+ }
292
+ return child;
293
+ });
294
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.View, { style, children: childrenWithProps });
295
+ };
296
+
297
+ // ../primitives-native/src/Divider.tsx
298
+ var import_react_native5 = require("react-native");
299
+ var import_jsx_runtime5 = require("react/jsx-runtime");
300
+
301
+ // ../primitives-native/src/Input.tsx
302
+ var import_react2 = require("react");
303
+ var import_react_native6 = require("react-native");
304
+ var import_jsx_runtime6 = require("react/jsx-runtime");
305
+ var keyboardTypeMap = {
306
+ text: "default",
307
+ number: "numeric",
308
+ email: "email-address",
309
+ tel: "phone-pad",
310
+ url: "url",
311
+ decimal: "decimal-pad"
312
+ };
313
+ var inputModeToKeyboardType = {
314
+ none: "default",
315
+ text: "default",
316
+ decimal: "decimal-pad",
317
+ numeric: "number-pad",
318
+ tel: "phone-pad",
319
+ search: "default",
320
+ email: "email-address",
321
+ url: "url"
322
+ };
323
+ var autoCompleteToTextContentType = {
324
+ "one-time-code": "oneTimeCode",
325
+ email: "emailAddress",
326
+ username: "username",
327
+ password: "password",
328
+ "new-password": "newPassword",
329
+ tel: "telephoneNumber",
330
+ "postal-code": "postalCode",
331
+ name: "name"
332
+ };
333
+ var InputPrimitive = (0, import_react2.forwardRef)(
334
+ ({
335
+ value,
336
+ placeholder,
337
+ onChange,
338
+ onChangeText,
339
+ onFocus,
340
+ onBlur,
341
+ onKeyDown,
342
+ disabled,
343
+ secureTextEntry,
344
+ style,
345
+ color,
346
+ fontSize,
347
+ placeholderTextColor,
348
+ maxLength,
349
+ name,
350
+ type,
351
+ inputMode,
352
+ autoComplete,
353
+ id,
354
+ "aria-invalid": ariaInvalid,
355
+ "aria-describedby": ariaDescribedBy,
356
+ "aria-labelledby": ariaLabelledBy,
357
+ "aria-label": ariaLabel,
358
+ "aria-disabled": ariaDisabled,
359
+ "data-testid": dataTestId
360
+ }, ref) => {
361
+ const handleChangeText = (text) => {
362
+ onChangeText?.(text);
363
+ if (onChange) {
364
+ const syntheticEvent = {
365
+ target: { value: text },
366
+ currentTarget: { value: text },
367
+ type: "change",
368
+ nativeEvent: { text },
369
+ preventDefault: () => {
370
+ },
371
+ stopPropagation: () => {
372
+ },
373
+ isTrusted: false
374
+ };
375
+ onChange(syntheticEvent);
376
+ }
377
+ };
378
+ const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
379
+ const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
380
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
381
+ import_react_native6.TextInput,
382
+ {
383
+ ref,
384
+ value,
385
+ placeholder,
386
+ onChangeText: handleChangeText,
387
+ onFocus,
388
+ onBlur,
389
+ onKeyPress: (e) => {
390
+ if (onKeyDown) {
391
+ onKeyDown({
392
+ key: e.nativeEvent.key,
393
+ preventDefault: () => {
394
+ }
395
+ });
396
+ }
397
+ },
398
+ editable: !disabled,
399
+ secureTextEntry: secureTextEntry || type === "password",
400
+ keyboardType,
401
+ textContentType,
402
+ style: [
403
+ {
404
+ color,
405
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
406
+ flex: 1,
407
+ padding: 0,
408
+ textAlign: style?.textAlign || "left"
409
+ },
410
+ style
411
+ ],
412
+ placeholderTextColor,
413
+ maxLength,
414
+ testID: dataTestId || id,
415
+ accessibilityLabel: ariaLabel,
416
+ accessibilityHint: ariaDescribedBy,
417
+ accessibilityState: {
418
+ disabled: disabled || ariaDisabled
419
+ },
420
+ accessible: true
421
+ }
422
+ );
423
+ }
424
+ );
425
+ InputPrimitive.displayName = "InputPrimitive";
426
+
427
+ // ../primitives-native/src/TextArea.tsx
428
+ var import_react3 = require("react");
429
+ var import_react_native7 = require("react-native");
430
+ var import_jsx_runtime7 = require("react/jsx-runtime");
431
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
432
+ ({
433
+ value,
434
+ placeholder,
435
+ onChange,
436
+ onChangeText,
437
+ onFocus,
438
+ onBlur,
439
+ onKeyDown,
440
+ disabled,
441
+ style,
442
+ color,
443
+ fontSize,
444
+ placeholderTextColor,
445
+ maxLength,
446
+ rows,
447
+ id,
448
+ "aria-invalid": ariaInvalid,
449
+ "aria-describedby": ariaDescribedBy,
450
+ "aria-labelledby": ariaLabelledBy,
451
+ "aria-label": ariaLabel,
452
+ "aria-disabled": ariaDisabled,
453
+ "data-testid": dataTestId
454
+ }, ref) => {
455
+ const handleChangeText = (text) => {
456
+ onChangeText?.(text);
457
+ if (onChange) {
458
+ const syntheticEvent = {
459
+ target: { value: text },
460
+ currentTarget: { value: text },
461
+ type: "change",
462
+ nativeEvent: { text },
463
+ preventDefault: () => {
464
+ },
465
+ stopPropagation: () => {
466
+ },
467
+ isTrusted: false
468
+ };
469
+ onChange(syntheticEvent);
470
+ }
471
+ };
472
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
473
+ import_react_native7.TextInput,
474
+ {
475
+ ref,
476
+ value,
477
+ placeholder,
478
+ onChangeText: handleChangeText,
479
+ onFocus,
480
+ onBlur,
481
+ onKeyPress: (e) => {
482
+ if (onKeyDown) {
483
+ onKeyDown({
484
+ key: e.nativeEvent.key,
485
+ preventDefault: () => {
486
+ }
487
+ });
488
+ }
489
+ },
490
+ editable: !disabled,
491
+ multiline: true,
492
+ numberOfLines: rows || 4,
493
+ style: [
494
+ {
495
+ color,
496
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
497
+ flex: 1,
498
+ padding: 0,
499
+ textAlignVertical: "top",
500
+ textAlign: style?.textAlign || "left"
501
+ },
502
+ style
503
+ ],
504
+ placeholderTextColor,
505
+ maxLength,
506
+ testID: dataTestId || id,
507
+ accessibilityLabel: ariaLabel,
508
+ accessibilityHint: ariaDescribedBy,
509
+ accessibilityState: {
510
+ disabled: disabled || ariaDisabled
511
+ },
512
+ accessible: true
513
+ }
514
+ );
515
+ }
516
+ );
517
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
518
+
519
+ // src/Autocomplete.tsx
520
+ var import_xui_core = require("@xsolla/xui-core");
521
+ var import_jsx_runtime8 = require("react/jsx-runtime");
522
+ var SearchIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
523
+ "svg",
524
+ {
525
+ width: "100%",
526
+ height: "100%",
527
+ viewBox: "0 0 18 18",
528
+ fill: "none",
529
+ xmlns: "http://www.w3.org/2000/svg",
530
+ children: [
531
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
532
+ "path",
533
+ {
534
+ d: "M8.25 14.25C11.5637 14.25 14.25 11.5637 14.25 8.25C14.25 4.93629 11.5637 2.25 8.25 2.25C4.93629 2.25 2.25 4.93629 2.25 8.25C2.25 11.5637 4.93629 14.25 8.25 14.25Z",
535
+ stroke: "currentColor",
536
+ strokeWidth: "1.5",
537
+ strokeLinecap: "round",
538
+ strokeLinejoin: "round"
539
+ }
540
+ ),
541
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
542
+ "path",
543
+ {
544
+ d: "M15.75 15.75L12.4875 12.4875",
545
+ stroke: "currentColor",
546
+ strokeWidth: "1.5",
547
+ strokeLinecap: "round",
548
+ strokeLinejoin: "round"
549
+ }
550
+ )
551
+ ]
552
+ }
553
+ );
554
+ var ChevronDown = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
555
+ "svg",
556
+ {
557
+ width: "100%",
558
+ height: "100%",
559
+ viewBox: "0 0 18 18",
560
+ fill: "none",
561
+ xmlns: "http://www.w3.org/2000/svg",
562
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
563
+ "path",
564
+ {
565
+ d: "M4.5 6.75L9 11.25L13.5 6.75",
566
+ stroke: "currentColor",
567
+ strokeWidth: "1.5",
568
+ strokeLinecap: "round",
569
+ strokeLinejoin: "round"
570
+ }
571
+ )
572
+ }
573
+ );
574
+ var ChevronUp = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
575
+ "svg",
576
+ {
577
+ width: "100%",
578
+ height: "100%",
579
+ viewBox: "0 0 18 18",
580
+ fill: "none",
581
+ xmlns: "http://www.w3.org/2000/svg",
582
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
583
+ "path",
584
+ {
585
+ d: "M13.5 11.25L9 6.75L4.5 11.25",
586
+ stroke: "currentColor",
587
+ strokeWidth: "1.5",
588
+ strokeLinecap: "round",
589
+ strokeLinejoin: "round"
590
+ }
591
+ )
592
+ }
593
+ );
594
+ var CloseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
595
+ "svg",
596
+ {
597
+ width: "100%",
598
+ height: "100%",
599
+ viewBox: "0 0 18 18",
600
+ fill: "none",
601
+ xmlns: "http://www.w3.org/2000/svg",
602
+ children: [
603
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
604
+ "path",
605
+ {
606
+ d: "M13.5 4.5L4.5 13.5",
607
+ stroke: "currentColor",
608
+ strokeWidth: "1.5",
609
+ strokeLinecap: "round",
610
+ strokeLinejoin: "round"
611
+ }
612
+ ),
613
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
614
+ "path",
615
+ {
616
+ d: "M4.5 4.5L13.5 13.5",
617
+ stroke: "currentColor",
618
+ strokeWidth: "1.5",
619
+ strokeLinecap: "round",
620
+ strokeLinejoin: "round"
621
+ }
622
+ )
623
+ ]
624
+ }
625
+ );
626
+ var Autocomplete = ({
627
+ value: propValue,
628
+ placeholder = "Search...",
629
+ onValueChange,
630
+ onSelect,
631
+ options = [],
632
+ isLoading = false,
633
+ size = "m",
634
+ state: externalState,
635
+ label,
636
+ errorLabel,
637
+ iconLeft = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SearchIcon, {}),
638
+ chevronRight = true,
639
+ filled = true
640
+ }) => {
641
+ const { theme } = (0, import_xui_core.useDesignSystem)();
642
+ const [internalValue, setInternalValue] = (0, import_react4.useState)(propValue || "");
643
+ const [isFocused, setIsFocused] = (0, import_react4.useState)(false);
644
+ const containerRef = (0, import_react4.useRef)(null);
645
+ const value = propValue !== void 0 ? propValue : internalValue;
646
+ const state = externalState || (isFocused ? "focus" : "default");
647
+ const isDisable = state === "disable";
648
+ const isError = state === "error";
649
+ const isFocus = state === "focus";
650
+ const sizeStyles = theme.sizing.input(size);
651
+ const inputColors = theme.colors.control.input;
652
+ (0, import_react4.useEffect)(() => {
653
+ const handleClickOutside = (event) => {
654
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
655
+ setIsFocused(false);
656
+ }
657
+ };
658
+ if (isFocused) {
659
+ document.addEventListener("mousedown", handleClickOutside);
660
+ }
661
+ return () => {
662
+ document.removeEventListener("mousedown", handleClickOutside);
663
+ };
664
+ }, [isFocused]);
665
+ const handleInputChange = (text) => {
666
+ if (!isDisable) {
667
+ setInternalValue(text);
668
+ if (onValueChange) onValueChange(text);
669
+ setIsFocused(true);
670
+ }
671
+ };
672
+ const handleSelect = (option) => {
673
+ setInternalValue(option);
674
+ setIsFocused(false);
675
+ if (onSelect) onSelect(option);
676
+ if (onValueChange) onValueChange(option);
677
+ };
678
+ const handleClear = (e) => {
679
+ e.stopPropagation();
680
+ handleInputChange("");
681
+ };
682
+ let backgroundColor = inputColors.bg;
683
+ let borderColor = inputColors.border;
684
+ if (isDisable) {
685
+ backgroundColor = inputColors.bgDisable;
686
+ borderColor = inputColors.borderDisable;
687
+ } else if (isError) {
688
+ borderColor = theme.colors.border.alert;
689
+ } else if (isFocus) {
690
+ backgroundColor = theme.colors.control.focus.bg;
691
+ borderColor = inputColors.borderHover;
692
+ } else if (state === "hover") {
693
+ backgroundColor = inputColors.bgHover;
694
+ borderColor = inputColors.borderHover;
695
+ }
696
+ if (filled === false && !isFocus && !isError && state !== "hover") {
697
+ backgroundColor = "transparent";
698
+ }
699
+ const textColor = isDisable ? inputColors.textDisable : inputColors.text;
700
+ const placeholderColor = inputColors.placeholder;
701
+ const iconColor = isDisable ? inputColors.textDisable : inputColors.text;
702
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
703
+ Box,
704
+ {
705
+ ref: containerRef,
706
+ flexDirection: "column",
707
+ gap: 4,
708
+ width: "100%",
709
+ position: "relative",
710
+ children: [
711
+ label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
712
+ Text,
713
+ {
714
+ color: theme.colors.content.secondary,
715
+ fontSize: sizeStyles.fontSize - 2,
716
+ fontWeight: "500",
717
+ marginBottom: 4,
718
+ children: label
719
+ }
720
+ ),
721
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
722
+ Box,
723
+ {
724
+ backgroundColor,
725
+ borderColor,
726
+ borderWidth: borderColor !== "transparent" ? 1 : 0,
727
+ borderRadius: theme.radius.button,
728
+ height: sizeStyles.height,
729
+ paddingHorizontal: sizeStyles.padding,
730
+ flexDirection: "row",
731
+ alignItems: "center",
732
+ gap: 10,
733
+ position: "relative",
734
+ hoverStyle: !isDisable && !isFocus && !isError ? {
735
+ backgroundColor: inputColors.bgHover,
736
+ borderColor: inputColors.borderHover
737
+ } : void 0,
738
+ children: [
739
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: sizeStyles.iconSize, color: iconColor, children: iconLeft }) }),
740
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flex: 1, height: "100%", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
741
+ InputPrimitive,
742
+ {
743
+ value,
744
+ placeholder,
745
+ onChangeText: handleInputChange,
746
+ onFocus: () => !isDisable && setIsFocused(true),
747
+ disabled: isDisable,
748
+ color: textColor,
749
+ fontSize: sizeStyles.fontSize,
750
+ placeholderTextColor: placeholderColor
751
+ }
752
+ ) }),
753
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "row", alignItems: "center", gap: 4, children: [
754
+ value.length > 0 && !isDisable && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { onPress: handleClear, padding: 2, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: sizeStyles.iconSize - 2, color: iconColor, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CloseIcon, {}) }) }),
755
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, { size: sizeStyles.iconSize, color: iconColor }) : chevronRight && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: sizeStyles.iconSize, color: iconColor, children: isFocus ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronDown, {}) }) })
756
+ ] })
757
+ ]
758
+ }
759
+ ),
760
+ isFocus && (options.length > 0 || isLoading) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
761
+ Box,
762
+ {
763
+ position: "absolute",
764
+ top: sizeStyles.height + (label ? 28 : 0) + 4,
765
+ left: 0,
766
+ right: 0,
767
+ backgroundColor: theme.colors.background.secondary,
768
+ borderColor: theme.colors.border.secondary,
769
+ borderWidth: 1,
770
+ borderRadius: theme.radius.button,
771
+ paddingVertical: 4,
772
+ style: {
773
+ zIndex: 1e3,
774
+ boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
775
+ maxHeight: 250,
776
+ overflowY: "auto"
777
+ },
778
+ children: isLoading && options.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { padding: 12, alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, { size: 24, color: theme.colors.content.secondary }) }) : options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
779
+ Box,
780
+ {
781
+ paddingHorizontal: sizeStyles.padding,
782
+ paddingVertical: 8,
783
+ onPress: () => handleSelect(option),
784
+ hoverStyle: {
785
+ backgroundColor: theme.colors.control.input.bgHover
786
+ },
787
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
788
+ Text,
789
+ {
790
+ color: theme.colors.content.primary,
791
+ fontSize: sizeStyles.fontSize,
792
+ children: option
793
+ }
794
+ )
795
+ },
796
+ index
797
+ ))
798
+ }
799
+ ),
800
+ isError && errorLabel && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
801
+ Text,
802
+ {
803
+ color: theme.colors.content.alert.primary,
804
+ fontSize: sizeStyles.fontSize - 2,
805
+ marginTop: 4,
806
+ children: errorLabel
807
+ }
808
+ )
809
+ ]
810
+ }
811
+ );
812
+ };
813
+ // Annotate the CommonJS export names for ESM import in node:
814
+ 0 && (module.exports = {
815
+ Autocomplete
816
+ });
817
+ //# sourceMappingURL=index.js.map