@tarojs/components-react 4.1.9-beta.1 → 4.1.9-beta.1-patch.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 (32) hide show
  1. package/dist/components/picker/index.js +22 -3
  2. package/dist/components/picker/index.js.map +1 -1
  3. package/dist/components/picker/picker-group.js +242 -81
  4. package/dist/components/picker/picker-group.js.map +1 -1
  5. package/dist/components/scroll-view/index.js +104 -30
  6. package/dist/components/scroll-view/index.js.map +1 -1
  7. package/dist/contexts/ScrollElementContext.js +6 -0
  8. package/dist/contexts/ScrollElementContext.js.map +1 -0
  9. package/dist/index.css +1 -1
  10. package/dist/index.js +1 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/original/components/picker/index.js +22 -3
  13. package/dist/original/components/picker/index.js.map +1 -1
  14. package/dist/original/components/picker/picker-group.js +242 -81
  15. package/dist/original/components/picker/picker-group.js.map +1 -1
  16. package/dist/original/components/picker/style/index.scss +146 -46
  17. package/dist/original/components/scroll-view/index.js +104 -30
  18. package/dist/original/components/scroll-view/index.js.map +1 -1
  19. package/dist/original/contexts/ScrollElementContext.js +6 -0
  20. package/dist/original/contexts/ScrollElementContext.js.map +1 -0
  21. package/dist/original/index.js +1 -0
  22. package/dist/original/index.js.map +1 -1
  23. package/dist/solid/components/picker/index.js +33 -14
  24. package/dist/solid/components/picker/index.js.map +1 -1
  25. package/dist/solid/components/picker/picker-group.js +243 -86
  26. package/dist/solid/components/picker/picker-group.js.map +1 -1
  27. package/dist/solid/components/scroll-view/index.js +109 -35
  28. package/dist/solid/components/scroll-view/index.js.map +1 -1
  29. package/dist/solid/contexts/ScrollElementContext.js +6 -0
  30. package/dist/solid/contexts/ScrollElementContext.js.map +1 -0
  31. package/dist/solid/index.css +1 -1
  32. package/package.json +6 -6
@@ -1,8 +1,9 @@
1
1
  import './style/index.scss';
2
2
  import { isFunction } from '@tarojs/shared';
3
3
  import classNames from 'classnames';
4
+ import { ScrollElementContext } from '../../contexts/ScrollElementContext.js';
4
5
  import { throttle, createForwardRefComponent } from '../../utils/index.js';
5
- import { useRef, useEffect } from '../../utils/hooks.react.js';
6
+ import { useRef, useState, useEffect } from '../../utils/hooks.react.js';
6
7
  import { jsx } from 'react/jsx-runtime';
7
8
 
8
9
  function easeOutScroll() {
@@ -30,16 +31,18 @@ function easeOutScroll() {
30
31
  }
31
32
  step();
32
33
  }
34
+ /** 未开启的滚动轴使用 nearest 避免原生 scrollIntoView 沿该轴滚动整页 */
33
35
  function scrollIntoView() {
34
36
  let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
35
- let isHorizontal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
36
- let animated = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
37
- let scrollIntoViewAlignment = arguments.length > 3 ? arguments[3] : undefined;
37
+ let animated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
38
+ let scrollX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
39
+ let scrollY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
40
+ let scrollIntoViewAlignment = arguments.length > 4 ? arguments[4] : undefined;
38
41
  var _a;
39
42
  (_a = document.querySelector(`#${id}`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
40
43
  behavior: animated ? 'smooth' : 'auto',
41
- block: !isHorizontal ? scrollIntoViewAlignment || 'center' : 'center',
42
- inline: isHorizontal ? scrollIntoViewAlignment || 'start' : 'start'
44
+ block: scrollY ? scrollIntoViewAlignment || 'center' : 'nearest',
45
+ inline: scrollX ? scrollIntoViewAlignment || 'start' : 'nearest'
43
46
  });
44
47
  }
45
48
  function scrollVertical(container, scrollTop, top, isAnimation) {
@@ -63,9 +66,14 @@ function scrollHorizontal(container, scrollLeft, left, isAnimation) {
63
66
  scrollLeft.current = left;
64
67
  }
65
68
  function ScrollView(props) {
69
+ var _a;
66
70
  const _scrollTop = useRef(null);
67
71
  const _scrollLeft = useRef(null);
68
72
  const container = useRef(null);
73
+ const scrollEndTimerRef = useRef(null);
74
+ const isScrollingRef = useRef(false);
75
+ const isInitializedRef = useRef(false);
76
+ const [containerHeight, setContainerHeight] = useState(0);
69
77
  const onTouchMove = e => {
70
78
  e.stopPropagation();
71
79
  };
@@ -73,35 +81,33 @@ function ScrollView(props) {
73
81
  let isInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
74
82
  // scrollIntoView
75
83
  if (props.scrollIntoView && typeof props.scrollIntoView === 'string' && document && document.querySelector && document.querySelector(`#${props.scrollIntoView}`)) {
76
- const isHorizontal = props.scrollX && !props.scrollY;
77
84
  if (isInit) {
78
- setTimeout(() => scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, isHorizontal, props.scrollIntoViewAlignment), 500);
85
+ setTimeout(() => scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, !!props.scrollX, !!props.scrollY, props.scrollIntoViewAlignment), 500);
79
86
  } else {
80
- scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, isHorizontal, props.scrollIntoViewAlignment);
87
+ scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, !!props.scrollX, !!props.scrollY, props.scrollIntoViewAlignment);
81
88
  }
82
89
  } else {
83
90
  const isAnimation = !!props.scrollWithAnimation;
84
91
  // Y 轴滚动
85
92
  if (props.scrollY && typeof props.scrollTop === 'number' && props.scrollTop !== _scrollTop.current) {
86
- if (isInit) {
87
- setTimeout(() => scrollVertical(container, _scrollTop, props.scrollTop, isAnimation), 10);
88
- } else {
89
- scrollVertical(container, _scrollTop, props.scrollTop, isAnimation);
90
- }
93
+ setTimeout(() => scrollVertical(container, _scrollTop, props.scrollTop, isAnimation), 10);
91
94
  }
92
95
  // X 轴滚动
93
96
  if (props.scrollX && typeof props.scrollLeft === 'number' && props.scrollLeft !== _scrollLeft.current) {
94
- if (isInit) {
95
- setTimeout(() => scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation), 10);
96
- } else {
97
- scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation);
98
- }
97
+ setTimeout(() => scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation), 10);
99
98
  }
