@jbpark/live-editor 2.2.0 → 3.0.1

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 (39) hide show
  1. package/dist/{ast-CAhr9WXv.js → ast-D6R-dsk0.js} +20 -5
  2. package/dist/ast-D6R-dsk0.js.map +1 -0
  3. package/dist/{boundary-DQiKrXhI.js → boundary-BF7iZp6e.js} +2 -2
  4. package/dist/{boundary-DQiKrXhI.js.map → boundary-BF7iZp6e.js.map} +1 -1
  5. package/dist/{context-CJ0_ptf4.js → context-DH70wj9d.js} +3 -3
  6. package/dist/{context-CJ0_ptf4.js.map → context-DH70wj9d.js.map} +1 -1
  7. package/dist/{core-D5Hn-6ow.js → core-CbuS_p_d.js} +2 -2
  8. package/dist/{core-D5Hn-6ow.js.map → core-CbuS_p_d.js.map} +1 -1
  9. package/dist/dnd/index.d.ts +2 -2
  10. package/dist/dnd/index.js +2 -2
  11. package/dist/{dnd-DRivgZdt.js → dnd-CZJjzuTC.js} +311 -269
  12. package/dist/dnd-CZJjzuTC.js.map +1 -0
  13. package/dist/{document-CgUTKVQo.js → document-C6bNHl7l.js} +2 -2
  14. package/dist/document-C6bNHl7l.js.map +1 -0
  15. package/dist/editor/index.js +2 -2
  16. package/dist/{editor-Ds-mUYs_.js → editor-Ct9wuhLm.js} +3 -3
  17. package/dist/{editor-Ds-mUYs_.js.map → editor-Ct9wuhLm.js.map} +1 -1
  18. package/dist/error/index.js +2 -2
  19. package/dist/{error-B5MciRP7.js → error-lsJey-it.js} +2 -2
  20. package/dist/{error-B5MciRP7.js.map → error-lsJey-it.js.map} +1 -1
  21. package/dist/{index-DYm4nsej.d.ts → index-Bqc5kUAG.d.ts} +45 -35
  22. package/dist/index.d.ts +7 -4
  23. package/dist/index.js +5 -5
  24. package/dist/index.js.map +1 -1
  25. package/dist/preview/index.js +1 -1
  26. package/dist/{preview-DtBbnlwy.js → preview-CNVXyDgY.js} +4 -4
  27. package/dist/{preview-DtBbnlwy.js.map → preview-CNVXyDgY.js.map} +1 -1
  28. package/dist/provider/index.js +1 -1
  29. package/dist/{use-dynamic-tailwind-cdaivJXJ.js → use-dynamic-tailwind-C0Onss1A.js} +2 -2
  30. package/dist/use-dynamic-tailwind-C0Onss1A.js.map +1 -0
  31. package/dist/utils/ast/index.js +2 -2
  32. package/dist/utils/index.js +2 -2
  33. package/dist/{utils-DbfbS1yV.js → utils-BwEgY5pe.js} +2 -2
  34. package/dist/{utils-DbfbS1yV.js.map → utils-BwEgY5pe.js.map} +1 -1
  35. package/package.json +1 -1
  36. package/dist/ast-CAhr9WXv.js.map +0 -1
  37. package/dist/dnd-DRivgZdt.js.map +0 -1
  38. package/dist/document-CgUTKVQo.js.map +0 -1
  39. package/dist/use-dynamic-tailwind-cdaivJXJ.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dnd-CZJjzuTC.js","names":["t","Children","CoreEditor","Children","Panel","PropertyPanel","LiveError","Renderer","Dnd","Renderer","DndImpl"],"sources":["../src/components/dnd/droppable.tsx","../src/components/dnd/draggable.tsx","../src/components/dnd/layout-context.ts","../src/components/dnd/panel/use-items-editor.ts","../src/components/dnd/panel/items.tsx","../src/components/dnd/panel/node.tsx","../src/components/dnd/panel/children.tsx","../src/components/dnd/panel/icon-map.tsx","../src/components/dnd/panel/field.tsx","../src/components/dnd/panel/field-group.tsx","../src/components/dnd/panel/panel.tsx","../src/components/dnd/layout.tsx","../src/components/dnd/renderer.tsx","../src/components/dnd/sortable.tsx","../src/components/dnd/overlay.tsx","../src/components/dnd/use-section-document.ts","../src/components/dnd/dnd.tsx","../src/components/dnd/index.ts"],"sourcesContent":["import { useDroppable } from '@dnd-kit/core';\nimport { Typography } from '@jbpark/ui-kit';\n\nimport { cn } from '~/utils';\n\nconst Droppable = ({\n children,\n className,\n}: React.ComponentPropsWithRef<'div'>) => {\n const { setNodeRef, isOver, active } = useDroppable({\n id: 'sortable-area',\n });\n\n const { setNodeRef: setBottomRef, isOver: isBottomOver } = useDroppable({\n id: 'sortable-area-bottom',\n });\n\n const isNewItemDragging = active?.data.current?.type === 'new-item';\n const shouldHighlight = isOver && isNewItemDragging;\n const shouldHighlightBottom = isBottomOver && isNewItemDragging;\n\n return (\n <div\n ref={setNodeRef}\n className={cn(\n 'min-h-full',\n 'border-2 border-dashed p-1',\n shouldHighlight ? 'border-blue-300 bg-blue-50' : 'border-gray-200',\n className,\n )}\n >\n {children}\n {isNewItemDragging && (\n <div\n ref={setBottomRef}\n className={cn(\n 'mt-2 min-h-24',\n 'rounded-lg border-2 border-dashed',\n 'transition-all duration-200',\n 'flex items-center justify-center',\n shouldHighlightBottom\n ? 'border-blue-400 bg-blue-100'\n : 'border-gray-300 bg-gray-50',\n )}\n >\n <Typography.Text className=\"text-sm text-gray-500\">\n {shouldHighlightBottom ? 'Drop here' : 'Drag here to add at bottom'}\n </Typography.Text>\n </div>\n )}\n </div>\n );\n};\n\nexport default Droppable;\n","import { useDraggable } from '@dnd-kit/core';\nimport { Card } from '@jbpark/ui-kit';\n\nimport type { Section } from '~/types';\nimport { cn } from '~/utils';\n\nexport interface DraggableItemDragState {\n ref: (node: HTMLElement | null) => void;\n dragProps: React.HTMLAttributes<HTMLElement>;\n isDragging: boolean;\n}\n\nexport interface DraggableItemProps {\n item: Section;\n children: (drag: DraggableItemDragState) => React.ReactNode;\n}\n\n// Owns the dnd-kit wiring (useDraggable + the `type: 'new-item'` data shape\n// Dnd's onDragEnd expects) so a custom palette only has to decide how\n// an item *looks*, not how dragging itself works. Exported as\n// Dnd.DraggableItem for that purpose; also used internally for the default\n// palette rendering, so both paths share the exact same drag wiring.\nconst DraggableItem = ({ item, children }: DraggableItemProps) => {\n const { attributes, listeners, setNodeRef, isDragging } = useDraggable({\n id: item.id,\n data: { type: 'new-item', item },\n });\n\n return children({\n ref: setNodeRef,\n dragProps: { ...listeners, ...attributes },\n isDragging,\n });\n};\n\n// The built-in card look, shared by the default (non-custom) palette\n// rendering and the drag overlay's floating preview — both rendered a plain\n// `<Draggable>` before this became a children-render-prop component.\nexport interface DefaultDraggableItemProps {\n item: Section;\n onAdd?: (item: Section) => void;\n // Double-click is the desktop convenience shortcut alongside drag — a\n // single click there would fire on every aborted/failed drag attempt.\n // On mobile there's nowhere to drag *to* (the palette lives in a Drawer\n // stacked over the canvas), so a tap can't be a failed drag, and\n // double-tap-to-dblclick synthesis from touch is unreliable anyway\n // (iOS Safari inconsistently fires it, and it can compete with the\n // browser's native double-tap-to-zoom gesture). Tapping just adds there.\n tapToAdd?: boolean;\n}\n\nexport const DefaultDraggableItem = ({\n item,\n onAdd,\n tapToAdd = false,\n}: DefaultDraggableItemProps) => (\n <DraggableItem item={item}>\n {({ ref, dragProps, isDragging }) => (\n <Card\n ref={ref}\n style={{ opacity: isDragging ? 0.5 : 1 }}\n {...dragProps}\n className={cn(\n 'cursor-grab',\n 'outline-none',\n 'hover:border-blue-300 hover:shadow-md',\n isDragging && 'opacity-50',\n )}\n onClick={tapToAdd && onAdd ? () => onAdd(item) : undefined}\n onDoubleClick={onAdd ? () => onAdd(item) : undefined}\n >\n {item.name}\n </Card>\n )}\n </DraggableItem>\n);\n\nexport default DraggableItem;\n","import { createContext, useContext } from 'react';\n\nimport type { DndPalette, DndPanel } from './dnd';\n\n// The layout state a custom arrangement needs. Separate from the palette and\n// panel data because a layout decides *where* things go, not what they\n// contain — the built-in layout reads only this slice.\nexport interface DndLayout {\n // From `useResponsiveSize` — the same value that picks the stacked mobile\n // arrangement, so a custom layout can branch on it without repeating the\n // breakpoint check. Also what the built-in palette reads to decide\n // tap-to-add: at a mobile breakpoint a tap can't be a failed drag attempt\n // (there's nothing visible to drag onto behind the Drawer) and dblclick\n // synthesis from double-tap is unreliable, so a single tap adds.\n isMobile: boolean;\n // `null` when nothing is selected. The built-in layout uses it to open the\n // properties Drawer on mobile, where the panel has nowhere else to go.\n selectedId: string | null;\n clearSelection: () => void;\n // The palette Drawer's open state. Dnd owns it because adding an item\n // closes the Drawer; a layout only opens it.\n paletteOpen: boolean;\n setPaletteOpen: (open: boolean) => void;\n}\n\n// Everything `Live.Dnd` publishes to its children, read back through the\n// three hooks below rather than as one object — a custom panel has no\n// business seeing the palette's items, and narrow hooks say which part of\n// Dnd a component actually depends on.\n//\n// `canvas` is the one node here rather than data: the droppable, the\n// sortable list and each section's compiled iframe are Dnd's own machinery,\n// so `Live.Dnd.Canvas` places it but nobody reproduces it.\ninterface DndRegions extends DndLayout {\n palette: DndPalette;\n panel: DndPanel;\n canvas: React.ReactNode;\n}\n\nexport const DndRegionContext = createContext<DndRegions | null>(null);\n\n// Internal, and takes a `subject` the public hooks don't: the caller as it\n// appears in source — a hook call, or the region element that wraps one — so\n// rendering `<Live.Dnd.Palette />` outside `Live.Dnd` reports the element the\n// reader actually wrote rather than the hook behind it.\nexport const useDndRegions = (subject: string): DndRegions => {\n const regions = useContext(DndRegionContext);\n\n if (!regions) {\n throw new Error(`${subject} must be used inside <Live.Dnd>.`);\n }\n\n return regions;\n};\n\n// The palette's items and the callback that adds one to the canvas. Pair it\n// with `Live.Dnd.DraggableItem` for the drag wiring and you have the whole\n// built-in palette's input.\nexport const useDndPalette = (): DndPalette =>\n useDndRegions('useDndPalette()').palette;\n\n// The selected section, its editable bindings, and the callbacks that commit\n// through Dnd's AST-update pipeline — everything the built-in property panel\n// runs on.\nexport const useDndPanel = (): DndPanel => useDndRegions('useDndPanel()').panel;\n\n// Returns the context object itself, narrowed: identity is stable across\n// renders, so this is safe in a dependency array.\nexport const useDndLayout = (): DndLayout => useDndRegions('useDndLayout()');\n","import { useEffect, useMemo } from 'react';\n\nimport * as t from '@babel/types';\nimport { Toast } from '@jbpark/ui-kit';\nimport { useMultiSelect } from '@jbpark/use-hooks';\nimport { nanoid } from 'nanoid';\n\nimport {\n type BindingRenderLeaf,\n type BindingRenderMap,\n type DataAttrNode,\n appendArrayItem,\n duplicateArrayItems,\n extract,\n extractNodeValue,\n extractObjectProperties,\n findEditableChildren,\n generateCode,\n getCurrentValue,\n getStructuredValue,\n moveArrayItem,\n moveArrayItems,\n parseArrayExpression,\n parseBinding,\n parseValue,\n removeArrayItems,\n updateArrayItemProperty,\n updateArrayItemValue,\n} from '~/utils/ast';\n\nimport type { PanelBinding, PanelNodeChange } from '../dnd';\n\n// One data-bound element discovered inside a JSX-valued item property.\n// These are the elements the top-level `bindings` array can't reach —\n// `extract()` doesn't walk into an attribute expression, so they're found\n// by re-extracting the property's own JSX here (#308).\nexport interface ItemsEditorNestedElement {\n // The element's `data-id`, which is what commits address it by.\n id: string;\n tagName: string;\n bindings: PanelBinding[];\n}\n\nexport interface ItemsEditorNestedGroup {\n // The item property holding this JSX (e.g. `children`, `label`).\n property: string;\n elements: ItemsEditorNestedElement[];\n // Set instead of `elements` when the JSX parsed but declared no binding\n // at all. Editing the property's raw source is the only thing left to\n // offer, so this is a `jsx`-typed binding over that source (#298).\n fallback?: PanelBinding;\n}\n\nexport interface ItemsEditorItem {\n // Stable only for this parse of `value` — regenerated whenever the source\n // string changes. Fine as a React key, not as an identity across edits;\n // use `elementIndex` for that.\n id: string;\n // Position among the visible items of this kind, which is what selection\n // indices refer to.\n index: number;\n // Position in the array's elements, which is what every `~/utils/ast`\n // item function addresses. Differs from `index` when the array mixes\n // objects and primitives.\n elementIndex: number;\n // An object item's plain (non-JSX) properties, already resolved through\n // the binding `render` map.\n properties: PanelBinding[];\n // An object item's JSX-valued properties.\n nested: ItemsEditorNestedGroup[];\n // A primitive item's own value. Absent on object items.\n value?: PanelBinding;\n}\n\nexport interface ItemsEditorActions {\n add: () => void;\n move: (elementIndex: number, toIndex: number) => void;\n remove: (elementIndex: number) => void;\n duplicateSelected: () => void;\n moveSelected: (direction: 'up' | 'down') => void;\n removeSelected: () => void;\n}\n\nexport interface ItemsEditor {\n // Which kind the array is being edited as. The panel shows one kind at a\n // time; an array holding both is treated as objects, and the primitives\n // stay untouched rather than being dropped.\n kind: 'object' | 'primitive';\n items: ItemsEditorItem[];\n // `@jbpark/use-hooks`' multi-select state, re-exposed as-is: `selected`,\n // `toggle`, `isSelected`, `clear`, `replace`. Its indices are item\n // `index` values, not `elementIndex` — the actions below translate.\n selection: ReturnType<typeof useMultiSelect>;\n actions: ItemsEditorActions;\n // The source didn't parse as an array expression. `items` is empty; the\n // built-in panel also raises a toast.\n parseError: boolean;\n}\n\nexport interface ItemsEditorOptions {\n render?: BindingRenderMap;\n // Commits a whole new array source. Every mutation here goes through\n // `~/utils/ast`'s item functions, which re-parse the source and hand back\n // a string, so no AST node is held or edited across renders.\n onChange?: (value: string) => void;\n // Commits an edit to one nested element, addressed by its own `data-id`.\n // A single binding's `onChange` can't express this — see #308.\n onNodeChange?: PanelNodeChange;\n}\n\nconst resolveLeaf = (\n render: BindingRenderMap | undefined,\n key: string,\n): BindingRenderLeaf | null => {\n const leaf = render?.[key];\n\n return leaf && 'type' in leaf ? (leaf as BindingRenderLeaf) : null;\n};\n\nconst resolveMap = (\n render: BindingRenderMap | undefined,\n key: string,\n): BindingRenderMap | undefined => {\n const leaf = render?.[key];\n\n return leaf && !('type' in leaf) ? (leaf as BindingRenderMap) : undefined;\n};\n\ninterface RawObjectItem {\n id: string;\n index: number;\n elementIndex: number;\n editableProperties: ReturnType<typeof extractObjectProperties>;\n jsxBindings: Record<string, DataAttrNode[]>;\n jsxFallbacks: Record<string, string>;\n}\n\ninterface RawPrimitiveItem {\n id: string;\n index: number;\n elementIndex: number;\n value: string | number | boolean | null;\n type: ReturnType<typeof extractNodeValue>['type'];\n}\n\n// Pulls the data-bound elements out of one JSX-valued property. A container\n// declaring `children` wins outright: it owns the elements below it, so\n// listing them separately would offer the same edit twice.\nconst bindingsInJSX = (node: t.Expression): DataAttrNode[] => {\n const nodes = extract(generateCode(node));\n const container = nodes.find(n =>\n n.bindings?.some(b => b.property === 'children'),\n );\n\n if (container) {\n return [container];\n }\n\n const bindings: DataAttrNode[] = [];\n\n nodes.forEach(n => {\n if (\n n.bindings &&\n n.bindings.length > 0 &&\n n.dataAttributes.some(a => a.name === 'data-id')\n ) {\n bindings.push(n);\n }\n\n bindings.push(...findEditableChildren(n));\n });\n\n return bindings;\n};\n\n// The parse. Split from the binding construction below so the Babel work is\n// memoized on the source string alone, while the callbacks the bindings\n// close over stay current on every render.\nconst parseSource = (value: string) => {\n const ast = parseArrayExpression(value);\n\n if (!ast) {\n return { objectItems: [], primitiveItems: [], parseError: true };\n }\n\n const objectItems: RawObjectItem[] = [];\n const primitiveItems: RawPrimitiveItem[] = [];\n const elements = ast.elements.filter((element): element is t.Expression =>\n Boolean(element),\n );\n\n elements.forEach((element, elementIndex) => {\n if (!t.isObjectExpression(element)) {\n const extracted = extractNodeValue(element);\n\n primitiveItems.push({\n id: nanoid(6),\n index: primitiveItems.length,\n elementIndex,\n value: extracted.value,\n type: extracted.type,\n });\n return;\n }\n\n const jsxBindings: Record<string, DataAttrNode[]> = {};\n const jsxFallbacks: Record<string, string> = {};\n\n element.properties.forEach(prop => {\n if (\n !t.isObjectProperty(prop) ||\n !t.isIdentifier(prop.key) ||\n !(t.isJSXElement(prop.value) || t.isJSXFragment(prop.value))\n ) {\n return;\n }\n\n const propertyName = prop.key.name;\n\n try {\n const found = bindingsInJSX(prop.value);\n\n if (found.length > 0) {\n jsxBindings[propertyName] = found;\n } else {\n jsxFallbacks[propertyName] = generateCode(prop.value);\n }\n } catch (error) {\n console.error(\n `Failed to parse JSX in property '${propertyName}':`,\n error,\n );\n }\n });\n\n objectItems.push({\n id: nanoid(6),\n index: objectItems.length,\n elementIndex,\n editableProperties: extractObjectProperties(element),\n jsxBindings,\n jsxFallbacks,\n });\n });\n\n return { objectItems, primitiveItems, parseError: false };\n};\n\n// The array-editing engine behind the built-in Items panel, exposed so a\n// consumer can render their own markup over it (#237/#308 follow-up).\n//\n// What it saves reimplementing: re-parsing each item's JSX to find nested\n// data-bound elements, resolving the binding `render` map, translating\n// visible item positions to array element positions before every edit, and\n// reconciling the selection after a move or delete (#285). Everything comes\n// back as `PanelBinding`s, the same currency `useDndPanel()` and\n// `Live.Dnd.Field` already speak, so nothing here requires touching Babel.\nexport const useItemsEditor = (\n value: string,\n { render, onChange, onNodeChange }: ItemsEditorOptions = {},\n): ItemsEditor => {\n const { objectItems, primitiveItems, parseError } = useMemo(\n () => parseSource(value),\n [value],\n );\n\n useEffect(() => {\n if (parseError) {\n Toast.error('Failed to parse items', {\n description: 'Check the console for details.',\n });\n }\n }, [parseError]);\n\n const kind =\n primitiveItems.length > 0 && objectItems.length === 0\n ? 'primitive'\n : 'object';\n const isPrimitive = kind === 'primitive';\n\n const selection = useMultiSelect(\n isPrimitive ? primitiveItems.length : objectItems.length,\n );\n\n // `null` means the edit could not be applied.\n const commit = (next: string | null) => {\n if (next === null) {\n Toast.error('Failed to update this item', {\n description: 'Check the console for details.',\n });\n return;\n }\n\n onChange?.(next);\n };\n\n // Selection indices are positions among the visible items; every AST\n // function addresses element positions. Keeping the two apart is what\n // stops an edit from dropping the items that aren't on screen.\n const elementIndicesOf = (indices: Set<number>) => {\n const items = isPrimitive ? primitiveItems : objectItems;\n\n return new Set(\n items\n .filter(item => indices.has(item.index))\n .map(item => item.elementIndex),\n );\n };\n\n const updateProperty = (\n elementIndex: number,\n propertyKey: string,\n next: unknown,\n ) => {\n commit(\n updateArrayItemProperty(value, elementIndex, propertyKey, next, render),\n );\n };\n\n const actions: ItemsEditorActions = {\n add: () => commit(appendArrayItem(value, kind)),\n\n move: (elementIndex, toIndex) => {\n const items = isPrimitive ? primitiveItems : objectItems;\n const target = items.find(item => item.index === toIndex);\n\n if (!target) {\n return;\n }\n\n commit(moveArrayItem(value, elementIndex, target.elementIndex));\n // Positions shift after a move, but the count doesn't, so\n // `useMultiSelect` never reconciles the set on its own — clear it so a\n // later bulk action can't target the wrong elements. See #285.\n selection.clear();\n },\n\n remove: elementIndex => {\n commit(removeArrayItems(value, new Set([elementIndex]), kind));\n // Removing an item shifts every position after it; same reasoning.\n selection.clear();\n },\n\n duplicateSelected: () =>\n commit(duplicateArrayItems(value, elementIndicesOf(selection.selected))),\n\n moveSelected: direction => {\n const result = moveArrayItems(\n value,\n elementIndicesOf(selection.selected),\n direction,\n );\n\n if (!result) {\n commit(null);\n return;\n }\n\n // Element positions, which match selection indices for the\n // all-one-kind arrays this is built for.\n selection.replace(result.indices);\n commit(result.code);\n },\n\n removeSelected: () => {\n commit(\n removeArrayItems(value, elementIndicesOf(selection.selected), kind),\n );\n selection.clear();\n },\n };\n\n // Built fresh each render rather than inside the memo above: these close\n // over `onChange`/`onNodeChange`, and the work is a plain walk of the\n // already-parsed result — no Babel.\n const items: ItemsEditorItem[] = isPrimitive\n ? primitiveItems.map(item => ({\n id: item.id,\n index: item.index,\n elementIndex: item.elementIndex,\n properties: [],\n nested: [],\n value: {\n id: `primitive-${item.id}`,\n label: `item-${item.index}`,\n property: item.type,\n value: item.value ?? '',\n rawValue: String(item.value ?? ''),\n onChange: next =>\n commit(updateArrayItemValue(value, item.elementIndex, next)),\n },\n }))\n : objectItems.map(item => {\n const properties: PanelBinding[] = Object.entries(\n item.editableProperties,\n ).map(([key, prop]) => {\n const leaf = resolveLeaf(render, key);\n\n return {\n id: `item-${item.id}-${key}`,\n label: key,\n property: leaf ? (leaf.property ?? (leaf.type as string)) : key,\n type: leaf?.type,\n render: leaf ? leaf.render : resolveMap(render, key),\n value: parseValue(String(prop.value)),\n rawValue: String(prop.value),\n // Carried through so a consumer can label the control with the\n // property's actual kind, as the built-in panel does.\n meta: { valueType: prop.type },\n onChange: next => updateProperty(item.elementIndex, key, next),\n };\n });\n\n const nested: ItemsEditorNestedGroup[] = [\n ...Object.entries(item.jsxBindings).map(([property, nodes]) => ({\n property,\n elements: nodes.flatMap(node => {\n const id = node.dataAttributes.find(\n a => a.name === 'data-id',\n )?.value;\n const attr = node.dataAttributes.find(\n a => a.name === 'data-binding',\n )?.value;\n\n if (!id || !attr) {\n return [];\n }\n\n const parsed = node.bindings ?? parseBinding(attr);\n\n if (!parsed.length) {\n return [];\n }\n\n return [\n {\n id,\n tagName: node.tagName || 'element',\n bindings: parsed.map(binding => ({\n id,\n label: binding.label,\n property: binding.property,\n type: binding.type,\n widget: binding.widget,\n options: binding.options,\n render: binding.render,\n min: binding.min,\n max: binding.max,\n pattern: binding.pattern,\n required: binding.required,\n meta: binding.meta,\n value: getStructuredValue(\n node,\n binding.property,\n binding.type,\n ),\n rawValue: getCurrentValue(node, binding.property),\n onChange: (next: unknown) =>\n onNodeChange?.({\n id,\n label: binding.label,\n property: binding.property,\n value: next,\n }),\n })),\n },\n ];\n }),\n })),\n ...Object.entries(item.jsxFallbacks).map(([property, code]) => ({\n property,\n elements: [],\n fallback: {\n id: `item-${item.id}-${property}-jsx`,\n label: property,\n property,\n type: 'jsx' as const,\n value: code,\n rawValue: code,\n onChange: (next: unknown) =>\n updateProperty(item.elementIndex, property, next),\n },\n })),\n ];\n\n return {\n id: item.id,\n index: item.index,\n elementIndex: item.elementIndex,\n properties,\n nested,\n };\n });\n\n return { kind, items, selection, actions, parseError };\n};\n","import { Button, Checkbox } from '@jbpark/ui-kit';\nimport { ArrowDown, ArrowUp, Copy, Plus, X } from 'lucide-react';\n\nimport type { BindingRenderMap } from '~/utils/ast';\n\nimport type { PanelNodeChange } from '../dnd';\nimport Field from './field';\nimport {\n type ItemsEditorNestedGroup,\n useItemsEditor,\n} from './use-items-editor';\n\ninterface Props {\n value: string;\n render?: BindingRenderMap;\n onChange?: (value: string) => void;\n onChildChange?: PanelNodeChange;\n}\n\ninterface BulkActionsBarProps {\n count: number;\n onDuplicate: () => void;\n onMoveUp: () => void;\n onMoveDown: () => void;\n onDelete: () => void;\n onClear: () => void;\n}\n\nconst BulkActionsBar = ({\n count,\n onDuplicate,\n onMoveUp,\n onMoveDown,\n onDelete,\n onClear,\n}: BulkActionsBarProps) => {\n if (count === 0) {\n return null;\n }\n\n return (\n <div\n className=\"flex items-center justify-between rounded border\n border-blue-200 bg-blue-50 p-2\"\n >\n <div className=\"text-xs font-medium text-blue-700\">{count} selected</div>\n <div className=\"flex items-center space-x-1\">\n <Button\n size=\"small\"\n icon={<Copy />}\n title=\"Duplicate selected\"\n onClick={onDuplicate}\n />\n <Button\n size=\"small\"\n icon={<ArrowUp />}\n title=\"Move selected up\"\n onClick={onMoveUp}\n />\n <Button\n size=\"small\"\n icon={<ArrowDown />}\n title=\"Move selected down\"\n onClick={onMoveDown}\n />\n <Button\n danger\n size=\"small\"\n icon={<X />}\n title=\"Delete selected\"\n onClick={onDelete}\n />\n <Button size=\"small\" onClick={onClear}>\n Clear\n </Button>\n </div>\n </div>\n );\n};\n\n// The data-bound elements found inside one JSX-valued property, or the\n// raw-source fallback when that property declared no binding at all (#298).\nconst NestedGroup = ({\n group,\n onNodeChange,\n}: {\n group: ItemsEditorNestedGroup;\n onNodeChange?: PanelNodeChange;\n}) => {\n if (group.fallback) {\n return (\n <div className=\"space-y-2\">\n <div className=\"text-xs font-medium text-blue-700\">\n {group.property}\n </div>\n <Field binding={group.fallback} onNodeChange={onNodeChange} />\n </div>\n );\n }\n\n return (\n <div className=\"space-y-2\">\n <div className=\"text-xs font-medium text-blue-700\">\n {group.property} Bindings ({group.elements.length}):\n </div>\n {group.elements.map(element => (\n <div\n key={`${group.property}-${element.id}`}\n className=\"rounded border border-blue-100 bg-blue-50 p-2\"\n >\n <div className=\"mb-1 text-xs text-blue-600\">\n &lt;{element.tagName}&gt;\n </div>\n <div className=\"space-y-2 rounded\">\n <div className=\"space-y-1\">\n {element.bindings.map(binding => (\n <div key={binding.label} className=\"space-y-1\">\n <label className=\"block text-xs font-semibold text-gray-700\">\n {binding.label}\n <span className=\"ml-1 text-gray-400\">\n ({binding.property})\n </span>\n </label>\n <Field binding={binding} onNodeChange={onNodeChange} />\n </div>\n ))}\n </div>\n </div>\n </div>\n ))}\n </div>\n );\n};\n\n// Presentation for `useItemsEditor`. Everything that reads or writes the\n// array source lives in that hook, which is exported so a consumer can put\n// their own markup over the same engine — see its doc comment (#237/#308).\nconst Items = ({ value, render, onChange, onChildChange }: Props) => {\n const { kind, items, selection, actions } = useItemsEditor(value, {\n render,\n onChange,\n onNodeChange: onChildChange,\n });\n\n const bulkBar = (\n <BulkActionsBar\n count={selection.selected.size}\n onDuplicate={actions.duplicateSelected}\n onMoveUp={() => actions.moveSelected('up')}\n onMoveDown={() => actions.moveSelected('down')}\n onDelete={actions.removeSelected}\n onClear={selection.clear}\n />\n );\n\n const itemControls = (item: { index: number; elementIndex: number }) => (\n <div className=\"flex space-x-1\">\n <Button\n size=\"small\"\n icon={<ArrowUp />}\n disabled={item.index === 0}\n onClick={() => actions.move(item.elementIndex, item.index - 1)}\n />\n <Button\n size=\"small\"\n icon={<ArrowDown />}\n disabled={item.index === items.length - 1}\n onClick={() => actions.move(item.elementIndex, item.index + 1)}\n />\n <Button\n danger\n size=\"small\"\n icon={<X />}\n disabled={items.length <= 1}\n onClick={() => actions.remove(item.elementIndex)}\n />\n </div>\n );\n\n if (kind === 'primitive') {\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between\">\n <div className=\"text-sm font-semibold\">Items ({items.length})</div>\n <Button\n size=\"small\"\n icon={<Plus />}\n variant=\"solid\"\n color=\"green\"\n onClick={actions.add}\n >\n Add Item\n </Button>\n </div>\n\n {bulkBar}\n\n {items.map(item => (\n <div\n key={item.id}\n className=\"space-y-2 rounded border border-gray-100 bg-gray-50 p-2\"\n >\n <div className=\"flex items-center justify-between space-x-1\">\n <div\n onClick={e => selection.toggle(item.index, e.shiftKey)}\n className=\"inline-flex\"\n >\n <Checkbox\n checked={selection.isSelected(item.index)}\n onChange={() => {}}\n />\n </div>\n {itemControls(item)}\n </div>\n <Field binding={item.value!} onNodeChange={onChildChange} />\n </div>\n ))}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between\">\n <div className=\"text-sm font-semibold\">Items ({items.length})</div>\n <Button\n size=\"small\"\n icon={<Plus />}\n variant=\"solid\"\n color=\"green\"\n disabled={items.length === 0}\n onClick={actions.add}\n >\n Add Item\n </Button>\n </div>\n\n {bulkBar}\n\n {items.map(item => (\n <div key={item.id} className=\"space-y-3 rounded border bg-gray-50 p-3\">\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center space-x-2\">\n <div\n onClick={e => selection.toggle(item.index, e.shiftKey)}\n className=\"inline-flex\"\n >\n <Checkbox\n checked={selection.isSelected(item.index)}\n onChange={() => {}}\n />\n </div>\n <div className=\"text-xs font-medium\">Item {item.index + 1}</div>\n </div>\n {itemControls(item)}\n </div>\n <div className=\"space-y-2\">\n {item.properties.map(binding => (\n <div key={`${item.id}-${binding.label}`}>\n <div className=\"flex flex-col space-y-2\">\n <label className=\"w-20 shrink-0 text-xs font-medium\">\n {binding.label}\n </label>\n <Field binding={binding} onNodeChange={onChildChange} />\n </div>\n <span className=\"text-right text-xs text-gray-500\">\n ({String(binding.meta?.valueType)})\n </span>\n </div>\n ))}\n </div>\n <div className=\"space-y-3 border-t pt-2\">\n {item.nested.length ? (\n item.nested.map(group => (\n <NestedGroup\n key={group.property}\n group={group}\n onNodeChange={onChildChange}\n />\n ))\n ) : (\n <div className=\"text-xs text-gray-500\">\n ✓ No JSX bindings found\n </div>\n )}\n </div>\n </div>\n ))}\n </div>\n );\n};\n\nexport default Items;\nexport { BulkActionsBar };\n","import {\n type DataAttrNode,\n getCurrentValue,\n getStructuredValue,\n parseBinding,\n} from '~/utils/ast';\n\nimport Field from './field';\n\nexport interface FieldEditorProps {\n data: DataAttrNode;\n onChange?: (params: {\n id: string;\n label: string;\n property: string;\n value: unknown;\n }) => void;\n}\n\nconst Node = ({ data, onChange }: FieldEditorProps) => {\n const idAttr = data.dataAttributes.find(a => a.name === 'data-id');\n const bindingAttr = data.dataAttributes.find(a => a.name === 'data-binding');\n\n if (!idAttr?.value || !bindingAttr?.value) {\n return null;\n }\n\n const dataId = idAttr.value;\n const bindings = data.bindings || parseBinding(bindingAttr.value);\n\n if (!bindings.length) {\n return null;\n }\n\n return (\n <div className=\"space-y-2 rounded\">\n <div className=\"space-y-1\">\n {bindings.map(binding => {\n const currentValue = getCurrentValue(data, binding.property);\n const structuredValue = getStructuredValue(\n data,\n binding.property,\n binding.type,\n );\n\n return (\n <div key={binding.label} className=\"space-y-1\">\n <label className=\"block text-xs font-semibold text-gray-700\">\n {binding.label}\n <span className=\"ml-1 text-gray-400\">({binding.property})</span>\n </label>\n <Field\n binding={{\n id: dataId,\n label: binding.label,\n property: binding.property,\n type: binding.type,\n widget: binding.widget,\n options: binding.options,\n render: binding.render,\n min: binding.min,\n max: binding.max,\n pattern: binding.pattern,\n required: binding.required,\n meta: binding.meta,\n value: structuredValue,\n rawValue: currentValue,\n onChange: next =>\n onChange?.({\n id: dataId,\n label: binding.label,\n property: binding.property,\n value: next,\n }),\n }}\n onNodeChange={onChange}\n />\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport default Node;\n","import { useMemo } from 'react';\n\nimport { Button, Checkbox } from '@jbpark/ui-kit';\nimport { useMultiSelect } from '@jbpark/use-hooks';\nimport { ArrowDown, ArrowUp, Plus, X } from 'lucide-react';\nimport { nanoid } from 'nanoid';\n\nimport { type DataAttrNode, findEditableChildren } from '~/utils/ast';\nimport { moveSelectedIndices, removeIndices } from '~/utils/selection';\n\nimport type { PanelNodeChange } from '../dnd';\nimport { BulkActionsBar } from './items';\nimport Node from './node';\n\ninterface Props {\n value: DataAttrNode[];\n onChange?: (value: string) => void;\n onNodeChange?: PanelNodeChange;\n}\n\nconst Children = ({ value, onChange, onNodeChange }: Props) => {\n const items = useMemo(() => (Array.isArray(value) ? value : []), [value]);\n\n const selection = useMultiSelect(items.length);\n\n const editableChildrenMap = useMemo(() => {\n const map = new Map<number, DataAttrNode[]>();\n items.forEach((item, index) => {\n const editableNodes = findEditableChildren(item);\n if (editableNodes.length > 0) {\n map.set(index, editableNodes);\n }\n });\n return map;\n }, [items]);\n\n const moveItem = (fromIndex: number, toIndex: number) => {\n const nextItems = [...items];\n const [movedItem] = nextItems.splice(fromIndex, 1);\n nextItems.splice(toIndex, 0, movedItem!);\n\n onChange?.(JSON.stringify(nextItems));\n };\n\n const moveSelectedItems = (\n indices: Set<number>,\n direction: 'up' | 'down',\n ) => {\n const { items: nextItems, indices: nextIndices } = moveSelectedIndices(\n items,\n indices,\n direction,\n );\n\n selection.replace(nextIndices);\n onChange?.(JSON.stringify(nextItems));\n };\n\n const deleteSelectedItems = (indices: Set<number>) => {\n if (items.length - indices.size < 1) {\n return;\n }\n\n const nextItems = removeIndices(items, indices);\n onChange?.(JSON.stringify(nextItems));\n };\n\n const deleteItem = (index: number) => deleteSelectedItems(new Set([index]));\n\n const addItem = () => {\n const template = items[0] || createDefaultItem();\n const newItem = cloneDataAttrNode(template);\n\n const nextItems = [...items, newItem];\n onChange?.(JSON.stringify(nextItems));\n };\n\n const duplicateSelectedItems = (indices: Set<number>) => {\n const sources = [...indices]\n .sort((a, b) => a - b)\n .map(index => items[index])\n .filter((item): item is DataAttrNode => Boolean(item));\n\n if (sources.length === 0) {\n return;\n }\n\n const clones = sources.map(cloneDataAttrNode);\n onChange?.(JSON.stringify([...items, ...clones]));\n };\n\n const createDefaultItem = (): DataAttrNode => ({\n id: nanoid(6),\n tagName: 'div',\n attributes: [\n { name: 'data-id', value: nanoid(6) },\n { name: 'data-item', value: 'true' },\n ],\n dataAttributes: [\n { name: 'data-id', value: nanoid(6) },\n { name: 'data-item', value: 'true' },\n ],\n textContent: '',\n children: [],\n });\n\n const cloneDataAttrNode = (node: DataAttrNode): DataAttrNode => ({\n ...node,\n id: nanoid(6),\n attributes: node.attributes.map(attr => ({\n ...attr,\n value: attr.name === 'data-id' ? nanoid(6) : attr.value,\n })),\n dataAttributes: node.dataAttributes.map(attr => ({\n ...attr,\n value: attr.name === 'data-id' ? nanoid(6) : attr.value,\n })),\n children: node.children?.map(cloneDataAttrNode),\n });\n\n return (\n <div className=\"space-y-3\">\n <div className=\"flex items-center justify-between\">\n <div className=\"text-sm font-semibold text-green-700\">\n Children Items ({items.length})\n </div>\n <Button size=\"small\" color=\"green\" icon={<Plus />} onClick={addItem}>\n Add Child\n </Button>\n </div>\n\n <BulkActionsBar\n count={selection.selected.size}\n onDuplicate={() => duplicateSelectedItems(selection.selected)}\n onMoveUp={() => moveSelectedItems(selection.selected, 'up')}\n onMoveDown={() => moveSelectedItems(selection.selected, 'down')}\n onDelete={() => {\n deleteSelectedItems(selection.selected);\n selection.clear();\n }}\n onClear={selection.clear}\n />\n\n {items.map((item, itemIndex) => (\n <div\n key={item.id || itemIndex}\n className=\"space-y-2 rounded border border-green-200 bg-green-50 p-3\"\n >\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center space-x-2\">\n <div\n onClick={e => selection.toggle(itemIndex, e.shiftKey)}\n className=\"inline-flex\"\n >\n <Checkbox\n checked={selection.isSelected(itemIndex)}\n onChange={() => {}}\n />\n </div>\n <div className=\"text-xs font-medium text-green-800\">\n Child {itemIndex + 1} ({item.tagName || 'fragment'})\n </div>\n </div>\n\n <div className=\"flex space-x-1\">\n <Button\n size=\"small\"\n icon={<ArrowUp />}\n disabled={itemIndex === 0}\n onClick={() => moveItem(itemIndex, itemIndex - 1)}\n />\n <Button\n size=\"small\"\n icon={<ArrowDown />}\n disabled={itemIndex === items.length - 1}\n onClick={() => moveItem(itemIndex, itemIndex + 1)}\n />\n <Button\n title={\n items.length <= 1\n ? 'At least 1 item is required'\n : 'Delete item'\n }\n danger\n size=\"small\"\n icon={<X />}\n disabled={items.length <= 1}\n onClick={() => deleteItem(itemIndex)}\n />\n </div>\n </div>\n\n {editableChildrenMap.has(itemIndex) && (\n <div className=\"space-y-2\">\n <div className=\"text-xs font-medium text-green-700\">\n Editable Bindings:\n </div>\n {editableChildrenMap.get(itemIndex)!.map((editableNode, idx) => {\n const nodeId = editableNode.dataAttributes.find(\n a => a.name === 'data-id',\n )?.value;\n\n return (\n <div\n key={`editable-${itemIndex}-${nodeId || idx}`}\n className=\"rounded border border-green-100 bg-white p-2\"\n >\n <div className=\"mb-1 text-xs text-green-600\">\n {editableNode.tagName}\n </div>\n <Node data={editableNode} onChange={onNodeChange} />\n </div>\n );\n })}\n </div>\n )}\n\n {!!item.children && !editableChildrenMap.has(itemIndex) && (\n <div className=\"space-y-1\">\n <div className=\"text-xs font-medium text-green-700\">\n Child Nodes:\n </div>\n {item.children.map((node, nodeIndex) => (\n <div\n key={`node-${itemIndex}-${nodeIndex}`}\n className=\"ml-2 rounded border border-green-100 bg-white p-2\"\n >\n <Node data={node} onChange={onNodeChange} />\n </div>\n ))}\n </div>\n )}\n </div>\n ))}\n </div>\n );\n};\n\nexport default Children;\n","import type { LucideIcon } from 'lucide-react';\nimport {\n AlertCircle,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n Bell,\n Bookmark,\n Calendar,\n Camera,\n Check,\n ChevronDown,\n ChevronRight,\n Clock,\n Download,\n Edit,\n Eye,\n Filter,\n Heart,\n Home,\n Image,\n Info,\n Link,\n Mail,\n Map,\n Menu,\n MessageCircle,\n Phone,\n Plus,\n Search,\n Settings,\n Share,\n ShoppingCart,\n Star,\n Trash,\n Upload,\n User,\n X,\n} from 'lucide-react';\n\nexport const ICON_MAP: Record<string, LucideIcon> = {\n AlertCircle,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n Bell,\n Bookmark,\n Calendar,\n Camera,\n Check,\n ChevronDown,\n ChevronRight,\n Clock,\n Download,\n Edit,\n Eye,\n Filter,\n Heart,\n Home,\n Image,\n Info,\n Link,\n Mail,\n Map,\n Menu,\n MessageCircle,\n Phone,\n Plus,\n Search,\n Settings,\n Share,\n ShoppingCart,\n Star,\n Trash,\n Upload,\n User,\n X,\n};\n\n// The label/value pairs Field's icon-picker feeds to Select, derived once\n// from ICON_MAP — exported (see index.ts) so a custom panel can\n// reach icon-picker parity without rebuilding this itself, per #236/#237.\nexport const ICON_OPTIONS = Object.entries(ICON_MAP).map(([name, Icon]) => ({\n label: (\n <span className=\"flex items-center gap-2\">\n <Icon size={14} />\n {name}\n </span>\n ),\n value: name,\n}));\n","import { type ComponentProps, useEffect, useRef, useState } from 'react';\n\nimport {\n Checkbox,\n ColorPicker,\n DatePicker,\n Input,\n RichTextEditor,\n Select,\n Upload,\n type UploadFile,\n} from '@jbpark/ui-kit';\nimport { useDebounce } from '@jbpark/use-hooks';\n\nimport CoreEditor from '~/components/editor/core';\nimport { BINDING_PROP } from '~/constants';\nimport { parseValue, validateBindingValue } from '~/utils/ast';\n\nimport type { PanelBinding, PanelNodeChange } from '../dnd';\nimport Children from './children';\nimport { ICON_MAP, ICON_OPTIONS } from './icon-map';\nimport Items from './items';\n\n// Exported as `Live.Dnd.Field` (see index.ts) so a custom panel can\n// hand any single binding back to the built-in control instead of\n// reimplementing it — most usefully for `items`/`children` bindings, whose\n// editors discover nested data-bound elements by re-extracting the value's\n// own JSX (~100 lines of Babel walking a consumer would otherwise have to\n// reproduce). Renders the *control* only; the built-in panel's label comes\n// from `FieldGroup`, so a consumer supplies their own heading and layout.\nexport interface FieldProps {\n binding: PanelBinding;\n // `Items`/`Children` edit a *different* element than `binding` itself —\n // an array item or a sibling child, each with its own id/label/property —\n // which `binding.onChange`'s single-value shape can't express. This is\n // the node-level escape hatch those two need (see #237's documented\n // items/children boundary). Not part of `PanelBinding`, which is\n // per-binding; it reaches a custom panel through `useDndPanel()`\n // instead (#308). Omit it and nested array/children edits won't commit.\n onNodeChange?: PanelNodeChange;\n}\n\nconst isColorProperty = (propertyName: string): boolean => {\n const name = propertyName.toLowerCase();\n return name.includes('color');\n};\n\nconst normalizeToHex = (value: string): string => {\n const trimmed = value.trim();\n\n if (/^#([0-9A-Fa-f]{3}){1,2}$/.test(trimmed)) {\n return trimmed;\n }\n return '#000000';\n};\n\nconst parseDateValue = (value: string): Date | undefined => {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value.trim());\n\n if (!match) {\n return undefined;\n }\n\n const [, year, month, day] = match;\n const date = new Date(Number(year), Number(month) - 1, Number(day));\n\n return Number.isNaN(date.getTime()) ? undefined : date;\n};\n\nconst formatDateValue = (date: Date): string => {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n\n return `${year}-${month}-${day}`;\n};\n\n// ColorPicker's onChange fires on every drag frame — committing straight\n// to `onChange` (which drives the AST parse/mutate/re-serialize +\n// generateSections + compile pipeline, see #130) makes a single drag cost\n// upward of 15-25ms per frame. Debouncing the *commit* keeps that pipeline\n// to roughly one run per pause instead of one per frame, while a local\n// `liveValue` state keeps the swatch/hex text updating every frame for\n// responsiveness — ColorPicker is fully controlled (`useControllableState`\n// with `value` always set here), so without this it would visually snap\n// back to the last committed color between debounced commits.\nconst COLOR_COMMIT_DELAY = 75;\n\n// A curated subset rather than `toolbar` (every preset): the panel is a\n// small sidebar field, not a full document editor, so this keeps to the\n// formatting controls most binding content actually needs.\nconst RICHTEXT_TOOLBAR: ComponentProps<typeof RichTextEditor>['toolbar'] = [\n 'bold',\n 'italic',\n 'underline',\n 'bulletList',\n 'orderedList',\n 'link',\n];\n\ninterface ColorPickerFieldProps {\n value: string;\n onChange: (value: string) => void;\n}\n\nconst ColorPickerField = ({ value, onChange }: ColorPickerFieldProps) => {\n const [liveValue, setLiveValue] = useState(value);\n // Tracks `value` purely to detect an external change during render (see\n // below) — refs can't be read/written during render, so this has to be\n // state even though nothing here reads `prevValue` itself afterward.\n const [prevValue, setPrevValue] = useState(value);\n const lastCommittedRef = useRef(value);\n\n // The committed `value` can also change from outside (undo/redo, another\n // field touching the same binding) — stay in sync with it rather than\n // only ever tracking our own commits. Adjusted during render (React's\n // recommended \"reset state when a prop changes\" pattern) rather than in\n // an effect, so the mismatched frame never actually paints.\n if (value !== prevValue) {\n setPrevValue(value);\n setLiveValue(value);\n }\n\n // `lastCommittedRef` only needs to be current by the time `commit` next\n // runs (always from an event handler / debounce timer, never render), so\n // syncing it in an effect — instead of alongside the state adjustment\n // above — keeps the ref access out of the render phase entirely.\n useEffect(() => {\n lastCommittedRef.current = value;\n }, [value]);\n\n const commit = (next: string) => {\n if (next === lastCommittedRef.current) {\n return;\n }\n lastCommittedRef.current = next;\n onChange(next);\n };\n\n const debouncedCommit = useDebounce(() => commit(liveValue), {\n delay: COLOR_COMMIT_DELAY,\n autoInvoke: false,\n });\n\n return (\n <ColorPicker\n showText\n value={liveValue}\n onChange={next => {\n setLiveValue(next);\n debouncedCommit();\n }}\n onOpenChange={open => {\n // Flush immediately on close (picker dismissed / selection\n // finished) instead of waiting out the debounce window, so the\n // last color is never at risk of being dropped by an unmount\n // racing the pending timeout.\n if (!open) {\n commit(liveValue);\n }\n }}\n />\n );\n};\n\nconst Field = ({ binding, onNodeChange }: FieldProps) => {\n // `value` is already structured (its real JS type); `rawValue` is the exact\n // source text used for the raw editors (Items/code/textarea) and as the\n // <input> defaultValue. See #238.\n const { id, value, rawValue, onChange } = binding;\n\n const [validationError, setValidationError] = useState<string | null>(null);\n\n // The text-like inputs below (url/asset/number/textarea) commit on blur, so\n // they need local live state to hold what the user is typing. Left\n // uncontrolled (`defaultValue`), they ignored later changes to the canonical\n // value — an undo/redo or another field touching the same binding — because\n // `Field` reconciles rather than remounts (stable `key={binding.label}`).\n // The stale text then got re-committed on blur, clobbering the undo. Track\n // the canonical `rawValue` with a render-phase reset, the same pattern\n // `ColorPickerField` uses above. See #284. (The date picker commits on\n // change, not blur, so it can bind the prop directly with no local state.)\n const [text, setText] = useState(rawValue);\n const [prevRawValue, setPrevRawValue] = useState(rawValue);\n\n if (rawValue !== prevRawValue) {\n setPrevRawValue(rawValue);\n setText(rawValue);\n }\n\n if (\n binding.property === 'items' ||\n binding.property === 'data' ||\n binding.type === 'array'\n ) {\n return (\n <Items\n value={rawValue}\n render={binding.render}\n onChange={onChange}\n onChildChange={onNodeChange}\n />\n );\n }\n\n if (binding.type === 'richtext') {\n return (\n <RichTextEditor\n value={rawValue}\n toolbar={RICHTEXT_TOOLBAR}\n onChange={next => {\n if (next !== rawValue) {\n onChange(next);\n }\n }}\n />\n );\n }\n\n if (binding.property === BINDING_PROP.INNER_HTML || binding.type === 'jsx') {\n const isHTML = binding.property === BINDING_PROP.INNER_HTML;\n\n return (\n <CoreEditor\n value={rawValue}\n height=\"150px\"\n fragment={!isHTML}\n raw={isHTML}\n onSave={next => {\n if (next !== rawValue) {\n onChange(next);\n }\n }}\n />\n );\n }\n\n if (binding.property === 'children' && Array.isArray(value)) {\n return (\n <Children value={value} onChange={onChange} onNodeChange={onNodeChange} />\n );\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n const objectValue = value as Record<string, unknown>;\n\n return (\n <div className=\"space-y-2 rounded border border-gray-200 bg-gray-50 p-2\">\n {Object.entries(objectValue).map(([key, val]) => (\n <div key={key} className=\"space-y-1\">\n <label className=\"block text-xs font-medium text-gray-600\">\n {key}\n </label>\n <Field\n binding={{\n id,\n label: key,\n property:\n binding.render?.[key] && 'type' in binding.render[key]\n ? (binding.render[key].type as string)\n : key,\n type:\n binding.render?.[key] && 'type' in binding.render[key]\n ? (binding.render[key] as { type: PanelBinding['type'] })\n .type\n : undefined,\n render:\n binding.render?.[key] && !('type' in binding.render[key])\n ? (binding.render[key] as PanelBinding['render'])\n : undefined,\n value: val,\n rawValue:\n typeof val === 'object' && val !== null\n ? JSON.stringify(val)\n : String(val),\n onChange: next => {\n onChange({ ...objectValue, [key]: next });\n },\n }}\n onNodeChange={onNodeChange}\n />\n </div>\n ))}\n </div>\n );\n }\n\n if (binding.type === 'boolean' || typeof value === 'boolean') {\n return (\n <Checkbox\n checked={value === true || value === 'true'}\n onChange={checked => {\n onChange(checked);\n }}\n />\n );\n }\n\n const stringValue = rawValue;\n\n if (binding.options && Array.isArray(binding.options)) {\n return (\n <Select\n value={stringValue}\n options={binding.options}\n onChange={next => {\n if (next !== value) {\n onChange(next);\n }\n }}\n />\n );\n }\n\n if (binding.type === 'color' || isColorProperty(binding.property)) {\n return (\n <ColorPickerField\n value={normalizeToHex(stringValue)}\n onChange={onChange}\n />\n );\n }\n\n if (binding.type === 'date') {\n return (\n <div>\n <DatePicker\n value={parseDateValue(stringValue)}\n onChange={date => {\n const next = date ? formatDateValue(date) : '';\n const result = validateBindingValue(binding, next);\n\n if (!result.valid) {\n setValidationError(result.message ?? 'Invalid value.');\n return;\n }\n\n setValidationError(null);\n\n if (next !== value) {\n onChange(next);\n }\n }}\n />\n {validationError && (\n <p className=\"mt-1 text-xs text-red-500\">{validationError}</p>\n )}\n </div>\n );\n }\n\n if (binding.type === 'url') {\n return (\n <div>\n <Input\n type=\"url\"\n value={text}\n onChange={e => setText(e.target.value)}\n placeholder=\"https://example.com\"\n onBlur={e => {\n const next = e.target.value.trim();\n const result = validateBindingValue(binding, next);\n\n if (!result.valid) {\n setValidationError(result.message ?? 'Invalid value.');\n return;\n }\n\n setValidationError(null);\n\n if (next !== value) {\n onChange(next);\n }\n }}\n />\n {validationError && (\n <p className=\"mt-1 text-xs text-red-500\">{validationError}</p>\n )}\n </div>\n );\n }\n\n // Checks `type` too, not just `widget`: a `type: 'icon-picker'` binding\n // parsed by `parseBinding` is already normalized to `widget: 'icon-picker'`\n // (see #236), but a hand-constructed BindingItem — e.g. the nested\n // render-leaf case just above, which doesn't carry `widget` — can still\n // arrive with the alias directly in `type`.\n if (binding.widget === 'icon-picker' || binding.type === 'icon-picker') {\n const SelectedIcon = ICON_MAP[stringValue];\n\n return (\n <div className=\"flex items-center gap-2\">\n <Select\n value={stringValue}\n options={ICON_OPTIONS}\n onChange={next => {\n if (next !== value) {\n onChange(next);\n }\n }}\n />\n {SelectedIcon && <SelectedIcon size={18} className=\"shrink-0\" />}\n </div>\n );\n }\n\n if (binding.widget === 'asset-picker' || binding.type === 'asset-picker') {\n const defaultUploadValue: UploadFile[] = stringValue\n ? [\n {\n uid: 'current',\n name: stringValue.split('/').pop() || 'asset',\n url: stringValue,\n },\n ]\n : [];\n\n return (\n <div className=\"space-y-2\">\n <Input\n value={text}\n onChange={e => setText(e.target.value)}\n placeholder=\"Enter an image URL\"\n onBlur={e => {\n const next = e.target.value.trim();\n const result = validateBindingValue(binding, next);\n\n if (!result.valid) {\n setValidationError(result.message ?? 'Invalid value.');\n return;\n }\n\n setValidationError(null);\n\n if (next !== value) {\n onChange(next);\n }\n }}\n />\n <Upload\n multiple={false}\n maxCount={1}\n accept=\"image/*\"\n defaultValue={defaultUploadValue}\n onChange={files => {\n const next = files[0]?.url ?? '';\n\n if (next !== value) {\n onChange(next);\n }\n }}\n />\n {validationError && (\n <p className=\"mt-1 text-xs text-red-500\">{validationError}</p>\n )}\n </div>\n );\n }\n\n if (binding.type === 'number' || typeof value === 'number') {\n return (\n <div>\n <Input\n type=\"number\"\n value={text}\n onChange={e => setText(e.target.value)}\n placeholder=\"Enter a numeric value\"\n onBlur={e => {\n const raw = e.target.value.trim();\n // Commit a real number, not a numeric string — the AST boundary\n // and `validateBindingValue` (its `min`/`max`) both expect the\n // value as its declared type now. An unparseable entry falls\n // back to the raw text so a genuine mistake still round-trips\n // rather than becoming `NaN`.\n const next: unknown =\n raw !== '' && !Number.isNaN(Number(raw)) ? Number(raw) : raw;\n const result = validateBindingValue(binding, next);\n\n if (!result.valid) {\n setValidationError(result.message ?? 'Invalid value.');\n return;\n }\n\n setValidationError(null);\n\n if (next !== value) {\n onChange(next);\n }\n }}\n />\n {validationError && (\n <p className=\"mt-1 text-xs text-red-500\">{validationError}</p>\n )}\n </div>\n );\n }\n\n return (\n <div>\n <Input.TextArea\n value={text}\n onChange={e => setText(e.target.value)}\n placeholder=\"Enter a value\"\n onBlur={e => {\n const raw = e.target.value.trim();\n // Untyped field: infer the value's type from the text the user\n // entered (so `42` commits as a number), the way the old boundary\n // did — but here, in the presentation layer, not by re-guessing in\n // the AST pipeline. A declared string-family type keeps the text\n // verbatim, so `\"{x}\"` stays a string.\n const next: unknown = binding.type ? raw : parseValue(raw);\n const result = validateBindingValue(binding, next);\n\n if (!result.valid) {\n setValidationError(result.message ?? 'Invalid value.');\n return;\n }\n\n setValidationError(null);\n\n if (next !== rawValue) {\n onChange(next);\n }\n }}\n />\n {validationError && (\n <p className=\"mt-1 text-xs text-red-500\">{validationError}</p>\n )}\n </div>\n );\n};\n\nexport default Field;\n","import type { PanelBinding, PanelNodeChange } from '../dnd';\nimport Field from './field';\n\ninterface Props {\n bindings: PanelBinding[];\n onNodeChange?: PanelNodeChange;\n}\n\n// One bordered group per element `id` — the same visual grouping `Node`\n// (panel/node.tsx) renders, but for the top-level panel list, where\n// `bindings` are already resolved PanelBindings (see dnd.tsx's `bindings`\n// useMemo). `Node` stays a separate component: it still parses a raw\n// DataAttrNode itself, which `Items` needs for elements it discovers\n// dynamically inside an array item's `children` (not present in the\n// top-level `bindings` array at all) — see #237's items/children boundary.\nconst FieldGroup = ({ bindings, onNodeChange }: Props) => (\n <div className=\"space-y-2 rounded\">\n <div className=\"space-y-1\">\n {bindings.map(binding => (\n <div key={binding.label} className=\"space-y-1\">\n <label className=\"block text-xs font-semibold text-gray-700\">\n {binding.label}\n <span className=\"ml-1 text-gray-400\">({binding.property})</span>\n </label>\n <Field binding={binding} onNodeChange={onNodeChange} />\n </div>\n ))}\n </div>\n </div>\n);\n\nexport default FieldGroup;\n","import { useMemo } from 'react';\n\nimport { Button, Typography } from '@jbpark/ui-kit';\nimport { ChevronDown, ChevronUp, Trash } from 'lucide-react';\n\nimport type { Section } from '~/types';\nimport { cn } from '~/utils';\n\nimport type { PanelBinding, PanelNodeChange } from '../dnd';\nimport FieldGroup from './field-group';\n\n// The built-in property panel. Reached publicly as `Live.Dnd.Panel`, which\n// is this in the container the desktop pane wants, driven from\n// `useDndPanel()` — every field here lines up with what that hook returns\n// (drop `onChange`, which this panel never needed), so the built-in panel and\n// a custom one run on the same data and the public surface can't drift into a\n// subset of it (#237).\n//\n// `onNodeChange` is the node-level escape hatch `Items`/`Children` use to\n// commit a *different* element's edit than any single\n// `PanelBinding.onChange` can express (see field.tsx's items/children\n// boundary note from step 1). Optional here only so this can be rendered\n// read-only for nested edits; leave it out with real data and nested\n// array/children edits silently don't commit (#308).\nexport interface PanelProps {\n item?: Section;\n onDelete?: (id: string) => void;\n // Reordering by dragging a section on the canvas doesn't work from\n // inside this panel on mobile — the canvas sits behind the Drawer this\n // panel renders in, so there's nothing visible to drag onto. These give\n // an explicit alternative that works regardless of layout.\n onMoveUp?: () => void;\n onMoveDown?: () => void;\n canMoveUp?: boolean;\n canMoveDown?: boolean;\n // `item`'s editable fields, already resolved to PanelBindings by Dnd's\n // `bindings` useMemo — the same data a custom panel receives, so\n // this panel doesn't re-derive it from DataAttrNode a second time (#237).\n bindings: PanelBinding[];\n onNodeChange?: PanelNodeChange;\n}\n\n// `bindings` is flat (one entry per bound property, across every editable\n// element in the section) — regroup by `id` to render the same \"one\n// bordered box per element\" layout as before. `bindings` is already\n// ordered element-by-element, property-by-property (dnd.tsx builds it via\n// `fields.flatMap`), so a Map preserves both the element order and each\n// element's own property order with no extra sorting.\nconst groupBindingsById = (bindings: PanelBinding[]): PanelBinding[][] => {\n const groups = new Map<string, PanelBinding[]>();\n\n for (const binding of bindings) {\n const group = groups.get(binding.id);\n\n if (group) {\n group.push(binding);\n } else {\n groups.set(binding.id, [binding]);\n }\n }\n\n return [...groups.values()];\n};\n\nconst Panel = ({\n item,\n onDelete,\n onMoveUp,\n onMoveDown,\n canMoveUp = false,\n canMoveDown = false,\n bindings,\n onNodeChange,\n}: PanelProps) => {\n const groups = useMemo(() => groupBindingsById(bindings), [bindings]);\n\n if (!item) {\n return (\n <Typography.Paragraph\n className={cn(\n 'p-4 text-sm text-gray-500',\n //\n )}\n >\n Please select a section.\n </Typography.Paragraph>\n );\n }\n\n return (\n <div\n className={cn(\n 'h-full space-y-4 p-4',\n 'overflow-x-hidden overflow-y-auto',\n //\n )}\n >\n <div className=\"flex items-center justify-between\">\n <Typography.Title className=\"text-lg font-semibold\">\n {item.name}\n </Typography.Title>\n <div className=\"flex items-center gap-1\">\n {onMoveUp && (\n <Button\n icon={<ChevronUp />}\n disabled={!canMoveUp}\n onClick={onMoveUp}\n aria-label=\"Move section up\"\n />\n )}\n {onMoveDown && (\n <Button\n icon={<ChevronDown />}\n disabled={!canMoveDown}\n onClick={onMoveDown}\n aria-label=\"Move section down\"\n />\n )}\n {onDelete && (\n <Button\n danger\n icon={<Trash />}\n onClick={() => onDelete(item.id)}\n aria-label=\"Delete section\"\n />\n )}\n </div>\n </div>\n {!groups.length && (\n <Typography.Text className=\"text-xs text-gray-400\">\n No editable elements.\n </Typography.Text>\n )}\n {groups.map(group => (\n <FieldGroup\n key={group[0]!.id}\n bindings={group}\n onNodeChange={onNodeChange}\n />\n ))}\n </div>\n );\n};\n\nexport default Panel;\n","import { Button, Drawer, Space, Splitter } from '@jbpark/ui-kit';\nimport { LayoutGrid } from 'lucide-react';\n\nimport { cn } from '~/utils';\n\nimport { DefaultDraggableItem } from './draggable';\nimport { useDndRegions } from './layout-context';\nimport PropertyPanel from './panel';\n\n// The regions take their content from context, so `children` is never a\n// consumer's to pass — everything else about the wrapper div is (className\n// is tailwind-merged over the defaults, so overriding one of them wins\n// rather than fighting).\nexport type DndRegionProps = Omit<\n React.ComponentPropsWithRef<'div'>,\n 'children'\n>;\n\n// The built-in palette and panel without their region wrapper. Both exist\n// because `Layout` renders them twice on mobile — once in a pane, once in a\n// Drawer that's already the scroll container and shouldn't inherit the\n// pane's background.\nconst PaletteItems = ({ subject }: { subject: string }) => {\n const {\n palette: { items, onAdd },\n isMobile,\n } = useDndRegions(subject);\n\n return (\n <Space orientation=\"vertical\" align=\"start\">\n {items.map(item => (\n <DefaultDraggableItem\n key={item.id}\n item={item}\n onAdd={onAdd}\n tapToAdd={isMobile}\n />\n ))}\n </Space>\n );\n};\n\nconst PanelFields = ({ subject }: { subject: string }) => {\n const {\n panel: {\n item,\n onDelete,\n onMoveUp,\n onMoveDown,\n canMoveUp,\n canMoveDown,\n bindings,\n onNodeChange,\n },\n } = useDndRegions(subject);\n\n return (\n <PropertyPanel\n item={item}\n onDelete={onDelete}\n onMoveUp={onMoveUp}\n onMoveDown={onMoveDown}\n canMoveUp={canMoveUp}\n canMoveDown={canMoveDown}\n bindings={bindings}\n onNodeChange={onNodeChange}\n />\n );\n};\n\n// The built-in palette, in the scroll container the desktop pane wants.\n// Replace it by putting your own component in `Layout`'s `palette` slot, or\n// anywhere in `Live.Dnd`'s children — `useDndPalette()` hands over the same\n// items and `onAdd` this reads.\nexport const Palette = ({ className, ...restProps }: DndRegionProps) => (\n <div\n className={cn(\n 'h-full overflow-y-auto bg-gray-50 p-4',\n className,\n //\n )}\n {...restProps}\n >\n <PaletteItems subject=\"<Live.Dnd.Palette>\" />\n </div>\n);\n\n// Owns the scroll container each section's iframe resolves by\n// `closest('[data-frame-container]')` to size itself against (see\n// frame/iframe.tsx), plus the containment/isolation styles that keep a\n// section's compiled CSS out of the editor chrome — hence a region rather\n// than a plain slot: a custom layout can move it, not lose it. Needs a\n// height-constrained parent, since it fills one (`h-full`). Render it\n// exactly once — the droppable and the sortable list inside use fixed ids,\n// and a second instance would duplicate both.\nexport const Canvas = ({ className, style, ...restProps }: DndRegionProps) => {\n const { canvas } = useDndRegions('<Live.Dnd.Canvas>');\n\n return (\n <div\n className={cn(\n 'relative h-full w-full overflow-y-auto',\n className,\n //\n )}\n data-frame-container\n style={{\n isolation: 'isolate',\n contain: 'layout style',\n transform: 'translateZ(0)',\n ...style,\n }}\n {...restProps}\n >\n {canvas}\n </div>\n );\n};\n\n// The built-in property panel. Same deal as `Palette`: replace it via\n// `Layout`'s `panel` slot or by placing your own component in `Live.Dnd`'s\n// children, driving it from `useDndPanel()`.\nexport const Panel = ({ className, ...restProps }: DndRegionProps) => (\n <div\n className={cn(\n 'h-full',\n className,\n //\n )}\n {...restProps}\n >\n <PanelFields subject=\"<Live.Dnd.Panel>\" />\n </div>\n);\n\nexport interface DndLayoutProps {\n // Replacements for the palette/panel regions, kept as slots so swapping\n // one out doesn't mean rebuilding the 3-pane Splitter and the mobile\n // Drawers around it. A slot is placed raw — it owns its own container,\n // unlike the built-in regions, which bring theirs. Drive it from\n // `useDndPalette()` / `useDndPanel()`.\n palette?: React.ReactNode;\n panel?: React.ReactNode;\n}\n\n// What `Live.Dnd` renders when given no children — the 3-pane desktop\n// Splitter, the stacked mobile canvas, and the mobile FAB/Drawers. Exported\n// so children can keep the built-in arrangement while wrapping it (a toolbar\n// above it, say) or while replacing just one region — and because\n// `@jbpark/ui-kit` is a dependency rather than a peer, so `Splitter` isn't\n// necessarily importable on the consumer's side.\nexport const Layout = ({ palette, panel }: DndLayoutProps) => {\n const { isMobile, selectedId, clearSelection, paletteOpen, setPaletteOpen } =\n useDndRegions('<Live.Dnd.Layout>');\n\n return (\n <>\n {isMobile ? (\n <Canvas />\n ) : (\n <Splitter withHandle orientation=\"horizontal\">\n <Splitter.Panel\n defaultSize=\"20%\"\n minSize=\"15%\"\n maxSize=\"35%\"\n collapsible\n >\n {palette ?? <Palette />}\n </Splitter.Panel>\n <Splitter.Panel defaultSize=\"60%\">\n <Canvas />\n </Splitter.Panel>\n <Splitter.Panel\n defaultSize=\"20%\"\n minSize=\"15%\"\n maxSize=\"35%\"\n collapsible\n >\n {panel ?? <Panel />}\n </Splitter.Panel>\n </Splitter>\n )}\n <Button\n type=\"primary\"\n shape=\"circle\"\n icon={<LayoutGrid />}\n aria-label=\"Components\"\n className=\"fixed right-4 bottom-4 z-20 md:hidden\"\n onClick={() => setPaletteOpen(true)}\n />\n {/* A slot goes in as-is; the built-ins go in without their region\n wrapper, since the Drawer is already the scroll container and the\n palette's gray background belongs to the desktop pane. */}\n <Drawer\n open={isMobile && paletteOpen}\n onClose={() => setPaletteOpen(false)}\n direction=\"bottom\"\n size=\"large\"\n title=\"Components\"\n >\n {palette ?? <PaletteItems subject=\"<Live.Dnd.Layout>\" />}\n </Drawer>\n <Drawer\n open={isMobile && Boolean(selectedId)}\n onClose={clearSelection}\n direction=\"bottom\"\n size=\"large\"\n title=\"Properties\"\n >\n {panel ?? <PanelFields subject=\"<Live.Dnd.Layout>\" />}\n </Drawer>\n </>\n );\n};\n\nexport default Layout;\n","import { memo } from 'react';\n\nimport ErrorBoundary from '~/components/error/boundary';\nimport LiveError from '~/components/error/error';\nimport Frame, { type FrameProps } from '~/components/frame';\nimport { useCompiledModule } from '~/components/preview/use-compiled-module';\nimport { useDynamicTailwind } from '~/components/preview/use-dynamic-tailwind';\n\ninterface Props {\n preview: string;\n modules?: Record<string, unknown>;\n headers?: Record<string, boolean>;\n frame?: FrameProps;\n dynamicTailwind?: boolean;\n provider?: (children: React.ReactNode) => React.ReactNode;\n}\n\n// Wrapped in memo() because `preview` is a plain string: for a section that\n// didn't change, the parent hands back the same content it computed last\n// render (see generateSections()/dnd.tsx), so a shallow prop comparison\n// lets React skip both the recompile below and reconciling this section's\n// iframe tree at all — see #97.\nconst Renderer = ({\n preview,\n headers,\n modules,\n frame,\n dynamicTailwind = false,\n provider,\n}: Props) => {\n const module = useCompiledModule(preview, modules);\n\n // In `shadow` mode there's no separate document to load a stylesheet into\n // — the shadow root only gets whatever CSS naturally inherits across the\n // boundary (see `frame/shadow.tsx`), not utility classes. So this section's\n // own Tailwind classes are compiled and portalled in as a `<style>` tag\n // alongside the rendered content, which crosses the shadow boundary fine\n // since it lives inside the same portal target.\n const { ref: wrapperRef, css: dynamicCSS } = useDynamicTailwind(\n preview,\n dynamicTailwind,\n );\n\n const renderProvider = (component: React.ReactNode) => {\n return provider ? provider(component) : component;\n };\n\n // Rendered in place of the frame rather than inside it: there is nothing to\n // portal into an iframe for code that never produced a component, and a\n // silent blank slot (the previous behaviour) gives the author no clue why\n // their section vanished. Mirrors preview/client.tsx's compile-error branch.\n if (module?.error) {\n return <LiveError message={module.error} title=\"Compile Error\" />;\n }\n\n const Component = module?.exports?.default;\n\n if (!Component) {\n return null;\n }\n\n return (\n <Frame {...frame} autoHeight>\n {container => (\n <div\n ref={wrapperRef}\n className=\"w-full overflow-x-hidden\"\n data-editor-mode\n >\n {/*\n Without this, a render error in any single canvas section\n propagated past Dnd and unmounted the whole editor — palette,\n canvas and panel — while the same error in <Preview> was caught\n and displayed (see #246). Kept inside the frame so the failure is\n reported in the slot the broken section occupies, and so a\n transient error while the author is mid-edit doesn't tear down and\n rebuild the iframe (script loading, style sync, resize observers)\n on every keystroke. `Error` is inline-styled, so it stays readable\n even in a frame that never received the host's CSS.\n\n resetKeys={[preview]} makes the fix itself the recovery signal: the\n next edit to this section produces a new preview string, which\n clears the caught error without needing a remount.\n\n No `Error.Guard` here, unlike client.tsx: it listens on `window`,\n not on its subtree, so one per section would mean N global\n listeners all tripping on any single error — every section would\n show a runtime error regardless of which one actually threw.\n\n Errors also stay local rather than going to ErrorContext, whose\n `error` is a single string shared by the whole tree: N sections\n reporting into it would overwrite each other with no way to tell\n which section failed.\n */}\n <ErrorBoundary resetKeys={[preview]}>\n {renderProvider(\n <>\n <Component\n headers={headers}\n container={container}\n //\n />\n {dynamicTailwind && dynamicCSS && <style>{dynamicCSS}</style>}\n </>,\n )}\n </ErrorBoundary>\n </div>\n )}\n </Frame>\n );\n};\n\nexport default memo(Renderer);\n","import { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { Button, Space } from '@jbpark/ui-kit';\nimport { Copy, Trash } from 'lucide-react';\n\nimport { cn } from '~/utils';\n\ninterface Props {\n id: string;\n name?: string;\n children: React.ReactNode;\n selected?: boolean;\n onClick?: () => void;\n onDelete?: (id: string) => void;\n onCopy?: (id: string) => void;\n}\n\nconst Sortable = ({\n id,\n children,\n selected,\n onClick,\n onDelete: _onDelete,\n onCopy: _onCopy,\n}: Props) => {\n const {\n attributes,\n listeners,\n setNodeRef,\n transform,\n transition,\n isDragging,\n isOver,\n active,\n } = useSortable({ id });\n\n const style = {\n transform: CSS.Transform.toString(transform),\n transition,\n opacity: isDragging ? 0.5 : 1,\n cursor: 'grab',\n };\n\n const isNewItemOver = isOver && active?.data.current?.type === 'new-item';\n\n const onDelete = (e: React.MouseEvent) => {\n e.stopPropagation();\n _onDelete?.(id);\n };\n\n const onCopy = (e: React.MouseEvent) => {\n e.stopPropagation();\n _onCopy?.(id);\n };\n\n return (\n <div\n ref={setNodeRef}\n style={style}\n {...attributes}\n {...listeners}\n onClick={onClick}\n className={cn(\n 'relative',\n selected && 'z-10 outline-2 outline-offset-2 outline-blue-500',\n isNewItemOver && 'border-t-4 border-t-green-500',\n //\n )}\n >\n <div\n className={cn(\n 'absolute inset-0 z-50',\n //\n )}\n />\n {children}\n {selected && (\n <Space\n className={cn(\n 'absolute top-1 right-1 z-60',\n //\n )}\n >\n <Button icon={<Copy />} onClick={onCopy} />\n <Button danger icon={<Trash />} onClick={onDelete} />\n </Space>\n )}\n </div>\n );\n};\n\nexport default Sortable;\n","import { useDndContext } from '@dnd-kit/core';\n\nimport type { FrameProps } from '~/components/frame';\nimport type { Section } from '~/types';\nimport { generateSection } from '~/utils';\n\nimport { DefaultDraggableItem } from './draggable';\nimport Renderer from './renderer';\nimport Sortable from './sortable';\n\ninterface Props {\n sections: Section[];\n renderProps: {\n fullCode: string;\n modules: Record<string, unknown>;\n frame?: FrameProps;\n dynamicTailwind?: boolean;\n };\n}\n\nconst Overlay = ({ sections, renderProps }: Props) => {\n const { active } = useDndContext();\n\n if (!active) {\n return null;\n }\n\n if (active.data.current?.type === 'new-item') {\n const item = active.data.current.item;\n\n return <DefaultDraggableItem item={item} />;\n }\n\n const section = sections.find(s => s.id === active.id);\n\n if (section) {\n const preview = generateSection(section.code, renderProps.fullCode);\n\n return (\n <Sortable id={section.id} name={section.name}>\n <Renderer\n preview={preview}\n modules={renderProps.modules}\n frame={renderProps.frame}\n dynamicTailwind={renderProps.dynamicTailwind}\n />\n </Sortable>\n );\n }\n\n return null;\n};\n\nexport default Overlay;\n","import { useCallback, useMemo, useState } from 'react';\n\nimport { arrayMove } from '@dnd-kit/sortable';\n\nimport type { Section } from '~/types';\nimport {\n createSectionPreviewCache,\n extractSections,\n replaceSections,\n} from '~/utils';\nimport { fillSectionIds, replaceIds } from '~/utils/ast';\n\nimport { usePreview } from '../context/states';\n\nexport interface SectionDocument {\n sections: Section[];\n previews: string[];\n selectedId: string | null;\n selectedItem?: Section;\n selectedIndex: number;\n select: (id: string) => void;\n clearSelection: () => void;\n add: (item: Pick<Section, 'name' | 'code'>, atIndex?: number) => void;\n remove: (id: string) => void;\n copy: (id: string) => void;\n move: (id: string | null, direction: 'up' | 'down') => void;\n reorder: (activeId: string, overId: string) => void;\n patch: (next: Partial<Section> & { id: string }) => void;\n}\n\n// Owns the document side of the DnD canvas: deriving sections from the code\n// string, tracking which one is selected, and committing every mutation.\n//\n// Extracted from Dnd (#245), where the commit sequence\n// `replaceSections -> onChange -> setCode` was spelled out seven separate\n// times. Naming it once means no mutation can perform half of it, and it\n// puts the section logic somewhere reachable without rendering dnd-kit.\nexport const useSectionDocument = (\n value: string,\n onChange?: (value: string) => void,\n): SectionDocument => {\n const { setCode } = usePreview();\n const [selectedId, setSelectedId] = useState<string | null>(null);\n\n // Sections identify themselves by `data-id`; `getSections` falls back to a\n // positional id for documents predating that (see #245). Filling the gap\n // here makes the ids below real identities rather than positions, so a\n // held `selectedId` survives an insert, copy, move or delete.\n //\n // Deliberately not committed on its own — like dnd.tsx's existing use of\n // fillIds for field ids, the filled document only reaches\n // `onChange`/`setCode` when a real mutation commits, so merely opening a\n // document never rewrites the author's code.\n const document = useMemo(() => fillSectionIds(value), [value]);\n const sections = useMemo(() => extractSections(document), [document]);\n\n // One cache per hook instance (lazy `useState` initializer, never\n // replaced) — see createSectionPreviewCache (#131). It's stateful by\n // design (remembers the previous render's previews to reuse the ones that\n // didn't change), which a `useMemo`/`useRef` can't do without touching a\n // ref during render; a cache object stored via `useState` and only ever\n // mutated through its own method isn't subject to that restriction the way\n // `ref.current` is.\n const [previewCache] = useState(() => createSectionPreviewCache());\n const previews = useMemo(\n () => previewCache.compute(document, sections),\n [previewCache, sections, document],\n );\n\n const selectedIndex = sections.findIndex(s => s.id === selectedId);\n const selectedItem = selectedIndex >= 0 ? sections[selectedIndex] : undefined;\n\n // The single place a set of sections becomes a new document. Takes only\n // `code` because that is genuinely all a commit reads — ids and names are\n // re-derived from the result, never carried across.\n //\n // Runs `fillSectionIds` on the way out so a section that arrived without\n // one still lands with an id: a palette template is a bare `<section>`\n // snippet with no `#app-container`, so it cannot be filled until after\n // it's spliced in. Returns the resulting sections so a caller that needs\n // to select what it just created can read the real id back rather than\n // inventing one.\n const commit = useCallback(\n (nextSections: { code: string }[]): Section[] => {\n const nextCode = fillSectionIds(\n replaceSections(\n document,\n nextSections.map(s => s.code),\n ),\n );\n\n onChange?.(nextCode);\n setCode(nextCode);\n\n return extractSections(nextCode);\n },\n [document, onChange, setCode],\n );\n\n const select = useCallback((id: string) => {\n setSelectedId(prev => (prev === id ? null : id));\n }, []);\n\n const clearSelection = useCallback(() => setSelectedId(null), []);\n\n const add = useCallback(\n (item: Pick<Section, 'name' | 'code'>, atIndex?: number) => {\n const next = { code: item.code };\n\n commit(\n atIndex === undefined || atIndex < 0\n ? [...sections, next]\n : [...sections.slice(0, atIndex), next, ...sections.slice(atIndex)],\n );\n },\n [commit, sections],\n );\n\n const remove = useCallback(\n (id: string) => {\n // Removes by position, not by predicate: `fillSectionIds` keeps ids\n // unique, but a filter would delete every match if that invariant ever\n // slipped — and this is the one destructive operation here, so it\n // shouldn't be the one relying on it.\n const index = sections.findIndex(s => s.id === id);\n\n if (index < 0) {\n return;\n }\n\n // Only the deleted section loses the selection. The previous\n // implementation cleared it unconditionally, so deleting any section\n // closed the panel for whichever one was open.\n if (id === selectedId) {\n setSelectedId(null);\n }\n\n commit(sections.filter((_, i) => i !== index));\n },\n [commit, sections, selectedId],\n );\n\n const copy = useCallback(\n (id: string) => {\n const index = sections.findIndex(s => s.id === id);\n const source = sections[index];\n\n if (!source) {\n return;\n }\n\n // replaceIds refreshes every data-id in the snippet, the section's own\n // included, so the copy carries a distinct identity into the document.\n const committed = commit([\n ...sections.slice(0, index + 1),\n { code: replaceIds(source.code) },\n ...sections.slice(index + 1),\n ]);\n\n // Read the new id back from the committed document. This used to\n // select a `uuidv4()` that was never written into the code and so\n // didn't exist after the next parse, leaving the panel empty right\n // after a copy (#245).\n setSelectedId(committed[index + 1]?.id ?? null);\n },\n [commit, sections],\n );\n\n const move = useCallback(\n (id: string | null, direction: 'up' | 'down') => {\n const index = sections.findIndex(s => s.id === id);\n const targetIndex = direction === 'up' ? index - 1 : index + 1;\n\n if (index < 0 || targetIndex < 0 || targetIndex >= sections.length) {\n return;\n }\n\n // No `setSelectedId` compensation needed any more: the id travels with\n // the section's own markup, so the selection follows it across a move.\n commit(arrayMove(sections, index, targetIndex));\n },\n [commit, sections],\n );\n\n const reorder = useCallback(\n (activeId: string, overId: string) => {\n const prevIndex = sections.findIndex(s => s.id === activeId);\n const nextIndex = sections.findIndex(s => s.id === overId);\n\n if (prevIndex < 0 || nextIndex < 0 || prevIndex === nextIndex) {\n return;\n }\n\n commit(arrayMove(sections, prevIndex, nextIndex));\n },\n [commit, sections],\n );\n\n const patch = useCallback(\n (next: Partial<Section> & { id: string }) => {\n commit(sections.map(s => (s.id === next.id ? { ...s, ...next } : s)));\n },\n [commit, sections],\n );\n\n return {\n sections,\n previews,\n selectedId,\n selectedItem,\n selectedIndex,\n select,\n clearSelection,\n add,\n remove,\n copy,\n move,\n reorder,\n patch,\n };\n};\n","import { Children, useEffect, useMemo, useState } from 'react';\n\nimport {\n DndContext,\n type DragEndEvent,\n type DragOverEvent,\n DragOverlay,\n type DragStartEvent,\n type Modifier,\n PointerSensor,\n closestCenter,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers';\nimport {\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\nimport { Space, Toast, Typography } from '@jbpark/ui-kit';\nimport { useResponsiveSize } from '@jbpark/use-hooks';\n\nimport { DRAGGABLE_ITEMS } from '~/constants';\nimport type { Section } from '~/types';\nimport {\n type BindingOption,\n type BindingRenderMap,\n type BindingType,\n type DataAttrNode,\n extract,\n fillIds,\n getCurrentValue,\n getStructuredValue,\n parseBinding,\n update,\n} from '~/utils/ast';\nimport type { UpdateFailure } from '~/utils/ast';\n\nimport { DEFAULT_TEMPLATE } from '../../constants';\nimport { cn, preloadScripts } from '../../utils';\nimport { usePreview } from '../context/states';\nimport { type FrameProps } from '../frame';\nimport Droppable from './droppable';\nimport Layout from './layout';\nimport { DndRegionContext } from './layout-context';\nimport Overlay from './overlay';\nimport Renderer from './renderer';\nimport Sortable from './sortable';\nimport { useSectionDocument } from './use-section-document';\n\n// Turn a structured `update` failure into a toast that names the actual\n// fault. Before #270 every failure showed \"Failed to update this field /\n// Check the console for details\" — but nothing was logged, so the console\n// was empty. Most of these are a wrong `property`/`label` in the element's\n// `data-binding`, not the value the author just typed, so the message points\n// there. `description` is only set for paths that genuinely log (parse\n// errors), so \"check the console\" is never a dead end again.\nconst describeUpdateFailure = (\n failure: UpdateFailure | undefined,\n label: string,\n): { title: string; description?: string } => {\n switch (failure?.reason) {\n case 'attribute-not-found':\n return {\n title: `Failed to update \"${label}\"`,\n description: `This element has no \"${failure.property}\" attribute — check the property in its data-binding.`,\n };\n case 'binding-not-declared':\n return {\n title: `Failed to update \"${label}\"`,\n description: `No binding for ${\n failure.property\n ? `property \"${failure.property}\"`\n : `label \"${label}\"`\n } is declared on this element's data-binding.`,\n };\n case 'duplicate-binding':\n return {\n title: `Failed to update \"${label}\"`,\n description: `${failure.count} bindings share ${\n failure.property\n ? `property \"${failure.property}\"`\n : `label \"${label}\"`\n } on this element — remove the duplicate in its data-binding.`,\n };\n case 'no-binding':\n return {\n title: `Failed to update \"${label}\"`,\n description: 'This element has no data-binding declaration.',\n };\n case 'element-not-found':\n return {\n title: `Failed to update \"${label}\"`,\n description: 'The target element could not be found in this section.',\n };\n case 'parse-error':\n return {\n title: `Failed to update \"${label}\"`,\n description: 'Check the console for details.',\n };\n default:\n return { title: `Failed to update \"${label}\"` };\n }\n};\n\n// What `useDndPalette()` returns. Deliberately just data: the drag wiring is\n// a component (`Live.Dnd.DraggableItem`) and the breakpoint belongs to\n// `useDndLayout()`, so a custom palette takes each from where it lives\n// rather than having all three funnelled through one object.\nexport interface DndPalette {\n items: Section[];\n // Appends the item to the canvas. Closes the mobile palette Drawer too,\n // which is a no-op wherever it isn't open.\n onAdd: (item: Section) => void;\n}\n\n// The node-level commit callback's shape, named because it's part of the\n// public surface in two places (`DndPanel`, `Field`) and was previously\n// spelled out inline in each — see #308.\nexport interface PanelNodeChange {\n (params: {\n id: string;\n label: string;\n property: string;\n value: unknown;\n }): void;\n}\n\n// What `useDndPanel()` returns — everything the built-in property panel runs\n// on, so a custom panel starts from the same place rather than re-deriving\n// any of it.\nexport interface DndPanel {\n item?: Section;\n onChange: (next: Partial<Section>) => void;\n onDelete: (id: string) => void;\n // Alternative to dragging a section to reorder it — needed since the\n // canvas sits behind the mobile Drawer the panel renders in, so\n // there's nothing visible to drag onto there.\n onMoveUp: () => void;\n onMoveDown: () => void;\n canMoveUp: boolean;\n canMoveDown: boolean;\n // `item`'s editable data-binding fields, already flattened to one entry\n // per bound property (across every non-<section> descendant carrying a\n // `data-binding` attribute). Each entry carries the binding's `type` and\n // current `value` plus an `onChange` wired straight into the same\n // AST-update pipeline the built-in panel uses — including the error Toast\n // on a bad edit. Switch on `type` to render your own control (an\n // `<input>`, `<textarea>`, `<select>`, ...) instead of the built-in one.\n bindings: PanelBinding[];\n // Node-level commit for elements that aren't in `bindings` — the nested\n // data-bound JSX held inside an `items`/`children` value, which the\n // built-in Items/Children editors discover by re-extracting that value's\n // own JSX. Those `data-id`s never reach `bindings` (the top-level\n // `extract()` doesn't walk into an attribute expression), and no single\n // `PanelBinding.onChange` can address them since each one closes over a\n // fixed `id` — hence this `(id, label, property, value)` channel. Hand it\n // to `Live.Dnd.Field` along with the binding, otherwise nested\n // array/children edits inside it silently don't commit (#308).\n onNodeChange: PanelNodeChange;\n}\n\n// One editable data-binding, flattened out of the selected section for a\n// custom panel. Exposes just what a consumer needs to render its own\n// control — the declared `type`, the current `value`, and an `onChange`\n// that commits through Dnd's AST-update pipeline — so it never has to touch\n// DataAttrNode/parseBinding/getCurrentValue itself.\nexport interface PanelBinding {\n // `data-id` of the owning element — stable across edits.\n id: string;\n // Human-readable label from the binding definition.\n label: string;\n // The bound prop/attribute name (e.g. `children`, `src`, `color`).\n property: string;\n // The declared data-binding type — switch on this to pick a control\n // (`string`/`url` -> <input>, `jsx`/`richtext` -> <textarea>, `boolean`\n // -> checkbox, ...). `undefined` means a plain string binding.\n type?: BindingType;\n // Presentation, as opposed to `type`'s data kind — an open string, not a\n // closed enum, since a custom panel can declare any widget it wants\n // (e.g. `'slider'`) and switch on it itself. The built-in panel\n // only recognizes `'icon-picker'`/`'asset-picker'`; anything else falls\n // back to the `type`-appropriate default control. See #236.\n widget?: string;\n // Present when the binding defines a fixed option set (render a <select>).\n options?: BindingOption[];\n // Present for `object`/`array` bindings whose nested keys/items declare\n // their own types — the same map the built-in panel uses to type each\n // nested field instead of falling back to a plain string input.\n render?: BindingRenderMap;\n // Constraints declared on the binding. `min`/`max` compare against the\n // real number `value` delivers for `type: 'number'` bindings (see\n // `validateBindingValue`).\n min?: number;\n max?: number;\n pattern?: string;\n required?: boolean;\n // Consumer-defined keys carried straight through from the authored\n // data-binding — namespaced instead of spread onto PanelBinding so they\n // can't collide with a future first-class field. Absent when nothing\n // extra was authored. See #234.\n meta?: Record<string, unknown>;\n // Current value as its real JS type — a number for `type: 'number'`, a\n // boolean for `type: 'boolean'`, an object/array for `object`/`array`,\n // a string otherwise. Switch on this without re-parsing. See #238.\n value: unknown;\n // The exact source text behind `value`, for cases that can't round-trip\n // through a JS value — `jsx`/`richtext` bindings, or an attribute whose\n // source is an expression you want to edit as text.\n rawValue: string;\n // Commit a new value through the same AST-update pipeline the built-in\n // panel uses (including the error Toast on a bad edit). Pass the value as\n // its real type; it's serialized once, at the AST boundary, where the\n // declared `type` is known — so no string quoting/guessing on your side.\n onChange: (value: unknown) => void;\n}\n\nexport interface Props extends Omit<\n React.ComponentPropsWithRef<'div'>,\n 'onChange'\n> {\n value?: string;\n props?: Record<string, unknown>;\n modules?: Record<string, unknown>;\n items?: Section[];\n frame?: FrameProps;\n dynamicTailwind?: boolean;\n provider?: (children: React.ReactNode) => React.ReactNode;\n onChange?: (value: string) => void;\n // The single customization slot. Omit it for the built-in editor. Supply\n // it and you own the arrangement: compose `Live.Dnd.Palette` /\n // `Live.Dnd.Canvas` / `Live.Dnd.Panel` (each the built-in region, in the\n // container it needs) and your own components in any structure you like.\n // The drag context wraps all of it, so drag-and-drop and field editing\n // keep working wherever a region lands. Your components read the same data\n // the built-ins do through `useDndPalette()` / `useDndPanel()` /\n // `useDndLayout()`.\n //\n // Note this replaces the mobile chrome too — the FAB and both Drawers live\n // in `Live.Dnd.Layout`, which is what runs when children are omitted.\n // Render it yourself (`<Live.Dnd.Layout panel={<MyPanel />} />`) to keep\n // the built-in arrangement while swapping one region. Render `Canvas` at\n // most once either way.\n children?: React.ReactNode;\n}\n\nconst conditionalModifiers: Modifier = args => {\n const { active } = args;\n\n if (active?.data.current?.type === 'new-item') {\n return args.transform;\n }\n\n return restrictToVerticalAxis(args);\n};\n\nconst Dnd = ({\n value: _value,\n props,\n modules = {},\n onChange: _onChange,\n className,\n items = [],\n frame,\n dynamicTailwind = false,\n provider,\n children,\n ...restProps\n}: Props) => {\n const [mobilePaletteOpen, setMobilePaletteOpen] = useState(false);\n\n const { breakpoint } = useResponsiveSize();\n const isMobile = breakpoint.current === 'xs' || breakpoint.current === 'sm';\n\n // Read-only here — `useSectionDocument` below owns `setCode` (the commit\n // side). `code` is still needed locally: it feeds `value`'s fallback\n // chain just below, and `value` itself is read again further down for\n // the drag overlay's `fullCode` — not something `useSectionDocument`\n // exposes back out.\n const { code } = usePreview();\n\n const sensors = useSensors(\n useSensor(PointerSensor, {\n activationConstraint: {\n distance: 10,\n },\n }),\n );\n\n // Uncontrolled usage (`<Live.Dnd />` with no `value`) used to read\n // nothing but DEFAULT_TEMPLATE forever: every edit committed through\n // useSectionDocument writes into PreviewContext, but this component\n // never read `code` back — so the section a reader just dragged in\n // vanished on the very next render. `Client` (preview/client.tsx)\n // already resolves the same dual-source situation with `_code || code`;\n // mirrored here, with DEFAULT_TEMPLATE kept only as the final fallback\n // for the case neither is set (fresh, empty context) — see #244.\n const value = _value || code || DEFAULT_TEMPLATE;\n\n const {\n sections,\n previews,\n selectedId,\n selectedItem,\n selectedIndex,\n select,\n clearSelection,\n add: addItem,\n remove: onDelete,\n copy: onCopy,\n move: moveSection,\n reorder,\n patch,\n } = useSectionDocument(value, _onChange);\n\n const onDragStart = (_: DragStartEvent) => {};\n\n const onDragOver = (_e: DragOverEvent) => {};\n\n const onDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n\n if (!over) {\n return;\n }\n\n if (active.data.current?.type === 'new-item') {\n const item = active.data.current.item as Section;\n const atBottom =\n over.id === 'sortable-area' || over.id === 'sortable-area-bottom';\n\n addItem(\n item,\n atBottom ? undefined : sections.findIndex(s => s.id === over.id),\n );\n return;\n }\n\n if (active.id !== over.id && sections.some(s => s.id === active.id)) {\n reorder(String(active.id), String(over.id));\n }\n };\n\n const onSelect = (id: string) => select(id);\n\n const onChange = (next: Partial<Section>) => {\n if (!next.id) {\n return;\n }\n\n patch(next as Partial<Section> & { id: string });\n };\n\n // Reads only the extracted `code` local, not `selectedItem`, so the\n // compiler can verify this dependency array actually matches what the\n // body reads — matches Panel's own former version of this same logic,\n // now shared here so both the built-in Panel and a custom one built on\n // `useDndPanel()` get the same extraction/update pipeline instead of each\n // needing it.\n const selectedCode = selectedItem?.code;\n const { fields, updatedCode, parseError } = useMemo(() => {\n if (!selectedCode) {\n return {\n fields: [] as DataAttrNode[],\n updatedCode: '',\n parseError: false,\n };\n }\n\n try {\n const updated = fillIds(selectedCode);\n const allNodes = extract(updated);\n const filtered = allNodes.filter(node => node.tagName !== 'section');\n\n return {\n fields: filtered,\n updatedCode: updated !== selectedCode ? updated : selectedCode,\n parseError: false,\n };\n } catch (e) {\n console.warn('⚠️ Parsing error', e);\n return {\n fields: [] as DataAttrNode[],\n updatedCode: '',\n parseError: true,\n };\n }\n }, [selectedCode]);\n\n useEffect(() => {\n if (parseError) {\n Toast.error('Failed to parse this section', {\n description: 'Check the console for details.',\n });\n }\n }, [parseError]);\n\n const onFieldChange = ({\n id,\n label,\n property,\n value: fieldValue,\n }: {\n id: string;\n label: string;\n property: string;\n value: unknown;\n }) => {\n const result = update(updatedCode, id, label, fieldValue, property);\n\n if (!result.success) {\n const { title, description } = describeUpdateFailure(\n result.failure,\n label,\n );\n Toast.error(title, description ? { description } : undefined);\n return;\n }\n\n if (selectedItem) {\n onChange({ ...selectedItem, code: result.code });\n }\n };\n\n // Flattens the extracted `fields` (one DataAttrNode per element) down to\n // one PanelBinding per bound property — the same walk the built-in\n // FieldEditor/Node does internally (data-id + parsed data-binding +\n // current value), but published through `useDndPanel()` as plain data so a\n // custom panel can render its own controls. Kept in a useMemo keyed on\n // `fields` alone; `onFieldChange` closes over `updatedCode`/`selectedItem`\n // but is stable enough per render, and rebuilding this array on every\n // render would re-render every panel consuming it.\n const bindings = useMemo<PanelBinding[]>(() => {\n return fields.flatMap(node => {\n const dataId = node.dataAttributes.find(a => a.name === 'data-id')?.value;\n const bindingAttr = node.dataAttributes.find(\n a => a.name === 'data-binding',\n )?.value;\n\n if (!dataId || !bindingAttr) {\n return [];\n }\n\n const parsed = node.bindings ?? parseBinding(bindingAttr);\n\n return parsed.map(binding => ({\n id: dataId,\n label: binding.label,\n property: binding.property,\n type: binding.type,\n widget: binding.widget,\n options: binding.options,\n render: binding.render,\n min: binding.min,\n max: binding.max,\n pattern: binding.pattern,\n required: binding.required,\n meta: binding.meta,\n value: getStructuredValue(node, binding.property, binding.type),\n rawValue: getCurrentValue(node, binding.property),\n onChange: (value: unknown) =>\n onFieldChange({\n id: dataId,\n label: binding.label,\n property: binding.property,\n value,\n }),\n }));\n });\n // onFieldChange is intentionally omitted — it's recreated every render\n // but only ever called from a user event, so closing over the latest\n // one via the render that produced these bindings is fine.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields]);\n\n useEffect(() => {\n if (frame?.scripts?.length) {\n preloadScripts(frame.scripts);\n }\n }, [frame?.scripts]);\n\n // Data, not nodes: the built-in palette and panel read these back through\n // `useDndPalette()`/`useDndPanel()` exactly as a custom one does, so\n // there's a single path and no way for the public surface to drift into a\n // subset of what the built-ins use — the point of #237.\n const palette: DndPalette = {\n items: items?.length ? items : DRAGGABLE_ITEMS,\n onAdd: (item: Section) => {\n addItem(item);\n setMobilePaletteOpen(false);\n },\n };\n\n const panel: DndPanel = {\n item: selectedItem,\n onChange,\n onDelete,\n onMoveUp: () => moveSection(selectedId, 'up'),\n onMoveDown: () => moveSection(selectedId, 'down'),\n canMoveUp: selectedIndex > 0,\n canMoveDown: selectedIndex >= 0 && selectedIndex < sections.length - 1,\n bindings,\n onNodeChange: onFieldChange,\n };\n\n // Content only — the frame container that wraps this (`data-frame-container`\n // plus the containment styles) belongs to `Live.Dnd.Canvas`, so a custom\n // layout can't accidentally drop it while still placing the canvas.\n const canvas = (\n <>\n <Droppable\n className={cn(\n !sections.length && 'h-full',\n //\n )}\n >\n {!sections.length ? (\n <div\n className={cn(\n 'flex items-center justify-center',\n 'h-full',\n 'text-gray-500',\n )}\n >\n <Space orientation=\"vertical\" align=\"center\">\n <Typography.Paragraph>No sections available</Typography.Paragraph>\n <Typography.Text>\n {isMobile\n ? 'Tap a component to add it'\n : 'Drag a component from the left to add it'}\n </Typography.Text>\n </Space>\n </div>\n ) : (\n <SortableContext\n items={sections.map(s => s.id)}\n strategy={verticalListSortingStrategy}\n >\n {sections.map((section, index) => (\n <Sortable\n key={section.id}\n id={section.id}\n name={section.name}\n selected={selectedId === section.id}\n onClick={() => onSelect(section.id)}\n onDelete={onDelete}\n onCopy={onCopy}\n >\n <Renderer\n preview={previews[index]!}\n modules={modules}\n frame={frame}\n dynamicTailwind={dynamicTailwind}\n provider={provider}\n {...props}\n />\n </Sortable>\n ))}\n </SortableContext>\n )}\n </Droppable>\n </>\n );\n\n return (\n <>\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n modifiers={[\n conditionalModifiers,\n //\n ]}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDragEnd={onDragEnd}\n >\n <div\n className={cn(\n 'relative flex h-full w-full',\n className,\n //\n )}\n {...restProps}\n >\n {/* Not memoized: `palette`, `panel` and `canvas` are all rebuilt\n each render anyway, so a memo would only add a dependency list\n to keep in sync. */}\n <DndRegionContext.Provider\n value={{\n palette,\n panel,\n canvas,\n isMobile,\n selectedId,\n clearSelection,\n paletteOpen: mobilePaletteOpen,\n setPaletteOpen: setMobilePaletteOpen,\n }}\n >\n {/* `Children.toArray` rather than a plain `children ??`: a JSX\n comment, or a `{cond && <MyLayout />}` that fell through,\n leaves `children` set but empty — and honouring that\n literally renders an editor with no regions at all, which\n looks like a broken build rather than a mistake in the\n layout. Falling back keeps the failure legible. */}\n {Children.toArray(children).length ? children : <Layout />}\n </DndRegionContext.Provider>\n </div>\n <DragOverlay>\n <Overlay\n sections={sections}\n renderProps={{\n fullCode: value,\n modules,\n frame,\n dynamicTailwind,\n ...props,\n }}\n />\n </DragOverlay>\n </DndContext>\n </>\n );\n};\n\nexport default Dnd;\n","import DndImpl, {\n type DndPalette,\n type DndPanel,\n type PanelBinding,\n type PanelNodeChange,\n type Props,\n} from './dnd';\nimport DraggableItem, {\n type DraggableItemDragState,\n type DraggableItemProps,\n} from './draggable';\nimport {\n Canvas,\n type DndLayoutProps,\n type DndRegionProps,\n Layout,\n Palette,\n Panel,\n} from './layout';\nimport {\n type DndLayout,\n useDndLayout,\n useDndPalette,\n useDndPanel,\n} from './layout-context';\nimport Field, { type FieldProps } from './panel/field';\nimport { ICON_MAP, ICON_OPTIONS } from './panel/icon-map';\nimport {\n type ItemsEditor,\n type ItemsEditorActions,\n type ItemsEditorItem,\n type ItemsEditorNestedElement,\n type ItemsEditorNestedGroup,\n type ItemsEditorOptions,\n useItemsEditor,\n} from './panel/use-items-editor';\n\ntype DndComponent = typeof DndImpl & {\n // Owns the dnd-kit wiring for a palette item and hands back `ref` /\n // `dragProps` / `isDragging`, so a custom palette decides how an item\n // *looks* without reimplementing how dragging works.\n DraggableItem: typeof DraggableItem;\n // The built-in control for one binding, exported so a custom panel can mix\n // its own controls with the built-in one per binding rather than choosing\n // all-or-nothing. Takes a `PanelBinding` straight out of `bindings` plus\n // `onNodeChange` — both `useDndPanel()` fields, so nothing internal is\n // needed to drive it. Most useful for `items`/`children` bindings, whose\n // editors find nested data-bound elements a consumer can't reach through\n // `bindings`. Renders the control only — supply your own label.\n Field: typeof Field;\n // The three built-in regions, each in the container it needs. Pass them as\n // `children` of `Live.Dnd` in any arrangement to own the layout, mixing in\n // your own components where you want to replace one. `Canvas` is the one\n // that can't be replaced — the droppable, the sortable list and each\n // section's compiled iframe are Dnd's own machinery — so render it exactly\n // once wherever the canvas belongs.\n Palette: typeof Palette;\n Canvas: typeof Canvas;\n Panel: typeof Panel;\n // The built-in arrangement: the 3-pane desktop Splitter, the stacked\n // mobile canvas, and the mobile FAB/Drawers. What `Live.Dnd` renders when\n // given no children, exported so children can wrap it (a toolbar above it,\n // say) or replace one region through its `palette`/`panel` slots without\n // rebuilding the rest. Also the only way to reach the built-in Splitter\n // layout without importing `@jbpark/ui-kit` directly, which a consumer may\n // not have as a direct dependency.\n Layout: typeof Layout;\n};\n\nconst Dnd = DndImpl as DndComponent;\n\nDnd.DraggableItem = DraggableItem;\nDnd.Field = Field;\nDnd.Palette = Palette;\nDnd.Canvas = Canvas;\nDnd.Panel = Panel;\nDnd.Layout = Layout;\n\nexport { DraggableItem, Field };\nexport { Palette, Canvas, Panel, Layout };\n// The data behind each region, so a component placed in `Live.Dnd`'s children\n// can replace one without losing what drives it: the palette's items and\n// `onAdd`, the panel's selected section/bindings/commit callbacks, and the\n// layout state the built-in mobile chrome runs on (`isMobile`, `selectedId` /\n// `clearSelection`, the palette Drawer's open state) — needed because\n// supplying children replaces that chrome along with the Splitter.\nexport { useDndPalette, useDndPanel, useDndLayout };\n// The array-editing engine behind the built-in Items panel, exposed for a\n// consumer who wants their own markup rather than the built-in control\n// (`Field` covers the latter). Everything it returns is `PanelBinding`s, so\n// the two compose: render the hook's own layout and hand individual\n// bindings to `Field` where the built-in control is good enough.\nexport { useItemsEditor };\n// The built-in panel's own `widget: 'icon-picker'` icon set/options —\n// exported so a custom panel can reach icon-picker parity (name ->\n// lucide-react component, and the same label/value pairs fed to Select)\n// instead of reimplementing an icon library, per #236/#237.\nexport { ICON_MAP, ICON_OPTIONS };\nexport type {\n Props,\n DndPalette,\n DndPanel,\n DndLayout,\n DndLayoutProps,\n DndRegionProps,\n PanelBinding,\n PanelNodeChange,\n FieldProps,\n ItemsEditor,\n ItemsEditorActions,\n ItemsEditorItem,\n ItemsEditorNestedElement,\n ItemsEditorNestedGroup,\n ItemsEditorOptions,\n DraggableItemProps,\n DraggableItemDragState,\n};\nexport default Dnd;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,MAAM,aAAa,EACjB,UACA,gBACwC;CACxC,MAAM,EAAE,YAAY,QAAQ,WAAW,aAAa,EAClD,IAAI,gBACN,CAAC;CAED,MAAM,EAAE,YAAY,cAAc,QAAQ,iBAAiB,aAAa,EACtE,IAAI,uBACN,CAAC;CAED,MAAM,oBAAoB,QAAQ,KAAK,SAAS,SAAS;CACzD,MAAM,kBAAkB,UAAU;CAClC,MAAM,wBAAwB,gBAAgB;CAE9C,OACE,qBAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,cACA,8BACA,kBAAkB,+BAA+B,mBACjD,SACF;EAPF,UAAA,CASG,UACA,qBACC,oBAAC,OAAD;GACE,KAAK;GACL,WAAW,GACT,iBACA,qCACA,+BACA,oCACA,wBACI,gCACA,4BACN;GAEA,UAAA,oBAAC,WAAW,MAAZ;IAAiB,WAAU;IACxB,UAAA,wBAAwB,cAAc;GACxB,CAAA;EACd,CAAA,CAEJ;;AAET;;;AC9BA,MAAM,iBAAiB,EAAE,MAAM,eAAmC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CAAA,EAAA,CAAA;AAEN;;;AC3iBA,MAAM,MAAMC;AAEZ,IAAI,gBAAgB;AACpB,IAAI,QAAQ;AACZ,IAAI,UAAU;AACd,IAAI,SAAS;AACb,IAAI,QAAQ;AACZ,IAAI,SAAS"}
@@ -94,7 +94,7 @@ const DRAGGABLE_ITEMS = [
94
94
  max: 40,
95
95
  // step/unit aren't fields this library knows about — they
96
96
  // survive parsing under binding.meta instead of being
97
- // stripped, so a custom renderPanel can read its own
97
+ // stripped, so a custom panel can read its own
98
98
  // per-field configuration back out. See #234.
99
99
  step: 4,
100
100
  unit: 'px',
@@ -39863,4 +39863,4 @@ const createSectionPreviewCache = () => {
39863
39863
  //#endregion
39864
39864
  export { __toESM as C, TS_PATTERNS as S, CONFIG as _, generateSectionPreview as a, DRAGGABLE_ITEMS as b, parseDocument as c, createBoundedCache as d, nanoid as f, BINDING_PROP as g, require_lib$7 as h, generateDocumentCode as i, replaceDocumentSections as l, require_lib$4 as m, createSectionPreviewCache as n, generateSectionPreviews as o, require_lib$3 as p, fillSectionIds as r, getSections as s, clearDocumentParseCache as t, traverse as u, DATA_ATTR as v, REGEX as x, DEFAULT_TEMPLATE as y };
39865
39865
 
39866
- //# sourceMappingURL=document-CgUTKVQo.js.map
39866
+ //# sourceMappingURL=document-C6bNHl7l.js.map