@faasjs/ant-design 1.4.2 → 1.6.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/README.md +49 -1011
- package/dist/index.d.mts +55 -9
- package/dist/index.d.ts +55 -9
- package/dist/index.js +106 -68
- package/dist/index.mjs +109 -66
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -15,44 +15,59 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
15
15
|
var dayjs2__default = /*#__PURE__*/_interopDefault(dayjs2);
|
|
16
16
|
|
|
17
17
|
// src/index.ts
|
|
18
|
+
var Modal = antd.Modal;
|
|
19
|
+
Modal.whyDidYouRender = true;
|
|
18
20
|
function useModal(init) {
|
|
19
|
-
const [props, setProps] = react$1.useState({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const [props, setProps] = react$1.useState({ open: false, ...init });
|
|
22
|
+
const setModalProps2 = react$1.useCallback(
|
|
23
|
+
(changes) => {
|
|
24
|
+
const changed = typeof changes === "function" ? changes(props) : changes;
|
|
25
|
+
setProps((prev) => ({ ...prev, ...changed }));
|
|
26
|
+
},
|
|
27
|
+
[setProps]
|
|
28
|
+
);
|
|
27
29
|
return {
|
|
28
|
-
modal: /* @__PURE__ */ jsxRuntime.jsx(
|
|
30
|
+
modal: /* @__PURE__ */ jsxRuntime.jsx(
|
|
31
|
+
Modal,
|
|
32
|
+
{
|
|
33
|
+
onCancel: () => setProps((prev) => ({
|
|
34
|
+
...prev,
|
|
35
|
+
open: false
|
|
36
|
+
})),
|
|
37
|
+
...props
|
|
38
|
+
}
|
|
39
|
+
),
|
|
29
40
|
modalProps: props,
|
|
30
|
-
setModalProps
|
|
31
|
-
setProps((prev) => ({
|
|
32
|
-
...prev,
|
|
33
|
-
...changes
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
41
|
+
setModalProps: setModalProps2
|
|
36
42
|
};
|
|
37
43
|
}
|
|
44
|
+
var Drawer = antd.Drawer;
|
|
45
|
+
Drawer.whyDidYouRender = true;
|
|
38
46
|
function useDrawer(init) {
|
|
39
47
|
const [props, setProps] = react$1.useState({
|
|
40
48
|
open: false,
|
|
41
|
-
onClose: () => setProps((prev) => ({
|
|
42
|
-
...prev,
|
|
43
|
-
open: false
|
|
44
|
-
})),
|
|
45
49
|
...init
|
|
46
50
|
});
|
|
51
|
+
const setDrawerProps2 = react$1.useCallback(
|
|
52
|
+
(changes) => {
|
|
53
|
+
const changed = typeof changes === "function" ? changes(props) : changes;
|
|
54
|
+
setProps((prev) => ({ ...prev, ...changed }));
|
|
55
|
+
},
|
|
56
|
+
[setProps]
|
|
57
|
+
);
|
|
47
58
|
return {
|
|
48
|
-
drawer: /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
drawer: /* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
+
Drawer,
|
|
61
|
+
{
|
|
62
|
+
onClose: () => setProps((prev) => ({
|
|
63
|
+
...prev,
|
|
64
|
+
open: false
|
|
65
|
+
})),
|
|
66
|
+
...props
|
|
67
|
+
}
|
|
68
|
+
),
|
|
49
69
|
drawerProps: props,
|
|
50
|
-
setDrawerProps
|
|
51
|
-
setProps((prev) => ({
|
|
52
|
-
...prev,
|
|
53
|
-
...changes
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
70
|
+
setDrawerProps: setDrawerProps2
|
|
56
71
|
};
|
|
57
72
|
}
|
|
58
73
|
function ErrorChildren(props) {
|
|
@@ -77,6 +92,7 @@ function ErrorChildren(props) {
|
|
|
77
92
|
function ErrorBoundary(props) {
|
|
78
93
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ErrorBoundary, { errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}), ...props });
|
|
79
94
|
}
|
|
95
|
+
ErrorBoundary.whyDidYouRender = true;
|
|
80
96
|
var isZH = /^zh/i.test(navigator.language);
|
|
81
97
|
var zh = {
|
|
82
98
|
lang: "zh",
|
|
@@ -146,61 +162,78 @@ function ConfigProvider(props) {
|
|
|
146
162
|
function useConfigContext() {
|
|
147
163
|
return react$1.useContext(ConfigContext);
|
|
148
164
|
}
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
165
|
+
var MessageContext = react$1.createContext({});
|
|
166
|
+
var NotificationContext = react$1.createContext(
|
|
167
|
+
{}
|
|
168
|
+
);
|
|
169
|
+
var ModalPropsContext = react$1.createContext({});
|
|
170
|
+
var SetModalPropsContext = react$1.createContext(() => void 0);
|
|
171
|
+
var DrawerPropsContext = react$1.createContext({});
|
|
172
|
+
var SetDrawerPropsContext = react$1.createContext(() => void 0);
|
|
155
173
|
function RoutesApp(props) {
|
|
156
174
|
const location = reactRouterDom.useLocation();
|
|
157
|
-
const { setDrawerProps, setModalProps } = useApp();
|
|
175
|
+
const { drawerProps, setDrawerProps: setDrawerProps2, modalProps, setModalProps: setModalProps2 } = useApp();
|
|
158
176
|
react$1.useEffect(() => {
|
|
159
177
|
console.debug("location", location);
|
|
160
|
-
|
|
161
|
-
|
|
178
|
+
if (drawerProps.open)
|
|
179
|
+
setDrawerProps2({ open: false });
|
|
180
|
+
if (modalProps.open)
|
|
181
|
+
setModalProps2({ open: false });
|
|
162
182
|
}, [location]);
|
|
163
183
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
|
|
164
184
|
}
|
|
165
185
|
function App(props) {
|
|
166
186
|
const [messageApi, messageContextHolder] = antd.message.useMessage();
|
|
167
187
|
const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
|
|
168
|
-
const { modal, setModalProps } = useModal();
|
|
169
|
-
const { drawer, setDrawerProps } = useDrawer();
|
|
170
|
-
const
|
|
188
|
+
const { modal, modalProps, setModalProps: setModalProps2 } = useModal();
|
|
189
|
+
const { drawer, drawerProps, setDrawerProps: setDrawerProps2 } = useDrawer();
|
|
190
|
+
const styleProviderProps = react$1.useMemo(
|
|
171
191
|
() => ({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
setDrawerProps
|
|
192
|
+
...props.styleProviderProps,
|
|
193
|
+
hashPriority: "high",
|
|
194
|
+
transformers: [cssinjs.legacyLogicalPropertiesTransformer]
|
|
176
195
|
}),
|
|
177
|
-
[
|
|
178
|
-
);
|
|
179
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
180
|
-
cssinjs.StyleProvider,
|
|
181
|
-
{
|
|
182
|
-
...Object.assign(props.styleProviderProps || {}, {
|
|
183
|
-
hashPriority: "high",
|
|
184
|
-
transformers: [cssinjs.legacyLogicalPropertiesTransformer]
|
|
185
|
-
}),
|
|
186
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.BrowserRouter, { ...props.browserRouterProps, children: [
|
|
187
|
-
messageContextHolder,
|
|
188
|
-
notificationContextHolder,
|
|
189
|
-
modal,
|
|
190
|
-
drawer,
|
|
191
|
-
/* @__PURE__ */ jsxRuntime.jsx(RoutesApp, { children: props.children })
|
|
192
|
-
] }) }) }) }) })
|
|
193
|
-
}
|
|
196
|
+
[props.styleProviderProps]
|
|
194
197
|
);
|
|
198
|
+
return /* @__PURE__ */ jsxRuntime.jsx(cssinjs.StyleProvider, { ...styleProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(MessageContext.Provider, { value: messageApi, children: /* @__PURE__ */ jsxRuntime.jsx(NotificationContext.Provider, { value: notificationApi, children: /* @__PURE__ */ jsxRuntime.jsx(DrawerPropsContext.Provider, { value: drawerProps, children: /* @__PURE__ */ jsxRuntime.jsx(SetDrawerPropsContext.Provider, { value: setDrawerProps2, children: /* @__PURE__ */ jsxRuntime.jsx(ModalPropsContext.Provider, { value: modalProps, children: /* @__PURE__ */ jsxRuntime.jsx(SetModalPropsContext.Provider, { value: setModalProps2, children: /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.BrowserRouter, { ...props.browserRouterProps, children: [
|
|
199
|
+
messageContextHolder,
|
|
200
|
+
notificationContextHolder,
|
|
201
|
+
modal,
|
|
202
|
+
drawer,
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsx(RoutesApp, { children: props.children })
|
|
204
|
+
] }) }) }) }) }) }) }) }) }) }) });
|
|
195
205
|
}
|
|
196
206
|
function useApp() {
|
|
197
|
-
return react
|
|
207
|
+
return react.useConstant(() => {
|
|
208
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
209
|
+
Object.defineProperty(obj, "message", {
|
|
210
|
+
get: () => react$1.useContext(MessageContext)
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(obj, "notification", {
|
|
213
|
+
get: () => react$1.useContext(NotificationContext)
|
|
214
|
+
});
|
|
215
|
+
Object.defineProperty(obj, "modalProps", {
|
|
216
|
+
get: () => react$1.useContext(ModalPropsContext)
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(obj, "setModalProps", {
|
|
219
|
+
get: () => react$1.useContext(SetModalPropsContext)
|
|
220
|
+
});
|
|
221
|
+
Object.defineProperty(obj, "drawerProps", {
|
|
222
|
+
get: () => react$1.useContext(DrawerPropsContext)
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(obj, "setDrawerProps", {
|
|
225
|
+
get: () => react$1.useContext(SetDrawerPropsContext)
|
|
226
|
+
});
|
|
227
|
+
return Object.freeze(obj);
|
|
228
|
+
});
|
|
198
229
|
}
|
|
199
230
|
App.useApp = useApp;
|
|
231
|
+
App.whyDidYouRender = true;
|
|
200
232
|
function Blank(options) {
|
|
201
233
|
const { theme } = useConfigContext();
|
|
202
234
|
return !options || lodashEs.isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || theme.Blank.text }) : options.value;
|
|
203
235
|
}
|
|
236
|
+
Blank.whyDidYouRender = true;
|
|
204
237
|
function transferOptions(options) {
|
|
205
238
|
if (!options)
|
|
206
239
|
return [];
|
|
@@ -263,6 +296,7 @@ function Loading(props) {
|
|
|
263
296
|
}
|
|
264
297
|
);
|
|
265
298
|
}
|
|
299
|
+
Loading.whyDidYouRender = true;
|
|
266
300
|
function FaasDataWrapper(props) {
|
|
267
301
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
268
302
|
react.FaasDataWrapper,
|
|
@@ -272,6 +306,7 @@ function FaasDataWrapper(props) {
|
|
|
272
306
|
}
|
|
273
307
|
);
|
|
274
308
|
}
|
|
309
|
+
FaasDataWrapper.whyDidYouRender = true;
|
|
275
310
|
function DescriptionItemContent(props) {
|
|
276
311
|
var _a, _b;
|
|
277
312
|
const [computedProps, setComputedProps] = react$1.useState();
|
|
@@ -410,6 +445,7 @@ function DescriptionItemContent(props) {
|
|
|
410
445
|
return computedProps.value || null;
|
|
411
446
|
}
|
|
412
447
|
}
|
|
448
|
+
DescriptionItemContent.whyDidYouRender = true;
|
|
413
449
|
function Description(props) {
|
|
414
450
|
if (props.faasData && !props.dataSource)
|
|
415
451
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -441,6 +477,7 @@ function Description(props) {
|
|
|
441
477
|
}
|
|
442
478
|
);
|
|
443
479
|
}
|
|
480
|
+
Description.whyDidYouRender = true;
|
|
444
481
|
function processProps(propsCopy, config) {
|
|
445
482
|
if (!propsCopy.title)
|
|
446
483
|
propsCopy.title = lodashEs.upperFirst(propsCopy.id);
|
|
@@ -732,6 +769,7 @@ function FormItem(props) {
|
|
|
732
769
|
return null;
|
|
733
770
|
}
|
|
734
771
|
}
|
|
772
|
+
FormItem.whyDidYouRender = true;
|
|
735
773
|
FormItem.useStatus = antd.Form.Item.useStatus;
|
|
736
774
|
function Form(props) {
|
|
737
775
|
var _a, _b;
|
|
@@ -861,6 +899,7 @@ function Form(props) {
|
|
|
861
899
|
computedProps.footer
|
|
862
900
|
] });
|
|
863
901
|
}
|
|
902
|
+
Form.whyDidYouRender = true;
|
|
864
903
|
Form.useForm = antd.Form.useForm;
|
|
865
904
|
Form.useFormInstance = antd.Form.useFormInstance;
|
|
866
905
|
Form.useWatch = antd.Form.useWatch;
|
|
@@ -970,6 +1009,7 @@ function Link(props) {
|
|
|
970
1009
|
}
|
|
971
1010
|
);
|
|
972
1011
|
}
|
|
1012
|
+
Link.whyDidYouRender = true;
|
|
973
1013
|
function PageNotFound() {
|
|
974
1014
|
const { theme } = useConfigContext();
|
|
975
1015
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "404", title: theme.common.pageNotFound });
|
|
@@ -993,6 +1033,7 @@ function Routes(props) {
|
|
|
993
1033
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: props.notFound || /* @__PURE__ */ jsxRuntime.jsx(PageNotFound, {}) }, "*")
|
|
994
1034
|
] });
|
|
995
1035
|
}
|
|
1036
|
+
Routes.whyDidYouRender = true;
|
|
996
1037
|
function processValue(item, value) {
|
|
997
1038
|
var _a;
|
|
998
1039
|
const transferred = transferValue(item.type, value);
|
|
@@ -1591,6 +1632,7 @@ function FaasDataTable({
|
|
|
1591
1632
|
}
|
|
1592
1633
|
);
|
|
1593
1634
|
}
|
|
1635
|
+
Table.whyDidYouRender = true;
|
|
1594
1636
|
function Tabs(props) {
|
|
1595
1637
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1596
1638
|
antd.Tabs,
|
|
@@ -1604,6 +1646,7 @@ function Tabs(props) {
|
|
|
1604
1646
|
}
|
|
1605
1647
|
);
|
|
1606
1648
|
}
|
|
1649
|
+
Tabs.whyDidYouRender = true;
|
|
1607
1650
|
function Title(props) {
|
|
1608
1651
|
const { theme } = useConfigContext();
|
|
1609
1652
|
react$1.useEffect(() => {
|
|
@@ -1621,6 +1664,7 @@ function Title(props) {
|
|
|
1621
1664
|
return react$1.cloneElement(props.children, { title: props.title });
|
|
1622
1665
|
return null;
|
|
1623
1666
|
}
|
|
1667
|
+
Title.whyDidYouRender = true;
|
|
1624
1668
|
|
|
1625
1669
|
Object.defineProperty(exports, "faas", {
|
|
1626
1670
|
enumerable: true,
|
|
@@ -1630,14 +1674,6 @@ Object.defineProperty(exports, "useFaas", {
|
|
|
1630
1674
|
enumerable: true,
|
|
1631
1675
|
get: function () { return react.useFaas; }
|
|
1632
1676
|
});
|
|
1633
|
-
Object.defineProperty(exports, "Drawer", {
|
|
1634
|
-
enumerable: true,
|
|
1635
|
-
get: function () { return antd.Drawer; }
|
|
1636
|
-
});
|
|
1637
|
-
Object.defineProperty(exports, "Modal", {
|
|
1638
|
-
enumerable: true,
|
|
1639
|
-
get: function () { return antd.Modal; }
|
|
1640
|
-
});
|
|
1641
1677
|
Object.defineProperty(exports, "lazy", {
|
|
1642
1678
|
enumerable: true,
|
|
1643
1679
|
get: function () { return react$1.lazy; }
|
|
@@ -1647,12 +1683,14 @@ exports.Blank = Blank;
|
|
|
1647
1683
|
exports.ConfigContext = ConfigContext;
|
|
1648
1684
|
exports.ConfigProvider = ConfigProvider;
|
|
1649
1685
|
exports.Description = Description;
|
|
1686
|
+
exports.Drawer = Drawer;
|
|
1650
1687
|
exports.ErrorBoundary = ErrorBoundary;
|
|
1651
1688
|
exports.FaasDataWrapper = FaasDataWrapper;
|
|
1652
1689
|
exports.Form = Form;
|
|
1653
1690
|
exports.FormItem = FormItem;
|
|
1654
1691
|
exports.Link = Link;
|
|
1655
1692
|
exports.Loading = Loading;
|
|
1693
|
+
exports.Modal = Modal;
|
|
1656
1694
|
exports.PageNotFound = PageNotFound;
|
|
1657
1695
|
exports.Routes = Routes;
|
|
1658
1696
|
exports.Table = Table;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ErrorBoundary as ErrorBoundary$1, FaasReactClient, FaasDataWrapper as FaasDataWrapper$1, faas } from '@faasjs/react';
|
|
1
|
+
import { ErrorBoundary as ErrorBoundary$1, FaasReactClient, useConstant, FaasDataWrapper as FaasDataWrapper$1, faas } from '@faasjs/react';
|
|
2
2
|
export { faas, useFaas } from '@faasjs/react';
|
|
3
|
-
import { Form as Form$1, Modal, Drawer, message, notification, ConfigProvider as ConfigProvider$1, Typography, Spin, Descriptions, Input, Button, Row, Col, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1, Alert, Space } from 'antd';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import { createContext, useState, useEffect, useContext, useMemo, cloneElement, useCallback, isValidElement, Suspense } from 'react';
|
|
3
|
+
import { Form as Form$1, Modal as Modal$1, Drawer as Drawer$1, message, notification, ConfigProvider as ConfigProvider$1, Typography, Spin, Descriptions, Input, Button, Row, Col, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1, Alert, Space } from 'antd';
|
|
4
|
+
import { legacyLogicalPropertiesTransformer, StyleProvider } from '@ant-design/cssinjs';
|
|
5
|
+
import { createContext, useState, useCallback, useEffect, useContext, useMemo, cloneElement, isValidElement, Suspense } from 'react';
|
|
7
6
|
export { lazy } from 'react';
|
|
8
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
8
|
import { BrowserRouter, useNavigate, Link as Link$1, Routes as Routes$1, Route, useLocation } from 'react-router-dom';
|
|
@@ -12,44 +11,59 @@ import dayjs2 from 'dayjs';
|
|
|
12
11
|
import { PlusOutlined, MinusCircleOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons';
|
|
13
12
|
|
|
14
13
|
// src/index.ts
|
|
14
|
+
var Modal = Modal$1;
|
|
15
|
+
Modal.whyDidYouRender = true;
|
|
15
16
|
function useModal(init) {
|
|
16
|
-
const [props, setProps] = useState({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const [props, setProps] = useState({ open: false, ...init });
|
|
18
|
+
const setModalProps2 = useCallback(
|
|
19
|
+
(changes) => {
|
|
20
|
+
const changed = typeof changes === "function" ? changes(props) : changes;
|
|
21
|
+
setProps((prev) => ({ ...prev, ...changed }));
|
|
22
|
+
},
|
|
23
|
+
[setProps]
|
|
24
|
+
);
|
|
24
25
|
return {
|
|
25
|
-
modal: /* @__PURE__ */ jsx(
|
|
26
|
+
modal: /* @__PURE__ */ jsx(
|
|
27
|
+
Modal,
|
|
28
|
+
{
|
|
29
|
+
onCancel: () => setProps((prev) => ({
|
|
30
|
+
...prev,
|
|
31
|
+
open: false
|
|
32
|
+
})),
|
|
33
|
+
...props
|
|
34
|
+
}
|
|
35
|
+
),
|
|
26
36
|
modalProps: props,
|
|
27
|
-
setModalProps
|
|
28
|
-
setProps((prev) => ({
|
|
29
|
-
...prev,
|
|
30
|
-
...changes
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
37
|
+
setModalProps: setModalProps2
|
|
33
38
|
};
|
|
34
39
|
}
|
|
40
|
+
var Drawer = Drawer$1;
|
|
41
|
+
Drawer.whyDidYouRender = true;
|
|
35
42
|
function useDrawer(init) {
|
|
36
43
|
const [props, setProps] = useState({
|
|
37
44
|
open: false,
|
|
38
|
-
onClose: () => setProps((prev) => ({
|
|
39
|
-
...prev,
|
|
40
|
-
open: false
|
|
41
|
-
})),
|
|
42
45
|
...init
|
|
43
46
|
});
|
|
47
|
+
const setDrawerProps2 = useCallback(
|
|
48
|
+
(changes) => {
|
|
49
|
+
const changed = typeof changes === "function" ? changes(props) : changes;
|
|
50
|
+
setProps((prev) => ({ ...prev, ...changed }));
|
|
51
|
+
},
|
|
52
|
+
[setProps]
|
|
53
|
+
);
|
|
44
54
|
return {
|
|
45
|
-
drawer: /* @__PURE__ */ jsx(
|
|
55
|
+
drawer: /* @__PURE__ */ jsx(
|
|
56
|
+
Drawer,
|
|
57
|
+
{
|
|
58
|
+
onClose: () => setProps((prev) => ({
|
|
59
|
+
...prev,
|
|
60
|
+
open: false
|
|
61
|
+
})),
|
|
62
|
+
...props
|
|
63
|
+
}
|
|
64
|
+
),
|
|
46
65
|
drawerProps: props,
|
|
47
|
-
setDrawerProps
|
|
48
|
-
setProps((prev) => ({
|
|
49
|
-
...prev,
|
|
50
|
-
...changes
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
66
|
+
setDrawerProps: setDrawerProps2
|
|
53
67
|
};
|
|
54
68
|
}
|
|
55
69
|
function ErrorChildren(props) {
|
|
@@ -74,6 +88,7 @@ function ErrorChildren(props) {
|
|
|
74
88
|
function ErrorBoundary(props) {
|
|
75
89
|
return /* @__PURE__ */ jsx(ErrorBoundary$1, { errorChildren: /* @__PURE__ */ jsx(ErrorChildren, {}), ...props });
|
|
76
90
|
}
|
|
91
|
+
ErrorBoundary.whyDidYouRender = true;
|
|
77
92
|
var isZH = /^zh/i.test(navigator.language);
|
|
78
93
|
var zh = {
|
|
79
94
|
lang: "zh",
|
|
@@ -143,61 +158,78 @@ function ConfigProvider(props) {
|
|
|
143
158
|
function useConfigContext() {
|
|
144
159
|
return useContext(ConfigContext);
|
|
145
160
|
}
|
|
146
|
-
var
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
var MessageContext = createContext({});
|
|
162
|
+
var NotificationContext = createContext(
|
|
163
|
+
{}
|
|
164
|
+
);
|
|
165
|
+
var ModalPropsContext = createContext({});
|
|
166
|
+
var SetModalPropsContext = createContext(() => void 0);
|
|
167
|
+
var DrawerPropsContext = createContext({});
|
|
168
|
+
var SetDrawerPropsContext = createContext(() => void 0);
|
|
152
169
|
function RoutesApp(props) {
|
|
153
170
|
const location = useLocation();
|
|
154
|
-
const { setDrawerProps, setModalProps } = useApp();
|
|
171
|
+
const { drawerProps, setDrawerProps: setDrawerProps2, modalProps, setModalProps: setModalProps2 } = useApp();
|
|
155
172
|
useEffect(() => {
|
|
156
173
|
console.debug("location", location);
|
|
157
|
-
|
|
158
|
-
|
|
174
|
+
if (drawerProps.open)
|
|
175
|
+
setDrawerProps2({ open: false });
|
|
176
|
+
if (modalProps.open)
|
|
177
|
+
setModalProps2({ open: false });
|
|
159
178
|
}, [location]);
|
|
160
179
|
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
161
180
|
}
|
|
162
181
|
function App(props) {
|
|
163
182
|
const [messageApi, messageContextHolder] = message.useMessage();
|
|
164
183
|
const [notificationApi, notificationContextHolder] = notification.useNotification();
|
|
165
|
-
const { modal, setModalProps } = useModal();
|
|
166
|
-
const { drawer, setDrawerProps } = useDrawer();
|
|
167
|
-
const
|
|
184
|
+
const { modal, modalProps, setModalProps: setModalProps2 } = useModal();
|
|
185
|
+
const { drawer, drawerProps, setDrawerProps: setDrawerProps2 } = useDrawer();
|
|
186
|
+
const styleProviderProps = useMemo(
|
|
168
187
|
() => ({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
setDrawerProps
|
|
188
|
+
...props.styleProviderProps,
|
|
189
|
+
hashPriority: "high",
|
|
190
|
+
transformers: [legacyLogicalPropertiesTransformer]
|
|
173
191
|
}),
|
|
174
|
-
[
|
|
175
|
-
);
|
|
176
|
-
return /* @__PURE__ */ jsx(
|
|
177
|
-
StyleProvider,
|
|
178
|
-
{
|
|
179
|
-
...Object.assign(props.styleProviderProps || {}, {
|
|
180
|
-
hashPriority: "high",
|
|
181
|
-
transformers: [legacyLogicalPropertiesTransformer]
|
|
182
|
-
}),
|
|
183
|
-
children: /* @__PURE__ */ jsx(ConfigProvider$1, { ...props.configProviderProps, children: /* @__PURE__ */ jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxs(BrowserRouter, { ...props.browserRouterProps, children: [
|
|
184
|
-
messageContextHolder,
|
|
185
|
-
notificationContextHolder,
|
|
186
|
-
modal,
|
|
187
|
-
drawer,
|
|
188
|
-
/* @__PURE__ */ jsx(RoutesApp, { children: props.children })
|
|
189
|
-
] }) }) }) }) })
|
|
190
|
-
}
|
|
192
|
+
[props.styleProviderProps]
|
|
191
193
|
);
|
|
194
|
+
return /* @__PURE__ */ jsx(StyleProvider, { ...styleProviderProps, children: /* @__PURE__ */ jsx(ConfigProvider$1, { ...props.configProviderProps, children: /* @__PURE__ */ jsx(MessageContext.Provider, { value: messageApi, children: /* @__PURE__ */ jsx(NotificationContext.Provider, { value: notificationApi, children: /* @__PURE__ */ jsx(DrawerPropsContext.Provider, { value: drawerProps, children: /* @__PURE__ */ jsx(SetDrawerPropsContext.Provider, { value: setDrawerProps2, children: /* @__PURE__ */ jsx(ModalPropsContext.Provider, { value: modalProps, children: /* @__PURE__ */ jsx(SetModalPropsContext.Provider, { value: setModalProps2, children: /* @__PURE__ */ jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxs(BrowserRouter, { ...props.browserRouterProps, children: [
|
|
195
|
+
messageContextHolder,
|
|
196
|
+
notificationContextHolder,
|
|
197
|
+
modal,
|
|
198
|
+
drawer,
|
|
199
|
+
/* @__PURE__ */ jsx(RoutesApp, { children: props.children })
|
|
200
|
+
] }) }) }) }) }) }) }) }) }) }) });
|
|
192
201
|
}
|
|
193
202
|
function useApp() {
|
|
194
|
-
return
|
|
203
|
+
return useConstant(() => {
|
|
204
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
205
|
+
Object.defineProperty(obj, "message", {
|
|
206
|
+
get: () => useContext(MessageContext)
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(obj, "notification", {
|
|
209
|
+
get: () => useContext(NotificationContext)
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(obj, "modalProps", {
|
|
212
|
+
get: () => useContext(ModalPropsContext)
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(obj, "setModalProps", {
|
|
215
|
+
get: () => useContext(SetModalPropsContext)
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(obj, "drawerProps", {
|
|
218
|
+
get: () => useContext(DrawerPropsContext)
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(obj, "setDrawerProps", {
|
|
221
|
+
get: () => useContext(SetDrawerPropsContext)
|
|
222
|
+
});
|
|
223
|
+
return Object.freeze(obj);
|
|
224
|
+
});
|
|
195
225
|
}
|
|
196
226
|
App.useApp = useApp;
|
|
227
|
+
App.whyDidYouRender = true;
|
|
197
228
|
function Blank(options) {
|
|
198
229
|
const { theme } = useConfigContext();
|
|
199
230
|
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || theme.Blank.text }) : options.value;
|
|
200
231
|
}
|
|
232
|
+
Blank.whyDidYouRender = true;
|
|
201
233
|
function transferOptions(options) {
|
|
202
234
|
if (!options)
|
|
203
235
|
return [];
|
|
@@ -260,6 +292,7 @@ function Loading(props) {
|
|
|
260
292
|
}
|
|
261
293
|
);
|
|
262
294
|
}
|
|
295
|
+
Loading.whyDidYouRender = true;
|
|
263
296
|
function FaasDataWrapper(props) {
|
|
264
297
|
return /* @__PURE__ */ jsx(
|
|
265
298
|
FaasDataWrapper$1,
|
|
@@ -269,6 +302,7 @@ function FaasDataWrapper(props) {
|
|
|
269
302
|
}
|
|
270
303
|
);
|
|
271
304
|
}
|
|
305
|
+
FaasDataWrapper.whyDidYouRender = true;
|
|
272
306
|
function DescriptionItemContent(props) {
|
|
273
307
|
var _a, _b;
|
|
274
308
|
const [computedProps, setComputedProps] = useState();
|
|
@@ -407,6 +441,7 @@ function DescriptionItemContent(props) {
|
|
|
407
441
|
return computedProps.value || null;
|
|
408
442
|
}
|
|
409
443
|
}
|
|
444
|
+
DescriptionItemContent.whyDidYouRender = true;
|
|
410
445
|
function Description(props) {
|
|
411
446
|
if (props.faasData && !props.dataSource)
|
|
412
447
|
return /* @__PURE__ */ jsx(
|
|
@@ -438,6 +473,7 @@ function Description(props) {
|
|
|
438
473
|
}
|
|
439
474
|
);
|
|
440
475
|
}
|
|
476
|
+
Description.whyDidYouRender = true;
|
|
441
477
|
function processProps(propsCopy, config) {
|
|
442
478
|
if (!propsCopy.title)
|
|
443
479
|
propsCopy.title = upperFirst(propsCopy.id);
|
|
@@ -729,6 +765,7 @@ function FormItem(props) {
|
|
|
729
765
|
return null;
|
|
730
766
|
}
|
|
731
767
|
}
|
|
768
|
+
FormItem.whyDidYouRender = true;
|
|
732
769
|
FormItem.useStatus = Form$1.Item.useStatus;
|
|
733
770
|
function Form(props) {
|
|
734
771
|
var _a, _b;
|
|
@@ -858,6 +895,7 @@ function Form(props) {
|
|
|
858
895
|
computedProps.footer
|
|
859
896
|
] });
|
|
860
897
|
}
|
|
898
|
+
Form.whyDidYouRender = true;
|
|
861
899
|
Form.useForm = Form$1.useForm;
|
|
862
900
|
Form.useFormInstance = Form$1.useFormInstance;
|
|
863
901
|
Form.useWatch = Form$1.useWatch;
|
|
@@ -967,6 +1005,7 @@ function Link(props) {
|
|
|
967
1005
|
}
|
|
968
1006
|
);
|
|
969
1007
|
}
|
|
1008
|
+
Link.whyDidYouRender = true;
|
|
970
1009
|
function PageNotFound() {
|
|
971
1010
|
const { theme } = useConfigContext();
|
|
972
1011
|
return /* @__PURE__ */ jsx(Result, { status: "404", title: theme.common.pageNotFound });
|
|
@@ -990,6 +1029,7 @@ function Routes(props) {
|
|
|
990
1029
|
/* @__PURE__ */ jsx(Route, { path: "*", element: props.notFound || /* @__PURE__ */ jsx(PageNotFound, {}) }, "*")
|
|
991
1030
|
] });
|
|
992
1031
|
}
|
|
1032
|
+
Routes.whyDidYouRender = true;
|
|
993
1033
|
function processValue(item, value) {
|
|
994
1034
|
var _a;
|
|
995
1035
|
const transferred = transferValue(item.type, value);
|
|
@@ -1588,6 +1628,7 @@ function FaasDataTable({
|
|
|
1588
1628
|
}
|
|
1589
1629
|
);
|
|
1590
1630
|
}
|
|
1631
|
+
Table.whyDidYouRender = true;
|
|
1591
1632
|
function Tabs(props) {
|
|
1592
1633
|
return /* @__PURE__ */ jsx(
|
|
1593
1634
|
Tabs$1,
|
|
@@ -1601,6 +1642,7 @@ function Tabs(props) {
|
|
|
1601
1642
|
}
|
|
1602
1643
|
);
|
|
1603
1644
|
}
|
|
1645
|
+
Tabs.whyDidYouRender = true;
|
|
1604
1646
|
function Title(props) {
|
|
1605
1647
|
const { theme } = useConfigContext();
|
|
1606
1648
|
useEffect(() => {
|
|
@@ -1618,5 +1660,6 @@ function Title(props) {
|
|
|
1618
1660
|
return cloneElement(props.children, { title: props.title });
|
|
1619
1661
|
return null;
|
|
1620
1662
|
}
|
|
1663
|
+
Title.whyDidYouRender = true;
|
|
1621
1664
|
|
|
1622
|
-
export { App, Blank, ConfigContext, ConfigProvider, Description, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, PageNotFound, Routes, Table, Tabs, Title, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useModal };
|
|
1665
|
+
export { App, Blank, ConfigContext, ConfigProvider, Description, Drawer, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, Modal, PageNotFound, Routes, Table, Tabs, Title, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useModal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lodash-es": "*"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@faasjs/react": "1.
|
|
29
|
+
"@faasjs/react": "1.6.0",
|
|
30
30
|
"antd": "*",
|
|
31
31
|
"react": "*",
|
|
32
32
|
"react-dom": "*",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"@testing-library/jest-dom": "*",
|
|
38
38
|
"@testing-library/react": "*",
|
|
39
39
|
"@testing-library/user-event": "*",
|
|
40
|
-
"@
|
|
40
|
+
"@welldone-software/why-did-you-render": "*",
|
|
41
|
+
"@faasjs/react": "1.6.0",
|
|
41
42
|
"antd": "*",
|
|
42
43
|
"react": "*",
|
|
43
44
|
"react-dom": "*",
|