@withpotter/pages-admin 0.13.0-next.73 → 0.13.0-next.76
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/admin/_shell/nav-fold.js +2 -2
- package/dist/admin/_shell/nav-fold.js.map +1 -1
- package/dist/admin/_shell/nav-group.js +27 -18
- package/dist/admin/_shell/nav-group.js.map +1 -1
- package/dist/admin/_shell/sidebar.js +8 -1
- package/dist/admin/_shell/sidebar.js.map +1 -1
- package/dist/admin/_shell/sidebar.module.css +25 -8
- package/dist/admin/_shell/use-open-groups.js +20 -0
- package/dist/admin/_shell/use-open-groups.js.map +1 -0
- package/package.json +4 -4
- package/dist/admin/_shell/use-group-fold.js +0 -50
- package/dist/admin/_shell/use-group-fold.js.map +0 -1
|
@@ -5,10 +5,10 @@ const FOLDABLE_GROUPS = /* @__PURE__ */ new Set([
|
|
|
5
5
|
"Platform"
|
|
6
6
|
]);
|
|
7
7
|
const foldsGroup = (label, rows, collapsed) => label !== null && FOLDABLE_GROUPS.has(label) && rows > 1 && !collapsed;
|
|
8
|
-
const
|
|
8
|
+
const isGroupOpen = (choices, label, containsActive) => choices[label] ?? containsActive;
|
|
9
9
|
export {
|
|
10
10
|
FOLDABLE_GROUPS,
|
|
11
11
|
foldsGroup,
|
|
12
|
-
|
|
12
|
+
isGroupOpen
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=nav-fold.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/_shell/nav-fold.ts"],"sourcesContent":["/**\n * Which sidebar groups
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/_shell/nav-fold.ts"],"sourcesContent":["/**\n * Which sidebar groups fold, and which one is open. Pure, so it is tested\n * without a browser. The merchant rail's hubs follow the same rules.\n */\n\n/**\n * The groups the admin opened or closed by hand, by label. A group not listed\n * has no choice yet, and each group is chosen on its own.\n */\nexport type GroupChoices = Record<string, boolean>;\n\n/** The groups that fold; every other group keeps its plain heading. */\nexport const FOLDABLE_GROUPS: ReadonlySet<string> = new Set([\n 'Workspaces',\n 'Operations',\n 'Inbox',\n 'Platform',\n]);\n\n/**\n * A group folds only when it is one of those, has more than one row to hide,\n * and the rail is wide: the icon-only rail has no headings to press.\n */\nexport const foldsGroup = (\n label: string | null,\n rows: number,\n collapsed: boolean,\n): label is string =>\n label !== null && FOLDABLE_GROUPS.has(label) && rows > 1 && !collapsed;\n\n/**\n * A group the admin chose is as they left it, whatever the others are doing.\n * With no choice yet it is open when it owns the current page, so the page\n * you are on always has a lit row.\n */\nexport const isGroupOpen = (\n choices: GroupChoices,\n label: string,\n containsActive: boolean,\n) => choices[label] ?? containsActive;\n"],"mappings":"AAYO,MAAM,kBAAuC,oBAAI,IAAI;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,MAAM,aAAa,CACxB,OACA,MACA,cAEA,UAAU,QAAQ,gBAAgB,IAAI,KAAK,KAAK,OAAO,KAAK,CAAC;AAOxD,MAAM,cAAc,CACzB,SACA,OACA,mBACG,QAAQ,KAAK,KAAK;","names":[]}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ChevronDown } from "lucide-react";
|
|
4
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
5
|
+
import { eases } from "@withpotter/lib/motion";
|
|
4
6
|
import { isActive } from "./nav-filter";
|
|
5
|
-
import { foldsGroup } from "./nav-fold";
|
|
7
|
+
import { foldsGroup, isGroupOpen } from "./nav-fold";
|
|
6
8
|
import { NavRow } from "./nav-row";
|
|
7
|
-
import { useGroupFold } from "./use-group-fold";
|
|
8
9
|
import styles from "./sidebar.module.css";
|
|
9
10
|
function NavGroupView({
|
|
10
11
|
group,
|
|
11
12
|
pathname,
|
|
12
13
|
collapsed,
|
|
13
|
-
canSupport
|
|
14
|
+
canSupport,
|
|
15
|
+
choices,
|
|
16
|
+
onToggle
|
|
14
17
|
}) {
|
|
18
|
+
const reduced = useReducedMotion();
|
|
15
19
|
const { label, items } = group;
|
|
16
20
|
const containsActive = items.some((item) => isActive(item, pathname));
|
|
17
|
-
const { closed, toggle } = useGroupFold(label ?? "", containsActive);
|
|
18
|
-
const folds = foldsGroup(label, items.length, collapsed);
|
|
19
21
|
const rows = items.map((item) => /* @__PURE__ */ jsx(
|
|
20
22
|
NavRow,
|
|
21
23
|
{
|
|
@@ -26,34 +28,41 @@ function NavGroupView({
|
|
|
26
28
|
},
|
|
27
29
|
item.href
|
|
28
30
|
));
|
|
29
|
-
if (!
|
|
31
|
+
if (!foldsGroup(label, items.length, collapsed))
|
|
30
32
|
return /* @__PURE__ */ jsxs("div", { className: styles.group, children: [
|
|
31
33
|
label && /* @__PURE__ */ jsx("div", { className: styles.groupLabel, children: label }),
|
|
32
34
|
rows
|
|
33
35
|
] });
|
|
36
|
+
const open = isGroupOpen(choices, label, containsActive);
|
|
34
37
|
return /* @__PURE__ */ jsxs("div", { className: styles.group, children: [
|
|
35
38
|
/* @__PURE__ */ jsxs(
|
|
36
39
|
"button",
|
|
37
40
|
{
|
|
38
41
|
type: "button",
|
|
39
42
|
className: `${styles.groupLabel} ${styles.groupToggle}`,
|
|
40
|
-
"aria-expanded":
|
|
41
|
-
onClick:
|
|
43
|
+
"aria-expanded": open,
|
|
44
|
+
onClick: () => onToggle(label, !open),
|
|
42
45
|
children: [
|
|
43
46
|
/* @__PURE__ */ jsx("span", { children: label }),
|
|
44
|
-
/* @__PURE__ */ jsx(
|
|
45
|
-
ChevronDown,
|
|
46
|
-
{
|
|
47
|
-
size: 14,
|
|
48
|
-
className: styles.groupChevron,
|
|
49
|
-
"data-closed": closed,
|
|
50
|
-
"aria-hidden": true
|
|
51
|
-
}
|
|
52
|
-
)
|
|
47
|
+
/* @__PURE__ */ jsx(ChevronDown, { size: 14, className: styles.groupChevron, "aria-hidden": true })
|
|
53
48
|
]
|
|
54
49
|
}
|
|
55
50
|
),
|
|
56
|
-
|
|
51
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: open && /* @__PURE__ */ jsx(
|
|
52
|
+
motion.div,
|
|
53
|
+
{
|
|
54
|
+
className: styles.groupRows,
|
|
55
|
+
initial: { height: 0, opacity: 0 },
|
|
56
|
+
animate: { height: "auto", opacity: 1 },
|
|
57
|
+
exit: { height: 0, opacity: 0 },
|
|
58
|
+
transition: reduced ? { duration: 0 } : {
|
|
59
|
+
height: { duration: 0.24, ease: eases.settle },
|
|
60
|
+
opacity: { duration: 0.16, ease: eases.out }
|
|
61
|
+
},
|
|
62
|
+
style: { overflow: "hidden" },
|
|
63
|
+
children: rows
|
|
64
|
+
}
|
|
65
|
+
) })
|
|
57
66
|
] });
|
|
58
67
|
}
|
|
59
68
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/_shell/nav-group.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronDown } from 'lucide-react';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/_shell/nav-group.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronDown } from 'lucide-react';\nimport { AnimatePresence, motion, useReducedMotion } from 'motion/react';\nimport { eases } from '@withpotter/lib/motion';\nimport type { NavGroup } from './nav-config';\nimport { isActive } from './nav-filter';\nimport { foldsGroup, isGroupOpen, type GroupChoices } from './nav-fold';\nimport { NavRow } from './nav-row';\nimport styles from './sidebar.module.css';\n\n/**\n * One sidebar group. With a heading and more than one row, the heading is a\n * button that opens and closes the rows, on its own: no other group moves.\n * The group holding the current page starts open, and the icon-only rail shows\n * every row.\n */\nexport function NavGroupView({\n group,\n pathname,\n collapsed,\n canSupport,\n choices,\n onToggle,\n}: {\n group: NavGroup;\n pathname: string;\n collapsed: boolean;\n canSupport: boolean;\n choices: GroupChoices;\n onToggle: (label: string, next: boolean) => void;\n}) {\n const reduced = useReducedMotion();\n const { label, items } = group;\n const containsActive = items.some((item) => isActive(item, pathname));\n\n const rows = items.map((item) => (\n <NavRow\n key={item.href}\n item={item}\n active={isActive(item, pathname)}\n collapsed={collapsed}\n canSupport={canSupport}\n />\n ));\n\n if (!foldsGroup(label, items.length, collapsed))\n return (\n <div className={styles.group}>\n {label && <div className={styles.groupLabel}>{label}</div>}\n {rows}\n </div>\n );\n\n const open = isGroupOpen(choices, label, containsActive);\n\n return (\n <div className={styles.group}>\n <button\n type=\"button\"\n className={`${styles.groupLabel} ${styles.groupToggle}`}\n aria-expanded={open}\n onClick={() => onToggle(label, !open)}\n >\n <span>{label}</span>\n <ChevronDown size={14} className={styles.groupChevron} aria-hidden />\n </button>\n {/* The rows grow and collapse rather than blink, as the merchant rail's\n hubs do: height so the groups below move with them, opacity finishing\n early on the way in. Clipped, or the rows spill past the closing box. */}\n <AnimatePresence initial={false}>\n {open && (\n <motion.div\n className={styles.groupRows}\n initial={{ height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={{ height: 0, opacity: 0 }}\n transition={\n reduced\n ? { duration: 0 }\n : {\n height: { duration: 0.24, ease: eases.settle },\n opacity: { duration: 0.16, ease: eases.out },\n }\n }\n style={{ overflow: 'hidden' }}\n >\n {rows}\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n );\n}\n"],"mappings":";AAqCI,cAWE,YAXF;AAnCJ,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB,QAAQ,wBAAwB;AAC1D,SAAS,aAAa;AAEtB,SAAS,gBAAgB;AACzB,SAAS,YAAY,mBAAsC;AAC3D,SAAS,cAAc;AACvB,OAAO,YAAY;AAQZ,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOG;AACD,QAAM,UAAU,iBAAiB;AACjC,QAAM,EAAE,OAAO,MAAM,IAAI;AACzB,QAAM,iBAAiB,MAAM,KAAK,CAAC,SAAS,SAAS,MAAM,QAAQ,CAA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[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { isActive } from "./nav-filter";
|
|
4
4
|
import { NavGroupView } from "./nav-group";
|
|
5
|
+
import { useOpenGroups } from "./use-open-groups";
|
|
5
6
|
import { SidebarFooter } from "./sidebar-footer";
|
|
6
7
|
import { useFluidHover } from "./use-fluid-hover";
|
|
7
8
|
import { UserMenu } from "./user-menu";
|
|
@@ -22,6 +23,10 @@ function Sidebar({
|
|
|
22
23
|
...group,
|
|
23
24
|
items: group.items.filter((item) => item.href !== FOOT_HREF)
|
|
24
25
|
})).filter((group) => group.items.length);
|
|
26
|
+
const activeGroup = navGroups.find(
|
|
27
|
+
(group) => group.items.some((item) => isActive(item, pathname))
|
|
28
|
+
)?.label ?? null;
|
|
29
|
+
const { choices, setGroupOpen } = useOpenGroups(pathname, activeGroup);
|
|
25
30
|
return /* @__PURE__ */ jsxs("aside", { className: styles.sidebar, "data-collapsed": collapsed, children: [
|
|
26
31
|
/* @__PURE__ */ jsx(UserMenu, { email, role, collapsed }),
|
|
27
32
|
/* @__PURE__ */ jsxs(
|
|
@@ -50,7 +55,9 @@ function Sidebar({
|
|
|
50
55
|
group,
|
|
51
56
|
pathname,
|
|
52
57
|
collapsed,
|
|
53
|
-
canSupport
|
|
58
|
+
canSupport,
|
|
59
|
+
choices,
|
|
60
|
+
onToggle: setGroupOpen
|
|
54
61
|
},
|
|
55
62
|
group.label ?? index
|
|
56
63
|
))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/_shell/sidebar.tsx"],"sourcesContent":["'use client';\n\nimport type { NavGroup } from './nav-config';\nimport { isActive } from './nav-filter';\nimport { NavGroupView } from './nav-group';\nimport { SidebarFooter } from './sidebar-footer';\nimport { useFluidHover } from './use-fluid-hover';\nimport { UserMenu } from './user-menu';\nimport styles from './sidebar.module.css';\n\n/** Settings lives in the pinned foot, beside the theme switch. */\nconst FOOT_HREF = '/admin/settings';\n\nexport function Sidebar({\n groups,\n pathname,\n canSupport,\n collapsed,\n email,\n role,\n onSearch,\n}: {\n groups: NavGroup[];\n pathname: string;\n canSupport: boolean;\n collapsed: boolean;\n email: string;\n role: string;\n onSearch: () => void;\n}) {\n const hover = useFluidHover();\n const settings = groups\n .flatMap((group) => group.items)\n .find((item) => item.href === FOOT_HREF);\n const navGroups = groups\n .map((group) => ({\n ...group,\n items: group.items.filter((item) => item.href !== FOOT_HREF),\n }))\n .filter((group) => group.items.length);\n\n return (\n <aside className={styles.sidebar} data-collapsed={collapsed}>\n <UserMenu email={email} role={role} collapsed={collapsed} />\n\n <nav\n className={styles.nav}\n aria-label=\"Admin\"\n onPointerMove={hover.onPointerMove}\n onPointerLeave={hover.onPointerLeave}\n >\n <span\n aria-hidden\n className={styles.glide}\n data-visible={Boolean(hover.rect)}\n style={\n hover.rect\n ? {\n transform: `translateY(${hover.rect.top}px)`,\n height: hover.rect.height,\n }\n : undefined\n }\n />\n {navGroups.map((group, index) => (\n <NavGroupView\n key={group.label ?? index}\n group={group}\n pathname={pathname}\n collapsed={collapsed}\n canSupport={canSupport}\n />\n ))}\n </nav>\n\n <SidebarFooter\n collapsed={collapsed}\n showSettings={Boolean(settings)}\n settingsActive={settings ? isActive(settings, pathname) : false}\n onSearch={onSearch}\n />\n </aside>\n );\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/_shell/sidebar.tsx"],"sourcesContent":["'use client';\n\nimport type { NavGroup } from './nav-config';\nimport { isActive } from './nav-filter';\nimport { NavGroupView } from './nav-group';\nimport { useOpenGroups } from './use-open-groups';\nimport { SidebarFooter } from './sidebar-footer';\nimport { useFluidHover } from './use-fluid-hover';\nimport { UserMenu } from './user-menu';\nimport styles from './sidebar.module.css';\n\n/** Settings lives in the pinned foot, beside the theme switch. */\nconst FOOT_HREF = '/admin/settings';\n\nexport function Sidebar({\n groups,\n pathname,\n canSupport,\n collapsed,\n email,\n role,\n onSearch,\n}: {\n groups: NavGroup[];\n pathname: string;\n canSupport: boolean;\n collapsed: boolean;\n email: string;\n role: string;\n onSearch: () => void;\n}) {\n const hover = useFluidHover();\n const settings = groups\n .flatMap((group) => group.items)\n .find((item) => item.href === FOOT_HREF);\n const navGroups = groups\n .map((group) => ({\n ...group,\n items: group.items.filter((item) => item.href !== FOOT_HREF),\n }))\n .filter((group) => group.items.length);\n const activeGroup =\n navGroups.find((group) =>\n group.items.some((item) => isActive(item, pathname)),\n )?.label ?? null;\n const { choices, setGroupOpen } = useOpenGroups(pathname, activeGroup);\n\n return (\n <aside className={styles.sidebar} data-collapsed={collapsed}>\n <UserMenu email={email} role={role} collapsed={collapsed} />\n\n <nav\n className={styles.nav}\n aria-label=\"Admin\"\n onPointerMove={hover.onPointerMove}\n onPointerLeave={hover.onPointerLeave}\n >\n <span\n aria-hidden\n className={styles.glide}\n data-visible={Boolean(hover.rect)}\n style={\n hover.rect\n ? {\n transform: `translateY(${hover.rect.top}px)`,\n height: hover.rect.height,\n }\n : undefined\n }\n />\n {navGroups.map((group, index) => (\n <NavGroupView\n key={group.label ?? index}\n group={group}\n pathname={pathname}\n collapsed={collapsed}\n canSupport={canSupport}\n choices={choices}\n onToggle={setGroupOpen}\n />\n ))}\n </nav>\n\n <SidebarFooter\n collapsed={collapsed}\n showSettings={Boolean(settings)}\n settingsActive={settings ? isActive(settings, pathname) : false}\n onSearch={onSearch}\n />\n </aside>\n );\n}\n"],"mappings":";AAiDM,cAEA,YAFA;AA9CN,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,OAAO,YAAY;AAGnB,MAAM,YAAY;AAEX,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAQG;AACD,QAAM,QAAQ,cAAc;AAC5B,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U,QAAQ,IAAI;AAAA,QAC1D;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -92,20 +92,37 @@
|
|
|
92
92
|
flex: none;
|
|
93
93
|
opacity: 0;
|
|
94
94
|
transition:
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
transform var(--adm-fast),
|
|
96
|
+
opacity var(--adm-fast);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/* The chevron arrives on hover, as on the merchant rail, and stays while the
|
|
100
|
+
group is open, rotated, to say the rows below belong to this heading. A
|
|
101
|
+
keyboard has no pointer and touch has no hover, so those keep it too. */
|
|
99
102
|
.groupToggle:hover .groupChevron,
|
|
100
|
-
.groupToggle:focus-visible .groupChevron
|
|
103
|
+
.groupToggle:focus-visible .groupChevron,
|
|
104
|
+
.groupToggle[aria-expanded='true'] .groupChevron {
|
|
101
105
|
opacity: 1;
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
.groupToggle[aria-expanded='true'] .groupChevron {
|
|
109
|
+
transform: rotate(180deg);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@media (hover: none) {
|
|
113
|
+
.groupChevron {
|
|
114
|
+
opacity: 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* The rows of a folding group, laid out like the group's own. The padding keeps
|
|
119
|
+
a focus ring from being clipped by the closing box; the margin takes it back. */
|
|
120
|
+
.groupRows {
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
gap: 2px;
|
|
124
|
+
padding: 2px;
|
|
125
|
+
margin: -2px;
|
|
109
126
|
}
|
|
110
127
|
|
|
111
128
|
.link {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
function useOpenGroups(pathname, activeGroup) {
|
|
4
|
+
const [choices, setChoices] = useState({});
|
|
5
|
+
const setGroupOpen = (label, next) => setChoices((current) => ({ ...current, [label]: next }));
|
|
6
|
+
const [choiceRoute, setChoiceRoute] = useState(pathname);
|
|
7
|
+
if (choiceRoute !== pathname) {
|
|
8
|
+
setChoiceRoute(pathname);
|
|
9
|
+
if (activeGroup && activeGroup in choices) {
|
|
10
|
+
const next = { ...choices };
|
|
11
|
+
delete next[activeGroup];
|
|
12
|
+
setChoices(next);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return { choices, setGroupOpen };
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useOpenGroups
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=use-open-groups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/_shell/use-open-groups.ts"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport type { GroupChoices } from './nav-fold';\n\n/**\n * Which sidebar groups the admin has opened or closed by hand, each on its\n * own: pressing one never moves another. `activeGroup` is the group holding the\n * current page, or null.\n */\nexport function useOpenGroups(pathname: string, activeGroup: string | null) {\n const [choices, setChoices] = useState<GroupChoices>({});\n const setGroupOpen = (label: string, next: boolean) =>\n setChoices((current) => ({ ...current, [label]: next }));\n // Arriving on a page retires the choice for its own group only, or a group\n // closed by hand would hide the row you just landed on. The other groups\n // stay as they were. Adjusted during render, not in an effect, so no stale\n // frame paints first.\n const [choiceRoute, setChoiceRoute] = useState(pathname);\n\n if (choiceRoute !== pathname) {\n setChoiceRoute(pathname);\n\n if (activeGroup && activeGroup in choices) {\n const next = { ...choices };\n\n delete next[activeGroup];\n setChoices(next);\n }\n }\n\n return { choices, setGroupOpen };\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AAQlB,SAAS,cAAc,UAAkB,aAA4B;AAC1E,QAAM,CAAC,SAAS,UAAU,IAAI,SAAuB,CAAC,CAAC;AACvD,QAAM,eAAe,CAAC,OAAe,SACnC,WAAW,CAAC,aAAa,EAAE,GAAG,SAAS,CAAC,KAAK,GAAG,KAAK,EAAE;AAKzD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,QAAQ;AAEvD,MAAI,gBAAgB,UAAU;AAC5B,mBAAe,QAAQ;AAEvB,QAAI,eAAe,eAAe,SAAS;AACzC,YAAM,OAAO,EAAE,GAAG,QAAQ;AAE1B,aAAO,KAAK,WAAW;AACvB,iBAAW,IAAI;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,aAAa;AACjC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@withpotter/pages-admin",
|
|
3
|
-
"version": "0.13.0-next.
|
|
3
|
+
"version": "0.13.0-next.76",
|
|
4
4
|
"description": "Box console platform-admin routes: overview, revenue, accounts, tenants, admins, roles, audit.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@radix-ui/react-popover": "^1.1.23",
|
|
33
33
|
"@tanstack/react-query": "^5.90.20",
|
|
34
|
-
"@withpotter/lib": "^0.13.0-next.
|
|
35
|
-
"@withpotter/platform-admin": "^0.13.0-next.
|
|
36
|
-
"@withpotter/ui-kit": "^0.13.0-next.
|
|
34
|
+
"@withpotter/lib": "^0.13.0-next.76",
|
|
35
|
+
"@withpotter/platform-admin": "^0.13.0-next.76",
|
|
36
|
+
"@withpotter/ui-kit": "^0.13.0-next.76",
|
|
37
37
|
"lucide-react": "^0.562.0",
|
|
38
38
|
"motion": "^12.42.2"
|
|
39
39
|
},
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useCallback, useSyncExternalStore } from "react";
|
|
3
|
-
import { isGroupClosed } from "./nav-fold";
|
|
4
|
-
const STORAGE_KEY = "pb_admin_nav_closed";
|
|
5
|
-
let closedCache = {};
|
|
6
|
-
let closedRaw = null;
|
|
7
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
8
|
-
function readClosed() {
|
|
9
|
-
if (typeof window === "undefined") return closedCache;
|
|
10
|
-
let raw = null;
|
|
11
|
-
try {
|
|
12
|
-
raw = localStorage.getItem(STORAGE_KEY);
|
|
13
|
-
} catch {
|
|
14
|
-
return closedCache;
|
|
15
|
-
}
|
|
16
|
-
if (raw !== closedRaw) {
|
|
17
|
-
closedRaw = raw;
|
|
18
|
-
try {
|
|
19
|
-
closedCache = raw ? JSON.parse(raw) : {};
|
|
20
|
-
} catch {
|
|
21
|
-
closedCache = {};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return closedCache;
|
|
25
|
-
}
|
|
26
|
-
const serverSnapshot = () => closedCache;
|
|
27
|
-
function subscribe(fn) {
|
|
28
|
-
listeners.add(fn);
|
|
29
|
-
return () => listeners.delete(fn);
|
|
30
|
-
}
|
|
31
|
-
function setClosed(label, closed) {
|
|
32
|
-
const next = { ...readClosed(), [label]: closed };
|
|
33
|
-
try {
|
|
34
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
closedRaw = JSON.stringify(next);
|
|
38
|
-
closedCache = next;
|
|
39
|
-
listeners.forEach((fn) => fn());
|
|
40
|
-
}
|
|
41
|
-
function useGroupFold(label, containsActive) {
|
|
42
|
-
const folded = useSyncExternalStore(subscribe, readClosed, serverSnapshot);
|
|
43
|
-
const closed = isGroupClosed(folded, label, containsActive);
|
|
44
|
-
const toggle = useCallback(() => setClosed(label, !closed), [label, closed]);
|
|
45
|
-
return { closed, toggle };
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
useGroupFold
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=use-group-fold.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/_shell/use-group-fold.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useSyncExternalStore } from 'react';\nimport { isGroupClosed, type FoldMap } from './nav-fold';\n\nconst STORAGE_KEY = 'pb_admin_nav_closed';\n\n/**\n * Which groups the admin has folded away, as an external store. localStorage\n * does not exist while the server renders, so reading it into state would\n * mismatch the HTML; useSyncExternalStore is built for this (the merchant\n * rail's NavSection does the same).\n */\nlet closedCache: FoldMap = {};\nlet closedRaw: string | null = null;\nconst listeners = new Set<() => void>();\n\nfunction readClosed(): FoldMap {\n if (typeof window === 'undefined') return closedCache;\n\n let raw: string | null = null;\n\n try {\n raw = localStorage.getItem(STORAGE_KEY);\n } catch {\n return closedCache;\n }\n\n // Cached by raw string so the snapshot is stable between renders; a fresh\n // object every call makes useSyncExternalStore loop.\n if (raw !== closedRaw) {\n closedRaw = raw;\n\n try {\n closedCache = raw ? JSON.parse(raw) : {};\n } catch {\n closedCache = {};\n }\n }\n\n return closedCache;\n}\n\n/** The server has no localStorage, so nothing is folded on first paint. */\nconst serverSnapshot = () => closedCache;\n\nfunction subscribe(fn: () => void) {\n listeners.add(fn);\n\n return () => listeners.delete(fn);\n}\n\nfunction setClosed(label: string, closed: boolean) {\n const next = { ...readClosed(), [label]: closed };\n\n try {\n localStorage.setItem(STORAGE_KEY, JSON.stringify(next));\n } catch {\n /* private mode: the choice just won't survive the visit */\n }\n\n closedRaw = JSON.stringify(next);\n closedCache = next;\n listeners.forEach((fn) => fn());\n}\n\nexport function useGroupFold(label: string, containsActive: boolean) {\n const folded = useSyncExternalStore(subscribe, readClosed, serverSnapshot);\n const closed = isGroupClosed(folded, label, containsActive);\n const toggle = useCallback(() => setClosed(label, !closed), [label, closed]);\n\n return { closed, toggle };\n}\n"],"mappings":";AAEA,SAAS,aAAa,4BAA4B;AAClD,SAAS,qBAAmC;AAE5C,MAAM,cAAc;AAQpB,IAAI,cAAuB,CAAC;AAC5B,IAAI,YAA2B;AAC/B,MAAM,YAAY,oBAAI,IAAgB;AAEtC,SAAS,aAAsB;AAC7B,MAAI,OAAO,WAAW,YAAa,QAAO;AAE1C,MAAI,MAAqB;AAEzB,MAAI;AACF,UAAM,aAAa,QAAQ,WAAW;AAAA,EACxC,QAAQ;AACN,WAAO;AAAA,EACT;AAIA,MAAI,QAAQ,WAAW;AACrB,gBAAY;AAEZ,QAAI;AACF,oBAAc,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;AAAA,IACzC,QAAQ;AACN,oBAAc,CAAC;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;AAGA,MAAM,iBAAiB,MAAM;AAE7B,SAAS,UAAU,IAAgB;AACjC,YAAU,IAAI,EAAE;AAEhB,SAAO,MAAM,UAAU,OAAO,EAAE;AAClC;AAEA,SAAS,UAAU,OAAe,QAAiB;AACjD,QAAM,OAAO,EAAE,GAAG,WAAW,GAAG,CAAC,KAAK,GAAG,OAAO;AAEhD,MAAI;AACF,iBAAa,QAAQ,aAAa,KAAK,UAAU,IAAI,CAAC;AAAA,EACxD,QAAQ;AAAA,EAER;AAEA,cAAY,KAAK,UAAU,IAAI;AAC/B,gBAAc;AACd,YAAU,QAAQ,CAAC,OAAO,GAAG,CAAC;AAChC;AAEO,SAAS,aAAa,OAAe,gBAAyB;AACnE,QAAM,SAAS,qBAAqB,WAAW,YAAY,cAAc;AACzE,QAAM,SAAS,cAAc,QAAQ,OAAO,cAAc;AAC1D,QAAM,SAAS,YAAY,MAAM,UAAU,OAAO,CAAC,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC;AAE3E,SAAO,EAAE,QAAQ,OAAO;AAC1B;","names":[]}
|