@gtkx/components 0.21.0 → 1.0.0-rc.1
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/LICENSE +373 -0
- package/README.md +173 -0
- package/dist/cell.d.ts +30 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +45 -0
- package/dist/cell.js.map +1 -0
- package/dist/column-view-column.d.ts +24 -14
- package/dist/column-view-column.d.ts.map +1 -1
- package/dist/column-view-column.js +19 -40
- package/dist/column-view-column.js.map +1 -1
- package/dist/column-view.d.ts +25 -11
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +53 -83
- package/dist/column-view.js.map +1 -1
- package/dist/constraint-layout-apply.d.ts +50 -1
- package/dist/constraint-layout-apply.d.ts.map +1 -1
- package/dist/constraint-layout-apply.js.map +1 -1
- package/dist/constraint-layout.d.ts +8 -1
- package/dist/constraint-layout.d.ts.map +1 -1
- package/dist/constraint-layout.js +12 -9
- package/dist/constraint-layout.js.map +1 -1
- package/dist/drop-down.d.ts +26 -36
- package/dist/drop-down.d.ts.map +1 -1
- package/dist/drop-down.js +47 -87
- package/dist/drop-down.js.map +1 -1
- package/dist/fixed.d.ts +26 -0
- package/dist/fixed.d.ts.map +1 -0
- package/dist/fixed.js +40 -0
- package/dist/fixed.js.map +1 -0
- package/dist/grid-view.d.ts +13 -10
- package/dist/grid-view.d.ts.map +1 -1
- package/dist/grid-view.js +30 -16
- package/dist/grid-view.js.map +1 -1
- package/dist/grid.d.ts +27 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +48 -0
- package/dist/grid.js.map +1 -0
- package/dist/hooks/use-cell-containers.d.ts +18 -0
- package/dist/hooks/use-cell-containers.d.ts.map +1 -0
- package/dist/hooks/{use-realized-slots.js → use-cell-containers.js} +18 -17
- package/dist/hooks/use-cell-containers.js.map +1 -0
- package/dist/hooks/use-collection-model.d.ts +26 -0
- package/dist/hooks/use-collection-model.d.ts.map +1 -0
- package/dist/hooks/use-collection-model.js +35 -0
- package/dist/hooks/use-collection-model.js.map +1 -0
- package/dist/hooks/use-collection-widget.d.ts +28 -0
- package/dist/hooks/use-collection-widget.d.ts.map +1 -0
- package/dist/hooks/use-collection-widget.js +21 -0
- package/dist/hooks/use-collection-widget.js.map +1 -0
- package/dist/hooks/use-drop-down-selection.d.ts +7 -6
- package/dist/hooks/use-drop-down-selection.d.ts.map +1 -1
- package/dist/hooks/use-drop-down-selection.js +6 -6
- package/dist/hooks/use-drop-down-selection.js.map +1 -1
- package/dist/hooks/use-expansion-model.d.ts +12 -0
- package/dist/hooks/use-expansion-model.d.ts.map +1 -0
- package/dist/hooks/use-expansion-model.js +71 -0
- package/dist/hooks/use-expansion-model.js.map +1 -0
- package/dist/hooks/use-header-menu.d.ts.map +1 -1
- package/dist/hooks/use-header-menu.js +12 -24
- package/dist/hooks/use-header-menu.js.map +1 -1
- package/dist/hooks/use-installed-model.d.ts +4 -0
- package/dist/hooks/use-installed-model.d.ts.map +1 -0
- package/dist/hooks/use-installed-model.js +15 -0
- package/dist/hooks/use-installed-model.js.map +1 -0
- package/dist/hooks/use-list-model.d.ts +14 -15
- package/dist/hooks/use-list-model.d.ts.map +1 -1
- package/dist/hooks/use-list-model.js +61 -34
- package/dist/hooks/use-list-model.js.map +1 -1
- package/dist/hooks/use-placed-child.d.ts +18 -0
- package/dist/hooks/use-placed-child.d.ts.map +1 -0
- package/dist/hooks/use-placed-child.js +47 -0
- package/dist/hooks/use-placed-child.js.map +1 -0
- package/dist/hooks/use-selection-model.d.ts +4 -3
- package/dist/hooks/use-selection-model.d.ts.map +1 -1
- package/dist/hooks/use-selection-model.js +8 -16
- package/dist/hooks/use-selection-model.js.map +1 -1
- package/dist/hooks/use-sort-handler.d.ts +10 -5
- package/dist/hooks/use-sort-handler.d.ts.map +1 -1
- package/dist/hooks/use-sort-handler.js +2 -2
- package/dist/hooks/use-sort-handler.js.map +1 -1
- package/dist/index.d.ts +11 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -13
- package/dist/index.js.map +1 -1
- package/dist/list-view.d.ts +17 -9
- package/dist/list-view.d.ts.map +1 -1
- package/dist/list-view.js +49 -24
- package/dist/list-view.js.map +1 -1
- package/dist/menu-items.d.ts.map +1 -1
- package/dist/menu-items.js.map +1 -1
- package/dist/menu.d.ts +6 -10
- package/dist/menu.d.ts.map +1 -1
- package/dist/menu.js +7 -9
- package/dist/menu.js.map +1 -1
- package/dist/overlay.d.ts +24 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +49 -0
- package/dist/overlay.js.map +1 -0
- package/dist/size-group.d.ts +20 -0
- package/dist/size-group.d.ts.map +1 -0
- package/dist/size-group.js +57 -0
- package/dist/size-group.js.map +1 -0
- package/dist/types.d.ts +43 -173
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/{realized-slot-store.d.ts → cell-container-store.d.ts} +7 -9
- package/dist/utils/cell-container-store.d.ts.map +1 -0
- package/dist/utils/{realized-slot-store.js → cell-container-store.js} +9 -14
- package/dist/utils/cell-container-store.js.map +1 -0
- package/dist/utils/item-models.d.ts +10 -0
- package/dist/utils/item-models.d.ts.map +1 -0
- package/dist/utils/{position-only-model.js → item-models.js} +13 -14
- package/dist/utils/item-models.js.map +1 -0
- package/dist/utils/item-resolver.d.ts +14 -17
- package/dist/utils/item-resolver.d.ts.map +1 -1
- package/dist/utils/item-resolver.js +34 -43
- package/dist/utils/item-resolver.js.map +1 -1
- package/dist/utils/list-item-flatten.d.ts +16 -24
- package/dist/utils/list-item-flatten.d.ts.map +1 -1
- package/dist/utils/list-item-flatten.js +16 -36
- package/dist/utils/list-item-flatten.js.map +1 -1
- package/package.json +52 -53
- package/src/cell.tsx +144 -0
- package/src/column-view-column.tsx +57 -48
- package/src/column-view.tsx +130 -146
- package/src/constraint-layout-apply.ts +53 -1
- package/src/constraint-layout.tsx +18 -13
- package/src/drop-down.tsx +129 -196
- package/src/fixed.tsx +86 -0
- package/src/grid-view.tsx +52 -44
- package/src/grid.tsx +88 -0
- package/src/hooks/{use-realized-slots.ts → use-cell-containers.ts} +30 -30
- package/src/hooks/use-collection-model.ts +60 -0
- package/src/hooks/use-collection-widget.ts +47 -0
- package/src/hooks/use-drop-down-selection.ts +12 -13
- package/src/hooks/use-expansion-model.ts +82 -0
- package/src/hooks/use-header-menu.ts +24 -23
- package/src/hooks/use-installed-model.ts +20 -0
- package/src/hooks/use-list-model.ts +103 -87
- package/src/hooks/use-placed-child.ts +79 -0
- package/src/hooks/use-selection-model.ts +11 -18
- package/src/hooks/use-sort-handler.ts +13 -8
- package/src/index.ts +25 -27
- package/src/list-view.tsx +120 -57
- package/src/menu.tsx +12 -14
- package/src/overlay.tsx +88 -0
- package/src/size-group.tsx +96 -0
- package/src/types.ts +55 -206
- package/src/utils/{realized-slot-store.ts → cell-container-store.ts} +13 -25
- package/src/utils/{position-only-model.ts → item-models.ts} +26 -28
- package/src/utils/item-resolver.ts +54 -59
- package/src/utils/list-item-flatten.ts +33 -56
- package/dist/collection-view.d.ts +0 -30
- package/dist/collection-view.d.ts.map +0 -1
- package/dist/collection-view.js +0 -52
- package/dist/collection-view.js.map +0 -1
- package/dist/contexts/column-view-context.d.ts +0 -17
- package/dist/contexts/column-view-context.d.ts.map +0 -1
- package/dist/contexts/column-view-context.js +0 -10
- package/dist/contexts/column-view-context.js.map +0 -1
- package/dist/hooks/use-model-installation.d.ts +0 -9
- package/dist/hooks/use-model-installation.d.ts.map +0 -1
- package/dist/hooks/use-model-installation.js +0 -20
- package/dist/hooks/use-model-installation.js.map +0 -1
- package/dist/hooks/use-realized-slots.d.ts +0 -20
- package/dist/hooks/use-realized-slots.d.ts.map +0 -1
- package/dist/hooks/use-realized-slots.js.map +0 -1
- package/dist/list-portal-host.d.ts +0 -11
- package/dist/list-portal-host.d.ts.map +0 -1
- package/dist/list-portal-host.js +0 -8
- package/dist/list-portal-host.js.map +0 -1
- package/dist/list-slot.d.ts +0 -14
- package/dist/list-slot.d.ts.map +0 -1
- package/dist/list-slot.js +0 -29
- package/dist/list-slot.js.map +0 -1
- package/dist/utils/position-only-model.d.ts +0 -10
- package/dist/utils/position-only-model.d.ts.map +0 -1
- package/dist/utils/position-only-model.js.map +0 -1
- package/dist/utils/realized-slot-store.d.ts.map +0 -1
- package/dist/utils/realized-slot-store.js.map +0 -1
- package/src/collection-view.tsx +0 -125
- package/src/contexts/column-view-context.ts +0 -28
- package/src/hooks/use-model-installation.ts +0 -25
- package/src/list-portal-host.tsx +0 -27
- package/src/list-slot.tsx +0 -56
|
@@ -1,17 +1,27 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/gi/gtk";
|
|
1
2
|
import { type GtkColumnViewColumnProps } from "@gtkx/jsx/gtk";
|
|
2
3
|
import { type ReactNode } from "react";
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
import { type TreeRenderContext } from "./cell.js";
|
|
5
|
+
import type { RenderItemProps } from "./types.js";
|
|
6
|
+
import type { ItemResolver } from "./utils/item-resolver.js";
|
|
7
|
+
export type ColumnDefDeclarativeProps<T = unknown> = {
|
|
8
|
+
title: string;
|
|
9
|
+
expand?: boolean | undefined;
|
|
10
|
+
resizable?: boolean | undefined;
|
|
11
|
+
fixedWidth?: number | undefined;
|
|
12
|
+
id: string;
|
|
13
|
+
sortable?: boolean | undefined;
|
|
14
|
+
visible?: boolean | undefined;
|
|
15
|
+
renderCell: (props: RenderItemProps<T>) => ReactNode;
|
|
16
|
+
headerMenu?: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
export type ColumnDef<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" | "sorter"> & ColumnDefDeclarativeProps<T>;
|
|
19
|
+
type ColumnViewColumnProps<T = unknown> = ColumnDef<T> & {
|
|
20
|
+
resolver: ItemResolver<unknown, unknown>;
|
|
21
|
+
tree: TreeRenderContext;
|
|
22
|
+
estimatedItemHeight?: number | undefined;
|
|
23
|
+
onInstance: (id: string, column: Gtk.ColumnViewColumn | null) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare const ColumnViewColumn: <T = unknown>(props: ColumnViewColumnProps<T>) => ReactNode;
|
|
26
|
+
export {};
|
|
17
27
|
//# sourceMappingURL=column-view-column.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-view-column.d.ts","sourceRoot":"","sources":["../src/column-view-column.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"column-view-column.d.ts","sourceRoot":"","sources":["../src/column-view-column.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAuB,KAAK,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEnF,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,OAAO,IAAI;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACrD,UAAU,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,IAAI,CAAC,wBAAwB,EAAE,SAAS,GAAG,QAAQ,CAAC,GACrF,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAEjC,KAAK,qBAAqB,CAAC,CAAC,GAAG,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG;IACrD,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,IAAI,EAAE,iBAAiB,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;CACzE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,GAAG,OAAO,SAAS,qBAAqB,CAAC,CAAC,CAAC,KAAG,SA+C/E,CAAC"}
|
|
@@ -1,51 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { GtkColumnViewColumn } from "@gtkx/jsx/gtk";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useMergeRefs } from "@gtkx/react/internal";
|
|
4
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
5
|
+
import { CellRenderHost, itemRenderer } from "./cell.js";
|
|
6
|
+
import { makeFactoryInstaller, useCellContainers } from "./hooks/use-cell-containers.js";
|
|
5
7
|
import { useHeaderMenu } from "./hooks/use-header-menu.js";
|
|
6
|
-
|
|
7
|
-
import { ListPortalHost } from "./list-portal-host.js";
|
|
8
|
-
const factoryBinding = {
|
|
9
|
-
install: (column, factory) => column.setFactory(factory),
|
|
10
|
-
uninstall: (column) => column.setFactory(null),
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* A single column of a {@link ColumnView}, rendering each row's cell through
|
|
14
|
-
* the declarative `renderCell` callback and optionally attaching a header
|
|
15
|
-
* context menu.
|
|
16
|
-
*/
|
|
8
|
+
const factoryInstaller = makeFactoryInstaller((column, factory) => column.setFactory(factory));
|
|
17
9
|
export const ColumnViewColumn = (props) => {
|
|
18
|
-
const { id, title,
|
|
19
|
-
const context = useColumnViewContext();
|
|
10
|
+
const { id, title, sortable, renderCell, headerMenu, resolver, tree, estimatedItemHeight, onInstance, ref, ...intrinsicProps } = props;
|
|
20
11
|
const [column, setColumn] = useState(null);
|
|
21
|
-
const captureColumn =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
binding: factoryBinding,
|
|
12
|
+
const captureColumn = useMergeRefs(ref, setColumn);
|
|
13
|
+
const store = useCellContainers({
|
|
14
|
+
object: column,
|
|
15
|
+
installer: factoryInstaller,
|
|
16
|
+
estimatedHeight: estimatedItemHeight,
|
|
27
17
|
});
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const unregisterRef = useRef(context.unregister);
|
|
31
|
-
unregisterRef.current = context.unregister;
|
|
18
|
+
const onInstanceRef = useRef(onInstance);
|
|
19
|
+
onInstanceRef.current = onInstance;
|
|
32
20
|
useLayoutEffect(() => {
|
|
33
21
|
if (column === null)
|
|
34
22
|
return;
|
|
35
|
-
|
|
36
|
-
return () =>
|
|
37
|
-
}, [column, id
|
|
23
|
+
onInstanceRef.current(id, column);
|
|
24
|
+
return () => onInstanceRef.current(id, null);
|
|
25
|
+
}, [column, id]);
|
|
38
26
|
const headerMenuPortal = useHeaderMenu(column, headerMenu);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
if (expand !== undefined)
|
|
42
|
-
intrinsicProps["expand"] = expand;
|
|
43
|
-
if (resizable !== undefined)
|
|
44
|
-
intrinsicProps["resizable"] = resizable;
|
|
45
|
-
if (fixedWidth !== undefined)
|
|
46
|
-
intrinsicProps["fixedWidth"] = fixedWidth;
|
|
47
|
-
if (visible !== undefined)
|
|
48
|
-
intrinsicProps["visible"] = visible;
|
|
49
|
-
return (_jsxs(_Fragment, { children: [createElement(GtkColumnViewColumn, intrinsicProps), _jsx(ListPortalHost, { store: store, resolver: context.resolver, render: slotRenderer }), headerMenuPortal] }));
|
|
27
|
+
const cellRenderer = itemRenderer((cellProps) => renderCell({ ...cellProps, item: cellProps.item }), tree);
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx(GtkColumnViewColumn, { ...intrinsicProps, id: id, title: title, ref: captureColumn }), _jsx(CellRenderHost, { store: store, resolver: resolver, render: cellRenderer }), headerMenuPortal] }));
|
|
50
29
|
};
|
|
51
30
|
//# sourceMappingURL=column-view-column.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-view-column.js","sourceRoot":"","sources":["../src/column-view-column.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAiC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"column-view-column.js","sourceRoot":"","sources":["../src/column-view-column.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAiC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAkB,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAqB,cAAc,EAAE,YAAY,EAA0B,MAAM,WAAW,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,MAAM,gBAAgB,GAAG,oBAAoB,CAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,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,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAI,EACrF,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,GAAI,EACzE,gBAAgB,IAClB,CACN,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkColumnViewColumn, type GtkColumnViewColumnProps } from \"@gtkx/jsx/gtk\";\nimport { useMergeRefs } from \"@gtkx/react/internal\";\nimport { type ReactNode, useLayoutEffect, useRef, useState } from \"react\";\nimport { type CellRenderer, CellRenderHost, itemRenderer, type TreeRenderContext } from \"./cell.js\";\nimport { makeFactoryInstaller, useCellContainers } from \"./hooks/use-cell-containers.js\";\nimport { useHeaderMenu } from \"./hooks/use-header-menu.js\";\nimport type { RenderItemProps } from \"./types.js\";\nimport type { ItemResolver } from \"./utils/item-resolver.js\";\n\nconst factoryInstaller = makeFactoryInstaller<Gtk.ColumnViewColumn>((column, factory) => column.setFactory(factory));\n\nexport type ColumnDefDeclarativeProps<T = unknown> = {\n title: string;\n expand?: boolean | undefined;\n resizable?: boolean | undefined;\n fixedWidth?: number | undefined;\n id: string;\n sortable?: boolean | undefined;\n visible?: boolean | undefined;\n renderCell: (props: RenderItemProps<T>) => ReactNode;\n headerMenu?: ReactNode;\n};\n\nexport type ColumnDef<T = unknown> = Omit<GtkColumnViewColumnProps, \"factory\" | \"sorter\"> &\n ColumnDefDeclarativeProps<T>;\n\ntype ColumnViewColumnProps<T = unknown> = ColumnDef<T> & {\n resolver: ItemResolver<unknown, unknown>;\n tree: TreeRenderContext;\n estimatedItemHeight?: number | undefined;\n onInstance: (id: string, column: Gtk.ColumnViewColumn | null) => void;\n};\n\nexport const ColumnViewColumn = <T = unknown>(props: ColumnViewColumnProps<T>): ReactNode => {\n const {\n id,\n title,\n sortable,\n renderCell,\n headerMenu,\n resolver,\n tree,\n estimatedItemHeight,\n onInstance,\n ref,\n ...intrinsicProps\n } = props as ColumnViewColumnProps<T> & { [key: string]: unknown };\n const [column, setColumn] = useState<Gtk.ColumnViewColumn | null>(null);\n\n const captureColumn = useMergeRefs<Gtk.ColumnViewColumn>(ref, setColumn);\n\n const store = useCellContainers<Gtk.ColumnViewColumn>({\n object: column,\n installer: factoryInstaller,\n estimatedHeight: estimatedItemHeight,\n });\n\n const onInstanceRef = useRef(onInstance);\n onInstanceRef.current = onInstance;\n\n useLayoutEffect(() => {\n if (column === null) return;\n onInstanceRef.current(id, column);\n return () => onInstanceRef.current(id, null);\n }, [column, id]);\n\n const headerMenuPortal = useHeaderMenu(column, headerMenu);\n\n const cellRenderer: CellRenderer<unknown, unknown> = itemRenderer<unknown, unknown>(\n (cellProps) => renderCell({ ...cellProps, item: cellProps.item as T }),\n tree,\n );\n\n return (\n <>\n <GtkColumnViewColumn {...intrinsicProps} id={id} title={title} ref={captureColumn} />\n <CellRenderHost store={store} resolver={resolver} render={cellRenderer} />\n {headerMenuPortal}\n </>\n );\n};\n"]}
|
package/dist/column-view.d.ts
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/gi/gtk";
|
|
1
2
|
import { type GtkColumnViewProps } from "@gtkx/jsx/gtk";
|
|
2
3
|
import { type ReactNode } from "react";
|
|
3
|
-
import type
|
|
4
|
+
import { type ColumnDef } from "./column-view-column.js";
|
|
5
|
+
import type { CollectionItemSizeProps, ControlledExpansionProps, ControlledSelectionProps, ItemNode, SectionNode } from "./types.js";
|
|
6
|
+
export type { ColumnDef, ColumnDefDeclarativeProps } from "./column-view-column.js";
|
|
7
|
+
export type ColumnViewSortProps = {
|
|
8
|
+
sortColumn?: string | null | undefined;
|
|
9
|
+
sortOrder?: Gtk.SortType | null | undefined;
|
|
10
|
+
onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type ColumnViewDeclarativeProps<T = unknown, S = unknown> = ColumnViewSortProps & Omit<CollectionItemSizeProps, "estimatedItemWidth"> & ControlledSelectionProps & ControlledExpansionProps & {
|
|
13
|
+
items?: ItemNode<T>[] | undefined;
|
|
14
|
+
sections?: SectionNode<S, T>[] | undefined;
|
|
15
|
+
renderHeader?: ((info: {
|
|
16
|
+
section: S;
|
|
17
|
+
}) => ReactNode) | null | undefined;
|
|
18
|
+
columns: ColumnDef<T>[];
|
|
19
|
+
};
|
|
4
20
|
/**
|
|
5
|
-
* Props for
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
21
|
+
* Props for {@link ColumnView}. Combines the underlying Gtk.ColumnView props with
|
|
22
|
+
* declarative collection props: flat items or grouped sections, controlled selection
|
|
23
|
+
* and expansion, sorting (sortColumn, sortOrder, onSortChanged), an optional section
|
|
24
|
+
* header renderer, and the columns to render.
|
|
9
25
|
*/
|
|
10
|
-
export type
|
|
26
|
+
export type ColumnViewProps<T = unknown, S = unknown> = Omit<GtkColumnViewProps, "columns" | "model" | "headerFactory" | keyof ColumnViewDeclarativeProps<T, S>> & ColumnViewDeclarativeProps<T, S>;
|
|
11
27
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* declared as {@link ColumnViewColumn} children. Supplying an external `model`
|
|
15
|
-
* switches to the uncontrolled form.
|
|
28
|
+
* Renders a Gtk.ColumnView: a multi-column, scrollable list backed by a collection
|
|
29
|
+
* model. Columns are declared through the columns prop, each a {@link ColumnDef}.
|
|
16
30
|
*/
|
|
17
|
-
export declare const ColumnView: <T = unknown, S = unknown>(props:
|
|
31
|
+
export declare const ColumnView: <T = unknown, S = unknown>(props: ColumnViewProps<T, S>) => ReactNode;
|
|
18
32
|
//# sourceMappingURL=column-view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-view.d.ts","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"column-view.d.ts","sourceRoot":"","sources":["../src/column-view.tsx"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AAC,CAAC,CAAC,EAAE,CAAC;CAC3B,CAAC;AAEN;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,IAAI,CACxD,kBAAkB,EAClB,SAAS,GAAG,OAAO,GAAG,eAAe,GAAG,MAAM,0BAA0B,CAAC,CAAC,EAAE,CAAC,CAAC,CACjF,GACG,0BAA0B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AA4FrC;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,SAAS,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,SA2CnF,CAAC"}
|
package/dist/column-view.js
CHANGED
|
@@ -1,108 +1,78 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { GtkColumnView } from "@gtkx/jsx/gtk";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { useRealizedSlots } from "./hooks/use-realized-slots.js";
|
|
9
|
-
import { useSelectionModel } from "./hooks/use-selection-model.js";
|
|
3
|
+
import { useCallback, useMemo, useState } from "react";
|
|
4
|
+
import { createTreeRenderContext, HeaderRenderHost } from "./cell.js";
|
|
5
|
+
import { ColumnViewColumn } from "./column-view-column.js";
|
|
6
|
+
import { makeFactoryInstaller, useCellContainers } from "./hooks/use-cell-containers.js";
|
|
7
|
+
import { useCollectionWidget } from "./hooks/use-collection-widget.js";
|
|
10
8
|
import { useSortHandler } from "./hooks/use-sort-handler.js";
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, []);
|
|
25
|
-
const unregister = useCallback((id) => {
|
|
26
|
-
setRegistrations((current) => {
|
|
27
|
-
if (!current.has(id))
|
|
9
|
+
const headerFactoryInstaller = makeFactoryInstaller((widget, factory) => widget.setHeaderFactory(factory));
|
|
10
|
+
const useColumnInstances = () => {
|
|
11
|
+
const [instances, setInstances] = useState(() => new Map());
|
|
12
|
+
const setInstance = useCallback((id, column) => {
|
|
13
|
+
setInstances((current) => {
|
|
14
|
+
if (column === null) {
|
|
15
|
+
if (!current.has(id))
|
|
16
|
+
return current;
|
|
17
|
+
const next = new Map(current);
|
|
18
|
+
next.delete(id);
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
if (current.get(id) === column)
|
|
28
22
|
return current;
|
|
29
23
|
const next = new Map(current);
|
|
30
|
-
next.
|
|
24
|
+
next.set(id, column);
|
|
31
25
|
return next;
|
|
32
26
|
});
|
|
33
27
|
}, []);
|
|
34
|
-
|
|
35
|
-
return { columns, register, unregister };
|
|
28
|
+
return { instances, setInstance };
|
|
36
29
|
};
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const installedModel = externalModel === undefined ? controlledSelection : externalModel;
|
|
54
|
-
useModelInstallation(widgetRef, installedModel, (widget, model) => widget.setModel(model));
|
|
55
|
-
const useHeader = externalModel === undefined && typeof props.renderHeader === "function";
|
|
56
|
-
const headers = useRealizedSlots({
|
|
57
|
-
target: useHeader ? widgetRef : null,
|
|
58
|
-
binding: headerFactoryBinding,
|
|
59
|
-
estimatedHeight: props.estimatedRowHeight ?? undefined,
|
|
30
|
+
const buildRegistrations = (columns, instances) => {
|
|
31
|
+
const result = [];
|
|
32
|
+
for (const column of columns) {
|
|
33
|
+
const instance = instances.get(column.id);
|
|
34
|
+
if (instance)
|
|
35
|
+
result.push({ id: column.id, column: instance, sortable: column.sortable ?? false });
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
const useColumnViewWiring = (props) => {
|
|
40
|
+
const { widgetRef, setRef, collection } = useCollectionWidget(props);
|
|
41
|
+
const useHeader = collection.useHeader;
|
|
42
|
+
const headerStore = useCellContainers({
|
|
43
|
+
object: useHeader ? widgetRef : null,
|
|
44
|
+
installer: headerFactoryInstaller,
|
|
45
|
+
estimatedHeight: props.estimatedItemHeight,
|
|
60
46
|
});
|
|
47
|
+
const { instances, setInstance } = useColumnInstances();
|
|
48
|
+
const registrations = useMemo(() => buildRegistrations(props.columns, instances), [props.columns, instances]);
|
|
61
49
|
useSortHandler({
|
|
62
50
|
columnView: widgetRef,
|
|
63
51
|
sortColumn: props.sortColumn,
|
|
64
52
|
sortOrder: props.sortOrder,
|
|
65
53
|
onSortChanged: props.onSortChanged,
|
|
66
|
-
columns:
|
|
54
|
+
columns: registrations,
|
|
67
55
|
});
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
resolver: listModel.resolver,
|
|
71
|
-
register: registry.register,
|
|
72
|
-
unregister: registry.unregister,
|
|
73
|
-
}), [listModel.resolver, registry.register, registry.unregister]);
|
|
56
|
+
const expandedIds = props.expandedIds;
|
|
57
|
+
const tree = useMemo(() => createTreeRenderContext(expandedIds, collection.rowId), [expandedIds, collection.rowId]);
|
|
74
58
|
return {
|
|
75
59
|
setRef,
|
|
76
|
-
resolver: listModel.resolver,
|
|
77
|
-
headerResolver: listModel.headerResolver,
|
|
78
|
-
headerStore: headers.store,
|
|
79
60
|
useHeader,
|
|
80
|
-
|
|
61
|
+
headerStore,
|
|
62
|
+
headerResolver: collection.headerResolver,
|
|
63
|
+
resolver: collection.resolver,
|
|
64
|
+
tree,
|
|
65
|
+
setInstance,
|
|
81
66
|
};
|
|
82
67
|
};
|
|
83
68
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* declared as {@link ColumnViewColumn} children. Supplying an external `model`
|
|
87
|
-
* switches to the uncontrolled form.
|
|
69
|
+
* Renders a Gtk.ColumnView: a multi-column, scrollable list backed by a collection
|
|
70
|
+
* model. Columns are declared through the columns prop, each a {@link ColumnDef}.
|
|
88
71
|
*/
|
|
89
72
|
export const ColumnView = (props) => {
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
items,
|
|
95
|
-
model,
|
|
96
|
-
selected,
|
|
97
|
-
selectionMode,
|
|
98
|
-
onSelectionChanged,
|
|
99
|
-
sortColumn,
|
|
100
|
-
sortOrder,
|
|
101
|
-
onSortChanged,
|
|
102
|
-
renderHeader,
|
|
103
|
-
estimatedRowHeight,
|
|
104
|
-
}, registry);
|
|
105
|
-
const intrinsic = createElement(GtkColumnView, { ...intrinsicProps, ref: wiring.setRef }, _jsx(ColumnViewContext.Provider, { value: wiring.contextValue, children: children }));
|
|
106
|
-
return (_jsxs(_Fragment, { children: [intrinsic, wiring.useHeader ? (_jsx(ListPortalHost, { store: wiring.headerStore, resolver: wiring.headerResolver, render: headerRenderer(renderHeader) })) : null] }));
|
|
73
|
+
const normalized = props;
|
|
74
|
+
const wiring = useColumnViewWiring(normalized);
|
|
75
|
+
const { ref, items, sections, columns, selectedIds, selectionMode, onSelectionChanged, expandedIds, onExpandedChange, sortColumn, sortOrder, onSortChanged, renderHeader, estimatedItemHeight, ...intrinsicProps } = normalized;
|
|
76
|
+
return (_jsxs(_Fragment, { children: [_jsx(GtkColumnView, { ...intrinsicProps, ref: wiring.setRef, children: columns.map((column) => (_jsx(ColumnViewColumn, { ...column, resolver: wiring.resolver, tree: wiring.tree, estimatedItemHeight: estimatedItemHeight, onInstance: wiring.setInstance }, column.id))) }), _jsx(HeaderRenderHost, { useHeader: wiring.useHeader, store: wiring.headerStore, resolver: wiring.headerResolver, renderHeader: renderHeader })] }));
|
|
107
77
|
};
|
|
108
78
|
//# sourceMappingURL=column-view.js.map
|
package/dist/column-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-view.js","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAA2B,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAA4B,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxG,OAAO,EAEH,iBAAiB,GAEpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAuB,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,MAAM,oBAAoB,GAAmC;IACzD,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC;IAC9D,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC;CACvD,CAAC;AAQF,MAAM,iBAAiB,GAAG,GAAmB,EAAE;IAC3C,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAkC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IACrG,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,YAAgC,EAAQ,EAAE;QACpE,gBAAgB,CAAC,CAAC,OAAO,EAAE,EAAE;YACzB,MAAM,IAAI,G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,CAAC;IACrD,MAAM,EACF,GAAG,EACH,KAAK,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,GAAG,cAAc,EACpB,GAAG,UAAU,CAAC;IAEf,OAAO,CACH,8BACI,KAAC,aAAa,OAAK,cAAc,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,YAChD,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACrB,KAAC,gBAAgB,OAET,MAAM,EACV,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,MAAM,CAAC,WAAW,IALzB,MAAM,CAAC,EAAE,CAMhB,CACL,CAAC,GACU,EAChB,KAAC,gBAAgB,IACb,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,KAAK,EAAE,MAAM,CAAC,WAAW,EACzB,QAAQ,EAAE,MAAM,CAAC,cAAc,EAC/B,YAAY,EAAE,YAAY,GAC5B,IACH,CACN,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkColumnView, type GtkColumnViewProps } from \"@gtkx/jsx/gtk\";\nimport { type ReactNode, type Ref, useCallback, useMemo, useState } from \"react\";\nimport { createTreeRenderContext, HeaderRenderHost, type TreeRenderContext } from \"./cell.js\";\nimport { type ColumnDef, ColumnViewColumn } from \"./column-view-column.js\";\nimport { makeFactoryInstaller, useCellContainers } from \"./hooks/use-cell-containers.js\";\nimport { useCollectionWidget } from \"./hooks/use-collection-widget.js\";\nimport { type ColumnRegistration, useSortHandler } from \"./hooks/use-sort-handler.js\";\nimport type {\n CollectionItemSizeProps,\n ControlledExpansionProps,\n ControlledSelectionProps,\n ItemNode,\n SectionNode,\n} from \"./types.js\";\nimport type { CellContainerStore } from \"./utils/cell-container-store.js\";\nimport type { ItemResolver } from \"./utils/item-resolver.js\";\n\nexport type { ColumnDef, ColumnDefDeclarativeProps } from \"./column-view-column.js\";\n\nconst headerFactoryInstaller = makeFactoryInstaller<Gtk.ColumnView>((widget, factory) =>\n widget.setHeaderFactory(factory),\n);\n\nexport type ColumnViewSortProps = {\n sortColumn?: string | null | undefined;\n sortOrder?: Gtk.SortType | null | undefined;\n onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;\n};\n\nexport type ColumnViewDeclarativeProps<T = unknown, S = unknown> = ColumnViewSortProps &\n Omit<CollectionItemSizeProps, \"estimatedItemWidth\"> &\n ControlledSelectionProps &\n ControlledExpansionProps & {\n items?: ItemNode<T>[] | undefined;\n sections?: SectionNode<S, T>[] | undefined;\n renderHeader?: ((info: { section: S }) => ReactNode) | null | undefined;\n columns: ColumnDef<T>[];\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, and the columns to render.\n */\nexport type ColumnViewProps<T = unknown, S = unknown> = Omit<\n GtkColumnViewProps,\n \"columns\" | \"model\" | \"headerFactory\" | keyof ColumnViewDeclarativeProps<T, S>\n> &\n ColumnViewDeclarativeProps<T, S>;\n\ntype NormalizedColumnViewProps<T, S> = ColumnViewDeclarativeProps<T, S> & {\n ref?: Ref<Gtk.ColumnView | null>;\n [key: string]: unknown;\n};\n\ninterface ColumnViewWiring<T, S> {\n setRef: (value: Gtk.ColumnView | null) => void;\n useHeader: boolean;\n headerStore: CellContainerStore;\n headerResolver: ItemResolver<T, S>;\n resolver: ItemResolver<unknown, unknown>;\n tree: TreeRenderContext;\n setInstance: (id: string, column: Gtk.ColumnViewColumn | null) => void;\n}\n\nconst useColumnInstances = (): {\n instances: Map<string, Gtk.ColumnViewColumn>;\n setInstance: (id: string, column: Gtk.ColumnViewColumn | null) => void;\n} => {\n const [instances, setInstances] = useState<Map<string, Gtk.ColumnViewColumn>>(() => new Map());\n const setInstance = useCallback((id: string, column: Gtk.ColumnViewColumn | null): void => {\n setInstances((current) => {\n if (column === null) {\n if (!current.has(id)) return current;\n const next = new Map(current);\n next.delete(id);\n return next;\n }\n if (current.get(id) === column) return current;\n const next = new Map(current);\n next.set(id, column);\n return next;\n });\n }, []);\n return { instances, setInstance };\n};\n\nconst buildRegistrations = <T,>(\n columns: ColumnDef<T>[],\n instances: Map<string, Gtk.ColumnViewColumn>,\n): ColumnRegistration[] => {\n const result: ColumnRegistration[] = [];\n for (const column of columns) {\n const instance = instances.get(column.id);\n if (instance) result.push({ id: column.id, column: instance, sortable: column.sortable ?? false });\n }\n return result;\n};\n\nconst useColumnViewWiring = <T, S>(props: NormalizedColumnViewProps<T, S>): ColumnViewWiring<T, S> => {\n const { widgetRef, setRef, collection } = useCollectionWidget<Gtk.ColumnView, T, S>(props);\n\n const useHeader = collection.useHeader;\n const headerStore = useCellContainers<Gtk.ColumnView>({\n object: useHeader ? widgetRef : null,\n installer: headerFactoryInstaller,\n estimatedHeight: props.estimatedItemHeight,\n });\n\n const { instances, setInstance } = useColumnInstances();\n const registrations = useMemo<ColumnRegistration[]>(\n () => buildRegistrations(props.columns, instances),\n [props.columns, instances],\n );\n\n useSortHandler({\n columnView: widgetRef,\n sortColumn: props.sortColumn,\n sortOrder: props.sortOrder,\n onSortChanged: props.onSortChanged,\n columns: registrations,\n });\n\n const expandedIds = props.expandedIds;\n const tree = useMemo<TreeRenderContext>(\n () => createTreeRenderContext(expandedIds, collection.rowId),\n [expandedIds, collection.rowId],\n );\n\n return {\n setRef,\n useHeader,\n headerStore,\n headerResolver: collection.headerResolver,\n resolver: collection.resolver as ItemResolver<unknown, unknown>,\n tree,\n setInstance,\n };\n};\n\n/**\n * Renders a Gtk.ColumnView: a multi-column, scrollable list backed by a collection\n * model. Columns are declared through the columns prop, each a {@link ColumnDef}.\n */\nexport const ColumnView = <T = unknown, S = unknown>(props: ColumnViewProps<T, S>): ReactNode => {\n const normalized = props as NormalizedColumnViewProps<T, S>;\n const wiring = useColumnViewWiring<T, S>(normalized);\n const {\n ref,\n items,\n sections,\n columns,\n selectedIds,\n selectionMode,\n onSelectionChanged,\n expandedIds,\n onExpandedChange,\n sortColumn,\n sortOrder,\n onSortChanged,\n renderHeader,\n estimatedItemHeight,\n ...intrinsicProps\n } = normalized;\n\n return (\n <>\n <GtkColumnView {...intrinsicProps} ref={wiring.setRef}>\n {columns.map((column) => (\n <ColumnViewColumn\n key={column.id}\n {...column}\n resolver={wiring.resolver}\n tree={wiring.tree}\n estimatedItemHeight={estimatedItemHeight}\n onInstance={wiring.setInstance}\n />\n ))}\n </GtkColumnView>\n <HeaderRenderHost\n useHeader={wiring.useHeader}\n store={wiring.headerStore}\n resolver={wiring.headerResolver}\n renderHeader={renderHeader}\n />\n </>\n );\n};\n"]}
|
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Describes one constraint added by `<ConstraintLayout.Constraint>`, relating a
|
|
4
|
+
* target widget attribute to a source attribute of another widget or guide.
|
|
5
|
+
*/
|
|
6
|
+
export type ConstraintProps = {
|
|
7
|
+
/** Name of the target widget or guide. Use "super" or omit to reference the layout's own widget. */
|
|
8
|
+
target?: string;
|
|
9
|
+
targetAttribute: Gtk.ConstraintAttribute;
|
|
10
|
+
/** Relation between the target and source attributes (defaults to equality). */
|
|
11
|
+
relation?: Gtk.ConstraintRelation;
|
|
12
|
+
/** Name of the source widget or guide. Use "super" or omit for a constant constraint. */
|
|
13
|
+
source?: string;
|
|
14
|
+
sourceAttribute?: Gtk.ConstraintAttribute;
|
|
15
|
+
/** Factor applied to the source attribute (defaults to 1). */
|
|
16
|
+
multiplier?: number;
|
|
17
|
+
/** Constant offset added to the relation (defaults to 0). */
|
|
18
|
+
constant?: number;
|
|
19
|
+
/** Constraint strength, higher values winning conflicts (defaults to required). */
|
|
20
|
+
strength?: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Describes an invisible spacing guide added by `<ConstraintLayout.Guide>`,
|
|
24
|
+
* usable as a constraint target under its id.
|
|
25
|
+
*/
|
|
26
|
+
export type ConstraintGuideProps = {
|
|
27
|
+
/** Identifier used to reference this guide from constraints. */
|
|
28
|
+
id: string;
|
|
29
|
+
minWidth?: number;
|
|
30
|
+
minHeight?: number;
|
|
31
|
+
/** Preferred (natural) width. */
|
|
32
|
+
natWidth?: number;
|
|
33
|
+
/** Preferred (natural) height. */
|
|
34
|
+
natHeight?: number;
|
|
35
|
+
maxWidth?: number;
|
|
36
|
+
maxHeight?: number;
|
|
37
|
+
/** Strength of the guide's own size constraints. */
|
|
38
|
+
strength?: Gtk.ConstraintStrength;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Describes constraints authored with the Visual Format Language (VFL), applied by
|
|
42
|
+
* `<ConstraintLayout.Vfl>`.
|
|
43
|
+
*/
|
|
44
|
+
export type ConstraintVflProps = {
|
|
45
|
+
/** VFL lines describing the constraints between named widgets and guides. */
|
|
46
|
+
lines: string[];
|
|
47
|
+
/** Default horizontal spacing used by the layout operator (defaults to 0). */
|
|
48
|
+
hspacing?: number;
|
|
49
|
+
/** Default vertical spacing used by the layout operator (defaults to 0). */
|
|
50
|
+
vspacing?: number;
|
|
51
|
+
};
|
|
3
52
|
export declare function applyConstraint(layout: Gtk.ConstraintLayout, props: ConstraintProps): () => void;
|
|
4
53
|
export declare function applyVfl(layout: Gtk.ConstraintLayout, props: ConstraintVflProps): () => void;
|
|
5
54
|
export declare function applyGuide(layout: Gtk.ConstraintLayout, props: ConstraintGuideProps): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraint-layout-apply.d.ts","sourceRoot":"","sources":["../src/constraint-layout-apply.ts"],"names":[],"mappings":"AACA,OAAO,KA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IAChF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC;QAClC,IAAI,EAAE,KAAK,CAAC,EAAE;QACd,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;KAC3B,CAAC,CAAC;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAEvC,OAAO,GAAG,EAAE;QACR,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,YAAY,CAAC,MAAM,CAAC;YAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,CAAC;AACN,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\n\n/**\n * Describes one constraint added by `<ConstraintLayout.Constraint>`, relating a\n * target widget attribute to a source attribute of another widget or guide.\n */\nexport type ConstraintProps = {\n /** Name of the target widget or guide. Use \"super\" or omit to reference the layout's own widget. */\n target?: string;\n targetAttribute: Gtk.ConstraintAttribute;\n /** Relation between the target and source attributes (defaults to equality). */\n relation?: Gtk.ConstraintRelation;\n /** Name of the source widget or guide. Use \"super\" or omit for a constant constraint. */\n source?: string;\n sourceAttribute?: Gtk.ConstraintAttribute;\n /** Factor applied to the source attribute (defaults to 1). */\n multiplier?: number;\n /** Constant offset added to the relation (defaults to 0). */\n constant?: number;\n /** Constraint strength, higher values winning conflicts (defaults to required). */\n strength?: number;\n};\n\n/**\n * Describes an invisible spacing guide added by `<ConstraintLayout.Guide>`,\n * usable as a constraint target under its id.\n */\nexport type ConstraintGuideProps = {\n /** Identifier used to reference this guide from constraints. */\n id: string;\n minWidth?: number;\n minHeight?: number;\n /** Preferred (natural) width. */\n natWidth?: number;\n /** Preferred (natural) height. */\n natHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n /** Strength of the guide's own size constraints. */\n strength?: Gtk.ConstraintStrength;\n};\n\n/**\n * Describes constraints authored with the Visual Format Language (VFL), applied by\n * `<ConstraintLayout.Vfl>`.\n */\nexport type ConstraintVflProps = {\n /** VFL lines describing the constraints between named widgets and guides. */\n lines: string[];\n /** Default horizontal spacing used by the layout operator (defaults to 0). */\n hspacing?: number;\n /** Default vertical spacing used by the layout operator (defaults to 0). */\n vspacing?: number;\n};\n\nconst SUPER_ID = \"super\";\n\nconst unknownIdMessage = (role: string, id: string): string =>\n `<ConstraintLayout.Constraint> references unknown id '${id}'. ` +\n `Set name=\"${id}\" on the ${role} widget, or add a <ConstraintLayout.Guide id=\"${id}\">.`;\n\nconst guideRegistry = new WeakMap<Gtk.ConstraintLayout, Map<string, Gtk.ConstraintGuide>>();\n\nconst guidesFor = (layout: Gtk.ConstraintLayout): Map<string, Gtk.ConstraintGuide> => {\n let map = guideRegistry.get(layout);\n if (!map) {\n map = new Map<string, Gtk.ConstraintGuide>();\n guideRegistry.set(layout, map);\n }\n return map;\n};\n\nconst explicitWidgetName = (widget: Gtk.Widget): string | null => {\n const value = new GObject.Value();\n value.init(GObject.TYPE_STRING);\n widget.getProperty(\"name\", value);\n const name = value.getString();\n return name !== null && name.length > 0 ? name : null;\n};\n\nfunction* namedChildren(layout: Gtk.ConstraintLayout): Generator<[string, Gtk.Widget]> {\n const host = layout.getWidget();\n if (!host) return;\n for (let child = host.getFirstChild(); child; child = child.getNextSibling()) {\n const name = explicitWidgetName(child);\n if (name !== null) yield [name, child];\n }\n}\n\nconst findChildByName = (layout: Gtk.ConstraintLayout, id: string): Gtk.Widget | undefined => {\n for (const [name, child] of namedChildren(layout)) {\n if (name === id) return child;\n }\n return undefined;\n};\n\nconst resolveConstraintTarget = (\n layout: Gtk.ConstraintLayout,\n id: string | undefined,\n): Gtk.ConstraintTarget | null | undefined => {\n if (id === undefined || id === SUPER_ID) return null;\n return findChildByName(layout, id) ?? guidesFor(layout).get(id);\n};\n\nconst constraintViews = (layout: Gtk.ConstraintLayout): Map<string, Gtk.ConstraintTarget> => {\n const views = new Map<string, Gtk.ConstraintTarget>();\n for (const [name, child] of namedChildren(layout)) views.set(name, child);\n for (const [name, guide] of guidesFor(layout)) {\n if (!views.has(name)) views.set(name, guide);\n }\n return views;\n};\n\nconst isLayoutLive = (layout: Gtk.ConstraintLayout): boolean => layout.getWidget() !== null;\n\nexport function applyConstraint(layout: Gtk.ConstraintLayout, props: ConstraintProps): () => void {\n const target = resolveConstraintTarget(layout, props.target);\n if (target === undefined) throw new Error(unknownIdMessage(\"target\", String(props.target)));\n const source = resolveConstraintTarget(layout, props.source);\n if (source === undefined) throw new Error(unknownIdMessage(\"source\", String(props.source)));\n\n const constraint = new Gtk.Constraint({\n target,\n targetAttribute: props.targetAttribute,\n relation: props.relation ?? Gtk.ConstraintRelation.EQ,\n source,\n sourceAttribute: props.sourceAttribute ?? Gtk.ConstraintAttribute.NONE,\n multiplier: props.multiplier ?? 1,\n constant: props.constant ?? 0,\n strength: props.strength ?? Gtk.ConstraintStrength.REQUIRED,\n });\n layout.addConstraint(constraint);\n\n return () => {\n if (isLayoutLive(layout)) layout.removeConstraint(constraint);\n };\n}\n\nexport function applyVfl(layout: Gtk.ConstraintLayout, props: ConstraintVflProps): () => void {\n const views = constraintViews(layout);\n const constraints = layout.addConstraintsFromDescription(\n props.lines,\n props.hspacing ?? 0,\n props.vspacing ?? 0,\n views,\n );\n\n return () => {\n if (!isLayoutLive(layout)) return;\n for (const constraint of constraints) layout.removeConstraint(constraint);\n };\n}\n\nexport function applyGuide(layout: Gtk.ConstraintLayout, props: ConstraintGuideProps): () => void {\n const guide = new Gtk.ConstraintGuide({\n name: props.id,\n minWidth: props.minWidth,\n minHeight: props.minHeight,\n natWidth: props.natWidth,\n natHeight: props.natHeight,\n maxWidth: props.maxWidth,\n maxHeight: props.maxHeight,\n strength: props.strength,\n });\n layout.addGuide(guide);\n guidesFor(layout).set(props.id, guide);\n\n return () => {\n guidesFor(layout).delete(props.id);\n if (isLayoutLive(layout)) layout.removeGuide(guide);\n };\n}\n"]}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { type ReactNode, type Ref } from "react";
|
|
3
|
-
import type
|
|
3
|
+
import { type ConstraintGuideProps, type ConstraintProps, type ConstraintVflProps } from "./constraint-layout-apply.js";
|
|
4
|
+
/** Props for {@link ConstraintLayout}. */
|
|
4
5
|
export type ConstraintLayoutProps = {
|
|
5
6
|
children?: ReactNode;
|
|
6
7
|
ref?: Ref<Gtk.ConstraintLayout | null>;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Installs a Gtk.ConstraintLayout on a host widget and exposes child components to
|
|
11
|
+
* populate it: {@link ConstraintProps | ConstraintLayout.Constraint} for individual constraints,
|
|
12
|
+
* {@link ConstraintGuideProps | ConstraintLayout.Guide} for spacing guides, and {@link ConstraintVflProps | ConstraintLayout.Vfl}
|
|
13
|
+
* for constraints authored in the Visual Format Language.
|
|
14
|
+
*/
|
|
8
15
|
export declare const ConstraintLayout: ((props: ConstraintLayoutProps) => ReactNode) & {
|
|
9
16
|
Guide: (props: ConstraintGuideProps) => ReactNode;
|
|
10
17
|
Constraint: (props: ConstraintProps) => ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraint-layout.d.ts","sourceRoot":"","sources":["../src/constraint-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAGzC,OAAO,
|
|
1
|
+
{"version":3,"file":"constraint-layout.d.ts","sourceRoot":"","sources":["../src/constraint-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAGzC,OAAO,EAGH,KAAK,SAAS,EACd,KAAK,GAAG,EAMX,MAAM,OAAO,CAAC;AACf,OAAO,EAIH,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAC1B,MAAM,8BAA8B,CAAC;AAatC,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAAG;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAC1C,CAAC;AAqCF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,KAAK,EAAE,qBAAqB,KAAK,SAAS,CAAC,GAAG;IAC3E,KAAK,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAC;IAClD,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAC;IAClD,GAAG,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,SAAS,CAAC;CAkDjD,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { GtkConstraintLayout } from "@gtkx/jsx/gtk";
|
|
3
|
-
import {
|
|
4
|
-
import { createContext,
|
|
5
|
-
import { applyConstraint, applyGuide, applyVfl } from "./constraint-layout-apply.js";
|
|
3
|
+
import { useMergeRefs } from "@gtkx/react/internal";
|
|
4
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useRef, } from "react";
|
|
5
|
+
import { applyConstraint, applyGuide, applyVfl, } from "./constraint-layout-apply.js";
|
|
6
6
|
const ORPHAN_MESSAGE = "<ConstraintLayout.Constraint> / <Guide> / <Vfl> must be a child of <ConstraintLayout>";
|
|
7
7
|
const ConstraintLayoutContext = createContext(null);
|
|
8
8
|
const useConstraintLayoutRef = () => {
|
|
@@ -43,13 +43,16 @@ const useDeferredContribution = (apply, deps) => {
|
|
|
43
43
|
};
|
|
44
44
|
}, deps);
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Installs a Gtk.ConstraintLayout on a host widget and exposes child components to
|
|
48
|
+
* populate it: {@link ConstraintProps | ConstraintLayout.Constraint} for individual constraints,
|
|
49
|
+
* {@link ConstraintGuideProps | ConstraintLayout.Guide} for spacing guides, and {@link ConstraintVflProps | ConstraintLayout.Vfl}
|
|
50
|
+
* for constraints authored in the Visual Format Language.
|
|
51
|
+
*/
|
|
46
52
|
export const ConstraintLayout = Object.assign(({ children, ref }) => {
|
|
47
53
|
const layoutRef = useRef(null);
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
}, [layoutRef]);
|
|
51
|
-
const [, mergedRef] = useForwardedRef(ref, captureLayout);
|
|
52
|
-
return (_jsxs(_Fragment, { children: [createElement(GtkConstraintLayout, { ref: mergedRef }), _jsx(ConstraintLayoutContext.Provider, { value: layoutRef, children: children })] }));
|
|
54
|
+
const mergedRef = useMergeRefs(ref, layoutRef);
|
|
55
|
+
return (_jsxs(_Fragment, { children: [_jsx(GtkConstraintLayout, { ref: mergedRef }), _jsx(ConstraintLayoutContext.Provider, { value: layoutRef, children: children })] }));
|
|
53
56
|
}, {
|
|
54
57
|
Guide: (props) => {
|
|
55
58
|
useLayoutContribution((layout) => applyGuide(layout, props), [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraint-layout.js","sourceRoot":"","sources":["../src/constraint-layout.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constraint-layout.js","sourceRoot":"","sources":["../src/constraint-layout.tsx"],"names":[],"mappings":";AACA,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AAC,QAAQ;YACd,KAAK,CAAC,SAAS;YACf,KAAK,CAAC,QAAQ;SACjB,CACJ,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,UAAU,EAAE,CAAC,KAAsB,EAAa,EAAE;QAC9C,uBAAuB,CACnB,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,EAC1C;YACI,KAAK,CAAC,MAAM;YACZ,KAAK,CAAC,eAAe;YACrB,KAAK,CAAC,QAAQ;YACd,KAAK,CAAC,MAAM;YACZ,KAAK,CAAC,eAAe;YACrB,KAAK,CAAC,UAAU;YAChB,KAAK,CAAC,QAAQ;YACd,KAAK,CAAC,QAAQ;SACjB,CACJ,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,GAAG,EAAE,CAAC,KAAyB,EAAa,EAAE;QAC1C,uBAAuB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC5G,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CACJ,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkConstraintLayout } from \"@gtkx/jsx/gtk\";\nimport { useMergeRefs } from \"@gtkx/react/internal\";\nimport {\n type Context,\n createContext,\n type ReactNode,\n type Ref,\n type RefObject,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport {\n applyConstraint,\n applyGuide,\n applyVfl,\n type ConstraintGuideProps,\n type ConstraintProps,\n type ConstraintVflProps,\n} from \"./constraint-layout-apply.js\";\n\nconst ORPHAN_MESSAGE = \"<ConstraintLayout.Constraint> / <Guide> / <Vfl> must be a child of <ConstraintLayout>\";\n\nconst ConstraintLayoutContext: Context<RefObject<Gtk.ConstraintLayout | null> | null> =\n createContext<RefObject<Gtk.ConstraintLayout | null> | null>(null);\n\nconst useConstraintLayoutRef = (): RefObject<Gtk.ConstraintLayout | null> => {\n const ref = useContext(ConstraintLayoutContext);\n if (!ref) throw new Error(ORPHAN_MESSAGE);\n return ref;\n};\n\n/** Props for {@link ConstraintLayout}. */\nexport type ConstraintLayoutProps = {\n children?: ReactNode;\n ref?: Ref<Gtk.ConstraintLayout | null>;\n};\n\ntype ContributionCleanupRef = { current: (() => void) | null };\n\nconst cleanupContribution = (cleanupRef: ContributionCleanupRef): void => {\n const cleanup = cleanupRef.current;\n if (!cleanup) return;\n cleanupRef.current = null;\n cleanup();\n};\n\nconst useLayoutContribution = (apply: (layout: Gtk.ConstraintLayout) => () => void, deps: unknown[]): void => {\n const layoutRef = useConstraintLayoutRef();\n useLayoutEffect(() => {\n const layout = layoutRef.current;\n if (!layout) return;\n return apply(layout);\n }, deps);\n};\n\nconst useDeferredContribution = (apply: (layout: Gtk.ConstraintLayout) => () => void, deps: unknown[]): void => {\n const layoutRef = useConstraintLayoutRef();\n const cleanupRef = useRef<(() => void) | null>(null);\n\n useLayoutEffect(() => () => cleanupContribution(cleanupRef), deps);\n\n useEffect(() => {\n const layout = layoutRef.current;\n if (!layout) return;\n const cleanup = apply(layout);\n cleanupRef.current = cleanup;\n return () => {\n if (cleanupRef.current === cleanup) cleanupContribution(cleanupRef);\n };\n }, deps);\n};\n\n/**\n * Installs a Gtk.ConstraintLayout on a host widget and exposes child components to\n * populate it: {@link ConstraintProps | ConstraintLayout.Constraint} for individual constraints,\n * {@link ConstraintGuideProps | ConstraintLayout.Guide} for spacing guides, and {@link ConstraintVflProps | ConstraintLayout.Vfl}\n * for constraints authored in the Visual Format Language.\n */\nexport const ConstraintLayout: ((props: ConstraintLayoutProps) => ReactNode) & {\n Guide: (props: ConstraintGuideProps) => ReactNode;\n Constraint: (props: ConstraintProps) => ReactNode;\n Vfl: (props: ConstraintVflProps) => ReactNode;\n} = Object.assign(\n ({ children, ref }: ConstraintLayoutProps): ReactNode => {\n const layoutRef = useRef<Gtk.ConstraintLayout | null>(null);\n const mergedRef = useMergeRefs<Gtk.ConstraintLayout>(ref, layoutRef);\n return (\n <>\n <GtkConstraintLayout ref={mergedRef} />\n <ConstraintLayoutContext.Provider value={layoutRef}>{children}</ConstraintLayoutContext.Provider>\n </>\n );\n },\n {\n Guide: (props: ConstraintGuideProps): ReactNode => {\n useLayoutContribution(\n (layout) => applyGuide(layout, props),\n [\n props.id,\n props.minWidth,\n props.minHeight,\n props.natWidth,\n props.natHeight,\n props.maxWidth,\n props.maxHeight,\n props.strength,\n ],\n );\n return null;\n },\n Constraint: (props: ConstraintProps): ReactNode => {\n useDeferredContribution(\n (layout) => applyConstraint(layout, props),\n [\n props.target,\n props.targetAttribute,\n props.relation,\n props.source,\n props.sourceAttribute,\n props.multiplier,\n props.constant,\n props.strength,\n ],\n );\n return null;\n },\n Vfl: (props: ConstraintVflProps): ReactNode => {\n useDeferredContribution((layout) => applyVfl(layout, props), [props.lines, props.hspacing, props.vspacing]);\n return null;\n },\n },\n);\n"]}
|