@gjsify/adwaita-core 0.36.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/lib/esm/accent.js +1 -0
  2. package/lib/esm/conformance/accent.js +1 -0
  3. package/lib/esm/conformance/index.js +1 -1
  4. package/lib/esm/conformance/shortcut-label.js +1 -0
  5. package/lib/esm/index.js +1 -1
  6. package/lib/esm/shortcut-label.js +1 -0
  7. package/lib/types/about-dialog.d.ts +92 -98
  8. package/lib/types/accent.d.ts +36 -0
  9. package/lib/types/accent.spec.d.ts +2 -0
  10. package/lib/types/action-row.d.ts +95 -125
  11. package/lib/types/avatar.d.ts +30 -37
  12. package/lib/types/banner.d.ts +25 -53
  13. package/lib/types/breakpoint.d.ts +6 -7
  14. package/lib/types/button-content.d.ts +41 -80
  15. package/lib/types/carousel.d.ts +175 -252
  16. package/lib/types/checks.d.ts +13 -30
  17. package/lib/types/chrome.d.ts +90 -136
  18. package/lib/types/color-scheme.d.ts +5 -6
  19. package/lib/types/conformance/about-dialog.d.ts +64 -91
  20. package/lib/types/conformance/accent.d.ts +20 -0
  21. package/lib/types/conformance/action-row.d.ts +26 -46
  22. package/lib/types/conformance/avatar.d.ts +8 -10
  23. package/lib/types/conformance/banner.d.ts +17 -37
  24. package/lib/types/conformance/button-content.d.ts +24 -46
  25. package/lib/types/conformance/carousel.d.ts +35 -75
  26. package/lib/types/conformance/checks.d.ts +0 -4
  27. package/lib/types/conformance/chrome.d.ts +28 -36
  28. package/lib/types/conformance/data-grid.d.ts +28 -47
  29. package/lib/types/conformance/dialog.d.ts +4 -9
  30. package/lib/types/conformance/entry-row.d.ts +20 -39
  31. package/lib/types/conformance/index.d.ts +4 -0
  32. package/lib/types/conformance/navigation-view.d.ts +0 -4
  33. package/lib/types/conformance/popover.d.ts +4 -9
  34. package/lib/types/conformance/preferences.d.ts +15 -28
  35. package/lib/types/conformance/rows.d.ts +5 -12
  36. package/lib/types/conformance/shortcut-label.d.ts +34 -0
  37. package/lib/types/conformance/sidebar.d.ts +28 -49
  38. package/lib/types/conformance/spinner.d.ts +21 -27
  39. package/lib/types/conformance/split-button.d.ts +21 -43
  40. package/lib/types/conformance/split-view.d.ts +29 -36
  41. package/lib/types/conformance/tab-view.d.ts +32 -73
  42. package/lib/types/conformance/view-stack.d.ts +0 -12
  43. package/lib/types/conformance/view-switcher.d.ts +46 -114
  44. package/lib/types/conformance/wrap-box.d.ts +40 -63
  45. package/lib/types/data-grid.d.ts +38 -48
  46. package/lib/types/dialog.d.ts +39 -51
  47. package/lib/types/easing.d.ts +6 -12
  48. package/lib/types/entry-row.d.ts +94 -123
  49. package/lib/types/glib.d.ts +17 -25
  50. package/lib/types/index.d.ts +4 -0
  51. package/lib/types/length-unit.d.ts +7 -12
  52. package/lib/types/navigation-view.d.ts +62 -68
  53. package/lib/types/popover.d.ts +39 -66
  54. package/lib/types/preferences.d.ts +83 -100
  55. package/lib/types/rows.d.ts +45 -63
  56. package/lib/types/shortcut-label.d.ts +79 -0
  57. package/lib/types/shortcut-label.spec.d.ts +2 -0
  58. package/lib/types/sidebar.d.ts +95 -121
  59. package/lib/types/spinner.d.ts +39 -61
  60. package/lib/types/split-button.d.ts +78 -134
  61. package/lib/types/split-view.d.ts +74 -89
  62. package/lib/types/tab-view.d.ts +174 -256
  63. package/lib/types/view-stack.d.ts +87 -129
  64. package/lib/types/view-switcher.d.ts +126 -211
  65. package/lib/types/wrap-box.d.ts +62 -123
  66. package/package.json +3 -3
