@platned/ui 0.7.0 → 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 +1343 -974
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +287 -30
- package/dist/index.d.ts +287 -30
- package/dist/index.js +1637 -1261
- 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.js
CHANGED
|
@@ -394,12 +394,13 @@ function Tooltip({
|
|
|
394
394
|
|
|
395
395
|
// src/components/overlays/menu-core.tsx
|
|
396
396
|
import {
|
|
397
|
+
Fragment as Fragment2,
|
|
397
398
|
forwardRef as forwardRef3,
|
|
398
399
|
useId as useId2
|
|
399
400
|
} from "react";
|
|
400
401
|
import clsx7 from "clsx";
|
|
401
402
|
import { CheckIcon, ChevronRightIcon } from "lucide-react";
|
|
402
|
-
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
403
|
+
import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
403
404
|
var MENU_PANEL_CLASSES = cn("z-popover", OVERLAY_PANEL_MENU, "focus:outline-none");
|
|
404
405
|
var ITEM_BASE = clsx7(
|
|
405
406
|
OVERLAY_ITEM_BASE,
|
|
@@ -426,6 +427,18 @@ function focusMenuEdge(event, edge) {
|
|
|
426
427
|
else if (document.activeElement === panel) items[0]?.focus();
|
|
427
428
|
});
|
|
428
429
|
}
|
|
430
|
+
function visibleMenuItems(items) {
|
|
431
|
+
const kept = items.filter((item) => {
|
|
432
|
+
if (item.hidden) return false;
|
|
433
|
+
if (item.type === "group" || item.type === "submenu") return visibleMenuItems(item.items).length > 0;
|
|
434
|
+
return true;
|
|
435
|
+
});
|
|
436
|
+
return kept.filter((item, i) => {
|
|
437
|
+
if (item.type !== "separator") return true;
|
|
438
|
+
const prev = kept[i - 1];
|
|
439
|
+
return i > 0 && i < kept.length - 1 && prev.type !== "separator";
|
|
440
|
+
});
|
|
441
|
+
}
|
|
429
442
|
function createMenuParts(P) {
|
|
430
443
|
const Item = forwardRef3(function MenuItem({ children, onSelect, tone = "default", disabled = false, icon, description, shortcut, textValue, className, ...rest }, ref) {
|
|
431
444
|
const descriptionId = useId2();
|
|
@@ -556,7 +569,58 @@ function createMenuParts(P) {
|
|
|
556
569
|
}
|
|
557
570
|
) });
|
|
558
571
|
});
|
|
572
|
+
function Items({ items }) {
|
|
573
|
+
return /* @__PURE__ */ jsx6(Fragment3, { children: visibleMenuItems(items).map(renderItem) });
|
|
574
|
+
}
|
|
575
|
+
function renderItem(item) {
|
|
576
|
+
switch (item.type) {
|
|
577
|
+
case "checkbox":
|
|
578
|
+
return /* @__PURE__ */ jsx6(
|
|
579
|
+
CheckboxItem,
|
|
580
|
+
{
|
|
581
|
+
checked: item.checked,
|
|
582
|
+
onCheckedChange: item.onCheckedChange,
|
|
583
|
+
disabled: item.disabled,
|
|
584
|
+
shortcut: item.shortcut,
|
|
585
|
+
textValue: item.textValue,
|
|
586
|
+
children: item.label
|
|
587
|
+
},
|
|
588
|
+
item.id
|
|
589
|
+
);
|
|
590
|
+
case "radio":
|
|
591
|
+
return /* @__PURE__ */ jsx6(RadioGroup, { value: item.value, onValueChange: item.onValueChange, children: item.options.map((option) => /* @__PURE__ */ jsx6(RadioItem, { value: option.value, disabled: option.disabled, children: option.label }, option.value)) }, item.id);
|
|
592
|
+
case "group":
|
|
593
|
+
return /* @__PURE__ */ jsx6(Group, { label: item.label, children: /* @__PURE__ */ jsx6(Items, { items: item.items }) }, item.id);
|
|
594
|
+
case "submenu":
|
|
595
|
+
return /* @__PURE__ */ jsxs2(Sub, { children: [
|
|
596
|
+
/* @__PURE__ */ jsx6(SubTrigger, { icon: item.icon, disabled: item.disabled, children: item.label }),
|
|
597
|
+
/* @__PURE__ */ jsx6(SubContent, { children: /* @__PURE__ */ jsx6(Items, { items: item.items }) })
|
|
598
|
+
] }, item.id);
|
|
599
|
+
case "label":
|
|
600
|
+
return /* @__PURE__ */ jsx6(Label, { children: item.label }, item.id);
|
|
601
|
+
case "separator":
|
|
602
|
+
return /* @__PURE__ */ jsx6(Separator, {}, item.id);
|
|
603
|
+
case "custom":
|
|
604
|
+
return /* @__PURE__ */ jsx6(Fragment2, { children: item.render() }, item.id);
|
|
605
|
+
default:
|
|
606
|
+
return /* @__PURE__ */ jsx6(
|
|
607
|
+
Item,
|
|
608
|
+
{
|
|
609
|
+
onSelect: item.onSelect,
|
|
610
|
+
tone: item.tone,
|
|
611
|
+
disabled: item.disabled,
|
|
612
|
+
icon: item.icon,
|
|
613
|
+
description: item.description,
|
|
614
|
+
shortcut: item.shortcut,
|
|
615
|
+
textValue: item.textValue,
|
|
616
|
+
children: item.label
|
|
617
|
+
},
|
|
618
|
+
item.id
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
559
622
|
return {
|
|
623
|
+
Items,
|
|
560
624
|
Item,
|
|
561
625
|
CheckboxItem,
|
|
562
626
|
RadioGroup,
|
|
@@ -630,7 +694,7 @@ import {
|
|
|
630
694
|
} from "react";
|
|
631
695
|
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
|
|
632
696
|
import { EllipsisIcon } from "lucide-react";
|
|
633
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
697
|
+
import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
634
698
|
var DropdownMenuStateContext = createContext3(null);
|
|
635
699
|
function useDropdownMenuState(part) {
|
|
636
700
|
const value = useContext3(DropdownMenuStateContext);
|
|
@@ -639,6 +703,11 @@ function useDropdownMenuState(part) {
|
|
|
639
703
|
}
|
|
640
704
|
function DropdownMenu({
|
|
641
705
|
children,
|
|
706
|
+
items,
|
|
707
|
+
trigger,
|
|
708
|
+
label,
|
|
709
|
+
side,
|
|
710
|
+
align,
|
|
642
711
|
open: openProp,
|
|
643
712
|
defaultOpen = false,
|
|
644
713
|
onOpenChange,
|
|
@@ -651,7 +720,10 @@ function DropdownMenu({
|
|
|
651
720
|
});
|
|
652
721
|
const pendingEdge = useRef3("start");
|
|
653
722
|
const state = useMemo(() => ({ setOpen, pendingEdge }), [setOpen]);
|
|
654
|
-
return /* @__PURE__ */ jsx8(DropdownMenuPrimitive.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ jsx8(DropdownMenuStateContext.Provider, { value: state, children
|
|
723
|
+
return /* @__PURE__ */ jsx8(DropdownMenuPrimitive.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ jsx8(DropdownMenuStateContext.Provider, { value: state, children: items ? /* @__PURE__ */ jsxs3(Fragment4, { children: [
|
|
724
|
+
/* @__PURE__ */ jsx8(DropdownMenuTrigger, { asChild: trigger != null, label, children: trigger }),
|
|
725
|
+
/* @__PURE__ */ jsx8(DropdownMenuContent, { side, align, children: /* @__PURE__ */ jsx8(DropdownMenuItems, { items }) })
|
|
726
|
+
] }) : children }) });
|
|
655
727
|
}
|
|
656
728
|
var DropdownMenuTrigger = forwardRef5(
|
|
657
729
|
function DropdownMenuTrigger2({ children, asChild = false, label = "Open menu", onClick, onPointerDown, onMouseDown, onKeyDown, ...rest }, ref) {
|
|
@@ -736,6 +808,7 @@ var DropdownMenuContent = forwardRef5(
|
|
|
736
808
|
}
|
|
737
809
|
);
|
|
738
810
|
var parts = createMenuParts(DropdownMenuPrimitive);
|
|
811
|
+
var DropdownMenuItems = parts.Items;
|
|
739
812
|
var DropdownMenuItem = parts.Item;
|
|
740
813
|
var DropdownMenuCheckboxItem = parts.CheckboxItem;
|
|
741
814
|
var DropdownMenuRadioGroup = parts.RadioGroup;
|
|
@@ -750,7 +823,7 @@ var DropdownMenuSubContent = parts.SubContent;
|
|
|
750
823
|
|
|
751
824
|
// src/components/chrome/nav-item.tsx
|
|
752
825
|
import clsx9 from "clsx";
|
|
753
|
-
import { Fragment as
|
|
826
|
+
import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
754
827
|
var SIZE = {
|
|
755
828
|
sm: { box: "h-9 gap-2 rounded-lg px-3 py-1.5", label: "text-body-xs", square: "w-9" },
|
|
756
829
|
md: { box: "h-11 gap-3 rounded-xl px-3.5 py-2.5", label: "text-body-sm", square: "w-11" }
|
|
@@ -843,7 +916,7 @@ function NavItem({
|
|
|
843
916
|
onClick?.(event);
|
|
844
917
|
}
|
|
845
918
|
};
|
|
846
|
-
const content = /* @__PURE__ */
|
|
919
|
+
const content = /* @__PURE__ */ jsxs4(Fragment5, { children: [
|
|
847
920
|
icon != null ? /* @__PURE__ */ jsx9("span", { "aria-hidden": true, className: "shrink-0 [&_svg]:size-4", children: icon }) : (
|
|
848
921
|
// Icons are optional, but the collapsed rail hides the label — so a row with neither
|
|
849
922
|
// renders as an empty box. Through 0.5.0 that is exactly what a nav without icons
|
|
@@ -922,7 +995,7 @@ function NavTabs({ items, className }) {
|
|
|
922
995
|
}
|
|
923
996
|
|
|
924
997
|
// src/sidebar/index.tsx
|
|
925
|
-
import { Fragment as
|
|
998
|
+
import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
926
999
|
function AppSidebar({
|
|
927
1000
|
groups,
|
|
928
1001
|
footerNav,
|
|
@@ -944,7 +1017,7 @@ function AppSidebar({
|
|
|
944
1017
|
),
|
|
945
1018
|
[groups, footerNav]
|
|
946
1019
|
);
|
|
947
|
-
return /* @__PURE__ */ jsx11(HashTargets.Provider, { value: hashTargets, children: /* @__PURE__ */
|
|
1020
|
+
return /* @__PURE__ */ jsx11(HashTargets.Provider, { value: hashTargets, children: /* @__PURE__ */ jsxs5(
|
|
948
1021
|
"aside",
|
|
949
1022
|
{
|
|
950
1023
|
className: cn(
|
|
@@ -994,7 +1067,7 @@ function AppSidebar({
|
|
|
994
1067
|
},
|
|
995
1068
|
group.title ?? `group-${groupIndex}`
|
|
996
1069
|
)) }) }),
|
|
997
|
-
(footerNav?.length || footer) && /* @__PURE__ */
|
|
1070
|
+
(footerNav?.length || footer) && /* @__PURE__ */ jsxs5("div", { className: "flex shrink-0 flex-col", children: [
|
|
998
1071
|
footerNav && footerNav.length > 0 && /* @__PURE__ */ jsx11("nav", { className: "flex flex-col gap-3 px-4 pt-2", children: footerNav.map((item) => /* @__PURE__ */ jsx11(
|
|
999
1072
|
SidebarLink,
|
|
1000
1073
|
{
|
|
@@ -1022,7 +1095,7 @@ function SidebarGroup({
|
|
|
1022
1095
|
// 12px between rows, per the design — the rows read as separate pills rather than a
|
|
1023
1096
|
// stack. Through 0.5.0 this was `gap-1`, which packed them into a near-continuous block.
|
|
1024
1097
|
// The same gap spaces the separator and the heading, so neither needs a margin of its own.
|
|
1025
|
-
/* @__PURE__ */
|
|
1098
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-3", children: [
|
|
1026
1099
|
showSeparator && /* @__PURE__ */ jsx11(SidebarSeparator, {}),
|
|
1027
1100
|
group.title && /* @__PURE__ */ jsx11(
|
|
1028
1101
|
"p",
|
|
@@ -1106,7 +1179,7 @@ function SidebarUserCard({
|
|
|
1106
1179
|
className
|
|
1107
1180
|
}) {
|
|
1108
1181
|
const initial = name.trim().charAt(0);
|
|
1109
|
-
const items = /* @__PURE__ */
|
|
1182
|
+
const items = /* @__PURE__ */ jsxs5(Fragment6, { children: [
|
|
1110
1183
|
menu,
|
|
1111
1184
|
/* @__PURE__ */ jsx11(
|
|
1112
1185
|
DropdownMenuItem,
|
|
@@ -1118,18 +1191,18 @@ function SidebarUserCard({
|
|
|
1118
1191
|
)
|
|
1119
1192
|
] });
|
|
1120
1193
|
if (collapsed) {
|
|
1121
|
-
return /* @__PURE__ */ jsx11("div", { className: cn("flex shrink-0 items-center justify-center p-4", className), children: /* @__PURE__ */
|
|
1194
|
+
return /* @__PURE__ */ jsx11("div", { className: cn("flex shrink-0 items-center justify-center p-4", className), children: /* @__PURE__ */ jsxs5(DropdownMenu, { children: [
|
|
1122
1195
|
/* @__PURE__ */ jsx11(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ jsx11("button", { type: "button", "aria-label": `${name} \u2014 user options`, className: "rounded-full", children: /* @__PURE__ */ jsx11(Avatar, { initial, size: "lg", shape: "circle" }) }) }),
|
|
1123
1196
|
/* @__PURE__ */ jsx11(DropdownMenuContent, { side: "right", align: "end", children: items })
|
|
1124
1197
|
] }) });
|
|
1125
1198
|
}
|
|
1126
|
-
return /* @__PURE__ */
|
|
1199
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("flex shrink-0 items-center gap-2.5 p-4", className), children: [
|
|
1127
1200
|
/* @__PURE__ */ jsx11(Avatar, { initial, size: "lg", shape: "circle" }),
|
|
1128
|
-
/* @__PURE__ */
|
|
1201
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
1129
1202
|
/* @__PURE__ */ jsx11("span", { className: "truncate text-body-sm font-semibold leading-snug text-default", children: name }),
|
|
1130
1203
|
/* @__PURE__ */ jsx11("span", { className: "truncate text-body-tiny font-regular leading-none text-default-secondary", children: role })
|
|
1131
1204
|
] }),
|
|
1132
|
-
/* @__PURE__ */
|
|
1205
|
+
/* @__PURE__ */ jsxs5(DropdownMenu, { children: [
|
|
1133
1206
|
/* @__PURE__ */ jsx11(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ jsx11(
|
|
1134
1207
|
"button",
|
|
1135
1208
|
{
|