@gjsify/adwaita-web 0.31.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/dist/adwaita-web.css +786 -272
- package/dist/adwaita-web.css.map +1 -1
- package/lib/types/adw-about-dialog.spec.d.ts +1 -0
- package/lib/types/adw-action-rows.spec.d.ts +1 -0
- package/lib/types/adw-avatar.spec.d.ts +1 -0
- package/lib/types/adw-banner.spec.d.ts +1 -0
- package/lib/types/adw-button-content.spec.d.ts +1 -0
- package/lib/types/adw-carousel.spec.d.ts +1 -0
- package/lib/types/adw-checks.spec.d.ts +1 -0
- package/lib/types/adw-header-bar.spec.d.ts +1 -0
- package/lib/types/adw-icon.spec.d.ts +1 -0
- package/lib/types/adw-progress-bar.spec.d.ts +1 -0
- package/lib/types/adw-sidebar.spec.d.ts +1 -0
- package/lib/types/adw-switch.spec.d.ts +1 -0
- package/lib/types/adw-wrap-box.spec.d.ts +1 -0
- package/lib/types/bottom-sheet.spec.d.ts +1 -0
- package/lib/types/breakpoints.d.ts +22 -0
- package/lib/types/breakpoints.spec.d.ts +1 -0
- package/lib/types/chrome.spec.d.ts +1 -0
- package/lib/types/elements/adw-about-dialog.d.ts +47 -8
- package/lib/types/elements/adw-action-row.d.ts +35 -0
- package/lib/types/elements/adw-avatar.d.ts +11 -0
- package/lib/types/elements/adw-bottom-sheet.d.ts +33 -4
- package/lib/types/elements/adw-button-content.d.ts +12 -0
- package/lib/types/elements/adw-button-row.d.ts +10 -1
- package/lib/types/elements/adw-carousel.d.ts +111 -8
- package/lib/types/elements/adw-checks.d.ts +57 -0
- package/lib/types/elements/adw-clamp.d.ts +4 -1
- package/lib/types/elements/adw-data-grid.d.ts +11 -31
- package/lib/types/elements/adw-drop-down.d.ts +17 -20
- package/lib/types/elements/adw-entry-row.d.ts +93 -3
- package/lib/types/elements/adw-expander-row.d.ts +7 -1
- package/lib/types/elements/adw-header-bar.d.ts +15 -0
- package/lib/types/elements/adw-icon.d.ts +25 -0
- package/lib/types/elements/adw-inline-view-switcher.d.ts +37 -11
- package/lib/types/elements/adw-menu-button.d.ts +6 -6
- package/lib/types/elements/adw-navigation-split-view.d.ts +6 -0
- package/lib/types/elements/adw-navigation-view.d.ts +63 -20
- package/lib/types/elements/adw-overlay-split-view.d.ts +38 -0
- package/lib/types/elements/adw-password-entry-row.d.ts +19 -10
- package/lib/types/elements/adw-popover.d.ts +58 -0
- package/lib/types/elements/adw-preferences-dialog.d.ts +57 -2
- package/lib/types/elements/adw-preferences-group.d.ts +31 -0
- package/lib/types/elements/adw-progress-bar.d.ts +38 -0
- package/lib/types/elements/adw-sidebar.d.ts +37 -5
- package/lib/types/elements/adw-split-button.d.ts +53 -7
- package/lib/types/elements/adw-switch-row.d.ts +11 -2
- package/lib/types/elements/adw-switch.d.ts +15 -0
- package/lib/types/elements/adw-tab-view.d.ts +129 -12
- package/lib/types/elements/adw-toolbar-view.d.ts +5 -0
- package/lib/types/elements/adw-view-stack.d.ts +27 -19
- package/lib/types/elements/adw-view-switcher-bar.d.ts +23 -7
- package/lib/types/elements/adw-view-switcher.d.ts +22 -11
- package/lib/types/elements/adw-window-title.d.ts +3 -1
- package/lib/types/elements/view-switcher-dom.d.ts +44 -0
- package/lib/types/entry-rows.spec.d.ts +1 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/navigation-view.spec.d.ts +1 -0
- package/lib/types/preferences-search.d.ts +20 -0
- package/lib/types/preferences.spec.d.ts +1 -0
- package/lib/types/split-button.spec.d.ts +1 -0
- package/lib/types/split-views.spec.d.ts +1 -0
- package/lib/types/styles.generated.d.ts +1 -1
- package/lib/types/tab-view.spec.d.ts +1 -0
- package/lib/types/view-stack.spec.d.ts +1 -0
- package/lib/types/view-switcher.spec.d.ts +1 -0
- package/package.json +6 -6
- package/scss/_banner.scss +13 -0
- package/scss/_bottom_sheet.scss +5 -6
- package/scss/_button.scss +3 -26
- package/scss/_button_content.scss +28 -0
- package/scss/_checks.scss +228 -0
- package/scss/_clamp.scss +9 -3
- package/scss/_data_grid.scss +15 -7
- package/scss/_drop_down.scss +12 -55
- package/scss/_expander_row.scss +5 -50
- package/scss/_icon.scss +51 -0
- package/scss/_icons.generated.scss +6 -0
- package/scss/_inline_view_switcher.scss +34 -0
- package/scss/_labels.scss +135 -0
- package/scss/_menu_button.scss +10 -70
- package/scss/_popover.scss +186 -0
- package/scss/_preferences.scss +29 -0
- package/scss/_preferences_dialog.scss +17 -0
- package/scss/_progress_bar.scss +161 -0
- package/scss/_reset.scss +18 -7
- package/scss/_spinner.scss +7 -3
- package/scss/_split_button.scss +6 -50
- package/scss/_switch.scss +90 -0
- package/scss/_switch_row.scss +6 -52
- package/scss/_tab_view.scss +64 -0
- package/scss/_theme.scss +10 -0
- package/scss/_toolbar_view.scss +74 -0
- package/scss/_variables.scss +34 -0
- package/scss/_view_switcher.scss +40 -0
- package/scss/_view_switcher_bar.scss +37 -0
- package/scss/_wrap_box.scss +56 -6
- package/scss/adwaita-skin.scss +23 -0
- package/src/adw-about-dialog.spec.ts +350 -0
- package/src/adw-action-rows.spec.ts +342 -0
- package/src/adw-avatar.spec.ts +139 -0
- package/src/adw-banner.spec.ts +152 -0
- package/src/adw-button-content.spec.ts +183 -0
- package/src/adw-button-row.spec.ts +12 -6
- package/src/adw-carousel.spec.ts +389 -0
- package/src/adw-checks.spec.ts +368 -0
- package/src/adw-drop-down.spec.ts +123 -0
- package/src/adw-header-bar.spec.ts +83 -0
- package/src/adw-icon.spec.ts +167 -0
- package/src/adw-progress-bar.spec.ts +173 -0
- package/src/adw-sidebar.spec.ts +332 -0
- package/src/adw-switch.spec.ts +242 -0
- package/src/adw-tab-view.spec.ts +12 -3
- package/src/adw-view-switcher-bar.spec.ts +61 -13
- package/src/adw-wrap-box.spec.ts +194 -0
- package/src/bottom-sheet.spec.ts +325 -0
- package/src/breakpoints.spec.ts +147 -0
- package/src/breakpoints.ts +67 -0
- package/src/chrome.spec.ts +301 -0
- package/src/elements/adw-about-dialog.ts +223 -163
- package/src/elements/adw-action-row.ts +120 -10
- package/src/elements/adw-avatar.ts +48 -54
- package/src/elements/adw-banner.ts +46 -10
- package/src/elements/adw-bottom-sheet.ts +145 -60
- package/src/elements/adw-button-content.ts +107 -33
- package/src/elements/adw-button-row.ts +61 -37
- package/src/elements/adw-button.ts +5 -7
- package/src/elements/adw-carousel.ts +467 -105
- package/src/elements/adw-checks.ts +299 -0
- package/src/elements/adw-clamp.ts +80 -10
- package/src/elements/adw-combo-row.ts +15 -7
- package/src/elements/adw-data-grid.ts +43 -91
- package/src/elements/adw-drop-down.ts +117 -128
- package/src/elements/adw-entry-row.ts +404 -36
- package/src/elements/adw-expander-row.ts +61 -29
- package/src/elements/adw-header-bar.ts +31 -6
- package/src/elements/adw-icon.ts +148 -0
- package/src/elements/adw-inline-view-switcher.ts +240 -129
- package/src/elements/adw-menu-button.ts +93 -70
- package/src/elements/adw-navigation-split-view.ts +48 -7
- package/src/elements/adw-navigation-view.ts +286 -148
- package/src/elements/adw-overlay-split-view.ts +164 -14
- package/src/elements/adw-password-entry-row.ts +111 -89
- package/src/elements/adw-popover.ts +283 -0
- package/src/elements/adw-preferences-dialog.ts +120 -21
- package/src/elements/adw-preferences-group.ts +128 -22
- package/src/elements/adw-progress-bar.ts +189 -0
- package/src/elements/adw-sidebar.ts +301 -142
- package/src/elements/adw-spin-row.ts +11 -5
- package/src/elements/adw-spinner.ts +23 -8
- package/src/elements/adw-split-button.ts +371 -92
- package/src/elements/adw-status-page.ts +9 -9
- package/src/elements/adw-switch-row.ts +100 -30
- package/src/elements/adw-switch.ts +129 -0
- package/src/elements/adw-tab-view.ts +682 -129
- package/src/elements/adw-toggle-group.ts +5 -7
- package/src/elements/adw-toolbar-view.ts +84 -21
- package/src/elements/adw-view-stack.ts +162 -85
- package/src/elements/adw-view-switcher-bar.ts +163 -81
- package/src/elements/adw-view-switcher.ts +231 -112
- package/src/elements/adw-window-title.ts +44 -11
- package/src/elements/adw-wrap-box.ts +131 -35
- package/src/elements/view-switcher-dom.ts +108 -0
- package/src/entry-rows.spec.ts +391 -0
- package/src/index.ts +23 -0
- package/src/navigation-view.spec.ts +435 -0
- package/src/preferences-search.ts +135 -0
- package/src/preferences.spec.ts +250 -0
- package/src/source-view/adw-source-view.ts +2 -5
- package/src/split-button.spec.ts +470 -0
- package/src/split-views.spec.ts +309 -0
- package/src/styles.generated.ts +1 -1
- package/src/tab-view.spec.ts +451 -0
- package/src/test.browser.mts +49 -0
- package/src/view-stack.spec.ts +272 -0
- package/src/view-switcher.spec.ts +446 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// DOM-level conformance tests for <adw-preferences-group> and
|
|
2
|
+
// <adw-preferences-dialog>, driven by the SAME vectors the NativeScript
|
|
3
|
+
// renderer asserts against (`@gjsify/adwaita-core/conformance`).
|
|
4
|
+
//
|
|
5
|
+
// Two things are being held here. First, the group header: this element derived
|
|
6
|
+
// two of the five states by hand and was missing the other three, so an empty
|
|
7
|
+
// group kept painting a `.boxed-list` card (its `box-shadow` strokes a
|
|
8
|
+
// full-width hairline over nothing) and no header ever carried the `single-line`
|
|
9
|
+
// class the stylesheet keys its metrics off. Second, the search: it did not
|
|
10
|
+
// exist in this port at all, and the dialog actively prevented it by hoisting
|
|
11
|
+
// every page's children out of the page element and discarding the pages —
|
|
12
|
+
// leaving nothing to derive `General → Appearance` from.
|
|
13
|
+
import { describe, expect, it } from '@gjsify/unit';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
PREFERENCES_GROUP_HEADER_VECTORS,
|
|
17
|
+
PREFERENCES_SEARCH_PAGES,
|
|
18
|
+
PREFERENCES_SEARCH_VECTORS,
|
|
19
|
+
} from '@gjsify/adwaita-core/conformance';
|
|
20
|
+
import type { PreferencesSearchPage } from '@gjsify/adwaita-core';
|
|
21
|
+
|
|
22
|
+
import type { AdwPreferencesGroup } from './elements/adw-preferences-group.js';
|
|
23
|
+
import type { AdwPreferencesDialog, AdwPreferencesPage } from './elements/adw-preferences-dialog.js';
|
|
24
|
+
|
|
25
|
+
/** Let a `MutationObserver` deliver — its records arrive on a microtask. */
|
|
26
|
+
const flushMutations = () => new Promise<void>((resolve) => queueMicrotask(() => resolve()));
|
|
27
|
+
|
|
28
|
+
/** Mount a group with a title / description / suffix / row count. */
|
|
29
|
+
function mountGroup(options: {
|
|
30
|
+
title?: string | null;
|
|
31
|
+
description?: string | null;
|
|
32
|
+
hasHeaderSuffix?: boolean;
|
|
33
|
+
rowCount?: number;
|
|
34
|
+
}): { group: AdwPreferencesGroup; host: HTMLElement } {
|
|
35
|
+
const host = document.createElement('div');
|
|
36
|
+
document.body.appendChild(host);
|
|
37
|
+
|
|
38
|
+
const group = document.createElement('adw-preferences-group') as AdwPreferencesGroup;
|
|
39
|
+
if (options.hasHeaderSuffix) {
|
|
40
|
+
const suffix = document.createElement('button');
|
|
41
|
+
suffix.setAttribute('slot', 'header-suffix');
|
|
42
|
+
suffix.textContent = 'Sign out';
|
|
43
|
+
group.appendChild(suffix);
|
|
44
|
+
}
|
|
45
|
+
for (let index = 0; index < (options.rowCount ?? 0); index++) {
|
|
46
|
+
const row = document.createElement('adw-action-row');
|
|
47
|
+
row.setAttribute('title', `Row ${index}`);
|
|
48
|
+
group.appendChild(row);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
host.appendChild(group);
|
|
52
|
+
// Set AFTER connect so the attribute path is exercised, and via
|
|
53
|
+
// setAttribute so exact whitespace survives (` ` is a visible title).
|
|
54
|
+
if (options.title !== undefined && options.title !== null) group.setAttribute('title', options.title);
|
|
55
|
+
if (options.description !== undefined && options.description !== null) {
|
|
56
|
+
group.setAttribute('description', options.description);
|
|
57
|
+
}
|
|
58
|
+
return { group, host };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The five states as this element renders them. */
|
|
62
|
+
function renderedState(group: AdwPreferencesGroup) {
|
|
63
|
+
const header = group.querySelector('.adw-preferences-group-header') as HTMLElement;
|
|
64
|
+
const title = group.querySelector('.adw-preferences-group-title') as HTMLElement;
|
|
65
|
+
const description = group.querySelector('.adw-preferences-group-description') as HTMLElement;
|
|
66
|
+
const listbox = group.querySelector('.adw-preferences-group-listbox') as HTMLElement;
|
|
67
|
+
return {
|
|
68
|
+
titleVisible: !title.hidden,
|
|
69
|
+
descriptionVisible: !description.hidden,
|
|
70
|
+
headerVisible: !header.hidden,
|
|
71
|
+
singleLine: header.classList.contains('single-line'),
|
|
72
|
+
listboxVisible: !listbox.hidden,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Build the shared conformance tree as real elements inside a dialog. */
|
|
77
|
+
function mountSearchDialog(pages: readonly PreferencesSearchPage[]): {
|
|
78
|
+
dialog: AdwPreferencesDialog;
|
|
79
|
+
host: HTMLElement;
|
|
80
|
+
} {
|
|
81
|
+
const host = document.createElement('div');
|
|
82
|
+
document.body.appendChild(host);
|
|
83
|
+
|
|
84
|
+
const dialog = document.createElement('adw-preferences-dialog') as AdwPreferencesDialog;
|
|
85
|
+
host.appendChild(dialog);
|
|
86
|
+
|
|
87
|
+
for (const page of pages) {
|
|
88
|
+
const pageEl = document.createElement('adw-preferences-page') as AdwPreferencesPage;
|
|
89
|
+
if (page.name) pageEl.setAttribute('name', page.name);
|
|
90
|
+
pageEl.setAttribute('title', page.title ?? '');
|
|
91
|
+
if (page.useUnderline) pageEl.setAttribute('use-underline', '');
|
|
92
|
+
if (page.visible === false) pageEl.hidden = true;
|
|
93
|
+
|
|
94
|
+
for (const group of page.groups) {
|
|
95
|
+
const groupEl = document.createElement('adw-preferences-group') as AdwPreferencesGroup;
|
|
96
|
+
groupEl.setAttribute('title', group.title ?? '');
|
|
97
|
+
if (group.visible === false) groupEl.hidden = true;
|
|
98
|
+
|
|
99
|
+
for (const row of group.rows) {
|
|
100
|
+
// An action row has a searchable subtitle; an entry row does
|
|
101
|
+
// not, and that difference is the point of the vector.
|
|
102
|
+
const rowEl = document.createElement(row.isActionRow ? 'adw-action-row' : 'adw-entry-row');
|
|
103
|
+
rowEl.setAttribute('title', row.title);
|
|
104
|
+
if (row.subtitle) rowEl.setAttribute('subtitle', row.subtitle);
|
|
105
|
+
if (row.visible === false) rowEl.hidden = true;
|
|
106
|
+
groupEl.appendChild(rowEl);
|
|
107
|
+
}
|
|
108
|
+
pageEl.appendChild(groupEl);
|
|
109
|
+
}
|
|
110
|
+
// Through the public add(), i.e. AFTER connect — the path that used to
|
|
111
|
+
// leave a page rendering outside the dialog card.
|
|
112
|
+
dialog.add(pageEl);
|
|
113
|
+
}
|
|
114
|
+
return { dialog, host };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const AdwPreferencesTest = async () => {
|
|
118
|
+
await describe('adw-preferences-group header (libadwaita conformance vectors)', async () => {
|
|
119
|
+
for (const vector of PREFERENCES_GROUP_HEADER_VECTORS) {
|
|
120
|
+
// This element paints its labels as text, not as Pango markup, so it
|
|
121
|
+
// derives with `useMarkup: false`; rows whose expectation depends on
|
|
122
|
+
// markup being interpreted are not its to satisfy.
|
|
123
|
+
if (vector.dependsOnMarkup) continue;
|
|
124
|
+
|
|
125
|
+
await it(`${JSON.stringify(vector.input)} — ${vector.rule}`, () => {
|
|
126
|
+
const { group, host } = mountGroup(vector.input);
|
|
127
|
+
expect(renderedState(group)).toStrictEqual(vector.state);
|
|
128
|
+
host.remove();
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
await it('hides the listbox card of an empty group', () => {
|
|
133
|
+
// The regression: `.adw-preferences-group-listbox` carries
|
|
134
|
+
// background, radius AND `box-shadow: 0 0 0 1px …`, so a zero-height
|
|
135
|
+
// empty list still stroked a full-width hairline.
|
|
136
|
+
const { group, host } = mountGroup({ title: 'Account', rowCount: 0 });
|
|
137
|
+
const listbox = group.querySelector('.adw-preferences-group-listbox') as HTMLElement;
|
|
138
|
+
expect(listbox.hidden).toBe(true);
|
|
139
|
+
host.remove();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
await it('reveals the card again when a row is appended later', async () => {
|
|
143
|
+
const { group, host } = mountGroup({ title: 'Account', rowCount: 0 });
|
|
144
|
+
const listbox = group.querySelector('.adw-preferences-group-listbox') as HTMLElement;
|
|
145
|
+
expect(listbox.hidden).toBe(true);
|
|
146
|
+
|
|
147
|
+
const row = document.createElement('adw-action-row');
|
|
148
|
+
row.setAttribute('title', 'Later');
|
|
149
|
+
group.appendChild(row);
|
|
150
|
+
await flushMutations();
|
|
151
|
+
|
|
152
|
+
// C wires update_listbox_visibility to the row model's
|
|
153
|
+
// items-changed, so the rule holds over time and not only at build.
|
|
154
|
+
expect(listbox.hidden).toBe(false);
|
|
155
|
+
expect(row.parentElement).toBe(listbox);
|
|
156
|
+
host.remove();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
await it('hides the card again when the last row is removed', async () => {
|
|
160
|
+
const { group, host } = mountGroup({ title: 'Account', rowCount: 1 });
|
|
161
|
+
const listbox = group.querySelector('.adw-preferences-group-listbox') as HTMLElement;
|
|
162
|
+
expect(listbox.hidden).toBe(false);
|
|
163
|
+
|
|
164
|
+
group.removeRow(listbox.children[0]!);
|
|
165
|
+
expect(listbox.hidden).toBe(true);
|
|
166
|
+
host.remove();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
await it('refuses to remove a child it does not own', () => {
|
|
170
|
+
const { group, host } = mountGroup({ title: 'Account', rowCount: 1 });
|
|
171
|
+
const foreign = document.createElement('adw-action-row');
|
|
172
|
+
document.body.appendChild(foreign);
|
|
173
|
+
// ADW_CRITICAL_CANNOT_REMOVE_CHILD (adw-preferences-group.c:437).
|
|
174
|
+
expect(group.removeRow(foreign)).toBe(false);
|
|
175
|
+
foreign.remove();
|
|
176
|
+
host.remove();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
await it('keeps a single-space title visible', () => {
|
|
180
|
+
// g_strcmp0(text, "") — the visibility test does not trim.
|
|
181
|
+
const { group, host } = mountGroup({ title: ' ' });
|
|
182
|
+
const title = group.querySelector('.adw-preferences-group-title') as HTMLElement;
|
|
183
|
+
expect(title.hidden).toBe(false);
|
|
184
|
+
expect(title.textContent).toBe(' ');
|
|
185
|
+
host.remove();
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
await describe('adw-preferences-dialog pages', async () => {
|
|
190
|
+
await it('keeps the page elements, so their identity survives', () => {
|
|
191
|
+
// They used to be discarded: the dialog hoisted every page's
|
|
192
|
+
// childNodes into one clamp, which is why `pageTitle` was inert on
|
|
193
|
+
// web and every search subtitle would have been empty.
|
|
194
|
+
const { dialog, host } = mountSearchDialog(PREFERENCES_SEARCH_PAGES);
|
|
195
|
+
expect(dialog.pages.map((page) => page.name)).toStrictEqual(['general', 'network', 'developer']);
|
|
196
|
+
expect(dialog.pages[0]!.getAttribute('title')).toBe('General');
|
|
197
|
+
host.remove();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
await it('renders a page added after connect INSIDE the dialog card', () => {
|
|
201
|
+
// The old code snapshotted pages once in connectedCallback, so a
|
|
202
|
+
// later page became a sibling of the scrim.
|
|
203
|
+
const { dialog, host } = mountSearchDialog([]);
|
|
204
|
+
const page = document.createElement('adw-preferences-page') as AdwPreferencesPage;
|
|
205
|
+
dialog.add(page);
|
|
206
|
+
expect(page.closest('.adw-preferences-dialog-box')).not.toBe(null);
|
|
207
|
+
host.remove();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
await it('refuses to remove a page it does not own', () => {
|
|
211
|
+
const { dialog, host } = mountSearchDialog([]);
|
|
212
|
+
const foreign = document.createElement('adw-preferences-page') as AdwPreferencesPage;
|
|
213
|
+
expect(dialog.removePage(foreign)).toBe(false);
|
|
214
|
+
host.remove();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
await describe('adw-preferences-dialog search (libadwaita conformance vectors)', async () => {
|
|
219
|
+
for (const { query, results, rule } of PREFERENCES_SEARCH_VECTORS) {
|
|
220
|
+
await it(`${JSON.stringify(query)} → ${results.length} result(s) — ${rule}`, () => {
|
|
221
|
+
const { dialog, host } = mountSearchDialog(PREFERENCES_SEARCH_PAGES);
|
|
222
|
+
expect(
|
|
223
|
+
dialog.search(query).map((result) => ({ title: result.title, subtitle: result.subtitle })),
|
|
224
|
+
).toStrictEqual(results.map((result) => ({ title: result.title, subtitle: result.subtitle })));
|
|
225
|
+
host.remove();
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
await it('returns the row ELEMENT, so a result can be activated', () => {
|
|
230
|
+
// search_result_activated_cb reveals the page and focuses the row;
|
|
231
|
+
// both come off the result rather than a second DOM query.
|
|
232
|
+
const { dialog, host } = mountSearchDialog(PREFERENCES_SEARCH_PAGES);
|
|
233
|
+
const [result] = dialog.search('strasse');
|
|
234
|
+
expect((result!.row.ref as Element).getAttribute('title')).toBe('Straße');
|
|
235
|
+
expect((result!.page.ref as Element).getAttribute('name')).toBe('network');
|
|
236
|
+
host.remove();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
await it('drops a row from the corpus the moment it is hidden', () => {
|
|
240
|
+
const { dialog, host } = mountSearchDialog(PREFERENCES_SEARCH_PAGES);
|
|
241
|
+
expect(dialog.search('sync over').length).toBe(1);
|
|
242
|
+
const row = dialog.search('sync over')[0]!.row.ref as HTMLElement;
|
|
243
|
+
row.hidden = true;
|
|
244
|
+
// The corpus is derived per call from the live tree, so visibility
|
|
245
|
+
// changes need no invalidation step.
|
|
246
|
+
expect(dialog.search('sync over').length).toBe(0);
|
|
247
|
+
host.remove();
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
@@ -38,6 +38,7 @@ import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
|
|
|
38
38
|
import { asm6502 } from './asm6502.js';
|
|
39
39
|
import { adwaitaEditorTheme, adwaitaHighlightStyle, ensureSourceViewStyleInjected } from './theme.js';
|
|
40
40
|
import { formatHexAddress, formatLineNumber, stripWhitespace } from './hex.js';
|
|
41
|
+
import { createAdwIcon } from '../elements/adw-icon.js';
|
|
41
42
|
|
|
42
43
|
/** A recognisable copy glyph rendered inline so the subpath needs no icon CSS. */
|
|
43
44
|
const COPY_SVG =
|
|
@@ -417,11 +418,7 @@ export class AdwSourceView extends HTMLElement {
|
|
|
417
418
|
}
|
|
418
419
|
// A non-default icon uses the adwaita-web mask class (requires the main
|
|
419
420
|
// bundle's icon CSS to be present).
|
|
420
|
-
this._copyButton.replaceChildren();
|
|
421
|
-
const icon = document.createElement('span');
|
|
422
|
-
icon.className = `adw-icon adw-icon--${name.replace(/-symbolic$/, '')}`;
|
|
423
|
-
icon.setAttribute('aria-hidden', 'true');
|
|
424
|
-
this._copyButton.appendChild(icon);
|
|
421
|
+
this._copyButton.replaceChildren(createAdwIcon(name));
|
|
425
422
|
}
|
|
426
423
|
|
|
427
424
|
private _readDeclarativeAttributes(): void {
|