@faasjs/ant-design 2.0.0 → 2.2.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.d.mts CHANGED
@@ -18,7 +18,7 @@ import { RuleObject } from 'rc-field-form/lib/interface';
18
18
  import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
19
19
  import * as antd_es_form_context from 'antd/es/form/context';
20
20
  import * as antd_es_form from 'antd/es/form';
21
- import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
21
+ import * as rc_field_form from 'rc-field-form';
22
22
  import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
23
23
  import * as antd_es_form_Form from 'antd/es/form/Form';
24
24
  import { Tab } from 'rc-tabs/es/interface';
@@ -159,9 +159,9 @@ interface useAppProps {
159
159
  message: MessageInstance;
160
160
  notification: NotificationInstance;
161
161
  modalProps: ModalProps;
162
- setModalProps: (changes: Partial<ModalProps>) => void;
162
+ setModalProps: setModalProps;
163
163
  drawerProps: DrawerProps;
164
- setDrawerProps: (changes: Partial<DrawerProps>) => void;
164
+ setDrawerProps: setDrawerProps;
165
165
  }
166
166
  /**
167
167
  * App component with Ant Design & FaasJS
@@ -192,7 +192,10 @@ interface useAppProps {
192
192
  */
193
193
  declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
194
194
  declare namespace App {
195
- var useApp: typeof useApp;
195
+ var useApp: {
196
+ (): Readonly<useAppProps>;
197
+ whyDidYouRender: boolean;
198
+ };
196
199
  var whyDidYouRender: boolean;
197
200
  }
198
201
  /**
@@ -204,7 +207,10 @@ declare namespace App {
204
207
  * const { message, notification, setModalProps, setDrawerProps } = useApp()
205
208
  * ```
206
209
  */
207
- declare function useApp(): Readonly<useAppProps>;
210
+ declare const useApp: {
211
+ (): Readonly<useAppProps>;
212
+ whyDidYouRender: boolean;
213
+ };
208
214
 
