@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
@@ -1 +1 @@
1
- {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/internal/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,KAAK,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG;IAC7D,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,SAAS,CAAC;IAC/C,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;IAC/D,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC1C,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACzC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC5C,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC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,CAAC;IACpC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,WAAW,CAAC;CAC3C,CAAC;AAyDF,iBAAS,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAIzD;AAED,iBAAS,gBAAgB,CACrB,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,GACnC,UAAU,CAeZ;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { slotPathAt, slotRefFor } from "./collection-model.js";
2
+ import { orderFor } from "./tree-expansion.js";
2
3
  import { findIds, findRows } from "./tree-order.js";
3
4
  const NO_ROWS = { positions: [], ids: [] };
4
5
  const NO_IDS = [];
@@ -10,8 +11,7 @@ function rowsFor(gtkModel, ids) {
10
11
  return findRows(expansion.index, expansion.slots, new Set(ids));
11
12
  }
12
13
  function positionFor(gtkModel, id) {
13
- const [first = -1] = rowsFor(gtkModel, [id]).positions;
14
- return first;
14
+ return orderFor(gtkModel.expansion).positions.get(id) ?? -1;
15
15
  }
16
16
  function refAt(model, position) {
17
17
  if (position < 0) {
@@ -19,12 +19,12 @@ function refAt(model, position) {
19
19
  }
20
20
  return slotRefFor(model?.getItem(position) ?? null);
21
21
  }
22
- function itemAt(index, ref) {
23
- return index.itemAt(ref.store.level.path, ref.slot);
22
+ function itemAt(ref) {
23
+ return ref.store.level.items[ref.slot];
24
24
  }
25
- function idAt(model, index, position) {
25
+ function idAt(model, position) {
26
26
  const ref = refAt(model, position);
27
- return ref === null ? null : (itemAt(index, ref)?.id ?? null);
27
+ return ref === null ? null : (itemAt(ref)?.id ?? null);
28
28
  }
29
29
  function pathAt(model, position) {
30
30
  const ref = refAt(model, position);
@@ -49,11 +49,13 @@ function createCollection(gtkModel, index, model) {
49
49
  expansion: gtkModel.expansion,
50
50
  isTree: index.isTree,
51
51
  rowAt: gtkModel.rowAt,
52
- itemAt: (ref) => itemAt(index, ref),
53
- sectionFor: index.sectionFor,
54
- idAt: (position) => idAt(model, index, position),
52
+ subscribe: gtkModel.subscribe,
53
+ getVersion: gtkModel.getVersion,
54
+ itemAt,
55
+ idAt: (position) => idAt(model, position),
55
56
  idsAt: (positions) => idsAt(gtkModel, positions),
56
57
  pathAt: (position) => pathAt(model, position),
58
+ isPending: () => gtkModel.isPending(index),
57
59
  positionFor: (id) => positionFor(gtkModel, id),
58
60
  rowsFor: (ids) => rowsFor(gtkModel, ids),
59
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/internal/collection.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAapD,MAAM,OAAO,GAAgB,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACxD,MAAM,MAAM,GAAa,EAAE,CAAC;AAE5B,SAAS,OAAO,CAAC,QAAyB,EAAE,GAAa;IACrD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IAE/B,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,WAAW,CAAC,QAAyB,EAAE,EAAU;IACtD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,KAAK,CAAC,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E,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAsB;IAC5C,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;IAEjC,OAAO,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;AACzD,CAAC;AAED,SAAS,gBAAgB,CACrB,QAAyB,EACzB,KAAsB,EACtB,KAAkC;IAElC,OAAO;QACH,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC;QACnC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC;QAChD,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;QAChD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC;QAC7C,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;KAC3C,CAAC;AACN,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ListItem } from \"../types.js\";\nimport type { CollectionIndex, SectionIdentity } from \"./collection-index.js\";\nimport type { CollectionModel, SlotRef } from \"./collection-model.js\";\nimport type { MatchedRows } from \"./tree-order.js\";\nimport { slotPathAt, slotRefFor } from \"./collection-model.js\";\nimport { findIds, findRows } from \"./tree-order.js\";\n\ntype Collection = Pick<CollectionModel, \"expansion\" | \"rowAt\"> & {\n isTree: boolean;\n itemAt: (ref: SlotRef) => ListItem | undefined;\n sectionFor: (levelPath: string) => SectionIdentity | undefined;\n idAt: (position: number) => string | null;\n idsAt: (positions: number[]) => string[];\n pathAt: (position: number) => string | null;\n positionFor: (id: string) => number;\n rowsFor: (ids: string[]) => MatchedRows;\n};\n\nconst NO_ROWS: MatchedRows = { positions: [], ids: [] };\nconst NO_IDS: string[] = [];\n\nfunction rowsFor(gtkModel: CollectionModel, ids: string[]): MatchedRows {\n if (ids.length === 0) {\n return NO_ROWS;\n }\n\n const { expansion } = gtkModel;\n\n return findRows(expansion.index, expansion.slots, new Set(ids));\n}\n\nfunction positionFor(gtkModel: CollectionModel, id: string): number {\n const [first = -1] = rowsFor(gtkModel, [id]).positions;\n\n return first;\n}\n\nfunction refAt(model: Gtk.FlattenListModel | null, position: number): SlotRef | null {\n if (position < 0) {\n return null;\n }\n\n return slotRefFor(model?.getItem(position) ?? null);\n}\n\nfunction itemAt(index: CollectionIndex, ref: SlotRef): ListItem | undefined {\n return index.itemAt(ref.store.level.path, ref.slot);\n}\n\nfunction idAt(model: Gtk.FlattenListModel | null, index: CollectionIndex, position: number): string | null {\n const ref = refAt(model, position);\n\n return ref === null ? null : (itemAt(index, ref)?.id ?? null);\n}\n\nfunction pathAt(model: Gtk.FlattenListModel | null, position: number): string | null {\n const ref = refAt(model, position);\n\n if (ref === null) {\n return null;\n }\n\n return slotPathAt(ref.store, ref.slot);\n}\n\nfunction idsAt(gtkModel: CollectionModel, positions: number[]): string[] {\n if (positions.length === 0) {\n return NO_IDS;\n }\n\n const { expansion } = gtkModel;\n\n return findIds(expansion.index, expansion.slots, new Set(positions));\n}\n\nfunction isCollectionIdle(collection: Collection): boolean {\n const { expansion } = collection;\n\n return !expansion.isApplying && !expansion.isSyncing;\n}\n\nfunction createCollection(\n gtkModel: CollectionModel,\n index: CollectionIndex,\n model: Gtk.FlattenListModel | null,\n): Collection {\n return {\n expansion: gtkModel.expansion,\n isTree: index.isTree,\n rowAt: gtkModel.rowAt,\n itemAt: (ref) => itemAt(index, ref),\n sectionFor: index.sectionFor,\n idAt: (position) => idAt(model, index, position),\n idsAt: (positions) => idsAt(gtkModel, positions),\n pathAt: (position) => pathAt(model, position),\n positionFor: (id) => positionFor(gtkModel, id),\n rowsFor: (ids) => rowsFor(gtkModel, ids),\n };\n}\n\nexport { createCollection, isCollectionIdle, type Collection };\n"]}
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/internal/collection.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAapD,MAAM,OAAO,GAAgB,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACxD,MAAM,MAAM,GAAa,EAAE,CAAC;AAE5B,SAAS,OAAO,CAAC,QAAyB,EAAE,GAAa;IACrD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IAE/B,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,WAAW,CAAC,QAAyB,EAAE,EAAU;IACtD,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,KAAK,CAAC,KAAkC,EAAE,QAAgB;IAC/D,IAAI,QAAQ,GAAG,CAAC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AAS,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;AACzD,CAAC;AAED,SAAS,gBAAgB,CACrB,QAAyB,EACzB,KAAsB,EACtB,KAAkC;IAElC,OAAO;QACH,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,MAAM;QACN,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;QACzC,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;QAChD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC;QAC7C,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC;QAC1C,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;KAC3C,CAAC;AACN,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ListItem } from \"../types.js\";\nimport type { CollectionIndex } from \"./collection-index.js\";\nimport type { CollectionModel, SlotRef } from \"./collection-model.js\";\nimport type { MatchedRows } from \"./tree-order.js\";\nimport { slotPathAt, slotRefFor } from \"./collection-model.js\";\nimport { orderFor } from \"./tree-expansion.js\";\nimport { findIds, findRows } from \"./tree-order.js\";\n\ntype Collection = Pick<CollectionModel, \"expansion\" | \"rowAt\" | \"subscribe\" | \"getVersion\"> & {\n isTree: boolean;\n itemAt: (ref: SlotRef) => ListItem | undefined;\n idAt: (position: number) => string | null;\n idsAt: (positions: number[]) => string[];\n pathAt: (position: number) => string | null;\n isPending: () => boolean;\n positionFor: (id: string) => number;\n rowsFor: (ids: string[]) => MatchedRows;\n};\n\nconst NO_ROWS: MatchedRows = { positions: [], ids: [] };\nconst NO_IDS: string[] = [];\n\nfunction rowsFor(gtkModel: CollectionModel, ids: string[]): MatchedRows {\n if (ids.length === 0) {\n return NO_ROWS;\n }\n\n const { expansion } = gtkModel;\n\n return findRows(expansion.index, expansion.slots, new Set(ids));\n}\n\nfunction positionFor(gtkModel: CollectionModel, id: string): number {\n return orderFor(gtkModel.expansion).positions.get(id) ?? -1;\n}\n\nfunction refAt(model: Gtk.FlattenListModel | null, position: number): SlotRef | null {\n if (position < 0) {\n return null;\n }\n\n return slotRefFor(model?.getItem(position) ?? null);\n}\n\nfunction itemAt(ref: SlotRef): ListItem | undefined {\n return ref.store.level.items[ref.slot];\n}\n\nfunction idAt(model: Gtk.FlattenListModel | null, position: number): string | null {\n const ref = refAt(model, position);\n\n return ref === null ? null : (itemAt(ref)?.id ?? null);\n}\n\nfunction pathAt(model: Gtk.FlattenListModel | null, position: number): string | null {\n const ref = refAt(model, position);\n\n if (ref === null) {\n return null;\n }\n\n return slotPathAt(ref.store, ref.slot);\n}\n\nfunction idsAt(gtkModel: CollectionModel, positions: number[]): string[] {\n if (positions.length === 0) {\n return NO_IDS;\n }\n\n const { expansion } = gtkModel;\n\n return findIds(expansion.index, expansion.slots, new Set(positions));\n}\n\nfunction isCollectionIdle(collection: Collection): boolean {\n const { expansion } = collection;\n\n return !expansion.isApplying && !expansion.isSyncing;\n}\n\nfunction createCollection(\n gtkModel: CollectionModel,\n index: CollectionIndex,\n model: Gtk.FlattenListModel | null,\n): Collection {\n return {\n expansion: gtkModel.expansion,\n isTree: index.isTree,\n rowAt: gtkModel.rowAt,\n subscribe: gtkModel.subscribe,\n getVersion: gtkModel.getVersion,\n itemAt,\n idAt: (position) => idAt(model, position),\n idsAt: (positions) => idsAt(gtkModel, positions),\n pathAt: (position) => pathAt(model, position),\n isPending: () => gtkModel.isPending(index),\n positionFor: (id) => positionFor(gtkModel, id),\n rowsFor: (ids) => rowsFor(gtkModel, ids),\n };\n}\n\nexport { createCollection, isCollectionIdle, type Collection };\n"]}
@@ -4,6 +4,7 @@ type ControlledSyncOptions<T> = {
4
4
  target?: object | null | undefined;
5
5
  apply: (value: T) => void;
6
6
  };
