vira
Version:
A simple and highly versatile design system using element-vir.
110 lines (109 loc) • 4.28 kB
TypeScript
import { type PartialWithUndefined } from '@augment-vir/common';
import { NavController, type Coords } from 'device-navigation';
import { PopUpManager, type ShowPopUpResult } from '../../util/pop-up-manager.js';
/**
* Offsets applied to any menu opened by {@link ViraPopUpTrigger}.
*
* @category Internal
*/
export type PopUpOffset = PartialWithUndefined<{
vertical: number;
right: number;
left: number;
}>;
/**
* Anchor options for pop-ups.
*
* @category Internal
*/
export declare enum HorizontalAnchor {
/**
* The left side of the pop-up will be anchored to the left side of the trigger, allowing the
* pop-up to grow on the right side of the trigger.
*/
Left = "left",
/**
* The Right side of the pop-up will be anchored to the right side of the trigger, allowing the
* pop-up to grow on the left side of the trigger.
*/
Right = "right",
/** Restrict the pop-up on both sides. */
Both = "both",
/**
* Automatically choose left or right based on available space, defaulting to anchoring on the
* left side.
*
* This is the default anchor for {@link ViraPopUpTrigger}.
*/
Auto = "auto"
}
/**
* Configs for {@link ViraPopUpTrigger} pop-up positioning and sizing.
*
* @category Internal
*/
export type PopUpTriggerPosition = {
/**
* - `HorizontalAnchor.Left`: pop-up is anchored to the left side of the trigger and the pop-up
* can grow to the right.
* - `HorizontalAnchor.Right`: pop-up is anchored to the right side of the trigger and the pop-up
* can grow to the left.
* - `HorizontalAnchor.Both`: pop-up is anchored on both sides of the trigger and cannot grow
* beyond it.
* - `HorizontalAnchor.Auto`: automatically choose left or right anchor based on available space,
* defaulting to left anchor. (This is the default experience.)
*
* Note that when `HorizontalAnchor.Both` is _not_ used, this anchor will cancel out any
* `popUpOffset` for the direction _opposite_ of the chosen anchor.
*/
horizontalAnchor: HorizontalAnchor;
/**
* When `true`, the pop-up will not have its maximum width constrained to fit within the
* overflow container. The positioning logic (left/right) will still be applied.
*
* @default false
*/
ignoreMaxWidth: boolean;
/**
* When `true`, the pop-up will not have its maximum height constrained to fit within the
* overflow container. The positioning logic (up/down) will still be applied.
*
* @default false
*/
ignoreMaxHeight: boolean;
};
/**
* An element with slots for a pop-up trigger and pop-up contents.
*
* @category PopUp
* @category Elements
* @see https://electrovir.github.io/vira/book/elements/vira-pop-up-trigger
*/
export declare const ViraPopUpTrigger: import("element-vir").DeclarativeElementDefinition<`vira-${string}`, PartialWithUndefined<PopUpTriggerPosition & {
isDisabled: boolean;
/** For debugging purposes only. Very bad for actual production code use. */
z_debug_forceOpenState: boolean;
/** Set to `true` to keep the pop-up open if it is interacted with. */
keepOpenAfterInteraction: boolean;
/** All values in px. */
popUpOffset: PopUpOffset;
/** If true, the focus outline is moved inside the element. */
useInsideFocus: boolean;
/** When `true`, the trigger will focus itself when the pop-up closes. */
focusOnClose: boolean;
}>, {
/** `undefined` means the pop up is not currently showing. */
showPopUpResult: ShowPopUpResult | undefined;
popUpManager: PopUpManager;
}, {
navSelect: import("element-vir").DefineEvent<Coords>;
/**
* - `undefined` indicates that the pop-up just closed.
* - {@link ShowPopUpResult} indicates that the pop-up just opened.
*/
openChange: import("element-vir").DefineEvent<ShowPopUpResult | undefined>;
init: import("element-vir").DefineEvent<{
navController: NavController;
popUpManager: PopUpManager;
}>;
}, "vira-pop-up-trigger-disabled" | "vira-pop-up-trigger-inside-focus" | "vira-pop-up-trigger-outside-focus", `vira-${string}-`, readonly ["vira-pop-up-trigger-trigger", "vira-pop-up-trigger-pop-up"], readonly []>;