@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.
package/web/index.js ADDED
@@ -0,0 +1,789 @@
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-web/src/Box.tsx
41
+ var import_react = __toESM(require("react"));
42
+ var import_styled_components = __toESM(require("styled-components"));
43
+ var import_jsx_runtime = require("react/jsx-runtime");
44
+ var StyledBox = import_styled_components.default.div`
45
+ display: flex;
46
+ box-sizing: border-box;
47
+ background-color: ${(props) => props.backgroundColor || "transparent"};
48
+ border-color: ${(props) => props.borderColor || "transparent"};
49
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
50
+
51
+ ${(props) => props.borderBottomWidth !== void 0 && `
52
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
53
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
54
+ border-bottom-style: solid;
55
+ `}
56
+ ${(props) => props.borderTopWidth !== void 0 && `
57
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
58
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
59
+ border-top-style: solid;
60
+ `}
61
+ ${(props) => props.borderLeftWidth !== void 0 && `
62
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
63
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
64
+ border-left-style: solid;
65
+ `}
66
+ ${(props) => props.borderRightWidth !== void 0 && `
67
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
68
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
69
+ border-right-style: solid;
70
+ `}
71
+
72
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
73
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
74
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
75
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
76
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
77
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
78
+
79
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
80
+ ${(props) => props.paddingHorizontal && `
81
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
82
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
83
+ `}
84
+ ${(props) => props.paddingVertical && `
85
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
86
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
87
+ `}
88
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
89
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
90
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
91
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
92
+
93
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
94
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
95
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
96
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
97
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
98
+
99
+ flex-direction: ${(props) => props.flexDirection || "column"};
100
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
101
+ align-items: ${(props) => props.alignItems || "stretch"};
102
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
103
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
104
+ position: ${(props) => props.position || "static"};
105
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
106
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
107
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
108
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
109
+ flex: ${(props) => props.flex};
110
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
111
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
112
+ align-self: ${(props) => props.alignSelf || "auto"};
113
+ overflow: ${(props) => props.overflow || "visible"};
114
+ overflow-x: ${(props) => props.overflowX || "visible"};
115
+ overflow-y: ${(props) => props.overflowY || "visible"};
116
+ z-index: ${(props) => props.zIndex};
117
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
118
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
119
+
120
+ &:hover {
121
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
122
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
123
+ }
124
+
125
+ &:active {
126
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
127
+ }
128
+ `;
129
+ var Box = import_react.default.forwardRef(
130
+ ({
131
+ children,
132
+ onPress,
133
+ onKeyDown,
134
+ onKeyUp,
135
+ role,
136
+ "aria-label": ariaLabel,
137
+ "aria-labelledby": ariaLabelledBy,
138
+ "aria-current": ariaCurrent,
139
+ "aria-disabled": ariaDisabled,
140
+ "aria-live": ariaLive,
141
+ "aria-busy": ariaBusy,
142
+ "aria-describedby": ariaDescribedBy,
143
+ "aria-expanded": ariaExpanded,
144
+ "aria-haspopup": ariaHasPopup,
145
+ "aria-pressed": ariaPressed,
146
+ "aria-controls": ariaControls,
147
+ tabIndex,
148
+ as,
149
+ src,
150
+ alt,
151
+ type,
152
+ disabled,
153
+ id,
154
+ ...props
155
+ }, ref) => {
156
+ if (as === "img" && src) {
157
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
+ "img",
159
+ {
160
+ src,
161
+ alt: alt || "",
162
+ style: {
163
+ display: "block",
164
+ objectFit: "cover",
165
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
166
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
167
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
168
+ position: props.position,
169
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
170
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
171
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
172
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
173
+ }
174
+ }
175
+ );
176
+ }
177
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
+ StyledBox,
179
+ {
180
+ ref,
181
+ as,
182
+ id,
183
+ type: as === "button" ? type || "button" : void 0,
184
+ disabled: as === "button" ? disabled : void 0,
185
+ onClick: onPress,
186
+ onKeyDown,
187
+ onKeyUp,
188
+ role,
189
+ "aria-label": ariaLabel,
190
+ "aria-labelledby": ariaLabelledBy,
191
+ "aria-current": ariaCurrent,
192
+ "aria-disabled": ariaDisabled,
193
+ "aria-busy": ariaBusy,
194
+ "aria-describedby": ariaDescribedBy,
195
+ "aria-expanded": ariaExpanded,
196
+ "aria-haspopup": ariaHasPopup,
197
+ "aria-pressed": ariaPressed,
198
+ "aria-controls": ariaControls,
199
+ "aria-live": ariaLive,
200
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
201
+ ...props,
202
+ children
203
+ }
204
+ );
205
+ }
206
+ );
207
+ Box.displayName = "Box";
208
+
209
+ // ../primitives-web/src/Text.tsx
210
+ var import_styled_components2 = __toESM(require("styled-components"));
211
+ var import_jsx_runtime2 = require("react/jsx-runtime");
212
+ var StyledText = import_styled_components2.default.span`
213
+ color: ${(props) => props.color || "inherit"};
214
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
215
+ font-weight: ${(props) => props.fontWeight || "normal"};
216
+ font-family: ${(props) => props.fontFamily || '"Pilat Wide Bold", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important'};
217
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
218
+ white-space: ${(props) => props.whiteSpace || "normal"};
219
+ text-align: ${(props) => props.textAlign || "inherit"};
220
+ text-decoration: ${(props) => props.textDecoration || "none"};
221
+ `;
222
+ var Text = ({
223
+ style,
224
+ className,
225
+ id,
226
+ role,
227
+ ...props
228
+ }) => {
229
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
230
+ StyledText,
231
+ {
232
+ ...props,
233
+ style,
234
+ className,
235
+ id,
236
+ role
237
+ }
238
+ );
239
+ };
240
+
241
+ // ../primitives-web/src/Spinner.tsx
242
+ var import_styled_components3 = __toESM(require("styled-components"));
243
+ var import_jsx_runtime3 = require("react/jsx-runtime");
244
+ var rotate = import_styled_components3.keyframes`
245
+ from {
246
+ transform: rotate(0deg);
247
+ }
248
+ to {
249
+ transform: rotate(360deg);
250
+ }
251
+ `;
252
+ var StyledSpinner = import_styled_components3.default.div`
253
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
254
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
255
+ border: ${(props) => props.strokeWidth || 2}px solid
256
+ ${(props) => props.color || "currentColor"};
257
+ border-bottom-color: transparent;
258
+ border-radius: 50%;
259
+ display: inline-block;
260
+ box-sizing: border-box;
261
+ animation: ${rotate} 1s linear infinite;
262
+ `;
263
+ var Spinner = ({
264
+ role = "status",
265
+ "aria-label": ariaLabel,
266
+ "aria-live": ariaLive = "polite",
267
+ "aria-describedby": ariaDescribedBy,
268
+ testID,
269
+ ...props
270
+ }) => {
271
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
272
+ StyledSpinner,
273
+ {
274
+ role,
275
+ "aria-label": ariaLabel,
276
+ "aria-live": ariaLive,
277
+ "aria-describedby": ariaDescribedBy,
278
+ "data-testid": testID,
279
+ ...props
280
+ }
281
+ );
282
+ };
283
+ Spinner.displayName = "Spinner";
284
+
285
+ // ../primitives-web/src/Icon.tsx
286
+ var import_styled_components4 = __toESM(require("styled-components"));
287
+ var import_jsx_runtime4 = require("react/jsx-runtime");
288
+ var StyledIcon = import_styled_components4.default.div`
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: center;
292
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
293
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
294
+ color: ${(props) => props.color || "currentColor"};
295
+
296
+ svg {
297
+ width: 100%;
298
+ height: 100%;
299
+ fill: none;
300
+ stroke: currentColor;
301
+ }
302
+ `;
303
+ var Icon = ({ children, ...props }) => {
304
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledIcon, { ...props, children });
305
+ };
306
+
307
+ // ../primitives-web/src/Divider.tsx
308
+ var import_styled_components5 = __toESM(require("styled-components"));
309
+ var import_jsx_runtime5 = require("react/jsx-runtime");
310
+ var StyledDivider = import_styled_components5.default.div`
311
+ background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
312
+ width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
313
+ height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
314
+
315
+ ${(props) => props.dashStroke && `
316
+ border-style: dashed;
317
+ border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
318
+ border-width: 0;
319
+ ${props.vertical ? `
320
+ border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
321
+ height: 100%;
322
+ ` : `
323
+ border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
324
+ width: 100%;
325
+ `}
326
+ `}
327
+ `;
328
+
329
+ // ../primitives-web/src/Input.tsx
330
+ var import_react2 = require("react");
331
+ var import_styled_components6 = __toESM(require("styled-components"));
332
+ var import_jsx_runtime6 = require("react/jsx-runtime");
333
+ var StyledInput = import_styled_components6.default.input`
334
+ background: transparent;
335
+ border: none;
336
+ outline: none;
337
+ width: 100%;
338
+ height: 100%;
339
+ padding: 0;
340
+ margin: 0;
341
+ color: ${(props) => props.color || "inherit"};
342
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
343
+ font-family: inherit;
344
+ text-align: inherit;
345
+
346
+ &::placeholder {
347
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
348
+ }
349
+
350
+ &:disabled {
351
+ cursor: not-allowed;
352
+ }
353
+ `;
354
+ var InputPrimitive = (0, import_react2.forwardRef)(
355
+ ({
356
+ value,
357
+ placeholder,
358
+ onChange,
359
+ onChangeText,
360
+ onFocus,
361
+ onBlur,
362
+ onKeyDown,
363
+ disabled,
364
+ secureTextEntry,
365
+ style,
366
+ color,
367
+ fontSize,
368
+ placeholderTextColor,
369
+ maxLength,
370
+ name,
371
+ type,
372
+ inputMode,
373
+ autoComplete,
374
+ id,
375
+ "aria-invalid": ariaInvalid,
376
+ "aria-describedby": ariaDescribedBy,
377
+ "aria-labelledby": ariaLabelledBy,
378
+ "aria-label": ariaLabel,
379
+ "aria-disabled": ariaDisabled,
380
+ "data-testid": dataTestId,
381
+ ...rest
382
+ }, ref) => {
383
+ const handleChange = (e) => {
384
+ if (onChange) {
385
+ onChange(e);
386
+ }
387
+ if (onChangeText) {
388
+ onChangeText(e.target.value);
389
+ }
390
+ };
391
+ const inputValue = value !== void 0 ? value : "";
392
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
393
+ StyledInput,
394
+ {
395
+ ref,
396
+ id,
397
+ value: inputValue,
398
+ name,
399
+ placeholder,
400
+ onChange: handleChange,
401
+ onFocus,
402
+ onBlur,
403
+ onKeyDown,
404
+ disabled,
405
+ type: secureTextEntry ? "password" : type || "text",
406
+ inputMode,
407
+ autoComplete,
408
+ style,
409
+ color,
410
+ fontSize,
411
+ placeholderTextColor,
412
+ maxLength,
413
+ "aria-invalid": ariaInvalid,
414
+ "aria-describedby": ariaDescribedBy,
415
+ "aria-labelledby": ariaLabelledBy,
416
+ "aria-label": ariaLabel,
417
+ "aria-disabled": ariaDisabled,
418
+ "data-testid": dataTestId,
419
+ ...rest
420
+ }
421
+ );
422
+ }
423
+ );
424
+ InputPrimitive.displayName = "InputPrimitive";
425
+
426
+ // ../primitives-web/src/TextArea.tsx
427
+ var import_react3 = require("react");
428
+ var import_styled_components7 = __toESM(require("styled-components"));
429
+ var import_jsx_runtime7 = require("react/jsx-runtime");
430
+ var StyledTextArea = import_styled_components7.default.textarea`
431
+ background: transparent;
432
+ border: none;
433
+ outline: none;
434
+ width: 100%;
435
+ height: 100%;
436
+ padding: 0;
437
+ margin: 0;
438
+ color: ${(props) => props.color || "inherit"};
439
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
440
+ font-family: inherit;
441
+ text-align: inherit;
442
+ resize: none;
443
+
444
+ &::placeholder {
445
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
446
+ }
447
+
448
+ &:disabled {
449
+ cursor: not-allowed;
450
+ }
451
+ `;
452
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
453
+ ({
454
+ value,
455
+ placeholder,
456
+ onChangeText,
457
+ onFocus,
458
+ onBlur,
459
+ onKeyDown,
460
+ disabled,
461
+ style,
462
+ color,
463
+ fontSize,
464
+ placeholderTextColor,
465
+ maxLength,
466
+ rows
467
+ }, ref) => {
468
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
469
+ StyledTextArea,
470
+ {
471
+ ref,
472
+ value,
473
+ placeholder,
474
+ onChange: (e) => onChangeText?.(e.target.value),
475
+ onFocus,
476
+ onBlur,
477
+ onKeyDown,
478
+ disabled,
479
+ style,
480
+ color,
481
+ fontSize,
482
+ placeholderTextColor,
483
+ maxLength,
484
+ rows
485
+ }
486
+ );
487
+ }
488
+ );
489
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
490
+
491
+ // src/Autocomplete.tsx
492
+ var import_xui_core = require("@xsolla/xui-core");
493
+ var import_jsx_runtime8 = require("react/jsx-runtime");
494
+ var SearchIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
495
+ "svg",
496
+ {
497
+ width: "100%",
498
+ height: "100%",
499
+ viewBox: "0 0 18 18",
500
+ fill: "none",
501
+ xmlns: "http://www.w3.org/2000/svg",
502
+ children: [
503
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
504
+ "path",
505
+ {
506
+ 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",
507
+ stroke: "currentColor",
508
+ strokeWidth: "1.5",
509
+ strokeLinecap: "round",
510
+ strokeLinejoin: "round"
511
+ }
512
+ ),
513
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
514
+ "path",
515
+ {
516
+ d: "M15.75 15.75L12.4875 12.4875",
517
+ stroke: "currentColor",
518
+ strokeWidth: "1.5",
519
+ strokeLinecap: "round",
520
+ strokeLinejoin: "round"
521
+ }
522
+ )
523
+ ]
524
+ }
525
+ );
526
+ var ChevronDown = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
527
+ "svg",
528
+ {
529
+ width: "100%",
530
+ height: "100%",
531
+ viewBox: "0 0 18 18",
532
+ fill: "none",
533
+ xmlns: "http://www.w3.org/2000/svg",
534
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
535
+ "path",
536
+ {
537
+ d: "M4.5 6.75L9 11.25L13.5 6.75",
538
+ stroke: "currentColor",
539
+ strokeWidth: "1.5",
540
+ strokeLinecap: "round",
541
+ strokeLinejoin: "round"
542
+ }
543
+ )
544
+ }
545
+ );
546
+ var ChevronUp = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
547
+ "svg",
548
+ {
549
+ width: "100%",
550
+ height: "100%",
551
+ viewBox: "0 0 18 18",
552
+ fill: "none",
553
+ xmlns: "http://www.w3.org/2000/svg",
554
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
555
+ "path",
556
+ {
557
+ d: "M13.5 11.25L9 6.75L4.5 11.25",
558
+ stroke: "currentColor",
559
+ strokeWidth: "1.5",
560
+ strokeLinecap: "round",
561
+ strokeLinejoin: "round"
562
+ }
563
+ )
564
+ }
565
+ );
566
+ var CloseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
567
+ "svg",
568
+ {
569
+ width: "100%",
570
+ height: "100%",
571
+ viewBox: "0 0 18 18",
572
+ fill: "none",
573
+ xmlns: "http://www.w3.org/2000/svg",
574
+ children: [
575
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
576
+ "path",
577
+ {
578
+ d: "M13.5 4.5L4.5 13.5",
579
+ stroke: "currentColor",
580
+ strokeWidth: "1.5",
581
+ strokeLinecap: "round",
582
+ strokeLinejoin: "round"
583
+ }
584
+ ),
585
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
586
+ "path",
587
+ {
588
+ d: "M4.5 4.5L13.5 13.5",
589
+ stroke: "currentColor",
590
+ strokeWidth: "1.5",
591
+ strokeLinecap: "round",
592
+ strokeLinejoin: "round"
593
+ }
594
+ )
595
+ ]
596
+ }
597
+ );
598
+ var Autocomplete = ({
599
+ value: propValue,
600
+ placeholder = "Search...",
601
+ onValueChange,
602
+ onSelect,
603
+ options = [],
604
+ isLoading = false,
605
+ size = "m",
606
+ state: externalState,
607
+ label,
608
+ errorLabel,
609
+ iconLeft = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SearchIcon, {}),
610
+ chevronRight = true,
611
+ filled = true
612
+ }) => {
613
+ const { theme } = (0, import_xui_core.useDesignSystem)();
614
+ const [internalValue, setInternalValue] = (0, import_react4.useState)(propValue || "");
615
+ const [isFocused, setIsFocused] = (0, import_react4.useState)(false);
616
+ const containerRef = (0, import_react4.useRef)(null);
617
+ const value = propValue !== void 0 ? propValue : internalValue;
618
+ const state = externalState || (isFocused ? "focus" : "default");
619
+ const isDisable = state === "disable";
620
+ const isError = state === "error";
621
+ const isFocus = state === "focus";
622
+ const sizeStyles = theme.sizing.input(size);
623
+ const inputColors = theme.colors.control.input;
624
+ (0, import_react4.useEffect)(() => {
625
+ const handleClickOutside = (event) => {
626
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
627
+ setIsFocused(false);
628
+ }
629
+ };
630
+ if (isFocused) {
631
+ document.addEventListener("mousedown", handleClickOutside);
632
+ }
633
+ return () => {
634
+ document.removeEventListener("mousedown", handleClickOutside);
635
+ };
636
+ }, [isFocused]);
637
+ const handleInputChange = (text) => {
638
+ if (!isDisable) {
639
+ setInternalValue(text);
640
+ if (onValueChange) onValueChange(text);
641
+ setIsFocused(true);
642
+ }
643
+ };
644
+ const handleSelect = (option) => {
645
+ setInternalValue(option);
646
+ setIsFocused(false);
647
+ if (onSelect) onSelect(option);
648
+ if (onValueChange) onValueChange(option);
649
+ };
650
+ const handleClear = (e) => {
651
+ e.stopPropagation();
652
+ handleInputChange("");
653
+ };
654
+ let backgroundColor = inputColors.bg;
655
+ let borderColor = inputColors.border;
656
+ if (isDisable) {
657
+ backgroundColor = inputColors.bgDisable;
658
+ borderColor = inputColors.borderDisable;
659
+ } else if (isError) {
660
+ borderColor = theme.colors.border.alert;
661
+ } else if (isFocus) {
662
+ backgroundColor = theme.colors.control.focus.bg;
663
+ borderColor = inputColors.borderHover;
664
+ } else if (state === "hover") {
665
+ backgroundColor = inputColors.bgHover;
666
+ borderColor = inputColors.borderHover;
667
+ }
668
+ if (filled === false && !isFocus && !isError && state !== "hover") {
669
+ backgroundColor = "transparent";
670
+ }
671
+ const textColor = isDisable ? inputColors.textDisable : inputColors.text;
672
+ const placeholderColor = inputColors.placeholder;
673
+ const iconColor = isDisable ? inputColors.textDisable : inputColors.text;
674
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
675
+ Box,
676
+ {
677
+ ref: containerRef,
678
+ flexDirection: "column",
679
+ gap: 4,
680
+ width: "100%",
681
+ position: "relative",
682
+ children: [
683
+ label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
684
+ Text,
685
+ {
686
+ color: theme.colors.content.secondary,
687
+ fontSize: sizeStyles.fontSize - 2,
688
+ fontWeight: "500",
689
+ marginBottom: 4,
690
+ children: label
691
+ }
692
+ ),
693
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
694
+ Box,
695
+ {
696
+ backgroundColor,
697
+ borderColor,
698
+ borderWidth: borderColor !== "transparent" ? 1 : 0,
699
+ borderRadius: theme.radius.button,
700
+ height: sizeStyles.height,
701
+ paddingHorizontal: sizeStyles.padding,
702
+ flexDirection: "row",
703
+ alignItems: "center",
704
+ gap: 10,
705
+ position: "relative",
706
+ hoverStyle: !isDisable && !isFocus && !isError ? {
707
+ backgroundColor: inputColors.bgHover,
708
+ borderColor: inputColors.borderHover
709
+ } : void 0,
710
+ children: [
711
+ 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 }) }),
712
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flex: 1, height: "100%", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
713
+ InputPrimitive,
714
+ {
715
+ value,
716
+ placeholder,
717
+ onChangeText: handleInputChange,
718
+ onFocus: () => !isDisable && setIsFocused(true),
719
+ disabled: isDisable,
720
+ color: textColor,
721
+ fontSize: sizeStyles.fontSize,
722
+ placeholderTextColor: placeholderColor
723
+ }
724
+ ) }),
725
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "row", alignItems: "center", gap: 4, children: [
726
+ 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, {}) }) }),
727
+ 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, {}) }) })
728
+ ] })
729
+ ]
730
+ }
731
+ ),
732
+ isFocus && (options.length > 0 || isLoading) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
733
+ Box,
734
+ {
735
+ position: "absolute",
736
+ top: sizeStyles.height + (label ? 28 : 0) + 4,
737
+ left: 0,
738
+ right: 0,
739
+ backgroundColor: theme.colors.background.secondary,
740
+ borderColor: theme.colors.border.secondary,
741
+ borderWidth: 1,
742
+ borderRadius: theme.radius.button,
743
+ paddingVertical: 4,
744
+ style: {
745
+ zIndex: 1e3,
746
+ boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
747
+ maxHeight: 250,
748
+ overflowY: "auto"
749
+ },
750
+ 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)(
751
+ Box,
752
+ {
753
+ paddingHorizontal: sizeStyles.padding,
754
+ paddingVertical: 8,
755
+ onPress: () => handleSelect(option),
756
+ hoverStyle: {
757
+ backgroundColor: theme.colors.control.input.bgHover
758
+ },
759
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
760
+ Text,
761
+ {
762
+ color: theme.colors.content.primary,
763
+ fontSize: sizeStyles.fontSize,
764
+ children: option
765
+ }
766
+ )
767
+ },
768
+ index
769
+ ))
770
+ }
771
+ ),
772
+ isError && errorLabel && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
773
+ Text,
774
+ {
775
+ color: theme.colors.content.alert.primary,
776
+ fontSize: sizeStyles.fontSize - 2,
777
+ marginTop: 4,
778
+ children: errorLabel
779
+ }
780
+ )
781
+ ]
782
+ }
783
+ );
784
+ };
785
+ // Annotate the CommonJS export names for ESM import in node:
786
+ 0 && (module.exports = {
787
+ Autocomplete
788
+ });
789
+ //# sourceMappingURL=index.js.map