@gtkx/components 2.0.0-beta.1 → 2.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -165
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +20 -9
- package/dist/column-view.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/cells.d.ts +19 -2
- package/dist/internal/cells.d.ts.map +1 -1
- package/dist/internal/cells.js +202 -39
- package/dist/internal/cells.js.map +1 -1
- package/dist/internal/collection-index.d.ts +3 -2
- package/dist/internal/collection-index.d.ts.map +1 -1
- package/dist/internal/collection-index.js +3 -3
- package/dist/internal/collection-index.js.map +1 -1
- package/dist/internal/collection-model.d.ts +28 -7
- package/dist/internal/collection-model.d.ts.map +1 -1
- package/dist/internal/collection-model.js +147 -127
- package/dist/internal/collection-model.js.map +1 -1
- package/dist/internal/collection.d.ts +5 -4
- package/dist/internal/collection.d.ts.map +1 -1
- package/dist/internal/collection.js +20 -21
- package/dist/internal/collection.js.map +1 -1
- package/dist/internal/controlled-sync.d.ts +6 -8
- package/dist/internal/controlled-sync.d.ts.map +1 -1
- package/dist/internal/controlled-sync.js +3 -3
- package/dist/internal/controlled-sync.js.map +1 -1
- package/dist/internal/drop-down.d.ts.map +1 -1
- package/dist/internal/drop-down.js +43 -44
- package/dist/internal/drop-down.js.map +1 -1
- package/dist/internal/expansion.js +4 -4
- package/dist/internal/expansion.js.map +1 -1
- package/dist/internal/selection.d.ts +1 -0
- package/dist/internal/selection.d.ts.map +1 -1
- package/dist/internal/selection.js +6 -6
- package/dist/internal/selection.js.map +1 -1
- package/dist/internal/tree-expansion.d.ts.map +1 -1
- package/dist/internal/tree-expansion.js +2 -11
- package/dist/internal/tree-expansion.js.map +1 -1
- package/dist/internal/tree-order.d.ts.map +1 -1
- package/dist/internal/tree-order.js +32 -76
- package/dist/internal/tree-order.js.map +1 -1
- package/dist/internal/use-collection.d.ts +5 -1
- package/dist/internal/use-collection.d.ts.map +1 -1
- package/dist/internal/use-collection.js +21 -7
- package/dist/internal/use-collection.js.map +1 -1
- package/dist/list-item-factory.d.ts +10 -0
- package/dist/list-item-factory.d.ts.map +1 -0
- package/dist/list-item-factory.js +14 -0
- package/dist/list-item-factory.js.map +1 -0
- package/dist/list-view.d.ts.map +1 -1
- package/dist/list-view.js +1 -0
- package/dist/list-view.js.map +1 -1
- package/dist/toast.d.ts +3 -5
- package/dist/toast.d.ts.map +1 -1
- package/dist/toast.js +3 -12
- package/dist/toast.js.map +1 -1
- package/dist/types.d.ts +44 -52
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +13 -10
- package/src/column-view.tsx +24 -12
- package/src/index.ts +3 -2
- package/src/internal/cells.tsx +330 -53
- package/src/internal/collection-index.ts +8 -6
- package/src/internal/collection-model.ts +190 -168
- package/src/internal/collection.ts +28 -24
- package/src/internal/controlled-sync.ts +9 -12
- package/src/internal/drop-down.tsx +64 -60
- package/src/internal/expansion.ts +4 -4
- package/src/internal/selection.tsx +8 -8
- package/src/internal/tree-expansion.ts +2 -14
- package/src/internal/tree-order.ts +33 -121
- package/src/internal/use-collection.tsx +29 -8
- package/src/list-item-factory.tsx +27 -0
- package/src/list-view.tsx +1 -0
- package/src/toast.tsx +4 -18
- package/src/types.ts +48 -52
package/dist/types.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type * as Adw from "@gtkx/gi/adw";
|
|
2
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
3
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
3
4
|
import type { AdwComboRowProps, AdwToastProps } from "@gtkx/jsx/adw";
|
|
4
5
|
import type { GtkColumnViewColumnProps, GtkColumnViewProps, GtkDropDownProps, GtkGridViewProps, GtkListViewProps } from "@gtkx/jsx/gtk";
|
|
6
|
+
import type { Primitive } from "@gtkx/utils";
|
|
5
7
|
import type { ReactNode, RefObject } from "react";
|
|
6
8
|
/**
|
|
7
9
|
* A single item in a collection model, identified by a stable id and holding an
|
|
8
10
|
* arbitrary value. Nested items form a tree.
|
|
9
11
|
*/
|
|
10
12
|
type ListItem<T = unknown> = {
|
|
11
|
-
/** Stable identifier used to
|
|
13
|
+
/** Stable identifier, unique across the collection, used to preserve identity across updates and selection. */
|
|
12
14
|
id: string;
|
|
13
15
|
/** Payload handed to the cell renderer as `ListItemRenderArgs.item`. */
|
|
14
16
|
value: T;
|
|
15
|
-
/** Child items
|
|
17
|
+
/** Child items in an acyclic tree, read only as rows are drawn. */
|
|
16
18
|
children?: ListItem<T>[] | undefined;
|
|
17
19
|
/** Hides the tree expander arrow even when the item has children, through `hide-expander`. */
|
|
18
20
|
shouldHideExpander?: boolean | undefined;
|
|
@@ -23,7 +25,7 @@ type ListItem<T = unknown> = {
|
|
|
23
25
|
};
|
|
24
26
|
/** A group of items rendered under a shared section header. */
|
|
25
27
|
type ListSection<S = unknown, T = unknown> = {
|
|
26
|
-
/** Stable identifier used to track the section across updates. */
|
|
28
|
+
/** Stable identifier, unique among sections, used to track the section across updates. */
|
|
27
29
|
id: string;
|
|
28
30
|
/** Payload handed to the section header renderer as `ListSectionRenderArgs.section`. */
|
|
29
31
|
value: S;
|
|
@@ -76,12 +78,23 @@ type ItemSizeProps = {
|
|
|
76
78
|
/** Width in pixels every cell asks for until its contents render; unset lets each cell size itself. */
|
|
77
79
|
estimatedItemWidth?: number | undefined;
|
|
78
80
|
};
|
|
81
|
+
type ListItemFactoryProps<T extends GObject.Object> = ItemSizeProps & {
|
|
82
|
+
renderItem: ListItemRenderer<T>;
|
|
83
|
+
};
|
|
84
|
+
/** The flat-collection hint shared by {@link ListView} and {@link ColumnView}. */
|
|
85
|
+
type FlatnessProps = {
|
|
86
|
+
/**
|
|
87
|
+
* Declares every item a leaf, so the view skips tree discovery when synchronising a large collection
|
|
88
|
+
* instead of scanning each item for `children`. Must not be set when any item has children: those
|
|
89
|
+
* items would render as plain rows that never expand.
|
|
90
|
+
*/
|
|
91
|
+
isFlat?: boolean | undefined;
|
|
92
|
+
};
|
|
79
93
|
/** Controlled selection shared by the multi-item collection views. */
|
|
80
94
|
type SelectionProps = {
|
|
81
95
|
/**
|
|
82
96
|
* Ids of the items to keep selected; omitting it keeps nothing selected, and `onSelectionChanged` is how a
|
|
83
|
-
* user's selection is adopted into it.
|
|
84
|
-
* and a single-selection view takes the first of them.
|
|
97
|
+
* user's selection is adopted into it.
|
|
85
98
|
*/
|
|
86
99
|
selectedIds?: string[] | null | undefined;
|
|
87
100
|
/** Called with one id per selected row whenever the selection changes, and once on mount. */
|
|
@@ -104,9 +117,7 @@ type ExpanderDescriptions = {
|
|
|
104
117
|
type ExpansionProps = {
|
|
105
118
|
/**
|
|
106
119
|
* Ids of the items to keep expanded; omitting it keeps every row collapsed, and `onExpandedChange` is how a
|
|
107
|
-
* user's expansion is adopted into it.
|
|
108
|
-
* them expand together. An item whose children lead back to itself expands one level at a time, since a row
|
|
109
|
-
* repeating an item already expanded above it stays collapsed.
|
|
120
|
+
* user's expansion is adopted into it.
|
|
110
121
|
*/
|
|
111
122
|
expandedIds?: string[] | null | undefined;
|
|
112
123
|
/** Called with one id per expanded row, in visible order, whenever expansion changes. */
|
|
@@ -128,12 +139,15 @@ type SortProps = {
|
|
|
128
139
|
onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;
|
|
129
140
|
};
|
|
130
141
|
/** The data a collection view renders, either as a plain item list or grouped into sections. */
|
|
131
|
-
type SourceProps<T, S> = {
|
|
132
|
-
/** Items to render, nesting through `ListItem.children` for a tree
|
|
142
|
+
type SourceProps<T, S> = ({
|
|
143
|
+
/** Items to render, nesting through `ListItem.children` for a tree. */
|
|
133
144
|
items?: ListItem<T>[] | undefined;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
145
|
+
} & Partial<Record<"sections", undefined>> & Partial<Record<"renderHeader", null | undefined>>) | ({
|
|
146
|
+
/** Items grouped under section headers. */
|
|
147
|
+
sections: ListSection<S, T>[];
|
|
148
|
+
/** Renders the header shown above each section. */
|
|
149
|
+
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
150
|
+
} & Partial<Record<"items", undefined>>);
|
|
137
151
|
/** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */
|
|
138
152
|
type ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" | "sorter" | "id" | "title"> & {
|
|
139
153
|
/** Stable identifier, also used to address the column through sorting props. */
|
|
@@ -148,40 +162,31 @@ type ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, "factory" |
|
|
|
148
162
|
headerMenu?: ReactNode;
|
|
149
163
|
};
|
|
150
164
|
/** The declarative collection props {@link ColumnView} adds on top of Gtk.ColumnView's own. */
|
|
151
|
-
type ColumnViewOwnProps<T, S> = SelectionProps & ExpansionProps & SortProps & SourceProps<T, S> & Omit<ItemSizeProps, "estimatedItemWidth"> & {
|
|
165
|
+
type ColumnViewOwnProps<T, S> = SelectionProps & ExpansionProps & SortProps & SourceProps<T, S> & FlatnessProps & Omit<ItemSizeProps, "estimatedItemWidth"> & {
|
|
152
166
|
/** Columns to render, in order; each carries its own cell renderer. */
|
|
153
167
|
columns: ColumnViewColumn<T>[];
|
|
154
|
-
/** Renders the header shown above each section. */
|
|
155
|
-
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
156
168
|
/** Resolves the props of the row carrying one item's cells, such as its screen-reader label. */
|
|
157
169
|
rowProps?: ListRowPropsResolver<T> | null | undefined;
|
|
158
170
|
};
|
|
159
171
|
/**
|
|
160
|
-
*
|
|
161
|
-
* declarative collection props: flat items or grouped sections, controlled selection
|
|
162
|
-
* and expansion, sorting (sortColumn, sortOrder, onSortChanged), an optional section
|
|
163
|
-
* header renderer, per-row props, and the columns to render.
|
|
172
|
+
* Native `Gtk.ColumnView` props with declarative columns and collections, controlled selection, expansion, and sorting.
|
|
164
173
|
*/
|
|
165
|
-
type ColumnViewProps<T = unknown, S = unknown> = Omit<GtkColumnViewProps, "columns" | "model" | "headerFactory" | "rowFactory" | keyof ColumnViewOwnProps<T, S>> & ColumnViewOwnProps<T, S>;
|
|
174
|
+
type ColumnViewProps<T = unknown, S = unknown> = Omit<GtkColumnViewProps, "children" | "columns" | "model" | "headerFactory" | "rowFactory" | keyof ColumnViewOwnProps<T, S>> & ColumnViewOwnProps<T, S>;
|
|
166
175
|
/** The declarative collection props {@link DropDown} and `ComboRow` add on top of their widget's own. */
|
|
167
176
|
type DropDownOwnProps<T, S> = SourceProps<T, S> & {
|
|
168
177
|
/** Id of the currently selected item, making the selection controlled. */
|
|
169
|
-
selectedId?: string |
|
|
170
|
-
/** Called with the id
|
|
171
|
-
onSelectionChanged?: ((id: string) => void) | null | undefined;
|
|
172
|
-
/** Renders the collapsed display
|
|
178
|
+
selectedId?: string | undefined;
|
|
179
|
+
/** Called with the selected id, or `null` when the model becomes empty. */
|
|
180
|
+
onSelectionChanged?: ((id: string | null) => void) | null | undefined;
|
|
181
|
+
/** Renders the collapsed display and, unless overridden, the popup rows. Required for non-primitive values. */
|
|
173
182
|
renderItem?: ListItemRenderer<T> | null | undefined;
|
|
174
183
|
/** Renderer for items in the open popup list, falling back to renderItem when omitted. */
|
|
175
184
|
renderListItem?: ListItemRenderer<T> | null | undefined;
|
|
176
|
-
/** Renderer for section headers in the popup list. */
|
|
177
|
-
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
178
185
|
};
|
|
179
186
|
/** A drop-down-shaped widget's props with its model and factories swapped for the declarative collection props. */
|
|
180
|
-
type DropDownWidgetProps<Widget, T, S> = Omit<Widget, "model" | "factory" | "listFactory" | "headerFactory" | keyof DropDownOwnProps<T, S>> & DropDownOwnProps<T, S
|
|
187
|
+
type DropDownWidgetProps<Widget, T, S> = Omit<Widget, "model" | "factory" | "listFactory" | "headerFactory" | keyof DropDownOwnProps<T, S>> & DropDownOwnProps<T, S> & (SourceProps<T & Primitive, S> | Record<"renderItem", ListItemRenderer<T>>);
|
|
181
188
|
/**
|
|
182
|
-
*
|
|
183
|
-
* collection props: flat items or grouped sections, controlled single selection, and renderers
|
|
184
|
-
* for the collapsed display, popup rows, and popup section headers.
|
|
189
|
+
* Native `Gtk.DropDown` props with declarative collections, controlled selection, and display/popup renderers.
|
|
185
190
|
*/
|
|
186
191
|
type DropDownProps<T = unknown, S = unknown> = DropDownWidgetProps<GtkDropDownProps, T, S>;
|
|
187
192
|
/** The declarative collection props {@link GridView} adds on top of Gtk.GridView's own. */
|
|
@@ -192,29 +197,21 @@ type GridViewOwnProps<T> = ItemSizeProps & SelectionProps & {
|
|
|
192
197
|
renderItem: ListItemRenderer<T>;
|
|
193
198
|
};
|
|
194
199
|
/**
|
|
195
|
-
*
|
|
196
|
-
* declarative collection props: items, a per-cell renderItem, controlled selection,
|
|
197
|
-
* and estimated item sizing.
|
|
200
|
+
* Native `Gtk.GridView` props with declarative cells, controlled selection, and estimated sizing.
|
|
198
201
|
*/
|
|
199
202
|
type GridViewProps<T = unknown> = Omit<GtkGridViewProps, "model" | "factory" | keyof GridViewOwnProps<T>> & GridViewOwnProps<T>;
|
|
200
203
|
/** The declarative collection props {@link ListView} adds on top of Gtk.ListView's own. */
|
|
201
|
-
type ListViewOwnProps<T, S> = ItemSizeProps & SelectionProps & ExpansionProps & SourceProps<T, S> & {
|
|
204
|
+
type ListViewOwnProps<T, S> = ItemSizeProps & SelectionProps & ExpansionProps & SourceProps<T, S> & FlatnessProps & {
|
|
202
205
|
/** Renders the contents of one row. */
|
|
203
206
|
renderItem: ListItemRenderer<T>;
|
|
204
|
-
/** Renders the header shown above each section. */
|
|
205
|
-
renderHeader?: ListSectionRenderer<S> | null | undefined;
|
|
206
207
|
};
|
|
207
208
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
* an optional section header renderer, controlled selection and expansion, and
|
|
211
|
-
* estimated item sizing.
|
|
209
|
+
* Native `Gtk.ListView` props with declarative rows and sections, controlled selection and expansion,
|
|
210
|
+
* and estimated sizing.
|
|
212
211
|
*/
|
|
213
212
|
type ListViewProps<T = unknown, S = unknown> = Omit<GtkListViewProps, "model" | "factory" | "headerFactory" | keyof ListViewOwnProps<T, S>> & ListViewOwnProps<T, S>;
|
|
214
213
|
/**
|
|
215
|
-
*
|
|
216
|
-
* collection props: flat items or grouped sections, controlled single selection, and renderers
|
|
217
|
-
* for the row display, popup rows, and popup section headers.
|
|
214
|
+
* Native `Adw.ComboRow` props with declarative collections, controlled selection, and display/popup renderers.
|
|
218
215
|
*/
|
|
219
216
|
type ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;
|
|
220
217
|
/**
|
|
@@ -222,15 +219,10 @@ type ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowPr
|
|
|
222
219
|
* `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.
|
|
223
220
|
*/
|
|
224
221
|
type ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, "onButtonClicked" | "onDismissed">;
|
|
225
|
-
/** Imperative controls for
|
|
222
|
+
/** Imperative controls for toasts, returned by {@link useToast}. */
|
|
226
223
|
type ToastController = {
|
|
227
224
|
/** Builds a toast, shows it through the overlay, and returns it. */
|
|
228
225
|
show: (options?: ToastOptions) => Adw.Toast;
|
|
229
|
-
/** Dismisses a single toast, typically one returned by `ToastController.show`. */
|
|
230
|
-
dismiss: (toast: Adw.Toast) => void;
|
|
231
|
-
};
|
|
232
|
-
/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */
|
|
233
|
-
type ToastOverlayController = {
|
|
234
226
|
/** Dismisses the shown toast and every queued one. */
|
|
235
227
|
dismissAll: () => void;
|
|
236
228
|
};
|
|
@@ -238,8 +230,8 @@ type ToastOverlayController = {
|
|
|
238
230
|
type ToastProviderProps = {
|
|
239
231
|
/** Ref also given to the `AdwToastOverlay` the toasts appear over. */
|
|
240
232
|
overlayRef: RefObject<Adw.ToastOverlay | null>;
|
|
241
|
-
/** Subtree whose `useToast`
|
|
233
|
+
/** Subtree whose `useToast` calls target that overlay. */
|
|
242
234
|
children?: ReactNode | undefined;
|
|
243
235
|
};
|
|
244
|
-
export { type SelectionProps, type ExpanderDescriptions, type ExpansionProps, type SortProps, type DropDownOwnProps, type ListItem, type ListSection, type ListItemRenderArgs, type ListRowProps, type ListSectionRenderArgs, type ListItemRenderer, type ListRowPropsResolver, type ListSectionRenderer, type ColumnViewColumn, type ColumnViewProps, type DropDownProps, type GridViewProps, type ListViewProps, type ComboRowProps, type ToastOptions, type ToastController, type
|
|
236
|
+
export { type SelectionProps, type ExpanderDescriptions, type ExpansionProps, type SortProps, type DropDownOwnProps, type ListItem, type ListSection, type ListItemRenderArgs, type ListRowProps, type ListSectionRenderArgs, type ListItemRenderer, type ListItemFactoryProps, type ListRowPropsResolver, type ListSectionRenderer, type ColumnViewColumn, type ColumnViewProps, type DropDownProps, type GridViewProps, type ListViewProps, type ComboRowProps, type ToastOptions, type ToastController, type ToastProviderProps, };
|
|
245
237
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EACR,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD;;;GAGG;AACH,KAAK,QAAQ,CAAC,CAAC,GAAG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,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GAC1B,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAySA,OAAO,EAwBN,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { AdwComboRowProps, AdwToastProps } from \"@gtkx/jsx/adw\";\nimport type {\n GtkColumnViewColumnProps,\n GtkColumnViewProps,\n GtkDropDownProps,\n GtkGridViewProps,\n GtkListViewProps,\n} from \"@gtkx/jsx/gtk\";\nimport type { ReactNode, RefObject } from \"react\";\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 ListItem<T = unknown> = {\n /** Stable identifier used to track the item across updates and selection, naming every row that carries it. */\n id: string;\n /** Payload handed to the cell renderer as `ListItemRenderArgs.item`. */\n value: T;\n /** Child items nested under this one, which turn a plain item list into a tree, read only as rows are drawn. */\n children?: ListItem<T>[] | undefined;\n /** Hides the tree expander arrow even when the item has children, through `hide-expander`. */\n shouldHideExpander?: boolean | undefined;\n /** Adds indentation matching the item's depth in the tree, through `indent-for-depth`. */\n shouldIndentForDepth?: boolean | undefined;\n /** Reserves indentation space for an expander icon, through `indent-for-icon`. */\n shouldIndentForIcon?: boolean | undefined;\n};\n\n/** A group of items rendered under a shared section header. */\ntype ListSection<S = unknown, T = unknown> = {\n /** Stable identifier used to track the section across updates. */\n id: string;\n /** Payload handed to the section header renderer as `ListSectionRenderArgs.section`. */\n value: S;\n /** Items belonging to this section. */\n data: ListItem<T>[];\n};\n\n/** Arguments passed to a {@link ListItemRenderer} when rendering one cell. */\ntype ListItemRenderArgs<T> = {\n /** Value of the `ListItem` being rendered. */\n item: T;\n /** Position of the item in the flattened item list, which excludes section headers and collapsed tree rows. */\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/**\n * Properties applied to the row that carries one item's cells. A Gtk.ColumnViewRow is not a widget, so\n * these are the only handles it offers; anything omitted falls back to the row's own default, which\n * leaves the accessibility strings unset rather than setting them to an empty string.\n */\ntype ListRowProps = {\n /** Name a screen reader announces for the row, through `accessible-label`. */\n accessibleLabel?: string | undefined;\n /** Longer description a screen reader announces for the row, through `accessible-description`. */\n accessibleDescription?: string | undefined;\n /** Whether activating the row emits the view's `activate` signal; rows are activatable by default. */\n isActivatable?: boolean | undefined;\n /** Whether the row takes keyboard focus; rows are focusable by default. */\n isFocusable?: boolean | undefined;\n /** Whether clicking or keying the row tries to select it; rows are selectable by default. */\n isSelectable?: boolean | undefined;\n};\n\n/** Arguments passed to a {@link ListSectionRenderer} when rendering one section header. */\ntype ListSectionRenderArgs<S> = {\n /** Value of the `ListSection` whose header is being rendered. */\n section: S;\n};\n\n/** Renders the contents of one cell of a collection view. */\ntype ListItemRenderer<T> = (args: ListItemRenderArgs<T>) => ReactNode;\n/** Renders the contents of one section header of a collection view. */\ntype ListSectionRenderer<S> = (args: ListSectionRenderArgs<S>) => ReactNode;\n/** Returns the {@link ListRowProps} to apply to the row displaying one item, re-run whenever the item renders. */\ntype ListRowPropsResolver<T> = (args: ListItemRenderArgs<T>) => ListRowProps;\n\n/** Size a collection view requests for each cell before its contents render, keeping scroll estimates steady. */\ntype ItemSizeProps = {\n /** Height in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemHeight?: number | undefined;\n /** Width in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemWidth?: number | undefined;\n};\n\n/** Controlled selection shared by the multi-item collection views. */\ntype SelectionProps = {\n /**\n * Ids of the items to keep selected; omitting it keeps nothing selected, and `onSelectionChanged` is how a\n * user's selection is adopted into it. An id repeated in several branches of a tree names every matching row,\n * and a single-selection view takes the first of them.\n */\n selectedIds?: string[] | null | undefined;\n /** Called with one id per selected row whenever the selection changes, and once on mount. */\n onSelectionChanged?: ((ids: string[]) => void) | null | undefined;\n /** How much the user may select, one item at a time unless `MULTIPLE` or `NONE` is given. */\n selectionMode?: Gtk.SelectionMode | null | undefined;\n};\n\n/**\n * Wording a screen reader announces for the control that expands and collapses a row. GTK names that control\n * after the row's own content and reports whether it is expanded, but says nothing about what activating it\n * does, so these strings supply that and belong in the application's own language.\n */\ntype ExpanderDescriptions = {\n /** Announced while the row is collapsed, such as \"Expand\". */\n expand: string;\n /** Announced while the row is expanded, such as \"Collapse\". */\n collapse: string;\n};\n\n/** Controlled expansion for the views that turn nested `ListItem.children` into a tree. */\ntype ExpansionProps = {\n /**\n * Ids of the items to keep expanded; omitting it keeps every row collapsed, and `onExpandedChange` is how a\n * user's expansion is adopted into it. An id repeated in several branches names every matching row, so all of\n * them expand together. An item whose children lead back to itself expands one level at a time, since a row\n * repeating an item already expanded above it stays collapsed.\n */\n expandedIds?: string[] | null | undefined;\n /** Called with one id per expanded row, in visible order, whenever expansion changes. */\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n /**\n * Wording announced for the expander of every row that can expand, describing what activating it does.\n * Omitting it leaves those expanders described only by the row they carry, and rows that cannot expand or\n * that hide their expander are never described.\n */\n expanderDescriptions?: ExpanderDescriptions | null | undefined;\n};\n\n/** Controlled sorting for the views whose headers can sort the collection. */\ntype SortProps = {\n /** Id of the column the view is sorted by, making sorting controlled. */\n sortColumn?: string | null | undefined;\n /** Direction `sortColumn` is sorted in, defaulting to ascending. */\n sortOrder?: Gtk.SortType | null | undefined;\n /** Called when the user sorts from a header, with the primary column's id, or null, and its order. */\n onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;\n};\n\n/** The data a collection view renders, either as a plain item list or grouped into sections. */\ntype SourceProps<T, S> = {\n /** Items to render, nesting through `ListItem.children` for a tree; ignored once `sections` is given. */\n items?: ListItem<T>[] | undefined;\n /** Items grouped under section headers, rendered in place of `items`. */\n sections?: ListSection<S, T>[] | undefined;\n};\n\n/** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */\ntype ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, \"factory\" | \"sorter\" | \"id\" | \"title\"> & {\n /** Stable identifier, also used to address the column through sorting props. */\n id: string;\n /** Text shown in the column header. */\n title: string;\n /** Renders the contents of this column's cell for one item. */\n renderCell: ListItemRenderer<T>;\n /** Makes the column header clickable, reporting the choice through `onSortChanged`. */\n isSortable?: boolean | undefined;\n /** Menu element popped up as the column header's context menu, on a right-click. */\n headerMenu?: ReactNode;\n};\n\n/** The declarative collection props {@link ColumnView} adds on top of Gtk.ColumnView's own. */\ntype ColumnViewOwnProps<T, S> = SelectionProps &\n ExpansionProps &\n SortProps &\n SourceProps<T, S> &\n Omit<ItemSizeProps, \"estimatedItemWidth\"> & {\n /** Columns to render, in order; each carries its own cell renderer. */\n columns: ColumnViewColumn<T>[];\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n /** Resolves the props of the row carrying one item's cells, such as its screen-reader label. */\n rowProps?: ListRowPropsResolver<T> | 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, per-row props, and the columns to render.\n */\ntype ColumnViewProps<T = unknown, S = unknown> = Omit<\n GtkColumnViewProps,\n \"columns\" | \"model\" | \"headerFactory\" | \"rowFactory\" | keyof ColumnViewOwnProps<T, S>\n> &\nColumnViewOwnProps<T, S>;\n\n/** The declarative collection props {@link DropDown} and `ComboRow` add on top of their widget's own. */\ntype DropDownOwnProps<T, S> = SourceProps<T, S> & {\n /** Id of the currently selected item, making the selection controlled. */\n selectedId?: string | null | undefined;\n /** Called with the id of the item that became selected. */\n onSelectionChanged?: ((id: string) => void) | null | undefined;\n /** Renders the collapsed display, and the popup rows too unless `renderListItem` is given. */\n renderItem?: ListItemRenderer<T> | null | undefined;\n /** Renderer for items in the open popup list, falling back to renderItem when omitted. */\n renderListItem?: ListItemRenderer<T> | null | undefined;\n /** Renderer for section headers in the popup list. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n};\n\n/** A drop-down-shaped widget's props with its model and factories swapped for the declarative collection props. */\ntype DropDownWidgetProps<Widget, T, S> = Omit<\n Widget,\n \"model\" | \"factory\" | \"listFactory\" | \"headerFactory\" | keyof DropDownOwnProps<T, S>\n> &\nDropDownOwnProps<T, S>;\n\n/**\n * Props for {@link DropDown}. Combines the underlying Gtk.DropDown props with the declarative\n * collection props: flat items or grouped sections, controlled single selection, and renderers\n * for the collapsed display, popup rows, and popup section headers.\n */\ntype DropDownProps<T = unknown, S = unknown> = DropDownWidgetProps<GtkDropDownProps, T, S>;\n\n/** The declarative collection props {@link GridView} adds on top of Gtk.GridView's own. */\ntype GridViewOwnProps<T> = ItemSizeProps &\n SelectionProps & {\n /** Items to render as cells; a grid is always flat, so `ListItem.children` is ignored. */\n items?: ListItem<T>[] | undefined;\n /** Renders the contents of one cell. */\n renderItem: ListItemRenderer<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\n/** The declarative collection props {@link ListView} adds on top of Gtk.ListView's own. */\ntype ListViewOwnProps<T, S> = ItemSizeProps &\n SelectionProps &\n ExpansionProps &\n SourceProps<T, S> & {\n /** Renders the contents of one row. */\n renderItem: ListItemRenderer<T>;\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<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/**\n * Props for {@link ComboRow}. Combines the underlying Adw.ComboRow props with the declarative\n * collection props: flat items or grouped sections, controlled single selection, and renderers\n * for the row display, popup rows, and popup section headers.\n */\ntype ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;\n/**\n * Describes a toast raised through {@link useToast}: the construct-time properties of an\n * `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.\n */\ntype ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, \"onButtonClicked\" | \"onDismissed\">;\n\n/** Imperative controls for individual toasts, returned by {@link useToast}. */\ntype ToastController = {\n /** Builds a toast, shows it through the overlay, and returns it. */\n show: (options?: ToastOptions) => Adw.Toast;\n /** Dismisses a single toast, typically one returned by `ToastController.show`. */\n dismiss: (toast: Adw.Toast) => void;\n};\n\n/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */\ntype ToastOverlayController = {\n /** Dismisses the shown toast and every queued one. */\n dismissAll: () => void;\n};\n\n/** Props for {@link ToastProvider}. */\ntype ToastProviderProps = {\n /** Ref also given to the `AdwToastOverlay` the toasts appear over. */\n overlayRef: RefObject<Adw.ToastOverlay | null>;\n /** Subtree whose `useToast` and `useToastOverlay` calls target that overlay. */\n children?: ReactNode | undefined;\n};\n\nexport {\n type SelectionProps,\n type ExpanderDescriptions,\n type ExpansionProps,\n type SortProps,\n type DropDownOwnProps,\n type ListItem,\n type ListSection,\n type ListItemRenderArgs,\n type ListRowProps,\n type ListSectionRenderArgs,\n type ListItemRenderer,\n type ListRowPropsResolver,\n type ListSectionRenderer,\n type ColumnViewColumn,\n type ColumnViewProps,\n type DropDownProps,\n type GridViewProps,\n type ListViewProps,\n type ComboRowProps,\n type ToastOptions,\n type ToastController,\n type ToastOverlayController,\n type ToastProviderProps,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqSA,OAAO,EAwBN,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { AdwComboRowProps, AdwToastProps } from \"@gtkx/jsx/adw\";\nimport type {\n GtkColumnViewColumnProps,\n GtkColumnViewProps,\n GtkDropDownProps,\n GtkGridViewProps,\n GtkListViewProps,\n} from \"@gtkx/jsx/gtk\";\nimport type { Primitive } from \"@gtkx/utils\";\nimport type { ReactNode, RefObject } from \"react\";\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 ListItem<T = unknown> = {\n /** Stable identifier, unique across the collection, used to preserve identity across updates and selection. */\n id: string;\n /** Payload handed to the cell renderer as `ListItemRenderArgs.item`. */\n value: T;\n /** Child items in an acyclic tree, read only as rows are drawn. */\n children?: ListItem<T>[] | undefined;\n /** Hides the tree expander arrow even when the item has children, through `hide-expander`. */\n shouldHideExpander?: boolean | undefined;\n /** Adds indentation matching the item's depth in the tree, through `indent-for-depth`. */\n shouldIndentForDepth?: boolean | undefined;\n /** Reserves indentation space for an expander icon, through `indent-for-icon`. */\n shouldIndentForIcon?: boolean | undefined;\n};\n\n/** A group of items rendered under a shared section header. */\ntype ListSection<S = unknown, T = unknown> = {\n /** Stable identifier, unique among sections, used to track the section across updates. */\n id: string;\n /** Payload handed to the section header renderer as `ListSectionRenderArgs.section`. */\n value: S;\n /** Items belonging to this section. */\n data: ListItem<T>[];\n};\n\n/** Arguments passed to a {@link ListItemRenderer} when rendering one cell. */\ntype ListItemRenderArgs<T> = {\n /** Value of the `ListItem` being rendered. */\n item: T;\n /** Position of the item in the flattened item list, which excludes section headers and collapsed tree rows. */\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/**\n * Properties applied to the row that carries one item's cells. A Gtk.ColumnViewRow is not a widget, so\n * these are the only handles it offers; anything omitted falls back to the row's own default, which\n * leaves the accessibility strings unset rather than setting them to an empty string.\n */\ntype ListRowProps = {\n /** Name a screen reader announces for the row, through `accessible-label`. */\n accessibleLabel?: string | undefined;\n /** Longer description a screen reader announces for the row, through `accessible-description`. */\n accessibleDescription?: string | undefined;\n /** Whether activating the row emits the view's `activate` signal; rows are activatable by default. */\n isActivatable?: boolean | undefined;\n /** Whether the row takes keyboard focus; rows are focusable by default. */\n isFocusable?: boolean | undefined;\n /** Whether clicking or keying the row tries to select it; rows are selectable by default. */\n isSelectable?: boolean | undefined;\n};\n\n/** Arguments passed to a {@link ListSectionRenderer} when rendering one section header. */\ntype ListSectionRenderArgs<S> = {\n /** Value of the `ListSection` whose header is being rendered. */\n section: S;\n};\n\n/** Renders the contents of one cell of a collection view. */\ntype ListItemRenderer<T> = (args: ListItemRenderArgs<T>) => ReactNode;\n/** Renders the contents of one section header of a collection view. */\ntype ListSectionRenderer<S> = (args: ListSectionRenderArgs<S>) => ReactNode;\n/** Returns the {@link ListRowProps} to apply to the row displaying one item, re-run whenever the item renders. */\ntype ListRowPropsResolver<T> = (args: ListItemRenderArgs<T>) => ListRowProps;\n\n/** Size a collection view requests for each cell before its contents render, keeping scroll estimates steady. */\ntype ItemSizeProps = {\n /** Height in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemHeight?: number | undefined;\n /** Width in pixels every cell asks for until its contents render; unset lets each cell size itself. */\n estimatedItemWidth?: number | undefined;\n};\n\ntype ListItemFactoryProps<T extends GObject.Object> = ItemSizeProps & {\n renderItem: ListItemRenderer<T>;\n};\n\n/** The flat-collection hint shared by {@link ListView} and {@link ColumnView}. */\ntype FlatnessProps = {\n /**\n * Declares every item a leaf, so the view skips tree discovery when synchronising a large collection\n * instead of scanning each item for `children`. Must not be set when any item has children: those\n * items would render as plain rows that never expand.\n */\n isFlat?: boolean | undefined;\n};\n\n/** Controlled selection shared by the multi-item collection views. */\ntype SelectionProps = {\n /**\n * Ids of the items to keep selected; omitting it keeps nothing selected, and `onSelectionChanged` is how a\n * user's selection is adopted into it.\n */\n selectedIds?: string[] | null | undefined;\n /** Called with one id per selected row whenever the selection changes, and once on mount. */\n onSelectionChanged?: ((ids: string[]) => void) | null | undefined;\n /** How much the user may select, one item at a time unless `MULTIPLE` or `NONE` is given. */\n selectionMode?: Gtk.SelectionMode | null | undefined;\n};\n\n/**\n * Wording a screen reader announces for the control that expands and collapses a row. GTK names that control\n * after the row's own content and reports whether it is expanded, but says nothing about what activating it\n * does, so these strings supply that and belong in the application's own language.\n */\ntype ExpanderDescriptions = {\n /** Announced while the row is collapsed, such as \"Expand\". */\n expand: string;\n /** Announced while the row is expanded, such as \"Collapse\". */\n collapse: string;\n};\n\n/** Controlled expansion for the views that turn nested `ListItem.children` into a tree. */\ntype ExpansionProps = {\n /**\n * Ids of the items to keep expanded; omitting it keeps every row collapsed, and `onExpandedChange` is how a\n * user's expansion is adopted into it.\n */\n expandedIds?: string[] | null | undefined;\n /** Called with one id per expanded row, in visible order, whenever expansion changes. */\n onExpandedChange?: ((ids: string[]) => void) | null | undefined;\n /**\n * Wording announced for the expander of every row that can expand, describing what activating it does.\n * Omitting it leaves those expanders described only by the row they carry, and rows that cannot expand or\n * that hide their expander are never described.\n */\n expanderDescriptions?: ExpanderDescriptions | null | undefined;\n};\n\n/** Controlled sorting for the views whose headers can sort the collection. */\ntype SortProps = {\n /** Id of the column the view is sorted by, making sorting controlled. */\n sortColumn?: string | null | undefined;\n /** Direction `sortColumn` is sorted in, defaulting to ascending. */\n sortOrder?: Gtk.SortType | null | undefined;\n /** Called when the user sorts from a header, with the primary column's id, or null, and its order. */\n onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;\n};\n\n/** The data a collection view renders, either as a plain item list or grouped into sections. */\ntype SourceProps<T, S> = ({\n /** Items to render, nesting through `ListItem.children` for a tree. */\n items?: ListItem<T>[] | undefined;\n} & Partial<Record<\"sections\", undefined>> & Partial<Record<\"renderHeader\", null | undefined>>) | ({\n /** Items grouped under section headers. */\n sections: ListSection<S, T>[];\n /** Renders the header shown above each section. */\n renderHeader?: ListSectionRenderer<S> | null | undefined;\n} & Partial<Record<\"items\", undefined>>);\n\n/** One column of a {@link ColumnView}, pairing Gtk.ColumnViewColumn props with a cell renderer. */\ntype ColumnViewColumn<T = unknown> = Omit<GtkColumnViewColumnProps, \"factory\" | \"sorter\" | \"id\" | \"title\"> & {\n /** Stable identifier, also used to address the column through sorting props. */\n id: string;\n /** Text shown in the column header. */\n title: string;\n /** Renders the contents of this column's cell for one item. */\n renderCell: ListItemRenderer<T>;\n /** Makes the column header clickable, reporting the choice through `onSortChanged`. */\n isSortable?: boolean | undefined;\n /** Menu element popped up as the column header's context menu, on a right-click. */\n headerMenu?: ReactNode;\n};\n\n/** The declarative collection props {@link ColumnView} adds on top of Gtk.ColumnView's own. */\ntype ColumnViewOwnProps<T, S> = SelectionProps &\n ExpansionProps &\n SortProps &\n SourceProps<T, S> &\n FlatnessProps &\n Omit<ItemSizeProps, \"estimatedItemWidth\"> & {\n /** Columns to render, in order; each carries its own cell renderer. */\n columns: ColumnViewColumn<T>[];\n /** Resolves the props of the row carrying one item's cells, such as its screen-reader label. */\n rowProps?: ListRowPropsResolver<T> | null | undefined;\n };\n\n/**\n * Native `Gtk.ColumnView` props with declarative columns and collections, controlled selection, expansion, and sorting.\n */\ntype ColumnViewProps<T = unknown, S = unknown> = Omit<\n GtkColumnViewProps,\n \"children\" | \"columns\" | \"model\" | \"headerFactory\" | \"rowFactory\" | keyof ColumnViewOwnProps<T, S>\n> &\nColumnViewOwnProps<T, S>;\n\n/** The declarative collection props {@link DropDown} and `ComboRow` add on top of their widget's own. */\ntype DropDownOwnProps<T, S> = SourceProps<T, S> & {\n /** Id of the currently selected item, making the selection controlled. */\n selectedId?: string | undefined;\n /** Called with the selected id, or `null` when the model becomes empty. */\n onSelectionChanged?: ((id: string | null) => void) | null | undefined;\n /** Renders the collapsed display and, unless overridden, the popup rows. Required for non-primitive values. */\n renderItem?: ListItemRenderer<T> | null | undefined;\n /** Renderer for items in the open popup list, falling back to renderItem when omitted. */\n renderListItem?: ListItemRenderer<T> | null | undefined;\n};\n\n/** A drop-down-shaped widget's props with its model and factories swapped for the declarative collection props. */\ntype DropDownWidgetProps<Widget, T, S> = Omit<\n Widget,\n \"model\" | \"factory\" | \"listFactory\" | \"headerFactory\" | keyof DropDownOwnProps<T, S>\n> &\nDropDownOwnProps<T, S> &\n(SourceProps<T & Primitive, S> | Record<\"renderItem\", ListItemRenderer<T>>);\n\n/**\n * Native `Gtk.DropDown` props with declarative collections, controlled selection, and display/popup renderers.\n */\ntype DropDownProps<T = unknown, S = unknown> = DropDownWidgetProps<GtkDropDownProps, T, S>;\n\n/** The declarative collection props {@link GridView} adds on top of Gtk.GridView's own. */\ntype GridViewOwnProps<T> = ItemSizeProps &\n SelectionProps & {\n /** Items to render as cells; a grid is always flat, so `ListItem.children` is ignored. */\n items?: ListItem<T>[] | undefined;\n /** Renders the contents of one cell. */\n renderItem: ListItemRenderer<T>;\n };\n\n/**\n * Native `Gtk.GridView` props with declarative cells, controlled selection, and estimated sizing.\n */\ntype GridViewProps<T = unknown> = Omit<GtkGridViewProps, \"model\" | \"factory\" | keyof GridViewOwnProps<T>> &\n GridViewOwnProps<T>;\n\n/** The declarative collection props {@link ListView} adds on top of Gtk.ListView's own. */\ntype ListViewOwnProps<T, S> = ItemSizeProps &\n SelectionProps &\n ExpansionProps &\n SourceProps<T, S> &\n FlatnessProps & {\n /** Renders the contents of one row. */\n renderItem: ListItemRenderer<T>;\n };\n\n/**\n * Native `Gtk.ListView` props with declarative rows and sections, controlled selection and expansion,\n * and estimated 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/**\n * Native `Adw.ComboRow` props with declarative collections, controlled selection, and display/popup renderers.\n */\ntype ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;\n/**\n * Describes a toast raised through {@link useToast}: the construct-time properties of an\n * `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.\n */\ntype ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, \"onButtonClicked\" | \"onDismissed\">;\n\n/** Imperative controls for toasts, returned by {@link useToast}. */\ntype ToastController = {\n /** Builds a toast, shows it through the overlay, and returns it. */\n show: (options?: ToastOptions) => Adw.Toast;\n /** Dismisses the shown toast and every queued one. */\n dismissAll: () => void;\n};\n\n/** Props for {@link ToastProvider}. */\ntype ToastProviderProps = {\n /** Ref also given to the `AdwToastOverlay` the toasts appear over. */\n overlayRef: RefObject<Adw.ToastOverlay | null>;\n /** Subtree whose `useToast` calls target that overlay. */\n children?: ReactNode | undefined;\n};\n\nexport {\n type SelectionProps,\n type ExpanderDescriptions,\n type ExpansionProps,\n type SortProps,\n type DropDownOwnProps,\n type ListItem,\n type ListSection,\n type ListItemRenderArgs,\n type ListRowProps,\n type ListSectionRenderArgs,\n type ListItemRenderer,\n type ListItemFactoryProps,\n type ListRowPropsResolver,\n type ListSectionRenderer,\n type ColumnViewColumn,\n type ColumnViewProps,\n type DropDownProps,\n type GridViewProps,\n type ListViewProps,\n type ComboRowProps,\n type ToastOptions,\n type ToastController,\n type ToastProviderProps,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/components",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0-beta.11",
|
|
4
|
+
"description": "Collection views, selection controls, and toasts for GTKX.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
7
7
|
"gtk",
|
|
8
8
|
"gtk4",
|
|
9
9
|
"adwaita",
|
|
10
|
+
"gnome",
|
|
10
11
|
"react",
|
|
11
12
|
"components",
|
|
12
13
|
"linux",
|
|
@@ -52,18 +53,20 @@
|
|
|
52
53
|
"node": ">=26.7.0"
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
|
-
"@gtkx/react": "2.0.0-beta.
|
|
56
|
-
"@gtkx/runtime": "2.0.0-beta.
|
|
57
|
-
"@gtkx/utils": "2.0.0-beta.
|
|
56
|
+
"@gtkx/react": "2.0.0-beta.11",
|
|
57
|
+
"@gtkx/runtime": "2.0.0-beta.11",
|
|
58
|
+
"@gtkx/utils": "2.0.0-beta.11"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
|
-
"react": "^19.
|
|
61
|
+
"@types/react": "^19.3",
|
|
62
|
+
"react": "^19.3"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
|
-
"@gtkx/config": "2.0.0-beta.
|
|
64
|
-
"@gtkx/testing": "2.0.0-beta.
|
|
65
|
-
"@gtkx/vitest": "2.0.0-beta.
|
|
66
|
-
"
|
|
65
|
+
"@gtkx/config": "2.0.0-beta.11",
|
|
66
|
+
"@gtkx/testing": "2.0.0-beta.11",
|
|
67
|
+
"@gtkx/vitest": "2.0.0-beta.11",
|
|
68
|
+
"@types/react": "^19.3.0",
|
|
69
|
+
"vitest": "^5.0.1"
|
|
67
70
|
},
|
|
68
71
|
"scripts": {
|
|
69
72
|
"release": "tsx ../../scripts/release-package.ts"
|
package/src/column-view.tsx
CHANGED
|
@@ -3,15 +3,17 @@ import * as Gtk from "@gtkx/gi/gtk";
|
|
|
3
3
|
import { GtkColumnView, GtkColumnViewColumn, GtkCustomSorter, GtkSignalListItemFactory } from "@gtkx/jsx/gtk";
|
|
4
4
|
import { useSignal } from "@gtkx/react";
|
|
5
5
|
import { omit } from "@gtkx/utils";
|
|
6
|
-
import {
|
|
6
|
+
import { useMemo, useRef } from "react";
|
|
7
7
|
import type { CellSize } from "./internal/cells.js";
|
|
8
8
|
import type { Collection } from "./internal/collection.js";
|
|
9
9
|
import type { ColumnViewColumn, ColumnViewProps, ExpanderDescriptions, SortProps } from "./types.js";
|
|
10
10
|
import { ItemPortals, useItemCells, useRowProps, useSectionHeader } from "./internal/cells.js";
|
|
11
|
+
import { useControlledSync } from "./internal/controlled-sync.js";
|
|
11
12
|
import { useCollection } from "./internal/use-collection.js";
|
|
12
13
|
import { useWidgetRef } from "./internal/use-widget-ref.js";
|
|
13
14
|
|
|
14
15
|
type SortTarget = { view: Gtk.ColumnView; column: Gtk.ColumnViewColumn | null };
|
|
16
|
+
type SortRequest = Pick<SortProps, "sortColumn" | "sortOrder">;
|
|
15
17
|
|
|
16
18
|
type ColumnCellsProps = {
|
|
17
19
|
column: ColumnViewColumn<never>;
|
|
@@ -29,6 +31,7 @@ type ColumnListProps = Omit<ColumnCellsProps, "column" | "hasExpander"> & {
|
|
|
29
31
|
const COLUMN_VIEW_PROPS = [
|
|
30
32
|
"items",
|
|
31
33
|
"sections",
|
|
34
|
+
"isFlat",
|
|
32
35
|
"renderHeader",
|
|
33
36
|
"rowProps",
|
|
34
37
|
"columns",
|
|
@@ -42,7 +45,6 @@ const COLUMN_VIEW_PROPS = [
|
|
|
42
45
|
"sortOrder",
|
|
43
46
|
"onSortChanged",
|
|
44
47
|
"estimatedItemHeight",
|
|
45
|
-
"children",
|
|
46
48
|
"ref",
|
|
47
49
|
] as const satisfies (keyof ColumnViewProps)[];
|
|
48
50
|
|
|
@@ -92,16 +94,18 @@ const applySort = (
|
|
|
92
94
|
}
|
|
93
95
|
};
|
|
94
96
|
|
|
95
|
-
const
|
|
97
|
+
const didEmitSortChanged = (
|
|
96
98
|
sorter: Gtk.ColumnViewSorter | null,
|
|
97
99
|
sorting: RefObject<boolean>,
|
|
98
100
|
sort: SortProps,
|
|
99
|
-
):
|
|
101
|
+
): boolean => {
|
|
100
102
|
if (sorter === null || sorting.current) {
|
|
101
|
-
return;
|
|
103
|
+
return false;
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
sort.onSortChanged?.(sorter.getPrimarySortColumn()?.getId() ?? null, sorter.getPrimarySortOrder());
|
|
107
|
+
|
|
108
|
+
return true;
|
|
105
109
|
};
|
|
106
110
|
|
|
107
111
|
const syncSort = (
|
|
@@ -123,16 +127,24 @@ const useColumnSorting = (view: Gtk.ColumnView | null, sort: SortProps, columns:
|
|
|
123
127
|
const sorting = useRef(false);
|
|
124
128
|
const sorter = view?.getSorter() ?? null;
|
|
125
129
|
const columnSorter = sorter instanceof Gtk.ColumnViewSorter ? sorter : null;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
const { sortColumn, sortOrder } = sort;
|
|
131
|
+
const request = useMemo<SortRequest>(() => ({ sortColumn, sortOrder }), [sortColumn, sortOrder]);
|
|
132
|
+
const markDrift = useControlledSync({
|
|
133
|
+
value: request,
|
|
134
|
+
source: columns,
|
|
135
|
+
target: view,
|
|
136
|
+
apply: (value) => {
|
|
137
|
+
syncSort(sorting, view, value.sortColumn, value.sortOrder);
|
|
138
|
+
},
|
|
129
139
|
});
|
|
130
140
|
|
|
131
|
-
|
|
141
|
+
useSignal(columnSorter, "changed", (): void => {
|
|
142
|
+
const didEmit = didEmitSortChanged(columnSorter, sorting, sort);
|
|
132
143
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
if (sortColumn !== undefined && didEmit) {
|
|
145
|
+
markDrift();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
136
148
|
};
|
|
137
149
|
|
|
138
150
|
const ColumnCells = ({
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,9 @@ export { ColumnView } from "./column-view.js";
|
|
|
2
2
|
export { ComboRow } from "./combo-row.js";
|
|
3
3
|
export { DropDown } from "./drop-down.js";
|
|
4
4
|
export { GridView } from "./grid-view.js";
|
|
5
|
+
export { ListItemFactory } from "./list-item-factory.js";
|
|
5
6
|
export { ListView } from "./list-view.js";
|
|
6
|
-
export { ToastProvider, useToast
|
|
7
|
+
export { ToastProvider, useToast } from "./toast.js";
|
|
7
8
|
export type {
|
|
8
9
|
ColumnViewColumn,
|
|
9
10
|
ColumnViewProps,
|
|
@@ -12,6 +13,7 @@ export type {
|
|
|
12
13
|
ExpanderDescriptions,
|
|
13
14
|
GridViewProps,
|
|
14
15
|
ListItem,
|
|
16
|
+
ListItemFactoryProps,
|
|
15
17
|
ListItemRenderArgs,
|
|
16
18
|
ListItemRenderer,
|
|
17
19
|
ListRowProps,
|
|
@@ -22,6 +24,5 @@ export type {
|
|
|
22
24
|
ListViewProps,
|
|
23
25
|
ToastController,
|
|
24
26
|
ToastOptions,
|
|
25
|
-
ToastOverlayController,
|
|
26
27
|
ToastProviderProps,
|
|
27
28
|
} from "./types.js";
|