@gjsify/adwaita-core 0.31.0 → 0.33.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 (124) 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/spinner.js +1 -0
  27. package/lib/esm/conformance/split-button.js +1 -0
  28. package/lib/esm/conformance/split-view.js +1 -0
  29. package/lib/esm/conformance/tab-view.js +1 -0
  30. package/lib/esm/conformance/view-stack.js +1 -0
  31. package/lib/esm/conformance/view-switcher.js +1 -0
  32. package/lib/esm/conformance/wrap-box.js +1 -0
  33. package/lib/esm/data-grid.js +1 -0
  34. package/lib/esm/dialog.js +1 -1
  35. package/lib/esm/easing.js +1 -0
  36. package/lib/esm/entry-row.js +1 -0
  37. package/lib/esm/glib.js +1 -0
  38. package/lib/esm/index.js +1 -1
  39. package/lib/esm/length-unit.js +1 -0
  40. package/lib/esm/navigation-view.js +1 -0
  41. package/lib/esm/popover.js +1 -0
  42. package/lib/esm/preferences.js +1 -0
  43. package/lib/esm/rows.js +1 -1
  44. package/lib/esm/sidebar.js +1 -0
  45. package/lib/esm/spinner.js +1 -0
  46. package/lib/esm/split-button.js +1 -0
  47. package/lib/esm/split-view.js +1 -0
  48. package/lib/esm/tab-view.js +1 -0
  49. package/lib/esm/view-stack.js +1 -0
  50. package/lib/esm/view-switcher.js +1 -0
  51. package/lib/esm/wrap-box.js +1 -0
  52. package/lib/types/about-dialog.d.ts +391 -0
  53. package/lib/types/about-dialog.spec.d.ts +2 -0
  54. package/lib/types/action-row.d.ts +270 -0
  55. package/lib/types/action-row.spec.d.ts +2 -0
  56. package/lib/types/avatar.d.ts +112 -0
  57. package/lib/types/avatar.spec.d.ts +2 -0
  58. package/lib/types/banner.d.ts +104 -0
  59. package/lib/types/banner.spec.d.ts +2 -0
  60. package/lib/types/button-content.d.ts +141 -0
  61. package/lib/types/button-content.spec.d.ts +2 -0
  62. package/lib/types/carousel.d.ts +535 -0
  63. package/lib/types/carousel.spec.d.ts +2 -0
  64. package/lib/types/checks.d.ts +63 -0
  65. package/lib/types/checks.spec.d.ts +2 -0
  66. package/lib/types/chrome.d.ts +355 -0
  67. package/lib/types/chrome.spec.d.ts +2 -0
  68. package/lib/types/conformance/about-dialog.d.ts +314 -0
  69. package/lib/types/conformance/action-row.d.ts +186 -0
  70. package/lib/types/conformance/avatar.d.ts +61 -0
  71. package/lib/types/conformance/banner.d.ts +91 -0
  72. package/lib/types/conformance/button-content.d.ts +110 -0
  73. package/lib/types/conformance/carousel.d.ts +298 -0
  74. package/lib/types/conformance/checks.d.ts +29 -0
  75. package/lib/types/conformance/chrome.d.ts +207 -0
  76. package/lib/types/conformance/data-grid.d.ts +136 -0
  77. package/lib/types/conformance/dialog.d.ts +97 -0
  78. package/lib/types/conformance/entry-row.d.ts +187 -0
  79. package/lib/types/conformance/index.d.ts +46 -0
  80. package/lib/types/conformance/navigation-view.d.ts +235 -0
  81. package/lib/types/conformance/popover.d.ts +58 -0
  82. package/lib/types/conformance/preferences.d.ts +184 -0
  83. package/lib/types/conformance/rows.d.ts +74 -0
  84. package/lib/types/conformance/sidebar.d.ts +182 -0
  85. package/lib/types/conformance/spinner.d.ts +66 -0
  86. package/lib/types/conformance/split-button.d.ts +193 -0
  87. package/lib/types/conformance/split-view.d.ts +301 -0
  88. package/lib/types/conformance/tab-view.d.ts +449 -0
  89. package/lib/types/conformance/view-stack.d.ts +121 -0
  90. package/lib/types/conformance/view-switcher.d.ts +443 -0
  91. package/lib/types/conformance/wrap-box.d.ts +185 -0
  92. package/lib/types/data-grid.d.ts +140 -0
  93. package/lib/types/data-grid.spec.d.ts +2 -0
  94. package/lib/types/dialog.d.ts +144 -0
  95. package/lib/types/easing.d.ts +21 -0
  96. package/lib/types/entry-row.d.ts +308 -0
  97. package/lib/types/entry-row.spec.d.ts +2 -0
  98. package/lib/types/glib.d.ts +49 -0
  99. package/lib/types/index.d.ts +50 -4
  100. package/lib/types/length-unit.d.ts +24 -0
  101. package/lib/types/navigation-view.d.ts +343 -0
  102. package/lib/types/navigation-view.spec.d.ts +2 -0
  103. package/lib/types/popover.d.ts +155 -0
  104. package/lib/types/popover.spec.d.ts +2 -0
  105. package/lib/types/preferences.d.ts +349 -0
  106. package/lib/types/preferences.spec.d.ts +2 -0
  107. package/lib/types/rows.d.ts +96 -8
  108. package/lib/types/sidebar.d.ts +308 -0
  109. package/lib/types/sidebar.spec.d.ts +2 -0
  110. package/lib/types/spinner.d.ts +117 -0
  111. package/lib/types/spinner.spec.d.ts +2 -0
  112. package/lib/types/split-button.d.ts +316 -0
  113. package/lib/types/split-button.spec.d.ts +2 -0
  114. package/lib/types/split-view.d.ts +703 -0
  115. package/lib/types/split-view.spec.d.ts +2 -0
  116. package/lib/types/tab-view.d.ts +616 -0
  117. package/lib/types/tab-view.spec.d.ts +2 -0
  118. package/lib/types/view-stack.d.ts +278 -0
  119. package/lib/types/view-stack.spec.d.ts +2 -0
  120. package/lib/types/view-switcher.d.ts +524 -0
  121. package/lib/types/view-switcher.spec.d.ts +2 -0
  122. package/lib/types/wrap-box.d.ts +200 -0
  123. package/lib/types/wrap-box.spec.d.ts +2 -0
  124. package/package.json +8 -4
