@ai-matrx/records-ui 0.116.66 → 0.116.68

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 (33) hide show
  1. package/CHANGELOG.md +73 -42
  2. package/dist/{SaveToTable-OYJH3OKN.js → SaveToTable-GU4RF65M.js} +3 -3
  3. package/dist/{chunk-O5K6Y3N3.js → chunk-4CI2HLX3.js} +1 -1
  4. package/dist/chunk-4CI2HLX3.js.map +1 -0
  5. package/dist/{chunk-NBL26U5K.js → chunk-6BTGCYPK.js} +2 -2
  6. package/dist/{chunk-EACZUXJO.js → chunk-6Q2RJEN5.js} +2 -2
  7. package/dist/{chunk-57CGHFPO.js → chunk-BWVNQYNC.js} +9 -9
  8. package/dist/chunk-BWVNQYNC.js.map +1 -0
  9. package/dist/{chunk-TEYXG4XD.js → chunk-K7OX6RG6.js} +1 -1
  10. package/dist/chunk-K7OX6RG6.js.map +1 -0
  11. package/dist/{chunk-W6FX3XVF.js → chunk-QNI75ZHU.js} +2 -2
  12. package/dist/helpers.cjs.map +1 -1
  13. package/dist/helpers.js.map +1 -1
  14. package/dist/html-frame.cjs.map +1 -1
  15. package/dist/html-frame.js +1 -1
  16. package/dist/index.cjs +64 -51
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +9 -3
  19. package/dist/index.d.ts +9 -3
  20. package/dist/index.js +73 -60
  21. package/dist/index.js.map +1 -1
  22. package/dist/pickers.cjs +4 -4
  23. package/dist/pickers.cjs.map +1 -1
  24. package/dist/pickers.js +4 -4
  25. package/dist/skeleton.js +3 -3
  26. package/package.json +5 -5
  27. package/dist/chunk-57CGHFPO.js.map +0 -1
  28. package/dist/chunk-O5K6Y3N3.js.map +0 -1
  29. package/dist/chunk-TEYXG4XD.js.map +0 -1
  30. /package/dist/{SaveToTable-OYJH3OKN.js.map → SaveToTable-GU4RF65M.js.map} +0 -0
  31. /package/dist/{chunk-NBL26U5K.js.map → chunk-6BTGCYPK.js.map} +0 -0
  32. /package/dist/{chunk-EACZUXJO.js.map → chunk-6Q2RJEN5.js.map} +0 -0
  33. /package/dist/{chunk-W6FX3XVF.js.map → chunk-QNI75ZHU.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/htmlFrameEntry.ts","../src/looks/htmlFrame.tsx"],"sourcesContent":["// src/htmlFrameEntry.ts — @ai-matrx/records-ui/html-frame · the seamless, sandboxed, auto-height HTML\n// frame alone (react + cn), for a host that draws written HTML without loading a screen.\nexport {\n HTML_SAMPLE_CSP,\n HTML_SAMPLE_SANDBOX,\n SAMPLE_TOKEN_NAMES,\n HtmlSampleFrame,\n HtmlSampleTokensProvider,\n TokenScope,\n fontLink,\n forwardWheel,\n hexToHslTriplet,\n hostTheme,\n hostTokens,\n sampleDocument,\n sampleHeight,\n sampleStyle,\n tokenScopeStyle,\n tokenValue,\n useHostTheme,\n useSampleTokens,\n type HtmlSampleFrameProps,\n type SampleTheme,\n type SampleTokenSet,\n type SampleTokens,\n} from \"./looks/htmlFrame\";\n","\"use client\";\n\n// src/looks/htmlFrame.tsx — @ai-matrx/records-ui · THE SEAMLESS HTML FRAME (light: react + cn only)\n//\n// Shipped alone as `@ai-matrx/records-ui/html-frame`, so a host draws written HTML (the board's\n// Cover hero) without loading a screen. The html_sample look (htmlLook.tsx) draws its samples in it.\n// What the frame allows and why: see htmlLook.tsx's header.\n\nimport { createContext, useContext, useEffect, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { cn } from \"@ai-matrx/design-system/cn\";\n/** The sandbox the frame wears. Markup and CSS only: never `allow-scripts` (see the header). */\nexport const HTML_SAMPLE_SANDBOX = \"allow-same-origin\";\n\n/** What a sample may load: inline styles, and images and fonts from data or https. Nothing else. */\nexport const HTML_SAMPLE_CSP =\n \"default-src 'none'; style-src 'unsafe-inline' https://fonts.googleapis.com; img-src data: blob: https:; font-src data: https:; media-src data: https:; script-src 'none'; connect-src 'none'; form-action 'none'\";\n\n/** The token names every sample can use as `var(--name)`. The agent skill names the same list. */\nexport const SAMPLE_TOKEN_NAMES = [\n \"background\",\n \"foreground\",\n \"card\",\n \"card-foreground\",\n \"popover\",\n \"popover-foreground\",\n \"muted\",\n \"muted-foreground\",\n \"primary\",\n \"primary-foreground\",\n \"secondary\",\n \"secondary-foreground\",\n \"accent\",\n \"accent-foreground\",\n \"destructive\",\n \"destructive-foreground\",\n \"success\",\n \"warning\",\n \"border\",\n \"input\",\n \"ring\",\n \"radius\",\n] as const;\n\nexport type SampleTheme = \"light\" | \"dark\";\n/** Token values by name, without the leading dashes: `{ primary: \"#1f4fe0\", radius: \"8px\" }`. */\nexport type SampleTokens = Readonly<Record<string, string>>;\nexport interface SampleTokenSet {\n light?: SampleTokens;\n dark?: SampleTokens;\n /** Web font families the samples name (a board's type styles); loaded from Google Fonts. */\n fonts?: readonly string[];\n}\n\n/** Families that are the system's own and need no loading. */\nconst SYSTEM_FAMILY = /^(system-ui|ui-[a-z-]+|-apple-system|blinkmacsystemfont|serif|sans-serif|monospace|cursive|fantasy|georgia|arial|helvetica|helvetica neue|times|times new roman|courier|courier new|verdana|tahoma|segoe ui|roboto mono|sf pro.*|menlo|monaco|consolas)$/i;\n\n/** The one stylesheet link that loads these families, or \"\" when none needs loading. */\nexport function fontLink(fonts: readonly string[] | undefined): string {\n const families = [...new Set((fonts ?? []).map((f) => f.trim()).filter((f) => /^[A-Za-z0-9 ]{2,40}$/.test(f) && !SYSTEM_FAMILY.test(f)))].slice(0, 8);\n if (families.length === 0) return \"\";\n const q = families.map((f) => `family=${f.replace(/ /g, \"+\")}:ital,wght@0,300..800;1,300..800`).join(\"&\");\n return `<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?${q}&display=swap\">`;\n}\n\nconst TokensContext = createContext<SampleTokenSet | null>(null);\n\n/** A host's own token values for every sample under it (a board's design-system tables). */\nexport function HtmlSampleTokensProvider({ tokens, children }: { tokens: SampleTokenSet | null; children: ReactNode }) {\n return <TokensContext.Provider value={tokens}>{children}</TokensContext.Provider>;\n}\n\n/** The token set a host provided for the samples under it (a board's design-system tables), or null. */\nexport function useSampleTokens(): SampleTokenSet | null {\n return useContext(TokensContext);\n}\n\n/** A hex color as the app's bare HSL triplet (\"210 80% 45%\"), or null for anything else. */\nexport function hexToHslTriplet(hex: string): string | null {\n const m = /^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(hex.trim());\n if (!m) return null;\n const n = parseInt(m[1]!, 16);\n const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((c) => c / 255) as [number, number, number];\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n const d = max - min;\n let h = 0;\n const sat = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));\n if (d !== 0) {\n if (max === r) h = ((g - b) / d) % 6;\n else if (max === g) h = (b - r) / d + 2;\n else h = (r - g) / d + 4;\n h *= 60;\n if (h < 0) h += 360;\n }\n const round = (x: number) => Math.round(x * 10) / 10;\n return `${round(h)} ${round(sat * 100)}% ${round(l * 100)}%`;\n}\n\n/**\n * The CSS variables that put app content (prose, controls) into the provided design system for one theme:\n * each color token the app keeps as an HSL triplet is overridden with the board's color, and the text takes\n * the board's body font. Nothing outside the scope changes.\n */\nexport function tokenScopeStyle(set: SampleTokenSet | null, theme: SampleTheme): Record<string, string> {\n const tokens = set?.[theme] ?? {};\n const out: Record<string, string> = {};\n for (const name of SAMPLE_TOKEN_NAMES) {\n const value = tokens[name];\n const triplet = value ? hexToHslTriplet(value) : null;\n if (triplet) out[`--${name}`] = triplet;\n }\n const safe = (v: string | undefined) => (v && !/[;{}<>]/.test(v) ? v : undefined);\n const body = safe(tokens[\"font-body\"]);\n if (body) {\n out.fontFamily = body;\n // The app's sans classes read these (Tailwind's `--font-sans`, the design system's typography token).\n out[\"--font-sans\"] = body;\n out[\"--typography-fontFamily-sans\"] = body;\n }\n // The scope paints the board's own ground, so the board's colors are read on the board's background in\n // both themes (a dark primary heading is never left on the app's card).\n const ground = safe(tokens[\"card\"]) ?? safe(tokens[\"background\"]);\n if (ground) out.backgroundColor = ground;\n // Text is the board's foreground; the app's accent hue (the blue a shared renderer's headings, links and\n // emphasis use) becomes the board's primary and link: inside the scope only, never the app's own pages.\n const fg = safe(tokens[\"foreground\"]);\n if (fg) out.color = fg;\n const primary = safe(tokens[\"primary\"]);\n const link = safe(tokens[\"link\"]) ?? primary;\n if (primary) {\n out[\"--color-blue-400\"] = primary;\n out[\"--color-blue-500\"] = primary;\n }\n if (link) out[\"--color-blue-600\"] = link;\n const display = safe(tokens[\"font-display\"]) ?? safe(tokens[\"font-title\"]);\n if (display) out[\"--token-scope-heading-font\"] = display;\n return out;\n}\n\n/** The host page's theme, followed as it changes. */\nexport function useHostTheme(): SampleTheme {\n const [theme, setTheme] = useState<SampleTheme>(() => hostTheme());\n useEffect(() => {\n if (typeof MutationObserver === \"undefined\" || typeof document === \"undefined\") return;\n const watch = new MutationObserver(() => setTheme(hostTheme()));\n watch.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\", \"data-theme\"] });\n return () => watch.disconnect();\n }, []);\n return theme;\n}\n\n/**\n * APP CONTENT IN THE HOST'S DESIGN SYSTEM: everything under it (a cover's prose, a card's text) draws with the\n * provided tokens (a board's own colors and body font) in the page's current theme. No provided tokens: it is\n * a plain wrapper and the app's own tokens apply.\n */\nexport function TokenScope({ className, children }: { className?: string; children: ReactNode }) {\n const set = useSampleTokens();\n const theme = useHostTheme();\n const style = tokenScopeStyle(set, theme);\n return (\n <div data-token-scope={set ? \"\" : undefined} className={className} style={style as CSSProperties}>\n {/* Headings take the board's display font (a plain style can't reach them; scoped to this element only). */}\n {style[\"--token-scope-heading-font\"] ? (\n <style>{\"[data-token-scope] :is(h1,h2,h3,h4,h5,h6){font-family:var(--token-scope-heading-font)}\"}</style>\n ) : null}\n {children}\n </div>\n );\n}\n\n/** A bare HSL triplet (\"240 5% 96%\", how the app keeps its colors) becomes a color a sample can use. */\nexport function tokenValue(raw: string): string {\n const v = raw.trim();\n return /^-?\\d+(\\.\\d+)?(deg)?\\s+\\d+(\\.\\d+)?%\\s+\\d+(\\.\\d+)?%(\\s*\\/\\s*[\\d.]+%?)?$/.test(v) ? `hsl(${v})` : v;\n}\n\n/** The host page's theme: `dark` when its root wears the `dark` class or `data-theme=\"dark\"`. */\nexport function hostTheme(doc: Document | undefined = typeof document === \"undefined\" ? undefined : document): SampleTheme {\n const root = doc?.documentElement;\n if (!root) return \"light\";\n return root.classList.contains(\"dark\") || root.dataset.theme === \"dark\" ? \"dark\" : \"light\";\n}\n\n/** The host page's own token values, read from where the frame sits (so a themed region counts). */\nexport function hostTokens(at: Element | null): Record<string, string> {\n const out: Record<string, string> = {};\n if (!at || typeof getComputedStyle === \"undefined\") return out;\n const style = getComputedStyle(at);\n for (const name of SAMPLE_TOKEN_NAMES) {\n const raw = style.getPropertyValue(`--${name}`);\n if (raw && raw.trim()) out[name] = tokenValue(raw);\n }\n return out;\n}\n\n/** The `:root` block a sample reads its tokens from, plus the frame's own seamless reset. */\nexport function sampleStyle(tokens: SampleTokens, theme: SampleTheme, font?: string): string {\n const vars = Object.entries(tokens)\n .filter(([name, value]) => /^[a-z][a-z0-9-]*$/.test(name) && !/[;{}<>]/.test(value))\n .map(([name, value]) => `--${name}:${value};`)\n .join(\"\");\n const family = font && !/[;{}<>]/.test(font) ? font : \"system-ui, sans-serif\";\n return (\n `:root{${vars}color-scheme:${theme};}` +\n `html,body{margin:0;padding:0;background:transparent;overflow:hidden;}` +\n // bare-hsl-ok: the sample frame's :root holds full colours (tokenValue wraps each triple in hsl())\n `body{color:var(--foreground,${theme === \"dark\" ? \"#e8ebf1\" : \"#111827\"});font-family:${family};font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;}` +\n `*,*::before,*::after{box-sizing:border-box;}` +\n `#matrx-sample{display:flow-root;}`\n );\n}\n\n/** The whole document the frame draws: CSP, tokens, the reset, and the sample inside one measured box. */\nexport function sampleDocument(html: string, tokens: SampleTokens, theme: SampleTheme, font?: string, fonts?: readonly string[]): string {\n return (\n `<!doctype html><html class=\"${theme}\" style=\"color-scheme:${theme}\"><head><meta charset=\"utf-8\">` +\n `<meta http-equiv=\"Content-Security-Policy\" content=\"${HTML_SAMPLE_CSP}\">` +\n fontLink(fonts) +\n `<meta name=\"color-scheme\" content=\"${theme}\">` +\n `<style id=\"matrx-sample-tokens\">${sampleStyle(tokens, theme, font)}</style>` +\n `</head><body><div id=\"matrx-sample\">${html}</div></body></html>`\n );\n}\n\n/** A wheel inside a sample, re-dispatched on the frame element so the page or board around it scrolls. */\nexport function forwardWheel(target: HTMLIFrameElement | null, e: WheelEvent): void {\n if (!target) return;\n const r = target.getBoundingClientRect();\n target.dispatchEvent(\n new WheelEvent(\"wheel\", {\n bubbles: true,\n cancelable: true,\n deltaX: e.deltaX,\n deltaY: e.deltaY,\n deltaZ: e.deltaZ,\n deltaMode: e.deltaMode,\n clientX: r.left + e.clientX,\n clientY: r.top + e.clientY,\n ctrlKey: e.ctrlKey,\n metaKey: e.metaKey,\n shiftKey: e.shiftKey,\n altKey: e.altKey,\n }),\n );\n}\n\n/** The sample's drawn height in px, from its one measured box (margins included: it is a flow root). */\nexport function sampleHeight(doc: Document | null | undefined): number {\n const box = doc?.getElementById(\"matrx-sample\");\n if (!box) return 0;\n return Math.ceil(box.getBoundingClientRect().height || box.scrollHeight || 0);\n}\n\nexport interface HtmlSampleFrameProps {\n html: string;\n /** What a screen reader calls the frame. */\n title?: string;\n className?: string;\n /** Height before the sample has been measured, so the page does not jump when it loads. Default 24. */\n initialHeight?: number;\n}\n\n/**\n * THE SEAMLESS SAMPLE FRAME — markup and CSS only, transparent, borderless, as tall as its content,\n * with the host's tokens and theme. See the file header for what the sandbox allows.\n */\nexport function HtmlSampleFrame({ html, title = \"Sample\", className, initialHeight = 24 }: HtmlSampleFrameProps) {\n const frame = useRef<HTMLIFrameElement | null>(null);\n const given = useContext(TokensContext);\n const [height, setHeight] = useState(initialHeight);\n const [theme, setTheme] = useState<SampleTheme>(() => hostTheme());\n // The document is built once per html; a theme or token change after that is written into the\n // live frame (`paint`), never a reload.\n const fontsKey = (given?.fonts ?? []).join(\"|\");\n const [doc, setDoc] = useState(() => sampleDocument(html, given?.[theme] ?? {}, theme, undefined, given?.fonts));\n const built = useRef(`${html}\\u0000${fontsKey}`);\n\n const tokensFor = (t: SampleTheme): Record<string, string> => ({ ...hostTokens(frame.current), ...(given?.[t] ?? {}) });\n const fontOf = () => (frame.current && typeof getComputedStyle !== \"undefined\" ? getComputedStyle(frame.current).fontFamily : undefined);\n\n // A new html: a new document, opened in today's theme with today's tokens.\n // New fonts to load also rebuild (a stylesheet link is part of the document head).\n useEffect(() => {\n const key = `${html}\\u0000${fontsKey}`;\n if (built.current === key) return;\n built.current = key;\n setDoc(sampleDocument(html, tokensFor(theme), theme, fontOf(), given?.fonts));\n // eslint-disable-next-line react-hooks/exhaustive-deps -- the theme and tokens are written live below\n }, [html, fontsKey]);\n\n // The host's theme, followed as it changes.\n useEffect(() => {\n if (typeof MutationObserver === \"undefined\" || typeof document === \"undefined\") return;\n const watch = new MutationObserver(() => setTheme(hostTheme()));\n watch.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\", \"data-theme\"] });\n return () => watch.disconnect();\n }, []);\n\n const measure = () => {\n const h = sampleHeight(frame.current?.contentDocument);\n if (h > 0) setHeight(h);\n };\n\n // Write the theme and tokens into the live document (same origin, no script inside it).\n const paint = () => {\n const inner = frame.current?.contentDocument;\n if (!inner?.documentElement) return;\n const style = inner.getElementById(\"matrx-sample-tokens\");\n if (style) style.textContent = sampleStyle(tokensFor(theme), theme, fontOf());\n inner.documentElement.className = theme;\n inner.documentElement.style.colorScheme = theme;\n measure();\n };\n\n useEffect(paint, [theme, given]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // The width the frame is given changes the sample's height (text wraps): measure again.\n useEffect(() => {\n const el = frame.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => measure());\n ro.observe(el);\n return () => ro.disconnect();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const onLoad = () => {\n paint();\n const inner = frame.current?.contentDocument;\n if (!inner) return;\n // Late images and fonts change the height after load.\n inner.addEventListener(\"load\", measure, true);\n void inner.fonts?.ready.then(measure).catch(() => undefined);\n const box = inner.getElementById(\"matrx-sample\");\n const View = inner.defaultView as (Window & { ResizeObserver?: typeof ResizeObserver }) | null;\n if (box && View?.ResizeObserver) new View.ResizeObserver(() => measure()).observe(box);\n // The sample never scrolls (it is as tall as its content), so a wheel over it belongs to the page or\n // board around it: hand it on to the frame element, where the host's own wheel handling sees it.\n inner.addEventListener(\"wheel\", (e) => forwardWheel(frame.current, e), { passive: true });\n };\n\n return (\n <iframe\n ref={frame}\n title={title}\n aria-label={title}\n data-records-html-sample=\"\"\n sandbox={HTML_SAMPLE_SANDBOX}\n referrerPolicy=\"no-referrer\"\n srcDoc={doc}\n onLoad={onLoad}\n scrolling=\"no\"\n className={cn(\"block w-full border-0 bg-transparent\", className)}\n style={{ height: `${height}px`, colorScheme: theme, overflow: \"hidden\" }}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQA,mBAA2G;AAC3G,gBAAmB;AA2DV;AAzDF,IAAM,sBAAsB;AAG5B,IAAM,kBACX;AAGK,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAaA,IAAM,gBAAg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AC;AAAA,EAC1F;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,cAAY;AAAA,MACZ,4BAAyB;AAAA,MACzB,SAAS;AAAA,MACT,gBAAe;AAAA,MACf,QAAQ;AAAA,MACR;AAAA,MACA,WAAU;AAAA,MACV,eAAW,cAAG,wCAAwC,SAAS;AAAA,MAC/D,OAAO,EAAE,QAAQ,GAAG,MAAM,MAAM,aAAa,OAAO,UAAU,SAAS;AAAA;AAAA,EACzE;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../src/htmlFrameEntry.ts","../src/looks/htmlFrame.tsx"],"sourcesContent":["// src/htmlFrameEntry.ts — @ai-matrx/records-ui/html-frame · the seamless, sandboxed, auto-height HTML\n// frame alone (react + cn), for a host that draws written HTML without loading a screen.\nexport {\n HTML_SAMPLE_CSP,\n HTML_SAMPLE_SANDBOX,\n SAMPLE_TOKEN_NAMES,\n HtmlSampleFrame,\n HtmlSampleTokensProvider,\n TokenScope,\n fontLink,\n forwardWheel,\n hexToHslTriplet,\n hostTheme,\n hostTokens,\n sampleDocument,\n sampleHeight,\n sampleStyle,\n tokenScopeStyle,\n tokenValue,\n useHostTheme,\n useSampleTokens,\n type HtmlSampleFrameProps,\n type SampleTheme,\n type SampleTokenSet,\n type SampleTokens,\n} from \"./looks/htmlFrame\";\n","\"use client\";\n\n// src/looks/htmlFrame.tsx — @ai-matrx/records-ui · THE SEAMLESS HTML FRAME (light: react + cn only)\n//\n// Shipped alone as `@ai-matrx/records-ui/html-frame`, so a host draws written HTML (the board's\n// Cover hero) without loading a screen. The html_sample look (htmlLook.tsx) draws its samples in it.\n// What the frame allows and why: see htmlLook.tsx's header.\n\nimport { createContext, useContext, useEffect, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { cn } from \"@ai-matrx/design-system/cn\";\n/** The sandbox the frame wears. Markup and CSS only: never `allow-scripts` (see the header). */\nexport const HTML_SAMPLE_SANDBOX = \"allow-same-origin\";\n\n/** What a sample may load: inline styles, and images and fonts from data or https. Nothing else. */\nexport const HTML_SAMPLE_CSP =\n \"default-src 'none'; style-src 'unsafe-inline' https://fonts.googleapis.com; img-src data: blob: https:; font-src data: https:; media-src data: https:; script-src 'none'; connect-src 'none'; form-action 'none'\";\n\n/** The token names every sample can use as `var(--name)`. The agent skill names the same list. */\nexport const SAMPLE_TOKEN_NAMES = [\n \"background\",\n \"foreground\",\n \"card\",\n \"card-foreground\",\n \"popover\",\n \"popover-foreground\",\n \"muted\",\n \"muted-foreground\",\n \"primary\",\n \"primary-foreground\",\n \"secondary\",\n \"secondary-foreground\",\n \"accent\",\n \"accent-foreground\",\n \"destructive\",\n \"destructive-foreground\",\n \"success\",\n \"warning\",\n \"border\",\n \"input\",\n \"ring\",\n \"radius\",\n] as const;\n\nexport type SampleTheme = \"light\" | \"dark\";\n/** Token values by name, without the leading dashes: `{ primary: \"#1f4fe0\", radius: \"8px\" }`. */\nexport type SampleTokens = Readonly<Record<string, string>>;\nexport interface SampleTokenSet {\n light?: SampleTokens;\n dark?: SampleTokens;\n /** Web font families the samples name (a board's type styles); loaded from Google Fonts. */\n fonts?: readonly string[];\n}\n\n/** Families that are the system's own and need no loading. */\nconst SYSTEM_FAMILY = /^(system-ui|ui-[a-z-]+|-apple-system|blinkmacsystemfont|serif|sans-serif|monospace|cursive|fantasy|georgia|arial|helvetica|helvetica neue|times|times new roman|courier|courier new|verdana|tahoma|segoe ui|roboto mono|sf pro.*|menlo|monaco|consolas)$/i;\n\n/** The one stylesheet link that loads these families, or \"\" when none needs loading. */\nexport function fontLink(fonts: readonly string[] | undefined): string {\n const families = [...new Set((fonts ?? []).map((f) => f.trim()).filter((f) => /^[A-Za-z0-9 ]{2,40}$/.test(f) && !SYSTEM_FAMILY.test(f)))].slice(0, 8);\n if (families.length === 0) return \"\";\n const q = families.map((f) => `family=${f.replace(/ /g, \"+\")}:ital,wght@0,300..800;1,300..800`).join(\"&\");\n return `<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?${q}&display=swap\">`;\n}\n\nconst TokensContext = createContext<SampleTokenSet | null>(null);\n\n/** A host's own token values for every sample under it (a board's design-system tables). */\nexport function HtmlSampleTokensProvider({ tokens, children }: { tokens: SampleTokenSet | null; children: ReactNode }) {\n return <TokensContext.Provider value={tokens}>{children}</TokensContext.Provider>;\n}\n\n/** The token set a host provided for the samples under it (a board's design-system tables), or null. */\nexport function useSampleTokens(): SampleTokenSet | null {\n return useContext(TokensContext);\n}\n\n/** A hex color as the app's bare HSL triplet (\"210 80% 45%\"), or null for anything else. */\nexport function hexToHslTriplet(hex: string): string | null {\n const m = /^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(hex.trim());\n if (!m) return null;\n const n = parseInt(m[1]!, 16);\n const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((c) => c / 255) as [number, number, number];\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n const d = max - min;\n let h = 0;\n const sat = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));\n if (d !== 0) {\n if (max === r) h = ((g - b) / d) % 6;\n else if (max === g) h = (b - r) / d + 2;\n else h = (r - g) / d + 4;\n h *= 60;\n if (h < 0) h += 360;\n }\n const round = (x: number) => Math.round(x * 10) / 10;\n return `${round(h)} ${round(sat * 100)}% ${round(l * 100)}%`;\n}\n\n/**\n * The CSS variables that put app content (prose, controls) into the provided design system for one theme:\n * each color token the app keeps as an HSL triplet is overridden with the board's color, and the text takes\n * the board's body font. Nothing outside the scope changes.\n */\nexport function tokenScopeStyle(set: SampleTokenSet | null, theme: SampleTheme): Record<string, string> {\n const tokens = set?.[theme] ?? {};\n const out: Record<string, string> = {};\n for (const name of SAMPLE_TOKEN_NAMES) {\n const value = tokens[name];\n const triplet = value ? hexToHslTriplet(value) : null;\n if (triplet) out[`--${name}`] = triplet;\n }\n const safe = (v: string | undefined) => (v && !/[;{}<>]/.test(v) ? v : undefined);\n const body = safe(tokens[\"font-body\"]);\n if (body) {\n out.fontFamily = body;\n // The app's sans classes read these (Tailwind's `--font-sans`, the design system's typography token).\n out[\"--font-sans\"] = body;\n out[\"--typography-fontFamily-sans\"] = body;\n }\n // The scope paints the board's own ground, so the board's colors are read on the board's background in\n // both themes (a dark primary heading is never left on the app's card).\n const ground = safe(tokens[\"card\"]) ?? safe(tokens[\"background\"]);\n if (ground) out.backgroundColor = ground;\n // Text is the board's foreground; the app's accent hue (the blue a shared renderer's headings, links and\n // emphasis use) becomes the board's primary and link: inside the scope only, never the app's own pages.\n const fg = safe(tokens[\"foreground\"]);\n if (fg) out.color = fg;\n const primary = safe(tokens[\"primary\"]);\n const link = safe(tokens[\"link\"]) ?? primary;\n if (primary) {\n out[\"--color-blue-400\"] = primary;\n out[\"--color-blue-500\"] = primary;\n }\n if (link) out[\"--color-blue-600\"] = link;\n const display = safe(tokens[\"font-display\"]) ?? safe(tokens[\"font-title\"]);\n if (display) out[\"--token-scope-heading-font\"] = display;\n return out;\n}\n\n/** The host page's theme, followed as it changes. */\nexport function useHostTheme(): SampleTheme {\n const [theme, setTheme] = useState<SampleTheme>(() => hostTheme());\n useEffect(() => {\n if (typeof MutationObserver === \"undefined\" || typeof document === \"undefined\") return;\n const watch = new MutationObserver(() => setTheme(hostTheme()));\n watch.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\", \"data-theme\"] });\n return () => watch.disconnect();\n }, []);\n return theme;\n}\n\n/**\n * APP CONTENT IN THE HOST'S DESIGN SYSTEM: everything under it (a cover's prose, a card's text) draws with the\n * provided tokens (a board's own colors and body font) in the page's current theme. No provided tokens: it is\n * a plain wrapper and the app's own tokens apply.\n */\nexport function TokenScope({ className, children }: { className?: string; children: ReactNode }) {\n const set = useSampleTokens();\n const theme = useHostTheme();\n const style = tokenScopeStyle(set, theme);\n return (\n <div data-token-scope={set ? \"\" : undefined} className={className} style={style as CSSProperties}>\n {/* Headings take the board's display font (a plain style can't reach them; scoped to this element only). */}\n {style[\"--token-scope-heading-font\"] ? (\n <style>{\"[data-token-scope] :is(h1,h2,h3,h4,h5,h6){font-family:var(--token-scope-heading-font)}\"}</style>\n ) : null}\n {children}\n </div>\n );\n}\n\n/** A bare HSL triplet (\"240 5% 96%\", how the app keeps its colors) becomes a color a sample can use. */\nexport function tokenValue(raw: string): string {\n const v = raw.trim();\n return /^-?\\d+(\\.\\d+)?(deg)?\\s+\\d+(\\.\\d+)?%\\s+\\d+(\\.\\d+)?%(\\s*\\/\\s*[\\d.]+%?)?$/.test(v) ? `hsl(${v})` : v;\n}\n\n/** The host page's theme: `dark` when its root wears the `dark` class or `data-theme=\"dark\"`. */\nexport function hostTheme(doc: Document | undefined = typeof document === \"undefined\" ? undefined : document): SampleTheme {\n const root = doc?.documentElement;\n if (!root) return \"light\";\n return root.classList.contains(\"dark\") || root.dataset.theme === \"dark\" ? \"dark\" : \"light\";\n}\n\n/** The host page's own token values, read from where the frame sits (so a themed region counts). */\nexport function hostTokens(at: Element | null): Record<string, string> {\n const out: Record<string, string> = {};\n if (!at || typeof getComputedStyle === \"undefined\") return out;\n const style = getComputedStyle(at);\n for (const name of SAMPLE_TOKEN_NAMES) {\n const raw = style.getPropertyValue(`--${name}`);\n if (raw && raw.trim()) out[name] = tokenValue(raw);\n }\n return out;\n}\n\n/** The `:root` block a sample reads its tokens from, plus the frame's own seamless reset. */\nexport function sampleStyle(tokens: SampleTokens, theme: SampleTheme, font?: string): string {\n const vars = Object.entries(tokens)\n .filter(([name, value]) => /^[a-z][a-z0-9-]*$/.test(name) && !/[;{}<>]/.test(value))\n .map(([name, value]) => `--${name}:${value};`)\n .join(\"\");\n const family = font && !/[;{}<>]/.test(font) ? font : \"system-ui, sans-serif\";\n return (\n `:root{${vars}color-scheme:${theme};}` +\n `html,body{margin:0;padding:0;background:transparent;overflow:hidden;}` +\n // bare-hsl-ok: the sample frame's :root holds full colors (tokenValue wraps each triple in hsl())\n `body{color:var(--foreground,${theme === \"dark\" ? \"#e8ebf1\" : \"#111827\"});font-family:${family};font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;}` +\n `*,*::before,*::after{box-sizing:border-box;}` +\n `#matrx-sample{display:flow-root;}`\n );\n}\n\n/** The whole document the frame draws: CSP, tokens, the reset, and the sample inside one measured box. */\nexport function sampleDocument(html: string, tokens: SampleTokens, theme: SampleTheme, font?: string, fonts?: readonly string[]): string {\n return (\n `<!doctype html><html class=\"${theme}\" style=\"color-scheme:${theme}\"><head><meta charset=\"utf-8\">` +\n `<meta http-equiv=\"Content-Security-Policy\" content=\"${HTML_SAMPLE_CSP}\">` +\n fontLink(fonts) +\n `<meta name=\"color-scheme\" content=\"${theme}\">` +\n `<style id=\"matrx-sample-tokens\">${sampleStyle(tokens, theme, font)}</style>` +\n `</head><body><div id=\"matrx-sample\">${html}</div></body></html>`\n );\n}\n\n/** A wheel inside a sample, re-dispatched on the frame element so the page or board around it scrolls. */\nexport function forwardWheel(target: HTMLIFrameElement | null, e: WheelEvent): void {\n if (!target) return;\n const r = target.getBoundingClientRect();\n target.dispatchEvent(\n new WheelEvent(\"wheel\", {\n bubbles: true,\n cancelable: true,\n deltaX: e.deltaX,\n deltaY: e.deltaY,\n deltaZ: e.deltaZ,\n deltaMode: e.deltaMode,\n clientX: r.left + e.clientX,\n clientY: r.top + e.clientY,\n ctrlKey: e.ctrlKey,\n metaKey: e.metaKey,\n shiftKey: e.shiftKey,\n altKey: e.altKey,\n }),\n );\n}\n\n/** The sample's drawn height in px, from its one measured box (margins included: it is a flow root). */\nexport function sampleHeight(doc: Document | null | undefined): number {\n const box = doc?.getElementById(\"matrx-sample\");\n if (!box) return 0;\n return Math.ceil(box.getBoundingClientRect().height || box.scrollHeight || 0);\n}\n\nexport interface HtmlSampleFrameProps {\n html: string;\n /** What a screen reader calls the frame. */\n title?: string;\n className?: string;\n /** Height before the sample has been measured, so the page does not jump when it loads. Default 24. */\n initialHeight?: number;\n}\n\n/**\n * THE SEAMLESS SAMPLE FRAME — markup and CSS only, transparent, borderless, as tall as its content,\n * with the host's tokens and theme. See the file header for what the sandbox allows.\n */\nexport function HtmlSampleFrame({ html, title = \"Sample\", className, initialHeight = 24 }: HtmlSampleFrameProps) {\n const frame = useRef<HTMLIFrameElement | null>(null);\n const given = useContext(TokensContext);\n const [height, setHeight] = useState(initialHeight);\n const [theme, setTheme] = useState<SampleTheme>(() => hostTheme());\n // The document is built once per html; a theme or token change after that is written into the\n // live frame (`paint`), never a reload.\n const fontsKey = (given?.fonts ?? []).join(\"|\");\n const [doc, setDoc] = useState(() => sampleDocument(html, given?.[theme] ?? {}, theme, undefined, given?.fonts));\n const built = useRef(`${html}\\u0000${fontsKey}`);\n\n const tokensFor = (t: SampleTheme): Record<string, string> => ({ ...hostTokens(frame.current), ...(given?.[t] ?? {}) });\n const fontOf = () => (frame.current && typeof getComputedStyle !== \"undefined\" ? getComputedStyle(frame.current).fontFamily : undefined);\n\n // A new html: a new document, opened in today's theme with today's tokens.\n // New fonts to load also rebuild (a stylesheet link is part of the document head).\n useEffect(() => {\n const key = `${html}\\u0000${fontsKey}`;\n if (built.current === key) return;\n built.current = key;\n setDoc(sampleDocument(html, tokensFor(theme), theme, fontOf(), given?.fonts));\n // eslint-disable-next-line react-hooks/exhaustive-deps -- the theme and tokens are written live below\n }, [html, fontsKey]);\n\n // The host's theme, followed as it changes.\n useEffect(() => {\n if (typeof MutationObserver === \"undefined\" || typeof document === \"undefined\") return;\n const watch = new MutationObserver(() => setTheme(hostTheme()));\n watch.observe(document.documentElement, { attributes: true, attributeFilter: [\"class\", \"data-theme\"] });\n return () => watch.disconnect();\n }, []);\n\n const measure = () => {\n const h = sampleHeight(frame.current?.contentDocument);\n if (h > 0) setHeight(h);\n };\n\n // Write the theme and tokens into the live document (same origin, no script inside it).\n const paint = () => {\n const inner = frame.current?.contentDocument;\n if (!inner?.documentElement) return;\n const style = inner.getElementById(\"matrx-sample-tokens\");\n if (style) style.textContent = sampleStyle(tokensFor(theme), theme, fontOf());\n inner.documentElement.className = theme;\n inner.documentElement.style.colorScheme = theme;\n measure();\n };\n\n useEffect(paint, [theme, given]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // The width the frame is given changes the sample's height (text wraps): measure again.\n useEffect(() => {\n const el = frame.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => measure());\n ro.observe(el);\n return () => ro.disconnect();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const onLoad = () => {\n paint();\n const inner = frame.current?.contentDocument;\n if (!inner) return;\n // Late images and fonts change the height after load.\n inner.addEventListener(\"load\", measure, true);\n void inner.fonts?.ready.then(measure).catch(() => undefined);\n const box = inner.getElementById(\"matrx-sample\");\n const View = inner.defaultView as (Window & { ResizeObserver?: typeof ResizeObserver }) | null;\n if (box && View?.ResizeObserver) new View.ResizeObserver(() => measure()).observe(box);\n // The sample never scrolls (it is as tall as its content), so a wheel over it belongs to the page or\n // board around it: hand it on to the frame element, where the host's own wheel handling sees it.\n inner.addEventListener(\"wheel\", (e) => forwardWheel(frame.current, e), { passive: true });\n };\n\n return (\n <iframe\n ref={frame}\n title={title}\n aria-label={title}\n data-records-html-sample=\"\"\n sandbox={HTML_SAMPLE_SANDBOX}\n referrerPolicy=\"no-referrer\"\n srcDoc={doc}\n onLoad={onLoad}\n scrolling=\"no\"\n className={cn(\"block w-full border-0 bg-transparent\", className)}\n style={{ height: `${height}px`, colorScheme: theme, overflow: \"hidden\" }}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQA,mBAA2G;AAC3G,gBAAmB;AA2DV;AAzDF,IAAM,sBAAsB;AAG5B,IAAM,kBACX;AAGK,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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UAAM,OAAO,MAAM;AACnB,QAAI,OAAO,MAAM,eAAgB,KAAI,KAAK,eAAe,MAAM,QAAQ,CAAC,EAAE,QAAQ,GAAG;AAGrF,UAAM,iBAAiB,SAAS,CAAC,MAAM,aAAa,MAAM,SAAS,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC;AAAA,EAC1F;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,cAAY;AAAA,MACZ,4BAAyB;AAAA,MACzB,SAAS;AAAA,MACT,gBAAe;AAAA,MACf,QAAQ;AAAA,MACR;AAAA,MACA,WAAU;AAAA,MACV,eAAW,cAAG,wCAAwC,SAAS;AAAA,MAC/D,OAAO,EAAE,QAAQ,GAAG,MAAM,MAAM,aAAa,OAAO,UAAU,SAAS;AAAA;AAAA,EACzE;AAEJ;","names":[]}
@@ -18,7 +18,7 @@ import {
18
18
  tokenValue,
19
19
  useHostTheme,
20
20
  useSampleTokens
21
- } from "./chunk-O5K6Y3N3.js";
21
+ } from "./chunk-4CI2HLX3.js";
22
22
  import "./chunk-HKYEHBQT.js";
