@gtkx/components 2.0.0-beta.11 → 2.0.0-beta.13

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 (92) hide show
  1. package/README.md +4 -4
  2. package/dist/column-view.d.ts.map +1 -1
  3. package/dist/column-view.js +8 -4
  4. package/dist/column-view.js.map +1 -1
  5. package/dist/combo-row.d.ts.map +1 -1
  6. package/dist/combo-row.js +3 -1
  7. package/dist/combo-row.js.map +1 -1
  8. package/dist/grid-view.d.ts.map +1 -1
  9. package/dist/grid-view.js +4 -3
  10. package/dist/grid-view.js.map +1 -1
  11. package/dist/internal/cells.d.ts +8 -9
  12. package/dist/internal/cells.d.ts.map +1 -1
  13. package/dist/internal/cells.js +98 -83
  14. package/dist/internal/cells.js.map +1 -1
  15. package/dist/internal/collection-index.d.ts +3 -5
  16. package/dist/internal/collection-index.d.ts.map +1 -1
  17. package/dist/internal/collection-index.js +3 -7
  18. package/dist/internal/collection-index.js.map +1 -1
  19. package/dist/internal/collection-model.d.ts +15 -4
  20. package/dist/internal/collection-model.d.ts.map +1 -1
  21. package/dist/internal/collection-model.js +154 -73
  22. package/dist/internal/collection-model.js.map +1 -1
  23. package/dist/internal/collection.d.ts +3 -3
  24. package/dist/internal/collection.d.ts.map +1 -1
  25. package/dist/internal/collection.js +11 -9
  26. package/dist/internal/collection.js.map +1 -1
  27. package/dist/internal/controlled-sync.d.ts +2 -1
  28. package/dist/internal/controlled-sync.d.ts.map +1 -1
  29. package/dist/internal/controlled-sync.js +6 -1
  30. package/dist/internal/controlled-sync.js.map +1 -1
  31. package/dist/internal/drop-down.d.ts +10 -4
  32. package/dist/internal/drop-down.d.ts.map +1 -1
  33. package/dist/internal/drop-down.js +61 -9
  34. package/dist/internal/drop-down.js.map +1 -1
  35. package/dist/internal/expansion.d.ts.map +1 -1
  36. package/dist/internal/expansion.js +46 -19
  37. package/dist/internal/expansion.js.map +1 -1
  38. package/dist/internal/first-header.d.ts +11 -0
  39. package/dist/internal/first-header.d.ts.map +1 -0
  40. package/dist/internal/first-header.js +21 -0
  41. package/dist/internal/first-header.js.map +1 -0
  42. package/dist/internal/keys.d.ts.map +1 -1
  43. package/dist/internal/level-splice.d.ts +27 -0
  44. package/dist/internal/level-splice.d.ts.map +1 -0
  45. package/dist/internal/level-splice.js +98 -0
  46. package/dist/internal/level-splice.js.map +1 -0
  47. package/dist/internal/selection.d.ts.map +1 -1
  48. package/dist/internal/selection.js +23 -16
  49. package/dist/internal/selection.js.map +1 -1
  50. package/dist/internal/tree-expansion.d.ts +3 -1
  51. package/dist/internal/tree-expansion.d.ts.map +1 -1
  52. package/dist/internal/tree-expansion.js +31 -2
  53. package/dist/internal/tree-expansion.js.map +1 -1
  54. package/dist/internal/tree-order.d.ts +2 -1
  55. package/dist/internal/tree-order.d.ts.map +1 -1
  56. package/dist/internal/tree-order.js +3 -2
  57. package/dist/internal/tree-order.js.map +1 -1
  58. package/dist/internal/use-collection.d.ts +1 -0
  59. package/dist/internal/use-collection.d.ts.map +1 -1
  60. package/dist/internal/use-collection.js +6 -2
  61. package/dist/internal/use-collection.js.map +1 -1
  62. package/dist/internal/use-widget-ref.d.ts.map +1 -1
  63. package/dist/list-item-factory.d.ts +1 -1
  64. package/dist/list-item-factory.d.ts.map +1 -1
  65. package/dist/list-item-factory.js +3 -3
  66. package/dist/list-item-factory.js.map +1 -1
  67. package/dist/list-view.d.ts.map +1 -1
  68. package/dist/list-view.js +9 -4
  69. package/dist/list-view.js.map +1 -1
  70. package/dist/types.d.ts +35 -12
  71. package/dist/types.d.ts.map +1 -1
  72. package/dist/types.js.map +1 -1
  73. package/package.json +10 -20
  74. package/src/column-view.tsx +8 -4
  75. package/src/combo-row.tsx +4 -1
  76. package/src/grid-view.tsx +3 -2
  77. package/src/internal/cells.tsx +174 -151
  78. package/src/internal/collection-index.ts +7 -14
  79. package/src/internal/collection-model.ts +211 -76
  80. package/src/internal/collection.ts +14 -13
  81. package/src/internal/controlled-sync.ts +8 -1
  82. package/src/internal/drop-down.tsx +112 -19
  83. package/src/internal/expansion.ts +52 -20
  84. package/src/internal/first-header.ts +23 -0
  85. package/src/internal/level-splice.ts +157 -0
  86. package/src/internal/selection.tsx +24 -19
  87. package/src/internal/tree-expansion.ts +43 -1
  88. package/src/internal/tree-order.ts +4 -10
  89. package/src/internal/use-collection.tsx +8 -2
  90. package/src/list-item-factory.tsx +2 -1
  91. package/src/list-view.tsx +10 -2
  92. package/src/types.ts +54 -24
@@ -2,17 +2,21 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as Gtk from "@gtkx/gi/gtk";
3
3
  import { GtkBox, GtkSignalListItemFactory, GtkTreeExpander } from "@gtkx/jsx/gtk";
4
4
  import { createPortal, useProperty } from "@gtkx/react";
