@tarojs/components-react 4.2.1-beta.1 → 4.2.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/image/index.js +3 -5
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/picker/index.js +35 -76
- package/dist/components/picker/index.js.map +1 -1
- package/dist/components/picker/picker-group.js +127 -477
- package/dist/components/picker/picker-group.js.map +1 -1
- package/dist/components/refresher/index.js +5 -5
- package/dist/components/refresher/index.js.map +1 -1
- package/dist/components/scroll-view/index.js +36 -80
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/original/components/image/index.js +3 -5
- package/dist/original/components/image/index.js.map +1 -1
- package/dist/original/components/image/style/index.scss +1 -5
- package/dist/original/components/picker/index.js +35 -76
- package/dist/original/components/picker/index.js.map +1 -1
- package/dist/original/components/picker/picker-group.js +127 -477
- package/dist/original/components/picker/picker-group.js.map +1 -1
- package/dist/original/components/picker/style/index.scss +8 -9
- package/dist/original/components/refresher/index.js +5 -5
- package/dist/original/components/refresher/index.js.map +1 -1
- package/dist/original/components/scroll-view/index.js +36 -80
- package/dist/original/components/scroll-view/index.js.map +1 -1
- package/dist/original/index.js +2 -6
- package/dist/original/index.js.map +1 -1
- package/dist/solid/components/image/index.js +3 -5
- package/dist/solid/components/image/index.js.map +1 -1
- package/dist/solid/components/picker/index.js +39 -82
- package/dist/solid/components/picker/index.js.map +1 -1
- package/dist/solid/components/picker/picker-group.js +151 -500
- package/dist/solid/components/picker/picker-group.js.map +1 -1
- package/dist/solid/components/refresher/index.js +5 -5
- package/dist/solid/components/refresher/index.js.map +1 -1
- package/dist/solid/components/scroll-view/index.js +40 -84
- package/dist/solid/components/scroll-view/index.js.map +1 -1
- package/dist/solid/index.css +1 -1
- package/dist/solid/index.js +1 -1
- package/package.json +6 -8
- package/dist/components/map/MapContext.js +0 -628
- package/dist/components/map/MapContext.js.map +0 -1
- package/dist/components/map/MapCustomCallout.js +0 -91
- package/dist/components/map/MapCustomCallout.js.map +0 -1
- package/dist/components/map/common.js +0 -4
- package/dist/components/map/common.js.map +0 -1
- package/dist/components/map/createMapContext.js +0 -34
- package/dist/components/map/createMapContext.js.map +0 -1
- package/dist/components/map/handler.js +0 -50
- package/dist/components/map/handler.js.map +0 -1
- package/dist/components/map/index.js +0 -329
- package/dist/components/map/index.js.map +0 -1
- package/dist/components/switch/index.js +0 -125
- package/dist/components/switch/index.js.map +0 -1
- package/dist/components/switch/style/index.scss.js +0 -4
- package/dist/components/switch/style/index.scss.js.map +0 -1
- package/dist/contexts/ScrollElementContext.js +0 -6
- package/dist/contexts/ScrollElementContext.js.map +0 -1
- package/dist/original/components/map/MapContext.js +0 -628
- package/dist/original/components/map/MapContext.js.map +0 -1
- package/dist/original/components/map/MapCustomCallout.js +0 -91
- package/dist/original/components/map/MapCustomCallout.js.map +0 -1
- package/dist/original/components/map/common.js +0 -4
- package/dist/original/components/map/common.js.map +0 -1
- package/dist/original/components/map/createMapContext.js +0 -34
- package/dist/original/components/map/createMapContext.js.map +0 -1
- package/dist/original/components/map/handler.js +0 -50
- package/dist/original/components/map/handler.js.map +0 -1
- package/dist/original/components/map/index.js +0 -329
- package/dist/original/components/map/index.js.map +0 -1
- package/dist/original/components/switch/index.js +0 -125
- package/dist/original/components/switch/index.js.map +0 -1
- package/dist/original/components/switch/style/index.scss +0 -35
- package/dist/original/contexts/ScrollElementContext.js +0 -6
- package/dist/original/contexts/ScrollElementContext.js.map +0 -1
- package/dist/solid/contexts/ScrollElementContext.js +0 -6
- package/dist/solid/contexts/ScrollElementContext.js.map +0 -1
|
@@ -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 { 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\n/** H5 等环境下 scrollTop 为整数,与带亚像素的受控值比较时允许该误差,避免反复 set scrollTop 与 scrollIntoView 打架 */\nconst CONTROLLED_SCROLL_EPSILON = 0.5\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 /** 与 props.scrollIntoView 比对,同 id 时只走受控 scrollTop,避免与上次锚点反复互顶 */\n const lastAppliedScrollIntoViewIdRef = useRef<string | null>(null)\n const [containerHeight, setContainerHeight] = useState(0)\n const onTouchMove = (e) => {\n e.stopPropagation()\n }\n\n const applyControlledScrollTopLeft = (p: IProps) => {\n const isAnimation = !!p.scrollWithAnimation\n const eps = CONTROLLED_SCROLL_EPSILON\n if (p.scrollY && typeof p.scrollTop === 'number' &&\n (_scrollTop.current === null || Math.abs(p.scrollTop - _scrollTop.current) >= eps)) {\n setTimeout(() => scrollVertical(container, _scrollTop, p.scrollTop, isAnimation), 10)\n }\n if (p.scrollX && typeof p.scrollLeft === 'number' &&\n (_scrollLeft.current === null || Math.abs(p.scrollLeft - _scrollLeft.current) >= eps)) {\n setTimeout(() => scrollHorizontal(container, _scrollLeft, p.scrollLeft, isAnimation), 10)\n }\n }\n\n const handleScroll = (props: IProps, isInit = false) => {\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 applyControlledScrollTopLeft(props)\n }\n }\n\n useEffect(() => {\n handleScroll(props, true)\n isInitializedRef.current = true\n }, [])\n\n // scrollTop / scrollLeft / scrollIntoView 受控同步(跳过 mount 时的 init effect)\n useEffect(() => {\n if (!isInitializedRef.current || !container.current) return\n\n const sitv = props.scrollIntoView\n const sitvOk = Boolean(\n sitv &&\n typeof sitv === 'string' &&\n document &&\n document.querySelector &&\n document.querySelector(`#${sitv}`)\n )\n\n if (sitvOk) {\n if (sitv !== lastAppliedScrollIntoViewIdRef.current) {\n scrollIntoView(\n sitv,\n props.scrollWithAnimation,\n !!props.scrollX,\n !!props.scrollY,\n props.scrollIntoViewAlignment\n )\n lastAppliedScrollIntoViewIdRef.current = typeof sitv === 'string' ? sitv : null\n } else {\n applyControlledScrollTopLeft(props)\n }\n } else {\n lastAppliedScrollIntoViewIdRef.current = null\n applyControlledScrollTopLeft(props)\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","CONTROLLED_SCROLL_EPSILON","ScrollView","props","_scrollTop","useRef","_scrollLeft","scrollEndTimerRef","isScrollingRef","isInitializedRef","lastAppliedScrollIntoViewIdRef","containerHeight","setContainerHeight","useState","onTouchMove","e","stopPropagation","applyControlledScrollTopLeft","p","scrollWithAnimation","eps","Math","abs","setTimeout","handleScroll","isInit","useEffect","sitv","sitvOk","Boolean","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,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,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"}
|
|
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 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\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 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 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 }, [props.scrollTop, props.scrollLeft, props.scrollIntoView])\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 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 onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\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","scrollEndTimerRef","isScrollingRef","isInitializedRef","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","onScrollStart","clearTimeout","onScrollEnd","call","_onTouchMove","isFunction","_onTouchStart","onTouchStart","_onTouchEnd","onTouchEnd","_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,IAAIA,GAAA;AACXhB,IAAAA,IAAI,GAAGU,MAAM,CAAC,CAAC,IAAID,IAAI,EAA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|
-
export { Ad, AdCustom, AnimationVideo, AnimationView, ArCamera, Audio, AwemeData, Block, Camera, Canvas, ChannelLive, ChannelVideo, Checkbox, CheckboxGroup, CommentDetail, CommentList, ContactButton, CoverImage, CoverView, CustomWrapper, DraggableSheet, Editor, FollowSwan, Form, FunctionalPageNavigator, GridBuilder, GridView, InlinePaymentPanel, KeyboardAccessory, Label, Lifestyle, Like, ListBuilder, ListView, LivePlayer, LivePusher, Login, Lottie, MatchMedia, MovableArea, MovableView, NativeSlot, NavigationBar, Navigator, NestedScrollBody, NestedScrollHeader, OfficialAccount, OpenContainer, OpenData, PageContainer, PageMeta, PickerView, PickerViewColumn, Progress, Radio, RadioGroup, RichText, RootPortal, RtcRoom, RtcRoomItem, Script, ShareElement, Slider, Slot, Snapshot, Span, Tabs, Textarea, Video, VoipRoom, WebView } from '@tarojs/components/lib/react';
|
|
1
|
+
export { Ad, AdCustom, AnimationVideo, AnimationView, ArCamera, Audio, AwemeData, Block, Camera, Canvas, ChannelLive, ChannelVideo, Checkbox, CheckboxGroup, CommentDetail, CommentList, ContactButton, CoverImage, CoverView, CustomWrapper, DraggableSheet, Editor, FollowSwan, Form, FunctionalPageNavigator, GridBuilder, GridView, InlinePaymentPanel, KeyboardAccessory, Label, Lifestyle, Like, ListBuilder, ListView, LivePlayer, LivePusher, Login, Lottie, Map, MatchMedia, MovableArea, MovableView, NativeSlot, NavigationBar, Navigator, NestedScrollBody, NestedScrollHeader, OfficialAccount, OpenContainer, OpenData, PageContainer, PageMeta, PickerView, PickerViewColumn, Progress, Radio, RadioGroup, RichText, RootPortal, RtcRoom, RtcRoomItem, Script, ShareElement, Slider, Slot, Snapshot, Span, Switch, Tabs, Textarea, Video, VoipRoom, WebView } from '@tarojs/components/lib/react';
|
|
2
2
|
export { default as Button } from './components/button/index.js';
|
|
3
3
|
export { default as Icon } from './components/icon/index.js';
|
|
4
4
|
export { default as Image } from './components/image/index.js';
|
|
5
5
|
export { default as Input } from './components/input/index.js';
|
|
6
|
-
export { default as Map } from './components/map/index.js';
|
|
7
6
|
export { default as Picker } from './components/picker/index.js';
|
|
8
7
|
export { default as PullDownRefresh } from './components/pull-down-refresh/index.js';
|
|
9
|
-
export { Refresher } from './components/refresher/index.js';
|
|
10
|
-
export { ScrollElementContext } from './contexts/ScrollElementContext.js';
|
|
8
|
+
export { default as Refresher } from './components/refresher/index.js';
|
|
11
9
|
export { default as ScrollView } from './components/scroll-view/index.js';
|
|
12
10
|
export { Swiper, SwiperItem } from './components/swiper/index.js';
|
|
13
|
-
export { default as Switch } from './components/switch/index.js';
|
|
14
11
|
export { default as Text } from './components/text/index.js';
|
|
15
12
|
export { default as View } from './components/view/index.js';
|
|
16
|
-
export { createMapContext } from './components/map/createMapContext.js';
|
|
17
13
|
|
|
18
14
|
/* eslint-disable simple-import-sort/exports */
|
|
19
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -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 {
|
|
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"}
|
|
@@ -13,18 +13,16 @@ function Image(props) {
|
|
|
13
13
|
const [, setIsLoaded] = useState(false);
|
|
14
14
|
const {
|
|
15
15
|
className,
|
|
16
|
-
style: style$1,
|
|
16
|
+
style: style$1 = {},
|
|
17
17
|
src,
|
|
18
18
|
mode,
|
|
19
19
|
onError,
|
|
20
20
|
lazyLoad,
|
|
21
21
|
imgProps,
|
|
22
|
-
forwardedRef
|
|
23
|
-
disableDefaultSize = false
|
|
22
|
+
forwardedRef
|
|
24
23
|
} = props,
|
|
25
|
-
reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"
|
|
24
|
+
reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"]);
|
|
26
25
|
const cls = classNames('taro-img', {
|
|
27
|
-
'taro-img--with-default-host-size': !disableDefaultSize,
|
|
28
26
|
'taro-img__widthfix': mode === 'widthFix'
|
|
29
27
|
}, className);
|
|
30
28
|
const imgCls = classNames('taro-img__mode-' + (mode || 'scaleToFill').toLowerCase().replace(/\s/g, ''));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent } from '../../utils'\nimport { useCallback, useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n src: string\n mode: string\n onError: () => void\n onLoad: (e) => void\n lazyLoad?: boolean\n imgProps?: Record<string, any>\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent } from '../../utils'\nimport { useCallback, useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n src: string\n mode: string\n onError: () => void\n onLoad: (e) => void\n lazyLoad?: boolean\n imgProps?: Record<string, any>\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n}\n\nfunction Image (props: IProps) {\n const imgRef = useRef<HTMLImageElement | null>(null)\n const observer = useRef<Partial<IntersectionObserver>>({})\n const [, setIsLoaded] = useState(false)\n const {\n className,\n style = {},\n src,\n mode,\n onError,\n lazyLoad,\n imgProps,\n forwardedRef,\n ...reset\n } = props\n\n const cls = classNames(\n 'taro-img',\n {\n 'taro-img__widthfix': mode === 'widthFix'\n },\n className\n )\n const imgCls = classNames(\n 'taro-img__mode-' +\n (mode || 'scaleToFill').toLowerCase().replace(/\\s/g, '')\n )\n\n const imageOnLoad = useCallback((e) => {\n const { onLoad } = props\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n width: e.target.width,\n height: e.target.height\n }\n })\n\n onLoad && onLoad(e)\n }, [props])\n\n useEffect(() => {\n if (lazyLoad) {\n observer.current = new IntersectionObserver(\n entries => {\n // 异步 api 关系\n if (entries[entries.length - 1].isIntersecting) {\n setIsLoaded(true)\n // findDOMNode(this).children[0].src = src\n imgRef.current!.src = src\n }\n },\n {\n rootMargin: '300px 0px'\n }\n )\n observer.current.observe?.(imgRef.current!)\n }\n\n return () => {\n observer.current?.disconnect?.()\n }\n }, [lazyLoad, src])\n\n return (\n <div className={cls} style={style} ref={forwardedRef} {...reset}>\n {lazyLoad ? (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n data-src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n ) : (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n )}\n </div>\n )\n}\n\nexport default createForwardRefComponent(Image)\n"],"names":["Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","src","mode","onError","lazyLoad","imgProps","forwardedRef","reset","__rest","cls","classNames","imgCls","toLowerCase","replace","imageOnLoad","useCallback","e","onLoad","Object","defineProperty","enumerable","writable","value","width","target","height","useEffect","current","IntersectionObserver","entries","length","isIntersecting","rootMargin","_b","_a","observe","call","disconnect","_el$","_tmpl$","_$use","_$spread","_$insert","_el$2","_tmpl$2","_$addEventListener","img","_$setAttribute","_el$3","_$effect","_$p","_$style","createForwardRefComponent"],"mappings":";;;;;;;;;AAmBA,SAASA,KAAKA,CAAEC,KAAa,EAAA;AAC3B,EAAA,MAAMC,MAAM,GAAGC,MAAM,CAA0B,IAAI,CAAC;AACpD,EAAA,MAAMC,QAAQ,GAAGD,MAAM,CAAgC,EAAE,CAAC;AAC1D,EAAA,MAAM,GAAGE,WAAW,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC;EACvC,MAAM;MACJC,SAAS;aACTC,OAAK,GAAG,EAAE;MACVC,GA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,KAAA,EAAA,UAAA,EACP1C,GAAG,CAAA;MAAAwC,MAAA,CAAAE,KAAA,EAGTtC,QAAQ,EAAA,KAAA,EAAA,KAAA,CAAA;AAAA,MAAA,OAAAsC,KAAA;AAAA,KAAA,GAAA,GAAA,CAAA,MAAA;MAAA,IAAAK,KAAA,GAAAJ,OAAA,EAAA;MAAAC,gBAAA,CAAAG,KAAA,EAAA,OAAA,EAQH7C,OAAO,CAAA;MAAA0C,gBAAA,CAAAG,KAAA,EAAA,MAAA,EADRlC,WAAW,CAAA;MAAA0B,GAAA,CAHdM,GAAG,IAAKpD,MAAM,CAACiC,OAAO,GAAGmB,GAAI,EAAAE,KAAA,CAAA;MAAAA,KAAA,CAAAjD,SAAA,GACvBY,MAAM;MAAAoC,YAAA,CAAAC,KAAA,EAAA,KAAA,EACZ/C,GAAG,CAAA;MAAAwC,MAAA,CAAAO,KAAA,EAGJ3C,QAAQ,EAAA,KAAA,EAAA,KAAA,CAAA;AAAA,MAAA,OAAA2C,KAAA;KAEf,GAAA,CAAA;IAAAC,MAAA,CAAAC,GAAA,IAAAC,KAAA,CAAAb,IAAA,EAnByBtC,OAAK,EAAAkD,GAAA,CAAA,CAAA;AAAA,IAAA,OAAAZ,IAAA;AAAA,GAAA,GAAA;AAsBrC;AAEA,YAAec,yBAAyB,CAAC5D,KAAK,CAAC;;;;"}
|
|
@@ -128,13 +128,12 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
128
128
|
children,
|
|
129
129
|
formType,
|
|
130
130
|
lang,
|
|
131
|
-
theme = 'light'
|
|
132
|
-
enableClickItemScroll = true
|
|
131
|
+
theme = 'light'
|
|
133
132
|
} = props,
|
|
134
|
-
restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "colors", "onChange", "onColumnChange", "onCancel", "children", "formType", "lang", "theme"
|
|
133
|
+
restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "colors", "onChange", "onColumnChange", "onCancel", "children", "formType", "lang", "theme"]);
|
|
135
134
|
const indexRef = React__default.useRef([]);
|
|
136
135
|
const pickerDateRef = React__default.useRef();
|
|
137
|
-
//
|
|
136
|
+
// 记录是否是用户滚动
|
|
138
137
|
const isInitializationCompletedRef = React__default.useRef(false);
|
|
139
138
|
const [state, setState] = React__default.useState({
|
|
140
139
|
pickerValue: value || EMPTY_ARRAY,
|
|
@@ -143,8 +142,7 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
143
142
|
hidden: true,
|
|
144
143
|
fadeOut: false,
|
|
145
144
|
isWillLoadCalled: false,
|
|
146
|
-
|
|
147
|
-
a11yTimeLimitNonce: 0
|
|
145
|
+
timestamp: 0 // 用以部分模式下强制刷新组件的的时间戳,多用于反复限位
|
|
148
146
|
});
|
|
149
147
|
// 在组件内部
|
|
150
148
|
const [columnsCount, setColumnsCount] = React__default.useState(() => getRegionColumnsCount(level));
|
|
@@ -202,36 +200,25 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
202
200
|
const monthRange = getMonthRange(_start, _end, currentYear);
|
|
203
201
|
const dayRange = getDayRange(_start, _end, currentYear, currentMonth);
|
|
204
202
|
indexRef.current = [yearRange.indexOf(currentYear), monthRange.indexOf(currentMonth), dayRange.indexOf(currentDay)];
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
203
|
+
if (!pickerDateRef.current || pickerDateRef.current._value.getTime() !== _value.getTime() || pickerDateRef.current._start.getTime() !== _start.getTime() || pickerDateRef.current._end.getTime() !== _end.getTime()) {
|
|
204
|
+
pickerDateRef.current = {
|
|
205
|
+
_value,
|
|
206
|
+
_start,
|
|
207
|
+
_end,
|
|
208
|
+
_updateValue: [currentYear, currentMonth, currentDay]
|
|
209
|
+
};
|
|
210
|
+
}
|
|
212
211
|
} else if (mode === 'region') {
|
|
213
212
|
// region 模式处理 - 验证数据
|
|
214
213
|
if (!regionData) {
|
|
215
214
|
console.error('Picker: regionData is required for region mode');
|
|
216
|
-
indexRef.current =
|
|
217
|
-
length: columnsCount
|
|
218
|
-
}, () => 0);
|
|
219
|
-
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
220
|
-
selectedIndices: [...indexRef.current],
|
|
221
|
-
pickerValue: value || EMPTY_ARRAY
|
|
222
|
-
}));
|
|
215
|
+
indexRef.current = [0];
|
|
223
216
|
return;
|
|
224
217
|
}
|
|
225
218
|
const validation = validateRegionData(regionData, 'Picker');
|
|
226
219
|
if (!validation.valid) {
|
|
227
220
|
console.error(validation.error);
|
|
228
|
-
indexRef.current =
|
|
229
|
-
length: columnsCount
|
|
230
|
-
}, () => 0);
|
|
231
|
-
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
232
|
-
selectedIndices: [...indexRef.current],
|
|
233
|
-
pickerValue: value || EMPTY_ARRAY
|
|
234
|
-
}));
|
|
221
|
+
indexRef.current = [0];
|
|
235
222
|
return;
|
|
236
223
|
}
|
|
237
224
|
// 获取列数
|
|
@@ -278,16 +265,16 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
278
265
|
handleProps();
|
|
279
266
|
}
|
|
280
267
|
}, [handleProps, state.isWillLoadCalled, JSON.stringify(value)]);
|
|
281
|
-
//
|
|
268
|
+
// 显示 Picker
|
|
282
269
|
const showPicker = React__default.useCallback(() => {
|
|
283
270
|
if (disabled) return;
|
|
284
271
|
isInitializationCompletedRef.current = false;
|
|
285
|
-
|
|
272
|
+
const newIndices = getIndices();
|
|
286
273
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
287
|
-
|
|
288
|
-
|
|
274
|
+
selectedIndices: newIndices,
|
|
275
|
+
hidden: false
|
|
289
276
|
}));
|
|
290
|
-
}, [disabled,
|
|
277
|
+
}, [disabled, getIndices]);
|
|
291
278
|
// 隐藏 Picker
|
|
292
279
|
const hidePicker = React__default.useCallback(() => {
|
|
293
280
|
isInitializationCompletedRef.current = false;
|
|
@@ -362,11 +349,11 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
362
349
|
finalIndices = [...newIndices];
|
|
363
350
|
hasLimited = true;
|
|
364
351
|
}
|
|
352
|
+
// 触发限位,更新状态,其它状态不用主动触发滚动
|
|
365
353
|
if (hasLimited) {
|
|
366
354
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
367
355
|
selectedIndices: finalIndices,
|
|
368
|
-
|
|
369
|
-
a11yTimeLimitNonce: prev.a11yTimeLimitNonce + 1
|
|
356
|
+
timestamp: Date.now()
|
|
370
357
|
}));
|
|
371
358
|
} else {
|
|
372
359
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
@@ -599,17 +586,11 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
599
586
|
}
|
|
600
587
|
});
|
|
601
588
|
}, [onColumnChange]);
|
|
602
|
-
|
|
603
|
-
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
604
|
-
a11yTimeLimitColumnId: null
|
|
605
|
-
}));
|
|
606
|
-
}, []);
|
|
607
|
-
// 取消时按 props 回同步索引,避免与 value 脱节
|
|
589
|
+
// 处理取消
|
|
608
590
|
const handleCancel = React__default.useCallback(() => {
|
|
609
|
-
handleProps();
|
|
610
591
|
hidePicker();
|
|
611
592
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
612
|
-
}, [
|
|
593
|
+
}, [hidePicker, onCancel]);
|
|
613
594
|
// 渲染选择器组
|
|
614
595
|
const renderPickerGroup = React__default.useMemo(() => {
|
|
615
596
|
switch (mode) {
|
|
@@ -627,18 +608,15 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
627
608
|
get selectedIndex() {
|
|
628
609
|
return state.selectedIndices[index];
|
|
629
610
|
},
|
|
630
|
-
colors: colors
|
|
631
|
-
enableClickItemScroll: enableClickItemScroll
|
|
611
|
+
colors: colors
|
|
632
612
|
}));
|
|
633
613
|
}
|
|
634
614
|
case 'time':
|
|
635
615
|
{
|
|
636
|
-
const timeA11yLimitFocus = state.a11yTimeLimitColumnId != null ? {
|
|
637
|
-
nonce: state.a11yTimeLimitNonce,
|
|
638
|
-
columnId: state.a11yTimeLimitColumnId
|
|
639
|
-
} : null;
|
|
640
616
|
return [createComponent(PickerGroup, {
|
|
641
|
-
key
|
|
617
|
+
get key() {
|
|
618
|
+
return `hour-${state.timestamp}`;
|
|
619
|
+
},
|
|
642
620
|
mode: "time",
|
|
643
621
|
range: hoursRange,
|
|
644
622
|
updateIndex: updateIndex,
|
|
@@ -646,15 +624,11 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
646
624
|
get selectedIndex() {
|
|
647
625
|
return state.selectedIndices[0];
|
|
648
626
|
},
|
|
649
|
-
colors: colors
|
|
650
|
-
timeA11yLimitFocus: timeA11yLimitFocus,
|
|
651
|
-
onTimeA11yLimitFocusConsumed: consumeTimeA11yLimitFocus,
|
|
652
|
-
get timeA11yLimitEventNonce() {
|
|
653
|
-
return state.a11yTimeLimitNonce;
|
|
654
|
-
},
|
|
655
|
-
enableClickItemScroll: enableClickItemScroll
|
|
627
|
+
colors: colors
|
|
656
628
|
}), createComponent(PickerGroup, {
|
|
657
|
-
key
|
|
629
|
+
get key() {
|
|
630
|
+
return `minute-${state.timestamp}`;
|
|
631
|
+
},
|
|
658
632
|
mode: "time",
|
|
659
633
|
range: minutesRange,
|
|
660
634
|
updateIndex: updateIndex,
|
|
@@ -662,13 +636,7 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
662
636
|
get selectedIndex() {
|
|
663
637
|
return state.selectedIndices[1];
|
|
664
638
|
},
|
|
665
|
-
colors: colors
|
|
666
|
-
timeA11yLimitFocus: timeA11yLimitFocus,
|
|
667
|
-
onTimeA11yLimitFocusConsumed: consumeTimeA11yLimitFocus,
|
|
668
|
-
get timeA11yLimitEventNonce() {
|
|
669
|
-
return state.a11yTimeLimitNonce;
|
|
670
|
-
},
|
|
671
|
-
enableClickItemScroll: enableClickItemScroll
|
|
639
|
+
colors: colors
|
|
672
640
|
})];
|
|
673
641
|
}
|
|
674
642
|
case 'date':
|
|
@@ -696,8 +664,7 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
696
664
|
get selectedIndex() {
|
|
697
665
|
return state.selectedIndices[0];
|
|
698
666
|
},
|
|
699
|
-
colors: colors
|
|
700
|
-
enableClickItemScroll: enableClickItemScroll
|
|
667
|
+
colors: colors
|
|
701
668
|
})];
|
|
702
669
|
if (fields === 'month' || fields === 'day') {
|
|
703
670
|
renderView.push(createComponent(PickerGroup, {
|
|
@@ -710,8 +677,7 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
710
677
|
get selectedIndex() {
|
|
711
678
|
return state.selectedIndices[1];
|
|
712
679
|
},
|
|
713
|
-
colors: colors
|
|
714
|
-
enableClickItemScroll: enableClickItemScroll
|
|
680
|
+
colors: colors
|
|
715
681
|
}));
|
|
716
682
|
}
|
|
717
683
|
if (fields === 'day') {
|
|
@@ -725,8 +691,7 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
725
691
|
get selectedIndex() {
|
|
726
692
|
return state.selectedIndices[2];
|
|
727
693
|
},
|
|
728
|
-
colors: colors
|
|
729
|
-
enableClickItemScroll: enableClickItemScroll
|
|
694
|
+
colors: colors
|
|
730
695
|
}));
|
|
731
696
|
}
|
|
732
697
|
return renderView;
|
|
@@ -766,8 +731,7 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
766
731
|
get selectedIndex() {
|
|
767
732
|
return state.selectedIndices[i];
|
|
768
733
|
},
|
|
769
|
-
colors: colors
|
|
770
|
-
enableClickItemScroll: enableClickItemScroll
|
|
734
|
+
colors: colors
|
|
771
735
|
}));
|
|
772
736
|
}
|
|
773
737
|
return columns;
|
|
@@ -781,11 +745,10 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
781
745
|
get selectedIndex() {
|
|
782
746
|
return state.selectedIndices[0];
|
|
783
747
|
},
|
|
784
|
-
colors: colors
|
|
785
|
-
enableClickItemScroll: enableClickItemScroll
|
|
748
|
+
colors: colors
|
|
786
749
|
});
|
|
787
750
|
}
|
|
788
|
-
}, [mode, range, rangeKey, fields, updateIndex, updateDay, handleColumnChange, pickerDateRef.current, level, regionData, state.selectedIndices,
|
|
751
|
+
}, [mode, range, rangeKey, fields, updateIndex, updateDay, handleColumnChange, pickerDateRef.current, level, regionData, state.selectedIndices, columnsCount, lang, colors]);
|
|
789
752
|
// 动画类名控制逻辑
|
|
790
753
|
const clsMask = classNames('taro-picker__mask-overlay', 'taro-picker__animate-fade-in', {
|
|
791
754
|
'taro-picker__animate-fade-out': state.fadeOut
|
|
@@ -799,9 +762,6 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
799
762
|
const titleStyle = colors.titleColor ? {
|
|
800
763
|
color: colors.titleColor
|
|
801
764
|
} : null;
|
|
802
|
-
const maskOverlayStyle = colors.maskColor ? {
|
|
803
|
-
backgroundColor: colors.maskColor
|
|
804
|
-
} : undefined;
|
|
805
765
|
// 暴露方法给外部
|
|
806
766
|
React__default.useImperativeHandle(ref, () => ({
|
|
807
767
|
showPicker,
|
|
@@ -822,13 +782,10 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
822
782
|
onClick: showPicker,
|
|
823
783
|
children: children
|
|
824
784
|
}), memo(() => memo(() => !!!state.hidden)() && createComponent(View, {
|
|
825
|
-
|
|
826
|
-
return classNames('taro-picker__overlay', `taro-picker__overlay--theme-${theme}`);
|
|
827
|
-
},
|
|
785
|
+
className: "taro-picker__overlay",
|
|
828
786
|
get children() {
|
|
829
787
|
return [createComponent(View, {
|
|
830
788
|
className: clsMask,
|
|
831
|
-
style: maskOverlayStyle,
|
|
832
789
|
onClick: handleCancel
|
|
833
790
|
}), createComponent(View, mergeProps({
|
|
834
791
|
className: clsSlider
|