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