strata-react 1.0.45 → 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/dist/index.js CHANGED
@@ -6476,12 +6476,70 @@ function PropertyList({ items, label, className }) {
6476
6476
  var GROUP_PREFIX = "⁣group⁣";
6477
6477
  var groupKey = (group) => `${GROUP_PREFIX}${group}`;
6478
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
+ }
6479
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. */
6480
6537
  var GroupedGridLayout = class extends GridLayout {
6481
6538
  headers = [];
6482
6539
  update(context) {
6483
6540
  super.update(context);
6484
- const space = (context.layoutOptions ?? {}).minSpace?.height ?? 18;
6541
+ const options = context.layoutOptions ?? {};
6542
+ const space = options.minSpace?.height ?? 18;
6485
6543
  const width = this.virtualizer.size.width;
6486
6544
  const collection = this.virtualizer.collection;
6487
6545
  const tiles = [...collection].filter((n) => !isGroupKey(n.key)).map((n) => super.getLayoutInfo(n.key)).filter((l) => l !== null);
@@ -6489,12 +6547,35 @@ var GroupedGridLayout = class extends GridLayout {
6489
6547
  const columns = Math.max(1, this.numColumns);
6490
6548
  const xs = [...collection].slice(0, columns).map((n) => super.getLayoutInfo(n.key)?.rect.x ?? 0);
6491
6549
  const tileHeight = tiles.reduce((h, t) => Math.max(h, t.rect.height), 0) || first?.rect.height || 0;
6550
+ const justify = options.justify;
6492
6551
  const next = /* @__PURE__ */ new Map();
6493
6552
  this.headers = [];
6494
6553
  let y = space;
6495
6554
  let col = 0;
6496
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
+ };
6497
6577
  const endRow = () => {
6578
+ endRun();
6498
6579
  if (!rowInfos.length) return;
6499
6580
  const h = rowInfos.reduce((m, l) => Math.max(m, l.rect.height), 0);
6500
6581
  for (const l of rowInfos) l.rect.height = h;
@@ -6517,6 +6598,14 @@ var GroupedGridLayout = class extends GridLayout {
6517
6598
  }
6518
6599
  const base = super.getLayoutInfo(node.key);
6519
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
+ }
6520
6609
  const info = base.copy();
6521
6610
  info.rect = new Rect(xs[col] ?? base.rect.x, y, base.rect.width, Math.max(tileHeight, base.rect.height));
6522
6611
  info.estimatedSize = base.estimatedSize;
@@ -6533,12 +6622,9 @@ var GroupedGridLayout = class extends GridLayout {
6533
6622
  }
6534
6623
  getVisibleLayoutInfos(rect) {
6535
6624
  const visible = super.getVisibleLayoutInfos(rect);
6536
- let current = null;
6537
- for (const h of this.headers) if (h.rect.y <= rect.y) current = h;
6538
- if (!current || current.rect.y === rect.y) return visible;
6539
- const stuck = current.copy();
6540
- stuck.rect = new Rect(0, rect.y, current.rect.width, current.rect.height);
6541
- stuck.zIndex = 10;
6625
+ const stuck = stuckHeader(this.headers, rect.y);
6626
+ if (!stuck) return visible;
6627
+ const current = stuck;
6542
6628
  return [...visible.filter((l) => l.key !== current.key), stuck];
6543
6629
  }
6544
6630
  };
@@ -6570,6 +6656,10 @@ var tileWidth = (size) => typeof size === "number" ? size : minWidth[size];
6570
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. */
6571
6657
  function tileLayoutOptions(tileSize, aspect) {
6572
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
+ };
6573
6663
  return {
6574
6664
  minItemSize: new Size(w, Math.round(w * aspectRatio[aspect]) + TILE_CHROME),
6575
6665
  minSpace: new Size(GAP, GAP)
@@ -6644,9 +6734,32 @@ function TileGridSkeleton({ count = 12, aspect = "square", tileSize = "md", clas
6644
6734
  }, i))
6645
6735
  });
6646
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
+ }
6647
6760
  // src/components/selectable-grid.tsx