209
215
  interface BlankProps {
210
216
  value?: any;
@@ -535,7 +541,7 @@ declare namespace Form {
535
541
  var whyDidYouRender: boolean;
536
542
  var useForm: typeof antd_es_form_Form.useForm;
537
543
  var useFormInstance: typeof antd_es_form_hooks_useFormInstance.default;
538
- var useWatch: typeof rc_field_form_es_useWatch.default;
544
+ var useWatch: typeof rc_field_form.useWatch;
539
545
  var Item: typeof FormItem;
540
546
  var List: react.FC<antd_es_form.FormListProps>;
541
547
  var ErrorList: react.FC<antd_es_form.ErrorListProps>;
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ import { RuleObject } from 'rc-field-form/lib/interface';
18
18
  import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
19
19
  import * as antd_es_form_context from 'antd/es/form/context';
20
20
  import * as antd_es_form from 'antd/es/form';
21
- import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
21
+ import * as rc_field_form from 'rc-field-form';
22
22
  import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
23
23
  import * as antd_es_form_Form from 'antd/es/form/Form';
24
24
  import { Tab } from 'rc-tabs/es/interface';
@@ -159,9 +159,9 @@ interface useAppProps {
159
159
  message: MessageInstance;
160
160
  notification: NotificationInstance;
161
161
  modalProps: ModalProps;
162
- setModalProps: (changes: Partial<ModalProps>) => void;
162
+ setModalProps: setModalProps;
163
163
  drawerProps: DrawerProps;
164
- setDrawerProps: (changes: Partial<DrawerProps>) => void;
164
+ setDrawerProps: setDrawerProps;
165
165
  }
166
166
  /**
167
167
  * App component with Ant Design & FaasJS
@@ -192,7 +192,10 @@ interface useAppProps {
192
192
  */
193
193
  declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
194
194
  declare namespace App {
195
- var useApp: typeof useApp;
195
+ var useApp: {
196
+ (): Readonly<useAppProps>;
197
+ whyDidYouRender: boolean;
198
+ };
196
199
  var whyDidYouRender: boolean;
197
200
  }
198
201
  /**
@@ -204,7 +207,10 @@ declare namespace App {
204
207
  * const { message, notification, setModalProps, setDrawerProps } = useApp()
205
208
  * ```
206
209
  */
207
- declare function useApp(): Readonly<useAppProps>;
210
+ declare const useApp: {
211
+ (): Readonly<useAppProps>;
212
+ whyDidYouRender: boolean;
213
+ };
208
214
 
209
215
  interface BlankProps {
210
216
  value?: any;
@@ -535,7 +541,7 @@ declare namespace Form {
535
541
  var whyDidYouRender: boolean;
536
542
  var useForm: typeof antd_es_form_Form.useForm;
537
543
  var useFormInstance: typeof antd_es_form_hooks_useFormInstance.default;
538
- var useWatch: typeof rc_field_form_es_useWatch.default;
544
+ var useWatch: typeof rc_field_form.useWatch;
539
545
  var Item: typeof FormItem;
540
546
  var List: react.FC<antd_es_form.FormListProps>;
541
547
  var ErrorList: react.FC<antd_es_form.ErrorListProps>;
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var Modal = antd.Modal;
19
19
  Modal.whyDidYouRender = true;
20
20
  function useModal(init) {
21
21
  const [props, setProps] = react$1.useState({ open: false, ...init });
22
- const setModalProps2 = react$1.useCallback(
22
+ const setModalProps = react$1.useCallback(
23
23
  (changes) => {
24
24
  const changed = typeof changes === "function" ? changes(props) : changes;
25
25
  setProps((prev) => ({ ...prev, ...changed }));
@@ -38,7 +38,7 @@ function useModal(init) {
38
38
  }
39
39
  ),
40
40
  modalProps: props,
41
- setModalProps: setModalProps2
41
+ setModalProps
42
42
  };
43
43
  }
44
44
  var Drawer = antd.Drawer;
@@ -48,7 +48,7 @@ function useDrawer(init) {
48
48
  open: false,
49
49
  ...init
50
50
  });
51
- const setDrawerProps2 = react$1.useCallback(
51
+ const setDrawerProps = react$1.useCallback(
52
52
  (changes) => {
53
53
  const changed = typeof changes === "function" ? changes(props) : changes;
54
54
  setProps((prev) => ({ ...prev, ...changed }));
@@ -67,7 +67,7 @@ function useDrawer(init) {
67
67
  }
68
68
  ),
69
69
  drawerProps: props,
70
- setDrawerProps: setDrawerProps2
70
+ setDrawerProps
71
71
  };
72
72
  }
73
73
  function ErrorChildren(props) {
@@ -162,31 +162,31 @@ function ConfigProvider(props) {
162
162
  function useConfigContext() {
163
163
  return react$1.useContext(ConfigContext);
164
164
  }
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);
165
+ var AppContext = react.createSplitedContext({
166
+ message: {},
167
+ notification: {},
168
+ modalProps: {},
169
+ setModalProps: () => void 0,
170
+ drawerProps: {},
171
+ setDrawerProps: () => void 0
172
+ });
173
173
  function RoutesApp(props) {
174
174
  const location = reactRouterDom.useLocation();
175
- const { drawerProps, setDrawerProps: setDrawerProps2, modalProps, setModalProps: setModalProps2 } = useApp();
175
+ const { drawerProps, setDrawerProps, modalProps, setModalProps } = useApp();
176
176
  react$1.useEffect(() => {
177
177
  console.debug("location", location);
178
178
  if (drawerProps.open)
179
- setDrawerProps2({ open: false });
179
+ setDrawerProps({ open: false });
180
180
  if (modalProps.open)
181
- setModalProps2({ open: false });
181
+ setModalProps({ open: false });
182
182
  }, [location]);
183
183
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
184
184
  }
185
185
  function App(props) {
186
186
  const [messageApi, messageContextHolder] = antd.message.useMessage();
187
187
  const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
188
- const { modal, modalProps, setModalProps: setModalProps2 } = useModal();
189
- const { drawer, drawerProps, setDrawerProps: setDrawerProps2 } = useDrawer();
188
+ const { modal, modalProps, setModalProps } = useModal();
189
+ const { drawer, drawerProps, setDrawerProps } = useDrawer();
190
190
  const styleProviderProps = react$1.useMemo(
191
191
  () => ({
192
192
  ...props.styleProviderProps,
@@ -195,38 +195,28 @@ function App(props) {
195
195
  }),
196
196
  [props.styleProviderProps]
197
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
- ] }) }) }) }) }) }) }) }) }) }) });
205
- }
206
- function useApp() {
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
+ return /* @__PURE__ */ jsxRuntime.jsx(cssinjs.StyleProvider, { ...styleProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(
199
+ AppContext.Provider,
200
+ {
201
+ value: {
202
+ message: messageApi,
203
+ notification: notificationApi,
204
+ drawerProps,
205
+ setDrawerProps,
206
+ modalProps,
207
+ setModalProps
208
+ },
209
+ children: /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.BrowserRouter, { ...props.browserRouterProps, children: [
210
+ messageContextHolder,
211
+ notificationContextHolder,
212
+ modal,
213
+ drawer,
214
+ /* @__PURE__ */ jsxRuntime.jsx(RoutesApp, { children: props.children })
215
+ ] }) }) })
216
+ }
217
+ ) }) });
229
218
  }
