@elytracms/studio 0.0.33 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/components/app-views/default-modules.js +13 -6
  2. package/dist/components/app-views/default-modules.js.map +1 -1
  3. package/dist/components/cms/cms-store.d.ts +7 -6
  4. package/dist/components/cms/cms-store.js +30 -10
  5. package/dist/components/cms/cms-store.js.map +1 -1
  6. package/dist/components/cms/detail-editor.js +29 -7
  7. package/dist/components/cms/detail-editor.js.map +1 -1
  8. package/dist/components/cms/details-pane.js +4 -3
  9. package/dist/components/cms/details-pane.js.map +1 -1
  10. package/dist/components/cms/field-renderer.js +2 -1
  11. package/dist/components/cms/field-renderer.js.map +1 -1
  12. package/dist/components/cms/import-export.js +3 -2
  13. package/dist/components/cms/import-export.js.map +1 -1
  14. package/dist/components/cms/issues-pane.js +3 -2
  15. package/dist/components/cms/issues-pane.js.map +1 -1
  16. package/dist/components/redirects/redirects-schema.js +10 -5
  17. package/dist/components/redirects/redirects-schema.js.map +1 -1
  18. package/dist/components/users/users-schema.js +7 -4
  19. package/dist/components/users/users-schema.js.map +1 -1
  20. package/dist/lib/cms-views/view-model.js +3 -2
  21. package/dist/lib/cms-views/view-model.js.map +1 -1
  22. package/dist/lib/i18n/i18n.d.ts +29 -2
  23. package/dist/lib/i18n/i18n.js +93 -9
  24. package/dist/lib/i18n/i18n.js.map +1 -1
  25. package/dist/lib/i18n/index.d.ts +1 -1
  26. package/dist/lib/i18n/index.js +1 -1
  27. package/dist/lib/i18n/index.js.map +1 -1
  28. package/dist/lib/i18n/messages.en.js +38 -0
  29. package/dist/lib/i18n/messages.en.js.map +1 -1
  30. package/dist/lib/i18n/types.d.ts +13 -0
  31. package/dist/lib/i18n/types.js.map +1 -1
  32. package/dist/lib/references/reference-model.js +6 -4
  33. package/dist/lib/references/reference-model.js.map +1 -1
  34. package/package.json +2 -2
@@ -3,6 +3,7 @@ import { Component, useMemo } from 'react';
3
3
  import { AlertTriangle } from 'lucide-react';
4
4
  import { resolveOverrides } from '@elytracms/core/studio-core';
5
5
  import { resolveDeploymentFieldRenderers } from '@elytracms/studio/lib/workspace';
6
+ import { translate } from '@elytracms/studio/lib/i18n';
6
7
  import { Input, Row, Text } from '@elytracms/studio/ui';
7
8
  /**
8
9
  * Resolve the studio config's custom field renderers through the shared
@@ -57,6 +58,6 @@ export class FieldRendererBoundary extends Component {
57
58
  */
58
59
  export const colorFieldRenderer = ({ value, onChange, readOnly, id }) => {
59
60
  const hex = typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value : '#000000';
60
- return (_jsxs(Row, { gap: "2", align: "center", children: [_jsx("input", { id: id, type: "color", disabled: readOnly, value: hex, onChange: (event) => onChange(event.target.value), "aria-label": "Colour", className: "h-8 w-12 cursor-pointer rounded-md border border-input bg-background disabled:opacity-50" }), _jsx(Input, { value: typeof value === 'string' ? value : '', disabled: readOnly, placeholder: "#rrggbb", onChange: (event) => onChange(event.target.value || undefined), className: "w-28 font-mono text-xs" })] }));
61
+ return (_jsxs(Row, { gap: "2", align: "center", children: [_jsx("input", { id: id, type: "color", disabled: readOnly, value: hex, onChange: (event) => onChange(event.target.value), "aria-label": translate('cms.field.colour'), className: "h-8 w-12 cursor-pointer rounded-md border border-input bg-background disabled:opacity-50" }), _jsx(Input, { value: typeof value === 'string' ? value : '', disabled: readOnly, placeholder: "#rrggbb", onChange: (event) => onChange(event.target.value || undefined), className: "w-28 font-mono text-xs" })] }));
61
62
  };
62
63
  //# sourceMappingURL=field-renderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field-renderer.js","sourceRoot":"","sources":["../../../src/components/cms/field-renderer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,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K,CAAC,CAAC,CAAC,EAAE,EAC7C,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAC,SAAS,EACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC,EAC9D,SAAS,EAAC,wBAAwB,GAClC,IACE,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { Component, useMemo } from 'react'\nimport type { ReactNode } from 'react'\nimport { AlertTriangle } from 'lucide-react'\nimport { resolveOverrides } from '@elytracms/core/studio-core'\nimport type { CustomizationIssue } from '@elytracms/core/studio-core'\nimport { resolveDeploymentFieldRenderers } from '@elytracms/studio/lib/workspace'\nimport { Input, Row, Text } from '@elytracms/studio/ui'\nimport type { CustomFieldRenderer } from '../app-views/studio-config'\n\n/**\n * EC-238 — custom field renderers, an instance of the EC-236 customization seam.\n *\n * A project registers a React component (via `defineStudio({ fieldRenderers })`)\n * keyed by CONTROL name to REPLACE the built-in document-editor control. A field\n * opts in PER-FIELD with `form: { control: '<name>' }` — so a renderer targets\n * exactly the fields that ask for it, not every field of a datatype. (`control` is\n * a presentation hint on the field; the field's `type` stays its honest datatype.\n * That split is why a colour is `type: 'text'` + `control: 'color'`, not a bogus\n * `plugin.color` type.) The contract is the exact {@link FieldControl} props seam,\n * so a project component drops in unchanged and reuses internal helpers\n * (relation/asset pickers, validation state) via the exported studio hooks\n * (`useCms`, `useOptionalDocumentEditor`). Resolution falls back to the built-in\n * control, and every failure mode — a non-component value, an unknown control on a\n * field, or a renderer that throws — surfaces a visible issue, never a silent drop\n * or a crash.\n */\n\nexport type { CustomFieldRenderer, CustomFieldRendererProps } from '../app-views/studio-config'\n\nexport interface ResolvedFieldRenderers {\n /** The custom renderer for a control name, or `undefined` → use the built-in. */\n get(control: string): CustomFieldRenderer | undefined\n /** Resolution issues (non-component); located by `id` = control name. */\n issues: CustomizationIssue[]\n}\n\n/**\n * Resolve the studio config's custom field renderers through the shared\n * customization core (EC-236): a registry keyed by control name, rejecting a\n * non-component with a visible issue and keeping the built-in. The map's keys are\n * unique by construction, so duplicates are structurally impossible.\n */\nexport function resolveFieldRenderers(\n renderers: Record<string, CustomFieldRenderer> | undefined,\n): ResolvedFieldRenderers {\n const resolved = resolveOverrides<CustomFieldRenderer>({\n point: 'fieldRenderers',\n defaults: [],\n overrides: Object.entries(renderers ?? {}).map(([control, component]) => ({\n id: control,\n value: component,\n })),\n allowNew: true,\n validate: (entry) => (typeof entry.value !== 'function' ? 'the renderer is not a component' : null),\n })\n return { get: (control) => resolved.get(control), issues: resolved.issues }\n}\n\n/** The active studio's resolved field renderers (config is static per studio boot). */\nexport function useFieldRenderers(): ResolvedFieldRenderers {\n return useMemo(() => resolveFieldRenderers(resolveDeploymentFieldRenderers()), [])\n}\n\n/** A visible, inline field-renderer issue — the customization seam's \"never silent\". */\nexport function FieldRendererIssue({ message }: { message: string }) {\n return (\n <Row gap=\"1\" align=\"center\" className=\"text-amber-600 dark:text-amber-400\" title={message}>\n <AlertTriangle aria-hidden className=\"size-3.5\" />\n <Text size=\"xs\">{message}</Text>\n </Row>\n )\n}\n\n/**\n * Error boundary around a custom renderer: a renderer that throws falls back to\n * the built-in control (passed as `fallback`) with a visible `issue` above it,\n * so a broken third-party component degrades the one field, never the editor.\n */\nexport class FieldRendererBoundary extends Component<\n { fallback: ReactNode; issue: ReactNode; children: ReactNode },\n { failed: boolean }\n> {\n override state = { failed: false }\n static getDerivedStateFromError() {\n return { failed: true }\n }\n override render() {\n if (this.state.failed) {\n return (\n <>\n {this.props.issue}\n {this.props.fallback}\n </>\n )\n }\n return this.props.children\n }\n}\n\n/**\n * Example custom field renderer (EC-238 DoD): a colour control proving reuse of\n * the studio form primitives and a save round-trip. A consuming repo registers it\n * (or its own) with `defineStudio({ fieldRenderers: { color: colorFieldRenderer } })`\n * and opts a field in with `form: { control: 'color' }` — the field's datatype\n * stays `text` (a `#rrggbb` string).\n */\nexport const colorFieldRenderer: CustomFieldRenderer = ({ value, onChange, readOnly, id }) => {\n const hex = typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value : '#000000'\n return (\n <Row gap=\"2\" align=\"center\">\n <input\n id={id}\n type=\"color\"\n disabled={readOnly}\n value={hex}\n onChange={(event) => onChange(event.target.value)}\n aria-label=\"Colour\"\n className=\"h-8 w-12 cursor-pointer rounded-md border border-input bg-background disabled:opacity-50\"\n />\n <Input\n value={typeof value === 'string' ? value : ''}\n disabled={readOnly}\n placeholder=\"#rrggbb\"\n onChange={(event) => onChange(event.target.value || undefined)}\n className=\"w-28 font-mono text-xs\"\n />\n </Row>\n )\n}\n"]}
