vira 28.19.3 → 28.19.5
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,9 +1,10 @@
|
|
|
1
1
|
import { assert } from '@augment-vir/assert';
|
|
2
|
+
import { walkActiveElement } from '@augment-vir/web';
|
|
2
3
|
import { NavController } from 'device-navigation';
|
|
3
4
|
import { classMap, css, defineElementEvent, html, listen, renderIf } from 'element-vir';
|
|
4
5
|
import { createFocusStyles } from '../../styles/focus.js';
|
|
5
6
|
import { noNativeFormStyles, noUserSelect, viraDisabledStyles } from '../../styles/index.js';
|
|
6
|
-
import { HidePopUpEvent, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
|
|
7
|
+
import { HidePopUpEvent, isInputLikeElement, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
|
|
7
8
|
import { defineViraElement } from '../define-vira-element.js';
|
|
8
9
|
import { triggerPopUpState } from './pop-up-helpers.js';
|
|
9
10
|
/**
|
|
@@ -285,6 +286,19 @@ export const ViraPopUpTrigger = defineViraElement()({
|
|
|
285
286
|
${listen('click', (event) => {
|
|
286
287
|
/** Detail is 0 if it was a keyboard key (like Enter) that triggered this click. */
|
|
287
288
|
if (event.detail === 0) {
|
|
289
|
+
let isTextActiveElement = false;
|
|
290
|
+
walkActiveElement(({ element }) => {
|
|
291
|
+
if (isInputLikeElement(element)) {
|
|
292
|
+
isTextActiveElement = true;
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
if (isTextActiveElement) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
288
302
|
respondToClick(event);
|
|
289
303
|
}
|
|
290
304
|
})}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type MaybePromise } from '@augment-vir/common';
|
|
2
2
|
import { type Coords, type NavController } from 'device-navigation';
|
|
3
3
|
import { type ExtractEventByType, type ExtractEventTypes, type ListenOptions, type RemoveListenerCallback } from 'typed-event-target';
|
|
4
|
+
/**
|
|
5
|
+
* Used to prevent pop-ups from closing when a text input is active.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function isInputLikeElement(element: Element): boolean;
|
|
4
10
|
/**
|
|
5
11
|
* A type used for representing a rectangle's position.
|
|
6
12
|
*
|
|
@@ -4,6 +4,23 @@ import { findOverflowAncestor } from '@augment-vir/web';
|
|
|
4
4
|
import { NavActivateEvent, NavDirection } from 'device-navigation';
|
|
5
5
|
import { listenToPageActivation } from 'page-active';
|
|
6
6
|
import { ListenTarget, defineTypedCustomEvent, defineTypedEvent, listenToGlobal, } from 'typed-event-target';
|
|
7
|
+
/**
|
|
8
|
+
* Used to prevent pop-ups from closing when a text input is active.
|
|
9
|
+
*
|
|
10
|
+
* @category Internal
|
|
11
|
+
*/
|
|
12
|
+
export function isInputLikeElement(element) {
|
|
13
|
+
return ((element instanceof HTMLInputElement &&
|
|
14
|
+
(element.type === 'text' ||
|
|
15
|
+
element.type === 'search' ||
|
|
16
|
+
element.type === 'email' ||
|
|
17
|
+
element.type === 'url' ||
|
|
18
|
+
element.type === 'tel' ||
|
|
19
|
+
element.type === 'password' ||
|
|
20
|
+
element.type === 'number')) ||
|
|
21
|
+
element instanceof HTMLTextAreaElement ||
|
|
22
|
+
(element instanceof HTMLElement && element.isContentEditable));
|
|
23
|
+
}
|
|
7
24
|
/**
|
|
8
25
|
* The default empty {@link PositionRect}, with all values set to 0.
|
|
9
26
|
*
|
|
@@ -51,27 +68,18 @@ export class PopUpManager {
|
|
|
51
68
|
this.navController = navController;
|
|
52
69
|
this.options = { ...this.options, ...options };
|
|
53
70
|
}
|
|
54
|
-
attachGlobalListeners(
|
|
55
|
-
let firstFired = false;
|
|
56
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
57
|
-
if (firstFired) {
|
|
58
|
-
this.removePopUp();
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
firstFired = true;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
resizeObserver.observe(container);
|
|
71
|
+
attachGlobalListeners() {
|
|
65
72
|
this.cleanupCallbacks = [
|
|
66
|
-
() => {
|
|
67
|
-
resizeObserver.disconnect();
|
|
68
|
-
},
|
|
69
73
|
listenToPageActivation(false, (isPageActive) => {
|
|
70
74
|
if (!isPageActive) {
|
|
71
75
|
this.removePopUp();
|
|
72
76
|
}
|
|
73
77
|
}),
|
|
74
78
|
this.navController.listen(NavActivateEvent, (event) => {
|
|
79
|
+
const target = event.composedPath()[0];
|
|
80
|
+
if (target instanceof Element && isInputLikeElement(target)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
75
83
|
if (event.detail.success) {
|
|
76
84
|
this.listenTarget.dispatch(new NavSelectEvent({ detail: event.detail.coords }));
|
|
77
85
|
this.navController.currentNavEntry?.entry.focus(true);
|
|
@@ -94,17 +102,7 @@ export class PopUpManager {
|
|
|
94
102
|
}
|
|
95
103
|
else if (this.options.supportNavigation) {
|
|
96
104
|
const target = event.composedPath()[0];
|
|
97
|
-
|
|
98
|
-
(target.type === 'text' ||
|
|
99
|
-
target.type === 'search' ||
|
|
100
|
-
target.type === 'email' ||
|
|
101
|
-
target.type === 'url' ||
|
|
102
|
-
target.type === 'tel' ||
|
|
103
|
-
target.type === 'password' ||
|
|
104
|
-
target.type === 'number')) ||
|
|
105
|
-
target instanceof HTMLTextAreaElement ||
|
|
106
|
-
(target instanceof HTMLElement && target.isContentEditable);
|
|
107
|
-
if (isTextInput) {
|
|
105
|
+
if (target instanceof Element && isInputLikeElement(target)) {
|
|
108
106
|
return;
|
|
109
107
|
}
|
|
110
108
|
if (keyCode === 'ArrowDown') {
|
|
@@ -192,7 +190,7 @@ export class PopUpManager {
|
|
|
192
190
|
diff.bottom < currentOptions.minDownSpace;
|
|
193
191
|
const useLeft = diff.left > diff.right + currentOptions.horizontalDiffThreshold &&
|
|
194
192
|
diff.right < currentOptions.minRightSpace;
|
|
195
|
-
this.attachGlobalListeners(
|
|
193
|
+
this.attachGlobalListeners();
|
|
196
194
|
return {
|
|
197
195
|
popDown: !useUp,
|
|
198
196
|
popRight: !useLeft,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vira",
|
|
3
|
-
"version": "28.19.
|
|
3
|
+
"version": "28.19.5",
|
|
4
4
|
"description": "A simple and highly versatile design system using element-vir.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"test:docs": "virmator docs check"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@augment-vir/assert": "^31.
|
|
42
|
-
"@augment-vir/common": "^31.
|
|
43
|
-
"@augment-vir/web": "^31.
|
|
41
|
+
"@augment-vir/assert": "^31.58.0",
|
|
42
|
+
"@augment-vir/common": "^31.58.0",
|
|
43
|
+
"@augment-vir/web": "^31.58.0",
|
|
44
44
|
"colorjs.io": "^0.6.0",
|
|
45
45
|
"date-vir": "^8.1.0",
|
|
46
46
|
"device-navigation": "^4.5.5",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"typed-event-target": "^4.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@augment-vir/test": "^31.
|
|
55
|
+
"@augment-vir/test": "^31.58.0",
|
|
56
56
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
57
57
|
"@web/test-runner": "^0.20.2",
|
|
58
58
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
63
63
|
"markdown-code-example-inserter": "^3.0.3",
|
|
64
64
|
"theme-vir": "^28.17.0",
|
|
65
|
-
"typedoc": "^0.28.
|
|
65
|
+
"typedoc": "^0.28.16",
|
|
66
66
|
"typescript": "5.9.3",
|
|
67
67
|
"vite": "^7.3.1",
|
|
68
68
|
"vite-tsconfig-paths": "^6.0.4"
|