100
99
  }
101
100
  };
102
101
  useEffect(() => {
103
102
  handleScroll(props, true);
103
+ isInitializedRef.current = true;
104
104
  }, []);
105
+ // 监听 scrollTop、scrollLeft、scrollIntoView 的变化(排除初始化)
106
+ useEffect(() => {
107
+ if (isInitializedRef.current && container.current) {
108
+ handleScroll(props, false);
109
+ }
110
+ }, [props.scrollTop, props.scrollLeft, props.scrollIntoView, props.scrollIntoViewAlignment, props.scrollWithAnimation, props.scrollX, props.scrollY]);
105
111
  const {
106
112
  className,
107
113
  style = {},
@@ -163,24 +169,92 @@ function ScrollView(props) {
163
169
  scrollWidth
164
170
  }
165
171
  });
172
+ // 处理滚动开始
173
+ if (!isScrollingRef.current) {
174
+ isScrollingRef.current = true;
175
+ if (props.onScrollStart) {
176
+ props.onScrollStart(e);
177
+ }
178
+ }
179
+ // 清除滚动结束定时器
180
+ if (scrollEndTimerRef.current) {
181
+ clearTimeout(scrollEndTimerRef.current);
182
+ scrollEndTimerRef.current = null;
183
+ }
184
+ // 设置滚动结束定时器(150ms 无滚动事件后触发)
185
+ if (props.onScrollEnd) {
186
+ scrollEndTimerRef.current = setTimeout(() => {
187
+ var _a;
188
+ if (isScrollingRef.current) {
189
+ isScrollingRef.current = false;
190
+ (_a = props.onScrollEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
191
+ }
192
+ scrollEndTimerRef.current = null;
193
+ }, 150);
194
+ }
166
195
  upperAndLowerThrottle(e);
167
196
  onScroll && onScroll(e);
168
197
  };
169
198
  const _onTouchMove = e => {
170
199
  isFunction(props.onTouchMove) ? props.onTouchMove(e) : onTouchMove(e);
171
200
  };
