@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
package/lib/types/index.d.ts
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
|
+
export { ActionRowState, BUTTON_ROW_ACTIVATABLE, ButtonRowState, SwitchRowState, WindowTitleState, deriveRowLabels, } from './action-row.js';
|
|
2
|
+
export type { ActionRowRenderState, AdwRowLabelInput, AdwRowLabels, ButtonRowRenderState, WindowTitleRenderState, } from './action-row.js';
|
|
3
|
+
export { ADW_ABOUT_DIALOG_LABELS, ADW_CREDITS_SECTION_TITLES, ADW_LICENSES, ADW_LICENSE_ALIASES, ADW_LICENSE_DEFAULTS, ADW_LICENSE_WARRANTY_TEMPLATE, ADW_TRANSLATOR_CREDITS_SENTINELS, GTK_LICENSE, aboutDialogVisibility, creditsSections, isLicenseType, legalSectionVisible, licenseText, licenseTypeForSpdxId, parseCreditPerson, setLicense, setLicenseType, translatorCreditsPeople, } from './about-dialog.js';
|
|
4
|
+
export type { AdwAboutDialogProps, AdwAboutDialogVisibility, AdwCreditPerson, AdwCreditsInput, AdwCreditsSection, AdwCreditsSectionInput, AdwLicenseAlias, AdwLicenseInfo, AdwLicenseNotify, AdwLicenseState, AdwLicenseTransition, AdwLicenseType, } from './about-dialog.js';
|
|
5
|
+
export { AVATAR_COLOR_COUNT, AVATAR_COLORS, avatarColor, avatarColorClass, avatarFontSize, avatarInitials, avatarMaxFontSize, avatarMode, flattenAvatarGradient, gStrHash, randomAvatarColorClass, } from './avatar.js';
|
|
6
|
+
export type { AdwAvatarColor, AdwAvatarMode } from './avatar.js';
|
|
7
|
+
export { ADW_BANNER_BUTTON_STYLES, ADW_BANNER_BUTTON_STYLE_CLASSES, ADW_BANNER_DEFAULTS, bannerButtonStyleClasses, bannerButtonText, bannerButtonVisible, bannerRenderState, isBannerButtonStyle, parseBannerButtonStyle, } from './banner.js';
|
|
8
|
+
export type { AdwBannerButtonStyle, AdwBannerProps, AdwBannerRenderState } from './banner.js';
|
|
9
|
+
export { ADW_BUTTON_CONTENT_DEFAULTS, BUTTON_CONTENT_FALLBACK_ICON, BUTTON_CONTENT_STYLE_CLASS, buttonContentEllipsize, buttonContentIconExpands, buttonContentIconIsEmpty, buttonContentIconName, buttonContentLabelText, buttonContentLabelVisible, buttonContentRenderState, buttonContentStyleTargetIndex, } from './button-content.js';
|
|
10
|
+
export type { AdwButtonContentProps, AdwButtonContentRenderState, ButtonContentAncestor, ButtonContentEllipsize, } from './button-content.js';
|
|
11
|
+
export { RadioGroupState, resolveCheckState } from './checks.js';
|
|
12
|
+
export type { AdwCheckState, RadioGroupChange, RadioGroupListener } from './checks.js';
|
|
1
13
|
export { AdwBreakpoint, evaluateBreakpointCondition, parseBreakpointCondition } from './breakpoint.js';
|
|
2
14
|
export type { AdwBreakpointHandlers, BreakpointBound, BreakpointConditionGroup, BreakpointConditionLeaf, BreakpointConditionNode, BreakpointDimension, BreakpointSize, } from './breakpoint.js';
|
|
3
15
|
export { DEFAULT_ICON_COLOR, DEFAULT_ICON_COLOR_DARK, adwaitaColorScheme, isThemeIconColor, onAdwaitaColorSchemeChanged, setAdwaitaColorScheme, themeIconColor, toggleAdwaitaColorScheme, } from './color-scheme.js';
|
|
4
16
|
export type { AdwColorScheme } from './color-scheme.js';
|
|
17
|
+
export { ADW_DATA_GRID_ROW_VARIANTS, DATA_GRID_CELL_CLASS, DATA_GRID_ROW_CLASS, dataGridCellText, dataGridColumnAlign, dataGridColumnClasses, dataGridRowInteractive, dataGridTrackTemplate, dataGridTracks, normalizeDataGridColumns, normalizeDataGridVariant, } from './data-grid.js';
|
|
18
|
+
export type { AdwDataGridAlign, AdwDataGridCellValue, AdwDataGridColumn, AdwDataGridRow, AdwDataGridRowVariant, DataGridTrack, } from './data-grid.js';
|
|
5
19
|
export { AdwToast, AdwToastQueue, DEFAULT_TOAST_TIMEOUT } from './toast.js';
|
|
6
20
|
export type { AdwToastOptions, AdwToastQueueHandlers, AdwToastQueueOptions, ToastScheduler, ToastTimerHandle, } from './toast.js';
|
|
7
|
-
export { AdwAlertResponses } from './dialog.js';
|
|
8
|
-
export type { AdwAlertResponse, AdwResponseAppearance, AdwResponseOptions, OrderedConfirmResponses } from './dialog.js';
|
|
9
|
-
export { ComboState, ExpanderState, SpinState, ToggleGroupState } from './rows.js';
|
|
10
|
-
export type { AdwComboOption, ComboStateChange, ComboStateListener, ExpanderStateListener, SpinStateChange, SpinStateListener, ToggleGroupStateChange, ToggleGroupStateListener, } from './rows.js';
|
|
21
|
+
export { AdwAlertResponses, BottomSheetPresentation, resolveBottomSheetClose } from './dialog.js';
|
|
22
|
+
export type { AdwAlertResponse, AdwResponseAppearance, AdwResponseOptions, BottomSheetCloseOutcome, BottomSheetCloseSource, BottomSheetCloseState, BottomSheetPresentationListener, BottomSheetPresentationOptions, BottomSheetTeardownCallback, OrderedConfirmResponses, } from './dialog.js';
|
|
23
|
+
export { ComboState, ExpanderState, SpinState, ToggleGroupState, normalizeComboOptions } from './rows.js';
|
|
24
|
+
export type { AdwComboOption, AdwComboOptionInput, ComboStateChange, ComboStateListener, ExpanderStateListener, SpinStateChange, SpinStateListener, ToggleGroupStateChange, ToggleGroupStateListener, } from './rows.js';
|
|
25
|
+
export { glibClamp, gStrStrip, stringIsNotEmpty } from './glib.js';
|
|
26
|
+
export { ViewStackState, normalizeIconName, resolvePageTitle } from './view-stack.js';
|
|
27
|
+
export type { AdwViewStackPageInfo, AdwViewStackPageSpec, ViewStackStateChange, ViewStackStateListener, } from './view-stack.js';
|
|
28
|
+
export { BACK_BUTTON_FALLBACK_TOOLTIP, NavigationViewState, describeNavigationDiagnostic } from './navigation-view.js';
|
|
29
|
+
export type { AdwNavigationPageProps, NavigationChangeReason, NavigationDiagnostic, NavigationDiagnosticCode, NavigationDiagnosticListener, NavigationPagePropsResolver, NavigationShortcutResult, NavigationStackChange, NavigationStackListener, NavigationViewOptions, } from './navigation-view.js';
|
|
30
|
+
export { ADW_SIDEBAR_NO_SELECTION, SidebarState, adjustSidebarSelection, clampSidebarSelection, flattenSidebarItems, sidebarHeaders, } from './sidebar.js';
|
|
31
|
+
export type { AdwSidebarItemSpec, AdwSidebarMode, AdwSidebarSectionSpec, SidebarActivation, SidebarFlatItem, SidebarHeaderSpec, SidebarItemFilter, SidebarSelectionChange, SidebarStateListener, } from './sidebar.js';
|
|
32
|
+
export { CAPS_LOCK_ICON_NAME, CAPS_LOCK_TOOLTIP, EMPTY_ANIMATION_DURATION_MS, ENTRY_ROW_APPLY_ICON_NAME, ENTRY_ROW_APPLY_TOOLTIP, ENTRY_ROW_EDIT_ICON_NAME, ENTRY_ROW_MAX_LENGTH_LIMIT, ENTRY_ROW_TITLE_SPACING, EntryRowState, PASSWORD_CONCEAL_ICON_NAME, PASSWORD_CONCEAL_LABEL, PASSWORD_REVEAL_ICON_NAME, PASSWORD_REVEAL_LABEL, PasswordEntryRowState, clampEntryText, entryTextLength, } from './entry-row.js';
|
|
33
|
+
export type { EntryRowActivation, EntryRowRenderState, EntryRowStateListener, PasswordEntryRowRenderState, PasswordEntryRowStateListener, } from './entry-row.js';
|
|
34
|
+
export { ADW_SWIPE_BORDER, DEFAULT_DPI, DEFAULT_MAX_SIDEBAR_WIDTH, DEFAULT_MIN_SIDEBAR_WIDTH, DEFAULT_SIDEBAR_WIDTH_FRACTION, DEFAULT_SIDEBAR_WIDTH_UNIT, INSTANT_SPLIT_VIEW_ANIMATOR, NAVIGATION_SPLIT_VIEW_CRITICALS, NavigationSplitViewState, OverlaySplitViewState, adwLengthToPx, isSidebarAtVisualStart, layoutNavigationSplitView, layoutOverlaySplitView, measureSplitViewHorizontal, resolveNaturalSidebarWidth, resolveNavigationAction, resolveNavigationSidebarWidth, resolveNavigationStack, resolveOverlaySidebarWidth, resolveSidebarBounds, resolveSwipeArea, resolveSwipeRelease, resolveSwipeSnapPoints, resolveSwipeStart, swipeCancelProgress, tagsConflict, } from './split-view.js';
|
|
35
|
+
export type { AdwLengthUnit, AdwPackType, AdwTextDirection, NavigationActionInput, NavigationActionResult, NavigationPageRef, NavigationSplitViewChange, NavigationSplitViewHandlers, NavigationSplitViewLayout, NavigationSplitViewListener, NavigationSplitViewOptions, NavigationSplitViewProperty, NavigationStackPlan, OverlaySplitViewChange, OverlaySplitViewLayout, OverlaySplitViewListener, OverlaySplitViewOptions, OverlaySplitViewProperty, SidebarBounds, SidebarWidthInput, SidebarWidthSpec, SplitViewAnimation, SplitViewAnimationRequest, SplitViewAnimator, SplitViewMeasureInput, SplitViewPane, SplitViewPaneRect, SwipeReleasePlan, } from './split-view.js';
|
|
36
|
+
export { DEFAULT_DROPDOWN_TOOLTIP, SPLIT_BUTTON_DISABLED_OPACITY, SplitButtonState, isSplitButtonDirection, menuButtonArrowIcon, menuButtonPopupDirection, parseMenuEntries, resolveDropdownTooltip, splitButtonArrowIcon, splitButtonPopupDirection, splitButtonRootState, splitButtonStyleClasses, } from './split-button.js';
|
|
37
|
+
export type { AdwArrowIcon, AdwMenuEntry, SplitButtonChange, SplitButtonContentMode, SplitButtonDirection, SplitButtonHalfState, SplitButtonListener, SplitButtonProperty, SplitButtonStyleClass, } from './split-button.js';
|
|
38
|
+
export { DEFAULT_INDICATOR_DESCRIPTION_STRINGS, INLINE_VIEW_SWITCHER_DISPLAY_MODES, VIEW_SWITCHER_BADGE_LIMIT, VIEW_SWITCHER_DRAG_SWITCH_DELAY, VIEW_SWITCHER_FALLBACK_ICON, VIEW_SWITCHER_NO_SELECTION, VIEW_SWITCHER_POLICIES, ViewSwitcherBarState, ViewSwitcherDragSwitch, ViewSwitcherState, buildInlineToggles, buildViewSwitcherButtons, createViewSwitcherPage, inlineToggleTooltip, isInlineViewSwitcherDisplayMode, isViewSwitcherButtonVisible, isViewSwitcherPolicy, pageIndexForToggle, shouldRevealViewSwitcherBar, stripMnemonic, toggleIndexForPage, viewSwitcherBadgeLabel, viewSwitcherButtonOrientation, viewSwitcherIconName, viewSwitcherIndicatorDescription, viewSwitcherLabel, viewSwitcherPageFromStackPage, viewSwitcherPagesFromStack, } from './view-switcher.js';
|
|
39
|
+
export type { AdwInlineViewSwitcherDisplayMode, AdwViewSwitcherPage, AdwViewSwitcherPageInit, AdwViewSwitcherPolicy, IndicatorDescriptionStrings, InlineToggleModel, ViewSwitcherBarChange, ViewSwitcherBarListener, ViewSwitcherButtonModel, ViewSwitcherDragSwitchOptions, ViewSwitcherScheduler, ViewSwitcherStateChange, ViewSwitcherStateListener, ViewSwitcherStateOptions, ViewSwitcherTimerHandle, } from './view-switcher.js';
|
|
40
|
+
export { DEFAULT_TAB_AUTOHIDE, TabViewState, isDescendantOfPage, successorAfterClose, tabCloseVisible, tabIconState, tabTooltip, tabTooltipIsMarkup, tabsRevealed, } from './tab-view.js';
|
|
41
|
+
export type { AdwTabPageSpec, AdwTabPageState, TabIconState, TabViewHandlers, TabViewPagesChange, TabViewPagesChangeKind, TabViewPagesListener, TabViewSelectionChange, TabViewSelectionListener, } from './tab-view.js';
|
|
42
|
+
export { CAROUSEL_SCROLL_TIMEOUT_MS, CAROUSEL_SETTLE_EPSILON, CarouselState, carouselClampPosition, carouselClosestSnapPoint, carouselNavigateTarget, carouselPageAtPosition, carouselRange, carouselReorderShift, carouselSizesFromSnapPoints, carouselSnapPoints, carouselWheelStep, } from './carousel.js';
|
|
43
|
+
export type { CarouselChangeReason, CarouselDirection, CarouselOrientation, CarouselPageChangedListener, CarouselRange, CarouselReorderShiftInput, CarouselScrollOptions, CarouselScrollRequest, CarouselScrollSource, CarouselStateChange, CarouselStateListener, CarouselStateOptions, CarouselWheelInput, } from './carousel.js';
|
|
44
|
+
export { UNTITLED_PAGE_LABEL, collectSearchRows, countVisiblePages, createSearchRowSubtitle, defaultCaseFolder, derivePreferencesGroupHeader, escapeMarkup, makeComparable, rowMatchesQuery, searchPreferences, stripMarkup, } from './preferences.js';
|
|
45
|
+
export type { CaseFolder, MakeComparableOptions, PreferencesGroupHeaderInput, PreferencesGroupHeaderState, PreferencesSearchEntry, PreferencesSearchGroup, PreferencesSearchPage, PreferencesSearchResult, PreferencesSearchRow, SearchPreferencesOptions, SearchRowSubtitleInput, } from './preferences.js';
|
|
46
|
+
export { ADW_CLAMP_DEFAULTS, ADW_CLAMP_SIZE_CLASSES, ADW_SPINNER_MAX_SIZE, ADW_SPINNER_MIN_SIZE, ADW_TOOLBAR_BAR_CLASSES, ADW_TOOLBAR_VIEW_CLASSES, ADW_TOOLBAR_VIEW_DEFAULTS, clampAllocate, clampChildSize, clampSizeFromChild, clampThresholds, normalizeClampSize, parseToolbarStyle, resolveSpinnerSize, spinnerGeometry, toolbarBarStyleClasses, toolbarViewAllocate, toolbarViewClasses, toolbarViewContentForSize, toolbarViewMeasure, } from './chrome.js';
|
|
47
|
+
export type { AdwClampSizeClass, AdwMeasurement, AdwToolbarStyle, ClampAllocation, ClampParams, ClampThresholds, SpinnerGeometry, ToolbarViewAllocateInput, ToolbarViewAllocation, ToolbarViewClassInput, ToolbarViewClasses, ToolbarViewContentForSize, ToolbarViewContentForSizeInput, ToolbarViewMeasureInput, } from './chrome.js';
|
|
48
|
+
export { POPOVER_ITEM_RADIUS, POPOVER_MENU_PADDING, POPOVER_PADDING, POPOVER_RADIUS, PopoverState, resolvePopoverKey, } from './popover.js';
|
|
49
|
+
export type { PopoverKeyAction, PopoverKeyContext, PopoverKeyResolution, PopoverStateChange, PopoverStateListener, } from './popover.js';
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/** The three headless `AdwNavigationPage` properties a renderer registers a page with. */
|
|
2
|
+
export interface AdwNavigationPageProps {
|
|
3
|
+
/**
|
|
4
|
+
* `AdwNavigationPage:tag` — unique within one view, or `null` for untagged.
|
|
5
|
+
* `''` is a legal tag: the C tag table is a plain `g_str_hash` table and only
|
|
6
|
+
* a NULL tag is skipped (add_page:1281).
|
|
7
|
+
*/
|
|
8
|
+
tag?: string | null;
|
|
9
|
+
/** `AdwNavigationPage:title` — defaults to `''`, never null (adw_navigation_page_init:794). */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** `AdwNavigationPage:can-pop` — defaults to `true` (adw_navigation_page_init:795). */
|
|
12
|
+
canPop?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Why the stack moved. Maps 1:1 onto the C signals so a renderer can re-emit
|
|
16
|
+
* them without re-deriving the cause: `'add'`/`'push'` → `::pushed`, `'pop'` →
|
|
17
|
+
* one `::popped` per entry in {@link NavigationStackChange.popped}, `'replace'` →
|
|
18
|
+
* `::replaced`. `'add'` is split out from `'push'` only because it is the
|
|
19
|
+
* auto-push add_page:1284-1285 performs, which is never animated.
|
|
20
|
+
*/
|
|
21
|
+
export type NavigationChangeReason = 'add' | 'push' | 'pop' | 'replace';
|
|
22
|
+
/** One stack mutation, as a single payload. */
|
|
23
|
+
export interface NavigationStackChange<P> {
|
|
24
|
+
/** The new navigation stack, bottom-first (`adw_navigation_view_get_navigation_stack`). */
|
|
25
|
+
stack: readonly P[];
|
|
26
|
+
/** The new visible page — the top of {@link stack} — or `null` for an empty stack. */
|
|
27
|
+
visiblePage: P | null;
|
|
28
|
+
/** {@link visiblePage}'s tag, or `null`. Never `''` for an untagged page. */
|
|
29
|
+
visiblePageTag: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* The page that was visible before this mutation. `previousVisiblePage !==
|
|
32
|
+
* visiblePage` is exactly the condition under which libadwaita notifies
|
|
33
|
+
* `visible-page` — including the `replace()` corner where the old visible
|
|
34
|
+
* page was destroyed rather than switched away from (replace:3078-3079).
|
|
35
|
+
*/
|
|
36
|
+
previousVisiblePage: P | null;
|
|
37
|
+
/** Why the stack moved. */
|
|
38
|
+
reason: NavigationChangeReason;
|
|
39
|
+
/**
|
|
40
|
+
* The popped pages, TOP-FIRST — `::popped` is emitted in this order.
|
|
41
|
+
* pop_from_stack:989-994 builds the list with `g_slist_prepend` while walking
|
|
42
|
+
* bottom-up, then iterates it forward. Always empty unless `reason` is `'pop'`.
|
|
43
|
+
*/
|
|
44
|
+
popped: readonly P[];
|
|
45
|
+
/** Pages unregistered by this mutation — the renderer destroys their views now. */
|
|
46
|
+
removed: readonly P[];
|
|
47
|
+
/**
|
|
48
|
+
* The outgoing visible page, destroyed only once the transition finishes
|
|
49
|
+
* (pop_from_stack:1007 skips it; transition_done_cb:1042 does it). The
|
|
50
|
+
* renderer hands it back by calling {@link NavigationViewState.finishTransition}.
|
|
51
|
+
*/
|
|
52
|
+
removeAfterTransition: P | null;
|
|
53
|
+
/**
|
|
54
|
+
* Whether this transition animates. `false` for the auto-push (add_page:1285),
|
|
55
|
+
* for every `replace()` (replace:3075), and whenever there is no outgoing page
|
|
56
|
+
* to slide away from (switch_page:857-858).
|
|
57
|
+
*/
|
|
58
|
+
animate: boolean;
|
|
59
|
+
/** Transition direction: `true` when the new page comes from BELOW (pop/replace). */
|
|
60
|
+
pop: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether `visible-page-tag` re-notifies: switch_page:927-930 notifies only
|
|
63
|
+
* when the outgoing OR the incoming page carries a tag.
|
|
64
|
+
*/
|
|
65
|
+
tagNotify: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** The four `g_critical` sites of the family, as structured data. */
|
|
68
|
+
export type NavigationDiagnosticCode = 'duplicate-tag' | 'already-in-stack' | 'tag-not-found' | 'not-in-stack';
|
|
69
|
+
/**
|
|
70
|
+
* A rejected mutation. Replaces `g_critical`: today web writes `console.warn`
|
|
71
|
+
* with two of the four cases and NS is silent, which is itself a divergence.
|
|
72
|
+
*/
|
|
73
|
+
export interface NavigationDiagnostic {
|
|
74
|
+
/** Which rule rejected the call. */
|
|
75
|
+
code: NavigationDiagnosticCode;
|
|
76
|
+
/** The offending tag, where the C message names one. */
|
|
77
|
+
tag?: string | null;
|
|
78
|
+
/** The offending page's title, where the C message names one instead. */
|
|
79
|
+
title?: string;
|
|
80
|
+
}
|
|
81
|
+
/** Subscriber for {@link NavigationViewState} stack changes. */
|
|
82
|
+
export type NavigationStackListener<P> = (change: NavigationStackChange<P>) => void;
|
|
83
|
+
/** Sink for rejected mutations — the injected `g_critical`. */
|
|
84
|
+
export type NavigationDiagnosticListener = (diagnostic: NavigationDiagnostic) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Supplies {@link AdwNavigationPageProps} for a page a mutation is registering
|
|
87
|
+
* on the fly. `replace()` may introduce pages the view has never seen; a renderer
|
|
88
|
+
* reads their properties from its own markup (DOM attributes, XML) and this is
|
|
89
|
+
* the seam that lets it, without core touching a platform API.
|
|
90
|
+
*/
|
|
91
|
+
export type NavigationPagePropsResolver<P> = (page: P) => AdwNavigationPageProps | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* What a shortcut handler must do with the key event. `'stop'` is
|
|
94
|
+
* `GDK_EVENT_STOP` — notably also returned WITHOUT popping when the visible page
|
|
95
|
+
* has `can-pop = FALSE`, so the key is not forwarded to an enclosing navigation
|
|
96
|
+
* view (pop_shortcut_cb:1150-1152).
|
|
97
|
+
*/
|
|
98
|
+
export type NavigationShortcutResult = 'stop' | 'propagate';
|
|
99
|
+
/** Construction defaults + the diagnostic seam. */
|
|
100
|
+
export interface NavigationViewOptions {
|
|
101
|
+
/** `AdwNavigationView:animate-transitions`, default `true` (init:2142). */
|
|
102
|
+
animateTransitions?: boolean;
|
|
103
|
+
/** `AdwNavigationView:pop-on-escape`, default `true` (init:2143). */
|
|
104
|
+
popOnEscape?: boolean;
|
|
105
|
+
/** Where rejected mutations are reported. Unset = silent. */
|
|
106
|
+
onDiagnostic?: NavigationDiagnosticListener;
|
|
107
|
+
}
|
|
108
|
+
/** The default back-button tooltip when the previous page has no title. */
|
|
109
|
+
export declare const BACK_BUTTON_FALLBACK_TOOLTIP = "Back";
|
|
110
|
+
/** The `g_critical` message libadwaita prints for `diagnostic` — kept verbatim. */
|
|
111
|
+
export declare function describeNavigationDiagnostic(diagnostic: NavigationDiagnostic): string;
|
|
112
|
+
/**
|
|
113
|
+
* The whole `Adw.NavigationView` machine, headless.
|
|
114
|
+
*
|
|
115
|
+
* A renderer registers its page handles ({@link add} / {@link push}), drives the
|
|
116
|
+
* mutators, and reacts to one {@link NavigationStackChange} per mutation. It keeps
|
|
117
|
+
* ZERO navigation state of its own — the stack, the tag index, the
|
|
118
|
+
* static-vs-dynamic ownership and the deferred-destroy queue all live here.
|
|
119
|
+
*/
|
|
120
|
+
export declare class NavigationViewState<P = unknown> {
|
|
121
|
+
private readonly _registry;
|
|
122
|
+
private readonly _tags;
|
|
123
|
+
private readonly _stack;
|
|
124
|
+
private readonly _listeners;
|
|
125
|
+
private readonly _onDiagnostic;
|
|
126
|
+
private _animateTransitions;
|
|
127
|
+
private _popOnEscape;
|
|
128
|
+
/** The outgoing page owed a destroy once the transition ends (C's `hiding_page`). */
|
|
129
|
+
private _pendingRemoval;
|
|
130
|
+
constructor(options?: NavigationViewOptions);
|
|
131
|
+
/** Subscribe to stack changes. Returns an unsubscribe function. */
|
|
132
|
+
subscribe(listener: NavigationStackListener<P>): () => void;
|
|
133
|
+
/** The navigation stack, bottom-first. A snapshot — mutating it does nothing. */
|
|
134
|
+
get stack(): readonly P[];
|
|
135
|
+
/** Number of pages on the stack. */
|
|
136
|
+
get depth(): number;
|
|
137
|
+
/** Every registered page (static + dynamically pushed), in registration order. */
|
|
138
|
+
get pages(): readonly P[];
|
|
139
|
+
/** The top of the stack, or `null` when the stack is empty (get_visible_page:3165). */
|
|
140
|
+
get visiblePage(): P | null;
|
|
141
|
+
/** The visible page's tag, or `null` — never `''` for an untagged page (get_visible_page_tag:3195). */
|
|
142
|
+
get visiblePageTag(): string | null;
|
|
143
|
+
/** Whether push/pop transitions animate. */
|
|
144
|
+
get animateTransitions(): boolean;
|
|
145
|
+
/** Whether Escape pops the visible page. */
|
|
146
|
+
get popOnEscape(): boolean;
|
|
147
|
+
/** Set `animate-transitions`. Returns whether it changed. */
|
|
148
|
+
setAnimateTransitions(value: boolean): boolean;
|
|
149
|
+
/** Set `pop-on-escape`. Returns whether it changed. */
|
|
150
|
+
setPopOnEscape(value: boolean): boolean;
|
|
151
|
+
/** Whether `page` is known to this view. */
|
|
152
|
+
isRegistered(page: P): boolean;
|
|
153
|
+
/** Whether `page` currently sits on the navigation stack. */
|
|
154
|
+
isInStack(page: P): boolean;
|
|
155
|
+
/** Whether `page` is a DYNAMIC page — pushed but never added, so destroyed when popped. */
|
|
156
|
+
isRemoveOnPop(page: P): boolean;
|
|
157
|
+
/** `page`'s tag, or `null` (also `null` for an unregistered page). */
|
|
158
|
+
tagOf(page: P): string | null;
|
|
159
|
+
/** `page`'s title. `''` when untitled or unregistered — the C title is never NULL. */
|
|
160
|
+
titleOf(page: P): string;
|
|
161
|
+
/** `page`'s `can-pop`. `true` for an unregistered page, matching the property default. */
|
|
162
|
+
canPopOf(page: P): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* The page with this tag, or `null` (find_page:2774).
|
|
165
|
+
*
|
|
166
|
+
* Byte-exact: the C table is `g_str_hash`/`g_str_equal`, so NFC and NFD
|
|
167
|
+
* spellings of the same word are DIFFERENT keys and `''` is a valid one.
|
|
168
|
+
* Dynamically-pushed pages are found too — `maybe_add_page` routes through
|
|
169
|
+
* `add_page`, which indexes the tag (:1281-1282).
|
|
170
|
+
*/
|
|
171
|
+
findPage(tag: string): P | null;
|
|
172
|
+
/**
|
|
173
|
+
* The page popping `page` would reveal (get_previous_page:3228) — `null` when
|
|
174
|
+
* `page` is the root page or is not on the stack.
|
|
175
|
+
*/
|
|
176
|
+
getPreviousPage(page: P): P | null;
|
|
177
|
+
/**
|
|
178
|
+
* Permanently add `page` (adw_navigation_view_add:2719). A page added this way
|
|
179
|
+
* survives being popped.
|
|
180
|
+
*
|
|
181
|
+
* Two rules that were missing from the renderers:
|
|
182
|
+
* 1. Adding a page that is on the stack as a DYNAMIC page converts it to a
|
|
183
|
+
* permanent one and does nothing else (:2725-2730) — the stack does not
|
|
184
|
+
* move and no change is emitted.
|
|
185
|
+
* 2. The auto-push fires whenever the stack is EMPTY, not only for the very
|
|
186
|
+
* first page ever added (add_page:1284) — so `add()` after `replace([])`
|
|
187
|
+
* pushes again.
|
|
188
|
+
*
|
|
189
|
+
* Returns `false` (with a `duplicate-tag` diagnostic) when the tag collides.
|
|
190
|
+
*/
|
|
191
|
+
add(page: P, props?: AdwNavigationPageProps): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Remove `page` (adw_navigation_view_remove:2750 → remove_page:1312).
|
|
194
|
+
*
|
|
195
|
+
* If the page is on the stack the removal is DEFERRED: the page is marked
|
|
196
|
+
* remove-on-pop and destroyed when it is popped (:1323-1326). Otherwise it is
|
|
197
|
+
* unregistered immediately and its tag freed. Returns `false` only for a page
|
|
198
|
+
* this view does not know.
|
|
199
|
+
*/
|
|
200
|
+
remove(page: P): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Set `page`'s tag (adw_navigation_page_set_tag:2437). Silent no-op when
|
|
203
|
+
* unchanged (:2448); rejected with `duplicate-tag` when another page already
|
|
204
|
+
* owns the tag, in which case the OLD tag is kept (:2456-2460).
|
|
205
|
+
*/
|
|
206
|
+
setTag(page: P, tag: string | null): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Set `page`'s title (adw_navigation_page_set_title:2508). Drives the header-bar
|
|
209
|
+
* title and the NEXT page's back-button tooltip. `null`/`undefined` is rejected
|
|
210
|
+
* — the C has `g_return_if_fail (title != NULL)` (:2514).
|
|
211
|
+
*/
|
|
212
|
+
setTitle(page: P, title: string): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Set `page`'s `can-pop` (adw_navigation_page_set_can_pop:2569). Gates
|
|
215
|
+
* shortcuts, gestures and the back button — deliberately NOT {@link pop}.
|
|
216
|
+
*/
|
|
217
|
+
setCanPop(page: P, canPop: boolean): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Push `page` onto the stack (adw_navigation_view_push:2800).
|
|
220
|
+
*
|
|
221
|
+
* A page the view has never seen is registered as DYNAMIC (destroyed when
|
|
222
|
+
* popped, maybe_add_page:1307-1308); an already-registered one keeps its
|
|
223
|
+
* permanence, because maybe_add_page returns early for it (:1296-1297). That
|
|
224
|
+
* asymmetry is why a static page survives a push/pop round trip.
|
|
225
|
+
*
|
|
226
|
+
* Returns `false` with `already-in-stack` when the page is already on the
|
|
227
|
+
* stack (push_to_stack:942-952), or with `duplicate-tag` when its tag collides.
|
|
228
|
+
*/
|
|
229
|
+
push(page: P, props?: AdwNavigationPageProps): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Push the page carrying `tag` (adw_navigation_view_push_by_tag:2829). An
|
|
232
|
+
* unknown tag is rejected with `tag-not-found` and changes nothing.
|
|
233
|
+
*/
|
|
234
|
+
pushByTag(tag: string): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Pop the visible page (adw_navigation_view_pop:2869). `false` when there is
|
|
237
|
+
* no visible page or no page beneath it.
|
|
238
|
+
*
|
|
239
|
+
* Deliberately IGNORES `can-pop`: the C function contains no such test and the
|
|
240
|
+
* property docs say so in as many words — "Manually calling
|
|
241
|
+
* [method@NavigationView.pop] […] will still work" (:2560-2561). Use
|
|
242
|
+
* {@link popFromShortcut} for the gated path.
|
|
243
|
+
*/
|
|
244
|
+
pop(): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Pop until `page` is visible (adw_navigation_view_pop_to_page:2913) — ONE
|
|
247
|
+
* atomic splice, so ONE visible-page notification carrying every popped page,
|
|
248
|
+
* not N sequential pops. Ignores `can-pop` on the pages it passes.
|
|
249
|
+
*
|
|
250
|
+
* `false` (silently) when `page` is already visible; `false` with
|
|
251
|
+
* `not-in-stack` when it is off-stack.
|
|
252
|
+
*/
|
|
253
|
+
popToPage(page: P): boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Pop until the page carrying `tag` is visible (adw_navigation_view_pop_to_tag:2958).
|
|
256
|
+
* An unknown tag yields `tag-not-found`; a known but off-stack one yields
|
|
257
|
+
* `not-in-stack`.
|
|
258
|
+
*/
|
|
259
|
+
popToTag(tag: string): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Replace the whole stack (adw_navigation_view_replace:3002). Never animates
|
|
262
|
+
* (:3075) and emits no `popped` — `::replaced` is its own signal.
|
|
263
|
+
*
|
|
264
|
+
* `null` entries are skipped (:3021, :3052) and a page listed twice is
|
|
265
|
+
* rejected on its second occurrence (:3055-3059). Old DYNAMIC pages are
|
|
266
|
+
* destroyed only when they are absent from the new set (:3033-3034); that
|
|
267
|
+
* guard is what makes replacing the stack with the tag of a pushed page work.
|
|
268
|
+
* An empty array leaves no visible page.
|
|
269
|
+
*
|
|
270
|
+
* `props` supplies registration properties for pages the view has not seen.
|
|
271
|
+
*/
|
|
272
|
+
replace(pages: readonly (P | null)[], props?: NavigationPagePropsResolver<P>): void;
|
|
273
|
+
/**
|
|
274
|
+
* Replace the stack with the pages carrying `tags`
|
|
275
|
+
* (adw_navigation_view_replace_with_tags:3124).
|
|
276
|
+
*
|
|
277
|
+
* Every tag is resolved BEFORE any mutation; an unknown one reports
|
|
278
|
+
* `tag-not-found` and becomes a null slot {@link replace} then skips, rather
|
|
279
|
+
* than aborting the call. Resolving up front is exactly what the web port's
|
|
280
|
+
* `replace()` failed to do.
|
|
281
|
+
*/
|
|
282
|
+
replaceWithTags(tags: readonly string[]): void;
|
|
283
|
+
/**
|
|
284
|
+
* Report that the outgoing transition finished (transition_done_cb:1029-1075),
|
|
285
|
+
* and receive the pages the renderer must now destroy.
|
|
286
|
+
*
|
|
287
|
+
* This is the injected timing seam replacing `AdwAnimation`'s "done" callback.
|
|
288
|
+
* A renderer that does not animate calls it straight after the change — which
|
|
289
|
+
* is precisely what `adw_animation_skip` does in the C when `animate` is FALSE.
|
|
290
|
+
* A page pushed back onto the stack before the transition finished survives,
|
|
291
|
+
* because the C routes this through `adw_navigation_view_remove` and its
|
|
292
|
+
* on-the-stack check (:1042 → remove_page:1323).
|
|
293
|
+
*/
|
|
294
|
+
finishTransition(): readonly P[];
|
|
295
|
+
/**
|
|
296
|
+
* Whether the automatic back button is shown — `get_previous_page(visible) !==
|
|
297
|
+
* null && can_pop(visible)` (adw-back-button.c update_page:84-108). This is the
|
|
298
|
+
* ONLY place `can-pop` decides whether a page can be left.
|
|
299
|
+
*/
|
|
300
|
+
canGoBack(): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* The back button's tooltip: the title of the page the button would reveal,
|
|
303
|
+
* falling back to `fallback` only when that title is empty
|
|
304
|
+
* (adw-back-button.c query_tooltip:399-419). `null` when there is no back
|
|
305
|
+
* button at all.
|
|
306
|
+
*/
|
|
307
|
+
backButtonTooltip(fallback?: string): string | null;
|
|
308
|
+
/**
|
|
309
|
+
* The `can-pop`-aware pop behind Alt+Left and the back mouse button
|
|
310
|
+
* (pop_shortcut_cb:1142-1158).
|
|
311
|
+
*
|
|
312
|
+
* Returns `'stop'` WITHOUT popping when the visible page has `can-pop = FALSE`
|
|
313
|
+
* — deliberately, so the key is not forwarded to an enclosing navigation view.
|
|
314
|
+
*/
|
|
315
|
+
popFromShortcut(): NavigationShortcutResult;
|
|
316
|
+
/** Escape-to-pop: {@link popFromShortcut} gated on `pop-on-escape` (escape_shortcut_cb:1175-1182). */
|
|
317
|
+
popFromEscape(): NavigationShortcutResult;
|
|
318
|
+
private _diagnose;
|
|
319
|
+
private _emit;
|
|
320
|
+
private _emitChange;
|
|
321
|
+
/** `add_page` (:1263) — register, index the tag, and auto-push into an empty stack. */
|
|
322
|
+
private _addPage;
|
|
323
|
+
/** `maybe_add_page` (:1290) — register an unknown page as DYNAMIC; keep a known one as it is. */
|
|
324
|
+
private _maybeAddPage;
|
|
325
|
+
/** `push_to_stack` (:933) — the append plus its already-in-stack guard. */
|
|
326
|
+
private _pushToStack;
|
|
327
|
+
/** `pop_from_stack` (:969) — one splice, one switch, then the per-page destroys. */
|
|
328
|
+
private _popFromStack;
|
|
329
|
+
/**
|
|
330
|
+
* `switch_page` (:824), minus the rendering: flush a still-pending deferred
|
|
331
|
+
* destroy, decide whether this transition animates, and queue the new one.
|
|
332
|
+
*/
|
|
333
|
+
private _beginSwitch;
|
|
334
|
+
/**
|
|
335
|
+
* Settle the deferred destroy owed by the last pop — the shared body of
|
|
336
|
+
* {@link finishTransition} and the mid-transition flush in {@link _beginSwitch}.
|
|
337
|
+
* Both go through `adw_navigation_view_remove` in the C (:1042 / :868), so both
|
|
338
|
+
* inherit `remove_page`'s on-the-stack check: a page pushed BACK before the
|
|
339
|
+
* transition ended survives and is merely re-marked remove-on-pop.
|
|
340
|
+
*/
|
|
341
|
+
private _resolvePendingRemoval;
|
|
342
|
+
private _unregister;
|
|
343
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Padding inside a popover's content box, in px — `popover > contents { padding: 8px }`
|
|
3
|
+
* (_popovers.scss:14).
|
|
4
|
+
*
|
|
5
|
+
* NOT what a MENU popover uses: `popover.menu > contents` re-declares
|
|
6
|
+
* `padding: 0` and moves the inset onto the item box as `$menu_margin` (6px)
|
|
7
|
+
* (_menus.scss:58-66) — two element selectors plus a class, so it wins over the
|
|
8
|
+
* plain `popover > contents` above. Both numbers are real; which one applies is
|
|
9
|
+
* decided by the `.menu` class, not by this constant. See {@link POPOVER_MENU_PADDING}.
|
|
10
|
+
*/
|
|
11
|
+
export declare const POPOVER_PADDING = 8;
|
|
12
|
+
/**
|
|
13
|
+
* Padding around the item box of a MENU popover, in px — `$menu_margin`
|
|
14
|
+
* (_common.scss:11), applied by `popover.menu > contents > … > stack > box`
|
|
15
|
+
* (_menus.scss:61-64) after that same rule zeroes the contents padding.
|
|
16
|
+
*
|
|
17
|
+
* This is the number the three hand-rolled copies actually used (`--spacing-xs`,
|
|
18
|
+
* 6px). They were not wrong about the inset — they were wrong about the radius,
|
|
19
|
+
* and one of them about the shadow.
|
|
20
|
+
*/
|
|
21
|
+
export declare const POPOVER_MENU_PADDING = 6;
|
|
22
|
+
/**
|
|
23
|
+
* Corner radius of a popover surface, in px — `$popover_radius`, defined as
|
|
24
|
+
* `$menu_radius + 6` = `9 + 6` (_common.scss:10,13) and applied at
|
|
25
|
+
* _popovers.scss:15.
|
|
26
|
+
*
|
|
27
|
+
* All three copies got this wrong: two used `--card-radius` (12px, `$card_radius`)
|
|
28
|
+
* and one `--button-radius` (9px, `$button_radius`).
|
|
29
|
+
*/
|
|
30
|
+
export declare const POPOVER_RADIUS = 15;
|
|
31
|
+
/**
|
|
32
|
+
* Corner radius of a menu item row, in px — `$menu_radius` (_common.scss:10),
|
|
33
|
+
* applied by `modelbutton` at _menus.scss:138.
|
|
34
|
+
*/
|
|
35
|
+
export declare const POPOVER_ITEM_RADIUS = 9;
|
|
36
|
+
/** Payload of a {@link PopoverState} change. */
|
|
37
|
+
export interface PopoverStateChange {
|
|
38
|
+
/** Whether the popover is now open. */
|
|
39
|
+
open: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* True for a user gesture ({@link PopoverState.toggle} — the anchor was
|
|
42
|
+
* clicked — or {@link PopoverState.dismiss} — an outside click or Escape);
|
|
43
|
+
* false for a programmatic {@link PopoverState.popup} / {@link PopoverState.popdown}.
|
|
44
|
+
*/
|
|
45
|
+
interactive: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Subscriber for {@link PopoverState} changes. */
|
|
48
|
+
export type PopoverStateListener = (change: PopoverStateChange) => void;
|
|
49
|
+
/**
|
|
50
|
+
* The open/closed state of a popover, with the programmatic-vs-interactive
|
|
51
|
+
* distinction the other core states carry ({@link ComboState}, {@link SpinState},
|
|
52
|
+
* {@link SplitButtonState}): a renderer re-emits `notify::*` only for the
|
|
53
|
+
* interactive changes, so an application calling `popup()` does not look like a
|
|
54
|
+
* user click.
|
|
55
|
+
*
|
|
56
|
+
* NAMING: the state exposes a `open` GETTER, so the mutators cannot also be
|
|
57
|
+
* called `open()`/`close()` — a class cannot carry both under one name. They
|
|
58
|
+
* take GTK's own vocabulary instead ({@link popup} / {@link popdown}, after
|
|
59
|
+
* `adw_split_button_popup()` / `..._popdown()`), which is also what the
|
|
60
|
+
* `<adw-popover>` element exposes. `SplitButtonState` resolved the same clash
|
|
61
|
+
* as `openMenu()`/`closeMenu()`.
|
|
62
|
+
*
|
|
63
|
+
* Idempotent: setting the current value again is a no-op and notifies nobody.
|
|
64
|
+
*/
|
|
65
|
+
export declare class PopoverState {
|
|
66
|
+
private _open;
|
|
67
|
+
private readonly _listeners;
|
|
68
|
+
/** Subscribe to open-state changes. Returns an unsubscribe function. */
|
|
69
|
+
subscribe(listener: PopoverStateListener): () => void;
|
|
70
|
+
private _emit;
|
|
71
|
+
private _setOpen;
|
|
72
|
+
/** Whether the popover is showing. */
|
|
73
|
+
get open(): boolean;
|
|
74
|
+
/** Show the popover programmatically. Returns whether it changed. */
|
|
75
|
+
popup(): boolean;
|
|
76
|
+
/** Hide the popover programmatically. Returns whether it changed. */
|
|
77
|
+
popdown(): boolean;
|
|
78
|
+
/** The anchor was activated by the user; flips open/closed. Returns whether it changed. */
|
|
79
|
+
toggle(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The user dismissed the popover — an outside click, or Escape. Distinct
|
|
82
|
+
* from {@link popdown} only in the `interactive` flag, which is the whole
|
|
83
|
+
* point: a dismissal is a gesture, a `popdown()` call is not.
|
|
84
|
+
*/
|
|
85
|
+
dismiss(): boolean;
|
|
86
|
+
}
|
|
87
|
+
/** What a key press asks the renderer to do. */
|
|
88
|
+
export type PopoverKeyAction =
|
|
89
|
+
/** Dismiss the popover and return focus to the anchor. */
|
|
90
|
+
'close'
|
|
91
|
+
/** Move focus to `index`. */
|
|
92
|
+
| 'focus'
|
|
93
|
+
/** Activate the item at `index` (and let the renderer close + notify). */
|
|
94
|
+
| 'activate'
|
|
95
|
+
/** Not ours — let the key through to whatever owns it. */
|
|
96
|
+
| 'none';
|
|
97
|
+
/** The list state a key press is resolved against. */
|
|
98
|
+
export interface PopoverKeyContext {
|
|
99
|
+
/**
|
|
100
|
+
* How many items are navigable RIGHT NOW. For a filtered list (the drop-down's
|
|
101
|
+
* search) that is the VISIBLE count, not the model length — filtering is the
|
|
102
|
+
* renderer's business, and this function only ever sees the surviving list.
|
|
103
|
+
*/
|
|
104
|
+
itemCount: number;
|
|
105
|
+
/** Focused item's index in that same list; `-1` when focus is elsewhere (the search entry, the surface). */
|
|
106
|
+
currentIndex: number;
|
|
107
|
+
/**
|
|
108
|
+
* Whether a search entry sits atop the popover. It matters only while
|
|
109
|
+
* `currentIndex` is `-1` (i.e. the entry has focus and owns the caret) — see
|
|
110
|
+
* {@link resolvePopoverKey}.
|
|
111
|
+
*/
|
|
112
|
+
hasSearch?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** {@link resolvePopoverKey}'s answer. */
|
|
115
|
+
export interface PopoverKeyResolution {
|
|
116
|
+
/** What to do. */
|
|
117
|
+
action: PopoverKeyAction;
|
|
118
|
+
/** Item index for `focus`/`activate`; `-1` for `close` and `none`. */
|
|
119
|
+
index: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Resolve a key press inside an open popover to a focus/activation move.
|
|
123
|
+
*
|
|
124
|
+
* This is the `(current ± 1 + n) % n` arithmetic `adw-menu-button` and
|
|
125
|
+
* `adw-drop-down` each spelled out, reconciled. Where the two copies differed:
|
|
126
|
+
*
|
|
127
|
+
* - **`ArrowUp` from no focus.** BOTH copies computed `(-1 - 1 + n) % n`, which
|
|
128
|
+
* is `n - 2` — the second-to-LAST item. Reachable in the drop-down on every
|
|
129
|
+
* open with `enable-search`, since it focuses the search entry. Fixed here to
|
|
130
|
+
* `n - 1`: ArrowUp from nothing enters the list at the END, the convention the
|
|
131
|
+
* ARIA menu/listbox patterns describe and the mirror of ArrowDown → `0`.
|
|
132
|
+
* Not verifiable against GTK in this tree — see the caveat below.
|
|
133
|
+
* - **`Enter`/`Space`.** The drop-down activated the focused item; the menu
|
|
134
|
+
* button had no case and leaned on the browser activating a focused `<button>`
|
|
135
|
+
* natively. Reported as `'activate'` for both: a renderer that calls
|
|
136
|
+
* `preventDefault()` and then `.click()` activates exactly once, where relying
|
|
137
|
+
* on the native path makes the behaviour depend on the item's tag.
|
|
138
|
+
* - **`Home`/`End` with a search entry focused.** The drop-down stole them
|
|
139
|
+
* unconditionally, so Home could not move the caret to the start of the query
|
|
140
|
+
* the user was typing. `'none'` here while `hasSearch && currentIndex < 0`.
|
|
141
|
+
* - The `+ n` in `(current + 1 + n) % n` is defensive only — for `current` in
|
|
142
|
+
* `[-1, n)` it is arithmetically identical to `(current + 1) % n`. Not a
|
|
143
|
+
* divergence, just two spellings.
|
|
144
|
+
*
|
|
145
|
+
* NOT VERIFIABLE IN THIS TREE: `refs/gtk` is empty and libadwaita vendors no
|
|
146
|
+
* `adw-popover.c`, so `GtkPopover`'s own `position` / `autohide` / `has-arrow`
|
|
147
|
+
* semantics — and GTK's exact keynav from an unfocused list — cannot be read
|
|
148
|
+
* from source here. The wrap arithmetic below is the reconciliation of our two
|
|
149
|
+
* copies against the ARIA patterns, not a claim about GTK's C.
|
|
150
|
+
*
|
|
151
|
+
* `Tab` is deliberately unhandled (`'none'`): GTK popovers trap focus, and doing
|
|
152
|
+
* that in the DOM is a renderer concern (`inert`, a focus sentinel) with no
|
|
153
|
+
* portable arithmetic to share.
|
|
154
|
+
*/
|
|
155
|
+
export declare function resolvePopoverKey(key: string, context: PopoverKeyContext): PopoverKeyResolution;
|