@elytracms/studio 0.0.65 → 0.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/self-account-view-source.js +9 -2
- package/dist/components/account/self-account-view-source.js.map +1 -1
- package/dist/components/app-views/default-modules.d.ts +28 -1
- package/dist/components/app-views/default-modules.js +47 -2
- package/dist/components/app-views/default-modules.js.map +1 -1
- package/dist/components/auth-context.js +32 -1
- package/dist/components/auth-context.js.map +1 -1
- package/dist/components/builder/blocks-model.js +4 -2
- package/dist/components/builder/blocks-model.js.map +1 -1
- package/dist/components/builder/canvas-dnd.js +4 -2
- package/dist/components/builder/canvas-dnd.js.map +1 -1
- package/dist/components/builder/insert-context.js +15 -6
- package/dist/components/builder/insert-context.js.map +1 -1
- package/dist/components/builder/page-tree.js +4 -2
- package/dist/components/builder/page-tree.js.map +1 -1
- package/dist/components/builder/property-inspector.js +2 -1
- package/dist/components/builder/property-inspector.js.map +1 -1
- package/dist/components/cms/asset-field.js +21 -5
- package/dist/components/cms/asset-field.js.map +1 -1
- package/dist/components/cms/bulk-actions.d.ts +22 -3
- package/dist/components/cms/bulk-actions.js +27 -3
- package/dist/components/cms/bulk-actions.js.map +1 -1
- package/dist/components/cms/cms-store.js +19 -0
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/detail-editor.js +18 -19
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/components/cms/prop-fields.js +23 -16
- package/dist/components/cms/prop-fields.js.map +1 -1
- package/dist/components/cms/publish-clean.d.ts +21 -0
- package/dist/components/cms/publish-clean.js +30 -0
- package/dist/components/cms/publish-clean.js.map +1 -0
- package/dist/components/cms/use-live-url.d.ts +24 -1
- package/dist/components/cms/use-live-url.js +26 -4
- package/dist/components/cms/use-live-url.js.map +1 -1
- package/dist/components/cms/use-publish-controller.js +8 -6
- package/dist/components/cms/use-publish-controller.js.map +1 -1
- package/dist/components/collection-view/cms-collection-view-source.js +15 -7
- package/dist/components/collection-view/cms-collection-view-source.js.map +1 -1
- package/dist/lib/auth/auth-adapter.d.ts +22 -0
- package/dist/lib/auth/auth-adapter.js.map +1 -1
- package/dist/lib/auth/convex-auth-adapter.d.ts +42 -1
- package/dist/lib/auth/convex-auth-adapter.js +69 -0
- package/dist/lib/auth/convex-auth-adapter.js.map +1 -1
- package/dist/lib/auth/dev-auto-login-adapter.d.ts +2 -1
- package/dist/lib/auth/dev-auto-login-adapter.js +6 -0
- package/dist/lib/auth/dev-auto-login-adapter.js.map +1 -1
- package/dist/lib/auth/index.d.ts +1 -1
- package/dist/lib/auth/index.js.map +1 -1
- package/dist/lib/auth/local-auth-adapter.d.ts +2 -1
- package/dist/lib/auth/local-auth-adapter.js +7 -0
- package/dist/lib/auth/local-auth-adapter.js.map +1 -1
- package/dist/lib/auth-errors.d.ts +45 -3
- package/dist/lib/auth-errors.js +46 -5
- package/dist/lib/auth-errors.js.map +1 -1
- package/dist/lib/clipboard/paste-target.js +5 -2
- package/dist/lib/clipboard/paste-target.js.map +1 -1
- package/dist/lib/dnd/drop-rules.d.ts +13 -0
- package/dist/lib/dnd/drop-rules.js +15 -0
- package/dist/lib/dnd/drop-rules.js.map +1 -1
- package/dist/lib/i18n/messages.de.js +3 -0
- package/dist/lib/i18n/messages.de.js.map +1 -1
- package/dist/lib/i18n/messages.en.d.ts +2 -0
- package/dist/lib/i18n/messages.en.js +8 -0
- package/dist/lib/i18n/messages.en.js.map +1 -1
- package/dist/lib/persistence/index.js +6 -3
- package/dist/lib/persistence/index.js.map +1 -1
- package/dist/lib/session-expiry.d.ts +19 -6
- package/dist/lib/session-expiry.js +13 -1
- package/dist/lib/session-expiry.js.map +1 -1
- package/dist/lib/session-revalidation.d.ts +81 -0
- package/dist/lib/session-revalidation.js +94 -0
- package/dist/lib/session-revalidation.js.map +1 -0
- package/package.json +2 -2
|
@@ -87,12 +87,19 @@ export function PropValueControl({ id, name, spec, value, onSet, onClear }) {
|
|
|
87
87
|
const kind = controlKind(spec);
|
|
88
88
|
// Select options live on the `select` field-def.
|
|
89
89
|
const options = spec.type === 'select' ? spec.options : [];
|
|
90
|
+
// EC-395: `form.readOnly` parity with the document form. `cms-store.tsx`'s
|
|
91
|
+
// `isFieldReadOnly` reads the identical `field.form?.readOnly === true` check —
|
|
92
|
+
// every control kind below (including the delegated `FieldControl`/
|
|
93
|
+
// `SegmentedOptions` mounts, which previously hardcoded `readOnly={false}`)
|
|
94
|
+
// degrades to the SAME disabled/inert interaction the document form's
|
|
95
|
+
// `FieldControl` renders for a read-only field, not a parallel treatment.
|
|
96
|
+
const readOnly = spec.form?.readOnly === true;
|
|
90
97
|
let control;
|
|
91
98
|
if (kind === 'boolean') {
|
|
92
|
-
control = (_jsxs("label", { className: "flex h-8 items-center gap-2 text-sm", children: [_jsx("input", { id: id, type: "checkbox", checked: current === true, onChange: (e) => onSet(e.target.checked), className: "size-4 accent-primary" }), _jsx(Text, { size: "sm", tone: "muted", children: current === true ? translate('common.true') : translate('common.false') })] }));
|
|
99
|
+
control = (_jsxs("label", { className: "flex h-8 items-center gap-2 text-sm", children: [_jsx("input", { id: id, type: "checkbox", checked: current === true, disabled: readOnly, onChange: (e) => onSet(e.target.checked), className: "size-4 accent-primary disabled:opacity-50" }), _jsx(Text, { size: "sm", tone: "muted", children: current === true ? translate('common.true') : translate('common.false') })] }));
|
|
93
100
|
}
|
|
94
101
|
else if (kind === 'select') {
|
|
95
|
-
control = (_jsx(Select, { id: id, value: String(current ?? ''), onChange: (e) => {
|
|
102
|
+
control = (_jsx(Select, { id: id, disabled: readOnly, value: String(current ?? ''), onChange: (e) => {
|
|
96
103
|
// EC-190: select option values are strings (field-def `options`).
|
|
97
104
|
const opt = options.find((o) => o.value === e.target.value);
|
|
98
105
|
onSet(opt ? opt.value : e.target.value);
|
|
@@ -103,16 +110,16 @@ export function PropValueControl({ id, name, spec, value, onSet, onClear }) {
|
|
|
103
110
|
// `field-control.tsx`) — delegation over a parallel dropdown. It reads the
|
|
104
111
|
// field-def's own `options` (label + per-option `description` tooltip); single-
|
|
105
112
|
// select only (picks one, no unset — an unset select keeps the native dropdown).
|
|
106
|
-
control = (_jsx(SegmentedOptions, { id: id, field: { ...spec, name }, value: current, onChange: (v) => onSet(v), readOnly:
|
|
113
|
+
control = (_jsx(SegmentedOptions, { id: id, field: { ...spec, name }, value: current, onChange: (v) => onSet(v), readOnly: readOnly }));
|
|
107
114
|
}
|
|
108
115
|
else if (kind === 'number') {
|
|
109
|
-
control = _jsx(NumberControl, { id: id, current: current, onSet: onSet, onClear: onClear });
|
|
116
|
+
control = (_jsx(NumberControl, { id: id, current: current, onSet: onSet, onClear: onClear, readOnly: readOnly }));
|
|
110
117
|
}
|
|
111
118
|
else if (kind === 'json') {
|
|
112
|
-
control = _jsx(JsonControl, { id: id, current: current, onSet: onSet });
|
|
119
|
+
control = _jsx(JsonControl, { id: id, current: current, onSet: onSet, readOnly: readOnly });
|
|
113
120
|
}
|
|
114
121
|
else if (kind === 'color') {
|
|
115
|
-
control = (_jsxs(Row, { gap: "2", children: [_jsx("input", { id: id, type: "color", value: typeof current === 'string' && /^#[0-9a-f]{6}$/i.test(current) ? current : '#000000', onChange: (e) => onSet(e.target.value), className: "h-8 w-10 shrink-0 rounded-md border border-input bg-background" }), _jsx(Input, { value: typeof current === 'string' ? current : '', onChange: (e) => onSet(e.target.value) })] }));
|
|
122
|
+
control = (_jsxs(Row, { gap: "2", children: [_jsx("input", { id: id, type: "color", disabled: readOnly, value: typeof current === 'string' && /^#[0-9a-f]{6}$/i.test(current) ? current : '#000000', onChange: (e) => onSet(e.target.value), className: "h-8 w-10 shrink-0 rounded-md border border-input bg-background disabled:opacity-50" }), _jsx(Input, { disabled: readOnly, value: typeof current === 'string' ? current : '', onChange: (e) => onSet(e.target.value) })] }));
|
|
116
123
|
}
|
|
117
124
|
else if (kind === 'richtext') {
|
|
118
125
|
// EC-387: a richText PROP now uses the SAME real editor as the collection-field
|
|
@@ -131,10 +138,10 @@ export function PropValueControl({ id, name, spec, value, onSet, onClear }) {
|
|
|
131
138
|
// preview surface (no provider, nothing to edit against) degrades to the same
|
|
132
139
|
// read-only value display the sibling controls use, instead of crashing with
|
|
133
140
|
// "useCollectionView must be used within a <CollectionViewProvider>".
|
|
134
|
-
control = hasWorkspaceContext ? (_jsx(RichTextEditor, { id: id, value: current, onChange: (next) => applyRichTextPropChange(next, { onSet, onClear }), allow: spec.type === 'richText' ? spec.allow : undefined })) : (_jsx(WorkspaceValueFallback, { value: current }));
|
|
141
|
+
control = hasWorkspaceContext ? (_jsx(RichTextEditor, { id: id, value: current, onChange: (next) => applyRichTextPropChange(next, { onSet, onClear }), allow: spec.type === 'richText' ? spec.allow : undefined, readOnly: readOnly })) : (_jsx(WorkspaceValueFallback, { value: current }));
|
|
135
142
|
}
|
|
136
143
|
else if (kind === 'textarea') {
|
|
137
|
-
control = (_jsx("textarea", { id: id, rows: 2, value: typeof current === 'string' ? current : '', onChange: (e) => onSet(e.target.value), className: "flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 text-sm text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none" }));
|
|
144
|
+
control = (_jsx("textarea", { id: id, rows: 2, disabled: readOnly, value: typeof current === 'string' ? current : '', onChange: (e) => onSet(e.target.value), className: "flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 text-sm text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50" }));
|
|
138
145
|
}
|
|
139
146
|
else if (kind === 'asset' || kind === 'object' || kind === 'relation') {
|
|
140
147
|
// EC-195/EC-253/EC-262: reuse the CMS field control. `asset` = library picker +
|
|
@@ -143,12 +150,12 @@ export function PropValueControl({ id, name, spec, value, onSet, onClear }) {
|
|
|
143
150
|
// All edit a structured static prop value through the same shared control documents use.
|
|
144
151
|
// Without a workspace context (the Components preview), degrade to a read-only
|
|
145
152
|
// value display so the pane renders instead of throwing.
|
|
146
|
-
control = hasWorkspaceContext ? (_jsx(FieldDensityProvider, { density: "compact", children: _jsx(FieldControl, { id: id, field: { ...spec, name }, value: current, onChange: (v) => (v === undefined || v === null ? onClear() : onSet(v)), readOnly:
|
|
153
|
+
control = hasWorkspaceContext ? (_jsx(FieldDensityProvider, { density: "compact", children: _jsx(FieldControl, { id: id, field: { ...spec, name }, value: current, onChange: (v) => (v === undefined || v === null ? onClear() : onSet(v)), readOnly: readOnly }) })) : (_jsx(WorkspaceValueFallback, { value: current }));
|
|
147
154
|
}
|
|
148
155
|
else {
|
|
149
|
-
control = (_jsx(Input, { id: id, value: typeof current === 'string' ? current : String(current ?? ''), onChange: (e) => onSet(e.target.value) }));
|
|
156
|
+
control = (_jsx(Input, { id: id, disabled: readOnly, value: typeof current === 'string' ? current : String(current ?? ''), onChange: (e) => onSet(e.target.value) }));
|
|
150
157
|
}
|
|
151
|
-
return (_jsxs(Stack, { gap: "1", children: [control, !valid ? (_jsx(Text, { size: "xs", className: "text-destructive", children: translate('builder.inspector.invalidValue') })) : null] }));
|
|
158
|
+
return (_jsxs(Stack, { gap: "1", children: [control, !valid && !readOnly ? (_jsx(Text, { size: "xs", className: "text-destructive", children: translate('builder.inspector.invalidValue') })) : null] }));
|
|
152
159
|
}
|
|
153
160
|
/**
|
|
154
161
|
* Read-only stand-in for an `asset`/`relation`/`object` prop when there is no
|
|
@@ -165,12 +172,12 @@ function WorkspaceValueFallback({ value }) {
|
|
|
165
172
|
return (_jsxs(Stack, { gap: "1", children: [_jsx("div", { className: "truncate rounded-md border border-input bg-muted/30 px-2.5 py-1.5 text-sm text-muted-foreground", children: text }), _jsx(Text, { size: "xs", tone: "muted", children: translate('components.preview.propNeedsDocument') })] }));
|
|
166
173
|
}
|
|
167
174
|
/** Number input with a local buffer: commits only finite values, never NaN; empty clears the prop. */
|
|
168
|
-
function NumberControl({ id, current, onSet, onClear, }) {
|
|
175
|
+
function NumberControl({ id, current, onSet, onClear, readOnly, }) {
|
|
169
176
|
const [raw, setRaw] = useState(typeof current === 'number' ? String(current) : '');
|
|
170
177
|
useEffect(() => {
|
|
171
178
|
setRaw(typeof current === 'number' ? String(current) : '');
|
|
172
179
|
}, [current]);
|
|
173
|
-
return (_jsx(Input, { id: id, type: "number", value: raw, onChange: (e) => {
|
|
180
|
+
return (_jsx(Input, { id: id, type: "number", disabled: readOnly, value: raw, onChange: (e) => {
|
|
174
181
|
const v = e.target.value;
|
|
175
182
|
setRaw(v);
|
|
176
183
|
if (v.trim() === '') {
|
|
@@ -183,14 +190,14 @@ function NumberControl({ id, current, onSet, onClear, }) {
|
|
|
183
190
|
} }));
|
|
184
191
|
}
|
|
185
192
|
/** JSON textarea with a local buffer: commits only when the text parses; flags parse errors. */
|
|
186
|
-
function JsonControl({ id, current, onSet, }) {
|
|
193
|
+
function JsonControl({ id, current, onSet, readOnly, }) {
|
|
187
194
|
const [raw, setRaw] = useState(() => JSON.stringify(current ?? null));
|
|
188
195
|
const [error, setError] = useState(null);
|
|
189
196
|
useEffect(() => {
|
|
190
197
|
setRaw(JSON.stringify(current ?? null));
|
|
191
198
|
setError(null);
|
|
192
199
|
}, [current]);
|
|
193
|
-
return (_jsxs(Stack, { gap: "1", children: [_jsx("textarea", { id: id, rows: 3, value: raw, onChange: (e) => {
|
|
200
|
+
return (_jsxs(Stack, { gap: "1", children: [_jsx("textarea", { id: id, rows: 3, disabled: readOnly, value: raw, onChange: (e) => {
|
|
194
201
|
const v = e.target.value;
|
|
195
202
|
setRaw(v);
|
|
196
203
|
try {
|
|
@@ -200,6 +207,6 @@ function JsonControl({ id, current, onSet, }) {
|
|
|
200
207
|
catch {
|
|
201
208
|
setError(translate('builder.inspector.invalidJson'));
|
|
202
209
|
}
|
|
203
|
-
}, className: "flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none" }), error ? (_jsx(Text, { size: "xs", className: "text-destructive", children: error })) : null] }));
|
|
210
|
+
}, className: "flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50" }), error ? (_jsx(Text, { size: "xs", className: "text-destructive", children: error })) : null] }));
|
|
204
211
|
}
|
|
205
212
|
//# sourceMappingURL=prop-fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-fields.js","sourceRoot":"","sources":["../../../src/components/cms/prop-fields.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAoCtF,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAA;QACjB,KAAK,QAAQ;YACX,iFAAiF;YACjF,8EAA8E;YAC9E,+EAA+E;YAC/E,gFAAgF;YAChF,IAAI,IAAI,CAA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O,CAAC,CAAC,CAAA;IACb,OAAO,CACL,MAAC,KAAK,IAAC,GAAG,EAAC,GAAG,aACZ,mBACE,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAA;oBACxB,MAAM,CAAC,CAAC,CAAC,CAAA;oBACT,IAAI,CAAC;wBACH,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAc,CAAC,CAAA;wBACjC,QAAQ,CAAC,IAAI,CAAC,CAAA;oBAChB,CAAC;oBAAC,MAAM,CAAC;wBACP,QAAQ,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC,CAAA;oBACtD,CAAC;gBACH,CAAC,EACD,SAAS,EAAC,2MAA2M,GACrN,EACD,KAAK,CAAC,CAAC,CAAC,CACP,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,kBAAkB,YACzC,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,IACF,CACT,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useState } from 'react'\nimport { isStaticProp } from '@elytracms/core/project-graph'\nimport type { JsonValue, PropValue } from '@elytracms/core/project-graph'\nimport type { PropField } from '@elytracms/core/component-registry'\nimport { fieldValueValidator } from '@elytracms/core/cms-core'\nimport type { FieldDef, SelectFieldDef, SelectOption } from '@elytracms/core/cms-core'\nimport { Input, Row, Select, Stack, Text } from '@elytracms/studio/ui'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { FieldControl } from './field-control'\nimport { SegmentedOptions } from './field-control-lib'\nimport { FieldDensityProvider } from './field-density'\nimport { RichTextEditor } from './rich-text'\nimport { useOptionalCollectionView } from '../collection-view/collection-view-context'\n\n/**\n * The EC-190 \"props-as-fields\" value control — the single renderer for a\n * manifest-declared prop field, shared by the canvas property inspector\n * (`builder/property-inspector.tsx`) and the rich-text component-embed prop editor\n * (`rich-text/embed-props.tsx`). Extracted here so both surfaces render prop fields\n * through *one* control set (asset → library picker, relation → document picker,\n * object → nested form, …) rather than two parallel form systems.\n *\n * It is deliberately store-agnostic: it reads a prop's current value and reports\n * edits through `onSet(rawValue)` / `onClear()`. The caller owns *where* the value\n * lands — the inspector dispatches a builder command; the embed editor rewrites a\n * ProseMirror node attr — and is responsible for wrapping the raw value in a\n * `staticProp` envelope.\n */\n\n/**\n * The inspector control to render for a prop field-def. The `control.kind`\n * vocabulary derives from the field `type` plus the optional `form.control`\n * presentation hint on `text` fields.\n */\nexport type ControlKind =\n | 'text'\n | 'textarea'\n | 'number'\n | 'boolean'\n | 'select'\n | 'options'\n | 'json'\n | 'color'\n | 'richtext'\n | 'asset'\n | 'object'\n | 'relation'\n\nexport function controlKind(spec: PropField): ControlKind {\n switch (spec.type) {\n case 'boolean':\n return 'boolean'\n case 'number':\n return 'number'\n case 'select':\n // EC-393: a single-select prop opting into `form.control: 'options'` renders the\n // SAME segmented button group the document form uses (EC-295), not the native\n // dropdown — parity with `field-control.tsx`. Segmented is single-select only,\n // so a `multiple` select stays on the native control (mirroring field-control).\n if (spec.form?.control === 'options' && !spec.multiple) return 'options'\n return 'select'\n case 'richText':\n return 'richtext'\n // EC-195: an `asset`-typed prop (e.g. the Image `src`) picks from the asset\n // library — never a raw asset id typed into a text box (the EC-192 persona).\n case 'asset':\n return 'asset'\n // EC-253: an `object`/repeater prop reuses the CMS repeater control below.\n case 'object':\n return 'object'\n // EC-262: a `relation`-typed prop (e.g. a ProductGrid's `category`) reuses the\n // CMS relation picker — never a text box that stringifies the ref to \"[object Object]\".\n case 'relation':\n return 'relation'\n case 'text': {\n const c = spec.form?.control\n if (c === 'textarea') return 'textarea'\n if (c === 'color') return 'color'\n if (c === 'json') return 'json'\n return 'text'\n }\n default:\n return 'text'\n }\n}\n\n/**\n * EC-387: route a rich-text editor emission to the prop value callbacks.\n *\n * The shared {@link RichTextEditor} emits either an emptied-editor `undefined`, the\n * exact stored envelope (an untouched/reverted edit), or a fresh `{ version, doc }`\n * value — never a plain string. An `undefined` clears the prop (reverting to the\n * manifest default, matching the asset/relation/object controls); anything else is a\n * structured `JsonValue` envelope set verbatim. Extracted pure so the wiring — the\n * exact bug the retired textarea stub had (it wrote a bare string over the envelope) —\n * is regression-pinned without driving TipTap.\n */\nexport function applyRichTextPropChange(\n next: unknown,\n handlers: { onSet: (value: JsonValue) => void; onClear: () => void },\n): void {\n if (next === undefined) handlers.onClear()\n else handlers.onSet(next as JsonValue)\n}\n\nexport interface PropValueControlProps {\n /** DOM id for the control's primary input (label `htmlFor` target). */\n id: string\n /** The prop's field name — needed to synthesize the `FieldDef` for reused controls. */\n name: string\n /** The manifest prop field-def driving the control kind + validation. */\n spec: PropField\n /** The prop's current value envelope (or `undefined` when unset). */\n value: PropValue | undefined\n /** Commit a new raw value (the caller wraps it in a `staticProp`). */\n onSet: (value: JsonValue) => void\n /** Remove the prop (revert to the manifest default). */\n onClear: () => void\n}\n\n/**\n * Render + edit a single manifest prop value. Store-agnostic: emits through\n * `onSet`/`onClear`. Shows a validation issue when the current value fails the\n * prop's field-def validator.\n */\nexport function PropValueControl({ id, name, spec, value, onSet, onClear }: PropValueControlProps) {\n const current = isStaticProp(value) ? value.value : (spec.default as JsonValue | undefined)\n // The `asset`/`relation`/`object` controls delegate to the CMS `FieldControl`,\n // which reads the ambient `CollectionViewSource` (asset library, relation\n // candidates, nested form). The component-registry preview surface has no\n // document/collection context, so outside a provider those controls must degrade\n // to a read-only value display instead of throwing \"useCollectionView must be\n // used within a <CollectionViewProvider>\" (the Konditorei Components-view crash).\n const hasWorkspaceContext = useOptionalCollectionView() != null\n\n // EC-190: validate with the prop's field-def value validator.\n const valid = current === undefined || fieldValueValidator({ ...spec, name } as FieldDef)(current)\n // EC-190: derive the editor control from the field `type` + optional `form.control`.\n const kind = controlKind(spec)\n // Select options live on the `select` field-def.\n const options: readonly SelectOption[] = spec.type === 'select' ? spec.options : []\n\n let control\n if (kind === 'boolean') {\n control = (\n <label className=\"flex h-8 items-center gap-2 text-sm\">\n <input\n id={id}\n type=\"checkbox\"\n checked={current === true}\n onChange={(e) => onSet(e.target.checked)}\n className=\"size-4 accent-primary\"\n />\n <Text size=\"sm\" tone=\"muted\">\n {current === true ? translate('common.true') : translate('common.false')}\n </Text>\n </label>\n )\n } else if (kind === 'select') {\n control = (\n <Select\n id={id}\n value={String(current ?? '')}\n onChange={(e) => {\n // EC-190: select option values are strings (field-def `options`).\n const opt = options.find((o) => o.value === e.target.value)\n onSet(opt ? opt.value : e.target.value)\n }}\n >\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {localizedLabel(opt.label, opt.value)}\n </option>\n ))}\n </Select>\n )\n } else if (kind === 'options') {\n // EC-393: reuse the EC-295 segmented control the document form renders (via\n // `field-control.tsx`) — delegation over a parallel dropdown. It reads the\n // field-def's own `options` (label + per-option `description` tooltip); single-\n // select only (picks one, no unset — an unset select keeps the native dropdown).\n control = (\n <SegmentedOptions\n id={id}\n field={{ ...spec, name } as SelectFieldDef}\n value={current}\n onChange={(v) => onSet(v as JsonValue)}\n readOnly={false}\n />\n )\n } else if (kind === 'number') {\n control = <NumberControl id={id} current={current} onSet={onSet} onClear={onClear} />\n } else if (kind === 'json') {\n control = <JsonControl id={id} current={current} onSet={onSet} />\n } else if (kind === 'color') {\n control = (\n <Row gap=\"2\">\n <input\n id={id}\n type=\"color\"\n value={typeof current === 'string' && /^#[0-9a-f]{6}$/i.test(current) ? current : '#000000'}\n onChange={(e) => onSet(e.target.value)}\n className=\"h-8 w-10 shrink-0 rounded-md border border-input bg-background\"\n />\n <Input value={typeof current === 'string' ? current : ''} onChange={(e) => onSet(e.target.value)} />\n </Row>\n )\n } else if (kind === 'richtext') {\n // EC-387: a richText PROP now uses the SAME real editor as the collection-field\n // path (`field-control.tsx` `case 'richText'`) — one editing surface, one\n // `{ version, doc }` value contract, never a second implementation. The retired\n // textarea stub read `typeof current === 'string'`, so a stored envelope showed\n // EMPTY and any edit clobbered the structured document with a bare string\n // (silent data destruction). The editor reads the envelope (or a legacy string,\n // or empty), always emits an envelope, and routes an emptied editor's `undefined`\n // to a prop clear via {@link applyRichTextPropChange}.\n //\n // Like the asset/relation/object controls below, the editor needs the ambient\n // workspace — its asset-image picker reads the REQUIRED collection-view context.\n // The block property inspector (the EC-387 target) is inside the detail editor's\n // `CollectionViewProvider`, so it gets the full editor; the component-registry\n // preview surface (no provider, nothing to edit against) degrades to the same\n // read-only value display the sibling controls use, instead of crashing with\n // \"useCollectionView must be used within a <CollectionViewProvider>\".\n control = hasWorkspaceContext ? (\n <RichTextEditor\n id={id}\n value={current}\n onChange={(next) => applyRichTextPropChange(next, { onSet, onClear })}\n allow={spec.type === 'richText' ? spec.allow : undefined}\n />\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else if (kind === 'textarea') {\n control = (\n <textarea\n id={id}\n rows={2}\n value={typeof current === 'string' ? current : ''}\n onChange={(e) => onSet(e.target.value)}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 text-sm text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none\"\n />\n )\n } else if (kind === 'asset' || kind === 'object' || kind === 'relation') {\n // EC-195/EC-253/EC-262: reuse the CMS field control. `asset` = library picker +\n // preview; `object` = the nested/repeater form; `relation` = the document picker\n // (resolves the ref to its title, instead of stringifying it to \"[object Object]\").\n // All edit a structured static prop value through the same shared control documents use.\n // Without a workspace context (the Components preview), degrade to a read-only\n // value display so the pane renders instead of throwing.\n control = hasWorkspaceContext ? (\n <FieldDensityProvider density=\"compact\">\n <FieldControl\n id={id}\n field={{ ...spec, name } as FieldDef}\n value={current}\n onChange={(v) => (v === undefined || v === null ? onClear() : onSet(v as JsonValue))}\n readOnly={false}\n />\n </FieldDensityProvider>\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else {\n control = (\n <Input\n id={id}\n value={typeof current === 'string' ? current : String(current ?? '')}\n onChange={(e) => onSet(e.target.value)}\n />\n )\n }\n\n return (\n <Stack gap=\"1\">\n {control}\n {!valid ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {translate('builder.inspector.invalidValue')}\n </Text>\n ) : null}\n </Stack>\n )\n}\n\n/**\n * Read-only stand-in for an `asset`/`relation`/`object` prop when there is no\n * ambient `CollectionViewSource` (the component-registry preview, which has no\n * document/collection context). Shows the current value and a hint that it is\n * editable inside a document — never the live picker, which needs a workspace.\n */\nfunction WorkspaceValueFallback({ value }: { value: JsonValue | undefined }) {\n const text =\n value === undefined || value === null\n ? '—'\n : typeof value === 'string'\n ? value\n : JSON.stringify(value)\n return (\n <Stack gap=\"1\">\n <div className=\"truncate rounded-md border border-input bg-muted/30 px-2.5 py-1.5 text-sm text-muted-foreground\">\n {text}\n </div>\n <Text size=\"xs\" tone=\"muted\">\n {translate('components.preview.propNeedsDocument')}\n </Text>\n </Stack>\n )\n}\n\n/** Number input with a local buffer: commits only finite values, never NaN; empty clears the prop. */\nfunction NumberControl({\n id,\n current,\n onSet,\n onClear,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: number) => void\n onClear: () => void\n}) {\n const [raw, setRaw] = useState(typeof current === 'number' ? String(current) : '')\n useEffect(() => {\n setRaw(typeof current === 'number' ? String(current) : '')\n }, [current])\n return (\n <Input\n id={id}\n type=\"number\"\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n if (v.trim() === '') {\n onClear()\n return\n }\n const n = Number(v)\n if (Number.isFinite(n)) onSet(n)\n }}\n />\n )\n}\n\n/** JSON textarea with a local buffer: commits only when the text parses; flags parse errors. */\nfunction JsonControl({\n id,\n current,\n onSet,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: JsonValue) => void\n}) {\n const [raw, setRaw] = useState(() => JSON.stringify(current ?? null))\n const [error, setError] = useState<string | null>(null)\n useEffect(() => {\n setRaw(JSON.stringify(current ?? null))\n setError(null)\n }, [current])\n return (\n <Stack gap=\"1\">\n <textarea\n id={id}\n rows={3}\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n try {\n onSet(JSON.parse(v) as JsonValue)\n setError(null)\n } catch {\n setError(translate('builder.inspector.invalidJson'))\n }\n }}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.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 {error ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {error}\n </Text>\n ) : null}\n </Stack>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"prop-fields.js","sourceRoot":"","sources":["../../../src/components/cms/prop-fields.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAoCtF,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAA;QACjB,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AAI,EAAC,SAAS,EAAC,kBAAkB,YACzC,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,IACF,CACT,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useState } from 'react'\nimport { isStaticProp } from '@elytracms/core/project-graph'\nimport type { JsonValue, PropValue } from '@elytracms/core/project-graph'\nimport type { PropField } from '@elytracms/core/component-registry'\nimport { fieldValueValidator } from '@elytracms/core/cms-core'\nimport type { FieldDef, SelectFieldDef, SelectOption } from '@elytracms/core/cms-core'\nimport { Input, Row, Select, Stack, Text } from '@elytracms/studio/ui'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { FieldControl } from './field-control'\nimport { SegmentedOptions } from './field-control-lib'\nimport { FieldDensityProvider } from './field-density'\nimport { RichTextEditor } from './rich-text'\nimport { useOptionalCollectionView } from '../collection-view/collection-view-context'\n\n/**\n * The EC-190 \"props-as-fields\" value control — the single renderer for a\n * manifest-declared prop field, shared by the canvas property inspector\n * (`builder/property-inspector.tsx`) and the rich-text component-embed prop editor\n * (`rich-text/embed-props.tsx`). Extracted here so both surfaces render prop fields\n * through *one* control set (asset → library picker, relation → document picker,\n * object → nested form, …) rather than two parallel form systems.\n *\n * It is deliberately store-agnostic: it reads a prop's current value and reports\n * edits through `onSet(rawValue)` / `onClear()`. The caller owns *where* the value\n * lands — the inspector dispatches a builder command; the embed editor rewrites a\n * ProseMirror node attr — and is responsible for wrapping the raw value in a\n * `staticProp` envelope.\n */\n\n/**\n * The inspector control to render for a prop field-def. The `control.kind`\n * vocabulary derives from the field `type` plus the optional `form.control`\n * presentation hint on `text` fields.\n */\nexport type ControlKind =\n | 'text'\n | 'textarea'\n | 'number'\n | 'boolean'\n | 'select'\n | 'options'\n | 'json'\n | 'color'\n | 'richtext'\n | 'asset'\n | 'object'\n | 'relation'\n\nexport function controlKind(spec: PropField): ControlKind {\n switch (spec.type) {\n case 'boolean':\n return 'boolean'\n case 'number':\n return 'number'\n case 'select':\n // EC-393: a single-select prop opting into `form.control: 'options'` renders the\n // SAME segmented button group the document form uses (EC-295), not the native\n // dropdown — parity with `field-control.tsx`. Segmented is single-select only,\n // so a `multiple` select stays on the native control (mirroring field-control).\n if (spec.form?.control === 'options' && !spec.multiple) return 'options'\n return 'select'\n case 'richText':\n return 'richtext'\n // EC-195: an `asset`-typed prop (e.g. the Image `src`) picks from the asset\n // library — never a raw asset id typed into a text box (the EC-192 persona).\n case 'asset':\n return 'asset'\n // EC-253: an `object`/repeater prop reuses the CMS repeater control below.\n case 'object':\n return 'object'\n // EC-262: a `relation`-typed prop (e.g. a ProductGrid's `category`) reuses the\n // CMS relation picker — never a text box that stringifies the ref to \"[object Object]\".\n case 'relation':\n return 'relation'\n case 'text': {\n const c = spec.form?.control\n if (c === 'textarea') return 'textarea'\n if (c === 'color') return 'color'\n if (c === 'json') return 'json'\n return 'text'\n }\n default:\n return 'text'\n }\n}\n\n/**\n * EC-387: route a rich-text editor emission to the prop value callbacks.\n *\n * The shared {@link RichTextEditor} emits either an emptied-editor `undefined`, the\n * exact stored envelope (an untouched/reverted edit), or a fresh `{ version, doc }`\n * value — never a plain string. An `undefined` clears the prop (reverting to the\n * manifest default, matching the asset/relation/object controls); anything else is a\n * structured `JsonValue` envelope set verbatim. Extracted pure so the wiring — the\n * exact bug the retired textarea stub had (it wrote a bare string over the envelope) —\n * is regression-pinned without driving TipTap.\n */\nexport function applyRichTextPropChange(\n next: unknown,\n handlers: { onSet: (value: JsonValue) => void; onClear: () => void },\n): void {\n if (next === undefined) handlers.onClear()\n else handlers.onSet(next as JsonValue)\n}\n\nexport interface PropValueControlProps {\n /** DOM id for the control's primary input (label `htmlFor` target). */\n id: string\n /** The prop's field name — needed to synthesize the `FieldDef` for reused controls. */\n name: string\n /** The manifest prop field-def driving the control kind + validation. */\n spec: PropField\n /** The prop's current value envelope (or `undefined` when unset). */\n value: PropValue | undefined\n /** Commit a new raw value (the caller wraps it in a `staticProp`). */\n onSet: (value: JsonValue) => void\n /** Remove the prop (revert to the manifest default). */\n onClear: () => void\n}\n\n/**\n * Render + edit a single manifest prop value. Store-agnostic: emits through\n * `onSet`/`onClear`. Shows a validation issue when the current value fails the\n * prop's field-def validator.\n */\nexport function PropValueControl({ id, name, spec, value, onSet, onClear }: PropValueControlProps) {\n const current = isStaticProp(value) ? value.value : (spec.default as JsonValue | undefined)\n // The `asset`/`relation`/`object` controls delegate to the CMS `FieldControl`,\n // which reads the ambient `CollectionViewSource` (asset library, relation\n // candidates, nested form). The component-registry preview surface has no\n // document/collection context, so outside a provider those controls must degrade\n // to a read-only value display instead of throwing \"useCollectionView must be\n // used within a <CollectionViewProvider>\" (the Konditorei Components-view crash).\n const hasWorkspaceContext = useOptionalCollectionView() != null\n\n // EC-190: validate with the prop's field-def value validator.\n const valid = current === undefined || fieldValueValidator({ ...spec, name } as FieldDef)(current)\n // EC-190: derive the editor control from the field `type` + optional `form.control`.\n const kind = controlKind(spec)\n // Select options live on the `select` field-def.\n const options: readonly SelectOption[] = spec.type === 'select' ? spec.options : []\n // EC-395: `form.readOnly` parity with the document form. `cms-store.tsx`'s\n // `isFieldReadOnly` reads the identical `field.form?.readOnly === true` check —\n // every control kind below (including the delegated `FieldControl`/\n // `SegmentedOptions` mounts, which previously hardcoded `readOnly={false}`)\n // degrades to the SAME disabled/inert interaction the document form's\n // `FieldControl` renders for a read-only field, not a parallel treatment.\n const readOnly = spec.form?.readOnly === true\n\n let control\n if (kind === 'boolean') {\n control = (\n <label className=\"flex h-8 items-center gap-2 text-sm\">\n <input\n id={id}\n type=\"checkbox\"\n checked={current === true}\n disabled={readOnly}\n onChange={(e) => onSet(e.target.checked)}\n className=\"size-4 accent-primary disabled:opacity-50\"\n />\n <Text size=\"sm\" tone=\"muted\">\n {current === true ? translate('common.true') : translate('common.false')}\n </Text>\n </label>\n )\n } else if (kind === 'select') {\n control = (\n <Select\n id={id}\n disabled={readOnly}\n value={String(current ?? '')}\n onChange={(e) => {\n // EC-190: select option values are strings (field-def `options`).\n const opt = options.find((o) => o.value === e.target.value)\n onSet(opt ? opt.value : e.target.value)\n }}\n >\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {localizedLabel(opt.label, opt.value)}\n </option>\n ))}\n </Select>\n )\n } else if (kind === 'options') {\n // EC-393: reuse the EC-295 segmented control the document form renders (via\n // `field-control.tsx`) — delegation over a parallel dropdown. It reads the\n // field-def's own `options` (label + per-option `description` tooltip); single-\n // select only (picks one, no unset — an unset select keeps the native dropdown).\n control = (\n <SegmentedOptions\n id={id}\n field={{ ...spec, name } as SelectFieldDef}\n value={current}\n onChange={(v) => onSet(v as JsonValue)}\n readOnly={readOnly}\n />\n )\n } else if (kind === 'number') {\n control = (\n <NumberControl id={id} current={current} onSet={onSet} onClear={onClear} readOnly={readOnly} />\n )\n } else if (kind === 'json') {\n control = <JsonControl id={id} current={current} onSet={onSet} readOnly={readOnly} />\n } else if (kind === 'color') {\n control = (\n <Row gap=\"2\">\n <input\n id={id}\n type=\"color\"\n disabled={readOnly}\n value={typeof current === 'string' && /^#[0-9a-f]{6}$/i.test(current) ? current : '#000000'}\n onChange={(e) => onSet(e.target.value)}\n className=\"h-8 w-10 shrink-0 rounded-md border border-input bg-background disabled:opacity-50\"\n />\n <Input\n disabled={readOnly}\n value={typeof current === 'string' ? current : ''}\n onChange={(e) => onSet(e.target.value)}\n />\n </Row>\n )\n } else if (kind === 'richtext') {\n // EC-387: a richText PROP now uses the SAME real editor as the collection-field\n // path (`field-control.tsx` `case 'richText'`) — one editing surface, one\n // `{ version, doc }` value contract, never a second implementation. The retired\n // textarea stub read `typeof current === 'string'`, so a stored envelope showed\n // EMPTY and any edit clobbered the structured document with a bare string\n // (silent data destruction). The editor reads the envelope (or a legacy string,\n // or empty), always emits an envelope, and routes an emptied editor's `undefined`\n // to a prop clear via {@link applyRichTextPropChange}.\n //\n // Like the asset/relation/object controls below, the editor needs the ambient\n // workspace — its asset-image picker reads the REQUIRED collection-view context.\n // The block property inspector (the EC-387 target) is inside the detail editor's\n // `CollectionViewProvider`, so it gets the full editor; the component-registry\n // preview surface (no provider, nothing to edit against) degrades to the same\n // read-only value display the sibling controls use, instead of crashing with\n // \"useCollectionView must be used within a <CollectionViewProvider>\".\n control = hasWorkspaceContext ? (\n <RichTextEditor\n id={id}\n value={current}\n onChange={(next) => applyRichTextPropChange(next, { onSet, onClear })}\n allow={spec.type === 'richText' ? spec.allow : undefined}\n readOnly={readOnly}\n />\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else if (kind === 'textarea') {\n control = (\n <textarea\n id={id}\n rows={2}\n disabled={readOnly}\n value={typeof current === 'string' ? current : ''}\n onChange={(e) => onSet(e.target.value)}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 text-sm text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50\"\n />\n )\n } else if (kind === 'asset' || kind === 'object' || kind === 'relation') {\n // EC-195/EC-253/EC-262: reuse the CMS field control. `asset` = library picker +\n // preview; `object` = the nested/repeater form; `relation` = the document picker\n // (resolves the ref to its title, instead of stringifying it to \"[object Object]\").\n // All edit a structured static prop value through the same shared control documents use.\n // Without a workspace context (the Components preview), degrade to a read-only\n // value display so the pane renders instead of throwing.\n control = hasWorkspaceContext ? (\n <FieldDensityProvider density=\"compact\">\n <FieldControl\n id={id}\n field={{ ...spec, name } as FieldDef}\n value={current}\n onChange={(v) => (v === undefined || v === null ? onClear() : onSet(v as JsonValue))}\n readOnly={readOnly}\n />\n </FieldDensityProvider>\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else {\n control = (\n <Input\n id={id}\n disabled={readOnly}\n value={typeof current === 'string' ? current : String(current ?? '')}\n onChange={(e) => onSet(e.target.value)}\n />\n )\n }\n\n return (\n <Stack gap=\"1\">\n {control}\n {/* EC-395: a read-only prop's value can't be fixed here — suppress the\n invalid-value flag exactly like the document form suppresses its field\n error on a read-only row (`detail-editor.tsx`'s\n `error={fieldReadOnly ? undefined : ...}`). */}\n {!valid && !readOnly ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {translate('builder.inspector.invalidValue')}\n </Text>\n ) : null}\n </Stack>\n )\n}\n\n/**\n * Read-only stand-in for an `asset`/`relation`/`object` prop when there is no\n * ambient `CollectionViewSource` (the component-registry preview, which has no\n * document/collection context). Shows the current value and a hint that it is\n * editable inside a document — never the live picker, which needs a workspace.\n */\nfunction WorkspaceValueFallback({ value }: { value: JsonValue | undefined }) {\n const text =\n value === undefined || value === null\n ? '—'\n : typeof value === 'string'\n ? value\n : JSON.stringify(value)\n return (\n <Stack gap=\"1\">\n <div className=\"truncate rounded-md border border-input bg-muted/30 px-2.5 py-1.5 text-sm text-muted-foreground\">\n {text}\n </div>\n <Text size=\"xs\" tone=\"muted\">\n {translate('components.preview.propNeedsDocument')}\n </Text>\n </Stack>\n )\n}\n\n/** Number input with a local buffer: commits only finite values, never NaN; empty clears the prop. */\nfunction NumberControl({\n id,\n current,\n onSet,\n onClear,\n readOnly,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: number) => void\n onClear: () => void\n readOnly: boolean\n}) {\n const [raw, setRaw] = useState(typeof current === 'number' ? String(current) : '')\n useEffect(() => {\n setRaw(typeof current === 'number' ? String(current) : '')\n }, [current])\n return (\n <Input\n id={id}\n type=\"number\"\n disabled={readOnly}\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n if (v.trim() === '') {\n onClear()\n return\n }\n const n = Number(v)\n if (Number.isFinite(n)) onSet(n)\n }}\n />\n )\n}\n\n/** JSON textarea with a local buffer: commits only when the text parses; flags parse errors. */\nfunction JsonControl({\n id,\n current,\n onSet,\n readOnly,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: JsonValue) => void\n readOnly: boolean\n}) {\n const [raw, setRaw] = useState(() => JSON.stringify(current ?? null))\n const [error, setError] = useState<string | null>(null)\n useEffect(() => {\n setRaw(JSON.stringify(current ?? null))\n setError(null)\n }, [current])\n return (\n <Stack gap=\"1\">\n <textarea\n id={id}\n rows={3}\n disabled={readOnly}\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n try {\n onSet(JSON.parse(v) as JsonValue)\n setError(null)\n } catch {\n setError(translate('builder.inspector.invalidJson'))\n }\n }}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50\"\n />\n {error ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {error}\n </Text>\n ) : null}\n </Stack>\n )\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CmsDocument, CollectionDef } from '@elytracms/core/cms-core';
|
|
2
|
+
import type { ManifestResolver } from '@elytracms/core/component-registry';
|
|
3
|
+
/**
|
|
4
|
+
* EC-425 — THE publish-time hidden-strip, extracted so single-document publish
|
|
5
|
+
* (`doPublish`, use-publish-controller) and bulk publish (`runBulk`, cms-store)
|
|
6
|
+
* share ONE clean step instead of the bulk bar bypassing it:
|
|
7
|
+
*
|
|
8
|
+
* - EC-273 `clearHiddenValues`: drop conditionally-hidden document field values
|
|
9
|
+
* (predicate-hidden, non-`retainWhenHidden`) from `values`/`localized`.
|
|
10
|
+
* - EC-394 `clearHiddenProps`: the same strip for component props across every
|
|
11
|
+
* `blocks`/canvas composition, so a hidden relation/asset prop's ref leaves
|
|
12
|
+
* the EC-277 reference index (derived from the stored draft at the EC-286
|
|
13
|
+
* write chokepoint) and stops blocking its target's delete/unpublish.
|
|
14
|
+
*
|
|
15
|
+
* The manifests resolve through the SESSION registry by default (client-side-
|
|
16
|
+
* with-user-session, the ratified trust boundary — same binding `doPublish`
|
|
17
|
+
* used inline since EC-394); tests inject a resolver to pin behaviour against
|
|
18
|
+
* fixture manifests. Identity-preserving: returns the input document when
|
|
19
|
+
* nothing clears, so callers can save-if-changed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function cleanHiddenForPublish(collection: CollectionDef, doc: CmsDocument, resolveManifest?: ManifestResolver): CmsDocument;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { clearHiddenValues } from '@elytracms/core/cms-core';
|
|
2
|
+
import { clearHiddenProps } from '@elytracms/core/component-registry';
|
|
3
|
+
import { getStudioRegistry } from '@elytracms/studio/lib/registry';
|
|
4
|
+
/**
|
|
5
|
+
* EC-425 — THE publish-time hidden-strip, extracted so single-document publish
|
|
6
|
+
* (`doPublish`, use-publish-controller) and bulk publish (`runBulk`, cms-store)
|
|
7
|
+
* share ONE clean step instead of the bulk bar bypassing it:
|
|
8
|
+
*
|
|
9
|
+
* - EC-273 `clearHiddenValues`: drop conditionally-hidden document field values
|
|
10
|
+
* (predicate-hidden, non-`retainWhenHidden`) from `values`/`localized`.
|
|
11
|
+
* - EC-394 `clearHiddenProps`: the same strip for component props across every
|
|
12
|
+
* `blocks`/canvas composition, so a hidden relation/asset prop's ref leaves
|
|
13
|
+
* the EC-277 reference index (derived from the stored draft at the EC-286
|
|
14
|
+
* write chokepoint) and stops blocking its target's delete/unpublish.
|
|
15
|
+
*
|
|
16
|
+
* The manifests resolve through the SESSION registry by default (client-side-
|
|
17
|
+
* with-user-session, the ratified trust boundary — same binding `doPublish`
|
|
18
|
+
* used inline since EC-394); tests inject a resolver to pin behaviour against
|
|
19
|
+
* fixture manifests. Identity-preserving: returns the input document when
|
|
20
|
+
* nothing clears, so callers can save-if-changed.
|
|
21
|
+
*/
|
|
22
|
+
export function cleanHiddenForPublish(collection, doc, resolveManifest = sessionManifestResolver()) {
|
|
23
|
+
return clearHiddenProps(collection, clearHiddenValues(collection, doc), resolveManifest);
|
|
24
|
+
}
|
|
25
|
+
/** The session component registry as a {@link ManifestResolver}. */
|
|
26
|
+
function sessionManifestResolver() {
|
|
27
|
+
const { registry } = getStudioRegistry();
|
|
28
|
+
return (id) => registry.getManifest(id);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=publish-clean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-clean.js","sourceRoot":"","sources":["../../../src/components/cms/publish-clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAyB,EACzB,GAAgB,EAChB,kBAAoC,uBAAuB,EAAE;IAE7D,OAAO,gBAAgB,CAAC,UAAU,EAAE,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,eAAe,CAAC,CAAA;AAC1F,CAAC;AAED,oEAAoE;AACpE,SAAS,uBAAuB;IAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,iBAAiB,EAAE,CAAA;IACxC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;AACzC,CAAC","sourcesContent":["import { clearHiddenValues } from '@elytracms/core/cms-core'\nimport type { CmsDocument, CollectionDef } from '@elytracms/core/cms-core'\nimport { clearHiddenProps } from '@elytracms/core/component-registry'\nimport type { ManifestResolver } from '@elytracms/core/component-registry'\nimport { getStudioRegistry } from '@elytracms/studio/lib/registry'\n\n/**\n * EC-425 — THE publish-time hidden-strip, extracted so single-document publish\n * (`doPublish`, use-publish-controller) and bulk publish (`runBulk`, cms-store)\n * share ONE clean step instead of the bulk bar bypassing it:\n *\n * - EC-273 `clearHiddenValues`: drop conditionally-hidden document field values\n * (predicate-hidden, non-`retainWhenHidden`) from `values`/`localized`.\n * - EC-394 `clearHiddenProps`: the same strip for component props across every\n * `blocks`/canvas composition, so a hidden relation/asset prop's ref leaves\n * the EC-277 reference index (derived from the stored draft at the EC-286\n * write chokepoint) and stops blocking its target's delete/unpublish.\n *\n * The manifests resolve through the SESSION registry by default (client-side-\n * with-user-session, the ratified trust boundary — same binding `doPublish`\n * used inline since EC-394); tests inject a resolver to pin behaviour against\n * fixture manifests. Identity-preserving: returns the input document when\n * nothing clears, so callers can save-if-changed.\n */\nexport function cleanHiddenForPublish(\n collection: CollectionDef,\n doc: CmsDocument,\n resolveManifest: ManifestResolver = sessionManifestResolver(),\n): CmsDocument {\n return clearHiddenProps(collection, clearHiddenValues(collection, doc), resolveManifest)\n}\n\n/** The session component registry as a {@link ManifestResolver}. */\nfunction sessionManifestResolver(): ManifestResolver {\n const { registry } = getStudioRegistry()\n return (id) => registry.getManifest(id)\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CmsDocument, CollectionDef, Locale } from '@elytracms/core/cms-core';
|
|
1
|
+
import type { CmsDocument, CollectionDef, DocumentUrl, Locale, LocaleConfig, RouteRecord } from '@elytracms/core/cms-core';
|
|
2
2
|
import type { CollectionViewSource } from '@elytracms/studio/lib/collection-view/collection-view-source';
|
|
3
3
|
/** The header's live-link descriptor: an `href` (open live) + a title, or a muted
|
|
4
4
|
* reason-only title while it isn't openable (loading / publish-first / no frontendUrl). */
|
|
@@ -23,6 +23,29 @@ export declare function resolveHeaderLive(input: {
|
|
|
23
23
|
loading: boolean;
|
|
24
24
|
published: boolean;
|
|
25
25
|
}): HeaderLive | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* EC-384 — derive a published document's live URL against the project's STORED
|
|
28
|
+
* config routes MERGED with the kit's implicit `/` → first-published-page
|
|
29
|
+
* fallback (EC-368/EC-187) — the exact same `mergeRouteRecords`/
|
|
30
|
+
* `fallbackHomeRoutes` pair the delivery resolver merges through
|
|
31
|
+
* (`@elytracms/core/cms-core`), so the studio and delivery can never disagree
|
|
32
|
+
* about a fallback-addressed home page's URL. Pure (no React), so it is
|
|
33
|
+
* unit-tested directly rather than through the hook. `siblings` doubles as the
|
|
34
|
+
* fallback's candidate pool: when `collection` is the `page` collection it IS
|
|
35
|
+
* the published `page` pool the fallback rule needs; for any other collection
|
|
36
|
+
* the derived fallback routes simply address no route of `collection` (a
|
|
37
|
+
* harmless no-op — `urlForDocument` only matches routes whose `document.collection`
|
|
38
|
+
* equals the target collection).
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveDocumentLiveUrl(input: {
|
|
41
|
+
routes: readonly RouteRecord[];
|
|
42
|
+
localeConfig: LocaleConfig;
|
|
43
|
+
frontendUrl: string | undefined;
|
|
44
|
+
collection: CollectionDef;
|
|
45
|
+
doc: CmsDocument;
|
|
46
|
+
siblings: readonly CmsDocument[];
|
|
47
|
+
locale: Locale;
|
|
48
|
+
}): DocumentUrl | undefined;
|
|
26
49
|
/**
|
|
27
50
|
* EC-205 / EC-216 — the LIVE URL derives strictly from PUBLISHED data (the pinned
|
|
28
51
|
* published snapshot + its published ancestors), never the draft, so an unpublished
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import { urlForDocument } from '@elytracms/core/cms-core';
|
|
2
|
+
import { fallbackHomeRoutes, mergeRouteRecords, urlForDocument } from '@elytracms/core/cms-core';
|
|
3
3
|
import { translate } from '@elytracms/studio/lib/i18n';
|
|
4
4
|
import { resolveDeploymentFrontendUrl, resolveDeploymentRoutes } from '@elytracms/studio/lib/workspace';
|
|
5
5
|
import { usePublishedDocuments } from '@elytracms/studio/lib/cms/published-documents';
|
|
@@ -25,6 +25,24 @@ export function resolveHeaderLive(input) {
|
|
|
25
25
|
: translate('cms.editor.setFrontendUrlHint'),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* EC-384 — derive a published document's live URL against the project's STORED
|
|
30
|
+
* config routes MERGED with the kit's implicit `/` → first-published-page
|
|
31
|
+
* fallback (EC-368/EC-187) — the exact same `mergeRouteRecords`/
|
|
32
|
+
* `fallbackHomeRoutes` pair the delivery resolver merges through
|
|
33
|
+
* (`@elytracms/core/cms-core`), so the studio and delivery can never disagree
|
|
34
|
+
* about a fallback-addressed home page's URL. Pure (no React), so it is
|
|
35
|
+
* unit-tested directly rather than through the hook. `siblings` doubles as the
|
|
36
|
+
* fallback's candidate pool: when `collection` is the `page` collection it IS
|
|
37
|
+
* the published `page` pool the fallback rule needs; for any other collection
|
|
38
|
+
* the derived fallback routes simply address no route of `collection` (a
|
|
39
|
+
* harmless no-op — `urlForDocument` only matches routes whose `document.collection`
|
|
40
|
+
* equals the target collection).
|
|
41
|
+
*/
|
|
42
|
+
export function resolveDocumentLiveUrl(input) {
|
|
43
|
+
const routes = mergeRouteRecords(input.routes, fallbackHomeRoutes(input.siblings, input.localeConfig));
|
|
44
|
+
return urlForDocument({ routes, frontendUrl: input.frontendUrl, localeConfig: input.localeConfig }, input.collection, input.doc, { siblings: input.siblings, locale: input.locale });
|
|
45
|
+
}
|
|
28
46
|
/**
|
|
29
47
|
* EC-205 / EC-216 — the LIVE URL derives strictly from PUBLISHED data (the pinned
|
|
30
48
|
* published snapshot + its published ancestors), never the draft, so an unpublished
|
|
@@ -38,11 +56,15 @@ export function useLiveUrl(input) {
|
|
|
38
56
|
const publishedDoc = publishedDocs.byId.get(doc.id);
|
|
39
57
|
if (!publishedDoc)
|
|
40
58
|
return undefined;
|
|
41
|
-
return
|
|
59
|
+
return resolveDocumentLiveUrl({
|
|
42
60
|
routes: resolveDeploymentRoutes(),
|
|
43
|
-
frontendUrl: resolveDeploymentFrontendUrl(),
|
|
44
61
|
localeConfig: source.localeConfig,
|
|
45
|
-
|
|
62
|
+
frontendUrl: resolveDeploymentFrontendUrl(),
|
|
63
|
+
collection,
|
|
64
|
+
doc: publishedDoc,
|
|
65
|
+
siblings: [...publishedDocs.byId.values()],
|
|
66
|
+
locale,
|
|
67
|
+
});
|
|
46
68
|
}, [publishedDocs, collection, doc.id, locale, source.localeConfig]);
|
|
47
69
|
const headerLive = resolveHeaderLive({
|
|
48
70
|
routableCollection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-live-url.js","sourceRoot":"","sources":["../../../src/components/cms/use-live-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"use-live-url.js","sourceRoot":"","sources":["../../../src/components/cms/use-live-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAUhG,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACvG,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAA;AASrF;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAKjC;IACC,IAAI,CAAC,KAAK,CAAC,kBAAkB;QAAE,OAAO,SAAS,CAAA;IAC/C,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;QACxB,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAA;IAC/G,CAAC;IACD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,OAAO;YAClB,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC;YACxC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS;gBAChB,CAAC,CAAC,SAAS,CAAC,8BAA8B,CAAC;gBAC3C,CAAC,CAAC,SAAS,CAAC,+BAA+B,CAAC;KACjD,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,C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Y,CAAC,CAAC,CAAA;IAEpE,MAAM,UAAU,GAAG,iBAAiB,CAAC;QACnC,kBAAkB;QAClB,OAAO;QACP,OAAO,EAAE,aAAa,CAAC,MAAM,KAAK,SAAS;QAC3C,SAAS;KACV,CAAC,CAAA;IACF,OAAO,EAAE,UAAU,EAAE,CAAA;AACvB,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { fallbackHomeRoutes, mergeRouteRecords, urlForDocument } from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n DocumentUrl,\n Locale,\n LocaleConfig,\n RouteRecord,\n} from '@elytracms/core/cms-core'\nimport type { CollectionViewSource } from '@elytracms/studio/lib/collection-view/collection-view-source'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { resolveDeploymentFrontendUrl, resolveDeploymentRoutes } from '@elytracms/studio/lib/workspace'\nimport { usePublishedDocuments } from '@elytracms/studio/lib/cms/published-documents'\n\n/** The header's live-link descriptor: an `href` (open live) + a title, or a muted\n * reason-only title while it isn't openable (loading / publish-first / no frontendUrl). */\nexport interface HeaderLive {\n href?: string\n title: string\n}\n\n/**\n * 0.0.42 (round 3) — the header composed-URL row's open-live affordance, as a pure\n * decision. Only a routable collection shows the row; its leaf opens the live page\n * when the doc is published AND a frontendUrl is set (an absolute `href`),\n * otherwise it is a muted icon whose tooltip explains WHY (still loading, publish\n * first, or set the frontendUrl). The draft-derived path itself updates as you\n * type — only the OPEN-live action is published-gated, preserving draft/live.\n */\nexport function resolveHeaderLive(input: {\n routableCollection: boolean\n liveUrl: { href?: string; path: string } | undefined\n loading: boolean\n published: boolean\n}): HeaderLive | undefined {\n if (!input.routableCollection) return undefined\n if (input.liveUrl?.href) {\n return { href: input.liveUrl.href, title: translate('cms.editor.openLiveUrl', { path: input.liveUrl.path }) }\n }\n return {\n title: input.loading\n ? translate('cms.editor.loadingLiveUrl')\n : !input.published\n ? translate('cms.editor.publishToViewLive')\n : translate('cms.editor.setFrontendUrlHint'),\n }\n}\n\n/**\n * EC-384 — derive a published document's live URL against the project's STORED\n * config routes MERGED with the kit's implicit `/` → first-published-page\n * fallback (EC-368/EC-187) — the exact same `mergeRouteRecords`/\n * `fallbackHomeRoutes` pair the delivery resolver merges through\n * (`@elytracms/core/cms-core`), so the studio and delivery can never disagree\n * about a fallback-addressed home page's URL. Pure (no React), so it is\n * unit-tested directly rather than through the hook. `siblings` doubles as the\n * fallback's candidate pool: when `collection` is the `page` collection it IS\n * the published `page` pool the fallback rule needs; for any other collection\n * the derived fallback routes simply address no route of `collection` (a\n * harmless no-op — `urlForDocument` only matches routes whose `document.collection`\n * equals the target collection).\n */\nexport function resolveDocumentLiveUrl(input: {\n routes: readonly RouteRecord[]\n localeConfig: LocaleConfig\n frontendUrl: string | undefined\n collection: CollectionDef\n doc: CmsDocument\n siblings: readonly CmsDocument[]\n locale: Locale\n}): DocumentUrl | undefined {\n const routes = mergeRouteRecords(input.routes, fallbackHomeRoutes(input.siblings, input.localeConfig))\n return urlForDocument(\n { routes, frontendUrl: input.frontendUrl, localeConfig: input.localeConfig },\n input.collection,\n input.doc,\n { siblings: input.siblings, locale: input.locale },\n )\n}\n\n/**\n * EC-205 / EC-216 — the LIVE URL derives strictly from PUBLISHED data (the pinned\n * published snapshot + its published ancestors), never the draft, so an unpublished\n * slug/parent edit can't leak into the live URL. Resolves the header's live-link\n * descriptor for the composed-URL row; `undefined` for a non-routable collection.\n */\nexport function useLiveUrl(input: {\n source: CollectionViewSource\n collection: CollectionDef\n doc: CmsDocument\n locale: Locale\n published: boolean\n routableCollection: boolean\n}): { headerLive: HeaderLive | undefined } {\n const { source, collection, doc, locale, published, routableCollection } = input\n const publishedDocs = usePublishedDocuments(source.projectId, collection.id)\n const liveUrl = useMemo(() => {\n const publishedDoc = publishedDocs.byId.get(doc.id)\n if (!publishedDoc) return undefined\n return resolveDocumentLiveUrl({\n routes: resolveDeploymentRoutes(),\n localeConfig: source.localeConfig,\n frontendUrl: resolveDeploymentFrontendUrl(),\n collection,\n doc: publishedDoc,\n siblings: [...publishedDocs.byId.values()],\n locale,\n })\n }, [publishedDocs, collection, doc.id, locale, source.localeConfig])\n\n const headerLive = resolveHeaderLive({\n routableCollection,\n liveUrl,\n loading: publishedDocs.status === 'loading',\n published,\n })\n return { headerLive }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useRef, useState } from 'react';
|
|
2
2
|
import { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router';
|
|
3
|
-
import {
|
|
3
|
+
import { cleanHiddenForPublish } from './publish-clean.js';
|
|
4
4
|
import { toast } from '@elytracms/studio/ui';
|
|
5
5
|
import { translate } from '@elytracms/studio/lib/i18n';
|
|
6
6
|
/**
|
|
@@ -37,11 +37,13 @@ export function usePublishController(input) {
|
|
|
37
37
|
// dialog so a successful publish returns to the list. Cleared on cancel or failure.
|
|
38
38
|
const closeAfterPublishRef = useRef(false);
|
|
39
39
|
const doPublish = useCallback(async () => {
|
|
40
|
-
// EC-273
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
40
|
+
// EC-273/EC-394 via the SHARED clean step (EC-425, also run by bulk publish):
|
|
41
|
+
// clean conditionally-hidden field values AND component props from the draft
|
|
42
|
+
// AT PUBLISH TIME — into the draft AND the snapshot, so both go clean
|
|
43
|
+
// together. Also captures the latest edit if Publish fires inside the
|
|
44
|
+
// autosave debounce window; the serial persister runs the upsert before the
|
|
45
|
+
// publish so the snapshot is this draft.
|
|
46
|
+
const cleaned = cleanHiddenForPublish(collection, draft);
|
|
45
47
|
if (cleaned !== draft)
|
|
46
48
|
setDraft(cleaned);
|
|
47
49
|
if (cleaned !== draft || dirty)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-publish-controller.js","sourceRoot":"","sources":["../../../src/components/cms/use-publish-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,M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;QACL,YAAY;QACZ,cAAc;QACd,aAAa;QACb,qBAAqB;QACrB,cAAc;QACd,oBAAoB;KACrB,CAAA;AACH,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react'\nimport { STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router'\nimport type { CmsDocument, CollectionDef, DocumentRef } from '@elytracms/core/cms-core'\nimport type { CollectionViewSource } from '@elytracms/studio/lib/collection-view/collection-view-source'\nimport { cleanHiddenForPublish } from './publish-clean'\nimport { toast } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\n\nexport type PublishState = 'idle' | 'pending' | 'success'\n\n/**\n * EC-268 / 0.0.39 — the split Publish button's shared gate, computed once so the\n * primary \"Publish\" and the \"Publish & close\" item can never diverge. A pure\n * decision (directly testable): the Published perspective is read-only (switch to\n * Draft to publish), schema errors block (with a count-aware hint), and an\n * in-flight publish disables re-entry.\n */\nexport function publishGate(input: {\n hasErrors: boolean\n viewReadOnly: boolean\n publishState: PublishState\n errorCount: number\n}): { disabled: boolean; title: string | undefined } {\n const disabled = input.hasErrors || input.viewReadOnly || input.publishState === 'pending'\n const title = input.viewReadOnly\n ? translate('cms.editor.switchToDraftToPublish')\n : input.hasErrors\n ? translate(\n input.errorCount === 1\n ? 'cms.editor.fixIssuesToPublish.one'\n : 'cms.editor.fixIssuesToPublish.other',\n { count: input.errorCount },\n )\n : undefined\n return { disabled, title }\n}\n\nexport interface PublishController {\n publishState: PublishState\n /** Is the confirm-through dialog (unpublished hard refs) open? */\n publishConfirm: boolean\n /** Publish (opening the confirm-through dialog first if there are unpublished refs). */\n handlePublish: () => void\n /** Publish and, on success, return to the rail's list (0.0.39 \"Publish & close\"). */\n handlePublishAndClose: () => void\n /** Confirm-through: publish despite the unpublished hard references. */\n confirmPublish: () => void\n /** Dismiss the confirm-through dialog (also clears a pending \"& close\" intent). */\n cancelPublishConfirm: () => void\n}\n\n/**\n * EC-268 / EC-300 / 0.0.39 — the publish controller. Owns the publish indicator\n * state, the EC-300 confirm-through guard (unpublished hard references would render\n * empty on the live site, so publishing confirms rather than blocks), and the\n * 0.0.39 \"Publish & close\" navigation (remembered across the confirm dialog via a\n * ref, so a successful publish returns to the rail-owned list).\n */\nexport function usePublishController(input: {\n source: CollectionViewSource\n docRef: DocumentRef\n collection: CollectionDef\n projectId: string\n draft: CmsDocument\n setDraft: (doc: CmsDocument) => void\n dirty: boolean\n hasUnpublishedRefs: boolean\n}): PublishController {\n const { source, docRef, collection, projectId, draft, setDraft, dirty, hasUnpublishedRefs } = input\n const navigate = useNavigate()\n const [publishState, setPublishState] = useState<PublishState>('idle')\n const [publishConfirm, setPublishConfirm] = useState(false)\n // The split-button \"Publish & close\" intent — remembered across the confirm-through\n // dialog so a successful publish returns to the list. Cleared on cancel or failure.\n const closeAfterPublishRef = useRef(false)\n\n const doPublish = useCallback(async () => {\n // EC-273/EC-394 via the SHARED clean step (EC-425, also run by bulk publish):\n // clean conditionally-hidden field values AND component props from the draft\n // AT PUBLISH TIME — into the draft AND the snapshot, so both go clean\n // together. Also captures the latest edit if Publish fires inside the\n // autosave debounce window; the serial persister runs the upsert before the\n // publish so the snapshot is this draft.\n const cleaned = cleanHiddenForPublish(collection, draft)\n if (cleaned !== draft) setDraft(cleaned)\n if (cleaned !== draft || dirty) source.save(cleaned)\n setPublishState('pending')\n try {\n await source.publishing?.publish(docRef)\n setPublishState('success')\n setTimeout(() => setPublishState('idle'), 1800)\n // \"Publish & close\": return to the list once the publish landed (never on a\n // failure). Rail-owned `listPath`, falling back to the project index (AD-19).\n if (closeAfterPublishRef.current) {\n closeAfterPublishRef.current = false\n void navigate({\n to: STUDIO_PROJECT_ROUTE,\n params: { projectId, _splat: source.listPath ?? studioPath.index() },\n })\n }\n } catch (error) {\n closeAfterPublishRef.current = false\n setPublishState('idle')\n toast.error(\n error instanceof Error\n ? translate('cms.editor.publishFailedReason', { error: error.message })\n : translate('cms.editor.publishFailed'),\n )\n }\n }, [collection, draft, setDraft, dirty, source, docRef, navigate, projectId])\n\n // Gate publish on the confirm-through dialog when there are unpublished hard\n // references; schema errors already disable the button, so they never reach here.\n const handlePublish = useCallback(() => {\n if (hasUnpublishedRefs) {\n setPublishConfirm(true)\n return\n }\n void doPublish()\n }, [hasUnpublishedRefs, doPublish])\n\n const handlePublishAndClose = useCallback(() => {\n closeAfterPublishRef.current = true\n handlePublish()\n }, [handlePublish])\n\n const confirmPublish = useCallback(() => {\n setPublishConfirm(false)\n void doPublish()\n }, [doPublish])\n\n const cancelPublishConfirm = useCallback(() => {\n setPublishConfirm(false)\n closeAfterPublishRef.current = false\n }, [])\n\n return {\n publishState,\n publishConfirm,\n handlePublish,\n handlePublishAndClose,\n confirmPublish,\n cancelPublishConfirm,\n }\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { isHierarchical
|
|
2
|
+
import { isHierarchical } from '@elytracms/core/cms-core';
|
|
3
3
|
import { studioPath } from '@elytracms/studio/router';
|
|
4
4
|
import { resolveDeploymentFrontendUrl, resolveDeploymentRoutes } from '@elytracms/studio/lib/workspace';
|
|
5
5
|
import { useCms } from '../cms/cms-store.js';
|
|
6
6
|
import { useOptionalAssets } from '../assets/assets-store.js';
|
|
7
7
|
import { usePublishedDocuments } from '@elytracms/studio/lib/cms/published-documents';
|
|
8
|
+
import { resolveDocumentLiveUrl } from '../cms/use-live-url.js';
|
|
8
9
|
/**
|
|
9
10
|
* Assemble a {@link CollectionViewSource} for a `cmsDocuments` collection from the
|
|
10
11
|
* ambient `CmsStore` + its side contexts (assets, published pool) + the
|
|
@@ -28,18 +29,25 @@ export function useCmsCollectionViewSource(collectionId) {
|
|
|
28
29
|
// Live-URL column: the published pool × deployment routes, memoised exactly as
|
|
29
30
|
// the table did — derived from PUBLISHED snapshots, never draft rows (EC-205).
|
|
30
31
|
const isRoutable = useMemo(() => resolveDeploymentRoutes().some((route) => route.document?.collection === collectionId), [collectionId]);
|
|
32
|
+
// EC-384: `resolveDocumentLiveUrl` merges the stored routes with the kit's
|
|
33
|
+
// fallback-home rule (same as the document editor's header affordance,
|
|
34
|
+
// `use-live-url.ts`) — otherwise a fallback-addressed home page showed no URL
|
|
35
|
+
// in this column even though the live site serves it.
|
|
31
36
|
const liveUrlMap = useMemo(() => {
|
|
32
37
|
if (!collection || !isRoutable)
|
|
33
38
|
return null;
|
|
34
|
-
const cfg = {
|
|
35
|
-
routes: resolveDeploymentRoutes(),
|
|
36
|
-
frontendUrl: resolveDeploymentFrontendUrl(),
|
|
37
|
-
localeConfig: cms.localeConfig,
|
|
38
|
-
};
|
|
39
39
|
const siblings = [...publishedDocs.byId.values()];
|
|
40
40
|
const map = new Map();
|
|
41
41
|
for (const published of siblings) {
|
|
42
|
-
const url =
|
|
42
|
+
const url = resolveDocumentLiveUrl({
|
|
43
|
+
routes: resolveDeploymentRoutes(),
|
|
44
|
+
frontendUrl: resolveDeploymentFrontendUrl(),
|
|
45
|
+
localeConfig: cms.localeConfig,
|
|
46
|
+
collection,
|
|
47
|
+
doc: published,
|
|
48
|
+
siblings,
|
|
49
|
+
locale: cms.activeLocale,
|
|
50
|
+
});
|
|
43
51
|
if (url)
|
|
44
52
|
map.set(published.id, url);
|
|
45
53
|
}
|