foldkit-mixins-builder 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,43 @@ pnpm add effect foldkit foldkit-bundle foldkit-builder foldkit-composition foldk
50
50
  Given `PageBuilder`, a `Builder.make` result from the
51
51
  [Builder's example](../builder/README.md#sixty-seconds):
52
52
 
53
+ <!-- docs-check standalone
54
+ import { Schema } from 'effect'
55
+ import { Builder } from 'foldkit-builder'
56
+ import { Block, Catalog, Content, Composition, Region } from 'foldkit-composition'
57
+ import { Renderer } from 'foldkit-composition/foldkit'
58
+ import { Entity } from 'foldkit-entity'
59
+ const Section = Block.define('Section', {
60
+ Props: Schema.Struct({ tone: Schema.Literals(['plain', 'accent']) }),
61
+ regions: { body: Region.many({ accepts: [Content.Flow] }) },
62
+ provides: [Content.Section],
63
+ })
64
+ const Heading = Block.define('Heading', {
65
+ Props: Schema.Struct({ text: Schema.String }),
66
+ provides: [Content.Flow],
67
+ })
68
+ const Site = Catalog.make({ blocks: [Section, Heading], roots: [Content.Section] })
69
+ const SiteRenderer = Renderer.make(Site, {
70
+ Section: ({ regions, h }) => h.section([], [...regions.body]),
71
+ Heading: ({ props, h }) => h.h2([], [props.text]),
72
+ })
73
+ const PageBuilder = Builder.make('PageBuilder', {
74
+ catalog: Site,
75
+ renderer: SiteRenderer,
76
+ starters: { Section: { tone: 'plain' }, Heading: { text: 'New heading' } },
77
+ })
78
+ const Page = Entity.define(
79
+ 'Page',
80
+ Schema.Struct({ id: Schema.String, title: Schema.String, document: Composition.Document }),
81
+ )
82
+ const PageInput = Entity.input(
83
+ Page,
84
+ Schema.Struct({
85
+ title: Page.fields.title.schema,
86
+ document: Composition.Document.check(Composition.valid(Site)),
87
+ }),
88
+ )
89
+ -->
53
90
  ```ts
54
91
  import { Bundle } from 'foldkit-bundle'
55
92
  import { BuilderView } from 'foldkit-mixins-builder'
@@ -120,7 +157,7 @@ body". The Builder owns the words; this package draws the region.
120
157
  import { Style } from 'foldkit-mixins'
121
158
  import { BuilderSlots, BuilderView } from 'foldkit-mixins-builder'
122
159
 
123
- const PageEditing = BuilderView.define(PageBuilder).pipe(
160
+ const Styled = BuilderView.define(PageBuilder).pipe(
124
161
  Style.attach(
125
162
  Style.forSlots(BuilderSlots)({
126
163
  root: Style.class('builder'),
@@ -161,7 +198,7 @@ attached to every Block's settings form:
161
198
  ```ts
162
199
  import { FieldSlots, FormSlots } from 'foldkit-mixins-form'
163
200
 
164
- const PageEditing = BuilderView.define(PageBuilder, {
201
+ const Configured = BuilderView.define(PageBuilder, {
165
202
  settings: {
166
203
  field: Style.attach(Style.forSlots(FieldSlots)({ label: Style.class('setting-label') })),
167
204
  form: Style.attach(Style.forSlots(FormSlots)({ root: Style.class('settings') })),
@@ -239,7 +276,7 @@ reaches redraw on every change. It is still correct, just not cached.
239
276
  Where the editor is narrow, it can show one of its three panels at a time:
240
277
 
241
278
  ```ts
242
- const PageEditing = BuilderView.define(PageBuilder).pipe(
279
+ const Narrow = BuilderView.define(PageBuilder).pipe(
243
280
  Style.attach(BuilderView.narrow('52rem')),
244
281
  )
245
282
  ```
@@ -285,6 +322,20 @@ application's, not the Builder's. The page's parent reads them, as it must to
285
322
  preview or publish the page, and gives them to the canvas as the Builder's view
286
323
  inputs; the Builder keeps no copy:
287
324
 
325
+ <!-- docs-check
326
+ import type { HtmlBuilder } from 'foldkit/html'
327
+ import type { Message } from 'foldkit-builder'
328
+ declare const model: object
329
+ declare const h: HtmlBuilder<Message>
330
+ declare const reads: { data: (model: object) => Parameters<typeof BuilderView.inputs>[0] extends infer I ? (I extends { data: infer D } ? D : never) : never }
331
+ declare const EditorSlot: {
332
+ view: (
333
+ model: object,
334
+ h: HtmlBuilder<Message>,
335
+ inputs: { controls: { document: ReturnType<typeof BuilderView.inputs> } },
336
+ ) => unknown
337
+ }
338
+ -->
288
339
  ```ts
289
340
  EditorSlot.view(model, h, {
290
341
  controls: {
@@ -368,6 +419,10 @@ from is the application's rows, loaded by its own query as a form's picker
368
419
  options are; the page's parent gives them in the Builder's view inputs, keyed
369
420
  `'Block.prop'`:
370
421
 
422
+ <!-- docs-check
423
+ const Category = Entity.define('Category', Schema.Struct({ id: Schema.String, name: Schema.String }))
424
+ declare const categories: ReadonlyArray<{ readonly id: string; readonly name: string }>
425
+ -->
371
426
  ```ts
372
427
  const Featured = Block.define('Featured', {
373
428
  Props: Schema.Struct({ category: Schema.NullOr(Schema.String) }),
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["BuilderWords"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;qBA8Ea,cAAY,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyJZ;WAAmB;WAAc;WAAiB;;;iBAG9C;WACN;WACA,SAAS;WAET,UAAU;WACV,SAAS;WACT,WAAW,OAAO,KAAK,mBAAmB;EAEnD,SACE,UAAU,UACV,UAAU,OAAO,OAAO,SACxB,gBACC,OAAO,OAAO;;WAER,YACP,UAAU,UACV,UAAU,OAAO,OAAO,SACxB,oBACG,OAAO,OAAO;;WAEV,UAAU,cAAc;WACxB,aACP,OAAO,KAAK,8CACT,OAAO,OAAO;WACV,aACP,OAAO,KAAK,yCACZ,aACA,WAAW,sBACR,OAAO,OAAO;WACV,aACP,OAAO,KAAK,mBACZ,aACA,WAAW,sBACR,OAAO,OAAO;;;qBAIR,SAAM,UAAc,aAAW,cAAc,eAAe;;qBAsB5D;;qBAEA;;qBAEA;;qBAmCA,UAAO;WAAwB;GAAc;;;;;;qBAsG7C,SAAM,KACZ,YAAU,WACL,UAAQ,QACX,KAAKA;;YA0BF;;;;;iBAMK;;WAEN,WAAW;;;;;WAKX,OAAO,SAAS;;;;;WAKhB,UAAU,SAAS,eAAe,cAAc;;WAEhD,QAAQ,QAAQA;;;i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WAAW;QAErB"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Option } from "effect";
1
+ import { Match, Option } from "effect";
2
2
  import { Layers, Message, controlOf, inputOf, layersArgs } from "foldkit-builder";
3
3
  import { Catalog, Composition, NodeId, fieldsOf, spaced } from "foldkit-composition";
4
4
  import { FIELD_ATTRIBUTE, MARK_ATTRIBUTE, NODE_ATTRIBUTE, PAGE_CONTAINER, REGION_ATTRIBUTE, Renderer } from "foldkit-composition/foldkit";
@@ -696,21 +696,21 @@ const BuilderView = {
696
696
  * identity, so an absent node or drop arrives as `undefined`, not as an
697
697
  * `Option`, which would be a new value on every draw.
698
698
  */
699
- const drawRow = (slots, h, { index, id, branch, node, open, selected, drop, dragged }) => h.li(slots.row.attrs([
699
+ const drawRow = (slots, h, { index, id, branch, node, selected, drop, dragged }) => h.li(slots.row.attrs([
700
700
  h.Key(id),
701
701
  h.DataAttribute(ROW_ATTRIBUTE, id),
702
702
  ...node === void 0 ? [] : [h.DataAttribute("block", node.block)],
703
703
  ...drop === void 0 ? [] : [h.DataAttribute(ROW_DROP_ATTRIBUTE, drop)],
704
704
  ...dragged ? [h.DataAttribute(ROW_DRAGGING_ATTRIBUTE, "")] : [],
705
705
  h.AriaSelected(selected),
706
- h.OnClick(Layers.wrapper.make(TreeNavigation.Message.Focused({ id }))),
706
+ h.OnClick(Message.RowPressed({ id: NodeId.make(id) })),
707
707
  h.OnMouseEnter(Message.Hovered({ id: NodeId.make(id) })),
708
708
  h.OnMouseLeave(Message.Unhovered())
709
709
  ], {
710
710
  index,
711
711
  id
712
712
  }), [
713
- ...branch ? [h.span(slots.rowToggle.attrs([h.AriaHidden(true), h.OnClick(Layers.wrapper.make(open ? TreeNavigation.Message.Closed({ id }) : TreeNavigation.Message.Opened({ id })))]), [])] : [],
713
+ ...branch ? [h.span(slots.rowToggle.attrs([h.AriaHidden(true), h.OnClick(Message.RowToggled({ id: NodeId.make(id) }))]), [])] : [],
714
714
  h.span(slots.rowLabel.attrs(), [node === void 0 ? id : labelOf(node.block)]),
715
715
  ...Option.match(node === void 0 ? Option.none() : summaryOf(node), {
716
716
  onNone: () => [],
@@ -751,7 +751,10 @@ const BuilderView = {
751
751
  const document = builder.document(input);
752
752
  const { selected } = input;
753
753
  const drop = dropOf(input.drag);
754
- const dragged = Option.flatMap(input.drag, (drag) => drag.source._tag === "Existing" ? Option.some(drag.source.id) : Option.none());
754
+ const dragged = Option.flatMap(input.drag, (drag) => Match.valueTags(drag.source, {
755
+ Existing: ({ id }) => Option.some(id),
756
+ New: () => Option.none()
757
+ }));
755
758
  const shown = TreeNavigation.shown(rowsOf(document), input.layers, layersArgs);
756
759
  const tree = h.ul(slots.tree.attrs([h.Role("tree"), h.AriaLabel(wordsOf(input.words).layers)]), shown.map((row, index) => slots.row.lazy({
757
760
  index,
@@ -876,9 +879,15 @@ const BuilderView = {
876
879
  container: "canvas",
877
880
  attribute: `data-${NODE_ATTRIBUTE}`,
878
881
  preventDefault: true,
879
- toMessage: (fact) => Option.match(asNodeId(fact.id), {
880
- onNone: () => fact._tag === "TargetHovered" ? Message.Unhovered() : Message.Deselected(),
881
- onSome: (id) => fact._tag === "TargetHovered" ? Message.Hovered({ id }) : Message.Selected({ id })
882
+ toMessage: (fact) => Match.valueTags(fact, {
883
+ TargetHovered: ({ id }) => Option.match(asNodeId(id), {
884
+ onNone: () => Message.Unhovered(),
885
+ onSome: (node) => Message.Hovered({ id: node })
886
+ }),
887
+ TargetPressed: ({ id }) => Option.match(asNodeId(id), {
888
+ onNone: () => Message.Deselected(),
889
+ onSome: (node) => Message.Selected({ id: node })
890
+ })
882
891
  })
883
892
  }),
884
893
  PointerDrag.behavior(BuilderSlots)({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["StyleLayers","builderWords"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `foldkit-mixins-builder`: the page Builder drawn as accessible HTML, every\n * element a `foldkit-mixins` Slot.\n *\n * `foldkit-builder` owns the editor's state and draws nothing of its own worth\n * shipping. This package draws it: a palette of the Blocks a page may gain, the\n * page's layers as an ARIA tree driven by the keyboard, the selected node's\n * props in an inspector, undo and redo, a viewport picker, and the page itself,\n * drawn by the site's own Renderer in edit mode. It adds no state and no\n * Messages: every element dispatches one of the Builder's own.\n *\n * Interaction comes from `foldkit-primitives`, attached as Behaviors:\n * `TreeNavigation` on the layers, `Targets` on the canvas (hover and click pick\n * a node), and the Builder's `keyPressed` shortcuts on the layers and the canvas.\n */\nimport { Option, Schema } from 'effect'\nimport {\n Layers,\n controlOf,\n inputOf,\n Message,\n layersArgs,\n type ContextValue,\n type BuilderCommand,\n type CommandKey,\n type DragSource,\n type DropZone,\n type InspectedForm,\n type Inspecting,\n type Model,\n type Settings,\n} from 'foldkit-builder'\nimport {\n Catalog,\n Composition,\n NodeId,\n fieldsOf,\n spaced,\n type Document,\n type Position,\n} from 'foldkit-composition'\nimport {\n FIELD_ATTRIBUTE,\n MARK_ATTRIBUTE,\n NODE_ATTRIBUTE,\n REGION_ATTRIBUTE,\n PAGE_CONTAINER,\n Renderer,\n} from 'foldkit-composition/foldkit'\nimport { Entity } from 'foldkit-entity'\nimport { Input, type Control } from 'foldkit-form'\nimport {\n Behavior,\n Capability,\n Layers as StyleLayers,\n type Placement,\n Slot,\n Slots,\n SlotView,\n Style,\n} from 'foldkit-mixins'\nimport { FormView, type FormViewInputs, type Renderers } from 'foldkit-mixins-form'\nimport { KeepInView, Measure, measured } from 'foldkit-primitives/dom'\nimport {\n EditableText,\n LiveAnnounce,\n PointerDrag,\n Targets,\n TreeNavigation,\n} from 'foldkit-primitives/interaction'\nimport type { KeyboardModifiers } from 'foldkit/html'\nimport { createLazy, inertHtml, type Attribute, type Html, type HtmlBuilder } from 'foldkit/html'\nimport * as Submodel from 'foldkit/submodel'\nimport { builderWords, say, wordsOf, type BuilderWords } from './words.js'\n\nexport { builderWords, type BuilderWords } from './words.js'\n\n/** The Builder's public customization contract: every element the editor draws. */\nexport const BuilderSlots = Slots.define({\n /** The editor: the container `builder`, so a Style may follow the editor's own width. */\n root: Slot.make({ capability: Capability.Container }),\n /**\n * The default layout's four regions, and what holds them, which a stylist\n * lays out rather than each panel: `start` holds the palette and the layers,\n * `bar` the toolbar, the crumbs, the viewports and the preview, `stage` the\n * alert and the canvas, and `end` the inspector. Inside `root`, so their\n * layout may change with `@container builder (…)`. A layout of your own\n * draws none of them.\n */\n regions: Slot.make({ capability: Capability.Container }),\n start: Slot.make({ capability: Capability.Container }),\n bar: Slot.make({ capability: Capability.Container }),\n stage: Slot.make({ capability: Capability.Container }),\n end: Slot.make({ capability: Capability.Container }),\n /**\n * A group of three pressed-state buttons, one per panel, Add, Layers and Settings, for a\n * narrow layout that shows one at a time (`BuilderView.narrow`); hidden\n * otherwise. One `panelTab` each, with `data-panel`.\n */\n panelTabs: Slot.make({ capability: Capability.Container }),\n panelTab: Slot.make({ capability: Capability.Interactive }),\n /** The Blocks a page may gain, in groups, one button each. */\n palette: Slot.make({ capability: Capability.Container }),\n /** One group of the palette, and its heading, drawn when there is more than one. */\n paletteGroup: Slot.make({ capability: Capability.Container }),\n paletteHeading: Slot.make({ capability: Capability.Base }),\n /** A Block to add: its label, and the line describing it. Carries `data-block`. */\n paletteItem: Slot.make({ capability: Capability.Interactive }),\n paletteLabel: Slot.make({ capability: Capability.Base }),\n paletteHint: Slot.make({ capability: Capability.Base }),\n /** The layers panel: it takes the editor's keyboard shortcuts. */\n layers: Slot.make({ capability: Capability.Interactive }),\n /** The `role=\"tree\"` element, and one `treeitem` row per node showing. Rows carry `data-block`. */\n tree: Slot.make({ capability: Capability.Container }),\n row: Slot.make({ capability: Capability.Focusable }),\n /** On a row that holds others: opens or closes it, as Right and Left do. */\n rowToggle: Slot.make({ capability: Capability.Interactive }),\n /** A row's Block, and what its node says, in brief. */\n rowLabel: Slot.make({ capability: Capability.Base }),\n rowSummary: Slot.make({ capability: Capability.Base }),\n /** Move, duplicate and delete for the selected node, in the inspector's head. Each carries `data-action`. */\n actions: Slot.make({ capability: Capability.Container }),\n action: Slot.make({ capability: Capability.Interactive }),\n /** The selected node's settings, or, with nothing selected, how to begin and the shortcuts. */\n inspector: Slot.make({ capability: Capability.Container }),\n /** The selected node's Block: its label, what it is for, and its actions. */\n inspectorHead: Slot.make({ capability: Capability.Container }),\n inspectorTitle: Slot.make({ capability: Capability.Base }),\n inspectorHint: Slot.make({ capability: Capability.Base }),\n /** One part of the settings, such as Content or Style, and its heading. */\n inspectorSection: Slot.make({ capability: Capability.Container }),\n inspectorSectionTitle: Slot.make({ capability: Capability.Base }),\n field: Slot.make({ capability: Capability.Container }),\n /** A field's name: a `label`, or a `span` naming a group of controls. */\n label: Slot.make({ capability: Capability.Base }),\n control: Slot.make({ capability: Capability.Interactive }),\n /** One choice of a many-choice picker: its checkbox and its words. */\n option: Slot.make({ capability: Capability.Base }),\n /** One choice of a `select`. */\n selectOption: Slot.make({ capability: Capability.Base }),\n /** A look's few values as buttons, one pressed: drawn in place of a select. */\n choices: Slot.make({ capability: Capability.Container }),\n choice: Slot.make({ capability: Capability.Interactive }),\n /** The editor's shortcuts, as a list of keys and what they do. */\n shortcuts: Slot.make({ capability: Capability.Container }),\n shortcutKeys: Slot.make({ capability: Capability.Base }),\n shortcutWhat: Slot.make({ capability: Capability.Base }),\n /** The commands offered in the toolbar, undo and redo by default. One `toolbarAction` each, with `data-action`. */\n toolbar: Slot.make({ capability: Capability.Container }),\n toolbarAction: Slot.make({ capability: Capability.Interactive }),\n /** Where the selection is: the page, then each node holding it, then it. One `crumb` button each. */\n crumbs: Slot.make({ capability: Capability.Container }),\n crumb: Slot.make({ capability: Capability.Interactive }),\n viewports: Slot.make({ capability: Capability.Container }),\n viewport: Slot.make({ capability: Capability.Interactive }),\n /** What the page is previewed as: one field per key of the Catalog's context. */\n preview: Slot.make({ capability: Capability.Container }),\n /** Why the last edit was refused. */\n alert: Slot.make({ capability: Capability.Base }),\n /** The page in edit mode, and the frame that sets its width. It takes the shortcuts when focused. */\n canvas: Slot.make({ capability: Capability.Container }),\n frame: Slot.make({ capability: Capability.Container }),\n /** In the frame while the page holds nothing: how to begin. */\n empty: Slot.make({ capability: Capability.Base }),\n /**\n * Over the selected node on the canvas, placed from where it is measured to\n * be, with its Block's label; drawn over the page, so the page's own\n * markup needs no mark to show it.\n */\n selectionBox: Slot.make({ capability: Capability.Container }),\n selectionLabel: Slot.make({ capability: Capability.Base }),\n /** Over the node under the pointer, as the selection's box is placed. */\n hoverBox: Slot.make({ capability: Capability.Base }),\n /** The live region the Builder's announcements are read from. */\n live: Slot.make({ capability: Capability.Base }),\n})\n\n/** A box over a measured node: where `Measure` found it, and nothing to the pointer. */\nconst boxOver = (name: string) => {\n const at = measured(name)\n return Style.self({\n position: 'absolute',\n insetInlineStart: `var(${at.x})`,\n insetBlockStart: `var(${at.y})`,\n width: `var(${at.w})`,\n height: `var(${at.h})`,\n display: `var(${at.display}, none)`,\n boxSizing: 'border-box',\n pointerEvents: 'none',\n })\n}\n\n/**\n * What the drawn Builder needs to work unstyled: the root a container, the frame\n * as wide as the viewport, centred, the boxes over the canvas, the narrow tabs\n * hidden. In `components`, so an application's style overrides it.\n */\nconst FrameDefaults = Style.forSlots(BuilderSlots)(\n {\n // The page's container, so a look measures the frame it is previewed in, not the window.\n frame: Style.self({\n maxWidth: 'var(--fk-frame-width)',\n marginInline: 'auto',\n containerType: 'inline-size',\n containerName: PAGE_CONTAINER,\n }),\n // What the boxes are placed in: the canvas, measured from its scroll box.\n canvas: Style.self({ position: 'relative' }),\n selectionBox: boxOver('selected'),\n selectionLabel: Style.self({\n position: 'absolute',\n insetBlockEnd: '100%',\n insetInlineStart: '0',\n }),\n hoverBox: boxOver('hovered'),\n // A container, so what it holds may be laid out by the editor's width, not the window's.\n root: Style.self({ containerType: 'inline-size', containerName: 'builder' }),\n // Shown only by a narrow layout, which shows one panel at a time.\n panelTabs: Style.self({ display: 'none' }),\n },\n { name: 'BuilderDefaults', layer: StyleLayers.standard.layer('components') },\n)\n\n/** The panels a narrow layout shows one at a time, by the Builder's `panel`, and their tabs' words. */\nconst PANELS = [\n ['insert', 'addPanel'],\n ['layers', 'layersPanel'],\n ['properties', 'settingsPanel'],\n] as const\n\n/** The width each viewport draws the page at. */\nexport const viewportWidths = { wide: '100%', medium: '768px', narrow: '375px' } as const\n\n/** What `BuilderView.define` needs of a Builder: what `Builder.make` returns has all of it. */\nexport interface BuilderLike {\n readonly name: string\n readonly catalog: Catalog\n // `any`: a Renderer's entries are keyed by its own Blocks, so no one Blocks type fits every Builder's.\n readonly renderer: Renderer<any, never>\n readonly offered: ReadonlyArray<string>\n readonly document: (model: Pick<Model, 'page'>) => Document\n // Method syntax: a Builder whose Blocks are named narrower still fits.\n placeFor(\n document: Document,\n selected: Option.Option<NodeId>,\n block: string,\n ): Option.Option<Position>\n /** Where a pattern goes, as `placeFor` places its root's Block. */\n readonly patternAt: (\n document: Document,\n selected: Option.Option<NodeId>,\n pattern: string,\n ) => Option.Option<Position>\n /** What a key, a node's action and the toolbar run. */\n readonly commands: ReadonlyArray<BuilderCommand>\n readonly inspecting: (\n model: Pick<Model, 'page' | 'selected' | 'inspector'>,\n ) => Option.Option<Inspecting>\n readonly keyCommand: (\n model: Pick<Model, 'page' | 'selected' | 'editing'>,\n key: string,\n modifiers: KeyboardModifiers,\n ) => Option.Option<Message>\n readonly keyPressed: (\n model: Pick<Model, 'editing'>,\n key: string,\n modifiers: KeyboardModifiers,\n ) => Option.Option<Message>\n}\n\n/** Every node as a tree row, in document order, with its parent node and whether it holds any. */\nexport const rowsOf = (document: Document): ReadonlyArray<TreeNavigation.Row> => {\n // The view and the tree's Behavior both ask, on every draw.\n const known = rowsByDocument.get(document)\n if (known !== undefined) return known\n const rows: Array<TreeNavigation.Row> = []\n const seen = new Set<string>()\n const visit = (id: NodeId, parent: string | null): void => {\n const node = document.nodes[id]\n if (node === undefined || seen.has(id)) return\n seen.add(id)\n const children = Object.values(node.regions).flat()\n rows.push({ id, parent, branch: children.length > 0 })\n for (const child of children) visit(child, id)\n }\n for (const root of document.roots) visit(root, null)\n rowsByDocument.set(document, rows)\n return rows\n}\n\nconst rowsByDocument = new WeakMap<Document, ReadonlyArray<TreeNavigation.Row>>()\n\n/** The attribute a layer row carries, holding its node's id, for a drag to find. */\nexport const ROW_ATTRIBUTE = 'builder-row'\n/** On the row a drop is aimed at, holding where: `before`, `inside` or `after`. */\nexport const ROW_DROP_ATTRIBUTE = 'builder-drop'\n/** On the row being dragged. */\nexport const ROW_DRAGGING_ATTRIBUTE = 'builder-dragging'\n\n/**\n * A drag's facts as the Builder's Messages; `source` says what the dragged\n * element is: a node's own id, or a palette tile's Block.\n */\nconst dragMessage =\n (source: (id: string) => DragSource) =>\n (fact: PointerDrag.DragFact): Message => {\n switch (fact._tag) {\n case 'DragStarted':\n return Message.DragStarted({ source: source(fact.id) })\n case 'DraggedOver':\n // The DOM's fact says \"over nothing\" with `null`, over the page's own space\n // with `region` too, and over a node's empty Region with its `part`; the\n // Builder has a Message for each.\n return fact.over !== null\n ? fact.over.part === undefined\n ? Message.DraggedOver({ id: NodeId.make(fact.over.id), zone: fact.over.zone })\n : Message.DraggedOverRegion({ id: NodeId.make(fact.over.id), region: fact.over.part })\n : fact.region === true\n ? Message.DraggedOverPage()\n : Message.DraggedOff()\n case 'DragDropped':\n return Message.DragDropped()\n case 'DragCancelled':\n return Message.DragCancelled()\n }\n }\n/** A row or a node dragged: a node on the page. */\nconst nodeDrag = dragMessage(id => ({ _tag: 'Existing', id: NodeId.make(id) }))\n/** A palette tile dragged: a new node of its Block. */\nconst tileDrag = dragMessage(block => ({ _tag: 'New', block }))\n\n/** The DOM id a layer row carries, so keyboard focus can find it. */\nexport const layerId = (builder: { readonly name: string }, id: string): string =>\n `${builder.name}-layer-${id}`\n\n/** A node id the DOM reported, where `null` or an empty id is none. */\nconst asNodeId = (id: string | null): Option.Option<NodeId> =>\n Option.map(\n Option.filter(Option.fromNullOr(id), found => found !== ''),\n NodeId.make,\n )\n\n/** A stored appearance that is a record of choices, as opposed to a list or a scalar. */\nconst isChoices = (\n value: Schema.Json | undefined,\n): value is { readonly [axis: string]: Schema.Json } =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/** What a context key's control reads as a value: blank is none, a toggle's text a boolean. */\nconst contextValue = (control: Control | undefined, raw: string): Option.Option<ContextValue> => {\n if (raw === '') return Option.none()\n if (control !== undefined && Input.Toggle.is(control)) return Option.some(raw === 'true')\n if (\n control !== undefined &&\n Input.Number.is(control) &&\n raw.trim() !== '' &&\n Number.isFinite(Number(raw))\n )\n return Option.some(Number(raw))\n return Option.some(raw)\n}\n\n/** Choices named by themselves. */\nconst named = (values: ReadonlyArray<string>): ReadonlyArray<BuilderOption> =>\n values.map(value => ({ value, label: value }))\n\n/**\n * A select's options: a blank, the choices, and a stored value the choices lack,\n * shown as `? value` and chosen, rather than the blank misreporting it. With no\n * word for the blank, it is offered only while nothing is chosen.\n */\nconst optionsOf = <Message>(\n h: HtmlBuilder<Message>,\n option: SlotView.SlotBuilder<Message>,\n select: {\n /** What the blank choice reads as; with none, a blank only while nothing is chosen. */\n readonly blank?: string | undefined\n readonly choices: ReadonlyArray<BuilderOption>\n readonly current?: string | undefined\n },\n): ReadonlyArray<Html> => {\n const { blank, choices, current } = select\n const empty = current === undefined || current === ''\n const stray = !empty && !choices.some(choice => choice.value === current)\n return [\n ...(blank !== undefined || empty\n ? [h.option(option.attrs([h.Value(''), h.Selected(empty)]), [blank ?? ''])]\n : []),\n ...choices.map(choice =>\n h.option(option.attrs([h.Value(choice.value), h.Selected(current === choice.value)]), [\n choice.label,\n ]),\n ),\n ...(stray\n ? [h.option(option.attrs([h.Value(current), h.Selected(true)]), [`? ${current}`])]\n : []),\n ]\n}\n\n/** The choices a context key offers, or `undefined` when it is typed in. */\nconst contextChoices = (control: Control | undefined): ReadonlyArray<string> | undefined =>\n control === undefined\n ? undefined\n : Input.Select.is(control)\n ? control.data.options.map(String)\n : Input.Toggle.is(control)\n ? ['true', 'false']\n : undefined\n\n/** The longest summary a layer row shows before it is cut short. */\nconst SUMMARY_LENGTH = 40\n\n/** The most values a look offers as buttons; one with more is a select. */\nconst CHOICES_SHOWN = 4\n\n/** The keys the tree's own keyboard takes, beside the commands: they move focus, not the page. */\nconst TREE_KEYS: ReadonlyArray<readonly [keys: string, what: 'treeUpDown' | 'treeLeftRight']> = [\n ['↑ ↓', 'treeUpDown'],\n ['← →', 'treeLeftRight'],\n]\n\n/** How a key is named on screen. */\nconst keyNames: Readonly<Record<string, string>> = {\n ArrowUp: '↑',\n ArrowDown: '↓',\n ArrowLeft: '←',\n ArrowRight: '→',\n}\n\n/**\n * A command's key as a person on `platform` reads it, in its own order: `⌥⇧⌘Z`\n * on a Mac, where `mod` is ⌘, and `Ctrl+Alt+Shift+Z` elsewhere, the modifiers\n * named by `words`.\n */\nexport const keysOf = (\n key: CommandKey,\n platform: Platform = 'other',\n words: Pick<BuilderWords, 'keyNames' | 'ctrlKey' | 'altKey' | 'shiftKey'> = builderWords,\n): string => {\n // A key is the caller's text: each table is read for an own entry only, never `Object`'s.\n const own = (table: Readonly<Record<string, string>>) =>\n Object.hasOwn(table, key.key) ? Option.fromUndefinedOr(table[key.key]) : Option.none()\n const name = Option.getOrElse(\n Option.orElse(own(keyNames), () => own(words.keyNames)),\n () => (key.key.length === 1 ? key.key.toUpperCase() : key.key),\n )\n const held = (\n words: { mod: string; alt: string; shift: string },\n order: ReadonlyArray<'mod' | 'alt' | 'shift'>,\n ) => order.flatMap(modifier => (key[modifier] === true ? [words[modifier]] : []))\n return platform === 'mac'\n ? [...held({ mod: '⌘', alt: '⌥', shift: '⇧' }, ['alt', 'shift', 'mod']), name].join('')\n : [\n ...held({ mod: words.ctrlKey, alt: words.altKey, shift: words.shiftKey }, [\n 'mod',\n 'alt',\n 'shift',\n ]),\n name,\n ].join('+')\n}\n\n/** The platform keys are named for: a Mac's, or any other's. */\nexport type Platform = 'mac' | 'other'\n\n/**\n * What the drawn Builder is given beside its Model, by the page's parent: the\n * application's, never the Builder's to keep.\n */\nexport interface BuilderViewInputs {\n /** The platform the author is on, so keys are named as theirs are (⌘ on a Mac). Default: `other`. */\n readonly platform?: Platform | undefined\n /**\n * Each node's read, by node id, as a published page is drawn with it: the\n * page's Query and Surface Blocks' values, so the canvas shows their rows.\n */\n readonly data?: Readonly<Record<string, unknown>> | undefined\n /**\n * The choices of a relation prop's picker, keyed `'Block.prop'`: the rows the\n * application loaded for it, as a form's `options` are.\n */\n readonly options?: Readonly<Record<string, ReadonlyArray<BuilderOption>>> | undefined\n /** The editor's words, over the English ones (`builderWords`). */\n readonly words?: Partial<BuilderWords> | undefined\n}\n\n/** One choice of a relation picker: what is stored, and what is shown. */\nexport interface BuilderOption {\n readonly value: string\n readonly label: string\n}\n\n/** What the drawn Builder's Slots and Behaviors read: its Model and its inputs. */\nexport type BuilderInput = Model & BuilderViewInputs\n\n// Whether a runtime render is under way, which `h.submodel` needs. Foldkit offers\n// no way to ask; a lazy slot reads the current frame before anything else and\n// throws without one. Any other throw, such as a slot drawn twice, is left to surface.\nconst probe = createLazy()\nconst nothing = () => null\nconst inRender = (): boolean => {\n try {\n probe(nothing, [])\n return true\n } catch {\n return false\n }\n}\n\n/**\n * How the inspector's settings forms look: Styles attached to every Block's\n * settings form, as to any form's `FormView.field(form)` and `FormView.define`.\n */\nexport interface SettingsLook {\n /** Attached to each settings form's fields: `FieldSlots`. */\n readonly field?: SlotView.SlotViewTransform\n /** Attached to each settings form around its fields: `FormSlots`. */\n readonly form?: SlotView.SlotViewTransform\n /**\n * Renderers for control kinds of the application's own, beside the shipped\n * ones, as a form view takes them. A function of the Message, since each\n * Block's settings form has Messages of its own: `foldkit-form-recipes/html`'s `renderers`.\n */\n readonly renderers?: <Message>() => Renderers<Message>\n}\n\n/** A Block's settings form, drawn with `look`. */\nconst settingsViewOf = (settings: Settings, look: SettingsLook) => {\n const field = FormView.field(\n settings.form,\n look.renderers === undefined ? {} : { renderers: look.renderers() },\n )\n const drawn = FormView.define(settings.form, {\n field: look.field === undefined ? field : field.pipe(look.field),\n })\n const view = FormView.submodel(\n settings.form,\n look.form === undefined ? drawn : drawn.pipe(look.form),\n )\n return view\n}\n\n/** The drawn Builder: what `BuilderView.define` returns. */\nexport type BuilderSlotView = SlotView.SlotView<typeof BuilderSlots, BuilderInput, Message>\n\nconst Parts = SlotView.parts(BuilderSlots)<BuilderInput, Message>()\n\n/** One piece of the drawn Builder, placed by `BuilderView.assemble`. */\nexport type BuilderPart = SlotView.Part<typeof BuilderSlots, BuilderInput, Message>\n\n/** The drawn Builder's pieces, by what they show. */\nexport interface BuilderParts {\n /** The panels' switch, for a narrow layout: see `BuilderView.narrow`. */\n readonly Panels: BuilderPart\n /** The Blocks a page may gain, each a button that inserts it. */\n readonly Palette: BuilderPart\n /** The page's nodes as an ARIA tree, with the keyboard and dragging. */\n readonly Layers: BuilderPart\n /** The selected node's props, looks, conditions and actions, or the shortcuts. */\n readonly Inspector: BuilderPart\n /** The toolbar's commands: undo and redo, unless the Builder's commands say otherwise. */\n readonly Toolbar: BuilderPart\n /** Where the selection is, from the page down. */\n readonly Crumbs: BuilderPart\n readonly Viewports: BuilderPart\n /** The context the page is previewed for; nothing where the Catalog has none. */\n readonly Preview: BuilderPart\n /** Why the last edit was refused; nothing when none was. */\n readonly Alert: BuilderPart\n /** The page, drawn by the site's Renderer, with the pointer. */\n readonly Canvas: BuilderPart\n /** What the Builder announces to a screen reader. */\n readonly Live: BuilderPart\n}\n\nexport const BuilderView = {\n /** What the drawn Builder is drawn with, typed where a form's `controls` entry cannot be. */\n inputs: (inputs: BuilderViewInputs = {}): BuilderViewInputs => inputs,\n\n /**\n * The drawn Builder as a Submodel view, for `bundle.pipe(Bundle.withView(...))`\n * or `builder.inputWith(...)`, drawn with `BuilderView.inputs(...)`.\n */\n submodel: (view: BuilderSlotView): Submodel.View<Model, Message, BuilderViewInputs> =>\n Submodel.defineView<Model, Message, BuilderViewInputs>(((\n model: Model,\n inputs: BuilderViewInputs | HtmlBuilder<Message>,\n h: HtmlBuilder<Message> | undefined,\n ) =>\n // A form draws a Bundle control with no inputs when its `controls` gives the\n // key none, and a Submodel view given none is called as `(model, h)`.\n h === undefined\n ? view(model, inputs as HtmlBuilder<Message>)\n : view({ ...model, ...(inputs as BuilderViewInputs) }, h)) as (\n model: Model,\n inputs: BuilderViewInputs,\n h: HtmlBuilder<Message>,\n ) => Html),\n\n /**\n * The Builder's parts, each drawn again only when what it reads changed,\n * with its Behaviors (the layers' keyboard, the canvas's pointer, the\n * shortcuts) declared with it. Place them with `assemble`.\n */\n parts: (\n builder: BuilderLike,\n options: {\n /** How the inspector's settings forms look. */\n readonly settings?: SettingsLook\n } = {},\n ): BuilderParts => {\n // Each Block's settings form, drawn: made once per form, as the form is once per Block.\n const settingsViews = new WeakMap<Settings, ReturnType<typeof settingsViewOf>>()\n const settingsView = (settings: Settings) => {\n const known = settingsViews.get(settings)\n if (known !== undefined) return known\n const made = settingsViewOf(settings, options.settings ?? {})\n settingsViews.set(settings, made)\n return made\n }\n const described = new Map(\n builder.catalog.blocks.map(block => {\n // The props a layer row may quote: those drawn as text.\n const texts = Object.entries(fieldsOf(block.Props)).flatMap(([key, schema]) => {\n const control = controlOf(block, key, schema)\n return control !== undefined && (Input.Text.is(control) || Input.Multiline.is(control))\n ? [key]\n : []\n })\n return [\n block.name,\n {\n label: block.words.label,\n description: block.words.description,\n // Blocks given no group share one.\n group: block.words.group,\n texts,\n },\n ] as const\n }),\n )\n /** A Block's label; one the Catalog lacks is marked unknown. */\n const labelOf = (name: string): string => described.get(name)?.label ?? `? ${name}`\n /** A node's first text prop that says something, cut short. */\n const summaryOf = (node: Document['nodes'][NodeId]): Option.Option<string> => {\n for (const key of described.get(node.block)?.texts ?? []) {\n const value = node.props[key]\n const text = typeof value === 'string' ? value.replace(/\\s+/g, ' ').trim() : ''\n if (text !== '')\n return Option.some(\n text.length > SUMMARY_LENGTH ? `${text.slice(0, SUMMARY_LENGTH - 1).trimEnd()}…` : text,\n )\n }\n return Option.none()\n }\n // The palette's groups, in the order their first Block is offered: a Map keeps insertion\n // order. Blocks given no group share one, named when drawn, by the words.\n const ungrouped = Symbol('ungrouped')\n const grouped = new Map<string | typeof ungrouped, Array<string>>()\n for (const name of builder.offered) {\n const group = Option.getOrElse(\n Option.flatMap(Option.fromUndefinedOr(described.get(name)), each => each.group),\n (): string | typeof ungrouped => ungrouped,\n )\n const names = grouped.get(group)\n if (names === undefined) grouped.set(group, [name])\n else names.push(name)\n }\n const groups = [...grouped].map(([group, names]) => ({\n group: group === ungrouped ? Option.none<string>() : Option.some(group),\n names,\n }))\n const patterns = builder.catalog.patterns\n // A heading names each group when there is more than one, the patterns' included.\n const headed = groups.length + (patterns.length > 0 ? 1 : 0) > 1\n\n // One field per context key: a choice, or typed in; blank is unset.\n const contextField = (\n slots: SlotView.SlotBuilders<typeof BuilderSlots, Message>,\n h: HtmlBuilder<Message>,\n field: {\n readonly id: string\n readonly label: string\n readonly schema: Schema.Top\n readonly current: Option.Option<ContextValue>\n /** What the blank choice reads as. */\n readonly blank: string\n /** The value chosen, or none for the blank. */\n readonly send: (value: Option.Option<ContextValue>) => Message\n },\n ) => {\n const { id: fieldId, label, schema, current, blank, send } = field\n const control = Input.resolve(Entity.unmapped, schema)\n const choices = contextChoices(control)\n // A context value that is itself `null` is shown as the blank too.\n const shown = Option.match(current, {\n onNone: () => '',\n onSome: value => (value === null ? '' : String(value)),\n })\n return h.div(slots.field.attrs(), [\n h.label(slots.label.attrs([h.For(fieldId)]), [label]),\n choices === undefined\n ? h.input(\n slots.control.attrs([\n h.Id(fieldId),\n h.Value(shown),\n h.OnInput(raw => send(contextValue(control, raw))),\n ]),\n )\n : h.select(\n slots.control.attrs([\n h.Id(fieldId),\n h.OnChange(raw => send(contextValue(control, raw))),\n ]),\n optionsOf(h, slots.selectOption, { blank, choices: named(choices), current: shown }),\n ),\n ])\n }\n\n const inspect = (\n document: Document,\n id: NodeId,\n options: Readonly<Record<string, ReadonlyArray<BuilderOption>>>,\n actions: Html,\n inspecting: Option.Option<Inspecting>,\n slots: SlotView.SlotBuilders<typeof BuilderSlots, Message>,\n h: HtmlBuilder<Message>,\n w: BuilderWords,\n ): Html => {\n const node = document.nodes[id]\n const block = node === undefined ? undefined : Catalog.block(builder.catalog, node.block)\n const head = h.div(slots.inspectorHead.attrs(), [\n h.h2(slots.inspectorTitle.attrs(), [node === undefined ? id : labelOf(node.block)]),\n ...Option.match(\n node === undefined\n ? Option.none()\n : (described.get(node.block)?.description ?? Option.none()),\n {\n onNone: () => [],\n onSome: hint => [h.p(slots.inspectorHint.attrs(), [hint])],\n },\n ),\n actions,\n ])\n /** A part of the settings under its heading; none when it has nothing in it. */\n const section = (title: string, fields: ReadonlyArray<Html>): ReadonlyArray<Html> =>\n fields.length === 0\n ? []\n : [\n h.div(slots.inspectorSection.attrs([h.Role('group'), h.AriaLabel(title)]), [\n h.h3(slots.inspectorSectionTitle.attrs(), [title]),\n ...fields,\n ]),\n ]\n if (node === undefined || block === undefined)\n return h.div(slots.inspector.attrs([h.Role('group'), h.AriaLabel(w.properties)]), [\n head,\n h.p([], [w.unknownBlock]),\n ...Object.entries(node?.props ?? {}).map(([key, value]) =>\n h.div(slots.field.attrs(), [\n h.span(slots.label.attrs(), [key]),\n h.code(slots.control.attrs(), [JSON.stringify(value)]),\n ]),\n ),\n ])\n // The props: the Block's settings form, whose changes the Builder turns into edits,\n // then any prop no control fits, as it is stored.\n /**\n * One of the node's forms, placed under `slot`; its Messages go to the\n * Builder as `Inspected`, naming the node and the form.\n */\n const drawForm = (\n target: Inspecting,\n form: InspectedForm,\n slot: string,\n inputs: FormViewInputs,\n ): Html => {\n const view = settingsView(form.settings)\n return inRender()\n ? h.submodel({\n slotId: `${builder.name}-${slot}`,\n model: form.model,\n view,\n toParentMessage: sent =>\n Message.Inspected({\n id: target.id,\n form: form.key,\n message: form.settings.encodeMessage(sent),\n }),\n viewInputs: inputs,\n })\n : // No runtime frame (a test, a static description): nothing carries the form's\n // Messages to the Builder, and no handler can run, so it is drawn as it is.\n view(form.model, inputs, SlotView.inertBuilder())\n }\n const fields = Option.match(inspecting, {\n onNone: () => [],\n onSome: target => [\n drawForm(target, target.props, 'settings', {\n submits: false,\n words: { none: w.none },\n // The application's choices are keyed `'Block.prop'`; the form's by prop.\n options: Object.fromEntries(\n Object.entries(options).flatMap(([at, choices]) =>\n at.startsWith(`${node.block}.`) ? [[at.slice(node.block.length + 1), choices]] : [],\n ),\n ),\n }),\n ...target.props.settings\n .shown(node.props)\n .map(({ label, value }) =>\n h.div(slots.field.attrs(), [\n h.span(slots.label.attrs(), [label]),\n h.code(slots.control.attrs(), [JSON.stringify(value)]),\n ]),\n ),\n ],\n })\n // The node's look: one choice per axis its Block offers, blank for the default,\n // and on a responsive axis one more per breakpoint it may change at.\n const chosen = isChoices(node.appearance) ? node.appearance : {}\n const looks = Object.entries(block.appearance).flatMap(([axis, look]) => {\n const { values, breakpoints } = look\n /** A value's name: the look's label for it, else the value spaced. */\n const named = (value: string): string => look.labels?.[value] ?? spaced(value)\n const stored = chosen[axis]\n // What is chosen at each point: `base`, then each breakpoint.\n const at: Readonly<Record<string, string>> =\n typeof stored === 'string'\n ? { base: stored }\n : isChoices(stored)\n ? Object.fromEntries(\n Object.entries(stored).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string',\n ),\n )\n : {}\n const choose =\n (point: string) =>\n (value: string): Message => {\n const { [point]: _, ...kept } = at\n const points = value === '' ? kept : { ...kept, [point]: value }\n const { [axis]: __, ...others } = chosen\n // One name when only the base is chosen; none when nothing is.\n const choice =\n Object.keys(points).length === 0\n ? undefined\n : Object.keys(points).length === 1 && points['base'] !== undefined\n ? points['base']\n : points\n const next = choice === undefined ? others : { ...others, [axis]: choice }\n return Message.Applied({\n op: Composition.Op.setAppearance(id, Object.keys(next).length === 0 ? null : next),\n })\n }\n const label = spaced(axis)\n if ((breakpoints ?? []).length === 0 && values.length <= CHOICES_SHOWN) {\n const current = at['base']\n // A stored value the look lacks is shown pressed, and choosing it again sends nothing.\n const stray =\n current !== undefined && !values.includes(current)\n ? Option.some(current)\n : Option.none()\n return [\n h.div(slots.field.attrs(), [\n h.span(slots.label.attrs(), [label]),\n h.div(\n slots.choices.attrs([\n h.Id(`${builder.name}-${id}-appearance-${axis}`),\n h.Role('group'),\n h.AriaLabel(label),\n ]),\n [\n ...[\n ['', w.lookDefault] as const,\n ...values.map(value => [value, named(value)] as const),\n ].map(([value, text]) =>\n h.button(\n slots.choice.attrs([\n h.Type('button'),\n h.AriaPressed(\n (value === '' ? current === undefined : current === value)\n ? 'true'\n : 'false',\n ),\n h.OnClick(choose('base')(value)),\n ]),\n [text],\n ),\n ),\n ...Option.match(stray, {\n onNone: () => [],\n onSome: value => [\n h.button(\n slots.choice.attrs([\n h.Type('button'),\n h.AriaPressed('true'),\n h.Disabled(true),\n ]),\n [`? ${value}`],\n ),\n ],\n }),\n ],\n ),\n ]),\n ]\n }\n return ['base', ...(breakpoints ?? [])].map(point => {\n const fieldId = `${builder.name}-${id}-appearance-${axis}${point === 'base' ? '' : `-${point}`}`\n return h.div(slots.field.attrs(), [\n h.label(slots.label.attrs([h.For(fieldId)]), [\n point === 'base' ? label : say(w.lookAt, { label, breakpoint: point }),\n ]),\n h.select(\n slots.control.attrs([h.Id(fieldId), h.OnChange(choose(point))]),\n optionsOf(h, slots.selectOption, {\n blank: point === 'base' ? w.lookDefault : w.lookUnchanged,\n choices: values.map(value => ({ value, label: named(value) })),\n current: at[point],\n }),\n ),\n ])\n })\n })\n // When it shows: an `eq` condition per context key, blank for always. Other\n // conditions on a key are kept as they are.\n const when = Array.isArray(node.when) ? node.when : []\n const isEqOn = (key: string) => (condition: Schema.Json) =>\n isChoices(condition) && Array.isArray(condition['eq']) && condition['eq'][0] === key\n const eqOf = (key: string): Option.Option<ContextValue> => {\n for (const condition of when)\n if (isChoices(condition) && isEqOn(key)(condition) && Array.isArray(condition['eq'])) {\n const value = condition['eq'][1]\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n )\n return Option.some(value)\n }\n return Option.none()\n }\n const conditions = Object.entries(fieldsOf(builder.catalog.context)).map(([key, schema]) =>\n contextField(slots, h, {\n id: `${builder.name}-${id}-when-${key}`,\n label: say(w.shownWhen, { key }),\n schema,\n current: eqOf(key),\n blank: w.always,\n send: value => {\n const others = when.filter(condition => !isEqOn(key)(condition))\n const next = Option.match(value, {\n onNone: () => others,\n onSome: chosen => [...others, { eq: [key, chosen] }],\n })\n return Message.Applied({\n op: Composition.Op.setWhen(id, next.length === 0 ? null : next),\n })\n },\n }),\n )\n // What each of the Block's events runs: an action the Catalog offers, blank for\n // none, then that action's input, one field each.\n const stored = isChoices(node.actions) ? node.actions : {}\n const events = block.events.flatMap(event => {\n const reference = stored[event]\n const ref = isChoices(reference) ? reference : {}\n const run = (name: string, given: { readonly [key: string]: Schema.Json }): Message =>\n Message.Applied({\n op: Composition.Op.setAction(id, event, { action: name, input: given }),\n })\n const pickId = `${builder.name}-${id}-on-${event}`\n const pick = h.div(slots.field.attrs(), [\n h.label(slots.label.attrs([h.For(pickId)]), [say(w.onEvent, { event })]),\n h.select(\n slots.control.attrs([\n h.Id(pickId),\n h.OnChange(name => {\n const chosen = builder.catalog.actions.find(each => each.name === name)\n return chosen === undefined\n ? Message.Applied({ op: Composition.Op.setAction(id, event, null) })\n : run(chosen.name, inputOf(block, event, chosen).seed())\n }),\n ]),\n optionsOf(h, slots.selectOption, {\n blank: w.runsNothing,\n choices: named(builder.catalog.actions.map(each => each.name)),\n current: typeof ref['action'] === 'string' ? ref['action'] : undefined,\n }),\n ),\n ])\n // The chosen action's input, its own form; an action the Catalog lacks has none.\n const input = Option.match(\n Option.flatMap(inspecting, target =>\n Option.map(Option.fromUndefinedOr(target.on[event]), form => ({ target, form })),\n ),\n {\n onNone: () => [],\n onSome: ({ target, form }) => [\n drawForm(target, form, `on-${event}`, { submits: false, words: { none: w.none } }),\n ],\n },\n )\n return [pick, ...input]\n })\n return h.div(slots.inspector.attrs([h.Role('group'), h.AriaLabel(w.properties)]), [\n head,\n ...section(w.content, fields),\n ...section(w.style, looks),\n ...section(w.visibility, conditions),\n ...section(w.interactions, events),\n ])\n }\n\n const shortcuts = ({\n input,\n h,\n }: {\n readonly input: Pick<BuilderInput, 'page' | 'selected' | 'editing'>\n readonly h: HtmlBuilder<Message>\n }) => [h.OnKeyDownPreventDefault((key, modifiers) => builder.keyPressed(input, key, modifiers))]\n\n /**\n * A button, disabled where there is nothing to send: by `aria-disabled`, so\n * it keeps focus when what it did (the last undo) leaves it nothing to do.\n */\n const button = (\n h: HtmlBuilder<Message>,\n slot: SlotView.SlotBuilder<Message>,\n label: string,\n message: Option.Option<Message>,\n extra: ReadonlyArray<Attribute<Message>> = [],\n ) =>\n h.button(\n slot.attrs([\n h.Type('button'),\n ...Option.match(message, {\n onNone: () => [h.AriaDisabled(true)],\n onSome: sent => [h.OnClick(sent)],\n }),\n ...extra,\n ]),\n [label],\n )\n\n /** A command as a button: disabled while it has nothing to do, titled with its first key. */\n const commandButton = (\n h: HtmlBuilder<Message>,\n slot: SlotView.SlotBuilder<Message>,\n command: BuilderCommand,\n input: Pick<BuilderInput, 'page' | 'selected' | 'platform' | 'words'>,\n ) => {\n const [key] = command.keys\n const w = wordsOf(input.words)\n return button(h, slot, command.label, command.run(input), [\n h.DataAttribute('action', command.id),\n h.Title(\n key === undefined\n ? command.label\n : say(w.withKeys, { label: command.label, keys: keysOf(key, input.platform, w) }),\n ),\n ])\n }\n\n const labelAt = (document: Document, id: NodeId): string =>\n Option.match(Option.fromUndefinedOr(document.nodes[id]), {\n onNone: () => id,\n onSome: node => labelOf(node.block),\n })\n // Where an insert lands, said on the Block's button, from the place itself.\n const whereItGoes = (\n document: Document,\n selected: Option.Option<NodeId>,\n at: Option.Option<Position>,\n w: BuilderWords,\n ): string =>\n Option.match(at, {\n onNone: () =>\n Option.match(selected, {\n onNone: () => w.nothingHoldsIt,\n onSome: id => say(w.cannotGoAt, { label: labelAt(document, id) }),\n }),\n onSome: position => {\n if (position._tag === 'Root') {\n // `placeFor` puts a root after the selected one, or last: never first before others.\n const before = document.roots[position.index - 1]\n return position.index === document.roots.length || before === undefined\n ? w.addsToEnd\n : say(w.addsAfter, { label: labelAt(document, before) })\n }\n const before =\n document.nodes[position.parent]?.regions[position.region]?.[position.index - 1]\n return Option.contains(selected, position.parent) || before === undefined\n ? say(w.addsInside, { label: labelAt(document, position.parent) })\n : say(w.addsAfter, { label: labelAt(document, before) })\n },\n })\n // A drop is marked only where it would land: `at` is none where the page refuses it.\n const dropOf = (drag: Model['drag']) =>\n Option.flatMap(drag, each => (Option.isSome(each.at) ? each.over : Option.none()))\n\n // The shortcuts, on the layers and on the canvas; each part draws one of the two.\n const Shortcuts = Behavior.forSlots(BuilderSlots)<\n Pick<BuilderInput, 'page' | 'selected' | 'editing'>,\n Message\n >(\n {\n layers: Behavior.slot({ attributes: shortcuts }),\n canvas: Behavior.slot({ attributes: shortcuts }),\n },\n { name: 'BuilderShortcuts' },\n )\n // What is selected, however it was (a click, a shortcut, an insert, the\n // address), is brought into view in the layers and on the canvas.\n const KeepSelectionInView = Behavior.forSlots(BuilderSlots)<Pick<BuilderInput, never>, Message>(\n {\n layers: Behavior.slot({\n mount: () => KeepInView({ selector: '[role=\"treeitem\"][aria-selected=\"true\"]' }),\n }),\n canvas: Behavior.slot({\n // The mark is on a `display: contents` wrapper, which has no box: the Block's own element does.\n mount: () => KeepInView({ selector: `[data-${MARK_ATTRIBUTE}=\"selected\"] > *` }),\n }),\n },\n { name: 'KeepSelectionInView' },\n )\n\n // The canvas, found by its id, so a tile dragged from the palette can land on its nodes.\n const canvasId = `${builder.name}-canvas`\n\n // Each panel's element: its id, for its tab to name, and whether its tab is chosen.\n const panelId = (panel: string) => `${builder.name}-panel-${panel}`\n const panelMarks = (\n panel: (typeof PANELS)[number][0],\n slot: 'palette' | 'layers' | 'inspector',\n ) =>\n Behavior.forSlots(BuilderSlots)<Pick<BuilderInput, 'panel'>, Message>(\n {\n [slot]: Behavior.slot({\n attributes: ({ input, h }) => [\n h.Id(panelId(panel)),\n h.DataAttribute('panel', panel),\n h.DataAttribute('panel-shown', String(input.panel === panel)),\n ],\n }),\n // Keyed by the panel's slot, which `forSlots` checks exists.\n } as unknown as Behavior.BehaviorSpec<\n typeof BuilderSlots,\n Pick<BuilderInput, 'panel'>,\n Message\n >,\n { name: `BuilderPanel-${panel}` },\n )\n\n const Panels = Parts.part('Panels', { reads: ['panel', 'words'] }, (input, slots, h) => {\n const w = wordsOf(input.words)\n return h.div(\n // A group of pressed buttons, as the viewports are: ARIA tabs would promise\n // arrow keys and a roving tab stop.\n slots.panelTabs.attrs([h.Role('group'), h.AriaLabel(w.panels)]),\n PANELS.map(([panel, label]) =>\n h.button(\n slots.panelTab.attrs([\n h.Type('button'),\n h.AriaPressed(input.panel === panel ? 'true' : 'false'),\n h.AriaControls(panelId(panel)),\n h.DataAttribute('panel', panel),\n h.OnClick(Message.PanelChosen({ panel })),\n ]),\n [w[label]],\n ),\n ),\n )\n })\n\n const Palette = Parts.part(\n 'Palette',\n {\n reads: ['page', 'selected', 'panel', 'words'],\n behaviors: [\n panelMarks('insert', 'palette'),\n // A tile dragged onto the page adds its Block where it is dropped; a press adds it\n // where the palette's button says.\n PointerDrag.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'palette',\n attribute: 'data-block',\n // Its own canvas, found from the palette, whatever the Builder's name holds.\n targets: { attribute: `data-${NODE_ATTRIBUTE}`, within: '[data-builder-canvas]' },\n part: `data-${REGION_ATTRIBUTE}`,\n toMessage: tileDrag,\n }),\n ],\n },\n (input, slots, h) => {\n const document = builder.document(input)\n const w = wordsOf(input.words)\n /** A tile: what it adds, said, where a press adds it, and the Message that asks. */\n const tile = (item: {\n readonly data: readonly [name: 'block' | 'pattern', value: string]\n readonly label: string\n readonly hint: Option.Option<string>\n readonly at: Option.Option<Position>\n readonly asked: (at: Position) => Message\n }) =>\n h.button(\n slots.paletteItem.attrs([\n h.Type('button'),\n h.DataAttribute(...item.data),\n h.AriaLabel(say(w.addBlock, { label: item.label })),\n h.Title(whereItGoes(document, input.selected, item.at, w)),\n // As a command's button: it keeps focus when its place fills up.\n ...Option.match(item.at, {\n onNone: () => [h.AriaDisabled(true)],\n onSome: position => [h.OnClick(item.asked(position))],\n }),\n ]),\n [\n h.span(slots.paletteLabel.attrs(), [item.label]),\n ...Option.match(item.hint, {\n onNone: () => [],\n onSome: hint => [h.span(slots.paletteHint.attrs(), [hint])],\n }),\n ],\n )\n const group = (name: string, tiles: ReadonlyArray<Html>) =>\n h.div(slots.paletteGroup.attrs([h.Role('group'), h.AriaLabel(name)]), [\n ...(headed ? [h.h3(slots.paletteHeading.attrs(), [name])] : []),\n ...tiles,\n ])\n return h.nav(slots.palette.attrs([h.AriaLabel(w.palette)]), [\n ...groups.map(({ group: named, names: blocks }) =>\n group(\n Option.getOrElse(named, () => w.ungrouped),\n blocks.map(block =>\n tile({\n data: ['block', block],\n label: labelOf(block),\n hint: described.get(block)?.description ?? Option.none(),\n at: builder.placeFor(document, input.selected, block),\n asked: at => Message.InsertAsked({ block, at }),\n }),\n ),\n ),\n ),\n ...(patterns.length === 0\n ? []\n : [\n group(\n w.patterns,\n patterns.map(pattern =>\n tile({\n data: ['pattern', pattern.name],\n label: pattern.words.label,\n hint: pattern.words.description,\n at: builder.patternAt(document, input.selected, pattern.name),\n asked: at => Message.PatternAsked({ pattern: pattern.name, at }),\n }),\n ),\n ),\n ]),\n ])\n },\n )\n\n /**\n * One layer row, from what it shows alone. Its arguments are compared by\n * identity, so an absent node or drop arrives as `undefined`, not as an\n * `Option`, which would be a new value on every draw.\n */\n const drawRow = (\n slots: SlotView.SlotBuilders<typeof BuilderSlots, Message>,\n h: HtmlBuilder<Message>,\n {\n index,\n id,\n branch,\n node,\n open,\n selected,\n drop,\n dragged,\n }: {\n readonly index: number\n readonly id: string\n readonly branch: boolean\n readonly node: Document['nodes'][NodeId] | undefined\n readonly open: boolean\n readonly selected: boolean\n readonly drop: DropZone | undefined\n readonly dragged: boolean\n },\n ): Html =>\n h.li(\n slots.row.attrs(\n [\n h.Key(id),\n h.DataAttribute(ROW_ATTRIBUTE, id),\n ...(node === undefined ? [] : [h.DataAttribute('block', node.block)]),\n ...(drop === undefined ? [] : [h.DataAttribute(ROW_DROP_ATTRIBUTE, drop)]),\n ...(dragged ? [h.DataAttribute(ROW_DRAGGING_ATTRIBUTE, '')] : []),\n h.AriaSelected(selected),\n // Made current, as the keys make a row: it selects the node and keeps the\n // layers showing, where `Selected` would switch a narrow editor to Settings.\n h.OnClick(Layers.wrapper.make(TreeNavigation.Message.Focused({ id }))),\n // Pointing at a row marks its node on the page, as pointing at the page does.\n h.OnMouseEnter(Message.Hovered({ id: NodeId.make(id) })),\n h.OnMouseLeave(Message.Unhovered()),\n ],\n { index, id },\n ),\n [\n ...(branch\n ? [\n h.span(\n slots.rowToggle.attrs([\n // The row says whether it is open; this is the pointer's way to change it.\n h.AriaHidden(true),\n h.OnClick(\n Layers.wrapper.make(\n open\n ? TreeNavigation.Message.Closed({ id })\n : TreeNavigation.Message.Opened({ id }),\n ),\n ),\n ]),\n [],\n ),\n ]\n : []),\n h.span(slots.rowLabel.attrs(), [node === undefined ? id : labelOf(node.block)]),\n ...Option.match(node === undefined ? Option.none() : summaryOf(node), {\n onNone: () => [],\n onSome: summary => [h.span(slots.rowSummary.attrs(), [summary])],\n }),\n ],\n )\n\n // Where the selected and the hovered node are, for the boxes drawn over them.\n const MeasureMarks = Behavior.forSlots(BuilderSlots)<Pick<BuilderInput, never>, Message>(\n {\n canvas: Behavior.slot({\n mount: () =>\n Measure({\n targets: {\n // The mark is on a `display: contents` wrapper, which has no box: its Block's element does.\n selected: `[data-${MARK_ATTRIBUTE}=\"selected\"] > *`,\n hovered: `[data-${MARK_ATTRIBUTE}=\"hovered\"] > *`,\n },\n }),\n }),\n },\n { name: 'MeasureMarks' },\n )\n\n const LayersPart = Parts.part(\n 'Layers',\n {\n reads: ['page', 'selected', 'layers', 'drag', 'editing', 'panel', 'words'],\n behaviors: [\n panelMarks('layers', 'layers'),\n TreeNavigation.behavior(Layers, layersArgs)(BuilderSlots)<\n Pick<BuilderInput, 'page' | 'selected' | 'layers' | 'drag'>,\n Message\n >({\n container: 'tree',\n item: 'row',\n rows: input => rowsOf(builder.document(input)),\n domId: id => layerId(builder, id),\n }),\n // A row is dragged onto another; the keyboard's way is the shortcuts.\n PointerDrag.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'tree',\n attribute: `data-${ROW_ATTRIBUTE}`,\n toMessage: nodeDrag,\n }),\n Shortcuts,\n KeepSelectionInView,\n ],\n },\n (input, slots, h) => {\n const document = builder.document(input)\n const { selected } = input\n const drop = dropOf(input.drag)\n const dragged = Option.flatMap(input.drag, drag =>\n drag.source._tag === 'Existing' ? Option.some(drag.source.id) : Option.none(),\n )\n const shown = TreeNavigation.shown(rowsOf(document), input.layers, layersArgs)\n const tree = h.ul(\n slots.tree.attrs([h.Role('tree'), h.AriaLabel(wordsOf(input.words).layers)]),\n // Each row drawn again only when what it shows changed: a new selection\n // redraws the row it left and the row it reached.\n shown.map((row, index) =>\n slots.row.lazy({ index, id: row.id }, drawRow, {\n index,\n id: row.id,\n branch: row.branch,\n node: document.nodes[NodeId.make(row.id)],\n open: TreeNavigation.isOpen(input.layers, layersArgs, row.id),\n selected: Option.contains(selected, NodeId.make(row.id)),\n drop: Option.getOrUndefined(\n Option.map(\n Option.filter(drop, over => over.id === row.id),\n over => over.zone,\n ),\n ),\n dragged: Option.contains(dragged, NodeId.make(row.id)),\n }),\n ),\n )\n // The tree inside is what is named \"Layers\"; the panel around it is not named twice.\n return h.section(slots.layers.attrs(), [tree])\n },\n )\n\n const Inspector = Parts.part(\n 'Inspector',\n {\n reads: ['page', 'selected', 'options', 'inspector', 'platform', 'panel', 'words'],\n behaviors: [panelMarks('properties', 'inspector')],\n },\n (input, slots, h) => {\n const w = wordsOf(input.words)\n const actions = h.div(\n slots.actions.attrs([h.Role('toolbar'), h.AriaLabel(w.selectedBlock)]),\n builder.commands\n .filter(command => command.placement.includes('node'))\n .map(command => commandButton(h, slots.action, command, input)),\n )\n return Option.match(input.selected, {\n onNone: () =>\n h.div(slots.inspector.attrs([h.Role('group'), h.AriaLabel(w.properties)]), [\n h.p(slots.inspectorHint.attrs(), [w.selectToChange]),\n h.h3(slots.inspectorSectionTitle.attrs(), [w.shortcuts]),\n h.dl(\n slots.shortcuts.attrs(),\n [\n ...TREE_KEYS.map(([keys, what]) => [keys, w[what]] as const),\n ...builder.commands.flatMap(command => {\n const [key] = command.keys\n return key === undefined\n ? []\n : [[keysOf(key, input.platform, w), command.label] as const]\n }),\n ].flatMap(([keys, what]) => [\n h.dt(slots.shortcutKeys.attrs(), [keys]),\n h.dd(slots.shortcutWhat.attrs(), [what]),\n ]),\n ),\n ]),\n onSome: id =>\n inspect(\n builder.document(input),\n id,\n input.options ?? {},\n actions,\n builder.inspecting(input),\n slots,\n h,\n w,\n ),\n })\n },\n )\n\n const Toolbar = Parts.part(\n 'Toolbar',\n { reads: ['page', 'selected', 'platform', 'words'] },\n (input, slots, h) =>\n h.div(\n slots.toolbar.attrs([h.Role('toolbar'), h.AriaLabel(wordsOf(input.words).pageActions)]),\n builder.commands\n .filter(command => command.placement.includes('toolbar'))\n .map(command => commandButton(h, slots.toolbarAction, command, input)),\n ),\n )\n\n const Crumbs = Parts.part(\n 'Crumbs',\n { reads: ['page', 'selected', 'words'] },\n (input, slots, h) => {\n const document = builder.document(input)\n const w = wordsOf(input.words)\n // The page, then each node from the top down to the selected one, which is where you are.\n const holders = (id: NodeId): ReadonlyArray<NodeId> => {\n const places = Composition.index(document)\n const chain: Array<NodeId> = [id]\n for (\n let place = places.get(id);\n place?.parent !== undefined;\n place = places.get(place.parent)\n )\n chain.unshift(place.parent)\n return chain\n }\n const trail = Option.match(input.selected, { onNone: () => [], onSome: holders })\n return h.nav(slots.crumbs.attrs([h.AriaLabel(w.crumbs)]), [\n h.button(\n slots.crumb.attrs([\n h.Type('button'),\n h.OnClick(Message.Deselected()),\n ...(trail.length === 0 ? [h.AriaCurrent('location')] : []),\n ]),\n [w.crumbPage],\n ),\n ...trail.map((id, index) =>\n h.button(\n slots.crumb.attrs([\n h.Type('button'),\n h.OnClick(Message.Selected({ id })),\n ...(index === trail.length - 1 ? [h.AriaCurrent('location')] : []),\n ]),\n [labelAt(document, id)],\n ),\n ),\n ])\n },\n )\n\n const Viewports = Parts.part('Viewports', { reads: ['viewport', 'words'] }, (input, slots, h) =>\n h.div(\n slots.viewports.attrs([h.Role('group'), h.AriaLabel(wordsOf(input.words).viewports)]),\n (['wide', 'medium', 'narrow'] as const).map(viewport =>\n button(\n h,\n slots.viewport,\n wordsOf(input.words)[viewport],\n Option.some(Message.ViewportChosen({ viewport })),\n [\n h.DataAttribute('viewport', viewport),\n h.AriaPressed(input.viewport === viewport ? 'true' : 'false'),\n ],\n ),\n ),\n ),\n )\n\n const context = fieldsOf(builder.catalog.context)\n // Nothing where the Catalog has no context to preview.\n const Preview = Parts.part('Preview', { reads: ['preview', 'words'] }, (input, slots, h) =>\n Object.keys(context).length === 0\n ? null\n : h.div(\n slots.preview.attrs([h.Role('group'), h.AriaLabel(wordsOf(input.words).previewAs)]),\n Object.entries(context).map(([key, schema]) =>\n contextField(slots, h, {\n id: `${builder.name}-preview-${key}`,\n label: key,\n schema,\n current: Option.fromUndefinedOr(input.preview[key]),\n blank: wordsOf(input.words).unset,\n send: value =>\n Option.match(value, {\n onNone: () => Message.PreviewCleared({ key }),\n onSome: chosen => Message.PreviewChosen({ key, value: chosen }),\n }),\n }),\n ),\n ),\n )\n\n const Alert = Parts.part('Alert', { reads: ['refused'] }, (input, slots, h) =>\n Option.match(input.refused, {\n onNone: () => null,\n onSome: refused => h.p(slots.alert.attrs([h.Role('alert')]), [refused.message]),\n }),\n )\n\n // Focusable, so a press on the page leaves the shortcuts where the selection is.\n const Canvas = Parts.part(\n 'Canvas',\n {\n reads: [\n 'page',\n 'selected',\n 'hovered',\n 'drag',\n 'viewport',\n 'preview',\n 'data',\n 'editing',\n 'words',\n ],\n behaviors: [\n Targets.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'canvas',\n attribute: `data-${NODE_ATTRIBUTE}`,\n // A link on the page being edited selects its node; it does not navigate.\n preventDefault: true,\n toMessage: fact =>\n Option.match(asNodeId(fact.id), {\n onNone: () =>\n fact._tag === 'TargetHovered' ? Message.Unhovered() : Message.Deselected(),\n onSome: id =>\n fact._tag === 'TargetHovered'\n ? Message.Hovered({ id })\n : Message.Selected({ id }),\n }),\n }),\n // A node is dragged onto another; the keyboard's way is the shortcuts.\n PointerDrag.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'canvas',\n attribute: `data-${NODE_ATTRIBUTE}`,\n part: `data-${REGION_ATTRIBUTE}`,\n toMessage: nodeDrag,\n }),\n // Text on the page, edited where it is: the Builder checks which field each names.\n EditableText.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'canvas',\n attribute: `data-${FIELD_ATTRIBUTE}`,\n toMessage: fact => {\n switch (fact._tag) {\n case 'EditAsked':\n return Message.EditingAsked({ field: fact.field })\n case 'TextEdited':\n return Message.FieldTyped({ field: fact.field, text: fact.text })\n case 'TextCommitted':\n return Message.EditingCommitted({ field: fact.field, text: fact.text })\n case 'TextCancelled':\n return Message.EditingCancelled({ field: fact.field })\n }\n },\n }),\n Shortcuts,\n KeepSelectionInView,\n MeasureMarks,\n ],\n },\n (input, slots, h) => {\n const document = builder.document(input)\n // The selected node's Block, named on its box.\n const selectedBlock = Option.flatMap(input.selected, id =>\n Option.fromUndefinedOr(document.nodes[id]?.block),\n )\n return h.div(\n slots.canvas.attrs([\n h.Id(canvasId),\n h.DataAttribute('builder-canvas', ''),\n h.Role('region'),\n h.AriaLabel(wordsOf(input.words).canvas),\n h.Tabindex(0),\n ]),\n [\n h.div(\n slots.frame.attrs([\n h.DataAttribute('viewport', input.viewport),\n // The width is the frame's own; the rule that reads it is `FrameDefaults`.\n h.Style({ '--fk-frame-width': viewportWidths[input.viewport] }),\n ]),\n [\n ...(document.roots.length === 0\n ? [h.p(slots.empty.attrs(), [wordsOf(input.words).emptyPage])]\n : []),\n ...Renderer.render(builder.renderer, document, inertHtml, {\n mode: 'edit',\n selected: input.selected,\n hovered: input.hovered,\n drop: dropOf(input.drag),\n context: input.preview,\n data: input.data,\n editing: input.editing,\n }),\n ],\n ),\n // Drawn over the page, placed from where the marked nodes are measured to be;\n // hidden while none is. They only show: they take no pointer.\n h.div(slots.hoverBox.attrs([h.AriaHidden(true)]), []),\n h.div(\n slots.selectionBox.attrs([h.AriaHidden(true)]),\n Option.match(selectedBlock, {\n onNone: () => [],\n onSome: name => [h.span(slots.selectionLabel.attrs(), [labelOf(name)])],\n }),\n ),\n ],\n )\n },\n )\n\n const Live = Parts.part('Live', { reads: ['announcer'] }, (input, slots, h) =>\n h.div(slots.live.attrs(), [LiveAnnounce.view(input.announcer, h)]),\n )\n\n return {\n Panels,\n Palette,\n Layers: LayersPart,\n Inspector,\n Toolbar,\n Crumbs,\n Viewports,\n Preview,\n Alert,\n Canvas,\n Live,\n }\n },\n\n /**\n * A layout of your own: `render` places the parts with `draw`, around\n * anything else you draw with its `h`. Styles and Behaviors attach to the\n * result as to `define`'s.\n */\n assemble: (\n render: SlotView.AssemblyRender<typeof BuilderSlots, BuilderInput, Message>,\n ): BuilderSlotView =>\n Parts.assemble(render, { name: 'Builder' }).pipe(Style.attach(FrameDefaults)),\n\n /**\n * The narrow layout, below `width` of the Builder itself (its root is the\n * container `builder`): the panels' tabs show, and only the panel the\n * Builder's `panel` names; selecting a node chooses Settings.\n * In the `app` layer by default, so it outranks an application's own\n * placing of the panels; pass `layer` to put it elsewhere.\n */\n narrow: (width: string, options: { readonly layer?: Placement } = {}) => {\n const narrower = `@container builder (max-width: ${width})`\n const hidden = Style.at(\n narrower,\n Style.pseudo('[data-panel-shown=\"false\"]', { display: 'none' }),\n )\n return Style.forSlots(BuilderSlots)(\n {\n panelTabs: Style.at(narrower, Style.self({ display: 'flex' })),\n palette: hidden,\n layers: hidden,\n inspector: hidden,\n },\n {\n name: 'BuilderNarrow',\n layer: options.layer ?? StyleLayers.standard.layer('app'),\n },\n )\n },\n\n /** The Builder drawn with every part, in the default layout. */\n define: (\n builder: BuilderLike,\n options: {\n /** How the inspector's settings forms look. */\n readonly settings?: SettingsLook\n } = {},\n ): BuilderSlotView => {\n const parts = BuilderView.parts(builder, options)\n // Four regions, so a new panel lands in one without moving the layout around it.\n return BuilderView.assemble((_input, slots, h, draw) =>\n h.div(slots.root.attrs(), [\n draw(parts.Panels),\n h.div(slots.regions.attrs(), [\n h.div(slots.start.attrs(), [draw(parts.Palette), draw(parts.Layers)]),\n h.div(slots.bar.attrs(), [\n draw(parts.Toolbar),\n draw(parts.Crumbs),\n draw(parts.Viewports),\n draw(parts.Preview),\n ]),\n h.div(slots.stage.attrs(), [draw(parts.Alert), draw(parts.Canvas)]),\n h.div(slots.end.attrs(), [draw(parts.Inspector)]),\n ]),\n draw(parts.Live),\n ]),\n )\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,MAAa,eAAe,MAAM,OAAO;;CAEvC,MAAM,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;;;;;;;;;CASpD,SAAS,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;CACvD,OAAO,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;CACrD,KAAK,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;CACnD,OAAO,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;CACrD,KAAK,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;;;;;;CAMnD,WAAW,KAAK,KAAK,EAAE,YAAY,WAAW,UAAU,CAAC;CACzD,UAAU,KAAK,KAAK,EAAE,YAAY,WAAW,YAAY,CAAC;;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AK,MAAM,OAAO,GAAG,KAAK,MAAM,MAAM,CAAC,CAAC;IACpE,EAAE,IAAI,MAAM,IAAI,MAAM,GAAG;KACvB,KAAK,MAAM,OAAO;KAClB,KAAK,MAAM,MAAM;KACjB,KAAK,MAAM,SAAS;KACpB,KAAK,MAAM,OAAO;IACpB,CAAC;IACD,EAAE,IAAI,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,MAAM,KAAK,GAAG,KAAK,MAAM,MAAM,CAAC,CAAC;IAClE,EAAE,IAAI,MAAM,IAAI,MAAM,GAAG,CAAC,KAAK,MAAM,SAAS,CAAC,CAAC;GAClD,CAAC;GACD,KAAK,MAAM,IAAI;EACjB,CAAC,CACH;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["StyleLayers","builderWords"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `foldkit-mixins-builder`: the page Builder drawn as accessible HTML, every\n * element a `foldkit-mixins` Slot.\n *\n * `foldkit-builder` owns the editor's state and draws nothing of its own worth\n * shipping. This package draws it: a palette of the Blocks a page may gain, the\n * page's layers as an ARIA tree driven by the keyboard, the selected node's\n * props in an inspector, undo and redo, a viewport picker, and the page itself,\n * drawn by the site's own Renderer in edit mode. It adds no state and no\n * Messages: every element dispatches one of the Builder's own.\n *\n * Interaction comes from `foldkit-primitives`, attached as Behaviors:\n * `TreeNavigation` on the layers, `Targets` on the canvas (hover and click pick\n * a node), and the Builder's `keyPressed` shortcuts on the layers and the canvas.\n */\nimport { Match, Option, Schema } from 'effect'\nimport {\n Layers,\n controlOf,\n inputOf,\n Message,\n layersArgs,\n type ContextValue,\n type BuilderCommand,\n type CommandKey,\n type DragSource,\n type DropZone,\n type InspectedForm,\n type Inspecting,\n type Model,\n type Settings,\n} from 'foldkit-builder'\nimport {\n Catalog,\n Composition,\n NodeId,\n fieldsOf,\n spaced,\n type Document,\n type Position,\n} from 'foldkit-composition'\nimport {\n FIELD_ATTRIBUTE,\n MARK_ATTRIBUTE,\n NODE_ATTRIBUTE,\n REGION_ATTRIBUTE,\n PAGE_CONTAINER,\n Renderer,\n} from 'foldkit-composition/foldkit'\nimport { Entity } from 'foldkit-entity'\nimport { Input, type Control } from 'foldkit-form'\nimport {\n Behavior,\n Capability,\n Layers as StyleLayers,\n type Placement,\n Slot,\n Slots,\n SlotView,\n Style,\n} from 'foldkit-mixins'\nimport { FormView, type FormViewInputs, type Renderers } from 'foldkit-mixins-form'\nimport { KeepInView, Measure, measured } from 'foldkit-primitives/dom'\nimport {\n EditableText,\n LiveAnnounce,\n PointerDrag,\n Targets,\n TreeNavigation,\n} from 'foldkit-primitives/interaction'\nimport type { KeyboardModifiers } from 'foldkit/html'\nimport { createLazy, inertHtml, type Attribute, type Html, type HtmlBuilder } from 'foldkit/html'\nimport * as Submodel from 'foldkit/submodel'\nimport { builderWords, say, wordsOf, type BuilderWords } from './words.js'\n\nexport { builderWords, type BuilderWords } from './words.js'\n\n/** The Builder's public customization contract: every element the editor draws. */\nexport const BuilderSlots = Slots.define({\n /** The editor: the container `builder`, so a Style may follow the editor's own width. */\n root: Slot.make({ capability: Capability.Container }),\n /**\n * The default layout's four regions, and what holds them, which a stylist\n * lays out rather than each panel: `start` holds the palette and the layers,\n * `bar` the toolbar, the crumbs, the viewports and the preview, `stage` the\n * alert and the canvas, and `end` the inspector. Inside `root`, so their\n * layout may change with `@container builder (…)`. A layout of your own\n * draws none of them.\n */\n regions: Slot.make({ capability: Capability.Container }),\n start: Slot.make({ capability: Capability.Container }),\n bar: Slot.make({ capability: Capability.Container }),\n stage: Slot.make({ capability: Capability.Container }),\n end: Slot.make({ capability: Capability.Container }),\n /**\n * A group of three pressed-state buttons, one per panel, Add, Layers and Settings, for a\n * narrow layout that shows one at a time (`BuilderView.narrow`); hidden\n * otherwise. One `panelTab` each, with `data-panel`.\n */\n panelTabs: Slot.make({ capability: Capability.Container }),\n panelTab: Slot.make({ capability: Capability.Interactive }),\n /** The Blocks a page may gain, in groups, one button each. */\n palette: Slot.make({ capability: Capability.Container }),\n /** One group of the palette, and its heading, drawn when there is more than one. */\n paletteGroup: Slot.make({ capability: Capability.Container }),\n paletteHeading: Slot.make({ capability: Capability.Base }),\n /** A Block to add: its label, and the line describing it. Carries `data-block`. */\n paletteItem: Slot.make({ capability: Capability.Interactive }),\n paletteLabel: Slot.make({ capability: Capability.Base }),\n paletteHint: Slot.make({ capability: Capability.Base }),\n /** The layers panel: it takes the editor's keyboard shortcuts. */\n layers: Slot.make({ capability: Capability.Interactive }),\n /** The `role=\"tree\"` element, and one `treeitem` row per node showing. Rows carry `data-block`. */\n tree: Slot.make({ capability: Capability.Container }),\n row: Slot.make({ capability: Capability.Focusable }),\n /** On a row that holds others: opens or closes it, as Right and Left do. */\n rowToggle: Slot.make({ capability: Capability.Interactive }),\n /** A row's Block, and what its node says, in brief. */\n rowLabel: Slot.make({ capability: Capability.Base }),\n rowSummary: Slot.make({ capability: Capability.Base }),\n /** Move, duplicate and delete for the selected node, in the inspector's head. Each carries `data-action`. */\n actions: Slot.make({ capability: Capability.Container }),\n action: Slot.make({ capability: Capability.Interactive }),\n /** The selected node's settings, or, with nothing selected, how to begin and the shortcuts. */\n inspector: Slot.make({ capability: Capability.Container }),\n /** The selected node's Block: its label, what it is for, and its actions. */\n inspectorHead: Slot.make({ capability: Capability.Container }),\n inspectorTitle: Slot.make({ capability: Capability.Base }),\n inspectorHint: Slot.make({ capability: Capability.Base }),\n /** One part of the settings, such as Content or Style, and its heading. */\n inspectorSection: Slot.make({ capability: Capability.Container }),\n inspectorSectionTitle: Slot.make({ capability: Capability.Base }),\n field: Slot.make({ capability: Capability.Container }),\n /** A field's name: a `label`, or a `span` naming a group of controls. */\n label: Slot.make({ capability: Capability.Base }),\n control: Slot.make({ capability: Capability.Interactive }),\n /** One choice of a many-choice picker: its checkbox and its words. */\n option: Slot.make({ capability: Capability.Base }),\n /** One choice of a `select`. */\n selectOption: Slot.make({ capability: Capability.Base }),\n /** A look's few values as buttons, one pressed: drawn in place of a select. */\n choices: Slot.make({ capability: Capability.Container }),\n choice: Slot.make({ capability: Capability.Interactive }),\n /** The editor's shortcuts, as a list of keys and what they do. */\n shortcuts: Slot.make({ capability: Capability.Container }),\n shortcutKeys: Slot.make({ capability: Capability.Base }),\n shortcutWhat: Slot.make({ capability: Capability.Base }),\n /** The commands offered in the toolbar, undo and redo by default. One `toolbarAction` each, with `data-action`. */\n toolbar: Slot.make({ capability: Capability.Container }),\n toolbarAction: Slot.make({ capability: Capability.Interactive }),\n /** Where the selection is: the page, then each node holding it, then it. One `crumb` button each. */\n crumbs: Slot.make({ capability: Capability.Container }),\n crumb: Slot.make({ capability: Capability.Interactive }),\n viewports: Slot.make({ capability: Capability.Container }),\n viewport: Slot.make({ capability: Capability.Interactive }),\n /** What the page is previewed as: one field per key of the Catalog's context. */\n preview: Slot.make({ capability: Capability.Container }),\n /** Why the last edit was refused. */\n alert: Slot.make({ capability: Capability.Base }),\n /** The page in edit mode, and the frame that sets its width. It takes the shortcuts when focused. */\n canvas: Slot.make({ capability: Capability.Container }),\n frame: Slot.make({ capability: Capability.Container }),\n /** In the frame while the page holds nothing: how to begin. */\n empty: Slot.make({ capability: Capability.Base }),\n /**\n * Over the selected node on the canvas, placed from where it is measured to\n * be, with its Block's label; drawn over the page, so the page's own\n * markup needs no mark to show it.\n */\n selectionBox: Slot.make({ capability: Capability.Container }),\n selectionLabel: Slot.make({ capability: Capability.Base }),\n /** Over the node under the pointer, as the selection's box is placed. */\n hoverBox: Slot.make({ capability: Capability.Base }),\n /** The live region the Builder's announcements are read from. */\n live: Slot.make({ capability: Capability.Base }),\n})\n\n/** A box over a measured node: where `Measure` found it, and nothing to the pointer. */\nconst boxOver = (name: string) => {\n const at = measured(name)\n return Style.self({\n position: 'absolute',\n insetInlineStart: `var(${at.x})`,\n insetBlockStart: `var(${at.y})`,\n width: `var(${at.w})`,\n height: `var(${at.h})`,\n display: `var(${at.display}, none)`,\n boxSizing: 'border-box',\n pointerEvents: 'none',\n })\n}\n\n/**\n * What the drawn Builder needs to work unstyled: the root a container, the frame\n * as wide as the viewport, centred, the boxes over the canvas, the narrow tabs\n * hidden. In `components`, so an application's style overrides it.\n */\nconst FrameDefaults = Style.forSlots(BuilderSlots)(\n {\n // The page's container, so a look measures the frame it is previewed in, not the window.\n frame: Style.self({\n maxWidth: 'var(--fk-frame-width)',\n marginInline: 'auto',\n containerType: 'inline-size',\n containerName: PAGE_CONTAINER,\n }),\n // What the boxes are placed in: the canvas, measured from its scroll box.\n canvas: Style.self({ position: 'relative' }),\n selectionBox: boxOver('selected'),\n selectionLabel: Style.self({\n position: 'absolute',\n insetBlockEnd: '100%',\n insetInlineStart: '0',\n }),\n hoverBox: boxOver('hovered'),\n // A container, so what it holds may be laid out by the editor's width, not the window's.\n root: Style.self({ containerType: 'inline-size', containerName: 'builder' }),\n // Shown only by a narrow layout, which shows one panel at a time.\n panelTabs: Style.self({ display: 'none' }),\n },\n { name: 'BuilderDefaults', layer: StyleLayers.standard.layer('components') },\n)\n\n/** The panels a narrow layout shows one at a time, by the Builder's `panel`, and their tabs' words. */\nconst PANELS = [\n ['insert', 'addPanel'],\n ['layers', 'layersPanel'],\n ['properties', 'settingsPanel'],\n] as const\n\n/** The width each viewport draws the page at. */\nexport const viewportWidths = { wide: '100%', medium: '768px', narrow: '375px' } as const\n\n/** What `BuilderView.define` needs of a Builder: what `Builder.make` returns has all of it. */\nexport interface BuilderLike {\n readonly name: string\n readonly catalog: Catalog\n // `any`: a Renderer's entries are keyed by its own Blocks, so no one Blocks type fits every Builder's.\n readonly renderer: Renderer<any, never>\n readonly offered: ReadonlyArray<string>\n readonly document: (model: Pick<Model, 'page'>) => Document\n // Method syntax: a Builder whose Blocks are named narrower still fits.\n placeFor(\n document: Document,\n selected: Option.Option<NodeId>,\n block: string,\n ): Option.Option<Position>\n /** Where a pattern goes, as `placeFor` places its root's Block. */\n readonly patternAt: (\n document: Document,\n selected: Option.Option<NodeId>,\n pattern: string,\n ) => Option.Option<Position>\n /** What a key, a node's action and the toolbar run. */\n readonly commands: ReadonlyArray<BuilderCommand>\n readonly inspecting: (\n model: Pick<Model, 'page' | 'selected' | 'inspector'>,\n ) => Option.Option<Inspecting>\n readonly keyCommand: (\n model: Pick<Model, 'page' | 'selected' | 'editing'>,\n key: string,\n modifiers: KeyboardModifiers,\n ) => Option.Option<Message>\n readonly keyPressed: (\n model: Pick<Model, 'editing'>,\n key: string,\n modifiers: KeyboardModifiers,\n ) => Option.Option<Message>\n}\n\n/** Every node as a tree row, in document order, with its parent node and whether it holds any. */\nexport const rowsOf = (document: Document): ReadonlyArray<TreeNavigation.Row> => {\n // The view and the tree's Behavior both ask, on every draw.\n const known = rowsByDocument.get(document)\n if (known !== undefined) return known\n const rows: Array<TreeNavigation.Row> = []\n const seen = new Set<string>()\n const visit = (id: NodeId, parent: string | null): void => {\n const node = document.nodes[id]\n if (node === undefined || seen.has(id)) return\n seen.add(id)\n const children = Object.values(node.regions).flat()\n rows.push({ id, parent, branch: children.length > 0 })\n for (const child of children) visit(child, id)\n }\n for (const root of document.roots) visit(root, null)\n rowsByDocument.set(document, rows)\n return rows\n}\n\nconst rowsByDocument = new WeakMap<Document, ReadonlyArray<TreeNavigation.Row>>()\n\n/** The attribute a layer row carries, holding its node's id, for a drag to find. */\nexport const ROW_ATTRIBUTE = 'builder-row'\n/** On the row a drop is aimed at, holding where: `before`, `inside` or `after`. */\nexport const ROW_DROP_ATTRIBUTE = 'builder-drop'\n/** On the row being dragged. */\nexport const ROW_DRAGGING_ATTRIBUTE = 'builder-dragging'\n\n/**\n * A drag's facts as the Builder's Messages; `source` says what the dragged\n * element is: a node's own id, or a palette tile's Block.\n */\nconst dragMessage =\n (source: (id: string) => DragSource) =>\n (fact: PointerDrag.DragFact): Message => {\n switch (fact._tag) {\n case 'DragStarted':\n return Message.DragStarted({ source: source(fact.id) })\n case 'DraggedOver':\n // The DOM's fact says \"over nothing\" with `null`, over the page's own space\n // with `region` too, and over a node's empty Region with its `part`; the\n // Builder has a Message for each.\n return fact.over !== null\n ? fact.over.part === undefined\n ? Message.DraggedOver({ id: NodeId.make(fact.over.id), zone: fact.over.zone })\n : Message.DraggedOverRegion({ id: NodeId.make(fact.over.id), region: fact.over.part })\n : fact.region === true\n ? Message.DraggedOverPage()\n : Message.DraggedOff()\n case 'DragDropped':\n return Message.DragDropped()\n case 'DragCancelled':\n return Message.DragCancelled()\n }\n }\n/** A row or a node dragged: a node on the page. */\nconst nodeDrag = dragMessage(id => ({ _tag: 'Existing', id: NodeId.make(id) }))\n/** A palette tile dragged: a new node of its Block. */\nconst tileDrag = dragMessage(block => ({ _tag: 'New', block }))\n\n/** The DOM id a layer row carries, so keyboard focus can find it. */\nexport const layerId = (builder: { readonly name: string }, id: string): string =>\n `${builder.name}-layer-${id}`\n\n/** A node id the DOM reported, where `null` or an empty id is none. */\nconst asNodeId = (id: string | null): Option.Option<NodeId> =>\n Option.map(\n Option.filter(Option.fromNullOr(id), found => found !== ''),\n NodeId.make,\n )\n\n/** A stored appearance that is a record of choices, as opposed to a list or a scalar. */\nconst isChoices = (\n value: Schema.Json | undefined,\n): value is { readonly [axis: string]: Schema.Json } =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/** What a context key's control reads as a value: blank is none, a toggle's text a boolean. */\nconst contextValue = (control: Control | undefined, raw: string): Option.Option<ContextValue> => {\n if (raw === '') return Option.none()\n if (control !== undefined && Input.Toggle.is(control)) return Option.some(raw === 'true')\n if (\n control !== undefined &&\n Input.Number.is(control) &&\n raw.trim() !== '' &&\n Number.isFinite(Number(raw))\n )\n return Option.some(Number(raw))\n return Option.some(raw)\n}\n\n/** Choices named by themselves. */\nconst named = (values: ReadonlyArray<string>): ReadonlyArray<BuilderOption> =>\n values.map(value => ({ value, label: value }))\n\n/**\n * A select's options: a blank, the choices, and a stored value the choices lack,\n * shown as `? value` and chosen, rather than the blank misreporting it. With no\n * word for the blank, it is offered only while nothing is chosen.\n */\nconst optionsOf = <Message>(\n h: HtmlBuilder<Message>,\n option: SlotView.SlotBuilder<Message>,\n select: {\n /** What the blank choice reads as; with none, a blank only while nothing is chosen. */\n readonly blank?: string | undefined\n readonly choices: ReadonlyArray<BuilderOption>\n readonly current?: string | undefined\n },\n): ReadonlyArray<Html> => {\n const { blank, choices, current } = select\n const empty = current === undefined || current === ''\n const stray = !empty && !choices.some(choice => choice.value === current)\n return [\n ...(blank !== undefined || empty\n ? [h.option(option.attrs([h.Value(''), h.Selected(empty)]), [blank ?? ''])]\n : []),\n ...choices.map(choice =>\n h.option(option.attrs([h.Value(choice.value), h.Selected(current === choice.value)]), [\n choice.label,\n ]),\n ),\n ...(stray\n ? [h.option(option.attrs([h.Value(current), h.Selected(true)]), [`? ${current}`])]\n : []),\n ]\n}\n\n/** The choices a context key offers, or `undefined` when it is typed in. */\nconst contextChoices = (control: Control | undefined): ReadonlyArray<string> | undefined =>\n control === undefined\n ? undefined\n : Input.Select.is(control)\n ? control.data.options.map(String)\n : Input.Toggle.is(control)\n ? ['true', 'false']\n : undefined\n\n/** The longest summary a layer row shows before it is cut short. */\nconst SUMMARY_LENGTH = 40\n\n/** The most values a look offers as buttons; one with more is a select. */\nconst CHOICES_SHOWN = 4\n\n/** The keys the tree's own keyboard takes, beside the commands: they move focus, not the page. */\nconst TREE_KEYS: ReadonlyArray<readonly [keys: string, what: 'treeUpDown' | 'treeLeftRight']> = [\n ['↑ ↓', 'treeUpDown'],\n ['← →', 'treeLeftRight'],\n]\n\n/** How a key is named on screen. */\nconst keyNames: Readonly<Record<string, string>> = {\n ArrowUp: '↑',\n ArrowDown: '↓',\n ArrowLeft: '←',\n ArrowRight: '→',\n}\n\n/**\n * A command's key as a person on `platform` reads it, in its own order: `⌥⇧⌘Z`\n * on a Mac, where `mod` is ⌘, and `Ctrl+Alt+Shift+Z` elsewhere, the modifiers\n * named by `words`.\n */\nexport const keysOf = (\n key: CommandKey,\n platform: Platform = 'other',\n words: Pick<BuilderWords, 'keyNames' | 'ctrlKey' | 'altKey' | 'shiftKey'> = builderWords,\n): string => {\n // A key is the caller's text: each table is read for an own entry only, never `Object`'s.\n const own = (table: Readonly<Record<string, string>>) =>\n Object.hasOwn(table, key.key) ? Option.fromUndefinedOr(table[key.key]) : Option.none()\n const name = Option.getOrElse(\n Option.orElse(own(keyNames), () => own(words.keyNames)),\n () => (key.key.length === 1 ? key.key.toUpperCase() : key.key),\n )\n const held = (\n words: { mod: string; alt: string; shift: string },\n order: ReadonlyArray<'mod' | 'alt' | 'shift'>,\n ) => order.flatMap(modifier => (key[modifier] === true ? [words[modifier]] : []))\n return platform === 'mac'\n ? [...held({ mod: '⌘', alt: '⌥', shift: '⇧' }, ['alt', 'shift', 'mod']), name].join('')\n : [\n ...held({ mod: words.ctrlKey, alt: words.altKey, shift: words.shiftKey }, [\n 'mod',\n 'alt',\n 'shift',\n ]),\n name,\n ].join('+')\n}\n\n/** The platform keys are named for: a Mac's, or any other's. */\nexport type Platform = 'mac' | 'other'\n\n/**\n * What the drawn Builder is given beside its Model, by the page's parent: the\n * application's, never the Builder's to keep.\n */\nexport interface BuilderViewInputs {\n /** The platform the author is on, so keys are named as theirs are (⌘ on a Mac). Default: `other`. */\n readonly platform?: Platform | undefined\n /**\n * Each node's read, by node id, as a published page is drawn with it: the\n * page's Query and Surface Blocks' values, so the canvas shows their rows.\n */\n readonly data?: Readonly<Record<string, unknown>> | undefined\n /**\n * The choices of a relation prop's picker, keyed `'Block.prop'`: the rows the\n * application loaded for it, as a form's `options` are.\n */\n readonly options?: Readonly<Record<string, ReadonlyArray<BuilderOption>>> | undefined\n /** The editor's words, over the English ones (`builderWords`). */\n readonly words?: Partial<BuilderWords> | undefined\n}\n\n/** One choice of a relation picker: what is stored, and what is shown. */\nexport interface BuilderOption {\n readonly value: string\n readonly label: string\n}\n\n/** What the drawn Builder's Slots and Behaviors read: its Model and its inputs. */\nexport type BuilderInput = Model & BuilderViewInputs\n\n// Whether a runtime render is under way, which `h.submodel` needs. Foldkit offers\n// no way to ask; a lazy slot reads the current frame before anything else and\n// throws without one. Any other throw, such as a slot drawn twice, is left to surface.\nconst probe = createLazy()\nconst nothing = () => null\nconst inRender = (): boolean => {\n try {\n probe(nothing, [])\n return true\n } catch {\n return false\n }\n}\n\n/**\n * How the inspector's settings forms look: Styles attached to every Block's\n * settings form, as to any form's `FormView.field(form)` and `FormView.define`.\n */\nexport interface SettingsLook {\n /** Attached to each settings form's fields: `FieldSlots`. */\n readonly field?: SlotView.SlotViewTransform\n /** Attached to each settings form around its fields: `FormSlots`. */\n readonly form?: SlotView.SlotViewTransform\n /**\n * Renderers for control kinds of the application's own, beside the shipped\n * ones, as a form view takes them. A function of the Message, since each\n * Block's settings form has Messages of its own: `foldkit-form-recipes/html`'s `renderers`.\n */\n readonly renderers?: <Message>() => Renderers<Message>\n}\n\n/** A Block's settings form, drawn with `look`. */\nconst settingsViewOf = (settings: Settings, look: SettingsLook) => {\n const field = FormView.field(\n settings.form,\n look.renderers === undefined ? {} : { renderers: look.renderers() },\n )\n const drawn = FormView.define(settings.form, {\n field: look.field === undefined ? field : field.pipe(look.field),\n })\n const view = FormView.submodel(\n settings.form,\n look.form === undefined ? drawn : drawn.pipe(look.form),\n )\n return view\n}\n\n/** The drawn Builder: what `BuilderView.define` returns. */\nexport type BuilderSlotView = SlotView.SlotView<typeof BuilderSlots, BuilderInput, Message>\n\nconst Parts = SlotView.parts(BuilderSlots)<BuilderInput, Message>()\n\n/** One piece of the drawn Builder, placed by `BuilderView.assemble`. */\nexport type BuilderPart = SlotView.Part<typeof BuilderSlots, BuilderInput, Message>\n\n/** The drawn Builder's pieces, by what they show. */\nexport interface BuilderParts {\n /** The panels' switch, for a narrow layout: see `BuilderView.narrow`. */\n readonly Panels: BuilderPart\n /** The Blocks a page may gain, each a button that inserts it. */\n readonly Palette: BuilderPart\n /** The page's nodes as an ARIA tree, with the keyboard and dragging. */\n readonly Layers: BuilderPart\n /** The selected node's props, looks, conditions and actions, or the shortcuts. */\n readonly Inspector: BuilderPart\n /** The toolbar's commands: undo and redo, unless the Builder's commands say otherwise. */\n readonly Toolbar: BuilderPart\n /** Where the selection is, from the page down. */\n readonly Crumbs: BuilderPart\n readonly Viewports: BuilderPart\n /** The context the page is previewed for; nothing where the Catalog has none. */\n readonly Preview: BuilderPart\n /** Why the last edit was refused; nothing when none was. */\n readonly Alert: BuilderPart\n /** The page, drawn by the site's Renderer, with the pointer. */\n readonly Canvas: BuilderPart\n /** What the Builder announces to a screen reader. */\n readonly Live: BuilderPart\n}\n\nexport const BuilderView = {\n /** What the drawn Builder is drawn with, typed where a form's `controls` entry cannot be. */\n inputs: (inputs: BuilderViewInputs = {}): BuilderViewInputs => inputs,\n\n /**\n * The drawn Builder as a Submodel view, for `bundle.pipe(Bundle.withView(...))`\n * or `builder.inputWith(...)`, drawn with `BuilderView.inputs(...)`.\n */\n submodel: (view: BuilderSlotView): Submodel.View<Model, Message, BuilderViewInputs> =>\n Submodel.defineView<Model, Message, BuilderViewInputs>(((\n model: Model,\n inputs: BuilderViewInputs | HtmlBuilder<Message>,\n h: HtmlBuilder<Message> | undefined,\n ) =>\n // A form draws a Bundle control with no inputs when its `controls` gives the\n // key none, and a Submodel view given none is called as `(model, h)`.\n h === undefined\n ? view(model, inputs as HtmlBuilder<Message>)\n : view({ ...model, ...(inputs as BuilderViewInputs) }, h)) as (\n model: Model,\n inputs: BuilderViewInputs,\n h: HtmlBuilder<Message>,\n ) => Html),\n\n /**\n * The Builder's parts, each drawn again only when what it reads changed,\n * with its Behaviors (the layers' keyboard, the canvas's pointer, the\n * shortcuts) declared with it. Place them with `assemble`.\n */\n parts: (\n builder: BuilderLike,\n options: {\n /** How the inspector's settings forms look. */\n readonly settings?: SettingsLook\n } = {},\n ): BuilderParts => {\n // Each Block's settings form, drawn: made once per form, as the form is once per Block.\n const settingsViews = new WeakMap<Settings, ReturnType<typeof settingsViewOf>>()\n const settingsView = (settings: Settings) => {\n const known = settingsViews.get(settings)\n if (known !== undefined) return known\n const made = settingsViewOf(settings, options.settings ?? {})\n settingsViews.set(settings, made)\n return made\n }\n const described = new Map(\n builder.catalog.blocks.map(block => {\n // The props a layer row may quote: those drawn as text.\n const texts = Object.entries(fieldsOf(block.Props)).flatMap(([key, schema]) => {\n const control = controlOf(block, key, schema)\n return control !== undefined && (Input.Text.is(control) || Input.Multiline.is(control))\n ? [key]\n : []\n })\n return [\n block.name,\n {\n label: block.words.label,\n description: block.words.description,\n // Blocks given no group share one.\n group: block.words.group,\n texts,\n },\n ] as const\n }),\n )\n /** A Block's label; one the Catalog lacks is marked unknown. */\n const labelOf = (name: string): string => described.get(name)?.label ?? `? ${name}`\n /** A node's first text prop that says something, cut short. */\n const summaryOf = (node: Document['nodes'][NodeId]): Option.Option<string> => {\n for (const key of described.get(node.block)?.texts ?? []) {\n const value = node.props[key]\n const text = typeof value === 'string' ? value.replace(/\\s+/g, ' ').trim() : ''\n if (text !== '')\n return Option.some(\n text.length > SUMMARY_LENGTH ? `${text.slice(0, SUMMARY_LENGTH - 1).trimEnd()}…` : text,\n )\n }\n return Option.none()\n }\n // The palette's groups, in the order their first Block is offered: a Map keeps insertion\n // order. Blocks given no group share one, named when drawn, by the words.\n const ungrouped = Symbol('ungrouped')\n const grouped = new Map<string | typeof ungrouped, Array<string>>()\n for (const name of builder.offered) {\n const group = Option.getOrElse(\n Option.flatMap(Option.fromUndefinedOr(described.get(name)), each => each.group),\n (): string | typeof ungrouped => ungrouped,\n )\n const names = grouped.get(group)\n if (names === undefined) grouped.set(group, [name])\n else names.push(name)\n }\n const groups = [...grouped].map(([group, names]) => ({\n group: group === ungrouped ? Option.none<string>() : Option.some(group),\n names,\n }))\n const patterns = builder.catalog.patterns\n // A heading names each group when there is more than one, the patterns' included.\n const headed = groups.length + (patterns.length > 0 ? 1 : 0) > 1\n\n // One field per context key: a choice, or typed in; blank is unset.\n const contextField = (\n slots: SlotView.SlotBuilders<typeof BuilderSlots, Message>,\n h: HtmlBuilder<Message>,\n field: {\n readonly id: string\n readonly label: string\n readonly schema: Schema.Top\n readonly current: Option.Option<ContextValue>\n /** What the blank choice reads as. */\n readonly blank: string\n /** The value chosen, or none for the blank. */\n readonly send: (value: Option.Option<ContextValue>) => Message\n },\n ) => {\n const { id: fieldId, label, schema, current, blank, send } = field\n const control = Input.resolve(Entity.unmapped, schema)\n const choices = contextChoices(control)\n // A context value that is itself `null` is shown as the blank too.\n const shown = Option.match(current, {\n onNone: () => '',\n onSome: value => (value === null ? '' : String(value)),\n })\n return h.div(slots.field.attrs(), [\n h.label(slots.label.attrs([h.For(fieldId)]), [label]),\n choices === undefined\n ? h.input(\n slots.control.attrs([\n h.Id(fieldId),\n h.Value(shown),\n h.OnInput(raw => send(contextValue(control, raw))),\n ]),\n )\n : h.select(\n slots.control.attrs([\n h.Id(fieldId),\n h.OnChange(raw => send(contextValue(control, raw))),\n ]),\n optionsOf(h, slots.selectOption, { blank, choices: named(choices), current: shown }),\n ),\n ])\n }\n\n const inspect = (\n document: Document,\n id: NodeId,\n options: Readonly<Record<string, ReadonlyArray<BuilderOption>>>,\n actions: Html,\n inspecting: Option.Option<Inspecting>,\n slots: SlotView.SlotBuilders<typeof BuilderSlots, Message>,\n h: HtmlBuilder<Message>,\n w: BuilderWords,\n ): Html => {\n const node = document.nodes[id]\n const block = node === undefined ? undefined : Catalog.block(builder.catalog, node.block)\n const head = h.div(slots.inspectorHead.attrs(), [\n h.h2(slots.inspectorTitle.attrs(), [node === undefined ? id : labelOf(node.block)]),\n ...Option.match(\n node === undefined\n ? Option.none()\n : (described.get(node.block)?.description ?? Option.none()),\n {\n onNone: () => [],\n onSome: hint => [h.p(slots.inspectorHint.attrs(), [hint])],\n },\n ),\n actions,\n ])\n /** A part of the settings under its heading; none when it has nothing in it. */\n const section = (title: string, fields: ReadonlyArray<Html>): ReadonlyArray<Html> =>\n fields.length === 0\n ? []\n : [\n h.div(slots.inspectorSection.attrs([h.Role('group'), h.AriaLabel(title)]), [\n h.h3(slots.inspectorSectionTitle.attrs(), [title]),\n ...fields,\n ]),\n ]\n if (node === undefined || block === undefined)\n return h.div(slots.inspector.attrs([h.Role('group'), h.AriaLabel(w.properties)]), [\n head,\n h.p([], [w.unknownBlock]),\n ...Object.entries(node?.props ?? {}).map(([key, value]) =>\n h.div(slots.field.attrs(), [\n h.span(slots.label.attrs(), [key]),\n h.code(slots.control.attrs(), [JSON.stringify(value)]),\n ]),\n ),\n ])\n // The props: the Block's settings form, whose changes the Builder turns into edits,\n // then any prop no control fits, as it is stored.\n /**\n * One of the node's forms, placed under `slot`; its Messages go to the\n * Builder as `Inspected`, naming the node and the form.\n */\n const drawForm = (\n target: Inspecting,\n form: InspectedForm,\n slot: string,\n inputs: FormViewInputs,\n ): Html => {\n const view = settingsView(form.settings)\n return inRender()\n ? h.submodel({\n slotId: `${builder.name}-${slot}`,\n model: form.model,\n view,\n toParentMessage: sent =>\n Message.Inspected({\n id: target.id,\n form: form.key,\n message: form.settings.encodeMessage(sent),\n }),\n viewInputs: inputs,\n })\n : // No runtime frame (a test, a static description): nothing carries the form's\n // Messages to the Builder, and no handler can run, so it is drawn as it is.\n view(form.model, inputs, SlotView.inertBuilder())\n }\n const fields = Option.match(inspecting, {\n onNone: () => [],\n onSome: target => [\n drawForm(target, target.props, 'settings', {\n submits: false,\n words: { none: w.none },\n // The application's choices are keyed `'Block.prop'`; the form's by prop.\n options: Object.fromEntries(\n Object.entries(options).flatMap(([at, choices]) =>\n at.startsWith(`${node.block}.`) ? [[at.slice(node.block.length + 1), choices]] : [],\n ),\n ),\n }),\n ...target.props.settings\n .shown(node.props)\n .map(({ label, value }) =>\n h.div(slots.field.attrs(), [\n h.span(slots.label.attrs(), [label]),\n h.code(slots.control.attrs(), [JSON.stringify(value)]),\n ]),\n ),\n ],\n })\n // The node's look: one choice per axis its Block offers, blank for the default,\n // and on a responsive axis one more per breakpoint it may change at.\n const chosen = isChoices(node.appearance) ? node.appearance : {}\n const looks = Object.entries(block.appearance).flatMap(([axis, look]) => {\n const { values, breakpoints } = look\n /** A value's name: the look's label for it, else the value spaced. */\n const named = (value: string): string => look.labels?.[value] ?? spaced(value)\n const stored = chosen[axis]\n // What is chosen at each point: `base`, then each breakpoint.\n const at: Readonly<Record<string, string>> =\n typeof stored === 'string'\n ? { base: stored }\n : isChoices(stored)\n ? Object.fromEntries(\n Object.entries(stored).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string',\n ),\n )\n : {}\n const choose =\n (point: string) =>\n (value: string): Message => {\n const { [point]: _, ...kept } = at\n const points = value === '' ? kept : { ...kept, [point]: value }\n const { [axis]: __, ...others } = chosen\n // One name when only the base is chosen; none when nothing is.\n const choice =\n Object.keys(points).length === 0\n ? undefined\n : Object.keys(points).length === 1 && points['base'] !== undefined\n ? points['base']\n : points\n const next = choice === undefined ? others : { ...others, [axis]: choice }\n return Message.Applied({\n op: Composition.Op.setAppearance(id, Object.keys(next).length === 0 ? null : next),\n })\n }\n const label = spaced(axis)\n if ((breakpoints ?? []).length === 0 && values.length <= CHOICES_SHOWN) {\n const current = at['base']\n // A stored value the look lacks is shown pressed, and choosing it again sends nothing.\n const stray =\n current !== undefined && !values.includes(current)\n ? Option.some(current)\n : Option.none()\n return [\n h.div(slots.field.attrs(), [\n h.span(slots.label.attrs(), [label]),\n h.div(\n slots.choices.attrs([\n h.Id(`${builder.name}-${id}-appearance-${axis}`),\n h.Role('group'),\n h.AriaLabel(label),\n ]),\n [\n ...[\n ['', w.lookDefault] as const,\n ...values.map(value => [value, named(value)] as const),\n ].map(([value, text]) =>\n h.button(\n slots.choice.attrs([\n h.Type('button'),\n h.AriaPressed(\n (value === '' ? current === undefined : current === value)\n ? 'true'\n : 'false',\n ),\n h.OnClick(choose('base')(value)),\n ]),\n [text],\n ),\n ),\n ...Option.match(stray, {\n onNone: () => [],\n onSome: value => [\n h.button(\n slots.choice.attrs([\n h.Type('button'),\n h.AriaPressed('true'),\n h.Disabled(true),\n ]),\n [`? ${value}`],\n ),\n ],\n }),\n ],\n ),\n ]),\n ]\n }\n return ['base', ...(breakpoints ?? [])].map(point => {\n const fieldId = `${builder.name}-${id}-appearance-${axis}${point === 'base' ? '' : `-${point}`}`\n return h.div(slots.field.attrs(), [\n h.label(slots.label.attrs([h.For(fieldId)]), [\n point === 'base' ? label : say(w.lookAt, { label, breakpoint: point }),\n ]),\n h.select(\n slots.control.attrs([h.Id(fieldId), h.OnChange(choose(point))]),\n optionsOf(h, slots.selectOption, {\n blank: point === 'base' ? w.lookDefault : w.lookUnchanged,\n choices: values.map(value => ({ value, label: named(value) })),\n current: at[point],\n }),\n ),\n ])\n })\n })\n // When it shows: an `eq` condition per context key, blank for always. Other\n // conditions on a key are kept as they are.\n const when = Array.isArray(node.when) ? node.when : []\n const isEqOn = (key: string) => (condition: Schema.Json) =>\n isChoices(condition) && Array.isArray(condition['eq']) && condition['eq'][0] === key\n const eqOf = (key: string): Option.Option<ContextValue> => {\n for (const condition of when)\n if (isChoices(condition) && isEqOn(key)(condition) && Array.isArray(condition['eq'])) {\n const value = condition['eq'][1]\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n )\n return Option.some(value)\n }\n return Option.none()\n }\n const conditions = Object.entries(fieldsOf(builder.catalog.context)).map(([key, schema]) =>\n contextField(slots, h, {\n id: `${builder.name}-${id}-when-${key}`,\n label: say(w.shownWhen, { key }),\n schema,\n current: eqOf(key),\n blank: w.always,\n send: value => {\n const others = when.filter(condition => !isEqOn(key)(condition))\n const next = Option.match(value, {\n onNone: () => others,\n onSome: chosen => [...others, { eq: [key, chosen] }],\n })\n return Message.Applied({\n op: Composition.Op.setWhen(id, next.length === 0 ? null : next),\n })\n },\n }),\n )\n // What each of the Block's events runs: an action the Catalog offers, blank for\n // none, then that action's input, one field each.\n const stored = isChoices(node.actions) ? node.actions : {}\n const events = block.events.flatMap(event => {\n const reference = stored[event]\n const ref = isChoices(reference) ? reference : {}\n const run = (name: string, given: { readonly [key: string]: Schema.Json }): Message =>\n Message.Applied({\n op: Composition.Op.setAction(id, event, { action: name, input: given }),\n })\n const pickId = `${builder.name}-${id}-on-${event}`\n const pick = h.div(slots.field.attrs(), [\n h.label(slots.label.attrs([h.For(pickId)]), [say(w.onEvent, { event })]),\n h.select(\n slots.control.attrs([\n h.Id(pickId),\n h.OnChange(name => {\n const chosen = builder.catalog.actions.find(each => each.name === name)\n return chosen === undefined\n ? Message.Applied({ op: Composition.Op.setAction(id, event, null) })\n : run(chosen.name, inputOf(block, event, chosen).seed())\n }),\n ]),\n optionsOf(h, slots.selectOption, {\n blank: w.runsNothing,\n choices: named(builder.catalog.actions.map(each => each.name)),\n current: typeof ref['action'] === 'string' ? ref['action'] : undefined,\n }),\n ),\n ])\n // The chosen action's input, its own form; an action the Catalog lacks has none.\n const input = Option.match(\n Option.flatMap(inspecting, target =>\n Option.map(Option.fromUndefinedOr(target.on[event]), form => ({ target, form })),\n ),\n {\n onNone: () => [],\n onSome: ({ target, form }) => [\n drawForm(target, form, `on-${event}`, { submits: false, words: { none: w.none } }),\n ],\n },\n )\n return [pick, ...input]\n })\n return h.div(slots.inspector.attrs([h.Role('group'), h.AriaLabel(w.properties)]), [\n head,\n ...section(w.content, fields),\n ...section(w.style, looks),\n ...section(w.visibility, conditions),\n ...section(w.interactions, events),\n ])\n }\n\n const shortcuts = ({\n input,\n h,\n }: {\n readonly input: Pick<BuilderInput, 'page' | 'selected' | 'editing'>\n readonly h: HtmlBuilder<Message>\n }) => [h.OnKeyDownPreventDefault((key, modifiers) => builder.keyPressed(input, key, modifiers))]\n\n /**\n * A button, disabled where there is nothing to send: by `aria-disabled`, so\n * it keeps focus when what it did (the last undo) leaves it nothing to do.\n */\n const button = (\n h: HtmlBuilder<Message>,\n slot: SlotView.SlotBuilder<Message>,\n label: string,\n message: Option.Option<Message>,\n extra: ReadonlyArray<Attribute<Message>> = [],\n ) =>\n h.button(\n slot.attrs([\n h.Type('button'),\n ...Option.match(message, {\n onNone: () => [h.AriaDisabled(true)],\n onSome: sent => [h.OnClick(sent)],\n }),\n ...extra,\n ]),\n [label],\n )\n\n /** A command as a button: disabled while it has nothing to do, titled with its first key. */\n const commandButton = (\n h: HtmlBuilder<Message>,\n slot: SlotView.SlotBuilder<Message>,\n command: BuilderCommand,\n input: Pick<BuilderInput, 'page' | 'selected' | 'platform' | 'words'>,\n ) => {\n const [key] = command.keys\n const w = wordsOf(input.words)\n return button(h, slot, command.label, command.run(input), [\n h.DataAttribute('action', command.id),\n h.Title(\n key === undefined\n ? command.label\n : say(w.withKeys, { label: command.label, keys: keysOf(key, input.platform, w) }),\n ),\n ])\n }\n\n const labelAt = (document: Document, id: NodeId): string =>\n Option.match(Option.fromUndefinedOr(document.nodes[id]), {\n onNone: () => id,\n onSome: node => labelOf(node.block),\n })\n // Where an insert lands, said on the Block's button, from the place itself.\n const whereItGoes = (\n document: Document,\n selected: Option.Option<NodeId>,\n at: Option.Option<Position>,\n w: BuilderWords,\n ): string =>\n Option.match(at, {\n onNone: () =>\n Option.match(selected, {\n onNone: () => w.nothingHoldsIt,\n onSome: id => say(w.cannotGoAt, { label: labelAt(document, id) }),\n }),\n onSome: position => {\n if (position._tag === 'Root') {\n // `placeFor` puts a root after the selected one, or last: never first before others.\n const before = document.roots[position.index - 1]\n return position.index === document.roots.length || before === undefined\n ? w.addsToEnd\n : say(w.addsAfter, { label: labelAt(document, before) })\n }\n const before =\n document.nodes[position.parent]?.regions[position.region]?.[position.index - 1]\n return Option.contains(selected, position.parent) || before === undefined\n ? say(w.addsInside, { label: labelAt(document, position.parent) })\n : say(w.addsAfter, { label: labelAt(document, before) })\n },\n })\n // A drop is marked only where it would land: `at` is none where the page refuses it.\n const dropOf = (drag: Model['drag']) =>\n Option.flatMap(drag, each => (Option.isSome(each.at) ? each.over : Option.none()))\n\n // The shortcuts, on the layers and on the canvas; each part draws one of the two.\n const Shortcuts = Behavior.forSlots(BuilderSlots)<\n Pick<BuilderInput, 'page' | 'selected' | 'editing'>,\n Message\n >(\n {\n layers: Behavior.slot({ attributes: shortcuts }),\n canvas: Behavior.slot({ attributes: shortcuts }),\n },\n { name: 'BuilderShortcuts' },\n )\n // What is selected, however it was (a click, a shortcut, an insert, the\n // address), is brought into view in the layers and on the canvas.\n const KeepSelectionInView = Behavior.forSlots(BuilderSlots)<Pick<BuilderInput, never>, Message>(\n {\n layers: Behavior.slot({\n mount: () => KeepInView({ selector: '[role=\"treeitem\"][aria-selected=\"true\"]' }),\n }),\n canvas: Behavior.slot({\n // The mark is on a `display: contents` wrapper, which has no box: the Block's own element does.\n mount: () => KeepInView({ selector: `[data-${MARK_ATTRIBUTE}=\"selected\"] > *` }),\n }),\n },\n { name: 'KeepSelectionInView' },\n )\n\n // The canvas, found by its id, so a tile dragged from the palette can land on its nodes.\n const canvasId = `${builder.name}-canvas`\n\n // Each panel's element: its id, for its tab to name, and whether its tab is chosen.\n const panelId = (panel: string) => `${builder.name}-panel-${panel}`\n const panelMarks = (\n panel: (typeof PANELS)[number][0],\n slot: 'palette' | 'layers' | 'inspector',\n ) =>\n Behavior.forSlots(BuilderSlots)<Pick<BuilderInput, 'panel'>, Message>(\n {\n [slot]: Behavior.slot({\n attributes: ({ input, h }) => [\n h.Id(panelId(panel)),\n h.DataAttribute('panel', panel),\n h.DataAttribute('panel-shown', String(input.panel === panel)),\n ],\n }),\n // Keyed by the panel's slot, which `forSlots` checks exists.\n } as unknown as Behavior.BehaviorSpec<\n typeof BuilderSlots,\n Pick<BuilderInput, 'panel'>,\n Message\n >,\n { name: `BuilderPanel-${panel}` },\n )\n\n const Panels = Parts.part('Panels', { reads: ['panel', 'words'] }, (input, slots, h) => {\n const w = wordsOf(input.words)\n return h.div(\n // A group of pressed buttons, as the viewports are: ARIA tabs would promise\n // arrow keys and a roving tab stop.\n slots.panelTabs.attrs([h.Role('group'), h.AriaLabel(w.panels)]),\n PANELS.map(([panel, label]) =>\n h.button(\n slots.panelTab.attrs([\n h.Type('button'),\n h.AriaPressed(input.panel === panel ? 'true' : 'false'),\n h.AriaControls(panelId(panel)),\n h.DataAttribute('panel', panel),\n h.OnClick(Message.PanelChosen({ panel })),\n ]),\n [w[label]],\n ),\n ),\n )\n })\n\n const Palette = Parts.part(\n 'Palette',\n {\n reads: ['page', 'selected', 'panel', 'words'],\n behaviors: [\n panelMarks('insert', 'palette'),\n // A tile dragged onto the page adds its Block where it is dropped; a press adds it\n // where the palette's button says.\n PointerDrag.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'palette',\n attribute: 'data-block',\n // Its own canvas, found from the palette, whatever the Builder's name holds.\n targets: { attribute: `data-${NODE_ATTRIBUTE}`, within: '[data-builder-canvas]' },\n part: `data-${REGION_ATTRIBUTE}`,\n toMessage: tileDrag,\n }),\n ],\n },\n (input, slots, h) => {\n const document = builder.document(input)\n const w = wordsOf(input.words)\n /** A tile: what it adds, said, where a press adds it, and the Message that asks. */\n const tile = (item: {\n readonly data: readonly [name: 'block' | 'pattern', value: string]\n readonly label: string\n readonly hint: Option.Option<string>\n readonly at: Option.Option<Position>\n readonly asked: (at: Position) => Message\n }) =>\n h.button(\n slots.paletteItem.attrs([\n h.Type('button'),\n h.DataAttribute(...item.data),\n h.AriaLabel(say(w.addBlock, { label: item.label })),\n h.Title(whereItGoes(document, input.selected, item.at, w)),\n // As a command's button: it keeps focus when its place fills up.\n ...Option.match(item.at, {\n onNone: () => [h.AriaDisabled(true)],\n onSome: position => [h.OnClick(item.asked(position))],\n }),\n ]),\n [\n h.span(slots.paletteLabel.attrs(), [item.label]),\n ...Option.match(item.hint, {\n onNone: () => [],\n onSome: hint => [h.span(slots.paletteHint.attrs(), [hint])],\n }),\n ],\n )\n const group = (name: string, tiles: ReadonlyArray<Html>) =>\n h.div(slots.paletteGroup.attrs([h.Role('group'), h.AriaLabel(name)]), [\n ...(headed ? [h.h3(slots.paletteHeading.attrs(), [name])] : []),\n ...tiles,\n ])\n return h.nav(slots.palette.attrs([h.AriaLabel(w.palette)]), [\n ...groups.map(({ group: named, names: blocks }) =>\n group(\n Option.getOrElse(named, () => w.ungrouped),\n blocks.map(block =>\n tile({\n data: ['block', block],\n label: labelOf(block),\n hint: described.get(block)?.description ?? Option.none(),\n at: builder.placeFor(document, input.selected, block),\n asked: at => Message.InsertAsked({ block, at }),\n }),\n ),\n ),\n ),\n ...(patterns.length === 0\n ? []\n : [\n group(\n w.patterns,\n patterns.map(pattern =>\n tile({\n data: ['pattern', pattern.name],\n label: pattern.words.label,\n hint: pattern.words.description,\n at: builder.patternAt(document, input.selected, pattern.name),\n asked: at => Message.PatternAsked({ pattern: pattern.name, at }),\n }),\n ),\n ),\n ]),\n ])\n },\n )\n\n /**\n * One layer row, from what it shows alone. Its arguments are compared by\n * identity, so an absent node or drop arrives as `undefined`, not as an\n * `Option`, which would be a new value on every draw.\n */\n const drawRow = (\n slots: SlotView.SlotBuilders<typeof BuilderSlots, Message>,\n h: HtmlBuilder<Message>,\n {\n index,\n id,\n branch,\n node,\n selected,\n drop,\n dragged,\n }: {\n readonly index: number\n readonly id: string\n readonly branch: boolean\n readonly node: Document['nodes'][NodeId] | undefined\n // Unread here: the row's Behavior draws it, and as an argument it redraws a toggled row.\n readonly open: boolean\n readonly selected: boolean\n readonly drop: DropZone | undefined\n readonly dragged: boolean\n },\n ): Html =>\n h.li(\n slots.row.attrs(\n [\n h.Key(id),\n h.DataAttribute(ROW_ATTRIBUTE, id),\n ...(node === undefined ? [] : [h.DataAttribute('block', node.block)]),\n ...(drop === undefined ? [] : [h.DataAttribute(ROW_DROP_ATTRIBUTE, drop)]),\n ...(dragged ? [h.DataAttribute(ROW_DRAGGING_ATTRIBUTE, '')] : []),\n h.AriaSelected(selected),\n // Made current, as the keys make a row: it selects the node and keeps the\n // layers showing, where `Selected` would switch a narrow editor to Settings.\n h.OnClick(Message.RowPressed({ id: NodeId.make(id) })),\n // Pointing at a row marks its node on the page, as pointing at the page does.\n h.OnMouseEnter(Message.Hovered({ id: NodeId.make(id) })),\n h.OnMouseLeave(Message.Unhovered()),\n ],\n { index, id },\n ),\n [\n ...(branch\n ? [\n h.span(\n slots.rowToggle.attrs([\n // The row says whether it is open; this is the pointer's way to change it.\n h.AriaHidden(true),\n h.OnClick(Message.RowToggled({ id: NodeId.make(id) })),\n ]),\n [],\n ),\n ]\n : []),\n h.span(slots.rowLabel.attrs(), [node === undefined ? id : labelOf(node.block)]),\n ...Option.match(node === undefined ? Option.none() : summaryOf(node), {\n onNone: () => [],\n onSome: summary => [h.span(slots.rowSummary.attrs(), [summary])],\n }),\n ],\n )\n\n // Where the selected and the hovered node are, for the boxes drawn over them.\n const MeasureMarks = Behavior.forSlots(BuilderSlots)<Pick<BuilderInput, never>, Message>(\n {\n canvas: Behavior.slot({\n mount: () =>\n Measure({\n targets: {\n // The mark is on a `display: contents` wrapper, which has no box: its Block's element does.\n selected: `[data-${MARK_ATTRIBUTE}=\"selected\"] > *`,\n hovered: `[data-${MARK_ATTRIBUTE}=\"hovered\"] > *`,\n },\n }),\n }),\n },\n { name: 'MeasureMarks' },\n )\n\n const LayersPart = Parts.part(\n 'Layers',\n {\n reads: ['page', 'selected', 'layers', 'drag', 'editing', 'panel', 'words'],\n behaviors: [\n panelMarks('layers', 'layers'),\n TreeNavigation.behavior(Layers, layersArgs)(BuilderSlots)<\n Pick<BuilderInput, 'page' | 'selected' | 'layers' | 'drag'>,\n Message\n >({\n container: 'tree',\n item: 'row',\n rows: input => rowsOf(builder.document(input)),\n domId: id => layerId(builder, id),\n }),\n // A row is dragged onto another; the keyboard's way is the shortcuts.\n PointerDrag.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'tree',\n attribute: `data-${ROW_ATTRIBUTE}`,\n toMessage: nodeDrag,\n }),\n Shortcuts,\n KeepSelectionInView,\n ],\n },\n (input, slots, h) => {\n const document = builder.document(input)\n const { selected } = input\n const drop = dropOf(input.drag)\n const dragged = Option.flatMap(input.drag, drag =>\n Match.valueTags(drag.source, {\n Existing: ({ id }) => Option.some(id),\n New: () => Option.none(),\n }),\n )\n const shown = TreeNavigation.shown(rowsOf(document), input.layers, layersArgs)\n const tree = h.ul(\n slots.tree.attrs([h.Role('tree'), h.AriaLabel(wordsOf(input.words).layers)]),\n // Each row drawn again only when what it shows changed: a new selection\n // redraws the row it left and the row it reached.\n shown.map((row, index) =>\n slots.row.lazy({ index, id: row.id }, drawRow, {\n index,\n id: row.id,\n branch: row.branch,\n node: document.nodes[NodeId.make(row.id)],\n open: TreeNavigation.isOpen(input.layers, layersArgs, row.id),\n selected: Option.contains(selected, NodeId.make(row.id)),\n drop: Option.getOrUndefined(\n Option.map(\n Option.filter(drop, over => over.id === row.id),\n over => over.zone,\n ),\n ),\n dragged: Option.contains(dragged, NodeId.make(row.id)),\n }),\n ),\n )\n // The tree inside is what is named \"Layers\"; the panel around it is not named twice.\n return h.section(slots.layers.attrs(), [tree])\n },\n )\n\n const Inspector = Parts.part(\n 'Inspector',\n {\n reads: ['page', 'selected', 'options', 'inspector', 'platform', 'panel', 'words'],\n behaviors: [panelMarks('properties', 'inspector')],\n },\n (input, slots, h) => {\n const w = wordsOf(input.words)\n const actions = h.div(\n slots.actions.attrs([h.Role('toolbar'), h.AriaLabel(w.selectedBlock)]),\n builder.commands\n .filter(command => command.placement.includes('node'))\n .map(command => commandButton(h, slots.action, command, input)),\n )\n return Option.match(input.selected, {\n onNone: () =>\n h.div(slots.inspector.attrs([h.Role('group'), h.AriaLabel(w.properties)]), [\n h.p(slots.inspectorHint.attrs(), [w.selectToChange]),\n h.h3(slots.inspectorSectionTitle.attrs(), [w.shortcuts]),\n h.dl(\n slots.shortcuts.attrs(),\n [\n ...TREE_KEYS.map(([keys, what]) => [keys, w[what]] as const),\n ...builder.commands.flatMap(command => {\n const [key] = command.keys\n return key === undefined\n ? []\n : [[keysOf(key, input.platform, w), command.label] as const]\n }),\n ].flatMap(([keys, what]) => [\n h.dt(slots.shortcutKeys.attrs(), [keys]),\n h.dd(slots.shortcutWhat.attrs(), [what]),\n ]),\n ),\n ]),\n onSome: id =>\n inspect(\n builder.document(input),\n id,\n input.options ?? {},\n actions,\n builder.inspecting(input),\n slots,\n h,\n w,\n ),\n })\n },\n )\n\n const Toolbar = Parts.part(\n 'Toolbar',\n { reads: ['page', 'selected', 'platform', 'words'] },\n (input, slots, h) =>\n h.div(\n slots.toolbar.attrs([h.Role('toolbar'), h.AriaLabel(wordsOf(input.words).pageActions)]),\n builder.commands\n .filter(command => command.placement.includes('toolbar'))\n .map(command => commandButton(h, slots.toolbarAction, command, input)),\n ),\n )\n\n const Crumbs = Parts.part(\n 'Crumbs',\n { reads: ['page', 'selected', 'words'] },\n (input, slots, h) => {\n const document = builder.document(input)\n const w = wordsOf(input.words)\n // The page, then each node from the top down to the selected one, which is where you are.\n const holders = (id: NodeId): ReadonlyArray<NodeId> => {\n const places = Composition.index(document)\n const chain: Array<NodeId> = [id]\n for (\n let place = places.get(id);\n place?.parent !== undefined;\n place = places.get(place.parent)\n )\n chain.unshift(place.parent)\n return chain\n }\n const trail = Option.match(input.selected, { onNone: () => [], onSome: holders })\n return h.nav(slots.crumbs.attrs([h.AriaLabel(w.crumbs)]), [\n h.button(\n slots.crumb.attrs([\n h.Type('button'),\n h.OnClick(Message.Deselected()),\n ...(trail.length === 0 ? [h.AriaCurrent('location')] : []),\n ]),\n [w.crumbPage],\n ),\n ...trail.map((id, index) =>\n h.button(\n slots.crumb.attrs([\n h.Type('button'),\n h.OnClick(Message.Selected({ id })),\n ...(index === trail.length - 1 ? [h.AriaCurrent('location')] : []),\n ]),\n [labelAt(document, id)],\n ),\n ),\n ])\n },\n )\n\n const Viewports = Parts.part('Viewports', { reads: ['viewport', 'words'] }, (input, slots, h) =>\n h.div(\n slots.viewports.attrs([h.Role('group'), h.AriaLabel(wordsOf(input.words).viewports)]),\n (['wide', 'medium', 'narrow'] as const).map(viewport =>\n button(\n h,\n slots.viewport,\n wordsOf(input.words)[viewport],\n Option.some(Message.ViewportChosen({ viewport })),\n [\n h.DataAttribute('viewport', viewport),\n h.AriaPressed(input.viewport === viewport ? 'true' : 'false'),\n ],\n ),\n ),\n ),\n )\n\n const context = fieldsOf(builder.catalog.context)\n // Nothing where the Catalog has no context to preview.\n const Preview = Parts.part('Preview', { reads: ['preview', 'words'] }, (input, slots, h) =>\n Object.keys(context).length === 0\n ? null\n : h.div(\n slots.preview.attrs([h.Role('group'), h.AriaLabel(wordsOf(input.words).previewAs)]),\n Object.entries(context).map(([key, schema]) =>\n contextField(slots, h, {\n id: `${builder.name}-preview-${key}`,\n label: key,\n schema,\n current: Option.fromUndefinedOr(input.preview[key]),\n blank: wordsOf(input.words).unset,\n send: value =>\n Option.match(value, {\n onNone: () => Message.PreviewCleared({ key }),\n onSome: chosen => Message.PreviewChosen({ key, value: chosen }),\n }),\n }),\n ),\n ),\n )\n\n const Alert = Parts.part('Alert', { reads: ['refused'] }, (input, slots, h) =>\n Option.match(input.refused, {\n onNone: () => null,\n onSome: refused => h.p(slots.alert.attrs([h.Role('alert')]), [refused.message]),\n }),\n )\n\n // Focusable, so a press on the page leaves the shortcuts where the selection is.\n const Canvas = Parts.part(\n 'Canvas',\n {\n reads: [\n 'page',\n 'selected',\n 'hovered',\n 'drag',\n 'viewport',\n 'preview',\n 'data',\n 'editing',\n 'words',\n ],\n behaviors: [\n Targets.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'canvas',\n attribute: `data-${NODE_ATTRIBUTE}`,\n // A link on the page being edited selects its node; it does not navigate.\n preventDefault: true,\n toMessage: fact =>\n Match.valueTags(fact, {\n TargetHovered: ({ id }) =>\n Option.match(asNodeId(id), {\n onNone: () => Message.Unhovered(),\n onSome: node => Message.Hovered({ id: node }),\n }),\n TargetPressed: ({ id }) =>\n Option.match(asNodeId(id), {\n onNone: () => Message.Deselected(),\n onSome: node => Message.Selected({ id: node }),\n }),\n }),\n }),\n // A node is dragged onto another; the keyboard's way is the shortcuts.\n PointerDrag.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'canvas',\n attribute: `data-${NODE_ATTRIBUTE}`,\n part: `data-${REGION_ATTRIBUTE}`,\n toMessage: nodeDrag,\n }),\n // Text on the page, edited where it is: the Builder checks which field each names.\n EditableText.behavior(BuilderSlots)<Pick<BuilderInput, never>, Message>({\n container: 'canvas',\n attribute: `data-${FIELD_ATTRIBUTE}`,\n toMessage: fact => {\n switch (fact._tag) {\n case 'EditAsked':\n return Message.EditingAsked({ field: fact.field })\n case 'TextEdited':\n return Message.FieldTyped({ field: fact.field, text: fact.text })\n case 'TextCommitted':\n return Message.EditingCommitted({ field: fact.field, text: fact.text })\n case 'TextCancelled':\n return Message.EditingCancelled({ field: fact.field })\n }\n },\n }),\n Shortcuts,\n KeepSelectionInView,\n MeasureMarks,\n ],\n },\n (input, slots, h) => {\n const document = builder.document(input)\n // The selected node's Block, named on its box.\n const selectedBlock = Option.flatMap(input.selected, id =>\n Option.fromUndefinedOr(document.nodes[id]?.block),\n )\n return h.div(\n slots.canvas.attrs([\n h.Id(canvasId),\n h.DataAttribute('builder-canvas', ''),\n h.Role('region'),\n h.AriaLabel(wordsOf(input.words).canvas),\n h.Tabindex(0),\n ]),\n [\n h.div(\n slots.frame.attrs([\n h.DataAttribute('viewport', input.viewport),\n // The width is the frame's own; the rule that reads it is `FrameDefaults`.\n h.Style({ '--fk-frame-width': viewportWidths[input.viewport] }),\n ]),\n [\n ...(document.roots.length === 0\n ? [h.p(slots.empty.attrs(), [wordsOf(input.words).emptyPage])]\n : []),\n ...Renderer.render(builder.renderer, document, inertHtml, {\n mode: 'edit',\n selected: input.selected,\n hovered: input.hovered,\n drop: dropOf(input.drag),\n context: input.preview,\n data: input.data,\n editing: input.editing,\n }),\n ],\n ),\n // Drawn over the page, placed from where the marked nodes are measured to be;\n // hidden while none is. They only show: they take no pointer.\n h.div(slots.hoverBox.attrs([h.AriaHidden(true)]), []),\n h.div(\n slots.selectionBox.attrs([h.AriaHidden(true)]),\n Option.match(selectedBlock, {\n onNone: () => [],\n onSome: name => [h.span(slots.selectionLabel.attrs(), [labelOf(name)])],\n }),\n ),\n ],\n )\n },\n )\n\n const Live = Parts.part('Live', { reads: ['announcer'] }, (input, slots, h) =>\n h.div(slots.live.attrs(), [LiveAnnounce.view(input.announcer, h)]),\n )\n\n return {\n Panels,\n Palette,\n Layers: LayersPart,\n Inspector,\n Toolbar,\n Crumbs,\n Viewports,\n Preview,\n Alert,\n Canvas,\n Live,\n }\n },\n\n /**\n * A layout of your own: `render` places the parts with `draw`, around\n * anything else you draw with its `h`. Styles and Behaviors attach to the\n * result as to `define`'s.\n */\n assemble: (\n render: SlotView.AssemblyRender<typeof BuilderSlots, BuilderInput, Message>,\n ): BuilderSlotView =>\n Parts.assemble(render, { name: 'Builder' }).pipe(Style.attach(FrameDefaults)),\n\n /**\n * The narrow layout, below `width` of the Builder itself (its root is the\n * container `builder`): the panels' tabs show, and only the panel the\n * Builder's `panel` names; selecting a node chooses Settings.\n * In the `app` layer by default, so it outranks an application's own\n * placing of the panels; pass `layer` to put it elsewhere.\n */\n narrow: (width: string, options: { readonly layer?: Placement } = {}) => {\n const narrower = `@container builder (max-width: ${width})`\n const hidden = Style.at(\n narrower,\n Style.pseudo('[data-panel-shown=\"false\"]', { display: 'none' }),\n )\n return Style.forSlots(BuilderSlots)(\n {\n panelTabs: Style.at(narrower, Style.self({ display: 'flex' })),\n palette: hidden,\n layers: hidden,\n inspector: hidden,\n },\n {\n name: 'BuilderNarrow',\n layer: options.layer ?? StyleLayers.standard.layer('app'),\n },\n )\n },\n\n /** The Builder drawn with every part, in the default layout. */\n define: (\n builder: BuilderLike,\n options: {\n /** How the inspector's settings forms look. */\n readonly settings?: SettingsLook\n } = {},\n ): BuilderSlotView => {\n const parts = BuilderView.parts(builder, options)\n // Four regions, so a new panel lands in one without moving the layout around it.\n return BuilderView.assemble((_input, slots, h, draw) =>\n h.div(slots.root.attrs(), [\n draw(parts.Panels),\n h.div(slots.regions.attrs(), [\n h.div(slots.start.attrs(), [draw(parts.Palette), draw(parts.Layers)]),\n h.div(slots.bar.attrs(), [\n draw(parts.Toolbar),\n draw(parts.Crumbs),\n draw(parts.Viewports),\n draw(parts.Preview),\n ]),\n h.div(slots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der",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "The page builder drawn as accessible HTML through foldkit-mixins slots: a palette, a keyboard-driven layers tree, an inspector, and the page in edit mode.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -42,13 +42,13 @@
42
42
  "foldkit": "^0.170.0"
43
43
  },
44
44
  "dependencies": {
45
- "foldkit-composition": "0.6.0",
46
- "foldkit-entity": "0.16.0",
47
- "foldkit-form": "0.11.0",
48
- "foldkit-mixins": "0.23.0",
49
- "foldkit-primitives": "0.18.0",
50
- "foldkit-builder": "0.6.0",
51
- "foldkit-mixins-form": "0.13.0"
45
+ "foldkit-builder": "0.7.0",
46
+ "foldkit-composition": "0.7.0",
47
+ "foldkit-entity": "0.17.0",
48
+ "foldkit-form": "0.12.0",
49
+ "foldkit-mixins": "0.24.0",
50
+ "foldkit-mixins-form": "0.14.0",
51
+ "foldkit-primitives": "0.19.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "effect": "^4.1.1",
@@ -56,7 +56,7 @@
56
56
  "jsdom": "30.1.3",
57
57
  "tsdown": "^0.23.1",
58
58
  "typescript": "7.0.2",
59
- "foldkit-bundle": "0.11.0"
59
+ "foldkit-bundle": "0.12.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "node ../../scripts/declarations.mjs . && tsdown && node ../../scripts/declared-any.mjs .",