vira 26.5.0 → 26.5.1
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/pop-up/vira-menu-item.element.js +10 -11
- package/dist/elements/pop-up/vira-menu-trigger.element.js +7 -0
- package/dist/elements/pop-up/vira-menu.element.js +1 -0
- package/dist/elements/pop-up/vira-pop-up-menu.element.js +1 -2
- package/dist/elements/pop-up/vira-pop-up-trigger.element.js +20 -17
- package/dist/util/pop-up-manager.js +15 -2
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css, html } from 'element-vir';
|
|
2
2
|
import { Check24Icon } from '../../icons/icon-svgs/check-24.icon.js';
|
|
3
3
|
import { noUserSelect } from '../../styles/index.js';
|
|
4
4
|
import { defineViraElement } from '../define-vira-element.js';
|
|
@@ -12,27 +12,33 @@ import { ViraIcon } from '../vira-icon.element.js';
|
|
|
12
12
|
export const ViraMenuItem = defineViraElement()({
|
|
13
13
|
tagName: 'vira-menu-item',
|
|
14
14
|
hostClasses: {
|
|
15
|
-
'vira-menu-item-selected': ({ inputs }) => inputs.selected,
|
|
15
|
+
'vira-menu-item-selected': ({ inputs }) => !inputs.hideCheckIcon && inputs.selected,
|
|
16
16
|
},
|
|
17
17
|
styles: ({ hostClasses }) => css `
|
|
18
18
|
:host {
|
|
19
19
|
display: flex;
|
|
20
20
|
${noUserSelect};
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
max-width: 100%;
|
|
23
|
+
overflow: hidden;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
.item {
|
|
24
27
|
pointer-events: none;
|
|
25
28
|
min-height: 24px;
|
|
26
29
|
display: flex;
|
|
30
|
+
max-width: 100%;
|
|
27
31
|
align-items: center;
|
|
28
32
|
padding: 8px;
|
|
29
33
|
padding-right: 24px;
|
|
30
34
|
padding-left: 0;
|
|
31
35
|
text-align: left;
|
|
36
|
+
box-sizing: border-box;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
${hostClasses['vira-menu-item-selected'].selector} ${ViraIcon} {
|
|
35
40
|
opacity: 1;
|
|
41
|
+
visibility: hidden;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
/*
|
|
@@ -45,18 +51,11 @@ export const ViraMenuItem = defineViraElement()({
|
|
|
45
51
|
margin-right: -2px;
|
|
46
52
|
margin-left: 2px;
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
.include-left-spacing {
|
|
50
|
-
padding-left: 12px;
|
|
51
|
-
padding-right: 12px;
|
|
52
|
-
}
|
|
53
54
|
`,
|
|
54
55
|
render({ inputs }) {
|
|
55
56
|
return html `
|
|
56
|
-
<div class="item
|
|
57
|
-
|
|
58
|
-
<${ViraIcon.assign({ icon: Check24Icon })}></${ViraIcon}>
|
|
59
|
-
`)}
|
|
57
|
+
<div class="item">
|
|
58
|
+
<${ViraIcon.assign({ icon: Check24Icon })}></${ViraIcon}>
|
|
60
59
|
<slot>${inputs.label}</slot>
|
|
61
60
|
</div>
|
|
62
61
|
`;
|
|
@@ -31,6 +31,10 @@ export const ViraMenuTrigger = defineViraElement()({
|
|
|
31
31
|
${ViraPopUpTrigger} {
|
|
32
32
|
width: 100%;
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
.full-width-menu {
|
|
36
|
+
width: 100%;
|
|
37
|
+
}
|
|
34
38
|
`,
|
|
35
39
|
events: {
|
|
36
40
|
itemActivate: defineElementEvent(),
|
|
@@ -96,6 +100,9 @@ export const ViraMenuTrigger = defineViraElement()({
|
|
|
96
100
|
cornerStyle: inputs.menuCornerStyle,
|
|
97
101
|
})}
|
|
98
102
|
slot=${ViraPopUpTrigger.slotNames.popUp}
|
|
103
|
+
class=${classMap({
|
|
104
|
+
'full-width-menu': inputs.horizontalAnchor === HorizontalAnchor.Both,
|
|
105
|
+
})}
|
|
99
106
|
>
|
|
100
107
|
<${ViraMenu.assign({
|
|
101
108
|
items: inputs.items,
|
|
@@ -96,12 +96,15 @@ export const ViraPopUpTrigger = defineViraElement()({
|
|
|
96
96
|
pointer-events: none;
|
|
97
97
|
display: flex;
|
|
98
98
|
flex-direction: column;
|
|
99
|
+
align-items: flex-start;
|
|
100
|
+
overflow: hidden;
|
|
99
101
|
|
|
100
102
|
/* highest possible z-index */
|
|
101
103
|
z-index: 2147483647;
|
|
102
104
|
|
|
103
105
|
& > * {
|
|
104
106
|
pointer-events: auto;
|
|
107
|
+
max-width: 100%;
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
|
|
@@ -188,24 +191,24 @@ export const ViraPopUpTrigger = defineViraElement()({
|
|
|
188
191
|
triggerPopUp({ emitEvent: false, open: true }, undefined);
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
|
-
const
|
|
194
|
+
const leftCss = inputs.horizontalAnchor === HorizontalAnchor.Right && state.showPopUpResult
|
|
192
195
|
? css `
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
196
|
+
left: -${state.showPopUpResult.positions.diff.left}px;
|
|
197
|
+
`
|
|
198
|
+
: css `
|
|
199
|
+
left: ${inputs.popUpOffset?.left || 0}px;
|
|
200
|
+
`;
|
|
201
|
+
const rightCss = state.showPopUpResult && inputs.horizontalAnchor === HorizontalAnchor.Left
|
|
202
|
+
? css `
|
|
203
|
+
right: -${state.showPopUpResult.positions.diff.right}px;
|
|
204
|
+
`
|
|
205
|
+
: css `
|
|
206
|
+
right: ${inputs.popUpOffset?.right || 0}px;
|
|
207
|
+
`;
|
|
208
|
+
const horizontalPositionStyle = css `
|
|
209
|
+
${leftCss}
|
|
210
|
+
${rightCss}
|
|
211
|
+
`;
|
|
209
212
|
/**
|
|
210
213
|
* These styles do _not_ account for window resizing while the menu is open. I decided this
|
|
211
214
|
* was not a major enough problem to tackle. If it becomes major enough in the future,
|
|
@@ -49,8 +49,21 @@ export class PopUpManager {
|
|
|
49
49
|
this.navController = navController;
|
|
50
50
|
this.options = { ...this.options, ...options };
|
|
51
51
|
}
|
|
52
|
-
attachGlobalListeners() {
|
|
52
|
+
attachGlobalListeners(container) {
|
|
53
|
+
let firstFired = false;
|
|
54
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
55
|
+
if (firstFired) {
|
|
56
|
+
this.removePopUp();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
firstFired = true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
resizeObserver.observe(container);
|
|
53
63
|
this.cleanupCallbacks = [
|
|
64
|
+
() => {
|
|
65
|
+
resizeObserver.disconnect();
|
|
66
|
+
},
|
|
54
67
|
listenToPageActivation(false, (isPageActive) => {
|
|
55
68
|
if (!isPageActive) {
|
|
56
69
|
this.removePopUp();
|
|
@@ -167,7 +180,7 @@ export class PopUpManager {
|
|
|
167
180
|
});
|
|
168
181
|
const useUp = diff.top > diff.bottom + currentOptions.verticalDiffThreshold &&
|
|
169
182
|
diff.bottom < currentOptions.minDownSpace;
|
|
170
|
-
this.attachGlobalListeners();
|
|
183
|
+
this.attachGlobalListeners(container);
|
|
171
184
|
return {
|
|
172
185
|
popDown: !useUp,
|
|
173
186
|
positions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "26.5.
|
|
3
|
+
"version": "26.5.1",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"vite-tsconfig-paths": "^5.1.4"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"element-vir": "^26.5.
|
|
70
|
+
"element-vir": "^26.5.1"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">=22"
|