@cloudgrid-io/ui 0.69.0 → 0.71.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.
Files changed (99) hide show
  1. package/dist/badge/marks.d.ts +2 -0
  2. package/dist/badge/marks.d.ts.map +1 -1
  3. package/dist/badge/marks.js +5 -0
  4. package/dist/badge/marks.js.map +1 -1
  5. package/dist/badge/watermark.js +2 -2
  6. package/dist/badge/watermark.js.map +1 -1
  7. package/dist/blocks/add-tile.d.ts +17 -12
  8. package/dist/blocks/add-tile.d.ts.map +1 -1
  9. package/dist/blocks/add-tile.js +26 -14
  10. package/dist/blocks/add-tile.js.map +1 -1
  11. package/dist/blocks/browse-categories.d.ts +80 -0
  12. package/dist/blocks/browse-categories.d.ts.map +1 -0
  13. package/dist/blocks/browse-categories.js +106 -0
  14. package/dist/blocks/browse-categories.js.map +1 -0
  15. package/dist/blocks/creation-search.d.ts +145 -102
  16. package/dist/blocks/creation-search.d.ts.map +1 -1
  17. package/dist/blocks/creation-search.js +503 -125
  18. package/dist/blocks/creation-search.js.map +1 -1
  19. package/dist/blocks/empty-creations.d.ts +29 -2
  20. package/dist/blocks/empty-creations.d.ts.map +1 -1
  21. package/dist/blocks/empty-creations.js +38 -14
  22. package/dist/blocks/empty-creations.js.map +1 -1
  23. package/dist/blocks/entity-card.d.ts +5 -1
  24. package/dist/blocks/entity-card.d.ts.map +1 -1
  25. package/dist/blocks/entity-card.js +3 -2
  26. package/dist/blocks/entity-card.js.map +1 -1
  27. package/dist/blocks/feed-row.d.ts +92 -0
  28. package/dist/blocks/feed-row.d.ts.map +1 -0
  29. package/dist/blocks/feed-row.js +30 -0
  30. package/dist/blocks/feed-row.js.map +1 -0
  31. package/dist/blocks/filter-tabs.d.ts +12 -1
  32. package/dist/blocks/filter-tabs.d.ts.map +1 -1
  33. package/dist/blocks/filter-tabs.js +11 -2
  34. package/dist/blocks/filter-tabs.js.map +1 -1
  35. package/dist/blocks/greeting.d.ts +42 -0
  36. package/dist/blocks/greeting.d.ts.map +1 -0
  37. package/dist/blocks/greeting.js +38 -0
  38. package/dist/blocks/greeting.js.map +1 -0
  39. package/dist/blocks/home-bento.d.ts +11 -4
  40. package/dist/blocks/home-bento.d.ts.map +1 -1
  41. package/dist/blocks/home-bento.js +22 -6
  42. package/dist/blocks/home-bento.js.map +1 -1
  43. package/dist/blocks/home-pinned.d.ts +137 -24
  44. package/dist/blocks/home-pinned.d.ts.map +1 -1
  45. package/dist/blocks/home-pinned.js +285 -38
  46. package/dist/blocks/home-pinned.js.map +1 -1
  47. package/dist/blocks/icons.d.ts +54 -6
  48. package/dist/blocks/icons.d.ts.map +1 -1
  49. package/dist/blocks/icons.js +67 -6
  50. package/dist/blocks/icons.js.map +1 -1
  51. package/dist/blocks/impact-card.d.ts +114 -0
  52. package/dist/blocks/impact-card.d.ts.map +1 -0
  53. package/dist/blocks/impact-card.js +57 -0
  54. package/dist/blocks/impact-card.js.map +1 -0
  55. package/dist/blocks/inspiration-cards.d.ts +234 -5
  56. package/dist/blocks/inspiration-cards.d.ts.map +1 -1
  57. package/dist/blocks/inspiration-cards.js +289 -8
  58. package/dist/blocks/inspiration-cards.js.map +1 -1
  59. package/dist/blocks/inspiration-gallery.d.ts +139 -0
  60. package/dist/blocks/inspiration-gallery.d.ts.map +1 -0
  61. package/dist/blocks/inspiration-gallery.js +189 -0
  62. package/dist/blocks/inspiration-gallery.js.map +1 -0
  63. package/dist/blocks/jump-back-in.d.ts +251 -0
  64. package/dist/blocks/jump-back-in.d.ts.map +1 -0
  65. package/dist/blocks/jump-back-in.js +275 -0
  66. package/dist/blocks/jump-back-in.js.map +1 -0
  67. package/dist/blocks/load-more-grid.d.ts +125 -0
  68. package/dist/blocks/load-more-grid.d.ts.map +1 -0
  69. package/dist/blocks/load-more-grid.js +157 -0
  70. package/dist/blocks/load-more-grid.js.map +1 -0
  71. package/dist/blocks/menu-trigger.d.ts +7 -2
  72. package/dist/blocks/menu-trigger.d.ts.map +1 -1
  73. package/dist/blocks/menu-trigger.js +2 -0
  74. package/dist/blocks/menu-trigger.js.map +1 -1
  75. package/dist/blocks/phosphor-marks.d.ts +17 -1
  76. package/dist/blocks/phosphor-marks.d.ts.map +1 -1
  77. package/dist/blocks/phosphor-marks.js +25 -1
  78. package/dist/blocks/phosphor-marks.js.map +1 -1
  79. package/dist/blocks/pin-mark.d.ts +40 -0
  80. package/dist/blocks/pin-mark.d.ts.map +1 -0
  81. package/dist/blocks/pin-mark.js +40 -0
  82. package/dist/blocks/pin-mark.js.map +1 -0
  83. package/dist/blocks/start-card.d.ts +76 -0
  84. package/dist/blocks/start-card.d.ts.map +1 -0
  85. package/dist/blocks/start-card.js +82 -0
  86. package/dist/blocks/start-card.js.map +1 -0
  87. package/dist/blocks/stat-tile.d.ts +20 -19
  88. package/dist/blocks/stat-tile.d.ts.map +1 -1
  89. package/dist/blocks/stat-tile.js +32 -3
  90. package/dist/blocks/stat-tile.js.map +1 -1
  91. package/dist/index.d.ts +9 -0
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +9 -0
  94. package/dist/index.js.map +1 -1
  95. package/dist/lib/motion.d.ts +14 -0
  96. package/dist/lib/motion.d.ts.map +1 -1
  97. package/dist/lib/motion.js +4 -0
  98. package/dist/lib/motion.js.map +1 -1
  99. package/package.json +1 -1
