@elytracms/studio 0.0.66 → 0.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/components/builder/property-inspector.d.ts +0 -21
  2. package/dist/components/builder/property-inspector.js +5 -22
  3. package/dist/components/builder/property-inspector.js.map +1 -1
  4. package/dist/components/cms/asset-picker-core.d.ts +52 -0
  5. package/dist/components/cms/asset-picker-core.js +69 -0
  6. package/dist/components/cms/asset-picker-core.js.map +1 -0
  7. package/dist/components/cms/asset-picker.d.ts +16 -4
  8. package/dist/components/cms/asset-picker.js +34 -50
  9. package/dist/components/cms/asset-picker.js.map +1 -1
  10. package/dist/components/cms/detail-editor.js +45 -54
  11. package/dist/components/cms/detail-editor.js.map +1 -1
  12. package/dist/components/cms/prop-visibility.d.ts +3 -0
  13. package/dist/components/cms/prop-visibility.js +31 -0
  14. package/dist/components/cms/prop-visibility.js.map +1 -0
  15. package/dist/components/cms/rich-text/component-embed.d.ts +8 -6
  16. package/dist/components/cms/rich-text/component-embed.js +21 -62
  17. package/dist/components/cms/rich-text/component-embed.js.map +1 -1
  18. package/dist/components/cms/rich-text/editor.d.ts +13 -3
  19. package/dist/components/cms/rich-text/editor.js +36 -21
  20. package/dist/components/cms/rich-text/editor.js.map +1 -1
  21. package/dist/components/cms/rich-text/embed-props.d.ts +60 -27
  22. package/dist/components/cms/rich-text/embed-props.js +102 -45
  23. package/dist/components/cms/rich-text/embed-props.js.map +1 -1
  24. package/dist/lib/i18n/messages.de.js +1 -2
  25. package/dist/lib/i18n/messages.de.js.map +1 -1
  26. package/dist/lib/i18n/messages.en.d.ts +0 -1
  27. package/dist/lib/i18n/messages.en.js +1 -2
  28. package/dist/lib/i18n/messages.en.js.map +1 -1
  29. package/dist/ui/expandable-surface.d.ts +35 -25
  30. package/dist/ui/expandable-surface.js +41 -21
  31. package/dist/ui/expandable-surface.js.map +1 -1
  32. package/dist/ui/index.d.ts +1 -0
  33. package/dist/ui/index.js +1 -0
  34. package/dist/ui/index.js.map +1 -1
  35. package/dist/ui/surface-geometry.d.ts +68 -0
  36. package/dist/ui/surface-geometry.js +61 -0
  37. package/dist/ui/surface-geometry.js.map +1 -0
  38. package/package.json +2 -2
  39. package/src/styles/studio.css +30 -0
  40. package/dist/components/cms/rich-text/embed-inspector-context.d.ts +0 -50
  41. package/dist/components/cms/rich-text/embed-inspector-context.js +0 -12
  42. package/dist/components/cms/rich-text/embed-inspector-context.js.map +0 -1
  43. package/dist/components/cms/rich-text/embed-inspector.d.ts +0 -25
  44. package/dist/components/cms/rich-text/embed-inspector.js +0 -48
  45. package/dist/components/cms/rich-text/embed-inspector.js.map +0 -1
  46. package/dist/components/cms/use-embed-inspector-host.d.ts +0 -12
  47. package/dist/components/cms/use-embed-inspector-host.js +0 -17
  48. package/dist/components/cms/use-embed-inspector-host.js.map +0 -1
@@ -1,22 +1 @@
1
- import type { ComponentNode } from '@elytracms/core/project-graph';
2
- import type { ComponentManifest, PropField } from '@elytracms/core/component-registry';
3
1
  export declare function PropertyInspector(): import("react").JSX.Element;
4
- /**
5
- * The prop rows the inspector renders for a node (EC-393). Manifest props MINUS:
6
- * layout-managed props (they render in the Layout section, EC-162); `blocks` props
7
- * (they are child regions shown in Slots, EC-190); and any prop hidden RIGHT NOW by
8
- * its `form.hidden` — static `true`, or a predicate over the SIBLING prop values.
9
- *
10
- * The predicate's context is the component instance's EFFECTIVE prop values
11
- * (`effectivePropValues` — static values with manifest defaults filled), the prop
12
- * analogue of the document form's active-locale draft values (`isFieldHidden` there).
13
- * So a conditional row shows/hides live as a sibling prop changes and unmounts
14
- * exactly like a document-form field. Pure (no store) so the behaviour is testable.
15
- */
16
- export declare function visibleInspectorProps(manifest: ComponentManifest, node: ComponentNode, layoutManaged: ReadonlySet<string>): [string, PropField][];
17
- declare function PropField({ node, name, spec }: {
18
- node: ComponentNode;
19
- name: string;
20
- spec: PropField;
21
- }): import("react").JSX.Element;
22
- export {};
@@ -2,14 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { useEffect, useRef } from 'react';
3
3
  import { Lock } from 'lucide-react';
4
4
  import { staticProp } from '@elytracms/core/project-graph';
5
- import { effectivePropValues, manifestSlots } from '@elytracms/core/component-registry';
6
- import { isFieldHidden } from '@elytracms/core/cms-core';
5
+ import { manifestSlots } from '@elytracms/core/component-registry';
7
6
  import { getStudioRegistry } from '@elytracms/studio/lib/registry';
8
7
  import { Badge, Code, Field, InspectorSection, PanelHeader, Row, Spacer, Stack, Text, } from '@elytracms/studio/ui';
9
8
  import { humanizeName } from '@elytracms/studio/lib/utils';
10
9
  import { localizedLabel, translate } from '@elytracms/studio/lib/i18n';
11
10
  import { componentDisplayName } from '@elytracms/studio/lib/persona/labels';
12
11
  import { PropValueControl } from '../cms/prop-fields.js';
12
+ import { visiblePropFields } from '../cms/prop-visibility.js';
13
13
  import { useBuilder } from './builder-store.js';
14
14
  import { LayoutSection, layoutManagedPropNames } from './layout-inspector.js';
15
15
  import { usePropSync } from './prop-sync-context.js';
