vira 22.1.3 → 22.2.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/README.md +1 -1
- package/dist/elements/define-vira-element.d.ts +1 -1
- package/dist/elements/dropdown/dropdown-helpers.d.ts +22 -0
- package/dist/elements/dropdown/dropdown-helpers.js +56 -0
- package/dist/elements/dropdown/dropdown.mock.d.ts +13 -0
- package/dist/elements/dropdown/dropdown.mock.js +18 -0
- package/dist/elements/dropdown/vira-dropdown-item.element.d.ts +16 -0
- package/dist/elements/dropdown/vira-dropdown-item.element.js +63 -0
- package/dist/elements/dropdown/vira-dropdown-options.element.d.ts +16 -0
- package/dist/elements/dropdown/vira-dropdown-options.element.js +100 -0
- package/dist/elements/dropdown/vira-dropdown.element.d.ts +37 -0
- package/dist/elements/dropdown/vira-dropdown.element.js +310 -0
- package/dist/elements/index.d.ts +3 -0
- package/dist/elements/index.js +3 -0
- package/dist/elements/vira-button.element.js +3 -3
- package/dist/elements/vira-collapsible-wrapper.element.d.ts +1 -4
- package/dist/elements/vira-collapsible-wrapper.element.js +3 -6
- package/dist/elements/vira-input.element.d.ts +1 -1
- package/dist/elements/vira-input.element.js +7 -7
- package/dist/icons/icon-svgs/check-24.icon.d.ts +1 -0
- package/dist/icons/icon-svgs/check-24.icon.js +16 -0
- package/dist/icons/icon-svgs/chevron-up-24.icon.d.ts +1 -0
- package/dist/icons/icon-svgs/chevron-up-24.icon.js +23 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles/border.d.ts +3 -0
- package/dist/styles/border.js +4 -0
- package/dist/styles/color.d.ts +1 -1
- package/dist/styles/disabled.js +1 -0
- package/dist/styles/focus.d.ts +2 -2
- package/dist/styles/focus.js +5 -5
- package/dist/styles/form-themes.d.ts +8 -0
- package/dist/styles/form-themes.js +10 -0
- package/dist/styles/index.d.ts +3 -1
- package/dist/styles/index.js +3 -1
- package/dist/styles/scrollbar.js +4 -2
- package/dist/styles/shadows.d.ts +5 -0
- package/dist/styles/shadows.js +18 -0
- package/dist/styles/user-select.js +6 -3
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/dist/util/pop-up-manager.d.ts +90 -0
- package/dist/util/pop-up-manager.js +169 -0
- package/package.json +12 -8
- package/dist/styles/vira-css-vars.d.ts +0 -3
- package/dist/styles/vira-css-vars.js +0 -4
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { findOverflowParent } from '@augment-vir/browser';
|
|
2
|
+
import { mapObjectValues } from '@augment-vir/common';
|
|
3
|
+
import { NavController, NavDirection } from 'device-navigation';
|
|
4
|
+
import { listenToPageActivation } from 'page-active';
|
|
5
|
+
import { assertInstanceOf } from 'run-time-assertions';
|
|
6
|
+
import { ListenTarget, defineTypedCustomEvent, defineTypedEvent, listenToGlobal, } from 'typed-event-target';
|
|
7
|
+
export const emptyPositionRect = {
|
|
8
|
+
top: 0,
|
|
9
|
+
left: 0,
|
|
10
|
+
right: 0,
|
|
11
|
+
bottom: 0,
|
|
12
|
+
};
|
|
13
|
+
export class HidePopUpEvent extends defineTypedEvent('hide-pop-up') {
|
|
14
|
+
}
|
|
15
|
+
export class NavSelectEvent extends defineTypedCustomEvent()('nav-select') {
|
|
16
|
+
}
|
|
17
|
+
export class PopUpManager {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
Object.defineProperty(this, "listenTarget", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: new ListenTarget()
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "options", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: {
|
|
30
|
+
minDownSpace: 200,
|
|
31
|
+
verticalDiffThreshold: 20,
|
|
32
|
+
supportNavigation: true,
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "cleanupCallbacks", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: []
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(this, "lastRootElement", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: void 0
|
|
46
|
+
});
|
|
47
|
+
this.options = { ...this.options, ...options };
|
|
48
|
+
}
|
|
49
|
+
attachGlobalListeners(rootElement) {
|
|
50
|
+
const navController = new NavController(rootElement);
|
|
51
|
+
this.cleanupCallbacks = [
|
|
52
|
+
listenToPageActivation(false, (isPageActive) => {
|
|
53
|
+
if (!isPageActive) {
|
|
54
|
+
this.removePopUp();
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
listenToGlobal('mousedown', (event) => {
|
|
58
|
+
if (this.lastRootElement &&
|
|
59
|
+
event.composedPath().includes(this.lastRootElement)) {
|
|
60
|
+
/** Ignore clicks that came from the pop up host itself. */
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.removePopUp();
|
|
64
|
+
}, { passive: true }),
|
|
65
|
+
listenToGlobal('keydown', (event) => {
|
|
66
|
+
const keyCode = event.code;
|
|
67
|
+
if (keyCode === 'Escape') {
|
|
68
|
+
this.removePopUp();
|
|
69
|
+
}
|
|
70
|
+
else if (this.options.supportNavigation) {
|
|
71
|
+
if (keyCode === 'ArrowDown') {
|
|
72
|
+
event.stopImmediatePropagation();
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
navController.navigate({
|
|
75
|
+
direction: NavDirection.Down,
|
|
76
|
+
allowWrapping: false,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else if (keyCode === 'ArrowUp') {
|
|
80
|
+
event.stopImmediatePropagation();
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
navController.navigate({
|
|
83
|
+
direction: NavDirection.Up,
|
|
84
|
+
allowWrapping: false,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else if (keyCode === 'ArrowLeft') {
|
|
88
|
+
event.stopImmediatePropagation();
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
navController.navigate({
|
|
91
|
+
direction: NavDirection.Left,
|
|
92
|
+
allowWrapping: false,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else if (keyCode === 'ArrowRight') {
|
|
96
|
+
event.stopImmediatePropagation();
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
navController.navigate({
|
|
99
|
+
direction: NavDirection.Right,
|
|
100
|
+
allowWrapping: false,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else if (keyCode === 'Enter' || keyCode === 'Return') {
|
|
104
|
+
const currentlyFocused = navController.getCurrentlyFocused();
|
|
105
|
+
if (currentlyFocused) {
|
|
106
|
+
navController.enterInto();
|
|
107
|
+
this.listenTarget.dispatch(new NavSelectEvent({ detail: currentlyFocused.coords }));
|
|
108
|
+
event.stopImmediatePropagation();
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
listen(event, listener, options) {
|
|
117
|
+
return this.listenTarget.listen(event, listener, options);
|
|
118
|
+
}
|
|
119
|
+
removePopUp() {
|
|
120
|
+
this.cleanupCallbacks.forEach((callback) => callback());
|
|
121
|
+
this.listenTarget.dispatch(new HidePopUpEvent());
|
|
122
|
+
}
|
|
123
|
+
showPopUp(rootElement, options) {
|
|
124
|
+
this.lastRootElement = rootElement;
|
|
125
|
+
const currentOptions = { ...this.options, ...options };
|
|
126
|
+
const container = findOverflowParent(rootElement);
|
|
127
|
+
assertInstanceOf(container, HTMLElement);
|
|
128
|
+
const rootRect = rootElement.getBoundingClientRect();
|
|
129
|
+
const containerRect = container.getBoundingClientRect();
|
|
130
|
+
const containerScrollbarWidth = container.offsetWidth - container.clientWidth;
|
|
131
|
+
const containerScrollbarHeight = container.offsetHeight - container.clientHeight;
|
|
132
|
+
const containerPosition = container === document.body
|
|
133
|
+
? {
|
|
134
|
+
top: 0,
|
|
135
|
+
left: 0,
|
|
136
|
+
right: globalThis.innerWidth,
|
|
137
|
+
bottom: globalThis.innerHeight,
|
|
138
|
+
}
|
|
139
|
+
: {
|
|
140
|
+
top: containerRect.top,
|
|
141
|
+
left: containerRect.left,
|
|
142
|
+
right: containerRect.right - containerScrollbarWidth,
|
|
143
|
+
bottom: containerRect.bottom - containerScrollbarHeight,
|
|
144
|
+
};
|
|
145
|
+
const rootPosition = mapObjectValues(emptyPositionRect, (key) => {
|
|
146
|
+
return rootRect[key];
|
|
147
|
+
});
|
|
148
|
+
const diff = mapObjectValues(emptyPositionRect, (key) => {
|
|
149
|
+
const containerDimension = containerPosition[key];
|
|
150
|
+
const hostDimension = rootPosition[key];
|
|
151
|
+
return Math.abs(containerDimension - hostDimension);
|
|
152
|
+
});
|
|
153
|
+
const useUp = diff.top > diff.bottom + currentOptions.verticalDiffThreshold &&
|
|
154
|
+
diff.bottom < currentOptions.minDownSpace;
|
|
155
|
+
this.attachGlobalListeners(rootElement);
|
|
156
|
+
return {
|
|
157
|
+
popDown: !useUp,
|
|
158
|
+
positions: {
|
|
159
|
+
container: containerPosition,
|
|
160
|
+
root: rootPosition,
|
|
161
|
+
diff,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
destroy() {
|
|
166
|
+
this.removePopUp();
|
|
167
|
+
this.listenTarget.destroy();
|
|
168
|
+
}
|
|
169
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "22.1
|
|
3
|
+
"version": "22.2.1",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -32,17 +32,21 @@
|
|
|
32
32
|
"test": "virmator test-web"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@augment-vir/browser": "^
|
|
36
|
-
"@augment-vir/common": "^
|
|
35
|
+
"@augment-vir/browser": "^27.0.0",
|
|
36
|
+
"@augment-vir/common": "^27.0.0",
|
|
37
37
|
"colorjs.io": "^0.5.0",
|
|
38
38
|
"date-vir": "^5.1.4",
|
|
39
|
+
"device-navigation": "^1.0.0",
|
|
39
40
|
"lit-css-vars": "^3.0.9",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
41
|
+
"observavir": "^2.0.0",
|
|
42
|
+
"page-active": "^1.0.0",
|
|
43
|
+
"spa-router-vir": "^4.0.3",
|
|
44
|
+
"type-fest": "^4.17.0",
|
|
45
|
+
"typed-event-target": "^3.4.0"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
|
-
"@augment-vir/browser-testing": "^
|
|
45
|
-
"@augment-vir/node-js": "^
|
|
48
|
+
"@augment-vir/browser-testing": "^27.0.0",
|
|
49
|
+
"@augment-vir/node-js": "^27.0.0",
|
|
46
50
|
"@open-wc/testing": "^4.0.0",
|
|
47
51
|
"@types/chai": "^4.3.14",
|
|
48
52
|
"@types/mocha": "^10.0.6",
|
|
@@ -56,7 +60,7 @@
|
|
|
56
60
|
"markdown-code-example-inserter": "^1.0.0",
|
|
57
61
|
"run-time-assertions": "^1.2.0",
|
|
58
62
|
"typedoc": "^0.25.13",
|
|
59
|
-
"typescript": "5.
|
|
63
|
+
"typescript": "5.3.3",
|
|
60
64
|
"vite": "^4.5.0",
|
|
61
65
|
"vite-tsconfig-paths": "^4.3.2"
|
|
62
66
|
},
|