@duskmoon-dev/components 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +61 -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 +1183 -368
  39. package/dist/components/dm-query/DmQuery.types.d.ts +1 -1
  40. package/dist/components/dm-query/index.js +931 -188
  41. package/dist/components/dm-search/DmSearch.types.d.ts +4 -0
  42. package/dist/components/dm-search/index.js +917 -163
  43. package/dist/components/dm-table/index.js +1001 -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/megamenu/Megamenu.d.ts +2 -0
  55. package/dist/components/megamenu/Megamenu.types.d.ts +32 -0
  56. package/dist/components/megamenu/index.d.ts +2 -0
  57. package/dist/components/megamenu/index.js +214 -0
  58. package/dist/components/modal/index.js +128 -68
  59. package/dist/components/otp-input/OtpInput.d.ts +2 -0
  60. package/dist/components/otp-input/OtpInput.types.d.ts +16 -0
  61. package/dist/components/otp-input/index.d.ts +2 -0
  62. package/dist/components/otp-input/index.js +112 -0
  63. package/dist/components/popconfirm/index.js +255 -26
  64. package/dist/components/popover/index.js +24 -4
  65. package/dist/components/swap/Swap.d.ts +3 -0
  66. package/dist/components/swap/Swap.types.d.ts +22 -0
  67. package/dist/components/swap/index.d.ts +2 -0
  68. package/dist/components/swap/index.js +109 -0
  69. package/dist/components/time-picker/TimePicker.types.d.ts +1 -0
  70. package/dist/components/time-picker/index.js +167 -29
  71. package/dist/components/tooltip/Tooltip.types.d.ts +4 -0
  72. package/dist/components/tooltip/index.js +107 -27
  73. package/dist/components/tour/index.js +253 -24
  74. package/dist/components/tree-select/index.js +8 -8
  75. package/dist/components/upload/Upload.types.d.ts +1 -0
  76. package/dist/components/upload/index.js +2 -0
  77. package/dist/generated/version.d.ts +1 -1
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.js +3330 -1632
  80. package/dist/infrastructure.js +1 -1
  81. package/dist/styles.css +1190 -906
  82. package/package.json +23 -3
@@ -2,11 +2,11 @@
2
2
 
3
3
  // src/components/dm-search/DmSearch.tsx
4
4
  import {
5
- forwardRef as forwardRef4,
6
- useEffect,
7
- useImperativeHandle as useImperativeHandle2,
8
- useMemo as useMemo3,
9
- useState as useState4
5
+ forwardRef as forwardRef5,
6
+ useEffect as useEffect2,
7
+ useImperativeHandle as useImperativeHandle3,
8
+ useMemo as useMemo4,
9
+ useState as useState6
10
10
  } from "react";
11
11
 
12
12
  // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
