@tamagui/scroll-view 2.7.7 → 3.0.0-beta.1093.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
@@ -1,18 +1,13 @@
1
- import { fullscreenStyle } from "@tamagui/stacks";
2
1
  import { styled } from "@tamagui/web";
3
- import { ScrollView as ScrollViewNative } from "react-native-web";
4
- const ScrollView = styled(ScrollViewNative, {
5
- name: "ScrollView",
6
- scrollEnabled: true,
7
- variants: {
8
- fullscreen: {
9
- true: fullscreenStyle
10
- }
11
- }
2
+ import { WebScrollView } from "./WebScrollView.mjs";
3
+
4
+ const ScrollView = styled(WebScrollView, {
5
+ displayName: "ScrollView",
6
+ scrollEnabled: true
12
7
  }, {
13
- accept: {
14
- contentContainerStyle: "style"
15
- }
8
+ acceptsClassName: true,
9
+ neverFlatten: true
16
10
  });
11
+
17
12
  export { ScrollView };
18
13
  //# sourceMappingURL=ScrollView.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["fullscreenStyle","styled","ScrollView","ScrollViewNative","name","scrollEnabled","variants","fullscreen","true","accept","contentContainerStyle"],"sources":["../../src/ScrollView.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,QAAuB;AAEhC,SAASC,MAAA,QAAc;AACvB,SAASC,UAAA,IAAcC,gBAAA,QAAwB;AAExC,MAAMD,UAAA,GAAaD,MAAA,CACxBE,gBAAA,EACA;EACEC,IAAA,EAAM;EACNC,aAAA,EAAe;EAEfC,QAAA,EAAU;IACRC,UAAA,EAAY;MACVC,IAAA,EAAMR;IACR;EACF;AACF,GACA;EACES,MAAA,EAAQ;IACNC,qBAAA,EAAuB;EACzB;AACF,CACF","ignoreList":[]}
1
+ {"version":3,"file":"ScrollView.js","names":[],"sources":["jsx/ScrollView.js"],"sourcesContent":["import { styled } from \"@tamagui/web\";\nimport { WebScrollView } from \"./WebScrollView\";\nconst ScrollView = styled(\n WebScrollView,\n {\n displayName: \"ScrollView\",\n scrollEnabled: true\n },\n {\n acceptsClassName: true,\n neverFlatten: true\n }\n);\nexport {\n ScrollView\n};\n//# sourceMappingURL=ScrollView.js.map\n"],"mappings":";;;;AAEA,MAAM,aAAa,OACjB,eACA;CACE,aAAa;CACb,eAAe;AACjB,GACA;CACE,kBAAkB;CAClB,cAAc;AAChB,CACF"}
@@ -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":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","ScrollView_exports"],"sources":["../../src/ScrollView.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAS;;AAET,IAAAA,SAAS,GAAAC,MAAA,CAAcC,cAAA;AACvB,IAAAC,gBAAS,GAAcF,MAAA,CAAAG,wBAAwB;AAExC,IAAAC,iBAAmB,GAAAJ,MAAA,CAAAK,mBAAA;AAAA,IACxBC,YAAA,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AAAA,IACAC,QAAA,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EAAA,KACE,IAAMC,IAAA,IAAAD,GAAA,EACNZ,SAAA,CAAAW,MAAe,EAAAE,IAAA;IAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA;AAAA;AAEL,IAAAC,WACR,GAAYA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;EAAA,IAAAF,IACV,IAAM,OAAAA,IAAA,wBAAAA,IAAA;IAAA,KACR,IAAAG,GAAA,IAAAhB,iBAAA,CAAAa,IAAA,GACF,KAAAX,YAAA,CAAAe,IAAA,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,EACFnB,SAAA,CAAAiB,EAAA,EAAAI,GAAA;MAAAP,GAAA,EAAAA,CAAA,KAAAI,IAAA,CAAAG,GAAA;MAAAN,UAAA,IAAAK,IAAA,GAAAjB,gBAAA,CAAAe,IAAA,EAAAG,GAAA,MAAAD,IAAA,CAAAL;IAAA;EACA;EAAA,OACEE,EAAA;AAAQ;AACiB,IACzBM,YAAA,GAAAC,GAAA,IAAAR,WAAA,CAAAhB,SAAA;EAAAyB,KAAA;AAAA,IAAAD,GAAA;AAAA,IACFE,kBAAA;AACFhB,QAAA,CAAAgB,kBAAA","ignoreList":[]}
1
+ {"version":3,"file":"ScrollView.native.js","names":[],"sources":["jsx/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,211 @@
1
+ import { View } from "@tamagui/web";
2
+ import * as React from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ const View$1 = View;
6
+ function mergeRefs(...refs) {
7
+ return (node) => {
8
+ for (const ref of refs) {
9
+ if (!ref) continue;
10
+ if (typeof ref === "function") ref(node);
11
+ else ref.current = node;
12
+ }
13
+ };
14
+ }
15
+ function normalizeScrollEvent(e) {
16
+ const target = e.target;
17
+ return {
18
+ nativeEvent: {
19
+ contentOffset: {
20
+ get x() {
21
+ return target.scrollLeft;
22
+ },
23
+ get y() {
24
+ return target.scrollTop;
25
+ }
26
+ },
27
+ contentSize: {
28
+ get height() {
29
+ return target.scrollHeight;
30
+ },
31
+ get width() {
32
+ return target.scrollWidth;
33
+ }
34
+ },
35
+ layoutMeasurement: {
36
+ get height() {
37
+ return target.offsetHeight;
38
+ },
39
+ get width() {
40
+ return target.offsetWidth;
41
+ }
42
+ }
43
+ },
44
+ timeStamp: Date.now()
45
+ };
46
+ }
47
+ function shouldEmitScrollEvent(lastTick, eventThrottle) {
48
+ const timeSinceLastTick = Date.now() - lastTick;
49
+ return eventThrottle > 0 && timeSinceLastTick >= eventThrottle;
50
+ }
51
+ function resolveStyles(...inputs) {
52
+ return inputs.flat(Infinity).filter(Boolean);
53
+ }
54
+ function joinClassNames(...parts) {
55
+ const joined = parts.filter(Boolean).join(" ").trim();
56
+ return joined || void 0;
57
+ }
58
+ const commonStyle = {
59
+ flexGrow: 1,
60
+ flexShrink: 1
61
+ };
62
+ const styles = {
63
+ baseVertical: {
64
+ ...commonStyle,
65
+ flexDirection: "column",
66
+ overflowX: "hidden",
67
+ overflowY: "auto"
68
+ },
69
+ baseHorizontal: {
70
+ ...commonStyle,
71
+ flexDirection: "row",
72
+ overflowX: "auto",
73
+ overflowY: "hidden"
74
+ },
75
+ contentContainerHorizontal: { flexDirection: "row" },
76
+ contentContainerCenterContent: {
77
+ justifyContent: "center",
78
+ flexGrow: 1
79
+ },
80
+ stickyHeader: {
81
+ position: "sticky",
82
+ top: 0,
83
+ zIndex: 10
84
+ },
85
+ pagingEnabledHorizontal: { scrollSnapType: "x mandatory" },
86
+ pagingEnabledVertical: { scrollSnapType: "y mandatory" },
87
+ pagingEnabledChild: { scrollSnapAlign: "start" },
88
+ scrollDisabled: {
89
+ overflowX: "hidden",
90
+ overflowY: "hidden",
91
+ touchAction: "none"
92
+ }
93
+ };
94
+ const WebScrollView = React.forwardRef((props, forwardedRef) => {
95
+ 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;
96
+ const scrollNodeRef = React.useRef(null);
97
+ const innerViewRef = React.useRef(null);
98
+ const scrollState = React.useRef({
99
+ isScrolling: false,
100
+ scrollLastTick: 0
101
+ });
102
+ const scrollTimeout = React.useRef(null);
103
+ const scrollTo = (options) => {
104
+ const node = scrollNodeRef.current;
105
+ if (node == null) return;
106
+ const { x = 0, y = 0, animated = true } = options || {};
107
+ if (typeof node.scroll === "function") {
108
+ node.scroll({
109
+ top: y,
110
+ left: x,
111
+ behavior: animated ? "smooth" : "auto"
112
+ });
113
+ } else {
114
+ node.scrollLeft = x;
115
+ node.scrollTop = y;
116
+ }
117
+ };
118
+ const scrollToEnd = (options) => {
119
+ const node = scrollNodeRef.current;
120
+ if (node == null) return;
121
+ const animated = (options && options.animated) !== false;
122
+ const x = horizontal ? node.scrollWidth : 0;
123
+ const y = horizontal ? 0 : node.scrollHeight;
124
+ scrollTo({
125
+ x,
126
+ y,
127
+ animated
128
+ });
129
+ };
130
+ const setScrollNodeRef = React.useCallback((node) => {
131
+ scrollNodeRef.current = node;
132
+ if (node != null) {
133
+ node.getScrollResponder = () => node;
134
+ node.getScrollableNode = () => node;
135
+ node.getInnerViewNode = () => innerViewRef.current;
136
+ node.getInnerViewRef = () => innerViewRef.current;
137
+ node.getNativeScrollRef = () => node;
138
+ node.scrollTo = scrollTo;
139
+ node.scrollToEnd = scrollToEnd;
140
+ node.flashScrollIndicators = () => {};
141
+ }
142
+ mergeRefs(forwardedRef)(node);
143
+ }, [forwardedRef, horizontal]);
144
+ function handleScroll(e) {
145
+ e.stopPropagation();
146
+ if (e.target !== scrollNodeRef.current) return;
147
+ if (scrollTimeout.current != null) {
148
+ clearTimeout(scrollTimeout.current);
149
+ }
150
+ scrollTimeout.current = setTimeout(() => {
151
+ scrollState.current.isScrolling = false;
152
+ onScroll?.(normalizeScrollEvent(e));
153
+ }, 100);
154
+ if (scrollState.current.isScrolling) {
155
+ if (shouldEmitScrollEvent(scrollState.current.scrollLastTick, scrollEventThrottle)) {
156
+ scrollState.current.scrollLastTick = Date.now();
157
+ onScroll?.(normalizeScrollEvent(e));
158
+ }
159
+ } else {
160
+ scrollState.current.isScrolling = true;
161
+ scrollState.current.scrollLastTick = Date.now();
162
+ onScroll?.(normalizeScrollEvent(e));
163
+ }
164
+ }
165
+ const handleContentLayout = onContentSizeChange ? (e) => {
166
+ const { width, height } = e.nativeEvent.layout;
167
+ onContentSizeChange(width, height);
168
+ } : void 0;
169
+ const hasStickyHeaderIndices = !horizontal && Array.isArray(stickyHeaderIndices);
170
+ const renderedChildren = hasStickyHeaderIndices || pagingEnabled ? React.Children.map(children, (child, i) => {
171
+ const isSticky = hasStickyHeaderIndices && stickyHeaderIndices.indexOf(i) > -1;
172
+ if (child != null && (isSticky || pagingEnabled)) {
173
+ const resolvedStyle = resolveStyles(isSticky && styles.stickyHeader, pagingEnabled && styles.pagingEnabledChild);
174
+ return /* @__PURE__ */ jsx(View$1, {
175
+ style: resolvedStyle,
176
+ children: child
177
+ });
178
+ }
179
+ return child;
180
+ }) : children;
181
+ const contentStyle = resolveStyles(horizontal && styles.contentContainerHorizontal, centerContent && styles.contentContainerCenterContent, contentContainerStyle);
182
+ const contentContainer = /* @__PURE__ */ jsx(View$1, {
183
+ ref: innerViewRef,
184
+ onLayout: handleContentLayout,
185
+ style: contentStyle,
186
+ children: renderedChildren
187
+ });
188
+ const baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;
189
+ const pagingEnabledStyle = horizontal ? styles.pagingEnabledHorizontal : styles.pagingEnabledVertical;
190
+ const hideHorizontalScrollbar = showsHorizontalScrollIndicator === false;
191
+ const hideVerticalScrollbar = showsVerticalScrollIndicator === false;
192
+ const extraClassName = (hideHorizontalScrollbar ? " _hsb-x" : "") + (hideVerticalScrollbar ? " _hsb-y" : "");
193
+ const scrollStyle = resolveStyles(baseStyle, pagingEnabled && pagingEnabledStyle, style, !scrollEnabled && styles.scrollDisabled);
194
+ const scrollView = /* @__PURE__ */ jsx(View$1, {
195
+ ...rest,
196
+ className: joinClassNames(rest.className, extraClassName),
197
+ ref: setScrollNodeRef,
198
+ onScroll: handleScroll,
199
+ style: scrollStyle,
200
+ children: contentContainer
201
+ });
202
+ if (refreshControl) {
203
+ const refreshStyle = resolveStyles(baseStyle, style);
204
+ return React.cloneElement(refreshControl, { style: refreshStyle }, scrollView);
205
+ }
206
+ return scrollView;
207
+ });
208
+ WebScrollView.displayName = "ScrollView";
209
+
210
+ export { WebScrollView };
211
+ //# sourceMappingURL=WebScrollView.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebScrollView.js","names":["View","TamaguiView"],"sources":["jsx/WebScrollView.js"],"sourcesContent":["import { View as TamaguiView } from \"@tamagui/web\";\nimport * as React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nconst View = TamaguiView;\nfunction mergeRefs(...refs) {\n return (node) => {\n for (const ref of refs) {\n if (!ref) continue;\n if (typeof ref === \"function\") ref(node);\n else ref.current = node;\n }\n };\n}\nfunction normalizeScrollEvent(e) {\n const target = e.target;\n return {\n nativeEvent: {\n contentOffset: {\n get x() {\n return target.scrollLeft;\n },\n get y() {\n return target.scrollTop;\n }\n },\n contentSize: {\n get height() {\n return target.scrollHeight;\n },\n get width() {\n return target.scrollWidth;\n }\n },\n layoutMeasurement: {\n get height() {\n return target.offsetHeight;\n },\n get width() {\n return target.offsetWidth;\n }\n }\n },\n timeStamp: Date.now()\n };\n}\nfunction shouldEmitScrollEvent(lastTick, eventThrottle) {\n const timeSinceLastTick = Date.now() - lastTick;\n return eventThrottle > 0 && timeSinceLastTick >= eventThrottle;\n}\nfunction resolveStyles(...inputs) {\n return inputs.flat(Infinity).filter(Boolean);\n}\nfunction joinClassNames(...parts) {\n const joined = parts.filter(Boolean).join(\" \").trim();\n return joined || void 0;\n}\nconst commonStyle = {\n flexGrow: 1,\n flexShrink: 1\n};\nconst styles = {\n baseVertical: {\n ...commonStyle,\n flexDirection: \"column\",\n overflowX: \"hidden\",\n overflowY: \"auto\"\n },\n baseHorizontal: {\n ...commonStyle,\n flexDirection: \"row\",\n overflowX: \"auto\",\n overflowY: \"hidden\"\n },\n contentContainerHorizontal: {\n flexDirection: \"row\"\n },\n contentContainerCenterContent: {\n justifyContent: \"center\",\n flexGrow: 1\n },\n stickyHeader: {\n position: \"sticky\",\n top: 0,\n zIndex: 10\n },\n pagingEnabledHorizontal: {\n scrollSnapType: \"x mandatory\"\n },\n pagingEnabledVertical: {\n scrollSnapType: \"y mandatory\"\n },\n pagingEnabledChild: {\n scrollSnapAlign: \"start\"\n },\n scrollDisabled: {\n overflowX: \"hidden\",\n overflowY: \"hidden\",\n touchAction: \"none\"\n }\n};\nconst WebScrollView = React.forwardRef(\n (props, forwardedRef) => {\n const {\n children,\n contentContainerStyle,\n horizontal,\n onContentSizeChange,\n onScroll,\n refreshControl,\n stickyHeaderIndices,\n pagingEnabled,\n centerContent,\n scrollEnabled = true,\n scrollEventThrottle = 0,\n showsHorizontalScrollIndicator,\n showsVerticalScrollIndicator,\n style,\n // strip react-native-only props that shouldn't reach the DOM\n keyboardShouldPersistTaps,\n keyboardDismissMode,\n contentOffset,\n contentInset,\n contentInsetAdjustmentBehavior,\n decelerationRate,\n directionalLockEnabled,\n disableIntervalMomentum,\n disableScrollViewPanResponder,\n endFillColor,\n fadingEdgeLength,\n indicatorStyle,\n invertStickyHeaders,\n maintainVisibleContentPosition,\n maximumZoomScale,\n minimumZoomScale,\n nestedScrollEnabled,\n onScrollToTop,\n overScrollMode,\n pinchGestureEnabled,\n removeClippedSubviews,\n scrollIndicatorInsets,\n scrollPerfTag,\n scrollToOverflowEnabled,\n snapToAlignment,\n snapToEnd,\n snapToInterval,\n snapToOffsets,\n snapToStart,\n bounces,\n ...rest\n } = props;\n const scrollNodeRef = React.useRef(null);\n const innerViewRef = React.useRef(null);\n const scrollState = React.useRef({ isScrolling: false, scrollLastTick: 0 });\n const scrollTimeout = React.useRef(null);\n const scrollTo = (options) => {\n const node = scrollNodeRef.current;\n if (node == null) return;\n const { x = 0, y = 0, animated = true } = options || {};\n if (typeof node.scroll === \"function\") {\n node.scroll({ top: y, left: x, behavior: animated ? \"smooth\" : \"auto\" });\n } else {\n node.scrollLeft = x;\n node.scrollTop = y;\n }\n };\n const scrollToEnd = (options) => {\n const node = scrollNodeRef.current;\n if (node == null) return;\n const animated = (options && options.animated) !== false;\n const x = horizontal ? node.scrollWidth : 0;\n const y = horizontal ? 0 : node.scrollHeight;\n scrollTo({ x, y, animated });\n };\n const setScrollNodeRef = React.useCallback(\n (node) => {\n scrollNodeRef.current = node;\n if (node != null) {\n node.getScrollResponder = () => node;\n node.getScrollableNode = () => node;\n node.getInnerViewNode = () => innerViewRef.current;\n node.getInnerViewRef = () => innerViewRef.current;\n node.getNativeScrollRef = () => node;\n node.scrollTo = scrollTo;\n node.scrollToEnd = scrollToEnd;\n node.flashScrollIndicators = () => {\n };\n }\n mergeRefs(forwardedRef)(node);\n },\n [forwardedRef, horizontal]\n );\n function handleScroll(e) {\n e.stopPropagation();\n if (e.target !== scrollNodeRef.current) return;\n if (scrollTimeout.current != null) {\n clearTimeout(scrollTimeout.current);\n }\n scrollTimeout.current = setTimeout(() => {\n scrollState.current.isScrolling = false;\n onScroll?.(normalizeScrollEvent(e));\n }, 100);\n if (scrollState.current.isScrolling) {\n if (shouldEmitScrollEvent(scrollState.current.scrollLastTick, scrollEventThrottle)) {\n scrollState.current.scrollLastTick = Date.now();\n onScroll?.(normalizeScrollEvent(e));\n }\n } else {\n scrollState.current.isScrolling = true;\n scrollState.current.scrollLastTick = Date.now();\n onScroll?.(normalizeScrollEvent(e));\n }\n }\n const handleContentLayout = onContentSizeChange ? (e) => {\n const { width, height } = e.nativeEvent.layout;\n onContentSizeChange(width, height);\n } : void 0;\n const hasStickyHeaderIndices = !horizontal && Array.isArray(stickyHeaderIndices);\n const renderedChildren = hasStickyHeaderIndices || pagingEnabled ? React.Children.map(children, (child, i) => {\n const isSticky = hasStickyHeaderIndices && stickyHeaderIndices.indexOf(i) > -1;\n if (child != null && (isSticky || pagingEnabled)) {\n const resolvedStyle = resolveStyles(\n isSticky && styles.stickyHeader,\n pagingEnabled && styles.pagingEnabledChild\n );\n return /* @__PURE__ */ jsx(View, { style: resolvedStyle, children: child });\n }\n return child;\n }) : children;\n const contentStyle = resolveStyles(\n horizontal && styles.contentContainerHorizontal,\n centerContent && styles.contentContainerCenterContent,\n contentContainerStyle\n );\n const contentContainer = /* @__PURE__ */ jsx(View, { ref: innerViewRef, onLayout: handleContentLayout, style: contentStyle, children: renderedChildren });\n const baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;\n const pagingEnabledStyle = horizontal ? styles.pagingEnabledHorizontal : styles.pagingEnabledVertical;\n const hideHorizontalScrollbar = showsHorizontalScrollIndicator === false;\n const hideVerticalScrollbar = showsVerticalScrollIndicator === false;\n const extraClassName = (hideHorizontalScrollbar ? \" _hsb-x\" : \"\") + (hideVerticalScrollbar ? \" _hsb-y\" : \"\");\n const scrollStyle = resolveStyles(\n baseStyle,\n pagingEnabled && pagingEnabledStyle,\n style,\n !scrollEnabled && styles.scrollDisabled\n );\n const scrollView = /* @__PURE__ */ jsx(\n View,\n {\n ...rest,\n className: joinClassNames(rest.className, extraClassName),\n ref: setScrollNodeRef,\n onScroll: handleScroll,\n style: scrollStyle,\n children: contentContainer\n }\n );\n if (refreshControl) {\n const refreshStyle = resolveStyles(baseStyle, style);\n return React.cloneElement(\n refreshControl,\n {\n style: refreshStyle\n },\n scrollView\n );\n }\n return scrollView;\n }\n);\nWebScrollView.displayName = \"ScrollView\";\nexport {\n WebScrollView\n};\n//# sourceMappingURL=WebScrollView.js.map\n"],"mappings":";;;;;AAGA,MAAMA,SAAOC;AACb,SAAS,UAAU,GAAG,MAAM;CAC1B,QAAQ,SAAS;EACf,KAAK,MAAM,OAAO,MAAM;GACtB,IAAI,CAAC,KAAK;GACV,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;QAClC,IAAI,UAAU;EACrB;CACF;AACF;AACA,SAAS,qBAAqB,GAAG;CAC/B,MAAM,SAAS,EAAE;CACjB,OAAO;EACL,aAAa;GACX,eAAe;IACb,IAAI,IAAI;KACN,OAAO,OAAO;IAChB;IACA,IAAI,IAAI;KACN,OAAO,OAAO;IAChB;GACF;GACA,aAAa;IACX,IAAI,SAAS;KACX,OAAO,OAAO;IAChB;IACA,IAAI,QAAQ;KACV,OAAO,OAAO;IAChB;GACF;GACA,mBAAmB;IACjB,IAAI,SAAS;KACX,OAAO,OAAO;IAChB;IACA,IAAI,QAAQ;KACV,OAAO,OAAO;IAChB;GACF;EACF;EACA,WAAW,KAAK,IAAI;CACtB;AACF;AACA,SAAS,sBAAsB,UAAU,eAAe;CACtD,MAAM,oBAAoB,KAAK,IAAI,IAAI;CACvC,OAAO,gBAAgB,KAAK,qBAAqB;AACnD;AACA,SAAS,cAAc,GAAG,QAAQ;CAChC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,OAAO,OAAO;AAC7C;AACA,SAAS,eAAe,GAAG,OAAO;CAChC,MAAM,SAAS,MAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;CACpD,OAAO,UAAU,KAAK;AACxB;AACA,MAAM,cAAc;CAClB,UAAU;CACV,YAAY;AACd;AACA,MAAM,SAAS;CACb,cAAc;EACZ,GAAG;EACH,eAAe;EACf,WAAW;EACX,WAAW;CACb;CACA,gBAAgB;E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