@faasjs/ant-design 1.4.2 → 1.5.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/dist/index.mjs CHANGED
@@ -1,9 +1,8 @@
1
1
  import { ErrorBoundary as ErrorBoundary$1, FaasReactClient, 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
- export { Drawer, Modal } from 'antd';
5
- import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs';
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, useMemo, useEffect, useContext, 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,26 +11,37 @@ 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
- open: false,
18
- onCancel: () => setProps((prev) => ({
17
+ const [props, setProps] = useState({ open: false, ...init });
18
+ const onCancel = useCallback(() => {
19
+ setProps((prev) => ({
19
20
  ...prev,
20
21
  open: false
21
- })),
22
- ...init
23
- });
24
- return {
25
- modal: /* @__PURE__ */ jsx(Modal, { ...props }),
26
- modalProps: props,
27
- setModalProps(changes) {
22
+ }));
23
+ }, []);
24
+ const modal = useMemo(() => /* @__PURE__ */ jsx(Modal, { onCancel, ...props }), [props]);
25
+ const setModalProps = useCallback((changes) => {
26
+ if (typeof changes === "function") {
28
27
  setProps((prev) => ({
29
28
  ...prev,
30
- ...changes
29
+ ...changes(props)
31
30
  }));
31
+ return;
32
32
  }
33
+ setProps((prev) => ({
34
+ ...prev,
35
+ ...changes
36
+ }));
37
+ }, []);
38
+ return {
39
+ modal,
40
+ modalProps: props,
41
+ setModalProps
33
42
  };
34
43
  }
44
+ var Drawer = Drawer$1;
35
45
  function useDrawer(init) {
36
46
  const [props, setProps] = useState({
37
47
  open: false,
@@ -45,6 +55,13 @@ function useDrawer(init) {
45
55
  drawer: /* @__PURE__ */ jsx(Drawer, { ...props }),
46
56
  drawerProps: props,
47
57
  setDrawerProps(changes) {
58
+ if (typeof changes === "function") {
59
+ setProps((prev) => ({
60
+ ...prev,
61
+ ...changes(props)
62
+ }));
63
+ return;
64
+ }
48
65
  setProps((prev) => ({
49
66
  ...prev,
50
67
  ...changes
@@ -52,6 +69,7 @@ function useDrawer(init) {
52
69
  }
53
70
  };
54
71
  }
72
+ Drawer.whyDidYouRender = true;
55
73
  function ErrorChildren(props) {
56
74
  return /* @__PURE__ */ jsx(
57
75
  Alert,
@@ -74,6 +92,7 @@ function ErrorChildren(props) {
74
92
  function ErrorBoundary(props) {
75
93
  return /* @__PURE__ */ jsx(ErrorBoundary$1, { errorChildren: /* @__PURE__ */ jsx(ErrorChildren, {}), ...props });
76
94
  }
95
+ ErrorBoundary.whyDidYouRender = true;
77
96
  var isZH = /^zh/i.test(navigator.language);
78
97
  var zh = {
79
98
  lang: "zh",
@@ -162,7 +181,7 @@ function RoutesApp(props) {
162
181
  function App(props) {
163
182
  const [messageApi, messageContextHolder] = message.useMessage();
164
183
  const [notificationApi, notificationContextHolder] = notification.useNotification();
165
- const { modal, setModalProps } = useModal();
184
+ const { modal, modalProps, setModalProps } = useModal();
166
185
  const { drawer, setDrawerProps } = useDrawer();
167
186
  const memoizedContextValue = useMemo(
168
187
  () => ({
@@ -173,31 +192,32 @@ function App(props) {
173
192
  }),
174
193
  [messageApi, notificationApi, setModalProps, setDrawerProps]
175
194
  );
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
- }
195
+ const styleProviderProps = useMemo(
196
+ () => ({
197
+ ...props.styleProviderProps,
198
+ hashPriority: "high",
199
+ transformers: [legacyLogicalPropertiesTransformer]
200
+ }),
201
+ [props.styleProviderProps]
191
202
  );
203
+ return /* @__PURE__ */ jsx(StyleProvider, { ...styleProviderProps, 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: [
204
+ messageContextHolder,
205
+ notificationContextHolder,
206
+ modal,
207
+ drawer,
208
+ /* @__PURE__ */ jsx(RoutesApp, { children: props.children })
209
+ ] }) }) }) }) }) });
192
210
  }
193
211
  function useApp() {
194
212
  return useContext(AppContext);
195
213
  }
196
214
  App.useApp = useApp;
215
+ App.whyDidYouRender = true;
197
216
  function Blank(options) {
198
217
  const { theme } = useConfigContext();
199
218
  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
219
  }
220
+ Blank.whyDidYouRender = true;
201
221
  function transferOptions(options) {
202
222
  if (!options)
203
223
  return [];
@@ -260,6 +280,7 @@ function Loading(props) {
260
280
  }
261
281
  );
262
282
  }