219
+ var useApp = AppContext.use;
230
220
  App.useApp = useApp;
231
221
  App.whyDidYouRender = true;
232
222
  function Blank(options) {
@@ -938,18 +928,15 @@ function Link(props) {
938
928
  }
939
929
  );
940
930
  if (props.children)
941
- return (
942
- // biome-ignore lint/a11y/useValidAnchor: <explanation>
943
- /* @__PURE__ */ jsxRuntime.jsx(
944
- "a",
945
- {
946
- href: props.href,
947
- target: props.target || ((_c = theme.Link) == null ? void 0 : _c.target),
948
- style: computedStyle,
949
- onClick: props.onClick,
950
- children: props.children
951
- }
952
- )
931
+ return /* @__PURE__ */ jsxRuntime.jsx(
932
+ "a",
933
+ {
934
+ href: props.href,
935
+ target: props.target || ((_c = theme.Link) == null ? void 0 : _c.target),
936
+ style: computedStyle,
937
+ onClick: props.onClick,
938
+ children: props.children
939
+ }
953
940
  );
954
941
  return /* @__PURE__ */ jsxRuntime.jsx(
955
942
  antd.Typography.Link,
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { ErrorBoundary as ErrorBoundary$1, FaasReactClient, useConstant, FaasDataWrapper as FaasDataWrapper$1, faas } from '@faasjs/react';
1
+ import { createSplitedContext, ErrorBoundary as ErrorBoundary$1, FaasReactClient, FaasDataWrapper as FaasDataWrapper$1, faas } from '@faasjs/react';
2
2
  export { faas, useFaas } from '@faasjs/react';
3
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
4
  import { legacyLogicalPropertiesTransformer, StyleProvider } from '@ant-design/cssinjs';
@@ -15,7 +15,7 @@ var Modal = Modal$1;
15
15
  Modal.whyDidYouRender = true;
16
16
  function useModal(init) {
17
17
  const [props, setProps] = useState({ open: false, ...init });
18
- const setModalProps2 = useCallback(
18
+ const setModalProps = useCallback(
19
19
  (changes) => {
20
20
  const changed = typeof changes === "function" ? changes(props) : changes;
21
21
  setProps((prev) => ({ ...prev, ...changed }));
@@ -34,7 +34,7 @@ function useModal(init) {
34
34
  }
35
35
  ),
36
36
  modalProps: props,
37
- setModalProps: setModalProps2
37
+ setModalProps
38
38
  };
39
39
  }
40
40
  var Drawer = Drawer$1;
@@ -44,7 +44,7 @@ function useDrawer(init) {
44
44
  open: false,
45
45
  ...init
46
46
  });
47
- const setDrawerProps2 = useCallback(
47
+ const setDrawerProps = useCallback(
48
48
  (changes) => {
49
49
  const changed = typeof changes === "function" ? changes(props) : changes;
50
50
  setProps((prev) => ({ ...prev, ...changed }));
@@ -63,7 +63,7 @@ function useDrawer(init) {
63
63
  }
64
64
  ),
65
65
  drawerProps: props,
66
- setDrawerProps: setDrawerProps2
66
+ setDrawerProps
67
67
  };
68
68
  }
69
69
  function ErrorChildren(props) {
@@ -158,31 +158,31 @@ function ConfigProvider(props) {
158
158
  function useConfigContext() {
159
159
  return useContext(ConfigContext);
160
160
  }
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);
161
+ var AppContext = createSplitedContext({
162
+ message: {},
163
+ notification: {},
164
+ modalProps: {},
165
+ setModalProps: () => void 0,
166
+ drawerProps: {},
167
+ setDrawerProps: () => void 0
168
+ });
169
169
  function RoutesApp(props) {
170
170
  const location = useLocation();
171
- const { drawerProps, setDrawerProps: setDrawerProps2, modalProps, setModalProps: setModalProps2 } = useApp();
171
+ const { drawerProps, setDrawerProps, modalProps, setModalProps } = useApp();
172
172
  useEffect(() => {
173
173
  console.debug("location", location);
174
174
  if (drawerProps.open)
175
- setDrawerProps2({ open: false });
175
+ setDrawerProps({ open: false });
176
176
  if (modalProps.open)
177
- setModalProps2({ open: false });
177
+ setModalProps({ open: false });
178
178
  }, [location]);
179
179
  return /* @__PURE__ */ jsx(Fragment, { children: props.children });
180
180
  }
181
181
  function App(props) {
182
182
  const [messageApi, messageContextHolder] = message.useMessage();
183
183
  const [notificationApi, notificationContextHolder] = notification.useNotification();
184
- const { modal, modalProps, setModalProps: setModalProps2 } = useModal();
185
- const { drawer, drawerProps, setDrawerProps: setDrawerProps2 } = useDrawer();
184
+ const { modal, modalProps, setModalProps } = useModal();
185
+ const { drawer, drawerProps, setDrawerProps } = useDrawer();
186
186
  const styleProviderProps = useMemo(
187
187
  () => ({
188
188
  ...props.styleProviderProps,
@@ -191,38 +191,28 @@ function App(props) {
191
191
  }),
192
192
  [props.styleProviderProps]
193
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
- ] }) }) }) }) }) }) }) }) }) }) });
201
- }
202
- function useApp() {
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
- });
194
+ return /* @__PURE__ */ jsx(StyleProvider, { ...styleProviderProps, children: /* @__PURE__ */ jsx(ConfigProvider$1, { ...props.configProviderProps, children: /* @__PURE__ */ jsx(
195
+ AppContext.Provider,
196
+ {
197
+ value: {
198
+ message: messageApi,
199
+ notification: notificationApi,
200
+ drawerProps,
201
+ setDrawerProps,
202
+ modalProps,
203
+ setModalProps
204
+ },
205
+ children: /* @__PURE__ */ jsx(ConfigProvider, { ...props.faasConfigProviderProps, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxs(BrowserRouter, { ...props.browserRouterProps, children: [
206
+ messageContextHolder,
207
+ notificationContextHolder,
208
+ modal,
209
+ drawer,
210
+ /* @__PURE__ */ jsx(RoutesApp, { children: props.children })
211
+ ] }) }) })
212
+ }
213
+ ) }) });
225
214
  }
