@andamento/react 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.cjs +33 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(index_exports, {
|
|
|
23
23
|
SvgCellImage: () => SvgCellImage,
|
|
24
24
|
SvgTileLayout: () => SvgTileLayout,
|
|
25
25
|
TileLayout: () => TileLayout,
|
|
26
|
-
cellFromPointer: () =>
|
|
26
|
+
cellFromPointer: () => import_dom2.cellFromPointer,
|
|
27
27
|
coverStyle: () => coverStyle,
|
|
28
28
|
defaultPalette: () => import_svg2.defaultPalette,
|
|
29
29
|
neutralPalette: () => import_svg2.neutralPalette,
|
|
@@ -38,24 +38,25 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
// src/TileLayout.tsx
|
|
39
39
|
var import_react2 = require("react");
|
|
40
40
|
var import_core2 = require("@andamento/core");
|
|
41
|
-
var
|
|
41
|
+
var import_dom = require("@andamento/dom");
|
|
42
|
+
var import_internal2 = require("@andamento/dom/internal");
|
|
42
43
|
|
|
43
44
|
// src/useTileLayout.ts
|
|
44
45
|
var import_react = require("react");
|
|
45
46
|
var import_core = require("@andamento/core");
|
|
46
|
-
var
|
|
47
|
+
var import_internal = require("@andamento/dom/internal");
|
|
47
48
|
function useTileLayout(options) {
|
|
48
|
-
const key =
|
|
49
|
+
const key = (0, import_internal.optionsKey)(options);
|
|
49
50
|
return (0, import_react.useMemo)(() => (0, import_core.createLayout)(options), [key]);
|
|
50
51
|
}
|
|
51
52
|
function useFitCount(options, count, fit = {}) {
|
|
52
|
-
const key =
|
|
53
|
+
const key = (0, import_internal.optionsKey)(options);
|
|
53
54
|
const { cells, mode } = fit;
|
|
54
55
|
return (0, import_react.useMemo)(() => (0, import_core.fitCount)(options, count, { cells, mode }).layout, [key, count, cells, mode]);
|
|
55
56
|
}
|
|
56
57
|
function useResolvedLayout(component, options, layout, fit) {
|
|
57
58
|
const resolver = (0, import_react.useRef)();
|
|
58
|
-
resolver.current ?? (resolver.current = (0,
|
|
59
|
+
resolver.current ?? (resolver.current = (0, import_internal.layoutResolver)(`<${component}>`));
|
|
59
60
|
return resolver.current(options, layout, fit);
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -106,7 +107,7 @@ function TileLayout(props) {
|
|
|
106
107
|
});
|
|
107
108
|
const { bounds } = layout;
|
|
108
109
|
const buildFrame = (0, import_react2.useRef)();
|
|
109
|
-
buildFrame.current ?? (buildFrame.current = (0,
|
|
110
|
+
buildFrame.current ?? (buildFrame.current = (0, import_internal2.frameBuilder)());
|
|
110
111
|
const frame = buildFrame.current(layout, {
|
|
111
112
|
count: renderCell ? Infinity : items.length,
|
|
112
113
|
aspects: renderCell ? void 0 : aspects,
|
|
@@ -134,7 +135,7 @@ function TileLayout(props) {
|
|
|
134
135
|
else if (slot >= 0) content = items[slot];
|
|
135
136
|
const empty = isEmpty(content);
|
|
136
137
|
const state = { empty, slot: empty && !renderCell ? -1 : slot };
|
|
137
|
-
if (empty) content = (0,
|
|
138
|
+
if (empty) content = (0, import_internal2.resolvePerCell)(fallback, cell, state);
|
|
138
139
|
return { i, cell, content, key: keyOf(i), empty, state };
|
|
139
140
|
};
|
|
140
141
|
const virtual = !!virtualize;
|
|
@@ -176,7 +177,7 @@ function TileLayout(props) {
|
|
|
176
177
|
if (e.defaultPrevented || !navigable || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
177
178
|
const entry = entries.find((x) => tiles.current.get(x.cell.id) === e.target);
|
|
178
179
|
if (!entry || !focusable.has(entry.cell.id)) return;
|
|
179
|
-
const action = (0,
|
|
180
|
+
const action = (0, import_internal2.keyAction)(layout, entry.cell, e.key, (c) => focusable.has(c.id), !!onCellActivate);
|
|
180
181
|
if (!action) return;
|
|
181
182
|
e.preventDefault();
|
|
182
183
|
if ("activate" in action) onCellActivate(entry.cell, entry.state);
|
|
@@ -190,7 +191,7 @@ function TileLayout(props) {
|
|
|
190
191
|
const rendered = entries.map(({ i, cell, content, key, empty, state }) => {
|
|
191
192
|
const slot = slots[i];
|
|
192
193
|
const bevel = frame.bevel(i);
|
|
193
|
-
const tile = (0,
|
|
194
|
+
const tile = (0, import_internal2.tileStyle)(frame, cell, {
|
|
194
195
|
empty,
|
|
195
196
|
safeArea: safeArea2,
|
|
196
197
|
backdrop: backdrop != null,
|
|
@@ -200,7 +201,7 @@ function TileLayout(props) {
|
|
|
200
201
|
});
|
|
201
202
|
const silent = empty && isEmpty(content);
|
|
202
203
|
const canFocus = focusable.has(cell.id);
|
|
203
|
-
const viewBox = (0,
|
|
204
|
+
const viewBox = (0, import_internal2.tileViewBox)(cell);
|
|
204
205
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
205
206
|
"div",
|
|
206
207
|
{
|
|
@@ -210,24 +211,24 @@ function TileLayout(props) {
|
|
|
210
211
|
},
|
|
211
212
|
role: silent ? void 0 : list ? "listitem" : void 0,
|
|
212
213
|
"aria-hidden": silent ? true : void 0,
|
|
213
|
-
"aria-label": silent ? void 0 : (0,
|
|
214
|
+
"aria-label": silent ? void 0 : (0, import_internal2.resolvePerCell)(cellLabel, cell, state),
|
|
214
215
|
"aria-setsize": positions && list && !silent ? positions.size : void 0,
|
|
215
216
|
"aria-posinset": positions && list && !silent ? positions.get(i) : void 0,
|
|
216
217
|
tabIndex: canFocus ? cell.id === active ? 0 : -1 : void 0,
|
|
217
218
|
onFocus: canFocus ? (e) => e.target === e.currentTarget && setActiveId(cell.id) : void 0,
|
|
218
219
|
onClick: onCellActivate && !empty ? () => onCellActivate(cell, state) : void 0,
|
|
219
|
-
className: (0,
|
|
220
|
+
className: (0, import_internal2.resolvePerCell)(cellClassName, cell, state),
|
|
220
221
|
"data-cell-id": cell.id,
|
|
221
222
|
"data-index": cell.index,
|
|
222
223
|
"data-empty": empty ? "" : void 0,
|
|
223
224
|
"data-boundary": cell.boundary ? "" : void 0,
|
|
224
225
|
"data-entering": entering.current.has(key) ? "" : void 0,
|
|
225
|
-
style: { ...css(tile), ...(0,
|
|
226
|
+
style: { ...css(tile), ...(0, import_internal2.resolvePerCell)(cellStyle, cell, state) },
|
|
226
227
|
children: [
|
|
227
228
|
backdrop != null && // z-index -1 puts it behind the content but inside the tile: the tile's
|
|
228
229
|
// clip-path makes it a stacking context.
|
|
229
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "aria-hidden": true, style: css((0,
|
|
230
|
-
safeArea2 && content != null && !isEmpty(content) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-safe-area": "", style: css((0,
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "aria-hidden": true, style: css((0, import_internal2.backdropStyle)(frame, cell)), children: backdrop }),
|
|
231
|
+
safeArea2 && content != null && !isEmpty(content) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-safe-area": "", style: css((0, import_internal2.safeBoxStyle)(frame, cell, !renderCell && !empty && aspects ? aspects[slot] ?? 1 : void 0, safeArea2)), children: content }) : content,
|
|
231
232
|
bevel && bevel.length > 0 && // Over the content; the tile's box is its bounding box, so map that to the viewBox.
|
|
232
233
|
// When animating, the bevel is for the new shape, so it fades in as the tile arrives.
|
|
233
234
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -238,13 +239,13 @@ function TileLayout(props) {
|
|
|
238
239
|
"data-late": anim ? "" : void 0,
|
|
239
240
|
viewBox,
|
|
240
241
|
preserveAspectRatio: "none",
|
|
241
|
-
style: css(
|
|
242
|
+
style: css(import_internal2.overlayStyle),
|
|
242
243
|
children: bevel.map((p, k) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: p.d, fill: p.fill, fillOpacity: p.opacity }, k))
|
|
243
244
|
},
|
|
244
245
|
anim ? String(tile.clipPath) : void 0
|
|
245
246
|
),
|
|
246
247
|
canFocus && focusRing !== false && // The tile's outline, stroked across its edge; the clip keeps the inner half.
|
|
247
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { "aria-hidden": true, "data-focus-ring": "", viewBox, preserveAspectRatio: "none", style: css(
|
|
248
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { "aria-hidden": true, "data-focus-ring": "", viewBox, preserveAspectRatio: "none", style: css(import_internal2.overlayStyle), children: (0, import_internal2.ringStrokes)(frame, cell, focusRing).map((p, k) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: p.d, fill: "none", stroke: p.stroke, strokeWidth: p.width, vectorEffect: "non-scaling-stroke" }, k)) })
|
|
248
249
|
]
|
|
249
250
|
},
|
|
250
251
|
key
|
|
@@ -284,9 +285,9 @@ function TileLayout(props) {
|
|
|
284
285
|
if (!virtual) return;
|
|
285
286
|
const el = container.current;
|
|
286
287
|
if (!el) return;
|
|
287
|
-
return (0,
|
|
288
|
-
const next = (0,
|
|
289
|
-
setView((v) => (0,
|
|
288
|
+
return (0, import_internal2.watchView)(el, () => {
|
|
289
|
+
const next = (0, import_internal2.viewRect)(el, layout, overscan);
|
|
290
|
+
setView((v) => (0, import_internal2.sameRect)(v ?? void 0, next) ? v : next);
|
|
290
291
|
});
|
|
291
292
|
}, [virtual, layout, overscan]);
|
|
292
293
|
(0, import_react2.useEffect)(() => {
|
|
@@ -294,8 +295,8 @@ function TileLayout(props) {
|
|
|
294
295
|
return () => set.forEach(clearTimeout);
|
|
295
296
|
}, []);
|
|
296
297
|
const leaving = anim ? [...exiting].filter(([k]) => !lastKeys.current.has(k) && !rendered.some((el) => el.key === k)) : [];
|
|
297
|
-
const sheet = (0,
|
|
298
|
-
const shadow = (0,
|
|
298
|
+
const sheet = (0, import_internal2.tileSheet)({ focusRing: !!navigable && focusRing !== false, anim });
|
|
299
|
+
const shadow = (0, import_internal2.shadowShape)(frame, entries.map((e) => e.cell));
|
|
299
300
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
300
301
|
"div",
|
|
301
302
|
{
|
|
@@ -304,10 +305,10 @@ function TileLayout(props) {
|
|
|
304
305
|
role: role ?? "list",
|
|
305
306
|
...rest,
|
|
306
307
|
onKeyDown: handleKeyDown,
|
|
307
|
-
style: { ...css((0,
|
|
308
|
+
style: { ...css((0, import_internal2.containerStyle)(layout)), ...style },
|
|
308
309
|
children: [
|
|
309
310
|
sheet && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: sheet }),
|
|
310
|
-
background && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "aria-hidden": true, style: css((0,
|
|
311
|
+
background && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "aria-hidden": true, style: css((0, import_internal2.backgroundStyle)(frame, background)) }),
|
|
311
312
|
shadow && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { "aria-hidden": true, "data-andamento-shadow": "", viewBox: shadow.viewBox, preserveAspectRatio: "none", style: css(shadow.style), children: [
|
|
312
313
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("filter", { id: `${uid}-shadow`, x: "-10%", y: "-10%", width: "120%", height: "120%", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("feGaussianBlur", { stdDeviation: shadow.blur }) }),
|
|
313
314
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: shadow.d, fillRule: "evenodd", transform: shadow.transform, fill: "#000", fillOpacity: shadow.opacity, filter: `url(#${uid}-shadow)` })
|
|
@@ -334,12 +335,13 @@ function TileLayout(props) {
|
|
|
334
335
|
);
|
|
335
336
|
}
|
|
336
337
|
var useIsomorphicLayoutEffect = typeof window === "undefined" ? import_react2.useEffect : import_react2.useLayoutEffect;
|
|
337
|
-
var coverStyle = css(
|
|
338
|
+
var coverStyle = css(import_dom.coverStyle);
|
|
338
339
|
|
|
339
340
|
// src/SvgTileLayout.tsx
|
|
340
341
|
var import_react3 = require("react");
|
|
341
342
|
var import_core3 = require("@andamento/core");
|
|
342
343
|
var import_svg = require("@andamento/svg");
|
|
344
|
+
var import_internal3 = require("@andamento/svg/internal");
|
|
343
345
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
344
346
|
function SvgTileLayout(props) {
|
|
345
347
|
const {
|
|
@@ -377,7 +379,7 @@ function SvgTileLayout(props) {
|
|
|
377
379
|
});
|
|
378
380
|
const prefix = "andamento" + (0, import_react3.useId)().replace(/:/g, "");
|
|
379
381
|
const styles = (0, import_react3.useMemo)(
|
|
380
|
-
() => (0,
|
|
382
|
+
() => (0, import_internal3.resolveCellStyles)(layout, { images, repeatImages, fill, contentCells, placement, imageAspects, choose }),
|
|
381
383
|
[layout, images, repeatImages, fill, contentCells, placement, imageAspects, choose]
|
|
382
384
|
);
|
|
383
385
|
const { x, y, width, height } = layout.bounds;
|
|
@@ -438,7 +440,7 @@ function SvgTileLayout(props) {
|
|
|
438
440
|
"data-index": cell.index,
|
|
439
441
|
"data-empty": style.image ? void 0 : "",
|
|
440
442
|
"data-boundary": cell.boundary ? "" : void 0,
|
|
441
|
-
...(0,
|
|
443
|
+
...(0, import_internal3.cellA11y)(style, imageAlts),
|
|
442
444
|
children: [
|
|
443
445
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("clipPath", { id: clipPathId, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d, clipRule: "evenodd" }) }),
|
|
444
446
|
renderCell ? renderCell(cell, ctx) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -449,8 +451,8 @@ function SvgTileLayout(props) {
|
|
|
449
451
|
noFill: !!backdrop,
|
|
450
452
|
box: imageFit === "contain" && style.image ? (0, import_core3.safeArea)(cell, layout, { aspect: imageAspects && style.slot >= 0 ? imageAspects[style.slot] : void 0, within: containWithin }) : void 0,
|
|
451
453
|
cover: (() => {
|
|
452
|
-
const focus = imageFit !== "contain" && style.image && style.slot >= 0 ?
|
|
453
|
-
const aspect = focus ? imageAspects?.[style.slot
|
|
454
|
+
const focus = imageFit !== "contain" && style.image && style.slot >= 0 ? imageFocus?.[style.slot] : void 0;
|
|
455
|
+
const aspect = focus ? imageAspects?.[style.slot] ?? focus.aspect : void 0;
|
|
454
456
|
return focus && aspect ? (0, import_core3.coverRect)(cell, layout, { aspect, focus }) : void 0;
|
|
455
457
|
})()
|
|
456
458
|
}
|
|
@@ -560,7 +562,7 @@ function useImageFocus(srcs) {
|
|
|
560
562
|
}
|
|
561
563
|
|
|
562
564
|
// src/index.tsx
|
|
563
|
-
var
|
|
565
|
+
var import_dom2 = require("@andamento/dom");
|
|
564
566
|
var import_svg2 = require("@andamento/svg");
|
|
565
567
|
// Annotate the CommonJS export names for ESM import in node:
|
|
566
568
|
0 && (module.exports = {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/TileLayout.tsx","../src/useTileLayout.ts","../src/SvgTileLayout.tsx","../src/useImageFill.ts","../src/useImageAspects.ts","../src/useImageFocus.ts"],"sourcesContent":["/**\n * React bindings: `<TileLayout>` (any children, clipped to the tiles), `<SvgTileLayout>` and hooks.\n *\n * @module @andamento/react\n */\nexport { TileLayout, coverStyle } from \"./TileLayout\";\nexport type { CellState, TileLayoutProps } from \"./TileLayout\";\nexport { SvgTileLayout, SvgCellImage } from \"./SvgTileLayout\";\nexport type { SvgTileLayoutProps, SvgCellImageProps, SvgCellRenderContext } from \"./SvgTileLayout\";\nexport { useFitCount, useTileLayout } from \"./useTileLayout\";\nexport { useImageFill } from \"./useImageFill\";\nexport { useImageAspects } from \"./useImageAspects\";\nexport { useImageFocus } from \"./useImageFocus\";\nexport { cellFromPointer } from \"@andamento/dom\";\nexport type { PerCell, PointerLike } from \"@andamento/dom\";\nexport type { FitProp } from \"./useTileLayout\";\nexport type { Cell, ContentCells, ContentPlacement, Focus, Layout, LayoutOptions, MatchOptions, SafeAreaOptions, HitOptions } from \"@andamento/core\";\nexport { defaultPalette, neutralPalette } from \"@andamento/svg\";\nexport type { FillSource, ReliefOptions } from \"@andamento/svg\";\n","import {\n Children,\n cloneElement,\n isValidElement,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type KeyboardEvent,\n type CSSProperties,\n type HTMLAttributes,\n type Key,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { cellsInRect, type Cell, type ContentCells, type ContentPlacement, type Focus, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport {\n backdropStyle,\n backgroundStyle,\n containerStyle,\n coverStyle as sharedCoverStyle,\n frameBuilder,\n keyAction,\n overlayStyle,\n resolvePerCell as resolve,\n ringStrokes,\n safeBoxStyle,\n sameRect,\n shadowShape,\n tileSheet,\n tileStyle,\n tileViewBox,\n viewRect,\n watchView,\n type CellState,\n type SafeAreaProp,\n type PerCell,\n} from \"@andamento/dom\";\nimport type { FillSource, ReliefOptions } from \"@andamento/svg\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport type { CellState };\n\nconst isEmpty = (n: ReactNode) => n == null || n === false || n === true || n === \"\";\nconst css = (s: object) => s as CSSProperties;\n\nexport interface TileLayoutProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n /**\n * Any React content. Each top-level child fills one tile, in reading order\n * (top-to-bottom, left-to-right), and is clipped to the tile's shape.\n * Extra children beyond the number of tiles are not rendered.\n */\n children?: ReactNode;\n /**\n * Alternative to `children`: compute each tile's content from its cell. Takes precedence.\n * `slot` numbers the cells allowed by `contentCells` in reading order (-1 for the rest).\n */\n renderCell?: (cell: Cell, state: { slot: number }) => ReactNode;\n /**\n * Which tiles may hold children: \"all\" (default), \"whole\" (only tiles not cut by the\n * region outline), or a test per cell. The others are left empty.\n */\n contentCells?: ContentCells;\n /**\n * Where children go when there are fewer than tiles: \"reading\" (default; the first\n * tiles in reading order), \"center\" (the middle of the region) or \"spread\" (evenly\n * over it). Children always run in reading order across the tiles chosen.\n */\n placement?: ContentPlacement;\n /**\n * Width / height of each child, in order. When given, each child goes in a tile of\n * similar shape, so `object-fit: cover` crops as little as possible (landscape photos in\n * wide tiles, portraits in tall ones); see `matchSlots`. Featured tiles still take the\n * first children. Missing entries count as square. Ignored with `renderCell`.\n */\n aspects?: readonly number[];\n /**\n * Keep content out of the tiles' clipped corners: each tile's content goes in a box at\n * the tile's safe area (see `safeArea`), the largest rectangle that fits inside its shape,\n * instead of filling the tile's bounding box. Useful for text in triangles or hexagons.\n * With `aspects`, each child's box has the child's shape, so it shows whole and uncropped.\n * The box has `data-safe-area`; style its contents to fill it. Tiles show `fill` around\n * their content. For tiles an `edges: \"window\"` layout cuts, `true` or \"tile\" fits the\n * whole tile (content near the edge is partly hidden, like the tile) and \"visible\" the\n * part that shows.\n */\n safeArea?: SafeAreaProp;\n /** With `aspects`: \"shape\" also picks which tiles hold children by their shape, ignoring `placement`. */\n choose?: \"placement\" | \"shape\";\n /**\n * Focal point of each child (fractions of its width and height; see `estimateFocus`): what\n * a photo keeps in view as its tile crops it. Each tile sets `--andamento-object-position`,\n * which `coverStyle` uses as `object-position`; exact when the photo's shape is known (`aspects`, or the focus's `aspect`).\n */\n focalPoints?: readonly (Focus | undefined)[];\n /**\n * How many tiles each child spans (1 for an ordinary child; rounded): heavier childs get a\n * featured tile of that many merged tiles, where they fall in reading order (see\n * `weightedLayout`). With `fit`, the tiles are sized to fit everything. Needs `options`.\n */\n weights?: readonly number[];\n /**\n * Color of empty tiles: a color, a palette (neighboring tiles get different entries),\n * or a function per cell. Defaults to `neutralPalette`; use \"transparent\" for none.\n */\n fill?: FillSource;\n /**\n * Size the tiles to the children: scales the pattern so there are about as many tiles\n * (counted by `contentCells`) as children. `true`/\"atLeast\" makes sure every child gets\n * a tile; \"nearest\" gets as close as possible. Ignored with `layout` or `renderCell`.\n */\n fit?: FitProp;\n /**\n * One picture across all the tiles: rendered in every tile, sized and positioned to the\n * whole layout, so each tile shows its own piece. Use an element that fills its box,\n * e.g. `<img src=… style={coverStyle} />`. It sits behind the tile's content, and empty\n * tiles show it instead of `fill`. (Each tile gets its own copy, so a video would play\n * out of sync; images are loaded once.)\n */\n backdrop?: ReactNode;\n /**\n * Raised tiles: a bevel round each tile, lit from one side and drawn over its content,\n * and optionally a soft shadow each tile casts into the grout (set `shadow`). `true` for\n * the defaults. With `gap` as the grout width and `background` as its color or texture,\n * it looks like a tiled surface. See `ReliefOptions`.\n */\n relief?: boolean | ReliefOptions;\n /**\n * Keyboard navigation: tiles with content become focusable as one tab stop (roving\n * tabindex). Arrow keys move to the nearest tile in that direction, whatever the tiling;\n * Home and End go to the first and last. The focused tile shows `focusRing`.\n */\n navigable?: boolean;\n /**\n * Called when a tile with content is activated: clicked, or Enter or Space while it has\n * focus (with `navigable`).\n */\n onCellActivate?: (cell: Cell, state: CellState) => void;\n /** Accessible name for each tile (its `aria-label`), e.g. a photo's description. */\n cellLabel?: PerCell<string | undefined>;\n /**\n * Color of the focus outline drawn inside the focused tile's shape (a CSS outline would be\n * clipped away), with a white inner line so it shows on any content. `false` for none,\n * if you style `[data-cell-id]:focus-visible` yourself. Defaults to \"#1a56db\".\n */\n focusRing?: string | false;\n /**\n * Animate changes: when the layout changes (a resize, another tiling, a new gap) or the\n * children do, tiles glide and morph into their new places and shapes, a child keeping\n * its tile as it moves; new tiles fade in and removed ones fade out. Pure CSS\n * transitions, skipped when the user prefers reduced motion. `true` for 400 ms, or\n * `{ duration, easing }`.\n */\n animate?: boolean | { duration?: number; easing?: string };\n /**\n * Mount only the tiles in view (plus `overscan` pixels round it, default 300), for\n * layouts with thousands of tiles. Tiles mount and unmount as the page or any scrolling\n * container scrolls, or the layout resizes. Keyboard navigation still reaches every\n * tile (the focused one stays mounted and is scrolled to), and list items carry\n * `aria-setsize` and `aria-posinset`. With `renderCell`, every cell `contentCells`\n * allows counts as having content. On the server no tiles are rendered.\n */\n virtualize?: boolean | { overscan?: number };\n /** Content for empty tiles. */\n fallback?: PerCell<ReactNode>;\n /** Class name for each tile wrapper (fixed or per cell). */\n cellClassName?: PerCell<string>;\n /** Extra style for each tile wrapper (fixed or per cell), e.g. a background color. */\n cellStyle?: PerCell<CSSProperties>;\n /** Color painted across the whole region, visible through the gaps. */\n background?: string;\n}\n\n/**\n * Renders a tiling as HTML: one absolutely positioned, `clip-path`-ed element per tile,\n * holding whatever you put in it (images, video, text, components). Everything is sized\n * in percentages, so the layout scales with the container's width.\n *\n * Each tile wrapper has `data-cell-id` and `data-index`, plus `data-empty` (no content)\n * and `data-boundary` (cut by the region outline) for styling.\n *\n * Clipping also applies to pointer events, so hover and clicks follow the tile shapes.\n */\nexport function TileLayout(props: TileLayoutProps) {\n const {\n options,\n layout: given,\n children,\n renderCell,\n contentCells,\n placement,\n aspects,\n choose,\n focalPoints,\n weights,\n safeArea,\n fill,\n fit,\n backdrop,\n relief,\n navigable,\n onCellActivate,\n cellLabel,\n focusRing = \"#1a56db\",\n animate,\n virtualize,\n fallback,\n cellClassName,\n cellStyle,\n background,\n style,\n role,\n onKeyDown,\n ...rest\n } = props;\n const uid = \"andamento\" + useId().replace(/:/g, \"\");\n const items = renderCell ? [] : Children.toArray(children);\n const layout = useResolvedLayout(\"TileLayout\", options, given, {\n fit: !renderCell && fit,\n count: items.length,\n cells: contentCells,\n weights: renderCell ? undefined : weights,\n placement,\n });\n const { bounds } = layout;\n // Slots, fills and bevels, reused from the last render where nothing they depend on changed.\n const buildFrame = useRef<ReturnType<typeof frameBuilder>>();\n buildFrame.current ??= frameBuilder();\n const frame = buildFrame.current(layout, {\n count: renderCell ? Infinity : items.length,\n aspects: renderCell ? undefined : aspects,\n contentCells,\n placement,\n choose,\n fill,\n relief,\n animate,\n });\n const { slots, anim } = frame;\n\n // Key by child where possible, so a child keeps its state (video position, inputs,\n // animations) when the layout changes underneath it.\n const keyOf = (i: number): Key => {\n const slot = slots[i]!;\n if (!renderCell && slot >= 0) {\n const child = items[slot];\n return isValidElement(child) && child.key != null ? `child:${child.key}` : `child:${slot}`;\n }\n return `cell:${layout.cells[i]!.id}`;\n };\n // What a tile holds.\n const makeEntry = (i: number) => {\n const cell = layout.cells[i]!;\n const slot = slots[i]!;\n let content: ReactNode = null;\n if (renderCell) content = renderCell(cell, { slot });\n else if (slot >= 0) content = items[slot];\n const empty = isEmpty(content);\n const state: CellState = { empty, slot: empty && !renderCell ? -1 : slot };\n if (empty) content = resolve(fallback, cell, state);\n return { i, cell, content, key: keyOf(i), empty, state };\n };\n\n // Virtualization: the part of the layout in view, in layout units (null until measured).\n const virtual = !!virtualize;\n const overscan = Math.max(0, (typeof virtualize === \"object\" ? virtualize.overscan : undefined) ?? 300);\n const container = useRef<HTMLDivElement>(null);\n const [view, setView] = useState<Rect | null>(null);\n // Without virtualization, every tile's entry is worked out before rendering, so navigation\n // knows which have content. With it, only the tiles in view are; whether others have\n // content is judged without rendering them.\n const allEntries = virtual ? undefined : layout.cells.map((_, i) => makeEntry(i));\n const hasContent = (i: number) =>\n allEntries ? !allEntries[i]!.empty : renderCell ? slots[i]! >= 0 : slots[i]! >= 0 && !isEmpty(items[slots[i]!]);\n\n // Animation: enter / exit animations for tiles that come and go (the tiles' own\n // transitions are in their style).\n const mounted = useRef(false);\n const lastKeys = useRef(new Set<Key>());\n const entering = useRef(new Set<Key>());\n const lastTiles = useRef(new Map<Key, ReactElement>());\n const [exiting, setExiting] = useState(() => new Map<Key, ReactElement>());\n const timers = useRef(new Set<ReturnType<typeof setTimeout>>());\n\n // Roving tabindex: one tile is the tab stop; arrow keys move it.\n const focusable = new Set(navigable ? layout.cells.filter((c) => hasContent(c.index)).map((c) => c.id) : []);\n const [activeId, setActiveId] = useState<string>();\n const firstFocusable = layout.cells.find((c) => focusable.has(c.id))?.id;\n const active = activeId !== undefined && focusable.has(activeId) ? activeId : firstFocusable;\n const tiles = useRef(new Map<string, HTMLDivElement>());\n const pendingFocus = useRef<string>();\n const list = (role ?? \"list\") === \"list\";\n\n // The tiles to render: all of them, or those in view plus the tab stop (so Tab finds it).\n let entries: ReturnType<typeof makeEntry>[];\n if (allEntries) entries = allEntries;\n else {\n const shown = new Set(view && view.width >= 0 ? cellsInRect(layout, view).map((c) => c.index) : []);\n const activeCell = active !== undefined ? layout.cells.find((c) => c.id === active) : undefined;\n if (activeCell) shown.add(activeCell.index);\n entries = [...shown].sort((a, b) => a - b).map(makeEntry);\n }\n // List positions, as screen readers can't count tiles that aren't there.\n let positions: Map<number, number> | undefined;\n if (virtual) {\n positions = new Map();\n for (const c of layout.cells) if (hasContent(c.index)) positions.set(c.index, positions.size + 1);\n }\n\n // Animation bookkeeping uses every tile's key, so tiles scrolling in and out of view\n // don't count as coming and going.\n const allKeys = anim ? new Set(layout.cells.map((_, i) => keyOf(i))) : undefined;\n for (const e of entries) if (anim && mounted.current && !lastKeys.current.has(e.key)) entering.current.add(e.key);\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !navigable || e.altKey || e.ctrlKey || e.metaKey) return;\n // Only when a tile itself has focus, not an input or button inside it.\n const entry = entries.find((x) => tiles.current.get(x.cell.id) === e.target);\n if (!entry || !focusable.has(entry.cell.id)) return;\n const action = keyAction(layout, entry.cell, e.key, (c: Cell) => focusable.has(c.id), !!onCellActivate);\n if (!action) return;\n // Arrow keys at the edge are still ours: don't scroll the page.\n e.preventDefault();\n if (\"activate\" in action) onCellActivate!(entry.cell, entry.state);\n else if (\"move\" in action) {\n setActiveId(action.move.id);\n const el = tiles.current.get(action.move.id);\n // A tile out of view isn't mounted yet: focus it once it is.\n if (el) el.focus();\n else pendingFocus.current = action.move.id;\n }\n };\n\n const rendered = entries.map(({ i, cell, content, key, empty, state }) => {\n const slot = slots[i]!;\n const bevel = frame.bevel(i);\n const tile = tileStyle(frame, cell, {\n empty,\n safeArea,\n backdrop: backdrop != null,\n clickable: !!onCellActivate && !empty,\n focus: !renderCell && slot >= 0 ? focalPoints?.[slot] : undefined,\n aspect: !renderCell && slot >= 0 ? aspects?.[slot] : undefined,\n });\n // Tiles with nothing in them are decoration: hidden from assistive technology.\n const silent = empty && isEmpty(content);\n const canFocus = focusable.has(cell.id);\n const viewBox = tileViewBox(cell);\n return (\n <div\n key={key}\n ref={(el) => {\n if (el) tiles.current.set(cell.id, el);\n else tiles.current.delete(cell.id);\n }}\n role={silent ? undefined : list ? \"listitem\" : undefined}\n aria-hidden={silent ? true : undefined}\n aria-label={silent ? undefined : resolve(cellLabel, cell, state)}\n aria-setsize={positions && list && !silent ? positions.size : undefined}\n aria-posinset={positions && list && !silent ? positions.get(i) : undefined}\n tabIndex={canFocus ? (cell.id === active ? 0 : -1) : undefined}\n onFocus={canFocus ? (e) => e.target === e.currentTarget && setActiveId(cell.id) : undefined}\n onClick={onCellActivate && !empty ? () => onCellActivate(cell, state) : undefined}\n className={resolve(cellClassName, cell, state)}\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={empty ? \"\" : undefined}\n data-boundary={cell.boundary ? \"\" : undefined}\n data-entering={entering.current.has(key) ? \"\" : undefined}\n style={{ ...css(tile), ...resolve(cellStyle, cell, state) }}\n >\n {backdrop != null && (\n // z-index -1 puts it behind the content but inside the tile: the tile's\n // clip-path makes it a stacking context.\n <div aria-hidden style={css(backdropStyle(frame, cell))}>\n {backdrop}\n </div>\n )}\n {safeArea && content != null && !isEmpty(content) ? (\n <div data-safe-area=\"\" style={css(safeBoxStyle(frame, cell, !renderCell && !empty && aspects ? (aspects[slot] ?? 1) : undefined, safeArea))}>\n {content}\n </div>\n ) : (\n content\n )}\n {bevel && bevel.length > 0 && (\n // Over the content; the tile's box is its bounding box, so map that to the viewBox.\n // When animating, the bevel is for the new shape, so it fades in as the tile arrives.\n <svg\n key={anim ? String(tile.clipPath) : undefined}\n aria-hidden\n data-bevel=\"\"\n data-late={anim ? \"\" : undefined}\n viewBox={viewBox}\n preserveAspectRatio=\"none\"\n style={css(overlayStyle)}\n >\n {bevel.map((p, k) => (\n <path key={k} d={p.d} fill={p.fill} fillOpacity={p.opacity} />\n ))}\n </svg>\n )}\n {canFocus && focusRing !== false && (\n // The tile's outline, stroked across its edge; the clip keeps the inner half.\n <svg aria-hidden data-focus-ring=\"\" viewBox={viewBox} preserveAspectRatio=\"none\" style={css(overlayStyle)}>\n {ringStrokes(frame, cell, focusRing).map((p, k) => (\n <path key={k} d={p.d} fill=\"none\" stroke={p.stroke} strokeWidth={p.width} vectorEffect=\"non-scaling-stroke\" />\n ))}\n </svg>\n )}\n </div>\n );\n });\n\n // After each commit: tiles that just went away stay a moment to fade out.\n useIsomorphicLayoutEffect(() => {\n const current = new Map<Key, ReactElement>(rendered.map((el) => [el.key!, el]));\n const present = allKeys ?? current;\n if (anim && mounted.current) {\n const gone = [...lastTiles.current].filter(([k]) => !present.has(k));\n if (gone.length) {\n setExiting((prev) => new Map([...prev, ...gone]));\n const timer = setTimeout(() => {\n timers.current.delete(timer);\n setExiting((prev) => {\n const next = new Map(prev);\n for (const [k, el] of gone) if (next.get(k) === el) next.delete(k);\n return next;\n });\n }, anim.duration);\n timers.current.add(timer);\n }\n }\n for (const k of entering.current) if (!present.has(k)) entering.current.delete(k);\n lastKeys.current = new Set(present.keys());\n lastTiles.current = current;\n mounted.current = true;\n if (pendingFocus.current) {\n const el = tiles.current.get(pendingFocus.current);\n if (el) {\n pendingFocus.current = undefined;\n el.focus();\n }\n }\n });\n\n // Virtualization: measure what's in view, again on scroll (of the page or any container)\n // and resize, at most once a frame.\n useIsomorphicLayoutEffect(() => {\n if (!virtual) return;\n const el = container.current;\n if (!el) return;\n return watchView(el, () => {\n const next = viewRect(el, layout, overscan);\n setView((v) => (sameRect(v ?? undefined, next) ? v : next));\n });\n }, [virtual, layout, overscan]);\n useEffect(() => {\n const set = timers.current;\n return () => set.forEach(clearTimeout);\n }, []);\n const leaving = anim\n ? [...exiting].filter(([k]) => !lastKeys.current.has(k) && !rendered.some((el) => el.key === k))\n : [];\n\n const sheet = tileSheet({ focusRing: !!navigable && focusRing !== false, anim });\n const shadow = shadowShape(frame, entries.map((e) => e.cell));\n return (\n <div\n data-andamento=\"\"\n ref={container}\n role={role ?? \"list\"}\n {...rest}\n onKeyDown={handleKeyDown}\n style={{ ...css(containerStyle(layout)), ...style }}\n >\n {sheet && <style>{sheet}</style>}\n {background && <div aria-hidden style={css(backgroundStyle(frame, background))} />}\n {shadow && (\n <svg aria-hidden data-andamento-shadow=\"\" viewBox={shadow.viewBox} preserveAspectRatio=\"none\" style={css(shadow.style)}>\n <filter id={`${uid}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={shadow.blur} />\n </filter>\n <path d={shadow.d} fillRule=\"evenodd\" transform={shadow.transform} fill=\"#000\" fillOpacity={shadow.opacity} filter={`url(#${uid}-shadow)`} />\n </svg>\n )}\n {rendered}\n {leaving.map(([k, el]) =>\n // Fades out through the [data-exiting] rule in the style sheet.\n cloneElement(el as ReactElement<Record<string, unknown>>, {\n key: k,\n ref: null,\n role: undefined,\n tabIndex: undefined,\n onClick: undefined,\n onFocus: undefined,\n \"aria-hidden\": true,\n \"data-entering\": undefined,\n \"data-exiting\": \"\",\n }),\n )}\n </div>\n );\n}\n\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Style that makes an <img> or <video> cover its tile, like `object-fit: cover`. */\nexport const coverStyle: CSSProperties = css(sharedCoverStyle);\n","import { useMemo, useRef } from \"react\";\nimport { createLayout, fitCount, type ContentCells, type FitOptions, type Layout, type LayoutOptions } from \"@andamento/core\";\nimport { layoutResolver, type FitProp, type LayoutNeeds } from \"@andamento/dom\";\n\n/**\n * Compute a layout, recomputing only when the (serializable) options change.\n * Inline object literals are fine: options are compared by value.\n */\nexport function useTileLayout(options: LayoutOptions): Layout {\n const key = JSON.stringify(options);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => createLayout(options), [key]);\n}\n\n/**\n * Compute a layout whose tiles are sized to give about `count` usable cells (see\n * `fitCount` in @andamento/core). Options are compared by value; a `cells` function by\n * identity.\n */\nexport function useFitCount(options: LayoutOptions, count: number, fit: FitOptions = {}): Layout {\n const key = JSON.stringify(options);\n const { cells, mode } = fit;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => fitCount(options, count, { cells, mode }).layout, [key, count, cells, mode]);\n}\n\nexport type { FitProp };\n\n/**\n * Use `layout` if given, otherwise compute one from `options` (compared by value), fitted to\n * `count` items when `fit` is set.\n */\nexport function useResolvedLayout(\n component: string,\n options?: LayoutOptions,\n layout?: Layout,\n fit?: LayoutNeeds,\n): Layout {\n const resolver = useRef<ReturnType<typeof layoutResolver>>();\n resolver.current ??= layoutResolver(`<${component}>`);\n return resolver.current(options, layout, fit);\n}\n","import { useId, useMemo, type ReactNode, type SVGProps } from \"react\";\nimport { cellShape, coverRect, safeArea, type Cell, type Focus, type ContentCells, type ContentPlacement, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport { cellA11y, cellPath, defaultBevel, regionPath, viewPath, reliefPaths, resolveCellStyles, shadowOffset, type FillSource, type ImageSource, type ReliefOptions } from \"@andamento/svg\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport interface SvgCellRenderContext {\n /** `d` attribute of the cell outline. */\n path: string;\n /** Id of a <clipPath> with the cell's shape, already in the SVG. */\n clipPathId: string;\n /** Ready-made `clipPath` prop value: `url(#…)`. */\n clipPath: string;\n /** The fill/image the default renderer would have used. */\n fill: string;\n image?: string;\n /** Which item of `images` the cell shows (-1 if none or if `images` is a function). */\n slot: number;\n}\n\nexport interface SvgTileLayoutProps extends Omit<SVGProps<SVGSVGElement>, \"children\" | \"fill\" | \"stroke\" | \"strokeWidth\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n images?: ImageSource;\n repeatImages?: boolean;\n /** Which cells may hold an image from the `images` array: \"all\" (default), \"whole\" or a test. */\n contentCells?: ContentCells;\n /** Where images go when there are fewer than cells: \"reading\" (default), \"center\" or \"spread\". */\n placement?: ContentPlacement;\n /** Width / height of each image, to put images in cells of similar shape (see `matchSlots`). */\n imageAspects?: readonly number[];\n /** With `imageAspects`: \"shape\" also picks which cells get images by their shape. */\n choose?: \"placement\" | \"shape\";\n /**\n * \"cover\" (default) fills each cell's bounding box, cropped to its shape; \"contain\" shows\n * each image whole inside the cell's safe area (see `safeArea`), at its `imageAspects` shape.\n */\n imageFit?: \"cover\" | \"contain\";\n /**\n * With `imageFit: \"contain\"`, for cells an `edges: \"window\"` layout cuts: fit the image in\n * the whole tile (\"tile\", the default) or in the part that shows (\"visible\").\n */\n containWithin?: \"tile\" | \"visible\";\n /**\n * Focal point of each image (by position; fractions of its width and height, see\n * `estimateFocus`), kept in view when \"cover\" crops it (see `coverRect`). Needs each image's\n * shape, from `imageAspects` or the focus's `aspect`.\n */\n imageFocus?: readonly (Focus | undefined)[];\n /**\n * How many tiles each image in `images` spans (1 for most): heavier images get featured\n * tiles where they fall in reading order (see `weightedLayout`). Needs `options`.\n */\n imageWeights?: readonly number[];\n /**\n * Size the tiles to the `images` array (counted by `contentCells`): `true`/\"atLeast\" or\n * \"nearest\". Ignored with `layout`, `repeatImages` or an `images` function.\n */\n fit?: FitProp;\n /** Cell color under (or instead of) images. Defaults to `defaultPalette`. */\n fill?: FillSource;\n stroke?: string;\n strokeWidth?: number;\n /** Color painted across the whole region, behind the cells. */\n background?: string;\n /**\n * One image across all the cells (a URL), cropped to cover the layout and clipped to the\n * cells. The default cell rendering then skips `fill`; per-cell `images` go on top.\n */\n backdrop?: string;\n /**\n * Raised tiles: a lit bevel over each cell, and optionally a shadow cast into the grout.\n * `true` for the defaults. See `ReliefOptions`. Drawn over `renderCell` content too.\n */\n relief?: boolean | ReliefOptions;\n /** Replace the default cell rendering with SVG content. Rendered inside a <g> per cell. */\n renderCell?: (cell: Cell, ctx: SvgCellRenderContext) => ReactNode;\n /** Accessible title. */\n title?: string;\n /** Text alternative per image in `images`: those cells become labeled images; the rest decoration. */\n imageAlts?: readonly string[];\n}\n\n/**\n * Renders a tiling as a single <svg>: colored cells, optionally with images clipped\n * to each cell. Use this when you need pure SVG (export, print, embedding in other SVG);\n * use <TileLayout> to put arbitrary HTML/React content in the tiles.\n */\nexport function SvgTileLayout(props: SvgTileLayoutProps) {\n const {\n options,\n layout: given,\n images,\n repeatImages,\n contentCells,\n placement,\n imageAspects,\n choose,\n imageFit,\n containWithin,\n imageFocus,\n imageWeights,\n fit,\n fill,\n stroke,\n strokeWidth = 1,\n background,\n backdrop,\n relief: reliefProp,\n renderCell,\n title,\n imageAlts,\n ...svgProps\n } = props;\n const fitTo = Array.isArray(images) && !repeatImages ? images.length : 0;\n const layout = useResolvedLayout(\"SvgTileLayout\", options, given, {\n fit,\n count: fitTo,\n cells: contentCells,\n weights: Array.isArray(images) ? imageWeights : undefined,\n placement,\n });\n const prefix = \"andamento\" + useId().replace(/:/g, \"\");\n const styles = useMemo(\n () => resolveCellStyles(layout, { images, repeatImages, fill, contentCells, placement, imageAspects, choose }),\n [layout, images, repeatImages, fill, contentCells, placement, imageAspects, choose],\n );\n const { x, y, width, height } = layout.bounds;\n const relief = reliefProp === true ? {} : reliefProp || undefined;\n const reliefKey = relief ? JSON.stringify(relief) : \"\";\n const bevels = useMemo(() => {\n if (!relief) return undefined;\n const bevel = relief.bevel ?? defaultBevel(layout);\n return bevel > 0 ? layout.cells.map((c) => reliefPaths(layout, c, relief, bevel)) : undefined;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layout, reliefKey]);\n const cast = relief && shadowOffset(relief);\n\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={`${x} ${y} ${width} ${height}`} role={imageAlts?.length ? \"group\" : title ? \"img\" : undefined} {...svgProps}>\n {title && <title>{title}</title>}\n {background && <path className=\"andamento-region\" d={regionPath(layout)} fill={background} fillRule=\"evenodd\" />}\n {layout.view && (\n <clipPath id={`${prefix}-view`}>\n <path d={viewPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n )}\n <g className={layout.view ? \"andamento-view\" : undefined} clipPath={layout.view ? `url(#${prefix}-view)` : undefined}>\n {backdrop && (\n <>\n <clipPath id={`${prefix}-backdrop`}>\n {layout.cells.map((cell) => (\n <path key={cell.id} d={cellPath(layout, cell)} clipRule=\"evenodd\" />\n ))}\n </clipPath>\n <image\n className=\"andamento-backdrop\"\n href={backdrop}\n x={x}\n y={y}\n width={width}\n height={height}\n preserveAspectRatio=\"xMidYMid slice\"\n clipPath={`url(#${prefix}-backdrop)`}\n />\n </>\n )}\n {cast && (\n <g className=\"andamento-shadow\" clipPath={`url(#${prefix}-region)`}>\n <clipPath id={`${prefix}-region`}>\n <path d={regionPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n <filter id={`${prefix}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={cast.blur} />\n </filter>\n <path\n d={layout.cells.map((c) => cellPath(layout, c)).join(\"\")}\n fillRule=\"evenodd\"\n transform={`translate(${cast.dx} ${cast.dy})`}\n fill=\"#000\"\n fillOpacity={cast.opacity}\n filter={`url(#${prefix}-shadow)`}\n />\n </g>\n )}\n {layout.cells.map((cell, i) => {\n const d = cellPath(layout, cell);\n const clipPathId = `${prefix}-clip-${cell.index}`;\n const style = styles[i]!;\n const ctx: SvgCellRenderContext = { path: d, clipPathId, clipPath: `url(#${clipPathId})`, ...style };\n return (\n <g\n key={cell.id}\n className=\"andamento-cell\"\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={style.image ? undefined : \"\"}\n data-boundary={cell.boundary ? \"\" : undefined}\n {...cellA11y(style, imageAlts)}\n >\n <clipPath id={clipPathId}>\n <path d={d} clipRule=\"evenodd\" />\n </clipPath>\n {renderCell ? renderCell(cell, ctx) : <DefaultCell\n cell={cell}\n ctx={ctx}\n noFill={!!backdrop}\n box={\n imageFit === \"contain\" && style.image\n ? safeArea(cell, layout, { aspect: imageAspects && style.slot >= 0 ? imageAspects[style.slot] : undefined, within: containWithin })\n : undefined\n }\n cover={(() => {\n const focus = imageFit !== \"contain\" && style.image && style.slot >= 0 ? (Array.isArray(images) ? imageFocus?.[style.slot % images.length] : undefined) : undefined;\n const aspect = focus ? (imageAspects?.[style.slot % imageAspects.length] ?? focus.aspect) : undefined;\n return focus && aspect ? coverRect(cell, layout, { aspect, focus }) : undefined;\n })()}\n />}\n {bevels?.[i]!.map((p, k) => <path key={k} className=\"andamento-bevel\" d={p.d} fill={p.fill} fillOpacity={p.opacity} />)}\n {stroke && <path d={d} fill=\"none\" stroke={stroke} strokeWidth={strokeWidth} />}\n </g>\n );\n })}\n </g>\n </svg>\n );\n}\n\nfunction DefaultCell({ cell, ctx, noFill, box, cover }: { cell: Cell; ctx: SvgCellRenderContext; noFill: boolean; box?: Rect; cover?: Rect }) {\n return (\n <>\n {!noFill && <path d={ctx.path} fill={ctx.fill} fillRule=\"evenodd\" />}\n {ctx.image && <SvgCellImage cell={cell} href={ctx.image} clipPath={ctx.clipPath} box={box} cover={cover} />}\n </>\n );\n}\n\nexport interface SvgCellImageProps extends Omit<SVGProps<SVGImageElement>, \"href\" | \"x\" | \"y\" | \"width\" | \"height\"> {\n cell: Cell;\n href: string;\n /** Pass `ctx.clipPath` from `renderCell`. */\n clipPath: string;\n /**\n * Draw the image whole inside this box (e.g. `safeArea(cell, layout)`) instead of\n * covering the cell.\n */\n box?: Rect;\n /** Cover this rectangle instead of the cell's box (e.g. `coverRect(cell, layout, { aspect, focus })`). */\n cover?: Rect;\n}\n\n/**\n * An SVG <image> that covers the cell (like CSS `object-fit: cover`), clipped to its shape;\n * or, with `box`, shown whole inside the box (like `object-fit: contain`).\n */\nexport function SvgCellImage({ cell, href, clipPath, box, cover, ...rest }: SvgCellImageProps) {\n const b = box ?? cover ?? cellShape(cell).bbox;\n return (\n <image\n href={href}\n x={b.x}\n y={b.y}\n width={b.width}\n height={b.height}\n preserveAspectRatio={box ? \"xMidYMid meet\" : \"xMidYMid slice\"}\n clipPath={clipPath}\n {...rest}\n />\n );\n}\n","import { useEffect, useMemo, useState } from \"react\";\nimport { imageFill, loadImagePixels, type CellFill, type ImageFillOptions, type Pixels } from \"@andamento/core\";\n\n/**\n * Load an image and color tiles from it (see `imageFill`): returns a fill to pass as\n * `fill`, or `undefined` while the image loads (or if it fails), so the default fill shows\n * meanwhile. `maxSize` caps the size the image is read at (default 256 px on the long side).\n */\nexport function useImageFill(src: string | undefined, options: ImageFillOptions & { maxSize?: number } = {}): CellFill | undefined {\n const { fit, palette, fallback, samples, maxSize = 256 } = options;\n const [pixels, setPixels] = useState<{ src: string; pixels: Pixels }>();\n useEffect(() => {\n if (!src) return;\n let live = true;\n loadImagePixels(src, maxSize).then(\n (p) => live && setPixels({ src, pixels: p }),\n (e) => console.warn(`useImageFill: ${(e as Error).message}`),\n );\n return () => {\n live = false;\n };\n }, [src, maxSize]);\n const paletteKey = palette?.join(\",\");\n return useMemo(\n () => (pixels && pixels.src === src ? imageFill(pixels.pixels, { fit, palette, fallback, samples }) : undefined),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [pixels, src, fit, paletteKey, fallback, samples],\n );\n}\n","import { useEffect, useState } from \"react\";\n\n/**\n * Measure images' aspect ratios (width / height) by loading them, for the `aspects` and\n * `imageAspects` props. Returns `undefined` until every image has loaded or failed (failed\n * ones count as square), so content isn't reshuffled image by image as they arrive.\n */\nexport function useImageAspects(srcs: readonly string[] | undefined): number[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; aspects: number[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof Image === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map(\n (src) =>\n new Promise<number>((resolve) => {\n const img = new Image();\n img.onload = () => resolve(img.naturalWidth && img.naturalHeight ? img.naturalWidth / img.naturalHeight : 1);\n img.onerror = () => resolve(1);\n img.src = src;\n }),\n ),\n ).then((aspects) => live && setResult({ key, aspects }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.aspects : undefined;\n}\n","import { useEffect, useState } from \"react\";\nimport { estimateFocus, loadImagePixels, type Focus } from \"@andamento/core\";\n\n/**\n * Guess each image's focal point (see `estimateFocus`) by loading it, for the `focus` and\n * `imageFocus` props. Returns `undefined` until every image has been looked at; images that\n * fail to load (or that the browser won't let a canvas read) get the middle.\n */\nexport function useImageFocus(srcs: readonly string[] | undefined): Focus[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; focus: Focus[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof document === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map((src) =>\n loadImagePixels(src, 128)\n .then(estimateFocus)\n .catch(() => ({ x: 0.5, y: 0.5 })),\n ),\n ).then((focus) => live && setResult({ key, focus }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.focus : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAeO;AACP,IAAAC,eAAyI;AACzI,IAAAC,cAqBO;;;ACtCP,mBAAgC;AAChC,kBAA4G;AAC5G,iBAA+D;AAMxD,SAAS,cAAc,SAAgC;AAC5D,QAAM,MAAM,KAAK,UAAU,OAAO;AAElC,aAAO,sBAAQ,UAAM,0BAAa,OAAO,GAAG,CAAC,GAAG,CAAC;AACnD;AAOO,SAAS,YAAY,SAAwB,OAAe,MAAkB,CAAC,GAAW;AAC/F,QAAM,MAAM,KAAK,UAAU,OAAO;AAClC,QAAM,EAAE,OAAO,KAAK,IAAI;AAExB,aAAO,sBAAQ,UAAM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ACnD,WAAO,MAAM;AACX,aAAO;AAAA,IACT;AAAA,EAEF,GAAG,CAAC,GAAG,CAAC;AACR,SAAO,UAAU,OAAO,QAAQ,MAAM,OAAO,QAAQ;AACvD;;;ANdA,IAAAC,cAAgC;AAIhC,IAAAC,cAA+C;","names":["import_react","import_core","import_dom","safeArea","resolve","sharedCoverStyle","import_react","import_core","import_jsx_runtime","import_react","import_core","import_react","resolve","import_react","import_core","import_dom","import_svg"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/TileLayout.tsx","../src/useTileLayout.ts","../src/SvgTileLayout.tsx","../src/useImageFill.ts","../src/useImageAspects.ts","../src/useImageFocus.ts"],"sourcesContent":["/**\n * React bindings: `<TileLayout>` (any children, clipped to the tiles), `<SvgTileLayout>` and hooks.\n *\n * @module @andamento/react\n */\nexport { TileLayout, coverStyle } from \"./TileLayout\";\nexport type { CellState, TileLayoutProps } from \"./TileLayout\";\nexport { SvgTileLayout, SvgCellImage } from \"./SvgTileLayout\";\nexport type { SvgTileLayoutProps, SvgCellImageProps, SvgCellRenderContext } from \"./SvgTileLayout\";\nexport { useFitCount, useTileLayout } from \"./useTileLayout\";\nexport { useImageFill } from \"./useImageFill\";\nexport { useImageAspects } from \"./useImageAspects\";\nexport { useImageFocus } from \"./useImageFocus\";\nexport { cellFromPointer } from \"@andamento/dom\";\nexport type { PerCell, PointerLike } from \"@andamento/dom\";\nexport type { FitProp } from \"./useTileLayout\";\nexport type { Cell, ContentCells, ContentPlacement, Focus, Layout, LayoutOptions, MatchOptions, SafeAreaOptions, HitOptions } from \"@andamento/core\";\nexport { defaultPalette, neutralPalette } from \"@andamento/svg\";\nexport type { FillSource, ReliefOptions } from \"@andamento/svg\";\n","import {\n Children,\n cloneElement,\n isValidElement,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type KeyboardEvent,\n type CSSProperties,\n type HTMLAttributes,\n type Key,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { cellsInRect, type Cell, type ContentCells, type ContentPlacement, type Focus, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport {\n coverStyle as sharedCoverStyle,\n type CellState,\n type SafeAreaProp,\n type PerCell,\n} from \"@andamento/dom\";\nimport {\n backdropStyle,\n backgroundStyle,\n containerStyle,\n frameBuilder,\n keyAction,\n overlayStyle,\n resolvePerCell as resolve,\n ringStrokes,\n safeBoxStyle,\n sameRect,\n shadowShape,\n tileSheet,\n tileStyle,\n tileViewBox,\n viewRect,\n watchView,\n} from \"@andamento/dom/internal\";\nimport type { FillSource, ReliefOptions } from \"@andamento/svg\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport type { CellState };\n\nconst isEmpty = (n: ReactNode) => n == null || n === false || n === true || n === \"\";\nconst css = (s: object) => s as CSSProperties;\n\nexport interface TileLayoutProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n /**\n * Any React content. Each top-level child fills one tile, in reading order\n * (top-to-bottom, left-to-right), and is clipped to the tile's shape.\n * Extra children beyond the number of tiles are not rendered.\n */\n children?: ReactNode;\n /**\n * Alternative to `children`: compute each tile's content from its cell. Takes precedence.\n * `slot` numbers the cells allowed by `contentCells` in reading order (-1 for the rest).\n */\n renderCell?: (cell: Cell, state: { slot: number }) => ReactNode;\n /**\n * Which tiles may hold children: \"all\" (default), \"whole\" (only tiles not cut by the\n * region outline), or a test per cell. The others are left empty.\n */\n contentCells?: ContentCells;\n /**\n * Where children go when there are fewer than tiles: \"reading\" (default; the first\n * tiles in reading order), \"center\" (the middle of the region) or \"spread\" (evenly\n * over it). Children always run in reading order across the tiles chosen.\n */\n placement?: ContentPlacement;\n /**\n * Width / height of each child, in order. When given, each child goes in a tile of\n * similar shape, so `object-fit: cover` crops as little as possible (landscape photos in\n * wide tiles, portraits in tall ones); see `matchSlots`. Featured tiles still take the\n * first children. Missing entries count as square. Ignored with `renderCell`.\n */\n aspects?: readonly number[];\n /**\n * Keep content out of the tiles' clipped corners: each tile's content goes in a box at\n * the tile's safe area (see `safeArea`), the largest rectangle that fits inside its shape,\n * instead of filling the tile's bounding box. Useful for text in triangles or hexagons.\n * With `aspects`, each child's box has the child's shape, so it shows whole and uncropped.\n * The box has `data-safe-area`; style its contents to fill it. Tiles show `fill` around\n * their content. For tiles an `edges: \"window\"` layout cuts, `true` or \"tile\" fits the\n * whole tile (content near the edge is partly hidden, like the tile) and \"visible\" the\n * part that shows.\n */\n safeArea?: SafeAreaProp;\n /** With `aspects`: \"shape\" also picks which tiles hold children by their shape, ignoring `placement`. */\n choose?: \"placement\" | \"shape\";\n /**\n * Focal point of each child (fractions of its width and height; see `estimateFocus`): what\n * a photo keeps in view as its tile crops it. Each tile sets `--andamento-object-position`,\n * which `coverStyle` uses as `object-position`; exact when the photo's shape is known (`aspects`, or the focus's `aspect`).\n */\n focalPoints?: readonly (Focus | undefined)[];\n /**\n * How many tiles each child spans (1 for an ordinary child; rounded): heavier childs get a\n * featured tile of that many merged tiles, where they fall in reading order (see\n * `weightedLayout`). With `fit`, the tiles are sized to fit everything. Needs `options`.\n */\n weights?: readonly number[];\n /**\n * Color of empty tiles: a color, a palette (neighboring tiles get different entries),\n * or a function per cell. Defaults to `neutralPalette`; use \"transparent\" for none.\n */\n fill?: FillSource;\n /**\n * Size the tiles to the children: scales the pattern so there are about as many tiles\n * (counted by `contentCells`) as children. `true`/\"atLeast\" makes sure every child gets\n * a tile; \"nearest\" gets as close as possible. Ignored with `layout` or `renderCell`.\n */\n fit?: FitProp;\n /**\n * One picture across all the tiles: rendered in every tile, sized and positioned to the\n * whole layout, so each tile shows its own piece. Use an element that fills its box,\n * e.g. `<img src=… style={coverStyle} />`. It sits behind the tile's content, and empty\n * tiles show it instead of `fill`. (Each tile gets its own copy, so a video would play\n * out of sync; images are loaded once.)\n */\n backdrop?: ReactNode;\n /**\n * Raised tiles: a bevel round each tile, lit from one side and drawn over its content,\n * and optionally a soft shadow each tile casts into the grout (set `shadow`). `true` for\n * the defaults. With `gap` as the grout width and `background` as its color or texture,\n * it looks like a tiled surface. See `ReliefOptions`.\n */\n relief?: boolean | ReliefOptions;\n /**\n * Keyboard navigation: tiles with content become focusable as one tab stop (roving\n * tabindex). Arrow keys move to a touching tile in that direction, whatever the tiling;\n * Home and End go to the first and last. The focused tile shows `focusRing`.\n */\n navigable?: boolean;\n /**\n * Called when a tile with content is activated: clicked, or Enter or Space while it has\n * focus (with `navigable`).\n */\n onCellActivate?: (cell: Cell, state: CellState) => void;\n /** Accessible name for each tile (its `aria-label`), e.g. a photo's description. */\n cellLabel?: PerCell<string | undefined>;\n /**\n * Color of the focus outline drawn inside the focused tile's shape (a CSS outline would be\n * clipped away), with a white inner line so it shows on any content. `false` for none,\n * if you style `[data-cell-id]:focus-visible` yourself. Defaults to \"#1a56db\".\n */\n focusRing?: string | false;\n /**\n * Animate changes: when the layout changes (a resize, another tiling, a new gap) or the\n * children do, tiles glide and morph into their new places and shapes, a child keeping\n * its tile as it moves; new tiles fade in and removed ones fade out. Pure CSS\n * transitions, skipped when the user prefers reduced motion. `true` for 400 ms, or\n * `{ duration, easing }`.\n */\n animate?: boolean | { duration?: number; easing?: string };\n /**\n * Mount only the tiles in view (plus `overscan` pixels round it, default 300), for\n * layouts with thousands of tiles. Tiles mount and unmount as the page or any scrolling\n * container scrolls, or the layout resizes. Keyboard navigation still reaches every\n * tile (the focused one stays mounted and is scrolled to), and list items carry\n * `aria-setsize` and `aria-posinset`. With `renderCell`, every cell `contentCells`\n * allows counts as having content. On the server no tiles are rendered.\n */\n virtualize?: boolean | { overscan?: number };\n /** Content for empty tiles. */\n fallback?: PerCell<ReactNode>;\n /** Class name for each tile wrapper (fixed or per cell). */\n cellClassName?: PerCell<string>;\n /** Extra style for each tile wrapper (fixed or per cell), e.g. a background color. */\n cellStyle?: PerCell<CSSProperties>;\n /** Color painted across the whole region, visible through the gaps. */\n background?: string;\n}\n\n/**\n * Renders a tiling as HTML: one absolutely positioned, `clip-path`-ed element per tile,\n * holding whatever you put in it (images, video, text, components). Everything is sized\n * in percentages, so the layout scales with the container's width.\n *\n * Each tile wrapper has `data-cell-id` and `data-index`, plus `data-empty` (no content)\n * and `data-boundary` (cut by the region outline) for styling.\n *\n * Clipping also applies to pointer events, so hover and clicks follow the tile shapes.\n */\nexport function TileLayout(props: TileLayoutProps) {\n const {\n options,\n layout: given,\n children,\n renderCell,\n contentCells,\n placement,\n aspects,\n choose,\n focalPoints,\n weights,\n safeArea,\n fill,\n fit,\n backdrop,\n relief,\n navigable,\n onCellActivate,\n cellLabel,\n focusRing = \"#1a56db\",\n animate,\n virtualize,\n fallback,\n cellClassName,\n cellStyle,\n background,\n style,\n role,\n onKeyDown,\n ...rest\n } = props;\n const uid = \"andamento\" + useId().replace(/:/g, \"\");\n const items = renderCell ? [] : Children.toArray(children);\n const layout = useResolvedLayout(\"TileLayout\", options, given, {\n fit: !renderCell && fit,\n count: items.length,\n cells: contentCells,\n weights: renderCell ? undefined : weights,\n placement,\n });\n const { bounds } = layout;\n // Slots, fills and bevels, reused from the last render where nothing they depend on changed.\n const buildFrame = useRef<ReturnType<typeof frameBuilder>>();\n buildFrame.current ??= frameBuilder();\n const frame = buildFrame.current(layout, {\n count: renderCell ? Infinity : items.length,\n aspects: renderCell ? undefined : aspects,\n contentCells,\n placement,\n choose,\n fill,\n relief,\n animate,\n });\n const { slots, anim } = frame;\n\n // Key by child where possible, so a child keeps its state (video position, inputs,\n // animations) when the layout changes underneath it.\n const keyOf = (i: number): Key => {\n const slot = slots[i]!;\n if (!renderCell && slot >= 0) {\n const child = items[slot];\n return isValidElement(child) && child.key != null ? `child:${child.key}` : `child:${slot}`;\n }\n return `cell:${layout.cells[i]!.id}`;\n };\n // What a tile holds.\n const makeEntry = (i: number) => {\n const cell = layout.cells[i]!;\n const slot = slots[i]!;\n let content: ReactNode = null;\n if (renderCell) content = renderCell(cell, { slot });\n else if (slot >= 0) content = items[slot];\n const empty = isEmpty(content);\n const state: CellState = { empty, slot: empty && !renderCell ? -1 : slot };\n if (empty) content = resolve(fallback, cell, state);\n return { i, cell, content, key: keyOf(i), empty, state };\n };\n\n // Virtualization: the part of the layout in view, in layout units (null until measured).\n const virtual = !!virtualize;\n const overscan = Math.max(0, (typeof virtualize === \"object\" ? virtualize.overscan : undefined) ?? 300);\n const container = useRef<HTMLDivElement>(null);\n const [view, setView] = useState<Rect | null>(null);\n // Without virtualization, every tile's entry is worked out before rendering, so navigation\n // knows which have content. With it, only the tiles in view are; whether others have\n // content is judged without rendering them.\n const allEntries = virtual ? undefined : layout.cells.map((_, i) => makeEntry(i));\n const hasContent = (i: number) =>\n allEntries ? !allEntries[i]!.empty : renderCell ? slots[i]! >= 0 : slots[i]! >= 0 && !isEmpty(items[slots[i]!]);\n\n // Animation: enter / exit animations for tiles that come and go (the tiles' own\n // transitions are in their style).\n const mounted = useRef(false);\n const lastKeys = useRef(new Set<Key>());\n const entering = useRef(new Set<Key>());\n const lastTiles = useRef(new Map<Key, ReactElement>());\n const [exiting, setExiting] = useState(() => new Map<Key, ReactElement>());\n const timers = useRef(new Set<ReturnType<typeof setTimeout>>());\n\n // Roving tabindex: one tile is the tab stop; arrow keys move it.\n const focusable = new Set(navigable ? layout.cells.filter((c) => hasContent(c.index)).map((c) => c.id) : []);\n const [activeId, setActiveId] = useState<string>();\n const firstFocusable = layout.cells.find((c) => focusable.has(c.id))?.id;\n const active = activeId !== undefined && focusable.has(activeId) ? activeId : firstFocusable;\n const tiles = useRef(new Map<string, HTMLDivElement>());\n const pendingFocus = useRef<string>();\n const list = (role ?? \"list\") === \"list\";\n\n // The tiles to render: all of them, or those in view plus the tab stop (so Tab finds it).\n let entries: ReturnType<typeof makeEntry>[];\n if (allEntries) entries = allEntries;\n else {\n const shown = new Set(view && view.width >= 0 ? cellsInRect(layout, view).map((c) => c.index) : []);\n const activeCell = active !== undefined ? layout.cells.find((c) => c.id === active) : undefined;\n if (activeCell) shown.add(activeCell.index);\n entries = [...shown].sort((a, b) => a - b).map(makeEntry);\n }\n // List positions, as screen readers can't count tiles that aren't there.\n let positions: Map<number, number> | undefined;\n if (virtual) {\n positions = new Map();\n for (const c of layout.cells) if (hasContent(c.index)) positions.set(c.index, positions.size + 1);\n }\n\n // Animation bookkeeping uses every tile's key, so tiles scrolling in and out of view\n // don't count as coming and going.\n const allKeys = anim ? new Set(layout.cells.map((_, i) => keyOf(i))) : undefined;\n for (const e of entries) if (anim && mounted.current && !lastKeys.current.has(e.key)) entering.current.add(e.key);\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !navigable || e.altKey || e.ctrlKey || e.metaKey) return;\n // Only when a tile itself has focus, not an input or button inside it.\n const entry = entries.find((x) => tiles.current.get(x.cell.id) === e.target);\n if (!entry || !focusable.has(entry.cell.id)) return;\n const action = keyAction(layout, entry.cell, e.key, (c: Cell) => focusable.has(c.id), !!onCellActivate);\n if (!action) return;\n // Arrow keys at the edge are still ours: don't scroll the page.\n e.preventDefault();\n if (\"activate\" in action) onCellActivate!(entry.cell, entry.state);\n else if (\"move\" in action) {\n setActiveId(action.move.id);\n const el = tiles.current.get(action.move.id);\n // A tile out of view isn't mounted yet: focus it once it is.\n if (el) el.focus();\n else pendingFocus.current = action.move.id;\n }\n };\n\n const rendered = entries.map(({ i, cell, content, key, empty, state }) => {\n const slot = slots[i]!;\n const bevel = frame.bevel(i);\n const tile = tileStyle(frame, cell, {\n empty,\n safeArea,\n backdrop: backdrop != null,\n clickable: !!onCellActivate && !empty,\n focus: !renderCell && slot >= 0 ? focalPoints?.[slot] : undefined,\n aspect: !renderCell && slot >= 0 ? aspects?.[slot] : undefined,\n });\n // Tiles with nothing in them are decoration: hidden from assistive technology.\n const silent = empty && isEmpty(content);\n const canFocus = focusable.has(cell.id);\n const viewBox = tileViewBox(cell);\n return (\n <div\n key={key}\n ref={(el) => {\n if (el) tiles.current.set(cell.id, el);\n else tiles.current.delete(cell.id);\n }}\n role={silent ? undefined : list ? \"listitem\" : undefined}\n aria-hidden={silent ? true : undefined}\n aria-label={silent ? undefined : resolve(cellLabel, cell, state)}\n aria-setsize={positions && list && !silent ? positions.size : undefined}\n aria-posinset={positions && list && !silent ? positions.get(i) : undefined}\n tabIndex={canFocus ? (cell.id === active ? 0 : -1) : undefined}\n onFocus={canFocus ? (e) => e.target === e.currentTarget && setActiveId(cell.id) : undefined}\n onClick={onCellActivate && !empty ? () => onCellActivate(cell, state) : undefined}\n className={resolve(cellClassName, cell, state)}\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={empty ? \"\" : undefined}\n data-boundary={cell.boundary ? \"\" : undefined}\n data-entering={entering.current.has(key) ? \"\" : undefined}\n style={{ ...css(tile), ...resolve(cellStyle, cell, state) }}\n >\n {backdrop != null && (\n // z-index -1 puts it behind the content but inside the tile: the tile's\n // clip-path makes it a stacking context.\n <div aria-hidden style={css(backdropStyle(frame, cell))}>\n {backdrop}\n </div>\n )}\n {safeArea && content != null && !isEmpty(content) ? (\n <div data-safe-area=\"\" style={css(safeBoxStyle(frame, cell, !renderCell && !empty && aspects ? (aspects[slot] ?? 1) : undefined, safeArea))}>\n {content}\n </div>\n ) : (\n content\n )}\n {bevel && bevel.length > 0 && (\n // Over the content; the tile's box is its bounding box, so map that to the viewBox.\n // When animating, the bevel is for the new shape, so it fades in as the tile arrives.\n <svg\n key={anim ? String(tile.clipPath) : undefined}\n aria-hidden\n data-bevel=\"\"\n data-late={anim ? \"\" : undefined}\n viewBox={viewBox}\n preserveAspectRatio=\"none\"\n style={css(overlayStyle)}\n >\n {bevel.map((p, k) => (\n <path key={k} d={p.d} fill={p.fill} fillOpacity={p.opacity} />\n ))}\n </svg>\n )}\n {canFocus && focusRing !== false && (\n // The tile's outline, stroked across its edge; the clip keeps the inner half.\n <svg aria-hidden data-focus-ring=\"\" viewBox={viewBox} preserveAspectRatio=\"none\" style={css(overlayStyle)}>\n {ringStrokes(frame, cell, focusRing).map((p, k) => (\n <path key={k} d={p.d} fill=\"none\" stroke={p.stroke} strokeWidth={p.width} vectorEffect=\"non-scaling-stroke\" />\n ))}\n </svg>\n )}\n </div>\n );\n });\n\n // After each commit: tiles that just went away stay a moment to fade out.\n useIsomorphicLayoutEffect(() => {\n const current = new Map<Key, ReactElement>(rendered.map((el) => [el.key!, el]));\n const present = allKeys ?? current;\n if (anim && mounted.current) {\n const gone = [...lastTiles.current].filter(([k]) => !present.has(k));\n if (gone.length) {\n setExiting((prev) => new Map([...prev, ...gone]));\n const timer = setTimeout(() => {\n timers.current.delete(timer);\n setExiting((prev) => {\n const next = new Map(prev);\n for (const [k, el] of gone) if (next.get(k) === el) next.delete(k);\n return next;\n });\n }, anim.duration);\n timers.current.add(timer);\n }\n }\n for (const k of entering.current) if (!present.has(k)) entering.current.delete(k);\n lastKeys.current = new Set(present.keys());\n lastTiles.current = current;\n mounted.current = true;\n if (pendingFocus.current) {\n const el = tiles.current.get(pendingFocus.current);\n if (el) {\n pendingFocus.current = undefined;\n el.focus();\n }\n }\n });\n\n // Virtualization: measure what's in view, again on scroll (of the page or any container)\n // and resize, at most once a frame.\n useIsomorphicLayoutEffect(() => {\n if (!virtual) return;\n const el = container.current;\n if (!el) return;\n return watchView(el, () => {\n const next = viewRect(el, layout, overscan);\n setView((v) => (sameRect(v ?? undefined, next) ? v : next));\n });\n }, [virtual, layout, overscan]);\n useEffect(() => {\n const set = timers.current;\n return () => set.forEach(clearTimeout);\n }, []);\n const leaving = anim\n ? [...exiting].filter(([k]) => !lastKeys.current.has(k) && !rendered.some((el) => el.key === k))\n : [];\n\n const sheet = tileSheet({ focusRing: !!navigable && focusRing !== false, anim });\n const shadow = shadowShape(frame, entries.map((e) => e.cell));\n return (\n <div\n data-andamento=\"\"\n ref={container}\n role={role ?? \"list\"}\n {...rest}\n onKeyDown={handleKeyDown}\n style={{ ...css(containerStyle(layout)), ...style }}\n >\n {sheet && <style>{sheet}</style>}\n {background && <div aria-hidden style={css(backgroundStyle(frame, background))} />}\n {shadow && (\n <svg aria-hidden data-andamento-shadow=\"\" viewBox={shadow.viewBox} preserveAspectRatio=\"none\" style={css(shadow.style)}>\n <filter id={`${uid}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={shadow.blur} />\n </filter>\n <path d={shadow.d} fillRule=\"evenodd\" transform={shadow.transform} fill=\"#000\" fillOpacity={shadow.opacity} filter={`url(#${uid}-shadow)`} />\n </svg>\n )}\n {rendered}\n {leaving.map(([k, el]) =>\n // Fades out through the [data-exiting] rule in the style sheet.\n cloneElement(el as ReactElement<Record<string, unknown>>, {\n key: k,\n ref: null,\n role: undefined,\n tabIndex: undefined,\n onClick: undefined,\n onFocus: undefined,\n \"aria-hidden\": true,\n \"data-entering\": undefined,\n \"data-exiting\": \"\",\n }),\n )}\n </div>\n );\n}\n\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Style that makes an <img> or <video> cover its tile, like `object-fit: cover`. */\nexport const coverStyle: CSSProperties = css(sharedCoverStyle);\n","import { useMemo, useRef } from \"react\";\nimport { createLayout, fitCount, type ContentCells, type FitOptions, type Layout, type LayoutOptions } from \"@andamento/core\";\nimport { type FitProp } from \"@andamento/dom\";\nimport { layoutResolver, optionsKey, type LayoutNeeds } from \"@andamento/dom/internal\";\n\n/**\n * Compute a layout, recomputing only when the options change.\n * Inline object literals are fine: options are compared by value (a function in them,\n * such as `sizeAt`, by identity).\n */\nexport function useTileLayout(options: LayoutOptions): Layout {\n const key = optionsKey(options);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => createLayout(options), [key]);\n}\n\n/**\n * Compute a layout whose tiles are sized to give about `count` usable cells (see\n * `fitCount` in @andamento/core). Options are compared by value; a `cells` function by\n * identity.\n */\nexport function useFitCount(options: LayoutOptions, count: number, fit: FitOptions = {}): Layout {\n const key = optionsKey(options);\n const { cells, mode } = fit;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => fitCount(options, count, { cells, mode }).layout, [key, count, cells, mode]);\n}\n\nexport type { FitProp };\n\n/**\n * Use `layout` if given, otherwise compute one from `options` (compared by value), fitted to\n * `count` items when `fit` is set.\n */\nexport function useResolvedLayout(\n component: string,\n options?: LayoutOptions,\n layout?: Layout,\n fit?: LayoutNeeds,\n): Layout {\n const resolver = useRef<ReturnType<typeof layoutResolver>>();\n resolver.current ??= layoutResolver(`<${component}>`);\n return resolver.current(options, layout, fit);\n}\n","import { useId, useMemo, type ReactNode, type SVGProps } from \"react\";\nimport { cellShape, coverRect, safeArea, type Cell, type Focus, type ContentCells, type ContentPlacement, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport { cellPath, defaultBevel, regionPath, viewPath, reliefPaths, shadowOffset, type FillSource, type ImageSource, type ReliefOptions } from \"@andamento/svg\";\nimport { cellA11y, resolveCellStyles } from \"@andamento/svg/internal\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport interface SvgCellRenderContext {\n /** `d` attribute of the cell outline. */\n path: string;\n /** Id of a <clipPath> with the cell's shape, already in the SVG. */\n clipPathId: string;\n /** Ready-made `clipPath` prop value: `url(#…)`. */\n clipPath: string;\n /** The fill/image the default renderer would have used. */\n fill: string;\n image?: string;\n /** Which item of `images` the cell shows (-1 if none or if `images` is a function). */\n slot: number;\n}\n\nexport interface SvgTileLayoutProps extends Omit<SVGProps<SVGSVGElement>, \"children\" | \"fill\" | \"stroke\" | \"strokeWidth\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n images?: ImageSource;\n repeatImages?: boolean;\n /** Which cells may hold an image from the `images` array: \"all\" (default), \"whole\" or a test. */\n contentCells?: ContentCells;\n /** Where images go when there are fewer than cells: \"reading\" (default), \"center\" or \"spread\". */\n placement?: ContentPlacement;\n /** Width / height of each image, to put images in cells of similar shape (see `matchSlots`). */\n imageAspects?: readonly number[];\n /** With `imageAspects`: \"shape\" also picks which cells get images by their shape. */\n choose?: \"placement\" | \"shape\";\n /**\n * \"cover\" (default) fills each cell's bounding box, cropped to its shape; \"contain\" shows\n * each image whole inside the cell's safe area (see `safeArea`), at its `imageAspects` shape.\n */\n imageFit?: \"cover\" | \"contain\";\n /**\n * With `imageFit: \"contain\"`, for cells an `edges: \"window\"` layout cuts: fit the image in\n * the whole tile (\"tile\", the default) or in the part that shows (\"visible\").\n */\n containWithin?: \"tile\" | \"visible\";\n /**\n * Focal point of each image (by position; fractions of its width and height, see\n * `estimateFocus`), kept in view when \"cover\" crops it (see `coverRect`). Needs each image's\n * shape, from `imageAspects` or the focus's `aspect`.\n */\n imageFocus?: readonly (Focus | undefined)[];\n /**\n * How many tiles each image in `images` spans (1 for most): heavier images get featured\n * tiles where they fall in reading order (see `weightedLayout`). Needs `options`.\n */\n imageWeights?: readonly number[];\n /**\n * Size the tiles to the `images` array (counted by `contentCells`): `true`/\"atLeast\" or\n * \"nearest\". Ignored with `layout`, `repeatImages` or an `images` function.\n */\n fit?: FitProp;\n /** Cell color under (or instead of) images. Defaults to `defaultPalette`. */\n fill?: FillSource;\n stroke?: string;\n strokeWidth?: number;\n /** Color painted across the whole region, behind the cells. */\n background?: string;\n /**\n * One image across all the cells (a URL), cropped to cover the layout and clipped to the\n * cells. The default cell rendering then skips `fill`; per-cell `images` go on top.\n */\n backdrop?: string;\n /**\n * Raised tiles: a lit bevel over each cell, and optionally a shadow cast into the grout.\n * `true` for the defaults. See `ReliefOptions`. Drawn over `renderCell` content too.\n */\n relief?: boolean | ReliefOptions;\n /** Replace the default cell rendering with SVG content. Rendered inside a <g> per cell. */\n renderCell?: (cell: Cell, ctx: SvgCellRenderContext) => ReactNode;\n /** Accessible title. */\n title?: string;\n /** Text alternative per image in `images`: those cells become labeled images; the rest decoration. */\n imageAlts?: readonly string[];\n}\n\n/**\n * Renders a tiling as a single <svg>: colored cells, optionally with images clipped\n * to each cell. Use this when you need pure SVG (export, print, embedding in other SVG);\n * use <TileLayout> to put arbitrary HTML/React content in the tiles.\n */\nexport function SvgTileLayout(props: SvgTileLayoutProps) {\n const {\n options,\n layout: given,\n images,\n repeatImages,\n contentCells,\n placement,\n imageAspects,\n choose,\n imageFit,\n containWithin,\n imageFocus,\n imageWeights,\n fit,\n fill,\n stroke,\n strokeWidth = 1,\n background,\n backdrop,\n relief: reliefProp,\n renderCell,\n title,\n imageAlts,\n ...svgProps\n } = props;\n const fitTo = Array.isArray(images) && !repeatImages ? images.length : 0;\n const layout = useResolvedLayout(\"SvgTileLayout\", options, given, {\n fit,\n count: fitTo,\n cells: contentCells,\n weights: Array.isArray(images) ? imageWeights : undefined,\n placement,\n });\n const prefix = \"andamento\" + useId().replace(/:/g, \"\");\n const styles = useMemo(\n () => resolveCellStyles(layout, { images, repeatImages, fill, contentCells, placement, imageAspects, choose }),\n [layout, images, repeatImages, fill, contentCells, placement, imageAspects, choose],\n );\n const { x, y, width, height } = layout.bounds;\n const relief = reliefProp === true ? {} : reliefProp || undefined;\n const reliefKey = relief ? JSON.stringify(relief) : \"\";\n const bevels = useMemo(() => {\n if (!relief) return undefined;\n const bevel = relief.bevel ?? defaultBevel(layout);\n return bevel > 0 ? layout.cells.map((c) => reliefPaths(layout, c, relief, bevel)) : undefined;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layout, reliefKey]);\n const cast = relief && shadowOffset(relief);\n\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={`${x} ${y} ${width} ${height}`} role={imageAlts?.length ? \"group\" : title ? \"img\" : undefined} {...svgProps}>\n {title && <title>{title}</title>}\n {background && <path className=\"andamento-region\" d={regionPath(layout)} fill={background} fillRule=\"evenodd\" />}\n {layout.view && (\n <clipPath id={`${prefix}-view`}>\n <path d={viewPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n )}\n <g className={layout.view ? \"andamento-view\" : undefined} clipPath={layout.view ? `url(#${prefix}-view)` : undefined}>\n {backdrop && (\n <>\n <clipPath id={`${prefix}-backdrop`}>\n {layout.cells.map((cell) => (\n <path key={cell.id} d={cellPath(layout, cell)} clipRule=\"evenodd\" />\n ))}\n </clipPath>\n <image\n className=\"andamento-backdrop\"\n href={backdrop}\n x={x}\n y={y}\n width={width}\n height={height}\n preserveAspectRatio=\"xMidYMid slice\"\n clipPath={`url(#${prefix}-backdrop)`}\n />\n </>\n )}\n {cast && (\n <g className=\"andamento-shadow\" clipPath={`url(#${prefix}-region)`}>\n <clipPath id={`${prefix}-region`}>\n <path d={regionPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n <filter id={`${prefix}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={cast.blur} />\n </filter>\n <path\n d={layout.cells.map((c) => cellPath(layout, c)).join(\"\")}\n fillRule=\"evenodd\"\n transform={`translate(${cast.dx} ${cast.dy})`}\n fill=\"#000\"\n fillOpacity={cast.opacity}\n filter={`url(#${prefix}-shadow)`}\n />\n </g>\n )}\n {layout.cells.map((cell, i) => {\n const d = cellPath(layout, cell);\n const clipPathId = `${prefix}-clip-${cell.index}`;\n const style = styles[i]!;\n const ctx: SvgCellRenderContext = { path: d, clipPathId, clipPath: `url(#${clipPathId})`, ...style };\n return (\n <g\n key={cell.id}\n className=\"andamento-cell\"\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={style.image ? undefined : \"\"}\n data-boundary={cell.boundary ? \"\" : undefined}\n {...cellA11y(style, imageAlts)}\n >\n <clipPath id={clipPathId}>\n <path d={d} clipRule=\"evenodd\" />\n </clipPath>\n {renderCell ? renderCell(cell, ctx) : <DefaultCell\n cell={cell}\n ctx={ctx}\n noFill={!!backdrop}\n box={\n imageFit === \"contain\" && style.image\n ? safeArea(cell, layout, { aspect: imageAspects && style.slot >= 0 ? imageAspects[style.slot] : undefined, within: containWithin })\n : undefined\n }\n cover={(() => {\n const focus = imageFit !== \"contain\" && style.image && style.slot >= 0 ? imageFocus?.[style.slot] : undefined;\n const aspect = focus ? (imageAspects?.[style.slot] ?? focus.aspect) : undefined;\n return focus && aspect ? coverRect(cell, layout, { aspect, focus }) : undefined;\n })()}\n />}\n {bevels?.[i]!.map((p, k) => <path key={k} className=\"andamento-bevel\" d={p.d} fill={p.fill} fillOpacity={p.opacity} />)}\n {stroke && <path d={d} fill=\"none\" stroke={stroke} strokeWidth={strokeWidth} />}\n </g>\n );\n })}\n </g>\n </svg>\n );\n}\n\nfunction DefaultCell({ cell, ctx, noFill, box, cover }: { cell: Cell; ctx: SvgCellRenderContext; noFill: boolean; box?: Rect; cover?: Rect }) {\n return (\n <>\n {!noFill && <path d={ctx.path} fill={ctx.fill} fillRule=\"evenodd\" />}\n {ctx.image && <SvgCellImage cell={cell} href={ctx.image} clipPath={ctx.clipPath} box={box} cover={cover} />}\n </>\n );\n}\n\nexport interface SvgCellImageProps extends Omit<SVGProps<SVGImageElement>, \"href\" | \"x\" | \"y\" | \"width\" | \"height\"> {\n cell: Cell;\n href: string;\n /** Pass `ctx.clipPath` from `renderCell`. */\n clipPath: string;\n /**\n * Draw the image whole inside this box (e.g. `safeArea(cell, layout)`) instead of\n * covering the cell.\n */\n box?: Rect;\n /** Cover this rectangle instead of the cell's box (e.g. `coverRect(cell, layout, { aspect, focus })`). */\n cover?: Rect;\n}\n\n/**\n * An SVG <image> that covers the cell (like CSS `object-fit: cover`), clipped to its shape;\n * or, with `box`, shown whole inside the box (like `object-fit: contain`).\n */\nexport function SvgCellImage({ cell, href, clipPath, box, cover, ...rest }: SvgCellImageProps) {\n const b = box ?? cover ?? cellShape(cell).bbox;\n return (\n <image\n href={href}\n x={b.x}\n y={b.y}\n width={b.width}\n height={b.height}\n preserveAspectRatio={box ? \"xMidYMid meet\" : \"xMidYMid slice\"}\n clipPath={clipPath}\n {...rest}\n />\n );\n}\n","import { useEffect, useMemo, useState } from \"react\";\nimport { imageFill, loadImagePixels, type CellFill, type ImageFillOptions, type Pixels } from \"@andamento/core\";\n\n/**\n * Load an image and color tiles from it (see `imageFill`): returns a fill to pass as\n * `fill`, or `undefined` while the image loads (or if it fails), so the default fill shows\n * meanwhile. `maxSize` caps the size the image is read at (default 256 px on the long side).\n */\nexport function useImageFill(src: string | undefined, options: ImageFillOptions & { maxSize?: number } = {}): CellFill | undefined {\n const { fit, palette, fallback, samples, maxSize = 256 } = options;\n const [pixels, setPixels] = useState<{ src: string; pixels: Pixels }>();\n useEffect(() => {\n if (!src) return;\n let live = true;\n loadImagePixels(src, maxSize).then(\n (p) => live && setPixels({ src, pixels: p }),\n (e) => console.warn(`useImageFill: ${(e as Error).message}`),\n );\n return () => {\n live = false;\n };\n }, [src, maxSize]);\n const paletteKey = palette?.join(\",\");\n return useMemo(\n () => (pixels && pixels.src === src ? imageFill(pixels.pixels, { fit, palette, fallback, samples }) : undefined),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [pixels, src, fit, paletteKey, fallback, samples],\n );\n}\n","import { useEffect, useState } from \"react\";\n\n/**\n * Measure images' aspect ratios (width / height) by loading them, for the `aspects` and\n * `imageAspects` props. Returns `undefined` until every image has loaded or failed (failed\n * ones count as square), so content isn't reshuffled image by image as they arrive.\n */\nexport function useImageAspects(srcs: readonly string[] | undefined): number[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; aspects: number[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof Image === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map(\n (src) =>\n new Promise<number>((resolve) => {\n const img = new Image();\n img.onload = () => resolve(img.naturalWidth && img.naturalHeight ? img.naturalWidth / img.naturalHeight : 1);\n img.onerror = () => resolve(1);\n img.src = src;\n }),\n ),\n ).then((aspects) => live && setResult({ key, aspects }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.aspects : undefined;\n}\n","import { useEffect, useState } from \"react\";\nimport { estimateFocus, loadImagePixels, type Focus } from \"@andamento/core\";\n\n/**\n * Guess each image's focal point (see `estimateFocus`) by loading it, for the `focus` and\n * `imageFocus` props. Returns `undefined` until every image has been looked at; images that\n * fail to load (or that the browser won't let a canvas read) get the middle.\n */\nexport function useImageFocus(srcs: readonly string[] | undefined): Focus[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; focus: Focus[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof document === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map((src) =>\n loadImagePixels(src, 128)\n .then(estimateFocus)\n .catch(() => ({ x: 0.5, y: 0.5 })),\n ),\n ).then((focus) => live && setResult({ key, focus }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.focus : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAeO;AACP,IAAAC,eAAyI;AACzI,iBAKO;AACP,IAAAC,mBAiBO;;;ACxCP,mBAAgC;AAChC,kBAA4G;AAE5G,sBAA6D;AAOtD,SAAS,cAAc,SAAgC;AAC5D,QAAM,UAAM,4BAAW,OAAO;AAE9B,aAAO,sBAAQ,UAAM,0BAAa,OAAO,GAAG,CAAC,GAAG,CAAC;AACnD;AAOO,SAAS,YAAY,SAAwB,OAAe,MAAkB,CAAC,GAAW;AAC/F,QAAM,UAAM,4BAAW,OAAO;AAC9B,QAAM,EAAE,OAAO,KAAK,IAAI;AAExB,aAAO,sBAAQ,UAAM,sBAAS,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,OAAO,OAAO,IAAI,CAAC;AAClG;AAQO,SAAS,kBACd,WACA,SACA,QACA,KACQ;AACR,QAAM,eAAW,qBAA0C;AAC3D,WAAS,YAAT,SAAS,cAAY,gCAAe,IAAI,SAAS,GAAG;AACp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AQ;AAAA,MACN,KAAK;AAAA,QACH,CAAC,QACC,IAAI,QAAgB,CAACC,aAAY;AAC/B,gBAAM,MAAM,IAAI,MAAM;AACtB,cAAI,SAAS,MAAMA,SAAQ,IAAI,gBAAgB,IAAI,gBAAgB,IAAI,eAAe,IAAI,gBAAgB,CAAC;AAC3G,cAAI,UAAU,MAAMA,SAAQ,CAAC;AAC7B,cAAI,MAAM;AAAA,QACZ,CAAC;AAAA,MACL;AAAA,IACF,EAAE,KAAK,CAAC,YAAY,QAAQ,UAAU,EAAE,KAAK,QAAQ,CAAC,CAAC;AACvD,WAAO,MAAM;AACX,aAAO;AAAA,IACT;AAAA,EAEF,GAAG,CAAC,GAAG,CAAC;AACR,SAAO,UAAU,OAAO,QAAQ,MAAM,OAAO,UAAU;AACzD;;;AC9BA,IAAAC,gBAAoC;AACpC,IAAAC,eAA2D;AAOpD,SAAS,cAAc,MAA0D;AACtF,QAAM,MAAM,MAAM,KAAK,IAAI;AAC3B,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAA0C;AACtE,+BAAU,MAAM;AACd,QAAI,CAAC,QAAQ,QAAQ,UAAa,OAAO,aAAa,YAAa;AACnE,QAAI,OAAO;AACX,YAAQ;AAAA,MACN,KAAK;AAAA,QAAI,CAAC,YACR,8BAAgB,KAAK,GAAG,EACrB,KAAK,0BAAa,EAClB,MAAM,OAAO,EAAE,GAAG,KAAK,GAAG,IAAI,EAAE;AAAA,MACrC;AAAA,IACF,EAAE,KAAK,CAAC,UAAU,QAAQ,UAAU,EAAE,KAAK,MAAM,CAAC,CAAC;AACnD,WAAO,MAAM;AACX,aAAO;AAAA,IACT;AAAA,EAEF,GAAG,CAAC,GAAG,CAAC;AACR,SAAO,UAAU,OAAO,QAAQ,MAAM,OAAO,QAAQ;AACvD;;;ANdA,IAAAC,cAAgC;AAIhC,IAAAC,cAA+C;","names":["import_react","import_core","import_internal","safeArea","resolve","sharedCoverStyle","import_react","import_core","import_internal","import_jsx_runtime","import_react","import_core","import_react","resolve","import_react","import_core","import_dom","import_svg"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -8,8 +8,9 @@ import { FillSource, ReliefOptions, ImageSource } from '@andamento/svg';
|
|
|
8
8
|
export { FillSource, ReliefOptions, defaultPalette, neutralPalette } from '@andamento/svg';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Compute a layout, recomputing only when the
|
|
12
|
-
* Inline object literals are fine: options are compared by value
|
|
11
|
+
* Compute a layout, recomputing only when the options change.
|
|
12
|
+
* Inline object literals are fine: options are compared by value (a function in them,
|
|
13
|
+
* such as `sizeAt`, by identity).
|
|
13
14
|
*/
|
|
14
15
|
declare function useTileLayout(options: LayoutOptions): Layout;
|
|
15
16
|
/**
|
|
@@ -107,7 +108,7 @@ interface TileLayoutProps extends Omit<HTMLAttributes<HTMLDivElement>, "children
|
|
|
107
108
|
relief?: boolean | ReliefOptions;
|
|
108
109
|
/**
|
|
109
110
|
* Keyboard navigation: tiles with content become focusable as one tab stop (roving
|
|
110
|
-
* tabindex). Arrow keys move to
|
|
111
|
+
* tabindex). Arrow keys move to a touching tile in that direction, whatever the tiling;
|
|
111
112
|
* Home and End go to the first and last. The focused tile shows `focusRing`.
|
|
112
113
|
*/
|
|
113
114
|
navigable?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ import { FillSource, ReliefOptions, ImageSource } from '@andamento/svg';
|
|
|
8
8
|
export { FillSource, ReliefOptions, defaultPalette, neutralPalette } from '@andamento/svg';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Compute a layout, recomputing only when the
|
|
12
|
-
* Inline object literals are fine: options are compared by value
|
|
11
|
+
* Compute a layout, recomputing only when the options change.
|
|
12
|
+
* Inline object literals are fine: options are compared by value (a function in them,
|
|
13
|
+
* such as `sizeAt`, by identity).
|
|
13
14
|
*/
|
|
14
15
|
declare function useTileLayout(options: LayoutOptions): Layout;
|
|
15
16
|
/**
|
|
@@ -107,7 +108,7 @@ interface TileLayoutProps extends Omit<HTMLAttributes<HTMLDivElement>, "children
|
|
|
107
108
|
relief?: boolean | ReliefOptions;
|
|
108
109
|
/**
|
|
109
110
|
* Keyboard navigation: tiles with content become focusable as one tab stop (roving
|
|
110
|
-
* tabindex). Arrow keys move to
|
|
111
|
+
* tabindex). Arrow keys move to a touching tile in that direction, whatever the tiling;
|
|
111
112
|
* Home and End go to the first and last. The focused tile shows `focusRing`.
|
|
112
113
|
*/
|
|
113
114
|
navigable?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -10,11 +10,13 @@ import {
|
|
|
10
10
|
useState
|
|
11
11
|
} from "react";
|
|
12
12
|
import { cellsInRect } from "@andamento/core";
|
|
13
|
+
import {
|
|
14
|
+
coverStyle as sharedCoverStyle
|
|
15
|
+
} from "@andamento/dom";
|
|
13
16
|
import {
|
|
14
17
|
backdropStyle,
|
|
15
18
|
backgroundStyle,
|
|
16
19
|
containerStyle,
|
|
17
|
-
coverStyle as sharedCoverStyle,
|
|
18
20
|
frameBuilder,
|
|
19
21
|
keyAction,
|
|
20
22
|
overlayStyle,
|
|
@@ -28,18 +30,18 @@ import {
|
|
|
28
30
|
tileViewBox,
|
|
29
31
|
viewRect,
|
|
30
32
|
watchView
|
|
31
|
-
} from "@andamento/dom";
|
|
33
|
+
} from "@andamento/dom/internal";
|
|
32
34
|
|
|
33
35
|
// src/useTileLayout.ts
|
|
34
36
|
import { useMemo, useRef } from "react";
|
|
35
37
|
import { createLayout, fitCount } from "@andamento/core";
|
|
36
|
-
import { layoutResolver } from "@andamento/dom";
|
|
38
|
+
import { layoutResolver, optionsKey } from "@andamento/dom/internal";
|
|
37
39
|
function useTileLayout(options) {
|
|
38
|
-
const key =
|
|
40
|
+
const key = optionsKey(options);
|
|
39
41
|
return useMemo(() => createLayout(options), [key]);
|
|
40
42
|
}
|
|
41
43
|
function useFitCount(options, count, fit = {}) {
|
|
42
|
-
const key =
|
|
44
|
+
const key = optionsKey(options);
|
|
43
45
|
const { cells, mode } = fit;
|
|
44
46
|
return useMemo(() => fitCount(options, count, { cells, mode }).layout, [key, count, cells, mode]);
|
|
45
47
|
}
|
|
@@ -329,7 +331,8 @@ var coverStyle = css(sharedCoverStyle);
|
|
|
329
331
|
// src/SvgTileLayout.tsx
|
|
330
332
|
import { useId as useId2, useMemo as useMemo2 } from "react";
|
|
331
333
|
import { cellShape, coverRect, safeArea } from "@andamento/core";
|
|
332
|
-
import {
|
|
334
|
+
import { cellPath, defaultBevel, regionPath, viewPath, reliefPaths, shadowOffset } from "@andamento/svg";
|
|
335
|
+
import { cellA11y, resolveCellStyles } from "@andamento/svg/internal";
|
|
333
336
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
334
337
|
function SvgTileLayout(props) {
|
|
335
338
|
const {
|
|
@@ -439,8 +442,8 @@ function SvgTileLayout(props) {
|
|
|
439
442
|
noFill: !!backdrop,
|
|
440
443
|
box: imageFit === "contain" && style.image ? safeArea(cell, layout, { aspect: imageAspects && style.slot >= 0 ? imageAspects[style.slot] : void 0, within: containWithin }) : void 0,
|
|
441
444
|
cover: (() => {
|
|
442
|
-
const focus = imageFit !== "contain" && style.image && style.slot >= 0 ?
|
|
443
|
-
const aspect = focus ? imageAspects?.[style.slot
|
|
445
|
+
const focus = imageFit !== "contain" && style.image && style.slot >= 0 ? imageFocus?.[style.slot] : void 0;
|
|
446
|
+
const aspect = focus ? imageAspects?.[style.slot] ?? focus.aspect : void 0;
|
|
444
447
|
return focus && aspect ? coverRect(cell, layout, { aspect, focus }) : void 0;
|
|
445
448
|
})()
|
|
446
449
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TileLayout.tsx","../src/useTileLayout.ts","../src/SvgTileLayout.tsx","../src/useImageFill.ts","../src/useImageAspects.ts","../src/useImageFocus.ts","../src/index.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type KeyboardEvent,\n type CSSProperties,\n type HTMLAttributes,\n type Key,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { cellsInRect, type Cell, type ContentCells, type ContentPlacement, type Focus, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport {\n backdropStyle,\n backgroundStyle,\n containerStyle,\n coverStyle as sharedCoverStyle,\n frameBuilder,\n keyAction,\n overlayStyle,\n resolvePerCell as resolve,\n ringStrokes,\n safeBoxStyle,\n sameRect,\n shadowShape,\n tileSheet,\n tileStyle,\n tileViewBox,\n viewRect,\n watchView,\n type CellState,\n type SafeAreaProp,\n type PerCell,\n} from \"@andamento/dom\";\nimport type { FillSource, ReliefOptions } from \"@andamento/svg\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport type { CellState };\n\nconst isEmpty = (n: ReactNode) => n == null || n === false || n === true || n === \"\";\nconst css = (s: object) => s as CSSProperties;\n\nexport interface TileLayoutProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n /**\n * Any React content. Each top-level child fills one tile, in reading order\n * (top-to-bottom, left-to-right), and is clipped to the tile's shape.\n * Extra children beyond the number of tiles are not rendered.\n */\n children?: ReactNode;\n /**\n * Alternative to `children`: compute each tile's content from its cell. Takes precedence.\n * `slot` numbers the cells allowed by `contentCells` in reading order (-1 for the rest).\n */\n renderCell?: (cell: Cell, state: { slot: number }) => ReactNode;\n /**\n * Which tiles may hold children: \"all\" (default), \"whole\" (only tiles not cut by the\n * region outline), or a test per cell. The others are left empty.\n */\n contentCells?: ContentCells;\n /**\n * Where children go when there are fewer than tiles: \"reading\" (default; the first\n * tiles in reading order), \"center\" (the middle of the region) or \"spread\" (evenly\n * over it). Children always run in reading order across the tiles chosen.\n */\n placement?: ContentPlacement;\n /**\n * Width / height of each child, in order. When given, each child goes in a tile of\n * similar shape, so `object-fit: cover` crops as little as possible (landscape photos in\n * wide tiles, portraits in tall ones); see `matchSlots`. Featured tiles still take the\n * first children. Missing entries count as square. Ignored with `renderCell`.\n */\n aspects?: readonly number[];\n /**\n * Keep content out of the tiles' clipped corners: each tile's content goes in a box at\n * the tile's safe area (see `safeArea`), the largest rectangle that fits inside its shape,\n * instead of filling the tile's bounding box. Useful for text in triangles or hexagons.\n * With `aspects`, each child's box has the child's shape, so it shows whole and uncropped.\n * The box has `data-safe-area`; style its contents to fill it. Tiles show `fill` around\n * their content. For tiles an `edges: \"window\"` layout cuts, `true` or \"tile\" fits the\n * whole tile (content near the edge is partly hidden, like the tile) and \"visible\" the\n * part that shows.\n */\n safeArea?: SafeAreaProp;\n /** With `aspects`: \"shape\" also picks which tiles hold children by their shape, ignoring `placement`. */\n choose?: \"placement\" | \"shape\";\n /**\n * Focal point of each child (fractions of its width and height; see `estimateFocus`): what\n * a photo keeps in view as its tile crops it. Each tile sets `--andamento-object-position`,\n * which `coverStyle` uses as `object-position`; exact when the photo's shape is known (`aspects`, or the focus's `aspect`).\n */\n focalPoints?: readonly (Focus | undefined)[];\n /**\n * How many tiles each child spans (1 for an ordinary child; rounded): heavier childs get a\n * featured tile of that many merged tiles, where they fall in reading order (see\n * `weightedLayout`). With `fit`, the tiles are sized to fit everything. Needs `options`.\n */\n weights?: readonly number[];\n /**\n * Color of empty tiles: a color, a palette (neighboring tiles get different entries),\n * or a function per cell. Defaults to `neutralPalette`; use \"transparent\" for none.\n */\n fill?: FillSource;\n /**\n * Size the tiles to the children: scales the pattern so there are about as many tiles\n * (counted by `contentCells`) as children. `true`/\"atLeast\" makes sure every child gets\n * a tile; \"nearest\" gets as close as possible. Ignored with `layout` or `renderCell`.\n */\n fit?: FitProp;\n /**\n * One picture across all the tiles: rendered in every tile, sized and positioned to the\n * whole layout, so each tile shows its own piece. Use an element that fills its box,\n * e.g. `<img src=… style={coverStyle} />`. It sits behind the tile's content, and empty\n * tiles show it instead of `fill`. (Each tile gets its own copy, so a video would play\n * out of sync; images are loaded once.)\n */\n backdrop?: ReactNode;\n /**\n * Raised tiles: a bevel round each tile, lit from one side and drawn over its content,\n * and optionally a soft shadow each tile casts into the grout (set `shadow`). `true` for\n * the defaults. With `gap` as the grout width and `background` as its color or texture,\n * it looks like a tiled surface. See `ReliefOptions`.\n */\n relief?: boolean | ReliefOptions;\n /**\n * Keyboard navigation: tiles with content become focusable as one tab stop (roving\n * tabindex). Arrow keys move to the nearest tile in that direction, whatever the tiling;\n * Home and End go to the first and last. The focused tile shows `focusRing`.\n */\n navigable?: boolean;\n /**\n * Called when a tile with content is activated: clicked, or Enter or Space while it has\n * focus (with `navigable`).\n */\n onCellActivate?: (cell: Cell, state: CellState) => void;\n /** Accessible name for each tile (its `aria-label`), e.g. a photo's description. */\n cellLabel?: PerCell<string | undefined>;\n /**\n * Color of the focus outline drawn inside the focused tile's shape (a CSS outline would be\n * clipped away), with a white inner line so it shows on any content. `false` for none,\n * if you style `[data-cell-id]:focus-visible` yourself. Defaults to \"#1a56db\".\n */\n focusRing?: string | false;\n /**\n * Animate changes: when the layout changes (a resize, another tiling, a new gap) or the\n * children do, tiles glide and morph into their new places and shapes, a child keeping\n * its tile as it moves; new tiles fade in and removed ones fade out. Pure CSS\n * transitions, skipped when the user prefers reduced motion. `true` for 400 ms, or\n * `{ duration, easing }`.\n */\n animate?: boolean | { duration?: number; easing?: string };\n /**\n * Mount only the tiles in view (plus `overscan` pixels round it, default 300), for\n * layouts with thousands of tiles. Tiles mount and unmount as the page or any scrolling\n * container scrolls, or the layout resizes. Keyboard navigation still reaches every\n * tile (the focused one stays mounted and is scrolled to), and list items carry\n * `aria-setsize` and `aria-posinset`. With `renderCell`, every cell `contentCells`\n * allows counts as having content. On the server no tiles are rendered.\n */\n virtualize?: boolean | { overscan?: number };\n /** Content for empty tiles. */\n fallback?: PerCell<ReactNode>;\n /** Class name for each tile wrapper (fixed or per cell). */\n cellClassName?: PerCell<string>;\n /** Extra style for each tile wrapper (fixed or per cell), e.g. a background color. */\n cellStyle?: PerCell<CSSProperties>;\n /** Color painted across the whole region, visible through the gaps. */\n background?: string;\n}\n\n/**\n * Renders a tiling as HTML: one absolutely positioned, `clip-path`-ed element per tile,\n * holding whatever you put in it (images, video, text, components). Everything is sized\n * in percentages, so the layout scales with the container's width.\n *\n * Each tile wrapper has `data-cell-id` and `data-index`, plus `data-empty` (no content)\n * and `data-boundary` (cut by the region outline) for styling.\n *\n * Clipping also applies to pointer events, so hover and clicks follow the tile shapes.\n */\nexport function TileLayout(props: TileLayoutProps) {\n const {\n options,\n layout: given,\n children,\n renderCell,\n contentCells,\n placement,\n aspects,\n choose,\n focalPoints,\n weights,\n safeArea,\n fill,\n fit,\n backdrop,\n relief,\n navigable,\n onCellActivate,\n cellLabel,\n focusRing = \"#1a56db\",\n animate,\n virtualize,\n fallback,\n cellClassName,\n cellStyle,\n background,\n style,\n role,\n onKeyDown,\n ...rest\n } = props;\n const uid = \"andamento\" + useId().replace(/:/g, \"\");\n const items = renderCell ? [] : Children.toArray(children);\n const layout = useResolvedLayout(\"TileLayout\", options, given, {\n fit: !renderCell && fit,\n count: items.length,\n cells: contentCells,\n weights: renderCell ? undefined : weights,\n placement,\n });\n const { bounds } = layout;\n // Slots, fills and bevels, reused from the last render where nothing they depend on changed.\n const buildFrame = useRef<ReturnType<typeof frameBuilder>>();\n buildFrame.current ??= frameBuilder();\n const frame = buildFrame.current(layout, {\n count: renderCell ? Infinity : items.length,\n aspects: renderCell ? undefined : aspects,\n contentCells,\n placement,\n choose,\n fill,\n relief,\n animate,\n });\n const { slots, anim } = frame;\n\n // Key by child where possible, so a child keeps its state (video position, inputs,\n // animations) when the layout changes underneath it.\n const keyOf = (i: number): Key => {\n const slot = slots[i]!;\n if (!renderCell && slot >= 0) {\n const child = items[slot];\n return isValidElement(child) && child.key != null ? `child:${child.key}` : `child:${slot}`;\n }\n return `cell:${layout.cells[i]!.id}`;\n };\n // What a tile holds.\n const makeEntry = (i: number) => {\n const cell = layout.cells[i]!;\n const slot = slots[i]!;\n let content: ReactNode = null;\n if (renderCell) content = renderCell(cell, { slot });\n else if (slot >= 0) content = items[slot];\n const empty = isEmpty(content);\n const state: CellState = { empty, slot: empty && !renderCell ? -1 : slot };\n if (empty) content = resolve(fallback, cell, state);\n return { i, cell, content, key: keyOf(i), empty, state };\n };\n\n // Virtualization: the part of the layout in view, in layout units (null until measured).\n const virtual = !!virtualize;\n const overscan = Math.max(0, (typeof virtualize === \"object\" ? virtualize.overscan : undefined) ?? 300);\n const container = useRef<HTMLDivElement>(null);\n const [view, setView] = useState<Rect | null>(null);\n // Without virtualization, every tile's entry is worked out before rendering, so navigation\n // knows which have content. With it, only the tiles in view are; whether others have\n // content is judged without rendering them.\n const allEntries = virtual ? undefined : layout.cells.map((_, i) => makeEntry(i));\n const hasContent = (i: number) =>\n allEntries ? !allEntries[i]!.empty : renderCell ? slots[i]! >= 0 : slots[i]! >= 0 && !isEmpty(items[slots[i]!]);\n\n // Animation: enter / exit animations for tiles that come and go (the tiles' own\n // transitions are in their style).\n const mounted = useRef(false);\n const lastKeys = useRef(new Set<Key>());\n const entering = useRef(new Set<Key>());\n const lastTiles = useRef(new Map<Key, ReactElement>());\n const [exiting, setExiting] = useState(() => new Map<Key, ReactElement>());\n const timers = useRef(new Set<ReturnType<typeof setTimeout>>());\n\n // Roving tabindex: one tile is the tab stop; arrow keys move it.\n const focusable = new Set(navigable ? layout.cells.filter((c) => hasContent(c.index)).map((c) => c.id) : []);\n const [activeId, setActiveId] = useState<string>();\n const firstFocusable = layout.cells.find((c) => focusable.has(c.id))?.id;\n const active = activeId !== undefined && focusable.has(activeId) ? activeId : firstFocusable;\n const tiles = useRef(new Map<string, HTMLDivElement>());\n const pendingFocus = useRef<string>();\n const list = (role ?? \"list\") === \"list\";\n\n // The tiles to render: all of them, or those in view plus the tab stop (so Tab finds it).\n let entries: ReturnType<typeof makeEntry>[];\n if (allEntries) entries = allEntries;\n else {\n const shown = new Set(view && view.width >= 0 ? cellsInRect(layout, view).map((c) => c.index) : []);\n const activeCell = active !== undefined ? layout.cells.find((c) => c.id === active) : undefined;\n if (activeCell) shown.add(activeCell.index);\n entries = [...shown].sort((a, b) => a - b).map(makeEntry);\n }\n // List positions, as screen readers can't count tiles that aren't there.\n let positions: Map<number, number> | undefined;\n if (virtual) {\n positions = new Map();\n for (const c of layout.cells) if (hasContent(c.index)) positions.set(c.index, positions.size + 1);\n }\n\n // Animation bookkeeping uses every tile's key, so tiles scrolling in and out of view\n // don't count as coming and going.\n const allKeys = anim ? new Set(layout.cells.map((_, i) => keyOf(i))) : undefined;\n for (const e of entries) if (anim && mounted.current && !lastKeys.current.has(e.key)) entering.current.add(e.key);\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !navigable || e.altKey || e.ctrlKey || e.metaKey) return;\n // Only when a tile itself has focus, not an input or button inside it.\n const entry = entries.find((x) => tiles.current.get(x.cell.id) === e.target);\n if (!entry || !focusable.has(entry.cell.id)) return;\n const action = keyAction(layout, entry.cell, e.key, (c: Cell) => focusable.has(c.id), !!onCellActivate);\n if (!action) return;\n // Arrow keys at the edge are still ours: don't scroll the page.\n e.preventDefault();\n if (\"activate\" in action) onCellActivate!(entry.cell, entry.state);\n else if (\"move\" in action) {\n setActiveId(action.move.id);\n const el = tiles.current.get(action.move.id);\n // A tile out of view isn't mounted yet: focus it once it is.\n if (el) el.focus();\n else pendingFocus.current = action.move.id;\n }\n };\n\n const rendered = entries.map(({ i, cell, content, key, empty, state }) => {\n const slot = slots[i]!;\n const bevel = frame.bevel(i);\n const tile = tileStyle(frame, cell, {\n empty,\n safeArea,\n backdrop: backdrop != null,\n clickable: !!onCellActivate && !empty,\n focus: !renderCell && slot >= 0 ? focalPoints?.[slot] : undefined,\n aspect: !renderCell && slot >= 0 ? aspects?.[slot] : undefined,\n });\n // Tiles with nothing in them are decoration: hidden from assistive technology.\n const silent = empty && isEmpty(content);\n const canFocus = focusable.has(cell.id);\n const viewBox = tileViewBox(cell);\n return (\n <div\n key={key}\n ref={(el) => {\n if (el) tiles.current.set(cell.id, el);\n else tiles.current.delete(cell.id);\n }}\n role={silent ? undefined : list ? \"listitem\" : undefined}\n aria-hidden={silent ? true : undefined}\n aria-label={silent ? undefined : resolve(cellLabel, cell, state)}\n aria-setsize={positions && list && !silent ? positions.size : undefined}\n aria-posinset={positions && list && !silent ? positions.get(i) : undefined}\n tabIndex={canFocus ? (cell.id === active ? 0 : -1) : undefined}\n onFocus={canFocus ? (e) => e.target === e.currentTarget && setActiveId(cell.id) : undefined}\n onClick={onCellActivate && !empty ? () => onCellActivate(cell, state) : undefined}\n className={resolve(cellClassName, cell, state)}\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={empty ? \"\" : undefined}\n data-boundary={cell.boundary ? \"\" : undefined}\n data-entering={entering.current.has(key) ? \"\" : undefined}\n style={{ ...css(tile), ...resolve(cellStyle, cell, state) }}\n >\n {backdrop != null && (\n // z-index -1 puts it behind the content but inside the tile: the tile's\n // clip-path makes it a stacking context.\n <div aria-hidden style={css(backdropStyle(frame, cell))}>\n {backdrop}\n </div>\n )}\n {safeArea && content != null && !isEmpty(content) ? (\n <div data-safe-area=\"\" style={css(safeBoxStyle(frame, cell, !renderCell && !empty && aspects ? (aspects[slot] ?? 1) : undefined, safeArea))}>\n {content}\n </div>\n ) : (\n content\n )}\n {bevel && bevel.length > 0 && (\n // Over the content; the tile's box is its bounding box, so map that to the viewBox.\n // When animating, the bevel is for the new shape, so it fades in as the tile arrives.\n <svg\n key={anim ? String(tile.clipPath) : undefined}\n aria-hidden\n data-bevel=\"\"\n data-late={anim ? \"\" : undefined}\n viewBox={viewBox}\n preserveAspectRatio=\"none\"\n style={css(overlayStyle)}\n >\n {bevel.map((p, k) => (\n <path key={k} d={p.d} fill={p.fill} fillOpacity={p.opacity} />\n ))}\n </svg>\n )}\n {canFocus && focusRing !== false && (\n // The tile's outline, stroked across its edge; the clip keeps the inner half.\n <svg aria-hidden data-focus-ring=\"\" viewBox={viewBox} preserveAspectRatio=\"none\" style={css(overlayStyle)}>\n {ringStrokes(frame, cell, focusRing).map((p, k) => (\n <path key={k} d={p.d} fill=\"none\" stroke={p.stroke} strokeWidth={p.width} vectorEffect=\"non-scaling-stroke\" />\n ))}\n </svg>\n )}\n </div>\n );\n });\n\n // After each commit: tiles that just went away stay a moment to fade out.\n useIsomorphicLayoutEffect(() => {\n const current = new Map<Key, ReactElement>(rendered.map((el) => [el.key!, el]));\n const present = allKeys ?? current;\n if (anim && mounted.current) {\n const gone = [...lastTiles.current].filter(([k]) => !present.has(k));\n if (gone.length) {\n setExiting((prev) => new Map([...prev, ...gone]));\n const timer = setTimeout(() => {\n timers.current.delete(timer);\n setExiting((prev) => {\n const next = new Map(prev);\n for (const [k, el] of gone) if (next.get(k) === el) next.delete(k);\n return next;\n });\n }, anim.duration);\n timers.current.add(timer);\n }\n }\n for (const k of entering.current) if (!present.has(k)) entering.current.delete(k);\n lastKeys.current = new Set(present.keys());\n lastTiles.current = current;\n mounted.current = true;\n if (pendingFocus.current) {\n const el = tiles.current.get(pendingFocus.current);\n if (el) {\n pendingFocus.current = undefined;\n el.focus();\n }\n }\n });\n\n // Virtualization: measure what's in view, again on scroll (of the page or any container)\n // and resize, at most once a frame.\n useIsomorphicLayoutEffect(() => {\n if (!virtual) return;\n const el = container.current;\n if (!el) return;\n return watchView(el, () => {\n const next = viewRect(el, layout, overscan);\n setView((v) => (sameRect(v ?? undefined, next) ? v : next));\n });\n }, [virtual, layout, overscan]);\n useEffect(() => {\n const set = timers.current;\n return () => set.forEach(clearTimeout);\n }, []);\n const leaving = anim\n ? [...exiting].filter(([k]) => !lastKeys.current.has(k) && !rendered.some((el) => el.key === k))\n : [];\n\n const sheet = tileSheet({ focusRing: !!navigable && focusRing !== false, anim });\n const shadow = shadowShape(frame, entries.map((e) => e.cell));\n return (\n <div\n data-andamento=\"\"\n ref={container}\n role={role ?? \"list\"}\n {...rest}\n onKeyDown={handleKeyDown}\n style={{ ...css(containerStyle(layout)), ...style }}\n >\n {sheet && <style>{sheet}</style>}\n {background && <div aria-hidden style={css(backgroundStyle(frame, background))} />}\n {shadow && (\n <svg aria-hidden data-andamento-shadow=\"\" viewBox={shadow.viewBox} preserveAspectRatio=\"none\" style={css(shadow.style)}>\n <filter id={`${uid}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={shadow.blur} />\n </filter>\n <path d={shadow.d} fillRule=\"evenodd\" transform={shadow.transform} fill=\"#000\" fillOpacity={shadow.opacity} filter={`url(#${uid}-shadow)`} />\n </svg>\n )}\n {rendered}\n {leaving.map(([k, el]) =>\n // Fades out through the [data-exiting] rule in the style sheet.\n cloneElement(el as ReactElement<Record<string, unknown>>, {\n key: k,\n ref: null,\n role: undefined,\n tabIndex: undefined,\n onClick: undefined,\n onFocus: undefined,\n \"aria-hidden\": true,\n \"data-entering\": undefined,\n \"data-exiting\": \"\",\n }),\n )}\n </div>\n );\n}\n\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Style that makes an <img> or <video> cover its tile, like `object-fit: cover`. */\nexport const coverStyle: CSSProperties = css(sharedCoverStyle);\n","import { useMemo, useRef } from \"react\";\nimport { createLayout, fitCount, type ContentCells, type FitOptions, type Layout, type LayoutOptions } from \"@andamento/core\";\nimport { layoutResolver, type FitProp, type LayoutNeeds } from \"@andamento/dom\";\n\n/**\n * Compute a layout, recomputing only when the (serializable) options change.\n * Inline object literals are fine: options are compared by value.\n */\nexport function useTileLayout(options: LayoutOptions): Layout {\n const key = JSON.stringify(options);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => createLayout(options), [key]);\n}\n\n/**\n * Compute a layout whose tiles are sized to give about `count` usable cells (see\n * `fitCount` in @andamento/core). Options are compared by value; a `cells` function by\n * identity.\n */\nexport function useFitCount(options: LayoutOptions, count: number, fit: FitOptions = {}): Layout {\n const key = JSON.stringify(options);\n const { cells, mode } = fit;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => fitCount(options, count, { cells, mode }).layout, [key, count, cells, mode]);\n}\n\nexport type { FitProp };\n\n/**\n * Use `layout` if given, otherwise compute one from `options` (compared by value), fitted to\n * `count` items when `fit` is set.\n */\nexport function useResolvedLayout(\n component: string,\n options?: LayoutOptions,\n layout?: Layout,\n fit?: LayoutNeeds,\n): Layout {\n const resolver = useRef<ReturnType<typeof layoutResolver>>();\n resolver.current ??= layoutResolver(`<${component}>`);\n return resolver.current(options, layout, fit);\n}\n","import { useId, useMemo, type ReactNode, type SVGProps } from \"react\";\nimport { cellShape, coverRect, safeArea, type Cell, type Focus, type ContentCells, type ContentPlacement, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport { cellA11y, cellPath, defaultBevel, regionPath, viewPath, reliefPaths, resolveCellStyles, shadowOffset, type FillSource, type ImageSource, type ReliefOptions } from \"@andamento/svg\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport interface SvgCellRenderContext {\n /** `d` attribute of the cell outline. */\n path: string;\n /** Id of a <clipPath> with the cell's shape, already in the SVG. */\n clipPathId: string;\n /** Ready-made `clipPath` prop value: `url(#…)`. */\n clipPath: string;\n /** The fill/image the default renderer would have used. */\n fill: string;\n image?: string;\n /** Which item of `images` the cell shows (-1 if none or if `images` is a function). */\n slot: number;\n}\n\nexport interface SvgTileLayoutProps extends Omit<SVGProps<SVGSVGElement>, \"children\" | \"fill\" | \"stroke\" | \"strokeWidth\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n images?: ImageSource;\n repeatImages?: boolean;\n /** Which cells may hold an image from the `images` array: \"all\" (default), \"whole\" or a test. */\n contentCells?: ContentCells;\n /** Where images go when there are fewer than cells: \"reading\" (default), \"center\" or \"spread\". */\n placement?: ContentPlacement;\n /** Width / height of each image, to put images in cells of similar shape (see `matchSlots`). */\n imageAspects?: readonly number[];\n /** With `imageAspects`: \"shape\" also picks which cells get images by their shape. */\n choose?: \"placement\" | \"shape\";\n /**\n * \"cover\" (default) fills each cell's bounding box, cropped to its shape; \"contain\" shows\n * each image whole inside the cell's safe area (see `safeArea`), at its `imageAspects` shape.\n */\n imageFit?: \"cover\" | \"contain\";\n /**\n * With `imageFit: \"contain\"`, for cells an `edges: \"window\"` layout cuts: fit the image in\n * the whole tile (\"tile\", the default) or in the part that shows (\"visible\").\n */\n containWithin?: \"tile\" | \"visible\";\n /**\n * Focal point of each image (by position; fractions of its width and height, see\n * `estimateFocus`), kept in view when \"cover\" crops it (see `coverRect`). Needs each image's\n * shape, from `imageAspects` or the focus's `aspect`.\n */\n imageFocus?: readonly (Focus | undefined)[];\n /**\n * How many tiles each image in `images` spans (1 for most): heavier images get featured\n * tiles where they fall in reading order (see `weightedLayout`). Needs `options`.\n */\n imageWeights?: readonly number[];\n /**\n * Size the tiles to the `images` array (counted by `contentCells`): `true`/\"atLeast\" or\n * \"nearest\". Ignored with `layout`, `repeatImages` or an `images` function.\n */\n fit?: FitProp;\n /** Cell color under (or instead of) images. Defaults to `defaultPalette`. */\n fill?: FillSource;\n stroke?: string;\n strokeWidth?: number;\n /** Color painted across the whole region, behind the cells. */\n background?: string;\n /**\n * One image across all the cells (a URL), cropped to cover the layout and clipped to the\n * cells. The default cell rendering then skips `fill`; per-cell `images` go on top.\n */\n backdrop?: string;\n /**\n * Raised tiles: a lit bevel over each cell, and optionally a shadow cast into the grout.\n * `true` for the defaults. See `ReliefOptions`. Drawn over `renderCell` content too.\n */\n relief?: boolean | ReliefOptions;\n /** Replace the default cell rendering with SVG content. Rendered inside a <g> per cell. */\n renderCell?: (cell: Cell, ctx: SvgCellRenderContext) => ReactNode;\n /** Accessible title. */\n title?: string;\n /** Text alternative per image in `images`: those cells become labeled images; the rest decoration. */\n imageAlts?: readonly string[];\n}\n\n/**\n * Renders a tiling as a single <svg>: colored cells, optionally with images clipped\n * to each cell. Use this when you need pure SVG (export, print, embedding in other SVG);\n * use <TileLayout> to put arbitrary HTML/React content in the tiles.\n */\nexport function SvgTileLayout(props: SvgTileLayoutProps) {\n const {\n options,\n layout: given,\n images,\n repeatImages,\n contentCells,\n placement,\n imageAspects,\n choose,\n imageFit,\n containWithin,\n imageFocus,\n imageWeights,\n fit,\n fill,\n stroke,\n strokeWidth = 1,\n background,\n backdrop,\n relief: reliefProp,\n renderCell,\n title,\n imageAlts,\n ...svgProps\n } = props;\n const fitTo = Array.isArray(images) && !repeatImages ? images.length : 0;\n const layout = useResolvedLayout(\"SvgTileLayout\", options, given, {\n fit,\n count: fitTo,\n cells: contentCells,\n weights: Array.isArray(images) ? imageWeights : undefined,\n placement,\n });\n const prefix = \"andamento\" + useId().replace(/:/g, \"\");\n const styles = useMemo(\n () => resolveCellStyles(layout, { images, repeatImages, fill, contentCells, placement, imageAspects, choose }),\n [layout, images, repeatImages, fill, contentCells, placement, imageAspects, choose],\n );\n const { x, y, width, height } = layout.bounds;\n const relief = reliefProp === true ? {} : reliefProp || undefined;\n const reliefKey = relief ? JSON.stringify(relief) : \"\";\n const bevels = useMemo(() => {\n if (!relief) return undefined;\n const bevel = relief.bevel ?? defaultBevel(layout);\n return bevel > 0 ? layout.cells.map((c) => reliefPaths(layout, c, relief, bevel)) : undefined;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layout, reliefKey]);\n const cast = relief && shadowOffset(relief);\n\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={`${x} ${y} ${width} ${height}`} role={imageAlts?.length ? \"group\" : title ? \"img\" : undefined} {...svgProps}>\n {title && <title>{title}</title>}\n {background && <path className=\"andamento-region\" d={regionPath(layout)} fill={background} fillRule=\"evenodd\" />}\n {layout.view && (\n <clipPath id={`${prefix}-view`}>\n <path d={viewPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n )}\n <g className={layout.view ? \"andamento-view\" : undefined} clipPath={layout.view ? `url(#${prefix}-view)` : undefined}>\n {backdrop && (\n <>\n <clipPath id={`${prefix}-backdrop`}>\n {layout.cells.map((cell) => (\n <path key={cell.id} d={cellPath(layout, cell)} clipRule=\"evenodd\" />\n ))}\n </clipPath>\n <image\n className=\"andamento-backdrop\"\n href={backdrop}\n x={x}\n y={y}\n width={width}\n height={height}\n preserveAspectRatio=\"xMidYMid slice\"\n clipPath={`url(#${prefix}-backdrop)`}\n />\n </>\n )}\n {cast && (\n <g className=\"andamento-shadow\" clipPath={`url(#${prefix}-region)`}>\n <clipPath id={`${prefix}-region`}>\n <path d={regionPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n <filter id={`${prefix}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={cast.blur} />\n </filter>\n <path\n d={layout.cells.map((c) => cellPath(layout, c)).join(\"\")}\n fillRule=\"evenodd\"\n transform={`translate(${cast.dx} ${cast.dy})`}\n fill=\"#000\"\n fillOpacity={cast.opacity}\n filter={`url(#${prefix}-shadow)`}\n />\n </g>\n )}\n {layout.cells.map((cell, i) => {\n const d = cellPath(layout, cell);\n const clipPathId = `${prefix}-clip-${cell.index}`;\n const style = styles[i]!;\n const ctx: SvgCellRenderContext = { path: d, clipPathId, clipPath: `url(#${clipPathId})`, ...style };\n return (\n <g\n key={cell.id}\n className=\"andamento-cell\"\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={style.image ? undefined : \"\"}\n data-boundary={cell.boundary ? \"\" : undefined}\n {...cellA11y(style, imageAlts)}\n >\n <clipPath id={clipPathId}>\n <path d={d} clipRule=\"evenodd\" />\n </clipPath>\n {renderCell ? renderCell(cell, ctx) : <DefaultCell\n cell={cell}\n ctx={ctx}\n noFill={!!backdrop}\n box={\n imageFit === \"contain\" && style.image\n ? safeArea(cell, layout, { aspect: imageAspects && style.slot >= 0 ? imageAspects[style.slot] : undefined, within: containWithin })\n : undefined\n }\n cover={(() => {\n const focus = imageFit !== \"contain\" && style.image && style.slot >= 0 ? (Array.isArray(images) ? imageFocus?.[style.slot % images.length] : undefined) : undefined;\n const aspect = focus ? (imageAspects?.[style.slot % imageAspects.length] ?? focus.aspect) : undefined;\n return focus && aspect ? coverRect(cell, layout, { aspect, focus }) : undefined;\n })()}\n />}\n {bevels?.[i]!.map((p, k) => <path key={k} className=\"andamento-bevel\" d={p.d} fill={p.fill} fillOpacity={p.opacity} />)}\n {stroke && <path d={d} fill=\"none\" stroke={stroke} strokeWidth={strokeWidth} />}\n </g>\n );\n })}\n </g>\n </svg>\n );\n}\n\nfunction DefaultCell({ cell, ctx, noFill, box, cover }: { cell: Cell; ctx: SvgCellRenderContext; noFill: boolean; box?: Rect; cover?: Rect }) {\n return (\n <>\n {!noFill && <path d={ctx.path} fill={ctx.fill} fillRule=\"evenodd\" />}\n {ctx.image && <SvgCellImage cell={cell} href={ctx.image} clipPath={ctx.clipPath} box={box} cover={cover} />}\n </>\n );\n}\n\nexport interface SvgCellImageProps extends Omit<SVGProps<SVGImageElement>, \"href\" | \"x\" | \"y\" | \"width\" | \"height\"> {\n cell: Cell;\n href: string;\n /** Pass `ctx.clipPath` from `renderCell`. */\n clipPath: string;\n /**\n * Draw the image whole inside this box (e.g. `safeArea(cell, layout)`) instead of\n * covering the cell.\n */\n box?: Rect;\n /** Cover this rectangle instead of the cell's box (e.g. `coverRect(cell, layout, { aspect, focus })`). */\n cover?: Rect;\n}\n\n/**\n * An SVG <image> that covers the cell (like CSS `object-fit: cover`), clipped to its shape;\n * or, with `box`, shown whole inside the box (like `object-fit: contain`).\n */\nexport function SvgCellImage({ cell, href, clipPath, box, cover, ...rest }: SvgCellImageProps) {\n const b = box ?? cover ?? cellShape(cell).bbox;\n return (\n <image\n href={href}\n x={b.x}\n y={b.y}\n width={b.width}\n height={b.height}\n preserveAspectRatio={box ? \"xMidYMid meet\" : \"xMidYMid slice\"}\n clipPath={clipPath}\n {...rest}\n />\n );\n}\n","import { useEffect, useMemo, useState } from \"react\";\nimport { imageFill, loadImagePixels, type CellFill, type ImageFillOptions, type Pixels } from \"@andamento/core\";\n\n/**\n * Load an image and color tiles from it (see `imageFill`): returns a fill to pass as\n * `fill`, or `undefined` while the image loads (or if it fails), so the default fill shows\n * meanwhile. `maxSize` caps the size the image is read at (default 256 px on the long side).\n */\nexport function useImageFill(src: string | undefined, options: ImageFillOptions & { maxSize?: number } = {}): CellFill | undefined {\n const { fit, palette, fallback, samples, maxSize = 256 } = options;\n const [pixels, setPixels] = useState<{ src: string; pixels: Pixels }>();\n useEffect(() => {\n if (!src) return;\n let live = true;\n loadImagePixels(src, maxSize).then(\n (p) => live && setPixels({ src, pixels: p }),\n (e) => console.warn(`useImageFill: ${(e as Error).message}`),\n );\n return () => {\n live = false;\n };\n }, [src, maxSize]);\n const paletteKey = palette?.join(\",\");\n return useMemo(\n () => (pixels && pixels.src === src ? imageFill(pixels.pixels, { fit, palette, fallback, samples }) : undefined),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [pixels, src, fit, paletteKey, fallback, samples],\n );\n}\n","import { useEffect, useState } from \"react\";\n\n/**\n * Measure images' aspect ratios (width / height) by loading them, for the `aspects` and\n * `imageAspects` props. Returns `undefined` until every image has loaded or failed (failed\n * ones count as square), so content isn't reshuffled image by image as they arrive.\n */\nexport function useImageAspects(srcs: readonly string[] | undefined): number[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; aspects: number[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof Image === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map(\n (src) =>\n new Promise<number>((resolve) => {\n const img = new Image();\n img.onload = () => resolve(img.naturalWidth && img.naturalHeight ? img.naturalWidth / img.naturalHeight : 1);\n img.onerror = () => resolve(1);\n img.src = src;\n }),\n ),\n ).then((aspects) => live && setResult({ key, aspects }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.aspects : undefined;\n}\n","import { useEffect, useState } from \"react\";\nimport { estimateFocus, loadImagePixels, type Focus } from \"@andamento/core\";\n\n/**\n * Guess each image's focal point (see `estimateFocus`) by loading it, for the `focus` and\n * `imageFocus` props. Returns `undefined` until every image has been looked at; images that\n * fail to load (or that the browser won't let a canvas read) get the middle.\n */\nexport function useImageFocus(srcs: readonly string[] | undefined): Focus[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; focus: Focus[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof document === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map((src) =>\n loadImagePixels(src, 128)\n .then(estimateFocus)\n .catch(() => ({ x: 0.5, y: 0.5 })),\n ),\n ).then((focus) => live && setResult({ key, focus }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.focus : undefined;\n}\n","/**\n * React bindings: `<TileLayout>` (any children, clipped to the tiles), `<SvgTileLayout>` and hooks.\n *\n * @module @andamento/react\n */\nexport { TileLayout, coverStyle } from \"./TileLayout\";\nexport type { CellState, TileLayoutProps } from \"./TileLayout\";\nexport { SvgTileLayout, SvgCellImage } from \"./SvgTileLayout\";\nexport type { SvgTileLayoutProps, SvgCellImageProps, SvgCellRenderContext } from \"./SvgTileLayout\";\nexport { useFitCount, useTileLayout } from \"./useTileLayout\";\nexport { useImageFill } from \"./useImageFill\";\nexport { useImageAspects } from \"./useImageAspects\";\nexport { useImageFocus } from \"./useImageFocus\";\nexport { cellFromPointer } from \"@andamento/dom\";\nexport type { PerCell, PointerLike } from \"@andamento/dom\";\nexport type { FitProp } from \"./useTileLayout\";\nexport type { Cell, ContentCells, ContentPlacement, Focus, Layout, LayoutOptions, MatchOptions, SafeAreaOptions, HitOptions } from \"@andamento/core\";\nexport { defaultPalette, neutralPalette } from \"@andamento/svg\";\nexport type { FillSource, ReliefOptions } from \"@andamento/svg\";\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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useEffect","useState","resolve","useEffect","useState","loadImagePixels"]}
|
|
1
|
+
{"version":3,"sources":["../src/TileLayout.tsx","../src/useTileLayout.ts","../src/SvgTileLayout.tsx","../src/useImageFill.ts","../src/useImageAspects.ts","../src/useImageFocus.ts","../src/index.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type KeyboardEvent,\n type CSSProperties,\n type HTMLAttributes,\n type Key,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { cellsInRect, type Cell, type ContentCells, type ContentPlacement, type Focus, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport {\n coverStyle as sharedCoverStyle,\n type CellState,\n type SafeAreaProp,\n type PerCell,\n} from \"@andamento/dom\";\nimport {\n backdropStyle,\n backgroundStyle,\n containerStyle,\n frameBuilder,\n keyAction,\n overlayStyle,\n resolvePerCell as resolve,\n ringStrokes,\n safeBoxStyle,\n sameRect,\n shadowShape,\n tileSheet,\n tileStyle,\n tileViewBox,\n viewRect,\n watchView,\n} from \"@andamento/dom/internal\";\nimport type { FillSource, ReliefOptions } from \"@andamento/svg\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport type { CellState };\n\nconst isEmpty = (n: ReactNode) => n == null || n === false || n === true || n === \"\";\nconst css = (s: object) => s as CSSProperties;\n\nexport interface TileLayoutProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n /**\n * Any React content. Each top-level child fills one tile, in reading order\n * (top-to-bottom, left-to-right), and is clipped to the tile's shape.\n * Extra children beyond the number of tiles are not rendered.\n */\n children?: ReactNode;\n /**\n * Alternative to `children`: compute each tile's content from its cell. Takes precedence.\n * `slot` numbers the cells allowed by `contentCells` in reading order (-1 for the rest).\n */\n renderCell?: (cell: Cell, state: { slot: number }) => ReactNode;\n /**\n * Which tiles may hold children: \"all\" (default), \"whole\" (only tiles not cut by the\n * region outline), or a test per cell. The others are left empty.\n */\n contentCells?: ContentCells;\n /**\n * Where children go when there are fewer than tiles: \"reading\" (default; the first\n * tiles in reading order), \"center\" (the middle of the region) or \"spread\" (evenly\n * over it). Children always run in reading order across the tiles chosen.\n */\n placement?: ContentPlacement;\n /**\n * Width / height of each child, in order. When given, each child goes in a tile of\n * similar shape, so `object-fit: cover` crops as little as possible (landscape photos in\n * wide tiles, portraits in tall ones); see `matchSlots`. Featured tiles still take the\n * first children. Missing entries count as square. Ignored with `renderCell`.\n */\n aspects?: readonly number[];\n /**\n * Keep content out of the tiles' clipped corners: each tile's content goes in a box at\n * the tile's safe area (see `safeArea`), the largest rectangle that fits inside its shape,\n * instead of filling the tile's bounding box. Useful for text in triangles or hexagons.\n * With `aspects`, each child's box has the child's shape, so it shows whole and uncropped.\n * The box has `data-safe-area`; style its contents to fill it. Tiles show `fill` around\n * their content. For tiles an `edges: \"window\"` layout cuts, `true` or \"tile\" fits the\n * whole tile (content near the edge is partly hidden, like the tile) and \"visible\" the\n * part that shows.\n */\n safeArea?: SafeAreaProp;\n /** With `aspects`: \"shape\" also picks which tiles hold children by their shape, ignoring `placement`. */\n choose?: \"placement\" | \"shape\";\n /**\n * Focal point of each child (fractions of its width and height; see `estimateFocus`): what\n * a photo keeps in view as its tile crops it. Each tile sets `--andamento-object-position`,\n * which `coverStyle` uses as `object-position`; exact when the photo's shape is known (`aspects`, or the focus's `aspect`).\n */\n focalPoints?: readonly (Focus | undefined)[];\n /**\n * How many tiles each child spans (1 for an ordinary child; rounded): heavier childs get a\n * featured tile of that many merged tiles, where they fall in reading order (see\n * `weightedLayout`). With `fit`, the tiles are sized to fit everything. Needs `options`.\n */\n weights?: readonly number[];\n /**\n * Color of empty tiles: a color, a palette (neighboring tiles get different entries),\n * or a function per cell. Defaults to `neutralPalette`; use \"transparent\" for none.\n */\n fill?: FillSource;\n /**\n * Size the tiles to the children: scales the pattern so there are about as many tiles\n * (counted by `contentCells`) as children. `true`/\"atLeast\" makes sure every child gets\n * a tile; \"nearest\" gets as close as possible. Ignored with `layout` or `renderCell`.\n */\n fit?: FitProp;\n /**\n * One picture across all the tiles: rendered in every tile, sized and positioned to the\n * whole layout, so each tile shows its own piece. Use an element that fills its box,\n * e.g. `<img src=… style={coverStyle} />`. It sits behind the tile's content, and empty\n * tiles show it instead of `fill`. (Each tile gets its own copy, so a video would play\n * out of sync; images are loaded once.)\n */\n backdrop?: ReactNode;\n /**\n * Raised tiles: a bevel round each tile, lit from one side and drawn over its content,\n * and optionally a soft shadow each tile casts into the grout (set `shadow`). `true` for\n * the defaults. With `gap` as the grout width and `background` as its color or texture,\n * it looks like a tiled surface. See `ReliefOptions`.\n */\n relief?: boolean | ReliefOptions;\n /**\n * Keyboard navigation: tiles with content become focusable as one tab stop (roving\n * tabindex). Arrow keys move to a touching tile in that direction, whatever the tiling;\n * Home and End go to the first and last. The focused tile shows `focusRing`.\n */\n navigable?: boolean;\n /**\n * Called when a tile with content is activated: clicked, or Enter or Space while it has\n * focus (with `navigable`).\n */\n onCellActivate?: (cell: Cell, state: CellState) => void;\n /** Accessible name for each tile (its `aria-label`), e.g. a photo's description. */\n cellLabel?: PerCell<string | undefined>;\n /**\n * Color of the focus outline drawn inside the focused tile's shape (a CSS outline would be\n * clipped away), with a white inner line so it shows on any content. `false` for none,\n * if you style `[data-cell-id]:focus-visible` yourself. Defaults to \"#1a56db\".\n */\n focusRing?: string | false;\n /**\n * Animate changes: when the layout changes (a resize, another tiling, a new gap) or the\n * children do, tiles glide and morph into their new places and shapes, a child keeping\n * its tile as it moves; new tiles fade in and removed ones fade out. Pure CSS\n * transitions, skipped when the user prefers reduced motion. `true` for 400 ms, or\n * `{ duration, easing }`.\n */\n animate?: boolean | { duration?: number; easing?: string };\n /**\n * Mount only the tiles in view (plus `overscan` pixels round it, default 300), for\n * layouts with thousands of tiles. Tiles mount and unmount as the page or any scrolling\n * container scrolls, or the layout resizes. Keyboard navigation still reaches every\n * tile (the focused one stays mounted and is scrolled to), and list items carry\n * `aria-setsize` and `aria-posinset`. With `renderCell`, every cell `contentCells`\n * allows counts as having content. On the server no tiles are rendered.\n */\n virtualize?: boolean | { overscan?: number };\n /** Content for empty tiles. */\n fallback?: PerCell<ReactNode>;\n /** Class name for each tile wrapper (fixed or per cell). */\n cellClassName?: PerCell<string>;\n /** Extra style for each tile wrapper (fixed or per cell), e.g. a background color. */\n cellStyle?: PerCell<CSSProperties>;\n /** Color painted across the whole region, visible through the gaps. */\n background?: string;\n}\n\n/**\n * Renders a tiling as HTML: one absolutely positioned, `clip-path`-ed element per tile,\n * holding whatever you put in it (images, video, text, components). Everything is sized\n * in percentages, so the layout scales with the container's width.\n *\n * Each tile wrapper has `data-cell-id` and `data-index`, plus `data-empty` (no content)\n * and `data-boundary` (cut by the region outline) for styling.\n *\n * Clipping also applies to pointer events, so hover and clicks follow the tile shapes.\n */\nexport function TileLayout(props: TileLayoutProps) {\n const {\n options,\n layout: given,\n children,\n renderCell,\n contentCells,\n placement,\n aspects,\n choose,\n focalPoints,\n weights,\n safeArea,\n fill,\n fit,\n backdrop,\n relief,\n navigable,\n onCellActivate,\n cellLabel,\n focusRing = \"#1a56db\",\n animate,\n virtualize,\n fallback,\n cellClassName,\n cellStyle,\n background,\n style,\n role,\n onKeyDown,\n ...rest\n } = props;\n const uid = \"andamento\" + useId().replace(/:/g, \"\");\n const items = renderCell ? [] : Children.toArray(children);\n const layout = useResolvedLayout(\"TileLayout\", options, given, {\n fit: !renderCell && fit,\n count: items.length,\n cells: contentCells,\n weights: renderCell ? undefined : weights,\n placement,\n });\n const { bounds } = layout;\n // Slots, fills and bevels, reused from the last render where nothing they depend on changed.\n const buildFrame = useRef<ReturnType<typeof frameBuilder>>();\n buildFrame.current ??= frameBuilder();\n const frame = buildFrame.current(layout, {\n count: renderCell ? Infinity : items.length,\n aspects: renderCell ? undefined : aspects,\n contentCells,\n placement,\n choose,\n fill,\n relief,\n animate,\n });\n const { slots, anim } = frame;\n\n // Key by child where possible, so a child keeps its state (video position, inputs,\n // animations) when the layout changes underneath it.\n const keyOf = (i: number): Key => {\n const slot = slots[i]!;\n if (!renderCell && slot >= 0) {\n const child = items[slot];\n return isValidElement(child) && child.key != null ? `child:${child.key}` : `child:${slot}`;\n }\n return `cell:${layout.cells[i]!.id}`;\n };\n // What a tile holds.\n const makeEntry = (i: number) => {\n const cell = layout.cells[i]!;\n const slot = slots[i]!;\n let content: ReactNode = null;\n if (renderCell) content = renderCell(cell, { slot });\n else if (slot >= 0) content = items[slot];\n const empty = isEmpty(content);\n const state: CellState = { empty, slot: empty && !renderCell ? -1 : slot };\n if (empty) content = resolve(fallback, cell, state);\n return { i, cell, content, key: keyOf(i), empty, state };\n };\n\n // Virtualization: the part of the layout in view, in layout units (null until measured).\n const virtual = !!virtualize;\n const overscan = Math.max(0, (typeof virtualize === \"object\" ? virtualize.overscan : undefined) ?? 300);\n const container = useRef<HTMLDivElement>(null);\n const [view, setView] = useState<Rect | null>(null);\n // Without virtualization, every tile's entry is worked out before rendering, so navigation\n // knows which have content. With it, only the tiles in view are; whether others have\n // content is judged without rendering them.\n const allEntries = virtual ? undefined : layout.cells.map((_, i) => makeEntry(i));\n const hasContent = (i: number) =>\n allEntries ? !allEntries[i]!.empty : renderCell ? slots[i]! >= 0 : slots[i]! >= 0 && !isEmpty(items[slots[i]!]);\n\n // Animation: enter / exit animations for tiles that come and go (the tiles' own\n // transitions are in their style).\n const mounted = useRef(false);\n const lastKeys = useRef(new Set<Key>());\n const entering = useRef(new Set<Key>());\n const lastTiles = useRef(new Map<Key, ReactElement>());\n const [exiting, setExiting] = useState(() => new Map<Key, ReactElement>());\n const timers = useRef(new Set<ReturnType<typeof setTimeout>>());\n\n // Roving tabindex: one tile is the tab stop; arrow keys move it.\n const focusable = new Set(navigable ? layout.cells.filter((c) => hasContent(c.index)).map((c) => c.id) : []);\n const [activeId, setActiveId] = useState<string>();\n const firstFocusable = layout.cells.find((c) => focusable.has(c.id))?.id;\n const active = activeId !== undefined && focusable.has(activeId) ? activeId : firstFocusable;\n const tiles = useRef(new Map<string, HTMLDivElement>());\n const pendingFocus = useRef<string>();\n const list = (role ?? \"list\") === \"list\";\n\n // The tiles to render: all of them, or those in view plus the tab stop (so Tab finds it).\n let entries: ReturnType<typeof makeEntry>[];\n if (allEntries) entries = allEntries;\n else {\n const shown = new Set(view && view.width >= 0 ? cellsInRect(layout, view).map((c) => c.index) : []);\n const activeCell = active !== undefined ? layout.cells.find((c) => c.id === active) : undefined;\n if (activeCell) shown.add(activeCell.index);\n entries = [...shown].sort((a, b) => a - b).map(makeEntry);\n }\n // List positions, as screen readers can't count tiles that aren't there.\n let positions: Map<number, number> | undefined;\n if (virtual) {\n positions = new Map();\n for (const c of layout.cells) if (hasContent(c.index)) positions.set(c.index, positions.size + 1);\n }\n\n // Animation bookkeeping uses every tile's key, so tiles scrolling in and out of view\n // don't count as coming and going.\n const allKeys = anim ? new Set(layout.cells.map((_, i) => keyOf(i))) : undefined;\n for (const e of entries) if (anim && mounted.current && !lastKeys.current.has(e.key)) entering.current.add(e.key);\n\n const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !navigable || e.altKey || e.ctrlKey || e.metaKey) return;\n // Only when a tile itself has focus, not an input or button inside it.\n const entry = entries.find((x) => tiles.current.get(x.cell.id) === e.target);\n if (!entry || !focusable.has(entry.cell.id)) return;\n const action = keyAction(layout, entry.cell, e.key, (c: Cell) => focusable.has(c.id), !!onCellActivate);\n if (!action) return;\n // Arrow keys at the edge are still ours: don't scroll the page.\n e.preventDefault();\n if (\"activate\" in action) onCellActivate!(entry.cell, entry.state);\n else if (\"move\" in action) {\n setActiveId(action.move.id);\n const el = tiles.current.get(action.move.id);\n // A tile out of view isn't mounted yet: focus it once it is.\n if (el) el.focus();\n else pendingFocus.current = action.move.id;\n }\n };\n\n const rendered = entries.map(({ i, cell, content, key, empty, state }) => {\n const slot = slots[i]!;\n const bevel = frame.bevel(i);\n const tile = tileStyle(frame, cell, {\n empty,\n safeArea,\n backdrop: backdrop != null,\n clickable: !!onCellActivate && !empty,\n focus: !renderCell && slot >= 0 ? focalPoints?.[slot] : undefined,\n aspect: !renderCell && slot >= 0 ? aspects?.[slot] : undefined,\n });\n // Tiles with nothing in them are decoration: hidden from assistive technology.\n const silent = empty && isEmpty(content);\n const canFocus = focusable.has(cell.id);\n const viewBox = tileViewBox(cell);\n return (\n <div\n key={key}\n ref={(el) => {\n if (el) tiles.current.set(cell.id, el);\n else tiles.current.delete(cell.id);\n }}\n role={silent ? undefined : list ? \"listitem\" : undefined}\n aria-hidden={silent ? true : undefined}\n aria-label={silent ? undefined : resolve(cellLabel, cell, state)}\n aria-setsize={positions && list && !silent ? positions.size : undefined}\n aria-posinset={positions && list && !silent ? positions.get(i) : undefined}\n tabIndex={canFocus ? (cell.id === active ? 0 : -1) : undefined}\n onFocus={canFocus ? (e) => e.target === e.currentTarget && setActiveId(cell.id) : undefined}\n onClick={onCellActivate && !empty ? () => onCellActivate(cell, state) : undefined}\n className={resolve(cellClassName, cell, state)}\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={empty ? \"\" : undefined}\n data-boundary={cell.boundary ? \"\" : undefined}\n data-entering={entering.current.has(key) ? \"\" : undefined}\n style={{ ...css(tile), ...resolve(cellStyle, cell, state) }}\n >\n {backdrop != null && (\n // z-index -1 puts it behind the content but inside the tile: the tile's\n // clip-path makes it a stacking context.\n <div aria-hidden style={css(backdropStyle(frame, cell))}>\n {backdrop}\n </div>\n )}\n {safeArea && content != null && !isEmpty(content) ? (\n <div data-safe-area=\"\" style={css(safeBoxStyle(frame, cell, !renderCell && !empty && aspects ? (aspects[slot] ?? 1) : undefined, safeArea))}>\n {content}\n </div>\n ) : (\n content\n )}\n {bevel && bevel.length > 0 && (\n // Over the content; the tile's box is its bounding box, so map that to the viewBox.\n // When animating, the bevel is for the new shape, so it fades in as the tile arrives.\n <svg\n key={anim ? String(tile.clipPath) : undefined}\n aria-hidden\n data-bevel=\"\"\n data-late={anim ? \"\" : undefined}\n viewBox={viewBox}\n preserveAspectRatio=\"none\"\n style={css(overlayStyle)}\n >\n {bevel.map((p, k) => (\n <path key={k} d={p.d} fill={p.fill} fillOpacity={p.opacity} />\n ))}\n </svg>\n )}\n {canFocus && focusRing !== false && (\n // The tile's outline, stroked across its edge; the clip keeps the inner half.\n <svg aria-hidden data-focus-ring=\"\" viewBox={viewBox} preserveAspectRatio=\"none\" style={css(overlayStyle)}>\n {ringStrokes(frame, cell, focusRing).map((p, k) => (\n <path key={k} d={p.d} fill=\"none\" stroke={p.stroke} strokeWidth={p.width} vectorEffect=\"non-scaling-stroke\" />\n ))}\n </svg>\n )}\n </div>\n );\n });\n\n // After each commit: tiles that just went away stay a moment to fade out.\n useIsomorphicLayoutEffect(() => {\n const current = new Map<Key, ReactElement>(rendered.map((el) => [el.key!, el]));\n const present = allKeys ?? current;\n if (anim && mounted.current) {\n const gone = [...lastTiles.current].filter(([k]) => !present.has(k));\n if (gone.length) {\n setExiting((prev) => new Map([...prev, ...gone]));\n const timer = setTimeout(() => {\n timers.current.delete(timer);\n setExiting((prev) => {\n const next = new Map(prev);\n for (const [k, el] of gone) if (next.get(k) === el) next.delete(k);\n return next;\n });\n }, anim.duration);\n timers.current.add(timer);\n }\n }\n for (const k of entering.current) if (!present.has(k)) entering.current.delete(k);\n lastKeys.current = new Set(present.keys());\n lastTiles.current = current;\n mounted.current = true;\n if (pendingFocus.current) {\n const el = tiles.current.get(pendingFocus.current);\n if (el) {\n pendingFocus.current = undefined;\n el.focus();\n }\n }\n });\n\n // Virtualization: measure what's in view, again on scroll (of the page or any container)\n // and resize, at most once a frame.\n useIsomorphicLayoutEffect(() => {\n if (!virtual) return;\n const el = container.current;\n if (!el) return;\n return watchView(el, () => {\n const next = viewRect(el, layout, overscan);\n setView((v) => (sameRect(v ?? undefined, next) ? v : next));\n });\n }, [virtual, layout, overscan]);\n useEffect(() => {\n const set = timers.current;\n return () => set.forEach(clearTimeout);\n }, []);\n const leaving = anim\n ? [...exiting].filter(([k]) => !lastKeys.current.has(k) && !rendered.some((el) => el.key === k))\n : [];\n\n const sheet = tileSheet({ focusRing: !!navigable && focusRing !== false, anim });\n const shadow = shadowShape(frame, entries.map((e) => e.cell));\n return (\n <div\n data-andamento=\"\"\n ref={container}\n role={role ?? \"list\"}\n {...rest}\n onKeyDown={handleKeyDown}\n style={{ ...css(containerStyle(layout)), ...style }}\n >\n {sheet && <style>{sheet}</style>}\n {background && <div aria-hidden style={css(backgroundStyle(frame, background))} />}\n {shadow && (\n <svg aria-hidden data-andamento-shadow=\"\" viewBox={shadow.viewBox} preserveAspectRatio=\"none\" style={css(shadow.style)}>\n <filter id={`${uid}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={shadow.blur} />\n </filter>\n <path d={shadow.d} fillRule=\"evenodd\" transform={shadow.transform} fill=\"#000\" fillOpacity={shadow.opacity} filter={`url(#${uid}-shadow)`} />\n </svg>\n )}\n {rendered}\n {leaving.map(([k, el]) =>\n // Fades out through the [data-exiting] rule in the style sheet.\n cloneElement(el as ReactElement<Record<string, unknown>>, {\n key: k,\n ref: null,\n role: undefined,\n tabIndex: undefined,\n onClick: undefined,\n onFocus: undefined,\n \"aria-hidden\": true,\n \"data-entering\": undefined,\n \"data-exiting\": \"\",\n }),\n )}\n </div>\n );\n}\n\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Style that makes an <img> or <video> cover its tile, like `object-fit: cover`. */\nexport const coverStyle: CSSProperties = css(sharedCoverStyle);\n","import { useMemo, useRef } from \"react\";\nimport { createLayout, fitCount, type ContentCells, type FitOptions, type Layout, type LayoutOptions } from \"@andamento/core\";\nimport { type FitProp } from \"@andamento/dom\";\nimport { layoutResolver, optionsKey, type LayoutNeeds } from \"@andamento/dom/internal\";\n\n/**\n * Compute a layout, recomputing only when the options change.\n * Inline object literals are fine: options are compared by value (a function in them,\n * such as `sizeAt`, by identity).\n */\nexport function useTileLayout(options: LayoutOptions): Layout {\n const key = optionsKey(options);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => createLayout(options), [key]);\n}\n\n/**\n * Compute a layout whose tiles are sized to give about `count` usable cells (see\n * `fitCount` in @andamento/core). Options are compared by value; a `cells` function by\n * identity.\n */\nexport function useFitCount(options: LayoutOptions, count: number, fit: FitOptions = {}): Layout {\n const key = optionsKey(options);\n const { cells, mode } = fit;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => fitCount(options, count, { cells, mode }).layout, [key, count, cells, mode]);\n}\n\nexport type { FitProp };\n\n/**\n * Use `layout` if given, otherwise compute one from `options` (compared by value), fitted to\n * `count` items when `fit` is set.\n */\nexport function useResolvedLayout(\n component: string,\n options?: LayoutOptions,\n layout?: Layout,\n fit?: LayoutNeeds,\n): Layout {\n const resolver = useRef<ReturnType<typeof layoutResolver>>();\n resolver.current ??= layoutResolver(`<${component}>`);\n return resolver.current(options, layout, fit);\n}\n","import { useId, useMemo, type ReactNode, type SVGProps } from \"react\";\nimport { cellShape, coverRect, safeArea, type Cell, type Focus, type ContentCells, type ContentPlacement, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport { cellPath, defaultBevel, regionPath, viewPath, reliefPaths, shadowOffset, type FillSource, type ImageSource, type ReliefOptions } from \"@andamento/svg\";\nimport { cellA11y, resolveCellStyles } from \"@andamento/svg/internal\";\nimport { useResolvedLayout, type FitProp } from \"./useTileLayout\";\n\nexport interface SvgCellRenderContext {\n /** `d` attribute of the cell outline. */\n path: string;\n /** Id of a <clipPath> with the cell's shape, already in the SVG. */\n clipPathId: string;\n /** Ready-made `clipPath` prop value: `url(#…)`. */\n clipPath: string;\n /** The fill/image the default renderer would have used. */\n fill: string;\n image?: string;\n /** Which item of `images` the cell shows (-1 if none or if `images` is a function). */\n slot: number;\n}\n\nexport interface SvgTileLayoutProps extends Omit<SVGProps<SVGSVGElement>, \"children\" | \"fill\" | \"stroke\" | \"strokeWidth\"> {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n images?: ImageSource;\n repeatImages?: boolean;\n /** Which cells may hold an image from the `images` array: \"all\" (default), \"whole\" or a test. */\n contentCells?: ContentCells;\n /** Where images go when there are fewer than cells: \"reading\" (default), \"center\" or \"spread\". */\n placement?: ContentPlacement;\n /** Width / height of each image, to put images in cells of similar shape (see `matchSlots`). */\n imageAspects?: readonly number[];\n /** With `imageAspects`: \"shape\" also picks which cells get images by their shape. */\n choose?: \"placement\" | \"shape\";\n /**\n * \"cover\" (default) fills each cell's bounding box, cropped to its shape; \"contain\" shows\n * each image whole inside the cell's safe area (see `safeArea`), at its `imageAspects` shape.\n */\n imageFit?: \"cover\" | \"contain\";\n /**\n * With `imageFit: \"contain\"`, for cells an `edges: \"window\"` layout cuts: fit the image in\n * the whole tile (\"tile\", the default) or in the part that shows (\"visible\").\n */\n containWithin?: \"tile\" | \"visible\";\n /**\n * Focal point of each image (by position; fractions of its width and height, see\n * `estimateFocus`), kept in view when \"cover\" crops it (see `coverRect`). Needs each image's\n * shape, from `imageAspects` or the focus's `aspect`.\n */\n imageFocus?: readonly (Focus | undefined)[];\n /**\n * How many tiles each image in `images` spans (1 for most): heavier images get featured\n * tiles where they fall in reading order (see `weightedLayout`). Needs `options`.\n */\n imageWeights?: readonly number[];\n /**\n * Size the tiles to the `images` array (counted by `contentCells`): `true`/\"atLeast\" or\n * \"nearest\". Ignored with `layout`, `repeatImages` or an `images` function.\n */\n fit?: FitProp;\n /** Cell color under (or instead of) images. Defaults to `defaultPalette`. */\n fill?: FillSource;\n stroke?: string;\n strokeWidth?: number;\n /** Color painted across the whole region, behind the cells. */\n background?: string;\n /**\n * One image across all the cells (a URL), cropped to cover the layout and clipped to the\n * cells. The default cell rendering then skips `fill`; per-cell `images` go on top.\n */\n backdrop?: string;\n /**\n * Raised tiles: a lit bevel over each cell, and optionally a shadow cast into the grout.\n * `true` for the defaults. See `ReliefOptions`. Drawn over `renderCell` content too.\n */\n relief?: boolean | ReliefOptions;\n /** Replace the default cell rendering with SVG content. Rendered inside a <g> per cell. */\n renderCell?: (cell: Cell, ctx: SvgCellRenderContext) => ReactNode;\n /** Accessible title. */\n title?: string;\n /** Text alternative per image in `images`: those cells become labeled images; the rest decoration. */\n imageAlts?: readonly string[];\n}\n\n/**\n * Renders a tiling as a single <svg>: colored cells, optionally with images clipped\n * to each cell. Use this when you need pure SVG (export, print, embedding in other SVG);\n * use <TileLayout> to put arbitrary HTML/React content in the tiles.\n */\nexport function SvgTileLayout(props: SvgTileLayoutProps) {\n const {\n options,\n layout: given,\n images,\n repeatImages,\n contentCells,\n placement,\n imageAspects,\n choose,\n imageFit,\n containWithin,\n imageFocus,\n imageWeights,\n fit,\n fill,\n stroke,\n strokeWidth = 1,\n background,\n backdrop,\n relief: reliefProp,\n renderCell,\n title,\n imageAlts,\n ...svgProps\n } = props;\n const fitTo = Array.isArray(images) && !repeatImages ? images.length : 0;\n const layout = useResolvedLayout(\"SvgTileLayout\", options, given, {\n fit,\n count: fitTo,\n cells: contentCells,\n weights: Array.isArray(images) ? imageWeights : undefined,\n placement,\n });\n const prefix = \"andamento\" + useId().replace(/:/g, \"\");\n const styles = useMemo(\n () => resolveCellStyles(layout, { images, repeatImages, fill, contentCells, placement, imageAspects, choose }),\n [layout, images, repeatImages, fill, contentCells, placement, imageAspects, choose],\n );\n const { x, y, width, height } = layout.bounds;\n const relief = reliefProp === true ? {} : reliefProp || undefined;\n const reliefKey = relief ? JSON.stringify(relief) : \"\";\n const bevels = useMemo(() => {\n if (!relief) return undefined;\n const bevel = relief.bevel ?? defaultBevel(layout);\n return bevel > 0 ? layout.cells.map((c) => reliefPaths(layout, c, relief, bevel)) : undefined;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [layout, reliefKey]);\n const cast = relief && shadowOffset(relief);\n\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={`${x} ${y} ${width} ${height}`} role={imageAlts?.length ? \"group\" : title ? \"img\" : undefined} {...svgProps}>\n {title && <title>{title}</title>}\n {background && <path className=\"andamento-region\" d={regionPath(layout)} fill={background} fillRule=\"evenodd\" />}\n {layout.view && (\n <clipPath id={`${prefix}-view`}>\n <path d={viewPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n )}\n <g className={layout.view ? \"andamento-view\" : undefined} clipPath={layout.view ? `url(#${prefix}-view)` : undefined}>\n {backdrop && (\n <>\n <clipPath id={`${prefix}-backdrop`}>\n {layout.cells.map((cell) => (\n <path key={cell.id} d={cellPath(layout, cell)} clipRule=\"evenodd\" />\n ))}\n </clipPath>\n <image\n className=\"andamento-backdrop\"\n href={backdrop}\n x={x}\n y={y}\n width={width}\n height={height}\n preserveAspectRatio=\"xMidYMid slice\"\n clipPath={`url(#${prefix}-backdrop)`}\n />\n </>\n )}\n {cast && (\n <g className=\"andamento-shadow\" clipPath={`url(#${prefix}-region)`}>\n <clipPath id={`${prefix}-region`}>\n <path d={regionPath(layout)} clipRule=\"evenodd\" />\n </clipPath>\n <filter id={`${prefix}-shadow`} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n <feGaussianBlur stdDeviation={cast.blur} />\n </filter>\n <path\n d={layout.cells.map((c) => cellPath(layout, c)).join(\"\")}\n fillRule=\"evenodd\"\n transform={`translate(${cast.dx} ${cast.dy})`}\n fill=\"#000\"\n fillOpacity={cast.opacity}\n filter={`url(#${prefix}-shadow)`}\n />\n </g>\n )}\n {layout.cells.map((cell, i) => {\n const d = cellPath(layout, cell);\n const clipPathId = `${prefix}-clip-${cell.index}`;\n const style = styles[i]!;\n const ctx: SvgCellRenderContext = { path: d, clipPathId, clipPath: `url(#${clipPathId})`, ...style };\n return (\n <g\n key={cell.id}\n className=\"andamento-cell\"\n data-cell-id={cell.id}\n data-index={cell.index}\n data-empty={style.image ? undefined : \"\"}\n data-boundary={cell.boundary ? \"\" : undefined}\n {...cellA11y(style, imageAlts)}\n >\n <clipPath id={clipPathId}>\n <path d={d} clipRule=\"evenodd\" />\n </clipPath>\n {renderCell ? renderCell(cell, ctx) : <DefaultCell\n cell={cell}\n ctx={ctx}\n noFill={!!backdrop}\n box={\n imageFit === \"contain\" && style.image\n ? safeArea(cell, layout, { aspect: imageAspects && style.slot >= 0 ? imageAspects[style.slot] : undefined, within: containWithin })\n : undefined\n }\n cover={(() => {\n const focus = imageFit !== \"contain\" && style.image && style.slot >= 0 ? imageFocus?.[style.slot] : undefined;\n const aspect = focus ? (imageAspects?.[style.slot] ?? focus.aspect) : undefined;\n return focus && aspect ? coverRect(cell, layout, { aspect, focus }) : undefined;\n })()}\n />}\n {bevels?.[i]!.map((p, k) => <path key={k} className=\"andamento-bevel\" d={p.d} fill={p.fill} fillOpacity={p.opacity} />)}\n {stroke && <path d={d} fill=\"none\" stroke={stroke} strokeWidth={strokeWidth} />}\n </g>\n );\n })}\n </g>\n </svg>\n );\n}\n\nfunction DefaultCell({ cell, ctx, noFill, box, cover }: { cell: Cell; ctx: SvgCellRenderContext; noFill: boolean; box?: Rect; cover?: Rect }) {\n return (\n <>\n {!noFill && <path d={ctx.path} fill={ctx.fill} fillRule=\"evenodd\" />}\n {ctx.image && <SvgCellImage cell={cell} href={ctx.image} clipPath={ctx.clipPath} box={box} cover={cover} />}\n </>\n );\n}\n\nexport interface SvgCellImageProps extends Omit<SVGProps<SVGImageElement>, \"href\" | \"x\" | \"y\" | \"width\" | \"height\"> {\n cell: Cell;\n href: string;\n /** Pass `ctx.clipPath` from `renderCell`. */\n clipPath: string;\n /**\n * Draw the image whole inside this box (e.g. `safeArea(cell, layout)`) instead of\n * covering the cell.\n */\n box?: Rect;\n /** Cover this rectangle instead of the cell's box (e.g. `coverRect(cell, layout, { aspect, focus })`). */\n cover?: Rect;\n}\n\n/**\n * An SVG <image> that covers the cell (like CSS `object-fit: cover`), clipped to its shape;\n * or, with `box`, shown whole inside the box (like `object-fit: contain`).\n */\nexport function SvgCellImage({ cell, href, clipPath, box, cover, ...rest }: SvgCellImageProps) {\n const b = box ?? cover ?? cellShape(cell).bbox;\n return (\n <image\n href={href}\n x={b.x}\n y={b.y}\n width={b.width}\n height={b.height}\n preserveAspectRatio={box ? \"xMidYMid meet\" : \"xMidYMid slice\"}\n clipPath={clipPath}\n {...rest}\n />\n );\n}\n","import { useEffect, useMemo, useState } from \"react\";\nimport { imageFill, loadImagePixels, type CellFill, type ImageFillOptions, type Pixels } from \"@andamento/core\";\n\n/**\n * Load an image and color tiles from it (see `imageFill`): returns a fill to pass as\n * `fill`, or `undefined` while the image loads (or if it fails), so the default fill shows\n * meanwhile. `maxSize` caps the size the image is read at (default 256 px on the long side).\n */\nexport function useImageFill(src: string | undefined, options: ImageFillOptions & { maxSize?: number } = {}): CellFill | undefined {\n const { fit, palette, fallback, samples, maxSize = 256 } = options;\n const [pixels, setPixels] = useState<{ src: string; pixels: Pixels }>();\n useEffect(() => {\n if (!src) return;\n let live = true;\n loadImagePixels(src, maxSize).then(\n (p) => live && setPixels({ src, pixels: p }),\n (e) => console.warn(`useImageFill: ${(e as Error).message}`),\n );\n return () => {\n live = false;\n };\n }, [src, maxSize]);\n const paletteKey = palette?.join(\",\");\n return useMemo(\n () => (pixels && pixels.src === src ? imageFill(pixels.pixels, { fit, palette, fallback, samples }) : undefined),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [pixels, src, fit, paletteKey, fallback, samples],\n );\n}\n","import { useEffect, useState } from \"react\";\n\n/**\n * Measure images' aspect ratios (width / height) by loading them, for the `aspects` and\n * `imageAspects` props. Returns `undefined` until every image has loaded or failed (failed\n * ones count as square), so content isn't reshuffled image by image as they arrive.\n */\nexport function useImageAspects(srcs: readonly string[] | undefined): number[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; aspects: number[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof Image === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map(\n (src) =>\n new Promise<number>((resolve) => {\n const img = new Image();\n img.onload = () => resolve(img.naturalWidth && img.naturalHeight ? img.naturalWidth / img.naturalHeight : 1);\n img.onerror = () => resolve(1);\n img.src = src;\n }),\n ),\n ).then((aspects) => live && setResult({ key, aspects }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.aspects : undefined;\n}\n","import { useEffect, useState } from \"react\";\nimport { estimateFocus, loadImagePixels, type Focus } from \"@andamento/core\";\n\n/**\n * Guess each image's focal point (see `estimateFocus`) by loading it, for the `focus` and\n * `imageFocus` props. Returns `undefined` until every image has been looked at; images that\n * fail to load (or that the browser won't let a canvas read) get the middle.\n */\nexport function useImageFocus(srcs: readonly string[] | undefined): Focus[] | undefined {\n const key = srcs?.join(\"\\n\");\n const [result, setResult] = useState<{ key: string; focus: Focus[] }>();\n useEffect(() => {\n if (!srcs || key === undefined || typeof document === \"undefined\") return;\n let live = true;\n Promise.all(\n srcs.map((src) =>\n loadImagePixels(src, 128)\n .then(estimateFocus)\n .catch(() => ({ x: 0.5, y: 0.5 })),\n ),\n ).then((focus) => live && setResult({ key, focus }));\n return () => {\n live = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return result && result.key === key ? result.focus : undefined;\n}\n","/**\n * React bindings: `<TileLayout>` (any children, clipped to the tiles), `<SvgTileLayout>` and hooks.\n *\n * @module @andamento/react\n */\nexport { TileLayout, coverStyle } from \"./TileLayout\";\nexport type { CellState, TileLayoutProps } from \"./TileLayout\";\nexport { SvgTileLayout, SvgCellImage } from \"./SvgTileLayout\";\nexport type { SvgTileLayoutProps, SvgCellImageProps, SvgCellRenderContext } from \"./SvgTileLayout\";\nexport { useFitCount, useTileLayout } from \"./useTileLayout\";\nexport { useImageFill } from \"./useImageFill\";\nexport { useImageAspects } from \"./useImageAspects\";\nexport { useImageFocus } from \"./useImageFocus\";\nexport { cellFromPointer } from \"@andamento/dom\";\nexport type { PerCell, PointerLike } from \"@andamento/dom\";\nexport type { FitProp } from \"./useTileLayout\";\nexport type { Cell, ContentCells, ContentPlacement, Focus, Layout, LayoutOptions, MatchOptions, SafeAreaOptions, HitOptions } from \"@andamento/core\";\nexport { defaultPalette, neutralPalette } from \"@andamento/svg\";\nexport type { FillSource, ReliefOptions } from \"@andamento/svg\";\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAA;AAAA,EACA;AAAA,OAOK;AACP,SAAS,mBAAgI;AACzI;AAAA,EACE,cAAc;AAAA,OAIT;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACxCP,SAAS,SAAS,cAAc;AAChC,SAAS,cAAc,gBAAqF;AAE5G,SAAS,gBAAgB,kBAAoC;AAOtD,SAAS,cAAc,SAAgC;AAC5D,QAAM,MAAM,WAAW,OAAO;AAE9B,SAAO,QAAQ,MAAM,aAAa,OAAO,GAAG,CAAC,GAAG,CAAC;AACnD;AAOO,SAAS,YAAY,SAAwB,OAAe,MAAkB,CAAC,GAAW;AAC/F,QAAM,MAAM,WAAW,OAAO;AAC9B,QAAM,EAAE,OAAO,KAAK,IAAI;AAExB,SAAO,QAAQ,MAAM,SAAS,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,OAAO,OAAO,IAAI,CAAC;AAClG;AAQO,SAAS,kBACd,WACA,SACA,QACA,KACQ;AACR,QAAM,WAAW,OAA0C;AAC3D,WAAS,YAAT,SAAS,UAAY,eAAe,IAAI,SAAS,GAAG;AACpD,SAAO,SAAS,QAAQ,SAAS,QAAQ,GAAG;AAC9C;;;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M,CAAC,CAAC;AACnD,WAAO,MAAM;AACX,aAAO;AAAA,IACT;AAAA,EAEF,GAAG,CAAC,GAAG,CAAC;AACR,SAAO,UAAU,OAAO,QAAQ,MAAM,OAAO,QAAQ;AACvD;;;ACdA,SAAS,uBAAuB;AAIhC,SAAS,gBAAgB,sBAAsB;","names":["useRef","safeArea","useRef","useId","useMemo","jsx","jsxs","useId","useMemo","useEffect","useMemo","useState","useEffect","useState","resolve","useEffect","useState","loadImagePixels"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andamento/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React components for @andamento tiling layouts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tiling",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"typecheck": "tsc --noEmit -p ."
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@andamento/core": "0.
|
|
60
|
-
"@andamento/dom": "0.
|
|
61
|
-
"@andamento/svg": "0.
|
|
59
|
+
"@andamento/core": "0.2.0",
|
|
60
|
+
"@andamento/dom": "0.2.0",
|
|
61
|
+
"@andamento/svg": "0.2.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"react": ">=18"
|