@ai-matrx/records-ui 0.116.24 → 0.116.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/README.md +3 -3
- package/dist/SaveToTable-P3MPRSCW.js +20 -0
- package/dist/{chunk-MUK63ANA.js → chunk-4ZS4WEEE.js} +3 -3
- package/dist/chunk-4ZS4WEEE.js.map +1 -0
- package/dist/{chunk-SYHUPGCU.js → chunk-6Z537SLG.js} +1 -1
- package/dist/{chunk-SYHUPGCU.js.map → chunk-6Z537SLG.js.map} +1 -1
- package/dist/{chunk-ODABFEHG.js → chunk-7RSMA3NK.js} +3 -3
- package/dist/chunk-7RSMA3NK.js.map +1 -0
- package/dist/{chunk-VHZKLE63.js → chunk-FLIERNH7.js} +9 -9
- package/dist/chunk-FLIERNH7.js.map +1 -0
- package/dist/{chunk-ZNIXJ5RY.js → chunk-KQR2RA4V.js} +3 -3
- package/dist/{chunk-WQGFKNE2.js → chunk-OJTJ4HJI.js} +26 -26
- package/dist/chunk-OJTJ4HJI.js.map +1 -0
- package/dist/{chunk-PPWNFIJ5.js → chunk-OV6QBL5R.js} +2 -2
- package/dist/{chunk-PPWNFIJ5.js.map → chunk-OV6QBL5R.js.map} +1 -1
- package/dist/{chunk-5IX4BL72.js → chunk-QBMUTXTQ.js} +2 -2
- package/dist/{chunk-5IX4BL72.js.map → chunk-QBMUTXTQ.js.map} +1 -1
- package/dist/{chunk-MCDA6L7E.js → chunk-TC5S4VOW.js} +2 -2
- package/dist/chunk-TC5S4VOW.js.map +1 -0
- package/dist/{chunk-FECWKOWW.js → chunk-W7GR64CB.js} +1 -1
- package/dist/chunk-W7GR64CB.js.map +1 -0
- package/dist/{chunk-FHL4GG6R.js → chunk-WCQSJPLS.js} +2 -2
- package/dist/chunk-WCQSJPLS.js.map +1 -0
- package/dist/data-source.cjs.map +1 -1
- package/dist/data-source.d.cts +1 -1
- package/dist/data-source.d.ts +1 -1
- package/dist/data-source.js.map +1 -1
- package/dist/first-page.cjs.map +1 -1
- package/dist/first-page.d.cts +1 -1
- package/dist/first-page.d.ts +1 -1
- package/dist/first-page.js.map +1 -1
- package/dist/helpers.cjs +4 -4
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +9 -9
- package/dist/helpers.d.ts +9 -9
- package/dist/helpers.js +4 -4
- package/dist/helpers.js.map +1 -1
- package/dist/html-frame.cjs.map +1 -1
- package/dist/html-frame.d.cts +1 -1
- package/dist/html-frame.d.ts +1 -1
- package/dist/html-frame.js +1 -1
- package/dist/index.cjs +147 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -46
- package/dist/index.d.ts +46 -46
- package/dist/index.js +133 -102
- package/dist/index.js.map +1 -1
- package/dist/object-actions.cjs +2 -2
- package/dist/object-actions.cjs.map +1 -1
- package/dist/object-actions.js +3 -3
- package/dist/pickers.cjs +23 -23
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +8 -8
- package/dist/skeleton.cjs.map +1 -1
- package/dist/skeleton.js +4 -4
- package/dist/table-shape.cjs.map +1 -1
- package/dist/table-shape.js +1 -1
- package/package.json +4 -4
- package/dist/SaveToTable-PGOQVYVS.js +0 -20
- package/dist/chunk-FECWKOWW.js.map +0 -1
- package/dist/chunk-FHL4GG6R.js.map +0 -1
- package/dist/chunk-MCDA6L7E.js.map +0 -1
- package/dist/chunk-MUK63ANA.js.map +0 -1
- package/dist/chunk-ODABFEHG.js.map +0 -1
- package/dist/chunk-VHZKLE63.js.map +0 -1
- package/dist/chunk-WQGFKNE2.js.map +0 -1
- /package/dist/{SaveToTable-PGOQVYVS.js.map → SaveToTable-P3MPRSCW.js.map} +0 -0
- /package/dist/{chunk-ZNIXJ5RY.js.map → chunk-KQR2RA4V.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
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 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 colours) becomes a colour 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/** 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 };\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,gBAAgC;AACvF,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;AACr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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;AAAA,EACvF;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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fieldTypes.ts"],"sourcesContent":["// src/fieldTypes.ts — @ai-matrx/records-ui\n//\n// EVERY KIND OF COLUMN THE STORE TAKES, IN THE WORDS A PERSON USES.\n//\n// The store publishes fourteen parity types and, for each, a sentence about what\n// it is MADE OF — \"REC-31: a File record reached through a relation, target the\n// kernel `File` Table\", \"FLD-9: a declared computation, on read or on write,\n// evaluated by custom.rule_eval\", \"config.via names the relation field,\n// config.pick the Value on the far side\". Those sentences are true and they are\n// for us. The 19 September verdict found them printed at the person choosing a\n// column type, alongside contract row ids, and called it what it is: machine\n// identity where a person is looking.\n//\n// So this file holds the OTHER sentence — what the type is FOR — and the field\n// panel shows that one. The store's own `made_of` stays where it belongs, in\n// `PARITY_MADE_OF`, for an engineer reading the package.\n//\n// The LIST itself is still the store's: `PARITY_FIELD_TYPES` is generated from\n// `custom.parity_field_types()`, and `assertEveryParityTypeIsExplained` (run by\n// the suite) fails the moment the store ships a fourteenth and nobody wrote a\n// sentence for it. A type with no explanation would otherwise appear with a\n// blank line under it, which is the silent version of the same defect. It caught the\n// fourteenth — `checkbox`, 2026-09-21 — exactly as it was written to.\n\nimport { DECLARABLE_FIELD_KINDS, NEWER_FIELD_KINDS, PARITY_FIELD_TYPES, type DeclarableFieldKind, type NewerFieldKind, type ParityFieldType } from \"@ai-matrx/records/field-kinds\";\n\n/** The three behaviours that carry no parity type of their own. */\nexport type PlainFieldType = \"text\" | \"long_text\" | \"number\";\n\n/**\n * THE ONE A PERSON COMING FROM AIRTABLE REACHES FOR FIRST, AND IT WAS NOT HERE.\n *\n * The list above offered `member` (a Person) and `attachment` (a File) — the two\n * relations whose target is a Table the PLATFORM keeps — and nothing at all for\n * \"this job belongs to that customer\". The store has taken it since 2026-09-20\n * (`custom.field_declare` with `type: \"relation\"` and a `relation_target`), the\n * Field type has named it since the same day, and `editorKindFor` has answered\n * `\"relation\"` for one since long before that. Only the menu did not offer it,\n * so the guide's section 3 told a person to pick a kind that did not exist.\n *\n * It is NOT a parity type of its own. `custom.parity_field_types()` ships\n * fourteen (the fourteenth is `checkbox`) and a relation is a BEHAVIOUR — the same behaviour `member` and\n * `attachment` are made of — so it sits beside the three plain ones as its own\n * word, and `parityTypesWithNoExplanation()` is unaffected by it in both\n * directions: it does not appear there, and it cannot hide a real gap there.\n */\nexport type RelationFieldType = \"relation\";\n\n/**\n * What a person picks in the panel — AND IT IS THE STORE'S OWN LIST, not a union\n * assembled here.\n *\n * 🚨 THE CLASS FIX (FIX-10B-F6, VERIFIER-10). This used to read\n * `ParityFieldType | PlainFieldType | RelationFieldType` — the parity floor plus two words\n * this file knew about — and that union was the whole defect. `custom.doc_sign` accepts\n * exactly one field, a text column whose format is `signature`, and it is granted to\n * `authenticated`; the Documents screen told a person in so many words to go and declare\n * one; and no list any screen could read named it, so the control did not exist and the\n * e-sign half of Documents was unreachable from the product. A kind the store takes and no\n * screen offers is invisible, and nothing failed — which is the only reason it survived.\n *\n * `custom.field_kinds()` is now the ONE registry and `DECLARABLE_FIELD_KINDS` is generated\n * from it, so the next kind the store learns arrives here as a TYPE ERROR in\n * `FIELD_TYPE_CHOICES`'s coverage and as a red `kindsWithNoChoice()` below — never as a\n * silence.\n */\nexport type PickableFieldType = DeclarableFieldKind | SystemFieldKind | \"entity_reference\" | NewerFieldKind | LookFieldKind;\n\n/**\n * A KIND THAT IS A PLAIN COLUMN WEARING A LOOK (grids review 3, lane H item 5). The store keeps a\n * column's \"Shows as\" on the Field (`display_format`, `custom.display_format_ids()` has `rating` and\n * `time`), so a Rating is a whole number shown as stars and a Time is a time of day kept as its\n * 24-hour text — declared through the ordinary door (`{ plain, display_format }`) the same way the\n * \"Shows as\" picker makes one. Offered whenever the store does not yet publish the kind as its own\n * word (`custom.field_kinds()`): a Rating the store publishes goes as `{ type: \"rating\", max }`.\n */\nexport type LookFieldKind = \"time\" | \"color_pair\" | \"measure\" | \"type_style\" | \"shadow\";\n\nexport interface LookKind {\n plain: \"number\" | \"text\";\n look: (args: { ratingMax: number }) => { id: string; options?: Record<string, unknown> };\n}\n\nexport const LOOK_KINDS: Partial<Record<PickableFieldType, LookKind>> = {\n rating: { plain: \"number\", look: ({ ratingMax }) => ({ id: \"rating\", options: { ratingMax } }) },\n time: { plain: \"text\", look: () => ({ id: \"time\" }) },\n // PLUG-IN DESIGN LOOKS (2026-10-17, `looks/designLooks.tsx`): a structured token is JSON text in a text column.\n color_pair: { plain: \"text\", look: () => ({ id: \"color_pair\" }) },\n measure: { plain: \"number\", look: () => ({ id: \"measure\", options: { unit: \"px\" } }) },\n type_style: { plain: \"text\", look: () => ({ id: \"type_style\" }) },\n shadow: { plain: \"text\", look: () => ({ id: \"shadow\" }) },\n};\n\n/** Is this kind declared as a plain column wearing a look (because the store does not publish it)? */\nexport function declaredAsLook(kind: string): boolean {\n return kind in LOOK_KINDS && !storePublishesKind(kind);\n}\n\n/**\n * LANE 10 P4: THE NINE NEWER KINDS (rating, duration, created by, last changed by, status, address,\n * barcode, formatted text, count). Each is listed in `FIELD_TYPE_CATALOGUE` below, so every reader\n * (Settings, the column panel, every layout) names a column of one by its own word; the MENU offers\n * one only once `custom.field_kinds()` publishes it (after the chair's apply and\n * `pnpm records:generate`), so a person is never offered a kind the live store would refuse.\n */\nexport function storePublishesKind(kind: string): boolean {\n return DECLARABLE_FIELD_KINDS.some((row) => (row.kind as string) === kind);\n}\n\n/**\n * LANE SC-R: a column that points at a PLATFORM thing (a note, a web site, an agent). Its menu entry\n * is drawn only once `custom.field_kinds()` publishes `entity_reference` (after the chair's apply\n * and `pnpm records:generate`), so the menu never offers a kind the live store would refuse.\n */\nexport const STORE_PUBLISHES_ENTITY_REFERENCE = DECLARABLE_FIELD_KINDS.some(\n (row) => (row.kind as string) === \"entity_reference\",\n);\n\n/**\n * THE STORE'S OWN STAMPS AS COLUMNS (GRID-PRIMITIVES G5; TABLE-PARITY H2 H3, lane\n * DEFAULT-GRID-PARITY). `custom.field_declare` takes these three WORDS and makes each a formula\n * Field whose expression is the system node (`fx.autonumber`, `fx.created_time`,\n * `fx.modified_time`, `config.system` naming which), so nobody types into them and every reader\n * that serves a worked-out value serves them. `custom.field_kinds()` does not publish them,\n * because each is a formula, not a behaviour of its own. So they are named here, sent as their\n * word through the `{ type }` arm, and a new autonumber column numbers the records already in\n * the table through `custom.autonumber_backfill`.\n */\nexport type SystemFieldKind = \"autonumber\" | \"created_time\" | \"modified_time\";\n\nexport const SYSTEM_FIELD_KINDS: readonly SystemFieldKind[] = [\"autonumber\", \"created_time\", \"modified_time\"];\n\nexport function isSystemFieldKind(id: string): id is SystemFieldKind {\n return (SYSTEM_FIELD_KINDS as readonly string[]).includes(id);\n}\n\nexport interface FieldTypeChoice {\n id: PickableFieldType;\n /** The word on the menu. */\n label: string;\n /** One line, under the word, saying what it is FOR. Never what it is made of. */\n explanation: string;\n /** The heading it sits under, so seventeen choices read as four short lists. */\n group: \"Words\" | \"Numbers and dates\" | \"Choices and people\" | \"Worked out\";\n}\n\n/**\n * EVERY KIND THIS PACKAGE CAN NAME AND DRAW, in menu order. The menu (`FIELD_TYPE_CHOICES`) is this\n * list less the kinds the live store does not take yet; every reader names a column from this one.\n */\nexport const FIELD_TYPE_CATALOGUE: FieldTypeChoice[] = [\n { id: \"text\", group: \"Words\", label: \"Text\", explanation: \"A short line of writing — a name, a reference, a title.\" },\n { id: \"long_text\", group: \"Words\", label: \"Long text\", explanation: \"Several lines — a description, notes, an address.\" },\n { id: \"rich_text\", group: \"Words\", label: \"Formatted text\", explanation: \"Notes with bold, lists and links.\" },\n { id: \"email\", group: \"Words\", label: \"Email address\", explanation: \"An email address, checked as you type and ready to write to.\" },\n { id: \"phone\", group: \"Words\", label: \"Phone number\", explanation: \"A phone number, checked as you type.\" },\n { id: \"url\", group: \"Words\", label: \"Link\", explanation: \"A web address that opens in a new tab when you click it.\" },\n { id: \"address\", group: \"Words\", label: \"Address\", explanation: \"A street address in parts, opened in maps.\" },\n { id: \"color_pair\", group: \"Words\", label: \"Colour\", explanation: \"A colour for light and dark, with a readability check.\" },\n { id: \"type_style\", group: \"Words\", label: \"Type style\", explanation: \"A font, weight and size, shown as a sample.\" },\n { id: \"shadow\", group: \"Words\", label: \"Shadow\", explanation: \"A shadow, shown on a card.\" },\n { id: \"json\", group: \"Words\", label: \"JSON\", explanation: \"Structured data — a list or a set of named values — shown folded.\" },\n { id: \"barcode\", group: \"Words\", label: \"Barcode\", explanation: \"A code a scanner reads, like a wristband or a box.\" },\n { id: \"button\", group: \"Words\", label: \"Button\", explanation: \"A button on each record that opens a link or runs an action.\" },\n\n { id: \"number\", group: \"Numbers and dates\", label: \"Number\", explanation: \"A plain number you can total up and sort by.\" },\n { id: \"currency\", group: \"Numbers and dates\", label: \"Money\", explanation: \"An amount of money, shown with its currency wherever it appears.\" },\n { id: \"percent\", group: \"Numbers and dates\", label: \"Percentage\", explanation: \"A number out of a hundred, kept between 0 and 100.\" },\n { id: \"rating\", group: \"Numbers and dates\", label: \"Rating\", explanation: \"A score in stars, set with one click.\" },\n { id: \"duration\", group: \"Numbers and dates\", label: \"Duration\", explanation: \"A length of time, typed as 45 min or 1:30.\" },\n { id: \"time\", group: \"Numbers and dates\", label: \"Time\", explanation: \"A time of day with no date — a shift start, opening hours.\" },\n { id: \"measure\", group: \"Numbers and dates\", label: \"Size\", explanation: \"A number with a unit: 16 px, 1.5 rem, 200 ms.\" },\n { id: \"datetime\", group: \"Numbers and dates\", label: \"Date\", explanation: \"A day, or a day and a time. Dates are what the calendar view reads.\" },\n\n { id: \"select\", group: \"Choices and people\", label: \"Choice\", explanation: \"One answer from a list you write here. Choices are what the board view groups by.\" },\n { id: \"multi_select\", group: \"Choices and people\", label: \"Several choices\", explanation: \"Any number of answers from a list you write here.\" },\n { id: \"status\", group: \"Choices and people\", label: \"Status\", explanation: \"Choices grouped into To do, In progress and Done.\" },\n { id: \"checkbox\", group: \"Choices and people\", label: \"Yes / no\", explanation: \"A box you tick. Left alone it stays unanswered, which is not the same as a no.\" },\n { id: \"member\", group: \"Choices and people\", label: \"Person\", explanation: \"Somebody in this organization, picked from the people who are in it.\" },\n { id: \"attachment\", group: \"Choices and people\", label: \"File\", explanation: \"A file or a picture kept with the record.\" },\n { id: \"signature\", group: \"Choices and people\", label: \"Signature\", explanation: \"Somebody's sign-off on a document made from this record. Nobody types in it — it fills in when they sign.\" },\n { id: \"relation\", group: \"Choices and people\", label: \"Points at another record\", explanation: \"A link to records in another of your tables — the customer a job is for, the lines on an invoice.\" },\n {\n id: \"entity_reference\",\n group: \"Choices and people\",\n label: \"Points at something else on the platform\",\n explanation: \"A note, a web site, an agent, a workbook — anything you keep here that is not one of your tables.\",\n },\n\n { id: \"lookup\", group: \"Worked out\", label: \"Borrowed value\", explanation: \"A value read from a record this one points at, kept in step with it.\" },\n { id: \"rollup\", group: \"Worked out\", label: \"Total of linked records\", explanation: \"A count or a total worked out from the records this one points at.\" },\n { id: \"count\", group: \"Worked out\", label: \"Count of linked records\", explanation: \"How many records this one points at.\" },\n { id: \"formula\", group: \"Worked out\", label: \"Worked out from other columns\", explanation: \"A value this record works out for itself from its own other columns.\" },\n { id: \"autonumber\", group: \"Worked out\", label: \"Record number\", explanation: \"A number the table gives each record, one after another, never reused. Records already here are numbered in the order they were made.\" },\n { id: \"created_time\", group: \"Worked out\", label: \"Created time\", explanation: \"When each record was made. Nobody types it.\" },\n { id: \"modified_time\", group: \"Worked out\", label: \"Last changed time\", explanation: \"When each record last changed. Nobody types it.\" },\n { id: \"created_by\", group: \"Worked out\", label: \"Created by\", explanation: \"Who made each record. Nobody types it.\" },\n { id: \"modified_by\", group: \"Worked out\", label: \"Last changed by\", explanation: \"Who last changed each record. Nobody types it.\" },\n];\n\n/** The kinds the menu offers only once the live store publishes them. */\nconst GATED_KINDS = new Set<string>([\"entity_reference\", ...NEWER_FIELD_KINDS]);\n\nexport const FIELD_TYPE_CHOICES: FieldTypeChoice[] = FIELD_TYPE_CATALOGUE.filter(\n (c) => !GATED_KINDS.has(c.id) || storePublishesKind(c.id) || c.id in LOOK_KINDS,\n);\n\nexport const FIELD_TYPE_GROUPS: FieldTypeChoice[\"group\"][] = [\n \"Words\",\n \"Numbers and dates\",\n \"Choices and people\",\n \"Worked out\",\n];\n\nconst BY_ID = new Map<string, FieldTypeChoice>(FIELD_TYPE_CATALOGUE.map((c) => [c.id, c]));\n\nexport function fieldTypeChoice(id: string): FieldTypeChoice | undefined {\n return BY_ID.get(id);\n}\n\n/** The three that are a plain behaviour rather than one of the fourteen. */\nexport function isPlainFieldType(id: string): id is PlainFieldType {\n return id === \"text\" || id === \"long_text\" || id === \"number\";\n}\n\n/**\n * The one that is a relation a person aims themselves. It is neither plain nor\n * one of the thirteen, so every caller that branched on `isPlainFieldType`\n * alone has to answer this question too — which is why it is a named function\n * and not an inline string comparison at four call sites.\n */\nexport function isRelationFieldType(id: string): id is RelationFieldType {\n return id === \"relation\";\n}\n\n/**\n * One of FLD-11's fourteen, which is what `parity_type` on a declaration means.\n *\n * Read from the store's own generated floor, never from a list here — because a kind that\n * is NOT one of the fourteen (plain text, a person-aimed relation, a signature) has to be\n * declared by its WORD (`type`) and a panel that sent `parity_type` for it would be refused\n * \"There is no field type called …\". That is the shape of the F6 defect: the panel's `save`\n * had exactly two branches, relation and plain, and everything else fell into `parity_type`.\n */\nexport function isParityFieldType(id: string): id is ParityFieldType {\n return PARITY_FIELD_TYPES.some((row) => row.parity_type === id);\n}\n\n/**\n * THE GUARD THIS FILE NEEDS, because the list it explains is generated.\n *\n * Returns the parity types the store ships that nothing here explains. The\n * suite asserts it is empty; a fourteenth type would otherwise reach the menu\n * with a blank line under it and nobody would notice until a person did.\n *\n * `relation` is deliberately NOT one of the thirteen and therefore never\n * appears in this answer: `PARITY_FIELD_TYPES` is the store's own generated\n * list and a behaviour that carries no parity type is not in it.\n */\nexport function parityTypesWithNoExplanation(): string[] {\n return PARITY_FIELD_TYPES.map((row) => row.parity_type).filter((type) => !BY_ID.has(type));\n}\n\n/**\n * 🚨 THE GUARD THAT CLOSES THE CLASS (FIX-10B-F6).\n *\n * `parityTypesWithNoExplanation()` above watches the parity FLOOR, and the floor was never\n * the whole list: the store also declares plain text, long text, number, a person-aimed\n * relation and a signature, and for months nothing anywhere compared the panel's menu with\n * THAT. So `signature` — the one field `custom.doc_sign` accepts, on a door granted to\n * every signed-in person, named to the person by the Documents screen itself — was absent\n * from the menu and every check stayed green.\n *\n * This returns the kinds `custom.field_kinds()` publishes that this panel does not offer.\n * The suite asserts it is empty, so a kind the store learns tomorrow either reaches the\n * person or turns a test red the same day. It is the class, not the instance: it would have\n * caught `signature`, and it will catch the twentieth kind nobody has thought of yet.\n */\nexport function kindsWithNoChoice(): string[] {\n return DECLARABLE_FIELD_KINDS.map((row) => row.kind).filter((kind) => !BY_ID.has(kind));\n}\n\n// ───────────────────────────────────────────────────────────────────────────\n// THE WORDS ON THE TWO BUTTONS, IN ONE PLACE — because they used to be the SAME\n// WORDS in two places, and that cost somebody their column.\n//\n// 🚨 THE DEFECT (TAILS-5, 2026-09-21, measured while driving the panel headless\n// on Rincon Plumbing's Summerland branch). The Jobs toolbar's control that OPENS\n// the field panel read exactly \"Add field\", and the panel's own SAVE button read\n// exactly \"Add field\" too — `FieldEditor` says \"Save field\" only when EDITING an\n// existing column, so on the create path the two were character-identical. The\n// toolbar control is a TOGGLE: pressing it while the panel is open closes the\n// panel and throws away everything typed into it. So a person who typed a column\n// name, chose a type, picked the target table and its display columns, then\n// looked up at the words they were told to press, could lose all of it — with no\n// sentence, no request sent, and nothing to say it had happened. A walk written\n// by an agent lost the column twice that way and spent a round diagnosing the\n// store before reading the two labels side by side.\n//\n// WHY THEY LIVE HERE AND NOT IN `@ai-matrx/design-system`. The words are RECORDS\n// vocabulary — \"field\", \"column\" — and the design system knows nothing about\n// either; a labels module there would be a domain word in a generic package, and\n// the next person adding a button would not find it. This file is already the\n// one place that owns what a person READS about a column (`FIELD_TYPE_CHOICES`\n// is right above), and both surfaces that draw these buttons are in this\n// package. One module, one import each, and `fieldTypes.test.ts` asserts the two\n// can never be the same string again.\n//\n// THE RULE: the control that OPENS a panel and the control that COMMITS it never\n// read the same words. The opener is an invitation; the committer says what it\n// will make.\n\n/** The toolbar control that OPENS the add-a-column panel. An invitation. */\nexport const ADD_FIELD_OPEN_LABEL = \"Add column\";\n\n/** The panel's own primary, on the CREATE path. It says what pressing it makes. */\nexport const ADD_FIELD_SAVE_LABEL = \"Create column\";\n\n/** The panel's own primary when an existing column is being changed. */\nexport const EDIT_FIELD_SAVE_LABEL = \"Save column\";\n"],"mappings":";;;AAwBA,SAAS,wBAAwB,mBAAmB,0BAA+F;AA2D5I,IAAM,aAA2D;AAAA,EACtE,QAAQ,EAAE,OAAO,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,IAAM,cAAc,oBAAI,IAAY,CAAC,oBAAoB,GAAG,iBAAiB,CAAC;AAEvE,IAAM,qBAAwC,qBAAqB;AAAA,EACxE,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,KAAK,mBAAmB,EAAE,EAAE,KAAK,EAAE,MAAM;AACvE;AAEO,IAAM,oBAAgD;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,QAAQ,IAAI,IAA6B,qBAAqB,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAElF,SAAS,gBAAgB,IAAyC;AACvE,SAAO,MAAM,IAAI,EAAE;AACrB;AAGO,SAAS,iBAAiB,IAAkC;AACjE,SAAO,OAAO,UAAU,OAAO,eAAe,OAAO;AACvD;AAQO,SAAS,oBAAoB,IAAqC;AACvE,SAAO,OAAO;AAChB;AAWO,SAAS,kBAAkB,IAAmC;AACnE,SAAO,mBAAmB,KAAK,CAAC,QAAQ,IAAI,gBAAgB,EAAE;AAChE;AAaO,SAAS,+BAAyC;AACvD,SAAO,mBAAmB,IAAI,CAAC,QAAQ,IAAI,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC;AAC3F;AAiBO,SAAS,oBAA8B;AAC5C,SAAO,uBAAuB,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC;AACxF;AAiCO,IAAM,uBAAuB;AAG7B,IAAM,uBAAuB;AAG7B,IAAM,wBAAwB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/presentation.ts","../src/viewKeys.ts","../src/firstPage.ts","../src/embeddedLook.tsx"],"sourcesContent":["/**\n * The Gantt mode of a timeline view, by Field key. `mode` turns the left task list on; `critical` paints the longest\n * chain; `progress` is a percent/number column; `milestone` a yes/no column; `baselineStart` / `baselineEnd` the two\n * date columns \"Save baseline\" writes; `dependency` the link column that dependencies are written to.\n */\nexport interface GanttLook {\n mode?: boolean;\n critical?: boolean;\n progress?: string;\n milestone?: string;\n baselineStart?: string;\n baselineEnd?: string;\n dependency?: string;\n}\n\n/** Read a stored Gantt look; unknown keys and wrong shapes are dropped. */\nexport function parseGanttLook(raw: unknown): GanttLook | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const v = raw as Record<string, unknown>;\n const out: GanttLook = {};\n if (v[\"mode\"] === true) out.mode = true;\n if (v[\"critical\"] === true) out.critical = true;\n for (const k of [\"progress\", \"milestone\", \"baselineStart\", \"baselineEnd\", \"dependency\"] as const) {\n const x = v[k];\n if (typeof x === \"string\" && x !== \"\") out[k] = x;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/**\n * HOW A TABLE LOOKS — colors, formats and the frozen column.\n *\n * THE SPLIT, AND WHY IT IS THIS ONE. A Field declares WHAT it holds: a\n * currency, a percent, a date, a person. A VIEW declares HOW that reads and\n * what it is worth looking at: two decimal places or none, tint the row when\n * Status is Blocked, keep Name in place while the rest scrolls. Airtable draws\n * the line in exactly this place, and it has to be here: two people read one\n * table two different ways, and neither reading is a fact about the records.\n *\n * So nothing in this module is a new column on a Field and nothing here needed\n * a migration. A presentation lives on the saved-view record (`views.ts`), which\n * is an ordinary record of an ordinary Table — which means an agent sets it\n * through the same `records` tool it uses for everything else, and it travels\n * with the table the way every other record does.\n *\n * A FIELD STILL GETS ITS MONEY RIGHT WITH NO CONFIGURATION. `formatForField`\n * reads the Field's OWN declaration — a `currency` parity type with unit `$`, a\n * `percent`, a `datetime` with `config.kind` — and returns the format that\n * follows from it. The view's `formats` map only OVERRIDES that. A table nobody\n * has ever styled still shows `$1,250.50` and `45%`.\n */\n\n// The style parser from its own client-free subpath (lane SSR-ROWS): `@ai-matrx/records-ui/first-page`\n// runs in a host's SERVER component, and every export of the \"use client\" `data-table` entry is a\n// client reference there — calling `parseTableStyle` through it threw on the server.\nimport { COLOR_ROTATION, parseTableStyle, tableStyleIsEmpty } from \"@ai-matrx/design-system/data-table/table-style\";\nimport type {\n ChoiceColorLookup,\n GroupAggregateKind,\n GroupAggregateSpec,\n GroupOrder,\n StyleColor,\n TableStyle,\n} from \"@ai-matrx/design-system/data-table\";\nimport { getFieldFormat, type FieldFormatConfig } from \"@ai-matrx/design-system/field-formats\";\nimport type { ColorRule } from \"@ai-matrx/design-system/data-table\";\nimport { newerKindOf, ratingMaxOf } from \"@ai-matrx/records/field-kinds\";\nimport type { Field, TableDecorations } from \"@ai-matrx/records\";\n\nimport { editorKindFor } from \"./parity\";\nimport { dateFormatFor } from \"./dates\";\n\n/**\n * SECTIONS BY A FIELD — the view's own grouping.\n *\n * `field` is a Field KEY, exactly like `frozen` and the keys of `formats`,\n * because a view is written against the Table's declaration and never against\n * whatever id a screen happened to build its columns with.\n *\n * `aggregates` is keyed by Field key too, and `collapsed` holds the data\n * table's own group keys (`s:Blocked`, `n:3`, `empty`), which is what the\n * primitive emits and the only thing that survives a value rendering the same\n * text as another.\n *\n * NOTHING HERE IS EVER CALLED `valueOf`, `toString` or `hasOwnProperty`: every\n * object in JavaScript already has all three, so an optional field by one of\n * those names is NEVER absent and a `config.valueOf ? … : …` check silently\n * reads `Object.prototype`. It cost the primitive a whole grouping once.\n */\nexport type GridGrouping = {\n /** The Field key whose value makes the sections. */\n field: string;\n /** Per-Field-key subtotal on every section header. */\n aggregates?: Record<string, GroupAggregateSpec>;\n /** Section order. The primitive's default is `value-asc`; blanks sort last. */\n order?: GroupOrder;\n /** The sections this view keeps shut, by the primitive's own group key. */\n collapsed?: string[];\n /** The grouped column stays drawn as a column (Airtable). Absent = shown; `false` = the person stepped it aside. */\n showColumn?: boolean;\n /**\n * SUB-GROUPS (lane S1-PRIME VIEW-KEYS; ui-bench LISTS \"sub-grouping\"): up to two more levels\n * inside each section, by Field key. At most three levels in all — the store refuses a fourth\n * (`custom.view_declare`). A layout that draws one level ignores the rest; it never drops them,\n * because this list is parsed and written back whole with the rest of the look.\n */\n then?: GridSubGroup[];\n /**\n * DRILL (lane DRILL-TABLE-PRIMITIVE): the Dimension pivoted across the top — a Field key, or\n * `<key>:<grain>` for a date cut into periods.\n */\n across?: string;\n /** DRILL: the period `field` is cut into when it is a date (`month`); the store keeps `field` a Field key. */\n grain?: string;\n /** The Measures shown (\"what to display\"), by the store's own keys (`count`, `sum_quantity`). */\n show?: string[];\n /** The drill trail, in order: each crumb a Dimension reference and the value it narrowed to. */\n trail?: GridDrillStep[];\n};\n\n/** One crumb of a saved drill trail. `value: null` is \"no value\". */\nexport type GridDrillStep = { dim: string; value: string | null };\n\n/** One sub-group level: a Field key and its section order. */\nexport type GridSubGroup = { field: string; order?: GroupOrder; grain?: string };\n\n/** Everything a view says about how its table LOOKS. */\nexport type GridPresentation = {\n /** Color-by-a-column, rules and manual highlights. */\n style?: TableStyle;\n /** Per-column format overrides, by the Field's key. */\n formats?: Record<string, FieldFormatConfig>;\n /**\n * The columns that stay in place while the table scrolls sideways, by Field\n * key. Only the LEADING run of the view's column order can actually freeze —\n * the data table decides that, and declines rather than pinning a column at a\n * guessed offset.\n */\n frozen?: string[];\n /** Collapsible sections by one Field, with subtotals on each header. */\n grouping?: GridGrouping;\n /**\n * The width a person dragged a column to, by Field key. SPARSE on purpose —\n * a view saved before widths existed carries none and still parses, and a\n * column nobody resized is left to the table's own measurement.\n */\n widths?: Record<string, number>;\n /** The body row height this view remembers, in px. */\n rowHeight?: number;\n /**\n * Field keys hidden from this view — the SAME hidden-column list the grid's\n * own column picker holds, now given a place on the view so it survives a\n * reload and a layout switch reads the identical set gallery and grid agree\n * on, rather than a second \"fields shown\" list nobody kept in sync.\n */\n hiddenFields?: string[];\n /**\n * THE FIELDS A CARD LEAVES OFF (board, list, gallery, calendar, timeline), by Field key — the\n * card's own choice, kept apart from `hiddenFields` so a board's \"Card fields\" never hides the\n * grid's columns when the view switches layout (v7 TABLE-EXPERIENCE, walk 2026-10-05). An empty\n * list is a choice (every field shown); absent means the card never chose.\n */\n cardHidden?: string[];\n /**\n * THE ORDER A PERSON DRAGGED THE COLUMNS INTO, by Field key (merge tranche 6a). Sparse like\n * `widths`: a key it does not name keeps its Field's own place after the named ones, and a key\n * whose Field is gone is skipped — a column order can never hide or invent a column.\n */\n columnOrder?: string[];\n /**\n * The gallery's card size, remembered the same way the grid remembers its\n * row height — a per-view look, not a global default.\n */\n gallerySize?: \"small\" | \"medium\" | \"large\";\n /**\n * THE BOARD'S OWN LOOK (lane BOARD-SWIMLANES, Notion's board options). All kept on the view, all\n * read only by the kanban layout. Absent means the board's default: columns wear their choice's\n * colour, each heading shows its count, empty columns and lanes are drawn, cards are medium with\n * no preview.\n * boardSize card size: sets the column width, the preview's height and, small, drops the card's extras\n * boardPreview the FILE field drawn as a cover at the top of each card (absent = no preview)\n * boardHideEmpty leave out a column or a lane that holds no card\n * boardColorColumns false = neutral headings, no accent bar on the cards\n * boardCounts false = no count beside the heading\n * boardLanesShut the swimlanes kept shut to a strip, by the lane's name\n */\n boardSize?: \"small\" | \"medium\" | \"large\";\n boardPreview?: string;\n boardHideEmpty?: boolean;\n boardColorColumns?: boolean;\n boardCounts?: boolean;\n boardLanesShut?: string[];\n /**\n * A CHART VIEW'S MENU (PIVOT-VIEW): `chartLabels` draws each mark's value on it (the chart menu's \"Data labels\"\n * switch); `chartLegend: false` leaves the legend off. Read only by the chart layout.\n */\n chartLabels?: boolean;\n chartLegend?: boolean;\n /**\n * A LOCKED VIEW (lane NOTION-SMALL-2): its layout, filters, sorts and settings are not saved over until\n * somebody unlocks it. An editing convenience against an accidental change, never a permission.\n */\n locked?: boolean;\n /**\n * THIS VIEW'S OWN LAYOUT CHOICES, over the organization's `custom/grid_layout` knob (lane\n * DEFAULT-GRID-PARITY, TABLE-PARITY D1 D5 D6). Absent means \"whatever the organization\n * says\"; present is the view's word. `freezeFirst: false` is an explicit NO over an\n * organization that freezes the first column — an empty `frozen` cannot say that.\n */\n wrap?: boolean;\n /** AIRTABLE'S \"WRAP FIELD HEADERS\": column titles take a second line instead of being cut. Absent = one line. */\n headerWrap?: boolean;\n /** NOTION'S \"WRAP COLUMN\" (N5): the columns that wrap their text when the view as a whole does not. */\n wrapColumns?: string[];\n fit?: \"auto\" | \"fit\" | \"scroll\";\n freezeFirst?: boolean;\n /**\n * THE SUMMARY BAR (TABLE-PARITY F1): Field key → the store measure shown under that column\n * (`count`, `sum`, `avg`, `min`, `max`, `median`, `filled`, `empty`, `unique`), worked out\n * by `custom.record_aggregate` over the whole table.\n */\n summaries?: Record<string, string>;\n /** THE TIMELINE'S GANTT MODE (kept as `presentation.gantt`): see `GanttLook`. */\n gantt?: GanttLook;\n /**\n * WHERE THE FOOTER SITS (lane TABLE-PAGE-CHROME, owner 2026-09-25) — the row count and the\n * pages: `sticky`, pinned to the bottom of the screen while the rows scroll (the older grid's\n * way, and the default when a view says nothing), or `inline`, right after the last row with\n * the page scrolling. Read by the Grid and a host's Sheet.\n */\n footer?: FooterPlacement;\n};\n\n/** Where a grid's footer sits. */\nexport type FooterPlacement = \"sticky\" | \"inline\";\n\n/** What a view that says nothing gets — the older grid's pinned footer. */\nexport const DEFAULT_FOOTER: FooterPlacement = \"sticky\";\n\n/** Where THIS view's footer sits, said or defaulted. */\nexport function footerOf(p: GridPresentation | null | undefined): FooterPlacement {\n return p?.footer ?? DEFAULT_FOOTER;\n}\n\nexport const EMPTY_PRESENTATION: GridPresentation = {};\n\n/** A frozen column needs a known width, or the table declines to freeze at all. */\nexport const FROZEN_COLUMN_WIDTH = 200;\n\n/**\n * WHAT A ROW HEIGHT IS ALLOWED TO BE. Below the floor the text is clipped and\n * no editor fits; above the ceiling one record fills the screen. A view asking\n * for anything outside it is DROPPED rather than obeyed, because a saved look\n * must not be able to make a table unreadable — and the Fields' own heights\n * still draw, which is the tolerant half.\n */\nexport const MIN_ROW_HEIGHT = 24;\nexport const MAX_ROW_HEIGHT = 240;\n\n/**\n * The aggregate kinds and orders the primitive actually implements. Listed here\n * because they are the tolerant parser's allow-list and a view is hostile input:\n * `satisfies` ties them to the primitive's own union, so a kind it renames stops\n * this file compiling instead of quietly parsing into a subtotal nobody draws.\n */\nconst AGGREGATE_KINDS = [\n \"count\",\n \"sum\",\n \"average\",\n \"min\",\n \"max\",\n \"empty\",\n \"filled\",\n \"unique\",\n \"checked\",\n \"unchecked\",\n \"percentFilled\",\n] as const satisfies readonly GroupAggregateKind[];\n\nconst GROUP_ORDERS = [\n \"value-asc\",\n \"value-desc\",\n \"count-desc\",\n \"first-seen\",\n] as const satisfies readonly GroupOrder[];\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/**\n * Read a presentation out of whatever the view record holds — an object, or the\n * JSON string a text field stores.\n *\n * Tolerant in exactly the way `parseTableStyle` is: an unreadable half is\n * dropped and the rest still applies, because a table must keep drawing when\n * one piece of its styling goes out of date.\n */\nexport function parseGridPresentation(raw: unknown): GridPresentation {\n let value = raw;\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n if (trimmed === \"\") return {};\n try {\n value = JSON.parse(trimmed);\n } catch {\n return {};\n }\n }\n if (!isRecord(value)) return {};\n\n const out: GridPresentation = {};\n\n const style = parseTableStyle(value[\"style\"]);\n if (!tableStyleIsEmpty(style)) out.style = style;\n\n if (isRecord(value[\"formats\"])) {\n const formats: Record<string, FieldFormatConfig> = {};\n for (const [key, cfg] of Object.entries(value[\"formats\"])) {\n if (!isRecord(cfg)) continue;\n const id = cfg[\"id\"];\n if (typeof id !== \"string\") continue;\n const options = cfg[\"options\"];\n formats[key] = isRecord(options)\n ? {\n id: id as FieldFormatConfig[\"id\"],\n options: options as NonNullable<FieldFormatConfig[\"options\"]>,\n }\n : { id: id as FieldFormatConfig[\"id\"] };\n }\n if (Object.keys(formats).length > 0) out.formats = formats;\n }\n\n if (Array.isArray(value[\"frozen\"])) {\n const frozen = value[\"frozen\"].filter((k): k is string => typeof k === \"string\");\n if (frozen.length > 0) out.frozen = frozen;\n }\n\n const grouping = parseGrouping(value[\"grouping\"]);\n if (grouping) out.grouping = grouping;\n\n if (isRecord(value[\"widths\"])) {\n const widths: Record<string, number> = {};\n for (const [key, raw] of Object.entries(value[\"widths\"])) {\n // A width that is not a usable number is one column's loss, never the\n // view's: the rest of the widths still apply and that column is measured.\n if (typeof raw !== \"number\" || !Number.isFinite(raw) || raw <= 0) continue;\n widths[key] = Math.round(raw);\n }\n if (Object.keys(widths).length > 0) out.widths = widths;\n }\n\n const rowHeight = value[\"rowHeight\"];\n if (\n typeof rowHeight === \"number\" &&\n Number.isFinite(rowHeight) &&\n rowHeight >= MIN_ROW_HEIGHT &&\n rowHeight <= MAX_ROW_HEIGHT\n ) {\n out.rowHeight = Math.round(rowHeight);\n }\n\n if (Array.isArray(value[\"hiddenFields\"])) {\n const hiddenFields = value[\"hiddenFields\"].filter((k): k is string => typeof k === \"string\");\n if (hiddenFields.length > 0) out.hiddenFields = hiddenFields;\n }\n if (Array.isArray(value[\"cardHidden\"])) {\n out.cardHidden = value[\"cardHidden\"].filter((k): k is string => typeof k === \"string\");\n }\n\n if (Array.isArray(value[\"columnOrder\"])) {\n const columnOrder = value[\"columnOrder\"].filter((k): k is string => typeof k === \"string\");\n if (columnOrder.length > 0) out.columnOrder = columnOrder;\n }\n\n const gallerySize = value[\"gallerySize\"];\n if (gallerySize === \"small\" || gallerySize === \"medium\" || gallerySize === \"large\") {\n out.gallerySize = gallerySize;\n }\n\n const boardSize = value[\"boardSize\"];\n if (boardSize === \"small\" || boardSize === \"medium\" || boardSize === \"large\") out.boardSize = boardSize;\n if (typeof value[\"boardPreview\"] === \"string\" && value[\"boardPreview\"] !== \"\") out.boardPreview = value[\"boardPreview\"];\n if (typeof value[\"boardHideEmpty\"] === \"boolean\") out.boardHideEmpty = value[\"boardHideEmpty\"];\n if (typeof value[\"boardColorColumns\"] === \"boolean\") out.boardColorColumns = value[\"boardColorColumns\"];\n if (typeof value[\"boardCounts\"] === \"boolean\") out.boardCounts = value[\"boardCounts\"];\n if (typeof value[\"chartLabels\"] === \"boolean\") out.chartLabels = value[\"chartLabels\"];\n if (typeof value[\"chartLegend\"] === \"boolean\") out.chartLegend = value[\"chartLegend\"];\n if (value[\"locked\"] === true) out.locked = true;\n if (Array.isArray(value[\"boardLanesShut\"])) {\n const shut = value[\"boardLanesShut\"].filter((k): k is string => typeof k === \"string\");\n if (shut.length > 0) out.boardLanesShut = shut;\n }\n\n if (typeof value[\"wrap\"] === \"boolean\") out.wrap = value[\"wrap\"];\n if (typeof value[\"headerWrap\"] === \"boolean\") out.headerWrap = value[\"headerWrap\"];\n if (Array.isArray(value[\"wrapColumns\"])) {\n const wrapColumns = value[\"wrapColumns\"].filter((k): k is string => typeof k === \"string\");\n if (wrapColumns.length > 0) out.wrapColumns = wrapColumns;\n }\n const fit = value[\"fit\"];\n if (fit === \"auto\" || fit === \"fit\" || fit === \"scroll\") out.fit = fit;\n if (typeof value[\"freezeFirst\"] === \"boolean\") out.freezeFirst = value[\"freezeFirst\"];\n const footer = value[\"footer\"];\n if (footer === \"sticky\" || footer === \"inline\") out.footer = footer;\n {\n const gantt = parseGanttLook(value[\"gantt\"]);\n if (gantt) out.gantt = gantt;\n }\n if (isRecord(value[\"summaries\"])) {\n const summaries: Record<string, string> = {};\n for (const [key, op] of Object.entries(value[\"summaries\"])) {\n // A measure name is judged by the store when it is asked; a non-string is nobody's.\n if (typeof op === \"string\" && op.trim() !== \"\") summaries[key] = op;\n }\n if (Object.keys(summaries).length > 0) out.summaries = summaries;\n }\n\n return out;\n}\n\n/**\n * A grouping, or nothing. A grouping with no Field to group BY is not a partial\n * grouping — it is no grouping at all, so it is dropped whole; an unreadable\n * subtotal or a section order this primitive does not have costs only itself.\n */\nfunction parseGrouping(raw: unknown): GridGrouping | undefined {\n if (!isRecord(raw)) return undefined;\n const field = raw[\"field\"];\n if (typeof field !== \"string\" || field.trim() === \"\") return undefined;\n\n const out: GridGrouping = { field };\n\n if (isRecord(raw[\"aggregates\"])) {\n const aggregates: Record<string, GroupAggregateSpec> = {};\n for (const [key, spec] of Object.entries(raw[\"aggregates\"])) {\n if (!isRecord(spec)) continue;\n const kind = spec[\"kind\"];\n if (typeof kind !== \"string\") continue;\n if (!(AGGREGATE_KINDS as readonly string[]).includes(kind)) continue;\n const label = spec[\"label\"];\n aggregates[key] =\n typeof label === \"string\"\n ? { kind: kind as GroupAggregateKind, label }\n : { kind: kind as GroupAggregateKind };\n }\n if (Object.keys(aggregates).length > 0) out.aggregates = aggregates;\n }\n\n const order = raw[\"order\"];\n if (typeof order === \"string\" && (GROUP_ORDERS as readonly string[]).includes(order)) {\n out.order = order as GroupOrder;\n }\n\n if (Array.isArray(raw[\"collapsed\"])) {\n const collapsed = raw[\"collapsed\"].filter((k): k is string => typeof k === \"string\");\n if (collapsed.length > 0) out.collapsed = collapsed;\n }\n\n if (typeof raw[\"showColumn\"] === \"boolean\") out.showColumn = raw[\"showColumn\"];\n\n if (Array.isArray(raw[\"then\"])) {\n const then: GridSubGroup[] = [];\n for (const level of raw[\"then\"]) {\n if (!isRecord(level)) continue;\n const sub = level[\"field\"];\n if (typeof sub !== \"string\" || sub.trim() === \"\") continue;\n const subOrder = level[\"order\"];\n const subGrain = level[\"grain\"];\n then.push({\n field: sub,\n ...(typeof subOrder === \"string\" && (GROUP_ORDERS as readonly string[]).includes(subOrder)\n ? { order: subOrder as GroupOrder }\n : {}),\n ...(typeof subGrain === \"string\" && subGrain !== \"\" ? { grain: subGrain } : {}),\n });\n }\n if (then.length > 0) out.then = then.slice(0, 2);\n }\n\n const grain = raw[\"grain\"];\n if (typeof grain === \"string\" && grain !== \"\") out.grain = grain;\n const across = raw[\"across\"];\n if (typeof across === \"string\" && across.trim() !== \"\") out.across = across;\n if (Array.isArray(raw[\"show\"])) {\n const show = raw[\"show\"].filter((k): k is string => typeof k === \"string\" && k !== \"\");\n if (show.length > 0) out.show = show;\n }\n if (Array.isArray(raw[\"trail\"])) {\n const trail: GridDrillStep[] = [];\n for (const step of raw[\"trail\"]) {\n if (!isRecord(step) || typeof step[\"dim\"] !== \"string\" || step[\"dim\"] === \"\") continue;\n const value = step[\"value\"];\n if (value !== null && typeof value !== \"string\") continue;\n trail.push({ dim: step[\"dim\"], value });\n }\n if (trail.length > 0) out.trail = trail;\n }\n\n return out;\n}\n\n/** True when nothing here would change how anything looks. */\nexport function presentationIsEmpty(p: GridPresentation): boolean {\n return (\n (p.style === undefined || tableStyleIsEmpty(p.style)) &&\n Object.keys(p.formats ?? {}).length === 0 &&\n (p.frozen?.length ?? 0) === 0 &&\n p.grouping === undefined &&\n Object.keys(p.widths ?? {}).length === 0 &&\n p.rowHeight === undefined &&\n (p.hiddenFields?.length ?? 0) === 0 &&\n p.cardHidden === undefined &&\n (p.columnOrder?.length ?? 0) === 0 &&\n p.gallerySize === undefined &&\n p.boardSize === undefined &&\n p.boardPreview === undefined &&\n p.boardHideEmpty === undefined &&\n p.boardColorColumns === undefined &&\n p.boardCounts === undefined &&\n (p.boardLanesShut?.length ?? 0) === 0 &&\n p.chartLabels === undefined &&\n p.chartLegend === undefined &&\n p.locked === undefined &&\n p.wrap === undefined &&\n p.headerWrap === undefined &&\n p.fit === undefined &&\n p.freezeFirst === undefined &&\n p.footer === undefined &&\n Object.keys(p.summaries ?? {}).length === 0 &&\n p.gantt === undefined\n );\n}\n\n/** The string a view record stores. Empty string for \"this view styles nothing\". */\nexport function presentationDocument(p: GridPresentation): string {\n return presentationIsEmpty(p) ? \"\" : JSON.stringify(p);\n}\n\n/** Kinds whose value is a control the record renderer draws, never a formatter's string. */\nconst DRAWN_KINDS = new Set([\"select\", \"multi_select\", \"relation\", \"member\", \"person\", \"attachment\", \"file\", \"entity_reference\", \"checkbox\", \"boolean\", \"signature\", \"json\"]);\n\n/**\n * The display format a column's settings chose for it, when it is one the platform registry\n * knows and the column is not one the record renderer draws itself. `undefined` otherwise.\n */\nexport function shownAsOf(field: Field): FieldFormatConfig | undefined {\n if (DRAWN_KINDS.has(String(editorKindFor(field)))) return undefined;\n const raw = (field as unknown as { display_format?: unknown }).display_format;\n if (!raw || typeof raw !== \"object\") return undefined;\n const id = (raw as { id?: unknown }).id;\n // `formula` is the column's KIND, never a look: a worked-out column shows as its result format.\n if (typeof id !== \"string\" || id === \"formula\" || !getFieldFormat(id)) return undefined;\n const options = (raw as { options?: unknown }).options;\n return options && typeof options === \"object\" && Object.keys(options).length > 0\n ? ({ id, options } as FieldFormatConfig)\n : ({ id } as FieldFormatConfig);\n}\n\n/**\n * The format a Field's OWN declaration implies, before any view says anything.\n *\n * Returns `undefined` for a Field whose value the record renderer already draws\n * better than a formatter could — a relation chip, a person, an attachment, a\n * choice — because handing those to a text formatter would REPLACE a working\n * control with a string.\n */\n/**\n * A COLUMN THAT HOLDS YEARS (\"Founded\", \"Year\", \"Year built\", \"Established\", \"Model year\"…).\n * A year is a number that is never grouped: \"Founded 2,008\" read as a quantity (lane RECORD-PAGE-UI,\n * 2026-10-15). Known by its name; a value is printed as a year only when it is also a whole number\n * from 1000 to 2999 (`isYearValue`).\n */\nconst YEAR_NAMES = /(^|[\\s_-])(year|founded|established|incorporated|vintage)([\\s_-]|$)/i;\nexport function isYearField(field: Pick<Field, \"key\" | \"label\">): boolean {\n return YEAR_NAMES.test(String(field.label ?? \"\")) || YEAR_NAMES.test(field.key);\n}\nexport function isYearValue(value: unknown): boolean {\n return typeof value === \"number\" && Number.isInteger(value) && value >= 1000 && value <= 2999;\n}\n/** A number format with its grouping off for a year column, unless the column chose grouping itself. */\nfunction ungroupedForYears(field: Field, format: FieldFormatConfig): FieldFormatConfig {\n if (format.id !== \"number\" || !isYearField(field)) return format;\n const options = (format.options ?? {}) as Record<string, unknown>;\n if (options[\"useGrouping\"] !== undefined) return format;\n return { ...format, options: { ...options, useGrouping: false } };\n}\n\nexport function formatForField(field: Field): FieldFormatConfig | undefined {\n // \"SHOWS AS\" — THE FORMAT THE COLUMN'S OWN SETTINGS CHOSE (merge tranche 6a/6e). The column\n // keeps it on the Field (`display_format`, written by `custom.field_update`), so the grid, the\n // record panel and the export read one answer. A column the record renderer draws better than\n // a formatter (a choice, a link, a person, a file) keeps its own drawing.\n const shownAs = shownAsOf(field);\n // A RATING'S TOP STAR IS ITS MAX RULE (lane 10 P4), so changing the rule changes the stars.\n if (newerKindOf(field) === \"rating\" && (!shownAs || shownAs.id === \"rating\")) {\n return { id: \"rating\", options: { ...(shownAs?.options ?? {}), ratingMax: ratingMaxOf(field) } };\n }\n if (shownAs) return ungroupedForYears(field, shownAs);\n // THE STORE'S OWN STAMPS (Created time, Last changed time) are instants and print like\n // every other date-and-time cell — `dates.ts` answers, the same helper every card reads.\n const stamp = dateFormatFor(field);\n if (stamp && editorKindFor(field) !== \"datetime\") return stamp;\n switch (editorKindFor(field)) {\n case \"currency\":\n return {\n id: \"currency\",\n options: { currency: currencyCodeFor(field.unit) },\n };\n case \"percent\":\n return { id: \"percent\" };\n case \"datetime\":\n // The COLUMN's declaration: a `kind: \"date\"` column is a date column, anything else can\n // hold a moment. Each VALUE is still printed in its own shape (`RecordValue` →\n // `dates.dateFormatFor(field, value)`), so a bare date in a datetime column reads as a date.\n return String(field.config?.[\"kind\"] ?? \"\") === \"date\" ? { id: \"date\" } : { id: \"datetime\" };\n case \"email\":\n return { id: \"email\" };\n case \"url\":\n return { id: \"url\" };\n case \"phone\":\n return { id: \"phone\" };\n case \"number\":\n return ungroupedForYears(field, { id: \"number\" });\n default:\n return undefined;\n }\n}\n\n/**\n * THE FORMAT ONE CELL OF A COLUMN IS DRAWN IN — the grid's cell and the gallery's card alike\n * (guard G4 \"one format\", lane VIEWS-AND-FIELDS W1-B): the view's own format for the column when\n * it set one, else the Field's own (`formatForField`). One function, so no layout formats money\n * (or a date, or a percent) its own way.\n */\nexport function cellFormatFor(field: Field, viewFormat?: FieldFormatConfig | undefined): FieldFormatConfig | undefined {\n return viewFormat ?? formatForField(field);\n}\n\n/**\n * The store lets a person type the SYMBOL they think in (`$`, `€`), and\n * `Intl.NumberFormat` wants the ISO code. The symbols people actually enter are\n * mapped; anything else is passed straight through, because a real ISO code is\n * the other thing that lands in this field, and an unknown code still renders\n * (`1,234.00 XYZ`) rather than blanking — THE FALLBACK LAW.\n */\nconst SYMBOL_TO_CODE: Record<string, string> = {\n $: \"USD\",\n \"£\": \"GBP\",\n \"€\": \"EUR\",\n \"¥\": \"JPY\",\n \"₹\": \"INR\",\n \"₽\": \"RUB\",\n \"₩\": \"KRW\",\n \"R$\": \"BRL\",\n \"C$\": \"CAD\",\n \"A$\": \"AUD\",\n};\n\nexport function currencyCodeFor(unit: string | null | undefined): string {\n const raw = (unit ?? \"\").trim();\n if (raw === \"\") return \"USD\";\n return SYMBOL_TO_CODE[raw] ?? raw.toUpperCase();\n}\n\n/**\n * The color a value paints with when a view colors BY a column.\n *\n * NOTHING FAILS SILENTLY, so this never returns \"no color\" for a value that\n * exists. The store keeps a list column's choices as records of another Table,\n * and this grid has not read that Table's option colors, so the color is\n * derived from the value's own text: the same word always gets the same color,\n * different words get different ones, and `true` is green the way every\n * checklist reads. When those option colors do land, this is the ONE function\n * that changes and every screen follows.\n */\nexport const colorFromTheValue: ChoiceColorLookup = (_fieldKey, value) => {\n if (value === true) return \"green\";\n if (value === false || value === null || value === undefined) return undefined;\n const text = String(value).trim().toLowerCase();\n if (text === \"\") return undefined;\n let hash = 0;\n for (let i = 0; i < text.length; i += 1) {\n hash = (hash * 31 + text.charCodeAt(i)) >>> 0;\n }\n return COLOR_ROTATION[hash % COLOR_ROTATION.length] as StyleColor;\n};\n\n/**\n * G1's TABLE-LEVEL COLORS (`custom.table_decorations` / `client.tableDecorations`),\n * TRANSLATED INTO A `TableStyle` — the same document a saved view's own `presentation.style`\n * is, so one resolver (`resolveTableStyle`, below) can treat \"the table's colors\" and \"this\n * view's colors\" as two layers of the SAME thing instead of two unrelated systems.\n *\n * THE TRANSLATION IS NECESSARY AND IT IS THE ONLY ONE. G1 addresses a Field by its ID\n * (REC-17 — a column renamed keeps its color), because it is the STORE's own door; a\n * `TableStyle` addresses a Field by its KEY, because it reads straight off `row.document`,\n * which is keyed by Field key. A rule or a color-by whose Field has been deleted (its id no\n * longer resolves to a key) is dropped rather than crashing the whole style — a defect in\n * one rule costs that rule, never the read.\n */\nexport function styleFromDecorations(\n decorations: TableDecorations | null | undefined,\n fields: readonly Field[],\n): TableStyle {\n if (!decorations) return { version: 1 };\n const keyOf = (id: string) => fields.find((f) => f.id === id)?.key;\n const style: TableStyle = { version: 1 };\n\n if (decorations.color_by?.field) {\n const field = keyOf(decorations.color_by.field);\n if (field) style.colorBy = { field, target: decorations.color_by.target };\n }\n\n if (Array.isArray(decorations.rules) && decorations.rules.length > 0) {\n const rules: ColorRule[] = [];\n decorations.rules.forEach((rule, index) => {\n const field = keyOf(rule.field);\n if (!field) return;\n rules.push({\n id: rule.id ?? `decoration:${index}`,\n field,\n op: rule.op,\n color: rule.color,\n target: rule.target,\n ...(rule.value === undefined || rule.value === null ? {} : { value: String(rule.value) }),\n });\n });\n if (rules.length > 0) style.rules = rules;\n }\n\n if (decorations.rows && Object.keys(decorations.rows).length > 0) {\n style.rows = { ...decorations.rows };\n }\n\n const columns: Record<string, StyleColor> = {};\n for (const [id, color] of Object.entries(decorations.columns ?? {})) {\n const key = keyOf(id);\n if (key) columns[key] = color;\n }\n if (Object.keys(columns).length > 0) style.columns = columns;\n\n const cells: Record<string, Record<string, StyleColor>> = {};\n for (const [rowId, byField] of Object.entries(decorations.cells ?? {})) {\n for (const [id, color] of Object.entries(byField ?? {})) {\n const key = keyOf(id);\n if (!key) continue;\n (cells[rowId] ??= {})[key] = color;\n }\n }\n if (Object.keys(cells).length > 0) style.cells = cells;\n\n return style;\n}\n\n/**\n * THE ONE PRESENTATION RESOLVER every colored surface in this package reads —\n * `Grid`, and (via `Card`) the kanban board, the calendar and the gallery.\n *\n * THE CLASS THIS CLOSES (lane UI-QUICK-1, TABLE-PARITY review, 2026-09-24). Threading\n * `view.presentation.style` into `Card` closed the instance the CALENDAR-GALLERY bench\n * found — a VIEW that had its own color-by looked right everywhere — but it left the\n * class open: a table whose colors are the ORGANIZATION's decorations (G1's\n * `custom.table_decorations` — \"color rows by Account Type\", \"MAXED and NEAR rules\" on\n * Arman's own Coding Accounts table) and whose views never set a `presentation.style` of\n * their own drew NOTHING, on the grid exactly as much as on every other layout, because\n * nothing in this package had ever read G1's door at all.\n *\n * TWO LAYERS, ONE DOCUMENT. The table's decorations are the base coat — what every view\n * of this table shows until a view says otherwise. A view's OWN `presentation.style` is\n * an override, piece by piece: a view that only ever set manual row highlights still\n * inherits the table's color-by and rules for everything it never touched, and a view\n * that fully redecorated (its own `colorBy` AND its own `rules`) is not haunted by a\n * table rule it meant to replace. Per-piece, never all-or-nothing, because a view is a\n * LOOK on top of the table, not a wholesale substitute for it.\n */\nexport function resolveTableStyle(\n decorations: TableDecorations | null | undefined,\n fields: readonly Field[],\n viewStyle: TableStyle | undefined,\n): TableStyle {\n const base = styleFromDecorations(decorations, fields);\n if (!viewStyle) return base;\n const colorBy = viewStyle.colorBy ?? base.colorBy;\n const rules = viewStyle.rules ?? base.rules;\n const rows = viewStyle.rows ?? base.rows;\n const columns = viewStyle.columns ?? base.columns;\n const cells = viewStyle.cells ?? base.cells;\n return {\n version: 1,\n ...(colorBy !== undefined ? { colorBy } : {}),\n ...(rules !== undefined ? { rules } : {}),\n ...(rows !== undefined ? { rows } : {}),\n ...(columns !== undefined ? { columns } : {}),\n ...(cells !== undefined ? { cells } : {}),\n };\n}\n","// src/viewKeys.ts — @ai-matrx/records-ui · lane S1-PRIME VIEW-KEYS\n//\n// THE VIEW-KEY REGISTRY MOVED TO `@ai-matrx/records/views` (step 10, 2026-10-08): the declared keys, the one\n// reader and the one writer are headless there. What stays here is this package's LOOK: the grid\n// presentation (colors, formats, frozen columns — `presentation.ts`, built on design-system) bound as the\n// view's presentation codec. Every name this file exported is unchanged.\n\nimport * as base from \"@ai-matrx/records/views\";\nimport { parseGridPresentation, presentationDocument, presentationIsEmpty, type GridPresentation } from \"./presentation\";\n\nexport {\n STORE_KEEPS_TIMELINE,\n STORE_KEPT_LAYOUTS,\n VIEW_KEYS,\n storeKeepsLayout,\n viewKeysFor,\n viewSettingsFor,\n type ViewKeyDeclaration,\n type ViewKeyLayout,\n type ViewKeyWriter,\n type ViewSortKey,\n} from \"@ai-matrx/records/views\";\n\n/** This package's look, as the view's presentation codec. */\nexport const gridPresentationCodec: base.ViewPresentationCodec<GridPresentation> = {\n parse: parseGridPresentation,\n isEmpty: presentationIsEmpty,\n toDocument: (presentation) => JSON.parse(presentationDocument(presentation)) as Record<string, unknown>,\n};\n\n/** EVERY DECLARED KEY OF A VIEW, TYPED, with this package's grid look. */\nexport type ViewSettings = base.ViewSettings<GridPresentation>;\nexport type ViewSettingsPatch = base.ViewSettingsPatch<GridPresentation>;\n\n/** Every view and look door with this package's grid look bound — bindings of records' one definition. */\nexport const boundViews = base.bindViewCodec<GridPresentation>(gridPresentationCodec);\n\n/** THE READER (a stored `definition` and the row's flat `filters` in, every declared key out) and THE WRITER'S SHAPE. */\nexport const { viewSettings, viewSettingsPatch } = boundViews;\n","// src/firstPage.ts — @ai-matrx/records-ui/first-page · lane PAGE-BUNDLE-2\n//\n// THE GRID'S FIRST PAGE, ASKED BEFORE THE GRID EXISTS. The logic lives in `@ai-matrx/records/first-page` (headless,\n// step 10, 2026-10-08); this entry binds this package's grid look (`gridPresentationCodec`) so a view is read exactly\n// as the screen reads it. No React here (server-safe entry).\n\nimport { bindFirstPageCodec } from \"@ai-matrx/records/first-page\";\nimport type { GridPresentation } from \"./presentation\";\nimport { gridPresentationCodec } from \"./viewKeys\";\n\nexport type { GridPresentation } from \"./presentation\";\n\nexport {\n EMBEDDED_PAGE_SIZE,\n TABLE_PAGE_SIZE,\n firstGridPageArgs,\n serverRowsOf,\n viewFilterOf,\n type FirstGridPageArgs,\n} from \"@ai-matrx/records/first-page\";\n\ntype BoundFirstPage = ReturnType<typeof bindFirstPageCodec<GridPresentation>>;\nconst boundFirstPage = bindFirstPageCodec(gridPresentationCodec);\nexport const firstGridPageRequest: BoundFirstPage[\"firstGridPageRequest\"] = boundFirstPage.firstGridPageRequest;\nexport const askTablePageSeed: BoundFirstPage[\"askTablePageSeed\"] = boundFirstPage.askTablePageSeed;\n\n// Entity blocks and chart tiles (lane SEED-ENTITY).\nexport * from \"./firstPageEntity\";\n","\"use client\";\n\n// src/embeddedLook.tsx — @ai-matrx/records-ui · CHAIR-EMBEDDED-FIDELITY\n//\n// THE EMBEDDED TABLE'S LOOK, AS NAMED OPTIONS (never free-form styling). `TablePage\n// presentation=\"embedded\"` is the grid a page holds inline, measured against Notion's inline\n// database. Every difference from the full page is ONE option here, switched on by `Grid`\n// when `embedded` and read by the pieces that draw a value:\n//\n// · `blankEmpty` an empty cell is blank, not \"—\" (\"Withheld\" and a worked-out column's reason\n// words stay: they say something a dash would not).\n// · `choiceDot` a choice chip carries a small leading dot in its option's colour.\n// · `plainRelation` a relation cell reads like Notion's: the record's icon (else a page glyph)\n// then its title — no fill, no badge, no coloured underline; hover underlines.\n//\n// Row height and column dividers are classes on the table (`EMBEDDED_TABLE_CLASS`), drawn from\n// the design system's own tokens (`border-border`).\n\nimport { createContext, useContext } from \"react\";\n\nexport interface EmbeddedLook {\n blankEmpty: boolean;\n choiceDot: boolean;\n plainRelation: boolean;\n}\n\nexport const EMBEDDED_LOOK: EmbeddedLook = { blankEmpty: true, choiceDot: true, plainRelation: true };\n\nconst EmbeddedLookContext = createContext<EmbeddedLook | null>(null);\nexport const EmbeddedLookProvider = EmbeddedLookContext.Provider;\n/** The embedded look in force here, or `null` on a full page. */\nexport function useEmbeddedLook(): EmbeddedLook | null {\n return useContext(EmbeddedLookContext);\n}\n\n/**\n * Embedded rows are 40px tall with the value centred in them (as every grid cell is), and thin\n * vertical dividers sit between columns in the existing border token.\n */\nexport const EMBEDDED_TABLE_CLASS = [\n \"[&_tbody_td]:h-10\",\n \"[&_tbody_td]:align-middle!\",\n \"[&_tbody_td]:border-r\",\n \"[&_tbody_td]:border-border\",\n \"[&_tbody_td:last-child]:border-r-0\",\n \"[&_thead_th]:border-r\",\n \"[&_thead_th]:border-border\",\n \"[&_thead_th:last-child]:border-r-0\",\n].join(\" \");\n\n/** With no calculation chosen, the footer holds only the new-row line: no grey band, no rule above it. */\nexport const EMBEDDED_PLAIN_FOOTER_CLASS = \"[&_tfoot]:bg-transparent [&_tfoot]:border-t-0\";\n\n/**\n * HOW MANY ROWS AN EMBEDDED TABLE READS AT A TIME (CHAIR-EMBEDDED-FIDELITY 16): its first page, and\n * each \"Show more\" press brings about this many more — never the whole table. Declared beside the\n * server's first-page builder (`firstPage.ts`), which asks the same first page (lane SSR-ROWS).\n */\nexport { EMBEDDED_PAGE_SIZE } from \"./firstPage\";\n"],"mappings":";;;;;;;AAuDA,SAAS,gBAAgB,iBAAiB,yBAAyB;AASnE,SAAS,sBAA8C;AAEvD,SAAS,aAAa,mBAAmB;AAlDlC,SAAS,eAAe,KAAqC;AAClE,MAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,EAAG,QAAO;AAClE,QAAM,IAAI;AACV,QAAM,MAAiB,CAAC;AACxB,MAAI,EAAE,MAAM,MAAM,KAAM,KAAI,OAAO;AACnC,MAAI,EAAE,UAAU,MAAM,KAAM,KAAI,WAAW;AAC3C,aAAW,KAAK,CAAC,YAAY,aAAa,iBAAiB,eAAe,YAAY,GAAY;AAChG,UAAM,IAAI,EAAE,CAAC;AACb,QAAI,OAAO,MAAM,YAAY,MAAM,GAAI,KAAI,CAAC,IAAI;AAAA,EAClD;AACA,SAAO,OAAO,KAAK,GAAG,EAAE,SAAS,IAAI,MAAM;AAC7C;AAkNO,IAAM,iBAAkC;AAGxC,SAAS,SAAS,GAAyD;AAChF,SAAO,GAAG,UAAU;AACtB;AAEO,IAAM,qBAAuC,CAAC;AAG9C,IAAM,sBAAsB;AAS5B,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AAQ9B,IAAM,kBAAkB;AAAA,EACtB;AAAA,EACA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vC,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC;AAAA,IACrC,GAAI,YAAY,SAAY,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC3C,GAAI,UAAU,SAAY,EAAE,MAAM,IAAI,CAAC;AAAA,EACzC;AACF;;;ACrxBA,YAAY,UAAU;AAGtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAGA,IAAM,wBAAsE;AAAA,EACjF,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY,CAAC,iBAAiB,KAAK,MAAM,qBAAqB,YAAY,CAAC;AAC7E;AAOO,IAAM,aAAkB,mBAAgC,qBAAqB;AAG7E,IAAM,EAAE,cAAc,kBAAkB,IAAI;;;AChCnD,SAAS,0BAA0B;AAMnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAGP,IAAM,iBAAiB,mBAAmB,qBAAqB;AACxD,IAAM,uBAA+D,eAAe;AACpF,IAAM,mBAAuD,eAAe;;;ACNnF,SAAS,eAAe,kBAAkB;AAQnC,IAAM,gBAA8B,EAAE,YAAY,MAAM,WAAW,MAAM,eAAe,KAAK;AAEpG,IAAM,sBAAsB,cAAmC,IAAI;AAC5D,IAAM,uBAAuB,oBAAoB;AAEjD,SAAS,kBAAuC;AACrD,SAAO,WAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,GAAG;AAGH,IAAM,8BAA8B;","names":["raw","base"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docs.ts","../src/choiceLooks.ts","../src/parity.ts","../src/dates.ts"],"sourcesContent":["// src/docs.ts — @ai-matrx/records-ui · SCR-20, SCR-21, SCR-22\n//\n// DOCUMENTS OVER RECORDS. A template is a body whose tokens point at Fields BY\n// ID; a render is written ONCE and frozen with the SHA-256 of its own text; a\n// signature seals that exact version and is immutable once made.\n//\n// Three things this package refuses to re-implement, because the store already\n// does them and doing them twice is how two answers appear:\n// · which tokens a body contains — `custom.doc_tokens`;\n// · which of them this Table cannot answer, and why — `custom.doc_unresolved_tokens`;\n// · whether a signature still holds — `custom.doc_signature_intact`.\n//\n// The token syntax is the store's own: `{{field:<the field's id>}}`. A name\n// would be a token that silently stops resolving the day somebody renames a\n// Field, which is the exact failure REC-17 exists to prevent.\n\nimport type { Field, Uuid } from \"@ai-matrx/records\";\n\n/** The one token form, written the way the store's own pattern reads it. */\nexport function fieldToken(fieldId: Uuid): string {\n return `{{field:${fieldId}}}`;\n}\n\n/** THE DECLARATIVE SPEC an agent writes. One template, whole, in one object. */\nexport interface DocTemplateSpec {\n name: string;\n /** The body, tokens and all. */\n body: string;\n}\n\n/**\n * A template written in terms of Field KEYS — which is how an agent thinks and\n * how a person reads — turned into the store's id-based tokens. The agent writes\n * `{{title}}`; what is stored points at the Field's id, so a rename never\n * silently empties the document.\n *\n * A key this Table does not have is LEFT EXACTLY AS IT IS, so\n * `custom.doc_unresolved_tokens` names it and the screen shows the store's own\n * reason — it is never quietly deleted from the body.\n */\nexport function bodyFromKeys(body: string, fields: Field[]): string {\n const byKey = new Map(fields.map((f) => [f.key, f.id]));\n return body.replace(/\\{\\{\\s*([a-zA-Z0-9_]+)\\s*\\}\\}/g, (whole, key: string) => {\n const id = byKey.get(key);\n return id ? fieldToken(id) : whole;\n });\n}\n\n/** The reverse, for a person reading a stored body: ids shown as the Field's label. */\nexport function bodyForReading(body: string, fields: Field[]): string {\n const byId = new Map(fields.map((f) => [f.id, f.label || f.key]));\n return body.replace(/\\{\\{\\s*field:([0-9a-fA-F-]{36})\\s*\\}\\}/g, (whole, id: string) => {\n const label = byId.get(id);\n return label ? `{{${label}}}` : whole;\n });\n}\n\n/** VAL-10: a signature is a Value on a text Field whose format is `signature`. */\nexport function isSignatureField(field: Field): boolean {\n return field.type === \"text\" && (field.format ?? \"\").toLowerCase() === \"signature\";\n}\n","// src/choiceLooks.ts — @ai-matrx/records-ui · merge tranche 6f (early)\n//\n// A CHOICE WEARS THE COLOUR ITS OWNER GAVE IT.\n//\n// The older /data grid let a person paint each choice of a list (\"Completed\" green, \"Scheduled\"\n// blue), and those colours are kept on the Field itself: `display_format.options.choices`, the\n// document `custom.field_update` writes (the /data Sheet's seam writes it the same way, and a\n// column's settings here write it back). The grid used to ignore it and HASH THE WORD into a\n// colour, so a column painted green on /data came up amber here, and a colour a person set in the\n// settings changed nothing on screen — the silent half of a setting.\n//\n// Pure: no React, no store call. The Field the grid already holds carries everything.\n\nimport { newerKindOf } from \"@ai-matrx/records/field-kinds\";\nimport type { Field } from \"@ai-matrx/records\";\n// The values from the pure `table-style` subpath (no \"use client\", no grid): `@ai-matrx/records-ui/helpers`\n// reaches this file through `fieldTypeLabel`, and the data-table root would drag the whole grid with it.\nimport { CHOICE_CHIP_CLASS, NEUTRAL_CHIP_CLASS, STYLE_COLORS } from \"@ai-matrx/design-system/data-table/table-style\";\nimport type { ChoiceColorLookup, StyleColor } from \"@ai-matrx/design-system/data-table\";\n\n/** One choice's look, as the Field keeps it. */\nexport interface ChoiceLook {\n value: string;\n label?: string;\n color?: StyleColor;\n}\n\n/** The Field's display document, which the store keeps beside its declared keys. */\nexport function displayFormatOf(field: Field): { id: string; options: Record<string, unknown> } | null {\n const raw = (field as unknown as { display_format?: unknown }).display_format;\n if (!raw || typeof raw !== \"object\") return null;\n const id = (raw as { id?: unknown }).id;\n if (typeof id !== \"string\" || id === \"\") return null;\n const options = (raw as { options?: unknown }).options;\n return { id, options: options && typeof options === \"object\" ? (options as Record<string, unknown>) : {} };\n}\n\nfunction isStyleColor(v: unknown): v is StyleColor {\n return typeof v === \"string\" && (STYLE_COLORS as readonly string[]).includes(v);\n}\n\n/** Every choice look the Field keeps, in its own order. A colour outside the palette is dropped. */\nexport function choiceLooksOf(field: Field): ChoiceLook[] {\n const display = displayFormatOf(field);\n const choices = display?.options[\"choices\"];\n if (!Array.isArray(choices)) return [];\n const out: ChoiceLook[] = [];\n for (const c of choices) {\n if (!c || typeof c !== \"object\") continue;\n const value = (c as { value?: unknown }).value;\n if (typeof value !== \"string\" || value.trim() === \"\") continue;\n const color = (c as { color?: unknown }).color;\n const label = (c as { label?: unknown }).label;\n out.push({\n value: value.trim(),\n ...(typeof label === \"string\" && label.trim() !== \"\" ? { label: label.trim() } : {}),\n ...(isStyleColor(color) ? { color } : {}),\n });\n }\n return out;\n}\n\n/**\n * ONE WORD, HOWEVER IT WAS WRITTEN. A moved list keeps its words as `completed` / `truck_4` and\n * shows them as `Completed` / `Truck 4`; a colour kept against either spelling is the same choice.\n */\nexport function choiceWord(value: unknown): string {\n return String(value ?? \"\")\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\");\n}\n\n/**\n * NOTION'S STATUS COLOURS, BY GROUP: To-do grey, In progress blue, Complete green. A status choice\n * the column paints nothing for wears its group's colour, so a fresh Status column reads the way\n * Notion's does with nobody picking a colour. A choice with a colour of its own keeps it\n * (`storedChoiceColor` asks the column first).\n */\nexport const STATUS_GROUP_COLOR = { todo: \"gray\", in_progress: \"blue\", done: \"green\" } as const satisfies Record<string, StyleColor>;\n\n/** The colour a status choice's GROUP gives it, or `undefined` when the column is not a Status. */\nexport function statusGroupColor(field: Field, value: unknown): StyleColor | undefined {\n if (newerKindOf(field) !== \"status\" || value === null || value === undefined || value === \"\") return undefined;\n const word = choiceWord(value);\n if (word === \"\") return undefined;\n const groups = ((field.config ?? {}) as Record<string, unknown>)[\"status_groups\"];\n if (groups && typeof groups === \"object\") {\n // the group is kept under the choice's KEY; the cell may hold its WORDS (\"In progress\" ↔ in_progress)\n for (const [key, group] of Object.entries(groups as Record<string, unknown>)) {\n if (choiceWord(key) !== word) continue;\n return group === \"in_progress\" ? STATUS_GROUP_COLOR.in_progress : group === \"done\" ? STATUS_GROUP_COLOR.done : STATUS_GROUP_COLOR.todo;\n }\n }\n return STATUS_GROUP_COLOR.todo;\n}\n\n/** The colour this Field keeps for this value, or `undefined` when it keeps none. */\nexport function storedChoiceColor(field: Field, value: unknown): StyleColor | undefined {\n if (value === null || value === undefined || value === \"\") return undefined;\n const word = choiceWord(value);\n if (word === \"\") return undefined;\n for (const look of choiceLooksOf(field)) {\n if (!look.color) continue;\n if (choiceWord(look.value) === word || (look.label && choiceWord(look.label) === word)) return look.color;\n }\n return statusGroupColor(field, value);\n}\n\n/**\n * THE COLOUR-BY LOOKUP, STORED COLOURS FIRST. A value whose column keeps a colour for it wears\n * that colour; any other value still paints, deterministically, through `fallback` — a colour-by\n * that silently did nothing would be the screen lying about a setting a person just changed.\n */\nexport function storedChoiceColorLookup(\n fields: readonly Field[],\n fallback: ChoiceColorLookup,\n): ChoiceColorLookup {\n const byKey = new Map(fields.map((f) => [f.key, f] as const));\n return (fieldKey, value) => {\n const field = byKey.get(fieldKey);\n return (field ? storedChoiceColor(field, value) : undefined) ?? fallback(fieldKey, value);\n };\n}\n\n/**\n * THE ORDER A NEW CHOICE IS PAINTED IN (Airtable): each choice added to a list takes the next\n * palette colour the list does not wear yet, so a fresh list reads as distinct chips with nobody\n * picking a colour. Grey last — it reads as \"no colour\".\n */\nexport const NEW_CHOICE_PALETTE: readonly StyleColor[] = [\"blue\", \"green\", \"amber\", \"red\", \"violet\", \"teal\", \"slate\"];\n\n/** The colour the next choice of a list takes, given the colours its choices already wear. */\nexport function nextChoiceColor(worn: ReadonlyArray<StyleColor | null | undefined>): StyleColor {\n const taken = new Set(worn.filter((c): c is StyleColor => Boolean(c)));\n const free = NEW_CHOICE_PALETTE.find((c) => !taken.has(c));\n return free ?? NEW_CHOICE_PALETTE[worn.length % NEW_CHOICE_PALETTE.length]!;\n}\n\n/**\n * THE ONE CHIP A CHOICE IS DRAWN AS — the grid cell, the picker's list and its chip, a form's\n * pills: the colour the column keeps for the value (by any of the words given — its key, its\n * label), else the neutral chip. One answer, so no surface paints a choice its own way.\n */\nexport function choiceChipLookOf(field: Field, ...words: unknown[]): { className: string; color: StyleColor | null } {\n for (const word of words) {\n const color = storedChoiceColor(field, word);\n if (color) return { className: CHOICE_CHIP_CLASS[color], color };\n }\n return { className: NEUTRAL_CHIP_CLASS, color: null };\n}\n","// src/parity.ts — @ai-matrx/records-ui\n//\n// FLD-11, the parity floor. A Field stores a BEHAVIOUR (one of five) plus\n// modifiers, unit and format; a person picked one of THIRTEEN parity types in\n// the UI. This resolves the second from the first, using the same facts the\n// store's own `custom.parity_field_types()` describes — which is generated into\n// `@ai-matrx/records` and imported here, never retyped.\n//\n// Nothing in this file decides policy. It decides which editor to draw.\n\nimport { displayFormatOf } from \"./choiceLooks\";\nimport {\n KERNEL_TABLES,\n PARITY_FIELD_TYPES,\n fieldKindFor,\n newerKindOf,\n isButtonField,\n type FieldKind,\n type KernelTargets,\n type ParityFieldType,\n} from \"@ai-matrx/records/field-kinds\";\nimport type { Field } from \"@ai-matrx/records\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\nimport { isSignatureField } from \"./docs\";\nimport { fieldTypeChoice, isSystemFieldKind, type PickableFieldType } from \"./fieldTypes\";\n\n/** The kernel ids come from the store's own kernel rows, never from a literal here. */\nconst kernelId = (name: string): string =>\n KERNEL_TABLES.find((t) => t.name === name)?.id ?? \"\";\nconst KERNEL_FILE_TABLE = kernelId(\"File\");\nconst KERNEL_PERSON_TABLE = kernelId(\"Person\");\n\nexport const PARITY_LABEL: Record<ParityFieldType, string> = {\n attachment: \"Attachment\",\n checkbox: \"Yes / no\",\n currency: \"Currency\",\n datetime: \"Date\",\n email: \"Email\",\n formula: \"Formula\",\n lookup: \"Lookup\",\n member: \"Person\",\n multi_select: \"Multi-select\",\n percent: \"Percent\",\n phone: \"Phone\",\n rollup: \"Rollup\",\n select: \"Select\",\n url: \"Link\",\n};\n\n/** The \"made of\" sentence the store itself publishes, for the field editor's help text. */\nexport const PARITY_MADE_OF: Record<string, string> = Object.fromEntries(\n PARITY_FIELD_TYPES.map((p) => [p.parity_type, p.made_of]),\n);\n\n/**\n * Plain text and plain number are behaviours with no parity type of their own.\n *\n * 🚨 THIS IS NOW AN ALIAS, AND THAT IS THE POINT (TAILS-3, 2026-09-21). The\n * classifier moved into `@ai-matrx/records` as `FieldKind` so that the editor a\n * person types into and the COERCION applied to what they typed are decided by\n * one body. They were decided by two, and the public booking page paid for it:\n * \"Vehicle Year takes a number, and it was given a string\" on every table with\n * a number field.\n */\nexport type EditorKind = FieldKind;\n\n/** The kernel ids come from the store's own kernel rows, never from a literal here. */\nconst KERNEL: KernelTargets = { file: KERNEL_FILE_TABLE, person: KERNEL_PERSON_TABLE };\n\n/**\n * Which editor one Field wants. Reads the Field's own declaration only — the\n * behaviour, the modifiers, the format, the relation target and the config —\n * because those are what the store stores, and a screen that guessed from a\n * value would draw a different editor for an empty record.\n *\n * It is `fieldKindFor` with this package's kernel ids bound. Nothing here\n * decides anything the core does not.\n */\nexport function editorKindFor(field: Field): EditorKind {\n return fieldKindFor(field, KERNEL);\n}\n\n/**\n * WHICH KIND A PERSON PICKED, read back off the Field the store keeps — the ONE reader every\n * \"what does this column hold\" answer goes through (the Settings column list, the column panel).\n *\n * `editorKindFor` answers which EDITOR to draw, and for two families that is not the kind a\n * person picked: a Signature is a text Field whose format is `signature` (it draws a line of\n * text), and the store's stamps — Record number, Created time, Last changed time — are formula\n * Fields whose `config.system` names the stamp. Read through the editor classifier alone, the\n * Settings list called a Signature \"Text\" and a Record number \"Worked out from other columns\"\n * (lane 10 W1-A, guard `every-pickable-kind-reads-back-as-itself.test.tsx`).\n *\n * `undefined` when the Field is none of the kinds the menu offers.\n */\nexport function pickableTypeOf(field: Field): PickableFieldType | undefined {\n if (isSignatureField(field)) return \"signature\";\n // NOTION-PROPS-3: a button is text wearing the format `button`.\n if (isButtonField(field)) return \"button\";\n // LANE 10 P4: the nine newer kinds, each a base type wearing a format (`newerKindOf`).\n const newer = newerKindOf(field);\n if (newer) return newer;\n // A RATING OR A TIME made as a plain column wearing its look (`LOOK_KINDS`): named by that kind.\n const look = displayFormatOf(field)?.id;\n if (look === \"rating\" && field.type === \"range\") return \"rating\";\n if (look === \"time\" && field.type === \"text\") return \"time\";\n if ((look === \"color_pair\" || look === \"type_style\" || look === \"shadow\") && field.type === \"text\") return look;\n if (look === \"measure\" && field.type === \"range\") return \"measure\";\n const system = (field.config as Record<string, unknown> | undefined)?.[\"system\"];\n if (field.type === \"formula\" && typeof system === \"string\" && isSystemFieldKind(system)) return system;\n const kind = editorKindFor(field);\n return fieldTypeChoice(kind) ? (kind as PickableFieldType) : undefined;\n}\n\n/**\n * The type word a person sees in a header or a settings row — and it is the\n * SAME word the field panel offers, read from `FIELD_TYPE_CHOICES`, so a column\n * added as \"Money\" is never described anywhere else as \"Currency\".\n */\nexport function fieldTypeLabel(field: Field): string {\n const kind = pickableTypeOf(field) ?? editorKindFor(field);\n const known = fieldTypeChoice(kind)?.label;\n if (known) return field.multi && kind !== \"multi_select\" ? `${known} (many)` : known;\n const plain: Record<string, string> = {\n // `boolean` is the BEHAVIOUR word; `checkbox` is the type a person picks. Both are\n // written the way a person writes them, never as a raw token.\n boolean: \"Yes / no\",\n date: \"Date\",\n json: \"Structured data\",\n relation: \"Link to a record\",\n };\n // Never a raw token on a screen: an editor kind this table has not named is\n // still written the way a person writes it.\n return plain[kind] ?? humanizeIdentifier(kind);\n}\n","/**\n * 🚨 THE ONE DATE HELPER EVERY LAYOUT READS (lane UI-FIX-18, VERIFIER-18 H2 / M1).\n *\n * MEASURED 2026-09-24 on production, browser in America/Los_Angeles: Kitchen's start date,\n * stored `2026-04-01`, read **Apr 1** in the grid, **Mar 31** on the calendar, **3/31** in\n * the gallery, and Backyard Deck's May 1 read **4/30** in the record panel. The grid was right\n * because it formats through the design system's registry (`formatFieldValue`), which reads a\n * bare `YYYY-MM-DD` as a day on a calendar. Every other surface called `new Date(\"2026-04-01\")`\n * itself — which JavaScript parses as UTC MIDNIGHT — and then printed it in the viewer's zone,\n * so everybody west of Greenwich saw the day before.\n *\n * THE CLASS, NOT THE INSTANCE. No component in this package parses or prints a date on its\n * own any more; it asks this file, and this file asks the SAME registry the grid asks. The\n * calendar's day key is the one thing the registry does not answer, and it is answered here\n * by the same rule: a bare calendar date IS its own day (read the characters), an instant\n * (`…Z`, `…+hh:mm`) is placed on the viewer's own calendar.\n *\n * The store's own stamps — Created time and Last changed time (`fx.created_time`,\n * `fx.modified_time`) — are instants, and are printed like every other date-and-time cell\n * (VERIFIER-18 M1 found `2026-09-25T00:13:34.564Z` in the grid, the gallery and the panel).\n */\nimport { formatFieldValue, type FieldFormatConfig } from \"@ai-matrx/design-system/field-formats\";\nimport type { Field } from \"@ai-matrx/records\";\n\n/** A day on a calendar with no time and no zone — `2026-04-01`, or a zoneless local midnight. */\nconst BARE_CALENDAR_DATE = /^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ]00:00(?::00(?:\\.0+)?)?)?$/;\n\ntype SystemStamp = \"autonumber\" | \"created_time\" | \"modified_time\";\n\n/** The store's own stamp this Field is, when it is one (`config.system`). */\nexport function systemStampOf(field: Pick<Field, \"type\" | \"config\">): SystemStamp | null {\n if (field.type !== \"formula\") return null;\n const system = String((field.config ?? {})[\"system\"] ?? \"\");\n return system === \"autonumber\" || system === \"created_time\" || system === \"modified_time\" ? system : null;\n}\n\n/**\n * Does this value (or, with no value, this Field) carry a TIME OF DAY as well as a date?\n *\n * A DATE IS A DATE (chair ruling, 2026-09-24). The control and the text follow the STORED\n * VALUE's shape, never `config.kind` alone: a value with no time part — `1988-06-14`, a date\n * of birth on a `kind: \"datetime\"` Field — gets a date-only control and a date-only reading\n * everywhere (grid, form, panel, calendar). With no value yet, only a Field that says so\n * outright carries a time: the older `format: \"datetime\"`, or the store's own Created / Last\n * changed stamps (instants by construction).\n */\nexport function carriesTimeOfDay(field: Pick<Field, \"type\" | \"config\" | \"format\">, value?: unknown): boolean {\n if (value !== undefined && value !== null && value !== \"\") return hasTimePart(value);\n const stamp = systemStampOf(field);\n if (stamp === \"created_time\" || stamp === \"modified_time\") return true;\n return (field.format ?? \"\").toLowerCase() === \"datetime\";\n}\n\n/**\n * THE TIME OF DAY A MOMENT CARRIES, in the reader's clock (\"3:30 PM\") — the same words the grid's\n * date-and-time cell ends in — or null for a bare day. A calendar's month card and a timeline's bar\n * show it before the title (lane 10 P4, verifier V8 #7), as Google Calendar does.\n */\nexport function timeOfDayWords(value: unknown): string | null {\n if (!hasTimePart(value)) return null;\n const at = value instanceof Date ? value : new Date(value as string | number);\n return Number.isNaN(at.getTime()) ? null : at.toLocaleTimeString(undefined, { hour: \"numeric\", minute: \"2-digit\" });\n}\n\n/** A value that names a moment in the day, not just the day. */\nexport function hasTimePart(value: unknown): boolean {\n if (value instanceof Date || typeof value === \"number\") return true;\n if (typeof value !== \"string\") return false;\n const trimmed = value.trim();\n if (BARE_CALENDAR_DATE.test(trimmed)) return false;\n return /^\\d{4}-\\d{2}-\\d{2}[T ]\\d/.test(trimmed);\n}\n\n/** Is this Field a date column at all — a dated range, or the store's own time stamp? */\nexport function isDateField(field: Pick<Field, \"type\" | \"config\">): boolean {\n const stamp = systemStampOf(field);\n if (stamp === \"created_time\" || stamp === \"modified_time\") return true;\n if (field.type !== \"range\") return false;\n const kind = String((field.config ?? {})[\"kind\"] ?? \"\");\n return kind === \"date\" || kind === \"datetime\";\n}\n\n/**\n * The format a date-ish Field draws with, or `undefined` for a Field that is not one. With a\n * value, it is that value's own shape; without, the Field's (`carriesTimeOfDay`).\n * `presentation.formatForField` answers dates through this, so the grid and every card agree.\n */\nexport function dateFormatFor(\n field: Pick<Field, \"type\" | \"config\" | \"format\">,\n value?: unknown,\n): FieldFormatConfig | undefined {\n if (!isDateField(field)) return undefined;\n return carriesTimeOfDay(field, value) ? { id: \"datetime\" } : { id: \"date\" };\n}\n\n/**\n * THE TEXT OF ONE DATE VALUE, in the viewer's language — through the design system's\n * registry, exactly as the grid prints it, in the value's own shape. `null` when the value is\n * not a date at all, so the caller can fall back to its own reading (THE FALLBACK LAW).\n */\nexport function dateText(field: Pick<Field, \"type\" | \"config\" | \"format\">, value: unknown): string | null {\n const format = dateFormatFor(field, value) ?? (isDateLike(value) ? { id: hasTimePart(value) ? \"datetime\" : \"date\" } : undefined);\n if (!format) return null;\n const result = formatFieldValue(value, format);\n return result.ok && !result.empty ? result.text : null;\n}\n\nfunction isDateLike(value: unknown): boolean {\n return typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}/.test(value.trim());\n}\n\nfunction pad(n: number): string {\n return n < 10 ? `0${n}` : String(n);\n}\n\n/**\n * THE CALENDAR DAY a value falls on, as `YYYY-MM-DD` — the key a calendar files a card under.\n *\n * A bare calendar date is its own day. An instant is placed on the VIEWER's calendar: a visit\n * logged at 5:13 PM Pacific on 24 September is on the 24th for the person in Pacific time,\n * even though it is already the 25th in UTC.\n */\nexport function calendarDayOf(value: unknown): string | null {\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n const bare = BARE_CALENDAR_DATE.exec(trimmed);\n if (bare) return `${bare[1]}-${bare[2]}-${bare[3]}`;\n if (trimmed === \"\") return null;\n } else if (typeof value !== \"number\" && !(value instanceof Date)) {\n return null;\n }\n const at = value instanceof Date ? value : new Date(value as string | number);\n if (Number.isNaN(at.getTime())) return null;\n return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`;\n}\n\n/** The heading of one calendar day — `Apr 1, 2026` — built on local midnight, never UTC. */\nexport function calendarDayLabel(day: string): string {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(day);\n if (!m) return day;\n const at = new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]));\n return at.toLocaleDateString(undefined, { month: \"short\", day: \"numeric\", year: \"numeric\" });\n}\n\n// ---------------------------------------------------------------------------------------------\n// DAY ARITHMETIC ON THE VIEWER'S OWN CALENDAR (lane VIEWS-AND-FIELDS, sublane TL, 2026-10-02).\n// A day key is `YYYY-MM-DD`, built and read at LOCAL midnight — never `new Date(\"YYYY-MM-DD\")`,\n// which is UTC midnight and lands on the day before for everybody west of Greenwich. The timeline\n// places and moves bars with these; a move is always a whole number of days.\n\n/** The day key of a moment, on the viewer's calendar. */\nexport function dayKeyOf(at: Date): string {\n return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`;\n}\n\n/** A day key as local midnight. */\nexport function dayAt(day: string): Date {\n const [y, m, d] = day.split(\"-\").map(Number);\n return new Date(y!, (m ?? 1) - 1, d ?? 1);\n}\n\n/** The day `n` days after (or before, when negative) `day`. */\nexport function addDays(day: string, n: number): string {\n const at = dayAt(day);\n at.setDate(at.getDate() + n);\n return dayKeyOf(at);\n}\n\n/** Whole days from `from` to `to` (negative when `to` is earlier). DST-safe: rounds the hour away. */\nexport function daysBetween(from: string, to: string): number {\n return Math.round((dayAt(to).getTime() - dayAt(from).getTime()) / 86_400_000);\n}\n"],"mappings":";;;;;;;AAmBO,SAAS,WAAW,SAAuB;AAChD,SAAO,WAAW,OAAO;AAC3B;AAmBO,SAAS,aAAa,MAAc,QAAyB;AAClE,QAAM,QAAQ,IAAI,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AACtD,SAAO,KAAK,QAAQ,kCAAkC,CAAC,OAAO,QAAgB;AAC5E,UAAM,KAAK,MAAM,IAAI,GAAG;AACxB,WAAO,KAAK,WAAW,EAAE,IAAI;AAAA,EAC/B,CAAC;AACH;AAGO,SAAS,eAAe,MAAc,QAAyB;AACpE,QAAM,OAAO,IAAI,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;AAChE,SAAO,KAAK,QAAQ,2CAA2C,CAAC,OAAO,OAAe;AACpF,UAAM,QAAQ,KAAK,IAAI,EAAE;AACzB,WAAO,QAAQ,KAAK,KAAK,OAAO;AAAA,EAClC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