@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 +1 @@
1
- {"version":3,"file":"element-config.js","sourceRoot":"","sources":["../../src/adw/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,E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MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACvD,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { type ElementConfig, forTypes, internal, type ModuleExport } from \"../reconciler/registry.js\";\n\nconst CHILD_SETTER_TYPES: string[] = [\n \"AdwBin\",\n \"AdwClamp\",\n \"AdwClampScrollable\",\n \"AdwNavigationPage\",\n \"AdwSplitButton\",\n \"AdwStatusPage\",\n \"AdwTabOverview\",\n \"AdwToastOverlay\",\n \"AdwToggle\",\n];\n\nconst CONTENT_SETTER_TYPES: string[] = [\"AdwBottomSheet\", \"AdwFlap\", \"AdwOverlaySplitView\"];\nconst childrenProps = internal(\"ChildrenProps\");\nconst breakpointsProps = adw(\"AdwBreakpointsProps\");\nconst preferencesRowProps = adw(\"AdwPreferencesRowProps\");\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(CHILD_SETTER_TYPES, {\n props: childrenProps,\n omitProps: [\"child\"],\n }),\n ...forTypes(CONTENT_SETTER_TYPES, {\n props: childrenProps,\n omitProps: [\"content\"],\n }),\n AdwViewStackPage: {\n lazy: true,\n },\n AdwTabPage: {\n lazy: true,\n },\n AdwPreferencesRow: {\n props: preferencesRowProps,\n },\n AdwDialog: {\n props: breakpointsProps,\n component: adw(\"createDialogComponent\"),\n omitProps: [\"child\"],\n },\n AdwApplicationWindow: {\n props: breakpointsProps,\n omitProps: [\"content\"],\n },\n AdwWindow: {\n props: breakpointsProps,\n omitProps: [\"content\"],\n },\n AdwBreakpointBin: {\n props: breakpointsProps,\n omitProps: [\"child\"],\n },\n AdwActionRow: {\n props: preferencesRowProps,\n },\n AdwEntryRow: {\n props: preferencesRowProps,\n },\n AdwExpanderRow: {\n props: adw(\"AdwExpanderRowProps\"),\n },\n AdwNavigationSplitView: {\n props: childrenProps,\n omitProps: [\"content\"],\n },\n AdwLeaflet: {\n props: childrenProps,\n },\n AdwWrapBox: {\n props: childrenProps,\n },\n AdwCarousel: {\n props: childrenProps,\n },\n AdwPreferencesPage: {\n props: childrenProps,\n },\n AdwPreferencesDialog: {\n props: childrenProps,\n },\n AdwPreferencesWindow: {\n props: childrenProps,\n },\n AdwPreferencesGroup: {\n props: childrenProps,\n },\n AdwSqueezer: {\n props: childrenProps,\n },\n AdwTabView: {\n props: childrenProps,\n },\n AdwNavigationView: {\n props: childrenProps,\n },\n AdwViewStack: {\n props: childrenProps,\n },\n AdwToolbarView: {\n props: adw(\"AdwToolbarViewProps\"),\n omitProps: [\"content\"],\n },\n AdwHeaderBar: {\n props: internal(\"GtkHeaderBarProps\"),\n },\n AdwShortcutsDialog: {\n props: childrenProps,\n },\n AdwShortcutsSection: {\n props: childrenProps,\n },\n AdwToggleGroup: {\n props: childrenProps,\n },\n AdwAlertDialog: {\n props: adw(\"AdwAlertDialogProps\"),\n },\n};\n\nfunction adw(name: string): ModuleExport {\n return { module: \"@gtkx/react/adw\", export: name };\n}\n\nexport { CHILD_SETTER_TYPES, CONTENT_SETTER_TYPES, BUILTIN_ELEMENTS };\n"]}
1
+ {"version":3,"file":"element-config.js","sourceRoot":"","sources":["../../src/adw/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,QAAQ,EAAqB,MAAM,2BAA2B,CAAC;AAEtG,MAAM,kBAAkB,GAAa;IACjC,QAAQ;IACR,UAAU;IACV,mBAAmB;IACnB,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,WAAW;CACd,CAAC;AAEF,MAAM,oBAAoB,GAAa,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;AACjF,MAAM,aAAa,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;AAChD,MAAM,gBAAg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KAC7B;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,GAAG,CAAC,qBAAqB,CAAC;KACpC;IACD,sBAAsB,EAAE;QACpB,KAAK,EAAE,aAAa;QACpB,YAAY,EAAE,CAAC,SAAS,CAAC;KAC5B;IACD,UAAU,EAAE;QACR,KAAK,EAAE,aAAa;KACvB;IACD,WAAW,EAAE;QACT,KAAK,EAAE,aAAa;KACvB;IACD,kBAAkB,EAAE;QAChB,KAAK,EAAE,aAAa;KACvB;IACD,oBAAoB,EAAE;QAClB,KAAK,EAAE,aAAa;KACvB;IACD,mBAAmB,EAAE;QACjB,KAAK,EAAE,aAAa;KACvB;IACD,UAAU,EAAE;QACR,KAAK,EAAE,aAAa;KACvB;IACD,iBAAiB,EAAE;QACf,KAAK,EAAE,aAAa;KACvB;IACD,YAAY,EAAE;QACV,KAAK,EAAE,aAAa;KACvB;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,GAAG,CAAC,qBAAqB,CAAC;QACjC,YAAY,EAAE,CAAC,SAAS,CAAC;KAC5B;IACD,YAAY,EAAE;QACV,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC;KACvC;IACD,kBAAkB,EAAE;QAChB,KAAK,EAAE,aAAa;KACvB;IACD,mBAAmB,EAAE;QACjB,KAAK,EAAE,aAAa;KACvB;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,aAAa;KACvB;IACD,cAAc,EAAE;QACZ,KAAK,EAAE,GAAG,CAAC,qBAAqB,CAAC;QACjC,YAAY,EAAE,CAAC,YAAY,CAAC;KAC/B;CACJ,CAAC;AAEF,SAAS,GAAG,CAAC,IAAY;IACrB,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACvD,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { type ElementConfig, forTypes, internal, type ModuleExport } from \"../reconciler/registry.js\";\n\nconst CHILD_SETTER_TYPES: string[] = [\n \"AdwBin\",\n \"AdwClamp\",\n \"AdwNavigationPage\",\n \"AdwSplitButton\",\n \"AdwStatusPage\",\n \"AdwTabOverview\",\n \"AdwToastOverlay\",\n \"AdwToggle\",\n];\n\nconst CONTENT_SETTER_TYPES: string[] = [\"AdwBottomSheet\", \"AdwOverlaySplitView\"];\nconst childrenProps = internal(\"ChildrenProps\");\nconst breakpointsProps = adw(\"AdwBreakpointsProps\");\nconst preferencesRowProps = adw(\"AdwPreferencesRowProps\");\n\nconst BUILTIN_ELEMENTS: Record<string, ElementConfig> = {\n ...forTypes(CHILD_SETTER_TYPES, {\n props: childrenProps,\n omittedProps: [\"child\"],\n }),\n ...forTypes(CONTENT_SETTER_TYPES, {\n props: childrenProps,\n omittedProps: [\"content\"],\n }),\n AdwClampScrollable: {\n props: childrenProps,\n omittedProps: [\"child\"],\n },\n AdwViewStackPage: {\n isLazy: true,\n },\n AdwTabPage: {\n isLazy: true,\n },\n AdwLayout: {\n isLazy: true,\n },\n AdwSidebarSection: {\n props: childrenProps,\n },\n AdwMultiLayoutView: {\n props: adw(\"AdwMultiLayoutViewProps\"),\n },\n AdwPreferencesRow: {\n props: preferencesRowProps,\n },\n AdwDialog: {\n props: breakpointsProps,\n component: adw(\"createDialogComponent\"),\n omittedProps: [\"child\"],\n },\n AdwApplicationWindow: {\n props: breakpointsProps,\n omittedProps: [\"content\"],\n },\n AdwWindow: {\n props: breakpointsProps,\n omittedProps: [\"content\"],\n },\n AdwBreakpointBin: {\n props: breakpointsProps,\n omittedProps: [\"child\"],\n },\n AdwActionRow: {\n props: preferencesRowProps,\n },\n AdwEntryRow: {\n props: preferencesRowProps,\n },\n AdwExpanderRow: {\n props: adw(\"AdwExpanderRowProps\"),\n },\n AdwNavigationSplitView: {\n props: childrenProps,\n omittedProps: [\"content\"],\n },\n AdwWrapBox: {\n props: childrenProps,\n },\n AdwCarousel: {\n props: childrenProps,\n },\n AdwPreferencesPage: {\n props: childrenProps,\n },\n AdwPreferencesDialog: {\n props: childrenProps,\n },\n AdwPreferencesGroup: {\n props: childrenProps,\n },\n AdwTabView: {\n props: childrenProps,\n },\n AdwNavigationView: {\n props: childrenProps,\n },\n AdwViewStack: {\n props: childrenProps,\n },\n AdwToolbarView: {\n props: adw(\"AdwToolbarViewProps\"),\n omittedProps: [\"content\"],\n },\n AdwHeaderBar: {\n props: internal(\"GtkHeaderBarProps\"),\n },\n AdwShortcutsDialog: {\n props: childrenProps,\n },\n AdwShortcutsSection: {\n props: childrenProps,\n },\n AdwToggleGroup: {\n props: childrenProps,\n },\n AdwAlertDialog: {\n props: adw(\"AdwAlertDialogProps\"),\n omittedProps: [\"extraChild\"],\n },\n};\n\nfunction adw(name: string): ModuleExport {\n return { module: \"@gtkx/react/adw\", export: name };\n}\n\nexport { CHILD_SETTER_TYPES, CONTENT_SETTER_TYPES, BUILTIN_ELEMENTS };\n"]}
@@ -1,4 +1,5 @@
1
1
  import "./element-behaviors.js";
