@gtkx/react 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,24 @@
1
1
  import * as Adw from "@gtkx/gi/adw";
2
+ import * as Gtk from "@gtkx/gi/gtk";
2
3
  import { applicationCreator, boxSlot, childMatcher, childSetterSlot, contentSetterSlot, deferred, indexedSlot, list, methodSlot, setterSlot, slot, } from "../reconciler/behaviors.js";
3
4
  import { forTypes, registerElements } from "../reconciler/registry.js";
4
5
  import { BUILTIN_ELEMENTS, CHILD_SETTER_TYPES, CONTENT_SETTER_TYPES } from "./element-config.js";
5
6
  const SLOT_SUFFIX = "Slot";
6
7
  const childSetter = childSetterSlot();
7
- const contentSetter = contentSetterSlot();
8
- const breakpoints = methodSlot("breakpoints", "AdwBreakpoint", "addBreakpoint");
8
+ const contentSetter = contentSetterSlot(Gtk.Widget);
9
+ const breakpoints = methodSlot("breakpoints", Adw.Breakpoint, "addBreakpoint");
9
10
  const prefixSuffix = [
10
- methodSlot("prefix", "GtkWidget", "addPrefix", "remove"),
11
- methodSlot("suffix", "GtkWidget", "addSuffix", "remove"),
11
+ methodSlot("prefix", Gtk.Widget, "addPrefix", "remove"),
12
+ methodSlot("suffix", Gtk.Widget, "addSuffix", "remove"),
12
13
  ];