7
+ declare function hasSameIds(reported: string[], requested: string[]): boolean;
7
8
  declare function useControlledSync<T>(options: ControlledSyncOptions<T>): () => void;
8
- export { useControlledSync };
9
+ export { hasSameIds, useControlledSync };
9
10
  //# sourceMappingURL=controlled-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"controlled-sync.d.ts","sourceRoot":"","sources":["../../src/internal/controlled-sync.ts"],"names":[],"mappings":"AAGA,KAAK,qBAAqB,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B,CAAC;AAEF,iBAAS,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAiB3E;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"controlled-sync.d.ts","sourceRoot":"","sources":["../../src/internal/controlled-sync.ts"],"names":[],"mappings":"AAGA,KAAK,qBAAqB,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B,CAAC;AAEF,iBAAS,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAKpE;AAED,iBAAS,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAiB3E;AAED,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,5 +1,10 @@
1
1
  import { useLatestRef } from "@gtkx/react/internal";
2
2
  import { startTransition, useLayoutEffect, useState } from "react";
3
+ function hasSameIds(reported, requested) {
4
+ const wanted = new Set(requested);
5
+ const actual = new Set(reported);
6
+ return actual.size === wanted.size && actual.isSubsetOf(wanted);
7
+ }
3
8
  function useControlledSync(options) {
4
9
  const { value, source, target } = options;
5
10
  const [drift, setDrift] = useState(0);
@@ -14,5 +19,5 @@ function useControlledSync(options) {
14
19
  }, [applyRef, target, source, value, drift]);
15
20
  return markDrift;
16
21
  }
17
- export { useControlledSync };
22
+ export { hasSameIds, useControlledSync };
18
23
  //# sourceMappingURL=controlled-sync.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"controlled-sync.js","sourceRoot":"","sources":["../../src/internal/controlled-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AASnE,SAAS,iBAAiB,CAAI,OAAiC;IAC3D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEtC,MAAM,SAAS,GAAG,GAAS,EAAE;QACzB,eAAe,CAAC,GAAG,EAAE;YACjB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE7C,eAAe,CAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAE7C,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { useLatestRef } from \"@gtkx/react/internal\";\nimport { startTransition, useLayoutEffect, useState } from \"react\";\n\ntype ControlledSyncOptions<T> = {\n value: T;\n source?: object | null | undefined;\n target?: object | null | undefined;\n apply: (value: T) => void;\n};\n\nfunction useControlledSync<T>(options: ControlledSyncOptions<T>): () => void {\n const { value, source, target } = options;\n const [drift, setDrift] = useState(0);\n\n const markDrift = (): void => {\n startTransition(() => {\n setDrift((count) => count + 1);\n });\n };\n\n const applyRef = useLatestRef(options.apply);\n\n useLayoutEffect(() => {\n applyRef.current(value);\n }, [applyRef, target, source, value, drift]);\n\n return markDrift;\n}\n\nexport { useControlledSync };\n"]}
1
+ {"version":3,"file":"controlled-sync.js","sourceRoot":"","sources":["../../src/internal/controlled-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AASnE,SAAS,UAAU,CAAC,QAAkB,EAAE,SAAmB;IACvD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEjC,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,iBAAiB,CAAI,OAAiC;IAC3D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEtC,MAAM,SAAS,GAAG,GAAS,EAAE;QACzB,eAAe,CAAC,GAAG,EAAE;YACjB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE7C,eAAe,CAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAE7C,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { useLatestRef } from \"@gtkx/react/internal\";\nimport { startTransition, useLayoutEffect, useState } from \"react\";\n\ntype ControlledSyncOptions<T> = {\n value: T;\n source?: object | null | undefined;\n target?: object | null | undefined;\n apply: (value: T) => void;\n};\n\nfunction hasSameIds(reported: string[], requested: string[]): boolean {\n const wanted = new Set(requested);\n const actual = new Set(reported);\n\n return actual.size === wanted.size && actual.isSubsetOf(wanted);\n}\n\nfunction useControlledSync<T>(options: ControlledSyncOptions<T>): () => void {\n const { value, source, target } = options;\n const [drift, setDrift] = useState(0);\n\n const markDrift = (): void => {\n startTransition(() => {\n setDrift((count) => count + 1);\n });\n };\n\n const applyRef = useLatestRef(options.apply);\n\n useLayoutEffect(() => {\n applyRef.current(value);\n }, [applyRef, target, source, value, drift]);\n\n return markDrift;\n}\n\nexport { hasSameIds, useControlledSync };\n"]}
@@ -1,9 +1,14 @@
1
- import type * as GObject from "@gtkx/gi/gobject";
1
+ import type * as Adw from "@gtkx/gi/adw";
2
2
  import type { ElementType, ReactNode, Ref } from "react";
