@duskmoon-dev/components 0.3.3 → 0.4.1

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 (89) hide show
  1. package/README.md +142 -2
  2. package/dist/classes/chat.d.ts +9 -1
  3. package/dist/classes/console-page.d.ts +16 -0
  4. package/dist/classes/dropdown.d.ts +5 -5
  5. package/dist/classes/fab.d.ts +11 -0
  6. package/dist/classes/index.d.ts +5 -0
  7. package/dist/classes/index.js +180 -34
  8. package/dist/classes/megamenu.d.ts +10 -0
  9. package/dist/classes/otp-input.d.ts +12 -0
  10. package/dist/classes/popover.d.ts +1 -3
  11. package/dist/classes/swap.d.ts +12 -0
  12. package/dist/classes/tree-select.d.ts +6 -6
  13. package/dist/components/app/index.js +128 -68
  14. package/dist/components/avatar/Avatar.types.d.ts +1 -1
  15. package/dist/components/avatar/index.js +2 -1
  16. package/dist/components/badge/index.js +1 -1
  17. package/dist/components/button/Button.d.ts +1 -1
  18. package/dist/components/button/Button.types.d.ts +8 -0
  19. package/dist/components/button/index.js +253 -24
  20. package/dist/components/calendar/index.js +44 -19
  21. package/dist/components/chat/Chat.d.ts +9 -1
  22. package/dist/components/chat/Chat.types.d.ts +26 -0
  23. package/dist/components/chat/index.js +92 -3
  24. package/dist/components/color-picker/ColorPicker.types.d.ts +2 -1
  25. package/dist/components/color-picker/index.js +206 -9
  26. package/dist/components/console-page/ConsolePage.d.ts +2 -0
  27. package/dist/components/console-page/ConsolePage.types.d.ts +29 -0
  28. package/dist/components/console-page/index.d.ts +2 -0
  29. package/dist/components/console-page/index.js +205 -0
  30. package/dist/components/date-picker/DatePicker.types.d.ts +1 -0
  31. package/dist/components/date-picker/index.js +537 -35
  32. package/dist/components/date-picker/usePickerDropdown.d.ts +17 -0
  33. package/dist/components/dm-date-picker/index.js +545 -43
  34. package/dist/components/dm-drawer/index.js +253 -24
  35. package/dist/components/dm-layout/index.js +391 -24
  36. package/dist/components/dm-menu/index.js +380 -13
  37. package/dist/components/dm-page-header/index.js +404 -114
  38. package/dist/components/dm-pro-table/index.js +1195 -368
  39. package/dist/components/dm-query/DmQuery.types.d.ts +1 -1
  40. package/dist/components/dm-query/index.js +943 -188
  41. package/dist/components/dm-search/DmSearch.types.d.ts +4 -0
  42. package/dist/components/dm-search/index.js +929 -163
  43. package/dist/components/dm-table/index.js +1013 -247
  44. package/dist/components/dm-toolbar/index.js +400 -110
  45. package/dist/components/dm-truncate/index.js +115 -35
  46. package/dist/components/dropdown/Dropdown.types.d.ts +1 -1
  47. package/dist/components/dropdown/index.js +400 -110
  48. package/dist/components/fab/Fab.d.ts +4 -0
  49. package/dist/components/fab/Fab.types.d.ts +25 -0
  50. package/dist/components/fab/index.d.ts +2 -0
  51. package/dist/components/fab/index.js +480 -0
  52. package/dist/components/form/Form.types.d.ts +1 -0
  53. package/dist/components/form/index.js +14 -3
  54. package/dist/components/json-schema-form/JsonSchemaForm.d.ts +19 -0
  55. package/dist/components/json-schema-form/JsonSchemaWidget.d.ts +14 -0
  56. package/dist/components/json-schema-form/index.d.ts +8 -0
  57. package/dist/components/json-schema-form/index.js +7661 -0
  58. package/dist/components/json-schema-form/json-form-widgets.d.ts +26 -0
  59. package/dist/components/json-schema-form/json-schema-form.d.ts +50 -0
  60. package/dist/components/megamenu/Megamenu.d.ts +2 -0
  61. package/dist/components/megamenu/Megamenu.types.d.ts +32 -0
  62. package/dist/components/megamenu/index.d.ts +2 -0
  63. package/dist/components/megamenu/index.js +214 -0
  64. package/dist/components/modal/index.js +128 -68
  65. package/dist/components/otp-input/OtpInput.d.ts +2 -0
  66. package/dist/components/otp-input/OtpInput.types.d.ts +16 -0
  67. package/dist/components/otp-input/index.d.ts +2 -0
  68. package/dist/components/otp-input/index.js +112 -0
  69. package/dist/components/popconfirm/index.js +255 -26
  70. package/dist/components/popover/index.js +24 -4
  71. package/dist/components/select/index.js +12 -0
  72. package/dist/components/swap/Swap.d.ts +3 -0
  73. package/dist/components/swap/Swap.types.d.ts +22 -0
  74. package/dist/components/swap/index.d.ts +2 -0
  75. package/dist/components/swap/index.js +109 -0
  76. package/dist/components/time-picker/TimePicker.types.d.ts +1 -0
  77. package/dist/components/time-picker/index.js +167 -29
  78. package/dist/components/tooltip/Tooltip.types.d.ts +4 -0
  79. package/dist/components/tooltip/index.js +107 -27
  80. package/dist/components/tour/index.js +253 -24
  81. package/dist/components/tree-select/index.js +8 -8
  82. package/dist/components/upload/Upload.types.d.ts +1 -0
  83. package/dist/components/upload/index.js +2 -0
  84. package/dist/generated/version.d.ts +1 -1
  85. package/dist/index.d.ts +5 -0
  86. package/dist/index.js +3343 -1633
  87. package/dist/infrastructure.js +1 -1
  88. package/dist/styles.css +1359 -865
  89. package/package.json +31 -5
@@ -35,6 +35,10 @@ function getDmProTableClasses({ className }) {
35
35
  return cn(dmProTableBaseClass, className);
36
36
  }
37
37
 
38
+ // src/components/button/Button.tsx
39
+ import React from "react";
40
+ import { createPortal } from "react-dom";
41
+
38
42
  // src/classes/button.ts
39
43
  var buttonBaseClass = "btn";
40
44
  var buttonColorClasses = {
@@ -58,7 +62,7 @@ var buttonAppearanceClasses = {
58
62
  };
59
63
  var buttonShapeClasses = {
60
64
  rect: "",
61
- circle: "btn-circle",
65
+ circle: "btn-circle btn-icon",
62
66
  square: "btn-square"
63
67
  };
64
68
  var buttonSizeClasses = {
@@ -78,11 +82,14 @@ function getButtonClasses({
78
82
  isLoading,
79
83
  className
80
84
  }) {
81
- return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
85
+ 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);
82
86
  }
83
87
 
84
88
  // src/components/button/Button.tsx
85
- import { jsx, jsxs } from "react/jsx-runtime";
89
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
90
+ function isPromiseLike(value) {
91
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
92
+ }
86
93
  function Button({
87
94
  color = "primary",
88
95
  appearance = "filled",
@@ -96,8 +103,155 @@ function Button({
96
103
  children,
97
104
  disabled,
98
105
  ref,
106
+ confirm,
107
+ onClick,
99
108
  ...props
100
109
  }) {
110
+ const buttonRef = React.useRef(null);
111
+ const popoverRef = React.useRef(null);
112
+ const cancelRef = React.useRef(null);
113
+ const approvalRef = React.useRef("idle");
114
+ const pendingRef = React.useRef(false);
115
+ const actionRef = React.useRef(0);
116
+ const operationRef = React.useRef(0);
117
+ const mountedRef = React.useRef(false);
118
+ const [portalTarget, setPortalTarget] = React.useState(null);
119
+ const [confirmLoading, setConfirmLoading] = React.useState(false);
120
+ const [confirmError, setConfirmError] = React.useState(false);
121
+ const generatedId = React.useId().replace(/:/g, "");
122
+ const popoverId = `button-confirm-${generatedId}`;
123
+ const titleId = `${popoverId}-title`;
124
+ const descriptionId = `${popoverId}-description`;
125
+ const anchor = `--${popoverId}-anchor`;
126
+ const hasConfirm = Boolean(confirm);
127
+ const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
128
+ const title = confirmation ? confirmation.title : "Confirm action";
129
+ const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
130
+ const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
131
+ const hasContent = content !== undefined && content !== null && content !== false && content !== "";
132
+ const mergedRef = React.useCallback((node) => {
133
+ buttonRef.current = node;
134
+ if (!node) {
135
+ if (typeof ref === "function")
136
+ ref(null);
137
+ else if (ref)
138
+ ref.current = null;
139
+ return;
140
+ }
141
+ const cleanup = typeof ref === "function" ? ref(node) : undefined;
142
+ if (ref && typeof ref !== "function")
143
+ ref.current = node;
144
+ return () => {
145
+ buttonRef.current = null;
146
+ if (typeof cleanup === "function")
147
+ cleanup();
148
+ else if (typeof ref === "function")
149
+ ref(null);
150
+ else if (ref)
151
+ ref.current = null;
152
+ };
153
+ }, [ref]);
154
+ React.useEffect(() => {
155
+ mountedRef.current = true;
156
+ return () => {
157
+ mountedRef.current = false;
158
+ operationRef.current += 1;
159
+ };
160
+ }, []);
161
+ React.useEffect(() => {
162
+ operationRef.current += 1;
163
+ approvalRef.current = "idle";
164
+ setConfirmError(false);
165
+ setPortalTarget(hasConfirm ? document.body : null);
166
+ }, [hasConfirm]);
167
+ function closePopover() {
168
+ if (popoverRef.current?.matches(":popover-open")) {
169
+ popoverRef.current.hidePopover();
170
+ }
171
+ buttonRef.current?.focus();
172
+ }
173
+ function handleClick(event) {
174
+ if (!confirm) {
175
+ onClick?.(event);
176
+ return;
177
+ }
178
+ if (approvalRef.current === "native") {
179
+ approvalRef.current = "idle";
180
+ return;
181
+ }
182
+ if (approvalRef.current === "action") {
183
+ approvalRef.current = "idle";
184
+ let result;
185
+ try {
186
+ result = onClick?.(event);
187
+ } catch {
188
+ event.preventDefault();
189
+ pendingRef.current = false;
190
+ setConfirmError(true);
191
+ return;
192
+ }
193
+ if (!isPromiseLike(result)) {
194
+ pendingRef.current = false;
195
+ closePopover();
196
+ return;
197
+ }
198
+ const userPreventedDefault = event.defaultPrevented;
199
+ event.preventDefault();
200
+ setConfirmLoading(true);
201
+ const action = actionRef.current;
202
+ const operation = operationRef.current;
203
+ Promise.resolve(result).then(() => {
204
+ if (!mountedRef.current || action !== actionRef.current)
205
+ return;
206
+ pendingRef.current = false;
207
+ setConfirmLoading(false);
208
+ if (operation !== operationRef.current)
209
+ return;
210
+ closePopover();
211
+ if (!userPreventedDefault && !buttonRef.current?.disabled) {
212
+ approvalRef.current = "native";
213
+ buttonRef.current?.click();
214
+ approvalRef.current = "idle";
215
+ }
216
+ }, () => {
217
+ if (!mountedRef.current || action !== actionRef.current)
218
+ return;
219
+ pendingRef.current = false;
220
+ setConfirmLoading(false);
221
+ if (operation !== operationRef.current)
222
+ return;
223
+ setConfirmError(true);
224
+ cancelRef.current?.focus();
225
+ });
226
+ return;
227
+ }
228
+ event.preventDefault();
229
+ if (disabled || isLoading || pendingRef.current)
230
+ return;
231
+ if (popoverRef.current?.matches(":popover-open")) {
232
+ closePopover();
233
+ return;
234
+ }
235
+ setConfirmError(false);
236
+ popoverRef.current?.showPopover();
237
+ cancelRef.current?.focus();
238
+ }
239
+ function handleConfirm(event) {
240
+ event.preventDefault();
241
+ event.stopPropagation();
242
+ const trigger = buttonRef.current;
243
+ if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
244
+ return;
245
+ setConfirmError(false);
246
+ pendingRef.current = true;
247
+ actionRef.current += 1;
248
+ approvalRef.current = "action";
249
+ trigger.click();
250
+ if (approvalRef.current === "action") {
251
+ approvalRef.current = "idle";
252
+ pendingRef.current = false;
253
+ }
254
+ }
101
255
  const classes = getButtonClasses({
102
256
  color,
103
257
  appearance,
@@ -107,34 +261,109 @@ function Button({
107
261
  isLoading,
108
262
  className
109
263
  });
110
- return /* @__PURE__ */ jsxs("button", {
111
- ref,
112
- className: classes,
113
- disabled: disabled || isLoading,
114
- "aria-busy": isLoading,
115
- "aria-disabled": disabled || isLoading,
116
- ...props,
264
+ const confirmClasses = getButtonClasses({
265
+ color,
266
+ size: "sm",
267
+ isLoading: confirmLoading
268
+ });
269
+ return /* @__PURE__ */ jsxs(Fragment, {
117
270
  children: [
118
- isLoading && /* @__PURE__ */ jsx("span", {
119
- className: "btn-spinner"
120
- }),
121
- !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
122
- className: "btn-icon-left",
123
- children: leftIcon
124
- }),
125
- /* @__PURE__ */ jsx("span", {
126
- className: "btn-content",
127
- children
271
+ /* @__PURE__ */ jsxs("button", {
272
+ ref: confirm ? mergedRef : ref,
273
+ className: classes,
274
+ disabled: disabled || isLoading,
275
+ "aria-busy": isLoading,
276
+ "aria-disabled": disabled || isLoading,
277
+ ...props,
278
+ style: confirm ? { ...props.style, anchorName: anchor } : props.style,
279
+ "aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
280
+ "aria-controls": confirm ? popoverId : props["aria-controls"],
281
+ onClick: confirm ? handleClick : onClick,
282
+ children: [
283
+ isLoading && /* @__PURE__ */ jsx("span", {
284
+ className: "btn-spinner"
285
+ }),
286
+ !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
287
+ className: "btn-icon-left",
288
+ children: leftIcon
289
+ }),
290
+ /* @__PURE__ */ jsx("span", {
291
+ className: "btn-content",
292
+ children
293
+ }),
294
+ !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
295
+ className: "btn-icon-right",
296
+ children: rightIcon
297
+ })
298
+ ]
128
299
  }),
129
- !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
130
- className: "btn-icon-right",
131
- children: rightIcon
132
- })
300
+ confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
301
+ id: popoverId,
302
+ ref: popoverRef,
303
+ popover: "auto",
304
+ role: "dialog",
305
+ "aria-labelledby": hasTitle ? titleId : undefined,
306
+ "aria-label": hasTitle ? undefined : "Confirm action",
307
+ "aria-describedby": hasContent ? descriptionId : undefined,
308
+ className: "popover popover-confirm popover-bottom",
309
+ style: { positionAnchor: anchor },
310
+ onSubmit: handleConfirm,
311
+ onClick: (event) => event.stopPropagation(),
312
+ onToggle: (event) => {
313
+ if (!event.currentTarget.matches(":popover-open")) {
314
+ operationRef.current += 1;
315
+ if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
316
+ buttonRef.current?.focus();
317
+ }
318
+ }
319
+ },
320
+ children: [
321
+ hasTitle && /* @__PURE__ */ jsx("div", {
322
+ className: "popover-header",
323
+ children: /* @__PURE__ */ jsx("h3", {
324
+ id: titleId,
325
+ className: "popover-title",
326
+ children: title
327
+ })
328
+ }),
329
+ hasContent && /* @__PURE__ */ jsx("div", {
330
+ id: descriptionId,
331
+ className: "popover-body",
332
+ children: content
333
+ }),
334
+ confirmError && /* @__PURE__ */ jsx("div", {
335
+ role: "alert",
336
+ className: "popover-body",
337
+ children: "The action failed. Please try again."
338
+ }),
339
+ /* @__PURE__ */ jsxs("div", {
340
+ className: "popover-footer",
341
+ children: [
342
+ /* @__PURE__ */ jsx("button", {
343
+ ref: cancelRef,
344
+ type: "button",
345
+ className: "btn btn-text btn-sm",
346
+ popoverTarget: popoverId,
347
+ popoverTargetAction: "hide",
348
+ disabled: confirmLoading,
349
+ children: confirmation?.cancelText ?? "Cancel"
350
+ }),
351
+ /* @__PURE__ */ jsx("button", {
352
+ type: "submit",
353
+ className: confirmClasses,
354
+ disabled: disabled || isLoading || confirmLoading,
355
+ "aria-busy": confirmLoading,
356
+ children: confirmation?.confirmText ?? "Confirm"
357
+ })
358
+ ]
359
+ })
360
+ ]
361
+ }), portalTarget)
133
362
  ]
