@tamagui/scroll-view 2.7.7 → 3.0.0-beta.1091.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 (62) hide show
  1. package/dist/cjs/ScrollView.cjs +20 -31
  2. package/dist/cjs/ScrollView.native.cjs +47 -0
  3. package/dist/cjs/ScrollView.native.js +35 -32
  4. package/dist/cjs/ScrollView.native.js.map +1 -1
  5. package/dist/cjs/WebScrollView.cjs +236 -0
  6. package/dist/cjs/WebScrollView.native.cjs +274 -0
  7. package/dist/cjs/WebScrollView.native.js +276 -0
  8. package/dist/cjs/WebScrollView.native.js.map +1 -0
  9. package/dist/cjs/index.cjs +9 -11
  10. package/dist/cjs/index.native.cjs +20 -0
  11. package/dist/cjs/index.native.js +9 -10
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/cjs/web.cjs +24 -0
  14. package/dist/esm/ScrollView.mjs +8 -13
  15. package/dist/esm/ScrollView.mjs.map +1 -1
  16. package/dist/esm/ScrollView.native.js +17 -15
  17. package/dist/esm/ScrollView.native.js.map +1 -1
  18. package/dist/esm/WebScrollView.mjs +211 -0
  19. package/dist/esm/WebScrollView.mjs.map +1 -0
  20. package/dist/esm/WebScrollView.native.js +247 -0
  21. package/dist/esm/WebScrollView.native.js.map +1 -0
  22. package/dist/esm/index.js +1 -2
  23. package/dist/esm/index.mjs +1 -2
  24. package/dist/esm/index.native.js +1 -2
  25. package/dist/esm/web.mjs +3 -0
  26. package/dist/jsx/ScrollView.mjs +8 -13
  27. package/dist/jsx/ScrollView.mjs.map +1 -1
  28. package/dist/jsx/ScrollView.native.cjs +47 -0
  29. package/dist/jsx/ScrollView.native.js +35 -32
  30. package/dist/jsx/ScrollView.native.js.map +1 -1
  31. package/dist/jsx/WebScrollView.mjs +211 -0
  32. package/dist/jsx/WebScrollView.mjs.map +1 -0
  33. package/dist/jsx/WebScrollView.native.cjs +274 -0
  34. package/dist/jsx/WebScrollView.native.js +276 -0
  35. package/dist/jsx/WebScrollView.native.js.map +1 -0
  36. package/dist/jsx/index.js +1 -2
  37. package/dist/jsx/index.mjs +1 -2
  38. package/dist/jsx/index.native.cjs +20 -0
  39. package/dist/jsx/index.native.js +9 -10
  40. package/dist/jsx/index.native.js.map +1 -1
  41. package/dist/jsx/web.mjs +3 -0
  42. package/package.json +15 -6
  43. package/src/ScrollView.native.tsx +45 -0
  44. package/src/ScrollView.tsx +12 -15
  45. package/src/WebScrollView.tsx +332 -0
  46. package/src/index.ts +1 -0
  47. package/src/web.ts +8 -0
  48. package/types/ScrollView.d.ts +18 -16
  49. package/types/ScrollView.d.ts.map +1 -1
  50. package/types/ScrollView.native.d.ts +25 -0
  51. package/types/ScrollView.native.d.ts.map +1 -0
  52. package/types/WebScrollView.d.ts +25 -0
  53. package/types/WebScrollView.d.ts.map +1 -0
  54. package/types/index.d.ts +1 -0
  55. package/types/index.d.ts.map +1 -1
  56. package/types/web.d.ts +4 -0
  57. package/types/web.d.ts.map +1 -0
  58. package/dist/esm/index.js.map +0 -1
  59. package/dist/esm/index.mjs.map +0 -1
  60. package/dist/esm/index.native.js.map +0 -1
  61. package/dist/jsx/index.js.map +0 -1
  62. package/dist/jsx/index.mjs.map +0 -1
@@ -3,41 +3,30 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
10
  };
11
11
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
19
  };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
21
  var ScrollView_exports = {};
24
- __export(ScrollView_exports, {
25
- ScrollView: () => ScrollView
26
- });
22
+ __export(ScrollView_exports, { ScrollView: () => ScrollView });
27
23
  module.exports = __toCommonJS(ScrollView_exports);