2
+ /** @internal */
2
3
  export { createDialogComponent } from "./dialog.js";
3
4
  export type * from "./prop-types.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adw/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,mBAAmB,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adw/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC,gBAAgB;AAChB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,mBAAmB,iBAAiB,CAAC"}
package/dist/adw/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  import "./element-behaviors.js";
2
+ /** @internal */
2
3
  export { createDialogComponent } from "./dialog.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adw/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import \"./element-behaviors.js\";\n\nexport { createDialogComponent } from \"./dialog.js\";\nexport type * from \"./prop-types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adw/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC,gBAAgB;AAChB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import \"./element-behaviors.js\";\n\n/** @internal */\nexport { createDialogComponent } from \"./dialog.js\";\nexport type * from \"./prop-types.js\";\n"]}
@@ -1,29 +1,60 @@
1
1
  import type * as Adw from "@gtkx/gi/adw";
2
2
  import type { ReactNode } from "react";
3
3
  import type { ChildrenProps } from "../prop-types.js";
4
+ /** One button in an `Adw.AlertDialog`'s `responses` prop. */
4
5
  type AlertDialogResponse = {
6
+ /** Name the dialog reports on `onResponse` when this button is chosen. */
5
7
  id: string;
8
+ /** Text shown on the button. */
6
9
  label: string;
10
+ /** Styling the button is given, such as suggested or destructive; defaults to the plain appearance. */
7
11
  appearance?: Adw.ResponseAppearance;
8
- enabled?: boolean;
12
+ /** Whether the button can be activated; defaults to true. */
13
+ isEnabled?: boolean;
9
14
  };
15
+ /** Props of an `Adw.AlertDialog` element. */
10
16
  type AdwAlertDialogProps = {
17
+ /** Buttons the dialog offers, added and removed as the list changes. */
11
18
  responses?: AlertDialogResponse[] | null | undefined;
12
- } & ChildrenProps;
19
+ /**
20
+ * Widget set as the dialog's extra child, shown below the `heading` and `body` and above the
21
+ * response buttons, leaving the dialog's own chrome in place.
22
+ */
23
+ children?: ReactNode;
24
+ };
25
+ /** Props of an `Adw.PreferencesRow` element. */
13
26
  type AdwPreferencesRowProps = {
27
+ /** Widgets added at the start of the row, before its title. */
14
28
  prefix?: ReactNode | null | undefined;
29
+ /** Widgets added at the end of the row. */
15
30
  suffix?: ReactNode | null | undefined;
16
31
  };
32
+ /** Props of an `Adw.ExpanderRow` element. */
17
33
  type AdwExpanderRowProps = {
34
+ /** Widgets added to the area the row reveals when it expands. */
18
35
  rows?: ReactNode | null | undefined;
19
- actions?: ReactNode | null | undefined;
20
36
  } & AdwPreferencesRowProps;
37
+ /** Props of an `Adw.ToolbarView` element, whose `children` is the content the bars surround. */
21
38
  type AdwToolbarViewProps = {
39
+ /** Widgets stacked above the content. */
22
40
  topBar?: ReactNode | null | undefined;
41
+ /** Widgets stacked below the content. */
23
42
  bottomBar?: ReactNode | null | undefined;
24
43
  } & ChildrenProps;
44
+ /** Props of an element that hosts breakpoints, such as `Adw.Window` or `Adw.BreakpointBin`. */
25
45
  type AdwBreakpointsProps = {
46
+ /** `Adw.Breakpoint` elements added to the element, each applying while its condition holds. */
26
47
  breakpoints?: ReactNode | null | undefined;
27
48
  } & ChildrenProps;
