@ai-matrx/records-ui 0.116.32 → 0.116.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/dist/{chunk-GT27AGOI.js → chunk-FFST26WB.js} +59 -1
- package/dist/chunk-FFST26WB.js.map +1 -0
- package/dist/{chunk-ECUJDR3W.js → chunk-IL66BADF.js} +2 -2
- package/dist/html-frame.cjs +59 -1
- package/dist/html-frame.cjs.map +1 -1
- package/dist/html-frame.d.cts +26 -1
- package/dist/html-frame.d.ts +26 -1
- package/dist/html-frame.js +17 -3
- package/dist/index.cjs +2 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -7
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-GT27AGOI.js.map +0 -1
- /package/dist/{chunk-ECUJDR3W.js.map → chunk-IL66BADF.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -25,11 +25,35 @@
|
|
|
25
25
|
- Tests: `vitest.setup.ts` gives jsdom a no-op `performance.mark` / `measure`.
|
|
26
26
|
- **New subpath `@ai-matrx/records-ui/data-source`:** `recordsDataSource`, `personActor` and the who-changed words (`whenWords`, `actorWords`, `actorBadge`, `lastChangeSentence`, `SOMEBODY`, `THE_SYSTEM`) alone. `/helpers` also carries the field-type words, the colour resolver and the table builders, which read `@ai-matrx/records/core`; this entry reaches `@ai-matrx/kit` only, and shares the one data-source cache with `/helpers` and the root. Additive. Consumer action: a shell-reachable service that only binds its supabase client or says when imports from `/data-source`.
|
|
27
27
|
|
|
28
|
-
## 0.116.
|
|
28
|
+
## 0.116.34
|
|
29
29
|
|
|
30
30
|
UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
|
|
31
31
|
Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
|
|
32
32
|
|
|
33
|
+
## 0.116.32
|
|
34
|
+
|
|
35
|
+
SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
|
|
36
|
+
so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
|
|
37
|
+
Diff: `git diff f8faa6382e 373441d144 -- apps/shared/records-ui/src`
|
|
38
|
+
|
|
39
|
+
Changed shipped source files (4):
|
|
40
|
+
- `apps/shared/records-ui/src/Enrich.tsx`
|
|
41
|
+
- `apps/shared/records-ui/src/gridOpen.tsx`
|
|
42
|
+
- `apps/shared/records-ui/src/host.tsx`
|
|
43
|
+
- `apps/shared/records-ui/src/looks/htmlFrame.tsx`
|
|
44
|
+
|
|
45
|
+
## 0.116.31
|
|
46
|
+
|
|
47
|
+
SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
|
|
48
|
+
so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
|
|
49
|
+
Diff: `git diff 3892386591 f8faa6382e -- apps/shared/records-ui/src`
|
|
50
|
+
|
|
51
|
+
Changed shipped source files (4):
|
|
52
|
+
- `apps/shared/records-ui/src/Enrich.tsx`
|
|
53
|
+
- `apps/shared/records-ui/src/TableAsk.tsx`
|
|
54
|
+
- `apps/shared/records-ui/src/TablesHome.tsx`
|
|
55
|
+
- `apps/shared/records-ui/src/workedOutDate.ts`
|
|
56
|
+
|
|
33
57
|
## 0.116.30
|
|
34
58
|
|
|
35
59
|
SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
|
|
@@ -41,6 +41,57 @@ var TokensContext = createContext(null);
|
|
|
41
41
|
function HtmlSampleTokensProvider({ tokens, children }) {
|
|
42
42
|
return /* @__PURE__ */ jsx(TokensContext.Provider, { value: tokens, children });
|
|
43
43
|
}
|
|
44
|
+
function useSampleTokens() {
|
|
45
|
+
return useContext(TokensContext);
|
|
46
|
+
}
|
|
47
|
+
function hexToHslTriplet(hex) {
|
|
48
|
+
const m = /^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(hex.trim());
|
|
49
|
+
if (!m) return null;
|
|
50
|
+
const n = parseInt(m[1], 16);
|
|
51
|
+
const [r, g, b] = [n >> 16 & 255, n >> 8 & 255, n & 255].map((c) => c / 255);
|
|
52
|
+
const max = Math.max(r, g, b);
|
|
53
|
+
const min = Math.min(r, g, b);
|
|
54
|
+
const l = (max + min) / 2;
|
|
55
|
+
const d = max - min;
|
|
56
|
+
let h = 0;
|
|
57
|
+
const sat = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
58
|
+
if (d !== 0) {
|
|
59
|
+
if (max === r) h = (g - b) / d % 6;
|
|
60
|
+
else if (max === g) h = (b - r) / d + 2;
|
|
61
|
+
else h = (r - g) / d + 4;
|
|
62
|
+
h *= 60;
|
|
63
|
+
if (h < 0) h += 360;
|
|
64
|
+
}
|
|
65
|
+
const round = (x) => Math.round(x * 10) / 10;
|
|
66
|
+
return `${round(h)} ${round(sat * 100)}% ${round(l * 100)}%`;
|
|
67
|
+
}
|
|
68
|
+
function tokenScopeStyle(set, theme) {
|
|
69
|
+
const tokens = set?.[theme] ?? {};
|
|
70
|
+
const out = {};
|
|
71
|
+
for (const name of SAMPLE_TOKEN_NAMES) {
|
|
72
|
+
const value = tokens[name];
|
|
73
|
+
const triplet = value ? hexToHslTriplet(value) : null;
|
|
74
|
+
if (triplet) out[`--${name}`] = triplet;
|
|
75
|
+
}
|
|
76
|
+
const body = tokens["font-body"];
|
|
77
|
+
if (body && !/[;{}<>]/.test(body)) out.fontFamily = body;
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
function useHostTheme() {
|
|
81
|
+
const [theme, setTheme] = useState(() => hostTheme());
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (typeof MutationObserver === "undefined" || typeof document === "undefined") return;
|
|
84
|
+
const watch = new MutationObserver(() => setTheme(hostTheme()));
|
|
85
|
+
watch.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "data-theme"] });
|
|
86
|
+
return () => watch.disconnect();
|
|
87
|
+
}, []);
|
|
88
|
+
return theme;
|
|
89
|
+
}
|
|
90
|
+
function TokenScope({ className, children }) {
|
|
91
|
+
const set = useSampleTokens();
|
|
92
|
+
const theme = useHostTheme();
|
|
93
|
+
return /* @__PURE__ */ jsx("div", { "data-token-scope": set ? "" : void 0, className, style: tokenScopeStyle(set, theme), children });
|
|
94
|
+
}
|
|
44
95
|
function tokenValue(raw) {
|
|
45
96
|
const v = raw.trim();
|
|
46
97
|
return /^-?\d+(\.\d+)?(deg)?\s+\d+(\.\d+)?%\s+\d+(\.\d+)?%(\s*\/\s*[\d.]+%?)?$/.test(v) ? `hsl(${v})` : v;
|
|
@@ -169,13 +220,20 @@ export {
|
|
|
169
220
|
HTML_SAMPLE_SANDBOX,
|
|
170
221
|
HTML_SAMPLE_CSP,
|
|
171
222
|
SAMPLE_TOKEN_NAMES,
|
|
223
|
+
fontLink,
|
|
172
224
|
HtmlSampleTokensProvider,
|
|
225
|
+
useSampleTokens,
|
|
226
|
+
hexToHslTriplet,
|
|
227
|
+
tokenScopeStyle,
|
|
228
|
+
useHostTheme,
|
|
229
|
+
TokenScope,
|
|
173
230
|
tokenValue,
|
|
174
231
|
hostTheme,
|
|
175
232
|
hostTokens,
|
|
176
233
|
sampleStyle,
|
|
177
234
|
sampleDocument,
|
|
235
|
+
forwardWheel,
|
|
178
236
|
sampleHeight,
|
|
179
237
|
HtmlSampleFrame
|
|
180
238
|
};
|
|
181
|
-
//# sourceMappingURL=chunk-
|
|
239
|
+
//# sourceMappingURL=chunk-FFST26WB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/looks/htmlFrame.tsx"],"sourcesContent":["\"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 body = tokens[\"font-body\"];\n if (body && !/[;{}<>]/.test(body)) out.fontFamily = body;\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 return (\n <div data-token-scope={set ? \"\" : undefined} className={className} style={tokenScopeStyle(set, theme) as CSSProperties}>\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 `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":";;;AAQA,SAAS,eAAe,YAAY,WAAW,QAAQ,gBAAoD;AAC3G,SAAS,UAAU;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,gBAAgB;AAGf,SAAS,SAAS,OAA8C;AACrE,QAAM,WAAW,CAAC,GAAG,IAAI,KAAK,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,uBAAuB,KAAK,CAAC,KAAK,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC;AACpJ,MAAI,SAAS,WAAW,EAAG,QAAO;AAClC,QAAM,IAAI,SAAS,IAAI,CAAC,MAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,CAAC,kCAAkC,EAAE,KAAK,GAAG;AACxG,SAAO,kEAAkE,CAAC;AAC5E;AAEA,IAAM,gBAAgB,cAAqC,IAAI;AAGxD,S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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,WAAW,GAAG,wCAAwC,SAAS;AAAA,MAC/D,OAAO,EAAE,QAAQ,GAAG,MAAM,MAAM,aAAa,OAAO,UAAU,SAAS;AAAA;AAAA,EACzE;AAEJ;","names":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
HtmlSampleFrame,
|
|
11
11
|
HtmlSampleTokensProvider
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FFST26WB.js";
|
|
13
13
|
import {
|
|
14
14
|
ABSENCE_WORD_LABEL,
|
|
15
15
|
CONTEXT_POLICY_LABEL,
|
|
@@ -12322,4 +12322,4 @@ export {
|
|
|
12322
12322
|
RecordNameText,
|
|
12323
12323
|
HeldChangeDecision
|
|
12324
12324
|
};
|
|
12325
|
-
//# sourceMappingURL=chunk-
|
|
12325
|
+
//# sourceMappingURL=chunk-IL66BADF.js.map
|
package/dist/html-frame.cjs
CHANGED
|
@@ -26,12 +26,19 @@ __export(htmlFrameEntry_exports, {
|
|
|
26
26
|
HtmlSampleFrame: () => HtmlSampleFrame,
|
|
27
27
|
HtmlSampleTokensProvider: () => HtmlSampleTokensProvider,
|
|
28
28
|
SAMPLE_TOKEN_NAMES: () => SAMPLE_TOKEN_NAMES,
|
|
29
|
+
TokenScope: () => TokenScope,
|
|
30
|
+
fontLink: () => fontLink,
|
|
31
|
+
forwardWheel: () => forwardWheel,
|
|
32
|
+
hexToHslTriplet: () => hexToHslTriplet,
|
|
29
33
|
hostTheme: () => hostTheme,
|
|
30
34
|
hostTokens: () => hostTokens,
|
|
31
35
|
sampleDocument: () => sampleDocument,
|
|
32
36
|
sampleHeight: () => sampleHeight,
|
|
33
37
|
sampleStyle: () => sampleStyle,
|
|
34
|
-
|
|
38
|
+
tokenScopeStyle: () => tokenScopeStyle,
|
|
39
|
+
tokenValue: () => tokenValue,
|
|
40
|
+
useHostTheme: () => useHostTheme,
|
|
41
|
+
useSampleTokens: () => useSampleTokens
|
|
35
42
|
});
|
|
36
43
|
module.exports = __toCommonJS(htmlFrameEntry_exports);
|
|
37
44
|
|
|
@@ -76,6 +83,57 @@ var TokensContext = (0, import_react.createContext)(null);
|
|
|
76
83
|
function HtmlSampleTokensProvider({ tokens, children }) {
|
|
77
84
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TokensContext.Provider, { value: tokens, children });
|
|
78
85
|
}
|
|
86
|
+
function useSampleTokens() {
|
|
87
|
+
return (0, import_react.useContext)(TokensContext);
|
|
88
|
+
}
|
|
89
|
+
function hexToHslTriplet(hex) {
|
|
90
|
+
const m = /^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(hex.trim());
|
|
91
|
+
if (!m) return null;
|
|
92
|
+
const n = parseInt(m[1], 16);
|
|
93
|
+
const [r, g, b] = [n >> 16 & 255, n >> 8 & 255, n & 255].map((c) => c / 255);
|
|
94
|
+
const max = Math.max(r, g, b);
|
|
95
|
+
const min = Math.min(r, g, b);
|
|
96
|
+
const l = (max + min) / 2;
|
|
97
|
+
const d = max - min;
|
|
98
|
+
let h = 0;
|
|
99
|
+
const sat = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
100
|
+
if (d !== 0) {
|
|
101
|
+
if (max === r) h = (g - b) / d % 6;
|
|
102
|
+
else if (max === g) h = (b - r) / d + 2;
|
|
103
|
+
else h = (r - g) / d + 4;
|
|
104
|
+
h *= 60;
|
|
105
|
+
if (h < 0) h += 360;
|
|
106
|
+
}
|
|
107
|
+
const round = (x) => Math.round(x * 10) / 10;
|
|
108
|
+
return `${round(h)} ${round(sat * 100)}% ${round(l * 100)}%`;
|
|
109
|
+
}
|
|
110
|
+
function tokenScopeStyle(set, theme) {
|
|
111
|
+
const tokens = set?.[theme] ?? {};
|
|
112
|
+
const out = {};
|
|
113
|
+
for (const name of SAMPLE_TOKEN_NAMES) {
|
|
114
|
+
const value = tokens[name];
|
|
115
|
+
const triplet = value ? hexToHslTriplet(value) : null;
|
|
116
|
+
if (triplet) out[`--${name}`] = triplet;
|
|
117
|
+
}
|
|
118
|
+
const body = tokens["font-body"];
|
|
119
|
+
if (body && !/[;{}<>]/.test(body)) out.fontFamily = body;
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
function useHostTheme() {
|
|
123
|
+
const [theme, setTheme] = (0, import_react.useState)(() => hostTheme());
|
|
124
|
+
(0, import_react.useEffect)(() => {
|
|
125
|
+
if (typeof MutationObserver === "undefined" || typeof document === "undefined") return;
|
|
126
|
+
const watch = new MutationObserver(() => setTheme(hostTheme()));
|
|
127
|
+
watch.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "data-theme"] });
|
|
128
|
+
return () => watch.disconnect();
|
|
129
|
+
}, []);
|
|
130
|
+
return theme;
|
|
131
|
+
}
|
|
132
|
+
function TokenScope({ className, children }) {
|
|
133
|
+
const set = useSampleTokens();
|
|
134
|
+
const theme = useHostTheme();
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-token-scope": set ? "" : void 0, className, style: tokenScopeStyle(set, theme), children });
|
|
136
|
+
}
|
|
79
137
|
function tokenValue(raw) {
|
|
80
138
|
const v = raw.trim();
|
|
81
139
|
return /^-?\d+(\.\d+)?(deg)?\s+\d+(\.\d+)?%\s+\d+(\.\d+)?%(\s*\/\s*[\d.]+%?)?$/.test(v) ? `hsl(${v})` : v;
|
package/dist/html-frame.cjs.map
CHANGED
|
@@ -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 hostTheme,\n hostTokens,\n sampleDocument,\n sampleHeight,\n sampleStyle,\n tokenValue,\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 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/** 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 `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;;;ACQA,mBAAuF;AACvF,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,gBAAgB;AAGf,SAAS,SAAS,OAA8C;AACrE,QAAM,WAAW,CAAC,GAAG,IAAI,KAAK,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,uBAAuB,KAAK,CAAC,KAAK,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC;AACpJ,MAAI,SAAS,WAAW,EAAG,QAAO;AAClC,QAAM,IAAI,SAAS,IAAI,CAAC,MAAM,UAA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;AAC1C,YAAQ;AAAA,EACV;AAEA,8BAAU,OAAO,CAAC,OAAO,KAAK,CAAC;AAG/B,8BAAU,MAAM;AACd,UAAM,KAAK,MAAM;AACjB,QAAI,CAAC,MAAM,OAAO,mBAAmB,YAAa;AAClD,UAAM,KAAK,IAAI,eAAe,MAAM,QAAQ,CAAC;AAC7C,OAAG,QAAQ,EAAE;AACb,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B,GAAG,CAAC,CAAC;AAEL,QAAM,SAAS,MAAM;AACnB,UAAM;AACN,UAAM,QAAQ,MAAM,SAAS;AAC7B,QAAI,CAAC,MAAO;AAEZ,UAAM,iBAAiB,QAAQ,SAAS,IAAI;AAC5C,SAAK,MAAM,OAAO,MAAM,KAAK,OAAO,EAAE,MAAM,MAAM,MAAS;AAC3D,UAAM,MAAM,MAAM,eAAe,cAAc;AAC/C,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":[]}
|
|
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 body = tokens[\"font-body\"];\n if (body && !/[;{}<>]/.test(body)) out.fontFamily = body;\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 return (\n <div data-token-scope={set ? \"\" : undefined} className={className} style={tokenScopeStyle(set, theme) as CSSProperties}>\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 `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;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AK,MAAM;AACjB,QAAI,CAAC,MAAM,OAAO,mBAAmB,YAAa;AAClD,UAAM,KAAK,IAAI,eAAe,MAAM,QAAQ,CAAC;AAC7C,OAAG,QAAQ,EAAE;AACb,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B,GAAG,CAAC,CAAC;AAEL,QAAM,SAAS,MAAM;AACnB,UAAM;AACN,UAAM,QAAQ,MAAM,SAAS;AAC7B,QAAI,CAAC,MAAO;AAEZ,UAAM,iBAAiB,QAAQ,SAAS,IAAI;AAC5C,SAAK,MAAM,OAAO,MAAM,KAAK,OAAO,EAAE,MAAM,MAAM,MAAS;AAC3D,UAAM,MAAM,MAAM,eAAe,cAAc;AAC/C,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":[]}
|
package/dist/html-frame.d.cts
CHANGED
|
@@ -16,11 +16,34 @@ interface SampleTokenSet {
|
|
|
16
16
|
/** Web font families the samples name (a board's type styles); loaded from Google Fonts. */
|
|
17
17
|
fonts?: readonly string[];
|
|
18
18
|
}
|
|
19
|
+
/** The one stylesheet link that loads these families, or "" when none needs loading. */
|
|
20
|
+
declare function fontLink(fonts: readonly string[] | undefined): string;
|
|
19
21
|
/** A host's own token values for every sample under it (a board's design-system tables). */
|
|
20
22
|
declare function HtmlSampleTokensProvider({ tokens, children }: {
|
|
21
23
|
tokens: SampleTokenSet | null;
|
|
22
24
|
children: ReactNode;
|
|
23
25
|
}): react.JSX.Element;
|
|
26
|
+
/** The token set a host provided for the samples under it (a board's design-system tables), or null. */
|
|
27
|
+
declare function useSampleTokens(): SampleTokenSet | null;
|
|
28
|
+
/** A hex color as the app's bare HSL triplet ("210 80% 45%"), or null for anything else. */
|
|
29
|
+
declare function hexToHslTriplet(hex: string): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* The CSS variables that put app content (prose, controls) into the provided design system for one theme:
|
|
32
|
+
* each color token the app keeps as an HSL triplet is overridden with the board's color, and the text takes
|
|
33
|
+
* the board's body font. Nothing outside the scope changes.
|
|
34
|
+
*/
|
|
35
|
+
declare function tokenScopeStyle(set: SampleTokenSet | null, theme: SampleTheme): Record<string, string>;
|
|
36
|
+
/** The host page's theme, followed as it changes. */
|
|
37
|
+
declare function useHostTheme(): SampleTheme;
|
|
38
|
+
/**
|
|
39
|
+
* APP CONTENT IN THE HOST'S DESIGN SYSTEM: everything under it (a cover's prose, a card's text) draws with the
|
|
40
|
+
* provided tokens (a board's own colors and body font) in the page's current theme. No provided tokens: it is
|
|
41
|
+
* a plain wrapper and the app's own tokens apply.
|
|
42
|
+
*/
|
|
43
|
+
declare function TokenScope({ className, children }: {
|
|
44
|
+
className?: string;
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}): react.JSX.Element;
|
|
24
47
|
/** A bare HSL triplet ("240 5% 96%", how the app keeps its colors) becomes a color a sample can use. */
|
|
25
48
|
declare function tokenValue(raw: string): string;
|
|
26
49
|
/** The host page's theme: `dark` when its root wears the `dark` class or `data-theme="dark"`. */
|
|
@@ -31,6 +54,8 @@ declare function hostTokens(at: Element | null): Record<string, string>;
|
|
|
31
54
|
declare function sampleStyle(tokens: SampleTokens, theme: SampleTheme, font?: string): string;
|
|
32
55
|
/** The whole document the frame draws: CSP, tokens, the reset, and the sample inside one measured box. */
|
|
33
56
|
declare function sampleDocument(html: string, tokens: SampleTokens, theme: SampleTheme, font?: string, fonts?: readonly string[]): string;
|
|
57
|
+
/** A wheel inside a sample, re-dispatched on the frame element so the page or board around it scrolls. */
|
|
58
|
+
declare function forwardWheel(target: HTMLIFrameElement | null, e: WheelEvent): void;
|
|
34
59
|
/** The sample's drawn height in px, from its one measured box (margins included: it is a flow root). */
|
|
35
60
|
declare function sampleHeight(doc: Document | null | undefined): number;
|
|
36
61
|
interface HtmlSampleFrameProps {
|
|
@@ -47,4 +72,4 @@ interface HtmlSampleFrameProps {
|
|
|
47
72
|
*/
|
|
48
73
|
declare function HtmlSampleFrame({ html, title, className, initialHeight }: HtmlSampleFrameProps): react.JSX.Element;
|
|
49
74
|
|
|
50
|
-
export { HTML_SAMPLE_CSP, HTML_SAMPLE_SANDBOX, HtmlSampleFrame, type HtmlSampleFrameProps, HtmlSampleTokensProvider, SAMPLE_TOKEN_NAMES, type SampleTheme, type SampleTokenSet, type SampleTokens, hostTheme, hostTokens, sampleDocument, sampleHeight, sampleStyle, tokenValue };
|
|
75
|
+
export { HTML_SAMPLE_CSP, HTML_SAMPLE_SANDBOX, HtmlSampleFrame, type HtmlSampleFrameProps, HtmlSampleTokensProvider, SAMPLE_TOKEN_NAMES, type SampleTheme, type SampleTokenSet, type SampleTokens, TokenScope, fontLink, forwardWheel, hexToHslTriplet, hostTheme, hostTokens, sampleDocument, sampleHeight, sampleStyle, tokenScopeStyle, tokenValue, useHostTheme, useSampleTokens };
|
package/dist/html-frame.d.ts
CHANGED
|
@@ -16,11 +16,34 @@ interface SampleTokenSet {
|
|
|
16
16
|
/** Web font families the samples name (a board's type styles); loaded from Google Fonts. */
|
|
17
17
|
fonts?: readonly string[];
|
|
18
18
|
}
|
|
19
|
+
/** The one stylesheet link that loads these families, or "" when none needs loading. */
|
|
20
|
+
declare function fontLink(fonts: readonly string[] | undefined): string;
|
|
19
21
|
/** A host's own token values for every sample under it (a board's design-system tables). */
|
|
20
22
|
declare function HtmlSampleTokensProvider({ tokens, children }: {
|
|
21
23
|
tokens: SampleTokenSet | null;
|
|
22
24
|
children: ReactNode;
|
|
23
25
|
}): react.JSX.Element;
|
|
26
|
+
/** The token set a host provided for the samples under it (a board's design-system tables), or null. */
|
|
27
|
+
declare function useSampleTokens(): SampleTokenSet | null;
|
|
28
|
+
/** A hex color as the app's bare HSL triplet ("210 80% 45%"), or null for anything else. */
|
|
29
|
+
declare function hexToHslTriplet(hex: string): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* The CSS variables that put app content (prose, controls) into the provided design system for one theme:
|
|
32
|
+
* each color token the app keeps as an HSL triplet is overridden with the board's color, and the text takes
|
|
33
|
+
* the board's body font. Nothing outside the scope changes.
|
|
34
|
+
*/
|
|
35
|
+
declare function tokenScopeStyle(set: SampleTokenSet | null, theme: SampleTheme): Record<string, string>;
|
|
36
|
+
/** The host page's theme, followed as it changes. */
|
|
37
|
+
declare function useHostTheme(): SampleTheme;
|
|
38
|
+
/**
|
|
39
|
+
* APP CONTENT IN THE HOST'S DESIGN SYSTEM: everything under it (a cover's prose, a card's text) draws with the
|
|
40
|
+
* provided tokens (a board's own colors and body font) in the page's current theme. No provided tokens: it is
|
|
41
|
+
* a plain wrapper and the app's own tokens apply.
|
|
42
|
+
*/
|
|
43
|
+
declare function TokenScope({ className, children }: {
|
|
44
|
+
className?: string;
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}): react.JSX.Element;
|
|
24
47
|
/** A bare HSL triplet ("240 5% 96%", how the app keeps its colors) becomes a color a sample can use. */
|
|
25
48
|
declare function tokenValue(raw: string): string;
|
|
26
49
|
/** The host page's theme: `dark` when its root wears the `dark` class or `data-theme="dark"`. */
|
|
@@ -31,6 +54,8 @@ declare function hostTokens(at: Element | null): Record<string, string>;
|
|
|
31
54
|
declare function sampleStyle(tokens: SampleTokens, theme: SampleTheme, font?: string): string;
|
|
32
55
|
/** The whole document the frame draws: CSP, tokens, the reset, and the sample inside one measured box. */
|
|
33
56
|
declare function sampleDocument(html: string, tokens: SampleTokens, theme: SampleTheme, font?: string, fonts?: readonly string[]): string;
|
|
57
|
+
/** A wheel inside a sample, re-dispatched on the frame element so the page or board around it scrolls. */
|
|
58
|
+
declare function forwardWheel(target: HTMLIFrameElement | null, e: WheelEvent): void;
|
|
34
59
|
/** The sample's drawn height in px, from its one measured box (margins included: it is a flow root). */
|
|
35
60
|
declare function sampleHeight(doc: Document | null | undefined): number;
|
|
36
61
|
interface HtmlSampleFrameProps {
|
|
@@ -47,4 +72,4 @@ interface HtmlSampleFrameProps {
|
|
|
47
72
|
*/
|
|
48
73
|
declare function HtmlSampleFrame({ html, title, className, initialHeight }: HtmlSampleFrameProps): react.JSX.Element;
|
|
49
74
|
|
|
50
|
-
export { HTML_SAMPLE_CSP, HTML_SAMPLE_SANDBOX, HtmlSampleFrame, type HtmlSampleFrameProps, HtmlSampleTokensProvider, SAMPLE_TOKEN_NAMES, type SampleTheme, type SampleTokenSet, type SampleTokens, hostTheme, hostTokens, sampleDocument, sampleHeight, sampleStyle, tokenValue };
|
|
75
|
+
export { HTML_SAMPLE_CSP, HTML_SAMPLE_SANDBOX, HtmlSampleFrame, type HtmlSampleFrameProps, HtmlSampleTokensProvider, SAMPLE_TOKEN_NAMES, type SampleTheme, type SampleTokenSet, type SampleTokens, TokenScope, fontLink, forwardWheel, hexToHslTriplet, hostTheme, hostTokens, sampleDocument, sampleHeight, sampleStyle, tokenScopeStyle, tokenValue, useHostTheme, useSampleTokens };
|
package/dist/html-frame.js
CHANGED
|
@@ -5,13 +5,20 @@ import {
|
|
|
5
5
|
HtmlSampleFrame,
|
|
6
6
|
HtmlSampleTokensProvider,
|
|
7
7
|
SAMPLE_TOKEN_NAMES,
|
|
8
|
+
TokenScope,
|
|
9
|
+
fontLink,
|
|
10
|
+
forwardWheel,
|
|
11
|
+
hexToHslTriplet,
|
|
8
12
|
hostTheme,
|
|
9
13
|
hostTokens,
|
|
10
14
|
sampleDocument,
|
|
11
15
|
sampleHeight,
|
|
12
16
|
sampleStyle,
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
tokenScopeStyle,
|
|
18
|
+
tokenValue,
|
|
19
|
+
useHostTheme,
|
|
20
|
+
useSampleTokens
|
|
21
|
+
} from "./chunk-FFST26WB.js";
|
|
15
22
|
import "./chunk-HKYEHBQT.js";
|
|
16
23
|
export {
|
|
17
24
|
HTML_SAMPLE_CSP,
|
|
@@ -19,11 +26,18 @@ export {
|
|
|
19
26
|
HtmlSampleFrame,
|
|
20
27
|
HtmlSampleTokensProvider,
|
|
21
28
|
SAMPLE_TOKEN_NAMES,
|
|
29
|
+
TokenScope,
|
|
30
|
+
fontLink,
|
|
31
|
+
forwardWheel,
|
|
32
|
+
hexToHslTriplet,
|
|
22
33
|
hostTheme,
|
|
23
34
|
hostTokens,
|
|
24
35
|
sampleDocument,
|
|
25
36
|
sampleHeight,
|
|
26
37
|
sampleStyle,
|
|
27
|
-
|
|
38
|
+
tokenScopeStyle,
|
|
39
|
+
tokenValue,
|
|
40
|
+
useHostTheme,
|
|
41
|
+
useSampleTokens
|
|
28
42
|
};
|
|
29
43
|
//# sourceMappingURL=html-frame.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -41496,10 +41496,6 @@ function typedFormulaFields(all, rounds = FORMULA_TYPING_ROUNDS) {
|
|
|
41496
41496
|
byRounds.set(rounds, cur);
|
|
41497
41497
|
return cur;
|
|
41498
41498
|
}
|
|
41499
|
-
function formulaTypeOf(targetId, all, rounds = FORMULA_TYPING_ROUNDS) {
|
|
41500
|
-
const expr = ownExpression(all.find((f) => f.id === targetId));
|
|
41501
|
-
return expr ? formulaResultKind(expr, typedFormulaFields(all, rounds)) : "unknown";
|
|
41502
|
-
}
|
|
41503
41499
|
function formulaResultKind(node, all) {
|
|
41504
41500
|
if (!node || typeof node !== "object" || Array.isArray(node)) return "unknown";
|
|
41505
41501
|
const n = node;
|
|
@@ -41537,7 +41533,8 @@ function formulaResultKind(node, all) {
|
|
|
41537
41533
|
return import_records55.FORMULA_NODE_RESULTS[op2] ?? "unknown";
|
|
41538
41534
|
}
|
|
41539
41535
|
function isDateFormula(field2, all) {
|
|
41540
|
-
|
|
41536
|
+
const expr = ownExpression(field2);
|
|
41537
|
+
return !!expr && formulaResultKind(expr, typedFormulaFields(all)) === "date";
|
|
41541
41538
|
}
|
|
41542
41539
|
function isComputedField(field2) {
|
|
41543
41540
|
return field2?.type === "formula";
|