@pinnacle0/web-ui 0.6.9 → 0.6.10
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/package.json +1 -1
- package/util/MessageUtil.d.ts +3 -1
- package/util/MessageUtil.js +22 -4
- package/util/MessageUtil.js.map +1 -1
package/package.json
CHANGED
package/util/MessageUtil.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import type { ArgsProps } from "antd/es/message";
|
|
3
3
|
declare function success(content: string | React.ReactElement): void;
|
|
4
4
|
declare function error(content: string | React.ReactElement): void;
|
|
5
5
|
declare function info(config: Partial<Omit<ArgsProps, "type">> & {
|
|
6
6
|
content: ArgsProps["content"];
|
|
7
7
|
}): void;
|
|
8
|
+
declare function Root(): React.ReactElement;
|
|
8
9
|
export declare const MessageUtil: Readonly<{
|
|
9
10
|
success: typeof success;
|
|
10
11
|
error: typeof error;
|
|
11
12
|
info: typeof info;
|
|
13
|
+
Root: typeof Root;
|
|
12
14
|
}>;
|
|
13
15
|
export {};
|
package/util/MessageUtil.js
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Message from "antd/es/message";
|
|
3
|
+
let messageInstance = null;
|
|
2
4
|
function success(content) {
|
|
3
|
-
|
|
5
|
+
(messageInstance || Message).success(content);
|
|
4
6
|
}
|
|
5
7
|
function error(content) {
|
|
6
|
-
|
|
8
|
+
(messageInstance || Message).error(content);
|
|
7
9
|
}
|
|
8
10
|
function info(config) {
|
|
9
|
-
|
|
11
|
+
(messageInstance || Message).open({ duration: 3, ...config, type: "info" });
|
|
12
|
+
}
|
|
13
|
+
function Root() {
|
|
14
|
+
const [apiInstance, contextHolder] = Message.useMessage();
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (messageInstance) {
|
|
17
|
+
throw new Error("[web-ui] Message.Root cannot be mounted more than once");
|
|
18
|
+
}
|
|
19
|
+
messageInstance = apiInstance;
|
|
20
|
+
return () => {
|
|
21
|
+
messageInstance = null;
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- for didMount/willUnmount lifecycle
|
|
25
|
+
[]);
|
|
26
|
+
return contextHolder;
|
|
10
27
|
}
|
|
11
28
|
export const MessageUtil = Object.freeze({
|
|
12
29
|
success,
|
|
13
30
|
error,
|
|
14
31
|
info,
|
|
32
|
+
Root,
|
|
15
33
|
});
|
|
16
34
|
//# sourceMappingURL=MessageUtil.js.map
|
package/util/MessageUtil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageUtil.js","sourceRoot":"","sources":["../../src/util/MessageUtil.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageUtil.js","sourceRoot":"","sources":["../../src/util/MessageUtil.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,OAAO,MAAM,iBAAiB,CAAC;AAGtC,IAAI,eAAe,GAA2B,IAAI,CAAC;AAEnD,SAAS,OAAO,CAAC,OAAoC;IACjD,CAAC,eAAe,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,KAAK,CAAC,OAAoC;IAC/C,CAAC,eAAe,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,IAAI,CAAC,MAA0E;IACpF,CAAC,eAAe,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,IAAI;IACT,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAC1D,KAAK,CAAC,SAAS,CACX,GAAG,EAAE;QACD,IAAI,eAAe,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC9E,CAAC;QACD,eAAe,GAAG,WAAW,CAAC;QAC9B,OAAO,GAAG,EAAE;YACR,eAAe,GAAG,IAAI,CAAC;QAC3B,CAAC,CAAC;IACN,CAAC;IACD,6FAA6F;IAC7F,EAAE,CACL,CAAC;IACF,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,OAAO;IACP,KAAK;IACL,IAAI;IACJ,IAAI;CACP,CAAC,CAAC"}
|