@formancy/report-builder-angular 0.1.0 → 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"formancy-report-builder-angular.mjs","names":["i1.ReportEditorRoot"],"sources":["../../src/editor-state.ts","../../src/root.ts","../../src/canvas.ts","../../src/outline.ts","../../src/palette.ts","../../src/places.ts","../../src/problems.ts","../../src/properties.ts","../../src/status.ts","../../src/toolbar.ts","../../src/builder.ts"],"sourcesContent":["/**\n * An editor's state as a signal: the one place this package listens to\n * report-builder-core.\n *\n * The editor's `state()` is a frozen object that stays the same until\n * something changes, and `subscribe` says when it has. That is all a signal\n * needs, so this is a signal set on each notification, rather than an\n * Observable turned into one: nothing here is a stream, and `toSignal` would\n * add RxJS to every builder for the sake of one callback. An OnPush view\n * reading the signal is marked for check when it is set, and zoneless\n * change detection renders it; nothing else schedules a render.\n */\nimport { effect, linkedSignal } from '@angular/core'\nimport type { Signal } from '@angular/core'\nimport type { EditorState, ReportEditor } from '@formancy/report-builder-core'\n\n/**\n * The state of the editor `editor` names, for as long as the view that\n * called this lives. Call it in an injection context: a field initialiser\n * or a constructor.\n *\n * When `editor` names another editor, the signal is that editor's state at\n * once, and the old editor is let go (plan 21's \"replacing the session\n * input\"). The subscription is an effect's, and its cleanup unsubscribes: on\n * the next editor, and when the view's `DestroyRef` ends the effect, so a\n * destroyed builder leaves no listener behind on an editor that outlives it.\n */\nexport function injectEditorState(editor: Signal<ReportEditor>): Signal<EditorState> {\n // Read from the editor the input names whenever it names another, so the\n // first render needs no subscription to be right.\n const state = linkedSignal(() => editor().state())\n effect((onCleanup) => {\n const following = editor()\n onCleanup(following.subscribe(() => state.set(following.state())))\n // Whatever changed between the read above and the subscription.\n state.set(following.state())\n })\n return state.asReadonly()\n}\n","/**\n * The editor's root: the element every part of the builder stands in, and\n * the one object the parts share.\n *\n * It holds the editor's state as a signal, the editor's words, and the\n * three things only the root can do: route a key press to the action it\n * asks for, dispatch an action, and put focus where the action left the\n * person. The parts inject it, as a form control injects its form. What any\n * of it means is report-builder-core's: which key does what (`actionForKey`),\n * what is selected, where a component may go. This decides only where focus\n * goes in this DOM.\n */\nimport { afterEveryRender, computed, Directive, ElementRef, inject, input } from '@angular/core'\nimport { actionForKey, editorText } from '@formancy/report-builder-core'\nimport type { DragSubject, DropTarget, EditorAction, EditorOutcome, EditorPanel, EditorText, KeyScope, ReportEditor } from '@formancy/report-builder-core'\nimport { injectEditorState } from './editor-state'\n\n/** Where focus goes once what an action changed has rendered. */\nexport type FocusAfter =\n /** The selected outline row, which focus follows (the tree pattern); the tree itself when nothing is selected. */\n | { readonly to: 'selection' }\n /** The first place in the place chooser that has just opened, or its Cancel when there is none. */\n | { readonly to: 'places' }\n /** Back to the element that opened the place chooser. */\n | { readonly to: 'element'; readonly element: HTMLElement }\n /** Into a pane a narrow screen has just shown: its tree, its view, its first field or its list. */\n | { readonly to: 'pane'; readonly panel: EditorPanel }\n\nlet roots = 0\n\n/** Inputs whose own keys win: typing, and a select's arrows. Ctrl+Z in one undoes typing, not the report. */\nfunction keepsItsKeys(element: Element): boolean {\n if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) return true\n if (element instanceof HTMLInputElement) return !['checkbox', 'radio', 'button', 'submit', 'reset'].includes(element.type)\n return element instanceof HTMLElement && element.isContentEditable\n}\n\n/**\n * What focus lands on in each pane, the first of these that is there: the\n * selected outline row, else the tree's one tab stop, else the tree itself;\n * the design view; the first field; the problems' list.\n */\nconst PANE_FOCUS: Readonly<Record<EditorPanel, readonly string[]>> = {\n outline: ['[role=\"treeitem\"][aria-selected=\"true\"]', '[role=\"treeitem\"][tabindex=\"0\"]', '[role=\"tree\"]'],\n canvas: ['[data-report-part=\"canvas\"]'],\n properties: ['[data-report-part=\"properties\"] :is(input, select, textarea)'],\n diagnostics: ['[data-report-part=\"diagnostics\"]'],\n}\n\n/**\n * Where focus goes after an action in the outline: the selected row, else\n * the tree itself -- never the first row, which focus would select, so that\n * after an undo that leaves nothing selected the next Delete deletes nothing\n * the person did not choose.\n */\nconst SELECTION_FOCUS: readonly string[] = ['[role=\"treeitem\"][aria-selected=\"true\"]', '[role=\"tree\"]']\n\n@Directive({\n selector: '[reportEditor]',\n host: {\n role: 'region',\n 'data-report-part': 'editor',\n class: 'wb',\n '[attr.aria-label]': 't()(\"editor.label\")',\n '[attr.data-panel]': 'state().panel',\n '(keydown)': 'keydown($event)',\n },\n})\nexport class ReportEditorRoot {\n /** The editor this builder renders and acts on. Several builders may share one; each is told of the others' edits. */\n readonly editor = input.required<ReportEditor>({ alias: 'reportEditor' })\n readonly state = injectEditorState(this.editor)\n /** The editor's own words, in the editor's language. */\n readonly t = computed<EditorText>(() => editorText(this.state().locale))\n /** Unique on the page, so the ids tying a label or a description to its control are too. */\n readonly id = `report-editor-${String((roots += 1))}`\n /** The sentence beside an outline with no row, which describes the empty tree. */\n readonly outlineEmpty = `${this.id}-outline-empty`\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef)\n private focusAfter: FocusAfter | null = null\n /** What opened the place chooser, for focus to go back to when it is cancelled. */\n private opener: HTMLElement | null = null\n\n constructor() {\n afterEveryRender(() => this.moveFocus())\n }\n\n /**\n * Sends `action` to the editor, and moves focus as `focus` says once\n * what it changed has rendered. Every action comes from a listener of this\n * builder's, and a listener marks its view for check, so a render follows\n * even an action that changed nothing: the focus never waits for whatever\n * renders next.\n */\n dispatch(action: EditorAction, focus?: FocusAfter): EditorOutcome {\n if (focus !== undefined) this.focusAfter = focus\n return this.editor().dispatch(action)\n }\n\n /**\n * Opens the place chooser for `subject`, remembering `opener` to come back\n * to. It floats over the outline pane, so that is the pane a narrow screen\n * shows while it is open.\n */\n choosePlace(subject: DragSubject, opener: HTMLElement): void {\n this.opener = opener\n const outcome = this.dispatch({ type: 'startDrag', subject, via: 'keyboard' }, { to: 'places' })\n // Refused -- an image with nothing to draw -- and announced; there is no chooser to come back from.\n if (outcome.ok) this.dispatch({ type: 'openPanel', panel: 'outline' })\n else this.opener = null\n }\n\n /** Puts `subject` at `target`: an insert or a move, never a second copy of either. */\n place(subject: DragSubject, target: DropTarget): void {\n this.opener = null\n this.dispatch('kind' in subject ? { type: 'insert', kind: subject.kind, target: target.location } : { type: 'move', id: subject.id, target: target.location }, { to: 'selection' })\n }\n\n /**\n * Starts a pointer's drag of `subject`. One the editor refuses -- a kind\n * the report cannot hold yet -- is announced, and not picked up at all.\n */\n pickUp(event: DragEvent, subject: DragSubject, label: string): void {\n // Firefox starts no drag without data. What is dragged is the editor's to know; this is a name for it.\n event.dataTransfer?.setData('text/plain', label)\n if (!this.dispatch({ type: 'startDrag', subject, via: 'pointer' }).ok) event.preventDefault()\n }\n\n /** Drops what a pointer drags on the place it is over; focus follows to what was placed, as after the keyboard's choice. */\n putDown(event: DragEvent): void {\n if (this.state().drag?.via !== 'pointer') return\n event.preventDefault()\n this.dispatch({ type: 'drop' }, { to: 'selection' })\n }\n\n /**\n * Ends a drag without placing anything. A keyboard's goes back to what\n * opened the chooser (the dialog pattern); a pointer's leaves focus where\n * it is, because a pointer never moved it.\n */\n cancelPlacing(): void {\n const keyboard = this.state().drag?.via === 'keyboard'\n const back = this.opener ?? (keyboard ? this.placedFrom() : null)\n this.opener = null\n this.dispatch({ type: 'cancelDrag' }, back === null ? undefined : { to: 'element', element: back })\n }\n\n /**\n * Where a keyboard's chooser goes back to when this builder did not open\n * it -- the drag is the editor's and outlives a builder, so a Studio that\n * switches frameworks draws it here: the palette entry of what is being\n * placed, else the selected outline row, else the tree. Never nothing,\n * which would leave the keyboard on the page.\n */\n private placedFrom(): HTMLElement | null {\n const subject = this.state().drag?.subject\n const root = this.host.nativeElement\n const entry = subject !== undefined && 'kind' in subject ? root.querySelector<HTMLElement>(`[data-report-part=\"palette-item\"][data-kind=\"${subject.kind}\"]`) : null\n return entry ?? root.querySelector<HTMLElement>(SELECTION_FOCUS.join(', '))\n }\n\n /** A pointer's drag let go of anywhere but a place: it ends, and nothing changes. After a drop there is none left to end. */\n dragEnded(): void {\n if (this.state().drag?.via === 'pointer') this.cancelPlacing()\n }\n\n /** Shows `panel` on a narrow screen and takes focus into it, so the pane that appears is where the keyboard is. */\n showPane(panel: EditorPanel): void {\n this.dispatch({ type: 'openPanel', panel }, { to: 'pane', panel })\n }\n\n protected keydown(event: KeyboardEvent): void {\n // A key press reaches the root from an element inside it.\n const target = event.target as Element\n if (keepsItsKeys(target)) return\n const scope: KeyScope = target.closest('[role=\"tree\"]') === null ? 'editor' : 'outline'\n const action = actionForKey(event, scope, this.state().drag !== null)\n if (action === undefined) return\n // Alt+Left is the browser's Back and Ctrl+D its bookmark: the editor's, here.\n event.preventDefault()\n if (action.type === 'cancelDrag') return this.cancelPlacing()\n this.dispatch(action, scope === 'outline' ? { to: 'selection' } : undefined)\n }\n\n private moveFocus(): void {\n const focus = this.focusAfter\n if (focus === null) return\n this.focusAfter = null\n const root = this.host.nativeElement\n // In the order the selectors are listed, not the order of the page: the selected row before the first one.\n const first = (selectors: readonly string[]): HTMLElement | null => selectors.reduce<HTMLElement | null>((found, selector) => found ?? root.querySelector<HTMLElement>(selector), null)\n const element =\n focus.to === 'element'\n ? focus.element\n : focus.to === 'places'\n ? root.querySelector<HTMLElement>('[data-report-part=\"places\"] button')\n : first(focus.to === 'pane' ? PANE_FOCUS[focus.panel] : SELECTION_FOCUS)\n element?.focus()\n }\n}\n","/**\n * The design view: one sheet as wide as the page, the regions as bands on\n * it, each component's box in its band, rulers in millimetres along two\n * sides. Every size and position is the state's, in pixels at the zoom; this\n * only draws them.\n *\n * It is labelled as not the PDF, because it is not (plan 8). Each box is a\n * picture of where a component stands -- `role=\"img\"`, named by its label,\n * so reading the view says what is on it. A click selects one, and focus\n * follows to its outline row; a box is not a tab stop, because the outline\n * is the keyboard's way to every box. The view itself is one stop, so a\n * keyboard can scroll a zoomed sheet. Dragging a palette button, a box or\n * an outline row onto it places at the nearest place the session accepts,\n * with the places drawn, and named, while the drag lasts; the place chooser\n * is the keyboard's path for the same.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport { targetNear } from '@formancy/report-builder-core'\nimport type { CanvasBox } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'section[reportCanvas]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n 'data-report-part': 'canvas',\n tabindex: '0',\n '[attr.aria-label]': 'canvas().label',\n },\n template: `\n <p data-report-part=\"canvas-note\">{{ canvas().note }}</p>\n <div data-report-part=\"ruler\" data-orientation=\"horizontal\" role=\"img\" [attr.aria-label]=\"t()('ruler.horizontal')\" [style.width.px]=\"canvas().sheet.px.width\">\n @for (tick of canvas().rulers.horizontal; track tick.mm) {\n <span data-report-part=\"ruler-tick\" [attr.data-major]=\"tick.major ? 'true' : null\" [style.left.px]=\"tick.at\">@if (tick.label) {<span>{{ tick.label }}</span>}</span>\n }\n </div>\n <div data-report-part=\"ruler\" data-orientation=\"vertical\" role=\"img\" [attr.aria-label]=\"t()('ruler.vertical')\" [style.height.px]=\"canvas().sheet.px.height\">\n @for (tick of canvas().rulers.vertical; track tick.mm) {\n <span data-report-part=\"ruler-tick\" [attr.data-major]=\"tick.major ? 'true' : null\" [style.top.px]=\"tick.at\">@if (tick.label) {<span>{{ tick.label }}</span>}</span>\n }\n </div>\n <div data-report-part=\"sheet\" [style.width.px]=\"canvas().sheet.px.width\" [style.height.px]=\"canvas().sheet.px.height\" (dragover)=\"over($event)\" (drop)=\"root.putDown($event)\">\n @for (band of canvas().regions; track band.region) {\n <div\n data-report-part=\"region\"\n [attr.data-empty]=\"band.empty ? 'true' : null\"\n [style.left.px]=\"band.px.x\"\n [style.top.px]=\"band.px.y\"\n [style.width.px]=\"band.px.width\"\n [style.height.px]=\"band.px.height\"\n ><span data-report-part=\"region-label\">{{ band.label }}</span></div>\n }\n @for (box of canvas().boxes; track box.key) {\n <div\n role=\"img\"\n data-report-part=\"box\"\n [attr.aria-label]=\"box.label\"\n [attr.data-kind]=\"box.kind\"\n [attr.data-selected]=\"box.selected ? 'true' : null\"\n [attr.data-overflows]=\"box.overflows ? 'true' : null\"\n [attr.data-dragging]=\"box.id === dragged() && box.column === undefined ? 'true' : null\"\n [attr.title]=\"box.overflows ? t()('canvas.overflow') : null\"\n [attr.draggable]=\"box.column === undefined ? 'true' : null\"\n [style.left.px]=\"box.px.x\"\n [style.top.px]=\"box.px.y\"\n [style.width.px]=\"box.px.width\"\n [style.height.px]=\"box.px.height\"\n (click)=\"select(box)\"\n (dragstart)=\"drag(box, $event)\"\n (dragend)=\"root.dragEnded()\"\n ><span data-report-part=\"box-label\">{{ box.label }}</span>@if (box.problems > 0) {<span data-report-part=\"badge\" [attr.data-severity]=\"box.severity ?? null\" aria-hidden=\"true\">{{ box.problems }}</span>}</div>\n }\n <!-- Drawn only for the places the session accepts, named as the place\n chooser names them; the one under the pointer, or focused in the\n chooser, is marked. -->\n @for (target of state().dropTargets; track target.index) {\n <div\n role=\"img\"\n data-report-part=\"drop-indicator\"\n [attr.aria-label]=\"target.label\"\n [attr.data-over]=\"target.index === state().drag?.over ? 'true' : null\"\n [style.left.px]=\"target.px.x\"\n [style.top.px]=\"target.px.y\"\n [style.width.px]=\"target.px.width\"\n [style.height.px]=\"target.px.height\"\n ></div>\n }\n </div>\n `,\n})\nexport class ReportCanvas {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n protected readonly canvas = computed(() => this.state().canvas)\n /** The component being moved, drawn faded where it stands. */\n protected readonly dragged = computed(() => {\n const subject = this.state().drag?.subject\n return subject !== undefined && 'id' in subject ? subject.id : null\n })\n\n protected select(box: CanvasBox): void {\n this.root.dispatch({ type: 'select', id: box.id, ...(box.column === undefined ? {} : { column: box.column }) }, { to: 'selection' })\n }\n\n protected drag(box: CanvasBox, event: DragEvent): void {\n // A box inside another is inside its parent's box too: the innermost one moves.\n event.stopPropagation()\n this.root.pickUp(event, { id: box.id }, box.label)\n }\n\n /**\n * The place nearest the pointer, among those whose list it is over;\n * dropping is allowed only while a pointer drags. The places are in pixels\n * from the sheet's padding edge, where its placed children start: inside\n * its border, which the bounding box includes.\n */\n protected over(event: DragEvent): void {\n const drag = this.state().drag\n if (drag?.via !== 'pointer') return\n event.preventDefault()\n const sheet = event.currentTarget as HTMLElement\n const box = sheet.getBoundingClientRect()\n const over = targetNear(this.state().dropTargets, { x: event.clientX - box.left - sheet.clientLeft, y: event.clientY - box.top - sheet.clientTop })\n if (over !== drag.over) this.root.dispatch({ type: 'updateDrag', over })\n }\n}\n","/**\n * The outline: the report's regions, and every component and table column\n * in them, as a tree.\n *\n * The rows are flat, in the order a person reads the report, with the depth\n * said by `aria-level` and the place among siblings by `aria-posinset` and\n * `aria-setsize` -- as formancy's builder's structure tree does -- so a\n * row's accessible name is its own label and never its children's too.\n * One row is a tab stop, the selected one, else the first; with no rows the\n * tree itself is, empty and described by the builder's sentence that says\n * so, so a keyboard learns there is nothing rather than skipping it. Focus and selection are one: focus moving to a row selects it, and\n * every action that selects moves focus to its row. The keys (arrows, Home\n * and End, Alt with an arrow to move, Delete, Ctrl+D) are the root's,\n * decided by report-builder-core's `actionForKey`. Each region is a group\n * named by its label.\n *\n * A row can be dragged, and a drag dropped on a row lands just before it or\n * just after it -- the upper or the lower half -- through the editor's\n * `targetBeside`, among the places the session accepts.\n */\nimport { ChangeDetectionStrategy, Component, computed, ElementRef, inject } from '@angular/core'\nimport { targetBeside } from '@formancy/report-builder-core'\nimport type { OutlineNode } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n/** A node with its place among its siblings. */\ninterface Row {\n readonly node: OutlineNode\n readonly position: number\n readonly siblings: number\n}\n\n/** Every row under `nodes`, each before what it holds. */\nfunction rows(nodes: readonly OutlineNode[], into: Row[] = []): Row[] {\n nodes.forEach((node, at) => {\n into.push({ node, position: at + 1, siblings: nodes.length })\n rows(node.children, into)\n })\n return into\n}\n\n@Component({\n selector: 'div[reportOutline]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n role: 'tree',\n 'data-report-part': 'outline',\n '[attr.aria-label]': 't()(\"pane.outline\")',\n // With rows, focus from a script only: where it goes when an action\n // leaves nothing selected, since a row given focus would select itself.\n '[attr.tabindex]': 'stop() === undefined ? 0 : -1',\n '[attr.aria-describedby]': 'stop() === undefined ? root.outlineEmpty : null',\n '(dragover)': 'over($event)',\n '(drop)': 'root.putDown($event)',\n },\n // With no row at all the tree holds nothing: a tree owns rows, and a\n // region's name with none under it is not one. The builder says, beside\n // it, that it is empty (root.outlineEmpty).\n template: `\n @if (stop() !== undefined) {\n @for (region of regions(); track region.region) {\n <div role=\"group\" data-report-part=\"outline-region\" [attr.aria-label]=\"region.label\">\n <span data-report-part=\"region-label\" aria-hidden=\"true\">{{ region.label }}</span>\n @for (row of region.rows; track row.node.key) {\n <div\n role=\"treeitem\"\n data-report-part=\"outline-item\"\n [attr.data-kind]=\"row.node.kind\"\n [attr.aria-level]=\"row.node.depth + 1\"\n [attr.aria-posinset]=\"row.position\"\n [attr.aria-setsize]=\"row.siblings\"\n [attr.aria-selected]=\"row.node.selected\"\n [attr.aria-describedby]=\"described(row.node)\"\n [attr.draggable]=\"row.node.column === undefined ? 'true' : null\"\n [tabIndex]=\"row.node.key === stop() ? 0 : -1\"\n (focus)=\"focused(row.node)\"\n (click)=\"select(row.node)\"\n (dragstart)=\"drag(row.node, $event)\"\n (dragend)=\"root.dragEnded()\"\n >{{ row.node.label }}@if (row.node.problems > 0) {\n <!-- The count is drawn, and said as the row's description: inside\n the name it would make \"Introduction\" read \"Introduction 1\". -->\n <span data-report-part=\"badge\" [attr.data-severity]=\"row.node.severity ?? null\" aria-hidden=\"true\">{{ row.node.problems }}</span>\n <span [id]=\"problems(row.node)\" hidden>{{ t()('outline.problems', { count: row.node.problems }) }}</span>\n }\n @if (row.node.overflows) {\n <!-- What the canvas marks on a box too wide for its place, said where a keyboard is. -->\n <span [id]=\"overflow(row.node)\" hidden>{{ t()('canvas.overflow') }}</span>\n }</div>\n } @empty {\n <span>{{ t()('outline.empty') }}</span>\n }\n </div>\n }\n }\n `,\n})\nexport class ReportOutline {\n protected readonly root = inject(ReportEditorRoot)\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef)\n protected readonly t = this.root.t\n protected readonly regions = computed(() => this.root.state().outline.map((region) => ({ region: region.region, label: region.label, rows: rows(region.nodes) })))\n // ES2018, as ng-packagr compiles the published sources: no flatMap.\n private readonly all = computed(() => this.regions().reduce<OutlineNode[]>((nodes, region) => nodes.concat(region.rows.map((row) => row.node)), []))\n /** The row Tab lands on: the selected one, else the first; none when the tree is empty. */\n protected readonly stop = computed(() => {\n const all = this.all()\n return (all.find((node) => node.selected) ?? all[0])?.key\n })\n\n protected problems(node: OutlineNode): string {\n return `${this.root.id}-problems-${node.key}`\n }\n\n protected overflow(node: OutlineNode): string {\n return `${this.root.id}-overflow-${node.key}`\n }\n\n /** The ids of what describes a row: how many problems it has, and that it is wider than its place. */\n protected described(node: OutlineNode): string | null {\n const ids = [...(node.problems > 0 ? [this.problems(node)] : []), ...(node.overflows ? [this.overflow(node)] : [])]\n return ids.length === 0 ? null : ids.join(' ')\n }\n\n protected select(node: OutlineNode): void {\n this.root.dispatch({ type: 'select', id: node.id, ...(node.column === undefined ? {} : { column: node.column }) }, { to: 'selection' })\n }\n\n /** Focus that arrives on a row -- by Tab, or put there after an undo -- selects it, so the properties beside it are the focused row's. */\n protected focused(node: OutlineNode): void {\n if (!node.selected) this.root.dispatch({ type: 'select', id: node.id, ...(node.column === undefined ? {} : { column: node.column }) })\n }\n\n protected drag(node: OutlineNode, event: DragEvent): void {\n this.root.pickUp(event, { id: node.id }, node.label)\n }\n\n /**\n * The place beside the row the pointer is over: before it over its upper\n * half, after it over its lower half. A row with no such place -- the one\n * being moved, a table's column -- takes no drop, and says so to the\n * browser by leaving the dragover alone.\n */\n protected over(event: DragEvent): void {\n const drag = this.root.state().drag\n if (drag?.via !== 'pointer') return\n const element = (event.target as Element).closest('[role=\"treeitem\"]')\n const node = element === null ? undefined : this.all()[[...this.host.nativeElement.querySelectorAll('[role=\"treeitem\"]')].indexOf(element)]\n let over: number | null = null\n if (element !== null && node !== undefined && node.column === undefined) {\n const box = element.getBoundingClientRect()\n over = targetBeside(this.root.state().dropTargets, node.id, event.clientY < box.top + box.height / 2 ? 'before' : 'after')\n }\n if (over !== null) event.preventDefault()\n if (over !== drag.over) this.root.dispatch({ type: 'updateDrag', over })\n }\n}\n","/**\n * The palette: one button per kind of component the report format has.\n *\n * Activating one -- a click, Enter or Space -- opens the place chooser for\n * that kind, which is the keyboard's path for the drag (formancy.ai 0046).\n * Dragging one onto the design view is the pointer's. A kind the report\n * cannot hold yet stays in the list, `aria-disabled` and described by what\n * to declare first, so it is found rather than missed; activating it\n * announces the same.\n */\nimport { ChangeDetectionStrategy, Component, inject } from '@angular/core'\nimport type { PaletteEntry } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'div[reportPalette]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n role: 'group',\n 'data-report-part': 'palette',\n '[attr.aria-label]': 't()(\"pane.palette\")',\n },\n template: `\n @for (entry of state().palette; track entry.kind) {\n <button\n type=\"button\"\n data-report-part=\"palette-item\"\n draggable=\"true\"\n [attr.data-kind]=\"entry.kind\"\n [attr.aria-disabled]=\"entry.component === null ? 'true' : null\"\n [attr.aria-describedby]=\"entry.unavailable === undefined ? null : why(entry)\"\n (click)=\"choose(entry, $event)\"\n (dragstart)=\"drag(entry, $event)\"\n (dragend)=\"root.dragEnded()\"\n >{{ entry.label }}@if (entry.unavailable !== undefined) {<span [id]=\"why(entry)\" hidden>{{ entry.unavailable }}</span>}</button>\n }\n `,\n})\nexport class ReportPalette {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n\n protected why(entry: PaletteEntry): string {\n return `${this.root.id}-unavailable-${entry.kind}`\n }\n\n protected choose(entry: PaletteEntry, event: Event): void {\n this.root.choosePlace({ kind: entry.kind }, event.currentTarget as HTMLElement)\n }\n\n protected drag(entry: PaletteEntry, event: DragEvent): void {\n this.root.pickUp(event, { kind: entry.kind }, entry.label)\n }\n}\n","/**\n * The place chooser: the keyboard's path for every drag (formancy.ai 0046).\n *\n * While a person chooses where to put something by keyboard, this is a\n * dialog named for what is being placed, with a button per place the\n * session accepts -- report-core's `validLocations`, named by\n * report-builder-core -- and a Cancel button. It floats over the outline\n * pane, a pane of the workbench's own, so the design view beside it stays\n * in sight. Focus moves to the first place when it opens, or to Cancel when\n * there is none, which the dialog's description then explains; the place a\n * button stands for is drawn on the canvas while the button has focus.\n * Choosing one puts focus on the outline row of what was placed; Cancel, or\n * Escape, puts it back on what opened the chooser. It is not modal: the\n * rest of the editor stays usable while it is open.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport type { DropTarget } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'div[reportPlaces]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n 'data-report-part': 'places',\n // The workbench dresses a pane's buttons; idle, the chooser is no pane,\n // because the pane's display would override \\`hidden\\`.\n '[class.wb-pane]': 'choosing() !== null',\n '[hidden]': 'choosing() === null',\n '[attr.role]': 'choosing() === null ? null : \"dialog\"',\n // Named in the editor's words, as the header says, never after the\n // header, whose name a host's stylesheet could set in capitals.\n '[attr.aria-label]': 'choosing()?.title ?? null',\n '[attr.aria-describedby]': 'choosing()?.nowhere === undefined ? null : nowhere',\n },\n template: `\n @if (choosing(); as drag) {\n <header>{{ drag.title }}</header>\n @if (drag.nowhere !== undefined) {\n <p class=\"wb-problem\" [id]=\"nowhere\">{{ drag.nowhere }}</p>\n }\n @for (target of state().dropTargets; track target.index) {\n <button type=\"button\" data-report-part=\"place\" (focus)=\"show(target)\" (click)=\"root.place(drag.subject, target)\">{{ target.label }}</button>\n }\n <button type=\"button\" (click)=\"root.cancelPlacing()\">{{ t()('places.cancel') }}</button>\n }\n `,\n})\nexport class ReportPlaces {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n /** The drag a keyboard is choosing a place for; a pointer's is drawn on the canvas instead. */\n protected readonly choosing = computed(() => {\n const drag = this.state().drag\n return drag?.via === 'keyboard' ? drag : null\n })\n protected readonly nowhere = `${this.root.id}-nowhere`\n\n protected show(target: DropTarget): void {\n this.root.dispatch({ type: 'updateDrag', over: target.index })\n }\n}\n","/**\n * The problems: report-core's diagnostics, one button each, named by\n * severity and what it is about, and described by its sentence. Activating\n * one selects what it is about and puts focus on that outline row, so an\n * error message leads to the component it names (plan 8); one about the\n * report as a whole shows the report's own properties.\n *\n * The list is not a tab stop of its own: the toolbar's Problems button\n * moves focus to it, so what is said first is how many there are.\n *\n * Each entry is tracked by what it is (`DiagnosticEntry.key`), never by its\n * place in the list: a problem listed before the one the keyboard is on\n * leaves that one's button, and the keyboard, on the problem they were on.\n */\nimport { ChangeDetectionStrategy, Component, inject } from '@angular/core'\nimport type { DiagnosticEntry } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'div[reportProblems]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <ul data-report-part=\"diagnostics\" tabindex=\"-1\" [attr.aria-label]=\"t()('pane.problems')\">\n @for (entry of state().diagnostics; track entry.key) {\n <li data-report-part=\"diagnostic\" [attr.data-severity]=\"entry.severity\">\n <button type=\"button\" [attr.aria-describedby]=\"message($index)\" (click)=\"follow(entry)\">{{ entry.label }}</button>\n <div [id]=\"message($index)\">{{ entry.message }}</div>\n </li>\n }\n </ul>\n @if (state().diagnostics.length === 0) {\n <p>{{ t()('problems.none') }}</p>\n }\n `,\n})\nexport class ReportProblems {\n private readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n\n protected message(index: number): string {\n return `${this.root.id}-problem-${String(index)}`\n }\n\n protected follow(entry: DiagnosticEntry): void {\n const target = entry.target\n if (target === null) this.root.dispatch({ type: 'select', id: null })\n else this.root.dispatch({ type: 'select', ...target }, { to: 'selection' })\n }\n}\n","/**\n * The properties of what is selected, or of the report when nothing is: a\n * form named by the pane's heading, with one native control per field,\n * labelled by the field's label, with the role report-builder-core's\n * `PROPERTY_ROLES` gives its kind -- the control is chosen from that role,\n * so the two cannot disagree -- and required where the field is.\n *\n * A field commits when it changes: a text on leaving it, or on Enter in a\n * single-line one; a select or a checkbox at once. A value given back as it\n * already stands is not sent, so the change event a browser fires after\n * Enter commits nothing twice. Escape in a typed field gives back what the\n * report holds, so leaving it afterwards commits nothing. A refused value\n * stays as typed, marked invalid and described by the reason, which is\n * shown under it; the editor keeps both, so they survive a re-render.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport { PROPERTY_ROLES } from '@formancy/report-builder-core'\nimport type { PropertyField } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n/** The native control for a role: a textbox is a text input, a spinbutton a number input. */\nconst CONTROLS = { textbox: 'text', spinbutton: 'number', combobox: 'select', checkbox: 'checkbox' } as const\n\ntype Control = (typeof CONTROLS)[keyof typeof CONTROLS] | 'textarea'\n\ninterface Shown {\n readonly field: PropertyField\n readonly control: Control\n readonly id: string\n readonly errorId: string | null\n}\n\n@Component({\n selector: 'form[reportProperties]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n 'data-report-part': 'properties',\n '[attr.aria-label]': 'root.state().properties.heading',\n // Enter in a single-line field commits it; the browser's implicit submission would reload the page.\n '(submit)': '$event.preventDefault()',\n },\n template: `\n @for (shown of shown(); track shown.id) {\n <div data-report-part=\"property\" [attr.data-kind]=\"shown.field.kind\">\n <label [attr.for]=\"shown.id\">{{ shown.field.label }}</label>\n @switch (shown.control) {\n @case ('textarea') {\n <textarea\n [id]=\"shown.id\"\n [value]=\"shown.field.value\"\n [required]=\"shown.field.required\"\n [attr.placeholder]=\"shown.field.placeholder ?? null\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).value)\"\n (keydown.escape)=\"giveBack(shown.field, $event)\"\n ></textarea>\n }\n @case ('checkbox') {\n <input\n type=\"checkbox\"\n [id]=\"shown.id\"\n [checked]=\"shown.field.value === true\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).checked)\"\n />\n }\n @case ('select') {\n <select\n [id]=\"shown.id\"\n [required]=\"shown.field.required\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).value)\"\n >\n @for (option of shown.field.options ?? []; track option.value) {\n <option [value]=\"option.value\" [selected]=\"option.value === shown.field.value\">{{ option.label }}</option>\n }\n </select>\n }\n @default {\n <input\n [type]=\"shown.control\"\n [attr.step]=\"shown.control === 'number' ? 'any' : null\"\n [id]=\"shown.id\"\n [value]=\"shown.field.value\"\n [required]=\"shown.field.required\"\n [attr.placeholder]=\"shown.field.placeholder ?? null\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).value)\"\n (keydown.enter)=\"enter(shown.field, $event)\"\n (keydown.escape)=\"giveBack(shown.field, $event)\"\n />\n }\n }\n @if (shown.errorId !== null) {\n <p data-report-part=\"property-error\" class=\"wb-problem\" [id]=\"shown.errorId\">{{ shown.field.error }}</p>\n }\n </div>\n }\n `,\n})\nexport class ReportProperties {\n protected readonly root = inject(ReportEditorRoot)\n\n /**\n * Each field with its control and ids. The ids carry whose fields these\n * are, and the rows are tracked by them, so a field of the next selection\n * is a new control rather than one still holding what was typed into the\n * last selection's.\n */\n protected readonly shown = computed<readonly Shown[]>(() => {\n const { selection, properties } = this.root.state()\n const owner = selection === null ? 'report' : `${selection.id}${selection.column === undefined ? '' : `-${selection.column}`}`\n return properties.fields.map((field, index) => {\n const id = `${this.root.id}-${owner}-${String(index)}`\n const control: Control = field.kind === 'multiline' ? 'textarea' : CONTROLS[PROPERTY_ROLES[field.kind]]\n return { field, control, id, errorId: field.error === undefined ? null : `${id}-error` }\n })\n })\n\n protected commit(field: PropertyField, value: string | boolean): void {\n // The field as the editor has it now: an Enter's commit has landed by the time the browser's change event follows it.\n const now = this.root.state().properties.fields.find((candidate) => candidate.key === field.key)\n if (now !== undefined && now.value === value) return\n this.root.dispatch({ type: 'setProperty', key: field.key, value })\n }\n\n protected enter(field: PropertyField, event: Event): void {\n event.preventDefault()\n this.commit(field, (event.target as HTMLInputElement).value)\n }\n\n /** Escape: what the report holds, back in the field, so nothing typed since is committed when it is left. */\n protected giveBack(field: PropertyField, event: Event): void {\n const now = this.root.state().properties.fields.find((candidate) => candidate.key === field.key) ?? field\n ;(event.target as HTMLInputElement | HTMLTextAreaElement).value = String(now.value)\n }\n}\n","/**\n * The live region: what the last action did, or why it did nothing, in the\n * editor's words.\n *\n * Shown, not hidden, because a sighted keyboard user needs the same\n * confirmation. Each announcement is a new element, keyed by the editor's\n * count of them, so saying the same words twice -- \"Nothing to undo.\" on a\n * second Ctrl+Z -- is announced twice rather than taken for no change.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'p[reportStatus]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { role: 'status', 'data-report-part': 'status' },\n template: `@for (said of said(); track said.sequence) {<span>{{ said.text }}</span>}`,\n})\nexport class ReportStatus {\n private readonly root = inject(ReportEditorRoot)\n protected readonly said = computed(() => {\n const status = this.root.state().status\n return status.text === '' ? [] : [status]\n })\n}\n","/**\n * The toolbar: undo and redo, the keyboard's moves, the zoom, and the panes\n * a narrow screen shows one at a time.\n *\n * One tab stop, with the arrow keys between its buttons (the toolbar\n * pattern), stepping the way the page reads; an arrow held with a modifier\n * is the browser's or the screen reader's. A button whose action has\n * nowhere to go says so with `aria-disabled` and stays focusable, so\n * pressing Redo until there is nothing left to redo does not drop focus to\n * the page -- where the next Ctrl+Z would reach nothing -- and pressing it\n * again still asks the editor, which says why nothing happened.\n */\nimport { ChangeDetectionStrategy, Component, computed, ElementRef, inject, signal } from '@angular/core'\nimport type { EditorAction, EditorPanel, EditorState, EditorText } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n/** What a tool does: an action for the editor, the place chooser for the selection, or a pane. */\ntype Use = { readonly action: EditorAction } | { readonly placeSelection: true } | { readonly pane: EditorPanel }\n\ninterface Tool {\n readonly label: string\n readonly use: Use\n readonly available: boolean\n /** What undo or redo would take back. */\n readonly title: string | null\n}\n\nfunction tools(state: EditorState, t: EditorText): Tool[] {\n const { history, can } = state\n const tool = (label: Parameters<EditorText>[0], use: Use, available: boolean, title: string | null = null): Tool => ({ label: t(label), use, available, title })\n const act = (action: EditorAction): Use => ({ action })\n return [\n tool('action.undo', act({ type: 'undo' }), history.canUndo, history.undoLabel === null ? null : t('action.undoWhat', { label: history.undoLabel })),\n tool('action.redo', act({ type: 'redo' }), history.canRedo, history.redoLabel === null ? null : t('action.redoWhat', { label: history.redoLabel })),\n tool('action.moveUp', act({ type: 'moveUp' }), can.moveUp),\n tool('action.moveDown', act({ type: 'moveDown' }), can.moveDown),\n tool('action.indent', act({ type: 'indent' }), can.indent),\n tool('action.outdent', act({ type: 'outdent' }), can.outdent),\n tool('action.moveTo', { placeSelection: true }, can.moveTo),\n tool('action.duplicate', act({ type: 'duplicate' }), can.duplicate),\n tool('action.delete', act({ type: 'delete' }), can.delete),\n tool('action.zoomOut', act({ type: 'zoomOut' }), can.zoomOut),\n tool('action.zoomIn', act({ type: 'zoomIn' }), can.zoomIn),\n tool('action.zoomReset', act({ type: 'setZoom', zoom: 1 }), can.zoomReset),\n tool('pane.outline', { pane: 'outline' }, true),\n tool('pane.canvas', { pane: 'canvas' }, true),\n tool('pane.properties', { pane: 'properties' }, true),\n tool('pane.problems', { pane: 'diagnostics' }, true),\n ]\n}\n\n@Component({\n selector: 'div[reportToolbar]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n role: 'toolbar',\n 'data-report-part': 'toolbar',\n class: 'wb-tools',\n '[attr.aria-label]': 't()(\"toolbar.label\")',\n '(keydown)': 'along($event)',\n },\n template: `\n @for (tool of tools(); track tool.label; let at = $index) {\n @if (at === zoomAt()) {\n <!-- The live region already says \"Zoom 125%.\"; the readout does not say it twice. -->\n <output data-report-part=\"zoom\" aria-live=\"off\" [attr.aria-label]=\"t()('zoom.label')\">{{ state().zoomLabel }}</output>\n }\n <button\n type=\"button\"\n [attr.aria-disabled]=\"tool.available ? null : 'true'\"\n [attr.title]=\"tool.title\"\n [tabIndex]=\"at === stop() ? 0 : -1\"\n (focus)=\"stop.set(at)\"\n (click)=\"use(tool, $event)\"\n >{{ tool.label }}</button>\n }\n `,\n})\nexport class ReportToolbar {\n private readonly root = inject(ReportEditorRoot)\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n protected readonly tools = computed(() => tools(this.state(), this.t()))\n /** Where the zoom's readout stands: just before Zoom in. */\n protected readonly zoomAt = computed(() => this.tools().findIndex((tool) => 'action' in tool.use && tool.use.action.type === 'zoomIn'))\n /** The button Tab lands on: the one last focused, Undo at first. */\n protected readonly stop = signal(0)\n\n protected use(tool: Tool, event: Event): void {\n const use = tool.use\n if ('pane' in use) return this.root.showPane(use.pane)\n // Every other unavailable tool still asks, and the editor says why not;\n // this one has no component to place, only a table's column, or nothing.\n if ('placeSelection' in use) {\n const selection = this.state().selection\n if (tool.available && selection !== null) this.root.choosePlace({ id: selection.id }, event.currentTarget as HTMLElement)\n return\n }\n this.root.dispatch(use.action)\n }\n\n protected along(event: KeyboardEvent): void {\n if (event.altKey || event.ctrlKey || event.metaKey) return\n const buttons = [...this.host.nativeElement.querySelectorAll<HTMLElement>('button')]\n // Only its buttons take focus, so the key came from one of them.\n const at = buttons.findIndex((button) => button === event.target)\n // → is the next tool where the page reads left to right, and the one before where it reads right to left.\n const forwards = this.host.nativeElement.closest('[dir]')?.getAttribute('dir') === 'rtl' ? -1 : 1\n const count = buttons.length\n const to = new Map([\n ['ArrowRight', (at + forwards + count) % count],\n ['ArrowLeft', (at - forwards + count) % count],\n ['Home', 0],\n ['End', count - 1],\n ]).get(event.key)\n if (to === undefined) return\n event.preventDefault()\n buttons[to]?.focus()\n }\n}\n","/**\n * `<report-builder [editor]=\"editor\" />`: the whole editor, in the\n * workbench's three panes, with a bar above them and one below.\n *\n * The element is the editor's root (`ReportEditorRoot`, as a host\n * directive), a region named \"Report editor\". Its children, as the React\n * builder's are:\n *\n * - a bar with the report's title and the toolbar, which on a narrow screen\n * is what switches between the panes, so it stands in none of them;\n * - the palette over the outline -- with no row in it, an empty tree and\n * the sentence that says so -- with the place chooser floating over them\n * while a keyboard chooses a place;\n * - the design view;\n * - the properties and the problems, sharing the third column. On a narrow\n * screen report-builder.css shows the one pane the state's `panel` names,\n * so the column says it is whichever of the two is asked for, and each\n * half carries its own name for the other to be hidden by;\n * - a bar with the live region.\n *\n * A host that wants another arrangement puts `[reportEditor]` on its own\n * element and the parts inside it, as this template does.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport { ReportCanvas } from './canvas'\nimport { ReportOutline } from './outline'\nimport { ReportPalette } from './palette'\nimport { ReportPlaces } from './places'\nimport { ReportProblems } from './problems'\nimport { ReportProperties } from './properties'\nimport { ReportEditorRoot } from './root'\nimport { ReportStatus } from './status'\nimport { ReportToolbar } from './toolbar'\n\n@Component({\n selector: 'report-builder',\n changeDetection: ChangeDetectionStrategy.OnPush,\n hostDirectives: [{ directive: ReportEditorRoot, inputs: ['reportEditor: editor'] }],\n imports: [ReportCanvas, ReportOutline, ReportPalette, ReportPlaces, ReportProblems, ReportProperties, ReportStatus, ReportToolbar],\n template: `\n <div class=\"wb-pane\">\n <header>\n <span data-report-part=\"title\">{{ state().document.title }}</span>\n <div reportToolbar></div>\n </header>\n </div>\n <section class=\"wb-pane\" data-pane=\"outline\">\n <header>{{ t()('pane.outline') }}</header>\n <div class=\"wb-body\">\n <div reportPalette></div>\n <div reportOutline></div>\n @if (empty()) {\n <p data-report-part=\"outline-empty\" [id]=\"root.outlineEmpty\">{{ t()('outline.empty') }}</p>\n }\n </div>\n <div reportPlaces></div>\n </section>\n <section class=\"wb-pane wb-canvas\" data-pane=\"canvas\">\n <header>{{ t()('pane.canvas') }}</header>\n <div class=\"wb-body\">\n <section reportCanvas></section>\n </div>\n </section>\n <section class=\"wb-pane\" [attr.data-pane]=\"state().panel === 'diagnostics' ? 'diagnostics' : 'properties'\">\n <header data-pane=\"properties\">\n <span>{{ state().properties.heading }}</span>\n @if (state().selection !== null) {\n <button type=\"button\" (click)=\"root.dispatch({ type: 'select', id: null }, { to: 'pane', panel: 'properties' })\">{{ t()('properties.report') }}</button>\n }\n </header>\n <div class=\"wb-body\" data-pane=\"properties\">\n <form reportProperties></form>\n </div>\n <header data-pane=\"diagnostics\">\n <!-- A status, so a change in how many problems there are is said\n without taking the person's place: \"Problems 2\". Named in\n words, never after its own heading, which the Studio sets in\n capitals that Chromium would put in the name. -->\n <div role=\"status\" [attr.aria-label]=\"t()('pane.problems')\">\n <span>{{ t()('pane.problems') }}</span>{{ count() > 0 ? ' ' : '' }}@if (count() > 0) {<span data-report-part=\"badge\" [attr.data-severity]=\"severity()\">{{ count() }}</span>}\n </div>\n </header>\n <div class=\"wb-body\" data-pane=\"diagnostics\">\n <div reportProblems></div>\n </div>\n </section>\n <div class=\"wb-pane\">\n <p reportStatus></p>\n </div>\n `,\n})\nexport class ReportBuilder {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n protected readonly count = computed(() => this.state().diagnostics.length)\n /** No row in any region: the outline is an empty tree, and this says so beside it. */\n protected readonly empty = computed(() => this.state().outline.every((region) => region.nodes.length === 0))\n /** What colour the count is: an error's, when any problem is one. */\n protected readonly severity = computed(() => (this.state().diagnostics.some((entry) => entry.severity === 'error') ? 'error' : 'warning'))\n}\n"],"mappings":";;;AA2BA,SAAgB,kBAAkB,QAA4B;CAG5D,MAAM,QAAQ,mBAAmB,OAAM,CAAE,CAAC,MAAK,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAClD,QAAQ,cAAa;EACnB,MAAM,YAAY,OAAM;EACxB,UAAU,UAAU,gBAAgB,MAAM,IAAI,UAAU,MAAK,CAAE,CAAC,CAAC;EAEjE,MAAM,IAAI,UAAU,MAAK,CAAE;CAC7B,CAAC;CACD,OAAO,MAAM,WAAU;AACzB;ACVA,IAAI,QAAQ;AAGZ,SAAS,aAAa,SAAgB;CACpC,IAAI,mBAAmB,uBAAuB,mBAAmB,mBAAmB,OAAO;CAC3F,IAAI,mBAAmB,kBAAkB,OAAO,CAAC;EAAC;EAAY;EAAS;EAAU;EAAU;CAAO,CAAC,CAAC,SAAS,QAAQ,IAAI;CACzH,OAAO,mBAAmB,eAAe,QAAQ;AACnD;AAOA,MAAM,aAA+D;CACnE,SAAS;EAAC;EAA2C;EAAmC;CAAe;CACvG,QAAQ,CAAC,+BAA6B;CACtC,YAAY,CAAC,gEAA8D;CAC3E,aAAa,CAAC,oCAAkC;AACjD;AAQD,MAAM,kBAAqC,CAAC,+CAA2C,iBAAe;AAatG,IAAa,mBAAb,MAAa,iBAAgB;CAElB,SAAS,MAAM,SAAQ;EAAA,GAAA,YAAA,EAAA,WAAA,SAAA,+BAAA,CAAA;EAAiB,OAAO;CAAc,CAAA;CAC7D,QAAQ,kBAAkB,KAAK,MAAM;CAErC,IAAI,eAA2B,WAAW,KAAK,MAAK,CAAE,CAAC,MAAM,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,IAAA,CAAA,+BAAA,CAAA,CAA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;EAmDX,CAAA"}
1
+ {"version":3,"file":"formancy-report-builder-angular.mjs","names":["i1.ReportEditorRoot"],"sources":["../../src/editor-state.ts","../../src/root.ts","../../src/canvas.ts","../../src/host-view.ts","../../src/outline.ts","../../src/image-chooser.ts","../../src/palette.ts","../../src/places.ts","../../src/problems.ts","../../src/image-library.ts","../../src/properties.ts","../../src/status.ts","../../src/toolbar.ts","../../src/builder.ts"],"sourcesContent":["/**\n * An editor's state as a signal: the one place this package listens to\n * report-builder-core.\n *\n * The editor's `state()` is a frozen object that stays the same until\n * something changes, and `subscribe` says when it has. That is all a signal\n * needs, so this is a signal set on each notification, rather than an\n * Observable turned into one: nothing here is a stream, and `toSignal` would\n * add RxJS to every builder for the sake of one callback. An OnPush view\n * reading the signal is marked for check when it is set, and zoneless\n * change detection renders it; nothing else schedules a render.\n */\nimport { effect, linkedSignal } from '@angular/core'\nimport type { Signal } from '@angular/core'\nimport type { EditorState, ReportEditor } from '@formancy/report-builder-core'\n\n/**\n * The state of the editor `editor` names, for as long as the view that\n * called this lives. Call it in an injection context: a field initialiser\n * or a constructor.\n *\n * When `editor` names another editor, the signal is that editor's state at\n * once, and the old editor is let go (plan 21's \"replacing the session\n * input\"). The subscription is an effect's, and its cleanup unsubscribes: on\n * the next editor, and when the view's `DestroyRef` ends the effect, so a\n * destroyed builder leaves no listener behind on an editor that outlives it.\n */\nexport function injectEditorState(editor: Signal<ReportEditor>): Signal<EditorState> {\n // Read from the editor the input names whenever it names another, so the\n // first render needs no subscription to be right.\n const state = linkedSignal(() => editor().state())\n effect((onCleanup) => {\n const following = editor()\n onCleanup(following.subscribe(() => state.set(following.state())))\n // Whatever changed between the read above and the subscription.\n state.set(following.state())\n })\n return state.asReadonly()\n}\n","/**\n * The editor's root: the element every part of the builder stands in, and\n * the one object the parts share.\n *\n * It holds the editor's state as a signal, the editor's words, and the\n * three things only the root can do: route a key press to the action it\n * asks for, dispatch an action, and put focus where the action left the\n * person. The parts inject it, as a form control injects its form. What any\n * of it means is report-builder-core's: which key does what (`actionForKey`),\n * what is selected, where a component may go. This decides only where focus\n * goes in this DOM.\n */\nimport { afterEveryRender, computed, Directive, ElementRef, inject, input } from '@angular/core'\nimport { actionForKey, editorText } from '@formancy/report-builder-core'\nimport type { DragSubject, DropTarget, EditorAction, EditorOutcome, EditorPanel, EditorText, HideablePanel, KeyScope, ReportEditor } from '@formancy/report-builder-core'\nimport { injectEditorState } from './editor-state'\n\n/** Where focus goes once what an action changed has rendered. */\nexport type FocusAfter =\n /** The selected outline row, which focus follows (the tree pattern); the tree itself when nothing is selected. */\n | { readonly to: 'selection' }\n /** The first place in the place chooser that has just opened, or its Cancel when there is none. */\n | { readonly to: 'places' }\n /** Back to the element that opened the place chooser. */\n | { readonly to: 'element'; readonly element: HTMLElement }\n /** Into a pane a narrow screen has just shown: its tree, its view, its first field or its list. */\n | { readonly to: 'pane'; readonly panel: EditorPanel }\n\nlet roots = 0\n\n/** Inputs whose own keys win: typing, and a select's arrows. Ctrl+Z in one undoes typing, not the report. */\nfunction keepsItsKeys(element: Element): boolean {\n if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) return true\n if (element instanceof HTMLInputElement) return !['checkbox', 'radio', 'button', 'submit', 'reset'].includes(element.type)\n return element instanceof HTMLElement && element.isContentEditable\n}\n\n/**\n * What focus lands on in each pane, the first of these that is there: the\n * selected outline row, else the tree's one tab stop, else the tree itself;\n * the design view, else the host's view standing in its place; the first\n * field; the problems' list.\n */\nconst PANE_FOCUS: Readonly<Record<EditorPanel, readonly string[]>> = {\n outline: ['[role=\"treeitem\"][aria-selected=\"true\"]', '[role=\"treeitem\"][tabindex=\"0\"]', '[role=\"tree\"]'],\n canvas: ['[data-report-part=\"canvas\"]', '[data-report-part=\"view\"]'],\n properties: ['[data-report-part=\"properties\"] :is(input, select, textarea)'],\n diagnostics: ['[data-report-part=\"diagnostics\"]'],\n}\n\n/**\n * Where focus goes after an action in the outline: the selected row, else\n * the tree itself -- never the first row, which focus would select, so that\n * after an undo that leaves nothing selected the next Delete deletes nothing\n * the person did not choose.\n */\nconst SELECTION_FOCUS: readonly string[] = ['[role=\"treeitem\"][aria-selected=\"true\"]', '[role=\"tree\"]']\n\n@Directive({\n selector: '[reportEditor]',\n host: {\n role: 'region',\n 'data-report-part': 'editor',\n class: 'wb',\n '[attr.aria-label]': 't()(\"editor.label\")',\n '[attr.data-panel]': 'state().panel',\n '[attr.data-hidden]': 'hidden()',\n '(keydown)': 'keydown($event)',\n '(focusin)': 'focused($event)',\n },\n})\nexport class ReportEditorRoot {\n /** The editor this builder renders and acts on. Several builders may share one; each is told of the others' edits. */\n readonly editor = input.required<ReportEditor>({ alias: 'reportEditor' })\n readonly state = injectEditorState(this.editor)\n /** The editor's own words, in the editor's language. */\n readonly t = computed<EditorText>(() => editorText(this.state().locale))\n /** Unique on the page, so the ids tying a label or a description to its control are too. */\n readonly id = `report-editor-${String((roots += 1))}`\n /** The sentence beside an outline with no row, which describes the empty tree. */\n readonly outlineEmpty = `${this.id}-outline-empty`\n /** The panes the person hid, as report-builder.css reads them; no attribute when none is. */\n protected readonly hidden = computed(() => (this.state().hidden.length === 0 ? null : this.state().hidden.join(' ')))\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef)\n private focusAfter: FocusAfter | null = null\n /** What opened the place chooser, for focus to go back to when it is cancelled. */\n private opener: HTMLElement | null = null\n /** The element the keyboard last stood on in this builder, for a middle pane swapped from under it to hand the keyboard on. */\n private lastFocused: EventTarget | null = null\n /** Whether that element stood in the properties form, for a row taken from under it to hand the keyboard to the first field. */\n private lastInProperties = false\n /** What the middle pane showed at the last render: null before the first. */\n private view: 'design' | 'host' | null = null\n\n constructor() {\n afterEveryRender(() => this.moveFocus())\n }\n\n /**\n * Sends `action` to the editor, and moves focus as `focus` says once\n * what it changed has rendered. Every action comes from a listener of this\n * builder's, and a listener marks its view for check, so a render follows\n * even an action that changed nothing: the focus never waits for whatever\n * renders next.\n */\n dispatch(action: EditorAction, focus?: FocusAfter): EditorOutcome {\n if (focus !== undefined) this.focusAfter = focus\n return this.editor().dispatch(action)\n }\n\n /**\n * Sends `action`, and moves focus as `focus` says only when it was done:\n * a refused one leaves the keyboard where the person pressed, the live\n * region saying why -- a Remove of an image something draws (0033). The\n * render the action causes comes after this returns, so it finds the\n * focus asked for.\n */\n attempt(action: EditorAction, focus: FocusAfter): EditorOutcome {\n const outcome = this.editor().dispatch(action)\n if (outcome.ok) this.focusAfter = focus\n return outcome\n }\n\n /**\n * Opens the place chooser for `subject`, remembering `opener` to come back\n * to. It floats over the outline pane, so that is the pane a narrow screen\n * shows while it is open.\n */\n choosePlace(subject: DragSubject, opener: HTMLElement): void {\n this.opener = opener\n const outcome = this.dispatch({ type: 'startDrag', subject, via: 'keyboard' }, { to: 'places' })\n // Refused -- an image with nothing to draw -- and announced; there is no chooser to come back from.\n if (outcome.ok) this.dispatch({ type: 'openPanel', panel: 'outline' })\n else this.opener = null\n }\n\n /** Puts `subject` at `target`: an insert or a move, never a second copy of either. */\n place(subject: DragSubject, target: DropTarget): void {\n this.opener = null\n this.dispatch('kind' in subject ? { type: 'insert', kind: subject.kind, target: target.location } : { type: 'move', id: subject.id, target: target.location }, { to: 'selection' })\n }\n\n /**\n * Starts a pointer's drag of `subject`. One the editor refuses -- a kind\n * the report cannot hold yet -- is announced, and not picked up at all.\n */\n pickUp(event: DragEvent, subject: DragSubject, label: string): void {\n // Firefox starts no drag without data. What is dragged is the editor's to know; this is a name for it.\n event.dataTransfer?.setData('text/plain', label)\n if (!this.dispatch({ type: 'startDrag', subject, via: 'pointer' }).ok) event.preventDefault()\n }\n\n /** Drops what a pointer drags on the place it is over; focus follows to what was placed, as after the keyboard's choice. */\n putDown(event: DragEvent): void {\n if (this.state().drag?.via !== 'pointer') return\n event.preventDefault()\n this.dispatch({ type: 'drop' }, { to: 'selection' })\n }\n\n /**\n * Ends a drag without placing anything. A keyboard's goes back to what\n * opened the chooser (the dialog pattern); a pointer's leaves focus where\n * it is, because a pointer never moved it.\n */\n cancelPlacing(): void {\n const keyboard = this.state().drag?.via === 'keyboard'\n const back = this.opener ?? (keyboard ? this.placedFrom() : null)\n this.opener = null\n this.dispatch({ type: 'cancelDrag' }, back === null ? undefined : { to: 'element', element: back })\n }\n\n /**\n * Where a keyboard's chooser goes back to when this builder did not open\n * it -- the drag is the editor's and outlives a builder, so a Studio that\n * switches frameworks draws it here: the palette entry of what is being\n * placed, else the selected outline row, else the tree. Never nothing,\n * which would leave the keyboard on the page.\n */\n private placedFrom(): HTMLElement | null {\n const subject = this.state().drag?.subject\n const root = this.host.nativeElement\n const entry = subject !== undefined && 'kind' in subject ? root.querySelector<HTMLElement>(`[data-report-part=\"palette-item\"][data-kind=\"${subject.kind}\"]`) : null\n return entry ?? root.querySelector<HTMLElement>(SELECTION_FOCUS.join(', '))\n }\n\n /** A pointer's drag let go of anywhere but a place: it ends, and nothing changes. After a drop there is none left to end. */\n dragEnded(): void {\n if (this.state().drag?.via === 'pointer') this.cancelPlacing()\n }\n\n /** Shows `panel` -- on a narrow screen, or hidden -- and takes focus into it, so the pane that appears is where the keyboard is. */\n showPane(panel: EditorPanel): void {\n this.dispatch({ type: 'openPanel', panel }, { to: 'pane', panel })\n }\n\n /** Hides `panel`; its Hide goes with it, so focus goes to the design view that took its room. */\n hidePane(panel: HideablePanel): void {\n this.dispatch({ type: 'hidePanel', panel }, { to: 'pane', panel: 'canvas' })\n }\n\n protected focused(event: FocusEvent): void {\n this.lastFocused = event.target\n this.lastInProperties = event.target instanceof Element && event.target.closest('[data-report-part=\"properties\"]') !== null\n }\n\n protected keydown(event: KeyboardEvent): void {\n // A key press reaches the root from an element inside it.\n const target = event.target as Element\n if (keepsItsKeys(target)) return\n // A key pressed in this builder's host's view is the host's, as a text field's are its own.\n const view = target.closest('[data-report-part=\"view\"]')\n if (view !== null && this.host.nativeElement.contains(view)) return\n const scope: KeyScope = target.closest('[role=\"tree\"]') === null ? 'editor' : 'outline'\n const action = actionForKey(event, scope, this.state().drag !== null)\n if (action === undefined) return\n // Alt+Left is the browser's Back and Ctrl+D its bookmark: the editor's, here.\n event.preventDefault()\n if (action.type === 'cancelDrag') return this.cancelPlacing()\n this.dispatch(action, scope === 'outline' ? { to: 'selection' } : undefined)\n }\n\n /**\n * The middle pane swapped by the host -- its view placed or shown from\n * outside, as the window crosses a width -- takes the keyboard along\n * rather than drop it on the page: where the element it stood on went\n * with the pane, and nothing has taken it since. So does an undo or a\n * redo that takes away the row it stood on in the properties -- an\n * image's Remove, the add undone or the remove redone: it goes to the\n * first field, as a Remove that worked sends it.\n */\n private dropped(): FocusAfter | null {\n const view = this.state().view\n const swapped = this.view !== null && this.view !== view\n this.view = view\n const last = this.lastFocused\n const nowhere = document.activeElement === null || document.activeElement === document.body\n if (!(last instanceof Node) || last.isConnected || !nowhere) return null\n if (swapped) return { to: 'pane', panel: 'canvas' }\n return this.lastInProperties ? { to: 'pane', panel: 'properties' } : null\n }\n\n private moveFocus(): void {\n // Asked every render, so that it knows what the middle pane showed at the last.\n const dropped = this.dropped()\n const focus = this.focusAfter ?? dropped\n if (focus === null) return\n this.focusAfter = null\n const root = this.host.nativeElement\n // In the order the selectors are listed, not the order of the page: the selected row before the first one.\n const first = (selectors: readonly string[]): HTMLElement | null => selectors.reduce<HTMLElement | null>((found, selector) => found ?? root.querySelector<HTMLElement>(selector), null)\n const element =\n focus.to === 'element'\n ? focus.element\n : focus.to === 'places'\n ? root.querySelector<HTMLElement>('[data-report-part=\"places\"] button')\n : first(focus.to === 'pane' ? PANE_FOCUS[focus.panel] : SELECTION_FOCUS)\n element?.focus()\n }\n}\n","/**\n * The design view: one sheet as wide as the page, the regions as bands on\n * it, each component's box in its band, a payment part's band at its foot,\n * rulers in millimetres along two sides. Every size and position is the\n * state's, in pixels at the zoom; this only draws them.\n *\n * It is labelled as not the PDF, because it is not (plan 8). Each box is a\n * picture of where a component stands -- `role=\"img\"`, named by its label,\n * so reading the view says what is on it. A click selects one, and focus\n * follows to its outline row; a box is not a tab stop, because the outline\n * is the keyboard's way to every box. The view itself is one stop, so a\n * keyboard can scroll a zoomed sheet. Dragging a palette button, a box or\n * an outline row onto it places at the nearest place the session accepts,\n * with the places drawn, and named, while the drag lasts; the place chooser\n * is the keyboard's path for the same.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport { targetNear } from '@formancy/report-builder-core'\nimport type { CanvasBox } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'section[reportCanvas]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n 'data-report-part': 'canvas',\n tabindex: '0',\n '[attr.aria-label]': 'canvas().label',\n },\n template: `\n <p data-report-part=\"canvas-note\">{{ canvas().note }}</p>\n <div data-report-part=\"ruler\" data-orientation=\"horizontal\" role=\"img\" [attr.aria-label]=\"t()('ruler.horizontal')\" [style.width.px]=\"canvas().sheet.px.width\">\n @for (tick of canvas().rulers.horizontal; track tick.mm) {\n <span data-report-part=\"ruler-tick\" [attr.data-major]=\"tick.major ? 'true' : null\" [style.left.px]=\"tick.at\">@if (tick.label) {<span>{{ tick.label }}</span>}</span>\n }\n </div>\n <div data-report-part=\"ruler\" data-orientation=\"vertical\" role=\"img\" [attr.aria-label]=\"t()('ruler.vertical')\" [style.height.px]=\"canvas().sheet.px.height\">\n @for (tick of canvas().rulers.vertical; track tick.mm) {\n <span data-report-part=\"ruler-tick\" [attr.data-major]=\"tick.major ? 'true' : null\" [style.top.px]=\"tick.at\">@if (tick.label) {<span>{{ tick.label }}</span>}</span>\n }\n </div>\n <div data-report-part=\"sheet\" [style.width.px]=\"canvas().sheet.px.width\" [style.height.px]=\"canvas().sheet.px.height\" (dragover)=\"over($event)\" (drop)=\"root.putDown($event)\">\n @for (band of canvas().regions; track band.region) {\n <div\n data-report-part=\"region\"\n [attr.data-empty]=\"band.empty ? 'true' : null\"\n [style.left.px]=\"band.px.x\"\n [style.top.px]=\"band.px.y\"\n [style.width.px]=\"band.px.width\"\n [style.height.px]=\"band.px.height\"\n ><span data-report-part=\"region-label\">{{ band.label }}</span></div>\n }\n @for (box of canvas().boxes; track box.key) {\n <div\n role=\"img\"\n data-report-part=\"box\"\n [attr.aria-label]=\"box.label\"\n [attr.data-kind]=\"box.kind\"\n [attr.data-selected]=\"box.selected ? 'true' : null\"\n [attr.data-overflows]=\"box.overflows ? 'true' : null\"\n [attr.data-dragging]=\"box.id === dragged() && box.column === undefined ? 'true' : null\"\n [attr.title]=\"box.overflows ? t()('canvas.overflow') : null\"\n [attr.draggable]=\"box.column === undefined ? 'true' : null\"\n [style.left.px]=\"box.px.x\"\n [style.top.px]=\"box.px.y\"\n [style.width.px]=\"box.px.width\"\n [style.height.px]=\"box.px.height\"\n (click)=\"select(box)\"\n (dragstart)=\"drag(box, $event)\"\n (dragend)=\"root.dragEnded()\"\n ><span data-report-part=\"box-label\">{{ box.label }}</span>@if (box.problems > 0) {<span data-report-part=\"badge\" [attr.data-severity]=\"box.severity ?? null\" aria-hidden=\"true\">{{ box.problems }}</span>}</div>\n }\n <!-- Where a payment part's slip prints, below every region: a picture\n named as SIX names the part, as a box is named by its label. -->\n @if (canvas().paymentPart; as band) {\n <div\n role=\"img\"\n data-report-part=\"payment-part\"\n [attr.aria-label]=\"band.label\"\n [style.left.px]=\"band.px.x\"\n [style.top.px]=\"band.px.y\"\n [style.width.px]=\"band.px.width\"\n [style.height.px]=\"band.px.height\"\n ><span data-report-part=\"region-label\">{{ band.label }}</span></div>\n }\n <!-- Drawn only for the places the session accepts, named as the place\n chooser names them; the one under the pointer, or focused in the\n chooser, is marked. -->\n @for (target of state().dropTargets; track target.index) {\n <div\n role=\"img\"\n data-report-part=\"drop-indicator\"\n [attr.aria-label]=\"target.label\"\n [attr.data-over]=\"target.index === state().drag?.over ? 'true' : null\"\n [style.left.px]=\"target.px.x\"\n [style.top.px]=\"target.px.y\"\n [style.width.px]=\"target.px.width\"\n [style.height.px]=\"target.px.height\"\n ></div>\n }\n </div>\n `,\n})\nexport class ReportCanvas {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n protected readonly canvas = computed(() => this.state().canvas)\n /** The component being moved, drawn faded where it stands. */\n protected readonly dragged = computed(() => {\n const subject = this.state().drag?.subject\n return subject !== undefined && 'id' in subject ? subject.id : null\n })\n\n protected select(box: CanvasBox): void {\n this.root.dispatch({ type: 'select', id: box.id, ...(box.column === undefined ? {} : { column: box.column }) }, { to: 'selection' })\n }\n\n protected drag(box: CanvasBox, event: DragEvent): void {\n // A box inside another is inside its parent's box too: the innermost one moves.\n event.stopPropagation()\n this.root.pickUp(event, { id: box.id }, box.label)\n }\n\n /**\n * The place nearest the pointer, among those whose list it is over;\n * dropping is allowed only while a pointer drags. The places are in pixels\n * from the sheet's padding edge, where its placed children start: inside\n * its border, which the bounding box includes.\n */\n protected over(event: DragEvent): void {\n const drag = this.state().drag\n if (drag?.via !== 'pointer') return\n event.preventDefault()\n const sheet = event.currentTarget as HTMLElement\n const box = sheet.getBoundingClientRect()\n const over = targetNear(this.state().dropTargets, { x: event.clientX - box.left - sheet.clientLeft, y: event.clientY - box.top - sheet.clientTop })\n if (over !== drag.over) this.root.dispatch({ type: 'updateDrag', over })\n }\n}\n","/**\n * A view of the host's own -- the Studio's PDF -- in the design view's\n * place (0029). The host gives it as a template:\n *\n * ```html\n * <report-builder [editor]=\"editor\">\n * <ng-template reportHostView><app-preview /></ng-template>\n * </report-builder>\n * ```\n *\n * and the builder stamps it into a bare region, named by the editor's\n * `hostView`, while the editor's `view` is the host's, and destroys it when\n * the design view comes back. A template rather than projected content:\n * Angular makes projected content once, whether its slot is drawn or not,\n * so a view projected into the middle pane would live -- and the Studio's\n * Preview print -- behind the design view.\n *\n * `NgTemplateOutlet` would stamp it, but it is `@angular/common`'s, which is\n * not this package's peer; the outlet below is `@angular/core` alone.\n */\nimport { Directive, effect, inject, input, TemplateRef, ViewContainerRef } from '@angular/core'\n\n/** Marks the template a host gives `<report-builder>` as its view. */\n@Directive({ selector: 'ng-template[reportHostView]' })\nexport class ReportHostView {\n readonly template = inject<TemplateRef<unknown>>(TemplateRef)\n}\n\n/**\n * Stamps the host's template where it stands, for as long as it stands\n * there: the builder's template draws it only while the host's view is in\n * the middle, and the view goes with the element when that ends.\n */\n@Directive({ selector: '[reportHostOutlet]' })\nexport class ReportHostOutlet {\n readonly template = input.required<TemplateRef<unknown> | null>({ alias: 'reportHostOutlet' })\n private readonly container = inject(ViewContainerRef)\n\n constructor() {\n effect(() => {\n const template = this.template()\n this.container.clear()\n if (template !== null) this.container.createEmbeddedView(template)\n })\n }\n}\n","/**\n * The outline: the report's regions, and every component and table column\n * in them, as a tree.\n *\n * The rows are flat, in the order a person reads the report, with the depth\n * said by `aria-level` and the place among siblings by `aria-posinset` and\n * `aria-setsize` -- as formancy's builder's structure tree does -- so a\n * row's accessible name is its own label and never its children's too.\n * One row is a tab stop, the selected one, else the first; with no rows the\n * tree itself is, empty and described by the builder's sentence that says\n * so, so a keyboard learns there is nothing rather than skipping it. Focus and selection are one: focus moving to a row selects it, and\n * every action that selects moves focus to its row. The keys (arrows, Home\n * and End, Alt with an arrow to move, Delete, Ctrl+D) are the root's,\n * decided by report-builder-core's `actionForKey`. Each region is a group\n * named by its label.\n *\n * A row can be dragged, and a drag dropped on a row lands just before it or\n * just after it -- the upper or the lower half -- through the editor's\n * `targetBeside`, among the places the session accepts.\n */\nimport { ChangeDetectionStrategy, Component, computed, ElementRef, inject } from '@angular/core'\nimport { targetBeside } from '@formancy/report-builder-core'\nimport type { OutlineNode } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n/** A node with its place among its siblings. */\ninterface Row {\n readonly node: OutlineNode\n readonly position: number\n readonly siblings: number\n}\n\n/** Every row under `nodes`, each before what it holds. */\nfunction rows(nodes: readonly OutlineNode[], into: Row[] = []): Row[] {\n nodes.forEach((node, at) => {\n into.push({ node, position: at + 1, siblings: nodes.length })\n rows(node.children, into)\n })\n return into\n}\n\n@Component({\n selector: 'div[reportOutline]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n role: 'tree',\n 'data-report-part': 'outline',\n '[attr.aria-label]': 't()(\"pane.outline\")',\n // With rows, focus from a script only: where it goes when an action\n // leaves nothing selected, since a row given focus would select itself.\n '[attr.tabindex]': 'stop() === undefined ? 0 : -1',\n '[attr.aria-describedby]': 'stop() === undefined ? root.outlineEmpty : null',\n '(dragover)': 'over($event)',\n '(drop)': 'root.putDown($event)',\n },\n // With no row at all the tree holds nothing: a tree owns rows, and a\n // region's name with none under it is not one. The builder says, beside\n // it, that it is empty (root.outlineEmpty).\n template: `\n @if (stop() !== undefined) {\n @for (region of regions(); track region.region) {\n <div role=\"group\" data-report-part=\"outline-region\" [attr.aria-label]=\"region.label\">\n <span data-report-part=\"region-label\" aria-hidden=\"true\">{{ region.label }}</span>\n @for (row of region.rows; track row.node.key) {\n <div\n role=\"treeitem\"\n data-report-part=\"outline-item\"\n [attr.data-kind]=\"row.node.kind\"\n [attr.aria-level]=\"row.node.depth + 1\"\n [attr.aria-posinset]=\"row.position\"\n [attr.aria-setsize]=\"row.siblings\"\n [attr.aria-selected]=\"row.node.selected\"\n [attr.aria-describedby]=\"described(row.node)\"\n [attr.draggable]=\"row.node.column === undefined ? 'true' : null\"\n [tabIndex]=\"row.node.key === stop() ? 0 : -1\"\n (focus)=\"focused(row.node)\"\n (click)=\"select(row.node)\"\n (dragstart)=\"drag(row.node, $event)\"\n (dragend)=\"root.dragEnded()\"\n >{{ row.node.label }}@if (row.node.problems > 0) {\n <!-- The count is drawn, and said as the row's description: inside\n the name it would make \"Introduction\" read \"Introduction 1\". -->\n <span data-report-part=\"badge\" [attr.data-severity]=\"row.node.severity ?? null\" aria-hidden=\"true\">{{ row.node.problems }}</span>\n <span [id]=\"problems(row.node)\" hidden>{{ t()('outline.problems', { count: row.node.problems }) }}</span>\n }\n @if (row.node.overflows) {\n <!-- What the canvas marks on a box too wide for its place, said where a keyboard is. -->\n <span [id]=\"overflow(row.node)\" hidden>{{ t()('canvas.overflow') }}</span>\n }</div>\n } @empty {\n <span>{{ t()('outline.empty') }}</span>\n }\n </div>\n }\n }\n `,\n})\nexport class ReportOutline {\n protected readonly root = inject(ReportEditorRoot)\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef)\n protected readonly t = this.root.t\n protected readonly regions = computed(() => this.root.state().outline.map((region) => ({ region: region.region, label: region.label, rows: rows(region.nodes) })))\n // ES2018, as ng-packagr compiles the published sources: no flatMap.\n private readonly all = computed(() => this.regions().reduce<OutlineNode[]>((nodes, region) => nodes.concat(region.rows.map((row) => row.node)), []))\n /** The row Tab lands on: the selected one, else the first; none when the tree is empty. */\n protected readonly stop = computed(() => {\n const all = this.all()\n return (all.find((node) => node.selected) ?? all[0])?.key\n })\n\n protected problems(node: OutlineNode): string {\n return `${this.root.id}-problems-${node.key}`\n }\n\n protected overflow(node: OutlineNode): string {\n return `${this.root.id}-overflow-${node.key}`\n }\n\n /** The ids of what describes a row: how many problems it has, and that it is wider than its place. */\n protected described(node: OutlineNode): string | null {\n const ids = [...(node.problems > 0 ? [this.problems(node)] : []), ...(node.overflows ? [this.overflow(node)] : [])]\n return ids.length === 0 ? null : ids.join(' ')\n }\n\n protected select(node: OutlineNode): void {\n this.root.dispatch({ type: 'select', id: node.id, ...(node.column === undefined ? {} : { column: node.column }) }, { to: 'selection' })\n }\n\n /** Focus that arrives on a row -- by Tab, or put there after an undo -- selects it, so the properties beside it are the focused row's. */\n protected focused(node: OutlineNode): void {\n if (!node.selected) this.root.dispatch({ type: 'select', id: node.id, ...(node.column === undefined ? {} : { column: node.column }) })\n }\n\n protected drag(node: OutlineNode, event: DragEvent): void {\n this.root.pickUp(event, { id: node.id }, node.label)\n }\n\n /**\n * The place beside the row the pointer is over: before it over its upper\n * half, after it over its lower half. A row with no such place -- the one\n * being moved, a table's column -- takes no drop, and says so to the\n * browser by leaving the dragover alone.\n */\n protected over(event: DragEvent): void {\n const drag = this.root.state().drag\n if (drag?.via !== 'pointer') return\n const element = (event.target as Element).closest('[role=\"treeitem\"]')\n const node = element === null ? undefined : this.all()[[...this.host.nativeElement.querySelectorAll('[role=\"treeitem\"]')].indexOf(element)]\n let over: number | null = null\n if (element !== null && node !== undefined && node.column === undefined) {\n const box = element.getBoundingClientRect()\n over = targetBeside(this.root.state().dropTargets, node.id, event.clientY < box.top + box.height / 2 ? 'before' : 'after')\n }\n if (over !== null) event.preventDefault()\n if (over !== drag.over) this.root.dispatch({ type: 'updateDrag', over })\n }\n}\n","/**\n * The file input Add image… opens (0033): hidden, outside the\n * accessibility tree, never given focus, taking what the editor says the\n * host keeps. The palette draws Add image… beside it and calls `open`.\n *\n * `open` sends `chooseImage` and, when the editor will take a file now,\n * calls the input's `click()` at once, in the same activation -- a click,\n * Enter or Space -- which opens the platform's chooser; awaiting anything\n * first would lose the activation, and the browser would open nothing.\n *\n * On the input's change the file is taken into a local before `value` is\n * cleared, because in a browser clearing it empties `files`; it is cleared\n * so that the same file chosen again is a change again. A chooser closed\n * without a file changes nothing, and nothing is sent. What the file is,\n * and whether it is added, is the editor's to say, in the live region.\n */\nimport { Directive, ElementRef, inject } from '@angular/core'\nimport { ReportEditorRoot } from './root'\n\n@Directive({\n selector: 'input[reportImageChooser]',\n exportAs: 'reportImageChooser',\n host: {\n type: 'file',\n hidden: '',\n '[accept]': 'root.state().images.accept',\n '(change)': 'take()',\n },\n})\nexport class ReportImageChooser {\n protected readonly root = inject(ReportEditorRoot)\n private readonly input = inject<ElementRef<HTMLInputElement>>(ElementRef)\n\n /** Add image… pressed: the chooser opened, or the live region saying why not. */\n open(): void {\n if (this.root.dispatch({ type: 'chooseImage' }).ok) this.input.nativeElement.click()\n }\n\n protected take(): void {\n const input = this.input.nativeElement\n const file = input.files?.[0]\n input.value = ''\n if (file !== undefined) void this.root.editor().addImage(file)\n }\n}\n","/**\n * The palette: one button per kind of component the report format has.\n *\n * Activating one -- a click, Enter or Space -- opens the place chooser for\n * that kind, which is the keyboard's path for the drag (formancy.ai 0046).\n * Dragging one onto the design view is the pointer's. A kind the report\n * cannot hold yet stays in the list, `aria-disabled` and described by what\n * to declare first, so it is found rather than missed; activating it\n * announces the same.\n *\n * Where the host keeps images, Add image… stands last (0033): a palette\n * item of no kind, which starts no drag but opens the file chooser beside\n * it (`image-chooser.ts`), unavailable and described by why while the\n * editor takes no file, and busy while one is being added.\n */\nimport { ChangeDetectionStrategy, Component, inject } from '@angular/core'\nimport type { PaletteEntry } from '@formancy/report-builder-core'\nimport { ReportImageChooser } from './image-chooser'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'div[reportPalette]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ReportImageChooser],\n host: {\n role: 'group',\n 'data-report-part': 'palette',\n '[attr.aria-label]': 't()(\"pane.palette\")',\n },\n template: `\n @for (entry of state().palette; track entry.kind) {\n <button\n type=\"button\"\n data-report-part=\"palette-item\"\n draggable=\"true\"\n [attr.data-kind]=\"entry.kind\"\n [attr.aria-disabled]=\"entry.component === null ? 'true' : null\"\n [attr.aria-describedby]=\"entry.unavailable === undefined ? null : why(entry)\"\n (click)=\"choose(entry, $event)\"\n (dragstart)=\"drag(entry, $event)\"\n (dragend)=\"root.dragEnded()\"\n >{{ entry.label }}@if (entry.unavailable !== undefined) {<span [id]=\"why(entry)\" hidden>{{ entry.unavailable }}</span>}</button>\n }\n @if (state().images.store) {\n <button\n type=\"button\"\n data-report-part=\"palette-item\"\n [attr.aria-disabled]=\"state().can.addImage ? null : 'true'\"\n [attr.aria-describedby]=\"state().images.unavailable === undefined ? null : addWhy\"\n [attr.aria-busy]=\"state().images.adding === null ? null : 'true'\"\n (click)=\"file.open()\"\n >{{ t()('images.add') }}@if (state().images.unavailable !== undefined) {<span [id]=\"addWhy\" hidden>{{ state().images.unavailable }}</span>}</button>\n <input reportImageChooser #file=\"reportImageChooser\" />\n }\n `,\n})\nexport class ReportPalette {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n protected readonly addWhy = `${this.root.id}-unavailable-add-image`\n\n protected why(entry: PaletteEntry): string {\n return `${this.root.id}-unavailable-${entry.kind}`\n }\n\n protected choose(entry: PaletteEntry, event: Event): void {\n this.root.choosePlace({ kind: entry.kind }, event.currentTarget as HTMLElement)\n }\n\n protected drag(entry: PaletteEntry, event: DragEvent): void {\n this.root.pickUp(event, { kind: entry.kind }, entry.label)\n }\n}\n","/**\n * The place chooser: the keyboard's path for every drag (formancy.ai 0046).\n *\n * While a person chooses where to put something by keyboard, this is a\n * dialog named for what is being placed, with a button per place the\n * session accepts -- report-core's `validLocations`, named by\n * report-builder-core -- and a Cancel button. It floats over the outline\n * pane, a pane of the workbench's own, so the design view beside it stays\n * in sight. Focus moves to the first place when it opens, or to Cancel when\n * there is none, which the dialog's description then explains; the place a\n * button stands for is drawn on the canvas while the button has focus.\n * Choosing one puts focus on the outline row of what was placed; Cancel, or\n * Escape, puts it back on what opened the chooser. It is not modal: the\n * rest of the editor stays usable while it is open.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport type { DropTarget } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'div[reportPlaces]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n 'data-report-part': 'places',\n // The workbench dresses a pane's buttons; idle, the chooser is no pane,\n // because the pane's display would override \\`hidden\\`.\n '[class.wb-pane]': 'choosing() !== null',\n '[hidden]': 'choosing() === null',\n '[attr.role]': 'choosing() === null ? null : \"dialog\"',\n // Named in the editor's words, as the header says, never after the\n // header, whose name a host's stylesheet could set in capitals.\n '[attr.aria-label]': 'choosing()?.title ?? null',\n '[attr.aria-describedby]': 'choosing()?.nowhere === undefined ? null : nowhere',\n },\n template: `\n @if (choosing(); as drag) {\n <header>{{ drag.title }}</header>\n @if (drag.nowhere !== undefined) {\n <p class=\"wb-problem\" [id]=\"nowhere\">{{ drag.nowhere }}</p>\n }\n @for (target of state().dropTargets; track target.index) {\n <button type=\"button\" data-report-part=\"place\" (focus)=\"show(target)\" (click)=\"root.place(drag.subject, target)\">{{ target.label }}</button>\n }\n <button type=\"button\" (click)=\"root.cancelPlacing()\">{{ t()('places.cancel') }}</button>\n }\n `,\n})\nexport class ReportPlaces {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n /** The drag a keyboard is choosing a place for; a pointer's is drawn on the canvas instead. */\n protected readonly choosing = computed(() => {\n const drag = this.state().drag\n return drag?.via === 'keyboard' ? drag : null\n })\n protected readonly nowhere = `${this.root.id}-nowhere`\n\n protected show(target: DropTarget): void {\n this.root.dispatch({ type: 'updateDrag', over: target.index })\n }\n}\n","/**\n * The problems: report-core's diagnostics, one button each, named by\n * severity and what it is about, and described by its sentence. Activating\n * one selects what it is about and puts focus on that outline row, so an\n * error message leads to the component it names (plan 8); one about the\n * report as a whole shows the report's own properties.\n *\n * The list is not a tab stop of its own: the toolbar's Problems button\n * moves focus to it, so what is said first is how many there are.\n *\n * Each entry is tracked by what it is (`DiagnosticEntry.key`), never by its\n * place in the list: a problem listed before the one the keyboard is on\n * leaves that one's button, and the keyboard, on the problem they were on.\n */\nimport { ChangeDetectionStrategy, Component, inject } from '@angular/core'\nimport type { DiagnosticEntry } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'div[reportProblems]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <ul data-report-part=\"diagnostics\" tabindex=\"-1\" [attr.aria-label]=\"t()('pane.problems')\">\n @for (entry of state().diagnostics; track entry.key) {\n <li data-report-part=\"diagnostic\" [attr.data-severity]=\"entry.severity\">\n <button type=\"button\" [attr.aria-describedby]=\"message($index)\" (click)=\"follow(entry)\">{{ entry.label }}</button>\n <div [id]=\"message($index)\">{{ entry.message }}</div>\n </li>\n }\n </ul>\n @if (state().diagnostics.length === 0) {\n <p>{{ t()('problems.none') }}</p>\n }\n `,\n})\nexport class ReportProblems {\n private readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n\n protected message(index: number): string {\n return `${this.root.id}-problem-${String(index)}`\n }\n\n protected follow(entry: DiagnosticEntry): void {\n const target = entry.target\n if (target === null) this.root.dispatch({ type: 'select', id: null })\n else this.root.dispatch({ type: 'select', ...target }, { to: 'selection' })\n }\n}\n","/**\n * The report's images, listed under its own properties (0033): a group\n * named by the catalogue, with a row per image the report declares -- its\n * label as text, and a Remove named after the image.\n *\n * A Remove whose image something draws is `aria-disabled`, described by\n * what draws it, and still sends `removeImage`, so the live region says\n * why nothing happened. One that removed its image takes its own button\n * away, so the keyboard goes to the first field, as the way back to the\n * report's properties takes it; a refused one leaves it where it is.\n */\nimport { ChangeDetectionStrategy, Component, inject } from '@angular/core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'div[reportImageLibrary]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n role: 'group',\n '[attr.aria-label]': 'root.t()(\"images.heading\")',\n },\n template: `\n @for (image of root.state().images.assets; track image.id; let at = $index) {\n <div data-report-part=\"property\">\n <span>{{ image.label }}</span>\n <button\n type=\"button\"\n [attr.aria-label]=\"image.removeLabel\"\n [attr.aria-disabled]=\"image.inUse === undefined ? null : 'true'\"\n [attr.aria-describedby]=\"image.inUse === undefined ? null : why(at)\"\n (click)=\"remove(image.id)\"\n >{{ root.t()('images.remove') }}@if (image.inUse !== undefined) {<span [id]=\"why(at)\" hidden>{{ image.inUse }}</span>}</button>\n </div>\n }\n `,\n})\nexport class ReportImageLibrary {\n protected readonly root = inject(ReportEditorRoot)\n\n protected why(at: number): string {\n return `${this.root.id}-image-${String(at)}-in-use`\n }\n\n protected remove(asset: string): void {\n this.root.attempt({ type: 'removeImage', asset }, { to: 'pane', panel: 'properties' })\n }\n}\n","/**\n * The properties of what is selected, or of the report when nothing is: a\n * form named by the pane's heading, with one native control per field,\n * labelled by the field's label, with the role report-builder-core's\n * `PROPERTY_ROLES` gives its kind -- the control is chosen from that role,\n * so the two cannot disagree -- and required where the field is.\n *\n * A field commits when it changes: a text on leaving it, or on Enter in a\n * single-line one; a select or a checkbox at once. A value given back as it\n * already stands is not sent, so the change event a browser fires after\n * Enter commits nothing twice. Escape in a typed field gives back what the\n * report holds, so leaving it afterwards commits nothing. A refused value\n * stays as typed, marked invalid and described by the reason, which is\n * shown under it; the editor keeps both, so they survive a re-render.\n * Under the report's own fields, its images (`image-library.ts`, 0033).\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport { PROPERTY_ROLES } from '@formancy/report-builder-core'\nimport type { PropertyField } from '@formancy/report-builder-core'\nimport { ReportImageLibrary } from './image-library'\nimport { ReportEditorRoot } from './root'\n\n/** The native control for a role: a textbox is a text input, a spinbutton a number input. */\nconst CONTROLS = { textbox: 'text', spinbutton: 'number', combobox: 'select', checkbox: 'checkbox' } as const\n\ntype Control = (typeof CONTROLS)[keyof typeof CONTROLS] | 'textarea'\n\ninterface Shown {\n readonly field: PropertyField\n readonly control: Control\n readonly id: string\n readonly errorId: string | null\n}\n\n@Component({\n selector: 'form[reportProperties]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ReportImageLibrary],\n host: {\n 'data-report-part': 'properties',\n '[attr.aria-label]': 'root.state().properties.heading',\n // Enter in a single-line field commits it; the browser's implicit submission would reload the page.\n '(submit)': '$event.preventDefault()',\n },\n template: `\n @for (shown of shown(); track shown.id) {\n <div data-report-part=\"property\" [attr.data-kind]=\"shown.field.kind\">\n <label [attr.for]=\"shown.id\">{{ shown.field.label }}</label>\n @switch (shown.control) {\n @case ('textarea') {\n <textarea\n [id]=\"shown.id\"\n [value]=\"shown.field.value\"\n [required]=\"shown.field.required\"\n [attr.placeholder]=\"shown.field.placeholder ?? null\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).value)\"\n (keydown.escape)=\"giveBack(shown.field, $event)\"\n ></textarea>\n }\n @case ('checkbox') {\n <input\n type=\"checkbox\"\n [id]=\"shown.id\"\n [checked]=\"shown.field.value === true\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).checked)\"\n />\n }\n @case ('select') {\n <select\n [id]=\"shown.id\"\n [required]=\"shown.field.required\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).value)\"\n >\n @for (option of shown.field.options ?? []; track option.value) {\n <option [value]=\"option.value\" [selected]=\"option.value === shown.field.value\">{{ option.label }}</option>\n }\n </select>\n }\n @default {\n <input\n [type]=\"shown.control\"\n [attr.step]=\"shown.control === 'number' ? 'any' : null\"\n [id]=\"shown.id\"\n [value]=\"shown.field.value\"\n [required]=\"shown.field.required\"\n [attr.placeholder]=\"shown.field.placeholder ?? null\"\n [attr.aria-invalid]=\"shown.errorId === null ? null : 'true'\"\n [attr.aria-describedby]=\"shown.errorId\"\n (change)=\"commit(shown.field, $any($event.target).value)\"\n (keydown.enter)=\"enter(shown.field, $event)\"\n (keydown.escape)=\"giveBack(shown.field, $event)\"\n />\n }\n }\n @if (shown.errorId !== null) {\n <p data-report-part=\"property-error\" class=\"wb-problem\" [id]=\"shown.errorId\">{{ shown.field.error }}</p>\n }\n </div>\n }\n @if (root.state().selection === null && root.state().images.assets.length > 0) {\n <div reportImageLibrary></div>\n }\n `,\n})\nexport class ReportProperties {\n protected readonly root = inject(ReportEditorRoot)\n\n /**\n * Each field with its control and ids. The ids carry whose fields these\n * are, and the rows are tracked by them, so a field of the next selection\n * is a new control rather than one still holding what was typed into the\n * last selection's.\n */\n protected readonly shown = computed<readonly Shown[]>(() => {\n const { selection, properties } = this.root.state()\n const owner = selection === null ? 'report' : `${selection.id}${selection.column === undefined ? '' : `-${selection.column}`}`\n return properties.fields.map((field, index) => {\n const id = `${this.root.id}-${owner}-${String(index)}`\n const control: Control = field.kind === 'multiline' ? 'textarea' : CONTROLS[PROPERTY_ROLES[field.kind]]\n return { field, control, id, errorId: field.error === undefined ? null : `${id}-error` }\n })\n })\n\n protected commit(field: PropertyField, value: string | boolean): void {\n // The field as the editor has it now: an Enter's commit has landed by the time the browser's change event follows it.\n const now = this.root.state().properties.fields.find((candidate) => candidate.key === field.key)\n if (now !== undefined && now.value === value) return\n this.root.dispatch({ type: 'setProperty', key: field.key, value })\n }\n\n protected enter(field: PropertyField, event: Event): void {\n event.preventDefault()\n this.commit(field, (event.target as HTMLInputElement).value)\n }\n\n /** Escape: what the report holds, back in the field, so nothing typed since is committed when it is left. */\n protected giveBack(field: PropertyField, event: Event): void {\n const now = this.root.state().properties.fields.find((candidate) => candidate.key === field.key) ?? field\n ;(event.target as HTMLInputElement | HTMLTextAreaElement).value = String(now.value)\n }\n}\n","/**\n * The live region: what the last action did, or why it did nothing, in the\n * editor's words.\n *\n * Shown, not hidden, because a sighted keyboard user needs the same\n * confirmation. Each announcement is a new element, keyed by the editor's\n * count of them, so saying the same words twice -- \"Nothing to undo.\" on a\n * second Ctrl+Z -- is announced twice rather than taken for no change.\n */\nimport { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'\nimport { ReportEditorRoot } from './root'\n\n@Component({\n selector: 'p[reportStatus]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { role: 'status', 'data-report-part': 'status' },\n template: `@for (said of said(); track said.sequence) {<span>{{ said.text }}</span>}`,\n})\nexport class ReportStatus {\n private readonly root = inject(ReportEditorRoot)\n protected readonly said = computed(() => {\n const status = this.root.state().status\n return status.text === '' ? [] : [status]\n })\n}\n","/**\n * The toolbar: undo and redo, the keyboard's moves, the zoom, and the panes\n * a narrow screen shows one at a time.\n *\n * One tab stop, with the arrow keys between its buttons (the toolbar\n * pattern), stepping the way the page reads; an arrow held with a modifier\n * is the browser's or the screen reader's. A button whose action has\n * nowhere to go says so with `aria-disabled` and stays focusable, so\n * pressing Redo until there is nothing left to redo does not drop focus to\n * the page -- where the next Ctrl+Z would reach nothing -- and pressing it\n * again still asks the editor, which says why nothing happened.\n */\nimport { ChangeDetectionStrategy, Component, computed, ElementRef, inject, signal } from '@angular/core'\nimport type { EditorAction, EditorPanel, EditorState, EditorText } from '@formancy/report-builder-core'\nimport { ReportEditorRoot } from './root'\n\n/** What a tool does: an action for the editor, the place chooser for the selection, or a pane. */\ntype Use = { readonly action: EditorAction } | { readonly placeSelection: true } | { readonly pane: EditorPanel }\n\ninterface Tool {\n readonly label: string\n readonly use: Use\n readonly available: boolean\n /** What undo or redo would take back. */\n readonly title: string | null\n}\n\nfunction tools(state: EditorState, t: EditorText): Tool[] {\n const { history, can } = state\n const tool = (label: Parameters<EditorText>[0], use: Use, available: boolean, title: string | null = null): Tool => ({ label: t(label), use, available, title })\n const act = (action: EditorAction): Use => ({ action })\n return [\n tool('action.undo', act({ type: 'undo' }), history.canUndo, history.undoLabel === null ? null : t('action.undoWhat', { label: history.undoLabel })),\n tool('action.redo', act({ type: 'redo' }), history.canRedo, history.redoLabel === null ? null : t('action.redoWhat', { label: history.redoLabel })),\n tool('action.moveUp', act({ type: 'moveUp' }), can.moveUp),\n tool('action.moveDown', act({ type: 'moveDown' }), can.moveDown),\n tool('action.indent', act({ type: 'indent' }), can.indent),\n tool('action.outdent', act({ type: 'outdent' }), can.outdent),\n tool('action.moveTo', { placeSelection: true }, can.moveTo),\n tool('action.duplicate', act({ type: 'duplicate' }), can.duplicate),\n tool('action.delete', act({ type: 'delete' }), can.delete),\n tool('action.zoomOut', act({ type: 'zoomOut' }), can.zoomOut),\n tool('action.zoomIn', act({ type: 'zoomIn' }), can.zoomIn),\n tool('action.zoomReset', act({ type: 'setZoom', zoom: 1 }), can.zoomReset),\n tool('pane.outline', { pane: 'outline' }, true),\n tool('pane.canvas', { pane: 'canvas' }, true),\n tool('pane.properties', { pane: 'properties' }, true),\n tool('pane.problems', { pane: 'diagnostics' }, true),\n ]\n}\n\n@Component({\n selector: 'div[reportToolbar]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n role: 'toolbar',\n 'data-report-part': 'toolbar',\n class: 'wb-tools',\n '[attr.aria-label]': 't()(\"toolbar.label\")',\n '(keydown)': 'along($event)',\n },\n template: `\n @for (tool of tools(); track tool.label; let at = $index) {\n @if (at === zoomAt()) {\n <!-- The live region already says \"Zoom 125%.\"; the readout does not say it twice. -->\n <output data-report-part=\"zoom\" aria-live=\"off\" [attr.aria-label]=\"t()('zoom.label')\">{{ state().zoomLabel }}</output>\n }\n <button\n type=\"button\"\n [attr.aria-disabled]=\"tool.available ? null : 'true'\"\n [attr.title]=\"tool.title\"\n [tabIndex]=\"at === stop() ? 0 : -1\"\n (focus)=\"stop.set(at)\"\n (click)=\"use(tool, $event)\"\n >{{ tool.label }}</button>\n }\n `,\n})\nexport class ReportToolbar {\n private readonly root = inject(ReportEditorRoot)\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n protected readonly tools = computed(() => tools(this.state(), this.t()))\n /** Where the zoom's readout stands: just before Zoom in. */\n protected readonly zoomAt = computed(() => this.tools().findIndex((tool) => 'action' in tool.use && tool.use.action.type === 'zoomIn'))\n /** The button Tab lands on: the one last focused, Undo at first. */\n protected readonly stop = signal(0)\n\n protected use(tool: Tool, event: Event): void {\n const use = tool.use\n if ('pane' in use) return this.root.showPane(use.pane)\n // Every other unavailable tool still asks, and the editor says why not;\n // this one has no component to place, only a table's column, or nothing.\n if ('placeSelection' in use) {\n const selection = this.state().selection\n if (tool.available && selection !== null) this.root.choosePlace({ id: selection.id }, event.currentTarget as HTMLElement)\n return\n }\n this.root.dispatch(use.action)\n }\n\n protected along(event: KeyboardEvent): void {\n if (event.altKey || event.ctrlKey || event.metaKey) return\n const buttons = [...this.host.nativeElement.querySelectorAll<HTMLElement>('button')]\n // Only its buttons take focus, so the key came from one of them.\n const at = buttons.findIndex((button) => button === event.target)\n // → is the next tool where the page reads left to right, and the one before where it reads right to left.\n const forwards = this.host.nativeElement.closest('[dir]')?.getAttribute('dir') === 'rtl' ? -1 : 1\n const count = buttons.length\n const to = new Map([\n ['ArrowRight', (at + forwards + count) % count],\n ['ArrowLeft', (at - forwards + count) % count],\n ['Home', 0],\n ['End', count - 1],\n ]).get(event.key)\n if (to === undefined) return\n event.preventDefault()\n buttons[to]?.focus()\n }\n}\n","/**\n * `<report-builder [editor]=\"editor\" />`: the whole editor, in the\n * workbench's three panes, with a bar above them and one below.\n *\n * The element is the editor's root (`ReportEditorRoot`, as a host\n * directive), a region named \"Report editor\". Its children, as the React\n * builder's are:\n *\n * - a bar with the report's title and the toolbar, which on a narrow screen\n * is what switches between the panes, so it stands in none of them;\n * - the palette over the outline -- with no row in it, an empty tree and\n * the sentence that says so -- with the place chooser floating over them\n * while a keyboard chooses a place;\n * - the design view, or, while the editor's `view` is the host's, the\n * host's view in its place: the template the host gave as\n * `<ng-template reportHostView>`, stamped into a bare region named by the\n * editor's `hostView` -- no workbench pane, so no rule of the builder's\n * dresses what the host drew, and its keys are the host's;\n * - the properties and the problems, sharing the third column. On a narrow\n * screen report-builder.css shows the one pane the state's `panel` names,\n * so the column says it is whichever of the two is asked for, and each\n * half carries its own name for the other to be hidden by;\n * - a bar with the live region.\n *\n * Each side pane's header has a Hide, named after the pane, which gives the\n * design view its room and the keyboard. A pane the state says is hidden\n * is not drawn, and the third column goes when both its halves are.\n *\n * A host that wants another arrangement puts `[reportEditor]` on its own\n * element and the parts inside it, as this template does.\n */\nimport { ChangeDetectionStrategy, Component, computed, contentChild, inject } from '@angular/core'\nimport type { HideablePanel } from '@formancy/report-builder-core'\nimport { ReportCanvas } from './canvas'\nimport { ReportHostOutlet, ReportHostView } from './host-view'\nimport { ReportOutline } from './outline'\nimport { ReportPalette } from './palette'\nimport { ReportPlaces } from './places'\nimport { ReportProblems } from './problems'\nimport { ReportProperties } from './properties'\nimport { ReportEditorRoot } from './root'\nimport { ReportStatus } from './status'\nimport { ReportToolbar } from './toolbar'\n\n@Component({\n selector: 'report-builder',\n changeDetection: ChangeDetectionStrategy.OnPush,\n hostDirectives: [{ directive: ReportEditorRoot, inputs: ['reportEditor: editor'] }],\n imports: [ReportCanvas, ReportHostOutlet, ReportOutline, ReportPalette, ReportPlaces, ReportProblems, ReportProperties, ReportStatus, ReportToolbar],\n template: `\n <div class=\"wb-pane\">\n <header>\n <span data-report-part=\"title\">{{ state().document.title }}</span>\n <div reportToolbar></div>\n </header>\n </div>\n @if (shows('outline')) {\n <section class=\"wb-pane\" data-pane=\"outline\">\n <header>\n <span>{{ t()('pane.outline') }}</span>\n <button type=\"button\" data-report-part=\"hide-pane\" [attr.aria-label]=\"t()('action.hidePane', { pane: t()('pane.outline') })\" (click)=\"root.hidePane('outline')\">{{ t()('action.hide') }}</button>\n </header>\n <div class=\"wb-body\">\n <div reportPalette></div>\n <div reportOutline></div>\n @if (empty()) {\n <p data-report-part=\"outline-empty\" [id]=\"root.outlineEmpty\">{{ t()('outline.empty') }}</p>\n }\n </div>\n <div reportPlaces></div>\n </section>\n }\n @if (state().view === 'host') {\n <section data-pane=\"canvas\" data-report-part=\"view\" tabindex=\"-1\" [attr.aria-label]=\"state().hostView?.name\">\n <ng-container [reportHostOutlet]=\"hostView()?.template ?? null\"></ng-container>\n </section>\n } @else {\n <section class=\"wb-pane wb-canvas\" data-pane=\"canvas\">\n <header>{{ t()('pane.canvas') }}</header>\n <div class=\"wb-body\">\n <section reportCanvas></section>\n </div>\n </section>\n }\n @if (shows('properties') || shows('diagnostics')) {\n <section class=\"wb-pane\" [attr.data-pane]=\"state().panel === 'diagnostics' || !shows('properties') ? 'diagnostics' : 'properties'\">\n @if (shows('properties')) {\n <header data-pane=\"properties\">\n <span>{{ state().properties.heading }}</span>\n @if (state().selection !== null) {\n <button type=\"button\" (click)=\"root.dispatch({ type: 'select', id: null }, { to: 'pane', panel: 'properties' })\">{{ t()('properties.report') }}</button>\n }\n <button type=\"button\" data-report-part=\"hide-pane\" [attr.aria-label]=\"t()('action.hidePane', { pane: t()('pane.properties') })\" (click)=\"root.hidePane('properties')\">{{ t()('action.hide') }}</button>\n </header>\n <div class=\"wb-body\" data-pane=\"properties\">\n <form reportProperties></form>\n </div>\n }\n @if (shows('diagnostics')) {\n <header data-pane=\"diagnostics\">\n <!-- A status, so a change in how many problems there are is said\n without taking the person's place: \"Problems 2\". Named in\n words, never after its own heading, which the Studio sets in\n capitals that Chromium would put in the name. -->\n <div role=\"status\" [attr.aria-label]=\"t()('pane.problems')\">\n <span>{{ t()('pane.problems') }}</span>{{ count() > 0 ? ' ' : '' }}@if (count() > 0) {<span data-report-part=\"badge\" [attr.data-severity]=\"severity()\">{{ count() }}</span>}\n </div>\n <button type=\"button\" data-report-part=\"hide-pane\" [attr.aria-label]=\"t()('action.hidePane', { pane: t()('pane.problems') })\" (click)=\"root.hidePane('diagnostics')\">{{ t()('action.hide') }}</button>\n </header>\n <div class=\"wb-body\" data-pane=\"diagnostics\">\n <div reportProblems></div>\n </div>\n }\n </section>\n }\n <div class=\"wb-pane\">\n <p reportStatus></p>\n </div>\n `,\n})\nexport class ReportBuilder {\n protected readonly root = inject(ReportEditorRoot)\n protected readonly state = this.root.state\n protected readonly t = this.root.t\n protected readonly count = computed(() => this.state().diagnostics.length)\n /** The template the host gave as its view, if it gave one. */\n protected readonly hostView = contentChild(ReportHostView)\n /** No row in any region: the outline is an empty tree, and this says so beside it. */\n protected readonly empty = computed(() => this.state().outline.every((region) => region.nodes.length === 0))\n /** What colour the count is: an error's, when any problem is one. */\n protected readonly severity = computed(() => (this.state().diagnostics.some((entry) => entry.severity === 'error') ? 'error' : 'warning'))\n\n /** Whether the pane is drawn: every one the person has not hidden. */\n protected shows(panel: HideablePanel): boolean {\n return !this.state().hidden.includes(panel)\n }\n}\n"],"mappings":";;;AA2BA,SAAgB,kBAAkB,QAA4B;CAG5D,MAAM,QAAQ,mBAAmB,OAAM,CAAE,CAAC,MAAK,GA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AA,iBAAA,cAAc,GAAA,EAAA,UAAA,KAAA,CAAA;CAAA,CAAA,EAAA;AAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formancy/report-builder-angular",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Formancy Report Studio for Angular: the native report editor over report-builder-core and one report-core session, with signals.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -27,9 +27,9 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@formancy/report-builder-core": "0.1.0",
31
- "@formancy/report-core": "0.1.0",
32
- "@formancy/report-spec": "0.1.0",
30
+ "@formancy/report-builder-core": "0.2.0",
31
+ "@formancy/report-core": "0.2.0",
32
+ "@formancy/report-spec": "0.2.0",
33
33
  "tslib": "^2.8.0"
34
34
  },