23
23
  export {
24
24
  HTML_SAMPLE_CSP,
package/dist/index.cjs CHANGED
@@ -10246,19 +10246,19 @@ function HtmlSampleEditor({ value, onChange, disabled, id, label }) {
10246
10246
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_design_system3.Button, { type: "button", variant: "outline", onClick: done, children: "Done" }) })
10247
10247
  ] });
10248
10248
  }
10249
- var FIXED_COLOUR = /#[0-9a-f]{3,8}\b|\brgba?\(|\bhsla?\(/i;
10249
+ var FIXED_COLOR = /#[0-9a-f]{3,8}\b|\brgba?\(|\bhsla?\(/i;
10250
10250
  function htmlSampleChecks(value, _format) {
10251
10251
  const html = htmlOf(value);
10252
10252
  if (!html.trim()) return [];
10253
10253
  const out = [];
10254
10254
  const styles = [...html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>|style\s*=\s*"([^"]*)"/gi)].map((m) => m[1] ?? m[2] ?? "").join("\n");
10255
10255
  const outsideFallbacks = styles.replace(/var\([^()]*(\([^()]*\))?[^()]*\)/g, "");
10256
- if (FIXED_COLOUR.test(outsideFallbacks)) {
10256
+ if (FIXED_COLOR.test(outsideFallbacks)) {
10257
10257
  out.push({
10258
10258
  message: "fixed colors, not the theme's",
10259
10259
  fix: {
10260
10260
  label: "Use tokens",
10261
- // bare-hsl-ok: prose naming the frame's variables, not a colour
10261
+ // bare-hsl-ok: prose naming the frame's variables, not a color
10262
10262
  ask: "Rewrite this HTML sample so every color is one of the design system's CSS variables (var(--background), var(--foreground), var(--primary), var(--border)\u2026), keeping the markup and the look the same, so it follows light and dark."
10263
10263
  }
10264
10264
  });
@@ -10273,7 +10273,7 @@ var HTML_SAMPLE_LOOK = {
10273
10273
  Preview: HtmlSampleView,
10274
10274
  checks: htmlSampleChecks,
10275
10275
  starter: () => (
10276
- // bare-hsl-ok: sample HTML for the frame, whose :root holds full colours
10276
+ // bare-hsl-ok: sample HTML for the frame, whose :root holds full colors
10277
10277
  '<style>.b{font:inherit;padding:6px 12px;border-radius:var(--radius);border:1px solid transparent;background:var(--primary);color:var(--primary-foreground)}</style>\n<button class="b">Button</button>'
10278
10278
  )
10279
10279
  };
@@ -25545,7 +25545,7 @@ function paintByOption(style, _fields, index, lookup) {
25545
25545
  }
25546
25546
  };
25547
25547
  }