@@ -50,6 +50,10 @@ function getDmSearchClasses({
50
50
  return cn(dmSearchBaseClass, compact && dmSearchCompactClass, collapsed && dmSearchCollapsedClass, className);
51
51
  }
52
52
 
53
+ // src/components/button/Button.tsx
54
+ import React from "react";
55
+ import { createPortal } from "react-dom";
56
+
53
57
  // src/classes/button.ts
54
58
  var buttonBaseClass = "btn";
55
59
  var buttonColorClasses = {
@@ -73,7 +77,7 @@ var buttonAppearanceClasses = {
73
77
  };
74
78
  var buttonShapeClasses = {
75
79
  rect: "",
76
- circle: "btn-circle",
80
+ circle: "btn-circle btn-icon",
77
81
  square: "btn-square"
78
82
  };
79
83
  var buttonSizeClasses = {
@@ -93,11 +97,14 @@ function getButtonClasses({
93
97
  isLoading,
94
98
  className
95
99
  }) {
96
- return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
100
+ 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);
97
101
  }
98
102
 
99
103
  // src/components/button/Button.tsx
100
- import { jsx, jsxs } from "react/jsx-runtime";
104
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
105
+ function isPromiseLike(value) {
106
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
107
+ }
101
108
  function Button({
102
109
  color = "primary",
103
110
  appearance = "filled",
@@ -111,8 +118,155 @@ function Button({
111
118
  children,
112
119
  disabled,
113
120
  ref,
121
+ confirm,
122
+ onClick,
114
123
  ...props
115
124
  }) {
125
+ const buttonRef = React.useRef(null);
126
+ const popoverRef = React.useRef(null);
127
+ const cancelRef = React.useRef(null);
128
+ const approvalRef = React.useRef("idle");
129
+ const pendingRef = React.useRef(false);
130
+ const actionRef = React.useRef(0);
131
+ const operationRef = React.useRef(0);
132
+ const mountedRef = React.useRef(false);
133
+ const [portalTarget, setPortalTarget] = React.useState(null);
134
+ const [confirmLoading, setConfirmLoading] = React.useState(false);
135
+ const [confirmError, setConfirmError] = React.useState(false);
136
+ const generatedId = React.useId().replace(/:/g, "");
137
+ const popoverId = `button-confirm-${generatedId}`;
138
+ const titleId = `${popoverId}-title`;
139
+ const descriptionId = `${popoverId}-description`;
140
+ const anchor = `--${popoverId}-anchor`;
141
+ const hasConfirm = Boolean(confirm);
142
+ const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
143
+ const title = confirmation ? confirmation.title : "Confirm action";
144
+ const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
145
+ const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
146
+ const hasContent = content !== undefined && content !== null && content !== false && content !== "";
147
+ const mergedRef = React.useCallback((node) => {
148
+ buttonRef.current = node;
149
+ if (!node) {
150
+ if (typeof ref === "function")
151
+ ref(null);
152
+ else if (ref)
153
+ ref.current = null;
154
+ return;
155
+ }
156
+ const cleanup = typeof ref === "function" ? ref(node) : undefined;
157
+ if (ref && typeof ref !== "function")
158
+ ref.current = node;
159
+ return () => {
160
+ buttonRef.current = null;
161
+ if (typeof cleanup === "function")
162
+ cleanup();
163
+ else if (typeof ref === "function")
164
+ ref(null);
165
+ else if (ref)
166
+ ref.current = null;
167
+ };
168
+ }, [ref]);
169
+ React.useEffect(() => {
170
+ mountedRef.current = true;
171
+ return () => {
172
+ mountedRef.current = false;
173
+ operationRef.current += 1;
174
+ };
175
+ }, []);
176
+ React.useEffect(() => {
177
+ operationRef.current += 1;
178
+ approvalRef.current = "idle";
179
+ setConfirmError(false);
180
+ setPortalTarget(hasConfirm ? document.body : null);
181
+ }, [hasConfirm]);
182
+ function closePopover() {
183
+ if (popoverRef.current?.matches(":popover-open")) {
184
+ popoverRef.current.hidePopover();
185
+ }
186
+ buttonRef.current?.focus();
187
+ }
188
+ function handleClick(event) {
189
+ if (!confirm) {
190
+ onClick?.(event);
191
+ return;
192
+ }
193
+ if (approvalRef.current === "native") {
194
+ approvalRef.current = "idle";
195
+ return;
196
+ }
197
+ if (approvalRef.current === "action") {
198
+ approvalRef.current = "idle";
199
+ let result;
200
+ try {
201
+ result = onClick?.(event);
202
+ } catch {
203
+ event.preventDefault();
204
+ pendingRef.current = false;
205
+ setConfirmError(true);
206
+ return;
207
+ }
208
+ if (!isPromiseLike(result)) {
209
+ pendingRef.current = false;
210
+ closePopover();
211
+ return;
212
+ }
213
+ const userPreventedDefault = event.defaultPrevented;
214
+ event.preventDefault();
215
+ setConfirmLoading(true);
216
+ const action = actionRef.current;
217
+ const operation = operationRef.current;
218
+ Promise.resolve(result).then(() => {
219
+ if (!mountedRef.current || action !== actionRef.current)
220
+ return;
221
+ pendingRef.current = false;
222
+ setConfirmLoading(false);
223
+ if (operation !== operationRef.current)
224
+ return;
225
+ closePopover();
226
+ if (!userPreventedDefault && !buttonRef.current?.disabled) {
227
+ approvalRef.current = "native";
228
+ buttonRef.current?.click();
229
+ approvalRef.current = "idle";
230
+ }
231
+ }, () => {
232
+ if (!mountedRef.current || action !== actionRef.current)
233
+ return;
234
+ pendingRef.current = false;
235
+ setConfirmLoading(false);
236
+ if (operation !== operationRef.current)
237
+ return;
238
+ setConfirmError(true);
239
+ cancelRef.current?.focus();
240
+ });
241
+ return;
242
+ }
243
+ event.preventDefault();
244
+ if (disabled || isLoading || pendingRef.current)
245
+ return;
246
+ if (popoverRef.current?.matches(":popover-open")) {
247
+ closePopover();
248
+ return;
249
+ }
250
+ setConfirmError(false);
251
+ popoverRef.current?.showPopover();
252
+ cancelRef.current?.focus();
253
+ }
254
+ function handleConfirm(event) {
255
+ event.preventDefault();
256
+ event.stopPropagation();
257
+ const trigger = buttonRef.current;
258
+ if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
259
+ return;
260
+ setConfirmError(false);
261
+ pendingRef.current = true;
262
+ actionRef.current += 1;
263
+ approvalRef.current = "action";
264
+ trigger.click();
265
+ if (approvalRef.current === "action") {
266
+ approvalRef.current = "idle";
267
+ pendingRef.current = false;
268
+ }
269
+ }
116
270
  const classes = getButtonClasses({
117
271
  color,
118
272
  appearance,
@@ -122,34 +276,526 @@ function Button({
122
276
  isLoading,
123
277
  className
124
278
  });
125
- return /* @__PURE__ */ jsxs("button", {
126
- ref,
127
- className: classes,
128
- disabled: disabled || isLoading,
129
- "aria-busy": isLoading,
130
- "aria-disabled": disabled || isLoading,
131
- ...props,
279
+ const confirmClasses = getButtonClasses({
280
+ color,
281
+ size: "sm",
282
+ isLoading: confirmLoading
283
+ });
284
+ return /* @__PURE__ */ jsxs(Fragment, {
132
285
  children: [
133
- isLoading && /* @__PURE__ */ jsx("span", {
134
- className: "btn-spinner"
286
+ /* @__PURE__ */ jsxs("button", {
287
+ ref: confirm ? mergedRef : ref,
288
+ className: classes,
289
+ disabled: disabled || isLoading,
290
+ "aria-busy": isLoading,
291
+ "aria-disabled": disabled || isLoading,
292
+ ...props,
293
+ style: confirm ? { ...props.style, anchorName: anchor } : props.style,
294
+ "aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
295
+ "aria-controls": confirm ? popoverId : props["aria-controls"],
296
+ onClick: confirm ? handleClick : onClick,
297
+ children: [
298
+ isLoading && /* @__PURE__ */ jsx("span", {
299
+ className: "btn-spinner"
300
+ }),
301
+ !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
302
+ className: "btn-icon-left",
303
+ children: leftIcon
304
+ }),
305
+ /* @__PURE__ */ jsx("span", {
306
+ className: "btn-content",
307
+ children
308
+ }),
309
+ !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
310
+ className: "btn-icon-right",
311
+ children: rightIcon
312
+ })
313
+ ]
135
314
  }),
136
- !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
137
- className: "btn-icon-left",
138
- children: leftIcon
315
+ confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
316
+ id: popoverId,
317
+ ref: popoverRef,
318
+ popover: "auto",
319
+ role: "dialog",
320
+ "aria-labelledby": hasTitle ? titleId : undefined,
321
+ "aria-label": hasTitle ? undefined : "Confirm action",
322
+ "aria-describedby": hasContent ? descriptionId : undefined,
323
+ className: "popover popover-confirm popover-bottom",
324
+ style: { positionAnchor: anchor },
325
+ onSubmit: handleConfirm,
326
+ onClick: (event) => event.stopPropagation(),
327
+ onToggle: (event) => {
328
+ if (!event.currentTarget.matches(":popover-open")) {
329
+ operationRef.current += 1;
330
+ if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
331
+ buttonRef.current?.focus();
332
+ }
333
+ }
334
+ },
335
+ children: [
336
+ hasTitle && /* @__PURE__ */ jsx("div", {
337
+ className: "popover-header",
338
+ children: /* @__PURE__ */ jsx("h3", {
339
+ id: titleId,
340
+ className: "popover-title",
341
+ children: title
342
+ })
343
+ }),
344
+ hasContent && /* @__PURE__ */ jsx("div", {
345
+ id: descriptionId,
346
+ className: "popover-body",
347
+ children: content
348
+ }),
349
+ confirmError && /* @__PURE__ */ jsx("div", {
350
+ role: "alert",
351
+ className: "popover-body",
352
+ children: "The action failed. Please try again."
353
+ }),
354
+ /* @__PURE__ */ jsxs("div", {
355
+ className: "popover-footer",
356
+ children: [
357
+ /* @__PURE__ */ jsx("button", {
358
+ ref: cancelRef,
359
+ type: "button",
360
+ className: "btn btn-text btn-sm",
361
+ popoverTarget: popoverId,
362
+ popoverTargetAction: "hide",
363
+ disabled: confirmLoading,
364
+ children: confirmation?.cancelText ?? "Cancel"
365
+ }),
366
+ /* @__PURE__ */ jsx("button", {
367
+ type: "submit",
368
+ className: confirmClasses,
369
+ disabled: disabled || isLoading || confirmLoading,
370
+ "aria-busy": confirmLoading,
371
+ children: confirmation?.confirmText ?? "Confirm"
372
+ })
373
+ ]
374
+ })
375
+ ]
376
+ }), portalTarget)
377
+ ]
378
+ });
379
+ }
380
+ // src/components/date-picker/DatePicker.tsx
381
+ import { forwardRef as forwardRef2, useMemo as useMemo2, useState as useState3 } from "react";
382
+
383
+ // src/components/calendar/Calendar.tsx
384
+ import { forwardRef, useMemo, useState } from "react";
385
+
386
+ // src/classes/calendar.ts
387
+ var calendarBaseClass = "datepicker calendar";
388
+ var calendarHeaderClass = "calendar-header";
389
+ var calendarTitleClass = "calendar-title";
390
+ var calendarControlsClass = "calendar-controls";
391
+ var calendarNavClass = "calendar-nav";
392
+ var calendarModeClass = "calendar-mode";
393
+ var calendarWeekdaysClass = "calendar-weekdays";
394
+ var calendarWeekdayClass = "calendar-weekday";
395
+ var calendarBodyClass = "calendar-body";
396
+ var calendarDateGridClass = "calendar-date-grid";
397
+ var calendarMonthGridClass = "calendar-month-grid";
398
+ var calendarCellContentClass = "calendar-cell-content";
399
+ function getCalendarClasses({
400
+ fullscreen = true,
401
+ mode = "month",
402
+ className
403
+ }) {
404
+ return cn(calendarBaseClass, fullscreen ? "calendar-fullscreen" : "calendar-card", mode === "year" && "calendar-year-mode", className);
405
+ }
406
+ function getCalendarCellClasses({
407
+ selected,
408
+ today,
409
+ outside,
410
+ disabled,
411
+ className
412
+ }) {
413
+ return cn("calendar-cell", selected && "calendar-cell-selected", today && "calendar-cell-today", outside && "calendar-cell-outside", disabled && "calendar-cell-disabled", className);
414
+ }
415
+
416
+ // src/components/calendar/Calendar.tsx
417
+ import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
418
+ var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
419
+ var MONTHS = [
420
+ "Jan",
421
+ "Feb",
422
+ "Mar",
423
+ "Apr",
424
+ "May",
425
+ "Jun",
426
+ "Jul",
427
+ "Aug",
428
+ "Sep",
429
+ "Oct",
430
+ "Nov",
431
+ "Dec"
432
+ ];
433
+ function pad(value) {
434
+ return String(value).padStart(2, "0");
435
+ }
436
+ function formatDate(date) {
437
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
438
+ }
439
+ function formatMonth(date) {
440
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-01`;
441
+ }
442
+ function parseDate(value) {
443
+ if (value instanceof Date && !Number.isNaN(value.getTime())) {
444
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
445
+ }
446
+ if (typeof value === "string" && value.length > 0) {
447
+ const [year, month = "1", day = "1"] = value.split("-");
448
+ const parsed = new Date(Number(year), Number(month) - 1, Number(day));
449
+ if (!Number.isNaN(parsed.getTime())) {
450
+ return parsed;
451
+ }
452
+ }
453
+ const today = new Date;
454
+ return new Date(today.getFullYear(), today.getMonth(), today.getDate());
455
+ }
456
+ function addMonths(date, amount) {
457
+ return new Date(date.getFullYear(), date.getMonth() + amount, 1);
458
+ }
459
+ function addYears(date, amount) {
460
+ return new Date(date.getFullYear() + amount, date.getMonth(), 1);
461
+ }
462
+ function startOfCalendarGrid(panelDate) {
463
+ const firstOfMonth = new Date(panelDate.getFullYear(), panelDate.getMonth(), 1);
464
+ const start = new Date(firstOfMonth);
465
+ start.setDate(firstOfMonth.getDate() - firstOfMonth.getDay());
466
+ return start;
467
+ }
468
+ function buildDateGrid(panelDate) {
469
+ const start = startOfCalendarGrid(panelDate);
470
+ return Array.from({ length: 42 }, (_, index) => {
471
+ const date = new Date(start);
472
+ date.setDate(start.getDate() + index);
473
+ return date;
474
+ });
475
+ }
476
+ function isSameMonth(left, right) {
477
+ return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();
478
+ }
479
+ function isOutsideRange(date, validRange) {
480
+ if (!validRange) {
481
+ return false;
482
+ }
483
+ const current = formatDate(date);
484
+ const start = formatDate(parseDate(validRange[0]));
485
+ const end = formatDate(parseDate(validRange[1]));
486
+ return current < start || current > end;
487
+ }
488
+ function Header({
489
+ panelDate,
490
+ mode,
491
+ setPanelDate,
492
+ setMode
493
+ }) {
494
+ const title = mode === "year" ? String(panelDate.getFullYear()) : `${MONTHS[panelDate.getMonth()]} ${panelDate.getFullYear()}`;
495
+ return /* @__PURE__ */ jsxs2("div", {
496
+ className: calendarHeaderClass,
497
+ children: [
498
+ /* @__PURE__ */ jsx2("button", {
499
+ type: "button",
500
+ className: calendarNavClass,
501
+ "aria-label": "Previous panel",
502
+ onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, -1) : addMonths(panelDate, -1), mode),
503
+ children: /* @__PURE__ */ jsx2("svg", {
504
+ "aria-hidden": "true",
505
+ focusable: "false",
506
+ width: "16",
507
+ height: "16",
508
+ viewBox: "0 0 24 24",
509
+ fill: "none",
510
+ stroke: "currentColor",
511
+ strokeWidth: "2",
512
+ strokeLinecap: "round",
513
+ strokeLinejoin: "round",
514
+ children: /* @__PURE__ */ jsx2("path", {
515
+ d: "m15 18-6-6 6-6"
516
+ })
517
+ })
139
518
  }),
140
- /* @__PURE__ */ jsx("span", {
141
- className: "btn-content",
142
- children
519
+ /* @__PURE__ */ jsxs2("div", {
520
+ className: calendarControlsClass,
521
+ children: [
522
+ /* @__PURE__ */ jsx2("div", {
523
+ className: calendarTitleClass,
524
+ children: title
525
+ }),
526
+ /* @__PURE__ */ jsxs2("div", {
527
+ className: calendarModeClass,
528
+ children: [
529
+ /* @__PURE__ */ jsx2("button", {
530
+ type: "button",
531
+ "aria-pressed": mode === "month",
532
+ onClick: () => setMode("month"),
533
+ children: "Month"
534
+ }),
535
+ /* @__PURE__ */ jsx2("button", {
536
+ type: "button",
537
+ "aria-pressed": mode === "year",
538
+ onClick: () => setMode("year"),
539
+ children: "Year"
540
+ })
541
+ ]
542
+ })
543
+ ]
143
544
  }),
144
- !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
145
- className: "btn-icon-right",
146
- children: rightIcon
545
+ /* @__PURE__ */ jsx2("button", {
546
+ type: "button",
547
+ className: calendarNavClass,
548
+ "aria-label": "Next panel",
549
+ onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, 1) : addMonths(panelDate, 1), mode),
550
+ children: /* @__PURE__ */ jsx2("svg", {
551
+ "aria-hidden": "true",
552
+ focusable: "false",
553
+ width: "16",
554
+ height: "16",
555
+ viewBox: "0 0 24 24",
556
+ fill: "none",
557
+ stroke: "currentColor",
558
+ strokeWidth: "2",
559
+ strokeLinecap: "round",
560
+ strokeLinejoin: "round",
561
+ children: /* @__PURE__ */ jsx2("path", {
562
+ d: "m9 18 6-6-6-6"
563
+ })
564
+ })
147
565
  })
148
566
  ]
149
567
  });
150
568
  }
151
- // src/components/date-picker/DatePicker.tsx
152
- import { forwardRef, useMemo, useState } from "react";
569
+ var Calendar = forwardRef(({
570
+ className,
571
+ value,
572
+ defaultValue,
573
+ mode,
574
+ defaultMode = "month",
575
+ fullscreen = true,
576
+ validRange,
577
+ disabledDate,
578
+ dateCellRender,
579
+ dateFullCellRender,
580
+ monthCellRender,
581
+ monthFullCellRender,
582
+ cellRender,
583
+ fullCellRender,
584
+ headerRender,
585
+ onChange,
586
+ onSelect,
587
+ onPanelChange,
588
+ ...props
589
+ }, ref) => {
590
+ const selectedDate = parseDate(value ?? defaultValue);
591
+ const [innerValue, setInnerValue] = useState(() => formatDate(selectedDate));
592
+ const [panelDate, setInnerPanelDate] = useState(selectedDate);
593
+ const [innerMode, setInnerMode] = useState(mode ?? defaultMode);
594
+ const currentMode = mode ?? innerMode;
595
+ const currentValue = value === undefined ? innerValue : formatDate(parseDate(value));
596
+ const today = useMemo(() => formatDate(new Date), []);
597
+ const dateGrid = useMemo(() => buildDateGrid(panelDate), [panelDate]);
598
+ function emitPanelChange(nextDate, nextMode = currentMode) {
599
+ setInnerPanelDate(nextDate);
600
+ onPanelChange?.(formatDate(nextDate), nextMode);
601
+ }
602
+ function setCalendarMode(nextMode) {
603
+ if (mode === undefined) {
604
+ setInnerMode(nextMode);
605
+ }
606
+ onPanelChange?.(formatDate(panelDate), nextMode);
607
+ }
608
+ function commitValue(nextDate, source) {
609
+ const nextValue = source === "month" ? formatMonth(nextDate) : formatDate(nextDate);
610
+ if (disabledDate?.(nextValue) || isOutsideRange(nextDate, validRange)) {
611
+ return;
612
+ }
613
+ if (value === undefined) {
614
+ setInnerValue(nextValue);
615
+ }
616
+ setInnerPanelDate(nextDate);
617
+ onSelect?.(nextValue, { source });
618
+ onChange?.(nextValue);
619
+ }
620
+ function renderDateCell(date) {
621
+ const dateValue = formatDate(date);
622
+ const originNode = /* @__PURE__ */ jsxs2("div", {
623
+ className: calendarCellContentClass,
624
+ children: [
625
+ /* @__PURE__ */ jsx2("span", {
626
+ children: date.getDate()
627
+ }),
628
+ dateCellRender?.(dateValue)
629
+ ]
630
+ });
631
+ const info = {
632
+ originNode,
633
+ today,
634
+ type: "month"
635
+ };
636
+ const content = fullCellRender?.(dateValue, info) ?? dateFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
637
+ const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
638
+ return /* @__PURE__ */ jsx2("button", {
639
+ type: "button",
640
+ "aria-label": dateValue,
641
+ disabled,
642
+ className: getCalendarCellClasses({
643
+ selected: dateValue === currentValue,
644
+ today: dateValue === today,
645
+ outside: !isSameMonth(date, panelDate),
646
+ disabled
647
+ }),
648
+ onClick: () => commitValue(date, "date"),
649
+ children: content
650
+ }, dateValue);
651
+ }
652
+ function renderMonthCell(month) {
653
+ const date = new Date(panelDate.getFullYear(), month, 1);
654
+ const dateValue = formatMonth(date);
655
+ const originNode = /* @__PURE__ */ jsxs2("div", {
656
+ className: calendarCellContentClass,
657
+ children: [
658
+ /* @__PURE__ */ jsx2("span", {
659
+ children: MONTHS[month]
660
+ }),
661
+ monthCellRender?.(dateValue)
662
+ ]
663
+ });
664
+ const info = {
665
+ originNode,
666
+ today,
667
+ type: "year"
668
+ };
669
+ const content = fullCellRender?.(dateValue, info) ?? monthFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
670
+ const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
671
+ return /* @__PURE__ */ jsx2("button", {
672
+ type: "button",
673
+ "aria-label": dateValue,
674
+ disabled,
675
+ className: getCalendarCellClasses({
676
+ selected: dateValue === formatMonth(parseDate(currentValue)),
677
+ today: dateValue === formatMonth(new Date),
678
+ disabled
679
+ }),
680
+ onClick: () => commitValue(date, "month"),
681
+ children: content
682
+ }, dateValue);
683
+ }
684
+ return /* @__PURE__ */ jsxs2("div", {
685
+ ...props,
686
+ ref,
687
+ className: getCalendarClasses({
688
+ fullscreen,
689
+ mode: currentMode,
690
+ className
691
+ }),
692
+ children: [
693
+ headerRender ? headerRender({
694
+ value: formatDate(panelDate),
695
+ type: currentMode,
696
+ onChange: (nextValue) => emitPanelChange(parseDate(nextValue)),
697
+ onTypeChange: setCalendarMode
698
+ }) : /* @__PURE__ */ jsx2(Header, {
699
+ panelDate,
700
+ mode: currentMode,
701
+ setPanelDate: emitPanelChange,
702
+ setMode: setCalendarMode
703
+ }),
704
+ /* @__PURE__ */ jsx2("div", {
705
+ className: calendarBodyClass,
706
+ children: currentMode === "month" ? /* @__PURE__ */ jsxs2(Fragment2, {
707
+ children: [
708
+ /* @__PURE__ */ jsx2("div", {
709
+ className: calendarWeekdaysClass,
710
+ "aria-hidden": "true",
711
+ children: WEEKDAYS.map((weekday) => /* @__PURE__ */ jsx2("span", {
712
+ className: calendarWeekdayClass,
713
+ children: weekday
714
+ }, weekday))
715
+ }),
716
+ /* @__PURE__ */ jsx2("div", {
717
+ className: calendarDateGridClass,
718
+ children: dateGrid.map(renderDateCell)
719
+ })
720
+ ]
721
+ }) : /* @__PURE__ */ jsx2("div", {
722
+ className: calendarMonthGridClass,
723
+ children: MONTHS.map((_, month) => renderMonthCell(month))
724
+ })
725
+ })
726
+ ]
727
+ });
728
+ });
729
+ Calendar.displayName = "Calendar";
730
+ // src/components/date-picker/usePickerDropdown.ts
731
+ import { useEffect, useId, useImperativeHandle, useRef, useState as useState2 } from "react";
732
+ function usePickerDropdown({
733
+ open,
734
+ defaultOpen,
735
+ disabled,
736
+ onOpenChange,
737
+ ref
738
+ }) {
739
+ const rootRef = useRef(null);
740
+ const inputRef = useRef(null);
741
+ const skipFocus = useRef(false);
742
+ const panelId = useId();
743
+ const [innerOpen, setInnerOpen] = useState2(Boolean(defaultOpen));
744
+ const visible = !disabled && (open ?? innerOpen);
745
+ useImperativeHandle(ref, () => rootRef.current, []);
746
+ function setVisible(next) {
747
+ if (disabled || next === visible)
748
+ return;
749
+ if (open === undefined)
750
+ setInnerOpen(next);
751
+ onOpenChange?.(next);
752
+ }
753
+ function closeAndFocus() {
754
+ skipFocus.current = true;
755
+ inputRef.current?.focus();
756
+ skipFocus.current = false;
757
+ setVisible(false);
758
+ }
759
+ useEffect(() => {
760
+ function handleOutside(event) {
761
+ if (visible && !rootRef.current?.contains(event.target))
762
+ setVisible(false);
763
+ }
764
+ function handleKeyDown(event) {
765
+ if (event.defaultPrevented || !rootRef.current?.contains(event.target))
766
+ return;
767
+ if (event.key === "Escape" && visible) {
768
+ event.preventDefault();
769
+ closeAndFocus();
770
+ } else if (event.key === "ArrowDown" && event.target === inputRef.current) {
771
+ event.preventDefault();
772
+ setVisible(true);
773
+ }
774
+ }
775
+ document.addEventListener("pointerdown", handleOutside);
776
+ document.addEventListener("keydown", handleKeyDown);
777
+ return () => {
778
+ document.removeEventListener("pointerdown", handleOutside);
779
+ document.removeEventListener("keydown", handleKeyDown);
780
+ };
781
+ });
782
+ return {
783
+ rootRef,
784
+ inputRef,
785
+ panelId,
786
+ visible,
787
+ setVisible,
788
+ closeAndFocus,
789
+ onInputFocus: () => {
790
+ if (!skipFocus.current)
791
+ setVisible(true);
792
+ },
793
+ onRootBlur: (event) => {
794
+ if (!event.currentTarget.contains(event.relatedTarget))
795
+ setVisible(false);
796
+ }
797
+ };
798
+ }
153
799
 
154
800
  // src/classes/date-picker.ts
155
801
  var datePickerBaseClass = "datepicker";
@@ -198,7 +844,7 @@ function getDatePickerDropdownClasses({
198
844
  }
199
845
 
200
846
  // src/components/date-picker/DatePicker.tsx
201
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
847
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
202
848
  function todayValue(picker) {
203
849
  const today = new Date;
204
850
  const year = today.getFullYear();
@@ -237,9 +883,10 @@ function placeholderForPicker(picker) {
237
883
  function normalizeDateValue(value) {
238
884
  return typeof value === "string" && value.length > 0 ? value : undefined;
239
885
  }
240
- var DatePickerRoot = forwardRef(({
886
+ var DatePickerRoot = forwardRef2(({
241
887
  allowClear,
242
888
  className,
889
+ inputProps,
243
890
  defaultOpen,
244
891
  defaultValue,
245
892
  disabled,
@@ -258,19 +905,19 @@ var DatePickerRoot = forwardRef(({
258
905
  value,
259
906
  ...props
260
907
  }, ref) => {
908
+ const [calendarMode, setCalendarMode] = useState3("month");
261
909
  const isValueControlled = value !== undefined;
262
- const isOpenControlled = open !== undefined;
263
- const [innerValue, setInnerValue] = useState(() => normalizeDateValue(defaultValue));
264
- const [innerOpen, setInnerOpen] = useState(Boolean(defaultOpen));
910
+ const [innerValue, setInnerValue] = useState3(() => normalizeDateValue(defaultValue));
911
+ const dropdown = usePickerDropdown({
912
+ open,
913
+ defaultOpen,
914
+ disabled,
915
+ onOpenChange,
916
+ ref
917
+ });
265
918
  const currentValue = isValueControlled ? normalizeDateValue(value) : innerValue;
266
- const visible = isOpenControlled ? Boolean(open) : innerOpen;
919
+ const { visible, setVisible } = dropdown;
267
920
  const inputType = inputTypeForPicker(picker);
268
- function setVisible(nextOpen) {
269
- if (!isOpenControlled) {
270
- setInnerOpen(nextOpen);
271
- }
272
- onOpenChange?.(nextOpen);
273
- }
274
921
  function emitChange(nextValue) {
275
922
  if (nextValue && disabledDate?.(nextValue)) {
276
923
  return;
@@ -280,10 +927,17 @@ var DatePickerRoot = forwardRef(({
280
927
  }
281
928
  onChange?.(nextValue, nextValue ?? "");
282
929
  }
283
- const presetItems = useMemo(() => presets ?? [], [presets]);
284
- return /* @__PURE__ */ jsxs2("div", {
930
+ function selectValue(nextValue) {
931
+ if (disabledDate?.(nextValue))
932
+ return;
933
+ emitChange(nextValue);
934
+ dropdown.closeAndFocus();
935
+ }
936
+ const presetItems = useMemo2(() => presets ?? [], [presets]);
937
+ return /* @__PURE__ */ jsxs3("div", {
285
938
  ...props,
286
- ref,
939
+ ref: dropdown.rootRef,
940
+ onBlur: dropdown.onRootBlur,
287
941
  className: getDatePickerClasses({
288
942
  size,
289
943
  status,
@@ -293,7 +947,11 @@ var DatePickerRoot = forwardRef(({
293
947
  className
294
948
  }),
295
949
  children: [
296
- /* @__PURE__ */ jsx2("input", {
950
+ /* @__PURE__ */ jsx3("input", {
951
+ ...inputProps,
952
+ ref: dropdown.inputRef,
953
+ "aria-haspopup": "dialog",
954
+ "aria-controls": visible ? dropdown.panelId : undefined,
297
955
  className: datePickerInputClass,
298
956
  disabled,
299
957
  type: inputType,
@@ -301,15 +959,15 @@ var DatePickerRoot = forwardRef(({
301
959
  placeholder: placeholder ?? placeholderForPicker(picker),
302
960
  onFocus: (event) => {
303
961
  onFocus?.(event);
304
- setVisible(true);
962
+ dropdown.onInputFocus();
305
963
  },
306
964
  onBlur: (event) => {
307
965
  onBlur?.(event);
308
- setVisible(false);
309
966
  },
967
+ onClick: () => setVisible(true),
310
968
  onChange: (event) => emitChange(event.currentTarget.value || undefined)
311
969
  }),
312
- allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx2("button", {
970
+ allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx3("button", {
313
971
  type: "button",
314
972
  className: datePickerClearClass,
315
973
  "aria-label": "Clear date",
@@ -317,26 +975,95 @@ var DatePickerRoot = forwardRef(({
317
975
  onClick: () => emitChange(undefined),
318
976
  children: "x"
319
977
  }) : null,
320
- /* @__PURE__ */ jsx2("span", {
978
+ /* @__PURE__ */ jsx3("button", {
979
+ type: "button",
321
980
  className: datePickerIconClass,
322
- "aria-hidden": "true"
981
+ "aria-label": "Open date picker",
982
+ "aria-haspopup": "dialog",
983
+ "aria-expanded": visible,
984
+ "aria-controls": visible ? dropdown.panelId : undefined,
985
+ disabled,
986
+ onMouseDown: (event) => event.preventDefault(),
987
+ onClick: () => setVisible(!visible),
988
+ children: /* @__PURE__ */ jsxs3("svg", {
989
+ "aria-hidden": "true",
990
+ focusable: "false",
991
+ width: "18",
992
+ height: "18",
993
+ viewBox: "0 0 24 24",
994
+ fill: "none",
995
+ stroke: "currentColor",
996
+ strokeWidth: "1.75",
997
+ strokeLinecap: "round",
998
+ strokeLinejoin: "round",
999
+ children: [
1000
+ /* @__PURE__ */ jsx3("rect", {
1001
+ x: "3",
1002
+ y: "5",
1003
+ width: "18",
1004
+ height: "16",
1005
+ rx: "2"
1006
+ }),
1007
+ /* @__PURE__ */ jsx3("path", {
1008
+ d: "M8 3v4M16 3v4M3 10h18"
1009
+ })
1010
+ ]
1011
+ })
323
1012
  }),
324
- (presetItems.length > 0 || showNow) && visible ? /* @__PURE__ */ jsxs2("div", {
1013
+ visible ? /* @__PURE__ */ jsxs3("div", {
1014
+ id: dropdown.panelId,
1015
+ role: "dialog",
1016
+ "aria-label": "Choose date",
325
1017
  className: getDatePickerDropdownClasses({ open: visible }),
326
1018
  children: [
327
- presetItems.map((preset, index) => /* @__PURE__ */ jsx2("button", {
1019
+ picker === "date" || picker === "month" ? /* @__PURE__ */ jsx3(Calendar, {
1020
+ fullscreen: false,
1021
+ value: currentValue,
1022
+ mode: picker === "month" ? "year" : calendarMode,
1023
+ onPanelChange: (_, mode) => {
1024
+ if (picker === "date")
1025
+ setCalendarMode(mode);
1026
+ },
1027
+ disabledDate: (date) => {
1028
+ if (!disabledDate)
1029
+ return false;
1030
+ if (picker === "month")
1031
+ return disabledDate(date.slice(0, 7));
1032
+ if (calendarMode === "year") {
1033
+ const [year, month] = date.split("-").map(Number);
1034
+ const days = new Date(year, month, 0).getDate();
1035
+ return Array.from({ length: days }, (_, index) => `${date.slice(0, 7)}-${String(index + 1).padStart(2, "0")}`).every((day) => disabledDate(day));
1036
+ }
1037
+ return disabledDate(date);
1038
+ },
1039
+ onSelect: (date, info) => {
1040
+ if (picker === "date" && info.source === "month") {
1041
+ setCalendarMode("month");
1042
+ return;
1043
+ }
1044
+ selectValue(picker === "month" ? date.slice(0, 7) : date);
1045
+ }
1046
+ }) : /* @__PURE__ */ jsx3("input", {
1047
+ type: inputType,
1048
+ "aria-label": placeholderForPicker(picker),
1049
+ value: currentValue ?? "",
1050
+ onChange: (event) => selectValue(event.currentTarget.value)
1051
+ }),
1052
+ presetItems.map((preset, index) => /* @__PURE__ */ jsx3("button", {
328
1053
  type: "button",
329
1054
  className: datePickerPresetClass,
330
1055
  onMouseDown: (event) => event.preventDefault(),
331
- onClick: () => emitChange(preset.value),
1056
+ disabled: Boolean(disabledDate?.(preset.value)),
1057
+ onClick: () => selectValue(preset.value),
332
1058
  children: preset.label
333
1059
  }, index)),
334
- showNow ? /* @__PURE__ */ jsx2("div", {
1060
+ showNow ? /* @__PURE__ */ jsx3("div", {
335
1061
  className: datePickerFooterClass,
336
- children: /* @__PURE__ */ jsx2("button", {
1062
+ children: /* @__PURE__ */ jsx3("button", {
337
1063
  type: "button",
338
1064
  onMouseDown: (event) => event.preventDefault(),
339
- onClick: () => emitChange(todayValue(picker)),
1065
+ disabled: Boolean(disabledDate?.(todayValue(picker))),
1066
+ onClick: () => selectValue(todayValue(picker)),
340
1067
  children: "Now"
341
1068
  })
342
1069
  }) : null
@@ -346,9 +1073,10 @@ var DatePickerRoot = forwardRef(({
346
1073
  });
347
1074
  });
348
1075
  DatePickerRoot.displayName = "DatePicker";
349
- var RangePicker = forwardRef(({
1076
+ var RangePicker = forwardRef2(({
350
1077
  allowClear,
351
1078
  className,
1079
+ inputProps,
352
1080
  defaultValue,
353
1081
  disabled,
354
1082
  disabledDate,
@@ -362,7 +1090,7 @@ var RangePicker = forwardRef(({
362
1090
  ...props
363
1091
  }, ref) => {
364
1092
  const isControlled = value !== undefined;
365
- const [innerValue, setInnerValue] = useState(defaultValue ?? [undefined, undefined]);
1093
+ const [innerValue, setInnerValue] = useState3(defaultValue ?? [undefined, undefined]);
366
1094
  const currentValue = isControlled ? value : innerValue;
367
1095
  const inputType = inputTypeForPicker(picker);
368
1096
  function emitChange(nextValue) {
@@ -377,7 +1105,7 @@ var RangePicker = forwardRef(({
377
1105
  function updateIndex(index, nextItem) {
378
1106
  emitChange(index === 0 ? [nextItem, currentValue?.[1]] : [currentValue?.[0], nextItem]);
379
1107
  }
380
- return /* @__PURE__ */ jsxs2("div", {
1108
+ return /* @__PURE__ */ jsxs3("div", {
381
1109
  ...props,
382
1110
  ref,
383
1111
  className: getDatePickerClasses({
@@ -389,7 +1117,8 @@ var RangePicker = forwardRef(({
389
1117
  className
390
1118
  }),
391
1119
  children: [
392
- /* @__PURE__ */ jsx2("input", {
1120
+ /* @__PURE__ */ jsx3("input", {
1121
+ ...inputProps,
393
1122
  className: datePickerInputClass,
394
1123
  disabled,
395
1124
  type: inputType,
@@ -397,11 +1126,13 @@ var RangePicker = forwardRef(({
397
1126
  placeholder: Array.isArray(placeholder) ? placeholder[0] : "Start date",
398
1127
  onChange: (event) => updateIndex(0, event.currentTarget.value || undefined)
399
1128
  }),
400
- /* @__PURE__ */ jsx2("span", {
1129
+ /* @__PURE__ */ jsx3("span", {
401
1130
  className: datePickerSeparatorClass,
402
1131
  children: separator
403
1132
  }),
404
- /* @__PURE__ */ jsx2("input", {
1133
+ /* @__PURE__ */ jsx3("input", {
1134
+ ...inputProps,
1135
+ id: inputProps?.id ? `${inputProps.id}-end` : undefined,
405
1136
  className: datePickerInputClass,
406
1137
  disabled,
407
1138
  type: inputType,
@@ -409,7 +1140,7 @@ var RangePicker = forwardRef(({
409
1140
  placeholder: Array.isArray(placeholder) ? placeholder[1] : "End date",
410
1141
  onChange: (event) => updateIndex(1, event.currentTarget.value || undefined)
411
1142
  }),
412
- allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx2("button", {
1143
+ allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx3("button", {
413
1144
  type: "button",
414
1145
  className: datePickerClearClass,
415
1146
  "aria-label": "Clear date range",
@@ -421,7 +1152,7 @@ var RangePicker = forwardRef(({
421
1152
  });
422
1153
  RangePicker.displayName = "DatePicker.RangePicker";
423
1154
  function withPicker(picker, displayName) {
424
- const Picker = forwardRef((props, ref) => /* @__PURE__ */ jsx2(DatePickerRoot, {
1155
+ const Picker = forwardRef2((props, ref) => /* @__PURE__ */ jsx3(DatePickerRoot, {
425
1156
  ...props,
426
1157
  ref,
427
1158
  picker
@@ -438,10 +1169,10 @@ var DatePicker = Object.assign(DatePickerRoot, {
438
1169
  });
439
1170
  // src/components/input/Input.tsx
440
1171
  import {
441
- forwardRef as forwardRef2,
442
- useImperativeHandle,
443
- useRef,
444
- useState as useState2
1172
+ forwardRef as forwardRef3,
1173
+ useImperativeHandle as useImperativeHandle2,
1174
+ useRef as useRef2,
1175
+ useState as useState4
445
1176
  } from "react";
446
1177
 
447
1178
  // src/classes/input.ts
@@ -530,14 +1261,14 @@ function getTextAreaCountClasses({ exceeded }) {
530
1261
  }
531
1262
 
532
1263
  // src/components/input/Input.tsx
533
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1264
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
534
1265
  function toTextValue(value) {
535
1266
  if (Array.isArray(value)) {
536
1267
  return value.join(",");
537
1268
  }
538
1269
  return value == null ? "" : String(value);
539
1270
  }
540
- var InputRoot = forwardRef2(({
1271
+ var InputRoot = forwardRef3(({
541
1272
  allowClear,
542
1273
  className,
543
1274
  defaultValue,
@@ -552,12 +1283,12 @@ var InputRoot = forwardRef2(({
552
1283
  variant = "outlined",
553
1284
  ...props
554
1285
  }, ref) => {
555
- const inputRef = useRef(null);
556
- const [internalValue, setInternalValue] = useState2(() => toTextValue(defaultValue));
1286
+ const inputRef = useRef2(null);
1287
+ const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
557
1288
  const isControlled = value !== undefined;
558
1289
  const currentValue = isControlled ? toTextValue(value) : internalValue;
559
1290
  const hasAffix = prefix != null || suffix != null || allowClear;
560
- useImperativeHandle(ref, () => inputRef.current);
1291
+ useImperativeHandle2(ref, () => inputRef.current);
561
1292
  function handleChange(event) {
562
1293
  if (!isControlled) {
563
1294
  setInternalValue(event.currentTarget.value);
@@ -580,7 +1311,7 @@ var InputRoot = forwardRef2(({
580
1311
  });
581
1312
  input.focus();
582
1313
  }
583
- const control = /* @__PURE__ */ jsx3("input", {
1314
+ const control = /* @__PURE__ */ jsx4("input", {
584
1315
  ...props,
585
1316
  ref: inputRef,
586
1317
  type,
@@ -593,22 +1324,22 @@ var InputRoot = forwardRef2(({
593
1324
  return control;
594
1325
  }
595
1326
  const showClear = allowClear && !disabled && currentValue.length > 0;
596
- return /* @__PURE__ */ jsxs3("span", {
1327
+ return /* @__PURE__ */ jsxs4("span", {
597
1328
  className: getInputWrapperClasses({ affixed: hasAffix }),
598
1329
  children: [
599
- prefix != null ? /* @__PURE__ */ jsx3("span", {
1330
+ prefix != null ? /* @__PURE__ */ jsx4("span", {
600
1331
  className: inputPrefixClass,
601
1332
  children: prefix
602
1333
  }) : null,
603
1334
  control,
604
- showClear ? /* @__PURE__ */ jsx3("button", {
1335
+ showClear ? /* @__PURE__ */ jsx4("button", {
605
1336
  type: "button",
606
1337
  className: inputClearClass,
607
1338
  "aria-label": "Clear input",
608
1339
  onClick: handleClear,
609
1340
  children: "x"
610
1341
  }) : null,
611
- suffix != null ? /* @__PURE__ */ jsx3("span", {
1342
+ suffix != null ? /* @__PURE__ */ jsx4("span", {
612
1343
  className: inputSuffixClass,
613
1344
  children: suffix
614
1345
  }) : null
@@ -616,7 +1347,7 @@ var InputRoot = forwardRef2(({
616
1347
  });
617
1348
  });
618
1349
  InputRoot.displayName = "Input";
619
- var Search = forwardRef2(({
1350
+ var Search = forwardRef3(({
620
1351
  className,
621
1352
  disabled,
622
1353
  enterButton,
@@ -625,8 +1356,8 @@ var Search = forwardRef2(({
625
1356
  onSearch,
626
1357
  ...props
627
1358
  }, ref) => {
628
- const inputRef = useRef(null);
629
- useImperativeHandle(ref, () => inputRef.current);
1359
+ const inputRef = useRef2(null);
1360
+ useImperativeHandle2(ref, () => inputRef.current);
630
1361
  function emitSearch(event) {
631
1362
  onSearch?.(inputRef.current?.value ?? "", event);
632
1363
  }
@@ -637,16 +1368,16 @@ var Search = forwardRef2(({
637
1368
  }
638
1369
  }
639
1370
  const buttonContent = enterButton === true ? "Search" : enterButton ?? "Search";
640
- return /* @__PURE__ */ jsxs3("span", {
1371
+ return /* @__PURE__ */ jsxs4("span", {
641
1372
  className: getSearchWrapperClasses({ className }),
642
1373
  children: [
643
- /* @__PURE__ */ jsx3(InputRoot, {
1374
+ /* @__PURE__ */ jsx4(InputRoot, {
644
1375
  ...props,
645
1376
  ref: inputRef,
646
1377
  disabled,
647
1378
  onKeyDown: handleKeyDown
648
1379
  }),
649
- enterButton || loading ? /* @__PURE__ */ jsx3("button", {
1380
+ enterButton || loading ? /* @__PURE__ */ jsx4("button", {
650
1381
  type: "button",
651
1382
  className: inputSearchButtonClass,
652
1383
  disabled: disabled || loading,
@@ -658,10 +1389,10 @@ var Search = forwardRef2(({
658
1389
  });
659
1390
  });
660
1391
  Search.displayName = "Input.Search";
661
- var Password = forwardRef2(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
662
- const [visible, setVisible] = useState2(false);
1392
+ var Password = forwardRef3(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
1393
+ const [visible, setVisible] = useState4(false);
663
1394
  const type = visible ? "text" : "password";
664
- const toggle = visibilityToggle ? /* @__PURE__ */ jsx3("button", {
1395
+ const toggle = visibilityToggle ? /* @__PURE__ */ jsx4("button", {
665
1396
  type: "button",
666
1397
  className: inputPasswordToggleClass,
667
1398
  disabled,
@@ -671,9 +1402,9 @@ var Password = forwardRef2(({ className, disabled, visibilityToggle = true, ...p
671
1402
  },
672
1403
  children: visible ? "Hide" : "Show"
673
1404
  }) : undefined;
674
- return /* @__PURE__ */ jsx3("span", {
1405
+ return /* @__PURE__ */ jsx4("span", {
675
1406
  className: getPasswordWrapperClasses({ className }),
676
- children: /* @__PURE__ */ jsx3(InputRoot, {
1407
+ children: /* @__PURE__ */ jsx4(InputRoot, {
677
1408
  ...props,
678
1409
  ref,
679
1410
  disabled,
@@ -683,7 +1414,7 @@ var Password = forwardRef2(({ className, disabled, visibilityToggle = true, ...p
683
1414
  });
684
1415
  });
685
1416
  Password.displayName = "Input.Password";
686
- var TextArea = forwardRef2(({
1417
+ var TextArea = forwardRef3(({
687
1418
  autoSize,
688
1419
  className,
689
1420
  defaultValue,
@@ -697,7 +1428,7 @@ var TextArea = forwardRef2(({
697
1428
  variant = "outlined",
698
1429
  ...props
699
1430
  }, ref) => {
700
- const [internalValue, setInternalValue] = useState2(() => toTextValue(defaultValue));
1431
+ const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
701
1432
  const isControlled = value !== undefined;
702
1433
  const currentValue = isControlled ? toTextValue(value) : internalValue;
703
1434
  const count = currentValue.length;
@@ -708,7 +1439,7 @@ var TextArea = forwardRef2(({
708
1439
  }
709
1440
  onChange?.(event);
710
1441
  }
711
- const control = /* @__PURE__ */ jsx3("textarea", {
1442
+ const control = /* @__PURE__ */ jsx4("textarea", {
712
1443
  ...props,
713
1444
  ref,
714
1445
  className: getTextAreaClasses({
@@ -726,11 +1457,11 @@ var TextArea = forwardRef2(({
726
1457
  if (!showCount) {
727
1458
  return control;
728
1459
  }
729
- return /* @__PURE__ */ jsxs3("span", {
1460
+ return /* @__PURE__ */ jsxs4("span", {
730
1461
  className: textAreaWrapperClass,
731
1462
  children: [
732
1463
  control,
733
- /* @__PURE__ */ jsxs3("span", {
1464
+ /* @__PURE__ */ jsxs4("span", {
734
1465
  className: getTextAreaCountClasses({ exceeded }),
735
1466
  children: [
736
1467
  count,
@@ -741,7 +1472,7 @@ var TextArea = forwardRef2(({
741
1472
  });
742
1473
  });
743
1474
  TextArea.displayName = "Input.TextArea";
744
- var Group = forwardRef2(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx3("div", {
1475
+ var Group = forwardRef3(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx4("div", {
745
1476
  ...props,
746
1477
  ref,
747
1478
  className: cn(inputGroupClass, className),
@@ -755,7 +1486,7 @@ var Input = Object.assign(InputRoot, {
755
1486
  Group
756
1487
  });
757
1488
  // src/components/select/Select.tsx
758
- import React3, { forwardRef as forwardRef3, useMemo as useMemo2, useState as useState3 } from "react";
1489
+ import React5, { forwardRef as forwardRef4, useMemo as useMemo3, useState as useState5 } from "react";
759
1490
 
760
1491
  // src/classes/select.ts
761
1492
  var selectContainerClass = "select-container";
@@ -811,7 +1542,7 @@ function getSelectOptionClasses({
811
1542
  }
812
1543
 
813
1544
  // src/components/select/Select.tsx
814
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1545
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
815
1546
  function isGroup(option) {
816
1547
  return "options" in option;
817
1548
  }
@@ -836,8 +1567,8 @@ function normalizeMultiValue(value) {
836
1567
  }
837
1568
  function optionsFromChildren(children) {
838
1569
  const result = [];
839
- React3.Children.forEach(children, (child) => {
840
- if (!React3.isValidElement(child)) {
1570
+ React5.Children.forEach(children, (child) => {
1571
+ if (!React5.isValidElement(child)) {
841
1572
  return;
842
1573
  }
843
1574
  if (child.type === Option) {
@@ -887,19 +1618,19 @@ function filterOptions(options, searchValue, filterOption) {
887
1618
  function renderValue(option) {
888
1619
  return option ? optionLabel(option) : null;
889
1620
  }
890
- var Option = forwardRef3(({ children, ...props }, ref) => /* @__PURE__ */ jsx4("div", {
1621
+ var Option = forwardRef4(({ children, ...props }, ref) => /* @__PURE__ */ jsx5("div", {
891
1622
  ...props,
892
1623
  ref,
893
1624
  children
894
1625
  }));
895
1626
  Option.displayName = "Select.Option";
896
- var OptGroup = forwardRef3(({ children, ...props }, ref) => /* @__PURE__ */ jsx4("div", {
1627
+ var OptGroup = forwardRef4(({ children, ...props }, ref) => /* @__PURE__ */ jsx5("div", {
897
1628
  ...props,
898
1629
  ref,
899
1630
  children
900
1631
  }));
901
1632
  OptGroup.displayName = "Select.OptGroup";
902
- var SelectRoot = forwardRef3(({
1633
+ var SelectRoot = forwardRef4(({
903
1634
  allowClear,
904
1635
  children,
905
1636
  className,
@@ -918,11 +1649,11 @@ var SelectRoot = forwardRef3(({
918
1649
  ...props
919
1650
  }, ref) => {
920
1651
  const multiple = mode === "multiple" || mode === "tags";
921
- const sourceOptions = useMemo2(() => options ?? optionsFromChildren(children), [children, options]);
922
- const flatOptions = useMemo2(() => flattenOptions(sourceOptions), [sourceOptions]);
923
- const [open, setOpen] = useState3(false);
924
- const [searchValue, setSearchValue] = useState3("");
925
- const [internalValue, setInternalValue] = useState3(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
1652
+ const sourceOptions = useMemo3(() => options ?? optionsFromChildren(children), [children, options]);
1653
+ const flatOptions = useMemo3(() => flattenOptions(sourceOptions), [sourceOptions]);
1654
+ const [open, setOpen] = useState5(false);
1655
+ const [searchValue, setSearchValue] = useState5("");
1656
+ const [internalValue, setInternalValue] = useState5(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
926
1657
  const controlled = value !== undefined;
927
1658
  const currentValue = controlled ? value : internalValue;
928
1659
  const selectedValues = multiple ? normalizeMultiValue(currentValue) : normalizeSingleValue(currentValue) === undefined ? [] : [normalizeSingleValue(currentValue)];
@@ -979,7 +1710,7 @@ var SelectRoot = forwardRef3(({
979
1710
  }
980
1711
  function renderOption(option) {
981
1712
  const selected = selectedKeys.has(valueKey(option.value));
982
- return /* @__PURE__ */ jsx4("button", {
1713
+ return /* @__PURE__ */ jsx5("button", {
983
1714
  type: "button",
984
1715
  role: "option",
985
1716
  "aria-selected": selected,
@@ -998,11 +1729,11 @@ var SelectRoot = forwardRef3(({
998
1729
  if (!isGroup(option)) {
999
1730
  return renderOption(option);
1000
1731
  }
1001
- return /* @__PURE__ */ jsxs4("div", {
1732
+ return /* @__PURE__ */ jsxs5("div", {
1002
1733
  className: cn(selectGroupClass, option.className),
1003
1734
  role: "group",
1004
1735
  children: [
1005
- /* @__PURE__ */ jsx4("div", {
1736
+ /* @__PURE__ */ jsx5("div", {
1006
1737
  className: selectGroupLabelClass,
1007
1738
  children: option.label
1008
1739
  }),
@@ -1011,11 +1742,11 @@ var SelectRoot = forwardRef3(({
1011
1742
  }, `group-${index}`);
1012
1743
  });
1013
1744
  }
1014
- const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx4("span", {
1745
+ const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx5("span", {
1015
1746
  className: selectTagClass,
1016
1747
  children: renderValue(option)
1017
1748
  }, valueKey(option.value))) : renderValue(selectedOptions[0]);
1018
- return /* @__PURE__ */ jsxs4("div", {
1749
+ return /* @__PURE__ */ jsxs5("div", {
1019
1750
  ...props,
1020
1751
  ref,
1021
1752
  className: getSelectContainerClasses({
@@ -1026,7 +1757,7 @@ var SelectRoot = forwardRef3(({
1026
1757
  className
1027
1758
  }),
1028
1759
  children: [
1029
- /* @__PURE__ */ jsxs4("button", {
1760
+ /* @__PURE__ */ jsxs5("button", {
1030
1761
  type: "button",
1031
1762
  className: getSelectClasses({ size, status, disabled }),
1032
1763
  disabled: disabled || loading,
@@ -1034,33 +1765,33 @@ var SelectRoot = forwardRef3(({
1034
1765
  "aria-expanded": open,
1035
1766
  onClick: () => setOpen((current) => !current),
1036
1767
  children: [
1037
- /* @__PURE__ */ jsx4("span", {
1768
+ /* @__PURE__ */ jsx5("span", {
1038
1769
  className: selectSelectionClass,
1039
- children: hasValue ? selection : /* @__PURE__ */ jsx4("span", {
1770
+ children: hasValue ? selection : /* @__PURE__ */ jsx5("span", {
1040
1771
  className: selectPlaceholderClass,
1041
1772
  children: placeholder
1042
1773
  })
1043
1774
  }),
1044
- /* @__PURE__ */ jsx4("span", {
1775
+ /* @__PURE__ */ jsx5("span", {
1045
1776
  className: selectIconClass,
1046
1777
  "aria-hidden": "true",
1047
1778
  children: "v"
1048
1779
  })
1049
1780
  ]
1050
1781
  }),
1051
- allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx4("button", {
1782
+ allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx5("button", {
1052
1783
  type: "button",
1053
1784
  className: selectClearClass,
1054
1785
  "aria-label": "Clear selection",
1055
1786
  onClick: clearValue,
1056
1787
  children: "x"
1057
1788
  }) : null,
1058
- open ? /* @__PURE__ */ jsxs4("div", {
1789
+ open ? /* @__PURE__ */ jsxs5("div", {
1059
1790
  className: selectDropdownClass,
1060
1791
  role: "listbox",
1061
1792
  "aria-multiselectable": multiple || undefined,
1062
1793
  children: [
1063
- searchable ? /* @__PURE__ */ jsx4("input", {
1794
+ searchable ? /* @__PURE__ */ jsx5("input", {
1064
1795
  className: selectSearchClass,
1065
1796
  value: searchValue,
1066
1797
  placeholder: typeof placeholder === "string" ? placeholder : undefined,
@@ -1072,7 +1803,7 @@ var SelectRoot = forwardRef3(({
1072
1803
  }
1073
1804
  }
1074
1805
  }) : null,
1075
- visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx4("div", {
1806
+ visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx5("div", {
1076
1807
  className: selectEmptyClass,
1077
1808
  children: "No data"
1078
1809
  })
@@ -1086,7 +1817,7 @@ var Select = SelectRoot;
1086
1817
  Select.Option = Option;
1087
1818
  Select.OptGroup = OptGroup;
1088
1819
  // src/components/dm-search/DmSearch.tsx
1089
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1820
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1090
1821
  function initialValues(items, searchParams, useSearchParams = true) {
1091
1822
  return items.reduce((acc, item) => {
1092
1823
  const defaultValue = item.search.extraProps?.value ?? item.search.formProps?.initialValue;
@@ -1110,7 +1841,7 @@ function renderField({
1110
1841
  return item.search.render?.(value, setValue, item) ?? null;
1111
1842
  }
1112
1843
  if (item.search.type === "select") {
1113
- return /* @__PURE__ */ jsx5(Select, {
1844
+ return /* @__PURE__ */ jsx6(Select, {
1114
1845
  ...extraProps,
1115
1846
  disabled: Boolean(loading || extraProps.disabled),
1116
1847
  value,
@@ -1119,25 +1850,25 @@ function renderField({
1119
1850
  });
1120
1851
  }
1121
1852
  if (item.search.type === "dateRange") {
1122
- return /* @__PURE__ */ jsx5(DatePicker.RangePicker, {
1853
+ return /* @__PURE__ */ jsx6(DatePicker.RangePicker, {
1123
1854
  ...extraProps,
1124
1855
  value,
1125
1856
  onChange: (nextValue) => setValue(nextValue)
1126
1857
  });
1127
1858
  }
1128
1859
  if (item.search.type === "date") {
1129
- return /* @__PURE__ */ jsx5(DatePicker, {
1860
+ return /* @__PURE__ */ jsx6(DatePicker, {
1130
1861
  ...extraProps,
1131
1862
  value,
1132
1863
  onChange: (nextValue) => setValue(nextValue)
1133
1864
  });
1134
1865
  }
1135
1866
  if (item.search.type === "radio" || item.search.type === "checkbox") {
1136
- return /* @__PURE__ */ jsx5("div", {
1867
+ return /* @__PURE__ */ jsx6("div", {
1137
1868
  role: item.search.type === "radio" ? "radiogroup" : "group",
1138
- children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs5("label", {
1869
+ children: optionList(extraProps).map((option) => /* @__PURE__ */ jsxs6("label", {
1139
1870
  children: [
1140
- /* @__PURE__ */ jsx5("input", {
1871
+ /* @__PURE__ */ jsx6("input", {
1141
1872
  type: item.search.type,
1142
1873
  disabled: loading,
1143
1874
  checked: item.search.type === "checkbox" ? Array.isArray(value) && value.includes(option.value) : value === option.value,
@@ -1155,7 +1886,7 @@ function renderField({
1155
1886
  }, String(option.value)))
1156
1887
  });
1157
1888
  }
1158
- return /* @__PURE__ */ jsx5(Input, {
1889
+ return /* @__PURE__ */ jsx6(Input, {
1159
1890
  ...extraProps,
1160
1891
  type: item.search.type === "input-number" ? "number" : "text",
1161
1892
  disabled: Boolean(loading || extraProps.disabled),
@@ -1169,8 +1900,11 @@ function renderField({
1169
1900
  }
1170
1901
  });
1171
1902
  }
1172
- var DmSearch = forwardRef4(({
1903
+ var DmSearch = forwardRef5(({
1173
1904
  items = [],
1905
+ values: controlledValues,
1906
+ onValuesChange,
1907
+ onReset,
1174
1908
  onSearch,
1175
1909
  extra,
1176
1910
  fastFilterItem,
@@ -1179,27 +1913,37 @@ var DmSearch = forwardRef4(({
1179
1913
  compact = false,
1180
1914
  searchParams,
1181
1915
  loading = false,
1916
+ noValidate,
1182
1917
  enableDefaultPlaceHolder = false,
1183
1918
  className
1184
1919
  }, ref) => {
1185
- const allItems = useMemo3(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
1186
- const [collapsed, setCollapsed] = useState4(defaultCollapsed);
1187
- const [values, setValues] = useState4(() => initialValues(allItems, searchParams));
1920
+ const allItems = useMemo4(() => fastFilterItem ? [fastFilterItem, ...items] : items, [fastFilterItem, items]);
1921
+ const [collapsed, setCollapsed] = useState6(defaultCollapsed);
1922
+ const [internalValues, setValues] = useState6(() => initialValues(allItems, searchParams));
1923
+ const controlled = controlledValues !== undefined;
1924
+ const values = controlled ? controlledValues : internalValues;
1188
1925
  const visibleItems = collapsed ? allItems.slice(0, 1) : allItems;
1189
- useEffect(() => {
1190
- setValues(initialValues(allItems, searchParams));
1191
- }, [allItems, searchParams]);
1926
+ useEffect2(() => {
1927
+ if (!controlled)
1928
+ setValues(initialValues(allItems, searchParams));
1929
+ }, [allItems, searchParams, controlled]);
1192
1930
  function reset(useSearchParams = false) {
1193
1931
  const nextValues = initialValues(allItems, searchParams, useSearchParams);
1194
- setValues(nextValues);
1932
+ if (!controlled)
1933
+ setValues(nextValues);
1934
+ if (onReset)
1935
+ onReset(nextValues);
1936
+ else if (controlled)
1937
+ onValuesChange?.(nextValues);
1195
1938
  return nextValues;
1196
1939
  }
1197
- useImperativeHandle2(ref, () => ({
1940
+ useImperativeHandle3(ref, () => ({
1198
1941
  onReset: () => {
1199
1942
  reset(false);
1200
1943
  }
1201
1944
  }));
1202
- return /* @__PURE__ */ jsxs5("form", {
1945
+ return /* @__PURE__ */ jsxs6("form", {
1946
+ noValidate,
1203
1947
  id: "searchForm",
1204
1948
  className: getDmSearchClasses({ compact, collapsed, className }),
1205
1949
  onSubmit: (event) => {
@@ -1207,53 +1951,63 @@ var DmSearch = forwardRef4(({
1207
1951
  onSearch?.(values);
1208
1952
  },
1209
1953
  children: [
1210
- fastFilterItem ? /* @__PURE__ */ jsx5("div", {
1954
+ fastFilterItem ? /* @__PURE__ */ jsx6("div", {
1211
1955
  className: dmSearchFastFilterClass,
1212
1956
  children: fastFilterItem.title
1213
1957
  }) : null,
1214
- /* @__PURE__ */ jsx5("div", {
1958
+ /* @__PURE__ */ jsx6("div", {
1215
1959
  className: dmSearchFieldsClass,
1216
- children: visibleItems.map((item) => /* @__PURE__ */ jsxs5("label", {
1217
- className: dmSearchFieldClass,
1218
- children: [
1219
- compact ? null : /* @__PURE__ */ jsx5("span", {
1220
- children: item.title
1221
- }),
1222
- renderField({
1223
- item,
1224
- value: values[item.dataIndex],
1225
- loading,
1226
- enableDefaultPlaceHolder,
1227
- setValue: (value) => setValues((current) => ({
1228
- ...current,
1229
- [item.dataIndex]: value
1230
- }))
1231
- })
1232
- ]
1233
- }, item.key))
1960
+ children: visibleItems.map((item) => {
1961
+ const Field = item.search.type === "custom" ? "div" : "label";
1962
+ return /* @__PURE__ */ jsxs6(Field, {
1963
+ className: dmSearchFieldClass,
1964
+ children: [
1965
+ compact ? null : /* @__PURE__ */ jsx6("span", {
1966
+ children: item.title
1967
+ }),
1968
+ renderField({
1969
+ item,
1970
+ value: values[item.dataIndex],
1971
+ loading,
1972
+ enableDefaultPlaceHolder,
1973
+ setValue: (value) => {
1974
+ const nextValues = { ...values, [item.dataIndex]: value };
1975
+ if (!controlled)
1976
+ setValues(nextValues);
1977
+ onValuesChange?.(nextValues);
1978
+ }
1979
+ })
1980
+ ]
1981
+ }, item.key);
1982
+ })
1234
1983
  }),
1235
- /* @__PURE__ */ jsxs5("div", {
1984
+ /* @__PURE__ */ jsxs6("div", {
1236
1985
  className: dmSearchActionsClass,
1237
1986
  children: [
1238
- /* @__PURE__ */ jsx5(Button, {
1987
+ /* @__PURE__ */ jsx6(Button, {
1239
1988
  type: "submit",
1240
1989
  isLoading: loading,
1241
1990
  children: "Search"
1242
1991
  }),
1243
- /* @__PURE__ */ jsx5(Button, {
1992
+ /* @__PURE__ */ jsx6(Button, {
1244
1993
  type: "button",
1245
1994
  color: "secondary",
1246
1995
  appearance: "outline",
1247
- onClick: () => onSearch?.(reset(false)),
1996
+ onClick: () => {
1997
+ const nextValues = reset(false);
1998
+ if (!onReset)
1999
+ onSearch?.(nextValues);
2000
+ },
1248
2001
  children: "Reset"
1249
2002
  }),
1250
- !hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx5(Button, {
2003
+ !hideCollapseBtn && allItems.length > 1 ? /* @__PURE__ */ jsx6(Button, {
1251
2004
  type: "button",
1252
2005
  color: "secondary",
1253
2006
  appearance: "text",
1254
2007
  onClick: () => {
1255
2008
  setCollapsed((current) => !current);
1256
- setValues(initialValues(allItems, searchParams));
2009
+ if (!controlled)
2010
+ setValues(initialValues(allItems, searchParams));
1257
2011
  },
1258
2012
  children: collapsed ? "Expand" : "Collapse"
1259
2013
  }) : null,