1
+ {"version":3,"file":"field-renderer.js","sourceRoot":"","sources":["../../../src/components/cms/field-renderer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAA;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AA8BvD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAA0D;IAE1D,MAAM,QAAQ,GAAG,gBAAgB,CAAsB;QACrD,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;YACxE,EAAE,EAAE,OAAO;YACX,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,QAAQ,EAAE,IAAI;QACd,QAAQ,EAA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AC;CACF;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE;IAC3F,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IAC1F,OAAO,CACL,MAAC,GAAG,IAAC,GAAG,EAAC,GAAG,EAAC,KAAK,EAAC,QAAQ,aACzB,gBACE,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,gBACrC,SAAS,CAAC,kBAAkB,CAAC,EACzC,SAAS,EAAC,0FAA0F,GACpG,EACF,KAAC,KAAK,IACJ,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAC7C,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAC,SAAS,EACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC,EAC9D,SAAS,EAAC,wBAAwB,GAClC,IACE,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { Component, useMemo } from 'react'\nimport type { ReactNode } from 'react'\nimport { AlertTriangle } from 'lucide-react'\nimport { resolveOverrides } from '@elytracms/core/studio-core'\nimport type { CustomizationIssue } from '@elytracms/core/studio-core'\nimport { resolveDeploymentFieldRenderers } from '@elytracms/studio/lib/workspace'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { Input, Row, Text } from '@elytracms/studio/ui'\nimport type { CustomFieldRenderer } from '../app-views/studio-config'\n\n/**\n * EC-238 — custom field renderers, an instance of the EC-236 customization seam.\n *\n * A project registers a React component (via `defineStudio({ fieldRenderers })`)\n * keyed by CONTROL name to REPLACE the built-in document-editor control. A field\n * opts in PER-FIELD with `form: { control: '<name>' }` — so a renderer targets\n * exactly the fields that ask for it, not every field of a datatype. (`control` is\n * a presentation hint on the field; the field's `type` stays its honest datatype.\n * That split is why a colour is `type: 'text'` + `control: 'color'`, not a bogus\n * `plugin.color` type.) The contract is the exact {@link FieldControl} props seam,\n * so a project component drops in unchanged and reuses internal helpers\n * (relation/asset pickers, validation state) via the exported studio hooks\n * (`useCms`, `useOptionalDocumentEditor`). Resolution falls back to the built-in\n * control, and every failure mode — a non-component value, an unknown control on a\n * field, or a renderer that throws — surfaces a visible issue, never a silent drop\n * or a crash.\n */\n\nexport type { CustomFieldRenderer, CustomFieldRendererProps } from '../app-views/studio-config'\n\nexport interface ResolvedFieldRenderers {\n /** The custom renderer for a control name, or `undefined` → use the built-in. */\n get(control: string): CustomFieldRenderer | undefined\n /** Resolution issues (non-component); located by `id` = control name. */\n issues: CustomizationIssue[]\n}\n\n/**\n * Resolve the studio config's custom field renderers through the shared\n * customization core (EC-236): a registry keyed by control name, rejecting a\n * non-component with a visible issue and keeping the built-in. The map's keys are\n * unique by construction, so duplicates are structurally impossible.\n */\nexport function resolveFieldRenderers(\n renderers: Record<string, CustomFieldRenderer> | undefined,\n): ResolvedFieldRenderers {\n const resolved = resolveOverrides<CustomFieldRenderer>({\n point: 'fieldRenderers',\n defaults: [],\n overrides: Object.entries(renderers ?? {}).map(([control, component]) => ({\n id: control,\n value: component,\n })),\n allowNew: true,\n validate: (entry) => (typeof entry.value !== 'function' ? 'the renderer is not a component' : null),\n })\n return { get: (control) => resolved.get(control), issues: resolved.issues }\n}\n\n/** The active studio's resolved field renderers (config is static per studio boot). */\nexport function useFieldRenderers(): ResolvedFieldRenderers {\n return useMemo(() => resolveFieldRenderers(resolveDeploymentFieldRenderers()), [])\n}\n\n/** A visible, inline field-renderer issue — the customization seam's \"never silent\". */\nexport function FieldRendererIssue({ message }: { message: string }) {\n return (\n <Row gap=\"1\" align=\"center\" className=\"text-amber-600 dark:text-amber-400\" title={message}>\n <AlertTriangle aria-hidden className=\"size-3.5\" />\n <Text size=\"xs\">{message}</Text>\n </Row>\n )\n}\n\n/**\n * Error boundary around a custom renderer: a renderer that throws falls back to\n * the built-in control (passed as `fallback`) with a visible `issue` above it,\n * so a broken third-party component degrades the one field, never the editor.\n */\nexport class FieldRendererBoundary extends Component<\n { fallback: ReactNode; issue: ReactNode; children: ReactNode },\n { failed: boolean }\n> {\n override state = { failed: false }\n static getDerivedStateFromError() {\n return { failed: true }\n }\n override render() {\n if (this.state.failed) {\n return (\n <>\n {this.props.issue}\n {this.props.fallback}\n </>\n )\n }\n return this.props.children\n }\n}\n\n/**\n * Example custom field renderer (EC-238 DoD): a colour control proving reuse of\n * the studio form primitives and a save round-trip. A consuming repo registers it\n * (or its own) with `defineStudio({ fieldRenderers: { color: colorFieldRenderer } })`\n * and opts a field in with `form: { control: 'color' }` — the field's datatype\n * stays `text` (a `#rrggbb` string).\n */\nexport const colorFieldRenderer: CustomFieldRenderer = ({ value, onChange, readOnly, id }) => {\n const hex = typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value : '#000000'\n return (\n <Row gap=\"2\" align=\"center\">\n <input\n id={id}\n type=\"color\"\n disabled={readOnly}\n value={hex}\n onChange={(event) => onChange(event.target.value)}\n aria-label={translate('cms.field.colour')}\n className=\"h-8 w-12 cursor-pointer rounded-md border border-input bg-background disabled:opacity-50\"\n />\n <Input\n value={typeof value === 'string' ? value : ''}\n disabled={readOnly}\n placeholder=\"#rrggbb\"\n onChange={(event) => onChange(event.target.value || undefined)}\n className=\"w-28 font-mono text-xs\"\n />\n </Row>\n )\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { Badge, Button, Code, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Stack, Text, } from '@elytracms/studio/ui';
4
+ import { translate } from '@elytracms/studio/lib/i18n';
4
5
  import { useCollectionView } from '../collection-view/collection-view-context';
5
6
  /** Import collection data from JSON with validation + error reporting (brief §8.4, EC-079). */
6
7
  export function ImportDialog({ collectionId, open, onOpenChange, }) {
@@ -22,7 +23,7 @@ export function ImportDialog({ collectionId, open, onOpenChange, }) {
22
23
  parsed = JSON.parse(text);
23
24
  }
24
25
  catch {
25
- setParseError('Input is not valid JSON.');
26
+ setParseError(translate('cms.import.invalidJson'));
26
27
  return;
27
28
  }
28
29
  const items = Array.isArray(parsed) ? parsed : [parsed];
@@ -30,6 +31,6 @@ export function ImportDialog({ collectionId, open, onOpenChange, }) {
30
31
  if (outcome)
31
32
  setReport(outcome);
32
33
  }
33
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-lg", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Import documents" }), _jsxs(DialogDescription, { children: ["Paste a JSON array of documents for ", _jsx(Code, { tone: "muted", children: collectionId }), ". Each is validated against the collection schema before import."] })] }), _jsx("textarea", { value: text, onChange: (e) => setText(e.target.value), rows: 8, placeholder: '[{ "id": "post-x", "values": { "slug": "x" }, ... }]', className: "w-full rounded-md border border-input bg-background p-2.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none" }), parseError ? (_jsx(Text, { size: "sm", className: "text-destructive", children: parseError })) : null, report ? (_jsxs(Stack, { gap: "2", className: "rounded-md border border-border p-3", children: [_jsxs(Badge, { variant: report.added > 0 ? 'success' : 'outline', children: [report.added, " imported"] }), report.rejected.length > 0 ? (_jsxs(Stack, { gap: "1", children: [_jsxs(Text, { size: "xs", tone: "muted", children: [report.rejected.length, " rejected:"] }), report.rejected.map((r, i) => (_jsxs(Text, { size: "xs", className: "text-destructive", children: [_jsx(Code, { tone: "muted", children: r.id }), " \u2014 ", r.issues[0]?.message] }, `${r.id}-${i}`)))] })) : null] })) : null, _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "ghost", onClick: () => onOpenChange(false), children: "Close" }), _jsx(Button, { onClick: runImport, disabled: !text.trim(), children: "Import" })] })] }) }));
34
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-lg", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: translate('cms.import.title') }), _jsxs(DialogDescription, { children: ["Paste a JSON array of documents for ", _jsx(Code, { tone: "muted", children: collectionId }), ". Each is validated against the collection schema before import."] })] }), _jsx("textarea", { value: text, onChange: (e) => setText(e.target.value), rows: 8, placeholder: '[{ "id": "post-x", "values": { "slug": "x" }, ... }]', className: "w-full rounded-md border border-input bg-background p-2.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none" }), parseError ? (_jsx(Text, { size: "sm", className: "text-destructive", children: parseError })) : null, report ? (_jsxs(Stack, { gap: "2", className: "rounded-md border border-border p-3", children: [_jsx(Badge, { variant: report.added > 0 ? 'success' : 'outline', children: translate('cms.import.imported', { count: report.added }) }), report.rejected.length > 0 ? (_jsxs(Stack, { gap: "1", children: [_jsx(Text, { size: "xs", tone: "muted", children: translate('cms.import.rejected', { count: report.rejected.length }) }), report.rejected.map((r, i) => (_jsxs(Text, { size: "xs", className: "text-destructive", children: [_jsx(Code, { tone: "muted", children: r.id }), " \u2014 ", r.issues[0]?.message] }, `${r.id}-${i}`)))] })) : null] })) : null, _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "ghost", onClick: () => onOpenChange(false), children: translate('common.close') }), _jsx(Button, { onClick: runImport, disabled: !text.trim(), children: translate('cms.import.confirm') })] })] }) }));
34
35
  }
35
36
  //# sourceMappingURL=import-export.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"import-export.js","sourceRoot":"","sources":["../../../src/components/cms/import-export.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EACL,KAAK,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,IAAI,GACL,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAG9E,+FAA+F;AAC/F,MAAM,UAAU,YAAY,CAAC,EAC3B,YAAY,EACZ,IAAI,EACJ,YAAY,GAKb;IACC,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAA;IAClC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IACpC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAsB,IAAI,CAAC,CAAA;IAC/D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAEjE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,CAAC,EAAE,CAAC,CAAA;YACX,SAAS,CAAC,IAAI,CAAC,CAAA;YACf,aAAa,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,SAAS,SAAS;QAChB,aAAa,CAAC,IAAI,CAAC,CAAA;QACnB,IAAI,MAAe,CAAA;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,aAAa,CAAC,0BAA0B,CAAC,CAAA;YACzC,OAAM;QACR,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,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IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,aACzB,MAAM,CAAC,QAAQ,CAAC,MAAM,kBAClB,EACN,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC7B,MAAC,IAAI,IAAsB,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,kBAAkB,aAC/D,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,YAAE,CAAC,CAAC,EAAE,GAAQ,cAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,KAD/C,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAElB,CACR,CAAC,IACI,CACT,CAAC,CAAC,CAAC,IAAI,IACF,CACT,CAAC,CAAC,CAAC,IAAI,EAER,MAAC,YAAY,eACX,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,sBAEjD,EACT,KAAC,MAAM,IAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,uBAEzC,IACI,IACD,GACT,CACV,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useState } from 'react'\nimport {\n Badge,\n Button,\n Code,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { useCollectionView } from '../collection-view/collection-view-context'\nimport type { ImportReport } from './cms-store'\n\n/** Import collection data from JSON with validation + error reporting (brief §8.4, EC-079). */\nexport function ImportDialog({\n collectionId,\n open,\n onOpenChange,\n}: {\n collectionId: string\n open: boolean\n onOpenChange: (open: boolean) => void\n}) {\n const source = useCollectionView()\n const [text, setText] = useState('')\n const [report, setReport] = useState<ImportReport | null>(null)\n const [parseError, setParseError] = useState<string | null>(null)\n\n useEffect(() => {\n if (open) {\n setText('')\n setReport(null)\n setParseError(null)\n }\n }, [open])\n\n function runImport() {\n setParseError(null)\n let parsed: unknown\n try {\n parsed = JSON.parse(text)\n } catch {\n setParseError('Input is not valid JSON.')\n return\n }\n const items = Array.isArray(parsed) ? parsed : [parsed]\n const outcome = source.imports?.importDocuments(items)\n if (outcome) setReport(outcome)\n }\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-w-lg\">\n <DialogHeader>\n <DialogTitle>Import documents</DialogTitle>\n <DialogDescription>\n Paste a JSON array of documents for <Code tone=\"muted\">{collectionId}</Code>. Each is\n validated against the collection schema before import.\n </DialogDescription>\n </DialogHeader>\n\n <textarea\n value={text}\n onChange={(e) => setText(e.target.value)}\n rows={8}\n placeholder='[{ \"id\": \"post-x\", \"values\": { \"slug\": \"x\" }, ... }]'\n className=\"w-full rounded-md border border-input bg-background p-2.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none\"\n />\n\n {parseError ? (\n <Text size=\"sm\" className=\"text-destructive\">\n {parseError}\n </Text>\n ) : null}\n\n {report ? (\n <Stack gap=\"2\" className=\"rounded-md border border-border p-3\">\n <Badge variant={report.added > 0 ? 'success' : 'outline'}>{report.added} imported</Badge>\n {report.rejected.length > 0 ? (\n <Stack gap=\"1\">\n <Text size=\"xs\" tone=\"muted\">\n {report.rejected.length} rejected:\n </Text>\n {report.rejected.map((r, i) => (\n <Text key={`${r.id}-${i}`} size=\"xs\" className=\"text-destructive\">\n <Code tone=\"muted\">{r.id}</Code> — {r.issues[0]?.message}\n </Text>\n ))}\n </Stack>\n ) : null}\n </Stack>\n ) : null}\n\n <DialogFooter>\n <Button variant=\"ghost\" onClick={() => onOpenChange(false)}>\n Close\n </Button>\n <Button onClick={runImport} disabled={!text.trim()}>\n Import\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"]}
1
+ {"version":3,"file":"import-export.js","sourceRoot":"","sources":["../../../src/components/cms/import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GAAG,CAAC,CAAC,CAAC,CAAC,CAC5B,MAAC,KAAK,IAAC,GAAG,EAAC,GAAG,aACZ,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,YACzB,SAAS,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAC/D,EACN,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC7B,MAAC,IAAI,IAAsB,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,kBAAkB,aAC/D,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,YAAE,CAAC,CAAC,EAAE,GAAQ,cAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,KAD/C,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAElB,CACR,CAAC,IACI,CACT,CAAC,CAAC,CAAC,IAAI,IACF,CACT,CAAC,CAAC,CAAC,IAAI,EAER,MAAC,YAAY,eACX,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,YACvD,SAAS,CAAC,cAAc,CAAC,GACnB,EACT,KAAC,MAAM,IAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,YAC/C,SAAS,CAAC,oBAAoB,CAAC,GACzB,IACI,IACD,GACT,CACV,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useState } from 'react'\nimport {\n Badge,\n Button,\n Code,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { useCollectionView } from '../collection-view/collection-view-context'\nimport type { ImportReport } from './cms-store'\n\n/** Import collection data from JSON with validation + error reporting (brief §8.4, EC-079). */\nexport function ImportDialog({\n collectionId,\n open,\n onOpenChange,\n}: {\n collectionId: string\n open: boolean\n onOpenChange: (open: boolean) => void\n}) {\n const source = useCollectionView()\n const [text, setText] = useState('')\n const [report, setReport] = useState<ImportReport | null>(null)\n const [parseError, setParseError] = useState<string | null>(null)\n\n useEffect(() => {\n if (open) {\n setText('')\n setReport(null)\n setParseError(null)\n }\n }, [open])\n\n function runImport() {\n setParseError(null)\n let parsed: unknown\n try {\n parsed = JSON.parse(text)\n } catch {\n setParseError(translate('cms.import.invalidJson'))\n return\n }\n const items = Array.isArray(parsed) ? parsed : [parsed]\n const outcome = source.imports?.importDocuments(items)\n if (outcome) setReport(outcome)\n }\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-w-lg\">\n <DialogHeader>\n <DialogTitle>{translate('cms.import.title')}</DialogTitle>\n <DialogDescription>\n Paste a JSON array of documents for <Code tone=\"muted\">{collectionId}</Code>. Each is\n validated against the collection schema before import.\n </DialogDescription>\n </DialogHeader>\n\n <textarea\n value={text}\n onChange={(e) => setText(e.target.value)}\n rows={8}\n placeholder='[{ \"id\": \"post-x\", \"values\": { \"slug\": \"x\" }, ... }]'\n className=\"w-full rounded-md border border-input bg-background p-2.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none\"\n />\n\n {parseError ? (\n <Text size=\"sm\" className=\"text-destructive\">\n {parseError}\n </Text>\n ) : null}\n\n {report ? (\n <Stack gap=\"2\" className=\"rounded-md border border-border p-3\">\n <Badge variant={report.added > 0 ? 'success' : 'outline'}>\n {translate('cms.import.imported', { count: report.added })}\n </Badge>\n {report.rejected.length > 0 ? (\n <Stack gap=\"1\">\n <Text size=\"xs\" tone=\"muted\">\n {translate('cms.import.rejected', { count: report.rejected.length })}\n </Text>\n {report.rejected.map((r, i) => (\n <Text key={`${r.id}-${i}`} size=\"xs\" className=\"text-destructive\">\n <Code tone=\"muted\">{r.id}</Code> — {r.issues[0]?.message}\n </Text>\n ))}\n </Stack>\n ) : null}\n </Stack>\n ) : null}\n\n <DialogFooter>\n <Button variant=\"ghost\" onClick={() => onOpenChange(false)}>\n {translate('common.close')}\n </Button>\n <Button onClick={runImport} disabled={!text.trim()}>\n {translate('cms.import.confirm')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"]}
@@ -3,6 +3,7 @@ import { CircleAlert, CircleCheck, TriangleAlert } from 'lucide-react';
3
3
  import { Button, Row, Stack, Text } from '@elytracms/studio/ui';
