@gtkx/react 1.0.0-rc.1 → 1.0.0-rc.3
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/config.d.ts +2 -0
- package/dist/adw/config.d.ts.map +1 -0
- package/dist/adw/config.js +2 -0
- package/dist/adw/config.js.map +1 -0
- package/dist/{libraries/adw → adw}/dialog.d.ts +2 -2
- package/dist/adw/dialog.d.ts.map +1 -0
- package/dist/adw/dialog.js +25 -0
- package/dist/adw/dialog.js.map +1 -0
- package/dist/adw/element-behaviors.d.ts +2 -0
- package/dist/adw/element-behaviors.d.ts.map +1 -0
- package/dist/adw/element-behaviors.js +269 -0
- package/dist/adw/element-behaviors.js.map +1 -0
- package/dist/adw/element-config.d.ts +11 -0
- package/dist/adw/element-config.d.ts.map +1 -0
- package/dist/adw/element-config.js +127 -0
- package/dist/adw/element-config.js.map +1 -0
- package/dist/adw/index.d.ts +4 -0
- package/dist/adw/index.d.ts.map +1 -0
- package/dist/adw/index.js +3 -0
- package/dist/adw/index.js.map +1 -0
- package/dist/adw/prop-types.d.ts +29 -0
- package/dist/adw/prop-types.d.ts.map +1 -0
- package/dist/adw/prop-types.js +2 -0
- package/dist/adw/prop-types.js.map +1 -0
- package/dist/bootstrap.d.ts +2 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +5 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/components/application.d.ts +2 -2
- package/dist/components/application.d.ts.map +1 -1
- package/dist/components/application.js +31 -18
- package/dist/components/application.js.map +1 -1
- package/dist/components/element.d.ts +6 -0
- package/dist/components/element.d.ts.map +1 -0
- package/dist/components/element.js +29 -0
- package/dist/components/element.js.map +1 -0
- package/dist/components/window.d.ts +2 -2
- package/dist/components/window.d.ts.map +1 -1
- package/dist/components/window.js +22 -12
- package/dist/components/window.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -0
- package/dist/element-behaviors.d.ts +2 -0
- package/dist/element-behaviors.d.ts.map +1 -0
- package/dist/element-behaviors.js +348 -0
- package/dist/element-behaviors.js.map +1 -0
- package/dist/element-config.d.ts +10 -0
- package/dist/element-config.d.ts.map +1 -0
- package/dist/element-config.js +149 -0
- package/dist/element-config.js.map +1 -0
- package/dist/hooks/use-application.d.ts +4 -3
- package/dist/hooks/use-application.d.ts.map +1 -1
- package/dist/hooks/use-application.js +5 -4
- package/dist/hooks/use-application.js.map +1 -1
- package/dist/hooks/use-bind-setting.d.ts +21 -4
- package/dist/hooks/use-bind-setting.d.ts.map +1 -1
- package/dist/hooks/use-bind-setting.js +27 -16
- package/dist/hooks/use-bind-setting.js.map +1 -1
- package/dist/hooks/use-merged-refs.d.ts +8 -0
- package/dist/hooks/use-merged-refs.d.ts.map +1 -0
- package/dist/hooks/use-merged-refs.js +48 -0
- package/dist/hooks/use-merged-refs.js.map +1 -0
- package/dist/hooks/use-object-value.d.ts +3 -2
- package/dist/hooks/use-object-value.d.ts.map +1 -1
- package/dist/hooks/use-object-value.js +18 -21
- package/dist/hooks/use-object-value.js.map +1 -1
- package/dist/hooks/use-parent-window.d.ts +3 -2
- package/dist/hooks/use-parent-window.d.ts.map +1 -1
- package/dist/hooks/use-parent-window.js +3 -2
- package/dist/hooks/use-parent-window.js.map +1 -1
- package/dist/hooks/use-property.d.ts +5 -5
- package/dist/hooks/use-property.d.ts.map +1 -1
- package/dist/hooks/use-property.js +4 -3
- package/dist/hooks/use-property.js.map +1 -1
- package/dist/hooks/use-setting.d.ts +5 -16
- package/dist/hooks/use-setting.d.ts.map +1 -1
- package/dist/hooks/use-setting.js +16 -11
- package/dist/hooks/use-setting.js.map +1 -1
- package/dist/hooks/use-signal.d.ts +14 -7
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js +33 -18
- package/dist/hooks/use-signal.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +7 -7
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +6 -7
- package/dist/internal.js.map +1 -1
- package/dist/prop-types.d.ts +110 -0
- package/dist/prop-types.d.ts.map +1 -0
- package/dist/prop-types.js +2 -0
- package/dist/prop-types.js.map +1 -0
- package/dist/reconciler/apply-props.d.ts +10 -7
- package/dist/reconciler/apply-props.d.ts.map +1 -1
- package/dist/reconciler/apply-props.js +186 -82
- package/dist/reconciler/apply-props.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +59 -0
- package/dist/reconciler/behaviors.d.ts.map +1 -0
- package/dist/reconciler/behaviors.js +177 -0
- package/dist/reconciler/behaviors.js.map +1 -0
- package/dist/reconciler/child-routing.d.ts +5 -0
- package/dist/reconciler/child-routing.d.ts.map +1 -0
- package/dist/reconciler/child-routing.js +156 -0
- package/dist/reconciler/child-routing.js.map +1 -0
- package/dist/reconciler/host-config.d.ts +8 -12
- package/dist/reconciler/host-config.d.ts.map +1 -1
- package/dist/reconciler/host-config.js +171 -270
- package/dist/reconciler/host-config.js.map +1 -1
- package/dist/reconciler/instance.d.ts +4 -5
- package/dist/reconciler/instance.d.ts.map +1 -1
- package/dist/reconciler/instance.js +44 -22
- package/dist/reconciler/instance.js.map +1 -1
- package/dist/reconciler/metadata.d.ts +17 -0
- package/dist/reconciler/metadata.d.ts.map +1 -0
- package/dist/reconciler/metadata.js +82 -0
- package/dist/reconciler/metadata.js.map +1 -0
- package/dist/reconciler/node.d.ts +76 -0
- package/dist/reconciler/node.d.ts.map +1 -0
- package/dist/reconciler/node.js +53 -0
- package/dist/reconciler/node.js.map +1 -0
- package/dist/reconciler/placement.d.ts +5 -0
- package/dist/reconciler/placement.d.ts.map +1 -0
- package/dist/reconciler/placement.js +191 -0
- package/dist/reconciler/placement.js.map +1 -0
- package/dist/reconciler/registry.d.ts +107 -0
- package/dist/reconciler/registry.d.ts.map +1 -0
- package/dist/reconciler/registry.js +74 -0
- package/dist/reconciler/registry.js.map +1 -0
- package/dist/reconciler/root-element.d.ts +9 -12
- package/dist/reconciler/root-element.d.ts.map +1 -1
- package/dist/reconciler/root-element.js +6 -6
- package/dist/reconciler/root-element.js.map +1 -1
- package/dist/reconciler/root.d.ts +56 -0
- package/dist/reconciler/root.d.ts.map +1 -0
- package/dist/reconciler/root.js +106 -0
- package/dist/reconciler/root.js.map +1 -0
- package/dist/reconciler/signals.d.ts +9 -0
- package/dist/reconciler/signals.d.ts.map +1 -0
- package/dist/reconciler/signals.js +58 -0
- package/dist/reconciler/signals.js.map +1 -0
- package/dist/reconciler/text.d.ts +19 -0
- package/dist/reconciler/text.d.ts.map +1 -0
- package/dist/reconciler/text.js +281 -0
- package/dist/reconciler/text.js.map +1 -0
- package/dist/utils/accessible-metadata.d.ts +11 -4
- package/dist/utils/accessible-metadata.d.ts.map +1 -1
- package/dist/utils/accessible-metadata.js +20 -17
- package/dist/utils/accessible-metadata.js.map +1 -1
- package/dist/{reconciler/accessible.d.ts → utils/accessible-props.d.ts} +7 -6
- package/dist/utils/accessible-props.d.ts.map +1 -0
- package/dist/utils/accessible-props.js +181 -0
- package/dist/utils/accessible-props.js.map +1 -0
- package/dist/utils/ref-prop.d.ts +15 -0
- package/dist/utils/ref-prop.d.ts.map +1 -0
- package/dist/utils/ref-prop.js +18 -0
- package/dist/utils/ref-prop.js.map +1 -0
- package/dist/utils/settings.d.ts +17 -0
- package/dist/utils/settings.d.ts.map +1 -0
- package/dist/utils/settings.js +37 -0
- package/dist/utils/settings.js.map +1 -0
- package/dist/utils/variant.d.ts +57 -0
- package/dist/utils/variant.d.ts.map +1 -0
- package/dist/utils/variant.js +197 -0
- package/dist/utils/variant.js.map +1 -0
- package/env.d.ts +9 -0
- package/package.json +36 -11
- package/src/adw/config.ts +1 -0
- package/src/adw/dialog.tsx +35 -0
- package/src/adw/element-behaviors.ts +349 -0
- package/src/adw/element-config.ts +131 -0
- package/src/adw/index.ts +4 -0
- package/src/adw/prop-types.ts +42 -0
- package/src/bootstrap.ts +5 -0
- package/src/components/application.tsx +42 -23
- package/src/components/element.tsx +47 -0
- package/src/components/window.tsx +26 -14
- package/src/config.ts +10 -0
- package/src/element-behaviors.ts +424 -0
- package/src/element-config.ts +151 -0
- package/src/env.d.ts +1 -0
- package/src/hooks/use-application.ts +6 -4
- package/src/hooks/use-bind-setting.ts +47 -31
- package/src/hooks/use-merged-refs.ts +64 -0
- package/src/hooks/use-object-value.ts +27 -23
- package/src/hooks/use-parent-window.ts +4 -2
- package/src/hooks/use-property.ts +11 -10
- package/src/hooks/use-setting.ts +20 -33
- package/src/hooks/use-signal.ts +41 -48
- package/src/index.ts +7 -8
- package/src/internal.ts +8 -18
- package/src/prop-types.ts +142 -0
- package/src/reconciler/apply-props.ts +239 -85
- package/src/reconciler/behaviors.ts +330 -0
- package/src/reconciler/child-routing.ts +202 -0
- package/src/reconciler/host-config.ts +235 -367
- package/src/reconciler/instance.ts +76 -24
- package/src/reconciler/metadata.ts +119 -0
- package/src/reconciler/node.ts +161 -0
- package/src/reconciler/placement.ts +275 -0
- package/src/reconciler/registry.ts +175 -0
- package/src/reconciler/root-element.ts +9 -11
- package/src/reconciler/root.ts +172 -0
- package/src/reconciler/signals.ts +92 -0
- package/src/reconciler/text.ts +414 -0
- package/src/utils/accessible-metadata.ts +23 -18
- package/src/utils/accessible-props.ts +279 -0
- package/src/utils/ref-prop.ts +30 -0
- package/src/utils/settings.ts +69 -0
- package/src/utils/variant.ts +368 -0
- package/dist/hooks/use-merge-refs.d.ts +0 -3
- package/dist/hooks/use-merge-refs.d.ts.map +0 -1
- package/dist/hooks/use-merge-refs.js +0 -48
- package/dist/hooks/use-merge-refs.js.map +0 -1
- package/dist/hooks/use-object-attachment.d.ts +0 -10
- package/dist/hooks/use-object-attachment.d.ts.map +0 -1
- package/dist/hooks/use-object-attachment.js +0 -24
- package/dist/hooks/use-object-attachment.js.map +0 -1
- package/dist/libraries/adw/dialog.d.ts.map +0 -1
- package/dist/libraries/adw/dialog.js +0 -25
- package/dist/libraries/adw/dialog.js.map +0 -1
- package/dist/libraries/adw/index.d.ts +0 -2
- package/dist/libraries/adw/index.d.ts.map +0 -1
- package/dist/libraries/adw/index.js +0 -2
- package/dist/libraries/adw/index.js.map +0 -1
- package/dist/reconciler/accessible.d.ts.map +0 -1
- package/dist/reconciler/accessible.js +0 -143
- package/dist/reconciler/accessible.js.map +0 -1
- package/dist/reconciler/commit-flush.d.ts +0 -3
- package/dist/reconciler/commit-flush.d.ts.map +0 -1
- package/dist/reconciler/commit-flush.js +0 -13
- package/dist/reconciler/commit-flush.js.map +0 -1
- package/dist/reconciler/container-attach.d.ts +0 -10
- package/dist/reconciler/container-attach.d.ts.map +0 -1
- package/dist/reconciler/container-attach.js +0 -216
- package/dist/reconciler/container-attach.js.map +0 -1
- package/dist/reconciler/content-rebuild.d.ts +0 -3
- package/dist/reconciler/content-rebuild.d.ts.map +0 -1
- package/dist/reconciler/content-rebuild.js +0 -15
- package/dist/reconciler/content-rebuild.js.map +0 -1
- package/dist/reconciler/dispatch.d.ts +0 -6
- package/dist/reconciler/dispatch.d.ts.map +0 -1
- package/dist/reconciler/dispatch.js +0 -61
- package/dist/reconciler/dispatch.js.map +0 -1
- package/dist/reconciler/element-prop-appliers.d.ts +0 -5
- package/dist/reconciler/element-prop-appliers.d.ts.map +0 -1
- package/dist/reconciler/element-prop-appliers.js +0 -104
- package/dist/reconciler/element-prop-appliers.js.map +0 -1
- package/dist/reconciler/element-props.d.ts +0 -25
- package/dist/reconciler/element-props.d.ts.map +0 -1
- package/dist/reconciler/element-props.js +0 -157
- package/dist/reconciler/element-props.js.map +0 -1
- package/dist/reconciler/label-text-rebuild.d.ts +0 -3
- package/dist/reconciler/label-text-rebuild.d.ts.map +0 -1
- package/dist/reconciler/label-text-rebuild.js +0 -22
- package/dist/reconciler/label-text-rebuild.js.map +0 -1
- package/dist/reconciler/portal.d.ts +0 -11
- package/dist/reconciler/portal.d.ts.map +0 -1
- package/dist/reconciler/portal.js +0 -20
- package/dist/reconciler/portal.js.map +0 -1
- package/dist/reconciler/reconciler-error-handler.d.ts +0 -7
- package/dist/reconciler/reconciler-error-handler.d.ts.map +0 -1
- package/dist/reconciler/reconciler-error-handler.js +0 -24
- package/dist/reconciler/reconciler-error-handler.js.map +0 -1
- package/dist/reconciler/reconciler-root.d.ts +0 -19
- package/dist/reconciler/reconciler-root.d.ts.map +0 -1
- package/dist/reconciler/reconciler-root.js +0 -24
- package/dist/reconciler/reconciler-root.js.map +0 -1
- package/dist/reconciler/reconciler.d.ts +0 -3
- package/dist/reconciler/reconciler.d.ts.map +0 -1
- package/dist/reconciler/reconciler.js +0 -12
- package/dist/reconciler/reconciler.js.map +0 -1
- package/dist/reconciler/render.d.ts +0 -23
- package/dist/reconciler/render.d.ts.map +0 -1
- package/dist/reconciler/render.js +0 -46
- package/dist/reconciler/render.js.map +0 -1
- package/dist/reconciler/signal-store.d.ts +0 -22
- package/dist/reconciler/signal-store.d.ts.map +0 -1
- package/dist/reconciler/signal-store.js +0 -84
- package/dist/reconciler/signal-store.js.map +0 -1
- package/dist/reconciler/state.d.ts +0 -36
- package/dist/reconciler/state.d.ts.map +0 -1
- package/dist/reconciler/state.js +0 -38
- package/dist/reconciler/state.js.map +0 -1
- package/dist/reconciler/text-buffer-controller.d.ts +0 -17
- package/dist/reconciler/text-buffer-controller.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-controller.js +0 -102
- package/dist/reconciler/text-buffer-controller.js.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.d.ts +0 -3
- package/dist/reconciler/text-buffer-rebuild.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.js +0 -7
- package/dist/reconciler/text-buffer-rebuild.js.map +0 -1
- package/dist/reconciler/text-node.d.ts +0 -7
- package/dist/reconciler/text-node.d.ts.map +0 -1
- package/dist/reconciler/text-node.js +0 -8
- package/dist/reconciler/text-node.js.map +0 -1
- package/dist/reconciler/types.d.ts +0 -5
- package/dist/reconciler/types.d.ts.map +0 -1
- package/dist/reconciler/types.js +0 -2
- package/dist/reconciler/types.js.map +0 -1
- package/dist/reconciler/visibility.d.ts +0 -6
- package/dist/reconciler/visibility.d.ts.map +0 -1
- package/dist/reconciler/visibility.js +0 -57
- package/dist/reconciler/visibility.js.map +0 -1
- package/dist/reconciler/wrapper-apply.d.ts +0 -6
- package/dist/reconciler/wrapper-apply.d.ts.map +0 -1
- package/dist/reconciler/wrapper-apply.js +0 -287
- package/dist/reconciler/wrapper-apply.js.map +0 -1
- package/dist/reconciler/wrapper-content.d.ts +0 -8
- package/dist/reconciler/wrapper-content.d.ts.map +0 -1
- package/dist/reconciler/wrapper-content.js +0 -19
- package/dist/reconciler/wrapper-content.js.map +0 -1
- package/dist/reconciler/wrapper-node.d.ts +0 -8
- package/dist/reconciler/wrapper-node.d.ts.map +0 -1
- package/dist/reconciler/wrapper-node.js +0 -4
- package/dist/reconciler/wrapper-node.js.map +0 -1
- package/dist/reconciler/wrapper-protocol.d.ts +0 -13
- package/dist/reconciler/wrapper-protocol.d.ts.map +0 -1
- package/dist/reconciler/wrapper-protocol.js +0 -20
- package/dist/reconciler/wrapper-protocol.js.map +0 -1
- package/dist/utils/create-element-component.d.ts +0 -4
- package/dist/utils/create-element-component.d.ts.map +0 -1
- package/dist/utils/create-element-component.js +0 -54
- package/dist/utils/create-element-component.js.map +0 -1
- package/dist/utils/gtype.d.ts +0 -16
- package/dist/utils/gtype.d.ts.map +0 -1
- package/dist/utils/gtype.js +0 -127
- package/dist/utils/gtype.js.map +0 -1
- package/dist/utils/notify-name.d.ts +0 -5
- package/dist/utils/notify-name.d.ts.map +0 -1
- package/dist/utils/notify-name.js +0 -6
- package/dist/utils/notify-name.js.map +0 -1
- package/dist/utils/object-prop.d.ts +0 -8
- package/dist/utils/object-prop.d.ts.map +0 -1
- package/dist/utils/object-prop.js +0 -9
- package/dist/utils/object-prop.js.map +0 -1
- package/dist/utils/settings-accessor.d.ts +0 -8
- package/dist/utils/settings-accessor.d.ts.map +0 -1
- package/dist/utils/settings-accessor.js +0 -69
- package/dist/utils/settings-accessor.js.map +0 -1
- package/dist/utils/wrapper-node-jsx.d.ts +0 -32
- package/dist/utils/wrapper-node-jsx.d.ts.map +0 -1
- package/dist/utils/wrapper-node-jsx.js +0 -2
- package/dist/utils/wrapper-node-jsx.js.map +0 -1
- package/src/hooks/use-merge-refs.ts +0 -53
- package/src/hooks/use-object-attachment.ts +0 -35
- package/src/libraries/adw/dialog.tsx +0 -34
- package/src/libraries/adw/index.ts +0 -1
- package/src/reconciler/accessible.ts +0 -232
- package/src/reconciler/commit-flush.ts +0 -13
- package/src/reconciler/container-attach.ts +0 -219
- package/src/reconciler/content-rebuild.ts +0 -19
- package/src/reconciler/dispatch.ts +0 -58
- package/src/reconciler/element-prop-appliers.ts +0 -110
- package/src/reconciler/element-props.ts +0 -192
- package/src/reconciler/label-text-rebuild.ts +0 -26
- package/src/reconciler/portal.ts +0 -28
- package/src/reconciler/reconciler-error-handler.ts +0 -29
- package/src/reconciler/reconciler-root.ts +0 -57
- package/src/reconciler/reconciler.ts +0 -13
- package/src/reconciler/render.ts +0 -61
- package/src/reconciler/signal-store.ts +0 -103
- package/src/reconciler/state.ts +0 -72
- package/src/reconciler/text-buffer-controller.ts +0 -107
- package/src/reconciler/text-buffer-rebuild.ts +0 -12
- package/src/reconciler/text-node.ts +0 -13
- package/src/reconciler/types.ts +0 -6
- package/src/reconciler/visibility.ts +0 -52
- package/src/reconciler/wrapper-apply.ts +0 -308
- package/src/reconciler/wrapper-content.ts +0 -24
- package/src/reconciler/wrapper-node.ts +0 -8
- package/src/reconciler/wrapper-protocol.ts +0 -32
- package/src/utils/create-element-component.ts +0 -77
- package/src/utils/gtype.ts +0 -166
- package/src/utils/notify-name.ts +0 -10
- package/src/utils/object-prop.ts +0 -13
- package/src/utils/settings-accessor.ts +0 -89
- package/src/utils/wrapper-node-jsx.ts +0 -34
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
import { type ElementType, type ReactNode, type Ref,
|
|
3
|
-
import {
|
|
2
|
+
import { type ElementType, type ReactNode, type Ref, useLayoutEffect, useState } from "react";
|
|
3
|
+
import { useMergedRef } from "../hooks/use-merged-refs.js";
|
|
4
4
|
import { ParentWindowContext } from "../hooks/use-parent-window.js";
|
|
5
|
+
import { applyWrite } from "../reconciler/signals.js";
|
|
5
6
|
|
|
6
7
|
type WindowComponentProps = {
|
|
7
8
|
ref?: Ref<Gtk.Window | null> | undefined;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const presentWindow = (window: Gtk.Window): void => {
|
|
12
|
+
applyWrite(() => {
|
|
13
|
+
window.present();
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const destroyWindow = (window: Gtk.Window): void => {
|
|
18
|
+
applyWrite(() => {
|
|
19
|
+
window.destroy();
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const createWindowComponent = (Component: ElementType): ((props: WindowComponentProps) => ReactNode) => {
|
|
11
24
|
return ({ ref, ...rest }: WindowComponentProps): ReactNode => {
|
|
12
25
|
const [window, setWindow] = useState<Gtk.Window | null>(null);
|
|
26
|
+
const mergedRef = useMergedRef(ref, setWindow);
|
|
27
|
+
|
|
28
|
+
useLayoutEffect(() => {
|
|
29
|
+
if (!window) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
13
32
|
|
|
14
|
-
|
|
15
|
-
setWindow(window);
|
|
33
|
+
presentWindow(window);
|
|
16
34
|
|
|
17
35
|
return () => {
|
|
18
|
-
window
|
|
19
|
-
window.destroy();
|
|
20
|
-
setWindow(null);
|
|
36
|
+
destroyWindow(window);
|
|
21
37
|
};
|
|
22
|
-
}, []);
|
|
23
|
-
|
|
24
|
-
useLayoutEffect(() => {
|
|
25
|
-
window?.present();
|
|
26
38
|
}, [window]);
|
|
27
39
|
|
|
28
|
-
const mergedRef = useMergeRefs(ref, handleMount);
|
|
29
|
-
|
|
30
40
|
return (
|
|
31
41
|
<ParentWindowContext.Provider value={window}>
|
|
32
42
|
<Component ref={mergedRef} {...rest} />
|
|
@@ -34,3 +44,5 @@ export const createWindowComponent = (Component: ElementType): ((props: WindowCo
|
|
|
34
44
|
);
|
|
35
45
|
};
|
|
36
46
|
};
|
|
47
|
+
|
|
48
|
+
export { createWindowComponent };
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { BUILTIN_ELEMENTS } from "./element-config.js";
|
|
2
|
+
export type { DetachInfo, ElementBehavior, ElementConfig, ModuleExport, PlaceInfo } from "./reconciler/registry.js";
|
|
3
|
+
export {
|
|
4
|
+
defineBehavior,
|
|
5
|
+
defineElements,
|
|
6
|
+
ELEMENTS,
|
|
7
|
+
forTypes,
|
|
8
|
+
internal,
|
|
9
|
+
mergeElementConfigs,
|
|
10
|
+
} from "./reconciler/registry.js";
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
import * as Gio from "@gtkx/gi/gio";
|
|
3
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
+
import type {
|
|
5
|
+
ActionAccel,
|
|
6
|
+
CreditSection,
|
|
7
|
+
DragSourceIcon,
|
|
8
|
+
LevelBarOffset,
|
|
9
|
+
MenuItem,
|
|
10
|
+
ScaleMark,
|
|
11
|
+
VflConstraints,
|
|
12
|
+
} from "./prop-types.js";
|
|
13
|
+
import { BUILTIN_ELEMENTS, SINGLE_CHILD_TYPES } from "./element-config.js";
|
|
14
|
+
import {
|
|
15
|
+
addRemoveSlot,
|
|
16
|
+
adoptedChildrenSlot,
|
|
17
|
+
boxSlot,
|
|
18
|
+
childSetterSlot,
|
|
19
|
+
controlledText,
|
|
20
|
+
deferred,
|
|
21
|
+
list,
|
|
22
|
+
slot,
|
|
23
|
+
value,
|
|
24
|
+
wrappingIndexedSlot,
|
|
25
|
+
} from "./reconciler/behaviors.js";
|
|
26
|
+
import { type ElementConfig, forTypes, registerElements } from "./reconciler/registry.js";
|
|
27
|
+
|
|
28
|
+
/** The runtime half of the built-in element configuration: the behaviors bound to each GObject type. */
|
|
29
|
+
const BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {
|
|
30
|
+
...forTypes(SINGLE_CHILD_TYPES, {
|
|
31
|
+
behaviors: [childSetterSlot()],
|
|
32
|
+
}),
|
|
33
|
+
...forTypes(["GtkHeaderBar", "GtkActionBar"], {
|
|
34
|
+
behaviors: [
|
|
35
|
+
addRemoveSlot<Gtk.Widget, Gtk.HeaderBar | Gtk.ActionBar>(
|
|
36
|
+
"start",
|
|
37
|
+
"GtkWidget",
|
|
38
|
+
(bar, child) => {
|
|
39
|
+
bar.packStart(child);
|
|
40
|
+
},
|
|
41
|
+
(bar, child) => {
|
|
42
|
+
bar.remove(child);
|
|
43
|
+
},
|
|
44
|
+
),
|
|
45
|
+
addRemoveSlot<Gtk.Widget, Gtk.HeaderBar | Gtk.ActionBar>(
|
|
46
|
+
"end",
|
|
47
|
+
"GtkWidget",
|
|
48
|
+
(bar, child) => {
|
|
49
|
+
bar.packEnd(child);
|
|
50
|
+
},
|
|
51
|
+
(bar, child) => {
|
|
52
|
+
bar.remove(child);
|
|
53
|
+
},
|
|
54
|
+
),
|
|
55
|
+
],
|
|
56
|
+
}),
|
|
57
|
+
GtkWindow: {
|
|
58
|
+
behaviors: [childSetterSlot()],
|
|
59
|
+
},
|
|
60
|
+
GtkWidget: {
|
|
61
|
+
behaviors: [
|
|
62
|
+
slot<Gtk.Widget, Gtk.Popover>("children", "GtkPopover", {
|
|
63
|
+
attach: (parent, popover) => {
|
|
64
|
+
popover.setParent(parent);
|
|
65
|
+
},
|
|
66
|
+
detach: (_parent, popover) => {
|
|
67
|
+
popover.unparent();
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
addRemoveSlot<Gtk.EventController, Gtk.Widget>(
|
|
71
|
+
"controllers",
|
|
72
|
+
"GtkEventController",
|
|
73
|
+
(widget, controller) => {
|
|
74
|
+
widget.addController(controller);
|
|
75
|
+
},
|
|
76
|
+
(widget, controller) => {
|
|
77
|
+
widget.removeController(controller);
|
|
78
|
+
},
|
|
79
|
+
),
|
|
80
|
+
slot<Gtk.Widget, Gtk.LayoutManager>("layoutManager", "GtkLayoutManager", {
|
|
81
|
+
attach: (widget, manager) => {
|
|
82
|
+
widget.setLayoutManager(manager);
|
|
83
|
+
},
|
|
84
|
+
detach: (widget) => {
|
|
85
|
+
widget.setLayoutManager(null);
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
slot<Gtk.Widget, Gio.ActionGroup>("actionGroups", "GActionGroup", {
|
|
89
|
+
attach: (widget, group, info) => {
|
|
90
|
+
widget.insertActionGroup((info.props.prefix as string | null) ?? "", group);
|
|
91
|
+
},
|
|
92
|
+
detach: (widget, _group, info) => {
|
|
93
|
+
widget.insertActionGroup((info.props.prefix as string | null) ?? "", null);
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
GtkBox: {
|
|
99
|
+
behaviors: [boxSlot<Gtk.Box>()],
|
|
100
|
+
},
|
|
101
|
+
GtkListBox: {
|
|
102
|
+
behaviors: [
|
|
103
|
+
wrappingIndexedSlot(Gtk.ListBoxRow, (row, inner) => {
|
|
104
|
+
row.setChild(inner);
|
|
105
|
+
}),
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
GtkFlowBox: {
|
|
109
|
+
behaviors: [
|
|
110
|
+
wrappingIndexedSlot(Gtk.FlowBoxChild, (child, inner) => {
|
|
111
|
+
child.setChild(inner);
|
|
112
|
+
}),
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
GtkOverlay: {
|
|
116
|
+
behaviors: [
|
|
117
|
+
childSetterSlot<Gtk.Overlay>(),
|
|
118
|
+
slot<Gtk.Overlay, Gtk.Widget>("overlays", "GtkWidget", {
|
|
119
|
+
attach: (overlay, child) => {
|
|
120
|
+
overlay.addOverlay(child);
|
|
121
|
+
},
|
|
122
|
+
detach: (overlay, child) => {
|
|
123
|
+
overlay.removeOverlay(child);
|
|
124
|
+
},
|
|
125
|
+
resolve: layoutChild,
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
GtkShortcutController: {
|
|
130
|
+
behaviors: [
|
|
131
|
+
addRemoveSlot<Gtk.Shortcut, Gtk.ShortcutController>(
|
|
132
|
+
"shortcuts",
|
|
133
|
+
"GtkShortcut",
|
|
134
|
+
(controller, shortcut) => {
|
|
135
|
+
controller.addShortcut(shortcut);
|
|
136
|
+
},
|
|
137
|
+
(controller, shortcut) => {
|
|
138
|
+
controller.removeShortcut(shortcut);
|
|
139
|
+
},
|
|
140
|
+
),
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
GtkTextChildAnchor: {
|
|
144
|
+
behaviors: [{ create: () => Gtk.TextChildAnchor.new() }],
|
|
145
|
+
},
|
|
146
|
+
GtkTextView: {
|
|
147
|
+
behaviors: [
|
|
148
|
+
slot<Gtk.TextView, Gtk.TextBuffer>("children", "GtkTextBuffer", {
|
|
149
|
+
attach: (view, buffer) => {
|
|
150
|
+
view.setBuffer(buffer);
|
|
151
|
+
},
|
|
152
|
+
detach: (view) => {
|
|
153
|
+
view.setBuffer(null);
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
GActionMap: {
|
|
159
|
+
behaviors: [
|
|
160
|
+
slot<Gio.ActionMap, Gio.Action>("actions", "GAction", {
|
|
161
|
+
attach: (map, action) => {
|
|
162
|
+
map.addAction(action);
|
|
163
|
+
},
|
|
164
|
+
detach: (map, _action, info) => {
|
|
165
|
+
map.removeAction((info.props.name as string | null) ?? "");
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
GMenu: {
|
|
171
|
+
behaviors: [
|
|
172
|
+
list<Gio.Menu, MenuItem>("items", {
|
|
173
|
+
clear: (menu) => {
|
|
174
|
+
menu.removeAll();
|
|
175
|
+
},
|
|
176
|
+
add: (menu, item) => {
|
|
177
|
+
appendMenuItem(menu, item);
|
|
178
|
+
},
|
|
179
|
+
}),
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
GtkColumnView: {
|
|
183
|
+
behaviors: [
|
|
184
|
+
slot<Gtk.ColumnView, Gtk.ColumnViewColumn>("children", "GtkColumnViewColumn", {
|
|
185
|
+
attach: (view, column, info) => {
|
|
186
|
+
view.insertColumn(info.index, column);
|
|
187
|
+
},
|
|
188
|
+
detach: (view, column) => {
|
|
189
|
+
view.removeColumn(column);
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
GtkGrid: {
|
|
195
|
+
behaviors: [
|
|
196
|
+
slot<Gtk.Grid, Gtk.Widget>("children", "GtkWidget", {
|
|
197
|
+
attach: (grid, child) => {
|
|
198
|
+
grid.attach(child, 0, 0, 1, 1);
|
|
199
|
+
},
|
|
200
|
+
detach: (grid, child) => {
|
|
201
|
+
grid.remove(child);
|
|
202
|
+
},
|
|
203
|
+
resolve: layoutChild,
|
|
204
|
+
}),
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
GtkFixed: {
|
|
208
|
+
behaviors: [
|
|
209
|
+
slot<Gtk.Fixed, Gtk.Widget>("children", "GtkWidget", {
|
|
210
|
+
attach: (fixed, child) => {
|
|
211
|
+
fixed.put(child, 0, 0);
|
|
212
|
+
},
|
|
213
|
+
detach: (fixed, child) => {
|
|
214
|
+
fixed.remove(child);
|
|
215
|
+
},
|
|
216
|
+
resolve: layoutChild,
|
|
217
|
+
}),
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
GtkSizeGroup: {
|
|
221
|
+
behaviors: [
|
|
222
|
+
list<Gtk.SizeGroup, Gtk.Widget>("widgets", {
|
|
223
|
+
add: (group, widget) => {
|
|
224
|
+
group.addWidget(widget);
|
|
225
|
+
},
|
|
226
|
+
remove: (group, widget) => {
|
|
227
|
+
group.removeWidget(widget);
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
GtkConstraintLayout: {
|
|
233
|
+
behaviors: [
|
|
234
|
+
addRemoveSlot<Gtk.Constraint, Gtk.ConstraintLayout>(
|
|
235
|
+
"constraints",
|
|
236
|
+
"GtkConstraint",
|
|
237
|
+
(layout, constraint) => {
|
|
238
|
+
layout.addConstraint(constraint);
|
|
239
|
+
},
|
|
240
|
+
(layout, constraint) => {
|
|
241
|
+
layout.removeConstraint(constraint);
|
|
242
|
+
},
|
|
243
|
+
),
|
|
244
|
+
addRemoveSlot<Gtk.ConstraintGuide, Gtk.ConstraintLayout>(
|
|
245
|
+
"guides",
|
|
246
|
+
"GtkConstraintGuide",
|
|
247
|
+
(layout, guide) => {
|
|
248
|
+
layout.addGuide(guide);
|
|
249
|
+
},
|
|
250
|
+
(layout, guide) => {
|
|
251
|
+
layout.removeGuide(guide);
|
|
252
|
+
},
|
|
253
|
+
),
|
|
254
|
+
list<Gtk.ConstraintLayout, VflConstraints, Gtk.Constraint[]>("vfl", {
|
|
255
|
+
add: (layout, item) => [
|
|
256
|
+
...layout.addConstraintsFromDescription(
|
|
257
|
+
item.lines,
|
|
258
|
+
item.hspacing ?? 0,
|
|
259
|
+
item.vspacing ?? 0,
|
|
260
|
+
item.views ?? new Map<string, Gtk.ConstraintTarget>(),
|
|
261
|
+
),
|
|
262
|
+
],
|
|
263
|
+
remove: (layout, _item, constraints) => {
|
|
264
|
+
for (const constraint of constraints) {
|
|
265
|
+
layout.removeConstraint(constraint);
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
}),
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
GtkStack: {
|
|
272
|
+
behaviors: [
|
|
273
|
+
adoptedChildrenSlot<Gtk.Stack, Gtk.Widget>(
|
|
274
|
+
"GtkWidget",
|
|
275
|
+
(stack, child) => stack.addChild(child),
|
|
276
|
+
(stack, child) => {
|
|
277
|
+
stack.remove(child);
|
|
278
|
+
},
|
|
279
|
+
),
|
|
280
|
+
deferred<Gtk.Stack, string>("visibleChildName", (stack, name) => stack.getChildByName(name) !== null),
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
GtkNotebook: {
|
|
284
|
+
behaviors: [
|
|
285
|
+
slot<Gtk.Notebook, Gtk.Widget>("children", "GtkWidget", {
|
|
286
|
+
attach: (notebook, child, info) => notebook.insertPage(child, null, info.index),
|
|
287
|
+
reorder: (notebook, child, info) => {
|
|
288
|
+
notebook.reorderChild(child, info.index);
|
|
289
|
+
},
|
|
290
|
+
detach: (notebook, child) => {
|
|
291
|
+
notebook.detachTab(child);
|
|
292
|
+
},
|
|
293
|
+
resolve: (notebook, child) => notebook.getPage(child),
|
|
294
|
+
}),
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
GtkApplication: {
|
|
298
|
+
behaviors: [
|
|
299
|
+
addRemoveSlot<Gtk.Window, Gtk.Application>(
|
|
300
|
+
"children",
|
|
301
|
+
"GtkWindow",
|
|
302
|
+
(application, window) => {
|
|
303
|
+
application.addWindow(window);
|
|
304
|
+
},
|
|
305
|
+
(application, window) => {
|
|
306
|
+
application.removeWindow(window);
|
|
307
|
+
},
|
|
308
|
+
),
|
|
309
|
+
list<Gtk.Application, ActionAccel>("actionAccels", {
|
|
310
|
+
add: (application, item) => {
|
|
311
|
+
application.setAccelsForAction(item.detailedActionName, item.accels);
|
|
312
|
+
},
|
|
313
|
+
remove: (application, item) => {
|
|
314
|
+
application.setAccelsForAction(item.detailedActionName, []);
|
|
315
|
+
},
|
|
316
|
+
}),
|
|
317
|
+
],
|
|
318
|
+
},
|
|
319
|
+
GtkAboutDialog: {
|
|
320
|
+
behaviors: [
|
|
321
|
+
list<Gtk.AboutDialog, CreditSection>("creditSections", {
|
|
322
|
+
add: (dialog, section) => {
|
|
323
|
+
dialog.addCreditSection(section.sectionName, section.people);
|
|
324
|
+
},
|
|
325
|
+
}),
|
|
326
|
+
],
|
|
327
|
+
},
|
|
328
|
+
GtkScale: {
|
|
329
|
+
behaviors: [
|
|
330
|
+
list<Gtk.Scale, ScaleMark>("marks", {
|
|
331
|
+
add: (scale, mark) => {
|
|
332
|
+
scale.addMark(mark.value ?? 0, mark.position, mark.markup ?? null);
|
|
333
|
+
},
|
|
334
|
+
clear: (scale) => {
|
|
335
|
+
scale.clearMarks();
|
|
336
|
+
},
|
|
337
|
+
}),
|
|
338
|
+
],
|
|
339
|
+
},
|
|
340
|
+
GtkCalendar: {
|
|
341
|
+
behaviors: [
|
|
342
|
+
list<Gtk.Calendar, number>("markedDays", {
|
|
343
|
+
add: (calendar, day) => {
|
|
344
|
+
calendar.markDay(day);
|
|
345
|
+
},
|
|
346
|
+
clear: (calendar) => {
|
|
347
|
+
calendar.clearMarks();
|
|
348
|
+
},
|
|
349
|
+
}),
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
GtkLevelBar: {
|
|
353
|
+
behaviors: [
|
|
354
|
+
list<Gtk.LevelBar, LevelBarOffset>("offsets", {
|
|
355
|
+
add: (bar, offset) => {
|
|
356
|
+
bar.addOffsetValue(offset.name, offset.value ?? 0);
|
|
357
|
+
},
|
|
358
|
+
remove: (bar, offset) => {
|
|
359
|
+
bar.removeOffsetValue(offset.name);
|
|
360
|
+
},
|
|
361
|
+
}),
|
|
362
|
+
],
|
|
363
|
+
},
|
|
364
|
+
GtkDropTarget: {
|
|
365
|
+
behaviors: [
|
|
366
|
+
value<Gtk.DropTarget, GObject.Type[]>("types", (target, types) => {
|
|
367
|
+
target.setGtypes(types);
|
|
368
|
+
}),
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
GtkDrawingArea: {
|
|
372
|
+
behaviors: [
|
|
373
|
+
value<Gtk.DrawingArea, Gtk.DrawingAreaDrawFunc>("drawFunc", (area, draw) => {
|
|
374
|
+
area.setDrawFunc(draw);
|
|
375
|
+
area.queueDraw();
|
|
376
|
+
}),
|
|
377
|
+
],
|
|
378
|
+
},
|
|
379
|
+
GtkDragSource: {
|
|
380
|
+
behaviors: [
|
|
381
|
+
value<Gtk.DragSource, DragSourceIcon>("icon", (source, icon) => {
|
|
382
|
+
source.setIcon(icon.paintable ?? null, icon.hotX ?? 0, icon.hotY ?? 0);
|
|
383
|
+
}),
|
|
384
|
+
],
|
|
385
|
+
},
|
|
386
|
+
GtkEditable: {
|
|
387
|
+
behaviors: [controlledText("text")],
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
function layoutChild(parent: Gtk.Widget, child: Gtk.Widget): GObject.Object | null {
|
|
392
|
+
return parent.getLayoutManager()?.getLayoutChild(child) ?? null;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const buildMenu = (items: MenuItem[]): Gio.Menu => {
|
|
396
|
+
const menu = Gio.Menu.new();
|
|
397
|
+
|
|
398
|
+
for (const item of items) {
|
|
399
|
+
appendMenuItem(menu, item);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return menu;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
function appendMenuItem(menu: Gio.Menu, item: MenuItem): void {
|
|
406
|
+
const label = item.label ?? null;
|
|
407
|
+
|
|
408
|
+
if (item.submenu !== undefined) {
|
|
409
|
+
menu.appendSubmenu(label, buildMenu(item.submenu));
|
|
410
|
+
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (item.section !== undefined) {
|
|
415
|
+
menu.appendSection(label, buildMenu(item.section));
|
|
416
|
+
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
menu.append(label, item.action ?? null);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
registerElements(BUILTIN_ELEMENTS);
|
|
424
|
+
registerElements(BUILTIN_BEHAVIORS);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { type ElementConfig, forTypes, internal } from "./reconciler/registry.js";
|
|
2
|
+
|
|
3
|
+
const SINGLE_CHILD_TYPES: string[] = [
|
|
4
|
+
"GtkAspectFrame",
|
|
5
|
+
"GtkButton",
|
|
6
|
+
"GtkCheckButton",
|
|
7
|
+
"GtkComboBox",
|
|
8
|
+
"GtkDragIcon",
|
|
9
|
+
"GtkExpander",
|
|
10
|
+
"GtkFlowBoxChild",
|
|
11
|
+
"GtkFrame",
|
|
12
|
+
"GtkGraphicsOffload",
|
|
13
|
+
"GtkListBoxRow",
|
|
14
|
+
"GtkListHeader",
|
|
15
|
+
"GtkListItem",
|
|
16
|
+
"GtkMenuButton",
|
|
17
|
+
"GtkPopover",
|
|
18
|
+
"GtkPopoverBin",
|
|
19
|
+
"GtkRevealer",
|
|
20
|
+
"GtkScrolledWindow",
|
|
21
|
+
"GtkSearchBar",
|
|
22
|
+
"GtkTreeExpander",
|
|
23
|
+
"GtkViewport",
|
|
24
|
+
"GtkWindowHandle",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The static, runtime-free half of the built-in element configuration: which base props interface each
|
|
29
|
+
* generated element extends, which component wraps it, and whether its GObject is created lazily by its
|
|
30
|
+
* parent. Codegen imports this module, so it must never reach the GObject bindings.
|
|
31
|
+
*/
|
|
32
|
+
const BUILTIN_ELEMENTS: Record<string, ElementConfig> = {
|
|
33
|
+
...forTypes(SINGLE_CHILD_TYPES, {
|
|
34
|
+
props: internal("ChildrenProps"),
|
|
35
|
+
omitProps: ["child"],
|
|
36
|
+
}),
|
|
37
|
+
...forTypes(["GtkHeaderBar", "GtkActionBar"], {
|
|
38
|
+
props: internal("GtkHeaderBarProps"),
|
|
39
|
+
}),
|
|
40
|
+
GtkWindow: {
|
|
41
|
+
props: internal("ChildrenProps"),
|
|
42
|
+
component: internal("createWindowComponent"),
|
|
43
|
+
omitProps: ["child"],
|
|
44
|
+
},
|
|
45
|
+
GtkLabel: {
|
|
46
|
+
props: internal("ChildrenProps"),
|
|
47
|
+
},
|
|
48
|
+
GtkTextBuffer: {
|
|
49
|
+
props: internal("ChildrenProps"),
|
|
50
|
+
},
|
|
51
|
+
GtkTextTag: {
|
|
52
|
+
props: internal("ChildrenProps"),
|
|
53
|
+
},
|
|
54
|
+
GtkTextChildAnchor: {
|
|
55
|
+
props: internal("GtkTextChildAnchorProps"),
|
|
56
|
+
},
|
|
57
|
+
GtkGridLayoutChild: {
|
|
58
|
+
lazy: true,
|
|
59
|
+
},
|
|
60
|
+
GtkFixedLayoutChild: {
|
|
61
|
+
lazy: true,
|
|
62
|
+
},
|
|
63
|
+
GtkOverlayLayoutChild: {
|
|
64
|
+
lazy: true,
|
|
65
|
+
},
|
|
66
|
+
GtkStackPage: {
|
|
67
|
+
lazy: true,
|
|
68
|
+
},
|
|
69
|
+
GtkNotebookPage: {
|
|
70
|
+
lazy: true,
|
|
71
|
+
},
|
|
72
|
+
GActionGroup: {
|
|
73
|
+
props: internal("GActionGroupProps"),
|
|
74
|
+
},
|
|
75
|
+
GtkWidget: {
|
|
76
|
+
props: internal("GtkWidgetProps"),
|
|
77
|
+
},
|
|
78
|
+
GtkBox: {
|
|
79
|
+
props: internal("ChildrenProps"),
|
|
80
|
+
},
|
|
81
|
+
GtkListBox: {
|
|
82
|
+
props: internal("ChildrenProps"),
|
|
83
|
+
},
|
|
84
|
+
GtkFlowBox: {
|
|
85
|
+
props: internal("ChildrenProps"),
|
|
86
|
+
},
|
|
87
|
+
GtkOverlay: {
|
|
88
|
+
props: internal("GtkOverlayProps"),
|
|
89
|
+
omitProps: ["child"],
|
|
90
|
+
},
|
|
91
|
+
GtkShortcutController: {
|
|
92
|
+
props: internal("GtkShortcutControllerProps"),
|
|
93
|
+
},
|
|
94
|
+
GtkTextView: {
|
|
95
|
+
props: internal("ChildrenProps"),
|
|
96
|
+
},
|
|
97
|
+
GActionMap: {
|
|
98
|
+
props: internal("GActionMapProps"),
|
|
99
|
+
},
|
|
100
|
+
GMenu: {
|
|
101
|
+
props: internal("GMenuProps"),
|
|
102
|
+
},
|
|
103
|
+
GtkColumnView: {
|
|
104
|
+
props: internal("ChildrenProps"),
|
|
105
|
+
},
|
|
106
|
+
GtkGrid: {
|
|
107
|
+
props: internal("ChildrenProps"),
|
|
108
|
+
},
|
|
109
|
+
GtkFixed: {
|
|
110
|
+
props: internal("ChildrenProps"),
|
|
111
|
+
},
|
|
112
|
+
GtkSizeGroup: {
|
|
113
|
+
props: internal("GtkSizeGroupProps"),
|
|
114
|
+
},
|
|
115
|
+
GtkConstraintLayout: {
|
|
116
|
+
props: internal("GtkConstraintLayoutProps"),
|
|
117
|
+
},
|
|
118
|
+
GtkStack: {
|
|
119
|
+
props: internal("ChildrenProps"),
|
|
120
|
+
},
|
|
121
|
+
GtkNotebook: {
|
|
122
|
+
props: internal("ChildrenProps"),
|
|
123
|
+
},
|
|
124
|
+
GtkApplication: {
|
|
125
|
+
props: internal("GtkApplicationProps"),
|
|
126
|
+
component: internal("createApplicationComponent"),
|
|
127
|
+
},
|
|
128
|
+
GtkAboutDialog: {
|
|
129
|
+
props: internal("GtkAboutDialogProps"),
|
|
130
|
+
},
|
|
131
|
+
GtkScale: {
|
|
132
|
+
props: internal("GtkScaleProps"),
|
|
133
|
+
},
|
|
134
|
+
GtkCalendar: {
|
|
135
|
+
props: internal("GtkCalendarProps"),
|
|
136
|
+
},
|
|
137
|
+
GtkLevelBar: {
|
|
138
|
+
props: internal("GtkLevelBarProps"),
|
|
139
|
+
},
|
|
140
|
+
GtkDropTarget: {
|
|
141
|
+
props: internal("GtkDropTargetProps"),
|
|
142
|
+
},
|
|
143
|
+
GtkDrawingArea: {
|
|
144
|
+
props: internal("GtkDrawingAreaProps"),
|
|
145
|
+
},
|
|
146
|
+
GtkDragSource: {
|
|
147
|
+
props: internal("GtkDragSourceProps"),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export { SINGLE_CHILD_TYPES, BUILTIN_ELEMENTS };
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@gtkx/react/env" />
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { type Context, createContext, use } from "react";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const ApplicationContext: Context<Gtk.Application | null> = createContext<Gtk.Application | null>(null);
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Returns the `Gtk.Application` provided by the nearest `
|
|
7
|
+
* Returns the `Gtk.Application` provided by the nearest `GtkApplication` ancestor, throwing if used outside one.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
const useApplication = (): Gtk.Application => {
|
|
10
10
|
const context = use(ApplicationContext);
|
|
11
11
|
|
|
12
12
|
if (!context) {
|
|
13
|
-
throw new Error("
|
|
13
|
+
throw new Error("useApplication must be called within GtkApplication");
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
return context;
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
export { ApplicationContext, useApplication };
|