@gtkx/react 1.0.0-rc.3 → 1.0.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.
Files changed (203) hide show
  1. package/README.md +8 -9
  2. package/dist/adw/config.d.ts +1 -0
  3. package/dist/adw/config.d.ts.map +1 -1
  4. package/dist/adw/config.js +1 -0
  5. package/dist/adw/config.js.map +1 -1
  6. package/dist/adw/dialog.d.ts +4 -4
  7. package/dist/adw/dialog.d.ts.map +1 -1
  8. package/dist/adw/dialog.js +16 -21
  9. package/dist/adw/dialog.js.map +1 -1
  10. package/dist/adw/element-behaviors.js +104 -57
  11. package/dist/adw/element-behaviors.js.map +1 -1
  12. package/dist/adw/element-config.d.ts +0 -5
  13. package/dist/adw/element-config.d.ts.map +1 -1
  14. package/dist/adw/element-config.js +25 -26
  15. package/dist/adw/element-config.js.map +1 -1
  16. package/dist/adw/index.d.ts +1 -0
  17. package/dist/adw/index.d.ts.map +1 -1
  18. package/dist/adw/index.js +1 -0
  19. package/dist/adw/index.js.map +1 -1
  20. package/dist/adw/prop-types.d.ts +35 -4
  21. package/dist/adw/prop-types.d.ts.map +1 -1
  22. package/dist/adw/prop-types.js.map +1 -1
  23. package/dist/bootstrap.js +1 -1
  24. package/dist/bootstrap.js.map +1 -1
  25. package/dist/components/application-window.d.ts +5 -0
  26. package/dist/components/application-window.d.ts.map +1 -0
  27. package/dist/components/application-window.js +7 -0
  28. package/dist/components/application-window.js.map +1 -0
  29. package/dist/components/application.d.ts +3 -8
  30. package/dist/components/application.d.ts.map +1 -1
  31. package/dist/components/application.js +22 -6
  32. package/dist/components/application.js.map +1 -1
  33. package/dist/components/element.d.ts +13 -2
  34. package/dist/components/element.d.ts.map +1 -1
  35. package/dist/components/element.js +39 -15
  36. package/dist/components/element.js.map +1 -1
  37. package/dist/components/portaled.d.ts +5 -0
  38. package/dist/components/portaled.d.ts.map +1 -0
  39. package/dist/components/portaled.js +8 -0
  40. package/dist/components/portaled.js.map +1 -0
  41. package/dist/components/window.d.ts +6 -5
  42. package/dist/components/window.d.ts.map +1 -1
  43. package/dist/components/window.js +17 -16
  44. package/dist/components/window.js.map +1 -1
  45. package/dist/config.d.ts +7 -2
  46. package/dist/config.d.ts.map +1 -1
  47. package/dist/config.js +5 -1
  48. package/dist/config.js.map +1 -1
  49. package/dist/element-behaviors.js +11 -2
  50. package/dist/element-behaviors.js.map +1 -1
  51. package/dist/element-config.d.ts +4 -3
  52. package/dist/element-config.d.ts.map +1 -1
  53. package/dist/element-config.js +19 -15
  54. package/dist/element-config.js.map +1 -1
  55. package/dist/hooks/use-bind-setting.d.ts +8 -7
  56. package/dist/hooks/use-bind-setting.d.ts.map +1 -1
  57. package/dist/hooks/use-bind-setting.js +2 -7
  58. package/dist/hooks/use-bind-setting.js.map +1 -1
  59. package/dist/hooks/use-merged-refs.d.ts +1 -4
  60. package/dist/hooks/use-merged-refs.d.ts.map +1 -1
  61. package/dist/hooks/use-merged-refs.js +1 -1
  62. package/dist/hooks/use-merged-refs.js.map +1 -1
  63. package/dist/hooks/use-parent-window.d.ts +3 -1
  64. package/dist/hooks/use-parent-window.d.ts.map +1 -1
  65. package/dist/hooks/use-parent-window.js +3 -1
  66. package/dist/hooks/use-parent-window.js.map +1 -1
  67. package/dist/hooks/use-presented-instance.d.ts +12 -0
  68. package/dist/hooks/use-presented-instance.d.ts.map +1 -0
  69. package/dist/hooks/use-presented-instance.js +27 -0
  70. package/dist/hooks/use-presented-instance.js.map +1 -0
  71. package/dist/hooks/use-property.d.ts +4 -3
  72. package/dist/hooks/use-property.d.ts.map +1 -1
  73. package/dist/hooks/use-property.js +1 -2
  74. package/dist/hooks/use-property.js.map +1 -1
  75. package/dist/hooks/use-setting.d.ts +2 -3
  76. package/dist/hooks/use-setting.d.ts.map +1 -1
  77. package/dist/hooks/use-setting.js +2 -3
  78. package/dist/hooks/use-setting.js.map +1 -1
  79. package/dist/hooks/use-signal.d.ts +15 -8
  80. package/dist/hooks/use-signal.d.ts.map +1 -1
  81. package/dist/hooks/use-signal.js +6 -8
  82. package/dist/hooks/use-signal.js.map +1 -1
  83. package/dist/index.d.ts +10 -2
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +8 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/internal.d.ts +8 -5
  88. package/dist/internal.d.ts.map +1 -1
  89. package/dist/internal.js +7 -5
  90. package/dist/internal.js.map +1 -1
  91. package/dist/prop-types.d.ts +88 -4
  92. package/dist/prop-types.d.ts.map +1 -1
  93. package/dist/prop-types.js.map +1 -1
  94. package/dist/reconciler/apply-props.d.ts +4 -4
  95. package/dist/reconciler/apply-props.d.ts.map +1 -1
  96. package/dist/reconciler/apply-props.js +62 -20
  97. package/dist/reconciler/apply-props.js.map +1 -1
  98. package/dist/reconciler/behaviors.d.ts +9 -20
  99. package/dist/reconciler/behaviors.d.ts.map +1 -1
  100. package/dist/reconciler/behaviors.js +44 -41
  101. package/dist/reconciler/behaviors.js.map +1 -1
  102. package/dist/reconciler/devtools.d.ts +6 -0
  103. package/dist/reconciler/devtools.d.ts.map +1 -0
  104. package/dist/reconciler/devtools.js +11 -0
  105. package/dist/reconciler/devtools.js.map +1 -0
  106. package/dist/reconciler/host-config.d.ts +1 -1
  107. package/dist/reconciler/host-config.d.ts.map +1 -1
  108. package/dist/reconciler/host-config.js +17 -26
  109. package/dist/reconciler/host-config.js.map +1 -1
  110. package/dist/reconciler/instance.d.ts.map +1 -1
  111. package/dist/reconciler/instance.js +6 -4
  112. package/dist/reconciler/instance.js.map +1 -1
  113. package/dist/reconciler/metadata.d.ts +2 -2
  114. package/dist/reconciler/metadata.d.ts.map +1 -1
  115. package/dist/reconciler/metadata.js +9 -11
  116. package/dist/reconciler/metadata.js.map +1 -1
  117. package/dist/reconciler/node.d.ts +4 -3
  118. package/dist/reconciler/node.d.ts.map +1 -1
  119. package/dist/reconciler/node.js +8 -7
  120. package/dist/reconciler/node.js.map +1 -1
  121. package/dist/reconciler/placement.js +20 -20
  122. package/dist/reconciler/placement.js.map +1 -1
  123. package/dist/reconciler/registry.d.ts +46 -32
  124. package/dist/reconciler/registry.d.ts.map +1 -1
  125. package/dist/reconciler/registry.js +10 -19
  126. package/dist/reconciler/registry.js.map +1 -1
  127. package/dist/reconciler/root-element.d.ts +1 -1
  128. package/dist/reconciler/root-element.d.ts.map +1 -1
  129. package/dist/reconciler/root-element.js +0 -1
  130. package/dist/reconciler/root-element.js.map +1 -1
  131. package/dist/reconciler/root.d.ts +9 -20
  132. package/dist/reconciler/root.d.ts.map +1 -1
  133. package/dist/reconciler/root.js +6 -19
  134. package/dist/reconciler/root.js.map +1 -1
  135. package/dist/reconciler/signals.d.ts +1 -2
  136. package/dist/reconciler/signals.d.ts.map +1 -1
  137. package/dist/reconciler/signals.js +3 -3
  138. package/dist/reconciler/signals.js.map +1 -1
  139. package/dist/reconciler/text.js +5 -5
  140. package/dist/reconciler/text.js.map +1 -1
  141. package/dist/utils/accessible-props.d.ts +57 -9
  142. package/dist/utils/accessible-props.d.ts.map +1 -1
  143. package/dist/utils/accessible-props.js +11 -13
  144. package/dist/utils/accessible-props.js.map +1 -1
  145. package/dist/utils/ref-prop.d.ts +0 -6
  146. package/dist/utils/ref-prop.d.ts.map +1 -1
  147. package/dist/utils/ref-prop.js +0 -6
  148. package/dist/utils/ref-prop.js.map +1 -1
  149. package/dist/utils/settings.d.ts +7 -0
  150. package/dist/utils/settings.d.ts.map +1 -1
  151. package/dist/utils/settings.js.map +1 -1
  152. package/dist/utils/variant.d.ts +33 -1
  153. package/dist/utils/variant.d.ts.map +1 -1
  154. package/dist/utils/variant.js.map +1 -1
  155. package/env.d.ts +11 -4
  156. package/package.json +5 -5
  157. package/src/adw/config.ts +1 -0
  158. package/src/adw/dialog.tsx +23 -25
  159. package/src/adw/element-behaviors.ts +131 -60
  160. package/src/adw/element-config.ts +25 -26
  161. package/src/adw/index.ts +1 -0
  162. package/src/adw/prop-types.ts +36 -3
  163. package/src/bootstrap.ts +1 -1
  164. package/src/components/application-window.tsx +10 -0
  165. package/src/components/application.tsx +32 -5
  166. package/src/components/element.tsx +52 -17
  167. package/src/components/portaled.tsx +14 -0
  168. package/src/components/window.tsx +25 -23
  169. package/src/config.ts +13 -8
  170. package/src/element-behaviors.ts +20 -1
  171. package/src/element-config.ts +19 -15
  172. package/src/hooks/use-bind-setting.ts +8 -7
  173. package/src/hooks/use-merged-refs.ts +1 -1
  174. package/src/hooks/use-parent-window.ts +3 -1
  175. package/src/hooks/use-presented-instance.tsx +50 -0
  176. package/src/hooks/use-property.ts +4 -3
  177. package/src/hooks/use-setting.ts +2 -3
  178. package/src/hooks/use-signal.ts +18 -11
  179. package/src/index.ts +10 -2
  180. package/src/internal.ts +8 -5
  181. package/src/prop-types.ts +119 -11
  182. package/src/reconciler/apply-props.ts +77 -24
  183. package/src/reconciler/behaviors.ts +77 -50
  184. package/src/reconciler/devtools.ts +18 -0
  185. package/src/reconciler/host-config.ts +20 -32
  186. package/src/reconciler/instance.ts +7 -4
  187. package/src/reconciler/metadata.ts +11 -14
  188. package/src/reconciler/node.ts +12 -9
  189. package/src/reconciler/placement.ts +25 -25
  190. package/src/reconciler/registry.ts +56 -39
  191. package/src/reconciler/root-element.ts +4 -2
  192. package/src/reconciler/root.ts +12 -20
  193. package/src/reconciler/signals.ts +2 -3
  194. package/src/reconciler/text.ts +6 -6
  195. package/src/utils/accessible-props.ts +70 -25
  196. package/src/utils/ref-prop.ts +0 -6
  197. package/src/utils/settings.ts +7 -0
  198. package/src/utils/variant.ts +33 -1
  199. package/dist/utils/accessible-metadata.d.ts +0 -12
  200. package/dist/utils/accessible-metadata.d.ts.map +0 -1
  201. package/dist/utils/accessible-metadata.js +0 -25
  202. package/dist/utils/accessible-metadata.js.map +0 -1
  203. package/src/utils/accessible-metadata.ts +0 -31
