@tarojs/components-react 4.2.0 → 4.2.1-beta.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 (77) hide show
  1. package/dist/components/image/index.js +5 -3
  2. package/dist/components/image/index.js.map +1 -1
  3. package/dist/components/map/MapContext.js +628 -0
  4. package/dist/components/map/MapContext.js.map +1 -0
  5. package/dist/components/map/MapCustomCallout.js +91 -0
  6. package/dist/components/map/MapCustomCallout.js.map +1 -0
  7. package/dist/components/map/common.js +4 -0
  8. package/dist/components/map/common.js.map +1 -0
  9. package/dist/components/map/createMapContext.js +34 -0
  10. package/dist/components/map/createMapContext.js.map +1 -0
  11. package/dist/components/map/handler.js +50 -0
  12. package/dist/components/map/handler.js.map +1 -0
  13. package/dist/components/map/index.js +329 -0
  14. package/dist/components/map/index.js.map +1 -0
  15. package/dist/components/picker/index.js +76 -35
  16. package/dist/components/picker/index.js.map +1 -1
  17. package/dist/components/picker/picker-group.js +477 -127
  18. package/dist/components/picker/picker-group.js.map +1 -1
  19. package/dist/components/refresher/index.js +5 -5
  20. package/dist/components/refresher/index.js.map +1 -1
  21. package/dist/components/scroll-view/index.js +80 -36
  22. package/dist/components/scroll-view/index.js.map +1 -1
  23. package/dist/components/switch/index.js +125 -0
  24. package/dist/components/switch/index.js.map +1 -0
  25. package/dist/components/switch/style/index.scss.js +4 -0
  26. package/dist/components/switch/style/index.scss.js.map +1 -0
  27. package/dist/contexts/ScrollElementContext.js +6 -0
  28. package/dist/contexts/ScrollElementContext.js.map +1 -0
  29. package/dist/index.css +1 -1
  30. package/dist/index.js +6 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/original/components/image/index.js +5 -3
  33. package/dist/original/components/image/index.js.map +1 -1
  34. package/dist/original/components/image/style/index.scss +5 -1
  35. package/dist/original/components/map/MapContext.js +628 -0
  36. package/dist/original/components/map/MapContext.js.map +1 -0
  37. package/dist/original/components/map/MapCustomCallout.js +91 -0
  38. package/dist/original/components/map/MapCustomCallout.js.map +1 -0
  39. package/dist/original/components/map/common.js +4 -0
  40. package/dist/original/components/map/common.js.map +1 -0
  41. package/dist/original/components/map/createMapContext.js +34 -0
  42. package/dist/original/components/map/createMapContext.js.map +1 -0
  43. package/dist/original/components/map/handler.js +50 -0
  44. package/dist/original/components/map/handler.js.map +1 -0
  45. package/dist/original/components/map/index.js +329 -0
  46. package/dist/original/components/map/index.js.map +1 -0
  47. package/dist/original/components/picker/index.js +76 -35
  48. package/dist/original/components/picker/index.js.map +1 -1
  49. package/dist/original/components/picker/picker-group.js +477 -127
  50. package/dist/original/components/picker/picker-group.js.map +1 -1
  51. package/dist/original/components/picker/style/index.scss +9 -8
  52. package/dist/original/components/refresher/index.js +5 -5
  53. package/dist/original/components/refresher/index.js.map +1 -1
  54. package/dist/original/components/scroll-view/index.js +80 -36
  55. package/dist/original/components/scroll-view/index.js.map +1 -1
  56. package/dist/original/components/switch/index.js +125 -0
  57. package/dist/original/components/switch/index.js.map +1 -0
  58. package/dist/original/components/switch/style/index.scss +35 -0
  59. package/dist/original/contexts/ScrollElementContext.js +6 -0
  60. package/dist/original/contexts/ScrollElementContext.js.map +1 -0
  61. package/dist/original/index.js +6 -2
  62. package/dist/original/index.js.map +1 -1
  63. package/dist/solid/components/image/index.js +5 -3
  64. package/dist/solid/components/image/index.js.map +1 -1
  65. package/dist/solid/components/picker/index.js +82 -39
  66. package/dist/solid/components/picker/index.js.map +1 -1
  67. package/dist/solid/components/picker/picker-group.js +500 -151
  68. package/dist/solid/components/picker/picker-group.js.map +1 -1
  69. package/dist/solid/components/refresher/index.js +5 -5
  70. package/dist/solid/components/refresher/index.js.map +1 -1
  71. package/dist/solid/components/scroll-view/index.js +84 -40
  72. package/dist/solid/components/scroll-view/index.js.map +1 -1
  73. package/dist/solid/contexts/ScrollElementContext.js +6 -0
  74. package/dist/solid/contexts/ScrollElementContext.js.map +1 -0
  75. package/dist/solid/index.css +1 -1
  76. package/dist/solid/index.js +1 -1
  77. package/package.json +8 -6
