@nocobase/client 0.7.0-alpha.29 → 0.7.0-alpha.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/client",
3
- "version": "0.7.0-alpha.29",
3
+ "version": "0.7.0-alpha.30",
4
4
  "license": "Apache-2.0",
5
5
  "licenses": [
6
6
  {
@@ -26,10 +26,10 @@
26
26
  "@dnd-kit/core": "^5.0.1",
27
27
  "@dnd-kit/sortable": "^6.0.0",
28
28
  "@emotion/css": "^11.7.1",
29
- "@formily/antd": "^2.0.15",
30
- "@formily/core": "^2.0.15",
31
- "@formily/react": "^2.0.15",
32
- "@nocobase/utils": "0.7.0-alpha.29",
29
+ "@formily/antd": "2.0.20",
30
+ "@formily/core": "2.0.20",
31
+ "@formily/react": "2.0.20",
32
+ "@nocobase/utils": "0.7.0-alpha.30",
33
33
  "ahooks": "^3.0.5",
34
34
  "antd": "~4.19.5",
35
35
  "axios": "^0.24.0",
@@ -66,5 +66,5 @@
66
66
  "@types/marked": "^4.0.1",
67
67
  "axios-mock-adapter": "^1.20.0"
68
68
  },
69
- "gitHead": "46e660b10d1cf94ecb808a9a45edb5e8d40398dc"
69
+ "gitHead": "781fb0a999854341cd8c353d31ae5a11ecbbe775"
70
70
  }
@@ -286,6 +286,6 @@ export default {
286
286
  'Execution History': 'History',
287
287
  'Parallel branch': 'Branch',
288
288
 
289
- 'Confirm': 'Confirm',
290
- 'Form value changed tip': 'Are you sure to exit that Data unsaved',
289
+ 'Unsaved changes': 'Unsaved changes',
290
+ 'Are you sure you don\'t want to save?': 'Are you sure you don\'t want to save?',
291
291
  }
@@ -1,6 +1,6 @@
1
1
  import { css } from '@emotion/css';
2
2
  import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
3
- import { Drawer, Modal as AntdModal } from 'antd';
3
+ import { Drawer } from 'antd';
4
4
  import classNames from 'classnames';
5
5
  import React from 'react';
6
6
  import { createPortal } from 'react-dom';
@@ -11,7 +11,7 @@ import { ComposedActionDrawer } from './types';
11
11
  export const ActionDrawer: ComposedActionDrawer = observer((props) => {
12
12
  const { footerNodeName = 'Action.Drawer.Footer', ...others } = props;
13
13
  const { t } = useTranslation();
14
- const { visible, setVisible, formValueChanged, setFormValueChanged } = useActionContext();
14
+ const { visible, setVisible } = useActionContext();
15
15
  const schema = useFieldSchema();
16
16
  const field = useField();
17
17
  const footerSchema = schema.reduceProperties((buf, s) => {
@@ -22,18 +22,7 @@ export const ActionDrawer: ComposedActionDrawer = observer((props) => {
22
22
  });
23
23
 
24
24
  const closeHandler = () => {
25
- if (!formValueChanged) {
26
- setVisible(false);
27
- return;
28
- }
29
- AntdModal.confirm({
30
- title: t('Unsaved changes'),
31
- content: t("Are you sure you don't want to save?"),
32
- async onOk() {
33
- setFormValueChanged(false);
34
- setVisible(false);
35
- },
36
- });
25
+ setVisible(false);
37
26
  };
38
27
  return (
39
28
  <>
@@ -1,5 +1,7 @@
1
1
  import { useForm } from '@formily/react';
2
+ import { Modal as AntdModal } from 'antd';
2
3
  import { useContext } from 'react';
4
+ import { useTranslation } from 'react-i18next';
3
5
  import { ActionContext } from './context';
4
6
 
5
7
  export const useA = () => {
@@ -10,12 +12,28 @@ export const useA = () => {
10
12
 
11
13
  export const useActionContext = () => {
12
14
  const ctx = useContext(ActionContext);
15
+ const { t } = useTranslation();
13
16
 
14
17
  return {
15
18
  ...ctx,
16
19
  setVisible(visible: boolean) {
17
20
  if (ctx?.openMode !== 'page') {
18
- ctx?.setVisible?.(visible);
21
+ if (!visible) {
22
+ if (ctx.formValueChanged) {
23
+ AntdModal.confirm({
24
+ title: t('Unsaved changes'),
25
+ content: t("Are you sure you don't want to save?"),
26
+ async onOk() {
27
+ ctx.setFormValueChanged(false);
28
+ ctx.setVisible(false);
29
+ },
30
+ });
31
+ } else {
32
+ ctx.setVisible(false);
33
+ }
34
+ } else {
35
+ ctx?.setVisible?.(visible);
36
+ }
19
37
  }
20
38
  },
21
39
  };
@@ -62,7 +62,7 @@ const WithForm = (props) => {
62
62
  const id = uid();
63
63
  form.addEffects(id, () => {
64
64
  onFormInputChange((form) => {
65
- setFormValueChanged(true);
65
+ setFormValueChanged?.(true);
66
66
  });
67
67
  });
68
68
  return () => {