@ektyra/layout 0.0.0-stage → 0.2.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.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/dist/appearance/appearance.d.ts +39 -0
  3. package/dist/appearance/appearance.js +102 -0
  4. package/dist/appearance/index.d.ts +3 -0
  5. package/dist/appearance/index.js +2 -0
  6. package/dist/appearance/preloader.d.ts +11 -0
  7. package/dist/appearance/preloader.js +28 -0
  8. package/dist/navigation/context.d.ts +25 -0
  9. package/dist/navigation/context.js +31 -0
  10. package/dist/navigation/index.d.ts +5 -0
  11. package/dist/navigation/index.js +3 -0
  12. package/dist/navigation/trail.d.ts +10 -0
  13. package/dist/navigation/trail.js +37 -0
  14. package/dist/navigation/types.d.ts +46 -0
  15. package/dist/navigation/types.js +1 -0
  16. package/dist/notifications/context.d.ts +16 -0
  17. package/dist/notifications/context.js +11 -0
  18. package/dist/notifications/index.d.ts +5 -0
  19. package/dist/notifications/index.js +3 -0
  20. package/dist/notifications/notification-item.d.ts +6 -0
  21. package/dist/notifications/notification-item.js +13 -0
  22. package/dist/notifications/notification-types.d.ts +27 -0
  23. package/dist/notifications/notification-types.js +10 -0
  24. package/dist/notifications/notifications-panel.d.ts +10 -0
  25. package/dist/notifications/notifications-panel.js +9 -0
  26. package/dist/shell/auth/auth-heading.d.ts +7 -0
  27. package/dist/shell/auth/auth-heading.js +5 -0
  28. package/dist/shell/auth/auth-layout.d.ts +10 -0
  29. package/dist/shell/auth/auth-layout.js +14 -0
  30. package/dist/shell/auth/auth-theme-toggle.d.ts +5 -0
  31. package/dist/shell/auth/auth-theme-toggle.js +12 -0
  32. package/dist/shell/auth/auth-usps.d.ts +2 -0
  33. package/dist/shell/auth/auth-usps.js +15 -0
  34. package/dist/shell/auth/index.d.ts +2 -0
  35. package/dist/shell/auth/index.js +2 -0
  36. package/dist/shell/customizer/color-scheme-choice.d.ts +2 -0
  37. package/dist/shell/customizer/color-scheme-choice.js +25 -0
  38. package/dist/shell/customizer/layout-wireframe.d.ts +11 -0
  39. package/dist/shell/customizer/layout-wireframe.js +12 -0
  40. package/dist/shell/customizer/option-picker.d.ts +17 -0
  41. package/dist/shell/customizer/option-picker.js +8 -0
  42. package/dist/shell/customizer/palette-data.d.ts +18 -0
  43. package/dist/shell/customizer/palette-data.js +64 -0
  44. package/dist/shell/customizer/theme-customizer.d.ts +5 -0
  45. package/dist/shell/customizer/theme-customizer.js +96 -0
  46. package/dist/shell/horizontal-menu/horizontal-menu-leaf.d.ts +5 -0
  47. package/dist/shell/horizontal-menu/horizontal-menu-leaf.js +11 -0
  48. package/dist/shell/horizontal-menu/horizontal-menu.d.ts +2 -0
  49. package/dist/shell/horizontal-menu/horizontal-menu.js +39 -0
  50. package/dist/shell/horizontal-menu/index.d.ts +1 -0
  51. package/dist/shell/horizontal-menu/index.js +1 -0
  52. package/dist/shell/logo.d.ts +7 -0
  53. package/dist/shell/logo.js +9 -0
  54. package/dist/shell/navbar/command-menu.d.ts +19 -0
  55. package/dist/shell/navbar/command-menu.js +32 -0
  56. package/dist/shell/navbar/index.d.ts +1 -0
  57. package/dist/shell/navbar/index.js +1 -0
  58. package/dist/shell/navbar/navbar-help.d.ts +1 -0
  59. package/dist/shell/navbar/navbar-help.js +6 -0
  60. package/dist/shell/navbar/navbar-notifications.d.ts +6 -0
  61. package/dist/shell/navbar/navbar-notifications.js +20 -0
  62. package/dist/shell/navbar/navbar-search.d.ts +1 -0
  63. package/dist/shell/navbar/navbar-search.js +19 -0
  64. package/dist/shell/navbar/navbar-sidebar-toggle.d.ts +1 -0
  65. package/dist/shell/navbar/navbar-sidebar-toggle.js +20 -0
  66. package/dist/shell/navbar/navbar-user-menu.d.ts +8 -0
  67. package/dist/shell/navbar/navbar-user-menu.js +14 -0
  68. package/dist/shell/navbar/navbar.d.ts +4 -0
  69. package/dist/shell/navbar/navbar.js +12 -0
  70. package/dist/shell/page-breadcrumbs.d.ts +11 -0
  71. package/dist/shell/page-breadcrumbs.js +23 -0
  72. package/dist/shell/page-header.d.ts +26 -0
  73. package/dist/shell/page-header.js +16 -0
  74. package/dist/shell/sidebar/index.d.ts +1 -0
  75. package/dist/shell/sidebar/index.js +1 -0
  76. package/dist/shell/sidebar/sidebar-group-label.d.ts +7 -0
  77. package/dist/shell/sidebar/sidebar-group-label.js +8 -0
  78. package/dist/shell/sidebar/sidebar-nav-item.d.ts +4 -0
  79. package/dist/shell/sidebar/sidebar-nav-item.js +12 -0
  80. package/dist/shell/sidebar/sidebar-nav-parent.d.ts +12 -0
  81. package/dist/shell/sidebar/sidebar-nav-parent.js +43 -0
  82. package/dist/shell/sidebar/sidebar-nav-styles.d.ts +7 -0
  83. package/dist/shell/sidebar/sidebar-nav-styles.js +7 -0
  84. package/dist/shell/sidebar/sidebar-nav.d.ts +6 -0
  85. package/dist/shell/sidebar/sidebar-nav.js +9 -0
  86. package/dist/shell/sidebar/sidebar-project-switcher.d.ts +11 -0
  87. package/dist/shell/sidebar/sidebar-project-switcher.js +19 -0
  88. package/dist/shell/sidebar/sidebar-tooltip.d.ts +19 -0
  89. package/dist/shell/sidebar/sidebar-tooltip.js +23 -0
  90. package/dist/shell/sidebar/sidebar.d.ts +8 -0
  91. package/dist/shell/sidebar/sidebar.js +18 -0
  92. package/dist/sidebar-state/index.d.ts +1 -0
  93. package/dist/sidebar-state/index.js +1 -0
  94. package/dist/sidebar-state/sidebar-state.d.ts +19 -0
  95. package/dist/sidebar-state/sidebar-state.js +75 -0
  96. package/package.json +67 -3
  97. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ektyra contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The look of the app that the theme customizer controls, kept as attributes on