@@ -1,12 +1,9 @@
1
1
  /**
2
- * Input shape for a page.
3
- *
4
- * `title` omitted falls back to `name` ({@link resolvePageTitle} — a deliberate
5
- * deviation from `add_internal`, adw-view-stack.c:1170-1172, which leaves the
6
- * title NULL); `icon` is a GTK icon NAME (`PAGE_PROP_ICON_NAME`, :393-396)
7
- * normalized by {@link normalizeIconName}; `visible` defaults to `true`
8
- * (`adw_view_stack_page_init`, :475-479). `content` is the renderer's opaque
9
- * node — an `HTMLElement` on web, a NativeScript `View` on NS.
2
+ * Input shape for a page. `title` omitted falls back to `name`
3
+ * ({@link resolvePageTitle}, a deliberate deviation from `add_internal`, which leaves
4
+ * the title NULL); `icon` is a GTK icon NAME normalized by
5
+ * {@link normalizeIconName}; `visible` defaults to `true`. `content` is the
6
+ * renderer's opaque node — an `HTMLElement` on web, a NativeScript `View` on NS.
10
7
  */
11
8
  export interface AdwViewStackPageSpec<T = unknown> {
12
9
  /** Stable id used by `visible-child-name` and by a bound switcher. */
@@ -27,12 +24,10 @@ export interface AdwViewStackPageSpec<T = unknown> {
27
24
  useUnderline?: boolean;
28
25
  }
29
26
  /**
30
- * A resolved page descriptor, as a bound switcher reads it.
31
- *
32
- * `title` and `icon` are already normalized so no renderer repeats the fallback,
33
- * and `icon` is `''` when absent — never `undefined`, which is what the web
34
- * switcher bar's `page.icon.length` has always assumed and the NS port used to
35
- * violate.
27
+ * A resolved page descriptor, as a bound switcher reads it. `title` and `icon` are
28
+ * already normalized so no renderer repeats the fallback, and `icon` is `''` when
29
+ * absent — never `undefined`, which switcher code that reads `page.icon.length`
30
+ * relies on.
36
31
  */
37
32
  export interface AdwViewStackPageInfo<T = unknown> {
38
33
  /** Stable id used by `visible-child-name` and by a bound switcher. */
@@ -64,57 +59,42 @@ export interface ViewStackStateChange<T = unknown> {
64
59
  page: AdwViewStackPageInfo<T> | undefined;
65
60
  /**
66
61
  * `true` for an explicit {@link ViewStackState.setVisibleIndex} /
67
- * {@link ViewStackState.setVisibleName}; `false` for an auto-pick from
68
- * `addPage` / `setPageVisible`. libadwaita notifies on BOTH
69
- * (adw-view-stack.c:1038-1039) — the flag exists so a switcher can suppress
70
- * its own feedback loop, not so a renderer can drop the notification.
62
+ * {@link ViewStackState.setVisibleName}, `false` for an auto-pick from `addPage` /
63
+ * `setPageVisible`. libadwaita notifies on BOTH — the flag lets a switcher suppress
64
+ * its own feedback loop, not a renderer drop the notification.
71
65
  */
72
66
  interactive: boolean;
73
67
  }
74
68
  /** Subscriber for {@link ViewStackState} changes. */
75
69
  export type ViewStackStateListener<T = unknown> = (change: ViewStackStateChange<T>) => void;
76
70
  /**
77
- * The title a page renders with: `title` when given, else the page `name`.
78
- *
79
- * Pinned as a named function precisely because it is a DEVIATION from C —
80
- * `add_internal` (adw-view-stack.c:1170-1172) stores a NULL title and a native
81
- * `AdwViewSwitcher` then renders no label. Both ports independently chose the
82
- * name fallback; this makes it ONE documented decision instead of two
83
- * coincidentally-identical `title ?? name` expressions. An explicitly empty
84
- * title stays empty — only an absent one falls back.
71
+ * The title a page renders with: `title` when given, else the page `name`. A named
72
+ * function because it is a DEVIATION from C, where `add_internal` stores a NULL title
73
+ * and a native `AdwViewSwitcher` then renders no label. An explicitly empty title
74
+ * stays empty — only an absent one falls back.
85
75
  */
86
76
  export declare function resolvePageTitle(title: string | null | undefined, name: string): string;
87
77
  /**
88
- * A GTK icon name reduced to its renderer-neutral form: `''` for absent or
89
- * unusable, and a single anchored `-symbolic` suffix stripped.
78
+ * A GTK icon name reduced to its renderer-neutral form: `''` for absent or unusable,
79
+ * and a single anchored `-symbolic` suffix stripped. The strip is end-anchored and
80
+ * applied ONCE, so `go-symbolic-next` survives intact and `go-next-symbolic-symbolic`
81
+ * loses only the last suffix.
90
82
  *
91
- * `AdwViewStackPage:icon-name` is a NAME string (adw-view-stack.c:393-396,
92
- * :1887-1912), not markup. The strip is end-anchored and applied ONCE, so
93
- * `go-symbolic-next` survives intact and `go-next-symbolic-symbolic` loses only
94
- * the last suffix.
83
+ * The token guard belongs HERE, not in each caller: a name that is not one token
84
+ * cannot be one CSS class, and interpolating `icon-name="a b"` into
85
+ * `.adw-icon--<name>` injected a stray `b` class onto the icon node. Unusable names
86
+ * resolve to "no icon" so the renderer's absent-icon path takes over.
95
87
  *
96
- * THE TOKEN GUARD IS PART OF THE NORMALIZATION, not the caller's job. It had
97
- * been written exactly once — in `<adw-split-button>` — while the other 22
98
- * `.adw-icon--<name>` construction sites in `@gjsify/adwaita-web` built the
99
- * class without it, so `icon-name="a b"` interpolated into
100
- * `class="adw-icon adw-icon--a b"` and injected a stray `b` class onto the icon
101
- * node. That was live on `<adw-menu-button>`, for its own icon AND for every
102
- * JSON menu entry's. A name that cannot be one token cannot be one class, so it
103
- * resolves to "no icon" and the renderer's absent-icon path takes over.
104
- *
105
- * Consequence worth knowing: a reverse-DNS APPLICATION icon name
106
- * (`org.gnome.Builder`) is not a token and normalizes to `''`. It never had a
107
- * mask class either — `.adw-icon--org.gnome.Builder` parses as three classes —
108
- * so this turns a silently blank icon into an explicitly absent one.
88
+ * Consequence: a reverse-DNS APPLICATION icon name (`org.gnome.Builder`) is not a
89
+ * token and normalizes to `''` — it never had a mask class either, since
90
+ * `.adw-icon--org.gnome.Builder` parses as three classes.
109
91
  */
110
92
  export declare function normalizeIconName(icon: string | null | undefined): string;
111
93
  /**
112
- * The ordered page list of an `Adw.ViewStack` plus its visible-child selection,
113
- * with the C guard / ordering / fallback rules applied once for every renderer.
114
- *
115
- * `T` is the renderer's page-content type; the state machine never looks inside
116
- * it. Nothing here is a timer or a global, so an instance is a plain value a
117
- * test can drive step by step.
94
+ * The ordered page list of an `Adw.ViewStack` plus its visible-child selection, with
95
+ * the C guard / ordering / fallback rules applied once for every renderer. `T` is the
96
+ * renderer's page-content type; the state machine never looks inside it, and holds no
97
+ * timer or global, so an instance is a plain value a test can drive step by step.
118
98
  */
119
99
  export declare class ViewStackState<T = unknown> {
120
100
  private readonly _pages;
@@ -128,54 +108,45 @@ export declare class ViewStackState<T = unknown> {
128
108
  private _emit;
129
109
  /** Bounds-safe lookup — indexing is not enough, `_visibleIndex` is `-1` when empty. */
130
110
  private _pageAt;
131
- /** `set_visible_child (self, NULL)`'s scan for the first VISIBLE page (adw-view-stack.c:961-974). */
111
+ /** `set_visible_child (self, NULL)`'s scan for the first VISIBLE page. */
132
112
  private _firstVisibleIndex;
133
113
  private _record;
134
114
  /** All pages in add order — a frozen projection, so a switcher cannot mutate the model. */
135
115
  get pages(): readonly AdwViewStackPageInfo<T>[];
136
- /** Number of pages — `adw_view_stack_pages_get_n_items` (adw-view-stack.c:582-588). */
116
+ /** Number of pages — `adw_view_stack_pages_get_n_items`. */
137
117
  get count(): number;
138
118
  /**
139
- * Index of the FIRST page named `name`, or `-1` — `find_page_for_name`
140
- * (adw-view-stack.c:891-906). An exact, unnormalized compare: `g_strcmp0`
141
- * walks UTF-8 bytes, so the NFC and NFD spellings of a name are different
142
- * names in C exactly as they are under JS `===`.
119
+ * Index of the FIRST page named `name`, or `-1` — `find_page_for_name`. An exact,
120
+ * unnormalized compare: `g_strcmp0` walks UTF-8 bytes, so the NFC and NFD spellings
121
+ * of a name are different names in C exactly as they are under JS `===`.
143
122
  */
144
123
  indexOfName(name: string): number;
145
124
  /**
146
125
  * Whether the page at `position` is the selected one —
147
- * `adw_view_stack_pages_is_selected` (adw-view-stack.c:659-672). An
148
- * out-of-range position is simply not selected, never an error.
126
+ * `adw_view_stack_pages_is_selected`. An out-of-range position is simply not
127
+ * selected, never an error.
149
128
  */
150
129
  isSelected(position: number): boolean;
151
130
  /**
152
131
  * Append a page and return its descriptor.
153
132
  *
154
- * Selects it only when nothing is selected yet AND the page is visible
155
- * (`add_page`, adw-view-stack.c:1149-1151), notifying `interactive: false`
156
- * — which is what C does (:1038-1039) and what both ports skipped, forcing
157
- * every bound switcher to call `refresh()` by hand. A duplicate name is
158
- * accepted (C warns but still adds, :1115-1126 + :1136) and recorded in
159
- * {@link duplicateNames}.
133
+ * Selects it only when nothing is selected yet AND the page is visible (`add_page`),
134
+ * notifying with `interactive: false` as C does. A duplicate name is accepted (C
135
+ * warns but still adds) and recorded in {@link duplicateNames}.
160
136
  */
161
137
  addPage(spec: AdwViewStackPageSpec<T>): AdwViewStackPageInfo<T>;
162
138
  /**
163
139
  * Insert a page at `position`, or `null` when `position` is not an integer in
164
140
  * `[0, count]`.
165
141
  *
166
- * `Adw.ViewStack` has no insert-at-position API of its own — this is the
167
- * generalisation of {@link addPage}, which is now `insertPage(spec, count)`,
168
- * so there is ONE insertion path rather than two that can drift. It exists
169
- * because `Adw.TabView` is an ordered page list with the same
170
- * selection-follows-the-page semantics and needs it: `attach_page` is
171
- * literally `g_list_store_insert (self->children, position, page)`
172
- * (adw-tab-view.c:1748), and `insert_page` then auto-selects the new page
173
- * when nothing is selected (:1953-1954) — the same rule `add_page` applies
174
- * here (adw-view-stack.c:1149-1151).
142
+ * `Adw.ViewStack` has no insert-at-position API of its own; this is the
143
+ * generalisation of {@link addPage} (now `insertPage(spec, count)`) that
144
+ * `Adw.TabView` needs, whose `attach_page` is `g_list_store_insert` plus the same
145
+ * auto-select-when-nothing-is-selected rule.
175
146
  *
176
- * Inserting BEFORE the current selection shifts that selection's index up by
177
- * one and notifies nothing: C holds a page pointer, so the selected page is
178
- * unchanged and only its position moved.
147
+ * Inserting BEFORE the current selection shifts that selection's index up by one and
148
+ * notifies nothing: C holds a page pointer, so the selected page is unchanged and
149
+ * only its position moved.
179
150
  */
180
151
  insertPage(spec: AdwViewStackPageSpec<T>, position: number): AdwViewStackPageInfo<T> | null;
181
152
  private _insertRecord;
@@ -183,26 +154,23 @@ export declare class ViewStackState<T = unknown> {
183
154
  * Move the page at `from` to index `to`, keeping the SELECTION on whichever
184
155
  * page it was already on. Returns whether anything moved.
185
156
  *
186
- * Remove-then-insert, exactly as `adw_tab_view_reorder_page` does
187
- * (adw-tab-view.c:4553-4556) and as `adw_tab_view_set_page_pinned` does when
188
- * it re-orders a page across the pinned boundary (:4065-4073) — so `to` is an
189
- * index in the list WITHOUT the moved page, which is what makes
190
- * `set_page_pinned`'s `new_pos = n_pinned_pages` land where C lands.
157
+ * Remove-then-insert, as `adw_tab_view_reorder_page` and
158
+ * `adw_tab_view_set_page_pinned` do — so `to` is an index in the list WITHOUT the
159
+ * moved page, which is what makes `set_page_pinned`'s `new_pos = n_pinned_pages` land
160
+ * where C lands.
191
161
  *
192
- * Emits NOTHING: C reorders without ever calling `set_selected_page`, and
193
- * only the list model reports the change (`page-reordered`, :4561). A caller
194
- * that needs to hear about it owns that observable.
162
+ * Emits NOTHING: C reorders without calling `set_selected_page`, and only the list
163
+ * model reports the change (`page-reordered`).
195
164
  */
196
165
  movePage(from: number, to: number): boolean;
197
166
  /**
198
167
  * Remove the first page named `name`. Returns whether anything was removed.
199
168
  *
200
- * When the removed page was the visible one the selection becomes `-1` and
201
- * NOTHING is emitted: `stack_remove` clears `visible_child` directly
202
- * (adw-view-stack.c:1202-1203) and never calls `set_visible_child` on that
203
- * path, so there is no re-pick and no notification. Removing any OTHER page
204
- * keeps the same page selected — C holds a pointer, so the selection follows
205
- * the page and only its index shifts.
169
+ * When the removed page was the visible one the selection becomes `-1` and NOTHING is
170
+ * emitted: `stack_remove` clears `visible_child` directly and never calls
171
+ * `set_visible_child`, so there is no re-pick and no notification. Removing any OTHER
172
+ * page keeps the same page selected — C holds a pointer, so the selection follows the
173
+ * page and only its index shifts.
206
174
  */
207
175
  removePage(name: string): boolean;
208
176
  /** Index of the visible page, `-1` when none — distinct from "page 0 is selected". */
@@ -210,25 +178,22 @@ export declare class ViewStackState<T = unknown> {
210
178
  /**
211
179
  * Select by index. Returns whether the selection changed.
212
180
  *
213
- * Rejects — as a silent no-op that emits nothing — a non-integer, a
214
- * negative, an out-of-range, the already-selected, and a non-`visible`
215
- * index. `Number.isInteger` rather than `Number.isFinite` is the point:
216
- * `adw_view_stack_pages_select_item` takes a `guint` position
217
- * (adw-view-stack.c:675-683), so `1.5` is not a position that can exist —
218
- * both ports used to accept it and blank the entire stack. The hidden-page
219
- * clause is `if (gtk_widget_get_visible (page->widget))` at :2367.
181
+ * Rejects — as a silent no-op that emits nothing — a non-integer, a negative, an
182
+ * out-of-range, the already-selected and a non-`visible` index. `Number.isInteger`
183
+ * rather than `Number.isFinite` is the point: `adw_view_stack_pages_select_item` takes
184
+ * a `guint` position, so `1.5` is not a position that can exist. The hidden-page
185
+ * clause is C's `if (gtk_widget_get_visible (page->widget))`.
220
186
  */
221
187
  setVisibleIndex(index: number, interactive?: boolean): boolean;
222
- /** Name of the visible page, `''` when none — C returns NULL (adw-view-stack.c:2379-2385). */
188
+ /** Name of the visible page, `''` when none — C returns NULL. */
223
189
  get visibleName(): string;
224
190
  /**
225
191
  * Select by name. Returns whether the selection changed.
226
192
  *
227
- * `null`/`undefined` is a SILENT no-op — C returns before the lookup and
228
- * therefore before its warning (adw-view-stack.c:2404-2405). An unknown name
229
- * is a no-op that records a {@link diagnostics} entry (C's `g_warning` at
230
- * :2410). An EMPTY name is a legal lookup that matches a page literally
231
- * named `''`: `find_page_for_name` compares with `g_strcmp0` (:901), which
193
+ * `null`/`undefined` is a SILENT no-op — C returns before the lookup and therefore
194
+ * before its warning. An unknown name is a no-op that records a {@link diagnostics}
195
+ * entry (C's `g_warning`). An EMPTY name is a legal lookup that matches a page
196
+ * literally named `''`: `find_page_for_name` compares with `g_strcmp0`, which
232
197
  * special-cases only NULL.
233
198
  */
234
199
  setVisibleName(name: string | null | undefined, interactive?: boolean): boolean;
@@ -241,38 +206,31 @@ export declare class ViewStackState<T = unknown> {
241
206
  * whether the flag changed) — the renderer already knows it asked for the
242
207
  * flip; what it cannot derive is the fallback.
243
208
  *
244
- * Implements `update_child_visible` (adw-view-stack.c:1061-1082): making a
245
- * page visible while NOTHING is selected selects it (:1069-1070); hiding the
246
- * selected page runs `set_visible_child (self, NULL)`, whose scan takes the
247
- * first still-visible page (:961-974) — and selects nothing, notifying with
248
- * index `-1`, when there is none. Setting the flag to its current value
249
- * returns early, as `adw_view_stack_page_set_visible` does.
209
+ * Implements `update_child_visible`: making a page visible while NOTHING is selected
210
+ * selects it; hiding the selected page runs `set_visible_child (self, NULL)`, whose
211
+ * scan takes the first still-visible page — and selects nothing, notifying with index
212
+ * `-1`, when there is none. Setting the flag to its current value returns early.
250
213
  *
251
- * DEVIATION, deliberate: C keeps TWO flags (`AdwViewStackPage:visible` and
252
- * the child widget's own `gtk_widget_get_visible`) and its NULL-scan
253
- * consults only the widget one, so clearing `page->visible` on a page that
254
- * is FIRST in the list re-picks that same page and returns without
255
- * notifying. A renderer has one notion of "shown", so this collapses to one
256
- * flag — matching C's `gtk_widget_set_visible (child, FALSE)` path, where
257
- * the scan does skip the hidden page.
214
+ * DEVIATION, deliberate: C keeps TWO flags (`AdwViewStackPage:visible` and the child
215
+ * widget's own `gtk_widget_get_visible`) and its NULL-scan consults only the widget
216
+ * one, so clearing `page->visible` on a page that is FIRST in the list re-picks that
217
+ * same page and returns without notifying. A renderer has one notion of "shown", so
218
+ * this collapses to one flag — matching C's `gtk_widget_set_visible (child, FALSE)`
219
+ * path, where the scan does skip the hidden page.
258
220
  */
259
221
  setPageVisible(name: string, visible: boolean): boolean;
260
222
  /**
261
- * Names that occur more than once in the CURRENT page list, in the order
262
- * their first repeat was added.
263
- *
264
- * The mechanism replacing C's `g_warning` (adw-view-stack.c:1122, :1789):
265
- * duplicate names are legal and first-match-wins, but a developer whose
266
- * `visibleChildName` silently resolves to the wrong page needs the class to
267
- * be visible somewhere. Derived from the model rather than logged, so
268
- * removing the duplicate clears it.
223
+ * Names that occur more than once in the CURRENT page list, in the order their first
224
+ * repeat was added — the mechanism replacing C's `g_warning`. Duplicate names are
225
+ * legal and first-match-wins, so a `visibleChildName` that silently resolves to the
226
+ * wrong page needs the class to be visible somewhere. Derived from the model rather
227
+ * than logged, so removing the duplicate clears it.
269
228
  */
270
229
  get duplicateNames(): readonly string[];
271
230
  /**
272
- * Every diagnostic C would have printed as a `g_warning`, in order — the
273
- * unknown-name lookups and the duplicate-name adds. Both ports swallow these
274
- * entirely; keeping them as data lets a test assert on the class instead of
275
- * on stderr.
231
+ * Every diagnostic C would have printed as a `g_warning`, in order — the unknown-name
232
+ * lookups and the duplicate-name adds. Data rather than stderr so a test can assert on
233
+ * the class.
276
234
  */
277
235
  get diagnostics(): readonly string[];
278
236
  }