@@ -0,0 +1,278 @@
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
+ /** `AdwViewStackPage:badge-number`. Defaults to 0 — no badge. */
23
+ badgeNumber?: number;
24
+ /** `AdwViewStackPage:needs-attention`. Defaults to `false`. */
25
+ needsAttention?: boolean;
26
+ /** `AdwViewStackPage:use-underline`. Defaults to `false`. */
27
+ useUnderline?: boolean;
28
+ }
29
+ /**
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.
36
+ */
37
+ export interface AdwViewStackPageInfo<T = unknown> {
38
+ /** Stable id used by `visible-child-name` and by a bound switcher. */
39
+ readonly name: string;
40
+ /** Human-facing title, already resolved against `name`. */
41
+ readonly title: string;
42
+ /** Normalized GTK icon name, `''` when the page has none. */
43
+ readonly icon: string;
44
+ /** The renderer's page node, `undefined` for a headless page. */
45
+ readonly content: T | undefined;
46
+ /** Whether the page can be selected — `AdwViewStackPage:visible`. */
47
+ readonly visible: boolean;
48
+ /** `AdwViewStackPage:badge-number`. 0 means no badge. */
49
+ readonly badgeNumber: number;
50
+ /** `AdwViewStackPage:needs-attention` — the bare dot, with or without a badge. */
51
+ readonly needsAttention: boolean;
52
+ /** `AdwViewStackPage:use-underline` — whether the title carries a mnemonic. */
53
+ readonly useUnderline: boolean;
54
+ }
55
+ /** Payload of a selection change. */
56
+ export interface ViewStackStateChange<T = unknown> {
57
+ /** Index of the newly-visible page, `-1` when nothing is selected. */
58
+ index: number;
59
+ /** Its name, `''` when nothing is selected. */
60
+ name: string;
61
+ /** Its title, `''` when nothing is selected. */
62
+ title: string;
63
+ /** Its descriptor, `undefined` when nothing is selected. */
64
+ page: AdwViewStackPageInfo<T> | undefined;
65
+ /**
66
+ * `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.
71
+ */
72
+ interactive: boolean;
73
+ }
74
+ /** Subscriber for {@link ViewStackState} changes. */
75
+ export type ViewStackStateListener<T = unknown> = (change: ViewStackStateChange<T>) => void;
76
+ /**
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.
85
+ */
86
+ export declare function resolvePageTitle(title: string | null | undefined, name: string): string;
87
+ /**
88
+ * A GTK icon name reduced to its renderer-neutral form: `''` for absent or
89
+ * unusable, and a single anchored `-symbolic` suffix stripped.
90
+ *
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.
95
+ *
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.
109
+ */
110
+ export declare function normalizeIconName(icon: string | null | undefined): string;
111
+ /**
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.
118
+ */
119
+ export declare class ViewStackState<T = unknown> {
120
+ private readonly _pages;
121
+ private _visibleIndex;
122
+ private readonly _listeners;
123
+ private readonly _diagnostics;
124
+ /** Cached frozen projection of {@link pages}; dropped on any structural change. */
125
+ private _pagesView;
126
+ /** Subscribe to selection changes. Returns an unsubscribe function. */
127
+ subscribe(listener: ViewStackStateListener<T>): () => void;
128
+ private _emit;
129
+ /** Bounds-safe lookup — indexing is not enough, `_visibleIndex` is `-1` when empty. */
130
+ private _pageAt;
131
+ /** `set_visible_child (self, NULL)`'s scan for the first VISIBLE page (adw-view-stack.c:961-974). */
132
+ private _firstVisibleIndex;
133
+ private _record;
134
+ /** All pages in add order — a frozen projection, so a switcher cannot mutate the model. */
135
+ get pages(): readonly AdwViewStackPageInfo<T>[];
136
+ /** Number of pages — `adw_view_stack_pages_get_n_items` (adw-view-stack.c:582-588). */
137
+ get count(): number;
138
+ /**
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 `===`.
143
+ */
144
+ indexOfName(name: string): number;
145
+ /**
146
+ * 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.
149
+ */
150
+ isSelected(position: number): boolean;
151
+ /**
152
+ * Append a page and return its descriptor.
153
+ *
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}.
160
+ */
161
+ addPage(spec: AdwViewStackPageSpec<T>): AdwViewStackPageInfo<T>;
162
+ /**
163
+ * Insert a page at `position`, or `null` when `position` is not an integer in
164
+ * `[0, count]`.
165
+ *
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).
175
+ *
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.
179
+ */
180
+ insertPage(spec: AdwViewStackPageSpec<T>, position: number): AdwViewStackPageInfo<T> | null;
181
+ private _insertRecord;
182
+ /**
183
+ * Move the page at `from` to index `to`, keeping the SELECTION on whichever
184
+ * page it was already on. Returns whether anything moved.
185
+ *
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.
191
+ *
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.
195
+ */
196
+ movePage(from: number, to: number): boolean;
197
+ /**
198
+ * Remove the first page named `name`. Returns whether anything was removed.
199
+ *
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.
206
+ */
207
+ removePage(name: string): boolean;
208
+ /** Index of the visible page, `-1` when none — distinct from "page 0 is selected". */
209
+ get visibleIndex(): number;
210
+ /**
211
+ * Select by index. Returns whether the selection changed.
212
+ *
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.
220
+ */
221
+ setVisibleIndex(index: number, interactive?: boolean): boolean;
222
+ /** Name of the visible page, `''` when none — C returns NULL (adw-view-stack.c:2379-2385). */
223
+ get visibleName(): string;
224
+ /**
225
+ * Select by name. Returns whether the selection changed.
226
+ *
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
232
+ * special-cases only NULL.
233
+ */
234
+ setVisibleName(name: string | null | undefined, interactive?: boolean): boolean;
235
+ /** The visible page's descriptor, or `undefined` — renderers read `.content` off it. */
236
+ get visiblePage(): AdwViewStackPageInfo<T> | undefined;
237
+ /** Title of the visible page, `''` when none — what a header bar mirrors. */
238
+ get visibleTitle(): string;
239
+ /**
240
+ * Flip a page's `visible` flag. Returns whether the SELECTION moved (not
241
+ * whether the flag changed) — the renderer already knows it asked for the
242
+ * flip; what it cannot derive is the fallback.
243
+ *
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.
250
+ *
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.
258
+ */
259
+ setPageVisible(name: string, visible: boolean): boolean;
260
+ /**
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.
269
+ */
270
+ get duplicateNames(): readonly string[];
271
+ /**
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.
276
+ */
277
+ get diagnostics(): readonly string[];
278
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;