28
- export { type AlertDialogResponse, type AdwAlertDialogProps, type AdwPreferencesRowProps, type AdwExpanderRowProps, type AdwToolbarViewProps, type AdwBreakpointsProps, };
49
+ /** Props of an `Adw.MultiLayoutView` element. */
50
+ type AdwMultiLayoutViewProps = {
51
+ /** `Adw.Layout` elements added to the view, each holding the content it lays out. */
52
+ layouts?: ReactNode | null | undefined;
53
+ /**
54
+ * Widget the view places in the `Adw.LayoutSlot` whose `id` is the prop name without its `Slot`
55
+ * suffix, so `sidebarSlot` fills the slot with id `sidebar` in whichever layout is current.
56
+ */
57
+ [slot: `${string}Slot`]: ReactNode | null | undefined;
58
+ };
59
+ export { type AlertDialogResponse, type AdwAlertDialogProps, type AdwPreferencesRowProps, type AdwExpanderRowProps, type AdwToolbarViewProps, type AdwBreakpointsProps, type AdwMultiLayoutViewProps, };
29
60
  //# sourceMappingURL=prop-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../../src/adw/prop-types.ts"],"names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C;CAC5C,GAAG,aAAa,CAAC;AAElB,+FAA+F;AAC/F,KAAK,mBAAmB,GAAG;IACvB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CAC9C,GAAG,aAAa,CAAC;AAElB,iDAAiD;AACjD,KAAK,uBAAuB,GAAG;IAC3B,qFAAqF;IACrF,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,CAAC,IAAI,EAAE,GAAG,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CACzD,CAAC;AAEF,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prop-types.js","sourceRoot":"","sources":["../../src/adw/prop-types.ts"],"names":[],"mappings":"AAkCA,OAAO,EAON,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type { ReactNode } from \"react\";\nimport type { ChildrenProps } from \"../prop-types.js\";\n\ntype AlertDialogResponse = {\n id: string;\n label: string;\n appearance?: Adw.ResponseAppearance;\n enabled?: boolean;\n};\n\ntype AdwAlertDialogProps = {\n responses?: AlertDialogResponse[] | null | undefined;\n} & ChildrenProps;\n\ntype AdwPreferencesRowProps = {\n prefix?: ReactNode | null | undefined;\n suffix?: ReactNode | null | undefined;\n};\n\ntype AdwExpanderRowProps = {\n rows?: ReactNode | null | undefined;\n actions?: ReactNode | null | undefined;\n} & AdwPreferencesRowProps;\n\ntype AdwToolbarViewProps = {\n topBar?: ReactNode | null | undefined;\n bottomBar?: ReactNode | null | undefined;\n} & ChildrenProps;\n\ntype AdwBreakpointsProps = {\n breakpoints?: ReactNode | null | undefined;\n} & ChildrenProps;\n\nexport {\n type AlertDialogResponse,\n type AdwAlertDialogProps,\n type AdwPreferencesRowProps,\n type AdwExpanderRowProps,\n type AdwToolbarViewProps,\n type AdwBreakpointsProps,\n};\n"]}
1
+ {"version":3,"file":"prop-types.js","sourceRoot":"","sources":["../../src/adw/prop-types.ts"],"names":[],"mappings":"AAkEA,OAAO,EAQN,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type { ReactNode } from \"react\";\nimport type { ChildrenProps } from \"../prop-types.js\";\n\n/** One button in an `Adw.AlertDialog`'s `responses` prop. */\ntype AlertDialogResponse = {\n /** Name the dialog reports on `onResponse` when this button is chosen. */\n id: string;\n /** Text shown on the button. */\n label: string;\n /** Styling the button is given, such as suggested or destructive; defaults to the plain appearance. */\n appearance?: Adw.ResponseAppearance;\n /** Whether the button can be activated; defaults to true. */\n isEnabled?: boolean;\n};\n\n/** Props of an `Adw.AlertDialog` element. */\ntype AdwAlertDialogProps = {\n /** Buttons the dialog offers, added and removed as the list changes. */\n responses?: AlertDialogResponse[] | null | undefined;\n /**\n * Widget set as the dialog's extra child, shown below the `heading` and `body` and above the\n * response buttons, leaving the dialog's own chrome in place.\n */\n children?: ReactNode;\n};\n\n/** Props of an `Adw.PreferencesRow` element. */\ntype AdwPreferencesRowProps = {\n /** Widgets added at the start of the row, before its title. */\n prefix?: ReactNode | null | undefined;\n /** Widgets added at the end of the row. */\n suffix?: ReactNode | null | undefined;\n};\n\n/** Props of an `Adw.ExpanderRow` element. */\ntype AdwExpanderRowProps = {\n /** Widgets added to the area the row reveals when it expands. */\n rows?: ReactNode | null | undefined;\n} & AdwPreferencesRowProps;\n\n/** Props of an `Adw.ToolbarView` element, whose `children` is the content the bars surround. */\ntype AdwToolbarViewProps = {\n /** Widgets stacked above the content. */\n topBar?: ReactNode | null | undefined;\n /** Widgets stacked below the content. */\n bottomBar?: ReactNode | null | undefined;\n} & ChildrenProps;\n\n/** Props of an element that hosts breakpoints, such as `Adw.Window` or `Adw.BreakpointBin`. */\ntype AdwBreakpointsProps = {\n /** `Adw.Breakpoint` elements added to the element, each applying while its condition holds. */\n breakpoints?: ReactNode | null | undefined;\n} & ChildrenProps;\n\n/** Props of an `Adw.MultiLayoutView` element. */\ntype AdwMultiLayoutViewProps = {\n /** `Adw.Layout` elements added to the view, each holding the content it lays out. */\n layouts?: ReactNode | null | undefined;\n /**\n * Widget the view places in the `Adw.LayoutSlot` whose `id` is the prop name without its `Slot`\n * suffix, so `sidebarSlot` fills the slot with id `sidebar` in whichever layout is current.\n */\n [slot: `${string}Slot`]: ReactNode | null | undefined;\n};\n\nexport {\n type AlertDialogResponse,\n type AdwAlertDialogProps,\n type AdwPreferencesRowProps,\n type AdwExpanderRowProps,\n type AdwToolbarViewProps,\n type AdwBreakpointsProps,\n type AdwMultiLayoutViewProps,\n};\n"]}
package/dist/bootstrap.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { elements } from "virtual:gtkx-config";
2
2
  import "./element-behaviors.js";
3
3
  import { registerElements } from "./reconciler/registry.js";
