@umijs/plugins 4.0.0-canary.20230310.2 → 4.0.0-canary.20230315.1
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/dist/antd.js +50 -42
- package/libs/locale/SelectLang.tpl +1 -0
- package/package.json +3 -3
- package/tpls/antd-runtime.ts.tpl +63 -0
package/dist/antd.js
CHANGED
|
@@ -50,6 +50,8 @@ var antd_default = (api) => {
|
|
|
50
50
|
antdVersion = require(`${pkgPath}/package.json`).version;
|
|
51
51
|
} catch (e) {
|
|
52
52
|
}
|
|
53
|
+
const appComponentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.1.0");
|
|
54
|
+
const appConfigAvailable = import_plugin_utils.semver.gte(antdVersion, "5.3.0");
|
|
53
55
|
api.describe({
|
|
54
56
|
config: {
|
|
55
57
|
schema(Joi) {
|
|
@@ -63,7 +65,9 @@ var antd_default = (api) => {
|
|
|
63
65
|
import: Joi.boolean(),
|
|
64
66
|
// less or css, default less
|
|
65
67
|
style: Joi.string().allow("less", "css"),
|
|
66
|
-
theme: Joi.object()
|
|
68
|
+
theme: Joi.object(),
|
|
69
|
+
// Only antd@5.1.0 is supported
|
|
70
|
+
appConfig: Joi.object()
|
|
67
71
|
}),
|
|
68
72
|
Joi.boolean().invalid(true)
|
|
69
73
|
);
|
|
@@ -136,6 +140,18 @@ var antd_default = (api) => {
|
|
|
136
140
|
antd.theme
|
|
137
141
|
);
|
|
138
142
|
}
|
|
143
|
+
if (antd.appConfig) {
|
|
144
|
+
if (!appComponentAvailable) {
|
|
145
|
+
delete antd.appConfig;
|
|
146
|
+
api.logger.warn(
|
|
147
|
+
`antd.appConfig is only available in version 5.1.0 and above, but you are using version ${antdVersion}`
|
|
148
|
+
);
|
|
149
|
+
} else if (!appConfigAvailable && Object.keys(antd.appConfig).length > 0) {
|
|
150
|
+
api.logger.warn(
|
|
151
|
+
`versions [5.1.0 ~ 5.3.0) only allows antd.appConfig to be set to \`{}\``
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
139
155
|
return memo;
|
|
140
156
|
});
|
|
141
157
|
api.addExtraBabelPlugins(() => {
|
|
@@ -155,55 +171,44 @@ var antd_default = (api) => {
|
|
|
155
171
|
] : [];
|
|
156
172
|
});
|
|
157
173
|
api.onGenerateFiles(() => {
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
const withConfigProvider = !!api.config.antd.configProvider;
|
|
175
|
+
const withAppConfig = appConfigAvailable && !!api.config.antd.appConfig;
|
|
160
176
|
api.writeTmpFile({
|
|
161
177
|
path: `runtime.tsx`,
|
|
178
|
+
context: {
|
|
179
|
+
configProvider: withConfigProvider && JSON.stringify(api.config.antd.configProvider),
|
|
180
|
+
appConfig: appComponentAvailable && JSON.stringify(api.config.antd.appConfig)
|
|
181
|
+
},
|
|
182
|
+
tplPath: (0, import_path.join)(__dirname, "../tpls/antd-runtime.ts.tpl")
|
|
183
|
+
});
|
|
184
|
+
api.writeTmpFile({
|
|
185
|
+
path: "types.d.ts",
|
|
162
186
|
content: import_plugin_utils.Mustache.render(
|
|
163
187
|
`
|
|
164
|
-
|
|
165
|
-
import {
|
|
166
|
-
|
|
167
|
-
|
|
188
|
+
{{#withConfigProvider}}
|
|
189
|
+
import type { ConfigProviderProps } from 'antd/es/config-provider';
|
|
190
|
+
{{/withConfigProvider}}
|
|
191
|
+
{{#withAppConfig}}
|
|
192
|
+
import type { AppConfig } from 'antd/es/app/context';
|
|
193
|
+
{{/withAppConfig}}
|
|
168
194
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
prefixCls: \`\${finalConfig.prefixCls}-message\`
|
|
181
|
-
});
|
|
182
|
-
notification.config({
|
|
183
|
-
prefixCls: \`\${finalConfig.prefixCls}-notification\`
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
if (finalConfig.iconPrefixCls) {
|
|
187
|
-
// Icons in message need to set iconPrefixCls via ConfigProvider.config()
|
|
188
|
-
ConfigProvider.config({
|
|
189
|
-
iconPrefixCls: finalConfig.iconPrefixCls,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return <ConfigProvider {...finalConfig}>{container}</ConfigProvider>;
|
|
193
|
-
}
|
|
194
|
-
`.trim(),
|
|
195
|
+
type Prettify<T> = {
|
|
196
|
+
[K in keyof T]: T[K];
|
|
197
|
+
} & {};
|
|
198
|
+
|
|
199
|
+
type AntdConfig = Prettify<{}
|
|
200
|
+
{{#withConfigProvider}} & ConfigProviderProps{{/withConfigProvider}}
|
|
201
|
+
{{#withAppConfig}} & { appConfig: AppConfig }{{/withAppConfig}}
|
|
202
|
+
>;
|
|
203
|
+
|
|
204
|
+
export type RuntimeAntdConfig = (memo: AntdConfig) => AntdConfig;
|
|
205
|
+
`.trim(),
|
|
195
206
|
{
|
|
196
|
-
|
|
207
|
+
withConfigProvider,
|
|
208
|
+
withAppConfig
|
|
197
209
|
}
|
|
198
210
|
)
|
|
199
211
|
});
|
|
200
|
-
api.writeTmpFile({
|
|
201
|
-
path: "types.d.ts",
|
|
202
|
-
content: `
|
|
203
|
-
import type { ConfigProviderProps } from 'antd/es/config-provider';
|
|
204
|
-
export type RuntimeAntdConfig = (memo: ConfigProviderProps) => ConfigProviderProps;
|
|
205
|
-
`
|
|
206
|
-
});
|
|
207
212
|
api.writeTmpFile({
|
|
208
213
|
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
209
214
|
content: `
|
|
@@ -215,7 +220,10 @@ export type IRuntimeConfig = {
|
|
|
215
220
|
});
|
|
216
221
|
});
|
|
217
222
|
api.addRuntimePlugin(() => {
|
|
218
|
-
|
|
223
|
+
if (api.config.antd.configProvider || appComponentAvailable && api.config.antd.appConfig) {
|
|
224
|
+
return [(0, import_withTmpPath.withTmpPath)({ api, path: "runtime.tsx" })];
|
|
225
|
+
}
|
|
226
|
+
return [];
|
|
219
227
|
});
|
|
220
228
|
api.addEntryImportsAhead(() => {
|
|
221
229
|
const style = api.config.antd.style || "less";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20230315.1",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"styled-components": "6.0.0-beta.9",
|
|
43
43
|
"tslib": "^2",
|
|
44
44
|
"warning": "^4.0.3",
|
|
45
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
45
|
+
"@umijs/bundler-utils": "4.0.0-canary.20230315.1",
|
|
46
46
|
"@umijs/valtio": "1.0.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"antd": "^4.24.1",
|
|
50
|
-
"umi": "4.0.0-canary.
|
|
50
|
+
"umi": "4.0.0-canary.20230315.1"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
{{#configProvider}}
|
|
5
|
+
ConfigProvider,
|
|
6
|
+
{{/configProvider}}
|
|
7
|
+
{{#appConfig}}
|
|
8
|
+
App,
|
|
9
|
+
{{/appConfig}}
|
|
10
|
+
message,
|
|
11
|
+
notification,
|
|
12
|
+
} from 'antd';
|
|
13
|
+
import { ApplyPluginsType } from 'umi';
|
|
14
|
+
import { getPluginManager } from '../core/plugin';
|
|
15
|
+
|
|
16
|
+
export function rootContainer(rawContainer) {
|
|
17
|
+
const {
|
|
18
|
+
appConfig: finalAppConfig = {},
|
|
19
|
+
...finalConfigProvider
|
|
20
|
+
} = getPluginManager().applyPlugins({
|
|
21
|
+
key: 'antd',
|
|
22
|
+
type: ApplyPluginsType.modify,
|
|
23
|
+
initialValue: {
|
|
24
|
+
{{#configProvider}}
|
|
25
|
+
...{{{configProvider}}},
|
|
26
|
+
{{/configProvider}}
|
|
27
|
+
{{#appConfig}}
|
|
28
|
+
appConfig: {{{appConfig}}},
|
|
29
|
+
{{/appConfig}}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
let container = rawContainer;
|
|
34
|
+
|
|
35
|
+
{{#appConfig}}
|
|
36
|
+
// The App component should be under ConfigProvider
|
|
37
|
+
container = <App {...finalAppConfig}>{container}</App>;
|
|
38
|
+
{{/appConfig}}
|
|
39
|
+
|
|
40
|
+
{{#configProvider}}
|
|
41
|
+
if (finalConfigProvider.prefixCls) {
|
|
42
|
+
Modal.config({
|
|
43
|
+
rootPrefixCls: finalConfigProvider.prefixCls
|
|
44
|
+
});
|
|
45
|
+
message.config({
|
|
46
|
+
prefixCls: `${finalConfigProvider.prefixCls}-message`
|
|
47
|
+
});
|
|
48
|
+
notification.config({
|
|
49
|
+
prefixCls: `${finalConfigProvider.prefixCls}-notification`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (finalConfigProvider.iconPrefixCls) {
|
|
54
|
+
// Icons in message need to set iconPrefixCls via ConfigProvider.config()
|
|
55
|
+
ConfigProvider.config({
|
|
56
|
+
iconPrefixCls: finalConfigProvider.iconPrefixCls,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
container = <ConfigProvider {...finalConfigProvider}>{container}</ConfigProvider>;
|
|
60
|
+
{{/configProvider}}
|
|
61
|
+
|
|
62
|
+
return container;
|
|
63
|
+
}
|