25548
- function colourableBy(field2) {
25548
+ function colorableBy(field2) {
25549
25549
  const kind2 = String(editorKindFor(field2));
25550
25550
  return kind2 === "select" || kind2 === "multi_select" || kind2 === "checkbox" || kind2 === "boolean";
25551
25551
  }
@@ -25607,8 +25607,8 @@ function swatches(prefix, current, write) {
25607
25607
  ...current ? [{ id: `${prefix}-none`, label: "No highlight", onSelect: () => write(null) }] : []
25608
25608
  ];
25609
25609
  }
25610
- function useGridColours(args) {
25611
- const { enabled, tableId, fields, decorations, mayColour, whyNot, notify, view } = args;
25610
+ function useGridColors(args) {
25611
+ const { enabled, tableId, fields, decorations, mayColor, whyNot, notify, view } = args;
25612
25612
  const client = (0, import_react129.useRecordsClient)();
25613
25613
  const [rulesOpen, setRulesOpen] = (0, import_react128.useState)(null);
25614
25614
  const dialogOptions = useChoiceOptions(fields, rulesOpen !== null ? fields.filter(isChoiceField).map((f) => f.key) : []);
@@ -25626,7 +25626,7 @@ function useGridColours(args) {
25626
25626
  [client, tableId, decorations, notify]
25627
25627
  );
25628
25628
  const idOf = (0, import_react128.useCallback)((key) => fields.find((f) => f.key === key), [fields]);
25629
- const refusal3 = mayColour ? void 0 : whyNot;
25629
+ const refusal3 = mayColor ? void 0 : whyNot;
25630
25630
  const headerItem = (0, import_react128.useCallback)(
25631
25631
  (columnKey) => {
25632
25632
  if (!enabled) return null;
@@ -25635,33 +25635,33 @@ function useGridColours(args) {
25635
25635
  const name = fieldName(field2);
25636
25636
  const by = decorations.data?.color_by;
25637
25637
  const byThis = by?.field === field2.id;
25638
- const byWhy = colourableBy(field2) ? void 0 : `${name} holds free values; rows are colored by a column of choices or ticks. Use a color rule instead.`;
25638
+ const byWhy = colorableBy(field2) ? void 0 : `${name} holds free values; rows are colored by a column of choices or ticks. Use a color rule instead.`;
25639
25639
  const column = decorations.data?.columns?.[field2.id];
25640
25640
  return {
25641
- id: "col-colour",
25641
+ id: "col-color",
25642
25642
  label: "Color by\u2026",
25643
25643
  icon: "palette",
25644
25644
  disabledReason: refusal3,
25645
25645
  submenu: [
25646
25646
  byThis ? {
25647
- id: "col-colour-off",
25647
+ id: "col-color-off",
25648
25648
  label: `Stop coloring by ${name}`,
25649
25649
  onSelect: () => void write(["color_by"], null, `Rows are no longer colored by ${name}.`)
25650
25650
  } : {
25651
- id: "col-colour-rows",
25651
+ id: "col-color-rows",
25652
25652
  label: "Color rows by this column",
25653
25653
  disabledReason: byWhy,
25654
25654
  onSelect: () => void write(["color_by"], { field: field2.id, target: "row" }, `Each row wears the color of its ${name}.`)
25655
25655
  },
25656
25656
  ...byThis && by?.target === "row" ? [
25657
25657
  {
25658
- id: "col-colour-cells",
25658
+ id: "col-color-cells",
25659
25659
  label: "Color only this column's cells",
25660
25660
  onSelect: () => void write(["color_by"], { field: field2.id, target: "cell" }, `Only ${name}'s cells wear their color now.`)
25661
25661
  }
25662
25662
  ] : [],
25663
25663
  {
25664
- id: "col-colour-rules",
25664
+ id: "col-color-rules",
25665
25665
  label: "Color rules\u2026",
25666
25666
  onSelect: () => setRulesOpen(columnKey)
25667
25667
  },
@@ -25748,7 +25748,7 @@ function useGridColours(args) {
25748
25748
  [enabled, decorations.data, refusal3, write]
25749
25749
  );
25750
25750
  const dialogs = enabled ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
25751
- ColourRulesDialog,
25751
+ ColorRulesDialog,
25752
25752
  {
25753
25753
  open: rulesOpen !== null,
25754
25754
  startField: rulesOpen,
@@ -25772,11 +25772,11 @@ function useGridColours(args) {
25772
25772
  }
25773
25773
  }
25774
25774
  ) : null;
25775
- const colourable = fields.filter(colourableBy);
25775
+ const colorable = fields.filter(colorableBy);
25776
25776
  const byId = decorations.data?.color_by?.field ?? null;
25777
- const sheet = enabled ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-col gap-1.5", "data-records-grid-sheet-colours": "", children: [
25777
+ const sheet = enabled ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-col gap-1.5", "data-records-grid-sheet-colors": "", children: [
25778
25778
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-xs font-medium text-muted-foreground", children: "Colors" }),
25779
- mayColour ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-2", children: [
25779
+ mayColor ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-2", children: [
25780
25780
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("label", { className: "flex min-w-0 flex-1 items-center gap-2 text-xs text-muted-foreground", children: [
25781
25781
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "shrink-0", children: "Color rows by" }),
25782
25782
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
@@ -25789,11 +25789,11 @@ function useGridColours(args) {
25789
25789
  const field2 = fields.find((f) => f.id === id);
25790
25790
  void (field2 ? write(["color_by"], { field: field2.id, target: "row" }, `Each row wears the color of its ${fieldName(field2)}.`) : write(["color_by"], null, "Rows are no longer colored by a column."));
25791
25791
  },
25792
- options: [{ value: "", label: "No color" }, ...colourable.map((field2) => ({ value: field2.id, label: fieldName(field2) }))]
25792
+ options: [{ value: "", label: "No color" }, ...colorable.map((field2) => ({ value: field2.id, label: fieldName(field2) }))]
25793
25793
  }
25794
25794
  )
25795
25795
  ] }),
25796
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_design_system69.Button, { type: "button", size: "sm", variant: "outline", className: "h-10 shrink-0", onClick: () => setRulesOpen(colourable[0]?.key ?? fields[0]?.key ?? ""), children: "Color rules\u2026" })
25796
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_design_system69.Button, { type: "button", size: "sm", variant: "outline", className: "h-10 shrink-0", onClick: () => setRulesOpen(colorable[0]?.key ?? fields[0]?.key ?? ""), children: "Color rules\u2026" })
25797
25797
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { className: "text-xs text-muted-foreground", children: whyNot })
25798
25798
  ] }) : null;
