@lemon-fe/hooks 1.2.0 → 1.2.11-alpha.3
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/es/config.d.ts +5 -6
- package/es/config.js +5 -2
- package/es/index.d.ts +1 -1
- package/package.json +2 -2
package/es/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { type ReactNode, type ReactElement } from 'react';
|
|
2
|
-
interface
|
|
2
|
+
export interface HooksOpts<ToastReturnType = any> {
|
|
3
3
|
showToast: () => ToastReturnType;
|
|
4
4
|
cancelToast: (toastReturn: ToastReturnType) => void;
|
|
5
5
|
showError: (err: Error) => void;
|
|
@@ -9,14 +9,13 @@ interface Opts<ToastReturnType = any> {
|
|
|
9
9
|
/** 默认throttle时间,便于移动端使用 */
|
|
10
10
|
requestThrottleInterval: number;
|
|
11
11
|
}
|
|
12
|
-
export declare const hooksOpts:
|
|
12
|
+
export declare const hooksOpts: HooksOpts;
|
|
13
13
|
/**
|
|
14
14
|
* @description use HookContext
|
|
15
15
|
*/
|
|
16
|
-
export declare function config<ToastReturnType = any>(opts: Partial<
|
|
17
|
-
export declare const HooksConfigContext: React.Context<
|
|
16
|
+
export declare function config<ToastReturnType = any>(opts: Partial<HooksOpts<ToastReturnType>>): void;
|
|
17
|
+
export declare const HooksConfigContext: React.Context<HooksOpts<any>>;
|
|
18
18
|
export declare function HooksConfigProvider(props: {
|
|
19
|
-
value: Partial<
|
|
19
|
+
value: Partial<HooksOpts>;
|
|
20
20
|
children?: ReactNode | null;
|
|
21
21
|
}): JSX.Element;
|
|
22
|
-
export {};
|
package/es/config.js
CHANGED
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
import React, { createContext } from 'react';
|
|
7
|
+
import React, { createContext, useMemo } from 'react';
|
|
8
8
|
var warning = function warning(name) {
|
|
9
9
|
console.warn("implement hooks ".concat(name));
|
|
10
10
|
};
|
|
@@ -40,7 +40,10 @@ export function config(opts) {
|
|
|
40
40
|
}
|
|
41
41
|
export var HooksConfigContext = /*#__PURE__*/createContext(hooksOpts);
|
|
42
42
|
export function HooksConfigProvider(props) {
|
|
43
|
+
var opts = useMemo(function () {
|
|
44
|
+
return _objectSpread(_objectSpread({}, hooksOpts), props.value);
|
|
45
|
+
}, [props.value]);
|
|
43
46
|
return /*#__PURE__*/React.createElement(HooksConfigContext.Provider, {
|
|
44
|
-
value:
|
|
47
|
+
value: opts
|
|
45
48
|
}, props.children);
|
|
46
49
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export { default as useAsyncEffect } from './use-async-effect';
|
|
|
7
7
|
export { default as usePreload } from './use-preload';
|
|
8
8
|
export { default as useUpdateEffect } from './use-update-effect';
|
|
9
9
|
export { default as useLastestRef } from './use-latest-ref';
|
|
10
|
-
export { config, HooksConfigContext, HooksConfigProvider } from './config';
|
|
10
|
+
export { config, HooksConfigContext, HooksConfigProvider, type HooksOpts } from './config';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/hooks",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11-alpha.3",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"antd": "^4.24.8",
|
|
31
31
|
"react": "^17.0.2"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "7d99f5c1e6ea4c9715ce164d1d065f22d89073a8"
|
|
34
34
|
}
|