4
4
  import { cn } from '@elytracms/studio/lib/utils';
5
5
  import { cmsIssueLabel } from '@elytracms/studio/lib/persona/labels';
6
+ import { translate } from '@elytracms/studio/lib/i18n';
6
7
  import { fieldLabel } from './cms-store';
7
8
  /**
8
9
  * EC-283 — the document-scoped validation surface.
@@ -19,7 +20,7 @@ import { fieldLabel } from './cms-store';
19
20
  */
20
21
  export function IssuesPane({ issues, collection, onJumpToField, }) {
21
22
  if (issues.length === 0) {
22
- return (_jsxs(Stack, { gap: "2", align: "center", className: "px-4 py-10 text-center", children: [_jsx(CircleCheck, { className: "size-5 text-success", "aria-hidden": true }), _jsx(Text, { size: "sm", weight: "medium", children: "No issues" }), _jsx(Text, { size: "xs", tone: "muted", children: "This document satisfies the collection schema." })] }));
23
+ return (_jsxs(Stack, { gap: "2", align: "center", className: "px-4 py-10 text-center", children: [_jsx(CircleCheck, { className: "size-5 text-success", "aria-hidden": true }), _jsx(Text, { size: "sm", weight: "medium", children: translate('cms.issues.none') }), _jsx(Text, { size: "xs", tone: "muted", children: translate('cms.issues.satisfied') })] }));
23
24
  }
24
25
  return (_jsx(Stack, { gap: "1", className: "p-2", children: issues.map((issue, i) => (_jsx(IssueRow, { issue: issue, collection: collection, onJumpToField: onJumpToField }, `${issue.code}:${issue.path.join('/')}:${i}`))) }));
25
26
  }
@@ -28,6 +29,6 @@ function IssueRow({ issue, collection, onJumpToField, }) {
28
29
  const fieldName = typeof issue.meta?.field === 'string' ? issue.meta.field : undefined;
29
30
  const fieldDef = fieldName ? collection.fields.find((f) => f.name === fieldName) : undefined;
30
31
  const Icon = isError ? CircleAlert : TriangleAlert;
31
- return (_jsxs(Stack, { gap: "1", className: cn('rounded-md border px-2.5 py-2', isError ? 'border-destructive/30 bg-destructive/5' : 'border-warning/30 bg-warning/5'), children: [_jsxs(Row, { gap: "2", align: "start", children: [_jsx(Icon, { className: cn('mt-0.5 size-3.5 shrink-0', isError ? 'text-destructive' : 'text-warning'), "aria-hidden": true }), _jsxs(Stack, { gap: "1", className: "min-w-0", children: [_jsx(Text, { size: "xs", weight: "semibold", title: issue.code, children: cmsIssueLabel(issue.code) }), _jsx(Text, { size: "xs", tone: "muted", children: issue.message })] })] }), fieldName ? (_jsx(Row, { className: "pl-[1.375rem]", children: _jsxs(Button, { size: "sm", variant: "link", className: "h-auto p-0 text-xs", onClick: () => onJumpToField(fieldName), children: ["Go to ", fieldDef ? fieldLabel(fieldDef) : fieldName] }) })) : null] }));
32
+ return (_jsxs(Stack, { gap: "1", className: cn('rounded-md border px-2.5 py-2', isError ? 'border-destructive/30 bg-destructive/5' : 'border-warning/30 bg-warning/5'), children: [_jsxs(Row, { gap: "2", align: "start", children: [_jsx(Icon, { className: cn('mt-0.5 size-3.5 shrink-0', isError ? 'text-destructive' : 'text-warning'), "aria-hidden": true }), _jsxs(Stack, { gap: "1", className: "min-w-0", children: [_jsx(Text, { size: "xs", weight: "semibold", title: issue.code, children: cmsIssueLabel(issue.code) }), _jsx(Text, { size: "xs", tone: "muted", children: issue.message })] })] }), fieldName ? (_jsx(Row, { className: "pl-[1.375rem]", children: _jsx(Button, { size: "sm", variant: "link", className: "h-auto p-0 text-xs", onClick: () => onJumpToField(fieldName), children: translate('cms.issues.goToField', { field: fieldDef ? fieldLabel(fieldDef) : fieldName }) }) })) : null] }));
32
33
  }
33
34
  //# sourceMappingURL=issues-pane.js.map