13
- const preferencesDialogChildren = methodSlot("children", "AdwPreferencesPage", "add", "remove");
14
- const alertDialogExtraChild = setterSlot("children", "GtkWidget", "setExtraChild");
15
- const sidebarSections = indexedSlot("children", "AdwSidebarSection");
16
- const sidebarItems = indexedSlot("children", "AdwSidebarItem");
17
- const isWidget = childMatcher("GtkWidget");
14
+ const preferencesDialogChildren = methodSlot("children", Adw.PreferencesPage, "add", "remove");
15
+ const alertDialogExtraChild = setterSlot("children", Gtk.Widget, "setExtraChild");
16
+ const sidebarSections = indexedSlot("children", Adw.SidebarSection);
17
+ const sidebarItems = indexedSlot("children", Adw.SidebarItem);
18
+ const isWidget = childMatcher(Gtk.Widget);
19
+ const scrollableWidget = {
20
+ [Symbol.hasInstance]: (value) => value instanceof Gtk.Scrollable && value instanceof Gtk.Widget,
21
+ };
18
22
  const multiLayoutSlots = {
19
23
  attach: (view, child, info) => {
20
24
  const id = getSlotId(info.slot);
@@ -29,13 +33,12 @@ const multiLayoutSlots = {
29
33
  if (id === null || !isWidget(child)) {
30
34
  return;
31
35
  }
32
- const widget = child;
33
- if (view.getChild(id) === widget) {
34
- widget.unparent();
36
+ if (view.getChild(id) === child) {
37
+ child.unparent();
35
38
  }
36
39
  },
37
40
  };
38
- const multiLayoutLayouts = slot("layouts", "GtkWidget", {
41
+ const multiLayoutLayouts = slot("layouts", Gtk.Widget, {
39
42
  attach: (view, content) => {
40
43
  const layout = new Adw.Layout({ content });
41
44
  view.addLayout(layout);
@@ -67,7 +70,7 @@ const BUILTIN_BEHAVIORS = {
67
70
  },
68
71
  AdwClampScrollable: {
69
72
  behaviors: [
70
- setterSlot("children", "GtkScrollable", "setChild"),
73
+ setterSlot("children", scrollableWidget, "setChild"),
71
74
  ],
72
75
  },
73
76
  ...forTypes(CHILD_SETTER_TYPES, {
@@ -88,7 +91,7 @@ const BUILTIN_BEHAVIORS = {
88
91
  AdwBreakpointBin: {
89
92
  behaviors: [
90
93
  childSetter,
91
- methodSlot("breakpoints", "AdwBreakpoint", "addBreakpoint", "removeBreakpoint"),
94
+ methodSlot("breakpoints", Adw.Breakpoint, "addBreakpoint", "removeBreakpoint"),
92
95
  ],
93
96
  },
94
97
  AdwActionRow: {
@@ -100,18 +103,18 @@ const BUILTIN_BEHAVIORS = {
100
103
  AdwExpanderRow: {
101
104
  behaviors: [
102
105
  ...prefixSuffix,
103
- methodSlot("rows", "GtkWidget", "addRow", "remove"),
106
+ methodSlot("rows", Gtk.Widget, "addRow", "remove"),
104
107
  ],
105
108
  },
106
109
  AdwNavigationSplitView: {
107
- behaviors: [contentSetterSlot("AdwNavigationPage")],
110
+ behaviors: [contentSetterSlot(Adw.NavigationPage)],
108
111
  },
109
112
  AdwWrapBox: {
110
113
  behaviors: [boxSlot()],
111
114
  },
112
115
  AdwCarousel: {
113
116
  behaviors: [
114
- slot("children", "GtkWidget", {
117
+ slot("children", Gtk.Widget, {
115
118
  attach: (carousel, child, info) => {
116
119
  carousel.insert(child, info.index);
117
120
  },
@@ -126,7 +129,7 @@ const BUILTIN_BEHAVIORS = {
126
129
  },
127
130
  AdwPreferencesPage: {
128
131
  behaviors: [
129
- slot("children", "AdwPreferencesGroup", {
132
+ slot("children", Adw.PreferencesGroup, {
130
133
  attach: (page, group, info) => {
131
134
  page.insert(group, info.index);
132
135
  },
@@ -140,11 +143,11 @@ const BUILTIN_BEHAVIORS = {
140
143
  behaviors: [preferencesDialogChildren],
141
144
  },
142
145
  AdwPreferencesGroup: {
143
- behaviors: [methodSlot("children", "GtkWidget", "add", "remove")],
146
+ behaviors: [methodSlot("children", Gtk.Widget, "add", "remove")],
144
147
  },
145
148
  AdwTabView: {
146
149
  behaviors: [
147
- slot("children", "GtkWidget", {
150
+ slot("children", Gtk.Widget, {
148
151
  attach: (view, child, info) => view.insert(child, info.index),
149
152
  reorder: (view, _child, info) => {
150
153
  if (info.adopted instanceof Adw.TabPage) {
@@ -162,37 +165,37 @@ const BUILTIN_BEHAVIORS = {
162
165
  },
163
166
  AdwNavigationView: {
164
167
  behaviors: [
165
- methodSlot("children", "AdwNavigationPage", "add", "remove"),
168
+ methodSlot("children", Adw.NavigationPage, "add", "remove"),
166
169
  ],
167
170
  },
168
171
  AdwViewStack: {
169
172
  behaviors: [
170
- methodSlot("children", "GtkWidget", "add", "remove"),
173
+ methodSlot("children", Gtk.Widget, "add", "remove"),
171
174
  deferred("visibleChildName", (stack, name) => stack.getChildByName(name) !== null),
172
175
  ],
173
176
  },
174
177
  AdwToolbarView: {
175
178
  behaviors: [
176
- contentSetterSlot(),
177
- methodSlot("topBar", "GtkWidget", "addTopBar", "remove"),
178
- methodSlot("bottomBar", "GtkWidget", "addBottomBar", "remove"),
179
+ contentSetterSlot(Gtk.Widget),
180
+ methodSlot("topBar", Gtk.Widget, "addTopBar", "remove"),
181
+ methodSlot("bottomBar", Gtk.Widget, "addBottomBar", "remove"),
179
182
  ],
180
183
  },
181
184
  AdwHeaderBar: {
182
185
  behaviors: [
183
- methodSlot("start", "GtkWidget", "packStart", "remove"),
184
- methodSlot("end", "GtkWidget", "packEnd", "remove"),
186
+ methodSlot("start", Gtk.Widget, "packStart", "remove"),
187
+ methodSlot("end", Gtk.Widget, "packEnd", "remove"),
185
188
  ],
186
189
  },
187
190
  AdwShortcutsDialog: {
188
- behaviors: [methodSlot("children", "AdwShortcutsSection", "add")],
191
+ behaviors: [methodSlot("children", Adw.ShortcutsSection, "add")],
189
192
  },
190
193
  AdwShortcutsSection: {
191
- behaviors: [methodSlot("children", "AdwShortcutsItem", "add")],
194
+ behaviors: [methodSlot("children", Adw.ShortcutsItem, "add")],
192
195
  },
193
196
  AdwToggleGroup: {
194
197
  behaviors: [
195
- methodSlot("children", "AdwToggle", "add", "remove"),
198
+ methodSlot("children", Adw.Toggle, "add", "remove"),
196
199
  deferred("activeName", (group, name) => group.getToggleByName(name) !== null),
197
200
  deferred("active"),
198
201
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"element-behaviors.js","sourceRoot":"","sources":["../../src/adw/element-behaviors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EACH,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,UAAU,EACV,UAAU,EACV,IAAI,GACP,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA4C,QAAQ,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAkBjG,MAAM,WAAW,GAAG,MAAM,CAAC;A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ACJ,CAAC;SACL;KACJ;CACJ,CAAC;AAEF,SAAS,SAAS,CAAC,IAAY;IAC3B,IAAI,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACnC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport type { AlertDialogResponse } from \"./prop-types.js\";\nimport {\n applicationCreator,\n boxSlot,\n childMatcher,\n childSetterSlot,\n contentSetterSlot,\n deferred,\n indexedSlot,\n list,\n methodSlot,\n setterSlot,\n slot,\n} from \"../reconciler/behaviors.js\";\nimport { type ElementBehavior, type ElementConfig, forTypes, registerElements } from \"../reconciler/registry.js\";\nimport { BUILTIN_ELEMENTS, CHILD_SETTER_TYPES, CONTENT_SETTER_TYPES } from \"./element-config.js\";\n\ntype AdwChildSetter =\n | Adw.Bin |\n Adw.BreakpointBin |\n Adw.Clamp |\n Adw.Dialog |\n Adw.NavigationPage |\n Adw.SplitButton |\n Adw.StatusPage |\n Adw.TabOverview |\n Adw.ToastOverlay |\n Adw.Toggle;\n\ntype AdwContentSetter = Adw.ApplicationWindow | Adw.BottomSheet | Adw.OverlaySplitView | Adw.Window;\ntype BreakpointHost = Adw.ApplicationWindow | Adw.Window | Adw.Dialog;\ntype PrefixSuffixRow = Adw.ActionRow | Adw.EntryRow | Adw.ExpanderRow;\n\nconst SLOT_SUFFIX = \"Slot\";\nconst childSetter = childSetterSlot<AdwChildSetter>();\nconst contentSetter = contentSetterSlot<AdwContentSetter>();\nconst breakpoints = methodSlot<BreakpointHost, Adw.Breakpoint>(\"breakpoints\", \"AdwBreakpoint\", \"addBreakpoint\");\n\nconst prefixSuffix = [\n methodSlot<PrefixSuffixRow, Gtk.Widget>(\"prefix\", \"GtkWidget\", \"addPrefix\", \"remove\"),\n methodSlot<PrefixSuffixRow, Gtk.Widget>(\"suffix\", \"GtkWidget\", \"addSuffix\", \"remove\"),\n];\n\nconst preferencesDialogChildren = methodSlot<Adw.PreferencesDialog, Adw.PreferencesPage>(\n \"children\", \"AdwPreferencesPage\", \"add\", \"remove\",\n);\n\nconst alertDialogExtraChild = setterSlot<Adw.AlertDialog, Gtk.Widget>(\"children\", \"GtkWidget\", \"setExtraChild\");\nconst sidebarSections = indexedSlot<Adw.Sidebar, Adw.SidebarSection>(\"children\", \"AdwSidebarSection\");\nconst sidebarItems = indexedSlot<Adw.SidebarSection, Adw.SidebarItem>(\"children\", \"AdwSidebarItem\");\nconst isWidget = childMatcher(\"GtkWidget\");\n\nconst multiLayoutSlots: ElementBehavior<Adw.MultiLayoutView> = {\n attach: (view, child, info) => {\n const id = getSlotId(info.slot);\n\n if (id === null || !isWidget(child)) {\n return;\n }\n\n view.setChild(id, child as Gtk.Widget);\n\n return true;\n },\n detach: (view, child, info) => {\n const id = getSlotId(info.slot);\n\n if (id === null || !isWidget(child)) {\n return;\n }\n\n const widget = child as Gtk.Widget;\n\n if (view.getChild(id) === widget) {\n widget.unparent();\n }\n },\n};\n\nconst multiLayoutLayouts = slot<Adw.MultiLayoutView, Gtk.Widget>(\"layouts\", \"GtkWidget\", {\n attach: (view, content) => {\n const layout = new Adw.Layout({ content });\n view.addLayout(layout);\n\n return layout;\n },\n reorder: (_view, _content, info) => info.adopted,\n detach: (view, _content, info) => {\n if (info.adopted instanceof Adw.Layout) {\n view.removeLayout(info.adopted);\n }\n },\n});\n\nconst BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {\n AdwApplication: {\n behaviors: [applicationCreator(Adw.Application)],\n },\n AdwSidebar: {\n behaviors: [sidebarSections],\n },\n AdwSidebarSection: {\n behaviors: [sidebarItems],\n },\n AdwMultiLayoutView: {\n behaviors: [\n multiLayoutLayouts,\n multiLayoutSlots,\n deferred<Adw.MultiLayoutView, string>(\"layoutName\", (view, name) => view.getLayoutByName(name) !== null),\n ],\n },\n AdwClampScrollable: {\n behaviors: [\n setterSlot<Adw.ClampScrollable, Gtk.Scrollable & Gtk.Widget>(\"children\", \"GtkScrollable\", \"setChild\"),\n ],\n },\n ...forTypes(CHILD_SETTER_TYPES, {\n behaviors: [childSetter],\n }),\n ...forTypes(CONTENT_SETTER_TYPES, {\n behaviors: [contentSetter],\n }),\n AdwDialog: {\n behaviors: [childSetter, breakpoints],\n },\n AdwApplicationWindow: {\n behaviors: [contentSetter, breakpoints],\n },\n AdwWindow: {\n behaviors: [contentSetter, breakpoints],\n },\n AdwBreakpointBin: {\n behaviors: [\n childSetter,\n methodSlot<Adw.BreakpointBin, Adw.Breakpoint>(\n \"breakpoints\", \"AdwBreakpoint\", \"addBreakpoint\", \"removeBreakpoint\",\n ),\n ],\n },\n AdwActionRow: {\n behaviors: prefixSuffix,\n },\n AdwEntryRow: {\n behaviors: prefixSuffix,\n },\n AdwExpanderRow: {\n behaviors: [\n ...prefixSuffix,\n methodSlot<Adw.ExpanderRow, Gtk.Widget>(\"rows\", \"GtkWidget\", \"addRow\", \"remove\"),\n ],\n },\n AdwNavigationSplitView: {\n behaviors: [contentSetterSlot<Adw.NavigationSplitView, Adw.NavigationPage>(\"AdwNavigationPage\")],\n },\n AdwWrapBox: {\n behaviors: [boxSlot<Adw.WrapBox>()],\n },\n AdwCarousel: {\n behaviors: [\n slot<Adw.Carousel, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (carousel, child, info) => {\n carousel.insert(child, info.index);\n },\n detach: (carousel, child) => {\n carousel.remove(child);\n },\n reorder: (carousel, child, info) => {\n carousel.reorder(child, info.index);\n },\n }),\n ],\n },\n AdwPreferencesPage: {\n behaviors: [\n slot<Adw.PreferencesPage, Adw.PreferencesGroup>(\"children\", \"AdwPreferencesGroup\", {\n attach: (page, group, info) => {\n page.insert(group, info.index);\n },\n detach: (page, group) => {\n page.remove(group);\n },\n }),\n ],\n },\n AdwPreferencesDialog: {\n behaviors: [preferencesDialogChildren],\n },\n AdwPreferencesGroup: {\n behaviors: [methodSlot<Adw.PreferencesGroup, Gtk.Widget>(\"children\", \"GtkWidget\", \"add\", \"remove\")],\n },\n AdwTabView: {\n behaviors: [\n slot<Adw.TabView, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (view, child, info) => view.insert(child, info.index),\n reorder: (view, _child, info) => {\n if (info.adopted instanceof Adw.TabPage) {\n view.reorderPage(info.adopted, info.index);\n }\n },\n detach: (view, _child, info) => {\n if (info.adopted instanceof Adw.TabPage) {\n view.closePage(info.adopted);\n }\n },\n resolve: (view, child) => view.getPage(child),\n }),\n ],\n },\n AdwNavigationView: {\n behaviors: [\n methodSlot<Adw.NavigationView, Adw.NavigationPage>(\"children\", \"AdwNavigationPage\", \"add\", \"remove\"),\n ],\n },\n AdwViewStack: {\n behaviors: [\n methodSlot<Adw.ViewStack, Gtk.Widget>(\"children\", \"GtkWidget\", \"add\", \"remove\"),\n deferred<Adw.ViewStack, string>(\"visibleChildName\", (stack, name) => stack.getChildByName(name) !== null),\n ],\n },\n AdwToolbarView: {\n behaviors: [\n contentSetterSlot<Adw.ToolbarView>(),\n methodSlot<Adw.ToolbarView, Gtk.Widget>(\"topBar\", \"GtkWidget\", \"addTopBar\", \"remove\"),\n methodSlot<Adw.ToolbarView, Gtk.Widget>(\"bottomBar\", \"GtkWidget\", \"addBottomBar\", \"remove\"),\n ],\n },\n AdwHeaderBar: {\n behaviors: [\n methodSlot<Adw.HeaderBar, Gtk.Widget>(\"start\", \"GtkWidget\", \"packStart\", \"remove\"),\n methodSlot<Adw.HeaderBar, Gtk.Widget>(\"end\", \"GtkWidget\", \"packEnd\", \"remove\"),\n ],\n },\n AdwShortcutsDialog: {\n behaviors: [methodSlot<Adw.ShortcutsDialog, Adw.ShortcutsSection>(\"children\", \"AdwShortcutsSection\", \"add\")],\n },\n AdwShortcutsSection: {\n behaviors: [methodSlot<Adw.ShortcutsSection, Adw.ShortcutsItem>(\"children\", \"AdwShortcutsItem\", \"add\")],\n },\n AdwToggleGroup: {\n behaviors: [\n methodSlot<Adw.ToggleGroup, Adw.Toggle>(\"children\", \"AdwToggle\", \"add\", \"remove\"),\n deferred<Adw.ToggleGroup, string>(\"activeName\", (group, name) => group.getToggleByName(name) !== null),\n deferred(\"active\"),\n ],\n },\n AdwAlertDialog: {\n behaviors: [\n alertDialogExtraChild,\n list<Adw.AlertDialog, AlertDialogResponse>(\"responses\", {\n add: (dialog, response) => {\n dialog.addResponse(response.id, response.label);\n\n if (response.appearance !== undefined) {\n dialog.setResponseAppearance(response.id, response.appearance);\n }\n\n if (response.isEnabled !== undefined) {\n dialog.setResponseEnabled(response.id, response.isEnabled);\n }\n },\n remove: (dialog, response) => {\n dialog.removeResponse(response.id);\n },\n }),\n ],\n },\n};\n\nfunction getSlotId(name: string): string | null {\n if (name.length <= SLOT_SUFFIX.length || !name.endsWith(SLOT_SUFFIX)) {\n return null;\n }\n\n return name.slice(0, -SLOT_SUFFIX.length);\n}\n\nregisterElements(BUILTIN_ELEMENTS);\nregisterElements(BUILTIN_BEHAVIORS);\n"]}
1
+ {"version":3,"file":"element-behaviors.js","sourceRoot":"","sources":["../../src/adw/element-behaviors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EACH,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,UAAU,EACV,UAAU,EACV,IAAI,GACP,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA4C,QAAQ,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO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C,MAAM,EAAE,QAAQ,EAAE,EAAE;oBACtB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAEhD,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;wBACpC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;oBACnE,CAAC;oBAED,IAAI,QAAQ,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;wBACnC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;oBAC/D,CAAC;gBACL,CAAC;gBACD,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;oBACzB,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACvC,CAAC;aACJ,CAAC;SACL;KACJ;CACJ,CAAC;AAEF,SAAS,SAAS,CAAC,IAAY;IAC3B,IAAI,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACnC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import * as Adw from \"@gtkx/gi/adw\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport type { AlertDialogResponse } from \"./prop-types.js\";\nimport {\n applicationCreator,\n boxSlot,\n childMatcher,\n childSetterSlot,\n contentSetterSlot,\n deferred,\n indexedSlot,\n list,\n methodSlot,\n setterSlot,\n slot,\n} from \"../reconciler/behaviors.js\";\nimport { type ElementBehavior, type ElementConfig, forTypes, registerElements } from \"../reconciler/registry.js\";\nimport { BUILTIN_ELEMENTS, CHILD_SETTER_TYPES, CONTENT_SETTER_TYPES } from \"./element-config.js\";\n\ntype AdwChildSetter =\n | Adw.Bin |\n Adw.BreakpointBin |\n Adw.Clamp |\n Adw.Dialog |\n Adw.NavigationPage |\n Adw.SplitButton |\n Adw.StatusPage |\n Adw.TabOverview |\n Adw.ToastOverlay |\n Adw.Toggle;\n\ntype AdwContentSetter = Adw.ApplicationWindow | Adw.BottomSheet | Adw.OverlaySplitView | Adw.Window;\ntype BreakpointHost = Adw.ApplicationWindow | Adw.Window | Adw.Dialog;\ntype PrefixSuffixRow = Adw.ActionRow | Adw.EntryRow | Adw.ExpanderRow;\n\nconst SLOT_SUFFIX = \"Slot\";\nconst childSetter = childSetterSlot<AdwChildSetter>();\nconst contentSetter = contentSetterSlot<AdwContentSetter>(Gtk.Widget);\nconst breakpoints = methodSlot<BreakpointHost, Adw.Breakpoint>(\"breakpoints\", Adw.Breakpoint, \"addBreakpoint\");\n\nconst prefixSuffix = [\n methodSlot<PrefixSuffixRow, Gtk.Widget>(\"prefix\", Gtk.Widget, \"addPrefix\", \"remove\"),\n methodSlot<PrefixSuffixRow, Gtk.Widget>(\"suffix\", Gtk.Widget, \"addSuffix\", \"remove\"),\n];\n\nconst preferencesDialogChildren = methodSlot<Adw.PreferencesDialog, Adw.PreferencesPage>(\n \"children\", Adw.PreferencesPage, \"add\", \"remove\",\n);\n\nconst alertDialogExtraChild = setterSlot<Adw.AlertDialog, Gtk.Widget>(\"children\", Gtk.Widget, \"setExtraChild\");\nconst sidebarSections = indexedSlot<Adw.Sidebar, Adw.SidebarSection>(\"children\", Adw.SidebarSection);\nconst sidebarItems = indexedSlot<Adw.SidebarSection, Adw.SidebarItem>(\"children\", Adw.SidebarItem);\nconst isWidget = childMatcher(Gtk.Widget);\n\nconst scrollableWidget = {\n [Symbol.hasInstance]: (value: unknown): value is Gtk.Scrollable & Gtk.Widget =>\n value instanceof Gtk.Scrollable && value instanceof Gtk.Widget,\n};\n\nconst multiLayoutSlots: ElementBehavior<Adw.MultiLayoutView> = {\n attach: (view, child, info) => {\n const id = getSlotId(info.slot);\n\n if (id === null || !isWidget(child)) {\n return;\n }\n\n view.setChild(id, child);\n\n return true;\n },\n detach: (view, child, info) => {\n const id = getSlotId(info.slot);\n\n if (id === null || !isWidget(child)) {\n return;\n }\n\n if (view.getChild(id) === child) {\n child.unparent();\n }\n },\n};\n\nconst multiLayoutLayouts = slot<Adw.MultiLayoutView, Gtk.Widget>(\"layouts\", Gtk.Widget, {\n attach: (view, content) => {\n const layout = new Adw.Layout({ content });\n view.addLayout(layout);\n\n return layout;\n },\n reorder: (_view, _content, info) => info.adopted,\n detach: (view, _content, info) => {\n if (info.adopted instanceof Adw.Layout) {\n view.removeLayout(info.adopted);\n }\n },\n});\n\nconst BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {\n AdwApplication: {\n behaviors: [applicationCreator(Adw.Application)],\n },\n AdwSidebar: {\n behaviors: [sidebarSections],\n },\n AdwSidebarSection: {\n behaviors: [sidebarItems],\n },\n AdwMultiLayoutView: {\n behaviors: [\n multiLayoutLayouts,\n multiLayoutSlots,\n deferred<Adw.MultiLayoutView, string>(\"layoutName\", (view, name) => view.getLayoutByName(name) !== null),\n ],\n },\n AdwClampScrollable: {\n behaviors: [\n setterSlot<Adw.ClampScrollable, Gtk.Scrollable & Gtk.Widget>(\"children\", scrollableWidget, \"setChild\"),\n ],\n },\n ...forTypes(CHILD_SETTER_TYPES, {\n behaviors: [childSetter],\n }),\n ...forTypes(CONTENT_SETTER_TYPES, {\n behaviors: [contentSetter],\n }),\n AdwDialog: {\n behaviors: [childSetter, breakpoints],\n },\n AdwApplicationWindow: {\n behaviors: [contentSetter, breakpoints],\n },\n AdwWindow: {\n behaviors: [contentSetter, breakpoints],\n },\n AdwBreakpointBin: {\n behaviors: [\n childSetter,\n methodSlot<Adw.BreakpointBin, Adw.Breakpoint>(\n \"breakpoints\", Adw.Breakpoint, \"addBreakpoint\", \"removeBreakpoint\",\n ),\n ],\n },\n AdwActionRow: {\n behaviors: prefixSuffix,\n },\n AdwEntryRow: {\n behaviors: prefixSuffix,\n },\n AdwExpanderRow: {\n behaviors: [\n ...prefixSuffix,\n methodSlot<Adw.ExpanderRow, Gtk.Widget>(\"rows\", Gtk.Widget, \"addRow\", \"remove\"),\n ],\n },\n AdwNavigationSplitView: {\n behaviors: [contentSetterSlot<Adw.NavigationSplitView, Adw.NavigationPage>(Adw.NavigationPage)],\n },\n AdwWrapBox: {\n behaviors: [boxSlot<Adw.WrapBox>()],\n },\n AdwCarousel: {\n behaviors: [\n slot<Adw.Carousel, Gtk.Widget>(\"children\", Gtk.Widget, {\n attach: (carousel, child, info) => {\n carousel.insert(child, info.index);\n },\n detach: (carousel, child) => {\n carousel.remove(child);\n },\n reorder: (carousel, child, info) => {\n carousel.reorder(child, info.index);\n },\n }),\n ],\n },\n AdwPreferencesPage: {\n behaviors: [\n slot<Adw.PreferencesPage, Adw.PreferencesGroup>(\"children\", Adw.PreferencesGroup, {\n attach: (page, group, info) => {\n page.insert(group, info.index);\n },\n detach: (page, group) => {\n page.remove(group);\n },\n }),\n ],\n },\n AdwPreferencesDialog: {\n behaviors: [preferencesDialogChildren],\n },\n AdwPreferencesGroup: {\n behaviors: [methodSlot<Adw.PreferencesGroup, Gtk.Widget>(\"children\", Gtk.Widget, \"add\", \"remove\")],\n },\n AdwTabView: {\n behaviors: [\n slot<Adw.TabView, Gtk.Widget>(\"children\", Gtk.Widget, {\n attach: (view, child, info) => view.insert(child, info.index),\n reorder: (view, _child, info) => {\n if (info.adopted instanceof Adw.TabPage) {\n view.reorderPage(info.adopted, info.index);\n }\n },\n detach: (view, _child, info) => {\n if (info.adopted instanceof Adw.TabPage) {\n view.closePage(info.adopted);\n }\n },\n resolve: (view, child) => view.getPage(child),\n }),\n ],\n },\n AdwNavigationView: {\n behaviors: [\n methodSlot<Adw.NavigationView, Adw.NavigationPage>(\"children\", Adw.NavigationPage, \"add\", \"remove\"),\n ],\n },\n AdwViewStack: {\n behaviors: [\n methodSlot<Adw.ViewStack, Gtk.Widget>(\"children\", Gtk.Widget, \"add\", \"remove\"),\n deferred<Adw.ViewStack, string>(\"visibleChildName\", (stack, name) => stack.getChildByName(name) !== null),\n ],\n },\n AdwToolbarView: {\n behaviors: [\n contentSetterSlot<Adw.ToolbarView>(Gtk.Widget),\n methodSlot<Adw.ToolbarView, Gtk.Widget>(\"topBar\", Gtk.Widget, \"addTopBar\", \"remove\"),\n methodSlot<Adw.ToolbarView, Gtk.Widget>(\"bottomBar\", Gtk.Widget, \"addBottomBar\", \"remove\"),\n ],\n },\n AdwHeaderBar: {\n behaviors: [\n methodSlot<Adw.HeaderBar, Gtk.Widget>(\"start\", Gtk.Widget, \"packStart\", \"remove\"),\n methodSlot<Adw.HeaderBar, Gtk.Widget>(\"end\", Gtk.Widget, \"packEnd\", \"remove\"),\n ],\n },\n AdwShortcutsDialog: {\n behaviors: [methodSlot<Adw.ShortcutsDialog, Adw.ShortcutsSection>(\"children\", Adw.ShortcutsSection, \"add\")],\n },\n AdwShortcutsSection: {\n behaviors: [methodSlot<Adw.ShortcutsSection, Adw.ShortcutsItem>(\"children\", Adw.ShortcutsItem, \"add\")],\n },\n AdwToggleGroup: {\n behaviors: [\n methodSlot<Adw.ToggleGroup, Adw.Toggle>(\"children\", Adw.Toggle, \"add\", \"remove\"),\n deferred<Adw.ToggleGroup, string>(\"activeName\", (group, name) => group.getToggleByName(name) !== null),\n deferred(\"active\"),\n ],\n },\n AdwAlertDialog: {\n behaviors: [\n alertDialogExtraChild,\n list<Adw.AlertDialog, AlertDialogResponse>(\"responses\", {\n add: (dialog, response) => {\n dialog.addResponse(response.id, response.label);\n\n if (response.appearance !== undefined) {\n dialog.setResponseAppearance(response.id, response.appearance);\n }\n\n if (response.isEnabled !== undefined) {\n dialog.setResponseEnabled(response.id, response.isEnabled);\n }\n },\n remove: (dialog, response) => {\n dialog.removeResponse(response.id);\n },\n }),\n ],\n },\n};\n\nfunction getSlotId(name: string): string | null {\n if (name.length <= SLOT_SUFFIX.length || !name.endsWith(SLOT_SUFFIX)) {\n return null;\n }\n\n return name.slice(0, -SLOT_SUFFIX.length);\n}\n\nregisterElements(BUILTIN_ELEMENTS);\nregisterElements(BUILTIN_BEHAVIORS);\n"]}
@@ -10,8 +10,13 @@ declare const Prop = "gtkx:prop";
10
10
  * Left out, the component takes `unknown`, which accepts no attributes at all.
11
11
  *
12
12
  * @param typeName GType name to render, such as `GtkButton` or the `typeName` given to `registerClass`.
13
+ * @param cls Wrapper class the name resolves to. Referencing it keeps the class, and with it the
14
+ * registration the reconciler's name lookup depends on, in a tree-shaken bundle; the component
15
+ * itself renders through the name.
16
+ * @param metadata Registered metadata entry for the type. Referencing it keeps the type's property
17
+ * and signal tables, which register themselves when evaluated, in a tree-shaken bundle.
13
18
  * @returns A component taking that type's props.
14
19
  */
15
- declare function createElementComponent<P = unknown>(typeName: string): (props: P) => ReactNode;
20
+ declare const createElementComponent: <P = unknown>(typeName: string, cls?: unknown, metadata?: unknown) => (props: P) => ReactNode;
16
21
  export { Prop, createElementComponent };
17
22
  //# sourceMappingURL=element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/components/element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG3G,QAAA,MAAM,IAAI,cAAc,CAAC;AA4DzB;;;;;;;;;;;GAWG;AAEH,iBAAS,sBAAsB,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,CAEtF;AAED,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/components/element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG3G,QAAA,MAAM,IAAI,cAAc,CAAC;AA4DzB;;;;;;;;;;;;;;;;GAgBG;AAEH,QAAA,MAAM,sBAAsB,EAAE,CAAC,CAAC,GAAG,OAAO,EACtC,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,OAAO,EACb,QAAQ,CAAC,EAAE,OAAO,KACjB,CAAC,KAAK,EAAE,CAAC,KAAK,SACyE,CAAC;AAE7F,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC"}
@@ -43,11 +43,14 @@ const buildElement = (typeName, record) => {
43
43
  * Left out, the component takes `unknown`, which accepts no attributes at all.
44
44
  *
45
45
  * @param typeName GType name to render, such as `GtkButton` or the `typeName` given to `registerClass`.
46
+ * @param cls Wrapper class the name resolves to. Referencing it keeps the class, and with it the
47
+ * registration the reconciler's name lookup depends on, in a tree-shaken bundle; the component
48
+ * itself renders through the name.
49
+ * @param metadata Registered metadata entry for the type. Referencing it keeps the type's property
50
+ * and signal tables, which register themselves when evaluated, in a tree-shaken bundle.
46
51
  * @returns A component taking that type's props.
47
52
  */
48
53
  /* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- callers name the props */
49
- function createElementComponent(typeName) {
50
- return (props) => buildElement(typeName, isRecord(props) ? props : {});
51
- }
54
+ const createElementComponent = (typeName) => (props) => buildElement(typeName, isRecord(props) ? props : {});
52
55
  export { Prop, createElementComponent };
53
56
  //# sourceMappingURL=element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/components/element.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAoB,cAAc,EAAqC,MAAM,OAAO,CAAC;AAG3G,MAAM,IAAI,GAAG,WAAW,CAAC;AACzB,MAAM,gBAAgB,GAAgB,EAAE,CAAC;AAEzC,MAAM,UAAU,GAAG,CAAC,KAAc,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,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,MAAa,EAAgB,EAAE;IACnE,MAAM,IAAI,GAAG,QAAuB,CAAC;IACrC,MAAM,YAAY,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,CACH,MAAC,IAAI,OAAK,MAAM,aACX,gBAAgB,EAChB,MAAM,CAAC,QAAqB,IAC1B,CACV,CAAC;IACN,CAAC;IAED,OAAO,CACH,MAAC,IAAI,OAAK,gBAAgB,CAAC,MAAM,CAAC,aAC7B,YAAY,EACZ,MAAM,CAAC,QAAqB,IAC1B,CACV,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,0GAA0G;AAC1G,SAAS,sBAAsB,CAAc,QAAgB;IACzD,OAAO,CAAC,KAAQ,EAAa,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzF,CAAC;AAED,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { isRecord } from \"@gtkx/utils\";\nimport { createElement, type ElementType, isValidElement, type ReactElement, type ReactNode } from \"react\";\nimport type { Props } from \"../reconciler/registry.js\";\n\nconst Prop = \"gtkx:prop\";\nconst NO_PROP_CHILDREN: ReactNode[] = [];\n\nconst hasElement = (value: unknown): boolean =>\n isValidElement(value) || (Array.isArray(value) && value.some((item: unknown) => hasElement(item)));\n\nconst isRoutedProp = (key: string, value: unknown): boolean =>\n key !== \"children\" && key !== \"ref\" && hasElement(value);\n\nconst collectPropChildren = (record: Props): ReactNode[] | null => {\n let propChildren: ReactNode[] | null = null;\n\n for (const key in record) {\n if (!isRoutedProp(key, record[key])) {\n continue;\n }\n\n propChildren ??= [];\n\n propChildren.push(\n createElement(Prop, { propName: key, key: `${Prop}:${key}` }, record[key] as ReactNode),\n );\n }\n\n return propChildren;\n};\n\nconst hostPropsWithout = (record: Props): Props => {\n const hostProps: Props = {};\n\n for (const key in record) {\n if (key !== \"children\" && !isRoutedProp(key, record[key])) {\n hostProps[key] = record[key];\n }\n }\n\n return hostProps;\n};\n\nconst buildElement = (typeName: string, record: Props): ReactElement => {\n const Host = typeName as ElementType;\n const propChildren = collectPropChildren(record);\n\n if (propChildren === null) {\n return (\n <Host {...record}>\n {NO_PROP_CHILDREN}\n {record.children as ReactNode}\n </Host>\n );\n }\n\n return (\n <Host {...hostPropsWithout(record)}>\n {propChildren}\n {record.children as ReactNode}\n </Host>\n );\n};\n\n/**\n * Builds the component that renders the element of a GLib type, which is how the generated `@gtkx/jsx`\n * store exposes every widget. Reach for it to render a type codegen does not cover, such as one\n * `registerClass` created: the element name is the GType name, and the component routes each prop whose\n * value is an element into that prop's slot, which a bare intrinsic element cannot do.\n *\n * Name the props the element takes as the type argument, since the GType name says nothing about them.\n * Left out, the component takes `unknown`, which accepts no attributes at all.\n *\n * @param typeName GType name to render, such as `GtkButton` or the `typeName` given to `registerClass`.\n * @returns A component taking that type's props.\n */\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- callers name the props */\nfunction createElementComponent<P = unknown>(typeName: string): (props: P) => ReactNode {\n return (props: P): ReactNode => buildElement(typeName, isRecord(props) ? props : {});\n}\n\nexport { Prop, createElementComponent };\n"]}
1
+ {"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/components/element.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAoB,cAAc,EAAqC,MAAM,OAAO,CAAC;AAG3G,MAAM,IAAI,GAAG,WAAW,CAAC;AACzB,MAAM,gBAAgB,GAAgB,EAAE,CAAC;AAEzC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAW,EAAE,CAC3C,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAA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AAI,GAAG,QAAuB,CAAC;IACrC,MAAM,YAAY,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,CACH,MAAC,IAAI,OAAK,MAAM,aACX,gBAAgB,EAChB,MAAM,CAAC,QAAqB,IAC1B,CACV,CAAC;IACN,CAAC;IAED,OAAO,CACH,MAAC,IAAI,OAAK,gBAAgB,CAAC,MAAM,CAAC,aAC7B,YAAY,EACZ,MAAM,CAAC,QAAqB,IAC1B,CACV,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,0GAA0G;AAC1G,MAAM,sBAAsB,GAKxB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,KAAK,EAAa,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE7F,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { isRecord } from \"@gtkx/utils\";\nimport { createElement, type ElementType, isValidElement, type ReactElement, type ReactNode } from \"react\";\nimport type { Props } from \"../reconciler/registry.js\";\n\nconst Prop = \"gtkx:prop\";\nconst NO_PROP_CHILDREN: ReactNode[] = [];\n\nconst hasElement = (value: unknown): boolean =>\n isValidElement(value) || (Array.isArray(value) && value.some((item: unknown) => hasElement(item)));\n\nconst isRoutedProp = (key: string, value: unknown): boolean =>\n key !== \"children\" && key !== \"ref\" && hasElement(value);\n\nconst collectPropChildren = (record: Props): ReactNode[] | null => {\n let propChildren: ReactNode[] | null = null;\n\n for (const key in record) {\n if (!isRoutedProp(key, record[key])) {\n continue;\n }\n\n propChildren ??= [];\n\n propChildren.push(\n createElement(Prop, { propName: key, key: `${Prop}:${key}` }, record[key] as ReactNode),\n );\n }\n\n return propChildren;\n};\n\nconst hostPropsWithout = (record: Props): Props => {\n const hostProps: Props = {};\n\n for (const key in record) {\n if (key !== \"children\" && !isRoutedProp(key, record[key])) {\n hostProps[key] = record[key];\n }\n }\n\n return hostProps;\n};\n\nconst buildElement = (typeName: string, record: Props): ReactElement => {\n const Host = typeName as ElementType;\n const propChildren = collectPropChildren(record);\n\n if (propChildren === null) {\n return (\n <Host {...record}>\n {NO_PROP_CHILDREN}\n {record.children as ReactNode}\n </Host>\n );\n }\n\n return (\n <Host {...hostPropsWithout(record)}>\n {propChildren}\n {record.children as ReactNode}\n </Host>\n );\n};\n\n/**\n * Builds the component that renders the element of a GLib type, which is how the generated `@gtkx/jsx`\n * store exposes every widget. Reach for it to render a type codegen does not cover, such as one\n * `registerClass` created: the element name is the GType name, and the component routes each prop whose\n * value is an element into that prop's slot, which a bare intrinsic element cannot do.\n *\n * Name the props the element takes as the type argument, since the GType name says nothing about them.\n * Left out, the component takes `unknown`, which accepts no attributes at all.\n *\n * @param typeName GType name to render, such as `GtkButton` or the `typeName` given to `registerClass`.\n * @param cls Wrapper class the name resolves to. Referencing it keeps the class, and with it the\n * registration the reconciler's name lookup depends on, in a tree-shaken bundle; the component\n * itself renders through the name.\n * @param metadata Registered metadata entry for the type. Referencing it keeps the type's property\n * and signal tables, which register themselves when evaluated, in a tree-shaken bundle.\n * @returns A component taking that type's props.\n */\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- callers name the props */\nconst createElementComponent: <P = unknown>(\n typeName: string,\n cls?: unknown,\n metadata?: unknown,\n) => (props: P) => ReactNode =\n (typeName) => (props): ReactNode => buildElement(typeName, isRecord(props) ? props : {});\n\nexport { Prop, createElementComponent };\n"]}
@@ -15,8 +15,8 @@ const BUILTIN_BEHAVIORS = {
15
15
  }),
16
16
  ...forTypes(["GtkHeaderBar", "GtkActionBar"], {
17
17
  behaviors: [
18
- methodSlot("start", "GtkWidget", "packStart", "remove"),
19
- methodSlot("end", "GtkWidget", "packEnd", "remove"),
18
+ methodSlot("start", Gtk.Widget, "packStart", "remove"),
19
+ methodSlot("end", Gtk.Widget, "packEnd", "remove"),
20
20
  ],
21
21
  }),
22
22
  GtkWindow: {
@@ -24,7 +24,7 @@ const BUILTIN_BEHAVIORS = {
24
24
  },
25
25
  GtkWidget: {
26
26
  behaviors: [
27
- slot("children", "GtkPopover", {
27
+ slot("children", Gtk.Popover, {
28
28
  attach: (parent, popover) => {
29
29
  popover.setParent(parent);
30
30
  },
@@ -32,9 +32,9 @@ const BUILTIN_BEHAVIORS = {
32
32
  popover.unparent();
33
33
  },
34
34
  }),
35
- methodSlot("controllers", "GtkEventController", "addController", "removeController"),
36
- setterSlot("layoutManager", "GtkLayoutManager", "setLayoutManager"),
37
- slot("actionGroups", "GActionGroup", {
35
+ methodSlot("controllers", Gtk.EventController, "addController", "removeController"),
36
+ setterSlot("layoutManager", Gtk.LayoutManager, "setLayoutManager"),
37
+ slot("actionGroups", Gio.ActionGroup, {
38
38
  attach: (widget, group, info) => {
39
39
  widget.insertActionGroup(info.props.prefix ?? "", group);
40
40
  },
@@ -66,7 +66,7 @@ const BUILTIN_BEHAVIORS = {
66
66
  GtkOverlay: {
67
67
  behaviors: [
68
68
  childSetterSlot(),
69
- slot("overlays", "GtkWidget", {
69
+ slot("overlays", Gtk.Widget, {
70
70
  attach: (overlay, child) => {
71
71
  overlay.addOverlay(child);
72
72
  },
@@ -79,18 +79,18 @@ const BUILTIN_BEHAVIORS = {
79
79
  },
80
80
  GtkShortcutController: {
81
81
  behaviors: [
82
- methodSlot("shortcuts", "GtkShortcut", "addShortcut", "removeShortcut"),
82
+ methodSlot("shortcuts", Gtk.Shortcut, "addShortcut", "removeShortcut"),
83
83
  ],
84
84
  },
85
85
  GtkTextChildAnchor: {
86
86
  behaviors: [{ create: () => Gtk.TextChildAnchor.new() }],
87
87
  },
88
88
  GtkTextView: {
89
- behaviors: [setterSlot("children", "GtkTextBuffer", "setBuffer")],
89
+ behaviors: [setterSlot("children", Gtk.TextBuffer, "setBuffer")],
90
90
  },
91
91
  GActionMap: {
92
92
  behaviors: [
93
- slot("actions", "GAction", {
93
+ slot("actions", Gio.Action, {
94
94
  attach: (map, action) => {
95
95
  map.addAction(action);
96
96
  },
@@ -114,7 +114,7 @@ const BUILTIN_BEHAVIORS = {
114
114
  },
115
115
  GtkColumnView: {
116
116
  behaviors: [
117
- slot("children", "GtkColumnViewColumn", {
117
+ slot("children", Gtk.ColumnViewColumn, {
118
118
  attach: (view, column, info) => {
119
119
  view.insertColumn(info.index, column);
120
120
  },
@@ -126,7 +126,7 @@ const BUILTIN_BEHAVIORS = {
126
126
  },
127
127
  GtkGrid: {
128
128
  behaviors: [
129
- slot("children", "GtkWidget", {
129
+ slot("children", Gtk.Widget, {
130
130
  attach: (grid, child) => {
131
131
  grid.attach(child, 0, 0, 1, 1);
132
132
  },
@@ -139,7 +139,7 @@ const BUILTIN_BEHAVIORS = {
139
139
  },
140
140
  GtkFixed: {
141
141
  behaviors: [
142
- slot("children", "GtkWidget", {
142
+ slot("children", Gtk.Widget, {
143
143
  attach: (fixed, child) => {
144
144
  fixed.put(child, 0, 0);
145
145
  },
@@ -164,8 +164,8 @@ const BUILTIN_BEHAVIORS = {
164
164
  },
165
165
  GtkConstraintLayout: {
166
166
  behaviors: [
167
- methodSlot("constraints", "GtkConstraint", "addConstraint", "removeConstraint"),
168
- methodSlot("guides", "GtkConstraintGuide", "addGuide", "removeGuide"),
167
+ methodSlot("constraints", Gtk.Constraint, "addConstraint", "removeConstraint"),
168
+ methodSlot("guides", Gtk.ConstraintGuide, "addGuide", "removeGuide"),
169
169
  list("vfl", {
170
170
  add: (layout, item) => [
171
171
  ...layout.addConstraintsFromDescription(item.lines, item.hspacing ?? 0, item.vspacing ?? 0, item.views ?? new Map()),
@@ -180,13 +180,13 @@ const BUILTIN_BEHAVIORS = {
180
180
  },
181
181
  GtkStack: {
182
182
  behaviors: [
183
- methodSlot("children", "GtkWidget", "addChild", "remove"),
183
+ methodSlot("children", Gtk.Widget, "addChild", "remove"),
184
184
  deferred("visibleChildName", (stack, name) => stack.getChildByName(name) !== null),
185
185
  ],
186
186
  },
187
187
  GtkNotebook: {
188
188
  behaviors: [
189
- slot("children", "GtkWidget", {
189
+ slot("children", Gtk.Widget, {
190
190
  attach: (notebook, child, info) => notebook.insertPage(child, null, info.index),
191
191
  reorder: (notebook, child, info) => {
192
192
  notebook.reorderChild(child, info.index);
@@ -201,7 +201,7 @@ const BUILTIN_BEHAVIORS = {
201
201
  GtkApplication: {
202
202
  behaviors: [
203
203
  applicationCreator(Gtk.Application),
204
- methodSlot("children", "GtkWindow", "addWindow", "removeWindow"),
204
+ methodSlot("children", Gtk.Window, "addWindow", "removeWindow"),
205
205
  list("actionAccels", {
206
206
  add: (application, item) => {
207
207
  application.setAccelsForAction(item.detailedActionName, item.accels);
@@ -1 +1 @@
1
- {"version":3,"file":"element-behaviors.js","sourceRoot":"","sources":["../src/element-behaviors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAWpC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACH,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,UAAU,EACV,IAAI,EACJ,KAAK,EACL,mBAAmB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGH,QAAQ,EAER,gBAAgB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEjF,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAC5C,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,YAAY,GAAG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MAAM,IAAI,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACnC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport * as GLib from \"@gtkx/gi/glib\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport type {\n ActionAccel,\n CreditSection,\n DragSourceIcon,\n LevelBarOffset,\n MainOption,\n MenuItem,\n ScaleMark,\n VflConstraints,\n} from \"./prop-types.js\";\nimport { BUILTIN_ELEMENTS, SINGLE_CHILD_TYPES } from \"./element-config.js\";\nimport {\n applicationCreator,\n boxSlot,\n childSetterSlot,\n controlledText,\n deferred,\n deferredWith,\n list,\n methodSlot,\n setterSlot,\n slot,\n value,\n wrappingIndexedSlot,\n} from \"./reconciler/behaviors.js\";\nimport {\n type ElementBehavior,\n type ElementConfig,\n forTypes,\n type Props,\n registerElements,\n} from \"./reconciler/registry.js\";\nimport { applyWrite } from \"./reconciler/signals.js\";\nimport { applyStyle, CSS_CLASSES_PROP, styleClass } from \"./reconciler/style.js\";\n\nconst SELECTED_INDEX_PROP = \"selectedIndex\";\nconst SELECTION_SIGNAL = \"selected-rows-changed\";\nconst NO_SELECTION = -1;\n\nconst BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {\n ...forTypes(SINGLE_CHILD_TYPES, {\n behaviors: [childSetterSlot()],\n }),\n ...forTypes([\"GtkHeaderBar\", \"GtkActionBar\"], {\n behaviors: [\n methodSlot<Gtk.HeaderBar | Gtk.ActionBar, Gtk.Widget>(\"start\", \"GtkWidget\", \"packStart\", \"remove\"),\n methodSlot<Gtk.HeaderBar | Gtk.ActionBar, Gtk.Widget>(\"end\", \"GtkWidget\", \"packEnd\", \"remove\"),\n ],\n }),\n GtkWindow: {\n behaviors: [childSetterSlot()],\n },\n GtkWidget: {\n behaviors: [\n slot<Gtk.Widget, Gtk.Popover>(\"children\", \"GtkPopover\", {\n attach: (parent, popover) => {\n popover.setParent(parent);\n },\n detach: (_parent, popover) => {\n popover.unparent();\n },\n }),\n methodSlot<Gtk.Widget, Gtk.EventController>(\n \"controllers\", \"GtkEventController\", \"addController\", \"removeController\",\n ),\n setterSlot<Gtk.Widget, Gtk.LayoutManager>(\"layoutManager\", \"GtkLayoutManager\", \"setLayoutManager\"),\n slot<Gtk.Widget, Gio.ActionGroup>(\"actionGroups\", \"GActionGroup\", {\n attach: (widget, group, info) => {\n widget.insertActionGroup((info.props.prefix as string | null) ?? \"\", group);\n },\n detach: (widget, _group, info) => {\n widget.insertActionGroup((info.props.prefix as string | null) ?? \"\", null);\n },\n }),\n styleBehavior(),\n ],\n },\n GtkBox: {\n behaviors: [boxSlot<Gtk.Box>()],\n },\n GtkListBox: {\n behaviors: [\n wrappingIndexedSlot(Gtk.ListBoxRow, (row, inner) => {\n row.setChild(inner);\n }),\n selectedIndexBehavior(),\n ],\n },\n GtkFlowBox: {\n behaviors: [\n wrappingIndexedSlot(Gtk.FlowBoxChild, (child, inner) => {\n child.setChild(inner);\n }),\n ],\n },\n GtkOverlay: {\n behaviors: [\n childSetterSlot<Gtk.Overlay>(),\n slot<Gtk.Overlay, Gtk.Widget>(\"overlays\", \"GtkWidget\", {\n attach: (overlay, child) => {\n overlay.addOverlay(child);\n },\n detach: (overlay, child) => {\n overlay.removeOverlay(child);\n },\n resolve: layoutChild,\n }),\n ],\n },\n GtkShortcutController: {\n behaviors: [\n methodSlot<Gtk.ShortcutController, Gtk.Shortcut>(\n \"shortcuts\", \"GtkShortcut\", \"addShortcut\", \"removeShortcut\",\n ),\n ],\n },\n GtkTextChildAnchor: {\n behaviors: [{ create: () => Gtk.TextChildAnchor.new() }],\n },\n GtkTextView: {\n behaviors: [setterSlot<Gtk.TextView, Gtk.TextBuffer>(\"children\", \"GtkTextBuffer\", \"setBuffer\")],\n },\n GActionMap: {\n behaviors: [\n slot<Gio.ActionMap, Gio.Action>(\"actions\", \"GAction\", {\n attach: (map, action) => {\n map.addAction(action);\n },\n detach: (map, _action, info) => {\n map.removeAction((info.props.name as string | null) ?? \"\");\n },\n }),\n ],\n },\n GMenu: {\n behaviors: [\n list<Gio.Menu, MenuItem>(\"items\", {\n clear: (menu) => {\n menu.removeAll();\n },\n add: (menu, item) => {\n appendMenuItem(menu, item);\n },\n }),\n ],\n },\n GtkColumnView: {\n behaviors: [\n slot<Gtk.ColumnView, Gtk.ColumnViewColumn>(\"children\", \"GtkColumnViewColumn\", {\n attach: (view, column, info) => {\n view.insertColumn(info.index, column);\n },\n detach: (view, column) => {\n view.removeColumn(column);\n },\n }),\n ],\n },\n GtkGrid: {\n behaviors: [\n slot<Gtk.Grid, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (grid, child) => {\n grid.attach(child, 0, 0, 1, 1);\n },\n detach: (grid, child) => {\n grid.remove(child);\n },\n resolve: layoutChild,\n }),\n ],\n },\n GtkFixed: {\n behaviors: [\n slot<Gtk.Fixed, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (fixed, child) => {\n fixed.put(child, 0, 0);\n },\n detach: (fixed, child) => {\n fixed.remove(child);\n },\n resolve: layoutChild,\n }),\n ],\n },\n GtkSizeGroup: {\n behaviors: [\n list<Gtk.SizeGroup, Gtk.Widget>(\"widgets\", {\n add: (group, widget) => {\n group.addWidget(widget);\n },\n remove: (group, widget) => {\n group.removeWidget(widget);\n },\n }),\n ],\n },\n GtkConstraintLayout: {\n behaviors: [\n methodSlot<Gtk.ConstraintLayout, Gtk.Constraint>(\n \"constraints\", \"GtkConstraint\", \"addConstraint\", \"removeConstraint\",\n ),\n methodSlot<Gtk.ConstraintLayout, Gtk.ConstraintGuide>(\n \"guides\", \"GtkConstraintGuide\", \"addGuide\", \"removeGuide\",\n ),\n list<Gtk.ConstraintLayout, VflConstraints, Gtk.Constraint[]>(\"vfl\", {\n add: (layout, item) => [\n ...layout.addConstraintsFromDescription(\n item.lines,\n item.hspacing ?? 0,\n item.vspacing ?? 0,\n item.views ?? new Map<string, Gtk.ConstraintTarget>(),\n ),\n ],\n remove: (layout, _item, constraints) => {\n for (const constraint of constraints) {\n layout.removeConstraint(constraint);\n }\n },\n }),\n ],\n },\n GtkStack: {\n behaviors: [\n methodSlot<Gtk.Stack, Gtk.Widget>(\"children\", \"GtkWidget\", \"addChild\", \"remove\"),\n deferred<Gtk.Stack, string>(\"visibleChildName\", (stack, name) => stack.getChildByName(name) !== null),\n ],\n },\n GtkNotebook: {\n behaviors: [\n slot<Gtk.Notebook, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (notebook, child, info) => notebook.insertPage(child, null, info.index),\n reorder: (notebook, child, info) => {\n notebook.reorderChild(child, info.index);\n },\n detach: (notebook, child) => {\n notebook.detachTab(child);\n },\n resolve: (notebook, child) => notebook.getPage(child),\n }),\n ],\n },\n GtkApplication: {\n behaviors: [\n applicationCreator(Gtk.Application),\n methodSlot<Gtk.Application, Gtk.Window>(\"children\", \"GtkWindow\", \"addWindow\", \"removeWindow\"),\n list<Gtk.Application, ActionAccel>(\"actionAccels\", {\n add: (application, item) => {\n application.setAccelsForAction(item.detailedActionName, item.accels);\n },\n remove: (application, item) => {\n application.setAccelsForAction(item.detailedActionName, []);\n },\n }),\n list<Gtk.Application, MainOption>(\"mainOptions\", {\n add: (application, option) => {\n addMainOption(application, option);\n },\n }),\n ],\n },\n GtkAboutDialog: {\n behaviors: [\n list<Gtk.AboutDialog, CreditSection>(\"creditSections\", {\n add: (dialog, section) => {\n dialog.addCreditSection(section.sectionName, section.people);\n },\n }),\n ],\n },\n GtkScale: {\n behaviors: [\n list<Gtk.Scale, ScaleMark>(\"marks\", {\n add: (scale, mark) => {\n scale.addMark(mark.value ?? 0, mark.position, mark.markup ?? null);\n },\n clear: (scale) => {\n scale.clearMarks();\n },\n }),\n ],\n },\n GtkCalendar: {\n behaviors: [\n list<Gtk.Calendar, number>(\"markedDays\", {\n add: (calendar, day) => {\n calendar.markDay(day);\n },\n clear: (calendar) => {\n calendar.clearMarks();\n },\n }),\n ],\n },\n GtkLevelBar: {\n behaviors: [\n list<Gtk.LevelBar, LevelBarOffset>(\"offsets\", {\n add: (bar, offset) => {\n bar.addOffsetValue(offset.name, offset.value ?? 0);\n },\n remove: (bar, offset) => {\n bar.removeOffsetValue(offset.name);\n },\n }),\n ],\n },\n GtkDropTarget: {\n behaviors: [\n value<Gtk.DropTarget, GObject.Type[]>(\"types\", (target, types) => {\n target.setGtypes(types);\n }),\n ],\n },\n GtkDrawingArea: {\n behaviors: [\n value<Gtk.DrawingArea, Gtk.DrawingAreaDrawFunc>(\"drawFunc\", (area, draw) => {\n area.setDrawFunc(draw);\n area.queueDraw();\n }),\n ],\n },\n GtkDragSource: {\n behaviors: [\n value<Gtk.DragSource, DragSourceIcon>(\"icon\", (source, icon) => {\n source.setIcon(icon.paintable ?? null, icon.hotX ?? 0, icon.hotY ?? 0);\n }),\n ],\n },\n GtkEditable: {\n behaviors: [controlledText(\"text\")],\n },\n};\n\nfunction layoutChild(parent: Gtk.Widget, child: Gtk.Widget): GObject.Object | null {\n return parent.getLayoutManager()?.getLayoutChild(child) ?? null;\n}\n\nconst isNullish = (value: unknown): boolean => value === undefined || value === null;\nconst isInitialNull = (prevValue: unknown, value: unknown): boolean => value === null && prevValue === undefined;\n\nconst withStyleClass = (classes: unknown, className: string): string[] =>\n Array.isArray(classes) ? [...(classes as string[]), className] : [className];\n\nconst hasCssClassesChange = (prev: Props, next: Props): boolean => {\n const classes = next.cssClasses;\n\n if (classes === undefined || Object.is(prev.cssClasses, classes)) {\n return false;\n }\n\n return !isInitialNull(prev.cssClasses, classes);\n};\n\nconst didWriteCssClasses = (widget: Gtk.Widget, prev: Props, next: Props, className: string | null): boolean => {\n if (className === null || !hasCssClassesChange(prev, next)) {\n return false;\n }\n\n applyWrite(CSS_CLASSES_PROP, () => {\n Reflect.set(widget, CSS_CLASSES_PROP, withStyleClass(next.cssClasses, className));\n });\n\n return true;\n};\n\nconst isRestyled = (prev: Props, next: Props): boolean => {\n if (isNullish(prev.style) && isNullish(next.style)) {\n return false;\n }\n\n return !Object.is(prev.style, next.style);\n};\n\nfunction updateStyle(widget: Gtk.Widget, prev: Props, next: Props): Iterable<string> | undefined {\n const isChanged = isRestyled(prev, next);\n const className = isChanged ? applyStyle(widget, next.style) : styleClass(widget);\n\n if (!isChanged && className === null) {\n return;\n }\n\n return didWriteCssClasses(widget, prev, next, className) ? [\"style\", \"cssClasses\"] : [\"style\"];\n}\n\nfunction styleBehavior(): ElementBehavior<Gtk.Widget> {\n return { update: updateStyle };\n}\n\nfunction selectedRowIndex(box: Gtk.ListBox): number {\n return box.getSelectedRow()?.getIndex() ?? NO_SELECTION;\n}\n\nfunction selectedIndexError(value: number): Error {\n return new Error(\n \"The 'selectedIndex' of a <GtkListBox> must be a whole number, or -1 to select no row; \" +\n `received ${String(value)}.`,\n );\n}\n\nfunction desiredIndex(value: unknown): number | undefined {\n if (value === null) {\n return NO_SELECTION;\n }\n\n if (typeof value !== \"number\") {\n return undefined;\n }\n\n if (!Number.isSafeInteger(value)) {\n throw selectedIndexError(value);\n }\n\n return value;\n}\n\nfunction applySelectedIndex(box: Gtk.ListBox, index: number): void {\n if (index < 0) {\n box.unselectAll();\n\n return;\n }\n\n const row = box.getRowAtIndex(index);\n\n if (row !== null) {\n box.selectRow(row);\n }\n}\n\nfunction selectedIndexBehavior(): ElementBehavior<Gtk.ListBox> {\n return deferredWith<Gtk.ListBox, number>(SELECTED_INDEX_PROP, {\n parse: desiredIndex,\n read: selectedRowIndex,\n write: applySelectedIndex,\n signal: SELECTION_SIGNAL,\n });\n}\n\nconst addMainOption = (application: Gtk.Application, option: MainOption): void => {\n application.addMainOption(\n option.longName,\n option.shortName?.codePointAt(0) ?? 0,\n option.flags ?? GLib.OptionFlags.NONE,\n option.arg ?? GLib.OptionArg.NONE,\n option.description,\n option.argDescription ?? null,\n );\n};\n\nconst buildMenu = (items: MenuItem[]): Gio.Menu => {\n const menu = Gio.Menu.new();\n\n for (const item of items) {\n appendMenuItem(menu, item);\n }\n\n return menu;\n};\n\nfunction appendMenuItem(menu: Gio.Menu, item: MenuItem): void {\n const label = item.label ?? null;\n\n if (item.submenu !== undefined) {\n menu.appendSubmenu(label, buildMenu(item.submenu));\n\n return;\n }\n\n if (item.section !== undefined) {\n menu.appendSection(label, buildMenu(item.section));\n\n return;\n }\n\n menu.append(label, item.action ?? null);\n}\n\nregisterElements(BUILTIN_ELEMENTS);\nregisterElements(BUILTIN_BEHAVIORS);\n"]}
1
+ {"version":3,"file":"element-behaviors.js","sourceRoot":"","sources":["../src/element-behaviors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAWpC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACH,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,UAAU,EACV,IAAI,EACJ,KAAK,EACL,mBAAmB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGH,QAAQ,EAER,gBAAgB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEjF,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAC5C,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC;AAExB,MAAM,iBAAiB,GAAyC;IAC5D,GAAG,QAAQ,CAAC,kBAAkB,EAAE;QAC5B,SAAS,EAAE,CAAC,eAAe,EAAE,CAAC;KACjC,CAAC;IACF,GAAG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CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACnC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport * as GLib from \"@gtkx/gi/glib\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport type {\n ActionAccel,\n CreditSection,\n DragSourceIcon,\n LevelBarOffset,\n MainOption,\n MenuItem,\n ScaleMark,\n VflConstraints,\n} from \"./prop-types.js\";\nimport { BUILTIN_ELEMENTS, SINGLE_CHILD_TYPES } from \"./element-config.js\";\nimport {\n applicationCreator,\n boxSlot,\n childSetterSlot,\n controlledText,\n deferred,\n deferredWith,\n list,\n methodSlot,\n setterSlot,\n slot,\n value,\n wrappingIndexedSlot,\n} from \"./reconciler/behaviors.js\";\nimport {\n type ElementBehavior,\n type ElementConfig,\n forTypes,\n type Props,\n registerElements,\n} from \"./reconciler/registry.js\";\nimport { applyWrite } from \"./reconciler/signals.js\";\nimport { applyStyle, CSS_CLASSES_PROP, styleClass } from \"./reconciler/style.js\";\n\nconst SELECTED_INDEX_PROP = \"selectedIndex\";\nconst SELECTION_SIGNAL = \"selected-rows-changed\";\nconst NO_SELECTION = -1;\n\nconst BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {\n ...forTypes(SINGLE_CHILD_TYPES, {\n behaviors: [childSetterSlot()],\n }),\n ...forTypes([\"GtkHeaderBar\", \"GtkActionBar\"], {\n behaviors: [\n methodSlot<Gtk.HeaderBar | Gtk.ActionBar, Gtk.Widget>(\"start\", Gtk.Widget, \"packStart\", \"remove\"),\n methodSlot<Gtk.HeaderBar | Gtk.ActionBar, Gtk.Widget>(\"end\", Gtk.Widget, \"packEnd\", \"remove\"),\n ],\n }),\n GtkWindow: {\n behaviors: [childSetterSlot()],\n },\n GtkWidget: {\n behaviors: [\n slot<Gtk.Widget, Gtk.Popover>(\"children\", Gtk.Popover, {\n attach: (parent, popover) => {\n popover.setParent(parent);\n },\n detach: (_parent, popover) => {\n popover.unparent();\n },\n }),\n methodSlot<Gtk.Widget, Gtk.EventController>(\n \"controllers\", Gtk.EventController, \"addController\", \"removeController\",\n ),\n setterSlot<Gtk.Widget, Gtk.LayoutManager>(\"layoutManager\", Gtk.LayoutManager, \"setLayoutManager\"),\n slot<Gtk.Widget, Gio.ActionGroup>(\"actionGroups\", Gio.ActionGroup, {\n attach: (widget, group, info) => {\n widget.insertActionGroup((info.props.prefix as string | null) ?? \"\", group);\n },\n detach: (widget, _group, info) => {\n widget.insertActionGroup((info.props.prefix as string | null) ?? \"\", null);\n },\n }),\n styleBehavior(),\n ],\n },\n GtkBox: {\n behaviors: [boxSlot<Gtk.Box>()],\n },\n GtkListBox: {\n behaviors: [\n wrappingIndexedSlot(Gtk.ListBoxRow, (row, inner) => {\n row.setChild(inner);\n }),\n selectedIndexBehavior(),\n ],\n },\n GtkFlowBox: {\n behaviors: [\n wrappingIndexedSlot(Gtk.FlowBoxChild, (child, inner) => {\n child.setChild(inner);\n }),\n ],\n },\n GtkOverlay: {\n behaviors: [\n childSetterSlot<Gtk.Overlay>(),\n slot<Gtk.Overlay, Gtk.Widget>(\"overlays\", Gtk.Widget, {\n attach: (overlay, child) => {\n overlay.addOverlay(child);\n },\n detach: (overlay, child) => {\n overlay.removeOverlay(child);\n },\n resolve: layoutChild,\n }),\n ],\n },\n GtkShortcutController: {\n behaviors: [\n methodSlot<Gtk.ShortcutController, Gtk.Shortcut>(\n \"shortcuts\", Gtk.Shortcut, \"addShortcut\", \"removeShortcut\",\n ),\n ],\n },\n GtkTextChildAnchor: {\n behaviors: [{ create: () => Gtk.TextChildAnchor.new() }],\n },\n GtkTextView: {\n behaviors: [setterSlot<Gtk.TextView, Gtk.TextBuffer>(\"children\", Gtk.TextBuffer, \"setBuffer\")],\n },\n GActionMap: {\n behaviors: [\n slot<Gio.ActionMap, Gio.Action>(\"actions\", Gio.Action, {\n attach: (map, action) => {\n map.addAction(action);\n },\n detach: (map, _action, info) => {\n map.removeAction((info.props.name as string | null) ?? \"\");\n },\n }),\n ],\n },\n GMenu: {\n behaviors: [\n list<Gio.Menu, MenuItem>(\"items\", {\n clear: (menu) => {\n menu.removeAll();\n },\n add: (menu, item) => {\n appendMenuItem(menu, item);\n },\n }),\n ],\n },\n GtkColumnView: {\n behaviors: [\n slot<Gtk.ColumnView, Gtk.ColumnViewColumn>(\"children\", Gtk.ColumnViewColumn, {\n attach: (view, column, info) => {\n view.insertColumn(info.index, column);\n },\n detach: (view, column) => {\n view.removeColumn(column);\n },\n }),\n ],\n },\n GtkGrid: {\n behaviors: [\n slot<Gtk.Grid, Gtk.Widget>(\"children\", Gtk.Widget, {\n attach: (grid, child) => {\n grid.attach(child, 0, 0, 1, 1);\n },\n detach: (grid, child) => {\n grid.remove(child);\n },\n resolve: layoutChild,\n }),\n ],\n },\n GtkFixed: {\n behaviors: [\n slot<Gtk.Fixed, Gtk.Widget>(\"children\", Gtk.Widget, {\n attach: (fixed, child) => {\n fixed.put(child, 0, 0);\n },\n detach: (fixed, child) => {\n fixed.remove(child);\n },\n resolve: layoutChild,\n }),\n ],\n },\n GtkSizeGroup: {\n behaviors: [\n list<Gtk.SizeGroup, Gtk.Widget>(\"widgets\", {\n add: (group, widget) => {\n group.addWidget(widget);\n },\n remove: (group, widget) => {\n group.removeWidget(widget);\n },\n }),\n ],\n },\n GtkConstraintLayout: {\n behaviors: [\n methodSlot<Gtk.ConstraintLayout, Gtk.Constraint>(\n \"constraints\", Gtk.Constraint, \"addConstraint\", \"removeConstraint\",\n ),\n methodSlot<Gtk.ConstraintLayout, Gtk.ConstraintGuide>(\n \"guides\", Gtk.ConstraintGuide, \"addGuide\", \"removeGuide\",\n ),\n list<Gtk.ConstraintLayout, VflConstraints, Gtk.Constraint[]>(\"vfl\", {\n add: (layout, item) => [\n ...layout.addConstraintsFromDescription(\n item.lines,\n item.hspacing ?? 0,\n item.vspacing ?? 0,\n item.views ?? new Map<string, Gtk.ConstraintTarget>(),\n ),\n ],\n remove: (layout, _item, constraints) => {\n for (const constraint of constraints) {\n layout.removeConstraint(constraint);\n }\n },\n }),\n ],\n },\n GtkStack: {\n behaviors: [\n methodSlot<Gtk.Stack, Gtk.Widget>(\"children\", Gtk.Widget, \"addChild\", \"remove\"),\n deferred<Gtk.Stack, string>(\"visibleChildName\", (stack, name) => stack.getChildByName(name) !== null),\n ],\n },\n GtkNotebook: {\n behaviors: [\n slot<Gtk.Notebook, Gtk.Widget>(\"children\", Gtk.Widget, {\n attach: (notebook, child, info) => notebook.insertPage(child, null, info.index),\n reorder: (notebook, child, info) => {\n notebook.reorderChild(child, info.index);\n },\n detach: (notebook, child) => {\n notebook.detachTab(child);\n },\n resolve: (notebook, child) => notebook.getPage(child),\n }),\n ],\n },\n GtkApplication: {\n behaviors: [\n applicationCreator(Gtk.Application),\n methodSlot<Gtk.Application, Gtk.Window>(\"children\", Gtk.Window, \"addWindow\", \"removeWindow\"),\n list<Gtk.Application, ActionAccel>(\"actionAccels\", {\n add: (application, item) => {\n application.setAccelsForAction(item.detailedActionName, item.accels);\n },\n remove: (application, item) => {\n application.setAccelsForAction(item.detailedActionName, []);\n },\n }),\n list<Gtk.Application, MainOption>(\"mainOptions\", {\n add: (application, option) => {\n addMainOption(application, option);\n },\n }),\n ],\n },\n GtkAboutDialog: {\n behaviors: [\n list<Gtk.AboutDialog, CreditSection>(\"creditSections\", {\n add: (dialog, section) => {\n dialog.addCreditSection(section.sectionName, section.people);\n },\n }),\n ],\n },\n GtkScale: {\n behaviors: [\n list<Gtk.Scale, ScaleMark>(\"marks\", {\n add: (scale, mark) => {\n scale.addMark(mark.value ?? 0, mark.position, mark.markup ?? null);\n },\n clear: (scale) => {\n scale.clearMarks();\n },\n }),\n ],\n },\n GtkCalendar: {\n behaviors: [\n list<Gtk.Calendar, number>(\"markedDays\", {\n add: (calendar, day) => {\n calendar.markDay(day);\n },\n clear: (calendar) => {\n calendar.clearMarks();\n },\n }),\n ],\n },\n GtkLevelBar: {\n behaviors: [\n list<Gtk.LevelBar, LevelBarOffset>(\"offsets\", {\n add: (bar, offset) => {\n bar.addOffsetValue(offset.name, offset.value ?? 0);\n },\n remove: (bar, offset) => {\n bar.removeOffsetValue(offset.name);\n },\n }),\n ],\n },\n GtkDropTarget: {\n behaviors: [\n value<Gtk.DropTarget, GObject.Type[]>(\"types\", (target, types) => {\n target.setGtypes(types);\n }),\n ],\n },\n GtkDrawingArea: {\n behaviors: [\n value<Gtk.DrawingArea, Gtk.DrawingAreaDrawFunc>(\"drawFunc\", (area, draw) => {\n area.setDrawFunc(draw);\n area.queueDraw();\n }),\n ],\n },\n GtkDragSource: {\n behaviors: [\n value<Gtk.DragSource, DragSourceIcon>(\"icon\", (source, icon) => {\n source.setIcon(icon.paintable ?? null, icon.hotX ?? 0, icon.hotY ?? 0);\n }),\n ],\n },\n GtkEditable: {\n behaviors: [controlledText(\"text\")],\n },\n};\n\nfunction layoutChild(parent: Gtk.Widget, child: Gtk.Widget): GObject.Object | null {\n return parent.getLayoutManager()?.getLayoutChild(child) ?? null;\n}\n\nconst isNullish = (value: unknown): boolean => value === undefined || value === null;\nconst isInitialNull = (prevValue: unknown, value: unknown): boolean => value === null && prevValue === undefined;\n\nconst withStyleClass = (classes: unknown, className: string): string[] =>\n Array.isArray(classes) ? [...(classes as string[]), className] : [className];\n\nconst hasCssClassesChange = (prev: Props, next: Props): boolean => {\n const classes = next.cssClasses;\n\n if (classes === undefined || Object.is(prev.cssClasses, classes)) {\n return false;\n }\n\n return !isInitialNull(prev.cssClasses, classes);\n};\n\nconst didWriteCssClasses = (widget: Gtk.Widget, prev: Props, next: Props, className: string | null): boolean => {\n if (className === null || !hasCssClassesChange(prev, next)) {\n return false;\n }\n\n applyWrite(CSS_CLASSES_PROP, () => {\n Reflect.set(widget, CSS_CLASSES_PROP, withStyleClass(next.cssClasses, className));\n });\n\n return true;\n};\n\nconst isRestyled = (prev: Props, next: Props): boolean => {\n if (isNullish(prev.style) && isNullish(next.style)) {\n return false;\n }\n\n return !Object.is(prev.style, next.style);\n};\n\nfunction updateStyle(widget: Gtk.Widget, prev: Props, next: Props): Iterable<string> | undefined {\n const isChanged = isRestyled(prev, next);\n const className = isChanged ? applyStyle(widget, next.style) : styleClass(widget);\n\n if (!isChanged && className === null) {\n return;\n }\n\n return didWriteCssClasses(widget, prev, next, className) ? [\"style\", \"cssClasses\"] : [\"style\"];\n}\n\nfunction styleBehavior(): ElementBehavior<Gtk.Widget> {\n return { update: updateStyle };\n}\n\nfunction selectedRowIndex(box: Gtk.ListBox): number {\n return box.getSelectedRow()?.getIndex() ?? NO_SELECTION;\n}\n\nfunction selectedIndexError(value: number): Error {\n return new Error(\n \"The 'selectedIndex' of a <GtkListBox> must be a whole number, or -1 to select no row; \" +\n `received ${String(value)}.`,\n );\n}\n\nfunction desiredIndex(value: unknown): number | undefined {\n if (value === null) {\n return NO_SELECTION;\n }\n\n if (typeof value !== \"number\") {\n return undefined;\n }\n\n if (!Number.isSafeInteger(value)) {\n throw selectedIndexError(value);\n }\n\n return value;\n}\n\nfunction applySelectedIndex(box: Gtk.ListBox, index: number): void {\n if (index < 0) {\n box.unselectAll();\n\n return;\n }\n\n const row = box.getRowAtIndex(index);\n\n if (row !== null) {\n box.selectRow(row);\n }\n}\n\nfunction selectedIndexBehavior(): ElementBehavior<Gtk.ListBox> {\n return deferredWith<Gtk.ListBox, number>(SELECTED_INDEX_PROP, {\n parse: desiredIndex,\n read: selectedRowIndex,\n write: applySelectedIndex,\n signal: SELECTION_SIGNAL,\n });\n}\n\nconst addMainOption = (application: Gtk.Application, option: MainOption): void => {\n application.addMainOption(\n option.longName,\n option.shortName?.codePointAt(0) ?? 0,\n option.flags ?? GLib.OptionFlags.NONE,\n option.arg ?? GLib.OptionArg.NONE,\n option.description,\n option.argDescription ?? null,\n );\n};\n\nconst buildMenu = (items: MenuItem[]): Gio.Menu => {\n const menu = Gio.Menu.new();\n\n for (const item of items) {\n appendMenuItem(menu, item);\n }\n\n return menu;\n};\n\nfunction appendMenuItem(menu: Gio.Menu, item: MenuItem): void {\n const label = item.label ?? null;\n\n if (item.submenu !== undefined) {\n menu.appendSubmenu(label, buildMenu(item.submenu));\n\n return;\n }\n\n if (item.section !== undefined) {\n menu.appendSection(label, buildMenu(item.section));\n\n return;\n }\n\n menu.append(label, item.action ?? null);\n}\n\nregisterElements(BUILTIN_ELEMENTS);\nregisterElements(BUILTIN_BEHAVIORS);\n"]}
@@ -1,5 +1,5 @@
1
1
  import type * as GObject from "@gtkx/gi/gobject";
2
- import type * as Gtk from "@gtkx/gi/gtk";
2
+ import * as Gtk from "@gtkx/gi/gtk";
3
3
  import { type ApplicationClass, type CommandLineApplication } from "@gtkx/runtime";
4
4
  import type { DetachInfo, ElementBehavior, PlaceInfo, Props } from "./registry.js";
5
5
  type SlotHooks<P extends GObject.Object, C extends GObject.Object> = {
@@ -45,19 +45,22 @@ type IndexedChildHost<C extends GObject.Object> = GObject.Object & {
45
45
  remove: (child: C) => void;
46
46
  insert: (child: C, position: number) => unknown;
47
47
  };
48
- declare const childMatcher: (name: string) => ((child: GObject.Object) => boolean);
49
- declare const slot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childType: string, hooks: SlotHooks<P, C>) => ElementBehavior;
48
+ type ChildClass<C extends GObject.Object> = (abstract new (...args: never[]) => C) | {
49
+ [Symbol.hasInstance]: (value: unknown) => value is C;
50
+ };
51
+ declare const childMatcher: <C extends GObject.Object>(cls: ChildClass<C> | undefined) => ((child: GObject.Object) => child is C);
52
+ declare const slot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childClass: ChildClass<C> | undefined, hooks: SlotHooks<P, C>) => ElementBehavior;
50
53
  declare const value: <P extends GObject.Object, V>(prop: string, apply: ValueApply<P, V>) => ElementBehavior<P>;
51
54
  declare const list: <P extends GObject.Object, I, H = void>(prop: string, hooks: ListHooks<P, I, H>) => ElementBehavior<P>;
52
55
  declare const deferredWith: <P extends GObject.Object, V>(prop: string, hooks: DeferredHooks<P, V>) => ElementBehavior<P>;
53
56
  declare const deferred: <P extends GObject.Object, V>(prop: string, canApply?: CanApply<P, V>) => ElementBehavior<P>;
54
57
  declare const controlledText: (prop: string) => ElementBehavior;
55
58
  declare const childSetterSlot: <P extends ChildSetter>() => ElementBehavior<P>;
56
- declare const contentSetterSlot: <P extends ContentSetter<C>, C extends Gtk.Widget = Gtk.Widget>(childType?: string) => ElementBehavior<P>;
59
+ declare const contentSetterSlot: <P extends ContentSetter<C>, C extends Gtk.Widget = Gtk.Widget>(childClass: ChildClass<C>) => ElementBehavior<P>;
57
60
  declare const boxSlot: <P extends BoxLike>() => ElementBehavior<P>;
58
- declare const methodSlot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childType: string, add: MethodKey<P, C>, remove?: MethodKey<P, C>) => ElementBehavior;
59
- declare const setterSlot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childType: string, setter: MethodKey<P, C | null>) => ElementBehavior;
60
- declare const indexedSlot: <P extends IndexedChildHost<C>, C extends GObject.Object>(slotName: string, childType: string) => ElementBehavior<P>;
61
+ declare const methodSlot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childClass: ChildClass<C> | undefined, add: MethodKey<P, C>, remove?: MethodKey<P, C>) => ElementBehavior;
62
+ declare const setterSlot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childClass: ChildClass<C> | undefined, setter: MethodKey<P, C | null>) => ElementBehavior;
63
+ declare const indexedSlot: <P extends IndexedChildHost<C>, C extends GObject.Object>(slotName: string, childClass: ChildClass<C> | undefined) => ElementBehavior<P>;
61
64
  declare const wrappingIndexedSlot: <W extends Gtk.Widget, P extends IndexedChildHost<Gtk.Widget>>(Wrapper: new (props: Props) => W, setChild: (wrapper: W, inner: Gtk.Widget) => void) => ElementBehavior<P>;
62
65
  declare const applicationCreator: <P extends GObject.Object & CommandLineApplication, C extends Props>(base: ApplicationClass<P, C>) => ElementBehavior<P>;
63
66
  export { applicationCreator, childMatcher, slot, value, list, deferred, deferredWith, controlledText, childSetterSlot, contentSetterSlot, boxSlot, methodSlot, setterSlot, indexedSlot, wrappingIndexedSlot, };