@itilite/lumina-ui 1.1.11 → 1.1.12

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 (43) hide show
  1. package/dist/atom/RangePicker/RangePicker.js +105 -102
  2. package/dist/atom/RangePicker/RangePicker.mjs +2 -2
  3. package/dist/atom/Select/Select.d.mts +1 -4
  4. package/dist/atom/Select/Select.d.ts +1 -4
  5. package/dist/atom/Select/Select.js +105 -102
  6. package/dist/atom/Select/Select.mjs +1 -1
  7. package/dist/chunk-3AWYHB3A.mjs +618 -0
  8. package/dist/chunk-3WWAOBS6.mjs +633 -0
  9. package/dist/chunk-57YKBWEI.mjs +673 -0
  10. package/dist/chunk-5BBLW4MR.mjs +670 -0
  11. package/dist/chunk-6XGVIU52.mjs +679 -0
  12. package/dist/chunk-BKPTZNXK.mjs +618 -0
  13. package/dist/chunk-CNN74G3M.mjs +666 -0
  14. package/dist/chunk-CPOZJCLV.mjs +681 -0
  15. package/dist/chunk-DRNY4L7J.mjs +618 -0
  16. package/dist/chunk-G7I4NT42.mjs +720 -0
  17. package/dist/chunk-GU5F7Z7I.mjs +681 -0
  18. package/dist/chunk-HPDJYQXM.mjs +663 -0
  19. package/dist/chunk-HTYOI6JT.mjs +618 -0
  20. package/dist/chunk-IIJUGDEJ.mjs +618 -0
  21. package/dist/chunk-J327EMX2.mjs +663 -0
  22. package/dist/chunk-J3ZBXBJ2.mjs +689 -0
  23. package/dist/chunk-JEAZCSST.mjs +676 -0
  24. package/dist/chunk-KDR6M52K.mjs +723 -0
  25. package/dist/chunk-LEPDKBT2.mjs +709 -0
  26. package/dist/chunk-LH55S6HJ.mjs +618 -0
  27. package/dist/chunk-MO7JTKPH.mjs +618 -0
  28. package/dist/chunk-MWC57EU6.mjs +666 -0
  29. package/dist/chunk-OMXQ6VML.mjs +618 -0
  30. package/dist/chunk-PSESRID3.mjs +681 -0
  31. package/dist/chunk-RAWVG2MM.mjs +618 -0
  32. package/dist/chunk-T2Y6AXM5.mjs +618 -0
  33. package/dist/chunk-THT4ALWQ.mjs +618 -0
  34. package/dist/chunk-TWV2Z27S.mjs +618 -0
  35. package/dist/chunk-UPUD2FQL.mjs +618 -0
  36. package/dist/chunk-UUTSL2NM.mjs +618 -0
  37. package/dist/chunk-WCYB5OTY.mjs +618 -0
  38. package/dist/chunk-YCAOWGDP.mjs +618 -0
  39. package/dist/chunk-ZUUAXTPM.mjs +618 -0
  40. package/dist/index.js +105 -102
  41. package/dist/index.mjs +11 -11
  42. package/dist/styles.css +254 -254
  43. package/package.json +1 -1
