@tarojs/components-react 4.0.0-beta.6 → 4.0.0-beta.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/button/index.js +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 +71 -100
- 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 +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 +188 -209
- 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 +133 -165
- 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 +234 -266
- 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 +17 -30
- 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 +67 -95
- package/dist/components/view/index.js.map +1 -1
- package/dist/components/view/style/index.css.js +2 -6
- package/dist/components/view/style/index.css.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/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 +16 -4
- 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
|
@@ -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,EAA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EO,GAAI;AACfN,IAAAA,KAAK,EAAEA,KAAM;AACbC,IAAAA,OAAO,EAAEA,OAAQ;AACjBX,IAAAA,QAAQ,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,111 +1,82 @@
|
|
|
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 { useRef, useState, useCallback, useEffect } from '../../utils/hooks.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
6
|
|
|
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
|
-
_this2.imgRef.src = _this2.props.src;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
rootMargin: '300px 0px'
|
|
44
|
-
});
|
|
45
|
-
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
|
|
46
35
|
}
|
|
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
|
|
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;
|
|
63
48
|
}
|
|
49
|
+
}, {
|
|
50
|
+
rootMargin: '300px 0px'
|
|
64
51
|
});
|
|
65
|
-
|
|
52
|
+
(_b = (_a = observer.current).observe) === null || _b === void 0 ? void 0 : _b.call(_a, imgRef.current);
|
|
66
53
|
}
|
|
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
|
-
"data-src": src,
|
|
94
|
-
onLoad: this.imageOnLoad,
|
|
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);
|
|
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
|
+
}
|
|
109
80
|
|
|
110
81
|
export { Image as default };
|
|
111
82
|
//# 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 { 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,C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H,WAAY;AACpBV,MAAAA,OAAO,EAAEA,OAAQ;MAAA,GACbE,QAAAA;KACJ,CAAA;AACH,GACE,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -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":";;;;"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import './style/index.scss.js';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { omit } from '../../utils/index.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function getTrueType(type, confirmType, password) {
|
|
8
|
+
if (confirmType === 'search') type = 'search';
|
|
9
|
+
if (password) type = 'password';
|
|
10
|
+
if (typeof type === 'undefined') {
|
|
11
|
+
return 'text';
|
|
12
|
+
}
|
|
13
|
+
if (!type) {
|
|
14
|
+
throw new Error('unexpected type');
|
|
15
|
+
}
|
|
16
|
+
if (type === 'digit') type = 'number';
|
|
17
|
+
return type;
|
|
18
|
+
}
|
|
19
|
+
function fixControlledValue(value) {
|
|
20
|
+
return value !== null && value !== void 0 ? value : '';
|
|
21
|
+
}
|
|
22
|
+
class Input extends React__default.Component {
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props);
|
|
25
|
+
this.handleBeforeInput = e => {
|
|
26
|
+
if (!e.data) return;
|
|
27
|
+
const isNumber = e.data && /[0-9]/.test(e.data);
|
|
28
|
+
if (this.props.type === 'number' && !isNumber) {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
}
|
|
31
|
+
if (this.props.type === 'digit' && !isNumber) {
|
|
32
|
+
if (e.data !== '.' || e.data === '.' && e.target.value.indexOf('.') > -1) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
this.handleInput = this.handleInput.bind(this);
|
|
38
|
+
this.handlePaste = this.handlePaste.bind(this);
|
|
39
|
+
this.handleFocus = this.handleFocus.bind(this);
|
|
40
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
41
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
42
|
+
this.handleComposition = this.handleComposition.bind(this);
|
|
43
|
+
this.handleBeforeInput = this.handleBeforeInput.bind(this);
|
|
44
|
+
this.isOnComposition = false;
|
|
45
|
+
this.onInputExcuted = false;
|
|
46
|
+
}
|
|
47
|
+
componentDidMount() {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
// 修复无法选择文件
|
|
50
|
+
if (this.props.type === 'file') {
|
|
51
|
+
(_a = this.inputRef) === null || _a === void 0 ? void 0 : _a.addEventListener('change', this.handleInput);
|
|
52
|
+
} else {
|
|
53
|
+
(_b = this.inputRef) === null || _b === void 0 ? void 0 : _b.addEventListener('textInput', this.handleBeforeInput);
|
|
54
|
+
}
|
|
55
|
+
// 处理初始化是否 focus
|
|
56
|
+
if (this.props.focus && this.inputRef) this.inputRef.focus();
|
|
57
|
+
}
|
|
58
|
+
componentWillUnmount() {
|
|
59
|
+
var _a;
|
|
60
|
+
// 修复无法选择文件
|
|
61
|
+
if (this.props.type === 'file') {
|
|
62
|
+
this.inputRef.removeEventListener('change', this.handleInput);
|
|
63
|
+
} else {
|
|
64
|
+
(_a = this.inputRef) === null || _a === void 0 ? void 0 : _a.removeEventListener('textInput', this.handleBeforeInput);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
68
|
+
if (!this.props.focus && nextProps.focus && this.inputRef) this.inputRef.focus();
|
|
69
|
+
}
|
|
70
|
+
handleInput(e) {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
const {
|
|
73
|
+
type,
|
|
74
|
+
maxlength = 140,
|
|
75
|
+
confirmType = 'done',
|
|
76
|
+
password = false,
|
|
77
|
+
onInput
|
|
78
|
+
} = this.props;
|
|
79
|
+
if (!this.isOnComposition && !this.onInputExcuted) {
|
|
80
|
+
let {
|
|
81
|
+
value
|
|
82
|
+
} = e.target;
|
|
83
|
+
const inputType = getTrueType(type, confirmType, password);
|
|
84
|
+
this.onInputExcuted = true;
|
|
85
|
+
/* 修复 number 类型 maxLength 无效 */
|
|
86
|
+
if (inputType === 'number' && value && maxlength <= value.length) {
|
|
87
|
+
value = value.substring(0, maxlength);
|
|
88
|
+
e.target.value = value;
|
|
89
|
+
}
|
|
90
|
+
Object.defineProperty(e, 'detail', {
|
|
91
|
+
value: {
|
|
92
|
+
value,
|
|
93
|
+
cursor: value.length
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
// // 修复 IOS 光标跳转问题
|
|
97
|
+
// if (!(['number', 'file'].indexOf(inputType) >= 0)) {
|
|
98
|
+
// const pos = e.target.selectionEnd
|
|
99
|
+
// setTimeout(
|
|
100
|
+
// () => {
|
|
101
|
+
// e.target.selectionStart = pos
|
|
102
|
+
// e.target.selectionEnd = pos
|
|
103
|
+
// }
|
|
104
|
+
// )
|
|
105
|
+
// }
|
|
106
|
+
typeof onInput === 'function' && onInput(e);
|
|
107
|
+
this.onInputExcuted = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
handlePaste(e) {
|
|
111
|
+
e.stopPropagation();
|
|
112
|
+
const {
|
|
113
|
+
onPaste
|
|
114
|
+
} = this.props;
|
|
115
|
+
this.onInputExcuted = false;
|
|
116
|
+
Object.defineProperty(e, 'detail', {
|
|
117
|
+
value: {
|
|
118
|
+
value: e.target.value
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
typeof onPaste === 'function' && onPaste(e);
|
|
122
|
+
}
|
|
123
|
+
handleFocus(e) {
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
const {
|
|
126
|
+
onFocus
|
|
127
|
+
} = this.props;
|
|
128
|
+
this.onInputExcuted = false;
|
|
129
|
+
Object.defineProperty(e, 'detail', {
|
|
130
|
+
value: {
|
|
131
|
+
value: e.target.value
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
onFocus && onFocus(e);
|
|
135
|
+
}
|
|
136
|
+
handleBlur(e) {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
const {
|
|
139
|
+
onBlur
|
|
140
|
+
} = this.props;
|
|
141
|
+
Object.defineProperty(e, 'detail', {
|
|
142
|
+
value: {
|
|
143
|
+
value: e.target.value
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
onBlur && onBlur(e);
|
|
147
|
+
}
|
|
148
|
+
handleKeyDown(e) {
|
|
149
|
+
e.stopPropagation();
|
|
150
|
+
const {
|
|
151
|
+
onConfirm,
|
|
152
|
+
onKeyDown
|
|
153
|
+
} = this.props;
|
|
154
|
+
const {
|
|
155
|
+
value
|
|
156
|
+
} = e.target;
|
|
157
|
+
const keyCode = e.keyCode || e.code;
|
|
158
|
+
this.onInputExcuted = false;
|
|
159
|
+
if (typeof onKeyDown === 'function') {
|
|
160
|
+
Object.defineProperty(e, 'detail', {
|
|
161
|
+
value: {
|
|
162
|
+
value,
|
|
163
|
+
cursor: value.length,
|
|
164
|
+
keyCode
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
onKeyDown(e);
|
|
168
|
+
}
|
|
169
|
+
if (e.keyCode === 13 && typeof onConfirm === 'function') {
|
|
170
|
+
Object.defineProperty(e, 'detail', {
|
|
171
|
+
value: {
|
|
172
|
+
value
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
onConfirm(e);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
handleComposition(e) {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
if (!(e.target instanceof HTMLInputElement)) return;
|
|
181
|
+
if (e.type === 'compositionend') {
|
|
182
|
+
this.isOnComposition = false;
|
|
183
|
+
this.handleInput(e);
|
|
184
|
+
} else {
|
|
185
|
+
this.isOnComposition = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
render() {
|
|
189
|
+
const {
|
|
190
|
+
className = '',
|
|
191
|
+
placeholder,
|
|
192
|
+
type,
|
|
193
|
+
password = false,
|
|
194
|
+
disabled = false,
|
|
195
|
+
maxlength = 140,
|
|
196
|
+
confirmType = 'done',
|
|
197
|
+
name,
|
|
198
|
+
value
|
|
199
|
+
} = this.props;
|
|
200
|
+
const cls = classNames('taro-input-core', 'weui-input', className);
|
|
201
|
+
const otherProps = omit(this.props, ['className', 'placeholder', 'disabled', 'password', 'type', 'maxlength', 'confirmType', 'focus', 'name']);
|
|
202
|
+
if ('value' in this.props) {
|
|
203
|
+
otherProps.value = fixControlledValue(value);
|
|
204
|
+
}
|
|
205
|
+
return /*#__PURE__*/jsx("input", {
|
|
206
|
+
ref: input => {
|
|
207
|
+
this.inputRef = input;
|
|
208
|
+
},
|
|
209
|
+
...otherProps,
|
|
210
|
+
className: cls,
|
|
211
|
+
type: getTrueType(type, confirmType, password),
|
|
212
|
+
placeholder: placeholder,
|
|
213
|
+
disabled: disabled,
|
|
214
|
+
maxLength: maxlength,
|
|
215
|
+
name: name,
|
|
216
|
+
onInput: this.handleInput,
|
|
217
|
+
onPaste: this.handlePaste,
|
|
218
|
+
onFocus: this.handleFocus,
|
|
219
|
+
onBlur: this.handleBlur,
|
|
220
|
+
onKeyDown: this.handleKeyDown,
|
|
221
|
+
onCompositionStart: this.handleComposition,
|
|
222
|
+
onCompositionEnd: this.handleComposition,
|
|
223
|
+
onBeforeInput: this.handleBeforeInput
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export { Input as default };
|
|
229
|
+
//# sourceMappingURL=index.js.map
|