@lark-apaas/client-toolkit 1.1.19-alpha.error.1 → 1.1.19-antd-test.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/lib/ant-table.d.ts +4 -0
- package/lib/ant-table.js +2 -0
- package/lib/components/AppContainer/index.js +108 -7
- package/lib/components/ErrorRender/index.js +9 -3
- package/lib/logger/intercept-global-error.js +1 -1
- package/lib/utils/module-hot.d.ts +2 -1
- package/lib/utils/module-hot.js +2 -2
- package/package.json +7 -2
package/lib/ant-table.js
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
2
|
+
import react, { useEffect } from "react";
|
|
3
3
|
import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
|
|
4
4
|
import IframeBridge from "./IframeBridge.js";
|
|
5
5
|
import { defaultUIConfig } from "../theme/ui-config.js";
|
|
@@ -14,6 +14,15 @@ import safety from "./safety.js";
|
|
|
14
14
|
registerDayjsPlugins();
|
|
15
15
|
initAxiosConfig();
|
|
16
16
|
const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
|
|
17
|
+
const readCssVarColor = (varName, fallback)=>{
|
|
18
|
+
try {
|
|
19
|
+
if ('undefined' == typeof document) return fallback;
|
|
20
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
21
|
+
return value || fallback;
|
|
22
|
+
} catch {
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
17
26
|
const App = (props)=>{
|
|
18
27
|
const { themeMeta = {} } = props;
|
|
19
28
|
useAppInfo();
|
|
@@ -54,17 +63,109 @@ const App = (props)=>{
|
|
|
54
63
|
]
|
|
55
64
|
});
|
|
56
65
|
};
|
|
57
|
-
const
|
|
66
|
+
const AppContainer_AppContainer = (props)=>{
|
|
58
67
|
const { children, ...rest } = props;
|
|
68
|
+
const cssColors = {
|
|
69
|
+
background: readCssVarColor('--background'),
|
|
70
|
+
destructive: readCssVarColor('--destructive'),
|
|
71
|
+
primary: readCssVarColor('--primary'),
|
|
72
|
+
foreground: readCssVarColor('--foreground'),
|
|
73
|
+
warning: readCssVarColor('--warning'),
|
|
74
|
+
success: readCssVarColor('--success'),
|
|
75
|
+
muted: readCssVarColor('--muted'),
|
|
76
|
+
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
77
|
+
border: readCssVarColor('--border'),
|
|
78
|
+
popover: readCssVarColor('--popover'),
|
|
79
|
+
accent: readCssVarColor('--accent'),
|
|
80
|
+
radius: readCssVarColor('--radius')
|
|
81
|
+
};
|
|
82
|
+
const antdThemeToken = {
|
|
83
|
+
borderRadius: cssColors.radius,
|
|
84
|
+
colorBgBase: cssColors.background,
|
|
85
|
+
colorError: cssColors.destructive,
|
|
86
|
+
colorInfo: cssColors.primary,
|
|
87
|
+
colorLink: cssColors.primary,
|
|
88
|
+
colorPrimary: cssColors.primary,
|
|
89
|
+
colorSuccess: cssColors.primary,
|
|
90
|
+
colorTextBase: cssColors.foreground,
|
|
91
|
+
colorWarning: cssColors.destructive
|
|
92
|
+
};
|
|
93
|
+
const antdTableToken = {
|
|
94
|
+
bodySortBg: cssColors.muted,
|
|
95
|
+
borderColor: cssColors.border,
|
|
96
|
+
expandIconBg: cssColors.background,
|
|
97
|
+
filterDropdownBg: cssColors.popover,
|
|
98
|
+
filterDropdownMenuBg: cssColors.popover,
|
|
99
|
+
fixedHeaderSortActiveBg: cssColors.muted,
|
|
100
|
+
footerBg: cssColors.muted,
|
|
101
|
+
footerColor: cssColors.mutedForeground,
|
|
102
|
+
headerBg: cssColors.muted,
|
|
103
|
+
headerColor: cssColors.mutedForeground,
|
|
104
|
+
headerFilterHoverBg: cssColors.muted,
|
|
105
|
+
headerSortActiveBg: cssColors.muted,
|
|
106
|
+
headerSortHoverBg: cssColors.muted,
|
|
107
|
+
headerSplitColor: cssColors.border,
|
|
108
|
+
rowExpandedBg: cssColors.background,
|
|
109
|
+
rowHoverBg: cssColors.muted,
|
|
110
|
+
rowSelectedBg: cssColors.accent,
|
|
111
|
+
rowSelectedHoverBg: cssColors.accent,
|
|
112
|
+
stickyScrollBarBg: cssColors.muted,
|
|
113
|
+
headerBorderRadius: 'var(--radius)'
|
|
114
|
+
};
|
|
115
|
+
const antdPaginationToken = {
|
|
116
|
+
itemActiveBg: cssColors.background,
|
|
117
|
+
itemActiveBgDisabled: cssColors.muted,
|
|
118
|
+
itemActiveColor: cssColors.primary,
|
|
119
|
+
itemActiveColorDisabled: cssColors.muted,
|
|
120
|
+
itemActiveColorHover: cssColors.muted,
|
|
121
|
+
itemBg: cssColors.background,
|
|
122
|
+
itemInputBg: cssColors.background,
|
|
123
|
+
itemLinkBg: cssColors.background
|
|
124
|
+
};
|
|
125
|
+
const OptionalAntdProvider = ({ children })=>{
|
|
126
|
+
const [Provider, setProvider] = react.useState(null);
|
|
127
|
+
const [ready, setReady] = react.useState(false);
|
|
128
|
+
react.useEffect(()=>{
|
|
129
|
+
let mounted = true;
|
|
130
|
+
import("antd").then((mod)=>{
|
|
131
|
+
if (mounted && mod?.ConfigProvider) setProvider(()=>mod.ConfigProvider);
|
|
132
|
+
if (mounted) setReady(true);
|
|
133
|
+
}).catch(()=>{
|
|
134
|
+
if (mounted) {
|
|
135
|
+
setProvider(null);
|
|
136
|
+
setReady(true);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return ()=>{
|
|
140
|
+
mounted = false;
|
|
141
|
+
};
|
|
142
|
+
}, []);
|
|
143
|
+
if (!ready) return null;
|
|
144
|
+
if (!Provider) return /*#__PURE__*/ jsx(Fragment, {
|
|
145
|
+
children: children
|
|
146
|
+
});
|
|
147
|
+
return /*#__PURE__*/ jsx(Provider, {
|
|
148
|
+
theme: {
|
|
149
|
+
token: antdThemeToken,
|
|
150
|
+
components: {
|
|
151
|
+
Table: antdTableToken,
|
|
152
|
+
Pagination: antdPaginationToken
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
children: children
|
|
156
|
+
});
|
|
157
|
+
};
|
|
59
158
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
60
159
|
children: [
|
|
61
160
|
/*#__PURE__*/ jsx(safety, {}),
|
|
62
|
-
/*#__PURE__*/ jsx(
|
|
63
|
-
|
|
64
|
-
|
|
161
|
+
/*#__PURE__*/ jsx(OptionalAntdProvider, {
|
|
162
|
+
children: /*#__PURE__*/ jsx(App, {
|
|
163
|
+
themeMeta: props.themeMeta,
|
|
164
|
+
children: children
|
|
165
|
+
})
|
|
65
166
|
})
|
|
66
167
|
]
|
|
67
168
|
});
|
|
68
169
|
};
|
|
69
|
-
const
|
|
70
|
-
export {
|
|
170
|
+
const AppContainer = AppContainer_AppContainer;
|
|
171
|
+
export { AppContainer as default };
|
|
@@ -21,9 +21,15 @@ const RenderError = (props)=>{
|
|
|
21
21
|
useEffect(()=>{
|
|
22
22
|
if (!resetErrorBoundary) return;
|
|
23
23
|
const hot = getModuleHot();
|
|
24
|
-
if (hot)
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (hot) {
|
|
25
|
+
const handler = createApplyHandle((success)=>{
|
|
26
|
+
if (success) resetErrorBoundary();
|
|
27
|
+
});
|
|
28
|
+
hot.addStatusHandler(handler);
|
|
29
|
+
return ()=>{
|
|
30
|
+
hot.removeStatusHandler(handler);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
27
33
|
}, [
|
|
28
34
|
resetErrorBoundary
|
|
29
35
|
]);
|
|
@@ -64,7 +64,7 @@ function processDevServerLog(log) {
|
|
|
64
64
|
}
|
|
65
65
|
function listenModuleHmr() {
|
|
66
66
|
const hot = getModuleHot();
|
|
67
|
-
if (hot) hot.addStatusHandler(createApplyHandle((success)=>{
|
|
67
|
+
if (hot) hot.addStatusHandler(createApplyHandle((success, status)=>{
|
|
68
68
|
if (success) submitPostMessage({
|
|
69
69
|
type: 'DevServerMessage',
|
|
70
70
|
data: {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
type ModuleHotType = 'idle' | 'check' | 'prepare' | 'ready' | 'dispose' | 'apply' | 'abort' | 'fail';
|
|
14
14
|
interface ModuleHotInstance {
|
|
15
15
|
addStatusHandler: (handler: (status: ModuleHotType) => void) => void;
|
|
16
|
+
removeStatusHandler: (handler: (status: ModuleHotType) => void) => void;
|
|
16
17
|
}
|
|
17
18
|
export declare function getModuleHot(): ModuleHotInstance | null;
|
|
18
19
|
/**
|
|
@@ -20,5 +21,5 @@ export declare function getModuleHot(): ModuleHotInstance | null;
|
|
|
20
21
|
* 监听模块热更状态,当状态为apply时,调用回调函数并传入true
|
|
21
22
|
* @param callback 热更成功回调函数,参数为是否成功
|
|
22
23
|
*/
|
|
23
|
-
export declare function createApplyHandle(callback: (success: boolean) => void): (status: ModuleHotType) => void;
|
|
24
|
+
export declare function createApplyHandle(callback: (success: boolean, status: ModuleHotType) => void): (status: ModuleHotType) => void;
|
|
24
25
|
export {};
|
package/lib/utils/module-hot.js
CHANGED
|
@@ -7,12 +7,12 @@ function createApplyHandle(callback) {
|
|
|
7
7
|
return (status)=>{
|
|
8
8
|
if ('fail' === status || 'abort' === status) {
|
|
9
9
|
hasApply = false;
|
|
10
|
-
return callback(false);
|
|
10
|
+
return callback(false, status);
|
|
11
11
|
}
|
|
12
12
|
if (hasApply) {
|
|
13
13
|
if ('idle' === status) {
|
|
14
14
|
hasApply = false;
|
|
15
|
-
callback(true);
|
|
15
|
+
callback(true, status);
|
|
16
16
|
}
|
|
17
17
|
return;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.1.19-
|
|
3
|
+
"version": "1.1.19-antd-test.0",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"require": "./lib/index.js",
|
|
16
16
|
"types": "./lib/index.d.ts"
|
|
17
17
|
},
|
|
18
|
+
"./ant-table": {
|
|
19
|
+
"import": "./lib/ant-table.js",
|
|
20
|
+
"require": "./lib/ant-table.js",
|
|
21
|
+
"types": "./lib/ant-table.d.ts"
|
|
22
|
+
},
|
|
18
23
|
"./lib/index.css": "./lib/index.css",
|
|
19
24
|
"./dataloom": {
|
|
20
25
|
"import": "./lib/apis/dataloom.js",
|
|
@@ -76,7 +81,7 @@
|
|
|
76
81
|
"@ant-design/colors": "^7.2.1",
|
|
77
82
|
"@ant-design/cssinjs": "^1.24.0",
|
|
78
83
|
"@data-loom/js": "^0.4.0",
|
|
79
|
-
"@lark-apaas/miaoda-inspector": "^1.0.
|
|
84
|
+
"@lark-apaas/miaoda-inspector": "^1.0.4",
|
|
80
85
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
81
86
|
"@radix-ui/react-popover": "^1.1.15",
|
|
82
87
|
"@radix-ui/react-slot": "^1.2.3",
|