@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.
- package/lib/esm/about-dialog.js +3 -0
- package/lib/esm/action-row.js +1 -0
- package/lib/esm/avatar.js +1 -0
- package/lib/esm/banner.js +1 -0
- package/lib/esm/button-content.js +1 -0
- package/lib/esm/carousel.js +1 -0
- package/lib/esm/checks.js +1 -0
- package/lib/esm/chrome.js +1 -0
- package/lib/esm/conformance/about-dialog.js +6 -0
- package/lib/esm/conformance/action-row.js +1 -0
- package/lib/esm/conformance/avatar.js +1 -0
- package/lib/esm/conformance/banner.js +1 -0
- package/lib/esm/conformance/button-content.js +1 -0
- package/lib/esm/conformance/carousel.js +1 -0
- package/lib/esm/conformance/checks.js +1 -0
- package/lib/esm/conformance/chrome.js +1 -0
- package/lib/esm/conformance/data-grid.js +1 -0
- package/lib/esm/conformance/dialog.js +1 -0
- package/lib/esm/conformance/entry-row.js +1 -0
- package/lib/esm/conformance/index.js +1 -0
- package/lib/esm/conformance/navigation-view.js +1 -0
- package/lib/esm/conformance/popover.js +1 -0
- package/lib/esm/conformance/preferences.js +1 -0
- package/lib/esm/conformance/rows.js +1 -0
- package/lib/esm/conformance/sidebar.js +1 -0
- package/lib/esm/conformance/spinner.js +1 -0
- package/lib/esm/conformance/split-button.js +1 -0
- package/lib/esm/conformance/split-view.js +1 -0
- package/lib/esm/conformance/tab-view.js +1 -0
- package/lib/esm/conformance/view-stack.js +1 -0
- package/lib/esm/conformance/view-switcher.js +1 -0
- package/lib/esm/conformance/wrap-box.js +1 -0
- package/lib/esm/data-grid.js +1 -0
- package/lib/esm/dialog.js +1 -1
- package/lib/esm/easing.js +1 -0
- package/lib/esm/entry-row.js +1 -0
- package/lib/esm/glib.js +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/length-unit.js +1 -0
- package/lib/esm/navigation-view.js +1 -0
- package/lib/esm/popover.js +1 -0
- package/lib/esm/preferences.js +1 -0
- package/lib/esm/rows.js +1 -1
- package/lib/esm/sidebar.js +1 -0
- package/lib/esm/spinner.js +1 -0
- package/lib/esm/split-button.js +1 -0
- package/lib/esm/split-view.js +1 -0
- package/lib/esm/tab-view.js +1 -0
- package/lib/esm/view-stack.js +1 -0
- package/lib/esm/view-switcher.js +1 -0
- package/lib/esm/wrap-box.js +1 -0
- package/lib/types/about-dialog.d.ts +391 -0
- package/lib/types/about-dialog.spec.d.ts +2 -0
- package/lib/types/action-row.d.ts +270 -0
- package/lib/types/action-row.spec.d.ts +2 -0
- package/lib/types/avatar.d.ts +112 -0
- package/lib/types/avatar.spec.d.ts +2 -0
- package/lib/types/banner.d.ts +104 -0
- package/lib/types/banner.spec.d.ts +2 -0
- package/lib/types/button-content.d.ts +141 -0
- package/lib/types/button-content.spec.d.ts +2 -0
- package/lib/types/carousel.d.ts +535 -0
- package/lib/types/carousel.spec.d.ts +2 -0
- package/lib/types/checks.d.ts +63 -0
- package/lib/types/checks.spec.d.ts +2 -0
- package/lib/types/chrome.d.ts +355 -0
- package/lib/types/chrome.spec.d.ts +2 -0
- package/lib/types/conformance/about-dialog.d.ts +314 -0
- package/lib/types/conformance/action-row.d.ts +186 -0
- package/lib/types/conformance/avatar.d.ts +61 -0
- package/lib/types/conformance/banner.d.ts +91 -0
- package/lib/types/conformance/button-content.d.ts +110 -0
- package/lib/types/conformance/carousel.d.ts +298 -0
- package/lib/types/conformance/checks.d.ts +29 -0
- package/lib/types/conformance/chrome.d.ts +207 -0
- package/lib/types/conformance/data-grid.d.ts +136 -0
- package/lib/types/conformance/dialog.d.ts +97 -0
- package/lib/types/conformance/entry-row.d.ts +187 -0
- package/lib/types/conformance/index.d.ts +46 -0
- package/lib/types/conformance/navigation-view.d.ts +235 -0
- package/lib/types/conformance/popover.d.ts +58 -0
- package/lib/types/conformance/preferences.d.ts +184 -0
- package/lib/types/conformance/rows.d.ts +74 -0
- package/lib/types/conformance/sidebar.d.ts +182 -0
- package/lib/types/conformance/spinner.d.ts +66 -0
- package/lib/types/conformance/split-button.d.ts +193 -0
- package/lib/types/conformance/split-view.d.ts +301 -0
- package/lib/types/conformance/tab-view.d.ts +449 -0
- package/lib/types/conformance/view-stack.d.ts +121 -0
- package/lib/types/conformance/view-switcher.d.ts +443 -0
- package/lib/types/conformance/wrap-box.d.ts +185 -0
- package/lib/types/data-grid.d.ts +140 -0
- package/lib/types/data-grid.spec.d.ts +2 -0
- package/lib/types/dialog.d.ts +144 -0
- package/lib/types/easing.d.ts +21 -0
- package/lib/types/entry-row.d.ts +308 -0
- package/lib/types/entry-row.spec.d.ts +2 -0
- package/lib/types/glib.d.ts +49 -0
- package/lib/types/index.d.ts +50 -4
- package/lib/types/length-unit.d.ts +24 -0
- package/lib/types/navigation-view.d.ts +343 -0
- package/lib/types/navigation-view.spec.d.ts +2 -0
- package/lib/types/popover.d.ts +155 -0
- package/lib/types/popover.spec.d.ts +2 -0
- package/lib/types/preferences.d.ts +349 -0
- package/lib/types/preferences.spec.d.ts +2 -0
- package/lib/types/rows.d.ts +96 -8
- package/lib/types/sidebar.d.ts +308 -0
- package/lib/types/sidebar.spec.d.ts +2 -0
- package/lib/types/spinner.d.ts +117 -0
- package/lib/types/spinner.spec.d.ts +2 -0
- package/lib/types/split-button.d.ts +316 -0
- package/lib/types/split-button.spec.d.ts +2 -0
- package/lib/types/split-view.d.ts +703 -0
- package/lib/types/split-view.spec.d.ts +2 -0
- package/lib/types/tab-view.d.ts +616 -0
- package/lib/types/tab-view.spec.d.ts +2 -0
- package/lib/types/view-stack.d.ts +278 -0
- package/lib/types/view-stack.spec.d.ts +2 -0
- package/lib/types/view-switcher.d.ts +524 -0
- package/lib/types/view-switcher.spec.d.ts +2 -0
- package/lib/types/wrap-box.d.ts +200 -0
- package/lib/types/wrap-box.spec.d.ts +2 -0
- package/package.json +8 -4
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
import { stripMnemonic } from './glib.js';
|
|
2
|
+
import type { AdwViewStackPageInfo } from './view-stack.js';
|
|
3
|
+
/**
|
|
4
|
+
* The "nothing is selected" sentinel, standing in for
|
|
5
|
+
* `GTK_INVALID_LIST_POSITION` (adw-inline-view-switcher.c:366, :441).
|
|
6
|
+
*
|
|
7
|
+
* Returned by {@link toggleIndexForPage} / {@link pageIndexForToggle} when the
|
|
8
|
+
* two index spaces have no counterpart for each other — a hidden page has no
|
|
9
|
+
* toggle at all, which is a state `ToggleGroupState`'s always-non-negative
|
|
10
|
+
* `selected` cannot express.
|
|
11
|
+
*/
|
|
12
|
+
export declare const VIEW_SWITCHER_NO_SELECTION = -1;
|
|
13
|
+
/**
|
|
14
|
+
* The icon substituted for a NULL or empty icon name
|
|
15
|
+
* (adw-view-switcher-button.c:347, :399-405; adw-inline-view-switcher.c:131-145).
|
|
16
|
+
*/
|
|
17
|
+
export declare const VIEW_SWITCHER_FALLBACK_ICON = "image-missing";
|
|
18
|
+
/**
|
|
19
|
+
* `TIMEOUT_EXPAND` — how long a drag has to dwell over a non-active button
|
|
20
|
+
* before it switches to it (adw-view-switcher-button.c:14,
|
|
21
|
+
* adw-inline-view-switcher.c:80). Defined identically in both C files.
|
|
22
|
+
*/
|
|
23
|
+
export declare const VIEW_SWITCHER_DRAG_SWITCH_DELAY = 500;
|
|
24
|
+
/** The largest badge `AdwIndicatorBin` prints; anything above collapses to `999+`. */
|
|
25
|
+
export declare const VIEW_SWITCHER_BADGE_LIMIT = 999;
|
|
26
|
+
/** `AdwViewSwitcherPolicy` — which button layout the switcher forces. */
|
|
27
|
+
export type AdwViewSwitcherPolicy = 'narrow' | 'wide';
|
|
28
|
+
/**
|
|
29
|
+
* Every policy, in enum order. Doubles as the style-class list: libadwaita adds
|
|
30
|
+
* the current policy's class and removes the other (adw-view-switcher.c:539-545),
|
|
31
|
+
* so a renderer toggles each entry against the current value rather than
|
|
32
|
+
* hard-coding an add/remove pair.
|
|
33
|
+
*/
|
|
34
|
+
export declare const VIEW_SWITCHER_POLICIES: readonly AdwViewSwitcherPolicy[];
|
|
35
|
+
/** `AdwInlineViewSwitcherDisplayMode` — what the inline switcher's toggles show. */
|
|
36
|
+
export type AdwInlineViewSwitcherDisplayMode = 'labels' | 'icons' | 'both';
|
|
37
|
+
/**
|
|
38
|
+
* Every display mode, in enum order — and the toggle-group style classes
|
|
39
|
+
* (adw-inline-view-switcher.c:826-850), same toggle-against-current pattern as
|
|
40
|
+
* {@link VIEW_SWITCHER_POLICIES}.
|
|
41
|
+
*/
|
|
42
|
+
export declare const INLINE_VIEW_SWITCHER_DISPLAY_MODES: readonly AdwInlineViewSwitcherDisplayMode[];
|
|
43
|
+
/**
|
|
44
|
+
* Whether `value` is a policy libadwaita would accept.
|
|
45
|
+
*
|
|
46
|
+
* The C setter is guarded by the enum's own type (`g_value_get_enum`), and the
|
|
47
|
+
* browser port instead coerced anything unrecognised to a default — see
|
|
48
|
+
* {@link isInlineViewSwitcherDisplayMode} for why that is not the same thing.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isViewSwitcherPolicy(value: unknown): value is AdwViewSwitcherPolicy;
|
|
51
|
+
/**
|
|
52
|
+
* Whether `value` is a display mode libadwaita would accept.
|
|
53
|
+
*
|
|
54
|
+
* `adw_inline_view_switcher_set_display_mode` opens with
|
|
55
|
+
* `g_return_if_fail (mode <= ADW_INLINE_VIEW_SWITCHER_BOTH)`
|
|
56
|
+
* (adw-inline-view-switcher.c:819), which REJECTS the call and leaves the
|
|
57
|
+
* current mode alone. The browser port's `includes(raw) ? raw : 'both'` replaced
|
|
58
|
+
* the current mode with `'both'` instead, so a typo in one attribute silently
|
|
59
|
+
* changed what every toggle displayed.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isInlineViewSwitcherDisplayMode(value: unknown): value is AdwInlineViewSwitcherDisplayMode;
|
|
62
|
+
/**
|
|
63
|
+
* The page record every switcher flavour reads — `AdwViewStackPage`'s properties
|
|
64
|
+
* with their C defaults (adw-view-stack.c:373-436).
|
|
65
|
+
*
|
|
66
|
+
* `null` vs `''` is LOAD-BEARING and is why this record exists next to
|
|
67
|
+
* {@link AdwViewStackPageInfo} rather than being replaced by it: the
|
|
68
|
+
* button-visibility rule tests `title != NULL`, and an empty title is not NULL.
|
|
69
|
+
* Wave 1's stack page model resolves an absent title to the page NAME (a
|
|
70
|
+
* deliberate, documented deviation), so a page's "had no title at all" state
|
|
71
|
+
* only survives where the switcher owns its own pages.
|
|
72
|
+
*/
|
|
73
|
+
export interface AdwViewSwitcherPage {
|
|
74
|
+
/** Stable id, matching `AdwViewStackPage`'s name. */
|
|
75
|
+
name: string;
|
|
76
|
+
/** `AdwViewStackPage:title` — `null` when the page has none (C default). */
|
|
77
|
+
title: string | null;
|
|
78
|
+
/** `AdwViewStackPage:icon-name` — `null` when the page has none (C default). */
|
|
79
|
+
iconName: string | null;
|
|
80
|
+
/** `AdwViewStackPage:visible` — default `true`. Gates both the button and the toggle. */
|
|
81
|
+
visible: boolean;
|
|
82
|
+
/** `AdwViewStackPage:use-underline` — default `false`. An `_` in the title marks a mnemonic. */
|
|
83
|
+
useUnderline: boolean;
|
|
84
|
+
/** `AdwViewStackPage:badge-number` — default `0`, i.e. no badge. */
|
|
85
|
+
badgeNumber: number;
|
|
86
|
+
/** `AdwViewStackPage:needs-attention` — default `false`, i.e. no dot. */
|
|
87
|
+
needsAttention: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** What a caller has to supply for a page: the name, plus whatever it knows. */
|
|
90
|
+
export interface AdwViewSwitcherPageInit extends Partial<AdwViewSwitcherPage> {
|
|
91
|
+
/** Stable id, matching `AdwViewStackPage`'s name. */
|
|
92
|
+
name: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Normalize a partial page into the full record with the C defaults applied, so
|
|
96
|
+
* a renderer that only knows `{ name, title }` gets exactly the same derivations
|
|
97
|
+
* as one that knows badges.
|
|
98
|
+
*
|
|
99
|
+
* `undefined` collapses to the C default; an explicit `null` title or icon name
|
|
100
|
+
* stays `null`. The badge is normalized to a non-negative integer because
|
|
101
|
+
* `badge-number` is a `guint` (adw-view-stack.c:420-423) and every derivation
|
|
102
|
+
* below assumes it.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createViewSwitcherPage(init: AdwViewSwitcherPageInit): AdwViewSwitcherPage;
|
|
105
|
+
/**
|
|
106
|
+
* Project a wave-1 stack page descriptor onto a switcher page, for a switcher
|
|
107
|
+
* BOUND to an `Adw.ViewStack` rather than owning its own pages.
|
|
108
|
+
*
|
|
109
|
+
* One fidelity note remains: `AdwViewStackPageInfo.title` is already resolved
|
|
110
|
+
* against the page name, so it is never `null` and the button-visibility rule
|
|
111
|
+
* reduces to the `visible` flag.
|
|
112
|
+
*
|
|
113
|
+
* The second one is gone. This used to say the stack page carried none of
|
|
114
|
+
* `badge-number`, `needs-attention` or `use-underline`, "so a bound switcher
|
|
115
|
+
* derives an empty badge and no description" — which made a switcher bound to a
|
|
116
|
+
* stack STRUCTURALLY unable to show a badge, and both `ViewSwitcherBar`s go
|
|
117
|
+
* through here. The stack page carries all three now.
|
|
118
|
+
*/
|
|
119
|
+
export declare function viewSwitcherPageFromStackPage(page: AdwViewStackPageInfo): AdwViewSwitcherPage;
|
|
120
|
+
/** {@link viewSwitcherPageFromStackPage} over a whole page list. */
|
|
121
|
+
export declare function viewSwitcherPagesFromStack(pages: readonly AdwViewStackPageInfo[]): AdwViewSwitcherPage[];
|
|
122
|
+
/**
|
|
123
|
+
* `update_button`'s visibility rule (adw-view-switcher.c:178):
|
|
124
|
+
* `visible && (title != NULL || icon_name != NULL)`.
|
|
125
|
+
*
|
|
126
|
+
* The empty string is NOT NULL, so `title: ''` still yields a button — the
|
|
127
|
+
* opposite of what both ports did, which was to keep the button and hide only
|
|
128
|
+
* its label. `undefined` is read as absent, i.e. as C's NULL.
|
|
129
|
+
*/
|
|
130
|
+
export declare function isViewSwitcherButtonVisible(page: Pick<AdwViewSwitcherPage, 'visible' | 'title' | 'iconName'>): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* The icon a switcher actually renders: a NULL or EMPTY name becomes
|
|
133
|
+
* `image-missing` (adw-view-switcher-button.c:399-405,
|
|
134
|
+
* adw-inline-view-switcher.c:137-142 — `icon_name && *icon_name` fails on `''`).
|
|
135
|
+
*
|
|
136
|
+
* Never returns `''`, so a renderer has an icon to paint in every mode where the
|
|
137
|
+
* C widget creates a `GtkImage` at all. Both ports instead omitted the icon
|
|
138
|
+
* node, which is why an icon-only toggle for a page without an icon rendered as
|
|
139
|
+
* a blank box.
|
|
140
|
+
*/
|
|
141
|
+
export declare function viewSwitcherIconName(iconName: string | null | undefined): string;
|
|
142
|
+
/**
|
|
143
|
+
* The text a switcher paints for a page: `''` for a NULL title, otherwise the
|
|
144
|
+
* title with its mnemonic stripped when `use-underline` is set.
|
|
145
|
+
*
|
|
146
|
+
* `update_button` binds `title` onto the button's label together with
|
|
147
|
+
* `use-underline` (adw-view-switcher.c:170-176), and the template label carries
|
|
148
|
+
* `use-underline` too (adw-view-switcher-button.ui) — so GTK DISPLAYS `_Files`
|
|
149
|
+
* as `Files` with an underlined F. A renderer with no accelerator layer displays
|
|
150
|
+
* the same text; keeping the underscore would render a literal one, which is
|
|
151
|
+
* what the browser port did in the inline switcher's tooltip.
|
|
152
|
+
*/
|
|
153
|
+
export declare function viewSwitcherLabel(page: Pick<AdwViewSwitcherPage, 'title' | 'useUnderline'>): string;
|
|
154
|
+
/**
|
|
155
|
+
* `get_badge_label` (adw-indicator-bin.c:58-68): `''` for 0, `999+` above 999,
|
|
156
|
+
* the decimal otherwise. 999 itself prints, because the test is `> 999`.
|
|
157
|
+
*/
|
|
158
|
+
export declare function viewSwitcherBadgeLabel(badgeNumber: number): string;
|
|
159
|
+
/**
|
|
160
|
+
* The message catalogue {@link viewSwitcherIndicatorDescription} composes, so the
|
|
161
|
+
* core needs no gettext dependency while the composition ORDER stays pinned.
|
|
162
|
+
*
|
|
163
|
+
* C reads these through `C_("view switcher button badge", …)`; a renderer with a
|
|
164
|
+
* translation layer passes its own catalogue.
|
|
165
|
+
*/
|
|
166
|
+
export interface IndicatorDescriptionStrings {
|
|
167
|
+
/** `needs-attention` clause — C's "Attention requested." */
|
|
168
|
+
attentionRequested: string;
|
|
169
|
+
/** Badge clause above the limit — C's "Has a badge: more than 999." */
|
|
170
|
+
badgeOverflow: string;
|
|
171
|
+
/** Badge clause for a printable count — C's "Has a badge: %u." */
|
|
172
|
+
badge: (badgeNumber: number) => string;
|
|
173
|
+
}
|
|
174
|
+
/** The English source strings from adw-indicator-bin.c:77-92. */
|
|
175
|
+
export declare const DEFAULT_INDICATOR_DESCRIPTION_STRINGS: IndicatorDescriptionStrings;
|
|
176
|
+
/**
|
|
177
|
+
* `update_description` (adw-indicator-bin.c:70-113) — the screen-reader
|
|
178
|
+
* description bound onto the switcher button (adw-view-switcher-button.c:98-113)
|
|
179
|
+
* or the inline toggle (adw-inline-view-switcher.c:267).
|
|
180
|
+
*
|
|
181
|
+
* The BADGE clause comes first when both apply: the format string is
|
|
182
|
+
* `"%s %s", badge_description, needs_attention_description` (:96). `''` when
|
|
183
|
+
* neither applies — C stores the empty string there, not NULL, and the button
|
|
184
|
+
* then RESETS the accessible property rather than setting it.
|
|
185
|
+
*/
|
|
186
|
+
export declare function viewSwitcherIndicatorDescription(needsAttention: boolean, badgeNumber: number, strings?: IndicatorDescriptionStrings): string;
|
|
187
|
+
/**
|
|
188
|
+
* `update_tooltip` (adw-inline-view-switcher.c:163-192): the empty string in
|
|
189
|
+
* every display mode except `icons`, where it is the title with the mnemonic
|
|
190
|
+
* stripped when `use-underline` is set.
|
|
191
|
+
*
|
|
192
|
+
* Returns PLAIN text — see {@link stripMnemonic} on why the C markup escape does
|
|
193
|
+
* not belong in a port. A NULL title yields `''`: C would hand NULL to
|
|
194
|
+
* `g_markup_escape_text`, which every page libadwaita renders avoids by always
|
|
195
|
+
* having a title.
|
|
196
|
+
*/
|
|
197
|
+
export declare function inlineToggleTooltip(page: Pick<AdwViewSwitcherPage, 'title' | 'useUnderline'>, displayMode: AdwInlineViewSwitcherDisplayMode): string;
|
|
198
|
+
/**
|
|
199
|
+
* `update_bar_revealed` (adw-view-switcher-bar.c:104-126): the bar is revealed
|
|
200
|
+
* only when `reveal` is set AND more than one page is VISIBLE.
|
|
201
|
+
*
|
|
202
|
+
* When `reveal` is false the C loop never runs, so the count stays 0 — the two
|
|
203
|
+
* clauses are not independent and a renderer must not reorder them into
|
|
204
|
+
* `visibleCount > 1 || reveal`. Absent from both ports, which is why a bar bound
|
|
205
|
+
* to a one-page stack showed an empty strip libadwaita keeps collapsed.
|
|
206
|
+
*
|
|
207
|
+
* Takes the minimal shape so a caller can pass either
|
|
208
|
+
* {@link AdwViewSwitcherPage}s or wave-1 {@link AdwViewStackPageInfo}s.
|
|
209
|
+
*/
|
|
210
|
+
export declare function shouldRevealViewSwitcherBar(reveal: boolean, pages: readonly {
|
|
211
|
+
readonly visible: boolean;
|
|
212
|
+
}[]): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* The button orientation the policy implies — `WIDE` is horizontal, anything
|
|
215
|
+
* else vertical (adw-view-switcher.c:219-220, :534-537). The same ternary is
|
|
216
|
+
* used when a button is created and when the policy changes.
|
|
217
|
+
*/
|
|
218
|
+
export declare function viewSwitcherButtonOrientation(policy: AdwViewSwitcherPolicy): 'horizontal' | 'vertical';
|
|
219
|
+
/** The fully-derived per-button view model an `AdwViewSwitcher` renderer paints. */
|
|
220
|
+
export interface ViewSwitcherButtonModel {
|
|
221
|
+
/** Position in the PAGE list — `AdwViewSwitcher` keeps a button per page, so this is also the button index. */
|
|
222
|
+
pageIndex: number;
|
|
223
|
+
/** The page name, for a renderer that addresses pages by name. */
|
|
224
|
+
name: string;
|
|
225
|
+
/** The text to paint — {@link viewSwitcherLabel}, so already mnemonic-stripped. */
|
|
226
|
+
label: string;
|
|
227
|
+
/** The icon to paint — {@link viewSwitcherIconName}, never empty. */
|
|
228
|
+
iconName: string;
|
|
229
|
+
/** Whether the BUTTON is shown at all — {@link isViewSwitcherButtonVisible}. */
|
|
230
|
+
visible: boolean;
|
|
231
|
+
/** Whether this button's page is the selected one. */
|
|
232
|
+
selected: boolean;
|
|
233
|
+
/** Icon/label arrangement — {@link viewSwitcherButtonOrientation}. */
|
|
234
|
+
orientation: 'horizontal' | 'vertical';
|
|
235
|
+
/** Badge text, `''` when there is no badge — {@link viewSwitcherBadgeLabel}. */
|
|
236
|
+
badgeLabel: string;
|
|
237
|
+
/** Whether to paint the needs-attention dot. */
|
|
238
|
+
needsAttention: boolean;
|
|
239
|
+
/** Screen-reader description, `''` when neither badge nor attention applies. */
|
|
240
|
+
description: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* One model per page for `AdwViewSwitcher`, in PAGE index space.
|
|
244
|
+
*
|
|
245
|
+
* `populate_switcher` adds a button for EVERY page and `update_button` merely
|
|
246
|
+
* hides the ones that fail the visibility rule (adw-view-switcher.c:230-238,
|
|
247
|
+
* :178), so the index space is preserved — unlike the inline switcher, which
|
|
248
|
+
* drops hidden pages entirely. `selected` is the page index; `-1` selects
|
|
249
|
+
* nothing.
|
|
250
|
+
*/
|
|
251
|
+
export declare function buildViewSwitcherButtons(pages: readonly AdwViewSwitcherPage[], selected: number, policy: AdwViewSwitcherPolicy, strings?: IndicatorDescriptionStrings): ViewSwitcherButtonModel[];
|
|
252
|
+
/** The fully-derived per-toggle view model an `AdwInlineViewSwitcher` renderer paints. */
|
|
253
|
+
export interface InlineToggleModel {
|
|
254
|
+
/** Position among the TOGGLES — compacted, hidden pages skipped. */
|
|
255
|
+
toggleIndex: number;
|
|
256
|
+
/** Position in the PAGE list — libadwaita's `child-index` (adw-inline-view-switcher.c:346). */
|
|
257
|
+
pageIndex: number;
|
|
258
|
+
/** The page name. */
|
|
259
|
+
name: string;
|
|
260
|
+
/** The text to paint — already mnemonic-stripped. */
|
|
261
|
+
label: string;
|
|
262
|
+
/** The icon to paint, never empty. */
|
|
263
|
+
iconName: string;
|
|
264
|
+
/** Whether this display mode builds an icon at all (`labels` does not). */
|
|
265
|
+
showIcon: boolean;
|
|
266
|
+
/** Whether this display mode builds a label at all (`icons` does not). */
|
|
267
|
+
showLabel: boolean;
|
|
268
|
+
/** Tooltip text, `''` outside `icons` mode — {@link inlineToggleTooltip}. */
|
|
269
|
+
tooltip: string;
|
|
270
|
+
/** Badge text, `''` when there is no badge. */
|
|
271
|
+
badgeLabel: string;
|
|
272
|
+
/** Whether to paint the needs-attention dot. */
|
|
273
|
+
needsAttention: boolean;
|
|
274
|
+
/** Screen-reader description, `''` when neither badge nor attention applies. */
|
|
275
|
+
description: string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* `populate_group`'s filter + order (adw-inline-view-switcher.c:360-392): a page
|
|
279
|
+
* with `visible == FALSE` produces NO toggle.
|
|
280
|
+
*
|
|
281
|
+
* Which is why every model carries BOTH indices — `toggleIndex` is the compacted
|
|
282
|
+
* `0..k-1` position the toggle group knows, `pageIndex` is the position the
|
|
283
|
+
* selection model knows, and libadwaita reconciles them through the
|
|
284
|
+
* `child-index` it stashes on each toggle (:346, :114-129). Neither port
|
|
285
|
+
* filtered, so the two spaces coincided and the reconciliation looked
|
|
286
|
+
* unnecessary.
|
|
287
|
+
*
|
|
288
|
+
* Note this uses the page's `visible` flag ALONE — the title-or-icon rule
|
|
289
|
+
* belongs to `AdwViewSwitcher.update_button` and has no counterpart here, so a
|
|
290
|
+
* page with neither title nor icon still gets an (empty) toggle.
|
|
291
|
+
*/
|
|
292
|
+
export declare function buildInlineToggles(pages: readonly AdwViewSwitcherPage[], displayMode: AdwInlineViewSwitcherDisplayMode, strings?: IndicatorDescriptionStrings): InlineToggleModel[];
|
|
293
|
+
/**
|
|
294
|
+
* Page index → toggle index, or {@link VIEW_SWITCHER_NO_SELECTION} when the page
|
|
295
|
+
* is hidden or out of range — `selection_changed_cb`
|
|
296
|
+
* (adw-inline-view-switcher.c:434-453), where `index` stays
|
|
297
|
+
* `GTK_INVALID_LIST_POSITION` unless the visible child's page is itself visible.
|
|
298
|
+
*
|
|
299
|
+
* Non-integers are refused for the same reason `ViewStackState` refuses them:
|
|
300
|
+
* the C position is a `guint`.
|
|
301
|
+
*/
|
|
302
|
+
export declare function toggleIndexForPage(pages: readonly AdwViewSwitcherPage[], pageIndex: number): number;
|
|
303
|
+
/**
|
|
304
|
+
* Toggle index → page index, or {@link VIEW_SWITCHER_NO_SELECTION} when there is
|
|
305
|
+
* no such toggle — `notify_active_cb` (adw-inline-view-switcher.c:114-129), which
|
|
306
|
+
* reads the active toggle's `child-index` and selects THAT page position.
|
|
307
|
+
*/
|
|
308
|
+
export declare function pageIndexForToggle(pages: readonly AdwViewSwitcherPage[], toggleIndex: number): number;
|
|
309
|
+
/** Opaque handle a {@link ViewSwitcherScheduler} returns for a pending dwell. */
|
|
310
|
+
export type ViewSwitcherTimerHandle = unknown;
|
|
311
|
+
/**
|
|
312
|
+
* The injected timing seam for the drag-hover auto-switch.
|
|
313
|
+
*
|
|
314
|
+
* Deliberately the same SHAPE as `ToastScheduler` in `toast.ts`, so a renderer
|
|
315
|
+
* writes ONE adapter over its platform timer and passes it to both. The core
|
|
316
|
+
* never reaches for a global `setTimeout` — that is what `gjsify.headless: true`
|
|
317
|
+
* machine-checks.
|
|
318
|
+
*/
|
|
319
|
+
export interface ViewSwitcherScheduler {
|
|
320
|
+
/** Run `callback` after `ms`; return a handle {@link cancel} understands. */
|
|
321
|
+
schedule(callback: () => void, ms: number): ViewSwitcherTimerHandle;
|
|
322
|
+
/** Cancel a pending {@link schedule}. A stale or unknown handle must be a no-op. */
|
|
323
|
+
cancel(handle: ViewSwitcherTimerHandle): void;
|
|
324
|
+
}
|
|
325
|
+
/** Construction seams for {@link ViewSwitcherDragSwitch}. */
|
|
326
|
+
export interface ViewSwitcherDragSwitchOptions {
|
|
327
|
+
/** The platform timer adapter. */
|
|
328
|
+
scheduler: ViewSwitcherScheduler;
|
|
329
|
+
/** Called with the index that has been dwelt on long enough. */
|
|
330
|
+
onSwitch: (index: number) => void;
|
|
331
|
+
/** Dwell time in ms; defaults to {@link VIEW_SWITCHER_DRAG_SWITCH_DELAY}. */
|
|
332
|
+
delay?: number;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The 500 ms drag-hover auto-switch: hovering a non-active button while dragging
|
|
336
|
+
* switches to it, and leaving before the dwell elapses cancels.
|
|
337
|
+
*
|
|
338
|
+
* Present in BOTH C files and in neither port
|
|
339
|
+
* (adw-view-switcher-button.c:14, :58-63, :79-96; adw-inline-view-switcher.c:80,
|
|
340
|
+
* :194-236). Each button/toggle owns its OWN timer there, so this keeps one
|
|
341
|
+
* pending handle per index rather than a single global one — an enter on a
|
|
342
|
+
* second index does not silently disarm the first.
|
|
343
|
+
*/
|
|
344
|
+
export declare class ViewSwitcherDragSwitch {
|
|
345
|
+
private readonly _scheduler;
|
|
346
|
+
private readonly _onSwitch;
|
|
347
|
+
private readonly _delay;
|
|
348
|
+
private readonly _timers;
|
|
349
|
+
constructor(options: ViewSwitcherDragSwitchOptions);
|
|
350
|
+
/**
|
|
351
|
+
* A drag entered the button at `index` while `activeIndex` is selected.
|
|
352
|
+
* Returns whether a dwell was armed.
|
|
353
|
+
*
|
|
354
|
+
* `drag_enter_cb` early-returns when the hovered button is already active
|
|
355
|
+
* (adw-view-switcher-button.c:82-83; the inline twin compares indices at
|
|
356
|
+
* adw-inline-view-switcher.c:219), so hovering the current tab never
|
|
357
|
+
* schedules anything.
|
|
358
|
+
*/
|
|
359
|
+
enter(index: number, activeIndex: number): boolean;
|
|
360
|
+
/** The drag left the button at `index` — `drag_leave_cb` removes its source. */
|
|
361
|
+
leave(index: number): void;
|
|
362
|
+
/** Drop every pending dwell — used when the page list is rebuilt under the drag. */
|
|
363
|
+
cancel(): void;
|
|
364
|
+
/** Indices with a dwell still pending, ascending. Lets a test assert on the arming. */
|
|
365
|
+
get pending(): readonly number[];
|
|
366
|
+
}
|
|
367
|
+
/** Payload of a switcher selection change. */
|
|
368
|
+
export interface ViewSwitcherStateChange {
|
|
369
|
+
/** Index of the newly-selected PAGE, `-1` when nothing is selected. */
|
|
370
|
+
selected: number;
|
|
371
|
+
/** Its name, `''` when nothing is selected. */
|
|
372
|
+
name: string;
|
|
373
|
+
/** Its rendered label ({@link viewSwitcherLabel}), `''` when nothing is selected. */
|
|
374
|
+
title: string;
|
|
375
|
+
/**
|
|
376
|
+
* `true` for a user activation or an explicit select, `false` for a model-
|
|
377
|
+
* driven auto-pick (a page list rebuild, a visibility flip). Same tagging
|
|
378
|
+
* convention as `ComboState`/`SpinState`/`ViewStackState`; libadwaita
|
|
379
|
+
* notifies on both paths, so this is for suppressing feedback loops, not for
|
|
380
|
+
* dropping the notification.
|
|
381
|
+
*/
|
|
382
|
+
interactive: boolean;
|
|
383
|
+
}
|
|
384
|
+
/** Subscriber for {@link ViewSwitcherState} changes. */
|
|
385
|
+
export type ViewSwitcherStateListener = (change: ViewSwitcherStateChange) => void;
|
|
386
|
+
/** Construction seams for {@link ViewSwitcherState}. */
|
|
387
|
+
export interface ViewSwitcherStateOptions {
|
|
388
|
+
/** Platform timer adapter; without it the drag-hover auto-switch is inert. */
|
|
389
|
+
scheduler?: ViewSwitcherScheduler;
|
|
390
|
+
/** Dwell time in ms; defaults to {@link VIEW_SWITCHER_DRAG_SWITCH_DELAY}. */
|
|
391
|
+
dragSwitchDelay?: number;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* The page model + selection of a switcher that OWNS its pages — the browser and
|
|
395
|
+
* NativeScript switchers, which bundle the `AdwViewStack` libadwaita keeps
|
|
396
|
+
* separate.
|
|
397
|
+
*
|
|
398
|
+
* Selection is DELEGATED to {@link ViewStackState}, not re-implemented: the
|
|
399
|
+
* integer/range/already-selected/hidden guards, the by-name lookup, the
|
|
400
|
+
* first-VISIBLE-page auto-pick and the hide-fallback all come from there, which
|
|
401
|
+
* is where their conformance vectors already live. What this class adds is the
|
|
402
|
+
* C-faithful page record (so the button-visibility and badge rules have their
|
|
403
|
+
* inputs) and a name-preserving {@link setPages}, because both renderers rebuild
|
|
404
|
+
* their page list wholesale and libadwaita's selection follows the page OBJECT
|
|
405
|
+
* across such a rebuild (adw-view-stack.c:660-672) rather than the index.
|
|
406
|
+
*
|
|
407
|
+
* Policy and display mode are deliberately NOT here: each is one enum value plus
|
|
408
|
+
* one style class, validated by {@link isViewSwitcherPolicy} /
|
|
409
|
+
* {@link isInlineViewSwitcherDisplayMode} and rendered from
|
|
410
|
+
* {@link VIEW_SWITCHER_POLICIES} / {@link INLINE_VIEW_SWITCHER_DISPLAY_MODES}.
|
|
411
|
+
*/
|
|
412
|
+
export declare class ViewSwitcherState {
|
|
413
|
+
private _pages;
|
|
414
|
+
private _pagesView;
|
|
415
|
+
private _stack;
|
|
416
|
+
private readonly _listeners;
|
|
417
|
+
private readonly _drag;
|
|
418
|
+
constructor(options?: ViewSwitcherStateOptions);
|
|
419
|
+
/** Subscribe to selection changes. Returns an unsubscribe function. */
|
|
420
|
+
subscribe(listener: ViewSwitcherStateListener): () => void;
|
|
421
|
+
/** The pages, in declaration order — frozen, so a renderer cannot mutate the model. */
|
|
422
|
+
get pages(): readonly AdwViewSwitcherPage[];
|
|
423
|
+
/**
|
|
424
|
+
* Replace the whole page list, keeping the SELECTED PAGE selected across the
|
|
425
|
+
* rebuild whenever a page of the same name survives.
|
|
426
|
+
*
|
|
427
|
+
* libadwaita's selection is a page pointer compared by identity
|
|
428
|
+
* (`adw_view_stack_pages_is_selected`, adw-view-stack.c:660-672), so an
|
|
429
|
+
* insert before the selected page shifts its index without changing what is
|
|
430
|
+
* shown; a rebuild that dropped the selected page falls through to the
|
|
431
|
+
* first-visible auto-pick. Emits at most ONE change, tagged
|
|
432
|
+
* `interactive: false` — the page set changed, the user did not click.
|
|
433
|
+
*/
|
|
434
|
+
setPages(specs: readonly AdwViewSwitcherPageInit[]): void;
|
|
435
|
+
/** Index of the selected page, `-1` when nothing is selected. */
|
|
436
|
+
get selected(): number;
|
|
437
|
+
/** Name of the selected page, `''` when nothing is selected. */
|
|
438
|
+
get selectedName(): string;
|
|
439
|
+
/** The selected page record, or `undefined`. */
|
|
440
|
+
get selectedPage(): AdwViewSwitcherPage | undefined;
|
|
441
|
+
/** Number of pages. */
|
|
442
|
+
get count(): number;
|
|
443
|
+
/**
|
|
444
|
+
* Select by page index. Returns whether the selection changed.
|
|
445
|
+
*
|
|
446
|
+
* Every guard is {@link ViewStackState.setVisibleIndex}'s: a non-integer, a
|
|
447
|
+
* negative, an out-of-range and a hidden page are all silent no-ops — NOT
|
|
448
|
+
* clamped into range, which is what the browser switcher did (`active="-1"`
|
|
449
|
+
* jumped to the first page, `active="99"` to the last) where
|
|
450
|
+
* `adw_view_stack_pages_select_item` simply returns FALSE
|
|
451
|
+
* (adw-view-stack.c:682-684).
|
|
452
|
+
*/
|
|
453
|
+
setSelected(index: number, interactive?: boolean): boolean;
|
|
454
|
+
/** Select by page name. Returns whether the selection changed. */
|
|
455
|
+
selectName(name: string | null | undefined, interactive?: boolean): boolean;
|
|
456
|
+
/**
|
|
457
|
+
* Flip a page's `visible` flag. Returns whether the SELECTION moved.
|
|
458
|
+
*
|
|
459
|
+
* Both the switcher's page record and the delegated stack are updated, so the
|
|
460
|
+
* derived buttons and toggles rebuild against the same truth the selection
|
|
461
|
+
* fallback used (`update_child_visible`, adw-view-stack.c:1061-1082).
|
|
462
|
+
*/
|
|
463
|
+
setPageVisible(name: string, visible: boolean): boolean;
|
|
464
|
+
/** A drag entered the button/toggle for page `pageIndex`; arms the dwell. */
|
|
465
|
+
dragEnter(pageIndex: number): void;
|
|
466
|
+
/** The drag left page `pageIndex`; cancels its pending dwell. */
|
|
467
|
+
dragLeave(pageIndex: number): void;
|
|
468
|
+
/** Drop every pending dwell (the widget was torn down or the drag ended). */
|
|
469
|
+
cancelDrag(): void;
|
|
470
|
+
/** Page indices with a drag dwell still pending — the observable half of the timer. */
|
|
471
|
+
get pendingDragSwitches(): readonly number[];
|
|
472
|
+
/** Diagnostics the delegated stack recorded (C's `g_warning` texts). */
|
|
473
|
+
get diagnostics(): readonly string[];
|
|
474
|
+
private _subscribeStack;
|
|
475
|
+
private _emit;
|
|
476
|
+
}
|
|
477
|
+
/** Payload of a {@link ViewSwitcherBarState} change. */
|
|
478
|
+
export interface ViewSwitcherBarChange {
|
|
479
|
+
/** The REQUEST — `AdwViewSwitcherBar:reveal`, default `false`. */
|
|
480
|
+
reveal: boolean;
|
|
481
|
+
/** The DERIVED truth — {@link shouldRevealViewSwitcherBar}. */
|
|
482
|
+
revealed: boolean;
|
|
483
|
+
}
|
|
484
|
+
/** Subscriber for {@link ViewSwitcherBarState} changes. */
|
|
485
|
+
export type ViewSwitcherBarListener = (change: ViewSwitcherBarChange) => void;
|
|
486
|
+
/**
|
|
487
|
+
* `AdwViewSwitcherBar`'s reveal state machine: `reveal` is what the layout ASKS
|
|
488
|
+
* for, `revealed` is what the bar actually does.
|
|
489
|
+
*
|
|
490
|
+
* `update_bar_revealed` is re-run from `set_reveal`, from `set_stack` and from
|
|
491
|
+
* the pages' `items-changed` (adw-view-switcher-bar.c:340-343, :383, :277), so
|
|
492
|
+
* the derived value flips both when the flag changes and when the page set does
|
|
493
|
+
* — which is why {@link setPages} exists rather than the count being passed to
|
|
494
|
+
* {@link setReveal}. `reveal` defaults to FALSE (:256-259); the NativeScript bar
|
|
495
|
+
* started life VISIBLE, so a freshly constructed bar covered the screen bottom
|
|
496
|
+
* until someone set `revealed = false`.
|
|
497
|
+
*/
|
|
498
|
+
export declare class ViewSwitcherBarState {
|
|
499
|
+
private _reveal;
|
|
500
|
+
private _revealed;
|
|
501
|
+
private _pages;
|
|
502
|
+
private readonly _listeners;
|
|
503
|
+
/** Subscribe to reveal changes. Returns an unsubscribe function. */
|
|
504
|
+
subscribe(listener: ViewSwitcherBarListener): () => void;
|
|
505
|
+
/** Whether the layout asked for the bar — `AdwViewSwitcherBar:reveal`. */
|
|
506
|
+
get reveal(): boolean;
|
|
507
|
+
/** Whether the bar is actually shown — the derived truth. */
|
|
508
|
+
get revealed(): boolean;
|
|
509
|
+
/**
|
|
510
|
+
* Set the request. Returns whether `reveal` itself changed (C returns early
|
|
511
|
+
* before its notify when it did not, adw-view-switcher-bar.c:379-380); the
|
|
512
|
+
* subscriber only fires when the DERIVED value moves.
|
|
513
|
+
*/
|
|
514
|
+
setReveal(value: boolean): boolean;
|
|
515
|
+
/**
|
|
516
|
+
* Feed the bound stack's page list. Returns whether `revealed` flipped —
|
|
517
|
+
* the `items-changed` half of the same derivation.
|
|
518
|
+
*/
|
|
519
|
+
setPages(pages: readonly {
|
|
520
|
+
readonly visible: boolean;
|
|
521
|
+
}[]): boolean;
|
|
522
|
+
private _refresh;
|
|
523
|
+
}
|
|
524
|
+
export { stripMnemonic };
|