134
363
  });
135
364
  }
136
365
  // src/components/dm-table/DmTable.tsx
137
- import { useMemo as useMemo7, useState as useState8 } from "react";
366
+ import { useMemo as useMemo8, useState as useState10 } from "react";
138
367
 
139
368
  // src/classes/dm-table.ts
140
369
  var dmTableBaseClass = "dm-table";
@@ -635,11 +864,11 @@ var DmPagination = forwardRef2(({
635
864
  DmPagination.displayName = "DmPagination";
636
865
  // src/components/dm-search/DmSearch.tsx
637
866
  import {
638
- forwardRef as forwardRef6,
639
- useEffect as useEffect2,
640
- useImperativeHandle as useImperativeHandle2,
641
- useMemo as useMemo5,
642
- useState as useState6
867
+ forwardRef as forwardRef7,
868
+ useEffect as useEffect3,
869
+ useImperativeHandle as useImperativeHandle3,
870
+ useMemo as useMemo6,
871
+ useState as useState8
643
872
  } from "react";
644
873
 
645
874
  // src/classes/dm-search.ts
@@ -659,8 +888,425 @@ function getDmSearchClasses({
659
888
  }
660
889
 
661
890
  // src/components/date-picker/DatePicker.tsx
891
+ import { forwardRef as forwardRef4, useMemo as useMemo4, useState as useState5 } from "react";
892
+
893
+ // src/components/calendar/Calendar.tsx
662
894
  import { forwardRef as forwardRef3, useMemo as useMemo3, useState as useState3 } from "react";
663
895
 
896
+ // src/classes/calendar.ts
897
+ var calendarBaseClass = "datepicker calendar";
898
+ var calendarHeaderClass = "calendar-header";
899
+ var calendarTitleClass = "calendar-title";
900
+ var calendarControlsClass = "calendar-controls";
901
+ var calendarNavClass = "calendar-nav";
902
+ var calendarModeClass = "calendar-mode";
903
+ var calendarWeekdaysClass = "calendar-weekdays";
904
+ var calendarWeekdayClass = "calendar-weekday";
905
+ var calendarBodyClass = "calendar-body";
906
+ var calendarDateGridClass = "calendar-date-grid";
907
+ var calendarMonthGridClass = "calendar-month-grid";
908
+ var calendarCellContentClass = "calendar-cell-content";
909
+ function getCalendarClasses({
910
+ fullscreen = true,
911
+ mode = "month",
912
+ className
913
+ }) {
914
+ return cn(calendarBaseClass, fullscreen ? "calendar-fullscreen" : "calendar-card", mode === "year" && "calendar-year-mode", className);
915
+ }
916
+ function getCalendarCellClasses({
917
+ selected,
918
+ today,
919
+ outside,
920
+ disabled,
921
+ className
922
+ }) {
923
+ return cn("calendar-cell", selected && "calendar-cell-selected", today && "calendar-cell-today", outside && "calendar-cell-outside", disabled && "calendar-cell-disabled", className);
924
+ }
925
+
926
+ // src/components/calendar/Calendar.tsx
927
+ import { jsx as jsx5, jsxs as jsxs4, Fragment as Fragment2 } from "react/jsx-runtime";
928
+ var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
929
+ var MONTHS = [
930
+ "Jan",
931
+ "Feb",
932
+ "Mar",
933
+ "Apr",
934
+ "May",
935
+ "Jun",
936
+ "Jul",
937
+ "Aug",
938
+ "Sep",
939
+ "Oct",
940
+ "Nov",
941
+ "Dec"
942
+ ];
943
+ function pad(value) {
944
+ return String(value).padStart(2, "0");
945
+ }
946
+ function formatDate(date) {
947
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
948
+ }
949
+ function formatMonth(date) {
950
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-01`;
951
+ }
952
+ function parseDate(value) {
953
+ if (value instanceof Date && !Number.isNaN(value.getTime())) {
954
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
955
+ }
956
+ if (typeof value === "string" && value.length > 0) {
957
+ const [year, month = "1", day = "1"] = value.split("-");
958
+ const parsed = new Date(Number(year), Number(month) - 1, Number(day));
959
+ if (!Number.isNaN(parsed.getTime())) {
960
+ return parsed;
961
+ }
962
+ }
963
+ const today = new Date;
964
+ return new Date(today.getFullYear(), today.getMonth(), today.getDate());
965
+ }
966
+ function addMonths(date, amount) {
967
+ return new Date(date.getFullYear(), date.getMonth() + amount, 1);
968
+ }
969
+ function addYears(date, amount) {
970
+ return new Date(date.getFullYear() + amount, date.getMonth(), 1);
971
+ }
972
+ function startOfCalendarGrid(panelDate) {
973
+ const firstOfMonth = new Date(panelDate.getFullYear(), panelDate.getMonth(), 1);
974
+ const start = new Date(firstOfMonth);
975
+ start.setDate(firstOfMonth.getDate() - firstOfMonth.getDay());
976
+ return start;
977
+ }
978
+ function buildDateGrid(panelDate) {
979
+ const start = startOfCalendarGrid(panelDate);
980
+ return Array.from({ length: 42 }, (_, index) => {
981
+ const date = new Date(start);
982
+ date.setDate(start.getDate() + index);
983
+ return date;
984
+ });
985
+ }
986
+ function isSameMonth(left, right) {
987
+ return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();
988
+ }
989
+ function isOutsideRange(date, validRange) {
990
+ if (!validRange) {
991
+ return false;
992
+ }
993
+ const current = formatDate(date);
994
+ const start = formatDate(parseDate(validRange[0]));
995
+ const end = formatDate(parseDate(validRange[1]));
996
+ return current < start || current > end;
997
+ }
998
+ function Header({
999
+ panelDate,
1000
+ mode,
1001
+ setPanelDate,
1002
+ setMode
1003
+ }) {
1004
+ const title = mode === "year" ? String(panelDate.getFullYear()) : `${MONTHS[panelDate.getMonth()]} ${panelDate.getFullYear()}`;
1005
+ return /* @__PURE__ */ jsxs4("div", {
1006
+ className: calendarHeaderClass,
1007
+ children: [
1008
+ /* @__PURE__ */ jsx5("button", {
1009
+ type: "button",
1010
+ className: calendarNavClass,
1011
+ "aria-label": "Previous panel",
1012
+ onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, -1) : addMonths(panelDate, -1), mode),
1013
+ children: /* @__PURE__ */ jsx5("svg", {
1014
+ "aria-hidden": "true",
1015
+ focusable: "false",
1016
+ width: "16",
1017
+ height: "16",
1018
+ viewBox: "0 0 24 24",
1019
+ fill: "none",
1020
+ stroke: "currentColor",
1021
+ strokeWidth: "2",
1022
+ strokeLinecap: "round",
1023
+ strokeLinejoin: "round",
1024
+ children: /* @__PURE__ */ jsx5("path", {
1025
+ d: "m15 18-6-6 6-6"
1026
+ })
1027
+ })
1028
+ }),
1029
+ /* @__PURE__ */ jsxs4("div", {
1030
+ className: calendarControlsClass,
1031
+ children: [
1032
+ /* @__PURE__ */ jsx5("div", {
1033
+ className: calendarTitleClass,
1034
+ children: title
1035
+ }),
1036
+ /* @__PURE__ */ jsxs4("div", {
1037
+ className: calendarModeClass,
1038
+ children: [
1039
+ /* @__PURE__ */ jsx5("button", {
1040
+ type: "button",
1041
+ "aria-pressed": mode === "month",
1042
+ onClick: () => setMode("month"),
1043
+ children: "Month"
1044
+ }),
1045
+ /* @__PURE__ */ jsx5("button", {
1046
+ type: "button",
1047
+ "aria-pressed": mode === "year",
1048
+ onClick: () => setMode("year"),
1049
+ children: "Year"
1050
+ })
1051
+ ]
1052
+ })
1053
+ ]
1054
+ }),
1055
+ /* @__PURE__ */ jsx5("button", {
1056
+ type: "button",
1057
+ className: calendarNavClass,
1058
+ "aria-label": "Next panel",
1059
+ onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, 1) : addMonths(panelDate, 1), mode),
1060
+ children: /* @__PURE__ */ jsx5("svg", {
1061
+ "aria-hidden": "true",
1062
+ focusable: "false",
1063
+ width: "16",
1064
+ height: "16",
1065
+ viewBox: "0 0 24 24",
1066
+ fill: "none",
1067
+ stroke: "currentColor",
1068
+ strokeWidth: "2",
1069
+ strokeLinecap: "round",
1070
+ strokeLinejoin: "round",
1071
+ children: /* @__PURE__ */ jsx5("path", {
1072
+ d: "m9 18 6-6-6-6"
1073
+ })
1074
+ })
1075
+ })
1076
+ ]
1077
+ });
1078
+ }
1079
+ var Calendar = forwardRef3(({
1080
+ className,
1081
+ value,
1082
+ defaultValue,
1083
+ mode,
1084
+ defaultMode = "month",
1085
+ fullscreen = true,
1086
+ validRange,
1087
+ disabledDate,
1088
+ dateCellRender,
1089
+ dateFullCellRender,
1090
+ monthCellRender,
1091
+ monthFullCellRender,
1092
+ cellRender,
1093
+ fullCellRender,
1094
+ headerRender,
1095
+ onChange,
1096
+ onSelect,
1097
+ onPanelChange,
1098
+ ...props
1099
+ }, ref) => {
1100
+ const selectedDate = parseDate(value ?? defaultValue);
1101
+ const [innerValue, setInnerValue] = useState3(() => formatDate(selectedDate));
1102
+ const [panelDate, setInnerPanelDate] = useState3(selectedDate);
1103
+ const [innerMode, setInnerMode] = useState3(mode ?? defaultMode);
1104
+ const currentMode = mode ?? innerMode;
1105
+ const currentValue = value === undefined ? innerValue : formatDate(parseDate(value));
1106
+ const today = useMemo3(() => formatDate(new Date), []);
1107
+ const dateGrid = useMemo3(() => buildDateGrid(panelDate), [panelDate]);
1108
+ function emitPanelChange(nextDate, nextMode = currentMode) {
1109
+ setInnerPanelDate(nextDate);
1110
+ onPanelChange?.(formatDate(nextDate), nextMode);
1111
+ }
1112
+ function setCalendarMode(nextMode) {
1113
+ if (mode === undefined) {
1114
+ setInnerMode(nextMode);
1115
+ }
1116
+ onPanelChange?.(formatDate(panelDate), nextMode);
1117
+ }
1118
+ function commitValue(nextDate, source) {
1119
+ const nextValue = source === "month" ? formatMonth(nextDate) : formatDate(nextDate);
1120
+ if (disabledDate?.(nextValue) || isOutsideRange(nextDate, validRange)) {
1121
+ return;
1122
+ }
1123
+ if (value === undefined) {
1124
+ setInnerValue(nextValue);
1125
+ }
1126
+ setInnerPanelDate(nextDate);
1127
+ onSelect?.(nextValue, { source });
1128
+ onChange?.(nextValue);
1129
+ }
1130
+ function renderDateCell(date) {
1131
+ const dateValue = formatDate(date);
1132
+ const originNode = /* @__PURE__ */ jsxs4("div", {
1133
+ className: calendarCellContentClass,
1134
+ children: [
1135
+ /* @__PURE__ */ jsx5("span", {
1136
+ children: date.getDate()
1137
+ }),
1138
+ dateCellRender?.(dateValue)
1139
+ ]
1140
+ });
1141
+ const info = {
1142
+ originNode,
1143
+ today,
1144
+ type: "month"
1145
+ };
1146
+ const content = fullCellRender?.(dateValue, info) ?? dateFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
1147
+ const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
1148
+ return /* @__PURE__ */ jsx5("button", {
1149
+ type: "button",
1150
+ "aria-label": dateValue,
1151
+ disabled,
1152
+ className: getCalendarCellClasses({
1153
+ selected: dateValue === currentValue,
1154
+ today: dateValue === today,
1155
+ outside: !isSameMonth(date, panelDate),
1156
+ disabled
1157
+ }),
1158
+ onClick: () => commitValue(date, "date"),
1159
+ children: content
1160
+ }, dateValue);
1161
+ }
1162
+ function renderMonthCell(month) {
1163
+ const date = new Date(panelDate.getFullYear(), month, 1);
1164
+ const dateValue = formatMonth(date);
1165
+ const originNode = /* @__PURE__ */ jsxs4("div", {
1166
+ className: calendarCellContentClass,
1167
+ children: [
1168
+ /* @__PURE__ */ jsx5("span", {
1169
+ children: MONTHS[month]
1170
+ }),
1171
+ monthCellRender?.(dateValue)
1172
+ ]
1173
+ });
1174
+ const info = {
1175
+ originNode,
1176
+ today,
1177
+ type: "year"
1178
+ };
1179
+ const content = fullCellRender?.(dateValue, info) ?? monthFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
1180
+ const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
1181
+ return /* @__PURE__ */ jsx5("button", {
1182
+ type: "button",
1183
+ "aria-label": dateValue,
1184
+ disabled,
1185
+ className: getCalendarCellClasses({
1186
+ selected: dateValue === formatMonth(parseDate(currentValue)),
1187
+ today: dateValue === formatMonth(new Date),
1188
+ disabled
1189
+ }),
1190
+ onClick: () => commitValue(date, "month"),
1191
+ children: content
1192
+ }, dateValue);
1193
+ }
1194
+ return /* @__PURE__ */ jsxs4("div", {
1195
+ ...props,
1196
+ ref,
1197
+ className: getCalendarClasses({
1198
+ fullscreen,
1199
+ mode: currentMode,
1200
+ className
1201
+ }),
1202
+ children: [
1203
+ headerRender ? headerRender({
1204
+ value: formatDate(panelDate),
1205
+ type: currentMode,
1206
+ onChange: (nextValue) => emitPanelChange(parseDate(nextValue)),
1207
+ onTypeChange: setCalendarMode
1208
+ }) : /* @__PURE__ */ jsx5(Header, {
1209
+ panelDate,
1210
+ mode: currentMode,
1211
+ setPanelDate: emitPanelChange,
1212
+ setMode: setCalendarMode
1213
+ }),
1214
+ /* @__PURE__ */ jsx5("div", {
1215
+ className: calendarBodyClass,
1216
+ children: currentMode === "month" ? /* @__PURE__ */ jsxs4(Fragment2, {
1217
+ children: [
1218
+ /* @__PURE__ */ jsx5("div", {
1219
+ className: calendarWeekdaysClass,
1220
+ "aria-hidden": "true",
1221
+ children: WEEKDAYS.map((weekday) => /* @__PURE__ */ jsx5("span", {
1222
+ className: calendarWeekdayClass,
1223
+ children: weekday
1224
+ }, weekday))
1225
+ }),
1226
+ /* @__PURE__ */ jsx5("div", {
1227
+ className: calendarDateGridClass,
1228
+ children: dateGrid.map(renderDateCell)
1229
+ })
1230
+ ]
1231
+ }) : /* @__PURE__ */ jsx5("div", {
1232
+ className: calendarMonthGridClass,
1233
+ children: MONTHS.map((_, month) => renderMonthCell(month))
1234
+ })
1235
+ })
1236
+ ]
1237
+ });
1238
+ });
1239
+ Calendar.displayName = "Calendar";
1240
+ // src/components/date-picker/usePickerDropdown.ts
1241
+ import { useEffect as useEffect2, useId, useImperativeHandle, useRef as useRef2, useState as useState4 } from "react";
1242
+ function usePickerDropdown({
1243
+ open,
1244
+ defaultOpen,
1245
+ disabled,
1246
+ onOpenChange,
1247
+ ref
1248
+ }) {
1249
+ const rootRef = useRef2(null);
1250
+ const inputRef = useRef2(null);
1251
+ const skipFocus = useRef2(false);
1252
+ const panelId = useId();
1253
+ const [innerOpen, setInnerOpen] = useState4(Boolean(defaultOpen));
1254
+ const visible = !disabled && (open ?? innerOpen);
1255
+ useImperativeHandle(ref, () => rootRef.current, []);
1256
+ function setVisible(next) {
1257
+ if (disabled || next === visible)
1258
+ return;
1259
+ if (open === undefined)
1260
+ setInnerOpen(next);
1261
+ onOpenChange?.(next);
1262
+ }
1263
+ function closeAndFocus() {
1264
+ skipFocus.current = true;
1265
+ inputRef.current?.focus();
1266
+ skipFocus.current = false;
1267
+ setVisible(false);
1268
+ }
1269
+ useEffect2(() => {
1270
+ function handleOutside(event) {
1271
+ if (visible && !rootRef.current?.contains(event.target))
1272
+ setVisible(false);
1273
+ }
1274
+ function handleKeyDown(event) {
1275
+ if (event.defaultPrevented || !rootRef.current?.contains(event.target))
1276
+ return;
1277
+ if (event.key === "Escape" && visible) {
1278
+ event.preventDefault();
1279
+ closeAndFocus();
1280
+ } else if (event.key === "ArrowDown" && event.target === inputRef.current) {
1281
+ event.preventDefault();
1282
+ setVisible(true);
1283
+ }
1284
+ }
1285
+ document.addEventListener("pointerdown", handleOutside);
1286
+ document.addEventListener("keydown", handleKeyDown);
1287
+ return () => {
1288
+ document.removeEventListener("pointerdown", handleOutside);
1289
+ document.removeEventListener("keydown", handleKeyDown);
1290
+ };
1291
+ });
1292
+ return {
1293
+ rootRef,
1294
+ inputRef,
1295
+ panelId,
1296
+ visible,
1297
+ setVisible,
1298
+ closeAndFocus,
1299
+ onInputFocus: () => {
1300
+ if (!skipFocus.current)
1301
+ setVisible(true);
1302
+ },
1303
+ onRootBlur: (event) => {
1304
+ if (!event.currentTarget.contains(event.relatedTarget))
1305
+ setVisible(false);
1306
+ }
1307
+ };
1308
+ }
1309
+
664
1310
  // src/classes/date-picker.ts
665
1311
  var datePickerBaseClass = "datepicker";
666
1312
  var datePickerInputClass = "datepicker-input";
@@ -708,7 +1354,7 @@ function getDatePickerDropdownClasses({
708
1354
  }
709
1355
 
710
1356
  // src/components/date-picker/DatePicker.tsx
711
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1357
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
712
1358
  function todayValue(picker) {
713
1359
  const today = new Date;
714
1360
  const year = today.getFullYear();
@@ -747,9 +1393,10 @@ function placeholderForPicker(picker) {
747
1393
  function normalizeDateValue(value) {
748
1394
  return typeof value === "string" && value.length > 0 ? value : undefined;
749
1395
  }
750
- var DatePickerRoot = forwardRef3(({
1396
+ var DatePickerRoot = forwardRef4(({
751
1397
  allowClear,
752
1398
  className,
1399
+ inputProps,
753
1400
  defaultOpen,
754
1401
  defaultValue,
755
1402
  disabled,
@@ -768,19 +1415,19 @@ var DatePickerRoot = forwardRef3(({
768
1415
  value,
769
1416
  ...props
770
1417
  }, ref) => {
1418
+ const [calendarMode, setCalendarMode] = useState5("month");
771
1419
  const isValueControlled = value !== undefined;
772
- const isOpenControlled = open !== undefined;
773
- const [innerValue, setInnerValue] = useState3(() => normalizeDateValue(defaultValue));
774
- const [innerOpen, setInnerOpen] = useState3(Boolean(defaultOpen));
1420
+ const [innerValue, setInnerValue] = useState5(() => normalizeDateValue(defaultValue));
1421
+ const dropdown = usePickerDropdown({
1422
+ open,
1423
+ defaultOpen,
1424
+ disabled,
1425
+ onOpenChange,
1426
+ ref
1427
+ });
775
1428
  const currentValue = isValueControlled ? normalizeDateValue(value) : innerValue;
776
- const visible = isOpenControlled ? Boolean(open) : innerOpen;
1429
+ const { visible, setVisible } = dropdown;
777
1430
  const inputType = inputTypeForPicker(picker);
778
- function setVisible(nextOpen) {
779
- if (!isOpenControlled) {
780
- setInnerOpen(nextOpen);
781
- }
782
- onOpenChange?.(nextOpen);
783
- }
784
1431
  function emitChange(nextValue) {
785
1432
  if (nextValue && disabledDate?.(nextValue)) {
786
1433
  return;
@@ -790,10 +1437,17 @@ var DatePickerRoot = forwardRef3(({
790
1437
  }
791
1438
  onChange?.(nextValue, nextValue ?? "");
792
1439
  }
793
- const presetItems = useMemo3(() => presets ?? [], [presets]);
794
- return /* @__PURE__ */ jsxs4("div", {
1440
+ function selectValue(nextValue) {
1441
+ if (disabledDate?.(nextValue))
1442
+ return;
1443
+ emitChange(nextValue);
1444
+ dropdown.closeAndFocus();
1445
+ }
1446
+ const presetItems = useMemo4(() => presets ?? [], [presets]);
1447
+ return /* @__PURE__ */ jsxs5("div", {
795
1448
  ...props,
796
- ref,
1449
+ ref: dropdown.rootRef,
1450
+ onBlur: dropdown.onRootBlur,
797
1451
  className: getDatePickerClasses({
798
1452
  size,
799
1453
  status,
@@ -803,7 +1457,11 @@ var DatePickerRoot = forwardRef3(({
803
1457
  className
804
1458
  }),
805
1459
  children: [
806
- /* @__PURE__ */ jsx5("input", {
1460
+ /* @__PURE__ */ jsx6("input", {
1461
+ ...inputProps,
1462
+ ref: dropdown.inputRef,
1463
+ "aria-haspopup": "dialog",
1464
+ "aria-controls": visible ? dropdown.panelId : undefined,
807
1465
  className: datePickerInputClass,
808
1466
  disabled,
809
1467
  type: inputType,
@@ -811,15 +1469,15 @@ var DatePickerRoot = forwardRef3(({
811
1469
  placeholder: placeholder ?? placeholderForPicker(picker),
812
1470
  onFocus: (event) => {
813
1471
  onFocus?.(event);
814
- setVisible(true);
1472
+ dropdown.onInputFocus();
815
1473
  },
816
1474
  onBlur: (event) => {
817
1475
  onBlur?.(event);
818
- setVisible(false);
819
1476
  },
1477
+ onClick: () => setVisible(true),
820
1478
  onChange: (event) => emitChange(event.currentTarget.value || undefined)
821
1479
  }),
822
- allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx5("button", {
1480
+ allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx6("button", {
823
1481
  type: "button",
824
1482
  className: datePickerClearClass,
825
1483
  "aria-label": "Clear date",
@@ -827,26 +1485,95 @@ var DatePickerRoot = forwardRef3(({
827
1485
  onClick: () => emitChange(undefined),
828
1486
  children: "x"
829
1487
  }) : null,
830
- /* @__PURE__ */ jsx5("span", {
1488
+ /* @__PURE__ */ jsx6("button", {
1489
+ type: "button",
831
1490
  className: datePickerIconClass,
832
- "aria-hidden": "true"
1491
+ "aria-label": "Open date picker",
1492
+ "aria-haspopup": "dialog",
1493
+ "aria-expanded": visible,
1494
+ "aria-controls": visible ? dropdown.panelId : undefined,
1495
+ disabled,
1496
+ onMouseDown: (event) => event.preventDefault(),
1497
+ onClick: () => setVisible(!visible),
1498
+ children: /* @__PURE__ */ jsxs5("svg", {
1499
+ "aria-hidden": "true",
1500
+ focusable: "false",
1501
+ width: "18",
1502
+ height: "18",
1503
+ viewBox: "0 0 24 24",
1504
+ fill: "none",
1505
+ stroke: "currentColor",
1506
+ strokeWidth: "1.75",
1507
+ strokeLinecap: "round",
1508
+ strokeLinejoin: "round",
1509
+ children: [
1510
+ /* @__PURE__ */ jsx6("rect", {
1511
+ x: "3",
1512
+ y: "5",
1513
+ width: "18",
1514
+ height: "16",
1515
+ rx: "2"
1516
+ }),
1517
+ /* @__PURE__ */ jsx6("path", {
1518
+ d: "M8 3v4M16 3v4M3 10h18"
1519
+ })
1520
+ ]
1521
+ })
833
1522
  }),
834
- (presetItems.length > 0 || showNow) && visible ? /* @__PURE__ */ jsxs4("div", {
1523
+ visible ? /* @__PURE__ */ jsxs5("div", {
1524
+ id: dropdown.panelId,
1525
+ role: "dialog",
1526
+ "aria-label": "Choose date",
835
1527
  className: getDatePickerDropdownClasses({ open: visible }),
836
1528
  children: [
837
- presetItems.map((preset, index) => /* @__PURE__ */ jsx5("button", {
1529
+ picker === "date" || picker === "month" ? /* @__PURE__ */ jsx6(Calendar, {
1530
+ fullscreen: false,
1531
+ value: currentValue,
1532
+ mode: picker === "month" ? "year" : calendarMode,
1533
+ onPanelChange: (_, mode) => {
1534
+ if (picker === "date")
1535
+ setCalendarMode(mode);
1536
+ },
1537
+ disabledDate: (date) => {
1538
+ if (!disabledDate)
1539
+ return false;
1540
+ if (picker === "month")
1541
+ return disabledDate(date.slice(0, 7));
1542
+ if (calendarMode === "year") {
1543
+ const [year, month] = date.split("-").map(Number);
1544
+ const days = new Date(year, month, 0).getDate();
1545
+ return Array.from({ length: days }, (_, index) => `${date.slice(0, 7)}-${String(index + 1).padStart(2, "0")}`).every((day) => disabledDate(day));
1546
+ }
1547
+ return disabledDate(date);
1548
+ },
1549
+ onSelect: (date, info) => {
1550
+ if (picker === "date" && info.source === "month") {
1551
+ setCalendarMode("month");
1552
+ return;
1553
+ }
1554
+ selectValue(picker === "month" ? date.slice(0, 7) : date);
1555
+ }
1556
+ }) : /* @__PURE__ */ jsx6("input", {
1557
+ type: inputType,
1558
+ "aria-label": placeholderForPicker(picker),
1559
+ value: currentValue ?? "",
1560
+ onChange: (event) => selectValue(event.currentTarget.value)
1561
+ }),
1562
+ presetItems.map((preset, index) => /* @__PURE__ */ jsx6("button", {
838
1563
  type: "button",
839
1564
  className: datePickerPresetClass,
840
1565
  onMouseDown: (event) => event.preventDefault(),
841
- onClick: () => emitChange(preset.value),
1566
+ disabled: Boolean(disabledDate?.(preset.value)),
1567
+ onClick: () => selectValue(preset.value),
842
1568
  children: preset.label
843
1569
  }, index)),
844
- showNow ? /* @__PURE__ */ jsx5("div", {
1570
+ showNow ? /* @__PURE__ */ jsx6("div", {
845
1571
  className: datePickerFooterClass,
846
- children: /* @__PURE__ */ jsx5("button", {
1572
+ children: /* @__PURE__ */ jsx6("button", {
847
1573
  type: "button",
848
1574
  onMouseDown: (event) => event.preventDefault(),
849
- onClick: () => emitChange(todayValue(picker)),
1575
+ disabled: Boolean(disabledDate?.(todayValue(picker))),
1576
+ onClick: () => selectValue(todayValue(picker)),
850
1577
  children: "Now"
851
1578
  })
852
1579
  }) : null
@@ -856,9 +1583,10 @@ var DatePickerRoot = forwardRef3(({
856
1583
  });
857
1584
  });
858
1585
  DatePickerRoot.displayName = "DatePicker";
859
- var RangePicker = forwardRef3(({
1586
+ var RangePicker = forwardRef4(({
860
1587
  allowClear,
861
1588
  className,
1589
+ inputProps,
862
1590
  defaultValue,
863
1591
  disabled,
864
1592
  disabledDate,
@@ -872,7 +1600,7 @@ var RangePicker = forwardRef3(({
872
1600
  ...props
873
1601
  }, ref) => {
874
1602
  const isControlled = value !== undefined;
875
- const [innerValue, setInnerValue] = useState3(defaultValue ?? [undefined, undefined]);
1603
+ const [innerValue, setInnerValue] = useState5(defaultValue ?? [undefined, undefined]);
876
1604
  const currentValue = isControlled ? value : innerValue;
877
1605
  const inputType = inputTypeForPicker(picker);
878
1606
  function emitChange(nextValue) {
@@ -887,7 +1615,7 @@ var RangePicker = forwardRef3(({
887
1615
  function updateIndex(index, nextItem) {
888
1616
  emitChange(index === 0 ? [nextItem, currentValue?.[1]] : [currentValue?.[0], nextItem]);
889
1617
  }
890
- return /* @__PURE__ */ jsxs4("div", {
1618
+ return /* @__PURE__ */ jsxs5("div", {
891
1619
  ...props,
892
1620
  ref,
893
1621
  className: getDatePickerClasses({
@@ -899,7 +1627,8 @@ var RangePicker = forwardRef3(({
899
1627
  className
900
1628
  }),
901
1629
  children: [
902
- /* @__PURE__ */ jsx5("input", {
1630
+ /* @__PURE__ */ jsx6("input", {
1631
+ ...inputProps,
903
1632
  className: datePickerInputClass,
904
1633
  disabled,
905
1634
  type: inputType,
@@ -907,11 +1636,13 @@ var RangePicker = forwardRef3(({
907
1636
  placeholder: Array.isArray(placeholder) ? placeholder[0] : "Start date",
908
1637
  onChange: (event) => updateIndex(0, event.currentTarget.value || undefined)
909
1638
  }),
910
- /* @__PURE__ */ jsx5("span", {
1639
+ /* @__PURE__ */ jsx6("span", {
911
1640
  className: datePickerSeparatorClass,
912
1641
  children: separator
913
1642
  }),
914
- /* @__PURE__ */ jsx5("input", {
1643
+ /* @__PURE__ */ jsx6("input", {
1644
+ ...inputProps,
1645
+ id: inputProps?.id ? `${inputProps.id}-end` : undefined,
915
1646
  className: datePickerInputClass,
916
1647
  disabled,
917
1648
  type: inputType,
@@ -919,7 +1650,7 @@ var RangePicker = forwardRef3(({
919
1650
  placeholder: Array.isArray(placeholder) ? placeholder[1] : "End date",
920
1651
  onChange: (event) => updateIndex(1, event.currentTarget.value || undefined)
921
1652
  }),
922
- allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx5("button", {
1653
+ allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx6("button", {
923
1654
  type: "button",
924
1655
  className: datePickerClearClass,
925
1656
  "aria-label": "Clear date range",
@@ -931,7 +1662,7 @@ var RangePicker = forwardRef3(({
931
1662
  });
932
1663
  RangePicker.displayName = "DatePicker.RangePicker";
933
1664
  function withPicker(picker, displayName) {
934
- const Picker = forwardRef3((props, ref) => /* @__PURE__ */ jsx5(DatePickerRoot, {
1665
+ const Picker = forwardRef4((props, ref) => /* @__PURE__ */ jsx6(DatePickerRoot, {
935
1666
  ...props,
936
1667
  ref,
937
1668
  picker
@@ -948,10 +1679,10 @@ var DatePicker = Object.assign(DatePickerRoot, {
948
1679
  });
949
1680
  // src/components/input/Input.tsx
950
1681
  import {
951
- forwardRef as forwardRef4,
952
- useImperativeHandle,
953
- useRef as useRef2,
954
- useState as useState4
1682
+ forwardRef as forwardRef5,
1683
+ useImperativeHandle as useImperativeHandle2,
1684
+ useRef as useRef3,
1685
+ useState as useState6
955
1686
  } from "react";
956
1687
 
957
1688
  // src/classes/input.ts
@@ -1040,14 +1771,14 @@ function getTextAreaCountClasses({ exceeded }) {
1040
1771
  }
1041
1772
 
1042
1773
  // src/components/input/Input.tsx
1043
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1774
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1044
1775
  function toTextValue(value) {
1045
1776
  if (Array.isArray(value)) {
1046
1777
  return value.join(",");
1047
1778
  }
1048
1779
  return value == null ? "" : String(value);
1049
1780
  }
1050
- var InputRoot = forwardRef4(({
1781
+ var InputRoot = forwardRef5(({
1051
1782
  allowClear,
1052
1783
  className,
1053
1784
  defaultValue,
@@ -1062,12 +1793,12 @@ var InputRoot = forwardRef4(({
1062
1793
  variant = "outlined",
1063
1794
  ...props
1064
1795
  }, ref) => {
1065
- const inputRef = useRef2(null);
1066
- const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
1796
+ const inputRef = useRef3(null);
1797
+ const [internalValue, setInternalValue] = useState6(() => toTextValue(defaultValue));
1067
1798
  const isControlled = value !== undefined;
1068
1799
  const currentValue = isControlled ? toTextValue(value) : internalValue;
1069
1800
  const hasAffix = prefix != null || suffix != null || allowClear;
1070
- useImperativeHandle(ref, () => inputRef.current);
1801
+ useImperativeHandle2(ref, () => inputRef.current);
1071
1802
  function handleChange(event) {
1072
1803
  if (!isControlled) {
1073
1804
  setInternalValue(event.currentTarget.value);
@@ -1090,7 +1821,7 @@ var InputRoot = forwardRef4(({
1090
1821
  });
1091
1822
  input.focus();
1092
1823
  }
1093
- const control = /* @__PURE__ */ jsx6("input", {
1824
+ const control = /* @__PURE__ */ jsx7("input", {
1094
1825
  ...props,
1095
1826
  ref: inputRef,
1096
1827
  type,
@@ -1103,22 +1834,22 @@ var InputRoot = forwardRef4(({
1103
1834
  return control;
1104
1835
  }
1105
1836
  const showClear = allowClear && !disabled && currentValue.length > 0;
1106
- return /* @__PURE__ */ jsxs5("span", {
1837
+ return /* @__PURE__ */ jsxs6("span", {
1107
1838
  className: getInputWrapperClasses({ affixed: hasAffix }),
1108
1839
  children: [
1109
- prefix != null ? /* @__PURE__ */ jsx6("span", {
1840
+ prefix != null ? /* @__PURE__ */ jsx7("span", {
1110
1841
  className: inputPrefixClass,
1111
1842
  children: prefix
1112
1843
  }) : null,
1113
1844
  control,
1114
- showClear ? /* @__PURE__ */ jsx6("button", {
1845
+ showClear ? /* @__PURE__ */ jsx7("button", {
1115
1846
  type: "button",
1116
1847
  className: inputClearClass,
1117
1848
  "aria-label": "Clear input",
1118
1849
  onClick: handleClear,
1119
1850
  children: "x"
1120
1851
  }) : null,
1121
- suffix != null ? /* @__PURE__ */ jsx6("span", {
1852
+ suffix != null ? /* @__PURE__ */ jsx7("span", {
1122
1853
  className: inputSuffixClass,
1123
1854
  children: suffix
1124
1855
  }) : null
@@ -1126,7 +1857,7 @@ var InputRoot = forwardRef4(({
1126
1857
  });
1127
1858
  });
1128
1859
  InputRoot.displayName = "Input";
1129
- var Search = forwardRef4(({
1860
+ var Search = forwardRef5(({
1130
1861
  className,
1131
1862
  disabled,
1132
1863
  enterButton,
@@ -1135,8 +1866,8 @@ var Search = forwardRef4(({
1135
1866
  onSearch,
1136
1867
  ...props
1137
1868
  }, ref) => {
1138
- const inputRef = useRef2(null);
1139
- useImperativeHandle(ref, () => inputRef.current);
1869
+ const inputRef = useRef3(null);
1870
+ useImperativeHandle2(ref, () => inputRef.current);
1140
1871
  function emitSearch(event) {
1141
1872
  onSearch?.(inputRef.current?.value ?? "", event);
1142
1873
  }
@@ -1147,16 +1878,16 @@ var Search = forwardRef4(({
1147
1878
  }
1148
1879
  }
1149
1880
  const buttonContent = enterButton === true ? "Search" : enterButton ?? "Search";
1150
- return /* @__PURE__ */ jsxs5("span", {
1881
+ return /* @__PURE__ */ jsxs6("span", {
1151
1882
  className: getSearchWrapperClasses({ className }),
1152
1883
  children: [
1153
- /* @__PURE__ */ jsx6(InputRoot, {
1884
+ /* @__PURE__ */ jsx7(InputRoot, {
1154
1885
  ...props,
1155
1886
  ref: inputRef,
1156
1887
  disabled,
1157
1888
  onKeyDown: handleKeyDown
1158
1889
  }),
1159
- enterButton || loading ? /* @__PURE__ */ jsx6("button", {
1890
+ enterButton || loading ? /* @__PURE__ */ jsx7("button", {
1160
1891
  type: "button",
1161
1892
  className: inputSearchButtonClass,
1162
1893
  disabled: disabled || loading,
@@ -1168,10 +1899,10 @@ var Search = forwardRef4(({
1168
1899
  });
1169
1900
  });
1170
1901
  Search.displayName = "Input.Search";
1171
- var Password = forwardRef4(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
1172
- const [visible, setVisible] = useState4(false);
1902
+ var Password = forwardRef5(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
1903
+ const [visible, setVisible] = useState6(false);
1173
1904
  const type = visible ? "text" : "password";
1174
- const toggle = visibilityToggle ? /* @__PURE__ */ jsx6("button", {
1905
+ const toggle = visibilityToggle ? /* @__PURE__ */ jsx7("button", {
1175
1906
  type: "button",
1176
1907
  className: inputPasswordToggleClass,
1177
1908
  disabled,
@@ -1181,9 +1912,9 @@ var Password = forwardRef4(({ className, disabled, visibilityToggle = true, ...p
1181
1912
  },
1182
1913
  children: visible ? "Hide" : "Show"
1183
1914
  }) : undefined;
1184
- return /* @__PURE__ */ jsx6("span", {
1915
+ return /* @__PURE__ */ jsx7("span", {
1185
1916
  className: getPasswordWrapperClasses({ className }),
1186
- children: /* @__PURE__ */ jsx6(InputRoot, {
1917
+ children: /* @__PURE__ */ jsx7(InputRoot, {
1187
1918
  ...props,
1188
1919
  ref,
1189
1920
  disabled,
@@ -1193,7 +1924,7 @@ var Password = forwardRef4(({ className, disabled, visibilityToggle = true, ...p
1193
1924
  });
1194
1925
  });
1195
1926
  Password.displayName = "Input.Password";
1196
- var TextArea = forwardRef4(({
1927
+ var TextArea = forwardRef5(({
1197
1928
  autoSize,
1198
1929
  className,
1199
1930
  defaultValue,
@@ -1207,7 +1938,7 @@ var TextArea = forwardRef4(({
1207
1938
  variant = "outlined",
1208
1939
  ...props
1209
1940
  }, ref) => {
1210
- const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
1941
+ const [internalValue, setInternalValue] = useState6(() => toTextValue(defaultValue));
1211
1942
  const isControlled = value !== undefined;
1212
1943
  const currentValue = isControlled ? toTextValue(value) : internalValue;
1213
1944
  const count = currentValue.length;
@@ -1218,7 +1949,7 @@ var TextArea = forwardRef4(({
1218
1949
  }
1219
1950
  onChange?.(event);
1220
1951
  }
1221
- const control = /* @__PURE__ */ jsx6("textarea", {
1952
+ const control = /* @__PURE__ */ jsx7("textarea", {
1222
1953
  ...props,
1223
1954
  ref,
1224
1955
  className: getTextAreaClasses({
@@ -1236,11 +1967,11 @@ var TextArea = forwardRef4(({
1236
1967
  if (!showCount) {
1237
1968
  return control;
1238
1969
  }
1239
- return /* @__PURE__ */ jsxs5("span", {
1970
+ return /* @__PURE__ */ jsxs6("span", {
1240
1971
  className: textAreaWrapperClass,
1241
1972
  children: [
1242
1973
  control,
1243
- /* @__PURE__ */ jsxs5("span", {
1974
+ /* @__PURE__ */ jsxs6("span", {
1244
1975
  className: getTextAreaCountClasses({ exceeded }),
1245
1976
  children: [
1246
1977
  count,
@@ -1251,7 +1982,7 @@ var TextArea = forwardRef4(({
1251
1982
  });
1252
1983
  });
1253
1984
  TextArea.displayName = "Input.TextArea";
1254
- var Group = forwardRef4(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
1985
+ var Group = forwardRef5(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
1255
1986
  ...props,
1256
1987
  ref,
1257
1988
  className: cn(inputGroupClass, className),
@@ -1265,7 +1996,7 @@ var Input = Object.assign(InputRoot, {
1265
1996
  Group
1266
1997
  });
1267
1998
  // src/components/select/Select.tsx
1268
- import React5, { forwardRef as forwardRef5, useMemo as useMemo4, useState as useState5 } from "react";
1999
+ import React7, { forwardRef as forwardRef6, useMemo as useMemo5, useState as useState7 } from "react";
1269
2000
 
1270
2001
  // src/classes/select.ts
1271
2002
  var selectContainerClass = "select-container";
@@ -1321,7 +2052,7 @@ function getSelectOptionClasses({
1321
2052
  }
1322
2053
 
1323
2054
  // src/components/select/Select.tsx
1324
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
2055
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1325
2056
  function isGroup(option) {
1326
2057
  return "options" in option;
1327
2058
  }
@@ -1346,8 +2077,8 @@ function normalizeMultiValue(value) {
1346
2077
  }
1347
2078
  function optionsFromChildren(children) {
1348
2079
  const result = [];
1349
- React5.Children.forEach(children, (child) => {
1350
- if (!React5.isValidElement(child)) {
2080
+ React7.Children.forEach(children, (child) => {
2081
+ if (!React7.isValidElement(child)) {
1351
2082
  return;
1352
2083
  }
1353
2084
  if (child.type === Option) {
@@ -1397,25 +2128,31 @@ function filterOptions(options, searchValue, filterOption) {
1397
2128
  function renderValue(option) {
1398
2129
  return option ? optionLabel(option) : null;
1399
2130
  }
1400
- var Option = forwardRef5(({ children, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2131
+ var Option = forwardRef6(({ children, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
1401
2132
  ...props,
1402
2133
  ref,
1403
2134
  children
1404
2135
  }));
1405
2136
  Option.displayName = "Select.Option";
1406
- var OptGroup = forwardRef5(({ children, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2137
+ var OptGroup = forwardRef6(({ children, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
1407
2138
  ...props,
1408
2139
  ref,
1409
2140
  children
1410
2141
  }));
1411
2142
  OptGroup.displayName = "Select.OptGroup";
1412
- var SelectRoot = forwardRef5(({
2143
+ var SelectRoot = forwardRef6(({
1413
2144
  allowClear,
2145
+ "aria-describedby": ariaDescribedBy,
2146
+ "aria-errormessage": ariaErrorMessage,
2147
+ "aria-invalid": ariaInvalid,
2148
+ "aria-label": ariaLabel,
2149
+ "aria-labelledby": ariaLabelledBy,
1414
2150
  children,
1415
2151
  className,
1416
2152
  defaultValue,
1417
2153
  disabled,
1418
2154
  filterOption,
2155
+ id,
1419
2156
  loading,
1420
2157
  mode,
1421
2158
  onChange,
@@ -1428,11 +2165,11 @@ var SelectRoot = forwardRef5(({
1428
2165
  ...props
1429
2166
  }, ref) => {
1430
2167
  const multiple = mode === "multiple" || mode === "tags";
1431
- const sourceOptions = useMemo4(() => options ?? optionsFromChildren(children), [children, options]);
1432
- const flatOptions = useMemo4(() => flattenOptions(sourceOptions), [sourceOptions]);
1433
- const [open, setOpen] = useState5(false);
1434
- const [searchValue, setSearchValue] = useState5("");
1435
- const [internalValue, setInternalValue] = useState5(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
2168
+ const sourceOptions = useMemo5(() => options ?? optionsFromChildren(children), [children, options]);
2169
+ const flatOptions = useMemo5(() => flattenOptions(sourceOptions), [sourceOptions]);
2170
+ const [open, setOpen] = useState7(false);
2171
+ const [searchValue, setSearchValue] = useState7("");
2172
+ const [internalValue, setInternalValue] = useState7(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
1436
2173
  const controlled = value !== undefined;
1437
2174
  const currentValue = controlled ? value : internalValue;
1438
2175
  const selectedValues = multiple ? normalizeMultiValue(currentValue) : normalizeSingleValue(currentValue) === undefined ? [] : [normalizeSingleValue(currentValue)];
@@ -1489,7 +2226,7 @@ var SelectRoot = forwardRef5(({
1489
2226
  }
1490
2227
  function renderOption(option) {
1491
2228
  const selected = selectedKeys.has(valueKey(option.value));
1492
- return /* @__PURE__ */ jsx7("button", {
2229
+ return /* @__PURE__ */ jsx8("button", {
1493
2230
  type: "button",
1494
2231
  role: "option",
1495
2232
  "aria-selected": selected,
@@ -1508,11 +2245,11 @@ var SelectRoot = forwardRef5(({
1508
2245
  if (!isGroup(option)) {
1509
2246
  return renderOption(option);
1510
2247
  }
1511
- return /* @__PURE__ */ jsxs6("div", {
2248
+ return /* @__PURE__ */ jsxs7("div", {
1512
2249
  className: cn(selectGroupClass, option.className),
1513
2250
  role: "group",
1514
2251
  children: [
1515
- /* @__PURE__ */ jsx7("div", {
2252
+ /* @__PURE__ */ jsx8("div", {
1516
2253
  className: selectGroupLabelClass,
1517
2254
  children: option.label
1518
2255
  }),
@@ -1521,11 +2258,11 @@ var SelectRoot = forwardRef5(({
1521
2258
  }, `group-${index}`);
1522
2259
  });
1523
2260
  }
1524
- const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx7("span", {
2261
+ const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx8("span", {
1525
2262
  className: selectTagClass,
1526
2263
  children: renderValue(option)
1527
2264
  }, valueKey(option.value))) : renderValue(selectedOptions[0]);
1528
- return /* @__PURE__ */ jsxs6("div", {
2265
+ return /* @__PURE__ */ jsxs7("div", {
1529
2266
  ...props,
1530
2267
  ref,
1531
2268
  className: getSelectContainerClasses({
@@ -1536,41 +2273,47 @@ var SelectRoot = forwardRef5(({
1536
2273
  className
1537
2274
  }),
1538
2275
  children: [
1539
- /* @__PURE__ */ jsxs6("button", {
2276
+ /* @__PURE__ */ jsxs7("button", {
1540
2277
  type: "button",
2278
+ id,
1541
2279
  className: getSelectClasses({ size, status, disabled }),
1542
2280
  disabled: disabled || loading,
2281
+ "aria-describedby": ariaDescribedBy,
2282
+ "aria-errormessage": ariaErrorMessage,
2283
+ "aria-invalid": ariaInvalid,
2284
+ "aria-label": ariaLabel,
2285
+ "aria-labelledby": ariaLabelledBy,
1543
2286
  "aria-haspopup": "listbox",
1544
2287
  "aria-expanded": open,
1545
2288
  onClick: () => setOpen((current) => !current),
1546
2289
  children: [
1547
- /* @__PURE__ */ jsx7("span", {
2290
+ /* @__PURE__ */ jsx8("span", {
1548
2291
  className: selectSelectionClass,
1549
- children: hasValue ? selection : /* @__PURE__ */ jsx7("span", {
2292
+ children: hasValue ? selection : /* @__PURE__ */ jsx8("span", {
1550
2293
  className: selectPlaceholderClass,
1551
2294
  children: placeholder
1552
2295
  })
1553
2296
  }),
1554
- /* @__PURE__ */ jsx7("span", {
2297
+ /* @__PURE__ */ jsx8("span", {
1555
2298
  className: selectIconClass,
1556
2299
  "aria-hidden": "true",
1557
2300
  children: "v"
1558
2301
  })
1559
2302
  ]
1560
2303
  }),
1561
- allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx7("button", {
2304
+ allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx8("button", {
1562
2305
  type: "button",
1563
2306
  className: selectClearClass,
1564
2307
  "aria-label": "Clear selection",
1565
2308
  onClick: clearValue,
1566
2309
  children: "x"
1567
2310
  }) : null,
1568
- open ? /* @__PURE__ */ jsxs6("div", {
2311
+ open ? /* @__PURE__ */ jsxs7("div", {
1569
2312
  className: selectDropdownClass,
1570
2313
  role: "listbox",
1571
2314
  "aria-multiselectable": multiple || undefined,
1572
2315
  children: [
1573
- searchable ? /* @__PURE__ */ jsx7("input", {
2316
+ searchable ? /* @__PURE__ */ jsx8("input", {
1574
2317
  className: selectSearchClass,
1575
2318
  value: searchValue,
1576
2319
  placeholder: typeof placeholder === "string" ? placeholder : undefined,
@@ -1582,7 +2325,7 @@ var SelectRoot = forwardRef5(({
1582
2325
  }
1583
2326
  }
1584
2327
  }) : null,
1585
- visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx7("div", {
2328
+ visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx8("div", {
1586
2329
  className: selectEmptyClass,
1587
2330
  children: "No data"
1588
2331
  })
@@ -1596,7 +2339,7 @@ var Select = SelectRoot;
1596
2339
  Select.Option = Option;
1597
2340
  Select.OptGroup = OptGroup;
1598
2341
  // src/components/dm-search/DmSearch.tsx
1599
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
2342
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
1600
2343
  function initialValues(items, searchParams, useSearchParams = true) {
1601
2344
  return items.reduce((acc, item) => {
1602
2345
  const defaultValue = item.search.extraProps?.value ?? item.search.formProps?.initialValue;
@@ -1620,7 +2363,7 @@ function renderField({
1620
2363
  return item.search.render?.(value, setValue, item) ?? null;
1621
2364
  }
1622
2365
  if (item.search.type === "select") {
1623
- return /* @__PURE__ */ jsx8(Select, {
2366
+ return /* @__PURE__ */ jsx9(Select, {
1624
2367
  ...extraProps,
1625
2368
  disabled: Boolean(loading || extraProps.disabled),
1626
2369
  value,
@@ -1629,25 +2372,25 @@ function renderField({
1629
2372
  });
1630
2373
  }
1631
2374
  if (item.search.type === "dateRange") {
1632
- return /* @__PURE__ */ jsx8(DatePicker.RangePicker, {
2375
+ return /* @__PURE__ */ jsx9(DatePicker.RangePicker, {
1633
2376
  ...extraProps,
1634
2377
  value,
1635
2378
  onChange: (nextValue) => setValue(nextValue)
1636
2379
  });
1637
2380
  }
1638
2381
  if (item.search.type === "date") {
1639
- return /* @__PURE__ */ jsx8(DatePicker, {
2382
+ return /* @__PURE__ */ jsx9(DatePicker, {
1640
2383
  ...extraProps,
1641
2384
  value,
1642
2385
  onChange: (nextValue) => setValue(nextValue)
1643
2386
  });
1644
2387
  }
1645
2388
  if (item.search.type === "radio" || item.search.type === "checkbox") {
1646
- return /* @__PURE__ */ jsx8("div", {
2389
+ return /* @__PURE__ */ jsx9("div", {
1647
2390
  role: item.search.type === "radio" ? "radiogroup" : "group",
1648
- children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs7("label", {
2391
+ children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs8("label", {
1649
2392
  children: [
1650
- /* @__PURE__ */ jsx8("input", {
2393
+ /* @__PURE__ */ jsx9("input", {
1651
2394
  type: item.search.type,
1652
2395
  disabled: loading,
1653
2396
  checked: item.search.type === "checkbox" ? Array.isArray(value) && value.includes(option.value) : value === option.value,
@@ -1665,7 +2408,7 @@ function renderField({
1665
2408
  }, String(option.value)))
1666
2409
  });
1667
2410
  }
1668
- return /* @__PURE__ */ jsx8(Input, {
2411
+ return /* @__PURE__ */ jsx9(Input, {
1669
2412
  ...extraProps,
1670
2413
  type: item.search.type === "input-number" ? "number" : "text",
1671
2414
  disabled: Boolean(loading || extraProps.disabled),
@@ -1679,8 +2422,11 @@ function renderField({
1679
2422
  }
1680
2423
  });
1681
2424
  }
1682
- var DmSearch = forwardRef6(({
2425
+ var DmSearch = forwardRef7(({
1683
2426
  items = [],
2427
+ values: controlledValues,
2428
+ onValuesChange,
2429
+ onReset,
1684
2430
  onSearch,
1685
2431
  extra,
1686
2432
  fastFilterItem,
@@ -1689,27 +2435,37 @@ var DmSearch = forwardRef6(({
1689
2435
  compact = false,
1690
2436
  searchParams,
1691
2437
  loading = false,
2438
+ noValidate,
1692
2439
  enableDefaultPlaceHolder = false,
1693
2440
  className
1694
2441
  }, ref) => {
1695
- const allItems = useMemo5(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
1696
- const [collapsed, setCollapsed] = useState6(defaultCollapsed);
1697
- const [values, setValues] = useState6(() => initialValues(allItems, searchParams));
2442
+ const allItems = useMemo6(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
2443
+ const [collapsed, setCollapsed] = useState8(defaultCollapsed);
2444
+ const [internalValues, setValues] = useState8(() => initialValues(allItems, searchParams));
2445
+ const controlled = controlledValues !== undefined;
2446
+ const values = controlled ? controlledValues : internalValues;
1698
2447
  const visibleItems = collapsed ? allItems.slice(0, 1) : allItems;
1699
- useEffect2(() => {
1700
- setValues(initialValues(allItems, searchParams));
1701
- }, [allItems, searchParams]);
2448
+ useEffect3(() => {
2449
+ if (!controlled)
2450
+ setValues(initialValues(allItems, searchParams));
2451
+ }, [allItems, searchParams, controlled]);
1702
2452
  function reset(useSearchParams = false) {
1703
2453
  const nextValues = initialValues(allItems, searchParams, useSearchParams);
1704
- setValues(nextValues);
2454
+ if (!controlled)
2455
+ setValues(nextValues);
2456
+ if (onReset)
2457
+ onReset(nextValues);
2458
+ else if (controlled)
2459
+ onValuesChange?.(nextValues);
1705
2460
  return nextValues;
1706
2461
  }
1707
- useImperativeHandle2(ref, () => ({
2462
+ useImperativeHandle3(ref, () => ({
1708
2463
  onReset: () => {
1709
2464
  reset(false);
1710
2465
  }
1711
2466
  }));
1712
- return /* @__PURE__ */ jsxs7("form", {
2467
+ return /* @__PURE__ */ jsxs8("form", {
2468
+ noValidate,
1713
2469
  id: "searchForm",
1714
2470
  className: getDmSearchClasses({ compact, collapsed, className }),
1715
2471
  onSubmit: (event) => {
@@ -1717,53 +2473,63 @@ var DmSearch = forwardRef6(({
1717
2473
  onSearch?.(values);
1718
2474
  },
1719
2475
  children: [
1720
- fastFilterItem ? /* @__PURE__ */ jsx8("div", {
2476
+ fastFilterItem ? /* @__PURE__ */ jsx9("div", {
1721
2477
  className: dmSearchFastFilterClass,
1722
2478
  children: fastFilterItem.title
1723
2479
  }) : null,
1724
- /* @__PURE__ */ jsx8("div", {
2480
+ /* @__PURE__ */ jsx9("div", {
1725
2481
  className: dmSearchFieldsClass,
1726
- children: visibleItems.map((item) => /* @__PURE__ */ jsxs7("label", {
1727
- className: dmSearchFieldClass,
1728
- children: [
1729
- compact ? null : /* @__PURE__ */ jsx8("span", {
1730
- children: item.title
1731
- }),
1732
- renderField({
1733
- item,
1734
- value: values[item.dataIndex],
1735
- loading,
1736
- enableDefaultPlaceHolder,
1737
- setValue: (value) => setValues((current) => ({
1738
- ...current,
1739
- [item.dataIndex]: value
1740
- }))
1741
- })
1742
- ]
1743
- }, item.key))
2482
+ children: visibleItems.map((item) => {
2483
+ const Field = item.search.type === "custom" ? "div" : "label";
2484
+ return /* @__PURE__ */ jsxs8(Field, {
2485
+ className: dmSearchFieldClass,
2486
+ children: [
2487
+ compact ? null : /* @__PURE__ */ jsx9("span", {
2488
+ children: item.title
2489
+ }),
2490
+ renderField({
2491
+ item,
2492
+ value: values[item.dataIndex],
2493
+ loading,
2494
+ enableDefaultPlaceHolder,
2495
+ setValue: (value) => {
2496
+ const nextValues = { ...values, [item.dataIndex]: value };
2497
+ if (!controlled)
2498
+ setValues(nextValues);
2499
+ onValuesChange?.(nextValues);
2500
+ }
2501
+ })
2502
+ ]
2503
+ }, item.key);
2504
+ })
1744
2505
  }),
1745
- /* @__PURE__ */ jsxs7("div", {
2506
+ /* @__PURE__ */ jsxs8("div", {
1746
2507
  className: dmSearchActionsClass,
1747
2508
  children: [
1748
- /* @__PURE__ */ jsx8(Button, {
2509
+ /* @__PURE__ */ jsx9(Button, {
1749
2510
  type: "submit",
1750
2511
  isLoading: loading,
1751
2512
  children: "Search"
1752
2513
  }),
1753
- /* @__PURE__ */ jsx8(Button, {
2514
+ /* @__PURE__ */ jsx9(Button, {
1754
2515
  type: "button",
1755
2516
  color: "secondary",
1756
2517
  appearance: "outline",
1757
- onClick: () => onSearch?.(reset(false)),
2518
+ onClick: () => {
2519
+ const nextValues = reset(false);
2520
+ if (!onReset)
2521
+ onSearch?.(nextValues);
2522
+ },
1758
2523
  children: "Reset"
1759
2524
  }),
1760
- !hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx8(Button, {
2525
+ !hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx9(Button, {
1761
2526
  type: "button",
1762
2527
  color: "secondary",
1763
2528
  appearance: "text",
1764
2529
  onClick: () => {
1765
2530
  setCollapsed((current) => !current);
1766
- setValues(initialValues(allItems, searchParams));
2531
+ if (!controlled)
2532
+ setValues(initialValues(allItems, searchParams));
1767
2533
  },
1768
2534
  children: collapsed ? "Expand" : "Collapse"
1769
2535
  }) : null,
@@ -1775,10 +2541,10 @@ var DmSearch = forwardRef6(({
1775
2541
  });
1776
2542
  DmSearch.displayName = "DmSearch";
1777
2543
  // src/components/table/Table.tsx
1778
- import React7, {
1779
- forwardRef as forwardRef7,
1780
- useMemo as useMemo6,
1781
- useState as useState7
2544
+ import React9, {
2545
+ forwardRef as forwardRef8,
2546
+ useMemo as useMemo7,
2547
+ useState as useState9
1782
2548
  } from "react";
1783
2549
 
1784
2550
  // src/classes/table.ts
@@ -1828,7 +2594,7 @@ function getTableSorterClasses(active) {
1828
2594
  }
1829
2595
 
1830
2596
  // src/components/table/Table.tsx
1831
- import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2597
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1832
2598
  import { createElement } from "react";
1833
2599
  var defaultPageSize = 10;
1834
2600
  var defaultSortDirections = ["ascend", "descend", null];
@@ -1944,24 +2710,24 @@ function selectedRowsForKeys(data, keys, rowKey) {
1944
2710
  const keySet = new Set(normalizeKeys(keys));
1945
2711
  return data.filter((record, index) => keySet.has(String(getRecordKey(record, index, rowKey))));
1946
2712
  }
1947
- var Column = forwardRef7(() => null);
2713
+ var Column = forwardRef8(() => null);
1948
2714
  Column.displayName = "Table.Column";
1949
- var ColumnGroup = forwardRef7(() => null);
2715
+ var ColumnGroup = forwardRef8(() => null);
1950
2716
  ColumnGroup.displayName = "Table.ColumnGroup";
1951
- var SummaryRow = forwardRef7((props, ref) => /* @__PURE__ */ jsx9("tr", {
2717
+ var SummaryRow = forwardRef8((props, ref) => /* @__PURE__ */ jsx10("tr", {
1952
2718
  ...props,
1953
2719
  ref
1954
2720
  }));
1955
2721
  SummaryRow.displayName = "Table.Summary.Row";
1956
- var SummaryCell = forwardRef7(({ index, ...props }, ref) => {
1957
- return /* @__PURE__ */ jsx9("td", {
2722
+ var SummaryCell = forwardRef8(({ index, ...props }, ref) => {
2723
+ return /* @__PURE__ */ jsx10("td", {
1958
2724
  ...props,
1959
2725
  ref
1960
2726
  });
1961
2727
  });
1962
2728
  SummaryCell.displayName = "Table.Summary.Cell";
1963
- var Summary = Object.assign(forwardRef7(({ fixed, ...props }, ref) => {
1964
- return /* @__PURE__ */ jsx9("tfoot", {
2729
+ var Summary = Object.assign(forwardRef8(({ fixed, ...props }, ref) => {
2730
+ return /* @__PURE__ */ jsx10("tfoot", {
1965
2731
  ...props,
1966
2732
  ref
1967
2733
  });
@@ -1971,8 +2737,8 @@ var Summary = Object.assign(forwardRef7(({ fixed, ...props }, ref) => {
1971
2737
  });
1972
2738
  Summary.displayName = "Table.Summary";
1973
2739
  function columnsFromChildren(children) {
1974
- return React7.Children.toArray(children).flatMap((child) => {
1975
- if (!React7.isValidElement(child)) {
2740
+ return React9.Children.toArray(children).flatMap((child) => {
2741
+ if (!React9.isValidElement(child)) {
1976
2742
  return [];
1977
2743
  }
1978
2744
  if (child.type === Column) {
@@ -1998,12 +2764,12 @@ function renderSummary(summary, pageData, colSpan) {
1998
2764
  return null;
1999
2765
  }
2000
2766
  const node = summary(pageData);
2001
- if (React7.isValidElement(node) && node.type === Summary) {
2767
+ if (React9.isValidElement(node) && node.type === Summary) {
2002
2768
  return node;
2003
2769
  }
2004
- return /* @__PURE__ */ jsx9("tfoot", {
2005
- children: /* @__PURE__ */ jsx9("tr", {
2006
- children: /* @__PURE__ */ jsx9("td", {
2770
+ return /* @__PURE__ */ jsx10("tfoot", {
2771
+ children: /* @__PURE__ */ jsx10("tr", {
2772
+ children: /* @__PURE__ */ jsx10("td", {
2007
2773
  className: tableCellClass,
2008
2774
  colSpan,
2009
2775
  children: node
@@ -2047,18 +2813,18 @@ function TableRoot({
2047
2813
  className,
2048
2814
  ...props
2049
2815
  }, ref) {
2050
- const childColumns = useMemo6(() => columnsFromChildren(children), [children]);
2051
- const normalizedColumns = useMemo6(() => normalizeColumns(columns ?? childColumns), [childColumns, columns]);
2052
- const leaves = useMemo6(() => leafColumns(normalizedColumns), [normalizedColumns]);
2053
- const headerRows = useMemo6(() => buildHeaderRows(normalizedColumns, getDepth(normalizedColumns)), [normalizedColumns]);
2054
- const [sortStates, setSortStates] = useState7({});
2055
- const [filterStates, setFilterStates] = useState7({});
2056
- const [internalCurrent, setInternalCurrent] = useState7(1);
2057
- const [internalPageSize, setInternalPageSize] = useState7(defaultPageSize);
2058
- const [internalSelectedKeys, setInternalSelectedKeys] = useState7(rowSelection?.defaultSelectedRowKeys ?? []);
2059
- const [internalExpandedKeys, setInternalExpandedKeys] = useState7(expandable?.defaultExpandedRowKeys ?? []);
2816
+ const childColumns = useMemo7(() => columnsFromChildren(children), [children]);
2817
+ const normalizedColumns = useMemo7(() => normalizeColumns(columns ?? childColumns), [childColumns, columns]);
2818
+ const leaves = useMemo7(() => leafColumns(normalizedColumns), [normalizedColumns]);
2819
+ const headerRows = useMemo7(() => buildHeaderRows(normalizedColumns, getDepth(normalizedColumns)), [normalizedColumns]);
2820
+ const [sortStates, setSortStates] = useState9({});
2821
+ const [filterStates, setFilterStates] = useState9({});
2822
+ const [internalCurrent, setInternalCurrent] = useState9(1);
2823
+ const [internalPageSize, setInternalPageSize] = useState9(defaultPageSize);
2824
+ const [internalSelectedKeys, setInternalSelectedKeys] = useState9(rowSelection?.defaultSelectedRowKeys ?? []);
2825
+ const [internalExpandedKeys, setInternalExpandedKeys] = useState9(expandable?.defaultExpandedRowKeys ?? []);
2060
2826
  const spinning = typeof loading === "object" ? loading.spinning : Boolean(loading);
2061
- const activeFilters = useMemo6(() => {
2827
+ const activeFilters = useMemo7(() => {
2062
2828
  return leaves.reduce((result, column) => {
2063
2829
  const value = filterValueFor(column, filterStates) ?? null;
2064
2830
  if (value !== null) {
@@ -2067,7 +2833,7 @@ function TableRoot({
2067
2833
  return result;
2068
2834
  }, {});
2069
2835
  }, [filterStates, leaves]);
2070
- const activeSorter = useMemo6(() => {
2836
+ const activeSorter = useMemo7(() => {
2071
2837
  const column = leaves.find((item) => sortOrderFor(item, sortStates));
2072
2838
  if (!column) {
2073
2839
  return {};
@@ -2079,7 +2845,7 @@ function TableRoot({
2079
2845
  order: sortOrderFor(column, sortStates) ?? null
2080
2846
  };
2081
2847
  }, [leaves, sortStates]);
2082
- const filteredData = useMemo6(() => {
2848
+ const filteredData = useMemo7(() => {
2083
2849
  return leaves.reduce((records, column) => {
2084
2850
  const values = filterValueFor(column, filterStates);
2085
2851
  if (!values?.length || !column.onFilter) {
@@ -2088,7 +2854,7 @@ function TableRoot({
2088
2854
  return records.filter((record) => values.some((value) => column.onFilter?.(value, record)));
2089
2855
  }, dataSource);
2090
2856
  }, [dataSource, filterStates, leaves]);
2091
- const sortedData = useMemo6(() => {
2857
+ const sortedData = useMemo7(() => {
2092
2858
  const sorterColumn = leaves.find((column) => sortOrderFor(column, sortStates));
2093
2859
  const order = sorterColumn ? sortOrderFor(sorterColumn, sortStates) : null;
2094
2860
  const compare = sorterColumn ? sortCompare(sorterColumn.sorter) : undefined;
@@ -2231,18 +2997,18 @@ function TableRoot({
2231
2997
  return null;
2232
2998
  }
2233
2999
  if (rowSelection.type === "radio" || rowSelection.hideSelectAll) {
2234
- return /* @__PURE__ */ jsx9("th", {
3000
+ return /* @__PURE__ */ jsx10("th", {
2235
3001
  className: cn(tableHeaderCellClass, tableSelectionCellClass),
2236
3002
  children: rowSelection.columnTitle
2237
3003
  });
2238
3004
  }
2239
3005
  const pageKeys = pageData.map((record, index) => getRecordKey(record, index, rowKey));
2240
3006
  const allSelected = pageKeys.length > 0 && pageKeys.every((key) => selectedKeySet.has(String(key)));
2241
- return /* @__PURE__ */ jsx9("th", {
3007
+ return /* @__PURE__ */ jsx10("th", {
2242
3008
  className: cn(tableHeaderCellClass, tableSelectionCellClass),
2243
- children: /* @__PURE__ */ jsxs8("label", {
3009
+ children: /* @__PURE__ */ jsxs9("label", {
2244
3010
  children: [
2245
- /* @__PURE__ */ jsx9("input", {
3011
+ /* @__PURE__ */ jsx10("input", {
2246
3012
  type: "checkbox",
2247
3013
  "aria-label": "Select all rows",
2248
3014
  checked: allSelected,
@@ -2269,26 +3035,26 @@ function TableRoot({
2269
3035
  textAlign: column.align,
2270
3036
  ...headerProps.style
2271
3037
  }
2272
- }, /* @__PURE__ */ jsx9("span", {
3038
+ }, /* @__PURE__ */ jsx10("span", {
2273
3039
  children: title
2274
- }), column.sorter ? /* @__PURE__ */ jsx9("button", {
3040
+ }), column.sorter ? /* @__PURE__ */ jsx10("button", {
2275
3041
  type: "button",
2276
3042
  className: getTableSorterClasses(Boolean(sortOrder)),
2277
3043
  "aria-label": `Sort ${textFromNode(title, String(column.columnKey))}`,
2278
3044
  onClick: () => changeSorter(column),
2279
3045
  children: sortOrder === "ascend" ? "Asc" : sortOrder === "descend" ? "Desc" : "Sort"
2280
- }) : null, column.filters?.length ? /* @__PURE__ */ jsxs8("select", {
3046
+ }) : null, column.filters?.length ? /* @__PURE__ */ jsxs9("select", {
2281
3047
  className: tableFilterClass,
2282
3048
  "aria-label": `Filter ${textFromNode(title, String(column.columnKey))}`,
2283
3049
  multiple: column.filterMultiple !== false,
2284
3050
  value: column.filterMultiple === false ? String((filterValueFor(column, filterStates) ?? [])[0] ?? "") : (filterValueFor(column, filterStates) ?? []).map(String),
2285
3051
  onChange: (event) => changeFilter(column, event),
2286
3052
  children: [
2287
- column.filterMultiple === false ? /* @__PURE__ */ jsx9("option", {
3053
+ column.filterMultiple === false ? /* @__PURE__ */ jsx10("option", {
2288
3054
  value: "",
2289
3055
  children: "All"
2290
3056
  }) : null,
2291
- optionValues(column.filters).map((filter) => /* @__PURE__ */ jsx9("option", {
3057
+ optionValues(column.filters).map((filter) => /* @__PURE__ */ jsx10("option", {
2292
3058
  value: String(filter.value),
2293
3059
  children: filter.text
2294
3060
  }, String(filter.value)))
@@ -2313,14 +3079,14 @@ function TableRoot({
2313
3079
  const key = getRecordKey(record, index, rowKey);
2314
3080
  const checked = selectedKeySet.has(String(key));
2315
3081
  const checkboxProps = rowSelection.getCheckboxProps?.(record) ?? {};
2316
- const originNode = /* @__PURE__ */ jsx9("input", {
3082
+ const originNode = /* @__PURE__ */ jsx10("input", {
2317
3083
  ...checkboxProps,
2318
3084
  type: rowSelection.type === "radio" ? "radio" : "checkbox",
2319
3085
  "aria-label": `Select row ${index + 1}`,
2320
3086
  checked,
2321
3087
  onChange: (event) => toggleRowSelection(record, index, event)
2322
3088
  });
2323
- return /* @__PURE__ */ jsx9("td", {
3089
+ return /* @__PURE__ */ jsx10("td", {
2324
3090
  className: cn(tableCellClass, tableSelectionCellClass),
2325
3091
  children: rowSelection.renderCell ? rowSelection.renderCell(checked, record, index, originNode) : originNode
2326
3092
  });
@@ -2332,9 +3098,9 @@ function TableRoot({
2332
3098
  const key = getRecordKey(record, index, rowKey);
2333
3099
  const expanded = expandedKeySet.has(String(key));
2334
3100
  const expandableRow = expandable.rowExpandable?.(record) ?? true;
2335
- return /* @__PURE__ */ jsx9("td", {
3101
+ return /* @__PURE__ */ jsx10("td", {
2336
3102
  className: cn(tableCellClass, tableExpandCellClass),
2337
- children: expandableRow ? /* @__PURE__ */ jsx9("button", {
3103
+ children: expandableRow ? /* @__PURE__ */ jsx10("button", {
2338
3104
  type: "button",
2339
3105
  className: tableExpandButtonClass,
2340
3106
  "aria-label": `${expanded ? "Collapse" : "Expand"} row ${index + 1}`,
@@ -2347,7 +3113,7 @@ function TableRoot({
2347
3113
  const key = getRecordKey(record, index, rowKey);
2348
3114
  const expanded = expandedKeySet.has(String(key));
2349
3115
  const selected = selectedKeySet.has(String(key));
2350
- const row = /* @__PURE__ */ jsxs8("tr", {
3116
+ const row = /* @__PURE__ */ jsxs9("tr", {
2351
3117
  className: getTableRowClasses({ selected, expanded }),
2352
3118
  onClick: () => {
2353
3119
  if (expandable?.expandRowByClick) {
@@ -2363,12 +3129,12 @@ function TableRoot({
2363
3129
  if (!expanded || !expandable?.expandedRowRender) {
2364
3130
  return row;
2365
3131
  }
2366
- return /* @__PURE__ */ jsxs8(React7.Fragment, {
3132
+ return /* @__PURE__ */ jsxs9(React9.Fragment, {
2367
3133
  children: [
2368
3134
  row,
2369
- /* @__PURE__ */ jsx9("tr", {
3135
+ /* @__PURE__ */ jsx10("tr", {
2370
3136
  className: "table-expanded-row",
2371
- children: /* @__PURE__ */ jsx9("td", {
3137
+ children: /* @__PURE__ */ jsx10("td", {
2372
3138
  className: tableCellClass,
2373
3139
  colSpan: structuralColumnCount,
2374
3140
  children: expandable.expandedRowRender(record, index, 0, expanded)
@@ -2377,15 +3143,15 @@ function TableRoot({
2377
3143
  ]
2378
3144
  }, String(key));
2379
3145
  }
2380
- const tableNode = /* @__PURE__ */ jsxs8("table", {
3146
+ const tableNode = /* @__PURE__ */ jsxs9("table", {
2381
3147
  className: getTableClasses({ bordered, size }),
2382
3148
  style: { tableLayout },
2383
3149
  children: [
2384
- /* @__PURE__ */ jsx9("thead", {
2385
- children: headerRows.map((row, rowIndex) => /* @__PURE__ */ jsxs8("tr", {
3150
+ /* @__PURE__ */ jsx10("thead", {
3151
+ children: headerRows.map((row, rowIndex) => /* @__PURE__ */ jsxs9("tr", {
2386
3152
  children: [
2387
3153
  rowIndex === 0 ? renderSelectionHeader() : null,
2388
- rowIndex === 0 && hasExpandable ? /* @__PURE__ */ jsx9("th", {
3154
+ rowIndex === 0 && hasExpandable ? /* @__PURE__ */ jsx10("th", {
2389
3155
  className: cn(tableHeaderCellClass, tableExpandCellClass),
2390
3156
  children: expandable?.columnTitle
2391
3157
  }) : null,
@@ -2393,9 +3159,9 @@ function TableRoot({
2393
3159
  ]
2394
3160
  }, rowIndex))
2395
3161
  }),
2396
- /* @__PURE__ */ jsx9("tbody", {
2397
- children: bodyEmpty ? /* @__PURE__ */ jsx9("tr", {
2398
- children: /* @__PURE__ */ jsx9("td", {
3162
+ /* @__PURE__ */ jsx10("tbody", {
3163
+ children: bodyEmpty ? /* @__PURE__ */ jsx10("tr", {
3164
+ children: /* @__PURE__ */ jsx10("td", {
2399
3165
  className: tableEmptyClass,
2400
3166
  colSpan: structuralColumnCount,
2401
3167
  children: locale?.emptyText ?? "No data"
@@ -2405,12 +3171,12 @@ function TableRoot({
2405
3171
  renderSummary(summary, pageData, structuralColumnCount)
2406
3172
  ]
2407
3173
  });
2408
- return /* @__PURE__ */ jsxs8("div", {
3174
+ return /* @__PURE__ */ jsxs9("div", {
2409
3175
  ...props,
2410
3176
  ref,
2411
3177
  className: getTableWrapperClasses({ loading: spinning, className }),
2412
3178
  children: [
2413
- scroll?.x || scroll?.y ? /* @__PURE__ */ jsx9("div", {
3179
+ scroll?.x || scroll?.y ? /* @__PURE__ */ jsx10("div", {
2414
3180
  style: {
2415
3181
  overflow: "auto",
2416
3182
  maxHeight: scroll.y,
@@ -2418,30 +3184,30 @@ function TableRoot({
2418
3184
  },
2419
3185
  children: tableNode
2420
3186
  }) : tableNode,
2421
- spinning ? /* @__PURE__ */ jsx9("div", {
3187
+ spinning ? /* @__PURE__ */ jsx10("div", {
2422
3188
  className: tableLoadingIndicatorClass,
2423
3189
  role: "status",
2424
3190
  children: typeof loading === "object" && loading.indicator ? loading.indicator : "Loading"
2425
3191
  }) : null,
2426
- paginationConfig && !(paginationConfig.hideOnSinglePage && pageCount <= 1) ? /* @__PURE__ */ jsxs8("nav", {
3192
+ paginationConfig && !(paginationConfig.hideOnSinglePage && pageCount <= 1) ? /* @__PURE__ */ jsxs9("nav", {
2427
3193
  className: tablePaginationClass,
2428
3194
  "aria-label": "Table pagination",
2429
3195
  children: [
2430
- /* @__PURE__ */ jsx9("button", {
3196
+ /* @__PURE__ */ jsx10("button", {
2431
3197
  type: "button",
2432
3198
  className: tablePaginationButtonClass,
2433
3199
  disabled: paginationConfig.disabled || current <= 1,
2434
3200
  onClick: () => changePage(current - 1),
2435
3201
  children: "Previous"
2436
3202
  }),
2437
- /* @__PURE__ */ jsx9("span", {
3203
+ /* @__PURE__ */ jsx10("span", {
2438
3204
  className: tablePaginationInfoClass,
2439
3205
  children: paginationConfig.showTotal ? paginationConfig.showTotal(paginationConfig.total ?? sortedData.length, [
2440
3206
  bodyEmpty ? 0 : (current - 1) * pageSize + 1,
2441
3207
  Math.min(current * pageSize, sortedData.length)
2442
3208
  ]) : `${current} / ${pageCount}`
2443
3209
  }),
2444
- /* @__PURE__ */ jsx9("button", {
3210
+ /* @__PURE__ */ jsx10("button", {
2445
3211
  type: "button",
2446
3212
  className: tablePaginationButtonClass,
2447
3213
  disabled: paginationConfig.disabled || current >= pageCount,
@@ -2453,7 +3219,7 @@ function TableRoot({
2453
3219
  ]
2454
3220
  });
2455
3221
  }
2456
- var TableWithRef = forwardRef7(TableRoot);
3222
+ var TableWithRef = forwardRef8(TableRoot);
2457
3223
  var Table = Object.assign(TableWithRef, {
2458
3224
  Column,
2459
3225
  ColumnGroup,
@@ -2466,7 +3232,7 @@ var Table = Object.assign(TableWithRef, {
2466
3232
  });
2467
3233
  Table.displayName = "Table";
2468
3234
  // src/components/dm-table/DmTable.tsx
2469
- import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
3235
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
2470
3236
  function mapAndFilter(list, mapper) {
2471
3237
  return list.map(mapper).filter((item) => item !== false && item != null);
2472
3238
  }
@@ -2517,9 +3283,9 @@ function DmTable({
2517
3283
  rowSelection,
2518
3284
  ...props
2519
3285
  }) {
2520
- const tableColumns = useMemo7(() => mapAndFilter(inputColumns, filterDmTableColumn), [inputColumns]);
2521
- const [columns, setColumns] = useState8(tableColumns);
2522
- const [columnSettingsOpen, setColumnSettingsOpen] = useState8(false);
3286
+ const tableColumns = useMemo8(() => mapAndFilter(inputColumns, filterDmTableColumn), [inputColumns]);
3287
+ const [columns, setColumns] = useState10(tableColumns);
3288
+ const [columnSettingsOpen, setColumnSettingsOpen] = useState10(false);
2523
3289
  const items = searchProps?.items?.length ? searchProps.items : searchItems(inputColumns);
2524
3290
  const paginationObj = typeof pagination === "object" ? pagination : undefined;
2525
3291
  const paginationProps = paginationObj ? Object.fromEntries(Object.entries(paginationObj).filter(([key]) => key !== "ref")) : {};
@@ -2532,37 +3298,37 @@ function DmTable({
2532
3298
  globalThis.localStorage?.removeItem(columnState.persistenceKey);
2533
3299
  }
2534
3300
  }
2535
- return /* @__PURE__ */ jsxs9("div", {
3301
+ return /* @__PURE__ */ jsxs10("div", {
2536
3302
  className: getDmTableClasses({ className }),
2537
3303
  children: [
2538
- items.length > 0 || searchProps?.fastFilterItem ? /* @__PURE__ */ jsx10(Card, {
3304
+ items.length > 0 || searchProps?.fastFilterItem ? /* @__PURE__ */ jsx11(Card, {
2539
3305
  className: dmTableSearchClass,
2540
3306
  padding: "md",
2541
- children: /* @__PURE__ */ jsx10(DmSearch, {
3307
+ children: /* @__PURE__ */ jsx11(DmSearch, {
2542
3308
  ...searchProps,
2543
3309
  items
2544
3310
  })
2545
3311
  }) : null,
2546
- indicators ? /* @__PURE__ */ jsx10("div", {
3312
+ indicators ? /* @__PURE__ */ jsx11("div", {
2547
3313
  className: dmTableIndicatorsClass,
2548
3314
  children: indicators
2549
3315
  }) : null,
2550
- /* @__PURE__ */ jsxs9(Card, {
3316
+ /* @__PURE__ */ jsxs10(Card, {
2551
3317
  className: dmTableCardClass,
2552
3318
  padding: "md",
2553
3319
  children: [
2554
- name || extra || columnSettingVisible ? /* @__PURE__ */ jsxs9("div", {
3320
+ name || extra || columnSettingVisible ? /* @__PURE__ */ jsxs10("div", {
2555
3321
  className: dmTableHeaderClass,
2556
3322
  children: [
2557
- /* @__PURE__ */ jsx10("div", {
3323
+ /* @__PURE__ */ jsx11("div", {
2558
3324
  className: dmTableTitleClass,
2559
3325
  children: name
2560
3326
  }),
2561
- /* @__PURE__ */ jsxs9("div", {
3327
+ /* @__PURE__ */ jsxs10("div", {
2562
3328
  className: dmTableExtraClass,
2563
3329
  children: [
2564
3330
  extra,
2565
- columnSettingVisible ? /* @__PURE__ */ jsx10(Button, {
3331
+ columnSettingVisible ? /* @__PURE__ */ jsx11(Button, {
2566
3332
  type: "button",
2567
3333
  color: "secondary",
2568
3334
  appearance: "outline",
@@ -2574,20 +3340,20 @@ function DmTable({
2574
3340
  })
2575
3341
  ]
2576
3342
  }) : null,
2577
- columnSettingsOpen ? /* @__PURE__ */ jsx10("div", {
3343
+ columnSettingsOpen ? /* @__PURE__ */ jsx11("div", {
2578
3344
  role: "dialog",
2579
3345
  "aria-label": "Column settings",
2580
- children: /* @__PURE__ */ jsx10(Button, {
3346
+ children: /* @__PURE__ */ jsx11(Button, {
2581
3347
  type: "button",
2582
3348
  onClick: resetColumns,
2583
3349
  children: "Reset columns"
2584
3350
  })
2585
3351
  }) : null,
2586
- tableExtra ? /* @__PURE__ */ jsx10("div", {
3352
+ tableExtra ? /* @__PURE__ */ jsx11("div", {
2587
3353
  className: dmTableTableExtraClass,
2588
3354
  children: tableExtra
2589
3355
  }) : null,
2590
- /* @__PURE__ */ jsx10(Table, {
3356
+ /* @__PURE__ */ jsx11(Table, {
2591
3357
  ...props,
2592
3358
  dataSource,
2593
3359
  rowSelection,
@@ -2603,7 +3369,7 @@ function DmTable({
2603
3369
  onChange: paginationObj?.onChange
2604
3370
  } : false
2605
3371
  }),
2606
- pagination ? /* @__PURE__ */ jsx10(DmPagination, {
3372
+ pagination ? /* @__PURE__ */ jsx11(DmPagination, {
2607
3373
  ...paginationProps,
2608
3374
  className: dmTablePaginationClass,
2609
3375
  total,
@@ -2617,7 +3383,7 @@ function DmTable({
2617
3383
  }
2618
3384
  DmTable.displayName = "DmTable";
2619
3385
  // src/components/dm-toolbar/DmToolbar.tsx
2620
- import { useMemo as useMemo8 } from "react";
3386
+ import { useMemo as useMemo9 } from "react";
2621
3387
 
2622
3388
  // src/classes/dm-toolbar.ts
2623
3389
  var dmToolbarBaseClass = "dm-toolbar";
@@ -2638,36 +3404,34 @@ function getDmToolbarItemClasses({
2638
3404
  // src/components/dropdown/Dropdown.tsx
2639
3405
  import {
2640
3406
  cloneElement,
2641
- forwardRef as forwardRef8,
3407
+ forwardRef as forwardRef9,
2642
3408
  isValidElement,
2643
- useId,
2644
- useState as useState9
3409
+ useEffect as useEffect4,
3410
+ useId as useId2,
3411
+ useRef as useRef4,
3412
+ useState as useState11
2645
3413
  } from "react";
2646
3414
 
2647
3415
  // src/classes/dropdown.ts
2648
- var dropdownWrapperClass = "dropdown-wrapper";
2649
- var dropdownBaseClass = "popover dropdown";
2650
- var dropdownOpenClass = "popover-show dropdown-open";
2651
- var dropdownArrowClass = "popover-arrow dropdown-arrow";
3416
+ var dropdownWrapperClass = "dropdown";
3417
+ var dropdownBaseClass = "dropdown-content";
3418
+ var dropdownArrowClass = "dropdown-arrow";
2652
3419
  var dropdownMenuClass = "menu dropdown-menu";
2653
3420
  var dropdownButtonClass = "dropdown-button";
2654
3421
  var dropdownPlacementClasses = {
2655
- top: "popover-top dropdown-top",
2656
- bottom: "popover-bottom dropdown-bottom",
2657
- left: "popover-left dropdown-left",
2658
- right: "popover-right dropdown-right",
2659
- topLeft: "popover-top dropdown-top-left",
2660
- topRight: "popover-top dropdown-top-right",
2661
- bottomLeft: "popover-bottom dropdown-bottom-left",
2662
- bottomRight: "popover-bottom dropdown-bottom-right"
3422
+ top: "dropdown-block-start",
3423
+ bottom: "dropdown-block-end",
3424
+ left: "dropdown-inline-start",
3425
+ right: "dropdown-inline-end",
3426
+ topLeft: "dropdown-block-start",
3427
+ topRight: "dropdown-block-start",
3428
+ bottomLeft: "dropdown-block-end",
3429
+ bottomRight: "dropdown-block-end"
2663
3430
  };
2664
3431
  function getDropdownClasses({
2665
- placement = "bottomLeft",
2666
- open,
2667
- arrow,
2668
3432
  className
2669
3433
  }) {
2670
- return cn(dropdownBaseClass, dropdownPlacementClasses[placement], open && dropdownOpenClass, !arrow && "popover-no-arrow dropdown-no-arrow", className);
3434
+ return cn(dropdownBaseClass, className);
2671
3435
  }
2672
3436
 
2673
3437
  // src/classes/menu.ts
@@ -2719,21 +3483,18 @@ function getMenuItemClasses({
2719
3483
  }
2720
3484
 
2721
3485
  // src/components/dropdown/Dropdown.tsx
2722
- import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
2723
- function hasTrigger(triggers, trigger) {
2724
- return (triggers ?? ["hover"]).includes(trigger);
2725
- }
3486
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
2726
3487
  function callHandler(handler, event) {
2727
3488
  handler?.(event);
2728
3489
  }
2729
3490
  function renderMenuItem(item, onClick, close) {
2730
3491
  if (item.type === "divider") {
2731
- return /* @__PURE__ */ jsx11("li", {
3492
+ return /* @__PURE__ */ jsx12("li", {
2732
3493
  className: menuDividerClass
2733
3494
  }, String(item.key));
2734
3495
  }
2735
- return /* @__PURE__ */ jsx11("li", {
2736
- children: /* @__PURE__ */ jsxs10("button", {
3496
+ return /* @__PURE__ */ jsx12("li", {
3497
+ children: /* @__PURE__ */ jsxs11("button", {
2737
3498
  type: "button",
2738
3499
  className: cn(menuItemClass, item.danger && "menu-item-danger", item.className),
2739
3500
  disabled: item.disabled,
@@ -2742,18 +3503,18 @@ function renderMenuItem(item, onClick, close) {
2742
3503
  close();
2743
3504
  },
2744
3505
  children: [
2745
- item.icon ? /* @__PURE__ */ jsx11("span", {
3506
+ item.icon ? /* @__PURE__ */ jsx12("span", {
2746
3507
  className: "menu-item-icon",
2747
3508
  children: item.icon
2748
3509
  }) : null,
2749
- /* @__PURE__ */ jsx11("span", {
3510
+ /* @__PURE__ */ jsx12("span", {
2750
3511
  children: item.label
2751
3512
  })
2752
3513
  ]
2753
3514
  })
2754
3515
  }, String(item.key));
2755
3516
  }
2756
- var DropdownRoot = forwardRef8(({
3517
+ var DropdownRoot = forwardRef9(({
2757
3518
  arrow,
2758
3519
  children,
2759
3520
  className,
@@ -2773,148 +3534,214 @@ var DropdownRoot = forwardRef8(({
2773
3534
  trigger = ["hover"],
2774
3535
  ...props
2775
3536
  }, ref) => {
2776
- const [internalOpen, setInternalOpen] = useState9(Boolean(defaultOpen));
2777
- const isControlled = open !== undefined;
2778
- const visible = isControlled ? open : internalOpen;
2779
- const overlayId = useId();
2780
- function setVisible(nextOpen) {
2781
- if (disabled)
3537
+ const [internalOpen, setInternalOpen] = useState11(Boolean(defaultOpen));
3538
+ const [nativeOpen, setNativeOpen] = useState11(Boolean(open ?? defaultOpen));
3539
+ const visible = open ?? internalOpen;
3540
+ const popupRef = useRef4(null);
3541
+ const popupId = useId2();
3542
+ const anchorName = `--dm-dropdown-${popupId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
3543
+ const clickTrigger = trigger.includes("click") || trigger.includes("hover");
3544
+ useEffect4(() => {
3545
+ const popup = popupRef.current;
3546
+ if (!popup?.showPopover || !popup?.hidePopover)
2782
3547
  return;
2783
- if (!isControlled) {
3548
+ if (visible && !popup.matches(":popover-open"))
3549
+ popup.showPopover();
3550
+ if (!visible && popup.matches(":popover-open"))
3551
+ popup.hidePopover();
3552
+ }, [visible]);
3553
+ function setVisible(nextOpen) {
3554
+ if (open === undefined)
2784
3555
  setInternalOpen(nextOpen);
2785
- }
2786
3556
  onOpenChange?.(nextOpen);
2787
3557
  }
2788
- const close = () => setVisible(false);
2789
- const toggleVisible = () => setVisible(!visible);
2790
- const menuNode = overlay ?? (menu?.items ? /* @__PURE__ */ jsx11("ul", {
3558
+ function close() {
3559
+ const popup = popupRef.current;
3560
+ if (popup?.matches(":popover-open"))
3561
+ popup.hidePopover();
3562
+ else
3563
+ setVisible(false);
3564
+ }
3565
+ const menuNode = overlay ?? (menu?.items ? /* @__PURE__ */ jsx12("ul", {
2791
3566
  className: dropdownMenuClass,
2792
3567
  children: menu.items.map((item) => renderMenuItem(item, menu.onClick, close))
2793
3568
  }) : null);
2794
3569
  const popup = dropdownRender ? dropdownRender(menuNode) : menuNode;
2795
- const shouldRenderPopup = !destroyPopupOnHide || visible;
2796
- const triggerProps = {
2797
- "aria-controls": visible ? overlayId : undefined,
2798
- "aria-expanded": visible || undefined,
2799
- onMouseEnter: hasTrigger(trigger, "hover") ? () => setVisible(true) : undefined,
2800
- onMouseLeave: hasTrigger(trigger, "hover") ? () => setVisible(false) : undefined,
2801
- onClick: hasTrigger(trigger, "click") ? toggleVisible : undefined,
2802
- onContextMenu: hasTrigger(trigger, "contextMenu") ? (event) => {
2803
- event.preventDefault();
2804
- toggleVisible();
2805
- } : undefined
3570
+ const show = () => !disabled && popupRef.current?.showPopover?.();
3571
+ const hide = () => !disabled && popupRef.current?.hidePopover?.();
3572
+ const toggle = () => {
3573
+ if (disabled)
3574
+ return;
3575
+ if (popupRef.current?.matches(":popover-open"))
3576
+ hide();
3577
+ else
3578
+ show();
2806
3579
  };
3580
+ const childIsButton = isValidElement(children) && (children.type === "button" || children.type === Button);
2807
3581
  const triggerNode = isValidElement(children) ? cloneElement(children, {
2808
- "aria-controls": triggerProps["aria-controls"] ?? children.props["aria-controls"],
2809
- "aria-expanded": triggerProps["aria-expanded"] ?? children.props["aria-expanded"],
3582
+ popoverTarget: childIsButton && clickTrigger && !disabled ? popupId : undefined,
3583
+ style: {
3584
+ ...children.props.style,
3585
+ anchorName
3586
+ },
3587
+ "aria-controls": popupId,
3588
+ "aria-expanded": nativeOpen,
3589
+ disabled: disabled || children.props.disabled,
2810
3590
  onMouseEnter: (event) => {
2811
3591
  callHandler(children.props.onMouseEnter, event);
2812
- triggerProps.onMouseEnter?.();
3592
+ if (trigger.includes("hover"))
3593
+ show();
2813
3594
  onMouseEnter?.(event);
2814
3595
  },
2815
3596
  onMouseLeave: (event) => {
2816
3597
  callHandler(children.props.onMouseLeave, event);
2817
- triggerProps.onMouseLeave?.();
2818
3598
  onMouseLeave?.(event);
2819
3599
  },
2820
3600
  onClick: (event) => {
2821
3601
  callHandler(children.props.onClick, event);
2822
- triggerProps.onClick?.();
2823
3602
  onClick?.(event);
3603
+ if (!childIsButton && clickTrigger && !event.defaultPrevented)
3604
+ toggle();
2824
3605
  },
2825
3606
  onContextMenu: (event) => {
2826
3607
  callHandler(children.props.onContextMenu, event);
2827
- triggerProps.onContextMenu?.(event);
3608
+ if (trigger.includes("contextMenu")) {
3609
+ event.preventDefault();
3610
+ toggle();
3611
+ }
2828
3612
  onContextMenu?.(event);
2829
3613
  }
2830
- }) : /* @__PURE__ */ jsx11("span", {
2831
- role: "button",
2832
- tabIndex: disabled ? -1 : 0,
2833
- "aria-disabled": disabled || undefined,
2834
- "aria-controls": triggerProps["aria-controls"],
2835
- "aria-expanded": triggerProps["aria-expanded"],
3614
+ }) : /* @__PURE__ */ jsx12("button", {
3615
+ type: "button",
3616
+ disabled,
3617
+ popoverTarget: clickTrigger && !disabled ? popupId : undefined,
3618
+ style: { anchorName },
3619
+ "aria-controls": popupId,
3620
+ "aria-expanded": nativeOpen,
2836
3621
  onMouseEnter: (event) => {
2837
- triggerProps.onMouseEnter?.();
3622
+ if (trigger.includes("hover"))
3623
+ show();
2838
3624
  onMouseEnter?.(event);
2839
3625
  },
2840
3626
  onMouseLeave: (event) => {
2841
- triggerProps.onMouseLeave?.();
2842
3627
  onMouseLeave?.(event);
2843
3628
  },
2844
- onClick: (event) => {
2845
- triggerProps.onClick?.();
2846
- onClick?.(event);
2847
- },
2848
- onKeyDown: (event) => {
2849
- if (event.key === "Enter" || event.key === " ") {
3629
+ onClick,
3630
+ onContextMenu: (event) => {
3631
+ if (trigger.includes("contextMenu")) {
2850
3632
  event.preventDefault();
2851
- triggerProps.onClick?.();
3633
+ toggle();
2852
3634
  }
2853
- },
2854
- onContextMenu: (event) => {
2855
- triggerProps.onContextMenu?.(event);
2856
3635
  onContextMenu?.(event);
2857
3636
  },
2858
3637
  children
2859
3638
  });
2860
- return /* @__PURE__ */ jsxs10("span", {
3639
+ return /* @__PURE__ */ jsxs11("span", {
2861
3640
  ...props,
2862
3641
  ref,
2863
- className: dropdownWrapperClass,
3642
+ className: cn(dropdownWrapperClass, dropdownPlacementClasses[placement]),
3643
+ onMouseLeave: trigger.includes("hover") ? hide : undefined,
2864
3644
  children: [
2865
3645
  triggerNode,
2866
- shouldRenderPopup ? /* @__PURE__ */ jsxs10("span", {
2867
- id: overlayId,
2868
- role: "menu",
2869
- className: getDropdownClasses({
2870
- placement,
2871
- open: visible,
2872
- arrow,
2873
- className
2874
- }),
3646
+ /* @__PURE__ */ jsxs11("span", {
3647
+ id: popupId,
3648
+ ref: popupRef,
3649
+ popover: "auto",
3650
+ style: { positionAnchor: anchorName },
3651
+ className: getDropdownClasses({ className, arrow }),
3652
+ onToggle: (event) => {
3653
+ if (event.target !== event.currentTarget)
3654
+ return;
3655
+ const nextOpen = event.nativeEvent.newState === "open";
3656
+ setNativeOpen(nextOpen);
3657
+ setVisible(nextOpen);
3658
+ },
2875
3659
  children: [
2876
- popup,
2877
- arrow ? /* @__PURE__ */ jsx11("span", {
3660
+ !destroyPopupOnHide || visible ? popup : null,
3661
+ arrow ? /* @__PURE__ */ jsx12("span", {
2878
3662
  className: dropdownArrowClass
2879
3663
  }) : null
2880
3664
  ]
2881
- }) : null
3665
+ })
2882
3666
  ]
2883
3667
  });
2884
3668
  });
2885
3669
  DropdownRoot.displayName = "Dropdown";
2886
- var DropdownButton = forwardRef8(({
3670
+ var DropdownButton = forwardRef9(({
2887
3671
  buttonsRender,
2888
3672
  children,
2889
3673
  disabled,
2890
3674
  menu,
2891
3675
  onClick,
2892
3676
  trigger = ["click"],
3677
+ color = "base",
3678
+ appearance = "outline",
3679
+ size,
3680
+ shape,
3681
+ block,
3682
+ isLoading,
3683
+ leftIcon,
3684
+ rightIcon,
3685
+ confirm,
2893
3686
  ...props
2894
3687
  }, ref) => {
3688
+ const buttonStyle = { color, appearance, size, shape };
2895
3689
  const buttons = [
2896
- /* @__PURE__ */ jsx11(Button, {
3690
+ /* @__PURE__ */ jsx12(Button, {
3691
+ ...buttonStyle,
2897
3692
  disabled,
3693
+ isLoading,
3694
+ leftIcon,
3695
+ rightIcon,
3696
+ confirm,
2898
3697
  onClick,
2899
3698
  children
2900
3699
  }, "primary"),
2901
- /* @__PURE__ */ jsx11(Button, {
3700
+ /* @__PURE__ */ jsx12(Button, {
3701
+ ...buttonStyle,
3702
+ type: "button",
2902
3703
  "aria-label": "Open dropdown",
2903
- disabled,
2904
- children: "v"
3704
+ disabled: disabled || isLoading,
3705
+ children: /* @__PURE__ */ jsxs11("svg", {
3706
+ "aria-hidden": "true",
3707
+ width: "18",
3708
+ height: "18",
3709
+ viewBox: "0 0 24 24",
3710
+ fill: "currentColor",
3711
+ children: [
3712
+ /* @__PURE__ */ jsx12("circle", {
3713
+ cx: "5",
3714
+ cy: "12",
3715
+ r: "1.75"
3716
+ }),
3717
+ /* @__PURE__ */ jsx12("circle", {
3718
+ cx: "12",
3719
+ cy: "12",
3720
+ r: "1.75"
3721
+ }),
3722
+ /* @__PURE__ */ jsx12("circle", {
3723
+ cx: "19",
3724
+ cy: "12",
3725
+ r: "1.75"
3726
+ })
3727
+ ]
3728
+ })
2905
3729
  }, "trigger")
2906
3730
  ];
2907
3731
  const renderedButtons = buttonsRender ? buttonsRender(buttons) : buttons;
2908
- return /* @__PURE__ */ jsx11(DropdownRoot, {
2909
- ...props,
3732
+ return /* @__PURE__ */ jsxs11("span", {
2910
3733
  ref,
2911
- menu,
2912
- trigger,
2913
- disabled,
2914
- children: /* @__PURE__ */ jsx11("span", {
2915
- className: dropdownButtonClass,
2916
- children: renderedButtons
2917
- })
3734
+ className: cn(dropdownButtonClass, block && "dropdown-button-block"),
3735
+ children: [
3736
+ renderedButtons[0],
3737
+ /* @__PURE__ */ jsx12(DropdownRoot, {
3738
+ ...props,
3739
+ menu,
3740
+ trigger,
3741
+ disabled: disabled || isLoading,
3742
+ children: renderedButtons[1]
3743
+ })
3744
+ ]
2918
3745
  });
2919
3746
  });
2920
3747
  DropdownButton.displayName = "Dropdown.Button";
@@ -2922,7 +3749,7 @@ var Dropdown = Object.assign(DropdownRoot, {
2922
3749
  Button: DropdownButton
2923
3750
  });
2924
3751
  // src/components/dm-toolbar/DmToolbar.tsx
2925
- import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
3752
+ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
2926
3753
  function isPrimary(item) {
2927
3754
  return item.type === "primary";
2928
3755
  }
@@ -2938,7 +3765,7 @@ function renderToolbarItem(item, index) {
2938
3765
  } = item;
2939
3766
  const buttonProps = { ...buttonPropsWithKey };
2940
3767
  delete buttonProps.key;
2941
- const button = /* @__PURE__ */ jsx12(Button, {
3768
+ const button = /* @__PURE__ */ jsx13(Button, {
2942
3769
  ...buttonProps,
2943
3770
  type: htmlType,
2944
3771
  color: color ?? (type === "primary" ? "primary" : "secondary"),
@@ -2947,7 +3774,7 @@ function renderToolbarItem(item, index) {
2947
3774
  });
2948
3775
  if (!menu?.items?.length)
2949
3776
  return button;
2950
- return /* @__PURE__ */ jsx12(Dropdown, {
3777
+ return /* @__PURE__ */ jsx13(Dropdown, {
2951
3778
  trigger: ["click"],
2952
3779
  menu,
2953
3780
  children: button
@@ -2973,7 +3800,7 @@ function DmToolbar({
2973
3800
  moreText = "More",
2974
3801
  maxVisibleSecondaryItems
2975
3802
  }) {
2976
- const { visibleSecondaryItems, overflowSecondaryItems, primaryItems } = useMemo8(() => {
3803
+ const { visibleSecondaryItems, overflowSecondaryItems, primaryItems } = useMemo9(() => {
2977
3804
  const primaryItems = items.filter(isPrimary);
2978
3805
  const secondaryItems = items.filter((item) => !isPrimary(item));
2979
3806
  const visibleLimit = maxVisibleSecondaryItems === undefined ? secondaryItems.length : Math.max(0, maxVisibleSecondaryItems);
@@ -2982,18 +3809,18 @@ function DmToolbar({
2982
3809
  return { visibleSecondaryItems, overflowSecondaryItems, primaryItems };
2983
3810
  }, [items, maxVisibleSecondaryItems]);
2984
3811
  const showMore = overflowSecondaryItems.length > 0;
2985
- return /* @__PURE__ */ jsxs11("div", {
3812
+ return /* @__PURE__ */ jsxs12("div", {
2986
3813
  className: getDmToolbarClasses({ className }),
2987
3814
  style,
2988
3815
  children: [
2989
- visibleSecondaryItems.map((item, index) => /* @__PURE__ */ jsx12("span", {
3816
+ visibleSecondaryItems.map((item, index) => /* @__PURE__ */ jsx13("span", {
2990
3817
  className: getDmToolbarItemClasses({}),
2991
3818
  children: renderToolbarItem(item, index)
2992
3819
  }, item.key ?? `secondary-${index}`)),
2993
- showMore ? /* @__PURE__ */ jsx12(Dropdown, {
3820
+ showMore ? /* @__PURE__ */ jsx13(Dropdown, {
2994
3821
  trigger: ["click"],
2995
3822
  menu: toOverflowMenu(overflowSecondaryItems),
2996
- children: /* @__PURE__ */ jsx12(Button, {
3823
+ children: /* @__PURE__ */ jsx13(Button, {
2997
3824
  type: "button",
2998
3825
  className: dmToolbarMoreClass,
2999
3826
  color: "secondary",
@@ -3001,7 +3828,7 @@ function DmToolbar({
3001
3828
  children: moreText
3002
3829
  })
3003
3830
  }) : null,
3004
- primaryItems.map((item, index) => /* @__PURE__ */ jsx12("span", {
3831
+ primaryItems.map((item, index) => /* @__PURE__ */ jsx13("span", {
3005
3832
  className: getDmToolbarItemClasses({ primary: true }),
3006
3833
  children: renderToolbarItem(item, index)
3007
3834
  }, item.key ?? `primary-${index}`))
@@ -3010,7 +3837,7 @@ function DmToolbar({
3010
3837
  }
3011
3838
  DmToolbar.displayName = "DmToolbar";
3012
3839
  // src/components/dm-pro-table/DmProTable.tsx
3013
- import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
3840
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
3014
3841
  function renderToolbar(toolBarRender) {
3015
3842
  if (typeof toolBarRender === "function")
3016
3843
  return toolBarRender();
@@ -3026,23 +3853,23 @@ function DmProTable({
3026
3853
  rowData,
3027
3854
  ...props
3028
3855
  }) {
3029
- return /* @__PURE__ */ jsxs12("div", {
3856
+ return /* @__PURE__ */ jsxs13("div", {
3030
3857
  className: getDmProTableClasses({ className }),
3031
3858
  children: [
3032
- showTitleBar ? /* @__PURE__ */ jsxs12("div", {
3859
+ showTitleBar ? /* @__PURE__ */ jsxs13("div", {
3033
3860
  className: dmProTableHeaderClass,
3034
3861
  children: [
3035
- /* @__PURE__ */ jsx13("div", {
3862
+ /* @__PURE__ */ jsx14("div", {
3036
3863
  className: dmProTableTitleClass,
3037
3864
  children: headerTitle
3038
3865
  }),
3039
- /* @__PURE__ */ jsxs12("div", {
3866
+ /* @__PURE__ */ jsxs13("div", {
3040
3867
  className: dmProTableToolbarClass,
3041
3868
  children: [
3042
- toolbarItems?.length ? /* @__PURE__ */ jsx13(DmToolbar, {
3869
+ toolbarItems?.length ? /* @__PURE__ */ jsx14(DmToolbar, {
3043
3870
  items: toolbarItems
3044
3871
  }) : renderToolbar(toolBarRender),
3045
- columnSettingVisible ? /* @__PURE__ */ jsx13(Button, {
3872
+ columnSettingVisible ? /* @__PURE__ */ jsx14(Button, {
3046
3873
  type: "button",
3047
3874
  color: "secondary",
3048
3875
  appearance: "outline",
@@ -3053,7 +3880,7 @@ function DmProTable({
3053
3880
  })
3054
3881
  ]
3055
3882
  }) : null,
3056
- /* @__PURE__ */ jsx13(DmTable, {
3883
+ /* @__PURE__ */ jsx14(DmTable, {
3057
3884
  ...props,
3058
3885
  columnSettingVisible: showTitleBar ? false : columnSettingVisible,
3059
3886
  dataSource: rowData