@tamagui/remove-scroll 2.7.7 → 3.0.0-beta.643.1

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.
Files changed (44) hide show
  1. package/dist/cjs/RemoveScroll.cjs +18 -21
  2. package/dist/cjs/RemoveScroll.native.cjs +33 -0
  3. package/dist/cjs/RemoveScroll.native.js +19 -19
  4. package/dist/cjs/RemoveScroll.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +10 -11
  6. package/dist/cjs/index.native.cjs +21 -0
  7. package/dist/cjs/index.native.js +10 -10
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/useDisableScroll.cjs +94 -97
  10. package/dist/cjs/useDisableScroll.native.cjs +115 -0
  11. package/dist/cjs/useDisableScroll.native.js +96 -98
  12. package/dist/cjs/useDisableScroll.native.js.map +1 -1
  13. package/dist/esm/RemoveScroll.mjs +5 -3
  14. package/dist/esm/RemoveScroll.mjs.map +1 -1
  15. package/dist/esm/RemoveScroll.native.js +4 -3
  16. package/dist/esm/RemoveScroll.native.js.map +1 -1
  17. package/dist/esm/index.js +1 -2
  18. package/dist/esm/index.mjs +1 -2
  19. package/dist/esm/index.native.js +1 -2
  20. package/dist/esm/useDisableScroll.mjs +81 -79
  21. package/dist/esm/useDisableScroll.mjs.map +1 -1
  22. package/dist/esm/useDisableScroll.native.js +83 -81
  23. package/dist/esm/useDisableScroll.native.js.map +1 -1
  24. package/dist/jsx/RemoveScroll.mjs +5 -3
  25. package/dist/jsx/RemoveScroll.mjs.map +1 -1
  26. package/dist/jsx/RemoveScroll.native.cjs +33 -0
  27. package/dist/jsx/RemoveScroll.native.js +19 -19
  28. package/dist/jsx/RemoveScroll.native.js.map +1 -1
  29. package/dist/jsx/index.js +1 -2
  30. package/dist/jsx/index.mjs +1 -2
  31. package/dist/jsx/index.native.cjs +21 -0
  32. package/dist/jsx/index.native.js +10 -10
  33. package/dist/jsx/index.native.js.map +1 -1
  34. package/dist/jsx/useDisableScroll.mjs +81 -79
  35. package/dist/jsx/useDisableScroll.mjs.map +1 -1
  36. package/dist/jsx/useDisableScroll.native.cjs +115 -0
  37. package/dist/jsx/useDisableScroll.native.js +96 -98
  38. package/dist/jsx/useDisableScroll.native.js.map +1 -1
  39. package/package.json +2 -2
  40. package/dist/esm/index.js.map +0 -1
  41. package/dist/esm/index.mjs.map +0 -1
  42. package/dist/esm/index.native.js.map +0 -1
  43. package/dist/jsx/index.js.map +0 -1
  44. package/dist/jsx/index.mjs.map +0 -1
@@ -1,91 +1,93 @@
1
1
  import { useEffect, useRef } from "react";
