vira 26.13.0 → 27.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/define-vira-element.d.ts +1 -1
- package/dist/elements/index.d.ts +7 -7
- package/dist/elements/index.js +7 -7
- package/dist/elements/{pop-up/pop-up-helpers.d.ts → popover/popover-helpers.d.ts} +6 -6
- package/dist/elements/{pop-up/pop-up-helpers.js → popover/popover-helpers.js} +5 -5
- package/dist/elements/{pop-up → popover}/vira-menu-item.element.d.ts +3 -3
- package/dist/elements/{pop-up → popover}/vira-menu-item.element.js +1 -1
- package/dist/elements/popover/vira-menu-trigger.element.d.ts +41 -0
- package/dist/elements/{pop-up → popover}/vira-menu-trigger.element.js +29 -33
- package/dist/elements/{pop-up → popover}/vira-menu.element.d.ts +3 -3
- package/dist/elements/{pop-up → popover}/vira-menu.element.js +2 -2
- package/dist/elements/popover/vira-popover-menu.element.d.ts +35 -0
- package/dist/elements/{pop-up/vira-pop-up-menu.element.js → popover/vira-popover-menu.element.js} +23 -23
- package/dist/elements/popover/vira-popover-trigger.element.d.ts +67 -0
- package/dist/elements/popover/vira-popover-trigger.element.js +301 -0
- package/dist/elements/vira-bold-text.element.d.ts +1 -1
- package/dist/elements/vira-button.element.d.ts +1 -1
- package/dist/elements/vira-checkbox.element.d.ts +1 -1
- package/dist/elements/vira-collapsible-wrapper.element.d.ts +1 -1
- package/dist/elements/vira-dropdown.element.d.ts +7 -19
- package/dist/elements/vira-dropdown.element.js +8 -10
- package/dist/elements/vira-icon.element.d.ts +1 -1
- package/dist/elements/vira-image.element.d.ts +1 -1
- package/dist/elements/vira-input.element.d.ts +1 -1
- package/dist/elements/vira-input.element.js +17 -8
- package/dist/elements/vira-link.element.d.ts +31 -3
- package/dist/elements/vira-progress.element.d.ts +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +1 -1
- package/dist/util/{pop-up-manager.d.ts → popover-manager.d.ts} +60 -39
- package/dist/util/{pop-up-manager.js → popover-manager.js} +42 -45
- package/package.json +10 -10
- package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +0 -55
- package/dist/elements/pop-up/vira-pop-up-menu.element.d.ts +0 -35
- package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +0 -81
- package/dist/elements/pop-up/vira-pop-up-trigger.element.js +0 -282
- /package/dist/elements/{pop-up/pop-up-menu-item.d.ts → popover/popover-menu-item.d.ts} +0 -0
- /package/dist/elements/{pop-up/pop-up-menu-item.js → popover/popover-menu-item.js} +0 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { assert } from '@augment-vir/assert';
|
|
2
|
+
import { NavController } from 'device-navigation';
|
|
3
|
+
import { css, defineElementEvent, html, listen, onDomRendered, renderIf } from 'element-vir';
|
|
4
|
+
import { viraDisabledStyles } from '../../styles/disabled.js';
|
|
5
|
+
import { createFocusStyles } from '../../styles/focus.js';
|
|
6
|
+
import { noNativeFormStyles } from '../../styles/native-styles.js';
|
|
7
|
+
import { noUserSelect } from '../../styles/user-select.js';
|
|
8
|
+
import { HidePopoverEvent, NavSelectEvent, PopoverManager, } from '../../util/popover-manager.js';
|
|
9
|
+
import { defineViraElement } from '../define-vira-element.js';
|
|
10
|
+
import { triggerPopoverState } from './popover-helpers.js';
|
|
11
|
+
/**
|
|
12
|
+
* Anchor options for popovers.
|
|
13
|
+
*
|
|
14
|
+
* @category Internal
|
|
15
|
+
*/
|
|
16
|
+
export var HorizontalAnchor;
|
|
17
|
+
(function (HorizontalAnchor) {
|
|
18
|
+
/**
|
|
19
|
+
* The left side of the popover will be anchored to the left side of the trigger, allowing the
|
|
20
|
+
* popover to grow on the right side of the trigger.
|
|
21
|
+
*/
|
|
22
|
+
HorizontalAnchor["Left"] = "left";
|
|
23
|
+
/**
|
|
24
|
+
* The Right side of the popover will be anchored to the right side of the trigger, allowing the
|
|
25
|
+
* popover to grow on the left side of the trigger.
|
|
26
|
+
*/
|
|
27
|
+
HorizontalAnchor["Right"] = "right";
|
|
28
|
+
/**
|
|
29
|
+
* Restrict the popover on both sides.
|
|
30
|
+
*
|
|
31
|
+
* This is the default anchor for {@link ViraPopoverTrigger}.
|
|
32
|
+
*/
|
|
33
|
+
HorizontalAnchor["Both"] = "both";
|
|
34
|
+
})(HorizontalAnchor || (HorizontalAnchor = {}));
|
|
35
|
+
/**
|
|
36
|
+
* An element with slots for a popover trigger and popover contents.
|
|
37
|
+
*
|
|
38
|
+
* @category Popover
|
|
39
|
+
* @category Elements
|
|
40
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-popover-trigger
|
|
41
|
+
*/
|
|
42
|
+
export const ViraPopoverTrigger = defineViraElement()({
|
|
43
|
+
tagName: 'vira-popover-trigger',
|
|
44
|
+
state({ host }) {
|
|
45
|
+
return {
|
|
46
|
+
/** `undefined` means the popover is not currently showing. */
|
|
47
|
+
showPopoverResult: undefined,
|
|
48
|
+
popoverManager: new PopoverManager(new NavController(host, { activateOnMouseUp: true })),
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
slotNames: [
|
|
52
|
+
'trigger',
|
|
53
|
+
'popover',
|
|
54
|
+
],
|
|
55
|
+
hostClasses: {
|
|
56
|
+
'vira-popover-trigger-disabled': ({ inputs }) => !!inputs.isDisabled,
|
|
57
|
+
},
|
|
58
|
+
styles: ({ hostClasses }) => css `
|
|
59
|
+
:host {
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
max-width: 100%;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.wrapper {
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
position: relative;
|
|
69
|
+
/* Do not use display:flex. Doing so will break positioning for Firefox and Safari. */
|
|
70
|
+
display: block;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.dropdown-trigger {
|
|
74
|
+
${noNativeFormStyles};
|
|
75
|
+
${noUserSelect};
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
max-width: 100%;
|
|
78
|
+
position: relative;
|
|
79
|
+
flex-grow: 1;
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
anchor-name: --popover-trigger;
|
|
82
|
+
|
|
83
|
+
${createFocusStyles({
|
|
84
|
+
elementBorderSize: 1,
|
|
85
|
+
})}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
${hostClasses['vira-popover-trigger-disabled'].selector} {
|
|
89
|
+
${viraDisabledStyles}
|
|
90
|
+
pointer-events: auto;
|
|
91
|
+
|
|
92
|
+
& .dropdown-wrapper {
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[popover] {
|
|
98
|
+
/* More styles are set internally via JS. */
|
|
99
|
+
|
|
100
|
+
position: absolute;
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
inset: auto;
|
|
103
|
+
display: flex;
|
|
104
|
+
/* Allow menu shadows to overflow. Without this they are hidden. */
|
|
105
|
+
overflow: visible;
|
|
106
|
+
pointer-events: none;
|
|
107
|
+
|
|
108
|
+
> * {
|
|
109
|
+
pointer-events: auto;
|
|
110
|
+
max-width: 100%;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:popover-open {
|
|
115
|
+
${noNativeFormStyles}
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
events: {
|
|
119
|
+
navSelect: defineElementEvent(),
|
|
120
|
+
/**
|
|
121
|
+
* - `undefined` indicates that the popover just closed.
|
|
122
|
+
* - {@link ShowPopoverResult} indicates that the popover just opened.
|
|
123
|
+
*/
|
|
124
|
+
openChange: defineElementEvent(),
|
|
125
|
+
init: defineElementEvent(),
|
|
126
|
+
},
|
|
127
|
+
cleanup({ state, updateState }) {
|
|
128
|
+
updateState({
|
|
129
|
+
showPopoverResult: undefined,
|
|
130
|
+
});
|
|
131
|
+
state.popoverManager.destroy();
|
|
132
|
+
},
|
|
133
|
+
init({ state, updateState, host, inputs, dispatch, events }) {
|
|
134
|
+
/** Refocus the trigger and set the result to `undefined` when the popover closes. */
|
|
135
|
+
state.popoverManager.listen(HidePopoverEvent, () => {
|
|
136
|
+
updateState({
|
|
137
|
+
showPopoverResult: undefined,
|
|
138
|
+
});
|
|
139
|
+
dispatch(new events.openChange(undefined));
|
|
140
|
+
if (!inputs.isDisabled) {
|
|
141
|
+
const dropdownWrapper = host.shadowRoot.querySelector('.dropdown-trigger');
|
|
142
|
+
assert.instanceOf(dropdownWrapper, HTMLButtonElement, 'failed to find dropdown wrapper child');
|
|
143
|
+
dropdownWrapper.focus();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
state.popoverManager.listen(NavSelectEvent, (event) => {
|
|
147
|
+
if (!inputs.keepOpenAfterInteraction) {
|
|
148
|
+
triggerPopoverState({
|
|
149
|
+
open: false,
|
|
150
|
+
callback(showPopoverResult) {
|
|
151
|
+
updateState({
|
|
152
|
+
showPopoverResult,
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
host,
|
|
156
|
+
popoverManager: state.popoverManager,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
dispatch(new events.navSelect(event.detail));
|
|
160
|
+
});
|
|
161
|
+
dispatch(new events.init({
|
|
162
|
+
navController: state.popoverManager.navController,
|
|
163
|
+
popoverManager: state.popoverManager,
|
|
164
|
+
}));
|
|
165
|
+
},
|
|
166
|
+
render({ dispatch, events, state, inputs, updateState, host, slotNames }) {
|
|
167
|
+
function triggerPopover({ emitEvent, open, }, event) {
|
|
168
|
+
if (state.showPopoverResult && inputs.keepOpenAfterInteraction && event) {
|
|
169
|
+
const dropdownTrigger = host.shadowRoot.querySelector('.dropdown-trigger');
|
|
170
|
+
if (dropdownTrigger && !event.composedPath().includes(dropdownTrigger)) {
|
|
171
|
+
/**
|
|
172
|
+
* Prevent closing the popover when `keepOpenAfterInteraction` is turned on and
|
|
173
|
+
* the popover was interacted with.
|
|
174
|
+
*/
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
triggerPopoverState({
|
|
179
|
+
open,
|
|
180
|
+
callback(showPopoverResult) {
|
|
181
|
+
updateState({ showPopoverResult });
|
|
182
|
+
if (emitEvent) {
|
|
183
|
+
dispatch(new events.openChange(showPopoverResult));
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
host,
|
|
187
|
+
popoverManager: state.popoverManager,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (inputs.isDisabled) {
|
|
191
|
+
triggerPopover({ open: false, emitEvent: false }, undefined);
|
|
192
|
+
}
|
|
193
|
+
else if (inputs.z_debug_forceOpenState != undefined) {
|
|
194
|
+
if (!inputs.z_debug_forceOpenState && state.showPopoverResult) {
|
|
195
|
+
triggerPopover({ emitEvent: false, open: false }, undefined);
|
|
196
|
+
}
|
|
197
|
+
else if (inputs.z_debug_forceOpenState && !state.showPopoverResult) {
|
|
198
|
+
triggerPopover({ emitEvent: false, open: true }, undefined);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const horizontalPositionStyle = state.showPopoverResult
|
|
202
|
+
? state.showPopoverResult.popRight
|
|
203
|
+
? css `
|
|
204
|
+
width: ${state.showPopoverResult.positions.diff.rootLeftToContainerRight}px;
|
|
205
|
+
left: anchor(--popover-trigger left);
|
|
206
|
+
align-items: flex-start;
|
|
207
|
+
`
|
|
208
|
+
: css `
|
|
209
|
+
width: ${state.showPopoverResult.positions.diff.rootRightToContainerLeft}px;
|
|
210
|
+
right: anchor(--popover-trigger right);
|
|
211
|
+
/* Fallback for Firefox and Safari that don't yet support anchor() */
|
|
212
|
+
right: ${state.showPopoverResult.positions.diff.right}px;
|
|
213
|
+
align-items: flex-end;
|
|
214
|
+
`
|
|
215
|
+
: css `
|
|
216
|
+
display: none;
|
|
217
|
+
`;
|
|
218
|
+
const verticalPositionStyle = state.showPopoverResult
|
|
219
|
+
? state.showPopoverResult.popDown
|
|
220
|
+
? css `
|
|
221
|
+
top: anchor(--popover-trigger bottom);
|
|
222
|
+
height: ${state.showPopoverResult.positions.diff.bottom}px;
|
|
223
|
+
flex-direction: column;
|
|
224
|
+
`
|
|
225
|
+
: css `
|
|
226
|
+
bottom: anchor(--popover-trigger top);
|
|
227
|
+
height: ${state.showPopoverResult.positions.diff.top}px;
|
|
228
|
+
flex-direction: column-reverse;
|
|
229
|
+
`
|
|
230
|
+
: css `
|
|
231
|
+
display: none;
|
|
232
|
+
`;
|
|
233
|
+
/**
|
|
234
|
+
* These styles do _not_ account for window resizing while the menu is open. I decided this
|
|
235
|
+
* was not a major enough problem to tackle. If it becomes major enough in the future,
|
|
236
|
+
* you'll need to hook into a window _or_ container resize listener inside `PopoverManager`
|
|
237
|
+
* and emit a new `ShowPopoverResult` instance when it changes.
|
|
238
|
+
*
|
|
239
|
+
* Currently, the popover will simply close when the window is resized.
|
|
240
|
+
*/
|
|
241
|
+
const positionerStyles = css `
|
|
242
|
+
${verticalPositionStyle}
|
|
243
|
+
${horizontalPositionStyle}
|
|
244
|
+
`;
|
|
245
|
+
function respondToClick(event) {
|
|
246
|
+
triggerPopover({
|
|
247
|
+
emitEvent: true,
|
|
248
|
+
open: !state.showPopoverResult,
|
|
249
|
+
}, event);
|
|
250
|
+
}
|
|
251
|
+
return html `
|
|
252
|
+
<div class="wrapper">
|
|
253
|
+
<button
|
|
254
|
+
?disabled=${!!inputs.isDisabled}
|
|
255
|
+
class="dropdown-trigger"
|
|
256
|
+
role="listbox"
|
|
257
|
+
aria-expanded=${!!state.showPopoverResult}
|
|
258
|
+
${listen('keydown', (event) => {
|
|
259
|
+
if (!state.showPopoverResult && event.code.startsWith('Arrow')) {
|
|
260
|
+
triggerPopover({ emitEvent: true, open: true }, event);
|
|
261
|
+
}
|
|
262
|
+
})}
|
|
263
|
+
${listen('click', (event) => {
|
|
264
|
+
/**
|
|
265
|
+
* Detail is 0 if it was a keyboard key (like Enter) that triggered this
|
|
266
|
+
* click.
|
|
267
|
+
*/
|
|
268
|
+
if (event.detail === 0) {
|
|
269
|
+
respondToClick(event);
|
|
270
|
+
}
|
|
271
|
+
})}
|
|
272
|
+
${listen('mousedown', (event) => {
|
|
273
|
+
/** Ignore any clicks that aren't the main button. */
|
|
274
|
+
if (event.button === 0) {
|
|
275
|
+
respondToClick(event);
|
|
276
|
+
}
|
|
277
|
+
})}
|
|
278
|
+
>
|
|
279
|
+
<slot name=${slotNames.trigger}></slot>
|
|
280
|
+
</button>
|
|
281
|
+
<div
|
|
282
|
+
popover="manual"
|
|
283
|
+
style=${positionerStyles}
|
|
284
|
+
${onDomRendered((popoverElement) => {
|
|
285
|
+
assert.instanceOf(popoverElement, HTMLElement);
|
|
286
|
+
if (state.showPopoverResult) {
|
|
287
|
+
popoverElement.showPopover();
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
popoverElement.hidePopover();
|
|
291
|
+
}
|
|
292
|
+
})}
|
|
293
|
+
>
|
|
294
|
+
${renderIf(!!state.showPopoverResult, html `
|
|
295
|
+
<slot name=${slotNames.popover}></slot>
|
|
296
|
+
`)}
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
`;
|
|
300
|
+
},
|
|
301
|
+
});
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
export declare const ViraBoldText: import("element-vir").DeclarativeElementDefinition<"vira-bold", {
|
|
7
7
|
bold: boolean;
|
|
8
8
|
text: string;
|
|
9
|
-
}, {}, {}, "vira-bold-bold", "vira-bold-bold-weight", readonly []>;
|
|
9
|
+
}, {}, {}, "vira-bold-bold", "vira-bold-bold-weight", readonly [], readonly []>;
|
|
@@ -28,4 +28,4 @@ export declare const ViraButton: import("element-vir").DeclarativeElementDefinit
|
|
|
28
28
|
* @default false
|
|
29
29
|
*/
|
|
30
30
|
expandToFitIcon: boolean;
|
|
31
|
-
}>, {}, {}, "vira-button-outline-style" | "vira-button-disabled" | "vira-button-expand-to-fit-icon", "vira-button-primary-color" | "vira-button-primary-hover-color" | "vira-button-primary-active-color" | "vira-button-secondary-color" | "vira-button-padding" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color", readonly []>;
|
|
31
|
+
}>, {}, {}, "vira-button-outline-style" | "vira-button-disabled" | "vira-button-expand-to-fit-icon", "vira-button-primary-color" | "vira-button-primary-hover-color" | "vira-button-primary-active-color" | "vira-button-secondary-color" | "vira-button-padding" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color", readonly [], readonly []>;
|
|
@@ -29,4 +29,4 @@ export type ViraCheckboxInputs = PartialWithUndefined<{
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const ViraCheckbox: import("element-vir").DeclarativeElementDefinition<"vira-checkbox", Readonly<ViraCheckboxInputs>, {}, {
|
|
31
31
|
valueChange: import("element-vir").DefineEvent<boolean>;
|
|
32
|
-
}, "vira-checkbox-", "vira-checkbox-", readonly []>;
|
|
32
|
+
}, "vira-checkbox-", "vira-checkbox-", readonly [], readonly []>;
|
|
@@ -11,4 +11,4 @@ export declare const ViraCollapsibleWrapper: import("element-vir").DeclarativeEl
|
|
|
11
11
|
contentHeight: number;
|
|
12
12
|
}, {
|
|
13
13
|
expandChange: import("element-vir").DefineEvent<boolean>;
|
|
14
|
-
}, "vira-collapsible-wrapper-expanded", "vira-collapsible-wrapper-", readonly ["header"]>;
|
|
14
|
+
}, "vira-collapsible-wrapper-expanded", "vira-collapsible-wrapper-", readonly ["header"], readonly []>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
2
|
import { type ViraIconSvg } from '../icons/icon-svg.js';
|
|
3
|
-
import { type
|
|
4
|
-
import { type MenuItem } from './
|
|
5
|
-
import { HorizontalAnchor } from './pop-up/vira-pop-up-trigger.element.js';
|
|
3
|
+
import { type ShowPopoverResult } from '../util/popover-manager.js';
|
|
4
|
+
import { type MenuItem } from './popover/popover-menu-item.js';
|
|
6
5
|
/**
|
|
7
6
|
* Test ids for {@link ViraDropdown}.
|
|
8
7
|
*
|
|
@@ -14,7 +13,7 @@ export declare const viraDropdownTestIds: {
|
|
|
14
13
|
prefix: string;
|
|
15
14
|
};
|
|
16
15
|
/**
|
|
17
|
-
* A dropdown element that uses
|
|
16
|
+
* A dropdown element that uses popover menus.
|
|
18
17
|
*
|
|
19
18
|
* @category Dropdown
|
|
20
19
|
* @category Elements
|
|
@@ -37,21 +36,10 @@ export declare const ViraDropdown: import("element-vir").DeclarativeElementDefin
|
|
|
37
36
|
isDisabled: boolean;
|
|
38
37
|
/** For debugging purposes only. Very bad for actual production code use. */
|
|
39
38
|
z_debug_forceOpenState: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* - `HorizontalAnchor.Left`: dropdown is anchored to the left side of the trigger and the
|
|
42
|
-
* dropdown can grow to the right.
|
|
43
|
-
* - `HorizontalAnchor.Right`: dropdown is anchored to the right side of the trigger and the
|
|
44
|
-
* dropdown can grow to the left.
|
|
45
|
-
* - `HorizontalAnchor.Both`: dropdown is anchored on both sides of the trigger and cannot
|
|
46
|
-
* grow beyond it. (This is the default experience.)
|
|
47
|
-
*
|
|
48
|
-
* @default HorizontalAnchor.Both
|
|
49
|
-
*/
|
|
50
|
-
horizontalAnchor: HorizontalAnchor;
|
|
51
39
|
}>, {
|
|
52
|
-
/** `undefined` means the
|
|
53
|
-
|
|
40
|
+
/** `undefined` means the popover is not currently showing. */
|
|
41
|
+
showPopoverResult: ShowPopoverResult | undefined;
|
|
54
42
|
}, {
|
|
55
43
|
selectedChange: import("element-vir").DefineEvent<PropertyKey[]>;
|
|
56
|
-
openChange: import("element-vir").DefineEvent<
|
|
57
|
-
}, "vira-dropdown-", "vira-dropdown-", readonly []>;
|
|
44
|
+
openChange: import("element-vir").DefineEvent<ShowPopoverResult | undefined>;
|
|
45
|
+
}, "vira-dropdown-", "vira-dropdown-", readonly [], readonly []>;
|
|
@@ -6,8 +6,7 @@ import { viraBorders } from '../styles/border.js';
|
|
|
6
6
|
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
7
7
|
import { noUserSelect, viraAnimationDurations } from '../styles/index.js';
|
|
8
8
|
import { defineViraElement } from './define-vira-element.js';
|
|
9
|
-
import { ViraMenuTrigger } from './
|
|
10
|
-
import { HorizontalAnchor } from './pop-up/vira-pop-up-trigger.element.js';
|
|
9
|
+
import { ViraMenuTrigger } from './popover/vira-menu-trigger.element.js';
|
|
11
10
|
import { ViraIcon } from './vira-icon.element.js';
|
|
12
11
|
/**
|
|
13
12
|
* Test ids for {@link ViraDropdown}.
|
|
@@ -20,7 +19,7 @@ export const viraDropdownTestIds = {
|
|
|
20
19
|
prefix: 'dropdown-prefix',
|
|
21
20
|
};
|
|
22
21
|
/**
|
|
23
|
-
* A dropdown element that uses
|
|
22
|
+
* A dropdown element that uses popover menus.
|
|
24
23
|
*
|
|
25
24
|
* @category Dropdown
|
|
26
25
|
* @category Elements
|
|
@@ -102,8 +101,8 @@ export const ViraDropdown = defineViraElement()({
|
|
|
102
101
|
},
|
|
103
102
|
state() {
|
|
104
103
|
return {
|
|
105
|
-
/** `undefined` means the
|
|
106
|
-
|
|
104
|
+
/** `undefined` means the popover is not currently showing. */
|
|
105
|
+
showPopoverResult: undefined,
|
|
107
106
|
};
|
|
108
107
|
},
|
|
109
108
|
render({ state, inputs, dispatch, events, updateState }) {
|
|
@@ -137,14 +136,13 @@ export const ViraDropdown = defineViraElement()({
|
|
|
137
136
|
isDisabled: inputs.isDisabled,
|
|
138
137
|
isMultiSelect: inputs.isMultiSelect,
|
|
139
138
|
z_debug_forceOpenState: inputs.z_debug_forceOpenState,
|
|
140
|
-
|
|
139
|
+
popoverOffset: {
|
|
141
140
|
vertical: -1,
|
|
142
141
|
right: 24,
|
|
143
142
|
},
|
|
144
|
-
horizontalAnchor: inputs.horizontalAnchor || HorizontalAnchor.Both,
|
|
145
143
|
})}
|
|
146
144
|
${listen(ViraMenuTrigger.events.openChange, (event) => {
|
|
147
|
-
updateState({
|
|
145
|
+
updateState({ showPopoverResult: event.detail });
|
|
148
146
|
dispatch(new events.openChange(event.detail));
|
|
149
147
|
})}
|
|
150
148
|
${listen(ViraMenuTrigger.events.itemActivate, (event) => {
|
|
@@ -153,8 +151,8 @@ export const ViraDropdown = defineViraElement()({
|
|
|
153
151
|
>
|
|
154
152
|
<div
|
|
155
153
|
class="dropdown-trigger ${classMap({
|
|
156
|
-
open: !!state.
|
|
157
|
-
'open-upwards': !state.
|
|
154
|
+
open: !!state.showPopoverResult,
|
|
155
|
+
'open-upwards': !state.showPopoverResult?.popDown,
|
|
158
156
|
})}"
|
|
159
157
|
${testId(viraDropdownTestIds.trigger)}
|
|
160
158
|
>
|
|
@@ -10,4 +10,4 @@ export declare const ViraIcon: import("element-vir").DeclarativeElementDefinitio
|
|
|
10
10
|
icon: Pick<ViraIconSvg, "svgTemplate"> | undefined;
|
|
11
11
|
/** Ignores the given icon's embedded size and causes the <svg> element to fill its parent. */
|
|
12
12
|
fitContainer?: boolean | undefined;
|
|
13
|
-
}, {}, {}, "vira-icon-fit-container", "vira-icon-", readonly []>;
|
|
13
|
+
}, {}, {}, "vira-icon-fit-container", "vira-icon-", readonly [], readonly []>;
|
|
@@ -42,4 +42,4 @@ export declare const ViraImage: import("element-vir").DeclarativeElementDefiniti
|
|
|
42
42
|
}, {
|
|
43
43
|
imageLoad: import("element-vir").DefineEvent<void>;
|
|
44
44
|
imageError: import("element-vir").DefineEvent<unknown>;
|
|
45
|
-
}, "vira-image-height-constrained", "vira-image-", readonly ["loading", "error"]>;
|
|
45
|
+
}, "vira-image-height-constrained", "vira-image-", readonly ["loading", "error"], readonly []>;
|
|
@@ -40,4 +40,4 @@ export declare const ViraInput: import("element-vir").DeclarativeElementDefiniti
|
|
|
40
40
|
* that was blocked out of programmatic "value" property assignments.
|
|
41
41
|
*/
|
|
42
42
|
inputBlocked: import("element-vir").DefineEvent<string>;
|
|
43
|
-
}, "vira-input-disabled" | "vira-input-fit-text" | "vira-input-clear-button-shown", "vira-input-background-color" | "vira-input-placeholder-color" | "vira-input-text-color" | "vira-input-border-color" | "vira-input-text-selection-color" | "vira-input-action-button-color" | "vira-input-clear-button-hover-color" | "vira-input-clear-button-active-color" | "vira-input-show-password-button-hover-color" | "vira-input-show-password-button-active-color" | "vira-input-padding-horizontal" | "vira-input-padding-vertical", readonly []>;
|
|
43
|
+
}, "vira-input-disabled" | "vira-input-fit-text" | "vira-input-clear-button-shown", "vira-input-background-color" | "vira-input-placeholder-color" | "vira-input-text-color" | "vira-input-border-color" | "vira-input-text-selection-color" | "vira-input-action-button-color" | "vira-input-clear-button-hover-color" | "vira-input-clear-button-active-color" | "vira-input-show-password-button-hover-color" | "vira-input-show-password-button-active-color" | "vira-input-padding-horizontal" | "vira-input-padding-vertical", readonly [], readonly []>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertWrap } from '@augment-vir/assert';
|
|
2
|
+
import { extractEventTarget } from '@augment-vir/web';
|
|
2
3
|
import { attributes, css, defineElementEvent, html, ifDefined, listen, nothing, onResize, renderIf, } from 'element-vir';
|
|
3
4
|
import { CloseX24Icon } from '../icons/icon-svgs/close-x-24.icon.js';
|
|
4
5
|
import { EyeClosed24Icon, EyeOpen24Icon } from '../icons/index.js';
|
|
@@ -166,7 +167,7 @@ export const ViraInput = defineViraElement()({
|
|
|
166
167
|
overflow: hidden;
|
|
167
168
|
outline: none;
|
|
168
169
|
|
|
169
|
-
&:focus:focus-visible:not(
|
|
170
|
+
&:focus:focus-visible:not([disabled]) ~ .focus-border {
|
|
170
171
|
${createFocusStyles({
|
|
171
172
|
elementBorderSize: 0,
|
|
172
173
|
noNesting: true,
|
|
@@ -280,10 +281,15 @@ export const ViraInput = defineViraElement()({
|
|
|
280
281
|
return html `
|
|
281
282
|
<span
|
|
282
283
|
class="input-wrapper"
|
|
283
|
-
${listen('
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
284
|
+
${listen('mousedown', (event) => {
|
|
285
|
+
const eventTarget = extractEventTarget(event, HTMLElement, {
|
|
286
|
+
useOriginalTarget: true,
|
|
287
|
+
});
|
|
288
|
+
const inputElement = assertWrap.instanceOf(host.shadowRoot.querySelector('input'), HTMLInputElement);
|
|
289
|
+
if (eventTarget !== inputElement) {
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
inputElement.focus();
|
|
292
|
+
}
|
|
287
293
|
})}
|
|
288
294
|
>
|
|
289
295
|
${iconTemplate}
|
|
@@ -328,10 +334,11 @@ export const ViraInput = defineViraElement()({
|
|
|
328
334
|
<button
|
|
329
335
|
class="clear-x-button"
|
|
330
336
|
title="clear"
|
|
331
|
-
${listen('
|
|
332
|
-
/** Prevent focus of the input. */
|
|
337
|
+
${listen('mousedown', (event) => {
|
|
333
338
|
event.stopImmediatePropagation();
|
|
334
339
|
event.preventDefault();
|
|
340
|
+
})}
|
|
341
|
+
${listen('click', () => {
|
|
335
342
|
dispatch(new events.valueChange(''));
|
|
336
343
|
})}
|
|
337
344
|
>
|
|
@@ -342,10 +349,12 @@ export const ViraInput = defineViraElement()({
|
|
|
342
349
|
<button
|
|
343
350
|
class="show-password-button"
|
|
344
351
|
title="show password"
|
|
345
|
-
${listen('
|
|
352
|
+
${listen('mousedown', (event) => {
|
|
346
353
|
/** Prevent focus of the input. */
|
|
347
354
|
event.stopImmediatePropagation();
|
|
348
355
|
event.preventDefault();
|
|
356
|
+
})}
|
|
357
|
+
${listen('click', () => {
|
|
349
358
|
updateState({ showPassword: !state.showPassword });
|
|
350
359
|
})}
|
|
351
360
|
>
|
|
@@ -19,7 +19,7 @@ export type ViraLinkRoute = Readonly<{
|
|
|
19
19
|
* @category Elements
|
|
20
20
|
* @see https://electrovir.github.io/vira/book/elements/vira-link
|
|
21
21
|
*/
|
|
22
|
-
export declare const ViraLink: import("element-vir").DeclarativeElementDefinition<"vira-link",
|
|
22
|
+
export declare const ViraLink: import("element-vir").DeclarativeElementDefinition<"vira-link", (((Required<Pick<{
|
|
23
23
|
/**
|
|
24
24
|
* A full raw URL link that will navigate the current window away or open a new tab. If this
|
|
25
25
|
* property is provided for the inputs, don't provide a route property.
|
|
@@ -33,7 +33,35 @@ export declare const ViraLink: import("element-vir").DeclarativeElementDefinitio
|
|
|
33
33
|
* is provided for the inputs, don't provide a link property.
|
|
34
34
|
*/
|
|
35
35
|
route: ViraLinkRoute;
|
|
36
|
-
}, "link"
|
|
36
|
+
}, "link">> & Partial<Record<"route", never>>) | (Required<Pick<{
|
|
37
|
+
/**
|
|
38
|
+
* A full raw URL link that will navigate the current window away or open a new tab. If this
|
|
39
|
+
* property is provided for the inputs, don't provide a route property.
|
|
40
|
+
*/
|
|
41
|
+
link: {
|
|
42
|
+
url: string;
|
|
43
|
+
newTab: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A route that'll change that current page without navigating the window. If this property
|
|
47
|
+
* is provided for the inputs, don't provide a link property.
|
|
48
|
+
*/
|
|
49
|
+
route: ViraLinkRoute;
|
|
50
|
+
}, "route">> & Partial<Record<"link", never>>)) & Omit<{
|
|
51
|
+
/**
|
|
52
|
+
* A full raw URL link that will navigate the current window away or open a new tab. If this
|
|
53
|
+
* property is provided for the inputs, don't provide a route property.
|
|
54
|
+
*/
|
|
55
|
+
link: {
|
|
56
|
+
url: string;
|
|
57
|
+
newTab: boolean;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A route that'll change that current page without navigating the window. If this property
|
|
61
|
+
* is provided for the inputs, don't provide a link property.
|
|
62
|
+
*/
|
|
63
|
+
route: ViraLinkRoute;
|
|
64
|
+
}, "link" | "route">) & PartialWithUndefined<{
|
|
37
65
|
/** Styles that will be applied directly to the inner elements. */
|
|
38
66
|
stylePassthrough: Readonly<PartialWithUndefined<{
|
|
39
67
|
a: CSSResult;
|
|
@@ -42,4 +70,4 @@ export declare const ViraLink: import("element-vir").DeclarativeElementDefinitio
|
|
|
42
70
|
attributePassthrough: Readonly<PartialWithUndefined<{
|
|
43
71
|
a: AttributeValues;
|
|
44
72
|
}>>;
|
|
45
|
-
}>, {}, {}, "vira-link-", "vira-link-hover-color", readonly []>;
|
|
73
|
+
}>, {}, {}, "vira-link-", "vira-link-hover-color", readonly [], readonly []>;
|
|
@@ -15,4 +15,4 @@ export declare const ViraProgress: import("element-vir").DeclarativeElementDefin
|
|
|
15
15
|
min: number;
|
|
16
16
|
/** @default 100 */
|
|
17
17
|
max: number;
|
|
18
|
-
}>>, {}, {}, "vira-progress-", "vira-progress-border-radius" | "vira-progress-background-color" | "vira-progress-foreground-color", readonly []>;
|
|
18
|
+
}>>, {}, {}, "vira-progress-", "vira-progress-border-radius" | "vira-progress-background-color" | "vira-progress-foreground-color", readonly [], readonly []>;
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './define-table.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './popover-manager.js';
|
package/dist/util/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './define-table.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './popover-manager.js';
|