25799
25799
  return { headerItem, cellItem, cellsItem, rowItem, dialogs, sheet };
@@ -25802,7 +25802,7 @@ var SELECT2 = "h-8";
25802
25802
  var CHOICE_OPS = ["is", "is_not", "is_empty", "not_empty"].filter(
25803
25803
  (op2) => import_data_table9.COLOR_RULE_OPS.includes(op2)
25804
25804
  );
25805
- function ColourRulesDialog({
25805
+ function ColorRulesDialog({
25806
25806
  open,
25807
25807
  startField,
25808
25808
  fields,
@@ -25842,13 +25842,13 @@ function ColourRulesDialog({
25842
25842
  onClose();
25843
25843
  };
25844
25844
  const first = startField ?? fields[0]?.key ?? "";
25845
- return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_design_system69.Dialog, { open, onOpenChange: (next) => !next ? close() : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_design_system69.DialogContent, { className: "sm:max-w-2xl", "data-records-colour-rules": "", children: [
25845
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_design_system69.Dialog, { open, onOpenChange: (next) => !next ? close() : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_design_system69.DialogContent, { className: "sm:max-w-2xl", "data-records-color-rules": "", children: [
25846
25846
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_design_system69.DialogHeader, { children: [
25847
25847
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_design_system69.DialogTitle, { children: "Color rules" }),
25848
25848
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_design_system69.DialogDescription, { children: scope === "view" ? "The first rule a row matches wins. These rules belong to this view alone, and a date can be tested against today." : "The first rule a row matches wins. A rule tints the whole row, or only the cell it reads. Everyone who opens this table sees them." })
25849
25849
  ] }),
25850
25850
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-col gap-2", children: [
25851
- viewRules ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-1.5 text-xs", "data-records-colour-rules-scope": "", children: [
25851
+ viewRules ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-1.5 text-xs", "data-records-color-rules-scope": "", children: [
25852
25852
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-muted-foreground", children: "Keep them on" }),
25853
25853
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
25854
25854
  PickOne,
@@ -25868,7 +25868,7 @@ function ColourRulesDialog({
25868
25868
  )
25869
25869
  ] }) : null,
25870
25870
  rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { className: "text-xs text-muted-foreground", children: "No rules yet." }) : null,
25871
- rows.map((rule, i) => /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5 text-xs", "data-records-colour-rule": "", children: [
25871
+ rows.map((rule, i) => /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5 text-xs", "data-records-color-rule": "", children: [
25872
25872
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-muted-foreground", children: i === 0 ? "When" : "Else when" }),
25873
25873
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
25874
25874
  PickOne,
@@ -25884,7 +25884,7 @@ function ColourRulesDialog({
25884
25884
  PickOne,
25885
25885
  {
25886
25886
  label: "Test",
25887
- attrs: { "data-records-colour-rule-op": "" },
25887
+ attrs: { "data-records-color-rule-op": "" },
25888
25888
  className: SELECT2,
25889
25889
  value: rule.op,
25890
25890
  onChange: (picked) => set(i, { op: picked }),
@@ -25898,7 +25898,7 @@ function ColourRulesDialog({
25898
25898
  PickOne,
25899
25899
  {
25900
25900
  label: "Choice",
25901
- attrs: { "data-records-colour-rule-choice": "" },
25901
+ attrs: { "data-records-color-rule-choice": "" },
25902
25902
  className: SELECT2,
25903
25903
  placeholder: "Pick a choice",
25904
25904
  value: optionFor(choicesOf(rule.field), rule.value)?.id ?? "",
@@ -25909,7 +25909,7 @@ function ColourRulesDialog({
25909
25909
  "input",
25910
25910
  {
25911
25911
  "aria-label": "Value",
25912
- "data-records-colour-rule-value": "",
25912
+ "data-records-color-rule-value": "",
25913
25913
  className: "h-8 w-28 rounded border bg-background px-2 text-xs",
25914
25914
  value: rule.value,
25915
25915
  onChange: (e) => set(i, { value: e.target.value })
@@ -25933,7 +25933,7 @@ function ColourRulesDialog({
25933
25933
  PickOne,
25934
25934
  {
25935
25935
  label: "Color",
25936
- attrs: { "data-records-colour-rule-color": "" },
25936
+ attrs: { "data-records-color-rule-color": "" },
25937
25937
  className: SELECT2,
25938
25938
  value: rule.color,
25939
25939
  onChange: (picked) => set(i, { color: picked }),
@@ -25948,7 +25948,7 @@ function ColourRulesDialog({
25948
25948
  type: "button",
25949
25949
  size: "sm",
25950
25950
  variant: "outline",
25951
- "data-records-colour-rule-add": "",
25951
+ "data-records-color-rule-add": "",
25952
25952
  onClick: () => setDrafts([...rows, { field: first, op: "is", value: "", color: "amber", target: "row" }]),
25953
25953
  children: "Add a rule"
25954
25954
  }
@@ -25961,7 +25961,7 @@ function ColourRulesDialog({
25961
25961
  {
25962
25962
  type: "button",
25963
25963
  size: "sm",
25964
- "data-records-colour-rules-save": "",
25964
+ "data-records-color-rules-save": "",
25965
25965
  disabled: busy || drafts === null,
25966
25966
  onClick: async () => {
25967
25967
  setBusy(true);
@@ -27778,12 +27778,12 @@ function useMergedGridControls(args) {
27778
27778
  const [labelling, setLabelling] = (0, import_react143.useState)(false);
27779
27779
  const [rowActionsOpen, setRowActionsOpen] = (0, import_react143.useState)(false);
27780
27780
  const noDecorations = (0, import_react143.useMemo)(() => ({ data: null, apply: () => void 0 }), []);
27781
- const colours = useGridColours({
27781
+ const colors = useGridColors({
27782
27782
  enabled,
27783
27783
  tableId,
27784
27784
  fields,
27785
27785
  decorations: args.decorations ?? noDecorations,
27786
- mayColour: editable && rights.write,
27786
+ mayColor: editable && rights.write,
27787
27787
  whyNot: editable ? rights.why("write") : "Editing is off here.",
27788
27788
  notify,
27789
27789
  // THIS VIEW'S OWN RULES: kept on the look like every other view setting (and saved to the view the same way).
@@ -27929,8 +27929,8 @@ function useMergedGridControls(args) {
27929
27929
  const field2 = fields.find((f) => f.key === columnId2);
27930
27930
  if (!field2) return [];
27931
27931
  const out = [];
27932
- const colour = colours.headerItem(columnId2);
27933
- if (colour) out.push(colour);
27932
+ const color = colors.headerItem(columnId2);
27933
+ if (color) out.push(color);
27934
27934
  const wrapped = new Set(presentation.wrapColumns ?? []);
27935
27935
  const wraps = wrapped.has(columnId2);
27936
27936
  out.push({
@@ -27977,15 +27977,15 @@ function useMergedGridControls(args) {
27977
27977
  return out;
27978
27978
  },
27979
27979
  cell: (rowId, columnId2) => {
27980
- const item = colours.cellItem(rowId, columnId2);
27980
+ const item = colors.cellItem(rowId, columnId2);
27981
27981
  return [...args.moreItems?.cell?.(rowId, columnId2) ?? [], ...item ? [item] : []];
27982
27982
  },
27983
27983
  selection: (cells) => {
27984
- const item = colours.cellsItem(cells.map((c) => ({ rowId: c.rowId, columnKey: c.columnId })));
27984
+ const item = colors.cellsItem(cells.map((c) => ({ rowId: c.rowId, columnKey: c.columnId })));
27985
27985
  return item ? [item] : [];
27986
27986
  },
27987
27987
  row: (rowId) => {
27988
- const item = colours.rowItem(rowId);
27988
+ const item = colors.rowItem(rowId);
27989
27989
  return [...args.moreItems?.row?.(rowId) ?? [], ...item ? [item] : []];
27990
27990
  },
27991
27991
  table: () => [
@@ -28259,7 +28259,7 @@ function useMergedGridControls(args) {
28259
28259
  }, [
28260
28260
  columnAccess,
28261
28261
  args,
28262
- colours,
28262
+ colors,
28263
28263
  fieldKeys,
28264
28264
  canWrite,
28265
28265
  client,
@@ -28308,7 +28308,7 @@ function useMergedGridControls(args) {
28308
28308
  );
28309
28309
  const close = () => setDialog(null);
28310
28310
  const dialogs = !enabled ? null : /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [
28311
- colours.dialogs,
28311
+ colors.dialogs,
28312
28312
  dialog?.kind === "access" && columnAccess ? columnAccess({
28313
28313
  tableId,
28314
28314
  fieldId: dialog.field.id,
@@ -28577,7 +28577,7 @@ function useMergedGridControls(args) {
28577
28577
  dialogs,
28578
28578
  addColumn: () => setDialog({ kind: "insert", anchor: null, side: "right" }),
28579
28579
  sheetTools: enabled ? /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [
28580
- colours.sheet,
28580
+ colors.sheet,
28581
28581
  args.summaries ? /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
28582
28582
  SummarySheetControls,
28583
28583
  {
@@ -28887,10 +28887,19 @@ function CustomFieldsSection({
28887
28887
  if (!read.loading && !read.error && fields.length === 0 && !mayAdd && !rights.data) return null;
28888
28888
  const storeReason = rights.data?.reason ?? null;
28889
28889
  const reason = storeReason && entityLabel && rights.data?.label ? storeReason.split(rights.data.label).join(entityLabel) : storeReason;
28890
- const cannotAdd = rights.data && !rights.data.may_declare ? /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex min-w-0 flex-wrap items-center gap-2", "data-records-custom-fields-cannot-add": "", children: [
28891
- reason ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("p", { className: "min-w-0 text-[11px] text-muted-foreground", children: reason }) : null,
28892
- onMakeOwnTable ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.Button, { size: "sm", variant: "ghost", className: "ml-auto", onClick: onMakeOwnTable, children: "Make your own table" }) : null
28893
- ] }) : null;
28890
+ const refused = Boolean(rights.data && !rights.data.may_declare);
28891
+ const refusedSentence = reason ?? "Only an owner or an admin can add a field here.";
28892
+ const addRefused = (className2) => refused ? (
28893
+ // Its own provider: the section mounts in hosts with and without an app-root one.
28894
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.TooltipProvider, { titleTooltips: false, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_design_system79.Tooltip, { children: [
28895
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("span", { tabIndex: 0, className: (0, import_design_system79.cn)("inline-flex", className2), "data-records-custom-fields-cannot-add": "", children: [
28896
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.Button, { size: "sm", variant: "ghost", disabled: true, children: "Add field" }),
28897
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "sr-only", children: refusedSentence })
28898
+ ] }) }),
28899
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.TooltipContent, { className: "max-w-xs", children: refusedSentence })
28900
+ ] }) })
28901
+ ) : null;
28902
+ const cannotAdd = refused && onMakeOwnTable ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex min-w-0 items-center justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.Button, { size: "sm", variant: "ghost", onClick: onMakeOwnTable, children: "Make your own table" }) }) : null;
28894
28903
  const editor = adding ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
28895
28904
  FieldEditor,
28896
28905
  {
@@ -28911,7 +28920,7 @@ function CustomFieldsSection({
28911
28920
  /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
28912
28921
  /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("h3", { className: "text-sm font-medium", children: title }),
28913
28922
  !read.loading ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "text-muted-foreground", children: "None yet" }) : null,
28914
- mayAdd ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.Button, { size: "sm", variant: "ghost", className: "ml-auto", onClick: () => setAdding(true), children: "Add field" }) : null
28923
+ mayAdd ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_design_system79.Button, { size: "sm", variant: "ghost", className: "ml-auto", onClick: () => setAdding(true), children: "Add field" }) : addRefused("ml-auto")
28915
28924
  ] }),
28916
28925
  cannotAdd
28917
28926
  ] });
@@ -28943,7 +28952,7 @@ function CustomFieldsSection({
28943
28952
  onClick: () => setAdding(true),
28944
28953
  children: "Add field"
28945
28954
  }
28946
- ) : null,
28955
+ ) : !mayAdd && !editing ? addRefused(fields.length > 0 ? void 0 : "ml-auto") : null,
28947
28956
  editing ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
28948
28957
  import_design_system79.Button,
28949
28958
  {
@@ -53784,7 +53793,7 @@ function freshFormName(base2, taken) {
53784
53793
  function sameForm(a, b) {
53785
53794
  return JSON.stringify((0, import_forms3.formDeclareArgs)(a)) === JSON.stringify((0, import_forms3.formDeclareArgs)(b));
53786
53795
  }
53787
- var LOOK_REFUSAL = /^(That picture|A form's (colour|logo|cover|look))/;
53796
+ var LOOK_REFUSAL = /^(That picture|A form's (color|logo|cover|look))/;
53788
53797
  function isLookRefusal(error) {
53789
53798
  return Boolean(error && LOOK_REFUSAL.test(refusalSentence(error)));
53790
53799
  }
@@ -64280,7 +64289,7 @@ function EntitySectionBody(props) {
64280
64289
  "Add"
64281
64290
  ] }) : null
64282
64291
  ] }),
64283
- entity.error ? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: entity.error }) : entity.loading && entity.rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : entity.rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { className: "-mb-px overflow-x-auto", children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)("div", { "data-records-section-group": group.key, children: [
64292
+ entity.error ? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: entity.error }) : entity.loading && entity.rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : entity.rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(SectionEmpty, { empty: props.empty }) : /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { className: "-mb-px overflow-x-auto", children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)("div", { "data-records-section-group": group.key, children: [
64284
64293
  cols.group ? /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
64285
64294
  /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
64286
64295
  mayAdd ? /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(import_design_system183.Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Add to ${group.key || "no group"}`, onClick: () => setAdding(group.key), children: /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(import_icons2.PlusIcon, { className: "h-4 w-4" }) }) : null
@@ -64329,6 +64338,10 @@ function EntitySectionBody(props) {
64329
64338
  )
64330
64339
  ] });
64331
64340
  }
64341
+ function SectionEmpty({ empty }) {
64342
+ if (empty === "quiet") return /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("div", { "data-records-section-empty": "quiet", className: "pb-2" });
64343
+ return /* @__PURE__ */ (0, import_jsx_runtime208.jsx)("p", { "data-records-section-empty": "line", className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." });
64344
+ }
64332
64345
 
64333
64346
  // src/SectionCard.tsx
64334
64347
  var import_jsx_runtime209 = require("react/jsx-runtime");
@@ -64551,7 +64564,7 @@ var READS_ON_PROBLEM_WORDS = {
64551
64564
  missing: "no row by that name",
64552
64565
  self: "reads on itself",
64553
64566
  duplicate: "two rows share that name",
64554
- "no-colour": "that row has no color"
64567
+ "no-color": "that row has no color"
64555
64568
  };
64556
64569
  function resolveReadsOn(row, rows, keys) {
64557
64570
  if (!keys.readsOn || !keys.name) return { on: null, problem: null, target: null };
@@ -64564,7 +64577,7 @@ function resolveReadsOn(row, rows, keys) {
64564
64577
  if (matches2.length === 0) return { on, problem: "missing", target: null };
64565
64578
  if (matches2.length > 1) return { on, problem: "duplicate", target: null };
64566
64579
  const target = matches2[0];
64567
- if (keys.color && !(0, import_field_formats24.readColorPair)((target.document ?? {})[keys.color])) return { on, problem: "no-colour", target };
64580
+ if (keys.color && !(0, import_field_formats24.readColorPair)((target.document ?? {})[keys.color])) return { on, problem: "no-color", target };
64568
64581
  return { on, problem: null, target };
64569
64582
  }
64570
64583
  function groundOf(row, rows, keys) {
@@ -64803,7 +64816,7 @@ function TableSectionCard(props) {
64803
64816
  ] }),
64804
64817
  mayWrite && nameField ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_controls14.Button, { type: "button", variant: "outline", icon: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_icons3.PlusIcon, {}), onClick: () => setAdding(groups[groups.length - 1]?.key ?? UNGROUPED2), children: "Add" }) : null
64805
64818
  ] }),
64806
- refused ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: refusalSentence(refused) }) : !fieldsRead.data || page.loading && rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: "Nothing here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: (0, import_design_system184.cn)("-mb-px", !narrow && "overflow-x-auto"), children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)("div", { "data-records-section-group": group.key, className: "", children: [
64819
+ refused ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("p", { className: "px-5 pb-5 text-sm text-muted-foreground sm:px-6", children: refusalSentence(refused) }) : !fieldsRead.data || page.loading && rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: "flex flex-col gap-1.5 px-5 pb-5 sm:px-6", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: "h-9 rounded-md bg-muted" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(SectionEmpty, { empty: props.empty }) : /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: (0, import_design_system184.cn)("-mb-px", !narrow && "overflow-x-auto"), children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)("div", { "data-records-section-group": group.key, className: "", children: [
64807
64820
  cols.group ? /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)("div", { className: "flex items-center justify-between border-y border-border px-5 py-1 sm:px-6", children: [
64808
64821
  /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("span", { className: "text-xs font-semibold text-foreground", children: group.key || "No group" }),
64809
64822
  mayWrite ? /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_controls14.Button, { type: "button", variant: "quiet", icon: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_icons3.PlusIcon, {}), "aria-label": `Add to ${group.key || "no group"}`, onClick: () => setAdding(group.key) }) : null