@gtkx/components 2.0.0-beta.10 → 2.0.0-beta.11
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 +8 -168
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +19 -9
- package/dist/column-view.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/cells.d.ts +8 -1
- package/dist/internal/cells.d.ts.map +1 -1
- package/dist/internal/cells.js +84 -19
- package/dist/internal/cells.js.map +1 -1
- package/dist/internal/collection-index.d.ts +3 -2
- package/dist/internal/collection-index.d.ts.map +1 -1
- package/dist/internal/collection-index.js +3 -3
- package/dist/internal/collection-index.js.map +1 -1
- package/dist/internal/collection-model.d.ts +23 -2
- package/dist/internal/collection-model.d.ts.map +1 -1
- package/dist/internal/collection-model.js +118 -98
- package/dist/internal/collection-model.js.map +1 -1
- package/dist/internal/collection.d.ts +5 -4
- package/dist/internal/collection.d.ts.map +1 -1
- package/dist/internal/collection.js +20 -21
- package/dist/internal/collection.js.map +1 -1
- package/dist/internal/controlled-sync.d.ts +6 -8
- package/dist/internal/controlled-sync.d.ts.map +1 -1
- package/dist/internal/controlled-sync.js +3 -3
- package/dist/internal/controlled-sync.js.map +1 -1
- package/dist/internal/drop-down.d.ts.map +1 -1
- package/dist/internal/drop-down.js +43 -44
- package/dist/internal/drop-down.js.map +1 -1
- package/dist/internal/expansion.js +4 -4
- package/dist/internal/expansion.js.map +1 -1
- package/dist/internal/selection.d.ts +1 -0
- package/dist/internal/selection.d.ts.map +1 -1
- package/dist/internal/selection.js +6 -6
- package/dist/internal/selection.js.map +1 -1
- package/dist/internal/tree-expansion.d.ts.map +1 -1
- package/dist/internal/tree-expansion.js +2 -11
- package/dist/internal/tree-expansion.js.map +1 -1
- package/dist/internal/tree-order.d.ts.map +1 -1
- package/dist/internal/tree-order.js +32 -76
- package/dist/internal/tree-order.js.map +1 -1
- package/dist/internal/use-collection.d.ts +5 -1
- package/dist/internal/use-collection.d.ts.map +1 -1
- package/dist/internal/use-collection.js +21 -7
- package/dist/internal/use-collection.js.map +1 -1
- package/dist/list-item-factory.d.ts +10 -0
- package/dist/list-item-factory.d.ts.map +1 -0
- package/dist/list-item-factory.js +14 -0
- package/dist/list-item-factory.js.map +1 -0
- package/dist/toast.d.ts +3 -5
- package/dist/toast.d.ts.map +1 -1
- package/dist/toast.js +3 -12
- package/dist/toast.js.map +1 -1
- package/dist/types.d.ts +33 -50
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +12 -10
- package/src/column-view.tsx +23 -12
- package/src/index.ts +3 -2
- package/src/internal/cells.tsx +137 -20
- package/src/internal/collection-index.ts +8 -6
- package/src/internal/collection-model.ts +156 -134
- package/src/internal/collection.ts +28 -24
- package/src/internal/controlled-sync.ts +9 -12
- package/src/internal/drop-down.tsx +64 -60
- package/src/internal/expansion.ts +4 -4
- package/src/internal/selection.tsx +8 -8
- package/src/internal/tree-expansion.ts +2 -14
- package/src/internal/tree-order.ts +33 -121
- package/src/internal/use-collection.tsx +29 -8
- package/src/list-item-factory.tsx +27 -0
- package/src/toast.tsx +4 -18
- package/src/types.ts +35 -51
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-order.js","sourceRoot":"","sources":["../../src/internal/tree-order.ts"],"names":[],"mappings":"AA2DA,MAAM,OAAO,GAAa,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAEvD,SAAS,YAAY,CACjB,KAAU,EACV,MAAwC,EACxC,OAA4B;IAE5B,MAAM,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO;IACX,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KA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AAO;YACX,CAAC;YAED,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACrC,CAAC;AAED,SAAS,OAAO,CAAC,KAAsB,EAAE,KAAc,EAAE,SAAsB;IAC3E,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,WAAW,CAAC;QACR,KAAK;QACL,KAAK;QACL,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC/B,OAAO;YACX,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,OAAO,EACH,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,WAAW,GAId,CAAC","sourcesContent":["import type { ListItem } from \"../types.js\";\nimport type { CollectionIndex, Level } from \"./collection-index.js\";\nimport type { SlotMap } from \"./slots.js\";\n\ntype VisibleRow = {\n item: ListItem;\n position: number;\n isOpen: boolean;\n isMarked: boolean;\n};\n\ntype VisibleOrder = {\n expandedPaths: string[];\n expandedIds: string[];\n};\n\ntype MatchedRows = {\n positions: number[];\n ids: string[];\n};\n\ntype RowVisitor = (row: VisibleRow) => void;\n\ntype WalkOptions = {\n index: CollectionIndex;\n slots: SlotMap;\n marks?: SlotMap | undefined;\n visit?: RowVisitor | undefined;\n};\n\ntype LevelFrame = {\n level: Level;\n cursor: number;\n};\n\ntype WalkFrame = LevelFrame & {\n open: Set<number> | undefined;\n marked: Set<number> | undefined;\n};\n\ntype WalkState = {\n options: WalkOptions;\n stack: WalkFrame[];\n row: VisibleRow;\n order: VisibleOrder;\n};\n\ntype OpenFrame = LevelFrame & {\n owner: ListItem | null;\n};\n\ntype OpenWalk = {\n index: CollectionIndex;\n ids: Set<string>;\n paths: Set<string>;\n stack: OpenFrame[];\n ancestors: Set<ListItem>;\n};\n\nconst NO_ITEM: ListItem = { id: \"\", value: undefined };\n\nfunction advanceStack<F extends LevelFrame>(\n stack: F[],\n onSlot: (frame: F, slot: number) => void,\n onLeave?: (frame: F) => void,\n): void {\n const frame = stack.at(-1);\n\n if (frame === undefined) {\n return;\n }\n\n if (frame.cursor >= frame.level.items.length) {\n stack.pop();\n onLeave?.(frame);\n\n return;\n }\n\n const slot = frame.cursor;\n frame.cursor += 1;\n onSlot(frame, slot);\n}\n\nfunction frameFor(options: WalkOptions, level: Level): WalkFrame {\n return { level, cursor: 0, open: options.slots.get(level.path), marked: options.marks?.get(level.path) };\n}\n\nfunction descend(state: WalkState, level: Level, slot: number): void {\n const child = state.options.index.childLevel(level, slot);\n\n if (child === undefined) {\n return;\n }\n\n state.order.expandedPaths.push(child.path);\n state.order.expandedIds.push(state.row.item.id);\n state.stack.push(frameFor(state.options, child));\n}\n\nfunction visitSlot(state: WalkState, frame: WalkFrame, slot: number): void {\n const item = frame.level.items[slot];\n\n if (item === undefined) {\n return;\n }\n\n const { row } = state;\n row.item = item;\n row.isOpen = frame.open?.has(slot) ?? false;\n row.isMarked = frame.marked?.has(slot) ?? false;\n state.options.visit?.(row);\n row.position += 1;\n\n if (row.isOpen) {\n descend(state, frame.level, slot);\n }\n}\n\nfunction walkVisible(options: WalkOptions): VisibleOrder {\n const order: VisibleOrder = { expandedPaths: [], expandedIds: [] };\n const row: VisibleRow = { item: NO_ITEM, position: 0, isOpen: false, isMarked: false };\n const frames = options.index.groups.map((level) => frameFor(options, level));\n const state: WalkState = { options, stack: frames.toReversed(), row, order };\n\n const onSlot = (frame: WalkFrame, slot: number): void => {\n visitSlot(state, frame, slot);\n };\n\n while (state.stack.length > 0) {\n advanceStack(state.stack, onSlot);\n }\n\n return order;\n}\n\nfunction openSlot(walk: OpenWalk, frame: OpenFrame, slot: number): void {\n const item = frame.level.items[slot];\n\n if (item === undefined || !walk.ids.has(item.id) || walk.ancestors.has(item)) {\n return;\n }\n\n const child = walk.index.childLevel(frame.level, slot);\n\n if (child === undefined) {\n return;\n }\n\n walk.paths.add(child.path);\n walk.ancestors.add(item);\n walk.stack.push({ level: child, cursor: 0, owner: item });\n}\n\nfunction leaveOpenFrame(walk: OpenWalk, frame: OpenFrame): void {\n if (frame.owner !== null) {\n walk.ancestors.delete(frame.owner);\n }\n}\n\nfunction expandedPathsFor(index: CollectionIndex, ids: Set<string>): Set<string> {\n const paths: Set<string> = new Set();\n\n if (ids.size === 0 || !index.isTree) {\n return paths;\n }\n\n const frames = index.groups.map((level) => ({ level, cursor: 0, owner: null }));\n const walk: OpenWalk = { index, ids, paths, stack: frames.toReversed(), ancestors: new Set() };\n\n const onSlot = (frame: OpenFrame, slot: number): void => {\n openSlot(walk, frame, slot);\n };\n\n const onLeave = (frame: OpenFrame): void => {\n leaveOpenFrame(walk, frame);\n };\n\n while (walk.stack.length > 0) {\n advanceStack(walk.stack, onSlot, onLeave);\n }\n\n return paths;\n}\n\nfunction findRows(index: CollectionIndex, slots: SlotMap, ids: Set<string>): MatchedRows {\n const positions: number[] = [];\n const found: string[] = [];\n\n walkVisible({\n index,\n slots,\n visit: (row) => {\n if (!ids.has(row.item.id)) {\n return;\n }\n\n positions.push(row.position);\n found.push(row.item.id);\n },\n });\n\n return { positions, ids: found };\n}\n\nfunction findIds(index: CollectionIndex, slots: SlotMap, positions: Set<number>): string[] {\n const found: string[] = [];\n\n walkVisible({\n index,\n slots,\n visit: (row) => {\n if (!positions.has(row.position)) {\n return;\n }\n\n found.push(row.item.id);\n },\n });\n\n return found;\n}\n\nexport {\n expandedPathsFor,\n findIds,\n findRows,\n walkVisible,\n type MatchedRows,\n type VisibleOrder,\n type WalkOptions,\n};\n"]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C;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAsB,EAAE,KAAc,EAAE,GAAgB;IACtE,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,WAAW,CAAC;QACR,KAAK;QACL,KAAK;QACL,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxB,OAAO;YACX,CAAC;YAED,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACrC,CAAC;AAED,SAAS,OAAO,CAAC,KAAsB,EAAE,KAAc,EAAE,SAAsB;IAC3E,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,WAAW,CAAC;QACR,KAAK;QACL,KAAK;QACL,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC/B,OAAO;YACX,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,OAAO,EACH,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,WAAW,GAId,CAAC","sourcesContent":["import type { ListItem } from \"../types.js\";\nimport type { CollectionIndex, Level } from \"./collection-index.js\";\nimport type { SlotMap } from \"./slots.js\";\n\ntype VisibleRow = {\n item: ListItem;\n position: number;\n isOpen: boolean;\n isMarked: boolean;\n};\n\ntype VisibleOrder = {\n expandedPaths: string[];\n expandedIds: string[];\n};\n\ntype MatchedRows = {\n positions: number[];\n ids: string[];\n};\n\ntype RowVisitor = (row: VisibleRow) => void;\n\ntype WalkOptions = {\n index: CollectionIndex;\n slots: SlotMap;\n marks?: SlotMap | undefined;\n visit?: RowVisitor | undefined;\n};\n\ntype WalkState = {\n position: number;\n order: VisibleOrder;\n};\n\nfunction walkLevel(options: WalkOptions, level: Level, state: WalkState): void {\n const open = options.slots.get(level.path);\n const marked = options.marks?.get(level.path);\n\n for (const [slot, item] of level.items.entries()) {\n const isOpen = open?.has(slot) ?? false;\n options.visit?.({ item, position: state.position, isOpen, isMarked: marked?.has(slot) ?? false });\n state.position += 1;\n\n if (!isOpen) {\n continue;\n }\n\n const child = options.index.childLevel(level, slot);\n\n if (child !== undefined) {\n state.order.expandedPaths.push(child.path);\n state.order.expandedIds.push(item.id);\n walkLevel(options, child, state);\n }\n }\n}\n\nfunction walkVisible(options: WalkOptions): VisibleOrder {\n const state: WalkState = { position: 0, order: { expandedPaths: [], expandedIds: [] } };\n\n for (const level of options.index.groups) {\n walkLevel(options, level, state);\n }\n\n return state.order;\n}\n\nfunction expandLevel(index: CollectionIndex, level: Level, ids: Set<string>, paths: Set<string>): void {\n for (const [slot, item] of level.items.entries()) {\n if (!ids.has(item.id)) {\n continue;\n }\n\n const child = index.childLevel(level, slot);\n\n if (child !== undefined) {\n paths.add(child.path);\n expandLevel(index, child, ids, paths);\n }\n }\n}\n\nfunction expandedPathsFor(index: CollectionIndex, ids: Set<string>): Set<string> {\n const paths: Set<string> = new Set();\n\n if (ids.size === 0 || !index.isTree) {\n return paths;\n }\n\n for (const level of index.groups) {\n expandLevel(index, level, ids, paths);\n }\n\n return paths;\n}\n\nfunction findRows(index: CollectionIndex, slots: SlotMap, ids: Set<string>): MatchedRows {\n const positions: number[] = [];\n const found: string[] = [];\n\n walkVisible({\n index,\n slots,\n visit: (row) => {\n if (!ids.has(row.item.id)) {\n return;\n }\n\n positions.push(row.position);\n found.push(row.item.id);\n },\n });\n\n return { positions, ids: found };\n}\n\nfunction findIds(index: CollectionIndex, slots: SlotMap, positions: Set<number>): string[] {\n const found: string[] = [];\n\n walkVisible({\n index,\n slots,\n visit: (row) => {\n if (!positions.has(row.position)) {\n return;\n }\n\n found.push(row.item.id);\n },\n });\n\n return found;\n}\n\nexport {\n expandedPathsFor,\n findIds,\n findRows,\n walkVisible,\n type MatchedRows,\n type VisibleOrder,\n type WalkOptions,\n};\n"]}
|
|
@@ -11,7 +11,11 @@ type CollectionResult = {
|
|
|
11
11
|
collection: Collection;
|
|
12
12
|
selection: ReactElement;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type CollectionDataResult = {
|
|
15
|
+
collection: Collection;
|
|
16
|
+
model: ReactElement;
|
|
17
|
+
};
|
|
18
|
+
declare function useCollectionData(options: CollectionDataOptions): CollectionDataResult;
|
|
15
19
|
declare function useCollection(options: CollectionOptions): CollectionResult;
|
|
16
20
|
export { useCollection, useCollectionData };
|
|
17
21
|
//# sourceMappingURL=use-collection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../src/internal/use-collection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../src/internal/use-collection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAOlD,KAAK,qBAAqB,GAAG;IACzB,KAAK,CAAC,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,KAAK,iBAAiB,GAAG,qBAAqB,GAAG,cAAc,GAAG,cAAc,CAAC;AAEjF,KAAK,gBAAgB,GAAG;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,iBAAS,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CAwB/E;AAED,iBAAS,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAmBnE;AAED,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GtkFlattenListModel } from "@gtkx/jsx/gtk";
|
|
1
3
|
import { useLayoutEffect, useMemo, useState } from "react";
|
|
2
4
|
import { createCollectionIndex } from "./collection-index.js";
|
|
3
|
-
import { createCollectionModel } from "./collection-model.js";
|
|
5
|
+
import { CollectionRoot, createCollectionModel } from "./collection-model.js";
|
|
4
6
|
import { createCollection } from "./collection.js";
|
|
5
7
|
import { useExpansion } from "./expansion.js";
|
|
6
8
|
import { useSelection } from "./selection.js";
|
|
7
9
|
function useCollectionData(options) {
|
|
8
10
|
const { items, sections, isFlat } = options;
|
|
9
|
-
const [
|
|
11
|
+
const [gtkModel] = useState(createCollectionModel);
|
|
12
|
+
const [root, setRoot] = useState(null);
|
|
13
|
+
const [model, setModel] = useState(null);
|
|
10
14
|
const index = useMemo(() => createCollectionIndex(items, sections, isFlat === true), [items, sections, isFlat]);
|
|
11
|
-
const collection = useMemo(() => createCollection(
|
|
15
|
+
const collection = useMemo(() => createCollection(gtkModel, index, model), [gtkModel, index, model]);
|
|
12
16
|
useLayoutEffect(() => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
if (root !== null && model !== null) {
|
|
18
|
+
gtkModel.bind(root, model);
|
|
19
|
+
}
|
|
20
|
+
return gtkModel.clear;
|
|
21
|
+
}, [gtkModel, root, model]);
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
gtkModel.sync(index);
|
|
24
|
+
}, [gtkModel, index, root, model]);
|
|
25
|
+
return {
|
|
26
|
+
collection,
|
|
27
|
+
model: _jsx(GtkFlattenListModel, { ref: setModel, model: _jsx(CollectionRoot, { ref: setRoot }) }),
|
|
28
|
+
};
|
|
16
29
|
}
|
|
17
30
|
function useCollection(options) {
|
|
18
|
-
const collection = useCollectionData(options);
|
|
31
|
+
const { collection, model } = useCollectionData(options);
|
|
19
32
|
const onItemsChanged = useExpansion({
|
|
20
33
|
collection,
|
|
21
34
|
expandedIds: options.expandedIds,
|
|
@@ -23,6 +36,7 @@ function useCollection(options) {
|
|
|
23
36
|
});
|
|
24
37
|
const selection = useSelection({
|
|
25
38
|
collection,
|
|
39
|
+
model,
|
|
26
40
|
selectedIds: options.selectedIds,
|
|
27
41
|
onSelectionChanged: options.onSelectionChanged,
|
|
28
42
|
selectionMode: options.selectionMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-collection.js","sourceRoot":"","sources":["../../src/internal/use-collection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-collection.js","sourceRoot":"","sources":["../../src/internal/use-collection.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAA4B,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,MAAM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KAAK,CAAC,CAAC,CAAC;IAEnC,OAAO;QACH,UAAU;QACV,KAAK,EAAE,KAAC,mBAAmB,IAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAC,cAAc,IAAC,GAAG,EAAE,OAAO,GAAI,GAAI;KACzF,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,OAA0B;IAC7C,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEzD,MAAM,cAAc,GAAG,YAAY,CAAC;QAChC,UAAU;QACV,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;KAC7C,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,YAAY,CAAC;QAC3B,UAAU;QACV,KAAK;QACL,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,cAAc;KACjB,CAAC,CAAC;IAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AACrC,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ReactElement } from \"react\";\nimport { GtkFlattenListModel } from \"@gtkx/jsx/gtk\";\nimport { useLayoutEffect, useMemo, useState } from \"react\";\nimport type { ExpansionProps, ListItem, ListSection, SelectionProps } from \"../types.js\";\nimport type { Collection } from \"./collection.js\";\nimport { createCollectionIndex } from \"./collection-index.js\";\nimport { CollectionRoot, type CollectionRootStore, createCollectionModel } from \"./collection-model.js\";\nimport { createCollection } from \"./collection.js\";\nimport { useExpansion } from \"./expansion.js\";\nimport { useSelection } from \"./selection.js\";\n\ntype CollectionDataOptions = {\n items?: ListItem[] | undefined;\n sections?: ListSection[] | undefined;\n isFlat?: boolean | undefined;\n};\n\ntype CollectionOptions = CollectionDataOptions & SelectionProps & ExpansionProps;\n\ntype CollectionResult = {\n collection: Collection;\n selection: ReactElement;\n};\n\ntype CollectionDataResult = {\n collection: Collection;\n model: ReactElement;\n};\n\nfunction useCollectionData(options: CollectionDataOptions): CollectionDataResult {\n const { items, sections, isFlat } = options;\n const [gtkModel] = useState(createCollectionModel);\n const [root, setRoot] = useState<CollectionRootStore | null>(null);\n const [model, setModel] = useState<Gtk.FlattenListModel | null>(null);\n const index = useMemo(() => createCollectionIndex(items, sections, isFlat === true), [items, sections, isFlat]);\n const collection = useMemo(() => createCollection(gtkModel, index, model), [gtkModel, index, model]);\n\n useLayoutEffect(() => {\n if (root !== null && model !== null) {\n gtkModel.bind(root, model);\n }\n\n return gtkModel.clear;\n }, [gtkModel, root, model]);\n\n useLayoutEffect(() => {\n gtkModel.sync(index);\n }, [gtkModel, index, root, model]);\n\n return {\n collection,\n model: <GtkFlattenListModel ref={setModel} model={<CollectionRoot ref={setRoot} />} />,\n };\n}\n\nfunction useCollection(options: CollectionOptions): CollectionResult {\n const { collection, model } = useCollectionData(options);\n\n const onItemsChanged = useExpansion({\n collection,\n expandedIds: options.expandedIds,\n onExpandedChange: options.onExpandedChange,\n });\n\n const selection = useSelection({\n collection,\n model,\n selectedIds: options.selectedIds,\n onSelectionChanged: options.onSelectionChanged,\n selectionMode: options.selectionMode,\n onItemsChanged,\n });\n\n return { collection, selection };\n}\n\nexport { useCollection, useCollectionData };\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { ListItemFactoryProps } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Gtk.SignalListItemFactory that renders objects from an existing native model with React.
|
|
6
|
+
* Estimated dimensions keep cells stable until their content mounts.
|
|
7
|
+
*/
|
|
8
|
+
declare function ListItemFactory<T extends GObject.Object>({ renderItem, estimatedItemHeight, estimatedItemWidth, }: ListItemFactoryProps<T>): ReactNode;
|
|
9
|
+
export { ListItemFactory };
|
|
10
|
+
//# sourceMappingURL=list-item-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-item-factory.d.ts","sourceRoot":"","sources":["../src/list-item-factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;GAGG;AACH,iBAAS,eAAe,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,EAC/C,UAAU,EACV,mBAAwB,EACxB,kBAAuB,GAC1B,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,SAAS,CAUrC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GtkSignalListItemFactory } from "@gtkx/jsx/gtk";
|
|
3
|
+
import { NativeItemPortals, useItemCells } from "./internal/cells.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Gtk.SignalListItemFactory that renders objects from an existing native model with React.
|
|
6
|
+
* Estimated dimensions keep cells stable until their content mounts.
|
|
7
|
+
*/
|
|
8
|
+
function ListItemFactory({ renderItem, estimatedItemHeight = -1, estimatedItemWidth = -1, }) {
|
|
9
|
+
const size = { width: estimatedItemWidth, height: estimatedItemHeight };
|
|
10
|
+
const cells = useItemCells(size);
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(GtkSignalListItemFactory, { ...cells.handlers }), _jsx(NativeItemPortals, { registry: cells, render: renderItem, size: size })] }));
|
|
12
|
+
}
|
|
13
|
+
export { ListItemFactory };
|
|
14
|
+
//# sourceMappingURL=list-item-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-item-factory.js","sourceRoot":"","sources":["../src/list-item-factory.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEtE;;;GAGG;AACH,SAAS,eAAe,CAA2B,EAC/C,UAAU,EACV,mBAAmB,GAAG,CAAC,CAAC,EACxB,kBAAkB,GAAG,CAAC,CAAC,GACD;IACtB,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;IACxE,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAEjC,OAAO,CACH,8BACI,KAAC,wBAAwB,OAAK,KAAK,CAAC,QAAQ,GAAI,EAChD,KAAC,iBAAiB,IAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAI,IACvE,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { ReactNode } from \"react\";\nimport { GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport type { ListItemFactoryProps } from \"./types.js\";\nimport { NativeItemPortals, useItemCells } from \"./internal/cells.js\";\n\n/**\n * Creates a Gtk.SignalListItemFactory that renders objects from an existing native model with React.\n * Estimated dimensions keep cells stable until their content mounts.\n */\nfunction ListItemFactory<T extends GObject.Object>({\n renderItem,\n estimatedItemHeight = -1,\n estimatedItemWidth = -1,\n}: ListItemFactoryProps<T>): ReactNode {\n const size = { width: estimatedItemWidth, height: estimatedItemHeight };\n const cells = useItemCells(size);\n\n return (\n <>\n <GtkSignalListItemFactory {...cells.handlers} />\n <NativeItemPortals registry={cells} render={renderItem} size={size} />\n </>\n );\n}\n\nexport { ListItemFactory };\n"]}
|
package/dist/toast.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { ToastController,
|
|
3
|
-
/** Shares an Adw.ToastOverlay reference with
|
|
2
|
+
import type { ToastController, ToastProviderProps } from "./types.js";
|
|
3
|
+
/** Shares an Adw.ToastOverlay reference with useToast in every descendant. */
|
|
4
4
|
declare function ToastProvider(props: ToastProviderProps): ReactNode;
|
|
5
5
|
/** Returns a {@link ToastController} that shows and dismisses toasts on the nearest provider's overlay. */
|
|
6
6
|
declare function useToast(): ToastController;
|
|
7
|
-
|
|
8
|
-
declare function useToastOverlay(): ToastOverlayController;
|
|
9
|
-
export { ToastProvider, useToast, useToastOverlay };
|
|
7
|
+
export { ToastProvider, useToast };
|
|
10
8
|
//# sourceMappingURL=toast.d.ts.map
|
package/dist/toast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../src/toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAGlD,OAAO,KAAK,EAAE,eAAe,EAAgB,
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../src/toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAGlD,OAAO,KAAK,EAAE,eAAe,EAAgB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAmCpF,8EAA8E;AAC9E,iBAAS,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAE3D;AAED,2GAA2G;AAC3G,iBAAS,QAAQ,IAAI,eAAe,CAiBnC;AAED,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/toast.js
CHANGED
|
@@ -5,7 +5,7 @@ const ToastContext = createContext(null);
|
|
|
5
5
|
const useOverlayRef = () => {
|
|
6
6
|
const overlayRef = useContext(ToastContext);
|
|
7
7
|
if (overlayRef === null) {
|
|
8
|
-
throw new Error("useToast
|
|
8
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
9
9
|
}
|
|
10
10
|
return overlayRef;
|
|
11
11
|
};
|
|
@@ -24,7 +24,7 @@ const buildToast = (options) => {
|
|
|
24
24
|
}
|
|
25
25
|
return toast;
|
|
26
26
|
};
|
|
27
|
-
/** Shares an Adw.ToastOverlay reference with
|
|
27
|
+
/** Shares an Adw.ToastOverlay reference with useToast in every descendant. */
|
|
28
28
|
function ToastProvider(props) {
|
|
29
29
|
return _jsx(ToastContext.Provider, { value: props.overlayRef, children: props.children });
|
|
30
30
|
}
|
|
@@ -37,19 +37,10 @@ function useToast() {
|
|
|
37
37
|
overlayRef.current?.addToast(toast);
|
|
38
38
|
return toast;
|
|
39
39
|
},
|
|
40
|
-
dismiss: (toast) => {
|
|
41
|
-
toast.dismiss();
|
|
42
|
-
},
|
|
43
|
-
}), [overlayRef]);
|
|
44
|
-
}
|
|
45
|
-
/** Returns a {@link ToastOverlayController} for the nearest provider's overlay as a whole. */
|
|
46
|
-
function useToastOverlay() {
|
|
47
|
-
const overlayRef = useOverlayRef();
|
|
48
|
-
return useMemo(() => ({
|
|
49
40
|
dismissAll: () => {
|
|
50
41
|
overlayRef.current?.dismissAll();
|
|
51
42
|
},
|
|
52
43
|
}), [overlayRef]);
|
|
53
44
|
}
|
|
54
|
-
export { ToastProvider, useToast
|
|
45
|
+
export { ToastProvider, useToast };
|
|
55
46
|
//# sourceMappingURL=toast.js.map
|
package/dist/toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","sourceRoot":"","sources":["../src/toast.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAK3D,MAAM,YAAY,GAAG,aAAa,CAAoB,IA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CAAC,CAAC;AAEF,8EAA8E;AAC9E,SAAS,aAAa,CAAC,KAAyB;IAC5C,OAAO,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,UAAU,YAAG,KAAK,CAAC,QAAQ,GAAyB,CAAC;AACpG,CAAC;AAED,2GAA2G;AAC3G,SAAS,QAAQ;IACb,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,OAAO,OAAO,CACV,GAAG,EAAE,CAAC,CAAC;QACH,IAAI,EAAE,CAAC,OAAsB,EAAE,EAAE;YAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACxC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YAEpC,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,UAAU,EAAE,GAAG,EAAE;YACb,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QACrC,CAAC;KACJ,CAAC,EACF,CAAC,UAAU,CAAC,CACf,CAAC;AACN,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { ToastController, ToastOptions, ToastProviderProps } from \"./types.js\";\n\ntype OverlayRef = RefObject<Adw.ToastOverlay | null>;\n\nconst ToastContext = createContext<OverlayRef | null>(null);\n\nconst useOverlayRef = (): OverlayRef => {\n const overlayRef = useContext(ToastContext);\n\n if (overlayRef === null) {\n throw new Error(\"useToast must be used within a ToastProvider\");\n }\n\n return overlayRef;\n};\n\nconst buildToast = (options: ToastOptions): Adw.Toast => {\n const { onButtonClicked, onDismissed, ...props } = options;\n const toast = new Adw.Toast(props);\n\n if (onButtonClicked != null) {\n toast.on(\"button-clicked\", () => {\n onButtonClicked(toast);\n });\n }\n\n if (onDismissed != null) {\n toast.on(\"dismissed\", () => {\n onDismissed(toast);\n });\n }\n\n return toast;\n};\n\n/** Shares an Adw.ToastOverlay reference with useToast in every descendant. */\nfunction ToastProvider(props: ToastProviderProps): ReactNode {\n return <ToastContext.Provider value={props.overlayRef}>{props.children}</ToastContext.Provider>;\n}\n\n/** Returns a {@link ToastController} that shows and dismisses toasts on the nearest provider's overlay. */\nfunction useToast(): ToastController {\n const overlayRef = useOverlayRef();\n\n return useMemo<ToastController>(\n () => ({\n show: (options?: ToastOptions) => {\n const toast = buildToast(options ?? {});\n overlayRef.current?.addToast(toast);\n\n return toast;\n },\n dismissAll: () => {\n overlayRef.current?.dismissAll();\n },\n }),\n [overlayRef],\n );\n}\n\nexport { ToastProvider, useToast };\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type * as Adw from "@gtkx/gi/adw";
|
|
2
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
3
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
3
4
|
import type { AdwComboRowProps, AdwToastProps } from "@gtkx/jsx/adw";
|
|
4
5
|
import type { GtkColumnViewColumnProps, GtkColumnViewProps, GtkDropDownProps, GtkGridViewProps, GtkListViewProps } from "@gtkx/jsx/gtk";
|
|
6
|
+
import type { Primitive } from "@gtkx/utils";
|
|
5
7
|
import type { ReactNode, RefObject } from "react";
|
|
6
8
|
/**
|
|
7
9
|
* A single item in a collection model, identified by a stable id and holding an
|
|
8
10
|
* arbitrary value. Nested items form a tree.
|
|
9
11
|
*/
|
|
10
12
|
type ListItem<T = unknown> = {
|
|
11
|
-
/** Stable identifier used to
|
|
13
|
+
/** Stable identifier, unique across the collection, used to preserve identity across updates and selection. */
|
|
12
14
|
id: string;
|
|
13
15
|
/** Payload handed to the cell renderer as `ListItemRenderArgs.item`. */
|
|
14
16
|
value: T;
|
|
15
|
-
/** Child items
|
|
17
|
+
/** Child items in an acyclic tree, read only as rows are drawn. */
|
|
16
18
|
children?: ListItem<T>[] | undefined;
|
|
17
19
|
/** Hides the tree expander arrow even when the item has children, through `hide-expander`. */
|
|
18
20
|
shouldHideExpander?: boolean | undefined;
|
|
@@ -23,7 +25,7 @@ type ListItem<T = unknown> = {
|
|
|
23
25
|
};
|
|
24
26
|
/** A group of items rendered under a shared section header. */
|
|
25
27
|
type ListSection<S = unknown, T = unknown> = {
|
|
26
|
-
/** Stable identifier used to track the section across updates. */
|
|
28
|
+
/** Stable identifier, unique among sections, used to track the section across updates. */
|
|
27
29
|
id: string;
|
|
28
30
|
/** Payload handed to the section header renderer as `ListSectionRenderArgs.section`. */
|
|
29
31
|
value: S;
|
|
@@ -76,6 +78,9 @@ type ItemSizeProps = {
|
|
|
76
78
|
/** Width in pixels every cell asks for until its contents render; unset lets each cell size itself. */
|
|
77
79
|
estimatedItemWidth?: number | undefined;
|
|
78
80
|
};
|
|
81
|
+
type ListItemFactoryProps<T extends GObject.Object> = ItemSizeProps & {
|
|
82
|
+
renderItem: ListItemRenderer<T>;
|
|
83
|
+
};
|
|
79
84
|
/** The flat-collection hint shared by {@link ListView} and {@link ColumnView}. */
|
|
80
85
|
type FlatnessProps = {
|
|
81
86
|
/**
|
|
@@ -89,8 +94,7 @@ type FlatnessProps = {
|
|
|
89
94
|
type SelectionProps = {
|
|
90
95
|
/**
|
|
91
96
|
* Ids of the items to keep selected; omitting it keeps nothing selected, and `onSelectionChanged` is how a
|
|
92
|
-
* user's selection is adopted into it.
|
|
93
|
-
* and a single-selection view takes the first of them.
|
|
97
|
+
* user's selection is adopted into it.
|
|
94
98
|
*/
|
|
95
99
|
selectedIds?: string[] | null | undefined;
|
|
96
100
|
/** Called with one id per selected row whenever the selection changes, and once on mount. */
|
|
@@ -113,9 +117,7 @@ type ExpanderDescriptions = {
|
|
|
113
117
|
type ExpansionProps = {
|
|
114
118
|
/**
|
|
115
119
|
* Ids of the items to keep expanded; omitting it keeps every row collapsed, and `onExpandedChange` is how a
|
|
116
|
-
* user's expansion is adopted into it.
|
|
117
|
-
* them expand together. An item whose children lead back to itself expands one level at a time, since a row
|
|
118
|
-
* repeating an item already expanded above it stays collapsed.
|
|
120
|
+
* user's expansion is adopted into it.
|
|
119
121
|
*/
|
|
120
122
|
expandedIds?: string[] | null | undefined;
|
|
121
123
|
/** Called with one id per expanded row, in visible order, whenever expansion changes. */
|
|
@@ -137,12 +139,15 @@ type SortProps = {
|
|
|
137
139
|
onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;
|
|
138
140
|
};
|
|
139
141
|
/** The data a collection view renders, either as a plain item list or grouped into sections. */
|
|
140
|
-
type SourceProps<T, S> = {
|
|
141
|
-
/** Items to render, nesting through `ListItem.children` for a tree
|
|
142
|
+
type SourceProps<T, S> = ({
|
|
143
|
+
/** Items to render, nesting through `ListItem.children` for a tree. */
|
|
142
144
|
items?: ListItem<T>[] | undefined;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
} & Partial<Record<"sections", undefined>> & Partial<Record<"renderHeader", null | undefined>>) | ({
|
|
146
|
+
/** Items grouped under section headers. */
|
|
147
|
+
sections: ListSection<S, T>[];
|
|
148
|
+
/** Renders the header shown above each section. */
|
|
149
|
+
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
150
|
+
} & Partial<Record<"items", undefined>>);
|
|
146
151
|
/** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */
|
|
147
152
|
type ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" | "sorter" | "id" | "title"> & {
|
|
148
153
|
/** Stable identifier, also used to address the column through sorting props. */
|
|
@@ -160,37 +165,28 @@ type ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" |
|
|
|
160
165
|
type ColumnViewOwnProps<T, S> = SelectionProps & ExpansionProps & SortProps & SourceProps<T, S> & FlatnessProps & Omit<ItemSizeProps, "estimatedItemWidth"> & {
|
|
161
166
|
/** Columns to render, in order; each carries its own cell renderer. */
|
|
162
167
|
columns: ColumnViewColumn<T>[];
|
|
163
|
-
/** Renders the header shown above each section. */
|
|
164
|
-
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
165
168
|
/** Resolves the props of the row carrying one item's cells, such as its screen-reader label. */
|
|
166
169
|
rowProps?: ListRowPropsResolver<T> | null | undefined;
|
|
167
170
|
};
|
|
168
171
|
/**
|
|
169
|
-
*
|
|
170
|
-
* declarative collection props: flat items or grouped sections, controlled selection
|
|
171
|
-
* and expansion, sorting (sortColumn, sortOrder, onSortChanged), an optional section
|
|
172
|
-
* header renderer, per-row props, and the columns to render.
|
|
172
|
+
* Native `Gtk.ColumnView` props with declarative columns and collections, controlled selection, expansion, and sorting.
|
|
173
173
|
*/
|
|
174
|
-
type ColumnViewProps<T = unknown, S = unknown> = Omit<GtkColumnViewProps, "columns" | "model" | "headerFactory" | "rowFactory" | keyof ColumnViewOwnProps<T, S>> & ColumnViewOwnProps<T, S>;
|
|
174
|
+
type ColumnViewProps<T = unknown, S = unknown> = Omit<GtkColumnViewProps, "children" | "columns" | "model" | "headerFactory" | "rowFactory" | keyof ColumnViewOwnProps<T, S>> & ColumnViewOwnProps<T, S>;
|
|
175
175
|
/** The declarative collection props {@link DropDown} and `ComboRow` add on top of their widget's own. */
|
|
176
176
|
type DropDownOwnProps<T, S> = SourceProps<T, S> & {
|
|
177
177
|
/** Id of the currently selected item, making the selection controlled. */
|
|
178
|
-
selectedId?: string |
|
|
179
|
-
/** Called with the id
|
|
180
|
-
onSelectionChanged?: ((id: string) => void) | null | undefined;
|
|
181
|
-
/** Renders the collapsed display
|
|
178
|
+
selectedId?: string | undefined;
|
|
179
|
+
/** Called with the selected id, or `null` when the model becomes empty. */
|
|
180
|
+
onSelectionChanged?: ((id: string | null) => void) | null | undefined;
|
|
181
|
+
/** Renders the collapsed display and, unless overridden, the popup rows. Required for non-primitive values. */
|
|
182
182
|
renderItem?: ListItemRenderer<T> | null | undefined;
|
|
183
183
|
/** Renderer for items in the open popup list, falling back to renderItem when omitted. */
|
|
184
184
|
renderListItem?: ListItemRenderer<T> | null | undefined;
|
|
185
|
-
/** Renderer for section headers in the popup list. */
|
|
186
|
-
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
187
185
|
};
|
|
188
186
|
/** A drop-down-shaped widget's props with its model and factories swapped for the declarative collection props. */
|
|
189
|
-
type DropDownWidgetProps<Widget, T, S> = Omit<Widget, "model" | "factory" | "listFactory" | "headerFactory" | keyof DropDownOwnProps<T, S>> & DropDownOwnProps<T, S
|
|
187
|
+
type DropDownWidgetProps<Widget, T, S> = Omit<Widget, "model" | "factory" | "listFactory" | "headerFactory" | keyof DropDownOwnProps<T, S>> & DropDownOwnProps<T, S> & (SourceProps<T & Primitive, S> | Record<"renderItem", ListItemRenderer<T>>);
|
|
190
188
|
/**
|
|
191
|
-
*
|
|
192
|
-
* collection props: flat items or grouped sections, controlled single selection, and renderers
|
|
193
|
-
* for the collapsed display, popup rows, and popup section headers.
|
|
189
|
+
* Native `Gtk.DropDown` props with declarative collections, controlled selection, and display/popup renderers.
|
|
194
190
|
*/
|
|
195
191
|
type DropDownProps<T = unknown, S = unknown> = DropDownWidgetProps<GtkDropDownProps, T, S>;
|
|
196
192
|
/** The declarative collection props {@link GridView} adds on top of Gtk.GridView's own. */
|
|
@@ -201,29 +197,21 @@ type GridViewOwnProps<T> = ItemSizeProps & SelectionProps & {
|
|
|
201
197
|
renderItem: ListItemRenderer<T>;
|
|
202
198
|
};
|
|
203
199
|
/**
|
|
204
|
-
*
|
|
205
|
-
* declarative collection props: items, a per-cell renderItem, controlled selection,
|
|
206
|
-
* and estimated item sizing.
|
|
200
|
+
* Native `Gtk.GridView` props with declarative cells, controlled selection, and estimated sizing.
|
|
207
201
|
*/
|
|
208
202
|
type GridViewProps<T = unknown> = Omit<GtkGridViewProps, "model" | "factory" | keyof GridViewOwnProps<T>> & GridViewOwnProps<T>;
|
|
209
203
|
/** The declarative collection props {@link ListView} adds on top of Gtk.ListView's own. */
|
|
210
204
|
type ListViewOwnProps<T, S> = ItemSizeProps & SelectionProps & ExpansionProps & SourceProps<T, S> & FlatnessProps & {
|
|
211
205
|
/** Renders the contents of one row. */
|
|
212
206
|
renderItem: ListItemRenderer<T>;
|
|
213
|
-
/** Renders the header shown above each section. */
|
|
214
|
-
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
215
207
|
};
|
|
216
208
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* an optional section header renderer, controlled selection and expansion, and
|
|
220
|
-
* estimated item sizing.
|
|
209
|
+
* Native `Gtk.ListView` props with declarative rows and sections, controlled selection and expansion,
|
|
210
|
+
* and estimated sizing.
|
|
221
211
|
*/
|
|
222
212
|
type ListViewProps<T = unknown, S = unknown> = Omit<GtkListViewProps, "model" | "factory" | "headerFactory" | keyof ListViewOwnProps<T, S>> & ListViewOwnProps<T, S>;
|
|
223
213
|
/**
|
|
224
|
-
*
|
|
225
|
-
* collection props: flat items or grouped sections, controlled single selection, and renderers
|
|
226
|
-
* for the row display, popup rows, and popup section headers.
|
|
214
|
+
* Native `Adw.ComboRow` props with declarative collections, controlled selection, and display/popup renderers.
|
|
227
215
|
*/
|
|
228
216
|
type ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;
|
|
229
217
|
/**
|
|
@@ -231,15 +219,10 @@ type ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowPr
|
|
|
231
219
|
* `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.
|
|
232
220
|
*/
|
|
233
221
|
type ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, "onButtonClicked" | "onDismissed">;
|
|
234
|
-
/** Imperative controls for
|
|
222
|
+
/** Imperative controls for toasts, returned by {@link useToast}. */
|
|
235
223
|
type ToastController = {
|
|
236
224
|
/** Builds a toast, shows it through the overlay, and returns it. */
|
|
237
225
|
show: (options?: ToastOptions) => Adw.Toast;
|
|
238
|
-
/** Dismisses a single toast, typically one returned by `ToastController.show`. */
|
|
239
|
-
dismiss: (toast: Adw.Toast) => void;
|
|
240
|
-
};
|
|
241
|
-
/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */
|
|
242
|
-
type ToastOverlayController = {
|
|
243
226
|
/** Dismisses the shown toast and every queued one. */
|
|
244
227
|
dismissAll: () => void;
|
|
245
228
|
};
|
|
@@ -247,8 +230,8 @@ type ToastOverlayController = {
|
|
|
247
230
|
type ToastProviderProps = {
|
|
248
231
|
/** Ref also given to the `AdwToastOverlay` the toasts appear over. */
|
|
249
232
|
overlayRef: RefObject<Adw.ToastOverlay | null>;
|
|
250
|
-
/** Subtree whose `useToast`
|
|
233
|
+
/** Subtree whose `useToast` calls target that overlay. */
|
|
251
234
|
children?: ReactNode | undefined;
|
|
252
235
|
};
|
|
253
|
-
export { type SelectionProps, type ExpanderDescriptions, type ExpansionProps, type SortProps, type DropDownOwnProps, type ListItem, type ListSection, type ListItemRenderArgs, type ListRowProps, type ListSectionRenderArgs, type ListItemRenderer, type ListRowPropsResolver, type ListSectionRenderer, type ColumnViewColumn, type ColumnViewProps, type DropDownProps, type GridViewProps, type ListViewProps, type ComboRowProps, type ToastOptions, type ToastController, type
|
|
236
|
+
export { type SelectionProps, type ExpanderDescriptions, type ExpansionProps, type SortProps, type DropDownOwnProps, type ListItem, type ListSection, type ListItemRenderArgs, type ListRowProps, type ListSectionRenderArgs, type ListItemRenderer, type ListItemFactoryProps, type ListRowPropsResolver, type ListSectionRenderer, type ColumnViewColumn, type ColumnViewProps, type DropDownProps, type GridViewProps, type ListViewProps, type ComboRowProps, type ToastOptions, type ToastController, type ToastProviderProps, };
|
|
254
237
|
//# sourceMappingURL=types.d.ts.map
|
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,GA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Q,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GAC1B,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqSA,OAAO,EAwBN,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type * as GObject from \"@gtkx/gi/gobject\";\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 { Primitive } from \"@gtkx/utils\";\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, unique across the collection, used to preserve identity across updates and selection. */\n id: string;\n /** Payload handed to the cell renderer as `ListItemRenderArgs.item`. */\n value: T;\n /** Child items in an acyclic 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, unique among sections, 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\ntype ListItemFactoryProps<T extends GObject.Object> = ItemSizeProps & {\n renderItem: ListItemRenderer<T>;\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.\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.\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. */\n items?: ListItem<T>[] | undefined;\n} & Partial<Record<\"sections\", undefined>> & Partial<Record<\"renderHeader\", null | undefined>>) | ({\n /** Items grouped under section headers. */\n sections: ListSection<S, T>[];\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n} & Partial<Record<\"items\", undefined>>);\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 /** 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 * Native `Gtk.ColumnView` props with declarative columns and collections, controlled selection, expansion, and sorting.\n */\ntype ColumnViewProps<T = unknown, S = unknown> = Omit<\n GtkColumnViewProps,\n \"children\" | \"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 | undefined;\n /** Called with the selected id, or `null` when the model becomes empty. */\n onSelectionChanged?: ((id: string | null) => void) | null | undefined;\n /** Renders the collapsed display and, unless overridden, the popup rows. Required for non-primitive values. */\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};\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(SourceProps<T & Primitive, S> | Record<\"renderItem\", ListItemRenderer<T>>);\n\n/**\n * Native `Gtk.DropDown` props with declarative collections, controlled selection, and display/popup renderers.\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 * Native `Gtk.GridView` props with declarative cells, controlled selection, and estimated 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 };\n\n/**\n * Native `Gtk.ListView` props with declarative rows and sections, controlled selection and expansion,\n * and estimated 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 * Native `Adw.ComboRow` props with declarative collections, controlled selection, and display/popup renderers.\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 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 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` 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 ListItemFactoryProps,\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 ToastProviderProps,\n};\n"]}
|