@gtkx/react 1.4.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.
- package/README.md +1 -1
- package/dist/adw/element-behaviors.js +35 -120
- package/dist/adw/element-behaviors.js.map +1 -1
- package/dist/components/element.d.ts +6 -1
- package/dist/components/element.d.ts.map +1 -1
- package/dist/components/element.js +6 -3
- package/dist/components/element.js.map +1 -1
- package/dist/element-behaviors.js +29 -124
- package/dist/element-behaviors.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +27 -8
- package/dist/reconciler/behaviors.d.ts.map +1 -1
- package/dist/reconciler/behaviors.js +60 -31
- package/dist/reconciler/behaviors.js.map +1 -1
- package/dist/reconciler/instance.d.ts.map +1 -1
- package/dist/reconciler/instance.js +5 -4
- package/dist/reconciler/instance.js.map +1 -1
- package/dist/reconciler/metadata.d.ts.map +1 -1
- package/dist/reconciler/metadata.js +17 -3
- package/dist/reconciler/metadata.js.map +1 -1
- package/package.json +5 -5
- package/src/adw/element-behaviors.ts +40 -177
- package/src/components/element.tsx +11 -3
- package/src/element-behaviors.ts +35 -175
- package/src/reconciler/behaviors.ts +114 -56
- package/src/reconciler/instance.ts +5 -4
- package/src/reconciler/metadata.ts +25 -3
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing r
|
|
|
98
98
|
- a React reconciler that exposes every GObject as a JSX element,
|
|
99
99
|
- a CLI for scaffolding, development, and production builds,
|
|
100
100
|
- a dev server with Fast Refresh that patches your running UI in place,
|
|
101
|
-
- CSS-in-JS styling, React Spring animations, React Navigation stack, tab, drawer, and split view navigators, and high-level list, grid, and dialog components,
|
|
101
|
+
- CSS-in-JS styling, React Hook Form-powered Adwaita controls, gettext-backed react-i18next localization, React Spring animations, React Navigation stack, tab, drawer, and split view navigators, and high-level list, grid, and dialog components,
|
|
102
102
|
- a Testing Library-style API for querying and driving your widgets in tests,
|
|
103
103
|
- and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
|
|
104
104
|
|
|
@@ -1,43 +1,24 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/gi/adw";
|
|
2
|
-
import
|
|
2
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
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 =
|
|
9
|
-
attach: (host, breakpoint) => {
|
|
10
|
-
host.addBreakpoint(breakpoint);
|
|
11
|
-
},
|
|
12
|
-
});
|
|
8
|
+
const contentSetter = contentSetterSlot(Gtk.Widget);
|
|
9
|
+
const breakpoints = methodSlot("breakpoints", Adw.Breakpoint, "addBreakpoint");
|
|
13
10
|
const prefixSuffix = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, (row, child) => {
|
|
17
|
-
row.remove(child);
|
|
18
|
-
}),
|
|
19
|
-
addRemoveSlot("suffix", "GtkWidget", (row, child) => {
|
|
20
|
-
row.addSuffix(child);
|
|
21
|
-
}, (row, child) => {
|
|
22
|
-
row.remove(child);
|
|
23
|
-
}),
|
|
11
|
+
methodSlot("prefix", Gtk.Widget, "addPrefix", "remove"),
|
|
12
|
+
methodSlot("suffix", Gtk.Widget, "addSuffix", "remove"),
|
|
24
13
|
];
|
|
25
|
-
const preferencesDialogChildren =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
detach: (dialog) => {
|
|
35
|
-
dialog.setExtraChild(null);
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const sidebarSections = indexedSlot("children", "AdwSidebarSection");
|
|
39
|
-
const sidebarItems = indexedSlot("children", "AdwSidebarItem");
|
|
40
|
-
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
|
+
};
|
|
41
22
|
const multiLayoutSlots = {
|
|
42
23
|
attach: (view, child, info) => {
|
|
43
24
|
const id = getSlotId(info.slot);
|
|
@@ -52,13 +33,12 @@ const multiLayoutSlots = {
|
|
|
52
33
|
if (id === null || !isWidget(child)) {
|
|
53
34
|
return;
|
|
54
35
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
widget.unparent();
|
|
36
|
+
if (view.getChild(id) === child) {
|
|
37
|
+
child.unparent();
|
|
58
38
|
}
|
|
59
39
|
},
|
|
60
40
|
};
|
|
61
|
-
const multiLayoutLayouts = slot("layouts",
|
|
41
|
+
const multiLayoutLayouts = slot("layouts", Gtk.Widget, {
|
|
62
42
|
attach: (view, content) => {
|
|
63
43
|
const layout = new Adw.Layout({ content });
|
|
64
44
|
view.addLayout(layout);
|
|
@@ -90,14 +70,7 @@ const BUILTIN_BEHAVIORS = {
|
|
|
90
70
|
},
|
|
91
71
|
AdwClampScrollable: {
|
|
92
72
|
behaviors: [
|
|
93
|
-
|
|
94
|
-
attach: (clamp, child) => {
|
|
95
|
-
clamp.setChild(child);
|
|
96
|
-
},
|
|
97
|
-
detach: (clamp) => {
|
|
98
|
-
clamp.setChild(null);
|
|
99
|
-
},
|
|
100
|
-
}),
|
|
73
|
+
setterSlot("children", scrollableWidget, "setChild"),
|
|
101
74
|
],
|
|
102
75
|
},
|
|
103
76
|
...forTypes(CHILD_SETTER_TYPES, {
|
|
@@ -118,11 +91,7 @@ const BUILTIN_BEHAVIORS = {
|
|
|
118
91
|
AdwBreakpointBin: {
|
|
119
92
|
behaviors: [
|
|
120
93
|
childSetter,
|
|
121
|
-
|
|
122
|
-
bin.addBreakpoint(breakpoint);
|
|
123
|
-
}, (bin, breakpoint) => {
|
|
124
|
-
bin.removeBreakpoint(breakpoint);
|
|
125
|
-
}),
|
|
94
|
+
methodSlot("breakpoints", Adw.Breakpoint, "addBreakpoint", "removeBreakpoint"),
|
|
126
95
|
],
|
|
127
96
|
},
|
|
128
97
|
AdwActionRow: {
|
|
@@ -134,22 +103,18 @@ const BUILTIN_BEHAVIORS = {
|
|
|
134
103
|
AdwExpanderRow: {
|
|
135
104
|
behaviors: [
|
|
136
105
|
...prefixSuffix,
|
|
137
|
-
|
|
138
|
-
row.addRow(child);
|
|
139
|
-
}, (row, child) => {
|
|
140
|
-
row.remove(child);
|
|
141
|
-
}),
|
|
106
|
+
methodSlot("rows", Gtk.Widget, "addRow", "remove"),
|
|
142
107
|
],
|
|
143
108
|
},
|
|
144
109
|
AdwNavigationSplitView: {
|
|
145
|
-
behaviors: [contentSetterSlot(
|
|
110
|
+
behaviors: [contentSetterSlot(Adw.NavigationPage)],
|
|
146
111
|
},
|
|
147
112
|
AdwWrapBox: {
|
|
148
113
|
behaviors: [boxSlot()],
|
|
149
114
|
},
|
|
150
115
|
AdwCarousel: {
|
|
151
116
|
behaviors: [
|
|
152
|
-
slot("children",
|
|
117
|
+
slot("children", Gtk.Widget, {
|
|
153
118
|
attach: (carousel, child, info) => {
|
|
154
119
|
carousel.insert(child, info.index);
|
|
155
120
|
},
|
|
@@ -164,7 +129,7 @@ const BUILTIN_BEHAVIORS = {
|
|
|
164
129
|
},
|
|
165
130
|
AdwPreferencesPage: {
|
|
166
131
|
behaviors: [
|
|
167
|
-
slot("children",
|
|
132
|
+
slot("children", Adw.PreferencesGroup, {
|
|
168
133
|
attach: (page, group, info) => {
|
|
169
134
|
page.insert(group, info.index);
|
|
170
135
|
},
|
|
@@ -178,17 +143,11 @@ const BUILTIN_BEHAVIORS = {
|
|
|
178
143
|
behaviors: [preferencesDialogChildren],
|
|
179
144
|
},
|
|
180
145
|
AdwPreferencesGroup: {
|
|
181
|
-
behaviors: [
|
|
182
|
-
addRemoveSlot("children", "GtkWidget", (group, child) => {
|
|
183
|
-
group.add(child);
|
|
184
|
-
}, (group, child) => {
|
|
185
|
-
group.remove(child);
|
|
186
|
-
}),
|
|
187
|
-
],
|
|
146
|
+
behaviors: [methodSlot("children", Gtk.Widget, "add", "remove")],
|
|
188
147
|
},
|
|
189
148
|
AdwTabView: {
|
|
190
149
|
behaviors: [
|
|
191
|
-
slot("children",
|
|
150
|
+
slot("children", Gtk.Widget, {
|
|
192
151
|
attach: (view, child, info) => view.insert(child, info.index),
|
|
193
152
|
reorder: (view, _child, info) => {
|
|
194
153
|
if (info.adopted instanceof Adw.TabPage) {
|
|
@@ -206,81 +165,37 @@ const BUILTIN_BEHAVIORS = {
|
|
|
206
165
|
},
|
|
207
166
|
AdwNavigationView: {
|
|
208
167
|
behaviors: [
|
|
209
|
-
|
|
210
|
-
view.add(page);
|
|
211
|
-
}, (view, page) => {
|
|
212
|
-
view.remove(page);
|
|
213
|
-
}),
|
|
168
|
+
methodSlot("children", Adw.NavigationPage, "add", "remove"),
|
|
214
169
|
],
|
|
215
170
|
},
|
|
216
171
|
AdwViewStack: {
|
|
217
172
|
behaviors: [
|
|
218
|
-
|
|
219
|
-
stack.remove(child);
|
|
220
|
-
}),
|
|
173
|
+
methodSlot("children", Gtk.Widget, "add", "remove"),
|
|
221
174
|
deferred("visibleChildName", (stack, name) => stack.getChildByName(name) !== null),
|
|
222
175
|
],
|
|
223
176
|
},
|
|
224
177
|
AdwToolbarView: {
|
|
225
178
|
behaviors: [
|
|
226
|
-
contentSetterSlot(),
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}, (view, child) => {
|
|
230
|
-
view.remove(child);
|
|
231
|
-
}),
|
|
232
|
-
addRemoveSlot("bottomBar", "GtkWidget", (view, child) => {
|
|
233
|
-
view.addBottomBar(child);
|
|
234
|
-
}, (view, child) => {
|
|
235
|
-
view.remove(child);
|
|
236
|
-
}),
|
|
179
|
+
contentSetterSlot(Gtk.Widget),
|
|
180
|
+
methodSlot("topBar", Gtk.Widget, "addTopBar", "remove"),
|
|
181
|
+
methodSlot("bottomBar", Gtk.Widget, "addBottomBar", "remove"),
|
|
237
182
|
],
|
|
238
183
|
},
|
|
239
184
|
AdwHeaderBar: {
|
|
240
185
|
behaviors: [
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
bar.packStart(child);
|
|
244
|
-
},
|
|
245
|
-
detach: (bar, child) => {
|
|
246
|
-
bar.remove(child);
|
|
247
|
-
},
|
|
248
|
-
}),
|
|
249
|
-
slot("end", "GtkWidget", {
|
|
250
|
-
attach: (bar, child) => {
|
|
251
|
-
bar.packEnd(child);
|
|
252
|
-
},
|
|
253
|
-
detach: (bar, child) => {
|
|
254
|
-
bar.remove(child);
|
|
255
|
-
},
|
|
256
|
-
}),
|
|
186
|
+
methodSlot("start", Gtk.Widget, "packStart", "remove"),
|
|
187
|
+
methodSlot("end", Gtk.Widget, "packEnd", "remove"),
|
|
257
188
|
],
|
|
258
189
|
},
|
|
259
190
|
AdwShortcutsDialog: {
|
|
260
|
-
behaviors: [
|
|
261
|
-
slot("children", "AdwShortcutsSection", {
|
|
262
|
-
attach: (dialog, section) => {
|
|
263
|
-
dialog.add(section);
|
|
264
|
-
},
|
|
265
|
-
}),
|
|
266
|
-
],
|
|
191
|
+
behaviors: [methodSlot("children", Adw.ShortcutsSection, "add")],
|
|
267
192
|
},
|
|
268
193
|
AdwShortcutsSection: {
|
|
269
|
-
behaviors: [
|
|
270
|
-
slot("children", "AdwShortcutsItem", {
|
|
271
|
-
attach: (section, item) => {
|
|
272
|
-
section.add(item);
|
|
273
|
-
},
|
|
274
|
-
}),
|
|
275
|
-
],
|
|
194
|
+
behaviors: [methodSlot("children", Adw.ShortcutsItem, "add")],
|
|
276
195
|
},
|
|
277
196
|
AdwToggleGroup: {
|
|
278
197
|
behaviors: [
|
|
279
|
-
|
|
280
|
-
group.add(toggle);
|
|
281
|
-
}, (group, toggle) => {
|
|
282
|
-
group.remove(toggle);
|
|
283
|
-
}),
|
|
198
|
+
methodSlot("children", Adw.Toggle, "add", "remove"),
|
|
284
199
|
deferred("activeName", (group, name) => group.getToggleByName(name) !== null),
|
|
285
200
|
deferred("active"),
|
|
286
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,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,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;AAC3B,MAAM,WAAW,GAAG,eAAe,EAAkB,CAAC;AACtD,MAAM,aAAa,GAAG,iBAAiB,EAAoB,CAAC;AAE5D,MAAM,WAAW,GAAG,IAAI,CAAiC,aAAa,EAAE,eAAe,EAAE;IACrF,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;QACzB,IAAI,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AAS,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 type * as Gtk from \"@gtkx/gi/gtk\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport type { AlertDialogResponse } from \"./prop-types.js\";\nimport {\n addRemoveSlot,\n adoptedChildrenSlot,\n applicationCreator,\n boxSlot,\n childMatcher,\n childSetterSlot,\n contentSetterSlot,\n deferred,\n indexedSlot,\n list,\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>();\n\nconst breakpoints = slot<BreakpointHost, Adw.Breakpoint>(\"breakpoints\", \"AdwBreakpoint\", {\n attach: (host, breakpoint) => {\n host.addBreakpoint(breakpoint);\n },\n});\n\nconst prefixSuffix = [\n addRemoveSlot<Gtk.Widget, PrefixSuffixRow>(\n \"prefix\",\n \"GtkWidget\",\n (row, child) => {\n row.addPrefix(child);\n },\n (row, child) => {\n row.remove(child);\n },\n ),\n addRemoveSlot<Gtk.Widget, PrefixSuffixRow>(\n \"suffix\",\n \"GtkWidget\",\n (row, child) => {\n row.addSuffix(child);\n },\n (row, child) => {\n row.remove(child);\n },\n ),\n];\n\nconst preferencesDialogChildren = addRemoveSlot<Adw.PreferencesPage, Adw.PreferencesDialog>(\n \"children\",\n \"AdwPreferencesPage\",\n (dialog, page) => {\n dialog.add(page);\n },\n (dialog, page) => {\n dialog.remove(page);\n },\n);\n\nconst alertDialogExtraChild = slot<Adw.AlertDialog, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (dialog, child) => {\n dialog.setExtraChild(child);\n },\n detach: (dialog) => {\n dialog.setExtraChild(null);\n },\n});\n\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 slot<Adw.ClampScrollable, Gtk.Scrollable & Gtk.Widget>(\"children\", \"GtkScrollable\", {\n attach: (clamp, child) => {\n clamp.setChild(child);\n },\n detach: (clamp) => {\n clamp.setChild(null);\n },\n }),\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 addRemoveSlot<Adw.Breakpoint, Adw.BreakpointBin>(\n \"breakpoints\",\n \"AdwBreakpoint\",\n (bin, breakpoint) => {\n bin.addBreakpoint(breakpoint);\n },\n (bin, breakpoint) => {\n bin.removeBreakpoint(breakpoint);\n },\n ),\n ],\n },\n AdwActionRow: {\n behaviors: prefixSuffix,\n },\n AdwEntryRow: {\n behaviors: prefixSuffix,\n },\n AdwExpanderRow: {\n behaviors: [\n ...prefixSuffix,\n addRemoveSlot<Gtk.Widget, Adw.ExpanderRow>(\n \"rows\",\n \"GtkWidget\",\n (row, child) => {\n row.addRow(child);\n },\n (row, child) => {\n row.remove(child);\n },\n ),\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: [\n addRemoveSlot<Gtk.Widget, Adw.PreferencesGroup>(\n \"children\",\n \"GtkWidget\",\n (group, child) => {\n group.add(child);\n },\n (group, child) => {\n group.remove(child);\n },\n ),\n ],\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 addRemoveSlot<Adw.NavigationPage, Adw.NavigationView>(\n \"children\",\n \"AdwNavigationPage\",\n (view, page) => {\n view.add(page);\n },\n (view, page) => {\n view.remove(page);\n },\n ),\n ],\n },\n AdwViewStack: {\n behaviors: [\n adoptedChildrenSlot<Adw.ViewStack, Gtk.Widget>(\n \"GtkWidget\",\n (stack, child) => stack.add(child),\n (stack, child) => {\n stack.remove(child);\n },\n ),\n deferred<Adw.ViewStack, string>(\"visibleChildName\", (stack, name) => stack.getChildByName(name) !== null),\n ],\n },\n AdwToolbarView: {\n behaviors: [\n contentSetterSlot<Adw.ToolbarView>(),\n addRemoveSlot<Gtk.Widget, Adw.ToolbarView>(\n \"topBar\",\n \"GtkWidget\",\n (view, child) => {\n view.addTopBar(child);\n },\n (view, child) => {\n view.remove(child);\n },\n ),\n addRemoveSlot<Gtk.Widget, Adw.ToolbarView>(\n \"bottomBar\",\n \"GtkWidget\",\n (view, child) => {\n view.addBottomBar(child);\n },\n (view, child) => {\n view.remove(child);\n },\n ),\n ],\n },\n AdwHeaderBar: {\n behaviors: [\n slot<Adw.HeaderBar, Gtk.Widget>(\"start\", \"GtkWidget\", {\n attach: (bar, child) => {\n bar.packStart(child);\n },\n detach: (bar, child) => {\n bar.remove(child);\n },\n }),\n slot<Adw.HeaderBar, Gtk.Widget>(\"end\", \"GtkWidget\", {\n attach: (bar, child) => {\n bar.packEnd(child);\n },\n detach: (bar, child) => {\n bar.remove(child);\n },\n }),\n ],\n },\n AdwShortcutsDialog: {\n behaviors: [\n slot<Adw.ShortcutsDialog, Adw.ShortcutsSection>(\"children\", \"AdwShortcutsSection\", {\n attach: (dialog, section) => {\n dialog.add(section);\n },\n }),\n ],\n },\n AdwShortcutsSection: {\n behaviors: [\n slot<Adw.ShortcutsSection, Adw.ShortcutsItem>(\"children\", \"AdwShortcutsItem\", {\n attach: (section, item) => {\n section.add(item);\n },\n }),\n ],\n },\n AdwToggleGroup: {\n behaviors: [\n addRemoveSlot<Adw.Toggle, Adw.ToggleGroup>(\n \"children\",\n \"AdwToggle\",\n (group, toggle) => {\n group.add(toggle);\n },\n (group, toggle) => {\n group.remove(toggle);\n },\n ),\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,MA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AAc,EAAE;QACZ,SAAS,EAAE;YACP,qBAAqB;YACrB,IAAI,CAAuC,WAAW,EAAE;gBACpD,GAAG,EAAE,CAAC,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
|
|
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
|
|
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
|
-
|
|
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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Y,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"]}
|