@tarojs/components-react 4.0.0-canary.1 → 4.0.0-canary.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +14 -0
- package/dist/components/button/index.js +84 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/button/style/index.scss.js +4 -0
- package/dist/components/button/style/index.scss.js.map +1 -0
- package/dist/components/icon/index.js +33 -0
- package/dist/components/icon/index.js.map +1 -0
- package/dist/components/icon/style/index.scss.js +4 -0
- package/dist/components/icon/style/index.scss.js.map +1 -0
- package/dist/components/image/index.js +73 -104
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/image/style/index.css.js +4 -0
- package/dist/components/image/style/index.css.js.map +1 -0
- package/dist/components/input/index.js +229 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/input/style/index.scss.js +4 -0
- package/dist/components/input/style/index.scss.js.map +1 -0
- package/dist/components/pull-down-refresh/index.js +190 -211
- package/dist/components/pull-down-refresh/index.js.map +1 -1
- package/dist/components/pull-down-refresh/style/index.css.js +4 -0
- package/dist/components/pull-down-refresh/style/index.css.js.map +1 -0
- package/dist/components/scroll-view/index.js +134 -167
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/components/scroll-view/style/index.css.js +4 -0
- package/dist/components/scroll-view/style/index.css.js.map +1 -0
- package/dist/components/swiper/index.js +236 -269
- package/dist/components/swiper/index.js.map +1 -1
- package/dist/components/swiper/style/index.css.js +4 -0
- package/dist/components/swiper/style/index.css.js.map +1 -0
- package/dist/components/text/index.js +19 -33
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/text/style/index.css.js +4 -0
- package/dist/components/text/style/index.css.js.map +1 -0
- package/dist/components/view/index.js +69 -98
- package/dist/components/view/index.js.map +1 -1
- package/dist/components/view/style/index.css.js +4 -0
- package/dist/components/view/style/index.css.js.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/shared/dist/shared.esm.js +1164 -0
- package/dist/shared/dist/shared.esm.js.map +1 -0
- package/dist/solid/components/button/index.js +92 -0
- package/dist/solid/components/button/index.js.map +1 -0
- package/dist/solid/components/button/style/index.scss.js +4 -0
- package/dist/solid/components/button/style/index.scss.js.map +1 -0
- package/dist/solid/components/icon/index.js +35 -0
- package/dist/solid/components/icon/index.js.map +1 -0
- package/dist/solid/components/icon/style/index.scss.js +4 -0
- package/dist/solid/components/icon/style/index.scss.js.map +1 -0
- package/dist/solid/components/image/index.js +90 -0
- package/dist/solid/components/image/index.js.map +1 -0
- package/dist/solid/components/image/style/index.css.js +4 -0
- package/dist/solid/components/image/style/index.css.js.map +1 -0
- package/dist/solid/components/input/index.js +252 -0
- package/dist/solid/components/input/index.js.map +1 -0
- package/dist/solid/components/input/style/index.scss.js +4 -0
- package/dist/solid/components/input/style/index.scss.js.map +1 -0
- package/dist/solid/components/pull-down-refresh/index.js +328 -0
- package/dist/solid/components/pull-down-refresh/index.js.map +1 -0
- package/dist/solid/components/pull-down-refresh/style/index.css.js +4 -0
- package/dist/solid/components/pull-down-refresh/style/index.css.js.map +1 -0
- package/dist/solid/components/scroll-view/index.js +186 -0
- package/dist/solid/components/scroll-view/index.js.map +1 -0
- package/dist/solid/components/scroll-view/style/index.css.js +4 -0
- package/dist/solid/components/scroll-view/style/index.css.js.map +1 -0
- package/dist/solid/components/swiper/index.js +295 -0
- package/dist/solid/components/swiper/index.js.map +1 -0
- package/dist/solid/components/swiper/style/index.css.js +4 -0
- package/dist/solid/components/swiper/style/index.css.js.map +1 -0
- package/dist/solid/components/text/index.js +28 -0
- package/dist/solid/components/text/index.js.map +1 -0
- package/dist/solid/components/text/style/index.css.js +4 -0
- package/dist/solid/components/text/style/index.css.js.map +1 -0
- package/dist/solid/components/view/index.js +84 -0
- package/dist/solid/components/view/index.js.map +1 -0
- package/dist/solid/components/view/style/index.css.js +4 -0
- package/dist/solid/components/view/style/index.css.js.map +1 -0
- package/dist/solid/index.css +1 -0
- package/dist/solid/index.js +13 -0
- package/dist/solid/index.js.map +1 -0
- package/dist/solid/shared/dist/shared.esm.js +1164 -0
- package/dist/solid/shared/dist/shared.esm.js.map +1 -0
- package/dist/solid/utils/hooks.js +55 -0
- package/dist/solid/utils/hooks.js.map +1 -0
- package/dist/solid/utils/index.js +49 -0
- package/dist/solid/utils/index.js.map +1 -0
- package/dist/utils/hooks.js +55 -0
- package/dist/utils/hooks.js.map +1 -0
- package/dist/utils/index.js +20 -12
- package/dist/utils/index.js.map +1 -1
- package/package.json +27 -12
- package/dist/components/image/style/index.js +0 -8
- package/dist/components/image/style/index.js.map +0 -1
- package/dist/components/pull-down-refresh/style/index.js +0 -8
- package/dist/components/pull-down-refresh/style/index.js.map +0 -1
- package/dist/components/scroll-view/style/index.js +0 -8
- package/dist/components/scroll-view/style/index.js.map +0 -1
- package/dist/components/swiper/style/index.js +0 -8
- package/dist/components/swiper/style/index.js.map +0 -1
- package/dist/components/text/style/index.js +0 -8
- package/dist/components/text/style/index.js.map +0 -1
- package/dist/components/view/style/index.js +0 -8
- package/dist/components/view/style/index.js.map +0 -1
- package/dist/node_modules/.pnpm/registry.npmjs.org_style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +0 -27
- package/dist/node_modules/.pnpm/registry.npmjs.org_style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js.map +0 -1
- package/dist/node_modules/.pnpm/registry.npmjs.org_tslib@2.5.0/node_modules/tslib/tslib.es6.js +0 -446
- package/dist/node_modules/.pnpm/registry.npmjs.org_tslib@2.5.0/node_modules/tslib/tslib.es6.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -158,3 +158,17 @@ MIT (stencil-vue2-output-target):
|
|
|
158
158
|
The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
|
|
159
159
|
`/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
|
|
160
160
|
See `/LICENSE` for details of the license.
|
|
161
|
+
|
|
162
|
+
==================
|
|
163
|
+
|
|
164
|
+
MIT (weui):
|
|
165
|
+
The following files embed [stencil-vue2-output-target](https://github.com/Tencent/weui) MIT:
|
|
166
|
+
`/packages/taro-components/src/components/*.scss`
|
|
167
|
+
See `/LICENSE.txt` for details of the license.
|
|
168
|
+
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
Apache-2.0 (intersection-observer):
|
|
172
|
+
The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
|
|
173
|
+
`/packages/taro-api/src/polyfill/intersection-observer.ts`
|
|
174
|
+
See `/LICENSE.txt` for details of the license.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import './style/index.scss.js';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { omit } from '../../utils/index.js';
|
|
5
|
+
import { useRef, useState, useEffect } from '../../utils/hooks.js';
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
function Button(props) {
|
|
9
|
+
const startTimer = useRef();
|
|
10
|
+
const endTimer = useRef();
|
|
11
|
+
const [state, setState] = useState({
|
|
12
|
+
hover: false,
|
|
13
|
+
touch: false
|
|
14
|
+
});
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
return () => {
|
|
17
|
+
startTimer.current && clearTimeout(startTimer.current);
|
|
18
|
+
endTimer.current && clearTimeout(endTimer.current);
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
const _onTouchStart = e => {
|
|
22
|
+
setState(e => Object.assign(Object.assign({}, e), {
|
|
23
|
+
touch: true
|
|
24
|
+
}));
|
|
25
|
+
if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {
|
|
26
|
+
startTimer.current = setTimeout(() => {
|
|
27
|
+
if (state.touch) {
|
|
28
|
+
setState(e => Object.assign(Object.assign({}, e), {
|
|
29
|
+
hover: true
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
}, props.hoverStartTime || 20);
|
|
33
|
+
}
|
|
34
|
+
props.onTouchStart && props.onTouchStart(e);
|
|
35
|
+
};
|
|
36
|
+
const _onTouchEnd = e => {
|
|
37
|
+
setState(e => Object.assign(Object.assign({}, e), {
|
|
38
|
+
touch: false
|
|
39
|
+
}));
|
|
40
|
+
if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {
|
|
41
|
+
endTimer.current = setTimeout(() => {
|
|
42
|
+
if (!state.touch) {
|
|
43
|
+
setState(e => Object.assign(Object.assign({}, e), {
|
|
44
|
+
hover: false
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}, props.hoverStayTime || 70);
|
|
48
|
+
}
|
|
49
|
+
props.onTouchEnd && props.onTouchEnd(e);
|
|
50
|
+
};
|
|
51
|
+
const {
|
|
52
|
+
plain = false,
|
|
53
|
+
children,
|
|
54
|
+
disabled = false,
|
|
55
|
+
className,
|
|
56
|
+
style,
|
|
57
|
+
onClick,
|
|
58
|
+
hoverClass = 'button-hover',
|
|
59
|
+
loading = false,
|
|
60
|
+
type
|
|
61
|
+
} = props,
|
|
62
|
+
restProps = __rest(props, ["plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type"]);
|
|
63
|
+
const cls = classNames(className, 'taro-button-core', {
|
|
64
|
+
[`${hoverClass}`]: state.hover && !disabled
|
|
65
|
+
});
|
|
66
|
+
return /*#__PURE__*/jsxs("button", {
|
|
67
|
+
...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading']),
|
|
68
|
+
type: type,
|
|
69
|
+
className: cls,
|
|
70
|
+
style: style,
|
|
71
|
+
onClick: onClick,
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
onTouchStart: _onTouchStart,
|
|
74
|
+
onTouchEnd: _onTouchEnd,
|
|
75
|
+
loading: loading.toString(),
|
|
76
|
+
plain: plain.toString(),
|
|
77
|
+
children: [!!loading && /*#__PURE__*/jsx("i", {
|
|
78
|
+
className: "weui-loading"
|
|
79
|
+
}), children]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { Button as default };
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { omit } from '../../utils'\nimport { useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n size?: string\n plain?: boolean\n hoverClass?: string\n hoverStartTime?: number\n hoverStayTime?: number\n disabled?: boolean\n loading?: boolean\n type?: string\n className?: string\n}\n\ninterface IState {\n hover:boolean\n touch: boolean\n}\n\nfunction Button (props: IProps) {\n const startTimer = useRef<ReturnType<typeof setTimeout>>()\n const endTimer = useRef<ReturnType<typeof setTimeout>>()\n const [state, setState] = useState<IState>({\n hover: false,\n touch: false\n })\n\n useEffect(() => {\n return () => {\n startTimer.current && clearTimeout(startTimer.current)\n endTimer.current && clearTimeout(endTimer.current)\n }\n }, [])\n\n const _onTouchStart = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: true\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n startTimer.current = setTimeout(() => {\n if ((state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: true\n }))\n }\n }, props.hoverStartTime || 20)\n }\n props.onTouchStart && props.onTouchStart(e)\n }\n\n const _onTouchEnd = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: false\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n endTimer.current = setTimeout(() => {\n if (!(state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: false\n }))\n }\n }, props.hoverStayTime || 70)\n }\n props.onTouchEnd && props.onTouchEnd(e)\n }\n\n const { plain = false, children, disabled = false, className, style, onClick, hoverClass = 'button-hover', loading = false, type, ...restProps } = props\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled\n }\n )\n\n return (\n <button\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading'])}\n type={type}\n className={cls}\n style={style}\n onClick={onClick}\n disabled={disabled}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n loading={loading.toString()}\n plain={plain.toString()}\n >\n {!!loading && <i className='weui-loading' />}\n {children}\n </button>\n )\n}\n\nexport default Button\n"],"names":["Button","props","startTimer","useRef","endTimer","state","setState","useState","hover","touch","useEffect","current","clearTimeout","_onTouchStart","e","Object","assign","hoverClass","disabled","setTimeout","hoverStartTime","onTouchStart","_onTouchEnd","hoverStayTime","onTouchEnd","plain","children","className","style","onClick","loading","type","restProps","__rest","cls","classNames","_jsxs","omit","toString","_jsx"],"mappings":";;;;;;;AA0BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC,CAAA;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC,CAAA;AACxD,EAAA,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAS;AACzCC,IAAAA,KAAK,EAAE,KAAK;AACZC,IAAAA,KAAK,EAAE,KAAA;AACR,GAAA,CAAC,CAAA;AAEFC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAO,MAAK;MACVR,UAAU,CAACS,OAAO,IAAIC,YAAY,CAACV,UAAU,CAACS,OAAO,CAAC,CAAA;MACtDP,QAAQ,CAACO,OAAO,IAAIC,YAAY,CAACR,QAAQ,CAACO,OAAO,CAAC,CAAA;KACnD,CAAA;GACF,EAAE,EAAE,CAAC,CAAA;EAEN,MAAME,aAAa,GAAIC,CAAsC,IAAI;AAC/DR,IAAAA,QAAQ,CAAEQ,CAAC,IAAKC,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EAAEA,QAAS;AACnBG,IAAAA,YAAY,EAAER,aAAc;AAC5BW,IAAAA,UAAU,EAAEF,WAAY;AACxBQ,IAAAA,OAAO,EAAEA,OAAO,CAACQ,QAAQ,EAAG;AAC5Bb,IAAAA,KAAK,EAAEA,KAAK,CAACa,QAAQ,EAAG;AAAAZ,IAAAA,QAAA,EAEvB,CAAA,CAAC,CAACI,OAAO,iBAAIS,GAAA,CAAA,GAAA,EAAA;AAAGZ,MAAAA,SAAS,EAAC,cAAA;KAAc,CAAG,EAC3CD,QAAQ,CAAA;AAAA,GACH,CAAC,CAAA;AAEb;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import './style/index.scss.js';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { omit } from '../../utils/index.js';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const Icon = props => {
|
|
7
|
+
let {
|
|
8
|
+
type,
|
|
9
|
+
className = '',
|
|
10
|
+
size = '23',
|
|
11
|
+
color
|
|
12
|
+
} = props;
|
|
13
|
+
if (type) type = type.replace(/_/g, '-');
|
|
14
|
+
const cls = classNames({
|
|
15
|
+
[`weui-icon-${type}`]: true
|
|
16
|
+
}, className);
|
|
17
|
+
const style = {
|
|
18
|
+
'font-size': size + 'px',
|
|
19
|
+
color: color
|
|
20
|
+
};
|
|
21
|
+
return (
|
|
22
|
+
/*#__PURE__*/
|
|
23
|
+
// eslint-disable-next-line react/react-in-jsx-scope
|
|
24
|
+
jsx("i", {
|
|
25
|
+
...omit(props, ['type', 'className']),
|
|
26
|
+
className: cls,
|
|
27
|
+
style: style
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { Icon as default };
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/icon/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\n\nimport { omit } from '../../utils'\n\ninterface IProps {\n type: string\n color: string\n size?: number | string\n className?: string\n}\n\nconst Icon = (props: IProps) => {\n let { type, className = '', size = '23', color } = props\n if (type) type = type.replace(/_/g, '-')\n const cls = classNames(\n {\n [`weui-icon-${type}`]: true\n },\n className\n )\n const style = { 'font-size': size + 'px', color: color }\n\n return (\n // eslint-disable-next-line react/react-in-jsx-scope\n <i {...omit(props, ['type', 'className'])} className={cls} style={style} />\n )\n}\nexport default Icon\n"],"names":["Icon","props","type","className","size","color","replace","cls","classNames","style","_jsx","omit"],"mappings":";;;;;AAaMA,MAAAA,IAAI,GAAIC,KAAa,IAAI;EAC7B,IAAI;IAAEC,IAAI;AAAEC,IAAAA,SAAS,GAAG,EAAE;AAAEC,IAAAA,IAAI,GAAG,IAAI;AAAEC,IAAAA,KAAAA;AAAO,GAAA,GAAGJ,KAAK,CAAA;EACxD,IAAIC,IAAI,EAAEA,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;EACxC,MAAMC,GAAG,GAAGC,UAAU,CACpB;IACE,CAAc,CAAA,UAAA,EAAAN,IAAM,CAAA,CAAA,GAAG,IAAA;GACxB,EACDC,SAAS,CACV,CAAA;AACD,EAAA,MAAMM,KAAK,GAAG;IAAE,WAAW,EAAEL,IAAI,GAAG,IAAI;AAAEC,IAAAA,KAAK,EAAEA,KAAAA;GAAO,CAAA;AAExD,EAAA;AAAA;AACE;IACAK,GAAA,CAAA,GAAA,EAAA;MAAA,GAAOC,IAAI,CAACV,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAAEE,MAAAA,SAAS,EAAEI,GAAI;AAACE,MAAAA,KAAK,EAAEA,KAAAA;KAAS,CAAA;AAAA,IAAA;AAE/E;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,113 +1,82 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
|
|
4
|
-
import _inherits from '@babel/runtime/helpers/inherits';
|
|
5
|
-
import _createSuper from '@babel/runtime/helpers/createSuper';
|
|
6
|
-
import { __rest } from '../../node_modules/.pnpm/registry.npmjs.org_tslib@2.5.0/node_modules/tslib/tslib.es6.js';
|
|
7
|
-
import 'weui';
|
|
8
|
-
import './style/index.js';
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import './style/index.css.js';
|
|
9
3
|
import classNames from 'classnames';
|
|
10
|
-
import
|
|
4
|
+
import { useRef, useState, useCallback, useEffect } from '../../utils/hooks.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// findDOMNode(this).children[0].src = this.props.src
|
|
41
|
-
_this2.imgRef.src = _this2.props.src;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
rootMargin: '300px 0px'
|
|
46
|
-
});
|
|
47
|
-
this.observer.observe(this.imgRef);
|
|
7
|
+
function Image(props) {
|
|
8
|
+
const imgRef = useRef(null);
|
|
9
|
+
const observer = useRef({});
|
|
10
|
+
const [, setIsLoaded] = useState(false);
|
|
11
|
+
const {
|
|
12
|
+
className,
|
|
13
|
+
style = {},
|
|
14
|
+
src,
|
|
15
|
+
mode,
|
|
16
|
+
onError,
|
|
17
|
+
lazyLoad,
|
|
18
|
+
imgProps
|
|
19
|
+
} = props,
|
|
20
|
+
reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps"]);
|
|
21
|
+
const cls = classNames('taro-img', {
|
|
22
|
+
'taro-img__widthfix': mode === 'widthFix'
|
|
23
|
+
}, className);
|
|
24
|
+
const imgCls = classNames('taro-img__mode-' + (mode || 'scaleToFill').toLowerCase().replace(/\s/g, ''));
|
|
25
|
+
const imageOnLoad = useCallback(e => {
|
|
26
|
+
const {
|
|
27
|
+
onLoad
|
|
28
|
+
} = props;
|
|
29
|
+
Object.defineProperty(e, 'detail', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: {
|
|
33
|
+
width: e.target.width,
|
|
34
|
+
height: e.target.height
|
|
48
35
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
writable: true,
|
|
62
|
-
value: {
|
|
63
|
-
width: e.target.width,
|
|
64
|
-
height: e.target.height
|
|
36
|
+
});
|
|
37
|
+
onLoad && onLoad(e);
|
|
38
|
+
}, [props]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (lazyLoad) {
|
|
42
|
+
observer.current = new IntersectionObserver(entries => {
|
|
43
|
+
// 异步 api 关系
|
|
44
|
+
if (entries[entries.length - 1].isIntersecting) {
|
|
45
|
+
setIsLoaded(true);
|
|
46
|
+
// findDOMNode(this).children[0].src = src
|
|
47
|
+
imgRef.current.src = src;
|
|
65
48
|
}
|
|
49
|
+
}, {
|
|
50
|
+
rootMargin: '300px 0px'
|
|
66
51
|
});
|
|
67
|
-
|
|
52
|
+
(_b = (_a = observer.current).observe) === null || _b === void 0 ? void 0 : _b.call(_a, imgRef.current);
|
|
68
53
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"data-src": src,
|
|
96
|
-
onLoad: this.imageOnLoad,
|
|
97
|
-
onError: onError
|
|
98
|
-
}, imgProps)) : React.createElement("img", Object.assign({
|
|
99
|
-
ref: function ref(img) {
|
|
100
|
-
return _this3.imgRef = img;
|
|
101
|
-
},
|
|
102
|
-
className: imgCls,
|
|
103
|
-
src: src,
|
|
104
|
-
onLoad: this.imageOnLoad,
|
|
105
|
-
onError: onError
|
|
106
|
-
}, imgProps)));
|
|
107
|
-
}
|
|
108
|
-
}]);
|
|
109
|
-
return Image;
|
|
110
|
-
}(React.Component);
|
|
54
|
+
return () => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
(_b = (_a = observer.current) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
57
|
+
};
|
|
58
|
+
}, [lazyLoad, src]);
|
|
59
|
+
return /*#__PURE__*/jsx("div", {
|
|
60
|
+
className: cls,
|
|
61
|
+
style: style,
|
|
62
|
+
...reset,
|
|
63
|
+
children: lazyLoad ? /*#__PURE__*/jsx("img", {
|
|
64
|
+
ref: img => imgRef.current = img,
|
|
65
|
+
className: imgCls,
|
|
66
|
+
"data-src": src,
|
|
67
|
+
onLoad: imageOnLoad,
|
|
68
|
+
onError: onError,
|
|
69
|
+
...imgProps
|
|
70
|
+
}) : /*#__PURE__*/jsx("img", {
|
|
71
|
+
ref: img => imgRef.current = img,
|
|
72
|
+
className: imgCls,
|
|
73
|
+
src: src,
|
|
74
|
+
onLoad: imageOnLoad,
|
|
75
|
+
onError: onError,
|
|
76
|
+
...imgProps
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
111
80
|
|
|
112
81
|
export { Image as default };
|
|
113
82
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/image/index.tsx"],"sourcesContent":["import '
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.css'\n\nimport classNames from 'classnames'\n\nimport { useCallback, useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n src: string\n mode: string\n onError: () => void\n onLoad: (e) => void\n lazyLoad?: boolean\n imgProps?: Record<string, any>\n}\n\nfunction Image (props: IProps) {\n const imgRef = useRef<HTMLImageElement | null>(null)\n const observer = useRef<Partial<IntersectionObserver>>({})\n const [, setIsLoaded] = useState(false)\n const {\n className,\n style = {},\n src,\n mode,\n onError,\n lazyLoad,\n imgProps,\n ...reset\n } = props\n const cls = classNames(\n 'taro-img',\n {\n 'taro-img__widthfix': mode === 'widthFix'\n },\n className\n )\n const imgCls = classNames(\n 'taro-img__mode-' +\n (mode || 'scaleToFill').toLowerCase().replace(/\\s/g, '')\n )\n\n const imageOnLoad = useCallback((e) => {\n const { onLoad } = props\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n width: e.target.width,\n height: e.target.height\n }\n })\n\n onLoad && onLoad(e)\n }, [props])\n\n useEffect(() => {\n if (lazyLoad) {\n observer.current = new IntersectionObserver(\n entries => {\n // 异步 api 关系\n if (entries[entries.length - 1].isIntersecting) {\n setIsLoaded(true)\n // findDOMNode(this).children[0].src = src\n imgRef.current!.src = src\n }\n },\n {\n rootMargin: '300px 0px'\n }\n )\n observer.current.observe?.(imgRef.current!)\n }\n\n return () => {\n observer.current?.disconnect?.()\n }\n }, [lazyLoad, src])\n\n return (\n <div className={cls} style={style} {...reset}>\n {lazyLoad ? (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n data-src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n ) : (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n )}\n </div>\n )\n}\n\nexport default Image\n"],"names":["Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","src","mode","onError","lazyLoad","imgProps","reset","__rest","cls","classNames","imgCls","toLowerCase","replace","imageOnLoad","useCallback","e","onLoad","Object","defineProperty","enumerable","writable","value","width","target","height","useEffect","current","IntersectionObserver","entries","length","isIntersecting","rootMargin","_b","_a","observe","call","disconnect","_jsx","children","ref","img"],"mappings":";;;;;;AAiBA,SAASA,KAAKA,CAAEC,KAAa,EAAA;AAC3B,EAAA,MAAMC,MAAM,GAAGC,MAAM,CAA0B,IAAI,CAAC,CAAA;AACpD,EAAA,MAAMC,QAAQ,GAAGD,MAAM,CAAgC,EAAE,CAAC,CAAA;AAC1D,EAAA,MAAM,GAAGE,WAAW,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC,CAAA;EACvC,MAAM;MACJC,SAAS;MACTC,KAAK,GAAG,EAAE;MACVC,GAAG;MACHC,IAAI;MACJC,OAAO;MACPC,QAAQ;AACRC,MAAAA,QAAAA;AAAQ,KAAA,GAENZ,KAAK;IADJa,KAAK,GAAAC,MAAA,CACNd,KAAK,EATH,CASL,WAAA,EAAA,OAAA,EAAA,KAAA,EAAA,MAAA,EAAA,SAAA,EAAA,UAAA,EAAA,UAAA,CAAA,CAAQ,CAAA;AACT,EAAA,MAAMe,GAAG,GAAGC,UAAU,CACpB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