@sevenfold/setto-client 0.32.0 → 0.33.1

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.
@@ -3,8 +3,13 @@ import type { ThemeStore } from '../lib/theme-store';
3
3
  interface EditModeShellProps {
4
4
  children: ReactNode;
5
5
  themeStore: ThemeStore | null;
6
- /** When false, children render unchanged — no portals or document layout. */
6
+ /** Editing: the document layout, the section tools and the link hint. */
7
7
  active: boolean;
8
+ /**
9
+ * The Setto menu, which an owner has whether or not they are editing: out of
10
+ * edit mode it is only the pencil. Defaults to `active`.
11
+ */
12
+ menu?: boolean;
8
13
  }
9
14
  /**
10
15
  * Edit mode: full-width page with a floating Setto FAB anchored bottom-left.
@@ -13,7 +18,7 @@ interface EditModeShellProps {
13
18
  * Always mounted around the host app so toggling edit mode does not remount
14
19
  * page content (which would replay GSAP / scroll-driven animations).
15
20
  */
16
- export declare function EditModeShell({ children, themeStore, active }: EditModeShellProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function EditModeShell({ children, themeStore, active, menu }: EditModeShellProps): import("react/jsx-runtime").JSX.Element;
17
22
  /** @deprecated Use EditModeShell */
18
23
  export declare const EditModeMount: typeof EditModeShell;
19
24
  export {};
@@ -30,6 +30,8 @@ export declare class PageStore {
30
30
  constructor(initial: PagesManifest | null);
31
31
  snapshot(): PageStoreSnapshot;
32
32
  subscribe(listener: Listener): () => void;
33
+ /** The manifest as published, to tell which sections the owner changed. */
34
+ get baselineManifest(): PagesManifest | null;
33
35
  get manifest(): PagesManifest | null;
34
36
  /** True once the site has a manifest to edit. */
35
37
  has(): boolean;
@@ -0,0 +1,71 @@
1
+ import { type CSSProperties } from 'react';
2
+ /**
3
+ * Barista in the site's own colours, light or dark as the page is now
4
+ * (Simon, 2026-09-25).
5
+ *
6
+ * It used to take the brand colours by position — the first was the soft
7
+ * surface, the fourth the text — which was setto.no's own order and nobody
8
+ * else's: one site got a purple canvas, and the many that write their brand
9
+ * colours as `hsl(var(--primary))` got setto.no's coffee instead. And it had
10
+ * no dark mode at all.
11
+ *
12
+ * So it reads the page, as the page is drawn right now:
13
+ *
14
+ * 1. A site with the shadcn tokens (every template since August) is read by
15
+ * role — `--background`, `--card`, `--muted`, `--foreground`,
16
+ * `--primary` and `--primary-foreground` — resolved on `<html>`,
17
+ * so `.dark` is already applied.
18
+ * 2. Otherwise the page's own ground and text: the computed background and
19
+ * colour of `<body>`, and the accent picked from the brand colours as the
20
+ * most colourful one that stands out from that ground.
21
+ * 3. Otherwise Setto's crema and terracotta.
22
+ *
23
+ * Read again whenever `<html>` or `<body>` changes class, style or data (a
24
+ * theme toggle, `data-sky`) and when the
25
+ * system switches light and dark.
26
+ */
27
+ export interface ChatPalette {
28
+ canvas: string;
29
+ raised: string;
30
+ crema: string;
31
+ ink: string;
32
+ accent: string;
33
+ onAccent: string;
34
+ dark: boolean;
35
+ }
36
+ type Rgba = [number, number, number, number];
37
+ export declare const FALLBACK: ChatPalette;
38
+ export declare function paletteStyle(p: ChatPalette): CSSProperties;
39
+ export declare function rgbString([r, g, b, a]: Rgba): string;
40
+ export declare function luminance([r, g, b]: Rgba): number;
41
+ export declare function contrast(a: Rgba, b: Rgba): number;
42
+ /** How colourful: the spread of the channels, 0 for a grey. */
43
+ export declare function chroma([r, g, b]: Rgba): number;
44
+ /** `a` over `b`, `amount` of the way. */
45
+ export declare function mix(a: Rgba, b: Rgba, amount: number): Rgba;
46
+ /** A shadcn token as a CSS colour: a bare `h s% l%` triplet (with or without `/ alpha`), or a colour already. */
47
+ export declare function tokenColor(raw: string): string | null;
48
+ /**
49
+ * The palette for a ground, a text colour, the site's tokens where it has
50
+ * them, and brand colours to take an accent from where it has not. Pure: the
51
+ * hook below does the reading.
52
+ */
53
+ export declare function buildPalette(input: {
54
+ background: Rgba | null;
55
+ foreground: Rgba | null;
56
+ card?: Rgba | null;
57
+ muted?: Rgba | null;
58
+ primary?: Rgba | null;
59
+ primaryForeground?: Rgba | null;
60
+ brand?: Rgba[];
61
+ }): ChatPalette;
62
+ /** Any CSS colour the browser understands, as sRGB: drawn on one pixel and read back. */
63
+ export declare function toRgba(color: string | null | undefined): Rgba | null;
64
+ export declare function readPalette(brandColors: Array<{
65
+ value: string;
66
+ }> | undefined): ChatPalette;
67
+ /** The palette, kept in step with the page's light and dark. */
68
+ export declare function useSitePalette(brandColors: Array<{
69
+ value: string;
70
+ }> | undefined): CSSProperties;
71
+ export {};
@@ -13,8 +13,20 @@ export interface SettoContextValue {
13
13
  session: Session | null;
14
14
  /** True while the initial auth state is being read from local storage. */
15
15
  authLoading: boolean;
16
- /** True when inline edit mode is active (session + site access). */
16
+ /**
17
+ * True while the owner is editing: `canEdit`, and they chose to edit. What
18
+ * makes text editable, shows hidden sections and draws the section tools.
19
+ */
17
20
  editMode: boolean;
21
+ /**
22
+ * True when this person may edit this site: signed in, a member, the site is
23
+ * paid for, and this is not `/setto`. The Setto menu is drawn whenever this
24
+ * is; outside `editMode` it shows the site as a visitor sees it.
25
+ * Absent on a client older than 0.33, where `editMode` meant this.
26
+ */
27
+ canEdit: boolean;
28
+ /** Switch editing on or off. Remembered for this site in this browser. */
29
+ setEditing: (on: boolean) => void;
18
30
  /** Site row matching `config.siteId`, or `null` if the user has no access. */
19
31
  currentSite: SiteRow | null;
20
32
  /** All sites the user can access (loaded after sign-in). */
@@ -65,13 +77,15 @@ export interface SettoProviderProps {
65
77
  * Wraps the host app. Initialises Supabase, the API client, and listens for
66
78
  * auth changes. Mounts the edit toolbar and enables inline editing when active.
67
79
  *
68
- * Edit mode is on when ALL of:
80
+ * The owner may edit (`canEdit`) when ALL of:
69
81
  * 1. There is an authenticated Supabase session.
70
82
  * 2. The user has access to `config.siteId` in the Setto sites table.
71
- * 3. The current path is not the `/setto` admin SPA.
83
+ * 3. The site is paid for (`live`).
84
+ * 4. The current path is not the `/setto` admin SPA.
72
85
  *
73
- * Once an editor signs in via `/setto`, returning visits auto-enter edit mode
74
- * for as long as the Supabase session persists.
86
+ * Once an editor signs in via `/setto` they stay signed in until they sign out
87
+ * there. Whether they are editing is their own switch (`setEditing`): the
88
+ * Setto menu's pencil turns it on, and publishing turns it off.
75
89
  */
76
90
  export declare function SettoProvider({ config, children }: SettoProviderProps): import("react/jsx-runtime").JSX.Element;
77
91
  export declare function useSetto(): SettoContextValue;