@itilite/lumina-ui 1.1.4 → 1.1.5

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 (41) hide show
  1. package/dist/atom/RangePicker/Chevron.d.mts +13 -0
  2. package/dist/atom/RangePicker/Chevron.d.ts +13 -0
  3. package/dist/atom/RangePicker/Chevron.js +110 -0
  4. package/dist/atom/RangePicker/Chevron.mjs +7 -0
  5. package/dist/atom/RangePicker/RangePicker.d.mts +26 -0
  6. package/dist/atom/RangePicker/RangePicker.d.ts +26 -0
  7. package/dist/atom/RangePicker/RangePicker.js +1322 -0
  8. package/dist/atom/RangePicker/RangePicker.mjs +11 -0
  9. package/dist/atom/Select/Select.d.mts +40 -0
  10. package/dist/atom/Select/Select.d.ts +40 -0
  11. package/dist/atom/Select/Select.js +678 -0
  12. package/dist/atom/Select/Select.mjs +9 -0
  13. package/dist/chunk-33JITG5Y.mjs +621 -0
  14. package/dist/chunk-3K2RTVMH.mjs +584 -0
  15. package/dist/chunk-3YDCRJYV.mjs +618 -0
  16. package/dist/chunk-6NZEDJ2M.mjs +582 -0
  17. package/dist/chunk-BP4XS2GF.mjs +585 -0
  18. package/dist/chunk-BTIIO2CP.mjs +582 -0
  19. package/dist/chunk-D5B2TUSL.mjs +591 -0
  20. package/dist/chunk-E6UPDTDY.mjs +611 -0
  21. package/dist/chunk-G6P5MKL3.mjs +582 -0
  22. package/dist/chunk-IUTUCRDD.mjs +611 -0
  23. package/dist/chunk-JCMSG75Q.mjs +51 -0
  24. package/dist/chunk-JZCHXA6R.mjs +585 -0
  25. package/dist/chunk-KH7D4ESJ.mjs +584 -0
  26. package/dist/chunk-KQBCWIIM.mjs +618 -0
  27. package/dist/chunk-PGAAFJOG.mjs +576 -0
  28. package/dist/chunk-QUZAACW5.mjs +585 -0
  29. package/dist/chunk-RZ7V2KQZ.mjs +621 -0
  30. package/dist/chunk-S3CUYIE3.mjs +585 -0
  31. package/dist/chunk-TENXL4LK.mjs +107 -0
  32. package/dist/chunk-UFAFA6RV.mjs +585 -0
  33. package/dist/chunk-XE4LPYOW.mjs +581 -0
  34. package/dist/chunk-ZTRM4HZJ.mjs +53 -0
  35. package/dist/chunk-ZUMHWVMV.mjs +585 -0
  36. package/dist/index.d.mts +2 -0
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +1259 -0
  39. package/dist/index.mjs +21 -12
  40. package/dist/styles.css +794 -218
  41. package/package.json +2 -1