172
- return /*#__PURE__*/jsx("div", {
173
- ref: e => {
174
- if (e) {
175
- container.current = e;
176
- if (props.forwardedRef) props.forwardedRef.current = e;
201
+ const _onTouchStart = e => {
202
+ if (isFunction(props.onTouchStart)) {
203
+ props.onTouchStart(e);
204
+ }
205
+ };
206
+ const _onTouchEnd = e => {
207
+ if (isFunction(props.onTouchEnd)) {
208
+ props.onTouchEnd(e);
209
+ }
210
+ };
211
+ // 清理定时器
212
+ useEffect(() => {
213
+ return () => {
214
+ if (scrollEndTimerRef.current) {
215
+ clearTimeout(scrollEndTimerRef.current);
216
+ scrollEndTimerRef.current = null;
177
217
  }
178
- },
179
- style: style,
180
- className: cls,
181
- onScroll: _onScroll,
182
- onTouchMove: _onTouchMove,
183
- children: props.children
218
+ };
219
+ }, []);
220
+ // ScrollElementContext:嵌套滚动时向子组件提供 scrollRef、containerHeight、startOffset
221
+ useEffect(() => {
222
+ const el = container.current;
223
+ if (!el) return;
224
+ const update = () => {
225
+ if (container.current) {
226
+ setContainerHeight(container.current.clientHeight);
227
+ }
228
+ };
229
+ update();
230
+ const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(update) : null;
231
+ if (ro) {
232
+ ro.observe(el);
233
+ return () => ro.disconnect();
234
+ }
235
+ }, []);
236
+ const scrollElementContextValue = {
237
+ scrollRef: container,
238
+ containerHeight,
239
+ startOffset: (_a = props.startOffset) !== null && _a !== void 0 ? _a : 0
240
+ };
241
+ return /*#__PURE__*/jsx(ScrollElementContext.Provider, {
242
+ value: scrollElementContextValue,
243
+ children: /*#__PURE__*/jsx("div", {
244
+ ref: e => {
245
+ if (e) {
246
+ container.current = e;
247
+ if (props.forwardedRef) props.forwardedRef.current = e;
248
+ }
249
+ },
250
+ style: style,
251
+ className: cls,
252
+ onScroll: _onScroll,
253
+ onTouchMove: _onTouchMove,
254
+ onTouchStart: _onTouchStart,
255
+ onTouchEnd: _onTouchEnd,
256
+ children: props.children
257
+ })
184
258
  });
185
259
  }
186
260
  var index = createForwardRefComponent(ScrollView);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/scroll-view/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport { isFunction } from '@tarojs/shared'\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent, throttle } from '../../utils'\nimport { useEffect, useRef } from '../../utils/hooks'\n\nimport type React from 'react'\n\nfunction easeOutScroll (from = 0, to = 0, callback) {\n if (from === to || typeof from !== 'number') {\n return\n }\n const change = to - from\n const dur = 500\n const sTime = +new Date()\n function linear (t, b, c, d) {\n return (c * t) / d + b\n }\n const isLarger = to >= from\n\n function step () {\n from = linear(+new Date() - sTime, from, change, dur)\n if ((isLarger && from >= to) || (!isLarger && to >= from)) {\n callback(to)\n return\n }\n callback(from)\n requestAnimationFrame(step)\n }\n step()\n}\n\nfunction scrollIntoView (id = '', isHorizontal = false, animated = true, scrollIntoViewAlignment?: ScrollLogicalPosition) {\n document.querySelector(`#${id}`)?.scrollIntoView({\n behavior: animated ? 'smooth' : 'auto',\n block: !isHorizontal ? (scrollIntoViewAlignment || 'center') : 'center',\n inline: isHorizontal ? (scrollIntoViewAlignment || 'start') : 'start'\n })\n}\n\nfunction scrollVertical (container, scrollTop, top, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollTop.current, top, pos => {\n if (container.current) container.current.scrollTop = pos\n })\n } else {\n if (container.current) container.current.scrollTop = top\n }\n scrollTop.current = top\n}\n\nfunction scrollHorizontal (container, scrollLeft, left, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollLeft.current, left, pos => {\n if (container.current) container.current.scrollLeft = pos\n })\n } else {\n if (container.current) container.current.scrollLeft = left\n }\n scrollLeft.current = left\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n scrollX: boolean\n scrollY: boolean\n upperThreshold: number\n lowerThreshold: number\n scrollTop: number\n scrollLeft: number\n scrollIntoView?: string\n scrollIntoViewAlignment?: ScrollLogicalPosition\n scrollWithAnimation: boolean\n enableBackToTop?: boolean\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n onScrollToUpper: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollToLower: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScroll: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchMove: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n showScrollbar?: boolean // 新增参数,默认true\n enhanced?: boolean // 新增参数,默认false\n}\n\nfunction ScrollView (props: IProps) {\n const _scrollTop = useRef<any>(null)\n const _scrollLeft = useRef<any>(null)\n const container = useRef<any>(null)\n const onTouchMove = (e) => {\n e.stopPropagation()\n }\n\n const handleScroll = (props: IProps, isInit = false) => {\n // scrollIntoView\n if (\n props.scrollIntoView &&\n typeof props.scrollIntoView === 'string' &&\n document &&\n document.querySelector &&\n document.querySelector(`#${props.scrollIntoView}`)\n ) {\n const isHorizontal = props.scrollX && !props.scrollY\n if (isInit) {\n setTimeout(() => scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, isHorizontal, props.scrollIntoViewAlignment), 500)\n } else {\n scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, isHorizontal, props.scrollIntoViewAlignment)\n }\n } else {\n const isAnimation = !!props.scrollWithAnimation\n // Y 轴滚动\n if (props.scrollY && typeof props.scrollTop === 'number' && props.scrollTop !== _scrollTop.current) {\n if (isInit) {\n setTimeout(() => scrollVertical(container, _scrollTop, props.scrollTop, isAnimation), 10)\n } else {\n scrollVertical(container, _scrollTop, props.scrollTop, isAnimation)\n }\n }\n // X 轴滚动\n if (props.scrollX && typeof props.scrollLeft === 'number' && props.scrollLeft !== _scrollLeft.current) {\n if (isInit) {\n setTimeout(() => scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation), 10)\n } else {\n scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation)\n }\n }\n }\n }\n\n useEffect(() => {\n handleScroll(props, true)\n }, [])\n\n const {\n className,\n style = {},\n onScroll,\n onScrollToUpper,\n onScrollToLower,\n scrollX,\n scrollY,\n showScrollbar = true, // 默认显示滚动条\n enhanced = false // 默认不增强\n } = props\n let { upperThreshold = 50, lowerThreshold = 50 } = props\n const cls = classNames(\n 'taro-scroll',\n {\n 'taro-scroll-view__scroll-x': scrollX,\n 'taro-scroll-view__scroll-y': scrollY,\n 'taro-scroll--hidebar': enhanced === true && showScrollbar === false,\n 'taro-scroll--enhanced': enhanced === true\n },\n className\n )\n upperThreshold = Number(upperThreshold)\n lowerThreshold = Number(lowerThreshold)\n const upperAndLower = e => {\n if (!container.current) return\n const { offsetWidth, offsetHeight, scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n if (\n onScrollToLower &&\n ((props.scrollY && offsetHeight + scrollTop + lowerThreshold >= scrollHeight) ||\n (props.scrollX && offsetWidth + scrollLeft + lowerThreshold >= scrollWidth))\n ) {\n onScrollToLower(e)\n }\n if (\n onScrollToUpper &&\n ((props.scrollY && scrollTop <= upperThreshold) || (props.scrollX && scrollLeft <= upperThreshold))\n ) {\n onScrollToUpper(e)\n }\n }\n const upperAndLowerThrottle = throttle(upperAndLower, 200)\n const _onScroll = e => {\n const { scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n _scrollLeft.current = scrollLeft\n _scrollTop.current = scrollTop\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n scrollLeft,\n scrollTop,\n scrollHeight,\n scrollWidth\n }\n })\n upperAndLowerThrottle(e)\n onScroll && onScroll(e)\n }\n const _onTouchMove = e => {\n isFunction(props.onTouchMove) ? props.onTouchMove(e) : onTouchMove(e)\n }\n return (\n <div\n ref={e => {\n if (e) {\n container.current = e\n if (props.forwardedRef) props.forwardedRef.current = e\n }\n }}\n style={style}\n className={cls}\n onScroll={_onScroll}\n onTouchMove={_onTouchMove}\n >\n {props.children}\n </div>\n )\n}\n\nexport default createForwardRefComponent(ScrollView)\n"],"names":["easeOutScroll","from","arguments","length","undefined","to","callback","change","dur","sTime","Date","linear","t","b","c","d","isLarger","step","requestAnimationFrame","scrollIntoView","id","isHorizontal","animated","scrollIntoViewAlignment","_a","document","querySelector","behavior","block","inline","scrollVertical","container","scrollTop","top","isAnimation","current","pos","scrollHorizontal","scrollLeft","left","ScrollView","props","_scrollTop","useRef","_scrollLeft","onTouchMove","e","stopPropagation","handleScroll","isInit","scrollX","scrollY","setTimeout","scrollWithAnimation","useEffect","className","style","onScroll","onScrollToUpper","onScrollToLower","showScrollbar","enhanced","upperThreshold","lowerThreshold","cls","classNames","Number","upperAndLower","offsetWidth","offsetHeight","scrollHeight","scrollWidth","upperAndLowerThrottle","throttle","_onScroll","Object","defineProperty","enumerable","writable","value","_onTouchMove","isFunction","_jsx","ref","forwardedRef","children","createForwardRefComponent"],"mappings":";;;;;;;AAUA,SAASA,aAAaA,GAA4B;AAAA,EAAA,IAA1BC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,CAAC;AAAA,EAAA,IAAEG,EAAE,GAAAH,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,CAAC;EAAA,IAAEI,QAAQ,GAAAJ,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA;EAChD,IAAIH,IAAI,KAAKI,EAAE,IAAI,OAAOJ,IAAI,KAAK,QAAQ,EAAE;AAC3C,IAAA;AACF;AACA,EAAA,MAAMM,MAAM,GAAGF,EAAE,GAAGJ,IAAI;EACxB,MAAMO,GAAG,GAAG,GAAG;AACf,EAAA,MAAMC,KAAK,GAAG,CAAC,IAAIC,IAAI,EAAE;EACzB,SAASC,MAAMA,CAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAA;AACzB,IAAA,OAAQD,CAAC,GAAGF,CAAC,GAAIG,CAAC,GAAGF,CAAC;AACxB;AACA,EAAA,MAAMG,QAAQ,GAAGX,EAAE,IAAIJ,IAAI;EAE3B,SAASgB,IAAI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C,UAAU;QACVN,SAAS;QACTsC,YAAY;AACZC,QAAAA;AACD;AACF,KAAA,CAAC;IACFC,qBAAqB,CAAC1B,CAAC,CAAC;AACxBW,IAAAA,QAAQ,IAAIA,QAAQ,CAACX,CAAC,CAAC;GACxB;EACD,MAAMkC,YAAY,GAAGlC,CAAC,IAAG;AACvBmC,IAAAA,UAAU,CAACxC,KAAK,CAACI,WAAW,CAAC,GAAGJ,KAAK,CAACI,WAAW,CAACC,CAAC,CAAC,GAAGD,WAAW,CAACC,CAAC,CAAC;GACtE;AACD,EAAA,oBACEoC,GAAA,CAAA,KAAA,EAAA;IACEC,GAAG,EAAErC,CAAC,IAAG;AACP,MAAA,IAAIA,CAAC,EAAE;QACLf,SAAS,CAACI,OAAO,GAAGW,CAAC;QACrB,IAAIL,KAAK,CAAC2C,YAAY,EAAE3C,KAAK,CAAC2C,YAAY,CAACjD,OAAO,GAAGW,CAAC;AACxD;KACA;AACFU,IAAAA,KAAK,EAAEA,KAAM;AACbD,IAAAA,SAAS,EAAES,GAAI;AACfP,IAAAA,QAAQ,EAAEiB,SAAU;AACpB7B,IAAAA,WAAW,EAAEmC,YAAa;IAAAK,QAAA,EAEzB5C,KAAK,CAAC4C;AAAQ,GACZ,CAAC;AAEV;AAEA,YAAeC,yBAAyB,CAAC9C,UAAU,CAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/scroll-view/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport { isFunction } from '@tarojs/shared'\nimport classNames from 'classnames'\n\nimport { ScrollElementContext } from '../../contexts/ScrollElementContext'\nimport { createForwardRefComponent, throttle } from '../../utils'\nimport { useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\nfunction easeOutScroll (from = 0, to = 0, callback) {\n if (from === to || typeof from !== 'number') {\n return\n }\n const change = to - from\n const dur = 500\n const sTime = +new Date()\n function linear (t, b, c, d) {\n return (c * t) / d + b\n }\n const isLarger = to >= from\n\n function step () {\n from = linear(+new Date() - sTime, from, change, dur)\n if ((isLarger && from >= to) || (!isLarger && to >= from)) {\n callback(to)\n return\n }\n callback(from)\n requestAnimationFrame(step)\n }\n step()\n}\n\n/** 未开启的滚动轴使用 nearest 避免原生 scrollIntoView 沿该轴滚动整页 */\nfunction scrollIntoView (\n id = '',\n animated = true,\n scrollX = false,\n scrollY = false,\n scrollIntoViewAlignment?: ScrollLogicalPosition\n) {\n document.querySelector(`#${id}`)?.scrollIntoView({\n behavior: animated ? 'smooth' : 'auto',\n block: scrollY ? (scrollIntoViewAlignment || 'center') : 'nearest',\n inline: scrollX ? (scrollIntoViewAlignment || 'start') : 'nearest'\n })\n}\n\nfunction scrollVertical (container, scrollTop, top, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollTop.current, top, pos => {\n if (container.current) container.current.scrollTop = pos\n })\n } else {\n if (container.current) container.current.scrollTop = top\n }\n scrollTop.current = top\n}\n\nfunction scrollHorizontal (container, scrollLeft, left, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollLeft.current, left, pos => {\n if (container.current) container.current.scrollLeft = pos\n })\n } else {\n if (container.current) container.current.scrollLeft = left\n }\n scrollLeft.current = left\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n scrollX: boolean\n scrollY: boolean\n upperThreshold: number\n lowerThreshold: number\n scrollTop: number\n scrollLeft: number\n scrollIntoView?: string\n scrollIntoViewAlignment?: ScrollLogicalPosition\n scrollWithAnimation: boolean\n enableBackToTop?: boolean\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n onScrollToUpper: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollToLower: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScroll: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollStart?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollEnd?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchMove: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchStart?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchEnd?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n showScrollbar?: boolean // 新增参数,默认true\n enhanced?: boolean // 新增参数,默认false\n /** 嵌套滚动:内容在滚动容器中的起始偏移(固定头部等场景) */\n startOffset?: number\n}\n\nfunction ScrollView (props: IProps) {\n const _scrollTop = useRef<any>(null)\n const _scrollLeft = useRef<any>(null)\n const container = useRef<any>(null)\n const scrollEndTimerRef = useRef<NodeJS.Timeout | null>(null)\n const isScrollingRef = useRef<boolean>(false)\n const isInitializedRef = useRef<boolean>(false)\n const [containerHeight, setContainerHeight] = useState(0)\n const onTouchMove = (e) => {\n e.stopPropagation()\n }\n\n const handleScroll = (props: IProps, isInit = false) => {\n // scrollIntoView\n if (\n props.scrollIntoView &&\n typeof props.scrollIntoView === 'string' &&\n document &&\n document.querySelector &&\n document.querySelector(`#${props.scrollIntoView}`)\n ) {\n if (isInit) {\n setTimeout(\n () =>\n scrollIntoView(\n props.scrollIntoView,\n props.scrollWithAnimation,\n !!props.scrollX,\n !!props.scrollY,\n props.scrollIntoViewAlignment\n ),\n 500\n )\n } else {\n scrollIntoView(\n props.scrollIntoView,\n props.scrollWithAnimation,\n !!props.scrollX,\n !!props.scrollY,\n props.scrollIntoViewAlignment\n )\n }\n } else {\n const isAnimation = !!props.scrollWithAnimation\n // Y 轴滚动\n if (props.scrollY && typeof props.scrollTop === 'number' && props.scrollTop !== _scrollTop.current) {\n setTimeout(() => scrollVertical(container, _scrollTop, props.scrollTop, isAnimation), 10)\n }\n // X 轴滚动\n if (props.scrollX && typeof props.scrollLeft === 'number' && props.scrollLeft !== _scrollLeft.current) {\n setTimeout(() => scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation), 10)\n }\n }\n }\n\n useEffect(() => {\n handleScroll(props, true)\n isInitializedRef.current = true\n }, [])\n\n // 监听 scrollTop、scrollLeft、scrollIntoView 的变化(排除初始化)\n useEffect(() => {\n if (isInitializedRef.current && container.current) {\n handleScroll(props, false)\n }\n }, [\n props.scrollTop,\n props.scrollLeft,\n props.scrollIntoView,\n props.scrollIntoViewAlignment,\n props.scrollWithAnimation,\n props.scrollX,\n props.scrollY\n ])\n\n const {\n className,\n style = {},\n onScroll,\n onScrollToUpper,\n onScrollToLower,\n scrollX,\n scrollY,\n showScrollbar = true, // 默认显示滚动条\n enhanced = false // 默认不增强\n } = props\n let { upperThreshold = 50, lowerThreshold = 50 } = props\n const cls = classNames(\n 'taro-scroll',\n {\n 'taro-scroll-view__scroll-x': scrollX,\n 'taro-scroll-view__scroll-y': scrollY,\n 'taro-scroll--hidebar': enhanced === true && showScrollbar === false,\n 'taro-scroll--enhanced': enhanced === true\n },\n className\n )\n upperThreshold = Number(upperThreshold)\n lowerThreshold = Number(lowerThreshold)\n const upperAndLower = e => {\n if (!container.current) return\n const { offsetWidth, offsetHeight, scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n if (\n onScrollToLower &&\n ((props.scrollY && offsetHeight + scrollTop + lowerThreshold >= scrollHeight) ||\n (props.scrollX && offsetWidth + scrollLeft + lowerThreshold >= scrollWidth))\n ) {\n onScrollToLower(e)\n }\n if (\n onScrollToUpper &&\n ((props.scrollY && scrollTop <= upperThreshold) || (props.scrollX && scrollLeft <= upperThreshold))\n ) {\n onScrollToUpper(e)\n }\n }\n const upperAndLowerThrottle = throttle(upperAndLower, 200)\n const _onScroll = e => {\n const { scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n _scrollLeft.current = scrollLeft\n _scrollTop.current = scrollTop\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n scrollLeft,\n scrollTop,\n scrollHeight,\n scrollWidth\n }\n })\n\n // 处理滚动开始\n if (!isScrollingRef.current) {\n isScrollingRef.current = true\n if (props.onScrollStart) {\n props.onScrollStart(e)\n }\n }\n\n // 清除滚动结束定时器\n if (scrollEndTimerRef.current) {\n clearTimeout(scrollEndTimerRef.current)\n scrollEndTimerRef.current = null\n }\n\n // 设置滚动结束定时器(150ms 无滚动事件后触发)\n if (props.onScrollEnd) {\n scrollEndTimerRef.current = setTimeout(() => {\n if (isScrollingRef.current) {\n isScrollingRef.current = false\n props.onScrollEnd?.(e)\n }\n scrollEndTimerRef.current = null\n }, 150)\n }\n\n upperAndLowerThrottle(e)\n onScroll && onScroll(e)\n }\n const _onTouchMove = e => {\n isFunction(props.onTouchMove) ? props.onTouchMove(e) : onTouchMove(e)\n }\n const _onTouchStart = e => {\n if (isFunction(props.onTouchStart)) {\n props.onTouchStart(e)\n }\n }\n const _onTouchEnd = e => {\n if (isFunction(props.onTouchEnd)) {\n props.onTouchEnd(e)\n }\n }\n // 清理定时器\n useEffect(() => {\n return () => {\n if (scrollEndTimerRef.current) {\n clearTimeout(scrollEndTimerRef.current)\n scrollEndTimerRef.current = null\n }\n }\n }, [])\n\n // ScrollElementContext:嵌套滚动时向子组件提供 scrollRef、containerHeight、startOffset\n useEffect(() => {\n const el = container.current\n if (!el) return\n const update = () => {\n if (container.current) {\n setContainerHeight(container.current.clientHeight)\n }\n }\n update()\n const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(update) : null\n if (ro) {\n ro.observe(el)\n return () => ro.disconnect()\n }\n }, [])\n\n const scrollElementContextValue = {\n scrollRef: container,\n containerHeight,\n startOffset: props.startOffset ?? 0,\n }\n\n return (\n <ScrollElementContext.Provider value={scrollElementContextValue}>\n <div\n ref={e => {\n if (e) {\n container.current = e\n if (props.forwardedRef) props.forwardedRef.current = e\n }\n }}\n style={style}\n className={cls}\n onScroll={_onScroll}\n onTouchMove={_onTouchMove}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n >\n {props.children}\n </div>\n </ScrollElementContext.Provider>\n )\n}\n\nexport default createForwardRefComponent(ScrollView)\n"],"names":["easeOutScroll","from","arguments","length","undefined","to","callback","change","dur","sTime","Date","linear","t","b","c","d","isLarger","step","requestAnimationFrame","scrollIntoView","id","animated","scrollX","scrollY","scrollIntoViewAlignment","_a","document","querySelector","behavior","block","inline","scrollVertical","container","scrollTop","top","isAnimation","current","pos","scrollHorizontal","scrollLeft","left","ScrollView","props","_scrollTop","useRef","_scrollLeft","scrollEndTimerRef","isScrollingRef","isInitializedRef","containerHeight","setContainerHeight","useState","onTouchMove","e","stopPropagation","handleScroll","isInit","setTimeout","scrollWithAnimation","useEffect","className","style","onScroll","onScrollToUpper","onScrollToLower","showScrollbar","enhanced","upperThreshold","lowerThreshold","cls","classNames","Number","upperAndLower","offsetWidth","offsetHeight","scrollHeight","scrollWidth","upperAndLowerThrottle","throttle","_onScroll","Object","defineProperty","enumerable","writable","value","onScrollStart","clearTimeout","onScrollEnd","call","_onTouchMove","isFunction","_onTouchStart","onTouchStart","_onTouchEnd","onTouchEnd","el","update","clientHeight","ro","ResizeObserver","observe","disconnect","scrollElementContextValue","scrollRef","startOffset","_jsx","ScrollElementContext","Provider","children","ref","forwardedRef","createForwardRefComponent"],"mappings":";;;;;;;;AAWA,SAASA,aAAaA,GAA4B;AAAA,EAAA,IAA1BC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,CAAC;AAAA,EAAA,IAAEG,EAAE,GAAAH,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,CAAC;EAAA,IAAEI,QAAQ,GAAAJ,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA;EAChD,IAAIH,IAAI,KAAKI,EAAE,IAAI,OAAOJ,IAAI,KAAK,QAAQ,EAAE;AAC3C,IAAA;AACF;AACA,EAAA,MAAMM,MAAM,GAAGF,EAAE,GAAGJ,IAAI;EACxB,MAAMO,GAAG,GAAG,GAAG;AACf,EA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M;AACbD,MAAAA,SAAS,EAAES,GAAI;AACfP,MAAAA,QAAQ,EAAEiB,SAAU;AACpB3B,MAAAA,WAAW,EAAEqC,YAAa;AAC1BG,MAAAA,YAAY,EAAED,aAAc;AAC5BG,MAAAA,UAAU,EAAED,WAAY;MAAAe,QAAA,EAEvBlE,KAAK,CAACkE;KACJ;AACP,GAA+B,CAAC;AAEpC;AAEA,YAAeG,yBAAyB,CAACtE,UAAU,CAAC;;;;"}
