@itilite/lumina-ui 1.0.1 → 1.0.3-alpha

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 (122) hide show
  1. package/README.md +43 -10
  2. package/dist/AdvancedDateRangePicker-D7xn4So6.d.mts +59 -0
  3. package/dist/AdvancedDateRangePicker-D7xn4So6.d.ts +59 -0
  4. package/dist/AdvancedDateRangePicker-ozItnkhp.d.mts +57 -0
  5. package/dist/AdvancedDateRangePicker-ozItnkhp.d.ts +57 -0
  6. package/dist/Table-BOq-_9Nr.d.mts +121 -0
  7. package/dist/Table-BOq-_9Nr.d.ts +121 -0
  8. package/dist/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.d.mts +2 -0
  9. package/dist/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.d.ts +2 -0
  10. package/dist/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.js +1610 -0
  11. package/dist/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.mjs +15 -0
  12. package/dist/atom/AdvancedDateRangePicker/InternalCalendar.d.mts +17 -0
  13. package/dist/atom/AdvancedDateRangePicker/InternalCalendar.d.ts +17 -0
  14. package/dist/atom/AdvancedDateRangePicker/InternalCalendar.js +370 -0
  15. package/dist/atom/AdvancedDateRangePicker/InternalCalendar.mjs +8 -0
  16. package/dist/{Avatar.d.mts → atom/Avatar/Avatar.d.mts} +1 -9
  17. package/dist/{Avatar.d.ts → atom/Avatar/Avatar.d.ts} +1 -9
  18. package/dist/{Avatar.js → atom/Avatar/Avatar.js} +4 -2
  19. package/dist/{Avatar.mjs → atom/Avatar/Avatar.mjs} +2 -2
  20. package/dist/{Button.js → atom/Button/Button.js} +1 -1
  21. package/dist/{Button.mjs → atom/Button/Button.mjs} +2 -2
  22. package/dist/{Checkbox.mjs → atom/Checkbox/Checkbox.mjs} +2 -2
  23. package/dist/atom/LoadingSpinner/LoadingSpinner.d.mts +19 -0
  24. package/dist/atom/LoadingSpinner/LoadingSpinner.d.ts +19 -0
  25. package/dist/atom/LoadingSpinner/LoadingSpinner.js +90 -0
  26. package/dist/atom/LoadingSpinner/LoadingSpinner.mjs +9 -0
  27. package/dist/{Modal.d.mts → atom/Modal/Modal.d.mts} +1 -1
  28. package/dist/{Modal.d.ts → atom/Modal/Modal.d.ts} +1 -1
  29. package/dist/{Modal.js → atom/Modal/Modal.js} +1 -1
  30. package/dist/atom/Modal/Modal.mjs +10 -0
  31. package/dist/{Radio.mjs → atom/Radio/Radio.mjs} +2 -2
  32. package/dist/atom/RangePicker/Chevron.d.mts +13 -0
  33. package/dist/atom/RangePicker/Chevron.d.ts +13 -0
  34. package/dist/atom/RangePicker/Chevron.js +110 -0
  35. package/dist/atom/RangePicker/Chevron.mjs +7 -0
  36. package/dist/atom/RangePicker/RangePicker.d.mts +26 -0
  37. package/dist/atom/RangePicker/RangePicker.d.ts +26 -0
  38. package/dist/atom/RangePicker/RangePicker.js +1465 -0
  39. package/dist/atom/RangePicker/RangePicker.mjs +13 -0
  40. package/dist/atom/Select/Select.d.mts +40 -0
  41. package/dist/atom/Select/Select.d.ts +40 -0
  42. package/dist/atom/Select/Select.js +805 -0
  43. package/dist/atom/Select/Select.mjs +11 -0
  44. package/dist/atom/Slider/Slider.d.mts +34 -0
  45. package/dist/atom/Slider/Slider.d.ts +34 -0
  46. package/dist/atom/Slider/Slider.js +107 -0
  47. package/dist/atom/Slider/Slider.mjs +9 -0
  48. package/dist/{Switch.mjs → atom/Switch/Switch.mjs} +2 -2
  49. package/dist/atom/Table/Table.d.mts +3 -0
  50. package/dist/atom/Table/Table.d.ts +3 -0
  51. package/dist/atom/Table/Table.js +307 -0
  52. package/dist/atom/Table/Table.mjs +9 -0
  53. package/dist/atom/Tag/Tag.d.mts +6 -0
  54. package/dist/atom/Tag/Tag.d.ts +6 -0
  55. package/dist/atom/Tag/Tag.js +108 -0
  56. package/dist/atom/Tag/Tag.mjs +9 -0
  57. package/dist/{Tooltip.mjs → atom/Tooltip/Tooltip.mjs} +2 -2
  58. package/dist/chunk-27LRL4RO.mjs +428 -0
  59. package/dist/chunk-3HXZIFV6.mjs +438 -0
  60. package/dist/chunk-4JX54OKI.mjs +627 -0
  61. package/dist/chunk-4VZB2KR2.mjs +51 -0
  62. package/dist/chunk-53O7JM5I.mjs +424 -0
  63. package/dist/chunk-62VAYFZA.mjs +437 -0
  64. package/dist/chunk-6ON32H2N.mjs +431 -0
  65. package/dist/chunk-6XIT27XY.mjs +269 -0
  66. package/dist/chunk-772C454L.mjs +438 -0
  67. package/dist/chunk-7L267Y4P.mjs +429 -0
  68. package/dist/chunk-7WSVCE2C.mjs +269 -0
  69. package/dist/{chunk-HISCHZ5H.mjs → chunk-AF2RKLH6.mjs} +1 -1
  70. package/dist/chunk-BFFLWW7N.mjs +250 -0
  71. package/dist/chunk-D3N7VFER.mjs +73 -0
  72. package/dist/chunk-FTL3PFC2.mjs +438 -0
  73. package/dist/chunk-GU5F7Z7I.mjs +681 -0
  74. package/dist/chunk-GZ4P7OL3.mjs +429 -0
  75. package/dist/{chunk-X76GNSBB.mjs → chunk-IWO2Y5QX.mjs} +4 -2
  76. package/dist/chunk-J4YYP4IZ.mjs +0 -0
  77. package/dist/chunk-K2A4TWA3.mjs +430 -0
  78. package/dist/chunk-L3L42SIL.mjs +429 -0
  79. package/dist/chunk-MA23J4WQ.mjs +430 -0
  80. package/dist/chunk-N2WTNCQU.mjs +66 -0
  81. package/dist/chunk-N4DPPZVJ.mjs +269 -0
  82. package/dist/chunk-PQ3B2FEB.mjs +249 -0
  83. package/dist/chunk-QKTMWS4J.mjs +43 -0
  84. package/dist/chunk-QRGHJP7U.mjs +437 -0
  85. package/dist/chunk-RC6IGURJ.mjs +428 -0
  86. package/dist/chunk-TQDZWJZP.mjs +269 -0
  87. package/dist/{chunk-N355RJGH.mjs → chunk-UQJ3BDM4.mjs} +1 -1
  88. package/dist/chunk-V3CHJHUX.mjs +424 -0
  89. package/dist/chunk-ZGV6QMVM.mjs +437 -0
  90. package/dist/chunk-ZTRM4HZJ.mjs +53 -0
  91. package/dist/index.d.mts +18 -7
  92. package/dist/index.d.ts +18 -7
  93. package/dist/index.js +2470 -8
  94. package/dist/index.mjs +44 -10
  95. package/dist/molecules/UserProfile/UserProfile.d.mts +23 -0
  96. package/dist/molecules/UserProfile/UserProfile.d.ts +23 -0
  97. package/dist/molecules/UserProfile/UserProfile.js +243 -0
  98. package/dist/molecules/UserProfile/UserProfile.mjs +11 -0
  99. package/dist/styles.css +1891 -907
  100. package/dist/types-D4MD2w3_.d.mts +9 -0
  101. package/dist/types-D4MD2w3_.d.ts +9 -0
  102. package/dist/types-mhQmqhsR.d.mts +10 -0
  103. package/dist/types-mhQmqhsR.d.ts +10 -0
  104. package/package.json +9 -32
  105. package/dist/Modal.mjs +0 -10
  106. package/dist/chunk-2O2IH2FG.mjs +0 -83
  107. package/dist/styles.d.mts +0 -2
  108. package/dist/styles.d.ts +0 -2
  109. /package/dist/{Button.d.mts → atom/Button/Button.d.mts} +0 -0
  110. /package/dist/{Button.d.ts → atom/Button/Button.d.ts} +0 -0
  111. /package/dist/{Checkbox.d.mts → atom/Checkbox/Checkbox.d.mts} +0 -0
  112. /package/dist/{Checkbox.d.ts → atom/Checkbox/Checkbox.d.ts} +0 -0
  113. /package/dist/{Checkbox.js → atom/Checkbox/Checkbox.js} +0 -0
  114. /package/dist/{Radio.d.mts → atom/Radio/Radio.d.mts} +0 -0
  115. /package/dist/{Radio.d.ts → atom/Radio/Radio.d.ts} +0 -0
  116. /package/dist/{Radio.js → atom/Radio/Radio.js} +0 -0
  117. /package/dist/{Switch.d.mts → atom/Switch/Switch.d.mts} +0 -0
  118. /package/dist/{Switch.d.ts → atom/Switch/Switch.d.ts} +0 -0
  119. /package/dist/{Switch.js → atom/Switch/Switch.js} +0 -0
  120. /package/dist/{Tooltip.d.mts → atom/Tooltip/Tooltip.d.mts} +0 -0
  121. /package/dist/{Tooltip.d.ts → atom/Tooltip/Tooltip.d.ts} +0 -0
  122. /package/dist/{Tooltip.js → atom/Tooltip/Tooltip.js} +0 -0
