@andamento/dom 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/chunk-276TFSAG.cjs +299 -0
- package/dist/chunk-276TFSAG.cjs.map +1 -0
- package/dist/chunk-RCXEXYRF.js +299 -0
- package/dist/chunk-RCXEXYRF.js.map +1 -0
- package/dist/index.cjs +727 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +242 -0
- package/dist/index.d.ts +242 -0
- package/dist/index.js +727 -0
- package/dist/index.js.map +1 -0
- package/dist/internal-NveCwJWd.d.cts +169 -0
- package/dist/internal-NveCwJWd.d.ts +169 -0
- package/dist/internal.cjs +47 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +3 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +47 -0
- package/dist/internal.js.map +1 -0
- package/package.json +73 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _chunk276TFSAGcjs = require('./chunk-276TFSAG.cjs');
|
|
25
|
+
|
|
26
|
+
// src/mount.ts
|
|
27
|
+
var _core = require('@andamento/core');
|
|
28
|
+
var SVG = "http://www.w3.org/2000/svg";
|
|
29
|
+
var kebab = (k) => k.startsWith("--") ? k : k.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
30
|
+
var isEmpty = (c) => c == null || c === "";
|
|
31
|
+
var styleMemo = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
function applyStyle(el, next) {
|
|
33
|
+
const prev = _nullishCoalesce(styleMemo.get(el), () => ( {}));
|
|
34
|
+
for (const k of Object.keys(prev)) if (next[k] === void 0 && prev[k] !== void 0) el.style.removeProperty(kebab(k));
|
|
35
|
+
for (const [k, v] of Object.entries(next)) if (v !== void 0 && prev[k] !== v) el.style.setProperty(kebab(k), String(v));
|
|
36
|
+
styleMemo.set(el, next);
|
|
37
|
+
}
|
|
38
|
+
function attr(el, name, value) {
|
|
39
|
+
if (value === void 0 || value === null || value === false) {
|
|
40
|
+
if (el.hasAttribute(name)) el.removeAttribute(name);
|
|
41
|
+
} else {
|
|
42
|
+
const v = value === true ? "" : String(value);
|
|
43
|
+
if (el.getAttribute(name) !== v) el.setAttribute(name, v);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function setChildren(parent, nodes) {
|
|
47
|
+
let at = parent.firstChild;
|
|
48
|
+
for (const n of nodes) {
|
|
49
|
+
if (n === at) at = at.nextSibling;
|
|
50
|
+
else parent.insertBefore(n, at);
|
|
51
|
+
}
|
|
52
|
+
while (at) {
|
|
53
|
+
const next = at.nextSibling;
|
|
54
|
+
parent.removeChild(at);
|
|
55
|
+
at = next;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function svg(tag, attrs, children = []) {
|
|
59
|
+
const el = document.createElementNS(SVG, tag);
|
|
60
|
+
for (const [k, v] of Object.entries(attrs)) if (v !== void 0) el.setAttribute(k, String(v));
|
|
61
|
+
for (const c of children) el.appendChild(c);
|
|
62
|
+
return el;
|
|
63
|
+
}
|
|
64
|
+
var nodeIds = /* @__PURE__ */ new WeakMap();
|
|
65
|
+
var nextNodeId = 1;
|
|
66
|
+
var nodeId = (n) => {
|
|
67
|
+
let id = nodeIds.get(n);
|
|
68
|
+
if (!id) nodeIds.set(n, id = nextNodeId++);
|
|
69
|
+
return id;
|
|
70
|
+
};
|
|
71
|
+
var uidCount = 0;
|
|
72
|
+
function mountTileLayout(target, initial) {
|
|
73
|
+
let config = { ...initial };
|
|
74
|
+
const uid = `andamento-dom${++uidCount}`;
|
|
75
|
+
const resolveLayout = _chunk276TFSAGcjs.layoutResolver.call(void 0, "mountTileLayout");
|
|
76
|
+
const buildFrame = _chunk276TFSAGcjs.frameBuilder.call(void 0, );
|
|
77
|
+
const container = document.createElement("div");
|
|
78
|
+
container.setAttribute("data-andamento", "");
|
|
79
|
+
target.appendChild(container);
|
|
80
|
+
const sheet = document.createElement("style");
|
|
81
|
+
const backgroundEl = document.createElement("div");
|
|
82
|
+
backgroundEl.setAttribute("aria-hidden", "true");
|
|
83
|
+
const blur = svg("feGaussianBlur", {});
|
|
84
|
+
const shadowPath = svg("path", { "fill-rule": "evenodd", fill: "#000", filter: `url(#${uid}-shadow)` });
|
|
85
|
+
const shadowEl = svg("svg", { "aria-hidden": "true", "data-andamento-shadow": "", preserveAspectRatio: "none" }, [
|
|
86
|
+
svg("filter", { id: `${uid}-shadow`, x: "-10%", y: "-10%", width: "120%", height: "120%" }, [blur]),
|
|
87
|
+
shadowPath
|
|
88
|
+
]);
|
|
89
|
+
let layout;
|
|
90
|
+
let tiles = /* @__PURE__ */ new Map();
|
|
91
|
+
const leaving = /* @__PURE__ */ new Set();
|
|
92
|
+
const byElement = /* @__PURE__ */ new WeakMap();
|
|
93
|
+
let lastKeys = /* @__PURE__ */ new Set();
|
|
94
|
+
let mounted = false;
|
|
95
|
+
let activeId;
|
|
96
|
+
let pendingFocus;
|
|
97
|
+
let focusable = /* @__PURE__ */ new Set();
|
|
98
|
+
let view;
|
|
99
|
+
let stopWatching;
|
|
100
|
+
let watchedLayout;
|
|
101
|
+
const timers = /* @__PURE__ */ new Set();
|
|
102
|
+
let destroyed = false;
|
|
103
|
+
function render() {
|
|
104
|
+
if (destroyed) return;
|
|
105
|
+
const c = config;
|
|
106
|
+
const items = c.renderCell ? [] : _nullishCoalesce(c.items, () => ( []));
|
|
107
|
+
layout = resolveLayout(c.options, c.layout, {
|
|
108
|
+
fit: !c.renderCell && c.fit,
|
|
109
|
+
count: items.length,
|
|
110
|
+
cells: c.contentCells,
|
|
111
|
+
weights: c.renderCell ? void 0 : c.weights,
|
|
112
|
+
placement: c.placement
|
|
113
|
+
});
|
|
114
|
+
const frame = buildFrame(layout, {
|
|
115
|
+
count: c.renderCell ? Infinity : items.length,
|
|
116
|
+
aspects: c.renderCell ? void 0 : c.aspects,
|
|
117
|
+
contentCells: c.contentCells,
|
|
118
|
+
placement: c.placement,
|
|
119
|
+
choose: c.choose,
|
|
120
|
+
fill: c.fill,
|
|
121
|
+
relief: c.relief,
|
|
122
|
+
animate: c.animate
|
|
123
|
+
});
|
|
124
|
+
const { slots } = frame;
|
|
125
|
+
const focusRing = c.focusRing === void 0 ? "#1a56db" : c.focusRing;
|
|
126
|
+
const list = (_nullishCoalesce(c.role, () => ( "list"))) === "list";
|
|
127
|
+
const virtual = !!c.virtualize;
|
|
128
|
+
const keyOf = (i) => {
|
|
129
|
+
const slot = slots[i];
|
|
130
|
+
if (!c.renderCell && slot >= 0) {
|
|
131
|
+
const item = items[slot];
|
|
132
|
+
return item && typeof item === "object" ? `n${nodeId(item)}` : `i${slot}`;
|
|
133
|
+
}
|
|
134
|
+
return `c${layout.cells[i].id}`;
|
|
135
|
+
};
|
|
136
|
+
const hasContent = (i) => c.renderCell ? slots[i] >= 0 : slots[i] >= 0 && !isEmpty(items[slots[i]]);
|
|
137
|
+
focusable = new Set(c.navigable ? layout.cells.filter((cell) => hasContent(cell.index)).map((cell) => cell.id) : []);
|
|
138
|
+
const firstFocusable = _optionalChain([layout, 'access', _2 => _2.cells, 'access', _3 => _3.find, 'call', _4 => _4((cell) => focusable.has(cell.id)), 'optionalAccess', _5 => _5.id]);
|
|
139
|
+
const active = activeId !== void 0 && focusable.has(activeId) ? activeId : firstFocusable;
|
|
140
|
+
let shown;
|
|
141
|
+
if (!virtual) shown = layout.cells.map((_, i) => i);
|
|
142
|
+
else {
|
|
143
|
+
const s = new Set(view && view.width >= 0 ? _core.cellsInRect.call(void 0, layout, view).map((cell) => cell.index) : []);
|
|
144
|
+
const a = active !== void 0 ? layout.cells.find((cell) => cell.id === active) : void 0;
|
|
145
|
+
if (a) s.add(a.index);
|
|
146
|
+
shown = [...s].sort((x, y) => x - y);
|
|
147
|
+
}
|
|
148
|
+
let positions;
|
|
149
|
+
if (virtual) {
|
|
150
|
+
positions = /* @__PURE__ */ new Map();
|
|
151
|
+
for (const cell of layout.cells) if (hasContent(cell.index)) positions.set(cell.index, positions.size + 1);
|
|
152
|
+
}
|
|
153
|
+
const allKeys = frame.anim || virtual ? new Set(layout.cells.map((_, i) => keyOf(i))) : void 0;
|
|
154
|
+
const next = /* @__PURE__ */ new Map();
|
|
155
|
+
for (const i of shown) {
|
|
156
|
+
const cell = layout.cells[i];
|
|
157
|
+
const slot = slots[i];
|
|
158
|
+
const key = keyOf(i);
|
|
159
|
+
let content = c.renderCell ? c.renderCell(cell, { slot }) : slot >= 0 ? items[slot] : void 0;
|
|
160
|
+
const empty = isEmpty(content);
|
|
161
|
+
const state = { empty, slot: empty && !c.renderCell ? -1 : slot };
|
|
162
|
+
if (empty) content = _chunk276TFSAGcjs.resolvePerCell.call(void 0, c.fallback, cell, state);
|
|
163
|
+
const silent = empty && isEmpty(content);
|
|
164
|
+
let tile = tiles.get(key);
|
|
165
|
+
if (!tile || tile.leaving) {
|
|
166
|
+
const el2 = document.createElement("div");
|
|
167
|
+
tile = { key, el: el2, cell, state, empty };
|
|
168
|
+
if (frame.anim && mounted && !lastKeys.has(key)) el2.setAttribute("data-entering", "");
|
|
169
|
+
}
|
|
170
|
+
tiles.delete(key);
|
|
171
|
+
next.set(key, tile);
|
|
172
|
+
Object.assign(tile, { cell, state, empty });
|
|
173
|
+
const el = tile.el;
|
|
174
|
+
byElement.set(el, tile);
|
|
175
|
+
const canFocus = focusable.has(cell.id);
|
|
176
|
+
attr(el, "role", silent ? void 0 : list ? "listitem" : void 0);
|
|
177
|
+
attr(el, "aria-hidden", silent ? "true" : void 0);
|
|
178
|
+
attr(el, "aria-label", silent ? void 0 : _chunk276TFSAGcjs.resolvePerCell.call(void 0, c.cellLabel, cell, state));
|
|
179
|
+
attr(el, "aria-setsize", positions && list && !silent ? positions.size : void 0);
|
|
180
|
+
attr(el, "aria-posinset", positions && list && !silent ? positions.get(i) : void 0);
|
|
181
|
+
attr(el, "tabindex", canFocus ? cell.id === active ? 0 : -1 : void 0);
|
|
182
|
+
attr(el, "class", _chunk276TFSAGcjs.resolvePerCell.call(void 0, c.cellClass, cell, state) || void 0);
|
|
183
|
+
attr(el, "data-cell-id", cell.id);
|
|
184
|
+
attr(el, "data-index", cell.index);
|
|
185
|
+
attr(el, "data-empty", empty);
|
|
186
|
+
attr(el, "data-boundary", !!cell.boundary);
|
|
187
|
+
const extra = _nullishCoalesce(_chunk276TFSAGcjs.resolvePerCell.call(void 0, c.cellAttributes, cell, state), () => ( {}));
|
|
188
|
+
for (const k of _nullishCoalesce(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);
|
|
191
|
+
applyStyle(el, {
|
|
192
|
+
..._chunk276TFSAGcjs.tileStyle.call(void 0, frame, cell, {
|
|
193
|
+
empty,
|
|
194
|
+
safeArea: c.safeArea,
|
|
195
|
+
backdrop: c.backdrop != null,
|
|
196
|
+
clickable: !!c.onCellActivate && !empty,
|
|
197
|
+
focus: slot >= 0 ? _optionalChain([c, 'access', _6 => _6.focalPoints, 'optionalAccess', _7 => _7[slot]]) : void 0,
|
|
198
|
+
aspect: slot >= 0 ? _optionalChain([c, 'access', _8 => _8.aspects, 'optionalAccess', _9 => _9[slot]]) : void 0
|
|
199
|
+
}),
|
|
200
|
+
..._chunk276TFSAGcjs.resolvePerCell.call(void 0, c.cellStyle, cell, state)
|
|
201
|
+
});
|
|
202
|
+
const kids = [];
|
|
203
|
+
if (c.backdrop != null) {
|
|
204
|
+
if (!tile.backdrop || tile.backdrop.source !== c.backdrop) {
|
|
205
|
+
const node2 = typeof c.backdrop === "function" ? c.backdrop() : c.backdrop.cloneNode(true);
|
|
206
|
+
const wrap = document.createElement("div");
|
|
207
|
+
wrap.setAttribute("aria-hidden", "true");
|
|
208
|
+
wrap.appendChild(node2);
|
|
209
|
+
tile.backdrop = { source: c.backdrop, node: wrap };
|
|
210
|
+
}
|
|
211
|
+
applyStyle(tile.backdrop.node, _chunk276TFSAGcjs.backdropStyle.call(void 0, frame, cell));
|
|
212
|
+
kids.push(tile.backdrop.node);
|
|
213
|
+
} else tile.backdrop = void 0;
|
|
214
|
+
let node;
|
|
215
|
+
if (typeof content === "string") {
|
|
216
|
+
if (!tile.text) tile.text = document.createTextNode(content);
|
|
217
|
+
else if (tile.text.data !== content) tile.text.data = content;
|
|
218
|
+
node = tile.text;
|
|
219
|
+
} else if (content) node = content;
|
|
220
|
+
if (node && c.safeArea) {
|
|
221
|
+
if (!tile.safe) {
|
|
222
|
+
tile.safe = document.createElement("div");
|
|
223
|
+
tile.safe.setAttribute("data-safe-area", "");
|
|
224
|
+
}
|
|
225
|
+
const aspect = !c.renderCell && !empty && c.aspects ? _nullishCoalesce(c.aspects[slot], () => ( 1)) : void 0;
|
|
226
|
+
applyStyle(tile.safe, _chunk276TFSAGcjs.safeBoxStyle.call(void 0, frame, cell, aspect, c.safeArea));
|
|
227
|
+
setChildren(tile.safe, [node]);
|
|
228
|
+
kids.push(tile.safe);
|
|
229
|
+
} else if (node) kids.push(node);
|
|
230
|
+
const bevel = frame.bevel(i);
|
|
231
|
+
if (bevel && bevel.length) {
|
|
232
|
+
const clip = frame.anim ? String(el.style.getPropertyValue("clip-path")) : "";
|
|
233
|
+
const bk = _chunk276TFSAGcjs.tileViewBox.call(void 0, cell) + clip + bevel.map((p) => p.d + p.fill + p.opacity).join();
|
|
234
|
+
if (_optionalChain([tile, 'access', _10 => _10.bevel, 'optionalAccess', _11 => _11.key]) !== bk) {
|
|
235
|
+
const s = svg(
|
|
236
|
+
"svg",
|
|
237
|
+
{ "aria-hidden": "true", "data-bevel": "", "data-late": frame.anim ? "" : void 0, viewBox: _chunk276TFSAGcjs.tileViewBox.call(void 0, cell), preserveAspectRatio: "none" },
|
|
238
|
+
bevel.map((p) => svg("path", { d: p.d, fill: p.fill, "fill-opacity": p.opacity }))
|
|
239
|
+
);
|
|
240
|
+
applyStyle(s, _chunk276TFSAGcjs.overlayStyle);
|
|
241
|
+
tile.bevel = { key: bk, node: s };
|
|
242
|
+
}
|
|
243
|
+
kids.push(tile.bevel.node);
|
|
244
|
+
} else tile.bevel = void 0;
|
|
245
|
+
if (canFocus && focusRing !== false) {
|
|
246
|
+
const strokes = _chunk276TFSAGcjs.ringStrokes.call(void 0, frame, cell, focusRing);
|
|
247
|
+
const rk = _chunk276TFSAGcjs.tileViewBox.call(void 0, cell) + strokes[0].d + focusRing;
|
|
248
|
+
if (_optionalChain([tile, 'access', _12 => _12.ring, 'optionalAccess', _13 => _13.key]) !== rk) {
|
|
249
|
+
const s = svg(
|
|
250
|
+
"svg",
|
|
251
|
+
{ "aria-hidden": "true", "data-focus-ring": "", viewBox: _chunk276TFSAGcjs.tileViewBox.call(void 0, cell), preserveAspectRatio: "none" },
|
|
252
|
+
strokes.map((p) => svg("path", { d: p.d, fill: "none", stroke: p.stroke, "stroke-width": p.width, "vector-effect": "non-scaling-stroke" }))
|
|
253
|
+
);
|
|
254
|
+
applyStyle(s, _chunk276TFSAGcjs.overlayStyle);
|
|
255
|
+
tile.ring = { key: rk, node: s };
|
|
256
|
+
}
|
|
257
|
+
kids.push(tile.ring.node);
|
|
258
|
+
} else tile.ring = void 0;
|
|
259
|
+
setChildren(el, kids);
|
|
260
|
+
}
|
|
261
|
+
const present = _nullishCoalesce(allKeys, () => ( new Set(next.keys())));
|
|
262
|
+
for (const tile of tiles.values()) {
|
|
263
|
+
if (frame.anim && mounted && !present.has(tile.key)) startLeaving(tile, frame.anim.duration);
|
|
264
|
+
}
|
|
265
|
+
tiles = next;
|
|
266
|
+
attr(container, "role", _nullishCoalesce(c.role, () => ( "list")));
|
|
267
|
+
attr(container, "aria-label", c.label);
|
|
268
|
+
attr(container, "class", c.className);
|
|
269
|
+
applyStyle(container, _chunk276TFSAGcjs.containerStyle.call(void 0, layout));
|
|
270
|
+
const css = _chunk276TFSAGcjs.tileSheet.call(void 0, { focusRing: !!c.navigable && focusRing !== false, anim: frame.anim });
|
|
271
|
+
if (sheet.textContent !== css) sheet.textContent = css;
|
|
272
|
+
const top = [];
|
|
273
|
+
if (css) top.push(sheet);
|
|
274
|
+
if (c.background) {
|
|
275
|
+
applyStyle(backgroundEl, _chunk276TFSAGcjs.backgroundStyle.call(void 0, frame, c.background));
|
|
276
|
+
top.push(backgroundEl);
|
|
277
|
+
}
|
|
278
|
+
const shadow = _chunk276TFSAGcjs.shadowShape.call(void 0, frame, shown.map((i) => layout.cells[i]));
|
|
279
|
+
if (shadow) {
|
|
280
|
+
attr(shadowEl, "viewBox", shadow.viewBox);
|
|
281
|
+
applyStyle(shadowEl, shadow.style);
|
|
282
|
+
attr(blur, "stdDeviation", shadow.blur);
|
|
283
|
+
attr(shadowPath, "d", shadow.d);
|
|
284
|
+
attr(shadowPath, "transform", shadow.transform);
|
|
285
|
+
attr(shadowPath, "fill-opacity", shadow.opacity);
|
|
286
|
+
top.push(shadowEl);
|
|
287
|
+
}
|
|
288
|
+
setChildren(container, [...top, ...[...tiles.values()].map((t) => t.el), ...[...leaving].map((t) => t.el)]);
|
|
289
|
+
lastKeys = present;
|
|
290
|
+
mounted = true;
|
|
291
|
+
if (pendingFocus) {
|
|
292
|
+
const t = [...tiles.values()].find((x) => x.cell.id === pendingFocus);
|
|
293
|
+
if (t) {
|
|
294
|
+
pendingFocus = void 0;
|
|
295
|
+
t.el.focus();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (virtual && !stopWatching) {
|
|
299
|
+
let stop;
|
|
300
|
+
stopWatching = () => _optionalChain([stop, 'optionalCall', _14 => _14()]);
|
|
301
|
+
stop = _chunk276TFSAGcjs.watchView.call(void 0, container, measure);
|
|
302
|
+
} else if (!virtual && stopWatching) {
|
|
303
|
+
stopWatching();
|
|
304
|
+
stopWatching = void 0;
|
|
305
|
+
view = void 0;
|
|
306
|
+
} else if (virtual && watchedLayout !== layout) queueMicrotask(measure);
|
|
307
|
+
watchedLayout = layout;
|
|
308
|
+
}
|
|
309
|
+
function measure() {
|
|
310
|
+
if (destroyed || !config.virtualize) return;
|
|
311
|
+
const overscan = Math.max(0, _nullishCoalesce((typeof config.virtualize === "object" ? config.virtualize.overscan : void 0), () => ( 300)));
|
|
312
|
+
const next = _chunk276TFSAGcjs.viewRect.call(void 0, container, layout, overscan);
|
|
313
|
+
if (!_chunk276TFSAGcjs.sameRect.call(void 0, next, view)) {
|
|
314
|
+
view = next;
|
|
315
|
+
render();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function startLeaving(tile, duration) {
|
|
319
|
+
tile.leaving = true;
|
|
320
|
+
const el = tile.el;
|
|
321
|
+
for (const a of ["role", "tabindex", "aria-label", "aria-setsize", "aria-posinset", "data-entering"]) el.removeAttribute(a);
|
|
322
|
+
el.setAttribute("aria-hidden", "true");
|
|
323
|
+
el.setAttribute("data-exiting", "");
|
|
324
|
+
leaving.add(tile);
|
|
325
|
+
const timer = setTimeout(() => {
|
|
326
|
+
timers.delete(timer);
|
|
327
|
+
leaving.delete(tile);
|
|
328
|
+
el.remove();
|
|
329
|
+
}, duration);
|
|
330
|
+
timers.add(timer);
|
|
331
|
+
}
|
|
332
|
+
const tileOf = (e) => {
|
|
333
|
+
for (const n of e.composedPath()) {
|
|
334
|
+
if (n === container) return void 0;
|
|
335
|
+
if (n instanceof Element && n.parentNode === container) {
|
|
336
|
+
const t = byElement.get(n);
|
|
337
|
+
return t && !t.leaving ? t : void 0;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return void 0;
|
|
341
|
+
};
|
|
342
|
+
const setActive = (id) => {
|
|
343
|
+
if (id === activeId) return;
|
|
344
|
+
activeId = id;
|
|
345
|
+
for (const t of tiles.values()) if (focusable.has(t.cell.id)) attr(t.el, "tabindex", t.cell.id === id ? 0 : -1);
|
|
346
|
+
};
|
|
347
|
+
const onClick = (e) => {
|
|
348
|
+
const t = tileOf(e);
|
|
349
|
+
if (t && !t.empty && config.onCellActivate) config.onCellActivate(t.cell, t.state);
|
|
350
|
+
};
|
|
351
|
+
const onFocusIn = (e) => {
|
|
352
|
+
const t = tileOf(e);
|
|
353
|
+
if (t && e.target === t.el && focusable.has(t.cell.id)) setActive(t.cell.id);
|
|
354
|
+
};
|
|
355
|
+
const onKeyDown = (e) => {
|
|
356
|
+
if (e.defaultPrevented || !config.navigable || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
357
|
+
const t = tileOf(e);
|
|
358
|
+
if (!t || e.target !== t.el || !focusable.has(t.cell.id)) return;
|
|
359
|
+
const action = _chunk276TFSAGcjs.keyAction.call(void 0, layout, t.cell, e.key, (cell) => focusable.has(cell.id), !!config.onCellActivate);
|
|
360
|
+
if (!action) return;
|
|
361
|
+
e.preventDefault();
|
|
362
|
+
if ("activate" in action) config.onCellActivate(t.cell, t.state);
|
|
363
|
+
else if ("move" in action) {
|
|
364
|
+
const to = action.move;
|
|
365
|
+
setActive(to.id);
|
|
366
|
+
const shownTile = [...tiles.values()].find((x) => x.cell.id === to.id);
|
|
367
|
+
if (shownTile) shownTile.el.focus();
|
|
368
|
+
else {
|
|
369
|
+
pendingFocus = to.id;
|
|
370
|
+
render();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
container.addEventListener("click", onClick);
|
|
375
|
+
container.addEventListener("focusin", onFocusIn);
|
|
376
|
+
container.addEventListener("keydown", onKeyDown);
|
|
377
|
+
render();
|
|
378
|
+
return {
|
|
379
|
+
element: container,
|
|
380
|
+
get layout() {
|
|
381
|
+
return layout;
|
|
382
|
+
},
|
|
383
|
+
update(changes) {
|
|
384
|
+
config = { ...config, ...changes };
|
|
385
|
+
render();
|
|
386
|
+
},
|
|
387
|
+
refresh: render,
|
|
388
|
+
tileElement(cellId) {
|
|
389
|
+
for (const t of tiles.values()) if (t.cell.id === cellId) return t.el;
|
|
390
|
+
return void 0;
|
|
391
|
+
},
|
|
392
|
+
destroy() {
|
|
393
|
+
destroyed = true;
|
|
394
|
+
_optionalChain([stopWatching, 'optionalCall', _15 => _15()]);
|
|
395
|
+
timers.forEach(clearTimeout);
|
|
396
|
+
container.removeEventListener("click", onClick);
|
|
397
|
+
container.removeEventListener("focusin", onFocusIn);
|
|
398
|
+
container.removeEventListener("keydown", onKeyDown);
|
|
399
|
+
for (const t of [...tiles.values(), ...leaving]) {
|
|
400
|
+
if (t.safe) setChildren(t.safe, []);
|
|
401
|
+
setChildren(t.el, []);
|
|
402
|
+
}
|
|
403
|
+
container.remove();
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// src/element.ts
|
|
409
|
+
var Base = typeof HTMLElement === "undefined" ? class {
|
|
410
|
+
} : HTMLElement;
|
|
411
|
+
var BOOLEAN = ["navigable", "animate", "relief", "safe-area", "virtualize"];
|
|
412
|
+
var ATTRIBUTES = [...BOOLEAN, "options", "fit", "placement", "content-cells", "choose", "background", "fill", "focus-ring", "label"];
|
|
413
|
+
var json = (v) => {
|
|
414
|
+
try {
|
|
415
|
+
return JSON.parse(v);
|
|
416
|
+
} catch (e2) {
|
|
417
|
+
throw new SyntaxError(`<andamento-layout>: not valid JSON: ${v}`);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
var slotCount = 0;
|
|
421
|
+
var _config, _props, _handle, _observer, _queued, _slots, _items, _backdrop, _AndamentoLayoutElement_instances, backdropFor_fn, set_fn, schedule_fn, render_fn, configure_fn;
|
|
422
|
+
var AndamentoLayoutElement = class extends Base {
|
|
423
|
+
constructor() {
|
|
424
|
+
super();
|
|
425
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _AndamentoLayoutElement_instances);
|
|
426
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _config, {});
|
|
427
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _props, {});
|
|
428
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _handle);
|
|
429
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _observer);
|
|
430
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _queued, false);
|
|
431
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _slots, /* @__PURE__ */ new WeakMap());
|
|
432
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _items, []);
|
|
433
|
+
_chunk276TFSAGcjs.__privateAdd.call(void 0, this, _backdrop);
|
|
434
|
+
const root = this.attachShadow({ mode: "open" });
|
|
435
|
+
const style = document.createElement("style");
|
|
436
|
+
style.textContent = ":host{display:block}:host([hidden]){display:none}";
|
|
437
|
+
root.appendChild(style);
|
|
438
|
+
}
|
|
439
|
+
/** Layout options (also the `options` attribute, as JSON). */
|
|
440
|
+
get options() {
|
|
441
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).options;
|
|
442
|
+
}
|
|
443
|
+
set options(v) {
|
|
444
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { options: v });
|
|
445
|
+
}
|
|
446
|
+
/** A precomputed layout, instead of `options`. */
|
|
447
|
+
get layout() {
|
|
448
|
+
return _nullishCoalesce(_optionalChain([_chunk276TFSAGcjs.__privateGet.call(void 0, this, _handle), 'optionalAccess', _16 => _16.layout]), () => ( _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).layout));
|
|
449
|
+
}
|
|
450
|
+
set layout(v) {
|
|
451
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { layout: v });
|
|
452
|
+
}
|
|
453
|
+
/** Color of empty tiles: a color, a palette or a function per cell. */
|
|
454
|
+
get fill() {
|
|
455
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).fill;
|
|
456
|
+
}
|
|
457
|
+
set fill(v) {
|
|
458
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { fill: v });
|
|
459
|
+
}
|
|
460
|
+
get relief() {
|
|
461
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).relief;
|
|
462
|
+
}
|
|
463
|
+
set relief(v) {
|
|
464
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { relief: v });
|
|
465
|
+
}
|
|
466
|
+
/** Animate changes (the `animate` attribute; `animate` itself is the Web Animations method). */
|
|
467
|
+
get animated() {
|
|
468
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).animate;
|
|
469
|
+
}
|
|
470
|
+
set animated(v) {
|
|
471
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { animate: v });
|
|
472
|
+
}
|
|
473
|
+
get virtualize() {
|
|
474
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).virtualize;
|
|
475
|
+
}
|
|
476
|
+
set virtualize(v) {
|
|
477
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { virtualize: v });
|
|
478
|
+
}
|
|
479
|
+
get navigable() {
|
|
480
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).navigable;
|
|
481
|
+
}
|
|
482
|
+
set navigable(v) {
|
|
483
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { navigable: v });
|
|
484
|
+
}
|
|
485
|
+
get safeArea() {
|
|
486
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).safeArea;
|
|
487
|
+
}
|
|
488
|
+
set safeArea(v) {
|
|
489
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { safeArea: v });
|
|
490
|
+
}
|
|
491
|
+
get fit() {
|
|
492
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).fit;
|
|
493
|
+
}
|
|
494
|
+
set fit(v) {
|
|
495
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { fit: v });
|
|
496
|
+
}
|
|
497
|
+
get placement() {
|
|
498
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).placement;
|
|
499
|
+
}
|
|
500
|
+
set placement(v) {
|
|
501
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { placement: v });
|
|
502
|
+
}
|
|
503
|
+
get contentCells() {
|
|
504
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).contentCells;
|
|
505
|
+
}
|
|
506
|
+
set contentCells(v) {
|
|
507
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { contentCells: v });
|
|
508
|
+
}
|
|
509
|
+
get choose() {
|
|
510
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).choose;
|
|
511
|
+
}
|
|
512
|
+
set choose(v) {
|
|
513
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { choose: v });
|
|
514
|
+
}
|
|
515
|
+
/** Width / height of each child; otherwise read from children's `data-aspect`. */
|
|
516
|
+
get aspects() {
|
|
517
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).aspects;
|
|
518
|
+
}
|
|
519
|
+
set aspects(v) {
|
|
520
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { aspects: v });
|
|
521
|
+
}
|
|
522
|
+
/** Tiles each child spans; otherwise read from children's `data-weight`. */
|
|
523
|
+
get weights() {
|
|
524
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).weights;
|
|
525
|
+
}
|
|
526
|
+
set weights(v) {
|
|
527
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { weights: v });
|
|
528
|
+
}
|
|
529
|
+
/** Focal point of each child; otherwise read from children's `data-focus`. */
|
|
530
|
+
get focalPoints() {
|
|
531
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).focalPoints;
|
|
532
|
+
}
|
|
533
|
+
set focalPoints(v) {
|
|
534
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { focalPoints: v });
|
|
535
|
+
}
|
|
536
|
+
get background() {
|
|
537
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).background;
|
|
538
|
+
}
|
|
539
|
+
set background(v) {
|
|
540
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { background: v });
|
|
541
|
+
}
|
|
542
|
+
get focusRing() {
|
|
543
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).focusRing;
|
|
544
|
+
}
|
|
545
|
+
set focusRing(v) {
|
|
546
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { focusRing: v });
|
|
547
|
+
}
|
|
548
|
+
/** Accessible name of each tile. */
|
|
549
|
+
get cellLabel() {
|
|
550
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).cellLabel;
|
|
551
|
+
}
|
|
552
|
+
set cellLabel(v) {
|
|
553
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { cellLabel: v });
|
|
554
|
+
}
|
|
555
|
+
/** Extra style for each tile. */
|
|
556
|
+
get cellStyle() {
|
|
557
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).cellStyle;
|
|
558
|
+
}
|
|
559
|
+
set cellStyle(v) {
|
|
560
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { cellStyle: v });
|
|
561
|
+
}
|
|
562
|
+
/** Content for empty tiles (rendered in the shadow root). */
|
|
563
|
+
get fallback() {
|
|
564
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _props).fallback;
|
|
565
|
+
}
|
|
566
|
+
set fallback(v) {
|
|
567
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, set_fn).call(this, { fallback: v });
|
|
568
|
+
}
|
|
569
|
+
/** The tile element (in the shadow root) showing a cell, if it's rendered. */
|
|
570
|
+
tileElement(cellId) {
|
|
571
|
+
return _optionalChain([_chunk276TFSAGcjs.__privateGet.call(void 0, this, _handle), 'optionalAccess', _17 => _17.tileElement, 'call', _18 => _18(cellId)]);
|
|
572
|
+
}
|
|
573
|
+
connectedCallback() {
|
|
574
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _observer, new MutationObserver((records) => {
|
|
575
|
+
if (records.some((r) => r.target === this || r.target.parentNode === this)) _chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, schedule_fn).call(this);
|
|
576
|
+
}));
|
|
577
|
+
_chunk276TFSAGcjs.__privateGet.call(void 0, this, _observer).observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-aspect", "data-focus", "data-weight", "slot"] });
|
|
578
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, schedule_fn).call(this);
|
|
579
|
+
}
|
|
580
|
+
disconnectedCallback() {
|
|
581
|
+
_optionalChain([_chunk276TFSAGcjs.__privateGet.call(void 0, this, _observer), 'optionalAccess', _19 => _19.disconnect, 'call', _20 => _20()]);
|
|
582
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _observer, void 0);
|
|
583
|
+
_optionalChain([_chunk276TFSAGcjs.__privateGet.call(void 0, this, _handle), 'optionalAccess', _21 => _21.destroy, 'call', _22 => _22()]);
|
|
584
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _handle, void 0);
|
|
585
|
+
}
|
|
586
|
+
attributeChangedCallback() {
|
|
587
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, schedule_fn).call(this);
|
|
588
|
+
}
|
|
589
|
+
/** Render now rather than at the end of the current task (e.g. before measuring). */
|
|
590
|
+
render() {
|
|
591
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, render_fn).call(this);
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
_config = new WeakMap();
|
|
595
|
+
_props = new WeakMap();
|
|
596
|
+
_handle = new WeakMap();
|
|
597
|
+
_observer = new WeakMap();
|
|
598
|
+
_queued = new WeakMap();
|
|
599
|
+
_slots = new WeakMap();
|
|
600
|
+
_items = new WeakMap();
|
|
601
|
+
_backdrop = new WeakMap();
|
|
602
|
+
_AndamentoLayoutElement_instances = new WeakSet();
|
|
603
|
+
/** The same function for the same backdrop child, so tiles keep their copies. */
|
|
604
|
+
backdropFor_fn = function(el) {
|
|
605
|
+
if (_optionalChain([_chunk276TFSAGcjs.__privateGet.call(void 0, this, _backdrop), 'optionalAccess', _23 => _23.el]) !== el) _chunk276TFSAGcjs.__privateSet.call(void 0, this, _backdrop, { el, make: () => copyBackdrop(el) });
|
|
606
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _backdrop).make;
|
|
607
|
+
};
|
|
608
|
+
set_fn = function(changes) {
|
|
609
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _props, { ..._chunk276TFSAGcjs.__privateGet.call(void 0, this, _props), ...changes });
|
|
610
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, schedule_fn).call(this);
|
|
611
|
+
};
|
|
612
|
+
/** Several changes in one go render once. */
|
|
613
|
+
schedule_fn = function() {
|
|
614
|
+
if (_chunk276TFSAGcjs.__privateGet.call(void 0, this, _queued)) return;
|
|
615
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _queued, true);
|
|
616
|
+
queueMicrotask(() => {
|
|
617
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _queued, false);
|
|
618
|
+
_chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, render_fn).call(this);
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
render_fn = function() {
|
|
622
|
+
if (!this.isConnected) return;
|
|
623
|
+
const config = _chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, configure_fn).call(this);
|
|
624
|
+
if (!config.options && !config.layout) return;
|
|
625
|
+
if (_chunk276TFSAGcjs.__privateGet.call(void 0, this, _handle)) _chunk276TFSAGcjs.__privateGet.call(void 0, this, _handle).update(config);
|
|
626
|
+
else {
|
|
627
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _handle, mountTileLayout(this.shadowRoot, config));
|
|
628
|
+
_chunk276TFSAGcjs.__privateGet.call(void 0, this, _handle).element.setAttribute("part", "layout");
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
configure_fn = function() {
|
|
632
|
+
const a = (n) => this.getAttribute(n);
|
|
633
|
+
const flag = (n) => this.hasAttribute(n) && a(n) !== "false";
|
|
634
|
+
const fromAttrs = Object.fromEntries([...ATTRIBUTE_KEYS].map((k) => [k, void 0]));
|
|
635
|
+
if (a("options")) fromAttrs.options = json(a("options"));
|
|
636
|
+
for (const n of BOOLEAN) if (flag(n)) fromAttrs[n === "safe-area" ? "safeArea" : n] = true;
|
|
637
|
+
if (a("safe-area") === "tile" || a("safe-area") === "visible") fromAttrs.safeArea = a("safe-area");
|
|
638
|
+
if (a("fit")) fromAttrs.fit = a("fit") === "nearest" ? "nearest" : a("fit") === "false" ? false : true;
|
|
639
|
+
if (a("placement")) fromAttrs.placement = a("placement");
|
|
640
|
+
if (a("content-cells")) fromAttrs.contentCells = a("content-cells");
|
|
641
|
+
if (a("choose")) fromAttrs.choose = a("choose");
|
|
642
|
+
if (a("background")) fromAttrs.background = a("background");
|
|
643
|
+
if (a("fill")) fromAttrs.fill = a("fill").trim().startsWith("[") ? json(a("fill")) : a("fill");
|
|
644
|
+
if (a("focus-ring")) fromAttrs.focusRing = a("focus-ring") === "false" ? false : a("focus-ring");
|
|
645
|
+
if (a("label")) fromAttrs.label = a("label");
|
|
646
|
+
const children = [...this.children];
|
|
647
|
+
const backdrop = children.find((c) => c.getAttribute("slot") === "backdrop");
|
|
648
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _items, children.filter((c) => c !== backdrop && c.localName !== "template"));
|
|
649
|
+
const items = _chunk276TFSAGcjs.__privateGet.call(void 0, this, _items).map((child) => {
|
|
650
|
+
let slot = _chunk276TFSAGcjs.__privateGet.call(void 0, this, _slots).get(child);
|
|
651
|
+
if (!slot) {
|
|
652
|
+
slot = document.createElement("slot");
|
|
653
|
+
slot.name = `andamento-${++slotCount}`;
|
|
654
|
+
_chunk276TFSAGcjs.__privateGet.call(void 0, this, _slots).set(child, slot);
|
|
655
|
+
}
|
|
656
|
+
if (child.getAttribute("slot") !== slot.name) child.setAttribute("slot", slot.name);
|
|
657
|
+
return slot;
|
|
658
|
+
});
|
|
659
|
+
const aspectAttrs = _chunk276TFSAGcjs.__privateGet.call(void 0, this, _items).map((c) => Number(c.getAttribute("data-aspect")));
|
|
660
|
+
const aspects = aspectAttrs.some((v) => v > 0) ? aspectAttrs.map((v) => v > 0 ? v : 1) : void 0;
|
|
661
|
+
const focusAttrs = _chunk276TFSAGcjs.__privateGet.call(void 0, this, _items).map((c) => {
|
|
662
|
+
const [x, y] = (_nullishCoalesce(c.getAttribute("data-focus"), () => ( ""))).trim().split(/[\s,]+/).map(Number);
|
|
663
|
+
return Number.isFinite(x) && Number.isFinite(y) && c.hasAttribute("data-focus") ? { x, y } : void 0;
|
|
664
|
+
});
|
|
665
|
+
const focalPoints = focusAttrs.some(Boolean) ? focusAttrs : void 0;
|
|
666
|
+
const weightAttrs = _chunk276TFSAGcjs.__privateGet.call(void 0, this, _items).map((c) => Number(c.getAttribute("data-weight")));
|
|
667
|
+
const weights = weightAttrs.some((v) => v > 1) ? weightAttrs.map((v) => v > 0 ? v : 1) : void 0;
|
|
668
|
+
_chunk276TFSAGcjs.__privateSet.call(void 0, this, _config, {
|
|
669
|
+
...fromAttrs,
|
|
670
|
+
aspects,
|
|
671
|
+
focalPoints,
|
|
672
|
+
weights,
|
|
673
|
+
...overrides(_chunk276TFSAGcjs.__privateGet.call(void 0, this, _props)),
|
|
674
|
+
items,
|
|
675
|
+
backdrop: backdrop ? _chunk276TFSAGcjs.__privateMethod.call(void 0, this, _AndamentoLayoutElement_instances, backdropFor_fn).call(this, backdrop) : void 0,
|
|
676
|
+
cellAttributes: (cell, state) => ({
|
|
677
|
+
part: ["tile", state.empty && "empty", cell.boundary && "boundary"].filter(Boolean).join(" ")
|
|
678
|
+
}),
|
|
679
|
+
onCellActivate: (cell, state) => {
|
|
680
|
+
const detail = { cell, slot: state.slot, item: _chunk276TFSAGcjs.__privateGet.call(void 0, this, _items)[state.slot] };
|
|
681
|
+
this.dispatchEvent(new CustomEvent("cellactivate", { detail, bubbles: true, composed: true }));
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
return _chunk276TFSAGcjs.__privateGet.call(void 0, this, _config);
|
|
685
|
+
};
|
|
686
|
+
AndamentoLayoutElement.observedAttributes = ATTRIBUTES;
|
|
687
|
+
var overrides = (props) => Object.fromEntries(Object.entries(props).filter(([k, v]) => v !== void 0 || !ATTRIBUTE_KEYS.has(k)));
|
|
688
|
+
var ATTRIBUTE_KEYS = /* @__PURE__ */ new Set(["options", "navigable", "animate", "relief", "safeArea", "virtualize", "fit", "placement", "contentCells", "choose", "background", "fill", "focusRing", "label", "aspects", "focalPoints", "weights"]);
|
|
689
|
+
function copyBackdrop(el) {
|
|
690
|
+
const copy = el.cloneNode(true);
|
|
691
|
+
copy.removeAttribute("slot");
|
|
692
|
+
if (/^(img|video|picture|canvas)$/.test(copy.localName)) {
|
|
693
|
+
for (const [k, v] of Object.entries(_chunk276TFSAGcjs.coverStyle)) copy.style.setProperty(k.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()), String(v));
|
|
694
|
+
}
|
|
695
|
+
return copy;
|
|
696
|
+
}
|
|
697
|
+
function defineTileLayoutElement(tagName = "andamento-layout") {
|
|
698
|
+
if (typeof customElements === "undefined") return AndamentoLayoutElement;
|
|
699
|
+
const existing = customElements.get(tagName);
|
|
700
|
+
if (existing) return existing;
|
|
701
|
+
const cls = class extends AndamentoLayoutElement {
|
|
702
|
+
};
|
|
703
|
+
customElements.define(tagName, cls);
|
|
704
|
+
return cls;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/pointer.ts
|
|
708
|
+
|
|
709
|
+
function cellFromPointer(layout, event, options = {}) {
|
|
710
|
+
const el = _nullishCoalesce(options.element, () => ( event.currentTarget));
|
|
711
|
+
if (!el || typeof el.getBoundingClientRect !== "function") return void 0;
|
|
712
|
+
const point = _core.screenToLayout.call(void 0, layout, el.getBoundingClientRect(), event.clientX, event.clientY);
|
|
713
|
+
return _core.cellAt.call(void 0, layout, point, options);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// src/index.ts
|
|
717
|
+
var _svg = require('@andamento/svg');
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
exports.AndamentoLayoutElement = AndamentoLayoutElement; exports.cellFromPointer = cellFromPointer; exports.coverStyle = _chunk276TFSAGcjs.coverStyle; exports.defaultPalette = _svg.defaultPalette; exports.defineTileLayoutElement = defineTileLayoutElement; exports.mountTileLayout = mountTileLayout; exports.neutralPalette = _svg.neutralPalette;
|
|
727
|
+
//# sourceMappingURL=index.cjs.map
|