@@ -0,0 +1,1322 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+
59
+ // src/atom/RangePicker/RangePicker.tsx
60
+ var RangePicker_exports = {};
61
+ __export(RangePicker_exports, {
62
+ RangePicker: () => CustomRangePicker,
63
+ default: () => RangePicker_default
64
+ });
65
+ module.exports = __toCommonJS(RangePicker_exports);
66
+ var import_react2 = require("react");
67
+ var import_clsx2 = __toESM(require("clsx"));
68
+ var import_dayjs = __toESM(require("dayjs"));
69
+
70
+ // src/atom/RangePicker/Chevron.tsx
71
+ var React = __toESM(require("react"));
72
+ var import_jsx_runtime = require("react/jsx-runtime");
73
+ var Chevron = React.memo(
74
+ (_a) => {
75
+ var _b = _a, { size = "normal", color = "black", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
76
+ const getSize = (size2) => {
77
+ switch (size2) {
78
+ case "small":
79
+ return "M9.78 11.78a.75.75 0 000-1.06L7.06 8l2.72-2.72a.75.75 0 00-1.06-1.06L5.47 7.47a.75.75 0 000 1.06l3.25 3.25a.75.75 0 001.06 0z";
80
+ case "normal":
81
+ return "M14.78 17.78a.75.75 0 000-1.06L10.06 12l4.72-4.72a.75.75 0 00-1.06-1.06l-5.25 5.25a.75.75 0 000 1.06l5.25 5.25a.75.75 0 001.06 0z";
82
+ default:
83
+ return "M14.78 17.78a.75.75 0 000-1.06L10.06 12l4.72-4.72a.75.75 0 00-1.06-1.06l-5.25 5.25a.75.75 0 000 1.06l5.25 5.25a.75.75 0 001.06 0z";
84
+ }
85
+ };
86
+ const getContainer = (size2) => {
87
+ switch (size2) {
88
+ case "small":
89
+ return 16;
90
+ case "medium":
91
+ return 20;
92
+ case "normal":
93
+ return 24;
94
+ default:
95
+ return 24;
96
+ }
97
+ };
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ "svg",
100
+ __spreadProps(__spreadValues({
101
+ xmlns: "http://www.w3.org/2000/svg",
102
+ width: getContainer(size),
103
+ height: getContainer(size),
104
+ fill: "none",
105
+ viewBox: `0 0 ${getContainer(size)} ${getContainer(size)}`,
106
+ className
107
+ }, rest), {
108
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: color, d: getSize(size) })
109
+ })
110
+ );
111
+ }
112
+ );
113
+
114
+ // src/atom/RangePicker/RangePicker.module.scss
115
+ var RangePicker_module_default = { "range_start": "RangePicker-module__range_start___hGQp-", "range_end": "RangePicker-module__range_end___JJNib" };
116
+
117
+ // src/atom/Select/Select.tsx
118
+ var import_react = require("react");
119
+ var import_clsx = __toESM(require("clsx"));
120
+
121
+ // src/icons/Chevron.tsx
122
+ var React2 = __toESM(require("react"));
123
+ var import_jsx_runtime2 = require("react/jsx-runtime");
124
+ var Chevron2 = React2.memo(
125
+ (_a) => {
126
+ var _b = _a, { size = 16, color = "#6b7280", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
127
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
128
+ "svg",
129
+ __spreadProps(__spreadValues({
130
+ xmlns: "http://www.w3.org/2000/svg",
131
+ width: size,
132
+ height: size,
133
+ fill: "none",
134
+ viewBox: "0 0 16 16",
135
+ className
136
+ }, rest), {
137
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
138
+ "path",
139
+ {
140
+ fill: color,
141
+ 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"
142
+ }
143
+ )
144
+ })
145
+ );
146
+ }
147
+ );
148
+ Chevron2.displayName = "Chevron";
149
+
150
+ // src/icons/CrossV2.tsx
151
+ var React3 = __toESM(require("react"));
152
+ var import_jsx_runtime3 = require("react/jsx-runtime");
153
+ var CrossV2 = React3.memo(
154
+ (_a) => {
155
+ var _b = _a, { size = 16, color = "#111827", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
156
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
157
+ "svg",
158
+ __spreadProps(__spreadValues({
159
+ xmlns: "http://www.w3.org/2000/svg",
160
+ width: size,
161
+ height: size,
162
+ fill: "none",
163
+ viewBox: "0 0 16 16",
164
+ className
165
+ }, rest), {
166
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
167
+ "path",
168
+ {
169
+ fill: color,
170
+ fillRule: "evenodd",
171
+ 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",
172
+ clipRule: "evenodd"
173
+ }
174
+ )
175
+ })
176
+ );
177
+ }
178
+ );
179
+ CrossV2.displayName = "CrossV2";
180
+
181
+ // src/atom/Select/Select.tsx
182
+ var import_jsx_runtime4 = require("react/jsx-runtime");
183
+ var Select = ({
184
+ label,
185
+ mandatory = false,
186
+ error = false,
187
+ options = [],
188
+ valueSelected = "",
189
+ // Keep for backward compatibility
190
+ value: _valueProp,
191
+ // Rename to avoid potential conflicts with native value attribute
192
+ onChange,
193
+ className = "",
194
+ dropdownClassName = "",
195
+ optionClassName = "",
196
+ style = {},
197
+ showDisplayValue = false,
198
+ // New prop to show displayValue instead of label
199
+ allowClear = true,
200
+ enableSearch = true,
201
+ // New prop to control search functionality, default true
202
+ doubleCharSearch = false,
203
+ id,
204
+ name,
205
+ tabIndex,
206
+ // Add tabIndex prop
207
+ // Additional styling props
208
+ size = "default",
209
+ // 'small', 'default', 'large'
210
+ variant = "default",
211
+ // 'default', 'filled', 'outlined'
212
+ wrapperClassName = "",
213
+ inputClassName = "",
214
+ // Custom class for input element specifically
215
+ labelClassName = "",
216
+ // Custom class for label element specifically
217
+ height = "tw-h-12",
218
+ // Custom height
219
+ experience = "business"
220
+ }) => {
221
+ const normalizeValue = (0, import_react.useCallback)(
222
+ (val) => {
223
+ if (val === null || val === void 0) return "";
224
+ return String(val);
225
+ },
226
+ []
227
+ );
228
+ const validatedOptions = (0, import_react.useMemo)(() => {
229
+ if (!Array.isArray(options)) return [];
230
+ return options.filter(
231
+ (opt) => opt && typeof opt === "object" && opt.value !== void 0 && opt.value !== null && opt.label !== void 0
232
+ );
233
+ }, [options]);
234
+ const [isOpen, setIsOpen] = (0, import_react.useState)(false);
235
+ const [isFocused, setIsFocused] = (0, import_react.useState)(false);
236
+ const [searchTerm, setSearchTerm] = (0, import_react.useState)("");
237
+ const [isHovering, setIsHovering] = (0, import_react.useState)(false);
238
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react.useState)(-1);
239
+ const [selectedValue, setSelectedValue] = (0, import_react.useState)(() => {
240
+ const initialValue = valueSelected;
241
+ if (initialValue === null || initialValue === void 0) return "";
242
+ return String(initialValue);
243
+ });
244
+ const inputRef = (0, import_react.useRef)(null);
245
+ const inputValueRef = (0, import_react.useRef)("");
246
+ const dropdownRef = (0, import_react.useRef)(null);
247
+ const optionRefs = (0, import_react.useRef)([]);
248
+ const optionListRef = (0, import_react.useRef)(null);
249
+ const blurTimeoutRef = (0, import_react.useRef)(null);
250
+ const hoverTimeoutRef = (0, import_react.useRef)(null);
251
+ const isActive = isFocused || Boolean(selectedValue) || Boolean(valueSelected) || Boolean(searchTerm);
252
+ const sizeClasses = (0, import_react.useMemo)(() => {
253
+ switch (size) {
254
+ case "small":
255
+ return {
256
+ input: "tw-h-8 tw-px-3 tw-typography-body2",
257
+ padding: label ? "tw-pt-4 tw-pb-1" : "tw-py-2",
258
+ labelActive: "tw-top-0 tw-typography-caption4",
259
+ labelInactive: "tw-top-2 tw-typography-caption3"
260
+ };
261
+ case "medium":
262
+ return {
263
+ input: "tw-h-10 tw-px-4 tw-typography-body2",
264
+ padding: label ? "tw-pt-4 tw-pb-1" : "tw-py-2",
265
+ labelActive: "tw-top-1 tw-typography-caption3",
266
+ labelInactive: "tw-top-2.5 tw-typography-body2"
267
+ };
268
+ case "large":
269
+ return {
270
+ input: "tw-h-16 tw-px-5 tw-typography-bodyLarge",
271
+ padding: label ? "tw-pt-8 tw-pb-4" : "tw-py-5",
272
+ labelActive: "tw-top-1 tw-typography-caption2",
273
+ labelInactive: "tw-top-5 tw-typography-body1"
274
+ };
275
+ default:
276
+ return {
277
+ input: height + " tw-px-4 tw-typography-bodyLarge",
278
+ padding: label ? "tw-pt-6 tw-pb-3" : "tw-py-3",
279
+ labelActive: "tw-top-1 tw-typography-caption3",
280
+ labelInactive: "tw-top-3.5 tw-typography-body2"
281
+ };
282
+ }
283
+ }, [size, label, height]);
284
+ const variantClasses = (0, import_react.useMemo)(() => {
285
+ switch (variant) {
286
+ case "filled":
287
+ return "tw-bg-gray-50 tw-border-transparent";
288
+ case "outlined":
289
+ return "tw-bg-transparent tw-border-2";
290
+ default:
291
+ return " tw-border";
292
+ }
293
+ }, [variant]);
294
+ const handleBlur = (0, import_react.useCallback)(() => {
295
+ blurTimeoutRef.current = setTimeout(() => {
296
+ setIsOpen(false);
297
+ setSearchTerm("");
298
+ setHighlightedIndex(-1);
299
+ blurTimeoutRef.current = null;
300
+ setIsFocused(false);
301
+ }, 150);
302
+ }, []);
303
+ const handleSearchChange = (0, import_react.useCallback)(
304
+ (e) => {
305
+ var _a;
306
+ if (doubleCharSearch) {
307
+ setSearchTerm(e.target.value.slice(0, 2) || "");
308
+ } else {
309
+ setSearchTerm(e.target.value);
310
+ }
311
+ setIsOpen(true);
312
+ setHighlightedIndex(-1);
313
+ (_a = optionListRef == null ? void 0 : optionListRef.current) == null ? void 0 : _a.scrollTo({
314
+ top: 0,
315
+ behavior: "smooth"
316
+ });
317
+ },
318
+ [doubleCharSearch]
319
+ );
320
+ const handleOptionSelect = (0, import_react.useCallback)(
321
+ (option) => {
322
+ var _a;
323
+ if (blurTimeoutRef.current) {
324
+ clearTimeout(blurTimeoutRef.current);
325
+ blurTimeoutRef.current = null;
326
+ }
327
+ inputValueRef.current = option.label;
328
+ const normalizedValue = normalizeValue(option.value);
329
+ setSelectedValue(normalizedValue);
330
+ setSearchTerm("");
331
+ setIsOpen(false);
332
+ if (enableSearch) {
333
+ setIsFocused(false);
334
+ }
335
+ setIsHovering(false);
336
+ if (onChange) onChange(option.value);
337
+ if (enableSearch) (_a = inputRef.current) == null ? void 0 : _a.blur();
338
+ },
339
+ [normalizeValue, onChange, enableSearch]
340
+ );
341
+ const handleClear = (0, import_react.useCallback)(
342
+ (e) => {
343
+ var _a;
344
+ inputValueRef.current = "";
345
+ e.stopPropagation();
346
+ e.preventDefault();
347
+ setSelectedValue("");
348
+ setSearchTerm("");
349
+ if (enableSearch) {
350
+ setIsOpen(true);
351
+ setIsFocused(true);
352
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
353
+ } else {
354
+ setIsOpen(false);
355
+ setIsFocused(false);
356
+ }
357
+ if (onChange) onChange(null);
358
+ },
359
+ [onChange, enableSearch]
360
+ );
361
+ (0, import_react.useEffect)(() => {
362
+ if (!validatedOptions.length) {
363
+ setSelectedValue("");
364
+ setSearchTerm("");
365
+ inputValueRef.current = "";
366
+ }
367
+ }, [validatedOptions.length]);
368
+ (0, import_react.useEffect)(() => {
369
+ const newValue = normalizeValue(valueSelected);
370
+ setSelectedValue((prevValue) => {
371
+ const prevNormalized = normalizeValue(prevValue);
372
+ return prevNormalized !== newValue ? newValue : prevValue;
373
+ });
374
+ }, [valueSelected, normalizeValue]);
375
+ (0, import_react.useEffect)(() => {
376
+ const handleClickOutside = (event) => {
377
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
378
+ if (blurTimeoutRef.current) {
379
+ clearTimeout(blurTimeoutRef.current);
380
+ blurTimeoutRef.current = null;
381
+ }
382
+ setIsOpen(false);
383
+ setIsFocused(false);
384
+ setSearchTerm("");
385
+ setHighlightedIndex(-1);
386
+ }
387
+ };
388
+ document.addEventListener("mousedown", handleClickOutside);
389
+ return () => {
390
+ document.removeEventListener("mousedown", handleClickOutside);
391
+ if (blurTimeoutRef.current) {
392
+ clearTimeout(blurTimeoutRef.current);
393
+ }
394
+ if (hoverTimeoutRef.current) {
395
+ clearTimeout(hoverTimeoutRef.current);
396
+ }
397
+ };
398
+ }, []);
399
+ const getDisplayValue = (0, import_react.useCallback)(() => {
400
+ if (selectedValue && (validatedOptions == null ? void 0 : validatedOptions.length) > 0) {
401
+ const selected = validatedOptions.find(
402
+ (opt) => normalizeValue(opt.value) === normalizeValue(selectedValue)
403
+ );
404
+ if (selected) {
405
+ return showDisplayValue && selected.displayValue ? selected.displayValue : selected.label;
406
+ }
407
+ }
408
+ if (selectedValue && (!validatedOptions || validatedOptions.length === 0)) {
409
+ return selectedValue;
410
+ }
411
+ return "";
412
+ }, [selectedValue, validatedOptions, showDisplayValue, normalizeValue]);
413
+ const filteredOptions = (0, import_react.useMemo)(() => {
414
+ var _a;
415
+ if (!enableSearch) {
416
+ return validatedOptions;
417
+ }
418
+ (_a = dropdownRef.current) == null ? void 0 : _a.scrollTo(0, 0);
419
+ const updatedFilteredOptions = validatedOptions.filter((option) => {
420
+ var _a2;
421
+ return (_a2 = option == null ? void 0 : option.label) == null ? void 0 : _a2.toLowerCase().includes(searchTerm == null ? void 0 : searchTerm.toLowerCase());
422
+ });
423
+ return updatedFilteredOptions;
424
+ }, [validatedOptions, searchTerm, enableSearch]);
425
+ const getSelectedOptionIndex = (0, import_react.useCallback)(() => {
426
+ if (!selectedValue || !filteredOptions.length) {
427
+ return 0;
428
+ }
429
+ const index = filteredOptions.findIndex(
430
+ (option) => normalizeValue(option.value) === normalizeValue(selectedValue)
431
+ );
432
+ return index >= 0 ? index : 0;
433
+ }, [selectedValue, filteredOptions, normalizeValue]);
434
+ const handleInputInteraction = (0, import_react.useCallback)(
435
+ (_e) => {
436
+ var _a;
437
+ if (blurTimeoutRef.current) {
438
+ clearTimeout(blurTimeoutRef.current);
439
+ blurTimeoutRef.current = null;
440
+ }
441
+ if (isOpen) {
442
+ setIsOpen(false);
443
+ setIsFocused(false);
444
+ setSearchTerm("");
445
+ setHighlightedIndex(-1);
446
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
447
+ return;
448
+ }
449
+ setIsFocused(true);
450
+ setIsOpen(true);
451
+ setHighlightedIndex(getSelectedOptionIndex());
452
+ if (inputRef.current) {
453
+ inputRef.current.focus();
454
+ }
455
+ },
456
+ [isOpen, getSelectedOptionIndex]
457
+ );
458
+ const handleKeyDown = (0, import_react.useCallback)(
459
+ (e) => {
460
+ var _a;
461
+ if (!isOpen) return;
462
+ switch (e.key) {
463
+ case "ArrowDown":
464
+ e.preventDefault();
465
+ setHighlightedIndex((prev) => {
466
+ const nextIndex = prev < filteredOptions.length - 1 ? prev + 1 : prev;
467
+ return nextIndex;
468
+ });
469
+ break;
470
+ case "ArrowUp":
471
+ e.preventDefault();
472
+ setHighlightedIndex((prev) => {
473
+ const nextIndex = prev > 0 ? prev - 1 : prev;
474
+ return nextIndex;
475
+ });
476
+ break;
477
+ case "Enter":
478
+ e.preventDefault();
479
+ if (highlightedIndex >= 0 && filteredOptions[highlightedIndex]) {
480
+ handleOptionSelect(filteredOptions[highlightedIndex]);
481
+ }
482
+ break;
483
+ case "Escape":
484
+ e.preventDefault();
485
+ setIsOpen(false);
486
+ setIsFocused(false);
487
+ setSearchTerm("");
488
+ setHighlightedIndex(-1);
489
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
490
+ break;
491
+ default:
492
+ break;
493
+ }
494
+ },
495
+ [isOpen, highlightedIndex, filteredOptions, handleOptionSelect]
496
+ );
497
+ (0, import_react.useEffect)(() => {
498
+ if (highlightedIndex >= 0 && optionRefs.current[highlightedIndex]) {
499
+ optionRefs.current[highlightedIndex].scrollIntoView({
500
+ block: "nearest",
501
+ behavior: "smooth"
502
+ });
503
+ }
504
+ }, [highlightedIndex]);
505
+ (0, import_react.useEffect)(() => {
506
+ optionRefs.current = [];
507
+ }, [filteredOptions]);
508
+ const handleMouseEnter = (0, import_react.useCallback)(() => {
509
+ if (hoverTimeoutRef.current) {
510
+ clearTimeout(hoverTimeoutRef.current);
511
+ }
512
+ if (!isHovering) {
513
+ setIsHovering(true);
514
+ }
515
+ }, [isHovering]);
516
+ const handleMouseLeave = (0, import_react.useCallback)(() => {
517
+ hoverTimeoutRef.current = setTimeout(() => {
518
+ setIsHovering(false);
519
+ }, 50);
520
+ }, []);
521
+ const handleChevronClick = (0, import_react.useCallback)(
522
+ (e) => {
523
+ var _a;
524
+ e.preventDefault();
525
+ if (blurTimeoutRef.current) {
526
+ clearTimeout(blurTimeoutRef.current);
527
+ blurTimeoutRef.current = null;
528
+ }
529
+ if (isOpen) {
530
+ setIsOpen(false);
531
+ setIsFocused(false);
532
+ setSearchTerm("");
533
+ setHighlightedIndex(-1);
534
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
535
+ } else {
536
+ if (inputRef.current) {
537
+ inputRef.current.focus();
538
+ }
539
+ handleInputInteraction();
540
+ }
541
+ },
542
+ [isOpen, handleInputInteraction]
543
+ );
544
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
545
+ "div",
546
+ {
547
+ style,
548
+ className: (0, import_clsx.default)("tw-relative tw-w-full", wrapperClassName),
549
+ ref: dropdownRef,
550
+ onMouseEnter: handleMouseEnter,
551
+ onMouseLeave: handleMouseLeave,
552
+ children: [
553
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "tw-relative", children: [
554
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
555
+ "input",
556
+ {
557
+ ref: inputRef,
558
+ type: "text",
559
+ id,
560
+ name,
561
+ tabIndex,
562
+ autoComplete: "off",
563
+ autoCorrect: "off",
564
+ autoCapitalize: "off",
565
+ spellCheck: "false",
566
+ value: isFocused && enableSearch ? searchTerm : getDisplayValue(),
567
+ onChange: enableSearch ? handleSearchChange : void 0,
568
+ onClick: handleInputInteraction,
569
+ onKeyDown: handleKeyDown,
570
+ className: (0, import_clsx.default)(
571
+ "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",
572
+ sizeClasses.input,
573
+ sizeClasses.padding,
574
+ variantClasses,
575
+ {
576
+ "tw-bg-white": valueSelected || getDisplayValue() || isFocused,
577
+ "tw-bg-color-gray-5": !valueSelected || !getDisplayValue()
578
+ },
579
+ // Conditional padding based on label presence
580
+ !label && "tw-flex tw-items-center",
581
+ {
582
+ "!tw-border-color-primary": isFocused && experience === "business"
583
+ },
584
+ {
585
+ "!tw-border-[#804D7B]": isFocused && experience === "personal"
586
+ },
587
+ error ? "!tw-border-color-text-critical " : "tw-border-[#EBE3DD] hover:tw-border-[#C5B7AC]",
588
+ // Add focus state styling
589
+ "focus:tw-shadow-sm focus:tw-ring-offset-1",
590
+ className,
591
+ inputClassName
592
+ // Put inputClassName last so it can override default classes
593
+ ),
594
+ readOnly: !isFocused || !enableSearch
595
+ }
596
+ ),
597
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
598
+ "label",
599
+ {
600
+ htmlFor: id,
601
+ className: (0, import_clsx.default)(
602
+ "tw-absolute tw-left-[18px] tw-pointer-events-none tw-transition-all tw-duration-200 tw-ease-out tw-text-gray-500",
603
+ isActive ? sizeClasses.labelActive : sizeClasses.labelInactive,
604
+ error && "tw-text-color-text-critical",
605
+ labelClassName
606
+ ),
607
+ children: [
608
+ label,
609
+ mandatory && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "tw-text-color-text-critical tw-ml-1", children: "*" })
610
+ ]
611
+ }
612
+ ),
613
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
614
+ "div",
615
+ {
616
+ className: (0, import_clsx.default)(
617
+ "tw-absolute tw-right-3 tw-top-1/2 tw--translate-y-1/2 tw-flex tw-items-center",
618
+ {
619
+ "!tw-right-[5px]": doubleCharSearch && !(isHovering && selectedValue && allowClear)
620
+ }
621
+ ),
622
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
623
+ "div",
624
+ {
625
+ className: (0, import_clsx.default)(
626
+ "tw-transition-all tw-duration-200 tw-cursor-pointer tw-flex tw-items-center",
627
+ // Only rotate chevron when open and not showing clear icon
628
+ isOpen && !(isHovering && selectedValue && allowClear) && "-tw-rotate-180"
629
+ ),
630
+ onMouseDown: (e) => {
631
+ if (isHovering && selectedValue && allowClear) {
632
+ handleClear(e);
633
+ } else {
634
+ handleChevronClick(e);
635
+ }
636
+ },
637
+ children: isHovering && selectedValue && allowClear ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CrossV2, { color: "#111827", className: "tw-mr-1" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
638
+ Chevron2,
639
+ {
640
+ className: (0, import_clsx.default)("tw-text-gray-400"),
641
+ color: "#6B7280"
642
+ }
643
+ )
644
+ }
645
+ )
646
+ }
647
+ )
648
+ ] }),
649
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
650
+ "div",
651
+ {
652
+ className: (0, import_clsx.default)(
653
+ "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",
654
+ { "tw-max-h-60": !doubleCharSearch },
655
+ { "tw-max-h-44": doubleCharSearch },
656
+ dropdownClassName
657
+ ),
658
+ ref: optionListRef,
659
+ children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
660
+ "div",
661
+ {
662
+ ref: (el) => optionRefs.current[index] = el,
663
+ onClick: () => handleOptionSelect(option),
664
+ onMouseEnter: () => setHighlightedIndex(index),
665
+ className: (0, import_clsx.default)(
666
+ "tw-transition-all tw-duration-150 tw-typography-body2",
667
+ // Selected option styling
668
+ optionClassName
669
+ ),
670
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
671
+ "div",
672
+ {
673
+ className: (0, import_clsx.default)(
674
+ "tw-px-4 tw-cursor-pointer tw-py-2 tw-mx-0.5 tw-rounded-xl",
675
+ normalizeValue(selectedValue) === normalizeValue(option.value) ? experience === "personal" ? "tw-bg-[#f1e8fa]" : "tw-bg-[#fff1e1]" : (
676
+ // Highlighted option styling (keyboard navigation)
677
+ index === highlightedIndex ? "tw-bg-[#f3f4f6] tw-text-gray-900" : (
678
+ // Default option styling
679
+ "tw-text-gray-900 hover:tw-bg-[#1118270a]"
680
+ )
681
+ )
682
+ ),
683
+ children: option.label
684
+ }
685
+ )
686
+ },
687
+ doubleCharSearch ? option.label : option.value
688
+ )) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "tw-px-4 tw-py-3 tw-text-gray-500 tw-text-sm", children: "No options found" })
689
+ }
690
+ )
691
+ ]
692
+ }
693
+ );
694
+ };
695
+ var arePropsEqual = (prevProps, nextProps) => {
696
+ var _a, _b;
697
+ const criticalProps = [
698
+ "value",
699
+ "valueSelected",
700
+ "options",
701
+ "error",
702
+ "disabled",
703
+ "label",
704
+ "mandatory"
705
+ ];
706
+ for (const prop of criticalProps) {
707
+ if (prevProps[prop] !== nextProps[prop]) {
708
+ return false;
709
+ }
710
+ }
711
+ if (((_a = prevProps.options) == null ? void 0 : _a.length) !== ((_b = nextProps.options) == null ? void 0 : _b.length)) {
712
+ return false;
713
+ }
714
+ if (prevProps.options && nextProps.options) {
715
+ for (let i = 0; i < prevProps.options.length; i++) {
716
+ const prevOpt = prevProps.options[i];
717
+ const nextOpt = nextProps.options[i];
718
+ if ((prevOpt == null ? void 0 : prevOpt.value) !== (nextOpt == null ? void 0 : nextOpt.value) || (prevOpt == null ? void 0 : prevOpt.label) !== (nextOpt == null ? void 0 : nextOpt.label)) {
719
+ return false;
720
+ }
721
+ }
722
+ }
723
+ return true;
724
+ };
725
+ Select.displayName = "Select";
726
+ var Select_default = (0, import_react.memo)(Select, arePropsEqual);
727
+
728
+ // src/atom/RangePicker/RangePicker.tsx
729
+ var import_jsx_runtime5 = require("react/jsx-runtime");
730
+ function CustomRangePicker(props) {
731
+ var _a, _b;
732
+ const {
733
+ id = "",
734
+ footer,
735
+ onChange = () => {
736
+ },
737
+ dateRange = ["", ""],
738
+ showNightCount = false,
739
+ isRange = true,
740
+ showYearDropdown = false,
741
+ showSingleCalendar = false,
742
+ disablePastDates = false,
743
+ // New prop to control past date restriction
744
+ minDate = null,
745
+ // New prop for minimum allowed date
746
+ maxDate = null,
747
+ // New prop for maximum allowed date
748
+ minYear = 1900,
749
+ // Minimum year for dropdown
750
+ maxYear = (/* @__PURE__ */ new Date()).getFullYear() + 10,
751
+ // Maximum year for dropdown
752
+ experience = "business",
753
+ showToastError = () => {
754
+ }
755
+ } = props;
756
+ const onChangeRef = (0, import_react2.useRef)(onChange);
757
+ (0, import_react2.useEffect)(() => {
758
+ onChangeRef.current = onChange;
759
+ }, [onChange]);
760
+ const getInitialDate = () => {
761
+ if (dateRange[0]) {
762
+ return new Date(dateRange[0]);
763
+ }
764
+ if (!minDate && !maxDate && !minYear && !maxYear) {
765
+ return /* @__PURE__ */ new Date();
766
+ }
767
+ if (maxYear && maxYear !== (/* @__PURE__ */ new Date()).getFullYear()) {
768
+ let targetDate = new Date(maxYear, 7, 1);
769
+ if (maxDate) {
770
+ const maxDateTime = new Date(maxDate);
771
+ if (targetDate > maxDateTime) {
772
+ targetDate = new Date(
773
+ maxDateTime.getFullYear(),
774
+ maxDateTime.getMonth(),
775
+ 1
776
+ );
777
+ }
778
+ }
779
+ return targetDate;
780
+ }
781
+ if (minDate) {
782
+ const minDateTime = new Date(minDate);
783
+ minDateTime.setHours(0, 0, 0, 0);
784
+ return minDateTime;
785
+ }
786
+ return /* @__PURE__ */ new Date();
787
+ };
788
+ const [currentDate, setCurrentDate] = (0, import_react2.useState)(() => getInitialDate());
789
+ const [startDate, setStartDate] = (0, import_react2.useState)(
790
+ dateRange[0] ? new Date(dateRange[0]) : null
791
+ );
792
+ const [endDate, setEndDate] = (0, import_react2.useState)(
793
+ dateRange[0] && dateRange[1] ? new Date(dateRange[1]) : null
794
+ );
795
+ const [hoverDate, setHoverDate] = (0, import_react2.useState)(null);
796
+ const [isSelectingEnd, setIsSelectingEnd] = (0, import_react2.useState)(
797
+ dateRange[0] && !dateRange[1] ? true : false
798
+ );
799
+ const [selectedDate, setSelectedDate] = (0, import_react2.useState)(
800
+ !isRange && dateRange[0] ? new Date(dateRange[0]) : null
801
+ );
802
+ const getDaysBetween = (start, end) => {
803
+ if (!start || !end) return 0;
804
+ const startDay = (0, import_dayjs.default)(start).startOf("day");
805
+ const endDay = (0, import_dayjs.default)(end).startOf("day");
806
+ return endDay.diff(startDay, "day");
807
+ };
808
+ const nightCount = Math.abs(getDaysBetween(startDate || endDate, hoverDate));
809
+ const nightCountText = nightCount > 1 ? `${nightCount} nights` : "1 night";
810
+ const today = /* @__PURE__ */ new Date();
811
+ today.setHours(0, 0, 0, 0);
812
+ const firstMonth = new Date(
813
+ currentDate.getFullYear(),
814
+ currentDate.getMonth(),
815
+ 1
816
+ );
817
+ const secondMonth = new Date(
818
+ currentDate.getFullYear(),
819
+ currentDate.getMonth() + 1,
820
+ 1
821
+ );
822
+ const monthNames = [
823
+ "January",
824
+ "February",
825
+ "March",
826
+ "April",
827
+ "May",
828
+ "June",
829
+ "July",
830
+ "August",
831
+ "September",
832
+ "October",
833
+ "November",
834
+ "December"
835
+ ];
836
+ const dayNames = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
837
+ const generateYearOptions = () => {
838
+ const years = [];
839
+ for (let i = minYear; i <= maxYear; i++) {
840
+ const isYearDisabled = isYearCompletelyDisabled(i);
841
+ years.push({
842
+ label: i.toString(),
843
+ value: i,
844
+ disabled: isYearDisabled
845
+ });
846
+ }
847
+ return years;
848
+ };
849
+ const isYearCompletelyDisabled = (year) => {
850
+ const firstDayOfYear = new Date(year, 0, 1);
851
+ const lastDayOfYear = new Date(year, 11, 31);
852
+ if (minDate) {
853
+ const minDateTime = new Date(minDate);
854
+ minDateTime.setHours(0, 0, 0, 0);
855
+ if (minDateTime > lastDayOfYear) {
856
+ return true;
857
+ }
858
+ }
859
+ if (maxDate) {
860
+ const maxDateTime = new Date(maxDate);
861
+ maxDateTime.setHours(0, 0, 0, 0);
862
+ if (maxDateTime < firstDayOfYear) {
863
+ return true;
864
+ }
865
+ }
866
+ if (disablePastDates) {
867
+ const today2 = /* @__PURE__ */ new Date();
868
+ today2.setHours(0, 0, 0, 0);
869
+ if (lastDayOfYear < today2) {
870
+ return true;
871
+ }
872
+ }
873
+ return false;
874
+ };
875
+ const yearOptions = generateYearOptions();
876
+ const generateCalendarDays = (monthDate) => {
877
+ const year = monthDate.getFullYear();
878
+ const month = monthDate.getMonth();
879
+ const firstDay = new Date(year, month, 1);
880
+ const lastDay = new Date(year, month + 1, 0);
881
+ const daysInMonth = lastDay.getDate();
882
+ const startingDayOfWeek = firstDay.getDay();
883
+ const days = [];
884
+ for (let i = 0; i < startingDayOfWeek; i++) {
885
+ days.push(null);
886
+ }
887
+ for (let day = 1; day <= daysInMonth; day++) {
888
+ days.push(new Date(year, month, day));
889
+ }
890
+ return days;
891
+ };
892
+ const formatDateKey = (date) => {
893
+ if (!date) return "";
894
+ return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
895
+ };
896
+ const isSameDate = (date1, date2) => {
897
+ if (!date1 || !date2) return false;
898
+ return formatDateKey(date1) === formatDateKey(date2);
899
+ };
900
+ const isDateDisabled = (date) => {
901
+ if (!date) return false;
902
+ const checkDate = new Date(date);
903
+ checkDate.setHours(0, 0, 0, 0);
904
+ if (disablePastDates && checkDate < today) {
905
+ return true;
906
+ }
907
+ if (minDate) {
908
+ const minDateTime = new Date(minDate);
909
+ minDateTime.setHours(0, 0, 0, 0);
910
+ if (checkDate < minDateTime) {
911
+ return true;
912
+ }
913
+ }
914
+ if (maxDate) {
915
+ const maxDateTime = new Date(maxDate);
916
+ maxDateTime.setHours(0, 0, 0, 0);
917
+ if (checkDate > maxDateTime) {
918
+ return true;
919
+ }
920
+ }
921
+ return false;
922
+ };
923
+ const isDateInRange = (date) => {
924
+ if (!isRange || !startDate || !date) return false;
925
+ const compareDate = endDate || hoverDate;
926
+ if (!compareDate) return false;
927
+ const start = startDate < compareDate ? startDate : compareDate;
928
+ const end = startDate < compareDate ? compareDate : startDate;
929
+ return date >= start && date <= end;
930
+ };
931
+ const isDateBetweenRange = (date) => {
932
+ if (!isRange || !startDate || !date) return false;
933
+ const compareDate = endDate || hoverDate;
934
+ if (!compareDate) return false;
935
+ const start = startDate < compareDate ? startDate : compareDate;
936
+ const end = startDate < compareDate ? compareDate : startDate;
937
+ return date > start && date < end;
938
+ };
939
+ const handleDateClick = (date) => {
940
+ if (isDateDisabled(date)) return;
941
+ if (!isRange) {
942
+ setSelectedDate(date);
943
+ return;
944
+ }
945
+ const isCheckinCheckoutSame = (0, import_dayjs.default)(date).format("D MMM, YYYY") === (0, import_dayjs.default)(startDate).format("D MMM, YYYY");
946
+ if (showNightCount && isCheckinCheckoutSame) {
947
+ setStartDate(null);
948
+ setEndDate(null);
949
+ setIsSelectingEnd(false);
950
+ setHoverDate(null);
951
+ showToastError("Check-in and check-out dates cannot be the same.");
952
+ return;
953
+ }
954
+ if (!startDate || startDate && endDate) {
955
+ setStartDate(date);
956
+ setEndDate(null);
957
+ setIsSelectingEnd(true);
958
+ setHoverDate(null);
959
+ } else if (startDate && !endDate) {
960
+ if (date < startDate) {
961
+ setEndDate(startDate);
962
+ setStartDate(date);
963
+ } else {
964
+ setEndDate(date);
965
+ }
966
+ setIsSelectingEnd(false);
967
+ setHoverDate(null);
968
+ }
969
+ };
970
+ (0, import_react2.useEffect)(() => {
971
+ if (isRange) {
972
+ sessionStorage.removeItem("rangePickerStartDate");
973
+ onChangeRef.current(null, [
974
+ startDate ? (0, import_dayjs.default)(startDate).format("D MMM, YYYY") : "",
975
+ endDate ? (0, import_dayjs.default)(endDate).format("D MMM, YYYY") : ""
976
+ ]);
977
+ }
978
+ if (isRange && startDate && !endDate) {
979
+ sessionStorage.setItem(
980
+ "rangePickerStartDate",
981
+ (0, import_dayjs.default)(startDate).format("D MMM, YYYY")
982
+ );
983
+ }
984
+ }, [startDate, endDate, isRange]);
985
+ (0, import_react2.useEffect)(() => {
986
+ if (!isRange && selectedDate) {
987
+ onChangeRef.current(null, (0, import_dayjs.default)(selectedDate).format("D MMM, YYYY"));
988
+ }
989
+ }, [selectedDate, isRange]);
990
+ const handleDateHover = (date) => {
991
+ if (isDateDisabled(date) || !isRange) return;
992
+ if (isSelectingEnd && startDate && !endDate) {
993
+ setHoverDate(date);
994
+ }
995
+ };
996
+ const navigateMonth = (direction) => {
997
+ const newDate = new Date(currentDate);
998
+ newDate.setMonth(currentDate.getMonth() + direction);
999
+ setCurrentDate(newDate);
1000
+ };
1001
+ const isPreviousMonthDisabled = () => {
1002
+ const previousMonth = new Date(currentDate);
1003
+ previousMonth.setMonth(currentDate.getMonth() - 1);
1004
+ const lastDayOfPreviousMonth = new Date(
1005
+ previousMonth.getFullYear(),
1006
+ previousMonth.getMonth() + 1,
1007
+ 0
1008
+ );
1009
+ return isDateDisabled(lastDayOfPreviousMonth);
1010
+ };
1011
+ const isNextMonthDisabled = () => {
1012
+ const nextMonth = new Date(currentDate);
1013
+ nextMonth.setMonth(currentDate.getMonth() + 1);
1014
+ const firstDayOfNextMonth = new Date(
1015
+ nextMonth.getFullYear(),
1016
+ nextMonth.getMonth(),
1017
+ 1
1018
+ );
1019
+ return isDateDisabled(firstDayOfNextMonth);
1020
+ };
1021
+ const handleYearChange = (selectedYear) => {
1022
+ const newDate = new Date(currentDate);
1023
+ newDate.setFullYear(selectedYear);
1024
+ const targetMonth = newDate.getMonth();
1025
+ if (!isMonthDisabled(selectedYear, targetMonth)) {
1026
+ setCurrentDate(newDate);
1027
+ } else {
1028
+ const firstAvailableMonth = findFirstAvailableMonth(selectedYear);
1029
+ if (firstAvailableMonth !== -1) {
1030
+ newDate.setMonth(firstAvailableMonth);
1031
+ setCurrentDate(newDate);
1032
+ }
1033
+ }
1034
+ };
1035
+ const isMonthDisabled = (year, month) => {
1036
+ const lastDayOfMonth = new Date(year, month + 1, 0);
1037
+ const firstDayOfMonth = new Date(year, month, 1);
1038
+ return isDateDisabled(lastDayOfMonth) && isDateDisabled(firstDayOfMonth);
1039
+ };
1040
+ const findFirstAvailableMonth = (year) => {
1041
+ for (let month = 0; month < 12; month++) {
1042
+ if (!isMonthDisabled(year, month)) {
1043
+ return month;
1044
+ }
1045
+ }
1046
+ return -1;
1047
+ };
1048
+ const isSameDay = ((_a = (0, import_dayjs.default)(startDate)) == null ? void 0 : _a.format("D MMM, YYYY")) === ((_b = (0, import_dayjs.default)(endDate)) == null ? void 0 : _b.format("D MMM, YYYY"));
1049
+ const NightCountTooltip = () => {
1050
+ const TooltipArrow = (0, import_react2.memo)(() => {
1051
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-w-3 tw-h-3 tw-flex tw-items-center tw-justify-center tw-rounded tw-bg-transparent tw-rotate-90", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1052
+ "div",
1053
+ {
1054
+ style: {
1055
+ borderTop: "5px solid transparent",
1056
+ borderBottom: "5px solid transparent",
1057
+ borderLeft: "8px solid black"
1058
+ }
1059
+ }
1060
+ ) });
1061
+ });
1062
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tw-absolute tw-bottom-11 tw-py-2 tw-bg-black tw-text-white tw-px-2 tw-rounded-lg tw-z-50 tw-text-xs tw-whitespace-nowrap tw-opacity-0 tw-pointer-events-none group-hover:tw-opacity-100 tw-transition-opacity tw-duration-200", children: [
1063
+ nightCountText,
1064
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-absolute tw-right-[42%] tw-bottom-[-7px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TooltipArrow, {}) })
1065
+ ] });
1066
+ };
1067
+ const renderCalendar = (monthDate, isSecondCalendar = false) => {
1068
+ const days = generateCalendarDays(monthDate);
1069
+ const monthName = monthNames[monthDate.getMonth()];
1070
+ const year = monthDate.getFullYear();
1071
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1072
+ "div",
1073
+ {
1074
+ className: (0, import_clsx2.default)("tw-flex-1 tw-max-w-[83vw] tw-mb-2", {
1075
+ "tw-h-[320px]": showYearDropdown || days.length > 35,
1076
+ "tw-h-[290px]": !showYearDropdown || days.length <= 35
1077
+ }),
1078
+ children: [
1079
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-text-center tw-mb-4 sm:tw-mt-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: " tw-flex tw-justify-center tw-items-center tw-gap-4 ", children: [
1080
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h3", { className: "tw-typography-footNoteBold tw-text-color-text-default tw-m-0", children: [
1081
+ monthName,
1082
+ " ",
1083
+ !showYearDropdown && ` ${year}`
1084
+ ] }),
1085
+ showYearDropdown && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1086
+ Select_default,
1087
+ {
1088
+ options: yearOptions,
1089
+ value: currentDate.getFullYear(),
1090
+ valueSelected: currentDate.getFullYear(),
1091
+ onChange: (selectedYear) => {
1092
+ if (typeof selectedYear === "number") {
1093
+ handleYearChange(selectedYear);
1094
+ }
1095
+ },
1096
+ className: "tw-min-w-fit tw-bg-transparent tw-typography-footNoteBold tw-text-color-text-default",
1097
+ size: "small",
1098
+ variant: "filled",
1099
+ style: { width: "80px" },
1100
+ id: `${id}-year-select`,
1101
+ allowClear: false,
1102
+ enableSearch: false,
1103
+ experience
1104
+ }
1105
+ )
1106
+ ] }) }),
1107
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-grid tw-grid-cols-7 tw-mb-2", children: dayNames.map((day) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1108
+ "div",
1109
+ {
1110
+ className: "tw-py-2 tw-px-0 tw-text-center tw-typography-caption2 tw-text-[#6B7280]",
1111
+ children: day
1112
+ },
1113
+ day
1114
+ )) }),
1115
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-grid tw-grid-cols-7", children: days.map((date, index) => {
1116
+ if (!date) {
1117
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-h-10" }, index);
1118
+ }
1119
+ const isStart = isRange ? isSameDate(date, startDate) : false;
1120
+ const isEnd = isRange ? isSameDate(date, endDate) : false;
1121
+ const isSelected = !isRange ? isSameDate(date, selectedDate) : false;
1122
+ const isInRange = isRange ? isDateBetweenRange(date) : false;
1123
+ const isHovering = isRange && isSelectingEnd && hoverDate && isDateInRange(date) && !isStart && !isEnd;
1124
+ const isDisabled = isDateDisabled(date);
1125
+ let className = "tw-relative tw-z-20 tw-h-10 tw-w-10 tw-flex tw-items-center tw-justify-center tw-typography-caption1Bold ";
1126
+ const isFirstInRow = index % 7 === 0;
1127
+ const isLastInRow = index % 7 === 6;
1128
+ let pseudoClass = "";
1129
+ if (isDisabled) {
1130
+ className += "tw-text-gray-300 tw-cursor-not-allowed ";
1131
+ } else {
1132
+ className += "tw-cursor-pointer ";
1133
+ if (isStart || isEnd || isSelected) {
1134
+ className += "tw-bg-black tw-z-[21] tw-text-white tw-font-medium tw-rounded-full ";
1135
+ } else if (isInRange) {
1136
+ className += "tw-text-gray-900";
1137
+ if (window.innerWidth < 640) {
1138
+ className = className.replace(
1139
+ "tw-w-10",
1140
+ "tw-pr-2 tw-w-[50px] sm:tw-w-10 sm:tw-pr-0"
1141
+ );
1142
+ }
1143
+ pseudoClass = (0, import_clsx2.default)(RangePicker_module_default.range_start, RangePicker_module_default.range_end);
1144
+ } else {
1145
+ className += "tw-text-gray-700 hover:tw-border-2 hover:tw-border-black tw-rounded-full hover:tw-border-solid ";
1146
+ }
1147
+ if (isHovering) {
1148
+ className += "tw-border-2 tw-border-gray-400 tw-bg-white tw-z-[22]";
1149
+ }
1150
+ }
1151
+ const titleDate = (0, import_dayjs.default)(date).format("YYYY-MM-DD");
1152
+ const hoverDateFormatted = (0, import_dayjs.default)(hoverDate || null).format(
1153
+ "YYYY-MM-DD"
1154
+ );
1155
+ const isHoveringDate = (0, import_dayjs.default)(hoverDateFormatted).isSame(
1156
+ (0, import_dayjs.default)(date),
1157
+ "day"
1158
+ );
1159
+ const isHoverDateGreater = (0, import_dayjs.default)(hoverDate).isAfter(
1160
+ (0, import_dayjs.default)(startDate),
1161
+ "day"
1162
+ );
1163
+ const isHoverDateLess = (0, import_dayjs.default)(hoverDate).isBefore(
1164
+ (0, import_dayjs.default)(startDate),
1165
+ "day"
1166
+ );
1167
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tw-relative", children: [
1168
+ (isStart || isEnd) && startDate && endDate && !isSameDay && isRange && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1169
+ "div",
1170
+ {
1171
+ className: (0, import_clsx2.default)(
1172
+ "tw-w-9 tw-h-8 tw-bg-[#F2EFEC] tw-rotate-90 tw-absolute tw-z-10 tw-top-1",
1173
+ {
1174
+ "tw-left-5": isStart,
1175
+ "tw-right-5": isEnd,
1176
+ "tw-invisible": isFirstInRow && isEnd || isLastInRow && isStart
1177
+ }
1178
+ )
1179
+ }
1180
+ ),
1181
+ isHoveringDate && isHovering && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1182
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1183
+ "div",
1184
+ {
1185
+ className: (0, import_clsx2.default)(
1186
+ "tw-w-9 tw-h-8 tw-bg-[#F2EFEC] tw-rotate-90 tw-absolute tw-z-10 tw-top-1",
1187
+ {
1188
+ "tw-right-5": isHoverDateGreater,
1189
+ "tw-left-5": isHoverDateLess,
1190
+ "tw-invisible": isFirstInRow && isHoverDateGreater || isLastInRow && isHoverDateLess
1191
+ }
1192
+ )
1193
+ }
1194
+ ),
1195
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1196
+ "div",
1197
+ {
1198
+ className: (0, import_clsx2.default)(
1199
+ "tw-w-[18px] tw-h-[40px] tw-bg-white tw-rounded-r-full tw-absolute tw-z-20",
1200
+ {
1201
+ "tw-left-5": isHoverDateLess,
1202
+ "tw-right-5 tw-rotate-180": isHoverDateGreater
1203
+ }
1204
+ )
1205
+ }
1206
+ )
1207
+ ] }),
1208
+ isStart && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1209
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1210
+ "div",
1211
+ {
1212
+ className: (0, import_clsx2.default)(
1213
+ "tw-w-9 tw-h-8 tw-bg-[#F2EFEC] tw-rotate-90 tw-absolute tw-z-10 tw-top-1",
1214
+ {
1215
+ "tw-right-5": isHoverDateLess,
1216
+ "tw-left-5": isHoverDateGreater,
1217
+ "tw-invisible": isLastInRow
1218
+ }
1219
+ )
1220
+ }
1221
+ ),
1222
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1223
+ "div",
1224
+ {
1225
+ className: (0, import_clsx2.default)(
1226
+ "tw-w-[18px] tw-h-[40px] tw-bg-white tw-rounded-r-full tw-absolute tw-z-20",
1227
+ {
1228
+ "tw-left-5": isHoverDateGreater,
1229
+ "tw-right-5 tw-rotate-180": isHoverDateLess
1230
+ }
1231
+ )
1232
+ }
1233
+ )
1234
+ ] }),
1235
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1236
+ "div",
1237
+ {
1238
+ className: (0, import_clsx2.default)(className, pseudoClass, "tw-group", {
1239
+ "tw-border-2 !tw-border-black tw-rounded-full tw-border-solid": (0, import_dayjs.default)(date).isSame((0, import_dayjs.default)(hoverDate), "day")
1240
+ }),
1241
+ onClick: () => handleDateClick(date),
1242
+ onMouseEnter: () => handleDateHover(date),
1243
+ "data-date": titleDate,
1244
+ children: [
1245
+ showNightCount && isRange && isHovering && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NightCountTooltip, {}),
1246
+ date.getDate()
1247
+ ]
1248
+ }
1249
+ )
1250
+ ] }, formatDateKey(date));
1251
+ }) })
1252
+ ]
1253
+ }
1254
+ );
1255
+ };
1256
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1257
+ "div",
1258
+ {
1259
+ className: (0, import_clsx2.default)(
1260
+ "custom-range-picker tw-relative tw-bg-white tw-rounded-xl tw-pt-1 tw-px-0 tw-max-w-4xl tw-mx-auto tw-border tw-border-gray-200 tw-border-solid tw-w-full tw-max-h-[90vh] tw-overflow-y-auto",
1261
+ {
1262
+ "sm:tw-w-[640px]": !showSingleCalendar,
1263
+ "sm:tw-w-[330px]": showSingleCalendar
1264
+ }
1265
+ ),
1266
+ children: [
1267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tw-flex tw-items-center tw-px-4 tw-justify-between tw-mb-4 tw-absolute tw-right-0 tw-left-0 tw-top-0.5 sm:tw-top-4 tw-w-auto", children: [
1268
+ !isPreviousMonthDisabled() && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1269
+ "div",
1270
+ {
1271
+ className: "tw-relative tw-top-3 sm:tw-top-0 tw-cursor-pointer tw-rounded-full tw-w-10 tw-h-10 tw-flex tw-justify-center hover:tw-bg-gray-100 tw-items-center",
1272
+ onClick: () => navigateMonth(-1),
1273
+ id: "calendar-previous-month-button",
1274
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Chevron, { size: "medium" })
1275
+ }
1276
+ ),
1277
+ isPreviousMonthDisabled() && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-w-10 tw-h-10" }),
1278
+ !isNextMonthDisabled() && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1279
+ "div",
1280
+ {
1281
+ className: "tw-relative tw-top-3 sm:tw-top-0 tw-cursor-pointer tw-rounded-full tw-w-10 tw-h-10 tw-flex tw-justify-center hover:tw-bg-gray-100 tw-items-center",
1282
+ onClick: () => navigateMonth(1),
1283
+ id: "calendar-next-month-button",
1284
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1285
+ Chevron,
1286
+ {
1287
+ size: "medium",
1288
+ onClick: () => navigateMonth(1),
1289
+ className: "tw-rotate-180"
1290
+ }
1291
+ )
1292
+ }
1293
+ ),
1294
+ isNextMonthDisabled() && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-w-10 tw-h-10" })
1295
+ ] }),
1296
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tw-flex tw-items-center tw-justify-between tw-px-6 tw-border-solid tw-border-color-gray-100 tw-border-b tw-border-t-0 tw-border-l-0 tw-border-r-0 tw-w-auto", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1297
+ "div",
1298
+ {
1299
+ className: (0, import_clsx2.default)("tw-flex tw-w-full", {
1300
+ "tw-flex-col sm:tw-space-x-8 sm:tw-flex-row": isRange || !showSingleCalendar,
1301
+ "tw-justify-center": !isRange || showSingleCalendar,
1302
+ "tw-pt-4": showYearDropdown,
1303
+ // More space when year dropdown is visible
1304
+ "tw-pt-6": !showYearDropdown
1305
+ }),
1306
+ children: [
1307
+ renderCalendar(firstMonth),
1308
+ !showSingleCalendar && renderCalendar(secondMonth, true)
1309
+ ]
1310
+ }
1311
+ ) }),
1312
+ footer
1313
+ ]
1314
+ }
1315
+ );
1316
+ }
1317
+ CustomRangePicker.displayName = "RangePicker";
1318
+ var RangePicker_default = CustomRangePicker;
1319
+ // Annotate the CommonJS export names for ESM import in node:
1320
+ 0 && (module.exports = {
1321
+ RangePicker
1322
+ });