@tarojs/components-react 4.1.4-beta.13 → 4.1.4-beta.14

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.
Files changed (69) hide show
  1. package/dist/components/button/index.js +87 -0
  2. package/dist/components/button/index.js.map +1 -0
  3. package/dist/components/button/style/index.scss.js +4 -0
  4. package/dist/components/button/style/index.scss.js.map +1 -0
  5. package/dist/components/icon/index.js +36 -0
  6. package/dist/components/icon/index.js.map +1 -0
  7. package/dist/components/icon/style/index.scss.js +4 -0
  8. package/dist/components/icon/style/index.scss.js.map +1 -0
  9. package/dist/components/image/index.js +86 -0
  10. package/dist/components/image/index.js.map +1 -0
  11. package/dist/components/image/style/index.css.js +4 -0
  12. package/dist/components/image/style/index.css.js.map +1 -0
  13. package/dist/components/input/index.js +233 -0
  14. package/dist/components/input/index.js.map +1 -0
  15. package/dist/components/input/style/index.scss.js +4 -0
  16. package/dist/components/input/style/index.scss.js.map +1 -0
  17. package/dist/components/picker/index.js +13 -7
  18. package/dist/components/picker/index.js.map +1 -1
  19. package/dist/components/pull-down-refresh/index.js +320 -0
  20. package/dist/components/pull-down-refresh/index.js.map +1 -0
  21. package/dist/components/pull-down-refresh/style/index.css.js +4 -0
  22. package/dist/components/pull-down-refresh/style/index.css.js.map +1 -0
  23. package/dist/components/scroll-view/index.js +184 -0
  24. package/dist/components/scroll-view/index.js.map +1 -0
  25. package/dist/components/scroll-view/style/index.css.js +4 -0
  26. package/dist/components/scroll-view/style/index.css.js.map +1 -0
  27. package/dist/components/swiper/index.js +461 -0
  28. package/dist/components/swiper/index.js.map +1 -0
  29. package/dist/components/swiper/style/index.css.js +4 -0
  30. package/dist/components/swiper/style/index.css.js.map +1 -0
  31. package/dist/components/text/index.js +28 -0
  32. package/dist/components/text/index.js.map +1 -0
  33. package/dist/components/text/style/index.css.js +4 -0
  34. package/dist/components/text/style/index.css.js.map +1 -0
  35. package/dist/components/view/index.js +80 -0
  36. package/dist/components/view/index.js.map +1 -0
  37. package/dist/index.css +1 -1
  38. package/dist/index.js +12 -79
  39. package/dist/index.js.map +1 -1
  40. package/dist/solid/components/button/index.js +95 -0
  41. package/dist/solid/components/button/index.js.map +1 -0
  42. package/dist/solid/components/button/style/index.scss.js +4 -0
  43. package/dist/solid/components/button/style/index.scss.js.map +1 -0
  44. package/dist/solid/components/icon/index.js +39 -0
  45. package/dist/solid/components/icon/index.js.map +1 -0
  46. package/dist/solid/components/icon/style/index.scss.js +4 -0
  47. package/dist/solid/components/icon/style/index.scss.js.map +1 -0
  48. package/dist/solid/components/image/index.js +94 -0
  49. package/dist/solid/components/image/index.js.map +1 -0
  50. package/dist/solid/components/image/style/index.css.js +4 -0
  51. package/dist/solid/components/image/style/index.css.js.map +1 -0
  52. package/dist/solid/components/picker/index.js +15 -7
  53. package/dist/solid/components/picker/index.js.map +1 -1
  54. package/dist/solid/components/scroll-view/index.js +188 -0
  55. package/dist/solid/components/scroll-view/index.js.map +1 -0
  56. package/dist/solid/components/scroll-view/style/index.css.js +4 -0
  57. package/dist/solid/components/scroll-view/style/index.css.js.map +1 -0
  58. package/dist/solid/components/text/index.js +32 -0
  59. package/dist/solid/components/text/index.js.map +1 -0
  60. package/dist/solid/components/text/style/index.css.js +4 -0
  61. package/dist/solid/components/text/style/index.css.js.map +1 -0
  62. package/dist/solid/components/view/index.js +88 -0
  63. package/dist/solid/components/view/index.js.map +1 -0
  64. package/dist/solid/index.css +1 -1
  65. package/dist/solid/index.js +9 -79
  66. package/dist/solid/index.js.map +1 -1
  67. package/dist/styles/picker-styles.css +1 -1
  68. package/dist/styles/picker-styles.css.map +1 -1
  69. package/package.json +6 -6