5
- import { Fragment, memo, useInsertionEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
6
- import { slotPathAt, slotRefFor } from "./collection-model.js";
5
+ import { useLatestRef } from "@gtkx/react/internal";
6
+ import { createRef, Fragment, memo, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
7
+ import { levelStoreFor, slotRefFor } from "./collection-model.js";
7
8
  import { joinParts } from "./keys.js";
8
9
  const ItemCell = memo(ItemCellImpl, isSameItemCell);
9
10
  const ItemRow = memo(ItemRowImpl, isSameItemRow);
10
11
  const HeaderCell = memo(HeaderCellImpl);
12
+ const ItemCellList = memo(ItemCellListImpl, isWaitingForSync);
13
+ const ItemRowList = memo(ItemRowListImpl, isWaitingForSync);
11
14
  const CELL_OPTIONS = { isHost: isListItem, prepare: prepareCell };
12
15
  const HEADER_OPTIONS = { isHost: isListHeader, prepare: prepareCell };
13
16
  const ROW_OPTIONS = { isHost: isColumnViewRow };
14
17
  const NO_SIZE = { width: -1, height: -1 };
15
18
  const NO_ROW_PROPS = {};
19
+ const DEFAULT_ROW_PROPS = resolveRowProps(NO_ROW_PROPS);
16
20
  const placeholders = new WeakSet();
17
21
  const placeholder = (size) => {
18
22
  const widget = new Gtk.Box({ widthRequest: size.width, heightRequest: size.height });
@@ -45,7 +49,7 @@ function notifyRegistry(state) {
45
49
  }
46
50
  function createEntry(state, host) {
47
51
  state.serial += 1;
48
- return { key: `gtkx-cell-${String(state.serial)}`, host, identity: createItemIdentityStore() };
52
+ return { key: `gtkx-cell-${String(state.serial)}`, host, identity: createRef() };
49
53
  }
50
54
  function setupHost(state, host) {
51
55
  state.prepare?.(host, state.size);
@@ -131,8 +135,18 @@ function useHeaderCells(size) {
131
135
  function isRowWanted(options, item) {
132
136
  return options.expandedIds?.includes(item.id) ?? false;
133
137
  }
134
- function itemArgs(item, position, row, isExpanded) {
135
- const args = { item: item.value, index: position ?? 0 };
138
+ function collectionIndex(collection, item, position) {
139
+ if (position === undefined) {
140
+ return 0;
141
+ }
142
+ if (collection.idAt(position) === item.id) {
143
+ return position;
144
+ }
145
+ const index = collection.positionFor(item.id);
146
+ return index === -1 ? position : index;
147
+ }
148
+ function itemArgs(item, index, row, isExpanded) {
149
+ const args = { item: item.value, index };
136
150
  if (row === null) {
137
151
  return args;
138
152
  }
@@ -142,9 +156,6 @@ function itemArgs(item, position, row, isExpanded) {
142
156
  }
143
157
  return args;
144
158
  }
145
- function keyForItem(ref, item) {
146
- return joinParts([slotPathAt(ref.store, ref.slot), item.id]);
147
- }
148
159
  function slotFor(options) {
149
160
  const ref = slotRefFor(options.item);
150
161
  if (ref === null) {
@@ -155,36 +166,40 @@ function slotFor(options) {
155
166
  return null;
156
167
  }
157
168
  return {
158
- itemKey: keyForItem(ref, item),
169
+ itemKey: ref.key,
159
170
  item,
171
+ position: options.position,
160
172
  row: options.row,
161
- args: itemArgs(item, options.position, options.row, isRowWanted(options, item)),
173
+ args: itemArgs(item, collectionIndex(options.collection, item, options.position), options.row, isRowWanted(options, item)),
162
174
  };
163
175
  }
164
176
  function useItemSlot(entry, state, identity) {
165
177
  const position = useProperty(entry.host, "position");
166
178
  const item = useProperty(entry.host, "item") ?? null;
167
179
  const row = item instanceof Gtk.TreeListRow ? item : null;
180
+ const { collection, expandedIds } = state.current;
168
181
  if (position === identity.position) {
169
182
  return identity.item === undefined
170
183
  ? null
171
184
  : {
172
185
  itemKey: identity.itemKey,
173
186
  item: identity.item,
187
+ position,
174
188
  row,
175
- args: itemArgs(identity.item, position, row, identity.isExpanded),
189
+ args: itemArgs(identity.item, identity.index, row, identity.isExpanded),
176
190
  };
177
191
  }
178
- const { collection, expandedIds } = state.read();
179
192
  return slotFor({ item, position, row, collection, expandedIds });
180
193
  }
181
194
  function itemIdentity(entry, collection, expandedIds) {
182
195
  const ref = slotRefFor(entry.host.getItem());
183
196
  const item = ref === null ? undefined : collection.itemAt(ref);
197
+ const position = entry.host.getPosition();
184
198
  return {
185
- itemKey: ref === null || item === undefined ? "" : keyForItem(ref, item),
199
+ itemKey: ref === null || item === undefined ? "" : ref.key,
186
200
  item,
187
- position: entry.host.getPosition(),
201
+ position,
202
+ index: item === undefined ? 0 : collectionIndex(collection, item, position),
188
203
  isExpanded: item !== undefined && (expandedIds?.includes(item.id) ?? false),
189
204
  };
190
205
  }
@@ -192,29 +207,25 @@ function isSameItemIdentity(previous, next) {
192
207
  return (previous.item === next.item &&
193
208
  previous.itemKey === next.itemKey &&
194
209
  previous.position === next.position &&
210
+ previous.index === next.index &&
195
211
  previous.isExpanded === next.isExpanded);
196
212
  }
197
213
  function isSameItemCell(previous, next) {
198
- const identity = previous.entry.identity.read() ?? previous;
214
+ const identity = previous.entry.identity.current ?? previous;
199
215
  return (previous.entry === next.entry &&
200
216
  previous.render === next.render &&
217
+ previous.rowProps === next.rowProps &&
201
218
  previous.hasExpander === next.hasExpander &&
202
219
  previous.expanderDescriptions === next.expanderDescriptions &&
203
220
  isSameItemIdentity(identity, next));
204
221
  }
222
+ function isWaitingForSync(_previous, next) {
223
+ return next.isPending;
224
+ }
205
225
  function isSameItemRow(previous, next) {
206
- const identity = previous.entry.identity.read() ?? previous;
226
+ const identity = previous.entry.identity.current ?? previous;
207
227
  return previous.entry === next.entry && previous.rowProps === next.rowProps && isSameItemIdentity(identity, next);
208
228
  }
209
- function createItemIdentityStore() {
210
- let current = null;
211
- return {
212
- read: () => current,
213
- write: (identity) => {
214
- current = identity;
215
- },
216
- };
217
- }
218
229
  function createNativeItemKeyStore() {
219
230
  const keys = new WeakMap();
220
231
  let serial = 0;
@@ -235,31 +246,17 @@ function renderedIdentity(entry, slot) {
235
246
  return {
236
247
  itemKey: slot?.itemKey ?? "",
237
248
  item: slot?.item,
238
- position: slot?.args.index ?? entry.host.getPosition(),
249
+ position: slot?.position ?? entry.host.getPosition(),
250
+ index: slot?.args.index ?? 0,
239
251
  isExpanded: slot?.args.isExpanded ?? false,
240
252
  };
241
253
  }
242
254
  function useRememberIdentity(entry, slot) {
255
+ const identityRef = entry.identity;
243
256
  useLayoutEffect(() => {
244
- entry.identity.write(renderedIdentity(entry, slot));
257
+ identityRef.current = renderedIdentity(entry, slot);
245
258
  });
246
259
  }
247
- function createCollectionStateStore(initial) {
248
- let current = initial;
249
- return {
250
- read: () => current,
251
- write: (state) => {
252
- current = state;
253
- },
254
- };
255
- }
256
- function useCollectionState(collection, expandedIds) {
257
- const [state] = useState(() => createCollectionStateStore({ collection, expandedIds }));
258
- useInsertionEffect(() => {
259
- state.write({ collection, expandedIds });
260
- }, [state, collection, expandedIds]);
261
- return state;
262
- }
263
260
  function expanderDescriptionFor(slot, descriptions) {
264
261
  const { isExpanded } = slot.args;
265
262
  if (isExpanded === undefined || descriptions == null) {
@@ -269,9 +266,7 @@ function expanderDescriptionFor(slot, descriptions) {
269
266
  }
270
267
  function wrapExpander(slot, content, descriptions) {
271
268
  const { item, row } = slot;
272
- const expander = row === null
273
- ? (content)
274
- : (_jsx(GtkTreeExpander, { listRow: row, hideExpander: item.shouldHideExpander ?? false, indentForDepth: item.shouldIndentForDepth ?? true, indentForIcon: item.shouldIndentForIcon ?? true, accessibleDescription: expanderDescriptionFor(slot, descriptions), children: content }));
269
+ const expander = row === null ? (content) : (_jsx(GtkTreeExpander, { listRow: row, hideExpander: item.shouldHideExpander ?? false, indentForDepth: item.shouldIndentForDepth ?? true, indentForIcon: item.shouldIndentForIcon ?? true, accessibleDescription: expanderDescriptionFor(slot, descriptions), children: content }));
275
270
  return expander;
276
271
  }
277
272
  function itemBody(slot, render, hasExpander, descriptions) {
@@ -280,18 +275,15 @@ function itemBody(slot, render, hasExpander, descriptions) {
280
275
  }
281
276
  const renderItem = render;
282
277
  const content = renderItem(slot.args);
283
- return (_jsx(Fragment, { children: hasExpander ? wrapExpander(slot, content, descriptions) : content }, slot.itemKey));
278
+ return _jsx(Fragment, { children: hasExpander ? wrapExpander(slot, content, descriptions) : content }, slot.itemKey);
284
279
  }
285
280
  function rowText(value) {
286
281
  return value ?? null;
287
282
  }
288
- /* eslint-disable-next-line unicorn/consistent-boolean-name -- reads the flag off a row, paired with rowText */
289
283
  function rowFlag(value) {
290
284
  return value ?? true;
291
285
  }
292
- function rowPropsFor(slot, rowProps) {
293
- const resolve = rowProps;
294
- const props = slot === null ? NO_ROW_PROPS : resolve(slot.args);
286
+ function resolveRowProps(props) {
295
287
  return {
296
288
  accessibleLabel: rowText(props.accessibleLabel),
297
289
  accessibleDescription: rowText(props.accessibleDescription),
@@ -300,6 +292,10 @@ function rowPropsFor(slot, rowProps) {
300
292
  isSelectable: rowFlag(props.isSelectable),
301
293
  };
302
294
  }
295
+ function rowPropsFor(slot, rowProps) {
296
+ const resolve = rowProps;
297
+ return resolveRowProps(slot === null ? NO_ROW_PROPS : resolve(slot.args));
298
+ }
303
299
  function applyRowProps(host, props, previous) {
304
300
  if (previous?.accessibleLabel !== props.accessibleLabel) {
305
301
  host.accessibleLabel = props.accessibleLabel;
@@ -317,70 +313,89 @@ function applyRowProps(host, props, previous) {
317
313
  host.setSelectable(props.isSelectable);
318
314
  }
319
315
  }
320
- function ItemCellImpl({ entry, render, state, hasExpander, expanderDescriptions, ...identity }) {
316
+ function useAppliedRowProps(host, props) {
317
+ const previous = useRef(null);
318
+ useLayoutEffect(() => {
319
+ if (props === null && previous.current === null) {
320
+ return;
321
+ }
322
+ const next = props ?? DEFAULT_ROW_PROPS;
323
+ applyRowProps(host, next, previous.current);
324
+ previous.current = props === null ? null : next;
325
+ }, [host, props]);
326
+ }
327
+ function ItemCellImpl({ entry, render, rowProps, state, hasExpander, expanderDescriptions, ...identity }) {
321
328
  const slot = useItemSlot(entry, state, identity);
322
329
  useRememberIdentity(entry, slot);
330
+ useAppliedRowProps(entry.host, rowProps == null ? null : rowPropsFor(slot, rowProps));
323
331
  const body = itemBody(slot, render, hasExpander, expanderDescriptions);
324
332
  return createPortal(body, entry.host, entry.key);
325
333
  }
326
334
  function ItemRowImpl({ entry, rowProps, state, ...identity }) {
327
335
  const slot = useItemSlot(entry, state, identity);
328
336
  useRememberIdentity(entry, slot);
329
- const props = rowPropsFor(slot, rowProps);
330
- const previous = useRef(null);
331
- useLayoutEffect(() => {
332
- applyRowProps(entry.host, props, previous.current);
333
- previous.current = props;
334
- }, [entry.host, props]);
337
+ useAppliedRowProps(entry.host, rowPropsFor(slot, rowProps));
335
338
  return null;
336
339
  }
337
- function HeaderCellImpl({ entry, render, collection }) {
340
+ function HeaderCellImpl({ entry, render }) {
338
341
  const item = useProperty(entry.host, "item") ?? null;
339
- return createPortal(headerBody(slotRefFor(item), render, collection), entry.host, entry.key);
342
+ return createPortal(headerBody(levelStoreFor(item), render), entry.host, entry.key);
340
343
  }
341
- function NativeItemCell({ entry, render, keys, size, }) {
344
+ function NativeItemCell({ entry, render, rowProps, keys, size, }) {
342
345
  const position = useProperty(entry.host, "position");
343
346
  const item = useProperty(entry.host, "item") ?? null;
347
+ const args = item !== null && position !== undefined ? { item: item, index: position } : null;
348
+ useAppliedRowProps(entry.host, rowProps == null ? null : resolveRowProps(args === null ? NO_ROW_PROPS : rowProps(args)));
344
349
  let body = null;
345
- if (item !== null && position !== undefined) {
346
- const content = render({ item: item, index: position });
347
- const child = content == null || typeof content === "boolean"
348
- ? _jsx(GtkBox, { widthRequest: size.width, heightRequest: size.height })
349
- : content;
350
+ if (item !== null && args !== null) {
351
+ const content = render(args);
352
+ const child = content == null || typeof content === "boolean" ? (_jsx(GtkBox, { widthRequest: size.width, heightRequest: size.height })) : (content);
350
353
  body = _jsx(Fragment, { children: child }, keys.keyFor(item));
351
354
  }
352
355
  return createPortal(body, entry.host, entry.key);
353
356
  }
354
- function headerBody(ref, render, collection) {
355
- if (ref === null) {
356
- return null;
357
- }
358
- const section = collection.sectionFor(ref.store.level.path);
359
- if (section === undefined) {
357
+ function headerBody(store, render) {
358
+ const section = store?.level.section;
359
+ if (store === null || section === undefined) {
360
360
  return null;
361
361
  }
362
362
  const renderHeader = render;
363
- const key = joinParts([ref.store.level.path, section.id]);
363
+ const key = joinParts([store.key, section.id]);
364
364
  return _jsx(Fragment, { children: renderHeader({ section: section.value }) }, key);
365
365
  }
366
366
  function usePortalEntries(registry) {
367
367
  return useSyncExternalStore(registry.subscribe, registry.getEntries);
368
368
  }
369
- const ItemPortals = ({ registry, render, collection, hasExpander, expandedIds, expanderDescriptions, }) => {
369
+ function useCollectionVersion(collection) {
370
+ return useSyncExternalStore(collection.subscribe, collection.getVersion);
371
+ }
372
+ function ItemCellListImpl({ entries, render, rowProps, collection, hasExpander, expandedIds, expanderDescriptions, }) {
373
+ const state = useLatestRef({ collection, expandedIds });
374
+ return entries.map((entry) => (_jsx(ItemCell, { entry: entry, render: render, rowProps: rowProps, state: state, hasExpander: hasExpander ?? true, expanderDescriptions: expanderDescriptions, ...itemIdentity(entry, collection, expandedIds) }, entry.key)));
375
+ }
376
+ const ItemPortals = ({ registry, ...props }) => {
370
377
  const entries = usePortalEntries(registry);
371
- const state = useCollectionState(collection, expandedIds);
372
- return entries.map((entry) => (_jsx(ItemCell, { entry: entry, render: render, state: state, hasExpander: hasExpander ?? true, expanderDescriptions: expanderDescriptions, ...itemIdentity(entry, collection, expandedIds) }, entry.key)));
378
+ useCollectionVersion(props.collection);
379
+ return _jsx(ItemCellList, { ...props, entries: entries, isPending: props.collection.isPending() });
373
380
  };
374
- const RowPortals = ({ registry, rowProps, collection, expandedIds }) => {
375
- const entries = usePortalEntries(registry);
376
- const state = useCollectionState(collection, expandedIds);
381
+ function ItemRowListImpl({ entries, rowProps, collection, expandedIds }) {
382
+ const state = useLatestRef({ collection, expandedIds });
377
383
  return entries.map((entry) => (_jsx(ItemRow, { entry: entry, rowProps: rowProps, state: state, ...itemIdentity(entry, collection, expandedIds) }, entry.key)));
384
+ }
385
+ const RowPortals = ({ registry, ...props }) => {
386
+ const entries = usePortalEntries(registry);
387
+ useCollectionVersion(props.collection);
388
+ return _jsx(ItemRowList, { ...props, entries: entries, isPending: props.collection.isPending() });
389
+ };
390
+ const HeaderPortals = ({ registry, render, collection }) => {
391
+ const entries = usePortalEntries(registry);
392
+ const version = useCollectionVersion(collection);
393
+ return entries.map((entry) => _jsx(HeaderCell, { entry: entry, render: render, version: version }, entry.key));
378
394
  };
379
- const HeaderPortals = ({ registry, render, collection }) => usePortalEntries(registry).map((entry) => (_jsx(HeaderCell, { entry: entry, render: render, collection: collection }, entry.key)));
380
- function NativeItemPortals({ registry, render, size }) {
395
+ function NativeItemPortals({ registry, render, rowProps, size, }) {
381
396
  const entries = usePortalEntries(registry);
382
397
  const [keys] = useState(createNativeItemKeyStore);
383
- return entries.map((entry) => (_jsx(NativeItemCell, { entry: entry, render: render, keys: keys, size: size }, entry.key)));
398
+ return entries.map((entry) => (_jsx(NativeItemCell, { entry: entry, render: render, rowProps: rowProps, keys: keys, size: size }, entry.key)));
384
399
  }
385
400
  const useSectionHeader = (render, collection, size) => {
386
401
  const registry = useHeaderCells(size);
@@ -402,5 +417,5 @@ const useRowProps = (rowProps, collection, expandedIds) => {
402
417
  portals: (_jsx(RowPortals, { registry: registry, rowProps: rowProps, collection: collection, expandedIds: expandedIds })),
403
418
  };
404
419
  };
405
- export { useItemCells, useRowProps, useSectionHeader, ItemPortals, NativeItemPortals, };
420
+ export { useItemCells, useRowProps, useSectionHeader, ItemPortals, N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AAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO;QACH,YAAY,EAAE,EAAE,UAAU,EAAE,KAAC,wBAAwB,OAAK,QAAQ,CAAC,QAAQ,GAAI,EAAE;QACjF,OAAO,EAAE,CACL,KAAC,UAAU,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAI,CAC3G;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EACH,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GAEpB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkBox, GtkSignalListItemFactory, GtkTreeExpander } from \"@gtkx/jsx/gtk\";\nimport { createPortal, useProperty } from \"@gtkx/react\";\nimport { Fragment, memo, useInsertionEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport type {\n ExpanderDescriptions,\n ListItem,\n ListItemRenderArgs,\n ListItemRenderer,\n ListRowProps,\n ListRowPropsResolver,\n ListSectionRenderer,\n} from \"../types.js\";\nimport type { Collection } from \"./collection.js\";\nimport { slotPathAt, type SlotRef, slotRefFor } from \"./collection-model.js\";\nimport { joinParts } from \"./keys.js\";\n\ntype CellSize = {\n width: number;\n height: number;\n};\n\ntype FactoryHost = GObject.Object & {\n getItem: () => GObject.Object | null;\n};\n\ntype CellHost = FactoryHost & {\n getChild: () => Gtk.Widget | null;\n setChild: (child: Gtk.Widget | null) => void;\n};\n\ntype CellEntry<H extends FactoryHost> = {\n key: string;\n host: H;\n identity: ItemIdentityStore;\n};\n\ntype FactoryHandlers = {\n onSetup: (host: GObject.Object) => void;\n onBind: (host: GObject.Object) => void;\n onTeardown: (host: GObject.Object) => void;\n};\n\ntype CellRegistry<H extends FactoryHost> = {\n handlers: FactoryHandlers;\n setSize: (size: CellSize) => void;\n subscribe: (onChange: () => void) => () => void;\n getEntries: () => CellEntry<H>[];\n};\n\ntype HostGuard<H extends FactoryHost> = (value: GObject.Object) => value is H;\n\ntype CellRegistryOptions<H extends FactoryHost> = {\n isHost: HostGuard<H>;\n prepare?: ((host: H, size: CellSize) => void) | undefined;\n};\n\ntype CellRegistryState<H extends FactoryHost> = CellRegistryOptions<H> & {\n size: CellSize;\n entries: Map<H, CellEntry<H>>;\n snapshot: CellEntry<H>[] | null;\n listeners: Set<() => void>;\n serial: number;\n};\n\ntype ResolvedRowProps = {\n accessibleLabel: string | null;\n accessibleDescription: string | null;\n isActivatable: boolean;\n isFocusable: boolean;\n isSelectable: boolean;\n};\n\ntype ItemSlotOptions = {\n item: GObject.Object | null;\n position: number | undefined;\n row: Gtk.TreeListRow | null;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype PositionedHost = Gtk.ListItem | Gtk.ColumnViewRow;\n\ntype ItemSlot = {\n itemKey: string;\n item: ListItem;\n row: Gtk.TreeListRow | null;\n args: ListItemRenderArgs<unknown>;\n};\n\ntype CollectionState = {\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype CollectionStateStore = {\n read: () => CollectionState;\n write: (state: CollectionState) => void;\n};\n\ntype ItemIdentity = {\n itemKey: string;\n item: ListItem | undefined;\n position: number;\n isExpanded: boolean;\n};\n\ntype ItemIdentityStore = {\n read: () => ItemIdentity | null;\n write: (identity: ItemIdentity) => void;\n};\n\ntype ItemCellProps = {\n entry: CellEntry<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n state: CollectionStateStore;\n hasExpander: boolean;\n expanderDescriptions: ExpanderDescriptions | null | undefined;\n} & ItemIdentity;\n\ntype ItemPortalsProps = {\n registry: CellRegistry<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n collection: Collection;\n hasExpander?: boolean | undefined;\n expandedIds?: string[] | null | undefined;\n expanderDescriptions?: ExpanderDescriptions | null | undefined;\n};\n\ntype ItemRowProps = {\n entry: CellEntry<Gtk.ColumnViewRow>;\n rowProps: ListRowPropsResolver<never>;\n state: CollectionStateStore;\n} & ItemIdentity;\n\ntype RowPortalsProps = {\n registry: CellRegistry<Gtk.ColumnViewRow>;\n rowProps: ListRowPropsResolver<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype HeaderCellProps = {\n entry: CellEntry<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n collection: Collection;\n};\n\ntype HeaderPortalsProps = {\n registry: CellRegistry<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n collection: Collection;\n};\n\ntype NativeItemKeyStore = {\n keyFor: (item: GObject.Object) => string;\n};\n\ntype NativeItemCellProps<T extends GObject.Object> = {\n entry: CellEntry<Gtk.ListItem>;\n render: ListItemRenderer<T>;\n keys: NativeItemKeyStore;\n size: CellSize;\n};\n\ntype NativeItemPortalsProps<T extends GObject.Object> = {\n registry: CellRegistry<Gtk.ListItem>;\n render: ListItemRenderer<T>;\n size: CellSize;\n};\n\ntype SectionHeaderSlot = {\n factoryProps: { headerFactory?: ReactElement };\n portals: ReactNode;\n};\n\ntype RowSlot = {\n factoryProps: { rowFactory?: ReactElement };\n portals: ReactNode;\n};\n\nconst ItemCell = memo(ItemCellImpl, isSameItemCell);\nconst ItemRow = memo(ItemRowImpl, isSameItemRow);\nconst HeaderCell = memo(HeaderCellImpl);\nconst CELL_OPTIONS: CellRegistryOptions<Gtk.ListItem> = { isHost: isListItem, prepare: prepareCell };\nconst HEADER_OPTIONS: CellRegistryOptions<Gtk.ListHeader> = { isHost: isListHeader, prepare: prepareCell };\nconst ROW_OPTIONS: CellRegistryOptions<Gtk.ColumnViewRow> = { isHost: isColumnViewRow };\nconst NO_SIZE: CellSize = { width: -1, height: -1 };\nconst NO_ROW_PROPS: ListRowProps = {};\nconst placeholders: WeakSet<Gtk.Widget> = new WeakSet();\n\nconst placeholder = (size: CellSize): Gtk.Widget => {\n const widget = new Gtk.Box({ widthRequest: size.width, heightRequest: size.height });\n placeholders.add(widget);\n\n return widget;\n};\n\nfunction isListItem(value: GObject.Object): value is Gtk.ListItem {\n return value instanceof Gtk.ListItem;\n}\n\nfunction isListHeader(value: GObject.Object): value is Gtk.ListHeader {\n return value instanceof Gtk.ListHeader;\n}\n\nfunction isColumnViewRow(value: GObject.Object): value is Gtk.ColumnViewRow {\n return value instanceof Gtk.ColumnViewRow;\n}\n\nfunction prepareCell(host: CellHost, size: CellSize): void {\n const child = host.getChild();\n\n if (child === null) {\n host.setChild(placeholder(size));\n } else if (placeholders.has(child)) {\n child.setSizeRequest(size.width, size.height);\n }\n}\n\nfunction notifyRegistry<H extends FactoryHost>(state: CellRegistryState<H>): void {\n state.snapshot = null;\n\n for (const listener of state.listeners) {\n listener();\n }\n}\n\nfunction createEntry<H extends FactoryHost>(state: CellRegistryState<H>, host: H): CellEntry<H> {\n state.serial += 1;\n\n return { key: `gtkx-cell-${String(state.serial)}`, host, identity: createItemIdentityStore() };\n}\n\nfunction setupHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n state.prepare?.(host, state.size);\n state.entries.set(host, createEntry(state, host));\n notifyRegistry(state);\n}\n\nfunction teardownHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n if (state.entries.delete(host)) {\n notifyRegistry(state);\n }\n}\n\nfunction bindHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n state.prepare?.(host, state.size);\n}\n\nfunction subscribeRegistry<H extends FactoryHost>(state: CellRegistryState<H>, onChange: () => void): () => void {\n state.listeners.add(onChange);\n\n return () => {\n state.listeners.delete(onChange);\n };\n}\n\nfunction getRegistryEntries<H extends FactoryHost>(state: CellRegistryState<H>): CellEntry<H>[] {\n state.snapshot ??= state.entries.values().toArray();\n\n return state.snapshot;\n}\n\nfunction guarded<H extends FactoryHost>(isHost: HostGuard<H>, run: (host: H) => void): (host: GObject.Object) => void {\n return (host) => {\n if (isHost(host)) {\n run(host);\n }\n };\n}\n\nfunction createHandlers<H extends FactoryHost>(state: CellRegistryState<H>): FactoryHandlers {\n const { isHost } = state;\n\n return {\n onSetup: guarded(isHost, (host) => {\n setupHost(state, host);\n }),\n onBind: guarded(isHost, (host) => {\n bindHost(state, host);\n }),\n onTeardown: guarded(isHost, (host) => {\n teardownHost(state, host);\n }),\n };\n}\n\nfunction createCellRegistry<H extends FactoryHost>(options: CellRegistryOptions<H>, size: CellSize): CellRegistry<H> {\n const state: CellRegistryState<H> = {\n ...options,\n size,\n entries: new Map(),\n snapshot: null,\n listeners: new Set(),\n serial: 0,\n };\n\n return {\n handlers: createHandlers(state),\n setSize: (next) => {\n if (state.size.width === next.width && state.size.height === next.height) {\n return;\n }\n\n state.size = next;\n\n for (const host of state.entries.keys()) {\n state.prepare?.(host, next);\n }\n },\n subscribe: (onChange) => subscribeRegistry(state, onChange),\n getEntries: () => getRegistryEntries(state),\n };\n}\n\nfunction useCellRegistry<H extends FactoryHost>(options: CellRegistryOptions<H>, size: CellSize): CellRegistry<H> {\n const [registry] = useState(() => createCellRegistry(options, size));\n\n useLayoutEffect(() => {\n registry.setSize(size);\n });\n\n return registry;\n}\n\nfunction useItemCells(size: CellSize): CellRegistry<Gtk.ListItem> {\n return useCellRegistry(CELL_OPTIONS, size);\n}\n\nfunction useHeaderCells(size: CellSize): CellRegistry<Gtk.ListHeader> {\n return useCellRegistry(HEADER_OPTIONS, size);\n}\n\nfunction isRowWanted(options: ItemSlotOptions, item: ListItem): boolean {\n return options.expandedIds?.includes(item.id) ?? false;\n}\n\nfunction itemArgs(\n item: ListItem,\n position: number | undefined,\n row: Gtk.TreeListRow | null,\n isExpanded: boolean,\n): ListItemRenderArgs<unknown> {\n const args: ListItemRenderArgs<unknown> = { item: item.value, index: position ?? 0 };\n\n if (row === null) {\n return args;\n }\n\n args.depth = row.getDepth();\n\n if (row.isExpandable()) {\n args.isExpanded = isExpanded;\n }\n\n return args;\n}\n\nfunction keyForItem(ref: SlotRef, item: ListItem): string {\n return joinParts([slotPathAt(ref.store, ref.slot), item.id]);\n}\n\nfunction slotFor(options: ItemSlotOptions): ItemSlot | null {\n const ref = slotRefFor(options.item);\n\n if (ref === null) {\n return null;\n }\n\n const item = options.collection.itemAt(ref);\n\n if (item === undefined) {\n return null;\n }\n\n return {\n itemKey: keyForItem(ref, item),\n item,\n row: options.row,\n args: itemArgs(item, options.position, options.row, isRowWanted(options, item)),\n };\n}\n\nfunction useItemSlot(\n entry: CellEntry<PositionedHost>,\n state: CollectionStateStore,\n identity: ItemIdentity,\n): ItemSlot | null {\n const position = useProperty(entry.host, \"position\");\n const item = useProperty(entry.host, \"item\") ?? null;\n const row = item instanceof Gtk.TreeListRow ? item : null;\n\n if (position === identity.position) {\n return identity.item === undefined\n ? null\n : {\n itemKey: identity.itemKey,\n item: identity.item,\n row,\n args: itemArgs(identity.item, position, row, identity.isExpanded),\n };\n }\n\n const { collection, expandedIds } = state.read();\n\n return slotFor({ item, position, row, collection, expandedIds });\n}\n\nfunction itemIdentity(\n entry: CellEntry<PositionedHost>,\n collection: Collection,\n expandedIds: string[] | null | undefined,\n): ItemIdentity {\n const ref = slotRefFor(entry.host.getItem());\n const item = ref === null ? undefined : collection.itemAt(ref);\n\n return {\n itemKey: ref === null || item === undefined ? \"\" : keyForItem(ref, item),\n item,\n position: entry.host.getPosition(),\n isExpanded: item !== undefined && (expandedIds?.includes(item.id) ?? false),\n };\n}\n\nfunction isSameItemIdentity(previous: ItemIdentity, next: ItemIdentity): boolean {\n return (\n previous.item === next.item &&\n previous.itemKey === next.itemKey &&\n previous.position === next.position &&\n previous.isExpanded === next.isExpanded\n );\n}\n\nfunction isSameItemCell(previous: ItemCellProps, next: ItemCellProps): boolean {\n const identity = previous.entry.identity.read() ?? previous;\n\n return (\n previous.entry === next.entry &&\n previous.render === next.render &&\n previous.hasExpander === next.hasExpander &&\n previous.expanderDescriptions === next.expanderDescriptions &&\n isSameItemIdentity(identity, next)\n );\n}\n\nfunction isSameItemRow(previous: ItemRowProps, next: ItemRowProps): boolean {\n const identity = previous.entry.identity.read() ?? previous;\n\n return previous.entry === next.entry && previous.rowProps === next.rowProps && isSameItemIdentity(identity, next);\n}\n\nfunction createItemIdentityStore(): ItemIdentityStore {\n let current: ItemIdentity | null = null;\n\n return {\n read: () => current,\n write: (identity) => {\n current = identity;\n },\n };\n}\n\nfunction createNativeItemKeyStore(): NativeItemKeyStore {\n const keys: WeakMap<GObject.Object, string> = new WeakMap();\n let serial = 0;\n\n return {\n keyFor: (item) => {\n const current = keys.get(item);\n\n if (current !== undefined) {\n return current;\n }\n\n serial += 1;\n const key = `gtkx-native-item-${String(serial)}`;\n keys.set(item, key);\n\n return key;\n },\n };\n}\n\nfunction renderedIdentity(entry: CellEntry<PositionedHost>, slot: ItemSlot | null): ItemIdentity {\n return {\n itemKey: slot?.itemKey ?? \"\",\n item: slot?.item,\n position: slot?.args.index ?? entry.host.getPosition(),\n isExpanded: slot?.args.isExpanded ?? false,\n };\n}\n\nfunction useRememberIdentity(entry: CellEntry<PositionedHost>, slot: ItemSlot | null): void {\n useLayoutEffect(() => {\n entry.identity.write(renderedIdentity(entry, slot));\n });\n}\n\nfunction createCollectionStateStore(initial: CollectionState): CollectionStateStore {\n let current = initial;\n\n return {\n read: () => current,\n write: (state) => {\n current = state;\n },\n };\n}\n\nfunction useCollectionState(\n collection: Collection,\n expandedIds: string[] | null | undefined,\n): CollectionStateStore {\n const [state] = useState(() => createCollectionStateStore({ collection, expandedIds }));\n\n useInsertionEffect(() => {\n state.write({ collection, expandedIds });\n }, [state, collection, expandedIds]);\n\n return state;\n}\n\nfunction expanderDescriptionFor(\n slot: ItemSlot,\n descriptions: ExpanderDescriptions | null | undefined,\n): string | undefined {\n const { isExpanded } = slot.args;\n\n if (isExpanded === undefined || descriptions == null) {\n return undefined;\n }\n\n return isExpanded ? descriptions.collapse : descriptions.expand;\n}\n\nfunction wrapExpander(\n slot: ItemSlot,\n content: ReactNode,\n descriptions: ExpanderDescriptions | null | undefined,\n): ReactNode {\n const { item, row } = slot;\n\n const expander: ReactNode =\n row === null\n ? (\n content\n )\n : (\n <GtkTreeExpander\n listRow={row}\n hideExpander={item.shouldHideExpander ?? false}\n indentForDepth={item.shouldIndentForDepth ?? true}\n indentForIcon={item.shouldIndentForIcon ?? true}\n accessibleDescription={expanderDescriptionFor(slot, descriptions)}\n >\n {content}\n </GtkTreeExpander>\n );\n\n return expander;\n}\n\nfunction itemBody(\n slot: ItemSlot | null,\n render: ListItemRenderer<never>,\n hasExpander: boolean,\n descriptions: ExpanderDescriptions | null | undefined,\n): ReactNode {\n if (slot === null) {\n return null;\n }\n\n const renderItem = render as ListItemRenderer<unknown>;\n const content = renderItem(slot.args);\n\n return (\n <Fragment key={slot.itemKey}>{hasExpander ? wrapExpander(slot, content, descriptions) : content}</Fragment>\n );\n}\n\nfunction rowText(value: string | undefined): string | null {\n return value ?? null;\n}\n\n/* eslint-disable-next-line unicorn/consistent-boolean-name -- reads the flag off a row, paired with rowText */\nfunction rowFlag(value: boolean | undefined): boolean {\n return value ?? true;\n}\n\nfunction rowPropsFor(slot: ItemSlot | null, rowProps: ListRowPropsResolver<never>): ResolvedRowProps {\n const resolve = rowProps as ListRowPropsResolver<unknown>;\n const props = slot === null ? NO_ROW_PROPS : resolve(slot.args);\n\n return {\n accessibleLabel: rowText(props.accessibleLabel),\n accessibleDescription: rowText(props.accessibleDescription),\n isActivatable: rowFlag(props.isActivatable),\n isFocusable: rowFlag(props.isFocusable),\n isSelectable: rowFlag(props.isSelectable),\n };\n}\n\nfunction applyRowProps(\n host: Gtk.ColumnViewRow,\n props: ResolvedRowProps,\n previous: ResolvedRowProps | null,\n): void {\n if (previous?.accessibleLabel !== props.accessibleLabel) {\n host.accessibleLabel = props.accessibleLabel;\n }\n\n if (previous?.accessibleDescription !== props.accessibleDescription) {\n host.accessibleDescription = props.accessibleDescription;\n }\n\n if (previous?.isActivatable !== props.isActivatable) {\n host.setActivatable(props.isActivatable);\n }\n\n if (previous?.isFocusable !== props.isFocusable) {\n host.setFocusable(props.isFocusable);\n }\n\n if (previous?.isSelectable !== props.isSelectable) {\n host.setSelectable(props.isSelectable);\n }\n}\n\nfunction ItemCellImpl({\n entry,\n render,\n state,\n hasExpander,\n expanderDescriptions,\n ...identity\n}: ItemCellProps): ReactNode {\n const slot = useItemSlot(entry, state, identity);\n useRememberIdentity(entry, slot);\n const body = itemBody(slot, render, hasExpander, expanderDescriptions);\n\n return createPortal(body, entry.host, entry.key);\n}\n\nfunction ItemRowImpl({ entry, rowProps, state, ...identity }: ItemRowProps): ReactNode {\n const slot = useItemSlot(entry, state, identity);\n useRememberIdentity(entry, slot);\n const props = rowPropsFor(slot, rowProps);\n const previous = useRef<ResolvedRowProps | null>(null);\n\n useLayoutEffect(() => {\n applyRowProps(entry.host, props, previous.current);\n previous.current = props;\n }, [entry.host, props]);\n\n return null;\n}\n\nfunction HeaderCellImpl({ entry, render, collection }: HeaderCellProps): ReactNode {\n const item = useProperty(entry.host, \"item\") ?? null;\n\n return createPortal(headerBody(slotRefFor(item), render, collection), entry.host, entry.key);\n}\n\nfunction NativeItemCell<T extends GObject.Object>({\n entry,\n render,\n keys,\n size,\n}: NativeItemCellProps<T>): ReactNode {\n const position = useProperty(entry.host, \"position\");\n const item = useProperty(entry.host, \"item\") ?? null;\n let body: ReactNode = null;\n\n if (item !== null && position !== undefined) {\n const content = render({ item: item as T, index: position });\n const child = content == null || typeof content === \"boolean\"\n ? <GtkBox widthRequest={size.width} heightRequest={size.height} />\n : content;\n body = <Fragment key={keys.keyFor(item)}>{child}</Fragment>;\n }\n\n return createPortal(body, entry.host, entry.key);\n}\n\nfunction headerBody(\n ref: SlotRef | null,\n render: ListSectionRenderer<never>,\n collection: Collection,\n): ReactNode {\n if (ref === null) {\n return null;\n }\n\n const section = collection.sectionFor(ref.store.level.path);\n\n if (section === undefined) {\n return null;\n }\n\n const renderHeader = render as ListSectionRenderer<unknown>;\n const key = joinParts([ref.store.level.path, section.id]);\n\n return <Fragment key={key}>{renderHeader({ section: section.value })}</Fragment>;\n}\n\nfunction usePortalEntries<H extends FactoryHost>(registry: CellRegistry<H>): CellEntry<H>[] {\n return useSyncExternalStore(registry.subscribe, registry.getEntries);\n}\n\nconst ItemPortals = ({\n registry,\n render,\n collection,\n hasExpander,\n expandedIds,\n expanderDescriptions,\n}: ItemPortalsProps): ReactNode => {\n const entries = usePortalEntries(registry);\n const state = useCollectionState(collection, expandedIds);\n\n return entries.map((entry) => (\n <ItemCell\n key={entry.key}\n entry={entry}\n render={render}\n state={state}\n hasExpander={hasExpander ?? true}\n expanderDescriptions={expanderDescriptions}\n {...itemIdentity(entry, collection, expandedIds)}\n />\n ));\n};\n\nconst RowPortals = ({ registry, rowProps, collection, expandedIds }: RowPortalsProps): ReactNode => {\n const entries = usePortalEntries(registry);\n const state = useCollectionState(collection, expandedIds);\n\n return entries.map((entry) => (\n <ItemRow\n key={entry.key}\n entry={entry}\n rowProps={rowProps}\n state={state}\n {...itemIdentity(entry, collection, expandedIds)}\n />\n ));\n};\n\nconst HeaderPortals = ({ registry, render, collection }: HeaderPortalsProps): ReactNode =>\n usePortalEntries(registry).map((entry) => (\n <HeaderCell key={entry.key} entry={entry} render={render} collection={collection} />\n ));\n\nfunction NativeItemPortals<T extends GObject.Object>({ registry, render, size }: NativeItemPortalsProps<T>): ReactNode {\n const entries = usePortalEntries(registry);\n const [keys] = useState(createNativeItemKeyStore);\n\n return entries.map((entry) => (\n <NativeItemCell key={entry.key} entry={entry} render={render} keys={keys} size={size} />\n ));\n}\n\nconst useSectionHeader = (\n render: ListSectionRenderer<never> | null | undefined,\n collection: Collection,\n size: CellSize,\n): SectionHeaderSlot => {\n const registry = useHeaderCells(size);\n\n if (render == null) {\n return { factoryProps: {}, portals: null };\n }\n\n return {\n factoryProps: { headerFactory: <GtkSignalListItemFactory {...registry.handlers} /> },\n portals: <HeaderPortals registry={registry} render={render} collection={collection} />,\n };\n};\n\nconst useRowProps = (\n rowProps: ListRowPropsResolver<never> | null | undefined,\n collection: Collection,\n expandedIds: string[] | null | undefined,\n): RowSlot => {\n const registry = useCellRegistry(ROW_OPTIONS, NO_SIZE);\n\n if (rowProps == null) {\n return { factoryProps: {}, portals: null };\n }\n\n return {\n factoryProps: { rowFactory: <GtkSignalListItemFactory {...registry.handlers} /> },\n portals: (\n <RowPortals registry={registry} rowProps={rowProps} collection={collection} expandedIds={expandedIds} />\n ),\n };\n};\n\nexport {\n useItemCells,\n useRowProps,\n useSectionHeader,\n ItemPortals,\n NativeItemPortals,\n type CellSize,\n};\n"]}
1
+ {"version":3,"file":"cells.js","sourceRoot":"","sources":["../../src/internal/cells.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAW3G,OAAO,EAAuB,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AA2KtC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AACpD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AACjD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;AACxC,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;AAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAC5D,MAAM,YAAY,G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,CACrB,MAAqD,EACrD,UAAsB,EACtB,IAAc,EACG,EAAE;IACnB,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEtC,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACjB,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO;QACH,YAAY,EAAE,EAAE,aAAa,EAAE,KAAC,wBAAwB,OAAK,QAAQ,CAAC,QAAQ,GAAI,EAAE;QACpF,OAAO,EAAE,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAI;KACzF,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAChB,QAAwD,EACxD,UAAsB,EACtB,WAAwC,EACjC,EAAE;IACT,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAEvD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO;QACH,YAAY,EAAE,EAAE,UAAU,EAAE,KAAC,wBAAwB,OAAK,QAAQ,CAAC,QAAQ,GAAI,EAAE;QACjF,OAAO,EAAE,CACL,KAAC,UAAU,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAI,CAC3G;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAiB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { ReactElement, ReactNode, RefObject } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkBox, GtkSignalListItemFactory, GtkTreeExpander } from \"@gtkx/jsx/gtk\";\nimport { createPortal, useProperty } from \"@gtkx/react\";\nimport { useLatestRef } from \"@gtkx/react/internal\";\nimport { createRef, Fragment, memo, useLayoutEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport type {\n ExpanderDescriptions,\n ListItem,\n ListItemRenderArgs,\n ListItemRenderer,\n ListRowProps,\n ListRowPropsResolver,\n ListSectionRenderer,\n} from \"../types.js\";\nimport type { Collection } from \"./collection.js\";\nimport { type LazyLevelStore, levelStoreFor, slotRefFor } from \"./collection-model.js\";\nimport { joinParts } from \"./keys.js\";\n\ntype CellSize = {\n width: number;\n height: number;\n};\n\ntype FactoryHost = GObject.Object & {\n getItem: () => GObject.Object | null;\n};\n\ntype CellHost = FactoryHost & {\n getChild: () => Gtk.Widget | null;\n setChild: (child: Gtk.Widget | null) => void;\n};\n\ntype CellEntry<H extends FactoryHost> = {\n key: string;\n host: H;\n identity: RefObject<ItemIdentity | null>;\n};\n\ntype FactoryHandlers = {\n onSetup: (host: GObject.Object) => void;\n onBind: (host: GObject.Object) => void;\n onTeardown: (host: GObject.Object) => void;\n};\n\ntype CellRegistry<H extends FactoryHost> = {\n handlers: FactoryHandlers;\n setSize: (size: CellSize) => void;\n subscribe: (onChange: () => void) => () => void;\n getEntries: () => CellEntry<H>[];\n};\n\ntype HostGuard<H extends FactoryHost> = (value: GObject.Object) => value is H;\n\ntype CellRegistryOptions<H extends FactoryHost> = {\n isHost: HostGuard<H>;\n prepare?: ((host: H, size: CellSize) => void) | undefined;\n};\n\ntype CellRegistryState<H extends FactoryHost> = CellRegistryOptions<H> & {\n size: CellSize;\n entries: Map<H, CellEntry<H>>;\n snapshot: CellEntry<H>[] | null;\n listeners: Set<() => void>;\n serial: number;\n};\n\ntype ResolvedRowProps = {\n accessibleLabel: string | null;\n accessibleDescription: string | null;\n isActivatable: boolean;\n isFocusable: boolean;\n isSelectable: boolean;\n};\n\ntype ItemSlotOptions = {\n item: GObject.Object | null;\n position: number | undefined;\n row: Gtk.TreeListRow | null;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype PositionedHost = Gtk.ListItem | Gtk.ColumnViewRow;\n\ntype ItemSlot = {\n itemKey: string;\n item: ListItem;\n position: number | undefined;\n row: Gtk.TreeListRow | null;\n args: ListItemRenderArgs<unknown>;\n};\n\ntype CollectionState = {\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype ItemIdentity = {\n itemKey: string;\n item: ListItem | undefined;\n position: number;\n index: number;\n isExpanded: boolean;\n};\n\ntype ItemCellProps = {\n entry: CellEntry<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n rowProps: ListRowPropsResolver<never> | null | undefined;\n state: RefObject<CollectionState>;\n hasExpander: boolean;\n expanderDescriptions: ExpanderDescriptions | null | undefined;\n} & ItemIdentity;\n\ntype ItemPortalsProps = {\n registry: CellRegistry<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n rowProps?: ListRowPropsResolver<never> | null | undefined;\n collection: Collection;\n hasExpander?: boolean | undefined;\n expandedIds?: string[] | null | undefined;\n expanderDescriptions?: ExpanderDescriptions | null | undefined;\n};\n\ntype PendingList<H extends FactoryHost> = {\n entries: CellEntry<H>[];\n isPending: boolean;\n};\n\ntype ItemCellListProps = Omit<ItemPortalsProps, \"registry\"> & PendingList<Gtk.ListItem>;\n\ntype ItemRowListProps = Omit<RowPortalsProps, \"registry\"> & PendingList<Gtk.ColumnViewRow>;\n\ntype ItemRowProps = {\n entry: CellEntry<Gtk.ColumnViewRow>;\n rowProps: ListRowPropsResolver<never>;\n state: RefObject<CollectionState>;\n} & ItemIdentity;\n\ntype RowPortalsProps = {\n registry: CellRegistry<Gtk.ColumnViewRow>;\n rowProps: ListRowPropsResolver<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype HeaderCellProps = {\n entry: CellEntry<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n version: number;\n};\n\ntype HeaderPortalsProps = {\n registry: CellRegistry<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n collection: Collection;\n};\n\ntype NativeItemKeyStore = {\n keyFor: (item: GObject.Object) => string;\n};\n\ntype NativeItemCellProps<T extends GObject.Object> = {\n entry: CellEntry<Gtk.ListItem>;\n render: ListItemRenderer<T>;\n rowProps: ListRowPropsResolver<T> | null | undefined;\n keys: NativeItemKeyStore;\n size: CellSize;\n};\n\ntype NativeItemPortalsProps<T extends GObject.Object> = {\n registry: CellRegistry<Gtk.ListItem>;\n render: ListItemRenderer<T>;\n rowProps: ListRowPropsResolver<T> | null | undefined;\n size: CellSize;\n};\n\ntype SectionHeaderSlot = {\n factoryProps: { headerFactory?: ReactElement };\n portals: ReactNode;\n};\n\ntype RowSlot = {\n factoryProps: { rowFactory?: ReactElement };\n portals: ReactNode;\n};\n\nconst ItemCell = memo(ItemCellImpl, isSameItemCell);\nconst ItemRow = memo(ItemRowImpl, isSameItemRow);\nconst HeaderCell = memo(HeaderCellImpl);\nconst ItemCellList = memo(ItemCellListImpl, isWaitingForSync);\nconst ItemRowList = memo(ItemRowListImpl, isWaitingForSync);\nconst CELL_OPTIONS: CellRegistryOptions<Gtk.ListItem> = { isHost: isListItem, prepare: prepareCell };\nconst HEADER_OPTIONS: CellRegistryOptions<Gtk.ListHeader> = { isHost: isListHeader, prepare: prepareCell };\nconst ROW_OPTIONS: CellRegistryOptions<Gtk.ColumnViewRow> = { isHost: isColumnViewRow };\nconst NO_SIZE: CellSize = { width: -1, height: -1 };\nconst NO_ROW_PROPS: ListRowProps = {};\nconst DEFAULT_ROW_PROPS = resolveRowProps(NO_ROW_PROPS);\nconst placeholders: WeakSet<Gtk.Widget> = new WeakSet();\n\nconst placeholder = (size: CellSize): Gtk.Widget => {\n const widget = new Gtk.Box({ widthRequest: size.width, heightRequest: size.height });\n placeholders.add(widget);\n\n return widget;\n};\n\nfunction isListItem(value: GObject.Object): value is Gtk.ListItem {\n return value instanceof Gtk.ListItem;\n}\n\nfunction isListHeader(value: GObject.Object): value is Gtk.ListHeader {\n return value instanceof Gtk.ListHeader;\n}\n\nfunction isColumnViewRow(value: GObject.Object): value is Gtk.ColumnViewRow {\n return value instanceof Gtk.ColumnViewRow;\n}\n\nfunction prepareCell(host: CellHost, size: CellSize): void {\n const child = host.getChild();\n\n if (child === null) {\n host.setChild(placeholder(size));\n } else if (placeholders.has(child)) {\n child.setSizeRequest(size.width, size.height);\n }\n}\n\nfunction notifyRegistry<H extends FactoryHost>(state: CellRegistryState<H>): void {\n state.snapshot = null;\n\n for (const listener of state.listeners) {\n listener();\n }\n}\n\nfunction createEntry<H extends FactoryHost>(state: CellRegistryState<H>, host: H): CellEntry<H> {\n state.serial += 1;\n\n return { key: `gtkx-cell-${String(state.serial)}`, host, identity: createRef<ItemIdentity>() };\n}\n\nfunction setupHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n state.prepare?.(host, state.size);\n state.entries.set(host, createEntry(state, host));\n notifyRegistry(state);\n}\n\nfunction teardownHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n if (state.entries.delete(host)) {\n notifyRegistry(state);\n }\n}\n\nfunction bindHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n state.prepare?.(host, state.size);\n}\n\nfunction subscribeRegistry<H extends FactoryHost>(state: CellRegistryState<H>, onChange: () => void): () => void {\n state.listeners.add(onChange);\n\n return () => {\n state.listeners.delete(onChange);\n };\n}\n\nfunction getRegistryEntries<H extends FactoryHost>(state: CellRegistryState<H>): CellEntry<H>[] {\n state.snapshot ??= state.entries.values().toArray();\n\n return state.snapshot;\n}\n\nfunction guarded<H extends FactoryHost>(isHost: HostGuard<H>, run: (host: H) => void): (host: GObject.Object) => void {\n return (host) => {\n if (isHost(host)) {\n run(host);\n }\n };\n}\n\nfunction createHandlers<H extends FactoryHost>(state: CellRegistryState<H>): FactoryHandlers {\n const { isHost } = state;\n\n return {\n onSetup: guarded(isHost, (host) => {\n setupHost(state, host);\n }),\n onBind: guarded(isHost, (host) => {\n bindHost(state, host);\n }),\n onTeardown: guarded(isHost, (host) => {\n teardownHost(state, host);\n }),\n };\n}\n\nfunction createCellRegistry<H extends FactoryHost>(options: CellRegistryOptions<H>, size: CellSize): CellRegistry<H> {\n const state: CellRegistryState<H> = {\n ...options,\n size,\n entries: new Map(),\n snapshot: null,\n listeners: new Set(),\n serial: 0,\n };\n\n return {\n handlers: createHandlers(state),\n setSize: (next) => {\n if (state.size.width === next.width && state.size.height === next.height) {\n return;\n }\n\n state.size = next;\n\n for (const host of state.entries.keys()) {\n state.prepare?.(host, next);\n }\n },\n subscribe: (onChange) => subscribeRegistry(state, onChange),\n getEntries: () => getRegistryEntries(state),\n };\n}\n\nfunction useCellRegistry<H extends FactoryHost>(options: CellRegistryOptions<H>, size: CellSize): CellRegistry<H> {\n const [registry] = useState(() => createCellRegistry(options, size));\n\n useLayoutEffect(() => {\n registry.setSize(size);\n });\n\n return registry;\n}\n\nfunction useItemCells(size: CellSize): CellRegistry<Gtk.ListItem> {\n return useCellRegistry(CELL_OPTIONS, size);\n}\n\nfunction useHeaderCells(size: CellSize): CellRegistry<Gtk.ListHeader> {\n return useCellRegistry(HEADER_OPTIONS, size);\n}\n\nfunction isRowWanted(options: ItemSlotOptions, item: ListItem): boolean {\n return options.expandedIds?.includes(item.id) ?? false;\n}\n\nfunction collectionIndex(collection: Collection, item: ListItem, position: number | undefined): number {\n if (position === undefined) {\n return 0;\n }\n\n if (collection.idAt(position) === item.id) {\n return position;\n }\n\n const index = collection.positionFor(item.id);\n\n return index === -1 ? position : index;\n}\n\nfunction itemArgs(\n item: ListItem,\n index: number,\n row: Gtk.TreeListRow | null,\n isExpanded: boolean,\n): ListItemRenderArgs<unknown> {\n const args: ListItemRenderArgs<unknown> = { item: item.value, index };\n\n if (row === null) {\n return args;\n }\n\n args.depth = row.getDepth();\n\n if (row.isExpandable()) {\n args.isExpanded = isExpanded;\n }\n\n return args;\n}\n\nfunction slotFor(options: ItemSlotOptions): ItemSlot | null {\n const ref = slotRefFor(options.item);\n\n if (ref === null) {\n return null;\n }\n\n const item = options.collection.itemAt(ref);\n\n if (item === undefined) {\n return null;\n }\n\n return {\n itemKey: ref.key,\n item,\n position: options.position,\n row: options.row,\n args: itemArgs(\n item,\n collectionIndex(options.collection, item, options.position),\n options.row,\n isRowWanted(options, item),\n ),\n };\n}\n\nfunction useItemSlot(\n entry: CellEntry<PositionedHost>,\n state: RefObject<CollectionState>,\n identity: ItemIdentity,\n): ItemSlot | null {\n const position = useProperty(entry.host, \"position\");\n const item = useProperty(entry.host, \"item\") ?? null;\n const row = item instanceof Gtk.TreeListRow ? item : null;\n const { collection, expandedIds } = state.current;\n\n if (position === identity.position) {\n return identity.item === undefined\n ? null\n : {\n itemKey: identity.itemKey,\n item: identity.item,\n position,\n row,\n args: itemArgs(identity.item, identity.index, row, identity.isExpanded),\n };\n }\n\n return slotFor({ item, position, row, collection, expandedIds });\n}\n\nfunction itemIdentity(\n entry: CellEntry<PositionedHost>,\n collection: Collection,\n expandedIds: string[] | null | undefined,\n): ItemIdentity {\n const ref = slotRefFor(entry.host.getItem());\n const item = ref === null ? undefined : collection.itemAt(ref);\n const position = entry.host.getPosition();\n\n return {\n itemKey: ref === null || item === undefined ? \"\" : ref.key,\n item,\n position,\n index: item === undefined ? 0 : collectionIndex(collection, item, position),\n isExpanded: item !== undefined && (expandedIds?.includes(item.id) ?? false),\n };\n}\n\nfunction isSameItemIdentity(previous: ItemIdentity, next: ItemIdentity): boolean {\n return (\n previous.item === next.item &&\n previous.itemKey === next.itemKey &&\n previous.position === next.position &&\n previous.index === next.index &&\n previous.isExpanded === next.isExpanded\n );\n}\n\nfunction isSameItemCell(previous: ItemCellProps, next: ItemCellProps): boolean {\n const identity = previous.entry.identity.current ?? previous;\n\n return (\n previous.entry === next.entry &&\n previous.render === next.render &&\n previous.rowProps === next.rowProps &&\n previous.hasExpander === next.hasExpander &&\n previous.expanderDescriptions === next.expanderDescriptions &&\n isSameItemIdentity(identity, next)\n );\n}\n\nfunction isWaitingForSync<H extends FactoryHost>(_previous: PendingList<H>, next: PendingList<H>): boolean {\n return next.isPending;\n}\n\nfunction isSameItemRow(previous: ItemRowProps, next: ItemRowProps): boolean {\n const identity = previous.entry.identity.current ?? previous;\n\n return previous.entry === next.entry && previous.rowProps === next.rowProps && isSameItemIdentity(identity, next);\n}\n\nfunction createNativeItemKeyStore(): NativeItemKeyStore {\n const keys: WeakMap<GObject.Object, string> = new WeakMap();\n let serial = 0;\n\n return {\n keyFor: (item) => {\n const current = keys.get(item);\n\n if (current !== undefined) {\n return current;\n }\n\n serial += 1;\n const key = `gtkx-native-item-${String(serial)}`;\n keys.set(item, key);\n\n return key;\n },\n };\n}\n\nfunction renderedIdentity(entry: CellEntry<PositionedHost>, slot: ItemSlot | null): ItemIdentity {\n return {\n itemKey: slot?.itemKey ?? \"\",\n item: slot?.item,\n position: slot?.position ?? entry.host.getPosition(),\n index: slot?.args.index ?? 0,\n isExpanded: slot?.args.isExpanded ?? false,\n };\n}\n\nfunction useRememberIdentity(entry: CellEntry<PositionedHost>, slot: ItemSlot | null): void {\n const identityRef = entry.identity;\n useLayoutEffect(() => {\n identityRef.current = renderedIdentity(entry, slot);\n });\n}\n\nfunction expanderDescriptionFor(\n slot: ItemSlot,\n descriptions: ExpanderDescriptions | null | undefined,\n): string | undefined {\n const { isExpanded } = slot.args;\n\n if (isExpanded === undefined || descriptions == null) {\n return undefined;\n }\n\n return isExpanded ? descriptions.collapse : descriptions.expand;\n}\n\nfunction wrapExpander(\n slot: ItemSlot,\n content: ReactNode,\n descriptions: ExpanderDescriptions | null | undefined,\n): ReactNode {\n const { item, row } = slot;\n\n const expander: ReactNode =\n row === null ? (\n content\n ) : (\n <GtkTreeExpander\n listRow={row}\n hideExpander={item.shouldHideExpander ?? false}\n indentForDepth={item.shouldIndentForDepth ?? true}\n indentForIcon={item.shouldIndentForIcon ?? true}\n accessibleDescription={expanderDescriptionFor(slot, descriptions)}\n >\n {content}\n </GtkTreeExpander>\n );\n\n return expander;\n}\n\nfunction itemBody(\n slot: ItemSlot | null,\n render: ListItemRenderer<never>,\n hasExpander: boolean,\n descriptions: ExpanderDescriptions | null | undefined,\n): ReactNode {\n if (slot === null) {\n return null;\n }\n\n const renderItem = render as ListItemRenderer<unknown>;\n const content = renderItem(slot.args);\n\n return <Fragment key={slot.itemKey}>{hasExpander ? wrapExpander(slot, content, descriptions) : content}</Fragment>;\n}\n\nfunction rowText(value: string | undefined): string | null {\n return value ?? null;\n}\n\nfunction rowFlag(value: boolean | undefined): boolean {\n return value ?? true;\n}\n\nfunction resolveRowProps(props: ListRowProps): ResolvedRowProps {\n return {\n accessibleLabel: rowText(props.accessibleLabel),\n accessibleDescription: rowText(props.accessibleDescription),\n isActivatable: rowFlag(props.isActivatable),\n isFocusable: rowFlag(props.isFocusable),\n isSelectable: rowFlag(props.isSelectable),\n };\n}\n\nfunction rowPropsFor(slot: ItemSlot | null, rowProps: ListRowPropsResolver<never>): ResolvedRowProps {\n const resolve = rowProps as ListRowPropsResolver<unknown>;\n\n return resolveRowProps(slot === null ? NO_ROW_PROPS : resolve(slot.args));\n}\n\nfunction applyRowProps(host: PositionedHost, props: ResolvedRowProps, previous: ResolvedRowProps | null): void {\n if (previous?.accessibleLabel !== props.accessibleLabel) {\n host.accessibleLabel = props.accessibleLabel;\n }\n\n if (previous?.accessibleDescription !== props.accessibleDescription) {\n host.accessibleDescription = props.accessibleDescription;\n }\n\n if (previous?.isActivatable !== props.isActivatable) {\n host.setActivatable(props.isActivatable);\n }\n\n if (previous?.isFocusable !== props.isFocusable) {\n host.setFocusable(props.isFocusable);\n }\n\n if (previous?.isSelectable !== props.isSelectable) {\n host.setSelectable(props.isSelectable);\n }\n}\n\nfunction useAppliedRowProps(host: PositionedHost, props: ResolvedRowProps | null): void {\n const previous = useRef<ResolvedRowProps | null>(null);\n\n useLayoutEffect(() => {\n if (props === null && previous.current === null) {\n return;\n }\n\n const next = props ?? DEFAULT_ROW_PROPS;\n applyRowProps(host, next, previous.current);\n previous.current = props === null ? null : next;\n }, [host, props]);\n}\n\nfunction ItemCellImpl({\n entry,\n render,\n rowProps,\n state,\n hasExpander,\n expanderDescriptions,\n ...identity\n}: ItemCellProps): ReactNode {\n const slot = useItemSlot(entry, state, identity);\n useRememberIdentity(entry, slot);\n useAppliedRowProps(entry.host, rowProps == null ? null : rowPropsFor(slot, rowProps));\n const body = itemBody(slot, render, hasExpander, expanderDescriptions);\n\n return createPortal(body, entry.host, entry.key);\n}\n\nfunction ItemRowImpl({ entry, rowProps, state, ...identity }: ItemRowProps): ReactNode {\n const slot = useItemSlot(entry, state, identity);\n useRememberIdentity(entry, slot);\n useAppliedRowProps(entry.host, rowPropsFor(slot, rowProps));\n\n return null;\n}\n\nfunction HeaderCellImpl({ entry, render }: HeaderCellProps): ReactNode {\n const item = useProperty(entry.host, \"item\") ?? null;\n\n return createPortal(headerBody(levelStoreFor(item), render), entry.host, entry.key);\n}\n\nfunction NativeItemCell<T extends GObject.Object>({\n entry,\n render,\n rowProps,\n keys,\n size,\n}: NativeItemCellProps<T>): ReactNode {\n const position = useProperty(entry.host, \"position\");\n const item = useProperty(entry.host, \"item\") ?? null;\n const args = item !== null && position !== undefined ? { item: item as T, index: position } : null;\n useAppliedRowProps(\n entry.host,\n rowProps == null ? null : resolveRowProps(args === null ? NO_ROW_PROPS : rowProps(args)),\n );\n let body: ReactNode = null;\n\n if (item !== null && args !== null) {\n const content = render(args);\n const child =\n content == null || typeof content === \"boolean\" ? (\n <GtkBox widthRequest={size.width} heightRequest={size.height} />\n ) : (\n content\n );\n body = <Fragment key={keys.keyFor(item)}>{child}</Fragment>;\n }\n\n return createPortal(body, entry.host, entry.key);\n}\n\nfunction headerBody(store: LazyLevelStore | null, render: ListSectionRenderer<never>): ReactNode {\n const section = store?.level.section;\n\n if (store === null || section === undefined) {\n return null;\n }\n\n const renderHeader = render as ListSectionRenderer<unknown>;\n const key = joinParts([store.key, section.id]);\n\n return <Fragment key={key}>{renderHeader({ section: section.value })}</Fragment>;\n}\n\nfunction usePortalEntries<H extends FactoryHost>(registry: CellRegistry<H>): CellEntry<H>[] {\n return useSyncExternalStore(registry.subscribe, registry.getEntries);\n}\n\nfunction useCollectionVersion(collection: Collection): number {\n return useSyncExternalStore(collection.subscribe, collection.getVersion);\n}\n\nfunction ItemCellListImpl({\n entries,\n render,\n rowProps,\n collection,\n hasExpander,\n expandedIds,\n expanderDescriptions,\n}: ItemCellListProps): ReactNode {\n const state = useLatestRef({ collection, expandedIds });\n\n return entries.map((entry) => (\n <ItemCell\n key={entry.key}\n entry={entry}\n render={render}\n rowProps={rowProps}\n state={state}\n hasExpander={hasExpander ?? true}\n expanderDescriptions={expanderDescriptions}\n {...itemIdentity(entry, collection, expandedIds)}\n />\n ));\n}\n\nconst ItemPortals = ({ registry, ...props }: ItemPortalsProps): ReactNode => {\n const entries = usePortalEntries(registry);\n useCollectionVersion(props.collection);\n\n return <ItemCellList {...props} entries={entries} isPending={props.collection.isPending()} />;\n};\n\nfunction ItemRowListImpl({ entries, rowProps, collection, expandedIds }: ItemRowListProps): ReactNode {\n const state = useLatestRef({ collection, expandedIds });\n\n return entries.map((entry) => (\n <ItemRow\n key={entry.key}\n entry={entry}\n rowProps={rowProps}\n state={state}\n {...itemIdentity(entry, collection, expandedIds)}\n />\n ));\n}\n\nconst RowPortals = ({ registry, ...props }: RowPortalsProps): ReactNode => {\n const entries = usePortalEntries(registry);\n useCollectionVersion(props.collection);\n\n return <ItemRowList {...props} entries={entries} isPending={props.collection.isPending()} />;\n};\n\nconst HeaderPortals = ({ registry, render, collection }: HeaderPortalsProps): ReactNode => {\n const entries = usePortalEntries(registry);\n const version = useCollectionVersion(collection);\n\n return entries.map((entry) => <HeaderCell key={entry.key} entry={entry} render={render} version={version} />);\n};\n\nfunction NativeItemPortals<T extends GObject.Object>({\n registry,\n render,\n rowProps,\n size,\n}: NativeItemPortalsProps<T>): ReactNode {\n const entries = usePortalEntries(registry);\n const [keys] = useState(createNativeItemKeyStore);\n\n return entries.map((entry) => (\n <NativeItemCell key={entry.key} entry={entry} render={render} rowProps={rowProps} keys={keys} size={size} />\n ));\n}\n\nconst useSectionHeader = (\n render: ListSectionRenderer<never> | null | undefined,\n collection: Collection,\n size: CellSize,\n): SectionHeaderSlot => {\n const registry = useHeaderCells(size);\n\n if (render == null) {\n return { factoryProps: {}, portals: null };\n }\n\n return {\n factoryProps: { headerFactory: <GtkSignalListItemFactory {...registry.handlers} /> },\n portals: <HeaderPortals registry={registry} render={render} collection={collection} />,\n };\n};\n\nconst useRowProps = (\n rowProps: ListRowPropsResolver<never> | null | undefined,\n collection: Collection,\n expandedIds: string[] | null | undefined,\n): RowSlot => {\n const registry = useCellRegistry(ROW_OPTIONS, NO_SIZE);\n\n if (rowProps == null) {\n return { factoryProps: {}, portals: null };\n }\n\n return {\n factoryProps: { rowFactory: <GtkSignalListItemFactory {...registry.handlers} /> },\n portals: (\n <RowPortals registry={registry} rowProps={rowProps} collection={collection} expandedIds={expandedIds} />\n ),\n };\n};\n\nexport { useItemCells, useRowProps, useSectionHeader, ItemPortals, NativeItemPortals, type CellSize };\n"]}
@@ -1,18 +1,16 @@
1
1
  import type { ListItem, ListSection } from "../types.js";
2
+ type SectionIdentity = Pick<ListSection, "id" | "value">;
2
3
  type Level = {
3
4
  path: string;
4
5
  items: ListItem[];
5
6
  expandableFlags: boolean[];
7
+ section?: SectionIdentity | undefined;
6
8
  };
7
- type SectionIdentity = Pick<ListSection, "id" | "value">;
8
9
  type CollectionIndex = {
9
10
  isTree: boolean;
10
11
  groups: Level[];
11
12
  childLevel: (level: Level, slot: number) => Level | undefined;
12
- levelFor: (levelPath: string) => Level | undefined;
13
- itemAt: (levelPath: string, slot: number) => ListItem | undefined;
14
- sectionFor: (levelPath: string) => SectionIdentity | undefined;
15
13
  };
16
14
  declare function createCollectionIndex(items: ListItem[] | undefined, sections: ListSection[] | undefined, isFlat: boolean): CollectionIndex;
17
- export { createCollectionIndex, type CollectionIndex, type Level, type SectionIdentity };
15
+ export { createCollectionIndex, type CollectionIndex, type Level };
18
16
  //# sourceMappingURL=collection-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-index.d.ts","sourceRoot":"","sources":["../../src/internal/collection-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzD,KAAK,KAAK,GAAG;IACT,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,eAAe,EAAE,OAAO,EAAE,CAAC;CAC9B,CAAC;AAEF,KAAK,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC;AAEzD,KAAK,eAAe,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,GAAG,SAAS,CAAC;IAC9D,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,KAAK,GAAG,SAAS,CAAC;IACnD,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,CAAC;IAClE,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;CAClE,CAAC;AAoGF,iBAAS,qBAAqB,CAC1B,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAC7B,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,EACnC,MAAM,EAAE,OAAO,GAChB,eAAe,CAoBjB;AAED,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,KAAK,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"collection-index.d.ts","sourceRoot":"","sources":["../../src/internal/collection-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzD,KAAK,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC;AAEzD,KAAK,KAAK,GAAG;IACT,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,GAAG,SAAS,CAAC;CACjE,CAAC;AAmGF,iBAAS,qBAAqB,CAC1B,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAC7B,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,EACnC,MAAM,EAAE,OAAO,GAChB,eAAe,CAgBjB;AAED,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,CAAC"}
@@ -49,9 +49,9 @@ function buildGroups(state, source, sections) {
49
49
  return [newLevel(state, encodePart("0"), source)];
50
50
  }
51
51
  return sections.map((section, group) => {
52
- const path = encodePart(String(group));
53
- state.sections.set(path, { id: section.id, value: section.value });
54
- return newLevel(state, path, section.data);
52
+ const level = newLevel(state, encodePart(String(group)), section.data);
53
+ level.section = { id: section.id, value: section.value };
54
+ return level;
55
55
  });
56
56
  }
57
57
  function isTreeSource(source, sections, isFlat) {
@@ -69,16 +69,12 @@ function createCollectionIndex(items, sections, isFlat) {
69
69
  isTree: isTreeSource(source, sections, isFlat),
70
70
  groups: [],
71
71
  levels: new Map(),
72
- sections: new Map(),
73
72
  };
74
73
  state.groups = buildGroups(state, source, sections);
75
74
  return {
76
75
  isTree: state.isTree,
77
76
  groups: state.groups,
78
77
  childLevel: (level, slot) => childLevel(state, level, slot),
79
- levelFor: (levelPath) => levelFor(state, levelPath),
80
- itemAt: (levelPath, slot) => levelFor(state, levelPath)?.items[slot],
81
- sectionFor: (levelPath) => state.sections.get(levelPath),
82
78
  };
83
79
  }
84
80
  export { createCollectionIndex };