@itilite/lumina-ui 1.1.4 → 1.1.6

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 (181) hide show
  1. package/dist/atom/LoadingSpinner/LoadingSpinner.d.mts +19 -0
  2. package/dist/atom/LoadingSpinner/LoadingSpinner.d.ts +19 -0
  3. package/dist/atom/LoadingSpinner/LoadingSpinner.js +90 -0
  4. package/dist/atom/LoadingSpinner/LoadingSpinner.mjs +9 -0
  5. package/dist/atom/RangePicker/Chevron.d.mts +13 -0
  6. package/dist/atom/RangePicker/Chevron.d.ts +13 -0
  7. package/dist/atom/RangePicker/Chevron.js +110 -0
  8. package/dist/atom/RangePicker/Chevron.mjs +7 -0
  9. package/dist/atom/RangePicker/RangePicker.d.mts +26 -0
  10. package/dist/atom/RangePicker/RangePicker.d.ts +26 -0
  11. package/dist/atom/RangePicker/RangePicker.js +1451 -0
  12. package/dist/atom/RangePicker/RangePicker.mjs +13 -0
  13. package/dist/atom/Select/Select.d.mts +43 -0
  14. package/dist/atom/Select/Select.d.ts +43 -0
  15. package/dist/atom/Select/Select.js +800 -0
  16. package/dist/atom/Select/Select.mjs +11 -0
  17. package/dist/chunk-22VF7AVT.mjs +618 -0
  18. package/dist/chunk-2BNAAOBU.mjs +670 -0
  19. package/dist/chunk-2IMRLK6M.mjs +44 -0
  20. package/dist/chunk-2JIINZEK.mjs +618 -0
  21. package/dist/chunk-2LBFKQDZ.mjs +660 -0
  22. package/dist/chunk-2ZJBF5C4.mjs +618 -0
  23. package/dist/chunk-33JITG5Y.mjs +621 -0
  24. package/dist/chunk-3IMCN4K3.mjs +670 -0
  25. package/dist/chunk-3K2RTVMH.mjs +584 -0
  26. package/dist/chunk-3KBQQCET.mjs +674 -0
  27. package/dist/chunk-3KUHXNFH.mjs +678 -0
  28. package/dist/chunk-3PPNOIXN.mjs +618 -0
  29. package/dist/chunk-3XFY3TXJ.mjs +611 -0
  30. package/dist/chunk-3XW7HS5W.mjs +618 -0
  31. package/dist/chunk-3YDCRJYV.mjs +618 -0
  32. package/dist/chunk-447HZYZ4.mjs +612 -0
  33. package/dist/chunk-46F3B4U6.mjs +618 -0
  34. package/dist/chunk-4K5RZHL4.mjs +618 -0
  35. package/dist/chunk-4QHFP4YD.mjs +666 -0
  36. package/dist/chunk-4TFX4DHY.mjs +702 -0
  37. package/dist/chunk-4TWO6JES.mjs +666 -0
  38. package/dist/chunk-4UQVJ3ZU.mjs +666 -0
  39. package/dist/chunk-5247J65D.mjs +670 -0
  40. package/dist/chunk-66H5WSEJ.mjs +618 -0
  41. package/dist/chunk-6NZEDJ2M.mjs +582 -0
  42. package/dist/chunk-6OGEXG5U.mjs +618 -0
  43. package/dist/chunk-6ROQXYVN.mjs +672 -0
  44. package/dist/chunk-6WNI6X5Q.mjs +618 -0
  45. package/dist/chunk-72PPCN6D.mjs +675 -0
  46. package/dist/chunk-74EGXFNN.mjs +618 -0
  47. package/dist/chunk-77NCDGJA.mjs +707 -0
  48. package/dist/chunk-7NGBIPZT.mjs +618 -0
  49. package/dist/chunk-7NM4FNMQ.mjs +666 -0
  50. package/dist/chunk-7YBBSVUA.mjs +672 -0
  51. package/dist/chunk-7Z52UP7P.mjs +618 -0
  52. package/dist/chunk-B3LDL3KD.mjs +670 -0
  53. package/dist/chunk-B65LGQ47.mjs +666 -0
  54. package/dist/chunk-B6MTRO54.mjs +618 -0
  55. package/dist/chunk-BJBP5XYB.mjs +618 -0
  56. package/dist/chunk-BLLSWPCC.mjs +618 -0
  57. package/dist/chunk-BOYB7REJ.mjs +670 -0
  58. package/dist/chunk-BP2D64XI.mjs +618 -0
  59. package/dist/chunk-BP4XS2GF.mjs +585 -0
  60. package/dist/chunk-BRT5IPGQ.mjs +618 -0
  61. package/dist/chunk-BTIIO2CP.mjs +582 -0
  62. package/dist/chunk-C2J3VBFZ.mjs +670 -0
  63. package/dist/chunk-CDOR7GQP.mjs +618 -0
  64. package/dist/chunk-CI2RMA4V.mjs +612 -0
  65. package/dist/chunk-CNUIZOQJ.mjs +669 -0
  66. package/dist/chunk-CPBXPEST.mjs +672 -0
  67. package/dist/chunk-CVOLXLMU.mjs +618 -0
  68. package/dist/chunk-CWUCNC36.mjs +666 -0
  69. package/dist/chunk-CZBGN6GS.mjs +612 -0
  70. package/dist/chunk-D3APB62N.mjs +618 -0
  71. package/dist/chunk-D5B2TUSL.mjs +591 -0
  72. package/dist/chunk-D7TWXVL2.mjs +674 -0
  73. package/dist/chunk-DAZ53AD7.mjs +671 -0
  74. package/dist/chunk-DBY5U6IU.mjs +618 -0
  75. package/dist/chunk-DXTVU4M5.mjs +618 -0
  76. package/dist/chunk-DZBTD6QK.mjs +666 -0
  77. package/dist/chunk-E6UPDTDY.mjs +611 -0
  78. package/dist/chunk-EAK2IMM4.mjs +37 -0
  79. package/dist/chunk-EQT2Q2LW.mjs +610 -0
  80. package/dist/chunk-EWMCELQV.mjs +670 -0
  81. package/dist/chunk-EYKWBEHX.mjs +612 -0
  82. package/dist/chunk-FHLCFUP6.mjs +666 -0
  83. package/dist/chunk-FMPFLQZV.mjs +670 -0
  84. package/dist/chunk-G25YXZ74.mjs +618 -0
  85. package/dist/chunk-G6P5MKL3.mjs +582 -0
  86. package/dist/chunk-GSG6ZC3R.mjs +37 -0
  87. package/dist/chunk-H3MQUFTJ.mjs +618 -0
  88. package/dist/chunk-HKZRLVBX.mjs +618 -0
  89. package/dist/chunk-HQALJGVT.mjs +618 -0
  90. package/dist/chunk-I5GBZ3UX.mjs +676 -0
  91. package/dist/chunk-IUTUCRDD.mjs +611 -0
  92. package/dist/chunk-IV4V55OA.mjs +672 -0
  93. package/dist/chunk-J2RAFKAD.mjs +618 -0
  94. package/dist/chunk-JCMSG75Q.mjs +51 -0
  95. package/dist/chunk-JL34UFI7.mjs +670 -0
  96. package/dist/chunk-JTKSGGQM.mjs +611 -0
  97. package/dist/chunk-JZC2RRDH.mjs +618 -0
  98. package/dist/chunk-JZCHXA6R.mjs +585 -0
  99. package/dist/chunk-K3Y7VKT6.mjs +670 -0
  100. package/dist/chunk-KEVXNUFG.mjs +672 -0
  101. package/dist/chunk-KH7D4ESJ.mjs +584 -0
  102. package/dist/chunk-KQBCWIIM.mjs +618 -0
  103. package/dist/chunk-KRYAP7NG.mjs +670 -0
  104. package/dist/chunk-KU655POK.mjs +657 -0
  105. package/dist/chunk-L55SLVNX.mjs +618 -0
  106. package/dist/chunk-LCRYOZEV.mjs +618 -0
  107. package/dist/chunk-LH7PP6V2.mjs +618 -0
  108. package/dist/chunk-LJMMYKE2.mjs +618 -0
  109. package/dist/chunk-LK5TROLL.mjs +666 -0
  110. package/dist/chunk-MDR7DAKM.mjs +618 -0
  111. package/dist/chunk-MJZLCWZ5.mjs +666 -0
  112. package/dist/chunk-MKZTEJLS.mjs +612 -0
  113. package/dist/chunk-MQCOQHHP.mjs +618 -0
  114. package/dist/chunk-MSM4KUBM.mjs +618 -0
  115. package/dist/chunk-MTIUER63.mjs +676 -0
  116. package/dist/chunk-NBLV3UX5.mjs +618 -0
  117. package/dist/chunk-NLADSOJS.mjs +618 -0
  118. package/dist/chunk-NPMTWR3Y.mjs +618 -0
  119. package/dist/chunk-NQ6GKEO7.mjs +670 -0
  120. package/dist/chunk-NZSFYNUK.mjs +618 -0
  121. package/dist/chunk-OCNF4O5U.mjs +612 -0
  122. package/dist/chunk-OCW5QSWA.mjs +618 -0
  123. package/dist/chunk-OQF7JZFS.mjs +670 -0
  124. package/dist/chunk-OT675HGC.mjs +670 -0
  125. package/dist/chunk-P47TCYKN.mjs +618 -0
  126. package/dist/chunk-P7TOGXPI.mjs +672 -0
  127. package/dist/chunk-PCAXXEEQ.mjs +618 -0
  128. package/dist/chunk-PDHMG7OZ.mjs +672 -0
  129. package/dist/chunk-PFGVOZGM.mjs +618 -0
  130. package/dist/chunk-PGAAFJOG.mjs +576 -0
  131. package/dist/chunk-PQSSDK3E.mjs +618 -0
  132. package/dist/chunk-PST7W3NG.mjs +618 -0
  133. package/dist/chunk-QGPBZ2YV.mjs +664 -0
  134. package/dist/chunk-QKTMWS4J.mjs +43 -0
  135. package/dist/chunk-QOPCJITC.mjs +618 -0
  136. package/dist/chunk-QSE52CRC.mjs +618 -0
  137. package/dist/chunk-QTP2QMPL.mjs +669 -0
  138. package/dist/chunk-QUZAACW5.mjs +585 -0
  139. package/dist/chunk-R47XX6IW.mjs +611 -0
  140. package/dist/chunk-RL6AEU6E.mjs +612 -0
  141. package/dist/chunk-RZ7V2KQZ.mjs +621 -0
  142. package/dist/chunk-S3CUYIE3.mjs +585 -0
  143. package/dist/chunk-T7T4HCHH.mjs +618 -0
  144. package/dist/chunk-TED2WCDG.mjs +618 -0
  145. package/dist/chunk-TENXL4LK.mjs +107 -0
  146. package/dist/chunk-TJLIMMMB.mjs +612 -0
  147. package/dist/chunk-TNOJDLON.mjs +611 -0
  148. package/dist/chunk-TOR67IHH.mjs +672 -0
  149. package/dist/chunk-TOV7NVKM.mjs +618 -0
  150. package/dist/chunk-TSYMIRRN.mjs +618 -0
  151. package/dist/chunk-TTSRI4V7.mjs +708 -0
  152. package/dist/chunk-UBS3DTE5.mjs +672 -0
  153. package/dist/chunk-UBW6RYVF.mjs +670 -0
  154. package/dist/chunk-UFAFA6RV.mjs +585 -0
  155. package/dist/chunk-UJNUFKR5.mjs +43 -0
  156. package/dist/chunk-VAZZJOSJ.mjs +618 -0
  157. package/dist/chunk-VCWXOX2B.mjs +618 -0
  158. package/dist/chunk-VHCLEOHZ.mjs +618 -0
  159. package/dist/chunk-VTZSCGME.mjs +666 -0
  160. package/dist/chunk-W33KZ2XR.mjs +618 -0
  161. package/dist/chunk-WOVMTYDV.mjs +612 -0
  162. package/dist/chunk-WR3USBWK.mjs +672 -0
  163. package/dist/chunk-WXYQARQ6.mjs +618 -0
  164. package/dist/chunk-XE4LPYOW.mjs +581 -0
  165. package/dist/chunk-Y6XKW4NG.mjs +618 -0
  166. package/dist/chunk-YQSNJFZE.mjs +618 -0
  167. package/dist/chunk-Z6VG6AG7.mjs +678 -0
  168. package/dist/chunk-ZAPKQ4C3.mjs +678 -0
  169. package/dist/chunk-ZCWDQNHL.mjs +618 -0
  170. package/dist/chunk-ZF5JBNCI.mjs +618 -0
  171. package/dist/chunk-ZN7BHWOF.mjs +672 -0
  172. package/dist/chunk-ZTRM4HZJ.mjs +53 -0
  173. package/dist/chunk-ZUMHWVMV.mjs +585 -0
  174. package/dist/chunk-ZUQJKA5J.mjs +666 -0
  175. package/dist/chunk-ZWHWIGYQ.mjs +618 -0
  176. package/dist/index.d.mts +4 -0
  177. package/dist/index.d.ts +4 -0
  178. package/dist/index.js +1350 -0
  179. package/dist/index.mjs +22 -9
  180. package/dist/styles.css +845 -228
  181. package/package.json +4 -2