@@ -0,0 +1,6 @@
1
+ import React__default from 'react';
2
+
3
+ const ScrollElementContext = /*#__PURE__*/React__default.createContext(null);
4
+
5
+ export { ScrollElementContext };
6
+ //# sourceMappingURL=ScrollElementContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollElementContext.js","sources":["../../../src/contexts/ScrollElementContext.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * ScrollElementContext:嵌套滚动场景下,父容器(ScrollView/List)向子组件提供滚动容器信息。\n * 子组件(WaterFlow/List)可从 Context 获取 scrollRef、containerHeight、startOffset,\n * 实现随父容器一起滚动,无需业务方手动传 scrollElement。\n */\nexport interface ScrollElementContextValue {\n /** 外层滚动容器 ref */\n scrollRef: React.MutableRefObject<HTMLElement | null>\n /** 可视区高度 */\n containerHeight: number\n /** 内容在滚动容器中的起始偏移(上方有其他内容时使用) */\n startOffset: number\n /** 内层 WaterFlow 报告 scrollHeight 时调用(List 动高联动等) */\n reportNestedHeightChange?: (scrollHeight: number) => void\n}\n\nexport const ScrollElementContext = React.createContext<ScrollElementContextValue | null>(null)\n"],"names":["ScrollElementContext","React","createContext"],"mappings":";;AAkBO,MAAMA,oBAAoB,gBAAGC,cAAK,CAACC,aAAa,CAAmC,IAAI;;;;"}
@@ -6,6 +6,7 @@ export { default as Input } from './components/input/index.js';
6
6
  export { default as Picker } from './components/picker/index.js';