4
- registerElements(elements, { prepend: true });
4
+ registerElements(elements, { isPrepended: true });
5
5
  //# sourceMappingURL=bootstrap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,gBAAgB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC","sourcesContent":["import { elements } from \"virtual:gtkx-config\";\nimport \"./element-behaviors.js\";\nimport { registerElements } from \"./reconciler/registry.js\";\n\nregisterElements(elements, { prepend: true });\n"]}
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,gBAAgB,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC","sourcesContent":["import { elements } from \"virtual:gtkx-config\";\nimport \"./element-behaviors.js\";\nimport { registerElements } from \"./reconciler/registry.js\";\n\nregisterElements(elements, { isPrepended: true });\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ElementType, ReactNode } from "react";
2
+ declare const createApplicationWindowComponent: (Component: ElementType) => ((props: unknown) => ReactNode);
3
+ /** @internal */
4
+ export { createApplicationWindowComponent };
5
+ //# sourceMappingURL=application-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-window.d.ts","sourceRoot":"","sources":["../../src/components/application-window.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKpD,QAAA,MAAM,gCAAgC,GAAI,WAAW,WAAW,KAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CACX,CAAC;AAEvF,gBAAgB;AAChB,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { useApplication } from "../hooks/use-application.js";
2
+ import { createPortaledComponent } from "./portaled.js";
3
+ import { createPresentedWindowComponent } from "./window.js";
4
+ const createApplicationWindowComponent = (Component) => createPortaledComponent(createPresentedWindowComponent(Component), useApplication);
5
+ /** @internal */
6
+ export { createApplicationWindowComponent };
7
+ //# sourceMappingURL=application-window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-window.js","sourceRoot":"","sources":["../../src/components/application-window.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,gCAAgC,GAAG,CAAC,SAAsB,EAAmC,EAAE,CACjG,uBAAuB,CAAC,8BAA8B,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,CAAC;AAEvF,gBAAgB;AAChB,OAAO,EAAE,gCAAgC,EAAE,CAAC","sourcesContent":["import type { ElementType, ReactNode } from \"react\";\nimport { useApplication } from \"../hooks/use-application.js\";\nimport { createPortaledComponent } from \"./portaled.js\";\nimport { createPresentedWindowComponent } from \"./window.js\";\n\nconst createApplicationWindowComponent = (Component: ElementType): ((props: unknown) => ReactNode) =>\n createPortaledComponent(createPresentedWindowComponent(Component), useApplication);\n\n/** @internal */\nexport { createApplicationWindowComponent };\n"]}
@@ -1,10 +1,5 @@
1
- import type * as Gtk from "@gtkx/gi/gtk";
2
- import { type ElementType, type ReactNode, type Ref } from "react";
3
- type ApplicationComponentProps = {
4
- applicationId?: string | null | undefined;
5
- children?: ReactNode | undefined;
6
- ref?: Ref<Gtk.Application | null> | undefined;
7
- };
8
- declare const createApplicationComponent: (Component: ElementType) => ((props: ApplicationComponentProps) => ReactNode);
1
+ import { type ElementType, type ReactNode } from "react";
2
+ declare const createApplicationComponent: (Component: ElementType) => ((props: unknown) => ReactNode);
3
+ /** @internal */
9
4
  export { createApplicationComponent };
10
5
  //# sourceMappingURL=application.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/components/application.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAA6B,MAAM,OAAO,CAAC;AAK9F,KAAK,yBAAyB,GAAG;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CACjD,CAAC;AA+BF,QAAA,MAAM,0BAA0B,GAC5B,WAAW,WAAW,KACvB,CAAC,CAAC,KAAK,EAAE,yBAAyB,KAAK,SAAS,CAclD,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
1
+ {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/components/application.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAuC,MAAM,OAAO,CAAC;AAgF9F,QAAA,MAAM,0BAA0B,GAAI,WAAW,WAAW,KAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAC3B,CAAC;AAEjE,gBAAgB;AAChB,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -1,23 +1,37 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { quitApplication, runApplication } from "@gtkx/runtime";
3
3
  import { pickBy } from "@gtkx/utils";
4
+ import process from "node:process";
4
5
  import { useLayoutEffect, useState } from "react";
5
6
  import { applicationId as defaultApplicationId } from "virtual:gtkx-config";
6
7
  import { ApplicationContext } from "../hooks/use-application.js";
7
8
  import { useMergedRef } from "../hooks/use-merged-refs.js";
9
+ import { createPortaledComponent } from "./portaled.js";
8
10
  const POST_ACTIVATE_PROPS = new Set(["menubar"]);
9
- const useApplicationLifecycle = (application, setActivated) => {
11
+ const commandLine = (applicationId) => [
12
+ applicationId?.split(".").at(-1) ?? "gtkx",
13
+ ...process.argv.slice(2),
14
+ ];
15
+ const startApplication = (application, setActivated, applicationId) => {
16
+ application.on("activate", () => {
17
+ setActivated(true);
18
+ });
19
+ const { exitStatus } = runApplication(application, commandLine(applicationId));
20
+ if (exitStatus !== 0) {
21
+ process.exitCode = exitStatus;
22
+ }
23
+ };
24
+ const useApplicationLifecycle = (application, setActivated, applicationId) => {
10
25
  useLayoutEffect(() => {
11
26
  if (!application) {
12
27
  return;
13
28
  }
14
- runApplication(application);
15
- setActivated(true);
29
+ startApplication(application, setActivated, applicationId);
16
30
  return () => {
17
31
  quitApplication(application);
18
32
  setActivated(false);
19
33
  };
20
- }, [application, setActivated]);
34
+ }, [application, setActivated, applicationId]);
21
35
  };