@@ -0,0 +1,591 @@
1
+ import {
2
+ __objRest,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-FWCSY2DS.mjs";
6
+
7
+ // src/atom/Select/Select.tsx
8
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
9
+ import clsx from "clsx";
10
+
11
+ // src/icons/Chevron.tsx
12
+ import * as React from "react";
13
+ import { jsx } from "react/jsx-runtime";
14
+ var Chevron = React.memo(
15
+ (_a) => {
16
+ var _b = _a, { size = 16, color = "#6b7280", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
17
+ return /* @__PURE__ */ jsx(
18
+ "svg",
19
+ __spreadProps(__spreadValues({
20
+ xmlns: "http://www.w3.org/2000/svg",
21
+ width: size,
22
+ height: size,
23
+ fill: "none",
24
+ viewBox: "0 0 16 16",
25
+ className
26
+ }, rest), {
27
+ children: /* @__PURE__ */ jsx(
28
+ "path",
29
+ {
30
+ fill: color,
31
+ 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"
32
+ }
33
+ )
34
+ })
35
+ );
36
+ }
37
+ );
38
+ Chevron.displayName = "Chevron";
39
+
40
+ // src/icons/CrossV2.tsx
41
+ import * as React2 from "react";
42
+ import { jsx as jsx2 } from "react/jsx-runtime";
43
+ var CrossV2 = React2.memo(
44
+ (_a) => {
45
+ var _b = _a, { size = 16, color = "#111827", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
46
+ return /* @__PURE__ */ jsx2(
47
+ "svg",
48
+ __spreadProps(__spreadValues({
49
+ xmlns: "http://www.w3.org/2000/svg",
50
+ width: size,
51
+ height: size,
52
+ fill: "none",
53
+ viewBox: "0 0 16 16",
54
+ className
55
+ }, rest), {
56
+ children: /* @__PURE__ */ jsx2(
57
+ "path",
58
+ {
59
+ fill: color,
60
+ fillRule: "evenodd",
61
+ d: "M4.293 4.293a1 1 0 011.414 0L8 6.586l2.293-2.293a1 1 0 111.414 1.414L9.414 8l2.293 2.293a1 1 0 01-1.414 1.414L8 9.414l-2.293 2.293a1 1 0 01-1.414-1.414L6.586 8 4.293 5.707a1 1 0 010-1.414z",
62
+ clipRule: "evenodd"
63
+ }
64
+ )
65
+ })
66
+ );
67
+ }
68
+ );
69
+ CrossV2.displayName = "CrossV2";
70
+
71
+ // src/atom/Select/Select.tsx
72
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
73
+ var Select = ({
74
+ label,
75
+ mandatory = false,
76
+ error = false,
77
+ options = [],
78
+ valueSelected = "",
79
+ // Keep for backward compatibility
80
+ value: _valueProp,
81
+ // Rename to avoid potential conflicts with native value attribute
82
+ onChange,
83
+ className = "",
84
+ dropdownClassName = "",
85
+ optionClassName = "",
86
+ style = {},
87
+ showDisplayValue = false,
88
+ // New prop to show displayValue instead of label
89
+ allowClear = true,
90
+ enableSearch = true,
91
+ // New prop to control search functionality, default true
92
+ doubleCharSearch = false,
93
+ id,
94
+ name,
95
+ tabIndex,
96
+ // Add tabIndex prop
97
+ // Additional styling props
98
+ size = "default",
99
+ // 'small', 'default', 'large'
100
+ variant = "default",
101
+ // 'default', 'filled', 'outlined'
102
+ wrapperClassName = "",
103
+ inputClassName = "",
104
+ // Custom class for input element specifically
105
+ labelClassName = "",
106
+ // Custom class for label element specifically
107
+ height = "tw-h-12",
108
+ // Custom height
109
+ experience = "business"
110
+ }) => {
111
+ const normalizeValue = useCallback(
112
+ (val) => {
113
+ if (val === null || val === void 0) return "";
114
+ return String(val);
115
+ },
116
+ []
117
+ );
118
+ const validatedOptions = useMemo(() => {
119
+ if (!Array.isArray(options)) return [];
120
+ return options.filter(
121
+ (opt) => opt && typeof opt === "object" && opt.value !== void 0 && opt.value !== null && opt.label !== void 0
122
+ );
123
+ }, [options]);
124
+ const [isOpen, setIsOpen] = useState(false);
125
+ const [isFocused, setIsFocused] = useState(false);
126
+ const [searchTerm, setSearchTerm] = useState("");
127
+ const [isHovering, setIsHovering] = useState(false);
128
+ const [highlightedIndex, setHighlightedIndex] = useState(-1);
129
+ const [selectedValue, setSelectedValue] = useState(() => {
130
+ const initialValue = valueSelected;
131
+ if (initialValue === null || initialValue === void 0) return "";
132
+ return String(initialValue);
133
+ });
134
+ const inputRef = useRef(null);
135
+ const inputValueRef = useRef("");
136
+ const dropdownRef = useRef(null);
137
+ const optionRefs = useRef([]);
138
+ const optionListRef = useRef(null);
139
+ const blurTimeoutRef = useRef(null);
140
+ const hoverTimeoutRef = useRef(null);
141
+ const isActive = isFocused || Boolean(selectedValue) || Boolean(valueSelected) || Boolean(searchTerm);
142
+ const sizeClasses = useMemo(() => {
143
+ switch (size) {
144
+ case "small":
145
+ return {
146
+ input: "tw-h-8 tw-px-3 tw-typography-body2",
147
+ padding: label ? "tw-pt-4 tw-pb-1" : "tw-py-2",
148
+ labelActive: "tw-top-0 tw-typography-caption4",
149
+ labelInactive: "tw-top-2 tw-typography-caption3"
150
+ };
151
+ case "medium":
152
+ return {
153
+ input: "tw-h-10 tw-px-4 tw-typography-body2",
154
+ padding: label ? "tw-pt-4 tw-pb-1" : "tw-py-2",
155
+ labelActive: "tw-top-1 tw-typography-caption3",
156
+ labelInactive: "tw-top-2.5 tw-typography-body2"
157
+ };
158
+ case "large":
159
+ return {
160
+ input: "tw-h-16 tw-px-5 tw-typography-bodyLarge",
161
+ padding: label ? "tw-pt-8 tw-pb-4" : "tw-py-5",
162
+ labelActive: "tw-top-1 tw-typography-caption2",
163
+ labelInactive: "tw-top-5 tw-typography-body1"
164
+ };
165
+ default:
166
+ return {
167
+ input: height + " tw-px-4 tw-typography-bodyLarge",
168
+ padding: label ? "tw-pt-6 tw-pb-3" : "tw-py-3",
169
+ labelActive: "tw-top-1 tw-typography-caption3",
170
+ labelInactive: "tw-top-3.5 tw-typography-body2"
171
+ };
172
+ }
173
+ }, [size, label, height]);
174
+ const variantClasses = useMemo(() => {
175
+ switch (variant) {
176
+ case "filled":
177
+ return "tw-bg-gray-50 tw-border-transparent";
178
+ case "outlined":
179
+ return "tw-bg-transparent tw-border-2";
180
+ default:
181
+ return " tw-border";
182
+ }
183
+ }, [variant]);
184
+ const handleBlur = useCallback(() => {
185
+ blurTimeoutRef.current = setTimeout(() => {
186
+ setIsOpen(false);
187
+ setSearchTerm("");
188
+ setHighlightedIndex(-1);
189
+ blurTimeoutRef.current = null;
190
+ setIsFocused(false);
191
+ }, 150);
192
+ }, []);
193
+ const handleSearchChange = useCallback(
194
+ (e) => {
195
+ var _a;
196
+ if (doubleCharSearch) {
197
+ setSearchTerm(e.target.value.slice(0, 2) || "");
198
+ } else {
199
+ setSearchTerm(e.target.value);
200
+ }
201
+ setIsOpen(true);
202
+ setHighlightedIndex(-1);
203
+ (_a = optionListRef == null ? void 0 : optionListRef.current) == null ? void 0 : _a.scrollTo({
204
+ top: 0,
205
+ behavior: "smooth"
206
+ });
207
+ },
208
+ [doubleCharSearch]
209
+ );
210
+ const handleOptionSelect = useCallback(
211
+ (option) => {
212
+ var _a;
213
+ if (blurTimeoutRef.current) {
214
+ clearTimeout(blurTimeoutRef.current);
215
+ blurTimeoutRef.current = null;
216
+ }
217
+ inputValueRef.current = option.label;
218
+ const normalizedValue = normalizeValue(option.value);
219
+ setSelectedValue(normalizedValue);
220
+ setSearchTerm("");
221
+ setIsOpen(false);
222
+ if (enableSearch) {
223
+ setIsFocused(false);
224
+ }
225
+ setIsHovering(false);
226
+ if (onChange) onChange(option.value);
227
+ if (enableSearch) (_a = inputRef.current) == null ? void 0 : _a.blur();
228
+ },
229
+ [normalizeValue, onChange, enableSearch]
230
+ );
231
+ const handleClear = useCallback(
232
+ (e) => {
233
+ var _a;
234
+ inputValueRef.current = "";
235
+ e.stopPropagation();
236
+ e.preventDefault();
237
+ setSelectedValue("");
238
+ setSearchTerm("");
239
+ if (enableSearch) {
240
+ setIsOpen(true);
241
+ setIsFocused(true);
242
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
243
+ } else {
244
+ setIsOpen(false);
245
+ setIsFocused(false);
246
+ }
247
+ if (onChange) onChange(null);
248
+ },
249
+ [onChange, enableSearch]
250
+ );
251
+ useEffect(() => {
252
+ if (!validatedOptions.length) {
253
+ setSelectedValue("");
254
+ setSearchTerm("");
255
+ inputValueRef.current = "";
256
+ }
257
+ }, [validatedOptions.length]);
258
+ useEffect(() => {
259
+ const newValue = normalizeValue(valueSelected);
260
+ setSelectedValue((prevValue) => {
261
+ const prevNormalized = normalizeValue(prevValue);
262
+ return prevNormalized !== newValue ? newValue : prevValue;
263
+ });
264
+ }, [valueSelected, normalizeValue]);
265
+ useEffect(() => {
266
+ const handleClickOutside = (event) => {
267
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
268
+ if (blurTimeoutRef.current) {
269
+ clearTimeout(blurTimeoutRef.current);
270
+ blurTimeoutRef.current = null;
271
+ }
272
+ setIsOpen(false);
273
+ setIsFocused(false);
274
+ setSearchTerm("");
275
+ setHighlightedIndex(-1);
276
+ }
277
+ };
278
+ document.addEventListener("mousedown", handleClickOutside);
279
+ return () => {
280
+ document.removeEventListener("mousedown", handleClickOutside);
281
+ if (blurTimeoutRef.current) {
282
+ clearTimeout(blurTimeoutRef.current);
283
+ }
284
+ if (hoverTimeoutRef.current) {
285
+ clearTimeout(hoverTimeoutRef.current);
286
+ }
287
+ };
288
+ }, []);
289
+ const getDisplayValue = useCallback(() => {
290
+ if (selectedValue && (validatedOptions == null ? void 0 : validatedOptions.length) > 0) {
291
+ const selected = validatedOptions.find(
292
+ (opt) => normalizeValue(opt.value) === normalizeValue(selectedValue)
293
+ );
294
+ if (selected) {
295
+ return showDisplayValue && selected.displayValue ? selected.displayValue : selected.label;
296
+ }
297
+ }
298
+ if (selectedValue && (!validatedOptions || validatedOptions.length === 0)) {
299
+ return selectedValue;
300
+ }
301
+ return "";
302
+ }, [selectedValue, validatedOptions, showDisplayValue, normalizeValue]);
303
+ const filteredOptions = useMemo(() => {
304
+ var _a;
305
+ if (!enableSearch) {
306
+ return validatedOptions;
307
+ }
308
+ (_a = dropdownRef.current) == null ? void 0 : _a.scrollTo(0, 0);
309
+ const updatedFilteredOptions = validatedOptions.filter((option) => {
310
+ var _a2;
311
+ return (_a2 = option == null ? void 0 : option.label) == null ? void 0 : _a2.toLowerCase().includes(searchTerm == null ? void 0 : searchTerm.toLowerCase());
312
+ });
313
+ return updatedFilteredOptions;
314
+ }, [validatedOptions, searchTerm, enableSearch]);
315
+ const getSelectedOptionIndex = useCallback(() => {
316
+ if (!selectedValue || !filteredOptions.length) {
317
+ return 0;
318
+ }
319
+ const index = filteredOptions.findIndex(
320
+ (option) => normalizeValue(option.value) === normalizeValue(selectedValue)
321
+ );
322
+ return index >= 0 ? index : 0;
323
+ }, [selectedValue, filteredOptions, normalizeValue]);
324
+ const handleInputInteraction = useCallback(
325
+ (_e) => {
326
+ var _a;
327
+ if (blurTimeoutRef.current) {
328
+ clearTimeout(blurTimeoutRef.current);
329
+ blurTimeoutRef.current = null;
330
+ }
331
+ if (isOpen) {
332
+ setIsOpen(false);
333
+ setIsFocused(false);
334
+ setSearchTerm("");
335
+ setHighlightedIndex(-1);
336
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
337
+ return;
338
+ }
339
+ setIsFocused(true);
340
+ setIsOpen(true);
341
+ setHighlightedIndex(getSelectedOptionIndex());
342
+ if (inputRef.current) {
343
+ inputRef.current.focus();
344
+ }
345
+ },
346
+ [isOpen, getSelectedOptionIndex]
347
+ );
348
+ const handleKeyDown = useCallback(
349
+ (e) => {
350
+ var _a;
351
+ if (!isOpen) return;
352
+ switch (e.key) {
353
+ case "ArrowDown":
354
+ e.preventDefault();
355
+ setHighlightedIndex((prev) => {
356
+ const nextIndex = prev < filteredOptions.length - 1 ? prev + 1 : prev;
357
+ return nextIndex;
358
+ });
359
+ break;
360
+ case "ArrowUp":
361
+ e.preventDefault();
362
+ setHighlightedIndex((prev) => {
363
+ const nextIndex = prev > 0 ? prev - 1 : prev;
364
+ return nextIndex;
365
+ });
366
+ break;
367
+ case "Enter":
368
+ e.preventDefault();
369
+ if (highlightedIndex >= 0 && filteredOptions[highlightedIndex]) {
370
+ handleOptionSelect(filteredOptions[highlightedIndex]);
371
+ }
372
+ break;
373
+ case "Escape":
374
+ e.preventDefault();
375
+ setIsOpen(false);
376
+ setIsFocused(false);
377
+ setSearchTerm("");
378
+ setHighlightedIndex(-1);
379
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
380
+ break;
381
+ default:
382
+ break;
383
+ }
384
+ },
385
+ [isOpen, highlightedIndex, filteredOptions, handleOptionSelect]
386
+ );
387
+ useEffect(() => {
388
+ if (highlightedIndex >= 0 && optionRefs.current[highlightedIndex]) {
389
+ optionRefs.current[highlightedIndex].scrollIntoView({
390
+ block: "nearest",
391
+ behavior: "smooth"
392
+ });
393
+ }
394
+ }, [highlightedIndex]);
395
+ useEffect(() => {
396
+ optionRefs.current = [];
397
+ }, [filteredOptions]);
398
+ const handleMouseEnter = useCallback(() => {
399
+ if (hoverTimeoutRef.current) {
400
+ clearTimeout(hoverTimeoutRef.current);
401
+ }
402
+ if (!isHovering) {
403
+ setIsHovering(true);
404
+ }
405
+ }, [isHovering]);
406
+ const handleMouseLeave = useCallback(() => {
407
+ hoverTimeoutRef.current = setTimeout(() => {
408
+ setIsHovering(false);
409
+ }, 50);
410
+ }, []);
411
+ const handleChevronClick = useCallback(
412
+ (e) => {
413
+ var _a;
414
+ e.preventDefault();
415
+ if (blurTimeoutRef.current) {
416
+ clearTimeout(blurTimeoutRef.current);
417
+ blurTimeoutRef.current = null;
418
+ }
419
+ if (isOpen) {
420
+ setIsOpen(false);
421
+ setIsFocused(false);
422
+ setSearchTerm("");
423
+ setHighlightedIndex(-1);
424
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
425
+ } else {
426
+ if (inputRef.current) {
427
+ inputRef.current.focus();
428
+ }
429
+ handleInputInteraction();
430
+ }
431
+ },
432
+ [isOpen, handleInputInteraction]
433
+ );
434
+ return /* @__PURE__ */ jsxs(
435
+ "div",
436
+ {
437
+ style,
438
+ className: clsx("tw-relative tw-w-full", wrapperClassName),
439
+ ref: dropdownRef,
440
+ onMouseEnter: handleMouseEnter,
441
+ onMouseLeave: handleMouseLeave,
442
+ children: [
443
+ /* @__PURE__ */ jsxs("div", { className: "tw-relative", children: [
444
+ /* @__PURE__ */ jsx3(
445
+ "input",
446
+ {
447
+ ref: inputRef,
448
+ type: "text",
449
+ id,
450
+ name,
451
+ tabIndex,
452
+ autoComplete: "off",
453
+ autoCorrect: "off",
454
+ autoCapitalize: "off",
455
+ spellCheck: "false",
456
+ value: isFocused && enableSearch ? searchTerm : getDisplayValue(),
457
+ onChange: enableSearch ? handleSearchChange : void 0,
458
+ onClick: handleInputInteraction,
459
+ onKeyDown: handleKeyDown,
460
+ className: clsx(
461
+ "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",
462
+ sizeClasses.input,
463
+ sizeClasses.padding,
464
+ variantClasses,
465
+ {
466
+ "tw-bg-white": valueSelected || getDisplayValue() || isFocused,
467
+ "tw-bg-color-gray-5": !valueSelected || !getDisplayValue()
468
+ },
469
+ // Conditional padding based on label presence
470
+ !label && "tw-flex tw-items-center",
471
+ {
472
+ "!tw-border-color-primary": isFocused && experience === "business"
473
+ },
474
+ {
475
+ "!tw-border-[#804D7B]": isFocused && experience === "personal"
476
+ },
477
+ error ? "!tw-border-color-text-critical " : "tw-border-[#EBE3DD] hover:tw-border-[#C5B7AC]",
478
+ // Add focus state styling
479
+ "focus:tw-shadow-sm focus:tw-ring-offset-1",
480
+ className,
481
+ inputClassName
482
+ // Put inputClassName last so it can override default classes
483
+ ),
484
+ readOnly: !isFocused || !enableSearch
485
+ }
486
+ ),
487
+ label && /* @__PURE__ */ jsxs(
488
+ "label",
489
+ {
490
+ htmlFor: id,
491
+ className: clsx(
492
+ "tw-absolute tw-left-[18px] tw-pointer-events-none tw-transition-all tw-duration-200 tw-ease-out tw-text-gray-500",
493
+ isActive ? sizeClasses.labelActive : sizeClasses.labelInactive,
494
+ error && "tw-text-color-text-critical",
495
+ labelClassName
496
+ ),
497
+ children: [
498
+ label,
499
+ mandatory && /* @__PURE__ */ jsx3("span", { className: "tw-text-color-text-critical tw-ml-1", children: "*" })
500
+ ]
501
+ }
502
+ ),
503
+ /* @__PURE__ */ jsx3(
504
+ "div",
505
+ {
506
+ className: clsx(
507
+ "tw-absolute tw-right-3 tw-top-1/2 tw--translate-y-1/2 tw-flex tw-items-center",
508
+ {
509
+ "!tw-right-[5px]": doubleCharSearch && !(isHovering && selectedValue && allowClear)
510
+ }
511
+ ),
512
+ children: /* @__PURE__ */ jsx3(
513
+ "div",
514
+ {
515
+ className: clsx(
516
+ "tw-transition-all tw-duration-200 tw-cursor-pointer tw-flex tw-items-center",
517
+ // Only rotate chevron when open and not showing clear icon
518
+ isOpen && !(isHovering && selectedValue && allowClear) && "-tw-rotate-180"
519
+ ),
520
+ onMouseDown: (e) => {
521
+ if (isHovering && selectedValue && allowClear) {
522
+ handleClear(e);
523
+ } else {
524
+ handleChevronClick(e);
525
+ }
526
+ },
527
+ children: isHovering && selectedValue && allowClear ? /* @__PURE__ */ jsx3(CrossV2, { color: "#111827", className: "tw-mr-1" }) : /* @__PURE__ */ jsx3(
528
+ Chevron,
529
+ {
530
+ className: clsx("tw-text-gray-400 -tw-rotate-90"),
531
+ color: "#6B7280"
532
+ }
533
+ )
534
+ }
535
+ )
536
+ }
537
+ )
538
+ ] }),
539
+ isOpen && /* @__PURE__ */ jsx3(
540
+ "div",
541
+ {
542
+ className: clsx(
543
+ "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",
544
+ { "tw-max-h-60": !doubleCharSearch },
545
+ { "tw-max-h-44": doubleCharSearch },
546
+ dropdownClassName
547
+ ),
548
+ ref: optionListRef,
549
+ children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => /* @__PURE__ */ jsx3(
550
+ "div",
551
+ {
552
+ ref: (el) => optionRefs.current[index] = el,
553
+ onClick: () => handleOptionSelect(option),
554
+ onMouseEnter: () => setHighlightedIndex(index),
555
+ className: clsx(
556
+ "tw-transition-all tw-duration-150 tw-typography-body2",
557
+ // Selected option styling
558
+ optionClassName
559
+ ),
560
+ children: /* @__PURE__ */ jsx3(
561
+ "div",
562
+ {
563
+ className: clsx(
564
+ "tw-px-4 tw-cursor-pointer tw-py-2 tw-mx-0.5 tw-rounded-xl",
565
+ normalizeValue(selectedValue) === normalizeValue(option.value) ? experience === "personal" ? "tw-bg-[#f1e8fa]" : "tw-bg-[#fff1e1]" : (
566
+ // Highlighted option styling (keyboard navigation)
567
+ index === highlightedIndex ? "tw-bg-[#f3f4f6] tw-text-gray-900" : (
568
+ // Default option styling
569
+ "tw-text-gray-900 hover:tw-bg-[#1118270a]"
570
+ )
571
+ )
572
+ ),
573
+ children: option.label
574
+ }
575
+ )
576
+ },
577
+ doubleCharSearch ? option.label : option.value
578
+ )) : /* @__PURE__ */ jsx3("div", { className: "tw-px-4 tw-py-3 tw-text-gray-500 tw-text-sm", children: "No options found" })
579
+ }
580
+ )
581
+ ]
582
+ }
583
+ );
584
+ };
585
+ Select.displayName = "Select";
586
+ var Select_default = Select;
587
+
588
+ export {
589
+ Select,
590
+ Select_default
591
+ };