6648
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`. */
6649
- 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 }) {
6650
6763
  const select = useSelectRows(rows, rowKey, selection);
6651
6764
  const shownKeys = React.useMemo(() => new Set(rows.map(rowKey)), [rows, rowKey]);
6652
6765
  const groups = React.useMemo(() => {
@@ -6664,26 +6777,51 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
6664
6777
  }));
6665
6778
  }, [rows, groupBy]);
6666
6779
  const [folded, setFolded] = React.useState(/* @__PURE__ */ new Set());
6667
- const virtual = Boolean(groups) || rows.length >= virtualizeFrom;
6780
+ const natural = aspect === "natural";
6781
+ const ratio = typeof aspect === "number" ? aspect : null;
6782
+ const virtual = natural || Boolean(groups) || rows.length >= virtualizeFrom;
6668
6783
  const px = tileWidth(tileSize);
6669
6784
  const outer = React.useRef(null);
6670
6785
  const hidden = [...selection.selected].filter((k) => !shownKeys.has(k)).length;
6671
- const keep = React.useRef(null);
6786
+ const keep = React.useRef({
6787
+ share: null,
6788
+ key: null,
6789
+ offset: 0
6790
+ });
6791
+ const pointerAt = React.useRef(null);
6672
6792
  const scrollBox = () => outer.current?.querySelector("[data-strata-scroll]") ?? null;
6673
6793
  const zoom = (next) => {
6674
6794
  if (!onTileSizeChange) return;
6675
6795
  const clamped = Math.round(Math.min(zoomRange[1], Math.max(zoomRange[0], next)));
6676
6796
  if (clamped === px) return;
6677
6797
  const box = scrollBox();
6678
- keep.current = box && box.scrollHeight > 0 ? box.scrollTop / box.scrollHeight : null;
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
+ };
6679
6806
  onTileSizeChange(clamped);
6680
6807
  };
6681
6808
  const zoomRef = React.useRef(zoom);
6682
6809
  zoomRef.current = zoom;
6683
6810
  React.useLayoutEffect(() => {
6684
6811
  const box = scrollBox();
6685
- if (box && keep.current !== null) box.scrollTop = keep.current * box.scrollHeight;
6686
- keep.current = null;
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);
6687
6825
  }, [px]);
6688
6826
  React.useEffect(() => {
6689
6827
  const el = outer.current;
@@ -6691,12 +6829,132 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
6691
6829
  const onWheel = (e) => {
6692
6830
  if (!e.ctrlKey && !e.metaKey) return;
6693
6831
  e.preventDefault();
6832
+ pointerAt.current = {
6833
+ x: e.clientX,
6834
+ y: e.clientY
6835
+ };
6694
6836
  zoomRef.current(px * (e.deltaY < 0 ? 1.1 : 1 / 1.1));
6695
6837
  };
6696
6838
  el.addEventListener("wheel", onWheel, { passive: false });
6697
6839
  return () => el.removeEventListener("wheel", onWheel);
6698
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
+ };
6699
6956
  const disabledKeys = rows.filter((r) => !(selection.isSelectable?.(r) ?? true)).map(rowKey);
6957
+ const disabledSet = new Set(disabledKeys);
6700
6958
  const shift = useShiftNote();
6701
6959
  const pressed = React.useRef(null);
6702
6960
  const notePress = (e) => void (pressed.current = e.target.closest("[data-key]")?.getAttribute("data-key") ?? null);
@@ -6715,7 +6973,25 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
6715
6973
  const picked = next === "all" ? rows.filter((r) => selection.isSelectable?.(r) ?? true).map(rowKey) : [...next].map(String).filter((k) => shownKeys.has(k));
6716
6974
  selection.onChange(/* @__PURE__ */ new Set([...outside, ...picked]));
6717
6975
  };
6718
- const layoutOptions = React.useMemo(() => tileLayoutOptions(px, aspect), [px, aspect]);
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
+ ]);
6719
6995
  const byKey = React.useMemo(() => new Map(rows.map((r) => [rowKey(r), r])), [rows, rowKey]);
6720
6996
  const indexOf = React.useMemo(() => new Map(rows.map((r, i) => [rowKey(r), i])), [rows, rowKey]);
6721
6997
  const changeOne = (next) => {
@@ -6749,15 +7025,24 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
6749
7025
  const unselectable = !(selection.isSelectable?.(row) ?? true);
6750
7026
  const why = unselectableReason && unselectable ? unselectableReason(row) : void 0;
6751
7027
  const corner = badge?.(row);
7028
+ const second = mark?.(row);
6752
7029
  return /* @__PURE__ */ jsxs(GridListItem, {
6753
7030
  id: key,
6754
7031
  textValue: name,
7032
+ "aria-label": why ? `${name}, ${why}` : void 0,
6755
7033
  "data-index": index,
6756
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"),
6757
7035
  children: [
6758
- /* @__PURE__ */ jsx("span", {
6759
- className: cn("block overflow-hidden rounded-control bg-muted *:size-full *:object-cover", aspectClass[aspect]),
6760
- children: renderImage(row)
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
+ })]
6761
7046
  }),
6762
7047
  selectionMode === "multiple" && /* @__PURE__ */ jsx(TileBox, { label: `Select ${name}` }),
6763
7048
  corner != null && /* @__PURE__ */ jsx("span", {
@@ -6831,6 +7116,11 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
6831
7116
  return /* @__PURE__ */ jsxs("div", {
6832
7117
  ref: outer,
6833
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
+ }),
6834
7124
  onMouseDownCapture: (e) => {
6835
7125
  shift.handlers.onMouseDown(e);
6836
7126
  notePress(e);
@@ -6853,28 +7143,41 @@ function SelectableGrid({ label, rows, rowKey, renderImage, detail, selection, a
6853
7143
  else return;
6854
7144
  e.preventDefault();
6855
7145
  },
6856
- children: [selectionMode === "multiple" && /* @__PURE__ */ jsxs("div", {
6857
- className: "flex flex-wrap items-center gap-3",
6858
- children: [/* @__PURE__ */ jsx(Checkbox, {
6859
- label: "Select all shown",
6860
- checked: select.all.checked,
6861
- disabled: select.all.disabled,
6862
- onCheckedChange: select.all.toggle
6863
- }), hidden > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
6864
- role: "status",
6865
- className: "type-body-sm text-muted-foreground",
6866
- children: hidden === 1 ? "1 chosen is hidden by the filter" : `${hidden} chosen are hidden by the filter`
6867
- }), /* @__PURE__ */ jsx(Button, {
6868
- size: "sm",
6869
- variant: "ghost",
6870
- onPress: () => selection.onChange(new Set([...selection.selected].filter((k) => shownKeys.has(k)))),
6871
- children: "Clear hidden"
6872
- })] })]
6873
- }), virtual ? /* @__PURE__ */ jsx(Virtualizer, {
6874
- layout: groups ? GroupedGridLayout : GridLayout,
6875
- layoutOptions,
6876
- children: grid
6877
- }) : 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
+ ]
6878
7181
  });
6879
7182
  }
6880
7183
  function TileBox({ label }) {
@@ -13089,6 +13392,7 @@ function Conversation({ label, turns, answerName, personName = "You", entities,
13089
13392
  last?.text,
13090
13393
  last?.state,
13091
13394
  last?.role,
13395
+ last?.images?.length,
13092
13396
  toBottom
13093
13397
  ]);
13094
13398
  const states = React.useRef(/* @__PURE__ */ new Map());
@@ -13135,6 +13439,33 @@ function Conversation({ label, turns, answerName, personName = "You", entities,
13135
13439
  onOpen,
13136
13440
  children: t.text
13137
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
+ }),
13138
13469
  t.state === "streaming" && t.text && /* @__PURE__ */ jsx("p", {
13139
13470
  className: "mt-1 type-caption text-muted-foreground",
13140
13471
  children: "Still writing…"
@@ -15753,6 +16084,6 @@ function MarkableText({ label, ids, marks, kinds, onMark, clearKeys = [], onCare
15753
16084
  ]
15754
16085
  });
15755
16086
  }
15756
- 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 };
15757
16088
 
15758
16089
  //# sourceMappingURL=index.js.map