@@ -0,0 +1,666 @@
1
+ import {
2
+ LoadingSpinner_default
3
+ } from "./chunk-QKTMWS4J.mjs";
4
+ import {
5
+ Tooltip_default
6
+ } from "./chunk-MLCMZRUC.mjs";
7
+ import {
8
+ __objRest,
9
+ __spreadProps,
10
+ __spreadValues
11
+ } from "./chunk-FWCSY2DS.mjs";
12
+
13
+ // src/atom/Select/Select.tsx
14
+ import { useCallback, useEffect, useMemo, useRef, useState, memo as memo3 } from "react";
15
+ import clsx from "clsx";
16
+
17
+ // src/icons/Chevron.tsx
18
+ import * as React from "react";
19
+ import { jsx } from "react/jsx-runtime";
20
+ var Chevron = React.memo(
21
+ (_a) => {
22
+ var _b = _a, { size = 16, color = "#6b7280", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
23
+ return /* @__PURE__ */ jsx(
24
+ "svg",
25
+ __spreadProps(__spreadValues({
26
+ xmlns: "http://www.w3.org/2000/svg",
27
+ width: size,
28
+ height: size,
29
+ fill: "none",
30
+ viewBox: "0 0 16 16",
31
+ className
32
+ }, rest), {
33
+ children: /* @__PURE__ */ jsx(
34
+ "path",
35
+ {
36
+ fill: color,
37
+ d: "M11.78 6.22a.75.75 0 00-1.06 0L8 8.94 5.28 6.22a.75.75 0 00-1.06 1.06l3.25 3.25a.75.75 0 001.06 0l3.25-3.25a.75.75 0 000-1.06z"
38
+ }
39
+ )
40
+ })
41
+ );
42
+ }
43
+ );
44
+ Chevron.displayName = "Chevron";
45
+
46
+ // src/icons/CrossV2.tsx
47
+ import * as React2 from "react";
48
+ import { jsx as jsx2 } from "react/jsx-runtime";
49
+ var CrossV2 = React2.memo(
50
+ (_a) => {
51
+ var _b = _a, { size = 16, color = "#111827", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
52
+ return /* @__PURE__ */ jsx2(
53
+ "svg",
54
+ __spreadProps(__spreadValues({
55
+ xmlns: "http://www.w3.org/2000/svg",
56
+ width: size,
57
+ height: size,
58
+ fill: "none",
59
+ viewBox: "0 0 20 20"
60
+ }, rest), {
61
+ children: /* @__PURE__ */ jsx2(
62
+ "path",
63
+ {
64
+ fill: color,
65
+ d: "M4.411 4.41a.833.833 0 0 1 1.179 0L10 8.822l4.411-4.41a.833.833 0 1 1 1.179 1.178L11.179 10l4.41 4.41a.833.833 0 0 1-1.178 1.18l-4.41-4.411-4.411 4.41a.833.833 0 1 1-1.179-1.178L8.821 10l-4.41-4.41a.833.833 0 0 1 0-1.18"
66
+ }
67
+ )
68
+ })
69
+ );
70
+ }
71
+ );
72
+ CrossV2.displayName = "CrossV2";
73
+
74
+ // src/icons/Lock.tsx
75
+ import React3 from "react";
76
+ import { jsx as jsx3 } from "react/jsx-runtime";
77
+ var Lock = React3.memo((_a) => {
78
+ var _b = _a, { size = 16, color = "#000" } = _b, rest = __objRest(_b, ["size", "color"]);
79
+ return /* @__PURE__ */ jsx3(
80
+ "svg",
81
+ __spreadProps(__spreadValues({
82
+ xmlns: "http://www.w3.org/2000/svg",
83
+ width: size,
84
+ height: size,
85
+ fill: "none",
86
+ viewBox: "0 0 16 16"
87
+ }, rest), {
88
+ children: /* @__PURE__ */ jsx3(
89
+ "path",
90
+ {
91
+ fill: color,
92
+ d: "M9 9a1 1 0 11-2 0 1 1 0 012 0zM5 4h-.5A2.5 2.5 0 002 6.5v5A2.5 2.5 0 004.5 14h7a2.5 2.5 0 002.5-2.5v-5A2.5 2.5 0 0011.5 4H11v-.5a3 3 0 00-6 0V4zm1-.5a2 2 0 114 0V4H6v-.5zM11.5 5A1.5 1.5 0 0113 6.5v5a1.5 1.5 0 01-1.5 1.5h-7A1.5 1.5 0 013 11.5v-5A1.5 1.5 0 014.5 5h7z"
93
+ }
94
+ )
95
+ })
96
+ );
97
+ });
98
+
99
+ // src/atom/Select/Select.tsx
100
+ import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
101
+ var InputWrapper = memo3(({ children, disabled, disabledTooltip }) => {
102
+ if (disabled && disabledTooltip)
103
+ return /* @__PURE__ */ jsx4(Tooltip_default, { title: disabledTooltip, children });
104
+ return /* @__PURE__ */ jsx4(Fragment, { children });
105
+ });
106
+ var OptionItem = memo3(({
107
+ option,
108
+ index,
109
+ isSelected,
110
+ isHighlighted,
111
+ experience,
112
+ size,
113
+ optionClassName,
114
+ onSelectHandler,
115
+ onMouseEnterHandler
116
+ }) => {
117
+ return /* @__PURE__ */ jsx4(
118
+ "div",
119
+ {
120
+ onClick: () => onSelectHandler(option),
121
+ onMouseEnter: () => onMouseEnterHandler(index),
122
+ className: clsx(
123
+ "tw-transition-all tw-duration-150",
124
+ { "tw-typography-body2": size !== "small" },
125
+ { "tw-typography-caption1": size === "small" },
126
+ optionClassName
127
+ ),
128
+ children: /* @__PURE__ */ jsx4(
129
+ "div",
130
+ {
131
+ className: clsx(
132
+ "tw-px-4 tw-cursor-pointer tw-py-2 tw-mx-0.5 tw-rounded-xl",
133
+ isSelected ? experience === "personal" ? "tw-bg-[#f1e8fa]" : "tw-bg-[#fff1e1]" : isHighlighted ? "tw-bg-[#f3f4f6] tw-text-gray-900" : "tw-text-gray-900 hover:tw-bg-[#1118270a]"
134
+ ),
135
+ children: option.label
136
+ }
137
+ )
138
+ }
139
+ );
140
+ });
141
+ var Select = ({
142
+ label,
143
+ mandatory = false,
144
+ error = false,
145
+ options = [],
146
+ valueSelected = "",
147
+ // Keep for backward compatibility
148
+ value: _valueProp,
149
+ // Rename to avoid potential conflicts with native value attribute
150
+ onChange,
151
+ onSearch,
152
+ isLoading = false,
153
+ disabled = false,
154
+ disabledTooltip = "",
155
+ className = "",
156
+ dropdownClassName = "",
157
+ optionClassName = "",
158
+ style = {},
159
+ showDisplayValue = false,
160
+ // New prop to show displayValue instead of label
161
+ allowClear = true,
162
+ enableSearch = true,
163
+ doubleCharSearch = false,
164
+ id,
165
+ name,
166
+ tabIndex,
167
+ // Add tabIndex prop
168
+ // Additional styling props
169
+ size = "default",
170
+ // 'small', 'default', 'large'
171
+ variant = "default",
172
+ // 'default', 'filled', 'outlined'
173
+ wrapperClassName = "",
174
+ inputClassName = "",
175
+ // Custom class for input element specifically
176
+ labelClassName = "",
177
+ // Custom class for label element specifically
178
+ height = "tw-h-12",
179
+ // Custom height
180
+ experience = "business"
181
+ }) => {
182
+ const normalizeValue = useCallback(
183
+ (val) => {
184
+ if (val === null || val === void 0) return "";
185
+ return String(val);
186
+ },
187
+ []
188
+ );
189
+ const validatedOptions = useMemo(() => {
190
+ if (!Array.isArray(options)) return [];
191
+ return options.filter(
192
+ (opt) => opt && typeof opt === "object" && opt.value !== void 0 && opt.value !== null && opt.label !== void 0
193
+ );
194
+ }, [options]);
195
+ const [isOpen, setIsOpen] = useState(false);
196
+ const [isFocused, setIsFocused] = useState(false);
197
+ const [searchTerm, setSearchTerm] = useState("");
198
+ const [isHovering, setIsHovering] = useState(false);
199
+ const [highlightedIndex, setHighlightedIndex] = useState(-1);
200
+ const [selectedValue, setSelectedValue] = useState(() => {
201
+ const initialValue = valueSelected;
202
+ if (initialValue === null || initialValue === void 0) return "";
203
+ return String(initialValue);
204
+ });
205
+ const inputRef = useRef(null);
206
+ const inputValueRef = useRef("");
207
+ const dropdownRef = useRef(null);
208
+ const optionRefs = useRef([]);
209
+ const optionListRef = useRef(null);
210
+ const blurTimeoutRef = useRef(null);
211
+ const hoverTimeoutRef = useRef(null);
212
+ const isActive = isFocused || Boolean(selectedValue) || Boolean(valueSelected) || Boolean(searchTerm);
213
+ const sizeClasses = useMemo(() => {
214
+ switch (size) {
215
+ case "small":
216
+ return {
217
+ input: "tw-h-6 tw-typography-caption1Bold !tw-rounded-lg",
218
+ padding: "tw-px-2 tw-py-1",
219
+ labelActive: "tw-top-0.5 tw-typography-caption2",
220
+ labelInactive: "tw-top-1.5 tw-typography-caption3"
221
+ };
222
+ case "medium":
223
+ return {
224
+ input: "tw-h-10 tw-px-4 tw-typography-body2",
225
+ padding: label ? "tw-pt-4 tw-pb-1" : "tw-py-2",
226
+ labelActive: "tw-top-1 tw-typography-caption3",
227
+ labelInactive: "tw-top-2.5 tw-typography-body2"
228
+ };
229
+ case "large":
230
+ return {
231
+ input: "tw-h-16 tw-px-5 tw-typography-bodyLarge",
232
+ padding: label ? "tw-pt-8 tw-pb-4" : "tw-py-5",
233
+ labelActive: "tw-top-1 tw-typography-caption2",
234
+ labelInactive: "tw-top-5 tw-typography-body1"
235
+ };
236
+ default:
237
+ return {
238
+ input: height + " tw-px-4 tw-typography-bodyLarge",
239
+ padding: label ? "tw-pt-6 tw-pb-3" : "tw-py-3",
240
+ labelActive: "tw-top-1 tw-typography-caption3",
241
+ labelInactive: "tw-top-3.5 tw-typography-body2"
242
+ };
243
+ }
244
+ }, [size, label, height]);
245
+ const variantClasses = useMemo(() => {
246
+ switch (variant) {
247
+ case "filled":
248
+ return "tw-bg-gray-50 tw-border-transparent";
249
+ case "outlined":
250
+ return "tw-bg-transparent tw-border-2";
251
+ default:
252
+ return " tw-border";
253
+ }
254
+ }, [variant]);
255
+ const handleBlur = useCallback(() => {
256
+ blurTimeoutRef.current = setTimeout(() => {
257
+ setIsOpen(false);
258
+ setSearchTerm("");
259
+ setHighlightedIndex(-1);
260
+ blurTimeoutRef.current = null;
261
+ setIsFocused(false);
262
+ }, 150);
263
+ }, []);
264
+ const handleSearchChange = useCallback(
265
+ (e) => {
266
+ const searchValue = doubleCharSearch ? e.target.value.slice(0, 2) || "" : e.target.value;
267
+ if (doubleCharSearch) {
268
+ setSearchTerm(searchValue);
269
+ } else {
270
+ setSearchTerm(searchValue);
271
+ }
272
+ setIsOpen(true);
273
+ setHighlightedIndex(-1);
274
+ if (onSearch && typeof onSearch === "function") {
275
+ onSearch(searchValue);
276
+ }
277
+ },
278
+ [doubleCharSearch, onSearch]
279
+ );
280
+ const handleOptionSelect = useCallback(
281
+ (option) => {
282
+ var _a;
283
+ if (blurTimeoutRef.current) {
284
+ clearTimeout(blurTimeoutRef.current);
285
+ blurTimeoutRef.current = null;
286
+ }
287
+ inputValueRef.current = option.label;
288
+ const normalizedValue = normalizeValue(option.value);
289
+ setSelectedValue(normalizedValue);
290
+ setSearchTerm("");
291
+ setIsOpen(false);
292
+ if (enableSearch) {
293
+ setIsFocused(false);
294
+ }
295
+ setIsHovering(false);
296
+ if (onChange) onChange(option.value);
297
+ if (enableSearch) (_a = inputRef.current) == null ? void 0 : _a.blur();
298
+ },
299
+ [normalizeValue, onChange, enableSearch]
300
+ );
301
+ const handleClear = useCallback(
302
+ (e) => {
303
+ var _a;
304
+ inputValueRef.current = "";
305
+ e.stopPropagation();
306
+ e.preventDefault();
307
+ setSelectedValue("");
308
+ setSearchTerm("");
309
+ if (enableSearch) {
310
+ setIsOpen(true);
311
+ setIsFocused(true);
312
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
313
+ } else {
314
+ setIsOpen(false);
315
+ setIsFocused(false);
316
+ }
317
+ if (onChange) onChange(null);
318
+ },
319
+ [onChange, enableSearch]
320
+ );
321
+ useEffect(() => {
322
+ if (!validatedOptions.length) {
323
+ setSelectedValue("");
324
+ setSearchTerm("");
325
+ inputValueRef.current = "";
326
+ }
327
+ }, [validatedOptions.length]);
328
+ useEffect(() => {
329
+ const externalValue = _valueProp !== void 0 ? _valueProp : valueSelected;
330
+ const newValue = normalizeValue(externalValue);
331
+ setSelectedValue((prevValue) => {
332
+ const prevNormalized = normalizeValue(prevValue);
333
+ return prevNormalized !== newValue ? newValue : prevValue;
334
+ });
335
+ }, [valueSelected, _valueProp, normalizeValue]);
336
+ useEffect(() => {
337
+ const handleClickOutside = (event) => {
338
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
339
+ if (blurTimeoutRef.current) {
340
+ clearTimeout(blurTimeoutRef.current);
341
+ blurTimeoutRef.current = null;
342
+ }
343
+ setIsOpen(false);
344
+ setIsFocused(false);
345
+ setSearchTerm("");
346
+ setHighlightedIndex(-1);
347
+ }
348
+ };
349
+ document.addEventListener("mousedown", handleClickOutside);
350
+ return () => {
351
+ document.removeEventListener("mousedown", handleClickOutside);
352
+ if (blurTimeoutRef.current) {
353
+ clearTimeout(blurTimeoutRef.current);
354
+ }
355
+ if (hoverTimeoutRef.current) {
356
+ clearTimeout(hoverTimeoutRef.current);
357
+ }
358
+ };
359
+ }, []);
360
+ const getDisplayValue = useCallback(() => {
361
+ if (selectedValue && (validatedOptions == null ? void 0 : validatedOptions.length) > 0) {
362
+ const selected = validatedOptions.find(
363
+ (opt) => normalizeValue(opt.value) === normalizeValue(selectedValue)
364
+ );
365
+ if (selected) {
366
+ return showDisplayValue && selected.displayValue ? selected.displayValue : selected.label;
367
+ }
368
+ }
369
+ if (selectedValue && (!validatedOptions || validatedOptions.length === 0)) {
370
+ return selectedValue;
371
+ }
372
+ return "";
373
+ }, [selectedValue, validatedOptions, showDisplayValue, normalizeValue]);
374
+ const displayValue = useMemo(() => getDisplayValue(), [getDisplayValue]);
375
+ const inputClasses = useMemo(() => {
376
+ return clsx(
377
+ "tw-w-full tw-rounded-xl tw-outline-none tw-transition-all tw-duration-200 tw-cursor-pointer tw-border-solid tw-text-color-text-default",
378
+ sizeClasses.input,
379
+ sizeClasses.padding,
380
+ variantClasses,
381
+ {
382
+ "tw-bg-white": valueSelected || displayValue || isFocused,
383
+ "tw-bg-color-gray-5": !valueSelected || !displayValue,
384
+ "!tw-bg-[#F8F7F6] tw-cursor-not-allowed tw-pointer-events-none": disabled
385
+ },
386
+ !label && "tw-flex tw-items-center",
387
+ {
388
+ "!tw-border-color-primary": isFocused && experience === "business"
389
+ },
390
+ {
391
+ "!tw-border-[#804D7B]": isFocused && experience === "personal"
392
+ },
393
+ error ? "!tw-border-color-text-critical " : "tw-border-[#EBE3DD] hover:tw-border-[#C5B7AC]",
394
+ "focus:tw-shadow-sm focus:tw-ring-offset-1",
395
+ className,
396
+ inputClassName
397
+ );
398
+ }, [sizeClasses, variantClasses, valueSelected, displayValue, isFocused, disabled, label, experience, error, className, inputClassName]);
399
+ const filteredOptions = useMemo(() => {
400
+ if (!enableSearch) {
401
+ return validatedOptions;
402
+ }
403
+ const updatedFilteredOptions = validatedOptions.filter((option) => {
404
+ var _a;
405
+ return (_a = option == null ? void 0 : option.label) == null ? void 0 : _a.toLowerCase().includes(searchTerm == null ? void 0 : searchTerm.toLowerCase());
406
+ });
407
+ return updatedFilteredOptions;
408
+ }, [validatedOptions, searchTerm, enableSearch]);
409
+ const getSelectedOptionIndex = useCallback(() => {
410
+ if (!selectedValue || !filteredOptions.length) {
411
+ return 0;
412
+ }
413
+ const index = filteredOptions.findIndex(
414
+ (option) => normalizeValue(option.value) === normalizeValue(selectedValue)
415
+ );
416
+ return index >= 0 ? index : 0;
417
+ }, [selectedValue, filteredOptions, normalizeValue]);
418
+ const handleInputInteraction = useCallback(
419
+ (_e) => {
420
+ var _a;
421
+ if (blurTimeoutRef.current) {
422
+ clearTimeout(blurTimeoutRef.current);
423
+ blurTimeoutRef.current = null;
424
+ }
425
+ if (isOpen) {
426
+ setIsOpen(false);
427
+ setIsFocused(false);
428
+ setSearchTerm("");
429
+ setHighlightedIndex(-1);
430
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
431
+ return;
432
+ }
433
+ setIsFocused(true);
434
+ setIsOpen(true);
435
+ setHighlightedIndex(getSelectedOptionIndex());
436
+ if (inputRef.current) {
437
+ inputRef.current.focus();
438
+ }
439
+ },
440
+ [isOpen, getSelectedOptionIndex]
441
+ );
442
+ const handleKeyDown = useCallback(
443
+ (e) => {
444
+ var _a;
445
+ if (!isOpen) return;
446
+ switch (e.key) {
447
+ case "ArrowDown":
448
+ e.preventDefault();
449
+ setHighlightedIndex((prev) => {
450
+ const nextIndex = prev < filteredOptions.length - 1 ? prev + 1 : prev;
451
+ return nextIndex;
452
+ });
453
+ break;
454
+ case "ArrowUp":
455
+ e.preventDefault();
456
+ setHighlightedIndex((prev) => {
457
+ const nextIndex = prev > 0 ? prev - 1 : prev;
458
+ return nextIndex;
459
+ });
460
+ break;
461
+ case "Enter":
462
+ e.preventDefault();
463
+ if (highlightedIndex >= 0 && filteredOptions[highlightedIndex]) {
464
+ handleOptionSelect(filteredOptions[highlightedIndex]);
465
+ }
466
+ break;
467
+ case "Escape":
468
+ e.preventDefault();
469
+ setIsOpen(false);
470
+ setIsFocused(false);
471
+ setSearchTerm("");
472
+ setHighlightedIndex(-1);
473
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
474
+ break;
475
+ default:
476
+ break;
477
+ }
478
+ },
479
+ [isOpen, highlightedIndex, filteredOptions, handleOptionSelect]
480
+ );
481
+ useEffect(() => {
482
+ optionRefs.current = [];
483
+ }, [filteredOptions.length]);
484
+ const handleMouseEnter = useCallback(() => {
485
+ if (hoverTimeoutRef.current) {
486
+ clearTimeout(hoverTimeoutRef.current);
487
+ }
488
+ if (!isHovering) {
489
+ setIsHovering(true);
490
+ }
491
+ }, [isHovering]);
492
+ const handleMouseLeave = useCallback(() => {
493
+ hoverTimeoutRef.current = setTimeout(() => {
494
+ setIsHovering(false);
495
+ }, 50);
496
+ }, []);
497
+ const handleChevronClick = useCallback(
498
+ (e) => {
499
+ var _a;
500
+ e.preventDefault();
501
+ if (blurTimeoutRef.current) {
502
+ clearTimeout(blurTimeoutRef.current);
503
+ blurTimeoutRef.current = null;
504
+ }
505
+ if (isOpen) {
506
+ setIsOpen(false);
507
+ setIsFocused(false);
508
+ setSearchTerm("");
509
+ setHighlightedIndex(-1);
510
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
511
+ } else {
512
+ if (inputRef.current) {
513
+ inputRef.current.focus();
514
+ }
515
+ handleInputInteraction();
516
+ }
517
+ },
518
+ [isOpen, handleInputInteraction]
519
+ );
520
+ const handleChevronMouseDown = useCallback(
521
+ (e) => {
522
+ if (isHovering && selectedValue && allowClear) {
523
+ handleClear(e);
524
+ } else {
525
+ handleChevronClick(e);
526
+ }
527
+ },
528
+ [isHovering, selectedValue, allowClear, handleClear, handleChevronClick]
529
+ );
530
+ const handleOptionClick = useCallback((option) => {
531
+ handleOptionSelect(option);
532
+ }, [handleOptionSelect]);
533
+ const handleOptionMouseEnter = useCallback((index) => {
534
+ setHighlightedIndex(index);
535
+ }, []);
536
+ return /* @__PURE__ */ jsx4(InputWrapper, { disabled, disabledTooltip, children: /* @__PURE__ */ jsxs(
537
+ "div",
538
+ {
539
+ style,
540
+ className: clsx("tw-relative tw-w-full", wrapperClassName, {
541
+ "tw-cursor-not-allowed": disabled
542
+ }),
543
+ ref: dropdownRef,
544
+ onMouseEnter: handleMouseEnter,
545
+ onMouseLeave: handleMouseLeave,
546
+ children: [
547
+ /* @__PURE__ */ jsxs("div", { className: "tw-relative", children: [
548
+ /* @__PURE__ */ jsx4(
549
+ "input",
550
+ {
551
+ ref: inputRef,
552
+ type: "text",
553
+ id,
554
+ name,
555
+ tabIndex,
556
+ autoComplete: "off",
557
+ autoCorrect: "off",
558
+ autoCapitalize: "off",
559
+ spellCheck: "false",
560
+ value: isFocused && enableSearch ? searchTerm : displayValue,
561
+ onChange: enableSearch ? handleSearchChange : void 0,
562
+ onClick: handleInputInteraction,
563
+ onKeyDown: handleKeyDown,
564
+ className: inputClasses,
565
+ readOnly: !isFocused || !enableSearch
566
+ }
567
+ ),
568
+ label && size !== "small" && /* @__PURE__ */ jsxs(
569
+ "label",
570
+ {
571
+ htmlFor: id,
572
+ className: clsx(
573
+ "tw-absolute tw-left-[18px] tw-pointer-events-none tw-transition-all tw-duration-200 tw-ease-out tw-text-gray-500",
574
+ isActive ? sizeClasses.labelActive : sizeClasses.labelInactive,
575
+ error && "tw-text-color-text-critical",
576
+ labelClassName
577
+ ),
578
+ children: [
579
+ label,
580
+ mandatory && /* @__PURE__ */ jsx4("span", { className: "tw-text-color-text-critical tw-ml-1", children: "*" })
581
+ ]
582
+ }
583
+ ),
584
+ /* @__PURE__ */ jsxs(
585
+ "div",
586
+ {
587
+ className: clsx(
588
+ "tw-absolute tw-right-3 tw--translate-y-1/2 tw-flex tw-items-center",
589
+ {
590
+ "!tw-right-[5px]": doubleCharSearch && !(isHovering && selectedValue && allowClear),
591
+ "tw-top-3 !tw-right-2": size === "small",
592
+ "tw-top-1/2": size !== "small"
593
+ }
594
+ ),
595
+ children: [
596
+ disabled && /* @__PURE__ */ jsx4("div", { className: "tw-absolute tw-right-0 -tw-top-2", children: /* @__PURE__ */ jsx4(Lock, { size: 16 }) }),
597
+ isLoading ? /* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(LoadingSpinner_default, { size: "xs" }) }) : /* @__PURE__ */ jsx4(
598
+ "div",
599
+ {
600
+ className: clsx(
601
+ "tw-transition-all tw-duration-200 tw-cursor-pointer tw-flex tw-items-center",
602
+ // Only rotate chevron when open and not showing clear icon
603
+ isOpen && !(isHovering && selectedValue && allowClear) && "-tw-rotate-180"
604
+ ),
605
+ onMouseDown: handleChevronMouseDown,
606
+ children: disabled ? null : isHovering && selectedValue && allowClear ? /* @__PURE__ */ jsx4(
607
+ CrossV2,
608
+ {
609
+ color: "#111827",
610
+ className: clsx({ "tw-mr-1": size !== "small" }),
611
+ size: size === "small" ? 12 : 16
612
+ }
613
+ ) : /* @__PURE__ */ jsx4(
614
+ Chevron,
615
+ {
616
+ className: clsx("tw-text-gray-400"),
617
+ color: "#6B7280"
618
+ }
619
+ )
620
+ }
621
+ )
622
+ ]
623
+ }
624
+ )
625
+ ] }),
626
+ isOpen && /* @__PURE__ */ jsx4(
627
+ "div",
628
+ {
629
+ className: clsx(
630
+ "tw-absolute tw-z-[100] tw-w-full tw-mt-0 tw-bg-white tw-border tw-border-[#ebe3dd] tw-border-solid tw-rounded-xl tw-shadow-lg tw-overflow-y-auto tw-py-1",
631
+ { "tw-max-h-60": !doubleCharSearch },
632
+ { "tw-max-h-44": doubleCharSearch },
633
+ dropdownClassName
634
+ ),
635
+ ref: optionListRef,
636
+ children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => {
637
+ const isSelected = normalizeValue(selectedValue) === normalizeValue(option.value);
638
+ const isHighlighted = index === highlightedIndex;
639
+ return /* @__PURE__ */ jsx4("div", { ref: (el) => optionRefs.current[index] = el, children: /* @__PURE__ */ jsx4(
640
+ OptionItem,
641
+ {
642
+ option,
643
+ index,
644
+ isSelected,
645
+ isHighlighted,
646
+ experience,
647
+ size,
648
+ optionClassName,
649
+ onSelectHandler: handleOptionClick,
650
+ onMouseEnterHandler: handleOptionMouseEnter
651
+ }
652
+ ) }, doubleCharSearch ? option.label : option.value);
653
+ }) : /* @__PURE__ */ jsx4("div", { className: "tw-px-4 tw-py-3 tw-text-gray-500 tw-text-sm", children: "No options found" })
654
+ }
655
+ )
656
+ ]
657
+ }
658
+ ) });
659
+ };
660
+ Select.displayName = "Select";
661
+ var Select_default = Select;
662
+
663
+ export {
664
+ Select,
665
+ Select_default
666
+ };