@andamento/dom 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.
package/dist/index.d.ts CHANGED
@@ -1,166 +1,8 @@
1
- import { Cell, Layout, ContentCells, ContentPlacement, Rect, Focus, LayoutOptions, HitOptions } from '@andamento/core';
2
- import { ReliefPath, FillSource, ReliefOptions } from '@andamento/svg';
1
+ import { LayoutOptions, Layout, Cell, ContentCells, ContentPlacement, Focus, HitOptions } from '@andamento/core';
2
+ import { FillSource, ReliefOptions } from '@andamento/svg';
3
3
  export { FillSource, ReliefOptions, defaultPalette, neutralPalette } from '@andamento/svg';
4
-
5
- /**
6
- * The parts of an HTML tile layout that don't depend on a framework: what each tile's
7
- * element looks like, what keys do, what's in view. `mountTileLayout`, the
8
- * `<andamento-layout>` element and the Vue components all render from these.
9
- */
10
- /** How a layout's `fit` option sizes its tiles. */
11
- type FitProp = boolean | "atLeast" | "nearest";
12
- /** What a per-cell option function is told about the cell besides its geometry. */
13
- interface CellState {
14
- /** The cell has no content. */
15
- empty: boolean;
16
- /** Position among the cells that hold content, in reading order (the item index), or -1. */
17
- slot: number;
18
- }
19
- /**
20
- * Put each tile's content in its safe area: `true` or "tile" fits the whole tile (for a tile
21
- * an `edges: "window"` layout cuts, content near the edge is then partly hidden like the
22
- * tile), "visible" fits the part that shows. See `SafeAreaOptions.within`.
23
- */
24
- type SafeAreaProp = boolean | "tile" | "visible";
25
- /** A value, or a function giving it per cell. */
26
- type PerCell<T> = T | ((cell: Cell, state: CellState) => T);
27
- declare const resolvePerCell: <T>(v: PerCell<T> | undefined, cell: Cell, state: CellState) => T | undefined;
28
- /** Style as property → value, camelCase (`clipPath`) or custom (`--x`). */
29
- type StyleMap = Record<string, string | number | undefined>;
30
- /** Clip paths get this many points when animating, so any two tile shapes can morph. */
31
- declare const MORPH_POINTS = 72;
32
- /** What a layout's items need from it: how many there are, and how they're sized and placed. */
33
- interface LayoutNeeds {
34
- fit?: FitProp;
35
- count: number;
36
- cells?: ContentCells;
37
- /** Tiles each item spans (see `weightedLayout`); heavier items get featured tiles. */
38
- weights?: readonly number[];
39
- placement?: ContentPlacement;
40
- }
41
- /**
42
- * A layout from options, worked out again only when they change (compared by value; a
43
- * `cells` function by identity). Returns `layout` itself when given.
44
- */
45
- declare function layoutResolver(component: string): (options: LayoutOptions | undefined, layout: Layout | undefined, fit?: LayoutNeeds) => Layout;
46
- interface FrameOptions {
47
- /** How many items there are to place (Infinity when every allowed cell gets content). */
48
- count: number;
49
- aspects?: readonly number[];
50
- contentCells?: ContentCells;
51
- placement?: ContentPlacement;
52
- choose?: "placement" | "shape";
53
- fill?: FillSource;
54
- relief?: boolean | ReliefOptions;
55
- animate?: boolean | {
56
- duration?: number;
57
- easing?: string;
58
- };
59
- }
60
- /** Everything about a layout's tiles shared between them. */
61
- interface Frame {
62
- layout: Layout;
63
- /** Item index per cell, or -1. */
64
- slots: number[];
65
- /** Empty-tile color per cell. */
66
- fills: string[];
67
- /** Bevel paths for a cell (worked out on first use), or undefined without relief. */
68
- bevel(index: number): ReliefPath[] | undefined;
69
- shadow?: {
70
- dx: number;
71
- dy: number;
72
- blur: number;
73
- opacity: number;
74
- };
75
- anim?: {
76
- duration: number;
77
- easing: string;
78
- };
79
- /** `left, top, width, height` transitions, when animating. */
80
- boxTransition?: string;
81
- tileTransition?: string;
82
- }
83
- /** Builds frames, reusing the slots, fills and bevels of the last one where nothing they depend on changed. */
84
- declare function frameBuilder(): (layout: Layout, o: FrameOptions) => Frame;
85
- /** Style of the element holding the layout. */
86
- declare const containerStyle: (layout: Layout) => StyleMap;
87
- /** Style of the element painting `background` across the region (seen through the gaps). */
88
- declare const backgroundStyle: (frame: Frame, background: string) => StyleMap;
89
- /**
90
- * A tile's element: placed over its cell's bounding box and clipped to its shape. Empty
91
- * tiles (and every tile with `safeArea`) show their fill unless there's a backdrop.
92
- */
93
- declare function tileStyle(frame: Frame, cell: Cell, o: {
94
- empty: boolean;
95
- safeArea?: SafeAreaProp;
96
- backdrop?: boolean;
97
- clickable?: boolean;
98
- focus?: Focus;
99
- aspect?: number;
100
- }): StyleMap;
101
- /**
102
- * The `--andamento-object-position` a tile sets for its content's focal point, which
103
- * `coverStyle` uses as its `object-position`. Exact with the image's `aspect` (given, or the focus's own; see
104
- * `objectPosition`); without, the focus as a percentage, which CSS keeps at the same place
105
- * in the tile's box rather than in the middle of what shows.
106
- */
107
- declare function focusStyle(frame: Frame, cell: Cell, focus: Focus, aspect?: number): StyleMap;
108
- /** A backdrop copy inside a tile: behind its content, covering the whole layout. */
109
- declare const backdropStyle: (frame: Frame, cell: Cell) => StyleMap;
110
- /** The box holding a tile's content with `safeArea`. */
111
- declare const safeBoxStyle: (frame: Frame, cell: Cell, aspect?: number, safe?: SafeAreaProp) => StyleMap;
112
- /** Style of an <svg> drawn over a tile (bevel, focus ring), with `viewBox` set to `tileViewBox`. */
113
- declare const overlayStyle: StyleMap;
114
- declare const tileViewBox: (cell: Cell) => string;
115
- /** The focus ring's two strokes: white under the color, so it shows on any content. */
116
- declare const ringStrokes: (frame: Frame, cell: Cell, color: string) => {
117
- d: string;
118
- stroke: string;
119
- width: number;
120
- }[];
121
- /** The shadow tiles cast into the grout (with relief's `shadow`), for an <svg> over the region. */
122
- declare function shadowShape(frame: Frame, cells: readonly Cell[]): {
123
- viewBox: string;
124
- style: StyleMap;
125
- blur: number;
126
- d: string;
127
- transform: string;
128
- opacity: number;
129
- } | undefined;
130
- /**
131
- * What a key does on a focused tile: move focus to another tile, activate it, or just stop
132
- * the page scrolling (arrows at the edge). Undefined for keys that aren't ours.
133
- */
134
- declare function keyAction(layout: Layout, from: Cell, key: string, accept: (cell: Cell) => boolean, canActivate: boolean): {
135
- move: Cell;
136
- } | {
137
- activate: true;
138
- } | {
139
- prevent: true;
140
- } | undefined;
141
- /** Style sheet text for focus rings and animation (empty when neither is on). */
142
- declare function tileSheet(o: {
143
- focusRing: boolean;
144
- anim?: {
145
- duration: number;
146
- easing: string;
147
- };
148
- }): string;
149
- /** "Nothing in view": `view` before the layout has been measured, or when it's off screen. */
150
- declare const NOTHING_IN_VIEW: Rect;
151
- /**
152
- * The part of the layout in view (in layout units), widened by `overscan` pixels and
153
- * snapped outwards to a coarse grid so small scrolls give the same rectangle.
154
- */
155
- declare function viewRect(el: Element, layout: Layout, overscan: number): Rect;
156
- declare const sameRect: (a: Rect | undefined, b: Rect | undefined) => boolean;
157
- /**
158
- * Call `measure` now and again (at most once a frame) whenever the page or any scrolling
159
- * container scrolls, the window resizes or `el` does. Returns a function that stops it.
160
- */
161
- declare function watchView(el: Element, measure: () => void): () => void;
162
- /** Style that makes an <img> or <video> cover its tile, like `object-fit: cover`. */
163
- declare const coverStyle: StyleMap;
4
+ import { S as SafeAreaProp, F as FitProp, C as CellState, P as PerCell, a as StyleMap } from './internal-NveCwJWd.js';
5
+ export { c as coverStyle } from './internal-NveCwJWd.js';
164
6
 