28
- var import_stacks = require("@tamagui/stacks");
29
24
  var import_web = require("@tamagui/web");
30
- var import_react_native = require("react-native-web");
31
- const ScrollView = (0, import_web.styled)(import_react_native.ScrollView, {
32
- name: "ScrollView",
33
- scrollEnabled: true,
34
- variants: {
35
- fullscreen: {
36
- true: import_stacks.fullscreenStyle
37
- }
38
- }
25
+ var import_WebScrollView = require("./WebScrollView.cjs");
26
+ const ScrollView = (0, import_web.styled)(import_WebScrollView.WebScrollView, {
27
+ displayName: "ScrollView",
28
+ scrollEnabled: true
39
29
  }, {
40
- accept: {
41
- contentContainerStyle: "style"
42
- }
43
- });
30
+ acceptsClassName: true,
31
+ neverFlatten: true
32
+ });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ScrollView_native_exports = {};
30
+ __export(ScrollView_native_exports, { ScrollView: () => ScrollView });
31
+ module.exports = __toCommonJS(ScrollView_native_exports);
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var import_web = require("@tamagui/web");
34
+ var import_react = __toESM(require("react"), 1);
35
+ var import_react_native = require("react-native");
36
+ var ScrollViewNative = /* @__PURE__ */ import_react.default.forwardRef(function(param, ref) {
37
+ var { contentContainerStyle, ...props } = param;
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.ScrollView, {
39
+ ...props,
40
+ ref,
41
+ contentContainerStyle: (0, import_web.useStyle)(contentContainerStyle)
42
+ });
43
+ });
44
+ var ScrollView = (0, import_web.styled)(ScrollViewNative, {
45
+ displayName: "ScrollView",
46
+ scrollEnabled: true
47
+ }, { neverFlatten: true });
@@ -1,46 +1,49 @@
1
1
  "use strict";
2
2
 
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
12
14
  };
13
15
  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;
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
21
23
  };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
25
- var ScrollView_exports = {};
26
- __export(ScrollView_exports, {
27
- ScrollView: () => ScrollView
28
- });
29
- module.exports = __toCommonJS(ScrollView_exports);
30
- var import_stacks = require("@tamagui/stacks");
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ScrollView_native_exports = {};
30
+ __export(ScrollView_native_exports, { ScrollView: () => ScrollView });
31
+ module.exports = __toCommonJS(ScrollView_native_exports);
32
+ var import_jsx_runtime = require("react/jsx-runtime");
31
33
  var import_web = require("@tamagui/web");
34
+ var import_react = __toESM(require("react"), 1);
32
35
  var import_react_native = require("react-native");
