@andamento/dom 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/matthewputnam/code/andamento/packages/dom/dist/index.cjs","../src/mount.ts","../src/element.ts","../src/pointer.ts","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACzBA,uCAAyI;AA+HzI,IAAM,IAAA,EAAM,4BAAA;AACZ,IAAM,MAAA,EAAQ,CAAC,CAAA,EAAA,GAAe,CAAA,CAAE,UAAA,CAAW,IAAI,EAAA,EAAI,EAAA,EAAI,CAAA,CAAE,OAAA,CAAQ,QAAA,EAAU,CAAC,CAAA,EAAA,GAAM,IAAA,EAAM,CAAA,CAAE,WAAA,CAAY,CAAC,CAAA;AACvG,IAAM,QAAA,EAAU,CAAC,CAAA,EAAA,GAAmB,EAAA,GAAK,KAAA,GAAQ,EAAA,IAAM,EAAA;AAEvD,IAAM,UAAA,kBAAY,IAAI,OAAA,CAA2B,CAAA;AAEjD,SAAS,UAAA,CAAW,EAAA,EAA8B,IAAA,EAAgB;AAChE,EAAA,MAAM,KAAA,mBAAO,SAAA,CAAU,GAAA,CAAI,EAAE,CAAA,UAAK,CAAC,GAAA;AACnC,EAAA,IAAA,CAAA,MAAW,EAAA,GAAK,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,EAAG,GAAA,CAAI,IAAA,CAAK,CAAC,EAAA,IAAM,KAAA,EAAA,GAAa,IAAA,CAAK,CAAC,EAAA,IAAM,KAAA,CAAA,EAAW,EAAA,CAAG,KAAA,CAAM,cAAA,CAAe,KAAA,CAAM,CAAC,CAAC,CAAA;AACvH,EAAA,IAAA,CAAA,MAAW,CAAC,CAAA,EAAG,CA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AAA;AACC,EAAA;AACJ,EAAA;AACE,EAAA;AACP,EAAA;AACI,EAAA;AACI,EAAA;AACP,EAAA;AACG,EAAA;AACH,EAAA;AACK,EAAA;AAGF,EAAA;AACI,EAAA;AACf,EAAA;AACJ,EAAA;AACD,IAAA;AACL,IAAA;AACqB,MAAA;AACH,MAAA;AACX,MAAA;AAClB,IAAA;AACmC,IAAA;AAC5B,IAAA;AACR,EAAA;AACwB,EAAA;AACS,EAAA;AAEV,EAAA;AACS,IAAA;AACK,IAAA;AACrC,EAAA;AACmC,EAAA;AACX,EAAA;AACS,EAAA;AAEnB,EAAA;AACV,IAAA;AACH,IAAA;AACA,IAAA;AACA,IAAA;AACkB,IAAA;AAClB,IAAA;AACqB,IAAA;AAC8B,IAAA;AACnB,MAAA;AAChC,IAAA;AACkD,IAAA;AACO,MAAA;AACpB,MAAA;AACrC,IAAA;AACF,EAAA;AAEY,EAAA;AACd;AAjRO;AAyRA;AACkB;AAGc;AACT,EAAA;AACH,EAAA;AACQ,EAAA;AACG,IAAA;AACtC,EAAA;AACO,EAAA;AACT;AAMwC;AACR,EAAA;AACM,EAAA;AACf,EAAA;AAEK,EAAA;AAAwB,EAAA;AACuB,EAAA;AAClE,EAAA;AACT;AF4VyC;AACA;AGlsBuC;AAeZ;AAC7B,EAAA;AACH,EAAA;AACG,EAAA;AACD,EAAA;AACtC;AHsrByC;AACA;AI9rBhB;AJgsBgB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/matthewputnam/code/andamento/packages/dom/dist/index.cjs","sourcesContent":[null,"import { cellsInRect, type Cell, type ContentCells, type ContentPlacement, type Focus, type Layout, type LayoutOptions, type Rect } from \"@andamento/core\";\nimport type { FillSource, ReliefOptions } from \"@andamento/svg\";\nimport {\n backdropStyle,\n backgroundStyle,\n containerStyle,\n frameBuilder,\n keyAction,\n layoutResolver,\n overlayStyle,\n resolvePerCell,\n ringStrokes,\n safeBoxStyle,\n sameRect,\n shadowShape,\n tileSheet,\n tileStyle,\n tileViewBox,\n viewRect,\n watchView,\n type CellState,\n type FitProp,\n type PerCell,\n type SafeAreaProp,\n type StyleMap,\n} from \"./model\";\n\n/** What can go in a tile: a DOM node, text, or nothing. */\nexport type TileContent = Node | string | null | undefined;\n\nexport interface TileLayoutConfig {\n /** Layout options; or pass a precomputed `layout` instead. */\n options?: LayoutOptions;\n layout?: Layout;\n /**\n * The content: each item fills one tile, in reading order, clipped to the tile's shape.\n * Nodes are moved into their tiles (and kept there as the layout changes), so pass the\n * same node again to keep its state.\n */\n items?: readonly TileContent[];\n /**\n * Alternative to `items`: each tile's content from its cell, worked out on every render.\n * Return the same node again to keep it. `slot` numbers the cells allowed by `contentCells`.\n */\n renderCell?: (cell: Cell, state: { slot: number }) => TileContent;\n /** Which tiles may hold content: \"all\" (default), \"whole\" (not cut by the outline) or a test. */\n contentCells?: ContentCells;\n /** Where items go when there are fewer than tiles: \"reading\" (default), \"center\" or \"spread\". */\n placement?: ContentPlacement;\n /** Width / height of each item, to put items in tiles of similar shape (see `matchSlots`). */\n aspects?: readonly number[];\n /** With `aspects`: \"shape\" also picks which tiles hold items by their shape. */\n choose?: \"placement\" | \"shape\";\n /**\n * Focal point of each item (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; 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 item spans (1 for an ordinary item; rounded): heavier items 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 * Put each tile's content in the tile's safe area, not its bounding box (see `safeArea`).\n * For tiles an `edges: \"window\"` layout cuts, `true` or \"tile\" fits the whole tile and\n * \"visible\" the part that shows.\n */\n safeArea?: SafeAreaProp;\n /** Color of empty tiles: a color, a palette or a function per cell. Defaults to `neutralPalette`. */\n fill?: FillSource;\n /** Size the tiles to the items: `true`/\"atLeast\" or \"nearest\". Ignored with `layout` or `renderCell`. */\n fit?: FitProp;\n /**\n * One picture across all the tiles: a node copied into every tile (or a function making\n * a fresh one per tile), sized to the whole layout so each tile shows its piece.\n */\n backdrop?: Node | (() => Node);\n /** Raised tiles: a lit bevel and optional shadow. `true` for the defaults. */\n relief?: boolean | ReliefOptions;\n /** Arrow-key navigation over the tiles with content, as one tab stop. */\n navigable?: boolean;\n /** Called when a tile with content is clicked, or Enter / Space pressed on it (with `navigable`). */\n onCellActivate?: (cell: Cell, state: CellState) => void;\n /** Accessible name for each tile. */\n cellLabel?: PerCell<string | undefined>;\n /** Focus ring color, or `false` for none. Defaults to \"#1a56db\". */\n focusRing?: string | false;\n /** Animate layout and content changes. `true` for 400 ms, or `{ duration, easing }`. */\n animate?: boolean | { duration?: number; easing?: string };\n /** Only put tiles in view (plus `overscan` pixels, default 300) in the DOM. */\n virtualize?: boolean | { overscan?: number };\n /** Content for empty tiles. */\n fallback?: PerCell<TileContent>;\n /** Class for each tile element. */\n cellClass?: PerCell<string | undefined>;\n /** Extra style for each tile element: camelCase or custom (`--x`) properties. */\n cellStyle?: PerCell<StyleMap | undefined>;\n /** Extra attributes for each tile element (`part`, `title`, …). */\n cellAttributes?: PerCell<Record<string, string | undefined> | undefined>;\n /** Color painted across the whole region, visible through the gaps. */\n background?: string;\n /** Role of the layout element: \"list\" (default; tiles with content are list items) or another. */\n role?: string;\n /** Accessible name of the layout (its `aria-label`). */\n label?: string;\n /** Class for the layout element. */\n className?: string;\n}\n\nexport interface TileLayoutHandle {\n /** The layout element (with `data-andamento`), inside the element mounted into. */\n readonly element: HTMLDivElement;\n /** The layout being shown. */\n readonly layout: Layout;\n /** Change some options (others stay as they are; pass `undefined` to clear one) and re-render. */\n update(changes: Partial<TileLayoutConfig>): void;\n /** Render again, e.g. after changing what `renderCell` returns. */\n refresh(): void;\n /** The element of the tile showing a cell, if it's in the DOM. */\n tileElement(cellId: string): HTMLElement | undefined;\n /** Remove the layout (items are taken out of their tiles) and stop listening. */\n destroy(): void;\n}\n\nconst SVG = \"http://www.w3.org/2000/svg\";\nconst kebab = (k: string) => (k.startsWith(\"--\") ? k : k.replace(/[A-Z]/g, (m) => \"-\" + m.toLowerCase()));\nconst isEmpty = (c: TileContent) => c == null || c === \"\";\n\nconst styleMemo = new WeakMap<Element, StyleMap>();\n/** Set style properties, removing those set last time and not now. */\nfunction applyStyle(el: HTMLElement | SVGElement, next: StyleMap) {\n const prev = styleMemo.get(el) ?? {};\n for (const k of Object.keys(prev)) if (next[k] === undefined && prev[k] !== undefined) el.style.removeProperty(kebab(k));\n for (const [k, v] of Object.entries(next)) if (v !== undefined && prev[k] !== v) el.style.setProperty(kebab(k), String(v));\n styleMemo.set(el, next);\n}\n\nfunction attr(el: Element, name: string, value: string | number | boolean | undefined | null) {\n if (value === undefined || value === null || value === false) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else {\n const v = value === true ? \"\" : String(value);\n if (el.getAttribute(name) !== v) el.setAttribute(name, v);\n }\n}\n\n/** Make `parent`'s children exactly `nodes`, in order, moving as few as possible. */\nfunction setChildren(parent: Node, nodes: readonly Node[]) {\n let at: ChildNode | null = parent.firstChild;\n for (const n of nodes) {\n if (n === at) at = at.nextSibling;\n else parent.insertBefore(n, at);\n }\n while (at) {\n const next: ChildNode | null = at.nextSibling;\n parent.removeChild(at);\n at = next;\n }\n}\n\nfunction svg(tag: string, attrs: Record<string, string | number | undefined>, children: Element[] = []) {\n const el = document.createElementNS(SVG, tag);\n for (const [k, v] of Object.entries(attrs)) if (v !== undefined) el.setAttribute(k, String(v));\n for (const c of children) el.appendChild(c);\n return el;\n}\n\ninterface Tile {\n key: string;\n el: HTMLDivElement;\n cell: Cell;\n state: CellState;\n empty: boolean;\n text?: Text;\n backdrop?: { source: TileConfigBackdrop; node: Node };\n safe?: HTMLDivElement;\n bevel?: { key: string; node: SVGSVGElement };\n ring?: { key: string; node: SVGSVGElement };\n /** Names of the attributes `cellAttributes` set last time. */\n extra?: string[];\n /** Fading out (animated removal). */\n leaving?: boolean;\n}\ntype TileConfigBackdrop = NonNullable<TileLayoutConfig[\"backdrop\"]>;\n\nconst nodeIds = new WeakMap<Node, number>();\nlet nextNodeId = 1;\nconst nodeId = (n: Node) => {\n let id = nodeIds.get(n);\n if (!id) nodeIds.set(n, (id = nextNodeId++));\n return id;\n};\n\nlet uidCount = 0;\n\n/**\n * Render a tiling into `target` (an element or a shadow root), without a framework: one\n * absolutely positioned, clipped element per tile, holding the items you give it. Sized in\n * percentages, so it scales with `target`'s width. Returns a handle to update or remove it.\n *\n * Tiles have `data-cell-id`, `data-index`, `data-empty` and `data-boundary`, as with the\n * React and Vue components.\n */\nexport function mountTileLayout(target: Element | ShadowRoot, initial: TileLayoutConfig): TileLayoutHandle {\n let config: TileLayoutConfig = { ...initial };\n const uid = `andamento-dom${++uidCount}`;\n const resolveLayout = layoutResolver(\"mountTileLayout\");\n const buildFrame = frameBuilder();\n const container = document.createElement(\"div\");\n container.setAttribute(\"data-andamento\", \"\");\n target.appendChild(container);\n\n const sheet = document.createElement(\"style\");\n const backgroundEl = document.createElement(\"div\");\n backgroundEl.setAttribute(\"aria-hidden\", \"true\");\n const blur = svg(\"feGaussianBlur\", {});\n const shadowPath = svg(\"path\", { \"fill-rule\": \"evenodd\", fill: \"#000\", filter: `url(#${uid}-shadow)` });\n const shadowEl = svg(\"svg\", { \"aria-hidden\": \"true\", \"data-andamento-shadow\": \"\", preserveAspectRatio: \"none\" }, [\n svg(\"filter\", { id: `${uid}-shadow`, x: \"-10%\", y: \"-10%\", width: \"120%\", height: \"120%\" }, [blur]),\n shadowPath,\n ]) as SVGSVGElement;\n\n let layout!: Layout;\n let tiles = new Map<string, Tile>();\n const leaving = new Set<Tile>();\n const byElement = new WeakMap<Element, Tile>();\n let lastKeys = new Set<string>();\n let mounted = false;\n let activeId: string | undefined;\n let pendingFocus: string | undefined;\n let focusable = new Set<string>();\n let view: Rect | undefined;\n let stopWatching: (() => void) | undefined;\n let watchedLayout: Layout | undefined;\n const timers = new Set<ReturnType<typeof setTimeout>>();\n let destroyed = false;\n\n function render() {\n if (destroyed) return;\n const c = config;\n const items = c.renderCell ? [] : (c.items ?? []);\n layout = resolveLayout(c.options, c.layout, {\n fit: !c.renderCell && c.fit,\n count: items.length,\n cells: c.contentCells,\n weights: c.renderCell ? undefined : c.weights,\n placement: c.placement,\n });\n const frame = buildFrame(layout, {\n count: c.renderCell ? Infinity : items.length,\n aspects: c.renderCell ? undefined : c.aspects,\n contentCells: c.contentCells,\n placement: c.placement,\n choose: c.choose,\n fill: c.fill,\n relief: c.relief,\n animate: c.animate,\n });\n const { slots } = frame;\n const focusRing = c.focusRing === undefined ? \"#1a56db\" : c.focusRing;\n const list = (c.role ?? \"list\") === \"list\";\n const virtual = !!c.virtualize;\n\n // A tile keeps its element while it shows the same item, so items keep their state.\n const keyOf = (i: number) => {\n const slot = slots[i]!;\n if (!c.renderCell && slot >= 0) {\n const item = items[slot];\n return item && typeof item === \"object\" ? `n${nodeId(item)}` : `i${slot}`;\n }\n return `c${layout.cells[i]!.id}`;\n };\n const hasContent = (i: number) => (c.renderCell ? slots[i]! >= 0 : slots[i]! >= 0 && !isEmpty(items[slots[i]!]));\n\n focusable = new Set(c.navigable ? layout.cells.filter((cell) => hasContent(cell.index)).map((cell) => cell.id) : []);\n const firstFocusable = layout.cells.find((cell) => focusable.has(cell.id))?.id;\n const active = activeId !== undefined && focusable.has(activeId) ? activeId : firstFocusable;\n\n // The tiles to show: all, or those in view plus the tab stop.\n let shown: number[];\n if (!virtual) shown = layout.cells.map((_, i) => i);\n else {\n const s = new Set(view && view.width >= 0 ? cellsInRect(layout, view).map((cell) => cell.index) : []);\n const a = active !== undefined ? layout.cells.find((cell) => cell.id === active) : undefined;\n if (a) s.add(a.index);\n shown = [...s].sort((x, y) => x - y);\n }\n let positions: Map<number, number> | undefined;\n if (virtual) {\n positions = new Map();\n for (const cell of layout.cells) if (hasContent(cell.index)) positions.set(cell.index, positions.size + 1);\n }\n const allKeys = frame.anim || virtual ? new Set(layout.cells.map((_, i) => keyOf(i))) : undefined;\n\n const next = new Map<string, Tile>();\n for (const i of shown) {\n const cell = layout.cells[i]!;\n const slot = slots[i]!;\n const key = keyOf(i);\n let content: TileContent = c.renderCell ? c.renderCell(cell, { slot }) : slot >= 0 ? items[slot] : undefined;\n const empty = isEmpty(content);\n const state: CellState = { empty, slot: empty && !c.renderCell ? -1 : slot };\n if (empty) content = resolvePerCell(c.fallback, cell, state);\n const silent = empty && isEmpty(content);\n\n let tile = tiles.get(key);\n if (!tile || tile.leaving) {\n const el = document.createElement(\"div\");\n tile = { key, el, cell, state, empty };\n if (frame.anim && mounted && !lastKeys.has(key)) el.setAttribute(\"data-entering\", \"\");\n }\n tiles.delete(key);\n next.set(key, tile);\n Object.assign(tile, { cell, state, empty });\n const el = tile.el;\n byElement.set(el, tile);\n\n const canFocus = focusable.has(cell.id);\n attr(el, \"role\", silent ? undefined : list ? \"listitem\" : undefined);\n attr(el, \"aria-hidden\", silent ? \"true\" : undefined);\n attr(el, \"aria-label\", silent ? undefined : resolvePerCell(c.cellLabel, cell, state));\n attr(el, \"aria-setsize\", positions && list && !silent ? positions.size : undefined);\n attr(el, \"aria-posinset\", positions && list && !silent ? positions.get(i) : undefined);\n attr(el, \"tabindex\", canFocus ? (cell.id === active ? 0 : -1) : undefined);\n attr(el, \"class\", resolvePerCell(c.cellClass, cell, state) || undefined);\n attr(el, \"data-cell-id\", cell.id);\n attr(el, \"data-index\", cell.index);\n attr(el, \"data-empty\", empty);\n attr(el, \"data-boundary\", !!cell.boundary);\n // Extra attributes; those given last time and not now are removed.\n const extra = resolvePerCell(c.cellAttributes, cell, state) ?? {};\n for (const k of tile.extra ?? []) if (!(k in extra)) attr(el, k, undefined);\n for (const [k, v] of Object.entries(extra)) attr(el, k, v);\n tile.extra = Object.keys(extra);\n applyStyle(el, {\n ...tileStyle(frame, cell, {\n empty,\n safeArea: c.safeArea,\n backdrop: c.backdrop != null,\n clickable: !!c.onCellActivate && !empty,\n focus: slot >= 0 ? c.focalPoints?.[slot] : undefined,\n aspect: slot >= 0 ? c.aspects?.[slot] : undefined,\n }),\n ...resolvePerCell(c.cellStyle, cell, state),\n });\n\n // Children: backdrop, content (in its safe area box), bevel, focus ring.\n const kids: Node[] = [];\n if (c.backdrop != null) {\n if (!tile.backdrop || tile.backdrop.source !== c.backdrop) {\n const node = typeof c.backdrop === \"function\" ? c.backdrop() : c.backdrop.cloneNode(true);\n const wrap = document.createElement(\"div\");\n wrap.setAttribute(\"aria-hidden\", \"true\");\n wrap.appendChild(node);\n tile.backdrop = { source: c.backdrop, node: wrap };\n }\n applyStyle(tile.backdrop.node as HTMLElement, backdropStyle(frame, cell));\n kids.push(tile.backdrop.node);\n } else tile.backdrop = undefined;\n let node: Node | undefined;\n if (typeof content === \"string\") {\n if (!tile.text) tile.text = document.createTextNode(content);\n else if (tile.text.data !== content) tile.text.data = content;\n node = tile.text;\n } else if (content) node = content;\n if (node && c.safeArea) {\n if (!tile.safe) {\n tile.safe = document.createElement(\"div\");\n tile.safe.setAttribute(\"data-safe-area\", \"\");\n }\n const aspect = !c.renderCell && !empty && c.aspects ? (c.aspects[slot] ?? 1) : undefined;\n applyStyle(tile.safe, safeBoxStyle(frame, cell, aspect, c.safeArea));\n setChildren(tile.safe, [node]);\n kids.push(tile.safe);\n } else if (node) kids.push(node);\n const bevel = frame.bevel(i);\n if (bevel && bevel.length) {\n const clip = frame.anim ? String(el.style.getPropertyValue(\"clip-path\")) : \"\";\n const bk = tileViewBox(cell) + clip + bevel.map((p) => p.d + p.fill + p.opacity).join();\n if (tile.bevel?.key !== bk) {\n const s = svg(\n \"svg\",\n { \"aria-hidden\": \"true\", \"data-bevel\": \"\", \"data-late\": frame.anim ? \"\" : undefined, viewBox: tileViewBox(cell), preserveAspectRatio: \"none\" },\n bevel.map((p) => svg(\"path\", { d: p.d, fill: p.fill, \"fill-opacity\": p.opacity })),\n ) as SVGSVGElement;\n applyStyle(s, overlayStyle);\n tile.bevel = { key: bk, node: s };\n }\n kids.push(tile.bevel.node);\n } else tile.bevel = undefined;\n if (canFocus && focusRing !== false) {\n const strokes = ringStrokes(frame, cell, focusRing);\n const rk = tileViewBox(cell) + strokes[0]!.d + focusRing;\n if (tile.ring?.key !== rk) {\n const s = svg(\n \"svg\",\n { \"aria-hidden\": \"true\", \"data-focus-ring\": \"\", viewBox: tileViewBox(cell), preserveAspectRatio: \"none\" },\n strokes.map((p) => svg(\"path\", { d: p.d, fill: \"none\", stroke: p.stroke, \"stroke-width\": p.width, \"vector-effect\": \"non-scaling-stroke\" })),\n ) as SVGSVGElement;\n applyStyle(s, overlayStyle);\n tile.ring = { key: rk, node: s };\n }\n kids.push(tile.ring.node);\n } else tile.ring = undefined;\n setChildren(el, kids);\n }\n\n // Tiles no longer shown: gone for good (fade out when animating), or just out of view.\n const present = allKeys ?? new Set(next.keys());\n for (const tile of tiles.values()) {\n if (frame.anim && mounted && !present.has(tile.key)) startLeaving(tile, frame.anim.duration);\n }\n tiles = next;\n\n // The layout element and its children.\n attr(container, \"role\", c.role ?? \"list\");\n attr(container, \"aria-label\", c.label);\n attr(container, \"class\", c.className);\n applyStyle(container, containerStyle(layout));\n const css = tileSheet({ focusRing: !!c.navigable && focusRing !== false, anim: frame.anim });\n if (sheet.textContent !== css) sheet.textContent = css;\n const top: Node[] = [];\n if (css) top.push(sheet);\n if (c.background) {\n applyStyle(backgroundEl, backgroundStyle(frame, c.background));\n top.push(backgroundEl);\n }\n const shadow = shadowShape(frame, shown.map((i) => layout.cells[i]!));\n if (shadow) {\n attr(shadowEl, \"viewBox\", shadow.viewBox);\n applyStyle(shadowEl, shadow.style);\n attr(blur, \"stdDeviation\", shadow.blur);\n attr(shadowPath, \"d\", shadow.d);\n attr(shadowPath, \"transform\", shadow.transform);\n attr(shadowPath, \"fill-opacity\", shadow.opacity);\n top.push(shadowEl);\n }\n setChildren(container, [...top, ...[...tiles.values()].map((t) => t.el), ...[...leaving].map((t) => t.el)]);\n\n lastKeys = present;\n mounted = true;\n if (pendingFocus) {\n const t = [...tiles.values()].find((x) => x.cell.id === pendingFocus);\n if (t) {\n pendingFocus = undefined;\n t.el.focus();\n }\n }\n\n // Virtualization: measure what's in view, and again whenever it may change.\n if (virtual && !stopWatching) {\n // watchView measures straight away, which can render again: mark it started first,\n // so that render doesn't start a second watcher.\n let stop: (() => void) | undefined;\n stopWatching = () => stop?.();\n stop = watchView(container, measure);\n }\n else if (!virtual && stopWatching) {\n stopWatching();\n stopWatching = undefined;\n view = undefined;\n } else if (virtual && watchedLayout !== layout) queueMicrotask(measure);\n watchedLayout = layout;\n }\n\n function measure() {\n if (destroyed || !config.virtualize) return;\n const overscan = Math.max(0, (typeof config.virtualize === \"object\" ? config.virtualize.overscan : undefined) ?? 300);\n const next = viewRect(container, layout, overscan);\n if (!sameRect(next, view)) {\n view = next;\n render();\n }\n }\n\n function startLeaving(tile: Tile, duration: number) {\n tile.leaving = true;\n const el = tile.el;\n for (const a of [\"role\", \"tabindex\", \"aria-label\", \"aria-setsize\", \"aria-posinset\", \"data-entering\"]) el.removeAttribute(a);\n el.setAttribute(\"aria-hidden\", \"true\");\n el.setAttribute(\"data-exiting\", \"\");\n leaving.add(tile);\n const timer = setTimeout(() => {\n timers.delete(timer);\n leaving.delete(tile);\n el.remove();\n }, duration);\n timers.add(timer);\n }\n\n // Events, on the layout element: which tile they're for (across shadow roots too).\n const tileOf = (e: Event): Tile | undefined => {\n for (const n of e.composedPath()) {\n if (n === container) return undefined;\n if (n instanceof Element && n.parentNode === container) {\n const t = byElement.get(n);\n return t && !t.leaving ? t : undefined;\n }\n }\n return undefined;\n };\n const setActive = (id: string) => {\n if (id === activeId) return;\n activeId = id;\n for (const t of tiles.values()) if (focusable.has(t.cell.id)) attr(t.el, \"tabindex\", t.cell.id === id ? 0 : -1);\n };\n const onClick = (e: MouseEvent) => {\n const t = tileOf(e);\n if (t && !t.empty && config.onCellActivate) config.onCellActivate(t.cell, t.state);\n };\n const onFocusIn = (e: FocusEvent) => {\n const t = tileOf(e);\n if (t && e.target === t.el && focusable.has(t.cell.id)) setActive(t.cell.id);\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.defaultPrevented || !config.navigable || e.altKey || e.ctrlKey || e.metaKey) return;\n const t = tileOf(e);\n // Only when a tile itself has focus, not an input or button inside it.\n if (!t || e.target !== t.el || !focusable.has(t.cell.id)) return;\n const action = keyAction(layout, t.cell, e.key, (cell) => focusable.has(cell.id), !!config.onCellActivate);\n if (!action) return;\n e.preventDefault();\n if (\"activate\" in action) config.onCellActivate!(t.cell, t.state);\n else if (\"move\" in action) {\n const to = action.move;\n setActive(to.id);\n const shownTile = [...tiles.values()].find((x) => x.cell.id === to.id);\n if (shownTile) shownTile.el.focus();\n else {\n // Out of view (virtualized): render it, then focus it.\n pendingFocus = to.id;\n render();\n }\n }\n };\n container.addEventListener(\"click\", onClick);\n container.addEventListener(\"focusin\", onFocusIn);\n container.addEventListener(\"keydown\", onKeyDown);\n\n render();\n\n return {\n element: container,\n get layout() {\n return layout;\n },\n update(changes) {\n config = { ...config, ...changes };\n render();\n },\n refresh: render,\n tileElement(cellId) {\n for (const t of tiles.values()) if (t.cell.id === cellId) return t.el;\n return undefined;\n },\n destroy() {\n destroyed = true;\n stopWatching?.();\n timers.forEach(clearTimeout);\n container.removeEventListener(\"click\", onClick);\n container.removeEventListener(\"focusin\", onFocusIn);\n container.removeEventListener(\"keydown\", onKeyDown);\n // Take items out of their tiles, so they can be used elsewhere.\n for (const t of [...tiles.values(), ...leaving]) {\n if (t.safe) setChildren(t.safe, []);\n setChildren(t.el, []);\n }\n container.remove();\n },\n };\n}\n\n","import type { Cell, ContentCells, ContentPlacement, Focus, Layout, LayoutOptions } from \"@andamento/core\";\nimport type { FillSource, ReliefOptions } from \"@andamento/svg\";\nimport { coverStyle, type CellState, type FitProp, type PerCell, type SafeAreaProp, type StyleMap } from \"./model\";\nimport { mountTileLayout, type TileContent, type TileLayoutConfig, type TileLayoutHandle } from \"./mount\";\n\n/** Detail of the `cellactivate` event. */\nexport interface CellActivateDetail {\n cell: Cell;\n /** Item index, as in `CellState`. */\n slot: number;\n /** The child element in the tile. */\n item: Element | undefined;\n}\n\n// Lets the module load where there's no DOM (server rendering); the element can't be used there.\nconst Base = (typeof HTMLElement === \"undefined\" ? class {} : HTMLElement) as typeof HTMLElement;\n\nconst BOOLEAN = [\"navigable\", \"animate\", \"relief\", \"safe-area\", \"virtualize\"] as const;\nconst ATTRIBUTES = [...BOOLEAN, \"options\", \"fit\", \"placement\", \"content-cells\", \"choose\", \"background\", \"fill\", \"focus-ring\", \"label\"];\n\nconst json = (v: string) => {\n try {\n return JSON.parse(v);\n } catch {\n throw new SyntaxError(`<andamento-layout>: not valid JSON: ${v}`);\n }\n};\n\nlet slotCount = 0;\n\n/**\n * `<andamento-layout>`: a tiling as a web component, for any framework or none (Angular,\n * Svelte, Solid, Lit, plain HTML). Each child element fills one tile, in reading order,\n * clipped to the tile's shape; children stay where you put them (they're shown in the\n * tiles through slots), so frameworks keep managing them.\n *\n * Set `options` (a `LayoutOptions` object, or JSON in the attribute) or `layout`. Simple\n * settings are attributes too: `navigable`, `animate`, `relief`, `safe-area`, `virtualize`,\n * `fit`, `placement`, `content-cells`, `choose`, `background`, `fill`, `focus-ring`, `label`.\n * Give children `data-aspect` (width / height) to put them in tiles of their shape, and\n * `data-focus` (\"x y\", fractions of the width and height) to keep that point of a photo in\n * view as its tile crops it (style the photo with `coverStyle`, or\n * `object-position: var(--andamento-object-position)`), and `data-weight` (how many tiles\n * it spans) to give important children featured tiles. A child\n * with `slot=\"backdrop\"` is copied into every tile as one picture across them all.\n *\n * Tiles are in the element's shadow root: style them with `::part(tile)` (also `empty`\n * and `boundary`, e.g. `andamento-layout::part(empty)`). Activating a tile fires\n * `cellactivate`, with `CellActivateDetail`.\n */\nexport class AndamentoLayoutElement extends Base {\n static observedAttributes = ATTRIBUTES;\n\n #config: TileLayoutConfig & { options?: LayoutOptions } = {};\n #props: Partial<TileLayoutConfig> = {};\n #handle?: TileLayoutHandle;\n #observer?: MutationObserver;\n #queued = false;\n #slots = new WeakMap<Element, HTMLSlotElement>();\n #items: Element[] = [];\n #backdrop?: { el: Element; make: () => Node };\n\n /** The same function for the same backdrop child, so tiles keep their copies. */\n #backdropFor(el: Element) {\n if (this.#backdrop?.el !== el) this.#backdrop = { el, make: () => copyBackdrop(el) };\n return this.#backdrop.make;\n }\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: \"open\" });\n const style = document.createElement(\"style\");\n style.textContent = \":host{display:block}:host([hidden]){display:none}\";\n root.appendChild(style);\n }\n\n /** Layout options (also the `options` attribute, as JSON). */\n get options(): LayoutOptions | undefined {\n return this.#props.options;\n }\n set options(v: LayoutOptions | undefined) {\n this.#set({ options: v });\n }\n /** A precomputed layout, instead of `options`. */\n get layout(): Layout | undefined {\n return this.#handle?.layout ?? this.#props.layout;\n }\n set layout(v: Layout | undefined) {\n this.#set({ layout: v });\n }\n /** Color of empty tiles: a color, a palette or a function per cell. */\n get fill() {\n return this.#props.fill;\n }\n set fill(v: FillSource | undefined) {\n this.#set({ fill: v });\n }\n get relief() {\n return this.#props.relief;\n }\n set relief(v: boolean | ReliefOptions | undefined) {\n this.#set({ relief: v });\n }\n /** Animate changes (the `animate` attribute; `animate` itself is the Web Animations method). */\n get animated() {\n return this.#props.animate;\n }\n set animated(v: TileLayoutConfig[\"animate\"]) {\n this.#set({ animate: v });\n }\n get virtualize() {\n return this.#props.virtualize;\n }\n set virtualize(v: TileLayoutConfig[\"virtualize\"]) {\n this.#set({ virtualize: v });\n }\n get navigable() {\n return this.#props.navigable;\n }\n set navigable(v: boolean | undefined) {\n this.#set({ navigable: v });\n }\n get safeArea() {\n return this.#props.safeArea;\n }\n set safeArea(v: SafeAreaProp | undefined) {\n this.#set({ safeArea: v });\n }\n get fit() {\n return this.#props.fit;\n }\n set fit(v: FitProp | undefined) {\n this.#set({ fit: v });\n }\n get placement() {\n return this.#props.placement;\n }\n set placement(v: ContentPlacement | undefined) {\n this.#set({ placement: v });\n }\n get contentCells() {\n return this.#props.contentCells;\n }\n set contentCells(v: ContentCells | undefined) {\n this.#set({ contentCells: v });\n }\n get choose() {\n return this.#props.choose;\n }\n set choose(v: \"placement\" | \"shape\" | undefined) {\n this.#set({ choose: v });\n }\n /** Width / height of each child; otherwise read from children's `data-aspect`. */\n get aspects() {\n return this.#props.aspects;\n }\n set aspects(v: readonly number[] | undefined) {\n this.#set({ aspects: v });\n }\n /** Tiles each child spans; otherwise read from children's `data-weight`. */\n get weights() {\n return this.#props.weights;\n }\n set weights(v: readonly number[] | undefined) {\n this.#set({ weights: v });\n }\n /** Focal point of each child; otherwise read from children's `data-focus`. */\n get focalPoints() {\n return this.#props.focalPoints;\n }\n set focalPoints(v: readonly (Focus | undefined)[] | undefined) {\n this.#set({ focalPoints: v });\n }\n get background() {\n return this.#props.background;\n }\n set background(v: string | undefined) {\n this.#set({ background: v });\n }\n get focusRing() {\n return this.#props.focusRing;\n }\n set focusRing(v: string | false | undefined) {\n this.#set({ focusRing: v });\n }\n /** Accessible name of each tile. */\n get cellLabel() {\n return this.#props.cellLabel;\n }\n set cellLabel(v: PerCell<string | undefined> | undefined) {\n this.#set({ cellLabel: v });\n }\n /** Extra style for each tile. */\n get cellStyle() {\n return this.#props.cellStyle;\n }\n set cellStyle(v: PerCell<StyleMap | undefined> | undefined) {\n this.#set({ cellStyle: v });\n }\n /** Content for empty tiles (rendered in the shadow root). */\n get fallback() {\n return this.#props.fallback;\n }\n set fallback(v: PerCell<TileContent> | undefined) {\n this.#set({ fallback: v });\n }\n\n /** The tile element (in the shadow root) showing a cell, if it's rendered. */\n tileElement(cellId: string): HTMLElement | undefined {\n return this.#handle?.tileElement(cellId);\n }\n\n connectedCallback() {\n // Children added, removed or moved, or a child's data-aspect changing; not changes\n // deeper inside children.\n this.#observer = new MutationObserver((records) => {\n if (records.some((r) => r.target === this || r.target.parentNode === this)) this.#schedule();\n });\n this.#observer.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: [\"data-aspect\", \"data-focus\", \"data-weight\", \"slot\"] });\n this.#schedule();\n }\n\n disconnectedCallback() {\n this.#observer?.disconnect();\n this.#observer = undefined;\n this.#handle?.destroy();\n this.#handle = undefined;\n }\n\n attributeChangedCallback() {\n this.#schedule();\n }\n\n #set(changes: Partial<TileLayoutConfig>) {\n this.#props = { ...this.#props, ...changes };\n this.#schedule();\n }\n\n /** Several changes in one go render once. */\n #schedule() {\n if (this.#queued) return;\n this.#queued = true;\n queueMicrotask(() => {\n this.#queued = false;\n this.#render();\n });\n }\n\n /** Render now rather than at the end of the current task (e.g. before measuring). */\n render() {\n this.#render();\n }\n\n #render() {\n if (!this.isConnected) return;\n const config = this.#configure();\n if (!config.options && !config.layout) return;\n if (this.#handle) this.#handle.update(config);\n else {\n this.#handle = mountTileLayout(this.shadowRoot!, config);\n this.#handle.element.setAttribute(\"part\", \"layout\");\n }\n }\n\n #configure(): TileLayoutConfig {\n const a = (n: string) => this.getAttribute(n);\n const flag = (n: string) => this.hasAttribute(n) && a(n) !== \"false\";\n // Every setting named, so one that's been removed is cleared (updates merge).\n const fromAttrs: Partial<TileLayoutConfig> = Object.fromEntries([...ATTRIBUTE_KEYS].map((k) => [k, undefined]));\n if (a(\"options\")) fromAttrs.options = json(a(\"options\")!);\n for (const n of BOOLEAN) if (flag(n)) (fromAttrs as Record<string, unknown>)[n === \"safe-area\" ? \"safeArea\" : n] = true;\n if (a(\"safe-area\") === \"tile\" || a(\"safe-area\") === \"visible\") fromAttrs.safeArea = a(\"safe-area\") as \"tile\" | \"visible\";\n if (a(\"fit\")) fromAttrs.fit = a(\"fit\") === \"nearest\" ? \"nearest\" : a(\"fit\") === \"false\" ? false : true;\n if (a(\"placement\")) fromAttrs.placement = a(\"placement\") as ContentPlacement;\n if (a(\"content-cells\")) fromAttrs.contentCells = a(\"content-cells\") as ContentCells;\n if (a(\"choose\")) fromAttrs.choose = a(\"choose\") as \"placement\" | \"shape\";\n if (a(\"background\")) fromAttrs.background = a(\"background\")!;\n if (a(\"fill\")) fromAttrs.fill = a(\"fill\")!.trim().startsWith(\"[\") ? json(a(\"fill\")!) : a(\"fill\")!;\n if (a(\"focus-ring\")) fromAttrs.focusRing = a(\"focus-ring\") === \"false\" ? false : a(\"focus-ring\")!;\n if (a(\"label\")) fromAttrs.label = a(\"label\")!;\n\n // Children: each element fills a tile, through a slot of its own.\n const children = [...this.children];\n const backdrop = children.find((c) => c.getAttribute(\"slot\") === \"backdrop\");\n this.#items = children.filter((c) => c !== backdrop && c.localName !== \"template\");\n const items = this.#items.map((child) => {\n let slot = this.#slots.get(child);\n if (!slot) {\n slot = document.createElement(\"slot\");\n slot.name = `andamento-${++slotCount}`;\n this.#slots.set(child, slot);\n }\n if (child.getAttribute(\"slot\") !== slot.name) child.setAttribute(\"slot\", slot.name);\n return slot;\n });\n const aspectAttrs = this.#items.map((c) => Number(c.getAttribute(\"data-aspect\")));\n const aspects = aspectAttrs.some((v) => v > 0) ? aspectAttrs.map((v) => (v > 0 ? v : 1)) : undefined;\n\n const focusAttrs = this.#items.map((c): Focus | undefined => {\n const [x, y] = (c.getAttribute(\"data-focus\") ?? \"\").trim().split(/[\\s,]+/).map(Number);\n return Number.isFinite(x) && Number.isFinite(y) && c.hasAttribute(\"data-focus\") ? { x: x!, y: y! } : undefined;\n });\n const focalPoints = focusAttrs.some(Boolean) ? focusAttrs : undefined;\n const weightAttrs = this.#items.map((c) => Number(c.getAttribute(\"data-weight\")));\n const weights = weightAttrs.some((v) => v > 1) ? weightAttrs.map((v) => (v > 0 ? v : 1)) : undefined;\n\n this.#config = {\n ...fromAttrs,\n aspects,\n focalPoints,\n weights,\n ...overrides(this.#props),\n items,\n backdrop: backdrop ? this.#backdropFor(backdrop) : undefined,\n cellAttributes: (cell: Cell, state: CellState) => ({\n part: [\"tile\", state.empty && \"empty\", cell.boundary && \"boundary\"].filter(Boolean).join(\" \"),\n }),\n onCellActivate: (cell: Cell, state: CellState) => {\n const detail: CellActivateDetail = { cell, slot: state.slot, item: this.#items[state.slot] };\n this.dispatchEvent(new CustomEvent(\"cellactivate\", { detail, bubbles: true, composed: true }));\n },\n };\n // Children with no tile (more than there are tiles) are simply not shown.\n return this.#config;\n }\n}\n\n/**\n * Properties that override attributes. One set back to undefined stays in as undefined only\n * if no attribute gives it (so it's cleared, as updates merge).\n */\nconst overrides = (props: Partial<TileLayoutConfig>): Partial<TileLayoutConfig> =>\n Object.fromEntries(Object.entries(props).filter(([k, v]) => v !== undefined || !ATTRIBUTE_KEYS.has(k)));\nconst ATTRIBUTE_KEYS = new Set([\"options\", \"navigable\", \"animate\", \"relief\", \"safeArea\", \"virtualize\", \"fit\", \"placement\", \"contentCells\", \"choose\", \"background\", \"fill\", \"focusRing\", \"label\", \"aspects\", \"focalPoints\", \"weights\"]);\n\n/** A copy of the backdrop child for one tile; pictures are made to cover it. */\nfunction copyBackdrop(el: Element): Node {\n const copy = el.cloneNode(true) as HTMLElement;\n copy.removeAttribute(\"slot\");\n if (/^(img|video|picture|canvas)$/.test(copy.localName)) {\n for (const [k, v] of Object.entries(coverStyle)) copy.style.setProperty(k.replace(/[A-Z]/g, (m) => \"-\" + m.toLowerCase()), String(v));\n }\n return copy;\n}\n\n/**\n * Register `<andamento-layout>` (or another tag name). Safe to call more than once.\n * Returns the element class.\n */\nexport function defineTileLayoutElement(tagName = \"andamento-layout\"): typeof AndamentoLayoutElement {\n if (typeof customElements === \"undefined\") return AndamentoLayoutElement;\n const existing = customElements.get(tagName);\n if (existing) return existing as unknown as typeof AndamentoLayoutElement;\n // A subclass per tag name: one class can't be registered twice.\n const cls = class extends AndamentoLayoutElement {};\n customElements.define(tagName, cls as unknown as CustomElementConstructor);\n return cls;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"andamento-layout\": AndamentoLayoutElement;\n }\n interface HTMLElementEventMap {\n cellactivate: CustomEvent<CellActivateDetail>;\n }\n}\n","import { cellAt, screenToLayout, type Cell, type HitOptions, type Layout } from \"@andamento/core\";\n\n/** The parts of a pointer or mouse event `cellFromPointer` uses. */\nexport interface PointerLike {\n clientX: number;\n clientY: number;\n currentTarget: EventTarget | null;\n}\n\n/**\n * The cell under a pointer event, for handlers on the element showing the layout (a\n * `<TileLayout>`, an `<svg>` or a canvas). Unlike handlers on each tile, it can see the\n * gaps: with `tolerance`, a pointer in the grout picks the nearest tile. Pass `element`\n * when the handler is on some other element.\n */\nexport function cellFromPointer(layout: Layout, event: PointerLike, options: HitOptions & { element?: Element } = {}): Cell | undefined {\n const el = options.element ?? (event.currentTarget as Element | null);\n if (!el || typeof (el as Element).getBoundingClientRect !== \"function\") return undefined;\n const point = screenToLayout(layout, el.getBoundingClientRect(), event.clientX, event.clientY);\n return cellAt(layout, point, options);\n}\n","/**\n * No framework: `mountTileLayout()` and the `<andamento-layout>` web component.\n *\n * @module @andamento/dom\n */\nexport { mountTileLayout } from \"./mount\";\nexport type { TileContent, TileLayoutConfig, TileLayoutHandle } from \"./mount\";\nexport { AndamentoLayoutElement, defineTileLayoutElement } from \"./element\";\nexport type { CellActivateDetail } from \"./element\";\nexport { coverStyle } from \"./model\";\nexport type { CellState, FitProp, PerCell, SafeAreaProp, StyleMap } from \"./model\";\nexport { cellFromPointer } from \"./pointer\";\nexport type { PointerLike } from \"./pointer\";\nexport { defaultPalette, neutralPalette } from \"@andamento/svg\";\nexport type { FillSource, ReliefOptions } from \"@andamento/svg\";\n"]}
@@ -0,0 +1,242 @@
1
+ import { LayoutOptions, Layout, Cell, ContentCells, ContentPlacement, Focus, HitOptions } from '@andamento/core';
2
+ import { FillSource, ReliefOptions } from '@andamento/svg';
3
+ export { FillSource, ReliefOptions, defaultPalette, neutralPalette } from '@andamento/svg';
4
+ import { S as SafeAreaProp, F as FitProp, C as CellState, P as PerCell, a as StyleMap } from './internal-NveCwJWd.cjs';
5
+ export { c as coverStyle } from './internal-NveCwJWd.cjs';
6
+
7
+ /** What can go in a tile: a DOM node, text, or nothing. */
8
+ type TileContent = Node | string | null | undefined;
9
+ interface TileLayoutConfig {
10
+ /** Layout options; or pass a precomputed `layout` instead. */
11
+ options?: LayoutOptions;
12
+ layout?: Layout;
13
+ /**
14
+ * The content: each item fills one tile, in reading order, clipped to the tile's shape.
15
+ * Nodes are moved into their tiles (and kept there as the layout changes), so pass the
16
+ * same node again to keep its state.
17
+ */
18
+ items?: readonly TileContent[];
19
+ /**
20
+ * Alternative to `items`: each tile's content from its cell, worked out on every render.
21
+ * Return the same node again to keep it. `slot` numbers the cells allowed by `contentCells`.
22
+ */
23
+ renderCell?: (cell: Cell, state: {
24
+ slot: number;
25
+ }) => TileContent;
26
+ /** Which tiles may hold content: "all" (default), "whole" (not cut by the outline) or a test. */
27
+ contentCells?: ContentCells;
28
+ /** Where items go when there are fewer than tiles: "reading" (default), "center" or "spread". */
29
+ placement?: ContentPlacement;
30
+ /** Width / height of each item, to put items in tiles of similar shape (see `matchSlots`). */
31
+ aspects?: readonly number[];
32
+ /** With `aspects`: "shape" also picks which tiles hold items by their shape. */
33
+ choose?: "placement" | "shape";
34
+ /**
35
+ * Focal point of each item (fractions of its width and height; see `estimateFocus`): what
36
+ * a photo keeps in view as its tile crops it. Each tile sets `--andamento-object-position`,
37
+ * which `coverStyle` uses; exact when the photo's shape is known (`aspects`, or the focus's `aspect`).
38
+ */
39
+ focalPoints?: readonly (Focus | undefined)[];
40
+ /**
41
+ * How many tiles each item spans (1 for an ordinary item; rounded): heavier items get a
42
+ * featured tile of that many merged tiles, where they fall in reading order (see
43
+ * `weightedLayout`). With `fit`, the tiles are sized to fit everything. Needs `options`.
44
+ */
45
+ weights?: readonly number[];
46
+ /**
47
+ * Put each tile's content in the tile's safe area, not its bounding box (see `safeArea`).
48
+ * For tiles an `edges: "window"` layout cuts, `true` or "tile" fits the whole tile and
49
+ * "visible" the part that shows.
50
+ */
51
+ safeArea?: SafeAreaProp;
52
+ /** Color of empty tiles: a color, a palette or a function per cell. Defaults to `neutralPalette`. */
53
+ fill?: FillSource;
54
+ /** Size the tiles to the items: `true`/"atLeast" or "nearest". Ignored with `layout` or `renderCell`. */
55
+ fit?: FitProp;
56
+ /**
57
+ * One picture across all the tiles: a node copied into every tile (or a function making
58
+ * a fresh one per tile), sized to the whole layout so each tile shows its piece.
59
+ */
60
+ backdrop?: Node | (() => Node);
61
+ /** Raised tiles: a lit bevel and optional shadow. `true` for the defaults. */
62
+ relief?: boolean | ReliefOptions;
63
+ /** Arrow-key navigation over the tiles with content, as one tab stop. */
64
+ navigable?: boolean;
65
+ /** Called when a tile with content is clicked, or Enter / Space pressed on it (with `navigable`). */
66
+ onCellActivate?: (cell: Cell, state: CellState) => void;
67
+ /** Accessible name for each tile. */
68
+ cellLabel?: PerCell<string | undefined>;
69
+ /** Focus ring color, or `false` for none. Defaults to "#1a56db". */
70
+ focusRing?: string | false;
71
+ /** Animate layout and content changes. `true` for 400 ms, or `{ duration, easing }`. */
72
+ animate?: boolean | {
73
+ duration?: number;
74
+ easing?: string;
75
+ };
76
+ /** Only put tiles in view (plus `overscan` pixels, default 300) in the DOM. */
77
+ virtualize?: boolean | {
78
+ overscan?: number;
79
+ };
80
+ /** Content for empty tiles. */
81
+ fallback?: PerCell<TileContent>;
82
+ /** Class for each tile element. */
83
+ cellClass?: PerCell<string | undefined>;
84
+ /** Extra style for each tile element: camelCase or custom (`--x`) properties. */
85
+ cellStyle?: PerCell<StyleMap | undefined>;
86
+ /** Extra attributes for each tile element (`part`, `title`, …). */
87
+ cellAttributes?: PerCell<Record<string, string | undefined> | undefined>;
88
+ /** Color painted across the whole region, visible through the gaps. */
89
+ background?: string;
90
+ /** Role of the layout element: "list" (default; tiles with content are list items) or another. */
91
+ role?: string;
92
+ /** Accessible name of the layout (its `aria-label`). */
93
+ label?: string;
94
+ /** Class for the layout element. */
95
+ className?: string;
96
+ }
97
+ interface TileLayoutHandle {
98
+ /** The layout element (with `data-andamento`), inside the element mounted into. */
99
+ readonly element: HTMLDivElement;
100
+ /** The layout being shown. */
101
+ readonly layout: Layout;
102
+ /** Change some options (others stay as they are; pass `undefined` to clear one) and re-render. */
103
+ update(changes: Partial<TileLayoutConfig>): void;
104
+ /** Render again, e.g. after changing what `renderCell` returns. */
105
+ refresh(): void;
106
+ /** The element of the tile showing a cell, if it's in the DOM. */
107
+ tileElement(cellId: string): HTMLElement | undefined;
108
+ /** Remove the layout (items are taken out of their tiles) and stop listening. */
109
+ destroy(): void;
110
+ }
111
+ /**
112
+ * Render a tiling into `target` (an element or a shadow root), without a framework: one
113
+ * absolutely positioned, clipped element per tile, holding the items you give it. Sized in
114
+ * percentages, so it scales with `target`'s width. Returns a handle to update or remove it.
115
+ *
116
+ * Tiles have `data-cell-id`, `data-index`, `data-empty` and `data-boundary`, as with the
117
+ * React and Vue components.
118
+ */
119
+ declare function mountTileLayout(target: Element | ShadowRoot, initial: TileLayoutConfig): TileLayoutHandle;
120
+
121
+ /** Detail of the `cellactivate` event. */
122
+ interface CellActivateDetail {
123
+ cell: Cell;
124
+ /** Item index, as in `CellState`. */
125
+ slot: number;
126
+ /** The child element in the tile. */
127
+ item: Element | undefined;
128
+ }
129
+ declare const Base: typeof HTMLElement;
130
+ /**
131
+ * `<andamento-layout>`: a tiling as a web component, for any framework or none (Angular,
132
+ * Svelte, Solid, Lit, plain HTML). Each child element fills one tile, in reading order,
133
+ * clipped to the tile's shape; children stay where you put them (they're shown in the
134
+ * tiles through slots), so frameworks keep managing them.
135
+ *
136
+ * Set `options` (a `LayoutOptions` object, or JSON in the attribute) or `layout`. Simple
137
+ * settings are attributes too: `navigable`, `animate`, `relief`, `safe-area`, `virtualize`,
138
+ * `fit`, `placement`, `content-cells`, `choose`, `background`, `fill`, `focus-ring`, `label`.
139
+ * Give children `data-aspect` (width / height) to put them in tiles of their shape, and
140
+ * `data-focus` ("x y", fractions of the width and height) to keep that point of a photo in
141
+ * view as its tile crops it (style the photo with `coverStyle`, or
142
+ * `object-position: var(--andamento-object-position)`), and `data-weight` (how many tiles
143
+ * it spans) to give important children featured tiles. A child
144
+ * with `slot="backdrop"` is copied into every tile as one picture across them all.
145
+ *
146
+ * Tiles are in the element's shadow root: style them with `::part(tile)` (also `empty`
147
+ * and `boundary`, e.g. `andamento-layout::part(empty)`). Activating a tile fires
148
+ * `cellactivate`, with `CellActivateDetail`.
149
+ */
150
+ declare class AndamentoLayoutElement extends Base {
151
+ #private;
152
+ static observedAttributes: string[];
153
+ constructor();
154
+ /** Layout options (also the `options` attribute, as JSON). */
155
+ get options(): LayoutOptions | undefined;
156
+ set options(v: LayoutOptions | undefined);
157
+ /** A precomputed layout, instead of `options`. */
158
+ get layout(): Layout | undefined;
159
+ set layout(v: Layout | undefined);
160
+ /** Color of empty tiles: a color, a palette or a function per cell. */
161
+ get fill(): FillSource | undefined;
162
+ set fill(v: FillSource | undefined);
163
+ get relief(): boolean | ReliefOptions | undefined;
164
+ set relief(v: boolean | ReliefOptions | undefined);
165
+ /** Animate changes (the `animate` attribute; `animate` itself is the Web Animations method). */
166
+ get animated(): TileLayoutConfig["animate"];
167
+ set animated(v: TileLayoutConfig["animate"]);
168
+ get virtualize(): TileLayoutConfig["virtualize"];
169
+ set virtualize(v: TileLayoutConfig["virtualize"]);
170
+ get navigable(): boolean | undefined;
171
+ set navigable(v: boolean | undefined);
172
+ get safeArea(): SafeAreaProp | undefined;
173
+ set safeArea(v: SafeAreaProp | undefined);
174
+ get fit(): FitProp | undefined;
175
+ set fit(v: FitProp | undefined);
176
+ get placement(): ContentPlacement | undefined;
177
+ set placement(v: ContentPlacement | undefined);
178
+ get contentCells(): ContentCells | undefined;
179
+ set contentCells(v: ContentCells | undefined);
180
+ get choose(): "placement" | "shape" | undefined;
181
+ set choose(v: "placement" | "shape" | undefined);
182
+ /** Width / height of each child; otherwise read from children's `data-aspect`. */
183
+ get aspects(): readonly number[] | undefined;
184
+ set aspects(v: readonly number[] | undefined);
185
+ /** Tiles each child spans; otherwise read from children's `data-weight`. */
186
+ get weights(): readonly number[] | undefined;
187
+ set weights(v: readonly number[] | undefined);
188
+ /** Focal point of each child; otherwise read from children's `data-focus`. */
189
+ get focalPoints(): readonly (Focus | undefined)[] | undefined;
190
+ set focalPoints(v: readonly (Focus | undefined)[] | undefined);
191
+ get background(): string | undefined;
192
+ set background(v: string | undefined);
193
+ get focusRing(): string | false | undefined;
194
+ set focusRing(v: string | false | undefined);
195
+ /** Accessible name of each tile. */
196
+ get cellLabel(): PerCell<string | undefined> | undefined;
197
+ set cellLabel(v: PerCell<string | undefined> | undefined);
198
+ /** Extra style for each tile. */
199
+ get cellStyle(): PerCell<StyleMap | undefined> | undefined;
200
+ set cellStyle(v: PerCell<StyleMap | undefined> | undefined);
201
+ /** Content for empty tiles (rendered in the shadow root). */
202
+ get fallback(): PerCell<TileContent> | undefined;
203
+ set fallback(v: PerCell<TileContent> | undefined);
204
+ /** The tile element (in the shadow root) showing a cell, if it's rendered. */
205
+ tileElement(cellId: string): HTMLElement | undefined;
206
+ connectedCallback(): void;
207
+ disconnectedCallback(): void;
208
+ attributeChangedCallback(): void;
209
+ /** Render now rather than at the end of the current task (e.g. before measuring). */
210
+ render(): void;
211
+ }
212
+ /**
213
+ * Register `<andamento-layout>` (or another tag name). Safe to call more than once.
214
+ * Returns the element class.
215
+ */
216
+ declare function defineTileLayoutElement(tagName?: string): typeof AndamentoLayoutElement;
217
+ declare global {
218
+ interface HTMLElementTagNameMap {
219
+ "andamento-layout": AndamentoLayoutElement;
220
+ }
221
+ interface HTMLElementEventMap {
222
+ cellactivate: CustomEvent<CellActivateDetail>;
223
+ }
224
+ }
225
+
226
+ /** The parts of a pointer or mouse event `cellFromPointer` uses. */
227
+ interface PointerLike {
228
+ clientX: number;
229
+ clientY: number;
230
+ currentTarget: EventTarget | null;
231
+ }
232
+ /**
233
+ * The cell under a pointer event, for handlers on the element showing the layout (a
234
+ * `<TileLayout>`, an `<svg>` or a canvas). Unlike handlers on each tile, it can see the
235
+ * gaps: with `tolerance`, a pointer in the grout picks the nearest tile. Pass `element`
236
+ * when the handler is on some other element.
237
+ */
238
+ declare function cellFromPointer(layout: Layout, event: PointerLike, options?: HitOptions & {
239
+ element?: Element;
240
+ }): Cell | undefined;
241
+
242
+ export { AndamentoLayoutElement, type CellActivateDetail, CellState, FitProp, PerCell, type PointerLike, SafeAreaProp, StyleMap, type TileContent, type TileLayoutConfig, type TileLayoutHandle, cellFromPointer, defineTileLayoutElement, mountTileLayout };
@@ -0,0 +1,242 @@
1
+ import { LayoutOptions, Layout, Cell, ContentCells, ContentPlacement, Focus, HitOptions } from '@andamento/core';
2
+ import { FillSource, ReliefOptions } from '@andamento/svg';
3
+ export { FillSource, ReliefOptions, defaultPalette, neutralPalette } from '@andamento/svg';
4
+ import { S as SafeAreaProp, F as FitProp, C as CellState, P as PerCell, a as StyleMap } from './internal-NveCwJWd.js';
5
+ export { c as coverStyle } from './internal-NveCwJWd.js';
6
+
7
+ /** What can go in a tile: a DOM node, text, or nothing. */
8
+ type TileContent = Node | string | null | undefined;
9
+ interface TileLayoutConfig {
10
+ /** Layout options; or pass a precomputed `layout` instead. */
11
+ options?: LayoutOptions;
12
+ layout?: Layout;
13
+ /**
14
+ * The content: each item fills one tile, in reading order, clipped to the tile's shape.
15
+ * Nodes are moved into their tiles (and kept there as the layout changes), so pass the
16
+ * same node again to keep its state.
17
+ */
18
+ items?: readonly TileContent[];
19
+ /**
20
+ * Alternative to `items`: each tile's content from its cell, worked out on every render.
21
+ * Return the same node again to keep it. `slot` numbers the cells allowed by `contentCells`.
22
+ */
23
+ renderCell?: (cell: Cell, state: {
24
+ slot: number;
25
+ }) => TileContent;
26
+ /** Which tiles may hold content: "all" (default), "whole" (not cut by the outline) or a test. */
27
+ contentCells?: ContentCells;
28
+ /** Where items go when there are fewer than tiles: "reading" (default), "center" or "spread". */
29
+ placement?: ContentPlacement;
30
+ /** Width / height of each item, to put items in tiles of similar shape (see `matchSlots`). */
31
+ aspects?: readonly number[];
32
+ /** With `aspects`: "shape" also picks which tiles hold items by their shape. */
33
+ choose?: "placement" | "shape";
34
+ /**
35
+ * Focal point of each item (fractions of its width and height; see `estimateFocus`): what
36
+ * a photo keeps in view as its tile crops it. Each tile sets `--andamento-object-position`,
37
+ * which `coverStyle` uses; exact when the photo's shape is known (`aspects`, or the focus's `aspect`).
38
+ */
39
+ focalPoints?: readonly (Focus | undefined)[];
40
+ /**
41
+ * How many tiles each item spans (1 for an ordinary item; rounded): heavier items get a
42
+ * featured tile of that many merged tiles, where they fall in reading order (see
43
+ * `weightedLayout`). With `fit`, the tiles are sized to fit everything. Needs `options`.
44
+ */
45
+ weights?: readonly number[];
46
+ /**
47
+ * Put each tile's content in the tile's safe area, not its bounding box (see `safeArea`).
48
+ * For tiles an `edges: "window"` layout cuts, `true` or "tile" fits the whole tile and
49
+ * "visible" the part that shows.
50
+ */
51
+ safeArea?: SafeAreaProp;
52
+ /** Color of empty tiles: a color, a palette or a function per cell. Defaults to `neutralPalette`. */
53
+ fill?: FillSource;
54
+ /** Size the tiles to the items: `true`/"atLeast" or "nearest". Ignored with `layout` or `renderCell`. */
55
+ fit?: FitProp;
56
+ /**
57
+ * One picture across all the tiles: a node copied into every tile (or a function making
58
+ * a fresh one per tile), sized to the whole layout so each tile shows its piece.
59
+ */
60
+ backdrop?: Node | (() => Node);
61
+ /** Raised tiles: a lit bevel and optional shadow. `true` for the defaults. */
62
+ relief?: boolean | ReliefOptions;
63
+ /** Arrow-key navigation over the tiles with content, as one tab stop. */
64
+ navigable?: boolean;
65
+ /** Called when a tile with content is clicked, or Enter / Space pressed on it (with `navigable`). */
66
+ onCellActivate?: (cell: Cell, state: CellState) => void;
67
+ /** Accessible name for each tile. */
68
+ cellLabel?: PerCell<string | undefined>;
69
+ /** Focus ring color, or `false` for none. Defaults to "#1a56db". */
70
+ focusRing?: string | false;
71
+ /** Animate layout and content changes. `true` for 400 ms, or `{ duration, easing }`. */
72
+ animate?: boolean | {
73
+ duration?: number;
74
+ easing?: string;
75
+ };
76
+ /** Only put tiles in view (plus `overscan` pixels, default 300) in the DOM. */
77
+ virtualize?: boolean | {
78
+ overscan?: number;
79
+ };
80
+ /** Content for empty tiles. */
81
+ fallback?: PerCell<TileContent>;
82
+ /** Class for each tile element. */
83
+ cellClass?: PerCell<string | undefined>;
84
+ /** Extra style for each tile element: camelCase or custom (`--x`) properties. */
85
+ cellStyle?: PerCell<StyleMap | undefined>;
86
+ /** Extra attributes for each tile element (`part`, `title`, …). */
87
+ cellAttributes?: PerCell<Record<string, string | undefined> | undefined>;
88
+ /** Color painted across the whole region, visible through the gaps. */
89
+ background?: string;
90
+ /** Role of the layout element: "list" (default; tiles with content are list items) or another. */
91
+ role?: string;
92
+ /** Accessible name of the layout (its `aria-label`). */
93
+ label?: string;
94
+ /** Class for the layout element. */
95
+ className?: string;
96
+ }
97
+ interface TileLayoutHandle {
98
+ /** The layout element (with `data-andamento`), inside the element mounted into. */
99
+ readonly element: HTMLDivElement;
100
+ /** The layout being shown. */
101
+ readonly layout: Layout;
102
+ /** Change some options (others stay as they are; pass `undefined` to clear one) and re-render. */
103
+ update(changes: Partial<TileLayoutConfig>): void;
104
+ /** Render again, e.g. after changing what `renderCell` returns. */
105
+ refresh(): void;
106
+ /** The element of the tile showing a cell, if it's in the DOM. */
107
+ tileElement(cellId: string): HTMLElement | undefined;
108
+ /** Remove the layout (items are taken out of their tiles) and stop listening. */
109
+ destroy(): void;
110
+ }
111
+ /**
112
+ * Render a tiling into `target` (an element or a shadow root), without a framework: one
113
+ * absolutely positioned, clipped element per tile, holding the items you give it. Sized in
114
+ * percentages, so it scales with `target`'s width. Returns a handle to update or remove it.
115
+ *
116
+ * Tiles have `data-cell-id`, `data-index`, `data-empty` and `data-boundary`, as with the
117
+ * React and Vue components.
118
+ */
119
+ declare function mountTileLayout(target: Element | ShadowRoot, initial: TileLayoutConfig): TileLayoutHandle;
120
+
121
+ /** Detail of the `cellactivate` event. */
122
+ interface CellActivateDetail {
123
+ cell: Cell;
124
+ /** Item index, as in `CellState`. */
125
+ slot: number;
126
+ /** The child element in the tile. */
127
+ item: Element | undefined;
128
+ }
129
+ declare const Base: typeof HTMLElement;
130
+ /**
131
+ * `<andamento-layout>`: a tiling as a web component, for any framework or none (Angular,
132
+ * Svelte, Solid, Lit, plain HTML). Each child element fills one tile, in reading order,
133
+ * clipped to the tile's shape; children stay where you put them (they're shown in the
134
+ * tiles through slots), so frameworks keep managing them.
135
+ *
136
+ * Set `options` (a `LayoutOptions` object, or JSON in the attribute) or `layout`. Simple
137
+ * settings are attributes too: `navigable`, `animate`, `relief`, `safe-area`, `virtualize`,
138
+ * `fit`, `placement`, `content-cells`, `choose`, `background`, `fill`, `focus-ring`, `label`.
139
+ * Give children `data-aspect` (width / height) to put them in tiles of their shape, and
140
+ * `data-focus` ("x y", fractions of the width and height) to keep that point of a photo in
141
+ * view as its tile crops it (style the photo with `coverStyle`, or
142
+ * `object-position: var(--andamento-object-position)`), and `data-weight` (how many tiles
143
+ * it spans) to give important children featured tiles. A child
144
+ * with `slot="backdrop"` is copied into every tile as one picture across them all.
145
+ *
146
+ * Tiles are in the element's shadow root: style them with `::part(tile)` (also `empty`
147
+ * and `boundary`, e.g. `andamento-layout::part(empty)`). Activating a tile fires
148
+ * `cellactivate`, with `CellActivateDetail`.
149
+ */
150
+ declare class AndamentoLayoutElement extends Base {
151
+ #private;
152
+ static observedAttributes: string[];
153
+ constructor();
154
+ /** Layout options (also the `options` attribute, as JSON). */
155
+ get options(): LayoutOptions | undefined;
156
+ set options(v: LayoutOptions | undefined);
157
+ /** A precomputed layout, instead of `options`. */
158
+ get layout(): Layout | undefined;
159
+ set layout(v: Layout | undefined);
160
+ /** Color of empty tiles: a color, a palette or a function per cell. */
161
+ get fill(): FillSource | undefined;
162
+ set fill(v: FillSource | undefined);
163
+ get relief(): boolean | ReliefOptions | undefined;
164
+ set relief(v: boolean | ReliefOptions | undefined);
165
+ /** Animate changes (the `animate` attribute; `animate` itself is the Web Animations method). */
166
+ get animated(): TileLayoutConfig["animate"];
167
+ set animated(v: TileLayoutConfig["animate"]);
168
+ get virtualize(): TileLayoutConfig["virtualize"];
169
+ set virtualize(v: TileLayoutConfig["virtualize"]);
170
+ get navigable(): boolean | undefined;
171
+ set navigable(v: boolean | undefined);
172
+ get safeArea(): SafeAreaProp | undefined;
173
+ set safeArea(v: SafeAreaProp | undefined);
174
+ get fit(): FitProp | undefined;
175
+ set fit(v: FitProp | undefined);
176
+ get placement(): ContentPlacement | undefined;
177
+ set placement(v: ContentPlacement | undefined);
178
+ get contentCells(): ContentCells | undefined;
179
+ set contentCells(v: ContentCells | undefined);
180
+ get choose(): "placement" | "shape" | undefined;
181
+ set choose(v: "placement" | "shape" | undefined);
182
+ /** Width / height of each child; otherwise read from children's `data-aspect`. */
183
+ get aspects(): readonly number[] | undefined;
184
+ set aspects(v: readonly number[] | undefined);
185
+ /** Tiles each child spans; otherwise read from children's `data-weight`. */
186
+ get weights(): readonly number[] | undefined;
187
+ set weights(v: readonly number[] | undefined);
188
+ /** Focal point of each child; otherwise read from children's `data-focus`. */
189
+ get focalPoints(): readonly (Focus | undefined)[] | undefined;
190
+ set focalPoints(v: readonly (Focus | undefined)[] | undefined);
191
+ get background(): string | undefined;
192
+ set background(v: string | undefined);
193
+ get focusRing(): string | false | undefined;
194
+ set focusRing(v: string | false | undefined);
195
+ /** Accessible name of each tile. */
196
+ get cellLabel(): PerCell<string | undefined> | undefined;
197
+ set cellLabel(v: PerCell<string | undefined> | undefined);
198
+ /** Extra style for each tile. */
199
+ get cellStyle(): PerCell<StyleMap | undefined> | undefined;
200
+ set cellStyle(v: PerCell<StyleMap | undefined> | undefined);
201
+ /** Content for empty tiles (rendered in the shadow root). */
202
+ get fallback(): PerCell<TileContent> | undefined;
203
+ set fallback(v: PerCell<TileContent> | undefined);
204
+ /** The tile element (in the shadow root) showing a cell, if it's rendered. */
205
+ tileElement(cellId: string): HTMLElement | undefined;
206
+ connectedCallback(): void;
207
+ disconnectedCallback(): void;
208
+ attributeChangedCallback(): void;
209
+ /** Render now rather than at the end of the current task (e.g. before measuring). */
210
+ render(): void;
211
+ }
212
+ /**
213
+ * Register `<andamento-layout>` (or another tag name). Safe to call more than once.
214
+ * Returns the element class.
215
+ */
216
+ declare function defineTileLayoutElement(tagName?: string): typeof AndamentoLayoutElement;
217
+ declare global {
218
+ interface HTMLElementTagNameMap {
219
+ "andamento-layout": AndamentoLayoutElement;
220
+ }
221
+ interface HTMLElementEventMap {
222
+ cellactivate: CustomEvent<CellActivateDetail>;
223
+ }
224
+ }
225
+
226
+ /** The parts of a pointer or mouse event `cellFromPointer` uses. */
227
+ interface PointerLike {
228
+ clientX: number;
229
+ clientY: number;
230
+ currentTarget: EventTarget | null;
231
+ }
232
+ /**
233
+ * The cell under a pointer event, for handlers on the element showing the layout (a
234
+ * `<TileLayout>`, an `<svg>` or a canvas). Unlike handlers on each tile, it can see the
235
+ * gaps: with `tolerance`, a pointer in the grout picks the nearest tile. Pass `element`
236
+ * when the handler is on some other element.
237
+ */
238
+ declare function cellFromPointer(layout: Layout, event: PointerLike, options?: HitOptions & {
239
+ element?: Element;
240
+ }): Cell | undefined;
241
+
242
+ export { AndamentoLayoutElement, type CellActivateDetail, CellState, FitProp, PerCell, type PointerLike, SafeAreaProp, StyleMap, type TileContent, type TileLayoutConfig, type TileLayoutHandle, cellFromPointer, defineTileLayoutElement, mountTileLayout };