@@ -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;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;MAC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AAA,SAAS,EAAEO,GAAI;AACfN,IAAAA,KAAK,EAAEA,KAAM;AACbC,IAAAA,OAAO,EAAEA,OAAQ;AACjBZ,IAAAA,QAAQ,EAAEA,QAAS;AACnBG,IAAAA,YAAY,EAAER,aAAc;AAC5BW,IAAAA,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;KAAc,CAAG,EAC3CD,QAAQ;AAAA,GACH,CAAC;AAEb;AAEA,YAAee,yBAAyB,CAAC1C,MAAM,CAAC;;;;"}
@@ -0,0 +1,4 @@
1
+ var undefined$1 = undefined;
2
+
3
+ export { undefined$1 as default };
4
+ //# sourceMappingURL=index.scss.js.map
@@ -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;AAAc,GAAA,GAAGL,KAAK;EACtE,IAAIC,IAAI,EAAEA,IAAI,GAAGA,IAAI,CAACK,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EACxC,MAAMC,GAAG,GAAGC,UAAU,CACpB;IACE,CAAC,CAAA,UAAA,EAAaP,IAAI,CAAA,CAAE,GAAG;GACxB,EACDC,SAAS,CACV;AACD,EAAA,MAAMO,KAAK,GAAG;IAAE,WAAW,EAAEN,IAAI,GAAG,IAAI;AAAEC,IAAAA,KAAK,EAAEA;GAAO;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;KAAM;AAAG;AAElH,CAAC;AACD,YAAeI,yBAAyB,CAACd,IAAI,CAAC;;;;"}
@@ -0,0 +1,4 @@
1
+ var undefined$1 = undefined;
2
+
3
+ export { undefined$1 as default };
4
+ //# sourceMappingURL=index.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,86 @@
1
+ import { __rest } from 'tslib';
2
+ import './style/index.css.js';
3
+ import classNames from 'classnames';
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';
7
+
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
37
+ }
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;
50
+ }
51
+ }, {
52
+ rootMargin: '300px 0px'
53
+ });
54
+ (_b = (_a = observer.current).observe) === null || _b === void 0 ? void 0 : _b.call(_a, imgRef.current);
55
+ }
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);
84
+
85
+ export { index as default };
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/image/index.tsx"],"sourcesContent":["import './style/index.css'\n\nimport classNames from 'classnames'\n\nimport { 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,KAAKA,CAAEC,KAAa,EAAA;AAC3B,EAAA,MAAMC,MAAM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,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;;;;"}
@@ -0,0 +1,4 @@
1
+ var undefined$1 = undefined;
2
+
3
+ export { undefined$1 as default };
4
+ //# sourceMappingURL=index.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,233 @@
1
+ import './style/index.scss.js';
2
+ import classNames from 'classnames';
3
+ import React__default from 'react';
4
+ import { omit, createForwardRefComponent } 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, ['forwardedRef', '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
+ if (this.props.forwardedRef) {
208
+ this.props.forwardedRef.current = input;
209
+ }
210
+ this.inputRef = input;
211
+ },
212
+ ...otherProps,
213
+ className: cls,
214
+ type: getTrueType(type, confirmType, password),
215
+ placeholder: placeholder,
216
+ disabled: disabled,
217
+ maxLength: maxlength,
218
+ name: name,
219
+ onInput: this.handleInput,
220
+ onPaste: this.handlePaste,
221
+ onFocus: this.handleFocus,
222
+ onBlur: this.handleBlur,
223
+ onKeyDown: this.handleKeyDown,
224
+ onCompositionStart: this.handleComposition,
225
+ onCompositionEnd: this.handleComposition,
226
+ onBeforeInput: this.handleBeforeInput
227
+ });
228
+ }
229
+ }
230
+ var index = createForwardRefComponent(Input);
231
+
232
+ export { index as default };
233
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/input/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport classNames from 'classnames'\nimport React from 'react'\n\nimport { createForwardRefComponent, omit } from '../../utils'\n\nfunction getTrueType (type: string | undefined, confirmType: string, password: boolean) {\n if (confirmType === 'search') type = 'search'\n if (password) type = 'password'\n if (typeof type === 'undefined') {\n return 'text'\n }\n if (!type) {\n throw new Error('unexpected type')\n }\n if (type === 'digit') type = 'number'\n\n return type\n}\n\nfunction fixControlledValue (value) {\n return value ?? ''\n}\n\ninterface IProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {\n password?: boolean\n disabled?: boolean\n maxlength?: number\n placeholder?: string\n value?: string\n focus?: boolean\n confirmType?: string\n name?: string\n type?: string\n onConfirm?: (e) => void\n forwardedRef?: React.MutableRefObject<HTMLInputElement>\n}\n\nclass Input extends React.Component<IProps, null> {\n constructor (props) {\n super(props)\n this.handleInput = this.handleInput.bind(this)\n this.handlePaste = this.handlePaste.bind(this)\n this.handleFocus = this.handleFocus.bind(this)\n this.handleBlur = this.handleBlur.bind(this)\n this.handleKeyDown = this.handleKeyDown.bind(this)\n this.handleComposition = this.handleComposition.bind(this)\n this.handleBeforeInput = this.handleBeforeInput.bind(this)\n this.isOnComposition = false\n this.onInputExcuted = false\n }\n\n inputRef: HTMLInputElement\n isOnComposition: boolean\n onInputExcuted: boolean\n\n componentDidMount () {\n // 修复无法选择文件\n if (this.props.type === 'file') {\n this.inputRef?.addEventListener('change', this.handleInput)\n } else {\n this.inputRef?.addEventListener('textInput', this.handleBeforeInput)\n }\n\n // 处理初始化是否 focus\n if (this.props.focus && this.inputRef) this.inputRef.focus()\n }\n\n componentWillUnmount () {\n // 修复无法选择文件\n if (this.props.type === 'file') {\n this.inputRef.removeEventListener('change', this.handleInput)\n } else {\n this.inputRef?.removeEventListener('textInput', this.handleBeforeInput)\n }\n }\n\n UNSAFE_componentWillReceiveProps (nextProps: Readonly<IProps>) {\n if (!this.props.focus && nextProps.focus && this.inputRef) this.inputRef.focus()\n }\n\n handleInput (e) {\n e.stopPropagation()\n const {\n type,\n maxlength = 140,\n confirmType = 'done',\n password = false,\n onInput\n } = this.props\n\n if (!this.isOnComposition && !this.onInputExcuted) {\n let { value } = e.target\n const inputType = getTrueType(type, confirmType, password)\n this.onInputExcuted = true\n /* 修复 number 类型 maxLength 无效 */\n if (inputType === 'number' && value && maxlength <= value.length) {\n value = value.substring(0, maxlength)\n e.target.value = value\n }\n\n Object.defineProperty(e, 'detail', {\n value: { value, cursor: value.length }\n })\n // // 修复 IOS 光标跳转问题\n // if (!(['number', 'file'].indexOf(inputType) >= 0)) {\n // const pos = e.target.selectionEnd\n // setTimeout(\n // () => {\n // e.target.selectionStart = pos\n // e.target.selectionEnd = pos\n // }\n // )\n // }\n\n typeof onInput === 'function' && onInput(e)\n this.onInputExcuted = false\n }\n }\n\n handlePaste (e) {\n e.stopPropagation()\n const { onPaste } = this.props\n this.onInputExcuted = false\n Object.defineProperty(e, 'detail', {\n value: {\n value: e.target.value\n }\n })\n typeof onPaste === 'function' && onPaste(e)\n }\n\n handleFocus (e) {\n e.stopPropagation()\n const { onFocus } = this.props\n this.onInputExcuted = false\n Object.defineProperty(e, 'detail', {\n value: {\n value: e.target.value\n }\n })\n onFocus && onFocus(e)\n }\n\n handleBlur (e) {\n e.stopPropagation()\n const { onBlur } = this.props\n Object.defineProperty(e, 'detail', {\n value: {\n value: e.target.value\n }\n })\n onBlur && onBlur(e)\n }\n\n handleKeyDown (e) {\n e.stopPropagation()\n const { onConfirm, onKeyDown } = this.props\n const { value } = e.target\n const keyCode = e.keyCode || e.code\n this.onInputExcuted = false\n\n if (typeof onKeyDown === 'function') {\n Object.defineProperty(e, 'detail', {\n value: {\n value,\n cursor: value.length,\n keyCode\n }\n })\n onKeyDown(e)\n }\n\n if (e.keyCode === 13 && typeof onConfirm === 'function') {\n Object.defineProperty(e, 'detail', {\n value: {\n value\n }\n })\n onConfirm(e)\n }\n }\n\n handleComposition (e) {\n e.stopPropagation()\n if (!(e.target instanceof HTMLInputElement)) return\n\n if (e.type === 'compositionend') {\n this.isOnComposition = false\n this.handleInput(e)\n } else {\n this.isOnComposition = true\n }\n }\n\n handleBeforeInput = (e) => {\n if (!e.data) return\n const isNumber = e.data && /[0-9]/.test(e.data)\n if (this.props.type === 'number' && !isNumber) {\n e.preventDefault()\n }\n if (this.props.type === 'digit' && !isNumber) {\n if (e.data !== '.' || (e.data === '.' && e.target.value.indexOf('.') > -1)) {\n e.preventDefault()\n }\n }\n }\n\n render () {\n const {\n className = '',\n placeholder,\n type,\n password = false,\n disabled = false,\n maxlength = 140,\n confirmType = 'done',\n name,\n value\n } = this.props\n const cls = classNames('taro-input-core', 'weui-input', className)\n\n const otherProps = omit(this.props, [\n 'forwardedRef',\n 'className',\n 'placeholder',\n 'disabled',\n 'password',\n 'type',\n 'maxlength',\n 'confirmType',\n 'focus',\n 'name'\n ])\n\n if ('value' in this.props) {\n otherProps.value = fixControlledValue(value)\n }\n\n return (\n <input\n ref={(input: HTMLInputElement) => {\n if (this.props.forwardedRef) {\n this.props.forwardedRef.current = input\n }\n this.inputRef = input\n }}\n {...otherProps}\n className={cls}\n type={getTrueType(type, confirmType, password)}\n placeholder={placeholder}\n disabled={disabled}\n maxLength={maxlength}\n name={name}\n onInput={this.handleInput}\n onPaste={this.handlePaste}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n onCompositionStart={this.handleComposition}\n onCompositionEnd={this.handleComposition}\n onBeforeInput={this.handleBeforeInput}\n />\n )\n }\n}\n\nexport default createForwardRefComponent(Input)\n"],"names":["getTrueType","type","confirmType","password","Error","fixControlledValue","value","Input","React","Component","constructor","props","handleBeforeInput","e","data","isNumber","test","preventDefault","target","indexOf","handleInput","bind","handlePaste","handleFocus","handleBlur","handleKeyDown","handleComposition","isOnComposition","onInputExcuted","componentDidMount","_a","inputRef","addEventListener","_b","focus","componentWillUnmount","removeEventListener","UNSAFE_componentWillReceiveProps","nextProps","stopPropagation","maxlength","onInput","inputType","length","substring","Object","defineProperty","cursor","onPaste","onFocus","onBlur","onConfirm","onKeyDown","keyCode","code","HTMLInputElement","render","className","placeholder","disabled","name","cls","classNames","otherProps","omit","_jsx","ref","input","forwardedR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C/B,QAAA,IAAI,IAAI,CAACxD,KAAK,CAACyD,YAAY,EAAE;AAC3B,UAAA,IAAI,CAACzD,KAAK,CAACyD,YAAY,CAACC,OAAO,GAAGF,KAAK;AACzC;QACA,IAAI,CAACpC,QAAQ,GAAGoC,KAAK;OACrB;AAAA,MAAA,GACEJ,UAAU;AACdN,MAAAA,SAAS,EAAEI,GAAI;MACf5D,IAAI,EAAED,WAAW,CAACC,IAAI,EAAEC,WAAW,EAAEC,QAAQ,CAAE;AAC/CuD,MAAAA,WAAW,EAAEA,WAAY;AACzBC,MAAAA,QAAQ,EAAEA,QAAS;AACnBW,MAAAA,SAAS,EAAE9B,SAAU;AACrBoB,MAAAA,IAAI,EAAEA,IAAK;MACXnB,OAAO,EAAE,IAAI,CAACrB,WAAY;MAC1B4B,OAAO,EAAE,IAAI,CAAC1B,WAAY;MAC1B2B,OAAO,EAAE,IAAI,CAAC1B,WAAY;MAC1B2B,MAAM,EAAE,IAAI,CAAC1B,UAAW;MACxB4B,SAAS,EAAE,IAAI,CAAC3B,aAAc;MAC9B8C,kBAAkB,EAAE,IAAI,CAAC7C,iBAAkB;MAC3C8C,gBAAgB,EAAE,IAAI,CAAC9C,iBAAkB;MACzC+C,aAAa,EAAE,IAAI,CAAC7D;AAAkB,KACtC,CAAA;AAEN;AACD;AAED,YAAe8D,yBAAyB,CAACnE,KAAK,CAAC;;;;"}
@@ -0,0 +1,4 @@
1
+ var undefined$1 = undefined;
2
+
3
+ export { undefined$1 as default };
4
+ //# sourceMappingURL=index.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -94,7 +94,7 @@ function getRegionColumnsCount(level) {
94
94
  // 默认显示省市区/县三列
95
95
  }
96
96
  }
