vira 32.3.0 → 33.0.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/directives/index.d.ts +2 -0
- package/dist/directives/index.js +2 -0
- package/dist/directives/popover.directive.d.ts +29 -0
- package/dist/directives/popover.directive.js +45 -0
- package/dist/directives/tooltip.directive.d.ts +60 -0
- package/dist/directives/tooltip.directive.js +99 -0
- package/dist/elements/color/vira-color-picker.element.d.ts +1 -1
- package/dist/elements/color/vira-color-picker.element.js +17 -15
- package/dist/elements/index.d.ts +5 -5
- package/dist/elements/index.js +5 -5
- package/dist/elements/{pop-up → popover}/vira-menu-item.element.d.ts +4 -4
- package/dist/elements/{pop-up → popover}/vira-menu-item.element.js +3 -3
- package/dist/elements/popover/vira-menu-trigger.element.d.ts +56 -0
- package/dist/elements/{pop-up → popover}/vira-menu-trigger.element.js +19 -30
- package/dist/elements/popover/vira-menu.element.d.ts +35 -0
- package/dist/elements/popover/vira-menu.element.js +262 -0
- package/dist/elements/popover/vira-popover-trigger.element.d.ts +49 -0
- package/dist/elements/popover/vira-popover-trigger.element.js +301 -0
- package/dist/elements/popover/vira-tooltip.element.d.ts +10 -0
- package/dist/elements/popover/vira-tooltip.element.js +176 -0
- package/dist/elements/vira-checkbox.element.d.ts +3 -3
- package/dist/elements/vira-checkbox.element.js +4 -3
- package/dist/elements/vira-date-input.element.d.ts +2 -1
- package/dist/elements/vira-date-input.element.js +3 -2
- package/dist/elements/vira-drawer.element.js +1 -1
- package/dist/elements/vira-dropdown.element.d.ts +29 -12
- package/dist/elements/vira-dropdown.element.js +173 -60
- package/dist/elements/vira-form.element.js +13 -22
- package/dist/elements/vira-input.element.d.ts +2 -1
- package/dist/elements/vira-input.element.js +2 -2
- package/dist/elements/vira-json-form.element.js +40 -36
- package/dist/elements/vira-modal.element.js +1 -1
- package/dist/elements/vira-tabs.element.d.ts +3 -9
- package/dist/elements/vira-tabs.element.js +5 -6
- package/dist/elements/vira-text-area.element.d.ts +2 -1
- package/dist/elements/vira-text-area.element.js +3 -2
- package/dist/elements/vira-theme-switcher.element.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/util/anchored-popover.d.ts +40 -0
- package/dist/util/anchored-popover.js +70 -0
- package/dist/util/index.d.ts +4 -3
- package/dist/util/index.js +4 -3
- package/dist/util/{pop-up-helpers.d.ts → menu-helpers.d.ts} +4 -18
- package/dist/util/{pop-up-helpers.js → menu-helpers.js} +2 -17
- package/dist/util/popover-manager.d.ts +123 -0
- package/dist/util/popover-manager.js +412 -0
- package/dist/util/vira-dropdown-option.d.ts +30 -0
- package/dist/util/vira-dropdown-option.js +8 -0
- package/dist/util/vira-form-fields.d.ts +5 -10
- package/dist/util/vira-form-fields.js +15 -11
- package/dist/util/vira-theme-client.d.ts +1 -1
- package/dist/util/vira-theme-client.js +3 -3
- package/package.json +2 -1
- package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +0 -45
- package/dist/elements/pop-up/vira-menu.element.d.ts +0 -36
- package/dist/elements/pop-up/vira-menu.element.js +0 -88
- package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +0 -109
- package/dist/elements/pop-up/vira-pop-up-trigger.element.js +0 -408
- package/dist/elements/vira-select.element.d.ts +0 -44
- package/dist/elements/vira-select.element.js +0 -418
- package/dist/util/pop-up-manager.d.ts +0 -200
- package/dist/util/pop-up-manager.js +0 -258
- package/dist/util/vira-select-option.d.ts +0 -31
- package/dist/util/vira-select-option.js +0 -8
|
@@ -3,7 +3,7 @@ import { type FullSpaRoute, type GenericTreePaths, type SpaRouter } from 'spa-ro
|
|
|
3
3
|
import { type ViraIconSvg } from '../icons/icon-svg.js';
|
|
4
4
|
import { ViraColorVariant } from '../styles/form-variants.js';
|
|
5
5
|
import { ViraThemeColorName } from '../styles/vira-color-theme-object.js';
|
|
6
|
-
import { type
|
|
6
|
+
import { type PopoverOffset } from './popover/vira-popover-trigger.element.js';
|
|
7
7
|
/**
|
|
8
8
|
* Controls which edge of the tab the selection indicator bar appears on.
|
|
9
9
|
*
|
|
@@ -93,16 +93,10 @@ export declare const ViraTabs: import("element-vir").DeclarativeElementDefinitio
|
|
|
93
93
|
* @default ViraTabsIconLayout.Vertical
|
|
94
94
|
*/
|
|
95
95
|
iconLayout: ViraTabsIconLayout;
|
|
96
|
-
/**
|
|
97
|
-
* Horizontal anchor for the dropdown menu. Only used when tabs overflow into a dropdown.
|
|
98
|
-
*
|
|
99
|
-
* @default HorizontalAnchor.Left
|
|
100
|
-
*/
|
|
101
|
-
menuHorizontalAnchor: HorizontalAnchor;
|
|
102
96
|
/** Whether the dropdown trigger is disabled. Only used when tabs overflow into a dropdown. */
|
|
103
97
|
menuIsDisabled: boolean;
|
|
104
|
-
/** Offset for the dropdown
|
|
105
|
-
|
|
98
|
+
/** Offset for the dropdown popover. Only used when tabs overflow into a dropdown. */
|
|
99
|
+
menuPopoverOffset: Readonly<PopoverOffset>;
|
|
106
100
|
/**
|
|
107
101
|
* Text shown on the overflow "more" trigger when the selected tab is _not_ collapsed into
|
|
108
102
|
* the menu. When the selected tab _is_ collapsed, the trigger shows that tab's label (with
|
|
@@ -13,9 +13,9 @@ import { standaloneThemeColorNames, ViraColorVariant, viraColorVariantToHostClas
|
|
|
13
13
|
import { noNativeFormStyles, noUserSelect, viraDisabledStyles, viraTheme } from '../styles/index.js';
|
|
14
14
|
import { viraThemeByKeys, ViraThemeColorName } from '../styles/vira-color-theme-object.js';
|
|
15
15
|
import { defineViraElement } from '../util/define-vira-element.js';
|
|
16
|
-
import { renderMenuItemEntries } from '../util/
|
|
17
|
-
import { ViraMenuTrigger } from './
|
|
18
|
-
import { ViraMenuCornerStyle } from './
|
|
16
|
+
import { renderMenuItemEntries } from '../util/menu-helpers.js';
|
|
17
|
+
import { ViraMenuTrigger } from './popover/vira-menu-trigger.element.js';
|
|
18
|
+
import { ViraMenuCornerStyle } from './popover/vira-menu.element.js';
|
|
19
19
|
import { ViraBoldText } from './vira-bold-text.element.js';
|
|
20
20
|
import { ViraButton } from './vira-button.element.js';
|
|
21
21
|
import { ViraIcon } from './vira-icon.element.js';
|
|
@@ -786,10 +786,9 @@ export const ViraTabs = defineViraElement()({
|
|
|
786
786
|
? html `
|
|
787
787
|
<div class="tab-more">
|
|
788
788
|
<${ViraMenuTrigger.assign({
|
|
789
|
-
horizontalAnchor: inputs.menuHorizontalAnchor,
|
|
790
789
|
isDisabled: inputs.menuIsDisabled,
|
|
791
|
-
|
|
792
|
-
menuCornerStyle: ViraMenuCornerStyle.
|
|
790
|
+
popoverOffset: inputs.menuPopoverOffset,
|
|
791
|
+
menuCornerStyle: ViraMenuCornerStyle.Round,
|
|
793
792
|
})}>
|
|
794
793
|
<${ViraButton.assign({
|
|
795
794
|
text: selectedIsCollapsed ? selectedTab?.label : overflowLabel,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type HtmlInterpolation } from 'element-vir';
|
|
2
3
|
/**
|
|
3
4
|
* A multi-line text area element with all listeners properly attached. Mirrors the look and feel of
|
|
4
5
|
* {@link ViraInput} but for multi-line text input.
|
|
@@ -9,7 +10,7 @@ import { type PartialWithUndefined } from '@augment-vir/common';
|
|
|
9
10
|
*/
|
|
10
11
|
export declare const ViraTextArea: import("element-vir").DeclarativeElementDefinition<"vira-text-area", PartialWithUndefined<{
|
|
11
12
|
/** A label that is shown above the text area, if provided. */
|
|
12
|
-
label: string;
|
|
13
|
+
label: string | HtmlInterpolation;
|
|
13
14
|
/** If true, applies error styling. */
|
|
14
15
|
hasError: boolean;
|
|
15
16
|
/** Number of visible text rows. Defaults to 4. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
1
2
|
import { randomString } from '@augment-vir/common';
|
|
2
|
-
import { attributes, css, defineElementEvent, html, ifDefined, listen } from 'element-vir';
|
|
3
|
+
import { attributes, css, defineElementEvent, html, ifDefined, listen, } from 'element-vir';
|
|
3
4
|
import { createFocusStyles } from '../styles/focus.js';
|
|
4
5
|
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
5
6
|
import { viraDisabledStyles } from '../styles/index.js';
|
|
@@ -187,7 +188,7 @@ export const ViraTextArea = defineViraElement()({
|
|
|
187
188
|
<span class="text-area-wrapper">
|
|
188
189
|
<textarea
|
|
189
190
|
id=${ifDefined(inputs.label ? state.randomId : undefined)}
|
|
190
|
-
aria-label=${ifDefined(inputs.label || undefined)}
|
|
191
|
+
aria-label=${ifDefined((check.isString(inputs.label) && inputs.label) || undefined)}
|
|
191
192
|
rows=${inputs.rows ?? 4}
|
|
192
193
|
?disabled=${inputs.disabled}
|
|
193
194
|
autocomplete=${ifDefined(inputs.disableBrowserHelps ? 'off' : undefined)}
|
|
@@ -75,21 +75,21 @@ export const ViraThemeSwitcher = defineViraElement()({
|
|
|
75
75
|
const themeClient = inputs.themeClient || state.internalThemeClient || new ViraThemeClient();
|
|
76
76
|
updateState({
|
|
77
77
|
internalThemeClient: themeClient,
|
|
78
|
-
currentTheme: themeClient.
|
|
78
|
+
currentTheme: themeClient.getCurrentTheme(),
|
|
79
79
|
});
|
|
80
80
|
const labels = inputs.labels || defaultThemeLabels;
|
|
81
81
|
return Object.values(ViraThemeSelection).map((theme) => {
|
|
82
82
|
return html `
|
|
83
83
|
<button
|
|
84
84
|
class=${classMap({
|
|
85
|
-
selected: themeClient.
|
|
85
|
+
selected: themeClient.getCurrentTheme() === theme,
|
|
86
86
|
})}
|
|
87
87
|
title=${labels[theme]}
|
|
88
88
|
${listen('click', (event) => {
|
|
89
89
|
event.stopPropagation();
|
|
90
90
|
themeClient.setSelectedTheme(theme);
|
|
91
91
|
updateState({
|
|
92
|
-
currentTheme: themeClient.
|
|
92
|
+
currentTheme: themeClient.getCurrentTheme(),
|
|
93
93
|
});
|
|
94
94
|
})}
|
|
95
95
|
>
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type CSSResult } from 'element-vir';
|
|
3
|
+
/**
|
|
4
|
+
* The class that `PopoverManager` toggles on a popover to make the browser re-run its
|
|
5
|
+
* `position-try-fallbacks` from the first entry.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const anchoredPopoverRetryClass = "retry-position";
|
|
10
|
+
/**
|
|
11
|
+
* A single `position-try-fallbacks` entry for {@link createAnchoredPopoverStyles}.
|
|
12
|
+
*
|
|
13
|
+
* @category Popover
|
|
14
|
+
*/
|
|
15
|
+
export type AnchoredPopoverFallback = {
|
|
16
|
+
/**
|
|
17
|
+
* The `@position-try` rule name, without the leading `--`. Only needs to be unique within the
|
|
18
|
+
* shadow root that the styles are used in.
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
/** Only the properties that `@position-try` rules accept have any effect here. */
|
|
22
|
+
styles: CSSResult;
|
|
23
|
+
} & PartialWithUndefined<{
|
|
24
|
+
/** Adds `flip-block` to this entry, which mirrors it (and its block margins) vertically. */
|
|
25
|
+
flipBlock: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates the shared styles for a `popover` element that is positioned with CSS anchor positioning
|
|
29
|
+
* and opened through `PopoverManager`. Put the popover's default position (such as `position-area`)
|
|
30
|
+
* in a rule _after_ these styles. `fallbacks` are tried in order whenever the default position
|
|
31
|
+
* overflows the viewport.
|
|
32
|
+
*
|
|
33
|
+
* @category Popover
|
|
34
|
+
*/
|
|
35
|
+
export declare function createAnchoredPopoverStyles({ selector, fallbacks, }: Readonly<{
|
|
36
|
+
fallbacks: ReadonlyArray<Readonly<AnchoredPopoverFallback>>;
|
|
37
|
+
} & PartialWithUndefined<{
|
|
38
|
+
/** Selects the popover element. Omit this when the host element itself is the popover. */
|
|
39
|
+
selector: CSSResult | string;
|
|
40
|
+
}>>): CSSResult;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { css, unsafeCSS } from 'element-vir';
|
|
2
|
+
/**
|
|
3
|
+
* The class that `PopoverManager` toggles on a popover to make the browser re-run its
|
|
4
|
+
* `position-try-fallbacks` from the first entry.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export const anchoredPopoverRetryClass = 'retry-position';
|
|
9
|
+
function createFallbackEntry({ name, flipBlock }) {
|
|
10
|
+
return flipBlock ? `--${name} flip-block` : `--${name}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates the shared styles for a `popover` element that is positioned with CSS anchor positioning
|
|
14
|
+
* and opened through `PopoverManager`. Put the popover's default position (such as `position-area`)
|
|
15
|
+
* in a rule _after_ these styles. `fallbacks` are tried in order whenever the default position
|
|
16
|
+
* overflows the viewport.
|
|
17
|
+
*
|
|
18
|
+
* @category Popover
|
|
19
|
+
*/
|
|
20
|
+
export function createAnchoredPopoverStyles({ selector, fallbacks, }) {
|
|
21
|
+
const fallbackEntries = fallbacks.map((fallback) => createFallbackEntry(fallback));
|
|
22
|
+
const retryClass = unsafeCSS(anchoredPopoverRetryClass);
|
|
23
|
+
return css `
|
|
24
|
+
/*
|
|
25
|
+
Anchored through showPopover({source}).
|
|
26
|
+
*/
|
|
27
|
+
${selector ? unsafeCSS(selector) : unsafeCSS(':host')} {
|
|
28
|
+
/*
|
|
29
|
+
position-anchor is set explicitly because its initial value differs between browsers.
|
|
30
|
+
*/
|
|
31
|
+
position-anchor: auto;
|
|
32
|
+
/* Override the browser's default popover styles. */
|
|
33
|
+
position: fixed;
|
|
34
|
+
inset: auto;
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
border: none;
|
|
38
|
+
height: auto;
|
|
39
|
+
overflow: visible;
|
|
40
|
+
background: none;
|
|
41
|
+
color: inherit;
|
|
42
|
+
|
|
43
|
+
position-try-fallbacks: ${unsafeCSS(fallbackEntries.join(', ') || 'none')};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
Browsers keep using the last position-try-fallbacks entry that fit until it no longer
|
|
48
|
+
fits, even when an earlier entry fits again, so without this the popover would not return
|
|
49
|
+
to its default position after a resize or scroll. Changing the computed
|
|
50
|
+
position-try-fallbacks value is what makes browsers start over from the first entry, so
|
|
51
|
+
this repeats an entry, which does not change the result.
|
|
52
|
+
*/
|
|
53
|
+
${selector
|
|
54
|
+
? css `
|
|
55
|
+
${unsafeCSS(selector)}.${retryClass}
|
|
56
|
+
`
|
|
57
|
+
: unsafeCSS(`:host(.${anchoredPopoverRetryClass})`)} {
|
|
58
|
+
position-try-fallbacks: ${unsafeCSS([
|
|
59
|
+
...fallbackEntries,
|
|
60
|
+
...fallbackEntries.slice(-1),
|
|
61
|
+
].join(', ') || 'none')};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
${unsafeCSS(fallbacks
|
|
65
|
+
.map(({ name, styles }) => {
|
|
66
|
+
return `@position-try --${name} {${styles.cssText}}`;
|
|
67
|
+
})
|
|
68
|
+
.join('\n'))}
|
|
69
|
+
`;
|
|
70
|
+
}
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
export * from './anchored-popover.js';
|
|
1
2
|
export * from './define-table.js';
|
|
2
3
|
export * from './define-vira-element.js';
|
|
3
4
|
export * from './dynamic-element.js';
|
|
5
|
+
export * from './menu-helpers.js';
|
|
4
6
|
export * from './overflow-observer.js';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './pop-up-manager.js';
|
|
7
|
+
export * from './popover-manager.js';
|
|
7
8
|
export * from './shared-text-input-logic.js';
|
|
9
|
+
export * from './vira-dropdown-option.js';
|
|
8
10
|
export * from './vira-form-fields.js';
|
|
9
11
|
export * from './vira-json-schema.js';
|
|
10
|
-
export * from './vira-select-option.js';
|
|
11
12
|
export * from './vira-theme-client.js';
|
package/dist/util/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
export * from './anchored-popover.js';
|
|
1
2
|
export * from './define-table.js';
|
|
2
3
|
export * from './define-vira-element.js';
|
|
3
4
|
export * from './dynamic-element.js';
|
|
5
|
+
export * from './menu-helpers.js';
|
|
4
6
|
export * from './overflow-observer.js';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './pop-up-manager.js';
|
|
7
|
+
export * from './popover-manager.js';
|
|
7
8
|
export * from './shared-text-input-logic.js';
|
|
9
|
+
export * from './vira-dropdown-option.js';
|
|
8
10
|
export * from './vira-form-fields.js';
|
|
9
11
|
export * from './vira-json-schema.js';
|
|
10
|
-
export * from './vira-select-option.js';
|
|
11
12
|
export * from './vira-theme-client.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type MaybePromise, type PartialWithUndefined } from '@augment-vir/common';
|
|
2
2
|
import { type HtmlInterpolation } from 'element-vir';
|
|
3
|
-
import { ViraMenuItem } from '../elements/
|
|
4
|
-
import { type PopUpManager, type PopUpManagerOptions, type ShowPopUpResult } from './pop-up-manager.js';
|
|
3
|
+
import { ViraMenuItem } from '../elements/popover/vira-menu-item.element.js';
|
|
5
4
|
/**
|
|
6
5
|
* Verifies that all items have unique ids.
|
|
7
6
|
*
|
|
@@ -10,23 +9,10 @@ import { type PopUpManager, type PopUpManagerOptions, type ShowPopUpResult } fro
|
|
|
10
9
|
export declare function assertUniqueIdProps(items: ReadonlyArray<Readonly<{
|
|
11
10
|
id: PropertyKey;
|
|
12
11
|
}>>): void;
|
|
13
|
-
/**
|
|
14
|
-
* Handles toggling pop up state for `ViraDropdown`.
|
|
15
|
-
*
|
|
16
|
-
* @category Internal
|
|
17
|
-
*/
|
|
18
|
-
export declare function triggerPopUpState({ open, callback, popUpManager, host, options, }: Readonly<{
|
|
19
|
-
open: boolean;
|
|
20
|
-
popUpManager: PopUpManager;
|
|
21
|
-
host: HTMLElement;
|
|
22
|
-
} & PartialWithUndefined<{
|
|
23
|
-
callback?: ((showPopUpResult: ShowPopUpResult | undefined) => void) | undefined;
|
|
24
|
-
options?: Partial<PopUpManagerOptions> | undefined;
|
|
25
|
-
}>>): void;
|
|
26
12
|
/**
|
|
27
13
|
* A helper type to be used with {@link renderMenuItemEntries}.
|
|
28
14
|
*
|
|
29
|
-
* @category
|
|
15
|
+
* @category Popover
|
|
30
16
|
*/
|
|
31
17
|
export type ViraMenuItemEntry = {
|
|
32
18
|
content: HtmlInterpolation;
|
|
@@ -44,7 +30,7 @@ export type ViraMenuItemEntry = {
|
|
|
44
30
|
/**
|
|
45
31
|
* A callback for menu items getting activated, to be used with {@link renderMenuItemEntries}.
|
|
46
32
|
*
|
|
47
|
-
* @category
|
|
33
|
+
* @category Popover
|
|
48
34
|
*/
|
|
49
35
|
export type MenuItemClickCallback = (params: Readonly<{
|
|
50
36
|
/** The menu item's index in the array. */
|
|
@@ -54,6 +40,6 @@ export type MenuItemClickCallback = (params: Readonly<{
|
|
|
54
40
|
/**
|
|
55
41
|
* A helper for rendering a bunch of menu items.
|
|
56
42
|
*
|
|
57
|
-
* @category
|
|
43
|
+
* @category Popover
|
|
58
44
|
*/
|
|
59
45
|
export declare function renderMenuItemEntries(items: ReadonlyArray<Readonly<ViraMenuItemEntry>>): import("lit-html").HTMLTemplateResult[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { filterMap, joinWithFinalConjunction, } from '@augment-vir/common';
|
|
2
2
|
import { html, listen } from 'element-vir';
|
|
3
|
-
import { ViraMenuItem } from '../elements/
|
|
3
|
+
import { ViraMenuItem } from '../elements/popover/vira-menu-item.element.js';
|
|
4
4
|
/**
|
|
5
5
|
* Verifies that all items have unique ids.
|
|
6
6
|
*
|
|
@@ -21,25 +21,10 @@ export function assertUniqueIdProps(items) {
|
|
|
21
21
|
throw new Error(`Duplicate option ids were given: ${joinWithFinalConjunction(duplicateIds)}`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Handles toggling pop up state for `ViraDropdown`.
|
|
26
|
-
*
|
|
27
|
-
* @category Internal
|
|
28
|
-
*/
|
|
29
|
-
export function triggerPopUpState({ open, callback, popUpManager, host, options, }) {
|
|
30
|
-
if (open) {
|
|
31
|
-
const showPopUpResult = popUpManager.showPopUp(host, options);
|
|
32
|
-
callback?.(showPopUpResult);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
popUpManager.removePopUp();
|
|
36
|
-
callback?.(undefined);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
24
|
/**
|
|
40
25
|
* A helper for rendering a bunch of menu items.
|
|
41
26
|
*
|
|
42
|
-
* @category
|
|
27
|
+
* @category Popover
|
|
43
28
|
*/
|
|
44
29
|
export function renderMenuItemEntries(items) {
|
|
45
30
|
return filterMap(items, (item, index) => {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type AnyDuration } from 'date-vir';
|
|
3
|
+
import { type Coords, type NavController } from 'device-navigation';
|
|
4
|
+
/**
|
|
5
|
+
* Used to prevent popovers from closing when a text input is active.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function isInputLikeElement(element: Element): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether a keyboard click (a click with `detail` of `0`) came from pressing Enter in a text input,
|
|
12
|
+
* which browsers turn into a click on the form's first button.
|
|
13
|
+
*
|
|
14
|
+
* @category Internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function isTextInputActive(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Determines if a mouse event landed on a scrollbar rather than on element content. Scrollbar
|
|
19
|
+
* interactions fire mouse events on the scrolling element itself (or on `<html>` for the page
|
|
20
|
+
* scrollbar), so an outside-click check would otherwise treat dragging a scrollbar as a click away
|
|
21
|
+
* from the popover and dismiss it mid-drag.
|
|
22
|
+
*
|
|
23
|
+
* @category Internal
|
|
24
|
+
*/
|
|
25
|
+
export declare function isMouseEventOnScrollbar(event: Readonly<MouseEvent>): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The interaction on the anchor element that shows and hides a popover.
|
|
28
|
+
*
|
|
29
|
+
* @category Popover
|
|
30
|
+
*/
|
|
31
|
+
export declare enum PopoverTrigger {
|
|
32
|
+
/**
|
|
33
|
+
* Shows the popover shortly after the anchor is hovered or focused and hides it when the anchor
|
|
34
|
+
* is no longer hovered or focused.
|
|
35
|
+
*/
|
|
36
|
+
Hover = "hover",
|
|
37
|
+
/** Toggles the popover when the anchor is clicked. An arrow key opens it. */
|
|
38
|
+
Click = "click",
|
|
39
|
+
/**
|
|
40
|
+
* Toggles the popover as soon as the mouse is pressed on the anchor, so it can be dragged over
|
|
41
|
+
* the popover's contents and released on one of them. Keyboard clicks and arrow keys also
|
|
42
|
+
* work.
|
|
43
|
+
*/
|
|
44
|
+
Mousedown = "mousedown"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for {@link PopoverManager.update}, usually passed through the `popover` directive.
|
|
48
|
+
*
|
|
49
|
+
* @category Popover
|
|
50
|
+
*/
|
|
51
|
+
export type PopoverOptions = {
|
|
52
|
+
/** `true` or `false` force the popover open or closed, ignoring all interactions. */
|
|
53
|
+
trigger: boolean | PopoverTrigger;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the `popover` element to open. Called each time the popover opens, so it may create
|
|
56
|
+
* the element.
|
|
57
|
+
*/
|
|
58
|
+
getPopover: () => HTMLElement;
|
|
59
|
+
} & PartialWithUndefined<{
|
|
60
|
+
/** Called when the user selects an item in the popover through the `NavController`. */
|
|
61
|
+
onNavSelect: (coords: Coords) => void;
|
|
62
|
+
/**
|
|
63
|
+
* How long to wait after the popover is triggered before opening it. Defaults to 300
|
|
64
|
+
* milliseconds for {@link PopoverTrigger.Hover} and no delay for everything else.
|
|
65
|
+
*/
|
|
66
|
+
delay: AnyDuration;
|
|
67
|
+
/** Closes the popover once it has been open this long. By default it stays open. */
|
|
68
|
+
timeout: AnyDuration;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Opens and closes a single `popover` element that is anchored to another element: it opens the
|
|
72
|
+
* popover in response to the anchor's interactions (see {@link PopoverTrigger}) and closes it on
|
|
73
|
+
* Escape, an outside mousedown, or the page going inactive. Style the popover with
|
|
74
|
+
* `createAnchoredPopoverStyles`.
|
|
75
|
+
*
|
|
76
|
+
* @category Popover
|
|
77
|
+
*/
|
|
78
|
+
export declare class PopoverManager {
|
|
79
|
+
/**
|
|
80
|
+
* Enables arrow key navigation within the open popover. Omit this for popovers that have
|
|
81
|
+
* nothing to navigate, like tooltips.
|
|
82
|
+
*/
|
|
83
|
+
readonly navController?: NavController | undefined;
|
|
84
|
+
protected anchor: HTMLElement | undefined;
|
|
85
|
+
protected options: Readonly<PopoverOptions> | undefined;
|
|
86
|
+
/** The most recently opened popover. */
|
|
87
|
+
protected popover: HTMLElement | undefined;
|
|
88
|
+
protected showTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
89
|
+
/** Closes the popover after `options.timeout`. */
|
|
90
|
+
protected hideTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
91
|
+
/** Removes the listeners for the current anchor and `trigger`. */
|
|
92
|
+
protected removeAnchorListeners: (() => void) | undefined;
|
|
93
|
+
/** Removes the global listeners attached while the popover is open. */
|
|
94
|
+
protected removeOpenListeners: (() => void) | undefined;
|
|
95
|
+
constructor(
|
|
96
|
+
/**
|
|
97
|
+
* Enables arrow key navigation within the open popover. Omit this for popovers that have
|
|
98
|
+
* nothing to navigate, like tooltips.
|
|
99
|
+
*/
|
|
100
|
+
navController?: NavController | undefined);
|
|
101
|
+
/** Whether the popover is open. */
|
|
102
|
+
isOpen(): boolean;
|
|
103
|
+
/** Call this each time the anchor or options might have changed. The `popover` directive does. */
|
|
104
|
+
update(anchor: HTMLElement, options: Readonly<PopoverOptions>): void;
|
|
105
|
+
/** Opens or closes the popover when `trigger` is `true` or `false`. */
|
|
106
|
+
applyForcedState(): void;
|
|
107
|
+
/** Opens the popover right away. */
|
|
108
|
+
show(): void;
|
|
109
|
+
/** Closes the popover, unless `trigger` forces it open, and cancels a scheduled show. */
|
|
110
|
+
hide(): void;
|
|
111
|
+
/** Opens the popover after `options.delay`. */
|
|
112
|
+
scheduleShow(): void;
|
|
113
|
+
/** Opens the popover, or closes it (and cancels a delayed open). */
|
|
114
|
+
toggle(): void;
|
|
115
|
+
/** Opens a closed popover when an arrow key is pressed. */
|
|
116
|
+
openOnArrow(event: Readonly<KeyboardEvent>): void;
|
|
117
|
+
/** Closes the popover and removes all listeners. */
|
|
118
|
+
destroy(): void;
|
|
119
|
+
/** Closes the popover even when `trigger` forces it open. */
|
|
120
|
+
close(): void;
|
|
121
|
+
/** Attaches the global listeners that only matter while the popover is open. */
|
|
122
|
+
protected attachOpenListeners(): () => void;
|
|
123
|
+
}
|