@tarojs/components-react 4.0.0-canary.9 → 4.0.1-alpha.0
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 +8 -8
- package/dist/components/button/index.js +87 -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 +36 -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 +76 -101
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/image/style/index.css.js +2 -6
- package/dist/components/image/style/index.css.js.map +1 -1
- package/dist/components/input/index.js +233 -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 +195 -210
- package/dist/components/pull-down-refresh/index.js.map +1 -1
- package/dist/components/pull-down-refresh/style/index.css.js +2 -6
- package/dist/components/pull-down-refresh/style/index.css.js.map +1 -1
- package/dist/components/scroll-view/index.js +137 -167
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/components/scroll-view/style/index.css.js +2 -6
- package/dist/components/scroll-view/style/index.css.js.map +1 -1
- package/dist/components/swiper/index.js +248 -268
- package/dist/components/swiper/index.js.map +1 -1
- package/dist/components/swiper/style/index.css.js +2 -6
- package/dist/components/swiper/style/index.css.js.map +1 -1
- package/dist/components/text/index.js +22 -31
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/text/style/index.css.js +2 -6
- package/dist/components/text/style/index.css.js.map +1 -1
- package/dist/components/view/index.js +72 -97
- package/dist/components/view/index.js.map +1 -1
- package/dist/index.css +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/solid/components/button/index.js +95 -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 +39 -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 +94 -0
- package/dist/solid/components/image/index.js.map +1 -0
- package/dist/solid/components/image/style/index.css.js +4 -0
- package/dist/{components/view → solid/components/image}/style/index.css.js.map +1 -1
- package/dist/solid/components/input/index.js +256 -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 +334 -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 +188 -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 +307 -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 +32 -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 +88 -0
- package/dist/solid/components/view/index.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/utils/hooks.solid.js +54 -0
- package/dist/solid/utils/hooks.solid.js.map +1 -0
- package/dist/solid/utils/index.js +58 -0
- package/dist/solid/utils/index.js.map +1 -0
- package/dist/utils/hooks.react.js +15 -0
- package/dist/utils/hooks.react.js.map +1 -0
- package/dist/utils/index.js +31 -12
- package/dist/utils/index.js.map +1 -1
- package/package.json +20 -17
- package/types/index.d.ts +14 -0
- package/dist/components/view/style/index.css.js +0 -8
- 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/LICENSE
CHANGED
|
@@ -154,15 +154,8 @@ See `/LICENSE` for details of the license.
|
|
|
154
154
|
|
|
155
155
|
==================
|
|
156
156
|
|
|
157
|
-
MIT (stencil-vue2-output-target):
|
|
158
|
-
The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
|
|
159
|
-
`/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
|
|
160
|
-
See `/LICENSE` for details of the license.
|
|
161
|
-
|
|
162
|
-
==================
|
|
163
|
-
|
|
164
157
|
MIT (weui):
|
|
165
|
-
The following files embed [
|
|
158
|
+
The following files embed [weui](https://github.com/Tencent/weui) MIT:
|
|
166
159
|
`/packages/taro-components/src/components/*.scss`
|
|
167
160
|
See `/LICENSE.txt` for details of the license.
|
|
168
161
|
|
|
@@ -172,3 +165,10 @@ Apache-2.0 (intersection-observer):
|
|
|
172
165
|
The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
|
|
173
166
|
`/packages/taro-api/src/polyfill/intersection-observer.ts`
|
|
174
167
|
See `/LICENSE.txt` for details of the license.
|
|
168
|
+
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
MIT (babel-plugin-jsx-dom-expressions):
|
|
172
|
+
The following files embed [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) MIT:
|
|
173
|
+
`/packages/babel-plugin-transform-solid-jsx/src/*`
|
|
174
|
+
See `/LICENSE` for details of the license.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import './style/index.scss.js';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { omit, createForwardRefComponent } from '../../utils/index.js';
|
|
5
|
+
import { useRef, useState, useEffect } from '../../utils/hooks.react.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
|
+
forwardedRef,
|
|
53
|
+
plain = false,
|
|
54
|
+
children,
|
|
55
|
+
disabled = false,
|
|
56
|
+
className,
|
|
57
|
+
style,
|
|
58
|
+
onClick,
|
|
59
|
+
hoverClass = 'button-hover',
|
|
60
|
+
loading = false,
|
|
61
|
+
type
|
|
62
|
+
} = props,
|
|
63
|
+
restProps = __rest(props, ["forwardedRef", "plain", "children", "disabled", "className", "style", "onClick", "hoverClass", "loading", "type"]);
|
|
64
|
+
const cls = classNames(className, 'taro-button-core', {
|
|
65
|
+
[`${hoverClass}`]: state.hover && !disabled
|
|
66
|
+
});
|
|
67
|
+
return /*#__PURE__*/jsxs("button", {
|
|
68
|
+
...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef']),
|
|
69
|
+
type: type,
|
|
70
|
+
ref: forwardedRef,
|
|
71
|
+
className: cls,
|
|
72
|
+
style: style,
|
|
73
|
+
onClick: onClick,
|
|
74
|
+
disabled: disabled,
|
|
75
|
+
onTouchStart: _onTouchStart,
|
|
76
|
+
onTouchEnd: _onTouchEnd,
|
|
77
|
+
loading: loading.toString(),
|
|
78
|
+
plain: plain.toString(),
|
|
79
|
+
children: [!!loading && /*#__PURE__*/jsx("i", {
|
|
80
|
+
className: "weui-loading"
|
|
81
|
+
}), children]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
var index = createForwardRefComponent(Button);
|
|
85
|
+
|
|
86
|
+
export { index as default };
|
|
87
|
+
//# 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 { createForwardRefComponent, omit } from '../../utils'\nimport { useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n size?: string\n plain?: boolean\n hoverClass?: string\n hoverStartTime?: number\n hoverStayTime?: number\n disabled?: boolean\n loading?: boolean\n type?: string\n className?: string\n forwardedRef?: React.MutableRefObject<HTMLButtonElement>\n}\n\ninterface IState {\n hover:boolean\n touch: boolean\n}\n\nfunction Button (props: IProps) {\n const startTimer = useRef<ReturnType<typeof setTimeout>>()\n const endTimer = useRef<ReturnType<typeof setTimeout>>()\n const [state, setState] = useState<IState>({\n hover: false,\n touch: false\n })\n\n useEffect(() => {\n return () => {\n startTimer.current && clearTimeout(startTimer.current)\n endTimer.current && clearTimeout(endTimer.current)\n }\n }, [])\n\n const _onTouchStart = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: true\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n startTimer.current = setTimeout(() => {\n if ((state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: true\n }))\n }\n }, props.hoverStartTime || 20)\n }\n props.onTouchStart && props.onTouchStart(e)\n }\n\n const _onTouchEnd = (e: React.TouchEvent<HTMLButtonElement>) => {\n setState((e) => ({\n ...e,\n touch: false\n }))\n if (props.hoverClass && props.hoverClass !== 'none' && !props.disabled) {\n endTimer.current = setTimeout(() => {\n if (!(state as IState).touch) {\n setState((e) => ({\n ...e,\n hover: false\n }))\n }\n }, props.hoverStayTime || 70)\n }\n props.onTouchEnd && props.onTouchEnd(e)\n }\n\n const { forwardedRef, plain = false, children, disabled = false, className, style, onClick, hoverClass = 'button-hover', loading = false, type, ...restProps } = props\n\n const cls = classNames(\n className,\n 'taro-button-core',\n {\n [`${hoverClass}`]: (state as IState).hover && !disabled\n }\n )\n\n return (\n <button\n {...omit(restProps, ['hoverClass', 'onTouchStart', 'onTouchEnd', 'type', 'loading', 'forwardedRef'])}\n type={type}\n ref={forwardedRef}\n className={cls}\n style={style}\n onClick={onClick}\n disabled={disabled}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n loading={loading.toString()}\n plain={plain.toString()}\n >\n {!!loading && <i className='weui-loading' />}\n {children}\n </button>\n )\n}\n\nexport default createForwardRefComponent(Button)\n"],"names":["Button","props","startTimer","useRef","endTimer","state","setState","useState","hover","touch","useEffect","current","clearTimeout","_onTouchStart","e","Object","assign","hoverClass","disabled","setTimeout","hoverStartTime","onTouchStart","_onTouchEnd","hoverStayTime","onTouchEnd","forwardedRef","plain","children","className","style","onClick","loading","type","restProps","__rest","cls","classNames","_jsxs","omit","ref","toString","_jsx","createForwardRefComponent"],"mappings":";;;;;;;AA2BA,SAASA,MAAMA,CAAEC,KAAa,EAAA;AAC5B,EAAA,MAAMC,UAAU,GAAGC,MAAM,EAAiC,CAAA;AAC1D,EAAA,MAAMC,QAAQ,GAAGD,MAAM,EAAiC,CAAA;AACxD,EAAA,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAS;AACzCC,IAAAA,KAAK,EAAE,KAAK;AACZC,IAAAA,KAAK,EAAE,KAAA;AACR,GAAA,CAAC,CAAA;AAEFC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAO,MAAK;MACVR,UAAU,CAACS,OAAO,IAAIC,YAAY,CAACV,UAAU,CAACS,OAAO,CAAC,CAAA;MACtDP,QAAQ,CAACO,OAAO,IAAIC,YAAY,CAACR,QAAQ,CAACO,OAAO,CAAC,CAAA;KACnD,CAAA;GACF,EAAE,EAAE,CAAC,CAAA;EAEN,MAAME,aAAa,GAAIC,CAAsC,IAAI;AAC/DR,IAAAA,QAAQ,CAAEQ,CAAC,IAAKC,MAAA,CAAAC,MAAA,CAAAD,MAAA,CAAAC,MAAA,CAAA,EAAA,EACXF,CAAC,CAAA,EAAA;AACJL,MAAAA,KAAK,EAAE,IAAA;AAAI,KAAA,CACX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UAAU,EAAEF,WAAY;AACxBS,IAAAA,OAAO,EAAEA,OAAO,CAACS,QAAQ,EAAG;AAC5Bd,IAAAA,KAAK,EAAEA,KAAK,CAACc,QAAQ,EAAG;AAAAb,IAAAA,QAAA,EAEvB,CAAA,CAAC,CAACI,OAAO,iBAAIU,GAAA,CAAA,GAAA,EAAA;AAAGb,MAAAA,SAAS,EAAC,cAAA;KAAc,CAAG,EAC3CD,QAAQ,CAAA;AAAA,GACH,CAAC,CAAA;AAEb,CAAA;AAEA,YAAee,yBAAyB,CAAC1C,MAAM,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import './style/index.scss.js';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { omit, createForwardRefComponent } 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
|
+
forwardedRef
|
|
13
|
+
} = props;
|
|
14
|
+
if (type) type = type.replace(/_/g, '-');
|
|
15
|
+
const cls = classNames({
|
|
16
|
+
[`weui-icon-${type}`]: true
|
|
17
|
+
}, className);
|
|
18
|
+
const style = {
|
|
19
|
+
'font-size': size + 'px',
|
|
20
|
+
color: color
|
|
21
|
+
};
|
|
22
|
+
return (
|
|
23
|
+
/*#__PURE__*/
|
|
24
|
+
// eslint-disable-next-line react/react-in-jsx-scope
|
|
25
|
+
jsx("i", {
|
|
26
|
+
ref: forwardedRef,
|
|
27
|
+
...omit(props, ['type', 'className', 'forwardedRef']),
|
|
28
|
+
className: cls,
|
|
29
|
+
style: style
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
var index = createForwardRefComponent(Icon);
|
|
34
|
+
|
|
35
|
+
export { index as default };
|
|
36
|
+
//# 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 { createForwardRefComponent, omit } from '../../utils'\n\ninterface IProps {\n type: string\n color: string\n size?: number | string\n className?: string\n forwardedRef?: React.MutableRefObject<HTMLLIElement>\n}\n\nconst Icon = (props: IProps) => {\n let { type, className = '', size = '23', color, forwardedRef } = props\n if (type) type = type.replace(/_/g, '-')\n const cls = classNames(\n {\n [`weui-icon-${type}`]: true\n },\n className\n )\n const style = { 'font-size': size + 'px', color: color }\n\n return (\n // eslint-disable-next-line react/react-in-jsx-scope\n <i ref={forwardedRef} {...omit(props, ['type', 'className', 'forwardedRef'])} className={cls} style={style} />\n )\n}\nexport default createForwardRefComponent(Icon)\n"],"names":["Icon","props","type","className","size","color","forwardedRef","replace","cls","classNames","style","_jsx","ref","omit","createForwardRefComponent"],"mappings":";;;;;AAcA,MAAMA,IAAI,GAAIC,KAAa,IAAI;EAC7B,IAAI;IAAEC,IAAI;AAAEC,IAAAA,SAAS,GAAG,EAAE;AAAEC,IAAAA,IAAI,GAAG,IAAI;IAAEC,KAAK;AAAEC,IAAAA,YAAAA;AAAc,GAAA,GAAGL,KAAK,CAAA;EACtE,IAAIC,IAAI,EAAEA,IAAI,GAAGA,IAAI,CAACK,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;EACxC,MAAMC,GAAG,GAAGC,UAAU,CACpB;IACE,CAAC,CAAA,UAAA,EAAaP,IAAI,CAAA,CAAE,GAAG,IAAA;GACxB,EACDC,SAAS,CACV,CAAA;AACD,EAAA,MAAMO,KAAK,GAAG;IAAE,WAAW,EAAEN,IAAI,GAAG,IAAI;AAAEC,IAAAA,KAAK,EAAEA,KAAAA;GAAO,CAAA;AAExD,EAAA;AAAA;AACE;IACAM,GAAA,CAAA,GAAA,EAAA;AAAGC,MAAAA,GAAG,EAAEN,YAAa;MAAA,GAAKO,IAAI,CAACZ,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AAAEE,MAAAA,SAAS,EAAEK,GAAI;AAACE,MAAAA,KAAK,EAAEA,KAAAA;KAAM,CAAA;AAAG,IAAA;AAElH,CAAC,CAAA;AACD,YAAeI,yBAAyB,CAACd,IAAI,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,111 +1,86 @@
|
|
|
1
|
-
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
-
import _createClass from '@babel/runtime/helpers/createClass';
|
|
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
1
|
import { __rest } from 'tslib';
|
|
7
2
|
import './style/index.css.js';
|
|
8
3
|
import classNames from 'classnames';
|
|
9
|
-
import
|
|
4
|
+
import { createForwardRefComponent } from '../../utils/index.js';
|
|
5
|
+
import { useRef, useState, useCallback, useEffect } from '../../utils/hooks.react.js';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
7
|
|
|
11
|
-
|
|
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
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
rootMargin: '300px 0px'
|
|
44
|
-
});
|
|
45
|
-
this.observer.observe(this.imgRef);
|
|
8
|
+
function Image(props) {
|
|
9
|
+
const imgRef = useRef(null);
|
|
10
|
+
const observer = useRef({});
|
|
11
|
+
const [, setIsLoaded] = useState(false);
|
|
12
|
+
const {
|
|
13
|
+
className,
|
|
14
|
+
style = {},
|
|
15
|
+
src,
|
|
16
|
+
mode,
|
|
17
|
+
onError,
|
|
18
|
+
lazyLoad,
|
|
19
|
+
imgProps,
|
|
20
|
+
forwardedRef
|
|
21
|
+
} = props,
|
|
22
|
+
reset = __rest(props, ["className", "style", "src", "mode", "onError", "lazyLoad", "imgProps", "forwardedRef"]);
|
|
23
|
+
const cls = classNames('taro-img', {
|
|
24
|
+
'taro-img__widthfix': mode === 'widthFix'
|
|
25
|
+
}, className);
|
|
26
|
+
const imgCls = classNames('taro-img__mode-' + (mode || 'scaleToFill').toLowerCase().replace(/\s/g, ''));
|
|
27
|
+
const imageOnLoad = useCallback(e => {
|
|
28
|
+
const {
|
|
29
|
+
onLoad
|
|
30
|
+
} = props;
|
|
31
|
+
Object.defineProperty(e, 'detail', {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: {
|
|
35
|
+
width: e.target.width,
|
|
36
|
+
height: e.target.height
|
|
46
37
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
writable: true,
|
|
60
|
-
value: {
|
|
61
|
-
width: e.target.width,
|
|
62
|
-
height: e.target.height
|
|
38
|
+
});
|
|
39
|
+
onLoad && onLoad(e);
|
|
40
|
+
}, [props]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
if (lazyLoad) {
|
|
44
|
+
observer.current = new IntersectionObserver(entries => {
|
|
45
|
+
// 异步 api 关系
|
|
46
|
+
if (entries[entries.length - 1].isIntersecting) {
|
|
47
|
+
setIsLoaded(true);
|
|
48
|
+
// findDOMNode(this).children[0].src = src
|
|
49
|
+
imgRef.current.src = src;
|
|
63
50
|
}
|
|
51
|
+
}, {
|
|
52
|
+
rootMargin: '300px 0px'
|
|
64
53
|
});
|
|
65
|
-
|
|
54
|
+
(_b = (_a = observer.current).observe) === null || _b === void 0 ? void 0 : _b.call(_a, imgRef.current);
|
|
66
55
|
}
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
onError: onError
|
|
96
|
-
}, imgProps)) : React.createElement("img", Object.assign({
|
|
97
|
-
ref: function ref(img) {
|
|
98
|
-
return _this3.imgRef = img;
|
|
99
|
-
},
|
|
100
|
-
className: imgCls,
|
|
101
|
-
src: src,
|
|
102
|
-
onLoad: this.imageOnLoad,
|
|
103
|
-
onError: onError
|
|
104
|
-
}, imgProps)));
|
|
105
|
-
}
|
|
106
|
-
}]);
|
|
107
|
-
return Image;
|
|
108
|
-
}(React.Component);
|
|
56
|
+
return () => {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
(_b = (_a = observer.current) === null || _a === void 0 ? void 0 : _a.disconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
59
|
+
};
|
|
60
|
+
}, [lazyLoad, src]);
|
|
61
|
+
return /*#__PURE__*/jsx("div", {
|
|
62
|
+
className: cls,
|
|
63
|
+
style: style,
|
|
64
|
+
ref: forwardedRef,
|
|
65
|
+
...reset,
|
|
66
|
+
children: lazyLoad ? /*#__PURE__*/jsx("img", {
|
|
67
|
+
ref: img => imgRef.current = img,
|
|
68
|
+
className: imgCls,
|
|
69
|
+
"data-src": src,
|
|
70
|
+
onLoad: imageOnLoad,
|
|
71
|
+
onError: onError,
|
|
72
|
+
...imgProps
|
|
73
|
+
}) : /*#__PURE__*/jsx("img", {
|
|
74
|
+
ref: img => imgRef.current = img,
|
|
75
|
+
className: imgCls,
|
|
76
|
+
src: src,
|
|
77
|
+
onLoad: imageOnLoad,
|
|
78
|
+
onError: onError,
|
|
79
|
+
...imgProps
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var index = createForwardRefComponent(Image);
|
|
109
84
|
|
|
110
|
-
export {
|
|
85
|
+
export { index as default };
|
|
111
86
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.css'\n\nimport classNames from 'classnames'\nimport 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\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.css'\n\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent } from '../../utils'\nimport { useCallback, useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n src: string\n mode: string\n onError: () => void\n onLoad: (e) => void\n lazyLoad?: boolean\n imgProps?: Record<string, any>\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n}\n\nfunction Image (props: IProps) {\n const imgRef = useRef<HTMLImageElement | null>(null)\n const observer = useRef<Partial<IntersectionObserver>>({})\n const [, setIsLoaded] = useState(false)\n const {\n className,\n style = {},\n src,\n mode,\n onError,\n lazyLoad,\n imgProps,\n forwardedRef,\n ...reset\n } = props\n const cls = classNames(\n 'taro-img',\n {\n 'taro-img__widthfix': mode === 'widthFix'\n },\n className\n )\n const imgCls = classNames(\n 'taro-img__mode-' +\n (mode || 'scaleToFill').toLowerCase().replace(/\\s/g, '')\n )\n\n const imageOnLoad = useCallback((e) => {\n const { onLoad } = props\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n width: e.target.width,\n height: e.target.height\n }\n })\n\n onLoad && onLoad(e)\n }, [props])\n\n useEffect(() => {\n if (lazyLoad) {\n observer.current = new IntersectionObserver(\n entries => {\n // 异步 api 关系\n if (entries[entries.length - 1].isIntersecting) {\n setIsLoaded(true)\n // findDOMNode(this).children[0].src = src\n imgRef.current!.src = src\n }\n },\n {\n rootMargin: '300px 0px'\n }\n )\n observer.current.observe?.(imgRef.current!)\n }\n\n return () => {\n observer.current?.disconnect?.()\n }\n }, [lazyLoad, src])\n\n return (\n <div className={cls} style={style} ref={forwardedRef} {...reset}>\n {lazyLoad ? (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n data-src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n ) : (\n <img\n ref={img => (imgRef.current = img)}\n className={imgCls}\n src={src}\n onLoad={imageOnLoad}\n onError={onError}\n {...imgProps}\n />\n )}\n </div>\n )\n}\n\nexport default createForwardRefComponent(Image)\n"],"names":["Image","props","imgRef","useRef","observer","setIsLoaded","useState","className","style","src","mode","onError","lazyLoad","imgProps","forwardedRef","reset","__rest","cls","classNames","imgCls","toLowerCase","replace","imageOnLoad","useCallback","e","onLoad","Object","defineProperty","enumerable","writable","value","width","target","height","useEffect","current","IntersectionObserver","entries","length","isIntersecting","rootMargin","_b","_a","observe","call","disconnect","_jsx","ref","children","img","createForwardRefComponent"],"mappings":";;;;;;;AAmBA,SAASA,K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A,EAC5DpC,QAAQ,gBACPkC,GAAA,CAAA,KAAA,EAAA;AACEC,MAAAA,GAAG,EAAEE,GAAG,IAAK/C,MAAM,CAACiC,OAAO,GAAGc,GAAK;AACnC1C,MAAAA,SAAS,EAAEY,MAAO;AAClB,MAAA,UAAA,EAAUV,GAAI;AACdgB,MAAAA,MAAM,EAAEH,WAAY;AACpBX,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE,QAAAA;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,QAAAA;KACJ,CAAA;AACH,GACE,CAAC,CAAA;AAEV,CAAA;AAEA,YAAeqC,yBAAyB,CAAClD,KAAK,CAAC;;;;"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
var undefined$1 = undefined;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var stylesheet="img[src=\"\"]{opacity:0}.taro-img{display:inline-block;font-size:0;height:240px;overflow:hidden;position:relative;width:320px}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-aspectfit,.taro-img__mode-scaletofill{height:100%;object-fit:contain;width:100%}.taro-img__mode-aspectfill{height:100%;object-fit:cover;width:100%}.taro-img__mode-top,.taro-img__mode-widthfix{width:100%}.taro-img__mode-bottom{bottom:0;position:absolute;width:100%}.taro-img__mode-left{height:100%}.taro-img__mode-right{height:100%}.taro-img__mode-right,.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{bottom:0;position:absolute}.taro-img__mode-bottomright{bottom:0;position:absolute;right:0}";
|
|
5
|
-
styleInject(css_248z,{"insertAt":"top"});
|
|
6
|
-
|
|
7
|
-
export { css_248z as default, stylesheet };
|
|
3
|
+
export { undefined$1 as default };
|
|
8
4
|
//# sourceMappingURL=index.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|