@gtkx/components 1.0.0-rc.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/column-view.d.ts +2 -2
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +14 -12
- package/dist/column-view.js.map +1 -1
- package/dist/grid-view.js +1 -1
- package/dist/grid-view.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/cells.d.ts +31 -23
- package/dist/internal/cells.d.ts.map +1 -1
- package/dist/internal/cells.js +168 -77
- package/dist/internal/cells.js.map +1 -1
- package/dist/internal/collection-index.d.ts +8 -11
- package/dist/internal/collection-index.d.ts.map +1 -1
- package/dist/internal/collection-index.js +53 -73
- package/dist/internal/collection-index.js.map +1 -1
- package/dist/internal/collection-model.d.ts +24 -4
- package/dist/internal/collection-model.d.ts.map +1 -1
- package/dist/internal/collection-model.js +247 -96
- package/dist/internal/collection-model.js.map +1 -1
- package/dist/internal/collection.d.ts +8 -10
- package/dist/internal/collection.d.ts.map +1 -1
- package/dist/internal/collection.js +38 -48
- package/dist/internal/collection.js.map +1 -1
- package/dist/internal/controlled-sync.d.ts +11 -0
- package/dist/internal/controlled-sync.d.ts.map +1 -0
- package/dist/internal/controlled-sync.js +19 -0
- package/dist/internal/controlled-sync.js.map +1 -0
- package/dist/internal/drop-down.d.ts.map +1 -1
- package/dist/internal/drop-down.js +27 -15
- package/dist/internal/drop-down.js.map +1 -1
- package/dist/internal/expansion.d.ts +3 -2
- package/dist/internal/expansion.d.ts.map +1 -1
- package/dist/internal/expansion.js +73 -48
- package/dist/internal/expansion.js.map +1 -1
- package/dist/internal/keys.d.ts +5 -0
- package/dist/internal/keys.d.ts.map +1 -0
- package/dist/internal/keys.js +13 -0
- package/dist/internal/keys.js.map +1 -0
- package/dist/internal/selection.d.ts +3 -2
- package/dist/internal/selection.d.ts.map +1 -1
- package/dist/internal/selection.js +68 -35
- package/dist/internal/selection.js.map +1 -1
- package/dist/internal/slots.d.ts +10 -0
- package/dist/internal/slots.d.ts.map +1 -0
- package/dist/internal/slots.js +43 -0
- package/dist/internal/slots.js.map +1 -0
- package/dist/internal/tree-expansion.d.ts +19 -0
- package/dist/internal/tree-expansion.d.ts.map +1 -0
- package/dist/internal/tree-expansion.js +72 -0
- package/dist/internal/tree-expansion.js.map +1 -0
- package/dist/internal/tree-order.d.ts +26 -0
- package/dist/internal/tree-order.d.ts.map +1 -0
- package/dist/internal/tree-order.js +109 -0
- package/dist/internal/tree-order.js.map +1 -0
- package/dist/internal/use-collection.d.ts +1 -1
- package/dist/internal/use-collection.d.ts.map +1 -1
- package/dist/internal/use-collection.js +4 -4
- package/dist/internal/use-collection.js.map +1 -1
- package/dist/list-view.d.ts.map +1 -1
- package/dist/list-view.js +6 -6
- package/dist/list-view.js.map +1 -1
- package/dist/types.d.ts +72 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +17 -9
- package/src/column-view.tsx +28 -25
- package/src/grid-view.tsx +1 -1
- package/src/index.ts +3 -0
- package/src/internal/cells.tsx +339 -117
- package/src/internal/collection-index.ts +68 -92
- package/src/internal/collection-model.ts +327 -112
- package/src/internal/collection.ts +45 -65
- package/src/internal/controlled-sync.ts +34 -0
- package/src/internal/drop-down.tsx +41 -20
- package/src/internal/expansion.ts +95 -70
- package/src/internal/keys.ts +18 -0
- package/src/internal/selection.tsx +100 -51
- package/src/internal/slots.ts +67 -0
- package/src/internal/tree-expansion.ts +115 -0
- package/src/internal/tree-order.ts +208 -0
- package/src/internal/use-collection.tsx +5 -5
- package/src/list-view.tsx +14 -10
- package/src/types.ts +78 -20
package/dist/internal/cells.js
CHANGED
|
@@ -1,30 +1,51 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
-
import { GtkTreeExpander } from "@gtkx/jsx/gtk";
|
|
3
|
+
import { GtkSignalListItemFactory, GtkTreeExpander } from "@gtkx/jsx/gtk";
|
|
4
4
|
import { createPortal, useProperty } from "@gtkx/react";
|
|
5
|
+
import { setObjectProperty, t } from "@gtkx/runtime";
|
|
5
6
|
import { memo, useLayoutEffect, useState, useSyncExternalStore } from "react";
|
|
6
|
-
import {
|
|
7
|
+
import { slotRefFor } from "./collection-model.js";
|
|
7
8
|
const ItemCell = memo(ItemCellImpl);
|
|
9
|
+
const ItemRow = memo(ItemRowImpl);
|
|
8
10
|
const HeaderCell = memo(HeaderCellImpl);
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const CELL_OPTIONS = { isHost: isListItem, prepare: prepareCell };
|
|
12
|
+
const HEADER_OPTIONS = { isHost: isListHeader, prepare: prepareCell };
|
|
13
|
+
const ROW_OPTIONS = { isHost: isColumnViewRow };
|
|
14
|
+
const NO_SIZE = { width: -1, height: -1 };
|
|
15
|
+
const NO_ROW_PROPS = {};
|
|
16
|
+
const ROW_TEXT_DESCRIPTOR = t.string("borrowed");
|
|
11
17
|
const placeholder = (size) => new Gtk.Box({ widthRequest: size.width, heightRequest: size.height });
|
|
18
|
+
function isListItem(value) {
|
|
19
|
+
return value instanceof Gtk.ListItem;
|
|
20
|
+
}
|
|
21
|
+
function isListHeader(value) {
|
|
22
|
+
return value instanceof Gtk.ListHeader;
|
|
23
|
+
}
|
|
24
|
+
function isColumnViewRow(value) {
|
|
25
|
+
return value instanceof Gtk.ColumnViewRow;
|
|
26
|
+
}
|
|
27
|
+
function prepareCell(host, size) {
|
|
28
|
+
if (host.getChild() === null) {
|
|
29
|
+
host.setChild(placeholder(size));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
12
32
|
function notifyEntry(entry) {
|
|
13
33
|
for (const listener of entry.listeners) {
|
|
14
34
|
listener();
|
|
15
35
|
}
|
|
16
36
|
}
|
|
17
|
-
function
|
|
37
|
+
function notifyRegistry(state) {
|
|
18
38
|
state.snapshot = null;
|
|
39
|
+
state.version += 1;
|
|
19
40
|
for (const listener of state.listeners) {
|
|
20
41
|
listener();
|
|
21
42
|
}
|
|
22
43
|
}
|
|
23
|
-
function createEntry(state,
|
|
44
|
+
function createEntry(state, host) {
|
|
24
45
|
state.serial += 1;
|
|
25
46
|
const entry = {
|
|
26
47
|
key: `gtkx-cell-${String(state.serial)}`,
|
|
27
|
-
|
|
48
|
+
host,
|
|
28
49
|
item: null,
|
|
29
50
|
listeners: new Set(),
|
|
30
51
|
subscribe: (onChange) => {
|
|
@@ -37,102 +58,97 @@ function createEntry(state, cell) {
|
|
|
37
58
|
};
|
|
38
59
|
return entry;
|
|
39
60
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
state.entries.set(
|
|
43
|
-
|
|
61
|
+
function setupHost(state, host) {
|
|
62
|
+
state.prepare?.(host, state.size);
|
|
63
|
+
state.entries.set(host, createEntry(state, host));
|
|
64
|
+
notifyRegistry(state);
|
|
44
65
|
}
|
|
45
|
-
function
|
|
46
|
-
if (state.entries.delete(
|
|
47
|
-
|
|
66
|
+
function teardownHost(state, host) {
|
|
67
|
+
if (state.entries.delete(host)) {
|
|
68
|
+
notifyRegistry(state);
|
|
48
69
|
}
|
|
49
70
|
}
|
|
50
|
-
function writeBinding(state,
|
|
51
|
-
const entry = state.entries.get(
|
|
71
|
+
function writeBinding(state, host, item) {
|
|
72
|
+
const entry = state.entries.get(host);
|
|
52
73
|
if (entry === undefined) {
|
|
53
74
|
return;
|
|
54
75
|
}
|
|
55
76
|
entry.item = item;
|
|
56
77
|
notifyEntry(entry);
|
|
57
78
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
return cell instanceof Gtk.ListHeader ? cell.getItem() : null;
|
|
63
|
-
}
|
|
64
|
-
function bindCell(state, cell) {
|
|
65
|
-
if (cell.getChild() === null) {
|
|
66
|
-
cell.setChild(placeholder(state.size));
|
|
67
|
-
}
|
|
68
|
-
writeBinding(state, cell, boundItem(cell));
|
|
79
|
+
function bindHost(state, host) {
|
|
80
|
+
state.prepare?.(host, state.size);
|
|
81
|
+
writeBinding(state, host, host.getItem());
|
|
69
82
|
}
|
|
70
|
-
function
|
|
83
|
+
function subscribeRegistry(state, onChange) {
|
|
71
84
|
state.listeners.add(onChange);
|
|
72
85
|
return () => {
|
|
73
86
|
state.listeners.delete(onChange);
|
|
74
87
|
};
|
|
75
88
|
}
|
|
76
|
-
function
|
|
89
|
+
function getRegistryEntries(state) {
|
|
77
90
|
state.snapshot ??= state.entries.values().toArray();
|
|
78
91
|
return state.snapshot;
|
|
79
92
|
}
|
|
80
|
-
function guarded(
|
|
81
|
-
return (
|
|
82
|
-
if (
|
|
83
|
-
run(
|
|
93
|
+
function guarded(isHost, run) {
|
|
94
|
+
return (host) => {
|
|
95
|
+
if (isHost(host)) {
|
|
96
|
+
run(host);
|
|
84
97
|
}
|
|
85
98
|
};
|
|
86
99
|
}
|
|
87
|
-
function createHandlers(state
|
|
100
|
+
function createHandlers(state) {
|
|
101
|
+
const { isHost } = state;
|
|
88
102
|
return {
|
|
89
|
-
onSetup: guarded(
|
|
90
|
-
|
|
103
|
+
onSetup: guarded(isHost, (host) => {
|
|
104
|
+
setupHost(state, host);
|
|
91
105
|
}),
|
|
92
|
-
onBind: guarded(
|
|
93
|
-
|
|
106
|
+
onBind: guarded(isHost, (host) => {
|
|
107
|
+
bindHost(state, host);
|
|
94
108
|
}),
|
|
95
|
-
onUnbind: guarded(
|
|
96
|
-
writeBinding(state,
|
|
109
|
+
onUnbind: guarded(isHost, (host) => {
|
|
110
|
+
writeBinding(state, host, null);
|
|
97
111
|
}),
|
|
98
|
-
onTeardown: guarded(
|
|
99
|
-
|
|
112
|
+
onTeardown: guarded(isHost, (host) => {
|
|
113
|
+
teardownHost(state, host);
|
|
100
114
|
}),
|
|
101
115
|
};
|
|
102
116
|
}
|
|
103
|
-
function
|
|
117
|
+
function createCellRegistry(options, size) {
|
|
104
118
|
const state = {
|
|
119
|
+
...options,
|
|
105
120
|
size,
|
|
106
121
|
entries: new Map(),
|
|
107
122
|
snapshot: null,
|
|
108
123
|
listeners: new Set(),
|
|
109
124
|
serial: 0,
|
|
125
|
+
version: 0,
|
|
110
126
|
};
|
|
111
127
|
return {
|
|
112
|
-
handlers: createHandlers(state
|
|
128
|
+
handlers: createHandlers(state),
|
|
113
129
|
setSize: (next) => {
|
|
114
130
|
state.size = next;
|
|
115
131
|
},
|
|
116
|
-
subscribe: (onChange) =>
|
|
117
|
-
|
|
132
|
+
subscribe: (onChange) => subscribeRegistry(state, onChange),
|
|
133
|
+
getVersion: () => state.version,
|
|
134
|
+
getEntries: () => getRegistryEntries(state),
|
|
118
135
|
};
|
|
119
136
|
}
|
|
120
|
-
function
|
|
121
|
-
const [
|
|
137
|
+
function useCellRegistry(options, size) {
|
|
138
|
+
const [registry] = useState(() => createCellRegistry(options, size));
|
|
122
139
|
useLayoutEffect(() => {
|
|
123
|
-
|
|
140
|
+
registry.setSize(size);
|
|
124
141
|
});
|
|
125
|
-
return
|
|
142
|
+
return registry;
|
|
126
143
|
}
|
|
127
144
|
function useItemCells(size) {
|
|
128
|
-
return
|
|
145
|
+
return useCellRegistry(CELL_OPTIONS, size);
|
|
129
146
|
}
|
|
130
147
|
function useHeaderCells(size) {
|
|
131
|
-
return
|
|
148
|
+
return useCellRegistry(HEADER_OPTIONS, size);
|
|
132
149
|
}
|
|
133
150
|
function isRowWanted(options, item) {
|
|
134
|
-
|
|
135
|
-
return expandedIds == null ? options.isRowExpanded === true : expandedIds.includes(item.id);
|
|
151
|
+
return options.expandedIds?.includes(item.id) ?? false;
|
|
136
152
|
}
|
|
137
153
|
function itemArgs(item, options) {
|
|
138
154
|
const args = { item: item.value, index: options.position ?? 0 };
|
|
@@ -146,40 +162,115 @@ function itemArgs(item, options) {
|
|
|
146
162
|
}
|
|
147
163
|
return args;
|
|
148
164
|
}
|
|
149
|
-
function
|
|
165
|
+
function slotFor(options) {
|
|
166
|
+
const ref = slotRefFor(options.item);
|
|
167
|
+
const item = ref === null ? undefined : options.collection.itemAt(ref);
|
|
168
|
+
if (item === undefined) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return { item, row: options.row, args: itemArgs(item, options) };
|
|
172
|
+
}
|
|
173
|
+
function useItemSlot(entry, collection, expandedIds) {
|
|
174
|
+
const position = useProperty(entry.host, "position");
|
|
175
|
+
const item = useSyncExternalStore(entry.subscribe, entry.getItem);
|
|
176
|
+
const row = item instanceof Gtk.TreeListRow ? item : null;
|
|
177
|
+
return slotFor({ item, position, row, collection, expandedIds });
|
|
178
|
+
}
|
|
179
|
+
function expanderDescriptionFor(slot, descriptions) {
|
|
180
|
+
const { isExpanded } = slot.args;
|
|
181
|
+
if (isExpanded === undefined || descriptions == null) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
return isExpanded ? descriptions.collapse : descriptions.expand;
|
|
185
|
+
}
|
|
186
|
+
function wrapExpander(slot, content, descriptions) {
|
|
187
|
+
const { item, row } = slot;
|
|
150
188
|
const expander = row === null
|
|
151
189
|
? (content)
|
|
152
|
-
: (_jsx(GtkTreeExpander, { listRow: row, hideExpander: item.
|
|
190
|
+
: (_jsx(GtkTreeExpander, { listRow: row, hideExpander: item.shouldHideExpander ?? false, indentForDepth: item.shouldIndentForDepth ?? true, indentForIcon: item.shouldIndentForIcon ?? true, accessibleDescription: expanderDescriptionFor(slot, descriptions), children: content }));
|
|
153
191
|
return expander;
|
|
154
192
|
}
|
|
155
|
-
function itemBody(
|
|
156
|
-
|
|
157
|
-
const item = id === null ? undefined : options.collection.itemFor(id);
|
|
158
|
-
if (item === undefined) {
|
|
193
|
+
function itemBody(slot, render, descriptions) {
|
|
194
|
+
if (slot === null) {
|
|
159
195
|
return null;
|
|
160
196
|
}
|
|
161
|
-
const
|
|
162
|
-
return wrapExpander(
|
|
197
|
+
const renderItem = render;
|
|
198
|
+
return wrapExpander(slot, renderItem(slot.args), descriptions);
|
|
163
199
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
200
|
+
function rowText(value) {
|
|
201
|
+
return value ?? null;
|
|
202
|
+
}
|
|
203
|
+
/* eslint-disable-next-line unicorn/consistent-boolean-name -- reads the flag off a row, paired with rowText */
|
|
204
|
+
function rowFlag(value) {
|
|
205
|
+
return value ?? true;
|
|
206
|
+
}
|
|
207
|
+
function rowPropsFor(slot, rowProps) {
|
|
208
|
+
const resolve = rowProps;
|
|
209
|
+
const props = slot === null ? NO_ROW_PROPS : resolve(slot.args);
|
|
210
|
+
return {
|
|
211
|
+
accessibleLabel: rowText(props.accessibleLabel),
|
|
212
|
+
accessibleDescription: rowText(props.accessibleDescription),
|
|
213
|
+
isActivatable: rowFlag(props.isActivatable),
|
|
214
|
+
isFocusable: rowFlag(props.isFocusable),
|
|
215
|
+
isSelectable: rowFlag(props.isSelectable),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function setRowText(host, name, value) {
|
|
219
|
+
setObjectProperty(host, name, ROW_TEXT_DESCRIPTOR, value);
|
|
220
|
+
}
|
|
221
|
+
function applyRowProps(host, props) {
|
|
222
|
+
setRowText(host, "accessible-label", props.accessibleLabel);
|
|
223
|
+
setRowText(host, "accessible-description", props.accessibleDescription);
|
|
224
|
+
host.setActivatable(props.isActivatable);
|
|
225
|
+
host.setFocusable(props.isFocusable);
|
|
226
|
+
host.setSelectable(props.isSelectable);
|
|
227
|
+
}
|
|
228
|
+
function ItemCellImpl({ entry, render, collection, expandedIds, expanderDescriptions }) {
|
|
229
|
+
const slot = useItemSlot(entry, collection, expandedIds);
|
|
230
|
+
const body = itemBody(slot, render, expanderDescriptions);
|
|
231
|
+
return createPortal(body, entry.host, entry.key);
|
|
232
|
+
}
|
|
233
|
+
function ItemRowImpl({ entry, rowProps, collection, expandedIds }) {
|
|
234
|
+
const slot = useItemSlot(entry, collection, expandedIds);
|
|
235
|
+
const props = rowPropsFor(slot, rowProps);
|
|
236
|
+
useLayoutEffect(() => {
|
|
237
|
+
applyRowProps(entry.host, props);
|
|
238
|
+
});
|
|
239
|
+
return null;
|
|
171
240
|
}
|
|
172
241
|
function HeaderCellImpl({ entry, render, collection }) {
|
|
173
242
|
const item = useSyncExternalStore(entry.subscribe, entry.getItem);
|
|
174
|
-
const
|
|
243
|
+
const ref = slotRefFor(item);
|
|
175
244
|
const renderHeader = render;
|
|
176
|
-
const body =
|
|
177
|
-
return createPortal(body, entry.
|
|
245
|
+
const body = ref === null ? null : renderHeader({ section: collection.sectionFor(ref.store.level.path) });
|
|
246
|
+
return createPortal(body, entry.host, entry.key);
|
|
178
247
|
}
|
|
179
|
-
function usePortalEntries(
|
|
180
|
-
|
|
248
|
+
function usePortalEntries(registry) {
|
|
249
|
+
useSyncExternalStore(registry.subscribe, registry.getVersion);
|
|
250
|
+
return registry.getEntries();
|
|
181
251
|
}
|
|
182
|
-
const ItemPortals = ({
|
|
183
|
-
const
|
|
184
|
-
|
|
252
|
+
const ItemPortals = ({ registry, render, collection, expandedIds, expanderDescriptions, }) => usePortalEntries(registry).map((entry) => (_jsx(ItemCell, { entry: entry, render: render, collection: collection, expandedIds: expandedIds, expanderDescriptions: expanderDescriptions }, entry.key)));
|
|
253
|
+
const RowPortals = ({ registry, rowProps, collection, expandedIds }) => usePortalEntries(registry).map((entry) => (_jsx(ItemRow, { entry: entry, rowProps: rowProps, collection: collection, expandedIds: expandedIds }, entry.key)));
|
|
254
|
+
const HeaderPortals = ({ registry, render, collection }) => usePortalEntries(registry).map((entry) => (_jsx(HeaderCell, { entry: entry, render: render, collection: collection }, entry.key)));
|
|
255
|
+
const useSectionHeader = (render, collection, size) => {
|
|
256
|
+
const registry = useHeaderCells(size);
|
|
257
|
+
if (render == null) {
|
|
258
|
+
return { factoryProps: {}, portals: null };
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
factoryProps: { headerFactory: _jsx(GtkSignalListItemFactory, { ...registry.handlers }) },
|
|
262
|
+
portals: _jsx(HeaderPortals, { registry: registry, render: render, collection: collection }),
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
const useRowProps = (rowProps, collection, expandedIds) => {
|
|
266
|
+
const registry = useCellRegistry(ROW_OPTIONS, NO_SIZE);
|
|
267
|
+
if (rowProps == null) {
|
|
268
|
+
return { factoryProps: {}, portals: null };
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
factoryProps: { rowFactory: _jsx(GtkSignalListItemFactory, { ...registry.handlers }) },
|
|
272
|
+
portals: (_jsx(RowPortals, { registry: registry, rowProps: rowProps, collection: collection, expandedIds: expandedIds })),
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
export { useItemCells, useRowProps, useSectionHeader, ItemPortals, };
|
|
185
276
|
//# sourceMappingURL=cells.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cells.js","sourceRoot":"","sources":["../../src/internal/cells.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAG9E,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAiF9C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;AACpC,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;AAExC,MAAM,UAAU,GAAG,CAAC,KAAqB,EAAyB,EAAE,CAAC,KAAK,YAAY,GAAG,CAAC,QAAQ,CAAC;AACnG,MAAM,YAAY,GAAG,CAAC,KAAqB,EAA2B,EAAE,CAAC,KAAK,YAAY,GAAG,CAAC,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,CAAC,EAAE,CAAC,CAAC;IAEvF,OAAO,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,gBAAgB,CAAqB,KAAmB;IAC7D,OAAO,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAoB,EAAa,EAAE,CAC5F,gBAAgB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACnC,KAAC,QAAQ,IAAiB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,IAAzF,KAAK,CAAC,GAAG,CAAoF,CAC/G,CAAC,CAAC;AAEP,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAsB,EAAa,EAAE,CACnF,gBAAgB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACnC,KAAC,UAAU,IAAiB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,IAA/D,KAAK,CAAC,GAAG,CAA0D,CACvF,CAAC,CAAC;AAEP,OAAO,EACH,YAAY,EACZ,cAAc,EACd,WAAW,EACX,aAAa,GAGhB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { ReactNode } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkTreeExpander } from \"@gtkx/jsx/gtk\";\nimport { createPortal, useProperty } from \"@gtkx/react\";\nimport { memo, useLayoutEffect, useState, useSyncExternalStore } from \"react\";\nimport type { ListItem, ListItemRenderArgs, ListItemRenderer, ListSectionRenderer } from \"../types.js\";\nimport type { Collection } from \"./collection.js\";\nimport { getId } from \"./collection-model.js\";\n\ntype CellSize = {\n width: number;\n height: number;\n};\n\ntype CellHost = GObject.Object & {\n getChild: () => Gtk.Widget | null;\n setChild: (child: Gtk.Widget | null) => void;\n};\n\ntype CellEntry<C extends CellHost> = {\n key: string;\n cell: C;\n item: GObject.Object | null;\n listeners: Set<() => void>;\n subscribe: (onChange: () => void) => () => void;\n getItem: () => GObject.Object | null;\n};\n\ntype FactoryHandlers = {\n onSetup: (cell: GObject.Object) => void;\n onBind: (cell: GObject.Object) => void;\n onUnbind: (cell: GObject.Object) => void;\n onTeardown: (cell: GObject.Object) => void;\n};\n\ntype CellStore<C extends CellHost> = {\n handlers: FactoryHandlers;\n setSize: (size: CellSize) => void;\n subscribe: (onChange: () => void) => () => void;\n getSnapshot: () => CellEntry<C>[];\n};\n\ntype StoreState<C extends CellHost> = {\n size: CellSize;\n entries: Map<C, CellEntry<C>>;\n snapshot: CellEntry<C>[] | null;\n listeners: Set<() => void>;\n serial: number;\n};\n\ntype CellGuard<C extends CellHost> = (value: GObject.Object) => value is C;\n\ntype ItemBodyOptions = {\n item: GObject.Object | null;\n position: number | undefined;\n row: Gtk.TreeListRow | null;\n isRowExpanded: boolean | undefined;\n render: ListItemRenderer<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype ItemCellProps = {\n entry: CellEntry<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype ItemPortalsProps = {\n store: CellStore<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n collection: Collection;\n expandedIds?: string[] | null | undefined;\n};\n\ntype HeaderCellProps = {\n entry: CellEntry<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n collection: Collection;\n};\n\ntype HeaderPortalsProps = {\n store: CellStore<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n collection: Collection;\n};\n\nconst ItemCell = memo(ItemCellImpl);\nconst HeaderCell = memo(HeaderCellImpl);\n\nconst isListItem = (value: GObject.Object): value is Gtk.ListItem => value instanceof Gtk.ListItem;\nconst isListHeader = (value: GObject.Object): value is Gtk.ListHeader => value instanceof Gtk.ListHeader;\n\nconst placeholder = (size: CellSize): Gtk.Widget =>\n new Gtk.Box({ widthRequest: size.width, heightRequest: size.height });\n\nfunction notifyEntry<C extends CellHost>(entry: CellEntry<C>): void {\n for (const listener of entry.listeners) {\n listener();\n }\n}\n\nfunction notifyRoster<C extends CellHost>(state: StoreState<C>): void {\n state.snapshot = null;\n\n for (const listener of state.listeners) {\n listener();\n }\n}\n\nfunction createEntry<C extends CellHost>(state: StoreState<C>, cell: C): CellEntry<C> {\n state.serial += 1;\n\n const entry: CellEntry<C> = {\n key: `gtkx-cell-${String(state.serial)}`,\n cell,\n item: null,\n listeners: new Set(),\n subscribe: (onChange) => {\n entry.listeners.add(onChange);\n\n return () => {\n entry.listeners.delete(onChange);\n };\n },\n getItem: () => entry.item,\n };\n\n return entry;\n}\n\nfunction setupCell<C extends CellHost>(state: StoreState<C>, cell: C): void {\n cell.setChild(placeholder(state.size));\n state.entries.set(cell, createEntry(state, cell));\n notifyRoster(state);\n}\n\nfunction teardownCell<C extends CellHost>(state: StoreState<C>, cell: C): void {\n if (state.entries.delete(cell)) {\n notifyRoster(state);\n }\n}\n\nfunction writeBinding<C extends CellHost>(state: StoreState<C>, cell: C, item: GObject.Object | null): void {\n const entry = state.entries.get(cell);\n\n if (entry === undefined) {\n return;\n }\n\n entry.item = item;\n notifyEntry(entry);\n}\n\nfunction boundItem(cell: CellHost): GObject.Object | null {\n if (cell instanceof Gtk.ListItem) {\n return cell.getItem();\n }\n\n return cell instanceof Gtk.ListHeader ? cell.getItem() : null;\n}\n\nfunction bindCell<C extends CellHost>(state: StoreState<C>, cell: C): void {\n if (cell.getChild() === null) {\n cell.setChild(placeholder(state.size));\n }\n\n writeBinding(state, cell, boundItem(cell));\n}\n\nfunction subscribeRoster<C extends CellHost>(state: StoreState<C>, onChange: () => void): () => void {\n state.listeners.add(onChange);\n\n return () => {\n state.listeners.delete(onChange);\n };\n}\n\nfunction rosterSnapshot<C extends CellHost>(state: StoreState<C>): CellEntry<C>[] {\n state.snapshot ??= state.entries.values().toArray();\n\n return state.snapshot;\n}\n\nfunction guarded<C extends CellHost>(isCell: CellGuard<C>, run: (cell: C) => void): (cell: GObject.Object) => void {\n return (cell) => {\n if (isCell(cell)) {\n run(cell);\n }\n };\n}\n\nfunction createHandlers<C extends CellHost>(state: StoreState<C>, isCell: CellGuard<C>): FactoryHandlers {\n return {\n onSetup: guarded(isCell, (cell) => {\n setupCell(state, cell);\n }),\n onBind: guarded(isCell, (cell) => {\n bindCell(state, cell);\n }),\n onUnbind: guarded(isCell, (cell) => {\n writeBinding(state, cell, null);\n }),\n onTeardown: guarded(isCell, (cell) => {\n teardownCell(state, cell);\n }),\n };\n}\n\nfunction createCellStore<C extends CellHost>(isCell: CellGuard<C>, size: CellSize): CellStore<C> {\n const state: StoreState<C> = {\n size,\n entries: new Map(),\n snapshot: null,\n listeners: new Set(),\n serial: 0,\n };\n\n return {\n handlers: createHandlers(state, isCell),\n setSize: (next) => {\n state.size = next;\n },\n subscribe: (onChange) => subscribeRoster(state, onChange),\n getSnapshot: () => rosterSnapshot(state),\n };\n}\n\nfunction useCellStore<C extends CellHost>(isCell: CellGuard<C>, size: CellSize): CellStore<C> {\n const [store] = useState(() => createCellStore(isCell, size));\n\n useLayoutEffect(() => {\n store.setSize(size);\n });\n\n return store;\n}\n\nfunction useItemCells(size: CellSize): CellStore<Gtk.ListItem> {\n return useCellStore(isListItem, size);\n}\n\nfunction useHeaderCells(size: CellSize): CellStore<Gtk.ListHeader> {\n return useCellStore(isListHeader, size);\n}\n\nfunction isRowWanted(options: ItemBodyOptions, item: ListItem): boolean {\n const { expandedIds } = options;\n\n return expandedIds == null ? options.isRowExpanded === true : expandedIds.includes(item.id);\n}\n\nfunction itemArgs(item: ListItem, options: ItemBodyOptions): ListItemRenderArgs<unknown> {\n const args: ListItemRenderArgs<unknown> = { item: item.value, index: options.position ?? 0 };\n const row = options.row;\n\n if (row === null) {\n return args;\n }\n\n args.depth = row.getDepth();\n\n if (row.isExpandable()) {\n args.isExpanded = isRowWanted(options, item);\n }\n\n return args;\n}\n\nfunction wrapExpander(item: ListItem, row: Gtk.TreeListRow | null, content: ReactNode): ReactNode {\n const expander: ReactNode =\n row === null\n ? (\n content\n )\n : (\n <GtkTreeExpander\n listRow={row}\n hideExpander={item.hideExpander ?? false}\n indentForDepth={item.indentForDepth ?? true}\n indentForIcon={item.indentForIcon ?? true}\n >\n {content}\n </GtkTreeExpander>\n );\n\n return expander;\n}\n\nfunction itemBody(options: ItemBodyOptions): ReactNode {\n const id = getId(options.item);\n const item = id === null ? undefined : options.collection.itemFor(id);\n\n if (item === undefined) {\n return null;\n }\n\n const render = options.render as ListItemRenderer<unknown>;\n\n return wrapExpander(item, options.row, render(itemArgs(item, options)));\n}\n\nfunction ItemCellImpl({ entry, render, collection, expandedIds }: ItemCellProps): ReactNode {\n const item = useSyncExternalStore(entry.subscribe, entry.getItem);\n const position = useProperty(entry.cell, \"position\");\n const row = item instanceof Gtk.TreeListRow ? item : null;\n const isRowExpanded = useProperty(row, \"expanded\");\n const body = itemBody({ item, position, row, isRowExpanded, render, collection, expandedIds });\n\n return createPortal(body, entry.cell, entry.key);\n}\n\nfunction HeaderCellImpl({ entry, render, collection }: HeaderCellProps): ReactNode {\n const item = useSyncExternalStore(entry.subscribe, entry.getItem);\n const id = getId(item);\n const renderHeader = render as ListSectionRenderer<unknown>;\n const body = id === null ? null : renderHeader({ section: collection.sectionFor(id) });\n\n return createPortal(body, entry.cell, entry.key);\n}\n\nfunction usePortalEntries<C extends CellHost>(store: CellStore<C>): CellEntry<C>[] {\n return useSyncExternalStore(store.subscribe, store.getSnapshot);\n}\n\nconst ItemPortals = ({ store, render, collection, expandedIds }: ItemPortalsProps): ReactNode =>\n usePortalEntries(store).map((entry) => (\n <ItemCell key={entry.key} entry={entry} render={render} collection={collection} expandedIds={expandedIds} />\n ));\n\nconst HeaderPortals = ({ store, render, collection }: HeaderPortalsProps): ReactNode =>\n usePortalEntries(store).map((entry) => (\n <HeaderCell key={entry.key} entry={entry} render={render} collection={collection} />\n ));\n\nexport {\n useItemCells,\n useHeaderCells,\n ItemPortals,\n HeaderPortals,\n type CellSize,\n type CellStore,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"cells.js","sourceRoot":"","sources":["../../src/internal/cells.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAW9E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAoInD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;AACpC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;AAClC,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;AACxC,MAAM,YAAY,GAAsC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACrG,MAAM,cAAc,GAAwC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAC3G,MAAM,WAAW,GAA2C,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACxF,MAAM,OAAO,GAAa,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;AACpD,MAAM,YAAY,GAAiB,EAAE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E;QACjF,OAAO,EAAE,CACL,KAAC,UAAU,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAI,CAC3G;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EACH,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,WAAW,GAEd,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkSignalListItemFactory, GtkTreeExpander } from \"@gtkx/jsx/gtk\";\nimport { createPortal, useProperty } from \"@gtkx/react\";\nimport { setObjectProperty, t } from \"@gtkx/runtime\";\nimport { memo, useLayoutEffect, useState, useSyncExternalStore } from \"react\";\nimport type {\n ExpanderDescriptions,\n ListItem,\n ListItemRenderArgs,\n ListItemRenderer,\n ListRowProps,\n ListRowPropsResolver,\n ListSectionRenderer,\n} from \"../types.js\";\nimport type { Collection } from \"./collection.js\";\nimport { slotRefFor } from \"./collection-model.js\";\n\ntype CellSize = {\n width: number;\n height: number;\n};\n\ntype FactoryHost = GObject.Object & {\n getItem: () => GObject.Object | null;\n};\n\ntype CellHost = FactoryHost & {\n getChild: () => Gtk.Widget | null;\n setChild: (child: Gtk.Widget | null) => void;\n};\n\ntype CellEntry<H extends FactoryHost> = {\n key: string;\n host: H;\n item: GObject.Object | null;\n listeners: Set<() => void>;\n subscribe: (onChange: () => void) => () => void;\n getItem: () => GObject.Object | null;\n};\n\ntype FactoryHandlers = {\n onSetup: (host: GObject.Object) => void;\n onBind: (host: GObject.Object) => void;\n onUnbind: (host: GObject.Object) => void;\n onTeardown: (host: GObject.Object) => void;\n};\n\ntype CellRegistry<H extends FactoryHost> = {\n handlers: FactoryHandlers;\n setSize: (size: CellSize) => void;\n subscribe: (onChange: () => void) => () => void;\n getVersion: () => number;\n getEntries: () => CellEntry<H>[];\n};\n\ntype HostGuard<H extends FactoryHost> = (value: GObject.Object) => value is H;\n\ntype CellRegistryOptions<H extends FactoryHost> = {\n isHost: HostGuard<H>;\n prepare?: ((host: H, size: CellSize) => void) | undefined;\n};\n\ntype CellRegistryState<H extends FactoryHost> = CellRegistryOptions<H> & {\n size: CellSize;\n entries: Map<H, CellEntry<H>>;\n snapshot: CellEntry<H>[] | null;\n listeners: Set<() => void>;\n serial: number;\n version: number;\n};\n\ntype ResolvedRowProps = {\n accessibleLabel: string | null;\n accessibleDescription: string | null;\n isActivatable: boolean;\n isFocusable: boolean;\n isSelectable: boolean;\n};\n\ntype ItemSlotOptions = {\n item: GObject.Object | null;\n position: number | undefined;\n row: Gtk.TreeListRow | null;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype PositionedHost = Gtk.ListItem | Gtk.ColumnViewRow;\n\ntype ItemSlot = {\n item: ListItem;\n row: Gtk.TreeListRow | null;\n args: ListItemRenderArgs<unknown>;\n};\n\ntype ItemCellProps = {\n entry: CellEntry<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n expanderDescriptions: ExpanderDescriptions | null | undefined;\n};\n\ntype ItemPortalsProps = {\n registry: CellRegistry<Gtk.ListItem>;\n render: ListItemRenderer<never>;\n collection: Collection;\n expandedIds?: string[] | null | undefined;\n expanderDescriptions?: ExpanderDescriptions | null | undefined;\n};\n\ntype ItemRowProps = {\n entry: CellEntry<Gtk.ColumnViewRow>;\n rowProps: ListRowPropsResolver<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype RowPortalsProps = {\n registry: CellRegistry<Gtk.ColumnViewRow>;\n rowProps: ListRowPropsResolver<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n};\n\ntype HeaderCellProps = {\n entry: CellEntry<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n collection: Collection;\n};\n\ntype HeaderPortalsProps = {\n registry: CellRegistry<Gtk.ListHeader>;\n render: ListSectionRenderer<never>;\n collection: Collection;\n};\n\ntype SectionHeaderSlot = {\n factoryProps: { headerFactory?: ReactElement };\n portals: ReactNode;\n};\n\ntype RowSlot = {\n factoryProps: { rowFactory?: ReactElement };\n portals: ReactNode;\n};\n\nconst ItemCell = memo(ItemCellImpl);\nconst ItemRow = memo(ItemRowImpl);\nconst HeaderCell = memo(HeaderCellImpl);\nconst CELL_OPTIONS: CellRegistryOptions<Gtk.ListItem> = { isHost: isListItem, prepare: prepareCell };\nconst HEADER_OPTIONS: CellRegistryOptions<Gtk.ListHeader> = { isHost: isListHeader, prepare: prepareCell };\nconst ROW_OPTIONS: CellRegistryOptions<Gtk.ColumnViewRow> = { isHost: isColumnViewRow };\nconst NO_SIZE: CellSize = { width: -1, height: -1 };\nconst NO_ROW_PROPS: ListRowProps = {};\nconst ROW_TEXT_DESCRIPTOR = t.string(\"borrowed\");\n\nconst placeholder = (size: CellSize): Gtk.Widget =>\n new Gtk.Box({ widthRequest: size.width, heightRequest: size.height });\n\nfunction isListItem(value: GObject.Object): value is Gtk.ListItem {\n return value instanceof Gtk.ListItem;\n}\n\nfunction isListHeader(value: GObject.Object): value is Gtk.ListHeader {\n return value instanceof Gtk.ListHeader;\n}\n\nfunction isColumnViewRow(value: GObject.Object): value is Gtk.ColumnViewRow {\n return value instanceof Gtk.ColumnViewRow;\n}\n\nfunction prepareCell(host: CellHost, size: CellSize): void {\n if (host.getChild() === null) {\n host.setChild(placeholder(size));\n }\n}\n\nfunction notifyEntry<H extends FactoryHost>(entry: CellEntry<H>): void {\n for (const listener of entry.listeners) {\n listener();\n }\n}\n\nfunction notifyRegistry<H extends FactoryHost>(state: CellRegistryState<H>): void {\n state.snapshot = null;\n state.version += 1;\n\n for (const listener of state.listeners) {\n listener();\n }\n}\n\nfunction createEntry<H extends FactoryHost>(state: CellRegistryState<H>, host: H): CellEntry<H> {\n state.serial += 1;\n\n const entry: CellEntry<H> = {\n key: `gtkx-cell-${String(state.serial)}`,\n host,\n item: null,\n listeners: new Set(),\n subscribe: (onChange) => {\n entry.listeners.add(onChange);\n\n return () => {\n entry.listeners.delete(onChange);\n };\n },\n getItem: () => entry.item,\n };\n\n return entry;\n}\n\nfunction setupHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n state.prepare?.(host, state.size);\n state.entries.set(host, createEntry(state, host));\n notifyRegistry(state);\n}\n\nfunction teardownHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n if (state.entries.delete(host)) {\n notifyRegistry(state);\n }\n}\n\nfunction writeBinding<H extends FactoryHost>(state: CellRegistryState<H>, host: H, item: GObject.Object | null): void {\n const entry = state.entries.get(host);\n\n if (entry === undefined) {\n return;\n }\n\n entry.item = item;\n notifyEntry(entry);\n}\n\nfunction bindHost<H extends FactoryHost>(state: CellRegistryState<H>, host: H): void {\n state.prepare?.(host, state.size);\n writeBinding(state, host, host.getItem());\n}\n\nfunction subscribeRegistry<H extends FactoryHost>(state: CellRegistryState<H>, onChange: () => void): () => void {\n state.listeners.add(onChange);\n\n return () => {\n state.listeners.delete(onChange);\n };\n}\n\nfunction getRegistryEntries<H extends FactoryHost>(state: CellRegistryState<H>): CellEntry<H>[] {\n state.snapshot ??= state.entries.values().toArray();\n\n return state.snapshot;\n}\n\nfunction guarded<H extends FactoryHost>(isHost: HostGuard<H>, run: (host: H) => void): (host: GObject.Object) => void {\n return (host) => {\n if (isHost(host)) {\n run(host);\n }\n };\n}\n\nfunction createHandlers<H extends FactoryHost>(state: CellRegistryState<H>): FactoryHandlers {\n const { isHost } = state;\n\n return {\n onSetup: guarded(isHost, (host) => {\n setupHost(state, host);\n }),\n onBind: guarded(isHost, (host) => {\n bindHost(state, host);\n }),\n onUnbind: guarded(isHost, (host) => {\n writeBinding(state, host, null);\n }),\n onTeardown: guarded(isHost, (host) => {\n teardownHost(state, host);\n }),\n };\n}\n\nfunction createCellRegistry<H extends FactoryHost>(options: CellRegistryOptions<H>, size: CellSize): CellRegistry<H> {\n const state: CellRegistryState<H> = {\n ...options,\n size,\n entries: new Map(),\n snapshot: null,\n listeners: new Set(),\n serial: 0,\n version: 0,\n };\n\n return {\n handlers: createHandlers(state),\n setSize: (next) => {\n state.size = next;\n },\n subscribe: (onChange) => subscribeRegistry(state, onChange),\n getVersion: () => state.version,\n getEntries: () => getRegistryEntries(state),\n };\n}\n\nfunction useCellRegistry<H extends FactoryHost>(options: CellRegistryOptions<H>, size: CellSize): CellRegistry<H> {\n const [registry] = useState(() => createCellRegistry(options, size));\n\n useLayoutEffect(() => {\n registry.setSize(size);\n });\n\n return registry;\n}\n\nfunction useItemCells(size: CellSize): CellRegistry<Gtk.ListItem> {\n return useCellRegistry(CELL_OPTIONS, size);\n}\n\nfunction useHeaderCells(size: CellSize): CellRegistry<Gtk.ListHeader> {\n return useCellRegistry(HEADER_OPTIONS, size);\n}\n\nfunction isRowWanted(options: ItemSlotOptions, item: ListItem): boolean {\n return options.expandedIds?.includes(item.id) ?? false;\n}\n\nfunction itemArgs(item: ListItem, options: ItemSlotOptions): ListItemRenderArgs<unknown> {\n const args: ListItemRenderArgs<unknown> = { item: item.value, index: options.position ?? 0 };\n const row = options.row;\n\n if (row === null) {\n return args;\n }\n\n args.depth = row.getDepth();\n\n if (row.isExpandable()) {\n args.isExpanded = isRowWanted(options, item);\n }\n\n return args;\n}\n\nfunction slotFor(options: ItemSlotOptions): ItemSlot | null {\n const ref = slotRefFor(options.item);\n const item = ref === null ? undefined : options.collection.itemAt(ref);\n\n if (item === undefined) {\n return null;\n }\n\n return { item, row: options.row, args: itemArgs(item, options) };\n}\n\nfunction useItemSlot(\n entry: CellEntry<PositionedHost>,\n collection: Collection,\n expandedIds: string[] | null | undefined,\n): ItemSlot | null {\n const position = useProperty(entry.host, \"position\");\n const item = useSyncExternalStore(entry.subscribe, entry.getItem);\n const row = item instanceof Gtk.TreeListRow ? item : null;\n\n return slotFor({ item, position, row, collection, expandedIds });\n}\n\nfunction expanderDescriptionFor(\n slot: ItemSlot,\n descriptions: ExpanderDescriptions | null | undefined,\n): string | undefined {\n const { isExpanded } = slot.args;\n\n if (isExpanded === undefined || descriptions == null) {\n return undefined;\n }\n\n return isExpanded ? descriptions.collapse : descriptions.expand;\n}\n\nfunction wrapExpander(\n slot: ItemSlot,\n content: ReactNode,\n descriptions: ExpanderDescriptions | null | undefined,\n): ReactNode {\n const { item, row } = slot;\n\n const expander: ReactNode =\n row === null\n ? (\n content\n )\n : (\n <GtkTreeExpander\n listRow={row}\n hideExpander={item.shouldHideExpander ?? false}\n indentForDepth={item.shouldIndentForDepth ?? true}\n indentForIcon={item.shouldIndentForIcon ?? true}\n accessibleDescription={expanderDescriptionFor(slot, descriptions)}\n >\n {content}\n </GtkTreeExpander>\n );\n\n return expander;\n}\n\nfunction itemBody(\n slot: ItemSlot | null,\n render: ListItemRenderer<never>,\n descriptions: ExpanderDescriptions | null | undefined,\n): ReactNode {\n if (slot === null) {\n return null;\n }\n\n const renderItem = render as ListItemRenderer<unknown>;\n\n return wrapExpander(slot, renderItem(slot.args), descriptions);\n}\n\nfunction rowText(value: string | undefined): string | null {\n return value ?? null;\n}\n\n/* eslint-disable-next-line unicorn/consistent-boolean-name -- reads the flag off a row, paired with rowText */\nfunction rowFlag(value: boolean | undefined): boolean {\n return value ?? true;\n}\n\nfunction rowPropsFor(slot: ItemSlot | null, rowProps: ListRowPropsResolver<never>): ResolvedRowProps {\n const resolve = rowProps as ListRowPropsResolver<unknown>;\n const props = slot === null ? NO_ROW_PROPS : resolve(slot.args);\n\n return {\n accessibleLabel: rowText(props.accessibleLabel),\n accessibleDescription: rowText(props.accessibleDescription),\n isActivatable: rowFlag(props.isActivatable),\n isFocusable: rowFlag(props.isFocusable),\n isSelectable: rowFlag(props.isSelectable),\n };\n}\n\nfunction setRowText(host: Gtk.ColumnViewRow, name: string, value: string | null): void {\n setObjectProperty(host, name, ROW_TEXT_DESCRIPTOR, value);\n}\n\nfunction applyRowProps(host: Gtk.ColumnViewRow, props: ResolvedRowProps): void {\n setRowText(host, \"accessible-label\", props.accessibleLabel);\n setRowText(host, \"accessible-description\", props.accessibleDescription);\n host.setActivatable(props.isActivatable);\n host.setFocusable(props.isFocusable);\n host.setSelectable(props.isSelectable);\n}\n\nfunction ItemCellImpl({ entry, render, collection, expandedIds, expanderDescriptions }: ItemCellProps): ReactNode {\n const slot = useItemSlot(entry, collection, expandedIds);\n const body = itemBody(slot, render, expanderDescriptions);\n\n return createPortal(body, entry.host, entry.key);\n}\n\nfunction ItemRowImpl({ entry, rowProps, collection, expandedIds }: ItemRowProps): ReactNode {\n const slot = useItemSlot(entry, collection, expandedIds);\n const props = rowPropsFor(slot, rowProps);\n\n useLayoutEffect(() => {\n applyRowProps(entry.host, props);\n });\n\n return null;\n}\n\nfunction HeaderCellImpl({ entry, render, collection }: HeaderCellProps): ReactNode {\n const item = useSyncExternalStore(entry.subscribe, entry.getItem);\n const ref = slotRefFor(item);\n const renderHeader = render as ListSectionRenderer<unknown>;\n const body = ref === null ? null : renderHeader({ section: collection.sectionFor(ref.store.level.path) });\n\n return createPortal(body, entry.host, entry.key);\n}\n\nfunction usePortalEntries<H extends FactoryHost>(registry: CellRegistry<H>): CellEntry<H>[] {\n useSyncExternalStore(registry.subscribe, registry.getVersion);\n\n return registry.getEntries();\n}\n\nconst ItemPortals = ({\n registry,\n render,\n collection,\n expandedIds,\n expanderDescriptions,\n}: ItemPortalsProps): ReactNode =>\n usePortalEntries(registry).map((entry) => (\n <ItemCell\n key={entry.key}\n entry={entry}\n render={render}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n />\n ));\n\nconst RowPortals = ({ registry, rowProps, collection, expandedIds }: RowPortalsProps): ReactNode =>\n usePortalEntries(registry).map((entry) => (\n <ItemRow\n key={entry.key}\n entry={entry}\n rowProps={rowProps}\n collection={collection}\n expandedIds={expandedIds}\n />\n ));\n\nconst HeaderPortals = ({ registry, render, collection }: HeaderPortalsProps): ReactNode =>\n usePortalEntries(registry).map((entry) => (\n <HeaderCell key={entry.key} entry={entry} render={render} collection={collection} />\n ));\n\nconst useSectionHeader = (\n render: ListSectionRenderer<never> | null | undefined,\n collection: Collection,\n size: CellSize,\n): SectionHeaderSlot => {\n const registry = useHeaderCells(size);\n\n if (render == null) {\n return { factoryProps: {}, portals: null };\n }\n\n return {\n factoryProps: { headerFactory: <GtkSignalListItemFactory {...registry.handlers} /> },\n portals: <HeaderPortals registry={registry} render={render} collection={collection} />,\n };\n};\n\nconst useRowProps = (\n rowProps: ListRowPropsResolver<never> | null | undefined,\n collection: Collection,\n expandedIds: string[] | null | undefined,\n): RowSlot => {\n const registry = useCellRegistry(ROW_OPTIONS, NO_SIZE);\n\n if (rowProps == null) {\n return { factoryProps: {}, portals: null };\n }\n\n return {\n factoryProps: { rowFactory: <GtkSignalListItemFactory {...registry.handlers} /> },\n portals: (\n <RowPortals registry={registry} rowProps={rowProps} collection={collection} expandedIds={expandedIds} />\n ),\n };\n};\n\nexport {\n useItemCells,\n useRowProps,\n useSectionHeader,\n ItemPortals,\n type CellSize,\n};\n"]}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import type { ListItem, ListSection } from "../types.js";
|
|
2
2
|
type Level = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
path: string;
|
|
4
|
+
items: ListItem[];
|
|
5
5
|
expandableFlags: boolean[];
|
|
6
6
|
};
|
|
7
7
|
type CollectionIndex = {
|
|
8
8
|
isTree: boolean;
|
|
9
|
-
size: number;
|
|
10
9
|
groups: Level[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
sectionFor: (
|
|
15
|
-
positionFor: (id: string) => number;
|
|
10
|
+
childLevel: (level: Level, slot: number) => Level | undefined;
|
|
11
|
+
levelFor: (levelPath: string) => Level | undefined;
|
|
12
|
+
itemAt: (levelPath: string, slot: number) => ListItem | undefined;
|
|
13
|
+
sectionFor: (levelPath: string) => unknown;
|
|
16
14
|
};
|
|
17
|
-
declare const
|
|
18
|
-
declare const childLevelKey: (id: string) => string;
|
|
15
|
+
declare const emptyLevel: () => Level;
|
|
19
16
|
declare function createCollectionIndex(items: ListItem[] | undefined, sections: ListSection[] | undefined, isFlat: boolean): CollectionIndex;
|
|
20
|
-
export { createCollectionIndex,
|
|
17
|
+
export { createCollectionIndex, emptyLevel, type CollectionIndex, type Level };
|
|
21
18
|
//# sourceMappingURL=collection-index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-index.d.ts","sourceRoot":"","sources":["../../src/internal/collection-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"collection-index.d.ts","sourceRoot":"","sources":["../../src/internal/collection-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzD,KAAK,KAAK,GAAG;IACT,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,eAAe,EAAE,OAAO,EAAE,CAAC;CAC9B,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,GAAG,SAAS,CAAC;IAC9D,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,KAAK,GAAG,SAAS,CAAC;IACnD,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,CAAC;IAClE,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C,CAAC;AAWF,QAAA,MAAM,UAAU,QAAO,KAAuD,CAAC;AA0F/E,iBAAS,qBAAqB,CAC1B,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAC7B,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,EACnC,MAAM,EAAE,OAAO,GAChB,eAAe,CAoBjB;AAED,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,CAAC"}
|