@zag-js/interact-outside 0.1.2 → 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 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/README.md CHANGED
@@ -12,11 +12,8 @@ npm i @zag-js/interact-outside
12
12
 
13
13
  ## Contribution
14
14
 
15
- Yes please! See the
16
- [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md)
17
- for details.
15
+ Yes please! See the [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md) for details.
18
16
 
19
17
  ## Licence
20
18
 
21
- This project is licensed under the terms of the
22
- [MIT license](https://github.com/chakra-ui/zag/blob/main/LICENSE).
19
+ This project is licensed under the terms of the [MIT license](https://github.com/chakra-ui/zag/blob/main/LICENSE).
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export declare type InteractOutsideHandlers = {
1
+ declare type InteractOutsideHandlers = {
2
2
  onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;
3
3
  onFocusOutside?: (event: FocusOutsideEvent) => void;
4
4
  onInteractOutside?: (event: InteractOutsideEvent) => void;
5
5
  };
6
- export declare type InteractOutsideOptions = InteractOutsideHandlers & {
6
+ declare type InteractOutsideOptions = InteractOutsideHandlers & {
7
7
  exclude?: (target: HTMLElement) => boolean;
8
8
  };
9
9
  declare type EventDetails<T> = {
@@ -11,8 +11,9 @@ declare type EventDetails<T> = {
11
11
  contextmenu: boolean;
12
12
  focusable: boolean;
13
13
  };
14
- export declare type PointerDownOutsideEvent = CustomEvent<EventDetails<PointerEvent>>;
15
- export declare type FocusOutsideEvent = CustomEvent<EventDetails<FocusEvent>>;
16
- export declare type InteractOutsideEvent = PointerDownOutsideEvent | FocusOutsideEvent;
17
- export declare function trackInteractOutside(node: HTMLElement | null, options: InteractOutsideOptions): () => void;
18
- export {};
14
+ declare type PointerDownOutsideEvent = CustomEvent<EventDetails<PointerEvent>>;
15
+ declare type FocusOutsideEvent = CustomEvent<EventDetails<FocusEvent>>;
16
+ declare type InteractOutsideEvent = PointerDownOutsideEvent | FocusOutsideEvent;
17
+ declare function trackInteractOutside(node: HTMLElement | null, options: InteractOutsideOptions): (() => void) | undefined;
18
+
19
+ export { FocusOutsideEvent, InteractOutsideEvent, InteractOutsideHandlers, InteractOutsideOptions, PointerDownOutsideEvent, trackInteractOutside };
package/dist/index.js CHANGED
@@ -27,14 +27,13 @@ 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 != null ? res : void 0;
30
+ return res ?? void 0;
31
31
  };
32
32
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
33
33
  var isDom = () => typeof window !== "undefined";
34
34
  function getPlatform() {
35
- var _a;
36
35
  const agent = navigator.userAgentData;
37
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
36
+ return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
38
37
  }
39
38
  var pt = (v) => isDom() && v.test(getPlatform());
40
39
  var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
@@ -46,20 +45,18 @@ function isWindow(value) {
46
45
  return (value == null ? void 0 : value.toString()) === "[object Window]";
47
46
  }
48
47
  function getDocument(el) {
49
- var _a;
50
48
  if (isWindow(el))
51
49
  return el.document;
52
50
  if (isDocument(el))
53
51
  return el;
54
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
52
+ return (el == null ? void 0 : el.ownerDocument) ?? document;
55
53
  }
56
54
  function getWindow(el) {
57
- var _a;
58
- return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
55
+ return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
59
56
  }
60
57
  function getEventTarget(event) {
61
- var _a, _b;
62
- return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
58
+ var _a;
59
+ return ((_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) ?? event.target;
63
60
  }
64
61
  function contains(parent, child) {
65
62
  if (!parent)
@@ -185,3 +182,7 @@ function trackInteractOutside(node, options) {
185
182
  cleanups.forEach((fn) => fn());
186
183
  };
187
184
  }
185
+ // Annotate the CommonJS export names for ESM import in node:
186
+ 0 && (module.exports = {
187
+ trackInteractOutside
188
+ });
package/dist/index.mjs CHANGED
@@ -1,14 +1,13 @@
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 != null ? res : void 0;
4
+ return res ?? void 0;
5
5
  };
6
6
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
7
7
  var isDom = () => typeof window !== "undefined";
8
8
  function getPlatform() {
9
- var _a;
10
9
  const agent = navigator.userAgentData;
11
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
10
+ return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
12
11
  }
13
12
  var pt = (v) => isDom() && v.test(getPlatform());
14
13
  var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
@@ -20,20 +19,18 @@ function isWindow(value) {
20
19
  return (value == null ? void 0 : value.toString()) === "[object Window]";
21
20
  }
22
21
  function getDocument(el) {
23
- var _a;
24
22
  if (isWindow(el))
25
23
  return el.document;
26
24
  if (isDocument(el))
27
25
  return el;
28
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
26
+ return (el == null ? void 0 : el.ownerDocument) ?? document;
29
27
  }
30
28
  function getWindow(el) {
31
- var _a;
32
- return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
29
+ return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
33
30
  }
34
31
  function getEventTarget(event) {
35
- var _a, _b;
36
- return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
32
+ var _a;
33
+ return ((_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) ?? event.target;
37
34
  }
38
35
  function contains(parent, child) {
39
36
  if (!parent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/interact-outside",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Track interations or focus outside an element",
5
5
  "keywords": [
6
6
  "js",
@@ -18,22 +18,23 @@
18
18
  "files": [
19
19
  "dist/**/*"
20
20
  ],
21
- "scripts": {
22
- "build:fast": "yarn zag build",
23
- "start": "yarn zag build --watch",
24
- "build": "yarn zag build --prod",
25
- "test": "jest --config ../../../jest.config.js --rootDir tests",
26
- "lint": "eslint src --ext .ts,.tsx",
27
- "test:ci": "yarn test --ci --runInBand --updateSnapshot",
28
- "test:watch": "yarn test --watchAll"
29
- },
30
- "dependencies": {
31
- "@zag-js/dom-utils": "0.1.7"
21
+ "devDependencies": {
22
+ "@zag-js/dom-utils": "0.1.8",
23
+ "@zag-js/utils": "0.1.3"
32
24
  },
33
25
  "publishConfig": {
34
26
  "access": "public"
35
27
  },
36
28
  "bugs": {
37
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
+ },
31
+ "scripts": {
32
+ "build-fast": "tsup src/index.ts --format=esm,cjs",
33
+ "start": "pnpm build --watch",
34
+ "build": "tsup src/index.ts --format=esm,cjs --dts",
35
+ "test": "jest --config ../../../jest.config.js --rootDir tests",
36
+ "lint": "eslint src --ext .ts,.tsx",
37
+ "test-ci": "pnpm test --ci --runInBand -u",
38
+ "test-watch": "pnpm test --watchAll"
38
39
  }
39
- }
40
+ }