@gtkx/components 0.21.0 → 1.0.0-rc.1

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 (185) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +173 -0
  3. package/dist/cell.d.ts +30 -0
  4. package/dist/cell.d.ts.map +1 -0
  5. package/dist/cell.js +45 -0
  6. package/dist/cell.js.map +1 -0
  7. package/dist/column-view-column.d.ts +24 -14
  8. package/dist/column-view-column.d.ts.map +1 -1
  9. package/dist/column-view-column.js +19 -40
  10. package/dist/column-view-column.js.map +1 -1
  11. package/dist/column-view.d.ts +25 -11
  12. package/dist/column-view.d.ts.map +1 -1
  13. package/dist/column-view.js +53 -83
  14. package/dist/column-view.js.map +1 -1
  15. package/dist/constraint-layout-apply.d.ts +50 -1
  16. package/dist/constraint-layout-apply.d.ts.map +1 -1
  17. package/dist/constraint-layout-apply.js.map +1 -1
  18. package/dist/constraint-layout.d.ts +8 -1
  19. package/dist/constraint-layout.d.ts.map +1 -1
  20. package/dist/constraint-layout.js +12 -9
  21. package/dist/constraint-layout.js.map +1 -1
  22. package/dist/drop-down.d.ts +26 -36
  23. package/dist/drop-down.d.ts.map +1 -1
  24. package/dist/drop-down.js +47 -87
  25. package/dist/drop-down.js.map +1 -1
  26. package/dist/fixed.d.ts +26 -0
  27. package/dist/fixed.d.ts.map +1 -0
  28. package/dist/fixed.js +40 -0
  29. package/dist/fixed.js.map +1 -0
  30. package/dist/grid-view.d.ts +13 -10
  31. package/dist/grid-view.d.ts.map +1 -1
  32. package/dist/grid-view.js +30 -16
  33. package/dist/grid-view.js.map +1 -1
  34. package/dist/grid.d.ts +27 -0
  35. package/dist/grid.d.ts.map +1 -0
  36. package/dist/grid.js +48 -0
  37. package/dist/grid.js.map +1 -0
  38. package/dist/hooks/use-cell-containers.d.ts +18 -0
  39. package/dist/hooks/use-cell-containers.d.ts.map +1 -0
  40. package/dist/hooks/{use-realized-slots.js → use-cell-containers.js} +18 -17
  41. package/dist/hooks/use-cell-containers.js.map +1 -0
  42. package/dist/hooks/use-collection-model.d.ts +26 -0
  43. package/dist/hooks/use-collection-model.d.ts.map +1 -0
  44. package/dist/hooks/use-collection-model.js +35 -0
  45. package/dist/hooks/use-collection-model.js.map +1 -0
  46. package/dist/hooks/use-collection-widget.d.ts +28 -0
  47. package/dist/hooks/use-collection-widget.d.ts.map +1 -0
  48. package/dist/hooks/use-collection-widget.js +21 -0
  49. package/dist/hooks/use-collection-widget.js.map +1 -0
  50. package/dist/hooks/use-drop-down-selection.d.ts +7 -6
  51. package/dist/hooks/use-drop-down-selection.d.ts.map +1 -1
  52. package/dist/hooks/use-drop-down-selection.js +6 -6
  53. package/dist/hooks/use-drop-down-selection.js.map +1 -1
  54. package/dist/hooks/use-expansion-model.d.ts +12 -0
  55. package/dist/hooks/use-expansion-model.d.ts.map +1 -0
  56. package/dist/hooks/use-expansion-model.js +71 -0
  57. package/dist/hooks/use-expansion-model.js.map +1 -0
  58. package/dist/hooks/use-header-menu.d.ts.map +1 -1
  59. package/dist/hooks/use-header-menu.js +12 -24
  60. package/dist/hooks/use-header-menu.js.map +1 -1
  61. package/dist/hooks/use-installed-model.d.ts +4 -0
  62. package/dist/hooks/use-installed-model.d.ts.map +1 -0
  63. package/dist/hooks/use-installed-model.js +15 -0
  64. package/dist/hooks/use-installed-model.js.map +1 -0
  65. package/dist/hooks/use-list-model.d.ts +14 -15
  66. package/dist/hooks/use-list-model.d.ts.map +1 -1
  67. package/dist/hooks/use-list-model.js +61 -34
  68. package/dist/hooks/use-list-model.js.map +1 -1
  69. package/dist/hooks/use-placed-child.d.ts +18 -0
  70. package/dist/hooks/use-placed-child.d.ts.map +1 -0
  71. package/dist/hooks/use-placed-child.js +47 -0
  72. package/dist/hooks/use-placed-child.js.map +1 -0
  73. package/dist/hooks/use-selection-model.d.ts +4 -3
  74. package/dist/hooks/use-selection-model.d.ts.map +1 -1
  75. package/dist/hooks/use-selection-model.js +8 -16
  76. package/dist/hooks/use-selection-model.js.map +1 -1
  77. package/dist/hooks/use-sort-handler.d.ts +10 -5
  78. package/dist/hooks/use-sort-handler.d.ts.map +1 -1
  79. package/dist/hooks/use-sort-handler.js +2 -2
  80. package/dist/hooks/use-sort-handler.js.map +1 -1
  81. package/dist/index.d.ts +11 -17
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +6 -13
  84. package/dist/index.js.map +1 -1
  85. package/dist/list-view.d.ts +17 -9
  86. package/dist/list-view.d.ts.map +1 -1
  87. package/dist/list-view.js +49 -24
  88. package/dist/list-view.js.map +1 -1
  89. package/dist/menu-items.d.ts.map +1 -1
  90. package/dist/menu-items.js.map +1 -1
  91. package/dist/menu.d.ts +6 -10
  92. package/dist/menu.d.ts.map +1 -1
  93. package/dist/menu.js +7 -9
  94. package/dist/menu.js.map +1 -1
  95. package/dist/overlay.d.ts +24 -0
  96. package/dist/overlay.d.ts.map +1 -0
  97. package/dist/overlay.js +49 -0
  98. package/dist/overlay.js.map +1 -0
  99. package/dist/size-group.d.ts +20 -0
  100. package/dist/size-group.d.ts.map +1 -0
  101. package/dist/size-group.js +57 -0
  102. package/dist/size-group.js.map +1 -0
  103. package/dist/types.d.ts +43 -173
  104. package/dist/types.d.ts.map +1 -1
  105. package/dist/types.js.map +1 -1
  106. package/dist/utils/{realized-slot-store.d.ts → cell-container-store.d.ts} +7 -9
  107. package/dist/utils/cell-container-store.d.ts.map +1 -0
  108. package/dist/utils/{realized-slot-store.js → cell-container-store.js} +9 -14
  109. package/dist/utils/cell-container-store.js.map +1 -0
  110. package/dist/utils/item-models.d.ts +10 -0
  111. package/dist/utils/item-models.d.ts.map +1 -0
  112. package/dist/utils/{position-only-model.js → item-models.js} +13 -14
  113. package/dist/utils/item-models.js.map +1 -0
  114. package/dist/utils/item-resolver.d.ts +14 -17
  115. package/dist/utils/item-resolver.d.ts.map +1 -1
  116. package/dist/utils/item-resolver.js +34 -43
  117. package/dist/utils/item-resolver.js.map +1 -1
  118. package/dist/utils/list-item-flatten.d.ts +16 -24
  119. package/dist/utils/list-item-flatten.d.ts.map +1 -1
  120. package/dist/utils/list-item-flatten.js +16 -36
  121. package/dist/utils/list-item-flatten.js.map +1 -1
  122. package/package.json +52 -53
  123. package/src/cell.tsx +144 -0
  124. package/src/column-view-column.tsx +57 -48
  125. package/src/column-view.tsx +130 -146
  126. package/src/constraint-layout-apply.ts +53 -1
  127. package/src/constraint-layout.tsx +18 -13
  128. package/src/drop-down.tsx +129 -196
  129. package/src/fixed.tsx +86 -0
  130. package/src/grid-view.tsx +52 -44
  131. package/src/grid.tsx +88 -0
  132. package/src/hooks/{use-realized-slots.ts → use-cell-containers.ts} +30 -30
  133. package/src/hooks/use-collection-model.ts +60 -0
  134. package/src/hooks/use-collection-widget.ts +47 -0
  135. package/src/hooks/use-drop-down-selection.ts +12 -13
  136. package/src/hooks/use-expansion-model.ts +82 -0
  137. package/src/hooks/use-header-menu.ts +24 -23
  138. package/src/hooks/use-installed-model.ts +20 -0
  139. package/src/hooks/use-list-model.ts +103 -87
  140. package/src/hooks/use-placed-child.ts +79 -0
  141. package/src/hooks/use-selection-model.ts +11 -18
  142. package/src/hooks/use-sort-handler.ts +13 -8
  143. package/src/index.ts +25 -27
  144. package/src/list-view.tsx +120 -57
  145. package/src/menu.tsx +12 -14
  146. package/src/overlay.tsx +88 -0
  147. package/src/size-group.tsx +96 -0
  148. package/src/types.ts +55 -206
  149. package/src/utils/{realized-slot-store.ts → cell-container-store.ts} +13 -25
  150. package/src/utils/{position-only-model.ts → item-models.ts} +26 -28
  151. package/src/utils/item-resolver.ts +54 -59
  152. package/src/utils/list-item-flatten.ts +33 -56
  153. package/dist/collection-view.d.ts +0 -30
  154. package/dist/collection-view.d.ts.map +0 -1
  155. package/dist/collection-view.js +0 -52
  156. package/dist/collection-view.js.map +0 -1
  157. package/dist/contexts/column-view-context.d.ts +0 -17
  158. package/dist/contexts/column-view-context.d.ts.map +0 -1
  159. package/dist/contexts/column-view-context.js +0 -10
  160. package/dist/contexts/column-view-context.js.map +0 -1
  161. package/dist/hooks/use-model-installation.d.ts +0 -9
  162. package/dist/hooks/use-model-installation.d.ts.map +0 -1
  163. package/dist/hooks/use-model-installation.js +0 -20
  164. package/dist/hooks/use-model-installation.js.map +0 -1
  165. package/dist/hooks/use-realized-slots.d.ts +0 -20
  166. package/dist/hooks/use-realized-slots.d.ts.map +0 -1
  167. package/dist/hooks/use-realized-slots.js.map +0 -1
  168. package/dist/list-portal-host.d.ts +0 -11
  169. package/dist/list-portal-host.d.ts.map +0 -1
  170. package/dist/list-portal-host.js +0 -8
  171. package/dist/list-portal-host.js.map +0 -1
  172. package/dist/list-slot.d.ts +0 -14
  173. package/dist/list-slot.d.ts.map +0 -1
  174. package/dist/list-slot.js +0 -29
  175. package/dist/list-slot.js.map +0 -1
  176. package/dist/utils/position-only-model.d.ts +0 -10
  177. package/dist/utils/position-only-model.d.ts.map +0 -1
  178. package/dist/utils/position-only-model.js.map +0 -1
  179. package/dist/utils/realized-slot-store.d.ts.map +0 -1
  180. package/dist/utils/realized-slot-store.js.map +0 -1
  181. package/src/collection-view.tsx +0 -125
  182. package/src/contexts/column-view-context.ts +0 -28
  183. package/src/hooks/use-model-installation.ts +0 -25
  184. package/src/list-portal-host.tsx +0 -27
  185. package/src/list-slot.tsx +0 -56
