@duskmoon-dev/components 0.3.1 → 0.4.0

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 (109) hide show
  1. package/README.md +61 -2
  2. package/dist/{chunk-r9wkv7xd.js → chunk-fwjzvsrx.js} +3 -3
  3. package/dist/classes/chat.d.ts +43 -0
  4. package/dist/classes/console-page.d.ts +16 -0
  5. package/dist/classes/dropdown.d.ts +5 -5
  6. package/dist/classes/fab.d.ts +11 -0
  7. package/dist/classes/index.d.ts +6 -0
  8. package/dist/classes/index.js +1443 -1210
  9. package/dist/classes/megamenu.d.ts +10 -0
  10. package/dist/classes/otp-input.d.ts +12 -0
  11. package/dist/classes/popover.d.ts +1 -3
  12. package/dist/classes/swap.d.ts +12 -0
  13. package/dist/classes/tree-select.d.ts +6 -6
  14. package/dist/components/anchor/index.js +2 -2
  15. package/dist/components/app/index.js +211 -151
  16. package/dist/components/avatar/Avatar.types.d.ts +1 -1
  17. package/dist/components/avatar/index.js +2 -1
  18. package/dist/components/badge/index.js +1 -1
  19. package/dist/components/button/Button.d.ts +1 -1
  20. package/dist/components/button/Button.types.d.ts +8 -0
  21. package/dist/components/button/index.js +253 -24
  22. package/dist/components/calendar/index.js +44 -19
  23. package/dist/components/cascader/index.js +2 -2
  24. package/dist/components/chat/Chat.d.ts +22 -0
  25. package/dist/components/chat/Chat.types.d.ts +73 -0
  26. package/dist/components/chat/index.d.ts +2 -0
  27. package/dist/components/chat/index.js +309 -0
  28. package/dist/components/color-picker/ColorPicker.types.d.ts +2 -1
  29. package/dist/components/color-picker/index.js +210 -13
  30. package/dist/components/config-provider/index.js +2 -2
  31. package/dist/components/console-page/ConsolePage.d.ts +2 -0
  32. package/dist/components/console-page/ConsolePage.types.d.ts +29 -0
  33. package/dist/components/console-page/index.d.ts +2 -0
  34. package/dist/components/console-page/index.js +205 -0
  35. package/dist/components/date-picker/DatePicker.types.d.ts +1 -0
  36. package/dist/components/date-picker/index.js +537 -35
  37. package/dist/components/date-picker/usePickerDropdown.d.ts +17 -0
  38. package/dist/components/dm-breadcrumb/index.js +18 -18
  39. package/dist/components/dm-date-picker/index.js +635 -133
  40. package/dist/components/dm-drawer/index.js +269 -40
  41. package/dist/components/dm-layout/index.js +575 -208
  42. package/dist/components/dm-menu/index.js +399 -32
  43. package/dist/components/dm-message/index.js +18 -18
  44. package/dist/components/dm-page-header/index.js +537 -247
  45. package/dist/components/dm-pagination/index.js +39 -39
  46. package/dist/components/dm-pro-table/index.js +2374 -1559
  47. package/dist/components/dm-provider/index.js +94 -94
  48. package/dist/components/dm-query/DmQuery.types.d.ts +1 -1
  49. package/dist/components/dm-query/index.js +955 -210
  50. package/dist/components/dm-search/DmSearch.types.d.ts +4 -0
  51. package/dist/components/dm-search/index.js +937 -183
  52. package/dist/components/dm-splitter/index.js +32 -32
  53. package/dist/components/dm-status/index.js +25 -25
  54. package/dist/components/dm-table/index.js +1430 -676
  55. package/dist/components/dm-tabs/index.js +34 -34
  56. package/dist/components/dm-toolbar/index.js +423 -133
  57. package/dist/components/dm-tree/index.js +92 -92
  58. package/dist/components/dm-truncate/index.js +145 -65
  59. package/dist/components/dropdown/Dropdown.types.d.ts +1 -1
  60. package/dist/components/dropdown/index.js +467 -177
  61. package/dist/components/fab/Fab.d.ts +4 -0
  62. package/dist/components/fab/Fab.types.d.ts +25 -0
  63. package/dist/components/fab/index.d.ts +2 -0
  64. package/dist/components/fab/index.js +480 -0
  65. package/dist/components/form/Form.types.d.ts +1 -0
  66. package/dist/components/form/index.js +16 -5
  67. package/dist/components/grid/index.js +2 -2
  68. package/dist/components/input/index.js +4 -4
  69. package/dist/components/markdown/index.js +1 -1
  70. package/dist/components/megamenu/Megamenu.d.ts +2 -0
  71. package/dist/components/megamenu/Megamenu.types.d.ts +32 -0
  72. package/dist/components/megamenu/index.d.ts +2 -0
  73. package/dist/components/megamenu/index.js +214 -0
  74. package/dist/components/message/index.js +5 -5
  75. package/dist/components/modal/index.js +128 -68
  76. package/dist/components/notification/index.js +2 -2
  77. package/dist/components/otp-input/OtpInput.d.ts +2 -0
  78. package/dist/components/otp-input/OtpInput.types.d.ts +16 -0
  79. package/dist/components/otp-input/index.d.ts +2 -0
  80. package/dist/components/otp-input/index.js +112 -0
  81. package/dist/components/popconfirm/index.js +297 -68
  82. package/dist/components/popover/index.js +24 -4
  83. package/dist/components/skeleton/index.js +5 -5
  84. package/dist/components/spin/index.js +2 -2
  85. package/dist/components/steps/index.js +2 -2
  86. package/dist/components/swap/Swap.d.ts +3 -0
  87. package/dist/components/swap/Swap.types.d.ts +22 -0
  88. package/dist/components/swap/index.d.ts +2 -0
  89. package/dist/components/swap/index.js +109 -0
  90. package/dist/components/table/index.js +2 -2
  91. package/dist/components/tabs/index.js +2 -2
  92. package/dist/components/tag/index.js +2 -2
  93. package/dist/components/time-picker/TimePicker.types.d.ts +1 -0
  94. package/dist/components/time-picker/index.js +167 -29
  95. package/dist/components/tooltip/Tooltip.types.d.ts +4 -0
  96. package/dist/components/tooltip/index.js +107 -27
  97. package/dist/components/tour/index.js +315 -86
  98. package/dist/components/tree-select/index.js +8 -8
  99. package/dist/components/typography/index.js +4 -4
  100. package/dist/components/upload/Upload.types.d.ts +1 -0
  101. package/dist/components/upload/index.js +7 -5
  102. package/dist/generated/version.d.ts +1 -1
  103. package/dist/index.d.ts +6 -0
  104. package/dist/index.js +4023 -2134
  105. package/dist/infrastructure.js +11 -11
  106. package/dist/styles.css +13677 -9811
  107. package/dist/theme/index.js +3 -3
  108. package/dist/utils/index.js +5 -5
  109. package/package.json +30 -6
@@ -1,5 +1,22 @@
1
1
  "use client";
2
2
 
3
+ // src/components/dm-query/DmQuery.tsx
4
+ import {
5
+ forwardRef as forwardRef6,
6
+ useImperativeHandle as useImperativeHandle4,
7
+ useRef as useRef3,
8
+ useState as useState7
9
+ } from "react";
10
+
11
+ // src/components/dm-search/DmSearch.tsx
12
+ import {
13
+ forwardRef as forwardRef5,
14
+ useEffect as useEffect2,
15
+ useImperativeHandle as useImperativeHandle3,
16
+ useMemo as useMemo4,
17
+ useState as useState6
18
+ } from "react";
19
+
3
20
  // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
