@pisell/materials 1.0.924 → 1.0.926
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +146 -146
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +18 -18
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +23 -23
- package/dist/umd/materials.min.css +1 -0
- package/dist/umd/materials.min.js +1 -0
- package/dist/umd/static/DotsSix.57d66266.svg +1 -0
- package/dist/umd/static/arrow-left.e542294f.svg +1 -0
- package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
- package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
- package/dist/umd/static/help-circle.31c9be40.svg +1 -0
- package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/index.d.ts +11 -11
- package/es/components/pisellCamera/index.js +11 -2
- package/es/components/pisellCamera/index.less +17 -6
- package/es/components/pisellToast/index.d.ts +1 -1
- package/es/components/pisellToast/index.js +1 -1
- package/es/components/pisellToast/squareToast/index.d.ts +12 -22
- package/es/components/pisellToast/squareToast/index.js +24 -106
- package/es/components/pisellToast/squareToast/index.less +7 -18
- package/es/components/pisellToast/squareToast/methods.d.ts +13 -0
- package/es/components/pisellToast/squareToast/methods.js +136 -0
- package/es/components/pisellToast/squareToast/renderImperatively.d.ts +29 -0
- package/es/components/pisellToast/squareToast/renderImperatively.js +165 -0
- package/es/components/pisellToast/squareToast/toast.d.ts +25 -0
- package/es/components/pisellToast/squareToast/toast.js +60 -0
- package/es/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
- package/es/components/table/Table/fields/index.d.ts +2 -2
- package/es/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
- package/es/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/locales/zh-TW.js +8 -15
- package/es/utils/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/index.d.ts +11 -11
- package/lib/components/pisellCamera/index.js +5 -2
- package/lib/components/pisellCamera/index.less +17 -6
- package/lib/components/pisellToast/index.d.ts +1 -1
- package/lib/components/pisellToast/index.js +2 -2
- package/lib/components/pisellToast/squareToast/index.d.ts +12 -22
- package/lib/components/pisellToast/squareToast/index.js +30 -93
- package/lib/components/pisellToast/squareToast/index.less +7 -18
- package/lib/components/pisellToast/squareToast/methods.d.ts +13 -0
- package/lib/components/pisellToast/squareToast/methods.js +150 -0
- package/lib/components/pisellToast/squareToast/renderImperatively.d.ts +29 -0
- package/lib/components/pisellToast/squareToast/renderImperatively.js +148 -0
- package/lib/components/pisellToast/squareToast/toast.d.ts +25 -0
- package/lib/components/pisellToast/squareToast/toast.js +88 -0
- package/lib/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
- package/lib/components/table/Table/fields/index.d.ts +2 -2
- package/lib/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
- package/lib/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/locales/zh-TW.js +4 -0
- package/lib/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/es/components/pisellToast/squareToast/useToast.d.ts +0 -39
- package/es/components/pisellToast/squareToast/useToast.js +0 -145
- package/lib/components/pisellToast/squareToast/useToast.d.ts +0 -39
- package/lib/components/pisellToast/squareToast/useToast.js +0 -148
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { clear, show, success, info, loading, fail, hide } from './methods';
|
|
2
2
|
import './index.less';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
duration?: number;
|
|
13
|
-
/** 关闭回调 */
|
|
14
|
-
onClose?: () => void;
|
|
15
|
-
/** 自定义图标 */
|
|
16
|
-
icon?: React.ReactNode;
|
|
17
|
-
/** 自定义样式类名 */
|
|
18
|
-
className?: string;
|
|
19
|
-
/** 自定义样式 */
|
|
20
|
-
style?: React.CSSProperties;
|
|
21
|
-
/** 是否显示遮罩 */
|
|
22
|
-
mask?: boolean;
|
|
3
|
+
interface ToastInstance {
|
|
4
|
+
show: typeof show;
|
|
5
|
+
clear: typeof clear;
|
|
6
|
+
success: typeof success;
|
|
7
|
+
info: typeof info;
|
|
8
|
+
loading: typeof loading;
|
|
9
|
+
fail: typeof fail;
|
|
10
|
+
error: typeof fail;
|
|
11
|
+
hide: typeof hide;
|
|
23
12
|
}
|
|
24
|
-
declare const Toast:
|
|
13
|
+
declare const Toast: ToastInstance;
|
|
14
|
+
export declare const useToast: () => ToastInstance;
|
|
25
15
|
export default Toast;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,106 +14,45 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/components/pisellToast/squareToast/index.tsx
|
|
30
20
|
var squareToast_exports = {};
|
|
31
21
|
__export(squareToast_exports, {
|
|
32
|
-
default: () => squareToast_default
|
|
22
|
+
default: () => squareToast_default,
|
|
23
|
+
useToast: () => useToast
|
|
33
24
|
});
|
|
34
25
|
module.exports = __toCommonJS(squareToast_exports);
|
|
35
|
-
var import_react =
|
|
36
|
-
var
|
|
37
|
-
var import_icon = __toESM(require("../../icon"));
|
|
38
|
-
var import_classnames = __toESM(require("classnames"));
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_methods = require("./methods");
|
|
39
28
|
var import_index = require("./index.less");
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
loading:
|
|
46
|
-
fail:
|
|
29
|
+
var Toast = {
|
|
30
|
+
show: import_methods.show,
|
|
31
|
+
clear: import_methods.clear,
|
|
32
|
+
success: import_methods.success,
|
|
33
|
+
info: import_methods.info,
|
|
34
|
+
loading: import_methods.loading,
|
|
35
|
+
fail: import_methods.fail,
|
|
36
|
+
error: import_methods.fail,
|
|
37
|
+
hide: import_methods.hide
|
|
47
38
|
};
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
setInternalVisible(visible);
|
|
62
|
-
}, [visible]);
|
|
63
|
-
(0, import_react.useEffect)(() => {
|
|
64
|
-
if (internalVisible && duration > 0) {
|
|
65
|
-
const timer = setTimeout(() => {
|
|
66
|
-
handleClose();
|
|
67
|
-
}, duration);
|
|
68
|
-
return () => clearTimeout(timer);
|
|
69
|
-
}
|
|
70
|
-
}, [internalVisible, duration]);
|
|
71
|
-
const handleClose = () => {
|
|
72
|
-
setInternalVisible(false);
|
|
73
|
-
onClose == null ? void 0 : onClose();
|
|
74
|
-
};
|
|
75
|
-
const showIcon = (0, import_react.useMemo)(() => {
|
|
76
|
-
return icon !== void 0 || icons[type];
|
|
77
|
-
}, [type, icon]);
|
|
78
|
-
const renderIcon = () => {
|
|
79
|
-
if (icon !== void 0) {
|
|
80
|
-
return icon;
|
|
81
|
-
}
|
|
82
|
-
const iconType = icons[type];
|
|
83
|
-
if (iconType) {
|
|
84
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
85
|
-
import_icon.default,
|
|
86
|
-
{
|
|
87
|
-
type: iconType,
|
|
88
|
-
className: `pisell-square-toast-icon pisell-square-toast-icon-${type}`
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
};
|
|
94
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
95
|
-
import_modal.default,
|
|
96
|
-
{
|
|
97
|
-
open: visible,
|
|
98
|
-
footer: null,
|
|
99
|
-
closable: false,
|
|
100
|
-
centered: true,
|
|
101
|
-
maskTransitionName: "",
|
|
102
|
-
transitionName: "",
|
|
103
|
-
getContainer: () => document.body,
|
|
104
|
-
wrapClassName: "pisell-square-toast-wrap",
|
|
105
|
-
className: (0, import_classnames.default)("pisell-square-toast-modal", className),
|
|
106
|
-
width: "auto",
|
|
107
|
-
style: { textAlign: "center", ...style },
|
|
108
|
-
bodyStyle: { padding: 0 },
|
|
109
|
-
mask,
|
|
110
|
-
modalRender: () => /* @__PURE__ */ import_react.default.createElement(
|
|
111
|
-
"div",
|
|
112
|
-
{
|
|
113
|
-
className: `pisell-square-toast ${type ? `pisell-square-toast-${type}` : ""}`
|
|
114
|
-
},
|
|
115
|
-
showIcon && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-square-toast-icon-wrapper" }, renderIcon()),
|
|
116
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-square-toast-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-square-toast-message" }, message))
|
|
117
|
-
)
|
|
118
|
-
}
|
|
39
|
+
var useToast = () => {
|
|
40
|
+
return (0, import_react.useMemo)(
|
|
41
|
+
() => ({
|
|
42
|
+
show: import_methods.show,
|
|
43
|
+
clear: import_methods.clear,
|
|
44
|
+
success: import_methods.success,
|
|
45
|
+
info: import_methods.info,
|
|
46
|
+
loading: import_methods.loading,
|
|
47
|
+
fail: import_methods.fail,
|
|
48
|
+
error: import_methods.fail,
|
|
49
|
+
hide: import_methods.hide
|
|
50
|
+
}),
|
|
51
|
+
[]
|
|
119
52
|
);
|
|
120
53
|
};
|
|
121
54
|
var squareToast_default = Toast;
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
useToast
|
|
58
|
+
});
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
.pisell-square-toast-modal {
|
|
6
6
|
pointer-events: none;
|
|
7
7
|
user-select: none;
|
|
8
|
+
min-width: 190px;
|
|
9
|
+
min-height: 74px;
|
|
8
10
|
|
|
9
11
|
// Toast 容器
|
|
10
12
|
.pisell-square-toast {
|
|
@@ -19,7 +21,6 @@
|
|
|
19
21
|
overflow: hidden;
|
|
20
22
|
background: rgba(0, 0, 0, 0.8);
|
|
21
23
|
|
|
22
|
-
// 图标包装器
|
|
23
24
|
.pisell-square-toast-icon-wrapper {
|
|
24
25
|
display: flex;
|
|
25
26
|
align-items: center;
|
|
@@ -43,27 +44,15 @@
|
|
|
43
44
|
|
|
44
45
|
// 内容区域
|
|
45
46
|
.pisell-square-toast-content {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
text-align: center;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 带图标的样式调整
|
|
55
|
-
&.pisell-square-toast-success,
|
|
56
|
-
&.pisell-square-toast-error,
|
|
57
|
-
&.pisell-square-toast-warning,
|
|
58
|
-
&.pisell-square-toast-fail,
|
|
59
|
-
&.pisell-square-toast-loading {
|
|
60
|
-
min-width: 190px;
|
|
61
|
-
min-height: 74px;
|
|
47
|
+
font-size: 20px;
|
|
48
|
+
line-height: 1.5;
|
|
49
|
+
color: #ffffff;
|
|
50
|
+
text-align: center;
|
|
62
51
|
}
|
|
63
52
|
}
|
|
64
53
|
}
|
|
65
54
|
|
|
66
|
-
// 旋转动画
|
|
55
|
+
// loading 旋转动画
|
|
67
56
|
@keyframes fadenum {
|
|
68
57
|
to {
|
|
69
58
|
transform: rotate(360deg);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToastProps } from './toast';
|
|
3
|
+
interface ToastInstance {
|
|
4
|
+
close: () => void;
|
|
5
|
+
}
|
|
6
|
+
declare const show: (configOrContent: Partial<ToastProps> | React.ReactNode, duration?: number, afterClose?: () => void) => ToastInstance;
|
|
7
|
+
declare const clear: () => void;
|
|
8
|
+
declare const success: (content: React.ReactNode, duration?: number, afterClose?: () => void) => ToastInstance;
|
|
9
|
+
declare const info: (content: React.ReactNode, duration?: number, afterClose?: () => void) => ToastInstance;
|
|
10
|
+
declare const loading: (content: React.ReactNode, duration?: number, afterClose?: () => void) => ToastInstance;
|
|
11
|
+
declare const fail: (content: React.ReactNode, duration?: number, afterClose?: () => void) => ToastInstance;
|
|
12
|
+
declare const hide: () => void;
|
|
13
|
+
export { show, clear, success, info, loading, fail, hide };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/pisellToast/squareToast/methods.tsx
|
|
30
|
+
var methods_exports = {};
|
|
31
|
+
__export(methods_exports, {
|
|
32
|
+
clear: () => clear,
|
|
33
|
+
fail: () => fail,
|
|
34
|
+
hide: () => hide,
|
|
35
|
+
info: () => info,
|
|
36
|
+
loading: () => loading,
|
|
37
|
+
show: () => show,
|
|
38
|
+
success: () => success
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(methods_exports);
|
|
41
|
+
var import_react = __toESM(require("react"));
|
|
42
|
+
var import_toast = __toESM(require("./toast"));
|
|
43
|
+
var import_renderImperatively = require("./renderImperatively");
|
|
44
|
+
var currentHandler = null;
|
|
45
|
+
var currentTimeout = null;
|
|
46
|
+
var defaultProps = {
|
|
47
|
+
duration: 2e3,
|
|
48
|
+
mask: false,
|
|
49
|
+
icon: "info"
|
|
50
|
+
};
|
|
51
|
+
function mergeProps(a, b) {
|
|
52
|
+
const filteredB = Object.keys(b).reduce((acc, key) => {
|
|
53
|
+
if (b[key] !== void 0) {
|
|
54
|
+
acc[key] = b[key];
|
|
55
|
+
}
|
|
56
|
+
return acc;
|
|
57
|
+
}, {});
|
|
58
|
+
return {
|
|
59
|
+
...a,
|
|
60
|
+
...filteredB
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
var show = (configOrContent, duration, afterClose) => {
|
|
64
|
+
var _a;
|
|
65
|
+
let props;
|
|
66
|
+
if (typeof configOrContent === "string" || import_react.default.isValidElement(configOrContent)) {
|
|
67
|
+
props = mergeProps(defaultProps, {
|
|
68
|
+
content: configOrContent,
|
|
69
|
+
...duration !== void 0 && { duration },
|
|
70
|
+
...afterClose !== void 0 && { afterClose }
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
props = mergeProps(defaultProps, configOrContent || {});
|
|
74
|
+
}
|
|
75
|
+
const element = /* @__PURE__ */ import_react.default.createElement(
|
|
76
|
+
import_toast.default,
|
|
77
|
+
{
|
|
78
|
+
...props,
|
|
79
|
+
onCancel: () => {
|
|
80
|
+
currentHandler = null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
if (currentHandler) {
|
|
85
|
+
if ((_a = currentHandler.isRendered) == null ? void 0 : _a.call(currentHandler)) {
|
|
86
|
+
currentHandler.replace(element);
|
|
87
|
+
} else {
|
|
88
|
+
currentHandler.close();
|
|
89
|
+
currentHandler = (0, import_renderImperatively.renderImperatively)(element);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
currentHandler = (0, import_renderImperatively.renderImperatively)(element);
|
|
93
|
+
}
|
|
94
|
+
if (currentTimeout) {
|
|
95
|
+
window.clearTimeout(currentTimeout);
|
|
96
|
+
}
|
|
97
|
+
if (props.duration !== 0) {
|
|
98
|
+
currentTimeout = window.setTimeout(() => {
|
|
99
|
+
clear();
|
|
100
|
+
}, props.duration);
|
|
101
|
+
}
|
|
102
|
+
const instance = {
|
|
103
|
+
close: () => {
|
|
104
|
+
if (currentHandler) {
|
|
105
|
+
currentHandler.close();
|
|
106
|
+
currentHandler = null;
|
|
107
|
+
}
|
|
108
|
+
if (currentTimeout) {
|
|
109
|
+
window.clearTimeout(currentTimeout);
|
|
110
|
+
currentTimeout = null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return instance;
|
|
115
|
+
};
|
|
116
|
+
var clear = () => {
|
|
117
|
+
if (currentHandler) {
|
|
118
|
+
currentHandler.close();
|
|
119
|
+
currentHandler = null;
|
|
120
|
+
}
|
|
121
|
+
if (currentTimeout) {
|
|
122
|
+
window.clearTimeout(currentTimeout);
|
|
123
|
+
currentTimeout = null;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var success = (content, duration, afterClose) => {
|
|
127
|
+
return show({ content, icon: "success", duration, afterClose });
|
|
128
|
+
};
|
|
129
|
+
var info = (content, duration, afterClose) => {
|
|
130
|
+
return show({ content, icon: "info", duration, afterClose });
|
|
131
|
+
};
|
|
132
|
+
var loading = (content, duration, afterClose) => {
|
|
133
|
+
return show({ content, icon: "loading", duration, afterClose });
|
|
134
|
+
};
|
|
135
|
+
var fail = (content, duration, afterClose) => {
|
|
136
|
+
return show({ content, icon: "error", duration, afterClose });
|
|
137
|
+
};
|
|
138
|
+
var hide = () => {
|
|
139
|
+
clear();
|
|
140
|
+
};
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
clear,
|
|
144
|
+
fail,
|
|
145
|
+
hide,
|
|
146
|
+
info,
|
|
147
|
+
loading,
|
|
148
|
+
show,
|
|
149
|
+
success
|
|
150
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Root } from 'react-dom/client';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
declare type ImperativeProps = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
afterClose?: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare type TargetElement = ReactElement<ImperativeProps>;
|
|
10
|
+
export declare type ImperativeHandler = {
|
|
11
|
+
close: () => void;
|
|
12
|
+
replace: (element: TargetElement) => void;
|
|
13
|
+
isRendered?: () => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare type UnmountType = () => Promise<void>;
|
|
16
|
+
export declare type RenderType = (node: React.ReactElement, container: Element | DocumentFragment) => UnmountType;
|
|
17
|
+
declare const MARK = "__pisell_react_root__";
|
|
18
|
+
declare type ContainerType = (Element | DocumentFragment) & {
|
|
19
|
+
[MARK]?: Root;
|
|
20
|
+
};
|
|
21
|
+
export declare function render(node: React.ReactElement, container: ContainerType): void;
|
|
22
|
+
export declare function unmount(container: ContainerType): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated 设置 React 渲染函数以兼容使用。
|
|
25
|
+
*/
|
|
26
|
+
export declare function unstableSetRender(render?: RenderType): RenderType;
|
|
27
|
+
export declare function renderToBody(element: ReactElement): UnmountType;
|
|
28
|
+
export declare function renderImperatively(element: TargetElement): ImperativeHandler;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/pisellToast/squareToast/renderImperatively.tsx
|
|
30
|
+
var renderImperatively_exports = {};
|
|
31
|
+
__export(renderImperatively_exports, {
|
|
32
|
+
render: () => render,
|
|
33
|
+
renderImperatively: () => renderImperatively,
|
|
34
|
+
renderToBody: () => renderToBody,
|
|
35
|
+
unmount: () => unmount,
|
|
36
|
+
unstableSetRender: () => unstableSetRender
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(renderImperatively_exports);
|
|
39
|
+
var ReactDOM = __toESM(require("react-dom"));
|
|
40
|
+
var import_client = require("react-dom/client");
|
|
41
|
+
var import_react = __toESM(require("react"));
|
|
42
|
+
var MARK = "__pisell_react_root__";
|
|
43
|
+
function render(node, container) {
|
|
44
|
+
const root = container[MARK] || (0, import_client.createRoot)(container);
|
|
45
|
+
root.render(node);
|
|
46
|
+
container[MARK] = root;
|
|
47
|
+
}
|
|
48
|
+
async function unmount(container) {
|
|
49
|
+
return Promise.resolve().then(() => {
|
|
50
|
+
var _a;
|
|
51
|
+
(_a = container[MARK]) == null ? void 0 : _a.unmount();
|
|
52
|
+
delete container[MARK];
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var defaultReactRender = (node, container) => {
|
|
56
|
+
if (process.env.NODE_ENV !== "production") {
|
|
57
|
+
const majorVersion = parseInt(import_react.default.version.split(".")[0], 10);
|
|
58
|
+
const fullKeys = Object.keys(ReactDOM);
|
|
59
|
+
console.warn(
|
|
60
|
+
majorVersion < 19 || fullKeys.includes("createRoot"),
|
|
61
|
+
`[Compatible] Toast support React is 16 ~ 18.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
render(node, container);
|
|
65
|
+
return () => {
|
|
66
|
+
return unmount(container);
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var unstableRender = defaultReactRender;
|
|
70
|
+
function unstableSetRender(render2) {
|
|
71
|
+
if (render2) {
|
|
72
|
+
unstableRender = render2;
|
|
73
|
+
}
|
|
74
|
+
return unstableRender;
|
|
75
|
+
}
|
|
76
|
+
function renderToBody(element) {
|
|
77
|
+
const container = document.createElement("div");
|
|
78
|
+
document.body.appendChild(container);
|
|
79
|
+
return unstableSetRender()(element, container);
|
|
80
|
+
}
|
|
81
|
+
function renderImperatively(element) {
|
|
82
|
+
const Wrapper = import_react.default.forwardRef((_, ref) => {
|
|
83
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
84
|
+
const closedRef = (0, import_react.useRef)(false);
|
|
85
|
+
const [elementToRender, setElementToRender] = (0, import_react.useState)(element);
|
|
86
|
+
const keyRef = (0, import_react.useRef)(0);
|
|
87
|
+
(0, import_react.useEffect)(() => {
|
|
88
|
+
if (!closedRef.current) {
|
|
89
|
+
setOpen(true);
|
|
90
|
+
} else {
|
|
91
|
+
afterClose();
|
|
92
|
+
}
|
|
93
|
+
}, []);
|
|
94
|
+
function onCancel() {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
closedRef.current = true;
|
|
97
|
+
setOpen(false);
|
|
98
|
+
(_b = (_a = elementToRender.props).onCancel) == null ? void 0 : _b.call(_a);
|
|
99
|
+
}
|
|
100
|
+
function afterClose() {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
unmount2();
|
|
103
|
+
(_b = (_a = elementToRender.props).afterClose) == null ? void 0 : _b.call(_a);
|
|
104
|
+
}
|
|
105
|
+
(0, import_react.useImperativeHandle)(ref, () => ({
|
|
106
|
+
close: onCancel,
|
|
107
|
+
replace: (element2) => {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
keyRef.current++;
|
|
110
|
+
(_b = (_a = elementToRender.props).afterClose) == null ? void 0 : _b.call(_a);
|
|
111
|
+
setElementToRender(element2);
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
return import_react.default.cloneElement(elementToRender, {
|
|
115
|
+
...elementToRender.props,
|
|
116
|
+
key: keyRef.current,
|
|
117
|
+
open,
|
|
118
|
+
onCancel,
|
|
119
|
+
afterClose
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
const wrapperRef = import_react.default.createRef();
|
|
123
|
+
const unmount2 = renderToBody(/* @__PURE__ */ import_react.default.createElement(Wrapper, { ref: wrapperRef }));
|
|
124
|
+
return {
|
|
125
|
+
close: async () => {
|
|
126
|
+
var _a, _b, _c;
|
|
127
|
+
if (!wrapperRef.current) {
|
|
128
|
+
unmount2();
|
|
129
|
+
(_b = (_a = element.props).afterClose) == null ? void 0 : _b.call(_a);
|
|
130
|
+
} else {
|
|
131
|
+
(_c = wrapperRef.current) == null ? void 0 : _c.close();
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
replace: (element2) => {
|
|
135
|
+
var _a;
|
|
136
|
+
(_a = wrapperRef.current) == null ? void 0 : _a.replace(element2);
|
|
137
|
+
},
|
|
138
|
+
isRendered: () => !!wrapperRef.current
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
render,
|
|
144
|
+
renderImperatively,
|
|
145
|
+
renderToBody,
|
|
146
|
+
unmount,
|
|
147
|
+
unstableSetRender
|
|
148
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
export declare type ToastType = 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
4
|
+
export interface ToastProps {
|
|
5
|
+
/** Toast 类型 */
|
|
6
|
+
icon?: ToastType | React.ReactNode;
|
|
7
|
+
/** 显示的内容,支持文本或 React 节点 */
|
|
8
|
+
content: React.ReactNode;
|
|
9
|
+
/** 是否显示 */
|
|
10
|
+
open?: boolean;
|
|
11
|
+
/** 自动关闭时间,单位毫秒,0 表示不自动关闭 */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** 关闭 */
|
|
14
|
+
onCancel?: () => void;
|
|
15
|
+
/** 关闭后回调 */
|
|
16
|
+
afterClose?: () => void;
|
|
17
|
+
/** 自定义样式类名 */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** 自定义样式 */
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
/** 是否显示遮罩 */
|
|
22
|
+
mask?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare const Toast: React.FC<ToastProps>;
|
|
25
|
+
export default Toast;
|