package/dist/types.d.ts CHANGED
@@ -1,198 +1,68 @@
1
- import type * as Gio from "@gtkx/gi/gio";
2
- import type * as GObject from "@gtkx/gi/gobject";
3
1
  import type * as Gtk from "@gtkx/gi/gtk";
4
- import type { ReactNode } from "react";
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 & {
5
+ component: C;
6
+ } & Omit<ComponentPropsWithRef<C>, keyof Placement>;
7
+ /** 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
+ component?: C;
10
+ } & Omit<ComponentPropsWithRef<C>, ExtraOmit | keyof Own>;
5
11
  /**
6
- * A declarative item rendered by the {@link ListView}, {@link GridView},
7
- * {@link ColumnView}, and {@link DropDown} components.
8
- *
9
- * A non-section item carries an arbitrary value of type `T` and may declare
10
- * tree `children`. A section item carries a value of type `S` and groups a list
11
- * of child items underneath a header.
12
+ * A single item in a collection model, identified by a stable id and holding an
13
+ * arbitrary value. Nested items form a tree.
12
14
  */
13
- export type ListItem<T = unknown, S = unknown> = {
15
+ export type ItemNode<T = unknown> = {
16
+ /** Stable identifier used to track the item across updates and selection. */
14
17
  id: string;
15
18
  value: T;
16
- section?: false | undefined;
17
- children?: ListItem<T, S>[] | undefined;
19
+ children?: ItemNode<T>[] | undefined;
20
+ /** Hides the tree expander arrow even when the item has children. */
18
21
  hideExpander?: boolean | undefined;
22
+ /** Adds indentation matching the item's depth in the tree. */
19
23
  indentForDepth?: boolean | undefined;
24
+ /** Reserves indentation space for an expander icon. */
20
25
  indentForIcon?: boolean | undefined;
21
- } | {
26
+ };
27
+ /** A group of items rendered under a shared section header. */
28
+ export type SectionNode<S = unknown, T = unknown> = {
29
+ /** Stable identifier used to track the section across updates. */
22
30
  id: string;
23
31
  value: S;
24
- section: true;
25
- children: ListItem<T, S>[];
32
+ /** Items belonging to this section. */
33
+ data: ItemNode<T>[];
34
+ };
35
+ /** Props passed to a renderItem callback when rendering one cell. */
36
+ export type RenderItemProps<T> = {
37
+ item: T;
38
+ index: number;
39
+ /** Depth of the item within a tree, starting at zero for top-level items. */
40
+ depth?: number | undefined;
41
+ /** Whether the item is currently expanded in a tree view. */
42
+ isExpanded?: boolean | undefined;
26
43
  };
27
- type ListViewSharedProps = {
44
+ export type CollectionItemSizeProps = {
28
45
  estimatedItemHeight?: number | undefined;
29
46
  estimatedItemWidth?: number | undefined;
30
47
  };
31
- type ListViewControlledSelectionProps = {
32
- selected?: string[] | null | undefined;
48
+ export type ControlledSelectionProps = {
49
+ selectedIds?: string[] | null | undefined;
33
50
  onSelectionChanged?: ((ids: string[]) => void) | null | undefined;
34
51
  selectionMode?: Gtk.SelectionMode | null | undefined;
35
52
  };
36
- type UncontrolledItemType<T> = [T] extends [GObject.Object] ? T : GObject.Object;
37
- /**
38
- * Props for the {@link ListView} component, replacing the raw `GtkListView`
39
- * factory/model surface with a declarative `items`/`renderItem` API, optional
40
- * controlled selection, section headers, and tree autoexpansion. Supplying an
41
- * external `model` switches to the uncontrolled form.
42
- */
43
- export type ListViewProps<T = unknown, S = unknown> = ListViewSharedProps & ((ListViewControlledSelectionProps & {
44
- items?: ListItem<T, S>[] | undefined;
45
- renderItem: (item: T, row?: Gtk.TreeListRow | null) => ReactNode;
46
- autoexpand?: boolean | undefined;
47
- renderHeader?: ((item: S) => ReactNode) | null | undefined;
48
- model?: never;
49
- }) | {
50
- model: Gio.ListModel;
51
- renderItem: (item: UncontrolledItemType<T>) => ReactNode;
52
- items?: never;
53
- autoexpand?: never;
54
- renderHeader?: never;
55
- selected?: never;
56
- onSelectionChanged?: never;
57
- selectionMode?: never;
58
- });
59
- /**
60
- * Props for the {@link GridView} component, replacing the raw `GtkGridView`
61
- * factory/model surface with a declarative `items`/`renderItem` API and
62
- * optional controlled selection. Supplying an external `model` switches to the
63
- * uncontrolled form.
64
- */
65
- export type GridViewProps<T = unknown> = ListViewSharedProps & ((ListViewControlledSelectionProps & {
66
- items?: ListItem<T>[] | undefined;
67
- renderItem: (item: T) => ReactNode;
68
- model?: never;
69
- }) | {
70
- model: Gio.ListModel;
71
- renderItem: (item: UncontrolledItemType<T>) => ReactNode;
72
- items?: never;
73
- selected?: never;
74
- onSelectionChanged?: never;
75
- selectionMode?: never;
76
- });
77
- type ColumnViewSortProps = {
78
- sortColumn?: string | null | undefined;
79
- sortOrder?: Gtk.SortType | null | undefined;
80
- onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;
81
- estimatedRowHeight?: number | null | undefined;
82
- };
83
- /**
84
- * Props for the {@link ColumnView} component, replacing the raw `GtkColumnView`
85
- * surface with a declarative `items` model, optional controlled selection,
86
- * controlled sorting, and section headers. Columns are declared as
87
- * {@link ColumnViewColumn} children. Supplying an external `model` switches to
88
- * the uncontrolled form.
89
- */
90
- export type ColumnViewProps<T = unknown, S = unknown> = ColumnViewSortProps & ((ListViewControlledSelectionProps & {
91
- items?: ListItem<T, S>[] | undefined;
92
- renderHeader?: ((item: S) => ReactNode) | null | undefined;
93
- model?: never;
94
- }) | {
95
- model: Gio.ListModel;
96
- items?: never;
97
- renderHeader?: never;
98
- selected?: never;
99
- onSelectionChanged?: never;
100
- selectionMode?: never;
101
- });
102
- /**
103
- * Props for a single {@link ColumnViewColumn} of a {@link ColumnView},
104
- * replacing the raw `GtkColumnViewColumn` factory/sorter surface with a
105
- * declarative `renderCell` callback and an optional header context menu.
106
- */
107
- export type ColumnViewColumnProps<T = unknown> = {
108
- title: string;
109
- expand?: boolean | undefined;
110
- resizable?: boolean | undefined;
111
- fixedWidth?: number | undefined;
112
- id: string;
113
- sortable?: boolean | undefined;
114
- visible?: boolean | undefined;
115
- renderCell: (item: T) => ReactNode;
116
- headerMenu?: ReactNode;
117
- };
118
- /**
119
- * Props shared by the {@link DropDown} and {@link ComboRow} components,
120
- * replacing the raw factory/model surface with declarative `items`, controlled
121
- * `selectedId`, and per-slot renderers for the selected face, the popup list,
122
- * and section headers. Supplying an external `model` switches to the
123
- * uncontrolled form.
124
- */
125
- export type DropDownProps<T = unknown, S = unknown> = {
126
- items?: ListItem<T, S>[] | undefined;
127
- selectedId?: string | null | undefined;
128
- onSelectionChanged?: ((id: string) => void) | null | undefined;
129
- renderItem?: ((item: T) => ReactNode) | null | undefined;
130
- renderListItem?: ((item: T) => ReactNode) | null | undefined;
131
- renderHeader?: ((item: S) => ReactNode) | null | undefined;
132
- model?: never;
133
- } | {
134
- model: Gio.ListModel;
135
- renderItem?: ((item: UncontrolledItemType<T>) => ReactNode) | null | undefined;
136
- renderListItem?: ((item: UncontrolledItemType<T>) => ReactNode) | null | undefined;
137
- items?: never;
138
- selectedId?: never;
139
- onSelectionChanged?: never;
140
- renderHeader?: never;
53
+ export type ControlledExpansionProps = {
54
+ expandedIds?: string[] | null | undefined;
55
+ onExpandedChange?: ((ids: string[]) => void) | null | undefined;
141
56
  };
142
- /**
143
- * A single declarative entry in a {@link Menu} model. An entry is a plain item
144
- * (`label` plus `action`), a `submenu`, or a `section` of nested entries.
145
- */
57
+ /** Declarative description of a single menu item, optionally nesting a submenu or section. */
146
58
  export type MenuEntry = {
59
+ /** Text shown for the item. */
147
60
  label?: string | undefined;
61
+ /** Action name activated when the item is chosen, for example "app.quit". */
148
62
  action?: string | undefined;
63
+ /** Nested entries shown as a submenu opened from this item. */
149
64
  submenu?: MenuEntry[] | undefined;
65
+ /** Nested entries grouped as a visually separated section. */
150
66
  section?: MenuEntry[] | undefined;
151
67
  };
152
- /**
153
- * The declarative menu-model surface added by the {@link Menu} component on top
154
- * of the raw `GMenu` element.
155
- */
156
- export type MenuItemsProps = {
157
- items?: MenuEntry[] | null | undefined;
158
- };
159
- /**
160
- * Props for a `<ConstraintLayout.Constraint>` declaring a single relation
161
- * between a target attribute and a source attribute within a
162
- * {@link ConstraintLayout}.
163
- */
164
- export type ConstraintProps = {
165
- target?: string;
166
- targetAttribute: Gtk.ConstraintAttribute;
167
- relation?: Gtk.ConstraintRelation;
168
- source?: string;
169
- sourceAttribute?: Gtk.ConstraintAttribute;
170
- multiplier?: number;
171
- constant?: number;
172
- strength?: number;
173
- };
174
- /**
175
- * Props for a `<ConstraintLayout.Guide>` declaring an invisible layout guide
176
- * that other constraints can reference by `id` within a {@link ConstraintLayout}.
177
- */
178
- export type ConstraintGuideProps = {
179
- id: string;
180
- minWidth?: number;
181
- minHeight?: number;
182
- natWidth?: number;
183
- natHeight?: number;
184
- maxWidth?: number;
185
- maxHeight?: number;
186
- strength?: Gtk.ConstraintStrength;
187
- };
188
- /**
189
- * Props for a `<ConstraintLayout.Vfl>` declaring constraints through the GTK
190
- * Visual Format Language within a {@link ConstraintLayout}.
191
- */
192
- export type ConstraintVflProps = {
193
- lines: string[];
194
- hspacing?: number;
195
- vspacing?: number;
196
- };
197
- export {};
198
68
  //# 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,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IACvC;IACI,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC,GACD;IACI,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,EAAE,IAAI,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;CAC9B,CAAC;AAER,KAAK,mBAAmB,GAAG;IACvB,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,KAAK,gCAAgC,GAAG;IACpC,QAAQ,C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ACpC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACnC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,kBAAkB,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAClE,aAAa,CAAC,EAAE,GAAG,CAAC,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACnC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,gBAAgB,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CACnE,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,SAAS,GAAG;IACpB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IAClC,8DAA8D;IAC9D,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;CACrC,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
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,12 +1,10 @@
1
1
  import type * as GObject from "@gtkx/gi/gobject";
2
2
  import type * as Gtk from "@gtkx/gi/gtk";
3
- export interface SlotEntry {
4
- container: GObject.Object;
3
+ export type CellEntry = {
5
4
  position: number;
6
5
  treeRow: Gtk.TreeListRow | null;
7
- item: GObject.Object | null;
8
- }
9
- export declare class RealizedSlotStore {
6
+ };
7
+ export declare class CellContainerStore {
10
8
  private entries;
11
9
  private published;
12
10
  private setListeners;
@@ -15,16 +13,16 @@ export declare class RealizedSlotStore {
15
13
  private keys;
16
14
  private snapshot;
17
15
  subscribeSet: (onChange: () => void) => (() => void);
18
- getSlotsSnapshot: () => GObject.Object[];
16
+ getContainersSnapshot: () => GObject.Object[];
19
17
  subscribePosition: (container: GObject.Object, onChange: () => void) => (() => void);
20
- getPosition: (container: GObject.Object) => SlotEntry;
18
+ getPosition: (container: GObject.Object) => CellEntry;
21
19
  keyFor: (container: GObject.Object) => string;
22
20
  addContainer: (container: GObject.Object) => void;
23
- bind: (container: GObject.Object, position: number, treeRow: Gtk.TreeListRow | null, item: GObject.Object | null) => void;
21
+ bind: (container: GObject.Object, position: number, treeRow: Gtk.TreeListRow | null) => void;
24
22
  unbind: (container: GObject.Object) => void;
25
23
  removeContainer: (container: GObject.Object) => void;
26
24
  private flushSet;
27
25
  private notifySet;
28
26
  private notifyPosition;
29
27
  }
30
- //# sourceMappingURL=realized-slot-store.d.ts.map
28
+ //# sourceMappingURL=cell-container-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cell-container-store.d.ts","sourceRoot":"","sources":["../../src/utils/cell-container-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;CACnC,CAAC;AAIF,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,SAAS,CAAwC;IAEzD,OAAO,CAAC,YAAY,CAAyB;IAE7C,OAAO,CAAC,iBAAiB,CAA8C;IAEvE,OAAO,CAAC,gBAAgB,CAAyC;IAEjE,OAAO,CAAC,IAAI,CAAyC;IAErD,OAAO,CAAC,QAAQ,CAAwB;IAExC,YAAY,aAAc,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAKjD;IAEF,qBAAqB,QAAO,OAAO,CAAC,MAAM,EAAE,CAAkB;IAE9D,iBAAiB,cAAe,OAAO,CAAC,MAAM,YAAY,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAajF;IAEF,WAAW,cAAe,OAAO,CAAC,MAAM,KAAG,SAAS,CAOlD;IAEF,MAAM,cAAe,OAAO,CAAC,MAAM,KAAG,MAAM,CAM1C;IAEF,YAAY,cAAe,OAAO,CAAC,MAAM,KAAG,IAAI,CAI9C;IAEF,IAAI,cAAe,OAAO,CAAC,MAAM,YAAY,MAAM,WAAW,GAAG,CAAC,WAAW,GAAG,IAAI,KAAG,IAAI,CAGzF;IAEF,MAAM,cAAe,OAAO,CAAC,MAAM,KAAG,IAAI,CAIxC;IAEF,eAAe,cAAe,OAAO,CAAC,MAAM,KAAG,IAAI,CAKjD;IAEF,OAAO,CAAC,QAAQ,CAGd;IAEF,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,cAAc;CAczB"}
@@ -1,5 +1,5 @@
1
1
  let nextKey = 0;
2
- export class RealizedSlotStore {
2
+ export class CellContainerStore {
3
3
  entries = new Map();
4
4
  published = new Map();
5
5
  setListeners = new Set();
@@ -13,7 +13,7 @@ export class RealizedSlotStore {
13
13
  this.setListeners.delete(onChange);
14
14
  };
15
15
  };
16
- getSlotsSnapshot = () => this.snapshot;
16
+ getContainersSnapshot = () => this.snapshot;
17
17
  subscribePosition = (container, onChange) => {
18
18
  let listeners = this.positionListeners.get(container);
19
19
  if (listeners === undefined) {
@@ -33,7 +33,7 @@ export class RealizedSlotStore {
33
33
  getPosition = (container) => {
34
34
  let entry = this.published.get(container);
35
35
  if (entry === undefined) {
36
- entry = { container, position: -1, treeRow: null, item: null };
36
+ entry = { position: -1, treeRow: null };
37
37
  this.published.set(container, entry);
38
38
  }
39
39
  return entry;
@@ -42,29 +42,24 @@ export class RealizedSlotStore {
42
42
  const existing = this.keys.get(container);
43
43
  if (existing !== undefined)
44
44
  return existing;
45
- const key = `slot-${nextKey++}`;
45
+ const key = `cell-${nextKey++}`;
46
46
  this.keys.set(container, key);
47
47
  return key;
48
48
  };
49
49
  addContainer = (container) => {
50
50
  if (this.entries.has(container))
51
51
  return;
52
- this.entries.set(container, { container, position: -1, treeRow: null, item: null });
52
+ this.entries.set(container, { position: -1, treeRow: null });
53
53
  this.notifySet();
54
54
  };
55
- bind = (container, position, treeRow, item) => {
56
- if (!this.entries.has(container)) {
57
- this.entries.set(container, { container, position, treeRow, item });
58
- this.notifySet();
59
- return;
60
- }
61
- this.entries.set(container, { container, position, treeRow, item });
55
+ bind = (container, position, treeRow) => {
56
+ this.entries.set(container, { position, treeRow });
62
57
  this.notifyPosition(container);
63
58
  };
64
59
  unbind = (container) => {
65
60
  if (!this.entries.has(container))
66
61
  return;
67
- this.entries.set(container, { container, position: -1, treeRow: null, item: null });
62
+ this.entries.set(container, { position: -1, treeRow: null });
68
63
  this.notifyPosition(container);
69
64
  };
70
65
  removeContainer = (container) => {
@@ -100,4 +95,4 @@ export class RealizedSlotStore {
100
95
  flush();
101
96
  }
102
97
  }
103
- //# sourceMappingURL=realized-slot-store.js.map
98
+ //# sourceMappingURL=cell-container-store.js.map
@@ -0,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C,GAAG,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,KAAK,GAAG,GAAS,EAAE;gBACf,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACzC,IAAI,IAAI,KAAK,SAAS;oBAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;gBAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACxD,IAAI,SAAS,KAAK,SAAS;oBAAE,OAAO;gBACpC,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC;oBAAE,QAAQ,EAAE,CAAC;YACtD,CAAC,CAAC;YACF,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;QACD,KAAK,EAAE,CAAC;IACZ,CAAC;CACJ","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\n\nexport type CellEntry = {\n position: number;\n treeRow: Gtk.TreeListRow | null;\n};\n\nlet nextKey = 0;\n\nexport class CellContainerStore {\n private entries = new Map<GObject.Object, CellEntry>();\n\n private published = new Map<GObject.Object, CellEntry>();\n\n private setListeners = new Set<() => void>();\n\n private positionListeners = new Map<GObject.Object, Set<() => void>>();\n\n private positionFlushers = new Map<GObject.Object, () => void>();\n\n private keys = new WeakMap<GObject.Object, string>();\n\n private snapshot: GObject.Object[] = [];\n\n subscribeSet = (onChange: () => void): (() => void) => {\n this.setListeners.add(onChange);\n return () => {\n this.setListeners.delete(onChange);\n };\n };\n\n getContainersSnapshot = (): GObject.Object[] => this.snapshot;\n\n subscribePosition = (container: GObject.Object, onChange: () => void): (() => void) => {\n let listeners = this.positionListeners.get(container);\n if (listeners === undefined) {\n listeners = new Set();\n this.positionListeners.set(container, listeners);\n }\n listeners.add(onChange);\n return () => {\n const current = this.positionListeners.get(container);\n if (current === undefined) return;\n current.delete(onChange);\n if (current.size === 0) this.positionListeners.delete(container);\n };\n };\n\n getPosition = (container: GObject.Object): CellEntry => {\n let entry = this.published.get(container);\n if (entry === undefined) {\n entry = { position: -1, treeRow: null };\n this.published.set(container, entry);\n }\n return entry;\n };\n\n keyFor = (container: GObject.Object): string => {\n const existing = this.keys.get(container);\n if (existing !== undefined) return existing;\n const key = `cell-${nextKey++}`;\n this.keys.set(container, key);\n return key;\n };\n\n addContainer = (container: GObject.Object): void => {\n if (this.entries.has(container)) return;\n this.entries.set(container, { position: -1, treeRow: null });\n this.notifySet();\n };\n\n bind = (container: GObject.Object, position: number, treeRow: Gtk.TreeListRow | null): void => {\n this.entries.set(container, { position, treeRow });\n this.notifyPosition(container);\n };\n\n unbind = (container: GObject.Object): void => {\n if (!this.entries.has(container)) return;\n this.entries.set(container, { position: -1, treeRow: null });\n this.notifyPosition(container);\n };\n\n removeContainer = (container: GObject.Object): void => {\n if (!this.entries.delete(container)) return;\n this.published.delete(container);\n this.positionFlushers.delete(container);\n this.notifySet();\n };\n\n private flushSet = (): void => {\n this.snapshot = [...this.entries.keys()];\n for (const listener of [...this.setListeners]) listener();\n };\n\n private notifySet(): void {\n this.flushSet();\n }\n\n private notifyPosition(container: GObject.Object): void {\n let flush = this.positionFlushers.get(container);\n if (flush === undefined) {\n flush = (): void => {\n const live = this.entries.get(container);\n if (live !== undefined) this.published.set(container, live);\n const listeners = this.positionListeners.get(container);\n if (listeners === undefined) return;\n for (const listener of [...listeners]) listener();\n };\n this.positionFlushers.set(container, flush);\n }\n flush();\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type * as GObject from "@gtkx/gi/gobject";
2
+ import * as Gtk from "@gtkx/gi/gtk";
3
+ import type { ItemNode, SectionNode } from "../types.js";
4
+ import type { RowValue } from "./item-resolver.js";
5
+ export declare const retagRows: <T>(items: ItemNode<T>[], rowValues: WeakMap<GObject.Object, RowValue<T>>, placeholdersById: Map<string, GObject.Object>) => void;
6
+ export declare const createFlatModel: (count: number) => Gtk.StringList;
7
+ export declare const resizeFlatModel: (model: Gtk.StringList, count: number) => void;
8
+ export declare const createTreeModel: <T>(items: ItemNode<T>[], rowValues: WeakMap<GObject.Object, RowValue<T>>, placeholdersById: Map<string, GObject.Object>) => Gtk.TreeListModel;
9
+ export declare const createSectionModel: <S, T>(sections: SectionNode<S, T>[]) => Gtk.FlattenListModel;
10
+ //# sourceMappingURL=item-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-models.d.ts","sourceRoot":"","sources":["../../src/utils/item-models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAKnD,eAAO,MAAM,SAAS,GAAI,CAAC,SAChB,QAAQ,CAAC,CAAC,CAAC,EAAE,aACT,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,oBAC7B,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,KAC9C,IAeF,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,GAAG,CAAC,UAAqD,CAAC;AAE1G,eAAO,MAAM,eAAe,UAAW,GAAG,CAAC,UAAU,SAAS,MAAM,KAAG,IAStE,CAAC;AA+BF,eAAO,MAAM,eAAe,GAAI,CAAC,SACtB,QAAQ,CAAC,CAAC,CAAC,EAAE,aACT,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,oBAC7B,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,KAC9C,GAAG,CAAC,aA4BN,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,YAAY,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAG,GAAG,CAAC,gBAM5E,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import * as Gio from "@gtkx/gi/gio";
2
2
  import * as Gtk from "@gtkx/gi/gtk";
3
- import { treeItemMetadata } from "./list-item-flatten.js";
3
+ import { countDescendants, treeItemMetadata } from "./list-item-flatten.js";
4
4
  const emptyStrings = (count) => new Array(Math.max(0, count)).fill("");
5
5
  export const retagRows = (items, rowValues, placeholdersById) => {
6
6
  const walk = (list) => {
@@ -10,7 +10,6 @@ export const retagRows = (items, rowValues, placeholdersById) => {
10
10
  rowValues.set(placeholder, {
11
11
  id: item.id,
12
12
  value: item.value,
13
- isHeader: item.section === true,
14
13
  metadata: treeItemMetadata(item),
15
14
  });
16
15
  }
@@ -40,17 +39,17 @@ const createTaggedRow = (row, rowValues, placeholdersById) => {
40
39
  return placeholder;
41
40
  };
42
41
  const childModelOf = (children, rowValues, placeholdersById) => {
43
- const store = Gio.ListStore.new(Gtk.StringObject.prototype.__gtype__);
42
+ const store = Gio.ListStore.new(Gtk.StringObject.prototype.__type__);
44
43
  for (const child of children) {
45
- store.append(createTaggedRow({ id: child.id, value: child.value, isHeader: false, metadata: treeItemMetadata(child) }, rowValues, placeholdersById));
44
+ store.append(createTaggedRow({ id: child.id, value: child.value, metadata: treeItemMetadata(child) }, rowValues, placeholdersById));
46
45
  }
47
46
  return store;
48
47
  };
49
- export const createTreeModel = (items, autoexpand, rowValues, placeholdersById) => {
48
+ export const createTreeModel = (items, rowValues, placeholdersById) => {
50
49
  const childrenByRow = new WeakMap();
51
- const root = Gio.ListStore.new(Gtk.StringObject.prototype.__gtype__);
50
+ const root = Gio.ListStore.new(Gtk.StringObject.prototype.__type__);
52
51
  for (const item of items) {
53
- const placeholder = createTaggedRow({ id: item.id, value: item.value, isHeader: item.section === true, metadata: treeItemMetadata(item) }, rowValues, placeholdersById);
52
+ const placeholder = createTaggedRow({ id: item.id, value: item.value, metadata: treeItemMetadata(item) }, rowValues, placeholdersById);
54
53
  if (item.children !== undefined && item.children.length > 0) {
55
54
  childrenByRow.set(placeholder, item.children);
56
55
  }
@@ -71,13 +70,13 @@ export const createTreeModel = (items, autoexpand, rowValues, placeholdersById)
71
70
  }
72
71
  return store;
73
72
  };
74
- return Gtk.TreeListModel.new(root, false, autoexpand, createFunc);
73
+ return Gtk.TreeListModel.new(root, false, false, createFunc);
75
74
  };
76
- export const createSectionModel = (items) => {
77
- const sections = Gio.ListStore.new(Gtk.StringList.prototype.__gtype__);
78
- for (const section of items) {
79
- sections.append(Gtk.StringList.new(emptyStrings(section.children?.length ?? 0)));
75
+ export const createSectionModel = (sections) => {
76
+ const store = Gio.ListStore.new(Gtk.StringList.prototype.__type__);
77
+ for (const section of sections) {
78
+ store.append(Gtk.StringList.new(emptyStrings(countDescendants(section.data))));
80
79
  }
81
- return Gtk.FlattenListModel.new(sections);
80
+ return Gtk.FlattenListModel.new(store);
82
81
  };
83
- //# sourceMappingURL=position-only-model.js.map
82
+ //# sourceMappingURL=item-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-models.js","sourceRoot":"","sources":["../../src/utils/item-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE5E,MAAM,YAAY,GAAG,CAAC,KAAa,EAAY,EAAE,CAAC,IAAI,KAAK,CAAS,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEjG,MAAM,CAAC,MAAM,SAAS,GAAG,CACrB,KAAoB,EACpB,SAA+C,EAC/C,gBAA6C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AAC;IACjB,CAAC,CAAC;IACF,OAAO,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAO,QAA6B,EAAwB,EAAE;IAC5F,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["import * as Gio from \"@gtkx/gi/gio\";\nimport type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ItemNode, SectionNode } from \"../types.js\";\nimport type { RowValue } from \"./item-resolver.js\";\nimport { countDescendants, treeItemMetadata } from \"./list-item-flatten.js\";\n\nconst emptyStrings = (count: number): string[] => new Array<string>(Math.max(0, count)).fill(\"\");\n\nexport const retagRows = <T>(\n items: ItemNode<T>[],\n rowValues: WeakMap<GObject.Object, RowValue<T>>,\n placeholdersById: Map<string, GObject.Object>,\n): void => {\n const walk = (list: ItemNode<T>[]): void => {\n for (const item of list) {\n const placeholder = placeholdersById.get(item.id);\n if (placeholder !== undefined) {\n rowValues.set(placeholder, {\n id: item.id,\n value: item.value,\n metadata: treeItemMetadata(item),\n });\n }\n if (item.children !== undefined && item.children.length > 0) walk(item.children);\n }\n };\n walk(items);\n};\n\nexport const createFlatModel = (count: number): Gtk.StringList => Gtk.StringList.new(emptyStrings(count));\n\nexport const resizeFlatModel = (model: Gtk.StringList, count: number): void => {\n const target = Math.max(0, count);\n const current = model.getNItems();\n if (current === target) return;\n if (target > current) {\n model.splice(current, 0, emptyStrings(target - current));\n return;\n }\n model.splice(target, current - target, null);\n};\n\nconst createTaggedRow = <T>(\n row: RowValue<T>,\n rowValues: WeakMap<GObject.Object, RowValue<T>>,\n placeholdersById?: Map<string, GObject.Object>,\n): GObject.Object => {\n const placeholder = Gtk.StringObject.new(\"\");\n rowValues.set(placeholder, row);\n if (placeholdersById !== undefined) placeholdersById.set(row.id, placeholder);\n return placeholder;\n};\n\nconst childModelOf = <T>(\n children: ItemNode<T>[],\n rowValues: WeakMap<GObject.Object, RowValue<T>>,\n placeholdersById: Map<string, GObject.Object>,\n): Gio.ListStore => {\n const store = Gio.ListStore.new(Gtk.StringObject.prototype.__type__);\n for (const child of children) {\n store.append(\n createTaggedRow(\n { id: child.id, value: child.value, metadata: treeItemMetadata(child) },\n rowValues,\n placeholdersById,\n ),\n );\n }\n return store;\n};\n\nexport const createTreeModel = <T>(\n items: ItemNode<T>[],\n rowValues: WeakMap<GObject.Object, RowValue<T>>,\n placeholdersById: Map<string, GObject.Object>,\n): Gtk.TreeListModel => {\n const childrenByRow = new WeakMap<GObject.Object, ItemNode<T>[]>();\n const root = Gio.ListStore.new(Gtk.StringObject.prototype.__type__);\n for (const item of items) {\n const placeholder = createTaggedRow(\n { id: item.id, value: item.value, metadata: treeItemMetadata(item) },\n rowValues,\n placeholdersById,\n );\n if (item.children !== undefined && item.children.length > 0) {\n childrenByRow.set(placeholder, item.children);\n }\n root.append(placeholder);\n }\n const createFunc = (rowItem: GObject.Object): Gio.ListModel | null => {\n const children = childrenByRow.get(rowItem);\n if (children === undefined) return null;\n const store = childModelOf(children, rowValues, placeholdersById);\n for (let index = 0; index < children.length; index++) {\n const child = children[index];\n if (child !== undefined && child.children !== undefined && child.children.length > 0) {\n const placeholder = store.getItem(index);\n if (placeholder !== null) childrenByRow.set(placeholder, child.children);\n }\n }\n return store;\n };\n return Gtk.TreeListModel.new(root, false, false, createFunc);\n};\n\nexport const createSectionModel = <S, T>(sections: SectionNode<S, T>[]): Gtk.FlattenListModel => {\n const store = Gio.ListStore.new(Gtk.StringList.prototype.__type__);\n for (const section of sections) {\n store.append(Gtk.StringList.new(emptyStrings(countDescendants(section.data))));\n }\n return Gtk.FlattenListModel.new(store);\n};\n"]}
@@ -1,28 +1,25 @@
1
- import type * as Gio from "@gtkx/gi/gio";
2
1
  import type * as GObject from "@gtkx/gi/gobject";
3
2
  import type * as Gtk from "@gtkx/gi/gtk";
4
- import type { ListItem } from "../types.js";
3
+ import type { ItemNode, SectionNode } from "../types.js";
5
4
  import { type TreeItemMetadata } from "./list-item-flatten.js";
6
- export interface Resolved<T = unknown, S = unknown> {
5
+ export type Resolved<T = unknown, S = unknown> = {
7
6
  value: T | S | undefined;
8
7
  present: boolean;
9
8
  isHeader: boolean;
10
- treeRow: Gtk.TreeListRow | null;
11
9
  metadata: TreeItemMetadata;
12
- }
13
- export interface ItemResolver<T = unknown, S = unknown> {
14
- resolve(position: number, treeRow: Gtk.TreeListRow | null, boundItem: GObject.Object | null): Resolved<T, S>;
15
- positionOf(id: string): number;
10
+ };
11
+ export type ItemResolver<T = unknown, S = unknown> = {
12
+ resolve(position: number, treeRow: Gtk.TreeListRow | null): Resolved<T, S>;
13
+ positionOfId(id: string): number;
16
14
  idOf(position: number): string | undefined;
17
- count: number;
18
- }
19
- export interface RowValue<T = unknown, S = unknown> {
15
+ };
16
+ export type RowValue<T = unknown> = {
20
17
  id: string;
21
- value: T | S;
22
- isHeader: boolean;
18
+ value: T;
23
19
  metadata: TreeItemMetadata;
24
- }
25
- export declare const createControlledResolver: <T, S>(items: ListItem<T, S>[] | undefined, flattenTreeChildren: boolean, rowValues: WeakMap<GObject.Object, RowValue<T, S>>) => ItemResolver<T, S>;
26
- export declare const createModelResolver: <T, S>(model: Gio.ListModel) => ItemResolver<T, S>;
27
- export declare const createSectionHeaderResolver: <T, S>(items: ListItem<T, S>[] | undefined) => ItemResolver<T, S>;
20
+ };
21
+ export declare const rowIdOf: <T>(rowValues: WeakMap<GObject.Object, RowValue<T>>, row: Gtk.TreeListRow) => string | undefined;
22
+ export declare const createItemResolver: <T, S>(items: ItemNode<T>[] | undefined, flattenTreeChildren: boolean, rowValues: WeakMap<GObject.Object, RowValue<T>>) => ItemResolver<T, S>;
23
+ export declare const createSectionHeaderResolver: <T, S>(sections: SectionNode<S, T>[] | undefined) => ItemResolver<T, S>;
24
+ export declare const createTreeResolver: <T, S>(items: ItemNode<T>[] | undefined, rowValues: WeakMap<GObject.Object, RowValue<T>>, model: Gtk.TreeListModel) => ItemResolver<T, S>;
28
25
  //# sourceMappingURL=item-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"item-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/item-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAcjF,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO;IAC9C,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;IAChC,QAAQ,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO;IAClD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,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