@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.
- 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/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/entry-row.js +1 -0
- package/lib/esm/glib.js +1 -0
- package/lib/esm/index.js +1 -1
- 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/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/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 +300 -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 +284 -0
- package/lib/types/conformance/checks.d.ts +29 -0
- package/lib/types/conformance/chrome.d.ts +195 -0
- package/lib/types/conformance/data-grid.d.ts +134 -0
- package/lib/types/conformance/dialog.d.ts +97 -0
- package/lib/types/conformance/entry-row.d.ts +185 -0
- package/lib/types/conformance/index.d.ts +44 -0
- package/lib/types/conformance/navigation-view.d.ts +235 -0
- package/lib/types/conformance/popover.d.ts +56 -0
- package/lib/types/conformance/preferences.d.ts +170 -0
- package/lib/types/conformance/rows.d.ts +51 -0
- package/lib/types/conformance/sidebar.d.ts +182 -0
- package/lib/types/conformance/split-button.d.ts +189 -0
- package/lib/types/conformance/split-view.d.ts +290 -0
- package/lib/types/conformance/tab-view.d.ts +441 -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 +134 -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/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 +43 -4
- 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 +49 -2
- package/lib/types/sidebar.d.ts +308 -0
- package/lib/types/sidebar.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 +714 -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 +266 -0
- package/lib/types/view-stack.spec.d.ts +2 -0
- package/lib/types/view-switcher.d.ts +521 -0
- package/lib/types/view-switcher.spec.d.ts +2 -0
- package/package.json +8 -4
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
/** `SCROLL_TIMEOUT_DURATION` (adw-carousel.c:22) — the lockout after a wheel step. */
|
|
2
|
+
export declare const CAROUSEL_SCROLL_TIMEOUT_MS = 150;
|
|
3
|
+
/**
|
|
4
|
+
* How close to a snap point counts as "the scroll has arrived", in pages —
|
|
5
|
+
* see {@link CarouselState.settleIfArrived}.
|
|
6
|
+
*
|
|
7
|
+
* Not a libadwaita constant: C knows a scroll finished because its own spring
|
|
8
|
+
* animation says so, while a renderer that lets the platform scroll (CSS
|
|
9
|
+
* scroll-snap, a NativeScript `ScrollView`) has only the offset, which lands on
|
|
10
|
+
* a sub-pixel value an exact compare would never match. A hundredth of a page is
|
|
11
|
+
* invisible and far tighter than the 0.02 the web port's old heuristic used.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CAROUSEL_SETTLE_EPSILON = 0.01;
|
|
14
|
+
/** Which axis the carousel pages along — `GtkOrientable:orientation`. */
|
|
15
|
+
export type CarouselOrientation = 'horizontal' | 'vertical';
|
|
16
|
+
/** One keynav / wheel step — `AdwNavigationDirection`. */
|
|
17
|
+
export type CarouselDirection = 'back' | 'forward';
|
|
18
|
+
/**
|
|
19
|
+
* The `GdkInputSource` cases `scroll_cb` distinguishes (adw-carousel.c:537-542).
|
|
20
|
+
* Everything that is neither a touchpad nor a mouse behaves the same, so the
|
|
21
|
+
* three-way split is the whole vocabulary the rule needs.
|
|
22
|
+
*/
|
|
23
|
+
export type CarouselScrollSource = 'touchpad' | 'mouse' | 'other';
|
|
24
|
+
/** The scrollable interval a position is clamped into — `get_range`. */
|
|
25
|
+
export interface CarouselRange {
|
|
26
|
+
/** Always 0 (adw-carousel.c:215-216). */
|
|
27
|
+
lower: number;
|
|
28
|
+
/** `MAX (0, position_shift + last snap point)` (:219). */
|
|
29
|
+
upper: number;
|
|
30
|
+
}
|
|
31
|
+
/** Input to {@link carouselWheelStep} — one scroll event, already normalized. */
|
|
32
|
+
export interface CarouselWheelInput {
|
|
33
|
+
/** Horizontal delta; positive scrolls forward. */
|
|
34
|
+
deltaX: number;
|
|
35
|
+
/** Vertical delta; positive scrolls forward. */
|
|
36
|
+
deltaY: number;
|
|
37
|
+
/** The carousel's orientation, which decides which axis counts. */
|
|
38
|
+
orientation: CarouselOrientation;
|
|
39
|
+
/** The device the event came from. */
|
|
40
|
+
source: CarouselScrollSource;
|
|
41
|
+
}
|
|
42
|
+
/** Arguments of {@link carouselReorderShift} — all four snap-point values it compares. */
|
|
43
|
+
export interface CarouselReorderShiftInput {
|
|
44
|
+
/** Snap point of the page the carousel is currently closest to. */
|
|
45
|
+
closestPoint: number;
|
|
46
|
+
/** Snap point the moved page had before the move. */
|
|
47
|
+
oldPoint: number;
|
|
48
|
+
/** Snap point it lands on. */
|
|
49
|
+
newPoint: number;
|
|
50
|
+
/** The moved page's reveal size — how much geometry crosses the position. */
|
|
51
|
+
size: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The snap point of every page, from their reveal sizes:
|
|
55
|
+
* `snapPoint[i] = (Σ_{j≤i} size[j]) − 1` (`adw_carousel_size_allocate`,
|
|
56
|
+
* adw-carousel.c:777-789).
|
|
57
|
+
*
|
|
58
|
+
* Sizes are reveal FRACTIONS, not pixels, so mid-animation snap points are
|
|
59
|
+
* fractional — and a page that was just inserted (size 0, :1385) pushes the
|
|
60
|
+
* first snap point NEGATIVE. That is legal and load-bearing: it is what makes
|
|
61
|
+
* the following pages keep their positions while the new one grows in.
|
|
62
|
+
*/
|
|
63
|
+
export declare function carouselSnapPoints(sizes: readonly number[]): number[];
|
|
64
|
+
/**
|
|
65
|
+
* The inverse of {@link carouselSnapPoints}: `sizes[0] = points[0] + 1` and
|
|
66
|
+
* `sizes[i] = points[i] − points[i−1]` (adw-carousel-indicator-dots.c:189-191).
|
|
67
|
+
*
|
|
68
|
+
* This is the ONLY channel through which an indicator learns per-page reveal
|
|
69
|
+
* state — `AdwSwipeable` hands out snap points, never sizes — so an indicator
|
|
70
|
+
* that wants to fade a page in has to reconstruct them.
|
|
71
|
+
*/
|
|
72
|
+
export declare function carouselSizesFromSnapPoints(points: readonly number[]): number[];
|
|
73
|
+
/**
|
|
74
|
+
* The scrollable range — `get_range` (adw-carousel.c:207-220).
|
|
75
|
+
*
|
|
76
|
+
* `positionShift` is the pending compensation an insert/remove/reorder
|
|
77
|
+
* accumulates before the next allocation; it is part of the bound because C adds
|
|
78
|
+
* it there (:219), so a shift large enough to cancel the last snap point
|
|
79
|
+
* collapses the range to `[0, 0]` rather than going negative.
|
|
80
|
+
*/
|
|
81
|
+
export declare function carouselRange(snapPoints: readonly number[], positionShift?: number): CarouselRange;
|
|
82
|
+
/**
|
|
83
|
+
* `set_position`'s guard (adw-carousel.c:269) — the single clamp every position
|
|
84
|
+
* write in the widget goes through.
|
|
85
|
+
*
|
|
86
|
+
* Fractional positions pass through untouched: this bounds the scroll, it does
|
|
87
|
+
* not snap to a page. Uses GLib's `CLAMP`, which tests the HIGH bound first —
|
|
88
|
+
* the range here can never invert, but the primitive is the one C uses.
|
|
89
|
+
*/
|
|
90
|
+
export declare function carouselClampPosition(position: number, snapPoints: readonly number[], positionShift?: number): number;
|
|
91
|
+
/**
|
|
92
|
+
* The index of the snap point nearest `position`, `-1` for an empty list —
|
|
93
|
+
* `get_closest_child_at` (adw-carousel.c:180-205).
|
|
94
|
+
*
|
|
95
|
+
* The tie-break is the whole point: C replaces its current best only on a strict
|
|
96
|
+
* `>`, so at an exact half-way position the EARLIER page wins. Exported rather
|
|
97
|
+
* than inlined because `get_closest_child_at` is called with four different
|
|
98
|
+
* include/exclude combinations of adding and removing children, and each caller
|
|
99
|
+
* must get the same tie-break.
|
|
100
|
+
*/
|
|
101
|
+
export declare function carouselClosestSnapPoint(position: number, snapPoints: readonly number[]): number;
|
|
102
|
+
/**
|
|
103
|
+
* The page `position` settles on — `get_page_at_position` (adw-carousel.c:222-239):
|
|
104
|
+
* clamp into the range first, then take the nearest snap point.
|
|
105
|
+
*
|
|
106
|
+
* Returns `-1` for an empty carousel, matching `find_child_index` (:155) and the
|
|
107
|
+
* `page-changed` documentation, which spells that case out (:1150-1151).
|
|
108
|
+
*
|
|
109
|
+
* Rounds an exact `.5` DOWN, via {@link carouselClosestSnapPoint}. Do not
|
|
110
|
+
* "simplify" this to `Math.round`: that is what both ports did, and it disagrees
|
|
111
|
+
* with GTK on every half-way position.
|
|
112
|
+
*/
|
|
113
|
+
export declare function carouselPageAtPosition(position: number, snapPoints: readonly number[]): number;
|
|
114
|
+
/**
|
|
115
|
+
* The page an arrow key moves to, or `null` when the step is refused —
|
|
116
|
+
* `navigate_to_direction` (adw-carousel.c:475-508).
|
|
117
|
+
*
|
|
118
|
+
* `null` means C returned `FALSE`: an empty carousel, or already at the bound in
|
|
119
|
+
* that direction. Home/End are the same operation with targets `0` and
|
|
120
|
+
* `nPages − 1` (`keynav_bounds_cb`, :641-674).
|
|
121
|
+
*
|
|
122
|
+
* The returned index is C's raw `index ± 1` and is NOT clamped — only the WHEEL
|
|
123
|
+
* path clamps (:567). With a position inside `[0, nPages − 1]` it is always in
|
|
124
|
+
* range; outside it, `adw_carousel_get_nth_page`'s precondition (:1616) is what
|
|
125
|
+
* rejects it, which is exactly what {@link CarouselState.scrollTo} does.
|
|
126
|
+
*/
|
|
127
|
+
export declare function carouselNavigateTarget(position: number, nPages: number, direction: CarouselDirection): number | null;
|
|
128
|
+
/**
|
|
129
|
+
* How many pages one scroll event moves — `scroll_cb`'s axis rules
|
|
130
|
+
* (adw-carousel.c:537-559). `0` means "propagate the event", the only case where
|
|
131
|
+
* C returns `GDK_EVENT_PROPAGATE` from this part of the handler.
|
|
132
|
+
*
|
|
133
|
+
* Three rules, all of which one port or the other loses:
|
|
134
|
+
* - a TOUCHPAD source is always ignored (:537-538), because its kinetic
|
|
135
|
+
* scrolling is already driving the swipe tracker;
|
|
136
|
+
* - the vertical delta counts when the carousel is vertical OR the source is a
|
|
137
|
+
* mouse — "mice often don't have easily accessible horizontal scrolling"
|
|
138
|
+
* (:540-542, :547-552);
|
|
139
|
+
* - the horizontal delta is a FALLBACK: consulted only for a horizontal
|
|
140
|
+
* carousel, and only when the vertical branch produced nothing (:554-559).
|
|
141
|
+
* The web port dropped it entirely by returning early on `|dy| <= |dx|`.
|
|
142
|
+
*/
|
|
143
|
+
export declare function carouselWheelStep(input: CarouselWheelInput): -1 | 0 | 1;
|
|
144
|
+
/**
|
|
145
|
+
* How far the position must move so the visible page does not jump when a page
|
|
146
|
+
* is reordered — the `position_shift` delta of `adw_carousel_reorder`
|
|
147
|
+
* (adw-carousel.c:1488-1495).
|
|
148
|
+
*
|
|
149
|
+
* Three branches: the moved page IS the current one (follow it, `newPoint −
|
|
150
|
+
* oldPoint`); it crossed the current position from after to before (`+size`, the
|
|
151
|
+
* content ahead grew by that page); or from before to after (`−size`). Anything
|
|
152
|
+
* that does not cross the position leaves it alone. Every comparison is
|
|
153
|
+
* epsilon-tolerant, because snap points are accumulated sums.
|
|
154
|
+
*/
|
|
155
|
+
export declare function carouselReorderShift(args: CarouselReorderShiftInput): number;
|
|
156
|
+
/**
|
|
157
|
+
* Which of C's three "tell someone" sites a {@link CarouselStateChange} came
|
|
158
|
+
* from. libadwaita has three distinct ones and collapsing them into a single
|
|
159
|
+
* opaque notification would lose information the GObject API has:
|
|
160
|
+
* - `position` — `set_position` notified `notify::position` (adw-carousel.c:281);
|
|
161
|
+
* - `n-pages` — an insert or a remove notified `notify::n-pages` (:1406, :1531);
|
|
162
|
+
* - `geometry` — only `gtk_widget_queue_allocate` ran: a size or order change
|
|
163
|
+
* that moved no position (:296, :1498).
|
|
164
|
+
*/
|
|
165
|
+
export type CarouselChangeReason = 'position' | 'n-pages' | 'geometry';
|
|
166
|
+
/** Payload of a {@link CarouselState} notification. */
|
|
167
|
+
export interface CarouselStateChange {
|
|
168
|
+
/** The clamped fractional scroll position. */
|
|
169
|
+
position: number;
|
|
170
|
+
/** Number of pages, excluding ones whose removal is still animating. */
|
|
171
|
+
nPages: number;
|
|
172
|
+
/** {@link carouselPageAtPosition} for the current position; `-1` when empty. */
|
|
173
|
+
page: number;
|
|
174
|
+
/**
|
|
175
|
+
* `true` for a user navigation (wheel, keynav, an interactive scroll),
|
|
176
|
+
* `false` for a programmatic or model-driven one. libadwaita notifies
|
|
177
|
+
* unconditionally (:281) — the flag exists so a bound indicator can tell the
|
|
178
|
+
* two apart, not so a renderer can drop the notification.
|
|
179
|
+
*/
|
|
180
|
+
interactive: boolean;
|
|
181
|
+
/** Which C notification site this corresponds to. */
|
|
182
|
+
reason: CarouselChangeReason;
|
|
183
|
+
}
|
|
184
|
+
/** Subscriber for {@link CarouselState} changes. */
|
|
185
|
+
export type CarouselStateListener = (change: CarouselStateChange) => void;
|
|
186
|
+
/** Subscriber for `page-changed` — `index` is `-1` for an empty carousel. */
|
|
187
|
+
export type CarouselPageChangedListener = (index: number) => void;
|
|
188
|
+
/**
|
|
189
|
+
* A scroll the state machine wants performed — the renderer seam, in the shape
|
|
190
|
+
* of `AdwToastQueueHandlers`' `onShow`/`onHide`.
|
|
191
|
+
*
|
|
192
|
+
* The core owns WHICH page is scrolled to (the wheel and keynav paths compute it
|
|
193
|
+
* and no renderer should redo that); the renderer owns HOW, because that is a
|
|
194
|
+
* DOM `scrollTo` on one side and a `scrollToHorizontalOffset` on the other.
|
|
195
|
+
*/
|
|
196
|
+
export interface CarouselScrollRequest {
|
|
197
|
+
/** Target page index, always a valid index into the non-removing pages. */
|
|
198
|
+
index: number;
|
|
199
|
+
/** Its snap point — the value `position` must end up at. */
|
|
200
|
+
position: number;
|
|
201
|
+
/** Whether this came from a user navigation. */
|
|
202
|
+
interactive: boolean;
|
|
203
|
+
/** Whether the renderer is expected to animate (and then call `settle()`). */
|
|
204
|
+
animate: boolean;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Construction seams and the libadwaita property DEFAULTS, which both ports got
|
|
208
|
+
* wrong or omitted.
|
|
209
|
+
*/
|
|
210
|
+
export interface CarouselStateOptions {
|
|
211
|
+
/** `GtkOrientable:orientation`, default `'horizontal'` (adw-carousel.c:1205). */
|
|
212
|
+
orientation?: CarouselOrientation;
|
|
213
|
+
/** `AdwCarousel:interactive`, default TRUE (:1051-1054). Gates wheel + keynav. */
|
|
214
|
+
interactive?: boolean;
|
|
215
|
+
/** `AdwCarousel:allow-scroll-wheel`, default TRUE (:1103-1106, :1201). */
|
|
216
|
+
allowScrollWheel?: boolean;
|
|
217
|
+
/** `AdwCarousel:allow-long-swipes`, default FALSE (:1115-1118). */
|
|
218
|
+
allowLongSwipes?: boolean;
|
|
219
|
+
/** `AdwCarousel:spacing` in px, default 0 (:1061-1066). Feeds `distance` (:767). */
|
|
220
|
+
spacing?: number;
|
|
221
|
+
/** `AdwCarousel:reveal-duration` in ms, default 0 (:1127-1132, :1206). */
|
|
222
|
+
revealDuration?: number;
|
|
223
|
+
/** Clock for the wheel lockout. Injected, never a global — default `Date.now`. */
|
|
224
|
+
now?: () => number;
|
|
225
|
+
/** Renderer seam invoked for every accepted {@link CarouselState.scrollTo}. */
|
|
226
|
+
onScrollTo?: (request: CarouselScrollRequest) => void;
|
|
227
|
+
/**
|
|
228
|
+
* Default for `adw_carousel_scroll_to`'s `animate` argument (:1571-1598).
|
|
229
|
+
*
|
|
230
|
+
* The core has no animator, so `true` means the RENDERER drives the ramp:
|
|
231
|
+
* `scrollTo` only issues the {@link CarouselScrollRequest} and waits for the
|
|
232
|
+
* renderer to feed positions back through {@link CarouselState.setPosition}
|
|
233
|
+
* and finish with {@link CarouselState.settle}. `false` (the default) is
|
|
234
|
+
* `do_scroll_to`'s skip path (:1541-1542): the position jumps to the target
|
|
235
|
+
* and `page-changed` fires at once.
|
|
236
|
+
*/
|
|
237
|
+
animateScroll?: boolean;
|
|
238
|
+
}
|
|
239
|
+
/** Per-call overrides for {@link CarouselState.scrollTo}. */
|
|
240
|
+
export interface CarouselScrollOptions {
|
|
241
|
+
/** Tag the resulting change as a user navigation. Default `false`. */
|
|
242
|
+
interactive?: boolean;
|
|
243
|
+
/** Override {@link CarouselStateOptions.animateScroll} for this scroll. */
|
|
244
|
+
animate?: boolean;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The page list of an `Adw.Carousel` plus its fractional position — the insert /
|
|
248
|
+
* reorder / remove ordering rules, the `position_shift` bookkeeping, the wheel
|
|
249
|
+
* lockout and the `page-changed` emission, once, for every renderer.
|
|
250
|
+
*
|
|
251
|
+
* The reveal ANIMATION is not here: a renderer feeds its eased values through
|
|
252
|
+
* {@link setPageSize}, and a carousel with the default `reveal-duration` of 0
|
|
253
|
+
* calls {@link skipReveal} instead. What is here is everything that decides what
|
|
254
|
+
* those sizes MEAN — snap points, the range, which page is current, and how far
|
|
255
|
+
* the position has to move so the visible page stays put.
|
|
256
|
+
*
|
|
257
|
+
* Two array shapes appear and they are not the same length while a removal
|
|
258
|
+
* animates: {@link snapPoints} and {@link sizes} cover every tracked child
|
|
259
|
+
* (`adw_carousel_get_snap_points`, :1260-1283, walks all of them), while
|
|
260
|
+
* {@link nPages} and {@link indexOf} skip the ones being removed
|
|
261
|
+
* (`adw_carousel_get_n_pages`, :1640-1645). That is C, and an indicator that
|
|
262
|
+
* conflated them would drop a dot the moment a page started shrinking.
|
|
263
|
+
*/
|
|
264
|
+
export declare class CarouselState {
|
|
265
|
+
private readonly _children;
|
|
266
|
+
private _position;
|
|
267
|
+
private _orientation;
|
|
268
|
+
private _interactive;
|
|
269
|
+
private _allowScrollWheel;
|
|
270
|
+
private _allowLongSwipes;
|
|
271
|
+
private _spacing;
|
|
272
|
+
private _revealDuration;
|
|
273
|
+
private readonly _now;
|
|
274
|
+
private readonly _onScrollTo;
|
|
275
|
+
private readonly _animateScroll;
|
|
276
|
+
/** When the current wheel lockout started, `null` while no lockout is armed. */
|
|
277
|
+
private _wheelLockedAt;
|
|
278
|
+
/** The page {@link settleIfArrived} last reported, `null` while the scroll is moving. */
|
|
279
|
+
private _settledPage;
|
|
280
|
+
private readonly _listeners;
|
|
281
|
+
private readonly _pageChangedListeners;
|
|
282
|
+
private readonly _diagnostics;
|
|
283
|
+
constructor(options?: CarouselStateOptions);
|
|
284
|
+
/** Subscribe to state changes. Returns an unsubscribe function. */
|
|
285
|
+
subscribe(listener: CarouselStateListener): () => void;
|
|
286
|
+
/** Subscribe to `page-changed` (adw-carousel.c:1153-1165). Returns an unsubscribe function. */
|
|
287
|
+
onPageChanged(listener: CarouselPageChangedListener): () => void;
|
|
288
|
+
private _emit;
|
|
289
|
+
/** Number of pages, skipping ones whose removal is still animating (:1640-1645). */
|
|
290
|
+
get nPages(): number;
|
|
291
|
+
/** The ids of the pages that count towards {@link nPages}, in order. */
|
|
292
|
+
get ids(): readonly string[];
|
|
293
|
+
/** The clamped fractional scroll position (`AdwCarousel:position`). */
|
|
294
|
+
get position(): number;
|
|
295
|
+
/** Every tracked child's reveal size, INCLUDING ones being removed. */
|
|
296
|
+
get sizes(): number[];
|
|
297
|
+
/** Every tracked child's snap point — `adw_carousel_get_snap_points` (:1260-1283). */
|
|
298
|
+
get snapPoints(): number[];
|
|
299
|
+
/** The scrollable range the position is clamped into. */
|
|
300
|
+
get range(): CarouselRange;
|
|
301
|
+
/**
|
|
302
|
+
* Snap points of the pages that still count — the array every page LOOKUP
|
|
303
|
+
* runs against, because `get_page_at_position` excludes removing children
|
|
304
|
+
* (`get_closest_child_at (…, TRUE, FALSE)`, :233) and `find_child_index`
|
|
305
|
+
* numbers them out too (:146-147).
|
|
306
|
+
*
|
|
307
|
+
* Their values still come from the full accumulation, so a shrinking page
|
|
308
|
+
* keeps pushing the pages after it until it reaches size 0.
|
|
309
|
+
*/
|
|
310
|
+
private _visibleSnapPoints;
|
|
311
|
+
/**
|
|
312
|
+
* The page `position` settles on, `-1` when the carousel is empty.
|
|
313
|
+
*
|
|
314
|
+
* C clamps against the FULL range here (:229-231) while searching only the
|
|
315
|
+
* visible children; clamping against the visible points instead cannot
|
|
316
|
+
* change the answer, because snap points ascend and both clamps land at or
|
|
317
|
+
* beyond the last visible one, where the nearest visible point is the same.
|
|
318
|
+
*/
|
|
319
|
+
pageAt(position: number): number;
|
|
320
|
+
/**
|
|
321
|
+
* Index of the page with `id` among the pages that count, `-1` when it is
|
|
322
|
+
* unknown OR is being removed — `find_child_index (…, count_removing =
|
|
323
|
+
* FALSE)` skips a removing child before it ever compares (:146-147).
|
|
324
|
+
*/
|
|
325
|
+
indexOf(id: string): number;
|
|
326
|
+
/**
|
|
327
|
+
* The snap point of the `index`-th page that counts, `undefined` when the
|
|
328
|
+
* index is out of range — `adw_carousel_get_nth_page` followed by reading
|
|
329
|
+
* `info->snap_point`, which is what `scroll_to` animates towards (:1618,
|
|
330
|
+
* :392-393).
|
|
331
|
+
*
|
|
332
|
+
* A renderer needs this to tell "the scroll has arrived" from "the scroll is
|
|
333
|
+
* still moving", and it must not index {@link snapPoints} by a page index to
|
|
334
|
+
* get it: those two arrays disagree while a removal is animating.
|
|
335
|
+
*/
|
|
336
|
+
snapPointOf(index: number): number | undefined;
|
|
337
|
+
/** Full-list index of the `n`-th page that counts, `-1` when out of range — `get_nth_link` (:158-178). */
|
|
338
|
+
private _nthLink;
|
|
339
|
+
/** Full-list index of the child nearest `position`, honouring C's include flags. */
|
|
340
|
+
private _closestChildIndex;
|
|
341
|
+
/**
|
|
342
|
+
* `update_shift_position_flag` (adw-carousel.c:241-258): a page that is at or
|
|
343
|
+
* BEFORE the currently-shown one must drag the position along as it grows or
|
|
344
|
+
* shrinks, otherwise the visible page slides sideways under the user.
|
|
345
|
+
*
|
|
346
|
+
* The lookup deliberately EXCLUDES adding children and INCLUDES removing
|
|
347
|
+
* ones (:249), so the position still follows a page that is being removed
|
|
348
|
+
* while it is the active one.
|
|
349
|
+
*/
|
|
350
|
+
private _updateShiftPositionFlag;
|
|
351
|
+
/** `set_position`'s per-child refresh of the shift flags (adw-carousel.c:274-279). */
|
|
352
|
+
private _updateShiftFlags;
|
|
353
|
+
/**
|
|
354
|
+
* `set_position` (adw-carousel.c:260-282) — clamp, store, refresh the shift
|
|
355
|
+
* flags, notify. Returns whether the stored value changed; the notification
|
|
356
|
+
* fires either way, because C's `g_object_notify_by_pspec` at :281 is
|
|
357
|
+
* unconditional and a bound indicator that only repaints on a CHANGE misses
|
|
358
|
+
* the settle back onto the page it started from.
|
|
359
|
+
*
|
|
360
|
+
* A non-finite position is refused outright and recorded in
|
|
361
|
+
* {@link diagnostics}. `AdwCarousel:position` is a double declared over
|
|
362
|
+
* `[0, G_MAXDOUBLE]` (:1036-1041), so NaN is outside the property's own
|
|
363
|
+
* contract — and letting one through is what left the NativeScript port with
|
|
364
|
+
* a NaN position and no active dot at all.
|
|
365
|
+
*/
|
|
366
|
+
setPosition(position: number, interactive?: boolean): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Scroll to a page — `adw_carousel_get_nth_page` + `scroll_to` (:1609-1621,
|
|
369
|
+
* :378-397). Returns whether the scroll was accepted.
|
|
370
|
+
*
|
|
371
|
+
* Out-of-range, negative and non-integer indices are REFUSED, not clamped:
|
|
372
|
+
* `get_nth_page` fails its precondition and hands `scroll_to` a NULL widget,
|
|
373
|
+
* which returns before touching anything (:385-386). Only the wheel path
|
|
374
|
+
* clamps, and it does so before it gets here (:567). The refusal is recorded
|
|
375
|
+
* in {@link diagnostics}, which is where `scrollToPage(NaN)` now ends up
|
|
376
|
+
* instead of in the position.
|
|
377
|
+
*/
|
|
378
|
+
scrollTo(index: number, options?: CarouselScrollOptions): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* `scroll_animation_done_cb` (adw-carousel.c:363-376) — the scroll has come to
|
|
381
|
+
* rest, so emit `page-changed` with the page the position landed on.
|
|
382
|
+
*
|
|
383
|
+
* Emitted after EVERY completed scroll, including one that settles back onto
|
|
384
|
+
* the page it started from, and with index `-1` when the carousel is empty —
|
|
385
|
+
* the case the signal's own documentation calls out (:1150-1151) and that the
|
|
386
|
+
* web port's index-change gate made unreachable.
|
|
387
|
+
*/
|
|
388
|
+
settle(): void;
|
|
389
|
+
/**
|
|
390
|
+
* {@link settle} for a renderer that does not own its scroll animation:
|
|
391
|
+
* emits `page-changed` the first time the position comes to rest on a snap
|
|
392
|
+
* point, and re-arms as soon as it leaves one. Returns whether it emitted.
|
|
393
|
+
*
|
|
394
|
+
* A DEVIATION with a reason: `scroll_animation_done_cb` (:363-376) is driven
|
|
395
|
+
* by the spring animation finishing, and neither CSS scroll-snap nor a
|
|
396
|
+
* NativeScript `ScrollView` has an equivalent — both only report offsets. So
|
|
397
|
+
* ARRIVAL at a snap point stands in for "the animation finished", and the
|
|
398
|
+
* one-shot bookkeeping lives here rather than in two renderers, where it
|
|
399
|
+
* would be the third copy of the same idea to drift.
|
|
400
|
+
*/
|
|
401
|
+
settleIfArrived(epsilon?: number): boolean;
|
|
402
|
+
/**
|
|
403
|
+
* One keynav step — `keynav_cb` → `navigate_to_direction` (:579-639, :475-508).
|
|
404
|
+
* Returns whether the carousel moved.
|
|
405
|
+
*
|
|
406
|
+
* The `interactive` gate lives here because `keynav_cb` checks it before
|
|
407
|
+
* calling `navigate_to_direction` (:588); `adw_carousel_scroll_to` is NOT
|
|
408
|
+
* gated, which is why {@link scrollTo} isn't either.
|
|
409
|
+
*/
|
|
410
|
+
navigate(direction: CarouselDirection): boolean;
|
|
411
|
+
/**
|
|
412
|
+
* One scroll-wheel event — `scroll_cb` (adw-carousel.c:510-577). Returns the
|
|
413
|
+
* step taken; `0` means the event was NOT consumed and must propagate, which
|
|
414
|
+
* is the only value for which C returns `GDK_EVENT_PROPAGATE`.
|
|
415
|
+
*
|
|
416
|
+
* The four gates run in C's order — the property, the 150 ms lockout,
|
|
417
|
+
* `interactive`, and an empty carousel (:523-533) — then the axis rules, then
|
|
418
|
+
* one clamped page step and a fresh lockout (:566-574). A step that is
|
|
419
|
+
* refused by the clamp (already on the last page) still consumes the event
|
|
420
|
+
* and still arms the lockout, exactly as C does.
|
|
421
|
+
*/
|
|
422
|
+
handleWheel(input: Omit<CarouselWheelInput, 'orientation'>): -1 | 0 | 1;
|
|
423
|
+
/**
|
|
424
|
+
* `adw_carousel_insert` (adw-carousel.c:1370-1407). Returns whether the page
|
|
425
|
+
* was added.
|
|
426
|
+
*
|
|
427
|
+
* `position` is `-1` (append, the default) or an index to insert BEFORE; an
|
|
428
|
+
* index past the end appends too, because `get_nth_link` returns NULL there
|
|
429
|
+
* (:1388-1391 + the documented behaviour at :1366-1368). Anything below `-1`
|
|
430
|
+
* fails C's precondition (:1381) and is recorded instead.
|
|
431
|
+
*
|
|
432
|
+
* The page starts at size 0 and `adding` (:1385-1386) — it occupies no
|
|
433
|
+
* geometry yet, which is what pushes the first snap point negative. A
|
|
434
|
+
* renderer either ramps it with {@link setPageSize} or, with the default
|
|
435
|
+
* `reveal-duration` of 0, finishes it at once with {@link skipReveal}.
|
|
436
|
+
*/
|
|
437
|
+
insertPage(id: string, position?: number): boolean;
|
|
438
|
+
/**
|
|
439
|
+
* `adw_carousel_remove` (adw-carousel.c:1508-1532). Returns whether a page was
|
|
440
|
+
* removed.
|
|
441
|
+
*
|
|
442
|
+
* The page leaves {@link nPages} immediately (:1522 + :1640-1645) but keeps
|
|
443
|
+
* its geometry until its size reaches 0, so the pages after it slide over
|
|
444
|
+
* instead of jumping. A page that is still ANIMATING IN disappears at once
|
|
445
|
+
* instead: `animate_child_resize` skips the in-flight reveal, and finishing
|
|
446
|
+
* it runs `resize_animation_done_cb`, which frees a removing child on the
|
|
447
|
+
* spot (:329-337 → :309-313). C runs that skipped reveal to its target first
|
|
448
|
+
* and banks the shift; dropping the child outright lands in the same state,
|
|
449
|
+
* because the banked shift and the geometry it paid for are freed together.
|
|
450
|
+
*/
|
|
451
|
+
removePage(id: string): boolean;
|
|
452
|
+
/**
|
|
453
|
+
* `adw_carousel_reorder` (adw-carousel.c:1419-1499). Returns whether the page
|
|
454
|
+
* moved.
|
|
455
|
+
*
|
|
456
|
+
* `position` is `-1` or past the end for "move to the end". The three
|
|
457
|
+
* early-outs are C's and they are not interchangeable: a `position` equal to
|
|
458
|
+
* the page's CURRENT one returns before normalisation (:1439-1440), and
|
|
459
|
+
* moving the last page to the end is a no-op checked after it (:1448-1449).
|
|
460
|
+
* The position compensation is {@link carouselReorderShift}.
|
|
461
|
+
*/
|
|
462
|
+
reorderPage(id: string, position: number): boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Feed one frame of a page's reveal animation —
|
|
465
|
+
* `resize_animation_value_cb` + `resize_animation_done_cb` (:284-316).
|
|
466
|
+
* Returns whether the size was applied.
|
|
467
|
+
*
|
|
468
|
+
* A size change on a page at or before the current one moves the position by
|
|
469
|
+
* the same delta (:293-294), which is what keeps the visible page still while
|
|
470
|
+
* a page grows in ahead of it. C banks that delta in `position_shift` and
|
|
471
|
+
* applies it at the next `size_allocate` (:732-736); with no allocation cycle
|
|
472
|
+
* to wait for, it is applied here — the settled state is identical.
|
|
473
|
+
*
|
|
474
|
+
* Reaching the animation's target ENDS it: a page that arrives at 1 stops
|
|
475
|
+
* being `adding`, and one that arrives at 0 while removing is dropped from
|
|
476
|
+
* the geometry (:306-313).
|
|
477
|
+
*/
|
|
478
|
+
setPageSize(id: string, size: number): boolean;
|
|
479
|
+
/**
|
|
480
|
+
* Finish a page's pending reveal or removal at once — `adw_animation_skip`
|
|
481
|
+
* (:331), which jumps a timed animation to its target value.
|
|
482
|
+
*
|
|
483
|
+
* This is the whole reveal for a carousel with the default `reveal-duration`
|
|
484
|
+
* of 0 (:1206), which is what both renderers run today, and it keeps the
|
|
485
|
+
* "which value does this page animate TO" rule out of both of them. Returns
|
|
486
|
+
* whether anything was pending.
|
|
487
|
+
*
|
|
488
|
+
* An unknown id is NOT a diagnostic here, unlike everywhere else: removing a
|
|
489
|
+
* page that was still revealing frees it on the spot (:329-337), so a
|
|
490
|
+
* renderer that finishes what it just removed legitimately finds nothing.
|
|
491
|
+
*/
|
|
492
|
+
skipReveal(id: string): boolean;
|
|
493
|
+
/** `GtkOrientable:orientation` — which axis the carousel pages along. */
|
|
494
|
+
get orientation(): CarouselOrientation;
|
|
495
|
+
/** Set the orientation. Returns whether it changed (:982-992). */
|
|
496
|
+
setOrientation(orientation: CarouselOrientation): boolean;
|
|
497
|
+
/** `AdwCarousel:interactive` — whether the carousel can be navigated at all. */
|
|
498
|
+
get interactive(): boolean;
|
|
499
|
+
/** Set `interactive`. Returns whether it changed (:1694-1708). */
|
|
500
|
+
setInteractive(value: boolean): boolean;
|
|
501
|
+
/** `AdwCarousel:allow-scroll-wheel` — default TRUE, which both ports lost. */
|
|
502
|
+
get allowScrollWheel(): boolean;
|
|
503
|
+
/** Set `allow-scroll-wheel`. Returns whether it changed (:1852-1866). */
|
|
504
|
+
setAllowScrollWheel(value: boolean): boolean;
|
|
505
|
+
/**
|
|
506
|
+
* `AdwCarousel:allow-long-swipes` — whether one flick may cross more than one
|
|
507
|
+
* snap point. Forwarded to the swipe tracker in C (:1900-1914); the state
|
|
508
|
+
* machine only carries it, because the gesture itself is the renderer's.
|
|
509
|
+
*/
|
|
510
|
+
get allowLongSwipes(): boolean;
|
|
511
|
+
/** Set `allow-long-swipes`. Returns whether it changed. */
|
|
512
|
+
setAllowLongSwipes(value: boolean): boolean;
|
|
513
|
+
/** `AdwCarousel:spacing` in px — the gap between pages, part of `distance` (:767). */
|
|
514
|
+
get spacing(): number;
|
|
515
|
+
/** Set `spacing`. Returns whether it changed. A `guint` in C, so negatives are refused. */
|
|
516
|
+
setSpacing(spacing: number): boolean;
|
|
517
|
+
/** `AdwCarousel:reveal-duration` in ms — how long a page takes to grow in. */
|
|
518
|
+
get revealDuration(): number;
|
|
519
|
+
/** Set `reveal-duration`. Returns whether it changed. A `guint` in C. */
|
|
520
|
+
setRevealDuration(ms: number): boolean;
|
|
521
|
+
/**
|
|
522
|
+
* The px distance between two page origins — `self->distance` (:767), the
|
|
523
|
+
* unit a renderer converts a position into a scroll offset with.
|
|
524
|
+
* `pageLength` is the measured size of the largest page along the
|
|
525
|
+
* carousel's own axis.
|
|
526
|
+
*/
|
|
527
|
+
pageDistance(pageLength: number): number;
|
|
528
|
+
/**
|
|
529
|
+
* Every warning C would have printed, in order — the refused scroll targets,
|
|
530
|
+
* the bad insert/reorder positions, the unknown page ids and the non-finite
|
|
531
|
+
* values. Kept as data so a test can assert on the CLASS of mistake instead
|
|
532
|
+
* of on stderr; both ports swallowed all of them.
|
|
533
|
+
*/
|
|
534
|
+
get diagnostics(): readonly string[];
|
|
535
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three states a check or radio can be in.
|
|
3
|
+
*
|
|
4
|
+
* `indeterminate` is not "checked plus a flag": it paints its own glyph, and it
|
|
5
|
+
* maps to a distinct a11y value (`aria-checked="mixed"`), so a renderer that
|
|
6
|
+
* models the pair as two booleans has to re-derive the precedence every time it
|
|
7
|
+
* needs to answer "what does this look like / sound like right now".
|
|
8
|
+
*/
|
|
9
|
+
export type AdwCheckState = 'unchecked' | 'checked' | 'indeterminate';
|
|
10
|
+
/**
|
|
11
|
+
* Collapse the `checked` / `indeterminate` pair into the one state that paints.
|
|
12
|
+
*
|
|
13
|
+
* Indeterminate WINS, including over checked — see the module header for the
|
|
14
|
+
* cascade reading that settles it (_checks.scss:79-81 re-declares the glyph
|
|
15
|
+
* after both `:checked` rules, at equal specificity).
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveCheckState(checked: boolean, indeterminate: boolean): AdwCheckState;
|
|
18
|
+
/** Payload of a {@link RadioGroupState} change — both halves of one exclusive move. */
|
|
19
|
+
export interface RadioGroupChange {
|
|
20
|
+
/** The group the move happened in. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** The value that is now selected. */
|
|
23
|
+
selected: string;
|
|
24
|
+
/** The value that just lost the selection, or `null` when the group was empty. */
|
|
25
|
+
deselected: string | null;
|
|
26
|
+
}
|
|
27
|
+
/** Subscriber for {@link RadioGroupState} changes. */
|
|
28
|
+
export type RadioGroupListener = (change: RadioGroupChange) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Which value is selected in each named radio group.
|
|
31
|
+
*
|
|
32
|
+
* ONE registry over MANY groups, keyed by name, because that is the shape the
|
|
33
|
+
* renderers need: a radio knows its own group NAME, not its siblings, exactly as
|
|
34
|
+
* `<input type="radio" name="…">` does. Two independent groups therefore need
|
|
35
|
+
* two names — the registry is as global as its host (one instance per document
|
|
36
|
+
* in `@gjsify/adwaita-web`).
|
|
37
|
+
*
|
|
38
|
+
* {@link select} notifies ONCE per move, carrying the value that gained the
|
|
39
|
+
* selection and the one that lost it, so a renderer repaints both members off a
|
|
40
|
+
* single event. Re-selecting the value already held is a no-op and notifies
|
|
41
|
+
* nothing — a user clicking a checked radio twice must not produce a second
|
|
42
|
+
* event, and must never end up with nothing selected (HTML radios cannot be
|
|
43
|
+
* unchecked by clicking either).
|
|
44
|
+
*
|
|
45
|
+
* A group nobody has picked in reports `null`. Whether GTK instead activates the
|
|
46
|
+
* first member of a group is NOT verifiable here (see the module header), so
|
|
47
|
+
* this reports the state it actually has rather than inventing a default.
|
|
48
|
+
*/
|
|
49
|
+
export declare class RadioGroupState {
|
|
50
|
+
private readonly _selected;
|
|
51
|
+
private readonly _listeners;
|
|
52
|
+
/** Subscribe to selection changes in ANY group. Returns an unsubscribe function. */
|
|
53
|
+
subscribe(listener: RadioGroupListener): () => void;
|
|
54
|
+
private _emit;
|
|
55
|
+
/** The value selected in `name`, or `null` when nothing is selected there. */
|
|
56
|
+
selected(name: string): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Select `value` in group `name`, deselecting whatever was selected there.
|
|
59
|
+
*
|
|
60
|
+
* Returns whether the selection actually moved; a no-op notifies nothing.
|
|
61
|
+
*/
|
|
62
|
+
select(name: string, value: string): boolean;
|
|
63
|
+
}
|