@platned/ui 0.7.1 → 0.8.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.
- package/dist/index.cjs +278 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +208 -15
- package/dist/index.d.ts +208 -15
- package/dist/index.js +414 -277
- package/dist/index.js.map +1 -1
- package/dist/sidebar.cjs +73 -1
- package/dist/sidebar.cjs.map +1 -1
- package/dist/sidebar.js +87 -14
- package/dist/sidebar.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/sidebar.cjs
CHANGED
|
@@ -456,6 +456,18 @@ function focusMenuEdge(event, edge) {
|
|
|
456
456
|
else if (document.activeElement === panel) items[0]?.focus();
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
|
+
function visibleMenuItems(items) {
|
|
460
|
+
const kept = items.filter((item) => {
|
|
461
|
+
if (item.hidden) return false;
|
|
462
|
+
if (item.type === "group" || item.type === "submenu") return visibleMenuItems(item.items).length > 0;
|
|
463
|
+
return true;
|
|
464
|
+
});
|
|
465
|
+
return kept.filter((item, i) => {
|
|
466
|
+
if (item.type !== "separator") return true;
|
|
467
|
+
const prev = kept[i - 1];
|
|
468
|
+
return i > 0 && i < kept.length - 1 && prev.type !== "separator";
|
|
469
|
+
});
|
|
470
|
+
}
|
|
459
471
|
function createMenuParts(P) {
|
|
460
472
|
const Item = (0, import_react7.forwardRef)(function MenuItem({ children, onSelect, tone = "default", disabled = false, icon, description, shortcut, textValue, className, ...rest }, ref) {
|
|
461
473
|
const descriptionId = (0, import_react7.useId)();
|
|
@@ -586,7 +598,58 @@ function createMenuParts(P) {
|
|
|
586
598
|
}
|
|
587
599
|
) });
|
|
588
600
|
});
|
|
601
|
+
function Items({ items }) {
|
|
602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: visibleMenuItems(items).map(renderItem) });
|
|
603
|
+
}
|
|
604
|
+
function renderItem(item) {
|
|
605
|
+
switch (item.type) {
|
|
606
|
+
case "checkbox":
|
|
607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
608
|
+
CheckboxItem,
|
|
609
|
+
{
|
|
610
|
+
checked: item.checked,
|
|
611
|
+
onCheckedChange: item.onCheckedChange,
|
|
612
|
+
disabled: item.disabled,
|
|
613
|
+
shortcut: item.shortcut,
|
|
614
|
+
textValue: item.textValue,
|
|
615
|
+
children: item.label
|
|
616
|
+
},
|
|
617
|
+
item.id
|
|
618
|
+
);
|
|
619
|
+
case "radio":
|
|
620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RadioGroup, { value: item.value, onValueChange: item.onValueChange, children: item.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RadioItem, { value: option.value, disabled: option.disabled, children: option.label }, option.value)) }, item.id);
|
|
621
|
+
case "group":
|
|
622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Group, { label: item.label, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Items, { items: item.items }) }, item.id);
|
|
623
|
+
case "submenu":
|
|
624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Sub, { children: [
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SubTrigger, { icon: item.icon, disabled: item.disabled, children: item.label }),
|
|
626
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SubContent, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Items, { items: item.items }) })
|
|
627
|
+
] }, item.id);
|
|
628
|
+
case "label":
|
|
629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { children: item.label }, item.id);
|
|
630
|
+
case "separator":
|
|
631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Separator, {}, item.id);
|
|
632
|
+
case "custom":
|
|
633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: item.render() }, item.id);
|
|
634
|
+
default:
|
|
635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
636
|
+
Item,
|
|
637
|
+
{
|
|
638
|
+
onSelect: item.onSelect,
|
|
639
|
+
tone: item.tone,
|
|
640
|
+
disabled: item.disabled,
|
|
641
|
+
icon: item.icon,
|
|
642
|
+
description: item.description,
|
|
643
|
+
shortcut: item.shortcut,
|
|
644
|
+
textValue: item.textValue,
|
|
645
|
+
children: item.label
|
|
646
|
+
},
|
|
647
|
+
item.id
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
589
651
|
return {
|
|
652
|
+
Items,
|
|
590
653
|
Item,
|
|
591
654
|
CheckboxItem,
|
|
592
655
|
RadioGroup,
|
|
@@ -663,6 +726,11 @@ function useDropdownMenuState(part) {
|
|
|
663
726
|
}
|
|
664
727
|
function DropdownMenu({
|
|
665
728
|
children,
|
|
729
|
+
items,
|
|
730
|
+
trigger,
|
|
731
|
+
label,
|
|
732
|
+
side,
|
|
733
|
+
align,
|
|
666
734
|
open: openProp,
|
|
667
735
|
defaultOpen = false,
|
|
668
736
|
onOpenChange,
|
|
@@ -675,7 +743,10 @@ function DropdownMenu({
|
|
|
675
743
|
});
|
|
676
744
|
const pendingEdge = (0, import_react9.useRef)("start");
|
|
677
745
|
const state = (0, import_react9.useMemo)(() => ({ setOpen, pendingEdge }), [setOpen]);
|
|
678
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuStateContext.Provider, { value: state, children
|
|
746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuStateContext.Provider, { value: state, children: items ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
747
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuTrigger, { asChild: trigger != null, label, children: trigger }),
|
|
748
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuContent, { side, align, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuItems, { items }) })
|
|
749
|
+
] }) : children }) });
|
|
679
750
|
}
|
|
680
751
|
var DropdownMenuTrigger = (0, import_react9.forwardRef)(
|
|
681
752
|
function DropdownMenuTrigger2({ children, asChild = false, label = "Open menu", onClick, onPointerDown, onMouseDown, onKeyDown, ...rest }, ref) {
|
|
@@ -760,6 +831,7 @@ var DropdownMenuContent = (0, import_react9.forwardRef)(
|
|
|
760
831
|
}
|
|
761
832
|
);
|
|
762
833
|
var parts = createMenuParts(import_radix_ui2.DropdownMenu);
|
|
834
|
+
var DropdownMenuItems = parts.Items;
|
|
763
835
|
var DropdownMenuItem = parts.Item;
|
|
764
836
|
var DropdownMenuCheckboxItem = parts.CheckboxItem;
|
|
765
837
|
var DropdownMenuRadioGroup = parts.RadioGroup;
|