4
21
  function r(e) {
5
22
  var t, f, n = "";
@@ -25,6 +42,26 @@ function clsx() {
25
42
  function cn(...inputs) {
26
43
  return clsx(inputs);
27
44
  }
45
+ // src/classes/dm-search.ts
46
+ var dmSearchBaseClass = "dm-search";
47
+ var dmSearchCompactClass = "dm-search-compact";
48
+ var dmSearchCollapsedClass = "dm-search-collapsed";
49
+ var dmSearchFieldsClass = "dm-search-fields";
50
+ var dmSearchFieldClass = "dm-search-field";
51
+ var dmSearchActionsClass = "dm-search-actions";
52
+ var dmSearchFastFilterClass = "dm-search-fast-filter";
53
+ function getDmSearchClasses({
54
+ compact,
55
+ collapsed,
56
+ className
57
+ }) {
58
+ return cn(dmSearchBaseClass, compact && dmSearchCompactClass, collapsed && dmSearchCollapsedClass, className);
59
+ }
60
+
61
+ // src/components/button/Button.tsx
62
+ import React from "react";
63
+ import { createPortal } from "react-dom";
64
+
28
65
  // src/classes/button.ts
29
66
  var buttonBaseClass = "btn";
30
67
  var buttonColorClasses = {
@@ -48,7 +85,7 @@ var buttonAppearanceClasses = {
48
85
  };
49
86
  var buttonShapeClasses = {
50
87
  rect: "",
51
- circle: "btn-circle",
88
+ circle: "btn-circle btn-icon",
52
89
  square: "btn-square"
53
90
  };
54
91
  var buttonSizeClasses = {
@@ -68,11 +105,14 @@ function getButtonClasses({
68
105
  isLoading,
69
106
  className
70
107
  }) {
71
- return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
108
+ return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], shape === "circle" && size === "xs" && "btn-icon-sm", shape === "circle" && size === "sm" && "btn-icon-sm", shape === "circle" && size === "lg" && "btn-icon-lg", block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
72
109
  }
73
110
 
74
111
  // src/components/button/Button.tsx
75
- import { jsx, jsxs } from "react/jsx-runtime";
112
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
113
+ function isPromiseLike(value) {
114
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
115
+ }
76
116
  function Button({
77
117
  color = "primary",
78
118
  appearance = "filled",
@@ -86,8 +126,155 @@ function Button({
86
126
  children,
87
127
  disabled,
88
128
  ref,
129
+ confirm,
130
+ onClick,
89
131
  ...props
90
132
  }) {
133
+ const buttonRef = React.useRef(null);
134
+ const popoverRef = React.useRef(null);
135
+ const cancelRef = React.useRef(null);
136
+ const approvalRef = React.useRef("idle");
137
+ const pendingRef = React.useRef(false);
138
+ const actionRef = React.useRef(0);
139
+ const operationRef = React.useRef(0);
140
+ const mountedRef = React.useRef(false);
141
+ const [portalTarget, setPortalTarget] = React.useState(null);
142
+ const [confirmLoading, setConfirmLoading] = React.useState(false);
143
+ const [confirmError, setConfirmError] = React.useState(false);
144
+ const generatedId = React.useId().replace(/:/g, "");
145
+ const popoverId = `button-confirm-${generatedId}`;
146
+ const titleId = `${popoverId}-title`;
147
+ const descriptionId = `${popoverId}-description`;
148
+ const anchor = `--${popoverId}-anchor`;
149
+ const hasConfirm = Boolean(confirm);
150
+ const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
151
+ const title = confirmation ? confirmation.title : "Confirm action";
152
+ const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
153
+ const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
154
+ const hasContent = content !== undefined && content !== null && content !== false && content !== "";
155
+ const mergedRef = React.useCallback((node) => {
156
+ buttonRef.current = node;
157
+ if (!node) {
158
+ if (typeof ref === "function")
159
+ ref(null);
160
+ else if (ref)
161
+ ref.current = null;
162
+ return;
163
+ }
164
+ const cleanup = typeof ref === "function" ? ref(node) : undefined;
165
+ if (ref && typeof ref !== "function")
166
+ ref.current = node;
167
+ return () => {
168
+ buttonRef.current = null;
169
+ if (typeof cleanup === "function")
170
+ cleanup();
171
+ else if (typeof ref === "function")
172
+ ref(null);
173
+ else if (ref)
174
+ ref.current = null;
175
+ };
176
+ }, [ref]);
177
+ React.useEffect(() => {
178
+ mountedRef.current = true;
179
+ return () => {
180
+ mountedRef.current = false;
181
+ operationRef.current += 1;
182
+ };
183
+ }, []);
184
+ React.useEffect(() => {
185
+ operationRef.current += 1;
186
+ approvalRef.current = "idle";
187
+ setConfirmError(false);
188
+ setPortalTarget(hasConfirm ? document.body : null);
189
+ }, [hasConfirm]);
190
+ function closePopover() {
191
+ if (popoverRef.current?.matches(":popover-open")) {
192
+ popoverRef.current.hidePopover();
193
+ }
194
+ buttonRef.current?.focus();
195
+ }
196
+ function handleClick(event) {
197
+ if (!confirm) {
198
+ onClick?.(event);
199
+ return;
200
+ }
201
+ if (approvalRef.current === "native") {
202
+ approvalRef.current = "idle";
203
+ return;
204
+ }
205
+ if (approvalRef.current === "action") {
206
+ approvalRef.current = "idle";
207
+ let result;
208
+ try {
209
+ result = onClick?.(event);
210
+ } catch {
211
+ event.preventDefault();
212
+ pendingRef.current = false;
213
+ setConfirmError(true);
214
+ return;
215
+ }
216
+ if (!isPromiseLike(result)) {
217
+ pendingRef.current = false;
218
+ closePopover();
219
+ return;
220
+ }
221
+ const userPreventedDefault = event.defaultPrevented;
222
+ event.preventDefault();
223
+ setConfirmLoading(true);
224
+ const action = actionRef.current;
225
+ const operation = operationRef.current;
226
+ Promise.resolve(result).then(() => {
227
+ if (!mountedRef.current || action !== actionRef.current)
228
+ return;
229
+ pendingRef.current = false;
230
+ setConfirmLoading(false);
231
+ if (operation !== operationRef.current)
232
+ return;
233
+ closePopover();
234
+ if (!userPreventedDefault && !buttonRef.current?.disabled) {
235
+ approvalRef.current = "native";
236
+ buttonRef.current?.click();
237
+ approvalRef.current = "idle";
238
+ }
239
+ }, () => {
240
+ if (!mountedRef.current || action !== actionRef.current)
241
+ return;
242
+ pendingRef.current = false;
243
+ setConfirmLoading(false);
244
+ if (operation !== operationRef.current)
245
+ return;
246
+ setConfirmError(true);
247
+ cancelRef.current?.focus();
248
+ });
249
+ return;
250
+ }
251
+ event.preventDefault();
252
+ if (disabled || isLoading || pendingRef.current)
253
+ return;
254
+ if (popoverRef.current?.matches(":popover-open")) {
255
+ closePopover();
256
+ return;
257
+ }
258
+ setConfirmError(false);
259
+ popoverRef.current?.showPopover();
260
+ cancelRef.current?.focus();
261
+ }
262
+ function handleConfirm(event) {
263
+ event.preventDefault();
264
+ event.stopPropagation();
265
+ const trigger = buttonRef.current;
266
+ if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
267
+ return;
268
+ setConfirmError(false);
269
+ pendingRef.current = true;
270
+ actionRef.current += 1;
271
+ approvalRef.current = "action";
272
+ trigger.click();
273
+ if (approvalRef.current === "action") {
274
+ approvalRef.current = "idle";
275
+ pendingRef.current = false;
276
+ }
277
+ }
91
278
  const classes = getButtonClasses({
92
279
  color,
93
280
  appearance,
@@ -97,34 +284,526 @@ function Button({
97
284
  isLoading,
98
285
  className
99
286
  });
100
- return /* @__PURE__ */ jsxs("button", {
101
- ref,
102
- className: classes,
103
- disabled: disabled || isLoading,
104
- "aria-busy": isLoading,
105
- "aria-disabled": disabled || isLoading,
106
- ...props,
287
+ const confirmClasses = getButtonClasses({
288
+ color,
289
+ size: "sm",
290
+ isLoading: confirmLoading
291
+ });
292
+ return /* @__PURE__ */ jsxs(Fragment, {
107
293
  children: [
108
- isLoading && /* @__PURE__ */ jsx("span", {
109
- className: "btn-spinner"
294
+ /* @__PURE__ */ jsxs("button", {
295
+ ref: confirm ? mergedRef : ref,
296
+ className: classes,
297
+ disabled: disabled || isLoading,
298
+ "aria-busy": isLoading,
299
+ "aria-disabled": disabled || isLoading,
300
+ ...props,
301
+ style: confirm ? { ...props.style, anchorName: anchor } : props.style,
302
+ "aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
303
+ "aria-controls": confirm ? popoverId : props["aria-controls"],
304
+ onClick: confirm ? handleClick : onClick,
305
+ children: [
306
+ isLoading && /* @__PURE__ */ jsx("span", {
307
+ className: "btn-spinner"
308
+ }),
309
+ !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
310
+ className: "btn-icon-left",
311
+ children: leftIcon
312
+ }),
313
+ /* @__PURE__ */ jsx("span", {
314
+ className: "btn-content",
315
+ children
316
+ }),
317
+ !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
318
+ className: "btn-icon-right",
319
+ children: rightIcon
320
+ })
321
+ ]
110
322
  }),
111
- !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
112
- className: "btn-icon-left",
113
- children: leftIcon
323
+ confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
324
+ id: popoverId,
325
+ ref: popoverRef,
326
+ popover: "auto",
327
+ role: "dialog",
328
+ "aria-labelledby": hasTitle ? titleId : undefined,
329
+ "aria-label": hasTitle ? undefined : "Confirm action",
330
+ "aria-describedby": hasContent ? descriptionId : undefined,
331
+ className: "popover popover-confirm popover-bottom",
332
+ style: { positionAnchor: anchor },
333
+ onSubmit: handleConfirm,
334
+ onClick: (event) => event.stopPropagation(),
335
+ onToggle: (event) => {
336
+ if (!event.currentTarget.matches(":popover-open")) {
337
+ operationRef.current += 1;
338
+ if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
339
+ buttonRef.current?.focus();
340
+ }
341
+ }
342
+ },
343
+ children: [
344
+ hasTitle && /* @__PURE__ */ jsx("div", {
345
+ className: "popover-header",
346
+ children: /* @__PURE__ */ jsx("h3", {
347
+ id: titleId,
348
+ className: "popover-title",
349
+ children: title
350
+ })
351
+ }),
352
+ hasContent && /* @__PURE__ */ jsx("div", {
353
+ id: descriptionId,
354
+ className: "popover-body",
355
+ children: content
356
+ }),
357
+ confirmError && /* @__PURE__ */ jsx("div", {
358
+ role: "alert",
359
+ className: "popover-body",
360
+ children: "The action failed. Please try again."
361
+ }),
362
+ /* @__PURE__ */ jsxs("div", {
363
+ className: "popover-footer",
364
+ children: [
365
+ /* @__PURE__ */ jsx("button", {
366
+ ref: cancelRef,
367
+ type: "button",
368
+ className: "btn btn-text btn-sm",
369
+ popoverTarget: popoverId,
370
+ popoverTargetAction: "hide",
371
+ disabled: confirmLoading,
372
+ children: confirmation?.cancelText ?? "Cancel"
373
+ }),
374
+ /* @__PURE__ */ jsx("button", {
375
+ type: "submit",
376
+ className: confirmClasses,
377
+ disabled: disabled || isLoading || confirmLoading,
378
+ "aria-busy": confirmLoading,
379
+ children: confirmation?.confirmText ?? "Confirm"
380
+ })
381
+ ]
382
+ })
383
+ ]
384
+ }), portalTarget)
385
+ ]
386
+ });
387
+ }
388
+ // src/components/date-picker/DatePicker.tsx
389
+ import { forwardRef as forwardRef2, useMemo as useMemo2, useState as useState3 } from "react";
390
+
391
+ // src/components/calendar/Calendar.tsx
392
+ import { forwardRef, useMemo, useState } from "react";
393
+
394
+ // src/classes/calendar.ts
395
+ var calendarBaseClass = "datepicker calendar";
396
+ var calendarHeaderClass = "calendar-header";
397
+ var calendarTitleClass = "calendar-title";
398
+ var calendarControlsClass = "calendar-controls";
399
+ var calendarNavClass = "calendar-nav";
400
+ var calendarModeClass = "calendar-mode";
401
+ var calendarWeekdaysClass = "calendar-weekdays";
402
+ var calendarWeekdayClass = "calendar-weekday";
403
+ var calendarBodyClass = "calendar-body";
404
+ var calendarDateGridClass = "calendar-date-grid";
405
+ var calendarMonthGridClass = "calendar-month-grid";
406
+ var calendarCellContentClass = "calendar-cell-content";
407
+ function getCalendarClasses({
408
+ fullscreen = true,
409
+ mode = "month",
410
+ className
411
+ }) {
412
+ return cn(calendarBaseClass, fullscreen ? "calendar-fullscreen" : "calendar-card", mode === "year" && "calendar-year-mode", className);
413
+ }
414
+ function getCalendarCellClasses({
415
+ selected,
416
+ today,
417
+ outside,
418
+ disabled,
419
+ className
420
+ }) {
421
+ return cn("calendar-cell", selected && "calendar-cell-selected", today && "calendar-cell-today", outside && "calendar-cell-outside", disabled && "calendar-cell-disabled", className);
422
+ }
423
+
424
+ // src/components/calendar/Calendar.tsx
425
+ import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
426
+ var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
427
+ var MONTHS = [
428
+ "Jan",
429
+ "Feb",
430
+ "Mar",
431
+ "Apr",
432
+ "May",
433
+ "Jun",
434
+ "Jul",
435
+ "Aug",
436
+ "Sep",
437
+ "Oct",
438
+ "Nov",
439
+ "Dec"
440
+ ];
441
+ function pad(value) {
442
+ return String(value).padStart(2, "0");
443
+ }
444
+ function formatDate(date) {
445
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
446
+ }
447
+ function formatMonth(date) {
448
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-01`;
449
+ }
450
+ function parseDate(value) {
451
+ if (value instanceof Date && !Number.isNaN(value.getTime())) {
452
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
453
+ }
454
+ if (typeof value === "string" && value.length > 0) {
455
+ const [year, month = "1", day = "1"] = value.split("-");
456
+ const parsed = new Date(Number(year), Number(month) - 1, Number(day));
457
+ if (!Number.isNaN(parsed.getTime())) {
458
+ return parsed;
459
+ }
460
+ }
461
+ const today = new Date;
462
+ return new Date(today.getFullYear(), today.getMonth(), today.getDate());
463
+ }
464
+ function addMonths(date, amount) {
465
+ return new Date(date.getFullYear(), date.getMonth() + amount, 1);
466
+ }
467
+ function addYears(date, amount) {
468
+ return new Date(date.getFullYear() + amount, date.getMonth(), 1);
469
+ }
470
+ function startOfCalendarGrid(panelDate) {
471
+ const firstOfMonth = new Date(panelDate.getFullYear(), panelDate.getMonth(), 1);
472
+ const start = new Date(firstOfMonth);
473
+ start.setDate(firstOfMonth.getDate() - firstOfMonth.getDay());
474
+ return start;
475
+ }
476
+ function buildDateGrid(panelDate) {
477
+ const start = startOfCalendarGrid(panelDate);
478
+ return Array.from({ length: 42 }, (_, index) => {
479
+ const date = new Date(start);
480
+ date.setDate(start.getDate() + index);
481
+ return date;
482
+ });
483
+ }
484
+ function isSameMonth(left, right) {
485
+ return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();
486
+ }
487
+ function isOutsideRange(date, validRange) {
488
+ if (!validRange) {
489
+ return false;
490
+ }
491
+ const current = formatDate(date);
492
+ const start = formatDate(parseDate(validRange[0]));
493
+ const end = formatDate(parseDate(validRange[1]));
494
+ return current < start || current > end;
495
+ }
496
+ function Header({
497
+ panelDate,
498
+ mode,
499
+ setPanelDate,
500
+ setMode
501
+ }) {
502
+ const title = mode === "year" ? String(panelDate.getFullYear()) : `${MONTHS[panelDate.getMonth()]} ${panelDate.getFullYear()}`;
503
+ return /* @__PURE__ */ jsxs2("div", {
504
+ className: calendarHeaderClass,
505
+ children: [
506
+ /* @__PURE__ */ jsx2("button", {
507
+ type: "button",
508
+ className: calendarNavClass,
509
+ "aria-label": "Previous panel",
510
+ onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, -1) : addMonths(panelDate, -1), mode),
511
+ children: /* @__PURE__ */ jsx2("svg", {
512
+ "aria-hidden": "true",
513
+ focusable: "false",
514
+ width: "16",
515
+ height: "16",
516
+ viewBox: "0 0 24 24",
517
+ fill: "none",
518
+ stroke: "currentColor",
519
+ strokeWidth: "2",
520
+ strokeLinecap: "round",
521
+ strokeLinejoin: "round",
522
+ children: /* @__PURE__ */ jsx2("path", {
523
+ d: "m15 18-6-6 6-6"
524
+ })
525
+ })
114
526
  }),
115
- /* @__PURE__ */ jsx("span", {
116
- className: "btn-content",
117
- children
527
+ /* @__PURE__ */ jsxs2("div", {
528
+ className: calendarControlsClass,
529
+ children: [
530
+ /* @__PURE__ */ jsx2("div", {
531
+ className: calendarTitleClass,
532
+ children: title
533
+ }),
534
+ /* @__PURE__ */ jsxs2("div", {
535
+ className: calendarModeClass,
536
+ children: [
537
+ /* @__PURE__ */ jsx2("button", {
538
+ type: "button",
539
+ "aria-pressed": mode === "month",
540
+ onClick: () => setMode("month"),
541
+ children: "Month"
542
+ }),
543
+ /* @__PURE__ */ jsx2("button", {
544
+ type: "button",
545
+ "aria-pressed": mode === "year",
546
+ onClick: () => setMode("year"),
547
+ children: "Year"
548
+ })
549
+ ]
550
+ })
551
+ ]
118
552
  }),
119
- !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
120
- className: "btn-icon-right",
121
- children: rightIcon
553
+ /* @__PURE__ */ jsx2("button", {
554
+ type: "button",
555
+ className: calendarNavClass,
556
+ "aria-label": "Next panel",
557
+ onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, 1) : addMonths(panelDate, 1), mode),
558
+ children: /* @__PURE__ */ jsx2("svg", {
559
+ "aria-hidden": "true",
560
+ focusable: "false",
561
+ width: "16",
562
+ height: "16",
563
+ viewBox: "0 0 24 24",
564
+ fill: "none",
565
+ stroke: "currentColor",
566
+ strokeWidth: "2",
567
+ strokeLinecap: "round",
568
+ strokeLinejoin: "round",
569
+ children: /* @__PURE__ */ jsx2("path", {
570
+ d: "m9 18 6-6-6-6"
571
+ })
572
+ })
122
573
  })
123
574
  ]
124
575
  });
125
576
  }
126
- // src/components/date-picker/DatePicker.tsx
127
- import { forwardRef, useMemo, useState } from "react";
577
+ var Calendar = forwardRef(({
578
+ className,
579
+ value,
580
+ defaultValue,
581
+ mode,
582
+ defaultMode = "month",
583
+ fullscreen = true,
584
+ validRange,
585
+ disabledDate,
586
+ dateCellRender,
587
+ dateFullCellRender,
588
+ monthCellRender,
589
+ monthFullCellRender,
590
+ cellRender,
591
+ fullCellRender,
592
+ headerRender,
593
+ onChange,
594
+ onSelect,
595
+ onPanelChange,
596
+ ...props
597
+ }, ref) => {
598
+ const selectedDate = parseDate(value ?? defaultValue);
599
+ const [innerValue, setInnerValue] = useState(() => formatDate(selectedDate));
600
+ const [panelDate, setInnerPanelDate] = useState(selectedDate);
601
+ const [innerMode, setInnerMode] = useState(mode ?? defaultMode);
602
+ const currentMode = mode ?? innerMode;
603
+ const currentValue = value === undefined ? innerValue : formatDate(parseDate(value));
604
+ const today = useMemo(() => formatDate(new Date), []);
605
+ const dateGrid = useMemo(() => buildDateGrid(panelDate), [panelDate]);
606
+ function emitPanelChange(nextDate, nextMode = currentMode) {
607
+ setInnerPanelDate(nextDate);
608
+ onPanelChange?.(formatDate(nextDate), nextMode);
609
+ }
610
+ function setCalendarMode(nextMode) {
611
+ if (mode === undefined) {
612
+ setInnerMode(nextMode);
613
+ }
614
+ onPanelChange?.(formatDate(panelDate), nextMode);
615
+ }
616
+ function commitValue(nextDate, source) {
617
+ const nextValue = source === "month" ? formatMonth(nextDate) : formatDate(nextDate);
618
+ if (disabledDate?.(nextValue) || isOutsideRange(nextDate, validRange)) {
619
+ return;
620
+ }
621
+ if (value === undefined) {
622
+ setInnerValue(nextValue);
623
+ }
624
+ setInnerPanelDate(nextDate);
625
+ onSelect?.(nextValue, { source });
626
+ onChange?.(nextValue);
627
+ }
628
+ function renderDateCell(date) {
629
+ const dateValue = formatDate(date);
630
+ const originNode = /* @__PURE__ */ jsxs2("div", {
631
+ className: calendarCellContentClass,
632
+ children: [
633
+ /* @__PURE__ */ jsx2("span", {
634
+ children: date.getDate()
635
+ }),
636
+ dateCellRender?.(dateValue)
637
+ ]
638
+ });
639
+ const info = {
640
+ originNode,
641
+ today,
642
+ type: "month"
643
+ };
644
+ const content = fullCellRender?.(dateValue, info) ?? dateFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
645
+ const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
646
+ return /* @__PURE__ */ jsx2("button", {
647
+ type: "button",
648
+ "aria-label": dateValue,
649
+ disabled,
650
+ className: getCalendarCellClasses({
651
+ selected: dateValue === currentValue,
652
+ today: dateValue === today,
653
+ outside: !isSameMonth(date, panelDate),
654
+ disabled
655
+ }),
656
+ onClick: () => commitValue(date, "date"),
657
+ children: content
658
+ }, dateValue);
659
+ }
660
+ function renderMonthCell(month) {
661
+ const date = new Date(panelDate.getFullYear(), month, 1);
662
+ const dateValue = formatMonth(date);
663
+ const originNode = /* @__PURE__ */ jsxs2("div", {
664
+ className: calendarCellContentClass,
665
+ children: [
666
+ /* @__PURE__ */ jsx2("span", {
667
+ children: MONTHS[month]
668
+ }),
669
+ monthCellRender?.(dateValue)
670
+ ]
671
+ });
672
+ const info = {
673
+ originNode,
674
+ today,
675
+ type: "year"
676
+ };
677
+ const content = fullCellRender?.(dateValue, info) ?? monthFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
678
+ const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
679
+ return /* @__PURE__ */ jsx2("button", {
680
+ type: "button",
681
+ "aria-label": dateValue,
682
+ disabled,
683
+ className: getCalendarCellClasses({
684
+ selected: dateValue === formatMonth(parseDate(currentValue)),
685
+ today: dateValue === formatMonth(new Date),
686
+ disabled
687
+ }),
688
+ onClick: () => commitValue(date, "month"),
689
+ children: content
690
+ }, dateValue);
691
+ }
692
+ return /* @__PURE__ */ jsxs2("div", {
693
+ ...props,
694
+ ref,
695
+ className: getCalendarClasses({
696
+ fullscreen,
697
+ mode: currentMode,
698
+ className
699
+ }),
700
+ children: [
701
+ headerRender ? headerRender({
702
+ value: formatDate(panelDate),
703
+ type: currentMode,
704
+ onChange: (nextValue) => emitPanelChange(parseDate(nextValue)),
705
+ onTypeChange: setCalendarMode
706
+ }) : /* @__PURE__ */ jsx2(Header, {
707
+ panelDate,
708
+ mode: currentMode,
709
+ setPanelDate: emitPanelChange,
710
+ setMode: setCalendarMode
711
+ }),
712
+ /* @__PURE__ */ jsx2("div", {
713
+ className: calendarBodyClass,
714
+ children: currentMode === "month" ? /* @__PURE__ */ jsxs2(Fragment2, {
715
+ children: [
716
+ /* @__PURE__ */ jsx2("div", {
717
+ className: calendarWeekdaysClass,
718
+ "aria-hidden": "true",
719
+ children: WEEKDAYS.map((weekday) => /* @__PURE__ */ jsx2("span", {
720
+ className: calendarWeekdayClass,
721
+ children: weekday
722
+ }, weekday))
723
+ }),
724
+ /* @__PURE__ */ jsx2("div", {
725
+ className: calendarDateGridClass,
726
+ children: dateGrid.map(renderDateCell)
727
+ })
728
+ ]
729
+ }) : /* @__PURE__ */ jsx2("div", {
730
+ className: calendarMonthGridClass,
731
+ children: MONTHS.map((_, month) => renderMonthCell(month))
732
+ })
733
+ })
734
+ ]
735
+ });
736
+ });
737
+ Calendar.displayName = "Calendar";
738
+ // src/components/date-picker/usePickerDropdown.ts
739
+ import { useEffect, useId, useImperativeHandle, useRef, useState as useState2 } from "react";
740
+ function usePickerDropdown({
741
+ open,
742
+ defaultOpen,
743
+ disabled,
744
+ onOpenChange,
745
+ ref
746
+ }) {
747
+ const rootRef = useRef(null);
748
+ const inputRef = useRef(null);
749
+ const skipFocus = useRef(false);
750
+ const panelId = useId();
751
+ const [innerOpen, setInnerOpen] = useState2(Boolean(defaultOpen));
752
+ const visible = !disabled && (open ?? innerOpen);
753
+ useImperativeHandle(ref, () => rootRef.current, []);
754
+ function setVisible(next) {
755
+ if (disabled || next === visible)
756
+ return;
757
+ if (open === undefined)
758
+ setInnerOpen(next);
759
+ onOpenChange?.(next);
760
+ }
761
+ function closeAndFocus() {
762
+ skipFocus.current = true;
763
+ inputRef.current?.focus();
764
+ skipFocus.current = false;
765
+ setVisible(false);
766
+ }
767
+ useEffect(() => {
768
+ function handleOutside(event) {
769
+ if (visible && !rootRef.current?.contains(event.target))
770
+ setVisible(false);
771
+ }
772
+ function handleKeyDown(event) {
773
+ if (event.defaultPrevented || !rootRef.current?.contains(event.target))
774
+ return;
775
+ if (event.key === "Escape" && visible) {
776
+ event.preventDefault();
777
+ closeAndFocus();
778
+ } else if (event.key === "ArrowDown" && event.target === inputRef.current) {
779
+ event.preventDefault();
780
+ setVisible(true);
781
+ }
782
+ }
783
+ document.addEventListener("pointerdown", handleOutside);
784
+ document.addEventListener("keydown", handleKeyDown);
785
+ return () => {
786
+ document.removeEventListener("pointerdown", handleOutside);
787
+ document.removeEventListener("keydown", handleKeyDown);
788
+ };
789
+ });
790
+ return {
791
+ rootRef,
792
+ inputRef,
793
+ panelId,
794
+ visible,
795
+ setVisible,
796
+ closeAndFocus,
797
+ onInputFocus: () => {
798
+ if (!skipFocus.current)
799
+ setVisible(true);
800
+ },
801
+ onRootBlur: (event) => {
802
+ if (!event.currentTarget.contains(event.relatedTarget))
803
+ setVisible(false);
804
+ }
805
+ };
806
+ }
128
807
 
129
808
  // src/classes/date-picker.ts
130
809
  var datePickerBaseClass = "datepicker";
@@ -173,7 +852,7 @@ function getDatePickerDropdownClasses({
173
852
  }
174
853
 
175
854
  // src/components/date-picker/DatePicker.tsx
176
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
855
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
177
856
  function todayValue(picker) {
178
857
  const today = new Date;
179
858
  const year = today.getFullYear();
@@ -212,9 +891,10 @@ function placeholderForPicker(picker) {
212
891
  function normalizeDateValue(value) {
213
892
  return typeof value === "string" && value.length > 0 ? value : undefined;
214
893
  }
215
- var DatePickerRoot = forwardRef(({
894
+ var DatePickerRoot = forwardRef2(({
216
895
  allowClear,
217
896
  className,
897
+ inputProps,
218
898
  defaultOpen,
219
899
  defaultValue,
220
900
  disabled,
@@ -233,19 +913,19 @@ var DatePickerRoot = forwardRef(({
233
913
  value,
234
914
  ...props
235
915
  }, ref) => {
916
+ const [calendarMode, setCalendarMode] = useState3("month");
236
917
  const isValueControlled = value !== undefined;
237
- const isOpenControlled = open !== undefined;
238
- const [innerValue, setInnerValue] = useState(() => normalizeDateValue(defaultValue));
239
- const [innerOpen, setInnerOpen] = useState(Boolean(defaultOpen));
918
+ const [innerValue, setInnerValue] = useState3(() => normalizeDateValue(defaultValue));
919
+ const dropdown = usePickerDropdown({
920
+ open,
921
+ defaultOpen,
922
+ disabled,
923
+ onOpenChange,
924
+ ref
925
+ });
240
926
  const currentValue = isValueControlled ? normalizeDateValue(value) : innerValue;
241
- const visible = isOpenControlled ? Boolean(open) : innerOpen;
927
+ const { visible, setVisible } = dropdown;
242
928
  const inputType = inputTypeForPicker(picker);
243
- function setVisible(nextOpen) {
244
- if (!isOpenControlled) {
245
- setInnerOpen(nextOpen);
246
- }
247
- onOpenChange?.(nextOpen);
248
- }
249
929
  function emitChange(nextValue) {
250
930
  if (nextValue && disabledDate?.(nextValue)) {
251
931
  return;
@@ -255,10 +935,17 @@ var DatePickerRoot = forwardRef(({
255
935
  }
256
936
  onChange?.(nextValue, nextValue ?? "");
257
937
  }
258
- const presetItems = useMemo(() => presets ?? [], [presets]);
259
- return /* @__PURE__ */ jsxs2("div", {
938
+ function selectValue(nextValue) {
939
+ if (disabledDate?.(nextValue))
940
+ return;
941
+ emitChange(nextValue);
942
+ dropdown.closeAndFocus();
943
+ }
944
+ const presetItems = useMemo2(() => presets ?? [], [presets]);
945
+ return /* @__PURE__ */ jsxs3("div", {
260
946
  ...props,
261
- ref,
947
+ ref: dropdown.rootRef,
948
+ onBlur: dropdown.onRootBlur,
262
949
  className: getDatePickerClasses({
263
950
  size,
264
951
  status,
@@ -268,7 +955,11 @@ var DatePickerRoot = forwardRef(({
268
955
  className
269
956
  }),
270
957
  children: [
271
- /* @__PURE__ */ jsx2("input", {
958
+ /* @__PURE__ */ jsx3("input", {
959
+ ...inputProps,
960
+ ref: dropdown.inputRef,
961
+ "aria-haspopup": "dialog",
962
+ "aria-controls": visible ? dropdown.panelId : undefined,
272
963
  className: datePickerInputClass,
273
964
  disabled,
274
965
  type: inputType,
@@ -276,15 +967,15 @@ var DatePickerRoot = forwardRef(({
276
967
  placeholder: placeholder ?? placeholderForPicker(picker),
277
968
  onFocus: (event) => {
278
969
  onFocus?.(event);
279
- setVisible(true);
970
+ dropdown.onInputFocus();
280
971
  },
281
972
  onBlur: (event) => {
282
973
  onBlur?.(event);
283
- setVisible(false);
284
974
  },
975
+ onClick: () => setVisible(true),
285
976
  onChange: (event) => emitChange(event.currentTarget.value || undefined)
286
977
  }),
287
- allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx2("button", {
978
+ allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx3("button", {
288
979
  type: "button",
289
980
  className: datePickerClearClass,
290
981
  "aria-label": "Clear date",
@@ -292,26 +983,95 @@ var DatePickerRoot = forwardRef(({
292
983
  onClick: () => emitChange(undefined),
293
984
  children: "x"
294
985
  }) : null,
295
- /* @__PURE__ */ jsx2("span", {
986
+ /* @__PURE__ */ jsx3("button", {
987
+ type: "button",
296
988
  className: datePickerIconClass,
297
- "aria-hidden": "true"
989
+ "aria-label": "Open date picker",
990
+ "aria-haspopup": "dialog",
991
+ "aria-expanded": visible,
992
+ "aria-controls": visible ? dropdown.panelId : undefined,
993
+ disabled,
994
+ onMouseDown: (event) => event.preventDefault(),
995
+ onClick: () => setVisible(!visible),
996
+ children: /* @__PURE__ */ jsxs3("svg", {
997
+ "aria-hidden": "true",
998
+ focusable: "false",
999
+ width: "18",
1000
+ height: "18",
1001
+ viewBox: "0 0 24 24",
1002
+ fill: "none",
1003
+ stroke: "currentColor",
1004
+ strokeWidth: "1.75",
1005
+ strokeLinecap: "round",
1006
+ strokeLinejoin: "round",
1007
+ children: [
1008
+ /* @__PURE__ */ jsx3("rect", {
1009
+ x: "3",
1010
+ y: "5",
1011
+ width: "18",
1012
+ height: "16",
1013
+ rx: "2"
1014
+ }),
1015
+ /* @__PURE__ */ jsx3("path", {
1016
+ d: "M8 3v4M16 3v4M3 10h18"
1017
+ })
1018
+ ]
1019
+ })
298
1020
  }),
299
- (presetItems.length > 0 || showNow) && visible ? /* @__PURE__ */ jsxs2("div", {
1021
+ visible ? /* @__PURE__ */ jsxs3("div", {
1022
+ id: dropdown.panelId,
1023
+ role: "dialog",
1024
+ "aria-label": "Choose date",
300
1025
  className: getDatePickerDropdownClasses({ open: visible }),
301
1026
  children: [
302
- presetItems.map((preset, index) => /* @__PURE__ */ jsx2("button", {
1027
+ picker === "date" || picker === "month" ? /* @__PURE__ */ jsx3(Calendar, {
1028
+ fullscreen: false,
1029
+ value: currentValue,
1030
+ mode: picker === "month" ? "year" : calendarMode,
1031
+ onPanelChange: (_, mode) => {
1032
+ if (picker === "date")
1033
+ setCalendarMode(mode);
1034
+ },
1035
+ disabledDate: (date) => {
1036
+ if (!disabledDate)
1037
+ return false;
1038
+ if (picker === "month")
1039
+ return disabledDate(date.slice(0, 7));
1040
+ if (calendarMode === "year") {
1041
+ const [year, month] = date.split("-").map(Number);
1042
+ const days = new Date(year, month, 0).getDate();
1043
+ return Array.from({ length: days }, (_, index) => `${date.slice(0, 7)}-${String(index + 1).padStart(2, "0")}`).every((day) => disabledDate(day));
1044
+ }
1045
+ return disabledDate(date);
1046
+ },
1047
+ onSelect: (date, info) => {
1048
+ if (picker === "date" && info.source === "month") {
1049
+ setCalendarMode("month");
1050
+ return;
1051
+ }
1052
+ selectValue(picker === "month" ? date.slice(0, 7) : date);
1053
+ }
1054
+ }) : /* @__PURE__ */ jsx3("input", {
1055
+ type: inputType,
1056
+ "aria-label": placeholderForPicker(picker),
1057
+ value: currentValue ?? "",
1058
+ onChange: (event) => selectValue(event.currentTarget.value)
1059
+ }),
1060
+ presetItems.map((preset, index) => /* @__PURE__ */ jsx3("button", {
303
1061
  type: "button",
304
1062
  className: datePickerPresetClass,
305
1063
  onMouseDown: (event) => event.preventDefault(),
306
- onClick: () => emitChange(preset.value),
1064
+ disabled: Boolean(disabledDate?.(preset.value)),
1065
+ onClick: () => selectValue(preset.value),
307
1066
  children: preset.label
308
1067
  }, index)),
309
- showNow ? /* @__PURE__ */ jsx2("div", {
1068
+ showNow ? /* @__PURE__ */ jsx3("div", {
310
1069
  className: datePickerFooterClass,
311
- children: /* @__PURE__ */ jsx2("button", {
1070
+ children: /* @__PURE__ */ jsx3("button", {
312
1071
  type: "button",
313
1072
  onMouseDown: (event) => event.preventDefault(),
314
- onClick: () => emitChange(todayValue(picker)),
1073
+ disabled: Boolean(disabledDate?.(todayValue(picker))),
1074
+ onClick: () => selectValue(todayValue(picker)),
315
1075
  children: "Now"
316
1076
  })
317
1077
  }) : null
@@ -321,9 +1081,10 @@ var DatePickerRoot = forwardRef(({
321
1081
  });
322
1082
  });
323
1083
  DatePickerRoot.displayName = "DatePicker";
324
- var RangePicker = forwardRef(({
1084
+ var RangePicker = forwardRef2(({
325
1085
  allowClear,
326
1086
  className,
1087
+ inputProps,
327
1088
  defaultValue,
328
1089
  disabled,
329
1090
  disabledDate,
@@ -337,7 +1098,7 @@ var RangePicker = forwardRef(({
337
1098
  ...props
338
1099
  }, ref) => {
339
1100
  const isControlled = value !== undefined;
340
- const [innerValue, setInnerValue] = useState(defaultValue ?? [undefined, undefined]);
1101
+ const [innerValue, setInnerValue] = useState3(defaultValue ?? [undefined, undefined]);
341
1102
  const currentValue = isControlled ? value : innerValue;
342
1103
  const inputType = inputTypeForPicker(picker);
343
1104
  function emitChange(nextValue) {
@@ -352,7 +1113,7 @@ var RangePicker = forwardRef(({
352
1113
  function updateIndex(index, nextItem) {
353
1114
  emitChange(index === 0 ? [nextItem, currentValue?.[1]] : [currentValue?.[0], nextItem]);
354
1115
  }
355
- return /* @__PURE__ */ jsxs2("div", {
1116
+ return /* @__PURE__ */ jsxs3("div", {
356
1117
  ...props,
357
1118
  ref,
358
1119
  className: getDatePickerClasses({
@@ -364,7 +1125,8 @@ var RangePicker = forwardRef(({
364
1125
  className
365
1126
  }),
366
1127
  children: [
367
- /* @__PURE__ */ jsx2("input", {
1128
+ /* @__PURE__ */ jsx3("input", {
1129
+ ...inputProps,
368
1130
  className: datePickerInputClass,
369
1131
  disabled,
370
1132
  type: inputType,
@@ -372,11 +1134,13 @@ var RangePicker = forwardRef(({
372
1134
  placeholder: Array.isArray(placeholder) ? placeholder[0] : "Start date",
373
1135
  onChange: (event) => updateIndex(0, event.currentTarget.value || undefined)
374
1136
  }),
375
- /* @__PURE__ */ jsx2("span", {
1137
+ /* @__PURE__ */ jsx3("span", {
376
1138
  className: datePickerSeparatorClass,
377
1139
  children: separator
378
1140
  }),
379
- /* @__PURE__ */ jsx2("input", {
1141
+ /* @__PURE__ */ jsx3("input", {
1142
+ ...inputProps,
1143
+ id: inputProps?.id ? `${inputProps.id}-end` : undefined,
380
1144
  className: datePickerInputClass,
381
1145
  disabled,
382
1146
  type: inputType,
@@ -384,7 +1148,7 @@ var RangePicker = forwardRef(({
384
1148
  placeholder: Array.isArray(placeholder) ? placeholder[1] : "End date",
385
1149
  onChange: (event) => updateIndex(1, event.currentTarget.value || undefined)
386
1150
  }),
387
- allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx2("button", {
1151
+ allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx3("button", {
388
1152
  type: "button",
389
1153
  className: datePickerClearClass,
390
1154
  "aria-label": "Clear date range",
@@ -396,7 +1160,7 @@ var RangePicker = forwardRef(({
396
1160
  });
397
1161
  RangePicker.displayName = "DatePicker.RangePicker";
398
1162
  function withPicker(picker, displayName) {
399
- const Picker = forwardRef((props, ref) => /* @__PURE__ */ jsx2(DatePickerRoot, {
1163
+ const Picker = forwardRef2((props, ref) => /* @__PURE__ */ jsx3(DatePickerRoot, {
400
1164
  ...props,
401
1165
  ref,
402
1166
  picker
@@ -413,10 +1177,10 @@ var DatePicker = Object.assign(DatePickerRoot, {
413
1177
  });
414
1178
  // src/components/input/Input.tsx
415
1179
  import {
416
- forwardRef as forwardRef2,
417
- useImperativeHandle,
418
- useRef,
419
- useState as useState2
1180
+ forwardRef as forwardRef3,
1181
+ useImperativeHandle as useImperativeHandle2,
1182
+ useRef as useRef2,
1183
+ useState as useState4
420
1184
  } from "react";
421
1185
 
422
1186
  // src/classes/input.ts
@@ -505,14 +1269,14 @@ function getTextAreaCountClasses({ exceeded }) {
505
1269
  }
506
1270
 
507
1271
  // src/components/input/Input.tsx
508
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1272
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
509
1273
  function toTextValue(value) {
510
1274
  if (Array.isArray(value)) {
511
1275
  return value.join(",");
512
1276
  }
513
1277
  return value == null ? "" : String(value);
514
1278
  }
515
- var InputRoot = forwardRef2(({
1279
+ var InputRoot = forwardRef3(({
516
1280
  allowClear,
517
1281
  className,
518
1282
  defaultValue,
@@ -527,12 +1291,12 @@ var InputRoot = forwardRef2(({
527
1291
  variant = "outlined",
528
1292
  ...props
529
1293
  }, ref) => {
530
- const inputRef = useRef(null);
531
- const [internalValue, setInternalValue] = useState2(() => toTextValue(defaultValue));
1294
+ const inputRef = useRef2(null);
1295
+ const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
532
1296
  const isControlled = value !== undefined;
533
1297
  const currentValue = isControlled ? toTextValue(value) : internalValue;
534
1298
  const hasAffix = prefix != null || suffix != null || allowClear;
535
- useImperativeHandle(ref, () => inputRef.current);
1299
+ useImperativeHandle2(ref, () => inputRef.current);
536
1300
  function handleChange(event) {
537
1301
  if (!isControlled) {
538
1302
  setInternalValue(event.currentTarget.value);
@@ -555,7 +1319,7 @@ var InputRoot = forwardRef2(({
555
1319
  });
556
1320
  input.focus();
557
1321
  }
558
- const control = /* @__PURE__ */ jsx3("input", {
1322
+ const control = /* @__PURE__ */ jsx4("input", {
559
1323
  ...props,
560
1324
  ref: inputRef,
561
1325
  type,
@@ -568,22 +1332,22 @@ var InputRoot = forwardRef2(({
568
1332
  return control;
569
1333
  }
570
1334
  const showClear = allowClear && !disabled && currentValue.length > 0;
571
- return /* @__PURE__ */ jsxs3("span", {
1335
+ return /* @__PURE__ */ jsxs4("span", {
572
1336
  className: getInputWrapperClasses({ affixed: hasAffix }),
573
1337
  children: [
574
- prefix != null ? /* @__PURE__ */ jsx3("span", {
1338
+ prefix != null ? /* @__PURE__ */ jsx4("span", {
575
1339
  className: inputPrefixClass,
576
1340
  children: prefix
577
1341
  }) : null,
578
1342
  control,
579
- showClear ? /* @__PURE__ */ jsx3("button", {
1343
+ showClear ? /* @__PURE__ */ jsx4("button", {
580
1344
  type: "button",
581
1345
  className: inputClearClass,
582
1346
  "aria-label": "Clear input",
583
1347
  onClick: handleClear,
584
1348
  children: "x"
585
1349
  }) : null,
586
- suffix != null ? /* @__PURE__ */ jsx3("span", {
1350
+ suffix != null ? /* @__PURE__ */ jsx4("span", {
587
1351
  className: inputSuffixClass,
588
1352
  children: suffix
589
1353
  }) : null
@@ -591,7 +1355,7 @@ var InputRoot = forwardRef2(({
591
1355
  });
592
1356
  });
593
1357
  InputRoot.displayName = "Input";
594
- var Search = forwardRef2(({
1358
+ var Search = forwardRef3(({
595
1359
  className,
596
1360
  disabled,
597
1361
  enterButton,
@@ -600,8 +1364,8 @@ var Search = forwardRef2(({
600
1364
  onSearch,
601
1365
  ...props
602
1366
  }, ref) => {
603
- const inputRef = useRef(null);
604
- useImperativeHandle(ref, () => inputRef.current);
1367
+ const inputRef = useRef2(null);
1368
+ useImperativeHandle2(ref, () => inputRef.current);
605
1369
  function emitSearch(event) {
606
1370
  onSearch?.(inputRef.current?.value ?? "", event);
607
1371
  }
@@ -612,16 +1376,16 @@ var Search = forwardRef2(({
612
1376
  }
613
1377
  }
614
1378
  const buttonContent = enterButton === true ? "Search" : enterButton ?? "Search";
615
- return /* @__PURE__ */ jsxs3("span", {
1379
+ return /* @__PURE__ */ jsxs4("span", {
616
1380
  className: getSearchWrapperClasses({ className }),
617
1381
  children: [
618
- /* @__PURE__ */ jsx3(InputRoot, {
1382
+ /* @__PURE__ */ jsx4(InputRoot, {
619
1383
  ...props,
620
1384
  ref: inputRef,
621
1385
  disabled,
622
1386
  onKeyDown: handleKeyDown
623
1387
  }),
624
- enterButton || loading ? /* @__PURE__ */ jsx3("button", {
1388
+ enterButton || loading ? /* @__PURE__ */ jsx4("button", {
625
1389
  type: "button",
626
1390
  className: inputSearchButtonClass,
627
1391
  disabled: disabled || loading,
@@ -633,10 +1397,10 @@ var Search = forwardRef2(({
633
1397
  });
634
1398
  });
635
1399
  Search.displayName = "Input.Search";
636
- var Password = forwardRef2(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
637
- const [visible, setVisible] = useState2(false);
1400
+ var Password = forwardRef3(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
1401
+ const [visible, setVisible] = useState4(false);
638
1402
  const type = visible ? "text" : "password";
639
- const toggle = visibilityToggle ? /* @__PURE__ */ jsx3("button", {
1403
+ const toggle = visibilityToggle ? /* @__PURE__ */ jsx4("button", {
640
1404
  type: "button",
641
1405
  className: inputPasswordToggleClass,
642
1406
  disabled,
@@ -646,9 +1410,9 @@ var Password = forwardRef2(({ className, disabled, visibilityToggle = true, ...p
646
1410
  },
647
1411
  children: visible ? "Hide" : "Show"
648
1412
  }) : undefined;
649
- return /* @__PURE__ */ jsx3("span", {
1413
+ return /* @__PURE__ */ jsx4("span", {
650
1414
  className: getPasswordWrapperClasses({ className }),
651
- children: /* @__PURE__ */ jsx3(InputRoot, {
1415
+ children: /* @__PURE__ */ jsx4(InputRoot, {
652
1416
  ...props,
653
1417
  ref,
654
1418
  disabled,
@@ -658,7 +1422,7 @@ var Password = forwardRef2(({ className, disabled, visibilityToggle = true, ...p
658
1422
  });
659
1423
  });
660
1424
  Password.displayName = "Input.Password";
661
- var TextArea = forwardRef2(({
1425
+ var TextArea = forwardRef3(({
662
1426
  autoSize,
663
1427
  className,
664
1428
  defaultValue,
@@ -672,7 +1436,7 @@ var TextArea = forwardRef2(({
672
1436
  variant = "outlined",
673
1437
  ...props
674
1438
  }, ref) => {
675
- const [internalValue, setInternalValue] = useState2(() => toTextValue(defaultValue));
1439
+ const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
676
1440
  const isControlled = value !== undefined;
677
1441
  const currentValue = isControlled ? toTextValue(value) : internalValue;
678
1442
  const count = currentValue.length;
@@ -683,7 +1447,7 @@ var TextArea = forwardRef2(({
683
1447
  }
684
1448
  onChange?.(event);
685
1449
  }
686
- const control = /* @__PURE__ */ jsx3("textarea", {
1450
+ const control = /* @__PURE__ */ jsx4("textarea", {
687
1451
  ...props,
688
1452
  ref,
689
1453
  className: getTextAreaClasses({
@@ -701,11 +1465,11 @@ var TextArea = forwardRef2(({
701
1465
  if (!showCount) {
702
1466
  return control;
703
1467
  }
704
- return /* @__PURE__ */ jsxs3("span", {
1468
+ return /* @__PURE__ */ jsxs4("span", {
705
1469
  className: textAreaWrapperClass,
706
1470
  children: [
707
1471
  control,
708
- /* @__PURE__ */ jsxs3("span", {
1472
+ /* @__PURE__ */ jsxs4("span", {
709
1473
  className: getTextAreaCountClasses({ exceeded }),
710
1474
  children: [
711
1475
  count,
@@ -716,7 +1480,7 @@ var TextArea = forwardRef2(({
716
1480
  });
717
1481
  });
718
1482
  TextArea.displayName = "Input.TextArea";
719
- var Group = forwardRef2(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx3("div", {
1483
+ var Group = forwardRef3(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx4("div", {
720
1484
  ...props,
721
1485
  ref,
722
1486
  className: cn(inputGroupClass, className),
@@ -730,7 +1494,7 @@ var Input = Object.assign(InputRoot, {
730
1494
  Group
731
1495
  });
732
1496
  // src/components/select/Select.tsx
733
- import React3, { forwardRef as forwardRef3, useMemo as useMemo2, useState as useState3 } from "react";
1497
+ import React5, { forwardRef as forwardRef4, useMemo as useMemo3, useState as useState5 } from "react";
734
1498
 
735
1499
  // src/classes/select.ts
736
1500
  var selectContainerClass = "select-container";
@@ -786,7 +1550,7 @@ function getSelectOptionClasses({
786
1550
  }
787
1551
 
788
1552
  // src/components/select/Select.tsx
789
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1553
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
790
1554
  function isGroup(option) {
791
1555
  return "options" in option;
792
1556
  }
@@ -811,8 +1575,8 @@ function normalizeMultiValue(value) {
811
1575
  }
812
1576
  function optionsFromChildren(children) {
813
1577
  const result = [];
814
- React3.Children.forEach(children, (child) => {
815
- if (!React3.isValidElement(child)) {
1578
+ React5.Children.forEach(children, (child) => {
1579
+ if (!React5.isValidElement(child)) {
816
1580
  return;
817
1581
  }
818
1582
  if (child.type === Option) {
@@ -862,19 +1626,19 @@ function filterOptions(options, searchValue, filterOption) {
862
1626
  function renderValue(option) {
863
1627
  return option ? optionLabel(option) : null;
864
1628
  }
865
- var Option = forwardRef3(({ children, ...props }, ref) => /* @__PURE__ */ jsx4("div", {
1629
+ var Option = forwardRef4(({ children, ...props }, ref) => /* @__PURE__ */ jsx5("div", {
866
1630
  ...props,
867
1631
  ref,
868
1632
  children
869
1633
  }));
870
1634
  Option.displayName = "Select.Option";
871
- var OptGroup = forwardRef3(({ children, ...props }, ref) => /* @__PURE__ */ jsx4("div", {
1635
+ var OptGroup = forwardRef4(({ children, ...props }, ref) => /* @__PURE__ */ jsx5("div", {
872
1636
  ...props,
873
1637
  ref,
874
1638
  children
875
1639
  }));
876
1640
  OptGroup.displayName = "Select.OptGroup";
877
- var SelectRoot = forwardRef3(({
1641
+ var SelectRoot = forwardRef4(({
878
1642
  allowClear,
879
1643
  children,
880
1644
  className,
@@ -893,11 +1657,11 @@ var SelectRoot = forwardRef3(({
893
1657
  ...props
894
1658
  }, ref) => {
895
1659
  const multiple = mode === "multiple" || mode === "tags";
896
- const sourceOptions = useMemo2(() => options ?? optionsFromChildren(children), [children, options]);
897
- const flatOptions = useMemo2(() => flattenOptions(sourceOptions), [sourceOptions]);
898
- const [open, setOpen] = useState3(false);
899
- const [searchValue, setSearchValue] = useState3("");
900
- const [internalValue, setInternalValue] = useState3(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
1660
+ const sourceOptions = useMemo3(() => options ?? optionsFromChildren(children), [children, options]);
1661
+ const flatOptions = useMemo3(() => flattenOptions(sourceOptions), [sourceOptions]);
1662
+ const [open, setOpen] = useState5(false);
1663
+ const [searchValue, setSearchValue] = useState5("");
1664
+ const [internalValue, setInternalValue] = useState5(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
901
1665
  const controlled = value !== undefined;
902
1666
  const currentValue = controlled ? value : internalValue;
903
1667
  const selectedValues = multiple ? normalizeMultiValue(currentValue) : normalizeSingleValue(currentValue) === undefined ? [] : [normalizeSingleValue(currentValue)];
@@ -954,7 +1718,7 @@ var SelectRoot = forwardRef3(({
954
1718
  }
955
1719
  function renderOption(option) {
956
1720
  const selected = selectedKeys.has(valueKey(option.value));
957
- return /* @__PURE__ */ jsx4("button", {
1721
+ return /* @__PURE__ */ jsx5("button", {
958
1722
  type: "button",
959
1723
  role: "option",
960
1724
  "aria-selected": selected,
@@ -973,11 +1737,11 @@ var SelectRoot = forwardRef3(({
973
1737
  if (!isGroup(option)) {
974
1738
  return renderOption(option);
975
1739
  }
976
- return /* @__PURE__ */ jsxs4("div", {
1740
+ return /* @__PURE__ */ jsxs5("div", {
977
1741
  className: cn(selectGroupClass, option.className),
978
1742
  role: "group",
979
1743
  children: [
980
- /* @__PURE__ */ jsx4("div", {
1744
+ /* @__PURE__ */ jsx5("div", {
981
1745
  className: selectGroupLabelClass,
982
1746
  children: option.label
983
1747
  }),
@@ -986,11 +1750,11 @@ var SelectRoot = forwardRef3(({
986
1750
  }, `group-${index}`);
987
1751
  });
988
1752
  }
989
- const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx4("span", {
1753
+ const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx5("span", {
990
1754
  className: selectTagClass,
991
1755
  children: renderValue(option)
992
1756
  }, valueKey(option.value))) : renderValue(selectedOptions[0]);
993
- return /* @__PURE__ */ jsxs4("div", {
1757
+ return /* @__PURE__ */ jsxs5("div", {
994
1758
  ...props,
995
1759
  ref,
996
1760
  className: getSelectContainerClasses({
@@ -1001,7 +1765,7 @@ var SelectRoot = forwardRef3(({
1001
1765
  className
1002
1766
  }),
1003
1767
  children: [
1004
- /* @__PURE__ */ jsxs4("button", {
1768
+ /* @__PURE__ */ jsxs5("button", {
1005
1769
  type: "button",
1006
1770
  className: getSelectClasses({ size, status, disabled }),
1007
1771
  disabled: disabled || loading,
@@ -1009,33 +1773,33 @@ var SelectRoot = forwardRef3(({
1009
1773
  "aria-expanded": open,
1010
1774
  onClick: () => setOpen((current) => !current),
1011
1775
  children: [
1012
- /* @__PURE__ */ jsx4("span", {
1776
+ /* @__PURE__ */ jsx5("span", {
1013
1777
  className: selectSelectionClass,
1014
- children: hasValue ? selection : /* @__PURE__ */ jsx4("span", {
1778
+ children: hasValue ? selection : /* @__PURE__ */ jsx5("span", {
1015
1779
  className: selectPlaceholderClass,
1016
1780
  children: placeholder
1017
1781
  })
1018
1782
  }),
1019
- /* @__PURE__ */ jsx4("span", {
1783
+ /* @__PURE__ */ jsx5("span", {
1020
1784
  className: selectIconClass,
1021
1785
  "aria-hidden": "true",
1022
1786
  children: "v"
1023
1787
  })
1024
1788
  ]
1025
1789
  }),
1026
- allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx4("button", {
1790
+ allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx5("button", {
1027
1791
  type: "button",
1028
1792
  className: selectClearClass,
1029
1793
  "aria-label": "Clear selection",
1030
1794
  onClick: clearValue,
1031
1795
  children: "x"
1032
1796
  }) : null,
1033
- open ? /* @__PURE__ */ jsxs4("div", {
1797
+ open ? /* @__PURE__ */ jsxs5("div", {
1034
1798
  className: selectDropdownClass,
1035
1799
  role: "listbox",
1036
1800
  "aria-multiselectable": multiple || undefined,
1037
1801
  children: [
1038
- searchable ? /* @__PURE__ */ jsx4("input", {
1802
+ searchable ? /* @__PURE__ */ jsx5("input", {
1039
1803
  className: selectSearchClass,
1040
1804
  value: searchValue,
1041
1805
  placeholder: typeof placeholder === "string" ? placeholder : undefined,
@@ -1047,7 +1811,7 @@ var SelectRoot = forwardRef3(({
1047
1811
  }
1048
1812
  }
1049
1813
  }) : null,
1050
- visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx4("div", {
1814
+ visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx5("div", {
1051
1815
  className: selectEmptyClass,
1052
1816
  children: "No data"
1053
1817
  })
@@ -1061,32 +1825,7 @@ var Select = SelectRoot;
1061
1825
  Select.Option = Option;
1062
1826
  Select.OptGroup = OptGroup;
1063
1827
  // src/components/dm-search/DmSearch.tsx
1064
- import {
1065
- forwardRef as forwardRef4,
1066
- useEffect,
1067
- useImperativeHandle as useImperativeHandle2,
1068
- useMemo as useMemo3,
1069
- useState as useState4
1070
- } from "react";
1071
-
1072
- // src/classes/dm-search.ts
1073
- var dmSearchBaseClass = "dm-search";
1074
- var dmSearchCompactClass = "dm-search-compact";
1075
- var dmSearchCollapsedClass = "dm-search-collapsed";
1076
- var dmSearchFieldsClass = "dm-search-fields";
1077
- var dmSearchFieldClass = "dm-search-field";
1078
- var dmSearchActionsClass = "dm-search-actions";
1079
- var dmSearchFastFilterClass = "dm-search-fast-filter";
1080
- function getDmSearchClasses({
1081
- compact,
1082
- collapsed,
1083
- className
1084
- }) {
1085
- return cn(dmSearchBaseClass, compact && dmSearchCompactClass, collapsed && dmSearchCollapsedClass, className);
1086
- }
1087
-
1088
- // src/components/dm-search/DmSearch.tsx
1089
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1828
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1090
1829
  function initialValues(items, searchParams, useSearchParams = true) {
1091
1830
  return items.reduce((acc, item) => {
1092
1831
  const defaultValue = item.search.extraProps?.value ?? item.search.formProps?.initialValue;
@@ -1110,7 +1849,7 @@ function renderField({
1110
1849
  return item.search.render?.(value, setValue, item) ?? null;
1111
1850
  }
1112
1851
  if (item.search.type === "select") {
1113
- return /* @__PURE__ */ jsx5(Select, {
1852
+ return /* @__PURE__ */ jsx6(Select, {
1114
1853
  ...extraProps,
1115
1854
  disabled: Boolean(loading || extraProps.disabled),
1116
1855
  value,
@@ -1119,25 +1858,25 @@ function renderField({
1119
1858
  });
1120
1859
  }
1121
1860
  if (item.search.type === "dateRange") {
1122
- return /* @__PURE__ */ jsx5(DatePicker.RangePicker, {
1861
+ return /* @__PURE__ */ jsx6(DatePicker.RangePicker, {
1123
1862
  ...extraProps,
1124
1863
  value,
1125
1864
  onChange: (nextValue) => setValue(nextValue)
1126
1865
  });
1127
1866
  }
1128
1867
  if (item.search.type === "date") {
1129
- return /* @__PURE__ */ jsx5(DatePicker, {
1868
+ return /* @__PURE__ */ jsx6(DatePicker, {
1130
1869
  ...extraProps,
1131
1870
  value,
1132
1871
  onChange: (nextValue) => setValue(nextValue)
1133
1872
  });
1134
1873
  }
1135
1874
  if (item.search.type === "radio" || item.search.type === "checkbox") {
1136
- return /* @__PURE__ */ jsx5("div", {
1875
+ return /* @__PURE__ */ jsx6("div", {
1137
1876
  role: item.search.type === "radio" ? "radiogroup" : "group",
1138
- children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs5("label", {
1877
+ children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs6("label", {
1139
1878
  children: [
1140
- /* @__PURE__ */ jsx5("input", {
1879
+ /* @__PURE__ */ jsx6("input", {
1141
1880
  type: item.search.type,
1142
1881
  disabled: loading,
1143
1882
  checked: item.search.type === "checkbox" ? Array.isArray(value) && value.includes(option.value) : value === option.value,
@@ -1155,7 +1894,7 @@ function renderField({
1155
1894
  }, String(option.value)))
1156
1895
  });
1157
1896
  }
1158
- return /* @__PURE__ */ jsx5(Input, {
1897
+ return /* @__PURE__ */ jsx6(Input, {
1159
1898
  ...extraProps,
1160
1899
  type: item.search.type === "input-number" ? "number" : "text",
1161
1900
  disabled: Boolean(loading || extraProps.disabled),
@@ -1169,8 +1908,11 @@ function renderField({
1169
1908
  }
1170
1909
  });
1171
1910
  }
1172
- var DmSearch = forwardRef4(({
1911
+ var DmSearch = forwardRef5(({
1173
1912
  items = [],
1913
+ values: controlledValues,
1914
+ onValuesChange,
1915
+ onReset,
1174
1916
  onSearch,
1175
1917
  extra,
1176
1918
  fastFilterItem,
@@ -1179,27 +1921,37 @@ var DmSearch = forwardRef4(({
1179
1921
  compact = false,
1180
1922
  searchParams,
1181
1923
  loading = false,
1924
+ noValidate,
1182
1925
  enableDefaultPlaceHolder = false,
1183
1926
  className
1184
1927
  }, ref) => {
1185
- const allItems = useMemo3(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
1186
- const [collapsed, setCollapsed] = useState4(defaultCollapsed);
1187
- const [values, setValues] = useState4(() => initialValues(allItems, searchParams));
1928
+ const allItems = useMemo4(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
1929
+ const [collapsed, setCollapsed] = useState6(defaultCollapsed);
1930
+ const [internalValues, setValues] = useState6(() => initialValues(allItems, searchParams));
1931
+ const controlled = controlledValues !== undefined;
1932
+ const values = controlled ? controlledValues : internalValues;
1188
1933
  const visibleItems = collapsed ? allItems.slice(0, 1) : allItems;
1189
- useEffect(() => {
1190
- setValues(initialValues(allItems, searchParams));
1191
- }, [allItems, searchParams]);
1934
+ useEffect2(() => {
1935
+ if (!controlled)
1936
+ setValues(initialValues(allItems, searchParams));
1937
+ }, [allItems, searchParams, controlled]);
1192
1938
  function reset(useSearchParams = false) {
1193
1939
  const nextValues = initialValues(allItems, searchParams, useSearchParams);
1194
- setValues(nextValues);
1940
+ if (!controlled)
1941
+ setValues(nextValues);
1942
+ if (onReset)
1943
+ onReset(nextValues);
1944
+ else if (controlled)
1945
+ onValuesChange?.(nextValues);
1195
1946
  return nextValues;
1196
1947
  }
1197
- useImperativeHandle2(ref, () => ({
1948
+ useImperativeHandle3(ref, () => ({
1198
1949
  onReset: () => {
1199
1950
  reset(false);
1200
1951
  }
1201
1952
  }));
1202
- return /* @__PURE__ */ jsxs5("form", {
1953
+ return /* @__PURE__ */ jsxs6("form", {
1954
+ noValidate,
1203
1955
  id: "searchForm",
1204
1956
  className: getDmSearchClasses({ compact, collapsed, className }),
1205
1957
  onSubmit: (event) => {
@@ -1207,53 +1959,63 @@ var DmSearch = forwardRef4(({
1207
1959
  onSearch?.(values);
1208
1960
  },
1209
1961
  children: [
1210
- fastFilterItem ? /* @__PURE__ */ jsx5("div", {
1962
+ fastFilterItem ? /* @__PURE__ */ jsx6("div", {
1211
1963
  className: dmSearchFastFilterClass,
1212
1964
  children: fastFilterItem.title
1213
1965
  }) : null,
1214
- /* @__PURE__ */ jsx5("div", {
1966
+ /* @__PURE__ */ jsx6("div", {
1215
1967
  className: dmSearchFieldsClass,
1216
- children: visibleItems.map((item) => /* @__PURE__ */ jsxs5("label", {
1217
- className: dmSearchFieldClass,
1218
- children: [
1219
- compact ? null : /* @__PURE__ */ jsx5("span", {
1220
- children: item.title
1221
- }),
1222
- renderField({
1223
- item,
1224
- value: values[item.dataIndex],
1225
- loading,
1226
- enableDefaultPlaceHolder,
1227
- setValue: (value) => setValues((current) => ({
1228
- ...current,
1229
- [item.dataIndex]: value
1230
- }))
1231
- })
1232
- ]
1233
- }, item.key))
1968
+ children: visibleItems.map((item) => {
1969
+ const Field = item.search.type === "custom" ? "div" : "label";
1970
+ return /* @__PURE__ */ jsxs6(Field, {
1971
+ className: dmSearchFieldClass,
1972
+ children: [
1973
+ compact ? null : /* @__PURE__ */ jsx6("span", {
1974
+ children: item.title
1975
+ }),
1976
+ renderField({
1977
+ item,
1978
+ value: values[item.dataIndex],
1979
+ loading,
1980
+ enableDefaultPlaceHolder,
1981
+ setValue: (value) => {
1982
+ const nextValues = { ...values, [item.dataIndex]: value };
1983
+ if (!controlled)
1984
+ setValues(nextValues);
1985
+ onValuesChange?.(nextValues);
1986
+ }
1987
+ })
1988
+ ]
1989
+ }, item.key);
1990
+ })
1234
1991
  }),
1235
- /* @__PURE__ */ jsxs5("div", {
1992
+ /* @__PURE__ */ jsxs6("div", {
1236
1993
  className: dmSearchActionsClass,
1237
1994
  children: [
1238
- /* @__PURE__ */ jsx5(Button, {
1995
+ /* @__PURE__ */ jsx6(Button, {
1239
1996
  type: "submit",
1240
1997
  isLoading: loading,
1241
1998
  children: "Search"
1242
1999
  }),
1243
- /* @__PURE__ */ jsx5(Button, {
2000
+ /* @__PURE__ */ jsx6(Button, {
1244
2001
  type: "button",
1245
2002
  color: "secondary",
1246
2003
  appearance: "outline",
1247
- onClick: () => onSearch?.(reset(false)),
2004
+ onClick: () => {
2005
+ const nextValues = reset(false);
2006
+ if (!onReset)
2007
+ onSearch?.(nextValues);
2008
+ },
1248
2009
  children: "Reset"
1249
2010
  }),
1250
- !hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx5(Button, {
2011
+ !hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx6(Button, {
1251
2012
  type: "button",
1252
2013
  color: "secondary",
1253
2014
  appearance: "text",
1254
2015
  onClick: () => {
1255
2016
  setCollapsed((current) => !current);
1256
- setValues(initialValues(allItems, searchParams));
2017
+ if (!controlled)
2018
+ setValues(initialValues(allItems, searchParams));
1257
2019
  },
1258
2020
  children: collapsed ? "Expand" : "Collapse"
1259
2021
  }) : null,
@@ -1265,13 +2027,7 @@ var DmSearch = forwardRef4(({
1265
2027
  });
1266
2028
  DmSearch.displayName = "DmSearch";
1267
2029
  // src/components/dm-query/DmQuery.tsx
1268
- import {
1269
- forwardRef as forwardRef5,
1270
- useImperativeHandle as useImperativeHandle3,
1271
- useRef as useRef2,
1272
- useState as useState5
1273
- } from "react";
1274
- import { jsx as jsx6, jsxs as jsxs6, Fragment } from "react/jsx-runtime";
2030
+ import { jsx as jsx7 } from "react/jsx-runtime";
1275
2031
  function toSearchItem(item) {
1276
2032
  return {
1277
2033
  key: item.key,
@@ -1280,11 +2036,12 @@ function toSearchItem(item) {
1280
2036
  search: {
1281
2037
  type: item.type,
1282
2038
  extraProps: item.extraProps,
1283
- formProps: item.customProps
2039
+ formProps: item.customProps,
2040
+ render: item.render
1284
2041
  }
1285
2042
  };
1286
2043
  }
1287
- var DmQuery = forwardRef5(({
2044
+ var DmQuery = forwardRef6(({
1288
2045
  queryItem,
1289
2046
  fastFilterItem,
1290
2047
  collapsed = false,
@@ -1292,35 +2049,23 @@ var DmQuery = forwardRef5(({
1292
2049
  onSearch,
1293
2050
  ...props
1294
2051
  }, ref) => {
1295
- const searchRef = useRef2(null);
1296
- const [selectedItem, setSelectedItem] = useState5(queryItem[0]);
2052
+ const searchRef = useRef3(null);
2053
+ const [selectedItem, setSelectedItem] = useState7(queryItem[0]);
1297
2054
  const items = selectedItem ? [toSearchItem(selectedItem)] : queryItem.map(toSearchItem);
1298
- useImperativeHandle3(ref, () => ({
2055
+ useImperativeHandle4(ref, () => ({
1299
2056
  onReset: () => searchRef.current?.onReset(),
1300
2057
  retractChange: (value, data = queryItem) => {
1301
2058
  setSelectedItem(data.find((item) => item.name === value || item.key === value));
1302
2059
  }
1303
2060
  }));
1304
- return /* @__PURE__ */ jsx6(DmSearch, {
2061
+ return /* @__PURE__ */ jsx7(DmSearch, {
1305
2062
  ...props,
1306
2063
  ref: searchRef,
1307
- defaultCollapsed: collapsed,
2064
+ defaultCollapsed: props.defaultCollapsed ?? collapsed,
1308
2065
  items: collapsed ? queryItem.map(toSearchItem) : items,
1309
2066
  fastFilterItem: fastFilterItem ? toSearchItem(fastFilterItem) : undefined,
1310
2067
  onSearch,
1311
- extra: /* @__PURE__ */ jsxs6(Fragment, {
1312
- children: [
1313
- props.extra,
1314
- /* @__PURE__ */ jsx6("button", {
1315
- type: "button",
1316
- hidden: true,
1317
- onClick: () => {
1318
- searchRef.current?.onReset();
1319
- onReset?.();
1320
- }
1321
- })
1322
- ]
1323
- })
2068
+ onReset
1324
2069
  });
1325
2070
  });
1326
2071
  DmQuery.displayName = "DmQuery";