7
7
  export { default as PullDownRefresh } from './components/pull-down-refresh/index.js';
8
8
  export { default as Refresher } from './components/refresher/index.js';
9
+ export { ScrollElementContext } from './contexts/ScrollElementContext.js';
9
10
  export { default as ScrollView } from './components/scroll-view/index.js';
10
11
  export { Swiper, SwiperItem } from './components/swiper/index.js';
11
12
  export { default as Text } from './components/text/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.react.ts"],"sourcesContent":["/* eslint-disable simple-import-sort/exports */\nexport { Ad } from '@tarojs/components/lib/react'\nexport { AdCustom } from '@tarojs/components/lib/react'\nexport { AnimationVideo } from '@tarojs/components/lib/react'\nexport { AnimationView } from '@tarojs/components/lib/react'\nexport { ArCamera } from '@tarojs/components/lib/react'\nexport { Audio } from '@tarojs/components/lib/react'\nexport { AwemeData } from '@tarojs/components/lib/react'\nexport { Block } from '@tarojs/components/lib/react'\nexport { default as Button } from './components/button'\nexport { Camera } from '@tarojs/components/lib/react'\nexport { Canvas } from '@tarojs/components/lib/react'\nexport { ChannelLive } from '@tarojs/components/lib/react'\nexport { ChannelVideo } from '@tarojs/components/lib/react'\nexport { Checkbox, CheckboxGroup } from '@tarojs/components/lib/react'\nexport { CommentDetail, CommentList } from '@tarojs/components/lib/react'\nexport { ContactButton } from '@tarojs/components/lib/react'\nexport { CoverImage } from '@tarojs/components/lib/react'\nexport { CoverView } from '@tarojs/components/lib/react'\nexport { CustomWrapper } from '@tarojs/components/lib/react'\nexport { DraggableSheet } from '@tarojs/components/lib/react'\nexport { Editor } from '@tarojs/components/lib/react'\nexport { FollowSwan } from '@tarojs/components/lib/react'\nexport { Form } from '@tarojs/components/lib/react'\nexport { FunctionalPageNavigator } from '@tarojs/components/lib/react'\nexport { GridView } from '@tarojs/components/lib/react'\nexport { GridBuilder } from '@tarojs/components/lib/react'\nexport { default as Icon } from './components/icon'\nexport { default as Image } from './components/image'\nexport { InlinePaymentPanel } from '@tarojs/components/lib/react'\nexport { default as Input } from './components/input'\nexport { KeyboardAccessory } from '@tarojs/components/lib/react'\nexport { Label } from '@tarojs/components/lib/react'\nexport { Lifestyle } from '@tarojs/components/lib/react'\nexport { Like } from '@tarojs/components/lib/react'\nexport { LivePlayer } from '@tarojs/components/lib/react'\nexport { LivePusher } from '@tarojs/components/lib/react'\nexport { ListBuilder } from '@tarojs/components/lib/react'\nexport { ListView } from '@tarojs/components/lib/react'\nexport { Login } from '@tarojs/components/lib/react'\nexport { Lottie } from '@tarojs/components/lib/react'\nexport { Map } from '@tarojs/components/lib/react'\nexport { MatchMedia } from '@tarojs/components/lib/react'\nexport { MovableArea, MovableView } from '@tarojs/components/lib/react'\nexport { NavigationBar } from '@tarojs/components/lib/react'\nexport { Navigator } from '@tarojs/components/lib/react'\nexport { NestedScrollBody } from '@tarojs/components/lib/react'\nexport { NestedScrollHeader } from '@tarojs/components/lib/react'\nexport { OfficialAccount } from '@tarojs/components/lib/react'\nexport { OpenData } from '@tarojs/components/lib/react'\nexport { OpenContainer } from '@tarojs/components/lib/react'\nexport { PageContainer } from '@tarojs/components/lib/react'\nexport { PageMeta } from '@tarojs/components/lib/react'\nexport { default as Picker } from './components/picker'\nexport { PickerView, PickerViewColumn } from '@tarojs/components/lib/react'\nexport { Progress } from '@tarojs/components/lib/react'\nexport { default as PullDownRefresh } from './components/pull-down-refresh'\n// export { PullToRefresh } from '@tarojs/components/lib/react'\nexport { default as Refresher } from './components/refresher'\nexport { Radio, RadioGroup } from '@tarojs/components/lib/react'\nexport { RichText } from '@tarojs/components/lib/react'\nexport { RootPortal } from '@tarojs/components/lib/react'\nexport { RtcRoom, RtcRoomItem } from '@tarojs/components/lib/react'\nexport { Script } from '@tarojs/components/lib/react'\nexport { default as ScrollView } from './components/scroll-view'\nexport { ShareElement } from '@tarojs/components/lib/react'\nexport { Slider } from '@tarojs/components/lib/react'\nexport { Snapshot } from '@tarojs/components/lib/react'\nexport { Span } from '@tarojs/components/lib/react'\nexport { NativeSlot, Slot } from '@tarojs/components/lib/react'\nexport { Swiper, SwiperItem } from './components/swiper'\nexport { Switch } from '@tarojs/components/lib/react'\nexport { Tabs } from '@tarojs/components/lib/react'\nexport { default as Text } from './components/text'\nexport { Textarea } from '@tarojs/components/lib/react'\nexport { Video } from '@tarojs/components/lib/react'\nexport { default as View } from './components/view'\nexport { VoipRoom } from '@tarojs/components/lib/react'\nexport { WebView } from '@tarojs/components/lib/react'\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.react.ts"],"sourcesContent":["/* eslint-disable simple-import-sort/exports */\nexport { Ad } from '@tarojs/components/lib/react'\nexport { AdCustom } from '@tarojs/components/lib/react'\nexport { AnimationVideo } from '@tarojs/components/lib/react'\nexport { AnimationView } from '@tarojs/components/lib/react'\nexport { ArCamera } from '@tarojs/components/lib/react'\nexport { Audio } from '@tarojs/components/lib/react'\nexport { AwemeData } from '@tarojs/components/lib/react'\nexport { Block } from '@tarojs/components/lib/react'\nexport { default as Button } from './components/button'\nexport { Camera } from '@tarojs/components/lib/react'\nexport { Canvas } from '@tarojs/components/lib/react'\nexport { ChannelLive } from '@tarojs/components/lib/react'\nexport { ChannelVideo } from '@tarojs/components/lib/react'\nexport { Checkbox, CheckboxGroup } from '@tarojs/components/lib/react'\nexport { CommentDetail, CommentList } from '@tarojs/components/lib/react'\nexport { ContactButton } from '@tarojs/components/lib/react'\nexport { CoverImage } from '@tarojs/components/lib/react'\nexport { CoverView } from '@tarojs/components/lib/react'\nexport { CustomWrapper } from '@tarojs/components/lib/react'\nexport { DraggableSheet } from '@tarojs/components/lib/react'\nexport { Editor } from '@tarojs/components/lib/react'\nexport { FollowSwan } from '@tarojs/components/lib/react'\nexport { Form } from '@tarojs/components/lib/react'\nexport { FunctionalPageNavigator } from '@tarojs/components/lib/react'\nexport { GridView } from '@tarojs/components/lib/react'\nexport { GridBuilder } from '@tarojs/components/lib/react'\nexport { default as Icon } from './components/icon'\nexport { default as Image } from './components/image'\nexport { InlinePaymentPanel } from '@tarojs/components/lib/react'\nexport { default as Input } from './components/input'\nexport { KeyboardAccessory } from '@tarojs/components/lib/react'\nexport { Label } from '@tarojs/components/lib/react'\nexport { Lifestyle } from '@tarojs/components/lib/react'\nexport { Like } from '@tarojs/components/lib/react'\nexport { LivePlayer } from '@tarojs/components/lib/react'\nexport { LivePusher } from '@tarojs/components/lib/react'\nexport { ListBuilder } from '@tarojs/components/lib/react'\nexport { ListView } from '@tarojs/components/lib/react'\nexport { Login } from '@tarojs/components/lib/react'\nexport { Lottie } from '@tarojs/components/lib/react'\nexport { Map } from '@tarojs/components/lib/react'\nexport { MatchMedia } from '@tarojs/components/lib/react'\nexport { MovableArea, MovableView } from '@tarojs/components/lib/react'\nexport { NavigationBar } from '@tarojs/components/lib/react'\nexport { Navigator } from '@tarojs/components/lib/react'\nexport { NestedScrollBody } from '@tarojs/components/lib/react'\nexport { NestedScrollHeader } from '@tarojs/components/lib/react'\nexport { OfficialAccount } from '@tarojs/components/lib/react'\nexport { OpenData } from '@tarojs/components/lib/react'\nexport { OpenContainer } from '@tarojs/components/lib/react'\nexport { PageContainer } from '@tarojs/components/lib/react'\nexport { PageMeta } from '@tarojs/components/lib/react'\nexport { default as Picker } from './components/picker'\nexport { PickerView, PickerViewColumn } from '@tarojs/components/lib/react'\nexport { Progress } from '@tarojs/components/lib/react'\nexport { default as PullDownRefresh } from './components/pull-down-refresh'\n// export { PullToRefresh } from '@tarojs/components/lib/react'\nexport { default as Refresher } from './components/refresher'\nexport { Radio, RadioGroup } from '@tarojs/components/lib/react'\nexport { RichText } from '@tarojs/components/lib/react'\nexport { RootPortal } from '@tarojs/components/lib/react'\nexport { RtcRoom, RtcRoomItem } from '@tarojs/components/lib/react'\nexport { Script } from '@tarojs/components/lib/react'\nexport { ScrollElementContext, type ScrollElementContextValue } from './contexts/ScrollElementContext'\nexport { default as ScrollView } from './components/scroll-view'\nexport { ShareElement } from '@tarojs/components/lib/react'\nexport { Slider } from '@tarojs/components/lib/react'\nexport { Snapshot } from '@tarojs/components/lib/react'\nexport { Span } from '@tarojs/components/lib/react'\nexport { NativeSlot, Slot } from '@tarojs/components/lib/react'\nexport { Swiper, SwiperItem } from './components/swiper'\nexport { Switch } from '@tarojs/components/lib/react'\nexport { Tabs } from '@tarojs/components/lib/react'\nexport { default as Text } from './components/text'\nexport { Textarea } from '@tarojs/components/lib/react'\nexport { Video } from '@tarojs/components/lib/react'\nexport { default as View } from './components/view'\nexport { VoipRoom } from '@tarojs/components/lib/react'\nexport { WebView } from '@tarojs/components/lib/react'\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA"}
