@hzab/list-render 1.10.8 → 1.10.10

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/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
+ # @hzab/list-render@1.10.10
2
+
3
+ fix: 解决 FormModal 与 DetailModal 相互影响的问题
4
+
5
+ # @hzab/list-render@1.10.9
6
+
7
+ fix: 行内编辑 解决 select 等表单项 focus 报错问题
8
+
1
9
  # @hzab/list-render@1.10.8
2
10
 
3
- feat: 行内编辑事件通过onEdit抛出 添加保存前自定义处理函数onEditReqVerify,返回Promise用于截断或正常执行
11
+ feat: 行内编辑事件通过 onEdit 抛出 添加保存前自定义处理函数 onEditReqVerify,返回 Promise 用于截断或正常执行
4
12
 
5
13
  # @hzab/list-render@1.10.7
6
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/list-render",
3
- "version": "1.10.8",
3
+ "version": "1.10.10",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -18,7 +18,7 @@ function DetailModal(props, parentRef) {
18
18
  setOpen(true);
19
19
  // 处理 formRef.current 为 undefined 的问题
20
20
  setData(formData);
21
- setTitle(title || '详情')
21
+ setTitle(title || "详情");
22
22
  }
23
23
 
24
24
  function close() {
@@ -34,10 +34,15 @@ function DetailModal(props, parentRef) {
34
34
  formRef,
35
35
  }));
36
36
 
37
+ // Hack: 解决 FormModal DetailModal 相互影响的问题
38
+ if (!open) {
39
+ return null;
40
+ }
41
+
37
42
  let footer = undefined;
38
43
  const options = {
39
44
  close,
40
- form: formRef.current?.formRender,
45
+ formRef,
41
46
  scenario: "detail",
42
47
  };
43
48
  if (modalConf?.footer) {
@@ -62,6 +62,11 @@ export function FormModal(props, parentRef) {
62
62
  formRef,
63
63
  }));
64
64
 