@@ -0,0 +1,1610 @@
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/AdvancedDateRangePicker/AdvancedDateRangePicker.tsx
60
+ var AdvancedDateRangePicker_exports = {};
61
+ __export(AdvancedDateRangePicker_exports, {
62
+ AdvancedDateRangePicker: () => AdvancedDateRangePicker,
63
+ default: () => AdvancedDateRangePicker_default
64
+ });
65
+ module.exports = __toCommonJS(AdvancedDateRangePicker_exports);
66
+ var import_react4 = require("react");
67
+ var import_clsx3 = __toESM(require("clsx"));
68
+ var import_dayjs2 = __toESM(require("dayjs"));
69
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
70
+ var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore.js"));
71
+
72
+ // src/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.module.scss
73
+ var AdvancedDateRangePicker_module_default = { "root": "AdvancedDateRangePicker-module__root___udir8", "inner": "AdvancedDateRangePicker-module__inner___P4OHa", "left": "AdvancedDateRangePicker-module__left___T6E84", "sidebarItem": "AdvancedDateRangePicker-module__sidebarItem___-NXPm", "sidebarItemActive": "AdvancedDateRangePicker-module__sidebarItemActive___5GmBY", "main": "AdvancedDateRangePicker-module__main___G4MU9", "header": "AdvancedDateRangePicker-module__header___mxXEE", "timezoneWrapper": "AdvancedDateRangePicker-module__timezoneWrapper___886Qm", "dateTimeWrapper": "AdvancedDateRangePicker-module__dateTimeWrapper___unDQJ", "headerGroup": "AdvancedDateRangePicker-module__headerGroup___J7mJB", "headerLabel": "AdvancedDateRangePicker-module__headerLabel___Yvhkr", "headerSeparator": "AdvancedDateRangePicker-module__headerSeparator___Vwx6P", "timezoneSelect": "AdvancedDateRangePicker-module__timezoneSelect___f4oln", "timezoneSelectContainer": "AdvancedDateRangePicker-module__timezoneSelectContainer___8SMc4", "timezoneSelectInput": "AdvancedDateRangePicker-module__timezoneSelectInput___ol0-7", "timezoneDisabledBadge": "AdvancedDateRangePicker-module__timezoneDisabledBadge___VBxOd", "inputWrapper": "AdvancedDateRangePicker-module__inputWrapper___bFFNF", "dateTimeColumn": "AdvancedDateRangePicker-module__dateTimeColumn___tdDV3", "dateTimeGroup": "AdvancedDateRangePicker-module__dateTimeGroup___azF09", "dateInput": "AdvancedDateRangePicker-module__dateInput___0t9ww", "inputError": "AdvancedDateRangePicker-module__inputError___A5hid", "timeInput": "AdvancedDateRangePicker-module__timeInput___Jalr9", "errorMessage": "AdvancedDateRangePicker-module__errorMessage___gx7ag", "body": "AdvancedDateRangePicker-module__body___f8XYj", "footer": "AdvancedDateRangePicker-module__footer___rsJ2w", "doneBtn": "AdvancedDateRangePicker-module__doneBtn___mt-Sv" };
74
+
75
+ // src/atom/AdvancedDateRangePicker/InternalCalendar.tsx
76
+ var import_react = require("react");
77
+ var import_dayjs = __toESM(require("dayjs"));
78
+
79
+ // src/atom/RangePicker/Chevron.tsx
80
+ var React = __toESM(require("react"));
81
+ var import_jsx_runtime = require("react/jsx-runtime");
82
+ var Chevron = React.memo(
83
+ (_a) => {
84
+ var _b = _a, { size = "normal", color = "black", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
85
+ const getSize = (size2) => {
86
+ switch (size2) {
87
+ case "small":
88
+ 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";
89
+ case "normal":
90
+ 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";
91
+ default:
92
+ 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";
93
+ }
94
+ };
95
+ const getContainer = (size2) => {
96
+ switch (size2) {
97
+ case "small":
98
+ return 16;
99
+ case "medium":
100
+ return 20;
101
+ case "normal":
102
+ return 24;
103
+ default:
104
+ return 24;
105
+ }
106
+ };
107
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
+ "svg",
109
+ __spreadProps(__spreadValues({
110
+ xmlns: "http://www.w3.org/2000/svg",
111
+ width: getContainer(size),
112
+ height: getContainer(size),
113
+ fill: "none",
114
+ viewBox: `0 0 ${getContainer(size)} ${getContainer(size)}`,
115
+ className
116
+ }, rest), {
117
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: color, d: getSize(size) })
118
+ })
119
+ );
120
+ }
121
+ );
122
+
123
+ // src/atom/AdvancedDateRangePicker/InternalCalendar.tsx
124
+ var import_jsx_runtime2 = require("react/jsx-runtime");
125
+ var InternalCalendar = ({
126
+ id = "",
127
+ onChange = () => {
128
+ },
129
+ dateRange = ["", ""],
130
+ showSingleCalendar: showSingleCalendarProp = false,
131
+ disablePastDates = false,
132
+ minDate = null,
133
+ maxDate = null,
134
+ minYear = 1900,
135
+ maxYear = (/* @__PURE__ */ new Date()).getFullYear() + 10,
136
+ allowSameDates = false
137
+ }) => {
138
+ const onChangeRef = (0, import_react.useRef)(onChange);
139
+ (0, import_react.useEffect)(() => {
140
+ onChangeRef.current = onChange;
141
+ }, [onChange]);
142
+ const getInitialDate = () => {
143
+ const today2 = /* @__PURE__ */ new Date();
144
+ today2.setHours(0, 0, 0, 0);
145
+ if (dateRange[0]) return new Date(dateRange[0]);
146
+ if (today2.getFullYear() >= minYear && today2.getFullYear() <= maxYear) {
147
+ return today2;
148
+ }
149
+ if (minDate) {
150
+ const minDateTime = new Date(minDate);
151
+ minDateTime.setHours(0, 0, 0, 0);
152
+ return minDateTime;
153
+ }
154
+ return today2;
155
+ };
156
+ const [currentDate, setCurrentDate] = (0, import_react.useState)(() => getInitialDate());
157
+ const [startDate, setStartDate] = (0, import_react.useState)(
158
+ dateRange[0] ? new Date(dateRange[0]) : null
159
+ );
160
+ const [endDate, setEndDate] = (0, import_react.useState)(
161
+ dateRange[0] && dateRange[1] ? new Date(dateRange[1]) : null
162
+ );
163
+ const [hoverDate, setHoverDate] = (0, import_react.useState)(null);
164
+ const [isSelectingEnd, setIsSelectingEnd] = (0, import_react.useState)(
165
+ dateRange[0] && !dateRange[1] ? true : false
166
+ );
167
+ const [isMobile, setIsMobile] = (0, import_react.useState)(false);
168
+ (0, import_react.useEffect)(() => {
169
+ const checkMobile = () => {
170
+ setIsMobile(window.innerWidth < 1024);
171
+ };
172
+ checkMobile();
173
+ window.addEventListener("resize", checkMobile);
174
+ return () => window.removeEventListener("resize", checkMobile);
175
+ }, []);
176
+ const showSingle = showSingleCalendarProp || isMobile;
177
+ const prevRangeRef = (0, import_react.useRef)(dateRange);
178
+ (0, import_react.useEffect)(() => {
179
+ const isSameRange = dateRange[0] === prevRangeRef.current[0] && dateRange[1] === prevRangeRef.current[1];
180
+ if (isSameRange) return;
181
+ prevRangeRef.current = dateRange;
182
+ const nextStart = dateRange[0] ? new Date(dateRange[0]) : null;
183
+ const nextEnd = dateRange[1] ? new Date(dateRange[1]) : null;
184
+ setStartDate(nextStart);
185
+ setEndDate(nextEnd);
186
+ if (nextStart) {
187
+ const startMonth = nextStart.getFullYear() * 12 + nextStart.getMonth();
188
+ const currentMonthVal = currentDate.getFullYear() * 12 + currentDate.getMonth();
189
+ const isVisibleInFirst = startMonth === currentMonthVal;
190
+ const isVisibleInSecond = !showSingle && startMonth === currentMonthVal + 1;
191
+ if (!isVisibleInFirst && !isVisibleInSecond) {
192
+ setCurrentDate(new Date(nextStart.getFullYear(), nextStart.getMonth(), 1));
193
+ }
194
+ }
195
+ }, [dateRange, showSingle]);
196
+ const today = /* @__PURE__ */ new Date();
197
+ today.setHours(0, 0, 0, 0);
198
+ const firstMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
199
+ const secondMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 1);
200
+ const monthNames = [
201
+ "January",
202
+ "February",
203
+ "March",
204
+ "April",
205
+ "May",
206
+ "June",
207
+ "July",
208
+ "August",
209
+ "September",
210
+ "October",
211
+ "November",
212
+ "December"
213
+ ];
214
+ const dayNames = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
215
+ const generateCalendarDays = (monthDate) => {
216
+ const year = monthDate.getFullYear();
217
+ const month = monthDate.getMonth();
218
+ const firstDay = new Date(year, month, 1);
219
+ const lastDay = new Date(year, month + 1, 0);
220
+ const daysInMonth = lastDay.getDate();
221
+ const startingDayOfWeek = firstDay.getDay();
222
+ const days = [];
223
+ for (let i = 0; i < startingDayOfWeek; i++) days.push(null);
224
+ for (let day = 1; day <= daysInMonth; day++) days.push(new Date(year, month, day));
225
+ return days;
226
+ };
227
+ const isSameDate = (d1, d2) => {
228
+ if (!d1 || !d2) return false;
229
+ return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate();
230
+ };
231
+ const isDateDisabled = (date) => {
232
+ if (!date) return false;
233
+ const checkDate = new Date(date);
234
+ checkDate.setHours(0, 0, 0, 0);
235
+ if (disablePastDates && checkDate < today) return true;
236
+ if (minDate) {
237
+ const m = new Date(minDate);
238
+ m.setHours(0, 0, 0, 0);
239
+ if (checkDate < m) return true;
240
+ }
241
+ if (maxDate) {
242
+ const m = new Date(maxDate);
243
+ m.setHours(0, 0, 0, 0);
244
+ if (checkDate > m) return true;
245
+ }
246
+ return false;
247
+ };
248
+ const isDateBetweenRange = (date) => {
249
+ if (!startDate || !date) return false;
250
+ const comp = endDate || hoverDate;
251
+ if (!comp) return false;
252
+ const s = startDate < comp ? startDate : comp;
253
+ const e = startDate < comp ? comp : startDate;
254
+ return date > s && date < e;
255
+ };
256
+ const isDateInRange = (date) => {
257
+ if (!startDate || !date) return false;
258
+ const comp = endDate || hoverDate;
259
+ if (!comp) return false;
260
+ const s = startDate < comp ? startDate : comp;
261
+ const e = startDate < comp ? comp : startDate;
262
+ return date >= s && date <= e;
263
+ };
264
+ const handleDateClick = (date) => {
265
+ if (isDateDisabled(date)) return;
266
+ let nextStart = startDate;
267
+ let nextEnd = endDate;
268
+ const isSame = startDate && (0, import_dayjs.default)(date).isSame(startDate, "day");
269
+ if (!allowSameDates && isSame) {
270
+ setStartDate(null);
271
+ setEndDate(null);
272
+ setIsSelectingEnd(false);
273
+ onChangeRef.current(["", ""]);
274
+ return;
275
+ }
276
+ if (!startDate || startDate && endDate) {
277
+ nextStart = date;
278
+ nextEnd = null;
279
+ setStartDate(nextStart);
280
+ setEndDate(nextEnd);
281
+ setIsSelectingEnd(true);
282
+ } else {
283
+ if (date < startDate) {
284
+ nextEnd = startDate;
285
+ nextStart = date;
286
+ } else {
287
+ nextEnd = date;
288
+ }
289
+ setStartDate(nextStart);
290
+ setEndDate(nextEnd);
291
+ setIsSelectingEnd(false);
292
+ }
293
+ onChangeRef.current([
294
+ nextStart ? (0, import_dayjs.default)(nextStart).format("D MMM, YYYY") : "",
295
+ nextEnd ? (0, import_dayjs.default)(nextEnd).format("D MMM, YYYY") : ""
296
+ ]);
297
+ };
298
+ const handleDateHover = (date) => {
299
+ if (isDateDisabled(date)) return;
300
+ if (isSelectingEnd && startDate && !endDate) setHoverDate(date);
301
+ };
302
+ const navigateMonth = (direction) => {
303
+ const newDate = new Date(currentDate);
304
+ newDate.setMonth(currentDate.getMonth() + direction);
305
+ setCurrentDate(newDate);
306
+ };
307
+ const renderCalendar = (monthDate) => {
308
+ const days = generateCalendarDays(monthDate);
309
+ const monthName = monthNames[monthDate.getMonth()];
310
+ const year = monthDate.getFullYear();
311
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tw-flex-1 tw-mb-2", children: [
312
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-text-center tw-mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("h3", { className: "tw-typography-footNoteBold tw-text-gray-900 tw-m-0", children: [
313
+ monthName,
314
+ " ",
315
+ year
316
+ ] }) }),
317
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-grid tw-grid-cols-7 tw-mb-2", children: dayNames.map((day) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-py-2 tw-text-center tw-typography-caption2 tw-text-gray-500", children: day }, day)) }),
318
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-grid tw-grid-cols-7", children: days.map((date, index) => {
319
+ if (!date) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-h-7" }, index);
320
+ const isStart = isSameDate(date, startDate);
321
+ const isEnd = isSameDate(date, endDate);
322
+ const isInRange = isDateBetweenRange(date);
323
+ const isSelected = isDateInRange(date);
324
+ const isDisabled = isDateDisabled(date);
325
+ const isHovering = isSelectingEnd && hoverDate && isSameDate(date, hoverDate);
326
+ let cellClasses = "tw-relative tw-z-20 tw-h-7 tw-w-7 tw-flex tw-items-center tw-justify-center tw-typography-caption1Bold tw-cursor-pointer tw-transition-all ";
327
+ if (isDisabled) {
328
+ cellClasses += "tw-text-gray-300 tw-cursor-not-allowed ";
329
+ } else if (isStart || isEnd) {
330
+ cellClasses += "tw-bg-black tw-text-white tw-rounded-full ";
331
+ } else if (isInRange) {
332
+ cellClasses += "tw-text-gray-900 ";
333
+ } else {
334
+ cellClasses += "tw-text-gray-700 hover:tw-bg-gray-100 tw-rounded-full ";
335
+ }
336
+ if (isHovering && !isEnd) {
337
+ cellClasses += "tw-border-2 tw-border-gray-400 tw-border-dashed ";
338
+ }
339
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tw-relative tw-flex tw-justify-center", children: [
340
+ isInRange && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-absolute tw-inset-y-1 tw-inset-x-0 tw-bg-[#E5E9ED] tw-z-10" }),
341
+ isStart && endDate && !isSameDate(startDate, endDate) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-absolute tw-inset-y-1 tw-right-0 tw-left-1/2 tw-bg-[#E5E9ED] tw-z-10" }),
342
+ isEnd && startDate && !isSameDate(startDate, endDate) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tw-absolute tw-inset-y-1 tw-left-0 tw-right-1/2 tw-bg-[#E5E9ED] tw-z-10" }),
343
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
344
+ "div",
345
+ {
346
+ className: cellClasses,
347
+ onClick: () => handleDateClick(date),
348
+ onMouseEnter: () => handleDateHover(date),
349
+ children: date.getDate()
350
+ }
351
+ )
352
+ ] }, date.toISOString());
353
+ }) })
354
+ ] });
355
+ };
356
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tw-relative tw-bg-white tw-w-full", children: [
357
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tw-flex tw-items-center tw-justify-between tw-absolute tw-inset-x-0 tw-top-0 tw-z-30 tw-px-4", children: [
358
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
359
+ "div",
360
+ {
361
+ className: "tw-cursor-pointer tw-p-2 tw-rounded-full hover:tw-bg-gray-100",
362
+ onClick: () => navigateMonth(-1),
363
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Chevron, { size: "medium" })
364
+ }
365
+ ),
366
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
367
+ "div",
368
+ {
369
+ className: "tw-cursor-pointer tw-p-2 tw-rounded-full hover:tw-bg-gray-100",
370
+ onClick: () => navigateMonth(1),
371
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Chevron, { size: "medium", className: "tw-rotate-180" })
372
+ }
373
+ )
374
+ ] }),
375
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tw-flex tw-gap-8 tw-pt-2", children: [
376
+ renderCalendar(firstMonth),
377
+ !showSingle && renderCalendar(secondMonth)
378
+ ] })
379
+ ] });
380
+ };
381
+ var InternalCalendar_default = (0, import_react.memo)(InternalCalendar);
382
+
383
+ // src/atom/Button/Button.tsx
384
+ var import_antd = require("antd");
385
+ var import_clsx = __toESM(require("clsx"));
386
+
387
+ // src/atom/Button/Button.module.scss
388
+ var Button_module_default = { "button": "Button-module__button___cLCyl", "size_large": "Button-module__size_large___S-mbU", "shape_circle": "Button-module__shape_circle___sPUS5", "size_normal": "Button-module__size_normal___qJUMj", "size_small": "Button-module__size_small___IUeei", "type_primary": "Button-module__type_primary___Tauz-", "variant_subtle": "Button-module__variant_subtle___BMbbd", "variant_text": "Button-module__variant_text___Pc5Ia", "variant_link": "Button-module__variant_link___Cj1O9", "disabled": "Button-module__disabled___nwPn4", "type_secondary": "Button-module__type_secondary___CLmrA", "type_critical": "Button-module__type_critical___6ILOp", "onHoverUnderline": "Button-module__onHoverUnderline___LOfXo" };
389
+
390
+ // src/atom/Button/Button.tsx
391
+ var import_jsx_runtime3 = require("react/jsx-runtime");
392
+ function Button(props) {
393
+ const {
394
+ type = "primary",
395
+ variant = "default",
396
+ size = "normal",
397
+ shape = "default",
398
+ className = "",
399
+ icon = null,
400
+ children,
401
+ onClick,
402
+ href = "",
403
+ disabled = false,
404
+ loading = false,
405
+ onHoverUnderline = false
406
+ } = props;
407
+ const buttonMap = {
408
+ default: "primary",
409
+ subtle: "default",
410
+ text: "text",
411
+ link: "link"
412
+ };
413
+ const sizeMap = {
414
+ small: "small",
415
+ normal: "middle",
416
+ // Map "default" to "middle"
417
+ large: "large"
418
+ };
419
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
420
+ import_antd.Button,
421
+ {
422
+ className: (0, import_clsx.default)(
423
+ Button_module_default.button,
424
+ Button_module_default[`size_${size}`],
425
+ Button_module_default[`variant_${variant}`],
426
+ Button_module_default[`shape_${shape}`],
427
+ Button_module_default[`type_${type}`],
428
+ `size_${size}`,
429
+ `variant_${variant}`,
430
+ `shape_${shape}`,
431
+ `type_${type}`,
432
+ className,
433
+ {
434
+ "tw-cursor-not-allowed": disabled,
435
+ "tw-opacity-40": disabled
436
+ },
437
+ disabled && Button_module_default.disabled,
438
+ onHoverUnderline && Button_module_default.onHoverUnderline
439
+ ),
440
+ "data-testid": "lumina-button",
441
+ disabled,
442
+ href: href || void 0,
443
+ icon,
444
+ loading,
445
+ onClick,
446
+ shape,
447
+ size: sizeMap[size],
448
+ type: buttonMap[variant],
449
+ children
450
+ }
451
+ );
452
+ }
453
+ Button.displayName = "Button";
454
+ var Button_default = Button;
455
+
456
+ // src/atom/Select/Select.tsx
457
+ var import_react3 = require("react");
458
+ var import_clsx2 = __toESM(require("clsx"));
459
+
460
+ // src/icons/Chevron.tsx
461
+ var React2 = __toESM(require("react"));
462
+ var import_jsx_runtime4 = require("react/jsx-runtime");
463
+ var Chevron2 = React2.memo(
464
+ (_a) => {
465
+ var _b = _a, { size = 16, color = "#6b7280", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
466
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
467
+ "svg",
468
+ __spreadProps(__spreadValues({
469
+ xmlns: "http://www.w3.org/2000/svg",
470
+ width: size,
471
+ height: size,
472
+ fill: "none",
473
+ viewBox: "0 0 16 16",
474
+ className
475
+ }, rest), {
476
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
477
+ "path",
478
+ {
479
+ fill: color,
480
+ 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"
481
+ }
482
+ )
483
+ })
484
+ );
485
+ }
486
+ );
487
+ Chevron2.displayName = "Chevron";
488
+
489
+ // src/icons/CrossV2.tsx
490
+ var React3 = __toESM(require("react"));
491
+ var import_jsx_runtime5 = require("react/jsx-runtime");
492
+ var CrossV2 = React3.memo(
493
+ (_a) => {
494
+ var _b = _a, { size = 16, color = "#111827", className } = _b, rest = __objRest(_b, ["size", "color", "className"]);
495
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
496
+ "svg",
497
+ __spreadProps(__spreadValues({
498
+ xmlns: "http://www.w3.org/2000/svg",
499
+ width: size,
500
+ height: size,
501
+ fill: "none",
502
+ viewBox: "0 0 20 20"
503
+ }, rest), {
504
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
505
+ "path",
506
+ {
507
+ fill: color,
508
+ 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"
509
+ }
510
+ )
511
+ })
512
+ );
513
+ }
514
+ );
515
+ CrossV2.displayName = "CrossV2";
516
+
517
+ // src/icons/Lock.tsx
518
+ var import_react2 = __toESM(require("react"));
519
+ var import_jsx_runtime6 = require("react/jsx-runtime");
520
+ var Lock = import_react2.default.memo((_a) => {
521
+ var _b = _a, { size = 16, color = "#000" } = _b, rest = __objRest(_b, ["size", "color"]);
522
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
523
+ "svg",
524
+ __spreadProps(__spreadValues({
525
+ xmlns: "http://www.w3.org/2000/svg",
526
+ width: size,
527
+ height: size,
528
+ fill: "none",
529
+ viewBox: "0 0 16 16"
530
+ }, rest), {
531
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
532
+ "path",
533
+ {
534
+ fill: color,
535
+ 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"
536
+ }
537
+ )
538
+ })
539
+ );
540
+ });
541
+
542
+ // src/atom/Tooltip/Tooltip.tsx
543
+ var import_antd2 = require("antd");
544
+
545
+ // src/atom/Tooltip/Tooltip.module.scss
546
+ var Tooltip_module_default = { "light": "Tooltip-module__light___H5oCc" };
547
+
548
+ // src/atom/Tooltip/Tooltip.tsx
549
+ var import_jsx_runtime7 = require("react/jsx-runtime");
550
+ var Tooltip = (_a) => {
551
+ var _b = _a, {
552
+ children,
553
+ title = "",
554
+ placement = "top",
555
+ color = "#1F2937",
556
+ className,
557
+ mode = "dark"
558
+ } = _b, rest = __objRest(_b, [
559
+ "children",
560
+ "title",
561
+ "placement",
562
+ "color",
563
+ "className",
564
+ "mode"
565
+ ]);
566
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
567
+ import_antd2.Tooltip,
568
+ __spreadProps(__spreadValues({
569
+ className,
570
+ color,
571
+ title,
572
+ placement,
573
+ overlayClassName: mode === "light" ? Tooltip_module_default.light : ""
574
+ }, rest), {
575
+ children
576
+ })
577
+ );
578
+ };
579
+ Tooltip.displayName = "Tooltip";
580
+ var Tooltip_default = Tooltip;
581
+
582
+ // src/atom/LoadingSpinner/LoadingSpinner.tsx
583
+ var import_icons = require("@ant-design/icons");
584
+ var import_antd3 = require("antd");
585
+
586
+ // src/atom/LoadingSpinner/LoadingSpinner.module.scss
587
+ var LoadingSpinner_module_default = { "spinnerContainer": "LoadingSpinner-module__spinnerContainer___DiPLf" };
588
+
589
+ // src/atom/LoadingSpinner/LoadingSpinner.tsx
590
+ var import_jsx_runtime8 = require("react/jsx-runtime");
591
+ var sizeMapping = {
592
+ xs: 16,
593
+ small: 24,
594
+ medium: 36,
595
+ large: 48
596
+ };
597
+ var LoadingSpinner = (_a) => {
598
+ var _b = _a, { size = "small", color = "#ec5d25" } = _b, rest = __objRest(_b, ["size", "color"]);
599
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", __spreadProps(__spreadValues({ className: LoadingSpinner_module_default.spinnerContainer }, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
600
+ import_antd3.Spin,
601
+ {
602
+ indicator: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
603
+ import_icons.LoadingOutlined,
604
+ {
605
+ style: { fontSize: sizeMapping[size], color },
606
+ spin: true
607
+ }
608
+ )
609
+ }
610
+ ) }));
611
+ };
612
+ LoadingSpinner.displayName = "LoadingSpinner";
613
+ var LoadingSpinner_default = LoadingSpinner;
614
+
615
+ // src/atom/Select/Select.tsx
616
+ var import_jsx_runtime9 = require("react/jsx-runtime");
617
+ var InputWrapper = (0, import_react3.memo)(({ children, disabled, disabledTooltip }) => {
618
+ if (disabled && disabledTooltip)
619
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Tooltip_default, { title: disabledTooltip, children });
620
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
621
+ });
622
+ var OptionItem = (0, import_react3.memo)(({
623
+ option,
624
+ index,
625
+ isSelected,
626
+ isHighlighted,
627
+ experience,
628
+ size,
629
+ optionClassName,
630
+ onSelectHandler,
631
+ onMouseEnterHandler
632
+ }) => {
633
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
634
+ "div",
635
+ {
636
+ onClick: () => onSelectHandler(option),
637
+ onMouseEnter: () => onMouseEnterHandler(index),
638
+ className: (0, import_clsx2.default)(
639
+ "tw-transition-all tw-duration-150",
640
+ { "tw-typography-body2": size !== "small" },
641
+ { "tw-typography-caption1": size === "small" },
642
+ optionClassName
643
+ ),
644
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
645
+ "div",
646
+ {
647
+ className: (0, import_clsx2.default)(
648
+ "tw-px-4 tw-cursor-pointer tw-py-2 tw-mx-0.5 tw-rounded-xl",
649
+ 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]"
650
+ ),
651
+ children: option.label
652
+ }
653
+ )
654
+ }
655
+ );
656
+ });
657
+ var Select = ({
658
+ label,
659
+ mandatory = false,
660
+ error = false,
661
+ options = [],
662
+ valueSelected = "",
663
+ // Keep for backward compatibility
664
+ value: _valueProp,
665
+ // Rename to avoid potential conflicts with native value attribute
666
+ onChange,
667
+ onSearch,
668
+ isLoading = false,
669
+ disabled = false,
670
+ disabledTooltip = "",
671
+ className = "",
672
+ dropdownClassName = "",
673
+ optionClassName = "",
674
+ style = {},
675
+ showDisplayValue = false,
676
+ // New prop to show displayValue instead of label
677
+ allowClear = true,
678
+ enableSearch = true,
679
+ doubleCharSearch = false,
680
+ id,
681
+ name,
682
+ tabIndex,
683
+ // Add tabIndex prop
684
+ // Additional styling props
685
+ size = "default",
686
+ // 'small', 'default', 'large'
687
+ variant = "default",
688
+ // 'default', 'filled', 'outlined'
689
+ wrapperClassName = "",
690
+ inputClassName = "",
691
+ // Custom class for input element specifically
692
+ labelClassName = "",
693
+ // Custom class for label element specifically
694
+ height = "tw-h-12",
695
+ // Custom height
696
+ experience = "business"
697
+ }) => {
698
+ const normalizeValue = (0, import_react3.useCallback)(
699
+ (val) => {
700
+ if (val === null || val === void 0) return "";
701
+ return String(val);
702
+ },
703
+ []
704
+ );
705
+ const validatedOptions = (0, import_react3.useMemo)(() => {
706
+ if (!Array.isArray(options)) return [];
707
+ return options.filter(
708
+ (opt) => opt && typeof opt === "object" && opt.value !== void 0 && opt.value !== null && opt.label !== void 0
709
+ );
710
+ }, [options]);
711
+ const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
712
+ const [isFocused, setIsFocused] = (0, import_react3.useState)(false);
713
+ const [searchTerm, setSearchTerm] = (0, import_react3.useState)("");
714
+ const [isHovering, setIsHovering] = (0, import_react3.useState)(false);
715
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react3.useState)(-1);
716
+ const [selectedValue, setSelectedValue] = (0, import_react3.useState)(() => {
717
+ const initialValue = valueSelected;
718
+ if (initialValue === null || initialValue === void 0) return "";
719
+ return String(initialValue);
720
+ });
721
+ const inputRef = (0, import_react3.useRef)(null);
722
+ const inputValueRef = (0, import_react3.useRef)("");
723
+ const dropdownRef = (0, import_react3.useRef)(null);
724
+ const optionRefs = (0, import_react3.useRef)([]);
725
+ const optionListRef = (0, import_react3.useRef)(null);
726
+ const blurTimeoutRef = (0, import_react3.useRef)(null);
727
+ const hoverTimeoutRef = (0, import_react3.useRef)(null);
728
+ const isActive = isFocused || Boolean(selectedValue) || Boolean(valueSelected) || Boolean(searchTerm);
729
+ const sizeClasses = (0, import_react3.useMemo)(() => {
730
+ switch (size) {
731
+ case "small":
732
+ return {
733
+ input: "tw-h-6 tw-typography-caption1Bold !tw-rounded-lg",
734
+ padding: "tw-px-2 tw-py-1",
735
+ labelActive: "tw-top-0.5 tw-typography-caption2",
736
+ labelInactive: "tw-top-1.5 tw-typography-caption3"
737
+ };
738
+ case "medium":
739
+ return {
740
+ input: "tw-h-10 tw-px-4 tw-typography-body2",
741
+ padding: label ? "tw-pt-4 tw-pb-1" : "tw-py-2",
742
+ labelActive: "tw-top-1 tw-typography-caption3",
743
+ labelInactive: "tw-top-2.5 tw-typography-body2"
744
+ };
745
+ case "large":
746
+ return {
747
+ input: "tw-h-16 tw-px-5 tw-typography-bodyLarge",
748
+ padding: label ? "tw-pt-8 tw-pb-4" : "tw-py-5",
749
+ labelActive: "tw-top-1 tw-typography-caption2",
750
+ labelInactive: "tw-top-5 tw-typography-body1"
751
+ };
752
+ default:
753
+ return {
754
+ input: height + " tw-px-4 tw-typography-bodyLarge",
755
+ padding: label ? "tw-pt-6 tw-pb-3" : "tw-py-3",
756
+ labelActive: "tw-top-1 tw-typography-caption3",
757
+ labelInactive: "tw-top-3.5 tw-typography-body2"
758
+ };
759
+ }
760
+ }, [size, label, height]);
761
+ const variantClasses = (0, import_react3.useMemo)(() => {
762
+ switch (variant) {
763
+ case "filled":
764
+ return "tw-bg-gray-50 tw-border-transparent";
765
+ case "outlined":
766
+ return "tw-bg-transparent tw-border-2";
767
+ default:
768
+ return " tw-border";
769
+ }
770
+ }, [variant]);
771
+ const handleBlur = (0, import_react3.useCallback)(() => {
772
+ blurTimeoutRef.current = setTimeout(() => {
773
+ setIsOpen(false);
774
+ setSearchTerm("");
775
+ setHighlightedIndex(-1);
776
+ blurTimeoutRef.current = null;
777
+ setIsFocused(false);
778
+ }, 150);
779
+ }, []);
780
+ const handleSearchChange = (0, import_react3.useCallback)(
781
+ (e) => {
782
+ var _a;
783
+ const searchValue = doubleCharSearch ? e.target.value.slice(0, 2) || "" : e.target.value;
784
+ if (doubleCharSearch) {
785
+ setSearchTerm(searchValue);
786
+ } else {
787
+ setSearchTerm(searchValue);
788
+ }
789
+ setIsOpen(true);
790
+ setHighlightedIndex(-1);
791
+ if (onSearch && typeof onSearch === "function") {
792
+ onSearch(searchValue);
793
+ }
794
+ (_a = optionListRef == null ? void 0 : optionListRef.current) == null ? void 0 : _a.scrollTo({
795
+ top: 0,
796
+ behavior: "smooth"
797
+ });
798
+ },
799
+ [doubleCharSearch, onSearch]
800
+ );
801
+ const handleOptionSelect = (0, import_react3.useCallback)(
802
+ (option) => {
803
+ var _a;
804
+ if (blurTimeoutRef.current) {
805
+ clearTimeout(blurTimeoutRef.current);
806
+ blurTimeoutRef.current = null;
807
+ }
808
+ inputValueRef.current = option.label;
809
+ const normalizedValue = normalizeValue(option.value);
810
+ setSelectedValue(normalizedValue);
811
+ setSearchTerm("");
812
+ setIsOpen(false);
813
+ if (enableSearch) {
814
+ setIsFocused(false);
815
+ }
816
+ setIsHovering(false);
817
+ if (onChange) onChange(option.value);
818
+ if (enableSearch) (_a = inputRef.current) == null ? void 0 : _a.blur();
819
+ },
820
+ [normalizeValue, onChange, enableSearch]
821
+ );
822
+ const handleClear = (0, import_react3.useCallback)(
823
+ (e) => {
824
+ var _a;
825
+ inputValueRef.current = "";
826
+ e.stopPropagation();
827
+ e.preventDefault();
828
+ setSelectedValue("");
829
+ setSearchTerm("");
830
+ if (enableSearch) {
831
+ setIsOpen(true);
832
+ setIsFocused(true);
833
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
834
+ } else {
835
+ setIsOpen(false);
836
+ setIsFocused(false);
837
+ }
838
+ if (onChange) onChange(null);
839
+ },
840
+ [onChange, enableSearch]
841
+ );
842
+ (0, import_react3.useEffect)(() => {
843
+ if (!validatedOptions.length) {
844
+ setSelectedValue("");
845
+ setSearchTerm("");
846
+ inputValueRef.current = "";
847
+ }
848
+ }, [validatedOptions.length]);
849
+ (0, import_react3.useEffect)(() => {
850
+ const externalValue = _valueProp !== void 0 ? _valueProp : valueSelected;
851
+ const newValue = normalizeValue(externalValue);
852
+ setSelectedValue((prevValue) => {
853
+ const prevNormalized = normalizeValue(prevValue);
854
+ return prevNormalized !== newValue ? newValue : prevValue;
855
+ });
856
+ }, [valueSelected, _valueProp, normalizeValue]);
857
+ (0, import_react3.useEffect)(() => {
858
+ const handleClickOutside = (event) => {
859
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
860
+ if (blurTimeoutRef.current) {
861
+ clearTimeout(blurTimeoutRef.current);
862
+ blurTimeoutRef.current = null;
863
+ }
864
+ setIsOpen(false);
865
+ setIsFocused(false);
866
+ setSearchTerm("");
867
+ setHighlightedIndex(-1);
868
+ }
869
+ };
870
+ document.addEventListener("mousedown", handleClickOutside);
871
+ return () => {
872
+ document.removeEventListener("mousedown", handleClickOutside);
873
+ if (blurTimeoutRef.current) {
874
+ clearTimeout(blurTimeoutRef.current);
875
+ }
876
+ if (hoverTimeoutRef.current) {
877
+ clearTimeout(hoverTimeoutRef.current);
878
+ }
879
+ };
880
+ }, []);
881
+ const getDisplayValue = (0, import_react3.useCallback)(() => {
882
+ if (selectedValue && (validatedOptions == null ? void 0 : validatedOptions.length) > 0) {
883
+ const selected = validatedOptions.find(
884
+ (opt) => normalizeValue(opt.value) === normalizeValue(selectedValue)
885
+ );
886
+ if (selected) {
887
+ return showDisplayValue && selected.displayValue ? selected.displayValue : selected.label;
888
+ }
889
+ }
890
+ if (selectedValue && (!validatedOptions || validatedOptions.length === 0)) {
891
+ return selectedValue;
892
+ }
893
+ return "";
894
+ }, [selectedValue, validatedOptions, showDisplayValue, normalizeValue]);
895
+ const displayValue = (0, import_react3.useMemo)(() => getDisplayValue(), [getDisplayValue]);
896
+ const inputClasses = (0, import_react3.useMemo)(() => {
897
+ return (0, import_clsx2.default)(
898
+ "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",
899
+ sizeClasses.input,
900
+ sizeClasses.padding,
901
+ variantClasses,
902
+ {
903
+ "tw-bg-white": valueSelected || displayValue || isFocused,
904
+ "tw-bg-color-gray-5": !valueSelected || !displayValue,
905
+ "!tw-bg-[#F8F7F6] tw-cursor-not-allowed tw-pointer-events-none": disabled
906
+ },
907
+ !label && "tw-flex tw-items-center",
908
+ {
909
+ "!tw-border-color-primary": isFocused && experience === "business"
910
+ },
911
+ {
912
+ "!tw-border-[#804D7B]": isFocused && experience === "personal"
913
+ },
914
+ error ? "!tw-border-color-text-critical " : "tw-border-[#EBE3DD] hover:tw-border-[#C5B7AC]",
915
+ "focus:tw-shadow-sm focus:tw-ring-offset-1",
916
+ className,
917
+ inputClassName
918
+ );
919
+ }, [sizeClasses, variantClasses, valueSelected, displayValue, isFocused, disabled, label, experience, error, className, inputClassName]);
920
+ const filteredOptions = (0, import_react3.useMemo)(() => {
921
+ var _a;
922
+ if (!enableSearch) {
923
+ return validatedOptions;
924
+ }
925
+ (_a = dropdownRef.current) == null ? void 0 : _a.scrollTo(0, 0);
926
+ const updatedFilteredOptions = validatedOptions.filter((option) => {
927
+ var _a2;
928
+ return (_a2 = option == null ? void 0 : option.label) == null ? void 0 : _a2.toLowerCase().includes(searchTerm == null ? void 0 : searchTerm.toLowerCase());
929
+ });
930
+ return updatedFilteredOptions;
931
+ }, [validatedOptions, searchTerm, enableSearch]);
932
+ const getSelectedOptionIndex = (0, import_react3.useCallback)(() => {
933
+ if (!selectedValue || !filteredOptions.length) {
934
+ return 0;
935
+ }
936
+ const index = filteredOptions.findIndex(
937
+ (option) => normalizeValue(option.value) === normalizeValue(selectedValue)
938
+ );
939
+ return index >= 0 ? index : 0;
940
+ }, [selectedValue, filteredOptions, normalizeValue]);
941
+ const handleInputInteraction = (0, import_react3.useCallback)(
942
+ (_e) => {
943
+ var _a;
944
+ if (blurTimeoutRef.current) {
945
+ clearTimeout(blurTimeoutRef.current);
946
+ blurTimeoutRef.current = null;
947
+ }
948
+ if (isOpen) {
949
+ setIsOpen(false);
950
+ setIsFocused(false);
951
+ setSearchTerm("");
952
+ setHighlightedIndex(-1);
953
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
954
+ return;
955
+ }
956
+ setIsFocused(true);
957
+ setIsOpen(true);
958
+ setHighlightedIndex(getSelectedOptionIndex());
959
+ if (inputRef.current) {
960
+ inputRef.current.focus();
961
+ }
962
+ },
963
+ [isOpen, getSelectedOptionIndex]
964
+ );
965
+ const handleKeyDown = (0, import_react3.useCallback)(
966
+ (e) => {
967
+ var _a;
968
+ if (!isOpen) return;
969
+ switch (e.key) {
970
+ case "ArrowDown":
971
+ e.preventDefault();
972
+ setHighlightedIndex((prev) => {
973
+ const nextIndex = prev < filteredOptions.length - 1 ? prev + 1 : prev;
974
+ return nextIndex;
975
+ });
976
+ break;
977
+ case "ArrowUp":
978
+ e.preventDefault();
979
+ setHighlightedIndex((prev) => {
980
+ const nextIndex = prev > 0 ? prev - 1 : prev;
981
+ return nextIndex;
982
+ });
983
+ break;
984
+ case "Enter":
985
+ e.preventDefault();
986
+ if (highlightedIndex >= 0 && filteredOptions[highlightedIndex]) {
987
+ handleOptionSelect(filteredOptions[highlightedIndex]);
988
+ }
989
+ break;
990
+ case "Escape":
991
+ e.preventDefault();
992
+ setIsOpen(false);
993
+ setIsFocused(false);
994
+ setSearchTerm("");
995
+ setHighlightedIndex(-1);
996
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
997
+ break;
998
+ default:
999
+ break;
1000
+ }
1001
+ },
1002
+ [isOpen, highlightedIndex, filteredOptions, handleOptionSelect]
1003
+ );
1004
+ (0, import_react3.useEffect)(() => {
1005
+ if (highlightedIndex >= 0 && optionRefs.current[highlightedIndex]) {
1006
+ optionRefs.current[highlightedIndex].scrollIntoView({
1007
+ block: "nearest",
1008
+ behavior: "smooth"
1009
+ });
1010
+ }
1011
+ }, [highlightedIndex]);
1012
+ (0, import_react3.useEffect)(() => {
1013
+ optionRefs.current = [];
1014
+ }, [filteredOptions.length]);
1015
+ const handleMouseEnter = (0, import_react3.useCallback)(() => {
1016
+ if (hoverTimeoutRef.current) {
1017
+ clearTimeout(hoverTimeoutRef.current);
1018
+ }
1019
+ if (!isHovering) {
1020
+ setIsHovering(true);
1021
+ }
1022
+ }, [isHovering]);
1023
+ const handleMouseLeave = (0, import_react3.useCallback)(() => {
1024
+ hoverTimeoutRef.current = setTimeout(() => {
1025
+ setIsHovering(false);
1026
+ }, 50);
1027
+ }, []);
1028
+ const handleChevronClick = (0, import_react3.useCallback)(
1029
+ (e) => {
1030
+ var _a;
1031
+ e.preventDefault();
1032
+ if (blurTimeoutRef.current) {
1033
+ clearTimeout(blurTimeoutRef.current);
1034
+ blurTimeoutRef.current = null;
1035
+ }
1036
+ if (isOpen) {
1037
+ setIsOpen(false);
1038
+ setIsFocused(false);
1039
+ setSearchTerm("");
1040
+ setHighlightedIndex(-1);
1041
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
1042
+ } else {
1043
+ if (inputRef.current) {
1044
+ inputRef.current.focus();
1045
+ }
1046
+ handleInputInteraction();
1047
+ }
1048
+ },
1049
+ [isOpen, handleInputInteraction]
1050
+ );
1051
+ const handleChevronMouseDown = (0, import_react3.useCallback)(
1052
+ (e) => {
1053
+ if (isHovering && selectedValue && allowClear) {
1054
+ handleClear(e);
1055
+ } else {
1056
+ handleChevronClick(e);
1057
+ }
1058
+ },
1059
+ [isHovering, selectedValue, allowClear, handleClear, handleChevronClick]
1060
+ );
1061
+ const handleOptionClick = (0, import_react3.useCallback)((option) => {
1062
+ handleOptionSelect(option);
1063
+ }, [handleOptionSelect]);
1064
+ const handleOptionMouseEnter = (0, import_react3.useCallback)((index) => {
1065
+ setHighlightedIndex(index);
1066
+ }, []);
1067
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InputWrapper, { disabled, disabledTooltip, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1068
+ "div",
1069
+ {
1070
+ style,
1071
+ className: (0, import_clsx2.default)("tw-relative tw-w-full", wrapperClassName, {
1072
+ "tw-cursor-not-allowed": disabled
1073
+ }),
1074
+ ref: dropdownRef,
1075
+ onMouseEnter: handleMouseEnter,
1076
+ onMouseLeave: handleMouseLeave,
1077
+ children: [
1078
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "tw-relative", children: [
1079
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1080
+ "input",
1081
+ {
1082
+ ref: inputRef,
1083
+ type: "text",
1084
+ id,
1085
+ name,
1086
+ tabIndex,
1087
+ autoComplete: "off",
1088
+ autoCorrect: "off",
1089
+ autoCapitalize: "off",
1090
+ spellCheck: "false",
1091
+ value: isFocused && enableSearch ? searchTerm : displayValue,
1092
+ onChange: enableSearch ? handleSearchChange : void 0,
1093
+ onClick: handleInputInteraction,
1094
+ onKeyDown: handleKeyDown,
1095
+ className: inputClasses,
1096
+ readOnly: !isFocused || !enableSearch
1097
+ }
1098
+ ),
1099
+ label && size !== "small" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1100
+ "label",
1101
+ {
1102
+ htmlFor: id,
1103
+ className: (0, import_clsx2.default)(
1104
+ "tw-absolute tw-left-[18px] tw-pointer-events-none tw-transition-all tw-duration-200 tw-ease-out tw-text-gray-500",
1105
+ isActive ? sizeClasses.labelActive : sizeClasses.labelInactive,
1106
+ error && "tw-text-color-text-critical",
1107
+ labelClassName
1108
+ ),
1109
+ children: [
1110
+ label,
1111
+ mandatory && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "tw-text-color-text-critical tw-ml-1", children: "*" })
1112
+ ]
1113
+ }
1114
+ ),
1115
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1116
+ "div",
1117
+ {
1118
+ className: (0, import_clsx2.default)(
1119
+ "tw-absolute tw-right-3 tw--translate-y-1/2 tw-flex tw-items-center",
1120
+ {
1121
+ "!tw-right-[5px]": doubleCharSearch && !(isHovering && selectedValue && allowClear),
1122
+ "tw-top-3 !tw-right-2": size === "small",
1123
+ "tw-top-1/2": size !== "small"
1124
+ }
1125
+ ),
1126
+ children: [
1127
+ disabled && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "tw-absolute tw-right-0 -tw-top-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Lock, { size: 16 }) }),
1128
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LoadingSpinner_default, { size: "xs" }) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1129
+ "div",
1130
+ {
1131
+ className: (0, import_clsx2.default)(
1132
+ "tw-transition-all tw-duration-200 tw-cursor-pointer tw-flex tw-items-center",
1133
+ // Only rotate chevron when open and not showing clear icon
1134
+ isOpen && !(isHovering && selectedValue && allowClear) && "-tw-rotate-180"
1135
+ ),
1136
+ onMouseDown: handleChevronMouseDown,
1137
+ children: disabled ? null : isHovering && selectedValue && allowClear ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1138
+ CrossV2,
1139
+ {
1140
+ color: "#111827",
1141
+ className: (0, import_clsx2.default)({ "tw-mr-1": size !== "small" }),
1142
+ size: size === "small" ? 12 : 16
1143
+ }
1144
+ ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1145
+ Chevron2,
1146
+ {
1147
+ className: (0, import_clsx2.default)("tw-text-gray-400"),
1148
+ color: "#6B7280"
1149
+ }
1150
+ )
1151
+ }
1152
+ )
1153
+ ]
1154
+ }
1155
+ )
1156
+ ] }),
1157
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1158
+ "div",
1159
+ {
1160
+ className: (0, import_clsx2.default)(
1161
+ "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",
1162
+ { "tw-max-h-60": !doubleCharSearch },
1163
+ { "tw-max-h-44": doubleCharSearch },
1164
+ dropdownClassName
1165
+ ),
1166
+ ref: optionListRef,
1167
+ children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => {
1168
+ const isSelected = normalizeValue(selectedValue) === normalizeValue(option.value);
1169
+ const isHighlighted = index === highlightedIndex;
1170
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: (el) => optionRefs.current[index] = el, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1171
+ OptionItem,
1172
+ {
1173
+ option,
1174
+ index,
1175
+ isSelected,
1176
+ isHighlighted,
1177
+ experience,
1178
+ size,
1179
+ optionClassName,
1180
+ onSelectHandler: handleOptionClick,
1181
+ onMouseEnterHandler: handleOptionMouseEnter
1182
+ }
1183
+ ) }, doubleCharSearch ? option.label : option.value);
1184
+ }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "tw-px-4 tw-py-3 tw-text-gray-500 tw-text-sm", children: "No options found" })
1185
+ }
1186
+ )
1187
+ ]
1188
+ }
1189
+ ) });
1190
+ };
1191
+ Select.displayName = "Select";
1192
+ var Select_default = Select;
1193
+
1194
+ // src/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.tsx
1195
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1196
+ import_dayjs2.default.extend(import_customParseFormat.default);
1197
+ import_dayjs2.default.extend(import_isSameOrBefore.default);
1198
+ var DEFAULT_TIME = { hour: "12", minute: "00", period: "PM" };
1199
+ function getPresets() {
1200
+ const today = /* @__PURE__ */ new Date();
1201
+ today.setHours(0, 0, 0, 0);
1202
+ return [
1203
+ {
1204
+ label: "Custom",
1205
+ key: "custom",
1206
+ getRange: () => [null, null]
1207
+ },
1208
+ {
1209
+ label: "Yesterday",
1210
+ key: "yesterday",
1211
+ getRange: () => {
1212
+ const d = new Date(today);
1213
+ d.setDate(d.getDate() - 1);
1214
+ return [d, d];
1215
+ }
1216
+ },
1217
+ {
1218
+ label: "Previous week",
1219
+ key: "previous-week",
1220
+ getRange: () => {
1221
+ const dayOfWeek = today.getDay();
1222
+ const start = new Date(today);
1223
+ start.setDate(today.getDate() - dayOfWeek - 6);
1224
+ const end = new Date(today);
1225
+ return [start, end];
1226
+ }
1227
+ },
1228
+ {
1229
+ label: "This month",
1230
+ key: "this-month",
1231
+ getRange: () => {
1232
+ const start = new Date(today.getFullYear(), today.getMonth(), 1);
1233
+ const end = new Date(today.getFullYear(), today.getMonth() + 1, 0);
1234
+ return [start, end];
1235
+ }
1236
+ },
1237
+ {
1238
+ label: "Previous month",
1239
+ key: "previous-month",
1240
+ getRange: () => {
1241
+ const start = new Date(today.getFullYear(), today.getMonth() - 1, 1);
1242
+ const end = new Date(today.getFullYear(), today.getMonth(), 0);
1243
+ return [start, end];
1244
+ }
1245
+ },
1246
+ {
1247
+ label: "Previous quarter",
1248
+ key: "previous-quarter",
1249
+ getRange: () => {
1250
+ const month = today.getMonth();
1251
+ const quarter = Math.floor(month / 3);
1252
+ const startMonth = (quarter - 1) * 3;
1253
+ const start = new Date(today.getFullYear(), startMonth, 1);
1254
+ const end = new Date(today.getFullYear(), startMonth + 3, 0);
1255
+ return [start, end];
1256
+ }
1257
+ }
1258
+ ];
1259
+ }
1260
+ function applyDateMask(v, prev) {
1261
+ if (v.length < prev.length) return v;
1262
+ const digits = v.replace(/[^\d]/g, "").slice(0, 8);
1263
+ if (digits.length >= 2) {
1264
+ const d = Number(digits.slice(0, 2));
1265
+ if (d < 1 || d > 31) return prev;
1266
+ }
1267
+ if (digits.length >= 4) {
1268
+ const m = Number(digits.slice(2, 4));
1269
+ if (m < 1 || m > 12) return prev;
1270
+ }
1271
+ let result = "";
1272
+ if (digits.length > 0) result += digits.slice(0, 2);
1273
+ if (digits.length >= 2) result += "-";
1274
+ if (digits.length > 2) result += digits.slice(2, 4);
1275
+ if (digits.length >= 4) result += "-";
1276
+ if (digits.length > 4) result += digits.slice(4, 8);
1277
+ return result.slice(0, 10);
1278
+ }
1279
+ function applyTimeMask(v, prev) {
1280
+ if (v.length < prev.length) return v;
1281
+ const digits = v.replace(/[^\d]/g, "").slice(0, 4);
1282
+ if (digits.length >= 2) {
1283
+ const h = Number(digits.slice(0, 2));
1284
+ if (h < 1 || h > 12) return prev;
1285
+ }
1286
+ if (digits.length >= 4) {
1287
+ const m = Number(digits.slice(2, 4));
1288
+ if (m > 59) return prev;
1289
+ }
1290
+ let result = "";
1291
+ if (digits.length > 0) result += digits.slice(0, 2);
1292
+ if (digits.length >= 2) result += ":";
1293
+ if (digits.length > 2) result += digits.slice(2, 4);
1294
+ if (v.toUpperCase().includes("A")) result += " AM";
1295
+ else if (v.toUpperCase().includes("P")) result += " PM";
1296
+ else if (digits.length === 4) result += " ";
1297
+ return result.slice(0, 8);
1298
+ }
1299
+ function formatForDisplay(date) {
1300
+ if (!date) return "";
1301
+ return (0, import_dayjs2.default)(date).format("DD-MM-YYYY");
1302
+ }
1303
+ function validateDateString(raw) {
1304
+ const regex = /^(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[0-2])-\d{4}$/;
1305
+ if (!regex.test(raw)) return false;
1306
+ const [d, m, y] = raw.split("-").map(Number);
1307
+ const date = new Date(y, m - 1, d);
1308
+ return date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
1309
+ }
1310
+ function validateTimeString(raw) {
1311
+ const regex = /^(0[1-9]|1[0-2]):(0[0-9]|[1-5][0-9])\s(AM|PM)$/i;
1312
+ return regex.test(raw);
1313
+ }
1314
+ function parseDateInput(raw) {
1315
+ if (!validateDateString(raw)) return null;
1316
+ return (0, import_dayjs2.default)(raw, "DD-MM-YYYY", true).toDate();
1317
+ }
1318
+ function parseTimeInput(raw) {
1319
+ if (!validateTimeString(raw)) return null;
1320
+ const match = raw.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);
1321
+ if (!match) return null;
1322
+ return {
1323
+ hour: match[1].padStart(2, "0"),
1324
+ minute: match[2].padStart(2, "0"),
1325
+ period: match[3].toUpperCase()
1326
+ };
1327
+ }
1328
+ function formatTime(t) {
1329
+ return `${t.hour}:${t.minute} ${t.period}`;
1330
+ }
1331
+ var DateTimeInputGroup = (0, import_react4.memo)(function DateTimeInputGroup2({
1332
+ label,
1333
+ dateValue,
1334
+ timeValue,
1335
+ dateError,
1336
+ timeError,
1337
+ onDateChange,
1338
+ onTimeChange
1339
+ }) {
1340
+ const [isDateFocused, setIsDateFocused] = (0, import_react4.useState)(false);
1341
+ const [isTimeFocused, setIsTimeFocused] = (0, import_react4.useState)(false);
1342
+ const showDateError = dateError && !isDateFocused;
1343
+ const showTimeError = timeError && !isTimeFocused;
1344
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.headerGroup, children: [
1345
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: AdvancedDateRangePicker_module_default.headerLabel, children: label }),
1346
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: AdvancedDateRangePicker_module_default.dateTimeColumn, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.dateTimeGroup, children: [
1347
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.inputWrapper, children: [
1348
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1349
+ "input",
1350
+ {
1351
+ type: "text",
1352
+ placeholder: "dd-mm-yyyy",
1353
+ value: dateValue,
1354
+ onFocus: () => setIsDateFocused(true),
1355
+ onBlur: () => setIsDateFocused(false),
1356
+ onChange: (e) => onDateChange(e.target.value),
1357
+ className: (0, import_clsx3.default)(AdvancedDateRangePicker_module_default.dateInput, { [AdvancedDateRangePicker_module_default.inputError]: showDateError })
1358
+ }
1359
+ ),
1360
+ showDateError && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: AdvancedDateRangePicker_module_default.errorMessage, children: "Enter valid date" })
1361
+ ] }),
1362
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.inputWrapper, children: [
1363
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1364
+ "input",
1365
+ {
1366
+ type: "text",
1367
+ placeholder: "12:00 PM",
1368
+ value: timeValue,
1369
+ onFocus: () => setIsTimeFocused(true),
1370
+ onBlur: () => setIsTimeFocused(false),
1371
+ onChange: (e) => onTimeChange(e.target.value),
1372
+ className: (0, import_clsx3.default)(AdvancedDateRangePicker_module_default.timeInput, { [AdvancedDateRangePicker_module_default.inputError]: showTimeError })
1373
+ }
1374
+ ),
1375
+ showTimeError && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: AdvancedDateRangePicker_module_default.errorMessage, children: "Enter valid time" })
1376
+ ] })
1377
+ ] }) })
1378
+ ] });
1379
+ });
1380
+ function AdvancedDateRangePicker({
1381
+ value,
1382
+ onChange,
1383
+ confirmLabel = "Done",
1384
+ className = "",
1385
+ disabled = false,
1386
+ disablePastDates = false,
1387
+ minDate = null,
1388
+ maxDate = null,
1389
+ showSingleCalendar = false,
1390
+ id = "adv-drp",
1391
+ defaultTimezone = "UTC",
1392
+ isTimezoneDisabled = false,
1393
+ timezoneOptions = [],
1394
+ defaultPreset = "custom"
1395
+ }) {
1396
+ var _a, _b, _c;
1397
+ const PRESETS = (0, import_react4.useMemo)(() => getPresets(), []);
1398
+ const [startDate, setStartDate] = (0, import_react4.useState)((_a = value == null ? void 0 : value.startDate) != null ? _a : null);
1399
+ const [endDate, setEndDate] = (0, import_react4.useState)((_b = value == null ? void 0 : value.endDate) != null ? _b : null);
1400
+ const [timezone, setTimezone] = (0, import_react4.useState)((_c = value == null ? void 0 : value.timezone) != null ? _c : defaultTimezone);
1401
+ const [fromDateStr, setFromDateStr] = (0, import_react4.useState)(formatForDisplay(startDate));
1402
+ const [toDateStr, setToDateStr] = (0, import_react4.useState)(formatForDisplay(endDate));
1403
+ const [fromTimeStr, setFromTimeStr] = (0, import_react4.useState)(
1404
+ (value == null ? void 0 : value.startTime) ? formatTime(value.startTime) : "12:00 PM"
1405
+ );
1406
+ const [toTimeStr, setToTimeStr] = (0, import_react4.useState)(
1407
+ (value == null ? void 0 : value.endTime) ? formatTime(value.endTime) : "12:00 PM"
1408
+ );
1409
+ const [activePreset, setActivePreset] = (0, import_react4.useState)(defaultPreset);
1410
+ const fromDateError = (0, import_react4.useMemo)(() => fromDateStr.length > 0 && (fromDateStr.length < 10 || !validateDateString(fromDateStr)), [fromDateStr]);
1411
+ const toDateError = (0, import_react4.useMemo)(() => toDateStr.length > 0 && (toDateStr.length < 10 || !validateDateString(toDateStr)), [toDateStr]);
1412
+ const fromTimeError = (0, import_react4.useMemo)(() => fromTimeStr.length > 0 && (fromTimeStr.length < 8 || !validateTimeString(fromTimeStr)), [fromTimeStr]);
1413
+ const toTimeError = (0, import_react4.useMemo)(() => toTimeStr.length > 0 && (toTimeStr.length < 8 || !validateTimeString(toTimeStr)), [toTimeStr]);
1414
+ const isReady = (0, import_react4.useMemo)(() => {
1415
+ return startDate !== null && endDate !== null && validateDateString(fromDateStr) && validateDateString(toDateStr) && validateTimeString(fromTimeStr) && validateTimeString(toTimeStr) && (0, import_dayjs2.default)(startDate).isSameOrBefore((0, import_dayjs2.default)(endDate), "day");
1416
+ }, [startDate, endDate, fromDateStr, toDateStr, fromTimeStr, toTimeStr]);
1417
+ (0, import_react4.useEffect)(() => {
1418
+ var _a2, _b2, _c2;
1419
+ if (value) {
1420
+ setStartDate((_a2 = value.startDate) != null ? _a2 : null);
1421
+ setEndDate((_b2 = value.endDate) != null ? _b2 : null);
1422
+ setTimezone((_c2 = value.timezone) != null ? _c2 : defaultTimezone);
1423
+ if (value.startTime) setFromTimeStr(formatTime(value.startTime));
1424
+ if (value.endTime) setToTimeStr(formatTime(value.endTime));
1425
+ }
1426
+ }, [value, defaultTimezone]);
1427
+ (0, import_react4.useEffect)(() => {
1428
+ setFromDateStr(formatForDisplay(startDate));
1429
+ }, [startDate]);
1430
+ (0, import_react4.useEffect)(() => {
1431
+ setToDateStr(formatForDisplay(endDate));
1432
+ }, [endDate]);
1433
+ const rangeValue = (0, import_react4.useMemo)(() => [
1434
+ startDate ? startDate.toISOString() : "",
1435
+ endDate ? endDate.toISOString() : ""
1436
+ ], [startDate, endDate]);
1437
+ const handleRangeChange = (0, import_react4.useCallback)(
1438
+ (range) => {
1439
+ const [s, e] = range;
1440
+ if (s) {
1441
+ const sDateByDayjs = (0, import_dayjs2.default)(s, "D MMM, YYYY").toDate();
1442
+ setStartDate(sDateByDayjs);
1443
+ } else {
1444
+ setStartDate(null);
1445
+ }
1446
+ if (e) {
1447
+ const eDateByDayjs = (0, import_dayjs2.default)(e, "D MMM, YYYY").toDate();
1448
+ setEndDate(eDateByDayjs);
1449
+ } else {
1450
+ setEndDate(null);
1451
+ }
1452
+ setActivePreset("custom");
1453
+ },
1454
+ []
1455
+ );
1456
+ const handlePreset = (0, import_react4.useCallback)(
1457
+ (preset) => {
1458
+ const [s, e] = preset.getRange();
1459
+ setStartDate(s);
1460
+ setEndDate(e);
1461
+ setActivePreset(preset.key);
1462
+ },
1463
+ []
1464
+ );
1465
+ const handleFromDateChange = (0, import_react4.useCallback)((v) => {
1466
+ const masked = applyDateMask(v, fromDateStr);
1467
+ setFromDateStr(masked);
1468
+ setActivePreset("custom");
1469
+ if (masked.length === 10) {
1470
+ const parsed = parseDateInput(masked);
1471
+ if (parsed) {
1472
+ setStartDate(parsed);
1473
+ if (endDate && (0, import_dayjs2.default)(parsed).isAfter((0, import_dayjs2.default)(endDate), "day")) {
1474
+ setEndDate(null);
1475
+ }
1476
+ }
1477
+ }
1478
+ }, [fromDateStr, endDate]);
1479
+ const handleToDateChange = (0, import_react4.useCallback)((v) => {
1480
+ const masked = applyDateMask(v, toDateStr);
1481
+ setToDateStr(masked);
1482
+ setActivePreset("custom");
1483
+ if (masked.length === 10) {
1484
+ const parsed = parseDateInput(masked);
1485
+ if (parsed) {
1486
+ setEndDate(parsed);
1487
+ if (startDate && (0, import_dayjs2.default)(parsed).isBefore((0, import_dayjs2.default)(startDate), "day")) {
1488
+ setStartDate(null);
1489
+ }
1490
+ }
1491
+ }
1492
+ }, [toDateStr, startDate]);
1493
+ const handleFromTimeChange = (0, import_react4.useCallback)((v) => {
1494
+ const masked = applyTimeMask(v, fromTimeStr);
1495
+ setFromTimeStr(masked);
1496
+ setActivePreset("custom");
1497
+ }, [fromTimeStr]);
1498
+ const handleToTimeChange = (0, import_react4.useCallback)((v) => {
1499
+ const masked = applyTimeMask(v, toTimeStr);
1500
+ setToTimeStr(masked);
1501
+ setActivePreset("custom");
1502
+ }, [toTimeStr]);
1503
+ const handleDone = (0, import_react4.useCallback)(() => {
1504
+ var _a2, _b2;
1505
+ if (!isReady) return;
1506
+ const fromTime = (_a2 = parseTimeInput(fromTimeStr)) != null ? _a2 : DEFAULT_TIME;
1507
+ const toTime = (_b2 = parseTimeInput(toTimeStr)) != null ? _b2 : DEFAULT_TIME;
1508
+ onChange == null ? void 0 : onChange({
1509
+ startDate,
1510
+ endDate,
1511
+ startTime: fromTime,
1512
+ endTime: toTime,
1513
+ timezone
1514
+ });
1515
+ }, [isReady, onChange, startDate, endDate, fromTimeStr, toTimeStr, timezone]);
1516
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: (0, import_clsx3.default)(AdvancedDateRangePicker_module_default.root, className), id, children: [
1517
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.inner, children: [
1518
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("aside", { className: AdvancedDateRangePicker_module_default.left, children: PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1519
+ "button",
1520
+ {
1521
+ type: "button",
1522
+ onClick: () => handlePreset(p),
1523
+ className: (0, import_clsx3.default)(AdvancedDateRangePicker_module_default.sidebarItem, {
1524
+ [AdvancedDateRangePicker_module_default.sidebarItemActive]: activePreset === p.key
1525
+ }),
1526
+ children: p.label
1527
+ },
1528
+ p.key
1529
+ )) }),
1530
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.main, children: [
1531
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("header", { className: AdvancedDateRangePicker_module_default.header, children: [
1532
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.timezoneWrapper, children: [
1533
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: AdvancedDateRangePicker_module_default.headerLabel, children: "Timezone" }),
1534
+ isTimezoneDisabled ? (
1535
+ /* Disabled state: plain text badge instead of empty dropdown */
1536
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: AdvancedDateRangePicker_module_default.timezoneDisabledBadge, children: timezone })
1537
+ ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1538
+ Select_default,
1539
+ {
1540
+ value: timezone,
1541
+ onChange: (val) => {
1542
+ if (val) setTimezone(String(val));
1543
+ },
1544
+ options: timezoneOptions,
1545
+ size: "small",
1546
+ allowClear: false,
1547
+ enableSearch: false,
1548
+ wrapperClassName: AdvancedDateRangePicker_module_default.timezoneSelectContainer,
1549
+ inputClassName: AdvancedDateRangePicker_module_default.timezoneSelectInput
1550
+ }
1551
+ )
1552
+ ] }),
1553
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: AdvancedDateRangePicker_module_default.dateTimeWrapper, children: [
1554
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1555
+ DateTimeInputGroup,
1556
+ {
1557
+ label: "From",
1558
+ dateValue: fromDateStr,
1559
+ timeValue: fromTimeStr,
1560
+ dateError: fromDateError,
1561
+ timeError: fromTimeError,
1562
+ onDateChange: handleFromDateChange,
1563
+ onTimeChange: handleFromTimeChange
1564
+ }
1565
+ ),
1566
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1567
+ DateTimeInputGroup,
1568
+ {
1569
+ label: "To",
1570
+ dateValue: toDateStr,
1571
+ timeValue: toTimeStr,
1572
+ dateError: toDateError,
1573
+ timeError: toTimeError,
1574
+ onDateChange: handleToDateChange,
1575
+ onTimeChange: handleToTimeChange
1576
+ }
1577
+ )
1578
+ ] })
1579
+ ] }),
1580
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: AdvancedDateRangePicker_module_default.body, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1581
+ InternalCalendar_default,
1582
+ {
1583
+ id: `${id}-calendar`,
1584
+ dateRange: rangeValue,
1585
+ onChange: handleRangeChange,
1586
+ disablePastDates,
1587
+ minDate,
1588
+ maxDate,
1589
+ showSingleCalendar
1590
+ }
1591
+ ) })
1592
+ ] })
1593
+ ] }),
1594
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("footer", { className: AdvancedDateRangePicker_module_default.footer, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1595
+ Button_default,
1596
+ {
1597
+ onClick: handleDone,
1598
+ disabled: disabled || !isReady,
1599
+ shape: "round",
1600
+ children: confirmLabel
1601
+ }
1602
+ ) })
1603
+ ] });
1604
+ }
1605
+ AdvancedDateRangePicker.displayName = "AdvancedDateRangePicker";
1606
+ var AdvancedDateRangePicker_default = AdvancedDateRangePicker;
1607
+ // Annotate the CommonJS export names for ESM import in node:
1608
+ 0 && (module.exports = {
1609
+ AdvancedDateRangePicker
1610
+ });