strata-react 1.0.44 → 1.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/UPGRADING.md +4 -0
- package/dist/components/conversation.d.ts +14 -0
- package/dist/components/selectable-grid.d.ts +18 -6
- package/dist/components/tile-grid.d.ts +9 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +537 -127
- package/dist/index.js.map +1 -1
- package/dist/lib/grouped-grid-layout.d.ts +44 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
import { Link, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
|
|
13
13
|
import { createSortedRowModel, flexRender, rowSortingFeature, tableFeatures, useTable } from "@tanstack/react-table";
|
|
14
14
|
import { VisuallyHidden, mergeProps, useDrop, useFocusRing, useMove, useSlider, useSliderThumb } from "react-aria";
|
|
15
|
-
import { Size, useSliderState } from "react-stately";
|
|
15
|
+
import { LayoutInfo, Rect, Size, useSliderState } from "react-stately";
|
|
16
16
|
import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
17
17
|
import pixelmatch from "pixelmatch";
|
|
18
18
|
// src/lib/chords.ts
|
|
@@ -6471,6 +6471,163 @@ function PropertyList({ items, label, className }) {
|
|
|
6471
6471
|
})
|
|
6472
6472
|
});
|
|
6473
6473
|
}
|
|
6474
|
+
// src/lib/grouped-grid-layout.ts
|
|
6475
|
+
/** Keys of group headings start with this, so a tile key that is a plain id can never be mistaken for one. */
|
|
6476
|
+
var GROUP_PREFIX = "group";
|
|
6477
|
+
var groupKey = (group) => `${GROUP_PREFIX}${group}`;
|
|
6478
|
+
var isGroupKey = (key) => typeof key === "string" && key.startsWith("group");
|
|
6479
|
+
/**
|
|
6480
|
+
* Rows of equal height, each picture at its own shape (Google Photos, Lightroom): fill a row with
|
|
6481
|
+
* pictures at the target height `rowHeight` until it is full, then scale the row's height so it spans
|
|
6482
|
+
* `width` exactly. The last row of a run keeps the target height rather than stretching, so a short
|
|
6483
|
+
* run does not become giant pictures. `padding` is each tile's own padding and border, added to
|
|
6484
|
+
* every tile's width on top of the picture (the picture is `aspect` times the row's height). Returns
|
|
6485
|
+
* the placements and each row's picture height.
|
|
6486
|
+
*/
|
|
6487
|
+
function justifyRows(items, width, rowHeight, gap, padding) {
|
|
6488
|
+
const placed = [];
|
|
6489
|
+
const heights = [];
|
|
6490
|
+
let run = [];
|
|
6491
|
+
const flush = (last) => {
|
|
6492
|
+
if (!run.length) return;
|
|
6493
|
+
const sum = run.reduce((t, i) => t + i.aspect, 0);
|
|
6494
|
+
const room = width - gap * (run.length - 1) - padding * run.length;
|
|
6495
|
+
const h = last ? Math.min(rowHeight, room / sum) : room / sum;
|
|
6496
|
+
let x = 0;
|
|
6497
|
+
for (const i of run) {
|
|
6498
|
+
const w = i.aspect * h + padding;
|
|
6499
|
+
placed.push({
|
|
6500
|
+
key: i.key,
|
|
6501
|
+
x,
|
|
6502
|
+
width: w,
|
|
6503
|
+
row: heights.length
|
|
6504
|
+
});
|
|
6505
|
+
x += w + gap;
|
|
6506
|
+
}
|
|
6507
|
+
heights.push(h);
|
|
6508
|
+
run = [];
|
|
6509
|
+
};
|
|
6510
|
+
for (const item of items) {
|
|
6511
|
+
run.push(item);
|
|
6512
|
+
if (run.reduce((t, i) => t + i.aspect * rowHeight + padding, 0) + gap * (run.length - 1) >= width) flush(false);
|
|
6513
|
+
}
|
|
6514
|
+
flush(true);
|
|
6515
|
+
return {
|
|
6516
|
+
placed,
|
|
6517
|
+
heights
|
|
6518
|
+
};
|
|
6519
|
+
}
|
|
6520
|
+
/**
|
|
6521
|
+
* The copy of the heading to draw at the top of the visible area, or null when the real one is already
|
|
6522
|
+
* there. It is the last heading at or above `top`, moved to `top`, but never lower than the next
|
|
6523
|
+
* heading's top less its own height, so the next heading pushes it up as it arrives.
|
|
6524
|
+
*/
|
|
6525
|
+
function stuckHeader(headers, top) {
|
|
6526
|
+
let current = null;
|
|
6527
|
+
for (const h of headers) if (h.rect.y <= top) current = h;
|
|
6528
|
+
if (!current || current.rect.y === top) return null;
|
|
6529
|
+
const after = headers[headers.indexOf(current) + 1];
|
|
6530
|
+
const y = after ? Math.min(top, after.rect.y - current.rect.height) : top;
|
|
6531
|
+
const copy = current.copy();
|
|
6532
|
+
copy.rect = new Rect(0, y, current.rect.width, current.rect.height);
|
|
6533
|
+
copy.zIndex = 10;
|
|
6534
|
+
return copy;
|
|
6535
|
+
}
|
|
6536
|
+
/** `GridLayout` with full-width group headings (items keyed by `groupKey`) that stay at the top of the scroll box while their group is in view. */
|
|
6537
|
+
var GroupedGridLayout = class extends GridLayout {
|
|
6538
|
+
headers = [];
|
|
6539
|
+
update(context) {
|
|
6540
|
+
super.update(context);
|
|
6541
|
+
const options = context.layoutOptions ?? {};
|
|
6542
|
+
const space = options.minSpace?.height ?? 18;
|
|
6543
|
+
const width = this.virtualizer.size.width;
|
|
6544
|
+
const collection = this.virtualizer.collection;
|
|
6545
|
+
const tiles = [...collection].filter((n) => !isGroupKey(n.key)).map((n) => super.getLayoutInfo(n.key)).filter((l) => l !== null);
|
|
6546
|
+
const first = tiles[0];
|
|
6547
|
+
const columns = Math.max(1, this.numColumns);
|
|
6548
|
+
const xs = [...collection].slice(0, columns).map((n) => super.getLayoutInfo(n.key)?.rect.x ?? 0);
|
|
6549
|
+
const tileHeight = tiles.reduce((h, t) => Math.max(h, t.rect.height), 0) || first?.rect.height || 0;
|
|
6550
|
+
const justify = options.justify;
|
|
6551
|
+
const next = /* @__PURE__ */ new Map();
|
|
6552
|
+
this.headers = [];
|
|
6553
|
+
let y = space;
|
|
6554
|
+
let col = 0;
|
|
6555
|
+
let rowInfos = [];
|
|
6556
|
+
let run = [];
|
|
6557
|
+
const endRun = () => {
|
|
6558
|
+
if (!justify || !run.length) return;
|
|
6559
|
+
const { placed, heights } = justifyRows(run.map((r) => ({
|
|
6560
|
+
key: String(r.node.key),
|
|
6561
|
+
aspect: r.aspect
|
|
6562
|
+
})), width, justify.rowHeight, space, justify.padding);
|
|
6563
|
+
const byKey = new Map(run.map((r) => [String(r.node.key), r]));
|
|
6564
|
+
const tops = [];
|
|
6565
|
+
for (const h of heights) {
|
|
6566
|
+
tops.push(y);
|
|
6567
|
+
y += h + justify.chrome + space;
|
|
6568
|
+
}
|
|
6569
|
+
for (const p of placed) {
|
|
6570
|
+
const info = byKey.get(p.key).base.copy();
|
|
6571
|
+
info.rect = new Rect(p.x, tops[p.row], p.width, heights[p.row] + justify.chrome);
|
|
6572
|
+
info.estimatedSize = false;
|
|
6573
|
+
next.set(p.key, info);
|
|
6574
|
+
}
|
|
6575
|
+
run = [];
|
|
6576
|
+
};
|
|
6577
|
+
const endRow = () => {
|
|
6578
|
+
endRun();
|
|
6579
|
+
if (!rowInfos.length) return;
|
|
6580
|
+
const h = rowInfos.reduce((m, l) => Math.max(m, l.rect.height), 0);
|
|
6581
|
+
for (const l of rowInfos) l.rect.height = h;
|
|
6582
|
+
y += h + space;
|
|
6583
|
+
rowInfos = [];
|
|
6584
|
+
col = 0;
|
|
6585
|
+
};
|
|
6586
|
+
for (const node of collection) {
|
|
6587
|
+
const key = String(node.key);
|
|
6588
|
+
if (isGroupKey(key)) {
|
|
6589
|
+
endRow();
|
|
6590
|
+
const info = new LayoutInfo(node.type, key, new Rect(0, y, width, 40));
|
|
6591
|
+
info.estimatedSize = false;
|
|
6592
|
+
info.allowOverflow = true;
|
|
6593
|
+
info.content = node;
|
|
6594
|
+
next.set(key, info);
|
|
6595
|
+
this.headers.push(info);
|
|
6596
|
+
y += 40 + space;
|
|
6597
|
+
continue;
|
|
6598
|
+
}
|
|
6599
|
+
const base = super.getLayoutInfo(node.key);
|
|
6600
|
+
if (!base) continue;
|
|
6601
|
+
if (justify) {
|
|
6602
|
+
run.push({
|
|
6603
|
+
node,
|
|
6604
|
+
base,
|
|
6605
|
+
aspect: justify.aspects.get(key) ?? 1
|
|
6606
|
+
});
|
|
6607
|
+
continue;
|
|
6608
|
+
}
|
|
6609
|
+
const info = base.copy();
|
|
6610
|
+
info.rect = new Rect(xs[col] ?? base.rect.x, y, base.rect.width, Math.max(tileHeight, base.rect.height));
|
|
6611
|
+
info.estimatedSize = base.estimatedSize;
|
|
6612
|
+
next.set(key, info);
|
|
6613
|
+
rowInfos.push(info);
|
|
6614
|
+
if (++col === columns) endRow();
|
|
6615
|
+
}
|
|
6616
|
+
endRow();
|
|
6617
|
+
this.layoutInfos = next;
|
|
6618
|
+
this.contentSize = {
|
|
6619
|
+
width,
|
|
6620
|
+
height: y
|
|
6621
|
+
};
|
|
6622
|
+
}
|
|
6623
|
+
getVisibleLayoutInfos(rect) {
|
|
6624
|
+
const visible = super.getVisibleLayoutInfos(rect);
|
|
6625
|
+
const stuck = stuckHeader(this.headers, rect.y);
|
|
6626
|
+
if (!stuck) return visible;
|
|
6627
|
+
const current = stuck;
|
|
6628
|
+
return [...visible.filter((l) => l.key !== current.key), stuck];
|
|
6629
|
+
}
|
|
6630
|
+
};
|
|
6474
6631
|
// src/components/tile-grid.tsx
|
|
6475
6632
|
var minWidth = {
|
|
6476
6633
|
sm: 96,
|
|
@@ -6499,6 +6656,10 @@ var tileWidth = (size) => typeof size === "number" ? size : minWidth[size];
|
|
|
6499
6656
|
/** `GridLayout` options for tiles of this size and aspect: they grow from the minimum width to fill the row, and each row is as tall as its tallest tile as measured. */
|
|
6500
6657
|
function tileLayoutOptions(tileSize, aspect) {
|
|
6501
6658
|
const w = tileWidth(tileSize);
|
|
6659
|
+
if (typeof aspect === "number") return {
|
|
6660
|
+
minItemSize: new Size(w, Math.round(w / aspect) + TILE_CHROME),
|
|
6661
|
+
minSpace: new Size(GAP, GAP)
|
|
6662
|
+
};
|
|
6502
6663
|
return {
|
|
6503
6664
|
minItemSize: new Size(w, Math.round(w * aspectRatio[aspect]) + TILE_CHROME),
|
|
6504
6665
|
minSpace: new Size(GAP, GAP)
|
|
@@ -6573,9 +6734,32 @@ function TileGridSkeleton({ count = 12, aspect = "square", tileSize = "md", clas
|
|
|
6573
6734
|
}, i))
|
|
6574
6735
|
});
|
|
6575
6736
|
}
|
|
6737
|
+
/** The loading shape of a `SelectableGrid`: `count` picture boxes at the grid's tile size and shape, for a `DataView` skeleton. With `shapes` (widths over heights, cycled) the boxes are in rows at their own shapes, as `aspect="natural"` draws them. */
|
|
6738
|
+
function SelectableGridSkeleton({ count = 24, aspect = "square", tileSize = "md", shapes, className }) {
|
|
6739
|
+
const px = tileWidth(tileSize);
|
|
6740
|
+
if (shapes?.length) return /* @__PURE__ */ jsx("div", {
|
|
6741
|
+
"aria-hidden": true,
|
|
6742
|
+
className: cn("flex min-w-0 flex-wrap gap-3", className),
|
|
6743
|
+
children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx("div", {
|
|
6744
|
+
className: "p-1.5",
|
|
6745
|
+
style: { width: Math.round(shapes[i % shapes.length] * px) + 14 },
|
|
6746
|
+
children: /* @__PURE__ */ jsx(ThumbnailSkeleton, { aspect: shapes[i % shapes.length] })
|
|
6747
|
+
}, i))
|
|
6748
|
+
});
|
|
6749
|
+
const ratio = typeof aspect === "number" ? aspect : thumbnailAspect[aspect];
|
|
6750
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6751
|
+
"aria-hidden": true,
|
|
6752
|
+
className: cn("grid min-w-0 gap-3", className),
|
|
6753
|
+
style: { gridTemplateColumns: `repeat(auto-fill, minmax(min(${px}px, 100%), 1fr))` },
|
|
6754
|
+
children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx("div", {
|
|
6755
|
+
className: "p-1.5",
|
|
6756
|
+
children: /* @__PURE__ */ jsx(ThumbnailSkeleton, { aspect: ratio })
|
|
6757
|
+
}, i))
|
|
6758
|
+
});
|
|
6759
|
+
}
|
|
6576
6760
|
// src/components/selectable-grid.tsx
|
|
6577
6761
|
/** A grid of pictures to choose from: each tile one labelled target, "Select all shown", Shift-click ranges, virtualised from `virtualizeFrom` tiles. Pair with `useSelection` and a `BulkBar`. */
|
|
6578
|
-
function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, aspect = "square", tileSize = "md", onTileSizeChange, zoomRange = [64, 320], selectionMode = "multiple", selectionBehavior = "toggle", onAction, badge, groupBy, groupHeading, unselectableReason, virtualizeFrom = 100, maxHeight = 480, className }) {
|
|
6762
|
+
function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, aspect = "square", naturalAspect, tileSize = "md", onTileSizeChange, zoomRange = [64, 320], selectionMode = "multiple", selectionBehavior = "toggle", onAction, badge, mark, fit = "cover", groupBy, groupHeading, unselectableReason, virtualizeFrom = 100, maxHeight = 480, className }) {
|
|
6579
6763
|
const select = useSelectRows(rows, rowKey, selection);
|
|
6580
6764
|
const shownKeys = React.useMemo(() => new Set(rows.map(rowKey)), [rows, rowKey]);
|
|
6581
6765
|
const groups = React.useMemo(() => {
|
|
@@ -6593,26 +6777,51 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
|
|
|
6593
6777
|
}));
|
|
6594
6778
|
}, [rows, groupBy]);
|
|
6595
6779
|
const [folded, setFolded] = React.useState(/* @__PURE__ */ new Set());
|
|
6596
|
-
const
|
|
6780
|
+
const natural = aspect === "natural";
|
|
6781
|
+
const ratio = typeof aspect === "number" ? aspect : null;
|
|
6782
|
+
const virtual = natural || Boolean(groups) || rows.length >= virtualizeFrom;
|
|
6597
6783
|
const px = tileWidth(tileSize);
|
|
6598
6784
|
const outer = React.useRef(null);
|
|
6599
6785
|
const hidden = [...selection.selected].filter((k) => !shownKeys.has(k)).length;
|
|
6600
|
-
const keep = React.useRef(
|
|
6786
|
+
const keep = React.useRef({
|
|
6787
|
+
share: null,
|
|
6788
|
+
key: null,
|
|
6789
|
+
offset: 0
|
|
6790
|
+
});
|
|
6791
|
+
const pointerAt = React.useRef(null);
|
|
6601
6792
|
const scrollBox = () => outer.current?.querySelector("[data-strata-scroll]") ?? null;
|
|
6602
6793
|
const zoom = (next) => {
|
|
6603
6794
|
if (!onTileSizeChange) return;
|
|
6604
6795
|
const clamped = Math.round(Math.min(zoomRange[1], Math.max(zoomRange[0], next)));
|
|
6605
6796
|
if (clamped === px) return;
|
|
6606
6797
|
const box = scrollBox();
|
|
6607
|
-
|
|
6798
|
+
const p = pointerAt.current;
|
|
6799
|
+
const under = p ? document.elementFromPoint?.(p.x, p.y)?.closest("[data-key]") : null;
|
|
6800
|
+
const anchor = under && outer.current?.contains(under) ? under : document.activeElement?.closest("[data-key]") ?? null;
|
|
6801
|
+
keep.current = {
|
|
6802
|
+
share: box && box.scrollHeight > 0 ? box.scrollTop / box.scrollHeight : null,
|
|
6803
|
+
key: anchor && !isGroupKey(anchor.getAttribute("data-key")) ? anchor.getAttribute("data-key") : null,
|
|
6804
|
+
offset: box && anchor ? anchor.getBoundingClientRect().top - box.getBoundingClientRect().top : 0
|
|
6805
|
+
};
|
|
6608
6806
|
onTileSizeChange(clamped);
|
|
6609
6807
|
};
|
|
6610
6808
|
const zoomRef = React.useRef(zoom);
|
|
6611
6809
|
zoomRef.current = zoom;
|
|
6612
6810
|
React.useLayoutEffect(() => {
|
|
6613
6811
|
const box = scrollBox();
|
|
6614
|
-
|
|
6615
|
-
|
|
6812
|
+
const { share, key, offset } = keep.current;
|
|
6813
|
+
if (box && share !== null) box.scrollTop = share * box.scrollHeight;
|
|
6814
|
+
keep.current = {
|
|
6815
|
+
share: null,
|
|
6816
|
+
key: null,
|
|
6817
|
+
offset: 0
|
|
6818
|
+
};
|
|
6819
|
+
if (!box || !key) return;
|
|
6820
|
+
const frame = requestAnimationFrame(() => {
|
|
6821
|
+
const el = [...box.querySelectorAll("[data-key]")].find((n) => n.getAttribute("data-key") === key);
|
|
6822
|
+
if (el) box.scrollTop += el.getBoundingClientRect().top - box.getBoundingClientRect().top - offset;
|
|
6823
|
+
});
|
|
6824
|
+
return () => cancelAnimationFrame(frame);
|
|
6616
6825
|
}, [px]);
|
|
6617
6826
|
React.useEffect(() => {
|
|
6618
6827
|
const el = outer.current;
|
|
@@ -6620,12 +6829,132 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
|
|
|
6620
6829
|
const onWheel = (e) => {
|
|
6621
6830
|
if (!e.ctrlKey && !e.metaKey) return;
|
|
6622
6831
|
e.preventDefault();
|
|
6832
|
+
pointerAt.current = {
|
|
6833
|
+
x: e.clientX,
|
|
6834
|
+
y: e.clientY
|
|
6835
|
+
};
|
|
6623
6836
|
zoomRef.current(px * (e.deltaY < 0 ? 1.1 : 1 / 1.1));
|
|
6624
6837
|
};
|
|
6625
6838
|
el.addEventListener("wheel", onWheel, { passive: false });
|
|
6626
6839
|
return () => el.removeEventListener("wheel", onWheel);
|
|
6627
6840
|
}, [px, Boolean(onTileSizeChange)]);
|
|
6841
|
+
const pinch = React.useRef(null);
|
|
6842
|
+
React.useEffect(() => {
|
|
6843
|
+
const el = outer.current;
|
|
6844
|
+
if (!el || !onTileSizeChange) return;
|
|
6845
|
+
const distance = (t) => Math.hypot(t[0].clientX - t[1].clientX, t[0].clientY - t[1].clientY);
|
|
6846
|
+
const onStart = (e) => void (pinch.current = e.touches.length === 2 ? {
|
|
6847
|
+
distance: distance(e.touches),
|
|
6848
|
+
px
|
|
6849
|
+
} : null);
|
|
6850
|
+
const onMove = (e) => {
|
|
6851
|
+
const start = pinch.current;
|
|
6852
|
+
if (!start || e.touches.length !== 2 || start.distance === 0) return;
|
|
6853
|
+
e.preventDefault();
|
|
6854
|
+
zoomRef.current(start.px * (distance(e.touches) / start.distance));
|
|
6855
|
+
};
|
|
6856
|
+
const onEnd = (e) => void (e.touches.length < 2 && (pinch.current = null));
|
|
6857
|
+
el.addEventListener("touchstart", onStart, { passive: true });
|
|
6858
|
+
el.addEventListener("touchmove", onMove, { passive: false });
|
|
6859
|
+
el.addEventListener("touchend", onEnd);
|
|
6860
|
+
el.addEventListener("touchcancel", onEnd);
|
|
6861
|
+
return () => {
|
|
6862
|
+
el.removeEventListener("touchstart", onStart);
|
|
6863
|
+
el.removeEventListener("touchmove", onMove);
|
|
6864
|
+
el.removeEventListener("touchend", onEnd);
|
|
6865
|
+
el.removeEventListener("touchcancel", onEnd);
|
|
6866
|
+
};
|
|
6867
|
+
}, [Boolean(onTileSizeChange)]);
|
|
6868
|
+
const [marquee, setMarquee] = React.useState(null);
|
|
6869
|
+
const startMarquee = (e) => {
|
|
6870
|
+
if (selectionMode !== "multiple" || e.button !== 0 || e.pointerType === "touch") return;
|
|
6871
|
+
const target = e.target;
|
|
6872
|
+
if (!target.closest("[data-strata-scroll]") || target.closest("[data-key], button, input, a")) return;
|
|
6873
|
+
const root = outer.current;
|
|
6874
|
+
const scroller = scrollBox();
|
|
6875
|
+
if (!root || !scroller) return;
|
|
6876
|
+
const additive = e.ctrlKey || e.metaKey || e.shiftKey;
|
|
6877
|
+
const base = new Set([...selection.selected].filter((k) => additive || !shownKeys.has(k)));
|
|
6878
|
+
const origin = () => {
|
|
6879
|
+
const r = scroller.getBoundingClientRect();
|
|
6880
|
+
return {
|
|
6881
|
+
x: r.left - scroller.scrollLeft,
|
|
6882
|
+
y: r.top - scroller.scrollTop
|
|
6883
|
+
};
|
|
6884
|
+
};
|
|
6885
|
+
const o0 = origin();
|
|
6886
|
+
const start = {
|
|
6887
|
+
x: e.clientX - o0.x,
|
|
6888
|
+
y: e.clientY - o0.y
|
|
6889
|
+
};
|
|
6890
|
+
const seen = /* @__PURE__ */ new Map();
|
|
6891
|
+
let pointer = {
|
|
6892
|
+
x: e.clientX,
|
|
6893
|
+
y: e.clientY
|
|
6894
|
+
};
|
|
6895
|
+
let moved = false;
|
|
6896
|
+
let frame = 0;
|
|
6897
|
+
const update = () => {
|
|
6898
|
+
const o = origin();
|
|
6899
|
+
for (const el of root.querySelectorAll("[data-key]")) {
|
|
6900
|
+
const key = el.getAttribute("data-key");
|
|
6901
|
+
if (isGroupKey(key) || !byKey.has(key) || disabledSet.has(key)) continue;
|
|
6902
|
+
const box = el.getBoundingClientRect();
|
|
6903
|
+
seen.set(key, {
|
|
6904
|
+
l: box.left - o.x,
|
|
6905
|
+
r: box.right - o.x,
|
|
6906
|
+
t: box.top - o.y,
|
|
6907
|
+
b: box.bottom - o.y
|
|
6908
|
+
});
|
|
6909
|
+
}
|
|
6910
|
+
const cur = {
|
|
6911
|
+
x: pointer.x - o.x,
|
|
6912
|
+
y: pointer.y - o.y
|
|
6913
|
+
};
|
|
6914
|
+
const l = Math.min(start.x, cur.x), r = Math.max(start.x, cur.x), t = Math.min(start.y, cur.y), b = Math.max(start.y, cur.y);
|
|
6915
|
+
const chosen = new Set(base);
|
|
6916
|
+
for (const [key, box] of seen) if (box.l < r && box.r > l && box.t < b && box.b > t) chosen.add(key);
|
|
6917
|
+
selection.onChange(chosen);
|
|
6918
|
+
setMarquee({
|
|
6919
|
+
x0: start.x + o.x,
|
|
6920
|
+
y0: start.y + o.y,
|
|
6921
|
+
x1: pointer.x,
|
|
6922
|
+
y1: pointer.y
|
|
6923
|
+
});
|
|
6924
|
+
};
|
|
6925
|
+
const tick = () => {
|
|
6926
|
+
const r = scroller.getBoundingClientRect();
|
|
6927
|
+
const edge = 40;
|
|
6928
|
+
const delta = pointer.y < r.top + edge ? -(r.top + edge - pointer.y) : pointer.y > r.bottom - edge ? pointer.y - (r.bottom - edge) : 0;
|
|
6929
|
+
if (delta) scroller.scrollTop += Math.max(-24, Math.min(24, delta / 2));
|
|
6930
|
+
update();
|
|
6931
|
+
frame = requestAnimationFrame(tick);
|
|
6932
|
+
};
|
|
6933
|
+
const move = (m) => {
|
|
6934
|
+
pointer = {
|
|
6935
|
+
x: m.clientX,
|
|
6936
|
+
y: m.clientY
|
|
6937
|
+
};
|
|
6938
|
+
if (!moved && Math.hypot(m.clientX - e.clientX, m.clientY - e.clientY) < 4) return;
|
|
6939
|
+
if (!moved) {
|
|
6940
|
+
moved = true;
|
|
6941
|
+
frame = requestAnimationFrame(tick);
|
|
6942
|
+
}
|
|
6943
|
+
update();
|
|
6944
|
+
};
|
|
6945
|
+
const up = () => {
|
|
6946
|
+
cancelAnimationFrame(frame);
|
|
6947
|
+
window.removeEventListener("pointermove", move);
|
|
6948
|
+
window.removeEventListener("pointerup", up);
|
|
6949
|
+
window.removeEventListener("pointercancel", up);
|
|
6950
|
+
setMarquee(null);
|
|
6951
|
+
};
|
|
6952
|
+
window.addEventListener("pointermove", move);
|
|
6953
|
+
window.addEventListener("pointerup", up);
|
|
6954
|
+
window.addEventListener("pointercancel", up);
|
|
6955
|
+
};
|
|
6628
6956
|
const disabledKeys = rows.filter((r) => !(selection.isSelectable?.(r) ?? true)).map(rowKey);
|
|
6957
|
+
const disabledSet = new Set(disabledKeys);
|
|
6629
6958
|
const shift = useShiftNote();
|
|
6630
6959
|
const pressed = React.useRef(null);
|
|
6631
6960
|
const notePress = (e) => void (pressed.current = e.target.closest("[data-key]")?.getAttribute("data-key") ?? null);
|
|
@@ -6644,7 +6973,25 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
|
|
|
6644
6973
|
const picked = next === "all" ? rows.filter((r) => selection.isSelectable?.(r) ?? true).map(rowKey) : [...next].map(String).filter((k) => shownKeys.has(k));
|
|
6645
6974
|
selection.onChange(/* @__PURE__ */ new Set([...outside, ...picked]));
|
|
6646
6975
|
};
|
|
6647
|
-
const
|
|
6976
|
+
const hasDetail = Boolean(detail);
|
|
6977
|
+
const layoutOptions = React.useMemo(() => {
|
|
6978
|
+
if (aspect !== "natural") return tileLayoutOptions(px, aspect);
|
|
6979
|
+
const aspects = new Map(rows.map((r) => [rowKey(r), Math.max(.1, naturalAspect?.(r) ?? 1)]));
|
|
6980
|
+
return {
|
|
6981
|
+
...tileLayoutOptions(px, "square"),
|
|
6982
|
+
justify: {
|
|
6983
|
+
aspects,
|
|
6984
|
+
rowHeight: px,
|
|
6985
|
+
padding: 14,
|
|
6986
|
+
chrome: hasDetail ? 40 : 14
|
|
6987
|
+
}
|
|
6988
|
+
};
|
|
6989
|
+
}, [
|
|
6990
|
+
px,
|
|
6991
|
+
aspect,
|
|
6992
|
+
rows,
|
|
6993
|
+
hasDetail
|
|
6994
|
+
]);
|
|
6648
6995
|
const byKey = React.useMemo(() => new Map(rows.map((r) => [rowKey(r), r])), [rows, rowKey]);
|
|
6649
6996
|
const indexOf = React.useMemo(() => new Map(rows.map((r, i) => [rowKey(r), i])), [rows, rowKey]);
|
|
6650
6997
|
const changeOne = (next) => {
|
|
@@ -6652,55 +6999,128 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
|
|
|
6652
6999
|
const picked = next === "all" ? [] : [...next].map(String).filter((k) => shownKeys.has(k));
|
|
6653
7000
|
selection.onChange(/* @__PURE__ */ new Set([...outside, ...picked.slice(-1)]));
|
|
6654
7001
|
};
|
|
6655
|
-
const
|
|
6656
|
-
|
|
7002
|
+
const selectableIn = (list) => list.filter((r) => selection.isSelectable?.(r) ?? true).map(rowKey);
|
|
7003
|
+
const groupChecked = (list) => {
|
|
7004
|
+
const keys = selectableIn(list);
|
|
7005
|
+
const chosen = keys.filter((k) => selection.selected.has(k)).length;
|
|
7006
|
+
return chosen === 0 ? false : chosen === keys.length ? true : "mixed";
|
|
7007
|
+
};
|
|
7008
|
+
const toggleGroup = (list) => {
|
|
7009
|
+
const next = new Set(selection.selected);
|
|
7010
|
+
const on = groupChecked(list) === false;
|
|
7011
|
+
for (const k of selectableIn(list)) if (on) next.add(k);
|
|
7012
|
+
else next.delete(k);
|
|
7013
|
+
selection.onChange(next);
|
|
7014
|
+
};
|
|
7015
|
+
const foldGroup = (key) => setFolded((f) => {
|
|
7016
|
+
const n = new Set(f);
|
|
7017
|
+
if (n.has(key)) n.delete(key);
|
|
7018
|
+
else n.add(key);
|
|
7019
|
+
return n;
|
|
7020
|
+
});
|
|
7021
|
+
const tile = (row) => {
|
|
7022
|
+
const key = rowKey(row);
|
|
7023
|
+
const index = indexOf.get(key) ?? 0;
|
|
7024
|
+
const name = selection.rowLabel(row);
|
|
7025
|
+
const unselectable = !(selection.isSelectable?.(row) ?? true);
|
|
7026
|
+
const why = unselectableReason && unselectable ? unselectableReason(row) : void 0;
|
|
7027
|
+
const corner = badge?.(row);
|
|
7028
|
+
const second = mark?.(row);
|
|
7029
|
+
return /* @__PURE__ */ jsxs(GridListItem, {
|
|
7030
|
+
id: key,
|
|
7031
|
+
textValue: name,
|
|
7032
|
+
"aria-label": why ? `${name}, ${why}` : void 0,
|
|
7033
|
+
"data-index": index,
|
|
7034
|
+
className: cn("group relative grid min-w-0 gap-1.5 rounded-surface border border-transparent p-1.5 select-none outline-offset-2 transition-state", "selected:border-primary selected:bg-surface-sunken", unselectable ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-surface-sunken"),
|
|
7035
|
+
children: [
|
|
7036
|
+
/* @__PURE__ */ jsxs("span", {
|
|
7037
|
+
className: "relative block",
|
|
7038
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
7039
|
+
className: cn("block overflow-hidden rounded-control bg-muted *:size-full", fit === "contain" ? "*:object-contain" : "*:object-cover", !natural && ratio === null && aspectClass[aspect]),
|
|
7040
|
+
style: natural ? { aspectRatio: Math.max(.1, naturalAspect?.(row) ?? 1) } : ratio !== null ? { aspectRatio: ratio } : void 0,
|
|
7041
|
+
children: renderImage(row)
|
|
7042
|
+
}), second != null && /* @__PURE__ */ jsx("span", {
|
|
7043
|
+
className: "absolute right-1.5 bottom-1.5 rounded-control bg-background/90 px-1.5 type-caption text-foreground tabular-nums",
|
|
7044
|
+
children: second
|
|
7045
|
+
})]
|
|
7046
|
+
}),
|
|
7047
|
+
selectionMode === "multiple" && /* @__PURE__ */ jsx(TileBox, { label: `Select ${name}` }),
|
|
7048
|
+
corner != null && /* @__PURE__ */ jsx("span", {
|
|
7049
|
+
className: "absolute top-3 right-3",
|
|
7050
|
+
children: corner
|
|
7051
|
+
}),
|
|
7052
|
+
detail?.(row) != null && /* @__PURE__ */ jsx("span", {
|
|
7053
|
+
className: "truncate type-body-sm text-muted-foreground",
|
|
7054
|
+
children: detail(row)
|
|
7055
|
+
}),
|
|
7056
|
+
why && /* @__PURE__ */ jsx("span", {
|
|
7057
|
+
className: "truncate type-caption text-muted-foreground",
|
|
7058
|
+
children: why
|
|
7059
|
+
})
|
|
7060
|
+
]
|
|
7061
|
+
}, key);
|
|
7062
|
+
};
|
|
7063
|
+
const header = (g) => {
|
|
7064
|
+
const heading = groupHeading ? groupHeading(g.key, g.rows) : g.key;
|
|
7065
|
+
const isFolded = folded.has(g.key);
|
|
7066
|
+
return /* @__PURE__ */ jsxs(GridListItem, {
|
|
7067
|
+
id: groupKey(g.key),
|
|
7068
|
+
textValue: heading,
|
|
7069
|
+
onAction: () => foldGroup(g.key),
|
|
7070
|
+
className: "flex min-w-0 items-center gap-2 bg-background outline-offset-[-2px]",
|
|
7071
|
+
children: [
|
|
7072
|
+
/* @__PURE__ */ jsx(Button, {
|
|
7073
|
+
size: "sm",
|
|
7074
|
+
variant: "ghost",
|
|
7075
|
+
"aria-expanded": !isFolded,
|
|
7076
|
+
"aria-label": `${isFolded ? "Unfold" : "Fold"} ${heading}`,
|
|
7077
|
+
onPress: () => foldGroup(g.key),
|
|
7078
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {
|
|
7079
|
+
"aria-hidden": true,
|
|
7080
|
+
className: cn("transition-state", isFolded && "-rotate-90")
|
|
7081
|
+
})
|
|
7082
|
+
}),
|
|
7083
|
+
selectionMode === "multiple" && /* @__PURE__ */ jsx(Checkbox, {
|
|
7084
|
+
label: `Select ${heading}`,
|
|
7085
|
+
hideLabel: true,
|
|
7086
|
+
checked: groupChecked(g.rows),
|
|
7087
|
+
disabled: selectableIn(g.rows).length === 0,
|
|
7088
|
+
onCheckedChange: () => toggleGroup(g.rows)
|
|
7089
|
+
}),
|
|
7090
|
+
/* @__PURE__ */ jsx("h3", {
|
|
7091
|
+
className: "type-label",
|
|
7092
|
+
children: heading
|
|
7093
|
+
}),
|
|
7094
|
+
/* @__PURE__ */ jsx("span", {
|
|
7095
|
+
className: "type-caption text-muted-foreground tabular-nums",
|
|
7096
|
+
children: g.rows.length
|
|
7097
|
+
})
|
|
7098
|
+
]
|
|
7099
|
+
}, groupKey(g.key));
|
|
7100
|
+
};
|
|
7101
|
+
const grid = /* @__PURE__ */ jsx(GridList, {
|
|
7102
|
+
"aria-label": label,
|
|
6657
7103
|
layout: "grid",
|
|
6658
7104
|
selectionMode,
|
|
6659
7105
|
selectionBehavior,
|
|
7106
|
+
disabledBehavior: "selection",
|
|
6660
7107
|
selectedKeys: new Set([...selection.selected].filter((k) => shownKeys.has(k))),
|
|
6661
7108
|
onSelectionChange: selectionMode === "single" ? changeOne : changeSelection,
|
|
6662
7109
|
onAction: onAction ? (key) => void (byKey.has(String(key)) && onAction(byKey.get(String(key)))) : void 0,
|
|
6663
|
-
disabledKeys,
|
|
6664
|
-
"data-strata-scroll":
|
|
6665
|
-
className: cn("min-w-0 outline-none", virtual
|
|
6666
|
-
style: virtual
|
|
6667
|
-
children:
|
|
6668
|
-
const key = rowKey(row);
|
|
6669
|
-
const index = indexOf.get(key) ?? 0;
|
|
6670
|
-
const name = selection.rowLabel(row);
|
|
6671
|
-
const why = unselectableReason && !(selection.isSelectable?.(row) ?? true) ? unselectableReason(row) : void 0;
|
|
6672
|
-
const corner = badge?.(row);
|
|
6673
|
-
return /* @__PURE__ */ jsxs(GridListItem, {
|
|
6674
|
-
id: key,
|
|
6675
|
-
textValue: name,
|
|
6676
|
-
"data-index": index,
|
|
6677
|
-
className: cn("group relative grid min-w-0 gap-1.5 rounded-surface border border-transparent p-1.5 select-none outline-offset-2 transition-state", "selected:border-primary selected:bg-surface-sunken disabled:cursor-not-allowed disabled:opacity-50", "cursor-pointer hover:bg-surface-sunken disabled:hover:bg-transparent"),
|
|
6678
|
-
children: [
|
|
6679
|
-
/* @__PURE__ */ jsx("span", {
|
|
6680
|
-
className: cn("block overflow-hidden rounded-control bg-muted *:size-full *:object-cover", aspectClass[aspect]),
|
|
6681
|
-
children: renderImage(row)
|
|
6682
|
-
}),
|
|
6683
|
-
selectionMode === "multiple" && /* @__PURE__ */ jsx(TileBox, { label: `Select ${name}` }),
|
|
6684
|
-
corner != null && /* @__PURE__ */ jsx("span", {
|
|
6685
|
-
className: "absolute top-3 right-3",
|
|
6686
|
-
children: corner
|
|
6687
|
-
}),
|
|
6688
|
-
detail?.(row) != null && /* @__PURE__ */ jsx("span", {
|
|
6689
|
-
className: "truncate type-body-sm text-muted-foreground",
|
|
6690
|
-
children: detail(row)
|
|
6691
|
-
}),
|
|
6692
|
-
why && /* @__PURE__ */ jsx("span", {
|
|
6693
|
-
className: "truncate type-caption text-muted-foreground",
|
|
6694
|
-
children: why
|
|
6695
|
-
})
|
|
6696
|
-
]
|
|
6697
|
-
}, key);
|
|
6698
|
-
})
|
|
7110
|
+
disabledKeys: groups ? [...disabledKeys, ...groups.map((g) => groupKey(g.key))] : disabledKeys,
|
|
7111
|
+
"data-strata-scroll": "",
|
|
7112
|
+
className: cn("min-w-0 outline-none", virtual ? "overflow-y-auto" : "grid gap-3"),
|
|
7113
|
+
style: virtual ? { height: maxHeight } : { gridTemplateColumns: `repeat(auto-fill, minmax(min(${px}px, 100%), 1fr))` },
|
|
7114
|
+
children: groups ? groups.map((g) => [header(g), ...folded.has(g.key) ? [] : g.rows.map(tile)]) : rows.map(tile)
|
|
6699
7115
|
});
|
|
6700
|
-
const grid = groups ? null : list(rows, true);
|
|
6701
7116
|
return /* @__PURE__ */ jsxs("div", {
|
|
6702
7117
|
ref: outer,
|
|
6703
7118
|
className: cn("grid min-w-0 gap-3", className),
|
|
7119
|
+
onPointerDown: startMarquee,
|
|
7120
|
+
onPointerMove: (e) => void (pointerAt.current = {
|
|
7121
|
+
x: e.clientX,
|
|
7122
|
+
y: e.clientY
|
|
7123
|
+
}),
|
|
6704
7124
|
onMouseDownCapture: (e) => {
|
|
6705
7125
|
shift.handlers.onMouseDown(e);
|
|
6706
7126
|
notePress(e);
|
|
@@ -6708,6 +7128,12 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
|
|
|
6708
7128
|
onKeyDownCapture: (e) => {
|
|
6709
7129
|
shift.handlers.onKeyDown(e);
|
|
6710
7130
|
notePress(e);
|
|
7131
|
+
const onHeader = e.target.closest("[data-key]")?.getAttribute("data-key");
|
|
7132
|
+
if (e.key === " " && groups && isGroupKey(onHeader) && e.target.getAttribute("data-key") === onHeader && selectionMode === "multiple") {
|
|
7133
|
+
toggleGroup(groups.find((g) => groupKey(g.key) === onHeader)?.rows ?? []);
|
|
7134
|
+
e.preventDefault();
|
|
7135
|
+
e.stopPropagation();
|
|
7136
|
+
}
|
|
6711
7137
|
},
|
|
6712
7138
|
onKeyDown: (e) => {
|
|
6713
7139
|
if (isTypingTarget(e.target) || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
@@ -6717,47 +7143,41 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
|
|
|
6717
7143
|
else return;
|
|
6718
7144
|
e.preventDefault();
|
|
6719
7145
|
},
|
|
6720
|
-
children: [
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
}, g.key))
|
|
6756
|
-
}) : virtual ? /* @__PURE__ */ jsx(Virtualizer, {
|
|
6757
|
-
layout: GridLayout,
|
|
6758
|
-
layoutOptions,
|
|
6759
|
-
children: grid
|
|
6760
|
-
}) : grid]
|
|
7146
|
+
children: [
|
|
7147
|
+
selectionMode === "multiple" && /* @__PURE__ */ jsxs("div", {
|
|
7148
|
+
className: "flex flex-wrap items-center gap-3",
|
|
7149
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
7150
|
+
label: "Select all shown",
|
|
7151
|
+
checked: select.all.checked,
|
|
7152
|
+
disabled: select.all.disabled,
|
|
7153
|
+
onCheckedChange: select.all.toggle
|
|
7154
|
+
}), hidden > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
7155
|
+
role: "status",
|
|
7156
|
+
className: "type-body-sm text-muted-foreground",
|
|
7157
|
+
children: hidden === 1 ? "1 chosen is hidden by the filter" : `${hidden} chosen are hidden by the filter`
|
|
7158
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
7159
|
+
size: "sm",
|
|
7160
|
+
variant: "ghost",
|
|
7161
|
+
onPress: () => selection.onChange(new Set([...selection.selected].filter((k) => shownKeys.has(k)))),
|
|
7162
|
+
children: "Clear hidden"
|
|
7163
|
+
})] })]
|
|
7164
|
+
}),
|
|
7165
|
+
marquee && /* @__PURE__ */ jsx("div", {
|
|
7166
|
+
"aria-hidden": true,
|
|
7167
|
+
className: "pointer-events-none fixed z-50 border border-primary bg-primary/10",
|
|
7168
|
+
style: {
|
|
7169
|
+
left: Math.min(marquee.x0, marquee.x1),
|
|
7170
|
+
top: Math.min(marquee.y0, marquee.y1),
|
|
7171
|
+
width: Math.abs(marquee.x1 - marquee.x0),
|
|
7172
|
+
height: Math.abs(marquee.y1 - marquee.y0)
|
|
7173
|
+
}
|
|
7174
|
+
}),
|
|
7175
|
+
virtual ? /* @__PURE__ */ jsx(Virtualizer, {
|
|
7176
|
+
layout: groups || natural ? GroupedGridLayout : GridLayout,
|
|
7177
|
+
layoutOptions,
|
|
7178
|
+
children: grid
|
|
7179
|
+
}) : grid
|
|
7180
|
+
]
|
|
6761
7181
|
});
|
|
6762
7182
|
}
|
|
6763
7183
|
function TileBox({ label }) {
|
|
@@ -6778,44 +7198,6 @@ function TileBox({ label }) {
|
|
|
6778
7198
|
})
|
|
6779
7199
|
});
|
|
6780
7200
|
}
|
|
6781
|
-
function GroupSection({ heading, rows, rowKey, selection, folded, onFold, multiple, children }) {
|
|
6782
|
-
const group = useSelectRows(rows, rowKey, selection);
|
|
6783
|
-
return /* @__PURE__ */ jsxs("section", {
|
|
6784
|
-
"aria-label": heading,
|
|
6785
|
-
className: "grid gap-2 pb-3",
|
|
6786
|
-
children: [/* @__PURE__ */ jsxs("header", {
|
|
6787
|
-
className: "sticky top-0 z-10 flex items-center gap-2 bg-background py-1",
|
|
6788
|
-
children: [
|
|
6789
|
-
/* @__PURE__ */ jsx(Button, {
|
|
6790
|
-
size: "sm",
|
|
6791
|
-
variant: "ghost",
|
|
6792
|
-
"aria-expanded": !folded,
|
|
6793
|
-
"aria-label": `${folded ? "Unfold" : "Fold"} ${heading}`,
|
|
6794
|
-
onPress: onFold,
|
|
6795
|
-
children: /* @__PURE__ */ jsx(ChevronDown, {
|
|
6796
|
-
"aria-hidden": true,
|
|
6797
|
-
className: cn("transition-state", folded && "-rotate-90")
|
|
6798
|
-
})
|
|
6799
|
-
}),
|
|
6800
|
-
multiple && /* @__PURE__ */ jsx(Checkbox, {
|
|
6801
|
-
label: `Select ${heading}`,
|
|
6802
|
-
hideLabel: true,
|
|
6803
|
-
checked: group.all.checked,
|
|
6804
|
-
disabled: group.all.disabled,
|
|
6805
|
-
onCheckedChange: group.all.toggle
|
|
6806
|
-
}),
|
|
6807
|
-
/* @__PURE__ */ jsx("h3", {
|
|
6808
|
-
className: "type-label",
|
|
6809
|
-
children: heading
|
|
6810
|
-
}),
|
|
6811
|
-
/* @__PURE__ */ jsx("span", {
|
|
6812
|
-
className: "type-caption text-muted-foreground tabular-nums",
|
|
6813
|
-
children: rows.length
|
|
6814
|
-
})
|
|
6815
|
-
]
|
|
6816
|
-
}), !folded && children]
|
|
6817
|
-
});
|
|
6818
|
-
}
|
|
6819
7201
|
// src/lib/viewport.ts
|
|
6820
7202
|
/** The picture fitted in its frame, not panned. */
|
|
6821
7203
|
var FIT = {
|
|
@@ -13010,6 +13392,7 @@ function Conversation({ label, turns, answerName, personName = "You", entities,
|
|
|
13010
13392
|
last?.text,
|
|
13011
13393
|
last?.state,
|
|
13012
13394
|
last?.role,
|
|
13395
|
+
last?.images?.length,
|
|
13013
13396
|
toBottom
|
|
13014
13397
|
]);
|
|
13015
13398
|
const states = React.useRef(/* @__PURE__ */ new Map());
|
|
@@ -13056,6 +13439,33 @@ function Conversation({ label, turns, answerName, personName = "You", entities,
|
|
|
13056
13439
|
onOpen,
|
|
13057
13440
|
children: t.text
|
|
13058
13441
|
}),
|
|
13442
|
+
t.images && t.images.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
13443
|
+
className: "mt-2 flex flex-wrap gap-2",
|
|
13444
|
+
children: t.images.map((im, i) => {
|
|
13445
|
+
const pic = /* @__PURE__ */ jsx(Thumbnail, {
|
|
13446
|
+
src: im.src,
|
|
13447
|
+
alt: im.label,
|
|
13448
|
+
missing: "Picture not available",
|
|
13449
|
+
aspect: im.aspect ?? "16/9",
|
|
13450
|
+
fit: "contain",
|
|
13451
|
+
className: "w-56 max-w-full rounded-control bg-muted"
|
|
13452
|
+
});
|
|
13453
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
13454
|
+
className: "flex max-w-full flex-col gap-1",
|
|
13455
|
+
children: [im.href ? /* @__PURE__ */ jsx("a", {
|
|
13456
|
+
href: im.href,
|
|
13457
|
+
target: "_blank",
|
|
13458
|
+
rel: "noreferrer",
|
|
13459
|
+
"aria-label": `${im.label} (full size, opens in a new tab)`,
|
|
13460
|
+
className: "rounded-control",
|
|
13461
|
+
children: pic
|
|
13462
|
+
}) : pic, /* @__PURE__ */ jsx("span", {
|
|
13463
|
+
className: "type-caption text-muted-foreground",
|
|
13464
|
+
children: im.label
|
|
13465
|
+
})]
|
|
13466
|
+
}, `${i}-${im.src}`);
|
|
13467
|
+
})
|
|
13468
|
+
}),
|
|
13059
13469
|
t.state === "streaming" && t.text && /* @__PURE__ */ jsx("p", {
|
|
13060
13470
|
className: "mt-1 type-caption text-muted-foreground",
|
|
13061
13471
|
children: "Still writing…"
|
|
@@ -15674,6 +16084,6 @@ function MarkableText({ label, ids, marks, kinds, onMark, clearKeys = [], onCare
|
|
|
15674
16084
|
]
|
|
15675
16085
|
});
|
|
15676
16086
|
}
|
|
15677
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlayWindowButton, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, SaveStatus, SecretField, SeekBar, SelectableGrid, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, gainToVolume, geo, gridPoints, gutterOf, isDoubtful, isReservedChord, isTypingTarget, jobProgressText, joinMediaGroup, joinRects, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, phraseDoubtful, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, splitRect, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkspaceState, valueAt, viewOf, viewsOf, wordAt, zoomAt, zoomToBox };
|
|
16087
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlayWindowButton, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, SaveStatus, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, gainToVolume, geo, gridPoints, gutterOf, isDoubtful, isReservedChord, isTypingTarget, jobProgressText, joinMediaGroup, joinRects, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, phraseDoubtful, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, splitRect, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkspaceState, valueAt, viewOf, viewsOf, wordAt, zoomAt, zoomToBox };
|
|
15678
16088
|
|
|
15679
16089
|
//# sourceMappingURL=index.js.map
|