@zag-js/remove-scroll 0.1.1 → 0.1.4

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
@@ -1,7 +1,5 @@
1
1
  # @zag-js/remove-scroll
2
2
 
3
-
4
-
5
3
  ## Installation
6
4
 
7
5
  ```sh
@@ -12,11 +10,8 @@ npm i @zag-js/remove-scroll
12
10
 
13
11
  ## Contribution
14
12
 
15
- Yes please! See the
16
- [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md)
17
- for details.
13
+ Yes please! See the [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md) for details.
18
14
 
19
15
  ## Licence
20
16
 
21
- This project is licensed under the terms of the
22
- [MIT license](https://github.com/chakra-ui/zag/blob/main/LICENSE).
17
+ 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 +1,3 @@
1
- export declare function preventBodyScroll(_document?: Document): () => void;
1
+ declare function preventBodyScroll(_document?: Document): (() => void) | undefined;
2
+
3
+ export { preventBodyScroll };
package/dist/index.js CHANGED
@@ -27,9 +27,8 @@ module.exports = __toCommonJS(src_exports);
27
27
  // ../dom/dist/index.mjs
28
28
  var isDom = () => typeof window !== "undefined";
29
29
  function getPlatform() {
30
- var _a;
31
30
  const agent = navigator.userAgentData;
32
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
31
+ return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
33
32
  }
34
33
  var pt = (v) => isDom() && v.test(getPlatform());
35
34
  var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
@@ -69,9 +68,8 @@ function getPaddingProperty(documentElement) {
69
68
  return scrollbarX ? "paddingLeft" : "paddingRight";
70
69
  }
71
70
  function preventBodyScroll(_document) {
72
- var _a;
73
- const doc = _document != null ? _document : document;
74
- const win = (_a = doc.defaultView) != null ? _a : window;
71
+ const doc = _document ?? document;
72
+ const win = doc.defaultView ?? window;
75
73
  const { documentElement, body } = doc;
76
74
  const locked = body.hasAttribute(LOCK_CLASSNAME);
77
75
  if (locked)
@@ -85,10 +83,9 @@ function preventBodyScroll(_document) {
85
83
  [paddingProperty]: `${scrollbarWidth}px`
86
84
  });
87
85
  const setIOSStyle = () => {
88
- var _a2, _b;
89
86
  const { scrollX, scrollY, visualViewport } = win;
90
- const offsetLeft = (_a2 = visualViewport == null ? void 0 : visualViewport.offsetLeft) != null ? _a2 : 0;
91
- const offsetTop = (_b = visualViewport == null ? void 0 : visualViewport.offsetTop) != null ? _b : 0;
87
+ const offsetLeft = (visualViewport == null ? void 0 : visualViewport.offsetLeft) ?? 0;
88
+ const offsetTop = (visualViewport == null ? void 0 : visualViewport.offsetTop) ?? 0;
92
89
  const restoreStyle = assignStyle(body, {
93
90
  position: "fixed",
94
91
  overflow: "hidden",
@@ -108,3 +105,7 @@ function preventBodyScroll(_document) {
108
105
  body.removeAttribute(LOCK_CLASSNAME);
109
106
  };
110
107
  }
108
+ // Annotate the CommonJS export names for ESM import in node:
109
+ 0 && (module.exports = {
110
+ preventBodyScroll
111
+ });
package/dist/index.mjs CHANGED
@@ -1,9 +1,8 @@
1
1
  // ../dom/dist/index.mjs
2
2
  var isDom = () => typeof window !== "undefined";
3
3
  function getPlatform() {
4
- var _a;
5
4
  const agent = navigator.userAgentData;
6
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
5
+ return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
7
6
  }
8
7
  var pt = (v) => isDom() && v.test(getPlatform());
9
8
  var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
@@ -43,9 +42,8 @@ function getPaddingProperty(documentElement) {
43
42
  return scrollbarX ? "paddingLeft" : "paddingRight";
44
43
  }
45
44
  function preventBodyScroll(_document) {
46
- var _a;
47
- const doc = _document != null ? _document : document;
48
- const win = (_a = doc.defaultView) != null ? _a : window;
45
+ const doc = _document ?? document;
46
+ const win = doc.defaultView ?? window;
49
47
  const { documentElement, body } = doc;
50
48
  const locked = body.hasAttribute(LOCK_CLASSNAME);
51
49
  if (locked)
@@ -59,10 +57,9 @@ function preventBodyScroll(_document) {
59
57
  [paddingProperty]: `${scrollbarWidth}px`
60
58
  });
61
59
  const setIOSStyle = () => {
62
- var _a2, _b;
63
60
  const { scrollX, scrollY, visualViewport } = win;
64
- const offsetLeft = (_a2 = visualViewport == null ? void 0 : visualViewport.offsetLeft) != null ? _a2 : 0;
65
- const offsetTop = (_b = visualViewport == null ? void 0 : visualViewport.offsetTop) != null ? _b : 0;
61
+ const offsetLeft = (visualViewport == null ? void 0 : visualViewport.offsetLeft) ?? 0;
62
+ const offsetTop = (visualViewport == null ? void 0 : visualViewport.offsetTop) ?? 0;
66
63
  const restoreStyle = assignStyle(body, {
67
64
  position: "fixed",
68
65
  overflow: "hidden",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/remove-scroll",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "JavaScript utility to remove scroll on body",
5
5
  "keywords": [
6
6
  "js",
@@ -18,22 +18,22 @@
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
21
  "publishConfig": {
31
22
  "access": "public"
32
23
  },
33
- "dependencies": {
34
- "@zag-js/dom-utils": "0.1.6"
24
+ "devDependencies": {
25
+ "@zag-js/dom-utils": "0.1.11"
35
26
  },
36
27
  "bugs": {
37
28
  "url": "https://github.com/chakra-ui/zag/issues"
29
+ },
30
+ "scripts": {
31
+ "build-fast": "tsup src/index.ts --format=esm,cjs",
32
+ "start": "pnpm build --watch",
33
+ "build": "tsup src/index.ts --format=esm,cjs --dts",
34
+ "test": "jest --config ../../../jest.config.js --rootDir tests",
35
+ "lint": "eslint src --ext .ts,.tsx",
36
+ "test-ci": "pnpm test --ci --runInBand -u",
37
+ "test-watch": "pnpm test --watchAll"
38
38
  }
39
- }
39
+ }