2
- var canUseDOM = function () {
3
- return typeof window !== "undefined" && !!window.document && !!window.document.createElement;
2
+
3
+ var canUseDOM = function() {
4
+ return typeof window !== "undefined" && !!window.document && !!window.document.createElement;
4
5
  };
5
6
  var refCount = 0;
6
7
  var savedScrollY = 0;
7
8
  var previousStyles = null;
8
9
  function isIOSSafari() {
9
- if (typeof navigator === "undefined") return false;
10
- var ua = navigator.userAgent;
11
- var isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
12
- var isSafari = /^((?!chrome|android).)*safari/i.test(ua);
13
- return isIOS && isSafari;
10
+ if (typeof navigator === "undefined") return false;
11
+ var ua = navigator.userAgent;
12
+ var isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
13
+ var isSafari = /^((?!chrome|android).)*safari/i.test(ua);
14
+ return isIOS && isSafari;
14
15
  }
15
- var useDisableBodyScroll = function (enabled) {
16
- var wasEnabled = useRef(false);
17
- useEffect(function () {
18
- if (!canUseDOM()) {
19
- return;
20
- }
21
- if (enabled && !wasEnabled.current) {
22
- wasEnabled.current = true;
23
- if (++refCount === 1) {
24
- var html = document.documentElement;
25
- var body = document.body;
26
- savedScrollY = window.scrollY;
27
- previousStyles = {
28
- htmlOverflow: html.style.overflow,
29
- htmlScrollbarGutter: html.style.scrollbarGutter,
30
- bodyPosition: body.style.position,
31
- bodyTop: body.style.top,
32
- bodyWidth: body.style.width,
33
- bodyOverflow: body.style.overflow,
34
- bodyOverscrollBehavior: body.style.overscrollBehavior
35
- };
36
- html.style.scrollbarGutter = "stable";
37
- html.style.overflow = "hidden";
38
- body.style.overscrollBehavior = "none";
39
- if (isIOSSafari()) {
40
- body.style.position = "fixed";
41
- body.style.top = `-${savedScrollY}px`;
42
- body.style.width = "100%";
43
- body.style.overflow = "hidden";
44
- }
45
- }
46
- } else if (!enabled && wasEnabled.current) {
47
- wasEnabled.current = false;
48
- if (--refCount === 0 && previousStyles) {
49
- var html1 = document.documentElement;
50
- var body1 = document.body;
51
- html1.style.overflow = previousStyles.htmlOverflow;
52
- html1.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
53
- body1.style.position = previousStyles.bodyPosition;
54
- body1.style.top = previousStyles.bodyTop;
55
- body1.style.width = previousStyles.bodyWidth;
56
- body1.style.overflow = previousStyles.bodyOverflow;
57
- body1.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
58
- if (savedScrollY > 0) {
59
- window.scrollTo(0, savedScrollY);
60
- }
61
- previousStyles = null;
62
- savedScrollY = 0;
63
- }
64
- }
65
- }, [enabled]);
66
- useEffect(function () {
67
- return function () {
68
- if (wasEnabled.current) {
69
- wasEnabled.current = false;
70
- if (--refCount === 0 && previousStyles) {
71
- var html = document.documentElement;
72
- var body = document.body;
73
- html.style.overflow = previousStyles.htmlOverflow;
74
- html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
75
- body.style.position = previousStyles.bodyPosition;
76
- body.style.top = previousStyles.bodyTop;
77
- body.style.width = previousStyles.bodyWidth;
78
- body.style.overflow = previousStyles.bodyOverflow;
79
- body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
80
- if (savedScrollY > 0) {
81
- window.scrollTo(0, savedScrollY);
82
- }
83
- previousStyles = null;
84
- savedScrollY = 0;
85
- }
86
- }
87
- };
88
- }, []);
16
+ var useDisableBodyScroll = function(enabled) {
17
+ var wasEnabled = useRef(false);
18
+ useEffect(function() {
19
+ if (!canUseDOM()) {
20
+ return;
21
+ }
22
+ if (enabled && !wasEnabled.current) {
23
+ wasEnabled.current = true;
24
+ if (++refCount === 1) {
25
+ var html = document.documentElement;
26
+ var body = document.body;
27
+ savedScrollY = window.scrollY;
28
+ previousStyles = {
29
+ htmlOverflow: html.style.overflow,
30
+ htmlScrollbarGutter: html.style.scrollbarGutter,
31
+ bodyPosition: body.style.position,
32
+ bodyTop: body.style.top,
33
+ bodyWidth: body.style.width,
34
+ bodyOverflow: body.style.overflow,
35
+ bodyOverscrollBehavior: body.style.overscrollBehavior
36
+ };
37
+ html.style.scrollbarGutter = "stable";
38
+ html.style.overflow = "hidden";
39
+ body.style.overscrollBehavior = "none";
40
+ if (isIOSSafari()) {
41
+ body.style.position = "fixed";
42
+ body.style.top = `-${savedScrollY}px`;
43
+ body.style.width = "100%";
44
+ body.style.overflow = "hidden";
45
+ }
46
+ }
47
+ } else if (!enabled && wasEnabled.current) {
48
+ wasEnabled.current = false;
49
+ if (--refCount === 0 && previousStyles) {
50
+ var html1 = document.documentElement;
51
+ var body1 = document.body;
52
+ html1.style.overflow = previousStyles.htmlOverflow;
53
+ html1.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
54
+ body1.style.position = previousStyles.bodyPosition;
55
+ body1.style.top = previousStyles.bodyTop;
56
+ body1.style.width = previousStyles.bodyWidth;
57
+ body1.style.overflow = previousStyles.bodyOverflow;
58
+ body1.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
59
+ if (savedScrollY > 0) {
60
+ window.scrollTo(0, savedScrollY);
61
+ }
62
+ previousStyles = null;
63
+ savedScrollY = 0;
64
+ }
65
+ }
66
+ }, [enabled]);
67
+ useEffect(function() {
68
+ return function() {
69
+ if (wasEnabled.current) {
70
+ wasEnabled.current = false;
71
+ if (--refCount === 0 && previousStyles) {
72
+ var html = document.documentElement;
73
+ var body = document.body;
74
+ html.style.overflow = previousStyles.htmlOverflow;
75
+ html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
76
+ body.style.position = previousStyles.bodyPosition;
77
+ body.style.top = previousStyles.bodyTop;
78
+ body.style.width = previousStyles.bodyWidth;
79
+ body.style.overflow = previousStyles.bodyOverflow;
80
+ body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
81
+ if (savedScrollY > 0) {
82
+ window.scrollTo(0, savedScrollY);
83
+ }
84
+ previousStyles = null;
85
+ savedScrollY = 0;
86
+ }
87
+ }
88
+ };
89
+ }, []);
89
90
  };
91
+
90
92
  export { useDisableBodyScroll };
91
93
  //# sourceMappingURL=useDisableScroll.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","canUseDOM","window","document","createElement","refCount","savedScrollY","previousStyles","isIOSSafari","navigator","ua","userAgent","isIOS","test","platform","maxTouchPoints","isSafari","useDisableBodyScroll","enabled","wasEnabled","current","html","documentElement","body","scrollY","htmlOverflow","style","overflow","htmlScrollbarGutter","scrollbarGutter","bodyPosition","position","bodyTop","top","bodyWidth","width","bodyOverflow","bodyOverscrollBehavior","overscrollBehavior","html1","body1","scrollTo"],"sources":["../../src/useDisableScroll.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAA,EAAWC,MAAA,QAAc;AAElC,IAAAC,SAAM,YAAAA,CAAA,EACJ;EAEF,OAAI,OAAWC,MAAA,sBAAAA,MAAA,CAAAC,QAAA,MAAAD,MAAA,CAAAC,QAAA,CAAAC,aAAA;AACf;AACA,IAAIC,QAAA;AAWJ,IAAAC,YAAS;AACP,IAAAC,cAAW;AACX,SAAMC,WAAKA,CAAA,EAAU;EACrB,WAAMC,SACJ,gBAAmB,EAAK,OACvB;EACH,IAAAC,EAAM,GAAAD,SAAW,CAAAE,SAAA;EACjB,IAAAC,KAAO,qBAAS,CAAAC,IAAA,CAAAH,EAAA,KAAAD,SAAA,CAAAK,QAAA,mBAAAL,SAAA,CAAAM,cAAA;EAClB,IA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B,YAAe;UAE/CP,IAAI,CAAAG,KAAA,CAAAO,GAAA,GAAA1B,cAAkB,CAAAyB,OAAA;UACpBT,IAAA,CAAAG,KAAO,CAAAS,KAAA,GAAS5B,cAAe,CAAA2B,SAAA;UACjCX,IAAA,CAAAG,KAAA,CAAAC,QAAA,GAAApB,cAAA,CAAA6B,YAAA;UAEAb,IAAA,CAAAG,KAAA,CAAAY,kBAAiB,GAAA/B,cAAA,CAAA8B,sBAAA;UACjB,IAAA/B,YAAe;YACjBJ,MAAA,CAAAuC,QAAA,IAAAnC,YAAA;UACF;UACFC,cAAA;UACGD,YAAA;QACP","ignoreList":[]}
1
+ {"version":3,"file":"useDisableScroll.native.js","names":[],"sources":["esm/useDisableScroll.native.js"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nvar canUseDOM = function() {\n return typeof window !== \"undefined\" && !!window.document && !!window.document.createElement;\n};\nvar refCount = 0;\nvar savedScrollY = 0;\nvar previousStyles = null;\nfunction isIOSSafari() {\n if (typeof navigator === \"undefined\") return false;\n var ua = navigator.userAgent;\n var isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 1;\n var isSafari = /^((?!chrome|android).)*safari/i.test(ua);\n return isIOS && isSafari;\n}\nvar useDisableBodyScroll = function(enabled) {\n var wasEnabled = useRef(false);\n useEffect(function() {\n if (!canUseDOM()) {\n return;\n }\n if (enabled && !wasEnabled.current) {\n wasEnabled.current = true;\n if (++refCount === 1) {\n var html = document.documentElement;\n var body = document.body;\n savedScrollY = window.scrollY;\n previousStyles = {\n htmlOverflow: html.style.overflow,\n htmlScrollbarGutter: html.style.scrollbarGutter,\n bodyPosition: body.style.position,\n bodyTop: body.style.top,\n bodyWidth: body.style.width,\n bodyOverflow: body.style.overflow,\n bodyOverscrollBehavior: body.style.overscrollBehavior\n };\n html.style.scrollbarGutter = \"stable\";\n html.style.overflow = \"hidden\";\n body.style.overscrollBehavior = \"none\";\n if (isIOSSafari()) {\n body.style.position = \"fixed\";\n body.style.top = `-${savedScrollY}px`;\n body.style.width = \"100%\";\n body.style.overflow = \"hidden\";\n }\n }\n } else if (!enabled && wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n var html1 = document.documentElement;\n var body1 = document.body;\n html1.style.overflow = previousStyles.htmlOverflow;\n html1.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body1.style.position = previousStyles.bodyPosition;\n body1.style.top = previousStyles.bodyTop;\n body1.style.width = previousStyles.bodyWidth;\n body1.style.overflow = previousStyles.bodyOverflow;\n body1.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0;\n }\n }\n }, [\n enabled\n ]);\n useEffect(function() {\n return function() {\n if (wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n var html = document.documentElement;\n var body = document.body;\n html.style.overflow = previousStyles.htmlOverflow;\n html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body.style.position = previousStyles.bodyPosition;\n body.style.top = previousStyles.bodyTop;\n body.style.width = previousStyles.bodyWidth;\n body.style.overflow = previousStyles.bodyOverflow;\n body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0;\n }\n }\n };\n }, []);\n};\nexport {\n useDisableBodyScroll\n};\n//# sourceMappingURL=useDisableScroll.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,WAAW;CACzB,OAAO,OAAO,WAAW,eAAe,CAAC,CAAC,OAAO,YAAY,CAAC,CAAC,OAAO,SAAS;AACjF;AACA,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,SAAS,cAAc;CACrB,IAAI,OAAO,cAAc,aAAa,OAAO;CAC7C,IAAI,KAAK,UAAU;CACnB,IAAI,QAAQ,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C;IACA,iBAAiB;IACjB,eAAe;GACjB;EACF;CACF,GAAG,CACD,OACF,CAAC;CACD,UAAU,WAAW;EACnB,OAAO,WAAW;GAChB,IAAI,WAAW,SAAS;IACtB,WAAW,UAAU;IACrB,IAAI,EAAE,aAAa,KAAK,gBAAgB;KACtC,IAAI,OAAO,SAAS;KACpB,IAAI,OAAO,SAAS;KACpB,KAAK,MAAM,WAAW,eAAe;KACrC,KAAK,MAAM,kBAAkB,eAAe;KAC5C,KAAK,MAAM,WAAW,eAAe;KACrC,KAAK,MAAM,MAAM,eAAe;KAChC,KAAK,MAAM,QAAQ,eAAe;KAClC,KAAK,MAAM,WAAW,eAAe;KACrC,KAAK,MAAM,qBAAqB,eAAe;KAC/C,IAAI,eAAe,GAAG;MACpB,OAAO,SAAS,GAAG,YAAY;KACjC;KACA,iBAAiB;KACjB,eAAe;IACjB;GACF;EACF;CACF,GAAG,CAAC,CAAC;AACP"}
@@ -1,7 +1,9 @@
1
1
  import { useDisableBodyScroll } from "./useDisableScroll.mjs";
2
- const RemoveScroll = props => {
3
- useDisableBodyScroll(Boolean(props.enabled));
4
- return props.children;
2
+
3
+ const RemoveScroll = (props) => {
4
+ useDisableBodyScroll(Boolean(props.enabled));
5
+ return props.children;
5
6
  };
7
+
6
8
  export { RemoveScroll };
7
9
  //# sourceMappingURL=RemoveScroll.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["useDisableBodyScroll","RemoveScroll","props","Boolean","enabled","children"],"sources":["../../src/RemoveScroll.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,oBAAA,QAA4B;AAO9B,MAAMC,YAAA,GAAgBC,KAAA,IAAwC;EACnEF,oBAAA,CAAqBG,OAAA,CAAQD,KAAA,CAAME,OAAO,CAAC;EAE3C,OAAOF,KAAA,CAAMG,QAAA;AACf","ignoreList":[]}
1
+ {"version":3,"file":"RemoveScroll.js","names":[],"sources":["jsx/RemoveScroll.js"],"sourcesContent":["import { useDisableBodyScroll } from \"./useDisableScroll\";\nconst RemoveScroll = (props) => {\n useDisableBodyScroll(Boolean(props.enabled));\n return props.children;\n};\nexport {\n RemoveScroll\n};\n//# sourceMappingURL=RemoveScroll.js.map\n"],"mappings":";;;AACA,MAAM,gBAAgB,UAAU;CAC9B,qBAAqB,QAAQ,MAAM,OAAO,CAAC;CAC3C,OAAO,MAAM;AACf"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var RemoveScroll_native_exports = {};
25
+ __export(RemoveScroll_native_exports, {
26
+ RemoveScroll: () => RemoveScroll,
27
+ getAllowedScrollableNode: () => getAllowedScrollableNode
28
+ });
29
+ module.exports = __toCommonJS(RemoveScroll_native_exports);
30
+ var RemoveScroll = function(props) {
31
+ return props.children;
32
+ };
33
+ var getAllowedScrollableNode = function() {};
@@ -1,35 +1,35 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
24
  var RemoveScroll_native_exports = {};
26
25
  __export(RemoveScroll_native_exports, {
27
- RemoveScroll: () => RemoveScroll,
28
- getAllowedScrollableNode: () => getAllowedScrollableNode
26
+ RemoveScroll: () => RemoveScroll,
27
+ getAllowedScrollableNode: () => getAllowedScrollableNode
29
28
  });
30
29
  module.exports = __toCommonJS(RemoveScroll_native_exports);
31
- var RemoveScroll = function (props) {
32
- return props.children;
30
+ var RemoveScroll = function(props) {
31
+ return props.children;
33
32
  };
34
- var getAllowedScrollableNode = function () {};
33
+ var getAllowedScrollableNode = function() {};
34
+
35
35
  //# sourceMappingURL=RemoveScroll.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["RemoveScroll_native_exports","__export","RemoveScroll","getAllowedScrollableNode","module","exports","__toCommonJS","props","children"],"sources":["../../src/RemoveScroll.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,2BAAA;AAAAC,QAAA,CAAAD,2BAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,wBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAN,2BAAA;AAAO,IAAIE,YAAA,GAAe,SAAAA,CAASK,KAAA,EAAO;EACtC,OAAOA,KAAA,CAAMC,QAAA;AACjB;AACO,IAAIL,wBAAA,GAA2B,SAAAA,CAAA,EAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"RemoveScroll.native.js","names":[],"sources":["jsx/RemoveScroll.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar RemoveScroll_native_exports = {};\n__export(RemoveScroll_native_exports, {\n RemoveScroll: () => RemoveScroll,\n getAllowedScrollableNode: () => getAllowedScrollableNode\n});\nmodule.exports = __toCommonJS(RemoveScroll_native_exports);\nvar RemoveScroll = function(props) {\n return props.children;\n};\nvar getAllowedScrollableNode = function() {\n};\n//# sourceMappingURL=RemoveScroll.native.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,8BAA8B,CAAC;AACnC,SAAS,6BAA6B;CACpC,oBAAoB;CACpB,gCAAgC;AAClC,CAAC;AACD,OAAO,UAAU,aAAa,2BAA2B;AACzD,IAAI,eAAe,SAAS,OAAO;CACjC,OAAO,MAAM;AACf;AACA,IAAI,2BAA2B,WAAW,CAC1C"}
package/dist/jsx/index.js CHANGED
@@ -1,2 +1 @@
1
- export * from "./RemoveScroll.mjs";
2
- //# sourceMappingURL=index.js.map
1
+ export * from "./RemoveScroll.mjs"
@@ -1,2 +1 @@
1
- export * from "./RemoveScroll.mjs";
2
- //# sourceMappingURL=index.mjs.map
1
+ export * from "./RemoveScroll.mjs"
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ module.exports = __toCommonJS(index_exports);
21
+ __reExport(index_exports, require("./RemoveScroll.native.js"), module.exports);
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
- get: () => from[key],
11
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
- });
13
- }
14
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
15
16
  };
16
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
- value: true
19
- }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var index_exports = {};
21
20
  module.exports = __toCommonJS(index_exports);
22
21
  __reExport(index_exports, require("./RemoveScroll.native.js"), module.exports);
22
+
23
23
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["jsx/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./RemoveScroll\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,0BAAgB,GAAG,OAAO,OAAO"}
@@ -1,89 +1,91 @@
1
1
  import { useEffect, useRef } from "react";
2
+
2
3
  const canUseDOM = () => typeof window !== "undefined" && !!window.document && !!window.document.createElement;
3
4
  let refCount = 0;
4
5
  let savedScrollY = 0;
5
6
  let previousStyles = null;
6
7
  function isIOSSafari() {
7
- if (typeof navigator === "undefined") return false;
8
- const ua = navigator.userAgent;
9
- const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
10
- const isSafari = /^((?!chrome|android).)*safari/i.test(ua);
11
- return isIOS && isSafari;
8
+ if (typeof navigator === "undefined") return false;
9
+ const ua = navigator.userAgent;
10
+ const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
11
+ const isSafari = /^((?!chrome|android).)*safari/i.test(ua);
12
+ return isIOS && isSafari;
12
13
  }
13
- const useDisableBodyScroll = enabled => {
14
- const wasEnabled = useRef(false);
15
- useEffect(() => {
16
- if (!canUseDOM()) {
17
- return;
18
- }
19
- if (enabled && !wasEnabled.current) {
20
- wasEnabled.current = true;
21
- if (++refCount === 1) {
22
- const html = document.documentElement;
23
- const body = document.body;
24
- savedScrollY = window.scrollY;
25
- previousStyles = {
26
- htmlOverflow: html.style.overflow,
27
- htmlScrollbarGutter: html.style.scrollbarGutter,
28
- bodyPosition: body.style.position,
29
- bodyTop: body.style.top,
30
- bodyWidth: body.style.width,
31
- bodyOverflow: body.style.overflow,
32
- bodyOverscrollBehavior: body.style.overscrollBehavior
33
- };
34
- html.style.scrollbarGutter = "stable";
35
- html.style.overflow = "hidden";
36
- body.style.overscrollBehavior = "none";
37
- if (isIOSSafari()) {
38
- body.style.position = "fixed";
39
- body.style.top = `-${savedScrollY}px`;
40
- body.style.width = "100%";
41
- body.style.overflow = "hidden";
42
- }
43
- }
44
- } else if (!enabled && wasEnabled.current) {
45
- wasEnabled.current = false;
46
- if (--refCount === 0 && previousStyles) {
47
- const html = document.documentElement;
48
- const body = document.body;
49
- html.style.overflow = previousStyles.htmlOverflow;
50
- html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
51
- body.style.position = previousStyles.bodyPosition;
52
- body.style.top = previousStyles.bodyTop;
53
- body.style.width = previousStyles.bodyWidth;
54
- body.style.overflow = previousStyles.bodyOverflow;
55
- body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
56
- if (savedScrollY > 0) {
57
- window.scrollTo(0, savedScrollY);
58
- }
59
- previousStyles = null;
60
- savedScrollY = 0;
61
- }
62
- }
63
- }, [enabled]);
64
- useEffect(() => {
65
- return () => {
66
- if (wasEnabled.current) {
67
- wasEnabled.current = false;
68
- if (--refCount === 0 && previousStyles) {
69
- const html = document.documentElement;
70
- const body = document.body;
71
- html.style.overflow = previousStyles.htmlOverflow;
72
- html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
73
- body.style.position = previousStyles.bodyPosition;
74
- body.style.top = previousStyles.bodyTop;
75
- body.style.width = previousStyles.bodyWidth;
76
- body.style.overflow = previousStyles.bodyOverflow;
77
- body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
78
- if (savedScrollY > 0) {
79
- window.scrollTo(0, savedScrollY);
80
- }
81
- previousStyles = null;
82
- savedScrollY = 0;
83
- }
84
- }
85
- };
86
- }, []);
14
+ const useDisableBodyScroll = (enabled) => {
15
+ const wasEnabled = useRef(false);
16
+ useEffect(() => {
17
+ if (!canUseDOM()) {
18
+ return;
19
+ }
20
+ if (enabled && !wasEnabled.current) {
21
+ wasEnabled.current = true;
22
+ if (++refCount === 1) {
23
+ const html = document.documentElement;
24
+ const body = document.body;
25
+ savedScrollY = window.scrollY;
26
+ previousStyles = {
27
+ htmlOverflow: html.style.overflow,
28
+ htmlScrollbarGutter: html.style.scrollbarGutter,
29
+ bodyPosition: body.style.position,
30
+ bodyTop: body.style.top,
31
+ bodyWidth: body.style.width,
32
+ bodyOverflow: body.style.overflow,
33
+ bodyOverscrollBehavior: body.style.overscrollBehavior
34
+ };
35
+ html.style.scrollbarGutter = "stable";
36
+ html.style.overflow = "hidden";
37
+ body.style.overscrollBehavior = "none";
38
+ if (isIOSSafari()) {
39
+ body.style.position = "fixed";
40
+ body.style.top = `-${savedScrollY}px`;
41
+ body.style.width = "100%";
42
+ body.style.overflow = "hidden";
43
+ }
44
+ }
45
+ } else if (!enabled && wasEnabled.current) {
46
+ wasEnabled.current = false;
47
+ if (--refCount === 0 && previousStyles) {
48
+ const html = document.documentElement;
49
+ const body = document.body;
50
+ html.style.overflow = previousStyles.htmlOverflow;
51
+ html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
52
+ body.style.position = previousStyles.bodyPosition;
53
+ body.style.top = previousStyles.bodyTop;
54
+ body.style.width = previousStyles.bodyWidth;
55
+ body.style.overflow = previousStyles.bodyOverflow;
56
+ body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
57
+ if (savedScrollY > 0) {
58
+ window.scrollTo(0, savedScrollY);
59
+ }
60
+ previousStyles = null;
61
+ savedScrollY = 0;
62
+ }
63
+ }
64
+ }, [enabled]);
65
+ useEffect(() => {
66
+ return () => {
67
+ if (wasEnabled.current) {
68
+ wasEnabled.current = false;
69
+ if (--refCount === 0 && previousStyles) {
70
+ const html = document.documentElement;
71
+ const body = document.body;
72
+ html.style.overflow = previousStyles.htmlOverflow;
73
+ html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
74
+ body.style.position = previousStyles.bodyPosition;
75
+ body.style.top = previousStyles.bodyTop;
76
+ body.style.width = previousStyles.bodyWidth;
77
+ body.style.overflow = previousStyles.bodyOverflow;
78
+ body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
79
+ if (savedScrollY > 0) {
80
+ window.scrollTo(0, savedScrollY);
81
+ }
82
+ previousStyles = null;
83
+ savedScrollY = 0;
84
+ }
85
+ }
86
+ };
87
+ }, []);
87
88
  };
89
+
88
90
  export { useDisableBodyScroll };
89
91
  //# sourceMappingURL=useDisableScroll.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","canUseDOM","window","document","createElement","refCount","savedScrollY","previousStyles","isIOSSafari","navigator","ua","userAgent","isIOS","test","platform","maxTouchPoints","isSafari","useDisableBodyScroll","enabled","wasEnabled","current","html","documentElement","body","scrollY","htmlOverflow","style","overflow","htmlScrollbarGutter","scrollbarGutter","bodyPosition","position","bodyTop","top","bodyWidth","width","bodyOverflow","bodyOverscrollBehavior","overscrollBehavior","scrollTo"],"sources":["../../src/useDisableScroll.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAA,EAAWC,MAAA,QAAc;AAElC,MAAMC,SAAA,GAAYA,CAAA,KAChB,OAAOC,MAAA,KAAW,eAAe,CAAC,CAACA,MAAA,CAAOC,QAAA,IAAY,CAAC,CAACD,MAAA,CAAOC,QAAA,CAASC,aAAA;AAE1E,IAAIC,QAAA,GAAW;AACf,IAAIC,YAAA,GAAe;AACnB,IAAIC,cAAA,GAQO;AAGX,SAASC,YAAA,EAAc;EACrB,IAAI,OAAOC,SAAA,KAAc,aAAa,OAAO;EAC7C,MAAMC,EAAA,GAAKD,SAAA,CAAUE,SAAA;EACrB,MAAMC,KAAA,GACJ,mBAAmBC,IAAA,CAAKH,EAAE,KACzBD,SAAA,CAAUK,QAAA,KAAa,cAAcL,SAAA,CAAUM,cAAA,GAAiB;EACnE,MAAMC,QAAA,GAAW,iCAAiCH,IAAA,CAAKH,EAAE;EACzD,OAAOE,KAAA,IAASI,QAAA;AAClB;AAEO,MAAMC,oBAAA,GAAwBC,OAAA,IAA2B;EAC9D,MAAMC,UAAA,GAAanB,MAAA,CAAO,KAAK;EAE/BD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AAA,CAAeuB,YAAA;UACrCP,IAAA,CAAKG,KAAA,CAAMO,GAAA,GAAM1B,cAAA,CAAeyB,OAAA;UAChCT,IAAA,CAAKG,KAAA,CAAMS,KAAA,GAAQ5B,cAAA,CAAe2B,SAAA;UAClCX,IAAA,CAAKG,KAAA,CAAMC,QAAA,GAAWpB,cAAA,CAAe6B,YAAA;UACrCb,IAAA,CAAKG,KAAA,CAAMY,kBAAA,GAAqB/B,cAAA,CAAe8B,sBAAA;UAE/C,IAAI/B,YAAA,GAAe,GAAG;YACpBJ,MAAA,CAAOqC,QAAA,CAAS,GAAGjC,YAAY;UACjC;UAEAC,cAAA,GAAiB;UACjBD,YAAA,GAAe;QACjB;MACF;IACF;EACF,GAAG,EAAE;AACP","ignoreList":[]}
1
+ {"version":3,"file":"useDisableScroll.js","names":[],"sources":["jsx/useDisableScroll.js"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nconst canUseDOM = () => typeof window !== \"undefined\" && !!window.document && !!window.document.createElement;\nlet refCount = 0;\nlet savedScrollY = 0;\nlet previousStyles = null;\nfunction isIOSSafari() {\n if (typeof navigator === \"undefined\") return false;\n const ua = navigator.userAgent;\n const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 1;\n const isSafari = /^((?!chrome|android).)*safari/i.test(ua);\n return isIOS && isSafari;\n}\nconst useDisableBodyScroll = (enabled) => {\n const wasEnabled = useRef(false);\n useEffect(() => {\n if (!canUseDOM()) {\n return;\n }\n if (enabled && !wasEnabled.current) {\n wasEnabled.current = true;\n if (++refCount === 1) {\n const html = document.documentElement;\n const body = document.body;\n savedScrollY = window.scrollY;\n previousStyles = {\n htmlOverflow: html.style.overflow,\n htmlScrollbarGutter: html.style.scrollbarGutter,\n bodyPosition: body.style.position,\n bodyTop: body.style.top,\n bodyWidth: body.style.width,\n bodyOverflow: body.style.overflow,\n bodyOverscrollBehavior: body.style.overscrollBehavior\n };\n html.style.scrollbarGutter = \"stable\";\n html.style.overflow = \"hidden\";\n body.style.overscrollBehavior = \"none\";\n if (isIOSSafari()) {\n body.style.position = \"fixed\";\n body.style.top = `-${savedScrollY}px`;\n body.style.width = \"100%\";\n body.style.overflow = \"hidden\";\n }\n }\n } else if (!enabled && wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n const html = document.documentElement;\n const body = document.body;\n html.style.overflow = previousStyles.htmlOverflow;\n html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body.style.position = previousStyles.bodyPosition;\n body.style.top = previousStyles.bodyTop;\n body.style.width = previousStyles.bodyWidth;\n body.style.overflow = previousStyles.bodyOverflow;\n body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0;\n }\n }\n }, [enabled]);\n useEffect(() => {\n return () => {\n if (wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n const html = document.documentElement;\n const body = document.body;\n html.style.overflow = previousStyles.htmlOverflow;\n html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body.style.position = previousStyles.bodyPosition;\n body.style.top = previousStyles.bodyTop;\n body.style.width = previousStyles.bodyWidth;\n body.style.overflow = previousStyles.bodyOverflow;\n body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0;\n }\n }\n };\n }, []);\n};\nexport {\n useDisableBodyScroll\n};\n//# sourceMappingURL=useDisableScroll.js.map\n"],"mappings":";;;AACA,MAAM,kBAAkB,OAAO,WAAW,eAAe,CAAC,CAAC,OAAO,YAAY,CAAC,CAAC,OAAO,SAAS;AAChG,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,SAAS,cAAc;CACrB,IAAI,OAAO,cAAc,aAAa,OAAO;CAC7C,MAAM,KAA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