165
7
  /** What can go in a tile: a DOM node, text, or nothing. */
166
8
  type TileContent = Node | string | null | undefined;
@@ -397,4 +239,4 @@ declare function cellFromPointer(layout: Layout, event: PointerLike, options?: H
397
239
  element?: Element;
398
240
  }): Cell | undefined;
399
241
 
400
- export { AndamentoLayoutElement, type CellActivateDetail, type CellState, type FitProp, type Frame, type FrameOptions, type LayoutNeeds, MORPH_POINTS, NOTHING_IN_VIEW, type PerCell, type PointerLike, type SafeAreaProp, type StyleMap, type TileContent, type TileLayoutConfig, type TileLayoutHandle, backdropStyle, backgroundStyle, cellFromPointer, containerStyle, coverStyle, defineTileLayoutElement, focusStyle, frameBuilder, keyAction, layoutResolver, mountTileLayout, overlayStyle, resolvePerCell, ringStrokes, safeBoxStyle, sameRect, shadowShape, tileSheet, tileStyle, tileViewBox, viewRect, watchView };
242
+ export { AndamentoLayoutElement, type CellActivateDetail, CellState, FitProp, PerCell, type PointerLike, SafeAreaProp, StyleMap, type TileContent, type TileLayoutConfig, type TileLayoutHandle, cellFromPointer, defineTileLayoutElement, mountTileLayout };
package/dist/index.js CHANGED
@@ -1,256 +1,30 @@
1
- var __typeError = (msg) => {
2
- throw TypeError(msg);
3
- };
4
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
-
10
- // src/mount.ts
11
- import { cellsInRect } from "@andamento/core";
12
-
13
- // src/model.ts
14
1
  import {
15
- backdropCss,
16
- cellCss,
17
- cellShape,
18
- cellInDirection,
19
- contentSlots,
20
- createLayout,
21
- objectPosition,
22
- fitCount,
23
- matchSlots,
24
- regionCss,
25
- safeAreaCss,
26
- screenToLayout,
27
- viewCss,
28
- weightedLayout
29
- } from "@andamento/core";
30
- import { cellPath, defaultBevel, neutralPalette, reliefPaths, resolveFills, shadowOffset } from "@andamento/svg";
31
- var resolvePerCell = (v, cell, state) => typeof v === "function" ? v(cell, state) : v;
32
- var MORPH_POINTS = 72;
33
- var PLACEHOLDER = { region: { x: 0, y: 0, width: 1, height: 1 }, tiling: { type: "grid", width: 1 } };
34
- function layoutResolver(component) {
35
- let lastKey, lastCells, last;
36
- return (options, layout, fit) => {
37
- if (layout) return layout;
38
- if (!options) throw new Error(`${component} needs either \`options\` or \`layout\``);
39
- const fitting = !!fit?.fit && fit.count >= 1 && Number.isFinite(fit.count);
40
- const mode = fit?.fit === "nearest" ? "nearest" : "atLeast";
41
- const count = fit && Number.isFinite(fit.count) ? fit.count : 0;
42
- const weights = fit?.weights?.some((w) => w > 1) && count > 0 ? Array.from({ length: count }, (_, i) => fit.weights[i] ?? 1) : void 0;
43
- const cells = fitting || weights ? fit.cells : void 0;
44
- const key = JSON.stringify([options, fitting && fit.count, mode, weights, weights && fit.placement]);
45
- if (last && key === lastKey && cells === lastCells) return last;
46
- last = weights ? weightedLayout(options, weights, { fit: fitting && mode, cells, placement: fit.placement }).layout : fitting ? fitCount(options, fit.count, { cells, mode }).layout : createLayout(options ?? PLACEHOLDER);
47
- lastKey = key;
48
- lastCells = cells;
49
- return last;
50
- };
51
- }
52
- function frameBuilder() {
53
- let slotKey = "", slotLayout, slotCells, slots = [];
54
- let fillLayout, fillSource, fills = [];
55
- let bevelKey = "", bevelLayout, bevels = /* @__PURE__ */ new Map();
56
- return (layout, o) => {
57
- const key = JSON.stringify([o.count === Infinity ? -1 : o.count, o.aspects, o.placement, o.choose, typeof o.contentCells === "function" ? 0 : o.contentCells]);
58
- if (layout !== slotLayout || key !== slotKey || o.contentCells !== slotCells) {
59
- slots = o.aspects && o.count !== Infinity ? matchSlots(layout, Array.from({ length: o.count }, (_, i) => o.aspects[i] ?? 1), { cells: o.contentCells, placement: o.placement, choose: o.choose }) : contentSlots(layout, o.count, { cells: o.contentCells, placement: o.placement });
60
- slotLayout = layout;
61
- slotKey = key;
62
- slotCells = o.contentCells;
63
- }
64
- const fill = o.fill ?? neutralPalette;
65
- if (layout !== fillLayout || fill !== fillSource) {
66
- fills = resolveFills(layout, fill);
67
- fillLayout = layout;
68
- fillSource = fill;
69
- }
70
- const relief = o.relief === true ? {} : o.relief || void 0;
71
- const rk = relief ? JSON.stringify(relief) : "";
72
- if (layout !== bevelLayout || rk !== bevelKey) {
73
- bevels = /* @__PURE__ */ new Map();
74
- bevelLayout = layout;
75
- bevelKey = rk;
76
- }
77
- const width = relief ? relief.bevel ?? defaultBevel(layout) : 0;
78
- const cache = bevels;
79
- const anim = o.animate ? {
80
- duration: (typeof o.animate === "object" ? o.animate.duration : void 0) ?? 400,
81
- easing: (typeof o.animate === "object" ? o.animate.easing : void 0) ?? "cubic-bezier(0.2, 0.8, 0.2, 1)"
82
- } : void 0;
83
- const timing = anim ? `${anim.duration}ms ${anim.easing}` : "";
84
- const boxTransition = anim ? ["left", "top", "width", "height"].map((p) => `${p} ${timing}`).join(", ") : void 0;
85
- return {
86
- layout,
87
- slots,
88
- fills,
89
- bevel(i) {
90
- if (!relief || width <= 0) return void 0;
91
- let b = cache.get(i);
92
- if (!b) cache.set(i, b = reliefPaths(layout, layout.cells[i], relief, width));
93
- return b;
94
- },
95
- shadow: relief ? shadowOffset(relief) : void 0,
96
- anim,
97
- boxTransition,
98
- tileTransition: anim ? `${boxTransition}, clip-path ${timing}, background-color ${timing}` : void 0
99
- };
100
- };
101
- }
102
- var containerStyle = (layout) => ({
103
- position: "relative",
104
- width: "100%",
105
- aspectRatio: `${layout.bounds.width} / ${layout.bounds.height}`
106
- });
107
- var backgroundStyle = (frame, background) => ({
108
- position: "absolute",
109
- inset: "0",
110
- background,
111
- clipPath: regionCss(frame.layout),
112
- transition: frame.anim ? `clip-path ${frame.anim.duration}ms ${frame.anim.easing}` : void 0
113
- });
114
- function tileStyle(frame, cell, o) {
115
- return {
116
- ...o.focus && !o.empty ? focusStyle(frame, cell, o.focus, o.aspect) : {},
117
- position: "absolute",
118
- boxSizing: "border-box",
119
- overflow: "hidden",
120
- ...cellCss(cell, frame.layout, 4, frame.anim ? { points: MORPH_POINTS } : {}),
121
- transition: frame.tileTransition,
122
- background: (o.empty || o.safeArea) && !o.backdrop ? frame.fills[cell.index] : void 0,
123
- cursor: o.clickable ? "pointer" : void 0
124
- };
125
- }
126
- function focusStyle(frame, cell, focus, aspect) {
127
- const shape = aspect ?? focus.aspect;
128
- const pos = shape && shape > 0 ? objectPosition(cell, frame.layout, { aspect: shape, focus }) : `${focus.x * 100}% ${focus.y * 100}%`;
129
- return { "--andamento-object-position": pos };
130
- }
131
- var backdropStyle = (frame, cell) => ({
132
- position: "absolute",
133
- zIndex: -1,
134
- pointerEvents: "none",
135
- ...backdropCss(cell, frame.layout),
136
- transition: frame.boxTransition
137
- });
138
- var safeBoxStyle = (frame, cell, aspect, safe) => ({
139
- position: "absolute",
140
- boxSizing: "border-box",
141
- ...safeAreaCss(cell, frame.layout, { aspect, within: safe === "visible" ? "visible" : "tile" }),
142
- transition: frame.boxTransition
143
- });
144
- var overlayStyle = { position: "absolute", inset: "0", width: "100%", height: "100%", pointerEvents: "none" };
145
- var tileViewBox = (cell) => {
146
- const b = cellShape(cell).bbox;
147
- return `${b.x} ${b.y} ${b.width} ${b.height}`;
148
- };
149
- var ringStrokes = (frame, cell, color) => {
150
- const d = cellPath(frame.layout, cell);
151
- return [
152
- { d, stroke: "#fff", width: 8 },
153
- { d, stroke: color, width: 4 }
154
- ];
155
- };
156
- function shadowShape(frame, cells) {
157
- const s = frame.shadow;
158
- if (!s) return void 0;
159
- const { bounds } = frame.layout;
160
- return {
161
- viewBox: `${bounds.x} ${bounds.y} ${bounds.width} ${bounds.height}`,
162
- style: { ...overlayStyle, clipPath: viewCss(frame.layout) },
163
- blur: s.blur,
164
- d: cells.map((c) => cellPath(frame.layout, c)).join(""),
165
- transform: `translate(${s.dx} ${s.dy})`,
166
- opacity: s.opacity
167
- };
168
- }
169
- function keyAction(layout, from, key, accept, canActivate) {
170
- const dirs = { ArrowUp: "up", ArrowDown: "down", ArrowLeft: "left", ArrowRight: "right" };
171
- let to;
172
- if (dirs[key]) to = cellInDirection(layout, from, dirs[key], accept);
173
- else if (key === "Home") to = layout.cells.find(accept);
174
- else if (key === "End") to = [...layout.cells].reverse().find(accept);
175
- else if ((key === "Enter" || key === " ") && canActivate) return { activate: true };
176
- if (to) return { move: to };
177
- return key.startsWith("Arrow") ? { prevent: true } : void 0;
178
- }
179
- function tileSheet(o) {
180
- let css = "";
181
- if (o.focusRing)
182
- css += "[data-andamento]>[data-cell-id]:focus{outline:none}[data-andamento]>[data-cell-id]>[data-focus-ring]{display:none}[data-andamento]>[data-cell-id]:focus-visible>[data-focus-ring]{display:block}";
183
- if (o.anim) {
184
- const { duration, easing } = o.anim;
185
- css += `@keyframes andamento-enter{from{opacity:0;transform:scale(.85)}}@keyframes andamento-exit{to{opacity:0;transform:scale(.85)}}@keyframes andamento-late{0%,70%{opacity:0}to{opacity:1}}[data-andamento]>[data-entering]{animation:andamento-enter ${duration}ms ${easing} backwards}[data-andamento]>[data-exiting]{animation:andamento-exit ${duration}ms ${easing} forwards;pointer-events:none}[data-andamento]>[data-cell-id]>[data-late]{animation:andamento-late ${duration}ms linear backwards}@media (prefers-reduced-motion:reduce){[data-andamento]>[data-cell-id],[data-andamento]>[data-cell-id] *{transition:none!important;animation:none!important}[data-andamento]>[data-exiting]{display:none}}`;
186
- }
187
- return css;
188
- }
189
- var NOTHING_IN_VIEW = { x: 0, y: 0, width: -1, height: -1 };
190
- function viewRect(el, layout, overscan) {
191
- const box = el.getBoundingClientRect();
192
- const seen = visibleClientRect(el, box);
193
- const { bounds } = layout;
194
- const scale = Math.min(box.width / (bounds.width || 1), box.height / (bounds.height || 1));
195
- if (!seen || !(scale > 0)) return NOTHING_IN_VIEW;
196
- const a = screenToLayout(layout, box, seen.left - overscan, seen.top - overscan);
197
- const b = screenToLayout(layout, box, seen.right + overscan, seen.bottom + overscan);
198
- const q = Math.max(overscan / 2, 50) / scale;
199
- const x0 = Math.floor(a.x / q) * q, y0 = Math.floor(a.y / q) * q;
200
- return { x: x0, y: y0, width: Math.ceil(b.x / q) * q - x0, height: Math.ceil(b.y / q) * q - y0 };
201
- }
202
- var sameRect = (a, b) => !!a && !!b && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
203
- function watchView(el, measure) {
204
- const raf = typeof requestAnimationFrame === "function" ? requestAnimationFrame : (f) => setTimeout(f, 16);
205
- const cancel = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : (h) => clearTimeout(h);
206
- let frame = 0;
207
- const run = () => {
208
- frame = 0;
209
- measure();
210
- };
211
- const schedule = () => {
212
- if (!frame) frame = raf(run);
213
- };
214
- measure();
215
- window.addEventListener("scroll", schedule, { capture: true, passive: true });
216
- window.addEventListener("resize", schedule);
217
- const observer = typeof ResizeObserver === "function" ? new ResizeObserver(schedule) : void 0;
218
- observer?.observe(el);
219
- return () => {
220
- if (frame) cancel(frame);
221
- window.removeEventListener("scroll", schedule, { capture: true });
222
- window.removeEventListener("resize", schedule);
223
- observer?.disconnect();
224
- };
225
- }
226
- function visibleClientRect(el, box) {
227
- let left = Math.max(box.left, 0);
228
- let top = Math.max(box.top, 0);
229
- let right = Math.min(box.right, window.innerWidth || document.documentElement.clientWidth);
230
- let bottom = Math.min(box.bottom, window.innerHeight || document.documentElement.clientHeight);
231
- const parent = (n) => n.parentElement ?? (n.parentNode?.host ?? null);
232
- for (let p = parent(el); p && p !== document.body && p !== document.documentElement; p = parent(p)) {
233
- const s = getComputedStyle(p);
234
- if (/(auto|scroll|hidden|clip)/.test(`${s.overflow} ${s.overflowX} ${s.overflowY}`)) {
235
- const r = p.getBoundingClientRect();
236
- left = Math.max(left, r.left);
237
- top = Math.max(top, r.top);
238
- right = Math.min(right, r.right);
239
- bottom = Math.min(bottom, r.bottom);
240
- }
241
- }
242
- return right > left && bottom > top ? { left, top, right, bottom } : void 0;
243
- }
244
- var coverStyle = {
245
- display: "block",
246
- width: "100%",
247
- height: "100%",
248
- objectFit: "cover",
249
- // Set by the tile from the item's focal point (see `focalPoints`); centerd otherwise.
250
- objectPosition: "var(--andamento-object-position, 50% 50%)"
251
- };
2
+ __privateAdd,
3
+ __privateGet,
4
+ __privateMethod,
5
+ __privateSet,
6
+ backdropStyle,
7
+ backgroundStyle,
8
+ containerStyle,
9
+ coverStyle,
10
+ frameBuilder,
11
+ keyAction,
12
+ layoutResolver,
13
+ overlayStyle,
14
+ resolvePerCell,
15
+ ringStrokes,
16
+ safeBoxStyle,
17
+ sameRect,
18
+ shadowShape,
19
+ tileSheet,
20
+ tileStyle,
21
+ tileViewBox,
22
+ viewRect,
23
+ watchView
24
+ } from "./chunk-RCXEXYRF.js";
252
25
 
