@zag-js/dismissable 0.0.0-dev-20220714012600 → 0.1.3
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/LICENSE +21 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +9 -6
- package/dist/index.mjs +5 -6
- package/package.json +14 -13
- package/dist/dismissable-layer.d.ts +0 -13
- package/dist/escape-keydown.d.ts +0 -1
- package/dist/layer-stack.d.ts +0 -25
- package/dist/pointer-event-outside.d.ts +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Chakra UI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { InteractOutsideHandlers } from '@zag-js/interact-outside';
|
|
2
|
+
|
|
3
|
+
declare type Container = HTMLElement | null | Array<HTMLElement | null>;
|
|
4
|
+
declare type DismissableElementHandlers = InteractOutsideHandlers & {
|
|
5
|
+
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
6
|
+
};
|
|
7
|
+
declare type DismissableElementOptions = DismissableElementHandlers & {
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
pointerBlocking?: boolean;
|
|
10
|
+
onDismiss: () => void;
|
|
11
|
+
exclude?: Container | (() => Container);
|
|
12
|
+
};
|
|
13
|
+
declare function trackDismissableElement(node: HTMLElement | null, options: DismissableElementOptions): (() => void) | undefined;
|
|
14
|
+
|
|
15
|
+
export { DismissableElementHandlers, DismissableElementOptions, trackDismissableElement };
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
27
27
|
// ../dom/dist/index.mjs
|
|
28
28
|
var runIfFn = (v, ...a) => {
|
|
29
29
|
const res = typeof v === "function" ? v(...a) : v;
|
|
30
|
-
return res
|
|
30
|
+
return res ?? void 0;
|
|
31
31
|
};
|
|
32
32
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
33
33
|
function isDocument(el) {
|
|
@@ -37,16 +37,15 @@ function isWindow(value) {
|
|
|
37
37
|
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
38
38
|
}
|
|
39
39
|
function getDocument(el) {
|
|
40
|
-
var _a;
|
|
41
40
|
if (isWindow(el))
|
|
42
41
|
return el.document;
|
|
43
42
|
if (isDocument(el))
|
|
44
43
|
return el;
|
|
45
|
-
return (
|
|
44
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
46
45
|
}
|
|
47
46
|
function getEventTarget(event) {
|
|
48
|
-
var _a
|
|
49
|
-
return (
|
|
47
|
+
var _a;
|
|
48
|
+
return ((_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) ?? event.target;
|
|
50
49
|
}
|
|
51
50
|
function contains(parent, child) {
|
|
52
51
|
if (!parent)
|
|
@@ -72,7 +71,7 @@ var import_interact_outside = require("@zag-js/interact-outside");
|
|
|
72
71
|
function warn(...a) {
|
|
73
72
|
const m = a.length === 1 ? a[0] : a[1];
|
|
74
73
|
const c = a.length === 2 ? a[0] : true;
|
|
75
|
-
if (c &&
|
|
74
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
76
75
|
console.warn(m);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -249,3 +248,7 @@ function trackDismissableElement(node, options) {
|
|
|
249
248
|
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
250
249
|
};
|
|
251
250
|
}
|
|
251
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
252
|
+
0 && (module.exports = {
|
|
253
|
+
trackDismissableElement
|
|
254
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ../dom/dist/index.mjs
|
|
2
2
|
var runIfFn = (v, ...a) => {
|
|
3
3
|
const res = typeof v === "function" ? v(...a) : v;
|
|
4
|
-
return res
|
|
4
|
+
return res ?? void 0;
|
|
5
5
|
};
|
|
6
6
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
7
7
|
function isDocument(el) {
|
|
@@ -11,16 +11,15 @@ function isWindow(value) {
|
|
|
11
11
|
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
12
12
|
}
|
|
13
13
|
function getDocument(el) {
|
|
14
|
-
var _a;
|
|
15
14
|
if (isWindow(el))
|
|
16
15
|
return el.document;
|
|
17
16
|
if (isDocument(el))
|
|
18
17
|
return el;
|
|
19
|
-
return (
|
|
18
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
20
19
|
}
|
|
21
20
|
function getEventTarget(event) {
|
|
22
|
-
var _a
|
|
23
|
-
return (
|
|
21
|
+
var _a;
|
|
22
|
+
return ((_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) ?? event.target;
|
|
24
23
|
}
|
|
25
24
|
function contains(parent, child) {
|
|
26
25
|
if (!parent)
|
|
@@ -48,7 +47,7 @@ import {
|
|
|
48
47
|
function warn(...a) {
|
|
49
48
|
const m = a.length === 1 ? a[0] : a[1];
|
|
50
49
|
const c = a.length === 2 ? a[0] : true;
|
|
51
|
-
if (c &&
|
|
50
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
52
51
|
console.warn(m);
|
|
53
52
|
}
|
|
54
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/dismissable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Dismissable layer utilities for the DOM",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -22,25 +22,26 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"dist/**/*"
|
|
24
24
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build:fast": "yarn zag build",
|
|
27
|
-
"start": "yarn zag build --watch",
|
|
28
|
-
"build": "yarn zag build --prod",
|
|
29
|
-
"test": "jest --config ../../../jest.config.js --rootDir tests",
|
|
30
|
-
"lint": "eslint src --ext .ts,.tsx",
|
|
31
|
-
"test:ci": "yarn test --ci --runInBand --updateSnapshot",
|
|
32
|
-
"test:watch": "yarn test --watchAll"
|
|
33
|
-
},
|
|
34
25
|
"publishConfig": {
|
|
35
26
|
"access": "public"
|
|
36
27
|
},
|
|
37
28
|
"dependencies": {
|
|
38
|
-
"@zag-js/interact-outside": "0.
|
|
29
|
+
"@zag-js/interact-outside": "0.1.3"
|
|
39
30
|
},
|
|
40
31
|
"devDependencies": {
|
|
41
|
-
"@zag-js/dom-utils": "0.
|
|
32
|
+
"@zag-js/dom-utils": "0.1.8",
|
|
33
|
+
"@zag-js/utils": "0.1.3"
|
|
42
34
|
},
|
|
43
35
|
"bugs": {
|
|
44
36
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build-fast": "tsup src/index.ts --format=esm,cjs",
|
|
40
|
+
"start": "pnpm build --watch",
|
|
41
|
+
"build": "tsup src/index.ts --format=esm,cjs --dts",
|
|
42
|
+
"test": "jest --config ../../../jest.config.js --rootDir tests",
|
|
43
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
44
|
+
"test-ci": "pnpm test --ci --runInBand -u",
|
|
45
|
+
"test-watch": "pnpm test --watchAll"
|
|
45
46
|
}
|
|
46
|
-
}
|
|
47
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { InteractOutsideHandlers } from "@zag-js/interact-outside";
|
|
2
|
-
declare type Container = HTMLElement | null | Array<HTMLElement | null>;
|
|
3
|
-
export declare type DismissableElementHandlers = InteractOutsideHandlers & {
|
|
4
|
-
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
5
|
-
};
|
|
6
|
-
export declare type DismissableElementOptions = DismissableElementHandlers & {
|
|
7
|
-
debug?: boolean;
|
|
8
|
-
pointerBlocking?: boolean;
|
|
9
|
-
onDismiss: () => void;
|
|
10
|
-
exclude?: Container | (() => Container);
|
|
11
|
-
};
|
|
12
|
-
export declare function trackDismissableElement(node: HTMLElement | null, options: DismissableElementOptions): () => void;
|
|
13
|
-
export {};
|
package/dist/escape-keydown.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function trackEscapeKeydown(fn?: (event: KeyboardEvent) => void): () => void;
|
package/dist/layer-stack.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export declare type Layer = {
|
|
2
|
-
dismiss: VoidFunction;
|
|
3
|
-
node: HTMLElement;
|
|
4
|
-
pointerBlocking?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare const layerStack: {
|
|
7
|
-
layers: Layer[];
|
|
8
|
-
branches: HTMLElement[];
|
|
9
|
-
count(): number;
|
|
10
|
-
pointerBlockingLayers(): Layer[];
|
|
11
|
-
topMostPointerBlockingLayer(): Layer | undefined;
|
|
12
|
-
hasPointerBlockingLayer(): boolean;
|
|
13
|
-
isBelowPointerBlockingLayer(node: HTMLElement): boolean;
|
|
14
|
-
isTopMost(node: HTMLElement | null): boolean;
|
|
15
|
-
getNestedLayers(node: HTMLElement): unknown[];
|
|
16
|
-
isInNestedLayer(node: HTMLElement, target: HTMLElement | EventTarget | null): any;
|
|
17
|
-
isInBranch(target: HTMLElement | EventTarget | null): boolean;
|
|
18
|
-
add(layer: Layer): void;
|
|
19
|
-
addBranch(node: HTMLElement): void;
|
|
20
|
-
remove(node: HTMLElement): void;
|
|
21
|
-
removeBranch(node: HTMLElement): void;
|
|
22
|
-
indexOf(node: HTMLElement | undefined): any;
|
|
23
|
-
dismiss(node: HTMLElement): void;
|
|
24
|
-
clear(): void;
|
|
25
|
-
};
|