@gtkx/components 1.0.0-rc.1 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adw/index.d.ts +3 -0
- package/dist/adw/index.d.ts.map +1 -0
- package/dist/adw/index.js +2 -0
- package/dist/adw/index.js.map +1 -0
- package/dist/adw/toast.d.ts +10 -0
- package/dist/adw/toast.d.ts.map +1 -0
- package/dist/adw/toast.js +51 -0
- package/dist/adw/toast.js.map +1 -0
- package/dist/adw/types.d.ts +28 -0
- package/dist/adw/types.d.ts.map +1 -0
- package/dist/adw/types.js +2 -0
- package/dist/adw/types.js.map +1 -0
- package/dist/column-view.d.ts +7 -29
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +98 -70
- package/dist/column-view.js.map +1 -1
- package/dist/drop-down.d.ts +8 -27
- package/dist/drop-down.d.ts.map +1 -1
- package/dist/drop-down.js +112 -81
- package/dist/drop-down.js.map +1 -1
- package/dist/grid-view.d.ts +6 -16
- package/dist/grid-view.d.ts.map +1 -1
- package/dist/grid-view.js +25 -33
- package/dist/grid-view.js.map +1 -1
- package/dist/index.d.ts +6 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/cells.d.ts +50 -0
- package/dist/internal/cells.d.ts.map +1 -0
- package/dist/internal/cells.js +185 -0
- package/dist/internal/cells.js.map +1 -0
- package/dist/internal/collection-index.d.ts +21 -0
- package/dist/internal/collection-index.d.ts.map +1 -0
- package/dist/internal/collection-index.js +106 -0
- package/dist/internal/collection-index.js.map +1 -0
- package/dist/internal/collection-model.d.ts +12 -0
- package/dist/internal/collection-model.d.ts.map +1 -0
- package/dist/internal/collection-model.js +164 -0
- package/dist/internal/collection-model.js.map +1 -0
- package/dist/internal/collection.d.ts +18 -0
- package/dist/internal/collection.d.ts.map +1 -0
- package/dist/internal/collection.js +64 -0
- package/dist/internal/collection.js.map +1 -0
- package/dist/internal/expansion.d.ts +9 -0
- package/dist/internal/expansion.d.ts.map +1 -0
- package/dist/internal/expansion.js +75 -0
- package/dist/internal/expansion.js.map +1 -0
- package/dist/internal/selection.d.ts +12 -0
- package/dist/internal/selection.d.ts.map +1 -0
- package/dist/internal/selection.js +99 -0
- package/dist/internal/selection.js.map +1 -0
- package/dist/internal/use-collection.d.ts +18 -0
- package/dist/internal/use-collection.d.ts.map +1 -0
- package/dist/internal/use-collection.js +42 -0
- package/dist/internal/use-collection.js.map +1 -0
- package/dist/internal/use-widget-ref.d.ts +4 -0
- package/dist/internal/use-widget-ref.d.ts.map +1 -0
- package/dist/internal/use-widget-ref.js +8 -0
- package/dist/internal/use-widget-ref.js.map +1 -0
- package/dist/list-view.d.ts +5 -20
- package/dist/list-view.d.ts.map +1 -1
- package/dist/list-view.js +32 -53
- package/dist/list-view.js.map +1 -1
- package/dist/size-group.d.ts +8 -16
- package/dist/size-group.d.ts.map +1 -1
- package/dist/size-group.js +35 -51
- package/dist/size-group.js.map +1 -1
- package/dist/types.d.ts +97 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +17 -6
- package/src/adw/index.ts +2 -0
- package/src/adw/toast.tsx +74 -0
- package/src/adw/types.ts +32 -0
- package/src/column-view.tsx +176 -160
- package/src/drop-down.tsx +180 -167
- package/src/grid-view.tsx +29 -73
- package/src/index.ts +18 -25
- package/src/internal/cells.tsx +345 -0
- package/src/internal/collection-index.ts +168 -0
- package/src/internal/collection-model.ts +246 -0
- package/src/internal/collection.ts +104 -0
- package/src/internal/expansion.ts +123 -0
- package/src/internal/selection.tsx +159 -0
- package/src/internal/use-collection.tsx +70 -0
- package/src/internal/use-widget-ref.ts +11 -0
- package/src/list-view.tsx +43 -139
- package/src/size-group.tsx +63 -82
- package/src/types.ts +155 -24
- package/dist/cell.d.ts +0 -30
- package/dist/cell.d.ts.map +0 -1
- package/dist/cell.js +0 -45
- package/dist/cell.js.map +0 -1
- package/dist/column-view-column.d.ts +0 -27
- package/dist/column-view-column.d.ts.map +0 -1
- package/dist/column-view-column.js +0 -30
- package/dist/column-view-column.js.map +0 -1
- package/dist/constraint-layout-apply.d.ts +0 -55
- package/dist/constraint-layout-apply.d.ts.map +0 -1
- package/dist/constraint-layout-apply.js +0 -107
- package/dist/constraint-layout-apply.js.map +0 -1
- package/dist/constraint-layout.d.ts +0 -20
- package/dist/constraint-layout.d.ts.map +0 -1
- package/dist/constraint-layout.js +0 -88
- package/dist/constraint-layout.js.map +0 -1
- package/dist/fixed.d.ts +0 -26
- package/dist/fixed.d.ts.map +0 -1
- package/dist/fixed.js +0 -40
- package/dist/fixed.js.map +0 -1
- package/dist/grid.d.ts +0 -27
- package/dist/grid.d.ts.map +0 -1
- package/dist/grid.js +0 -48
- package/dist/grid.js.map +0 -1
- package/dist/hooks/use-cell-containers.d.ts +0 -18
- package/dist/hooks/use-cell-containers.d.ts.map +0 -1
- package/dist/hooks/use-cell-containers.js +0 -67
- package/dist/hooks/use-cell-containers.js.map +0 -1
- package/dist/hooks/use-collection-model.d.ts +0 -26
- package/dist/hooks/use-collection-model.d.ts.map +0 -1
- package/dist/hooks/use-collection-model.js +0 -35
- package/dist/hooks/use-collection-model.js.map +0 -1
- package/dist/hooks/use-collection-widget.d.ts +0 -28
- package/dist/hooks/use-collection-widget.d.ts.map +0 -1
- package/dist/hooks/use-collection-widget.js +0 -21
- package/dist/hooks/use-collection-widget.js.map +0 -1
- package/dist/hooks/use-drop-down-selection.d.ts +0 -16
- package/dist/hooks/use-drop-down-selection.d.ts.map +0 -1
- package/dist/hooks/use-drop-down-selection.js +0 -35
- package/dist/hooks/use-drop-down-selection.js.map +0 -1
- package/dist/hooks/use-expansion-model.d.ts +0 -12
- package/dist/hooks/use-expansion-model.d.ts.map +0 -1
- package/dist/hooks/use-expansion-model.js +0 -71
- package/dist/hooks/use-expansion-model.js.map +0 -1
- package/dist/hooks/use-header-menu.d.ts +0 -4
- package/dist/hooks/use-header-menu.d.ts.map +0 -1
- package/dist/hooks/use-header-menu.js +0 -20
- package/dist/hooks/use-header-menu.js.map +0 -1
- package/dist/hooks/use-installed-model.d.ts +0 -4
- package/dist/hooks/use-installed-model.d.ts.map +0 -1
- package/dist/hooks/use-installed-model.js +0 -15
- package/dist/hooks/use-installed-model.js.map +0 -1
- package/dist/hooks/use-list-model.d.ts +0 -19
- package/dist/hooks/use-list-model.d.ts.map +0 -1
- package/dist/hooks/use-list-model.js +0 -97
- package/dist/hooks/use-list-model.js.map +0 -1
- package/dist/hooks/use-placed-child.d.ts +0 -18
- package/dist/hooks/use-placed-child.d.ts.map +0 -1
- package/dist/hooks/use-placed-child.js +0 -47
- package/dist/hooks/use-placed-child.js.map +0 -1
- package/dist/hooks/use-selection-model.d.ts +0 -13
- package/dist/hooks/use-selection-model.d.ts.map +0 -1
- package/dist/hooks/use-selection-model.js +0 -103
- package/dist/hooks/use-selection-model.js.map +0 -1
- package/dist/hooks/use-sort-handler.d.ts +0 -17
- package/dist/hooks/use-sort-handler.d.ts.map +0 -1
- package/dist/hooks/use-sort-handler.js +0 -87
- package/dist/hooks/use-sort-handler.js.map +0 -1
- package/dist/menu-items.d.ts +0 -5
- package/dist/menu-items.d.ts.map +0 -1
- package/dist/menu-items.js +0 -48
- package/dist/menu-items.js.map +0 -1
- package/dist/menu.d.ts +0 -14
- package/dist/menu.d.ts.map +0 -1
- package/dist/menu.js +0 -24
- package/dist/menu.js.map +0 -1
- package/dist/overlay.d.ts +0 -24
- package/dist/overlay.d.ts.map +0 -1
- package/dist/overlay.js +0 -49
- package/dist/overlay.js.map +0 -1
- package/dist/utils/cell-container-store.d.ts +0 -28
- package/dist/utils/cell-container-store.d.ts.map +0 -1
- package/dist/utils/cell-container-store.js +0 -98
- package/dist/utils/cell-container-store.js.map +0 -1
- package/dist/utils/item-models.d.ts +0 -10
- package/dist/utils/item-models.d.ts.map +0 -1
- package/dist/utils/item-models.js +0 -82
- package/dist/utils/item-models.js.map +0 -1
- package/dist/utils/item-resolver.d.ts +0 -25
- package/dist/utils/item-resolver.d.ts.map +0 -1
- package/dist/utils/item-resolver.js +0 -102
- package/dist/utils/item-resolver.js.map +0 -1
- package/dist/utils/list-item-flatten.d.ts +0 -24
- package/dist/utils/list-item-flatten.d.ts.map +0 -1
- package/dist/utils/list-item-flatten.js +0 -68
- package/dist/utils/list-item-flatten.js.map +0 -1
- package/src/cell.tsx +0 -144
- package/src/column-view-column.tsx +0 -82
- package/src/constraint-layout-apply.ts +0 -173
- package/src/constraint-layout.tsx +0 -135
- package/src/fixed.tsx +0 -86
- package/src/grid.tsx +0 -88
- package/src/hooks/use-cell-containers.ts +0 -93
- package/src/hooks/use-collection-model.ts +0 -60
- package/src/hooks/use-collection-widget.ts +0 -47
- package/src/hooks/use-drop-down-selection.ts +0 -52
- package/src/hooks/use-expansion-model.ts +0 -82
- package/src/hooks/use-header-menu.ts +0 -34
- package/src/hooks/use-installed-model.ts +0 -20
- package/src/hooks/use-list-model.ts +0 -161
- package/src/hooks/use-placed-child.ts +0 -79
- package/src/hooks/use-selection-model.ts +0 -114
- package/src/hooks/use-sort-handler.ts +0 -107
- package/src/menu-items.ts +0 -48
- package/src/menu.tsx +0 -32
- package/src/overlay.tsx +0 -88
- package/src/utils/cell-container-store.ts +0 -114
- package/src/utils/item-models.ts +0 -113
- package/src/utils/item-resolver.ts +0 -138
- package/src/utils/list-item-flatten.ts +0 -90
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
import { GtkColumnViewColumn, type GtkColumnViewColumnProps } from "@gtkx/jsx/gtk";
|
|
3
|
-
import { useMergeRefs } from "@gtkx/react/internal";
|
|
4
|
-
import { type ReactNode, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
-
import { type CellRenderer, CellRenderHost, itemRenderer, type TreeRenderContext } from "./cell.js";
|
|
6
|
-
import { makeFactoryInstaller, useCellContainers } from "./hooks/use-cell-containers.js";
|
|
7
|
-
import { useHeaderMenu } from "./hooks/use-header-menu.js";
|
|
8
|
-
import type { RenderItemProps } from "./types.js";
|
|
9
|
-
import type { ItemResolver } from "./utils/item-resolver.js";
|
|
10
|
-
|
|
11
|
-
const factoryInstaller = makeFactoryInstaller<Gtk.ColumnViewColumn>((column, factory) => column.setFactory(factory));
|
|
12
|
-
|
|
13
|
-
export type ColumnDefDeclarativeProps<T = unknown> = {
|
|
14
|
-
title: string;
|
|
15
|
-
expand?: boolean | undefined;
|
|
16
|
-
resizable?: boolean | undefined;
|
|
17
|
-
fixedWidth?: number | undefined;
|
|
18
|
-
id: string;
|
|
19
|
-
sortable?: boolean | undefined;
|
|
20
|
-
visible?: boolean | undefined;
|
|
21
|
-
renderCell: (props: RenderItemProps<T>) => ReactNode;
|
|
22
|
-
headerMenu?: ReactNode;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type ColumnDef<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" | "sorter"> &
|
|
26
|
-
ColumnDefDeclarativeProps<T>;
|
|
27
|
-
|
|
28
|
-
type ColumnViewColumnProps<T = unknown> = ColumnDef<T> & {
|
|
29
|
-
resolver: ItemResolver<unknown, unknown>;
|
|
30
|
-
tree: TreeRenderContext;
|
|
31
|
-
estimatedItemHeight?: number | undefined;
|
|
32
|
-
onInstance: (id: string, column: Gtk.ColumnViewColumn | null) => void;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const ColumnViewColumn = <T = unknown>(props: ColumnViewColumnProps<T>): ReactNode => {
|
|
36
|
-
const {
|
|
37
|
-
id,
|
|
38
|
-
title,
|
|
39
|
-
sortable,
|
|
40
|
-
renderCell,
|
|
41
|
-
headerMenu,
|
|
42
|
-
resolver,
|
|
43
|
-
tree,
|
|
44
|
-
estimatedItemHeight,
|
|
45
|
-
onInstance,
|
|
46
|
-
ref,
|
|
47
|
-
...intrinsicProps
|
|
48
|
-
} = props as ColumnViewColumnProps<T> & { [key: string]: unknown };
|
|
49
|
-
const [column, setColumn] = useState<Gtk.ColumnViewColumn | null>(null);
|
|
50
|
-
|
|
51
|
-
const captureColumn = useMergeRefs<Gtk.ColumnViewColumn>(ref, setColumn);
|
|
52
|
-
|
|
53
|
-
const store = useCellContainers<Gtk.ColumnViewColumn>({
|
|
54
|
-
object: column,
|
|
55
|
-
installer: factoryInstaller,
|
|
56
|
-
estimatedHeight: estimatedItemHeight,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const onInstanceRef = useRef(onInstance);
|
|
60
|
-
onInstanceRef.current = onInstance;
|
|
61
|
-
|
|
62
|
-
useLayoutEffect(() => {
|
|
63
|
-
if (column === null) return;
|
|
64
|
-
onInstanceRef.current(id, column);
|
|
65
|
-
return () => onInstanceRef.current(id, null);
|
|
66
|
-
}, [column, id]);
|
|
67
|
-
|
|
68
|
-
const headerMenuPortal = useHeaderMenu(column, headerMenu);
|
|
69
|
-
|
|
70
|
-
const cellRenderer: CellRenderer<unknown, unknown> = itemRenderer<unknown, unknown>(
|
|
71
|
-
(cellProps) => renderCell({ ...cellProps, item: cellProps.item as T }),
|
|
72
|
-
tree,
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<>
|
|
77
|
-
<GtkColumnViewColumn {...intrinsicProps} id={id} title={title} ref={captureColumn} />
|
|
78
|
-
<CellRenderHost store={store} resolver={resolver} render={cellRenderer} />
|
|
79
|
-
{headerMenuPortal}
|
|
80
|
-
</>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Describes one constraint added by `<ConstraintLayout.Constraint>`, relating a
|
|
6
|
-
* target widget attribute to a source attribute of another widget or guide.
|
|
7
|
-
*/
|
|
8
|
-
export type ConstraintProps = {
|
|
9
|
-
/** Name of the target widget or guide. Use "super" or omit to reference the layout's own widget. */
|
|
10
|
-
target?: string;
|
|
11
|
-
targetAttribute: Gtk.ConstraintAttribute;
|
|
12
|
-
/** Relation between the target and source attributes (defaults to equality). */
|
|
13
|
-
relation?: Gtk.ConstraintRelation;
|
|
14
|
-
/** Name of the source widget or guide. Use "super" or omit for a constant constraint. */
|
|
15
|
-
source?: string;
|
|
16
|
-
sourceAttribute?: Gtk.ConstraintAttribute;
|
|
17
|
-
/** Factor applied to the source attribute (defaults to 1). */
|
|
18
|
-
multiplier?: number;
|
|
19
|
-
/** Constant offset added to the relation (defaults to 0). */
|
|
20
|
-
constant?: number;
|
|
21
|
-
/** Constraint strength, higher values winning conflicts (defaults to required). */
|
|
22
|
-
strength?: number;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Describes an invisible spacing guide added by `<ConstraintLayout.Guide>`,
|
|
27
|
-
* usable as a constraint target under its id.
|
|
28
|
-
*/
|
|
29
|
-
export type ConstraintGuideProps = {
|
|
30
|
-
/** Identifier used to reference this guide from constraints. */
|
|
31
|
-
id: string;
|
|
32
|
-
minWidth?: number;
|
|
33
|
-
minHeight?: number;
|
|
34
|
-
/** Preferred (natural) width. */
|
|
35
|
-
natWidth?: number;
|
|
36
|
-
/** Preferred (natural) height. */
|
|
37
|
-
natHeight?: number;
|
|
38
|
-
maxWidth?: number;
|
|
39
|
-
maxHeight?: number;
|
|
40
|
-
/** Strength of the guide's own size constraints. */
|
|
41
|
-
strength?: Gtk.ConstraintStrength;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Describes constraints authored with the Visual Format Language (VFL), applied by
|
|
46
|
-
* `<ConstraintLayout.Vfl>`.
|
|
47
|
-
*/
|
|
48
|
-
export type ConstraintVflProps = {
|
|
49
|
-
/** VFL lines describing the constraints between named widgets and guides. */
|
|
50
|
-
lines: string[];
|
|
51
|
-
/** Default horizontal spacing used by the layout operator (defaults to 0). */
|
|
52
|
-
hspacing?: number;
|
|
53
|
-
/** Default vertical spacing used by the layout operator (defaults to 0). */
|
|
54
|
-
vspacing?: number;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const SUPER_ID = "super";
|
|
58
|
-
|
|
59
|
-
const unknownIdMessage = (role: string, id: string): string =>
|
|
60
|
-
`<ConstraintLayout.Constraint> references unknown id '${id}'. ` +
|
|
61
|
-
`Set name="${id}" on the ${role} widget, or add a <ConstraintLayout.Guide id="${id}">.`;
|
|
62
|
-
|
|
63
|
-
const guideRegistry = new WeakMap<Gtk.ConstraintLayout, Map<string, Gtk.ConstraintGuide>>();
|
|
64
|
-
|
|
65
|
-
const guidesFor = (layout: Gtk.ConstraintLayout): Map<string, Gtk.ConstraintGuide> => {
|
|
66
|
-
let map = guideRegistry.get(layout);
|
|
67
|
-
if (!map) {
|
|
68
|
-
map = new Map<string, Gtk.ConstraintGuide>();
|
|
69
|
-
guideRegistry.set(layout, map);
|
|
70
|
-
}
|
|
71
|
-
return map;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const explicitWidgetName = (widget: Gtk.Widget): string | null => {
|
|
75
|
-
const value = new GObject.Value();
|
|
76
|
-
value.init(GObject.TYPE_STRING);
|
|
77
|
-
widget.getProperty("name", value);
|
|
78
|
-
const name = value.getString();
|
|
79
|
-
return name !== null && name.length > 0 ? name : null;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
function* namedChildren(layout: Gtk.ConstraintLayout): Generator<[string, Gtk.Widget]> {
|
|
83
|
-
const host = layout.getWidget();
|
|
84
|
-
if (!host) return;
|
|
85
|
-
for (let child = host.getFirstChild(); child; child = child.getNextSibling()) {
|
|
86
|
-
const name = explicitWidgetName(child);
|
|
87
|
-
if (name !== null) yield [name, child];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const findChildByName = (layout: Gtk.ConstraintLayout, id: string): Gtk.Widget | undefined => {
|
|
92
|
-
for (const [name, child] of namedChildren(layout)) {
|
|
93
|
-
if (name === id) return child;
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const resolveConstraintTarget = (
|
|
99
|
-
layout: Gtk.ConstraintLayout,
|
|
100
|
-
id: string | undefined,
|
|
101
|
-
): Gtk.ConstraintTarget | null | undefined => {
|
|
102
|
-
if (id === undefined || id === SUPER_ID) return null;
|
|
103
|
-
return findChildByName(layout, id) ?? guidesFor(layout).get(id);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const constraintViews = (layout: Gtk.ConstraintLayout): Map<string, Gtk.ConstraintTarget> => {
|
|
107
|
-
const views = new Map<string, Gtk.ConstraintTarget>();
|
|
108
|
-
for (const [name, child] of namedChildren(layout)) views.set(name, child);
|
|
109
|
-
for (const [name, guide] of guidesFor(layout)) {
|
|
110
|
-
if (!views.has(name)) views.set(name, guide);
|
|
111
|
-
}
|
|
112
|
-
return views;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const isLayoutLive = (layout: Gtk.ConstraintLayout): boolean => layout.getWidget() !== null;
|
|
116
|
-
|
|
117
|
-
export function applyConstraint(layout: Gtk.ConstraintLayout, props: ConstraintProps): () => void {
|
|
118
|
-
const target = resolveConstraintTarget(layout, props.target);
|
|
119
|
-
if (target === undefined) throw new Error(unknownIdMessage("target", String(props.target)));
|
|
120
|
-
const source = resolveConstraintTarget(layout, props.source);
|
|
121
|
-
if (source === undefined) throw new Error(unknownIdMessage("source", String(props.source)));
|
|
122
|
-
|
|
123
|
-
const constraint = new Gtk.Constraint({
|
|
124
|
-
target,
|
|
125
|
-
targetAttribute: props.targetAttribute,
|
|
126
|
-
relation: props.relation ?? Gtk.ConstraintRelation.EQ,
|
|
127
|
-
source,
|
|
128
|
-
sourceAttribute: props.sourceAttribute ?? Gtk.ConstraintAttribute.NONE,
|
|
129
|
-
multiplier: props.multiplier ?? 1,
|
|
130
|
-
constant: props.constant ?? 0,
|
|
131
|
-
strength: props.strength ?? Gtk.ConstraintStrength.REQUIRED,
|
|
132
|
-
});
|
|
133
|
-
layout.addConstraint(constraint);
|
|
134
|
-
|
|
135
|
-
return () => {
|
|
136
|
-
if (isLayoutLive(layout)) layout.removeConstraint(constraint);
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function applyVfl(layout: Gtk.ConstraintLayout, props: ConstraintVflProps): () => void {
|
|
141
|
-
const views = constraintViews(layout);
|
|
142
|
-
const constraints = layout.addConstraintsFromDescription(
|
|
143
|
-
props.lines,
|
|
144
|
-
props.hspacing ?? 0,
|
|
145
|
-
props.vspacing ?? 0,
|
|
146
|
-
views,
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
return () => {
|
|
150
|
-
if (!isLayoutLive(layout)) return;
|
|
151
|
-
for (const constraint of constraints) layout.removeConstraint(constraint);
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function applyGuide(layout: Gtk.ConstraintLayout, props: ConstraintGuideProps): () => void {
|
|
156
|
-
const guide = new Gtk.ConstraintGuide({
|
|
157
|
-
name: props.id,
|
|
158
|
-
minWidth: props.minWidth,
|
|
159
|
-
minHeight: props.minHeight,
|
|
160
|
-
natWidth: props.natWidth,
|
|
161
|
-
natHeight: props.natHeight,
|
|
162
|
-
maxWidth: props.maxWidth,
|
|
163
|
-
maxHeight: props.maxHeight,
|
|
164
|
-
strength: props.strength,
|
|
165
|
-
});
|
|
166
|
-
layout.addGuide(guide);
|
|
167
|
-
guidesFor(layout).set(props.id, guide);
|
|
168
|
-
|
|
169
|
-
return () => {
|
|
170
|
-
guidesFor(layout).delete(props.id);
|
|
171
|
-
if (isLayoutLive(layout)) layout.removeGuide(guide);
|
|
172
|
-
};
|
|
173
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
import { GtkConstraintLayout } from "@gtkx/jsx/gtk";
|
|
3
|
-
import { useMergeRefs } from "@gtkx/react/internal";
|
|
4
|
-
import {
|
|
5
|
-
type Context,
|
|
6
|
-
createContext,
|
|
7
|
-
type ReactNode,
|
|
8
|
-
type Ref,
|
|
9
|
-
type RefObject,
|
|
10
|
-
useContext,
|
|
11
|
-
useEffect,
|
|
12
|
-
useLayoutEffect,
|
|
13
|
-
useRef,
|
|
14
|
-
} from "react";
|
|
15
|
-
import {
|
|
16
|
-
applyConstraint,
|
|
17
|
-
applyGuide,
|
|
18
|
-
applyVfl,
|
|
19
|
-
type ConstraintGuideProps,
|
|
20
|
-
type ConstraintProps,
|
|
21
|
-
type ConstraintVflProps,
|
|
22
|
-
} from "./constraint-layout-apply.js";
|
|
23
|
-
|
|
24
|
-
const ORPHAN_MESSAGE = "<ConstraintLayout.Constraint> / <Guide> / <Vfl> must be a child of <ConstraintLayout>";
|
|
25
|
-
|
|
26
|
-
const ConstraintLayoutContext: Context<RefObject<Gtk.ConstraintLayout | null> | null> =
|
|
27
|
-
createContext<RefObject<Gtk.ConstraintLayout | null> | null>(null);
|
|
28
|
-
|
|
29
|
-
const useConstraintLayoutRef = (): RefObject<Gtk.ConstraintLayout | null> => {
|
|
30
|
-
const ref = useContext(ConstraintLayoutContext);
|
|
31
|
-
if (!ref) throw new Error(ORPHAN_MESSAGE);
|
|
32
|
-
return ref;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/** Props for {@link ConstraintLayout}. */
|
|
36
|
-
export type ConstraintLayoutProps = {
|
|
37
|
-
children?: ReactNode;
|
|
38
|
-
ref?: Ref<Gtk.ConstraintLayout | null>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type ContributionCleanupRef = { current: (() => void) | null };
|
|
42
|
-
|
|
43
|
-
const cleanupContribution = (cleanupRef: ContributionCleanupRef): void => {
|
|
44
|
-
const cleanup = cleanupRef.current;
|
|
45
|
-
if (!cleanup) return;
|
|
46
|
-
cleanupRef.current = null;
|
|
47
|
-
cleanup();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const useLayoutContribution = (apply: (layout: Gtk.ConstraintLayout) => () => void, deps: unknown[]): void => {
|
|
51
|
-
const layoutRef = useConstraintLayoutRef();
|
|
52
|
-
useLayoutEffect(() => {
|
|
53
|
-
const layout = layoutRef.current;
|
|
54
|
-
if (!layout) return;
|
|
55
|
-
return apply(layout);
|
|
56
|
-
}, deps);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const useDeferredContribution = (apply: (layout: Gtk.ConstraintLayout) => () => void, deps: unknown[]): void => {
|
|
60
|
-
const layoutRef = useConstraintLayoutRef();
|
|
61
|
-
const cleanupRef = useRef<(() => void) | null>(null);
|
|
62
|
-
|
|
63
|
-
useLayoutEffect(() => () => cleanupContribution(cleanupRef), deps);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
const layout = layoutRef.current;
|
|
67
|
-
if (!layout) return;
|
|
68
|
-
const cleanup = apply(layout);
|
|
69
|
-
cleanupRef.current = cleanup;
|
|
70
|
-
return () => {
|
|
71
|
-
if (cleanupRef.current === cleanup) cleanupContribution(cleanupRef);
|
|
72
|
-
};
|
|
73
|
-
}, deps);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Installs a Gtk.ConstraintLayout on a host widget and exposes child components to
|
|
78
|
-
* populate it: {@link ConstraintProps | ConstraintLayout.Constraint} for individual constraints,
|
|
79
|
-
* {@link ConstraintGuideProps | ConstraintLayout.Guide} for spacing guides, and {@link ConstraintVflProps | ConstraintLayout.Vfl}
|
|
80
|
-
* for constraints authored in the Visual Format Language.
|
|
81
|
-
*/
|
|
82
|
-
export const ConstraintLayout: ((props: ConstraintLayoutProps) => ReactNode) & {
|
|
83
|
-
Guide: (props: ConstraintGuideProps) => ReactNode;
|
|
84
|
-
Constraint: (props: ConstraintProps) => ReactNode;
|
|
85
|
-
Vfl: (props: ConstraintVflProps) => ReactNode;
|
|
86
|
-
} = Object.assign(
|
|
87
|
-
({ children, ref }: ConstraintLayoutProps): ReactNode => {
|
|
88
|
-
const layoutRef = useRef<Gtk.ConstraintLayout | null>(null);
|
|
89
|
-
const mergedRef = useMergeRefs<Gtk.ConstraintLayout>(ref, layoutRef);
|
|
90
|
-
return (
|
|
91
|
-
<>
|
|
92
|
-
<GtkConstraintLayout ref={mergedRef} />
|
|
93
|
-
<ConstraintLayoutContext.Provider value={layoutRef}>{children}</ConstraintLayoutContext.Provider>
|
|
94
|
-
</>
|
|
95
|
-
);
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
Guide: (props: ConstraintGuideProps): ReactNode => {
|
|
99
|
-
useLayoutContribution(
|
|
100
|
-
(layout) => applyGuide(layout, props),
|
|
101
|
-
[
|
|
102
|
-
props.id,
|
|
103
|
-
props.minWidth,
|
|
104
|
-
props.minHeight,
|
|
105
|
-
props.natWidth,
|
|
106
|
-
props.natHeight,
|
|
107
|
-
props.maxWidth,
|
|
108
|
-
props.maxHeight,
|
|
109
|
-
props.strength,
|
|
110
|
-
],
|
|
111
|
-
);
|
|
112
|
-
return null;
|
|
113
|
-
},
|
|
114
|
-
Constraint: (props: ConstraintProps): ReactNode => {
|
|
115
|
-
useDeferredContribution(
|
|
116
|
-
(layout) => applyConstraint(layout, props),
|
|
117
|
-
[
|
|
118
|
-
props.target,
|
|
119
|
-
props.targetAttribute,
|
|
120
|
-
props.relation,
|
|
121
|
-
props.source,
|
|
122
|
-
props.sourceAttribute,
|
|
123
|
-
props.multiplier,
|
|
124
|
-
props.constant,
|
|
125
|
-
props.strength,
|
|
126
|
-
],
|
|
127
|
-
);
|
|
128
|
-
return null;
|
|
129
|
-
},
|
|
130
|
-
Vfl: (props: ConstraintVflProps): ReactNode => {
|
|
131
|
-
useDeferredContribution((layout) => applyVfl(layout, props), [props.lines, props.hspacing, props.vspacing]);
|
|
132
|
-
return null;
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
);
|
package/src/fixed.tsx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import * as Graphene from "@gtkx/gi/graphene";
|
|
2
|
-
import * as Gsk from "@gtkx/gi/gsk";
|
|
3
|
-
import type * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
-
import { GtkFixed, type GtkFixedProps } from "@gtkx/jsx/gtk";
|
|
5
|
-
import { useMergeRefs } from "@gtkx/react/internal";
|
|
6
|
-
import {
|
|
7
|
-
createContext,
|
|
8
|
-
type ElementType,
|
|
9
|
-
type ReactNode,
|
|
10
|
-
type Ref,
|
|
11
|
-
type RefCallback,
|
|
12
|
-
useCallback,
|
|
13
|
-
useContext,
|
|
14
|
-
useLayoutEffect,
|
|
15
|
-
useRef,
|
|
16
|
-
useState,
|
|
17
|
-
} from "react";
|
|
18
|
-
import type { ChildProps } from "./types.js";
|
|
19
|
-
|
|
20
|
-
const FixedContext = createContext<Gtk.Fixed | null | undefined>(undefined);
|
|
21
|
-
|
|
22
|
-
const useFixedInstance = (): Gtk.Fixed | null => {
|
|
23
|
-
const fixed = useContext(FixedContext);
|
|
24
|
-
if (fixed === undefined) throw new Error("<Fixed.Child> must be a child of <Fixed>");
|
|
25
|
-
return fixed;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/** Props for {@link Fixed}. */
|
|
29
|
-
export type FixedProps = GtkFixedProps & { ref?: Ref<Gtk.Fixed | null>; children?: ReactNode };
|
|
30
|
-
|
|
31
|
-
export type FixedPlacementProps = {
|
|
32
|
-
x?: number | null | undefined;
|
|
33
|
-
y?: number | null | undefined;
|
|
34
|
-
/** Full transform applied to the child, overriding x and y when provided. */
|
|
35
|
-
transform?: Gsk.Transform | null | undefined;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/** Positions a single child inside a {@link Fixed} at coordinates x and y, or by an explicit transform. */
|
|
39
|
-
export type FixedChildProps<C extends ElementType> = ChildProps<C, FixedPlacementProps>;
|
|
40
|
-
|
|
41
|
-
const transformOf = (x: number, y: number, transform: Gsk.Transform | null | undefined): Gsk.Transform | null =>
|
|
42
|
-
transform !== undefined ? transform : Gsk.Transform.new().translate(Graphene.Point.create(x, y));
|
|
43
|
-
|
|
44
|
-
const FixedChild = <C extends ElementType>({
|
|
45
|
-
component,
|
|
46
|
-
x,
|
|
47
|
-
y,
|
|
48
|
-
transform,
|
|
49
|
-
ref,
|
|
50
|
-
...rest
|
|
51
|
-
}: FixedChildProps<C>): ReactNode => {
|
|
52
|
-
const fixed = useFixedInstance();
|
|
53
|
-
const Component: ElementType = component;
|
|
54
|
-
const widgetRef = useRef<Gtk.Widget | null>(null);
|
|
55
|
-
const captureWidget = useCallback<RefCallback<Gtk.Widget>>((node) => {
|
|
56
|
-
widgetRef.current = node;
|
|
57
|
-
}, []);
|
|
58
|
-
const setWidget = useMergeRefs<Gtk.Widget>(ref, captureWidget);
|
|
59
|
-
|
|
60
|
-
useLayoutEffect(() => {
|
|
61
|
-
const widget = widgetRef.current;
|
|
62
|
-
if (widget === null || fixed === null) return;
|
|
63
|
-
fixed.setChildTransform(widget, transformOf(x ?? 0, y ?? 0, transform));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return <Component {...rest} ref={setWidget} />;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Renders a Gtk.Fixed container whose children are placed at explicit positions via
|
|
71
|
-
* {@link Fixed.Child}.
|
|
72
|
-
*/
|
|
73
|
-
export const Fixed: ((props: FixedProps) => ReactNode) & {
|
|
74
|
-
Child: <C extends ElementType>(props: FixedChildProps<C>) => ReactNode;
|
|
75
|
-
} = Object.assign(
|
|
76
|
-
({ children, ref, ...rest }: FixedProps): ReactNode => {
|
|
77
|
-
const [fixed, setFixed] = useState<Gtk.Fixed | null>(null);
|
|
78
|
-
const mergedRef = useMergeRefs<Gtk.Fixed>(ref, setFixed);
|
|
79
|
-
return (
|
|
80
|
-
<GtkFixed {...rest} ref={mergedRef}>
|
|
81
|
-
<FixedContext.Provider value={fixed}>{children}</FixedContext.Provider>
|
|
82
|
-
</GtkFixed>
|
|
83
|
-
);
|
|
84
|
-
},
|
|
85
|
-
{ Child: FixedChild },
|
|
86
|
-
);
|
package/src/grid.tsx
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
import { GtkGrid, type GtkGridProps } from "@gtkx/jsx/gtk";
|
|
3
|
-
import { useMergeRefs } from "@gtkx/react/internal";
|
|
4
|
-
import { Children, type ElementType, type ReactNode, type Ref, useRef } from "react";
|
|
5
|
-
import { createParentContext, usePlacedChild } from "./hooks/use-placed-child.js";
|
|
6
|
-
import type { ChildProps } from "./types.js";
|
|
7
|
-
|
|
8
|
-
const { Context: GridContext, useParentRef: useGridRef } = createParentContext<Gtk.Grid>(
|
|
9
|
-
"<Grid.Child> must be a child of <Grid>",
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
/** Props for {@link Grid}. */
|
|
13
|
-
export type GridProps = GtkGridProps & { ref?: Ref<Gtk.Grid | null>; children?: ReactNode };
|
|
14
|
-
|
|
15
|
-
export type GridPlacement = {
|
|
16
|
-
column?: number | null | undefined;
|
|
17
|
-
row?: number | null | undefined;
|
|
18
|
-
/** Number of columns the child spans (defaults to 1). */
|
|
19
|
-
columnSpan?: number | null | undefined;
|
|
20
|
-
/** Number of rows the child spans (defaults to 1). */
|
|
21
|
-
rowSpan?: number | null | undefined;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/** Places a single child inside a {@link Grid} at a column and row, optionally spanning multiple cells. */
|
|
25
|
-
export type GridChildProps<C extends ElementType> = ChildProps<C, GridPlacement>;
|
|
26
|
-
|
|
27
|
-
type Placement = { column: number; row: number; columnSpan: number; rowSpan: number };
|
|
28
|
-
|
|
29
|
-
const placementOf = (props: GridPlacement): Placement => ({
|
|
30
|
-
column: props.column ?? 0,
|
|
31
|
-
row: props.row ?? 0,
|
|
32
|
-
columnSpan: props.columnSpan ?? 1,
|
|
33
|
-
rowSpan: props.rowSpan ?? 1,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const samePlacement = (a: Placement, b: Placement): boolean =>
|
|
37
|
-
a.column === b.column && a.row === b.row && a.columnSpan === b.columnSpan && a.rowSpan === b.rowSpan;
|
|
38
|
-
|
|
39
|
-
const GridChild = <C extends ElementType>({
|
|
40
|
-
component,
|
|
41
|
-
column,
|
|
42
|
-
row,
|
|
43
|
-
columnSpan,
|
|
44
|
-
rowSpan,
|
|
45
|
-
ref,
|
|
46
|
-
...rest
|
|
47
|
-
}: GridChildProps<C>): ReactNode => {
|
|
48
|
-
const gridRef = useGridRef();
|
|
49
|
-
const Component: ElementType = component;
|
|
50
|
-
return usePlacedChild<Gtk.Widget, Placement>({
|
|
51
|
-
render: (placeRef) => <Component {...rest} ref={placeRef} />,
|
|
52
|
-
ref,
|
|
53
|
-
placement: placementOf({ column, row, columnSpan, rowSpan }),
|
|
54
|
-
samePlacement,
|
|
55
|
-
place: (widget, placement, previous) => {
|
|
56
|
-
const grid = gridRef.current;
|
|
57
|
-
if (!grid) return;
|
|
58
|
-
if (previous !== undefined && widget.getParent() === grid) grid.remove(widget);
|
|
59
|
-
if (widget.getParent() !== grid) {
|
|
60
|
-
grid.attach(widget, placement.column, placement.row, placement.columnSpan, placement.rowSpan);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
release: (widget) => {
|
|
64
|
-
const grid = gridRef.current;
|
|
65
|
-
if (grid && widget.getParent() === grid) grid.remove(widget);
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Renders a Gtk.Grid whose children are attached at explicit column/row positions via
|
|
72
|
-
* {@link Grid.Child}.
|
|
73
|
-
*/
|
|
74
|
-
export const Grid: ((props: GridProps) => ReactNode) & {
|
|
75
|
-
Child: <C extends ElementType>(props: GridChildProps<C>) => ReactNode;
|
|
76
|
-
} = Object.assign(
|
|
77
|
-
({ children, ref, ...rest }: GridProps): ReactNode => {
|
|
78
|
-
const gridRef = useRef<Gtk.Grid | null>(null);
|
|
79
|
-
const mergedRef = useMergeRefs<Gtk.Grid>(ref, gridRef);
|
|
80
|
-
return (
|
|
81
|
-
<>
|
|
82
|
-
<GtkGrid {...rest} ref={mergedRef} />
|
|
83
|
-
<GridContext.Provider value={gridRef}>{Children.toArray(children)}</GridContext.Provider>
|
|
84
|
-
</>
|
|
85
|
-
);
|
|
86
|
-
},
|
|
87
|
-
{ Child: GridChild },
|
|
88
|
-
);
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
-
import { type ObjectProp, useObjectAttachment } from "@gtkx/react/internal";
|
|
4
|
-
import { useRef } from "react";
|
|
5
|
-
import { CellContainerStore } from "../utils/cell-container-store.js";
|
|
6
|
-
|
|
7
|
-
type ChildContainer = {
|
|
8
|
-
getChild(): Gtk.Widget | null;
|
|
9
|
-
setChild(child: Gtk.Widget | null): void;
|
|
10
|
-
getItem(): GObject.Object | null;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const isChildContainer = (container: GObject.Object): container is GObject.Object & ChildContainer =>
|
|
14
|
-
container instanceof Gtk.ListItem || container instanceof Gtk.ListHeader;
|
|
15
|
-
|
|
16
|
-
const positionOf = (container: GObject.Object & ChildContainer): number => {
|
|
17
|
-
if (container instanceof Gtk.ListItem) return container.getPosition();
|
|
18
|
-
if (container instanceof Gtk.ListHeader) return container.getStart();
|
|
19
|
-
return -1;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type FactoryInstaller<W extends GObject.Object> = {
|
|
23
|
-
install(widget: W, factory: Gtk.SignalListItemFactory): void;
|
|
24
|
-
uninstall(widget: W): void;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const makeFactoryInstaller = <W extends GObject.Object>(
|
|
28
|
-
setFactory: (widget: W, factory: Gtk.SignalListItemFactory | null) => void,
|
|
29
|
-
): FactoryInstaller<W> => ({
|
|
30
|
-
install: (widget, factory) => setFactory(widget, factory),
|
|
31
|
-
uninstall: (widget) => setFactory(widget, null),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
type CellContainersOptions<W extends GObject.Object> = {
|
|
35
|
-
object: ObjectProp<W>;
|
|
36
|
-
installer: FactoryInstaller<W>;
|
|
37
|
-
estimatedHeight?: number | undefined;
|
|
38
|
-
estimatedWidth?: number | undefined;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const applyEstimatedSize = (child: Gtk.Widget, height: number | undefined, width: number | undefined): void => {
|
|
42
|
-
if (height === undefined && width === undefined) return;
|
|
43
|
-
child.setSizeRequest(width ?? -1, height ?? -1);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const useCellContainers = <W extends GObject.Object>(options: CellContainersOptions<W>): CellContainerStore => {
|
|
47
|
-
const { object, installer, estimatedHeight, estimatedWidth } = options;
|
|
48
|
-
const storeRef = useRef<CellContainerStore | null>(null);
|
|
49
|
-
if (storeRef.current === null) storeRef.current = new CellContainerStore();
|
|
50
|
-
const store = storeRef.current;
|
|
51
|
-
|
|
52
|
-
const installerRef = useRef(installer);
|
|
53
|
-
installerRef.current = installer;
|
|
54
|
-
|
|
55
|
-
const factoryRef = useRef<Gtk.SignalListItemFactory | null>(null);
|
|
56
|
-
if (factoryRef.current === null) {
|
|
57
|
-
const factory = Gtk.SignalListItemFactory.new();
|
|
58
|
-
factory.on("setup", (container) => {
|
|
59
|
-
if (isChildContainer(container) && container.getChild() === null) {
|
|
60
|
-
const placeholder = new Gtk.Box();
|
|
61
|
-
applyEstimatedSize(placeholder, estimatedHeight, estimatedWidth);
|
|
62
|
-
container.setChild(placeholder);
|
|
63
|
-
}
|
|
64
|
-
store.addContainer(container);
|
|
65
|
-
});
|
|
66
|
-
factory.on("bind", (container) => {
|
|
67
|
-
if (isChildContainer(container)) {
|
|
68
|
-
const item = container.getItem();
|
|
69
|
-
const treeRow = item instanceof Gtk.TreeListRow ? item : null;
|
|
70
|
-
store.bind(container, positionOf(container), treeRow);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
factory.on("unbind", (container) => {
|
|
74
|
-
store.unbind(container);
|
|
75
|
-
});
|
|
76
|
-
factory.on("teardown", (container) => {
|
|
77
|
-
store.removeContainer(container);
|
|
78
|
-
});
|
|
79
|
-
factoryRef.current = factory;
|
|
80
|
-
}
|
|
81
|
-
const factory = factoryRef.current;
|
|
82
|
-
|
|
83
|
-
useObjectAttachment<W, { widget: W }>(object, {
|
|
84
|
-
attach: (widget) => {
|
|
85
|
-
installerRef.current.install(widget, factory);
|
|
86
|
-
return { widget };
|
|
87
|
-
},
|
|
88
|
-
detach: (attachment) => installerRef.current.uninstall(attachment.widget),
|
|
89
|
-
isSame: (attachment, widget) => attachment.widget === widget,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return store;
|
|
93
|
-
};
|