@gjsify/adwaita-web 0.44.0 → 0.46.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/README.md +8 -6
- package/dist/adwaita-web.css +96 -96
- package/dist/adwaita-web.css.map +1 -1
- package/lib/types/elements/adw-entry-row.d.ts +2 -2
- package/lib/types/elements/adw-expander-row.d.ts +1 -1
- package/lib/types/elements/adw-header-bar.d.ts +16 -8
- package/lib/types/elements/adw-split-button.d.ts +1 -1
- package/lib/types/elements/adw-switch-row.d.ts +1 -1
- package/lib/types/elements/adw-wrap-box.d.ts +1 -1
- package/lib/types/elements/{adw-checks.d.ts → checks.d.ts} +9 -2
- package/lib/types/elements/{adw-button.d.ts → gtk-button.d.ts} +1 -1
- package/lib/types/elements/{adw-drop-down.d.ts → gtk-drop-down.d.ts} +6 -6
- package/lib/types/elements/{adw-entry.d.ts → gtk-entry.d.ts} +1 -1
- package/lib/types/elements/{adw-icon.d.ts → gtk-image.d.ts} +2 -2
- package/lib/types/elements/{adw-menu-button.d.ts → gtk-menu-button.d.ts} +13 -4
- package/lib/types/elements/{adw-popover.d.ts → gtk-popover.d.ts} +9 -9
- package/lib/types/elements/{adw-progress-bar.d.ts → gtk-progress-bar.d.ts} +1 -1
- package/lib/types/elements/{adw-switch.d.ts → gtk-switch.d.ts} +2 -2
- package/lib/types/elements/view-switcher-dom.d.ts +4 -4
- package/lib/types/exported-elements.d.ts +10 -0
- package/lib/types/gtk-button.spec.d.ts +1 -0
- package/lib/types/gtk-drop-down.spec.d.ts +1 -0
- package/lib/types/gtk-entry.spec.d.ts +1 -0
- package/lib/types/gtk-image.spec.d.ts +1 -0
- package/lib/types/gtk-menu-button.spec.d.ts +1 -0
- package/lib/types/gtk-progress-bar.spec.d.ts +1 -0
- package/lib/types/gtk-switch.spec.d.ts +1 -0
- package/lib/types/icon-registry.d.ts +2 -2
- package/lib/types/index.d.ts +13 -51
- package/lib/types/namespace/adw.d.ts +44 -0
- package/lib/types/namespace/gtk.d.ts +9 -0
- package/lib/types/styles.generated.d.ts +1 -1
- package/package.json +9 -6
- package/scss/_about_dialog.scss +1 -1
- package/scss/_button.scss +4 -4
- package/scss/_checks.scss +6 -6
- package/scss/_drop_down.scss +3 -3
- package/scss/_entry.scss +3 -3
- package/scss/_expander_row.scss +1 -1
- package/scss/_icon.scss +4 -4
- package/scss/_menu_button.scss +3 -3
- package/scss/_popover.scss +2 -2
- package/scss/_progress_bar.scss +4 -4
- package/scss/_reset.scss +10 -8
- package/scss/_split_button.scss +1 -1
- package/scss/_style_classes.scss +9 -9
- package/scss/_switch.scss +2 -2
- package/scss/_switch_row.scss +1 -1
- package/scss/_toast.scss +1 -1
- package/scss/adwaita-skin.scss +2 -2
- package/src/adw-action-rows.spec.ts +2 -2
- package/src/adw-button-content.spec.ts +1 -1
- package/src/adw-header-bar.spec.ts +9 -4
- package/src/adw-tab-view.spec.ts +71 -0
- package/src/bottom-sheet.spec.ts +2 -2
- package/src/{adw-checks.spec.ts → checks.spec.ts} +11 -11
- package/src/chrome.spec.ts +2 -2
- package/src/connect-lifecycle.spec.ts +10 -7
- package/src/elements/adw-about-dialog.ts +6 -6
- package/src/elements/adw-avatar.ts +4 -4
- package/src/elements/adw-button-content.ts +6 -6
- package/src/elements/adw-button-row.ts +6 -6
- package/src/elements/adw-combo-row.ts +1 -1
- package/src/elements/adw-entry-row.ts +5 -5
- package/src/elements/adw-expander-row.ts +10 -10
- package/src/elements/adw-header-bar.ts +34 -13
- package/src/elements/adw-navigation-view.ts +24 -4
- package/src/elements/adw-password-entry-row.ts +3 -3
- package/src/elements/adw-sidebar.ts +4 -4
- package/src/elements/adw-split-button.ts +14 -14
- package/src/elements/adw-status-page.ts +4 -4
- package/src/elements/adw-switch-row.ts +8 -8
- package/src/elements/adw-tab-view.ts +32 -10
- package/src/elements/adw-toast-overlay.ts +2 -2
- package/src/elements/adw-toggle-group.ts +3 -3
- package/src/elements/adw-view-switcher-bar.ts +3 -3
- package/src/elements/adw-view-switcher.ts +3 -3
- package/src/elements/{adw-checks.ts → checks.ts} +13 -6
- package/src/elements/{adw-button.ts → gtk-button.ts} +6 -6
- package/src/elements/{adw-drop-down.ts → gtk-drop-down.ts} +18 -18
- package/src/elements/{adw-entry.ts → gtk-entry.ts} +4 -4
- package/src/elements/{adw-icon.ts → gtk-image.ts} +5 -5
- package/src/elements/{adw-menu-button.ts → gtk-menu-button.ts} +27 -18
- package/src/elements/{adw-popover.ts → gtk-popover.ts} +18 -18
- package/src/elements/{adw-progress-bar.ts → gtk-progress-bar.ts} +5 -5
- package/src/elements/{adw-switch.ts → gtk-switch.ts} +4 -4
- package/src/elements/view-switcher-dom.ts +5 -5
- package/src/exported-elements.ts +50 -0
- package/src/{adw-button.spec.ts → gtk-button.spec.ts} +6 -6
- package/src/{adw-drop-down.spec.ts → gtk-drop-down.spec.ts} +17 -17
- package/src/{adw-entry.spec.ts → gtk-entry.spec.ts} +8 -8
- package/src/{adw-icon.spec.ts → gtk-image.spec.ts} +21 -21
- package/src/{adw-menu-button.spec.ts → gtk-menu-button.spec.ts} +6 -6
- package/src/{adw-progress-bar.spec.ts → gtk-progress-bar.spec.ts} +12 -12
- package/src/{adw-switch.spec.ts → gtk-switch.spec.ts} +20 -20
- package/src/icon-registry.spec.ts +6 -6
- package/src/icon-registry.ts +6 -6
- package/src/index.ts +64 -63
- package/src/namespace/adw.ts +99 -0
- package/src/namespace/gtk.ts +22 -0
- package/src/preferences-search.ts +1 -1
- package/src/slotted-children.spec.ts +5 -3
- package/src/source-view/adw-source-view.ts +2 -2
- package/src/split-button.spec.ts +5 -5
- package/src/styles.generated.ts +1 -1
- package/src/test.browser.mts +15 -15
- package/lib/types/adw-button.spec.d.ts +0 -1
- package/lib/types/adw-drop-down.spec.d.ts +0 -1
- package/lib/types/adw-entry.spec.d.ts +0 -1
- package/lib/types/adw-icon.spec.d.ts +0 -1
- package/lib/types/adw-menu-button.spec.d.ts +0 -1
- package/lib/types/adw-progress-bar.spec.d.ts +0 -1
- package/lib/types/adw-switch.spec.d.ts +0 -1
- /package/lib/types/{adw-checks.spec.d.ts → checks.spec.d.ts} +0 -0
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
// into state calls, pinned to the C source by the shared vectors in
|
|
26
26
|
// `@gjsify/adwaita-core/conformance` (see `src/split-button.spec.ts`). Of the
|
|
27
27
|
// element's own former copies only the glyph→mask-class mapping is a renderer
|
|
28
|
-
// concern — see ARROW_MASK_CLASSES. The menu surface is `<
|
|
28
|
+
// concern — see ARROW_MASK_CLASSES. The menu surface is `<gtk-popover>`, which is
|
|
29
29
|
// what brings the 15px radius, Escape dismissal and arrow-key navigation; do not
|
|
30
30
|
// hand-roll a surface here instead.
|
|
31
31
|
//
|
|
@@ -47,16 +47,16 @@ import {
|
|
|
47
47
|
import type { AdwArrowIcon, AdwMenuEntry, SplitButtonChange, SplitButtonDirection } from '@gjsify/adwaita-core';
|
|
48
48
|
|
|
49
49
|
// SIDE-EFFECT import, deliberately separate from the type import below: it is
|
|
50
|
-
// what guarantees `
|
|
50
|
+
// what guarantees `gtk-popover` is defined before this module's own
|
|
51
51
|
// `customElements.define` can upgrade a server-rendered `<adw-split-button>` and
|
|
52
|
-
// build one. A combined `import {
|
|
52
|
+
// build one. A combined `import { GtkPopover }` would NOT do it — the binding is
|
|
53
53
|
// only ever used in type position here, and this package compiles without
|
|
54
54
|
// `verbatimModuleSyntax`, so TypeScript would elide the whole statement and take
|
|
55
55
|
// the registration with it.
|
|
56
|
-
import './
|
|
57
|
-
import type {
|
|
56
|
+
import './gtk-popover.js';
|
|
57
|
+
import type { GtkPopover } from './gtk-popover.js';
|
|
58
58
|
|
|
59
|
-
import { type
|
|
59
|
+
import { type GtkImage, createGtkImage } from './gtk-image.js';
|
|
60
60
|
|
|
61
61
|
const VARIANT_CLASSES: Record<string, string> = {
|
|
62
62
|
flat: 'flat',
|
|
@@ -87,11 +87,11 @@ const ARROW_MASK_CLASSES: Readonly<Record<AdwArrowIcon, string>> = {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
// The `-symbolic` strip and the single-CSS-token guard belong to `normalizeIconName`,
|
|
90
|
-
// applied by <
|
|
90
|
+
// applied by <gtk-image>: never rebuild the mask class by hand, which is how five sites
|
|
91
91
|
// in this package shipped without the guard.
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
* Direction → the CSS axis `<
|
|
94
|
+
* Direction → the CSS axis `<gtk-popover>` places the surface on. WHICH
|
|
95
95
|
* direction applies is not decided here — {@link splitButtonPopupDirection}
|
|
96
96
|
* folds `none` onto `down` (GtkMenuButton's rule, not the split button's), and
|
|
97
97
|
* this table is keyed by its output for the same reason ARROW_MASK_CLASSES is.
|
|
@@ -107,8 +107,8 @@ export class AdwSplitButton extends HTMLElement {
|
|
|
107
107
|
private readonly _state = new SplitButtonState();
|
|
108
108
|
private _actionEl!: HTMLButtonElement;
|
|
109
109
|
private _dropdownEl!: HTMLButtonElement;
|
|
110
|
-
private _arrowEl!:
|
|
111
|
-
private _menuEl!:
|
|
110
|
+
private _arrowEl!: GtkImage;
|
|
111
|
+
private _menuEl!: GtkPopover;
|
|
112
112
|
/** Inline text content, captured before we take over the subtree. */
|
|
113
113
|
private _inlineLabel = '';
|
|
114
114
|
/** Last `open` value reflected as `notify::active`, so the event fires once per flip. */
|
|
@@ -226,10 +226,10 @@ export class AdwSplitButton extends HTMLElement {
|
|
|
226
226
|
this._dropdownEl.type = 'button';
|
|
227
227
|
this._dropdownEl.className = 'adw-split-button-dropdown';
|
|
228
228
|
this._dropdownEl.setAttribute('aria-haspopup', 'menu');
|
|
229
|
-
this._arrowEl =
|
|
229
|
+
this._arrowEl = createGtkImage(null);
|
|
230
230
|
this._dropdownEl.appendChild(this._arrowEl);
|
|
231
231
|
|
|
232
|
-
this._menuEl = document.createElement('
|
|
232
|
+
this._menuEl = document.createElement('gtk-popover') as GtkPopover;
|
|
233
233
|
this._menuEl.classList.add('adw-split-button-menu');
|
|
234
234
|
this._menuEl.setAttribute('role', 'menu');
|
|
235
235
|
// The dropdown half IS a GtkMenuButton (the C passes straight through to
|
|
@@ -376,7 +376,7 @@ export class AdwSplitButton extends HTMLElement {
|
|
|
376
376
|
this._actionEl.classList.toggle('icon-only', mode === 'icon');
|
|
377
377
|
|
|
378
378
|
if (mode === 'icon' && iconName !== null) {
|
|
379
|
-
this._actionEl.appendChild(
|
|
379
|
+
this._actionEl.appendChild(createGtkImage(iconName));
|
|
380
380
|
} else if (mode === 'label' && label !== null) {
|
|
381
381
|
// Never trimmed: two spaces are a valid label and render as one.
|
|
382
382
|
this._actionEl.appendChild(document.createTextNode(label));
|
|
@@ -430,7 +430,7 @@ export class AdwSplitButton extends HTMLElement {
|
|
|
430
430
|
const item = document.createElement('button');
|
|
431
431
|
item.type = 'button';
|
|
432
432
|
// `.adw-popover-item` is what makes the row navigable: it is the selector
|
|
433
|
-
// `<
|
|
433
|
+
// `<gtk-popover>` walks for arrow/Home/End/Enter.
|
|
434
434
|
item.className = 'adw-popover-item adw-split-button-menu-item';
|
|
435
435
|
item.setAttribute('role', 'menuitem');
|
|
436
436
|
item.tabIndex = -1;
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
// Reference: refs/libadwaita/src/stylesheet/widgets/_misc.scss (AdwStatusPage)
|
|
6
6
|
// Copyright (c) GNOME contributors (libadwaita). LGPLv2.1+.
|
|
7
7
|
// Modifications: Implemented as a Web Component for @gjsify/adwaita-web; the
|
|
8
|
-
// icon node is <
|
|
8
|
+
// icon node is <gtk-image>.
|
|
9
9
|
|
|
10
10
|
import { stringIsNotEmpty } from '@gjsify/adwaita-core';
|
|
11
11
|
|
|
12
12
|
import { bindEmptySections } from '../empty-sections.js';
|
|
13
13
|
import { bindSlottedChildren } from '../slotted-children.js';
|
|
14
|
-
import { type
|
|
14
|
+
import { type GtkImage, createGtkImage } from './gtk-image.js';
|
|
15
15
|
|
|
16
16
|
export class AdwStatusPage extends HTMLElement {
|
|
17
|
-
private _iconEl!:
|
|
17
|
+
private _iconEl!: GtkImage;
|
|
18
18
|
private _titleEl!: HTMLSpanElement;
|
|
19
19
|
private _descEl!: HTMLSpanElement;
|
|
20
20
|
private _childEl!: HTMLDivElement;
|
|
@@ -28,7 +28,7 @@ export class AdwStatusPage extends HTMLElement {
|
|
|
28
28
|
if (this._initialized) return;
|
|
29
29
|
this._initialized = true;
|
|
30
30
|
|
|
31
|
-
this._iconEl =
|
|
31
|
+
this._iconEl = createGtkImage(null, 'adw-status-page-icon');
|
|
32
32
|
|
|
33
33
|
this._titleEl = document.createElement('span');
|
|
34
34
|
this._titleEl.className = 'adw-status-page-title';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// <adw-switch-row> — row with a title/subtitle and a trailing `<
|
|
1
|
+
// <adw-switch-row> — row with a title/subtitle and a trailing `<gtk-switch>`.
|
|
2
2
|
//
|
|
3
3
|
// The ACTIVE flag, its notify rule and the toggle-on-row-activation are HEADLESS and live
|
|
4
4
|
// in `@gjsify/adwaita-core` (ADR 0004) as {@link SwitchRowState}; this element keeps only
|
|
@@ -14,22 +14,22 @@
|
|
|
14
14
|
// Copyright (c) 2025 csm. MIT License.
|
|
15
15
|
// Modifications: Reimplemented as Web Component for @gjsify/adwaita-web;
|
|
16
16
|
// title/subtitle text column added to match Adw.SwitchRow; the active state
|
|
17
|
-
// composed from @gjsify/adwaita-core; the toggle markup from <
|
|
17
|
+
// composed from @gjsify/adwaita-core; the toggle markup from <gtk-switch>.
|
|
18
18
|
|
|
19
19
|
import { SwitchRowState, deriveRowLabels } from '@gjsify/adwaita-core';
|
|
20
20
|
|
|
21
21
|
// SIDE-EFFECT import, deliberately separate from the type import below: it guarantees
|
|
22
|
-
// `
|
|
23
|
-
// server-rendered `<adw-switch-row>` and build one. A combined `import {
|
|
22
|
+
// `gtk-switch` is defined before this module's `customElements.define` can upgrade a
|
|
23
|
+
// server-rendered `<adw-switch-row>` and build one. A combined `import { GtkSwitch }`
|
|
24
24
|
// would NOT do it — the binding is only used in type position, and this package compiles
|
|
25
25
|
// without `verbatimModuleSyntax`, so TypeScript would elide the statement and take the
|
|
26
26
|
// registration with it.
|
|
27
|
-
import './
|
|
27
|
+
import './gtk-switch.js';
|
|
28
28
|
import { attachRowActivation } from './row-activation.js';
|
|
29
|
-
import type {
|
|
29
|
+
import type { GtkSwitch } from './gtk-switch.js';
|
|
30
30
|
|
|
31
31
|
export class AdwSwitchRow extends HTMLElement {
|
|
32
|
-
private _switchEl!:
|
|
32
|
+
private _switchEl!: GtkSwitch;
|
|
33
33
|
private _titleEl!: HTMLSpanElement;
|
|
34
34
|
private _subtitleEl!: HTMLSpanElement;
|
|
35
35
|
/** The headless active flag + its notify rule (ADR 0004). */
|
|
@@ -62,7 +62,7 @@ export class AdwSwitchRow extends HTMLElement {
|
|
|
62
62
|
this._subtitleEl.className = 'adw-row-subtitle';
|
|
63
63
|
text.append(this._titleEl, this._subtitleEl);
|
|
64
64
|
|
|
65
|
-
this._switchEl = document.createElement('
|
|
65
|
+
this._switchEl = document.createElement('gtk-switch') as GtkSwitch;
|
|
66
66
|
// adw-switch-row.c:159 — the slider is not a focus target; the ROW is.
|
|
67
67
|
this._switchEl.unfocusable = true;
|
|
68
68
|
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
// Reference: packages/nativescript-bridge/adwaita/src/widgets/adw-tab-view.ts (NS twin)
|
|
44
44
|
// Copyright (c) 2020-2022 Purism SPC / GNOME contributors (libadwaita). LGPLv2.1+.
|
|
45
45
|
// Modifications: Implemented as a Web Component for @gjsify/adwaita-web; the
|
|
46
|
-
// tab icon + indicator nodes are <
|
|
46
|
+
// tab icon + indicator nodes are <gtk-image>.
|
|
47
47
|
|
|
48
48
|
import { TabViewState, tabCloseVisible, tabIconState, tabTooltip, tabsRevealed } from '@gjsify/adwaita-core';
|
|
49
49
|
import type { AdwTabPageSpec, AdwTabPageState, TabViewPagesChange, TabViewSelectionChange } from '@gjsify/adwaita-core';
|
|
50
50
|
|
|
51
|
-
import { type
|
|
51
|
+
import { type GtkImage, createGtkImage } from './gtk-image.js';
|
|
52
52
|
|
|
53
53
|
export type AdwTabViewPage = AdwTabPageState<HTMLElement>;
|
|
54
54
|
|
|
@@ -74,8 +74,21 @@ export class AdwTabPage extends HTMLElement {
|
|
|
74
74
|
attributeChangedCallback(name: string, _old: string | null, value: string | null) {
|
|
75
75
|
// `closest` still finds the view after adoption: the element is moved
|
|
76
76
|
// into the view's page container, not replaced by a wrapper.
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
//
|
|
78
|
+
// `instanceof` rather than a cast plus `?.`, because the two failures the
|
|
79
|
+
// `?.` conflated are different: a MISSING ancestor, and an ancestor that is
|
|
80
|
+
// there but is still an ordinary HTMLElement because its own definition has
|
|
81
|
+
// not upgraded it. The cast asserted the second away, and it is the one that
|
|
82
|
+
// happened — `syncDeclaredPage is not a function`, 19 times on
|
|
83
|
+
// `/getting-started/`, once per declared page.
|
|
84
|
+
//
|
|
85
|
+
// Dropping the notification for an un-upgraded view is correct and not
|
|
86
|
+
// merely quiet: such a view has not adopted this page yet, and
|
|
87
|
+
// `_adoptDeclaredPage` reads every attribute in PAGE_ATTRIBUTES straight off
|
|
88
|
+
// the element when it does, so there is nothing to lose and nothing to defer.
|
|
89
|
+
const view = this.closest('adw-tab-view');
|
|
90
|
+
if (!(view instanceof AdwTabView)) return;
|
|
91
|
+
view.syncDeclaredPage(this, name, value);
|
|
79
92
|
}
|
|
80
93
|
}
|
|
81
94
|
|
|
@@ -478,10 +491,10 @@ export class AdwTabView extends HTMLElement {
|
|
|
478
491
|
tab.setAttribute('role', 'tab');
|
|
479
492
|
tab.dataset.pageId = page.id;
|
|
480
493
|
|
|
481
|
-
// Decorative mask-image nodes — <
|
|
494
|
+
// Decorative mask-image nodes — <gtk-image> carries the convention, including the
|
|
482
495
|
// `-symbolic` strip, which is ours and not C's: there the name reaches
|
|
483
496
|
// `GtkImage` untouched.
|
|
484
|
-
const icon =
|
|
497
|
+
const icon = createGtkImage(null, 'adw-tab-icon');
|
|
485
498
|
tab.appendChild(icon);
|
|
486
499
|
|
|
487
500
|
// `AdwTabPage:loading` swaps the icon image for an `AdwSpinnerPaintable` — the
|
|
@@ -498,7 +511,7 @@ export class AdwTabView extends HTMLElement {
|
|
|
498
511
|
label.className = 'adw-tab-title';
|
|
499
512
|
tab.appendChild(label);
|
|
500
513
|
|
|
501
|
-
tab.appendChild(
|
|
514
|
+
tab.appendChild(createGtkImage(null, 'adw-tab-indicator'));
|
|
502
515
|
|
|
503
516
|
// Close affordance — a small flat button drawn with a CSS "×" glyph. NOT because
|
|
504
517
|
// the glyph is unavailable: `window-close` is in the ICONS map and has a mask class
|
|
@@ -568,7 +581,7 @@ export class AdwTabView extends HTMLElement {
|
|
|
568
581
|
tab.classList.toggle('closing', page.closing);
|
|
569
582
|
|
|
570
583
|
const icons = tabIconState(page, this.getAttribute('default-icon'));
|
|
571
|
-
const icon = tab.querySelector('.adw-tab-icon') as
|
|
584
|
+
const icon = tab.querySelector('.adw-tab-icon') as GtkImage | null;
|
|
572
585
|
if (icon) {
|
|
573
586
|
icon.iconName = icons.icon;
|
|
574
587
|
// The two occupy the same slot and are never both visible: C
|
|
@@ -579,7 +592,7 @@ export class AdwTabView extends HTMLElement {
|
|
|
579
592
|
// The spinner is mounted only while it spins, so an idle tab holds no
|
|
580
593
|
// element in the shared rAF ticker.
|
|
581
594
|
if (spinner) spinner.hidden = !(icons.spinner && icons.iconVisible);
|
|
582
|
-
const indicator = tab.querySelector('.adw-tab-indicator') as
|
|
595
|
+
const indicator = tab.querySelector('.adw-tab-indicator') as GtkImage | null;
|
|
583
596
|
if (indicator) {
|
|
584
597
|
indicator.iconName = page.indicatorIcon;
|
|
585
598
|
indicator.hidden = !icons.indicatorVisible;
|
|
@@ -797,5 +810,14 @@ export class AdwTabView extends HTMLElement {
|
|
|
797
810
|
}
|
|
798
811
|
}
|
|
799
812
|
|
|
800
|
-
|
|
813
|
+
// The VIEW first, and the order carries weight: `define` upgrades every matching
|
|
814
|
+
// element already in the document, immediately. Registering the page first therefore
|
|
815
|
+
// upgraded every declared `<adw-tab-page>` while its `<adw-tab-view>` parent was still
|
|
816
|
+
// un-upgraded, and `AdwTabPage.attributeChangedCallback` reaches for that parent.
|
|
817
|
+
// Parent before child keeps the window shut; the `instanceof` guard in the callback is
|
|
818
|
+
// what holds when something outside this file reopens it — and because the guard makes
|
|
819
|
+
// the order UNOBSERVABLE (with it in place, page-first renders identically and every
|
|
820
|
+
// test still passes, measured), the order itself is held by
|
|
821
|
+
// `scripts/check-adwaita-upgrade-order.mjs` rather than by a spec.
|
|
801
822
|
customElements.define('adw-tab-view', AdwTabView);
|
|
823
|
+
customElements.define('adw-tab-page', AdwTabPage);
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import { AdwToast, AdwToastQueue } from '@gjsify/adwaita-core';
|
|
21
21
|
|
|
22
22
|
import { bindSlottedChildren } from '../slotted-children.js';
|
|
23
|
-
import {
|
|
23
|
+
import { createGtkImage } from './gtk-image.js';
|
|
24
24
|
import type { ToastScheduler, ToastTimerHandle } from '@gjsify/adwaita-core';
|
|
25
25
|
|
|
26
26
|
// The timing seam is re-exported so a consumer can type a custom scheduler for
|
|
@@ -196,7 +196,7 @@ export class AdwToastOverlay extends HTMLElement {
|
|
|
196
196
|
close.type = 'button';
|
|
197
197
|
close.className = 'adw-toast-close-button';
|
|
198
198
|
close.setAttribute('aria-label', 'Close');
|
|
199
|
-
close.appendChild(
|
|
199
|
+
close.appendChild(createGtkImage('window-close'));
|
|
200
200
|
close.addEventListener('click', () => this._queue.dismiss());
|
|
201
201
|
el.appendChild(close);
|
|
202
202
|
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
// Copyright (c) GNOME contributors (libadwaita). LGPLv2.1+.
|
|
53
53
|
// Modifications: Implemented as a Web Component for @gjsify/adwaita-web; the
|
|
54
54
|
// selection state machine composed from @gjsify/adwaita-core, the icon node
|
|
55
|
-
// from <
|
|
55
|
+
// from <gtk-image>.
|
|
56
56
|
|
|
57
57
|
import { ToggleGroupState } from '@gjsify/adwaita-core';
|
|
58
58
|
|
|
59
|
-
import {
|
|
59
|
+
import { createGtkImage } from './gtk-image.js';
|
|
60
60
|
import { attachRovingFocus } from './roving-focus.js';
|
|
61
61
|
|
|
62
62
|
/** A single toggle. Children of <adw-toggle-group>; consumed at connect time. */
|
|
@@ -141,7 +141,7 @@ export class AdwToggleGroup extends HTMLElement {
|
|
|
141
141
|
|
|
142
142
|
const label = toggle.getAttribute('label') ?? '';
|
|
143
143
|
const icon = toggle.getAttribute('icon-name') ?? '';
|
|
144
|
-
if (icon) btn.appendChild(
|
|
144
|
+
if (icon) btn.appendChild(createGtkImage(icon));
|
|
145
145
|
if (label) btn.appendChild(document.createTextNode(label));
|
|
146
146
|
|
|
147
147
|
// An icon-only toggle has no text — give it an accessible name.
|
|
@@ -23,13 +23,13 @@ import { ViewSwitcherBarState, buildViewSwitcherButtons, viewSwitcherPagesFromSt
|
|
|
23
23
|
|
|
24
24
|
import type { AdwViewStack } from './adw-view-stack.js';
|
|
25
25
|
import { applyDescription, applyIndicator, applySwitcherIcon } from './view-switcher-dom.js';
|
|
26
|
-
import { type
|
|
26
|
+
import { type GtkImage, createGtkImage } from './gtk-image.js';
|
|
27
27
|
import { attachRovingFocus } from './roving-focus.js';
|
|
28
28
|
|
|
29
29
|
/** The DOM nodes one bar button owns — the bar paints the derived model onto them. */
|
|
30
30
|
interface BarButtonNodes {
|
|
31
31
|
button: HTMLButtonElement;
|
|
32
|
-
icon:
|
|
32
|
+
icon: GtkImage;
|
|
33
33
|
label: HTMLSpanElement;
|
|
34
34
|
indicator: HTMLSpanElement;
|
|
35
35
|
}
|
|
@@ -227,7 +227,7 @@ export class AdwViewSwitcherBar extends HTMLElement {
|
|
|
227
227
|
// recomputing the mapping — the spelling `<adw-inline-view-switcher>` uses.
|
|
228
228
|
button.dataset.pageIndex = String(pageIndex);
|
|
229
229
|
|
|
230
|
-
const icon =
|
|
230
|
+
const icon = createGtkImage(null, 'adw-view-switcher-bar-icon');
|
|
231
231
|
|
|
232
232
|
const label = document.createElement('span');
|
|
233
233
|
label.className = 'adw-view-switcher-bar-label';
|
|
@@ -54,13 +54,13 @@ import {
|
|
|
54
54
|
domViewSwitcherScheduler,
|
|
55
55
|
readSwitcherPage,
|
|
56
56
|
} from './view-switcher-dom.js';
|
|
57
|
-
import { type
|
|
57
|
+
import { type GtkImage, createGtkImage } from './gtk-image.js';
|
|
58
58
|
import { attachRovingFocus } from './roving-focus.js';
|
|
59
59
|
|
|
60
60
|
/** The DOM nodes one page owns — the switcher paints the derived model onto them. */
|
|
61
61
|
interface PageNodes {
|
|
62
62
|
button: HTMLButtonElement;
|
|
63
|
-
icon:
|
|
63
|
+
icon: GtkImage;
|
|
64
64
|
label: HTMLSpanElement;
|
|
65
65
|
indicator: HTMLSpanElement;
|
|
66
66
|
body: HTMLDivElement;
|
|
@@ -271,7 +271,7 @@ export class AdwViewSwitcher extends HTMLElement {
|
|
|
271
271
|
|
|
272
272
|
// Both children always exist, as in AdwViewSwitcherButton's template — the icon
|
|
273
273
|
// carries `image-missing` rather than disappearing.
|
|
274
|
-
const icon =
|
|
274
|
+
const icon = createGtkImage(null, 'adw-view-switcher-icon');
|
|
275
275
|
|
|
276
276
|
const label = document.createElement('span');
|
|
277
277
|
label.className = 'adw-view-switcher-label';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// <
|
|
1
|
+
// <gtk-check-button> and <adw-radio> — the two form-control primitives, in ONE module,
|
|
2
2
|
// for the same reason `scss/_checks.scss` is one partial: upstream merges them
|
|
3
3
|
// (`refs/libadwaita/src/stylesheet/widgets/_checks.scss` has no `_radio.scss` beside
|
|
4
4
|
// it), and everything but the corner radius, the glyph and the group is shared.
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
// disabled — boolean; the control does not respond and is dimmed.
|
|
36
36
|
// label — the text beside the indicator. When absent, the element's
|
|
37
37
|
// existing child nodes become the label (so a server-rendered
|
|
38
|
-
// `<
|
|
38
|
+
// `<gtk-check-button>Enable</gtk-check-button>` upgrades intact).
|
|
39
39
|
// Attributes (<adw-radio> only):
|
|
40
40
|
// name — the group. Exclusivity is scoped to it, exactly as `name`
|
|
41
41
|
// scopes `<input type="radio">` — including the empty case:
|
|
@@ -68,7 +68,14 @@ import { RadioGroupState, resolveCheckState } from '@gjsify/adwaita-core';
|
|
|
68
68
|
*/
|
|
69
69
|
const radioGroups = new RadioGroupState();
|
|
70
70
|
|
|
71
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* The markup + state shared by `<gtk-check-button>` and `<adw-radio>`.
|
|
73
|
+
*
|
|
74
|
+
* It keeps the `Adw` prefix while the element above it does not, and the split is the
|
|
75
|
+
* same one the stylesheet makes: this class builds `.adw-check-input`,
|
|
76
|
+
* `.adw-check-indicator` and `.adw-check-label`, which are the Adwaita SKIN, and the
|
|
77
|
+
* skin is not what the tag names. It is also not a widget — nothing registers it.
|
|
78
|
+
*/
|
|
72
79
|
abstract class AdwCheckBase extends HTMLElement {
|
|
73
80
|
protected _input!: HTMLInputElement;
|
|
74
81
|
protected _indicator!: HTMLSpanElement;
|
|
@@ -124,7 +131,7 @@ abstract class AdwCheckBase extends HTMLElement {
|
|
|
124
131
|
this._initialized = true;
|
|
125
132
|
|
|
126
133
|
// Captured BEFORE the element takes over its own children, so a server-rendered
|
|
127
|
-
// `<
|
|
134
|
+
// `<gtk-check-button>Enable</gtk-check-button>` keeps its text.
|
|
128
135
|
const authored = [...this.childNodes];
|
|
129
136
|
|
|
130
137
|
this._input = document.createElement('input');
|
|
@@ -193,7 +200,7 @@ abstract class AdwCheckBase extends HTMLElement {
|
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
/** The Adwaita checkbox — `checkbutton > check` as a custom element. */
|
|
196
|
-
export class
|
|
203
|
+
export class GtkCheckButton extends AdwCheckBase {
|
|
197
204
|
static get observedAttributes() {
|
|
198
205
|
return ['checked', 'indeterminate', 'disabled', 'label'];
|
|
199
206
|
}
|
|
@@ -282,5 +289,5 @@ export class AdwRadio extends AdwCheckBase {
|
|
|
282
289
|
}
|
|
283
290
|
}
|
|
284
291
|
|
|
285
|
-
customElements.define('
|
|
292
|
+
customElements.define('gtk-check-button', GtkCheckButton);
|
|
286
293
|
customElements.define('adw-radio', AdwRadio);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// <
|
|
1
|
+
// <gtk-button> — Adwaita button.
|
|
2
2
|
// Attributes: icon (symbolic name, e.g. "go-previous" / "view-refresh"),
|
|
3
3
|
// label, tooltip, disabled, and the boolean variant flags
|
|
4
4
|
// flat / suggested / destructive / circular / pill.
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
// Reference: refs/libadwaita/src/stylesheet/widgets/_buttons.scss
|
|
8
8
|
// Copyright (c) GNOME contributors (libadwaita). LGPLv2.1+.
|
|
9
9
|
// Modifications: Implemented as a Web Component for @gjsify/adwaita-web; the
|
|
10
|
-
// icon node is <
|
|
10
|
+
// icon node is <gtk-image>.
|
|
11
11
|
|
|
12
12
|
import { buttonStyleClasses } from '@gjsify/adwaita-core';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { createGtkImage } from './gtk-image.js';
|
|
15
15
|
|
|
16
16
|
/** The boolean attributes that select a style class; the mapping lives in the core. */
|
|
17
17
|
const STYLE_ATTRIBUTES = ['flat', 'suggested', 'destructive', 'circular', 'pill'] as const;
|
|
18
18
|
|
|
19
|
-
export class
|
|
19
|
+
export class GtkButton extends HTMLElement {
|
|
20
20
|
private _button!: HTMLButtonElement;
|
|
21
21
|
private _label = '';
|
|
22
22
|
private _initialized = false;
|
|
@@ -57,7 +57,7 @@ export class AdwButton extends HTMLElement {
|
|
|
57
57
|
if (icon && !label) btn.classList.add('icon-only');
|
|
58
58
|
|
|
59
59
|
btn.replaceChildren();
|
|
60
|
-
if (icon) btn.appendChild(
|
|
60
|
+
if (icon) btn.appendChild(createGtkImage(icon));
|
|
61
61
|
if (label) btn.appendChild(document.createTextNode(label));
|
|
62
62
|
|
|
63
63
|
const tooltip = this.getAttribute('tooltip');
|
|
@@ -74,4 +74,4 @@ export class AdwButton extends HTMLElement {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
customElements.define('
|
|
77
|
+
customElements.define('gtk-button', GtkButton);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// <
|
|
1
|
+
// <gtk-drop-down> — A standalone dropdown selector: the web counterpart of
|
|
2
2
|
// Gtk.DropDown. It is a flat Adwaita button showing the current selection (its
|
|
3
3
|
// label + a `pan-down` chevron) that opens an Adwaita popover list of options;
|
|
4
4
|
// picking one updates the selection. This is the toolbar/inline control twin of
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// Escape and supports arrow-key navigation, Home/End, Enter to pick, and
|
|
13
13
|
// type-ahead (typing jumps to the next matching option).
|
|
14
14
|
//
|
|
15
|
-
// The popover is `<
|
|
15
|
+
// The popover is `<gtk-popover>` and the dismissal/keyboard machine is
|
|
16
16
|
// `@gjsify/adwaita-core`'s (ADR 0004). So is the SELECTION: the options list, the
|
|
17
17
|
// index↔value mapping, the bounds guards and the programmatic-vs-interactive split are
|
|
18
18
|
// {@link ComboState}, the same state machine `<adw-combo-row>` composes — so both
|
|
@@ -47,31 +47,31 @@
|
|
|
47
47
|
// Modifications: Implemented as a Web Component for @gjsify/adwaita-web.
|
|
48
48
|
|
|
49
49
|
// SIDE-EFFECT import, deliberately separate from the type import below: it is
|
|
50
|
-
// what guarantees `
|
|
51
|
-
// `customElements.define` can upgrade a server-rendered `<
|
|
52
|
-
// build one. A combined `import {
|
|
50
|
+
// what guarantees `gtk-popover` is defined before this module's own
|
|
51
|
+
// `customElements.define` can upgrade a server-rendered `<gtk-drop-down>` and
|
|
52
|
+
// build one. A combined `import { GtkPopover }` would NOT do it — the binding is
|
|
53
53
|
// only ever used in type position here, and this package compiles without
|
|
54
54
|
// `verbatimModuleSyntax`, so TypeScript would elide the whole statement and take
|
|
55
55
|
// the registration with it.
|
|
56
|
-
import './
|
|
57
|
-
import type {
|
|
56
|
+
import './gtk-popover.js';
|
|
57
|
+
import type { GtkPopover } from './gtk-popover.js';
|
|
58
58
|
|
|
59
59
|
import { ComboState, normalizeComboOptions } from '@gjsify/adwaita-core';
|
|
60
60
|
import type { AdwComboOption, AdwComboOptionInput } from '@gjsify/adwaita-core';
|
|
61
61
|
|
|
62
|
-
import {
|
|
62
|
+
import { createGtkImage } from './gtk-image.js';
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* A dropdown option — `value` is the stable id, `label` the shown text. An alias of
|
|
66
66
|
* core's {@link AdwComboOption}, since the drop-down and the combo row are the same
|
|
67
67
|
* selection model behind two chromes; still exported so the published name keeps working.
|
|
68
68
|
*/
|
|
69
|
-
export type
|
|
69
|
+
export type GtkDropDownOption = AdwComboOption;
|
|
70
70
|
|
|
71
|
-
export class
|
|
71
|
+
export class GtkDropDown extends HTMLElement {
|
|
72
72
|
private _buttonEl!: HTMLButtonElement;
|
|
73
73
|
private _labelEl!: HTMLSpanElement;
|
|
74
|
-
private _popoverEl!:
|
|
74
|
+
private _popoverEl!: GtkPopover;
|
|
75
75
|
private _listEl!: HTMLDivElement;
|
|
76
76
|
private _searchEl: HTMLInputElement | null = null;
|
|
77
77
|
private _itemButtons: HTMLButtonElement[] = [];
|
|
@@ -86,7 +86,7 @@ export class AdwDropDown extends HTMLElement {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/** The options list. Setting it rebuilds the popover and clamps the selection. */
|
|
89
|
-
get options():
|
|
89
|
+
get options(): GtkDropDownOption[] {
|
|
90
90
|
return this._state.options;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -97,7 +97,7 @@ export class AdwDropDown extends HTMLElement {
|
|
|
97
97
|
if (this._initialized) this._renderAll();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
get items():
|
|
100
|
+
get items(): GtkDropDownOption[] {
|
|
101
101
|
return this._state.options;
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -124,7 +124,7 @@ export class AdwDropDown extends HTMLElement {
|
|
|
124
124
|
if (index >= 0) this._selectIndex(index);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
get selectedItem():
|
|
127
|
+
get selectedItem(): GtkDropDownOption | null {
|
|
128
128
|
return this._state.options[this._state.selectedIndex] ?? null;
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -156,7 +156,7 @@ export class AdwDropDown extends HTMLElement {
|
|
|
156
156
|
this._labelEl = document.createElement('span');
|
|
157
157
|
this._labelEl.className = 'adw-drop-down-label';
|
|
158
158
|
|
|
159
|
-
this._buttonEl.append(this._labelEl,
|
|
159
|
+
this._buttonEl.append(this._labelEl, createGtkImage('go-down', 'adw-drop-down-arrow'));
|
|
160
160
|
this._buttonEl.addEventListener('click', () => {
|
|
161
161
|
if (this.hasAttribute('disabled')) return;
|
|
162
162
|
if (!this._popoverEl.open && this._state.count === 0) return;
|
|
@@ -164,7 +164,7 @@ export class AdwDropDown extends HTMLElement {
|
|
|
164
164
|
});
|
|
165
165
|
this._buttonEl.addEventListener('keydown', (event) => this._onButtonKeyDown(event));
|
|
166
166
|
|
|
167
|
-
this._popoverEl = document.createElement('
|
|
167
|
+
this._popoverEl = document.createElement('gtk-popover') as GtkPopover;
|
|
168
168
|
this._popoverEl.classList.add('adw-drop-down-popover');
|
|
169
169
|
this._popoverEl.setAttribute('role', 'listbox');
|
|
170
170
|
// A dropdown's popover is a `popover.menu` too — `dropdown { popover.menu { … } }`
|
|
@@ -208,7 +208,7 @@ export class AdwDropDown extends HTMLElement {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
private _parseOptionsAttr():
|
|
211
|
+
private _parseOptionsAttr(): GtkDropDownOption[] {
|
|
212
212
|
const raw = this.getAttribute('options') ?? this.getAttribute('items');
|
|
213
213
|
if (!raw) return [];
|
|
214
214
|
try {
|
|
@@ -378,4 +378,4 @@ export class AdwDropDown extends HTMLElement {
|
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
-
customElements.define('
|
|
381
|
+
customElements.define('gtk-drop-down', GtkDropDown);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// <
|
|
1
|
+
// <gtk-entry> — Adwaita single-line text entry (e.g. a browser URL bar).
|
|
2
2
|
// Attributes: value, placeholder, type, disabled, maxlength.
|
|
3
3
|
// Properties: value (get/set, proxies the inner input), maxLength, textLength.
|
|
4
4
|
// Events: native `input` bubbles from the inner input; `activate` (CustomEvent)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// The character arithmetic is HEADLESS and lives in `@gjsify/adwaita-core`
|
|
8
8
|
// (ADR 0004): `entryTextLength` counts CODE POINTS and `clampEntryText` truncates
|
|
9
|
-
// on them. `@gjsify/adwaita-nativescript`'s
|
|
9
|
+
// on them. `@gjsify/adwaita-nativescript`'s GtkEntry has composed the same two
|
|
10
10
|
// since it shipped; this element counted nothing at all, so the same consumer
|
|
11
11
|
// got a max length on one renderer and none on the other — and the native
|
|
12
12
|
// `maxlength` attribute would not have closed the gap, because the browser
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { ENTRY_ROW_MAX_LENGTH_LIMIT, clampEntryText, entryTextLength } from '@gjsify/adwaita-core';
|
|
23
23
|
|
|
24
|
-
export class
|
|
24
|
+
export class GtkEntry extends HTMLElement {
|
|
25
25
|
private _input!: HTMLInputElement;
|
|
26
26
|
private _initialized = false;
|
|
27
27
|
private _maxLength = 0;
|
|
@@ -103,4 +103,4 @@ export class AdwEntry extends HTMLElement {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
customElements.define('
|
|
106
|
+
customElements.define('gtk-entry', GtkEntry);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// <
|
|
1
|
+
// <gtk-image> — the symbolic icon node as an element. Every icon in this package is a
|
|
2
2
|
// CSS-masked box whose glyph comes from a generated `.adw-icon--<name>` class and
|
|
3
3
|
// whose colour is `currentColor`, so it themes with whatever contains it. The name
|
|
4
4
|
// derivation and its guard live once in `@gjsify/adwaita-core`'s
|
|
@@ -46,7 +46,7 @@ export const MASK_CLASS_PREFIX = 'adw-icon--';
|
|
|
46
46
|
*/
|
|
47
47
|
export const MISSING_ICON_NAME = 'image-missing';
|
|
48
48
|
|
|
49
|
-
export class
|
|
49
|
+
export class GtkImage extends HTMLElement {
|
|
50
50
|
static get observedAttributes() {
|
|
51
51
|
return ['icon-name', 'size'];
|
|
52
52
|
}
|
|
@@ -141,11 +141,11 @@ export class AdwIcon extends HTMLElement {
|
|
|
141
141
|
* Build one icon node. `extraClasses` are the caller's own positioning/context
|
|
142
142
|
* classes, added alongside the managed `.adw-icon` + mask class, not replacing them.
|
|
143
143
|
*/
|
|
144
|
-
export function
|
|
145
|
-
const icon = document.createElement('
|
|
144
|
+
export function createGtkImage(iconName: string | null, ...extraClasses: string[]): GtkImage {
|
|
145
|
+
const icon = document.createElement('gtk-image') as GtkImage;
|
|
146
146
|
if (iconName !== null) icon.setAttribute('icon-name', iconName);
|
|
147
147
|
if (extraClasses.length > 0) icon.classList.add(...extraClasses);
|
|
148
148
|
return icon;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
customElements.define('
|
|
151
|
+
customElements.define('gtk-image', GtkImage);
|