@gtkx/components 1.0.0-rc.1 → 1.0.0-rc.2

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 (210) hide show
  1. package/dist/adw/index.d.ts +3 -0
  2. package/dist/adw/index.d.ts.map +1 -0
  3. package/dist/adw/index.js +2 -0
  4. package/dist/adw/index.js.map +1 -0
  5. package/dist/adw/toast.d.ts +10 -0
  6. package/dist/adw/toast.d.ts.map +1 -0
  7. package/dist/adw/toast.js +51 -0
  8. package/dist/adw/toast.js.map +1 -0
  9. package/dist/adw/types.d.ts +28 -0
  10. package/dist/adw/types.d.ts.map +1 -0
  11. package/dist/adw/types.js +2 -0
  12. package/dist/adw/types.js.map +1 -0
  13. package/dist/column-view.d.ts +7 -29
  14. package/dist/column-view.d.ts.map +1 -1
  15. package/dist/column-view.js +98 -70
  16. package/dist/column-view.js.map +1 -1
  17. package/dist/drop-down.d.ts +8 -27
  18. package/dist/drop-down.d.ts.map +1 -1
  19. package/dist/drop-down.js +112 -81
  20. package/dist/drop-down.js.map +1 -1
  21. package/dist/grid-view.d.ts +6 -16
  22. package/dist/grid-view.d.ts.map +1 -1
  23. package/dist/grid-view.js +25 -33
  24. package/dist/grid-view.js.map +1 -1
  25. package/dist/index.d.ts +6 -12
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -6
  28. package/dist/index.js.map +1 -1
  29. package/dist/internal/cells.d.ts +50 -0
  30. package/dist/internal/cells.d.ts.map +1 -0
  31. package/dist/internal/cells.js +185 -0
  32. package/dist/internal/cells.js.map +1 -0
  33. package/dist/internal/collection-index.d.ts +21 -0
  34. package/dist/internal/collection-index.d.ts.map +1 -0
  35. package/dist/internal/collection-index.js +106 -0
  36. package/dist/internal/collection-index.js.map +1 -0
  37. package/dist/internal/collection-model.d.ts +12 -0
  38. package/dist/internal/collection-model.d.ts.map +1 -0
  39. package/dist/internal/collection-model.js +164 -0
  40. package/dist/internal/collection-model.js.map +1 -0
  41. package/dist/internal/collection.d.ts +18 -0
  42. package/dist/internal/collection.d.ts.map +1 -0
  43. package/dist/internal/collection.js +64 -0
  44. package/dist/internal/collection.js.map +1 -0
  45. package/dist/internal/expansion.d.ts +9 -0
  46. package/dist/internal/expansion.d.ts.map +1 -0
  47. package/dist/internal/expansion.js +75 -0
  48. package/dist/internal/expansion.js.map +1 -0
  49. package/dist/internal/selection.d.ts +12 -0
  50. package/dist/internal/selection.d.ts.map +1 -0
  51. package/dist/internal/selection.js +99 -0
  52. package/dist/internal/selection.js.map +1 -0
  53. package/dist/internal/use-collection.d.ts +18 -0
  54. package/dist/internal/use-collection.d.ts.map +1 -0
  55. package/dist/internal/use-collection.js +42 -0
  56. package/dist/internal/use-collection.js.map +1 -0
  57. package/dist/internal/use-widget-ref.d.ts +4 -0
  58. package/dist/internal/use-widget-ref.d.ts.map +1 -0
  59. package/dist/internal/use-widget-ref.js +8 -0
  60. package/dist/internal/use-widget-ref.js.map +1 -0
  61. package/dist/list-view.d.ts +5 -20
  62. package/dist/list-view.d.ts.map +1 -1
  63. package/dist/list-view.js +32 -53
  64. package/dist/list-view.js.map +1 -1
  65. package/dist/size-group.d.ts +8 -16
  66. package/dist/size-group.d.ts.map +1 -1
  67. package/dist/size-group.js +35 -51
  68. package/dist/size-group.js.map +1 -1
  69. package/dist/types.d.ts +97 -24
  70. package/dist/types.d.ts.map +1 -1
  71. package/dist/types.js.map +1 -1
  72. package/package.json +17 -6
  73. package/src/adw/index.ts +2 -0
  74. package/src/adw/toast.tsx +74 -0
  75. package/src/adw/types.ts +32 -0
  76. package/src/column-view.tsx +176 -160
  77. package/src/drop-down.tsx +180 -167
  78. package/src/grid-view.tsx +29 -73
  79. package/src/index.ts +18 -25
  80. package/src/internal/cells.tsx +345 -0
  81. package/src/internal/collection-index.ts +168 -0
  82. package/src/internal/collection-model.ts +246 -0
  83. package/src/internal/collection.ts +104 -0
  84. package/src/internal/expansion.ts +123 -0
  85. package/src/internal/selection.tsx +159 -0
  86. package/src/internal/use-collection.tsx +70 -0
  87. package/src/internal/use-widget-ref.ts +11 -0
  88. package/src/list-view.tsx +43 -139
  89. package/src/size-group.tsx +63 -82
  90. package/src/types.ts +155 -24
  91. package/dist/cell.d.ts +0 -30
  92. package/dist/cell.d.ts.map +0 -1
  93. package/dist/cell.js +0 -45
  94. package/dist/cell.js.map +0 -1
  95. package/dist/column-view-column.d.ts +0 -27
  96. package/dist/column-view-column.d.ts.map +0 -1
  97. package/dist/column-view-column.js +0 -30
  98. package/dist/column-view-column.js.map +0 -1
  99. package/dist/constraint-layout-apply.d.ts +0 -55
  100. package/dist/constraint-layout-apply.d.ts.map +0 -1
  101. package/dist/constraint-layout-apply.js +0 -107
  102. package/dist/constraint-layout-apply.js.map +0 -1
  103. package/dist/constraint-layout.d.ts +0 -20
  104. package/dist/constraint-layout.d.ts.map +0 -1
  105. package/dist/constraint-layout.js +0 -88
  106. package/dist/constraint-layout.js.map +0 -1
  107. package/dist/fixed.d.ts +0 -26
  108. package/dist/fixed.d.ts.map +0 -1
  109. package/dist/fixed.js +0 -40
  110. package/dist/fixed.js.map +0 -1
  111. package/dist/grid.d.ts +0 -27
  112. package/dist/grid.d.ts.map +0 -1
  113. package/dist/grid.js +0 -48
  114. package/dist/grid.js.map +0 -1
  115. package/dist/hooks/use-cell-containers.d.ts +0 -18
  116. package/dist/hooks/use-cell-containers.d.ts.map +0 -1
  117. package/dist/hooks/use-cell-containers.js +0 -67
  118. package/dist/hooks/use-cell-containers.js.map +0 -1
  119. package/dist/hooks/use-collection-model.d.ts +0 -26
  120. package/dist/hooks/use-collection-model.d.ts.map +0 -1
  121. package/dist/hooks/use-collection-model.js +0 -35
  122. package/dist/hooks/use-collection-model.js.map +0 -1
  123. package/dist/hooks/use-collection-widget.d.ts +0 -28
  124. package/dist/hooks/use-collection-widget.d.ts.map +0 -1
  125. package/dist/hooks/use-collection-widget.js +0 -21
  126. package/dist/hooks/use-collection-widget.js.map +0 -1
  127. package/dist/hooks/use-drop-down-selection.d.ts +0 -16
  128. package/dist/hooks/use-drop-down-selection.d.ts.map +0 -1
  129. package/dist/hooks/use-drop-down-selection.js +0 -35
  130. package/dist/hooks/use-drop-down-selection.js.map +0 -1
  131. package/dist/hooks/use-expansion-model.d.ts +0 -12
  132. package/dist/hooks/use-expansion-model.d.ts.map +0 -1
  133. package/dist/hooks/use-expansion-model.js +0 -71
  134. package/dist/hooks/use-expansion-model.js.map +0 -1
  135. package/dist/hooks/use-header-menu.d.ts +0 -4
  136. package/dist/hooks/use-header-menu.d.ts.map +0 -1
  137. package/dist/hooks/use-header-menu.js +0 -20
  138. package/dist/hooks/use-header-menu.js.map +0 -1
  139. package/dist/hooks/use-installed-model.d.ts +0 -4
  140. package/dist/hooks/use-installed-model.d.ts.map +0 -1
  141. package/dist/hooks/use-installed-model.js +0 -15
  142. package/dist/hooks/use-installed-model.js.map +0 -1
  143. package/dist/hooks/use-list-model.d.ts +0 -19
  144. package/dist/hooks/use-list-model.d.ts.map +0 -1
  145. package/dist/hooks/use-list-model.js +0 -97
  146. package/dist/hooks/use-list-model.js.map +0 -1
  147. package/dist/hooks/use-placed-child.d.ts +0 -18
  148. package/dist/hooks/use-placed-child.d.ts.map +0 -1
  149. package/dist/hooks/use-placed-child.js +0 -47
  150. package/dist/hooks/use-placed-child.js.map +0 -1
  151. package/dist/hooks/use-selection-model.d.ts +0 -13
  152. package/dist/hooks/use-selection-model.d.ts.map +0 -1
  153. package/dist/hooks/use-selection-model.js +0 -103
  154. package/dist/hooks/use-selection-model.js.map +0 -1
  155. package/dist/hooks/use-sort-handler.d.ts +0 -17
  156. package/dist/hooks/use-sort-handler.d.ts.map +0 -1
  157. package/dist/hooks/use-sort-handler.js +0 -87
  158. package/dist/hooks/use-sort-handler.js.map +0 -1
  159. package/dist/menu-items.d.ts +0 -5
  160. package/dist/menu-items.d.ts.map +0 -1
  161. package/dist/menu-items.js +0 -48
  162. package/dist/menu-items.js.map +0 -1
  163. package/dist/menu.d.ts +0 -14
  164. package/dist/menu.d.ts.map +0 -1
  165. package/dist/menu.js +0 -24
  166. package/dist/menu.js.map +0 -1
  167. package/dist/overlay.d.ts +0 -24
  168. package/dist/overlay.d.ts.map +0 -1
  169. package/dist/overlay.js +0 -49
  170. package/dist/overlay.js.map +0 -1
  171. package/dist/utils/cell-container-store.d.ts +0 -28
  172. package/dist/utils/cell-container-store.d.ts.map +0 -1
  173. package/dist/utils/cell-container-store.js +0 -98
  174. package/dist/utils/cell-container-store.js.map +0 -1
  175. package/dist/utils/item-models.d.ts +0 -10
  176. package/dist/utils/item-models.d.ts.map +0 -1
  177. package/dist/utils/item-models.js +0 -82
  178. package/dist/utils/item-models.js.map +0 -1
  179. package/dist/utils/item-resolver.d.ts +0 -25
  180. package/dist/utils/item-resolver.d.ts.map +0 -1
  181. package/dist/utils/item-resolver.js +0 -102
  182. package/dist/utils/item-resolver.js.map +0 -1
  183. package/dist/utils/list-item-flatten.d.ts +0 -24
  184. package/dist/utils/list-item-flatten.d.ts.map +0 -1
  185. package/dist/utils/list-item-flatten.js +0 -68
  186. package/dist/utils/list-item-flatten.js.map +0 -1
  187. package/src/cell.tsx +0 -144
  188. package/src/column-view-column.tsx +0 -82
  189. package/src/constraint-layout-apply.ts +0 -173
  190. package/src/constraint-layout.tsx +0 -135
  191. package/src/fixed.tsx +0 -86
  192. package/src/grid.tsx +0 -88
  193. package/src/hooks/use-cell-containers.ts +0 -93
  194. package/src/hooks/use-collection-model.ts +0 -60
  195. package/src/hooks/use-collection-widget.ts +0 -47
  196. package/src/hooks/use-drop-down-selection.ts +0 -52
  197. package/src/hooks/use-expansion-model.ts +0 -82
  198. package/src/hooks/use-header-menu.ts +0 -34
  199. package/src/hooks/use-installed-model.ts +0 -20
  200. package/src/hooks/use-list-model.ts +0 -161
  201. package/src/hooks/use-placed-child.ts +0 -79
  202. package/src/hooks/use-selection-model.ts +0 -114
  203. package/src/hooks/use-sort-handler.ts +0 -107
  204. package/src/menu-items.ts +0 -48
  205. package/src/menu.tsx +0 -32
  206. package/src/overlay.tsx +0 -88
  207. package/src/utils/cell-container-store.ts +0 -114
  208. package/src/utils/item-models.ts +0 -113
  209. package/src/utils/item-resolver.ts +0 -138
  210. package/src/utils/list-item-flatten.ts +0 -90