@@ -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 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,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-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,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AAe,QAAA,EAEvB3E,KAAK,CAAC2E;KACJ;AACP,GAA+B,CAAC;AAEpC;AAEA,YAAeG,yBAAyB,CAAC/E,UAAU,CAAC;;;;"}
@@ -0,0 +1,125 @@
1
+ import { __rest } from 'tslib';
2
+ import './style/index.scss.js';
3
+ import { View } from '@tarojs/components';
4
+ import classNames from 'classnames';
5
+ import { omit, createForwardRefComponent } from '../../utils/index.js';
6
+ import { useState, useCallback } from '../../utils/hooks.react.js';
7
+ import { jsx } from 'react/jsx-runtime';
8
+
9
+ function Switch(props) {
10
+ const {
11
+ type = 'switch',
12
+ checked: controlledChecked,
13
+ defaultChecked = false,
14
+ disabled = false,
15
+ color = '#04BE02',
16
+ width,
17
+ height,
18
+ beforeChange,
19
+ nativeProps = {},
20
+ onChange,
21
+ forwardedRef,
22
+ className,
23
+ style
24
+ } = props,
25
+ rest = __rest(props, ["type", "checked", "defaultChecked", "disabled", "color", "width", "height", "beforeChange", "nativeProps", "onChange", "forwardedRef", "className", "style"]);
26
+ const [innerChecked, setInnerChecked] = useState(defaultChecked);
27
+ const [loading, setLoading] = useState(false);
28
+ const isChecked = controlledChecked !== undefined ? controlledChecked : innerChecked;
29
+ const applyChange = useCallback(value => {
30
+ if (controlledChecked === undefined) {
31
+ setInnerChecked(value);
32
+ }
33
+ const e = {
34
+ detail: {
35
+ value
36
+ }
37
+ };
38
+ onChange && onChange(e);
39
+ }, [controlledChecked, onChange]);
40
+ const handleToggle = useCallback(newValue => {
41
+ if (disabled || loading) return;
42
+ if (beforeChange) {
43
+ const result = beforeChange(newValue);
44
+ if (result === false) return;
45
+ if (result instanceof Promise) {
46
+ setLoading(true);
47
+ result.then(asyncResult => {
48
+ setLoading(false);
49
+ if (asyncResult === false) return;
50
+ applyChange(newValue);
51
+ }, () => {
52
+ setLoading(false);
53
+ });
54
+ return;
55
+ }
56
+ }
57
+ applyChange(newValue);
58
+ }, [disabled, loading, beforeChange, applyChange]);
59
+ const isSwitch = type === 'switch';
60
+ const sw = width !== null && width !== void 0 ? width : isSwitch ? 52 : 20;
61
+ const sh = height !== null && height !== void 0 ? height : isSwitch ? 32 : 20;
62
+ const dynamicStyle = isSwitch ? {
63
+ width: `${sw}px`,
64
+ height: `${sh}px`,
65
+ borderRadius: `${sh / 2}px`,
66
+ backgroundColor: isChecked ? color : '#DFDFDF',
67
+ borderColor: isChecked ? color : '#DFDFDF'
68
+ } : {
69
+ width: `${sh}px`,
70
+ height: `${sh}px`,
71
+ borderRadius: '4px',
72
+ backgroundColor: isChecked ? color : 'transparent',
73
+ borderColor: isChecked ? color : '#c9c9c9'
74
+ };
75
+ const cls = classNames('taro-switch', `taro-switch--type-${type}`, {
76
+ 'taro-switch--checked': isChecked,
77
+ 'taro-switch--disabled': disabled
78
+ }, className);
79
+ const rootStyle = Object.assign(Object.assign({}, dynamicStyle), style);
80
+ const onClick = e => {
81
+ e.stopPropagation();
82
+ handleToggle(!isChecked);
83
+ };
84
+ if (isSwitch) {
85
+ const thumbStyle = {
86
+ width: `${sh - 4}px`,
87
+ height: `${sh - 4}px`,
88
+ transform: isChecked ? `translateX(${sw - sh}px)` : undefined
89
+ };
90
+ return /*#__PURE__*/jsx(View, {
91
+ className: cls,
92
+ style: rootStyle,
93
+ ref: forwardedRef,
94
+ onClick: onClick,
95
+ ...omit(rest, ['forwardedRef']),
96
+ ...nativeProps,
97
+ children: /*#__PURE__*/jsx(View, {
98
+ className: "taro-switch__thumb",
99
+ style: thumbStyle
100
+ })
101
+ });
102
+ }
103
+ return /*#__PURE__*/jsx(View, {
104
+ className: cls,
105
+ style: rootStyle,
106
+ ref: forwardedRef,
107
+ onClick: onClick,
108
+ ...omit(rest, ['forwardedRef']),
109
+ ...nativeProps,
110
+ children: /*#__PURE__*/jsx(View, {
111
+ className: "taro-switch__checkmark",
112
+ style: {
113
+ width: `${Math.round(sh * 0.3)}px`,
114
+ height: `${Math.round(sh * 0.5)}px`,
115
+ borderRight: `${Math.round(sh * 0.1)}px solid #fff`,
116
+ borderBottom: `${Math.round(sh * 0.1)}px solid #fff`,
117
+ transform: isChecked ? `translate(-50%, -65%) rotate(45deg) scale(1)` : `translate(-50%, -65%) rotate(45deg) scale(0)`
118
+ }
119
+ })
120
+ });
121
+ }
122
+ var index = createForwardRefComponent(Switch);
123
+
124
+ export { index as default };
125
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/switch/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport { View } from '@tarojs/components'\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent, omit } from '../../utils'\nimport { useCallback, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\nexport type BeforeChange = (value: boolean) => boolean | Promise<boolean>\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n type?: 'switch' | 'checkbox'\n checked?: boolean\n defaultChecked?: boolean\n disabled?: boolean\n color?: string\n width?: number\n height?: number\n beforeChange?: BeforeChange\n nativeProps?: Record<string, any>\n onChange?: (e: any) => void\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n}\n\nfunction Switch (props: IProps) {\n const {\n type = 'switch',\n checked: controlledChecked,\n defaultChecked = false,\n disabled = false,\n color = '#04BE02',\n width,\n height,\n beforeChange,\n nativeProps = {},\n onChange,\n forwardedRef,\n className,\n style,\n ...rest\n } = props\n\n const [innerChecked, setInnerChecked] = useState(defaultChecked)\n const [loading, setLoading] = useState(false)\n\n const isChecked = controlledChecked !== undefined\n ? controlledChecked\n : innerChecked\n\n const applyChange = useCallback((value: boolean) => {\n if (controlledChecked === undefined) {\n setInnerChecked(value)\n }\n\n const e = { detail: { value } }\n onChange && onChange(e)\n }, [controlledChecked, onChange])\n\n const handleToggle = useCallback((newValue: boolean) => {\n if (disabled || loading) return\n\n if (beforeChange) {\n const result = beforeChange(newValue)\n\n if (result === false) return\n\n if (result instanceof Promise) {\n setLoading(true)\n result\n .then((asyncResult) => {\n setLoading(false)\n if (asyncResult === false) return\n applyChange(newValue)\n }, () => {\n setLoading(false)\n })\n return\n }\n }\n\n applyChange(newValue)\n }, [disabled, loading, beforeChange, applyChange])\n\n const isSwitch = type === 'switch'\n const sw = width ?? (isSwitch ? 52 : 20)\n const sh = height ?? (isSwitch ? 32 : 20)\n\n const dynamicStyle: React.CSSProperties = isSwitch ? {\n width: `${sw}px`,\n height: `${sh}px`,\n borderRadius: `${sh / 2}px`,\n backgroundColor: isChecked ? color : '#DFDFDF',\n borderColor: isChecked ? color : '#DFDFDF'\n } : {\n width: `${sh}px`,\n height: `${sh}px`,\n borderRadius: '4px',\n backgroundColor: isChecked ? color : 'transparent',\n borderColor: isChecked ? color : '#c9c9c9'\n }\n\n const cls = classNames(\n 'taro-switch',\n `taro-switch--type-${type}`,\n {\n 'taro-switch--checked': isChecked,\n 'taro-switch--disabled': disabled\n },\n className\n )\n\n const rootStyle = {\n ...dynamicStyle,\n ...style\n } as unknown as React.CSSProperties\n\n const onClick = (e: React.MouseEvent) => {\n e.stopPropagation()\n handleToggle(!isChecked)\n }\n\n if (isSwitch) {\n const thumbStyle: React.CSSProperties = {\n width: `${sh - 4}px`,\n height: `${sh - 4}px`,\n transform: isChecked ? `translateX(${sw - sh}px)` : undefined\n }\n return (\n <View\n className={cls}\n style={rootStyle}\n ref={forwardedRef}\n onClick={onClick}\n {...omit(rest, ['forwardedRef'])}\n {...nativeProps}\n >\n <View className='taro-switch__thumb' style={thumbStyle} />\n </View>\n )\n }\n\n return (\n <View\n className={cls}\n style={rootStyle}\n ref={forwardedRef}\n onClick={onClick}\n {...omit(rest, ['forwardedRef'])}\n {...nativeProps}\n >\n <View\n className='taro-switch__checkmark'\n style={{\n width: `${Math.round(sh * 0.3)}px`,\n height: `${Math.round(sh * 0.5)}px`,\n borderRight: `${Math.round(sh * 0.1)}px solid #fff`,\n borderBottom: `${Math.round(sh * 0.1)}px solid #fff`,\n transform: isChecked\n ? `translate(-50%, -65%) rotate(45deg) scale(1)`\n : `translate(-50%, -65%) rotate(45deg) scale(0)`\n }}\n />\n </View>\n )\n}\n\nexport default createForwardRefComponent(Switch)\n"],"names":["Switch","props","type","checked","controlledChecked","defaultChecked","disabled","color","width","height","beforeChange","nativeProps","onChange","forwardedRef","className","style","rest","innerChecked","setInnerChecked","useState","loading","setLoading","isChecked","undefined","applyChange","useCallback","value","e","detail","handleToggle","newValue","result","Promise","then","asyncResult","isSwitch","sw","sh","dynamicStyle","borderRadius","backgroundColor","borderColor","cls","classNames","rootStyle","Object","assign","onClick","stopPropagation","thumbStyle","transform","_jsx","View","ref","omit","children","Math","round","borderRight","borderBottom","createForwardRefComponent"],"mappings":";;;;;;;;AA0BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;EAC5B,MAAM;AACJC,MAAAA,IAAI,GAAG,QAAQ;AACfC,MAAAA,OAAO,EAAEC,iBAAiB;AAC1BC,MAAAA,cAAc,GAAG,KAAK;AACtBC,MAAAA,QAAQ,GAAG,KAAK;AAChBC,MAAAA,KAAK,GAAG,SAAS;MACjBC,KAAK;MACLC,MAAM;MACNC,YAAY;MACZC,WAAW,GAAG,EAAE;MAChBC,QAAQ;MACRC,YAAY;MACZC,SAAS;AACTC,MAAAA;AAAK,KAAA,GAEHd,KAAK;AADJe,IAAAA,IAAI,UACLf,KAAK,EAfH,CAeL,MAAA,EAAA,SAAA,EAAA,gBAAA,EAAA,UAAA,EAAA,OAAA,EAAA,OAAA,EAAA,QAAA,EAAA,cAAA,EAAA,aAAA,EAAA,UAAA,EAAA,cAAA,EAAA,WAAA,EAAA,OAAA,CAAA,CAAQ;EAET,MAAM,CAACgB,YAAY,EAAEC,eAAe,CAAC,GAAGC,QAAQ,CAACd,cAAc,CAAC;EAChE,MAAM,CAACe,OAAO,EAAEC,UAAU,CAAC,GAAGF,QAAQ,CAAC,KAAK,CAAC;EAE7C,MAAMG,SAAS,GAAGlB,iBAAiB,KAAKmB,SAAS,GAC7CnB,iBAAiB,GACjBa,YAAY;AAEhB,EAAA,MAAMO,WAAW,GAAGC,WAAW,CAAEC,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AACpB,EAAE,GAAG,GAAG,CAAC,CAAe,aAAA,CAAA;QACnDsB,YAAY,EAAE,CAAGH,EAAAA,IAAI,CAACC,KAAK,CAACpB,EAAE,GAAG,GAAG,CAAC,CAAe,aAAA,CAAA;AACpDa,QAAAA,SAAS,EAAE5B,SAAS,GAChB,CAAA,4CAAA,CAA8C,GAC9C,CAAA,4CAAA;AACL;KAEL;AAAA,GAAM,CAAC;AAEX;AAEA,YAAesC,yBAAyB,CAAC5D,MAAM,CAAC;;;;"}
@@ -0,0 +1,4 @@
1
+ var undefined$1 = undefined;
2
+
3
+ export { undefined$1 as default };
4
+ //# sourceMappingURL=index.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -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;;;;"}
package/dist/index.css CHANGED
@@ -1 +1 @@
1
- @-webkit-keyframes weuiLoading{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes weuiLoading{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.taro-button-core.taro-btn-loading .weui-loading{animation:weuiLoading 1s steps(12) infinite;background:transparent url(https://img13.360buyimg.com/imagetools/jfs/t1/353674/27/5761/14397/690ac1cfFf6bf0e2c/77727d0791bacf8e.png) no-repeat;background-size:cover;display:inline-block;height:22px;width:22px}.taro-button-core.taro-btn-loading .weui-loading.weui-btn_primary,.taro-button-core.taro-btn-loading .weui-loading.weui-btn_warn{color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-loading .weui-loading.weui-btn_primary{background-color:#179b16}.taro-button-core.taro-btn-loading .weui-loading.weui-btn_warn{background-color:#ce3c39}.taro-button-core.taro-btn-loading.taro-btn-mini .weui-loading{display:inline-block;height:16px;vertical-align:middle;width:16px}.taro-button-core{-webkit-tap-highlight-color:rgba(0,0,0,0);align-items:center;appearance:none;background-color:#f8f8f8;border:1px solid rgba(0,0,0,.2);border-radius:10px;box-sizing:border-box;color:#000;display:flex;font-size:18px;justify-content:center;outline:0;overflow:hidden;padding:0 14px;position:relative;text-decoration:none;width:100%}.taro-button-core:focus{outline:0}.taro-button-core:not(.taro-btn-disabled):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core+.taro-button-core{margin-top:15px}.taro-button-core.taro-btn-default{background-color:#f8f8f8;color:#000}.taro-button-core.taro-btn-default:not(.taro-btn-disabled):visited{color:#000}.taro-button-core.taro-btn-default:not(.taro-btn-disabled):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core.taro-btn-mini{display:inline-block;font-size:13px;padding:0 26px;vertical-align:middle;width:auto}.taro-button-core.taro-btn-plain,.taro-button-core.taro-btn-plain.taro-btn-default,.taro-button-core.taro-btn-plain.taro-btn-primary,.taro-button-core.taro-btn-plain.taro-btn-warn{background-color:transparent;border-width:1px}.taro-button-core.taro-btn-disabled{color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-disabled.taro-btn-default{background-color:#f7f7f7;color:rgba(0,0,0,.3)}.taro-button-core.taro-btn-disabled.taro-btn-primary{background-color:#9ed99d}.taro-button-core.taro-btn-disabled.taro-btn-warn{background-color:#ec8b89}.taro-button-core.taro-btn-loading.taro-btn-primary,.taro-button-core.taro-btn-loading.taro-btn-warn{color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-loading.taro-btn-primary{background-color:#179b16}.taro-button-core.taro-btn-loading.taro-btn-warn{background-color:#ce3c39}.taro-button-core.taro-btn-plain.taro-btn-primary{border:1px solid #1aad19;color:#1aad19}.taro-button-core.taro-btn-plain.taro-btn-primary:not(.taro-btn-disabled):active{background-color:transparent;border-color:rgba(26,173,25,.6);color:rgba(26,173,25,.6)}.taro-button-core.taro-btn-plain.taro-btn-primary:after{border-width:0}.taro-button-core.taro-btn-plain.taro-btn-warn{border:1px solid #e64340;color:#e64340}.taro-button-core.taro-btn-plain.taro-btn-warn:not(.taro-btn-disabled):active{background-color:transparent;border-color:rgba(230,67,64,.6);color:rgba(230,67,64,.6)}.taro-button-core.taro-btn-plain.taro-btn-warn:after{border-width:0}.taro-button-core.taro-btn-plain,.taro-button-core.taro-btn-plain.taro-btn-default{border:1px solid #353535;color:#353535}.taro-button-core.taro-btn-plain.taro-btn-default:not(.taro-btn-disabled):active,.taro-button-core.taro-btn-plain:not(.taro-btn-disabled):active{background-color:transparent;border-color:rgba(53,53,53,.6);color:rgba(53,53,53,.6)}.taro-button-core.taro-btn-plain.taro-btn-default:after,.taro-button-core.taro-btn-plain:after{border-width:0}.taro-button-core.taro-btn-primary{background-color:#1aad19;color:#fff}.taro-button-core.taro-btn-primary:not(.taro-btn-disabled):visited{color:#fff}.taro-button-core.taro-btn-primary:not(.taro-btn-disabled):active{background-color:#179b16;color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-warn{background-color:#e64340;color:#fff}.taro-button-core.taro-btn-warn:not(.taro-btn-disabled):visited{color:#fff}.taro-button-core.taro-btn-warn:not(.taro-btn-disabled):active{background-color:#ce3c39;color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-plain.taro-btn-disabled.taro-btn-default,.taro-button-core.taro-btn-plain.taro-btn-disabled.taro-btn-primary,.taro-button-core.taro-btn-plain.taro-btn-disabled.taro-btn-warn{background-color:#f7f7f7;border:1px solid rgba(0,0,0,.2);color:rgba(0,0,0,.3)}.weui-icon-circle:before{content:"\ea01"}.weui-icon-download:before{content:"\ea02"}.weui-icon-info:before{content:"\ea03"}.weui-icon-safe-success:before{content:"\ea04"}.weui-icon-safe-warn:before{content:"\ea05"}.weui-icon-success:before{content:"\ea06"}.weui-icon-success-circle:before{content:"\ea07"}.weui-icon-success-no-circle:before{content:"\ea08"}.weui-icon-waiting:before{content:"\ea09"}.weui-icon-waiting-circle:before{content:"\ea0a"}.weui-icon-warn:before{content:"\ea0b"}.weui-icon-info-circle:before{content:"\ea0c"}.weui-icon-cancel:before{content:"\ea0d"}.weui-icon-search:before{content:"\ea0e"}.weui-icon-clear:before{content:"\ea0f"}.weui-icon-back:before{content:"\ea10"}.weui-icon-delete:before{content:"\ea11"}.weui-icon-success{color:#09bb07;font-size:23px}.weui-icon-waiting{color:#10aeff;font-size:23px}.weui-icon-warn{color:#f43530;font-size:23px}.weui-icon-info{color:#10aeff;font-size:23px}.weui-icon-success-circle,.weui-icon-success-no-circle{color:#09bb07;font-size:23px}.weui-icon-waiting-circle{color:#10aeff;font-size:23px}.weui-icon-circle{color:#c9c9c9;font-size:23px}.weui-icon-download,.weui-icon-info-circle{color:#09bb07;font-size:23px}.weui-icon-safe-success{color:#09bb07}.weui-icon-safe-warn{color:#ffbe00}.weui-icon-cancel{color:#f43530;font-size:22px}.weui-icon-clear,.weui-icon-search{color:#b2b2b2;font-size:14px}.weui-icon-delete.weui-icon_gallery-delete{color:#fff;font-size:22px}.weui-icon_msg{font-size:93px}.weui-icon_msg.weui-icon-warn{color:#f76260}.weui-icon_msg-primary{font-size:93px}.weui-icon_msg-primary.weui-icon-warn{color:#ffbe00}img[src=""]{opacity:0}.taro-img{display:inline-block;font-size:0;height:240px;overflow:hidden;position:relative;width:320px}.taro-img.taro-img__widthfix,.taro-img__mode-heightfix{height:100%}.taro-img__mode-scaletofill{height:100%;width:100%}.taro-img__mode-aspectfit{height:100%;object-fit:contain;width:100%}.taro-img__mode-aspectfill{height:100%;object-fit:cover;width:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-bottom,.taro-img__mode-top{left:50%;position:absolute;transform:translate(-50%)}.taro-img__mode-bottom{bottom:0}.taro-img__mode-center{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.taro-img__mode-left,.taro-img__mode-right{position:absolute;top:50%;transform:translateY(-50%)}.taro-img__mode-right{right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{bottom:0;position:absolute}.taro-img__mode-bottomright{bottom:0;position:absolute;right:0}.taro-input-core{display:block}.weui-input{-webkit-appearance:none;background-color:transparent;border:0;color:inherit;font-size:inherit;height:1.4705882353em;line-height:1.4705882353;outline:0;width:100%}.weui-input::-webkit-inner-spin-button,.weui-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.taro-picker__overlay{position:fixed;z-index:1000}.taro-picker__mask-overlay,.taro-picker__overlay{bottom:0;height:100%;left:0;right:0;top:0;width:100%}.taro-picker__mask-overlay{position:absolute;z-index:1001}.taro-picker{bottom:0;font-size:14px;left:0;position:absolute;width:100%;z-index:1002}.taro-picker__hd{align-items:center;display:flex;font-size:17px;height:44px;justify-content:space-between;padding:0;position:relative}.taro-picker__hd:after{bottom:0;content:"";height:1px;left:0;position:absolute;transform:scaleY(.5);width:100%}.taro-picker__action{flex:0 0 auto;font-size:14px;height:44px;line-height:44px;padding:0 10px}.taro-picker__title{font-size:16px;font-weight:500;left:50%;max-width:40%;overflow:hidden;position:absolute;text-overflow:ellipsis;top:50%;transform:translate(-50%,-50%);white-space:nowrap}.taro-picker__bd{box-sizing:border-box;display:flex;flex:1;height:238px;overflow:hidden;width:100%}.taro-picker-theme-light{background-color:#e5e5e5}.taro-picker-theme-light .taro-picker__mask-overlay{background-color:rgba(0,0,0,.6)}.taro-picker-theme-light .taro-picker__hd{background-color:#fff}.taro-picker-theme-light .taro-picker__hd:after{background-color:#e5e5e5}.taro-picker-theme-light .taro-picker__action{color:#ff0f23}.taro-picker-theme-light .taro-picker__action:first-child{color:#888}.taro-picker-theme-light .taro-picker__title{color:#000}.taro-picker-theme-light .taro-picker__bd{background-color:#fff}.taro-picker-theme-light .taro-picker__indicator{border-bottom:1px solid #e5e5e5;border-top:1px solid #e5e5e5}.taro-picker-theme-light .taro-picker__mask{background:linear-gradient(180deg,hsla(0,0%,100%,.95),hsla(0,0%,100%,.6) 40%,hsla(0,0%,100%,0) 45%,hsla(0,0%,100%,0) 55%,hsla(0,0%,100%,.6) 60%,hsla(0,0%,100%,.95))}.taro-picker-theme-light .taro-picker__item{color:#000}.taro-picker-theme-light .taro-picker__item--selected{color:#ff0f23}.taro-picker-theme-light .taro-picker__item--disabled{color:#999}.taro-picker-theme-dark{background-color:hsla(0,0%,100%,.06)}.taro-picker-theme-dark .taro-picker__mask-overlay{background-color:hsla(0,0%,8%,.7)}.taro-picker-theme-dark .taro-picker__hd{background-color:#1f1f1f}.taro-picker-theme-dark .taro-picker__hd:after{background-color:hsla(0,0%,100%,.06)}.taro-picker-theme-dark .taro-picker__action{color:#ff0f23}.taro-picker-theme-dark .taro-picker__action:first-child{color:#818181}.taro-picker-theme-dark .taro-picker__title{color:#e6e6e6}.taro-picker-theme-dark .taro-picker__bd{background-color:#1f1f1f}.taro-picker-theme-dark .taro-picker__indicator{border-bottom:1px solid hsla(0,0%,100%,.06);border-top:1px solid hsla(0,0%,100%,.06)}.taro-picker-theme-dark .taro-picker__mask{background:linear-gradient(180deg,rgba(31,31,31,.95),rgba(31,31,31,.6) 40%,rgba(31,31,31,0) 45%,rgba(31,31,31,0) 55%,rgba(31,31,31,.6) 60%,rgba(31,31,31,.95))}.taro-picker-theme-dark .taro-picker__item{color:#e6e6e6}.taro-picker-theme-dark .taro-picker__item--selected{color:#ff0f23}.taro-picker-theme-dark .taro-picker__item--disabled{color:#999}.taro-picker__group{align-items:center;box-sizing:border-box;display:flex;flex:1;height:100%;justify-content:center;min-width:0;position:relative}.taro-picker__group--date .taro-picker__columns{display:flex;height:100%;width:100%}.taro-picker__mask{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:1}.taro-picker__indicator{box-sizing:border-box;height:34px;left:0;position:absolute;top:50%;transform:translateY(-50%);width:100%;z-index:1002}.taro-picker__content{box-sizing:border-box;height:100%;width:100%}.taro-picker__item{align-items:center;box-sizing:border-box;display:flex;font-size:16px;height:34px;justify-content:center;line-height:34px;overflow:hidden;padding:0 8px;text-align:center;text-overflow:ellipsis;white-space:nowrap;width:100%}.taro-picker__item--selected{font-weight:500}.taro-picker__column{flex:1;margin:0 8px}.taro-picker__column:first-child{margin-left:0}.taro-picker__column:last-child{margin-right:0}.taro-picker__item--custom{align-items:center;color:#888;display:flex;font-weight:400;justify-content:center;text-align:center}@keyframes taro-picker__slide-up{0%{transform:translate3d(0,100%,0)}to{transform:translateZ(0)}}@keyframes taro-picker__slide-down{0%{transform:translateZ(0)}to{transform:translate3d(0,100%,0)}}@keyframes taro-picker__fade-in{0%{opacity:0}to{opacity:1}}@keyframes taro-picker__fade-out{0%{opacity:1}to{opacity:0}}.rmc-pull-to-refresh-content{transform-origin:left top 0}.rmc-pull-to-refresh-content-wrapper{min-height:100%}.rmc-pull-to-refresh-transition{transition:transform .3s}@keyframes rmc-pull-to-refresh-indicator{50%{opacity:.2}to{opacity:1}}.rmc-pull-to-refresh-indicator{height:30px;line-height:10px;text-align:center}.rmc-pull-to-refresh-indicator>div{animation-fill-mode:both;animation:rmc-pull-to-refresh-indicator .5s linear 0s infinite;background-color:grey;border-radius:100%;display:inline-block;height:6px;margin:3px;width:6px}.rmc-pull-to-refresh-indicator>div:nth-child(0){animation-delay:-.1s!important}.rmc-pull-to-refresh-indicator>div:first-child{animation-delay:-.2s!important}.rmc-pull-to-refresh-indicator>div:nth-child(2){animation-delay:-.3s!important}.rmc-pull-to-refresh-down .rmc-pull-to-refresh-indicator{margin-top:-25px}.taro-scroll{-webkit-overflow-scrolling:auto}.taro-scroll--hidebar::-webkit-scrollbar{display:none}.taro-scroll-view{overflow:hidden}.taro-scroll-view__scroll-x{overflow-x:scroll;overflow-y:hidden}.taro-scroll-view__scroll-y{overflow-x:hidden;overflow-y:scroll}.swiper-container-wrapper{height:150px}.swiper-container{height:100%;overflow:visible;position:relative}.taro-text{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.taro-text__selectable{-moz-user-select:text;-webkit-user-select:text;-ms-user-select:text;user-select:text}
1
+ @-webkit-keyframes weuiLoading{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes weuiLoading{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.taro-button-core.taro-btn-loading .weui-loading{animation:weuiLoading 1s steps(12) infinite;background:transparent url(https://img13.360buyimg.com/imagetools/jfs/t1/353674/27/5761/14397/690ac1cfFf6bf0e2c/77727d0791bacf8e.png) no-repeat;background-size:cover;display:inline-block;height:22px;width:22px}.taro-button-core.taro-btn-loading .weui-loading.weui-btn_primary,.taro-button-core.taro-btn-loading .weui-loading.weui-btn_warn{color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-loading .weui-loading.weui-btn_primary{background-color:#179b16}.taro-button-core.taro-btn-loading .weui-loading.weui-btn_warn{background-color:#ce3c39}.taro-button-core.taro-btn-loading.taro-btn-mini .weui-loading{display:inline-block;height:16px;vertical-align:middle;width:16px}.taro-button-core{-webkit-tap-highlight-color:rgba(0,0,0,0);align-items:center;appearance:none;background-color:#f8f8f8;border:1px solid rgba(0,0,0,.2);border-radius:10px;box-sizing:border-box;color:#000;display:flex;font-size:18px;justify-content:center;outline:0;overflow:hidden;padding:0 14px;position:relative;text-decoration:none;width:100%}.taro-button-core:focus{outline:0}.taro-button-core:not(.taro-btn-disabled):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core+.taro-button-core{margin-top:15px}.taro-button-core.taro-btn-default{background-color:#f8f8f8;color:#000}.taro-button-core.taro-btn-default:not(.taro-btn-disabled):visited{color:#000}.taro-button-core.taro-btn-default:not(.taro-btn-disabled):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core.taro-btn-mini{display:inline-block;font-size:13px;padding:0 26px;vertical-align:middle;width:auto}.taro-button-core.taro-btn-plain,.taro-button-core.taro-btn-plain.taro-btn-default,.taro-button-core.taro-btn-plain.taro-btn-primary,.taro-button-core.taro-btn-plain.taro-btn-warn{background-color:transparent;border-width:1px}.taro-button-core.taro-btn-disabled{color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-disabled.taro-btn-default{background-color:#f7f7f7;color:rgba(0,0,0,.3)}.taro-button-core.taro-btn-disabled.taro-btn-primary{background-color:#9ed99d}.taro-button-core.taro-btn-disabled.taro-btn-warn{background-color:#ec8b89}.taro-button-core.taro-btn-loading.taro-btn-primary,.taro-button-core.taro-btn-loading.taro-btn-warn{color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-loading.taro-btn-primary{background-color:#179b16}.taro-button-core.taro-btn-loading.taro-btn-warn{background-color:#ce3c39}.taro-button-core.taro-btn-plain.taro-btn-primary{border:1px solid #1aad19;color:#1aad19}.taro-button-core.taro-btn-plain.taro-btn-primary:not(.taro-btn-disabled):active{background-color:transparent;border-color:rgba(26,173,25,.6);color:rgba(26,173,25,.6)}.taro-button-core.taro-btn-plain.taro-btn-primary:after{border-width:0}.taro-button-core.taro-btn-plain.taro-btn-warn{border:1px solid #e64340;color:#e64340}.taro-button-core.taro-btn-plain.taro-btn-warn:not(.taro-btn-disabled):active{background-color:transparent;border-color:rgba(230,67,64,.6);color:rgba(230,67,64,.6)}.taro-button-core.taro-btn-plain.taro-btn-warn:after{border-width:0}.taro-button-core.taro-btn-plain,.taro-button-core.taro-btn-plain.taro-btn-default{border:1px solid #353535;color:#353535}.taro-button-core.taro-btn-plain.taro-btn-default:not(.taro-btn-disabled):active,.taro-button-core.taro-btn-plain:not(.taro-btn-disabled):active{background-color:transparent;border-color:rgba(53,53,53,.6);color:rgba(53,53,53,.6)}.taro-button-core.taro-btn-plain.taro-btn-default:after,.taro-button-core.taro-btn-plain:after{border-width:0}.taro-button-core.taro-btn-primary{background-color:#1aad19;color:#fff}.taro-button-core.taro-btn-primary:not(.taro-btn-disabled):visited{color:#fff}.taro-button-core.taro-btn-primary:not(.taro-btn-disabled):active{background-color:#179b16;color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-warn{background-color:#e64340;color:#fff}.taro-button-core.taro-btn-warn:not(.taro-btn-disabled):visited{color:#fff}.taro-button-core.taro-btn-warn:not(.taro-btn-disabled):active{background-color:#ce3c39;color:hsla(0,0%,100%,.6)}.taro-button-core.taro-btn-plain.taro-btn-disabled.taro-btn-default,.taro-button-core.taro-btn-plain.taro-btn-disabled.taro-btn-primary,.taro-button-core.taro-btn-plain.taro-btn-disabled.taro-btn-warn{background-color:#f7f7f7;border:1px solid rgba(0,0,0,.2);color:rgba(0,0,0,.3)}.weui-icon-circle:before{content:"\ea01"}.weui-icon-download:before{content:"\ea02"}.weui-icon-info:before{content:"\ea03"}.weui-icon-safe-success:before{content:"\ea04"}.weui-icon-safe-warn:before{content:"\ea05"}.weui-icon-success:before{content:"\ea06"}.weui-icon-success-circle:before{content:"\ea07"}.weui-icon-success-no-circle:before{content:"\ea08"}.weui-icon-waiting:before{content:"\ea09"}.weui-icon-waiting-circle:before{content:"\ea0a"}.weui-icon-warn:before{content:"\ea0b"}.weui-icon-info-circle:before{content:"\ea0c"}.weui-icon-cancel:before{content:"\ea0d"}.weui-icon-search:before{content:"\ea0e"}.weui-icon-clear:before{content:"\ea0f"}.weui-icon-back:before{content:"\ea10"}.weui-icon-delete:before{content:"\ea11"}.weui-icon-success{color:#09bb07;font-size:23px}.weui-icon-waiting{color:#10aeff;font-size:23px}.weui-icon-warn{color:#f43530;font-size:23px}.weui-icon-info{color:#10aeff;font-size:23px}.weui-icon-success-circle,.weui-icon-success-no-circle{color:#09bb07;font-size:23px}.weui-icon-waiting-circle{color:#10aeff;font-size:23px}.weui-icon-circle{color:#c9c9c9;font-size:23px}.weui-icon-download,.weui-icon-info-circle{color:#09bb07;font-size:23px}.weui-icon-safe-success{color:#09bb07}.weui-icon-safe-warn{color:#ffbe00}.weui-icon-cancel{color:#f43530;font-size:22px}.weui-icon-clear,.weui-icon-search{color:#b2b2b2;font-size:14px}.weui-icon-delete.weui-icon_gallery-delete{color:#fff;font-size:22px}.weui-icon_msg{font-size:93px}.weui-icon_msg.weui-icon-warn{color:#f76260}.weui-icon_msg-primary{font-size:93px}.weui-icon_msg-primary.weui-icon-warn{color:#ffbe00}img[src=""]{opacity:0}.taro-img{display:inline-block;font-size:0;overflow:hidden;position:relative}.taro-img--with-default-host-size{height:240px;width:320px}.taro-img.taro-img__widthfix,.taro-img__mode-heightfix{height:100%}.taro-img__mode-scaletofill{height:100%;width:100%}.taro-img__mode-aspectfit{height:100%;object-fit:contain;width:100%}.taro-img__mode-aspectfill{height:100%;object-fit:cover;width:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-bottom,.taro-img__mode-top{left:50%;position:absolute;transform:translate(-50%)}.taro-img__mode-bottom{bottom:0}.taro-img__mode-center{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.taro-img__mode-left,.taro-img__mode-right{position:absolute;top:50%;transform:translateY(-50%)}.taro-img__mode-right{right:0}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{bottom:0;position:absolute}.taro-img__mode-bottomright{bottom:0;position:absolute;right:0}.taro-input-core{display:block}.weui-input{-webkit-appearance:none;background-color:transparent;border:0;color:inherit;font-size:inherit;height:1.4705882353em;line-height:1.4705882353;outline:0;width:100%}.weui-input::-webkit-inner-spin-button,.weui-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.taro-picker__overlay{position:fixed;z-index:1000}.taro-picker__mask-overlay,.taro-picker__overlay{bottom:0;height:100%;left:0;right:0;top:0;width:100%}.taro-picker__mask-overlay{position:absolute;z-index:1001}.taro-picker__overlay.taro-picker__overlay--theme-light .taro-picker__mask-overlay{background-color:rgba(0,0,0,.6)}.taro-picker__overlay.taro-picker__overlay--theme-dark .taro-picker__mask-overlay{background-color:hsla(0,0%,8%,.7)}.taro-picker{bottom:0;font-size:14px;left:0;position:absolute;width:100%;z-index:1002}.taro-picker__hd{align-items:center;display:flex;font-size:17px;height:44px;justify-content:space-between;padding:0;position:relative}.taro-picker__hd:after{bottom:0;content:"";height:1px;left:0;position:absolute;transform:scaleY(.5);width:100%}.taro-picker__action{flex:0 0 auto;font-size:14px;height:44px;line-height:44px;padding:0 10px}.taro-picker__title{font-size:16px;font-weight:500;left:50%;max-width:40%;overflow:hidden;position:absolute;text-overflow:ellipsis;top:50%;transform:translate(-50%,-50%);white-space:nowrap}.taro-picker__bd{box-sizing:border-box;display:flex;flex:1;height:238px;overflow:hidden;width:100%}.taro-picker-theme-light{background-color:#e5e5e5}.taro-picker-theme-light .taro-picker__hd{background-color:#fff}.taro-picker-theme-light .taro-picker__hd:after{background-color:#e5e5e5}.taro-picker-theme-light .taro-picker__action{color:#ff0f23}.taro-picker-theme-light .taro-picker__action:first-child{color:#888}.taro-picker-theme-light .taro-picker__title{color:#000}.taro-picker-theme-light .taro-picker__bd{background-color:#fff}.taro-picker-theme-light .taro-picker__indicator{border-bottom:1px solid #e5e5e5;border-top:1px solid #e5e5e5}.taro-picker-theme-light .taro-picker__mask{background:linear-gradient(180deg,hsla(0,0%,100%,.95),hsla(0,0%,100%,.6) 40%,hsla(0,0%,100%,0) 45%,hsla(0,0%,100%,0) 55%,hsla(0,0%,100%,.6) 60%,hsla(0,0%,100%,.95))}.taro-picker-theme-light .taro-picker__item{color:#000}.taro-picker-theme-light .taro-picker__item--selected{color:#ff0f23}.taro-picker-theme-light .taro-picker__item--disabled{color:#999}.taro-picker-theme-dark{background-color:hsla(0,0%,100%,.06)}.taro-picker-theme-dark .taro-picker__hd{background-color:#1f1f1f}.taro-picker-theme-dark .taro-picker__hd:after{background-color:hsla(0,0%,100%,.06)}.taro-picker-theme-dark .taro-picker__action{color:#ff0f23}.taro-picker-theme-dark .taro-picker__action:first-child{color:#818181}.taro-picker-theme-dark .taro-picker__title{color:#e6e6e6}.taro-picker-theme-dark .taro-picker__bd{background-color:#1f1f1f}.taro-picker-theme-dark .taro-picker__indicator{border-bottom:1px solid hsla(0,0%,100%,.06);border-top:1px solid hsla(0,0%,100%,.06)}.taro-picker-theme-dark .taro-picker__mask{background:linear-gradient(180deg,rgba(31,31,31,.95),rgba(31,31,31,.6) 40%,rgba(31,31,31,0) 45%,rgba(31,31,31,0) 55%,rgba(31,31,31,.6) 60%,rgba(31,31,31,.95))}.taro-picker-theme-dark .taro-picker__item{color:#e6e6e6}.taro-picker-theme-dark .taro-picker__item--selected{color:#ff0f23}.taro-picker-theme-dark .taro-picker__item--disabled{color:#999}.taro-picker__group{align-items:center;box-sizing:border-box;display:flex;flex:1;height:100%;justify-content:center;min-width:0;position:relative}.taro-picker__group--date .taro-picker__columns{display:flex;height:100%;width:100%}.taro-picker__mask{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:1}.taro-picker__indicator{box-sizing:border-box;height:34px;left:0;position:absolute;top:50%;transform:translateY(-50%);width:100%;z-index:1002}.taro-picker__content{box-sizing:border-box;height:100%;width:100%}.taro-picker__item{align-items:center;box-sizing:border-box;display:flex;font-size:16px;height:34px;justify-content:center;line-height:34px;overflow:hidden;padding:0 8px;text-align:center;text-overflow:ellipsis;white-space:nowrap;width:100%}.taro-picker__item--selected{font-weight:500}.taro-picker__column{flex:1;margin:0 8px}.taro-picker__column:first-child{margin-left:0}.taro-picker__column:last-child{margin-right:0}.taro-picker__item--custom{align-items:center;color:#888;display:flex;font-weight:400;justify-content:center;text-align:center}@keyframes taro-picker__slide-up{0%{transform:translate3d(0,100%,0)}to{transform:translateZ(0)}}@keyframes taro-picker__slide-down{0%{transform:translateZ(0)}to{transform:translate3d(0,100%,0)}}@keyframes taro-picker__fade-in{0%{opacity:0}to{opacity:1}}@keyframes taro-picker__fade-out{0%{opacity:1}to{opacity:0}}.rmc-pull-to-refresh-content{transform-origin:left top 0}.rmc-pull-to-refresh-content-wrapper{min-height:100%}.rmc-pull-to-refresh-transition{transition:transform .3s}@keyframes rmc-pull-to-refresh-indicator{50%{opacity:.2}to{opacity:1}}.rmc-pull-to-refresh-indicator{height:30px;line-height:10px;text-align:center}.rmc-pull-to-refresh-indicator>div{animation-fill-mode:both;animation:rmc-pull-to-refresh-indicator .5s linear 0s infinite;background-color:grey;border-radius:100%;display:inline-block;height:6px;margin:3px;width:6px}.rmc-pull-to-refresh-indicator>div:nth-child(0){animation-delay:-.1s!important}.rmc-pull-to-refresh-indicator>div:first-child{animation-delay:-.2s!important}.rmc-pull-to-refresh-indicator>div:nth-child(2){animation-delay:-.3s!important}.rmc-pull-to-refresh-down .rmc-pull-to-refresh-indicator{margin-top:-25px}.taro-scroll{-webkit-overflow-scrolling:auto}.taro-scroll--hidebar::-webkit-scrollbar{display:none}.taro-scroll-view{overflow:hidden}.taro-scroll-view__scroll-x{overflow-x:scroll;overflow-y:hidden}.taro-scroll-view__scroll-y{overflow-x:hidden;overflow-y:scroll}.swiper-container-wrapper{height:150px}.swiper-container{height:100%;overflow:visible;position:relative}.taro-switch{cursor:pointer;display:inline-block;position:relative}.taro-switch--disabled{cursor:not-allowed;opacity:.5}.taro-switch--type-switch{border:1px solid #dfdfdf;box-sizing:border-box}.taro-switch--type-switch .taro-switch__thumb{background-color:#fff;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.4);left:1px;position:absolute;top:1px}.taro-switch--type-checkbox{border:1px solid #c9c9c9;box-sizing:border-box}.taro-switch--type-checkbox .taro-switch__checkmark{left:50%;position:absolute;top:50%}.taro-text{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.taro-text__selectable{-moz-user-select:text;-webkit-user-select:text;-ms-user-select:text;user-select:text}
package/dist/index.js CHANGED
@@ -1,15 +1,19 @@
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';
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, 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';
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';
6
7
  export { default as Picker } from './components/picker/index.js';
7
8
  export { default as PullDownRefresh } from './components/pull-down-refresh/index.js';
8
- export { default as Refresher } from './components/refresher/index.js';
9
+ export { Refresher } from './components/refresher/index.js';
10
+ export { ScrollElementContext } from './contexts/ScrollElementContext.js';
9
11
  export { default as ScrollView } from './components/scroll-view/index.js';
10
12
  export { Swiper, SwiperItem } from './components/swiper/index.js';
13
+ export { default as Switch } from './components/switch/index.js';
11
14
  export { default as Text } from './components/text/index.js';
12
15
  export { default as View } from './components/view/index.js';
16
+ export { createMapContext } from './components/map/createMapContext.js';
13
17
 
14
18
  /* eslint-disable simple-import-sort/exports */
15
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -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 { default as Map, type MapProps } from './components/map'\nexport { createMapContext } from './components/map'\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, type RefresherProps } 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 { default as Switch } from './components/switch'\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"}
@@ -11,16 +11,18 @@ function Image(props) {
11
11
  const [, setIsLoaded] = useState(false);
12
12
  const {
13
13
  className,
14
- style = {},
14
+ style,
15
15
  src,
16
16
  mode,
17
17
  onError,
18
18
  lazyLoad,
19
19
  imgProps,
20
- forwardedRef
20
+ forwardedRef,
21
+ disableDefaultSize = false
21
22
  } = props,
22
- reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"]);
23
+ reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef", "disableDefaultSize"]);
23
24
  const cls = classNames('taro-img', {
25
+ 'taro-img--with-default-host-size': !disableDefaultSize,
24
26
  'taro-img__widthfix': mode === 'widthFix'
25
27
  }, className);
26
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}\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","_jsx","ref","children","img","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;MACTC,KAAK,GAAG,EAAE;MACVC,GAAG;MACHC,IAAI;MACJC,OAAO;MACPC,QAAQ;MACRC,QAAQ;AACRC,MAAAA;AAAY,KAAA,GAEVb,KAAK;IADJc,KAAK,GAAAC,MAAA,CACNf,KAAK,EAVH,CAUL,WAAA,EAAA,OAAA,EAAA,KAAA,EAAA,MAAA,EAAA,SAAA,EAAA,UAAA,EAAA,UAAA,EAAA,cAAA,CAAA,CAAQ;AAET,EAAA,MAAMgB,GAAG,GAAGC,UAAU,CACpB,UAAU,EACV;IACE,oBAAoB,EAAER,IAAI,KAAK;GAChC,EACDH,SAAS,CACV;EACD,MAAMY,MAAM,GAAGD,UAAU,CACvB,iBAAiB,GACf,CAACR,IAAI,IAAI,aAAa,EAAEU,WAAW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,QAAQ,CAAC+B,OAAO,MAAE,IAAA,IAAAO,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAAA,EAAA,CAAAG,UAAU,kDAAI;KACjC;AACH,GAAC,EAAE,CAACjC,QAAQ,EAAEH,GAAG,CAAC,CAAC;AAEnB,EAAA,oBACEqC,GAAA,CAAA,KAAA,EAAA;AAAKvC,IAAAA,SAAS,EAAEU,GAAI;AAACT,IAAAA,KAAK,EAAEA,KAAM;AAACuC,IAAAA,GAAG,EAAEjC,YAAa;AAAA,IAAA,GAAKC,KAAK;IAAAiC,QAAA,EAC5DpC,QAAQ,gBACPkC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAK/C,MAAM,CAACiC,OAAO,GAAGc,GAAK;AACnC1C,MAAAA,SAAS,EAAEY,MAAO;AAClB,MAAA,UAAA,EAAUV,GAAI;AACdgB,MAAAA,MAAM,EAAEH,WAAY;AACpBX,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KAAS,CACb,gBAEFiC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAK/C,MAAM,CAACiC,OAAO,GAAGc,GAAK;AACnC1C,MAAAA,SAAS,EAAEY,MAAO;AAClBV,MAAAA,GAAG,EAAEA,GAAI;AACTgB,MAAAA,MAAM,EAAEH,WAAY;AACpBX,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KACJ;AACH,GACE,CAAC;AAEV;AAEA,YAAeqC,yBAAyB,CAAClD,KAAK,CAAC;;;;"}
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 /** 为 true 时不挂载默认占位尺寸(320×240),由业务 style/class 决定容器大小 */\n disableDefaultSize?: boolean\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 disableDefaultSize = false,\n ...reset\n } = props\n\n const cls = classNames(\n 'taro-img',\n {\n 'taro-img--with-default-host-size': !disableDefaultSize,\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","disableDefaultSize","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","_jsx","ref","children","img","createForwardRefComponent"],"mappings":";;;;;;;AAqBA,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;MACTC,KAAK;MACLC,GAAG;MACHC,IAAI;MACJC,OAAO;MACPC,QAAQ;MACRC,QAAQ;MACRC,YAAY;AACZC,MAAAA,kBAAkB,GAAG;AAEnB,KAAA,GAAAd,KAAK;IADJe,KAAK,GACNC,MAAA,CAAAhB,KAAK,EAXH,CAAA,WAAA,EAAA,OAAA,EAAA,KAAA,EAAA,MAAA,EAAA,SAAA,EAAA,UAAA,EAAA,UAAA,EAAA,cAAA,EAAA,oBAAA,CAWL,CAAQ;AAET,EAAA,MAAMiB,GAAG,GAAGC,UAAU,CACpB,UAAU,EACV;IACE,kCAAkC,EAAE,CAACJ,kBAAkB;IACvD,oBAAoB,EAAEL,IAAI,KAAK;GAChC,EACDH,SAAS,CACV;EACD,MAAMa,MAAM,GAAGD,UAAU,CACvB,iBAAiB,GACf,CAACT,IAAI,IAAI,aAAa,EAAEW,WAAW,EAAE,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3D;AAED,EAAA,MAAMC,WAAW,GAAGC,WAAW,CAAEC,CAAC,IAAI;IACpC,MAAM;AAAEC,MAAAA;AAAQ,KAAA,GAAGzB,KAAK;AACxB0B,IAAAA,M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nB,EAAA,oBACEsC,GAAA,CAAA,KAAA,EAAA;AAAKxC,IAAAA,SAAS,EAAEW,GAAI;AAACV,IAAAA,KAAK,EAAEA,KAAM;AAACwC,IAAAA,GAAG,EAAElC,YAAa;AAAA,IAAA,GAAKE,KAAK;IAAAiC,QAAA,EAC5DrC,QAAQ,gBACPmC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAKhD,MAAM,CAACkC,OAAO,GAAGc,GAAK;AACnC3C,MAAAA,SAAS,EAAEa,MAAO;AAClB,MAAA,UAAA,EAAUX,GAAI;AACdiB,MAAAA,MAAM,EAAEH,WAAY;AACpBZ,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KAAS,CACb,gBAEFkC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAKhD,MAAM,CAACkC,OAAO,GAAGc,GAAK;AACnC3C,MAAAA,SAAS,EAAEa,MAAO;AAClBX,MAAAA,GAAG,EAAEA,GAAI;AACTiB,MAAAA,MAAM,EAAEH,WAAY;AACpBZ,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KACJ;AACH,GACE,CAAC;AAEV;AAEA,YAAesC,yBAAyB,CAACnD,KAAK,CAAC;;;;"}
@@ -2,13 +2,17 @@ img[src=''] {
2
2
  opacity: 0;
3
3
  }
4
4
 
5
+ /* 默认占位宽高仅挂在 .taro-img--with-default-host-size(由 disableDefaultSize 控制是否挂载),与业务 class 同为单类优先级 */
5
6
  .taro-img {
6
7
  display: inline-block;
7
8
  overflow: hidden;
8
9
  position: relative;
10
+ font-size: 0;
11
+ }
12
+
13
+ .taro-img--with-default-host-size {
9
14
  width: 320px;
10
15
  height: 240px;
11
- font-size: 0;
12
16
  }
13
17
 
14
18
  .taro-img.taro-img__widthfix {