@@ -0,0 +1,275 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../lib/cloudgrid-cn.js";
5
+ import { ActionLink } from "./action-link.js";
6
+ import { formatChartNumber } from "./chart-parts.js";
7
+ import { Button } from "../ui/button.js";
8
+ import { Dialog, DialogClose, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../ui/dialog.js";
9
+ import { FilterTab, FilterTabs } from "./filter-tabs.js";
10
+ import { PinnedCreations, RecentlyOpened } from "./home-pinned.js";
11
+ import { CloseIcon, ForwardIcon, PlusIcon } from "./icons.js";
12
+ import { PinMark } from "./pin-mark.js";
13
+ import { Skeleton } from "../ui/skeleton.js";
14
+ import { PictureOverIdentity, THUMBNAIL_WITH_IDENTITY, ThumbnailIdentity } from "../lib/thumbnail-identity.js";
15
+ /**
16
+ * JUMP BACK IN (ui#605, Asaf's design for console#1182, 2026-11-25, on top of
17
+ * Tamir's issue): the block both front pages place, and its "See all" window.
18
+ *
19
+ * Presentational, as the Home's pieces are: the pins, the recent opens, the
20
+ * window's rows and every handler are the caller's; nothing here fetches, and
21
+ * nothing here decides what is pinned.
22
+ *
23
+ * ## The block (`JumpBackIn`)
24
+ *
25
+ * One card, in the Home's card shell, the one every Home card wears
26
+ * (`BentoCard`'s look, class for class): `bg-card`, the hairline edge
27
+ * (`border-hairline`), radius 12 (`rounded-md`), 24 inside, no shadow. The
28
+ * issue first said radius 20 with the card shadow; the lead corrected it.
29
+ *
30
+ * header "Jump back in" at the Home's section title size (the
31
+ * `BentoCard` title: 20 bold on a 28 line), and 12 after it the
32
+ * line "Your pins, then what you opened last." in Small, muted
33
+ * (`text-faint-strong`); on a narrow card the line wraps under
34
+ * the title. At the far right, with `onSeeAll`, "See all N" and
35
+ * the arrow: the Home's teal text link (`ActionLink`, bold, the
36
+ * 16 arrow 6 after the words), a button that calls `onSeeAll`;
37
+ * the caller opens `JumpBackInWindow`
38
+ * Pinned "Pinned · N", a small label (Small, muted) after the outline
39
+ * pin, then `PinnedCreations` at its small size
40
+ * (`size="small"`, Asaf, 2026-11-26): the same small My
41
+ * creations cards, as many as fit at 192 or more (five of
42
+ * about 206 at the Console's 1440), sharing the row to its
43
+ * edge or the arrow, the arrows, the Unpin chip on hover, and
44
+ * one "Pin a creation" slot after the last pin (ui#622; none
45
+ * at six), My creations' empty card with the push pin: grey at
46
+ * rest, cyan on hover, where the pin stands up; at zero pins a
47
+ * muted line beside it. Its other props pass through untouched
48
+ * Recently "Recently opened", the same small label, then the recent
49
+ * opened opens as tiles (`RecentlyOpened layout="tiles"`): four in a
50
+ * row, two where four do not fit, one on a phone; on hover the
51
+ * pin chip, "Pin it" or "Unpin" (ui#622), with `onPin` and
52
+ * `onUnpin`
53
+ * spacing 16 between the header and the parts, 12 from a label to its row
54
+ *
55
+ * Each part can be absent. No `recent`, or none yet (the recent opens route is
56
+ * not live), and Recently opened is not drawn at all, not even its empty
57
+ * line. No `pinned` and Pinned is not drawn; an empty list is Pinned's own
58
+ * empty state, the one slot and its line.
59
+ *
60
+ * ## The window (`JumpBackInWindow`)
61
+ *
62
+ * The library's dialog, 680 wide where there is room (the search window's
63
+ * width, ui#531): the title "Everything you can open", the line "N creations
64
+ * across the spaces you belong to.", the tabs (`FilterTabs`): All with its
65
+ * count, Pinned with its count, Recently opened; and the rows. A row is the
66
+ * picture (64 by 40 at 8, the tiles' picture), the name, and under it "owner ·
67
+ * space · Opened 2h ago" (each part when known), the whole row the creation's
68
+ * link; at its end "Pinned" after the filled pin, or "+ Pin". With `onUnpin`
69
+ * "Pinned" is a button that unpins; with `onPin`, "+ Pin" pins. Both sit above
70
+ * the row's link, never inside it.
71
+ *
72
+ * The tabs filter the rows the caller gives (`jumpBackInRows`): All, every
73
+ * row; Pinned, those `pinned`; Recently opened, those with an `opened`. A
74
+ * caller that loads each tab's own rows (`onTabChange`) passes them as they
75
+ * come; the filter then changes nothing. A row whose id came before is never
76
+ * drawn again, so a page that repeats one cannot show it twice.
77
+ *
78
+ * It loads more as the reader scrolls: the rows are their own scrolling box,
79
+ * and when the reader is within 160 of its end (`JUMP_BACK_IN_LOAD_MARGIN`),
80
+ * or the rows do not fill it, `onLoadMore` is called, once for each count of
81
+ * the caller's rows, so a page that brings nothing the tab shows, or only
82
+ * repeats, still counts as come (`jumpBackInShouldLoad`,
83
+ * `jumpBackInLoadSettled`, `jumpBackInLoadAsk`). A load that ended without
84
+ * new rows (a failed page) is asked again on the reader's next scroll, wheel
85
+ * or touch on the rows, or tab, never by itself; not while `loading`, not without `hasMore`,
86
+ * and not again until the caller's rows have grown. While
87
+ * `loading`, a skeleton row stands at the end. Not in this cut: Edit pins,
88
+ * search, "Most used".
89
+ *
90
+ * An overlay: it portals to the body, out of any surface scope, so it is the
91
+ * white popover on the card, the panel and ink alike.
92
+ *
93
+ * ## Tokens
94
+ *
95
+ * the label Small (`text-caption`) in `text-faint-strong`, the 16 outline
96
+ * pin in `text-faint` (`PinMark`, tilted)
97
+ * Pinned the 15 filled pin, upright (`PinMark pinned`, ui#622), in the
98
+ * accent role, "Pinned" in Small, muted
99
+ * + Pin Small Medium in the accent role, the 14 plus before it
100
+ * the rows 60 tall, 2 apart, radius 8, the hover wash
101
+ */
102
+ /** Every line the block and the window write, as the design writes them. */
103
+ export const JUMP_BACK_IN_COPY = {
104
+ title: "Jump back in",
105
+ line: "Your pins, then what you opened last.",
106
+ seeAll: "See all",
107
+ pinned: "Pinned",
108
+ recent: "Recently opened",
109
+ windowTitle: "Everything you can open",
110
+ tabsLabel: "Filter what you can open",
111
+ tabAll: "All",
112
+ tabPinned: "Pinned",
113
+ tabRecent: "Recently opened",
114
+ rowPinned: "Pinned",
115
+ rowPin: "Pin",
116
+ rowUnpin: "unpin",
117
+ loading: "Loading more",
118
+ emptyAll: "Creations you can open will appear here.",
119
+ emptyPinned: "Nothing pinned yet. Pin a creation and it stays here.",
120
+ emptyRecent: "Creations you open will appear here.",
121
+ };
122
+ /** The window's line: "15 creations across the spaces you belong to." */
123
+ export function jumpBackInWindowLine(count) {
124
+ return `${formatChartNumber(count)} ${count === 1 ? "creation" : "creations"} across the spaces you belong to.`;
125
+ }
126
+ /**
127
+ * The rows a tab shows, in the caller's order: All every row, Pinned the
128
+ * pinned, Recently opened those with an `opened`. A row whose id came before
129
+ * is left out, so nothing shows twice.
130
+ */
131
+ export function jumpBackInRows(rows, tab) {
132
+ const seen = new Set();
133
+ const out = [];
134
+ for (const row of rows) {
135
+ if (seen.has(row.id))
136
+ continue;
137
+ seen.add(row.id);
138
+ if (tab === "pinned" && row.pinned !== true)
139
+ continue;
140
+ if (tab === "recent" && (row.opened === undefined || row.opened === null))
141
+ continue;
142
+ out.push(row);
143
+ }
144
+ return out;
145
+ }
146
+ /** How near the end of the rows, in px, the reader is when the next page is asked for. */
147
+ export const JUMP_BACK_IN_LOAD_MARGIN = 160;
148
+ /**
149
+ * Whether to ask for the next page: the reader is within `margin` of the end
150
+ * of the rows' box (or the rows do not fill it), there is more, nothing is
151
+ * loading, and either the rows have grown since the last ask (`count` and
152
+ * `askedAt` are the caller's rows, `rows.length`, not the rows a tab shows:
153
+ * a page that brings nothing the tab shows, or only repeats, still came), or
154
+ * the last load ended without new rows (`stalled`, a failed page) and the
155
+ * reader has just acted on the rows (`reader`: a scroll, a wheel or a touch on
156
+ * them, or a tab). A stalled load is never asked again by itself, so a
157
+ * failing feed is not asked in a loop (Nataly's review, PR #613).
158
+ */
159
+ export function jumpBackInShouldLoad(view, state, margin = JUMP_BACK_IN_LOAD_MARGIN) {
160
+ if (!state.hasMore || state.loading)
161
+ return false;
162
+ const grown = state.askedAt === null || state.count > state.askedAt;
163
+ if (!grown && !(state.stalled === true && state.reader === true))
164
+ return false;
165
+ return view.scrollHeight - view.scrollTop - view.clientHeight <= margin;
166
+ }
167
+ /** The bookkeeping before the first ask. */
168
+ export const JUMP_BACK_IN_LOAD_START = { askedAt: null, stalled: false, wasLoading: false };
169
+ /**
170
+ * The bookkeeping after a render with `rows` and `loading`: a load that has
171
+ * just ended with no more rows than when it was asked is stalled; a list
172
+ * shorter than at the last ask was replaced (a new tab's own rows, a reset),
173
+ * so it starts over.
174
+ */
175
+ export function jumpBackInLoadSettled(track, rows, loading) {
176
+ if (track.askedAt !== null && rows.length < track.askedAt)
177
+ return { askedAt: null, stalled: false, wasLoading: loading };
178
+ const ended = track.wasLoading && !loading;
179
+ const stalled = ended ? track.askedAt !== null && rows.length <= track.askedAt : track.stalled;
180
+ return { askedAt: track.askedAt, stalled, wasLoading: loading };
181
+ }
182
+ /**
183
+ * Whether to ask for the next page now, by `jumpBackInShouldLoad` with the
184
+ * caller's own `rows`: the bookkeeping after the ask, or null for no ask.
185
+ */
186
+ export function jumpBackInLoadAsk(view, track, now) {
187
+ const state = { hasMore: now.hasMore, loading: now.loading, count: now.rows.length, askedAt: track.askedAt, stalled: track.stalled, reader: now.reader };
188
+ if (!jumpBackInShouldLoad(view, state))
189
+ return null;
190
+ return { askedAt: now.rows.length, stalled: false, wasLoading: track.wasLoading };
191
+ }
192
+ /** The small label over a part: Small, muted. */
193
+ const PART_LABEL = "m-0 flex min-w-0 items-center gap-1.5 text-caption font-normal text-faint-strong";
194
+ function JumpBackIn({ pinned, pinnedCount, recent, onUnpin, onAddPin, onPin, onOpen, onSeeAll, seeAllCount, linkComponent, title = JUMP_BACK_IN_COPY.title, line = JUMP_BACK_IN_COPY.line, seeAllLabel = JUMP_BACK_IN_COPY.seeAll, pinnedLabel = JUMP_BACK_IN_COPY.pinned, recentLabel = JUMP_BACK_IN_COPY.recent, level = 2, className, ...props }) {
195
+ const id = React.useId();
196
+ const Heading = `h${level}`;
197
+ const Label = `h${level + 1}`;
198
+ const count = pinnedCount ?? pinned?.length ?? 0;
199
+ return (_jsxs("section", { "data-slot": "jump-back-in", "aria-labelledby": id, className: cn("flex min-w-0 flex-col gap-4 rounded-md border border-hairline bg-card p-6 text-ink", className), ...props, children: [_jsxs("div", { "data-slot": "jump-back-in-header", className: "flex min-w-0 items-baseline justify-between gap-3", children: [_jsxs("div", { "data-slot": "jump-back-in-heading", className: "flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1", children: [_jsx(Heading, { id: id, "data-slot": "jump-back-in-title", className: "m-0 min-w-0 text-heading-md leading-7 font-bold text-ink", children: title }), line !== undefined && line !== null ? (_jsx("p", { "data-slot": "jump-back-in-line", className: "m-0 min-w-0 text-caption text-faint-strong", children: line })) : null] }), onSeeAll ? (_jsxs(ActionLink, { "data-slot": "jump-back-in-see-all", weight: "bold", render: _jsx("button", { type: "button", "aria-haspopup": "dialog", onClick: () => onSeeAll() }), className: "shrink-0 cursor-pointer gap-1.5 whitespace-nowrap", children: [seeAllCount === undefined ? seeAllLabel : `${seeAllLabel} ${formatChartNumber(seeAllCount)}`, _jsx(ForwardIcon, { className: "size-4" })] })) : null] }), pinned !== undefined ? (_jsxs("div", { "data-slot": "jump-back-in-pinned", className: "flex min-w-0 flex-col gap-3", children: [_jsxs(Label, { "data-slot": "jump-back-in-pinned-label", className: PART_LABEL, children: [_jsx(PinMark, { className: "size-4 text-faint" }), _jsxs("span", { children: [pinnedLabel, " \u00B7 ", formatChartNumber(count)] })] }), _jsx(PinnedCreations, { size: "small", items: pinned, onUnpin: onUnpin, onOpen: onOpen, onAddPin: onAddPin, linkComponent: linkComponent })] })) : null, recent !== undefined && recent.length > 0 ? (_jsxs("div", { "data-slot": "jump-back-in-recent", className: "flex min-w-0 flex-col gap-3", children: [_jsx(Label, { "data-slot": "jump-back-in-recent-label", className: PART_LABEL, children: recentLabel }), _jsx(RecentlyOpened, { layout: "tiles", items: recent, onOpen: onOpen, onPin: onPin, onUnpin: onUnpin, linkComponent: linkComponent })] })) : null] }));
200
+ }
201
+ /** A window row's picture: the tiles' 64 by 40 at 8, the identity under it with a `seed`. */
202
+ const ROW_THUMBNAIL = "block h-10 w-16 shrink-0 overflow-hidden rounded-xs bg-raised";
203
+ /** The row's link covers the row (its `::after`); the keyboard frame is drawn on that cover. */
204
+ const ROW_LINK = cn("flex min-w-0 flex-1 items-center gap-3 text-start outline-none", "after:absolute after:inset-0 after:rounded-xs after:content-['']", "focus-key:after:outline-1 focus-key:after:outline-offset-2 focus-key:after:outline-(--ring) focus-key:after:outline-solid");
205
+ /** "Pinned" and "+ Pin": above the row's link. */
206
+ const ROW_END = "relative z-10 inline-flex shrink-0 items-center gap-1 rounded-2xs text-caption outline-none focus-line";
207
+ function RowOpener({ row, onOpen, linkComponent, children, }) {
208
+ if (row.href !== undefined) {
209
+ const Link = linkComponent ?? "a";
210
+ return (_jsx(Link, { href: row.href, "data-slot": "jump-back-in-row-link", className: cn("text-ink no-underline", ROW_LINK), children: children }));
211
+ }
212
+ if (onOpen) {
213
+ return (_jsx("button", { type: "button", "data-slot": "jump-back-in-row-link", onClick: () => onOpen(row), className: cn("cursor-pointer text-ink", ROW_LINK), children: children }));
214
+ }
215
+ return (_jsx("div", { "data-slot": "jump-back-in-row-link", className: ROW_LINK, children: children }));
216
+ }
217
+ function WindowRow({ row, onPin, onUnpin, onOpen, linkComponent, }) {
218
+ const meta = [row.owner, row.space, row.opened].filter((part) => part !== undefined && part !== null && part !== "");
219
+ return (_jsxs("li", { "data-slot": "jump-back-in-row", className: "relative flex h-15 min-w-0 items-center gap-3 rounded-xs px-2 hover:bg-(--cg-hover)", children: [_jsxs(RowOpener, { row: row, onOpen: onOpen, linkComponent: linkComponent, children: [_jsxs("span", { "data-slot": "jump-back-in-row-thumbnail", className: row.seed === undefined ? ROW_THUMBNAIL : `${ROW_THUMBNAIL} ${THUMBNAIL_WITH_IDENTITY}`, children: [row.seed !== undefined ? _jsx(ThumbnailIdentity, { seed: row.seed, name: row.name, size: "thumb" }) : null, row.thumbnailSrc !== undefined && row.seed !== undefined ? (_jsx(PictureOverIdentity, { src: row.thumbnailSrc, alt: "", decoding: "async", draggable: false, className: "block size-full object-cover object-top" })) : row.thumbnailSrc !== undefined ? (_jsx("img", { src: row.thumbnailSrc, alt: "", decoding: "async", draggable: false, className: "block size-full object-cover object-top" })) : null] }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsx("span", { "data-slot": "jump-back-in-row-name", className: "min-w-0 truncate text-body-sm font-medium text-ink", children: row.name }), meta.length > 0 ? (_jsx("span", { "data-slot": "jump-back-in-row-meta", className: "min-w-0 truncate text-caption text-faint-strong", children: meta.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 ? " · " : null, part] }, i))) })) : null] })] }), row.pinned === true ? (onUnpin ? (_jsxs("button", { type: "button", "data-slot": "jump-back-in-row-pinned", "aria-label": `${JUMP_BACK_IN_COPY.rowPinned}, ${JUMP_BACK_IN_COPY.rowUnpin} ${row.name}`, onClick: () => onUnpin(row), className: cn(ROW_END, "cursor-pointer text-faint-strong hover:text-ink"), children: [_jsx(PinMark, { pinned: true, className: "size-3.75 text-(--cg-text-accent)" }), JUMP_BACK_IN_COPY.rowPinned] })) : (_jsxs("span", { "data-slot": "jump-back-in-row-pinned", className: cn(ROW_END, "text-faint-strong"), children: [_jsx(PinMark, { pinned: true, className: "size-3.75 text-(--cg-text-accent)" }), JUMP_BACK_IN_COPY.rowPinned] }))) : onPin ? (_jsxs("button", { type: "button", "data-slot": "jump-back-in-row-pin", onClick: () => onPin(row), className: cn(ROW_END, "cursor-pointer font-medium text-(--cg-text-accent) hover:underline underline-offset-4"), children: [_jsx(PlusIcon, { className: "size-3.5 shrink-0" }), JUMP_BACK_IN_COPY.rowPin, _jsx("span", { className: "sr-only", children: ` ${row.name}` })] })) : null] }));
220
+ }
221
+ /**
222
+ * Every control in the block and the window shows the hand (Asaf's standing
223
+ * rule); a tab that is disabled keeps the arrow. `FilterTab` draws none of
224
+ * its own, so the window's tabs add it.
225
+ */
226
+ const TAB_HAND = "enabled:cursor-pointer";
227
+ /** The skeleton row at the end while the next page loads. */
228
+ function SkeletonRow() {
229
+ return (_jsxs("li", { "data-slot": "jump-back-in-row-skeleton", "aria-hidden": "true", className: "flex h-15 min-w-0 items-center gap-3 px-2", children: [_jsx(Skeleton, { className: "h-10 w-16 shrink-0 rounded-xs" }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsx(Skeleton, { className: "h-3.5 w-2/5 rounded-2xs" }), _jsx(Skeleton, { className: "h-3 w-3/5 rounded-2xs" })] })] }));
230
+ }
231
+ function JumpBackInWindow({ open, onOpenChange, rows, total, pinnedCount, tab: tabProp, defaultTab = "all", onTabChange, hasMore = false, loading = false, onLoadMore, onPin, onUnpin, onOpen, linkComponent, title = JUMP_BACK_IN_COPY.windowTitle, line, className, }) {
232
+ const [ownTab, setOwnTab] = React.useState(defaultTab);
233
+ const tab = tabProp ?? ownTab;
234
+ const shown = jumpBackInRows(rows, tab);
235
+ const pinned = pinnedCount ?? jumpBackInRows(rows, "pinned").length;
236
+ // The rows' box, once the dialog has mounted it: the popup mounts after
237
+ // `open` turns true, so a ref read in that commit would still be empty.
238
+ const [box, setBox] = React.useState(null);
239
+ // The paging bookkeeping, on the caller's own rows (all of them, not the
240
+ // tab's), so a page that brings nothing the tab shows still counts as come.
241
+ const track = React.useRef(JUMP_BACK_IN_LOAD_START);
242
+ const check = React.useCallback((reader) => {
243
+ if (!box || !onLoadMore)
244
+ return;
245
+ const next = jumpBackInLoadAsk(box, track.current, { rows, hasMore, loading, reader });
246
+ if (!next)
247
+ return;
248
+ track.current = next;
249
+ onLoadMore();
250
+ }, [box, rows, hasMore, loading, onLoadMore]);
251
+ // Each render: settle the bookkeeping (a load that ended without new rows
252
+ // is stalled), then ask if the box is at its end, which rows that do not
253
+ // fill it are. A stalled load waits for the reader. A new tab is the
254
+ // reader's act.
255
+ const lastTab = React.useRef(tab);
256
+ React.useEffect(() => {
257
+ track.current = jumpBackInLoadSettled(track.current, rows, loading);
258
+ const tabbed = lastTab.current !== tab;
259
+ lastTab.current = tab;
260
+ check(tabbed);
261
+ }, [check, rows, loading, tab]);
262
+ // The reader acting on the rows: a scroll, a wheel or a touch on them.
263
+ const byReader = () => check(true);
264
+ const pick = (next) => {
265
+ const value = next;
266
+ if (tabProp === undefined)
267
+ setOwnTab(value);
268
+ onTabChange?.(value);
269
+ box?.scrollTo?.({ top: 0 });
270
+ };
271
+ const empty = tab === "pinned" ? JUMP_BACK_IN_COPY.emptyPinned : tab === "recent" ? JUMP_BACK_IN_COPY.emptyRecent : JUMP_BACK_IN_COPY.emptyAll;
272
+ return (_jsx(Dialog, { open: open, onOpenChange: (next) => onOpenChange(next), children: _jsxs(DialogContent, { "data-slot": "jump-back-in-window", showCloseButton: false, className: cn("flex max-h-[min(calc(100svh-2rem),45rem)] flex-col gap-4 overflow-hidden sm:max-w-170", className), children: [_jsxs(DialogClose, { "data-slot": "dialog-close", render: _jsx(Button, { variant: "ghost", size: "icon", className: "absolute top-5 right-6.5 cursor-pointer text-ink" }), children: [_jsx(CloseIcon, { className: "size-5" }), _jsx("span", { className: "sr-only", children: "Close" })] }), _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { "data-slot": "jump-back-in-window-title", children: title }), _jsx(DialogDescription, { "data-slot": "jump-back-in-window-line", className: "text-faint-strong", children: line ?? jumpBackInWindowLine(total) })] }), _jsxs(FilterTabs, { label: JUMP_BACK_IN_COPY.tabsLabel, value: tab, onValueChange: pick, className: "flex-wrap", children: [_jsx(FilterTab, { value: "all", count: total, className: TAB_HAND, children: JUMP_BACK_IN_COPY.tabAll }), _jsx(FilterTab, { value: "pinned", count: pinned, className: TAB_HAND, children: JUMP_BACK_IN_COPY.tabPinned }), _jsx(FilterTab, { value: "recent", className: TAB_HAND, children: JUMP_BACK_IN_COPY.tabRecent })] }), shown.length === 0 && !loading ? (_jsx("p", { "data-slot": "jump-back-in-window-empty", className: "m-0 py-6 text-center text-body-sm text-faint-strong", children: empty })) : null, _jsxs("ul", { ref: setBox, "data-slot": "jump-back-in-window-rows", "aria-busy": loading ? true : undefined, onScroll: byReader, onWheel: byReader, onTouchMove: byReader, className: cn("-mx-2 my-0 grid min-h-0 flex-1 list-none content-start gap-0.5 overflow-y-auto p-0", shown.length === 0 && !loading && "hidden"), children: [shown.map((row) => (_jsx(WindowRow, { row: row, onPin: onPin, onUnpin: onUnpin, onOpen: onOpen, linkComponent: linkComponent }, row.id))), loading ? _jsx(SkeletonRow, {}) : null] }), loading ? (_jsx("span", { role: "status", className: "sr-only", children: JUMP_BACK_IN_COPY.loading })) : null] }) }));
273
+ }
274
+ export { JumpBackIn, JumpBackInWindow };
275
+ //# sourceMappingURL=jump-back-in.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jump-back-in.js","sourceRoot":"","sources":["../../src/blocks/jump-back-in.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAE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CAAC,CAClB,KAAC,SAAS,IAAc,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,IAA9F,GAAG,CAAC,EAAE,CAA4F,CACnH,CAAC,EACD,OAAO,CAAC,CAAC,CAAC,KAAC,WAAW,KAAG,CAAC,CAAC,CAAC,IAAI,IAC9B,EACJ,OAAO,CAAC,CAAC,CAAC,CACT,eAAM,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,YACpC,iBAAiB,CAAC,OAAO,GACrB,CACR,CAAC,CAAC,CAAC,IAAI,IACM,GACT,CACV,CAAA;AACH,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAA"}
@@ -0,0 +1,125 @@
1
+ import * as React from "react";
2
+ /** What the grid knows when it decides whether to ask for the next page. */
3
+ type LoadMoreState = {
4
+ /** The marker is within about a screen of the window's bottom. */
5
+ near: boolean;
6
+ /** How many cards are shown. A change is the caller adding rows. */
7
+ count: number;
8
+ loading: boolean;
9
+ ended: boolean;
10
+ failed: boolean;
11
+ /**
12
+ * What the list is of, e.g. the picked category. A new key is a new list:
13
+ * what the gate saw is forgotten, so its next page is asked for even when the
14
+ * new list is as long as the old.
15
+ */
16
+ resetKey?: React.Key | null;
17
+ };
18
+ /**
19
+ * When the grid asks for the next page (ui#607), on its own so it can be
20
+ * proved without a browser. `check` is called whenever anything above changes;
21
+ * it calls `load` once when the marker is near and nothing stops it, and not
22
+ * again until one of three things says the ask was answered:
23
+ *
24
+ * rows `count` changed: the caller added rows
25
+ * a page `loading` went from true to false: a page finished, even one
26
+ * that added no rows (an empty page with a cursor, repeats the
27
+ * caller dropped, a filter on the client), so a marker still near
28
+ * asks again (Nataly's review, ui#619)
29
+ * a list `resetKey` changed: a new list (a category switch), forgotten
30
+ * entirely, so its next page is asked for even at the same length
31
+ *
32
+ * Never while a page loads, after the end, or after a failure. `retry` is Try
33
+ * again: it asks once more with the same rows.
34
+ */
35
+ declare function createLoadMoreGate(load: () => void): {
36
+ check({ near, count, loading, ended, failed, resetKey }: LoadMoreState): boolean;
37
+ retry(): void;
38
+ };
39
+ /**
40
+ * The Home creation card's shape, empty, while its page loads (ui#607): the
41
+ * card's box (`ENTITY_CARD_HOME_BOX`, 302 x 238, the hairline and the 12px
42
+ * corner, the 1px pad), the picture at the card's 159/92 and 11px inner corner,
43
+ * then the name and the line under it as two bars. The library's `Skeleton`
44
+ * draws each piece, so it pulses as every skeleton does. Wider than 302, on a
45
+ * phone, the picture gives up its ratio and takes the room the bars leave, so
46
+ * the box stays the card's 238. Decoration: hidden
47
+ * from a screen reader; the grid says it is loading.
48
+ */
49
+ declare function CreationCardSkeleton({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
50
+ /**
51
+ * The Grid page's card grid that loads as you scroll (ui#607, Asaf,
52
+ * 2026-11-25, cloudgrid-console#1183).
53
+ *
54
+ * ## The grid
55
+ *
56
+ * The caller's cards, one item each: the Home creation card (`EntityCard
57
+ * look="home"`, 302 wide). The columns are that card's width, as many as fit,
58
+ * spread to the edges, and no more than four: the list is at most the page's
59
+ * column, 1280, which is four cards and three 24 gaps exactly. On a phone
60
+ * (under 640) it is one a row and the card fills it: the card's 302 width
61
+ * gives way to the row's. Its 238 height stays: the Home card's name block sits
62
+ * a fixed height from its top, so the picture shows the same 172 rows, wider.
63
+ *
64
+ * Long lists stay light without a windowing library: every item is
65
+ * `content-visibility: auto`, so a row off screen skips layout and paint, and
66
+ * holds the card's 238 height while it does so the scroll bar does not jump.
67
+ * Each item is 4px larger than its card on every side (a padding the margin
68
+ * takes back), because the skipping also clips to the item: the card's
69
+ * keyboard frame, 3px outside it, stays whole.
70
+ *
71
+ * ## Asking for more
72
+ *
73
+ * A marker under the list. When it comes within about one screen of the
74
+ * window's bottom (an IntersectionObserver with a 100% bottom margin), the
75
+ * caller's `onLoadMore` is called once. It is not called again until the
76
+ * caller has added rows (the number of cards changed), a page has finished
77
+ * (`loading` back to false, even with no new rows), the list is a new one
78
+ * (`resetKey`, say the picked category), or the caller has ended the list
79
+ * (`ended`, which takes the marker away). How many a page holds, about 24, is
80
+ * the caller's; the grid never asks on its own beyond that one call.
81
+ *
82
+ * ## The states
83
+ *
84
+ * loading `loading`: a row of card skeletons (`skeletons`, 4) after the
85
+ * cards, in the card's own shape, so nothing above them moves; the
86
+ * list says it is busy
87
+ * end `ended`: the caller's line ("That's everything on Atomic Labs.")
88
+ * under the list, in the faint body tone
89
+ * failed `failed`: a line ("More creations did not load.") with Try again,
90
+ * the teal text link; every card already shown stays. Try again
91
+ * calls `onRetry`, or `onLoadMore` when there is none
92
+ *
93
+ * The line under the list is a polite live region, so the end and a failure
94
+ * are read when they come.
95
+ */
96
+ declare function LoadMoreGrid({ label, onLoadMore, onRetry, loading, ended, failed, endLabel, failedLabel, retryLabel, loadingLabel, skeletons, resetKey, className, children, ...props }: React.ComponentProps<"div"> & {
97
+ /** Names the list, e.g. "Creations on Atomic Labs". */
98
+ label: string;
99
+ /** Asked once when the reader is about a screen from the bottom. */
100
+ onLoadMore?: () => void;
101
+ /** Try again, after a failed page. Defaults to `onLoadMore`. */
102
+ onRetry?: () => void;
103
+ /** A page is loading: a row of skeletons, and no new ask. */
104
+ loading?: boolean;
105
+ /** The list is complete: the end line, and the marker goes. */
106
+ ended?: boolean;
107
+ /** The last page failed: the failed line with Try again; the cards stay. */
108
+ failed?: boolean;
109
+ /** The end line: "That's everything on <grid>." The caller's words. */
110
+ endLabel?: React.ReactNode;
111
+ failedLabel?: React.ReactNode;
112
+ retryLabel?: React.ReactNode;
113
+ /** Read while a page loads; the skeletons themselves are hidden. */
114
+ loadingLabel?: string;
115
+ /**
116
+ * What the list is of, e.g. the picked category: a new key is a new list,
117
+ * and its next page is asked for even when it is as long as the last.
118
+ */
119
+ resetKey?: React.Key | null;
120
+ /** How many skeletons a loading page shows: a row. */
121
+ skeletons?: number;
122
+ }): React.JSX.Element;
123
+ export { CreationCardSkeleton, LoadMoreGrid, createLoadMoreGate };
124
+ export type { LoadMoreState };
125
+ //# sourceMappingURL=load-more-grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-more-grid.d.ts","sourceRoot":"","sources":["../../src/blocks/load-more-grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,4EAA4E;AAC5E,KAAK,aAAa,GAAG;IACnB,kEAAkE;IAClE,IAAI,EAAE,OAAO,CAAA;IACb,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,GAAG,IAAI,CAAA;CAC5B,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,IAAI;6DAMiB,aAAa;;EAsBzE;AAED;;;;;;;;;GASG;AACH,iBAAS,oBAAoB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAejF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,iBAAS,YAAY,CAAC,EACpB,KAAK,EACL,UAAU,EACV,OAAO,EACP,OAAe,EACf,KAAa,EACb,MAAc,EACd,QAAQ,EACR,WAA4C,EAC5C,UAAwB,EACxB,YAAuC,EACvC,SAAa,EACb,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IAC/B,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,4EAA4E;IAC5E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,GAAG,IAAI,CAAA;IAC3B,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,qBAgGA;AAED,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,CAAA"}
@@ -0,0 +1,157 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../lib/cloudgrid-cn.js";
5
+ import { ActionLink } from "./action-link.js";
6
+ import { ENTITY_CARD_HOME_BOX } from "./entity-card.js";
7
+ import { Skeleton } from "../ui/skeleton.js";
8
+ /**
9
+ * When the grid asks for the next page (ui#607), on its own so it can be
10
+ * proved without a browser. `check` is called whenever anything above changes;
11
+ * it calls `load` once when the marker is near and nothing stops it, and not
12
+ * again until one of three things says the ask was answered:
13
+ *
14
+ * rows `count` changed: the caller added rows
15
+ * a page `loading` went from true to false: a page finished, even one
16
+ * that added no rows (an empty page with a cursor, repeats the
17
+ * caller dropped, a filter on the client), so a marker still near
18
+ * asks again (Nataly's review, ui#619)
19
+ * a list `resetKey` changed: a new list (a category switch), forgotten
20
+ * entirely, so its next page is asked for even at the same length
21
+ *
22
+ * Never while a page loads, after the end, or after a failure. `retry` is Try
23
+ * again: it asks once more with the same rows.
24
+ */
25
+ function createLoadMoreGate(load) {
26
+ let asked = false;
27
+ let seen;
28
+ let key;
29
+ let wasLoading = false;
30
+ return {
31
+ check({ near, count, loading, ended, failed, resetKey }) {
32
+ if (resetKey !== key) {
33
+ key = resetKey;
34
+ seen = undefined;
35
+ asked = false;
36
+ }
37
+ if (count !== seen) {
38
+ seen = count;
39
+ asked = false;
40
+ }
41
+ if (wasLoading && !loading)
42
+ asked = false;
43
+ wasLoading = loading;
44
+ if (!near || asked || loading || ended || failed)
45
+ return false;
46
+ asked = true;
47
+ load();
48
+ return true;
49
+ },
50
+ retry() {
51
+ asked = true;
52
+ load();
53
+ },
54
+ };
55
+ }
56
+ /**
57
+ * The Home creation card's shape, empty, while its page loads (ui#607): the
58
+ * card's box (`ENTITY_CARD_HOME_BOX`, 302 x 238, the hairline and the 12px
59
+ * corner, the 1px pad), the picture at the card's 159/92 and 11px inner corner,
60
+ * then the name and the line under it as two bars. The library's `Skeleton`
61
+ * draws each piece, so it pulses as every skeleton does. Wider than 302, on a
62
+ * phone, the picture gives up its ratio and takes the room the bars leave, so
63
+ * the box stays the card's 238. Decoration: hidden
64
+ * from a screen reader; the grid says it is loading.
65
+ */
66
+ function CreationCardSkeleton({ className, ...props }) {
67
+ return (_jsxs("div", { "data-slot": "creation-card-skeleton", "aria-hidden": "true", className: cn("flex shrink-0 flex-col gap-4 rounded-md border border-hairline bg-card p-px", ENTITY_CARD_HOME_BOX, className), ...props, children: [_jsx(Skeleton, { className: "aspect-[159/92] w-full rounded-[calc(var(--cg-radius-md)-1px)] max-sm:aspect-auto max-sm:min-h-0 max-sm:flex-1" }), _jsxs("div", { className: "grid gap-2 px-3", children: [_jsx(Skeleton, { className: "h-4 w-2/3 rounded-2xs" }), _jsx(Skeleton, { className: "h-3 w-1/2 rounded-2xs" })] })] }));
68
+ }
69
+ /**
70
+ * The Grid page's card grid that loads as you scroll (ui#607, Asaf,
71
+ * 2026-11-25, cloudgrid-console#1183).
72
+ *
73
+ * ## The grid
74
+ *
75
+ * The caller's cards, one item each: the Home creation card (`EntityCard
76
+ * look="home"`, 302 wide). The columns are that card's width, as many as fit,
77
+ * spread to the edges, and no more than four: the list is at most the page's
78
+ * column, 1280, which is four cards and three 24 gaps exactly. On a phone
79
+ * (under 640) it is one a row and the card fills it: the card's 302 width
80
+ * gives way to the row's. Its 238 height stays: the Home card's name block sits
81
+ * a fixed height from its top, so the picture shows the same 172 rows, wider.
82
+ *
83
+ * Long lists stay light without a windowing library: every item is
84
+ * `content-visibility: auto`, so a row off screen skips layout and paint, and
85
+ * holds the card's 238 height while it does so the scroll bar does not jump.
86
+ * Each item is 4px larger than its card on every side (a padding the margin
87
+ * takes back), because the skipping also clips to the item: the card's
88
+ * keyboard frame, 3px outside it, stays whole.
89
+ *
90
+ * ## Asking for more
91
+ *
92
+ * A marker under the list. When it comes within about one screen of the
93
+ * window's bottom (an IntersectionObserver with a 100% bottom margin), the
94
+ * caller's `onLoadMore` is called once. It is not called again until the
95
+ * caller has added rows (the number of cards changed), a page has finished
96
+ * (`loading` back to false, even with no new rows), the list is a new one
97
+ * (`resetKey`, say the picked category), or the caller has ended the list
98
+ * (`ended`, which takes the marker away). How many a page holds, about 24, is
99
+ * the caller's; the grid never asks on its own beyond that one call.
100
+ *
101
+ * ## The states
102
+ *
103
+ * loading `loading`: a row of card skeletons (`skeletons`, 4) after the
104
+ * cards, in the card's own shape, so nothing above them moves; the
105
+ * list says it is busy
106
+ * end `ended`: the caller's line ("That's everything on Atomic Labs.")
107
+ * under the list, in the faint body tone
108
+ * failed `failed`: a line ("More creations did not load.") with Try again,
109
+ * the teal text link; every card already shown stays. Try again
110
+ * calls `onRetry`, or `onLoadMore` when there is none
111
+ *
112
+ * The line under the list is a polite live region, so the end and a failure
113
+ * are read when they come.
114
+ */
115
+ function LoadMoreGrid({ label, onLoadMore, onRetry, loading = false, ended = false, failed = false, endLabel, failedLabel = "More creations did not load.", retryLabel = "Try again", loadingLabel = "Loading more creations", skeletons = 4, resetKey, className, children, ...props }) {
116
+ const items = React.Children.toArray(children);
117
+ const count = items.length;
118
+ const marker = React.useRef(null);
119
+ const near = React.useRef(false);
120
+ const asks = React.useRef({ onLoadMore, onRetry });
121
+ const state = React.useRef({ count, loading, ended, failed, resetKey });
122
+ const [gate] = React.useState(() => createLoadMoreGate(() => asks.current.onLoadMore?.()));
123
+ React.useEffect(() => {
124
+ asks.current = { onLoadMore, onRetry };
125
+ }, [onLoadMore, onRetry]);
126
+ // Rows added, a page done or failed, the end: look again.
127
+ React.useEffect(() => {
128
+ state.current = { count, loading, ended, failed, resetKey };
129
+ gate.check({ near: near.current, ...state.current });
130
+ }, [gate, count, loading, ended, failed, resetKey]);
131
+ const watching = !ended && !failed;
132
+ React.useEffect(() => {
133
+ const el = marker.current;
134
+ if (!watching || !el || typeof IntersectionObserver !== "function")
135
+ return;
136
+ const io = new IntersectionObserver((entries) => {
137
+ near.current = entries[entries.length - 1].isIntersecting;
138
+ gate.check({ near: near.current, ...state.current });
139
+ }, { rootMargin: "0px 0px 100% 0px" });
140
+ io.observe(el);
141
+ return () => {
142
+ io.disconnect();
143
+ near.current = false;
144
+ };
145
+ }, [gate, watching]);
146
+ const retry = () => {
147
+ if (asks.current.onRetry)
148
+ asks.current.onRetry();
149
+ else
150
+ gate.retry();
151
+ };
152
+ return (_jsxs("div", { "data-slot": "load-more-grid", className: cn("flex min-w-0 flex-col gap-6", className), ...props, children: [_jsxs("ul", { "data-slot": "load-more-grid-list", "aria-label": label, "aria-busy": loading || undefined, className: "m-0 grid w-full max-w-page list-none grid-cols-1 justify-between gap-6 p-0 sm:grid-cols-[repeat(auto-fill,18.875rem)]", children: [items.map((card, i) => (_jsx("li", { "data-slot": "load-more-grid-item", className: "-m-1 min-w-0 p-1 [contain-intrinsic-size:auto_14.875rem] [content-visibility:auto] max-sm:*:w-full", children: card }, React.isValidElement(card) ? (card.key ?? i) : i))), loading
153
+ ? Array.from({ length: skeletons }, (_, i) => (_jsx("li", { "data-slot": "load-more-grid-skeleton", "aria-hidden": "true", className: "min-w-0 max-sm:*:w-full", children: _jsx(CreationCardSkeleton, {}) }, `skeleton-${i}`)))
154
+ : null] }), _jsx("div", { "data-slot": "load-more-grid-status", role: "status", className: "flex min-h-6 flex-wrap items-center justify-center gap-x-2 text-center", children: failed ? (_jsxs(_Fragment, { children: [_jsx("p", { "data-slot": "load-more-grid-failed", className: "m-0 text-body-sm text-faint-strong", children: failedLabel }), _jsx(ActionLink, { "data-slot": "load-more-grid-retry", render: _jsx("button", { type: "button" }), weight: "bold", onClick: retry, className: "cursor-pointer border-0 bg-transparent p-0", children: retryLabel })] })) : ended ? (endLabel !== undefined && endLabel !== null ? (_jsx("p", { "data-slot": "load-more-grid-end", className: "m-0 text-body-sm text-faint-strong", children: endLabel })) : null) : loading ? (_jsx("span", { className: "sr-only", children: loadingLabel })) : null }), watching ? _jsx("div", { ref: marker, "data-slot": "load-more-grid-marker", "aria-hidden": "true", className: "h-px w-full" }) : null] }));
155
+ }
156
+ export { CreationCardSkeleton, LoadMoreGrid, createLoadMoreGate };
157
+ //# sourceMappingURL=load-more-grid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-more-grid.js","sourceRoot":"","sources":["../../src/blocks/load-more-grid.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAmBjD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,kBAAkB,CAAC,IAAgB;IAC1C,IAAI,KAAK,GAAG,KAAK,CAAA;IACjB,IA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