3
+ * `<html>` so it is right from the first paint (no flash on reload), the same way
4
+ * the color scheme (`core/theme`) and the sidebar (`core/sidebar`) work:
5
+ *
6
+ * - `data-layout="horizontal"`: the menu runs across the top and there is no sidebar.
7
+ * - `data-layout="detached"`: the sidebar floats as a rounded panel, apart from the page edge.
8
+ * - `data-width="boxed"`: the page content stays in a centered column.
9
+ * - `data-palette="…"`: a color palette (see `core/styles/palettes.css`).
10
+ * - `data-preloader="…"`: the animation shown while the app loads.
11
+ *
12
+ * The default choice of each setting has no attribute. Dark mode and the sidebar
13
+ * width are separate (`core/theme`, `core/sidebar`).
14
+ */
15
+ export declare const layouts: readonly ["vertical", "horizontal", "detached"];
16
+ export declare const widths: readonly ["fluid", "boxed"];
17
+ export declare const preloaders: readonly ["none", "rotating", "spinning", "loading"];
18
+ export declare const palettes: readonly ["default", "clay", "amber", "ocean", "violet", "nature", "catppuccin", "supabase", "customer"];
19
+ export type Layout = (typeof layouts)[number];
20
+ export type Width = (typeof widths)[number];
21
+ export type Preloader = (typeof preloaders)[number];
22
+ export type Palette = (typeof palettes)[number];
23
+ export type Appearance = {
24
+ layout: Layout;
25
+ width: Width;
26
+ palette: Palette;
27
+ preloader: Preloader;
28
+ };
29
+ export declare const defaultAppearance: Appearance;
30
+ export declare const APPEARANCE_STORAGE_KEY = "ektyra-cms-appearance";
31
+ /**
32
+ * Inline script for <head>: restores the saved choices before first paint. It runs before
33
+ * any module has loaded, so it repeats the read-and-apply steps below in a few lines.
34
+ */
35
+ export declare const appearanceInitScript: string;
36
+ export declare function setAppearance<K extends keyof Appearance>(key: K, value: Appearance[K]): void;
37
+ export declare function resetAppearance(): void;
38
+ /** The current choices. The server always says the defaults; the browser corrects it right away. */
39
+ export declare function useAppearance(): Appearance;
@@ -0,0 +1,102 @@
1
+ import { useSyncExternalStore } from "react";
2
+ /**
3
+ * The look of the app that the theme customizer controls, kept as attributes on
4
+ * `<html>` so it is right from the first paint (no flash on reload), the same way
5
+ * the color scheme (`core/theme`) and the sidebar (`core/sidebar`) work:
6
+ *
7
+ * - `data-layout="horizontal"`: the menu runs across the top and there is no sidebar.
8
+ * - `data-layout="detached"`: the sidebar floats as a rounded panel, apart from the page edge.
9
+ * - `data-width="boxed"`: the page content stays in a centered column.
10
+ * - `data-palette="…"`: a color palette (see `core/styles/palettes.css`).
11
+ * - `data-preloader="…"`: the animation shown while the app loads.
12
+ *
13
+ * The default choice of each setting has no attribute. Dark mode and the sidebar
14
+ * width are separate (`core/theme`, `core/sidebar`).
15
+ */
16
+ export const layouts = ["vertical", "horizontal", "detached"];
17
+ export const widths = ["fluid", "boxed"];
18
+ export const preloaders = ["none", "rotating", "spinning", "loading"];
19
+ export const palettes = [
20
+ "default",
21
+ "clay",
22
+ "amber",
23
+ "ocean",
24
+ "violet",
25
+ "nature",
26
+ "catppuccin",
27
+ "supabase",
28
+ "customer",
29
+ ];
30
+ export const defaultAppearance = {
31
+ layout: "vertical",
32
+ width: "fluid",
33
+ palette: "default",
34
+ preloader: "none",
35
+ };
36
+ export const APPEARANCE_STORAGE_KEY = "ektyra-cms-appearance";
37
+ const attributes = {
38
+ layout: "data-layout",
39
+ width: "data-width",
40
+ palette: "data-palette",
41
+ preloader: "data-preloader",
42
+ };
43
+ const choices = { layout: layouts, width: widths, palette: palettes, preloader: preloaders };
44
+ function isChoice(key, value) {
45
+ return choices[key].includes(value);
46
+ }
47
+ /**
48
+ * Inline script for <head>: restores the saved choices before first paint. It runs before
49
+ * any module has loaded, so it repeats the read-and-apply steps below in a few lines.
50
+ */
51
+ export const appearanceInitScript = `(function(){try{var s=JSON.parse(localStorage.getItem(${JSON.stringify(APPEARANCE_STORAGE_KEY)})||"{}");var a=${JSON.stringify(attributes)};var d=${JSON.stringify(defaultAppearance)};var c=${JSON.stringify(choices)};for(var k in a){var v=s[k];if(v&&v!==d[k]&&c[k].indexOf(v)>-1)document.documentElement.setAttribute(a[k],v)}}catch(e){}})();`;
52
+ const listeners = new Set();
53
+ const subscribe = (listener) => {
54
+ listeners.add(listener);
55
+ return () => listeners.delete(listener);
56
+ };
57
+ // useSyncExternalStore needs the same object back until something changes.
58
+ let snapshot = defaultAppearance;
59
+ function readAppearance() {
60
+ const root = document.documentElement;
61
+ const next = { ...defaultAppearance };
62
+ for (const key of Object.keys(attributes)) {
63
+ const value = root.getAttribute(attributes[key]);
64
+ if (isChoice(key, value))
65
+ next[key] = value;
66
+ }
67
+ const same = Object.keys(next).every((key) => next[key] === snapshot[key]);
68
+ if (!same)
69
+ snapshot = next;
70
+ return snapshot;
71
+ }
72
+ export function setAppearance(key, value) {
73
+ const root = document.documentElement;
74
+ if (value === defaultAppearance[key])
75
+ root.removeAttribute(attributes[key]);
76
+ else
77
+ root.setAttribute(attributes[key], value);
78
+ try {
79
+ localStorage.setItem(APPEARANCE_STORAGE_KEY, JSON.stringify(readAppearance()));
80
+ }
81
+ catch {
82
+ /* storage unavailable: the choice lasts for this visit only */
83
+ }
84
+ listeners.forEach((listener) => listener());
85
+ }
86
+ export function resetAppearance() {
87
+ for (const key of Object.keys(attributes)) {
88
+ document.documentElement.removeAttribute(attributes[key]);
89
+ }
90
+ try {
91
+ localStorage.removeItem(APPEARANCE_STORAGE_KEY);
92
+ }
93
+ catch {
94
+ /* storage unavailable */
95
+ }
96
+ readAppearance();
97
+ listeners.forEach((listener) => listener());
98
+ }
99
+ /** The current choices. The server always says the defaults; the browser corrects it right away. */
100
+ export function useAppearance() {
101
+ return useSyncExternalStore(subscribe, readAppearance, () => defaultAppearance);
102
+ }
@@ -0,0 +1,3 @@
1
+ export { appearanceInitScript, defaultAppearance, layouts, palettes, preloaders, resetAppearance, setAppearance, useAppearance, widths, } from "./appearance.ts";
2
+ export type { Appearance, Layout, Palette, Preloader, Width } from "./appearance.ts";
3
+ export { AppPreloader, PreloaderPreview } from "./preloader.tsx";
@@ -0,0 +1,2 @@
1
+ export { appearanceInitScript, defaultAppearance, layouts, palettes, preloaders, resetAppearance, setAppearance, useAppearance, widths, } from "./appearance.js";
2
+ export { AppPreloader, PreloaderPreview } from "./preloader.js";
@@ -0,0 +1,11 @@
1
+ import type { Preloader } from "./appearance.ts";
2
+ /**
3
+ * Full-screen loader for the first load. The saved choice is on `<html data-preloader>` before
4
+ * first paint, so CSS shows it right away; once the app has started it fades out. With no
5
+ * choice it never shows.
6
+ */
7
+ export declare function AppPreloader(): import("react").JSX.Element;
8
+ /** A short preview of a preloader, shown when it is picked in the customizer. */
9
+ export declare function PreloaderPreview({ kind }: Readonly<{
10
+ kind: Preloader | null;
11
+ }>): import("react").JSX.Element | null;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { Logo } from "../shell/logo.js";
4
+ /** Shortest time the preloader stays up, so it does not flash by. */
5
+ const MIN_VISIBLE_MS = 700;
6
+ /** The three animations. They are always in the markup; CSS shows the chosen one. */
7
+ function PreloaderArt() {
8
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "preloader-art", "data-kind": "rotating", children: _jsx(Logo, { className: "h-10 w-auto" }) }), _jsx("div", { className: "preloader-art", "data-kind": "spinning", children: _jsx("span", { className: "preloader-ring" }) }), _jsxs("div", { className: "preloader-art", "data-kind": "loading", children: [_jsx(Logo, { className: "h-8 w-auto" }), _jsx("span", { className: "preloader-bar" })] })] }));
9
+ }
10
+ /**
11
+ * Full-screen loader for the first load. The saved choice is on `<html data-preloader>` before
12
+ * first paint, so CSS shows it right away; once the app has started it fades out. With no
13
+ * choice it never shows.
14
+ */
15
+ export function AppPreloader() {
16
+ const [done, setDone] = useState(false);
17
+ useEffect(() => {
18
+ const timer = window.setTimeout(() => setDone(true), MIN_VISIBLE_MS);
19
+ return () => window.clearTimeout(timer);
20
+ }, []);
21
+ return (_jsx("div", { "aria-hidden": "true", "data-done": done, className: "app-preloader", children: _jsx(PreloaderArt, {}) }));
22
+ }
23
+ /** A short preview of a preloader, shown when it is picked in the customizer. */
24
+ export function PreloaderPreview({ kind }) {
25
+ if (!kind || kind === "none")
26
+ return null;
27
+ return (_jsx("div", { "aria-hidden": "true", "data-kind": kind, className: "app-preloader app-preloader-preview", children: _jsx(PreloaderArt, {}) }));
28
+ }
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from "react";
2
+ import type { NavGroup, SearchablePage, TrailEntry } from "./types.ts";
3
+ /**
4
+ * What the app gives the shell: its menu, how many unread things a menu item stands for, and pages that are
5
+ * not in the menu. A hook is passed for the badge so the app can read its own stores.
6
+ */
7
+ export type NavigationValue = {
8
+ main: readonly NavGroup[];
9
+ footer: readonly NavGroup[];
10
+ /** Called once per menu item on every render, so it must follow the rules of hooks. */
11
+ useBadgeCount: (to: string) => number;
12
+ extraTrail: readonly TrailEntry[];
13
+ extraPages: readonly SearchablePage[];
14
+ };
15
+ export declare function NavigationProvider({ children, main, footer, useBadgeCount, extraTrail, extraPages, }: Readonly<{
16
+ children: ReactNode;
17
+ main: readonly NavGroup[];
18
+ } & Partial<Omit<NavigationValue, "main">>>): import("react").JSX.Element;
19
+ export declare function useNavigation(): {
20
+ main: readonly NavGroup[];
21
+ footer: readonly NavGroup[];
22
+ pages: SearchablePage[];
23
+ findTrailEntry: (pathname: string) => TrailEntry | undefined;
24
+ };
25
+ export declare function useNavBadgeCount(to: string): number;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from "react";
3
+ import { findTrailEntry, searchablePages, trailEntries } from "./trail.js";
4
+ const empty = {
5
+ main: [],
6
+ footer: [],
7
+ useBadgeCount: () => 0,
8
+ extraTrail: [],
9
+ extraPages: [],
10
+ };
11
+ const NavigationContext = createContext(empty);
12
+ export function NavigationProvider({ children, main, footer = [], useBadgeCount = empty.useBadgeCount, extraTrail = [], extraPages = [], }) {
13
+ const value = useMemo(() => ({ main, footer, useBadgeCount, extraTrail, extraPages }), [main, footer, useBadgeCount, extraTrail, extraPages]);
14
+ return _jsx(NavigationContext.Provider, { value: value, children: children });
15
+ }
16
+ export function useNavigation() {
17
+ const value = useContext(NavigationContext);
18
+ return useMemo(() => {
19
+ const groups = [...value.main, ...value.footer];
20
+ const entries = trailEntries(groups, value.extraTrail);
21
+ return {
22
+ main: value.main,
23
+ footer: value.footer,
24
+ pages: searchablePages(groups, value.extraPages),
25
+ findTrailEntry: (pathname) => findTrailEntry(entries, pathname),
26
+ };
27
+ }, [value]);
28
+ }
29
+ export function useNavBadgeCount(to) {
30
+ return useContext(NavigationContext).useBadgeCount(to);
31
+ }
@@ -0,0 +1,5 @@
1
+ export { NavigationProvider, useNavBadgeCount, useNavigation } from "./context.tsx";
2
+ export type { NavigationValue } from "./context.tsx";
3
+ export { findTrailEntry, searchablePages, trailEntries } from "./trail.ts";
4
+ export { isNavParent } from "./types.ts";
5
+ export type { NavChild, NavGroup, NavItem, NavLeaf, NavParent, NavTo, SearchablePage, TrailEntry, } from "./types.ts";
@@ -0,0 +1,3 @@
1
+ export { NavigationProvider, useNavBadgeCount, useNavigation } from "./context.js";
2
+ export { findTrailEntry, searchablePages, trailEntries } from "./trail.js";
3
+ export { isNavParent } from "./types.js";
@@ -0,0 +1,10 @@
1
+ import type { NavGroup, SearchablePage, TrailEntry } from "./types.ts";
2
+ /** Every page in the menu with the headings above it. Pages outside the menu can be added with `extra`. */
3
+ export declare function trailEntries(groups: readonly NavGroup[], extra?: readonly TrailEntry[]): TrailEntry[];
4
+ /**
5
+ * The menu entry that owns a path. `/users/u2` belongs to `/users`: the longest entry whose path is the start of
6
+ * the current one wins.
7
+ */
8
+ export declare function findTrailEntry(entries: readonly TrailEntry[], pathname: string): TrailEntry | undefined;
9
+ /** Every page, submenus included, for the search dialog. */
10
+ export declare function searchablePages(groups: readonly NavGroup[], extra?: readonly SearchablePage[]): SearchablePage[];
@@ -0,0 +1,37 @@
1
+ import { isNavParent } from "./types.js";
2
+ /** Every page in the menu with the headings above it. Pages outside the menu can be added with `extra`. */
3
+ export function trailEntries(groups, extra = []) {
4
+ return [
5
+ ...groups.flatMap((group) => group.items.flatMap((item) => {
6
+ const above = group.label ? [group.label] : [];
7
+ return isNavParent(item)
8
+ ? item.children.map((child) => ({
9
+ parents: [...above, item.label],
10
+ label: child.label,
11
+ to: child.to,
12
+ icon: item.icon,
13
+ }))
14
+ : [{ parents: above, label: item.label, to: item.to, icon: item.icon }];
15
+ })),
16
+ ...extra,
17
+ ];
18
+ }
19
+ /**
20
+ * The menu entry that owns a path. `/users/u2` belongs to `/users`: the longest entry whose path is the start of
21
+ * the current one wins.
22
+ */
23
+ export function findTrailEntry(entries, pathname) {
24
+ const clean = pathname.replace(/\/+$/, "") || "/";
25
+ return entries
26
+ .filter((entry) => clean === entry.to || clean.startsWith(`${entry.to}/`))
27
+ .sort((a, b) => b.to.length - a.to.length)[0];
28
+ }
29
+ /** Every page, submenus included, for the search dialog. */
30
+ export function searchablePages(groups, extra = []) {
31
+ return [
32
+ ...groups.flatMap((group) => group.items.flatMap((item) => isNavParent(item)
33
+ ? item.children.map((child) => ({ ...child, icon: item.icon, group: item.label }))
34
+ : [{ label: item.label, to: item.to, icon: item.icon }])),
35
+ ...extra,
36
+ ];
37
+ }
@@ -0,0 +1,46 @@
1
+ import type { LucideIcon } from "lucide-react";
2
+ /** A path in the app. The app narrows it to its own route type where it wants to. */
3
+ export type NavTo = string;
4
+ export type NavChild = {
5
+ label: string;
6
+ to: NavTo;
7
+ };
8
+ /** A menu item that is a page. */
9
+ export type NavLeaf = {
10
+ label: string;
11
+ icon: LucideIcon;
12
+ to: NavTo;
13
+ /** A small tag next to the label, for example "Soon". */
14
+ badge?: string;
15
+ };
16
+ /** A menu item that opens a submenu. It is not a page itself. */
17
+ export type NavParent = {
18
+ label: string;
19
+ icon: LucideIcon;
20
+ children: NavChild[];
21
+ };
22
+ export type NavItem = NavLeaf | NavParent;
23
+ export declare const isNavParent: (item: NavItem) => item is NavParent;
24
+ /**
25
+ * A block of menu items. A group with a `label` shows it as a small uppercase heading; when the sidebar is
26
+ * collapsed the heading turns into a divider.
27
+ */
28
+ export type NavGroup = {
29
+ label?: string;
30
+ items: NavItem[];
31
+ };
32
+ export type SearchablePage = {
33
+ label: string;
34
+ to: NavTo;
35
+ icon: LucideIcon;
36
+ /** The parent menu item, shown next to the label. */
37
+ group?: string;
38
+ };
39
+ export type TrailEntry = {
40
+ /** Menu headings above the page. They are not pages. */
41
+ parents: string[];
42
+ label: string;
43
+ to: NavTo;
44
+ /** The menu icon of the page (or of its submenu), used for the icon tile in the page header. */
45
+ icon: LucideIcon;
46
+ };
@@ -0,0 +1 @@
1
+ export const isNavParent = (item) => "children" in item;
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from "react";
2
+ import type { Notification } from "./notification-types.ts";
3
+ export type NotificationsApi = {
4
+ items: Notification[];
5
+ unread: number;
6
+ open: (notification: Notification) => void;
7
+ markAllRead: () => void;
8
+ };
9
+ type UseNotifications = () => NotificationsApi;
10
+ /** The app supplies a hook that returns its notifications, so the shell never knows where they come from. */
11
+ export declare function NotificationsProvider({ children, useNotifications, }: Readonly<{
12
+ children: ReactNode;
13
+ useNotifications: UseNotifications;
14
+ }>): import("react").JSX.Element;
15
+ export declare function useNotifications(): NotificationsApi;
16
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const none = { items: [], unread: 0, open: () => { }, markAllRead: () => { } };
4
+ const NotificationsContext = createContext(() => none);
5
+ /** The app supplies a hook that returns its notifications, so the shell never knows where they come from. */
6
+ export function NotificationsProvider({ children, useNotifications, }) {
7
+ return (_jsx(NotificationsContext.Provider, { value: useNotifications, children: children }));
8
+ }
9
+ export function useNotifications() {
10
+ return useContext(NotificationsContext)();
11
+ }
@@ -0,0 +1,5 @@
1
+ export { NotificationsProvider, useNotifications } from "./context.tsx";
2
+ export type { NotificationsApi } from "./context.tsx";
3
+ export { NotificationsPanel } from "./notifications-panel.tsx";
4
+ export { typeInfo } from "./notification-types.ts";
5
+ export type { Notification, NotificationType } from "./notification-types.ts";
@@ -0,0 +1,3 @@
1
+ export { NotificationsProvider, useNotifications } from "./context.js";
2
+ export { NotificationsPanel } from "./notifications-panel.js";
3
+ export { typeInfo } from "./notification-types.js";
@@ -0,0 +1,6 @@
1
+ import type { Notification } from "./notification-types.ts";
2
+ /** One line in the bell's list: an icon, a type badge, who or what, and when. */
3
+ export declare function NotificationItem({ notification, onOpen, }: Readonly<{
4
+ notification: Notification;
5
+ onOpen: () => void;
6
+ }>): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { format, isSameDay } from "date-fns";
3
+ import { Badge } from "@ektyra/ui/components/badge";
4
+ import { cn } from "@ektyra/ui/lib/cn";
5
+ import { typeInfo } from "./notification-types.js";
6
+ const SAMPLE_DAY = new Date(2026, 10, 18);
7
+ const when = (date) => isSameDay(date, SAMPLE_DAY) ? format(date, "HH:mm") : format(date, "d MMM");
8
+ /** One line in the bell's list: an icon, a type badge, who or what, and when. */
9
+ export function NotificationItem({ notification, onOpen, }) {
10
+ const info = typeInfo[notification.type];
11
+ const Icon = info.icon;
12
+ return (_jsx("li", { children: _jsxs("button", { type: "button", onClick: onOpen, className: cn("flex w-full cursor-pointer items-start gap-3 rounded-lg p-3 text-left outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring", !notification.read && "bg-primary/5"), children: [_jsx("span", { className: "mt-0.5 grid size-8 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground", children: _jsx(Icon, { className: "size-4", "aria-hidden": "true" }) }), _jsxs("span", { className: "grid min-w-0 flex-1 grid-cols-[minmax(0,1fr)] gap-1", children: [_jsxs("span", { className: "flex items-center gap-2", children: [_jsx(Badge, { variant: info.variant, className: "px-1.5 py-0 text-[0.65rem]", children: info.label }), _jsx("span", { className: "ml-auto shrink-0 text-xs text-muted-foreground tabular-nums", children: when(notification.at) }), !notification.read && (_jsx("span", { className: "size-2 shrink-0 rounded-full bg-primary", children: _jsx("span", { className: "sr-only", children: "Unread" }) }))] }), _jsx("span", { className: cn("truncate text-sm", notification.read && "text-muted-foreground"), children: notification.title }), _jsx("span", { className: "line-clamp-2 text-xs text-muted-foreground", children: notification.text })] })] }) }));
13
+ }
@@ -0,0 +1,27 @@
1
+ import type { LucideIcon } from "lucide-react";
2
+ import type { badgeVariants } from "@ektyra/ui/components/badge";
3
+ import type { NavTo } from "../navigation/types.ts";
4
+ export type NotificationType = "email" | "chat" | "task" | "calendar" | "system" | "order";
5
+ export type Notification = {
6
+ id: string;
7
+ title: string;
8
+ text: string;
9
+ at: Date;
10
+ read: boolean;
11
+ /** How many unread things this stands for (a chat with three new messages). */
12
+ count: number;
13
+ /** Called when the notification is clicked, before going to the page. */
14
+ onOpen: () => void;
15
+ type: NotificationType;
16
+ to: NavTo;
17
+ /** Route parameters, when `to` has them. */
18
+ params?: Record<string, string>;
19
+ };
20
+ type Variant = NonNullable<Parameters<typeof badgeVariants>[0]>["variant"];
21
+ /** How each kind of notification looks: its label, icon and badge colour. */
22
+ export declare const typeInfo: Record<NotificationType, {
23
+ label: string;
24
+ icon: LucideIcon;
25
+ variant: Variant;
26
+ }>;
27
+ export {};
@@ -0,0 +1,10 @@
1
+ import { CalendarDays, Info, Kanban, Mail, MessageSquare, ShoppingCart } from "lucide-react";
2
+ /** How each kind of notification looks: its label, icon and badge colour. */
3
+ export const typeInfo = {
4
+ email: { label: "Email", icon: Mail, variant: "info" },
5
+ chat: { label: "Chat", icon: MessageSquare, variant: "success" },
6
+ task: { label: "Task", icon: Kanban, variant: "warning" },
7
+ calendar: { label: "Calendar", icon: CalendarDays, variant: "default" },
8
+ system: { label: "System", icon: Info, variant: "secondary" },
9
+ order: { label: "Order", icon: ShoppingCart, variant: "info" },
10
+ };
@@ -0,0 +1,10 @@
1
+ import type { Notification } from "./notification-types.ts";
2
+ type NotificationsPanelProps = Readonly<{
3
+ items: Notification[];
4
+ unread: number;
5
+ onOpen: (notification: Notification) => void;
6
+ onMarkAllRead: () => void;
7
+ }>;
8
+ /** What opens from the bell: a header with "Mark all as read", then the latest notifications. */
9
+ export declare function NotificationsPanel({ items, unread, onOpen, onMarkAllRead, }: NotificationsPanelProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { BellOff } from "lucide-react";
3
+ import { Badge } from "@ektyra/ui/components/badge";
4
+ import { Button } from "@ektyra/ui/components/button";
5
+ import { NotificationItem } from "./notification-item.js";
6
+ /** What opens from the bell: a header with "Mark all as read", then the latest notifications. */
7
+ export function NotificationsPanel({ items, unread, onOpen, onMarkAllRead, }) {
8
+ return (_jsxs("div", { className: "flex max-h-[min(32rem,calc(100dvh-6rem))] flex-col", children: [_jsxs("div", { className: "flex items-center gap-2 border-b border-border px-4 py-3", children: [_jsx("h2", { className: "text-sm", children: "Notifications" }), unread > 0 && _jsxs(Badge, { children: [unread, " new"] }), _jsx(Button, { variant: "ghost", size: "sm", className: "ml-auto", disabled: unread === 0, onClick: onMarkAllRead, children: "Mark all as read" })] }), items.length === 0 ? (_jsxs("div", { className: "grid place-items-center gap-2 px-6 py-12 text-center text-sm text-muted-foreground", children: [_jsx(BellOff, { className: "size-6", "aria-hidden": "true" }), "You are all caught up."] })) : (_jsx("ul", { className: "scrollbar-primary min-h-0 flex-1 overflow-y-auto p-2", "aria-label": "Latest notifications", children: items.map((notification) => (_jsx(NotificationItem, { notification: notification, onOpen: () => onOpen(notification) }, notification.id))) }))] }));
9
+ }
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from "react";
2
+ /** The title block at the top of an auth form: an optional icon, a heading and a line of help. */
3
+ export declare function AuthHeading({ title, description, icon, }: Readonly<{
4
+ title: string;
5
+ description: ReactNode;
6
+ icon?: ReactNode;
7
+ }>): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /** The title block at the top of an auth form: an optional icon, a heading and a line of help. */
3
+ export function AuthHeading({ title, description, icon, }) {
4
+ return (_jsxs("div", { className: "grid gap-3", children: [icon && (_jsx("span", { className: "grid size-11 place-items-center rounded-xl bg-primary/10 text-primary [&_svg]:size-5", children: icon })), _jsx("h1", { className: "text-3xl tracking-tight", children: title }), _jsx("p", { className: "text-muted-foreground", children: description })] }));
5
+ }
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * The layout for sign-in style pages: no sidebar, no navbar. A split screen where
4
+ * the form side is the narrower one and the picture side runs the full height of
5
+ * the page (it hides on small screens). Pages put their content in `<Outlet />`;
6
+ * the three selling points sit under it on every auth page. `aside` is the picture side (a promo panel).
7
+ */
8
+ export declare function AuthLayout({ aside }: Readonly<{
9
+ aside?: ReactNode;
10
+ }>): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Link, Outlet } from "@tanstack/react-router";
3
+ import { Logo } from "../logo.js";
4
+ import { AuthThemeToggle } from "./auth-theme-toggle.js";
5
+ import { AuthUsps } from "./auth-usps.js";
6
+ /**
7
+ * The layout for sign-in style pages: no sidebar, no navbar. A split screen where
8
+ * the form side is the narrower one and the picture side runs the full height of
9
+ * the page (it hides on small screens). Pages put their content in `<Outlet />`;
10
+ * the three selling points sit under it on every auth page. `aside` is the picture side (a promo panel).
11
+ */
12
+ export function AuthLayout({ aside }) {
13
+ return (_jsxs("div", { className: "grid min-h-dvh lg:grid-cols-[minmax(36rem,5fr)_7fr]", children: [_jsxs("div", { className: "flex min-h-dvh flex-col px-6 py-8 sm:px-12 lg:px-12", children: [_jsxs("header", { className: "mx-auto flex w-full max-w-lg items-center justify-between", children: [_jsx(Link, { to: "/", "aria-label": "Ektyra, go to the app", children: _jsx(Logo, { className: "h-8 w-auto" }) }), _jsx(AuthThemeToggle, {})] }), _jsxs("div", { className: "mx-auto flex w-full max-w-lg flex-1 flex-col justify-center gap-10 py-10", children: [_jsx("main", { className: "flex min-w-0 flex-col gap-8", children: _jsx(Outlet, {}) }), _jsx(AuthUsps, {})] }), _jsxs("footer", { className: "mx-auto flex w-full max-w-lg flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground", children: [_jsx("span", { children: "\u00A9 2026 Ektyra" }), _jsx(Link, { to: "/", className: "transition-colors hover:text-foreground", children: "Back to the app" })] })] }), aside] }));
14
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Flips between light and dark. Both icons are always in the page and CSS shows
3
+ * the right one, so the server and the browser agree and nothing flashes.
4
+ */
5
+ export declare function AuthThemeToggle(): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Moon, Sun } from "lucide-react";
3
+ import { IconButton } from "@ektyra/ui/components/icon-button";
4
+ import { useTheme } from "@ektyra/ui/theme";
5
+ /**
6
+ * Flips between light and dark. Both icons are always in the page and CSS shows
7
+ * the right one, so the server and the browser agree and nothing flashes.
8
+ */
9
+ export function AuthThemeToggle() {
10
+ const { resolvedTheme, setTheme } = useTheme();
11
+ return (_jsxs(IconButton, { label: "Toggle light and dark theme", onClick: () => setTheme(resolvedTheme === "dark" ? "light" : "dark"), children: [_jsx(Moon, { className: "dark:hidden", "aria-hidden": "true" }), _jsx(Sun, { className: "hidden dark:block", "aria-hidden": "true" })] }));
12
+ }
@@ -0,0 +1,2 @@
1
+ /** Three short selling points under the form, separated by thin lines. */
2
+ export declare function AuthUsps(): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { LayoutGrid, Layers, Users } from "lucide-react";
3
+ const usps = [
4
+ { icon: Users, title: "Built for teams", text: "Collaborate, review, and publish together." },
5
+ { icon: Layers, title: "Flexible roles", text: "Give each teammate the right level of access." },
6
+ {
7
+ icon: LayoutGrid,
8
+ title: "Multi-site management",
9
+ text: "Run and grow multiple sites from one workspace.",
10
+ },
11
+ ];
12
+ /** Three short selling points under the form, separated by thin lines. */
13
+ export function AuthUsps() {
14
+ return (_jsx("ul", { className: "grid gap-6 sm:grid-cols-3 sm:gap-0 sm:divide-x sm:divide-border", children: usps.map(({ icon: Icon, title, text }) => (_jsxs("li", { className: "grid content-start gap-2 sm:px-4 sm:first:pl-0 sm:last:pr-0", children: [_jsx(Icon, { className: "size-5 text-primary", "aria-hidden": "true" }), _jsx("p", { className: "text-sm", children: title }), _jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: text })] }, title))) }));
15
+ }
@@ -0,0 +1,2 @@
1
+ export { AuthHeading } from "./auth-heading.tsx";
2
+ export { AuthLayout } from "./auth-layout.tsx";
@@ -0,0 +1,2 @@
1
+ export { AuthHeading } from "./auth-heading.js";
2
+ export { AuthLayout } from "./auth-layout.js";
@@ -0,0 +1,2 @@
1
+ /** Light, dark or follow the device. Used by the theme customizer and the preferences page. */
2
+ export declare function ColorSchemeChoice(): import("react").JSX.Element;