215
+ var useApp = AppContext.use;
226
216
  App.useApp = useApp;
227
217
  App.whyDidYouRender = true;
228
218
  function Blank(options) {
@@ -934,18 +924,15 @@ function Link(props) {
934
924
  }
935
925
  );
936
926
  if (props.children)
937
- return (
938
- // biome-ignore lint/a11y/useValidAnchor: <explanation>
939
- /* @__PURE__ */ jsx(
940
- "a",
941
- {
942
- href: props.href,
943
- target: props.target || ((_c = theme.Link) == null ? void 0 : _c.target),
944
- style: computedStyle,
945
- onClick: props.onClick,
946
- children: props.children
947
- }
948
- )
927
+ return /* @__PURE__ */ jsx(
928
+ "a",
929
+ {
930
+ href: props.href,
931
+ target: props.target || ((_c = theme.Link) == null ? void 0 : _c.target),
932
+ style: computedStyle,
933
+ onClick: props.onClick,
934
+ children: props.children
935
+ }
949
936
  );
950
937
  return /* @__PURE__ */ jsx(
951
938
  Typography.Link,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "2.0.0",
3
+ "version": "2.2.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": "2.0.0",
29
+ "@faasjs/react": "2.2.0",
30
30
  "antd": "*",
31
31
  "react": "*",
32
32
  "react-dom": "*",
@@ -38,7 +38,7 @@
38
38
  "@testing-library/react": "*",
39
39
  "@testing-library/user-event": "*",
40
40
  "@welldone-software/why-did-you-render": "*",
41
- "@faasjs/react": "2.0.0",
41
+ "@faasjs/react": "2.2.0",
42
42
  "antd": "*",
43
43
  "react": "*",
44
44
  "react-dom": "*",