smoodly 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +182 -40
  2. package/bin/smoodly.js +6 -0
  3. package/dist/admin/client-ops.js +1 -0
  4. package/dist/admin/editor/EditorView.js +20 -6
  5. package/dist/admin/editor/InsertPicker.d.ts +14 -0
  6. package/dist/admin/editor/InsertPicker.js +37 -7
  7. package/dist/admin/editor/InspectorFields.js +1 -1
  8. package/dist/admin/editor/Outline.js +2 -2
  9. package/dist/admin/editor/PageSettings.js +1 -1
  10. package/dist/admin/editor/SeoSettings.js +1 -1
  11. package/dist/admin/editor/locale-url.d.ts +7 -4
  12. package/dist/admin/editor/locale-url.js +14 -7
  13. package/dist/admin/editor/usePageLocale.js +9 -1
  14. package/dist/admin/forms/CropEditor.d.ts +4 -2
  15. package/dist/admin/forms/CropEditor.js +6 -3
  16. package/dist/admin/forms/DatePicker.d.ts +9 -0
  17. package/dist/admin/forms/DatePicker.js +133 -0
  18. package/dist/admin/forms/FieldWidget.js +11 -5
  19. package/dist/admin/forms/ImagePreview.d.ts +9 -0
  20. package/dist/admin/forms/ImagePreview.js +11 -0
  21. package/dist/admin/forms/MediaWidget.d.ts +8 -2
  22. package/dist/admin/forms/MediaWidget.js +13 -13
  23. package/dist/admin/forms/RichtextElementCard.js +1 -1
  24. package/dist/admin/forms/RichtextImageCard.js +14 -9
  25. package/dist/admin/forms/date-picker.d.ts +44 -0
  26. package/dist/admin/forms/date-picker.js +117 -0
  27. package/dist/admin/forms/elements-context.d.ts +3 -0
  28. package/dist/admin/forms/elements-context.js +7 -2
  29. package/dist/admin/forms/time-zone-context.d.ts +7 -0
  30. package/dist/admin/forms/time-zone-context.js +15 -0
  31. package/dist/admin/forms/useRichtextEditor.js +10 -1
  32. package/dist/admin/next/bridge.d.ts +2 -1
  33. package/dist/admin/next/bridge.js +35 -5
  34. package/dist/admin/ops-impl.js +4 -0
  35. package/dist/admin/ops.d.ts +9 -0
  36. package/dist/admin/serialize.d.ts +2 -0
  37. package/dist/admin/serialize.js +1 -0
  38. package/dist/admin/shell/AdminApp.js +23 -1
  39. package/dist/admin/shell/EntriesList.js +12 -21
  40. package/dist/admin/shell/EntryForm.js +48 -7
  41. package/dist/admin/shell/GlobalForm.js +22 -2
  42. package/dist/admin/shell/GlobalList.js +4 -18
  43. package/dist/admin/shell/IconRail.js +14 -5
  44. package/dist/admin/shell/InviteModal.js +9 -5
  45. package/dist/admin/shell/ListView.js +2 -2
  46. package/dist/admin/shell/MediaScreen.js +11 -1
  47. package/dist/admin/shell/MembersPage.js +33 -15
  48. package/dist/admin/shell/PageDialogs.d.ts +26 -0
  49. package/dist/admin/shell/PageDialogs.js +38 -0
  50. package/dist/admin/shell/PagesList.js +96 -73
  51. package/dist/admin/shell/RouteLink.js +1 -1
  52. package/dist/admin/shell/SchemaNotice.d.ts +4 -0
  53. package/dist/admin/shell/SchemaNotice.js +4 -0
  54. package/dist/admin/shell/SettingsView.js +11 -26
  55. package/dist/admin/shell/live-url.d.ts +4 -3
  56. package/dist/admin/shell/live-url.js +12 -3
  57. package/dist/admin/shell/locale-memory.d.ts +8 -0
  58. package/dist/admin/shell/locale-memory.js +23 -0
  59. package/dist/admin/shell/members-list.d.ts +2 -0
  60. package/dist/admin/shell/members-list.js +5 -0
  61. package/dist/admin/shell/page-dialogs.d.ts +9 -0
  62. package/dist/admin/shell/page-dialogs.js +19 -0
  63. package/dist/admin/shell/router.d.ts +10 -7
  64. package/dist/admin/shell/router.js +18 -9
  65. package/dist/admin/shell/settings.d.ts +0 -6
  66. package/dist/admin/shell/settings.js +4 -5
  67. package/dist/admin/tree-ops.js +3 -0
  68. package/dist/admin/ui/ActionMenu.js +26 -6
  69. package/dist/admin/ui/Combobox.d.ts +5 -0
  70. package/dist/admin/ui/Combobox.js +1 -1
  71. package/dist/admin/ui/ConfirmDialog.d.ts +8 -0
  72. package/dist/admin/ui/ConfirmDialog.js +30 -0
  73. package/dist/admin/ui/Dialog.d.ts +13 -0
  74. package/dist/admin/ui/Dialog.js +54 -0
  75. package/dist/admin/ui/HistoryModal.d.ts +2 -1
  76. package/dist/admin/ui/HistoryModal.js +7 -2
  77. package/dist/admin/ui/ResizeHandle.js +4 -4
  78. package/dist/admin/ui/confirm.d.ts +35 -0
  79. package/dist/admin/ui/confirm.js +57 -0
  80. package/dist/admin/ui/primitives.d.ts +19 -4
  81. package/dist/admin/ui/primitives.js +11 -5
  82. package/dist/admin/ui/resize.d.ts +7 -4
  83. package/dist/admin/ui/resize.js +7 -4
  84. package/dist/admin/ui/theme.d.ts +1 -1
  85. package/dist/admin/ui/theme.js +368 -203
  86. package/dist/admin/validate.d.ts +4 -0
  87. package/dist/admin/validate.js +28 -0
  88. package/dist/cli/load-collections.d.ts +2 -0
  89. package/dist/cli/load-collections.js +26 -0
  90. package/dist/cli/main.d.ts +13 -0
  91. package/dist/cli/main.js +62 -0
  92. package/dist/cli/migrate.d.ts +23 -0
  93. package/dist/cli/migrate.js +64 -0
  94. package/dist/config.d.ts +4 -0
  95. package/dist/config.js +9 -0
  96. package/dist/fields.d.ts +2 -0
  97. package/dist/fields.js +2 -0
  98. package/dist/index.d.ts +2 -1
  99. package/dist/index.js +2 -1
  100. package/dist/marks.d.ts +3 -0
  101. package/dist/marks.js +3 -0
  102. package/dist/migrations.d.ts +37 -0
  103. package/dist/migrations.js +73 -0
  104. package/dist/schema-version.d.ts +17 -0
  105. package/dist/schema-version.js +32 -0
  106. package/dist/sql-space.js +6 -0
  107. package/dist/sql.js +10 -0
  108. package/dist/store.d.ts +3 -0
  109. package/dist/store.js +4 -0
  110. package/dist/supabase-store.d.ts +3 -0
  111. package/dist/supabase-store.js +23 -0
  112. package/dist/time-zone.d.ts +6 -0
  113. package/dist/time-zone.js +27 -0
  114. package/migrations/20260926120000_smoodly_v1.sql +535 -0
  115. package/package.json +13 -3
