vira 26.5.0 → 26.5.2

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.
@@ -1,4 +1,4 @@
1
- import { classMap, css, html, renderIf } from 'element-vir';
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 ${classMap({ 'include-left-spacing': !!inputs.hideCheckIcon })}">
57
- ${renderIf(!inputs.hideCheckIcon, html `
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,
@@ -39,6 +39,7 @@ export const ViraMenu = defineViraElement()({
39
39
  flex-direction: column;
40
40
 
41
41
  width: 100%;
42
+ max-width: 100%;
42
43
  max-height: 100%;
43
44
  overflow-y: auto;
44
45
  z-index: 100;
@@ -43,8 +43,7 @@ export const ViraPopUpMenu = defineViraElement()({
43
43
  styles: ({ hostClasses }) => css `
44
44
  :host {
45
45
  display: flex;
46
-
47
- width: 100%;
46
+ max-width: 100%;
48
47
  max-height: 100%;
49
48
  overflow-y: auto;
50
49
  z-index: 99;
@@ -96,12 +96,19 @@ 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%;
108
+ }
109
+
110
+ &.right-aligned {
111
+ align-items: flex-end;
105
112
  }
106
113
  }
107
114
 
@@ -188,24 +195,24 @@ export const ViraPopUpTrigger = defineViraElement()({
188
195
  triggerPopUp({ emitEvent: false, open: true }, undefined);
189
196
  }
190
197
  }
191
- const horizontalPositionStyle = state.showPopUpResult
198
+ const leftCss = inputs.horizontalAnchor === HorizontalAnchor.Right && state.showPopUpResult
199
+ ? css `
200
+ left: -${state.showPopUpResult.positions.diff.left}px;
201
+ `
202
+ : css `
203
+ left: ${inputs.popUpOffset?.left || 0}px;
204
+ `;
205
+ const rightCss = state.showPopUpResult && inputs.horizontalAnchor === HorizontalAnchor.Left
192
206
  ? css `
193
- ${inputs.horizontalAnchor === HorizontalAnchor.Right
194
- ? css `
195
- left: -${state.showPopUpResult.positions.diff.left}px;
196
- `
197
- : css `
198
- left: ${inputs.popUpOffset?.left || 0}px;
199
- `}
200
- ${inputs.horizontalAnchor === HorizontalAnchor.Left
201
- ? css `
202
- right: -${state.showPopUpResult.positions.diff.right}px;
203
- `
204
- : css `
205
- right: ${inputs.popUpOffset?.right || 0}px;
206
- `}
207
- `
208
- : css ``;
207
+ right: -${state.showPopUpResult.positions.diff.right}px;
208
+ `
209
+ : css `
210
+ right: ${inputs.popUpOffset?.right || 0}px;
211
+ `;
212
+ const horizontalPositionStyle = css `
213
+ ${leftCss}
214
+ ${rightCss}
215
+ `;
209
216
  /**
210
217
  * These styles do _not_ account for window resizing while the menu is open. I decided this
211
218
  * was not a major enough problem to tackle. If it becomes major enough in the future,
@@ -260,7 +267,12 @@ export const ViraPopUpTrigger = defineViraElement()({
260
267
  <div class="dropdown-trigger">
261
268
  <slot name=${slotNames.trigger}></slot>
262
269
  </div>
263
- <div class="pop-up-positioner" style=${positionerStyles}>
270
+ <div
271
+ class="pop-up-positioner ${classMap({
272
+ 'right-aligned': inputs.horizontalAnchor === HorizontalAnchor.Right,
273
+ })}"
274
+ style=${positionerStyles}
275
+ >
264
276
  ${renderIf(!!state.showPopUpResult, html `
265
277
  <slot name=${slotNames.popUp}></slot>
266
278
  `)}
@@ -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.0",
3
+ "version": "26.5.2",
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.0"
70
+ "element-vir": "^26.5.2"
71
71
  },
72
72
  "engines": {
73
73
  "node": ">=22"