@tarojs/components-react 4.0.0-beta.132 → 4.0.0-beta.134
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/button/index.js +8 -5
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/icon/index.js +7 -4
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/image/index.js +8 -4
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/input/index.js +7 -3
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/pull-down-refresh/index.js +9 -3
- package/dist/components/pull-down-refresh/index.js.map +1 -1
- package/dist/components/scroll-view/index.js +5 -3
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/components/swiper/index.js +20 -6
- package/dist/components/swiper/index.js.map +1 -1
- package/dist/components/text/index.js +7 -3
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/view/index.js +7 -4
- package/dist/components/view/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/solid/components/button/index.js +9 -6
- package/dist/solid/components/button/index.js.map +1 -1
- package/dist/solid/components/icon/index.js +9 -5
- package/dist/solid/components/icon/index.js.map +1 -1
- package/dist/solid/components/image/index.js +9 -5
- package/dist/solid/components/image/index.js.map +1 -1
- package/dist/solid/components/input/index.js +9 -5
- package/dist/solid/components/input/index.js.map +1 -1
- package/dist/solid/components/pull-down-refresh/index.js +11 -5
- package/dist/solid/components/pull-down-refresh/index.js.map +1 -1
- package/dist/solid/components/scroll-view/index.js +5 -3
- package/dist/solid/components/scroll-view/index.js.map +1 -1
- package/dist/solid/components/swiper/index.js +22 -8
- package/dist/solid/components/swiper/index.js.map +1 -1
- package/dist/solid/components/text/index.js +8 -4
- package/dist/solid/components/text/index.js.map +1 -1
- package/dist/solid/components/view/index.js +9 -5
- package/dist/solid/components/view/index.js.map +1 -1
- package/dist/solid/index.css +1 -1
- package/dist/solid/utils/{hooks.js → hooks.solid.js} +16 -17
- package/dist/solid/utils/hooks.solid.js.map +1 -0
- package/dist/solid/utils/index.js +10 -1
- package/dist/solid/utils/index.js.map +1 -1
- package/dist/utils/hooks.react.js +15 -0
- package/dist/utils/hooks.react.js.map +1 -0
- package/dist/utils/index.js +12 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +6 -6
- package/types/index.d.ts +14 -0
- package/dist/components/view/style/index.css.js +0 -4
- package/dist/components/view/style/index.css.js.map +0 -1
- package/dist/solid/components/view/style/index.css.js +0 -4
- package/dist/solid/components/view/style/index.css.js.map +0 -1
- package/dist/solid/utils/hooks.js.map +0 -1
- package/dist/utils/hooks.js +0 -55
- package/dist/utils/hooks.js.map +0 -1
|
@@ -4,7 +4,7 @@ import './style/index.css.js';
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import React__default from 'react';
|
|
6
6
|
import Swipers from 'swiper/swiper-bundle.esm.js';
|
|
7
|
-
import { debounce } from '../../utils/index.js';
|
|
7
|
+
import { debounce, createForwardRefComponent } from '../../utils/index.js';
|
|
8
8
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
10
|
let INSTANCE_ID = 0;
|
|
@@ -18,18 +18,24 @@ const createEvent = type => {
|
|
|
18
18
|
}
|
|
19
19
|
return e;
|
|
20
20
|
};
|
|
21
|
-
class
|
|
21
|
+
class SwiperItemInner extends React__default.Component {
|
|
22
22
|
render() {
|
|
23
23
|
const _a = this.props,
|
|
24
24
|
{
|
|
25
25
|
className,
|
|
26
26
|
style,
|
|
27
27
|
itemId,
|
|
28
|
-
children
|
|
28
|
+
children,
|
|
29
|
+
forwardedRef
|
|
29
30
|
} = _a,
|
|
30
|
-
restProps = __rest(_a, ["className", "style", "itemId", "children"]);
|
|
31
|
+
restProps = __rest(_a, ["className", "style", "itemId", "children", "forwardedRef"]);
|
|
31
32
|
const cls = classNames('swiper-slide', className);
|
|
32
33
|
return /*#__PURE__*/jsx("div", {
|
|
34
|
+
ref: e => {
|
|
35
|
+
if (e && forwardedRef) {
|
|
36
|
+
forwardedRef.current = e;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
33
39
|
className: cls,
|
|
34
40
|
style: style,
|
|
35
41
|
"item-id": itemId,
|
|
@@ -38,7 +44,7 @@ class SwiperItem extends React__default.Component {
|
|
|
38
44
|
});
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
|
-
class
|
|
47
|
+
class SwiperInner extends React__default.Component {
|
|
42
48
|
constructor() {
|
|
43
49
|
super(...arguments);
|
|
44
50
|
this._id = 1 + INSTANCE_ID++;
|
|
@@ -235,7 +241,8 @@ class Swiper extends React__default.Component {
|
|
|
235
241
|
previousMargin,
|
|
236
242
|
nextMargin,
|
|
237
243
|
indicatorColor,
|
|
238
|
-
indicatorActiveColor
|
|
244
|
+
indicatorActiveColor,
|
|
245
|
+
forwardedRef
|
|
239
246
|
} = this.props;
|
|
240
247
|
const defaultIndicatorColor = indicatorColor || 'rgba(0, 0, 0, .3)';
|
|
241
248
|
const defaultIndicatorActiveColor = indicatorActiveColor || '#000';
|
|
@@ -254,6 +261,11 @@ class Swiper extends React__default.Component {
|
|
|
254
261
|
return /*#__PURE__*/jsx("div", {
|
|
255
262
|
className: `swiper-container-wrapper ${cls}`,
|
|
256
263
|
style: sty,
|
|
264
|
+
ref: e => {
|
|
265
|
+
if (forwardedRef && e) {
|
|
266
|
+
forwardedRef.current = e;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
257
269
|
children: /*#__PURE__*/jsxs("div", {
|
|
258
270
|
className: "swiper-container",
|
|
259
271
|
style: {
|
|
@@ -279,6 +291,8 @@ class Swiper extends React__default.Component {
|
|
|
279
291
|
});
|
|
280
292
|
}
|
|
281
293
|
}
|
|
294
|
+
const Swiper = createForwardRefComponent(SwiperInner);
|
|
295
|
+
const SwiperItem = createForwardRefComponent(SwiperItemInner);
|
|
282
296
|
|
|
283
297
|
export { Swiper, SwiperItem };
|
|
284
298
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/swiper/index.tsx"],"sourcesContent":["import 'swiper/swiper-bundle.min.css'\nimport './style/index.css'\n\nimport classNames from 'classnames'\nimport React from 'react'\nimport Swipers from 'swiper/swiper-bundle.esm.js'\n\nimport { debounce } from '../../utils'\n\nimport type ISwiper from 'swiper'\n\nlet INSTANCE_ID = 0\n\ninterface SwiperItemProps extends React.HTMLAttributes<HTMLDivElement> {\n itemId: string\n}\n\ninterface SwiperProps extends React.HTMLAttributes<HTMLDivElement> {\n autoplay?: boolean\n interval?: number\n duration?: number\n current?: number\n displayMultipleItems?: number\n circular?: boolean\n vertical?: boolean\n spaceBetween?: any\n previousMargin?: string\n nextMargin?: string\n indicatorColor?: string\n indicatorActiveColor?: string\n indicatorDots?: boolean\n onAnimationFinish?: (e: TouchEvent) => void\n}\n\nconst createEvent = (type: string) => {\n let e\n try {\n e = new TouchEvent(type)\n } catch (err) {\n e = document.createEvent('Event')\n e.initEvent(type, true, true)\n }\n return e\n}\n\nclass SwiperItem extends React.Component<SwiperItemProps, Record<string, unknown>> {\n render () {\n const { className, style, itemId, children, ...restProps } = this.props\n const cls = classNames('swiper-slide', className)\n return (\n <div\n className={cls}\n style={style}\n item-id={itemId}\n {...restProps}\n >\n {children}\n </div>\n )\n }\n}\n\nclass Swiper extends React.Component<SwiperProps, Record<string, unknown>> {\n _id = 1 + INSTANCE_ID++\n _$current = 0\n _$width = 0\n _$height = 0\n $el: HTMLDivElement | null\n mySwiper: ISwiper\n observer: MutationObserver\n observerFirst: MutationObserver\n observerLast: MutationObserver\n\n componentDidMount () {\n const {\n autoplay = false,\n circular = true,\n current = 0,\n displayMultipleItems = 1,\n duration = 500,\n interval = 5000,\n spaceBetween,\n vertical\n } = this.props\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this\n const opt: Record<string, any> = {\n // 指示器\n pagination: { el: `.taro-swiper-${this._id} > .swiper-container > .swiper-pagination` },\n direction: vertical ? 'vertical' : 'horizontal',\n loop: circular,\n slidesPerView: parseFloat(String(displayMultipleItems)),\n initialSlide: parseInt(String(current), 10),\n speed: parseInt(String(duration), 10),\n observer: true,\n observeParents: true,\n on: {\n slideChange () {\n const e = createEvent('touchend')\n try {\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n value: {\n current: this.realIndex\n }\n })\n } catch (err) {} // eslint-disable-line no-empty\n that._$current = this.realIndex\n that.handleOnChange(e)\n },\n transitionEnd () {\n const e = createEvent('touchend')\n try {\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n value: {\n current: this.mySwiper.realIndex\n }\n })\n if (this.mySwiper.isBeginning) {\n this.mySwiper.slideToLoop((this.props.children as any).length - 1, 0)\n } else if (this.mySwiper.isEnd) {\n this.mySwiper.slideToLoop(0, 0)\n }\n } catch (err) {} // eslint-disable-line no-empty\n that.handleOnAnimationFinish(e)\n },\n observerUpdate (_swiper: ISwiper, e) {\n const target = e.target\n const className = target && typeof target.className === 'string' ? target.className : ''\n if (className.includes('taro_page') && target.style.display !== 'none') {\n if (that.props.autoplay && target.contains(_swiper.$el[0])) {\n if (that.props.circular) {\n _swiper.slideToLoop(this.realIndex, 0) // 更新下标\n } else {\n _swiper.slideTo(this.realIndex)\n }\n }\n }\n }\n }\n }\n\n // 自动播放\n if (autoplay) {\n opt.autoplay = {\n delay: parseInt(String(interval), 10),\n disableOnInteraction: false\n }\n }\n\n // 两端距离\n if (spaceBetween) {\n opt.spaceBetween = spaceBetween\n }\n\n this.mySwiper = new Swipers(this.$el!, opt)\n setTimeout(() => {\n this.mySwiper.update()\n }, 500)\n\n if (!this.mySwiper || !this.props.circular) return\n\n const wrapper = this.mySwiper.$wrapperEl[0]\n this.observer = new MutationObserver(this.handleSwiperLoopListen)\n\n this.observer.observe(wrapper, {\n childList: true\n })\n }\n\n UNSAFE_componentWillReceiveProps (nextProps) {\n if (this.mySwiper) {\n const nextCurrent = typeof nextProps.current === 'number' ? nextProps.current : this._$current || 0\n\n this.handleSwiperLoop()\n // 是否衔接滚动模式\n if (nextProps.circular) {\n if (!this.mySwiper.isBeginning && !this.mySwiper.isEnd) {\n this.mySwiper.slideToLoop(parseInt(nextCurrent, 10)) // 更新下标\n }\n } else {\n this.mySwiper.slideTo(parseInt(nextCurrent, 10) + 1) // 更新下标\n }\n\n const autoplay = this.mySwiper.autoplay\n // 判断是否需要停止或开始自动轮播\n if (autoplay.running !== nextProps.autoplay) {\n if (nextProps.autoplay) {\n if (typeof this.mySwiper.params.autoplay === 'object') {\n this.mySwiper.params.autoplay.disableOnInteraction = false\n this.mySwiper.params.autoplay.delay = parseInt(String(this.props.interval) || '3000', 10)\n }\n autoplay.start()\n } else {\n autoplay.stop()\n }\n }\n\n this.mySwiper.update() // 更新子元素\n }\n }\n\n componentDidUpdate (preProps) {\n if (preProps.children.length === 0 && (this.props.children as any).length > 0) {\n (this.mySwiper as any).loopDestroy()\n ;(this.mySwiper as any).loopCreate()\n }\n if (!this.mySwiper) return\n if (this.props.autoplay) {\n if (this._$width !== this.mySwiper.width || this._$height !== this.mySwiper.height) {\n this.mySwiper.autoplay.start()\n }\n }\n this._$width = this.mySwiper.width\n this._$height = this.mySwiper.height\n }\n\n componentWillUnmount () {\n this.$el = null\n if (this.mySwiper) this.mySwiper.destroy()\n this.observer?.disconnect?.()\n this.observerFirst?.disconnect?.()\n this.observerLast?.disconnect?.()\n }\n\n handleOnChange (e: React.FormEvent<HTMLDivElement>) {\n const func = this.props.onChange\n typeof func === 'function' && func(e)\n }\n\n handleOnAnimationFinish (e: TouchEvent) {\n const func = this.props.onAnimationFinish\n typeof func === 'function' && func(e)\n }\n\n parsePX (s = '0px') {\n return parseFloat(s.replace(/r*px/i, ''))\n }\n\n handleSwiperLoopListen = () => {\n this.observerFirst?.disconnect?.()\n this.observerLast?.disconnect?.()\n this.observerFirst = new MutationObserver(this.handleSwiperLoop)\n this.observerLast = new MutationObserver(this.handleSwiperLoop)\n const wrapper = this.mySwiper.$wrapperEl[0]\n const list = wrapper.querySelectorAll('taro-swiper-item-core:not(.swiper-slide-duplicate)')\n if (list.length >= 1) {\n this.observerFirst.observe(list[0], {\n characterData: true\n })\n } else if (list.length >= 2) {\n this.observerLast.observe(list[list.length - 1], {\n characterData: true\n })\n }\n }\n\n handleSwiperLoop = debounce(() => {\n if (this.mySwiper && this.mySwiper.$wrapperEl && this.props.circular) {\n // @ts-ignore\n this.mySwiper.loopDestroy()\n // @ts-ignore\n this.mySwiper.loopCreate()\n }\n }, 500)\n\n render () {\n const {\n className,\n style,\n vertical,\n previousMargin,\n nextMargin,\n indicatorColor,\n indicatorActiveColor\n } = this.props\n const defaultIndicatorColor = indicatorColor || 'rgba(0, 0, 0, .3)'\n const defaultIndicatorActiveColor = indicatorActiveColor || '#000'\n const cls = classNames(`taro-swiper-${this._id}`, className)\n const sty = Object.assign({\n paddingTop: vertical ? this.parsePX(previousMargin) : 0,\n paddingRight: vertical ? 0 : this.parsePX(nextMargin),\n paddingBottom: vertical ? this.parsePX(nextMargin) : 0,\n paddingLeft: vertical ? 0 : this.parsePX(previousMargin),\n overflow: 'hidden'\n }, style)\n const paginationCls = classNames(\n 'swiper-pagination',\n {\n 'swiper-pagination-hidden': !this.props.indicatorDots,\n 'swiper-pagination-bullets': this.props.indicatorDots\n }\n )\n return (\n <div className={`swiper-container-wrapper ${cls}`} style={sty}>\n <div className='swiper-container' style={{ overflow: 'visible' }} ref={(el) => { this.$el = el }}>\n <div\n dangerouslySetInnerHTML={{\n __html: `<style type='text/css'>\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet { background: ${defaultIndicatorColor} }\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet-active { background: ${defaultIndicatorActiveColor} }\n </style>`\n }}\n />\n <div className='swiper-wrapper'>{this.props.children}</div>\n <div className={paginationCls} />\n </div>\n </div>\n )\n }\n}\n\nexport { Swiper, SwiperItem }\n"],"names":["INSTANCE_ID","createEvent","type","e","TouchEvent","err","document","initEvent","SwiperItem","React","Component","render","_a","props","className","style","itemId","children","restProps","__rest","cls","classNames","_jsx","Swiper","constructor","_id","_$current","_$width","_$height","handleSwiperLoopListen","_b","observerFirst","disconnect","_d","observerLast","_c","MutationObserver","handleSwiperLoop","wrapper","mySwiper","$wrapperEl","list","querySelectorAll","length","observe","characterData","debounce","circular","loopDestroy","loopCreate","componentDidMount","autoplay","current","displayMultipleItems","duration","interval","spaceBetween","vertical","that","opt","pagination","el","direction","loop","slidesPerView","parseFloat","String","initialSlide","parseInt","speed","observer","observeParents","on","slideChange","Object","defineProperty","enumerable","value","realIndex","handleOnChange","transitionEnd","isBeginning","slideToLoop","isEnd","handleOnAnimationFinish","observerUpdate","_swiper","target","includes","display","contains","$el","slideTo","delay","disableOnInteraction","Swipers","setTimeout","update","childList","UNSAFE_componentWillReceiveProps","nextProps","nextCurrent","running","params","start","stop","componentDidUpdate","preProps","width","height","componentWillUnmount","destroy","_f","_e","func","onChange","onAnimationFinish","parsePX","s","arguments","undefined","replace","previousMargin","nextMargin","indicatorColor","indicatorActiveColor","defaultIndicatorColor","defaultIndicatorActiveColor","sty","assign","paddingTop","paddingRight","paddingBottom","paddingLeft","overflow","paginationCls","indicatorDots","_jsxs","ref","dangerouslySetInnerHTML","__html"],"mappings":";;;;;;;;;AAWA,IAAIA,WAAW,GAAG,CAAC,CAAA;AAuBnB,MAAMC,WAAW,GAAIC,IAAY,IAAI;AACnC,EAAA,IAAIC,CAAC,CAAA;EACL,IAAI;AACFA,IAAAA,CAAC,GAAG,IAAIC,UAAU,CAACF,IAAI,CAAC,CAAA;GACzB,CAAC,OAAOG,GAAG,EAAE;AACZF,IAAAA,CAAC,GAAGG,QAAQ,CAACL,WAAW,CAAC,OAAO,CAAC,CAAA;IACjCE,CAAC,CAACI,SAAS,CAACL,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAC/B,GAAA;AACA,EAAA,OAAOC,CAAC,CAAA;AACV,CAAC,CAAA;AAED,MAAMK,UAAW,SAAQC,cAAK,CAACC,SAAm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AAA,GAAG,CAAG,CAAA;AAACL,MAAAA,KAAK,EAAEiH,GAAI;AAAA/G,MAAAA,QAAA,eAC5DwH,IAAA,CAAA,KAAA,EAAA;AAAK3H,QAAAA,SAAS,EAAC,kBAAkB;AAACC,QAAAA,KAAK,EAAE;AAAEuH,UAAAA,QAAQ,EAAE,SAAA;SAAY;QAACI,GAAG,EAAG7E,EAAE,IAAO;UAAA,IAAI,CAAC8B,GAAG,GAAG9B,EAAE,CAAA;SAAG;AAAA5C,QAAAA,QAAA,gBAC/FK,GAAA,CAAA,KAAA,EAAA;AACEqH,UAAAA,uBAAuB,EAAE;AACvBC,YAAAA,MAAM,EAAE,CAAA;6BACO,IAAI,CAACnH,GAAG,CAAA,oFAAA,EAAuFqG,qBAAqB,CAAA;6BACpH,IAAI,CAACrG,GAAG,CAAA,2FAAA,EAA8FsG,2BAA2B,CAAA;AACvI,sBAAA,CAAA;AACV,WAAA;SAEH,CAAA,eAAAzG,GAAA,CAAA,KAAA,EAAA;AAAKR,UAAAA,SAAS,EAAC,gBAAgB;AAAAG,UAAAA,QAAA,EAAE,IAAI,CAACJ,KAAK,CAACI,QAAAA;SAAc,CAC1D,eAAAK,GAAA,CAAA,KAAA,EAAA;AAAKR,UAAAA,SAAS,EAAEyH,aAAAA;AAAc,SAChC,CAAA,CAAA;OAAK,CAAA;AACP,KAAK,CAAC,CAAA;AAEV,GAAA;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/swiper/index.tsx"],"sourcesContent":["import 'swiper/swiper-bundle.min.css'\nimport './style/index.css'\n\nimport classNames from 'classnames'\nimport React from 'react'\nimport Swipers from 'swiper/swiper-bundle.esm.js'\n\nimport { createForwardRefComponent, debounce } from '../../utils'\n\nimport type ISwiper from 'swiper'\n\nlet INSTANCE_ID = 0\n\ninterface SwiperItemProps extends React.HTMLAttributes<HTMLDivElement> {\n itemId: string\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n}\n\ninterface SwiperProps extends React.HTMLAttributes<HTMLDivElement> {\n autoplay?: boolean\n interval?: number\n duration?: number\n current?: number\n displayMultipleItems?: number\n circular?: boolean\n vertical?: boolean\n spaceBetween?: any\n previousMargin?: string\n nextMargin?: string\n indicatorColor?: string\n indicatorActiveColor?: string\n indicatorDots?: boolean\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n onAnimationFinish?: (e: TouchEvent) => void\n}\n\nconst createEvent = (type: string) => {\n let e\n try {\n e = new TouchEvent(type)\n } catch (err) {\n e = document.createEvent('Event')\n e.initEvent(type, true, true)\n }\n return e\n}\n\nclass SwiperItemInner extends React.Component<SwiperItemProps, Record<string, unknown>> {\n render () {\n const { className, style, itemId, children, forwardedRef, ...restProps } = this.props\n const cls = classNames('swiper-slide', className)\n return (\n <div\n ref={(e) => {\n if (e && forwardedRef) {\n forwardedRef.current = e\n }\n }}\n className={cls}\n style={style}\n item-id={itemId}\n {...restProps}\n >\n {children}\n </div>\n )\n }\n}\n\nclass SwiperInner extends React.Component<SwiperProps, Record<string, unknown>> {\n _id = 1 + INSTANCE_ID++\n _$current = 0\n _$width = 0\n _$height = 0\n $el: HTMLDivElement | null\n mySwiper: ISwiper\n observer: MutationObserver\n observerFirst: MutationObserver\n observerLast: MutationObserver\n\n componentDidMount () {\n const {\n autoplay = false,\n circular = true,\n current = 0,\n displayMultipleItems = 1,\n duration = 500,\n interval = 5000,\n spaceBetween,\n vertical\n } = this.props\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this\n const opt: Record<string, any> = {\n // 指示器\n pagination: { el: `.taro-swiper-${this._id} > .swiper-container > .swiper-pagination` },\n direction: vertical ? 'vertical' : 'horizontal',\n loop: circular,\n slidesPerView: parseFloat(String(displayMultipleItems)),\n initialSlide: parseInt(String(current), 10),\n speed: parseInt(String(duration), 10),\n observer: true,\n observeParents: true,\n on: {\n slideChange () {\n const e = createEvent('touchend')\n try {\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n value: {\n current: this.realIndex\n }\n })\n } catch (err) {} // eslint-disable-line no-empty\n that._$current = this.realIndex\n that.handleOnChange(e)\n },\n transitionEnd () {\n const e = createEvent('touchend')\n try {\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n value: {\n current: this.mySwiper.realIndex\n }\n })\n if (this.mySwiper.isBeginning) {\n this.mySwiper.slideToLoop((this.props.children as any).length - 1, 0)\n } else if (this.mySwiper.isEnd) {\n this.mySwiper.slideToLoop(0, 0)\n }\n } catch (err) {} // eslint-disable-line no-empty\n that.handleOnAnimationFinish(e)\n },\n observerUpdate (_swiper: ISwiper, e) {\n const target = e.target\n const className = target && typeof target.className === 'string' ? target.className : ''\n if (className.includes('taro_page') && target.style.display !== 'none') {\n if (that.props.autoplay && target.contains(_swiper.$el[0])) {\n if (that.props.circular) {\n _swiper.slideToLoop(this.realIndex, 0) // 更新下标\n } else {\n _swiper.slideTo(this.realIndex)\n }\n }\n }\n }\n }\n }\n\n // 自动播放\n if (autoplay) {\n opt.autoplay = {\n delay: parseInt(String(interval), 10),\n disableOnInteraction: false\n }\n }\n\n // 两端距离\n if (spaceBetween) {\n opt.spaceBetween = spaceBetween\n }\n\n this.mySwiper = new Swipers(this.$el!, opt)\n setTimeout(() => {\n this.mySwiper.update()\n }, 500)\n\n if (!this.mySwiper || !this.props.circular) return\n\n const wrapper = this.mySwiper.$wrapperEl[0]\n this.observer = new MutationObserver(this.handleSwiperLoopListen)\n\n this.observer.observe(wrapper, {\n childList: true\n })\n }\n\n UNSAFE_componentWillReceiveProps (nextProps) {\n if (this.mySwiper) {\n const nextCurrent = typeof nextProps.current === 'number' ? nextProps.current : this._$current || 0\n\n this.handleSwiperLoop()\n // 是否衔接滚动模式\n if (nextProps.circular) {\n if (!this.mySwiper.isBeginning && !this.mySwiper.isEnd) {\n this.mySwiper.slideToLoop(parseInt(nextCurrent, 10)) // 更新下标\n }\n } else {\n this.mySwiper.slideTo(parseInt(nextCurrent, 10) + 1) // 更新下标\n }\n\n const autoplay = this.mySwiper.autoplay\n // 判断是否需要停止或开始自动轮播\n if (autoplay.running !== nextProps.autoplay) {\n if (nextProps.autoplay) {\n if (typeof this.mySwiper.params.autoplay === 'object') {\n this.mySwiper.params.autoplay.disableOnInteraction = false\n this.mySwiper.params.autoplay.delay = parseInt(String(this.props.interval) || '3000', 10)\n }\n autoplay.start()\n } else {\n autoplay.stop()\n }\n }\n\n this.mySwiper.update() // 更新子元素\n }\n }\n\n componentDidUpdate (preProps) {\n if (preProps.children.length === 0 && (this.props.children as any).length > 0) {\n (this.mySwiper as any).loopDestroy()\n ;(this.mySwiper as any).loopCreate()\n }\n if (!this.mySwiper) return\n if (this.props.autoplay) {\n if (this._$width !== this.mySwiper.width || this._$height !== this.mySwiper.height) {\n this.mySwiper.autoplay.start()\n }\n }\n this._$width = this.mySwiper.width\n this._$height = this.mySwiper.height\n }\n\n componentWillUnmount () {\n this.$el = null\n if (this.mySwiper) this.mySwiper.destroy()\n this.observer?.disconnect?.()\n this.observerFirst?.disconnect?.()\n this.observerLast?.disconnect?.()\n }\n\n handleOnChange (e: React.FormEvent<HTMLDivElement>) {\n const func = this.props.onChange\n typeof func === 'function' && func(e)\n }\n\n handleOnAnimationFinish (e: TouchEvent) {\n const func = this.props.onAnimationFinish\n typeof func === 'function' && func(e)\n }\n\n parsePX (s = '0px') {\n return parseFloat(s.replace(/r*px/i, ''))\n }\n\n handleSwiperLoopListen = () => {\n this.observerFirst?.disconnect?.()\n this.observerLast?.disconnect?.()\n this.observerFirst = new MutationObserver(this.handleSwiperLoop)\n this.observerLast = new MutationObserver(this.handleSwiperLoop)\n const wrapper = this.mySwiper.$wrapperEl[0]\n const list = wrapper.querySelectorAll('taro-swiper-item-core:not(.swiper-slide-duplicate)')\n if (list.length >= 1) {\n this.observerFirst.observe(list[0], {\n characterData: true\n })\n } else if (list.length >= 2) {\n this.observerLast.observe(list[list.length - 1], {\n characterData: true\n })\n }\n }\n\n handleSwiperLoop = debounce(() => {\n if (this.mySwiper && this.mySwiper.$wrapperEl && this.props.circular) {\n // @ts-ignore\n this.mySwiper.loopDestroy()\n // @ts-ignore\n this.mySwiper.loopCreate()\n }\n }, 500)\n\n render () {\n const {\n className,\n style,\n vertical,\n previousMargin,\n nextMargin,\n indicatorColor,\n indicatorActiveColor,\n forwardedRef\n } = this.props\n const defaultIndicatorColor = indicatorColor || 'rgba(0, 0, 0, .3)'\n const defaultIndicatorActiveColor = indicatorActiveColor || '#000'\n const cls = classNames(`taro-swiper-${this._id}`, className)\n const sty = Object.assign({\n paddingTop: vertical ? this.parsePX(previousMargin) : 0,\n paddingRight: vertical ? 0 : this.parsePX(nextMargin),\n paddingBottom: vertical ? this.parsePX(nextMargin) : 0,\n paddingLeft: vertical ? 0 : this.parsePX(previousMargin),\n overflow: 'hidden'\n }, style)\n const paginationCls = classNames(\n 'swiper-pagination',\n {\n 'swiper-pagination-hidden': !this.props.indicatorDots,\n 'swiper-pagination-bullets': this.props.indicatorDots\n }\n )\n return (\n <div className={`swiper-container-wrapper ${cls}`} style={sty} ref={(e) => {\n if (forwardedRef && e) {\n forwardedRef.current = e\n }\n }}>\n <div className='swiper-container' style={{ overflow: 'visible' }} ref={(el) => { this.$el = el }}>\n <div\n dangerouslySetInnerHTML={{\n __html: `<style type='text/css'>\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet { background: ${defaultIndicatorColor} }\n .taro-swiper-${this._id} > .swiper-container > .swiper-pagination > .swiper-pagination-bullet-active { background: ${defaultIndicatorActiveColor} }\n </style>`\n }}\n />\n <div className='swiper-wrapper'>{this.props.children}</div>\n <div className={paginationCls} />\n </div>\n </div>\n )\n }\n}\n\nexport const Swiper = createForwardRefComponent(SwiperInner)\nexport const SwiperItem = createForwardRefComponent(SwiperItemInner)\n"],"names":["INSTANCE_ID","createEvent","type","e","TouchEvent","err","document","initEvent","SwiperItemInner","React","Component","render","_a","props","className","style","itemId","children","forwardedRef","restProps","__rest","cls","classNames","_jsx","ref","current","SwiperInner","constructor","_id","_$current","_$width","_$height","handleSwiperLoopListen","_b","observerFirst","disconnect","_d","observerLast","_c","MutationObserver","handleSwiperLoop","wrapper","mySwiper","$wrapperEl","list","querySelectorAll","length","observe","characterData","debounce","circular","loopDestroy","loopCreate","componentDidMount","autoplay","displayMultipleItems","duration","interval","spaceBetween","vertical","that","opt","pagination","el","direction","loop","slidesPerView","parseFloat","String","initialSlide","parseInt","speed","observer","observeParents","on","slideChange","Object","defineProperty","enumerable","value","realIndex","handleOnChange","transitionEnd","isBeginning","slideToLoop","isEnd","handleOnAnimationFinish","observerUpdate","_swiper","target","includes","display","contains","$el","slideTo","delay","disableOnInteraction","Swipers","setTimeout","update","childList","UNSAFE_componentWillReceiveProps","nextProps","nextCurrent","running","params","start","stop","componentDidUpdate","preProps","width","height","componentWillUnmount","destroy","_f","_e","func","onChange","onAnimationFinish","parsePX","s","arguments","undefined","replace","previousMargin","nextMargin","indicatorColor","indicatorActiveColor","defaultIndicatorColor","defaultIndicatorActiveColor","sty","assign","paddingTop","paddingRight","paddingBottom","paddingLeft","overflow","paginationCls","indicatorDots","_jsxs","dangerouslySetInnerHTML","__html","Swiper","createForwardRefComponent","SwiperItem"],"mappings":";;;;;;;;;AAWA,IAAIA,WAAW,GAAG,CAAC,CAAA;AAyBnB,MAAMC,WAAW,GAAIC,IAAY,IAAI;AACnC,EAAA,IAAIC,CAAC,CAAA;EACL,IAAI;AACFA,IAAAA,CAAC,GAAG,IAAIC,UAAU,CAACF,IAAI,CAAC,CAAA;GACzB,CAAC,OAAOG,GAAG,EAAE;AACZF,IAAAA,CAAC,GAAGG,QAAQ,CAACL,WAAW,CAAC,OAAO,CAAC,CAAA;IACjCE,CAAC,CAACI,SAAS,CAACL,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAC/B,GAAA;AACA,EAAA,OAAOC,CAAC,CAAA;AACV,CAAC,CAAA;AAED,MAAMK,eAAgB,SAAQC,cAAK,CAACC,SAAmD,CAAA;AACrFC,EAAAA,MAAMA,GAAA;A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,eAAe;;;;"}
|
|
@@ -2,23 +2,27 @@ import { __rest } from 'tslib';
|
|
|
2
2
|
import './style/index.css.js';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import 'react';
|
|
5
|
+
import { createForwardRefComponent } from '../../utils/index.js';
|
|
5
6
|
import { jsx } from 'react/jsx-runtime';
|
|
6
7
|
|
|
7
8
|
function Text(props) {
|
|
8
9
|
const {
|
|
9
10
|
className,
|
|
10
|
-
selectable = false
|
|
11
|
+
selectable = false,
|
|
12
|
+
forwardedRef
|
|
11
13
|
} = props,
|
|
12
|
-
restProps = __rest(props, ["className", "selectable"]);
|
|
14
|
+
restProps = __rest(props, ["className", "selectable", "forwardedRef"]);
|
|
13
15
|
const cls = classNames('taro-text', {
|
|
14
16
|
'taro-text__selectable': selectable
|
|
15
17
|
}, className);
|
|
16
18
|
return /*#__PURE__*/jsx("span", {
|
|
17
19
|
...restProps,
|
|
18
20
|
className: cls,
|
|
21
|
+
ref: forwardedRef,
|
|
19
22
|
children: props.children
|
|
20
23
|
});
|
|
21
24
|
}
|
|
25
|
+
var index = createForwardRefComponent(Text);
|
|
22
26
|
|
|
23
|
-
export {
|
|
27
|
+
export { index as default };
|
|
24
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/text/index.tsx"],"sourcesContent":["import './style/index.css'\n\nimport classNames from 'classnames'\nimport React from 'react'\n\ninterface IProps extends React.HTMLAttributes<HTMLSpanElement> {\n selectable?: boolean\n}\n\nfunction Text (props: IProps) {\n const { className, selectable = false, ...restProps } = props\n const cls = classNames(\n 'taro-text',\n {\n 'taro-text__selectable': selectable\n },\n className\n )\n return (\n <span {...restProps} className={cls}>\n {props.children}\n </span>\n )\n}\n\nexport default Text\n"],"names":["Text","props","className","selectable","restProps","__rest","cls","classNames","_jsx","children"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/text/index.tsx"],"sourcesContent":["import './style/index.css'\n\nimport classNames from 'classnames'\nimport React from 'react'\n\nimport { createForwardRefComponent } from '../../utils'\n\ninterface IProps extends React.HTMLAttributes<HTMLSpanElement> {\n selectable?: boolean\n forwardedRef?: React.MutableRefObject<HTMLSpanElement>\n}\n\nfunction Text (props: IProps) {\n const { className, selectable = false, forwardedRef, ...restProps } = props\n const cls = classNames(\n 'taro-text',\n {\n 'taro-text__selectable': selectable\n },\n className\n )\n return (\n <span {...restProps} className={cls} ref={forwardedRef}>\n {props.children}\n </span>\n )\n}\n\nexport default createForwardRefComponent(Text)\n"],"names":["Text","props","className","selectable","forwardedRef","restProps","__rest","cls","classNames","_jsx","ref","children","createForwardRefComponent"],"mappings":";;;;;;;AAYA,SAASA,IAAIA,CAAEC,KAAa,EAAA;EAC1B,MAAM;MAAEC,SAAS;AAAEC,MAAAA,UAAU,GAAG,KAAK;AAAEC,MAAAA,YAAAA;AAA+B,KAAA,GAAAH,KAAK;AAAnBI,IAAAA,SAAS,GAAAC,MAAA,CAAKL,KAAK,EAArE,CAAA,WAAA,EAAA,YAAA,EAAA,cAAA,CAA6D,CAAQ,CAAA;AAC3E,EAAA,MAAMM,GAAG,GAAGC,UAAU,CACpB,WAAW,EACX;AACE,IAAA,uBAAuB,EAAEL,UAAAA;GAC1B,EACDD,SAAS,CACV,CAAA;AACD,EAAA,oBACEO,GAAA,CAAA,MAAA,EAAA;AAAA,IAAA,GAAUJ,SAAS;AAAEH,IAAAA,SAAS,EAAEK,GAAI;AAACG,IAAAA,GAAG,EAAEN,YAAa;IAAAO,QAAA,EACpDV,KAAK,CAACU,QAAAA;AAAQ,GACX,CAAC,CAAA;AAEX,CAAA;AAEA,YAAeC,yBAAyB,CAACZ,IAAI,CAAC;;;;"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import './style/index.css.js';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
|
-
import { useState, useEffect } from '../../utils/hooks.js';
|
|
3
|
+
import { useState, useEffect } from '../../utils/hooks.react.js';
|
|
4
|
+
import { createForwardRefComponent } from '../../utils/index.js';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
function View(_a) {
|
|
8
8
|
var {
|
|
9
9
|
className,
|
|
10
10
|
hoverClass,
|
|
11
|
+
forwardedRef,
|
|
11
12
|
onTouchStart,
|
|
12
13
|
onTouchEnd,
|
|
13
14
|
onTouchMove,
|
|
14
15
|
hoverStartTime = 50,
|
|
15
16
|
hoverStayTime = 400
|
|
16
17
|
} = _a,
|
|
17
|
-
other = __rest(_a, ["className", "hoverClass", "onTouchStart", "onTouchEnd", "onTouchMove", "hoverStartTime", "hoverStayTime"]);
|
|
18
|
+
other = __rest(_a, ["className", "hoverClass", "forwardedRef", "onTouchStart", "onTouchEnd", "onTouchMove", "hoverStartTime", "hoverStayTime"]);
|
|
18
19
|
let timeoutEvent;
|
|
19
20
|
let startTime = 0;
|
|
20
21
|
const [hover, setHover] = useState(false);
|
|
@@ -64,6 +65,7 @@ function View(_a) {
|
|
|
64
65
|
}, className));
|
|
65
66
|
}, [hover, className]);
|
|
66
67
|
return /*#__PURE__*/jsx("div", {
|
|
68
|
+
ref: forwardedRef,
|
|
67
69
|
className: "react" === 'solid' ? cls() : cls,
|
|
68
70
|
onTouchStart: _onTouchStart,
|
|
69
71
|
onTouchEnd: _onTouchEnd,
|
|
@@ -72,6 +74,7 @@ function View(_a) {
|
|
|
72
74
|
children: other.children
|
|
73
75
|
});
|
|
74
76
|
}
|
|
77
|
+
var index = createForwardRefComponent(View);
|
|
75
78
|
|
|
76
|
-
export {
|
|
79
|
+
export { index as default };
|
|
77
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/view/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/view/index.tsx"],"sourcesContent":["import classNames from 'classnames'\n\nimport { useEffect, useState } from '../../utils/hooks'\nimport { createForwardRefComponent } from '../../utils/index'\n\nimport type { TFunc } from '@tarojs/runtime/dist/runtime.esm'\nimport type React from 'react'\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n hoverClass?: string\n hoverStartTime?: number\n hoverStayTime?: number\n onTouchStart?(e: React.TouchEvent<HTMLDivElement>): void\n onTouchEnd?(e: React.TouchEvent<HTMLDivElement>): void\n onTouchMove?(e: React.TouchEvent<HTMLDivElement>): void\n onLongPress?(): void\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n}\n\nfunction View ({\n className,\n hoverClass,\n forwardedRef,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n hoverStartTime = 50,\n hoverStayTime = 400,\n ...other\n}: IProps) {\n let timeoutEvent: ReturnType<typeof setTimeout>\n let startTime = 0\n const [hover, setHover] = useState<boolean>(false)\n const [touch, setTouch] = useState<boolean>(false)\n\n const [cls, setCls] = useState<string>(classNames(\n '',\n {\n [`${hoverClass}`]: process.env.FRAMEWORK === 'solid' ? (hover as unknown as TFunc)() : hover\n },\n className\n ))\n\n const _onTouchStart = e => {\n if (hoverClass) {\n setTouch(true)\n setTimeout(() => {\n if (process.env.FRAMEWORK === 'solid' ? (touch as unknown as TFunc)() : touch) {\n setHover(true)\n }\n }, hoverStartTime)\n }\n onTouchStart && onTouchStart(e)\n if (other.onLongPress) {\n timeoutEvent = setTimeout(() => {\n other.onLongPress!()\n }, 350)\n startTime = new Date().getTime()\n }\n }\n\n const _onTouchMove = e => {\n clearTimeout(timeoutEvent)\n onTouchMove && onTouchMove(e)\n }\n\n const _onTouchEnd = e => {\n const spanTime = new Date().getTime() - startTime\n if (spanTime < 350) {\n clearTimeout(timeoutEvent)\n }\n if (hoverClass) {\n setTouch(false)\n setTimeout(() => {\n if (process.env.FRAMEWORK === 'solid' ? (touch as unknown as TFunc)() : touch) {\n setHover(false)\n }\n }, hoverStayTime)\n }\n onTouchEnd && onTouchEnd(e)\n }\n\n useEffect(() => {\n setCls(classNames(\n '',\n {\n [`${hoverClass}`]: process.env.FRAMEWORK === 'solid' ? (hover as unknown as TFunc)() : hover\n },\n className\n ))\n }, [hover, className])\n\n return (\n <div\n ref={forwardedRef}\n className={process.env.FRAMEWORK === 'solid' ? (cls as unknown as TFunc)() : cls as string}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n onTouchMove={_onTouchMove}\n {...other}\n >\n {other.children}\n </div>\n )\n}\n\n\nexport default createForwardRefComponent(View)\n"],"names":["View","_a","className","hoverClass","forwardedRef","onTouchStart","onTouchEnd","onTouchMove","hoverStartTime","hoverStayTime","other","__rest","timeoutEvent","startTime","hover","setHover","useState","touch","setTouch","cls","setCls","classNames","process","_onTouchStart","e","setTimeout","onLongPress","Date","getTime","_onTouchMove","clearTimeout","_onTouchEnd","spanTime","useEffect","_jsx","ref","children","createForwardRefComponent"],"mappings":";;;;;;AAmBA,SAASA,IAAIA,CAAEC,EAUN,EAAA;MAVM;MACbC,SAAS;MACTC,UAAU;MACVC,YAAY;MACZC,YAAY;MACZC,UAAU;MACVC,WAAW;AACXC,MAAAA,cAAc,GAAG,EAAE;AACnBC,MAAAA,aAAa,GAAG,GAAA;UAET;IADJC,KAAK,GATKC,MAAA,CAAAV,EAAA,EAAA,CAAA,WAAA,EAAA,YAAA,EAAA,cAAA,EAAA,cAAA,EAAA,YAAA,EAAA,aAAA,EAAA,gBAAA,EAAA,eAAA,CAUd,CADS,CAAA;AAER,EAAA,IAAIW,YAA2C,CAAA;EAC/C,IAAIC,SAAS,GAAG,CAAC,CAAA;EACjB,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAU,KAAK,CAAC,CAAA;EAClD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGF,QAAQ,CAAU,KAAK,CAAC,CAAA;EAElD,MAAM,CAACG,GAAG,EAAEC,MAAM,CAAC,GAAGJ,QAAQ,CAASK,UAAU,CAC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,IAAIH,OAAqB,KAAK,OAAO,GAAIL,KAA0B,EAAE,GAAGA,KAAK,EAAE;UAC7EF,QAAQ,CAAC,KAAK,CAAC,CAAA;AACjB,SAAA;OACD,EAAEN,aAAa,CAAC,CAAA;AACnB,KAAA;AACAH,IAAAA,UAAU,IAAIA,UAAU,CAACkB,CAAC,CAAC,CAAA;GAC5B,CAAA;AAEDS,EAAAA,SAAS,CAAC,MAAK;AACbb,IAAAA,MAAM,CAACC,UAAU,CACf,EAAE,EACF;AACE,MAAA,CAAC,CAAGlB,EAAAA,UAAU,CAAE,CAAA,GAAGmB,OAAqB,KAAK,OAAO,GAAIR,KAA0B,EAAE,GAAGA,KAAAA;KACxF,EACDZ,SAAS,CACV,CAAC,CAAA;AACJ,GAAC,EAAE,CAACY,KAAK,EAAEZ,SAAS,CAAC,CAAC,CAAA;AAEtB,EAAA,oBACEgC,GAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,GAAG,EAAE/B,YAAa;AAClBF,IAAAA,SAAS,EAAEoB,OAAqB,KAAK,OAAO,GAAIH,GAAwB,EAAE,GAAGA,GAAc;AAC3Fd,IAAAA,YAAY,EAAEkB,aAAc;AAC5BjB,IAAAA,UAAU,EAAEyB,WAAY;AACxBxB,IAAAA,WAAW,EAAEsB,YAAa;AAAA,IAAA,GACtBnB,KAAK;IAAA0B,QAAA,EAER1B,KAAK,CAAC0B,QAAAA;AAAQ,GACZ,CAAC,CAAA;AAEV,CAAA;AAGA,YAAeC,yBAAyB,CAACrC,IAAI,CAAC;;;;"}
|
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[loading]>.weui-loading{animation:weuiLoading 1s steps(12) infinite;background:transparent url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cpath fill='none' d='M0 0h100v100H0z'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E9E9E9' rx='5' ry='5' transform='translate(0 -30)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23989697' rx='5' ry='5' transform='rotate(30 105.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%239B999A' rx='5' ry='5' transform='rotate(60 75.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23A3A1A2' rx='5' ry='5' transform='rotate(90 65 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23ABA9AA' rx='5' ry='5' transform='rotate(120 58.66 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23B2B2B2' rx='5' ry='5' transform='rotate(150 54.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23BAB8B9' rx='5' ry='5' transform='rotate(180 50 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23C2C0C1' rx='5' ry='5' transform='rotate(-150 45.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23CBCBCB' rx='5' ry='5' transform='rotate(-120 41.34 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23D2D2D2' rx='5' ry='5' transform='rotate(-90 35 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23DADADA' rx='5' ry='5' transform='rotate(-60 24.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E2E2E2' rx='5' ry='5' transform='rotate(-30 -5.98 65)'/%3E%3C/svg%3E") no-repeat;background-size:100%;display:inline-block;height:20px;vertical-align:middle;width:20px}.taro-button-core[loading]>.weui-loading.weui-btn_primary,.taro-button-core[loading]>.weui-loading.weui-btn_warn{color:hsla(0,0%,100%,.6)}.taro-button-core[loading]>.weui-loading.weui-btn_primary{background-color:#179b16}.taro-button-core[loading]>.weui-loading.weui-btn_warn{background-color:#ce3c39}.taro-button-core{-webkit-tap-highlight-color:rgba(0,0,0,0);appearance:none;background-color:#f8f8f8;border-radius:5px;border-width:0;box-sizing:border-box;color:#000;display:block;font-size:18px;line-height:2.55555556;margin-left:auto;margin-right:auto;outline:0;overflow:hidden;padding-left:14px;padding-right:14px;position:relative;text-align:center;text-decoration:none;width:100%}.taro-button-core:focus{outline:0}.taro-button-core:not([disabled]):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core:after{border:1px solid rgba(0,0,0,.2);border-radius:10px;box-sizing:border-box;content:" ";height:200%;left:0;position:absolute;top:0;transform:scale(.5);transform-origin:0 0;width:200%}.taro-button-core+.taro-button-core{margin-top:15px}.taro-button-core[type=default]{background-color:#f8f8f8;color:#000}.taro-button-core[type=default]:not([disabled]):visited{color:#000}.taro-button-core[type=default]:not([disabled]):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core[size=mini]{display:inline-block;font-size:13px;line-height:2.3;padding:0 1.32em;width:auto}.taro-button-core[plain],.taro-button-core[plain][type=default],.taro-button-core[plain][type=primary]{background-color:transparent;border-width:1px}.taro-button-core[disabled]{color:hsla(0,0%,100%,.6)}.taro-button-core[disabled][type=default]{background-color:#f7f7f7;color:rgba(0,0,0,.3)}.taro-button-core[disabled][type=primary]{background-color:#9ed99d}.taro-button-core[disabled][type=warn]{background-color:#ec8b89}.taro-button-core[loading] .weui-loading{margin:-.2em .34em 0 0}.taro-button-core[loading][type=primary],.taro-button-core[loading][type=warn]{color:hsla(0,0%,100%,.6)}.taro-button-core[loading][type=primary]{background-color:#179b16}.taro-button-core[loading][type=warn]{background-color:#ce3c39}.taro-button-core[plain][type=primary]{border:1px solid #1aad19;color:#1aad19}.taro-button-core[plain][type=primary]:not([disabled]):active{background-color:transparent;border-color:rgba(26,173,25,.6);color:rgba(26,173,25,.6)}.taro-button-core[plain][type=primary]:after{border-width:0}.taro-button-core[plain][type=warn]{border:1px solid #e64340;color:#e64340}.taro-button-core[plain][type=warn]:not([disabled]):active{background-color:transparent;border-color:rgba(230,67,64,.6);color:rgba(230,67,64,.6)}.taro-button-core[plain][type=warn]:after{border-width:0}.taro-button-core[plain],.taro-button-core[plain][type=default]{border:1px solid #353535;color:#353535}.taro-button-core[plain]:not([disabled]):active,.taro-button-core[plain][type=default]:not([disabled]):active{background-color:transparent;border-color:rgba(53,53,53,.6);color:rgba(53,53,53,.6)}.taro-button-core[plain]:after,.taro-button-core[plain][type=default]:after{border-width:0}.taro-button-core[type=primary]{background-color:#1aad19;color:#fff}.taro-button-core[type=primary]:not([disabled]):visited{color:#fff}.taro-button-core[type=primary]:not([disabled]):active{background-color:#179b16;color:hsla(0,0%,100%,.6)}.taro-button-core[type=warn]{background-color:#e64340;color:#fff}.taro-button-core[type=warn]:not([disabled]):visited{color:#fff}.taro-button-core[type=warn]:not([disabled]):active{background-color:#ce3c39;color:hsla(0,0%,100%,.6)}.taro-button-core[plain][disabled],.taro-button-core[plain][disabled][type=primary]{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{height:100%}.taro-img__mode-aspectfit,.taro-img__mode-scaletofill{height:100%;object-fit:contain;width:100%}.taro-img__mode-aspectfill{height:100%;object-fit:cover;width:100%}.taro-img__mode-top,.taro-img__mode-widthfix{width:100%}.taro-img__mode-bottom{bottom:0;position:absolute;width:100%}.taro-img__mode-left{height:100%}.taro-img__mode-right{height:100%}.taro-img__mode-right,.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
|
|
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[loading]>.weui-loading{animation:weuiLoading 1s steps(12) infinite;background:transparent url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cpath fill='none' d='M0 0h100v100H0z'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E9E9E9' rx='5' ry='5' transform='translate(0 -30)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23989697' rx='5' ry='5' transform='rotate(30 105.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%239B999A' rx='5' ry='5' transform='rotate(60 75.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23A3A1A2' rx='5' ry='5' transform='rotate(90 65 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23ABA9AA' rx='5' ry='5' transform='rotate(120 58.66 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23B2B2B2' rx='5' ry='5' transform='rotate(150 54.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23BAB8B9' rx='5' ry='5' transform='rotate(180 50 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23C2C0C1' rx='5' ry='5' transform='rotate(-150 45.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23CBCBCB' rx='5' ry='5' transform='rotate(-120 41.34 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23D2D2D2' rx='5' ry='5' transform='rotate(-90 35 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23DADADA' rx='5' ry='5' transform='rotate(-60 24.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E2E2E2' rx='5' ry='5' transform='rotate(-30 -5.98 65)'/%3E%3C/svg%3E") no-repeat;background-size:100%;display:inline-block;height:20px;vertical-align:middle;width:20px}.taro-button-core[loading]>.weui-loading.weui-btn_primary,.taro-button-core[loading]>.weui-loading.weui-btn_warn{color:hsla(0,0%,100%,.6)}.taro-button-core[loading]>.weui-loading.weui-btn_primary{background-color:#179b16}.taro-button-core[loading]>.weui-loading.weui-btn_warn{background-color:#ce3c39}.taro-button-core{-webkit-tap-highlight-color:rgba(0,0,0,0);appearance:none;background-color:#f8f8f8;border-radius:5px;border-width:0;box-sizing:border-box;color:#000;display:block;font-size:18px;line-height:2.55555556;margin-left:auto;margin-right:auto;outline:0;overflow:hidden;padding-left:14px;padding-right:14px;position:relative;text-align:center;text-decoration:none;width:100%}.taro-button-core:focus{outline:0}.taro-button-core:not([disabled]):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core:after{border:1px solid rgba(0,0,0,.2);border-radius:10px;box-sizing:border-box;content:" ";height:200%;left:0;position:absolute;top:0;transform:scale(.5);transform-origin:0 0;width:200%}.taro-button-core+.taro-button-core{margin-top:15px}.taro-button-core[type=default]{background-color:#f8f8f8;color:#000}.taro-button-core[type=default]:not([disabled]):visited{color:#000}.taro-button-core[type=default]:not([disabled]):active{background-color:#dedede;color:rgba(0,0,0,.6)}.taro-button-core[size=mini]{display:inline-block;font-size:13px;line-height:2.3;padding:0 1.32em;width:auto}.taro-button-core[plain],.taro-button-core[plain][type=default],.taro-button-core[plain][type=primary]{background-color:transparent;border-width:1px}.taro-button-core[disabled]{color:hsla(0,0%,100%,.6)}.taro-button-core[disabled][type=default]{background-color:#f7f7f7;color:rgba(0,0,0,.3)}.taro-button-core[disabled][type=primary]{background-color:#9ed99d}.taro-button-core[disabled][type=warn]{background-color:#ec8b89}.taro-button-core[loading] .weui-loading{margin:-.2em .34em 0 0}.taro-button-core[loading][type=primary],.taro-button-core[loading][type=warn]{color:hsla(0,0%,100%,.6)}.taro-button-core[loading][type=primary]{background-color:#179b16}.taro-button-core[loading][type=warn]{background-color:#ce3c39}.taro-button-core[plain][type=primary]{border:1px solid #1aad19;color:#1aad19}.taro-button-core[plain][type=primary]:not([disabled]):active{background-color:transparent;border-color:rgba(26,173,25,.6);color:rgba(26,173,25,.6)}.taro-button-core[plain][type=primary]:after{border-width:0}.taro-button-core[plain][type=warn]{border:1px solid #e64340;color:#e64340}.taro-button-core[plain][type=warn]:not([disabled]):active{background-color:transparent;border-color:rgba(230,67,64,.6);color:rgba(230,67,64,.6)}.taro-button-core[plain][type=warn]:after{border-width:0}.taro-button-core[plain],.taro-button-core[plain][type=default]{border:1px solid #353535;color:#353535}.taro-button-core[plain]:not([disabled]):active,.taro-button-core[plain][type=default]:not([disabled]):active{background-color:transparent;border-color:rgba(53,53,53,.6);color:rgba(53,53,53,.6)}.taro-button-core[plain]:after,.taro-button-core[plain][type=default]:after{border-width:0}.taro-button-core[type=primary]{background-color:#1aad19;color:#fff}.taro-button-core[type=primary]:not([disabled]):visited{color:#fff}.taro-button-core[type=primary]:not([disabled]):active{background-color:#179b16;color:hsla(0,0%,100%,.6)}.taro-button-core[type=warn]{background-color:#e64340;color:#fff}.taro-button-core[type=warn]:not([disabled]):visited{color:#fff}.taro-button-core[type=warn]:not([disabled]):active{background-color:#ce3c39;color:hsla(0,0%,100%,.6)}.taro-button-core[plain][disabled],.taro-button-core[plain][disabled][type=primary]{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{height:100%}.taro-img__mode-aspectfit,.taro-img__mode-scaletofill{height:100%;object-fit:contain;width:100%}.taro-img__mode-aspectfill{height:100%;object-fit:cover;width:100%}.taro-img__mode-top,.taro-img__mode-widthfix{width:100%}.taro-img__mode-bottom{bottom:0;position:absolute;width:100%}.taro-img__mode-left{height:100%}.taro-img__mode-right{height:100%}.taro-img__mode-right,.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}.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::-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%}.swiper-pagination{font-size:0}.swiper-pagination-bullet{opacity:1}.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,9 +1,9 @@
|
|
|
1
|
-
import { template, spread, mergeProps, insert } from 'solid-js/web';
|
|
1
|
+
import { template, use, spread, mergeProps, insert } from 'solid-js/web';
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import './style/index.scss.js';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import { omit } from '../../utils/index.js';
|
|
6
|
-
import { useRef, useState, useEffect } from '../../utils/hooks.js';
|
|
5
|
+
import { omit, createForwardRefComponent } from '../../utils/index.js';
|
|
6
|
+
import { useRef, useState, useEffect } from '../../utils/hooks.solid.js';
|
|
7
7
|
|
|
8
8
|
var _tmpl$ = /*#__PURE__*/template(`<button>`),
|
|
9
9
|
_tmpl$2 = /*#__PURE__*/template(`<i class=weui-loading>`);
|
|
@@ -51,6 +51,7 @@ function Button(props) {
|
|
|
51
51
|
props.onTouchEnd && props.onTouchEnd(e);
|
|
52
52
|
};
|
|
53
53
|
const {
|
|
54
|
+
forwardedRef,
|
|
54
55
|
plain = false,
|
|
55
56
|
children,
|
|
56
57
|
disabled = false,
|
|
@@ -61,13 +62,14 @@ function Button(props) {
|
|
|
61
62
|
loading = false,
|
|
62
63
|
type
|
|
63
64
|
} = props,
|
|
64
|
-
restProps = __rest(props, ["plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type"]);
|
|
65
|
+
restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type"]);
|
|
65
66
|
const cls = classNames(className, 'taro-button-core', {
|
|
66
67
|
[`${hoverClass}`]: state.hover && !disabled
|
|
67
68
|
});
|
|
68
69
|
return (() => {
|
|
69
70
|
var _el$ = _tmpl$();
|
|
70
|
-
|
|
71
|
+
use(forwardedRef, _el$);
|
|
72
|
+
spread(_el$, mergeProps(() => omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef']), {
|
|
71
73
|
"type": type,
|
|
72
74
|
"className": cls,
|
|
73
75
|
"style": style,
|
|
@@ -87,6 +89,7 @@ function Button(props) {
|
|
|
87
89
|
return _el$;
|
|
88
90
|
})();
|
|
89
91
|
}
|
|
92
|
+
var index = createForwardRefComponent(Button);
|
|
90
93
|
|
|
91
|
-
export {
|
|
94
|
+
export { index as default };
|
|
92
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/button/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { omit } from '../../utils'\nimport { useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n size?: string\n plain?: boolean\n hoverClass?: string\n hoverStartTime?: number\n hoverStayTime?: number\n disabled?: boolean\n loading?: boolean\n type?: string\n className?: string\n}\n\ninterface IState {\n hover:boolean\n touch: boolean\n}\n\nfunction Button (props: IProps) {\n const startTimer = useRef<ReturnType<typeof setTimeout>>()\n const endTimer = useRef<ReturnType<typeof setTimeout>>()\n const [state, setState] = useState<IState>({\n hover: false,\n touch: false\n })\n\n useEffect(() => {\n return () => {\n startTimer.current && clearTimeout(startTimer.current)\n endTimer.current && clearTimeout(endTimer.current)\n }\n }, [])\n\n const _onTouchStart = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: true\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n startTimer.current = setTimeout(() => {\n if ((state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: true\n }))\n }\n }, props.hoverStartTime || 20)\n }\n props.onTouchStart && props.onTouchStart(e)\n }\n\n const _onTouchEnd = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: false\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n endTimer.current = setTimeout(() => {\n if (!(state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: false\n }))\n }\n }, props.hoverStayTime || 70)\n }\n props.onTouchEnd && props.onTouchEnd(e)\n }\n\n const { plain = false, children, disabled = false, className, style, onClick, hoverClass = 'button-hover', loading = false, type, ...restProps } = props\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled\n }\n )\n\n return (\n <button\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading'])}\n type={type}\n className={cls}\n style={style}\n onClick={onClick}\n disabled={disabled}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n loading={loading.toString()}\n plain={plain.toString()}\n >\n {!!loading && <i className='weui-loading' />}\n {children}\n </button>\n )\n}\n\nexport default Button\n"],"names":["Button","props","startTimer","useRef","endTimer","state","setState","useState","hover","touch","useEffect","current","clearTimeout","_onTouchStart","e","Object","assign","hoverClass","disabled","setTimeout","hoverStartTime","onTouchStart","_onTouchEnd","hoverStayTime","onTouchEnd","plain","children","className","style","onClick","loading","type","restProps","__rest","cls","classNames","_el$","_tmpl$","_$spread","_$mergeProps","omit","toString","_$insert","_tmpl$2"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/button/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent, omit } from '../../utils'\nimport { useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n size?: string\n plain?: boolean\n hoverClass?: string\n hoverStartTime?: number\n hoverStayTime?: number\n disabled?: boolean\n loading?: boolean\n type?: string\n className?: string\n forwardedRef?: React.MutableRefObject<HTMLButtonElement>\n}\n\ninterface IState {\n hover:boolean\n touch: boolean\n}\n\nfunction Button (props: IProps) {\n const startTimer = useRef<ReturnType<typeof setTimeout>>()\n const endTimer = useRef<ReturnType<typeof setTimeout>>()\n const [state, setState] = useState<IState>({\n hover: false,\n touch: false\n })\n\n useEffect(() => {\n return () => {\n startTimer.current && clearTimeout(startTimer.current)\n endTimer.current && clearTimeout(endTimer.current)\n }\n }, [])\n\n const _onTouchStart = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: true\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n startTimer.current = setTimeout(() => {\n if ((state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: true\n }))\n }\n }, props.hoverStartTime || 20)\n }\n props.onTouchStart && props.onTouchStart(e)\n }\n\n const _onTouchEnd = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: false\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n endTimer.current = setTimeout(() => {\n if (!(state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: false\n }))\n }\n }, props.hoverStayTime || 70)\n }\n props.onTouchEnd && props.onTouchEnd(e)\n }\n\n const { forwardedRef, plain = false, children, disabled = false, className, style, onClick, hoverClass = 'button-hover', loading = false, type, ...restProps } = props\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled\n }\n )\n\n return (\n <button\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef'])}\n type={type}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={onClick}\n disabled={disabled}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n loading={loading.toString()}\n plain={plain.toString()}\n >\n {!!loading && <i className='weui-loading' />}\n {children}\n </button>\n )\n}\n\nexport default createForwardRefComponent(Button)\n"],"names":["Button","props","startTimer","useRef","endTimer","state","setState","useState","hover","touch","useEffect","current","clearTimeout","_onTouchStart","e","Object","assign","hoverClass","disabled","setTimeout","hoverStartTime","onTouchStart","_onTouchEnd","hoverStayTime","onTouchEnd","forwardedRef","plain","children","className","style","onClick","loading","type","restProps","__rest","cls","classNames","_el$","_tmpl$","_$use","_$spread","_$mergeProps","omit","toString","_$insert","_tmpl$2","createForwardRefComponent"],"mappings":";;;;;;;;;AA2BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC,CAAA;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC,CAAA;AACxD,EAAA,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAS;AACzCC,IAAAA,KAAK,EAAE,KAAK;AACZC,IAAAA,KAAK,EAAE,KAAA;AACR,GAAA,CAAC,CAAA;AAEFC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAO,MAAK;MACVR,UAAU,CAACS,OAAO,IAAIC,YAAY,CAACV,UAAU,CAACS,OAAO,CAAC,CAAA;MACtDP,QAAQ,CAACO,OAAO,IAAIC,YAAY,CAACR,QAAQ,CAACO,OAAO,CAAC,CAAA;KACnD,CAAA;GACF,EAAE,EAAE,CAAC,CAAA;EAEN,MAAME,aAAa,GAAIC,CAAsC,IAAI;AAC/DR,IAAAA,QAAQ,CAAEQ,CAAC,IAAKC,MAAA,CAAAC,MAAA,CAAAD,MAAA,CAAAC,MAAA,CAAA,EAA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G;AAAA,MAAA,OAAA,EACPN,KAAK;AAAA,MAAA,SAAA,EACHC,OAAO;AAAA,MAAA,UAAA,EACNZ,QAAQ;AAAA,MAAA,cAAA,EACJL,aAAa;AAAA,MAAA,YAAA,EACfS,WAAW;AAAA,MAAA,IACvBS,OAAOA,GAAA;AAAA,QAAA,OAAEA,OAAO,CAACY,QAAQ,EAAE,CAAA;AAAA,OAAA;AAAA,MAAA,IAC3BjB,KAAKA,GAAA;AAAA,QAAA,OAAEA,KAAK,CAACiB,QAAQ,EAAE,CAAA;AAAA,OAAA;AAAA,KAAA,CAAA,EAAA,KAAA,EAAA,IAAA,CAAA,CAAA;IAAAC,MAAA,CAAAP,IAAA,EAEtB,CAAC,CAACN,OAAO,IAAAc,OAAA,EAAkC,EAAA,IAAA,CAAA,CAAA;IAAAD,MAAA,CAAAP,IAAA,EAC3CV,QAAQ,EAAA,IAAA,CAAA,CAAA;AAAA,IAAA,OAAAU,IAAA,CAAA;AAAA,GAAA,GAAA,CAAA;AAGf,CAAA;AAEA,YAAeS,yBAAyB,CAAC9C,MAAM,CAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { template, spread, mergeProps } from 'solid-js/web';
|
|
1
|
+
import { template, use, spread, mergeProps } from 'solid-js/web';
|
|
2
2
|
import './style/index.scss.js';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { omit } from '../../utils/index.js';
|
|
4
|
+
import { omit, createForwardRefComponent } from '../../utils/index.js';
|
|
5
5
|
|
|
6
6
|
var _tmpl$ = /*#__PURE__*/template(`<i>`);
|
|
7
7
|
const Icon = props => {
|
|
@@ -9,7 +9,8 @@ const Icon = props => {
|
|
|
9
9
|
type,
|
|
10
10
|
className = '',
|
|
11
11
|
size = '23',
|
|
12
|
-
color
|
|
12
|
+
color,
|
|
13
|
+
forwardedRef
|
|
13
14
|
} = props;
|
|
14
15
|
if (type) type = type.replace(/_/g, '-');
|
|
15
16
|
const cls = classNames({
|
|
@@ -22,7 +23,9 @@ const Icon = props => {
|
|
|
22
23
|
return (// eslint-disable-next-line react/react-in-jsx-scope
|
|
23
24
|
(() => {
|
|
24
25
|
var _el$ = _tmpl$();
|
|
25
|
-
|
|
26
|
+
var _ref$ = forwardedRef;
|
|
27
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : forwardedRef = _el$;
|
|
28
|
+
spread(_el$, mergeProps(() => omit(props, ['type', 'className', 'forwardedRef']), {
|
|
26
29
|
"className": cls,
|
|
27
30
|
"style": style
|
|
28
31
|
}), false, false);
|
|
@@ -30,6 +33,7 @@ const Icon = props => {
|
|
|
30
33
|
})()
|
|
31
34
|
);
|
|
32
35
|
};
|
|
36
|
+
var index = createForwardRefComponent(Icon);
|
|
33
37
|
|
|
34
|
-
export {
|
|
38
|
+
export { index as default };
|
|
35
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/icon/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { omit } from '../../utils'\n\ninterface IProps {\n type: string\n color: string\n size?: number | string\n className?: string\n}\n\nconst Icon = (props: IProps) => {\n let { type, className = '', size = '23', color } = props\n if (type) type = type.replace(/_/g, '-')\n const cls = classNames(\n {\n [`weui-icon-${type}`]: true\n },\n className\n )\n const style = { 'font-size': size + 'px', color: color }\n\n return (\n // eslint-disable-next-line react/react-in-jsx-scope\n <i {...omit(props, ['type', 'className'])} className={cls} style={style} />\n )\n}\nexport default Icon\n"],"names":["Icon","props","type","className","size","color","replace","cls","classNames","style","_el$","_tmpl$","_$spread","_$mergeProps","omit"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/icon/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent, omit } from '../../utils'\n\ninterface IProps {\n type: string\n color: string\n size?: number | string\n className?: string\n forwardedRef?: React.MutableRefObject<HTMLLIElement>\n}\n\nconst Icon = (props: IProps) => {\n let { type, className = '', size = '23', color, forwardedRef } = props\n if (type) type = type.replace(/_/g, '-')\n const cls = classNames(\n {\n [`weui-icon-${type}`]: true\n },\n className\n )\n const style = { 'font-size': size + 'px', color: color }\n\n return (\n // eslint-disable-next-line react/react-in-jsx-scope\n <i ref={forwardedRef} {...omit(props, ['type', 'className', 'forwardedRef'])} className={cls} style={style} />\n )\n}\nexport default createForwardRefComponent(Icon)\n"],"names":["Icon","props","type","className","size","color","forwardedRef","replace","cls","classNames","style","_el$","_tmpl$","_ref$","_$use","_$spread","_$mergeProps","omit","createForwardRefComponent"],"mappings":";;;;;;AAcA,MAAMA,IAAI,GAAIC,KAAa,IAAI;EAC7B,IAAI;IAAEC,IAAI;AAAEC,IAAAA,SAAS,GAAG,EAAE;AAAEC,IAAAA,IAAI,GAAG,IAAI;IAAEC,KAAK;AAAEC,IAAAA,YAAAA;AAAc,GAAA,GAAGL,KAAK,CAAA;EACtE,IAAIC,IAAI,EAAEA,IAAI,GAAGA,IAAI,CAACK,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;EACxC,MAAMC,GAAG,GAAGC,UAAU,CACpB;IACE,CAAC,CAAA,UAAA,EAAaP,IAAI,CAAA,CAAE,GAAG,IAAA;GACxB,EACDC,SAAS,CACV,CAAA;AACD,EAAA,MAAMO,KAAK,GAAG;IAAE,WAAW,EAAEN,IAAI,GAAG,IAAI;AAAEC,IAAAA,KAAK,EAAEA,KAAAA;GAAO,CAAA;EAExD;AACE,IAAA,CAAA,MAAA;MAAA,IAAAM,IAAA,GAAAC,MAAA,EAAA,CAAA;MAAA,IAAAC,KAAA,GACQP,YAAY,CAAA;MAAA,OAAAO,KAAA,KAAAC,UAAAA,GAAAA,GAAA,CAAAD,KAAA,EAAAF,IAAA,CAAA,GAAZL,YAAY,GAAAK,IAAA,CAAA;AAAAI,MAAAA,MAAA,CAAAJ,IAAA,EAAAK,UAAA,CAAA,MAAMC,IAAI,CAAChB,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,EAAA;AAAA,QAAA,WAAA,EAAaO,GAAG;QAAA,OAASE,EAAAA,KAAAA;AAAK,OAAA,CAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AAAA,MAAA,OAAAC,IAAA,CAAA;AAAA,KAAA,GAAA;AAAA,IAAA;AAE9G,CAAC,CAAA;AACD,YAAeO,yBAAyB,CAAClB,IAAI,CAAC;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { template, spread, insert, addEventListener,
|
|
1
|
+
import { template, use, spread, insert, addEventListener, setAttribute, effect, style } from 'solid-js/web';
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import './style/index.css.js';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import {
|
|
5
|
+
import { createForwardRefComponent } from '../../utils/index.js';
|
|
6
|
+
import { useRef, useState, useCallback, useEffect } from '../../utils/hooks.solid.js';
|
|
6
7
|
|
|
7
8
|
var _tmpl$ = /*#__PURE__*/template(`<div>`),
|
|
8
9
|
_tmpl$2 = /*#__PURE__*/template(`<img>`);
|
|
@@ -17,9 +18,10 @@ function Image(props) {
|
|
|
17
18
|
mode,
|
|
18
19
|
onError,
|
|
19
20
|
lazyLoad,
|
|
20
|
-
imgProps
|
|
21
|
+
imgProps,
|
|
22
|
+
forwardedRef
|
|
21
23
|
} = props,
|
|
22
|
-
reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps"]);
|
|
24
|
+
reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"]);
|
|
23
25
|
const cls = classNames('taro-img', {
|
|
24
26
|
'taro-img__widthfix': mode === 'widthFix'
|
|
25
27
|
}, className);
|
|
@@ -60,6 +62,7 @@ function Image(props) {
|
|
|
60
62
|
}, [lazyLoad, src]);
|
|
61
63
|
return (() => {
|
|
62
64
|
var _el$ = _tmpl$();
|
|
65
|
+
use(forwardedRef, _el$);
|
|
63
66
|
_el$.className = cls;
|
|
64
67
|
spread(_el$, reset, false, true);
|
|
65
68
|
insert(_el$, lazyLoad ? (() => {
|
|
@@ -85,6 +88,7 @@ function Image(props) {
|
|
|
85
88
|
return _el$;
|
|
86
89
|
})();
|
|
87
90
|
}
|
|
91
|
+
var index = createForwardRefComponent(Image);
|
|
88
92
|
|
|
89
|
-
export {
|
|
93
|
+
export { index as default };
|
|
90
94
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.css'\n\nimport classNames from 'classnames'\n\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}\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 ...reset\n } = props\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} {...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 Image\n"],"names":["Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","src","mode","onError","lazyLoad","imgProps","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$","_$spread","_$insert","_el$2","_tmpl$2","_$addEventListener","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.css'\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 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,CAAA;AACpD,EAAA,MAAMC,QAAQ,GAAGD,M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