@@ -6,10 +6,10 @@ import { navigate } from "./router.js";
6
6
  export function ListView({ title, titleTrailing, actions, notice, columns, rows, empty, sortable }) {
7
7
  const widths = sortable ? ["24px", ...columns.map((c) => c.width)] : columns.map((c) => c.width);
8
8
  const grid = { gridTemplateColumns: widths.join(" ") };
9
- return (_jsxs(_Fragment, { children: [_jsx(TopBar, { left: _jsxs(_Fragment, { children: [_jsx("span", { className: "sm-title", children: title }), titleTrailing] }), right: actions }), notice, _jsx("div", { className: "sm-listwrap", children: _jsxs("div", { className: "sm-table", children: [_jsxs("div", { className: "sm-table__head", style: grid, children: [sortable && _jsx("span", { "aria-hidden": "true" }), columns.map((c) => _jsx("span", { children: c.label }, c.label))] }), _jsxs("div", { className: "sm-table__body", ref: sortable?.hook.containerRef, children: [rows.map((r, i) => {
9
+ return (_jsxs(_Fragment, { children: [_jsx(TopBar, { left: _jsxs(_Fragment, { children: [_jsx("span", { className: "sm-title", children: title }), titleTrailing] }), right: actions }), notice && _jsx("div", { className: "sm-listnotice", children: notice }), _jsx("div", { className: "sm-listwrap", children: _jsxs("div", { className: "sm-table", children: [_jsxs("div", { className: "sm-table__head", style: grid, children: [sortable && _jsx("span", { "aria-hidden": "true" }), columns.map((c) => _jsx("span", { children: c.label }, c.label))] }), _jsxs("div", { className: "sm-table__body", ref: sortable?.hook.containerRef, children: [rows.map((r, i) => {
10
10
  const clickable = Boolean(r.href || r.onClick);
11
11
  const href = r.href;
12
- const go = r.onClick ?? (href ? () => { navigate(href); } : undefined);
12
+ const go = r.onClick ?? (href ? () => { void navigate(href); } : undefined);
13
13
  return (_jsxs("div", { style: { ...grid, ...sortable?.hook.rowStyle(i) }, role: clickable ? "button" : undefined, tabIndex: clickable ? 0 : undefined, className: cx("sm-row", clickable && "sm-row--clickable", sortable?.hook.rowClass(i)), onClick: go, onKeyDown: (e) => { if (go && (e.key === "Enter" || e.key === " ")) {
14
14
  e.preventDefault();
15
15
  go();
@@ -9,6 +9,7 @@ import { useAssets } from "../forms/assets-context.js";
9
9
  import { uploadFile } from "../forms/upload.js";
10
10
  import { MediaGrid } from "../forms/MediaGrid.js";
11
11
  import { Banner, Button, Field, Segmented, TopBar } from "../ui/primitives.js";
12
+ import { confirm } from "../ui/confirm.js";
12
13
  import { RouteLink } from "./RouteLink.js";
13
14
  import { KIND_FILTERS, acceptFor, formatBytes, kindOfFilter, usageLabel } from "./media-list.js";
14
15
  const META = ["title", "alt", "caption", "credit"];
@@ -70,7 +71,16 @@ export function MediaScreen({ initialItems = [], initialSelected = null, initial
70
71
  load();
71
72
  };
72
73
  const remove = async () => {
73
- if (!selected || !window.confirm(`Delete "${selected.title ?? selected.filename}"? This cannot be undone.`))
74
+ if (!selected)
75
+ return;
76
+ const ok = await confirm({
77
+ title: "Delete this file?",
78
+ body: "The file is removed from the media library and from storage. This cannot be undone.",
79
+ confirmLabel: "Delete file",
80
+ destructive: true,
81
+ subject: { name: selected.title ?? selected.filename },
82
+ });
83
+ if (!ok)
74
84
  return;
75
85
  const r = await assets.ops.delete(selected.id);
76
86
  if (!r.ok) {
@@ -2,18 +2,20 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  // packages/smoodly/src/admin/shell/MembersPage.tsx
4
4
  // The Members page (spec 2026-09-25 §7; management §4): the admission
5
- // table with Invite, an in-place role control and Remove — all off when
6
- // the control plane manages the space (the console URL banner stays).
7
- // Own row and the last admin render their controls disabled with the
8
- // guard's reason, so the rule is visible before it is hit.
5
+ // table with Invite, the role as a badge and a row menu with Change role
6
+ // (to the other role, after a confirm) and Remove member (2026-09-26; the
7
+ // in-place pills before) — all off when the control plane manages the
8
+ // space (the console URL banner stays). Own row and the last admin render
9
+ // their menu disabled with the guard's reason, so the rule is visible
10
+ // before it is hit.
9
11
  import { useEffect, useState } from "react";
10
- import { MEMBER_ROLES } from "../../permissions.js";
11
12
  import { ActionMenu } from "../ui/ActionMenu.js";
12
- import { Banner, Button, Segmented, StatusBadge } from "../ui/primitives.js";
13
+ import { Banner, Button, StatusBadge } from "../ui/primitives.js";
14
+ import { confirm } from "../ui/confirm.js";
13
15
  import { ErrorPane } from "./ErrorPane.js";
14
16
  import { InviteModal } from "./InviteModal.js";
15
17
  import { ListView } from "./ListView.js";
16
- import { GUARD_TITLE, memberRows, roleLabel } from "./members-list.js";
18
+ import { GUARD_TITLE, ROLE_DESCRIPTION, memberRows, roleLabel } from "./members-list.js";
17
19
  export function MembersPage({ ops, userId, initial = null }) {
18
20
  const [data, setData] = useState(initial);
19
21
  const [error, setError] = useState(null);
@@ -38,8 +40,16 @@ export function MembersPage({ ops, userId, initial = null }) {
38
40
  void load();
39
41
  return null;
40
42
  };
41
- const setRole = async (row, role) => {
42
- if (role === row.value)
43
+ /** Two roles: the change is to the other one, confirmed with what it may do. */
44
+ const changeRole = async (row) => {
45
+ const role = row.value === "admin" ? "editor" : "admin";
46
+ const ok = await confirm({
47
+ title: `Change role to ${roleLabel(role).toLowerCase()}?`,
48
+ body: `${roleLabel(role)}: ${ROLE_DESCRIPTION[role]}`,
49
+ confirmLabel: "Change role",
50
+ subject: { name: row.email },
51
+ });
52
+ if (!ok)
43
53
  return;
44
54
  const r = await ops.members.setRole(row.key, role);
45
55
  if (!r.ok) {
@@ -49,7 +59,14 @@ export function MembersPage({ ops, userId, initial = null }) {
49
59
  setData((d) => d && { ...d, members: d.members.map((m) => (m.userId === row.key ? r.data : m)) });
50
60
  };
51
61
  const remove = async (row) => {
52
- if (!window.confirm(`Remove ${row.email} from this site? They keep their account and lose access to the admin.`))
62
+ const ok = await confirm({
63
+ title: "Remove this member?",
64
+ body: "They keep their account and lose access to this site's admin. You can invite them again later.",
65
+ confirmLabel: "Remove member",
66
+ destructive: true,
67
+ subject: { name: row.email },
68
+ });
69
+ if (!ok)
53
70
  return;
54
71
  const r = await ops.members.remove(row.key);
55
72
  if (!r.ok) {
@@ -65,18 +82,19 @@ export function MembersPage({ ops, userId, initial = null }) {
65
82
  const guardTitle = (r) => (r.own ? GUARD_TITLE.own : r.lastAdmin ? GUARD_TITLE.lastAdmin : undefined);
66
83
  return (_jsxs(_Fragment, { children: [_jsx(ListView, { title: "Members", actions: !managed && data && _jsx(Button, { onClick: () => setInviting(true), children: "Invite" }), notice: _jsxs(_Fragment, { children: [data?.consoleUrl && (_jsxs(Banner, { tone: "ok", children: ["Members are managed at smoodly.io.", " ", _jsx("a", { href: data.consoleUrl, target: "_blank", rel: "noreferrer", children: "Open the console" })] })), notice && _jsx(Banner, { tone: notice.tone, onDismiss: () => setNotice(null), children: notice.text })] }), columns: [
67
84
  { label: "Email", width: "minmax(200px,1fr)" },
68
- { label: "Role", width: managed ? "120px" : "180px" },
85
+ { label: "Role", width: "120px" },
69
86
  ...(managed ? [] : [{ label: "", width: "48px" }]),
70
87
  ], rows: rows.map((r) => ({
71
88
  key: r.key,
72
89
  cells: [
73
90
  r.fallback ? _jsx("span", { style: { color: "var(--text-muted)" }, children: r.email }) : r.email,
74
- managed
75
- ? _jsx(StatusBadge, { status: r.role })
76
- : _jsx(Segmented, { options: MEMBER_ROLES, value: r.value, onChange: (v) => void setRole(r, v), label: roleLabel, disabled: r.own || r.lastAdmin, option: () => (guardTitle(r) ? { title: guardTitle(r) } : undefined) }),
91
+ _jsx(StatusBadge, { status: r.role }),
77
92
  ...(managed ? [] : [
78
93
  // ActionMenu has no title of its own when disabled: the span carries the guard's reason.
79
- _jsx("span", { title: guardTitle(r), children: _jsx(ActionMenu, { label: "Member actions", small: true, disabled: r.own || r.lastAdmin, items: [{ label: "Remove", danger: true, run: () => void remove(r) }] }) }),
94
+ _jsx("span", { title: guardTitle(r), children: _jsx(ActionMenu, { label: "Member actions", small: true, disabled: r.own || r.lastAdmin, items: [
95
+ { label: "Change role", run: () => void changeRole(r) },
96
+ { label: "Remove member", danger: true, run: () => void remove(r) },
97
+ ] }) }),
80
98
  ]),
81
99
  ],
82
100
  })), empty: "No members yet" }), inviting && _jsx(InviteModal, { onClose: () => setInviting(false), onInvite: invite })] }));
@@ -0,0 +1,26 @@
1
+ import { type ReactElement } from "react";
2
+ import type { AdminPageTemplate } from "../serialize.ts";
3
+ export type PageFormValues = {
4
+ title: string;
5
+ slug: string;
6
+ template: string | null;
7
+ };
8
+ export declare function PageFormDialog({ title: heading, submitLabel, fields, templates, parentPath, initial, onClose, onSubmit }: {
9
+ /** The dialog's heading ("New page", "Rename page"). */
10
+ title: string;
11
+ submitLabel: string;
12
+ /** Which fields the dialog shows. */
13
+ fields: {
14
+ title?: boolean;
15
+ slug?: boolean;
16
+ template?: boolean;
17
+ };
18
+ /** The open page registrations, for the page-type select (shown when `fields.template` and there is more than one). */
19
+ templates?: AdminPageTemplate[];
20
+ /** The parent's path, shown before the slug ("/company/"); the root's is "/". */
21
+ parentPath?: string;
22
+ initial?: Partial<PageFormValues>;
23
+ onClose(): void;
24
+ /** Resolves to an error message, or null when the op landed (the caller closes). */
25
+ onSubmit(values: PageFormValues): Promise<string | null>;
26
+ }): ReactElement;
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // The Pages list's form dialogs on the dialog card (ui/Dialog.tsx), in
4
+ // place of window.prompt (2026-09-25): New page / New path / New subpage
5
+ // / New subpath (a title, a slug that follows the title until edited, the
6
+ // page type when more than one open registration exists), Add page here
7
+ // (the page type alone) and Rename (title and slug; the home page's title
8
+ // alone, its slug being the config's). Enter submits; the op's error
9
+ // shows inside; success closes it from the caller.
10
+ import { useId, useState } from "react";
11
+ import { DialogCard } from "../ui/Dialog.js";
12
+ import { Banner, Button, Field } from "../ui/primitives.js";
13
+ import { followsTitle, slugify } from "./page-dialogs.js";
14
+ export function PageFormDialog({ title: heading, submitLabel, fields, templates = [], parentPath, initial, onClose, onSubmit }) {
15
+ const [values, setValues] = useState({
16
+ title: initial?.title ?? "",
17
+ slug: initial?.slug ?? "",
18
+ template: initial?.template ?? (templates[0]?.name ?? null),
19
+ });
20
+ const [error, setError] = useState(null);
21
+ const [busy, setBusy] = useState(false);
22
+ const chooseTemplate = fields.template && templates.length > 1;
23
+ const prefix = parentPath === undefined ? undefined : parentPath === "/" ? "/" : `${parentPath}/`;
24
+ const setTitle = (title) => setValues((v) => ({ ...v, title, slug: fields.slug && followsTitle(v.slug, v.title) ? slugify(title) : v.slug }));
25
+ const submit = async (e) => {
26
+ e.preventDefault();
27
+ if (busy)
28
+ return;
29
+ setError(null);
30
+ setBusy(true);
31
+ setError(await onSubmit({ ...values, title: values.title.trim(), slug: values.slug.trim() }));
32
+ setBusy(false);
33
+ };
34
+ const formId = `sm-page-form${useId()}`;
35
+ return (_jsx(DialogCard, { title: heading, onClose: onClose, actions: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "secondary", onClick: onClose, children: "Cancel" }), _jsx("button", { type: "submit", form: formId, className: "sm-btn sm-btn--primary", disabled: busy, children: busy ? "Saving…" : submitLabel })] }), children: _jsxs("form", { id: formId, className: "sm-dialog__form", onSubmit: submit, children: [fields.title && (_jsx(Field, { label: "Title", children: _jsx("input", { className: "sm-input", required: true, autoFocus: true, value: values.title, onChange: (e) => setTitle(e.target.value) }) })), fields.slug && (_jsx(Field, { label: "Slug", hint: "The URL segment: lowercase letters, digits and hyphens.", children: prefix
36
+ ? (_jsxs("span", { className: "sm-inputwrap", children: [_jsx("span", { className: "sm-prefix", children: prefix }), _jsx("input", { className: "sm-input sm-input--mono", required: true, autoFocus: !fields.title, value: values.slug, onChange: (e) => setValues((v) => ({ ...v, slug: e.target.value })) })] }))
37
+ : (_jsx("input", { className: "sm-input sm-input--mono", required: true, autoFocus: !fields.title, value: values.slug, onChange: (e) => setValues((v) => ({ ...v, slug: e.target.value })) })) })), chooseTemplate && (_jsx(Field, { label: "Page type", children: _jsx("select", { className: "sm-select", autoFocus: !fields.title && !fields.slug, value: values.template ?? "", onChange: (e) => setValues((v) => ({ ...v, template: e.target.value })), children: templates.map((t) => _jsx("option", { value: t.name, children: t.title }, t.name)) }) })), error && _jsx(Banner, { tone: "error", children: error })] }) }));
38
+ }
@@ -17,35 +17,22 @@ import { useSortable } from "../ui/useSortable.js";
17
17
  import { useAdminHref } from "./base.js";
18
18
  import { navigate } from "./router.js";
19
19
  import { ErrorPane } from "./ErrorPane.js";
20
+ import { rememberLocale, rememberedLocale } from "./locale-memory.js";
20
21
  import { confirmLiveUrl } from "./live-url.js";
21
- const LOCALE_KEY = "smoodly.pages.locale";
22
- /** The selected locale survives a reload within the session; a stored
23
- * value that is no longer supported falls back to the default. */
24
- function rememberedLocale(registry) {
25
- try {
26
- const stored = window.sessionStorage.getItem(LOCALE_KEY);
27
- if (stored && registry.locales.supported.includes(stored))
28
- return stored;
29
- }
30
- catch {
31
- // storage unavailable (private mode, no window) — the default is fine
32
- }
33
- return registry.locales.default;
34
- }
22
+ import { confirm } from "../ui/confirm.js";
23
+ import { PageFormDialog } from "./PageDialogs.js";
35
24
  export function PagesList({ ops, registry }) {
36
25
  const adminHref = useAdminHref();
37
26
  const [pages, setPages] = useState(null);
38
27
  const [error, setError] = useState(null);
39
28
  const [collapsed, setCollapsed] = useState(() => new Set());
40
29
  const [menu, setMenu] = useState(null);
41
- const [locale, setLocale] = useState(() => rememberedLocale(registry));
30
+ const [dialog, setDialog] = useState(null);
31
+ const [locale, setLocale] = useState(() => rememberedLocale(registry.locales));
42
32
  const multilingual = registry.locales.supported.length > 1;
43
33
  const pickLocale = (next) => {
44
34
  setLocale(next);
45
- try {
46
- window.sessionStorage.setItem(LOCALE_KEY, next);
47
- }
48
- catch { /* see rememberedLocale */ }
35
+ rememberLocale(next);
49
36
  };
50
37
  const load = useCallback(() => ops.pages.list()
51
38
  .then((r) => (r.ok ? setPages(r.data) : setError(r.message)))
@@ -77,7 +64,7 @@ export function PagesList({ ops, registry }) {
77
64
  return;
78
65
  // A published page under a new parent is a new live URL (members management §5).
79
66
  const current = row.record.locales[locale];
80
- if (!confirmLiveUrl({ status: current?.status, from: row.parentId ?? "", to: projection.parentId ?? "" }))
67
+ if (!(await confirmLiveUrl({ status: current?.status, from: row.parentId ?? "", to: projection.parentId ?? "" }, { name: row.title, path: row.path })))
81
68
  return;
82
69
  const ok = await run(() => ops.pages.move(row.id, { parentId: projection.parentId, index: projection.index }));
83
70
  if (!ok)
@@ -86,10 +73,10 @@ export function PagesList({ ops, registry }) {
86
73
  });
87
74
  /** The editor opens in the locale selected here. */
88
75
  const openEditor = (id) => {
89
- navigate(adminHref(`/pages/${encodeURIComponent(id)}?locale=${encodeURIComponent(locale)}`));
76
+ void navigate(adminHref(`/pages/${encodeURIComponent(id)}?locale=${encodeURIComponent(locale)}`));
90
77
  };
91
- /** Run an op; on success reload the list (and maybe navigate), else show the op's message. Resolves to whether it succeeded. */
92
- const run = async (work, then) => {
78
+ /** Run an op; on success reload the list (and maybe navigate). Resolves to the op's message, or null when it landed. */
79
+ const attempt = async (work, then) => {
93
80
  let result;
94
81
  try {
95
82
  result = await work();
@@ -97,74 +84,107 @@ export function PagesList({ ops, registry }) {
97
84
  catch {
98
85
  result = { ok: false, code: "internal", message: "Couldn't reach the server." };
99
86
  }
100
- if (!result.ok) {
101
- window.alert(result.message);
102
- return false;
103
- }
87
+ if (!result.ok)
88
+ return result.message;
104
89
  then?.(result.data);
105
90
  await load();
106
- return true;
91
+ return null;
107
92
  };
108
- const pickTemplate = () => {
109
- if (noOpen)
110
- return null;
111
- if (creatable.length === 1)
112
- return creatable[0].name;
113
- return window.prompt(`Page type? (${creatable.map((p) => p.name).join(", ")})`) || null;
93
+ /** `attempt` for an action outside a dialog: the message goes to an alert. Resolves to whether it succeeded. */
94
+ const run = async (work, then) => {
95
+ const message = await attempt(work, then);
96
+ if (message)
97
+ window.alert(message);
98
+ return message === null;
114
99
  };
115
- /** New page and New path (a folder in the tree) create in the SELECTED locale (spec §6). */
100
+ /** New page and New path (a folder in the tree) create in the SELECTED locale (spec §6),
101
+ * Add page here gives a folder a template, Rename edits the title and slug — all in a dialog (PageDialogs). */
116
102
  const newNode = (parentId, kind) => {
117
103
  if (kind === "page" && noOpen)
118
104
  return;
119
- const slug = window.prompt(`Slug for the new ${kind === "folder" ? "path" : "page"} (e.g. about):`);
120
- if (!slug)
121
- return;
122
- const template = kind === "page" ? pickTemplate() : null;
123
- if (kind === "page" && !template)
124
- return;
125
- void run(() => ops.pages.create({ parentId, locale, slug, template }), (page) => { if (template)
126
- openEditor(page.id); });
105
+ setDialog({ kind: "new", parentId, node: kind });
127
106
  };
128
107
  const addPageHere = (row) => {
129
- const template = pickTemplate();
130
- if (!template)
108
+ if (noOpen)
131
109
  return;
132
- void run(() => ops.pages.setTemplate(row.id, template), (page) => openEditor(page.id));
110
+ if (creatable.length === 1) {
111
+ void run(() => ops.pages.setTemplate(row.id, creatable[0].name), (page) => openEditor(page.id));
112
+ return;
113
+ }
114
+ setDialog({ kind: "template", row });
115
+ };
116
+ const rename = (row) => { if (row.record.locales[locale])
117
+ setDialog({ kind: "rename", row }); };
118
+ const closeDialog = () => setDialog(null);
119
+ /** The parent's path from a row's own: "/company/about-us" → "/company", "/about" → "/". */
120
+ const parentPathOf = (path) => {
121
+ if (!path)
122
+ return "/";
123
+ const cut = path.lastIndexOf("/");
124
+ return cut <= 0 ? "/" : path.slice(0, cut);
125
+ };
126
+ /** What the open dialog submits. Resolves to the op's message, or null and the caller closes. */
127
+ const submitDialog = async (values) => {
128
+ if (!dialog)
129
+ return null;
130
+ if (dialog.kind === "new") {
131
+ const template = dialog.node === "page" ? values.template : null;
132
+ if (dialog.node === "page" && !template)
133
+ return "Choose a page type.";
134
+ return attempt(() => ops.pages.create({ parentId: dialog.parentId, locale, slug: values.slug, title: values.title, template }), (page) => { if (template)
135
+ openEditor(page.id); });
136
+ }
137
+ if (dialog.kind === "template") {
138
+ if (!values.template)
139
+ return "Choose a page type.";
140
+ return attempt(() => ops.pages.setTemplate(dialog.row.id, values.template), (page) => openEditor(page.id));
141
+ }
142
+ const { row } = dialog;
143
+ const current = row.record.locales[locale];
144
+ if (!current)
145
+ return null;
146
+ // The site root's slug is the config's homePageSlug — title only there.
147
+ if (row.isHome)
148
+ return attempt(() => ops.pages.rename(row.id, { locale, title: values.title }));
149
+ if (!(await confirmLiveUrl({ status: current.status, from: current.slug, to: values.slug }, { name: row.title, path: row.path })))
150
+ return null;
151
+ return attempt(() => ops.pages.rename(row.id, { locale, title: values.title, slug: values.slug }));
133
152
  };
134
- const addLocale = (row) => {
153
+ const addLocale = async (row) => {
135
154
  const from = sourceLocaleOf(row.record, registry);
136
- if (!window.confirm(`Add "${row.title}" to ${locale}? Its ${from} content is copied as the first ${locale} draft.`))
155
+ const ok = await confirm({
156
+ title: `Add this page to ${locale}?`,
157
+ body: `Its ${from} content is copied as the first ${locale} draft. Nothing is published until you publish it.`,
158
+ confirmLabel: `Add to ${locale}`,
159
+ subject: { name: row.title, path: row.record.locales[from] ? row.path : null },
160
+ });
161
+ if (!ok)
137
162
  return;
138
163
  void run(() => ops.pages.addLocale(row.id, locale, { from }), (page) => { if (page.template !== null)
139
164
  openEditor(page.id); });
140
165
  };
141
- const removeLocale = (row) => {
142
- if (!window.confirm(`Remove "${row.title}" from ${locale}? Its ${locale} content and history are deleted.`))
166
+ const removeLocale = async (row) => {
167
+ const ok = await confirm({
168
+ title: `Remove this page from ${locale}?`,
169
+ body: `Its ${locale} content and history are deleted. Other languages are not affected.`,
170
+ confirmLabel: `Remove from ${locale}`,
171
+ destructive: true,
172
+ subject: { name: row.title, path: row.path },
173
+ });
174
+ if (!ok)
143
175
  return;
144
176
  void run(() => ops.pages.removeLocale(row.id, locale));
145
177
  };
146
- const rename = (row) => {
147
- const current = row.record.locales[locale];
148
- if (!current)
149
- return;
150
- const title = window.prompt("Title:", current.title);
151
- if (title === null)
152
- return;
153
- // The site root's slug is the config's homePageSlug — title only here.
154
- if (row.isHome) {
155
- void run(() => ops.pages.rename(row.id, { locale, title }));
156
- return;
157
- }
158
- const slug = window.prompt("Slug (the URL segment):", current.slug);
159
- if (slug === null)
160
- return;
161
- if (!confirmLiveUrl({ status: current.status, from: current.slug, to: slug }))
162
- return;
163
- void run(() => ops.pages.rename(row.id, { locale, title, slug }));
164
- };
165
- const destroy = (row) => {
178
+ const destroy = async (row) => {
166
179
  const scope = row.locales.length > 1 ? ` in every language (${row.locales.join(", ")})` : "";
167
- if (!window.confirm(`Delete "${row.title}"${scope}?`))
180
+ const ok = await confirm({
181
+ title: row.hasChildren ? "Delete this page and everything under it?" : "Delete this page?",
182
+ body: `The page${scope} and its history are removed. Links pointing to it stop working. This cannot be undone.`,
183
+ confirmLabel: "Delete page",
184
+ destructive: true,
185
+ subject: { name: row.title, path: row.path },
186
+ });
187
+ if (!ok)
168
188
  return;
169
189
  void run(() => ops.pages.delete(row.id));
170
190
  };
@@ -200,7 +220,7 @@ export function PagesList({ ops, registry }) {
200
220
  else if (row.template !== null)
201
221
  openEditor(row.id);
202
222
  else if (row.kind === "mount" && row.collection)
203
- navigate(adminHref(`/${row.collection}`));
223
+ void navigate(adminHref(`/${row.collection}`));
204
224
  else if (row.hasChildren)
205
225
  toggle(row.id);
206
226
  };
@@ -238,5 +258,8 @@ export function PagesList({ ops, registry }) {
238
258
  position: "absolute",
239
259
  left: Math.max(12, Math.min(menu.x - 280, window.innerWidth - 312)),
240
260
  top: Math.min(menu.y + 8, Math.max(12, window.innerHeight - 300)),
241
- }, children: [items.map((item) => (_jsx("button", { type: "button", className: "sm-picker__item", onClick: () => { setMenu(null); item.run(); }, children: item.label }, item.label))), items.length === 0 && (_jsx("p", { style: { color: "var(--text-muted)", padding: 10 }, children: "Owned by code \u2014 nothing to change here." }))] }) }))] }));
261
+ }, children: [items.map((item) => (_jsx("button", { type: "button", className: "sm-picker__item", onClick: () => { setMenu(null); item.run(); }, children: item.label }, item.label))), items.length === 0 && (_jsx("p", { style: { color: "var(--text-muted)", padding: 10 }, children: "Owned by code \u2014 nothing to change here." }))] }) })), dialog?.kind === "new" && (_jsx(PageFormDialog, { title: dialog.node === "page" ? (dialog.parentId ? "New subpage" : "New page") : (dialog.parentId ? "New subpath" : "New path"), submitLabel: dialog.node === "page" ? "Create page" : "Create path", fields: { title: true, slug: true, template: dialog.node === "page" }, templates: creatable, parentPath: dialog.parentId ? (rows.find((r) => r.id === dialog.parentId)?.path ?? "/") : "/", onClose: closeDialog, onSubmit: (values) => submitDialog(values).then((message) => { if (message === null)
262
+ closeDialog(); return message; }) })), dialog?.kind === "template" && (_jsx(PageFormDialog, { title: "Add page here", submitLabel: "Add page", fields: { template: true }, templates: creatable, onClose: closeDialog, onSubmit: (values) => submitDialog(values).then((message) => { if (message === null)
263
+ closeDialog(); return message; }) })), dialog?.kind === "rename" && (_jsx(PageFormDialog, { title: "Rename page", submitLabel: "Rename", fields: { title: true, slug: !dialog.row.isHome }, initial: { title: dialog.row.record.locales[locale]?.title ?? "", slug: dialog.row.record.locales[locale]?.slug ?? "" }, parentPath: dialog.row.isHome ? undefined : parentPathOf(dialog.row.path), onClose: closeDialog, onSubmit: (values) => submitDialog(values).then((message) => { if (message === null)
264
+ closeDialog(); return message; }) }))] }));
242
265
  }
@@ -6,7 +6,7 @@ export function RouteLink({ href, onClick, ...rest }) {
6
6
  onClick?.(e);
7
7
  if (isPlainLeftClick(e, rest.target)) {
8
8
  e.preventDefault();
9
- navigate(href);
9
+ void navigate(href);
10
10
  }
11
11
  } }));
12
12
  }
@@ -0,0 +1,4 @@
1
+ import type { SchemaStatus } from "../ops.ts";
2
+ export declare function SchemaNotice({ status }: {
3
+ status: SchemaStatus;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function SchemaNotice({ status }) {
3
+ return (_jsx("div", { style: { height: "100vh", display: "grid", placeItems: "center", padding: 24, color: "var(--text)" }, children: _jsxs("div", { style: { maxWidth: 520, display: "grid", gap: 12 }, children: [_jsx("h1", { className: "sm-title", style: { fontSize: 22, margin: 0 }, children: "The database needs an update" }), _jsxs("p", { style: { margin: 0 }, children: ["The database schema is at version ", status.database ?? "none", ". This version of Smoodly needs version ", status.required, "."] }), _jsx("p", { style: { margin: 0 }, children: "From the site's folder:" }), _jsx("pre", { className: "sm-code", children: _jsx("code", { children: "npx smoodly migrate" }) }), _jsx("p", { style: { margin: 0 }, children: "then apply it:" }), _jsx("pre", { className: "sm-code", children: _jsx("code", { children: "supabase db push" }) }), _jsxs("p", { style: { margin: 0, color: "var(--text-muted)" }, children: ["That is for a hosted project; for the local stack run ", _jsx("code", { children: "supabase db reset" }), ". Reload this page afterwards."] })] }) }));
4
+ }
@@ -1,27 +1,28 @@
1
1
  "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  // packages/smoodly/src/admin/shell/SettingsView.tsx
4
4
  // The Settings area (spec 2026-09-25 §5): a 200px secondary nav at the
5
- // left of the main column, then the page with its own top bar. The head
6
- // segment alone replaces itself with the default page, so Back skips the
7
- // empty URL. An unknown page is the shell's Not found pane. Admins only
8
- // (members management §2): an editor gets the error pane, and until the
9
- // role is known the area is loading.
5
+ // left of the main column, its card starting where the page's card starts (no heading since 2026-09-26) —
6
+ // then the page with its own top bar. The head segment alone replaces
7
+ // itself with the default page, so Back skips the empty URL. An unknown
8
+ // page is the shell's Not found pane. Admins only (members management
9
+ // §2): an editor gets the error pane, and until the role is known the
10
+ // area is loading. Members is the only page (the Roles table moved into
11
+ // the invite modal's role descriptions; API Keys never had contents).
10
12
  import { useEffect } from "react";
11
13
  import { can } from "../../permissions.js";
12
- import { TopBar } from "../ui/primitives.js";
13
14
  import { useAdminHref } from "./base.js";
14
15
  import { ErrorPane } from "./ErrorPane.js";
15
16
  import { MembersPage } from "./MembersPage.js";
16
17
  import { RouteLink } from "./RouteLink.js";
17
18
  import { navigate } from "./router.js";
18
- import { DEFAULT_SETTINGS_PAGE, SETTINGS_PAGES, settingsPage, settingsTitle } from "./settings.js";
19
+ import { DEFAULT_SETTINGS_PAGE, SETTINGS_PAGES, settingsPage } from "./settings.js";
19
20
  export function SettingsView({ ops, tail, role, userId }) {
20
21
  const adminHref = useAdminHref();
21
22
  const page = settingsPage(tail);
22
23
  useEffect(() => {
23
24
  if (tail === undefined)
24
- navigate(adminHref(`/settings/${DEFAULT_SETTINGS_PAGE}`), { replace: true });
25
+ void navigate(adminHref(`/settings/${DEFAULT_SETTINGS_PAGE}`), { replace: true });
25
26
  }, [tail, adminHref]);
26
27
  if (role === null)
27
28
  return _jsx("div", { className: "sm-empty", children: "Loading\u2026" });
@@ -29,21 +30,5 @@ export function SettingsView({ ops, tail, role, userId }) {
29
30
  return _jsx(ErrorPane, { message: "Settings are for admins." });
30
31
  if (!page)
31
32
  return _jsx(ErrorPane, { message: "Not found." });
32
- return (_jsxs("div", { className: "sm-settings", children: [_jsx("nav", { className: "sm-settings__nav", "aria-label": "Settings", children: SETTINGS_PAGES.map((p) => (_jsx(RouteLink, { className: "sm-settings__link", href: adminHref(`/settings/${p.id}`), "aria-current": p.id === page ? "page" : undefined, children: p.title }, p.id))) }), _jsx("section", { className: "sm-settings__page", children: page === "members"
33
- ? _jsx(MembersPage, { ops: ops, userId: userId })
34
- : page === "roles"
35
- ? _jsx(RolesPage, {})
36
- : _jsxs(_Fragment, { children: [_jsx(TopBar, { left: _jsx("span", { className: "sm-title", children: settingsTitle(page) }) }), _jsx("div", { className: "sm-listwrap" })] }) })] }));
37
- }
38
- // The two roles, read-only (members management §1): what each may do.
39
- // A row per capability group, not per Capability — the table explains,
40
- // permissions.ts decides.
41
- const ROLE_ROWS = [
42
- ["Edit, publish, unpublish and delete content; upload and delete media", true, true],
43
- ["Open Settings and every page under it", true, false],
44
- ["Invite, re-role and remove members", true, false],
45
- ];
46
- function RolesPage() {
47
- const grid = { gridTemplateColumns: "minmax(240px,1fr) 100px 100px" };
48
- return (_jsxs(_Fragment, { children: [_jsx(TopBar, { left: _jsx("span", { className: "sm-title", children: "Roles" }) }), _jsx("div", { className: "sm-listwrap", children: _jsxs("div", { className: "sm-table", children: [_jsxs("div", { className: "sm-table__head", style: grid, children: [_jsx("span", { children: "What a role may do" }), _jsx("span", { children: "Admin" }), _jsx("span", { children: "Editor" })] }), _jsx("div", { className: "sm-table__body", children: ROLE_ROWS.map(([what, admin, editor]) => (_jsxs("div", { className: "sm-row", style: grid, children: [_jsx("span", { className: "sm-cell", children: what }), _jsx("span", { className: "sm-cell", children: admin ? "yes" : "no" }), _jsx("span", { className: "sm-cell", children: editor ? "yes" : "no" })] }, what))) })] }) })] }));
33
+ return (_jsxs("div", { className: "sm-settings", children: [_jsx("nav", { className: "sm-settings__nav", "aria-label": "Settings", children: SETTINGS_PAGES.map((p) => (_jsx(RouteLink, { className: "sm-settings__link", href: adminHref(`/settings/${p.id}`), "aria-current": p.id === page ? "page" : undefined, children: p.title }, p.id))) }), _jsx("section", { className: "sm-settings__page", children: _jsx(MembersPage, { ops: ops, userId: userId }) })] }));
49
34
  }
@@ -1,9 +1,10 @@
1
- export declare const LIVE_URL_MESSAGE = "This changes the live URL. Old links stop working until a redirect exists (there are none yet). Continue?";
1
+ import { type ConfirmOptions, type ConfirmSubject } from "../ui/confirm.ts";
2
+ export declare const LIVE_URL_CONFIRM: Omit<ConfirmOptions, "subject">;
2
3
  /** `from` null = there was no URL part to change (a new row, a collection without a path). */
3
4
  export declare function liveUrlChanges(input: {
4
5
  status: "draft" | "published" | undefined;
5
6
  from: string | null;
6
7
  to: string | null;
7
8
  }): boolean;
8
- /** True when the change may go ahead: not a live change, or confirmed. */
9
- export declare const confirmLiveUrl: (input: Parameters<typeof liveUrlChanges>[0]) => boolean;
9
+ /** Resolves true when the change may go ahead: not a live change, or confirmed. */
10
+ export declare function confirmLiveUrl(input: Parameters<typeof liveUrlChanges>[0], subject?: ConfirmSubject): Promise<boolean>;
@@ -1,10 +1,19 @@
1
1
  // The one confirm on anything that changes a live URL (spec 2026-09-25
2
2
  // members management §5): a published page's or entry's slug, or a
3
3
  // published page's parent. Whoever the role — the mistake is the same.
4
- export const LIVE_URL_MESSAGE = "This changes the live URL. Old links stop working until a redirect exists (there are none yet). Continue?";
4
+ // Asked in the admin's own dialog (ui/confirm.ts); the subject chip names
5
+ // the record and the URL part that is about to change.
6
+ import { confirm } from "../ui/confirm.js";
7
+ export const LIVE_URL_CONFIRM = {
8
+ title: "Change the live URL?",
9
+ body: "This is published. Old links to it stop working until a redirect exists, and Smoodly has none yet.",
10
+ confirmLabel: "Change URL",
11
+ };
5
12
  /** `from` null = there was no URL part to change (a new row, a collection without a path). */
6
13
  export function liveUrlChanges(input) {
7
14
  return input.status === "published" && input.from !== null && input.to !== input.from;
8
15
  }
9
- /** True when the change may go ahead: not a live change, or confirmed. */
10
- export const confirmLiveUrl = (input) => !liveUrlChanges(input) || window.confirm(LIVE_URL_MESSAGE);
16
+ /** Resolves true when the change may go ahead: not a live change, or confirmed. */
17
+ export async function confirmLiveUrl(input, subject) {
18
+ return !liveUrlChanges(input) || confirm({ ...LIVE_URL_CONFIRM, subject });
19
+ }
@@ -0,0 +1,8 @@
1
+ import type { AdminRegistry } from "../serialize.ts";
2
+ export declare const LOCALE_KEY = "smoodly-locale";
3
+ type Locales = AdminRegistry["locales"];
4
+ /** The stored locale when the config supports it, else the default. */
5
+ export declare function resolveLocale(stored: string | null | undefined, locales: Locales): string;
6
+ export declare function rememberedLocale(locales: Locales): string;
7
+ export declare function rememberLocale(locale: string): void;
8
+ export {};
@@ -0,0 +1,23 @@
1
+ export const LOCALE_KEY = "smoodly-locale";
2
+ /** The stored locale when the config supports it, else the default. */
3
+ export function resolveLocale(stored, locales) {
4
+ return stored && locales.supported.includes(stored) ? stored : locales.default;
5
+ }
6
+ export function rememberedLocale(locales) {
7
+ let stored = null;
8
+ try {
9
+ stored = window.localStorage.getItem(LOCALE_KEY);
10
+ }
11
+ catch {
12
+ // storage unavailable (private mode, no window) — the default is fine
13
+ }
14
+ return resolveLocale(stored, locales);
15
+ }
16
+ export function rememberLocale(locale) {
17
+ try {
18
+ window.localStorage.setItem(LOCALE_KEY, locale);
19
+ }
20
+ catch {
21
+ // not remembered — the screen still switches
22
+ }
23
+ }
@@ -12,6 +12,8 @@ export type MemberRow = {
12
12
  lastAdmin: boolean;
13
13
  };
14
14
  export declare const roleLabel: (role: string) => string;
15
+ /** What each role may do, in one line — the invite modal's radio descriptions (permissions.ts decides). */
16
+ export declare const ROLE_DESCRIPTION: Record<MemberRole, string>;
15
17
  export declare function memberRows(members: MemberRecord[], opts: {
16
18
  me: string;
17
19
  }): MemberRow[];
@@ -1,5 +1,10 @@
1
1
  import { normalizeRole } from "../../permissions.js";
2
2
  export const roleLabel = (role) => (role ? role[0].toUpperCase() + role.slice(1) : "");
3
+ /** What each role may do, in one line — the invite modal's radio descriptions (permissions.ts decides). */
4
+ export const ROLE_DESCRIPTION = {
5
+ editor: "Edits, publishes and deletes content and media.",
6
+ admin: "Everything an editor can, and Settings: invites, re-roles and removes members.",
7
+ };
3
8
  export function memberRows(members, opts) {
4
9
  const admins = members.filter((m) => normalizeRole(m.role) === "admin").length;
5
10
  return members.map((m) => {