vira 27.0.0 → 28.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/elements/index.d.ts +7 -7
- package/dist/elements/index.js +7 -7
- package/dist/elements/{popover/popover-helpers.d.ts → pop-up/pop-up-helpers.d.ts} +6 -6
- package/dist/elements/{popover/popover-helpers.js → pop-up/pop-up-helpers.js} +5 -5
- package/dist/elements/{popover → pop-up}/vira-menu-item.element.d.ts +2 -2
- package/dist/elements/{popover → pop-up}/vira-menu-item.element.js +1 -1
- package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +55 -0
- package/dist/elements/{popover → pop-up}/vira-menu-trigger.element.js +33 -29
- package/dist/elements/{popover → pop-up}/vira-menu.element.d.ts +2 -2
- package/dist/elements/{popover → pop-up}/vira-menu.element.js +2 -2
- package/dist/elements/pop-up/vira-pop-up-menu.element.d.ts +35 -0
- package/dist/elements/{popover/vira-popover-menu.element.js → pop-up/vira-pop-up-menu.element.js} +23 -23
- package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +81 -0
- package/dist/elements/pop-up/vira-pop-up-trigger.element.js +282 -0
- package/dist/elements/vira-dropdown.element.d.ts +18 -6
- package/dist/elements/vira-dropdown.element.js +10 -8
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +1 -1
- package/dist/util/{popover-manager.d.ts → pop-up-manager.d.ts} +39 -60
- package/dist/util/{popover-manager.js → pop-up-manager.js} +45 -42
- package/package.json +1 -1
- package/dist/elements/popover/vira-menu-trigger.element.d.ts +0 -41
- package/dist/elements/popover/vira-popover-menu.element.d.ts +0 -35
- package/dist/elements/popover/vira-popover-trigger.element.d.ts +0 -67
- package/dist/elements/popover/vira-popover-trigger.element.js +0 -301
- /package/dist/elements/{popover/popover-menu-item.d.ts → pop-up/pop-up-menu-item.d.ts} +0 -0
- /package/dist/elements/{popover/popover-menu-item.js → pop-up/pop-up-menu-item.js} +0 -0
package/dist/elements/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from './define-vira-element.js';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
2
|
+
export * from './pop-up/pop-up-helpers.js';
|
|
3
|
+
export * from './pop-up/pop-up-menu-item.js';
|
|
4
|
+
export * from './pop-up/vira-menu-item.element.js';
|
|
5
|
+
export * from './pop-up/vira-menu-trigger.element.js';
|
|
6
|
+
export * from './pop-up/vira-menu.element.js';
|
|
7
|
+
export * from './pop-up/vira-pop-up-menu.element.js';
|
|
8
|
+
export * from './pop-up/vira-pop-up-trigger.element.js';
|
|
9
9
|
export * from './vira-bold-text.element.js';
|
|
10
10
|
export * from './vira-button.element.js';
|
|
11
11
|
export * from './vira-checkbox.element.js';
|
package/dist/elements/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from './define-vira-element.js';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
2
|
+
export * from './pop-up/pop-up-helpers.js';
|
|
3
|
+
export * from './pop-up/pop-up-menu-item.js';
|
|
4
|
+
export * from './pop-up/vira-menu-item.element.js';
|
|
5
|
+
export * from './pop-up/vira-menu-trigger.element.js';
|
|
6
|
+
export * from './pop-up/vira-menu.element.js';
|
|
7
|
+
export * from './pop-up/vira-pop-up-menu.element.js';
|
|
8
|
+
export * from './pop-up/vira-pop-up-trigger.element.js';
|
|
9
9
|
export * from './vira-bold-text.element.js';
|
|
10
10
|
export * from './vira-button.element.js';
|
|
11
11
|
export * from './vira-checkbox.element.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type MenuItem } from './
|
|
1
|
+
import { type PopUpManager, type ShowPopUpResult } from '../../util/pop-up-manager.js';
|
|
2
|
+
import { type MenuItem } from './pop-up-menu-item.js';
|
|
3
3
|
/**
|
|
4
4
|
* Verifies that all items have unique ids.
|
|
5
5
|
*
|
|
@@ -18,13 +18,13 @@ export declare function updateSelectedItems(
|
|
|
18
18
|
/** The item that should be newly toggled. */
|
|
19
19
|
newItem: Readonly<MenuItem>, currentSelection?: ReadonlyArray<PropertyKey>, isMultiSelect?: boolean): PropertyKey[];
|
|
20
20
|
/**
|
|
21
|
-
* Handles toggling
|
|
21
|
+
* Handles toggling pop up state for `ViraDropdown`.
|
|
22
22
|
*
|
|
23
23
|
* @category Internal
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function triggerPopUpState({ open, callback, popUpManager, host, }: {
|
|
26
26
|
open: boolean;
|
|
27
|
-
|
|
27
|
+
popUpManager: PopUpManager;
|
|
28
28
|
host: HTMLElement;
|
|
29
|
-
callback?: ((
|
|
29
|
+
callback?: ((showPopUpResult: ShowPopUpResult | undefined) => void) | undefined;
|
|
30
30
|
}): void;
|
|
@@ -42,17 +42,17 @@ newItem, currentSelection = [], isMultiSelect = false) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Handles toggling
|
|
45
|
+
* Handles toggling pop up state for `ViraDropdown`.
|
|
46
46
|
*
|
|
47
47
|
* @category Internal
|
|
48
48
|
*/
|
|
49
|
-
export function
|
|
49
|
+
export function triggerPopUpState({ open, callback, popUpManager, host, }) {
|
|
50
50
|
if (open) {
|
|
51
|
-
const
|
|
52
|
-
callback?.(
|
|
51
|
+
const showPopUpResult = popUpManager.showPopUp(host);
|
|
52
|
+
callback?.(showPopUpResult);
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
|
|
55
|
+
popUpManager.removePopUp();
|
|
56
56
|
callback?.(undefined);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
-
import { type MenuItem } from './
|
|
2
|
+
import { type MenuItem } from './pop-up-menu-item.js';
|
|
3
3
|
/**
|
|
4
4
|
* An element for an individual menu item.
|
|
5
5
|
*
|
|
6
|
-
* @category
|
|
6
|
+
* @category PopUp
|
|
7
7
|
* @category Elements
|
|
8
8
|
*/
|
|
9
9
|
export declare const ViraMenuItem: import("element-vir").DeclarativeElementDefinition<"vira-menu-item", Readonly<{
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type NavController } from 'device-navigation';
|
|
3
|
+
import { type PopUpManager, type ShowPopUpResult } from '../../util/pop-up-manager.js';
|
|
4
|
+
import { type MenuItem } from './pop-up-menu-item.js';
|
|
5
|
+
import { type PopUpMenuCornerStyle } from './vira-pop-up-menu.element.js';
|
|
6
|
+
import { HorizontalAnchor, type PopUpOffset } from './vira-pop-up-trigger.element.js';
|
|
7
|
+
/**
|
|
8
|
+
* Test ids for {@link ViraMenuTrigger}.
|
|
9
|
+
*
|
|
10
|
+
* @category Internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const viraMenuTriggerTestIds: {
|
|
13
|
+
menu: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A more specific wrapper of `ViraPopUpTrigger` that always opens a menu.
|
|
17
|
+
*
|
|
18
|
+
* @category PopUp
|
|
19
|
+
* @category Elements
|
|
20
|
+
*/
|
|
21
|
+
export declare const ViraMenuTrigger: import("element-vir").DeclarativeElementDefinition<"vira-menu-trigger", {
|
|
22
|
+
items: ReadonlyArray<Readonly<MenuItem>>;
|
|
23
|
+
} & PartialWithUndefined<{
|
|
24
|
+
/** The selected item ids from the given `items` object. */
|
|
25
|
+
selected: ReadonlyArray<PropertyKey>;
|
|
26
|
+
isDisabled: boolean;
|
|
27
|
+
isMultiSelect: boolean;
|
|
28
|
+
z_debug_forceOpenState: boolean;
|
|
29
|
+
popUpOffset: PopUpOffset;
|
|
30
|
+
/** Hide menu item check mark icons. */
|
|
31
|
+
hideCheckIcons: boolean;
|
|
32
|
+
menuCornerStyle: PopUpMenuCornerStyle;
|
|
33
|
+
/**
|
|
34
|
+
* - `HorizontalAnchor.Left`: pop-up is anchored to the left side of the trigger and the
|
|
35
|
+
* pop-up can grow to the right.
|
|
36
|
+
* - `HorizontalAnchor.Right`: pop-up is anchored to the right side of the trigger and the
|
|
37
|
+
* pop-up can grow to the left.
|
|
38
|
+
* - `HorizontalAnchor.Both`: pop-up is anchored on both sides of the trigger and cannot grow
|
|
39
|
+
* beyond it.
|
|
40
|
+
*
|
|
41
|
+
* Note that when `HorizontalAnchor.Both` is _not_ used, this anchor will cancel out any
|
|
42
|
+
* `popUpOffset` for the direction _opposite_ of the chosen anchor.
|
|
43
|
+
*
|
|
44
|
+
* @default HorizontalAnchor.Left
|
|
45
|
+
*/
|
|
46
|
+
horizontalAnchor: HorizontalAnchor;
|
|
47
|
+
}>, {
|
|
48
|
+
navController: undefined | NavController;
|
|
49
|
+
popUpManager: undefined | PopUpManager;
|
|
50
|
+
/** `undefined` means the pop up is not currently showing. */
|
|
51
|
+
showPopUpResult: ShowPopUpResult | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
itemActivate: import("element-vir").DefineEvent<PropertyKey[]>;
|
|
54
|
+
openChange: import("element-vir").DefineEvent<ShowPopUpResult | undefined>;
|
|
55
|
+
}, "vira-menu-trigger-", "vira-menu-trigger-", readonly [], readonly []>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { classMap, css, defineElementEvent, html, listen, nothing, testId } from 'element-vir';
|
|
2
2
|
import { defineViraElement } from '../define-vira-element.js';
|
|
3
|
-
import { updateSelectedItems } from './
|
|
3
|
+
import { updateSelectedItems } from './pop-up-helpers.js';
|
|
4
4
|
import { ViraMenu } from './vira-menu.element.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { PopUpMenuDirection, ViraPopUpMenu, } from './vira-pop-up-menu.element.js';
|
|
6
|
+
import { HorizontalAnchor, ViraPopUpTrigger, } from './vira-pop-up-trigger.element.js';
|
|
7
7
|
/**
|
|
8
8
|
* Test ids for {@link ViraMenuTrigger}.
|
|
9
9
|
*
|
|
@@ -13,9 +13,9 @@ export const viraMenuTriggerTestIds = {
|
|
|
13
13
|
menu: 'menu-trigger-menu',
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* A more specific wrapper of `
|
|
16
|
+
* A more specific wrapper of `ViraPopUpTrigger` that always opens a menu.
|
|
17
17
|
*
|
|
18
|
-
* @category
|
|
18
|
+
* @category PopUp
|
|
19
19
|
* @category Elements
|
|
20
20
|
*/
|
|
21
21
|
export const ViraMenuTrigger = defineViraElement()({
|
|
@@ -28,7 +28,7 @@ export const ViraMenuTrigger = defineViraElement()({
|
|
|
28
28
|
max-width: 100%;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
${
|
|
31
|
+
${ViraPopUpTrigger} {
|
|
32
32
|
width: 100%;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -43,37 +43,38 @@ export const ViraMenuTrigger = defineViraElement()({
|
|
|
43
43
|
state() {
|
|
44
44
|
return {
|
|
45
45
|
navController: undefined,
|
|
46
|
-
|
|
47
|
-
/** `undefined` means the
|
|
48
|
-
|
|
46
|
+
popUpManager: undefined,
|
|
47
|
+
/** `undefined` means the pop up is not currently showing. */
|
|
48
|
+
showPopUpResult: undefined,
|
|
49
49
|
};
|
|
50
50
|
},
|
|
51
51
|
render({ inputs, state, updateState, dispatch, events }) {
|
|
52
52
|
return html `
|
|
53
|
-
<${
|
|
53
|
+
<${ViraPopUpTrigger.assign({
|
|
54
54
|
isDisabled: inputs.isDisabled,
|
|
55
55
|
keepOpenAfterInteraction: true,
|
|
56
56
|
z_debug_forceOpenState: inputs.z_debug_forceOpenState,
|
|
57
|
-
|
|
57
|
+
popUpOffset: inputs.popUpOffset,
|
|
58
|
+
horizontalAnchor: inputs.horizontalAnchor || HorizontalAnchor.Left,
|
|
58
59
|
})}
|
|
59
60
|
class=${classMap({
|
|
60
|
-
open: !!state.
|
|
61
|
+
open: !!state.showPopUpResult,
|
|
61
62
|
})}
|
|
62
|
-
${listen(
|
|
63
|
+
${listen(ViraPopUpTrigger.events.init, (event) => {
|
|
63
64
|
updateState({
|
|
64
65
|
navController: event.detail.navController,
|
|
65
|
-
|
|
66
|
+
popUpManager: event.detail.popUpManager,
|
|
66
67
|
});
|
|
67
68
|
})}
|
|
68
|
-
${listen(
|
|
69
|
-
if (!!state.
|
|
69
|
+
${listen(ViraPopUpTrigger.events.openChange, (event) => {
|
|
70
|
+
if (!!state.showPopUpResult !== !!event.detail) {
|
|
70
71
|
dispatch(new events.openChange(event.detail));
|
|
71
72
|
}
|
|
72
73
|
updateState({
|
|
73
|
-
|
|
74
|
+
showPopUpResult: event.detail,
|
|
74
75
|
});
|
|
75
76
|
})}
|
|
76
|
-
${listen(
|
|
77
|
+
${listen(ViraPopUpTrigger.events.navSelect, (event) => {
|
|
77
78
|
const itemIndex = event.detail.x;
|
|
78
79
|
const item = inputs.items[itemIndex];
|
|
79
80
|
if (!item) {
|
|
@@ -82,23 +83,26 @@ export const ViraMenuTrigger = defineViraElement()({
|
|
|
82
83
|
dispatch(new events.itemActivate(updateSelectedItems(item, inputs.selected, inputs.isMultiSelect)));
|
|
83
84
|
if (!inputs.isMultiSelect) {
|
|
84
85
|
/**
|
|
85
|
-
* Defer
|
|
86
|
+
* Defer pop up removal to prevent race conditions with element-internal
|
|
86
87
|
* click handlers.
|
|
87
88
|
*/
|
|
88
|
-
globalThis.setTimeout(() => state.
|
|
89
|
+
globalThis.setTimeout(() => state.popUpManager?.removePopUp());
|
|
89
90
|
}
|
|
90
91
|
})}
|
|
91
92
|
>
|
|
92
|
-
<slot slot=${
|
|
93
|
-
${state.navController && state.
|
|
93
|
+
<slot slot=${ViraPopUpTrigger.slotNames.trigger}></slot>
|
|
94
|
+
${state.navController && state.showPopUpResult
|
|
94
95
|
? html `
|
|
95
|
-
<${
|
|
96
|
-
direction: state.
|
|
97
|
-
?
|
|
98
|
-
:
|
|
96
|
+
<${ViraPopUpMenu.assign({
|
|
97
|
+
direction: state.showPopUpResult.popDown
|
|
98
|
+
? PopUpMenuDirection.Downwards
|
|
99
|
+
: PopUpMenuDirection.Upwards,
|
|
99
100
|
cornerStyle: inputs.menuCornerStyle,
|
|
100
101
|
})}
|
|
101
|
-
slot=${
|
|
102
|
+
slot=${ViraPopUpTrigger.slotNames.popUp}
|
|
103
|
+
class=${classMap({
|
|
104
|
+
'full-width-menu': inputs.horizontalAnchor === HorizontalAnchor.Both,
|
|
105
|
+
})}
|
|
102
106
|
>
|
|
103
107
|
<${ViraMenu.assign({
|
|
104
108
|
items: inputs.items,
|
|
@@ -109,10 +113,10 @@ export const ViraMenuTrigger = defineViraElement()({
|
|
|
109
113
|
})}
|
|
110
114
|
${testId(viraMenuTriggerTestIds.menu)}
|
|
111
115
|
></${ViraMenu}>
|
|
112
|
-
</${
|
|
116
|
+
</${ViraPopUpMenu}>
|
|
113
117
|
`
|
|
114
118
|
: nothing}
|
|
115
|
-
</${
|
|
119
|
+
</${ViraPopUpTrigger}>
|
|
116
120
|
`;
|
|
117
121
|
},
|
|
118
122
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
2
|
import { NavController } from 'device-navigation';
|
|
3
|
-
import { type MenuItem } from './
|
|
3
|
+
import { type MenuItem } from './pop-up-menu-item.js';
|
|
4
4
|
/**
|
|
5
5
|
* Test ids for {@link ViraMenu}.
|
|
6
6
|
*
|
|
@@ -14,7 +14,7 @@ export declare const viraMenuTestIds: {
|
|
|
14
14
|
* when items are selected or unselected, pass in a `NavController` instance and hook into its
|
|
15
15
|
* events.
|
|
16
16
|
*
|
|
17
|
-
* @category
|
|
17
|
+
* @category PopUp
|
|
18
18
|
* @category Elements
|
|
19
19
|
*/
|
|
20
20
|
export declare const ViraMenu: import("element-vir").DeclarativeElementDefinition<"vira-menu", Readonly<{
|
|
@@ -5,7 +5,7 @@ import { viraFormCssVars } from '../../styles/form-styles.js';
|
|
|
5
5
|
import { noNativeFormStyles, viraDisabledStyles } from '../../styles/index.js';
|
|
6
6
|
import { defineViraElement } from '../define-vira-element.js';
|
|
7
7
|
import { ViraLink } from '../vira-link.element.js';
|
|
8
|
-
import { assertUniqueIdProps } from './
|
|
8
|
+
import { assertUniqueIdProps } from './pop-up-helpers.js';
|
|
9
9
|
import { ViraMenuItem } from './vira-menu-item.element.js';
|
|
10
10
|
/**
|
|
11
11
|
* Test ids for {@link ViraMenu}.
|
|
@@ -20,7 +20,7 @@ export const viraMenuTestIds = {
|
|
|
20
20
|
* when items are selected or unselected, pass in a `NavController` instance and hook into its
|
|
21
21
|
* events.
|
|
22
22
|
*
|
|
23
|
-
* @category
|
|
23
|
+
* @category PopUp
|
|
24
24
|
* @category Elements
|
|
25
25
|
*/
|
|
26
26
|
export const ViraMenu = defineViraElement()({
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
/**
|
|
3
|
+
* Possible corner styles for {@link ViraPopUpMenu}.
|
|
4
|
+
*
|
|
5
|
+
* @category Internal
|
|
6
|
+
*/
|
|
7
|
+
export declare enum PopUpMenuCornerStyle {
|
|
8
|
+
/** Rounding of corners depends on the open direction of the menu. */
|
|
9
|
+
Directional = "directional",
|
|
10
|
+
/** All of the menus corners should be rounded. */
|
|
11
|
+
AllRounded = "all-rounded",
|
|
12
|
+
/** None of the menus corners should be rounded. */
|
|
13
|
+
AllSquare = "all-square"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Menu pop-up directions available for {@link ViraPopUpMenu}.
|
|
17
|
+
*
|
|
18
|
+
* @category Internal
|
|
19
|
+
*/
|
|
20
|
+
export declare enum PopUpMenuDirection {
|
|
21
|
+
Downwards = "downwards",
|
|
22
|
+
Upwards = "upwards"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A simple default style wrapper for pop-up menus.
|
|
26
|
+
*
|
|
27
|
+
* @category PopUp
|
|
28
|
+
* @category Elements
|
|
29
|
+
*/
|
|
30
|
+
export declare const ViraPopUpMenu: import("element-vir").DeclarativeElementDefinition<"vira-pop-up-menu", PartialWithUndefined<{
|
|
31
|
+
/** @default PopUpMenuDirection.Downwards */
|
|
32
|
+
direction: PopUpMenuDirection;
|
|
33
|
+
/** @default PopUpMenuCornerStyle.Directional */
|
|
34
|
+
cornerStyle: PopUpMenuCornerStyle;
|
|
35
|
+
}>, {}, {}, "vira-pop-up-menu-open-upwards" | "vira-pop-up-menu-rounded" | "vira-pop-up-menu-square", "vira-pop-up-menu-", readonly [], readonly []>;
|
package/dist/elements/{popover/vira-popover-menu.element.js → pop-up/vira-pop-up-menu.element.js}
RENAMED
|
@@ -4,41 +4,41 @@ import { viraFormCssVars } from '../../styles/form-styles.js';
|
|
|
4
4
|
import { viraShadows } from '../../styles/shadows.js';
|
|
5
5
|
import { defineViraElement } from '../define-vira-element.js';
|
|
6
6
|
/**
|
|
7
|
-
* Possible corner styles for {@link
|
|
7
|
+
* Possible corner styles for {@link ViraPopUpMenu}.
|
|
8
8
|
*
|
|
9
9
|
* @category Internal
|
|
10
10
|
*/
|
|
11
|
-
export var
|
|
12
|
-
(function (
|
|
11
|
+
export var PopUpMenuCornerStyle;
|
|
12
|
+
(function (PopUpMenuCornerStyle) {
|
|
13
13
|
/** Rounding of corners depends on the open direction of the menu. */
|
|
14
|
-
|
|
14
|
+
PopUpMenuCornerStyle["Directional"] = "directional";
|
|
15
15
|
/** All of the menus corners should be rounded. */
|
|
16
|
-
|
|
16
|
+
PopUpMenuCornerStyle["AllRounded"] = "all-rounded";
|
|
17
17
|
/** None of the menus corners should be rounded. */
|
|
18
|
-
|
|
19
|
-
})(
|
|
18
|
+
PopUpMenuCornerStyle["AllSquare"] = "all-square";
|
|
19
|
+
})(PopUpMenuCornerStyle || (PopUpMenuCornerStyle = {}));
|
|
20
20
|
/**
|
|
21
|
-
* Menu
|
|
21
|
+
* Menu pop-up directions available for {@link ViraPopUpMenu}.
|
|
22
22
|
*
|
|
23
23
|
* @category Internal
|
|
24
24
|
*/
|
|
25
|
-
export var
|
|
26
|
-
(function (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})(
|
|
25
|
+
export var PopUpMenuDirection;
|
|
26
|
+
(function (PopUpMenuDirection) {
|
|
27
|
+
PopUpMenuDirection["Downwards"] = "downwards";
|
|
28
|
+
PopUpMenuDirection["Upwards"] = "upwards";
|
|
29
|
+
})(PopUpMenuDirection || (PopUpMenuDirection = {}));
|
|
30
30
|
/**
|
|
31
|
-
* A simple default style wrapper for
|
|
31
|
+
* A simple default style wrapper for pop-up menus.
|
|
32
32
|
*
|
|
33
|
-
* @category
|
|
33
|
+
* @category PopUp
|
|
34
34
|
* @category Elements
|
|
35
35
|
*/
|
|
36
|
-
export const
|
|
37
|
-
tagName: 'vira-
|
|
36
|
+
export const ViraPopUpMenu = defineViraElement()({
|
|
37
|
+
tagName: 'vira-pop-up-menu',
|
|
38
38
|
hostClasses: {
|
|
39
|
-
'vira-
|
|
40
|
-
'vira-
|
|
41
|
-
'vira-
|
|
39
|
+
'vira-pop-up-menu-open-upwards': ({ inputs }) => inputs.direction === PopUpMenuDirection.Upwards,
|
|
40
|
+
'vira-pop-up-menu-rounded': ({ inputs }) => inputs.cornerStyle === PopUpMenuCornerStyle.AllRounded,
|
|
41
|
+
'vira-pop-up-menu-square': ({ inputs }) => inputs.cornerStyle === PopUpMenuCornerStyle.AllSquare,
|
|
42
42
|
},
|
|
43
43
|
styles: ({ hostClasses }) => css `
|
|
44
44
|
:host {
|
|
@@ -57,18 +57,18 @@ export const ViraPopoverMenu = defineViraElement()({
|
|
|
57
57
|
${viraShadows.menuShadow}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
${hostClasses['vira-
|
|
60
|
+
${hostClasses['vira-pop-up-menu-open-upwards'].selector} {
|
|
61
61
|
${viraShadows.menuShadowReversed}
|
|
62
62
|
border-radius: ${viraBorders['vira-form-input-radius'].value};
|
|
63
63
|
border-bottom-left-radius: 0;
|
|
64
64
|
border-bottom-right-radius: 0;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
${hostClasses['vira-
|
|
67
|
+
${hostClasses['vira-pop-up-menu-square'].selector} {
|
|
68
68
|
border-radius: 0;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
${hostClasses['vira-
|
|
71
|
+
${hostClasses['vira-pop-up-menu-rounded'].selector} {
|
|
72
72
|
border-radius: ${viraBorders['vira-form-input-radius'].value};
|
|
73
73
|
}
|
|
74
74
|
`,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { NavController, type Coords } from 'device-navigation';
|
|
3
|
+
import { PopUpManager, type ShowPopUpResult } from '../../util/pop-up-manager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Offsets applied to any menu opened by {@link ViraPopUpTrigger}.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export type PopUpOffset = PartialWithUndefined<{
|
|
10
|
+
vertical: number;
|
|
11
|
+
right: number;
|
|
12
|
+
left: number;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Anchor options for pop-ups.
|
|
16
|
+
*
|
|
17
|
+
* @category Internal
|
|
18
|
+
*/
|
|
19
|
+
export declare enum HorizontalAnchor {
|
|
20
|
+
/**
|
|
21
|
+
* The left side of the pop-up will be anchored to the left side of the trigger, allowing the
|
|
22
|
+
* pop-up to grow on the right side of the trigger.
|
|
23
|
+
*/
|
|
24
|
+
Left = "left",
|
|
25
|
+
/**
|
|
26
|
+
* The Right side of the pop-up will be anchored to the right side of the trigger, allowing the
|
|
27
|
+
* pop-up to grow on the left side of the trigger.
|
|
28
|
+
*/
|
|
29
|
+
Right = "right",
|
|
30
|
+
/**
|
|
31
|
+
* Restrict the pop-up on both sides.
|
|
32
|
+
*
|
|
33
|
+
* This is the default anchor for {@link ViraPopUpTrigger}.
|
|
34
|
+
*/
|
|
35
|
+
Both = "both"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* An element with slots for a pop-up trigger and pop-up contents.
|
|
39
|
+
*
|
|
40
|
+
* @category PopUp
|
|
41
|
+
* @category Elements
|
|
42
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-pop-up-trigger
|
|
43
|
+
*/
|
|
44
|
+
export declare const ViraPopUpTrigger: import("element-vir").DeclarativeElementDefinition<"vira-pop-up-trigger", PartialWithUndefined<{
|
|
45
|
+
isDisabled: boolean;
|
|
46
|
+
/** For debugging purposes only. Very bad for actual production code use. */
|
|
47
|
+
z_debug_forceOpenState: boolean;
|
|
48
|
+
/** Set to `true` to keep the pop-up open if it is interacted with. */
|
|
49
|
+
keepOpenAfterInteraction: boolean;
|
|
50
|
+
/** All values in px. */
|
|
51
|
+
popUpOffset?: PopUpOffset;
|
|
52
|
+
/**
|
|
53
|
+
* - `HorizontalAnchor.Left`: pop-up is anchored to the left side of the trigger and the
|
|
54
|
+
* pop-up can grow to the right.
|
|
55
|
+
* - `HorizontalAnchor.Right`: pop-up is anchored to the right side of the trigger and the
|
|
56
|
+
* pop-up can grow to the left.
|
|
57
|
+
* - `HorizontalAnchor.Both`: pop-up is anchored on both sides of the trigger and cannot grow
|
|
58
|
+
* beyond it. (This is the default experience.)
|
|
59
|
+
*
|
|
60
|
+
* Note that when `HorizontalAnchor.Both` is _not_ used, this anchor will cancel out any
|
|
61
|
+
* `popUpOffset` for the direction _opposite_ of the chosen anchor.
|
|
62
|
+
*
|
|
63
|
+
* @default HorizontalAnchor.Both
|
|
64
|
+
*/
|
|
65
|
+
horizontalAnchor?: HorizontalAnchor;
|
|
66
|
+
}>, {
|
|
67
|
+
/** `undefined` means the pop up is not currently showing. */
|
|
68
|
+
showPopUpResult: ShowPopUpResult | undefined;
|
|
69
|
+
popUpManager: PopUpManager;
|
|
70
|
+
}, {
|
|
71
|
+
navSelect: import("element-vir").DefineEvent<Coords>;
|
|
72
|
+
/**
|
|
73
|
+
* - `undefined` indicates that the pop-up just closed.
|
|
74
|
+
* - {@link ShowPopUpResult} indicates that the pop-up just opened.
|
|
75
|
+
*/
|
|
76
|
+
openChange: import("element-vir").DefineEvent<ShowPopUpResult | undefined>;
|
|
77
|
+
init: import("element-vir").DefineEvent<{
|
|
78
|
+
navController: NavController;
|
|
79
|
+
popUpManager: PopUpManager;
|
|
80
|
+
}>;
|
|
81
|
+
}, "vira-pop-up-trigger-disabled", "vira-pop-up-trigger-", readonly ["trigger", "popUp"], readonly []>;
|