@okjt/dashboard 0.7.0 → 0.9.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/AccountMenu.js +1 -1
- package/dist/ActivityPanel.js +3 -3
- package/dist/AdminPageHero.js +2 -2
- package/dist/AdminSidePanel.js +4 -4
- package/dist/AdminSummaryCards.js +1 -1
- package/dist/AdminToolbarFilters.js +4 -4
- package/dist/AdminTutorial.js +1 -1
- package/dist/BoldToolbar.js +2 -2
- package/dist/CollaboratorAvatars.js +2 -2
- package/dist/DashboardProvider.js +1 -1
- package/dist/DashboardSidebar.js +1 -1
- package/dist/ShareModal.js +1 -1
- package/dist/TwoPaneDialog.js +67 -0
- package/dist/TwoPaneForm.js +154 -0
- package/dist/VersionHistoryDrawer.js +3 -3
- package/dist/index.js +7 -0
- package/dist/toolbar-glass.css +68 -0
- package/dist/useAdminAction.js +12 -9
- package/dist/useFilteredItems.js +28 -10
- package/dist/useGlassToolbar.js +67 -0
- package/package.json +7 -4
package/dist/AccountMenu.js
CHANGED
|
@@ -48,7 +48,7 @@ function AccountMenu({ compactLinks = [], links = [], roleText, extra, fallbackN
|
|
|
48
48
|
/* @__PURE__ */ jsxs("div", { className: "px-4 py-2 border-b border-tone-100 mb-1", children: [
|
|
49
49
|
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-tone-800 truncate", children: user?.name || fallbackName }),
|
|
50
50
|
user?.email && /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-500 truncate", children: user.email }),
|
|
51
|
-
roleText && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-accent font-medium mt-0.5", children: roleText })
|
|
51
|
+
roleText && /* @__PURE__ */ jsx("p", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] text-accent font-medium mt-0.5", children: roleText })
|
|
52
52
|
] }),
|
|
53
53
|
extra?.({ itemClass, close }),
|
|
54
54
|
compactLinks.length > 0 && /* @__PURE__ */ jsx("div", { className: "md:hidden border-b border-tone-100 pb-1 mb-1", children: compactLinks.map((link) => /* @__PURE__ */ jsxs(Link, { to: link.path, role: "menuitem", onClick: close, className: itemClass, children: [
|
package/dist/ActivityPanel.js
CHANGED
|
@@ -18,7 +18,7 @@ function ActivityPanel() {
|
|
|
18
18
|
});
|
|
19
19
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
|
|
20
20
|
/* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
21
|
-
/* @__PURE__ */ jsx("h3", { className: "text-[11px] font-bold uppercase tracking-wider text-tone-500", children: "On this page" }),
|
|
21
|
+
/* @__PURE__ */ jsx("h3", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] font-bold uppercase tracking-wider text-tone-500", children: "On this page" }),
|
|
22
22
|
othersHere.length ? /* @__PURE__ */ jsxs("ul", { className: "space-y-1.5", children: [
|
|
23
23
|
othersHere.map((person) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-sm text-tone-700", children: [
|
|
24
24
|
/* @__PURE__ */ jsx(CollaboratorAvatar, { person, size: "xs" }),
|
|
@@ -29,14 +29,14 @@ function ActivityPanel() {
|
|
|
29
29
|
] }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-500", children: "Only you right now." })
|
|
30
30
|
] }),
|
|
31
31
|
/* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
32
|
-
/* @__PURE__ */ jsx("h3", { className: "text-[11px] font-bold uppercase tracking-wider text-tone-500", children: "Recent changes" }),
|
|
32
|
+
/* @__PURE__ */ jsx("h3", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] font-bold uppercase tracking-wider text-tone-500", children: "Recent changes" }),
|
|
33
33
|
isLoading ? /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-400", children: "Loading\u2026" }) : recent.length ? /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: recent.map((r) => /* @__PURE__ */ jsxs("li", { className: "text-xs text-tone-600 leading-snug", children: [
|
|
34
34
|
/* @__PURE__ */ jsx("span", { className: "font-medium text-tone-800", children: r.user?.name || anonymousName }),
|
|
35
35
|
" ",
|
|
36
36
|
ACTION_WORDS[r.action] || r.action,
|
|
37
37
|
" ",
|
|
38
38
|
/* @__PURE__ */ jsx("span", { className: "font-medium text-tone-800", children: r.subject_label }),
|
|
39
|
-
/* @__PURE__ */ jsx("span", { className: "block text-[11px] text-tone-400", children: formatDistanceToNow(new Date(r.updated_at || r.created_at), { addSuffix: true }) })
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: "block text-[length:max(11px,var(--okjt-min-text,0px))] text-tone-400", children: formatDistanceToNow(new Date(r.updated_at || r.created_at), { addSuffix: true }) })
|
|
40
40
|
] }, r.id)) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-500", children: "No changes recorded here yet." }),
|
|
41
41
|
/* @__PURE__ */ jsx(Button, { size: "sm", icon: History, fullWidth: true, onClick: openHistory, children: "Version history" })
|
|
42
42
|
] }),
|
package/dist/AdminPageHero.js
CHANGED
|
@@ -44,7 +44,7 @@ function PlainPageHero({ title, description, breadcrumb, icon }) {
|
|
|
44
44
|
children: [
|
|
45
45
|
icon && /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-lg flex items-center justify-center shrink-0", style: { background: "color-mix(in srgb, var(--color-accent) 10%, transparent)" }, children: icon }),
|
|
46
46
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 leading-tight", children: [
|
|
47
|
-
parent && /* @__PURE__ */ jsx("p", { className: "hidden sm:block text-[11px] text-tone-400 truncate", children: parent.path ? /* @__PURE__ */ jsx(Link, { to: parent.path, className: "hover:text-accent", children: parent.label }) : parent.label }),
|
|
47
|
+
parent && /* @__PURE__ */ jsx("p", { className: "hidden sm:block text-[length:max(11px,var(--okjt-min-text,0px))] text-tone-400 truncate", children: parent.path ? /* @__PURE__ */ jsx(Link, { to: parent.path, className: "hover:text-accent", children: parent.label }) : parent.label }),
|
|
48
48
|
/* @__PURE__ */ jsx("p", { className: "text-base font-semibold text-body truncate", children: title })
|
|
49
49
|
] }),
|
|
50
50
|
/* @__PURE__ */ jsx(
|
|
@@ -127,7 +127,7 @@ function BoldPageHero({ title, subtitle, description, breadcrumbs = [], breadcru
|
|
|
127
127
|
className: "flex items-center gap-3 min-w-0",
|
|
128
128
|
children: [
|
|
129
129
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 leading-tight", children: [
|
|
130
|
-
parent && /* @__PURE__ */ jsx("p", { className: "hidden sm:block text-[11px] text-soft truncate", children: parentTo ? /* @__PURE__ */ jsx(Link, { to: parentTo, className: "hover:text-ink transition", children: parent.label }) : parent.label }),
|
|
130
|
+
parent && /* @__PURE__ */ jsx("p", { className: "hidden sm:block text-[length:max(11px,var(--okjt-min-text,0px))] text-soft truncate", children: parentTo ? /* @__PURE__ */ jsx(Link, { to: parentTo, className: "hover:text-ink transition", children: parent.label }) : parent.label }),
|
|
131
131
|
/* @__PURE__ */ jsx("p", { className: "text-ink font-semibold truncate", children: title })
|
|
132
132
|
] }),
|
|
133
133
|
/* @__PURE__ */ jsxs(
|
package/dist/AdminSidePanel.js
CHANGED
|
@@ -10,7 +10,7 @@ const Named = ({ name, fallback: Fallback, className }) => /* @__PURE__ */ jsx(D
|
|
|
10
10
|
function Badge({ item }) {
|
|
11
11
|
if (useLook() === "bold") return /* @__PURE__ */ jsx(BoldBadge, { item });
|
|
12
12
|
if (item.badge > 0) {
|
|
13
|
-
return /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 min-w-[1.25rem] h-5 px-1.5 rounded-full bg-accent/15 text-accent-dark text-[11px] font-semibold flex items-center justify-center", children: item.badge > 99 ? "99+" : item.badge });
|
|
13
|
+
return /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 min-w-[1.25rem] h-5 px-1.5 rounded-full bg-accent/15 text-accent-dark text-[length:max(11px,var(--okjt-min-text,0px))] font-semibold flex items-center justify-center", children: item.badge > 99 ? "99+" : item.badge });
|
|
14
14
|
}
|
|
15
15
|
if (item.dot) {
|
|
16
16
|
return /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 w-2 h-2 rounded-full bg-amber-500", "aria-label": "Unsaved changes" });
|
|
@@ -22,7 +22,7 @@ function Badge({ item }) {
|
|
|
22
22
|
}
|
|
23
23
|
function BoldBadge({ item }) {
|
|
24
24
|
if (item.badge > 0) {
|
|
25
|
-
return /* @__PURE__ */ jsx("span", { className: "ml-auto flex h-5 min-w-[1.25rem] shrink-0 items-center justify-center rounded-full bg-accent/15 px-1.5 text-[11px] font-semibold text-accent-dark", children: item.badge > 99 ? "99+" : item.badge });
|
|
25
|
+
return /* @__PURE__ */ jsx("span", { className: "ml-auto flex h-5 min-w-[1.25rem] shrink-0 items-center justify-center rounded-full bg-accent/15 px-1.5 text-[length:max(11px,var(--okjt-min-text,0px))] font-semibold text-accent-dark", children: item.badge > 99 ? "99+" : item.badge });
|
|
26
26
|
}
|
|
27
27
|
if (item.dot) return /* @__PURE__ */ jsx("span", { className: "ml-auto h-2 w-2 shrink-0 rounded-full bg-amber-400", "aria-label": "Unsaved changes" });
|
|
28
28
|
if (item.count != null) return /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 text-xs tabular-nums text-tone-400", children: item.count });
|
|
@@ -48,7 +48,7 @@ function SidePanelNav({ panel, onPicked, selection, manage = {} }) {
|
|
|
48
48
|
role: "tab",
|
|
49
49
|
"aria-selected": active,
|
|
50
50
|
onClick: () => pick(item.id),
|
|
51
|
-
className: `relative flex flex-col items-center gap-1 py-2 px-0.5 rounded-xl text-[10px] font-semibold uppercase tracking-wide transition-colors border ${active ? "bg-accent/10 border-accent/30 text-accent-dark" : "border-transparent text-tone-500 hover:bg-tone-50 hover:text-tone-700"}`,
|
|
51
|
+
className: `relative flex flex-col items-center gap-1 py-2 px-0.5 rounded-xl text-[length:max(10px,var(--okjt-min-text,0px))] font-semibold uppercase tracking-wide transition-colors border ${active ? "bg-accent/10 border-accent/30 text-accent-dark" : "border-transparent text-tone-500 hover:bg-tone-50 hover:text-tone-700"}`,
|
|
52
52
|
children: [
|
|
53
53
|
Icon && /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4", "aria-hidden": "true" }),
|
|
54
54
|
item.label,
|
|
@@ -68,7 +68,7 @@ function SidePanelNav({ panel, onPicked, selection, manage = {} }) {
|
|
|
68
68
|
const selecting = !!selection?.selecting;
|
|
69
69
|
const canReorder = !!manage.canReorder && !selecting && movable.length > 1;
|
|
70
70
|
const row = ({ item, groupStart }, leading) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
|
-
groupStart && /* @__PURE__ */ jsx("p", { className: `${look === "bold" ? "px-2.5 pb-1 text-xs font-semibold capitalize text-tone-400" : "px-2 pb-1 text-[10px] font-bold uppercase tracking-[0.16em] text-tone-400"} ${groupStart === "later" ? "pt-3" : ""}`, children: item.group }),
|
|
71
|
+
groupStart && /* @__PURE__ */ jsx("p", { className: `${look === "bold" ? "px-2.5 pb-1 text-xs font-semibold capitalize text-tone-400" : "px-2 pb-1 text-[length:max(10px,var(--okjt-min-text,0px))] font-bold uppercase tracking-[0.16em] text-tone-400"} ${groupStart === "later" ? "pt-3" : ""}`, children: item.group }),
|
|
72
72
|
/* @__PURE__ */ jsx(
|
|
73
73
|
ItemRow,
|
|
74
74
|
{
|
|
@@ -93,7 +93,7 @@ function BoldStatCard({ icon, label, value, trend, hint, onClick, active = false
|
|
|
93
93
|
{
|
|
94
94
|
icon: up ? "trend-up" : down ? "trend-down" : "trend-flat",
|
|
95
95
|
fallback: up ? TrendingUp : down ? TrendingDown : Minus,
|
|
96
|
-
className: `${trendColor} text-[10px]`
|
|
96
|
+
className: `${trendColor} text-[length:max(10px,var(--okjt-min-text,0px))]`
|
|
97
97
|
}
|
|
98
98
|
),
|
|
99
99
|
/* @__PURE__ */ jsxs("span", { className: `text-xs font-medium ${trendColor}`, children: [
|
|
@@ -60,7 +60,7 @@ function AdminToolbarFilters({ filters }) {
|
|
|
60
60
|
children: [
|
|
61
61
|
/* @__PURE__ */ jsx(SlidersHorizontal, { className: "w-4 h-4" }),
|
|
62
62
|
/* @__PURE__ */ jsx("span", { className: "hidden sm:inline max-w-[10rem] truncate", children: buttonLabel }),
|
|
63
|
-
activeCount > 0 && /* @__PURE__ */ jsx("span", { className: "min-w-5 h-5 px-1 rounded-full bg-accent text-white text-[10px] font-bold flex items-center justify-center", children: activeCount })
|
|
63
|
+
activeCount > 0 && /* @__PURE__ */ jsx("span", { className: "min-w-5 h-5 px-1 rounded-full bg-accent text-white text-[length:max(10px,var(--okjt-min-text,0px))] font-bold flex items-center justify-center", children: activeCount })
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
),
|
|
@@ -76,7 +76,7 @@ function AdminToolbarFilters({ filters }) {
|
|
|
76
76
|
className: "absolute bottom-full left-0 mb-3 w-[min(20rem,calc(100vw-2rem))] max-h-[60vh] overflow-y-auto bg-surface rounded-2xl shadow-2xl border border-tone-100 p-4 space-y-4 text-left",
|
|
77
77
|
children: [
|
|
78
78
|
groups.map((group) => /* @__PURE__ */ jsxs("div", { children: [
|
|
79
|
-
/* @__PURE__ */ jsx("p", { className: "text-[11px] font-semibold uppercase tracking-wider text-tone-500 mb-2", children: group.label || "Show" }),
|
|
79
|
+
/* @__PURE__ */ jsx("p", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] font-semibold uppercase tracking-wider text-tone-500 mb-2", children: group.label || "Show" }),
|
|
80
80
|
/* @__PURE__ */ jsx(
|
|
81
81
|
SegmentedControl,
|
|
82
82
|
{
|
|
@@ -100,7 +100,7 @@ function AdminToolbarFilters({ filters }) {
|
|
|
100
100
|
)
|
|
101
101
|
] }, group.id)),
|
|
102
102
|
sort && /* @__PURE__ */ jsxs("div", { children: [
|
|
103
|
-
/* @__PURE__ */ jsx("p", { className: "text-[11px] font-semibold uppercase tracking-wider text-tone-500 mb-2", children: sort.label || "Sort by" }),
|
|
103
|
+
/* @__PURE__ */ jsx("p", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] font-semibold uppercase tracking-wider text-tone-500 mb-2", children: sort.label || "Sort by" }),
|
|
104
104
|
/* @__PURE__ */ jsx(
|
|
105
105
|
"select",
|
|
106
106
|
{
|
|
@@ -114,7 +114,7 @@ function AdminToolbarFilters({ filters }) {
|
|
|
114
114
|
] }),
|
|
115
115
|
filters.extra && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: filters.extra }),
|
|
116
116
|
views && /* @__PURE__ */ jsxs("div", { children: [
|
|
117
|
-
/* @__PURE__ */ jsx("p", { className: "text-[11px] font-semibold uppercase tracking-wider text-tone-500 mb-2", children: "Saved views" }),
|
|
117
|
+
/* @__PURE__ */ jsx("p", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] font-semibold uppercase tracking-wider text-tone-500 mb-2", children: "Saved views" }),
|
|
118
118
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1.5", children: [
|
|
119
119
|
views.items.map((view2) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center rounded-lg bg-tone-50 text-sm text-tone-700", children: [
|
|
120
120
|
/* @__PURE__ */ jsxs("button", { type: "button", onClick: () => {
|
package/dist/AdminTutorial.js
CHANGED
|
@@ -203,7 +203,7 @@ function AdminTutorial({ steps: allSteps, onComplete, isRestarted = false, open,
|
|
|
203
203
|
/* @__PURE__ */ jsx("div", { className: "p-6 pb-0", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start mb-4", children: [
|
|
204
204
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
205
205
|
/* @__PURE__ */ jsx("div", { className: "w-10 h-10 rounded-xl bg-accent/10 flex items-center justify-center", children: currentStep === steps.length - 1 ? /* @__PURE__ */ jsx(Trophy, { className: "w-5 h-5 text-accent" }) : /* @__PURE__ */ jsx("span", { className: "text-accent font-bold text-base", children: currentStep + 1 }) }),
|
|
206
|
-
currentStep === 0 && /* @__PURE__ */ jsx("span", { className: "bg-accent/10 text-accent text-[10px] uppercase tracking-wider font-bold px-2 py-1 rounded-md", children: "New Feature" })
|
|
206
|
+
currentStep === 0 && /* @__PURE__ */ jsx("span", { className: "bg-accent/10 text-accent text-[length:max(10px,var(--okjt-min-text,0px))] uppercase tracking-wider font-bold px-2 py-1 rounded-md", children: "New Feature" })
|
|
207
207
|
] }),
|
|
208
208
|
/* @__PURE__ */ jsx(
|
|
209
209
|
"button",
|
package/dist/BoldToolbar.js
CHANGED
|
@@ -74,7 +74,7 @@ function FiltersMenu({ filters, search, storageKey }) {
|
|
|
74
74
|
children: [
|
|
75
75
|
/* @__PURE__ */ jsx(Named, { name: "filters", fallback: SlidersHorizontal }),
|
|
76
76
|
/* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Filters" }),
|
|
77
|
-
active > 0 && /* @__PURE__ */ jsx("span", { className: "min-w-[1.25rem] h-5 px-1 rounded-full bg-accent text-[11px] leading-5 text-white text-center", children: active })
|
|
77
|
+
active > 0 && /* @__PURE__ */ jsx("span", { className: "min-w-[1.25rem] h-5 px-1 rounded-full bg-accent text-[length:max(11px,var(--okjt-min-text,0px))] leading-5 text-white text-center", children: active })
|
|
78
78
|
]
|
|
79
79
|
}
|
|
80
80
|
),
|
|
@@ -210,7 +210,7 @@ function BoldToolbar({ search, filters = [], view, actions = [], selection, chil
|
|
|
210
210
|
className: "w-40 sm:w-56 sm:focus:w-72 rounded-xl border border-contrast/10 bg-contrast/5 py-2 pl-9 pr-9 text-sm transition-all"
|
|
211
211
|
}
|
|
212
212
|
),
|
|
213
|
-
/* @__PURE__ */ jsx("kbd", { className: "pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 hidden sm:block rounded border border-contrast/15 px-1.5 text-[10px] text-soft", children: "/" })
|
|
213
|
+
/* @__PURE__ */ jsx("kbd", { className: "pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 hidden sm:block rounded border border-contrast/15 px-1.5 text-[length:max(10px,var(--okjt-min-text,0px))] text-soft", children: "/" })
|
|
214
214
|
] }),
|
|
215
215
|
filters.length > 0 && /* @__PURE__ */ jsx(FiltersMenu, { filters, search, storageKey }),
|
|
216
216
|
view && view.modes?.length > 1 && /* @__PURE__ */ jsx("div", { className: "flex gap-1 rounded-xl border border-contrast/10 bg-ink-deep/30 p-1", children: view.modes.map((mode) => /* @__PURE__ */ jsx(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { collaboratorColor, initials, useModules } from "./modules.js";
|
|
3
3
|
const SIZES = {
|
|
4
|
-
xs: "w-5 h-5 text-[9px]",
|
|
5
|
-
sm: "w-7 h-7 text-[11px]",
|
|
4
|
+
xs: "w-5 h-5 text-[length:max(9px,var(--okjt-min-text,0px))]",
|
|
5
|
+
sm: "w-7 h-7 text-[length:max(11px,var(--okjt-min-text,0px))]",
|
|
6
6
|
md: "w-9 h-9 text-xs"
|
|
7
7
|
};
|
|
8
8
|
function CollaboratorAvatar({ person, size = "sm", className = "" }) {
|
|
@@ -41,7 +41,7 @@ const DEFAULT_SHELL = {
|
|
|
41
41
|
logoBoxClass: "p-4",
|
|
42
42
|
logoClass: "h-10 w-auto",
|
|
43
43
|
railLogoClass: "h-9 w-12 object-contain",
|
|
44
|
-
navTitleClass: "px-3 mb-1 text-[10px] font-bold uppercase tracking-[0.18em] text-white/50",
|
|
44
|
+
navTitleClass: "px-3 mb-1 text-[length:max(10px,var(--okjt-min-text,0px))] font-bold uppercase tracking-[0.18em] text-white/50",
|
|
45
45
|
navItemClass: "px-3 py-2 rounded-lg",
|
|
46
46
|
navActiveClass: "text-accent-dark bg-white shadow-sm",
|
|
47
47
|
navIdleClass: "text-white/75 hover:text-accent-dark hover:bg-white",
|
package/dist/DashboardSidebar.js
CHANGED
|
@@ -78,7 +78,7 @@ function DashboardSidebar({ isOpen, onClose, collapsed = false }) {
|
|
|
78
78
|
!rail && /* @__PURE__ */ jsx("span", { className: shell.navLabelClass, children: item.label }),
|
|
79
79
|
!rail && (here.length > 0 || newCount > 0) && /* @__PURE__ */ jsxs("span", { className: "ml-auto flex items-center gap-1.5 shrink-0", "aria-hidden": "true", children: [
|
|
80
80
|
/* @__PURE__ */ jsx(CollaboratorAvatars, { people: here, size: "xs", max: 2 }),
|
|
81
|
-
newCount > 0 && /* @__PURE__ */ jsx("span", { className: `min-w-[1.25rem] h-5 px-1.5 rounded-full ${shell.badgeClass} text-[10px] font-bold flex items-center justify-center`, children: newCount > 99 ? "99+" : newCount })
|
|
81
|
+
newCount > 0 && /* @__PURE__ */ jsx("span", { className: `min-w-[1.25rem] h-5 px-1.5 rounded-full ${shell.badgeClass} text-[length:max(10px,var(--okjt-min-text,0px))] font-bold flex items-center justify-center`, children: newCount > 99 ? "99+" : newCount })
|
|
82
82
|
] }),
|
|
83
83
|
isActive && !rail && /* @__PURE__ */ jsx(
|
|
84
84
|
motion.div,
|
package/dist/ShareModal.js
CHANGED
|
@@ -196,7 +196,7 @@ function ShareModal({ isOpen, onClose }) {
|
|
|
196
196
|
className: selectClass,
|
|
197
197
|
children: ROLES.map((r) => /* @__PURE__ */ jsx("option", { value: r.value, children: r.label }, r.value))
|
|
198
198
|
}
|
|
199
|
-
) : /* @__PURE__ */ jsx("span", { className: "px-2 py-0.5 rounded-full bg-tone-100 text-[11px] font-medium text-tone-600", children: roleLabel(person.role) }),
|
|
199
|
+
) : /* @__PURE__ */ jsx("span", { className: "px-2 py-0.5 rounded-full bg-tone-100 text-[length:max(11px,var(--okjt-min-text,0px))] font-medium text-tone-600", children: roleLabel(person.role) }),
|
|
200
200
|
isOwner && person.pending && /* @__PURE__ */ jsx(
|
|
201
201
|
Button,
|
|
202
202
|
{
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef } from "react";
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
function TwoPaneDialog({ open, title, subtitle, sections, active, onSelect, onClose, footer, children }) {
|
|
5
|
+
const titleId = useId();
|
|
6
|
+
const panelRef = useRef(null);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!open) return void 0;
|
|
9
|
+
const onKey = (e) => {
|
|
10
|
+
if (e.key === "Escape") onClose();
|
|
11
|
+
};
|
|
12
|
+
document.addEventListener("keydown", onKey);
|
|
13
|
+
const previous = document.activeElement;
|
|
14
|
+
panelRef.current?.focus();
|
|
15
|
+
return () => {
|
|
16
|
+
document.removeEventListener("keydown", onKey);
|
|
17
|
+
previous?.focus?.();
|
|
18
|
+
};
|
|
19
|
+
}, [open, onClose]);
|
|
20
|
+
if (!open) return null;
|
|
21
|
+
return /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-[150] flex items-stretch justify-center bg-ink/40 sm:items-center sm:p-6", children: /* @__PURE__ */ jsxs(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
ref: panelRef,
|
|
25
|
+
tabIndex: -1,
|
|
26
|
+
role: "dialog",
|
|
27
|
+
"aria-modal": "true",
|
|
28
|
+
"aria-labelledby": titleId,
|
|
29
|
+
className: "flex h-full w-full flex-col overflow-hidden bg-surface shadow-xl outline-none sm:h-[min(44rem,90vh)] sm:max-w-5xl sm:rounded-2xl",
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsxs("header", { className: "flex items-start justify-between gap-4 border-b border-line px-5 py-4", children: [
|
|
32
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
33
|
+
/* @__PURE__ */ jsx("h2", { id: titleId, className: "truncate !font-sans !text-lg !font-semibold !text-ink", children: title }),
|
|
34
|
+
subtitle && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-sm text-tone-500", children: subtitle })
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, className: "rounded-full p-2 text-tone-500 hover:bg-tint", "aria-label": "Close", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col sm:flex-row", children: [
|
|
39
|
+
/* @__PURE__ */ jsx("nav", { "aria-label": "Sections", className: "shrink-0 border-b border-line bg-paper sm:w-56 sm:border-b-0 sm:border-r", children: /* @__PURE__ */ jsx("ol", { className: "flex gap-1 overflow-x-auto p-2 sm:flex-col sm:p-3", children: sections.map((s, i) => {
|
|
40
|
+
const on = s.id === active;
|
|
41
|
+
return /* @__PURE__ */ jsx("li", { className: "shrink-0", children: /* @__PURE__ */ jsxs(
|
|
42
|
+
"button",
|
|
43
|
+
{
|
|
44
|
+
type: "button",
|
|
45
|
+
onClick: () => onSelect(s.id),
|
|
46
|
+
"aria-current": on ? "step" : void 0,
|
|
47
|
+
className: `flex w-full items-start gap-3 rounded-xl px-3 py-2 text-left transition-colors ${on ? "bg-ink text-white" : "text-body hover:bg-tint"}`,
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsx("span", { className: `mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-full text-[length:max(11px,var(--okjt-min-text,0px))] font-semibold ${on ? "bg-white/20" : s.done ? "bg-positive text-white" : "bg-line text-soft"}`, children: s.done && !on ? "\u2713" : i + 1 }),
|
|
50
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
|
|
51
|
+
/* @__PURE__ */ jsx("span", { className: "block text-sm font-semibold", children: s.label }),
|
|
52
|
+
s.hint && /* @__PURE__ */ jsx("span", { className: `hidden text-xs sm:block ${on ? "text-white/70" : "text-tone-500"}`, children: s.hint })
|
|
53
|
+
] })
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
) }, s.id);
|
|
57
|
+
}) }) }),
|
|
58
|
+
/* @__PURE__ */ jsx("section", { className: "min-h-0 flex-1 overflow-y-auto p-5", children })
|
|
59
|
+
] }),
|
|
60
|
+
footer && /* @__PURE__ */ jsx("footer", { className: "flex flex-wrap items-center justify-end gap-2 border-t border-line px-5 py-3", children: footer })
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
) });
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
TwoPaneDialog as default
|
|
67
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { ArrowLeft, ArrowRight, Save } from "lucide-react";
|
|
4
|
+
import { Button } from "@okjt/ui";
|
|
5
|
+
import TwoPaneDialog from "./TwoPaneDialog.js";
|
|
6
|
+
const CHECK = "check";
|
|
7
|
+
function TwoPaneForm({
|
|
8
|
+
open,
|
|
9
|
+
title,
|
|
10
|
+
subtitle,
|
|
11
|
+
sections,
|
|
12
|
+
initial,
|
|
13
|
+
validate = () => ({}),
|
|
14
|
+
onClose,
|
|
15
|
+
onSubmit,
|
|
16
|
+
submitLabel = "Save",
|
|
17
|
+
draftKey = null
|
|
18
|
+
}) {
|
|
19
|
+
const [values, setValues] = useState(initial);
|
|
20
|
+
const [touched, setTouched] = useState({});
|
|
21
|
+
const [active, setActive] = useState(sections[0]?.id);
|
|
22
|
+
const [saving, setSaving] = useState(false);
|
|
23
|
+
const [restored, setRestored] = useState(false);
|
|
24
|
+
const [visited, setVisited] = useState(() => /* @__PURE__ */ new Set());
|
|
25
|
+
const opened = useRef(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!open) {
|
|
28
|
+
opened.current = false;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (opened.current) return;
|
|
32
|
+
opened.current = true;
|
|
33
|
+
let draft = null;
|
|
34
|
+
try {
|
|
35
|
+
draft = draftKey ? JSON.parse(localStorage.getItem(`draft:${draftKey}`) || "null") : null;
|
|
36
|
+
} catch {
|
|
37
|
+
draft = null;
|
|
38
|
+
}
|
|
39
|
+
setValues(draft ? { ...initial, ...draft } : initial);
|
|
40
|
+
setRestored(!!draft);
|
|
41
|
+
setTouched({});
|
|
42
|
+
setVisited(/* @__PURE__ */ new Set());
|
|
43
|
+
setActive(sections[0]?.id);
|
|
44
|
+
}, [open]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!open || !draftKey || !opened.current) return;
|
|
47
|
+
try {
|
|
48
|
+
localStorage.setItem(`draft:${draftKey}`, JSON.stringify(values));
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
}, [values, open, draftKey]);
|
|
52
|
+
const errors = useMemo(() => Object.fromEntries(Object.entries(validate(values) || {}).filter(([, m]) => m)), [values, validate]);
|
|
53
|
+
const sectionOf = (name) => sections.find((s) => s.fields?.includes(name))?.id;
|
|
54
|
+
const sectionErrors = (s) => (s.fields || []).filter((f) => errors[f]);
|
|
55
|
+
if (!open) return null;
|
|
56
|
+
const clearDraft = () => {
|
|
57
|
+
if (draftKey) try {
|
|
58
|
+
localStorage.removeItem(`draft:${draftKey}`);
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const set = (name) => (e) => setValues((v) => ({ ...v, [name]: e?.target ? e.target.type === "checkbox" ? e.target.checked : e.target.value : e }));
|
|
63
|
+
const field = (name) => ({ name, value: values[name] ?? "", onChange: set(name) });
|
|
64
|
+
const error = (name) => touched[name] ? errors[name] : null;
|
|
65
|
+
const onBlur = (e) => {
|
|
66
|
+
if (e.target.name) setTouched((t) => ({ ...t, [e.target.name]: true }));
|
|
67
|
+
};
|
|
68
|
+
const go = (id) => {
|
|
69
|
+
setVisited((v) => new Set(v).add(active));
|
|
70
|
+
setActive(id);
|
|
71
|
+
};
|
|
72
|
+
const all = [...sections, { id: CHECK, label: "Check details", hint: Object.keys(errors).length ? `${Object.keys(errors).length} to fix` : "Ready to save" }];
|
|
73
|
+
const index = all.findIndex((s) => s.id === active);
|
|
74
|
+
const current = sections.find((s) => s.id === active);
|
|
75
|
+
const submit = async () => {
|
|
76
|
+
if (Object.keys(errors).length) {
|
|
77
|
+
setTouched(Object.fromEntries(Object.keys(errors).map((k) => [k, true])));
|
|
78
|
+
go(CHECK);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setSaving(true);
|
|
82
|
+
try {
|
|
83
|
+
await onSubmit(values);
|
|
84
|
+
clearDraft();
|
|
85
|
+
onClose();
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
setSaving(false);
|
|
89
|
+
};
|
|
90
|
+
const discard = () => {
|
|
91
|
+
clearDraft();
|
|
92
|
+
onClose();
|
|
93
|
+
};
|
|
94
|
+
return /* @__PURE__ */ jsx(
|
|
95
|
+
TwoPaneDialog,
|
|
96
|
+
{
|
|
97
|
+
open: true,
|
|
98
|
+
title,
|
|
99
|
+
subtitle: restored ? "We kept what you\u2019d typed last time." : subtitle,
|
|
100
|
+
sections: all.map((s) => ({
|
|
101
|
+
id: s.id,
|
|
102
|
+
label: s.label,
|
|
103
|
+
hint: s.id === CHECK ? s.hint : sectionErrors(s).length && sectionErrors(s).some((f) => touched[f]) ? "Something to fix" : s.hint,
|
|
104
|
+
done: s.id !== CHECK && visited.has(s.id) && !sectionErrors(s).length
|
|
105
|
+
})),
|
|
106
|
+
active,
|
|
107
|
+
onSelect: go,
|
|
108
|
+
onClose,
|
|
109
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
110
|
+
draftKey && restored && /* @__PURE__ */ jsx(Button, { onClick: discard, children: "Discard draft" }),
|
|
111
|
+
index > 0 && /* @__PURE__ */ jsx(Button, { icon: ArrowLeft, onClick: () => go(all[index - 1].id), children: "Back" }),
|
|
112
|
+
active !== CHECK && /* @__PURE__ */ jsx(Button, { icon: ArrowRight, onClick: () => go(all[index + 1].id), children: "Next" }),
|
|
113
|
+
/* @__PURE__ */ jsx(Button, { edit: true, variant: "secondary", icon: Save, loading: saving, onClick: submit, children: submitLabel })
|
|
114
|
+
] }),
|
|
115
|
+
children: /* @__PURE__ */ jsxs("form", { onBlur, onSubmit: (e) => {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
submit();
|
|
118
|
+
}, noValidate: true, children: [
|
|
119
|
+
current && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
120
|
+
current.intro && /* @__PURE__ */ jsx("p", { className: "text-sm text-tone-500", children: current.intro }),
|
|
121
|
+
current.render({ values, set, field, error, setValues })
|
|
122
|
+
] }),
|
|
123
|
+
active === CHECK && /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
|
|
124
|
+
Object.keys(errors).length > 0 && /* @__PURE__ */ jsxs("div", { role: "alert", className: "rounded-xl border border-amber-200 bg-amber-50 p-3 text-sm text-amber-900", children: [
|
|
125
|
+
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Before saving:" }),
|
|
126
|
+
/* @__PURE__ */ jsx("ul", { className: "mt-1 space-y-1", children: Object.entries(errors).map(([name, message]) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", { type: "button", className: "underline", onClick: () => go(sectionOf(name) || sections[0].id), children: message }) }, name)) })
|
|
127
|
+
] }),
|
|
128
|
+
sections.filter((s) => s.summary).map((s) => {
|
|
129
|
+
const rows = s.summary(values).filter(([, v]) => v !== null && v !== void 0 && v !== "");
|
|
130
|
+
return /* @__PURE__ */ jsxs("section", { children: [
|
|
131
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
132
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-ink", children: s.label }),
|
|
133
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "text-sm text-accent hover:underline", onClick: () => go(s.id), children: "Change" })
|
|
134
|
+
] }),
|
|
135
|
+
rows.length ? /* @__PURE__ */ jsx("dl", { className: "mt-1 grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[10rem_1fr]", children: rows.map(([label, value]) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
|
|
136
|
+
/* @__PURE__ */ jsx("dt", { className: "text-tone-500", children: label }),
|
|
137
|
+
/* @__PURE__ */ jsx("dd", { className: "text-body", children: value })
|
|
138
|
+
] }, label)) }) : /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-tone-500", children: "Nothing filled in." })
|
|
139
|
+
] }, s.id);
|
|
140
|
+
})
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ jsx("button", { type: "submit", className: "hidden", "aria-hidden": "true", tabIndex: -1 })
|
|
143
|
+
] })
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
function FieldError({ message }) {
|
|
148
|
+
if (!message) return null;
|
|
149
|
+
return /* @__PURE__ */ jsx("p", { role: "alert", className: "-mt-2 text-xs text-amber-800", children: message });
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
FieldError,
|
|
153
|
+
TwoPaneForm as default
|
|
154
|
+
};
|
|
@@ -38,13 +38,13 @@ function Entry({ revision, batchSize, showModule, onRestore, restoring, canResto
|
|
|
38
38
|
" ",
|
|
39
39
|
/* @__PURE__ */ jsx("span", { className: "font-medium text-tone-900", children: revision.subject_label || revision.subject_type })
|
|
40
40
|
] }),
|
|
41
|
-
/* @__PURE__ */ jsxs("p", { className: "text-[11px] text-tone-500 flex flex-wrap gap-x-2", children: [
|
|
41
|
+
/* @__PURE__ */ jsxs("p", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] text-tone-500 flex flex-wrap gap-x-2", children: [
|
|
42
42
|
/* @__PURE__ */ jsx("span", { title: format(when, "PPpp"), children: formatDistanceToNow(when, { addSuffix: true }) }),
|
|
43
43
|
showModule && /* @__PURE__ */ jsx("span", { className: "px-1.5 rounded bg-tone-100 text-tone-600", children: moduleLabel })
|
|
44
44
|
] }),
|
|
45
45
|
revision.changes?.length > 0 && /* @__PURE__ */ jsxs("ul", { className: "space-y-0.5 pt-0.5", children: [
|
|
46
46
|
revision.changes.slice(0, 4).map((change) => /* @__PURE__ */ jsx(Change, { change }, change.field)),
|
|
47
|
-
revision.changes.length > 4 && /* @__PURE__ */ jsxs("li", { className: "text-[11px] text-tone-400", children: [
|
|
47
|
+
revision.changes.length > 4 && /* @__PURE__ */ jsxs("li", { className: "text-[length:max(11px,var(--okjt-min-text,0px))] text-tone-400", children: [
|
|
48
48
|
"+",
|
|
49
49
|
revision.changes.length - 4,
|
|
50
50
|
" more fields"
|
|
@@ -147,7 +147,7 @@ function VersionHistoryDrawer({ module, onClose, onRestored }) {
|
|
|
147
147
|
const header = day !== lastDay ? day : null;
|
|
148
148
|
lastDay = day;
|
|
149
149
|
return /* @__PURE__ */ jsxs("li", { children: [
|
|
150
|
-
header && /* @__PURE__ */ jsx("h3", { className: "sticky top-0 z-10 bg-surface/95 backdrop-blur pt-3 pb-1 text-[11px] font-bold uppercase tracking-wider text-tone-500", children: header }),
|
|
150
|
+
header && /* @__PURE__ */ jsx("h3", { className: "sticky top-0 z-10 bg-surface/95 backdrop-blur pt-3 pb-1 text-[length:max(11px,var(--okjt-min-text,0px))] font-bold uppercase tracking-wider text-tone-500", children: header }),
|
|
151
151
|
/* @__PURE__ */ jsx("ul", { className: "divide-y divide-tone-100", children: /* @__PURE__ */ jsx(
|
|
152
152
|
Entry,
|
|
153
153
|
{
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,9 @@ import { default as default44 } from "./ConfirmPasswordPage.js";
|
|
|
61
61
|
import { default as default45 } from "./TwoFactorForm.js";
|
|
62
62
|
import { default as default46 } from "./AcceptInvitePage.js";
|
|
63
63
|
import { default as default47 } from "./AccountMenu.js";
|
|
64
|
+
import { default as default48 } from "./TwoPaneDialog.js";
|
|
65
|
+
import { default as default49, FieldError } from "./TwoPaneForm.js";
|
|
66
|
+
import { default as default50 } from "./useGlassToolbar.js";
|
|
64
67
|
export {
|
|
65
68
|
default46 as AcceptInvitePage,
|
|
66
69
|
default47 as AccountMenu,
|
|
@@ -100,6 +103,7 @@ export {
|
|
|
100
103
|
default15 as DeleteButton,
|
|
101
104
|
default14 as EditableFieldset,
|
|
102
105
|
default17 as EmptyState,
|
|
106
|
+
FieldError,
|
|
103
107
|
default42 as ForgotPasswordPage,
|
|
104
108
|
default36 as GoogleButton,
|
|
105
109
|
default40 as GoogleCallbackPage,
|
|
@@ -116,6 +120,8 @@ export {
|
|
|
116
120
|
default5 as StatCard,
|
|
117
121
|
default16 as ToggleButton,
|
|
118
122
|
default45 as TwoFactorForm,
|
|
123
|
+
default48 as TwoPaneDialog,
|
|
124
|
+
default49 as TwoPaneForm,
|
|
119
125
|
default20 as UnsavedChangesStatus,
|
|
120
126
|
default41 as VerifyEmailPage,
|
|
121
127
|
default30 as VersionHistoryDrawer,
|
|
@@ -141,6 +147,7 @@ export {
|
|
|
141
147
|
default23 as useCrudHandlers,
|
|
142
148
|
useDashboard,
|
|
143
149
|
default25 as useFilteredItems,
|
|
150
|
+
default50 as useGlassToolbar,
|
|
144
151
|
useGuardedNavigate,
|
|
145
152
|
useHasUnsavedChanges,
|
|
146
153
|
useModules,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @okjt/dashboard/toolbar-glass.css: on phones, the floating toolbar becomes
|
|
3
|
+
* a glass bar at the bottom, lifted from Naoa. Import it once to turn it on:
|
|
4
|
+
*
|
|
5
|
+
* import '@okjt/dashboard/toolbar-glass.css';
|
|
6
|
+
*
|
|
7
|
+
* and call useGlassToolbar() in the dashboard, which tucks the bar away while
|
|
8
|
+
* the page scrolls down and switches it to solid on a device that drops
|
|
9
|
+
* frames with the blur on (html.toolbar-tucked, html.toolbar-solid). Solid
|
|
10
|
+
* too when the person asks for less transparency or the browser can't blur.
|
|
11
|
+
*
|
|
12
|
+
* Colours (defaults are Naoa's warm white; keep text contrast AA over your
|
|
13
|
+
* darkest content):
|
|
14
|
+
* --okjt-toolbar-glass-bg the glass rgba(255, 249, 245, 0.88)
|
|
15
|
+
* --okjt-toolbar-solid-bg the solid fallback #FFF9F5
|
|
16
|
+
* --okjt-toolbar-glass-border rgba(255, 255, 255, 0.6)
|
|
17
|
+
* --okjt-toolbar-glass-shadow 0 10px 30px rgba(31, 24, 19, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.7)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/* Phones: the toolbar packs its controls tighter, so it covers less of the
|
|
21
|
+
page. Menus that open from it keep their normal sizes. */
|
|
22
|
+
@media (max-width: 639.98px) {
|
|
23
|
+
.admin-floating-toolbar :is(button, select):not(:where([class*="absolute"] *)) {
|
|
24
|
+
padding: 0.5rem 0.6rem;
|
|
25
|
+
min-height: 2.25rem;
|
|
26
|
+
font-size: 0.75rem;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media (max-width: 639.98px) {
|
|
31
|
+
.admin-theme .admin-floating-toolbar {
|
|
32
|
+
background: var(--okjt-toolbar-glass-bg, rgba(255, 249, 245, 0.88)) !important;
|
|
33
|
+
-webkit-backdrop-filter: blur(18px) saturate(170%);
|
|
34
|
+
backdrop-filter: blur(18px) saturate(170%);
|
|
35
|
+
border: 1px solid var(--okjt-toolbar-glass-border, rgba(255, 255, 255, 0.6));
|
|
36
|
+
box-shadow: var(--okjt-toolbar-glass-shadow, 0 10px 30px rgba(31, 24, 19, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.7)) !important;
|
|
37
|
+
border-radius: 1.5rem;
|
|
38
|
+
}
|
|
39
|
+
.admin-theme .admin-floating-toolbar :is(button, select) { min-height: 2.75rem; } /* 44px touch targets */
|
|
40
|
+
.admin-theme .admin-floating-toolbar [class*="bottom-full"] button { min-height: 2.75rem; font-size: 0.875rem; }
|
|
41
|
+
/* The wrapper the kit positions (its first child is the bar). `translate`,
|
|
42
|
+
not `transform`: framer-motion owns the wrapper's transform. */
|
|
43
|
+
.admin-theme div:has(> .admin-floating-toolbar) {
|
|
44
|
+
transition: translate 420ms cubic-bezier(0.34, 1.4, 0.64, 1), opacity 240ms ease;
|
|
45
|
+
}
|
|
46
|
+
html.toolbar-tucked div:has(> .admin-floating-toolbar) {
|
|
47
|
+
translate: -50% calc(100% + 1.5rem) !important;
|
|
48
|
+
opacity: 0 !important; /* framer-motion sets an inline opacity */
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
}
|
|
51
|
+
html.toolbar-solid .admin-floating-toolbar {
|
|
52
|
+
background: var(--okjt-toolbar-solid-bg, #FFF9F5) !important;
|
|
53
|
+
-webkit-backdrop-filter: none;
|
|
54
|
+
backdrop-filter: none;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
@media (max-width: 639.98px) and (prefers-reduced-transparency: reduce) {
|
|
58
|
+
.admin-theme .admin-floating-toolbar {
|
|
59
|
+
background: var(--okjt-toolbar-solid-bg, #FFF9F5) !important;
|
|
60
|
+
-webkit-backdrop-filter: none;
|
|
61
|
+
backdrop-filter: none;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
|
65
|
+
.admin-theme .admin-floating-toolbar { background: var(--okjt-toolbar-solid-bg, #FFF9F5) !important; }
|
|
66
|
+
}
|
|
67
|
+
/* Reduced motion: the kit's MotionConfig stops the springs; make the tuck
|
|
68
|
+
instant in your own reduced-motion rule if you have one. */
|
package/dist/useAdminAction.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { useCallback, useMemo, useRef, useState } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { QueryClientContext } from "@tanstack/react-query";
|
|
3
3
|
import { toast } from "react-hot-toast";
|
|
4
4
|
import { usePermissions, confirmAction, notifyError, notifySuccess } from "@okjt/ui";
|
|
5
|
-
import { useDashboard } from "./DashboardProvider.js";
|
|
5
|
+
import { useComponentDefaults, useDashboard } from "./DashboardProvider.js";
|
|
6
6
|
const resolve = (value, ...args) => typeof value === "function" ? value(...args) : value;
|
|
7
7
|
const deniedByRole = (err) => err?.response?.status === 403 && err.response.data?.reason === "role";
|
|
8
8
|
function useAdminAction(fn, options = {}) {
|
|
9
9
|
const { canEdit, isOwner } = usePermissions();
|
|
10
10
|
const allowed = options.role === "owner" ? isOwner : canEdit;
|
|
11
|
-
const queryClient =
|
|
11
|
+
const queryClient = useContext(QueryClientContext);
|
|
12
|
+
const defaults = useComponentDefaults("AdminAction", {});
|
|
12
13
|
const refreshCollaboration = useDashboard().useAfterChange();
|
|
13
14
|
const [pendingKeys, setPendingKeys] = useState(() => /* @__PURE__ */ new Set());
|
|
14
15
|
const latest = useRef({ fn, options });
|
|
15
|
-
latest.current = { fn, options };
|
|
16
|
+
latest.current = { fn, options: { ...defaults, ...options } };
|
|
16
17
|
const run = useCallback(async (...args) => {
|
|
17
18
|
const { fn: write, options: opts } = latest.current;
|
|
18
19
|
if (!allowed) {
|
|
@@ -27,10 +28,12 @@ function useAdminAction(fn, options = {}) {
|
|
|
27
28
|
const result = await write(...args);
|
|
28
29
|
const message = resolve(opts.success, result, ...args);
|
|
29
30
|
if (message) notifySuccess(message);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (queryClient) {
|
|
32
|
+
await Promise.all([
|
|
33
|
+
...(opts.invalidate || []).map((queryKey) => queryClient.invalidateQueries({ queryKey })),
|
|
34
|
+
...opts.refreshHistory === false ? [] : [queryClient.invalidateQueries({ queryKey: ["revisions"] })]
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
34
37
|
refreshCollaboration?.();
|
|
35
38
|
opts.onSuccess?.(result, ...args);
|
|
36
39
|
return result;
|
package/dist/useFilteredItems.js
CHANGED
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
function useFilteredItems(items,
|
|
2
|
+
function useFilteredItems(items, queryOrOptions, legacyFilterFn) {
|
|
3
|
+
const options = queryOrOptions && typeof queryOrOptions === "object" ? queryOrOptions : { searchQuery: queryOrOptions, filterFn: legacyFilterFn };
|
|
4
|
+
const { searchQuery, filterFn, searchFields, where, sortFn } = options;
|
|
5
|
+
const fieldsKey = searchFields ? searchFields.join(",") : "";
|
|
6
|
+
const whereKey = where ? JSON.stringify(where) : "";
|
|
3
7
|
return useMemo(() => {
|
|
4
8
|
if (!items) return [];
|
|
9
|
+
let list = items;
|
|
10
|
+
const conditions = where ? Object.entries(where).filter(([, v]) => v !== void 0 && v !== null && v !== "") : [];
|
|
11
|
+
if (conditions.length) {
|
|
12
|
+
list = list.filter((item) => conditions.every(([field, value]) => String(item?.[field]) === String(value)));
|
|
13
|
+
}
|
|
5
14
|
const searchLower = (searchQuery || "").toLowerCase();
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
if (searchLower) {
|
|
16
|
+
list = list.filter((item) => {
|
|
17
|
+
if (filterFn) return filterFn(item, searchLower);
|
|
18
|
+
if (searchFields) {
|
|
19
|
+
return searchFields.some((field) => {
|
|
20
|
+
const value = item?.[field];
|
|
21
|
+
return value !== void 0 && value !== null && String(value).toLowerCase().includes(searchLower);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return Object.values(item).some((val) => {
|
|
25
|
+
if (typeof val === "string") return val.toLowerCase().includes(searchLower);
|
|
26
|
+
if (val && typeof val === "object") return JSON.stringify(val).toLowerCase().includes(searchLower);
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
13
29
|
});
|
|
14
|
-
}
|
|
15
|
-
|
|
30
|
+
}
|
|
31
|
+
if (sortFn) list = [...list].sort(sortFn);
|
|
32
|
+
return list;
|
|
33
|
+
}, [items, searchQuery, filterFn, fieldsKey, whereKey, sortFn]);
|
|
16
34
|
}
|
|
17
35
|
export {
|
|
18
36
|
useFilteredItems as default
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
const PHONE = "(max-width: 639.98px)";
|
|
3
|
+
const PROBE_FRAMES = 45;
|
|
4
|
+
const SLOW_FRAME_MS = 22;
|
|
5
|
+
function useGlassToolbar({ storageKey = "okjt-toolbar-solid" } = {}) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const root = document.documentElement;
|
|
8
|
+
const phone = window.matchMedia?.(PHONE);
|
|
9
|
+
let solid = false;
|
|
10
|
+
try {
|
|
11
|
+
solid = localStorage.getItem(storageKey) === "1";
|
|
12
|
+
} catch {
|
|
13
|
+
}
|
|
14
|
+
root.classList.toggle("toolbar-solid", solid);
|
|
15
|
+
let last = /* @__PURE__ */ new Map();
|
|
16
|
+
let probing = false;
|
|
17
|
+
let probed = solid;
|
|
18
|
+
const probe = () => {
|
|
19
|
+
if (probed || probing || !phone?.matches || !CSS.supports?.("backdrop-filter", "blur(1px)")) return;
|
|
20
|
+
probing = true;
|
|
21
|
+
const times = [];
|
|
22
|
+
let prev = performance.now();
|
|
23
|
+
const tick = (now) => {
|
|
24
|
+
times.push(now - prev);
|
|
25
|
+
prev = now;
|
|
26
|
+
if (times.length < PROBE_FRAMES) {
|
|
27
|
+
requestAnimationFrame(tick);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const avg = times.slice(5).reduce((a, b) => a + b, 0) / (times.length - 5);
|
|
31
|
+
probed = true;
|
|
32
|
+
probing = false;
|
|
33
|
+
if (avg > SLOW_FRAME_MS) {
|
|
34
|
+
root.classList.add("toolbar-solid");
|
|
35
|
+
try {
|
|
36
|
+
localStorage.setItem(storageKey, "1");
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
requestAnimationFrame(tick);
|
|
42
|
+
};
|
|
43
|
+
const onScroll = (e) => {
|
|
44
|
+
if (!phone?.matches) {
|
|
45
|
+
root.classList.remove("toolbar-tucked");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const el = e.target === document ? document.scrollingElement : e.target;
|
|
49
|
+
if (!el || typeof el.scrollTop !== "number" || el.closest?.('.admin-floating-toolbar, [role="dialog"]')) return;
|
|
50
|
+
const top = el.scrollTop;
|
|
51
|
+
const delta = top - (last.get(el) ?? top);
|
|
52
|
+
last.set(el, top);
|
|
53
|
+
if (delta > 6 && top > 80) root.classList.add("toolbar-tucked");
|
|
54
|
+
else if (delta < -6 || top <= 80) root.classList.remove("toolbar-tucked");
|
|
55
|
+
probe();
|
|
56
|
+
};
|
|
57
|
+
document.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
58
|
+
return () => {
|
|
59
|
+
document.removeEventListener("scroll", onScroll, { capture: true });
|
|
60
|
+
root.classList.remove("toolbar-tucked", "toolbar-solid");
|
|
61
|
+
last = /* @__PURE__ */ new Map();
|
|
62
|
+
};
|
|
63
|
+
}, [storageKey]);
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
useGlassToolbar as default
|
|
67
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okjt/dashboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Dashboard pages for OKJTech projects: page layout, hero, summary cards, floating toolbar with search and filters, side panel, lists, bulk actions, one way to save, and working together: presence, version history, sharing; the dashboard shell, sign-in pages and account menu",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,20 +10,23 @@
|
|
|
10
10
|
"directory": "packages/dashboard"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
|
-
".": "./dist/index.js"
|
|
13
|
+
".": "./dist/index.js",
|
|
14
|
+
"./toolbar-glass.css": "./dist/toolbar-glass.css"
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
16
17
|
"dist",
|
|
17
18
|
"README.md"
|
|
18
19
|
],
|
|
19
|
-
"sideEffects":
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"*.css"
|
|
22
|
+
],
|
|
20
23
|
"scripts": {
|
|
21
24
|
"build": "node build.mjs",
|
|
22
25
|
"prepack": "node build.mjs",
|
|
23
26
|
"test": "node build.mjs && vitest run"
|
|
24
27
|
},
|
|
25
28
|
"dependencies": {
|
|
26
|
-
"@okjt/ui": "^0.
|
|
29
|
+
"@okjt/ui": "^0.5.0"
|
|
27
30
|
},
|
|
28
31
|
"peerDependencies": {
|
|
29
32
|
"@tanstack/react-query": ">=5",
|