@gjsify/adwaita-web 0.36.0 → 0.37.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/dist/adwaita-web.css +433 -33
- package/dist/adwaita-web.css.map +1 -1
- package/lib/types/adw-shortcut-label.spec.d.ts +2 -0
- package/lib/types/breakpoints.d.ts +10 -12
- package/lib/types/elements/adw-about-dialog.d.ts +19 -36
- package/lib/types/elements/adw-action-row.d.ts +9 -12
- package/lib/types/elements/adw-alert-dialog.d.ts +0 -12
- package/lib/types/elements/adw-avatar.d.ts +1 -0
- package/lib/types/elements/adw-bottom-sheet.d.ts +7 -12
- package/lib/types/elements/adw-button-content.d.ts +3 -4
- package/lib/types/elements/adw-button-row.d.ts +1 -1
- package/lib/types/elements/adw-carousel.d.ts +28 -49
- package/lib/types/elements/adw-checks.d.ts +2 -8
- package/lib/types/elements/adw-combo-row.d.ts +6 -6
- package/lib/types/elements/adw-data-grid.d.ts +5 -10
- package/lib/types/elements/adw-drop-down.d.ts +3 -11
- package/lib/types/elements/adw-entry-row.d.ts +20 -23
- package/lib/types/elements/adw-icon.d.ts +2 -4
- package/lib/types/elements/adw-inline-view-switcher.d.ts +18 -31
- package/lib/types/elements/adw-navigation-split-view.d.ts +7 -12
- package/lib/types/elements/adw-navigation-view.d.ts +2 -10
- package/lib/types/elements/adw-overlay-split-view.d.ts +28 -52
- package/lib/types/elements/adw-password-entry-row.d.ts +4 -5
- package/lib/types/elements/adw-popover.d.ts +2 -7
- package/lib/types/elements/adw-preferences-dialog.d.ts +21 -34
- package/lib/types/elements/adw-preferences-group.d.ts +12 -14
- package/lib/types/elements/adw-progress-bar.d.ts +3 -4
- package/lib/types/elements/adw-shortcut-label.d.ts +20 -0
- package/lib/types/elements/adw-sidebar.d.ts +5 -10
- package/lib/types/elements/adw-spinner.d.ts +3 -5
- package/lib/types/elements/adw-split-button.d.ts +6 -16
- package/lib/types/elements/adw-switch-row.d.ts +3 -3
- package/lib/types/elements/adw-tab-view.d.ts +16 -26
- package/lib/types/elements/adw-toast-overlay.d.ts +8 -13
- package/lib/types/elements/adw-view-stack.d.ts +7 -17
- package/lib/types/elements/adw-view-switcher-bar.d.ts +4 -8
- package/lib/types/elements/adw-view-switcher.d.ts +18 -38
- package/lib/types/elements/adw-wrap-box.d.ts +7 -17
- package/lib/types/elements/view-switcher-dom.d.ts +10 -13
- package/lib/types/index.d.ts +1 -0
- package/lib/types/source-view/hex.d.ts +7 -13
- package/lib/types/style-classes.spec.d.ts +11 -0
- package/lib/types/styles.generated.d.ts +1 -1
- package/package.json +6 -6
- package/scss/_about_dialog.scss +3 -2
- package/scss/_action_row.scss +33 -0
- package/scss/_avatar.scss +12 -0
- package/scss/_button.scss +44 -22
- package/scss/_card.scss +11 -8
- package/scss/_checks.scss +2 -4
- package/scss/_dialog.scss +3 -2
- package/scss/_headerbar.scss +23 -0
- package/scss/_popover.scss +8 -4
- package/scss/_preferences.scss +7 -7
- package/scss/_progress_bar.scss +9 -6
- package/scss/_reset.scss +1 -1
- package/scss/_shortcut_label.scss +80 -0
- package/scss/_sidebar.scss +57 -0
- package/scss/_status_page.scss +20 -0
- package/scss/_style_classes.scss +407 -0
- package/scss/_switch.scss +4 -3
- package/scss/_variables.scss +25 -0
- package/scss/adwaita-skin.scss +12 -0
- package/src/adw-about-dialog.spec.ts +34 -49
- package/src/adw-action-rows.spec.ts +25 -33
- package/src/adw-avatar.spec.ts +51 -20
- package/src/adw-banner.spec.ts +5 -8
- package/src/adw-button-content.spec.ts +9 -12
- package/src/adw-button-row.spec.ts +2 -4
- package/src/adw-carousel.spec.ts +40 -53
- package/src/adw-checks.spec.ts +36 -47
- package/src/adw-drop-down.spec.ts +25 -32
- package/src/adw-header-bar.spec.ts +5 -7
- package/src/adw-icon.spec.ts +23 -32
- package/src/adw-progress-bar.spec.ts +10 -12
- package/src/adw-row-state.spec.ts +9 -10
- package/src/adw-shortcut-label.spec.ts +112 -0
- package/src/adw-sidebar.spec.ts +17 -24
- package/src/adw-switch.spec.ts +11 -17
- package/src/adw-tab-view.spec.ts +7 -10
- package/src/adw-toast-overlay.spec.ts +7 -11
- package/src/adw-view-switcher-bar.spec.ts +10 -14
- package/src/adw-wrap-box.spec.ts +25 -36
- package/src/bottom-sheet.spec.ts +30 -36
- package/src/breakpoints.ts +15 -18
- package/src/chrome.spec.ts +13 -21
- package/src/elements/adw-about-dialog.ts +71 -114
- package/src/elements/adw-action-row.ts +22 -37
- package/src/elements/adw-alert-dialog.ts +25 -50
- package/src/elements/adw-avatar.ts +40 -15
- package/src/elements/adw-banner.ts +14 -18
- package/src/elements/adw-bottom-sheet.ts +31 -52
- package/src/elements/adw-button-content.ts +30 -37
- package/src/elements/adw-button-row.ts +14 -24
- package/src/elements/adw-carousel.ts +87 -148
- package/src/elements/adw-checks.ts +43 -56
- package/src/elements/adw-clamp.ts +8 -9
- package/src/elements/adw-combo-row.ts +17 -25
- package/src/elements/adw-data-grid.ts +26 -38
- package/src/elements/adw-dialog.ts +25 -56
- package/src/elements/adw-drop-down.ts +31 -51
- package/src/elements/adw-entry-row.ts +39 -46
- package/src/elements/adw-expander-row.ts +30 -53
- package/src/elements/adw-icon.ts +30 -53
- package/src/elements/adw-inline-view-switcher.ts +38 -67
- package/src/elements/adw-menu-button.ts +28 -58
- package/src/elements/adw-navigation-split-view.ts +35 -47
- package/src/elements/adw-navigation-view.ts +12 -28
- package/src/elements/adw-overlay-split-view.ts +100 -175
- package/src/elements/adw-password-entry-row.ts +18 -28
- package/src/elements/adw-popover.ts +28 -44
- package/src/elements/adw-preferences-dialog.ts +41 -66
- package/src/elements/adw-preferences-group.ts +33 -46
- package/src/elements/adw-progress-bar.ts +27 -47
- package/src/elements/adw-shortcut-label.ts +138 -0
- package/src/elements/adw-sidebar.ts +31 -39
- package/src/elements/adw-spin-row.ts +7 -14
- package/src/elements/adw-spinner.ts +31 -43
- package/src/elements/adw-split-button.ts +45 -75
- package/src/elements/adw-switch-row.ts +29 -46
- package/src/elements/adw-switch.ts +28 -47
- package/src/elements/adw-tab-view.ts +62 -103
- package/src/elements/adw-toast-overlay.ts +28 -35
- package/src/elements/adw-toggle-group.ts +9 -16
- package/src/elements/adw-view-stack.ts +32 -51
- package/src/elements/adw-view-switcher-bar.ts +26 -50
- package/src/elements/adw-view-switcher.ts +60 -110
- package/src/elements/adw-window-title.ts +4 -4
- package/src/elements/adw-wrap-box.ts +33 -59
- package/src/elements/view-switcher-dom.ts +15 -22
- package/src/entry-rows.spec.ts +18 -24
- package/src/index.ts +13 -15
- package/src/navigation-view.spec.ts +7 -10
- package/src/preferences-search.ts +11 -15
- package/src/preferences.spec.ts +13 -15
- package/src/source-view/adw-source-view.ts +6 -19
- package/src/source-view/hex.ts +7 -13
- package/src/split-button.spec.ts +32 -44
- package/src/split-views.spec.ts +83 -149
- package/src/style-classes.spec.ts +181 -0
- package/src/style-isolation.spec.ts +3 -6
- package/src/styles.generated.ts +1 -1
- package/src/tab-view.spec.ts +26 -35
- package/src/test.browser.mts +4 -0
- package/src/view-stack.spec.ts +23 -34
- package/src/view-switcher.spec.ts +56 -84
|
@@ -10,15 +10,13 @@
|
|
|
10
10
|
// `Adw.NavigationPage:tag`.
|
|
11
11
|
// Slots: slot="sidebar", slot="content".
|
|
12
12
|
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// NAVIGATION_SPLIT_VIEW_CRITICALS and NAVIGATION_ACTION_VECTORS — the last of
|
|
21
|
-
// which had no consumer at all before this.
|
|
13
|
+
// THREE rules from the C are not expressible as CSS classes and live in
|
|
14
|
+
// `NavigationSplitViewState` (`@gjsify/adwaita-core`), held to NAVIGATION_STACK_VECTORS,
|
|
15
|
+
// NAVIGATION_SPLIT_VIEW_CRITICALS and NAVIGATION_ACTION_VECTORS: the navigation-stack
|
|
16
|
+
// ordering table (a LONE child stays visible whatever `show-content` says; with
|
|
17
|
+
// `sidebar-position: end` the CONTENT is the root page), the duplicate-tag guard, and
|
|
18
|
+
// the `navigation.push` / `navigation.pop` routing that lets a nested split view
|
|
19
|
+
// forward a push outwards.
|
|
22
20
|
//
|
|
23
21
|
// Reference: refs/adwaita-web/adwaita-web/docs/widgets/navigationsplitview.md
|
|
24
22
|
// Reference: refs/libadwaita/src/adw-navigation-split-view.c
|
|
@@ -94,18 +92,16 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
94
92
|
this.setAttribute('sidebar-position', value);
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
/** The sidebar page's tag of record, or `null`. */
|
|
98
95
|
get sidebarTag(): string | null {
|
|
99
96
|
return this._state.sidebarTag;
|
|
100
97
|
}
|
|
101
98
|
|
|
102
|
-
/** The content page's tag of record, or `null`. */
|
|
103
99
|
get contentTag(): string | null {
|
|
104
100
|
return this._state.contentTag;
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
/**
|
|
108
|
-
* `navigation.push` with `tag` — `navigation_push_cb
|
|
104
|
+
* `navigation.push` with `tag` — `navigation_push_cb`.
|
|
109
105
|
*
|
|
110
106
|
* An unmatched tag DELEGATES to the parent before it may become a critical,
|
|
111
107
|
* which is how nested split views forward a push outwards; on this port that
|
|
@@ -116,7 +112,7 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
116
112
|
return this._state.push(tag);
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
/** `navigation.pop` — `navigation_pop_cb
|
|
115
|
+
/** `navigation.pop` — `navigation_pop_cb`. */
|
|
120
116
|
pop(): NavigationActionResult {
|
|
121
117
|
return this._state.pop();
|
|
122
118
|
}
|
|
@@ -138,16 +134,16 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
138
134
|
|
|
139
135
|
this.replaceChildren(this._sidebarEl, this._contentEl);
|
|
140
136
|
|
|
141
|
-
// Parse-time attributes are the CONSTRUCTION properties,
|
|
142
|
-
//
|
|
143
|
-
//
|
|
137
|
+
// Parse-time attributes are the CONSTRUCTION properties, as in the overlay view:
|
|
138
|
+
// applying them as sequential setters emits a transition for a state the markup
|
|
139
|
+
// simply declared.
|
|
144
140
|
this._state = new NavigationSplitViewState({
|
|
145
141
|
sidebarPosition: this.sidebarPosition,
|
|
146
142
|
collapsed: this.hasAttribute('collapsed'),
|
|
147
143
|
showContent: this.hasAttribute('show-content'),
|
|
148
|
-
// `g_critical` has no browser counterpart
|
|
149
|
-
//
|
|
150
|
-
//
|
|
144
|
+
// `g_critical` has no browser counterpart a consumer can see; `console.error`
|
|
145
|
+
// is the one a developer reads, and the TEXT is C's verbatim so a GTK bug
|
|
146
|
+
// report and a browser one say the same.
|
|
151
147
|
onCritical: (message) => console.error(message),
|
|
152
148
|
onDelegate: (action, tag) => {
|
|
153
149
|
const detail: NavigationDelegateDetail = { tag, handled: false };
|
|
@@ -155,10 +151,9 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
155
151
|
return detail.handled;
|
|
156
152
|
},
|
|
157
153
|
});
|
|
158
|
-
// Which children EXIST decides the stack, so the panes are mounted into
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
// express.
|
|
154
|
+
// Which children EXIST decides the stack, so the panes are mounted into the state
|
|
155
|
+
// and not merely into the DOM — a lone child stays visible whatever
|
|
156
|
+
// `show-content` says, which two CSS classes cannot express.
|
|
162
157
|
this._state.setSidebar(sidebarChildren.length > 0 ? { tag: this._tagOf(sidebarChildren) } : null);
|
|
163
158
|
this._state.setContent(contentChildren.length > 0 ? { tag: this._tagOf(contentChildren) } : null);
|
|
164
159
|
this._state.subscribe(() => {
|
|
@@ -181,11 +176,10 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
181
176
|
}
|
|
182
177
|
|
|
183
178
|
/**
|
|
184
|
-
* Mirror the state's `showContent` onto the attribute, so the DOM keeps
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* re-enters `attributeChangedCallback`, which without the flag is a loop.
|
|
179
|
+
* Mirror the state's `showContent` onto the attribute, so the DOM keeps telling the
|
|
180
|
+
* truth after a `navigation.push` moved it. Guarded like the overlay view's
|
|
181
|
+
* reflection: writing the attribute re-enters `attributeChangedCallback`, which
|
|
182
|
+
* without the flag is a loop.
|
|
189
183
|
*/
|
|
190
184
|
private _reflectShowContent() {
|
|
191
185
|
if (this._reflecting) return;
|
|
@@ -231,11 +225,9 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
231
225
|
this._sidebarEl.style.maxWidth = '';
|
|
232
226
|
return;
|
|
233
227
|
}
|
|
234
|
-
// An ABSENT attribute
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
// The core also normalises the pair — libadwaita never lets max fall
|
|
238
|
-
// below min, and CSS resolves that conflict the other way round.
|
|
228
|
+
// An ABSENT attribute is NOT "no bound at all": Adw.NavigationSplitView always
|
|
229
|
+
// has 180 / 280. The core also normalises the pair — libadwaita never lets max
|
|
230
|
+
// fall below min, and CSS resolves that conflict the other way round.
|
|
239
231
|
const bounds = resolveSidebarBounds(
|
|
240
232
|
{
|
|
241
233
|
minSidebarWidth: this._widthAttr('min-sidebar-width', DEFAULT_MIN_SIDEBAR_WIDTH),
|
|
@@ -248,7 +240,6 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
248
240
|
this._sidebarEl.style.maxWidth = `${bounds.max}px`;
|
|
249
241
|
}
|
|
250
242
|
|
|
251
|
-
/** A pixel attribute, falling back to the widget's own default. */
|
|
252
243
|
private _widthAttr(name: string, fallback: number): number {
|
|
253
244
|
const raw = this.getAttribute(name);
|
|
254
245
|
if (raw === null) return fallback;
|
|
@@ -256,7 +247,7 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
256
247
|
return Number.isFinite(value) ? value : fallback;
|
|
257
248
|
}
|
|
258
249
|
|
|
259
|
-
/** The reading direction `start` / `end` resolve against (`get_start_or_end
|
|
250
|
+
/** The reading direction `start` / `end` resolve against (`get_start_or_end`). */
|
|
260
251
|
private get _direction(): AdwTextDirection {
|
|
261
252
|
return getComputedStyle(this).direction === 'rtl' ? 'rtl' : 'ltr';
|
|
262
253
|
}
|
|
@@ -273,27 +264,24 @@ export class AdwNavigationSplitView extends HTMLElement {
|
|
|
273
264
|
isSidebarAtVisualStart(state.sidebarPosition, this._direction),
|
|
274
265
|
);
|
|
275
266
|
|
|
276
|
-
// THE PANE STYLE CLASSES, and only while docked
|
|
277
|
-
//
|
|
278
|
-
//
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
// Painting it `--sidebar-bg-color` at every width, as this did, is the
|
|
282
|
-
// same defect the overlay view has with `.overlay-pane`.
|
|
267
|
+
// THE PANE STYLE CLASSES, and only while docked: libadwaita builds the two
|
|
268
|
+
// `.sidebar-pane` / `.content-pane` bins in the UNCOLLAPSED branch alone, and
|
|
269
|
+
// collapsed both pages move into one AdwNavigationView where neither bin exists.
|
|
270
|
+
// A collapsed sidebar is therefore a full window page on the WINDOW background,
|
|
271
|
+
// so painting it `--sidebar-bg-color` at every width is wrong.
|
|
283
272
|
this._sidebarEl?.classList.toggle('sidebar-pane', !state.collapsed);
|
|
284
273
|
this._contentEl?.classList.toggle('content-pane', !state.collapsed);
|
|
285
274
|
|
|
286
|
-
// The STACK, not the two flags: `update_navigation_stack`
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
//
|
|
275
|
+
// The STACK, not the two flags: `update_navigation_stack` keeps a LONE child
|
|
276
|
+
// visible whatever `show-content` says, and with `sidebar-position: end` the
|
|
277
|
+
// CONTENT is the root page — so the sidebar is PUSHED ON TOP of it rather than
|
|
278
|
+
// replacing it.
|
|
290
279
|
const { stack } = state.stack;
|
|
291
280
|
const visible = stack[stack.length - 1] ?? null;
|
|
292
281
|
if (this._sidebarEl) this._sidebarEl.dataset.paneVisible = String(!state.collapsed || visible === 'sidebar');
|
|
293
282
|
if (this._contentEl) this._contentEl.dataset.paneVisible = String(!state.collapsed || visible === 'content');
|
|
294
283
|
}
|
|
295
284
|
|
|
296
|
-
/** (Re)bind the `breakpoint` condition to `collapsed`. */
|
|
297
285
|
private _syncBreakpoint() {
|
|
298
286
|
this._disposeBreakpoint?.();
|
|
299
287
|
this._disposeBreakpoint = bindBreakpointSetter(this, this.getAttribute('breakpoint'), (active) => {
|
|
@@ -10,14 +10,7 @@
|
|
|
10
10
|
// automatic back button, translate stack changes into CustomEvents, and route
|
|
11
11
|
// Escape / Alt+Left into the core's shortcut handlers.
|
|
12
12
|
//
|
|
13
|
-
// The
|
|
14
|
-
// `pop()` refused to pop a `can-pop="false"` page (the C documents the exact
|
|
15
|
-
// opposite at adw-navigation-view.c:2559-2561), `replace()` purged dynamic pages
|
|
16
|
-
// BEFORE resolving string entries so `replace(['tag-of-a-pushed-page'])` blanked
|
|
17
|
-
// the view outright, `popToTag()` was a loop of single pops that stopped early at
|
|
18
|
-
// a `can-pop="false"` page, and the back-button tooltip was hardcoded to "Back"
|
|
19
|
-
// where the C uses the previous page's title. See `navigation-view.spec.ts` for
|
|
20
|
-
// the vectors this element is now held to.
|
|
13
|
+
// The vectors this element is held to are in `navigation-view.spec.ts`.
|
|
21
14
|
//
|
|
22
15
|
// Pages are declared as <adw-navigation-page> children (each with a `title` and
|
|
23
16
|
// optional `tag` attribute). The view snapshots them at connect time. Like
|
|
@@ -111,7 +104,6 @@ export class AdwNavigationPage extends HTMLElement {
|
|
|
111
104
|
view?.syncPageProperty(this, name, previous);
|
|
112
105
|
}
|
|
113
106
|
|
|
114
|
-
/** Put an attribute back the way it was, without re-entering the sync. */
|
|
115
107
|
revertAttribute(name: string, value: string | null): void {
|
|
116
108
|
this._syncing = true;
|
|
117
109
|
if (value === null) this.removeAttribute(name);
|
|
@@ -138,7 +130,6 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
138
130
|
return ['animate-transitions', 'pop-on-escape'];
|
|
139
131
|
}
|
|
140
132
|
|
|
141
|
-
/** Whether push/pop transitions are animated. */
|
|
142
133
|
get animateTransitions(): boolean {
|
|
143
134
|
// Absent attribute defaults to true (matches Adw.NavigationView).
|
|
144
135
|
return this.getAttribute('animate-transitions') !== 'false';
|
|
@@ -157,17 +148,14 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
157
148
|
this.setAttribute('pop-on-escape', value ? 'true' : 'false');
|
|
158
149
|
}
|
|
159
150
|
|
|
160
|
-
/** The currently-visible page (top of the stack), or null when empty. */
|
|
161
151
|
get visiblePage(): AdwNavigationPage | null {
|
|
162
152
|
return this._state.visiblePage;
|
|
163
153
|
}
|
|
164
154
|
|
|
165
|
-
/** The tag of the visible page, or null. */
|
|
166
155
|
get visiblePageTag(): string | null {
|
|
167
156
|
return this._state.visiblePageTag;
|
|
168
157
|
}
|
|
169
158
|
|
|
170
|
-
/** The number of pages on the navigation stack. */
|
|
171
159
|
get depth(): number {
|
|
172
160
|
return this._state.depth;
|
|
173
161
|
}
|
|
@@ -177,7 +165,6 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
177
165
|
return this._state.stack;
|
|
178
166
|
}
|
|
179
167
|
|
|
180
|
-
/** Every page this view knows — static and dynamically pushed. */
|
|
181
168
|
get pages(): readonly AdwNavigationPage[] {
|
|
182
169
|
return this._state.pages;
|
|
183
170
|
}
|
|
@@ -214,9 +201,9 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
214
201
|
this._state.setPopOnEscape(this.popOnEscape);
|
|
215
202
|
this.addEventListener('keydown', this._onKeyDown);
|
|
216
203
|
|
|
217
|
-
// add_page
|
|
218
|
-
//
|
|
219
|
-
// `
|
|
204
|
+
// `add_page` auto-pushes into an EMPTY stack, so the first declared page becomes
|
|
205
|
+
// visible — and it does so through `push_to_stack`, which is why the `pushed` /
|
|
206
|
+
// `notify::visible-page` events fire for it.
|
|
220
207
|
for (const page of declared) this._state.add(page, readPageProps(page));
|
|
221
208
|
// A declared page the core REJECTED (a duplicate tag) is not one of ours:
|
|
222
209
|
// it must leave the DOM, or it would sit in the stack wrapper unmanaged and
|
|
@@ -330,9 +317,8 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
330
317
|
* Replace the whole navigation stack (mirrors AdwNavigationView.replace). The
|
|
331
318
|
* last page becomes visible; the transition is never animated.
|
|
332
319
|
*
|
|
333
|
-
* String entries are resolved BEFORE anything is mutated
|
|
334
|
-
*
|
|
335
|
-
* dynamically-pushed page and blank the view.
|
|
320
|
+
* String entries are resolved BEFORE anything is mutated, as `replace_with_tags`
|
|
321
|
+
* does: resolving late loses a dynamically-pushed page and blanks the view.
|
|
336
322
|
*/
|
|
337
323
|
replace(pages: ReadonlyArray<AdwNavigationPage | string | null>): void {
|
|
338
324
|
const resolved = pages.map((entry) => {
|
|
@@ -391,8 +377,8 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
391
377
|
if (event.key === 'Escape') {
|
|
392
378
|
result = this._state.popFromEscape();
|
|
393
379
|
} else if (event.altKey && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
|
|
394
|
-
// back_forward_shortcut_cb
|
|
395
|
-
//
|
|
380
|
+
// `back_forward_shortcut_cb` swaps the arrows under RTL; only the BACK
|
|
381
|
+
// direction is handled, since forward needs ::get-next-page.
|
|
396
382
|
const back = getComputedStyle(this).direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
|
|
397
383
|
if (event.key !== back) return;
|
|
398
384
|
result = this._state.popFromShortcut();
|
|
@@ -437,15 +423,14 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
437
423
|
if (page.parentNode === this._pagesEl) this._pagesEl.removeChild(page);
|
|
438
424
|
}
|
|
439
425
|
|
|
440
|
-
/** Inject (or remove) the automatic back button on the visible page. */
|
|
441
426
|
private _syncBackButton(page: AdwNavigationPage): void {
|
|
442
427
|
if (!this._state.canGoBack() || page.hasAttribute('no-back-button')) {
|
|
443
428
|
this._removeBackButton(page);
|
|
444
429
|
return;
|
|
445
430
|
}
|
|
446
431
|
|
|
447
|
-
// The tooltip is the title of the page the button REVEALS, so it can change
|
|
448
|
-
//
|
|
432
|
+
// The tooltip is the title of the page the button REVEALS, so it can change while
|
|
433
|
+
// the button itself stays put (`AdwBackButton`'s `query_tooltip`).
|
|
449
434
|
const tooltip = this._state.backButtonTooltip() ?? BACK_BUTTON_FALLBACK_TOOLTIP;
|
|
450
435
|
const existing = this._backButtons.get(page);
|
|
451
436
|
if (existing) {
|
|
@@ -453,9 +438,8 @@ export class AdwNavigationView extends HTMLElement {
|
|
|
453
438
|
return;
|
|
454
439
|
}
|
|
455
440
|
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
// AdwHeaderBar grows a back button when placed inside an AdwNavigationView.
|
|
441
|
+
// The button goes into the first <adw-header-bar> inside the page content, the
|
|
442
|
+
// way AdwHeaderBar grows one when placed inside an AdwNavigationView.
|
|
459
443
|
const headerBar = page.querySelector('adw-header-bar') as HTMLElement | null;
|
|
460
444
|
if (!headerBar) return;
|
|
461
445
|
const start = (headerBar as { startSection?: HTMLElement | null }).startSection ?? null;
|