283
+ Loading.whyDidYouRender = true;
263
284
  function FaasDataWrapper(props) {
264
285
  return /* @__PURE__ */ jsx(
265
286
  FaasDataWrapper$1,
@@ -269,6 +290,7 @@ function FaasDataWrapper(props) {
269
290
  }
270
291
  );
271
292
  }
293
+ FaasDataWrapper.whyDidYouRender = true;
272
294
  function DescriptionItemContent(props) {
273
295
  var _a, _b;
274
296
  const [computedProps, setComputedProps] = useState();
@@ -407,6 +429,7 @@ function DescriptionItemContent(props) {
407
429
  return computedProps.value || null;
408
430
  }
409
431
  }
432
+ DescriptionItemContent.whyDidYouRender = true;
410
433
  function Description(props) {
411
434
  if (props.faasData && !props.dataSource)
412
435
  return /* @__PURE__ */ jsx(
@@ -438,6 +461,7 @@ function Description(props) {
438
461
  }
439
462
  );
440
463
  }
464
+ Description.whyDidYouRender = true;
441
465
  function processProps(propsCopy, config) {
442
466
  if (!propsCopy.title)
443
467
  propsCopy.title = upperFirst(propsCopy.id);
@@ -729,6 +753,7 @@ function FormItem(props) {
729
753
  return null;
730
754
  }
731
755
  }
756
+ FormItem.whyDidYouRender = true;
732
757
  FormItem.useStatus = Form$1.Item.useStatus;
733
758
  function Form(props) {
734
759
  var _a, _b;
@@ -858,6 +883,7 @@ function Form(props) {
858
883
  computedProps.footer
859
884
  ] });
860
885
  }
886
+ Form.whyDidYouRender = true;
861
887
  Form.useForm = Form$1.useForm;
862
888
  Form.useFormInstance = Form$1.useFormInstance;
863
889
  Form.useWatch = Form$1.useWatch;
@@ -967,6 +993,7 @@ function Link(props) {
967
993
  }
968
994
  );
969
995
  }
996
+ Link.whyDidYouRender = true;
970
997
  function PageNotFound() {
971
998
  const { theme } = useConfigContext();
972
999
  return /* @__PURE__ */ jsx(Result, { status: "404", title: theme.common.pageNotFound });
@@ -990,6 +1017,7 @@ function Routes(props) {
990
1017
  /* @__PURE__ */ jsx(Route, { path: "*", element: props.notFound || /* @__PURE__ */ jsx(PageNotFound, {}) }, "*")
991
1018
  ] });
992
1019
  }
1020
+ Routes.whyDidYouRender = true;
993
1021
  function processValue(item, value) {
994
1022
  var _a;
995
1023
  const transferred = transferValue(item.type, value);
@@ -1588,6 +1616,7 @@ function FaasDataTable({
1588
1616
  }
1589
1617
  );
1590
1618
  }
1619
+ Table.whyDidYouRender = true;
1591
1620
  function Tabs(props) {
1592
1621
  return /* @__PURE__ */ jsx(
1593
1622
  Tabs$1,
@@ -1601,6 +1630,7 @@ function Tabs(props) {
1601
1630
  }
1602
1631
  );
1603
1632
  }
1633
+ Tabs.whyDidYouRender = true;
1604
1634
  function Title(props) {
1605
1635
  const { theme } = useConfigContext();
1606
1636
  useEffect(() => {
@@ -1618,5 +1648,6 @@ function Title(props) {
1618
1648
  return cloneElement(props.children, { title: props.title });
1619
1649
  return null;
1620
1650
  }
1651
+ Title.whyDidYouRender = true;
1621
1652
 
1622
- export { App, Blank, ConfigContext, ConfigProvider, Description, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, PageNotFound, Routes, Table, Tabs, Title, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useModal };
1653
+ 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.4.2",
3
+ "version": "1.5.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.4.2",
29
+ "@faasjs/react": "1.5.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
- "@faasjs/react": "1.4.2",
40
+ "@welldone-software/why-did-you-render": "*",
41
+ "@faasjs/react": "1.5.0",
41
42
  "antd": "*",
42
43
  "react": "*",
43
44
  "react-dom": "*",