22
36
  const applicationChildren = (application, children) => {
23
37
  if (!application) {
@@ -25,15 +39,17 @@ const applicationChildren = (application, children) => {
25
39
  }
26
40
  return _jsx(ApplicationContext.Provider, { value: application, children: children });
27
41
  };
28
- const createApplicationComponent = (Component) => {
42
+ const createApplicationElement = (Component) => {
29
43
  return ({ applicationId = defaultApplicationId, children, ref, ...rest }) => {
30
44
  const [application, setApplication] = useState(null);
31
45
  const [activated, setActivated] = useState(false);
32
- useApplicationLifecycle(application, setActivated);
46
+ useApplicationLifecycle(application, setActivated, applicationId);
33
47
  const mergedRef = useMergedRef(ref, setApplication);
34
48
  const appliedProps = activated ? rest : pickBy(rest, (_value, key) => !POST_ACTIVATE_PROPS.has(key));
35
49
  return (_jsx(Component, { ref: mergedRef, applicationId: applicationId, ...appliedProps, children: activated ? applicationChildren(application, children) : null }));
36
50
  };
37
51
  };
52
+ const createApplicationComponent = (Component) => createPortaledComponent(createApplicationElement(Component));
53
+ /** @internal */
38
54
  export { createApplicationComponent };
39
55
  //# sourceMappingURL=application.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/components/application.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAA8C,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9F,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6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C,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAErG,OAAO,CACH,KAAC,SAAS,IAAC,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,KAAM,YAAY,YACpE,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,GACtD,CACf,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { quitApplication, runApplication } from \"@gtkx/runtime\";\nimport { pickBy } from \"@gtkx/utils\";\nimport { type ElementType, type ReactNode, type Ref, useLayoutEffect, useState } from \"react\";\nimport { applicationId as defaultApplicationId } from \"virtual:gtkx-config\";\nimport { ApplicationContext } from \"../hooks/use-application.js\";\nimport { useMergedRef } from \"../hooks/use-merged-refs.js\";\n\ntype ApplicationComponentProps = {\n applicationId?: string | null | undefined;\n children?: ReactNode | undefined;\n ref?: Ref<Gtk.Application | null> | undefined;\n};\n\nconst POST_ACTIVATE_PROPS = new Set([\"menubar\"]);\n\nconst useApplicationLifecycle = (\n application: Gtk.Application | null,\n setActivated: (isActivated: boolean) => void,\n): void => {\n useLayoutEffect(() => {\n if (!application) {\n return;\n }\n\n runApplication(application);\n setActivated(true);\n\n return () => {\n quitApplication(application);\n setActivated(false);\n };\n }, [application, setActivated]);\n};\n\nconst applicationChildren = (application: Gtk.Application | null, children: ReactNode): ReactNode => {\n if (!application) {\n return null;\n }\n\n return <ApplicationContext.Provider value={application}>{children}</ApplicationContext.Provider>;\n};\n\nconst createApplicationComponent = (\n Component: ElementType,\n): ((props: ApplicationComponentProps) => ReactNode) => {\n return ({ applicationId = defaultApplicationId, children, ref, ...rest }: ApplicationComponentProps): ReactNode => {\n const [application, setApplication] = useState<Gtk.Application | null>(null);\n const [activated, setActivated] = useState(false);\n useApplicationLifecycle(application, setActivated);\n const mergedRef = useMergedRef(ref, setApplication);\n const appliedProps = activated ? rest : pickBy(rest, (_value, key) => !POST_ACTIVATE_PROPS.has(key));\n\n return (\n <Component ref={mergedRef} applicationId={applicationId} {...appliedProps}>\n {activated ? applicationChildren(application, children) : null}\n </Component>\n );\n };\n};\n\nexport { createApplicationComponent };\n"]}
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/components/application.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAA8C,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9F,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAQxD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAEjD,MAAM,WAAW,GAAG,CAAC,aAA4B,EAAY,EAAE,CAAC;IAC5D,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM;IAC1C,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACrB,WAA4B,EAC5B,YAA4C,EAC5C,aAA4B,EACxB,EAAE;IACN,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAA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CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClD,uBAAuB,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACpD,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAErG,OAAO,CACH,KAAC,SAAS,IAAC,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,KAAM,YAAY,YACpE,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,GACtD,CACf,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,0BAA0B,GAAG,CAAC,SAAsB,EAAmC,EAAE,CAC3F,uBAAuB,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,CAAC;AAEjE,gBAAgB;AAChB,OAAO,EAAE,0BAA0B,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { quitApplication, runApplication } from \"@gtkx/runtime\";\nimport { pickBy } from \"@gtkx/utils\";\nimport process from \"node:process\";\nimport { type ElementType, type ReactNode, type Ref, useLayoutEffect, useState } from \"react\";\nimport { applicationId as defaultApplicationId } from \"virtual:gtkx-config\";\nimport { ApplicationContext } from \"../hooks/use-application.js\";\nimport { useMergedRef } from \"../hooks/use-merged-refs.js\";\nimport { createPortaledComponent } from \"./portaled.js\";\n\ntype ApplicationComponentProps = {\n applicationId?: string | null | undefined;\n children?: ReactNode | undefined;\n ref?: Ref<Gtk.Application | null> | undefined;\n};\n\nconst POST_ACTIVATE_PROPS = new Set([\"menubar\"]);\n\nconst commandLine = (applicationId: string | null): string[] => [\n applicationId?.split(\".\").at(-1) ?? \"gtkx\",\n ...process.argv.slice(2),\n];\n\nconst startApplication = (\n application: Gtk.Application,\n setActivated: (isActivated: boolean) => void,\n applicationId: string | null,\n): void => {\n application.on(\"activate\", () => {\n setActivated(true);\n });\n\n const { exitStatus } = runApplication(application, commandLine(applicationId));\n\n if (exitStatus !== 0) {\n process.exitCode = exitStatus;\n }\n};\n\nconst useApplicationLifecycle = (\n application: Gtk.Application | null,\n setActivated: (isActivated: boolean) => void,\n applicationId: string | null,\n): void => {\n useLayoutEffect(() => {\n if (!application) {\n return;\n }\n\n startApplication(application, setActivated, applicationId);\n\n return () => {\n quitApplication(application);\n setActivated(false);\n };\n }, [application, setActivated, applicationId]);\n};\n\nconst applicationChildren = (application: Gtk.Application | null, children: ReactNode): ReactNode => {\n if (!application) {\n return null;\n }\n\n return <ApplicationContext.Provider value={application}>{children}</ApplicationContext.Provider>;\n};\n\nconst createApplicationElement = (\n Component: ElementType,\n): ((props: ApplicationComponentProps) => ReactNode) => {\n return ({ applicationId = defaultApplicationId, children, ref, ...rest }: ApplicationComponentProps): ReactNode => {\n const [application, setApplication] = useState<Gtk.Application | null>(null);\n const [activated, setActivated] = useState(false);\n useApplicationLifecycle(application, setActivated, applicationId);\n const mergedRef = useMergedRef(ref, setApplication);\n const appliedProps = activated ? rest : pickBy(rest, (_value, key) => !POST_ACTIVATE_PROPS.has(key));\n\n return (\n <Component ref={mergedRef} applicationId={applicationId} {...appliedProps}>\n {activated ? applicationChildren(application, children) : null}\n </Component>\n );\n };\n};\n\nconst createApplicationComponent = (Component: ElementType): ((props: unknown) => ReactNode) =>\n createPortaledComponent(createApplicationElement(Component));\n\n/** @internal */\nexport { createApplicationComponent };\n"]}
@@ -1,6 +1,17 @@
1
1
  import { type ReactNode } from "react";
2
- /** The intrinsic element that carries an object-valued prop's element into its parent's named property. */
3
2
  declare const Prop = "gtkx:prop";
4
- declare const createElementComponent: (typeName: string) => ((props: unknown) => ReactNode);
3
+ /**
4
+ * Builds the component that renders the element of a GLib type, which is how the generated `@gtkx/jsx`
5
+ * store exposes every widget. Reach for it to render a type codegen does not cover, such as one
6
+ * `registerClass` created: the element name is the GType name, and the component routes each prop whose
7
+ * value is an element into that prop's slot, which a bare intrinsic element cannot do.
8
+ *
9
+ * Name the props the element takes as the type argument, since the GType name says nothing about them.
10
+ * Left out, the component takes `unknown`, which accepts no attributes at all.
11
+ *
12
+ * @param typeName GType name to render, such as `GtkButton` or the `typeName` given to `registerClass`.
13
+ * @returns A component taking that type's props.
14
+ */
15
+ declare function createElementComponent<P = unknown>(typeName: string): (props: P) => ReactNode;
5
16
  export { Prop, createElementComponent };
6
17
  //# 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,2GAA2G;AAC3G,QAAA,MAAM,IAAI,cAAc,CAAC;AAoCzB,QAAA,MAAM,sBAAsB,GACvB,UAAU,MAAM,KAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAEU,CAAC;AAEjE,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/components/element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG3G,QAAA,MAAM,IAAI,cAAc,CAAC;AA4DzB;;;;;;;;;;;GAWG;AAEH,iBAAS,sBAAsB,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,CAEtF;AAED,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,29 +1,53 @@