33
- var ScrollView = (0, import_web.styled)(import_react_native.ScrollView, {
34
- name: "ScrollView",
35
- scrollEnabled: true,
36
- variants: {
37
- fullscreen: {
38
- true: import_stacks.fullscreenStyle
39
- }
40
- }
41
- }, {
42
- accept: {
43
- contentContainerStyle: "style"
44
- }
36
+ var ScrollViewNative = /* @__PURE__ */ import_react.default.forwardRef(function(param, ref) {
37
+ var { contentContainerStyle, ...props } = param;
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.ScrollView, {
39
+ ...props,
40
+ ref,
41
+ contentContainerStyle: (0, import_web.useStyle)(contentContainerStyle)
42
+ });
45
43
  });
44
+ var ScrollView = (0, import_web.styled)(ScrollViewNative, {
45
+ displayName: "ScrollView",
46
+ scrollEnabled: true
47
+ }, { neverFlatten: true });
48
+
46
49
  //# sourceMappingURL=ScrollView.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ScrollView_exports","__export","ScrollView","module","exports","import_stacks","require","import_web","import_react_native","styled","name","scrollEnabled","variants","fullscreen","true","fullscreenStyle","accept","contentContainerStyle"],"sources":["../../src/ScrollView.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kBAAA;AAAAC,QAAA,CAAAD,kBAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAgC,CAAAK,kBAAA;AAEhC,IAAAK,aAAuB,GAAAC,OAAA;AACvB,IAAAC,UAAA,GAAAD,OAAA,eAA+C;AAExC,IAAAE,mBAAmB,GAAAF,OAAA;AAAA,IACxBJ,UAAA,OAAAK,UAAA,CAAAE,MAAA,EAAAD,mBAAA,CAAAN,UAAA;EACAQ,IAAA;EAAAC,aACQ;EAAAC,QACN;IAEAC,UAAU;MACRC,IAAA,EAAAT,aAAY,CAAAU;IAAA;EACJ;AACR;EAEJC,MAAA;IACAC,qBAAA;EAAA;AACU","ignoreList":[]}
1
+ {"version":3,"file":"ScrollView.native.js","names":[],"sources":["cjs/ScrollView.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar ScrollView_native_exports = {};\n__export(ScrollView_native_exports, {\n ScrollView: () => ScrollView\n});\nmodule.exports = __toCommonJS(ScrollView_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_web = require(\"@tamagui/web\");\nvar import_react = __toESM(require(\"react\"), 1);\nvar import_react_native = require(\"react-native\");\nvar ScrollViewNative = /* @__PURE__ */ import_react.default.forwardRef(function(param, ref) {\n var { contentContainerStyle, ...props } = param;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.ScrollView, {\n ...props,\n ref,\n contentContainerStyle: (0, import_web.useStyle)(contentContainerStyle)\n });\n});\nvar ScrollView = (0, import_web.styled)(ScrollViewNative, {\n displayName: \"ScrollView\",\n scrollEnabled: true\n}, {\n neverFlatten: true\n});\n//# sourceMappingURL=ScrollView.native.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,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,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,4BAA4B,CAAC;AACjC,SAAS,2BAA2B,EAClC,kBAAkB,WACpB,CAAC;AACD,OAAO,UAAU,aAAa,yBAAyB;AACvD,IAAI,qBAAqB,QAAQ,mBAAmB;AACpD,IAAI,aAAa,QAAQ,cAAc;AACvC,IAAI,eAAe,QAAQ,QAAQ,OAAO,GAAG,CAAC;AAC9C,IAAI,sBAAsB,QAAQ,cAAc;AAChD,IAAI,mBAAmC,6BAAa,QAAQ,WAAW,SAAS,OAAO,KAAK;CAC1F,IAAI,EAAE,uBAAuB,GAAG,UAAU;CAC1C,OAAuB,iBAAC,GAAG,mBAAmB,IAAG,CAAE,oBAAoB,YAAY;EACjF,GAAG;EACH;EACA,wBAAwB,GAAG,WAAW,SAAQ,CAAE,qBAAqB;CACvE,CAAC;AACH,CAAC;AACD,IAAI,cAAc,GAAG,WAAW,OAAM,CAAE,kBAAkB;CACxD,aAAa;CACb,eAAe;AACjB,GAAG,EACD,cAAc,KAChB,CAAC"}
@@ -0,0 +1,236 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ 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;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var WebScrollView_exports = {};
28
+ __export(WebScrollView_exports, { WebScrollView: () => WebScrollView });
29
+ module.exports = __toCommonJS(WebScrollView_exports);
30
+ var import_web = require("@tamagui/web");
31
+ var React = __toESM(require("react"), 1);
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ const View = import_web.View;
34
+ function mergeRefs(...refs) {
35
+ return (node) => {
36
+ for (const ref of refs) {
37
+ if (!ref) continue;
38
+ if (typeof ref === "function") ref(node);
39
+ else ref.current = node;
40
+ }
41
+ };
42
+ }
43
+ function normalizeScrollEvent(e) {
44
+ const target = e.target;
45
+ return {
46
+ nativeEvent: {
47
+ contentOffset: {
48
+ get x() {
49
+ return target.scrollLeft;
50
+ },
51
+ get y() {
52
+ return target.scrollTop;
53
+ }
54
+ },
55
+ contentSize: {
56
+ get height() {
57
+ return target.scrollHeight;
58
+ },
59
+ get width() {
60
+ return target.scrollWidth;
61
+ }
62
+ },
63
+ layoutMeasurement: {
64
+ get height() {
65
+ return target.offsetHeight;
66
+ },
67
+ get width() {
68
+ return target.offsetWidth;
69
+ }
70
+ }
71
+ },
72
+ timeStamp: Date.now()
73
+ };
74
+ }
75
+ function shouldEmitScrollEvent(lastTick, eventThrottle) {
76
+ const timeSinceLastTick = Date.now() - lastTick;
77
+ return eventThrottle > 0 && timeSinceLastTick >= eventThrottle;
78
+ }
79
+ function resolveStyles(...inputs) {
80
+ return inputs.flat(Infinity).filter(Boolean);
81
+ }
82
+ function joinClassNames(...parts) {
83
+ const joined = parts.filter(Boolean).join(" ").trim();
84
+ return joined || void 0;
85
+ }
86
+ const commonStyle = {
87
+ flexGrow: 1,
88
+ flexShrink: 1
89
+ };
90
+ const styles = {
91
+ baseVertical: {
92
+ ...commonStyle,
93
+ flexDirection: "column",
94
+ overflowX: "hidden",
95
+ overflowY: "auto"
96
+ },
97
+ baseHorizontal: {
98
+ ...commonStyle,
99
+ flexDirection: "row",
100
+ overflowX: "auto",
101
+ overflowY: "hidden"
102
+ },
103
+ contentContainerHorizontal: { flexDirection: "row" },
104
+ contentContainerCenterContent: {
105
+ justifyContent: "center",
106
+ flexGrow: 1
107
+ },
108
+ stickyHeader: {
109
+ position: "sticky",
110
+ top: 0,
111
+ zIndex: 10
112
+ },
113
+ pagingEnabledHorizontal: { scrollSnapType: "x mandatory" },
114
+ pagingEnabledVertical: { scrollSnapType: "y mandatory" },
115
+ pagingEnabledChild: { scrollSnapAlign: "start" },
116
+ scrollDisabled: {
117
+ overflowX: "hidden",
118
+ overflowY: "hidden",
119
+ touchAction: "none"
120
+ }
121
+ };
122
+ const WebScrollView = React.forwardRef((props, forwardedRef) => {
123
+ const { children, contentContainerStyle, horizontal, onContentSizeChange, onScroll, refreshControl, stickyHeaderIndices, pagingEnabled, centerContent, scrollEnabled = true, scrollEventThrottle = 0, showsHorizontalScrollIndicator, showsVerticalScrollIndicator, style, keyboardShouldPersistTaps, keyboardDismissMode, contentOffset, contentInset, contentInsetAdjustmentBehavior, decelerationRate, directionalLockEnabled, disableIntervalMomentum, disableScrollViewPanResponder, endFillColor, fadingEdgeLength, indicatorStyle, invertStickyHeaders, maintainVisibleContentPosition, maximumZoomScale, minimumZoomScale, nestedScrollEnabled, onScrollToTop, overScrollMode, pinchGestureEnabled, removeClippedSubviews, scrollIndicatorInsets, scrollPerfTag, scrollToOverflowEnabled, snapToAlignment, snapToEnd, snapToInterval, snapToOffsets, snapToStart, bounces, ...rest } = props;
124
+ const scrollNodeRef = React.useRef(null);
125
+ const innerViewRef = React.useRef(null);
126
+ const scrollState = React.useRef({
127
+ isScrolling: false,
128
+ scrollLastTick: 0
129
+ });
130
+ const scrollTimeout = React.useRef(null);
131
+ const scrollTo = (options) => {
132
+ const node = scrollNodeRef.current;
133
+ if (node == null) return;
134
+ const { x = 0, y = 0, animated = true } = options || {};
135
+ if (typeof node.scroll === "function") {
136
+ node.scroll({
137
+ top: y,
138
+ left: x,
139
+ behavior: animated ? "smooth" : "auto"
140
+ });
141
+ } else {
142
+ node.scrollLeft = x;
143
+ node.scrollTop = y;
144
+ }
145
+ };
146
+ const scrollToEnd = (options) => {
147
+ const node = scrollNodeRef.current;
148
+ if (node == null) return;
149
+ const animated = (options && options.animated) !== false;
150
+ const x = horizontal ? node.scrollWidth : 0;
151
+ const y = horizontal ? 0 : node.scrollHeight;
152
+ scrollTo({
153
+ x,
154
+ y,
155
+ animated
156
+ });
157
+ };
158
+ const setScrollNodeRef = React.useCallback((node) => {
159
+ scrollNodeRef.current = node;
160
+ if (node != null) {
161
+ node.getScrollResponder = () => node;
162
+ node.getScrollableNode = () => node;
163
+ node.getInnerViewNode = () => innerViewRef.current;
164
+ node.getInnerViewRef = () => innerViewRef.current;
165
+ node.getNativeScrollRef = () => node;
166
+ node.scrollTo = scrollTo;
167
+ node.scrollToEnd = scrollToEnd;
168
+ node.flashScrollIndicators = () => {};
169
+ }
170
+ mergeRefs(forwardedRef)(node);
171
+ }, [forwardedRef, horizontal]);
172
+ function handleScroll(e) {
173
+ e.stopPropagation();
174
+ if (e.target !== scrollNodeRef.current) return;
175
+ if (scrollTimeout.current != null) {
176
+ clearTimeout(scrollTimeout.current);
177
+ }
178
+ scrollTimeout.current = setTimeout(() => {
179
+ scrollState.current.isScrolling = false;
180
+ onScroll?.(normalizeScrollEvent(e));
181
+ }, 100);
182
+ if (scrollState.current.isScrolling) {
183
+ if (shouldEmitScrollEvent(scrollState.current.scrollLastTick, scrollEventThrottle)) {
184
+ scrollState.current.scrollLastTick = Date.now();
185
+ onScroll?.(normalizeScrollEvent(e));
186
+ }
187
+ } else {
188
+ scrollState.current.isScrolling = true;
189
+ scrollState.current.scrollLastTick = Date.now();
190
+ onScroll?.(normalizeScrollEvent(e));
191
+ }
192
+ }
193
+ const handleContentLayout = onContentSizeChange ? (e) => {
194
+ const { width, height } = e.nativeEvent.layout;
195
+ onContentSizeChange(width, height);
196
+ } : void 0;
197
+ const hasStickyHeaderIndices = !horizontal && Array.isArray(stickyHeaderIndices);
198
+ const renderedChildren = hasStickyHeaderIndices || pagingEnabled ? React.Children.map(children, (child, i) => {
199
+ const isSticky = hasStickyHeaderIndices && stickyHeaderIndices.indexOf(i) > -1;
200
+ if (child != null && (isSticky || pagingEnabled)) {
201
+ const resolvedStyle = resolveStyles(isSticky && styles.stickyHeader, pagingEnabled && styles.pagingEnabledChild);
202
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
203
+ style: resolvedStyle,
204
+ children: child
205
+ });
206
+ }
207
+ return child;
208
+ }) : children;
209
+ const contentStyle = resolveStyles(horizontal && styles.contentContainerHorizontal, centerContent && styles.contentContainerCenterContent, contentContainerStyle);
210
+ const contentContainer = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
211
+ ref: innerViewRef,
212
+ onLayout: handleContentLayout,
213
+ style: contentStyle,
214
+ children: renderedChildren
215
+ });
216
+ const baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;
217
+ const pagingEnabledStyle = horizontal ? styles.pagingEnabledHorizontal : styles.pagingEnabledVertical;
218
+ const hideHorizontalScrollbar = showsHorizontalScrollIndicator === false;
219
+ const hideVerticalScrollbar = showsVerticalScrollIndicator === false;
220
+ const extraClassName = (hideHorizontalScrollbar ? " _hsb-x" : "") + (hideVerticalScrollbar ? " _hsb-y" : "");
221
+ const scrollStyle = resolveStyles(baseStyle, pagingEnabled && pagingEnabledStyle, style, !scrollEnabled && styles.scrollDisabled);
222
+ const scrollView = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, {
223
+ ...rest,
224
+ className: joinClassNames(rest.className, extraClassName),
225
+ ref: setScrollNodeRef,
226
+ onScroll: handleScroll,
227
+ style: scrollStyle,
228
+ children: contentContainer
229
+ });
230
+ if (refreshControl) {
231
+ const refreshStyle = resolveStyles(baseStyle, style);
232
+ return React.cloneElement(refreshControl, { style: refreshStyle }, scrollView);
233
+ }
234
+ return scrollView;
235
+ });
236
+ WebScrollView.displayName = "ScrollView";