97
- function Picker(props) {
97
+ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
98
98
  var _a, _b;
99
99
  const {
100
100
  mode = 'selector',
@@ -114,10 +114,9 @@ function Picker(props) {
114
114
  onCancel,
115
115
  children,
116
116
  style,
117
- forwardedRef,
118
117
  formType
119
118
  } = props,
120
- restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "onChange", "onColumnChange", "onCancel", "children", "style", "forwardedRef", "formType"]);
119
+ restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "onChange", "onColumnChange", "onCancel", "children", "style", "formType"]);
121
120
  const indexRef = React.useRef([]);
122
121
  const pickerDateRef = React.useRef();
123
122
  const [state, setState] = React.useState({
@@ -688,13 +687,19 @@ function Picker(props) {
688
687
  const clsSlider = classNames('taro-picker', 'taro-picker__animate-slide-up', {
689
688
  'taro-picker__animate-slide-down': state.fadeOut
690
689
  });
690
+ // 暴露方法给外部
691
+ React.useImperativeHandle(ref, () => ({
692
+ showPicker,
693
+ hidePicker
694
+ }));
691
695
  return /*#__PURE__*/jsxs(View, {
692
- ref: forwardedRef,
696
+ ref: ref // 直接绑定 ref
697
+ ,
693
698
  style: style,
694
699
  ...(formType ? {
695
700
  'data-form-type': formType
696
701
  } : {}),
697
- ...omit(restProps, ['mode', 'disabled', 'range', 'rangeKey', 'value', 'start', 'end', 'fields', 'name', 'textProps', 'onChange', 'onColumnChange', 'onCancel', 'children', 'style', 'forwardedRef', 'formType']),
702
+ ...omit(restProps, ['mode', 'disabled', 'range', 'rangeKey', 'value', 'start', 'end', 'fields', 'name', 'textProps', 'onChange', 'onColumnChange', 'onCancel', 'children', 'style', 'formType']),
698
703
  children: [/*#__PURE__*/jsx(View, {
699
704
  onClick: showPicker,
700
705
  children: children
@@ -726,7 +731,8 @@ function Picker(props) {
726
731
  })]
727
732
  })]
728
733
  });
729
- }
734
+ });
735
+ Picker.displayName = 'Picker';
730
736
 
731
- export { Picker, Picker as default };
737
+ export { Picker as default };
732
738
  //# sourceMappingURL=index.js.map