35
35
  "peerDependencies": {
@@ -1,6 +1,30 @@
1
- import { CanvasBox, DiagnosticEntry, DragSubject, DropTarget, EditorAction, EditorOutcome, EditorPanel, EditorState, EditorText, OutlineNode, PaletteEntry, PropertyField, ReportEditor } from "@formancy/report-builder-core";
1
+ import { CanvasBox, DiagnosticEntry, DragSubject, DropTarget, EditorAction, EditorOutcome, EditorPanel, EditorState, EditorText, HideablePanel, OutlineNode, PaletteEntry, PropertyField, ReportEditor } from "@formancy/report-builder-core";
2
2
  import * as i0 from "@angular/core";
3
- import { Signal } from "@angular/core";
3
+ import { Signal, TemplateRef } from "@angular/core";
4
+ /** Marks the template a host gives `<report-builder>` as its view. */
5
+ export declare class ReportHostView {
6
+ readonly template: TemplateRef<unknown>;
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<ReportHostView, never>;
8
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ReportHostView, "ng-template[reportHostView]", never, {}, {}, never, never, true, never>;
9
+ }
10
+ /**
11
+ * Stamps the host's template where it stands, for as long as it stands
12
+ * there: the builder's template draws it only while the host's view is in
13
+ * the middle, and the view goes with the element when that ends.
14
+ */
15
+ declare class ReportHostOutlet {
16
+ readonly template: import("@angular/core").InputSignal<TemplateRef<unknown> | null>;
17
+ private readonly container;
18
+ constructor();
19
+ static ɵfac: i0.ɵɵFactoryDeclaration<ReportHostOutlet, never>;
20
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ReportHostOutlet, "[reportHostOutlet]", never, {
21
+ "template": {
22
+ "alias": "reportHostOutlet";
23
+ "required": true;
24
+ "isSignal": true;
25
+ };
26
+ }, {}, never, never, true, never>;
27
+ }
4
28
  /** Where focus goes once what an action changed has rendered. */
5
29
  type FocusAfter =
6
30
  /** The selected outline row, which focus follows (the tree pattern); the tree itself when nothing is selected. */
@@ -31,10 +55,18 @@ export declare class ReportEditorRoot {
31
55
  readonly id: string;
32
56
  /** The sentence beside an outline with no row, which describes the empty tree. */
33
57
  readonly outlineEmpty: string;
58
+ /** The panes the person hid, as report-builder.css reads them; no attribute when none is. */
59
+ protected readonly hidden: import("@angular/core").Signal<string | null>;
34
60
  private readonly host;
35
61
  private focusAfter;
36
62
  /** What opened the place chooser, for focus to go back to when it is cancelled. */
37
63
  private opener;
64
+ /** The element the keyboard last stood on in this builder, for a middle pane swapped from under it to hand the keyboard on. */
65
+ private lastFocused;
66
+ /** Whether that element stood in the properties form, for a row taken from under it to hand the keyboard to the first field. */
67
+ private lastInProperties;
68
+ /** What the middle pane showed at the last render: null before the first. */
69
+ private view;
38
70
  constructor();
39
71
  /**
40
72
  * Sends `action` to the editor, and moves focus as `focus` says once
@@ -44,6 +76,14 @@ export declare class ReportEditorRoot {
44
76
  * renders next.
45
77
  */
46
78
  dispatch(action: EditorAction, focus?: FocusAfter): EditorOutcome;
79
+ /**
80
+ * Sends `action`, and moves focus as `focus` says only when it was done:
81
+ * a refused one leaves the keyboard where the person pressed, the live
82
+ * region saying why -- a Remove of an image something draws (0033). The
83
+ * render the action causes comes after this returns, so it finds the
84
+ * focus asked for.
85
+ */
86
+ attempt(action: EditorAction, focus: FocusAfter): EditorOutcome;
47
87
  /**
48
88
  * Opens the place chooser for `subject`, remembering `opener` to come back
49
89
  * to. It floats over the outline pane, so that is the pane a narrow screen
@@ -75,9 +115,22 @@ export declare class ReportEditorRoot {
75
115
  private placedFrom;
76
116
  /** A pointer's drag let go of anywhere but a place: it ends, and nothing changes. After a drop there is none left to end. */
77
117
  dragEnded(): void;
78
- /** Shows `panel` on a narrow screen and takes focus into it, so the pane that appears is where the keyboard is. */
118
+ /** Shows `panel` -- on a narrow screen, or hidden -- and takes focus into it, so the pane that appears is where the keyboard is. */
79
119
  showPane(panel: EditorPanel): void;
120
+ /** Hides `panel`; its Hide goes with it, so focus goes to the design view that took its room. */
121
+ hidePane(panel: HideablePanel): void;
122
+ protected focused(event: FocusEvent): void;
80
123
  protected keydown(event: KeyboardEvent): void;
124
+ /**
125
+ * The middle pane swapped by the host -- its view placed or shown from
126
+ * outside, as the window crosses a width -- takes the keyboard along
127
+ * rather than drop it on the page: where the element it stood on went
128
+ * with the pane, and nothing has taken it since. So does an undo or a
129
+ * redo that takes away the row it stood on in the properties -- an
130
+ * image's Remove, the add undone or the remove redone: it goes to the
131
+ * first field, as a Remove that worked sends it.
132
+ */
133
+ private dropped;
81
134
  private moveFocus;
82
135
  static ɵfac: i0.ɵɵFactoryDeclaration<ReportEditorRoot, never>;
83
136
  static ɵdir: i0.ɵɵDirectiveDeclaration<ReportEditorRoot, "[reportEditor]", never, {
@@ -93,12 +146,16 @@ export declare class ReportBuilder {
93
146
  protected readonly state: import("@angular/core").Signal<import("@formancy/report-builder-core").EditorState>;
94
147
  protected readonly t: import("@angular/core").Signal<import("@formancy/report-builder-core").EditorText>;
95
148
  protected readonly count: import("@angular/core").Signal<number>;
149
+ /** The template the host gave as its view, if it gave one. */
150
+ protected readonly hostView: import("@angular/core").Signal<ReportHostView | undefined>;
96
151
  /** No row in any region: the outline is an empty tree, and this says so beside it. */
97
152
  protected readonly empty: import("@angular/core").Signal<boolean>;
98
153
  /** What colour the count is: an error's, when any problem is one. */
99
154
  protected readonly severity: import("@angular/core").Signal<"error" | "warning">;
155
+ /** Whether the pane is drawn: every one the person has not hidden. */
156
+ protected shows(panel: HideablePanel): boolean;
100
157
  static ɵfac: i0.ɵɵFactoryDeclaration<ReportBuilder, never>;
101
- static ɵcmp: i0.ɵɵComponentDeclaration<ReportBuilder, "report-builder", never, {}, {}, never, never, true, [{
158
+ static ɵcmp: i0.ɵɵComponentDeclaration<ReportBuilder, "report-builder", never, {}, {}, ["hostView"], never, true, [{
102
159
  directive: typeof ReportEditorRoot;
103
160
  inputs: {
104
161
  "reportEditor": "editor";
@@ -165,6 +222,7 @@ export declare class ReportPalette {
165
222
  protected readonly root: ReportEditorRoot;
166
223
  protected readonly state: import("@angular/core").Signal<import("@formancy/report-builder-core").EditorState>;
167
224
  protected readonly t: import("@angular/core").Signal<import("@formancy/report-builder-core").EditorText>;
225
+ protected readonly addWhy: string;
168
226
  protected why(entry: PaletteEntry): string;
169
227
  protected choose(entry: PaletteEntry, event: Event): void;
170
228
  protected drag(entry: PaletteEntry, event: DragEvent): void;