ropav 0.14.0 → 0.15.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/components/alert-dialog/alert-dialog-backdrop.js +3 -1
- package/dist/components/drawer/drawer-backdrop.js +3 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/meter/meter-root.js +1 -1
- package/dist/components/modal/modal-backdrop.js +3 -1
- package/dist/components/overlay/overlay-popover.js +14 -5
- package/dist/components/portal-provider/index.d.ts +3 -0
- package/dist/components/portal-provider/index.js +2 -0
- package/dist/components/portal-provider/portal-provider.d.ts +21 -0
- package/dist/components/portal-provider/portal-provider.js +20 -0
- package/dist/components/portal-provider/portal-provider.types.d.ts +22 -0
- package/dist/components/toast/toast-provider.js +3 -1
- package/dist/components/tooltip/tooltip-content.js +4 -1
- package/dist/composables/focus-scope-registry.d.ts +9 -1
- package/dist/composables/focus-scope-registry.js +9 -2
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/use-combo-box.js +6 -3
- package/dist/composables/use-dismissable.d.ts +6 -0
- package/dist/composables/use-dismissable.js +8 -10
- package/dist/composables/use-focus-scope.d.ts +6 -0
- package/dist/composables/use-focus-scope.js +10 -2
- package/dist/composables/use-modal-overlay.js +14 -2
- package/dist/composables/use-portal.d.ts +35 -0
- package/dist/composables/use-portal.js +47 -0
- package/dist/index.js +3 -1
- package/dist/ropav.min.css +1 -1
- package/dist/utils/aria-hide-outside.d.ts +4 -1
- package/dist/utils/aria-hide-outside.js +17 -5
- package/dist/utils/region.d.ts +10 -0
- package/dist/utils/region.js +13 -0
- package/dist/version.js +1 -1
- package/package.json +6 -2
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export interface AriaHideOutsideOptions {
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Nothing outside this element is hidden, and only this element is watched for content added
|
|
4
|
+
* later. @default document.body
|
|
5
|
+
*/
|
|
3
6
|
root?: Element;
|
|
4
7
|
/**
|
|
5
8
|
* Uses `inert` instead of `aria-hidden`, which also blocks pointer interaction and focus
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { regionsOverlap } from "./region.js";
|
|
1
2
|
import { TOP_LAYER_SELECTOR } from "./top-layer.js";
|
|
2
3
|
//#region src/utils/aria-hide-outside.ts
|
|
3
4
|
var supportsInert = typeof HTMLElement !== "undefined" && "inert" in HTMLElement.prototype;
|
|
@@ -9,8 +10,19 @@ var supportsInert = typeof HTMLElement !== "undefined" && "inert" in HTMLElement
|
|
|
9
10
|
* itself keeps a count of zero, so it is never un-hidden by this.
|
|
10
11
|
*/
|
|
11
12
|
var refCounts = /* @__PURE__ */ new WeakMap();
|
|
12
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Active layers, innermost last. Only the innermost of the layers whose roots overlap watches the
|
|
15
|
+
* DOM for new content: two modals open in two apps' windows side by side each keep watching their
|
|
16
|
+
* own, while two nested in one place hand watching to the inner one.
|
|
17
|
+
*/
|
|
13
18
|
var layers = [];
|
|
19
|
+
/** Whether a later layer covers this one's root, so this one leaves the watching to it. */
|
|
20
|
+
var isShadowed = (layer) => layers.slice(layers.indexOf(layer) + 1).some((later) => regionsOverlap(later.root, layer.root));
|
|
21
|
+
/** Watch with exactly the layers nothing later covers. */
|
|
22
|
+
var syncObservers = () => {
|
|
23
|
+
for (const layer of layers) if (isShadowed(layer)) layer.disconnect();
|
|
24
|
+
else layer.observe();
|
|
25
|
+
};
|
|
14
26
|
/** Content that must never be hidden, however deep in the page it sits. */
|
|
15
27
|
var ALWAYS_VISIBLE_SELECTOR = `[data-live-announcer], ${TOP_LAYER_SELECTOR}`;
|
|
16
28
|
var isAlwaysVisible = (node) => node instanceof HTMLElement && node.matches(ALWAYS_VISIBLE_SELECTOR);
|
|
@@ -67,7 +79,6 @@ var ariaHideOutside = (targets, options = {}) => {
|
|
|
67
79
|
node = walker.nextNode();
|
|
68
80
|
}
|
|
69
81
|
};
|
|
70
|
-
layers.at(-1)?.disconnect();
|
|
71
82
|
walk(root);
|
|
72
83
|
const observer = new MutationObserver((changes) => {
|
|
73
84
|
for (const change of changes) {
|
|
@@ -88,10 +99,11 @@ var ariaHideOutside = (targets, options = {}) => {
|
|
|
88
99
|
childList: true,
|
|
89
100
|
subtree: true
|
|
90
101
|
}),
|
|
102
|
+
root,
|
|
91
103
|
visibleNodes
|
|
92
104
|
};
|
|
93
|
-
layer.observe();
|
|
94
105
|
layers.push(layer);
|
|
106
|
+
syncObservers();
|
|
95
107
|
return () => {
|
|
96
108
|
observer.disconnect();
|
|
97
109
|
for (const node of hiddenNodes) {
|
|
@@ -104,7 +116,7 @@ var ariaHideOutside = (targets, options = {}) => {
|
|
|
104
116
|
}
|
|
105
117
|
const index = layers.indexOf(layer);
|
|
106
118
|
if (index >= 0) layers.splice(index, 1);
|
|
107
|
-
|
|
119
|
+
syncObservers();
|
|
108
120
|
};
|
|
109
121
|
};
|
|
110
122
|
/**
|
|
@@ -116,7 +128,7 @@ var ariaHideOutside = (targets, options = {}) => {
|
|
|
116
128
|
* @returns A function withdrawing the exemption, or `undefined` if nothing is hiding anything.
|
|
117
129
|
*/
|
|
118
130
|
var keepVisible = (element) => {
|
|
119
|
-
const layer = layers.at(-1);
|
|
131
|
+
const layer = layers.findLast((candidate) => candidate.root.contains(element)) ?? layers.at(-1);
|
|
120
132
|
if (!layer || layer.visibleNodes.has(element)) return void 0;
|
|
121
133
|
layer.visibleNodes.add(element);
|
|
122
134
|
return () => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether two parts of the page can see each other's overlays.
|
|
3
|
+
*
|
|
4
|
+
* An overlay belongs to a region: the root its `PortalProvider` names, or the whole document
|
|
5
|
+
* (`null`) without one. The page-wide stacks — which overlay is innermost, which one watches the
|
|
6
|
+
* DOM, which one holds focus — are only shared between overlays whose regions overlap. Two apps'
|
|
7
|
+
* windows side by side are separate regions, so a modal in one is not stacked over a modal in the
|
|
8
|
+
* other; the whole document overlaps everything, so without a provider nothing changes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const regionsOverlap: (a: Element | null, b: Element | null) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/utils/region.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether two parts of the page can see each other's overlays.
|
|
4
|
+
*
|
|
5
|
+
* An overlay belongs to a region: the root its `PortalProvider` names, or the whole document
|
|
6
|
+
* (`null`) without one. The page-wide stacks — which overlay is innermost, which one watches the
|
|
7
|
+
* DOM, which one holds focus — are only shared between overlays whose regions overlap. Two apps'
|
|
8
|
+
* windows side by side are separate regions, so a modal in one is not stacked over a modal in the
|
|
9
|
+
* other; the whole document overlaps everything, so without a provider nothing changes.
|
|
10
|
+
*/
|
|
11
|
+
var regionsOverlap = (a, b) => a == null || b == null || a.contains(b) || b.contains(a);
|
|
12
|
+
//#endregion
|
|
13
|
+
export { regionsOverlap };
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ropav",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Vapor-native Vue 3 component library — accessible by default, styled with framework-agnostic CSS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -277,6 +277,10 @@
|
|
|
277
277
|
"import": "./dist/components/popover/index.js",
|
|
278
278
|
"types": "./dist/components/popover/index.d.ts"
|
|
279
279
|
},
|
|
280
|
+
"./portal-provider": {
|
|
281
|
+
"import": "./dist/components/portal-provider/index.js",
|
|
282
|
+
"types": "./dist/components/portal-provider/index.d.ts"
|
|
283
|
+
},
|
|
280
284
|
"./progress-bar": {
|
|
281
285
|
"import": "./dist/components/progress-bar/index.js",
|
|
282
286
|
"types": "./dist/components/progress-bar/index.d.ts"
|
|
@@ -417,7 +421,7 @@
|
|
|
417
421
|
"@internationalized/date": "3.12.4",
|
|
418
422
|
"@internationalized/number": "3.6.8",
|
|
419
423
|
"@internationalized/string": "3.2.10",
|
|
420
|
-
"@ropav/styles": "0.
|
|
424
|
+
"@ropav/styles": "0.15.0"
|
|
421
425
|
},
|
|
422
426
|
"peerDependencies": {
|
|
423
427
|
"vue": "^3.6.0-rc.8"
|