@tarojs/components-react 4.1.8-beta.2 → 4.1.8

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.
@@ -1,5 +1,6 @@
1
1
  import { __rest } from 'tslib';
2
2
  import './style/index.scss.js';
3
+ import { View } from '@tarojs/components';
3
4
  import classNames from 'classnames';
4
5
  import { omit, createForwardRefComponent } from '../../utils/index.js';
5
6
  import { useRef, useState, useEffect, useCallback } from '../../utils/hooks.react.js';
@@ -46,6 +47,12 @@ function Button(props) {
46
47
  }
47
48
  }, props.hoverStayTime || 70);
48
49
  }
50
+ if (!props.disabled && props.formType) {
51
+ const eventName = props.formType === 'submit' ? 'tarobuttonsubmit' : 'tarobuttonreset';
52
+ e.currentTarget.dispatchEvent(new CustomEvent(eventName, {
53
+ bubbles: true
54
+ }));
55
+ }
49
56
  props.onTouchEnd && props.onTouchEnd(e);
50
57
  };
51
58
  const {
@@ -59,12 +66,18 @@ function Button(props) {
59
66
  hoverClass = 'button-hover',
60
67
  loading = false,
61
68
  type = 'default',
62
- size
69
+ size,
70
+ formType
63
71
  } = props,
64
- restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type", "size"]);
72
+ restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type", "size", "formType"]);
65
73
  const handleClick = useCallback(e => {
66
- if (disabled) return; // 如果按钮不可用,直接返回
67
- onClick === null || onClick === void 0 ? void 0 : onClick(e); // 否则执行点击回调
74
+ if (disabled) {
75
+ // 按钮禁用时阻止事件冒泡并不触发点击回调
76
+ e.stopPropagation();
77
+ return;
78
+ }
79
+ // 按钮可用时触发点击回调
80
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
68
81
  }, [disabled, onClick]);
69
82
  const cls = classNames(className, 'taro-button-core', {
70
83
  [`${hoverClass}`]: state.hover && !disabled,
@@ -76,8 +89,8 @@ function Button(props) {
76
89
  'taro-btn-primary': type === 'primary',
77
90
  'taro-btn-warn': type === 'warn'
78
91
  });
79
- return /*#__PURE__*/jsxs("button", {
80
- ...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick']),
92
+ return /*#__PURE__*/jsxs(View, {
93
+ ...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick', 'formType']),
81
94
  type: type,
82
95
  size: size,
83
96
  disabled: disabled,
@@ -87,9 +100,9 @@ function Button(props) {
87
100
  onClick: handleClick,
88
101
  onTouchStart: _onTouchStart,
89
102
  onTouchEnd: _onTouchEnd,
90
- loading: loading.toString(),
91
103
  plain: plain.toString(),
92
- children: [!!loading && /*#__PURE__*/jsx("i", {
104
+ "form-type": formType,
105
+ children: [!!loading && /*#__PURE__*/jsx(View, {
93
106
  className: "weui-loading"
94
107
  }), children]
95
108
  });
@@ -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 { createForwardRefComponent, omit } from '../../utils'\nimport { useCallback, 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 onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\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 = 'default', size, ...restProps } = props\n\n const handleClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) return // 如果按钮不可用,直接返回\n onClick?.(e) // 否则执行点击回调\n },\n [disabled, onClick]\n )\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled,\n 'taro-btn-disabled': disabled,\n 'taro-btn-loading': loading,\n 'taro-btn-plain': plain,\n 'taro-btn-mini': size === 'mini',\n 'taro-btn-default': type === 'default',\n 'taro-btn-primary': type === 'primary',\n 'taro-btn-warn': type === 'warn'\n }\n )\n\n return (\n <button\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick'])}\n type={type}\n size={size}\n disabled={disabled}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={handleClick}\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","size","restProps","__rest","handleClick","useCallback","cls","classNames","_jsxs","omit","ref","toString","_jsx","createForwardRefComponent"],"mappings":";;;;;;;AA4BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC;AACxD,EAAA,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAS;AACzCC,IAAAA,KAAK,EAAE,KAAK;AACZC,IAAAA,KAAK,EAAE;AACR,GAAA,CAAC;AAEFC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAO,MAAK;MACVR,UAAU,CAACS,OAAO,IAAIC,YAAY,CAACV,UAAU,CAACS,OAAO,CAAC;MACtDP,QAAQ,CAACO,OAAO,IAAIC,YAAY,CAACR,QAAQ,CAACO,OAAO,CAAC;KACnD;GACF,EAAE,EAAE,CAAC;EAEN,MAAME,aAAa,GAAIC,CAAsC,IAAI;AAC/DR,IAAAA,QAAQ,CAAEQ,CAAC,IAAKC,MAAA,CAAAC,MAAA,CAAAD,MAAA,CAAAC,MAAA,CAAA,EAAA,EACXF,CAAC,CAAA,EAAA;AACJL,MAAAA,KAAK,EAAE;AAAI,KAAA,CACX,CAAC;AACH,IAAA,IAAIR,KAAK,CAACgB,UAAU,IAAIhB,KAAK,CAACgB,UAAU,KAAK,MAAM,IAAI,CAAChB,KAAK,CAACiB,QAAQ,EAAE;AACtEhB,MAAAA,UAAU,CAACS,OAAO,GAAGQ,UAAU,CAAC,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c,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAC5IF,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,IAAI,EAAEA,IAAK;AACXf,IAAAA,QAAQ,EAAEA,QAAS;AACnBwB,IAAAA,GAAG,EAAEjB,YAAa;AAClBG,IAAAA,SAAS,EAAEU,GAAI;AACfT,IAAAA,KAAK,EAAEA,KAAM;AACbC,IAAAA,OAAO,EAAEM,WAAY;AACrBf,IAAAA,YAAY,EAAER,aAAc;AAC5BW,IAAAA,UAAU,EAAEF,WAAY;AACxBS,IAAAA,OAAO,EAAEA,OAAO,CAACY,QAAQ,EAAG;AAC5BjB,IAAAA,KAAK,EAAEA,KAAK,CAACiB,QAAQ,EAAG;AAAAhB,IAAAA,QAAA,EAEvB,CAAA,CAAC,CAACI,OAAO,iBAAIa,GAAA,CAAA,GAAA,EAAA;AAAGhB,MAAAA,SAAS,EAAC;KAAc,CAAG,EAC3CD,QAAQ;AAAA,GACH,CAAC;AAEb;AAEA,YAAekB,yBAAyB,CAAC7C,MAAM,CAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/button/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, 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 onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\n formType?: 'submit' | 'reset'\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\n if (!props.disabled && props.formType) {\n const eventName = props.formType === 'submit' ? 'tarobuttonsubmit' : 'tarobuttonreset'\n e.currentTarget.dispatchEvent(new CustomEvent(eventName, { bubbles: true }))\n }\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 = 'default', size, formType, ...restProps } = props\n\n const handleClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n // 按钮禁用时阻止事件冒泡并不触发点击回调\n e.stopPropagation()\n return\n }\n // 按钮可用时触发点击回调\n onClick?.(e)\n },\n [disabled, onClick]\n )\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled,\n 'taro-btn-disabled': disabled,\n 'taro-btn-loading': loading,\n 'taro-btn-plain': plain,\n 'taro-btn-mini': size === 'mini',\n 'taro-btn-default': type === 'default',\n 'taro-btn-primary': type === 'primary',\n 'taro-btn-warn': type === 'warn'\n }\n )\n\n return (\n <View\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick', 'formType'])}\n type={type}\n size={size}\n disabled={disabled}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={handleClick}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n plain={plain.toString()}\n form-type={formType as any}\n >\n {!!loading && <View className='weui-loading' />}\n {children}\n </View>\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","formType","eventName","currentTarget","dispatchEvent","CustomEvent","bubbles","onTouchEnd","forwardedRef","plain","children","className","style","onClick","loading","type","size","restProps","__rest","handleClick","useCallback","stopPropagation","cls","classNames","_jsxs","View","omit","ref","toString","_jsx","createForwardRefComponent"],"mappings":";;;;;;;;AA8BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC;AACxD,EAAA,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAS;AACzCC,IAAAA,KAAK,EAAE,KAAK;AACZC,IAAAA,KAAK,EAAE;AACR,GAAA,CAAC;AAEFC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAO,MAAK;MACVR,UAAU,CAACS,OAAO,IAAIC,YAAY,CAACV,UAAU,CAACS,OAAO,CAAC;MACtDP,QAAQ,CAACO,OAAO,IAAIC,YAAY,CAACR,QAAQ,CAACO,OAAO,CAAC;KACnD;GACF,EAAE,EAAE,CAAC;EAEN,MAAME,aAAa,GAAIC,CAAsC,IAAI;AAC/DR,IAAAA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J,IAAI,EAAA;AAACd,MAAAA,SAAS,EAAC;KAAc,CAAG,EAC9CD,QAAQ;AAAA,GACL,CAAC;AAEX;AAEA,YAAeoB,yBAAyB,CAACrD,MAAM,CAAC;;;;"}
@@ -2,41 +2,9 @@ import { __rest } from 'tslib';
2
2
  import './style/index.scss.js';
3
3
  import classNames from 'classnames';
4
4
  import { createForwardRefComponent } from '../../utils/index.js';
5
- import { useRef, useState, useEffect, useCallback } from '../../utils/hooks.react.js';
5
+ import { useRef, useState, useCallback, useEffect } from '../../utils/hooks.react.js';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
- const LEGO_CDN_URL = 'http://ossin.jd.com/swm-plus/h5Tag/tag.js';
9
- // 检查CDN脚本是否已加载
10
- const isLegoScriptLoaded = () => {
11
- return document.querySelector(`script[src="${LEGO_CDN_URL}"]`) !== null;
12
- };
13
- // 插入CDN脚本
14
- const insertLegoScript = () => {
15
- if (isLegoScriptLoaded()) return;
16
- const script = document.createElement('script');
17
- script.type = 'module';
18
- script.src = LEGO_CDN_URL;
19
- document.head.appendChild(script);
20
- };
21
- // 解析lego协议URL
22
- const parseLegoUrl = src => {
23
- if (!src.startsWith('lego://')) return null;
24
- try {
25
- // 移除 'lego://' 前缀
26
- const urlWithoutProtocol = src.substring(7);
27
- // 分割tagId和参数
28
- const [tagId, params] = urlWithoutProtocol.split('?');
29
- // 解析参数
30
- const text = params ? new URLSearchParams(params).get('text') || '' : '';
31
- return {
32
- tagId,
33
- text
34
- };
35
- } catch (error) {
36
- console.warn('Failed to parse lego URL:', src, error);
37
- return null;
38
- }
39
- };
40
8
  function Image(props) {
41
9
  const imgRef = useRef(null);
42
10
  const observer = useRef({});
@@ -49,21 +17,9 @@ function Image(props) {
49
17
  onError,
50
18
  lazyLoad,
51
19
  imgProps,
52
- forwardedRef,
53
- lang
20
+ forwardedRef
54
21
  } = props,
55
- reset = __rest(props
56
- // 检查是否为lego模式
57
- , ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef", "lang"]);
58
- // 检查是否为lego模式
59
- const legoData = parseLegoUrl(src);
60
- const isLegoMode = legoData !== null;
61
- // 如果是lego模式,确保CDN脚本已加载
62
- useEffect(() => {
63
- if (isLegoMode) {
64
- insertLegoScript();
65
- }
66
- }, [isLegoMode]);
22
+ reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"]);
67
23
  const cls = classNames('taro-img', {
68
24
  'taro-img__widthfix': mode === 'widthFix'
69
25
  }, className);
@@ -102,22 +58,6 @@ function Image(props) {
102
58
  (_b = (_a = observer.current) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
103
59
  };
104
60
  }, [lazyLoad, src]);
105
- // 如果是lego模式,渲染canvas-tag
106
- if (isLegoMode && legoData) {
107
- return /*#__PURE__*/jsx("div", {
108
- className: cls,
109
- style: style,
110
- ref: forwardedRef,
111
- ...reset,
112
- children: /*#__PURE__*/jsx("canvas-tag", {
113
- tagId: legoData.tagId,
114
- text: legoData.text,
115
- lang: lang,
116
- ...imgProps
117
- })
118
- });
119
- }
120
- // 普通图片模式
121
61
  return /*#__PURE__*/jsx("div", {
122
62
  className: cls,
123
63
  style: style,
@@ -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 lang?: string\n}\n\n// CDN脚本URL\nconst LEGO_CDN_URL = 'http://ossin.jd.com/swm-plus/h5Tag/tag.js'\n\n// 检查CDN脚本是否已加载\nconst isLegoScriptLoaded = (): boolean => {\n return document.querySelector(`script[src=\"${LEGO_CDN_URL}\"]`) !== null\n}\n\n// 插入CDN脚本\nconst insertLegoScript = (): void => {\n if (isLegoScriptLoaded()) return\n\n const script = document.createElement('script')\n script.type = 'module'\n script.src = LEGO_CDN_URL\n document.head.appendChild(script)\n}\n\n// 解析lego协议URL\nconst parseLegoUrl = (src: string): { tagId: string, text: string } | null => {\n if (!src.startsWith('lego://')) return null\n\n try {\n // 移除 'lego://' 前缀\n const urlWithoutProtocol = src.substring(7)\n\n // 分割tagId和参数\n const [tagId, params] = urlWithoutProtocol.split('?')\n\n // 解析参数\n const text = params ? new URLSearchParams(params).get('text') || '' : ''\n\n return { tagId, text }\n } catch (error) {\n console.warn('Failed to parse lego URL:', src, error)\n return null\n }\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 lang,\n ...reset\n } = props\n\n // 检查是否为lego模式\n const legoData = parseLegoUrl(src)\n const isLegoMode = legoData !== null\n\n // 如果是lego模式,确保CDN脚本已加载\n useEffect(() => {\n if (isLegoMode) {\n insertLegoScript()\n }\n }, [isLegoMode])\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 // 如果是lego模式,渲染canvas-tag\n if (isLegoMode && legoData) {\n return (\n <div className={cls} style={style} ref={forwardedRef} {...reset}>\n <canvas-tag\n tagId={legoData.tagId}\n text={legoData.text}\n lang={lang}\n {...imgProps}\n />\n </div>\n )\n }\n\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":["LEGO_CDN_URL","isLegoScriptLoaded","document","querySelector","insertLegoScript","script","createElement","type","src","head","appendChild","parseLegoUrl","startsWith","urlWithoutProtocol","substring","tagId","params","split","text","URLSearchParams","get","error","console","warn","Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","mode","onError","lazyLoad","imgProps","forwardedRef","lang","reset","__rest","legoData","isLegoMode","useEffect","cls","classNames","imgCls","toLowerCase","replace","imageOnLoad","useCallback","e","onLoad","Object","defineProperty","enumerable","writable","value","width","target","height","current","IntersectionObserver","entries","length","isIntersecting","rootMargin","_b","_a","observe","call","disconnect","_jsx","ref","children","img","createForwardRefComponent"],"mappings":";;;;;;;AAqBA,MAAMA,YAAY,GAAG,2CAA2C;AAEhE;AACA,MAAMC,kBAAkB,GAAGA,MAAc;EACvC,OAAOC,QAAQ,CAACC,aAAa,CAAC,eAAeH,YAAY,CAAA,EAAA,CAAI,CAAC,KAAK,IAAI;AACzE,CAAC;AAED;AACA,MAAMI,gBAAgB,GAAGA,MAAW;EAClC,IAAIH,kB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QAAA,GACPF;OAER;AAAA,KAAK,CAAC;AAEV;AAEA;AACA,EAAA,oBACEoC,GAAA,CAAA,KAAA,EAAA;AAAKzC,IAAAA,SAAS,EAAEa,GAAI;AAACZ,IAAAA,KAAK,EAAEA,KAAM;AAACyC,IAAAA,GAAG,EAAEpC,YAAa;AAAA,IAAA,GAAKE,KAAK;IAAAmC,QAAA,EAC5DvC,QAAQ,gBACPqC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAKjD,MAAM,CAACmC,OAAO,GAAGc,GAAK;AACnC5C,MAAAA,SAAS,EAAEe,MAAO;AAClB,MAAA,UAAA,EAAUtC,GAAI;AACd4C,MAAAA,MAAM,EAAEH,WAAY;AACpBf,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KAAS,CACb,gBAEFoC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAKjD,MAAM,CAACmC,OAAO,GAAGc,GAAK;AACnC5C,MAAAA,SAAS,EAAEe,MAAO;AAClBtC,MAAAA,GAAG,EAAEA,GAAI;AACT4C,MAAAA,MAAM,EAAEH,WAAY;AACpBf,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KACJ;AACH,GACE,CAAC;AAEV;AAEA,YAAewC,yBAAyB,CAACpD,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}\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,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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;;;;"}
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:1px solid rgba(0,0,0,.2);border-radius:10px;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(.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;line-height:2.3;padding:0 1.32em;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 .weui-loading{margin:-.2em .34em 0 0}.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{background-color:rgba(0,0,0,.6);position:absolute;z-index:1001}.taro-picker{background-color:#e5e5e5;bottom:0;font-size:14px;left:0;position:absolute;width:100%;z-index:1002}.taro-picker__hd{align-items:center;background-color:#fff;display:flex;font-size:17px;height:44px;justify-content:space-between;padding:0;position:relative}.taro-picker__hd:after{background-color:#e5e5e5;bottom:0;content:"";height:1px;left:0;position:absolute;transform:scaleY(.5);width:100%}.taro-picker__action{color:#ff0f23;flex:0 0 auto;font-size:14px;height:44px;line-height:44px;padding:0 10px}.taro-picker__action:first-child{color:#888}.taro-picker__title{color:#000;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{background-color:#fff;height:238px;overflow:hidden;width:100%}.taro-picker__bd,.taro-picker__group{box-sizing:border-box;display:flex;flex:1}.taro-picker__group{align-items:center;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{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));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__indicator:after,.taro-picker__indicator:before{background-color:#e5e5e5;content:"";height:1px;left:0;position:absolute;right:0;transform:scaleY(.5)}.taro-picker__indicator:before{top:0}.taro-picker__indicator:after{bottom:0}.taro-picker__content{box-sizing:border-box;height:100%;width:100%}.taro-picker__item{align-items:center;box-sizing:border-box;color:#000;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{color:#ff0f23;font-weight:500}.taro-picker__item--disabled{color:#999}.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;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{background-color:rgba(0,0,0,.6);position:absolute;z-index:1001}.taro-picker{background-color:#e5e5e5;bottom:0;font-size:14px;left:0;position:absolute;width:100%;z-index:1002}.taro-picker__hd{align-items:center;background-color:#fff;display:flex;font-size:17px;height:44px;justify-content:space-between;padding:0;position:relative}.taro-picker__hd:after{background-color:#e5e5e5;bottom:0;content:"";height:1px;left:0;position:absolute;transform:scaleY(.5);width:100%}.taro-picker__action{color:#ff0f23;flex:0 0 auto;font-size:14px;height:44px;line-height:44px;padding:0 10px}.taro-picker__action:first-child{color:#888}.taro-picker__title{color:#000;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{background-color:#fff;height:238px;overflow:hidden;width:100%}.taro-picker__bd,.taro-picker__group{box-sizing:border-box;display:flex;flex:1}.taro-picker__group{align-items:center;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{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));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__indicator:after,.taro-picker__indicator:before{background-color:#e5e5e5;content:"";height:1px;left:0;position:absolute;right:0;transform:scaleY(.5)}.taro-picker__indicator:before{top:0}.taro-picker__indicator:after{bottom:0}.taro-picker__content{box-sizing:border-box;height:100%;width:100%}.taro-picker__item{align-items:center;box-sizing:border-box;color:#000;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{color:#ff0f23;font-weight:500}.taro-picker__item--disabled{color:#999}.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,5 +1,6 @@
1
1
  import { __rest } from 'tslib';
2
2
  import './style/index.scss';
3
+ import { View } from '@tarojs/components';
3
4
  import classNames from 'classnames';
4
5
  import { omit, createForwardRefComponent } from '../../utils/index.js';
5
6
  import { useRef, useState, useEffect, useCallback } from '../../utils/hooks.react.js';
@@ -46,6 +47,12 @@ function Button(props) {
46
47
  }
47
48
  }, props.hoverStayTime || 70);
48
49
  }
50
+ if (!props.disabled && props.formType) {
51
+ const eventName = props.formType === 'submit' ? 'tarobuttonsubmit' : 'tarobuttonreset';
52
+ e.currentTarget.dispatchEvent(new CustomEvent(eventName, {
53
+ bubbles: true
54
+ }));
55
+ }
49
56
  props.onTouchEnd && props.onTouchEnd(e);
50
57
  };
51
58
  const {
@@ -59,12 +66,18 @@ function Button(props) {
59
66
  hoverClass = 'button-hover',
60
67
  loading = false,
61
68
  type = 'default',
62
- size
69
+ size,
70
+ formType
63
71
  } = props,
64
- restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type", "size"]);
72
+ restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type", "size", "formType"]);
65
73
  const handleClick = useCallback(e => {
66
- if (disabled) return; // 如果按钮不可用,直接返回
67
- onClick === null || onClick === void 0 ? void 0 : onClick(e); // 否则执行点击回调
74
+ if (disabled) {
75
+ // 按钮禁用时阻止事件冒泡并不触发点击回调
76
+ e.stopPropagation();
77
+ return;
78
+ }
79
+ // 按钮可用时触发点击回调
80
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
68
81
  }, [disabled, onClick]);
69
82
  const cls = classNames(className, 'taro-button-core', {
70
83
  [`${hoverClass}`]: state.hover && !disabled,
@@ -76,8 +89,8 @@ function Button(props) {
76
89
  'taro-btn-primary': type === 'primary',
77
90
  'taro-btn-warn': type === 'warn'
78
91
  });
79
- return /*#__PURE__*/jsxs("button", {
80
- ...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick']),
92
+ return /*#__PURE__*/jsxs(View, {
93
+ ...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick', 'formType']),
81
94
  type: type,
82
95
  size: size,
83
96
  disabled: disabled,
@@ -87,9 +100,9 @@ function Button(props) {
87
100
  onClick: handleClick,
88
101
  onTouchStart: _onTouchStart,
89
102
  onTouchEnd: _onTouchEnd,
90
- loading: loading.toString(),
91
103
  plain: plain.toString(),
92
- children: [!!loading && /*#__PURE__*/jsx("i", {
104
+ "form-type": formType,
105
+ children: [!!loading && /*#__PURE__*/jsx(View, {
93
106
  className: "weui-loading"
94
107
  }), children]
95
108
  });
@@ -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 { createForwardRefComponent, omit } from '../../utils'\nimport { useCallback, 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 onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\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 = 'default', size, ...restProps } = props\n\n const handleClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) return // 如果按钮不可用,直接返回\n onClick?.(e) // 否则执行点击回调\n },\n [disabled, onClick]\n )\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled,\n 'taro-btn-disabled': disabled,\n 'taro-btn-loading': loading,\n 'taro-btn-plain': plain,\n 'taro-btn-mini': size === 'mini',\n 'taro-btn-default': type === 'default',\n 'taro-btn-primary': type === 'primary',\n 'taro-btn-warn': type === 'warn'\n }\n )\n\n return (\n <button\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick'])}\n type={type}\n size={size}\n disabled={disabled}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={handleClick}\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","size","restProps","__rest","handleClick","useCallback","cls","classNames","_jsxs","omit","ref","toString","_jsx","createForwardRefComponent"],"mappings":";;;;;;;AA4BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC;AACxD,EAAA,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAS;AACzCC,IAAAA,KAAK,EAAE,KAAK;AACZC,IAAAA,KAAK,EAAE;AACR,GAAA,CAAC;AAEFC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAO,MAAK;MACVR,UAAU,CAACS,OAAO,IAAIC,YA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../../../../src/components/button/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, 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 onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\n formType?: 'submit' | 'reset'\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\n if (!props.disabled && props.formType) {\n const eventName = props.formType === 'submit' ? 'tarobuttonsubmit' : 'tarobuttonreset'\n e.currentTarget.dispatchEvent(new CustomEvent(eventName, { bubbles: true }))\n }\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 = 'default', size, formType, ...restProps } = props\n\n const handleClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n // 按钮禁用时阻止事件冒泡并不触发点击回调\n e.stopPropagation()\n return\n }\n // 按钮可用时触发点击回调\n onClick?.(e)\n },\n [disabled, onClick]\n )\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled,\n 'taro-btn-disabled': disabled,\n 'taro-btn-loading': loading,\n 'taro-btn-plain': plain,\n 'taro-btn-mini': size === 'mini',\n 'taro-btn-default': type === 'default',\n 'taro-btn-primary': type === 'primary',\n 'taro-btn-warn': type === 'warn'\n }\n )\n\n return (\n <View\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick', 'formType'])}\n type={type}\n size={size}\n disabled={disabled}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={handleClick}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n plain={plain.toString()}\n form-type={formType as any}\n >\n {!!loading && <View className='weui-loading' />}\n {children}\n </View>\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","formType","eventName","currentTarget","dispatchEvent","CustomEvent","bubbles","onTouchEnd","forwardedRef","plain","children","className","style","onClick","loading","type","size","restProps","__rest","handleClick","useCallback","stopPropagation","cls","classNames","_jsxs","View","omit","ref","toString","_jsx","createForwardRefComponent"],"mappings":";;;;;;;;AA8BA,SAASA,MAAMA,CAAEC,KAAa,EAA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M,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACxJF,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,IAAI,EAAEA,IAAK;AACXrB,IAAAA,QAAQ,EAAEA,QAAS;AACnBgC,IAAAA,GAAG,EAAEnB,YAAa;AAClBG,IAAAA,SAAS,EAAEW,GAAI;AACfV,IAAAA,KAAK,EAAEA,KAAM;AACbC,IAAAA,OAAO,EAAEM,WAAY;AACrBrB,IAAAA,YAAY,EAAER,aAAc;AAC5BiB,IAAAA,UAAU,EAAER,WAAY;AACxBU,IAAAA,KAAK,EAAEA,KAAK,CAACmB,QAAQ,EAAG;AACxB,IAAA,WAAA,EAAW3B,QAAgB;AAAAS,IAAAA,QAAA,GAE1B,CAAC,CAACI,OAAO,iBAAIe,GAAA,CAACJ,IAAI,EAAA;AAACd,MAAAA,SAAS,EAAC;KAAc,CAAG,EAC9CD,QAAQ;AAAA,GACL,CAAC;AAEX;AAEA,YAAeoB,yBAAyB,CAACrD,MAAM,CAAC;;;;"}
@@ -63,52 +63,60 @@ $weuiBtnPlainDefaultActiveColor: rgba(53, 53, 53, .6);
63
63
  $weuiBtnPlainDefaultActiveBorderColor: rgba(53, 53, 53, .6);
64
64
 
65
65
  /* Imported from weui-btn_loading.scss */
66
- @-webkit-keyframes weuiLoading {
67
- 0% {
68
- transform: rotate3d(0, 0, 1, 0deg);
69
- }
70
-
71
- 100% {
72
- transform: rotate3d(0, 0, 1, 360deg);
73
- }
74
- }
75
-
76
- @keyframes weuiLoading {
77
- 0% {
78
- transform: rotate3d(0, 0, 1, 0deg);
79
- }
80
-
81
- 100% {
82
- transform: rotate3d(0, 0, 1, 360deg);
83
- }
84
- }
85
-
86
- .taro-button-core[loading] {
87
- >.weui-loading {
88
- // font-size: 16px;
89
- width: 20px; // 1em;
90
- height: 20px; // 1em;
91
- display: inline-block;
92
- vertical-align: middle;
93
- animation: weuiLoading 1s steps(12, end) infinite;
94
- 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;
95
- background-size: 100%;
96
-
97
- &.weui-btn_primary,
98
- &.weui-btn_warn {
99
- color: $weuiBtnActiveFontColor;
100
- }
101
- &.weui-btn_primary {
102
- // color: var(--weui-WHITE);
103
- background-color: $weuiBtnPrimaryActiveBg;
104
- }
105
-
106
- &.weui-btn_warn {
107
- background-color: $weuiBtnWarnActiveBg;
108
- }
109
- }
110
-
66
+ @-webkit-keyframes weuiLoading {
67
+ 0% {
68
+ transform: rotate3d(0, 0, 1, 0deg);
69
+ }
70
+
71
+ 100% {
72
+ transform: rotate3d(0, 0, 1, 360deg);
73
+ }
74
+ }
75
+
76
+ @keyframes weuiLoading {
77
+ 0% {
78
+ transform: rotate3d(0, 0, 1, 0deg);
79
+ }
80
+
81
+ 100% {
82
+ transform: rotate3d(0, 0, 1, 360deg);
83
+ }
111
84
  }
85
+
86
+ .taro-button-core.taro-btn-loading {
87
+ .weui-loading {
88
+ display: inline-block;
89
+ width: 22px;
90
+ height: 22px;
91
+ animation: weuiLoading 1s steps(12, end) infinite;
92
+ background: transparent url("https://img13.360buyimg.com/imagetools/jfs/t1/353674/27/5761/14397/690ac1cfFf6bf0e2c/77727d0791bacf8e.png") no-repeat;
93
+ background-size: cover;
94
+
95
+ &.weui-btn_primary,
96
+ &.weui-btn_warn {
97
+ color: $weuiBtnActiveFontColor;
98
+ }
99
+ &.weui-btn_primary {
100
+ // color: var(--weui-WHITE);
101
+ background-color: $weuiBtnPrimaryActiveBg;
102
+ }
103
+
104
+ &.weui-btn_warn {
105
+ background-color: $weuiBtnWarnActiveBg;
106
+ }
107
+ }
108
+
109
+ }
110
+
111
+ .taro-button-core.taro-btn-loading.taro-btn-mini {
112
+ .weui-loading {
113
+ display: inline-block;
114
+ width: 16px;
115
+ height: 16px;
116
+ vertical-align: middle;
117
+ }
118
+ }
119
+
112
120
  $weuiBtnHeight: 46px;
113
121
  $weuiBtnFontSize: 18px;
114
122
  $weuiBtnFontColor: #fff;
@@ -119,7 +127,7 @@ $weuiBtnDefaultGap: 15px;
119
127
 
120
128
  // Button Mini
121
129
  $weuiBtnMiniFontSize: 13px;
122
- $weuiBtnMiniHeight: 2.3;
130
+ $weuiBtnMiniHeight: 2;
123
131
 
124
132
  // Button Default
125
133
  $weuiBtnDefaultFontColor: #000;
@@ -158,24 +166,20 @@ $weuiBtnPlainWarnActiveColor: rgba(230 67 64 / 60%);
158
166
  $weuiBtnPlainWarnActiveBorderColor: rgba(230 67 64 / 60%);
159
167
 
160
168
  .taro-button-core {
161
- display: block;
169
+ display: flex;
170
+ align-items: center;
171
+ justify-content: center;
162
172
  overflow: hidden;
163
173
  position: relative;
164
174
  box-sizing: border-box;
165
- margin-left: auto;
166
- margin-right: auto;
167
- padding-left: 14px;
168
- padding-right: 14px;
169
- border-width: 0;
175
+ padding: 0 14px;
170
176
  border: 1px solid rgb(0 0 0 / 20%);
171
177
  border-radius: $weuiBtnBorderRadius * 2;
172
178
  width: 100%;
173
179
  appearance: none;
174
180
  outline: 0;
175
181
  background-color: $weuiBtnDefaultBg;
176
- line-height: 2.55555556;
177
182
  text-decoration: none;
178
- text-align: center;
179
183
  font-size: $weuiBtnFontSize;
180
184
  color: $weuiBtnDefaultFontColor;
181
185
  -webkit-tap-highlight-color: rgb(0 0 0 / 0%);
@@ -209,9 +213,9 @@ $weuiBtnPlainWarnActiveBorderColor: rgba(230 67 64 / 60%);
209
213
 
210
214
  &.taro-btn-mini {
211
215
  display: inline-block;
212
- padding: 0 1.32em;
216
+ padding: 0 26px;
213
217
  width: auto;
214
- line-height: $weuiBtnMiniHeight;
218
+ vertical-align: middle;
215
219
  font-size: $weuiBtnMiniFontSize;
216
220
  }
217
221
 
@@ -241,9 +245,6 @@ $weuiBtnPlainWarnActiveBorderColor: rgba(230 67 64 / 60%);
241
245
  }
242
246
 
243
247
  &.taro-btn-loading {
244
- .weui-loading {
245
- margin: -0.2em 0.34em 0 0;
246
- }
247
248
 
248
249
  &.taro-btn-primary,
249
250
  &.taro-btn-warn {
@@ -350,4 +351,4 @@ $weuiBtnPlainWarnActiveBorderColor: rgba(230 67 64 / 60%);
350
351
  background-color: #f7f7f7;
351
352
  color: rgb(0 0 0 / 30%);
352
353
  }
353
- }
354
+ }
@@ -2,41 +2,9 @@ import { __rest } from 'tslib';
2
2
  import './style/index.scss';
3
3
  import classNames from 'classnames';
4
4
  import { createForwardRefComponent } from '../../utils/index.js';
5
- import { useRef, useState, useEffect, useCallback } from '../../utils/hooks.react.js';
5
+ import { useRef, useState, useCallback, useEffect } from '../../utils/hooks.react.js';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
- const LEGO_CDN_URL = 'http://ossin.jd.com/swm-plus/h5Tag/tag.js';
9
- // 检查CDN脚本是否已加载
10
- const isLegoScriptLoaded = () => {
11
- return document.querySelector(`script[src="${LEGO_CDN_URL}"]`) !== null;
12
- };
13
- // 插入CDN脚本
14
- const insertLegoScript = () => {
15
- if (isLegoScriptLoaded()) return;
16
- const script = document.createElement('script');
17
- script.type = 'module';
18
- script.src = LEGO_CDN_URL;
19
- document.head.appendChild(script);
20
- };
21
- // 解析lego协议URL
22
- const parseLegoUrl = src => {
23
- if (!src.startsWith('lego://')) return null;
24
- try {
25
- // 移除 'lego://' 前缀
26
- const urlWithoutProtocol = src.substring(7);
27
- // 分割tagId和参数
28
- const [tagId, params] = urlWithoutProtocol.split('?');
29
- // 解析参数
30
- const text = params ? new URLSearchParams(params).get('text') || '' : '';
31
- return {
32
- tagId,
33
- text
34
- };
35
- } catch (error) {
36
- console.warn('Failed to parse lego URL:', src, error);
37
- return null;
38
- }
39
- };
40
8
  function Image(props) {
41
9
  const imgRef = useRef(null);
42
10
  const observer = useRef({});
@@ -49,21 +17,9 @@ function Image(props) {
49
17
  onError,
50
18
  lazyLoad,
51
19
  imgProps,
52
- forwardedRef,
53
- lang
20
+ forwardedRef
54
21
  } = props,
55
- reset = __rest(props
56
- // 检查是否为lego模式
57
- , ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef", "lang"]);
58
- // 检查是否为lego模式
59
- const legoData = parseLegoUrl(src);
60
- const isLegoMode = legoData !== null;
61
- // 如果是lego模式,确保CDN脚本已加载
62
- useEffect(() => {
63
- if (isLegoMode) {
64
- insertLegoScript();
65
- }
66
- }, [isLegoMode]);
22
+ reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"]);
67
23
  const cls = classNames('taro-img', {
68
24
  'taro-img__widthfix': mode === 'widthFix'
69
25
  }, className);
@@ -102,22 +58,6 @@ function Image(props) {
102
58
  (_b = (_a = observer.current) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
103
59
  };
104
60
  }, [lazyLoad, src]);
105
- // 如果是lego模式,渲染canvas-tag
106
- if (isLegoMode && legoData) {
107
- return /*#__PURE__*/jsx("div", {
108
- className: cls,
109
- style: style,
110
- ref: forwardedRef,
111
- ...reset,
112
- children: /*#__PURE__*/jsx("canvas-tag", {
113
- tagId: legoData.tagId,
114
- text: legoData.text,
115
- lang: lang,
116
- ...imgProps
117
- })
118
- });
119
- }
120
- // 普通图片模式
121
61
  return /*#__PURE__*/jsx("div", {
122
62
  className: cls,
123
63
  style: style,
@@ -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 lang?: string\n}\n\n// CDN脚本URL\nconst LEGO_CDN_URL = 'http://ossin.jd.com/swm-plus/h5Tag/tag.js'\n\n// 检查CDN脚本是否已加载\nconst isLegoScriptLoaded = (): boolean => {\n return document.querySelector(`script[src=\"${LEGO_CDN_URL}\"]`) !== null\n}\n\n// 插入CDN脚本\nconst insertLegoScript = (): void => {\n if (isLegoScriptLoaded()) return\n\n const script = document.createElement('script')\n script.type = 'module'\n script.src = LEGO_CDN_URL\n document.head.appendChild(script)\n}\n\n// 解析lego协议URL\nconst parseLegoUrl = (src: string): { tagId: string, text: string } | null => {\n if (!src.startsWith('lego://')) return null\n\n try {\n // 移除 'lego://' 前缀\n const urlWithoutProtocol = src.substring(7)\n\n // 分割tagId和参数\n const [tagId, params] = urlWithoutProtocol.split('?')\n\n // 解析参数\n const text = params ? new URLSearchParams(params).get('text') || '' : ''\n\n return { tagId, text }\n } catch (error) {\n console.warn('Failed to parse lego URL:', src, error)\n return null\n }\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 lang,\n ...reset\n } = props\n\n // 检查是否为lego模式\n const legoData = parseLegoUrl(src)\n const isLegoMode = legoData !== null\n\n // 如果是lego模式,确保CDN脚本已加载\n useEffect(() => {\n if (isLegoMode) {\n insertLegoScript()\n }\n }, [isLegoMode])\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 // 如果是lego模式,渲染canvas-tag\n if (isLegoMode && legoData) {\n return (\n <div className={cls} style={style} ref={forwardedRef} {...reset}>\n <canvas-tag\n tagId={legoData.tagId}\n text={legoData.text}\n lang={lang}\n {...imgProps}\n />\n </div>\n )\n }\n\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":["LEGO_CDN_URL","isLegoScriptLoaded","document","querySelector","insertLegoScript","script","createElement","type","src","head","appendChild","parseLegoUrl","startsWith","urlWithoutProtocol","substring","tagId","params","split","text","URLSearchParams","get","error","console","warn","Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","mode","onError","lazyLoad","imgProps","forwardedRef","lang","reset","__rest","legoData","isLegoMode","useEffect","cls","classNames","imgCls","toLowerCase","replace","imageOnLoad","useCallback","e","onLoad","Object","defineProperty","enumerable","writable","value","width","target","height","current","IntersectionObserver","entries","length","isIntersecting","rootMargin","_b","_a","observe","call","disconnect","_jsx","ref","children","img","createForwardRefComponent"],"mappings":";;;;;;;AAqBA,MAAMA,YAAY,GAAG,2CAA2C;AAEhE;AACA,MAAMC,kBAAkB,GAAGA,MAAc;EACvC,OAAOC,QAAQ,CAACC,aAAa,CAAC,eAAeH,YAAY,CAAA,EAAA,CAAI,CAAC,KAAK,IAAI;AACzE,CAAC;AAED;AACA,MAAMI,gBAAgB,GAAGA,MAAW;EAClC,IAAIH,kBAAkB,EAAE,EAAE;AAE1B,EAAA,MAAMI,MAAM,GAAGH,QAAQ,CAACI,aAAa,CAAC,QAAQ,CAAC;EAC/CD,MAAM,CAACE,IAAI,GAAG,QAAQ;EACtBF,MAAM,CAACG,GAAG,GAAGR,YAAY;AACzBE,EAAAA,QAAQ,CAACO,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AA,IAAA,GAAKE,KAAK;IAAAmC,QAAA,EAC5DvC,QAAQ,gBACPqC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAKjD,MAAM,CAACmC,OAAO,GAAGc,GAAK;AACnC5C,MAAAA,SAAS,EAAEe,MAAO;AAClB,MAAA,UAAA,EAAUtC,GAAI;AACd4C,MAAAA,MAAM,EAAEH,WAAY;AACpBf,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KAAS,CACb,gBAEFoC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAKjD,MAAM,CAACmC,OAAO,GAAGc,GAAK;AACnC5C,MAAAA,SAAS,EAAEe,MAAO;AAClBtC,MAAAA,GAAG,EAAEA,GAAI;AACT4C,MAAAA,MAAM,EAAEH,WAAY;AACpBf,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE;KACJ;AACH,GACE,CAAC;AAEV;AAEA,YAAewC,yBAAyB,CAACpD,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}\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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,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,12 +1,11 @@
1
- import { template, use, spread, mergeProps, insert } from 'solid-js/web';
1
+ import { createComponent, mergeProps, memo } from 'solid-js/web';
2
2
  import { __rest } from 'tslib';
3
3
  import './style/index.scss.js';
4
+ import { View } from '@tarojs/components';
4
5
  import classNames from 'classnames';
5
6
  import { omit, createForwardRefComponent } from '../../utils/index.js';
6
7
  import { useRef, useState, useEffect, useCallback } from '../../utils/hooks.solid.js';
7
8
 
8
- var _tmpl$ = /*#__PURE__*/template(`<button>`),
9
- _tmpl$2 = /*#__PURE__*/template(`<i class=weui-loading>`);
10
9
  function Button(props) {
11
10
  const startTimer = useRef();
12
11
  const endTimer = useRef();
@@ -48,6 +47,12 @@ function Button(props) {
48
47
  }
49
48
  }, props.hoverStayTime || 70);
50
49
  }
50
+ if (!props.disabled && props.formType) {
51
+ const eventName = props.formType === 'submit' ? 'tarobuttonsubmit' : 'tarobuttonreset';
52
+ e.currentTarget.dispatchEvent(new CustomEvent(eventName, {
53
+ bubbles: true
54
+ }));
55
+ }
51
56
  props.onTouchEnd && props.onTouchEnd(e);
52
57
  };
53
58
  const {
@@ -61,12 +66,18 @@ function Button(props) {
61
66
  hoverClass = 'button-hover',
62
67
  loading = false,
63
68
  type = 'default',
64
- size
69
+ size,
70
+ formType
65
71
  } = props,
66
- restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type", "size"]);
72
+ restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type", "size", "formType"]);
67
73
  const handleClick = useCallback(e => {
68
- if (disabled) return; // 如果按钮不可用,直接返回
69
- onClick === null || onClick === void 0 ? void 0 : onClick(e); // 否则执行点击回调
74
+ if (disabled) {
75
+ // 按钮禁用时阻止事件冒泡并不触发点击回调
76
+ e.stopPropagation();
77
+ return;
78
+ }
79
+ // 按钮可用时触发点击回调
80
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
70
81
  }, [disabled, onClick]);
71
82
  const cls = classNames(className, 'taro-button-core', {
72
83
  [`${hoverClass}`]: state.hover && !disabled,
@@ -78,29 +89,26 @@ function Button(props) {
78
89
  'taro-btn-primary': type === 'primary',
79
90
  'taro-btn-warn': type === 'warn'
80
91
  });
81
- return (() => {
82
- var _el$ = _tmpl$();
83
- use(forwardedRef, _el$);
84
- spread(_el$, mergeProps(() => omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick']), {
85
- "type": type,
86
- "size": size,
87
- "disabled": disabled,
88
- "className": cls,
89
- "style": style,
90
- "onClick": handleClick,
91
- "onTouchStart": _onTouchStart,
92
- "onTouchEnd": _onTouchEnd,
93
- get loading() {
94
- return loading.toString();
95
- },
96
- get plain() {
97
- return plain.toString();
98
- }
99
- }), false, true);
100
- insert(_el$, !!loading && _tmpl$2(), null);
101
- insert(_el$, children, null);
102
- return _el$;
103
- })();
92
+ return createComponent(View, mergeProps(() => omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick', 'formType']), {
93
+ type: type,
94
+ size: size,
95
+ disabled: disabled,
96
+ ref: forwardedRef,
97
+ className: cls,
98
+ style: style,
99
+ onClick: handleClick,
100
+ onTouchStart: _onTouchStart,
101
+ onTouchEnd: _onTouchEnd,
102
+ get plain() {
103
+ return plain.toString();
104
+ },
105
+ "form-type": formType,
106
+ get children() {
107
+ return [memo(() => !!loading && createComponent(View, {
108
+ className: "weui-loading"
109
+ })), children];
110
+ }
111
+ }));
104
112
  }
105
113
  var index = createForwardRefComponent(Button);
106
114
 
@@ -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 { createForwardRefComponent, omit } from '../../utils'\nimport { useCallback, 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 onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\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 = 'default', size, ...restProps } = props\n\n const handleClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) return // 如果按钮不可用,直接返回\n onClick?.(e) // 否则执行点击回调\n },\n [disabled, onClick]\n )\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled,\n 'taro-btn-disabled': disabled,\n 'taro-btn-loading': loading,\n 'taro-btn-plain': plain,\n 'taro-btn-mini': size === 'mini',\n 'taro-btn-default': type === 'default',\n 'taro-btn-primary': type === 'primary',\n 'taro-btn-warn': type === 'warn'\n }\n )\n\n return (\n <button\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick'])}\n type={type}\n size={size}\n disabled={disabled}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={handleClick}\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","size","restProps","__rest","handleClick","useCallback","cls","classNames","_el$","_tmpl$","_$use","_$spread","_$mergeProps","omit","toString","_$insert","_tmpl$2","createForwardRefComponent"],"mappings":";;;;;;;;;AA4BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC;AACxD,EAAA,MAAM,CA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QAAQ,EAAE;AAAA,OAAA;AAAA,MAAA,IAC3BpB,KAAKA,GAAA;AAAA,QAAA,OAAEA,KAAK,CAACoB,QAAQ,EAAE;AAAA;AAAA,KAAA,CAAA,EAAA,KAAA,EAAA,IAAA,CAAA;IAAAC,MAAA,CAAAP,IAAA,EAEtB,CAAC,CAACT,OAAO,IAAAiB,OAAA,EAAkC,EAAA,IAAA,CAAA;IAAAD,MAAA,CAAAP,IAAA,EAC3Cb,QAAQ,EAAA,IAAA,CAAA;AAAA,IAAA,OAAAa,IAAA;AAAA,GAAA,GAAA;AAGf;AAEA,YAAeS,yBAAyB,CAACjD,MAAM,CAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/button/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, 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 onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\n formType?: 'submit' | 'reset'\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\n if (!props.disabled && props.formType) {\n const eventName = props.formType === 'submit' ? 'tarobuttonsubmit' : 'tarobuttonreset'\n e.currentTarget.dispatchEvent(new CustomEvent(eventName, { bubbles: true }))\n }\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 = 'default', size, formType, ...restProps } = props\n\n const handleClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n // 按钮禁用时阻止事件冒泡并不触发点击回调\n e.stopPropagation()\n return\n }\n // 按钮可用时触发点击回调\n onClick?.(e)\n },\n [disabled, onClick]\n )\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled,\n 'taro-btn-disabled': disabled,\n 'taro-btn-loading': loading,\n 'taro-btn-plain': plain,\n 'taro-btn-mini': size === 'mini',\n 'taro-btn-default': type === 'default',\n 'taro-btn-primary': type === 'primary',\n 'taro-btn-warn': type === 'warn'\n }\n )\n\n return (\n <View\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef', 'size', 'plain', 'disabled', 'onClick', 'formType'])}\n type={type}\n size={size}\n disabled={disabled}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={handleClick}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n plain={plain.toString()}\n form-type={formType as any}\n >\n {!!loading && <View className='weui-loading' />}\n {children}\n </View>\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","formType","eventName","currentTarget","dispatchEvent","CustomEvent","bubbles","onTouchEnd","forwardedRef","plain","children","className","style","onClick","loading","type","size","restProps","__rest","handleClick","useCallback","stopPropagation","cls","classNames","_$createComponent","View","_$mergeProps","omit","ref","toString","_$memo","createForwardRefComponent"],"mappings":";;;;;;;;AA8BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC;AACxD,EAAA,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAS;AACzCC,IAAAA,KAAK,EAAE,KAAK;AACZC,IAAAA,KAAK,EAAE;AACR,GAAA,CAAC;AAEFC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAO,MAAK;MACVR,UAAU,CAACS,OAAO,IAAIC,YAAY,CAACV,UAAU,CAACS,OAAO,CAAC;MACtDP,QAAQ,CAACO,OAAO,IAAIC,YAAY,CAACR,QAAQ,CAACO,OAAO,CAAC;KACnD;GACF,EAAE,EAAE,CAAC;EAEN,MAAME,aAAa,GAAIC,CAAsC,IAAI;AAC/DR,IAAAA,QAAQ,CAAEQ,CAAC,IAAKC,MAAA,CAAAC,MAAA,CAAAD,MAAA,CAAAC,MAAA,CAAA,EAAA,EACXF,CAAC,CAAA,EAAA;AACJL,MAAAA,KAAK,EAAE;AAAI,KAAA,CACX,CAAC;AACH,IAAA,IAAIR,KAAK,CAACgB,UAAU,IAAIhB,KAAK,CAACgB,UAAU,KAAK,MAAM,IAAI,CAAChB,KAAK,CAACiB,QA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1,12 @@
1
- import { template, use, spread, mergeProps, getOwner, effect, style, insert, addEventListener, setAttribute } from 'solid-js/web';
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.scss.js';
4
4
  import classNames from 'classnames';
5
5
  import { createForwardRefComponent } from '../../utils/index.js';
6
- import { useRef, useState, useEffect, useCallback } from '../../utils/hooks.solid.js';
6
+ import { useRef, useState, useCallback, useEffect } from '../../utils/hooks.solid.js';
7
7
 
8
- var _tmpl$ = /*#__PURE__*/template(`<div><canvas-tag>`, true, false, false),
9
- _tmpl$2 = /*#__PURE__*/template(`<div>`),
10
- _tmpl$3 = /*#__PURE__*/template(`<img>`);
11
- // CDN脚本URL
12
- const LEGO_CDN_URL = 'http://ossin.jd.com/swm-plus/h5Tag/tag.js';
13
- // 检查CDN脚本是否已加载
14
- const isLegoScriptLoaded = () => {
15
- return document.querySelector(`script[src="${LEGO_CDN_URL}"]`) !== null;
16
- };
17
- // 插入CDN脚本
18
- const insertLegoScript = () => {
19
- if (isLegoScriptLoaded()) return;
20
- const script = document.createElement('script');
21
- script.type = 'module';
22
- script.src = LEGO_CDN_URL;
23
- document.head.appendChild(script);
24
- };
25
- // 解析lego协议URL
26
- const parseLegoUrl = src => {
27
- if (!src.startsWith('lego://')) return null;
28
- try {
29
- // 移除 'lego://' 前缀
30
- const urlWithoutProtocol = src.substring(7);
31
- // 分割tagId和参数
32
- const [tagId, params] = urlWithoutProtocol.split('?');
33
- // 解析参数
34
- const text = params ? new URLSearchParams(params).get('text') || '' : '';
35
- return {
36
- tagId,
37
- text
38
- };
39
- } catch (error) {
40
- console.warn('Failed to parse lego URL:', src, error);
41
- return null;
42
- }
43
- };
8
+ var _tmpl$ = /*#__PURE__*/template(`<div>`),
9
+ _tmpl$2 = /*#__PURE__*/template(`<img>`);
44
10
  function Image(props) {
45
11
  const imgRef = useRef(null);
46
12
  const observer = useRef({});
@@ -53,21 +19,9 @@ function Image(props) {
53
19
  onError,
54
20
  lazyLoad,
55
21
  imgProps,
56
- forwardedRef,
57
- lang
22
+ forwardedRef
58
23
  } = props,
59
- reset = __rest(props
60
- // 检查是否为lego模式
61
- , ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef", "lang"]);
62
- // 检查是否为lego模式
63
- const legoData = parseLegoUrl(src);
64
- const isLegoMode = legoData !== null;
65
- // 如果是lego模式,确保CDN脚本已加载
66
- useEffect(() => {
67
- if (isLegoMode) {
68
- insertLegoScript();
69
- }
70
- }, [isLegoMode]);
24
+ reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"]);
71
25
  const cls = classNames('taro-img', {
72
26
  'taro-img__widthfix': mode === 'widthFix'
73
27
  }, className);
@@ -106,55 +60,32 @@ function Image(props) {
106
60
  (_b = (_a = observer.current) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
107
61
  };
108
62
  }, [lazyLoad, src]);
109
- // 如果是lego模式,渲染canvas-tag
110
- if (isLegoMode && legoData) {
111
- return (() => {
112
- var _el$ = _tmpl$(),
113
- _el$2 = _el$.firstChild;
114
- use(forwardedRef, _el$);
115
- _el$.className = cls;
116
- spread(_el$, reset, false, true);
117
- _el$2.lang = lang;
118
- spread(_el$2, mergeProps({
119
- get tagId() {
120
- return legoData.tagId;
121
- },
122
- get text() {
123
- return legoData.text;
124
- }
125
- }, imgProps), false, false);
126
- _el$2._$owner = getOwner();
127
- effect(_$p => style(_el$, style$1, _$p));
128
- return _el$;
129
- })();
130
- }
131
- // 普通图片模式
132
63
  return (() => {
133
- var _el$3 = _tmpl$2();
134
- use(forwardedRef, _el$3);
135
- _el$3.className = cls;
136
- spread(_el$3, reset, false, true);
137
- insert(_el$3, lazyLoad ? (() => {
138
- var _el$4 = _tmpl$3();
139
- addEventListener(_el$4, "error", onError);
140
- addEventListener(_el$4, "load", imageOnLoad);
141
- use(img => imgRef.current = img, _el$4);
142
- _el$4.className = imgCls;
143
- setAttribute(_el$4, "data-src", src);
144
- spread(_el$4, imgProps, false, false);
145
- return _el$4;
64
+ var _el$ = _tmpl$();
65
+ use(forwardedRef, _el$);
66
+ _el$.className = cls;
67
+ spread(_el$, reset, false, true);
68
+ insert(_el$, lazyLoad ? (() => {
69
+ var _el$2 = _tmpl$2();
70
+ addEventListener(_el$2, "error", onError);
71
+ addEventListener(_el$2, "load", imageOnLoad);
72
+ use(img => imgRef.current = img, _el$2);
73
+ _el$2.className = imgCls;
74
+ setAttribute(_el$2, "data-src", src);
75
+ spread(_el$2, imgProps, false, false);
76
+ return _el$2;
146
77
  })() : (() => {
147
- var _el$5 = _tmpl$3();
148
- addEventListener(_el$5, "error", onError);
149
- addEventListener(_el$5, "load", imageOnLoad);
150
- use(img => imgRef.current = img, _el$5);
151
- _el$5.className = imgCls;
152
- setAttribute(_el$5, "src", src);
153
- spread(_el$5, imgProps, false, false);
154
- return _el$5;
78
+ var _el$3 = _tmpl$2();
79
+ addEventListener(_el$3, "error", onError);
80
+ addEventListener(_el$3, "load", imageOnLoad);
81
+ use(img => imgRef.current = img, _el$3);
82
+ _el$3.className = imgCls;
83
+ setAttribute(_el$3, "src", src);
84
+ spread(_el$3, imgProps, false, false);
85
+ return _el$3;
155
86
  })());
156
- effect(_$p => style(_el$3, style$1, _$p));
157
- return _el$3;
87
+ effect(_$p => style(_el$, style$1, _$p));
88
+ return _el$;
158
89
  })();
159
90
  }
160
91
  var index = createForwardRefComponent(Image);
@@ -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 lang?: string\n}\n\n// CDN脚本URL\nconst LEGO_CDN_URL = 'http://ossin.jd.com/swm-plus/h5Tag/tag.js'\n\n// 检查CDN脚本是否已加载\nconst isLegoScriptLoaded = (): boolean => {\n return document.querySelector(`script[src=\"${LEGO_CDN_URL}\"]`) !== null\n}\n\n// 插入CDN脚本\nconst insertLegoScript = (): void => {\n if (isLegoScriptLoaded()) return\n\n const script = document.createElement('script')\n script.type = 'module'\n script.src = LEGO_CDN_URL\n document.head.appendChild(script)\n}\n\n// 解析lego协议URL\nconst parseLegoUrl = (src: string): { tagId: string, text: string } | null => {\n if (!src.startsWith('lego://')) return null\n\n try {\n // 移除 'lego://' 前缀\n const urlWithoutProtocol = src.substring(7)\n\n // 分割tagId和参数\n const [tagId, params] = urlWithoutProtocol.split('?')\n\n // 解析参数\n const text = params ? new URLSearchParams(params).get('text') || '' : ''\n\n return { tagId, text }\n } catch (error) {\n console.warn('Failed to parse lego URL:', src, error)\n return null\n }\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 lang,\n ...reset\n } = props\n\n // 检查是否为lego模式\n const legoData = parseLegoUrl(src)\n const isLegoMode = legoData !== null\n\n // 如果是lego模式,确保CDN脚本已加载\n useEffect(() => {\n if (isLegoMode) {\n insertLegoScript()\n }\n }, [isLegoMode])\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 // 如果是lego模式,渲染canvas-tag\n if (isLegoMode && legoData) {\n return (\n <div className={cls} style={style} ref={forwardedRef} {...reset}>\n <canvas-tag\n tagId={legoData.tagId}\n text={legoData.text}\n lang={lang}\n {...imgProps}\n />\n </div>\n )\n }\n\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":["LEGO_CDN_URL","isLegoScriptLoaded","document","querySelector","insertLegoScript","script","createElement","type","src","head","appendChild","parseLegoUrl","startsWith","urlWithoutProtocol","substring","tagId","params","split","text","URLSearchParams","get","error","console","warn","Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","mode","onError","lazyLoad","imgProps","forwardedRef","lang","reset","__rest","legoData","isLegoMode","useEffect","cls","classNames","imgCls","toLowerCase","replace","imageOnLoad","useCallback","e","onLoad","Object","defineProperty","enumerable","writable","value","width","target","height","current","IntersectionObserver","entries","length","isIntersecting","rootMargin","_b","_a","observe","call","disconnect","_el$","_tmpl$","_el$2","firstChild","_$use","_$spread","_$mergeProps","_$owner","_$getOwner","_$effect","_$p","_$style","_el$3","_tmpl$2","_$insert","_el$4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C,OAAO,GAAG6B,GAAI,EAAAH,KAAA,CAAA;MAAAA,KAAA,CAAAxD,SAAA,GACvBe,MAAM;MAAA6C,YAAA,CAAAJ,KAAA,EAAA,UAAA,EACP/E,GAAG,CAAA;MAAAqE,MAAA,CAAAU,KAAA,EAGTnD,QAAQ,EAAA,KAAA,EAAA,KAAA,CAAA;AAAA,MAAA,OAAAmD,KAAA;AAAA,KAAA,GAAA,GAAA,CAAA,MAAA;MAAA,IAAAK,KAAA,GAAAJ,OAAA,EAAA;MAAAC,gBAAA,CAAAG,KAAA,EAAA,OAAA,EAQH1D,OAAO,CAAA;MAAAuD,gBAAA,CAAAG,KAAA,EAAA,MAAA,EADR3C,WAAW,CAAA;MAAA2B,GAAA,CAHdc,GAAG,IAAKhE,MAAM,CAACmC,OAAO,GAAG6B,GAAI,EAAAE,KAAA,CAAA;MAAAA,KAAA,CAAA7D,SAAA,GACvBe,MAAM;MAAA6C,YAAA,CAAAC,KAAA,EAAA,KAAA,EACZpF,GAAG,CAAA;MAAAqE,MAAA,CAAAe,KAAA,EAGJxD,QAAQ,EAAA,KAAA,EAAA,KAAA,CAAA;AAAA,MAAA,OAAAwD,KAAA;KAEf,GAAA,CAAA;IAAAX,MAAA,CAAAC,GAAA,IAAAC,KAAA,CAAAC,KAAA,EAnByBpD,OAAK,EAAAkD,GAAA,CAAA,CAAA;AAAA,IAAA,OAAAE,KAAA;AAAA,GAAA,GAAA;AAsBrC;AAEA,YAAeS,yBAAyB,CAACrE,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}\n\nfunction Image (props: IProps) {\n const imgRef = useRef<HTMLImageElement | null>(null)\n const observer = useRef<Partial<IntersectionObserver>>({})\n const [, setIsLoaded] = useState(false)\n const {\n className,\n style = {},\n src,\n mode,\n onError,\n lazyLoad,\n imgProps,\n forwardedRef,\n ...reset\n } = props\n\n const cls = classNames(\n 'taro-img',\n {\n 'taro-img__widthfix': mode === 'widthFix'\n },\n className\n )\n const imgCls = classNames(\n 'taro-img__mode-' +\n (mode || 'scaleToFill').toLowerCase().replace(/\\s/g, '')\n )\n\n const imageOnLoad = useCallback((e) => {\n const { onLoad } = props\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n width: e.target.width,\n height: e.target.height\n }\n })\n\n onLoad && onLoad(e)\n }, [props])\n\n useEffect(() => {\n if (lazyLoad) {\n observer.current = new IntersectionObserver(\n entries => {\n // 异步 api 关系\n if (entries[entries.length - 1].isIntersecting) {\n setIsLoaded(true)\n // findDOMNode(this).children[0].src = src\n imgRef.current!.src = src\n }\n },\n {\n rootMargin: '300px 0px'\n }\n )\n observer.current.observe?.(imgRef.current!)\n }\n\n return () => {\n observer.current?.disconnect?.()\n }\n }, [lazyLoad, src])\n\n return (\n <div className={cls} style={style} ref={forwardedRef} {...reset}>\n {lazyLoad ? (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n data-src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n ) : (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n )}\n </div>\n )\n}\n\nexport default createForwardRefComponent(Image)\n"],"names":["Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","src","mode","onError","lazyLoad","imgProps","forwardedRef","reset","__rest","cls","classNames","imgCls","toLowerCase","replace","imageOnLoad","useCallback","e","onLoad","Object","defineProperty","enumerable","writable","value","width","target","height","useEffect","current","IntersectionObserver","entries","length","isIntersecting","rootMargin","_b","_a","observe","call","disconnect","_el$","_tmpl$","_$use","_$spread","_$insert","_el$2","_tmpl$2","_$addEventListener","img","_$setAttribute","_el$3","_$effect","_$p","_$style","createForwardRefComponent"],"mappings":";;;;;;;;;AAmBA,SAASA,KAAKA,CAAEC,KAAa,EAAA;AAC3B,EAAA,MAAMC,MAAM,GAAGC,MAAM,CAA0B,IAAI,CAAC;AACpD,EAAA,MAAMC,QAAQ,GAAGD,MAAM,CAAgC,EAAE,CAAC;AAC1D,EAAA,MAAM,GAAGE,WAAW,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC;EACvC,MAAM;MACJC,SAAS;aACTC,OAAK,GAAG,EAAE;MACVC,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,EAAE,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3D;AAED,EAAA,MAAMC,WAAW,GAAGC,WAAW,CAAEC,CAAC,IAAI;IACpC,MAAM;AAAEC,MAAAA;AAAQ,KAAA,GAAGxB,KAAK;AACxByB,IAAAA,MAAM,CAACC,cAAc,CAACH,CAAC,EAAE,QAAQ,EAAE;AACjCI,MAAAA,UAAU,EAAE,IAAI;AAChBC,MAAAA,QAAQ,EAAE,IAAI;AACdC,MAAAA,KAAK,EAAE;AACLC,QAAAA,KAAK,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AAsBrC;AAEA,YAAec,yBAAyB,CAAC5D,KAAK,CAAC;;;;"}
@@ -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:1px solid rgba(0,0,0,.2);border-radius:10px;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(.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;line-height:2.3;padding:0 1.32em;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 .weui-loading{margin:-.2em .34em 0 0}.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-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{background-color:rgba(0,0,0,.6);position:absolute;z-index:1001}.taro-picker{background-color:#e5e5e5;bottom:0;font-size:14px;left:0;position:absolute;width:100%;z-index:1002}.taro-picker__hd{align-items:center;background-color:#fff;display:flex;font-size:17px;height:44px;justify-content:space-between;padding:0;position:relative}.taro-picker__hd:after{background-color:#e5e5e5;bottom:0;content:"";height:1px;left:0;position:absolute;transform:scaleY(.5);width:100%}.taro-picker__action{color:#ff0f23;flex:0 0 auto;font-size:14px;height:44px;line-height:44px;padding:0 10px}.taro-picker__action:first-child{color:#888}.taro-picker__title{color:#000;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{background-color:#fff;height:238px;overflow:hidden;width:100%}.taro-picker__bd,.taro-picker__group{box-sizing:border-box;display:flex;flex:1}.taro-picker__group{align-items:center;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{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));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__indicator:after,.taro-picker__indicator:before{background-color:#e5e5e5;content:"";height:1px;left:0;position:absolute;right:0;transform:scaleY(.5)}.taro-picker__indicator:before{top:0}.taro-picker__indicator:after{bottom:0}.taro-picker__content{box-sizing:border-box;height:100%;width:100%}.taro-picker__item{align-items:center;box-sizing:border-box;color:#000;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{color:#ff0f23;font-weight:500}.taro-picker__item--disabled{color:#999}.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}}.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}.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;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-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{background-color:rgba(0,0,0,.6);position:absolute;z-index:1001}.taro-picker{background-color:#e5e5e5;bottom:0;font-size:14px;left:0;position:absolute;width:100%;z-index:1002}.taro-picker__hd{align-items:center;background-color:#fff;display:flex;font-size:17px;height:44px;justify-content:space-between;padding:0;position:relative}.taro-picker__hd:after{background-color:#e5e5e5;bottom:0;content:"";height:1px;left:0;position:absolute;transform:scaleY(.5);width:100%}.taro-picker__action{color:#ff0f23;flex:0 0 auto;font-size:14px;height:44px;line-height:44px;padding:0 10px}.taro-picker__action:first-child{color:#888}.taro-picker__title{color:#000;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{background-color:#fff;height:238px;overflow:hidden;width:100%}.taro-picker__bd,.taro-picker__group{box-sizing:border-box;display:flex;flex:1}.taro-picker__group{align-items:center;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{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));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__indicator:after,.taro-picker__indicator:before{background-color:#e5e5e5;content:"";height:1px;left:0;position:absolute;right:0;transform:scaleY(.5)}.taro-picker__indicator:before{top:0}.taro-picker__indicator:after{bottom:0}.taro-picker__content{box-sizing:border-box;height:100%;width:100%}.taro-picker__item{align-items:center;box-sizing:border-box;color:#000;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{color:#ff0f23;font-weight:500}.taro-picker__item--disabled{color:#999}.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}}.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}.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/components-react",
3
- "version": "4.1.8-beta.2",
3
+ "version": "4.1.8",
4
4
  "description": "",
5
5
  "main:h5": "dist/index.js",
6
6
  "main": "dist/index.js",
@@ -29,9 +29,9 @@
29
29
  "identity-obj-proxy": "^3.0.0",
30
30
  "swiper": "11.1.15",
31
31
  "tslib": "^2.6.2",
32
- "@tarojs/shared": "4.1.8-beta.2",
33
- "@tarojs/taro": "4.1.8-beta.2",
34
- "@tarojs/components": "4.1.8-beta.2"
32
+ "@tarojs/components": "4.1.8",
33
+ "@tarojs/shared": "4.1.8",
34
+ "@tarojs/taro": "4.1.8"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@babel/plugin-transform-runtime": "^7.24.1",
@@ -47,8 +47,8 @@
47
47
  "jest-environment-jsdom": "^29.7.0",
48
48
  "solid-js": "^1.8.16",
49
49
  "ts-jest": "^29.1.1",
50
- "@tarojs/runtime": "4.1.8-beta.2",
51
- "@tarojs/helper": "4.1.8-beta.2"
50
+ "@tarojs/helper": "4.1.8",
51
+ "@tarojs/runtime": "4.1.8"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": "*",