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