@tarojs/components-react 4.0.1 → 4.0.3-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 +78 -103
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/icon/index.js +26 -17
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/image/index.js +76 -101
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/input/index.js +183 -206
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/pull-down-refresh/index.js +195 -211
- package/dist/components/pull-down-refresh/index.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/swiper/index.js +248 -268
- package/dist/components/swiper/index.js.map +1 -1
- package/dist/components/text/index.js +22 -31
- package/dist/components/text/index.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 -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/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 +26 -15
- package/dist/utils/index.js.map +1 -1
- package/package.json +19 -18
- package/types/index.d.ts +17 -0
- /package/dist/{components/view → solid/components/image}/style/index.css.js +0 -0
- /package/dist/{components/view → solid/components/image}/style/index.css.js.map +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.solid.js","sources":["../../../src/utils/hooks.solid.ts"],"sourcesContent":["import Solid from 'solid-js'\n\nimport type { TFunc } from '@tarojs/runtime/dist/runtime.esm'\n\nexport const useState = <T = any>(value: T, options?): [() => T, TFunc] => {\n const [state, setState] = Solid.createSignal(value, options)\n return [state, setState]\n}\n\nexport const useCallback = (callback, deps) => {\n const [_, setSignal] = Solid.createSignal(0) // eslint-disable-line @typescript-eslint/no-unused-vars\n\n Solid.createEffect(() => {\n deps.forEach(dep => typeof dep === 'function' ? dep() : dep)\n setSignal(s => s + 1)\n })\n\n return async (...args) => {\n Solid.createEffect(() => {\n const clean = callback(...args)\n return typeof clean === 'function' && Solid.onCleanup(clean)\n })\n }\n}\n\nexport const useEffect = (effect, deps) => {\n Solid.createEffect(() => {\n const cleanup = effect()\n deps.forEach(dep => dep)\n\n return () => {\n if (typeof cleanup === 'function') cleanup()\n }\n })\n}\n\nexport const useMemo = Solid.createMemo\n\nexport const useRef = <T = any>(init?: T) => {\n const [state] = Solid.createSignal(init)\n return {\n current: state()\n }\n}\n\nexport const createContext = Solid.createContext\nexport const useContext = Solid.useContext\nexport const memo = (component, _propsAreEqual) => component // eslint-disable-line @typescript-eslint/no-unused-vars\nexport const forwardRef = (component) => component\nexport const useImperativeHandle = (ref, createHandle, deps) => {\n Solid.createEffect(() => {\n deps.forEach(dep => dep)\n ref.current = createHandle()\n })\n}\n"],"names":["useState","value","options","state","setState","Solid","createSignal","useCallback","callback","deps","_","setSignal","createEffect","forEach","dep","s","_len","arguments","length","args","Array","_key","__awaiter","clean","onCleanup","useEffect","effect","cleanup","useMemo","createMemo","useRef","init","current","createContext","useContext","memo","component","_propsAreEqual","forwardRef","useImperativeHandle","ref","createHandle"],"mappings":";;;MAIaA,QAAQ,GAAGA,CAAUC,KAAQ,EAAEC,OAAQ,KAAsB;AACxE,EAAA,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,KAAK,CAACC,YAAY,CAACL,KAAK,EAAEC,OAAO,CAAC,CAAA;AAC5D,EAAA,OAAO,CAACC,KAAK,EAAEC,QAAQ,CAAC,CAAA;AAC1B,EAAC;MAEYG,WAAW,GAAGA,CAACC,QAAQ,EAAEC,IAAI,KAAI;AAC5C,EAAA,MAAM,CAACC,CAAC,EAAEC,SAAS,CAAC,GAAGN,KAAK,CAACC,YAAY,CAAC,CAAC,CAAC,CAAA;EAE5CD,KAAK,CAACO,YAAY,CAAC,MAAK;AACtBH,IAAAA,IAAI,CAACI,OAAO,CAACC,GAAG,IAAI,OAAOA,GAAG,KAAK,UAAU,GAAGA,GAAG,EAA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AM,CAAC5B,KAAK,CAAC,GAAGE,KAAK,CAACC,YAAY,CAACyB,IAAI,CAAC,CAAA;EACxC,OAAO;IACLC,OAAO,EAAE7B,KAAK,EAAE;GACjB,CAAA;AACH,EAAC;AAEY8B,MAAAA,aAAa,GAAG5B,KAAK,CAAC4B,cAAa;AACnCC,MAAAA,UAAU,GAAG7B,KAAK,CAAC6B,WAAU;AACnC,MAAMC,IAAI,GAAGA,CAACC,SAAS,EAAEC,cAAc,KAAKD,UAAS;AAC/CE,MAAAA,UAAU,GAAIF,SAAS,IAAKA,UAAS;AAC3C,MAAMG,mBAAmB,GAAGA,CAACC,GAAG,EAAEC,YAAY,EAAEhC,IAAI,KAAI;EAC7DJ,KAAK,CAACO,YAAY,CAAC,MAAK;AACtBH,IAAAA,IAAI,CAACI,OAAO,CAACC,GAAG,IAAIA,GAAG,CAAC,CAAA;AACxB0B,IAAAA,GAAG,CAACR,OAAO,GAAGS,YAAY,EAAE,CAAA;AAC9B,GAAC,CAAC,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createComponent, mergeProps } from 'solid-js/web';
|
|
2
|
+
import { forwardRef } from './hooks.solid.js';
|
|
3
|
+
|
|
4
|
+
function throttle(fn) {
|
|
5
|
+
let threshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
|
6
|
+
let scope = arguments.length > 2 ? arguments[2] : undefined;
|
|
7
|
+
let lastTime = 0;
|
|
8
|
+
let deferTimer;
|
|
9
|
+
return function () {
|
|
10
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11
|
+
args[_key] = arguments[_key];
|
|
12
|
+
}
|
|
13
|
+
const context = scope || this;
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
if (now - lastTime > threshold) {
|
|
16
|
+
fn.apply(this, args);
|
|
17
|
+
lastTime = now;
|
|
18
|
+
} else {
|
|
19
|
+
clearTimeout(deferTimer);
|
|
20
|
+
deferTimer = setTimeout(() => {
|
|
21
|
+
lastTime = now;
|
|
22
|
+
fn.apply(context, args);
|
|
23
|
+
}, threshold);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function debounce(fn) {
|
|
28
|
+
let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
|
29
|
+
let scope = arguments.length > 2 ? arguments[2] : undefined;
|
|
30
|
+
let timer;
|
|
31
|
+
return function () {
|
|
32
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
33
|
+
args[_key2] = arguments[_key2];
|
|
34
|
+
}
|
|
35
|
+
const context = scope || this;
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
timer = setTimeout(function () {
|
|
38
|
+
fn.apply(context, args);
|
|
39
|
+
}, ms);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function omit(obj, fields) {
|
|
43
|
+
const shallowCopy = Object.assign({}, obj);
|
|
44
|
+
for (let i = 0; i < fields.length; i += 1) {
|
|
45
|
+
const key = fields[i];
|
|
46
|
+
delete shallowCopy[key];
|
|
47
|
+
}
|
|
48
|
+
return shallowCopy;
|
|
49
|
+
}
|
|
50
|
+
const createForwardRefComponent = ReactComponent => {
|
|
51
|
+
const forwardRefComponent = (props, ref) => createComponent(ReactComponent, mergeProps(props, {
|
|
52
|
+
forwardedRef: ref
|
|
53
|
+
}));
|
|
54
|
+
return forwardRef(forwardRefComponent);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { createForwardRefComponent, debounce, omit, throttle };
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/index.tsx"],"sourcesContent":["/* eslint-disable react/react-in-jsx-scope */\nimport { forwardRef } from './hooks'\n\nexport function throttle (fn, threshold = 250, scope?) {\n let lastTime = 0\n let deferTimer: ReturnType<typeof setTimeout>\n return function (...args) {\n const context = scope || this\n const now = Date.now()\n if (now - lastTime > threshold) {\n fn.apply(this, args)\n lastTime = now\n } else {\n clearTimeout(deferTimer)\n deferTimer = setTimeout(() => {\n lastTime = now\n fn.apply(context, args)\n }, threshold)\n }\n }\n}\n\nexport function debounce (fn, ms = 250, scope?) {\n let timer: ReturnType<typeof setTimeout>\n\n return function (...args) {\n const context = scope || this\n clearTimeout(timer)\n timer = setTimeout(function () {\n fn.apply(context, args)\n }, ms)\n }\n}\n\nexport function omit (obj, fields) {\n const shallowCopy = Object.assign({}, obj)\n for (let i = 0; i < fields.length; i += 1) {\n const key = fields[i]\n delete shallowCopy[key]\n }\n return shallowCopy\n}\n\nexport const createForwardRefComponent = (ReactComponent: any) => {\n const forwardRefComponent = (\n props,\n ref\n ) => <ReactComponent {...props} forwardedRef={ref} />\n\n return forwardRef(forwardRefComponent)\n}\n\n"],"names":["throttle","fn","threshold","arguments","length","undefined","scope","lastTime","deferTimer","_len","args","Array","_key","context","now","Date","apply","clearTimeout","setTimeout","debounce","ms","timer","_len2","_key2","omit","obj","fields","shallowCopy","Object","assign","i","key","createForwardRefComponent","ReactComponent","forwardRefComponent","props","ref","_$createComponent","_$mergeProps","forwardedRef","forwardRef"],"mappings":";;;AAGM,SAAUA,QAAQA,CAAEC,EAAE,EAAyB;AAAA,EAAA,IAAvBC,SAAS,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,GAAG,CAAA;EAAA,IAAEG,KAAM,GAAAH,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA,CAAA;EACnD,IAAIE,QAAQ,GAAG,CAAC,CAAA;AAChB,EAAA,IAAIC,UAAyC,CAAA;AAC7C,EAAA,OAAO,YAAiB;AAAA,IAAA,KAAA,IAAAC,IAAA,GAAAN,SAAA,CAAAC,MAAA,EAAJM,IAAI,G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|
|
5
|
+
const useEffect = React.useEffect;
|
|
6
|
+
const useMemo = React.useMemo;
|
|
7
|
+
const useRef = React.useRef;
|
|
8
|
+
const createContext = React.createContext;
|
|
9
|
+
const useContext = React.useContext;
|
|
10
|
+
const memo = React.memo;
|
|
11
|
+
const forwardRef = React.forwardRef;
|
|
12
|
+
const useImperativeHandle = React.useImperativeHandle;
|
|
13
|
+
|
|
14
|
+
export { createContext, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState };
|
|
15
|
+
//# sourceMappingURL=hooks.react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.react.js","sources":["../../src/utils/hooks.react.ts"],"sourcesContent":["import * as React from 'react'\n\nexport const useState = React.useState\n\nexport const useCallback = React.useCallback\n\nexport const useEffect = React.useEffect\n\nexport const useMemo = React.useMemo\n\nexport const useRef = React.useRef\n\nexport const createContext = React.createContext\nexport const useContext = React.useContext\nexport const memo = React.memo\nexport const forwardRef = React.forwardRef\nexport const useImperativeHandle = React.useImperativeHandle\n"],"names":["useState","React","useCallback","useEffect","useMemo","useRef","createContext","useContext","memo","forwardRef","useImperativeHandle"],"mappings":";;AAEaA,MAAAA,QAAQ,GAAGC,KAAK,CAACD,SAAQ;AAEzBE,MAAAA,WAAW,GAAGD,KAAK,CAACC,YAAW;AAE/BC,MAAAA,SAAS,GAAGF,KAAK,CAACE,UAAS;AAE3BC,MAAAA,OAAO,GAAGH,KAAK,CAACG,QAAO;AAEvBC,MAAAA,MAAM,GAAGJ,KAAK,CAACI,OAAM;AAErBC,MAAAA,aAAa,GAAGL,KAAK,CAACK,cAAa;AACnCC,MAAAA,UAAU,GAAGN,KAAK,CAACM,WAAU;AAC7BC,MAAAA,IAAI,GAAGP,KAAK,CAACO,KAAI;AACjBC,MAAAA,UAAU,GAAGR,KAAK,CAACQ,WAAU;AAC7BC,MAAAA,mBAAmB,GAAGT,KAAK,CAACS;;;;"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import { forwardRef } from './hooks.react.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable react/react-in-jsx-scope */
|
|
1
5
|
function throttle(fn) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
let threshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
|
7
|
+
let scope = arguments.length > 2 ? arguments[2] : undefined;
|
|
8
|
+
let lastTime = 0;
|
|
9
|
+
let deferTimer;
|
|
6
10
|
return function () {
|
|
7
11
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
12
|
args[_key] = arguments[_key];
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
const context = scope || this;
|
|
15
|
+
const now = Date.now();
|
|
12
16
|
if (now - lastTime > threshold) {
|
|
13
17
|
fn.apply(this, args);
|
|
14
18
|
lastTime = now;
|
|
15
19
|
} else {
|
|
16
20
|
clearTimeout(deferTimer);
|
|
17
|
-
deferTimer = setTimeout(
|
|
21
|
+
deferTimer = setTimeout(() => {
|
|
18
22
|
lastTime = now;
|
|
19
23
|
fn.apply(context, args);
|
|
20
24
|
}, threshold);
|
|
@@ -22,14 +26,14 @@ function throttle(fn) {
|
|
|
22
26
|
};
|
|
23
27
|
}
|
|
24
28
|
function debounce(fn) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
|
30
|
+
let scope = arguments.length > 2 ? arguments[2] : undefined;
|
|
31
|
+
let timer;
|
|
28
32
|
return function () {
|
|
29
33
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
30
34
|
args[_key2] = arguments[_key2];
|
|
31
35
|
}
|
|
32
|
-
|
|
36
|
+
const context = scope || this;
|
|
33
37
|
clearTimeout(timer);
|
|
34
38
|
timer = setTimeout(function () {
|
|
35
39
|
fn.apply(context, args);
|
|
@@ -37,13 +41,20 @@ function debounce(fn) {
|
|
|
37
41
|
};
|
|
38
42
|
}
|
|
39
43
|
function omit(obj, fields) {
|
|
40
|
-
|
|
41
|
-
for (
|
|
42
|
-
|
|
44
|
+
const shallowCopy = Object.assign({}, obj);
|
|
45
|
+
for (let i = 0; i < fields.length; i += 1) {
|
|
46
|
+
const key = fields[i];
|
|
43
47
|
delete shallowCopy[key];
|
|
44
48
|
}
|
|
45
49
|
return shallowCopy;
|
|
46
50
|
}
|
|
51
|
+
const createForwardRefComponent = ReactComponent => {
|
|
52
|
+
const forwardRefComponent = (props, ref) => /*#__PURE__*/jsx(ReactComponent, {
|
|
53
|
+
...props,
|
|
54
|
+
forwardedRef: ref
|
|
55
|
+
});
|
|
56
|
+
return forwardRef(forwardRefComponent);
|
|
57
|
+
};
|
|
47
58
|
|
|
48
|
-
export { debounce, omit, throttle };
|
|
59
|
+
export { createForwardRefComponent, debounce, omit, throttle };
|
|
49
60
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/index.
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/index.tsx"],"sourcesContent":["/* eslint-disable react/react-in-jsx-scope */\nimport { forwardRef } from './hooks'\n\nexport function throttle (fn, threshold = 250, scope?) {\n let lastTime = 0\n let deferTimer: ReturnType<typeof setTimeout>\n return function (...args) {\n const context = scope || this\n const now = Date.now()\n if (now - lastTime > threshold) {\n fn.apply(this, args)\n lastTime = now\n } else {\n clearTimeout(deferTimer)\n deferTimer = setTimeout(() => {\n lastTime = now\n fn.apply(context, args)\n }, threshold)\n }\n }\n}\n\nexport function debounce (fn, ms = 250, scope?) {\n let timer: ReturnType<typeof setTimeout>\n\n return function (...args) {\n const context = scope || this\n clearTimeout(timer)\n timer = setTimeout(function () {\n fn.apply(context, args)\n }, ms)\n }\n}\n\nexport function omit (obj, fields) {\n const shallowCopy = Object.assign({}, obj)\n for (let i = 0; i < fields.length; i += 1) {\n const key = fields[i]\n delete shallowCopy[key]\n }\n return shallowCopy\n}\n\nexport const createForwardRefComponent = (ReactComponent: any) => {\n const forwardRefComponent = (\n props,\n ref\n ) => <ReactComponent {...props} forwardedRef={ref} />\n\n return forwardRef(forwardRefComponent)\n}\n\n"],"names":["throttle","fn","threshold","arguments","length","undefined","scope","lastTime","deferTimer","_len","args","Array","_key","context","now","Date","apply","clearTimeout","setTimeout","debounce","ms","timer","_len2","_key2","omit","obj","fields","shallowCopy","Object","assign","i","key","createForwardRefComponent","ReactComponent","forwardRefComponent","props","ref","_jsx","forwardedRef","forwardRef"],"mappings":";;;AAAA;AAGM,SAAUA,QAAQA,CAAEC,EAAE,EAAyB;AAAA,EAAA,IAAvBC,SAAS,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,GAAG,CAAA;EAAA,IAAEG,KAAM,GAAAH,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA,CAAA;EACnD,IAAIE,QAAQ,GAAG,CAAC,CAAA;AAChB,EAAA,IAAIC,UAAyC,CAAA;AAC7C,EAAA,OAAO,YAAiB;AAAA,IAAA,KAAA,IAAAC,IAAA,GAAAN,SAAA,CAAAC,MAAA,EAAJM,IAAI,GAAAC,IAAAA,KAAA,CAAAF,IAAA,GAAAG,IAAA,GAAA,CAAA,EAAAA,IAAA,GAAAH,IAAA,EAAAG,IAAA,EAAA,EAAA;AAAJF,MAAAA,IAAI,CAAAE,IAAA,CAAAT,GAAAA,SAAA,CAAAS,IAAA,CAAA,CAAA;AAAA,KAAA;AACtB,IAAA,MAAMC,OAAO,GAAGP,KAAK,IAAI,IAAI,CAAA;AAC7B,I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,GAAGH,UAAU,CAAC,YAAA;AACjBjB,MAAAA,EAAE,CAACe,KAAK,CAACH,OAAO,EAAEH,IAAI,CAAC,CAAA;KACxB,EAAEU,EAAE,CAAC,CAAA;GACP,CAAA;AACH,CAAA;AAEgB,SAAAI,IAAIA,CAAEC,GAAG,EAAEC,MAAM,EAAA;EAC/B,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,EAAEJ,GAAG,CAAC,CAAA;AAC1C,EAAA,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,MAAM,CAACtB,MAAM,EAAE0B,CAAC,IAAI,CAAC,EAAE;AACzC,IAAA,MAAMC,GAAG,GAAGL,MAAM,CAACI,CAAC,CAAC,CAAA;IACrB,OAAOH,WAAW,CAACI,GAAG,CAAC,CAAA;AACzB,GAAA;AACA,EAAA,OAAOJ,WAAW,CAAA;AACpB,CAAA;AAEaK,MAAAA,yBAAyB,GAAIC,cAAmB,IAAI;EAC/D,MAAMC,mBAAmB,GAAGA,CAC1BC,KAAK,EACLC,GAAG,kBACAC,GAAA,CAACJ,cAAc,EAAA;AAAA,IAAA,GAAKE,KAAK;AAAEG,IAAAA,YAAY,EAAEF,GAAAA;AAAI,GAAA,CAAG,CAAA;EAErD,OAAOG,UAAU,CAACL,mBAAmB,CAAC,CAAA;AACxC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/components-react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main:h5": "
|
|
5
|
+
"main:h5": "dist/index.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.
|
|
7
|
+
"module": "dist/index.js",
|
|
8
8
|
"types": "types/index.d.ts",
|
|
9
9
|
"sideEffects": [
|
|
10
10
|
"./dist/components/**/loader.js",
|
|
@@ -24,31 +24,32 @@
|
|
|
24
24
|
"author": "",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@babel/runtime": "^7.
|
|
27
|
+
"@babel/runtime": "^7.24.4",
|
|
28
28
|
"classnames": "^2.2.5",
|
|
29
29
|
"swiper": "6.8.0",
|
|
30
30
|
"tslib": "^2.6.2",
|
|
31
|
-
"@tarojs/taro": "4.0.
|
|
32
|
-
"@tarojs/
|
|
31
|
+
"@tarojs/taro": "4.0.3-alpha.0",
|
|
32
|
+
"@tarojs/shared": "4.0.3-alpha.0",
|
|
33
|
+
"@tarojs/components": "4.0.3-alpha.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@babel/
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"typescript": "^4.7.4"
|
|
36
|
+
"@babel/preset-react": "^7.24.1",
|
|
37
|
+
"babel-preset-solid": "^1.8.15",
|
|
38
|
+
"react": "^18.2.0",
|
|
39
|
+
"solid-js": "^1.8.16",
|
|
40
|
+
"@tarojs/helper": "4.0.3-alpha.0",
|
|
41
|
+
"@tarojs/runtime": "4.0.3-alpha.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "*",
|
|
45
|
+
"solid-js": "*"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
|
+
"prod": "pnpm run build",
|
|
48
49
|
"prebuild": "pnpm run clean",
|
|
49
50
|
"build": "pnpm run rollup --environment NODE_ENV:production",
|
|
50
51
|
"clean": "rimraf ./dist",
|
|
51
52
|
"dev": "pnpm run rollup --environment NODE_ENV:development -w",
|
|
52
|
-
"rollup": "rollup
|
|
53
|
+
"rollup": "rollup -c"
|
|
53
54
|
}
|
|
54
55
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module '@tarojs/components-react' {
|
|
2
|
+
export * from '@tarojs/components'
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
declare module '*/hooks' {
|
|
6
|
+
import * as React from 'react'
|
|
7
|
+
export const useState: typeof React.useState
|
|
8
|
+
export const useCallback: typeof React.useCallback
|
|
9
|
+
export const useEffect: typeof React.useEffect
|
|
10
|
+
export const useMemo: typeof React.useMemo
|
|
11
|
+
export const useRef: typeof React.useRef
|
|
12
|
+
export const createContext: typeof React.createContext
|
|
13
|
+
export const useContext: typeof React.useContext
|
|
14
|
+
export const memo: typeof React.memo
|
|
15
|
+
export const forwardRef: typeof React.forwardRef
|
|
16
|
+
export const useImperativeHandle: typeof React.useImperativeHandle
|
|
17
|
+
}
|
|
File without changes
|
|
File without changes
|