@@ -127,9 +127,10 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
127
127
  onCancel,
128
128
  children,
129
129
  formType,
130
- lang
130
+ lang,
131
+ theme = 'light'
131
132
  } = props,
132
- restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "colors", "onChange", "onColumnChange", "onCancel", "children", "formType", "lang"]);
133
+ restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "colors", "onChange", "onColumnChange", "onCancel", "children", "formType", "lang", "theme"]);
133
134
  const indexRef = React__default.useRef([]);
134
135
  const pickerDateRef = React__default.useRef();
135
136
  // 记录是否是用户滚动
@@ -752,9 +753,15 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
752
753
  const clsMask = classNames('taro-picker__mask-overlay', 'taro-picker__animate-fade-in', {
753
754
  'taro-picker__animate-fade-out': state.fadeOut
754
755
  });
755
- const clsSlider = classNames('taro-picker', 'taro-picker__animate-slide-up', {
756
+ const clsSlider = classNames('taro-picker', 'taro-picker__animate-slide-up', `taro-picker-theme-${theme}`, {
756
757
  'taro-picker__animate-slide-down': state.fadeOut
757
758
  });
759
+ const backgroundStyle = colors.backgroundColor ? {
760
+ backgroundColor: colors.backgroundColor
761
+ } : null;
762
+ const titleStyle = colors.titleColor ? {
763
+ color: colors.titleColor
764
+ } : null;
758
765
  // 暴露方法给外部
759
766
  React__default.useImperativeHandle(ref, () => ({
760
767
  showPicker,
@@ -780,11 +787,17 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
780
787
  return [createComponent(View, {
781
788
  className: clsMask,
782
789
  onClick: handleCancel
783
- }), createComponent(View, {
784
- className: clsSlider,
790
+ }), createComponent(View, mergeProps({
791
+ className: clsSlider
792
+ }, backgroundStyle ? {
793
+ style: backgroundStyle
794
+ } : {}, {
785
795
  get children() {
786
- return [createComponent(View, {
787
- className: "taro-picker__hd",
796
+ return [createComponent(View, mergeProps({
797
+ className: "taro-picker__hd"
798
+ }, backgroundStyle ? {
799
+ style: backgroundStyle
800
+ } : {}, {
788
801
  get children() {
789
802
  return [createComponent(View, {
790
803
  className: "taro-picker__action",
@@ -797,10 +810,13 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
797
810
  get children() {
798
811
  return (_a = textProps.cancelText) !== null && _a !== void 0 ? _a : langText.cancel;
799
812
  }
800
- }), memo(() => headerText && createComponent(View, {
801
- className: "taro-picker__title",
813
+ }), memo(() => headerText && createComponent(View, mergeProps({
814
+ className: "taro-picker__title"
815
+ }, titleStyle ? {
816
+ style: titleStyle
817
+ } : {}, {
802
818
  children: headerText
803
- })), createComponent(View, {
819
+ }))), createComponent(View, {
804
820
  className: "taro-picker__action",
805
821
  onClick: handleChange,
806
822
  get style() {
@@ -813,12 +829,15 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
813
829
  }
814
830
  })];
815
831
  }
816
- }), createComponent(View, {
817
- className: "taro-picker__bd",
832
+ })), createComponent(View, mergeProps({
833
+ className: "taro-picker__bd"
834
+ }, backgroundStyle ? {
835
+ style: backgroundStyle
836
+ } : {}, {
818
837
  children: renderPickerGroup
819
- })];
838
+ }))];
820
839
  }
821
- })];
840
+ }))];
822
841
  }
823
842
  }))];
824
843
  }