65
+ // Hack: 解决 FormModal DetailModal 相互影响的问题
66
+ if (!open) {
67
+ return null;
68
+ }
69
+
65
70
  function onOk() {
66
71
  validate().then(async () => {
67
72
  const submitForm = _.cloneDeep(await formRef.current?.formRender?.values);
@@ -111,7 +116,7 @@ export function FormModal(props, parentRef) {
111
116
  cancel: close,
112
117
  onOk,
113
118
  close,
114
- form: formRef.current?.formRender,
119
+ formRef,
115
120
  validate,
116
121
  scenario: scenarioRef.current,
117
122
  };
@@ -177,7 +182,7 @@ export function FormModal(props, parentRef) {
177
182
  return (
178
183
  <CModal {..._modalProps}>
179
184
  {FormSlot ? (
180
- <FormSlot {...props} formRef={formRef} scenario={scenarioRef.current} schema={props.schema?.schema} />
185
+ <FormSlot {...props} formRef={formRef} scenario={scenarioRef.current} schema={props.schema} />
181
186
  ) : (
182
187
  <FormRender
183
188
  {...props.formProps}
@@ -1,72 +1,72 @@
1
- import { cloneDeep } from "lodash";
2
- import { autorun, observable } from "@formily/reactive";
3
- import { getStateFunc } from "./formily-utils";
4
-
5
- /**
6
- * 处理自己添加的变量
7
- * @param {Array} fieldList
8
- * @param {Object} opt
9
- * @returns
10
- */
11
- export function handleReactions(fieldList, opt = {}) {
12
- if (!Array.isArray(fieldList)) {
13
- console.warn("Error handleReactions: fieldList not array");
14
- return fieldList;
15
- }
16
- const resList = [];
17
- cloneDeep(fieldList).forEach((item) => {
18
- handleReaction(item, opt);
19
- resList.push(item);
20
- });
21
- return resList;
22
- }
23
-
24
- /**
25
- * 处理自己添加的变量
26
- * @param {Object} fieldSchema
27
- * @param {Object} opt
28
- * @returns
29
- */
30
- export function handleReaction(fieldSchema, opt = {}) {
31
- const { scope, formilyRef = {}, scenario } = opt || {};
32
-
33
- const field = fieldSchema?.field || fieldSchema;
34
- const { state, run } = field["x-reactions"]?.fulfill || {};
35
- const args = {
36
- scope,
37
- // $deps,
38
- $self: field,
39
- $effect: autorun.effect,
40
- // $form: $form,
41
- // $values: $values,
42
- $observable: observable,
43
- $memo: autorun.memo,
44
- $props: {
45
- // formilyRef.current.fields formilyRef.current.fieldSchemas
46
- formilyRef,
47
- },
48
- };
49
-
50
- // 自身变量
51
- if (field.inTable) {
52
- const inTableEffectFn = getStateFunc(field.inTable, args);
53
- if (inTableEffectFn) {
54
- const inTable = inTableEffectFn(args);
55
- field.inTable = inTable;
56
- }
57
- }
58
-
59
- // 属性响应器
60
- if (state) {
61
- }
62
-
63
- // 动作响应器
64
- // if (run) {
65
- // getFunc(run)(args);
66
- // }
67
-
68
- if (field.visible === false) {
69
- return field;
70
- }
71
- return field;
72
- }
1
+ import { cloneDeep } from "lodash";
2
+ import { autorun, observable } from "@formily/reactive";
3
+ import { getStateFunc } from "./formily-utils";
4
+
5
+ /**
6
+ * 处理自己添加的变量
7
+ * @param {Array} fieldList
8
+ * @param {Object} opt
9
+ * @returns
10
+ */
11
+ export function handleReactions(fieldList, opt = {}) {
12
+ if (!Array.isArray(fieldList)) {
13
+ console.warn("Error handleReactions: fieldList not array");
14
+ return fieldList;
15
+ }
16
+ const resList = [];
17
+ cloneDeep(fieldList).forEach((item) => {
18
+ handleReaction(item, opt);
19
+ resList.push(item);
20
+ });
21
+ return resList;
22
+ }
23
+
24
+ /**
25
+ * 处理自己添加的变量
26
+ * @param {Object} fieldSchema
27
+ * @param {Object} opt
28
+ * @returns
29
+ */
30
+ export function handleReaction(fieldSchema, opt = {}) {
31
+ const { scope, formilyRef = {}, scenario } = opt || {};
32
+
33
+ const field = fieldSchema?.field || fieldSchema;
34
+ const { state, run } = field["x-reactions"]?.fulfill || {};
35
+ const args = {
36
+ scope,
37
+ // $deps,
38
+ $self: field,
39
+ $effect: autorun.effect,
40
+ // $form: $form,
41
+ // $values: $values,
42
+ $observable: observable,
43
+ $memo: autorun.memo,
44
+ $props: {
45
+ // formilyRef.current.fields formilyRef.current.fieldSchemas
46
+ formilyRef,
47
+ },
48
+ };
49
+
50
+ // 自身变量
51
+ if (field.inTable) {
52
+ const inTableEffectFn = getStateFunc(field.inTable, args);
53
+ if (inTableEffectFn) {
54
+ const inTable = inTableEffectFn(args);
55
+ field.inTable = inTable;
56
+ }
57
+ }
58
+
59
+ // 属性响应器
60
+ if (state) {
61
+ }
62
+
63
+ // 动作响应器
64
+ // if (run) {
65
+ // getFunc(run)(args);
66
+ // }
67
+
68
+ if (field.visible === false) {
69
+ return field;
70
+ }
71
+ return field;
72
+ }
@@ -181,7 +181,10 @@ export const useEditTable = (props) => {
181
181
 
182
182
  useEffect(() => {
183
183
  if (editingId || editingKey) {
184
- editingFiledRef.current?.current?.focus?.();
184
+ try {
185
+ // HACK: try catch 解决 select 等表单项 focus 报错问题
186
+ editingFiledRef.current?.current?.focus?.();
187
+ } catch (error) {}
185
188
  }
186
189
  }, [editingId, editingKey]);
187
190
 
@@ -212,7 +215,7 @@ export const useEditTable = (props) => {
212
215
  try {
213
216
  // 点击保存,数据抛出
214
217
  (await formRender?.validate()) as Item;
215
- onEditSubmit && await onEditSubmit(formRender.values);
218
+ onEditSubmit && (await onEditSubmit(formRender.values));
216
219
  // 清除编辑目标
217
220
  setEditingId("");
218
221
  setEditingKey("");