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
package/README-components.md
CHANGED
|
@@ -231,7 +231,7 @@ Every family, by group, A-Z inside each.
|
|
|
231
231
|
|
|
232
232
|
<!-- components:start -->
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
91 families, 143 tags; 4 families in progress.
|
|
235
235
|
|
|
236
236
|
### Elements
|
|
237
237
|
|
|
@@ -285,6 +285,7 @@ Ways to present a kind of content.
|
|
|
285
285
|
| <img src="docs/images/components/ui-comment.png" alt="Comment, its first example" width="115" height="96"> | [Comment](docs/ui-comment.html) | `<ui-comment>` `<ui-comments>` | One comment: who wrote it, when, what, and the replies to it. | reply, post, message |
|
|
286
286
|
| | [Diagram](docs/ui-diagram.html) | `<ui-diagram>` `<ui-diagram-node>` | A diagram draws boxes in columns and the links between them, solid for what a box contains and dashed for what it refers to. Drag a box to move it. | graph, node graph, network diagram, boxes and lines |
|
|
287
287
|
| <img src="docs/images/components/ui-feed.png" alt="Feed, its first example" width="96" height="96"> | [Feed](docs/ui-feed.html) | `<ui-feed>` `<ui-event>` | A feed presents people's activity chronologically. | activity feed, timeline, news feed, activity stream |
|
|
288
|
+
| | [Graph](docs/ui-graph.html) *(In progress)* | `<ui-graph>` | A graph draws nodes joined by edges, laid out left to right. A node may hold a graph of its own, opened in place, in a modal, or in its stead. | graph, node graph, network diagram, flow chart |
|
|
288
289
|
| | [Item](docs/ui-item.html) | `<ui-item>` | An item of a dropdown, list, menu or Items view. | list item, media object, row |
|
|
289
290
|
| <img src="docs/images/components/ui-items.png" alt="Items, its first example" width="144" height="96"> | [Items](docs/ui-items.html) | `<ui-items>` | A group of items: site content, each an image beside its header, meta, description and extra. | item list, media list, product list, results |
|
|
290
291
|
| <img src="docs/images/components/ui-statistic.png" alt="Statistic, its first example" width="175" height="80"> | [Statistic](docs/ui-statistic.html) | `<ui-statistic>` `<ui-statistics>` | A statistic emphasizes the current value of an attribute. | stat, kpi, metric, counter |
|
|
@@ -305,7 +306,7 @@ Elements with behaviour: they open, pick, move.
|
|
|
305
306
|
| <img src="docs/images/components/ui-embed.png" alt="Embed, its first example" width="171" height="96"> | [Embed](docs/ui-embed.html) | `<ui-embed>` | An embed displays content from other websites, like YouTube videos, loaded only when asked for. | iframe, video, youtube, vimeo |
|
|
306
307
|
| | [Flyout](docs/ui-flyout.html) | `<ui-flyout>` | A flyout is a modal that slides in from a side of the page. | drawer, sheet, side panel, off canvas |
|
|
307
308
|
| <img src="docs/images/components/ui-include.png" alt="Include, its first example" width="200" height="40"> | [Include](docs/ui-include.html) | `<ui-include>` | An include shows part of another page from this site in this one, loaded at once, when idle or when scrolled into view. | island, partial, fragment, server-side include |
|
|
308
|
-
| | [JSON data](docs/ui-json.html) | `<ui-json>` | JSON data holds data in a page, as its text or from a file with `source
|
|
309
|
+
| | [JSON data](docs/ui-json.html) | `<ui-json>` | JSON data holds data in a page, as its text or from a file with `source`, and shows it as an outline whose objects and arrays open and close. `value` is the parsed data, and an element it sits inside may read it. | data, data island, json script, application/json |
|
|
309
310
|
| | [Modal](docs/ui-modal.html) | `<ui-modal>` | A modal displays content that temporarily blocks interactions with the main view of a site. | dialog, popup window, lightbox, confirm |
|
|
310
311
|
| <img src="docs/images/components/ui-nag.png" alt="Nag, its first example" width="200" height="18"> | [Nag](docs/ui-nag.html) | `<ui-nag>` | A nag is a persistent message that stays until dismissed, and can remember the dismissal. | banner, cookie notice, announcement bar, sticky banner |
|
|
311
312
|
| | [Popup](docs/ui-popup.html) | `<ui-popup>` | A popup displays additional information on top of a page. | tooltip, popover, hint, hover card |
|
|
@@ -339,6 +340,7 @@ Elements with no Fomantic counterpart.
|
|
|
339
340
|
| | [Action](docs/ui-action.html) | `<ui-action>` | A menu item or toolbar button drawn from an action: its title, icon and shortcut keys. | action, command, menu item, toolbar button |
|
|
340
341
|
| | [App menu](docs/ui-app-menu.html) | `<ui-app-menu>` | An app menu is an app's top bar, joined to the top of its window or page: a start section (a menu or sidebar button, then a title or breadcrumb), a middle that stays on the bar's centre, and an end section for buttons. It takes every `<ui-menu>` attribute. | app bar, top bar, title bar, header bar |
|
|
341
342
|
| <img src="docs/images/components/ui-code.png" alt="Code, its first example" width="200" height="17"> | [Code](docs/ui-code.html) | `<ui-code>` | Code shows a block of source code coloured by its language, from the element's own text or a file on this site. | code block, syntax highlighting, highlighter, pre |
|
|
343
|
+
| | [Device](docs/ui-device.html) | `<ui-device>` | A device draws a phone, tablet or desktop round what it holds, at that device's screen size, with buttons in its thick bottom edge. | device frame, phone frame, mockup, device mockup |
|
|
342
344
|
| | [Dimension](docs/ui-dimension.html) | `<ui-dimension>` | A dimension shows one measure in the reader's own units: 5 ft 8 in in the US, 172 cm elsewhere. | measure, measurement, unit, number with units |
|
|
343
345
|
| | [Example](docs/ui-example.html) | `<ui-example>` | An example shows its own markup live, under a heading and description, with the same markup as code a button shows and hides. | example, demo, live example, code sample |
|
|
344
346
|
| | [Icon Picker](docs/ui-icon-picker.html) | `<ui-icon-picker>` | An icon picker lets people choose an icon by searching for it and clicking its glyph. | icon chooser, icon selector, glyph picker, symbol picker |
|
|
@@ -373,7 +375,7 @@ Elements with no Fomantic counterpart.
|
|
|
373
375
|
| Docs index | `<ui-docs-index>` | A site index draws a card for each of a site's pages, grouped by the pages' tags, with a search field above them. | site index, site map, component index, table of contents |
|
|
374
376
|
| Docs inspector | `<ui-docs-inspector>` | An inspector shows another element's attributes, properties and custom states, live: click the element, and watch them change. | inspector, element inspector, devtools, live properties |
|
|
375
377
|
| Docs nav | `<ui-docs-nav>` | A docs nav is a panel listing the site's pages and every component, A-Z or by topic, in folding groups, with search and favourites; the current page is highlighted and scrolled into view. | sidebar, table of contents, toc, site nav |
|
|
376
|
-
| Docs palette | `<ui-docs-palette>` | A palette groups editor shows the Spell editor's palette as columns, a group each: drag a component to another group or place, drag a group to reorder it, rename a group, add or remove one, then save. | palette groups, palette editor, component groups, palette table |
|
|
378
|
+
| Docs palette | `<ui-docs-palette>` | A palette groups editor shows the Spell editor's palette as columns, a group each: drag a component to another group or place, drag a group to reorder it, rename a group or pick its icon, add or remove one, then save. | palette groups, palette editor, component groups, palette table |
|
|
377
379
|
| Docs search | `<ui-docs-search>` | A docs search is a field that finds sections of the page shown, components, attributes and every page's sections as you type, and jumps to the one you pick; `/` or Cmd / Ctrl+K focuses it from anywhere. | site search, docs search, quick find, jump to |
|
|
378
380
|
| Docs theme bench | `<ui-docs-theme-bench>` | A theme bench shows the theme editor full width, previewing Spell's real pages side by side in the theme being made: the editor, an epic page, Spell UI's docs and a notebook. | theme bench, theme workbench, look tuner, token tuner |
|
|
379
381
|
| Docs tokens | `<ui-docs-tokens>` | A token table lists the CSS custom properties of a component family, or of the whole foundation, with their defaults and a live swatch for each colour; a playground adds inputs that restyle a live preview. | css variables, custom properties, design tokens, theme tokens |
|
|
@@ -6,7 +6,7 @@ var r = /* @__PURE__ */ e({ Dragging: () => i }), i = class Dragging {
|
|
|
6
6
|
options;
|
|
7
7
|
static current;
|
|
8
8
|
static get cover() {
|
|
9
|
-
return Dragging.madeCover || (Dragging.madeCover = document.createElement("div"), Dragging.madeCover.style.cssText =
|
|
9
|
+
return Dragging.madeCover || (Dragging.madeCover = document.createElement("div"), Dragging.madeCover.style.cssText = c), Dragging.madeCover;
|
|
10
10
|
}
|
|
11
11
|
static madeCover;
|
|
12
12
|
isTouch;
|
|
@@ -27,6 +27,8 @@ var r = /* @__PURE__ */ e({ Dragging: () => i }), i = class Dragging {
|
|
|
27
27
|
pointerId;
|
|
28
28
|
listening = new AbortController();
|
|
29
29
|
moving = [];
|
|
30
|
+
depths = [];
|
|
31
|
+
plane = a.FLAT;
|
|
30
32
|
get carried() {
|
|
31
33
|
return this.moving;
|
|
32
34
|
}
|
|
@@ -45,7 +47,10 @@ var r = /* @__PURE__ */ e({ Dragging: () => i }), i = class Dragging {
|
|
|
45
47
|
if (Math.hypot(t, n) < 6) return;
|
|
46
48
|
this.start();
|
|
47
49
|
}
|
|
48
|
-
if (this.follows)
|
|
50
|
+
if (this.follows) {
|
|
51
|
+
let [e, r] = this.plane.toPlane(t, n);
|
|
52
|
+
this.moving.forEach((t, n) => t.style.translate = `${e}px ${r}px${this.depths[n]}`);
|
|
53
|
+
}
|
|
49
54
|
if (e.preventDefault(), Dragging.send(this.element, "drag", e), this.options.placing) return this.options.placing(e.clientX, e.clientY);
|
|
50
55
|
this.moveOver(Dragging.dropTargetAt(this.element, e.clientX, e.clientY), e);
|
|
51
56
|
};
|
|
@@ -58,8 +63,11 @@ var r = /* @__PURE__ */ e({ Dragging: () => i }), i = class Dragging {
|
|
|
58
63
|
start() {
|
|
59
64
|
let e = [];
|
|
60
65
|
for (let t = this.element.nextElementSibling; t; t = t.nextElementSibling) e.push(t);
|
|
61
|
-
if (this.moving = this.options.carried ?? [this.element, ...e], this.follows)
|
|
62
|
-
|
|
66
|
+
if (this.moving = this.options.carried ?? [this.element, ...e], this.follows) {
|
|
67
|
+
for (let e of this.moving) e.style.zIndex = s, e.style.pointerEvents = "none", e.style.transition = "none";
|
|
68
|
+
this.depths = this.moving.map((e) => depthOf(e.style.translate)), this.plane = a.of(this.element, this.depths[0]);
|
|
69
|
+
}
|
|
70
|
+
getSelection()?.removeAllRanges(), document.documentElement.style.userSelect = "none", this.isTouch || (Dragging.cover.style.cursor = this.options.cursor ?? l, document.body.append(Dragging.cover)), Dragging.current = this, this.element.dispatchEvent(new DragEvent("dragstart", {
|
|
63
71
|
bubbles: !0,
|
|
64
72
|
composed: !0
|
|
65
73
|
}));
|
|
@@ -91,16 +99,16 @@ var r = /* @__PURE__ */ e({ Dragging: () => i }), i = class Dragging {
|
|
|
91
99
|
}
|
|
92
100
|
settle() {
|
|
93
101
|
for (let e of this.follows ? this.moving : []) {
|
|
94
|
-
let t = e.style.translate;
|
|
95
|
-
e.style.translate = "", e.style.pointerEvents = "", e.style.zIndex = "", getComputedStyle(e).translate, e.style.transition = "", e.isConnected && t && t !==
|
|
102
|
+
let t = e.style.translate, n = depthOf(t);
|
|
103
|
+
e.style.translate = "", e.style.pointerEvents = "", e.style.zIndex = "", getComputedStyle(e).translate, e.style.transition = "", e.isConnected && t && t !== `0px 0px${n}` && e.animate([{
|
|
96
104
|
translate: t,
|
|
97
|
-
zIndex:
|
|
105
|
+
zIndex: s
|
|
98
106
|
}, {
|
|
99
|
-
translate:
|
|
100
|
-
zIndex:
|
|
107
|
+
translate: `0px 0px${n}`,
|
|
108
|
+
zIndex: s
|
|
101
109
|
}], {
|
|
102
|
-
duration:
|
|
103
|
-
easing:
|
|
110
|
+
duration: u,
|
|
111
|
+
easing: d
|
|
104
112
|
});
|
|
105
113
|
}
|
|
106
114
|
document.documentElement.style.userSelect = "", Dragging.cover.remove(), Dragging.current === this && (Dragging.current = void 0), this.element.dispatchEvent(new DragEvent("dragend", {
|
|
@@ -165,7 +173,42 @@ var r = /* @__PURE__ */ e({ Dragging: () => i }), i = class Dragging {
|
|
|
165
173
|
once: !0
|
|
166
174
|
}), n(() => window.removeEventListener("click", swallow, { capture: !0 }));
|
|
167
175
|
}
|
|
168
|
-
}, a =
|
|
176
|
+
}, a = class PlaneMap {
|
|
177
|
+
xx;
|
|
178
|
+
xy;
|
|
179
|
+
yx;
|
|
180
|
+
yy;
|
|
181
|
+
static FLAT = new PlaneMap(1, 0, 0, 1);
|
|
182
|
+
static of(e, t) {
|
|
183
|
+
let centre = () => {
|
|
184
|
+
let t = e.getBoundingClientRect();
|
|
185
|
+
return [t.left + t.width / 2, t.top + t.height / 2];
|
|
186
|
+
}, n = e.style.translate, [r, i] = centre();
|
|
187
|
+
e.style.translate = `${o}px 0px${t}`;
|
|
188
|
+
let [a, s] = centre();
|
|
189
|
+
e.style.translate = `0px ${o}px${t}`;
|
|
190
|
+
let [c, l] = centre();
|
|
191
|
+
e.style.translate = n;
|
|
192
|
+
let [u, d, f, p] = [
|
|
193
|
+
(a - r) / o,
|
|
194
|
+
(s - i) / o,
|
|
195
|
+
(c - r) / o,
|
|
196
|
+
(l - i) / o
|
|
197
|
+
], m = u * p - f * d;
|
|
198
|
+
return !Number.isFinite(m) || Math.abs(m) < .01 || Math.abs(u - 1) < .001 && Math.abs(p - 1) < .001 && Math.abs(f) < .001 && Math.abs(d) < .001 ? PlaneMap.FLAT : new PlaneMap(p / m, -f / m, -d / m, u / m);
|
|
199
|
+
}
|
|
200
|
+
constructor(e, t, n, r) {
|
|
201
|
+
this.xx = e, this.xy = t, this.yx = n, this.yy = r;
|
|
202
|
+
}
|
|
203
|
+
toPlane(e, t) {
|
|
204
|
+
return this === PlaneMap.FLAT ? [e, t] : [this.xx * e + this.xy * t, this.yx * e + this.yy * t];
|
|
205
|
+
}
|
|
206
|
+
}, o = 100;
|
|
207
|
+
function depthOf(e) {
|
|
208
|
+
let t = e.trim().split(/\s+/)[2];
|
|
209
|
+
return t ? ` ${t}` : "";
|
|
210
|
+
}
|
|
211
|
+
var s = "1000", c = "position: fixed; inset: 0; z-index: 2147483647", l = "grabbing", u = 200, d = "cubic-bezier(0.2, 0.7, 0.3, 1)";
|
|
169
212
|
export { r as n, i as t };
|
|
170
213
|
|
|
171
|
-
//# sourceMappingURL=Dragging-
|
|
214
|
+
//# sourceMappingURL=Dragging-tHPSvf3G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dragging-tHPSvf3G.js","names":["__exportAll","Dragging_exports","Dragging","DRAG_COVER","element","options","event","listening","PlaneMap","left","x","top","y","width","height","dx","dy","index","target","following","next","DRAGGING_Z_INDEX","DRAG_CURSOR","wasDragging","from","depth","SLIDE_BACK_MS","SLIDE_BACK_EASING","type","hits","hit","under","at","lists","child","row","list","box","kind","span","other","taking","chain","rule","each","soon","own","x0","y0","PROBE_PX","x1","y1","x2","y2","a","c","b","d","det","xx","xy","yx","yy","translate"],"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 * - On a board shown turned or scaled (the editor's Anatomy, in 3D), they move in the board's own plane,\n * so they stay under the pointer: the pointer's move is turned back through the board's turn (`PlaneMap`),\n * and each keeps the depth its own `translate` gave it (epic `editor` T120).\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 /** Each carried element's depth, the third part of its own `translate` as the drag started (`\"\"`: none). */\n private depths: string[] = []\n /** How a move on screen is a move in the board's plane: worked out as the drag starts. */\n private plane = PlaneMap.FLAT\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) {\n const [x, y] = this.plane.toPlane(dx, dy)\n this.moving.forEach((element, index) => (element.style.translate = `${x}px ${y}px${this.depths[index]}`))\n }\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 this.depths = this.moving.map((element) => depthOf(element.style.translate))\n this.plane = PlaneMap.of(this.element, this.depths[0]!)\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 const depth = depthOf(from)\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${depth}`) {\n element.animate(\n [\n { translate: from, zIndex: DRAGGING_Z_INDEX },\n { translate: `0px 0px${depth}`, 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/**\n * How a move of the pointer on screen is a move in the plane of the board an element lies on:\n * the inverse of how the board's turn and size carry a move of the element across the screen.\n * - Measured, not worked out from the transforms: the element is moved 100px across and 100px down in its plane\n * (keeping its depth), and where its box goes on screen says how its plane lies.\n * - A flat board, or one the browser can't say, is `FLAT`: a move on screen is the same move in the plane.\n */\nclass PlaneMap {\n /** No turn, no size: the same move. */\n static readonly FLAT = new PlaneMap(1, 0, 0, 1)\n\n /** The map for `element`, whose own `translate` depth is `depth` (`\"\"`, or ` <length>`). */\n static of(element: HTMLElement, depth: string): PlaneMap {\n const centre = () => {\n const box = element.getBoundingClientRect()\n return [box.left + box.width / 2, box.top + box.height / 2] as const\n }\n const own = element.style.translate\n const [x0, y0] = centre()\n element.style.translate = `${PROBE_PX}px 0px${depth}`\n const [x1, y1] = centre()\n element.style.translate = `0px ${PROBE_PX}px${depth}`\n const [x2, y2] = centre()\n element.style.translate = own\n // across and down in the plane, on screen, per pixel\n const [a, c, b, d] = [(x1 - x0) / PROBE_PX, (y1 - y0) / PROBE_PX, (x2 - x0) / PROBE_PX, (y2 - y0) / PROBE_PX]\n const det = a * d - b * c\n if (!Number.isFinite(det) || Math.abs(det) < 0.01) return PlaneMap.FLAT\n if (Math.abs(a - 1) < 0.001 && Math.abs(d - 1) < 0.001 && Math.abs(b) < 0.001 && Math.abs(c) < 0.001)\n return PlaneMap.FLAT\n return new PlaneMap(d / det, -b / det, -c / det, a / det)\n }\n\n private constructor(\n private readonly xx: number,\n private readonly xy: number,\n private readonly yx: number,\n private readonly yy: number\n ) {}\n\n /** The move in the plane that carries the element `dx`, `dy` across the screen. */\n toPlane(dx: number, dy: number): [number, number] {\n if (this === PlaneMap.FLAT) return [dx, dy]\n return [this.xx * dx + this.xy * dy, this.yx * dx + this.yy * dy]\n }\n}\n\n/** How far `PlaneMap.of()` moves the element to see where its plane lies, px. */\nconst PROBE_PX = 100\n\n/** The depth part of a `translate` (`\"10px 4px 48px\"` => `\" 48px\"`), with its space: `\"\"` for none. */\nfunction depthOf(translate: string): string {\n const depth = translate.trim().split(/\\s+/)[2]\n return depth ? ` ${depth}` : \"\"\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,kDAyCaE,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,IAA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E;CAClE;AACF,GAGMiC,IAAW;AAGjB,SAAS,QAAQ,GAA2B;CAC1C,IAAMxB,IAAQsC,EAAU,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;CAC5C,OAAOtC,IAAQ,IAAIA,MAAU;AAC/B;AA8BA,IAAMJ,IAAmB,QAGnBlB,IAAa,kDAGbmB,IAAc,YAGdI,IAAgB,KAGhBC,IAAoB"}
|
|
@@ -167,8 +167,15 @@ export declare class DOMElement<C extends E.UIComponent<any> = E.UIComponent<any
|
|
|
167
167
|
* so the family decides again (`<ui-modal visible>` losing `visible` hides).
|
|
168
168
|
*/
|
|
169
169
|
private onVisibleAttributeChanged;
|
|
170
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Constructor step: take own properties set before the upgrade, and store their values at once.
|
|
172
|
+
* - An attribute's property: its value stored now, and set again at the first connect.
|
|
173
|
+
* - Any other property the family's DOM element class has a setter for (`<ui-json>`'s `value`):
|
|
174
|
+
* set again, through that setter, at the first connect.
|
|
175
|
+
*/
|
|
171
176
|
private captureUpgradeValues;
|
|
177
|
+
/** Does a class between `element`'s own and `HTMLElement` give `property` a setter? */
|
|
178
|
+
private static hasSetterFor;
|
|
172
179
|
/** First-connect step: set the captured values again, through the real setters (so they reflect). */
|
|
173
180
|
private restoreUpgradeValues;
|
|
174
181
|
/**
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { JSX } from '@solidjs/web';
|
|
2
|
+
/** How many items are drawn at a time. */
|
|
3
|
+
export declare const MOST_AT_ONCE = 24;
|
|
4
|
+
/**
|
|
5
|
+
* How long it waits before drawing more, when what it drew last took no room: items still reading, or drawing nothing.
|
|
6
|
+
* - Else a list whose items each read from a server (the Met's artworks), and draw nothing till then, or at all, would
|
|
7
|
+
* draw every one at once: the end never moves away from the view. So at most `MOST_AT_ONCE` reads a second.
|
|
8
|
+
*/
|
|
9
|
+
export declare const WAIT_WHEN_NOTHING_MOVED_MS = 1000;
|
|
10
|
+
/** What it takes to draw a long list, from `drawnInWindow()`. */
|
|
11
|
+
export type DrawnWindow<Item> = {
|
|
12
|
+
/** Every item there is now, tracked. */
|
|
13
|
+
items: () => readonly Item[];
|
|
14
|
+
/** Item drawn, with its position counting from 0. */
|
|
15
|
+
drawItem: (item: Item, position: () => number) => JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* What it remembers by, for coming back: the list itself.
|
|
18
|
+
* - Asked as the list is first read, never by the caller's drawing: reading it there would draw everything again when it changes.
|
|
19
|
+
*/
|
|
20
|
+
key?: () => object | undefined;
|
|
21
|
+
/** A place's further pages. */
|
|
22
|
+
more?: () => MorePages | undefined;
|
|
23
|
+
/** How many it draws at a time, when it isn't `MOST_AT_ONCE`: `show them 12 at a time`. */
|
|
24
|
+
atOnce?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The position of an item that must be drawn now, tracked: everything up to it is drawn at once.
|
|
27
|
+
* - A picked row, or where a key moved to, past what's drawn; `-1` or `undefined` for none.
|
|
28
|
+
*/
|
|
29
|
+
through?: () => number | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* What tells the drawing that how many to draw changed, when that isn't a Solid signal:
|
|
32
|
+
* Spell's core hands its `Cell`.
|
|
33
|
+
* - Why: a signal's write waits for whatever else is pending on the page,
|
|
34
|
+
* and a Spell action may be waiting all this while;
|
|
35
|
+
* a cell's write reaches the drawing at once, through the page's cells bridge.
|
|
36
|
+
*/
|
|
37
|
+
changes?: () => CountChanges;
|
|
38
|
+
/** Is the page going to its top, so a list coming back stays there rather than scrolling to where it was? */
|
|
39
|
+
isGoingToTheTop?: () => boolean;
|
|
40
|
+
};
|
|
41
|
+
/** What says how many are drawn changed: `read()` where it's read, `changed()` after it changes. */
|
|
42
|
+
export type CountChanges = {
|
|
43
|
+
/** It's being read: the drawing reading it follows it. */
|
|
44
|
+
read(): void;
|
|
45
|
+
/** It changed. */
|
|
46
|
+
changed(): void;
|
|
47
|
+
};
|
|
48
|
+
/** A list whose next page hasn't been read. */
|
|
49
|
+
export type MorePages = {
|
|
50
|
+
/** Is there another page? */
|
|
51
|
+
hasMorePages: boolean;
|
|
52
|
+
/** Read it. NEVER rejects. */
|
|
53
|
+
readNextPage(): Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
/** Can this page tell when something comes near the view? */
|
|
56
|
+
export declare function canDrawInWindows(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The list, drawn as much as fits: see the file's docs.
|
|
59
|
+
* - Kept by identity: an item added, removed or moved changes only its own node.
|
|
60
|
+
* - Call in an owner: a component, or a drawing's memo.
|
|
61
|
+
*/
|
|
62
|
+
export declare function drawnInWindow<Item>({ items, drawItem, key, more, atOnce, through, changes, isGoingToTheTop }: DrawnWindow<Item>): JSX.Element;
|
package/dist/_util/Dragging.d.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* - 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.
|
|
6
6
|
* - They follow the pointer by their `translate`, raised above the board,
|
|
7
7
|
* with no transition meanwhile, so a page whose cards glide (Solitaire) still keeps up with it (epic `editor` I99).
|
|
8
|
+
* - On a board shown turned or scaled (the editor's Anatomy, in 3D), they move in the board's own plane,
|
|
9
|
+
* so they stay under the pointer: the pointer's move is turned back through the board's turn (`PlaneMap`),
|
|
10
|
+
* and each keeps the depth its own `translate` gave it (epic `editor` T120).
|
|
8
11
|
* - They ignore the pointer meanwhile, so what's under it can be found.
|
|
9
12
|
* - Or what its owner says (`DragOptions.carried`), staying where it is (`follows: false`):
|
|
10
13
|
* e.g. a task list's selected tasks, dimmed, while a line shows where they'd go
|
|
@@ -57,6 +60,10 @@ export declare class Dragging {
|
|
|
57
60
|
private readonly listening;
|
|
58
61
|
/** What's carried, once it's a drag: the element, then its list's items after it -- or what `options` says. */
|
|
59
62
|
private moving;
|
|
63
|
+
/** Each carried element's depth, the third part of its own `translate` as the drag started (`""`: none). */
|
|
64
|
+
private depths;
|
|
65
|
+
/** How a move on screen is a move in the board's plane: worked out as the drag starts. */
|
|
66
|
+
private plane;
|
|
60
67
|
/** What's carried: the element first. */
|
|
61
68
|
get carried(): readonly HTMLElement[];
|
|
62
69
|
/**
|
|
@@ -1596,3 +1596,5 @@ export declare const TocMarks: {
|
|
|
1596
1596
|
readonly entry: "data-toc";
|
|
1597
1597
|
readonly group: "data-toc-group";
|
|
1598
1598
|
};
|
|
1599
|
+
/** `<ui-tree>`'s data items (`appearance="columns"`, `items`): its own file, named here for the JSX types (`UIT.TreeItemData`). */
|
|
1600
|
+
export type { TreeItemData } from 'spell/ui/components/ui-tree/UITree.types';
|
|
@@ -42,6 +42,9 @@ export declare class DOMDiagramElement extends E.DOMElement<UIDiagram> {
|
|
|
42
42
|
* - Accessibility: the `<svg>` is a `group`, named by a summary ("Diagram: 9 boxes, 11 links");
|
|
43
43
|
* each box is a button named by its name, its description saying the arrow keys move it.
|
|
44
44
|
* - NEVER knows where its spec came from: the ingester's NERD (P11) and a hand-written spec look the same to it.
|
|
45
|
+
* - Spell UI's other drawings of boxes and lines:
|
|
46
|
+
* - `<ui-tree-diagram>`: a tree
|
|
47
|
+
* - `<ui-graph>`: any graph, in layers left to right, with ports, nested graphs, pan and zoom
|
|
45
48
|
****************/
|
|
46
49
|
export declare class UIDiagram extends E.UIComponent<typeof diagramVocabulary> {
|
|
47
50
|
static vocabulary: {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { GraphData, GraphLayoutOptions, GraphLayoutResult, GraphPlacedEdge, GraphPoint, GraphPort, GraphPortSide } from './UIGraph.types';
|
|
2
|
+
/****************
|
|
3
|
+
* ### `GraphLayout`
|
|
4
|
+
* Lays a graph out left to right, in layers (a small Sugiyama): pure, numbers in, boxes and paths out.
|
|
5
|
+
* - The steps, per level:
|
|
6
|
+
* 1. each node's size, from its label and ports; a node open in place is laid out first, and grows round it
|
|
7
|
+
* 2. cycles broken (depth first, back edges turned round), then layers by longest path, sources pulled right
|
|
8
|
+
* 3. a dummy point per layer a long edge crosses, so it routes round the boxes
|
|
9
|
+
* 4. order within each layer by barycentre sweeps (each box moved towards its neighbours' mean), ports counted
|
|
10
|
+
* 5. x by layer; y pulled towards each box's neighbours, then pushed apart so nothing overlaps
|
|
11
|
+
* - Edges come out as points; `pathFor()` turns them into a smooth SVG path, leaving and entering ports sideways.
|
|
12
|
+
* - The enclosing node's ports (`boundary`) are pins in the first and last layers:
|
|
13
|
+
* a container's own ports sit where its child graph's pins are.
|
|
14
|
+
* - Measured: 200 nodes and 400 edges in one level lay out in tens of milliseconds (`UIGraph`'s docs page).
|
|
15
|
+
* - GENERIC: imports only the family's types.
|
|
16
|
+
****************/
|
|
17
|
+
export declare class GraphLayout {
|
|
18
|
+
/** `graph` laid out, every open level flattened into absolute boxes. */
|
|
19
|
+
static of(graph: GraphData, options?: GraphLayoutOptions): GraphLayoutResult;
|
|
20
|
+
/** `d` of an edge's `<path>`: cubic curves through its points, leaving and entering along its sides. */
|
|
21
|
+
static pathFor(edge: Pick<GraphPlacedEdge, "points" | "fromSide" | "toSide">): string;
|
|
22
|
+
/** A control point `reach` out of `point`, on `side`. */
|
|
23
|
+
private static toward;
|
|
24
|
+
/** The middle of an edge's path, for its label. */
|
|
25
|
+
static middleOf(edge: Pick<GraphPlacedEdge, "points">): GraphPoint;
|
|
26
|
+
/** A port's side: its own, else its kind's, else where most of its edges are drawn from. */
|
|
27
|
+
static sideOf(port: GraphPort, votes: {
|
|
28
|
+
asSource: number;
|
|
29
|
+
asTarget: number;
|
|
30
|
+
} | undefined): GraphPortSide;
|
|
31
|
+
private readonly metrics;
|
|
32
|
+
private readonly options;
|
|
33
|
+
private constructor();
|
|
34
|
+
private textWidth;
|
|
35
|
+
private labelOf;
|
|
36
|
+
/** One graph laid out, its coordinates relative to its own top left. */
|
|
37
|
+
private level;
|
|
38
|
+
/** A node's box: a leaf sized to its label and ports, or a container round its laid out child graph. */
|
|
39
|
+
private box;
|
|
40
|
+
/** Place `ports` evenly along `unit`'s `side`. */
|
|
41
|
+
private spread;
|
|
42
|
+
/** Where an edge's end attaches; `undefined` for an end naming nothing in this graph. */
|
|
43
|
+
private endOf;
|
|
44
|
+
/** Layers: cycles broken, longest path from the sources, sources pulled next to what they feed; pins at the sides. */
|
|
45
|
+
private assignLayers;
|
|
46
|
+
/** Order within each layer: barycentre sweeps, down then up, keeping the best. */
|
|
47
|
+
private order;
|
|
48
|
+
/** x by layer, y pulled towards neighbours without overlapping; the level's size. */
|
|
49
|
+
private place;
|
|
50
|
+
/** Put each unit of `layer` as near its `wanted` y as it can, in order, without overlaps. */
|
|
51
|
+
private static separate;
|
|
52
|
+
/** `level`'s boxes and edges, moved to `x`, `y`, into `nodes` and `edges`; open nodes' levels after them. */
|
|
53
|
+
private flatten;
|
|
54
|
+
}
|