@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
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  // src/components/dm-page-header/DmPageHeader.tsx
4
- import React4, { useMemo as useMemo2 } from "react";
4
+ import React5, { useMemo as useMemo2 } from "react";
5
5
 
6
6
  // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
7
7
  function r(e) {
@@ -349,6 +349,10 @@ function getDmToolbarItemClasses({
349
349
  return cn(dmToolbarItemClass, primary ? dmToolbarPrimaryItemClass : dmToolbarSecondaryItemClass, className);
350
350
  }
351
351
 
352
+ // src/components/button/Button.tsx
353
+ import React2 from "react";
354
+ import { createPortal } from "react-dom";
355
+
352
356
  // src/classes/button.ts
353
357
  var buttonBaseClass = "btn";
354
358
  var buttonColorClasses = {
@@ -372,7 +376,7 @@ var buttonAppearanceClasses = {
372
376
  };
373
377
  var buttonShapeClasses = {
374
378
  rect: "",
375
- circle: "btn-circle",
379
+ circle: "btn-circle btn-icon",
376
380
  square: "btn-square"
377
381
  };
378
382
  var buttonSizeClasses = {
@@ -392,11 +396,14 @@ function getButtonClasses({
392
396
  isLoading,
393
397
  className
394
398
  }) {
395
- return cn(buttonBaseClass, buttonColorClasses[color], buttonAppearanceClasses[appearance], buttonShapeClasses[shape], buttonSizeClasses[size], block && buttonBlockClass, isLoading && buttonIsLoadingClass, className);
399
+ 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);
396
400
  }
397
401
 
398
402
  // src/components/button/Button.tsx
399
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
403
+ import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
404
+ function isPromiseLike(value) {
405
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
406
+ }
400
407
  function Button({
401
408
  color = "primary",
402
409
  appearance = "filled",
@@ -410,8 +417,155 @@ function Button({
410
417
  children,
411
418
  disabled,
412
419
  ref,
420
+ confirm,
421
+ onClick,
413
422
  ...props
414
423
  }) {
424
+ const buttonRef = React2.useRef(null);
425
+ const popoverRef = React2.useRef(null);
426
+ const cancelRef = React2.useRef(null);
427
+ const approvalRef = React2.useRef("idle");
428
+ const pendingRef = React2.useRef(false);
429
+ const actionRef = React2.useRef(0);
430
+ const operationRef = React2.useRef(0);
431
+ const mountedRef = React2.useRef(false);
432
+ const [portalTarget, setPortalTarget] = React2.useState(null);
433
+ const [confirmLoading, setConfirmLoading] = React2.useState(false);
434
+ const [confirmError, setConfirmError] = React2.useState(false);
435
+ const generatedId = React2.useId().replace(/:/g, "");
436
+ const popoverId = `button-confirm-${generatedId}`;
437
+ const titleId = `${popoverId}-title`;
438
+ const descriptionId = `${popoverId}-description`;
439
+ const anchor = `--${popoverId}-anchor`;
440
+ const hasConfirm = Boolean(confirm);
441
+ const confirmation = confirm && typeof confirm === "object" ? confirm : undefined;
442
+ const title = confirmation ? confirmation.title : "Confirm action";
443
+ const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
444
+ const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
445
+ const hasContent = content !== undefined && content !== null && content !== false && content !== "";
446
+ const mergedRef = React2.useCallback((node) => {
447
+ buttonRef.current = node;
448
+ if (!node) {
449
+ if (typeof ref === "function")
450
+ ref(null);
451
+ else if (ref)
452
+ ref.current = null;
453
+ return;
454
+ }
455
+ const cleanup = typeof ref === "function" ? ref(node) : undefined;
456
+ if (ref && typeof ref !== "function")
457
+ ref.current = node;
458
+ return () => {
459
+ buttonRef.current = null;
460
+ if (typeof cleanup === "function")
461
+ cleanup();
462
+ else if (typeof ref === "function")
463
+ ref(null);
464
+ else if (ref)
465
+ ref.current = null;
466
+ };
467
+ }, [ref]);
468
+ React2.useEffect(() => {
469
+ mountedRef.current = true;
470
+ return () => {
471
+ mountedRef.current = false;
472
+ operationRef.current += 1;
473
+ };
474
+ }, []);
475
+ React2.useEffect(() => {
476
+ operationRef.current += 1;
477
+ approvalRef.current = "idle";
478
+ setConfirmError(false);
479
+ setPortalTarget(hasConfirm ? document.body : null);
480
+ }, [hasConfirm]);
481
+ function closePopover() {
482
+ if (popoverRef.current?.matches(":popover-open")) {
483
+ popoverRef.current.hidePopover();
484
+ }
485
+ buttonRef.current?.focus();
486
+ }
487
+ function handleClick(event) {
488
+ if (!confirm) {
489
+ onClick?.(event);
490
+ return;
491
+ }
492
+ if (approvalRef.current === "native") {
493
+ approvalRef.current = "idle";
494
+ return;
495
+ }
496
+ if (approvalRef.current === "action") {
497
+ approvalRef.current = "idle";
498
+ let result;
499
+ try {
500
+ result = onClick?.(event);
501
+ } catch {
502
+ event.preventDefault();
503
+ pendingRef.current = false;
504
+ setConfirmError(true);
505
+ return;
506
+ }
507
+ if (!isPromiseLike(result)) {
508
+ pendingRef.current = false;
509
+ closePopover();
510
+ return;
511
+ }
512
+ const userPreventedDefault = event.defaultPrevented;
513
+ event.preventDefault();
514
+ setConfirmLoading(true);
515
+ const action = actionRef.current;
516
+ const operation = operationRef.current;
517
+ Promise.resolve(result).then(() => {
518
+ if (!mountedRef.current || action !== actionRef.current)
519
+ return;
520
+ pendingRef.current = false;
521
+ setConfirmLoading(false);
522
+ if (operation !== operationRef.current)
523
+ return;
524
+ closePopover();
525
+ if (!userPreventedDefault && !buttonRef.current?.disabled) {
526
+ approvalRef.current = "native";
527
+ buttonRef.current?.click();
528
+ approvalRef.current = "idle";
529
+ }
530
+ }, () => {
531
+ if (!mountedRef.current || action !== actionRef.current)
532
+ return;
533
+ pendingRef.current = false;
534
+ setConfirmLoading(false);
535
+ if (operation !== operationRef.current)
536
+ return;
537
+ setConfirmError(true);
538
+ cancelRef.current?.focus();
539
+ });
540
+ return;
541
+ }
542
+ event.preventDefault();
543
+ if (disabled || isLoading || pendingRef.current)
544
+ return;
545
+ if (popoverRef.current?.matches(":popover-open")) {
546
+ closePopover();
547
+ return;
548
+ }
549
+ setConfirmError(false);
550
+ popoverRef.current?.showPopover();
551
+ cancelRef.current?.focus();
552
+ }
553
+ function handleConfirm(event) {
554
+ event.preventDefault();
555
+ event.stopPropagation();
556
+ const trigger = buttonRef.current;
557
+ if (disabled || isLoading || pendingRef.current || !trigger || trigger.disabled || !event.currentTarget.matches(":popover-open"))
558
+ return;
559
+ setConfirmError(false);
560
+ pendingRef.current = true;
561
+ actionRef.current += 1;
562
+ approvalRef.current = "action";
563
+ trigger.click();
564
+ if (approvalRef.current === "action") {
565
+ approvalRef.current = "idle";
566
+ pendingRef.current = false;
567
+ }
568
+ }
415
569
  const classes = getButtonClasses({
416
570
  color,
417
571
  appearance,
@@ -421,29 +575,104 @@ function Button({
421
575
  isLoading,
422
576
  className
423
577
  });
424
- return /* @__PURE__ */ jsxs2("button", {
425
- ref,
426
- className: classes,
427
- disabled: disabled || isLoading,
428
- "aria-busy": isLoading,
429
- "aria-disabled": disabled || isLoading,
430
- ...props,
578
+ const confirmClasses = getButtonClasses({
579
+ color,
580
+ size: "sm",
581
+ isLoading: confirmLoading
582
+ });
583
+ return /* @__PURE__ */ jsxs2(Fragment2, {
431
584
  children: [
432
- isLoading && /* @__PURE__ */ jsx2("span", {
433
- className: "btn-spinner"
434
- }),
435
- !isLoading && leftIcon && /* @__PURE__ */ jsx2("span", {
436
- className: "btn-icon-left",
437
- children: leftIcon
438
- }),
439
- /* @__PURE__ */ jsx2("span", {
440
- className: "btn-content",
441
- children
585
+ /* @__PURE__ */ jsxs2("button", {
586
+ ref: confirm ? mergedRef : ref,
587
+ className: classes,
588
+ disabled: disabled || isLoading,
589
+ "aria-busy": isLoading,
590
+ "aria-disabled": disabled || isLoading,
591
+ ...props,
592
+ style: confirm ? { ...props.style, anchorName: anchor } : props.style,
593
+ "aria-haspopup": confirm ? "dialog" : props["aria-haspopup"],
594
+ "aria-controls": confirm ? popoverId : props["aria-controls"],
595
+ onClick: confirm ? handleClick : onClick,
596
+ children: [
597
+ isLoading && /* @__PURE__ */ jsx2("span", {
598
+ className: "btn-spinner"
599
+ }),
600
+ !isLoading && leftIcon && /* @__PURE__ */ jsx2("span", {
601
+ className: "btn-icon-left",
602
+ children: leftIcon
603
+ }),
604
+ /* @__PURE__ */ jsx2("span", {
605
+ className: "btn-content",
606
+ children
607
+ }),
608
+ !isLoading && rightIcon && /* @__PURE__ */ jsx2("span", {
609
+ className: "btn-icon-right",
610
+ children: rightIcon
611
+ })
612
+ ]
442
613
  }),
443
- !isLoading && rightIcon && /* @__PURE__ */ jsx2("span", {
444
- className: "btn-icon-right",
445
- children: rightIcon
446
- })
614
+ confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs2("form", {
615
+ id: popoverId,
616
+ ref: popoverRef,
617
+ popover: "auto",
618
+ role: "dialog",
619
+ "aria-labelledby": hasTitle ? titleId : undefined,
620
+ "aria-label": hasTitle ? undefined : "Confirm action",
621
+ "aria-describedby": hasContent ? descriptionId : undefined,
622
+ className: "popover popover-confirm popover-bottom",
623
+ style: { positionAnchor: anchor },
624
+ onSubmit: handleConfirm,
625
+ onClick: (event) => event.stopPropagation(),
626
+ onToggle: (event) => {
627
+ if (!event.currentTarget.matches(":popover-open")) {
628
+ operationRef.current += 1;
629
+ if (event.currentTarget.contains(document.activeElement) || document.activeElement === document.body) {
630
+ buttonRef.current?.focus();
631
+ }
632
+ }
633
+ },
634
+ children: [
635
+ hasTitle && /* @__PURE__ */ jsx2("div", {
636
+ className: "popover-header",
637
+ children: /* @__PURE__ */ jsx2("h3", {
638
+ id: titleId,
639
+ className: "popover-title",
640
+ children: title
641
+ })
642
+ }),
643
+ hasContent && /* @__PURE__ */ jsx2("div", {
644
+ id: descriptionId,
645
+ className: "popover-body",
646
+ children: content
647
+ }),
648
+ confirmError && /* @__PURE__ */ jsx2("div", {
649
+ role: "alert",
650
+ className: "popover-body",
651
+ children: "The action failed. Please try again."
652
+ }),
653
+ /* @__PURE__ */ jsxs2("div", {
654
+ className: "popover-footer",
655
+ children: [
656
+ /* @__PURE__ */ jsx2("button", {
657
+ ref: cancelRef,
658
+ type: "button",
659
+ className: "btn btn-text btn-sm",
660
+ popoverTarget: popoverId,
661
+ popoverTargetAction: "hide",
662
+ disabled: confirmLoading,
663
+ children: confirmation?.cancelText ?? "Cancel"
664
+ }),
665
+ /* @__PURE__ */ jsx2("button", {
666
+ type: "submit",
667
+ className: confirmClasses,
668
+ disabled: disabled || isLoading || confirmLoading,
669
+ "aria-busy": confirmLoading,
670
+ children: confirmation?.confirmText ?? "Confirm"
671
+ })
672
+ ]
673
+ })
674
+ ]
675
+ }), portalTarget)
447
676
  ]
448
677
  });
449
678
  }
@@ -452,34 +681,32 @@ import {
452
681
  cloneElement,
453
682
  forwardRef as forwardRef2,
454
683
  isValidElement,
684
+ useEffect,
455
685
  useId,
686
+ useRef,
456
687
  useState
457
688
  } from "react";
458
689
 
459
690
  // src/classes/dropdown.ts
460
- var dropdownWrapperClass = "dropdown-wrapper";
461
- var dropdownBaseClass = "popover dropdown";
462
- var dropdownOpenClass = "popover-show dropdown-open";
463
- var dropdownArrowClass = "popover-arrow dropdown-arrow";
691
+ var dropdownWrapperClass = "dropdown";
692
+ var dropdownBaseClass = "dropdown-content";
693
+ var dropdownArrowClass = "dropdown-arrow";
464
694
  var dropdownMenuClass = "menu dropdown-menu";
465
695
  var dropdownButtonClass = "dropdown-button";
466
696
  var dropdownPlacementClasses = {
467
- top: "popover-top dropdown-top",
468
- bottom: "popover-bottom dropdown-bottom",
469
- left: "popover-left dropdown-left",
470
- right: "popover-right dropdown-right",
471
- topLeft: "popover-top dropdown-top-left",
472
- topRight: "popover-top dropdown-top-right",
473
- bottomLeft: "popover-bottom dropdown-bottom-left",
474
- bottomRight: "popover-bottom dropdown-bottom-right"
697
+ top: "dropdown-block-start",
698
+ bottom: "dropdown-block-end",
699
+ left: "dropdown-inline-start",
700
+ right: "dropdown-inline-end",
701
+ topLeft: "dropdown-block-start",
702
+ topRight: "dropdown-block-start",
703
+ bottomLeft: "dropdown-block-end",
704
+ bottomRight: "dropdown-block-end"
475
705
  };
476
706
  function getDropdownClasses({
477
- placement = "bottomLeft",
478
- open,
479
- arrow,
480
707
  className
481
708
  }) {
482
- return cn(dropdownBaseClass, dropdownPlacementClasses[placement], open && dropdownOpenClass, !arrow && "popover-no-arrow dropdown-no-arrow", className);
709
+ return cn(dropdownBaseClass, className);
483
710
  }
484
711
 
485
712
  // src/classes/menu.ts
@@ -532,9 +759,6 @@ function getMenuItemClasses({
532
759
 
533
760
  // src/components/dropdown/Dropdown.tsx
534
761
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
535
- function hasTrigger(triggers, trigger) {
536
- return (triggers ?? ["hover"]).includes(trigger);
537
- }
538
762
  function callHandler(handler, event) {
539
763
  handler?.(event);
540
764
  }
@@ -586,85 +810,103 @@ var DropdownRoot = forwardRef2(({
586
810
  ...props
587
811
  }, ref) => {
588
812
  const [internalOpen, setInternalOpen] = useState(Boolean(defaultOpen));
589
- const isControlled = open !== undefined;
590
- const visible = isControlled ? open : internalOpen;
591
- const overlayId = useId();
592
- function setVisible(nextOpen) {
593
- if (disabled)
813
+ const [nativeOpen, setNativeOpen] = useState(Boolean(open ?? defaultOpen));
814
+ const visible = open ?? internalOpen;
815
+ const popupRef = useRef(null);
816
+ const popupId = useId();
817
+ const anchorName = `--dm-dropdown-${popupId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
818
+ const clickTrigger = trigger.includes("click") || trigger.includes("hover");
819
+ useEffect(() => {
820
+ const popup = popupRef.current;
821
+ if (!popup?.showPopover || !popup?.hidePopover)
594
822
  return;
595
- if (!isControlled) {
823
+ if (visible && !popup.matches(":popover-open"))
824
+ popup.showPopover();
825
+ if (!visible && popup.matches(":popover-open"))
826
+ popup.hidePopover();
827
+ }, [visible]);
828
+ function setVisible(nextOpen) {
829
+ if (open === undefined)
596
830
  setInternalOpen(nextOpen);
597
- }
598
831
  onOpenChange?.(nextOpen);
599
832
  }
600
- const close = () => setVisible(false);
601
- const toggleVisible = () => setVisible(!visible);
833
+ function close() {
834
+ const popup = popupRef.current;
835
+ if (popup?.matches(":popover-open"))
836
+ popup.hidePopover();
837
+ else
838
+ setVisible(false);
839
+ }
602
840
  const menuNode = overlay ?? (menu?.items ? /* @__PURE__ */ jsx3("ul", {
603
841
  className: dropdownMenuClass,
604
842
  children: menu.items.map((item) => renderMenuItem2(item, menu.onClick, close))
605
843
  }) : null);
606
844
  const popup = dropdownRender ? dropdownRender(menuNode) : menuNode;
607
- const shouldRenderPopup = !destroyPopupOnHide || visible;
608
- const triggerProps = {
609
- "aria-controls": visible ? overlayId : undefined,
610
- "aria-expanded": visible || undefined,
611
- onMouseEnter: hasTrigger(trigger, "hover") ? () => setVisible(true) : undefined,
612
- onMouseLeave: hasTrigger(trigger, "hover") ? () => setVisible(false) : undefined,
613
- onClick: hasTrigger(trigger, "click") ? toggleVisible : undefined,
614
- onContextMenu: hasTrigger(trigger, "contextMenu") ? (event) => {
615
- event.preventDefault();
616
- toggleVisible();
617
- } : undefined
845
+ const show = () => !disabled && popupRef.current?.showPopover?.();
846
+ const hide = () => !disabled && popupRef.current?.hidePopover?.();
847
+ const toggle = () => {
848
+ if (disabled)
849
+ return;
850
+ if (popupRef.current?.matches(":popover-open"))
851
+ hide();
852
+ else
853
+ show();
618
854
  };
855
+ const childIsButton = isValidElement(children) && (children.type === "button" || children.type === Button);
619
856
  const triggerNode = isValidElement(children) ? cloneElement(children, {
620
- "aria-controls": triggerProps["aria-controls"] ?? children.props["aria-controls"],
621
- "aria-expanded": triggerProps["aria-expanded"] ?? children.props["aria-expanded"],
857
+ popoverTarget: childIsButton && clickTrigger && !disabled ? popupId : undefined,
858
+ style: {
859
+ ...children.props.style,
860
+ anchorName
861
+ },
862
+ "aria-controls": popupId,
863
+ "aria-expanded": nativeOpen,
864
+ disabled: disabled || children.props.disabled,
622
865
  onMouseEnter: (event) => {
623
866
  callHandler(children.props.onMouseEnter, event);
624
- triggerProps.onMouseEnter?.();
867
+ if (trigger.includes("hover"))
868
+ show();
625
869
  onMouseEnter?.(event);
626
870
  },
627
871
  onMouseLeave: (event) => {
628
872
  callHandler(children.props.onMouseLeave, event);
629
- triggerProps.onMouseLeave?.();
630
873
  onMouseLeave?.(event);
631
874
  },
632
875
  onClick: (event) => {
633
876
  callHandler(children.props.onClick, event);
634
- triggerProps.onClick?.();
635
877
  onClick?.(event);
878
+ if (!childIsButton && clickTrigger && !event.defaultPrevented)
879
+ toggle();
636
880
  },
637
881
  onContextMenu: (event) => {
638
882
  callHandler(children.props.onContextMenu, event);
639
- triggerProps.onContextMenu?.(event);
883
+ if (trigger.includes("contextMenu")) {
884
+ event.preventDefault();
885
+ toggle();
886
+ }
640
887
  onContextMenu?.(event);
641
888
  }
642
- }) : /* @__PURE__ */ jsx3("span", {
643
- role: "button",
644
- tabIndex: disabled ? -1 : 0,
645
- "aria-disabled": disabled || undefined,
646
- "aria-controls": triggerProps["aria-controls"],
647
- "aria-expanded": triggerProps["aria-expanded"],
889
+ }) : /* @__PURE__ */ jsx3("button", {
890
+ type: "button",
891
+ disabled,
892
+ popoverTarget: clickTrigger && !disabled ? popupId : undefined,
893
+ style: { anchorName },
894
+ "aria-controls": popupId,
895
+ "aria-expanded": nativeOpen,
648
896
  onMouseEnter: (event) => {
649
- triggerProps.onMouseEnter?.();
897
+ if (trigger.includes("hover"))
898
+ show();
650
899
  onMouseEnter?.(event);
651
900
  },
652
901
  onMouseLeave: (event) => {
653
- triggerProps.onMouseLeave?.();
654
902
  onMouseLeave?.(event);
655
903
  },
656
- onClick: (event) => {
657
- triggerProps.onClick?.();
658
- onClick?.(event);
659
- },
660
- onKeyDown: (event) => {
661
- if (event.key === "Enter" || event.key === " ") {
904
+ onClick,
905
+ onContextMenu: (event) => {
906
+ if (trigger.includes("contextMenu")) {
662
907
  event.preventDefault();
663
- triggerProps.onClick?.();
908
+ toggle();
664
909
  }
665
- },
666
- onContextMenu: (event) => {
667
- triggerProps.onContextMenu?.(event);
668
910
  onContextMenu?.(event);
669
911
  },
670
912
  children
@@ -672,25 +914,30 @@ var DropdownRoot = forwardRef2(({
672
914
  return /* @__PURE__ */ jsxs3("span", {
673
915
  ...props,
674
916
  ref,
675
- className: dropdownWrapperClass,
917
+ className: cn(dropdownWrapperClass, dropdownPlacementClasses[placement]),
918
+ onMouseLeave: trigger.includes("hover") ? hide : undefined,
676
919
  children: [
677
920
  triggerNode,
678
- shouldRenderPopup ? /* @__PURE__ */ jsxs3("span", {
679
- id: overlayId,
680
- role: "menu",
681
- className: getDropdownClasses({
682
- placement,
683
- open: visible,
684
- arrow,
685
- className
686
- }),
921
+ /* @__PURE__ */ jsxs3("span", {
922
+ id: popupId,
923
+ ref: popupRef,
924
+ popover: "auto",
925
+ style: { positionAnchor: anchorName },
926
+ className: getDropdownClasses({ className, arrow }),
927
+ onToggle: (event) => {
928
+ if (event.target !== event.currentTarget)
929
+ return;
930
+ const nextOpen = event.nativeEvent.newState === "open";
931
+ setNativeOpen(nextOpen);
932
+ setVisible(nextOpen);
933
+ },
687
934
  children: [
688
- popup,
935
+ !destroyPopupOnHide || visible ? popup : null,
689
936
  arrow ? /* @__PURE__ */ jsx3("span", {
690
937
  className: dropdownArrowClass
691
938
  }) : null
692
939
  ]
693
- }) : null
940
+ })
694
941
  ]
695
942
  });
696
943
  });
@@ -702,31 +949,74 @@ var DropdownButton = forwardRef2(({
702
949
  menu,
703
950
  onClick,
704
951
  trigger = ["click"],
952
+ color = "base",
953
+ appearance = "outline",
954
+ size,
955
+ shape,
956
+ block,
957
+ isLoading,
958
+ leftIcon,
959
+ rightIcon,
960
+ confirm,
705
961
  ...props
706
962
  }, ref) => {
963
+ const buttonStyle = { color, appearance, size, shape };
707
964
  const buttons = [
708
965
  /* @__PURE__ */ jsx3(Button, {
966
+ ...buttonStyle,
709
967
  disabled,
968
+ isLoading,
969
+ leftIcon,
970
+ rightIcon,
971
+ confirm,
710
972
  onClick,
711
973
  children
712
974
  }, "primary"),
713
975
  /* @__PURE__ */ jsx3(Button, {
976
+ ...buttonStyle,
977
+ type: "button",
714
978
  "aria-label": "Open dropdown",
715
- disabled,
716
- children: "v"
979
+ disabled: disabled || isLoading,
980
+ children: /* @__PURE__ */ jsxs3("svg", {
981
+ "aria-hidden": "true",
982
+ width: "18",
983
+ height: "18",
984
+ viewBox: "0 0 24 24",
985
+ fill: "currentColor",
986
+ children: [
987
+ /* @__PURE__ */ jsx3("circle", {
988
+ cx: "5",
989
+ cy: "12",
990
+ r: "1.75"
991
+ }),
992
+ /* @__PURE__ */ jsx3("circle", {
993
+ cx: "12",
994
+ cy: "12",
995
+ r: "1.75"
996
+ }),
997
+ /* @__PURE__ */ jsx3("circle", {
998
+ cx: "19",
999
+ cy: "12",
1000
+ r: "1.75"
1001
+ })
1002
+ ]
1003
+ })
717
1004
  }, "trigger")
718
1005
  ];
719
1006
  const renderedButtons = buttonsRender ? buttonsRender(buttons) : buttons;
720
- return /* @__PURE__ */ jsx3(DropdownRoot, {
721
- ...props,
1007
+ return /* @__PURE__ */ jsxs3("span", {
722
1008
  ref,
723
- menu,
724
- trigger,
725
- disabled,
726
- children: /* @__PURE__ */ jsx3("span", {
727
- className: dropdownButtonClass,
728
- children: renderedButtons
729
- })
1009
+ className: cn(dropdownButtonClass, block && "dropdown-button-block"),
1010
+ children: [
1011
+ renderedButtons[0],
1012
+ /* @__PURE__ */ jsx3(DropdownRoot, {
1013
+ ...props,
1014
+ menu,
1015
+ trigger,
1016
+ disabled: disabled || isLoading,
1017
+ children: renderedButtons[1]
1018
+ })
1019
+ ]
730
1020
  });
731
1021
  });
732
1022
  DropdownButton.displayName = "Dropdown.Button";
@@ -822,12 +1112,12 @@ function DmToolbar({
822
1112
  }
823
1113
  DmToolbar.displayName = "DmToolbar";
824
1114
  // src/components/dm-page-header/DmPageHeader.tsx
825
- import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment2 } from "react/jsx-runtime";
1115
+ import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment3 } from "react/jsx-runtime";
826
1116
  function isTitleList(title) {
827
1117
  return Array.isArray(title);
828
1118
  }
829
1119
  function isToolbarProps(extra) {
830
- return Boolean(extra && typeof extra === "object" && !React4.isValidElement(extra) && "items" in extra);
1120
+ return Boolean(extra && typeof extra === "object" && !React5.isValidElement(extra) && "items" in extra);
831
1121
  }
832
1122
  function DmPageHeader({
833
1123
  backClick,
@@ -881,7 +1171,7 @@ function DmPageHeader({
881
1171
  /* @__PURE__ */ jsxs5("div", {
882
1172
  className: dmPageHeaderMainClass,
883
1173
  children: [
884
- handleBack ? /* @__PURE__ */ jsxs5(Fragment2, {
1174
+ handleBack ? /* @__PURE__ */ jsxs5(Fragment3, {
885
1175
  children: [
886
1176
  /* @__PURE__ */ jsx5("button", {
887
1177
  type: "button",