3
+ import * as Gtk from "@gtkx/gi/gtk";
4
+ import type * as Pango from "@gtkx/gi/pango";
3
5
  import type { DropDownOwnProps } from "../types.js";
4
- type SelectableWidget = GObject.Object & {
5
- getSelected: () => number;
6
- selected: number;
6
+ type SelectableWidget = Gtk.DropDown | Adw.ComboRow;
7
+ /** Label settings of the widget's own default item factory, kept by the default renderers. */
8
+ type ItemLabelProps = {
9
+ ellipsize?: Pango.EllipsizeMode;
10
+ maxWidthChars?: number;
11
+ widthChars?: number;
7
12
  };
8
13
  type DropDownBaseProps = DropDownOwnProps<unknown, unknown> & {
9
14
  onNotifySelected?: ((value: number | null, self: SelectableWidget) => void) | null | undefined;
@@ -11,6 +16,7 @@ type DropDownBaseProps = DropDownOwnProps<unknown, unknown> & {
11
16
  } & Record<string, unknown>;
12
17
  declare function DropDownBase(props: DropDownBaseProps & {
13
18
  component: ElementType;
19
+ itemLabel?: ItemLabelProps;
14
20
  }): ReactNode;
15
21
  export { DropDownBase, type DropDownBaseProps };
16
22
  //# sourceMappingURL=drop-down.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"drop-down.d.ts","sourceRoot":"","sources":["../../src/internal/drop-down.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIzD,OAAO,KAAK,EAAE,gBAAgB,EAAwC,MAAM,aAAa,CAAC;AAO1F,KAAK,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG;I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,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG;IAC1D,gBAAgB,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/F,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CAClD,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA2O5B,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG;IAAE,SAAS,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,cAAc,CAAA;CAAE,GAAG,SAAS,CAsClH;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,CAAC"}
@@ -1,14 +1,21 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { GtkLabel, GtkSignalListItemFactory } from "@gtkx/jsx/gtk";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as GObject from "@gtkx/gi/gobject";
3
+ import * as Gtk from "@gtkx/gi/gtk";
4
+ import { GtkBox, GtkImage, GtkLabel, GtkSignalListItemFactory } from "@gtkx/jsx/gtk";
5
+ import { useProperty } from "@gtkx/react";
6
+ import { useLatestRef } from "@gtkx/react/internal";
3
7
  import { omit } from "@gtkx/utils";
4
- import { useRef } from "react";
8
+ import { useLayoutEffect, useRef, useState } from "react";
5
9
  import { ItemPortals, useItemCells, useSectionHeader } from "./cells.js";
10
+ import { slotRefFor } from "./collection-model.js";
6
11
  import { isCollectionIdle } from "./collection.js";
7
12
  import { useControlledSync } from "./controlled-sync.js";
13
+ import { showFirstHeader } from "./first-header.js";
8
14
  import { useCollectionData } from "./use-collection.js";
9
15
  import { useWidgetRef } from "./use-widget-ref.js";
10
16
  const DROP_DOWN_PROPS = [
11
17
  "component",
18
+ "itemLabel",
12
19
  "items",
13
20
  "sections",
14
21
  "selectedId",
@@ -22,8 +29,46 @@ const DROP_DOWN_PROPS = [
22
29
  function newApplyState() {
23
30
  return { isApplying: false, isReady: false };
24
31
  }
25
- const defaultRenderItem = ({ item }) => item == null ? null : _jsx(GtkLabel, { children: String(item) });
26
- const faceRenderer = (props) => props.renderItem ?? defaultRenderItem;
32
+ const defaultRenderer = (itemLabel) => ({ item }) => item == null ? null : _jsx(GtkLabel, { ...itemLabel, children: String(item) });
33
+ const faceRenderer = (props, itemLabel) => props.renderItem ?? defaultRenderer(itemLabel);
34
+ const selectionMarkedRenderer = (selected, itemLabel) => ({ item, index }) => (_jsxs(GtkBox, { children: [_jsx(GtkLabel, { xalign: 0, ...itemLabel, children: item == null ? "" : String(item) }), _jsx(GtkImage, { iconName: "object-select-symbolic", accessibleRole: Gtk.AccessibleRole.PRESENTATION, opacity: index === selected ? 1 : 0 })] }));
35
+ const popupRenderer = (props, selected, itemLabel) => props.renderListItem ?? (props.renderItem == null ? selectionMarkedRenderer(selected, itemLabel) : null);
36
+ const textOf = (value) => {
37
+ switch (typeof value) {
38
+ case "string":
39
+ return value;
40
+ case "number":
41
+ case "bigint":
42
+ case "boolean":
43
+ return String(value);
44
+ case "symbol":
45
+ return value.toString();
46
+ default:
47
+ return "";
48
+ }
49
+ };
50
+ const slotText = (collection, ref) => ref === null ? "" : textOf(collection.itemAt(ref)?.value);
51
+ /**
52
+ * AdwComboRow reads the selected item's text for its subtitle only when the selected item or the expression changes.
53
+ * Slots keep their objects when an item's value changes in place, so the expression is replaced when the selected
54
+ * item's text changes without a selection change.
55
+ */
56
+ const useItemTextExpression = (widget, collection) => {
57
+ const latest = useLatestRef(collection);
58
+ const shown = useRef({ ref: null, text: "" });
59
+ const createExpression = () => Gtk.ClosureExpression.new(GObject.TYPE_STRING, (object) => slotText(latest.current, slotRefFor(object)), null);
60
+ const [expression, setExpression] = useState(createExpression);
61
+ useLayoutEffect(() => {
62
+ const ref = slotRefFor(widget?.getSelectedItem() ?? null);
63
+ const text = slotText(collection, ref);
64
+ const isRenamed = ref !== null && ref === shown.current.ref && text !== shown.current.text;
65
+ shown.current = { ref, text };
66
+ if (isRenamed) {
67
+ setExpression(createExpression());
68
+ }
69
+ });
70
+ return expression;
71
+ };
27
72
  const resolvePosition = (widget, collection, selectedId) => {
28
73
  if (selectedId === undefined) {
29
74
  return widget.getSelected();
@@ -107,17 +152,24 @@ const useDropDownSelection = (options) => {
107
152
  };
108
153
  };
109
154
  function DropDownBase(props) {
110
- const { component: Component, items, sections, renderListItem, renderHeader, ref } = props;
155
+ const { component: Component, itemLabel = {}, items, sections, renderHeader, ref } = props;
111
156
  const rest = omit(props, DROP_DOWN_PROPS);
112
157
  const [widget, refCallback] = useWidgetRef(ref);
113
- const { collection, model } = useCollectionData({ items, sections, isFlat: true });
158
+ const { collection, model } = useCollectionData({
159
+ items,
160
+ sections,
161
+ isFlat: true,
162
+ onSectionsFilled: () => showFirstHeader(widget),
163
+ });
114
164
  const faceCells = useItemCells({ width: -1, height: -1 });
115
165
  const listCells = useItemCells({ width: -1, height: -1 });
116
166
  const header = useSectionHeader(renderHeader, collection, { width: -1, height: -1 });
117
167
  const handleNotifySelected = useDropDownSelection({ widget, collection, props });
118
- return (_jsxs(_Fragment, { children: [_jsx(Component, { ref: refCallback, model: model, factory: _jsx(GtkSignalListItemFactory, { ...faceCells.handlers }), ...(renderListItem != null && {
168
+ const renderListItem = popupRenderer(props, useProperty(widget, "selected"), itemLabel);
169
+ const expression = useItemTextExpression(widget, collection);
170
+ return (_jsxs(_Fragment, { children: [_jsx(Component, { ref: refCallback, model: model, expression: expression, factory: _jsx(GtkSignalListItemFactory, { ...faceCells.handlers }), ...(renderListItem !== null && {
119
171
  listFactory: _jsx(GtkSignalListItemFactory, { ...listCells.handlers }),
120
- }), ...header.factoryProps, ...rest, onNotifySelected: handleNotifySelected }), _jsx(ItemPortals, { registry: faceCells, render: faceRenderer(props), collection: collection }), renderListItem != null && (_jsx(ItemPortals, { registry: listCells, render: renderListItem, collection: collection })), header.portals] }));
172
+ }), ...header.factoryProps, ...rest, onNotifySelected: handleNotifySelected }), _jsx(ItemPortals, { registry: faceCells, render: faceRenderer(props, itemLabel), collection: collection }), renderListItem !== null && (_jsx(ItemPortals, { registry: listCells, render: renderListItem, collection: collection })), header.portals] }));
121
173
  }
122
174
  export { DropDownBase };
123
175
  //# sourceMappingURL=drop-down.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drop-down.js","sourceRoot":"","sources":["../../src/internal/drop-down.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA8BnD,MAAM,eAAe,GAAa;IAC9B,WAAW;IACX,OAAO;IACP,UAAU;IACV,YAAY;IACZ,oBAAoB;IACpB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,KAAK;CACR,CAAC;AAEF,SAAS,aAAa;IAClB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,iBAAiB,GAAG,CAAC,EAAE,IAAI,EAAiC,EAAa,EAAE,CAC7E,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAC,Q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AW,EAChB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,KAAC,wBAAwB,OAAK,SAAS,CAAC,QAAQ,GAAI,KACzD,CAAC,cAAc,IAAI,IAAI,IAAI;oBAC3B,WAAW,EAAE,KAAC,wBAAwB,OAAK,SAAS,CAAC,QAAQ,GAAI;iBACpE,CAAC,KACE,MAAM,CAAC,YAAY,KACnB,IAAI,EACR,gBAAgB,EAAE,oBAAoB,GACxC,EACF,KAAC,WAAW,IAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,UAAU,GAAI,EACxF,cAAc,IAAI,IAAI,IAAI,CACvB,KAAC,WAAW,IAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAI,CACvF,EACA,MAAM,CAAC,OAAO,IAChB,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,YAAY,EAA0B,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { ElementType, ReactNode, Ref } from \"react\";\nimport { GtkLabel, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { omit, type Primitive } from \"@gtkx/utils\";\nimport { useRef } from \"react\";\nimport type { DropDownOwnProps, ListItemRenderArgs, ListItemRenderer } from \"../types.js\";\nimport { ItemPortals, useItemCells, useSectionHeader } from \"./cells.js\";\nimport { type Collection, isCollectionIdle } from \"./collection.js\";\nimport { useControlledSync } from \"./controlled-sync.js\";\nimport { useCollectionData } from \"./use-collection.js\";\nimport { useWidgetRef } from \"./use-widget-ref.js\";\n\ntype SelectableWidget = GObject.Object & { getSelected: () => number; selected: number };\n\ntype DropDownBaseProps = DropDownOwnProps<unknown, unknown> & {\n onNotifySelected?: ((value: number | null, self: SelectableWidget) => void) | null | undefined;\n ref?: Ref<SelectableWidget | null> | undefined;\n} & Record<string, unknown>;\n\ntype SelectionOptions = {\n widget: SelectableWidget | null;\n collection: Collection;\n props: DropDownBaseProps;\n};\n\ntype NotifySelectedHandler = NonNullable<DropDownBaseProps[\"onNotifySelected\"]>;\ntype ApplyState = { isApplying: boolean; isReady: boolean };\n\ntype NotifyContext = {\n options: SelectionOptions;\n known: { current: string | null };\n state: ApplyState;\n markDrift: () => void;\n};\n\ntype KnownSelection = {\n known: { current: string | null };\n onSelectionChanged: ((id: string | null) => void) | null | undefined;\n};\n\nconst DROP_DOWN_PROPS: string[] = [\n \"component\",\n \"items\",\n \"sections\",\n \"selectedId\",\n \"onSelectionChanged\",\n \"onNotifySelected\",\n \"renderItem\",\n \"renderListItem\",\n \"renderHeader\",\n \"ref\",\n];\n\nfunction newApplyState(): ApplyState {\n return { isApplying: false, isReady: false };\n}\n\nconst defaultRenderItem = ({ item }: ListItemRenderArgs<Primitive>): ReactNode =>\n item == null ? null : <GtkLabel>{String(item)}</GtkLabel>;\nconst faceRenderer = (props: DropDownBaseProps): ListItemRenderer<never> => props.renderItem ?? defaultRenderItem;\n\nconst resolvePosition = (\n widget: SelectableWidget,\n collection: Collection,\n selectedId: string | undefined,\n): number => {\n if (selectedId === undefined) {\n return widget.getSelected();\n }\n\n const requested = collection.positionFor(selectedId);\n\n return requested >= 0 ? requested : widget.getSelected();\n};\n\nconst updateKnownSelection = (\n tracker: KnownSelection,\n effectiveId: string | null,\n selectedId: string | undefined,\n): void => {\n const { known, onSelectionChanged } = tracker;\n const expectedId = selectedId ?? known.current;\n const isNew = effectiveId !== known.current;\n known.current = effectiveId;\n\n if (expectedId !== null && effectiveId !== expectedId && isNew) {\n onSelectionChanged?.(effectiveId);\n }\n};\n\nconst reportKnownSelection = (tracker: KnownSelection, id: string | null): void => {\n const { known, onSelectionChanged } = tracker;\n\n if (id === known.current) {\n return;\n }\n\n known.current = id;\n onSelectionChanged?.(id);\n};\n\nconst hasSelectionDrifted = (\n widget: SelectableWidget,\n collection: Collection,\n selectedId: string | undefined,\n): boolean => {\n if (selectedId === undefined) {\n return false;\n }\n\n const requested = collection.positionFor(selectedId);\n\n return requested >= 0 && widget.getSelected() !== requested;\n};\n\nconst applySelectedPosition = (widget: SelectableWidget, position: number, state: ApplyState): void => {\n state.isApplying = true;\n\n try {\n widget.selected = position;\n } finally {\n state.isApplying = false;\n }\n};\n\nconst dispatchSelectedNotify = (context: NotifyContext, value: number | null, self: SelectableWidget): void => {\n const { options, known, state, markDrift } = context;\n\n if (state.isApplying) {\n return;\n }\n\n options.props.onNotifySelected?.(value, self);\n\n if (!state.isReady || !isCollectionIdle(options.collection)) {\n return;\n }\n\n reportKnownSelection(\n { known, onSelectionChanged: options.props.onSelectionChanged },\n options.collection.idAt(self.getSelected()),\n );\n\n if (hasSelectionDrifted(self, options.collection, options.props.selectedId)) {\n markDrift();\n }\n};\n\nconst useDropDownSelection = (options: SelectionOptions): NotifySelectedHandler => {\n const { widget, collection } = options;\n const { selectedId } = options.props;\n const known = useRef<string | null>(null);\n const applyState = useRef<ApplyState>(newApplyState());\n\n const syncKnownSelection = (position: number, requestedId: string | undefined): void => {\n const effectiveId = collection.idAt(position);\n const { onSelectionChanged } = options.props;\n updateKnownSelection({ known, onSelectionChanged }, effectiveId, requestedId);\n applyState.current.isReady = true;\n };\n\n const markDrift = useControlledSync({\n value: selectedId,\n source: collection,\n target: widget,\n apply: (value) => {\n if (widget === null) {\n return;\n }\n\n const position = resolvePosition(widget, collection, value);\n applySelectedPosition(widget, position, applyState.current);\n syncKnownSelection(position, value);\n },\n });\n\n return (value, self) => {\n dispatchSelectedNotify({ options, known, state: applyState.current, markDrift }, value, self);\n };\n};\n\nfunction DropDownBase(props: DropDownBaseProps & { component: ElementType }): ReactNode {\n const { component: Component, items, sections, renderListItem, renderHeader, ref } = props;\n const rest = omit(props, DROP_DOWN_PROPS);\n const [widget, refCallback] = useWidgetRef<SelectableWidget>(ref);\n const { collection, model } = useCollectionData({ items, sections, isFlat: true });\n const faceCells = useItemCells({ width: -1, height: -1 });\n const listCells = useItemCells({ width: -1, height: -1 });\n const header = useSectionHeader(renderHeader, collection, { width: -1, height: -1 });\n const handleNotifySelected = useDropDownSelection({ widget, collection, props });\n\n return (\n <>\n <Component\n ref={refCallback}\n model={model}\n factory={<GtkSignalListItemFactory {...faceCells.handlers} />}\n {...(renderListItem != null && {\n listFactory: <GtkSignalListItemFactory {...listCells.handlers} />,\n })}\n {...header.factoryProps}\n {...rest}\n onNotifySelected={handleNotifySelected}\n />\n <ItemPortals registry={faceCells} render={faceRenderer(props)} collection={collection} />\n {renderListItem != null && (\n <ItemPortals registry={listCells} render={renderListItem} collection={collection} />\n )}\n {header.portals}\n </>\n );\n}\n\nexport { DropDownBase, type DropDownBaseProps };\n"]}
1
+ {"version":3,"file":"drop-down.js","sourceRoot":"","sources":["../../src/internal/drop-down.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAgB,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO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AAU,EAAE,UAAU,GAAI,CACvF,EACA,MAAM,CAAC,OAAO,IAChB,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,YAAY,EAA0B,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type { ElementType, ReactNode, Ref } from \"react\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport type * as Pango from \"@gtkx/gi/pango\";\nimport { GtkBox, GtkImage, GtkLabel, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { useProperty } from \"@gtkx/react\";\nimport { useLatestRef } from \"@gtkx/react/internal\";\nimport { omit, type Primitive } from \"@gtkx/utils\";\nimport { useLayoutEffect, useRef, useState } from \"react\";\nimport type { DropDownOwnProps, ListItemRenderer } from \"../types.js\";\nimport { ItemPortals, useItemCells, useSectionHeader } from \"./cells.js\";\nimport { type SlotRef, slotRefFor } from \"./collection-model.js\";\nimport { type Collection, isCollectionIdle } from \"./collection.js\";\nimport { useControlledSync } from \"./controlled-sync.js\";\nimport { showFirstHeader } from \"./first-header.js\";\nimport { useCollectionData } from \"./use-collection.js\";\nimport { useWidgetRef } from \"./use-widget-ref.js\";\n\ntype SelectableWidget = Gtk.DropDown | Adw.ComboRow;\n\n/** Label settings of the widget's own default item factory, kept by the default renderers. */\ntype ItemLabelProps = {\n ellipsize?: Pango.EllipsizeMode;\n maxWidthChars?: number;\n widthChars?: number;\n};\n\ntype DropDownBaseProps = DropDownOwnProps<unknown, unknown> & {\n onNotifySelected?: ((value: number | null, self: SelectableWidget) => void) | null | undefined;\n ref?: Ref<SelectableWidget | null> | undefined;\n} & Record<string, unknown>;\n\ntype SelectionOptions = {\n widget: SelectableWidget | null;\n collection: Collection;\n props: DropDownBaseProps;\n};\n\ntype NotifySelectedHandler = NonNullable<DropDownBaseProps[\"onNotifySelected\"]>;\ntype ApplyState = { isApplying: boolean; isReady: boolean };\ntype ShownSelection = { ref: SlotRef | null; text: string };\n\ntype NotifyContext = {\n options: SelectionOptions;\n known: { current: string | null };\n state: ApplyState;\n markDrift: () => void;\n};\n\ntype KnownSelection = {\n known: { current: string | null };\n onSelectionChanged: ((id: string | null) => void) | null | undefined;\n};\n\nconst DROP_DOWN_PROPS: string[] = [\n \"component\",\n \"itemLabel\",\n \"items\",\n \"sections\",\n \"selectedId\",\n \"onSelectionChanged\",\n \"onNotifySelected\",\n \"renderItem\",\n \"renderListItem\",\n \"renderHeader\",\n \"ref\",\n];\n\nfunction newApplyState(): ApplyState {\n return { isApplying: false, isReady: false };\n}\n\nconst defaultRenderer =\n (itemLabel: ItemLabelProps): ListItemRenderer<Primitive> =>\n ({ item }) =>\n item == null ? null : <GtkLabel {...itemLabel}>{String(item)}</GtkLabel>;\nconst faceRenderer = (props: DropDownBaseProps, itemLabel: ItemLabelProps): ListItemRenderer<never> =>\n props.renderItem ?? defaultRenderer(itemLabel);\n\nconst selectionMarkedRenderer =\n (selected: number | undefined, itemLabel: ItemLabelProps): ListItemRenderer<Primitive> =>\n ({ item, index }) => (\n <GtkBox>\n <GtkLabel xalign={0} {...itemLabel}>\n {item == null ? \"\" : String(item)}\n </GtkLabel>\n <GtkImage\n iconName=\"object-select-symbolic\"\n accessibleRole={Gtk.AccessibleRole.PRESENTATION}\n opacity={index === selected ? 1 : 0}\n />\n </GtkBox>\n );\n\nconst popupRenderer = (\n props: DropDownBaseProps,\n selected: number | undefined,\n itemLabel: ItemLabelProps,\n): ListItemRenderer<never> | null =>\n props.renderListItem ?? (props.renderItem == null ? selectionMarkedRenderer(selected, itemLabel) : null);\n\nconst textOf = (value: unknown): string => {\n switch (typeof value) {\n case \"string\":\n return value;\n case \"number\":\n case \"bigint\":\n case \"boolean\":\n return String(value);\n case \"symbol\":\n return value.toString();\n default:\n return \"\";\n }\n};\n\nconst slotText = (collection: Collection, ref: SlotRef | null): string =>\n ref === null ? \"\" : textOf(collection.itemAt(ref)?.value);\n\n/**\n * AdwComboRow reads the selected item's text for its subtitle only when the selected item or the expression changes.\n * Slots keep their objects when an item's value changes in place, so the expression is replaced when the selected\n * item's text changes without a selection change.\n */\nconst useItemTextExpression = (widget: SelectableWidget | null, collection: Collection): Gtk.Expression => {\n const latest = useLatestRef(collection);\n const shown = useRef<ShownSelection>({ ref: null, text: \"\" });\n const createExpression = (): Gtk.Expression =>\n Gtk.ClosureExpression.new(\n GObject.TYPE_STRING,\n (object: GObject.Object | null) => slotText(latest.current, slotRefFor(object)),\n null,\n );\n const [expression, setExpression] = useState(createExpression);\n\n useLayoutEffect(() => {\n const ref = slotRefFor(widget?.getSelectedItem() ?? null);\n const text = slotText(collection, ref);\n const isRenamed = ref !== null && ref === shown.current.ref && text !== shown.current.text;\n shown.current = { ref, text };\n\n if (isRenamed) {\n setExpression(createExpression());\n }\n });\n\n return expression;\n};\n\nconst resolvePosition = (widget: SelectableWidget, collection: Collection, selectedId: string | undefined): number => {\n if (selectedId === undefined) {\n return widget.getSelected();\n }\n\n const requested = collection.positionFor(selectedId);\n\n return requested >= 0 ? requested : widget.getSelected();\n};\n\nconst updateKnownSelection = (\n tracker: KnownSelection,\n effectiveId: string | null,\n selectedId: string | undefined,\n): void => {\n const { known, onSelectionChanged } = tracker;\n const expectedId = selectedId ?? known.current;\n const isNew = effectiveId !== known.current;\n known.current = effectiveId;\n\n if (expectedId !== null && effectiveId !== expectedId && isNew) {\n onSelectionChanged?.(effectiveId);\n }\n};\n\nconst reportKnownSelection = (tracker: KnownSelection, id: string | null): void => {\n const { known, onSelectionChanged } = tracker;\n\n if (id === known.current) {\n return;\n }\n\n known.current = id;\n onSelectionChanged?.(id);\n};\n\nconst hasSelectionDrifted = (\n widget: SelectableWidget,\n collection: Collection,\n selectedId: string | undefined,\n): boolean => {\n if (selectedId === undefined) {\n return false;\n }\n\n const requested = collection.positionFor(selectedId);\n\n return requested >= 0 && widget.getSelected() !== requested;\n};\n\nconst applySelectedPosition = (widget: SelectableWidget, position: number, state: ApplyState): void => {\n state.isApplying = true;\n\n try {\n widget.selected = position;\n } finally {\n state.isApplying = false;\n }\n};\n\nconst dispatchSelectedNotify = (context: NotifyContext, value: number | null, self: SelectableWidget): void => {\n const { options, known, state, markDrift } = context;\n\n if (state.isApplying) {\n return;\n }\n\n options.props.onNotifySelected?.(value, self);\n\n if (!state.isReady || !isCollectionIdle(options.collection)) {\n return;\n }\n\n reportKnownSelection(\n { known, onSelectionChanged: options.props.onSelectionChanged },\n options.collection.idAt(self.getSelected()),\n );\n\n if (hasSelectionDrifted(self, options.collection, options.props.selectedId)) {\n markDrift();\n }\n};\n\nconst useDropDownSelection = (options: SelectionOptions): NotifySelectedHandler => {\n const { widget, collection } = options;\n const { selectedId } = options.props;\n const known = useRef<string | null>(null);\n const applyState = useRef<ApplyState>(newApplyState());\n\n const syncKnownSelection = (position: number, requestedId: string | undefined): void => {\n const effectiveId = collection.idAt(position);\n const { onSelectionChanged } = options.props;\n updateKnownSelection({ known, onSelectionChanged }, effectiveId, requestedId);\n applyState.current.isReady = true;\n };\n\n const markDrift = useControlledSync({\n value: selectedId,\n source: collection,\n target: widget,\n apply: (value) => {\n if (widget === null) {\n return;\n }\n\n const position = resolvePosition(widget, collection, value);\n applySelectedPosition(widget, position, applyState.current);\n syncKnownSelection(position, value);\n },\n });\n\n return (value, self) => {\n dispatchSelectedNotify({ options, known, state: applyState.current, markDrift }, value, self);\n };\n};\n\nfunction DropDownBase(props: DropDownBaseProps & { component: ElementType; itemLabel?: ItemLabelProps }): ReactNode {\n const { component: Component, itemLabel = {}, items, sections, renderHeader, ref } = props;\n const rest = omit(props, DROP_DOWN_PROPS);\n const [widget, refCallback] = useWidgetRef<SelectableWidget>(ref);\n const { collection, model } = useCollectionData({\n items,\n sections,\n isFlat: true,\n onSectionsFilled: () => showFirstHeader(widget),\n });\n const faceCells = useItemCells({ width: -1, height: -1 });\n const listCells = useItemCells({ width: -1, height: -1 });\n const header = useSectionHeader(renderHeader, collection, { width: -1, height: -1 });\n const handleNotifySelected = useDropDownSelection({ widget, collection, props });\n const renderListItem = popupRenderer(props, useProperty(widget, \"selected\"), itemLabel);\n const expression = useItemTextExpression(widget, collection);\n\n return (\n <>\n <Component\n ref={refCallback}\n model={model}\n expression={expression}\n factory={<GtkSignalListItemFactory {...faceCells.handlers} />}\n {...(renderListItem !== null && {\n listFactory: <GtkSignalListItemFactory {...listCells.handlers} />,\n })}\n {...header.factoryProps}\n {...rest}\n onNotifySelected={handleNotifySelected}\n />\n <ItemPortals registry={faceCells} render={faceRenderer(props, itemLabel)} collection={collection} />\n {renderListItem !== null && (\n <ItemPortals registry={listCells} render={renderListItem} collection={collection} />\n )}\n {header.portals}\n </>\n );\n}\n\nexport { DropDownBase, type DropDownBaseProps };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"expansion.d.ts","sourceRoot":"","sources":["../../src/internal/expansion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAUlD,KAAK,gBAAgB,GAAG;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,gBAAgB,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CACnE,CAAC;AAQF,KAAK,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAiGrF,iBAAS,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,CAgBnE;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"expansion.d.ts","sourceRoot":"","sources":["../../src/internal/expansion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAUlD,KAAK,gBAAgB,GAAG;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,gBAAgB,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CACnE,CAAC;AAQF,KAAK,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAiIrF,iBAAS,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,CAgBnE;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { useState } from "react";
2
2
  import { isCollectionIdle } from "./collection.js";
3
- import { useControlledSync } from "./controlled-sync.js";
3
+ import { hasSameIds, useControlledSync } from "./controlled-sync.js";
4
4
  import { joinParts } from "./keys.js";
5
5
  import { trackPaths } from "./slots.js";
6
6
  import { adoptOrder, markExpanded, orderFor } from "./tree-expansion.js";
@@ -8,27 +8,38 @@ import { expandedPathsFor, walkVisible } from "./tree-order.js";
8
8
  function hasSameExpansion(expanded, wanted) {
9
9
  return expanded.size === wanted.size && wanted.isSubsetOf(expanded);
10
10
  }
11
- function toggleOptions(collection, wanted) {
11
+ function collapsingPositions(expansion, wanted) {
12
+ const positions = [];
13
+ walkVisible({
14
+ index: expansion.index,
15
+ slots: expansion.slots,
16
+ marks: trackPaths(expansion.expanded.difference(wanted)),
17
+ visit: (row) => {
18
+ if (row.isMarked) {
19
+ positions.push(row.position);
20
+ }
21
+ },
22
+ });
23
+ return positions;
24
+ }
25
+ function expandOptions(collection, wanted) {
12
26
  const { expansion } = collection;
13
27
  return {
14
28
  index: expansion.index,
15
29
  slots: trackPaths(wanted),
16
- marks: trackPaths(wanted.symmetricDifference(expansion.expanded)),
30
+ marks: trackPaths(wanted.difference(expansion.expanded)),
17
31
  visit: (row) => {
18
32
  if (row.isMarked) {
19
- collection.rowAt(row.position)?.setExpanded(row.isOpen);
33
+ collection.rowAt(row.position)?.setExpanded(true);
20
34
  }
21
35
  },
22
36
  };
23
37
  }
24
- function walkApplying(expansion, options) {
25
- expansion.isApplying = true;
26
- try {
27
- return walkVisible(options);
28
- }
29
- finally {
30
- expansion.isApplying = false;
38
+ function toggleRows(collection, wanted) {
39
+ for (const position of collapsingPositions(collection.expansion, wanted).toReversed()) {
40
+ collection.rowAt(position)?.setExpanded(false);
31
41
  }
42
+ return walkVisible(expandOptions(collection, wanted));
32
43
  }
33
44
  function applyWanted(collection, expandedIds) {
34
45
  const { expansion } = collection;
@@ -36,23 +47,39 @@ function applyWanted(collection, expandedIds) {
36
47
  if (hasSameExpansion(expansion.expanded, wanted)) {
37
48
  return;
38
49
  }
39
- adoptOrder(expansion, walkApplying(expansion, toggleOptions(collection, wanted)));
50
+ expansion.isApplying = true;
51
+ try {
52
+ adoptOrder(expansion, toggleRows(collection, wanted));
53
+ }
54
+ finally {
55
+ expansion.isApplying = false;
56
+ }
57
+ }
58
+ function rememberExpansion(context, expandedPaths) {
59
+ const key = joinParts(expandedPaths);
60
+ const isKnown = context.last.key === key;
61
+ context.last.key = key;
62
+ return isKnown;
40
63
  }
41
64
  function reportExpansion(context) {
42
65
  const { expandedIds, expandedPaths } = orderFor(context.collection.expansion);
43
- const key = joinParts(expandedPaths);
44
- if (context.last.key === key) {
45
- return;
66
+ if (!rememberExpansion(context, expandedPaths)) {
67
+ context.onExpandedChange?.([...expandedIds]);
46
68
  }
47
- context.last.key = key;
48
- context.onExpandedChange?.([...expandedIds]);
49
69
  }
50
70
  function applyControlledExpansion(context, expandedIds) {
51
71
  if (!context.collection.isTree) {
52
72
  return;
53
73
  }
54
- applyWanted(context.collection, expandedIds ?? []);
55
- reportExpansion(context);
74
+ const requested = expandedIds ?? [];
75
+ applyWanted(context.collection, requested);
76
+ const order = orderFor(context.collection.expansion);
77
+ if (hasSameIds(order.expandedIds, requested)) {
78
+ rememberExpansion(context, order.expandedPaths);
79
+ }
80
+ else {
81
+ reportExpansion(context);
82
+ }
56
83
  }
57
84
  function didRowDrift(collection, change) {
58
85
  const path = collection.pathAt(change.position - 1);
@@ -1 +1 @@
1
- {"version":3,"file":"expansion.js","sourceRoot":"","sources":["../../src/internal/expansion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAuBhE,SAAS,gBAAgB,CAAC,QAAqB,EAAE,MAAmB;IAChE,OAAO,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,aAAa,CAAC,UAAsB,EAAE,MAAmB;IAC9D,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;IAEjC,OAAO;QACH,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC;QACzB,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACjE,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;gBACf,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,WAAW,CAA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AAG,QAAQ,CAAgB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAqB,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IAEzE,MAAM,SAAS,GAAG,iBAAiB,CAAC;QAChC,KAAK,EAAE,WAAW;QAClB,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YACb,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAChC,gBAAgB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IACvE,CAAC,CAAC;AACN,CAAC;AAED,OAAO,EAAE,YAAY,EAA2B,CAAC","sourcesContent":["import { useState } from \"react\";\nimport type { Collection } from \"./collection.js\";\nimport type { TreeExpansion } from \"./tree-expansion.js\";\nimport type { VisibleOrder, WalkOptions } from \"./tree-order.js\";\nimport { isCollectionIdle } from \"./collection.js\";\nimport { useControlledSync } from \"./controlled-sync.js\";\nimport { joinParts } from \"./keys.js\";\nimport { trackPaths } from \"./slots.js\";\nimport { adoptOrder, markExpanded, orderFor } from \"./tree-expansion.js\";\nimport { expandedPathsFor, walkVisible } from \"./tree-order.js\";\n\ntype ExpansionOptions = {\n collection: Collection;\n expandedIds?: string[] | null | undefined;\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n};\n\ntype ItemsChange = {\n position: number;\n removed: number;\n added: number;\n};\n\ntype ItemsChangeHandler = (position: number, removed: number, added: number) => void;\ntype LastExpansion = { key: string };\n\ntype ExpansionContext = {\n collection: Collection;\n last: LastExpansion;\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n};\n\nfunction hasSameExpansion(expanded: Set<string>, wanted: Set<string>): boolean {\n return expanded.size === wanted.size && wanted.isSubsetOf(expanded);\n}\n\nfunction toggleOptions(collection: Collection, wanted: Set<string>): WalkOptions {\n const { expansion } = collection;\n\n return {\n index: expansion.index,\n slots: trackPaths(wanted),\n marks: trackPaths(wanted.symmetricDifference(expansion.expanded)),\n visit: (row) => {\n if (row.isMarked) {\n collection.rowAt(row.position)?.setExpanded(row.isOpen);\n }\n },\n };\n}\n\nfunction walkApplying(expansion: TreeExpansion, options: WalkOptions): VisibleOrder {\n expansion.isApplying = true;\n\n try {\n return walkVisible(options);\n } finally {\n expansion.isApplying = false;\n }\n}\n\nfunction applyWanted(collection: Collection, expandedIds: string[]): void {\n const { expansion } = collection;\n const wanted = expandedPathsFor(expansion.index, new Set(expandedIds));\n\n if (hasSameExpansion(expansion.expanded, wanted)) {\n return;\n }\n\n adoptOrder(expansion, walkApplying(expansion, toggleOptions(collection, wanted)));\n}\n\nfunction reportExpansion(context: ExpansionContext): void {\n const { expandedIds, expandedPaths } = orderFor(context.collection.expansion);\n const key = joinParts(expandedPaths);\n\n if (context.last.key === key) {\n return;\n }\n\n context.last.key = key;\n context.onExpandedChange?.([...expandedIds]);\n}\n\nfunction applyControlledExpansion(context: ExpansionContext, expandedIds: string[] | null | undefined): void {\n if (!context.collection.isTree) {\n return;\n }\n\n applyWanted(context.collection, expandedIds ?? []);\n reportExpansion(context);\n}\n\nfunction didRowDrift(collection: Collection, change: ItemsChange): boolean {\n const path = collection.pathAt(change.position - 1);\n const isExpanded = change.removed === 0 && change.added > 0;\n const isCollapsed = change.added === 0 && change.removed > 0;\n\n if (path === null || isExpanded === isCollapsed) {\n return false;\n }\n\n markExpanded(collection.expansion, path, isExpanded);\n\n return true;\n}\n\nfunction observeExpansion(context: ExpansionContext, change: ItemsChange, onDrift: () => void): void {\n if (!context.collection.isTree || !isCollectionIdle(context.collection)) {\n return;\n }\n\n const didDrift = didRowDrift(context.collection, change);\n reportExpansion(context);\n\n if (didDrift) {\n onDrift();\n }\n}\n\nfunction useExpansion(options: ExpansionOptions): ItemsChangeHandler {\n const { collection, expandedIds, onExpandedChange } = options;\n const [last] = useState<LastExpansion>(() => ({ key: \"\" }));\n const context: ExpansionContext = { collection, last, onExpandedChange };\n\n const markDrift = useControlledSync({\n value: expandedIds,\n source: collection,\n apply: (value) => {\n applyControlledExpansion(context, value);\n },\n });\n\n return (position, removed, added) => {\n observeExpansion(context, { position, removed, added }, markDrift);\n };\n}\n\nexport { useExpansion, type ItemsChangeHandler };\n"]}
1
+ {"version":3,"file":"expansion.js","sourceRoot":"","sources":["../../src/internal/expansion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAuBhE,SAAS,gBAAgB,CAAC,QAAqB,EAAE,MAAmB;IAChE,OAAO,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAwB,EAAE,MAAmB;IACtE,MAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,WAAW,CAAC;QACR,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACxD,KAAK,EAAE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AAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAgB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAqB,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IAEzE,MAAM,SAAS,GAAG,iBAAiB,CAAC;QAChC,KAAK,EAAE,WAAW;QAClB,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YACb,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAChC,gBAAgB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IACvE,CAAC,CAAC;AACN,CAAC;AAED,OAAO,EAAE,YAAY,EAA2B,CAAC","sourcesContent":["import { useState } from \"react\";\nimport type { Collection } from \"./collection.js\";\nimport type { TreeExpansion } from \"./tree-expansion.js\";\nimport type { VisibleOrder, WalkOptions } from \"./tree-order.js\";\nimport { isCollectionIdle } from \"./collection.js\";\nimport { hasSameIds, useControlledSync } from \"./controlled-sync.js\";\nimport { joinParts } from \"./keys.js\";\nimport { trackPaths } from \"./slots.js\";\nimport { adoptOrder, markExpanded, orderFor } from \"./tree-expansion.js\";\nimport { expandedPathsFor, walkVisible } from \"./tree-order.js\";\n\ntype ExpansionOptions = {\n collection: Collection;\n expandedIds?: string[] | null | undefined;\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n};\n\ntype ItemsChange = {\n position: number;\n removed: number;\n added: number;\n};\n\ntype ItemsChangeHandler = (position: number, removed: number, added: number) => void;\ntype LastExpansion = { key: string };\n\ntype ExpansionContext = {\n collection: Collection;\n last: LastExpansion;\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n};\n\nfunction hasSameExpansion(expanded: Set<string>, wanted: Set<string>): boolean {\n return expanded.size === wanted.size && wanted.isSubsetOf(expanded);\n}\n\nfunction collapsingPositions(expansion: TreeExpansion, wanted: Set<string>): number[] {\n const positions: number[] = [];\n\n walkVisible({\n index: expansion.index,\n slots: expansion.slots,\n marks: trackPaths(expansion.expanded.difference(wanted)),\n visit: (row) => {\n if (row.isMarked) {\n positions.push(row.position);\n }\n },\n });\n\n return positions;\n}\n\nfunction expandOptions(collection: Collection, wanted: Set<string>): WalkOptions {\n const { expansion } = collection;\n\n return {\n index: expansion.index,\n slots: trackPaths(wanted),\n marks: trackPaths(wanted.difference(expansion.expanded)),\n visit: (row) => {\n if (row.isMarked) {\n collection.rowAt(row.position)?.setExpanded(true);\n }\n },\n };\n}\n\nfunction toggleRows(collection: Collection, wanted: Set<string>): VisibleOrder {\n for (const position of collapsingPositions(collection.expansion, wanted).toReversed()) {\n collection.rowAt(position)?.setExpanded(false);\n }\n\n return walkVisible(expandOptions(collection, wanted));\n}\n\nfunction applyWanted(collection: Collection, expandedIds: string[]): void {\n const { expansion } = collection;\n const wanted = expandedPathsFor(expansion.index, new Set(expandedIds));\n\n if (hasSameExpansion(expansion.expanded, wanted)) {\n return;\n }\n\n expansion.isApplying = true;\n\n try {\n adoptOrder(expansion, toggleRows(collection, wanted));\n } finally {\n expansion.isApplying = false;\n }\n}\n\nfunction rememberExpansion(context: ExpansionContext, expandedPaths: string[]): boolean {\n const key = joinParts(expandedPaths);\n const isKnown = context.last.key === key;\n context.last.key = key;\n\n return isKnown;\n}\n\nfunction reportExpansion(context: ExpansionContext): void {\n const { expandedIds, expandedPaths } = orderFor(context.collection.expansion);\n\n if (!rememberExpansion(context, expandedPaths)) {\n context.onExpandedChange?.([...expandedIds]);\n }\n}\n\nfunction applyControlledExpansion(context: ExpansionContext, expandedIds: string[] | null | undefined): void {\n if (!context.collection.isTree) {\n return;\n }\n\n const requested = expandedIds ?? [];\n applyWanted(context.collection, requested);\n const order = orderFor(context.collection.expansion);\n\n if (hasSameIds(order.expandedIds, requested)) {\n rememberExpansion(context, order.expandedPaths);\n } else {\n reportExpansion(context);\n }\n}\n\nfunction didRowDrift(collection: Collection, change: ItemsChange): boolean {\n const path = collection.pathAt(change.position - 1);\n const isExpanded = change.removed === 0 && change.added > 0;\n const isCollapsed = change.added === 0 && change.removed > 0;\n\n if (path === null || isExpanded === isCollapsed) {\n return false;\n }\n\n markExpanded(collection.expansion, path, isExpanded);\n\n return true;\n}\n\nfunction observeExpansion(context: ExpansionContext, change: ItemsChange, onDrift: () => void): void {\n if (!context.collection.isTree || !isCollectionIdle(context.collection)) {\n return;\n }\n\n const didDrift = didRowDrift(context.collection, change);\n reportExpansion(context);\n\n if (didDrift) {\n onDrift();\n }\n}\n\nfunction useExpansion(options: ExpansionOptions): ItemsChangeHandler {\n const { collection, expandedIds, onExpandedChange } = options;\n const [last] = useState<LastExpansion>(() => ({ key: \"\" }));\n const context: ExpansionContext = { collection, last, onExpandedChange };\n\n const markDrift = useControlledSync({\n value: expandedIds,\n source: collection,\n apply: (value) => {\n applyControlledExpansion(context, value);\n },\n });\n\n return (position, removed, added) => {\n observeExpansion(context, { position, removed, added }, markDrift);\n };\n}\n\nexport { useExpansion, type ItemsChangeHandler };\n"]}
@@ -0,0 +1,11 @@
1
+ import type * as Adw from "@gtkx/gi/adw";
2
+ import * as Gtk from "@gtkx/gi/gtk";
3
+ type SectionedWidget = Gtk.ListView | Gtk.ColumnView | Gtk.DropDown | Adw.ComboRow;
4
+ /**
5
+ * TODO: GTK 4.22 anchors a list whose model fills after the list holds it at the first row, scrolled past that
6
+ * row's section header. Scrolling a view to its first row, or handing a drop-down its filled model again, starts
7
+ * it at the header. Remove once a GTK release fixes the anchor and GTKX requires it.
8
+ */
9
+ declare function showFirstHeader(widget: SectionedWidget | null): void;
10
+ export { showFirstHeader };
11
+ //# sourceMappingURL=first-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-header.d.ts","sourceRoot":"","sources":["../../src/internal/first-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,KAAK,eAAe,GAAG,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAEnF;;;;GAIG;AACH,iBAAS,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAU7D;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ /**
3
+ * TODO: GTK 4.22 anchors a list whose model fills after the list holds it at the first row, scrolled past that
4
+ * row's section header. Scrolling a view to its first row, or handing a drop-down its filled model again, starts
5
+ * it at the header. Remove once a GTK release fixes the anchor and GTKX requires it.
6
+ */
7
+ function showFirstHeader(widget) {
8
+ if (widget instanceof Gtk.ListView) {
9
+ widget.scrollTo(0, Gtk.ListScrollFlags.NONE, null);
10
+ }
11
+ else if (widget instanceof Gtk.ColumnView) {
12
+ widget.scrollTo(0, null, Gtk.ListScrollFlags.NONE, null);
13
+ }
14
+ else if (widget !== null) {
15
+ const model = widget.getModel();
16
+ widget.setModel(null);
17
+ widget.setModel(model);
18
+ }
19
+ }
20
+ export { showFirstHeader };
21
+ //# sourceMappingURL=first-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-header.js","sourceRoot":"","sources":["../../src/internal/first-header.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAIpC;;;;GAIG;AACH,SAAS,eAAe,CAAC,MAA8B;IACnD,IAAI,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;SAAM,IAAI,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;SAAM,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\n\ntype SectionedWidget = Gtk.ListView | Gtk.ColumnView | Gtk.DropDown | Adw.ComboRow;\n\n/**\n * TODO: GTK 4.22 anchors a list whose model fills after the list holds it at the first row, scrolled past that\n * row's section header. Scrolling a view to its first row, or handing a drop-down its filled model again, starts\n * it at the header. Remove once a GTK release fixes the anchor and GTKX requires it.\n */\nfunction showFirstHeader(widget: SectionedWidget | null): void {\n if (widget instanceof Gtk.ListView) {\n widget.scrollTo(0, Gtk.ListScrollFlags.NONE, null);\n } else if (widget instanceof Gtk.ColumnView) {\n widget.scrollTo(0, null, Gtk.ListScrollFlags.NONE, null);\n } else if (widget !== null) {\n const model = widget.getModel();\n widget.setModel(null);\n widget.setModel(model);\n }\n}\n\nexport { showFirstHeader };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/internal/keys.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAA8D,CAAC;AACnG,QAAA,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,KAAG,MAA2D,CAAC;AAElG,QAAA,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,IAU9D,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/internal/keys.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,UAAU,UAAW,MAAM,KAAG,MAA8D,CAAC;AACnG,QAAA,MAAM,SAAS,WAAY,MAAM,EAAE,KAAG,MAA2D,CAAC;AAElG,QAAA,MAAM,YAAY,UAAW,MAAM,UAAU,MAAM,KAAG,MAAM,GAAG,IAU9D,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ type Splice = {
2
+ start: number;
3
+ removed: number;
4
+ added: number;
5
+ };
6
+ type KeyAt = (slot: number) => string;
7
+ type LevelKeys = {
8
+ previousLength: number;
9
+ nextLength: number;
10
+ previousKey: KeyAt;
11
+ nextKey: KeyAt;
12
+ };
13
+ type Relocate = (slot: number) => number | undefined;
14
+ declare const NO_SPLICE: Splice;
15
+ declare function findSplice(keys: LevelKeys): Splice;
16
+ declare function hasSplice(splice: Splice): boolean;
17
+ declare function matchMoves(keys: LevelKeys, splice: Splice, candidates: Iterable<number>): Map<number, number>;
18
+ declare function relocateSlot(splice: Splice, slot: number, moves?: Map<number, number>): number | undefined;
19
+ declare function relocateEntries<V>(entries: Map<number, V>, relocate: Relocate, onDrop: (value: V) => void): Map<number, V>;
20
+ /**
21
+ * GTK looks up every added item for a moved row whenever a splice removes a row it tracks, such as the scroll
22
+ * anchor or the focus, which makes every lazily created item real. Past a limit, the overlapping slots are
23
+ * rewritten in place instead and only the difference is spliced, so rows that move there remount.
24
+ */
25
+ declare function searchableSplice(splice: Splice, addedRows: number): Splice;
26
+ export { NO_SPLICE, findSplice, hasSplice, matchMoves, relocateEntries, relocateSlot, searchableSplice, type LevelKeys, type Relocate, type Splice, };
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