@gjsify/adwaita-core 0.30.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,308 @@
1
+ /**
2
+ * The "no item is selected" index — the TS mirror of `GTK_INVALID_LIST_POSITION`
3
+ * (`adw_sidebar_init`, adw-sidebar.c:2862).
4
+ *
5
+ * libadwaita spells it `G_MAXUINT` because `AdwSidebar:selected` is a `guint`;
6
+ * `-1` is the idiomatic TS sentinel and, being `G_MAXUINT` mod 2^32, it makes
7
+ * {@link adjustSidebarSelection}'s arithmetic agree with the C code bit for bit.
8
+ */
9
+ export declare const ADW_SIDEBAR_NO_SELECTION = -1;
10
+ /**
11
+ * How a sidebar looks and behaves — `AdwSidebarMode` (adw-sidebar.h).
12
+ *
13
+ * `'sidebar'` is a flat navigation list with a persistent, VISIBLE selection;
14
+ * `'page'` is a page of boxed lists where "the selection is invisible and only
15
+ * tracked to determine the initially selected item once switched back"
16
+ * (adw-sidebar.c:2948-2951). The tracked index is identical in both.
17
+ */
18
+ export type AdwSidebarMode = 'sidebar' | 'page';
19
+ /** One selectable row — the value half of `AdwSidebarItem`. */
20
+ export interface AdwSidebarItemSpec {
21
+ /** Row title. Defaults to `''` in libadwaita (adw-sidebar-item.c:419). */
22
+ title: string;
23
+ /** Optional second line. Absent and `''` are the same thing. */
24
+ subtitle?: string;
25
+ /** Symbolic icon name, e.g. `'folder-symbolic'`. Absent means no icon. */
26
+ iconName?: string;
27
+ /** Whether the row is rendered at all — bound to `row:visible` (adw-sidebar.c:1382). Default true. */
28
+ visible?: boolean;
29
+ /** Whether the row can be activated — bound to `row:sensitive` (adw-sidebar.c:1383). Default true. */
30
+ enabled?: boolean;
31
+ }
32
+ /**
33
+ * A titled group of rows — the value half of `AdwSidebarSection`.
34
+ *
35
+ * An absent or empty title selects the `'separator'` header instead of the
36
+ * `'title'` one (`update_header_page_cb`, adw-sidebar.c:1449-1455).
37
+ */
38
+ export interface AdwSidebarSectionSpec {
39
+ /** Group heading. Absent/empty renders a separator instead. */
40
+ title?: string;
41
+ /** The group's rows, in order. */
42
+ items: readonly AdwSidebarItemSpec[];
43
+ }
44
+ /** One entry of the flattened item model. */
45
+ export interface SidebarFlatItem {
46
+ /**
47
+ * The flat index `adw_sidebar_item_get_index` returns — the section's first
48
+ * index plus the local one (adw-sidebar-item.c:1040). It stays in the
49
+ * UNFILTERED space even when the item came out of a filtered walk, because
50
+ * libadwaita keeps the selection on `items_model` and the row list on
51
+ * `filtered_items` (adw-sidebar.c:2866, :2177-2180).
52
+ */
53
+ index: number;
54
+ /** Index of the owning section. */
55
+ sectionIndex: number;
56
+ /** Index of the item WITHIN its section (`adw_sidebar_item_get_section_index`). */
57
+ sectionItemIndex: number;
58
+ /** The item as declared — same object identity, so `selectedItem === spec` holds. */
59
+ item: AdwSidebarItemSpec;
60
+ /** `string_is_not_empty(title)` — the title label's visibility (adw-sidebar.c:1411-1412). */
61
+ titleVisible: boolean;
62
+ /** `string_is_not_empty(subtitle)` (adw-sidebar.c:1420-1421). */
63
+ subtitleVisible: boolean;
64
+ /** `notify_icon_cb`'s `icon_name && *icon_name` (adw-sidebar.c:1303). */
65
+ iconVisible: boolean;
66
+ }
67
+ /** The header libadwaita draws above one RENDERED section. */
68
+ export interface SidebarHeaderSpec {
69
+ /** Index of the section this header belongs to. */
70
+ sectionIndex: number;
71
+ /** Which page of the header stack shows — `'title'` or `'separator'` (adw-sidebar.c:1449-1455). */
72
+ kind: 'title' | 'separator';
73
+ /** The section title (`''` for a separator header). */
74
+ title: string;
75
+ /** True only for the section owning the FIRST rendered row — the `.first` class (adw-sidebar.c:1526). */
76
+ first: boolean;
77
+ }
78
+ /** Payload of a `notify::selected` re-emit. */
79
+ export interface SidebarSelectionChange {
80
+ /** The new selected index, or {@link ADW_SIDEBAR_NO_SELECTION}. */
81
+ selected: number;
82
+ /** The index it moved away from. */
83
+ previous: number;
84
+ /** `adw_sidebar_get_selected_item` — `undefined` when nothing is selected. */
85
+ item: AdwSidebarItemSpec | undefined;
86
+ /** True only for {@link SidebarState.activate} (a row click); false for programmatic changes. */
87
+ interactive: boolean;
88
+ }
89
+ /** Result of {@link SidebarState.activate}. */
90
+ export interface SidebarActivation {
91
+ /** The index that was clicked, echoed back unchanged. */
92
+ index: number;
93
+ /**
94
+ * Whether a row was actually activated. False when `index` addresses no
95
+ * rendered, enabled row — libadwaita's callbacks run off an existing,
96
+ * sensitive `GtkListBoxRow`, so there is nothing to activate otherwise.
97
+ */
98
+ activated: boolean;
99
+ /** Whether the selection moved. `activated && !selectionChanged` is a re-click of the current row. */
100
+ selectionChanged: boolean;
101
+ }
102
+ /** Per-instance subscriber, same shape as `ComboStateListener` (rows.ts:114). */
103
+ export type SidebarStateListener = (change: SidebarSelectionChange) => void;
104
+ /**
105
+ * The TS stand-in for `GtkFilter` on `AdwSidebar:filter` (adw-sidebar.c:3127).
106
+ *
107
+ * Decides only what is RENDERED and whether the sidebar counts as empty — never
108
+ * the selection index space, which counts the unfiltered model.
109
+ */
110
+ export type SidebarItemFilter = (item: AdwSidebarItemSpec, index: number) => boolean;
111
+ /**
112
+ * The out-of-range rule, and the one all three implementations disagreed on:
113
+ * anything that is not a valid position becomes NO SELECTION — never the
114
+ * nearest in-range index.
115
+ *
116
+ * `adw_sidebar_set_selected` (adw-sidebar.c:3028-3029) is literally
117
+ * `if (selected >= self->n_items) selected = GTK_INVALID_LIST_POSITION;`. A
118
+ * negative input agrees with that for free: as a `guint`, `-7` is `4294967289`,
119
+ * which is `>= n_items` for any real sidebar.
120
+ *
121
+ * Non-integers and `NaN` are rejected rather than truncated. C cannot express
122
+ * them, so there is no ground truth to copy; rejecting is the reading that
123
+ * matches "not a valid position is no position", and it is what stops
124
+ * `sidebar.selected = 1.5` from leaving the NativeScript port highlighting no
125
+ * row while reporting a selection.
126
+ */
127
+ export declare function clampSidebarSelection(index: number, count: number): number;
128
+ /**
129
+ * Where the selection lands after the item model spliced — `items_changed_cb`
130
+ * (adw-sidebar.c:2246-2284), which neither renderer implemented.
131
+ *
132
+ * Four cases, in the C code's order:
133
+ * 1. `0 → n` auto-selects index 0 and notifies (adw-sidebar.c:2270-2273);
134
+ * 2. a splice covering the selected index clears it (adw-sidebar.c:2275-2278);
135
+ * 3. a splice at or before it shifts by `added - removed` (adw-sidebar.c:2280-2283);
136
+ * 4. a splice after it changes nothing.
137
+ *
138
+ * The comparisons run in the UNSIGNED domain (`>>> 0`) because that is where C
139
+ * runs them: with no selection, `selected` is `G_MAXUINT`, so case 2 can never
140
+ * fire and case 3 wraps. That wraparound is REPRODUCED, not repaired — inserting
141
+ * two items above a selection-less sidebar genuinely selects index 1 in GTK, and
142
+ * a renderer that "fixed" it would stop matching the toolkit it mirrors.
143
+ */
144
+ export declare function adjustSidebarSelection(selected: number, oldCount: number, newCount: number, position: number, removed: number, added: number): number;
145
+ /**
146
+ * Flatten the sections into the item model, the way `items_changed_cb`'s section
147
+ * walk does: `set_first_index (section, current); current += get_n_items (section)`
148
+ * (adw-sidebar.c:2261-2267).
149
+ *
150
+ * `sectionFirstIndex[i]` is `adw_sidebar_section_get_first_index` for section
151
+ * `i` — a zero-item section advances nothing, so it shares its successor's index.
152
+ *
153
+ * With a `filter`, `items` is the RENDERED subset while every `index` stays in
154
+ * the unfiltered space; `sectionFirstIndex` is likewise unfiltered.
155
+ */
156
+ export declare function flattenSidebarItems(sections: readonly AdwSidebarSectionSpec[], filter?: SidebarItemFilter | null): {
157
+ items: SidebarFlatItem[];
158
+ sectionFirstIndex: number[];
159
+ };
160
+ /**
161
+ * The headers that actually get drawn, in render order.
162
+ *
163
+ * In sidebar mode a header is a property OF A ROW (`gtk_list_box_row_set_header`,
164
+ * adw-sidebar.c:1563), so a section with no rows contributes none; in page mode
165
+ * the group's `visible` is bound to `filtered n-items > 0` (adw-sidebar.c:1780-1781),
166
+ * which comes to the same thing. Either way it is the sections that RENDER
167
+ * something that produce headers — not the declared section list, which is what
168
+ * the web port used and why an empty leading section drew a stray separator.
169
+ *
170
+ * The section owning the first rendered row gets `first: true`; when that
171
+ * section has no title its header is bound to `string_is_not_empty(title)` and
172
+ * therefore invisible (adw-sidebar.c:1521-1527), so it is omitted entirely.
173
+ */
174
+ export declare function sidebarHeaders(sections: readonly AdwSidebarSectionSpec[], filter?: SidebarItemFilter | null): SidebarHeaderSpec[];
175
+ /**
176
+ * The sidebar state machine both renderers drive.
177
+ *
178
+ * Programmatic changes ({@link setSelected}, {@link setSections},
179
+ * {@link insertSection}, {@link removeSectionAt}, {@link removeAllSections})
180
+ * notify with `interactive: false`; {@link activate} — the row click — notifies
181
+ * with `interactive: true` and applies the selection BEFORE reporting the
182
+ * activation, matching GtkListBox's `row-selected`-then-`row-activated` order
183
+ * (adw-sidebar.c:2188-2191) and page mode's `set_selected`-then-emit
184
+ * (`boxed_row_activated_cb`, adw-sidebar.c:1672-1673).
185
+ */
186
+ export declare class SidebarState {
187
+ private _mode;
188
+ private _sections;
189
+ private _filter;
190
+ private _selected;
191
+ private _items;
192
+ private _sectionFirstIndex;
193
+ private _visibleItems;
194
+ private _headers;
195
+ private readonly _listeners;
196
+ /** Subscribe to selection changes. Returns an unsubscribe function. */
197
+ subscribe(listener: SidebarStateListener): () => void;
198
+ private _emit;
199
+ /** Store an already-derived index; notify only on a real change (adw-sidebar.c:3031-3032). */
200
+ private _applySelected;
201
+ /** Recompute everything derived from `sections` + `filter`. */
202
+ private _invalidate;
203
+ /** The current look/behaviour. Defaults to `'sidebar'` (adw-sidebar.c:2860). */
204
+ get mode(): AdwSidebarMode;
205
+ /**
206
+ * Switch mode. Returns whether it changed — `adw_sidebar_set_mode` early-returns
207
+ * on the current value (adw-sidebar.c:2968-2969). Never touches the selection.
208
+ */
209
+ setMode(mode: AdwSidebarMode): boolean;
210
+ /**
211
+ * Whether the selection is PAINTED. Page mode tracks the selection but shows
212
+ * no selected row: its rows are plain `AdwActionRow`s in a boxed list
213
+ * (`create_boxed_row`, adw-sidebar.c:1676) and the mode is documented as
214
+ * "the selection is invisible, but still tracked" (adw-sidebar.c:2948-2951).
215
+ */
216
+ get selectionVisible(): boolean;
217
+ /** The declared sections. */
218
+ get sections(): readonly AdwSidebarSectionSpec[];
219
+ /**
220
+ * Replace every section at once — the renderers' "here is my whole tree" call.
221
+ *
222
+ * Equivalent to `adw_sidebar_remove_all()` followed by appending each section,
223
+ * i.e. two splices: everything removed (which clears the selection via
224
+ * adw-sidebar.c:2275-2278) and everything added (which re-runs the `0 → n`
225
+ * auto-select of index 0 at adw-sidebar.c:2270-2273). They are coalesced into
226
+ * ONE notification, because one property write should produce one change.
227
+ */
228
+ setSections(sections: readonly AdwSidebarSectionSpec[]): void;
229
+ /**
230
+ * Insert a section, returning the index it landed at.
231
+ *
232
+ * `adw_sidebar_insert` appends when `position` is negative OR at/past the end
233
+ * (adw-sidebar.c:3358-3364) — so on a two-section sidebar, positions `-1`,
234
+ * `2` and `5` all append, and position `2` is NOT an "insert at 2".
235
+ */
236
+ insertSection(section: AdwSidebarSectionSpec, position: number): number;
237
+ /**
238
+ * Remove the section at `index`. Returns false for an index that addresses no
239
+ * section — `adw_sidebar_remove` warns and returns when the section is not
240
+ * found (adw-sidebar.c:3387-3393), changing nothing.
241
+ */
242
+ removeSectionAt(index: number): boolean;
243
+ /** `adw_sidebar_remove_all` (adw-sidebar.c:3417) — one splice removing every item. */
244
+ removeAllSections(): void;
245
+ /**
246
+ * Re-derive the item model after an ITEM's own properties changed in place.
247
+ *
248
+ * libadwaita has no such call because it does not need one: title, subtitle
249
+ * and icon are live `g_object_bind_property` bindings straight onto the
250
+ * labels (adw-sidebar.c:1409-1421) and `notify::icon-name` goes to
251
+ * `notify_icon_cb` (:1393-1397) — none of them runs through
252
+ * `items_changed_cb`, so the selection cannot move. This method is the same
253
+ * contract for renderers that hand `SidebarState` mutable specs: the derived
254
+ * flags are recomputed, the selection is untouched, nothing is emitted.
255
+ * Both ports ignored post-construction item changes entirely.
256
+ */
257
+ refresh(): void;
258
+ /** `adw_sidebar_get_section` — `undefined` past the end (adw-sidebar.c:3297-3298). */
259
+ sectionAt(index: number): AdwSidebarSectionSpec | undefined;
260
+ /** `adw_sidebar_section_get_first_index` — 0 for a section that is not in this sidebar. */
261
+ sectionFirstIndex(sectionIndex: number): number;
262
+ /** Number of items in the UNFILTERED model — the selection index space (adw-sidebar.c:2255). */
263
+ get count(): number;
264
+ /** The full flattened item model, in flat-index order. */
265
+ get items(): readonly SidebarFlatItem[];
266
+ /** `adw_sidebar_get_item` — `undefined` for `index >= n_items` (adw-sidebar.c:3256). */
267
+ itemAt(index: number): AdwSidebarItemSpec | undefined;
268
+ /** The current item filter, or `null`. */
269
+ get filter(): SidebarItemFilter | null;
270
+ /**
271
+ * Set the item filter — `adw_sidebar_set_filter` (adw-sidebar.c:3127-3139).
272
+ *
273
+ * It only swaps the filter on the `GtkFilterListModel`; the selection is
274
+ * never re-derived, so a selected item that filters out stays selected.
275
+ */
276
+ setFilter(filter: SidebarItemFilter | null): void;
277
+ /** The items that pass the filter — the rows a renderer actually builds. */
278
+ get visibleItems(): readonly SidebarFlatItem[];
279
+ /** The headers to draw, derived from the sections that render at least one row. */
280
+ get headers(): readonly SidebarHeaderSpec[];
281
+ /**
282
+ * The `.empty` / placeholder state — `update_placeholder` counts the FILTERED
283
+ * model (adw-sidebar.c:1828, :1839-1842), so a fully filtered-out sidebar is
284
+ * empty even though its selection index space is not.
285
+ */
286
+ get isEmpty(): boolean;
287
+ /** The selected flat index, or {@link ADW_SIDEBAR_NO_SELECTION}. */
288
+ get selected(): number;
289
+ /** `adw_sidebar_get_selected_item` (adw-sidebar.c:3092). */
290
+ get selectedItem(): AdwSidebarItemSpec | undefined;
291
+ /**
292
+ * Programmatic selection — {@link clampSidebarSelection} then notify with
293
+ * `interactive: false`. Returns whether it changed.
294
+ */
295
+ setSelected(index: number): boolean;
296
+ /**
297
+ * A row click. Selects (notifying `interactive: true` if that moved) and then
298
+ * reports the activation, which libadwaita emits on EVERY click including a
299
+ * re-click of the already-selected row (`row_activated_cb`, adw-sidebar.c:1601-1612).
300
+ * That unconditional emit is how re-tapping the current row reveals the content
301
+ * pane of a split view (adw-sidebar.c:73-75) — the NativeScript port had no
302
+ * activation path at all, so that gesture did nothing there.
303
+ *
304
+ * A row that is filtered out, `visible: false`, or `enabled: false` is not
305
+ * activatable: it either has no `GtkListBoxRow` or has an insensitive one.
306
+ */
307
+ activate(index: number): SidebarActivation;
308
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,316 @@
1
+ /**
2
+ * The four mutually exclusive content slots of the action half. `'empty'` is the
3
+ * initial state — `label`, `icon-name` and `child` are all `NULL`
4
+ * (adw-split-button.c:311-352).
5
+ */
6
+ export type SplitButtonContentMode = 'empty' | 'label' | 'icon' | 'child';
7
+ /** `GtkArrowType` as a string union. Default `'down'` (adw-split-button.c:420). */
8
+ export type SplitButtonDirection = 'none' | 'up' | 'down' | 'left' | 'right';
9
+ /**
10
+ * Every symbolic icon an `arrow` node can be given `-gtk-icon-source` for
11
+ * (_buttons.scss:451-469 plus the `splitbutton` override at :621-623).
12
+ *
13
+ * A union rather than `string` so a renderer's glyph→asset table is TOTAL: an
14
+ * `Adwaita` release that introduces a sixth glyph breaks the renderers at COMPILE
15
+ * time instead of painting a blank arrow at runtime.
16
+ */
17
+ export type AdwArrowIcon = 'open-menu-symbolic' | 'pan-down-symbolic' | 'pan-up-symbolic' | 'pan-start-symbolic' | 'pan-end-symbolic';
18
+ /** A root style class `update_style_classes` puts on the `splitbutton` node. */
19
+ export type SplitButtonStyleClass = 'image-button' | 'text-button';
20
+ /**
21
+ * The GObject property names this widget notifies.
22
+ *
23
+ * Carried in {@link SplitButtonChange.notified} so a renderer can re-emit
24
+ * `notify::*` with the same sequence the upstream suite asserts: one mutation
25
+ * emits SEVERAL notifications inside a single freeze/thaw
26
+ * (adw-split-button.c:671-681), and that sequence cannot be reconstructed from
27
+ * the final state alone.
28
+ *
29
+ * `can-shrink` is deliberately absent — see the module note on deferred scope.
30
+ */
31
+ export type SplitButtonProperty = 'label' | 'icon-name' | 'child' | 'use-underline' | 'menu-model' | 'popover' | 'direction' | 'dropdown-tooltip';
32
+ /**
33
+ * One `GMenuModel` item: a label plus the detailed action it invokes, i.e. what
34
+ * `Gio.Menu.append (label, action)` produces (adw-split-button.c:385-388).
35
+ *
36
+ * `id` and `icon` are the existing menu-button extras from the two renderers, so
37
+ * all four menu call sites in the workspace can converge on ONE type. The name
38
+ * is family-neutral on purpose: `Adw.MenuButton` needs exactly this and must be
39
+ * able to adopt it without a rename.
40
+ */
41
+ export interface AdwMenuEntry {
42
+ /** Display label. */
43
+ label: string;
44
+ /** Detailed action name, e.g. `app.save-as`. */
45
+ action?: string;
46
+ /** Stable identifier, defaulting to {@link label} on activation. */
47
+ id?: string;
48
+ /** Symbolic icon name for the item. */
49
+ icon?: string;
50
+ }
51
+ /** Payload of a {@link SplitButtonState} notification. */
52
+ export interface SplitButtonChange {
53
+ /** Which content slot is filled. */
54
+ mode: SplitButtonContentMode;
55
+ /** The label, or `null` unless {@link mode} is `'label'`. */
56
+ label: string | null;
57
+ /** The icon name, or `null` unless {@link mode} is `'icon'`. */
58
+ iconName: string | null;
59
+ /** The child widget — the app's in `'child'` mode, an opaque internal node in `'label'`/`'icon'` mode. */
60
+ child: object | null;
61
+ /** The root style classes after this change. */
62
+ styleClasses: readonly SplitButtonStyleClass[];
63
+ /** Whether the dropdown half is live (a menu model or a popover is set). */
64
+ dropdownEnabled: boolean;
65
+ /** Whether the menu is popped up. */
66
+ open: boolean;
67
+ /** The `notify::*` properties C emits for this one mutation, in emission order. */
68
+ notified: readonly SplitButtonProperty[];
69
+ /** True for a user gesture ({@link SplitButtonState.toggleMenu} / {@link SplitButtonState.activateMenuEntry}). */
70
+ interactive: boolean;
71
+ }
72
+ /** Subscriber for {@link SplitButtonState} changes. */
73
+ export type SplitButtonListener = (change: SplitButtonChange) => void;
74
+ /** The GTK state flags of one half of the control, as booleans. */
75
+ export interface SplitButtonHalfState {
76
+ /** `GTK_STATE_FLAG_ACTIVE` — the half is pressed. */
77
+ active: boolean;
78
+ /** `GTK_STATE_FLAG_CHECKED` — for the arrow half, the menu is open. */
79
+ checked: boolean;
80
+ /** The `keyboard-activating` CSS class GTK sets during a keyboard press. */
81
+ keyboardActivating: boolean;
82
+ }
83
+ /** The translatable default dropdown tooltip (adw-split-button.c:531-532, :1049-1050). */
84
+ export declare const DEFAULT_DROPDOWN_TOOLTIP = "More Options";
85
+ /** Adwaita's `--disabled-opacity`, for renderers that dim rather than desaturate. */
86
+ export declare const SPLIT_BUTTON_DISABLED_OPACITY = 0.5;
87
+ /**
88
+ * `update_style_classes` as a pure function (adw-split-button.c:145-165).
89
+ *
90
+ * Both branches test the FIRST CHARACTER, not truthiness of the value: `''` is a
91
+ * perfectly good label — non-`NULL`, so `get_label()` returns it and
92
+ * `get_icon_name()` is `NULL` — yet `label[0]` is NUL, so it carries no
93
+ * `text-button` class. `' '` does carry it, and renders two spaces: nothing in
94
+ * the C path trims.
95
+ */
96
+ export declare function splitButtonStyleClasses(label: string | null, iconName: string | null): readonly SplitButtonStyleClass[];
97
+ /**
98
+ * The dropdown tooltip to actually show, and whether it is markup
99
+ * (adw-split-button.c:1044-1051).
100
+ *
101
+ * `has_dropdown_tooltip = tooltip && *tooltip` — a non-empty value goes through
102
+ * `gtk_widget_set_tooltip_markup` (Pango markup), an empty one restores the
103
+ * translated default as plain TEXT. The distinction is not cosmetic: a renderer
104
+ * that escapes the markup branch, or that leaves the accessible name empty on
105
+ * the default branch, is a different widget.
106
+ */
107
+ export declare function resolveDropdownTooltip(tooltip: string): {
108
+ text: string;
109
+ markup: boolean;
110
+ };
111
+ /**
112
+ * The arrow glyph a PLAIN `menubutton` draws for a direction — `none` is the
113
+ * `open-menu-symbolic` hamburger (_buttons.scss:454-456).
114
+ *
115
+ * Use {@link splitButtonArrowIcon} for the dropdown half of a split button, which
116
+ * the stylesheet gives a different `none`.
117
+ */
118
+ export declare function menuButtonArrowIcon(direction: SplitButtonDirection): AdwArrowIcon;
119
+ /**
120
+ * The arrow glyph a SPLIT BUTTON's dropdown half draws for a direction — `none`
121
+ * is `pan-down-symbolic`, per the `splitbutton` override at _buttons.scss:621-623.
122
+ */
123
+ export declare function splitButtonArrowIcon(direction: SplitButtonDirection): AdwArrowIcon;
124
+ /**
125
+ * Where the popup is placed: `'none'` behaves the same as `'down'`
126
+ * (adw-split-button.c:415).
127
+ *
128
+ * PLACEMENT IS NOT A SPLIT-BUTTON RULE, unlike the glyph. `adw_split_button_set_direction`
129
+ * is a pass-through to `gtk_menu_button_set_direction` (:997) and the getter reads
130
+ * it straight back off the same `GtkMenuButton` (:971) — the split button stores
131
+ * nothing and overrides nothing here, so `none → down` is `GtkMenuButton`'s own
132
+ * behaviour. {@link menuButtonPopupDirection} is therefore this very function
133
+ * rather than a second copy of it.
134
+ */
135
+ export declare function splitButtonPopupDirection(direction: SplitButtonDirection): Exclude<SplitButtonDirection, 'none'>;
136
+ /**
137
+ * Where a plain `menubutton` places its popup — deliberately an ALIAS of
138
+ * {@link splitButtonPopupDirection}, not a copy.
139
+ *
140
+ * The two arrow-glyph functions differ because the stylesheet overrides the glyph
141
+ * per widget; placement has no such override, and pinning that as reference
142
+ * equality (`menuButtonPopupDirection === splitButtonPopupDirection`) is a claim a
143
+ * test can hold, where a duplicated body would only be a claim a comment makes.
144
+ */
145
+ export declare const menuButtonPopupDirection: typeof splitButtonPopupDirection;
146
+ /** Whether `value` names a `GtkArrowType`, for parsing a renderer attribute. */
147
+ export declare function isSplitButtonDirection(value: unknown): value is SplitButtonDirection;
148
+ /**
149
+ * `update_state` as a pure fold (adw-split-button.c:118-143).
150
+ *
151
+ * The two halves are separate widgets, but the state the STYLESHEET keys off
152
+ * sits on the root: `splitbutton.flat:checked` shades the whole control and
153
+ * hides the separator while the menu is open (_buttons.scss:542-549). Neither
154
+ * renderer folded it, so both showed a per-half highlight only.
155
+ */
156
+ export declare function splitButtonRootState(action: SplitButtonHalfState, dropdown: SplitButtonHalfState): {
157
+ active: boolean;
158
+ checked: boolean;
159
+ };
160
+ /**
161
+ * Parse a JSON menu attribute into entries.
162
+ *
163
+ * Total by construction — malformed JSON, a non-array root and entries without a
164
+ * `label` key all yield `[]` / are dropped — because the input is author-written
165
+ * markup and a typo must not take the widget down with it. Replaces the two
166
+ * byte-identical copies in `adw-split-button.ts` and `adw-menu-button.ts`.
167
+ */
168
+ export declare function parseMenuEntries(json: string | null | undefined): AdwMenuEntry[];
169
+ /**
170
+ * The whole `Adw.SplitButton` state machine: content mode, use-underline,
171
+ * menu-model/popover exclusivity, direction, dropdown tooltip and the popup flag.
172
+ *
173
+ * Every mutator returns whether it changed anything and notifies only on a real
174
+ * change, like `ComboState`/`SpinState`. What this class adds over those is
175
+ * {@link SplitButtonChange.notified}: an ORDERED property list, because a single
176
+ * `set_label()` can emit `notify::icon-name`, `notify::child` and `notify::label`
177
+ * in that order and the upstream suite counts them.
178
+ */
179
+ export declare class SplitButtonState {
180
+ private _mode;
181
+ private _label;
182
+ private _iconName;
183
+ private _child;
184
+ private _useUnderline;
185
+ private _menuModel;
186
+ private _popover;
187
+ private _direction;
188
+ private _dropdownTooltip;
189
+ private _open;
190
+ private readonly _listeners;
191
+ /** Subscribe to state changes. Returns an unsubscribe function. */
192
+ subscribe(listener: SplitButtonListener): () => void;
193
+ private _emit;
194
+ /** Which content slot is filled. */
195
+ get mode(): SplitButtonContentMode;
196
+ /** The label, or `null` unless {@link mode} is `'label'`. */
197
+ get label(): string | null;
198
+ /**
199
+ * Set the label, clearing `icon-name` and `child`
200
+ * (adw-split-button.c:661-682).
201
+ *
202
+ * A non-string is rejected outright and changes nothing, mirroring
203
+ * `g_return_if_fail (label != NULL)` at :666 — there is no "unset the label"
204
+ * path in C, clearing it is a side effect of setting another slot.
205
+ */
206
+ setLabel(label: string): boolean;
207
+ /** The icon name, or `null` unless {@link mode} is `'icon'`. */
208
+ get iconName(): string | null;
209
+ /**
210
+ * Set the icon name, clearing `label` and `child`
211
+ * (adw-split-button.c:749-771). A non-string is rejected — `g_return_if_fail
212
+ * (icon_name != NULL)` at :754.
213
+ */
214
+ setIconName(iconName: string): boolean;
215
+ /**
216
+ * The child widget: the app's own in `'child'` mode, the opaque internal
217
+ * content node in `'label'`/`'icon'` mode, `null` when empty.
218
+ */
219
+ get child(): object | null;
220
+ /**
221
+ * Set (or clear, with `null`) the child, clearing `label` and `icon-name`
222
+ * (adw-split-button.c:799-824).
223
+ *
224
+ * This is also the only way to reach `'empty'` again from a filled slot, and
225
+ * it is how a renderer expresses "no content" — `setChild(null)` on a fresh
226
+ * state is correctly a no-op (:806-807).
227
+ */
228
+ setChild(child: object | null | undefined): boolean;
229
+ /** The root style classes for the current content. */
230
+ get styleClasses(): readonly SplitButtonStyleClass[];
231
+ /** Whether an underline in the label marks a mnemonic. */
232
+ get useUnderline(): boolean;
233
+ /**
234
+ * Set the mnemonic flag (adw-split-button.c:709-721). `!!`-normalised at :715,
235
+ * so a truthy non-boolean stores `true` and a following `setUseUnderline(true)`
236
+ * is correctly a no-op.
237
+ *
238
+ * Only the PROPERTY lives here. The `_S` → underlined-S derivation belongs to
239
+ * `GtkLabel`, not to this widget or its test — see the module note on
240
+ * deferred scope.
241
+ */
242
+ setUseUnderline(value: boolean): boolean;
243
+ /** The menu entries, or `null` when no menu model is set. */
244
+ get menuModel(): readonly AdwMenuEntry[] | null;
245
+ /**
246
+ * Set the menu model, dissociating any popover (adw-split-button.c:906-916,
247
+ * :397-398) and replacing it with the model-derived one.
248
+ *
249
+ * DELIBERATE NORMALISATION: an EMPTY list is stored as "no menu model". C can
250
+ * hold a non-`NULL` but empty `GMenu`, which leaves the dropdown live and
251
+ * pops up an empty popover — but neither renderer can construct that state
252
+ * (one parses a JSON array, the other takes a label list), so the two cases
253
+ * are the same input here, and collapsing them is what makes "no menu ⇒
254
+ * insensitive dropdown" (:376-378) hold from a renderer's point of view. The
255
+ * `@gjsify/adwaita-web` bug this kills was a click on a menu-less split
256
+ * button opening an empty, fully styled popover.
257
+ */
258
+ setMenuModel(entries: readonly AdwMenuEntry[] | null | undefined): boolean;
259
+ /** The popover: the one the app set, or the model-derived stand-in, or `null`. */
260
+ get popover(): object | null;
261
+ /**
262
+ * Set the popover, dissociating any menu model (adw-split-button.c:946-956,
263
+ * :390-398).
264
+ *
265
+ * The cleared property is notified before the set one, the order
266
+ * `set_label`/`set_icon_name`/`set_child` use throughout this widget
267
+ * (:671-681). GtkMenuButton's own internal ordering is not observable from
268
+ * the upstream suite, which only counts per-property notifications.
269
+ */
270
+ setPopover(popover: object | null | undefined): boolean;
271
+ /**
272
+ * Whether the dropdown half is live. "If the menu model is `NULL`, the
273
+ * dropdown is disabled" (adw-split-button.c:376-378) and the same for the
274
+ * popover (:394-396) — with neither, GtkMenuButton is insensitive.
275
+ */
276
+ get dropdownEnabled(): boolean;
277
+ /** The direction the popup opens in, and the arrow points. */
278
+ get direction(): SplitButtonDirection;
279
+ /** Set the direction (adw-split-button.c:988-1000). An unknown value is rejected. */
280
+ setDirection(direction: SplitButtonDirection): boolean;
281
+ /** The arrow glyph for the current direction, with the split button's `none`. */
282
+ get arrowIcon(): AdwArrowIcon;
283
+ /**
284
+ * The dropdown tooltip as SET — `''` while unset, never `null`
285
+ * (adw-split-button.c:1017-1018). Pass it through
286
+ * {@link resolveDropdownTooltip} to get what should actually be shown.
287
+ */
288
+ get dropdownTooltip(): string;
289
+ /**
290
+ * Set the dropdown tooltip (adw-split-button.c:1034-1054). The guard compares
291
+ * against the GETTER (:1041-1042), which already reports `''` when unset — so
292
+ * clearing an unset tooltip notifies nothing, while clearing a set one does
293
+ * notify and RESTORES the default rather than blanking the tooltip.
294
+ */
295
+ setDropdownTooltip(tooltip: string): boolean;
296
+ /** Whether the menu is popped up. */
297
+ get open(): boolean;
298
+ private _setOpen;
299
+ /** Pop the menu up programmatically — `adw_split_button_popup` (:1062-1068). */
300
+ openMenu(): boolean;
301
+ /** Dismiss the menu programmatically — `adw_split_button_popdown` (:1076-1082). */
302
+ closeMenu(): boolean;
303
+ /** The dropdown half was activated by the user; flips the menu open/closed. */
304
+ toggleMenu(): boolean;
305
+ /**
306
+ * Activate a menu entry BY POSITION and dismiss the menu, returning the entry
307
+ * (or `null` for an out-of-range index).
308
+ *
309
+ * Position is the addressing a `GMenuModel` actually uses — each item carries
310
+ * its own detailed action (adw-split-button.c:385-388). Resolving a choice by
311
+ * LABEL, as the NativeScript port did, silently dispatches the first of two
312
+ * identically named entries and cannot tell an entry called `Cancel` from a
313
+ * dismissed sheet.
314
+ */
315
+ activateMenuEntry(index: number): AdwMenuEntry | null;
316
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;