1
1
  import { jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { isRecord } from "@gtkx/utils";
3
3
  import { createElement, isValidElement } from "react";
4
- /** The intrinsic element that carries an object-valued prop's element into its parent's named property. */
5
4
  const Prop = "gtkx:prop";
5
+ const NO_PROP_CHILDREN = [];
6
6
  const hasElement = (value) => isValidElement(value) || (Array.isArray(value) && value.some((item) => hasElement(item)));
7
- const routeProp = (key, value, hostProps, propChildren) => {
8
- if (key !== "ref" && hasElement(value)) {
9
- propChildren.push(createElement(Prop, { propName: key, key: `${Prop}:${key}` }, value));
10
- }
11
- else {
12
- hostProps[key] = value;
7
+ const isRoutedProp = (key, value) => key !== "children" && key !== "ref" && hasElement(value);
8
+ const collectPropChildren = (record) => {
9
+ let propChildren = null;
10
+ for (const key in record) {
11
+ if (!isRoutedProp(key, record[key])) {
12
+ continue;
13
+ }
14
+ propChildren ??= [];
15
+ propChildren.push(createElement(Prop, { propName: key, key: `${Prop}:${key}` }, record[key]));
13
16
  }
17
+ return propChildren;
14
18
  };
15
- const buildElement = (typeName, record) => {
16
- const Host = typeName;
19
+ const hostPropsWithout = (record) => {
17
20
  const hostProps = {};
18
- const propChildren = [];
19
21
  for (const key in record) {
20
- if (key === "children") {
21
- continue;
22
+ if (key !== "children" && !isRoutedProp(key, record[key])) {
23
+ hostProps[key] = record[key];
22
24
  }
23
- routeProp(key, record[key], hostProps, propChildren);
24
25
  }
25
- return (_jsxs(Host, { ...hostProps, children: [propChildren, record.children] }));
26
+ return hostProps;
27
+ };
28
+ const buildElement = (typeName, record) => {
29
+ const Host = typeName;
30
+ const propChildren = collectPropChildren(record);
31
+ if (propChildren === null) {
32
+ return (_jsxs(Host, { ...record, children: [NO_PROP_CHILDREN, record.children] }));
33
+ }
34
+ return (_jsxs(Host, { ...hostPropsWithout(record), children: [propChildren, record.children] }));
26
35
  };
27
- const createElementComponent = (typeName) => (props) => buildElement(typeName, isRecord(props) ? props : {});
36
+ /**
37
+ * Builds the component that renders the element of a GLib type, which is how the generated `@gtkx/jsx`
38
+ * store exposes every widget. Reach for it to render a type codegen does not cover, such as one
39
+ * `registerClass` created: the element name is the GType name, and the component routes each prop whose
40
+ * value is an element into that prop's slot, which a bare intrinsic element cannot do.
41
+ *
42
+ * Name the props the element takes as the type argument, since the GType name says nothing about them.
43
+ * Left out, the component takes `unknown`, which accepts no attributes at all.
44
+ *
45
+ * @param typeName GType name to render, such as `GtkButton` or the `typeName` given to `registerClass`.
46
+ * @returns A component taking that type's props.
47
+ */
48
+ /* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- callers name the props */
49
+ function createElementComponent(typeName) {
50
+ return (props) => buildElement(typeName, isRecord(props) ? props : {});
51
+ }
28
52
  export { Prop, createElementComponent };
29
53
  //# sourceMappingURL=element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/components/element.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAoB,cAAc,EAAqC,MAAM,OAAO,CAAC;AAG3G,2GAA2G;AAC3G,MAAM,IAAI,GAAG,WAAW,CAAC;AAEzB,MAAM,UAAU,GAAG,CAAC,KAAc,EAAW,EAAE,CAC3C,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAa,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEvG,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,SAAgB,EAAE,YAAyB,EAAQ,EAAE;IACjG,IAAI,GAAG,KAAK,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,YAAY,CAAC,IAAI,CACb,aAAa,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,GAAG,EAAE,EAAE,EAAE,KAAkB,CAAC,CACpF,CAAC;IACN,CAAC;SAAM,CAAC;QACJ,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,MAAa,EAAgB,EAAE;IACnE,MAAM,IAAI,GAAG,QAAuB,CAAC;IACrC,MAAM,SAAS,GAAU,EAAE,CAAC;IAC5B,MAAM,YAAY,GAAgB,EAAE,CAAC;IAErC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACrB,SAAS;QACb,CAAC;QAED,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,CACH,MAAC,IAAI,OAAK,SAAS,aACd,YAAY,EACZ,MAAM,CAAC,QAAqB,IAC1B,CACV,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,sBAAsB,GACxB,CAAC,QAAgB,EAAmC,EAAE,CAClD,CAAC,KAAc,EAAa,EAAE,CAC1B,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEjE,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\n/** The intrinsic element that carries an object-valued prop's element into its parent's named property. */\nconst Prop = \"gtkx:prop\";\n\nconst hasElement = (value: unknown): boolean =>\n isValidElement(value) || (Array.isArray(value) && value.some((item: unknown) => hasElement(item)));\n\nconst routeProp = (key: string, value: unknown, hostProps: Props, propChildren: ReactNode[]): void => {\n if (key !== \"ref\" && hasElement(value)) {\n propChildren.push(\n createElement(Prop, { propName: key, key: `${Prop}:${key}` }, value as ReactNode),\n );\n } else {\n hostProps[key] = value;\n }\n};\n\nconst buildElement = (typeName: string, record: Props): ReactElement => {\n const Host = typeName as ElementType;\n const hostProps: Props = {};\n const propChildren: ReactNode[] = [];\n\n for (const key in record) {\n if (key === \"children\") {\n continue;\n }\n\n routeProp(key, record[key], hostProps, propChildren);\n }\n\n return (\n <Host {...hostProps}>\n {propChildren}\n {record.children as ReactNode}\n </Host>\n );\n};\n\nconst createElementComponent =\n (typeName: string): ((props: unknown) => ReactNode) =>\n (props: unknown): ReactNode =>\n buildElement(typeName, isRecord(props) ? props : {});\n\nexport { Prop, createElementComponent };\n"]}
1
+ {"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/components/element.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAoB,cAAc,EAAqC,MAAM,OAAO,CAAC;AAG3G,MAAM,IAAI,GAAG,WAAW,CAAC;AACzB,MAAM,gBAAgB,GAAgB,EAAE,CAAC;AAEzC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAW,EAAE,CAC3C,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAa,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEvG,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,KAAc,EAAW,EAAE,CAC1D,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AAE7D,MAAM,mBAAmB,GAAG,CAAC,MAAa,EAAsB,EAAE;IAC9D,IAAI,YAAY,GAAuB,IAAI,CAAC;IAE5C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,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AAE,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzF,CAAC;AAED,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { isRecord } from \"@gtkx/utils\";\nimport { createElement, type ElementType, isValidElement, type ReactElement, type ReactNode } from \"react\";\nimport type { Props } from \"../reconciler/registry.js\";\n\nconst Prop = \"gtkx:prop\";\nconst NO_PROP_CHILDREN: ReactNode[] = [];\n\nconst hasElement = (value: unknown): boolean =>\n isValidElement(value) || (Array.isArray(value) && value.some((item: unknown) => hasElement(item)));\n\nconst isRoutedProp = (key: string, value: unknown): boolean =>\n key !== \"children\" && key !== \"ref\" && hasElement(value);\n\nconst collectPropChildren = (record: Props): ReactNode[] | null => {\n let propChildren: ReactNode[] | null = null;\n\n for (const key in record) {\n if (!isRoutedProp(key, record[key])) {\n continue;\n }\n\n propChildren ??= [];\n\n propChildren.push(\n createElement(Prop, { propName: key, key: `${Prop}:${key}` }, record[key] as ReactNode),\n );\n }\n\n return propChildren;\n};\n\nconst hostPropsWithout = (record: Props): Props => {\n const hostProps: Props = {};\n\n for (const key in record) {\n if (key !== \"children\" && !isRoutedProp(key, record[key])) {\n hostProps[key] = record[key];\n }\n }\n\n return hostProps;\n};\n\nconst buildElement = (typeName: string, record: Props): ReactElement => {\n const Host = typeName as ElementType;\n const propChildren = collectPropChildren(record);\n\n if (propChildren === null) {\n return (\n <Host {...record}>\n {NO_PROP_CHILDREN}\n {record.children as ReactNode}\n </Host>\n );\n }\n\n return (\n <Host {...hostPropsWithout(record)}>\n {propChildren}\n {record.children as ReactNode}\n </Host>\n );\n};\n\n/**\n * Builds the component that renders the element of a GLib type, which is how the generated `@gtkx/jsx`\n * store exposes every widget. Reach for it to render a type codegen does not cover, such as one\n * `registerClass` created: the element name is the GType name, and the component routes each prop whose\n * value is an element into that prop's slot, which a bare intrinsic element cannot do.\n *\n * Name the props the element takes as the type argument, since the GType name says nothing about them.\n * Left out, the component takes `unknown`, which accepts no attributes at all.\n *\n * @param typeName GType name to render, such as `GtkButton` or the `typeName` given to `registerClass`.\n * @returns A component taking that type's props.\n */\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- callers name the props */\nfunction createElementComponent<P = unknown>(typeName: string): (props: P) => ReactNode {\n return (props: P): ReactNode => buildElement(typeName, isRecord(props) ? props : {});\n}\n\nexport { Prop, createElementComponent };\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ElementType, ReactNode } from "react";
2
+ import type { Container } from "../reconciler/host-config.js";
3
+ declare const createPortaledComponent: (Component: ElementType, useContainer?: () => Container) => ((props: unknown) => ReactNode);
4
+ export { createPortaledComponent };
5
+ //# sourceMappingURL=portaled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portaled.d.ts","sourceRoot":"","sources":["../../src/components/portaled.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAM9D,QAAA,MAAM,uBAAuB,GACxB,WAAW,WAAW,EAAE,eAAc,MAAM,SAA4B,KAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAEnB,CAAC;AAE5F,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { isRecord } from "@gtkx/utils";
3
+ import { rootElement } from "../reconciler/root-element.js";
4
+ import { createPortal } from "../reconciler/root.js";
5
+ const useRootContainer = () => rootElement;
6
+ const createPortaledComponent = (Component, useContainer = useRootContainer) => (props) => createPortal(_jsx(Component, { ...(isRecord(props) ? props : {}) }), useContainer());
7
+ export { createPortaledComponent };
8
+ //# sourceMappingURL=portaled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portaled.js","sourceRoot":"","sources":["../../src/components/portaled.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,gBAAgB,GAAG,GAAc,EAAE,CAAC,WAAW,CAAC;AAEtD,MAAM,uBAAuB,GACzB,CAAC,SAAsB,EAAE,eAAgC,gBAAgB,EAAmC,EAAE,CAC1G,CAAC,KAAc,EAAa,EAAE,CAC1B,YAAY,CAAC,KAAC,SAAS,OAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AAE5F,OAAO,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import type { ElementType, ReactNode } from \"react\";\nimport { isRecord } from \"@gtkx/utils\";\nimport type { Container } from \"../reconciler/host-config.js\";\nimport { rootElement } from \"../reconciler/root-element.js\";\nimport { createPortal } from \"../reconciler/root.js\";\n\nconst useRootContainer = (): Container => rootElement;\n\nconst createPortaledComponent =\n (Component: ElementType, useContainer: () => Container = useRootContainer): ((props: unknown) => ReactNode) =>\n (props: unknown): ReactNode =>\n createPortal(<Component {...(isRecord(props) ? props : {})} />, useContainer());\n\nexport { createPortaledComponent };\n"]}
@@ -1,8 +1,9 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
- import { type ElementType, type ReactNode, type Ref } from "react";
3
- type WindowComponentProps = {
4
- ref?: Ref<Gtk.Window | null> | undefined;
5
- };
6
- declare const createWindowComponent: (Component: ElementType) => ((props: WindowComponentProps) => ReactNode);
2
+ import { type ElementType, type ReactNode } from "react";
3
+ import { type PresentedProps } from "../hooks/use-presented-instance.js";
4
+ declare const createPresentedWindowComponent: (Component: ElementType) => ((props: PresentedProps<Gtk.Window>) => ReactNode);
5
+ declare const createWindowComponent: (Component: ElementType) => ((props: unknown) => ReactNode);
6
+ export { createPresentedWindowComponent };
7
+ /** @internal */
7
8
  export { createWindowComponent };
8
9
  //# sourceMappingURL=window.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../src/components/window.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAA6B,MAAM,OAAO,CAAC;AAK9F,KAAK,oBAAoB,GAAG;IACxB,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CAC5C,CAAC;AAcF,QAAA,MAAM,qBAAqB,GAAI,WAAW,WAAW,KAAG,CAAC,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAuBlG,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
1
+ {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../src/components/window.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAqB,KAAK,SAAS,EAAO,MAAM,OAAO,CAAC;AAEjF,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAuBnG,QAAA,MAAM,8BAA8B,GAAI,WAAW,WAAW,KAAG,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,SAAS,CAO5G,CAAC;AAWP,QAAA,MAAM,qBAAqB,GAAI,WAAW,WAAW,KAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CACS,CAAC;AAEhG,OAAO,EAAE,8BAA8B,EAAE,CAAC;AAC1C,gBAAgB;AAChB,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useLayoutEffect, useState } from "react";
3
- import { useMergedRef } from "../hooks/use-merged-refs.js";
2
+ import { use } from "react";
4
3
  import { ParentWindowContext } from "../hooks/use-parent-window.js";
4
+ import { createPresentedComponent } from "../hooks/use-presented-instance.js";
5
5
  import { applyWrite } from "../reconciler/signals.js";
6
+ import { createPortaledComponent } from "./portaled.js";
6
7
  const presentWindow = (window) => {
7
8
  applyWrite(() => {
8
9
  window.present();
@@ -13,21 +14,21 @@ const destroyWindow = (window) => {
13
14
  window.destroy();
14
15
  });
15
16
  };
16
- const createWindowComponent = (Component) => {
17
- return ({ ref, ...rest }) => {
18
- const [window, setWindow] = useState(null);
19
- const mergedRef = useMergedRef(ref, setWindow);
20
- useLayoutEffect(() => {
21
- if (!window) {
22
- return;
23
- }
24
- presentWindow(window);
25
- return () => {
26
- destroyWindow(window);
27
- };
28
- }, [window]);
29
- return (_jsx(ParentWindowContext.Provider, { value: window, children: _jsx(Component, { ref: mergedRef, ...rest }) }));
17
+ const usePresentWindow = () => presentWindow;
18
+ const createPresentedWindowComponent = (Component) => createPresentedComponent(Component, {
19
+ usePresent: usePresentWindow,
20
+ dismiss: destroyWindow,
21
+ wrap: (element, window) => (_jsx(ParentWindowContext.Provider, { value: window, children: element })),
22
+ });
23
+ const withDefaultTransientFor = (Component) => {
24
+ return (props) => {
25
+ const parent = use(ParentWindowContext);
26
+ const isDefaulted = props.transientFor === undefined && parent !== null;
27
+ return _jsx(Component, { ...(isDefaulted ? { ...props, transientFor: parent } : props) });
30
28
  };
31
29
  };
30
+ const createWindowComponent = (Component) => createPortaledComponent(withDefaultTransientFor(createPresentedWindowComponent(Component)));
31
+ export { createPresentedWindowComponent };
32
+ /** @internal */
32
33
  export { createWindowComponent };
33
34
  //# sourceMappingURL=window.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"window.js","sourceRoot":"","sources":["../../src/components/window.tsx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AAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { type ElementType, type ReactNode, type Ref, useLayoutEffect, useState } from \"react\";\nimport { useMergedRef } from \"../hooks/use-merged-refs.js\";\nimport { ParentWindowContext } from \"../hooks/use-parent-window.js\";\nimport { applyWrite } from \"../reconciler/signals.js\";\n\ntype WindowComponentProps = {\n ref?: Ref<Gtk.Window | null> | undefined;\n};\n\nconst presentWindow = (window: Gtk.Window): void => {\n applyWrite(() => {\n window.present();\n });\n};\n\nconst destroyWindow = (window: Gtk.Window): void => {\n applyWrite(() => {\n window.destroy();\n });\n};\n\nconst createWindowComponent = (Component: ElementType): ((props: WindowComponentProps) => ReactNode) => {\n return ({ ref, ...rest }: WindowComponentProps): ReactNode => {\n const [window, setWindow] = useState<Gtk.Window | null>(null);\n const mergedRef = useMergedRef(ref, setWindow);\n\n useLayoutEffect(() => {\n if (!window) {\n return;\n }\n\n presentWindow(window);\n\n return () => {\n destroyWindow(window);\n };\n }, [window]);\n\n return (\n <ParentWindowContext.Provider value={window}>\n <Component ref={mergedRef} {...rest} />\n </ParentWindowContext.Provider>\n );\n };\n};\n\nexport { createWindowComponent };\n"]}
1
+ {"version":3,"file":"window.js","sourceRoot":"","sources":["../../src/components/window.tsx"],"names":[],"mappings":";AACA,OAAO,EAAuD,GAAG,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAuB,MAAM,oCAAoC,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAOxD,MAAM,aAAa,GAAG,CAAC,MAAkB,EAAQ,EAAE;IAC/C,UAAU,CAAC,GAAG,EAAE;QACZ,MAAM,CAAC,OAAO,EAAE,CAAC;IACrB,C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\";\nimport { type ElementType, type ReactElement, type ReactNode, use } from \"react\";\nimport { ParentWindowContext } from \"../hooks/use-parent-window.js\";\nimport { createPresentedComponent, type PresentedProps } from \"../hooks/use-presented-instance.js\";\nimport { applyWrite } from \"../reconciler/signals.js\";\nimport { createPortaledComponent } from \"./portaled.js\";\n\ntype WindowComponentProps = PresentedProps<Gtk.Window> & {\n // eslint-disable-next-line gtkx/accessor-naming\n transientFor?: Gtk.Window | ReactElement | null | undefined;\n};\n\nconst presentWindow = (window: Gtk.Window): void => {\n applyWrite(() => {\n window.present();\n });\n};\n\nconst destroyWindow = (window: Gtk.Window): void => {\n applyWrite(() => {\n window.destroy();\n });\n};\n\nconst usePresentWindow = (): ((window: Gtk.Window) => void) => presentWindow;\n\nconst createPresentedWindowComponent = (Component: ElementType): ((props: PresentedProps<Gtk.Window>) => ReactNode) =>\n createPresentedComponent<Gtk.Window>(Component, {\n usePresent: usePresentWindow,\n dismiss: destroyWindow,\n wrap: (element, window) => (\n <ParentWindowContext.Provider value={window}>{element}</ParentWindowContext.Provider>\n ),\n });\n\nconst withDefaultTransientFor = (Component: ElementType): ((props: WindowComponentProps) => ReactNode) => {\n return (props: WindowComponentProps): ReactNode => {\n const parent = use(ParentWindowContext);\n const isDefaulted = props.transientFor === undefined && parent !== null;\n\n return <Component {...(isDefaulted ? { ...props, transientFor: parent } : props)} />;\n };\n};\n\nconst createWindowComponent = (Component: ElementType): ((props: unknown) => ReactNode) =>\n createPortaledComponent(withDefaultTransientFor(createPresentedWindowComponent(Component)));\n\nexport { createPresentedWindowComponent };\n/** @internal */\nexport { createWindowComponent };\n"]}
package/dist/config.d.ts CHANGED
@@ -1,4 +1,9 @@
1
+ /** @public */
2
+ export { createElementComponent } from "./components/element.js";
3
+ /** @public */
1
4
  export { BUILTIN_ELEMENTS } from "./element-config.js";
2
- export type { DetachInfo, ElementBehavior, ElementConfig, ModuleExport, PlaceInfo } from "./reconciler/registry.js";
3
- export { defineBehavior, defineElements, ELEMENTS, forTypes, internal, mergeElementConfigs, } from "./reconciler/registry.js";
5
+ /** @public */
6
+ export type { DetachInfo, ElementBehavior, ElementConfig, ModuleExport, PlaceInfo, Props, } from "./reconciler/registry.js";
7
+ /** @public */
8
+ export { defineBehavior, defineElements, ELEMENTS, mergeElementConfigs } from "./reconciler/registry.js";
4
9
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACpH,OAAO,EACH,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,mBAAmB,GACtB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,cAAc;AACd,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc;AACd,YAAY,EACR,UAAU,EACV,eAAe,EACf,aAAa,EACb,YAAY,EACZ,SAAS,EACT,KAAK,GACR,MAAM,0BAA0B,CAAC;AAClC,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/config.js CHANGED
@@ -1,3 +1,7 @@
1
+ /** @public */
2
+ export { createElementComponent } from "./components/element.js";
3
+ /** @public */
1
4
  export { BUILTIN_ELEMENTS } from "./element-config.js";
2
- export { defineBehavior, defineElements, ELEMENTS, forTypes, internal, mergeElementConfigs, } from "./reconciler/registry.js";
5
+ /** @public */
6
+ export { defineBehavior, defineElements, ELEMENTS, mergeElementConfigs } from "./reconciler/registry.js";
3
7
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EACH,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,mBAAmB,GACtB,MAAM,0BAA0B,CAAC","sourcesContent":["export { BUILTIN_ELEMENTS } from \"./element-config.js\";\nexport type { DetachInfo, ElementBehavior, ElementConfig, ModuleExport, PlaceInfo } from \"./reconciler/registry.js\";\nexport {\n defineBehavior,\n defineElements,\n ELEMENTS,\n forTypes,\n internal,\n mergeElementConfigs,\n} from \"./reconciler/registry.js\";\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,cAAc;AACd,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAUvD,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["/** @public */\nexport { createElementComponent } from \"./components/element.js\";\n/** @public */\nexport { BUILTIN_ELEMENTS } from \"./element-config.js\";\n/** @public */\nexport type {\n DetachInfo,\n ElementBehavior,\n ElementConfig,\n ModuleExport,\n PlaceInfo,\n Props,\n} from \"./reconciler/registry.js\";\n/** @public */\nexport { defineBehavior, defineElements, ELEMENTS, mergeElementConfigs } from \"./reconciler/registry.js\";\n"]}