@gtkx/components 2.0.0-beta.4 → 2.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +1 -0
- package/dist/column-view.js.map +1 -1
- package/dist/internal/cells.d.ts +11 -1
- package/dist/internal/cells.d.ts.map +1 -1
- package/dist/internal/cells.js +122 -24
- package/dist/internal/cells.js.map +1 -1
- package/dist/internal/collection-model.d.ts +5 -5
- package/dist/internal/collection-model.d.ts.map +1 -1
- package/dist/internal/collection-model.js +35 -35
- package/dist/internal/collection-model.js.map +1 -1
- package/dist/list-view.d.ts.map +1 -1
- package/dist/list-view.js +1 -0
- package/dist/list-view.js.map +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +7 -7
- package/src/column-view.tsx +1 -0
- package/src/internal/cells.tsx +198 -38
- package/src/internal/collection-model.ts +41 -41
- package/src/list-view.tsx +1 -0
- package/src/types.ts +13 -1
|
@@ -39,21 +39,16 @@ function slotRefFor(value) {
|
|
|
39
39
|
function slotPathAt(store, slot) {
|
|
40
40
|
return store.level.path + encodePart(String(slot));
|
|
41
41
|
}
|
|
42
|
-
function growStore(store) {
|
|
43
|
-
for (let slot = store.refs.length; slot < store.level.items.length; slot++) {
|
|
44
|
-
store.refs.push({ store, slot });
|
|
45
|
-
store.objects.push(null);
|
|
46
|
-
store.childStores.push(null);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
42
|
function newLevelStore(level) {
|
|
50
43
|
const store = new (registeredStoreClass())();
|
|
51
44
|
store.level = level;
|
|
52
|
-
growStore(store);
|
|
53
45
|
return store;
|
|
54
46
|
}
|
|
55
47
|
function collectFlips(previous, next, overlap) {
|
|
56
48
|
const flipped = new Set();
|
|
49
|
+
if (previous.expandableFlags.length === 0 && next.expandableFlags.length === 0) {
|
|
50
|
+
return flipped;
|
|
51
|
+
}
|
|
57
52
|
for (let slot = 0; slot < overlap; slot++) {
|
|
58
53
|
if ((previous.expandableFlags[slot] ?? false) !== (next.expandableFlags[slot] ?? false)) {
|
|
59
54
|
flipped.add(slot);
|
|
@@ -67,26 +62,26 @@ function pruneFlips(context, store, flipped) {
|
|
|
67
62
|
}
|
|
68
63
|
pruneSlots(context.expansion, store.level.path, (slot) => flipped.has(slot));
|
|
69
64
|
for (const slot of flipped) {
|
|
70
|
-
store.childStores
|
|
65
|
+
store.childStores.delete(slot);
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
function detachRefs(store, nextLength) {
|
|
74
|
-
for (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
ref.slot = -1;
|
|
69
|
+
for (const [slot, ref] of store.refs) {
|
|
70
|
+
if (slot < nextLength) {
|
|
71
|
+
continue;
|
|
78
72
|
}
|
|
73
|
+
ref.slot = -1;
|
|
74
|
+
store.refs.delete(slot);
|
|
75
|
+
store.objects.delete(slot);
|
|
76
|
+
store.childStores.delete(slot);
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
|
-
function shrinkStore(context, store, nextLength) {
|
|
82
|
-
if (
|
|
79
|
+
function shrinkStore(context, store, previousLength, nextLength) {
|
|
80
|
+
if (previousLength <= nextLength) {
|
|
83
81
|
return;
|
|
84
82
|
}
|
|
85
83
|
detachRefs(store, nextLength);
|
|
86
84
|
pruneSlots(context.expansion, store.level.path, (slot) => slot >= nextLength);
|
|
87
|
-
store.refs.length = nextLength;
|
|
88
|
-
store.objects.length = nextLength;
|
|
89
|
-
store.childStores.length = nextLength;
|
|
90
85
|
}
|
|
91
86
|
function emitTailSplice(store, previousLength, nextLength) {
|
|
92
87
|
if (nextLength < previousLength) {
|
|
@@ -118,7 +113,7 @@ function emitFlips(store, flipped) {
|
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
115
|
function childSync(context, store, slot, flipped) {
|
|
121
|
-
const child = store.childStores
|
|
116
|
+
const child = store.childStores.get(slot) ?? null;
|
|
122
117
|
if (child === null || flipped.has(slot)) {
|
|
123
118
|
return undefined;
|
|
124
119
|
}
|
|
@@ -127,7 +122,11 @@ function childSync(context, store, slot, flipped) {
|
|
|
127
122
|
}
|
|
128
123
|
function childSyncs(context, store, overlap, flipped) {
|
|
129
124
|
const syncs = [];
|
|
130
|
-
|
|
125
|
+
const slots = store.childStores.keys().toArray().toSorted((left, right) => left - right);
|
|
126
|
+
for (const slot of slots) {
|
|
127
|
+
if (slot >= overlap) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
131
130
|
const sync = childSync(context, store, slot, flipped);
|
|
132
131
|
if (sync !== undefined) {
|
|
133
132
|
syncs.push(sync);
|
|
@@ -137,13 +136,13 @@ function childSyncs(context, store, overlap, flipped) {
|
|
|
137
136
|
}
|
|
138
137
|
function syncEntry(context, entry) {
|
|
139
138
|
const { store, level } = entry;
|
|
140
|
-
const
|
|
139
|
+
const previous = store.level;
|
|
140
|
+
const previousLength = previous.items.length;
|
|
141
141
|
const overlap = Math.min(previousLength, level.items.length);
|
|
142
|
-
const flipped = collectFlips(
|
|
142
|
+
const flipped = collectFlips(previous, level, overlap);
|
|
143
143
|
store.level = level;
|
|
144
144
|
pruneFlips(context, store, flipped);
|
|
145
|
-
shrinkStore(context, store, level.items.length);
|
|
146
|
-
growStore(store);
|
|
145
|
+
shrinkStore(context, store, previousLength, level.items.length);
|
|
147
146
|
emitTailSplice(store, previousLength, level.items.length);
|
|
148
147
|
emitFlips(store, flipped);
|
|
149
148
|
return childSyncs(context, store, overlap, flipped);
|
|
@@ -158,7 +157,7 @@ function syncLevel(context, store, level) {
|
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
159
|
function ensureChildStore(index, store, slot) {
|
|
161
|
-
const existing = store.childStores
|
|
160
|
+
const existing = store.childStores.get(slot) ?? null;
|
|
162
161
|
if (existing !== null || !(store.level.expandableFlags[slot] ?? false)) {
|
|
163
162
|
return existing;
|
|
164
163
|
}
|
|
@@ -167,7 +166,7 @@ function ensureChildStore(index, store, slot) {
|
|
|
167
166
|
return null;
|
|
168
167
|
}
|
|
169
168
|
const created = newLevelStore(level);
|
|
170
|
-
store.childStores
|
|
169
|
+
store.childStores.set(slot, created);
|
|
171
170
|
return created;
|
|
172
171
|
}
|
|
173
172
|
function childStoreFor(state, object) {
|
|
@@ -280,12 +279,14 @@ function createCollectionModel() {
|
|
|
280
279
|
}
|
|
281
280
|
class LazyLevelStore extends GObject.Object {
|
|
282
281
|
level = { path: "", items: [], expandableFlags: [] };
|
|
283
|
-
refs =
|
|
284
|
-
objects =
|
|
285
|
-
childStores =
|
|
286
|
-
createItem(position
|
|
282
|
+
refs = new Map();
|
|
283
|
+
objects = new Map();
|
|
284
|
+
childStores = new Map();
|
|
285
|
+
createItem(position) {
|
|
286
|
+
const ref = { store: this, slot: position };
|
|
287
287
|
const created = Gtk.StringObject.new("");
|
|
288
|
-
this.
|
|
288
|
+
this.refs.set(position, ref);
|
|
289
|
+
this.objects.set(position, created);
|
|
289
290
|
SLOTS.set(created, ref);
|
|
290
291
|
return created;
|
|
291
292
|
}
|
|
@@ -293,14 +294,13 @@ class LazyLevelStore extends GObject.Object {
|
|
|
293
294
|
return GObject.TYPE_OBJECT;
|
|
294
295
|
}
|
|
295
296
|
vfuncGetNItems() {
|
|
296
|
-
return this.
|
|
297
|
+
return this.level.items.length;
|
|
297
298
|
}
|
|
298
299
|
vfuncGetItem(position) {
|
|
299
|
-
|
|
300
|
-
if (ref === undefined) {
|
|
300
|
+
if (position < 0 || position >= this.level.items.length) {
|
|
301
301
|
return null;
|
|
302
302
|
}
|
|
303
|
-
return this.objects
|
|
303
|
+
return this.objects.get(position) ?? this.createItem(position);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
export { createCollectionModel, slotPathAt, slotRefFor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-model.js","sourceRoot":"","sources":["../../src/internal/collection-model.ts"],"names":[],"mappings":"AAAA,OAAO,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AC,CAAC;QAC5B,CAAC;KACJ,CAAC;AACN,CAAC;AAED,MAAM,cAAe,SAAQ,OAAO,CAAC,MAAM;IAEvC,KAAK,GAAU,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;IAC5D,IAAI,GAAc,EAAE,CAAC;IACrB,OAAO,GAAgC,EAAE,CAAC;IAC1C,WAAW,GAA0B,EAAE,CAAC;IAEhC,UAAU,CAAC,QAAgB,EAAE,GAAY;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;QACjC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAExB,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,gBAAgB;QACZ,OAAO,OAAO,CAAC,WAAW,CAAC;IAC/B,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,YAAY,CAAC,QAAgB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC;CACJ;AAED,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAsC,CAAC","sourcesContent":["import * as Gio from \"@gtkx/gi/gio\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { registerClass } from \"@gtkx/runtime\";\nimport type { CollectionIndex, Level } from \"./collection-index.js\";\nimport type { TreeExpansion } from \"./tree-expansion.js\";\nimport { createCollectionIndex } from \"./collection-index.js\";\nimport { encodePart } from \"./keys.js\";\nimport { adoptIndex, createTreeExpansion, pruneSlots } from \"./tree-expansion.js\";\n\ntype LevelStore = Gio.ListModel & LazyLevelStore;\n\ntype SlotRef = {\n store: LevelStore;\n slot: number;\n};\n\ntype SyncContext = {\n index: CollectionIndex;\n expansion: TreeExpansion;\n};\n\ntype SlotRun = {\n start: number;\n length: number;\n};\n\ntype LevelSync = {\n store: LevelStore;\n level: Level;\n};\n\ntype ModelState = {\n root: Gio.ListStore;\n rootModels: GObject.Object[];\n model: Gtk.FlattenListModel;\n groupStores: LevelStore[];\n trees: Map<LevelStore, Gtk.TreeListModel>;\n treeModels: Gtk.TreeListModel[];\n expansion: TreeExpansion;\n index: CollectionIndex;\n};\n\ntype CollectionModel = {\n model: Gtk.FlattenListModel;\n expansion: TreeExpansion;\n rowAt: (position: number) => Gtk.TreeListRow | null;\n sync: (index: CollectionIndex) => void;\n};\n\nconst STORE_CLASS_KEY = Symbol.for(\"gtkx.components.lazy-level-store\");\nconst SLOTS_KEY = Symbol.for(\"gtkx.components.lazy-level-store.slots\");\nconst EMPTY_INDEX = createCollectionIndex(undefined, undefined, true);\nconst SLOTS = sharedSlots();\n\nconst newRootStore = (): Gio.ListStore => new Gio.ListStore({ itemType: GObject.TYPE_OBJECT });\n\nfunction sharedSlots(): WeakMap<GObject.Object, SlotRef> {\n const cached: unknown = Reflect.get(globalThis, SLOTS_KEY);\n\n if (cached instanceof WeakMap) {\n return cached as WeakMap<GObject.Object, SlotRef>;\n }\n\n const created: WeakMap<GObject.Object, SlotRef> = new WeakMap();\n Reflect.set(globalThis, SLOTS_KEY, created);\n\n return created;\n}\n\nfunction registeredStoreClass(): typeof LazyLevelStore {\n const cached: unknown = Reflect.get(globalThis, STORE_CLASS_KEY);\n\n if (typeof cached === \"function\") {\n return cached as typeof LazyLevelStore;\n }\n\n registerClass(LazyLevelStore, { typeName: \"GtkxLazyLevelStore\", implements: [Gio.ListModel] });\n Reflect.set(globalThis, STORE_CLASS_KEY, LazyLevelStore);\n\n return LazyLevelStore;\n}\n\nfunction slotRefFor(value: GObject.Object | null): SlotRef | null {\n const item = value instanceof Gtk.TreeListRow ? value.getItem() : value;\n\n if (item === null) {\n return null;\n }\n\n const ref = SLOTS.get(item);\n\n return ref === undefined || ref.slot === -1 ? null : ref;\n}\n\nfunction slotPathAt(store: LevelStore, slot: number): string {\n return store.level.path + encodePart(String(slot));\n}\n\nfunction growStore(store: LevelStore): void {\n for (let slot = store.refs.length; slot < store.level.items.length; slot++) {\n store.refs.push({ store, slot });\n store.objects.push(null);\n store.childStores.push(null);\n }\n}\n\nfunction newLevelStore(level: Level): LevelStore {\n const store = new (registeredStoreClass())() as LevelStore;\n store.level = level;\n growStore(store);\n\n return store;\n}\n\nfunction collectFlips(previous: Level, next: Level, overlap: number): Set<number> {\n const flipped: Set<number> = new Set();\n\n for (let slot = 0; slot < overlap; slot++) {\n if ((previous.expandableFlags[slot] ?? false) !== (next.expandableFlags[slot] ?? false)) {\n flipped.add(slot);\n }\n }\n\n return flipped;\n}\n\nfunction pruneFlips(context: SyncContext, store: LevelStore, flipped: Set<number>): void {\n if (flipped.size === 0) {\n return;\n }\n\n pruneSlots(context.expansion, store.level.path, (slot) => flipped.has(slot));\n\n for (const slot of flipped) {\n store.childStores[slot] = null;\n }\n}\n\nfunction detachRefs(store: LevelStore, nextLength: number): void {\n for (let slot = nextLength; slot < store.refs.length; slot++) {\n const ref = store.refs[slot];\n\n if (ref !== undefined) {\n ref.slot = -1;\n }\n }\n}\n\nfunction shrinkStore(context: SyncContext, store: LevelStore, nextLength: number): void {\n if (store.refs.length <= nextLength) {\n return;\n }\n\n detachRefs(store, nextLength);\n pruneSlots(context.expansion, store.level.path, (slot) => slot >= nextLength);\n store.refs.length = nextLength;\n store.objects.length = nextLength;\n store.childStores.length = nextLength;\n}\n\nfunction emitTailSplice(store: LevelStore, previousLength: number, nextLength: number): void {\n if (nextLength < previousLength) {\n store.itemsChanged(nextLength, previousLength - nextLength, 0);\n\n return;\n }\n\n if (nextLength > previousLength) {\n store.itemsChanged(previousLength, 0, nextLength - previousLength);\n }\n}\n\nfunction extendRuns(runs: SlotRun[], slot: number): void {\n const last = runs.at(-1);\n\n if (last !== undefined && last.start + last.length === slot) {\n last.length += 1;\n\n return;\n }\n\n runs.push({ start: slot, length: 1 });\n}\n\nfunction collectFlipRuns(flipped: Set<number>): SlotRun[] {\n const runs: SlotRun[] = [];\n\n for (const slot of flipped) {\n extendRuns(runs, slot);\n }\n\n return runs;\n}\n\nfunction emitFlips(store: LevelStore, flipped: Set<number>): void {\n for (const run of collectFlipRuns(flipped)) {\n store.itemsChanged(run.start, run.length, run.length);\n }\n}\n\nfunction childSync(\n context: SyncContext,\n store: LevelStore,\n slot: number,\n flipped: Set<number>,\n): LevelSync | undefined {\n const child = store.childStores[slot] ?? null;\n\n if (child === null || flipped.has(slot)) {\n return undefined;\n }\n\n const level = context.index.childLevel(store.level, slot);\n\n return level === undefined ? undefined : { store: child, level };\n}\n\nfunction childSyncs(context: SyncContext, store: LevelStore, overlap: number, flipped: Set<number>): LevelSync[] {\n const syncs: LevelSync[] = [];\n\n for (let slot = 0; slot < overlap; slot++) {\n const sync = childSync(context, store, slot, flipped);\n\n if (sync !== undefined) {\n syncs.push(sync);\n }\n }\n\n return syncs;\n}\n\nfunction syncEntry(context: SyncContext, entry: LevelSync): LevelSync[] {\n const { store, level } = entry;\n const previousLength = store.refs.length;\n const overlap = Math.min(previousLength, level.items.length);\n const flipped = collectFlips(store.level, level, overlap);\n store.level = level;\n pruneFlips(context, store, flipped);\n shrinkStore(context, store, level.items.length);\n growStore(store);\n emitTailSplice(store, previousLength, level.items.length);\n emitFlips(store, flipped);\n\n return childSyncs(context, store, overlap, flipped);\n}\n\nfunction syncLevel(context: SyncContext, store: LevelStore, level: Level): void {\n const pending: LevelSync[] = [{ store, level }];\n\n while (pending.length > 0) {\n const entry = pending.pop();\n\n if (entry !== undefined) {\n pending.push(...syncEntry(context, entry).toReversed());\n }\n }\n}\n\nfunction ensureChildStore(index: CollectionIndex, store: LevelStore, slot: number): LevelStore | null {\n const existing = store.childStores[slot] ?? null;\n\n if (existing !== null || !(store.level.expandableFlags[slot] ?? false)) {\n return existing;\n }\n\n const level = index.childLevel(store.level, slot);\n\n if (level === undefined) {\n return null;\n }\n\n const created = newLevelStore(level);\n store.childStores[slot] = created;\n\n return created;\n}\n\nfunction childStoreFor(state: ModelState, object: GObject.Object): Gio.ListModel | null {\n const ref = slotRefFor(object);\n\n if (ref === null) {\n return null;\n }\n\n return ensureChildStore(state.index, ref.store, ref.slot);\n}\n\nfunction treeFor(state: ModelState, store: LevelStore): Gtk.TreeListModel {\n return (\n state.trees.get(store) ?? Gtk.TreeListModel.new(store, false, false, (object) => childStoreFor(state, object))\n );\n}\n\nfunction nextTrees(state: ModelState, index: CollectionIndex): Map<LevelStore, Gtk.TreeListModel> {\n if (!index.isTree) {\n return new Map();\n }\n\n return new Map(state.groupStores.map((store) => [store, treeFor(state, store)]));\n}\n\nfunction pruneRebuiltLevels(state: ModelState, next: Map<LevelStore, Gtk.TreeListModel>): void {\n const stores: Set<LevelStore> = new Set([...state.trees.keys(), ...next.keys()]);\n\n for (const store of stores) {\n if (state.trees.get(store) !== next.get(store)) {\n pruneSlots(state.expansion, store.level.path, () => true);\n }\n }\n}\n\nfunction adoptTrees(state: ModelState, index: CollectionIndex): void {\n const next = nextTrees(state, index);\n pruneRebuiltLevels(state, next);\n state.trees = next;\n state.treeModels = next.values().toArray();\n}\n\nfunction desiredRootModels(state: ModelState, index: CollectionIndex): GObject.Object[] {\n adoptTrees(state, index);\n\n return index.isTree ? [...state.treeModels] : [...state.groupStores];\n}\n\nfunction rowAt(state: ModelState, position: number): Gtk.TreeListRow | null {\n let offset = position;\n\n for (const tree of state.treeModels) {\n const count = tree.getNItems();\n\n if (offset < count) {\n return tree.getRow(offset);\n }\n\n offset -= count;\n }\n\n return null;\n}\n\nfunction hasSameModels(previous: GObject.Object[], next: GObject.Object[]): boolean {\n return previous.length === next.length && next.every((model, index) => previous[index] === model);\n}\n\nfunction syncRoot(state: ModelState, index: CollectionIndex): void {\n const next = desiredRootModels(state, index);\n\n if (hasSameModels(state.rootModels, next)) {\n return;\n }\n\n state.root.splice(0, state.rootModels.length, next);\n state.rootModels = next;\n}\n\nfunction adjustGroupStores(state: ModelState, context: SyncContext): void {\n const { groups } = context.index;\n state.groupStores.length = Math.min(state.groupStores.length, groups.length);\n\n for (const level of groups.slice(state.groupStores.length)) {\n state.groupStores.push(newLevelStore(level));\n }\n}\n\nfunction stepGroupStores(state: ModelState, context: SyncContext, surviving: number): void {\n for (const [group, level] of context.index.groups.entries()) {\n const store = state.groupStores[group];\n\n if (store !== undefined && group < surviving) {\n syncLevel(context, store, level);\n }\n }\n}\n\nfunction syncModel(state: ModelState, index: CollectionIndex): void {\n const context: SyncContext = { index, expansion: state.expansion };\n const surviving = Math.min(state.groupStores.length, index.groups.length);\n state.index = index;\n state.expansion.isSyncing = true;\n\n try {\n adjustGroupStores(state, context);\n syncRoot(state, index);\n stepGroupStores(state, context, surviving);\n } finally {\n state.expansion.isSyncing = false;\n }\n\n adoptIndex(state.expansion, index);\n}\n\nfunction createCollectionModel(): CollectionModel {\n registeredStoreClass();\n const root = newRootStore();\n\n const state: ModelState = {\n root,\n rootModels: [],\n model: Gtk.FlattenListModel.new(root),\n groupStores: [],\n trees: new Map(),\n treeModels: [],\n expansion: createTreeExpansion(EMPTY_INDEX),\n index: EMPTY_INDEX,\n };\n\n return {\n model: state.model,\n expansion: state.expansion,\n rowAt: (position) => rowAt(state, position),\n sync: (index) => {\n syncModel(state, index);\n },\n };\n}\n\nclass LazyLevelStore extends GObject.Object implements Gio.ListModelImpl {\n declare itemsChanged: Gio.ListModel[\"itemsChanged\"];\n level: Level = { path: \"\", items: [], expandableFlags: [] };\n refs: SlotRef[] = [];\n objects: (Gtk.StringObject | null)[] = [];\n childStores: (LevelStore | null)[] = [];\n\n private createItem(position: number, ref: SlotRef): Gtk.StringObject {\n const created = Gtk.StringObject.new(\"\");\n this.objects[position] = created;\n SLOTS.set(created, ref);\n\n return created;\n }\n\n vfuncGetItemType(): bigint {\n return GObject.TYPE_OBJECT;\n }\n\n vfuncGetNItems(): number {\n return this.refs.length;\n }\n\n vfuncGetItem(position: number): GObject.Object | null {\n const ref = this.refs[position];\n\n if (ref === undefined) {\n return null;\n }\n\n return this.objects[position] ?? this.createItem(position, ref);\n }\n}\n\nexport { createCollectionModel, slotPathAt, slotRefFor, type CollectionModel, type SlotRef };\n"]}
|
|
1
|
+
{"version":3,"file":"collection-model.js","sourceRoot":"","sources":["../../src/internal/collection-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA0ClF,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AACvE,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AACvE,MAAM,WAAW,GAAG,qBAAqB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACtE,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;AAE5B,MAAM,YAAY,GAAG,GAAkB,EAAE,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAE/F,SAAS,WAAW;I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C,CAAC;IAED,YAAY,CAAC,QAAgB;QACzB,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnE,CAAC;CACJ;AAED,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAsC,CAAC","sourcesContent":["import * as Gio from \"@gtkx/gi/gio\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { registerClass } from \"@gtkx/runtime\";\nimport type { CollectionIndex, Level } from \"./collection-index.js\";\nimport type { TreeExpansion } from \"./tree-expansion.js\";\nimport { createCollectionIndex } from \"./collection-index.js\";\nimport { encodePart } from \"./keys.js\";\nimport { adoptIndex, createTreeExpansion, pruneSlots } from \"./tree-expansion.js\";\n\ntype LevelStore = Gio.ListModel & LazyLevelStore;\n\ntype SlotRef = {\n store: LazyLevelStore;\n slot: number;\n};\n\ntype SyncContext = {\n index: CollectionIndex;\n expansion: TreeExpansion;\n};\n\ntype SlotRun = {\n start: number;\n length: number;\n};\n\ntype LevelSync = {\n store: LevelStore;\n level: Level;\n};\n\ntype ModelState = {\n root: Gio.ListStore;\n rootModels: GObject.Object[];\n model: Gtk.FlattenListModel;\n groupStores: LevelStore[];\n trees: Map<LevelStore, Gtk.TreeListModel>;\n treeModels: Gtk.TreeListModel[];\n expansion: TreeExpansion;\n index: CollectionIndex;\n};\n\ntype CollectionModel = {\n model: Gtk.FlattenListModel;\n expansion: TreeExpansion;\n rowAt: (position: number) => Gtk.TreeListRow | null;\n sync: (index: CollectionIndex) => void;\n};\n\nconst STORE_CLASS_KEY = Symbol.for(\"gtkx.components.lazy-level-store\");\nconst SLOTS_KEY = Symbol.for(\"gtkx.components.lazy-level-store.slots\");\nconst EMPTY_INDEX = createCollectionIndex(undefined, undefined, true);\nconst SLOTS = sharedSlots();\n\nconst newRootStore = (): Gio.ListStore => new Gio.ListStore({ itemType: GObject.TYPE_OBJECT });\n\nfunction sharedSlots(): WeakMap<GObject.Object, SlotRef> {\n const cached: unknown = Reflect.get(globalThis, SLOTS_KEY);\n\n if (cached instanceof WeakMap) {\n return cached as WeakMap<GObject.Object, SlotRef>;\n }\n\n const created: WeakMap<GObject.Object, SlotRef> = new WeakMap();\n Reflect.set(globalThis, SLOTS_KEY, created);\n\n return created;\n}\n\nfunction registeredStoreClass(): typeof LazyLevelStore {\n const cached: unknown = Reflect.get(globalThis, STORE_CLASS_KEY);\n\n if (typeof cached === \"function\") {\n return cached as typeof LazyLevelStore;\n }\n\n registerClass(LazyLevelStore, { typeName: \"GtkxLazyLevelStore\", implements: [Gio.ListModel] });\n Reflect.set(globalThis, STORE_CLASS_KEY, LazyLevelStore);\n\n return LazyLevelStore;\n}\n\nfunction slotRefFor(value: GObject.Object | null): SlotRef | null {\n const item = value instanceof Gtk.TreeListRow ? value.getItem() : value;\n\n if (item === null) {\n return null;\n }\n\n const ref = SLOTS.get(item);\n\n return ref === undefined || ref.slot === -1 ? null : ref;\n}\n\nfunction slotPathAt(store: LazyLevelStore, slot: number): string {\n return store.level.path + encodePart(String(slot));\n}\n\nfunction newLevelStore(level: Level): LevelStore {\n const store = new (registeredStoreClass())() as LevelStore;\n store.level = level;\n\n return store;\n}\n\nfunction collectFlips(previous: Level, next: Level, overlap: number): Set<number> {\n const flipped: Set<number> = new Set();\n\n if (previous.expandableFlags.length === 0 && next.expandableFlags.length === 0) {\n return flipped;\n }\n\n for (let slot = 0; slot < overlap; slot++) {\n if ((previous.expandableFlags[slot] ?? false) !== (next.expandableFlags[slot] ?? false)) {\n flipped.add(slot);\n }\n }\n\n return flipped;\n}\n\nfunction pruneFlips(context: SyncContext, store: LevelStore, flipped: Set<number>): void {\n if (flipped.size === 0) {\n return;\n }\n\n pruneSlots(context.expansion, store.level.path, (slot) => flipped.has(slot));\n\n for (const slot of flipped) {\n store.childStores.delete(slot);\n }\n}\n\nfunction detachRefs(store: LevelStore, nextLength: number): void {\n for (const [slot, ref] of store.refs) {\n if (slot < nextLength) {\n continue;\n }\n\n ref.slot = -1;\n store.refs.delete(slot);\n store.objects.delete(slot);\n store.childStores.delete(slot);\n }\n}\n\nfunction shrinkStore(context: SyncContext, store: LevelStore, previousLength: number, nextLength: number): void {\n if (previousLength <= nextLength) {\n return;\n }\n\n detachRefs(store, nextLength);\n pruneSlots(context.expansion, store.level.path, (slot) => slot >= nextLength);\n}\n\nfunction emitTailSplice(store: LevelStore, previousLength: number, nextLength: number): void {\n if (nextLength < previousLength) {\n store.itemsChanged(nextLength, previousLength - nextLength, 0);\n\n return;\n }\n\n if (nextLength > previousLength) {\n store.itemsChanged(previousLength, 0, nextLength - previousLength);\n }\n}\n\nfunction extendRuns(runs: SlotRun[], slot: number): void {\n const last = runs.at(-1);\n\n if (last !== undefined && last.start + last.length === slot) {\n last.length += 1;\n\n return;\n }\n\n runs.push({ start: slot, length: 1 });\n}\n\nfunction collectFlipRuns(flipped: Set<number>): SlotRun[] {\n const runs: SlotRun[] = [];\n\n for (const slot of flipped) {\n extendRuns(runs, slot);\n }\n\n return runs;\n}\n\nfunction emitFlips(store: LevelStore, flipped: Set<number>): void {\n for (const run of collectFlipRuns(flipped)) {\n store.itemsChanged(run.start, run.length, run.length);\n }\n}\n\nfunction childSync(\n context: SyncContext,\n store: LevelStore,\n slot: number,\n flipped: Set<number>,\n): LevelSync | undefined {\n const child = store.childStores.get(slot) ?? null;\n\n if (child === null || flipped.has(slot)) {\n return undefined;\n }\n\n const level = context.index.childLevel(store.level, slot);\n\n return level === undefined ? undefined : { store: child, level };\n}\n\nfunction childSyncs(context: SyncContext, store: LevelStore, overlap: number, flipped: Set<number>): LevelSync[] {\n const syncs: LevelSync[] = [];\n const slots = store.childStores.keys().toArray().toSorted((left, right) => left - right);\n\n for (const slot of slots) {\n if (slot >= overlap) {\n continue;\n }\n\n const sync = childSync(context, store, slot, flipped);\n\n if (sync !== undefined) {\n syncs.push(sync);\n }\n }\n\n return syncs;\n}\n\nfunction syncEntry(context: SyncContext, entry: LevelSync): LevelSync[] {\n const { store, level } = entry;\n const previous = store.level;\n const previousLength = previous.items.length;\n const overlap = Math.min(previousLength, level.items.length);\n const flipped = collectFlips(previous, level, overlap);\n store.level = level;\n pruneFlips(context, store, flipped);\n shrinkStore(context, store, previousLength, level.items.length);\n emitTailSplice(store, previousLength, level.items.length);\n emitFlips(store, flipped);\n\n return childSyncs(context, store, overlap, flipped);\n}\n\nfunction syncLevel(context: SyncContext, store: LevelStore, level: Level): void {\n const pending: LevelSync[] = [{ store, level }];\n\n while (pending.length > 0) {\n const entry = pending.pop();\n\n if (entry !== undefined) {\n pending.push(...syncEntry(context, entry).toReversed());\n }\n }\n}\n\nfunction ensureChildStore(index: CollectionIndex, store: LazyLevelStore, slot: number): LevelStore | null {\n const existing = store.childStores.get(slot) ?? null;\n\n if (existing !== null || !(store.level.expandableFlags[slot] ?? false)) {\n return existing;\n }\n\n const level = index.childLevel(store.level, slot);\n\n if (level === undefined) {\n return null;\n }\n\n const created = newLevelStore(level);\n store.childStores.set(slot, created);\n\n return created;\n}\n\nfunction childStoreFor(state: ModelState, object: GObject.Object): Gio.ListModel | null {\n const ref = slotRefFor(object);\n\n if (ref === null) {\n return null;\n }\n\n return ensureChildStore(state.index, ref.store, ref.slot);\n}\n\nfunction treeFor(state: ModelState, store: LevelStore): Gtk.TreeListModel {\n return (\n state.trees.get(store) ?? Gtk.TreeListModel.new(store, false, false, (object) => childStoreFor(state, object))\n );\n}\n\nfunction nextTrees(state: ModelState, index: CollectionIndex): Map<LevelStore, Gtk.TreeListModel> {\n if (!index.isTree) {\n return new Map();\n }\n\n return new Map(state.groupStores.map((store) => [store, treeFor(state, store)]));\n}\n\nfunction pruneRebuiltLevels(state: ModelState, next: Map<LevelStore, Gtk.TreeListModel>): void {\n const stores: Set<LevelStore> = new Set([...state.trees.keys(), ...next.keys()]);\n\n for (const store of stores) {\n if (state.trees.get(store) !== next.get(store)) {\n pruneSlots(state.expansion, store.level.path, () => true);\n }\n }\n}\n\nfunction adoptTrees(state: ModelState, index: CollectionIndex): void {\n const next = nextTrees(state, index);\n pruneRebuiltLevels(state, next);\n state.trees = next;\n state.treeModels = next.values().toArray();\n}\n\nfunction desiredRootModels(state: ModelState, index: CollectionIndex): GObject.Object[] {\n adoptTrees(state, index);\n\n return index.isTree ? [...state.treeModels] : [...state.groupStores];\n}\n\nfunction rowAt(state: ModelState, position: number): Gtk.TreeListRow | null {\n let offset = position;\n\n for (const tree of state.treeModels) {\n const count = tree.getNItems();\n\n if (offset < count) {\n return tree.getRow(offset);\n }\n\n offset -= count;\n }\n\n return null;\n}\n\nfunction hasSameModels(previous: GObject.Object[], next: GObject.Object[]): boolean {\n return previous.length === next.length && next.every((model, index) => previous[index] === model);\n}\n\nfunction syncRoot(state: ModelState, index: CollectionIndex): void {\n const next = desiredRootModels(state, index);\n\n if (hasSameModels(state.rootModels, next)) {\n return;\n }\n\n state.root.splice(0, state.rootModels.length, next);\n state.rootModels = next;\n}\n\nfunction adjustGroupStores(state: ModelState, context: SyncContext): void {\n const { groups } = context.index;\n state.groupStores.length = Math.min(state.groupStores.length, groups.length);\n\n for (const level of groups.slice(state.groupStores.length)) {\n state.groupStores.push(newLevelStore(level));\n }\n}\n\nfunction stepGroupStores(state: ModelState, context: SyncContext, surviving: number): void {\n for (const [group, level] of context.index.groups.entries()) {\n const store = state.groupStores[group];\n\n if (store !== undefined && group < surviving) {\n syncLevel(context, store, level);\n }\n }\n}\n\nfunction syncModel(state: ModelState, index: CollectionIndex): void {\n const context: SyncContext = { index, expansion: state.expansion };\n const surviving = Math.min(state.groupStores.length, index.groups.length);\n state.index = index;\n state.expansion.isSyncing = true;\n\n try {\n adjustGroupStores(state, context);\n syncRoot(state, index);\n stepGroupStores(state, context, surviving);\n } finally {\n state.expansion.isSyncing = false;\n }\n\n adoptIndex(state.expansion, index);\n}\n\nfunction createCollectionModel(): CollectionModel {\n registeredStoreClass();\n const root = newRootStore();\n\n const state: ModelState = {\n root,\n rootModels: [],\n model: Gtk.FlattenListModel.new(root),\n groupStores: [],\n trees: new Map(),\n treeModels: [],\n expansion: createTreeExpansion(EMPTY_INDEX),\n index: EMPTY_INDEX,\n };\n\n return {\n model: state.model,\n expansion: state.expansion,\n rowAt: (position) => rowAt(state, position),\n sync: (index) => {\n syncModel(state, index);\n },\n };\n}\n\nclass LazyLevelStore extends GObject.Object implements Gio.ListModelImpl {\n declare itemsChanged: Gio.ListModel[\"itemsChanged\"];\n level: Level = { path: \"\", items: [], expandableFlags: [] };\n refs: Map<number, SlotRef> = new Map();\n objects: Map<number, Gtk.StringObject> = new Map();\n childStores: Map<number, LevelStore> = new Map();\n\n private createItem(position: number): Gtk.StringObject {\n const ref = { store: this, slot: position };\n const created = Gtk.StringObject.new(\"\");\n this.refs.set(position, ref);\n this.objects.set(position, created);\n SLOTS.set(created, ref);\n\n return created;\n }\n\n vfuncGetItemType(): bigint {\n return GObject.TYPE_OBJECT;\n }\n\n vfuncGetNItems(): number {\n return this.level.items.length;\n }\n\n vfuncGetItem(position: number): GObject.Object | null {\n if (position < 0 || position >= this.level.items.length) {\n return null;\n }\n\n return this.objects.get(position) ?? this.createItem(position);\n }\n}\n\nexport { createCollectionModel, slotPathAt, slotRefFor, type CollectionModel, type SlotRef };\n"]}
|
package/dist/list-view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-view.d.ts","sourceRoot":"","sources":["../src/list-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"list-view.d.ts","sourceRoot":"","sources":["../src/list-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAoBhD;;;GAGG;AACH,iBAAS,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CA2BjF;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/list-view.js
CHANGED
package/dist/list-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-view.js","sourceRoot":"","sources":["../src/list-view.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,eAAe,GAAG;IACpB,OAAO;IACP,UAAU;IACV,YAAY;IACZ,cAAc;IACd,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,aAAa;IACb,kBAAkB;IAClB,sBAAsB;IACtB,qBAAqB;IACrB,oBAAoB;CACoB,CAAC;AAE7C;;;GAGG;AACH,SAAS,QAAQ,CAA2B,KAA0B;IAClE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC;IAC9E,MAAM,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,kBAAkB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,IAAI,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,gBAAgB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAEhE,OAAO,CACH,8BACI,KAAC,WAAW,IACR,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,KAAC,wBAAwB,OAAK,SAAS,CAAC,QAAQ,GAAI,KACzD,MAAM,CAAC,YAAY,KACnB,IAAI,GACV,EACF,KAAC,WAAW,IACR,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,GAC5C,EACD,MAAM,CAAC,OAAO,IAChB,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { GtkListView, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { omit } from \"@gtkx/utils\";\nimport type { ListViewProps } from \"./types.js\";\nimport { ItemPortals, useItemCells, useSectionHeader } from \"./internal/cells.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\n\nconst LIST_VIEW_PROPS = [\n \"items\",\n \"sections\",\n \"renderItem\",\n \"renderHeader\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"expandedIds\",\n \"onExpandedChange\",\n \"expanderDescriptions\",\n \"estimatedItemHeight\",\n \"estimatedItemWidth\",\n] as const satisfies (keyof ListViewProps)[];\n\n/**\n * Renders a Gtk.ListView from declarative items or sections, with per-row rendering,\n * controlled selection, controlled tree expansion, and estimated item sizing.\n */\nfunction ListView<T = unknown, S = unknown>(props: ListViewProps<T, S>): ReactNode {\n const { renderItem, renderHeader, expandedIds, expanderDescriptions } = props;\n const { estimatedItemHeight, estimatedItemWidth } = props;\n const rest = omit(props, LIST_VIEW_PROPS);\n const size = { width: estimatedItemWidth ?? -1, height: estimatedItemHeight ?? -1 };\n const { collection, selection } = useCollection(props);\n const itemCells = useItemCells(size);\n const header = useSectionHeader(renderHeader, collection, size);\n\n return (\n <>\n <GtkListView\n model={selection}\n factory={<GtkSignalListItemFactory {...itemCells.handlers} />}\n {...header.factoryProps}\n {...rest}\n />\n <ItemPortals\n registry={itemCells}\n render={renderItem}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n />\n {header.portals}\n </>\n );\n}\n\nexport { ListView };\n"]}
|
|
1
|
+
{"version":3,"file":"list-view.js","sourceRoot":"","sources":["../src/list-view.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,eAAe,GAAG;IACpB,OAAO;IACP,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,cAAc;IACd,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,aAAa;IACb,kBAAkB;IAClB,sBAAsB;IACtB,qBAAqB;IACrB,oBAAoB;CACoB,CAAC;AAE7C;;;GAGG;AACH,SAAS,QAAQ,CAA2B,KAA0B;IAClE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC;IAC9E,MAAM,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,kBAAkB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,IAAI,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,gBAAgB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAEhE,OAAO,CACH,8BACI,KAAC,WAAW,IACR,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,KAAC,wBAAwB,OAAK,SAAS,CAAC,QAAQ,GAAI,KACzD,MAAM,CAAC,YAAY,KACnB,IAAI,GACV,EACF,KAAC,WAAW,IACR,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,GAC5C,EACD,MAAM,CAAC,OAAO,IAChB,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { GtkListView, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { omit } from \"@gtkx/utils\";\nimport type { ListViewProps } from \"./types.js\";\nimport { ItemPortals, useItemCells, useSectionHeader } from \"./internal/cells.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\n\nconst LIST_VIEW_PROPS = [\n \"items\",\n \"sections\",\n \"isFlat\",\n \"renderItem\",\n \"renderHeader\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"expandedIds\",\n \"onExpandedChange\",\n \"expanderDescriptions\",\n \"estimatedItemHeight\",\n \"estimatedItemWidth\",\n] as const satisfies (keyof ListViewProps)[];\n\n/**\n * Renders a Gtk.ListView from declarative items or sections, with per-row rendering,\n * controlled selection, controlled tree expansion, and estimated item sizing.\n */\nfunction ListView<T = unknown, S = unknown>(props: ListViewProps<T, S>): ReactNode {\n const { renderItem, renderHeader, expandedIds, expanderDescriptions } = props;\n const { estimatedItemHeight, estimatedItemWidth } = props;\n const rest = omit(props, LIST_VIEW_PROPS);\n const size = { width: estimatedItemWidth ?? -1, height: estimatedItemHeight ?? -1 };\n const { collection, selection } = useCollection(props);\n const itemCells = useItemCells(size);\n const header = useSectionHeader(renderHeader, collection, size);\n\n return (\n <>\n <GtkListView\n model={selection}\n factory={<GtkSignalListItemFactory {...itemCells.handlers} />}\n {...header.factoryProps}\n {...rest}\n />\n <ItemPortals\n registry={itemCells}\n render={renderItem}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n />\n {header.portals}\n </>\n );\n}\n\nexport { ListView };\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -76,6 +76,15 @@ type ItemSizeProps = {
|
|
|
76
76
|
/** Width in pixels every cell asks for until its contents render; unset lets each cell size itself. */
|
|
77
77
|
estimatedItemWidth?: number | undefined;
|
|
78
78
|
};
|
|
79
|
+
/** The flat-collection hint shared by {@link ListView} and {@link ColumnView}. */
|
|
80
|
+
type FlatnessProps = {
|
|
81
|
+
/**
|
|
82
|
+
* Declares every item a leaf, so the view skips tree discovery when synchronising a large collection
|
|
83
|
+
* instead of scanning each item for `children`. Must not be set when any item has children: those
|
|
84
|
+
* items would render as plain rows that never expand.
|
|
85
|
+
*/
|
|
86
|
+
isFlat?: boolean | undefined;
|
|
87
|
+
};
|
|
79
88
|
/** Controlled selection shared by the multi-item collection views. */
|
|
80
89
|
type SelectionProps = {
|
|
81
90
|
/**
|
|
@@ -148,7 +157,7 @@ type ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" |
|
|
|
148
157
|
headerMenu?: ReactNode;
|
|
149
158
|
};
|
|
150
159
|
/** The declarative collection props {@link ColumnView} adds on top of Gtk.ColumnView's own. */
|
|
151
|
-
type ColumnViewOwnProps<T, S> = SelectionProps & ExpansionProps & SortProps & SourceProps<T, S> & Omit<ItemSizeProps, "estimatedItemWidth"> & {
|
|
160
|
+
type ColumnViewOwnProps<T, S> = SelectionProps & ExpansionProps & SortProps & SourceProps<T, S> & FlatnessProps & Omit<ItemSizeProps, "estimatedItemWidth"> & {
|
|
152
161
|
/** Columns to render, in order; each carries its own cell renderer. */
|
|
153
162
|
columns: ColumnViewColumn<T>[];
|
|
154
163
|
/** Renders the header shown above each section. */
|
|
@@ -198,7 +207,7 @@ type GridViewOwnProps<T> = ItemSizeProps & SelectionProps & {
|
|
|
198
207
|
*/
|
|
199
208
|
type GridViewProps<T = unknown> = Omit<GtkGridViewProps, "model" | "factory" | keyof GridViewOwnProps<T>> & GridViewOwnProps<T>;
|
|
200
209
|
/** The declarative collection props {@link ListView} adds on top of Gtk.ListView's own. */
|
|
201
|
-
type ListViewOwnProps<T, S> = ItemSizeProps & SelectionProps & ExpansionProps & SourceProps<T, S> & {
|
|
210
|
+
type ListViewOwnProps<T, S> = ItemSizeProps & SelectionProps & ExpansionProps & SourceProps<T, S> & FlatnessProps & {
|
|
202
211
|
/** Renders the contents of one row. */
|
|
203
212
|
renderItem: ListItemRenderer<T>;
|
|
204
213
|
/** Renders the header shown above each section. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EACR,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAA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ts"],"names":[],"mappings":"AAySA,OAAO,EAwBN,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { AdwComboRowProps, AdwToastProps } from \"@gtkx/jsx/adw\";\nimport type {\n GtkColumnViewColumnProps,\n GtkColumnViewProps,\n GtkDropDownProps,\n GtkGridViewProps,\n GtkListViewProps,\n} from \"@gtkx/jsx/gtk\";\nimport type { ReactNode, RefObject } from \"react\";\n\n/**\n * A single item in a collection model, identified by a stable id and holding an\n * arbitrary value. Nested items form a tree.\n */\ntype ListItem<T = unknown> = {\n /** Stable identifier used to track the item across updates and selection, naming every row that carries it. */\n id: string;\n /** Payload handed to the cell renderer as `ListItemRenderArgs.item`. */\n value: T;\n /** Child items nested under this one, which turn a plain item list into a tree, read only as rows are drawn. */\n children?: ListItem<T>[] | undefined;\n /** Hides the tree expander arrow even when the item has children, through `hide-expander`. */\n shouldHideExpander?: boolean | undefined;\n /** Adds indentation matching the item's depth in the tree, through `indent-for-depth`. */\n shouldIndentForDepth?: boolean | undefined;\n /** Reserves indentation space for an expander icon, through `indent-for-icon`. */\n shouldIndentForIcon?: boolean | undefined;\n};\n\n/** A group of items rendered under a shared section header. */\ntype ListSection<S = unknown, T = unknown> = {\n /** Stable identifier used to track the section across updates. */\n id: string;\n /** Payload handed to the section header renderer as `ListSectionRenderArgs.section`. */\n value: S;\n /** Items belonging to this section. */\n data: ListItem<T>[];\n};\n\n/** Arguments passed to a {@link ListItemRenderer} when rendering one cell. */\ntype ListItemRenderArgs<T> = {\n /** Value of the `ListItem` being rendered. */\n item: T;\n /** Position of the item in the flattened item list, which excludes section headers and collapsed tree rows. */\n index: number;\n /** Depth of the item within a tree, starting at zero for top-level items. */\n depth?: number | undefined;\n /** Whether the item is currently expanded in a tree view. */\n isExpanded?: boolean | undefined;\n};\n\n/**\n * Properties applied to the row that carries one item's cells. A Gtk.ColumnViewRow is not a widget, so\n * these are the only handles it offers; anything omitted falls back to the row's own default, which\n * leaves the accessibility strings unset rather than setting them to an empty string.\n */\ntype ListRowProps = {\n /** Name a screen reader announces for the row, through `accessible-label`. */\n accessibleLabel?: string | undefined;\n /** Longer description a screen reader announces for the row, through `accessible-description`. */\n accessibleDescription?: string | undefined;\n /** Whether activating the row emits the view's `activate` signal; rows are activatable by default. */\n isActivatable?: boolean | undefined;\n /** Whether the row takes keyboard focus; rows are focusable by default. */\n isFocusable?: boolean | undefined;\n /** Whether clicking or keying the row tries to select it; rows are selectable by default. */\n isSelectable?: boolean | undefined;\n};\n\n/** Arguments passed to a {@link ListSectionRenderer} when rendering one section header. */\ntype ListSectionRenderArgs<S> = {\n /** Value of the `ListSection` whose header is being rendered. */\n section: S;\n};\n\n/** Renders the contents of one cell of a collection view. */\ntype ListItemRenderer<T> = (args: ListItemRenderArgs<T>) => ReactNode;\n/** Renders the contents of one section header of a collection view. */\ntype ListSectionRenderer<S> = (args: ListSectionRenderArgs<S>) => ReactNode;\n/** Returns the {@link ListRowProps} to apply to the row displaying one item, re-run whenever the item renders. */\ntype ListRowPropsResolver<T> = (args: ListItemRenderArgs<T>) => ListRowProps;\n\n/** Size a collection view requests for each cell before its contents render, keeping scroll estimates steady. */\ntype ItemSizeProps = {\n /** Height in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemHeight?: number | undefined;\n /** Width in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemWidth?: number | undefined;\n};\n\n/** Controlled selection shared by the multi-item collection views. */\ntype SelectionProps = {\n /**\n * Ids of the items to keep selected; omitting it keeps nothing selected, and `onSelectionChanged` is how a\n * user's selection is adopted into it. An id repeated in several branches of a tree names every matching row,\n * and a single-selection view takes the first of them.\n */\n selectedIds?: string[] | null | undefined;\n /** Called with one id per selected row whenever the selection changes, and once on mount. */\n onSelectionChanged?: ((ids: string[]) => void) | null | undefined;\n /** How much the user may select, one item at a time unless `MULTIPLE` or `NONE` is given. */\n selectionMode?: Gtk.SelectionMode | null | undefined;\n};\n\n/**\n * Wording a screen reader announces for the control that expands and collapses a row. GTK names that control\n * after the row's own content and reports whether it is expanded, but says nothing about what activating it\n * does, so these strings supply that and belong in the application's own language.\n */\ntype ExpanderDescriptions = {\n /** Announced while the row is collapsed, such as \"Expand\". */\n expand: string;\n /** Announced while the row is expanded, such as \"Collapse\". */\n collapse: string;\n};\n\n/** Controlled expansion for the views that turn nested `ListItem.children` into a tree. */\ntype ExpansionProps = {\n /**\n * Ids of the items to keep expanded; omitting it keeps every row collapsed, and `onExpandedChange` is how a\n * user's expansion is adopted into it. An id repeated in several branches names every matching row, so all of\n * them expand together. An item whose children lead back to itself expands one level at a time, since a row\n * repeating an item already expanded above it stays collapsed.\n */\n expandedIds?: string[] | null | undefined;\n /** Called with one id per expanded row, in visible order, whenever expansion changes. */\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n /**\n * Wording announced for the expander of every row that can expand, describing what activating it does.\n * Omitting it leaves those expanders described only by the row they carry, and rows that cannot expand or\n * that hide their expander are never described.\n */\n expanderDescriptions?: ExpanderDescriptions | null | undefined;\n};\n\n/** Controlled sorting for the views whose headers can sort the collection. */\ntype SortProps = {\n /** Id of the column the view is sorted by, making sorting controlled. */\n sortColumn?: string | null | undefined;\n /** Direction `sortColumn` is sorted in, defaulting to ascending. */\n sortOrder?: Gtk.SortType | null | undefined;\n /** Called when the user sorts from a header, with the primary column's id, or null, and its order. */\n onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;\n};\n\n/** The data a collection view renders, either as a plain item list or grouped into sections. */\ntype SourceProps<T, S> = {\n /** Items to render, nesting through `ListItem.children` for a tree; ignored once `sections` is given. */\n items?: ListItem<T>[] | undefined;\n /** Items grouped under section headers, rendered in place of `items`. */\n sections?: ListSection<S, T>[] | undefined;\n};\n\n/** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */\ntype ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, \"factory\" | \"sorter\" | \"id\" | \"title\"> & {\n /** Stable identifier, also used to address the column through sorting props. */\n id: string;\n /** Text shown in the column header. */\n title: string;\n /** Renders the contents of this column's cell for one item. */\n renderCell: ListItemRenderer<T>;\n /** Makes the column header clickable, reporting the choice through `onSortChanged`. */\n isSortable?: boolean | undefined;\n /** Menu element popped up as the column header's context menu, on a right-click. */\n headerMenu?: ReactNode;\n};\n\n/** The declarative collection props {@link ColumnView} adds on top of Gtk.ColumnView's own. */\ntype ColumnViewOwnProps<T, S> = SelectionProps &\n ExpansionProps &\n SortProps &\n SourceProps<T, S> &\n Omit<ItemSizeProps, \"estimatedItemWidth\"> & {\n /** Columns to render, in order; each carries its own cell renderer. */\n columns: ColumnViewColumn<T>[];\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n /** Resolves the props of the row carrying one item's cells, such as its screen-reader label. */\n rowProps?: ListRowPropsResolver<T> | null | undefined;\n };\n\n/**\n * Props for {@link ColumnView}. Combines the underlying Gtk.ColumnView props with\n * declarative collection props: flat items or grouped sections, controlled selection\n * and expansion, sorting (sortColumn, sortOrder, onSortChanged), an optional section\n * header renderer, per-row props, and the columns to render.\n */\ntype ColumnViewProps<T = unknown, S = unknown> = Omit<\n GtkColumnViewProps,\n \"columns\" | \"model\" | \"headerFactory\" | \"rowFactory\" | keyof ColumnViewOwnProps<T, S>\n> &\nColumnViewOwnProps<T, S>;\n\n/** The declarative collection props {@link DropDown} and `ComboRow` add on top of their widget's own. */\ntype DropDownOwnProps<T, S> = SourceProps<T, S> & {\n /** Id of the currently selected item, making the selection controlled. */\n selectedId?: string | null | undefined;\n /** Called with the id of the item that became selected. */\n onSelectionChanged?: ((id: string) => void) | null | undefined;\n /** Renders the collapsed display, and the popup rows too unless `renderListItem` is given. */\n renderItem?: ListItemRenderer<T> | null | undefined;\n /** Renderer for items in the open popup list, falling back to renderItem when omitted. */\n renderListItem?: ListItemRenderer<T> | null | undefined;\n /** Renderer for section headers in the popup list. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n};\n\n/** A drop-down-shaped widget's props with its model and factories swapped for the declarative collection props. */\ntype DropDownWidgetProps<Widget, T, S> = Omit<\n Widget,\n \"model\" | \"factory\" | \"listFactory\" | \"headerFactory\" | keyof DropDownOwnProps<T, S>\n> &\nDropDownOwnProps<T, S>;\n\n/**\n * Props for {@link DropDown}. Combines the underlying Gtk.DropDown props with the declarative\n * collection props: flat items or grouped sections, controlled single selection, and renderers\n * for the collapsed display, popup rows, and popup section headers.\n */\ntype DropDownProps<T = unknown, S = unknown> = DropDownWidgetProps<GtkDropDownProps, T, S>;\n\n/** The declarative collection props {@link GridView} adds on top of Gtk.GridView's own. */\ntype GridViewOwnProps<T> = ItemSizeProps &\n SelectionProps & {\n /** Items to render as cells; a grid is always flat, so `ListItem.children` is ignored. */\n items?: ListItem<T>[] | undefined;\n /** Renders the contents of one cell. */\n renderItem: ListItemRenderer<T>;\n };\n\n/**\n * Props for {@link GridView}. Combines the underlying Gtk.GridView props with\n * declarative collection props: items, a per-cell renderItem, controlled selection,\n * and estimated item sizing.\n */\ntype GridViewProps<T = unknown> = Omit<GtkGridViewProps, \"model\" | \"factory\" | keyof GridViewOwnProps<T>> &\n GridViewOwnProps<T>;\n\n/** The declarative collection props {@link ListView} adds on top of Gtk.ListView's own. */\ntype ListViewOwnProps<T, S> = ItemSizeProps &\n SelectionProps &\n ExpansionProps &\n SourceProps<T, S> & {\n /** Renders the contents of one row. */\n renderItem: ListItemRenderer<T>;\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n };\n\n/**\n * Props for {@link ListView}. Combines the underlying Gtk.ListView props with\n * declarative collection props: flat items or grouped sections, a per-row renderItem,\n * an optional section header renderer, controlled selection and expansion, and\n * estimated item sizing.\n */\ntype ListViewProps<T = unknown, S = unknown> = Omit<\n GtkListViewProps,\n \"model\" | \"factory\" | \"headerFactory\" | keyof ListViewOwnProps<T, S>\n> &\nListViewOwnProps<T, S>;\n\n/**\n * Props for {@link ComboRow}. Combines the underlying Adw.ComboRow props with the declarative\n * collection props: flat items or grouped sections, controlled single selection, and renderers\n * for the row display, popup rows, and popup section headers.\n */\ntype ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;\n/**\n * Describes a toast raised through {@link useToast}: the construct-time properties of an\n * `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.\n */\ntype ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, \"onButtonClicked\" | \"onDismissed\">;\n\n/** Imperative controls for individual toasts, returned by {@link useToast}. */\ntype ToastController = {\n /** Builds a toast, shows it through the overlay, and returns it. */\n show: (options?: ToastOptions) => Adw.Toast;\n /** Dismisses a single toast, typically one returned by `ToastController.show`. */\n dismiss: (toast: Adw.Toast) => void;\n};\n\n/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */\ntype ToastOverlayController = {\n /** Dismisses the shown toast and every queued one. */\n dismissAll: () => void;\n};\n\n/** Props for {@link ToastProvider}. */\ntype ToastProviderProps = {\n /** Ref also given to the `AdwToastOverlay` the toasts appear over. */\n overlayRef: RefObject<Adw.ToastOverlay | null>;\n /** Subtree whose `useToast` and `useToastOverlay` calls target that overlay. */\n children?: ReactNode | undefined;\n};\n\nexport {\n type SelectionProps,\n type ExpanderDescriptions,\n type ExpansionProps,\n type SortProps,\n type DropDownOwnProps,\n type ListItem,\n type ListSection,\n type ListItemRenderArgs,\n type ListRowProps,\n type ListSectionRenderArgs,\n type ListItemRenderer,\n type ListRowPropsResolver,\n type ListSectionRenderer,\n type ColumnViewColumn,\n type ColumnViewProps,\n type DropDownProps,\n type GridViewProps,\n type ListViewProps,\n type ComboRowProps,\n type ToastOptions,\n type ToastController,\n type ToastOverlayController,\n type ToastProviderProps,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqTA,OAAO,EAwBN,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { AdwComboRowProps, AdwToastProps } from \"@gtkx/jsx/adw\";\nimport type {\n GtkColumnViewColumnProps,\n GtkColumnViewProps,\n GtkDropDownProps,\n GtkGridViewProps,\n GtkListViewProps,\n} from \"@gtkx/jsx/gtk\";\nimport type { ReactNode, RefObject } from \"react\";\n\n/**\n * A single item in a collection model, identified by a stable id and holding an\n * arbitrary value. Nested items form a tree.\n */\ntype ListItem<T = unknown> = {\n /** Stable identifier used to track the item across updates and selection, naming every row that carries it. */\n id: string;\n /** Payload handed to the cell renderer as `ListItemRenderArgs.item`. */\n value: T;\n /** Child items nested under this one, which turn a plain item list into a tree, read only as rows are drawn. */\n children?: ListItem<T>[] | undefined;\n /** Hides the tree expander arrow even when the item has children, through `hide-expander`. */\n shouldHideExpander?: boolean | undefined;\n /** Adds indentation matching the item's depth in the tree, through `indent-for-depth`. */\n shouldIndentForDepth?: boolean | undefined;\n /** Reserves indentation space for an expander icon, through `indent-for-icon`. */\n shouldIndentForIcon?: boolean | undefined;\n};\n\n/** A group of items rendered under a shared section header. */\ntype ListSection<S = unknown, T = unknown> = {\n /** Stable identifier used to track the section across updates. */\n id: string;\n /** Payload handed to the section header renderer as `ListSectionRenderArgs.section`. */\n value: S;\n /** Items belonging to this section. */\n data: ListItem<T>[];\n};\n\n/** Arguments passed to a {@link ListItemRenderer} when rendering one cell. */\ntype ListItemRenderArgs<T> = {\n /** Value of the `ListItem` being rendered. */\n item: T;\n /** Position of the item in the flattened item list, which excludes section headers and collapsed tree rows. */\n index: number;\n /** Depth of the item within a tree, starting at zero for top-level items. */\n depth?: number | undefined;\n /** Whether the item is currently expanded in a tree view. */\n isExpanded?: boolean | undefined;\n};\n\n/**\n * Properties applied to the row that carries one item's cells. A Gtk.ColumnViewRow is not a widget, so\n * these are the only handles it offers; anything omitted falls back to the row's own default, which\n * leaves the accessibility strings unset rather than setting them to an empty string.\n */\ntype ListRowProps = {\n /** Name a screen reader announces for the row, through `accessible-label`. */\n accessibleLabel?: string | undefined;\n /** Longer description a screen reader announces for the row, through `accessible-description`. */\n accessibleDescription?: string | undefined;\n /** Whether activating the row emits the view's `activate` signal; rows are activatable by default. */\n isActivatable?: boolean | undefined;\n /** Whether the row takes keyboard focus; rows are focusable by default. */\n isFocusable?: boolean | undefined;\n /** Whether clicking or keying the row tries to select it; rows are selectable by default. */\n isSelectable?: boolean | undefined;\n};\n\n/** Arguments passed to a {@link ListSectionRenderer} when rendering one section header. */\ntype ListSectionRenderArgs<S> = {\n /** Value of the `ListSection` whose header is being rendered. */\n section: S;\n};\n\n/** Renders the contents of one cell of a collection view. */\ntype ListItemRenderer<T> = (args: ListItemRenderArgs<T>) => ReactNode;\n/** Renders the contents of one section header of a collection view. */\ntype ListSectionRenderer<S> = (args: ListSectionRenderArgs<S>) => ReactNode;\n/** Returns the {@link ListRowProps} to apply to the row displaying one item, re-run whenever the item renders. */\ntype ListRowPropsResolver<T> = (args: ListItemRenderArgs<T>) => ListRowProps;\n\n/** Size a collection view requests for each cell before its contents render, keeping scroll estimates steady. */\ntype ItemSizeProps = {\n /** Height in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemHeight?: number | undefined;\n /** Width in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemWidth?: number | undefined;\n};\n\n/** The flat-collection hint shared by {@link ListView} and {@link ColumnView}. */\ntype FlatnessProps = {\n /**\n * Declares every item a leaf, so the view skips tree discovery when synchronising a large collection\n * instead of scanning each item for `children`. Must not be set when any item has children: those\n * items would render as plain rows that never expand.\n */\n isFlat?: boolean | undefined;\n};\n\n/** Controlled selection shared by the multi-item collection views. */\ntype SelectionProps = {\n /**\n * Ids of the items to keep selected; omitting it keeps nothing selected, and `onSelectionChanged` is how a\n * user's selection is adopted into it. An id repeated in several branches of a tree names every matching row,\n * and a single-selection view takes the first of them.\n */\n selectedIds?: string[] | null | undefined;\n /** Called with one id per selected row whenever the selection changes, and once on mount. */\n onSelectionChanged?: ((ids: string[]) => void) | null | undefined;\n /** How much the user may select, one item at a time unless `MULTIPLE` or `NONE` is given. */\n selectionMode?: Gtk.SelectionMode | null | undefined;\n};\n\n/**\n * Wording a screen reader announces for the control that expands and collapses a row. GTK names that control\n * after the row's own content and reports whether it is expanded, but says nothing about what activating it\n * does, so these strings supply that and belong in the application's own language.\n */\ntype ExpanderDescriptions = {\n /** Announced while the row is collapsed, such as \"Expand\". */\n expand: string;\n /** Announced while the row is expanded, such as \"Collapse\". */\n collapse: string;\n};\n\n/** Controlled expansion for the views that turn nested `ListItem.children` into a tree. */\ntype ExpansionProps = {\n /**\n * Ids of the items to keep expanded; omitting it keeps every row collapsed, and `onExpandedChange` is how a\n * user's expansion is adopted into it. An id repeated in several branches names every matching row, so all of\n * them expand together. An item whose children lead back to itself expands one level at a time, since a row\n * repeating an item already expanded above it stays collapsed.\n */\n expandedIds?: string[] | null | undefined;\n /** Called with one id per expanded row, in visible order, whenever expansion changes. */\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n /**\n * Wording announced for the expander of every row that can expand, describing what activating it does.\n * Omitting it leaves those expanders described only by the row they carry, and rows that cannot expand or\n * that hide their expander are never described.\n */\n expanderDescriptions?: ExpanderDescriptions | null | undefined;\n};\n\n/** Controlled sorting for the views whose headers can sort the collection. */\ntype SortProps = {\n /** Id of the column the view is sorted by, making sorting controlled. */\n sortColumn?: string | null | undefined;\n /** Direction `sortColumn` is sorted in, defaulting to ascending. */\n sortOrder?: Gtk.SortType | null | undefined;\n /** Called when the user sorts from a header, with the primary column's id, or null, and its order. */\n onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;\n};\n\n/** The data a collection view renders, either as a plain item list or grouped into sections. */\ntype SourceProps<T, S> = {\n /** Items to render, nesting through `ListItem.children` for a tree; ignored once `sections` is given. */\n items?: ListItem<T>[] | undefined;\n /** Items grouped under section headers, rendered in place of `items`. */\n sections?: ListSection<S, T>[] | undefined;\n};\n\n/** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */\ntype ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, \"factory\" | \"sorter\" | \"id\" | \"title\"> & {\n /** Stable identifier, also used to address the column through sorting props. */\n id: string;\n /** Text shown in the column header. */\n title: string;\n /** Renders the contents of this column's cell for one item. */\n renderCell: ListItemRenderer<T>;\n /** Makes the column header clickable, reporting the choice through `onSortChanged`. */\n isSortable?: boolean | undefined;\n /** Menu element popped up as the column header's context menu, on a right-click. */\n headerMenu?: ReactNode;\n};\n\n/** The declarative collection props {@link ColumnView} adds on top of Gtk.ColumnView's own. */\ntype ColumnViewOwnProps<T, S> = SelectionProps &\n ExpansionProps &\n SortProps &\n SourceProps<T, S> &\n FlatnessProps &\n Omit<ItemSizeProps, \"estimatedItemWidth\"> & {\n /** Columns to render, in order; each carries its own cell renderer. */\n columns: ColumnViewColumn<T>[];\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n /** Resolves the props of the row carrying one item's cells, such as its screen-reader label. */\n rowProps?: ListRowPropsResolver<T> | null | undefined;\n };\n\n/**\n * Props for {@link ColumnView}. Combines the underlying Gtk.ColumnView props with\n * declarative collection props: flat items or grouped sections, controlled selection\n * and expansion, sorting (sortColumn, sortOrder, onSortChanged), an optional section\n * header renderer, per-row props, and the columns to render.\n */\ntype ColumnViewProps<T = unknown, S = unknown> = Omit<\n GtkColumnViewProps,\n \"columns\" | \"model\" | \"headerFactory\" | \"rowFactory\" | keyof ColumnViewOwnProps<T, S>\n> &\nColumnViewOwnProps<T, S>;\n\n/** The declarative collection props {@link DropDown} and `ComboRow` add on top of their widget's own. */\ntype DropDownOwnProps<T, S> = SourceProps<T, S> & {\n /** Id of the currently selected item, making the selection controlled. */\n selectedId?: string | null | undefined;\n /** Called with the id of the item that became selected. */\n onSelectionChanged?: ((id: string) => void) | null | undefined;\n /** Renders the collapsed display, and the popup rows too unless `renderListItem` is given. */\n renderItem?: ListItemRenderer<T> | null | undefined;\n /** Renderer for items in the open popup list, falling back to renderItem when omitted. */\n renderListItem?: ListItemRenderer<T> | null | undefined;\n /** Renderer for section headers in the popup list. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n};\n\n/** A drop-down-shaped widget's props with its model and factories swapped for the declarative collection props. */\ntype DropDownWidgetProps<Widget, T, S> = Omit<\n Widget,\n \"model\" | \"factory\" | \"listFactory\" | \"headerFactory\" | keyof DropDownOwnProps<T, S>\n> &\nDropDownOwnProps<T, S>;\n\n/**\n * Props for {@link DropDown}. Combines the underlying Gtk.DropDown props with the declarative\n * collection props: flat items or grouped sections, controlled single selection, and renderers\n * for the collapsed display, popup rows, and popup section headers.\n */\ntype DropDownProps<T = unknown, S = unknown> = DropDownWidgetProps<GtkDropDownProps, T, S>;\n\n/** The declarative collection props {@link GridView} adds on top of Gtk.GridView's own. */\ntype GridViewOwnProps<T> = ItemSizeProps &\n SelectionProps & {\n /** Items to render as cells; a grid is always flat, so `ListItem.children` is ignored. */\n items?: ListItem<T>[] | undefined;\n /** Renders the contents of one cell. */\n renderItem: ListItemRenderer<T>;\n };\n\n/**\n * Props for {@link GridView}. Combines the underlying Gtk.GridView props with\n * declarative collection props: items, a per-cell renderItem, controlled selection,\n * and estimated item sizing.\n */\ntype GridViewProps<T = unknown> = Omit<GtkGridViewProps, \"model\" | \"factory\" | keyof GridViewOwnProps<T>> &\n GridViewOwnProps<T>;\n\n/** The declarative collection props {@link ListView} adds on top of Gtk.ListView's own. */\ntype ListViewOwnProps<T, S> = ItemSizeProps &\n SelectionProps &\n ExpansionProps &\n SourceProps<T, S> &\n FlatnessProps & {\n /** Renders the contents of one row. */\n renderItem: ListItemRenderer<T>;\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n };\n\n/**\n * Props for {@link ListView}. Combines the underlying Gtk.ListView props with\n * declarative collection props: flat items or grouped sections, a per-row renderItem,\n * an optional section header renderer, controlled selection and expansion, and\n * estimated item sizing.\n */\ntype ListViewProps<T = unknown, S = unknown> = Omit<\n GtkListViewProps,\n \"model\" | \"factory\" | \"headerFactory\" | keyof ListViewOwnProps<T, S>\n> &\nListViewOwnProps<T, S>;\n\n/**\n * Props for {@link ComboRow}. Combines the underlying Adw.ComboRow props with the declarative\n * collection props: flat items or grouped sections, controlled single selection, and renderers\n * for the row display, popup rows, and popup section headers.\n */\ntype ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;\n/**\n * Describes a toast raised through {@link useToast}: the construct-time properties of an\n * `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.\n */\ntype ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, \"onButtonClicked\" | \"onDismissed\">;\n\n/** Imperative controls for individual toasts, returned by {@link useToast}. */\ntype ToastController = {\n /** Builds a toast, shows it through the overlay, and returns it. */\n show: (options?: ToastOptions) => Adw.Toast;\n /** Dismisses a single toast, typically one returned by `ToastController.show`. */\n dismiss: (toast: Adw.Toast) => void;\n};\n\n/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */\ntype ToastOverlayController = {\n /** Dismisses the shown toast and every queued one. */\n dismissAll: () => void;\n};\n\n/** Props for {@link ToastProvider}. */\ntype ToastProviderProps = {\n /** Ref also given to the `AdwToastOverlay` the toasts appear over. */\n overlayRef: RefObject<Adw.ToastOverlay | null>;\n /** Subtree whose `useToast` and `useToastOverlay` calls target that overlay. */\n children?: ReactNode | undefined;\n};\n\nexport {\n type SelectionProps,\n type ExpanderDescriptions,\n type ExpansionProps,\n type SortProps,\n type DropDownOwnProps,\n type ListItem,\n type ListSection,\n type ListItemRenderArgs,\n type ListRowProps,\n type ListSectionRenderArgs,\n type ListItemRenderer,\n type ListRowPropsResolver,\n type ListSectionRenderer,\n type ColumnViewColumn,\n type ColumnViewProps,\n type DropDownProps,\n type GridViewProps,\n type ListViewProps,\n type ComboRowProps,\n type ToastOptions,\n type ToastController,\n type ToastOverlayController,\n type ToastProviderProps,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/components",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "High-level GTK components: collection views, menus, containers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
"node": ">=26.7.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@gtkx/react": "2.0.0-beta.
|
|
56
|
-
"@gtkx/runtime": "2.0.0-beta.
|
|
57
|
-
"@gtkx/utils": "2.0.0-beta.
|
|
55
|
+
"@gtkx/react": "2.0.0-beta.6",
|
|
56
|
+
"@gtkx/runtime": "2.0.0-beta.6",
|
|
57
|
+
"@gtkx/utils": "2.0.0-beta.6"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^19.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@gtkx/config": "2.0.0-beta.
|
|
64
|
-
"@gtkx/testing": "2.0.0-beta.
|
|
65
|
-
"@gtkx/vitest": "2.0.0-beta.
|
|
63
|
+
"@gtkx/config": "2.0.0-beta.6",
|
|
64
|
+
"@gtkx/testing": "2.0.0-beta.6",
|
|
65
|
+
"@gtkx/vitest": "2.0.0-beta.6",
|
|
66
66
|
"vitest": "^4.1.11"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|