@@ -1,9 +1,9 @@
1
1
  import * as Gio from "@gtkx/gi/gio";
2
+ import * as GLib from "@gtkx/gi/glib";
2
3
  import * as Gtk from "@gtkx/gi/gtk";
3
4
  import { BUILTIN_ELEMENTS, SINGLE_CHILD_TYPES } from "./element-config.js";
4
- import { addRemoveSlot, adoptedChildrenSlot, boxSlot, childSetterSlot, controlledText, deferred, list, slot, value, wrappingIndexedSlot, } from "./reconciler/behaviors.js";
5
+ import { addRemoveSlot, adoptedChildrenSlot, applicationCreator, boxSlot, childSetterSlot, controlledText, deferred, list, slot, value, wrappingIndexedSlot, } from "./reconciler/behaviors.js";
5
6
  import { forTypes, registerElements } from "./reconciler/registry.js";
6
- /** The runtime half of the built-in element configuration: the behaviors bound to each GObject type. */
7
7
  const BUILTIN_BEHAVIORS = {
8
8
  ...forTypes(SINGLE_CHILD_TYPES, {
9
9
  behaviors: [childSetterSlot()],
@@ -235,6 +235,7 @@ const BUILTIN_BEHAVIORS = {
235
235
  },
236
236
  GtkApplication: {
237
237
  behaviors: [
238
+ applicationCreator(Gtk.Application),
238
239
  addRemoveSlot("children", "GtkWindow", (application, window) => {
239
240
  application.addWindow(window);
240
241
  }, (application, window) => {
@@ -248,6 +249,11 @@ const BUILTIN_BEHAVIORS = {
248
249
  application.setAccelsForAction(item.detailedActionName, []);
249
250
  },
250
251
  }),
252
+ list("mainOptions", {
253
+ add: (application, option) => {
254
+ addMainOption(application, option);
255
+ },
256
+ }),
251
257
  ],
252
258
  },
253
259
  GtkAboutDialog: {
@@ -324,6 +330,9 @@ const BUILTIN_BEHAVIORS = {
324
330
  function layoutChild(parent, child) {
325
331
  return parent.getLayoutManager()?.getLayoutChild(child) ?? null;
326
332
  }
333
+ const addMainOption = (application, option) => {
334
+ application.addMainOption(option.longName, option.shortName?.codePointAt(0) ?? 0, option.flags ?? GLib.OptionFlags.NONE, option.arg ?? GLib.OptionArg.NONE, option.description, option.argDescription ?? null);
335
+ };
327
336
  const buildMenu = (items) => {
328
337
  const menu = Gio.Menu.new();
329
338
  for (const item of items) {
@@ -1 +1 @@
1
- {"version":3,"file":"element-behaviors.js","sourceRoot":"","sources":["../src/element-behaviors.ts"],"names":[],"m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IAAI,CAAC;AACpE,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,KAAiB,EAAY,EAAE;IAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,SAAS,cAAc,CAAC,IAAc,EAAE,IAAc;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;IAEjC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAEnD,OAAO;IACX,CAAC;IAED,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAEnD,OAAO;IACX,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 Gtk from \"@gtkx/gi/gtk\";\nimport type {\n ActionAccel,\n CreditSection,\n DragSourceIcon,\n LevelBarOffset,\n MenuItem,\n ScaleMark,\n VflConstraints,\n} from \"./prop-types.js\";\nimport { BUILTIN_ELEMENTS, SINGLE_CHILD_TYPES } from \"./element-config.js\";\nimport {\n addRemoveSlot,\n adoptedChildrenSlot,\n boxSlot,\n childSetterSlot,\n controlledText,\n deferred,\n list,\n slot,\n value,\n wrappingIndexedSlot,\n} from \"./reconciler/behaviors.js\";\nimport { type ElementConfig, forTypes, registerElements } from \"./reconciler/registry.js\";\n\n/** The runtime half of the built-in element configuration: the behaviors bound to each GObject type. */\nconst BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {\n ...forTypes(SINGLE_CHILD_TYPES, {\n behaviors: [childSetterSlot()],\n }),\n ...forTypes([\"GtkHeaderBar\", \"GtkActionBar\"], {\n behaviors: [\n addRemoveSlot<Gtk.Widget, Gtk.HeaderBar | Gtk.ActionBar>(\n \"start\",\n \"GtkWidget\",\n (bar, child) => {\n bar.packStart(child);\n },\n (bar, child) => {\n bar.remove(child);\n },\n ),\n addRemoveSlot<Gtk.Widget, Gtk.HeaderBar | Gtk.ActionBar>(\n \"end\",\n \"GtkWidget\",\n (bar, child) => {\n bar.packEnd(child);\n },\n (bar, child) => {\n bar.remove(child);\n },\n ),\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 addRemoveSlot<Gtk.EventController, Gtk.Widget>(\n \"controllers\",\n \"GtkEventController\",\n (widget, controller) => {\n widget.addController(controller);\n },\n (widget, controller) => {\n widget.removeController(controller);\n },\n ),\n slot<Gtk.Widget, Gtk.LayoutManager>(\"layoutManager\", \"GtkLayoutManager\", {\n attach: (widget, manager) => {\n widget.setLayoutManager(manager);\n },\n detach: (widget) => {\n widget.setLayoutManager(null);\n },\n }),\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 ],\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 ],\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 addRemoveSlot<Gtk.Shortcut, Gtk.ShortcutController>(\n \"shortcuts\",\n \"GtkShortcut\",\n (controller, shortcut) => {\n controller.addShortcut(shortcut);\n },\n (controller, shortcut) => {\n controller.removeShortcut(shortcut);\n },\n ),\n ],\n },\n GtkTextChildAnchor: {\n behaviors: [{ create: () => Gtk.TextChildAnchor.new() }],\n },\n GtkTextView: {\n behaviors: [\n slot<Gtk.TextView, Gtk.TextBuffer>(\"children\", \"GtkTextBuffer\", {\n attach: (view, buffer) => {\n view.setBuffer(buffer);\n },\n detach: (view) => {\n view.setBuffer(null);\n },\n }),\n ],\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 addRemoveSlot<Gtk.Constraint, Gtk.ConstraintLayout>(\n \"constraints\",\n \"GtkConstraint\",\n (layout, constraint) => {\n layout.addConstraint(constraint);\n },\n (layout, constraint) => {\n layout.removeConstraint(constraint);\n },\n ),\n addRemoveSlot<Gtk.ConstraintGuide, Gtk.ConstraintLayout>(\n \"guides\",\n \"GtkConstraintGuide\",\n (layout, guide) => {\n layout.addGuide(guide);\n },\n (layout, guide) => {\n layout.removeGuide(guide);\n },\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 adoptedChildrenSlot<Gtk.Stack, Gtk.Widget>(\n \"GtkWidget\",\n (stack, child) => stack.addChild(child),\n (stack, child) => {\n stack.remove(child);\n },\n ),\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 addRemoveSlot<Gtk.Window, Gtk.Application>(\n \"children\",\n \"GtkWindow\",\n (application, window) => {\n application.addWindow(window);\n },\n (application, window) => {\n application.removeWindow(window);\n },\n ),\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 ],\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 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,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,cAAc,EACd,QAAQ,E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AiB,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 addRemoveSlot,\n adoptedChildrenSlot,\n applicationCreator,\n boxSlot,\n childSetterSlot,\n controlledText,\n deferred,\n list,\n slot,\n value,\n wrappingIndexedSlot,\n} from \"./reconciler/behaviors.js\";\nimport { type ElementConfig, forTypes, registerElements } from \"./reconciler/registry.js\";\n\nconst BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {\n ...forTypes(SINGLE_CHILD_TYPES, {\n behaviors: [childSetterSlot()],\n }),\n ...forTypes([\"GtkHeaderBar\", \"GtkActionBar\"], {\n behaviors: [\n addRemoveSlot<Gtk.Widget, Gtk.HeaderBar | Gtk.ActionBar>(\n \"start\",\n \"GtkWidget\",\n (bar, child) => {\n bar.packStart(child);\n },\n (bar, child) => {\n bar.remove(child);\n },\n ),\n addRemoveSlot<Gtk.Widget, Gtk.HeaderBar | Gtk.ActionBar>(\n \"end\",\n \"GtkWidget\",\n (bar, child) => {\n bar.packEnd(child);\n },\n (bar, child) => {\n bar.remove(child);\n },\n ),\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 addRemoveSlot<Gtk.EventController, Gtk.Widget>(\n \"controllers\",\n \"GtkEventController\",\n (widget, controller) => {\n widget.addController(controller);\n },\n (widget, controller) => {\n widget.removeController(controller);\n },\n ),\n slot<Gtk.Widget, Gtk.LayoutManager>(\"layoutManager\", \"GtkLayoutManager\", {\n attach: (widget, manager) => {\n widget.setLayoutManager(manager);\n },\n detach: (widget) => {\n widget.setLayoutManager(null);\n },\n }),\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 ],\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 ],\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 addRemoveSlot<Gtk.Shortcut, Gtk.ShortcutController>(\n \"shortcuts\",\n \"GtkShortcut\",\n (controller, shortcut) => {\n controller.addShortcut(shortcut);\n },\n (controller, shortcut) => {\n controller.removeShortcut(shortcut);\n },\n ),\n ],\n },\n GtkTextChildAnchor: {\n behaviors: [{ create: () => Gtk.TextChildAnchor.new() }],\n },\n GtkTextView: {\n behaviors: [\n slot<Gtk.TextView, Gtk.TextBuffer>(\"children\", \"GtkTextBuffer\", {\n attach: (view, buffer) => {\n view.setBuffer(buffer);\n },\n detach: (view) => {\n view.setBuffer(null);\n },\n }),\n ],\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 addRemoveSlot<Gtk.Constraint, Gtk.ConstraintLayout>(\n \"constraints\",\n \"GtkConstraint\",\n (layout, constraint) => {\n layout.addConstraint(constraint);\n },\n (layout, constraint) => {\n layout.removeConstraint(constraint);\n },\n ),\n addRemoveSlot<Gtk.ConstraintGuide, Gtk.ConstraintLayout>(\n \"guides\",\n \"GtkConstraintGuide\",\n (layout, guide) => {\n layout.addGuide(guide);\n },\n (layout, guide) => {\n layout.removeGuide(guide);\n },\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 adoptedChildrenSlot<Gtk.Stack, Gtk.Widget>(\n \"GtkWidget\",\n (stack, child) => stack.addChild(child),\n (stack, child) => {\n stack.remove(child);\n },\n ),\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 addRemoveSlot<Gtk.Window, Gtk.Application>(\n \"children\",\n \"GtkWindow\",\n (application, window) => {\n application.addWindow(window);\n },\n (application, window) => {\n application.removeWindow(window);\n },\n ),\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 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,9 +1,10 @@
1
1
  import { type ElementConfig } from "./reconciler/registry.js";
2
2
  declare const SINGLE_CHILD_TYPES: string[];
3
3
  /**
4
- * The static, runtime-free half of the built-in element configuration: which base props interface each
5
- * generated element extends, which component wraps it, and whether its GObject is created lazily by its
6
- * parent. Codegen imports this module, so it must never reach the GObject bindings.
4
+ * The framework's own element configuration for the GTK types it customizes: the base props interface each
5
+ * generated element extends, the component that wraps it, the GObject properties left out of its generated
6
+ * props, and whether its GObject is created by its parent. Carries no behaviors, so importing it never
7
+ * reaches the GObject bindings.
7
8
  */
8
9
  declare const BUILTIN_ELEMENTS: Record<string, ElementConfig>;
9
10
  export { SINGLE_CHILD_TYPES, BUILTIN_ELEMENTS };
@@ -1 +1 @@
1
- {"version":3,"file":"element-config.d.ts","sourceRoot":"","sources":["../src/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,0BAA0B,CAAC;AAElF,QAAA,MAAM,kBAAkB,EAAE,MAAM,EAsB/B,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAqHnD,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"element-config.d.ts","sourceRoot":"","sources":["../src/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,0BAA0B,CAAC;AAElF,QAAA,MAAM,kBAAkB,EAAE,MAAM,EAqB/B,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAyHnD,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -3,7 +3,6 @@ const SINGLE_CHILD_TYPES = [
3
3
  "GtkAspectFrame",
4
4
  "GtkButton",
5
5
  "GtkCheckButton",
6
- "GtkComboBox",
7
6
  "GtkDragIcon",
8
7
  "GtkExpander",
9
8
  "GtkFlowBoxChild",
@@ -23,14 +22,15 @@ const SINGLE_CHILD_TYPES = [
23
22
  "GtkWindowHandle",
24
23
  ];
25
24
  /**
26
- * The static, runtime-free half of the built-in element configuration: which base props interface each
27
- * generated element extends, which component wraps it, and whether its GObject is created lazily by its
28
- * parent. Codegen imports this module, so it must never reach the GObject bindings.
25
+ * The framework's own element configuration for the GTK types it customizes: the base props interface each
26
+ * generated element extends, the component that wraps it, the GObject properties left out of its generated
27
+ * props, and whether its GObject is created by its parent. Carries no behaviors, so importing it never
28
+ * reaches the GObject bindings.
29
29
  */
30
30
  const BUILTIN_ELEMENTS = {
31
31
  ...forTypes(SINGLE_CHILD_TYPES, {
32
32
  props: internal("ChildrenProps"),
33
- omitProps: ["child"],
33
+ omittedProps: ["child"],
34
34
  }),
35
35
  ...forTypes(["GtkHeaderBar", "GtkActionBar"], {
36
36
  props: internal("GtkHeaderBarProps"),
@@ -38,7 +38,10 @@ const BUILTIN_ELEMENTS = {
38
38
  GtkWindow: {
39
39
  props: internal("ChildrenProps"),
40
40
  component: internal("createWindowComponent"),
41
- omitProps: ["child"],
41
+ omittedProps: ["child"],
42
+ },
43
+ GtkApplicationWindow: {
44
+ component: internal("createApplicationWindowComponent"),
42
45
  },
43
46
  GtkLabel: {
44
47
  props: internal("ChildrenProps"),
@@ -53,22 +56,22 @@ const BUILTIN_ELEMENTS = {
53
56
  props: internal("GtkTextChildAnchorProps"),
54
57
  },
55
58
  GtkGridLayoutChild: {
56
- lazy: true,
59
+ isLazy: true,
57
60
  },
58
61
  GtkFixedLayoutChild: {
59
- lazy: true,
62
+ isLazy: true,
60
63
  },
61
64
  GtkOverlayLayoutChild: {
62
- lazy: true,
65
+ isLazy: true,
63
66
  },
64
67
  GtkStackPage: {
65
- lazy: true,
68
+ isLazy: true,
66
69
  },
67
70
  GtkNotebookPage: {
68
- lazy: true,
71
+ isLazy: true,
69
72
  },
70
73
  GActionGroup: {
71
- props: internal("GActionGroupProps"),
74
+ props: internal("ActionGroupProps"),
72
75
  },
73
76
  GtkWidget: {
74
77
  props: internal("GtkWidgetProps"),
@@ -84,7 +87,7 @@ const BUILTIN_ELEMENTS = {
84
87
  },
85
88
  GtkOverlay: {
86
89
  props: internal("GtkOverlayProps"),
87
- omitProps: ["child"],
90
+ omittedProps: ["child"],
88
91
  },
89
92
  GtkShortcutController: {
90
93
  props: internal("GtkShortcutControllerProps"),
@@ -93,10 +96,10 @@ const BUILTIN_ELEMENTS = {
93
96
  props: internal("ChildrenProps"),
94
97
  },
95
98
  GActionMap: {
96
- props: internal("GActionMapProps"),
99
+ props: internal("ActionMapProps"),
97
100
  },
98
101
  GMenu: {
99
- props: internal("GMenuProps"),
102
+ props: internal("MenuProps"),
100
103
  },
101
104
  GtkColumnView: {
102
105
  props: internal("ChildrenProps"),
@@ -109,6 +112,7 @@ const BUILTIN_ELEMENTS = {
109
112
  },
110
113
  GtkSizeGroup: {
111
114
  props: internal("GtkSizeGroupProps"),
115
+ component: internal("createPortaledComponent"),
112
116
  },
113
117
  GtkConstraintLayout: {
114
118
  props: internal("GtkConstraintLayoutProps"),
@@ -1 +1 @@
1
- {"version":3,"file":"element-config.js","sourceRoot":"","sources":["../src/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAElF,MAAM,kBAAkB,GAAa;IACjC,gBAAgB;IAChB,WAAW;IACX,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB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KACzC;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;KACnC;IACD,WAAW,EAAE;QACT,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC;KACtC;IACD,WAAW,EAAE;QACT,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC;KACtC;IACD,aAAa,EAAE;QACX,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC;KACxC;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,QAAQ,CAAC,qBAAqB,CAAC;KACzC;IACD,aAAa,EAAE;QACX,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC;KACxC;CACJ,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { type ElementConfig, forTypes, internal } from \"./reconciler/registry.js\";\n\nconst SINGLE_CHILD_TYPES: string[] = [\n \"GtkAspectFrame\",\n \"GtkButton\",\n \"GtkCheckButton\",\n \"GtkComboBox\",\n \"GtkDragIcon\",\n \"GtkExpander\",\n \"GtkFlowBoxChild\",\n \"GtkFrame\",\n \"GtkGraphicsOffload\",\n \"GtkListBoxRow\",\n \"GtkListHeader\",\n \"GtkListItem\",\n \"GtkMenuButton\",\n \"GtkPopover\",\n \"GtkPopoverBin\",\n \"GtkRevealer\",\n \"GtkScrolledWindow\",\n \"GtkSearchBar\",\n \"GtkTreeExpander\",\n \"GtkViewport\",\n \"GtkWindowHandle\",\n];\n\n/**\n * The static, runtime-free half of the built-in element configuration: which base props interface each\n * generated element extends, which component wraps it, and whether its GObject is created lazily by its\n * parent. Codegen imports this module, so it must never reach the GObject bindings.\n */\nconst BUILTIN_ELEMENTS: Record<string, ElementConfig> = {\n ...forTypes(SINGLE_CHILD_TYPES, {\n props: internal(\"ChildrenProps\"),\n omitProps: [\"child\"],\n }),\n ...forTypes([\"GtkHeaderBar\", \"GtkActionBar\"], {\n props: internal(\"GtkHeaderBarProps\"),\n }),\n GtkWindow: {\n props: internal(\"ChildrenProps\"),\n component: internal(\"createWindowComponent\"),\n omitProps: [\"child\"],\n },\n GtkLabel: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextBuffer: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextTag: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextChildAnchor: {\n props: internal(\"GtkTextChildAnchorProps\"),\n },\n GtkGridLayoutChild: {\n lazy: true,\n },\n GtkFixedLayoutChild: {\n lazy: true,\n },\n GtkOverlayLayoutChild: {\n lazy: true,\n },\n GtkStackPage: {\n lazy: true,\n },\n GtkNotebookPage: {\n lazy: true,\n },\n GActionGroup: {\n props: internal(\"GActionGroupProps\"),\n },\n GtkWidget: {\n props: internal(\"GtkWidgetProps\"),\n },\n GtkBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkListBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkFlowBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkOverlay: {\n props: internal(\"GtkOverlayProps\"),\n omitProps: [\"child\"],\n },\n GtkShortcutController: {\n props: internal(\"GtkShortcutControllerProps\"),\n },\n GtkTextView: {\n props: internal(\"ChildrenProps\"),\n },\n GActionMap: {\n props: internal(\"GActionMapProps\"),\n },\n GMenu: {\n props: internal(\"GMenuProps\"),\n },\n GtkColumnView: {\n props: internal(\"ChildrenProps\"),\n },\n GtkGrid: {\n props: internal(\"ChildrenProps\"),\n },\n GtkFixed: {\n props: internal(\"ChildrenProps\"),\n },\n GtkSizeGroup: {\n props: internal(\"GtkSizeGroupProps\"),\n },\n GtkConstraintLayout: {\n props: internal(\"GtkConstraintLayoutProps\"),\n },\n GtkStack: {\n props: internal(\"ChildrenProps\"),\n },\n GtkNotebook: {\n props: internal(\"ChildrenProps\"),\n },\n GtkApplication: {\n props: internal(\"GtkApplicationProps\"),\n component: internal(\"createApplicationComponent\"),\n },\n GtkAboutDialog: {\n props: internal(\"GtkAboutDialogProps\"),\n },\n GtkScale: {\n props: internal(\"GtkScaleProps\"),\n },\n GtkCalendar: {\n props: internal(\"GtkCalendarProps\"),\n },\n GtkLevelBar: {\n props: internal(\"GtkLevelBarProps\"),\n },\n GtkDropTarget: {\n props: internal(\"GtkDropTargetProps\"),\n },\n GtkDrawingArea: {\n props: internal(\"GtkDrawingAreaProps\"),\n },\n GtkDragSource: {\n props: internal(\"GtkDragSourceProps\"),\n },\n};\n\nexport { SINGLE_CHILD_TYPES, BUILTIN_ELEMENTS };\n"]}
1
+ {"version":3,"file":"element-config.js","sourceRoot":"","sources":["../src/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAElF,MAAM,kBAAkB,GAAa;IACjC,gBAAgB;IAChB,WAAW;IACX,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,UAAU;IACV,oBAAoB;IACpB,eAAe;IACf,eAAe;IACf,aAAa;IACb,eAAe;IACf,YAAY;IACZ,eAAe;IACf,aAAa;IACb,mBAAmB;IACnB,cAAc;IACd,iBAAiB;IACjB,aAAa;IACb,iBAAiB;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,gBAAgB,GAAkC;IACpD,GAAG,QAAQ,CAAC,kBAAkB,EAAE;QAC5B,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;QAChC,YAAY,EAAE,CAAC,OAAO,CAAC;KAC1B,CAAC;IACF,GAAG,QAAQ,CAAC,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;QAC1C,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC;KACvC,CAAC;IACF,SAAS,EAAE;QACP,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;QAChC,SAAS,EAAE,QAAQ,CAAC,uBAAuB,CAAC;QAC5C,YAAY,EAAE,CAAC,OAAO,CAAC;KAC1B;IACD,oBAAoB,EAAE;QAClB,SAAS,EAAE,QAAQ,CAAC,kCAAkC,CAAC;KAC1D;IACD,QAAQ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AQ,CAAC,eAAe,CAAC;KACnC;IACD,OAAO,EAAE;QACL,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;KACnC;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;KACnC;IACD,YAAY,EAAE;QACV,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC;QACpC,SAAS,EAAE,QAAQ,CAAC,yBAAyB,CAAC;KACjD;IACD,mBAAmB,EAAE;QACjB,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC;KAC9C;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;KACnC;IACD,WAAW,EAAE;QACT,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;KACnC;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,QAAQ,CAAC,qBAAqB,CAAC;QACtC,SAAS,EAAE,QAAQ,CAAC,4BAA4B,CAAC;KACpD;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,QAAQ,CAAC,qBAAqB,CAAC;KACzC;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;KACnC;IACD,WAAW,EAAE;QACT,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC;KACtC;IACD,WAAW,EAAE;QACT,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC;KACtC;IACD,aAAa,EAAE;QACX,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC;KACxC;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,QAAQ,CAAC,qBAAqB,CAAC;KACzC;IACD,aAAa,EAAE;QACX,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC;KACxC;CACJ,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { type ElementConfig, forTypes, internal } from \"./reconciler/registry.js\";\n\nconst SINGLE_CHILD_TYPES: string[] = [\n \"GtkAspectFrame\",\n \"GtkButton\",\n \"GtkCheckButton\",\n \"GtkDragIcon\",\n \"GtkExpander\",\n \"GtkFlowBoxChild\",\n \"GtkFrame\",\n \"GtkGraphicsOffload\",\n \"GtkListBoxRow\",\n \"GtkListHeader\",\n \"GtkListItem\",\n \"GtkMenuButton\",\n \"GtkPopover\",\n \"GtkPopoverBin\",\n \"GtkRevealer\",\n \"GtkScrolledWindow\",\n \"GtkSearchBar\",\n \"GtkTreeExpander\",\n \"GtkViewport\",\n \"GtkWindowHandle\",\n];\n\n/**\n * The framework's own element configuration for the GTK types it customizes: the base props interface each\n * generated element extends, the component that wraps it, the GObject properties left out of its generated\n * props, and whether its GObject is created by its parent. Carries no behaviors, so importing it never\n * reaches the GObject bindings.\n */\nconst BUILTIN_ELEMENTS: Record<string, ElementConfig> = {\n ...forTypes(SINGLE_CHILD_TYPES, {\n props: internal(\"ChildrenProps\"),\n omittedProps: [\"child\"],\n }),\n ...forTypes([\"GtkHeaderBar\", \"GtkActionBar\"], {\n props: internal(\"GtkHeaderBarProps\"),\n }),\n GtkWindow: {\n props: internal(\"ChildrenProps\"),\n component: internal(\"createWindowComponent\"),\n omittedProps: [\"child\"],\n },\n GtkApplicationWindow: {\n component: internal(\"createApplicationWindowComponent\"),\n },\n GtkLabel: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextBuffer: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextTag: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextChildAnchor: {\n props: internal(\"GtkTextChildAnchorProps\"),\n },\n GtkGridLayoutChild: {\n isLazy: true,\n },\n GtkFixedLayoutChild: {\n isLazy: true,\n },\n GtkOverlayLayoutChild: {\n isLazy: true,\n },\n GtkStackPage: {\n isLazy: true,\n },\n GtkNotebookPage: {\n isLazy: true,\n },\n GActionGroup: {\n props: internal(\"ActionGroupProps\"),\n },\n GtkWidget: {\n props: internal(\"GtkWidgetProps\"),\n },\n GtkBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkListBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkFlowBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkOverlay: {\n props: internal(\"GtkOverlayProps\"),\n omittedProps: [\"child\"],\n },\n GtkShortcutController: {\n props: internal(\"GtkShortcutControllerProps\"),\n },\n GtkTextView: {\n props: internal(\"ChildrenProps\"),\n },\n GActionMap: {\n props: internal(\"ActionMapProps\"),\n },\n GMenu: {\n props: internal(\"MenuProps\"),\n },\n GtkColumnView: {\n props: internal(\"ChildrenProps\"),\n },\n GtkGrid: {\n props: internal(\"ChildrenProps\"),\n },\n GtkFixed: {\n props: internal(\"ChildrenProps\"),\n },\n GtkSizeGroup: {\n props: internal(\"GtkSizeGroupProps\"),\n component: internal(\"createPortaledComponent\"),\n },\n GtkConstraintLayout: {\n props: internal(\"GtkConstraintLayoutProps\"),\n },\n GtkStack: {\n props: internal(\"ChildrenProps\"),\n },\n GtkNotebook: {\n props: internal(\"ChildrenProps\"),\n },\n GtkApplication: {\n props: internal(\"GtkApplicationProps\"),\n component: internal(\"createApplicationComponent\"),\n },\n GtkAboutDialog: {\n props: internal(\"GtkAboutDialogProps\"),\n },\n GtkScale: {\n props: internal(\"GtkScaleProps\"),\n },\n GtkCalendar: {\n props: internal(\"GtkCalendarProps\"),\n },\n GtkLevelBar: {\n props: internal(\"GtkLevelBarProps\"),\n },\n GtkDropTarget: {\n props: internal(\"GtkDropTargetProps\"),\n },\n GtkDrawingArea: {\n props: internal(\"GtkDrawingAreaProps\"),\n },\n GtkDragSource: {\n props: internal(\"GtkDragSourceProps\"),\n },\n};\n\nexport { SINGLE_CHILD_TYPES, BUILTIN_ELEMENTS };\n"]}
@@ -2,21 +2,22 @@ import type * as GObject from "@gtkx/gi/gobject";
2
2
  import * as Gio from "@gtkx/gi/gio";
3
3
  import type { SettingsSchema, SettingsSchemaKeys } from "../utils/settings.js";
4
4
  import { type RefProp } from "../utils/ref-prop.js";
5
+ /** Options for {@link useBindSetting}. */
5
6
  type UseBindSettingOptions<K extends SettingsSchemaKeys> = {
7
+ /** Schema the settings object is opened from. */
6
8
  schema: SettingsSchema<K>;
9
+ /** Key of that schema to bind. */
7
10
  key: keyof K & string;
11
+ /** Object holding the property, given directly or as a ref; nothing is bound while it is absent. */
8
12
  object: RefProp<GObject.Object>;
13
+ /** camelCase name of the property to keep in sync with the key. */
9
14
  property: string;
15
+ /** Direction and conversion behavior of the bind; defaults to `Gio.SettingsBindFlags.DEFAULT`. */
10
16
  flags?: Gio.SettingsBindFlags;
11
17
  };
12
18
  /**
13
- * Binds a GSettings key to a property of a GObject, keeping the two in sync for the object's lifetime.
14
- *
15
- * @param options.schema The schema reference identifying the settings backend.
16
- * @param options.key The key within the schema to bind.
17
- * @param options.object The GObject whose property is bound to the setting.
18
- * @param options.property The name of the object property to bind.
19
- * @param options.flags Flags controlling the binding's direction and behaviour.
19
+ * Binds a GSettings key to a property of a GObject, keeping the two in sync until the component unmounts.
20
+ * `property` is given in camelCase, and `flags` defaults to `Gio.SettingsBindFlags.DEFAULT`, a two-way bind.
20
21
  */
21
22
  declare function useBindSetting<K extends SettingsSchemaKeys>({ schema, key, object, property, flags, }: UseBindSettingOptions<K>): void;
22
23
  export { useBindSetting };
@@ -1 +1 @@
1
- {"version":3,"file":"use-bind-setting.d.ts","sourceRoot":"","sources":["../../src/hooks/use-bind-setting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,sBAAsB,CAAC;AAGpE,KAAK,qBAAqB,CAAC,CAAC,SAAS,kBAAkB,IAAI;IACvD,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;IACtB,MAA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,GAAG,IAAI,CAiBjC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -4,13 +4,8 @@ import { useLayoutEffect } from "react";
4
4
  import { resolveRefProp } from "../utils/ref-prop.js";
5
5
  import { useSettings } from "./use-setting.js";
6
6
  /**
7
- * Binds a GSettings key to a property of a GObject, keeping the two in sync for the object's lifetime.
8
- *
9
- * @param options.schema The schema reference identifying the settings backend.
10
- * @param options.key The key within the schema to bind.
11
- * @param options.object The GObject whose property is bound to the setting.
12
- * @param options.property The name of the object property to bind.
13
- * @param options.flags Flags controlling the binding's direction and behaviour.
7
+ * Binds a GSettings key to a property of a GObject, keeping the two in sync until the component unmounts.
8
+ * `property` is given in camelCase, and `flags` defaults to `Gio.SettingsBindFlags.DEFAULT`, a two-way bind.
14
9
  */
15
10
  function useBindSetting({ schema, key, object, property, flags = Gio.SettingsBindFlags.DEFAULT, }) {
16
11
  const settings = useSettings(schema);
@@ -1 +1 @@
1
- {"version":3,"file":"use-bind-setting.js","sourceRoot":"","sources":["../../src/hooks/use-bind-setting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAgB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAU/C;;;;;;;;GAQG;AACH,SAAS,cAAc,CAA+B,EAClD,MAAM,EACN,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC,OAAO,GACd;IACvB,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAEzC,eAAe,CAAC,GAAG,EAAE;QACjB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,OAAO;QACX,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAElD,OAAO,GAAG,EAAE;YACR,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAChD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport { kebabCase } from \"@gtkx/utils\";\nimport { useLayoutEffect } from \"react\";\nimport type { SettingsSchema, SettingsSchemaKeys } from \"../utils/settings.js\";\nimport { type RefProp, resolveRefProp } from \"../utils/ref-prop.js\";\nimport { useSettings } from \"./use-setting.js\";\n\ntype UseBindSettingOptions<K extends SettingsSchemaKeys> = {\n schema: SettingsSchema<K>;\n key: keyof K & string;\n object: RefProp<GObject.Object>;\n property: string;\n flags?: Gio.SettingsBindFlags;\n};\n\n/**\n * Binds a GSettings key to a property of a GObject, keeping the two in sync for the object's lifetime.\n *\n * @param options.schema The schema reference identifying the settings backend.\n * @param options.key The key within the schema to bind.\n * @param options.object The GObject whose property is bound to the setting.\n * @param options.property The name of the object property to bind.\n * @param options.flags Flags controlling the binding's direction and behaviour.\n */\nfunction useBindSetting<K extends SettingsSchemaKeys>({\n schema,\n key,\n object,\n property,\n flags = Gio.SettingsBindFlags.DEFAULT,\n}: UseBindSettingOptions<K>): void {\n const settings = useSettings(schema);\n const propertyName = kebabCase(property);\n\n useLayoutEffect(() => {\n const resolved = resolveRefProp(object);\n\n if (!resolved) {\n return;\n }\n\n settings.bind(key, resolved, propertyName, flags);\n\n return () => {\n Gio.Settings.unbind(resolved, propertyName);\n };\n }, [settings, key, object, propertyName, flags]);\n}\n\nexport { useBindSetting };\n"]}
1
+ {"version":3,"file":"use-bind-setting.js","sourceRoot":"","sources":["../../src/hooks/use-bind-setting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAgB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgB/C;;;GAGG;AACH,SAAS,cAAc,CAA+B,EAClD,MAAM,EACN,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC,OAAO,GACd;IACvB,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAEzC,eAAe,CAAC,GAAG,EAAE;QACjB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,OAAO;QACX,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAElD,OAAO,GAAG,EAAE;YACR,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAChD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport { kebabCase } from \"@gtkx/utils\";\nimport { useLayoutEffect } from \"react\";\nimport type { SettingsSchema, SettingsSchemaKeys } from \"../utils/settings.js\";\nimport { type RefProp, resolveRefProp } from \"../utils/ref-prop.js\";\nimport { useSettings } from \"./use-setting.js\";\n\n/** Options for {@link useBindSetting}. */\ntype UseBindSettingOptions<K extends SettingsSchemaKeys> = {\n /** Schema the settings object is opened from. */\n schema: SettingsSchema<K>;\n /** Key of that schema to bind. */\n key: keyof K & string;\n /** Object holding the property, given directly or as a ref; nothing is bound while it is absent. */\n object: RefProp<GObject.Object>;\n /** camelCase name of the property to keep in sync with the key. */\n property: string;\n /** Direction and conversion behavior of the bind; defaults to `Gio.SettingsBindFlags.DEFAULT`. */\n flags?: Gio.SettingsBindFlags;\n};\n\n/**\n * Binds a GSettings key to a property of a GObject, keeping the two in sync until the component unmounts.\n * `property` is given in camelCase, and `flags` defaults to `Gio.SettingsBindFlags.DEFAULT`, a two-way bind.\n */\nfunction useBindSetting<K extends SettingsSchemaKeys>({\n schema,\n key,\n object,\n property,\n flags = Gio.SettingsBindFlags.DEFAULT,\n}: UseBindSettingOptions<K>): void {\n const settings = useSettings(schema);\n const propertyName = kebabCase(property);\n\n useLayoutEffect(() => {\n const resolved = resolveRefProp(object);\n\n if (!resolved) {\n return;\n }\n\n settings.bind(key, resolved, propertyName, flags);\n\n return () => {\n Gio.Settings.unbind(resolved, propertyName);\n };\n }, [settings, key, object, propertyName, flags]);\n}\n\nexport { useBindSetting };\n"]}
@@ -1,8 +1,5 @@
1
1
  import { type Ref, type RefCallback } from "react";
2
2
  type PossibleRef<T> = Ref<T> | undefined;
3
- type RefCleanup<T> = ReturnType<RefCallback<T>>;
4
- declare function assignRef<T>(ref: PossibleRef<T>, value: T): RefCleanup<T>;
5
- declare function mergeRefs<T>(...refs: PossibleRef<T>[]): RefCallback<T>;
6
3
  declare function useMergedRef<T>(first: PossibleRef<T>, second: PossibleRef<T>): RefCallback<T>;
7
- export { assignRef, mergeRefs, useMergedRef };
4
+ export { useMergedRef };
8
5
  //# sourceMappingURL=use-merged-refs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-merged-refs.d.ts","sourceRoot":"","sources":["../../src/hooks/use-merged-refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,WAAW,EAAW,MAAM,OAAO,CAAC;AAE5D,KAAK,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACzC,KAAK,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAGhD,iBAAS,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAQlE;AAsCD,iBAAS,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAI/D;AAED,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEtF;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"use-merged-refs.d.ts","sourceRoot":"","sources":["../../src/hooks/use-merged-refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,WAAW,EAAW,MAAM,OAAO,CAAC;AAE5D,KAAK,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAwDzC,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEtF;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -44,5 +44,5 @@ function mergeRefs(...refs) {
44
44
  function useMergedRef(first, second) {
45
45
  return useMemo(() => mergeRefs(first, second), [first, second]);
46
46
  }
47
- export { assignRef, mergeRefs, useMergedRef };
47
+ export { useMergedRef };
48
48
  //# sourceMappingURL=use-merged-refs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-merged-refs.js","sourceRoot":"","sources":["../../src/hooks/use-merged-refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAA8B,OAAO,EAAE,MAAM,OAAO,CAAC;AAM5D,SAAS,SAAS,CAAI,GAAmB,EAAE,KAAQ;IAC/C,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;QACpC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACxB,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAI,UAAyB,EAAE,GAAmB,EAAE,IAAc;IACrF,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAErC,IAAI,OAAO,EAAE,CAAC;QACV,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAI,UAAyB,EAAE,GAAmB;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC;IACd,CAAC;SAAM,CAAC;QACJ,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAI,UAAyB,EAAE,IAAsB,EAAE,IAAc;IACnF,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACX,CAAC;IAED,OAAO,GAAG,EAAE;QACR,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACrB,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAChC,CAAC;QAED,UAAU,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CAAC;AACN,CAAC;AAED,SAAS,SAAS,CAAI,GAAG,IAAsB;IAC3C,MAAM,UAAU,GAAkB,IAAI,GAAG,EAAE,CAAC;IAE5C,OAAO,CAAC,IAAc,EAAiB,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,YAAY,CAAI,KAAqB,EAAE,MAAsB;IAClE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { isRecord } from \"@gtkx/utils\";\nimport { type Ref, type RefCallback, useMemo } from \"react\";\n\ntype PossibleRef<T> = Ref<T> | undefined;\ntype RefCleanup<T> = ReturnType<RefCallback<T>>;\ntype CleanupMap<T> = Map<PossibleRef<T>, Exclude<RefCleanup<T>, void>>;\n\nfunction assignRef<T>(ref: PossibleRef<T>, value: T): RefCleanup<T> {\n if (typeof ref === \"function\") {\n return ref(value);\n }\n\n if (isRecord(ref) && \"current\" in ref) {\n ref.current = value;\n }\n}\n\nfunction collectCleanup<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>, node: T | null): void {\n const cleanup = assignRef(ref, node);\n\n if (cleanup) {\n cleanupMap.set(ref, cleanup);\n }\n}\n\nfunction cleanupRef<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>): void {\n const cleanup = cleanupMap.get(ref);\n\n if (cleanup && typeof cleanup === \"function\") {\n cleanup();\n } else {\n assignRef(ref, null);\n }\n}\n\nfunction applyRefs<T>(cleanupMap: CleanupMap<T>, refs: PossibleRef<T>[], node: T | null): RefCleanup<T> {\n for (const ref of refs) {\n collectCleanup(cleanupMap, ref, node);\n }\n\n if (cleanupMap.size === 0) {\n return;\n }\n\n return () => {\n for (const ref of refs) {\n cleanupRef(cleanupMap, ref);\n }\n\n cleanupMap.clear();\n };\n}\n\nfunction mergeRefs<T>(...refs: PossibleRef<T>[]): RefCallback<T> {\n const cleanupMap: CleanupMap<T> = new Map();\n\n return (node: T | null): RefCleanup<T> => applyRefs(cleanupMap, refs, node);\n}\n\nfunction useMergedRef<T>(first: PossibleRef<T>, second: PossibleRef<T>): RefCallback<T> {\n return useMemo(() => mergeRefs(first, second), [first, second]);\n}\n\nexport { assignRef, mergeRefs, useMergedRef };\n"]}
1
+ {"version":3,"file":"use-merged-refs.js","sourceRoot":"","sources":["../../src/hooks/use-merged-refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAA8B,OAAO,EAAE,MAAM,OAAO,CAAC;AAM5D,SAAS,SAAS,CAAI,GAAmB,EAAE,KAAQ;IAC/C,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;QACpC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACxB,CAAC;AACL,CAAC;AAED,SAA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EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { isRecord } from \"@gtkx/utils\";\nimport { type Ref, type RefCallback, useMemo } from \"react\";\n\ntype PossibleRef<T> = Ref<T> | undefined;\ntype RefCleanup<T> = ReturnType<RefCallback<T>>;\ntype CleanupMap<T> = Map<PossibleRef<T>, Exclude<RefCleanup<T>, void>>;\n\nfunction assignRef<T>(ref: PossibleRef<T>, value: T): RefCleanup<T> {\n if (typeof ref === \"function\") {\n return ref(value);\n }\n\n if (isRecord(ref) && \"current\" in ref) {\n ref.current = value;\n }\n}\n\nfunction collectCleanup<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>, node: T | null): void {\n const cleanup = assignRef(ref, node);\n\n if (cleanup) {\n cleanupMap.set(ref, cleanup);\n }\n}\n\nfunction cleanupRef<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>): void {\n const cleanup = cleanupMap.get(ref);\n\n if (cleanup && typeof cleanup === \"function\") {\n cleanup();\n } else {\n assignRef(ref, null);\n }\n}\n\nfunction applyRefs<T>(cleanupMap: CleanupMap<T>, refs: PossibleRef<T>[], node: T | null): RefCleanup<T> {\n for (const ref of refs) {\n collectCleanup(cleanupMap, ref, node);\n }\n\n if (cleanupMap.size === 0) {\n return;\n }\n\n return () => {\n for (const ref of refs) {\n cleanupRef(cleanupMap, ref);\n }\n\n cleanupMap.clear();\n };\n}\n\nfunction mergeRefs<T>(...refs: PossibleRef<T>[]): RefCallback<T> {\n const cleanupMap: CleanupMap<T> = new Map();\n\n return (node: T | null): RefCleanup<T> => applyRefs(cleanupMap, refs, node);\n}\n\nfunction useMergedRef<T>(first: PossibleRef<T>, second: PossibleRef<T>): RefCallback<T> {\n return useMemo(() => mergeRefs(first, second), [first, second]);\n}\n\nexport { useMergedRef };\n"]}
@@ -2,7 +2,9 @@ import type * as Gtk from "@gtkx/gi/gtk";
2
2
  import { type Context } from "react";
3
3
  declare const ParentWindowContext: Context<Gtk.Window | null>;
4
4
  /**
5
- * Returns the `Gtk.Window` provided by the nearest window ancestor, or `null` when there is none.
5
+ * Returns the `Gtk.Window` of the nearest window ancestor. This is `null` on the first render even inside a
6
+ * window, because a window provides itself only once its GObject exists, and stays `null` outside one. The
7
+ * component re-renders when it resolves, so derive from the value rather than reading it once.
6
8
  */
7
9
  declare const useParentWindow: () => Gtk.Window | null;
8
10
  export { ParentWindowContext, useParentWindow };
@@ -1 +1 @@
1
- {"version":3,"file":"use-parent-window.d.ts","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,OAAO,CAAC;AAEzD,QAAA,MAAM,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAA0C,CAAC;AAE/F;;GAEG;AACH,QAAA,MAAM,eAAe,QAAO,GAAG,CAAC,MAAM,GAAG,IAAgC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"use-parent-window.d.ts","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,OAAO,CAAC;AAEzD,QAAA,MAAM,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAA0C,CAAC;AAE/F;;;;GAIG;AACH,QAAA,MAAM,eAAe,QAAO,GAAG,CAAC,MAAM,GAAG,IAAgC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import { createContext, use } from "react";
2
2
  const ParentWindowContext = createContext(null);
3
3
  /**
4
- * Returns the `Gtk.Window` provided by the nearest window ancestor, or `null` when there is none.
4
+ * Returns the `Gtk.Window` of the nearest window ancestor. This is `null` on the first render even inside a
5
+ * window, because a window provides itself only once its GObject exists, and stays `null` outside one. The
6
+ * component re-renders when it resolves, so derive from the value rather than reading it once.
5
7
  */
6
8
  const useParentWindow = () => use(ParentWindowContext);
7
9
  export { ParentWindowContext, useParentWindow };
@@ -1 +1 @@
1
- {"version":3,"file":"use-parent-window.js","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,mBAAmB,GAA+B,aAAa,CAAoB,IAAI,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,eAAe,GAAG,GAAsB,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { type Context, createContext, use } from \"react\";\n\nconst ParentWindowContext: Context<Gtk.Window | null> = createContext<Gtk.Window | null>(null);\n\n/**\n * Returns the `Gtk.Window` provided by the nearest window ancestor, or `null` when there is none.\n */\nconst useParentWindow = (): Gtk.Window | null => use(ParentWindowContext);\n\nexport { ParentWindowContext, useParentWindow };\n"]}
1
+ {"version":3,"file":"use-parent-window.js","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,mBAAmB,GAA+B,aAAa,CAAoB,IAAI,CAAC,CAAC;AAE/F;;;;GAIG;AACH,MAAM,eAAe,GAAG,GAAsB,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { type Context, createContext, use } from \"react\";\n\nconst ParentWindowContext: Context<Gtk.Window | null> = createContext<Gtk.Window | null>(null);\n\n/**\n * Returns the `Gtk.Window` of the nearest window ancestor. This is `null` on the first render even inside a\n * window, because a window provides itself only once its GObject exists, and stays `null` outside one. The\n * component re-renders when it resolves, so derive from the value rather than reading it once.\n */\nconst useParentWindow = (): Gtk.Window | null => use(ParentWindowContext);\n\nexport { ParentWindowContext, useParentWindow };\n"]}
@@ -0,0 +1,12 @@
1
+ import { type ElementType, type ReactNode, type Ref } from "react";
2
+ type PresentedProps<T> = {
3
+ ref?: Ref<T | null> | undefined;
4
+ };
5
+ type PresentedOptions<T> = {
6
+ usePresent: () => (instance: T) => void;
7
+ dismiss: (instance: T) => void;
8
+ wrap?: (element: ReactNode, instance: T | null) => ReactNode;
9
+ };
10
+ declare const createPresentedComponent: <T>(Component: ElementType, options: PresentedOptions<T>) => ((props: PresentedProps<T>) => ReactNode);
11
+ export { createPresentedComponent, type PresentedProps };
12
+ //# sourceMappingURL=use-presented-instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-presented-instance.d.ts","sourceRoot":"","sources":["../../src/hooks/use-presented-instance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAA+C,MAAM,OAAO,CAAC;AAGhH,KAAK,cAAc,CAAC,CAAC,IAAI;IACrB,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,KAAK,gBAAgB,CAAC,CAAC,IAAI;IACvB,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/B,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,KAAK,SAAS,CAAC;CAChE,CAAC;AAyBF,QAAA,MAAM,wBAAwB,GAAI,CAAC,EAC/B,WAAW,WAAW,EACtB,SAAS,gBAAgB,CAAC,CAAC,CAAC,KAC7B,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAQ1C,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,KAAK,cAAc,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useState } from "react";
3
+ import { useMergedRef } from "./use-merged-refs.js";
4
+ const usePresentedInstance = (ref, present, dismiss) => {
5
+ const [instance, setInstance] = useState(null);
6
+ const mergedRef = useMergedRef(ref, setInstance);
7
+ useLayoutEffect(() => {
8
+ if (!instance) {
9
+ return;
10
+ }
11
+ present(instance);
12
+ return () => {
13
+ dismiss(instance);
14
+ };
15
+ }, [instance, present, dismiss]);
16
+ return [instance, mergedRef];
17
+ };
18
+ const createPresentedComponent = (Component, options) => {
19
+ return ({ ref, ...rest }) => {
20
+ const present = options.usePresent();
21
+ const [instance, mergedRef] = usePresentedInstance(ref, present, options.dismiss);
22
+ const element = _jsx(Component, { ref: mergedRef, ...rest });
23
+ return options.wrap ? options.wrap(element, instance) : element;
24
+ };
25
+ };
26
+ export { createPresentedComponent };
27
+ //# sourceMappingURL=use-presented-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-presented-instance.js","sourceRoot":"","sources":["../../src/hooks/use-presented-instance.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAYpD,MAAM,oBAAoB,GAAG,CACzB,GAA8B,EAC9B,OAA8B,EAC9B,OAA8B,EACJ,EAAE;IAC5B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAW,IAAI,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAEjD,eAAe,CAAC,GAAG,EAAE;QACjB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,OAAO;QACX,CAAC;QAED,OAAO,CAAC,QAAQ,CAAC,CAAC;QAElB,OAAO,GAAG,EAAE;YACR,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAEjC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAC7B,SAAsB,EACtB,OAA4B,EACa,EAAE;IAC3C,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,EAAqB,EAAa,EAAE;QACtD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAClF,MAAM,OAAO,GAAG,KAAC,SAAS,IAAC,GAAG,EAAE,SAAS,KAAM,IAAI,GAAI,CAAC;QAExD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACpE,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAuB,CAAC","sourcesContent":["import { type ElementType, type ReactNode, type Ref, type RefCallback, useLayoutEffect, useState } from \"react\";\nimport { useMergedRef } from \"./use-merged-refs.js\";\n\ntype PresentedProps<T> = {\n ref?: Ref<T | null> | undefined;\n};\n\ntype PresentedOptions<T> = {\n usePresent: () => (instance: T) => void;\n dismiss: (instance: T) => void;\n wrap?: (element: ReactNode, instance: T | null) => ReactNode;\n};\n\nconst usePresentedInstance = <T,>(\n ref: Ref<T | null> | undefined,\n present: (instance: T) => void,\n dismiss: (instance: T) => void,\n): [T | null, RefCallback<T>] => {\n const [instance, setInstance] = useState<T | null>(null);\n const mergedRef = useMergedRef(ref, setInstance);\n\n useLayoutEffect(() => {\n if (!instance) {\n return;\n }\n\n present(instance);\n\n return () => {\n dismiss(instance);\n };\n }, [instance, present, dismiss]);\n\n return [instance, mergedRef];\n};\n\nconst createPresentedComponent = <T,>(\n Component: ElementType,\n options: PresentedOptions<T>,\n): ((props: PresentedProps<T>) => ReactNode) => {\n return ({ ref, ...rest }: PresentedProps<T>): ReactNode => {\n const present = options.usePresent();\n const [instance, mergedRef] = usePresentedInstance(ref, present, options.dismiss);\n const element = <Component ref={mergedRef} {...rest} />;\n\n return options.wrap ? options.wrap(element, instance) : element;\n };\n};\n\nexport { createPresentedComponent, type PresentedProps };\n"]}
@@ -1,14 +1,15 @@
1
1
  import type * as GObject from "@gtkx/gi/gobject";
2
2
  import type { RefProp } from "../utils/ref-prop.js";
3
+ /** The property map `T` declares, from camelCase property name to value type. */
3
4
  type Properties<T extends GObject.Object> = NonNullable<T["__properties__"]>;
5
+ /** Every property `T` declares that is also readable off the instance, in camelCase. */
4
6
  type PropertyName<T extends GObject.Object> = keyof Properties<T> & keyof T;
5
7
  /**
6
8
  * Subscribes to a GObject property and returns its current value, re-rendering when the property changes.
7
9
  *
8
- * @param object The GObject (or ref to one) whose property to observe.
9
10
  * @param propertyName The camelCase name of a readable property on the object.
10
- * @returns The current property value, or `undefined` when the object is not resolved.
11
+ * @returns The current value, or `undefined` while the object is null or an unresolved ref.
11
12
  */
12
13
  declare function useProperty<T extends GObject.Object, P extends PropertyName<T>>(object: RefProp<T>, propertyName: P & string): T[P] | undefined;
13
- export { useProperty, type PropertyName };
14
+ export { useProperty };
14
15
  //# sourceMappingURL=use-property.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-property.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAC7E,KAAK,YAAY,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,IAAI,MAAM,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,iBAAS,WAAW,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EACpE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,YAAY,EAAE,CAAC,GAAG,MAAM,GACzB,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAElB;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"use-property.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,iFAAiF;AACjF,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAC7E,wFAAwF;AACxF,KAAK,YAAY,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,IAAI,MAAM,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EACpE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,YAAY,EAAE,CAAC,GAAG,MAAM,GACzB,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAElB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -3,9 +3,8 @@ import { useObjectValue } from "./use-object-value.js";
3
3
  /**
4
4
  * Subscribes to a GObject property and returns its current value, re-rendering when the property changes.
5
5
  *
6
- * @param object The GObject (or ref to one) whose property to observe.
7
6
  * @param propertyName The camelCase name of a readable property on the object.
8
- * @returns The current property value, or `undefined` when the object is not resolved.
7
+ * @returns The current value, or `undefined` while the object is null or an unresolved ref.
9
8
  */
10
9
  function useProperty(object, propertyName) {
11
10
  return useObjectValue(object, `notify::${kebabCase(propertyName)}`, (obj) => obj?.[propertyName]);
@@ -1 +1 @@
1
- {"version":3,"file":"use-property.js","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD;;;;;;GAMG;AACH,SAAS,WAAW,CAChB,MAAkB,EAClB,YAAwB;IAExB,OAAO,cAAc,CAAC,MAAM,EAAE,WAAW,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACtG,CAAC;AAED,OAAO,EAAE,WAAW,EAAqB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport { kebabCase } from \"@gtkx/utils\";\nimport type { RefProp } from \"../utils/ref-prop.js\";\nimport { useObjectValue } from \"./use-object-value.js\";\n\ntype Properties<T extends GObject.Object> = NonNullable<T[\"__properties__\"]>;\ntype PropertyName<T extends GObject.Object> = keyof Properties<T> & keyof T;\n\n/**\n * Subscribes to a GObject property and returns its current value, re-rendering when the property changes.\n *\n * @param object The GObject (or ref to one) whose property to observe.\n * @param propertyName The camelCase name of a readable property on the object.\n * @returns The current property value, or `undefined` when the object is not resolved.\n */\nfunction useProperty<T extends GObject.Object, P extends PropertyName<T>>(\n object: RefProp<T>,\n propertyName: P & string,\n): T[P] | undefined {\n return useObjectValue(object, `notify::${kebabCase(propertyName)}`, (obj) => obj?.[propertyName]);\n}\n\nexport { useProperty, type PropertyName };\n"]}
1
+ {"version":3,"file":"use-property.js","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAOvD;;;;;GAKG;AACH,SAAS,WAAW,CAChB,MAAkB,EAClB,YAAwB;IAExB,OAAO,cAAc,CAAC,MAAM,EAAE,WAAW,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACtG,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport { kebabCase } from \"@gtkx/utils\";\nimport type { RefProp } from \"../utils/ref-prop.js\";\nimport { useObjectValue } from \"./use-object-value.js\";\n\n/** The property map `T` declares, from camelCase property name to value type. */\ntype Properties<T extends GObject.Object> = NonNullable<T[\"__properties__\"]>;\n/** Every property `T` declares that is also readable off the instance, in camelCase. */\ntype PropertyName<T extends GObject.Object> = keyof Properties<T> & keyof T;\n\n/**\n * Subscribes to a GObject property and returns its current value, re-rendering when the property changes.\n *\n * @param propertyName The camelCase name of a readable property on the object.\n * @returns The current value, or `undefined` while the object is null or an unresolved ref.\n */\nfunction useProperty<T extends GObject.Object, P extends PropertyName<T>>(\n object: RefProp<T>,\n propertyName: P & string,\n): T[P] | undefined {\n return useObjectValue(object, `notify::${kebabCase(propertyName)}`, (obj) => obj?.[propertyName]);\n}\n\nexport { useProperty };\n"]}
@@ -5,9 +5,8 @@ declare const useSettings: <K extends SettingsSchemaKeys>({ id, path }: UseSetti
5
5
  /**
6
6
  * Reads and writes a single key of a GSettings schema, re-rendering when the stored value changes.
7
7
  *
8
- * @param schema The schema reference identifying the settings backend.
9
- * @param key The key within the schema to read and write.
10
- * @returns A tuple of the current value and a setter that persists a new value.
8
+ * @returns The current value, and a setter that writes a new one back to GSettings.
9
+ * @throws When the key is not declared in the schema.
11
10
  */
12
11
  declare function useSetting<K extends SettingsSchemaKeys, P extends keyof K>(schema: SettingsSchema<K>, key: P & string): [SettingValue<K, P>, (value: SettingValue<K, P>) => void];
13
12
  export { useSettings, useSetting };