@@ -1 +1 @@
1
- {"version":3,"file":"size-group.d.ts","sourceRoot":"","sources":["../src/size-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAGzC,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,GAAG,EAKX,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAgB7C,mCAAmC;AACnC,MAAM,MAAM,cAAc,GAAG;IACzB,oEAAoE;IACpE,IAAI,CAAC,EAAE,GAAG,CAAC,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,iGAAiG;AACjG,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,WAAW,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AAoCvE;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,CAAC,GAAG;IAC7D,KAAK,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;CAgB9E,CAAC"}
1
+ {"version":3,"file":"size-group.d.ts","sourceRoot":"","sources":["../src/size-group.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAC;AAItE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAStE,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,CAAC,GAAG;IAC/D,KAAK,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;CAC9E,CAAC;AAIF;;;GAGG;AACH,QAAA,MAAM,SAAS,EAAE,kBAA4E,CAAC;AAoD9F,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,57 +1,41 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { GtkSizeGroup } from "@gtkx/jsx/gtk";
3
- import { useMergeRefs } from "@gtkx/react/internal";
4
- import { createContext, useCallback, useContext, useRef, } from "react";
3
+ import { useMergedRef } from "@gtkx/react/internal";
4
+ import { createContext, useCallback, useContext, useState } from "react";
5
5
  const SizeGroupContext = createContext(null);
6
- const useSizeGroupRegistry = () => {
7
- const registry = useContext(SizeGroupContext);
8
- if (!registry)
6
+ const SizeGroupChild = SizeGroupChildImpl;
7
+ /**
8
+ * Creates a Gtk.SizeGroup that keeps widgets joined through `SizeGroup.Child`
9
+ * at a common size in the given mode, without contributing a widget of its own.
10
+ */
11
+ const SizeGroup = Object.assign(SizeGroupRoot, { Child: SizeGroupChild });
12
+ const useRegister = () => {
13
+ const register = useContext(SizeGroupContext);
14
+ if (register === null) {
9
15
  throw new Error("<SizeGroup.Child> must be a child of <SizeGroup>");
10
- return registry;
16
+ }
17
+ return register;
11
18
  };
12
- const SizeGroupChild = ({ component, ref, ...rest }) => {
13
- const registry = useSizeGroupRegistry();
14
- const joinGroup = useCallback((widget) => {
15
- if (widget === null)
19
+ function SizeGroupChildImpl(props) {
20
+ const { component: Component, ref, ...rest } = props;
21
+ const refCallback = useMergedRef(ref, useRegister());
22
+ return _jsx(Component, { ...rest, ref: refCallback });
23
+ }
24
+ const addWidget = (widgets, widget) => widgets.includes(widget) ? widgets : [...widgets, widget];
25
+ const removeWidget = (widgets, widget) => widgets.filter((entry) => entry !== widget);
26
+ function SizeGroupRoot(props) {
27
+ const { mode, ref, children } = props;
28
+ const [widgets, setWidgets] = useState([]);
29
+ const register = useCallback((widget) => {
30
+ if (widget === null) {
16
31
  return;
17
- registry.addWidget(widget);
18
- return () => registry.removeWidget(widget);
19
- }, [registry]);
20
- const Component = component;
21
- const setWidget = useMergeRefs(ref, joinGroup);
22
- return _jsx(Component, { ...rest, ref: setWidget });
23
- };
24
- const createRegistry = () => {
25
- const members = new Set();
26
- let group = null;
27
- return {
28
- addWidget: (widget) => {
29
- members.add(widget);
30
- group?.addWidget(widget);
31
- },
32
- removeWidget: (widget) => {
33
- members.delete(widget);
34
- group?.removeWidget(widget);
35
- },
36
- setGroup: (next) => {
37
- group = next;
38
- if (next)
39
- for (const member of members)
40
- next.addWidget(member);
41
- },
42
- };
43
- };
44
- /**
45
- * Creates a Gtk.SizeGroup that keeps its member widgets at a common size. Members join the group
46
- * through {@link SizeGroup.Child}.
47
- */
48
- export const SizeGroup = Object.assign(({ mode, ref, children }) => {
49
- const registryRef = useRef(null);
50
- if (registryRef.current === null)
51
- registryRef.current = createRegistry();
52
- const registry = registryRef.current;
53
- const setGroup = useCallback((group) => registry.setGroup(group), [registry]);
54
- const mergedRef = useMergeRefs(ref, setGroup);
55
- return (_jsxs(_Fragment, { children: [_jsx(GtkSizeGroup, { ref: mergedRef, mode: mode }), _jsx(SizeGroupContext.Provider, { value: registry, children: children })] }));
56
- }, { Child: SizeGroupChild });
32
+ }
33
+ setWidgets((previous) => addWidget(previous, widget));
34
+ return () => {
35
+ setWidgets((previous) => removeWidget(previous, widget));
36
+ };
37
+ }, [setWidgets]);
38
+ return (_jsxs(_Fragment, { children: [_jsx(GtkSizeGroup, { ref: ref, mode: mode, widgets: widgets }), _jsx(SizeGroupContext.Provider, { value: register, children: children })] }));
39
+ }
40
+ export { SizeGro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5C,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAA6B,IACnF,CACN,CAAC;AACN,CAAC,EACD,EAAE,KAAK,EAAE,cAAc,EAAE,CAC5B,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkSizeGroup } from \"@gtkx/jsx/gtk\";\nimport { useMergeRefs } from \"@gtkx/react/internal\";\nimport {\n createContext,\n type ElementType,\n type ReactNode,\n type Ref,\n type RefCallback,\n useCallback,\n useContext,\n useRef,\n} from \"react\";\nimport type { ChildProps } from \"./types.js\";\n\ntype SizeGroupRegistry = {\n addWidget: (widget: Gtk.Widget) => void;\n removeWidget: (widget: Gtk.Widget) => void;\n setGroup: (group: Gtk.SizeGroup | null) => void;\n};\n\nconst SizeGroupContext = createContext<SizeGroupRegistry | null>(null);\n\nconst useSizeGroupRegistry = (): SizeGroupRegistry => {\n const registry = useContext(SizeGroupContext);\n if (!registry) throw new Error(\"<SizeGroup.Child> must be a child of <SizeGroup>\");\n return registry;\n};\n\n/** Props for {@link SizeGroup}. */\nexport type SizeGroupProps = {\n /** How the group equalizes sizes: horizontal, vertical, or both. */\n mode?: Gtk.SizeGroupMode | null | undefined;\n ref?: Ref<Gtk.SizeGroup | null>;\n children?: ReactNode;\n};\n\n/** Adds a single widget, rendered by the given component, to the enclosing {@link SizeGroup}. */\nexport type SizeGroupChildProps<C extends ElementType> = ChildProps<C>;\n\nconst SizeGroupChild = <C extends ElementType>({ component, ref, ...rest }: SizeGroupChildProps<C>): ReactNode => {\n const registry = useSizeGroupRegistry();\n const joinGroup = useCallback<RefCallback<Gtk.Widget>>(\n (widget) => {\n if (widget === null) return;\n registry.addWidget(widget);\n return () => registry.removeWidget(widget);\n },\n [registry],\n );\n const Component: ElementType = component;\n const setWidget = useMergeRefs<Gtk.Widget>(ref, joinGroup);\n return <Component {...rest} ref={setWidget} />;\n};\n\nconst createRegistry = (): SizeGroupRegistry => {\n const members = new Set<Gtk.Widget>();\n let group: Gtk.SizeGroup | null = null;\n return {\n addWidget: (widget) => {\n members.add(widget);\n group?.addWidget(widget);\n },\n removeWidget: (widget) => {\n members.delete(widget);\n group?.removeWidget(widget);\n },\n setGroup: (next) => {\n group = next;\n if (next) for (const member of members) next.addWidget(member);\n },\n };\n};\n\n/**\n * Creates a Gtk.SizeGroup that keeps its member widgets at a common size. Members join the group\n * through {@link SizeGroup.Child}.\n */\nexport const SizeGroup: ((props: SizeGroupProps) => ReactNode) & {\n Child: <C extends ElementType>(props: SizeGroupChildProps<C>) => ReactNode;\n} = Object.assign(\n ({ mode, ref, children }: SizeGroupProps): ReactNode => {\n const registryRef = useRef<SizeGroupRegistry | null>(null);\n if (registryRef.current === null) registryRef.current = createRegistry();\n const registry = registryRef.current;\n const setGroup = useCallback<RefCallback<Gtk.SizeGroup>>((group) => registry.setGroup(group), [registry]);\n const mergedRef = useMergeRefs<Gtk.SizeGroup>(ref, setGroup);\n return (\n <>\n <GtkSizeGroup ref={mergedRef} mode={mode} />\n <SizeGroupContext.Provider value={registry}>{children}</SizeGroupContext.Provider>\n </>\n );\n },\n { Child: SizeGroupChild },\n);\n"]}
1
+ {"version":3,"file":"size-group.js","sourceRoot":"","sources":["../src/size-group.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAczE,MAAM,gBAAgB,GAAG,aAAa,CAAkB,IAAI,CAAC,CAAC;AAC9D,MAAM,cAAc,GAAG,kBAAyF,CAAC;AACjH;;;GAGG;AACH,MAAM,SAAS,GAAuB,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;AAE9F,MAAM,WAAW,GAAG,GAAa,EAAE;IA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CAAC,CAAC;QAEtD,OAAO,GAAG,EAAE;YACR,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC;IACN,CAAC,EACD,CAAC,UAAU,CAAC,CACf,CAAC;IAEF,OAAO,CACH,8BACI,KAAC,YAAY,IAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAI,EACxD,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAA6B,IACnF,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ElementType, ReactNode, Ref, RefCallback } from \"react\";\nimport { GtkSizeGroup } from \"@gtkx/jsx/gtk\";\nimport { useMergedRef } from \"@gtkx/react/internal\";\nimport { createContext, useCallback, useContext, useState } from \"react\";\nimport type { SizeGroupChildProps, SizeGroupProps } from \"./types.js\";\n\ntype Register = RefCallback<Gtk.Widget | null>;\n\ntype SizeGroupChildRuntimeProps = {\n component: ElementType;\n ref?: Ref<Gtk.Widget | null> | undefined;\n} & Record<string, unknown>;\n\ntype SizeGroupComponent = ((props: SizeGroupProps) => ReactNode) & {\n Child: <C extends ElementType>(props: SizeGroupChildProps<C>) => ReactNode;\n};\n\nconst SizeGroupContext = createContext<Register | null>(null);\nconst SizeGroupChild = SizeGroupChildImpl as <C extends ElementType>(props: SizeGroupChildProps<C>) => ReactNode;\n/**\n * Creates a Gtk.SizeGroup that keeps widgets joined through `SizeGroup.Child`\n * at a common size in the given mode, without contributing a widget of its own.\n */\nconst SizeGroup: SizeGroupComponent = Object.assign(SizeGroupRoot, { Child: SizeGroupChild });\n\nconst useRegister = (): Register => {\n const register = useContext(SizeGroupContext);\n\n if (register === null) {\n throw new Error(\"<SizeGroup.Child> must be a child of <SizeGroup>\");\n }\n\n return register;\n};\n\nfunction SizeGroupChildImpl(props: SizeGroupChildRuntimeProps): ReactNode {\n const { component: Component, ref, ...rest } = props;\n const refCallback = useMergedRef<Gtk.Widget | null>(ref, useRegister());\n\n return <Component {...rest} ref={refCallback} />;\n}\n\nconst addWidget = (widgets: Gtk.Widget[], widget: Gtk.Widget): Gtk.Widget[] =>\n widgets.includes(widget) ? widgets : [...widgets, widget];\n\nconst removeWidget = (widgets: Gtk.Widget[], widget: Gtk.Widget): Gtk.Widget[] =>\n widgets.filter((entry) => entry !== widget);\n\nfunction SizeGroupRoot(props: SizeGroupProps): ReactNode {\n const { mode, ref, children } = props;\n const [widgets, setWidgets] = useState<Gtk.Widget[]>([]);\n\n const register = useCallback<Register>(\n (widget) => {\n if (widget === null) {\n return;\n }\n\n setWidgets((previous) => addWidget(previous, widget));\n\n return () => {\n setWidgets((previous) => removeWidget(previous, widget));\n };\n },\n [setWidgets],\n );\n\n return (\n <>\n <GtkSizeGroup ref={ref} mode={mode} widgets={widgets} />\n <SizeGroupContext.Provider value={register}>{children}</SizeGroupContext.Provider>\n </>\n );\n}\n\nexport { SizeGroup };\n"]}
package/dist/types.d.ts CHANGED
@@ -1,22 +1,23 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
- import type { ComponentPropsWithRef, ElementType } from "react";
3
- /** Props of a container's Child component: the widget to render, its own props, and any placement props. */
4
- export type ChildProps<C extends ElementType, Placement = unknown> = Placement & {
2
+ import type { GtkColumnViewColumnProps, GtkColumnViewProps, GtkDropDown, GtkGridViewProps, GtkListViewProps } from "@gtkx/jsx/gtk";
3
+ import type { ComponentPropsWithRef, ElementType, ReactNode, Ref } from "react";
4
+ /** Props of a container's Child component: the widget to render and its own props. */
5
+ type ChildProps<C extends ElementType> = {
5
6
  component: C;
6
- } & Omit<ComponentPropsWithRef<C>, keyof Placement>;
7
+ } & ComponentPropsWithRef<C>;
7
8
  /** Props of a component whose backing widget defaults to one type but can be swapped through `component`. */
8
- export type WidgetProps<C extends ElementType, Own = unknown, ExtraOmit extends string = never> = Own & {
9
+ type WidgetProps<C extends ElementType, Own = unknown, ExtraOmit extends string = never> = Own & {
9
10
  component?: C;
10
11
  } & Omit<ComponentPropsWithRef<C>, ExtraOmit | keyof Own>;
11
12
  /**
12
13
  * A single item in a collection model, identified by a stable id and holding an
13
14
  * arbitrary value. Nested items form a tree.
14
15
  */
15
- export type ItemNode<T = unknown> = {
16
+ type Item<T = unknown> = {
16
17
  /** Stable identifier used to track the item across updates and selection. */
17
18
  id: string;
18
19
  value: T;
19
- children?: ItemNode<T>[] | undefined;
20
+ children?: Item<T>[] | undefined;
20
21
  /** Hides the tree expander arrow even when the item has children. */
21
22
  hideExpander?: boolean | undefined;
22
23
  /** Adds indentation matching the item's depth in the tree. */
@@ -25,15 +26,15 @@ export type ItemNode<T = unknown> = {
25
26
  indentForIcon?: boolean | undefined;
26
27
  };
27
28
  /** A group of items rendered under a shared section header. */
28
- export type SectionNode<S = unknown, T = unknown> = {
29
+ type Section<S = unknown, T = unknown> = {
29
30
  /** Stable identifier used to track the section across updates. */
30
31
  id: string;
31
32
  value: S;
32
33
  /** Items belonging to this section. */
33
- data: ItemNode<T>[];
34
+ data: Item<T>[];
34
35
  };
35
- /** Props passed to a renderItem callback when rendering one cell. */
36
- export type RenderItemProps<T> = {
36
+ /** Arguments passed to an {@link ItemRenderer} when rendering one cell. */
37
+ type RenderItemArgs<T> = {
37
38
  item: T;
38
39
  index: number;
39
40
  /** Depth of the item within a tree, starting at zero for top-level items. */
@@ -41,28 +42,100 @@ export type RenderItemProps<T> = {
41
42
  /** Whether the item is currently expanded in a tree view. */
42
43
  isExpanded?: boolean | undefined;
43
44
  };
44
- export type CollectionItemSizeProps = {
45
+ /** Arguments passed to a {@link HeaderRenderer} when rendering one section header. */
46
+ type RenderHeaderArgs<S> = {
47
+ section: S;
48
+ };
49
+ /** Renders the contents of one cell of a collection view. */
50
+ type ItemRenderer<T> = (args: RenderItemArgs<T>) => ReactNode;
51
+ /** Renders the contents of one section header of a collection view. */
52
+ type HeaderRenderer<S> = (args: RenderHeaderArgs<S>) => ReactNode;
53
+ type ItemSizeProps = {
45
54
  estimatedItemHeight?: number | undefined;
46
55
  estimatedItemWidth?: number | undefined;
47
56
  };
48
- export type ControlledSelectionProps = {
57
+ type SelectionProps = {
49
58
  selectedIds?: string[] | null | undefined;
50
59
  onSelectionChanged?: ((ids: string[]) => void) | null | undefined;
51
60
  selectionMode?: Gtk.SelectionMode | null | undefined;
52
61
  };
53
- export type ControlledExpansionProps = {
62
+ type ExpansionProps = {
54
63
  expandedIds?: string[] | null | undefined;
55
64
  onExpandedChange?: ((ids: string[]) => void) | null | undefined;
56
65
  };
57
- /** Declarative description of a single menu item, optionally nesting a submenu or section. */
58
- export type MenuEntry = {
59
- /** Text shown for the item. */
60
- label?: string | undefined;
61
- /** Action name activated when the item is chosen, for example "app.quit". */
62
- action?: string | undefined;
63
- /** Nested entries shown as a submenu opened from this item. */
64
- submenu?: MenuEntry[] | undefined;
65
- /** Nested entries grouped as a visually separated section. */
66
- section?: MenuEntry[] | undefined;
66
+ type SourceProps<T, S> = {
67
+ items?: Item<T>[] | undefined;
68
+ sections?: Section<S, T>[] | undefined;
69
+ };
70
+ /** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */
71
+ type Column<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" | "sorter" | "id" | "title"> & {
72
+ /** Stable identifier, also used to address the column through sorting props. */
73
+ id: string;
74
+ title: string;
75
+ renderCell: ItemRenderer<T>;
76
+ /** Whether clicking the column header sorts by it. */
77
+ sortable?: boolean | undefined;
78
+ headerMenu?: ReactNode;
79
+ };
80
+ type ColumnViewOwnProps<T, S> = SelectionProps & ExpansionProps & SourceProps<T, S> & Omit<ItemSizeProps, "estimatedItemWidth"> & {
81
+ columns: Column<T>[];
82
+ renderHeader?: HeaderRenderer<S> | null | undefined;
83
+ /** Id of the column the view is sorted by, making sorting controlled. */
84
+ sortColumn?: string | null | undefined;
85
+ sortOrder?: Gtk.SortType | null | undefined;
86
+ onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;
87
+ };
88
+ /**
89
+ * Props for {@link ColumnView}. Combines the underlying Gtk.ColumnView props with
90
+ * declarative collection props: flat items or grouped sections, controlled selection
91
+ * and expansion, sorting (sortColumn, sortOrder, onSortChanged), an optional section
92
+ * header renderer, and the columns to render.
93
+ */
94
+ type ColumnViewProps<T = unknown, S = unknown> = Omit<GtkColumnViewProps, "columns" | "model" | "headerFactory" | keyof ColumnViewOwnProps<T, S>> & ColumnViewOwnProps<T, S>;
95
+ type DropDownOwnProps<T, S> = SourceProps<T, S> & {
96
+ /** Id of the currently selected item, making the selection controlled. */
97
+ selectedId?: string | null | undefined;
98
+ onSelectionChanged?: ((id: string) => void) | null | undefined;
99
+ renderItem?: ItemRenderer<T> | null | undefined;
100
+ /** Renderer for items in the open popup list, falling back to renderItem when omitted. */
101
+ renderListItem?: ItemRenderer<T> | null | undefined;
102
+ /** Renderer for section headers in the popup list. */
103
+ renderHeader?: HeaderRenderer<S> | null | undefined;
104
+ };
105
+ /**
106
+ * Props for {@link DropDown}. The backing widget is chosen through the `component` prop, defaulting to
107
+ * GtkDropDown, and its own props combine with the declarative collection props.
108
+ */
109
+ type DropDownProps<T = unknown, S = unknown, C extends ElementType = typeof GtkDropDown> = WidgetProps<C, DropDownOwnProps<T, S>, "model" | "factory" | "listFactory" | "headerFactory">;
110
+ type GridViewOwnProps<T> = ItemSizeProps & SelectionProps & {
111
+ items?: Item<T>[] | undefined;
112
+ renderItem: ItemRenderer<T>;
113
+ };
114
+ /**
115
+ * Props for {@link GridView}. Combines the underlying Gtk.GridView props with
116
+ * declarative collection props: items, a per-cell renderItem, controlled selection,
117
+ * and estimated item sizing.
118
+ */
119
+ type GridViewProps<T = unknown> = Omit<GtkGridViewProps, "model" | "factory" | keyof GridViewOwnProps<T>> & GridViewOwnProps<T>;
120
+ type ListViewOwnProps<T, S> = ItemSizeProps & SelectionProps & ExpansionProps & SourceProps<T, S> & {
121
+ renderItem: ItemRenderer<T>;
122
+ renderHeader?: HeaderRenderer<S> | null | undefined;
123
+ };
124
+ /**
125
+ * Props for {@link ListView}. Combines the underlying Gtk.ListView props with
126
+ * declarative collection props: flat items or grouped sections, a per-row renderItem,
127
+ * an optional section header renderer, controlled selection and expansion, and
128
+ * estimated item sizing.
129
+ */
130
+ type ListViewProps<T = unknown, S = unknown> = Omit<GtkListViewProps, "model" | "factory" | "headerFactory" | keyof ListViewOwnProps<T, S>> & ListViewOwnProps<T, S>;
131
+ /** Props for {@link SizeGroup}. */
132
+ type SizeGroupProps = {
133
+ /** How the group equalizes sizes: horizontal, vertical, or both. */
134
+ mode?: Gtk.SizeGroupMode | null | undefined;
135
+ ref?: Ref<Gtk.SizeGroup | null>;
136
+ children?: ReactNode;
67
137
  };
138
+ /** Adds a single widget, rendered by the given component, to the enclosing {@link SizeGroup}. */
139
+ type SizeGroupChildProps<C extends ElementType> = ChildProps<C>;
140
+ export { type SelectionProps, type ExpansionProps, type ChildProps, type WidgetProps, type Item, type Section, type RenderItemArgs, type RenderHeaderArgs, type ItemRenderer, type HeaderRenderer, type Column, type ColumnViewProps, type DropDownProps, type GridViewProps, type ListViewProps, type SizeGroupProps, type SizeGroupChildProps, };
68
141
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEhE,4GAA4G;AAC5G,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,SAAS,GAAG,OAAO,IAAI,SAAS,GAAG;IAC7E,SAAS,EAAE,CAAC,CAAC;CAChB,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,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K,mBAAmB,GAC3B,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ComponentPropsWithRef, ElementType } from \"react\";\n\n/** Props of a container's Child component: the widget to render, its own props, and any placement props. */\nexport type ChildProps<C extends ElementType, Placement = unknown> = Placement & {\n component: C;\n} & Omit<ComponentPropsWithRef<C>, keyof Placement>;\n\n/** Props of a component whose backing widget defaults to one type but can be swapped through `component`. */\nexport type WidgetProps<C extends ElementType, Own = unknown, ExtraOmit extends string = never> = Own & {\n component?: C;\n} & Omit<ComponentPropsWithRef<C>, ExtraOmit | keyof Own>;\n\n/**\n * A single item in a collection model, identified by a stable id and holding an\n * arbitrary value. Nested items form a tree.\n */\nexport type ItemNode<T = unknown> = {\n /** Stable identifier used to track the item across updates and selection. */\n id: string;\n value: T;\n children?: ItemNode<T>[] | undefined;\n /** Hides the tree expander arrow even when the item has children. */\n hideExpander?: boolean | undefined;\n /** Adds indentation matching the item's depth in the tree. */\n indentForDepth?: boolean | undefined;\n /** Reserves indentation space for an expander icon. */\n indentForIcon?: boolean | undefined;\n};\n\n/** A group of items rendered under a shared section header. */\nexport type SectionNode<S = unknown, T = unknown> = {\n /** Stable identifier used to track the section across updates. */\n id: string;\n value: S;\n /** Items belonging to this section. */\n data: ItemNode<T>[];\n};\n\n/** Props passed to a renderItem callback when rendering one cell. */\nexport type RenderItemProps<T> = {\n item: T;\n index: number;\n /** Depth of the item within a tree, starting at zero for top-level items. */\n depth?: number | undefined;\n /** Whether the item is currently expanded in a tree view. */\n isExpanded?: boolean | undefined;\n};\n\nexport type CollectionItemSizeProps = {\n estimatedItemHeight?: number | undefined;\n estimatedItemWidth?: number | undefined;\n};\n\nexport type ControlledSelectionProps = {\n selectedIds?: string[] | null | undefined;\n onSelectionChanged?: ((ids: string[]) => void) | null | undefined;\n selectionMode?: Gtk.SelectionMode | null | undefined;\n};\n\nexport type ControlledExpansionProps = {\n expandedIds?: string[] | null | undefined;\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n};\n\n/** Declarative description of a single menu item, optionally nesting a submenu or section. */\nexport type MenuEntry = {\n /** Text shown for the item. */\n label?: string | undefined;\n /** Action name activated when the item is chosen, for example \"app.quit\". */\n action?: string | undefined;\n /** Nested entries shown as a submenu opened from this item. */\n submenu?: MenuEntry[] | undefined;\n /** Nested entries grouped as a visually separated section. */\n section?: MenuEntry[] | undefined;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA4LA,OAAO,EAkBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type {\n GtkColumnViewColumnProps,\n GtkColumnViewProps,\n GtkDropDown,\n GtkGridViewProps,\n GtkListViewProps,\n} from \"@gtkx/jsx/gtk\";\nimport type { ComponentPropsWithRef, ElementType, ReactNode, Ref } from \"react\";\n\n/** Props of a container's Child component: the widget to render and its own props. */\ntype ChildProps<C extends ElementType> = {\n component: C;\n} & ComponentPropsWithRef<C>;\n\n/** Props of a component whose backing widget defaults to one type but can be swapped through `component`. */\ntype WidgetProps<C extends ElementType, Own = unknown, ExtraOmit extends string = never> = Own & {\n component?: C;\n} & Omit<ComponentPropsWithRef<C>, ExtraOmit | keyof Own>;\n\n/**\n * A single item in a collection model, identified by a stable id and holding an\n * arbitrary value. Nested items form a tree.\n */\ntype Item<T = unknown> = {\n /** Stable identifier used to track the item across updates and selection. */\n id: string;\n value: T;\n children?: Item<T>[] | undefined;\n /** Hides the tree expander arrow even when the item has children. */\n hideExpander?: boolean | undefined;\n /** Adds indentation matching the item's depth in the tree. */\n indentForDepth?: boolean | undefined;\n /** Reserves indentation space for an expander icon. */\n indentForIcon?: boolean | undefined;\n};\n\n/** A group of items rendered under a shared section header. */\ntype Section<S = unknown, T = unknown> = {\n /** Stable identifier used to track the section across updates. */\n id: string;\n value: S;\n /** Items belonging to this section. */\n data: Item<T>[];\n};\n\n/** Arguments passed to an {@link ItemRenderer} when rendering one cell. */\ntype RenderItemArgs<T> = {\n item: T;\n index: number;\n /** Depth of the item within a tree, starting at zero for top-level items. */\n depth?: number | undefined;\n /** Whether the item is currently expanded in a tree view. */\n isExpanded?: boolean | undefined;\n};\n\n/** Arguments passed to a {@link HeaderRenderer} when rendering one section header. */\ntype RenderHeaderArgs<S> = {\n section: S;\n};\n\n/** Renders the contents of one cell of a collection view. */\ntype ItemRenderer<T> = (args: RenderItemArgs<T>) => ReactNode;\n/** Renders the contents of one section header of a collection view. */\ntype HeaderRenderer<S> = (args: RenderHeaderArgs<S>) => ReactNode;\n\ntype ItemSizeProps = {\n estimatedItemHeight?: number | undefined;\n estimatedItemWidth?: number | undefined;\n};\n\ntype SelectionProps = {\n selectedIds?: string[] | null | undefined;\n onSelectionChanged?: ((ids: string[]) => void) | null | undefined;\n selectionMode?: Gtk.SelectionMode | null | undefined;\n};\n\ntype ExpansionProps = {\n expandedIds?: string[] | null | undefined;\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n};\n\ntype SourceProps<T, S> = {\n items?: Item<T>[] | undefined;\n sections?: Section<S, T>[] | undefined;\n};\n\n/** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */\ntype Column<T = unknown> = Omit<GtkColumnViewColumnProps, \"factory\" | \"sorter\" | \"id\" | \"title\"> & {\n /** Stable identifier, also used to address the column through sorting props. */\n id: string;\n title: string;\n renderCell: ItemRenderer<T>;\n /** Whether clicking the column header sorts by it. */\n sortable?: boolean | undefined;\n headerMenu?: ReactNode;\n};\n\ntype ColumnViewOwnProps<T, S> = SelectionProps &\n ExpansionProps &\n SourceProps<T, S> &\n Omit<ItemSizeProps, \"estimatedItemWidth\"> & {\n columns: Column<T>[];\n renderHeader?: HeaderRenderer<S> | null | undefined;\n /** Id of the column the view is sorted by, making sorting controlled. */\n sortColumn?: string | null | undefined;\n sortOrder?: Gtk.SortType | null | undefined;\n onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;\n };\n\n/**\n * Props for {@link ColumnView}. Combines the underlying Gtk.ColumnView props with\n * declarative collection props: flat items or grouped sections, controlled selection\n * and expansion, sorting (sortColumn, sortOrder, onSortChanged), an optional section\n * header renderer, and the columns to render.\n */\ntype ColumnViewProps<T = unknown, S = unknown> = Omit<\n GtkColumnViewProps,\n \"columns\" | \"model\" | \"headerFactory\" | keyof ColumnViewOwnProps<T, S>\n> &\nColumnViewOwnProps<T, S>;\n\ntype DropDownOwnProps<T, S> = SourceProps<T, S> & {\n /** Id of the currently selected item, making the selection controlled. */\n selectedId?: string | null | undefined;\n onSelectionChanged?: ((id: string) => void) | null | undefined;\n renderItem?: ItemRenderer<T> | null | undefined;\n /** Renderer for items in the open popup list, falling back to renderItem when omitted. */\n renderListItem?: ItemRenderer<T> | null | undefined;\n /** Renderer for section headers in the popup list. */\n renderHeader?: HeaderRenderer<S> | null | undefined;\n};\n\n/**\n * Props for {@link DropDown}. The backing widget is chosen through the `component` prop, defaulting to\n * GtkDropDown, and its own props combine with the declarative collection props.\n */\ntype DropDownProps<T = unknown, S = unknown, C extends ElementType = typeof GtkDropDown> = WidgetProps<\n C,\n DropDownOwnProps<T, S>,\n \"model\" | \"factory\" | \"listFactory\" | \"headerFactory\"\n>;\n\ntype GridViewOwnProps<T> = ItemSizeProps &\n SelectionProps & {\n items?: Item<T>[] | undefined;\n renderItem: ItemRenderer<T>;\n };\n\n/**\n * Props for {@link GridView}. Combines the underlying Gtk.GridView props with\n * declarative collection props: items, a per-cell renderItem, controlled selection,\n * and estimated item sizing.\n */\ntype GridViewProps<T = unknown> = Omit<GtkGridViewProps, \"model\" | \"factory\" | keyof GridViewOwnProps<T>> &\n GridViewOwnProps<T>;\n\ntype ListViewOwnProps<T, S> = ItemSizeProps &\n SelectionProps &\n ExpansionProps &\n SourceProps<T, S> & {\n renderItem: ItemRenderer<T>;\n renderHeader?: HeaderRenderer<S> | null | undefined;\n };\n\n/**\n * Props for {@link ListView}. Combines the underlying Gtk.ListView props with\n * declarative collection props: flat items or grouped sections, a per-row renderItem,\n * an optional section header renderer, controlled selection and expansion, and\n * estimated item sizing.\n */\ntype ListViewProps<T = unknown, S = unknown> = Omit<\n GtkListViewProps,\n \"model\" | \"factory\" | \"headerFactory\" | keyof ListViewOwnProps<T, S>\n> &\nListViewOwnProps<T, S>;\n\n/** Props for {@link SizeGroup}. */\ntype SizeGroupProps = {\n /** How the group equalizes sizes: horizontal, vertical, or both. */\n mode?: Gtk.SizeGroupMode | null | undefined;\n ref?: Ref<Gtk.SizeGroup | null>;\n children?: ReactNode;\n};\n\n/** Adds a single widget, rendered by the given component, to the enclosing {@link SizeGroup}. */\ntype SizeGroupChildProps<C extends ElementType> = ChildProps<C>;\n\nexport {\n type SelectionProps,\n type ExpansionProps,\n type ChildProps,\n type WidgetProps,\n type Item,\n type Section,\n type RenderItemArgs,\n type RenderHeaderArgs,\n type ItemRenderer,\n type HeaderRenderer,\n type Column,\n type ColumnViewProps,\n type DropDownProps,\n type GridViewProps,\n type ListViewProps,\n type SizeGroupProps,\n type SizeGroupChildProps,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/components",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "High-level GTKX components for declarative collection views, menus, and containers with attach-time placement",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -29,6 +29,10 @@
29
29
  ".": {
30
30
  "types": "./dist/index.d.ts",
31
31
  "default": "./dist/index.js"
32
+ },
33
+ "./adw": {
34
+ "types": "./dist/adw/index.d.ts",
35
+ "default": "./dist/adw/index.js"
32
36
  }
33
37
  },
34
38
  "sideEffects": false,
@@ -40,15 +44,22 @@
40
44
  "node": ">=24"
41
45
  },
42
46
  "dependencies": {
43
- "@gtkx/utils": "1.0.0-rc.1",
44
- "@gtkx/react": "1.0.0-rc.1"
47
+ "@gtkx/react": "1.0.0-rc.2",
48
+ "@gtkx/utils": "1.0.0-rc.2"
45
49
  },
46
50
  "peerDependencies": {
47
- "react": "^19"
51
+ "react": "^19.2"
52
+ },
53
+ "devDependencies": {
54
+ "@codspeed/vitest-plugin": "^5.7.1",
55
+ "vitest": "^4.1.10",
56
+ "@gtkx/config": "1.0.0-rc.2",
57
+ "@gtkx/runtime": "1.0.0-rc.2",
58
+ "@gtkx/testing": "1.0.0-rc.2",
59
+ "@gtkx/vitest": "1.0.0-rc.2"
48
60
  },
49
61
  "scripts": {
50
- "build": "tsc -b tsconfig.lib.json",
51
- "typecheck": "tsc -b --emitDeclarationOnly",
62
+ "bench": "NODE_ENV=production vitest bench --run --config vitest.bench.config.ts",
52
63
  "release": "tsx ../../scripts/release-package.ts"
53
64
  }
54
65
  }
@@ -0,0 +1,2 @@
1
+ export { ToastProvider, useToast, useToastOverlay } from "./toast.js";
2
+ export type { ToastController, ToastOptions, ToastOverlayController, ToastProviderProps } from "./types.js";
@@ -0,0 +1,74 @@
1
+ import type { ReactNode, RefObject } from "react";
2
+ import * as Adw from "@gtkx/gi/adw";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import type { ToastController, ToastOptions, ToastOverlayController, ToastProviderProps } from "./types.js";
5
+
6
+ type OverlayRef = RefObject<Adw.ToastOverlay | null>;
7
+
8
+ const ToastContext = createContext<OverlayRef | null>(null);
9
+
10
+ const useOverlayRef = (): OverlayRef => {
11
+ const overlayRef = useContext(ToastContext);
12
+
13
+ if (overlayRef === null) {
14
+ throw new Error("useToast and useToastOverlay must be used within a ToastProvider");
15
+ }
16
+
17
+ return overlayRef;
18
+ };
19
+
20
+ const buildToast = (options: ToastOptions): Adw.Toast => {
21
+ const { onButtonClicked, onDismissed, ...props } = options;
22
+ const toast = new Adw.Toast(props);
23
+
24
+ if (onButtonClicked != null) {
25
+ toast.on("button-clicked", onButtonClicked);
26
+ }
27
+
28
+ if (onDismissed != null) {
29
+ toast.on("dismissed", onDismissed);
30
+ }
31
+
32
+ return toast;
33
+ };
34
+
35
+ /** Shares an Adw.ToastOverlay reference with the toast hooks in every descendant. */
36
+ function ToastProvider(props: ToastProviderProps): ReactNode {
37
+ return <ToastContext.Provider value={props.overlayRef}>{props.children}</ToastContext.Provider>;
38
+ }
39
+
40
+ /** Returns a {@link ToastController} that shows and dismisses toasts on the nearest provider's overlay. */
41
+ function useToast(): ToastController {
42
+ const overlayRef = useOverlayRef();
43
+
44
+ return useMemo<ToastController>(
45
+ () => ({
46
+ show: (options?: ToastOptions) => {
47
+ const toast = buildToast(options ?? {});
48
+ overlayRef.current?.addToast(toast);
49
+
50
+ return toast;
51
+ },
52
+ dismiss: (toast: Adw.Toast) => {
53
+ toast.dismiss();
54
+ },
55
+ }),
56
+ [overlayRef],
57
+ );
58
+ }
59
+
60
+ /** Returns a {@link ToastOverlayController} for the nearest provider's overlay as a whole. */
61
+ function useToastOverlay(): ToastOverlayController {
62
+ const overlayRef = useOverlayRef();
63
+
64
+ return useMemo<ToastOverlayController>(
65
+ () => ({
66
+ dismissAll: () => {
67
+ overlayRef.current?.dismissAll();
68
+ },
69
+ }),
70
+ [overlayRef],
71
+ );
72
+ }
73
+
74
+ export { ToastProvider, useToast, useToastOverlay };
@@ -0,0 +1,32 @@
1
+ import type * as Adw from "@gtkx/gi/adw";
2
+ import type { AdwToastProps } from "@gtkx/jsx/adw";
3
+ import type { ReactNode, RefObject } from "react";
4
+
5
+ /**
6
+ * Describes a toast raised through {@link useToast}: the construct-time properties of an
7
+ * `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.
8
+ */
9
+ type ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, "onButtonClicked" | "onDismissed">;
10
+
11
+ /** Imperative controls for individual toasts, returned by {@link useToast}. */
12
+ type ToastController = {
13
+ /** Builds a toast, shows it through the overlay, and returns it. */
14
+ show: (options?: ToastOptions) => Adw.Toast;
15
+ /** Dismisses a single toast, typically one returned by {@link ToastController.show}. */
16
+ dismiss: (toast: Adw.Toast) => void;
17
+ };
18
+
19
+ /** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */
20
+ type ToastOverlayController = {
21
+ /** Dismisses the shown toast and every queued one. */
22
+ dismissAll: () => void;
23
+ };
24
+
25
+ /** Props for {@link ToastProvider}. */
26
+ type ToastProviderProps = {
27
+ /** Ref also given to the `AdwToastOverlay` the toasts appear over. */
28
+ overlayRef: RefObject<Adw.ToastOverlay | null>;
29
+ children?: ReactNode | undefined;
30
+ };
31
+
32
+ export { type ToastOptions, type ToastController, type ToastOverlayController, type ToastProviderProps };