spell-ui 0.8.12 → 0.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-components.md +5 -3
- package/dist/{Dragging-B93hbRxF.js → Dragging-tHPSvf3G.js} +56 -13
- package/dist/Dragging-tHPSvf3G.js.map +1 -0
- package/dist/_spell-element/DOMElement.d.ts +8 -1
- package/dist/_spell-element/drawnWindow.d.ts +62 -0
- package/dist/_util/Dragging.d.ts +7 -0
- package/dist/components/components.types.d.ts +2 -0
- package/dist/components/ui-diagram/UIDiagram.d.ts +3 -0
- package/dist/components/ui-graph/GraphLayout.d.ts +54 -0
- package/dist/components/ui-graph/UIGraph.d.ts +355 -0
- package/dist/components/ui-graph/UIGraph.en.d.ts +137 -0
- package/dist/components/ui-graph/UIGraph.es.d.ts +48 -0
- package/dist/components/ui-graph/UIGraph.types.d.ts +193 -0
- package/dist/components/ui-graph/index.d.ts +5 -0
- package/dist/components/ui-json/UIJson.d.ts +275 -10
- package/dist/components/ui-json/UIJson.en.d.ts +148 -9
- package/dist/components/ui-json/UIJson.es.d.ts +34 -3
- package/dist/components/ui-json/index.d.ts +2 -2
- package/dist/components/ui-split-panel/UISplitPanel.d.ts +2 -16
- package/dist/components/ui-tree/UITree.d.ts +758 -26
- package/dist/components/ui-tree/UITree.en.d.ts +113 -3
- package/dist/components/ui-tree/UITree.es.d.ts +24 -0
- package/dist/components/ui-tree/UITree.types.d.ts +34 -0
- package/dist/components/ui-tree/UITreeItem.d.ts +40 -1
- package/dist/components/ui-tree/UITreeItem.en.d.ts +9 -0
- package/dist/components/ui-tree/UITreeItem.es.d.ts +2 -0
- package/dist/components/ui-tree/index.d.ts +3 -2
- package/dist/components/ui-tree-diagram/UITreeDiagram.d.ts +3 -0
- package/dist/{components.es-DEa8Ep42.js → components.es-DilRG1VO.js} +117 -9
- package/dist/components.es-DilRG1VO.js.map +1 -0
- package/dist/core.js +713 -671
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +97 -96
- package/dist/jsx.d.ts +489 -20
- package/dist/ui-diagram.js +2 -2
- package/dist/ui-diagram.js.map +1 -1
- package/dist/ui-graph.editor-DLsXPyby.js +5 -0
- package/dist/ui-graph.editor-DLsXPyby.js.map +1 -0
- package/dist/ui-graph.js +1295 -0
- package/dist/ui-graph.js.map +1 -0
- package/dist/ui-json.editor-BS-v1bqO.js +5 -0
- package/dist/ui-json.editor-BS-v1bqO.js.map +1 -0
- package/dist/ui-json.js +629 -32
- package/dist/ui-json.js.map +1 -1
- package/dist/ui-property-editor.js +3 -2
- package/dist/ui-property-editor.js.map +1 -1
- package/dist/ui-root.js +34 -3
- package/dist/ui-root.js.map +1 -1
- package/dist/ui-site-nav.js +4 -4
- package/dist/ui-site-nav.js.map +1 -1
- package/dist/ui-split-panel.js +31 -61
- package/dist/ui-split-panel.js.map +1 -1
- package/dist/ui-tree-diagram.js +1 -1
- package/dist/ui-tree-diagram.js.map +1 -1
- package/dist/ui-tree.editor-Bqsa0dYQ.js +5 -0
- package/dist/ui-tree.editor-Bqsa0dYQ.js.map +1 -0
- package/dist/ui-tree.js +1734 -237
- package/dist/ui-tree.js.map +1 -1
- package/dist/util/PaneSizes.d.ts +42 -0
- package/dist/util/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/Dragging-B93hbRxF.js.map +0 -1
- package/dist/components.es-DEa8Ep42.js.map +0 -1
- package/dist/ui-json.editor-BgZbrB_W.js +0 -5
- package/dist/ui-json.editor-BgZbrB_W.js.map +0 -1
- package/dist/ui-tree.editor-BoQztwdz.js +0 -5
- package/dist/ui-tree.editor-BoQztwdz.js.map +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/****************
|
|
2
|
+
* ### `PaneSizes`
|
|
3
|
+
* Sizes written as text, a comma list (`"20%, *, 380px"`), read into one `PaneSize` each:
|
|
4
|
+
* how `<ui-split-panel>` reads its `columns` / `rows`, and `<ui-tree>` its columns' `size`.
|
|
5
|
+
* - Each entry is one of:
|
|
6
|
+
* - a number, `px`, `em` or `rem`: fixed
|
|
7
|
+
* - `%`: a percent (of what, each element says)
|
|
8
|
+
* - `*`, or missing: an equal share of the percent the `%` entries leave
|
|
9
|
+
* - `auto`: as big as its content (`units: "auto"`)
|
|
10
|
+
* - A space after a comma is ignored (`commaList()`).
|
|
11
|
+
* - STATIC, plain data, no DOM: at the bottom of Spell UI (`spell/ui/util`), so both elements share ONE reader.
|
|
12
|
+
****************/
|
|
13
|
+
export declare class PaneSizes {
|
|
14
|
+
/**
|
|
15
|
+
* One `PaneSize` per pane from `spec`.
|
|
16
|
+
* - Cut or padded to `count`: a missing or unreadable entry counts as `*`.
|
|
17
|
+
* - `*` entries share the percent the `%` entries leave, equally (at least 1% each).
|
|
18
|
+
* - `source`: who's reading, for the warning an unreadable entry gets (`"<ui-split-panel>"`)
|
|
19
|
+
*/
|
|
20
|
+
static sizesFor(spec: string | undefined, count: number, { source }?: {
|
|
21
|
+
source?: string | undefined;
|
|
22
|
+
}): PaneSize[];
|
|
23
|
+
/**
|
|
24
|
+
* ONE entry of a spec, read: `undefined` for `*`, or for text that isn't a size, which is warned about.
|
|
25
|
+
* - For an element that gives each entry a meaning of its own (`<ui-tree>`'s columns: `*` is the token's width).
|
|
26
|
+
* - `source`: who's reading, for the warning
|
|
27
|
+
*/
|
|
28
|
+
static sizeFor(entry: string, { source }?: {
|
|
29
|
+
source?: string | undefined;
|
|
30
|
+
}): PaneSize | undefined;
|
|
31
|
+
/** `sizes` written back as text, the form `sizesFor()` reads: `"60%,40%,auto"`. */
|
|
32
|
+
static sizeText(sizes: readonly PaneSize[]): string;
|
|
33
|
+
/** Is `size` an `auto` one, as big as its content? */
|
|
34
|
+
static isAuto(size: PaneSize | undefined): boolean;
|
|
35
|
+
}
|
|
36
|
+
/** One pane's size, e.g. `{ value: 20, units: "%" }`. */
|
|
37
|
+
export type PaneSize = {
|
|
38
|
+
/** How much, in `units`. */
|
|
39
|
+
value: number;
|
|
40
|
+
/** `px`, `em`, `rem`, `%` or `auto` (its `value` unused). */
|
|
41
|
+
units: string;
|
|
42
|
+
};
|
package/dist/util/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* `afterSolidUpdate()`, `beforeNextPaint()`, `soon()`, `after()`, `every()`; and to wait: `waitUntil()`, `within()`
|
|
25
25
|
* - `Warnings` -- `ui`'s console warnings, its own
|
|
26
26
|
* - `TopLayerTip` -- a tooltip in the top layer, so no frame cuts it off
|
|
27
|
+
* - `PaneSizes` -- sizes as text (`"20%, *, auto"`), read one way by `<ui-split-panel>` and `<ui-tree>`
|
|
27
28
|
* - `LoadOnce` (`spell/util/LoadOnce`) -- a load per key, once per page, with a choice of what a failure does
|
|
28
29
|
*/
|
|
29
30
|
export * from '../_util/class';
|
|
@@ -33,6 +34,7 @@ export * from '../_util/number';
|
|
|
33
34
|
export * from '../_util/string';
|
|
34
35
|
export * from '../_util/util.types';
|
|
35
36
|
export * from '../_util/timing';
|
|
37
|
+
export * from './PaneSizes';
|
|
36
38
|
export * from './TopLayerTip';
|
|
37
39
|
export * from './Warnings';
|
|
38
40
|
export * from '../_util/LoadOnce';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spell-ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.14",
|
|
4
4
|
"description": "Beautiful, themeable, accessible components that load themselves on demand, for use in plain HTML or any framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/spell-app/spell",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Dragging-B93hbRxF.js","names":["__exportAll","Dragging_exports","Dragging","DRAG_COVER","element","options","event","listening","left","x","top","y","width","height","dx","dy","target","following","next","DRAGGING_Z_INDEX","DRAG_CURSOR","wasDragging","from","SLIDE_BACK_MS","SLIDE_BACK_EASING","type","hits","hit","under","at","lists","child","row","list","box","kind","span","other","taking","chain","rule","each","soon"],"sources":["../../src/util/Dragging.ts"],"sourcesContent":["import { beforeNextPaint, soon } from \"./timing\"\n\n/****************\n * ### `Dragging`\n * One drag of a view's element, from pointer down to pointer up: a mouse and a finger alike.\n *\n * - What it carries: the element, and its list's items after it, e.g. a tableau's face-up card and the cards on it.\n * - They follow the pointer by their `translate`, raised above the board,\n * with no transition meanwhile, so a page whose cards glide (Solitaire) still keeps up with it (epic `editor` I99).\n * - They ignore the pointer meanwhile, so what's under it can be found.\n * - Or what its owner says (`DragOptions.carried`), staying where it is (`follows: false`):\n * e.g. a task list's selected tasks, dimmed, while a line shows where they'd go\n * (`SpellElement`, epic `outline-spell` P30).\n * - Where it lands: the viewable list's element under the pointer, as `dropTargetAt()` finds it.\n * - It sends the web's own drag events, as `DragEvent`s with no `dataTransfer`,\n * so a page can follow it as it would the browser's drag and drop:\n * - on the dragged element: `dragstart`, `drag` as it moves, `dragend`\n * - on the list under the pointer: `dragenter`, `dragover` as it moves over it, `dragleave`, and `drop`\n * - What's being dragged meanwhile: `Dragging.current`.\n * - Why not the browser's own drag and drop (`draggable=\"true\"`):\n * it's patchy on phones, only a faded picture of one element follows the pointer, and it can't glide or slide back.\n * - A press that doesn't move past `DRAG_START_PX` is no drag: its click goes through as ever.\n * A real drag swallows the click that follows it.\n * - What happens on the drop is its owner's to say (`onDrop`), e.g. `SpellElement`'s:\n * the pile's `when a card is dropped on it`, else the program's `card-drop`.\n * - What still sits where it was dragged from afterwards, a drop nobody took, slides back.\n * - Escape cancels it (epic `debut` P27, Q47): everything slides back, and its owner hears `onCancel`,\n * as it does for a drag the browser takes away, or the window losing focus mid-drag (epic `language` T29).\n * - What moved is drawn again in its new list, and glides there from where it was dropped (`Glides`).\n * - A mouse drag covers the whole page with the closed hand, whatever is under it (`DRAG_COVER`).\n * - Or the cursor its owner says (`DragOptions.cursor`): a line that resizes keeps `col-resize` while it's dragged.\n * - A rule can't do that: nothing in a page's sheets reaches into every shadow root,\n * and the code editor sets its own cursor.\n * - A drag can leave finding its place to its owner (`DragOptions.placing`), e.g. the editor's, moving a part:\n * no list hears of it, and `placing` is told where the pointer is.\n * - Plain DOM: no Solid, no core. Its owner hands it the element and what to do.\n * - In util, not Spell UI's runtime: a runner's build may not reach into `spell/ui/runtime`.\n ****************/\nexport class Dragging {\n /** The drag in progress, if any: a list under the pointer asks it what's coming. */\n static current: Dragging | undefined\n\n /** What covers the page during a mouse drag, showing its cursor: made once, on the first use. */\n private static get cover(): HTMLElement {\n if (!Dragging.madeCover) {\n Dragging.madeCover = document.createElement(\"div\")\n Dragging.madeCover.style.cssText = DRAG_COVER\n }\n return Dragging.madeCover\n }\n private static madeCover: HTMLElement | undefined\n\n /** Was it pressed with a finger? No cursor to show, so no cover. */\n private readonly isTouch: boolean\n\n /** Start watching a press on `element`, `event` its `pointerdown`: a drag once it moves far enough. */\n constructor(\n readonly element: HTMLElement,\n event: PointerEvent,\n private readonly options: DragOptions\n ) {\n this.isTouch = event.pointerType === \"touch\"\n this.startX = event.clientX\n this.startY = event.clientY\n this.pointerId = event.pointerId\n this.pressedAt = element.getBoundingClientRect()\n const listening = { signal: this.listening.signal }\n window.addEventListener(\"pointermove\", this.onMove, listening)\n window.addEventListener(\"pointerup\", this.onUp, listening)\n window.addEventListener(\"pointercancel\", this.onCancel, listening)\n window.addEventListener(\"keydown\", this.onKey, { ...listening, capture: true })\n window.addEventListener(\"blur\", this.onBlur, listening)\n if (this.isTouch) window.addEventListener(\"touchmove\", this.onTouchMove, { ...listening, passive: false })\n }\n\n /** Where the press started. */\n private readonly startX: number\n private readonly startY: number\n /** Where the element was as it was pressed: where in it the press was, and its size (`heldBoxAt()`). */\n private readonly pressedAt: DOMRect\n /** The pointer pressing: a second finger is ignored. */\n private readonly pointerId: number\n /** Ends the window listeners. */\n private readonly listening = new AbortController()\n /** What's carried, once it's a drag: the element, then its list's items after it -- or what `options` says. */\n private moving: HTMLElement[] = []\n\n /** What's carried: the element first. */\n get carried(): readonly HTMLElement[] {\n return this.moving\n }\n\n /**\n * Where the dragged element would be with the pointer at (`x`, `y`), held where it was pressed:\n * grabbed near its bottom, it's mostly above the pointer.\n * - So a list placing it goes by the element, not the pointer: it lands under the pointer as it was held.\n */\n heldBoxAt(x: number, y: number): DOMRect {\n const { left, top, width, height } = this.pressedAt\n return new DOMRect(left + x - this.startX, top + y - this.startY, width, height)\n }\n\n /** Does what's carried follow the pointer? Else it stays where it is (`DragOptions.follows`). */\n get follows(): boolean {\n return this.options.follows !== false\n }\n\n /** The drop target under the pointer now, if any: it's had `dragenter`, and gets `dragleave` as the pointer leaves. */\n private over: HTMLElement | undefined\n\n /** The pointer moved: past `DRAG_START_PX`, a drag starts; during one, what's dragged follows it. */\n private readonly onMove = (event: PointerEvent) => {\n if (event.pointerId !== this.pointerId) return\n const dx = event.clientX - this.startX\n const dy = event.clientY - this.startY\n if (!this.moving.length) {\n if (Math.hypot(dx, dy) < DRAG_START_PX) return\n this.start()\n }\n if (this.follows) for (const element of this.moving) element.style.translate = `${dx}px ${dy}px`\n event.preventDefault()\n Dragging.send(this.element, \"drag\", event)\n if (this.options.placing) return this.options.placing(event.clientX, event.clientY)\n this.moveOver(Dragging.dropTargetAt(this.element, event.clientX, event.clientY), event)\n }\n\n /**\n * A finger pressing a draggable thing never scrolls the page: it drags.\n * - Its owner's `touch-action: none` should say so, but Chrome loses it over text whose parent draws no box of its own\n * (`display: contents`): slotted text, e.g. a card's letter in its `<ui-text>`, so the page scrolled under the finger\n * (epic `language` T157).\n * - Only while this press lasts: a finger anywhere else scrolls as ever.\n */\n private readonly onTouchMove = (event: TouchEvent) => {\n if (event.cancelable) event.preventDefault()\n }\n\n /** The pointer is over `target` now: `dragleave` on the one it left, `dragenter` on a new one, `dragover` on it. */\n private moveOver(target: HTMLElement | undefined, event: PointerEvent) {\n if (target !== this.over) {\n if (this.over) Dragging.send(this.over, \"dragleave\", event)\n this.over = target\n if (target) Dragging.send(target, \"dragenter\", event)\n }\n if (target) Dragging.send(target, \"dragover\", event)\n }\n\n /**\n * The drag starts: what's carried is raised, and leaves the pointer to what's under it --\n * unless it stays where it is.\n */\n private start() {\n const following: HTMLElement[] = []\n for (let next = this.element.nextElementSibling; next; next = next.nextElementSibling) {\n following.push(next as HTMLElement)\n }\n this.moving = this.options.carried ?? [this.element, ...following]\n if (this.follows) {\n for (const element of this.moving) {\n element.style.zIndex = DRAGGING_Z_INDEX\n element.style.pointerEvents = \"none\"\n // follows the pointer at once: a page's own `transition` on `translate` (Solitaire's cards glide) would trail it\n element.style.transition = \"none\"\n }\n }\n // no text selected as the pointer sweeps the page, as the browser's own drag selects none\n getSelection()?.removeAllRanges()\n document.documentElement.style.userSelect = \"none\"\n if (!this.isTouch) {\n Dragging.cover.style.cursor = this.options.cursor ?? DRAG_CURSOR\n document.body.append(Dragging.cover)\n }\n Dragging.current = this\n this.element.dispatchEvent(new DragEvent(\"dragstart\", { bubbles: true, composed: true }))\n }\n\n /** The pointer's let go: a drag drops where it is; a press with no drag is left to its click. */\n private readonly onUp = (event: PointerEvent) => {\n if (event.pointerId !== this.pointerId) return\n this.listening.abort()\n if (!this.moving.length) return\n Dragging.swallowNextClick()\n const target = this.options.placing ? undefined : Dragging.dropTargetAt(this.element, event.clientX, event.clientY)\n this.moveOver(target, event)\n try {\n if (target) Dragging.send(target, \"drop\", event)\n this.options.onDrop(target)\n } finally {\n // after the move is drawn: what's still here wasn't taken, and slides back\n beforeNextPaint(() => this.settle())\n }\n }\n\n /** The browser took the pointer away (a scroll, a system gesture): put everything back. */\n private readonly onCancel = (event: PointerEvent) => {\n if (event.pointerId !== this.pointerId) return\n this.cancel(event)\n }\n\n /** Escape, during a drag: put everything back, and swallow the key. */\n private readonly onKey = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || !this.moving.length) return\n event.preventDefault()\n event.stopPropagation()\n Dragging.swallowNextClick()\n this.cancel(event)\n }\n\n /**\n * The window lost focus mid-drag (another app, a window switch): put everything back.\n * - Its let-go may never reach the page, so the cover would stay up, swallowing every click, until the next press.\n */\n private readonly onBlur = (event: FocusEvent) => {\n if (this.moving.length) this.cancel(event)\n }\n\n /** The drag is cancelled: it leaves the list it's over, slides back, and its owner hears so (`onCancel`). */\n private cancel(event: PointerEvent | KeyboardEvent | FocusEvent) {\n this.listening.abort()\n const wasDragging = this.moving.length > 0\n if (this.over) Dragging.send(this.over, \"dragleave\", event)\n this.over = undefined\n this.settle()\n if (wasDragging) this.options.onCancel?.()\n }\n\n /** What's still where it was dragged from slides back, and takes the pointer again. */\n private settle() {\n for (const element of this.follows ? this.moving : []) {\n const from = element.style.translate\n element.style.translate = \"\"\n element.style.pointerEvents = \"\"\n element.style.zIndex = \"\"\n // its new place taken without a transition (read, so the browser has it), then the page's own back\n void getComputedStyle(element).translate\n element.style.transition = \"\"\n if (element.isConnected && from && from !== \"0px 0px\") {\n element.animate(\n [\n { translate: from, zIndex: DRAGGING_Z_INDEX },\n { translate: \"0 0\", zIndex: DRAGGING_Z_INDEX }\n ],\n {\n duration: SLIDE_BACK_MS,\n easing: SLIDE_BACK_EASING\n }\n )\n }\n }\n document.documentElement.style.userSelect = \"\"\n Dragging.cover.remove()\n if (Dragging.current === this) Dragging.current = undefined\n this.element.dispatchEvent(new DragEvent(\"dragend\", { bubbles: true, composed: true }))\n }\n\n /** Send drag event `type` to `target`, where `event`'s pointer is: a `DragEvent`, as the browser's own. */\n private static send(target: HTMLElement, type: string, event: PointerEvent | KeyboardEvent | FocusEvent) {\n const { clientX, clientY } = \"clientX\" in event ? event : { clientX: 0, clientY: 0 }\n target.dispatchEvent(new DragEvent(type, { bubbles: true, composed: true, cancelable: true, clientX, clientY }))\n }\n\n /**\n * The element under (`x`, `y`) that may take the drop, searching up from the topmost there, through shadow roots:\n * the first one `isDropTarget()` accepts -- `undefined` if none.\n * - Looked for in `element`'s own tree, where the board is (a runner's shadow root, or the page).\n * - One that won't take it, or a gap between lists: the one list of that row that would, if only one would\n * (`rowTargetAt()`), e.g. a card anywhere over a game's foundations lands on its own suit's.\n */\n static dropTargetAt(element: HTMLElement, x: number, y: number): HTMLElement | undefined {\n const root = element.getRootNode() as Document | ShadowRoot\n const hits = root.elementsFromPoint(x, y).filter((hit) => hit !== Dragging.cover)\n let under: HTMLElement | undefined\n for (const hit of hits) {\n under = Dragging.upFrom(hit).find((at) => Dragging.isDropTarget(at)) as HTMLElement | undefined\n if (under) break\n }\n if (under && Dragging.takesDrop(under)) return under\n return Dragging.rowTargetAt(hits, x, y, under) ?? under\n }\n\n /**\n * A row of lists of one kind is one place to drop, e.g. a game's foundations: the one list in it that would take\n * what's dragged -- `undefined` if none would, or more than one.\n * - The row: the lists side by side under the pointer, in the nearest element around it that holds lists,\n * of the kind it's over (its tag), or whose span it's in.\n */\n private static rowTargetAt(hits: Element[], x: number, y: number, under: HTMLElement | undefined) {\n for (const hit of hits) {\n for (const at of Dragging.upFrom(hit)) {\n const lists = [...at.children].filter((child) => Dragging.isDropTarget(child)) as HTMLElement[]\n if (lists.length < 2) continue\n const row = lists\n .map((list) => ({ list, box: list.getBoundingClientRect() }))\n .filter(({ box }) => box.top <= y && y <= box.bottom)\n const kind =\n under?.localName ??\n row.find(({ list }) => {\n const span = row.filter((other) => other.list.localName === list.localName).map(({ box }) => box)\n return Math.min(...span.map((box) => box.left)) <= x && x <= Math.max(...span.map((box) => box.right))\n })?.list.localName\n const taking = row.filter(({ list }) => list.localName === kind && Dragging.takesDrop(list))\n return taking.length === 1 ? taking[0]!.list : undefined\n }\n }\n return undefined\n }\n\n /** `element` and every element around it, up through shadow roots. */\n private static upFrom(element: Element): Element[] {\n const chain: Element[] = []\n for (let at: Element | null = element; at; at = at.parentElement ?? (at.getRootNode() as ShadowRoot).host ?? null) {\n chain.push(at)\n }\n return chain\n }\n\n /** May `element` take a drop? Yes if any owner's rule says so (`addDropRule()`). */\n static isDropTarget(element: Element): boolean {\n return Dragging.dropRules.some((rule) => rule.isDropTarget(element))\n }\n\n /** Would drop target `element` take what's dragged now? The rule that owns it says; with none, yes. */\n static takesDrop(element: Element): boolean {\n const rule = Dragging.dropRules.find((each) => each.isDropTarget(element))\n return rule ? rule.takesDrop(element) : true\n }\n\n /**\n * Add an owner's rule for what takes a drop, e.g. `SpellElement`'s: a viewable list's element.\n * - A rule, not a setting: each copy of a runtime on the page adds its own, and each knows only its own elements\n * (the editor's layout runs on a copy, beside the program's). One setting, the last copy's, would refuse the rest.\n */\n static addDropRule(rule: DropRule): void {\n Dragging.dropRules.push(rule)\n }\n private static readonly dropRules: DropRule[] = []\n\n /** The click a drag's pointer up makes is no click: swallowed, once, before anything hears it. */\n private static swallowNextClick() {\n const swallow = (event: Event) => {\n event.stopPropagation()\n event.preventDefault()\n }\n window.addEventListener(\"click\", swallow, { capture: true, once: true })\n // a pointer up off the element makes no click: stop waiting for one\n soon(() => window.removeEventListener(\"click\", swallow, { capture: true }))\n }\n}\n\n/** One owner's rule for what takes a drop: `Dragging.addDropRule()`. */\nexport type DropRule = {\n /** May `element` take a drop? Only the owner's own elements. */\n isDropTarget: (element: Element) => boolean\n /** Would `element`, one of its drop targets, take what's dragged now? */\n takesDrop: (element: Element) => boolean\n}\n\n/** How a drag goes: what its owner says. */\nexport type DragOptions = {\n /** What happens on the drop, on `target`, the list under the pointer -- `undefined` for none. */\n onDrop(target: HTMLElement | undefined): void\n /** The drag was cancelled before any drop: Escape, or the browser took the pointer away. */\n onCancel?(): void\n /** What's carried, the dragged element first; default the element and its list's items after it. */\n carried?: HTMLElement[]\n /** Does what's carried follow the pointer? Default yes; `false`: it stays where it is, dimmed by its owner. */\n follows?: boolean\n /** Its owner finds the place itself: told where the pointer is as it moves, and no list hears of the drag. */\n placing?(x: number, y: number): void\n /** The cursor over the whole page while it's dragged with a mouse, as CSS says it: default the closed hand. */\n cursor?: string\n}\n\n/** How far the pointer moves before a press is a drag, in pixels: less is a click. */\nexport const DRAG_START_PX = 6\n\n/** Above the board while dragged. */\nconst DRAGGING_Z_INDEX = \"1000\"\n\n/** How the page's cover looks during a mouse drag (`Dragging.cover`): clear, over everything; its cursor, the drag's. */\nconst DRAG_COVER = \"position: fixed; inset: 0; z-index: 2147483647\"\n\n/** The cursor while dragging, unless the drag says another (`DragOptions.cursor`): the closed hand. */\nconst DRAG_CURSOR = \"grabbing\"\n\n/** How long a drop nobody took slides back, in milliseconds. */\nconst SLIDE_BACK_MS = 200\n\n/** How it slides back: quickly at first, settling into place. */\nconst SLIDE_BACK_EASING = \"cubic-bezier(0.2, 0.7, 0.3, 1)\"\n"],"mappings":";;;A,kDAsCaE,IAAb,MAAa,SAAS;CAmBT;CAEQ;CAnBnB,OAAO;CAGP,WAAmB,QAAqB;EAKtC,OAJK,SAAS,cACZ,SAAS,YAAY,SAAS,cAAc,KAAK,GACjD,SAAS,UAAU,MAAM,UAAUC,IAE9B,SAAS;CAClB;CACA,OAAe;CAGf;CAGA,YACE,GACA,GACA,GACA;EAKA,AARS,KAAA,UAAAC,GAEQ,KAAA,UAAAC,GAEjB,KAAK,UAAUC,EAAM,gBAAgB,SACrC,KAAK,SAASA,EAAM,SACpB,KAAK,SAASA,EAAM,SACpB,KAAK,YAAYA,EAAM,WACvB,KAAK,YAAYF,EAAQ,sBAAsB;EAC/C,IAAMG,IAAY,EAAE,QAAQ,KAAK,UAAU,OAAO;EAMlD,AALA,OAAO,iBAAiB,eAAe,KAAK,QAAQA,CAAS,GAC7D,OAAO,iBAAiB,aAAa,KAAK,MAAMA,CAAS,GACzD,OAAO,iBAAiB,iBAAiB,KAAK,UAAUA,CAAS,GACjE,OAAO,iBAAiB,WAAW,KAAK,OAAO;GAAE,GAAGA;GAAW,SAAS;EAAK,CAAC,GAC9E,OAAO,iBAAiB,QAAQ,KAAK,QAAQA,CAAS,GAClD,KAAK,WAAS,OAAO,iBAAiB,aAAa,KAAK,aAAa;GAAE,GAAGA;GAAW,SAAS;EAAM,CAAC;CAC3G;CAGA;CACA;CAEA;CAEA;CAEA,YAA6B,IAAI,gBAAgB;CAEjD,SAAgC,CAAC;CAGjC,IAAI,UAAkC;EACpC,O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