@@ -23,32 +23,15 @@ export function PropertyInspector() {
23
23
  const manifest = studio.registry.getManifest(node.componentId);
24
24
  return (_jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [_jsxs(PanelHeader, { children: [_jsx(Text, { size: "sm", weight: "semibold", children: translate('builder.inspector.title') }), _jsx(Spacer, {}), _jsx(Code, { tone: "muted", title: node.componentId, children: componentDisplayName(node.componentId, manifest) })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-auto", children: _jsx(SettingsTab, { node: node, manifest: manifest }) })] }));
25
25
  }
26
- /**
27
- * The prop rows the inspector renders for a node (EC-393). Manifest props MINUS:
28
- * layout-managed props (they render in the Layout section, EC-162); `blocks` props
29
- * (they are child regions shown in Slots, EC-190); and any prop hidden RIGHT NOW by
30
- * its `form.hidden` — static `true`, or a predicate over the SIBLING prop values.
31
- *
32
- * The predicate's context is the component instance's EFFECTIVE prop values
33
- * (`effectivePropValues` — static values with manifest defaults filled), the prop
34
- * analogue of the document form's active-locale draft values (`isFieldHidden` there).
35
- * So a conditional row shows/hides live as a sibling prop changes and unmounts
36
- * exactly like a document-form field. Pure (no store) so the behaviour is testable.
37
- */
38
- export function visibleInspectorProps(manifest, node, layoutManaged) {
39
- const ctx = { values: effectivePropValues(manifest, node) };
40
- return Object.entries(manifest.props).filter(([name, spec]) => !layoutManaged.has(name) &&
41
- spec.type !== 'blocks' &&
42
- !isFieldHidden({ ...spec, name }, ctx));
43
- }
44
26
  /** The full property surface: node identity, static props, condition, slots. */
45
27
  function SettingsTab({ node, manifest, }) {
46
28
  // Container layout props render in the dedicated Layout section (EC-162),
47
29
  // not as a second set of generic controls.
48
30
  const layoutManaged = new Set(layoutManagedPropNames(node));
49
31
  // EC-190: `blocks` props are slots; EC-393: `form.hidden` props are omitted —
50
- // evaluated against the node's effective sibling prop values, live as they change.
51
- const props = manifest ? visibleInspectorProps(manifest, node, layoutManaged) : [];
32
+ // evaluated against the node's effective sibling prop values, live as they change
33
+ // (the shared pure core in `cms/prop-visibility.ts`, EC-430).
34
+ const props = manifest ? visiblePropFields(manifest, node, layoutManaged) : [];
52
35
  const slots = manifest ? manifestSlots(manifest) : [];
53
36
  return (_jsxs(_Fragment, { children: [_jsx(LayoutSection, { node: node }), !manifest ? (_jsxs("div", { className: "p-3", children: [_jsx(Badge, { variant: "error", children: translate('builder.inspector.unknownComponent') }), _jsx(Text, { size: "xs", tone: "muted", className: "mt-2", children: translate('builder.inspector.noManifest') })] })) : (_jsx(InspectorSection, { title: translate('builder.inspector.props'), children: props.length === 0 ? (_jsx(Text, { size: "xs", tone: "subtle", children: translate('builder.inspector.noEditableProps') })) : (_jsx(Stack, { gap: "4", children: props.map(([name, spec]) => (_jsx(PropField, { node: node, name: name, spec: spec }, `${node.id}:${name}`))) })) })), slots.length > 0 ? (_jsxs(InspectorSection, { title: translate('builder.inspector.slots'), children: [_jsx(Stack, { gap: "1", children: slots.map((slot) => {
54
37
  const count = node.slots?.[slot.name]?.length ?? 0;
@@ -1 +1 @@
1
- {"version":3,"file":"property-inspector.js","sourceRoot":"","sources":["../../../src/components/builder/property-inspector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAG1D,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,GAAG,EACH,MAAM,EACN,KAAK,EACL,IAAI,GACL,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;IAC5B,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAA;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAA;IAEjC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CACL,cAAK,SAAS,EAAC,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,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Lock } from 'lucide-react'\nimport { staticProp } from '@elytracms/core/project-graph'\nimport type { ComponentNode } from '@elytracms/core/project-graph'\nimport type { ComponentManifest, PropField } from '@elytracms/core/component-registry'\nimport { effectivePropValues, manifestSlots } from '@elytracms/core/component-registry'\nimport { isFieldHidden } from '@elytracms/core/cms-core'\nimport type { FieldConditionContext, FieldDef } from '@elytracms/core/cms-core'\nimport { getStudioRegistry } from '@elytracms/studio/lib/registry'\nimport {\n Badge,\n Code,\n Field,\n InspectorSection,\n PanelHeader,\n Row,\n Spacer,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { humanizeName } from '@elytracms/studio/lib/utils'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { componentDisplayName } from '@elytracms/studio/lib/persona/labels'\nimport { PropValueControl } from '../cms/prop-fields'\nimport { useBuilder } from './builder-store'\nimport { LayoutSection, layoutManagedPropNames } from './layout-inspector'\nimport { usePropSync } from './prop-sync-context'\n\nexport function PropertyInspector() {\n const builder = useBuilder()\n const studio = getStudioRegistry()\n const node = builder.selectedNode\n\n if (!node) {\n return (\n <div className=\"grid h-full place-items-center p-6 text-center\">\n <Text size=\"sm\" tone=\"muted\">\n {translate('builder.inspector.emptySelection')}\n </Text>\n </div>\n )\n }\n\n const manifest = studio.registry.getManifest(node.componentId)\n\n return (\n <div className=\"flex h-full min-h-0 flex-col\">\n <PanelHeader>\n <Text size=\"sm\" weight=\"semibold\">\n {translate('builder.inspector.title')}\n </Text>\n <Spacer />\n <Code tone=\"muted\" title={node.componentId}>\n {componentDisplayName(node.componentId, manifest)}\n </Code>\n </PanelHeader>\n\n <div className=\"min-h-0 flex-1 overflow-auto\">\n <SettingsTab node={node} manifest={manifest} />\n </div>\n </div>\n )\n}\n\n/**\n * The prop rows the inspector renders for a node (EC-393). Manifest props MINUS:\n * layout-managed props (they render in the Layout section, EC-162); `blocks` props\n * (they are child regions shown in Slots, EC-190); and any prop hidden RIGHT NOW by\n * its `form.hidden` — static `true`, or a predicate over the SIBLING prop values.\n *\n * The predicate's context is the component instance's EFFECTIVE prop values\n * (`effectivePropValues` — static values with manifest defaults filled), the prop\n * analogue of the document form's active-locale draft values (`isFieldHidden` there).\n * So a conditional row shows/hides live as a sibling prop changes and unmounts\n * exactly like a document-form field. Pure (no store) so the behaviour is testable.\n */\nexport function visibleInspectorProps(\n manifest: ComponentManifest,\n node: ComponentNode,\n layoutManaged: ReadonlySet<string>,\n): [string, PropField][] {\n const ctx: FieldConditionContext = { values: effectivePropValues(manifest, node) }\n return Object.entries(manifest.props).filter(\n ([name, spec]) =>\n !layoutManaged.has(name) &&\n spec.type !== 'blocks' &&\n !isFieldHidden({ ...spec, name } as FieldDef, ctx),\n )\n}\n\n/** The full property surface: node identity, static props, condition, slots. */\nfunction SettingsTab({\n node,\n manifest,\n}: {\n node: ComponentNode\n manifest: ComponentManifest | undefined\n}) {\n // Container layout props render in the dedicated Layout section (EC-162),\n // not as a second set of generic controls.\n const layoutManaged = new Set(layoutManagedPropNames(node))\n // EC-190: `blocks` props are slots; EC-393: `form.hidden` props are omitted —\n // evaluated against the node's effective sibling prop values, live as they change.\n const props = manifest ? visibleInspectorProps(manifest, node, layoutManaged) : []\n const slots = manifest ? manifestSlots(manifest) : []\n\n return (\n <>\n {/* EC-192: the editor-facing inspector no longer renders the raw node id or\n namespaced component id (the persona promise). The component's human name\n is in the panel header (with the manifest id in its `title`); the canvas\n and tree provide selection. */}\n {/* Contextual layout inspector for Stack/Grid containers (EC-162). */}\n <LayoutSection node={node} />\n\n {!manifest ? (\n <div className=\"p-3\">\n <Badge variant=\"error\">{translate('builder.inspector.unknownComponent')}</Badge>\n <Text size=\"xs\" tone=\"muted\" className=\"mt-2\">\n {translate('builder.inspector.noManifest')}\n </Text>\n </div>\n ) : (\n <InspectorSection title={translate('builder.inspector.props')}>\n {props.length === 0 ? (\n <Text size=\"xs\" tone=\"subtle\">\n {translate('builder.inspector.noEditableProps')}\n </Text>\n ) : (\n <Stack gap=\"4\">\n {props.map(([name, spec]) => (\n // Key by node id so per-node local control state never leaks\n // across a selection change to a same-named prop.\n <PropField key={`${node.id}:${name}`} node={node} name={name} spec={spec} />\n ))}\n </Stack>\n )}\n </InspectorSection>\n )}\n\n {slots.length > 0 ? (\n <InspectorSection title={translate('builder.inspector.slots')}>\n <Stack gap=\"1\">\n {slots.map((slot) => {\n const count = node.slots?.[slot.name]?.length ?? 0\n const missing = slot.required && count === 0\n return (\n <Row key={slot.name} gap=\"2\">\n <Text size=\"xs\" title={slot.name}>\n {humanizeName(slot.name)}\n </Text>\n {slot.required ? (\n <Badge variant={missing ? 'error' : 'outline'}>{translate('common.required')}</Badge>\n ) : null}\n <Spacer />\n <Text size=\"xs\" tone=\"subtle\" mono>\n {count}\n </Text>\n </Row>\n )\n })}\n </Stack>\n <Text size=\"xs\" tone=\"subtle\" className=\"mt-2\">\n {translate('builder.inspector.slotsHint')}\n </Text>\n </InspectorSection>\n ) : null}\n </>\n )\n}\n\nfunction PropField({ node, name, spec }: { node: ComponentNode; name: string; spec: PropField }) {\n const builder = useBuilder()\n const sync = usePropSync()\n const anchorRef = useRef<HTMLDivElement>(null)\n const value = node.props?.[name]\n const id = `prop-${node.id}-${name}`\n // Coalesce rapid edits to the same prop into one undo step (EC-190).\n const coalesceKey = `${node.id}:${name}`\n\n // EC-408 FORWARD: a sub-part click that resolved to THIS prop scrolls its\n // control into view and focuses the first focusable element. Keyed on the\n // request object (a fresh nonce every request) so re-clicking re-focuses.\n const request = sync?.focusRequest\n useEffect(() => {\n if (!request || request.nodeId !== node.id || request.propName !== name) return\n const anchor = anchorRef.current\n if (!anchor) return\n anchor.scrollIntoView({ block: 'nearest' })\n anchor\n .querySelector<HTMLElement>('input, textarea, select, button, [contenteditable=\"true\"], [tabindex]')\n ?.focus()\n }, [request, node.id, name])\n\n return (\n // EC-408: the stable per-prop anchor. Focus (bubbling) inside any control\n // highlights the matching sub-part on the canvas (REVERSE); blur that leaves\n // the field clears it.\n <div\n ref={anchorRef}\n data-ec-prop-anchor={name}\n onFocus={() => sync?.setHighlighted({ nodeId: node.id, propName: name })}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) sync?.setHighlighted(null)\n }}\n >\n {/* EC-393: honor `form.description` as the field hint, at parity with the document\n form (`detail-editor.tsx` passes the same to its `Field`). */}\n <Field\n label={\n spec.form?.readOnly === true ? (\n // EC-395: the SAME read-only badge the document form renders next to a\n // `read`-access field label (`detail-editor.tsx`'s `fieldLevelReadOnly`\n // row) — identical icon, i18n key, and `Badge` variant, so a locked prop\n // reads exactly like a locked document field, never a bespoke treatment.\n <Row gap=\"2\">\n <span>{localizedLabel(spec.form?.label, name)}</span>\n <Badge variant=\"outline\">\n <Lock className=\"size-3\" /> {translate('cms.editor.readOnlyBadge')}\n </Badge>\n </Row>\n ) : (\n localizedLabel(spec.form?.label, name)\n )\n }\n htmlFor={id}\n hint={localizedLabel(spec.form?.description) || undefined}\n >\n <PropValueControl\n id={id}\n name={name}\n spec={spec}\n value={value}\n onSet={(v) => builder.dispatch({ type: 'setProp', id: node.id, name, value: staticProp(v), coalesceKey })}\n onClear={() => builder.dispatch({ type: 'removeProp', id: node.id, name })}\n />\n </Field>\n </div>\n )\n}\n\n"]}
1
+ {"version":3,"file":"property-inspector.js","sourceRoot":"","sources":["../../../src/components/builder/property-inspector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,gBAAgB,E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S,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EACzG,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAC1E,GACI,GACJ,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Lock } from 'lucide-react'\nimport { staticProp } from '@elytracms/core/project-graph'\nimport type { ComponentNode } from '@elytracms/core/project-graph'\nimport type { ComponentManifest, PropField } from '@elytracms/core/component-registry'\nimport { manifestSlots } from '@elytracms/core/component-registry'\nimport { getStudioRegistry } from '@elytracms/studio/lib/registry'\nimport {\n Badge,\n Code,\n Field,\n InspectorSection,\n PanelHeader,\n Row,\n Spacer,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { humanizeName } from '@elytracms/studio/lib/utils'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { componentDisplayName } from '@elytracms/studio/lib/persona/labels'\nimport { PropValueControl } from '../cms/prop-fields'\nimport { visiblePropFields } from '../cms/prop-visibility'\nimport { useBuilder } from './builder-store'\nimport { LayoutSection, layoutManagedPropNames } from './layout-inspector'\nimport { usePropSync } from './prop-sync-context'\n\nexport function PropertyInspector() {\n const builder = useBuilder()\n const studio = getStudioRegistry()\n const node = builder.selectedNode\n\n if (!node) {\n return (\n <div className=\"grid h-full place-items-center p-6 text-center\">\n <Text size=\"sm\" tone=\"muted\">\n {translate('builder.inspector.emptySelection')}\n </Text>\n </div>\n )\n }\n\n const manifest = studio.registry.getManifest(node.componentId)\n\n return (\n <div className=\"flex h-full min-h-0 flex-col\">\n <PanelHeader>\n <Text size=\"sm\" weight=\"semibold\">\n {translate('builder.inspector.title')}\n </Text>\n <Spacer />\n <Code tone=\"muted\" title={node.componentId}>\n {componentDisplayName(node.componentId, manifest)}\n </Code>\n </PanelHeader>\n\n <div className=\"min-h-0 flex-1 overflow-auto\">\n <SettingsTab node={node} manifest={manifest} />\n </div>\n </div>\n )\n}\n\n/** The full property surface: node identity, static props, condition, slots. */\nfunction SettingsTab({\n node,\n manifest,\n}: {\n node: ComponentNode\n manifest: ComponentManifest | undefined\n}) {\n // Container layout props render in the dedicated Layout section (EC-162),\n // not as a second set of generic controls.\n const layoutManaged = new Set(layoutManagedPropNames(node))\n // EC-190: `blocks` props are slots; EC-393: `form.hidden` props are omitted —\n // evaluated against the node's effective sibling prop values, live as they change\n // (the shared pure core in `cms/prop-visibility.ts`, EC-430).\n const props = manifest ? visiblePropFields(manifest, node, layoutManaged) : []\n const slots = manifest ? manifestSlots(manifest) : []\n\n return (\n <>\n {/* EC-192: the editor-facing inspector no longer renders the raw node id or\n namespaced component id (the persona promise). The component's human name\n is in the panel header (with the manifest id in its `title`); the canvas\n and tree provide selection. */}\n {/* Contextual layout inspector for Stack/Grid containers (EC-162). */}\n <LayoutSection node={node} />\n\n {!manifest ? (\n <div className=\"p-3\">\n <Badge variant=\"error\">{translate('builder.inspector.unknownComponent')}</Badge>\n <Text size=\"xs\" tone=\"muted\" className=\"mt-2\">\n {translate('builder.inspector.noManifest')}\n </Text>\n </div>\n ) : (\n <InspectorSection title={translate('builder.inspector.props')}>\n {props.length === 0 ? (\n <Text size=\"xs\" tone=\"subtle\">\n {translate('builder.inspector.noEditableProps')}\n </Text>\n ) : (\n <Stack gap=\"4\">\n {props.map(([name, spec]) => (\n // Key by node id so per-node local control state never leaks\n // across a selection change to a same-named prop.\n <PropField key={`${node.id}:${name}`} node={node} name={name} spec={spec} />\n ))}\n </Stack>\n )}\n </InspectorSection>\n )}\n\n {slots.length > 0 ? (\n <InspectorSection title={translate('builder.inspector.slots')}>\n <Stack gap=\"1\">\n {slots.map((slot) => {\n const count = node.slots?.[slot.name]?.length ?? 0\n const missing = slot.required && count === 0\n return (\n <Row key={slot.name} gap=\"2\">\n <Text size=\"xs\" title={slot.name}>\n {humanizeName(slot.name)}\n </Text>\n {slot.required ? (\n <Badge variant={missing ? 'error' : 'outline'}>{translate('common.required')}</Badge>\n ) : null}\n <Spacer />\n <Text size=\"xs\" tone=\"subtle\" mono>\n {count}\n </Text>\n </Row>\n )\n })}\n </Stack>\n <Text size=\"xs\" tone=\"subtle\" className=\"mt-2\">\n {translate('builder.inspector.slotsHint')}\n </Text>\n </InspectorSection>\n ) : null}\n </>\n )\n}\n\nfunction PropField({ node, name, spec }: { node: ComponentNode; name: string; spec: PropField }) {\n const builder = useBuilder()\n const sync = usePropSync()\n const anchorRef = useRef<HTMLDivElement>(null)\n const value = node.props?.[name]\n const id = `prop-${node.id}-${name}`\n // Coalesce rapid edits to the same prop into one undo step (EC-190).\n const coalesceKey = `${node.id}:${name}`\n\n // EC-408 FORWARD: a sub-part click that resolved to THIS prop scrolls its\n // control into view and focuses the first focusable element. Keyed on the\n // request object (a fresh nonce every request) so re-clicking re-focuses.\n const request = sync?.focusRequest\n useEffect(() => {\n if (!request || request.nodeId !== node.id || request.propName !== name) return\n const anchor = anchorRef.current\n if (!anchor) return\n anchor.scrollIntoView({ block: 'nearest' })\n anchor\n .querySelector<HTMLElement>('input, textarea, select, button, [contenteditable=\"true\"], [tabindex]')\n ?.focus()\n }, [request, node.id, name])\n\n return (\n // EC-408: the stable per-prop anchor. Focus (bubbling) inside any control\n // highlights the matching sub-part on the canvas (REVERSE); blur that leaves\n // the field clears it.\n <div\n ref={anchorRef}\n data-ec-prop-anchor={name}\n onFocus={() => sync?.setHighlighted({ nodeId: node.id, propName: name })}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) sync?.setHighlighted(null)\n }}\n >\n {/* EC-393: honor `form.description` as the field hint, at parity with the document\n form (`detail-editor.tsx` passes the same to its `Field`). */}\n <Field\n label={\n spec.form?.readOnly === true ? (\n // EC-395: the SAME read-only badge the document form renders next to a\n // `read`-access field label (`detail-editor.tsx`'s `fieldLevelReadOnly`\n // row) — identical icon, i18n key, and `Badge` variant, so a locked prop\n // reads exactly like a locked document field, never a bespoke treatment.\n <Row gap=\"2\">\n <span>{localizedLabel(spec.form?.label, name)}</span>\n <Badge variant=\"outline\">\n <Lock className=\"size-3\" /> {translate('cms.editor.readOnlyBadge')}\n </Badge>\n </Row>\n ) : (\n localizedLabel(spec.form?.label, name)\n )\n }\n htmlFor={id}\n hint={localizedLabel(spec.form?.description) || undefined}\n >\n <PropValueControl\n id={id}\n name={name}\n spec={spec}\n value={value}\n onSet={(v) => builder.dispatch({ type: 'setProp', id: node.id, name, value: staticProp(v), coalesceKey })}\n onClear={() => builder.dispatch({ type: 'removeProp', id: node.id, name })}\n />\n </Field>\n </div>\n )\n}\n\n"]}
@@ -0,0 +1,52 @@
1
+ import type { AssetRecord } from '@elytracms/core/persistence';
2
+ /**
3
+ * Pure selection/filter core for the asset picker (EC-432). DOM-free and
4
+ * side-effect-free so the media browser's "what shows" and "what a pick/upload
5
+ * commits" are unit-testable without a browser — the picker component is just the
6
+ * stage shell around these.
7
+ */
8
+ /**
9
+ * The stage width preset the media browser mounts with (EC-432 / EC-431 AD-A):
10
+ * the roomy `grid` measure (`min(1240px, 94vw)`) — browsing assets is spatial.
11
+ * Exported so the geometry contract is pinnable without rendering the portal
12
+ * (which is `null` in the node test env).
13
+ */
14
+ export declare const ASSET_PICKER_STAGE_PRESET: "grid";
15
+ /**
16
+ * Split a file-input `accept` string ("image/*", "image/png,image/jpeg",
17
+ * ".pdf") into the token list the core matcher understands. The picker receives
18
+ * `accept` as the file-input attribute string (from `assetAcceptAttr(field.accept)`,
19
+ * a literal like `"image/*"`, or `undefined`), not a field's structured list —
20
+ * so we re-split it here. Empty/undefined ⇒ no tokens (no restriction).
21
+ */
22
+ export declare function pickerAcceptTokens(accept: string | undefined): string[];
23
+ /**
24
+ * Does an asset satisfy the picker's `accept`? Reuses the core
25
+ * {@link assetMatchesAccept} matcher over the split tokens — an empty/absent
26
+ * `accept` accepts everything, so a picker opened WITHOUT an accept (the editable
27
+ * cell) still browses the whole library, unchanged.
28
+ */
29
+ export declare function matchesPickerAccept(asset: Pick<AssetRecord, 'contentType' | 'filename'>, accept: string | undefined): boolean;
30
+ /**
31
+ * The assets shown in the picker grid: the shipped search filter (EC-152) then
32
+ * the `accept` filter (EC-432) — an image field's picker browses only images,
33
+ * never the project's PDFs. Order follows the library.
34
+ */
35
+ export declare function visiblePickerAssets(assets: readonly AssetRecord[], query: string, accept: string | undefined): AssetRecord[];
36
+ /**
37
+ * The id an upload just added to the library, if any (upload-then-select, EC-301):
38
+ * the `upload()` API is fire-and-forget, so the picker diffs the library against
39
+ * the pre-upload id set to learn the new asset. `null` when nothing new landed.
40
+ */
41
+ export declare function uploadedSelection(before: Iterable<string>, after: readonly string[]): string | null;
42
+ /** The picker's commit callbacks — a pick fires `onChange` then closes the stage. */
43
+ export interface PickerCommit {
44
+ onChange: (assetId: string | null) => void;
45
+ onOpenChange: (open: boolean) => void;
46
+ }
47
+ /**
48
+ * Commit a picked asset (or a clear, `assetId === null`) and close the picker —
49
+ * the selection semantic (click = pick, fire `onChange`, close). Both the grid
50
+ * card and the Clear affordance route through this.
51
+ */
52
+ export declare function commitPickerSelection(assetId: string | null, { onChange, onOpenChange }: PickerCommit): void;
@@ -0,0 +1,69 @@
1
+ import { assetMatchesAccept } from '@elytracms/core/cms-core';
2
+ import { filterAssets } from '../assets/asset-search.js';
3
+ import { newlyAddedAssetIds } from '../assets/focal-point.js';
4
+ /**
5
+ * Pure selection/filter core for the asset picker (EC-432). DOM-free and
6
+ * side-effect-free so the media browser's "what shows" and "what a pick/upload
7
+ * commits" are unit-testable without a browser — the picker component is just the
8
+ * stage shell around these.
9
+ */
10
+ /**
11
+ * The stage width preset the media browser mounts with (EC-432 / EC-431 AD-A):
12
+ * the roomy `grid` measure (`min(1240px, 94vw)`) — browsing assets is spatial.
13
+ * Exported so the geometry contract is pinnable without rendering the portal
14
+ * (which is `null` in the node test env).
15
+ */
16
+ export const ASSET_PICKER_STAGE_PRESET = 'grid';
17
+ /**
18
+ * Split a file-input `accept` string ("image/*", "image/png,image/jpeg",
19
+ * ".pdf") into the token list the core matcher understands. The picker receives
20
+ * `accept` as the file-input attribute string (from `assetAcceptAttr(field.accept)`,
21
+ * a literal like `"image/*"`, or `undefined`), not a field's structured list —
22
+ * so we re-split it here. Empty/undefined ⇒ no tokens (no restriction).
23
+ */
24
+ export function pickerAcceptTokens(accept) {
25
+ if (!accept)
26
+ return [];
27
+ return accept
28
+ .split(',')
29
+ .map((token) => token.trim())
30
+ .filter(Boolean);
31
+ }
32
+ /**
33
+ * Does an asset satisfy the picker's `accept`? Reuses the core
34
+ * {@link assetMatchesAccept} matcher over the split tokens — an empty/absent
35
+ * `accept` accepts everything, so a picker opened WITHOUT an accept (the editable
36
+ * cell) still browses the whole library, unchanged.
37
+ */
38
+ export function matchesPickerAccept(asset, accept) {
39
+ const tokens = pickerAcceptTokens(accept);
40
+ if (tokens.length === 0)
41
+ return true;
42
+ return assetMatchesAccept({ contentType: asset.contentType, filename: asset.filename }, tokens);
43
+ }
44
+ /**
45
+ * The assets shown in the picker grid: the shipped search filter (EC-152) then
46
+ * the `accept` filter (EC-432) — an image field's picker browses only images,
47
+ * never the project's PDFs. Order follows the library.
48
+ */
49
+ export function visiblePickerAssets(assets, query, accept) {
50
+ return filterAssets(assets, query).filter((asset) => matchesPickerAccept(asset, accept));
51
+ }
52
+ /**
53
+ * The id an upload just added to the library, if any (upload-then-select, EC-301):
54
+ * the `upload()` API is fire-and-forget, so the picker diffs the library against
55
+ * the pre-upload id set to learn the new asset. `null` when nothing new landed.
56
+ */
57
+ export function uploadedSelection(before, after) {
58
+ return newlyAddedAssetIds(before, after)[0] ?? null;
59
+ }
60
+ /**
61
+ * Commit a picked asset (or a clear, `assetId === null`) and close the picker —
62
+ * the selection semantic (click = pick, fire `onChange`, close). Both the grid
63
+ * card and the Clear affordance route through this.
64
+ */
65
+ export function commitPickerSelection(assetId, { onChange, onOpenChange }) {
66
+ onChange(assetId);
67
+ onOpenChange(false);
68
+ }
69
+ //# sourceMappingURL=asset-picker-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-picker-core.js","sourceRoot":"","sources":["../../../src/components/cms/asset-picker-core.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE1D;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAe,CAAA;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,OAAO,MAAM;SACV,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAoD,EACpD,MAA0B;IAE1B,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACzC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,kBAAkB,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAA;AACjG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA8B,EAC9B,KAAa,EACb,MAA0B;IAE1B,OAAO,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;AAC1F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAwB,EAAE,KAAwB;IAClF,OAAO,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;AACrD,CAAC;AAQD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAsB,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAgB;IACpG,QAAQ,CAAC,OAAO,CAAC,CAAA;IACjB,YAAY,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC","sourcesContent":["import type { AssetRecord } from '@elytracms/core/persistence'\nimport { assetMatchesAccept } from '@elytracms/core/cms-core'\nimport { filterAssets } from '../assets/asset-search'\nimport { newlyAddedAssetIds } from '../assets/focal-point'\n\n/**\n * Pure selection/filter core for the asset picker (EC-432). DOM-free and\n * side-effect-free so the media browser's \"what shows\" and \"what a pick/upload\n * commits\" are unit-testable without a browser — the picker component is just the\n * stage shell around these.\n */\n\n/**\n * The stage width preset the media browser mounts with (EC-432 / EC-431 AD-A):\n * the roomy `grid` measure (`min(1240px, 94vw)`) — browsing assets is spatial.\n * Exported so the geometry contract is pinnable without rendering the portal\n * (which is `null` in the node test env).\n */\nexport const ASSET_PICKER_STAGE_PRESET = 'grid' as const\n\n/**\n * Split a file-input `accept` string (\"image/*\", \"image/png,image/jpeg\",\n * \".pdf\") into the token list the core matcher understands. The picker receives\n * `accept` as the file-input attribute string (from `assetAcceptAttr(field.accept)`,\n * a literal like `\"image/*\"`, or `undefined`), not a field's structured list —\n * so we re-split it here. Empty/undefined ⇒ no tokens (no restriction).\n */\nexport function pickerAcceptTokens(accept: string | undefined): string[] {\n if (!accept) return []\n return accept\n .split(',')\n .map((token) => token.trim())\n .filter(Boolean)\n}\n\n/**\n * Does an asset satisfy the picker's `accept`? Reuses the core\n * {@link assetMatchesAccept} matcher over the split tokens — an empty/absent\n * `accept` accepts everything, so a picker opened WITHOUT an accept (the editable\n * cell) still browses the whole library, unchanged.\n */\nexport function matchesPickerAccept(\n asset: Pick<AssetRecord, 'contentType' | 'filename'>,\n accept: string | undefined,\n): boolean {\n const tokens = pickerAcceptTokens(accept)\n if (tokens.length === 0) return true\n return assetMatchesAccept({ contentType: asset.contentType, filename: asset.filename }, tokens)\n}\n\n/**\n * The assets shown in the picker grid: the shipped search filter (EC-152) then\n * the `accept` filter (EC-432) — an image field's picker browses only images,\n * never the project's PDFs. Order follows the library.\n */\nexport function visiblePickerAssets(\n assets: readonly AssetRecord[],\n query: string,\n accept: string | undefined,\n): AssetRecord[] {\n return filterAssets(assets, query).filter((asset) => matchesPickerAccept(asset, accept))\n}\n\n/**\n * The id an upload just added to the library, if any (upload-then-select, EC-301):\n * the `upload()` API is fire-and-forget, so the picker diffs the library against\n * the pre-upload id set to learn the new asset. `null` when nothing new landed.\n */\nexport function uploadedSelection(before: Iterable<string>, after: readonly string[]): string | null {\n return newlyAddedAssetIds(before, after)[0] ?? null\n}\n\n/** The picker's commit callbacks — a pick fires `onChange` then closes the stage. */\nexport interface PickerCommit {\n onChange: (assetId: string | null) => void\n onOpenChange: (open: boolean) => void\n}\n\n/**\n * Commit a picked asset (or a clear, `assetId === null`) and close the picker —\n * the selection semantic (click = pick, fire `onChange`, close). Both the grid\n * card and the Clear affordance route through this.\n */\nexport function commitPickerSelection(assetId: string | null, { onChange, onOpenChange }: PickerCommit): void {\n onChange(assetId)\n onOpenChange(false)\n}\n"]}
@@ -2,15 +2,27 @@
2
2
  * Pick an asset for a CMS `asset` field (brief §8.4, §8.6, EC-075 → EC-152).
3
3
  * Backed by the *real* asset library (the assets store over the operations
4
4
  * client) — the same records the Assets section lists — not by fixture
5
- * documents. Selecting stores the asset id on the document field. The dialog
6
- * is form-width with a maximize toggle and supports drag/click upload that
7
- * auto-selects the new asset (EC-301).
5
+ * documents. Selecting stores the asset id on the document field.
6
+ *
7
+ * EC-432 (AD-C): the picker is a real MEDIA BROWSER on the {@link ExpandableSurface}
8
+ * `stage` (`grid` preset — `min(1240px, 94vw)`, near-full height), replacing the
9
+ * old `max-w-md` (448px) Dialog. It reuses the shipped assets-rail machinery: the
10
+ * assets store, the EC-152 search, the EC-400 thumb tile ({@link AssetThumb}), and
11
+ * the upload-then-select path. It is a SELECTION browser, not a form — click = pick
12
+ * (fires `onChange`, closes) plus the shipped clear/cancel affordances; the
13
+ * forms-never-modal rule governs document forms and is untouched. Opened from the
14
+ * expanded rich-text stage toolbar it rides ABOVE that stage on the EC-392 layer
15
+ * stack — Escape closes the browser first, the rich-text stage stays.
16
+ *
17
+ * The component CONTRACT is unchanged (`{ open, onOpenChange, value, accept,
18
+ * onChange }`) so every call site — asset fields, rich-text image insertion,
19
+ * editable cells — works with zero edits, just a bigger surface.
8
20
  */
9
21
  export declare function AssetPicker({ value, open, onOpenChange, onChange, accept, }: {
10
22
  value: string | null;
11
23
  open: boolean;
12
24
  onOpenChange: (open: boolean) => void;
13
25
  onChange: (assetId: string | null) => void;
14
- /** The file input's `accept` attribute for in-picker upload (field-derived). */
26
+ /** The file input's `accept` attribute for in-picker upload + grid filter (field-derived). */
15
27
  accept?: string;
16
28
  }): import("react").JSX.Element | null;
@@ -1,20 +1,32 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AlertTriangle, Check, ImageIcon, Maximize2, Minimize2, Search, Upload } from 'lucide-react';
2
+ import { AlertTriangle, Check, ImageIcon, Search, Upload } from 'lucide-react';
3
3
  import { useEffect, useMemo, useRef, useState } from 'react';
4
- import { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, Input, Row, Spacer, Stack, Text, } from '@elytracms/studio/ui';
4
+ import { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, ExpandableSurface, Input, Row, Spacer, Text, } from '@elytracms/studio/ui';
5
5
  import { cn } from '@elytracms/studio/lib/utils';
6
6
  import { translate } from '@elytracms/studio/lib/i18n';
7
- import { filterAssets } from '../assets/asset-search.js';
7
+ import { AssetThumb } from '../assets/asset-thumb.js';
8
8
  import { AssetsProvider, useAssets, useOptionalAssets } from '../assets/assets-store.js';
9
- import { newlyAddedAssetIds } from '../assets/focal-point.js';
10
9
  import { useCollectionView } from '../collection-view/collection-view-context.js';
10
+ import { ASSET_PICKER_STAGE_PRESET, commitPickerSelection, uploadedSelection, visiblePickerAssets, } from './asset-picker-core.js';
11
11
  /**
12
12
  * Pick an asset for a CMS `asset` field (brief §8.4, §8.6, EC-075 → EC-152).
13
13
  * Backed by the *real* asset library (the assets store over the operations
14
14
  * client) — the same records the Assets section lists — not by fixture
15
- * documents. Selecting stores the asset id on the document field. The dialog
16
- * is form-width with a maximize toggle and supports drag/click upload that
17
- * auto-selects the new asset (EC-301).
15
+ * documents. Selecting stores the asset id on the document field.
16
+ *
17
+ * EC-432 (AD-C): the picker is a real MEDIA BROWSER on the {@link ExpandableSurface}
18
+ * `stage` (`grid` preset — `min(1240px, 94vw)`, near-full height), replacing the
19
+ * old `max-w-md` (448px) Dialog. It reuses the shipped assets-rail machinery: the
20
+ * assets store, the EC-152 search, the EC-400 thumb tile ({@link AssetThumb}), and
21
+ * the upload-then-select path. It is a SELECTION browser, not a form — click = pick
22
+ * (fires `onChange`, closes) plus the shipped clear/cancel affordances; the
23
+ * forms-never-modal rule governs document forms and is untouched. Opened from the
24
+ * expanded rich-text stage toolbar it rides ABOVE that stage on the EC-392 layer
25
+ * stack — Escape closes the browser first, the rich-text stage stays.
26
+ *
27
+ * The component CONTRACT is unchanged (`{ open, onOpenChange, value, accept,
28
+ * onChange }`) so every call site — asset fields, rich-text image insertion,
29
+ * editable cells — works with zero edits, just a bigger surface.
18
30
  */
19
31
  export function AssetPicker({ value, open, onOpenChange, onChange, accept, }) {
20
32
  const source = useCollectionView();
@@ -24,21 +36,20 @@ export function AssetPicker({ value, open, onOpenChange, onChange, accept, }) {
24
36
  if (!open)
25
37
  return null;
26
38
  if (ambient) {
27
- return (_jsx(AssetPickerDialog, { value: value, onOpenChange: onOpenChange, onChange: onChange, accept: accept }));
39
+ return (_jsx(AssetPickerStage, { value: value, onOpenChange: onOpenChange, onChange: onChange, accept: accept }));
28
40
  }
29
41
  if (source.projectId === undefined) {
30
42
  // No project scope (fixture-only CMS session): the library is
31
43
  // unreachable — say so instead of silently showing nothing.
32
44
  return (_jsx(Dialog, { open: true, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: translate('cms.asset.pickTitle') }), _jsx(DialogDescription, { children: translate('cms.asset.pickDescription') })] }), _jsxs(Row, { gap: "2", "data-testid": "asset-picker-no-project", children: [_jsx(AlertTriangle, { className: "size-4 text-warning" }), _jsx(Text, { size: "sm", tone: "muted", children: translate('cms.asset.noProject') })] })] }) }));
33
45
  }
34
- return (_jsx(AssetsProvider, { projectId: source.projectId, children: _jsx(AssetPickerDialog, { value: value, onOpenChange: onOpenChange, onChange: onChange, accept: accept }) }));
46
+ return (_jsx(AssetsProvider, { projectId: source.projectId, children: _jsx(AssetPickerStage, { value: value, onOpenChange: onOpenChange, onChange: onChange, accept: accept }) }));
35
47
  }
36
- /** The open dialog over a mounted assets store. */
37
- function AssetPickerDialog({ value, onOpenChange, onChange, accept, }) {
48
+ /** The open media-browser stage over a mounted assets store. */
49
+ function AssetPickerStage({ value, onOpenChange, onChange, accept, }) {
38
50
  const store = useAssets();
39
51
  // Fresh per open: the picker unmounts entirely while closed.
40
52
  const [query, setQuery] = useState('');
41
- const [maximized, setMaximized] = useState(false);
42
53
  const [dragging, setDragging] = useState(false);
43
54
  const fileInputRef = useRef(null);
44
55
  // Library ids when an upload started; the effect below diffs against it to
@@ -48,18 +59,17 @@ function AssetPickerDialog({ value, onOpenChange, onChange, accept, }) {
48
59
  // child boundaries — the same per-element dragenter/dragleave flicker the field
49
60
  // fixes. Only hide when the count returns to zero.
50
61
  const dragDepth = useRef(0);
51
- const assets = filterAssets(store.assets, query);
62
+ const assets = visiblePickerAssets(store.assets, query, accept);
52
63
  const libraryIds = useMemo(() => store.assets.map((a) => a.id), [store.assets]);
53
64
  // Auto-select an asset uploaded from within the picker, then close.
54
65
  useEffect(() => {
55
66
  if (!pendingRef.current)
56
67
  return;
57
- const added = newlyAddedAssetIds(pendingRef.current, libraryIds);
58
- if (added.length === 0)
68
+ const picked = uploadedSelection(pendingRef.current, libraryIds);
69
+ if (picked === null)
59
70
  return;
60
71
  pendingRef.current = null;
61
- onChange(added[0]);
62
- onOpenChange(false);
72
+ commitPickerSelection(picked, { onChange, onOpenChange });
63
73
  }, [libraryIds, onChange, onOpenChange]);
64
74
  function handleUpload(files) {
65
75
  if (files.length === 0)
@@ -67,10 +77,10 @@ function AssetPickerDialog({ value, onOpenChange, onChange, accept, }) {
67
77
  pendingRef.current = new Set(libraryIds);
68
78
  store.upload(files);
69
79
  }
70
- // Radix portals the dialog in the DOM, but React synthetic events still bubble up
80
+ // The stage portals to document.body, but React synthetic events still bubble up
71
81
  // the COMPONENT tree — and this picker is rendered as a child of the asset field,
72
82
  // which has its own drag-to-upload handlers. Without stopPropagation a drop inside
73
- // the dialog would fire BOTH the picker's and the field's `onDrop`, uploading the
83
+ // the stage would fire BOTH the picker's and the field's `onDrop`, uploading the
74
84
  // file twice. Stop every DnD event here so the picker owns its drop entirely.
75
85
  function onDragEnter(e) {
76
86
  e.preventDefault();
@@ -98,40 +108,14 @@ function AssetPickerDialog({ value, onOpenChange, onChange, accept, }) {
98
108
  setDragging(false);
99
109
  handleUpload(Array.from(e.dataTransfer.files));
100
110
  }
101
- return (_jsx(Dialog, { open: true, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: cn(maximized ? 'max-w-[95vw]' : 'max-w-2xl'), onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, children: [_jsx(DialogHeader, { children: _jsxs(Row, { gap: "2", align: "center", children: [_jsxs(Stack, { gap: "1", className: "min-w-0 flex-1", children: [_jsx(DialogTitle, { children: translate('cms.asset.pickTitle') }), _jsx(DialogDescription, { children: translate('cms.asset.pickDescription') })] }), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": maximized ? translate('cms.asset.restoreDialogSize') : translate('cms.asset.maximizeDialog'), onClick: () => setMaximized((v) => !v), className: "mr-7", children: maximized ? _jsx(Minimize2, { className: "size-4" }) : _jsx(Maximize2, { className: "size-4" }) })] }) }), _jsxs(Row, { gap: "2", align: "center", children: [_jsxs("span", { className: "relative flex-1", children: [_jsx(Search, { className: "pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { autoFocus: true, value: query, onChange: (e) => setQuery(e.target.value), placeholder: translate('cms.asset.searchPlaceholder'), className: "pl-8", "data-testid": "asset-picker-search" })] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => fileInputRef.current?.click(), children: [_jsx(Upload, {}), " ", translate('common.upload')] }), _jsx("input", { ref: fileInputRef, type: "file", multiple: true, accept: accept ?? 'image/*', className: "hidden", onChange: (e) => {
111
+ return (_jsx(ExpandableSurface, { title: translate('cms.asset.pickTitle'), closeLabel: translate('common.close'), variant: "stage", preset: ASSET_PICKER_STAGE_PRESET, onDismiss: () => onOpenChange(false), headerLeading: _jsx(ImageIcon, { className: "size-4 text-muted-foreground", "aria-hidden": true }), children: _jsxs("div", { className: "relative flex min-h-0 flex-1 flex-col gap-3 p-4", onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, children: [_jsxs(Row, { gap: "2", align: "center", children: [_jsxs("span", { className: "relative flex-1", children: [_jsx(Search, { className: "pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { autoFocus: true, value: query, onChange: (e) => setQuery(e.target.value), placeholder: translate('cms.asset.searchPlaceholder'), className: "pl-8", "data-testid": "asset-picker-search" })] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => fileInputRef.current?.click(), children: [_jsx(Upload, {}), " ", translate('common.upload')] }), _jsx("input", { ref: fileInputRef, type: "file", multiple: true, accept: accept ?? 'image/*', className: "hidden", onChange: (e) => {
102
112
  handleUpload(Array.from(e.target.files ?? []));
103
113
  e.target.value = '';
104
- } })] }), _jsx("div", { className: cn('grid gap-2 overflow-auto', maximized
105
- ? 'max-h-[78vh] grid-cols-4 lg:grid-cols-6'
106
- : 'max-h-[60vh] grid-cols-3 sm:grid-cols-4'), "data-testid": "asset-picker-grid", children: store.status === 'loading' ? (_jsx(Text, { size: "sm", tone: "muted", className: "col-span-full p-3", children: translate('cms.asset.loading') })) : store.status === 'error' ? (_jsxs(Row, { gap: "2", className: "col-span-full p-3", "data-testid": "asset-picker-error", children: [_jsx(AlertTriangle, { className: "size-4 text-destructive" }), _jsx(Text, { size: "sm", tone: "muted", children: store.errorMessage ?? translate('cms.asset.loadError') })] })) : assets.length === 0 ? (_jsx(Text, { size: "sm", tone: "muted", className: "col-span-full p-3", children: query.trim()
107
- ? translate('cms.asset.noMatches')
108
- : translate('cms.asset.empty') })) : (assets.map((asset) => (_jsx(AssetPickerCard, { asset: asset, selected: asset.id === value, onPick: () => {
109
- onChange(asset.id);
110
- onOpenChange(false);
111
- } }, asset.id)))) }), _jsxs(Row, { gap: "2", children: [_jsx(Spacer, {}), value ? (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => {
112
- onChange(null);
113
- onOpenChange(false);
114
- }, children: translate('common.clear') })) : null] }), dragging ? (_jsx("div", { className: "pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-xl border-2 border-dashed border-primary bg-background/85", children: _jsxs(Row, { gap: "2", align: "center", children: [_jsx(Upload, { className: "size-5 text-primary" }), _jsx(Text, { className: "font-medium", children: translate('cms.asset.dropToUpload') })] }) })) : null] }) }));
114
+ } })] }), _jsx("div", { className: "grid min-h-0 flex-1 auto-rows-min grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5", "data-testid": "asset-picker-grid", children: store.status === 'loading' ? (_jsx(Text, { size: "sm", tone: "muted", className: "col-span-full p-3", children: translate('cms.asset.loading') })) : store.status === 'error' ? (_jsxs(Row, { gap: "2", className: "col-span-full p-3", "data-testid": "asset-picker-error", children: [_jsx(AlertTriangle, { className: "size-4 text-destructive" }), _jsx(Text, { size: "sm", tone: "muted", children: store.errorMessage ?? translate('cms.asset.loadError') })] })) : assets.length === 0 ? (_jsx(Text, { size: "sm", tone: "muted", className: "col-span-full p-3", children: query.trim() ? translate('cms.asset.noMatches') : translate('cms.asset.empty') })) : (assets.map((asset) => (_jsx(AssetPickerCard, { asset: asset, selected: asset.id === value, onPick: () => commitPickerSelection(asset.id, { onChange, onOpenChange }) }, asset.id)))) }), _jsxs(Row, { gap: "2", children: [_jsx(Spacer, {}), value ? (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => commitPickerSelection(null, { onChange, onOpenChange }), children: translate('common.clear') })) : null] }), dragging ? (_jsx("div", { className: "pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-lg border-2 border-dashed border-primary bg-background/85", children: _jsxs(Row, { gap: "2", align: "center", children: [_jsx(Upload, { className: "size-5 text-primary" }), _jsx(Text, { className: "font-medium", children: translate('cms.asset.dropToUpload') })] }) })) : null] }) }));
115
115
  }
116
- /** One selectable asset: thumbnail + title/filename + alt text. The internal
117
- * asset id is intentionally not shown — it's noise to editors (EC-301). */
116
+ /** One selectable asset: EC-400 thumb tile + title/filename + alt text. The
117
+ * internal asset id is intentionally not shown — it's noise to editors (EC-301). */
118
118
  function AssetPickerCard({ asset, selected, onPick, }) {
119
- return (_jsxs("button", { type: "button", onClick: onPick, className: cn('flex flex-col gap-1.5 rounded-lg border p-2 text-left transition-colors', selected ? 'border-primary bg-primary/5' : 'border-border hover:bg-muted'), "data-testid": "asset-picker-card", children: [_jsx(PickerThumbnail, { asset: asset }), _jsxs(Row, { gap: "1", children: [_jsx(Text, { size: "xs", className: "min-w-0 flex-1 truncate font-medium", children: asset.title ?? asset.filename }), selected ? _jsx(Check, { className: "size-3.5 text-primary" }) : null] }), _jsx(Text, { size: "xs", tone: asset.alt ? 'muted' : 'subtle', className: "truncate", children: asset.alt ?? translate('cms.asset.noAltText') })] }));
120
- }
121
- /** Image preview: the EC-400 downscaled thumb when resolvable, else the full
122
- * original; icon fallback for other types. In-memory/opaque locators
123
- * (memory://, convex://) are not fetchable by <img>, so those degrade too. */
124
- function PickerThumbnail({ asset }) {
125
- const isImage = asset.contentType.startsWith('image/');
126
- const thumbUrl = asset.thumb?.url;
127
- const src = thumbUrl?.startsWith('http') === true
128
- ? thumbUrl
129
- : asset.url?.startsWith('http') === true
130
- ? asset.url
131
- : undefined;
132
- if (isImage && src) {
133
- return (_jsx("img", { src: src, alt: asset.alt ?? asset.filename, className: "aspect-video w-full rounded-md bg-muted object-cover" }));
134
- }
135
- return (_jsx("span", { className: "grid aspect-video w-full place-items-center rounded-md bg-muted text-muted-foreground", children: _jsx(ImageIcon, { className: "size-6" }) }));
119
+ return (_jsxs("button", { type: "button", onClick: onPick, className: cn('flex flex-col gap-1.5 rounded-lg border p-2 text-left transition-colors', selected ? 'border-primary bg-primary/5' : 'border-border hover:bg-muted'), "data-testid": "asset-picker-card", "aria-pressed": selected, children: [_jsxs("span", { className: "relative block", children: [_jsx(AssetThumb, { record: asset, className: "aspect-video w-full" }), selected ? (_jsx("span", { className: "absolute right-1 top-1 grid size-5 place-items-center rounded-full bg-primary text-primary-foreground shadow", children: _jsx(Check, { className: "size-3" }) })) : null] }), _jsx(Text, { size: "xs", className: "min-w-0 truncate font-medium", children: asset.title ?? asset.filename }), _jsx(Text, { size: "xs", tone: asset.alt ? 'muted' : 'subtle', className: "truncate", children: asset.alt ?? translate('cms.asset.noAltText') })] }));
136
120
  }
137
121
  //# sourceMappingURL=asset-picker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asset-picker.js","sourceRoot":"","sources":["../../../src/components/cms/asset-picker.tsx"],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CAAA;IACH,CAAC;IACD,OAAO,CACL,eAAM,SAAS,EAAC,uFAAuF,YACrG,KAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC3B,CACR,CAAA;AACH,CAAC","sourcesContent":["import { AlertTriangle, Check, ImageIcon, Maximize2, Minimize2, Search, Upload } from 'lucide-react'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n Input,\n Row,\n Spacer,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { filterAssets } from '../assets/asset-search'\nimport { AssetsProvider, useAssets, useOptionalAssets } from '../assets/assets-store'\nimport { newlyAddedAssetIds } from '../assets/focal-point'\nimport { useCollectionView } from '../collection-view/collection-view-context'\n\n/**\n * Pick an asset for a CMS `asset` field (brief §8.4, §8.6, EC-075 → EC-152).\n * Backed by the *real* asset library (the assets store over the operations\n * client) — the same records the Assets section lists — not by fixture\n * documents. Selecting stores the asset id on the document field. The dialog\n * is form-width with a maximize toggle and supports drag/click upload that\n * auto-selects the new asset (EC-301).\n */\nexport function AssetPicker({\n value,\n open,\n onOpenChange,\n onChange,\n accept,\n}: {\n value: string | null\n open: boolean\n onOpenChange: (open: boolean) => void\n onChange: (assetId: string | null) => void\n /** The file input's `accept` attribute for in-picker upload (field-derived). */\n accept?: string\n}) {\n const source = useCollectionView()\n const ambient = useOptionalAssets()\n // Mount nothing while closed: the self-provided assets store would\n // otherwise load the library eagerly for every asset field on the form.\n if (!open) return null\n if (ambient) {\n return (\n <AssetPickerDialog value={value} onOpenChange={onOpenChange} onChange={onChange} accept={accept} />\n )\n }\n if (source.projectId === undefined) {\n // No project scope (fixture-only CMS session): the library is\n // unreachable — say so instead of silently showing nothing.\n return (\n <Dialog open onOpenChange={onOpenChange}>\n <DialogContent className=\"max-w-md\">\n <DialogHeader>\n <DialogTitle>{translate('cms.asset.pickTitle')}</DialogTitle>\n <DialogDescription>{translate('cms.asset.pickDescription')}</DialogDescription>\n </DialogHeader>\n <Row gap=\"2\" data-testid=\"asset-picker-no-project\">\n <AlertTriangle className=\"size-4 text-warning\" />\n <Text size=\"sm\" tone=\"muted\">\n {translate('cms.asset.noProject')}\n </Text>\n </Row>\n </DialogContent>\n </Dialog>\n )\n }\n return (\n <AssetsProvider projectId={source.projectId}>\n <AssetPickerDialog value={value} onOpenChange={onOpenChange} onChange={onChange} accept={accept} />\n </AssetsProvider>\n )\n}\n\n/** The open dialog over a mounted assets store. */\nfunction AssetPickerDialog({\n value,\n onOpenChange,\n onChange,\n accept,\n}: {\n value: string | null\n onOpenChange: (open: boolean) => void\n onChange: (assetId: string | null) => void\n accept?: string\n}) {\n const store = useAssets()\n // Fresh per open: the picker unmounts entirely while closed.\n const [query, setQuery] = useState('')\n const [maximized, setMaximized] = useState(false)\n const [dragging, setDragging] = useState(false)\n const fileInputRef = useRef<HTMLInputElement>(null)\n // Library ids when an upload started; the effect below diffs against it to\n // learn the new asset and select it (the `upload()` API returns nothing).\n const pendingRef = useRef<ReadonlySet<string> | null>(null)\n // Drag depth (EC-301): keeps the drop overlay steady as the pointer crosses\n // child boundaries — the same per-element dragenter/dragleave flicker the field\n // fixes. Only hide when the count returns to zero.\n const dragDepth = useRef(0)\n const assets = filterAssets(store.assets, query)\n const libraryIds = useMemo(() => store.assets.map((a) => a.id), [store.assets])\n\n // Auto-select an asset uploaded from within the picker, then close.\n useEffect(() => {\n if (!pendingRef.current) return\n const added = newlyAddedAssetIds(pendingRef.current, libraryIds)\n if (added.length === 0) return\n pendingRef.current = null\n onChange(added[0]!)\n onOpenChange(false)\n }, [libraryIds, onChange, onOpenChange])\n\n function handleUpload(files: File[]) {\n if (files.length === 0) return\n pendingRef.current = new Set(libraryIds)\n store.upload(files)\n }\n // Radix portals the dialog in the DOM, but React synthetic events still bubble up\n // the COMPONENT tree — and this picker is rendered as a child of the asset field,\n // which has its own drag-to-upload handlers. Without stopPropagation a drop inside\n // the dialog would fire BOTH the picker's and the field's `onDrop`, uploading the\n // file twice. Stop every DnD event here so the picker owns its drop entirely.\n function onDragEnter(e: React.DragEvent) {\n e.preventDefault()\n e.stopPropagation()\n dragDepth.current += 1\n if (!dragging) setDragging(true)\n }\n function onDragOver(e: React.DragEvent) {\n e.preventDefault()\n e.stopPropagation()\n }\n function onDragLeave(e: React.DragEvent) {\n e.stopPropagation()\n dragDepth.current -= 1\n if (dragDepth.current <= 0) {\n dragDepth.current = 0\n setDragging(false)\n }\n }\n function onDrop(e: React.DragEvent) {\n e.preventDefault()\n e.stopPropagation()\n dragDepth.current = 0\n setDragging(false)\n handleUpload(Array.from(e.dataTransfer.files))\n }\n\n return (\n <Dialog open onOpenChange={onOpenChange}>\n <DialogContent\n className={cn(maximized ? 'max-w-[95vw]' : 'max-w-2xl')}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n onDrop={onDrop}\n >\n <DialogHeader>\n <Row gap=\"2\" align=\"center\">\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <DialogTitle>{translate('cms.asset.pickTitle')}</DialogTitle>\n <DialogDescription>{translate('cms.asset.pickDescription')}</DialogDescription>\n </Stack>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={maximized ? translate('cms.asset.restoreDialogSize') : translate('cms.asset.maximizeDialog')}\n onClick={() => setMaximized((v) => !v)}\n className=\"mr-7\"\n >\n {maximized ? <Minimize2 className=\"size-4\" /> : <Maximize2 className=\"size-4\" />}\n </Button>\n </Row>\n </DialogHeader>\n\n <Row gap=\"2\" align=\"center\">\n <span className=\"relative flex-1\">\n <Search className=\"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground\" />\n <Input\n autoFocus\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={translate('cms.asset.searchPlaceholder')}\n className=\"pl-8\"\n data-testid=\"asset-picker-search\"\n />\n </span>\n <Button variant=\"outline\" size=\"sm\" onClick={() => fileInputRef.current?.click()}>\n <Upload /> {translate('common.upload')}\n </Button>\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n accept={accept ?? 'image/*'}\n className=\"hidden\"\n onChange={(e) => {\n handleUpload(Array.from(e.target.files ?? []))\n e.target.value = ''\n }}\n />\n </Row>\n\n <div\n className={cn(\n 'grid gap-2 overflow-auto',\n maximized\n ? 'max-h-[78vh] grid-cols-4 lg:grid-cols-6'\n : 'max-h-[60vh] grid-cols-3 sm:grid-cols-4',\n )}\n data-testid=\"asset-picker-grid\"\n >\n {store.status === 'loading' ? (\n <Text size=\"sm\" tone=\"muted\" className=\"col-span-full p-3\">\n {translate('cms.asset.loading')}\n </Text>\n ) : store.status === 'error' ? (\n <Row gap=\"2\" className=\"col-span-full p-3\" data-testid=\"asset-picker-error\">\n <AlertTriangle className=\"size-4 text-destructive\" />\n <Text size=\"sm\" tone=\"muted\">\n {store.errorMessage ?? translate('cms.asset.loadError')}\n </Text>\n </Row>\n ) : assets.length === 0 ? (\n <Text size=\"sm\" tone=\"muted\" className=\"col-span-full p-3\">\n {query.trim()\n ? translate('cms.asset.noMatches')\n : translate('cms.asset.empty')}\n </Text>\n ) : (\n assets.map((asset) => (\n <AssetPickerCard\n key={asset.id}\n asset={asset}\n selected={asset.id === value}\n onPick={() => {\n onChange(asset.id)\n onOpenChange(false)\n }}\n />\n ))\n )}\n </div>\n\n <Row gap=\"2\">\n <Spacer />\n {value ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => {\n onChange(null)\n onOpenChange(false)\n }}\n >\n {translate('common.clear')}\n </Button>\n ) : null}\n </Row>\n\n {dragging ? (\n <div className=\"pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-xl border-2 border-dashed border-primary bg-background/85\">\n <Row gap=\"2\" align=\"center\">\n <Upload className=\"size-5 text-primary\" />\n <Text className=\"font-medium\">{translate('cms.asset.dropToUpload')}</Text>\n </Row>\n </div>\n ) : null}\n </DialogContent>\n </Dialog>\n )\n}\n\n/** One selectable asset: thumbnail + title/filename + alt text. The internal\n * asset id is intentionally not shown — it's noise to editors (EC-301). */\nfunction AssetPickerCard({\n asset,\n selected,\n onPick,\n}: {\n asset: AssetRecord\n selected: boolean\n onPick: () => void\n}) {\n return (\n <button\n type=\"button\"\n onClick={onPick}\n className={cn(\n 'flex flex-col gap-1.5 rounded-lg border p-2 text-left transition-colors',\n selected ? 'border-primary bg-primary/5' : 'border-border hover:bg-muted',\n )}\n data-testid=\"asset-picker-card\"\n >\n <PickerThumbnail asset={asset} />\n <Row gap=\"1\">\n <Text size=\"xs\" className=\"min-w-0 flex-1 truncate font-medium\">\n {asset.title ?? asset.filename}\n </Text>\n {selected ? <Check className=\"size-3.5 text-primary\" /> : null}\n </Row>\n <Text size=\"xs\" tone={asset.alt ? 'muted' : 'subtle'} className=\"truncate\">\n {asset.alt ?? translate('cms.asset.noAltText')}\n </Text>\n </button>\n )\n}\n\n/** Image preview: the EC-400 downscaled thumb when resolvable, else the full\n * original; icon fallback for other types. In-memory/opaque locators\n * (memory://, convex://) are not fetchable by <img>, so those degrade too. */\nfunction PickerThumbnail({ asset }: { asset: AssetRecord }) {\n const isImage = asset.contentType.startsWith('image/')\n const thumbUrl = asset.thumb?.url\n const src =\n thumbUrl?.startsWith('http') === true\n ? thumbUrl\n : asset.url?.startsWith('http') === true\n ? asset.url\n : undefined\n if (isImage && src) {\n return (\n <img\n src={src}\n alt={asset.alt ?? asset.filename}\n className=\"aspect-video w-full rounded-md bg-muted object-cover\"\n />\n )\n }\n return (\n <span className=\"grid aspect-video w-full place-items-center rounded-md bg-muted text-muted-foreground\">\n <ImageIcon className=\"size-6\" />\n </span>\n )\n}\n"]}
1
+ {"version":3,"file":"asset-picker.js","sourceRoot":"","sources":["../../../src/components/cms/asset-picker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,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, useState } from 'react'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n ExpandableSurface,\n Input,\n Row,\n Spacer,\n Text,\n} from '@elytracms/studio/ui'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { AssetThumb } from '../assets/asset-thumb'\nimport { AssetsProvider, useAssets, useOptionalAssets } from '../assets/assets-store'\nimport { useCollectionView } from '../collection-view/collection-view-context'\nimport {\n ASSET_PICKER_STAGE_PRESET,\n commitPickerSelection,\n uploadedSelection,\n visiblePickerAssets,\n} from './asset-picker-core'\n\n/**\n * Pick an asset for a CMS `asset` field (brief §8.4, §8.6, EC-075 → EC-152).\n * Backed by the *real* asset library (the assets store over the operations\n * client) — the same records the Assets section lists — not by fixture\n * documents. Selecting stores the asset id on the document field.\n *\n * EC-432 (AD-C): the picker is a real MEDIA BROWSER on the {@link ExpandableSurface}\n * `stage` (`grid` preset — `min(1240px, 94vw)`, near-full height), replacing the\n * old `max-w-md` (448px) Dialog. It reuses the shipped assets-rail machinery: the\n * assets store, the EC-152 search, the EC-400 thumb tile ({@link AssetThumb}), and\n * the upload-then-select path. It is a SELECTION browser, not a form — click = pick\n * (fires `onChange`, closes) plus the shipped clear/cancel affordances; the\n * forms-never-modal rule governs document forms and is untouched. Opened from the\n * expanded rich-text stage toolbar it rides ABOVE that stage on the EC-392 layer\n * stack — Escape closes the browser first, the rich-text stage stays.\n *\n * The component CONTRACT is unchanged (`{ open, onOpenChange, value, accept,\n * onChange }`) so every call site — asset fields, rich-text image insertion,\n * editable cells — works with zero edits, just a bigger surface.\n */\nexport function AssetPicker({\n value,\n open,\n onOpenChange,\n onChange,\n accept,\n}: {\n value: string | null\n open: boolean\n onOpenChange: (open: boolean) => void\n onChange: (assetId: string | null) => void\n /** The file input's `accept` attribute for in-picker upload + grid filter (field-derived). */\n accept?: string\n}) {\n const source = useCollectionView()\n const ambient = useOptionalAssets()\n // Mount nothing while closed: the self-provided assets store would\n // otherwise load the library eagerly for every asset field on the form.\n if (!open) return null\n if (ambient) {\n return (\n <AssetPickerStage value={value} onOpenChange={onOpenChange} onChange={onChange} accept={accept} />\n )\n }\n if (source.projectId === undefined) {\n // No project scope (fixture-only CMS session): the library is\n // unreachable — say so instead of silently showing nothing.\n return (\n <Dialog open onOpenChange={onOpenChange}>\n <DialogContent className=\"max-w-md\">\n <DialogHeader>\n <DialogTitle>{translate('cms.asset.pickTitle')}</DialogTitle>\n <DialogDescription>{translate('cms.asset.pickDescription')}</DialogDescription>\n </DialogHeader>\n <Row gap=\"2\" data-testid=\"asset-picker-no-project\">\n <AlertTriangle className=\"size-4 text-warning\" />\n <Text size=\"sm\" tone=\"muted\">\n {translate('cms.asset.noProject')}\n </Text>\n </Row>\n </DialogContent>\n </Dialog>\n )\n }\n return (\n <AssetsProvider projectId={source.projectId}>\n <AssetPickerStage value={value} onOpenChange={onOpenChange} onChange={onChange} accept={accept} />\n </AssetsProvider>\n )\n}\n\n/** The open media-browser stage over a mounted assets store. */\nfunction AssetPickerStage({\n value,\n onOpenChange,\n onChange,\n accept,\n}: {\n value: string | null\n onOpenChange: (open: boolean) => void\n onChange: (assetId: string | null) => void\n accept?: string\n}) {\n const store = useAssets()\n // Fresh per open: the picker unmounts entirely while closed.\n const [query, setQuery] = useState('')\n const [dragging, setDragging] = useState(false)\n const fileInputRef = useRef<HTMLInputElement>(null)\n // Library ids when an upload started; the effect below diffs against it to\n // learn the new asset and select it (the `upload()` API returns nothing).\n const pendingRef = useRef<ReadonlySet<string> | null>(null)\n // Drag depth (EC-301): keeps the drop overlay steady as the pointer crosses\n // child boundaries — the same per-element dragenter/dragleave flicker the field\n // fixes. Only hide when the count returns to zero.\n const dragDepth = useRef(0)\n const assets = visiblePickerAssets(store.assets, query, accept)\n const libraryIds = useMemo(() => store.assets.map((a) => a.id), [store.assets])\n\n // Auto-select an asset uploaded from within the picker, then close.\n useEffect(() => {\n if (!pendingRef.current) return\n const picked = uploadedSelection(pendingRef.current, libraryIds)\n if (picked === null) return\n pendingRef.current = null\n commitPickerSelection(picked, { onChange, onOpenChange })\n }, [libraryIds, onChange, onOpenChange])\n\n function handleUpload(files: File[]) {\n if (files.length === 0) return\n pendingRef.current = new Set(libraryIds)\n store.upload(files)\n }\n // The stage portals to document.body, but React synthetic events still bubble up\n // the COMPONENT tree — and this picker is rendered as a child of the asset field,\n // which has its own drag-to-upload handlers. Without stopPropagation a drop inside\n // the stage would fire BOTH the picker's and the field's `onDrop`, uploading the\n // file twice. Stop every DnD event here so the picker owns its drop entirely.\n function onDragEnter(e: React.DragEvent) {\n e.preventDefault()\n e.stopPropagation()\n dragDepth.current += 1\n if (!dragging) setDragging(true)\n }\n function onDragOver(e: React.DragEvent) {\n e.preventDefault()\n e.stopPropagation()\n }\n function onDragLeave(e: React.DragEvent) {\n e.stopPropagation()\n dragDepth.current -= 1\n if (dragDepth.current <= 0) {\n dragDepth.current = 0\n setDragging(false)\n }\n }\n function onDrop(e: React.DragEvent) {\n e.preventDefault()\n e.stopPropagation()\n dragDepth.current = 0\n setDragging(false)\n handleUpload(Array.from(e.dataTransfer.files))\n }\n\n return (\n <ExpandableSurface\n title={translate('cms.asset.pickTitle')}\n closeLabel={translate('common.close')}\n variant=\"stage\"\n preset={ASSET_PICKER_STAGE_PRESET}\n onDismiss={() => onOpenChange(false)}\n headerLeading={<ImageIcon className=\"size-4 text-muted-foreground\" aria-hidden />}\n >\n <div\n className=\"relative flex min-h-0 flex-1 flex-col gap-3 p-4\"\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n onDrop={onDrop}\n >\n <Row gap=\"2\" align=\"center\">\n <span className=\"relative flex-1\">\n <Search className=\"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground\" />\n <Input\n autoFocus\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={translate('cms.asset.searchPlaceholder')}\n className=\"pl-8\"\n data-testid=\"asset-picker-search\"\n />\n </span>\n <Button variant=\"outline\" size=\"sm\" onClick={() => fileInputRef.current?.click()}>\n <Upload /> {translate('common.upload')}\n </Button>\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n accept={accept ?? 'image/*'}\n className=\"hidden\"\n onChange={(e) => {\n handleUpload(Array.from(e.target.files ?? []))\n e.target.value = ''\n }}\n />\n </Row>\n\n <div\n className=\"grid min-h-0 flex-1 auto-rows-min grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5\"\n data-testid=\"asset-picker-grid\"\n >\n {store.status === 'loading' ? (\n <Text size=\"sm\" tone=\"muted\" className=\"col-span-full p-3\">\n {translate('cms.asset.loading')}\n </Text>\n ) : store.status === 'error' ? (\n <Row gap=\"2\" className=\"col-span-full p-3\" data-testid=\"asset-picker-error\">\n <AlertTriangle className=\"size-4 text-destructive\" />\n <Text size=\"sm\" tone=\"muted\">\n {store.errorMessage ?? translate('cms.asset.loadError')}\n </Text>\n </Row>\n ) : assets.length === 0 ? (\n <Text size=\"sm\" tone=\"muted\" className=\"col-span-full p-3\">\n {query.trim() ? translate('cms.asset.noMatches') : translate('cms.asset.empty')}\n </Text>\n ) : (\n assets.map((asset) => (\n <AssetPickerCard\n key={asset.id}\n asset={asset}\n selected={asset.id === value}\n onPick={() => commitPickerSelection(asset.id, { onChange, onOpenChange })}\n />\n ))\n )}\n </div>\n\n <Row gap=\"2\">\n <Spacer />\n {value ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => commitPickerSelection(null, { onChange, onOpenChange })}\n >\n {translate('common.clear')}\n </Button>\n ) : null}\n </Row>\n\n {dragging ? (\n <div className=\"pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-lg border-2 border-dashed border-primary bg-background/85\">\n <Row gap=\"2\" align=\"center\">\n <Upload className=\"size-5 text-primary\" />\n <Text className=\"font-medium\">{translate('cms.asset.dropToUpload')}</Text>\n </Row>\n </div>\n ) : null}\n </div>\n </ExpandableSurface>\n )\n}\n\n/** One selectable asset: EC-400 thumb tile + title/filename + alt text. The\n * internal asset id is intentionally not shown — it's noise to editors (EC-301). */\nfunction AssetPickerCard({\n asset,\n selected,\n onPick,\n}: {\n asset: AssetRecord\n selected: boolean\n onPick: () => void\n}) {\n return (\n <button\n type=\"button\"\n onClick={onPick}\n className={cn(\n 'flex flex-col gap-1.5 rounded-lg border p-2 text-left transition-colors',\n selected ? 'border-primary bg-primary/5' : 'border-border hover:bg-muted',\n )}\n data-testid=\"asset-picker-card\"\n aria-pressed={selected}\n >\n <span className=\"relative block\">\n <AssetThumb record={asset} className=\"aspect-video w-full\" />\n {selected ? (\n <span className=\"absolute right-1 top-1 grid size-5 place-items-center rounded-full bg-primary text-primary-foreground shadow\">\n <Check className=\"size-3\" />\n </span>\n ) : null}\n </span>\n <Text size=\"xs\" className=\"min-w-0 truncate font-medium\">\n {asset.title ?? asset.filename}\n </Text>\n <Text size=\"xs\" tone={asset.alt ? 'muted' : 'subtle'} className=\"truncate\">\n {asset.alt ?? translate('cms.asset.noAltText')}\n </Text>\n </button>\n )\n}\n"]}