@@ -1 +1 @@
1
- {"version":3,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J,EACL,SAAS,CAAC,CAAC,CAAC,CACX,KAAC,GAAG,IAAC,SAAS,EAAC,eAAe,YAC5B,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,MAAM,EACd,SAAS,EAAC,oBAAoB,EAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,uBAEhC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,IAC3C,GACL,CACP,CAAC,CAAC,CAAC,IAAI,IACF,CACT,CAAA;AACH,CAAC","sourcesContent":["import { CircleAlert, CircleCheck, TriangleAlert } from 'lucide-react'\nimport type { CmsValidationIssue, CollectionDef } from '@elytracms/core/cms-core'\nimport { Button, Row, Stack, Text } from '@elytracms/studio/ui'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { cmsIssueLabel } from '@elytracms/studio/lib/persona/labels'\nimport { fieldLabel } from './cms-store'\n\n/**\n * EC-283 — the document-scoped validation surface.\n *\n * Lists every {@link CmsValidationIssue} for the open draft in the right\n * `InspectorSidebar` (the document-scoped equivalent of the amputated builder's\n * validation sidebar, EC-069). Field-level issues stay inline on the field too;\n * here they additionally list with a jump-to-field action. Document-level issues\n * that carry no `meta.field` (e.g. the EC-260 nesting-depth warning) have no\n * other home — this is theirs.\n *\n * Persona boundary (EC-192): rows show the plain-language `cmsIssueLabel`; the raw\n * `code` rides along in `title=` for engineers, never as visible copy.\n */\nexport function IssuesPane({\n issues,\n collection,\n onJumpToField,\n}: {\n issues: readonly CmsValidationIssue[]\n collection: CollectionDef\n onJumpToField: (field: string) => void\n}) {\n if (issues.length === 0) {\n return (\n <Stack gap=\"2\" align=\"center\" className=\"px-4 py-10 text-center\">\n <CircleCheck className=\"size-5 text-success\" aria-hidden />\n <Text size=\"sm\" weight=\"medium\">\n No issues\n </Text>\n <Text size=\"xs\" tone=\"muted\">\n This document satisfies the collection schema.\n </Text>\n </Stack>\n )\n }\n\n return (\n <Stack gap=\"1\" className=\"p-2\">\n {issues.map((issue, i) => (\n <IssueRow\n key={`${issue.code}:${issue.path.join('/')}:${i}`}\n issue={issue}\n collection={collection}\n onJumpToField={onJumpToField}\n />\n ))}\n </Stack>\n )\n}\n\nfunction IssueRow({\n issue,\n collection,\n onJumpToField,\n}: {\n issue: CmsValidationIssue\n collection: CollectionDef\n onJumpToField: (field: string) => void\n}) {\n const isError = issue.severity === 'error'\n const fieldName = typeof issue.meta?.field === 'string' ? issue.meta.field : undefined\n const fieldDef = fieldName ? collection.fields.find((f) => f.name === fieldName) : undefined\n const Icon = isError ? CircleAlert : TriangleAlert\n\n return (\n <Stack\n gap=\"1\"\n className={cn(\n 'rounded-md border px-2.5 py-2',\n isError ? 'border-destructive/30 bg-destructive/5' : 'border-warning/30 bg-warning/5',\n )}\n >\n <Row gap=\"2\" align=\"start\">\n <Icon\n className={cn('mt-0.5 size-3.5 shrink-0', isError ? 'text-destructive' : 'text-warning')}\n aria-hidden\n />\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" weight=\"semibold\" title={issue.code}>\n {cmsIssueLabel(issue.code)}\n </Text>\n <Text size=\"xs\" tone=\"muted\">\n {issue.message}\n </Text>\n </Stack>\n </Row>\n {fieldName ? (\n <Row className=\"pl-[1.375rem]\">\n <Button\n size=\"sm\"\n variant=\"link\"\n className=\"h-auto p-0 text-xs\"\n onClick={() => onJumpToField(fieldName)}\n >\n Go to {fieldDef ? fieldLabel(fieldDef) : fieldName}\n </Button>\n </Row>\n ) : null}\n </Stack>\n )\n}\n"]}
1
+ {"version":3,"file":"issues-pane.js","sourceRoot":"","sources":["../../../src/components/cms/issues-pane.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEtE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAA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O,EAAC,MAAM,EACd,SAAS,EAAC,oBAAoB,EAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,YAEtC,SAAS,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,GACnF,GACL,CACP,CAAC,CAAC,CAAC,IAAI,IACF,CACT,CAAA;AACH,CAAC","sourcesContent":["import { CircleAlert, CircleCheck, TriangleAlert } from 'lucide-react'\nimport type { CmsValidationIssue, CollectionDef } from '@elytracms/core/cms-core'\nimport { Button, Row, Stack, Text } from '@elytracms/studio/ui'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { cmsIssueLabel } from '@elytracms/studio/lib/persona/labels'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { fieldLabel } from './cms-store'\n\n/**\n * EC-283 — the document-scoped validation surface.\n *\n * Lists every {@link CmsValidationIssue} for the open draft in the right\n * `InspectorSidebar` (the document-scoped equivalent of the amputated builder's\n * validation sidebar, EC-069). Field-level issues stay inline on the field too;\n * here they additionally list with a jump-to-field action. Document-level issues\n * that carry no `meta.field` (e.g. the EC-260 nesting-depth warning) have no\n * other home — this is theirs.\n *\n * Persona boundary (EC-192): rows show the plain-language `cmsIssueLabel`; the raw\n * `code` rides along in `title=` for engineers, never as visible copy.\n */\nexport function IssuesPane({\n issues,\n collection,\n onJumpToField,\n}: {\n issues: readonly CmsValidationIssue[]\n collection: CollectionDef\n onJumpToField: (field: string) => void\n}) {\n if (issues.length === 0) {\n return (\n <Stack gap=\"2\" align=\"center\" className=\"px-4 py-10 text-center\">\n <CircleCheck className=\"size-5 text-success\" aria-hidden />\n <Text size=\"sm\" weight=\"medium\">\n {translate('cms.issues.none')}\n </Text>\n <Text size=\"xs\" tone=\"muted\">\n {translate('cms.issues.satisfied')}\n </Text>\n </Stack>\n )\n }\n\n return (\n <Stack gap=\"1\" className=\"p-2\">\n {issues.map((issue, i) => (\n <IssueRow\n key={`${issue.code}:${issue.path.join('/')}:${i}`}\n issue={issue}\n collection={collection}\n onJumpToField={onJumpToField}\n />\n ))}\n </Stack>\n )\n}\n\nfunction IssueRow({\n issue,\n collection,\n onJumpToField,\n}: {\n issue: CmsValidationIssue\n collection: CollectionDef\n onJumpToField: (field: string) => void\n}) {\n const isError = issue.severity === 'error'\n const fieldName = typeof issue.meta?.field === 'string' ? issue.meta.field : undefined\n const fieldDef = fieldName ? collection.fields.find((f) => f.name === fieldName) : undefined\n const Icon = isError ? CircleAlert : TriangleAlert\n\n return (\n <Stack\n gap=\"1\"\n className={cn(\n 'rounded-md border px-2.5 py-2',\n isError ? 'border-destructive/30 bg-destructive/5' : 'border-warning/30 bg-warning/5',\n )}\n >\n <Row gap=\"2\" align=\"start\">\n <Icon\n className={cn('mt-0.5 size-3.5 shrink-0', isError ? 'text-destructive' : 'text-warning')}\n aria-hidden\n />\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" weight=\"semibold\" title={issue.code}>\n {cmsIssueLabel(issue.code)}\n </Text>\n <Text size=\"xs\" tone=\"muted\">\n {issue.message}\n </Text>\n </Stack>\n </Row>\n {fieldName ? (\n <Row className=\"pl-[1.375rem]\">\n <Button\n size=\"sm\"\n variant=\"link\"\n className=\"h-auto p-0 text-xs\"\n onClick={() => onJumpToField(fieldName)}\n >\n {translate('cms.issues.goToField', { field: fieldDef ? fieldLabel(fieldDef) : fieldName })}\n </Button>\n </Row>\n ) : null}\n </Stack>\n )\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { collectionDefSchema } from '@elytracms/core/cms-core';
2
+ import { msgLabel } from '@elytracms/studio/lib/i18n';
2
3
  /**
3
4
  * The built-in **redirects** field lens (EC-303). Redirects are a separate
4
5
  * editorial rail — NOT a `cmsDocuments` collection — so this `CollectionDef`
@@ -12,30 +13,34 @@ export const redirectsCollectionDef = collectionDefSchema.parse({
12
13
  // Redirects aren't a CMS `kind`; 'document' just satisfies the lens schema.
13
14
  kind: 'document',
14
15
  titleField: 'from',
15
- form: { label: 'Redirects', labelSingular: 'redirect' },
16
+ // EC-241: the built-in rail's labels resolve through the message catalog (msgLabel),
17
+ // so a consumer's translation catalog localizes them — no per-rail EC-311 override
18
+ // needed just to translate. EC-311 field overrides still win for genuine
19
+ // customization (renaming, readOnly, control, validation).
20
+ form: { label: msgLabel('redirects.rail.label'), labelSingular: msgLabel('redirects.rail.labelSingular') },
16
21
  fields: [
17
22
  {
18
23
  name: 'from',
19
24
  type: 'text',
20
25
  filterable: true,
21
- form: { label: 'From', help: 'The source path to forward, e.g. /old-page.' },
26
+ form: { label: msgLabel('redirects.field.from.label'), help: 'The source path to forward, e.g. /old-page.' },
22
27
  },
23
28
  {
24
29
  name: 'to',
25
30
  type: 'text',
26
31
  filterable: true,
27
- form: { label: 'To', help: 'The destination path or URL, e.g. /new-page.' },
32
+ form: { label: msgLabel('redirects.field.to.label'), help: 'The destination path or URL, e.g. /new-page.' },
28
33
  },
29
34
  {
30
35
  name: 'permanent',
31
36
  type: 'boolean',
32
- form: { label: 'Permanent (301)', help: 'On → 301 permanent; off → 302 temporary.' },
37
+ form: { label: msgLabel('redirects.field.permanent.label'), help: 'On → 301 permanent; off → 302 temporary.' },
33
38
  },
34
39
  {
35
40
  name: 'enabled',
36
41
  type: 'boolean',
37
42
  filterable: true,
38
- form: { label: 'Enabled', help: 'Only enabled redirects are served on the live site.' },
43
+ form: { label: msgLabel('redirects.field.enabled.label'), help: 'Only enabled redirects are served on the live site.' },
39
44
  },
40
45
  ],
41
46
  });
@@ -1 +1 @@
1
- {"version":3,"file":"redirects-schema.js","sourceRoot":"","sources":["../../../src/components/redirects/redirects-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAG9D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB,mBAAmB,CAAC,KAAK,CAAC;IAC7E,EAAE,EAAE,UAAU;IACd,4EAA4E;IAC5E,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE;IACvD,MAAM,EAAE;QACN;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,6CAA6C,EAAE;SAC7E;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,8CAA8C,EAAE;SAC5E;QACD;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,0CAA0C,EAAE;SACrF;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,qDAAqD,EAAE;SACxF;KACF;CACF,CAAC,CAAA","sourcesContent":["import { collectionDefSchema } from '@elytracms/core/cms-core'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\n\n/**\n * The built-in **redirects** field lens (EC-303). Redirects are a separate\n * editorial rail — NOT a `cmsDocuments` collection — so this `CollectionDef`\n * exists only to drive the portable list/edit surfaces over the redirects\n * {@link CollectionViewSource}. The rail's semantics (content-gated, no\n * publish/versions/locales, create + remove) come from the source's\n * capabilities, never the schema `kind`. The title identity is the `from` path.\n */\nexport const redirectsCollectionDef: CollectionDef = collectionDefSchema.parse({\n id: 'redirect',\n // Redirects aren't a CMS `kind`; 'document' just satisfies the lens schema.\n kind: 'document',\n titleField: 'from',\n form: { label: 'Redirects', labelSingular: 'redirect' },\n fields: [\n {\n name: 'from',\n type: 'text',\n filterable: true,\n form: { label: 'From', help: 'The source path to forward, e.g. /old-page.' },\n },\n {\n name: 'to',\n type: 'text',\n filterable: true,\n form: { label: 'To', help: 'The destination path or URL, e.g. /new-page.' },\n },\n {\n name: 'permanent',\n type: 'boolean',\n form: { label: 'Permanent (301)', help: 'On → 301 permanent; off → 302 temporary.' },\n },\n {\n name: 'enabled',\n type: 'boolean',\n filterable: true,\n form: { label: 'Enabled', help: 'Only enabled redirects are served on the live site.' },\n },\n ],\n})\n"]}
1
+ {"version":3,"file":"redirects-schema.js","sourceRoot":"","sources":["../../../src/components/redirects/redirects-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB,mBAAmB,CAAC,KAAK,CAAC;IAC7E,EAAE,EAAE,UAAU;IACd,4EAA4E;IAC5E,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,MAAM;IAClB,qFAAqF;IACrF,mFAAmF;IACnF,yEAAyE;IACzE,2DAA2D;IAC3D,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,8BAA8B,CAAC,EAAE;IAC1G,MAAM,EAAE;QACN;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,4BAA4B,CAAC,EAAE,IAAI,EAAE,6CAA6C,EAAE;SAC7G;QACD;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EAAE,IAAI,EAAE,8CAA8C,EAAE;SAC5G;QACD;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,iCAAiC,CAAC,EAAE,IAAI,EAAE,0CAA0C,EAAE;SAC/G;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,+BAA+B,CAAC,EAAE,IAAI,EAAE,qDAAqD,EAAE;SACxH;KACF;CACF,CAAC,CAAA","sourcesContent":["import { collectionDefSchema } from '@elytracms/core/cms-core'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\nimport { msgLabel } from '@elytracms/studio/lib/i18n'\n\n/**\n * The built-in **redirects** field lens (EC-303). Redirects are a separate\n * editorial rail — NOT a `cmsDocuments` collection — so this `CollectionDef`\n * exists only to drive the portable list/edit surfaces over the redirects\n * {@link CollectionViewSource}. The rail's semantics (content-gated, no\n * publish/versions/locales, create + remove) come from the source's\n * capabilities, never the schema `kind`. The title identity is the `from` path.\n */\nexport const redirectsCollectionDef: CollectionDef = collectionDefSchema.parse({\n id: 'redirect',\n // Redirects aren't a CMS `kind`; 'document' just satisfies the lens schema.\n kind: 'document',\n titleField: 'from',\n // EC-241: the built-in rail's labels resolve through the message catalog (msgLabel),\n // so a consumer's translation catalog localizes them — no per-rail EC-311 override\n // needed just to translate. EC-311 field overrides still win for genuine\n // customization (renaming, readOnly, control, validation).\n form: { label: msgLabel('redirects.rail.label'), labelSingular: msgLabel('redirects.rail.labelSingular') },\n fields: [\n {\n name: 'from',\n type: 'text',\n filterable: true,\n form: { label: msgLabel('redirects.field.from.label'), help: 'The source path to forward, e.g. /old-page.' },\n },\n {\n name: 'to',\n type: 'text',\n filterable: true,\n form: { label: msgLabel('redirects.field.to.label'), help: 'The destination path or URL, e.g. /new-page.' },\n },\n {\n name: 'permanent',\n type: 'boolean',\n form: { label: msgLabel('redirects.field.permanent.label'), help: 'On → 301 permanent; off → 302 temporary.' },\n },\n {\n name: 'enabled',\n type: 'boolean',\n filterable: true,\n form: { label: msgLabel('redirects.field.enabled.label'), help: 'Only enabled redirects are served on the live site.' },\n },\n ],\n})\n"]}
@@ -1,5 +1,6 @@
1
1
  import { collectionDefSchema } from '@elytracms/core/cms-core';
2
2
  import { roleOptions } from '@elytracms/core/persistence';
3
+ import { msgLabel } from '@elytracms/studio/lib/i18n';
3
4
  /**
4
5
  * The built-in **users** field lens (EC-240, AD-19). Users are a separate rail —
5
6
  * NOT a `cmsDocuments` collection (`collectionKindSchema` is `document|asset`) —
@@ -22,16 +23,18 @@ export const usersCollectionDef = collectionDefSchema.parse({
22
23
  // source's capabilities (adminOnly, no publish/versions/create) carry the semantics.
23
24
  kind: 'document',
24
25
  titleField: 'name',
25
- form: { label: 'Users', labelSingular: 'user' },
26
+ // EC-241: built-in rail labels resolve through the message catalog (msgLabel) — a
27
+ // consumer's translation catalog localizes them without a per-rail override.
28
+ form: { label: msgLabel('users.rail.label'), labelSingular: msgLabel('users.rail.labelSingular') },
26
29
  fields: [
27
- { name: 'name', type: 'text', form: { label: 'Name', readOnly: true }, filterable: true },
28
- { name: 'email', type: 'text', form: { label: 'Email', readOnly: true }, filterable: true },
30
+ { name: 'name', type: 'text', form: { label: msgLabel('users.field.name.label'), readOnly: true }, filterable: true },
31
+ { name: 'email', type: 'text', form: { label: msgLabel('users.field.email.label'), readOnly: true }, filterable: true },
29
32
  {
30
33
  name: 'role',
31
34
  type: 'select',
32
35
  options: [...USER_ROLE_OPTIONS],
33
36
  filterable: true,
34
- form: { label: 'Role' },
37
+ form: { label: msgLabel('users.field.role.label') },
35
38
  },
36
39
  ],
37
40
  });
@@ -1 +1 @@
1
- {"version":3,"file":"users-schema.js","sourceRoot":"","sources":["../../../src/components/users/users-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD;;;;;;;;;;;;GAYG;AACH,kFAAkF;AAClF,oFAAoF;AACpF,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,EAAE,CAAA;AAE9C,MAAM,CAAC,MAAM,kBAAkB,GAAkB,mBAAmB,CAAC,KAAK,CAAC;IACzE,EAAE,EAAE,MAAM;IACV,4EAA4E;IAC5E,qFAAqF;IACrF,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE;IAC/C,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;QACzF,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;QAC3F;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC;YAC/B,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;SACxB;KACF;CACF,CAAC,CAAA","sourcesContent":["import { collectionDefSchema } from '@elytracms/core/cms-core'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\nimport { roleOptions } from '@elytracms/core/persistence'\n\n/**\n * The built-in **users** field lens (EC-240, AD-19). Users are a separate rail —\n * NOT a `cmsDocuments` collection (`collectionKindSchema` is `document|asset`) —\n * so this `CollectionDef` exists only to drive the portable list/edit surfaces\n * over the users {@link CollectionViewSource}. The rail's *user-ness* comes from\n * the source's capabilities (admin-only, no publish/versions/create), never the\n * schema `kind`.\n *\n * Identity fields (`name`, `email`) are **auth-owned** and read-only here — an\n * admin manages a member's *role* (and, later, project-declared custom fields\n * over the `meta` bag, mirroring assets); the person edits their own name/email\n * via account settings. A v1 default; a project may extend the field set later.\n */\n// Derived from the ONE role policy (EC-240c) — no hardcoded duplicate of the role\n// set. Reflects the shipped default today; a project's custom policy flows through.\nexport const USER_ROLE_OPTIONS = roleOptions()\n\nexport const usersCollectionDef: CollectionDef = collectionDefSchema.parse({\n id: 'user',\n // Users aren't a CMS `kind`; 'document' just satisfies the lens schema. The\n // source's capabilities (adminOnly, no publish/versions/create) carry the semantics.\n kind: 'document',\n titleField: 'name',\n form: { label: 'Users', labelSingular: 'user' },\n fields: [\n { name: 'name', type: 'text', form: { label: 'Name', readOnly: true }, filterable: true },\n { name: 'email', type: 'text', form: { label: 'Email', readOnly: true }, filterable: true },\n {\n name: 'role',\n type: 'select',\n options: [...USER_ROLE_OPTIONS],\n filterable: true,\n form: { label: 'Role' },\n },\n ],\n})\n"]}
1
+ {"version":3,"file":"users-schema.js","sourceRoot":"","sources":["../../../src/components/users/users-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH,kFAAkF;AAClF,oFAAoF;AACpF,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,EAAE,CAAA;AAE9C,MAAM,CAAC,MAAM,kBAAkB,GAAkB,mBAAmB,CAAC,KAAK,CAAC;IACzE,EAAE,EAAE,MAAM;IACV,4EAA4E;IAC5E,qFAAqF;IACrF,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,MAAM;IAClB,kFAAkF;IAClF,6EAA6E;IAC7E,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EAAE;IAClG,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,wBAAwB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;QACrH,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;QACvH;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC;YAC/B,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,wBAAwB,CAAC,EAAE;SACpD;KACF;CACF,CAAC,CAAA","sourcesContent":["import { collectionDefSchema } from '@elytracms/core/cms-core'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\nimport { roleOptions } from '@elytracms/core/persistence'\nimport { msgLabel } from '@elytracms/studio/lib/i18n'\n\n/**\n * The built-in **users** field lens (EC-240, AD-19). Users are a separate rail —\n * NOT a `cmsDocuments` collection (`collectionKindSchema` is `document|asset`) —\n * so this `CollectionDef` exists only to drive the portable list/edit surfaces\n * over the users {@link CollectionViewSource}. The rail's *user-ness* comes from\n * the source's capabilities (admin-only, no publish/versions/create), never the\n * schema `kind`.\n *\n * Identity fields (`name`, `email`) are **auth-owned** and read-only here — an\n * admin manages a member's *role* (and, later, project-declared custom fields\n * over the `meta` bag, mirroring assets); the person edits their own name/email\n * via account settings. A v1 default; a project may extend the field set later.\n */\n// Derived from the ONE role policy (EC-240c) — no hardcoded duplicate of the role\n// set. Reflects the shipped default today; a project's custom policy flows through.\nexport const USER_ROLE_OPTIONS = roleOptions()\n\nexport const usersCollectionDef: CollectionDef = collectionDefSchema.parse({\n id: 'user',\n // Users aren't a CMS `kind`; 'document' just satisfies the lens schema. The\n // source's capabilities (adminOnly, no publish/versions/create) carry the semantics.\n kind: 'document',\n titleField: 'name',\n // EC-241: built-in rail labels resolve through the message catalog (msgLabel) — a\n // consumer's translation catalog localizes them without a per-rail override.\n form: { label: msgLabel('users.rail.label'), labelSingular: msgLabel('users.rail.labelSingular') },\n fields: [\n { name: 'name', type: 'text', form: { label: msgLabel('users.field.name.label'), readOnly: true }, filterable: true },\n { name: 'email', type: 'text', form: { label: msgLabel('users.field.email.label'), readOnly: true }, filterable: true },\n {\n name: 'role',\n type: 'select',\n options: [...USER_ROLE_OPTIONS],\n filterable: true,\n form: { label: msgLabel('users.field.role.label') },\n },\n ],\n})\n"]}
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { documentDefaultLocale, resolveField, resolveLabel, titleFieldOf } from '@elytracms/core/cms-core';
2
+ import { documentDefaultLocale, resolveField, titleFieldOf } from '@elytracms/core/cms-core';
3
+ import { localizedLabel } from '@elytracms/studio/lib/i18n';
3
4
  import { FILTER_OPERATORS, compareListEntries, filterScalarOf, filterableFields, matchesCondition, validateWhere, } from '@elytracms/core/content';
4
5
  /**
5
6
  * The pure table-view model for the CMS collection table (EC-169).
@@ -67,7 +68,7 @@ export const STATE_OPTION = {
67
68
  export function filterableFieldOptions(collection) {
68
69
  const schemaOptions = filterableFields(collection).map((field) => ({
69
70
  field: field.name,
70
- label: resolveLabel(field.form?.label) ?? field.name,
71
+ label: localizedLabel(field.form?.label, field.name),
71
72
  def: field,
72
73
  }));
73
74
  return [...schemaOptions, STATE_OPTION];
@@ -1 +1 @@
1
- {"version":3,"file":"view-model.js","sourceRoot":"","sources":["../../../src/lib/cms-views/view-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,qBAAqB,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EAAE,GAAG,IAAI,GAAG,KAAK,CAAA;IACvB,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACjE,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;IACjC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACvB,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;IAC5B,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,SAAS;IACvB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;SAC/C,QAAQ,CAAC,EAAE,CAAC;SACZ,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACnB,OAAO,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,MAAM,EAAE,CAAA;AACpD,CAAC","sourcesContent":["import { z } from 'zod'\nimport { documentDefaultLocale, resolveField, resolveLabel, titleFieldOf } from '@elytracms/core/cms-core'\nimport type { CmsDocument, CollectionDef, FieldDef, LocaleConfig } from '@elytracms/core/cms-core'\nimport {\n FILTER_OPERATORS,\n compareListEntries,\n filterScalarOf,\n filterableFields,\n matchesCondition,\n validateWhere,\n} from '@elytracms/core/content'\nimport type {\n FilterCondition,\n FilterOperator,\n FilterScalar,\n NormalizedCondition,\n WhereInput,\n} from '@elytracms/core/content'\n\n/**\n * The pure table-view model for the CMS collection table (EC-169).\n *\n * A view bundles three things: filters in the closed AD-3 vocabulary\n * (`eq`/`in`/`lt`/`lte`/`gt`/`gte`, AND-only — exactly `@elytracms/core/content`'s\n * query model, evaluated with the same matching/ordering primitives), a sort\n * (field + direction), and the visible/ordered columns. Everything here is\n * plain data + functions so filtering, dirtiness, and column edits are\n * testable without a DOM.\n *\n * Filters are offered ONLY on fields the schema declares `filterable: true`\n * (EC-143), plus one built-in option: the document's publication state. The\n * state is document metadata, not a schema field — it powers the\n * \"show me drafts → bulk publish\" working set and still speaks only the\n * closed vocabulary (`eq`/`in`).\n */\n\n// --- Schemas (single source of truth — persisted view records reuse these) ----\n\nexport const filterScalarSchema = z.union([z.string(), z.number(), z.boolean()])\n\nexport const filterClauseSchema = z.object({\n /** A schema field name, or {@link STATE_FIELD} for the publication state. */\n field: z.string().min(1),\n op: z.enum(FILTER_OPERATORS),\n /** `in` carries an array of scalars; every other operator one scalar. */\n value: z.union([filterScalarSchema, z.array(filterScalarSchema)]),\n})\nexport type FilterClause = z.infer<typeof filterClauseSchema>\n\nexport const viewSortSchema = z.object({\n field: z.string().min(1),\n dir: z.enum(['asc', 'desc']),\n})\nexport type ViewSort = z.infer<typeof viewSortSchema>\n\nexport const tableViewStateSchema = z.object({\n /** AND-only list of conditions (no OR, no nesting — vision AD-3). */\n filters: z.array(filterClauseSchema),\n sort: viewSortSchema.nullable(),\n /**\n * The canonical column order (field names) — EVERY column, visible or not\n * (EC-213). Order is independent of visibility: hiding then re-showing a\n * column keeps its place. Schema fields absent here resolve in at the end\n * (see {@link resolveColumns}).\n */\n columns: z.array(z.string().min(1)),\n /**\n * The subset of {@link TableViewState.columns} that is hidden. Defaults to\n * `[]` so views persisted before EC-213 (no `hidden` key) load unchanged.\n */\n hidden: z.array(z.string().min(1)).default([]),\n})\nexport type TableViewState = z.infer<typeof tableViewStateSchema>\n\n// --- The built-in publication-state filter column ------------------------------\n\n/**\n * Sentinel field key for the publication state. `$`-prefixed so it can never\n * collide with a schema field name (`fieldDefSchema` names are identifiers).\n */\nexport const STATE_FIELD = '$state'\n\nconst STATE_VALUES = ['draft', 'published'] as const\n\n/** One field the filter builder may offer. */\nexport interface FilterableFieldOption {\n /** Clause field key: a schema field name, or {@link STATE_FIELD}. */\n field: string\n label: string\n /** The schema field def, or `null` for the built-in publication state. */\n def: FieldDef | null\n}\n\nexport const STATE_OPTION: FilterableFieldOption = {\n field: STATE_FIELD,\n label: 'State',\n def: null,\n}\n\n/**\n * The closed list of fields the filter builder offers: exactly the schema's\n * `filterable: true` fields (EC-143) plus the publication state. Nothing else\n * is ever offered — the UI builds queries, it does not invent a language.\n */\nexport function filterableFieldOptions(collection: CollectionDef): FilterableFieldOption[] {\n const schemaOptions = filterableFields(collection).map((field) => ({\n field: field.name,\n label: resolveLabel(field.form?.label) ?? field.name,\n def: field,\n }))\n return [...schemaOptions, STATE_OPTION]\n}\n\nexport function filterOptionFor(\n collection: CollectionDef,\n field: string,\n): FilterableFieldOption | undefined {\n return filterableFieldOptions(collection).find((option) => option.field === field)\n}\n\n// --- Operators per field type ---------------------------------------------------\n\n/** Display order + labels for the closed vocabulary. */\nexport const OPERATOR_LABELS: Record<FilterOperator, string> = {\n eq: 'equals',\n in: 'is one of',\n lt: 'less than',\n lte: 'at most',\n gt: 'greater than',\n gte: 'at least',\n}\n\nconst ORDERED_OPERATORS: readonly FilterOperator[] = ['eq', 'in', 'lt', 'lte', 'gt', 'gte']\n\n/**\n * The vocabulary subset that makes sense for a field's type. Always a subset\n * of the closed `FILTER_OPERATORS` — never an extension.\n */\nexport function operatorsFor(option: FilterableFieldOption): FilterOperator[] {\n if (option.def === null) return ['eq', 'in'] // publication state\n switch (option.def.type) {\n case 'boolean':\n return ['eq']\n case 'select':\n case 'relation':\n case 'asset':\n return ['eq', 'in']\n default:\n return [...ORDERED_OPERATORS]\n }\n}\n\n/** A sensible starting clause when a field is added to the builder. */\nexport function defaultClause(option: FilterableFieldOption): FilterClause {\n if (option.def === null) return { field: STATE_FIELD, op: 'eq', value: 'published' }\n switch (option.def.type) {\n case 'boolean':\n return { field: option.field, op: 'eq', value: true }\n case 'number':\n return { field: option.field, op: 'eq', value: 0 }\n case 'select':\n return { field: option.field, op: 'eq', value: option.def.options[0]?.value ?? '' }\n default:\n return { field: option.field, op: 'eq', value: '' }\n }\n}\n\n// --- Text ⇄ scalar coercion (the value inputs of the builder) -------------------\n\nconst DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/\n\n/** Coerce one text input into the scalar a clause compares against. */\nexport function scalarFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar {\n const type = option?.def?.type\n if (type === 'number') {\n const trimmed = raw.trim()\n if (trimmed === '') return raw // an emptied input must not become eq 0\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? raw : parsed\n }\n if (type === 'boolean') return raw === 'true'\n // Stored dates are full ISO strings; a date-input value compares correctly\n // once expanded to midnight UTC (ISO strings order by code units).\n if (type === 'date' && DATE_ONLY.test(raw)) return `${raw}T00:00:00.000Z`\n return raw\n}\n\n/** Parse a comma-separated list for the `in` operator. */\nexport function scalarListFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar[] {\n return raw\n .split(',')\n .map((part) => part.trim())\n .filter((part) => part !== '')\n .map((part) => scalarFromText(option, part))\n}\n\nexport function scalarListToText(value: FilterScalar | FilterScalar[]): string {\n const list = Array.isArray(value) ? value : [value]\n return list.map(String).join(', ')\n}\n\n// --- Clause validation -----------------------------------------------------------\n\n/** A structured problem with one clause (by index in the filter list). */\nexport interface ClauseIssue {\n index: number\n message: string\n}\n\n/**\n * Validate clauses against the collection schema. Schema-field clauses run\n * through the canonical `validateWhere` (EC-143: `filterable` enforcement +\n * operator/value shape); state clauses check the `eq`/`in` subset and the\n * draft/published value set. Invalid clauses (e.g. a persisted view whose\n * field is no longer filterable) are reported — never silently applied.\n */\nexport function validateClauses(\n collection: CollectionDef,\n clauses: readonly FilterClause[],\n): ClauseIssue[] {\n const issues: ClauseIssue[] = []\n clauses.forEach((clause, index) => {\n if (clause.field === STATE_FIELD) {\n if (clause.op !== 'eq' && clause.op !== 'in') {\n issues.push({ index, message: 'State filters support only \"eq\" and \"in\".' })\n return\n }\n const values = Array.isArray(clause.value) ? clause.value : [clause.value]\n if (!values.every((value) => (STATE_VALUES as readonly unknown[]).includes(value))) {\n issues.push({ index, message: 'State must be \"draft\" or \"published\".' })\n }\n return\n }\n const where: WhereInput = {\n [clause.field]: { [clause.op]: clause.value } as FilterCondition,\n }\n const errors = validateWhere(collection, where)\n if (errors.length > 0) issues.push({ index, message: errors[0]!.message })\n })\n return issues\n}\n\n// --- Matching & sorting (delegates to @elytracms/core/content's primitives) -------------\n\n/**\n * Published-ness source for the `$state` pseudo-field (EC-224): the version\n * POINTER, supplied by the caller as `cms.isPublished`. Defaults to \"nothing\n * published\" — a bare row carries no publish signal now that the flat `state`\n * field is gone, so the table (which knows the pointer) passes the real\n * predicate; fixtures/tests that don't surface `$state` get the safe default.\n */\nexport type IsPublished = (doc: CmsDocument) => boolean\nconst defaultIsPublished: IsPublished = () => false\n\n/** The scalar a document exposes for a clause/sort field, locale-resolved. */\nfunction scalarOf(\n collection: CollectionDef,\n doc: CmsDocument,\n field: string,\n localeConfig: LocaleConfig,\n isPublished: IsPublished,\n): FilterScalar | null {\n if (field === STATE_FIELD) return isPublished(doc) ? 'published' : 'draft'\n if (!collection.fields.some((f) => f.name === field)) return null\n const locale = documentDefaultLocale(doc, localeConfig)\n return filterScalarOf(resolveField(collection, doc, field, locale, localeConfig).value)\n}\n\n/** Does a document satisfy one clause? Same semantics as the content accessors. */\nexport function clauseMatches(\n collection: CollectionDef,\n doc: CmsDocument,\n localeConfig: LocaleConfig,\n clause: FilterClause,\n isPublished: IsPublished = defaultIsPublished,\n): boolean {\n const value = scalarOf(collection, doc, clause.field, localeConfig, isPublished)\n const condition = { [clause.op]: clause.value } as NormalizedCondition\n return matchesCondition(value, condition)\n}\n\n/**\n * Sort documents by one column in the canonical deterministic order\n * (`compareListEntries`: typed value order, id-ascending tiebreak). Unlike the\n * content accessors, the *table* may sort any rendered column — sorting is a\n * presentation concern here; the `filterable` flag governs filters.\n */\nexport function sortViewDocuments(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n sort: ViewSort | null,\n isPublished: IsPublished = defaultIsPublished,\n): CmsDocument[] {\n if (sort === null) return [...docs]\n const positions = new Map(\n docs.map((doc) => [doc.id, scalarOf(collection, doc, sort.field, localeConfig, isPublished)]),\n )\n return [...docs].sort((a, b) =>\n compareListEntries(\n { id: a.id, sortValue: positions.get(a.id) ?? null },\n { id: b.id, sortValue: positions.get(b.id) ?? null },\n sort.dir,\n ),\n )\n}\n\n/** The filtered + sorted documents of a view, plus any clause issues. */\nexport interface AppliedViewState {\n docs: CmsDocument[]\n /** Clauses that failed validation — reported AND excluded from matching. */\n issues: ClauseIssue[]\n}\n\n/**\n * Apply a view state to a document list: validate clauses, AND-match the valid\n * ones, sort. Invalid clauses never filter silently — they come back as\n * issues for the UI to surface.\n */\nexport function applyViewState(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n state: TableViewState,\n isPublished: IsPublished = defaultIsPublished,\n): AppliedViewState {\n const issues = validateClauses(collection, state.filters)\n const invalid = new Set(issues.map((issue) => issue.index))\n const active = state.filters.filter((_, index) => !invalid.has(index))\n const matched = docs.filter((doc) =>\n active.every((clause) => clauseMatches(collection, doc, localeConfig, clause, isPublished)),\n )\n return {\n docs: sortViewDocuments(collection, matched, localeConfig, state.sort, isPublished),\n issues,\n }\n}\n\n// --- View state construction, equality, columns ----------------------------------\n\n/** The id of the unnamed built-in \"All documents\" view. */\nexport const ALL_VIEW_ID = 'all'\n\n/** The default (unnamed) view: no filters, no sort, every field visible. */\n/**\n * Field types kept OFF the default table columns (EC-246b): the composite editing\n * surfaces — a blocks canvas, rich text, a structured object/repeater — read as\n * noise in a scalar list. `filterable` no longer forces (or governs) a column; the\n * default lens is \"all scalars\". These stay in the column picker one toggle away,\n * and any named view may list them in its `columns`; they're just off by default.\n */\nconst NON_DEFAULT_COLUMN_TYPES = new Set<FieldDef['type']>(['blocks', 'richText', 'object'])\n\n/** The collection's composite (non-scalar) field names — hidden in the default view. */\nfunction nonScalarColumns(collection: CollectionDef): string[] {\n return collection.fields.filter((f) => NON_DEFAULT_COLUMN_TYPES.has(f.type)).map((f) => f.name)\n}\n\nexport function defaultViewState(collection: CollectionDef): TableViewState {\n return {\n filters: [],\n sort: null,\n // Every field keeps a slot (order + picker), but the composite surfaces start\n // hidden so the default lens is the collection's scalars (EC-246b).\n columns: orderedColumnNames(collection),\n hidden: nonScalarColumns(collection),\n }\n}\n\n/**\n * A config-declared view (EC-246b) — the flat authoring shape a collection\n * declares in `cms/` config: `{ name, filters?, sort?, columns?, hidden? }`.\n * Filters/sort/columns sit at the top level (no nested `state` wrapper). The\n * studio validates + interprets these; `cms-core` stores them opaquely (it\n * can't reference the filter vocabulary without a layering cycle).\n */\nexport const configViewSchema = z.object({\n /** Optional stable id; defaults to a slug of `name`. */\n id: z.string().min(1).optional(),\n name: z.string().min(1),\n filters: z.array(filterClauseSchema).optional(),\n sort: viewSortSchema.nullable().optional(),\n /** Column order; when omitted, the view inherits the collection's default columns. */\n columns: z.array(z.string().min(1)).optional(),\n hidden: z.array(z.string().min(1)).optional(),\n})\nexport type ConfigView = z.infer<typeof configViewSchema>\n\n/** A resolved view: identity + the table state it restores (matches `SavedView`). */\nexport interface ResolvedView {\n id: string\n name: string\n state: TableViewState\n}\n\n/** Slug used to derive a config view's stable id from its name. */\nfunction configViewId(name: string, index: number): string {\n const slug = name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n return `config:${slug || index}`\n}\n\n/**\n * Resolve a collection's config-declared `views` into full {@link ResolvedView}s\n * (EC-246b). Each is validated with {@link configViewSchema}; malformed entries\n * and duplicate ids are dropped (defensive). Columns fall back to the collection\n * default when a view doesn't pin them, so a filter-only view still renders every\n * column. Config views are shared and change only in\n * code — the runtime never mutates them.\n */\nexport function configViewsFor(collection: CollectionDef): ResolvedView[] {\n const declared = collection.views\n if (!Array.isArray(declared)) return []\n const base = defaultViewState(collection)\n const seen = new Set<string>()\n const resolved: ResolvedView[] = []\n declared.forEach((raw, index) => {\n const parsed = configViewSchema.safeParse(raw)\n if (!parsed.success) return\n const view = parsed.data\n const id = view.id ?? configViewId(view.name, index)\n if (seen.has(id)) return\n seen.add(id)\n resolved.push({\n id,\n name: view.name,\n state: normalizeViewState({\n filters: view.filters ?? [],\n sort: view.sort ?? null,\n columns: view.columns && view.columns.length > 0 ? view.columns : base.columns,\n hidden: view.hidden ?? [],\n }),\n })\n })\n return resolved\n}\n\n/**\n * The default column order: the schema's title field first (it becomes the\n * default title/link column — EC-213 drops the separate primary-column\n * selector, treating the first visible column as the title), then the\n * remaining fields in schema order.\n */\nfunction orderedColumnNames(collection: CollectionDef): string[] {\n const names = collection.fields.map((field) => field.name)\n const title = titleFieldOf(collection)?.name\n if (title === undefined || !names.includes(title)) return names\n return [title, ...names.filter((name) => name !== title)]\n}\n\n/** Deep-cloned canonical form (stable key order via the Zod shape). */\nexport function normalizeViewState(state: TableViewState): TableViewState {\n return tableViewStateSchema.parse(state)\n}\n\n/** Structural equality on normalized states — drives the \"unsaved changes\" affordance. */\nexport function viewStatesEqual(a: TableViewState, b: TableViewState): boolean {\n return JSON.stringify(normalizeViewState(a)) === JSON.stringify(normalizeViewState(b))\n}\n\n/** One column of a view resolved against the current schema (EC-213). */\nexport interface ResolvedColumn {\n /** The schema field name. */\n field: string\n /** Whether the column renders (`false` ⇒ in {@link TableViewState.hidden}). */\n visible: boolean\n}\n\n/**\n * Resolve a view's columns against the live schema (EC-213): every schema\n * field exactly once, in the view's saved order, with any fields the view\n * predates appended (visible) and any fields no longer in the schema dropped.\n * This is the single source of truth for \"which columns, in what order, shown\n * or hidden\" — order is preserved across hide/show because visibility lives in\n * `hidden`, never in the order.\n */\nexport function resolveColumns(\n collection: CollectionDef,\n state: TableViewState,\n): ResolvedColumn[] {\n const schemaNames = collection.fields.map((field) => field.name)\n const schema = new Set(schemaNames)\n const hidden = new Set(state.hidden)\n // Keep the saved order, restricted to live fields and de-duplicated (a\n // corrupted persisted state must never render one field as two columns).\n const ordered: string[] = []\n const seen = new Set<string>()\n for (const name of state.columns) {\n if (schema.has(name) && !seen.has(name)) {\n ordered.push(name)\n seen.add(name)\n }\n }\n const appended = schemaNames.filter((name) => !seen.has(name))\n return [...ordered, ...appended].map((field) => ({ field, visible: !hidden.has(field) }))\n}\n\n/** The visible columns of a view, in render order (EC-213). */\nexport function visibleColumns(collection: CollectionDef, state: TableViewState): string[] {\n return resolveColumns(collection, state)\n .filter((column) => column.visible)\n .map((column) => column.field)\n}\n\n/**\n * The title/link column — the document IDENTITY column (EC-242): the schema title\n * field, shown as the leftmost linked cell whose content is `resolveDocumentTitle`\n * (a string `titleField` or a function pattern). Always present regardless of\n * column visibility — it is the document's identity, not a toggleable data column —\n * and excluded from the data columns so the title never shows twice. Falls back to\n * the first visible column, then the first field, then `id`, when no title field\n * is resolvable (e.g. a function title with no backing `title` field).\n */\nexport function primaryColumn(collection: CollectionDef, state: TableViewState): string {\n return (\n titleFieldOf(collection)?.name ??\n visibleColumns(collection, state)[0] ??\n collection.fields[0]?.name ??\n 'id'\n )\n}\n\n/**\n * Reconcile `columns` to the full resolved order so column edits operate on a\n * complete, stable order (drops removed fields, pins appended ones), and prune\n * `hidden` to fields the live schema still has (a column removed from the schema\n * must not leave dead `hidden` cruft that trips dirty-detection / persists).\n */\nfunction withResolvedOrder(collection: CollectionDef, state: TableViewState): TableViewState {\n const columns = resolveColumns(collection, state).map((column) => column.field)\n const live = new Set(columns)\n const hidden = state.hidden.filter((name) => live.has(name))\n return { ...state, columns, hidden }\n}\n\n/**\n * The canonical, schema-resolved form of a view state — full column order with\n * `hidden` pruned to live fields (EC-213). Two states that render identically\n * share one canonical form, so dirty-detection never trips on a mere column\n * reconciliation or a stale `hidden` entry (only a real filter/sort/visibility/\n * order change counts as \"unsaved\").\n */\nexport function canonicalViewState(\n collection: CollectionDef,\n state: TableViewState,\n): TableViewState {\n return normalizeViewState(withResolvedOrder(collection, state))\n}\n\n/**\n * Toggle a column's visibility — position is preserved (EC-213): visibility\n * lives in `hidden`, the order in `columns` is untouched. Columns the saved\n * order predates are pinned into `columns` first so their place is stable.\n */\nexport function toggleColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n): TableViewState {\n const base = withResolvedOrder(collection, state)\n const hidden = base.hidden.includes(field)\n ? base.hidden.filter((name) => name !== field)\n : [...base.hidden, field]\n return { ...base, hidden }\n}\n\n/** Move a column one position left (-1) or right (+1) in the full column order. */\nexport function moveColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n delta: -1 | 1,\n): TableViewState {\n const base = withResolvedOrder(collection, state)\n const from = base.columns.indexOf(field)\n const to = from + delta\n if (from < 0 || to < 0 || to >= base.columns.length) return state\n const columns = [...base.columns]\n columns.splice(from, 1)\n columns.splice(to, 0, field)\n return { ...base, columns }\n}\n\n/** A fresh id for a saved view (uniqueness, not determinism, is the point). */\nexport function newViewId(): string {\n const random = Math.floor(Math.random() * 36 ** 6)\n .toString(36)\n .padStart(6, '0')\n return `view-${Date.now().toString(36)}-${random}`\n}\n"]}
1
+ {"version":3,"file":"view-model.js","sourceRoot":"","sources":["../../../src/lib/cms-views/view-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAE3D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAA;AAShC;;;;;;;;;;;;;;;GAeG;AAEH,iFAAiF;AAEjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC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C,EAAE,KAAK,CAAC,CAAA;IAC5B,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,SAAS;IACvB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;SAC/C,QAAQ,CAAC,EAAE,CAAC;SACZ,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACnB,OAAO,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,MAAM,EAAE,CAAA;AACpD,CAAC","sourcesContent":["import { z } from 'zod'\nimport { documentDefaultLocale, resolveField, titleFieldOf } from '@elytracms/core/cms-core'\nimport { localizedLabel } from '@elytracms/studio/lib/i18n'\nimport type { CmsDocument, CollectionDef, FieldDef, LocaleConfig } from '@elytracms/core/cms-core'\nimport {\n FILTER_OPERATORS,\n compareListEntries,\n filterScalarOf,\n filterableFields,\n matchesCondition,\n validateWhere,\n} from '@elytracms/core/content'\nimport type {\n FilterCondition,\n FilterOperator,\n FilterScalar,\n NormalizedCondition,\n WhereInput,\n} from '@elytracms/core/content'\n\n/**\n * The pure table-view model for the CMS collection table (EC-169).\n *\n * A view bundles three things: filters in the closed AD-3 vocabulary\n * (`eq`/`in`/`lt`/`lte`/`gt`/`gte`, AND-only — exactly `@elytracms/core/content`'s\n * query model, evaluated with the same matching/ordering primitives), a sort\n * (field + direction), and the visible/ordered columns. Everything here is\n * plain data + functions so filtering, dirtiness, and column edits are\n * testable without a DOM.\n *\n * Filters are offered ONLY on fields the schema declares `filterable: true`\n * (EC-143), plus one built-in option: the document's publication state. The\n * state is document metadata, not a schema field — it powers the\n * \"show me drafts → bulk publish\" working set and still speaks only the\n * closed vocabulary (`eq`/`in`).\n */\n\n// --- Schemas (single source of truth — persisted view records reuse these) ----\n\nexport const filterScalarSchema = z.union([z.string(), z.number(), z.boolean()])\n\nexport const filterClauseSchema = z.object({\n /** A schema field name, or {@link STATE_FIELD} for the publication state. */\n field: z.string().min(1),\n op: z.enum(FILTER_OPERATORS),\n /** `in` carries an array of scalars; every other operator one scalar. */\n value: z.union([filterScalarSchema, z.array(filterScalarSchema)]),\n})\nexport type FilterClause = z.infer<typeof filterClauseSchema>\n\nexport const viewSortSchema = z.object({\n field: z.string().min(1),\n dir: z.enum(['asc', 'desc']),\n})\nexport type ViewSort = z.infer<typeof viewSortSchema>\n\nexport const tableViewStateSchema = z.object({\n /** AND-only list of conditions (no OR, no nesting — vision AD-3). */\n filters: z.array(filterClauseSchema),\n sort: viewSortSchema.nullable(),\n /**\n * The canonical column order (field names) — EVERY column, visible or not\n * (EC-213). Order is independent of visibility: hiding then re-showing a\n * column keeps its place. Schema fields absent here resolve in at the end\n * (see {@link resolveColumns}).\n */\n columns: z.array(z.string().min(1)),\n /**\n * The subset of {@link TableViewState.columns} that is hidden. Defaults to\n * `[]` so views persisted before EC-213 (no `hidden` key) load unchanged.\n */\n hidden: z.array(z.string().min(1)).default([]),\n})\nexport type TableViewState = z.infer<typeof tableViewStateSchema>\n\n// --- The built-in publication-state filter column ------------------------------\n\n/**\n * Sentinel field key for the publication state. `$`-prefixed so it can never\n * collide with a schema field name (`fieldDefSchema` names are identifiers).\n */\nexport const STATE_FIELD = '$state'\n\nconst STATE_VALUES = ['draft', 'published'] as const\n\n/** One field the filter builder may offer. */\nexport interface FilterableFieldOption {\n /** Clause field key: a schema field name, or {@link STATE_FIELD}. */\n field: string\n label: string\n /** The schema field def, or `null` for the built-in publication state. */\n def: FieldDef | null\n}\n\nexport const STATE_OPTION: FilterableFieldOption = {\n field: STATE_FIELD,\n label: 'State',\n def: null,\n}\n\n/**\n * The closed list of fields the filter builder offers: exactly the schema's\n * `filterable: true` fields (EC-143) plus the publication state. Nothing else\n * is ever offered — the UI builds queries, it does not invent a language.\n */\nexport function filterableFieldOptions(collection: CollectionDef): FilterableFieldOption[] {\n const schemaOptions = filterableFields(collection).map((field) => ({\n field: field.name,\n label: localizedLabel(field.form?.label, field.name),\n def: field,\n }))\n return [...schemaOptions, STATE_OPTION]\n}\n\nexport function filterOptionFor(\n collection: CollectionDef,\n field: string,\n): FilterableFieldOption | undefined {\n return filterableFieldOptions(collection).find((option) => option.field === field)\n}\n\n// --- Operators per field type ---------------------------------------------------\n\n/** Display order + labels for the closed vocabulary. */\nexport const OPERATOR_LABELS: Record<FilterOperator, string> = {\n eq: 'equals',\n in: 'is one of',\n lt: 'less than',\n lte: 'at most',\n gt: 'greater than',\n gte: 'at least',\n}\n\nconst ORDERED_OPERATORS: readonly FilterOperator[] = ['eq', 'in', 'lt', 'lte', 'gt', 'gte']\n\n/**\n * The vocabulary subset that makes sense for a field's type. Always a subset\n * of the closed `FILTER_OPERATORS` — never an extension.\n */\nexport function operatorsFor(option: FilterableFieldOption): FilterOperator[] {\n if (option.def === null) return ['eq', 'in'] // publication state\n switch (option.def.type) {\n case 'boolean':\n return ['eq']\n case 'select':\n case 'relation':\n case 'asset':\n return ['eq', 'in']\n default:\n return [...ORDERED_OPERATORS]\n }\n}\n\n/** A sensible starting clause when a field is added to the builder. */\nexport function defaultClause(option: FilterableFieldOption): FilterClause {\n if (option.def === null) return { field: STATE_FIELD, op: 'eq', value: 'published' }\n switch (option.def.type) {\n case 'boolean':\n return { field: option.field, op: 'eq', value: true }\n case 'number':\n return { field: option.field, op: 'eq', value: 0 }\n case 'select':\n return { field: option.field, op: 'eq', value: option.def.options[0]?.value ?? '' }\n default:\n return { field: option.field, op: 'eq', value: '' }\n }\n}\n\n// --- Text ⇄ scalar coercion (the value inputs of the builder) -------------------\n\nconst DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/\n\n/** Coerce one text input into the scalar a clause compares against. */\nexport function scalarFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar {\n const type = option?.def?.type\n if (type === 'number') {\n const trimmed = raw.trim()\n if (trimmed === '') return raw // an emptied input must not become eq 0\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? raw : parsed\n }\n if (type === 'boolean') return raw === 'true'\n // Stored dates are full ISO strings; a date-input value compares correctly\n // once expanded to midnight UTC (ISO strings order by code units).\n if (type === 'date' && DATE_ONLY.test(raw)) return `${raw}T00:00:00.000Z`\n return raw\n}\n\n/** Parse a comma-separated list for the `in` operator. */\nexport function scalarListFromText(\n option: FilterableFieldOption | undefined,\n raw: string,\n): FilterScalar[] {\n return raw\n .split(',')\n .map((part) => part.trim())\n .filter((part) => part !== '')\n .map((part) => scalarFromText(option, part))\n}\n\nexport function scalarListToText(value: FilterScalar | FilterScalar[]): string {\n const list = Array.isArray(value) ? value : [value]\n return list.map(String).join(', ')\n}\n\n// --- Clause validation -----------------------------------------------------------\n\n/** A structured problem with one clause (by index in the filter list). */\nexport interface ClauseIssue {\n index: number\n message: string\n}\n\n/**\n * Validate clauses against the collection schema. Schema-field clauses run\n * through the canonical `validateWhere` (EC-143: `filterable` enforcement +\n * operator/value shape); state clauses check the `eq`/`in` subset and the\n * draft/published value set. Invalid clauses (e.g. a persisted view whose\n * field is no longer filterable) are reported — never silently applied.\n */\nexport function validateClauses(\n collection: CollectionDef,\n clauses: readonly FilterClause[],\n): ClauseIssue[] {\n const issues: ClauseIssue[] = []\n clauses.forEach((clause, index) => {\n if (clause.field === STATE_FIELD) {\n if (clause.op !== 'eq' && clause.op !== 'in') {\n issues.push({ index, message: 'State filters support only \"eq\" and \"in\".' })\n return\n }\n const values = Array.isArray(clause.value) ? clause.value : [clause.value]\n if (!values.every((value) => (STATE_VALUES as readonly unknown[]).includes(value))) {\n issues.push({ index, message: 'State must be \"draft\" or \"published\".' })\n }\n return\n }\n const where: WhereInput = {\n [clause.field]: { [clause.op]: clause.value } as FilterCondition,\n }\n const errors = validateWhere(collection, where)\n if (errors.length > 0) issues.push({ index, message: errors[0]!.message })\n })\n return issues\n}\n\n// --- Matching & sorting (delegates to @elytracms/core/content's primitives) -------------\n\n/**\n * Published-ness source for the `$state` pseudo-field (EC-224): the version\n * POINTER, supplied by the caller as `cms.isPublished`. Defaults to \"nothing\n * published\" — a bare row carries no publish signal now that the flat `state`\n * field is gone, so the table (which knows the pointer) passes the real\n * predicate; fixtures/tests that don't surface `$state` get the safe default.\n */\nexport type IsPublished = (doc: CmsDocument) => boolean\nconst defaultIsPublished: IsPublished = () => false\n\n/** The scalar a document exposes for a clause/sort field, locale-resolved. */\nfunction scalarOf(\n collection: CollectionDef,\n doc: CmsDocument,\n field: string,\n localeConfig: LocaleConfig,\n isPublished: IsPublished,\n): FilterScalar | null {\n if (field === STATE_FIELD) return isPublished(doc) ? 'published' : 'draft'\n if (!collection.fields.some((f) => f.name === field)) return null\n const locale = documentDefaultLocale(doc, localeConfig)\n return filterScalarOf(resolveField(collection, doc, field, locale, localeConfig).value)\n}\n\n/** Does a document satisfy one clause? Same semantics as the content accessors. */\nexport function clauseMatches(\n collection: CollectionDef,\n doc: CmsDocument,\n localeConfig: LocaleConfig,\n clause: FilterClause,\n isPublished: IsPublished = defaultIsPublished,\n): boolean {\n const value = scalarOf(collection, doc, clause.field, localeConfig, isPublished)\n const condition = { [clause.op]: clause.value } as NormalizedCondition\n return matchesCondition(value, condition)\n}\n\n/**\n * Sort documents by one column in the canonical deterministic order\n * (`compareListEntries`: typed value order, id-ascending tiebreak). Unlike the\n * content accessors, the *table* may sort any rendered column — sorting is a\n * presentation concern here; the `filterable` flag governs filters.\n */\nexport function sortViewDocuments(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n sort: ViewSort | null,\n isPublished: IsPublished = defaultIsPublished,\n): CmsDocument[] {\n if (sort === null) return [...docs]\n const positions = new Map(\n docs.map((doc) => [doc.id, scalarOf(collection, doc, sort.field, localeConfig, isPublished)]),\n )\n return [...docs].sort((a, b) =>\n compareListEntries(\n { id: a.id, sortValue: positions.get(a.id) ?? null },\n { id: b.id, sortValue: positions.get(b.id) ?? null },\n sort.dir,\n ),\n )\n}\n\n/** The filtered + sorted documents of a view, plus any clause issues. */\nexport interface AppliedViewState {\n docs: CmsDocument[]\n /** Clauses that failed validation — reported AND excluded from matching. */\n issues: ClauseIssue[]\n}\n\n/**\n * Apply a view state to a document list: validate clauses, AND-match the valid\n * ones, sort. Invalid clauses never filter silently — they come back as\n * issues for the UI to surface.\n */\nexport function applyViewState(\n collection: CollectionDef,\n docs: readonly CmsDocument[],\n localeConfig: LocaleConfig,\n state: TableViewState,\n isPublished: IsPublished = defaultIsPublished,\n): AppliedViewState {\n const issues = validateClauses(collection, state.filters)\n const invalid = new Set(issues.map((issue) => issue.index))\n const active = state.filters.filter((_, index) => !invalid.has(index))\n const matched = docs.filter((doc) =>\n active.every((clause) => clauseMatches(collection, doc, localeConfig, clause, isPublished)),\n )\n return {\n docs: sortViewDocuments(collection, matched, localeConfig, state.sort, isPublished),\n issues,\n }\n}\n\n// --- View state construction, equality, columns ----------------------------------\n\n/** The id of the unnamed built-in \"All documents\" view. */\nexport const ALL_VIEW_ID = 'all'\n\n/** The default (unnamed) view: no filters, no sort, every field visible. */\n/**\n * Field types kept OFF the default table columns (EC-246b): the composite editing\n * surfaces — a blocks canvas, rich text, a structured object/repeater — read as\n * noise in a scalar list. `filterable` no longer forces (or governs) a column; the\n * default lens is \"all scalars\". These stay in the column picker one toggle away,\n * and any named view may list them in its `columns`; they're just off by default.\n */\nconst NON_DEFAULT_COLUMN_TYPES = new Set<FieldDef['type']>(['blocks', 'richText', 'object'])\n\n/** The collection's composite (non-scalar) field names — hidden in the default view. */\nfunction nonScalarColumns(collection: CollectionDef): string[] {\n return collection.fields.filter((f) => NON_DEFAULT_COLUMN_TYPES.has(f.type)).map((f) => f.name)\n}\n\nexport function defaultViewState(collection: CollectionDef): TableViewState {\n return {\n filters: [],\n sort: null,\n // Every field keeps a slot (order + picker), but the composite surfaces start\n // hidden so the default lens is the collection's scalars (EC-246b).\n columns: orderedColumnNames(collection),\n hidden: nonScalarColumns(collection),\n }\n}\n\n/**\n * A config-declared view (EC-246b) — the flat authoring shape a collection\n * declares in `cms/` config: `{ name, filters?, sort?, columns?, hidden? }`.\n * Filters/sort/columns sit at the top level (no nested `state` wrapper). The\n * studio validates + interprets these; `cms-core` stores them opaquely (it\n * can't reference the filter vocabulary without a layering cycle).\n */\nexport const configViewSchema = z.object({\n /** Optional stable id; defaults to a slug of `name`. */\n id: z.string().min(1).optional(),\n name: z.string().min(1),\n filters: z.array(filterClauseSchema).optional(),\n sort: viewSortSchema.nullable().optional(),\n /** Column order; when omitted, the view inherits the collection's default columns. */\n columns: z.array(z.string().min(1)).optional(),\n hidden: z.array(z.string().min(1)).optional(),\n})\nexport type ConfigView = z.infer<typeof configViewSchema>\n\n/** A resolved view: identity + the table state it restores (matches `SavedView`). */\nexport interface ResolvedView {\n id: string\n name: string\n state: TableViewState\n}\n\n/** Slug used to derive a config view's stable id from its name. */\nfunction configViewId(name: string, index: number): string {\n const slug = name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n return `config:${slug || index}`\n}\n\n/**\n * Resolve a collection's config-declared `views` into full {@link ResolvedView}s\n * (EC-246b). Each is validated with {@link configViewSchema}; malformed entries\n * and duplicate ids are dropped (defensive). Columns fall back to the collection\n * default when a view doesn't pin them, so a filter-only view still renders every\n * column. Config views are shared and change only in\n * code — the runtime never mutates them.\n */\nexport function configViewsFor(collection: CollectionDef): ResolvedView[] {\n const declared = collection.views\n if (!Array.isArray(declared)) return []\n const base = defaultViewState(collection)\n const seen = new Set<string>()\n const resolved: ResolvedView[] = []\n declared.forEach((raw, index) => {\n const parsed = configViewSchema.safeParse(raw)\n if (!parsed.success) return\n const view = parsed.data\n const id = view.id ?? configViewId(view.name, index)\n if (seen.has(id)) return\n seen.add(id)\n resolved.push({\n id,\n name: view.name,\n state: normalizeViewState({\n filters: view.filters ?? [],\n sort: view.sort ?? null,\n columns: view.columns && view.columns.length > 0 ? view.columns : base.columns,\n hidden: view.hidden ?? [],\n }),\n })\n })\n return resolved\n}\n\n/**\n * The default column order: the schema's title field first (it becomes the\n * default title/link column — EC-213 drops the separate primary-column\n * selector, treating the first visible column as the title), then the\n * remaining fields in schema order.\n */\nfunction orderedColumnNames(collection: CollectionDef): string[] {\n const names = collection.fields.map((field) => field.name)\n const title = titleFieldOf(collection)?.name\n if (title === undefined || !names.includes(title)) return names\n return [title, ...names.filter((name) => name !== title)]\n}\n\n/** Deep-cloned canonical form (stable key order via the Zod shape). */\nexport function normalizeViewState(state: TableViewState): TableViewState {\n return tableViewStateSchema.parse(state)\n}\n\n/** Structural equality on normalized states — drives the \"unsaved changes\" affordance. */\nexport function viewStatesEqual(a: TableViewState, b: TableViewState): boolean {\n return JSON.stringify(normalizeViewState(a)) === JSON.stringify(normalizeViewState(b))\n}\n\n/** One column of a view resolved against the current schema (EC-213). */\nexport interface ResolvedColumn {\n /** The schema field name. */\n field: string\n /** Whether the column renders (`false` ⇒ in {@link TableViewState.hidden}). */\n visible: boolean\n}\n\n/**\n * Resolve a view's columns against the live schema (EC-213): every schema\n * field exactly once, in the view's saved order, with any fields the view\n * predates appended (visible) and any fields no longer in the schema dropped.\n * This is the single source of truth for \"which columns, in what order, shown\n * or hidden\" — order is preserved across hide/show because visibility lives in\n * `hidden`, never in the order.\n */\nexport function resolveColumns(\n collection: CollectionDef,\n state: TableViewState,\n): ResolvedColumn[] {\n const schemaNames = collection.fields.map((field) => field.name)\n const schema = new Set(schemaNames)\n const hidden = new Set(state.hidden)\n // Keep the saved order, restricted to live fields and de-duplicated (a\n // corrupted persisted state must never render one field as two columns).\n const ordered: string[] = []\n const seen = new Set<string>()\n for (const name of state.columns) {\n if (schema.has(name) && !seen.has(name)) {\n ordered.push(name)\n seen.add(name)\n }\n }\n const appended = schemaNames.filter((name) => !seen.has(name))\n return [...ordered, ...appended].map((field) => ({ field, visible: !hidden.has(field) }))\n}\n\n/** The visible columns of a view, in render order (EC-213). */\nexport function visibleColumns(collection: CollectionDef, state: TableViewState): string[] {\n return resolveColumns(collection, state)\n .filter((column) => column.visible)\n .map((column) => column.field)\n}\n\n/**\n * The title/link column — the document IDENTITY column (EC-242): the schema title\n * field, shown as the leftmost linked cell whose content is `resolveDocumentTitle`\n * (a string `titleField` or a function pattern). Always present regardless of\n * column visibility — it is the document's identity, not a toggleable data column —\n * and excluded from the data columns so the title never shows twice. Falls back to\n * the first visible column, then the first field, then `id`, when no title field\n * is resolvable (e.g. a function title with no backing `title` field).\n */\nexport function primaryColumn(collection: CollectionDef, state: TableViewState): string {\n return (\n titleFieldOf(collection)?.name ??\n visibleColumns(collection, state)[0] ??\n collection.fields[0]?.name ??\n 'id'\n )\n}\n\n/**\n * Reconcile `columns` to the full resolved order so column edits operate on a\n * complete, stable order (drops removed fields, pins appended ones), and prune\n * `hidden` to fields the live schema still has (a column removed from the schema\n * must not leave dead `hidden` cruft that trips dirty-detection / persists).\n */\nfunction withResolvedOrder(collection: CollectionDef, state: TableViewState): TableViewState {\n const columns = resolveColumns(collection, state).map((column) => column.field)\n const live = new Set(columns)\n const hidden = state.hidden.filter((name) => live.has(name))\n return { ...state, columns, hidden }\n}\n\n/**\n * The canonical, schema-resolved form of a view state — full column order with\n * `hidden` pruned to live fields (EC-213). Two states that render identically\n * share one canonical form, so dirty-detection never trips on a mere column\n * reconciliation or a stale `hidden` entry (only a real filter/sort/visibility/\n * order change counts as \"unsaved\").\n */\nexport function canonicalViewState(\n collection: CollectionDef,\n state: TableViewState,\n): TableViewState {\n return normalizeViewState(withResolvedOrder(collection, state))\n}\n\n/**\n * Toggle a column's visibility — position is preserved (EC-213): visibility\n * lives in `hidden`, the order in `columns` is untouched. Columns the saved\n * order predates are pinned into `columns` first so their place is stable.\n */\nexport function toggleColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n): TableViewState {\n const base = withResolvedOrder(collection, state)\n const hidden = base.hidden.includes(field)\n ? base.hidden.filter((name) => name !== field)\n : [...base.hidden, field]\n return { ...base, hidden }\n}\n\n/** Move a column one position left (-1) or right (+1) in the full column order. */\nexport function moveColumn(\n collection: CollectionDef,\n state: TableViewState,\n field: string,\n delta: -1 | 1,\n): TableViewState {\n const base = withResolvedOrder(collection, state)\n const from = base.columns.indexOf(field)\n const to = from + delta\n if (from < 0 || to < 0 || to >= base.columns.length) return state\n const columns = [...base.columns]\n columns.splice(from, 1)\n columns.splice(to, 0, field)\n return { ...base, columns }\n}\n\n/** A fresh id for a saved view (uniqueness, not determinism, is the point). */\nexport function newViewId(): string {\n const random = Math.floor(Math.random() * 36 ** 6)\n .toString(36)\n .padStart(6, '0')\n return `view-${Date.now().toString(36)}-${random}`\n}\n"]}
@@ -13,6 +13,24 @@ interface ResolvedI18n {
13
13
  active: MessageCatalog;
14
14
  source: SourceCatalog;
15
15
  }
16
+ type LanguagesResolver = () => readonly string[] | null | undefined;
17
+ /**
18
+ * Provide the request's preferred languages for **SSR** (EC-241). The server has no
19
+ * `navigator`, so without this the server renders the default locale while the client
20
+ * renders the browser locale — a hydration mismatch (server text ≠ client text). A
21
+ * host (e.g. the TanStack Start root) sets a resolver that reads the request's
22
+ * `Accept-Language` header. It is invoked per render, so when the host reads from
23
+ * request-scoped storage (TanStack's AsyncLocalStorage) it stays concurrency-safe —
24
+ * the engine keeps no request state. A no-op on the client, where `navigator` wins.
25
+ */
26
+ export declare function setServerLanguagesResolver(fn: LanguagesResolver | null): void;
27
+ /**
28
+ * Parse an HTTP `Accept-Language` header into an ordered list of language tags,
29
+ * highest q-weight first: `de,en-US;q=0.7,en;q=0.3` → `['de', 'en-US', 'en']`. The
30
+ * server equivalent of `navigator.languages`, so SSR resolves the same locale the
31
+ * client will.
32
+ */
33
+ export declare function parseAcceptLanguage(header: string | null | undefined): string[];
16
34
  /**
17
35
  * Resolve the studio i18n from the config holder + the browser locale (EC-241).
18
36
  *
@@ -33,13 +51,22 @@ export declare function resolveStudioI18n(): ResolvedI18n;
33
51
  * is the React-idiomatic wrapper.
34
52
  */
35
53
  export declare function translate(key: string, vars?: Record<string, string | number>): string;
54
+ export declare function msgLabel(key: string): LocalizedString;
55
+ /**
56
+ * Decode a {@link msgLabel} to its translated string for the active locale, or
57
+ * `undefined` when the value is not a catalog-backed label (a plain string / locale
58
+ * map / absent). Every studio label read site checks this first, then falls back to
59
+ * {@link resolveLabel} for ordinary labels.
60
+ */
61
+ export declare function resolveMsgLabel(value: unknown): string | undefined;
36
62
  /**
37
63
  * Resolve a {@link LocalizedString} (field/collection/option label) against the
38
64
  * active UI locale (EC-241) — **non-hook**, reading the per-boot singleton, so it is
39
65
  * safe to call anywhere: a component body, a nested render helper, or config-build
40
66
  * code. Returns `fallback` (default `''`) when the value is absent. Prefer this over
41
67
  * `resolveLabel(x, useUiLocale())` at render sites — it localizes without a hook, so
42
- * it can't trip the rules-of-hooks in a conditional/nested position.
68
+ * it can't trip the rules-of-hooks in a conditional/nested position. A catalog-backed
69
+ * {@link msgLabel} (the built-in rails) resolves through the message catalog.
43
70
  */
44
71
  export declare function localizedLabel(value: LocalizedString | undefined, fallback?: string): string;
45
72
  /** The active studio-UI locale (browser-resolved). */
@@ -54,6 +81,6 @@ export declare function useT(): (key: string, vars?: Record<string, string | num
54
81
  export declare function useLabel(): (value: LocalizedString | undefined, fallback?: string) => string;
55
82
  /** Test seam: force the active locale. Never used by app code. */
56
83
  export declare function setUiLocaleForTests(locale: string | null): void;
57
- /** Test seam: reset i18n state (the once-per-boot warnings). Never used by app code. */
84
+ /** Test seam: reset i18n state (once-per-boot warnings + the SSR resolver). Never used by app code. */
58
85
  export declare function resetStudioI18nForTests(): void;
59
86
  export {};