253
26
  // src/mount.ts
27
+ import { cellsInRect } from "@andamento/core";
254
28
  var SVG = "http://www.w3.org/2000/svg";
255
29
  var kebab = (k) => k.startsWith("--") ? k : k.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
256
30
  var isEmpty = (c) => c == null || c === "";
@@ -410,7 +184,10 @@ function mountTileLayout(target, initial) {
410
184
  attr(el, "data-index", cell.index);
411
185
  attr(el, "data-empty", empty);
412
186
  attr(el, "data-boundary", !!cell.boundary);
413
- for (const [k, v] of Object.entries(resolvePerCell(c.cellAttributes, cell, state) ?? {})) attr(el, k, v);
187
+ const extra = resolvePerCell(c.cellAttributes, cell, state) ?? {};
188
+ for (const k of tile.extra ?? []) if (!(k in extra)) attr(el, k, void 0);
189
+ for (const [k, v] of Object.entries(extra)) attr(el, k, v);
190
+ tile.extra = Object.keys(extra);
414
191
  applyStyle(el, {
415
192
  ...tileStyle(frame, cell, {
416
193
  empty,
@@ -518,8 +295,11 @@ function mountTileLayout(target, initial) {
518
295
  t.el.focus();
519
296
  }
520
297
  }
521
- if (virtual && !stopWatching) stopWatching = watchView(container, measure);
522
- else if (!virtual && stopWatching) {
298
+ if (virtual && !stopWatching) {
299
+ let stop;
300
+ stopWatching = () => stop?.();
301
+ stop = watchView(container, measure);
302
+ } else if (!virtual && stopWatching) {
523
303
  stopWatching();
524
304
  stopWatching = void 0;
525
305
  view = void 0;
@@ -925,43 +705,23 @@ function defineTileLayoutElement(tagName = "andamento-layout") {
925
705
  }
926
706
 
927
707
  // src/pointer.ts
928
- import { cellAt, screenToLayout as screenToLayout2 } from "@andamento/core";
708
+ import { cellAt, screenToLayout } from "@andamento/core";
929
709
  function cellFromPointer(layout, event, options = {}) {
930
710
  const el = options.element ?? event.currentTarget;
931
711
  if (!el || typeof el.getBoundingClientRect !== "function") return void 0;
932
- const point = screenToLayout2(layout, el.getBoundingClientRect(), event.clientX, event.clientY);
712
+ const point = screenToLayout(layout, el.getBoundingClientRect(), event.clientX, event.clientY);
933
713
  return cellAt(layout, point, options);
934
714
  }
935
715
 
936
716
  // src/index.ts
937
- import { defaultPalette, neutralPalette as neutralPalette2 } from "@andamento/svg";
717
+ import { defaultPalette, neutralPalette } from "@andamento/svg";
938
718
  export {
939
719
  AndamentoLayoutElement,
940
- MORPH_POINTS,
941
- NOTHING_IN_VIEW,
942
- backdropStyle,
943
- backgroundStyle,
944
720
  cellFromPointer,
945
- containerStyle,
946
721
  coverStyle,
947
722
  defaultPalette,
948
723
  defineTileLayoutElement,
949
- focusStyle,
950
- frameBuilder,
951
- keyAction,
952
- layoutResolver,
953
724
  mountTileLayout,
954
- neutralPalette2 as neutralPalette,
955
- overlayStyle,
956
- resolvePerCell,
957
- ringStrokes,
958
- safeBoxStyle,
959
- sameRect,
960
- shadowShape,
961
- tileSheet,
962
- tileStyle,
963
- tileViewBox,
964
- viewRect,
965
- watchView
725
+ neutralPalette
966
726
  };
967
727
  //# sourceMappingURL=index.js.map