@zat-design/sisyphus-react 4.6.1 → 4.6.3-beta.1

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.
@@ -239,6 +239,12 @@
239
239
  }
240
240
  }
241
241
 
242
+ .@{ant-prefix}-table-tbody
243
+ .is-editing:not(.@{ant-prefix}-table-measure-row):not(.@{ant-prefix}-table-row-extra)
244
+ .@{ant-prefix}-form-item.@{ant-prefix}-form-item-has-error {
245
+ margin-bottom: calc(var(--zaui-space-size-md; 16px) * var(--zaui-size; 1)) !important;
246
+ }
247
+
242
248
  .@{ant-prefix}-table.@{ant-prefix}-table-bordered > .@{ant-prefix}-table-container {
243
249
  border: 0;
244
250
  }
@@ -19,6 +19,7 @@ import ProIcon from "../../../../../ProIcon";
19
19
  import locale from "../../../../../locale";
20
20
  import deleteSvg from "../../../../../assets/delete.svg";
21
21
  import close2Svg from "../../../../../assets/close2.svg";
22
+ import { FORM_LIST_ACTION_ABORT } from "../toolbarActions";
22
23
  const filterKeys = ["actionType"];
23
24
  const getDefaultActions = (mode) => {
24
25
  const originActions = {
@@ -36,7 +37,7 @@ const getDefaultActions = (mode) => {
36
37
  remove(index);
37
38
  },
38
39
  label: locale.ProForm.formListActions[1],
39
- icon: mode === "less" ? /* @__PURE__ */ jsx(ProIcon, { component: close2Svg, size: 14, className: "single-delete" }) : /* @__PURE__ */ jsx(ProIcon, { component: deleteSvg, size: 18 })
40
+ icon: mode === "less" || mode === "tabs" ? /* @__PURE__ */ jsx(ProIcon, { component: close2Svg, size: 14, className: "single-delete" }) : /* @__PURE__ */ jsx(ProIcon, { component: deleteSvg, size: 18 })
40
41
  },
41
42
  copy: {
42
43
  onClick: (record, { namePath, index, operation }) => {
@@ -69,12 +70,7 @@ const getDefaultActions = (mode) => {
69
70
  originActions[key].className = "pro-form-list-tool-btn";
70
71
  });
71
72
  }
72
- if (mode === "line") {
73
- Object.keys(originActions).forEach((key) => {
74
- delete originActions[key].label;
75
- });
76
- }
77
- if (mode === "less") {
73
+ if (mode === "line" || mode === "less" || mode === "tabs") {
78
74
  Object.keys(originActions).forEach((key) => {
79
75
  delete originActions[key].label;
80
76
  });
@@ -115,6 +111,8 @@ const ActionButton = (props) => {
115
111
  const handleClick = async (defaultCallback, callback, index2, item) => {
116
112
  const value = form.getFieldValue(namePath);
117
113
  const data = await (callback == null ? void 0 : callback(value, { namePath, index: index2, operation, form }));
114
+ if (data === FORM_LIST_ACTION_ABORT)
115
+ return;
118
116
  if (!callback || data === true) {
119
117
  defaultCallback == null ? void 0 : defaultCallback(value, { namePath, index: index2, operation, form });
120
118
  return;
@@ -172,6 +170,8 @@ const ActionButton = (props) => {
172
170
  const handleAddClick = async () => {
173
171
  const value = form.getFieldValue(namePath);
174
172
  const data = await (_onClick == null ? void 0 : _onClick(value, { namePath, index, operation, form }));
173
+ if (data === FORM_LIST_ACTION_ABORT)
174
+ return;
175
175
  if (!_onClick || data === true) {
176
176
  if (item.addIndex !== void 0) {
177
177
  const insertIndex = typeof item.addIndex === "function" ? item.addIndex(value, { index, namePath, form, operation }) : item.addIndex;
@@ -208,6 +208,7 @@ const ActionButton = (props) => {
208
208
  {
209
209
  ...defaultRest,
210
210
  ...omit(rest, filterKeys),
211
+ className: "pro-form-list-delete-icon",
211
212
  type: "text",
212
213
  onClick: (e) => e.stopPropagation(),
213
214
  children: label || defaultLabel
@@ -221,7 +222,8 @@ const ActionButton = (props) => {
221
222
  className: classNames({
222
223
  "pro-form-list-tool-btn": mode === "line",
223
224
  "pro-form-list-tool-btn-block": mode === "block",
224
- "pro-form-list-tool-btn-less": mode === "less"
225
+ "pro-form-list-tool-btn-less": mode === "less",
226
+ "pro-form-list-tool-btn-tabs": mode === "tabs"
225
227
  }),
226
228
  ...defaultRest,
227
229
  ...omit(rest, filterKeys),
@@ -8,6 +8,7 @@ interface EmptyProps {
8
8
  form?: FormInstance;
9
9
  namePath?: InternalNamePath;
10
10
  emptyBtnText?: string;
11
+ onAdd?: () => unknown | Promise<unknown>;
11
12
  }
12
- declare const Empty: ({ disabled, toolbarProps, operation, form, namePath, emptyBtnText }: EmptyProps) => import("react/jsx-runtime").JSX.Element;
13
+ declare const Empty: ({ disabled, toolbarProps, operation, form, namePath, emptyBtnText, onAdd, }: EmptyProps) => import("react/jsx-runtime").JSX.Element;
13
14
  export default Empty;
@@ -3,12 +3,24 @@ import { Button } from "antd";
3
3
  import isFunction from "lodash/isFunction";
4
4
  import EmptyImg from "../../../../../assets/empty.png";
5
5
  import locale from "../../../../../locale";
6
- const Empty = ({ disabled, toolbarProps, operation, form, namePath, emptyBtnText }) => {
6
+ const Empty = ({
7
+ disabled,
8
+ toolbarProps,
9
+ operation,
10
+ form,
11
+ namePath,
12
+ emptyBtnText,
13
+ onAdd
14
+ }) => {
7
15
  const addConfig = Array.isArray(toolbarProps) ? toolbarProps.find((item) => item.type === "add") : null;
8
16
  const handleAddClick = async () => {
9
17
  var _a;
10
18
  if (!operation || !form || !namePath)
11
19
  return;
20
+ if (onAdd) {
21
+ await onAdd();
22
+ return;
23
+ }
12
24
  const value = form.getFieldValue(namePath);
13
25
  const data = await ((_a = addConfig == null ? void 0 : addConfig.onClick) == null ? void 0 : _a.call(addConfig, value, { operation, form, namePath, index: 0 }));
14
26
  if (!(addConfig == null ? void 0 : addConfig.onClick) || data === true) {
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { FormInstance, FormListFieldData } from 'antd';
3
+ import type { InternalNamePath } from 'antd/es/form/interface';
4
+ import type { DiffConfigType } from '../../../../propsType';
5
+ import type { FormListType } from '../propsType';
6
+ interface Props extends Omit<FormListType, 'fields' | 'form'> {
7
+ diffConfig?: DiffConfigType;
8
+ fields: FormListFieldData[];
9
+ form: FormInstance;
10
+ isView?: boolean;
11
+ namePath: InternalNamePath;
12
+ processColumns: (index: number, namePath: InternalNamePath) => FormListType['columns'];
13
+ }
14
+ declare const TabsFields: React.FC<Props>;
15
+ export default TabsFields;
@@ -0,0 +1,346 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { Badge, Row, Tabs } from "antd";
4
+ import { PlusOutlined } from "@ant-design/icons";
5
+ import { DndContext } from "@dnd-kit/core";
6
+ import { horizontalListSortingStrategy, SortableContext, useSortable } from "@dnd-kit/sortable";
7
+ import { CSS } from "@dnd-kit/utilities";
8
+ import isFunction from "lodash/isFunction";
9
+ import dragSvg from "../../../../../assets/drag.svg";
10
+ import ProIcon from "../../../../../ProIcon";
11
+ import locale from "../../../../../locale";
12
+ import RenderFields from "../../../render/RenderFields";
13
+ import ActionButton from "./ActionButton";
14
+ import Empty from "./Empty";
15
+ import { memoWith } from "../utils";
16
+ import {
17
+ executeToolbarAdd,
18
+ FORM_LIST_ACTION_ABORT,
19
+ isToolbarActionVisible,
20
+ normalizeToolbarActions
21
+ } from "../toolbarActions";
22
+ import { subscribeFormListTabsValidation } from "../tabsValidation";
23
+ const MemoRenderFields = React.memo(RenderFields, memoWith);
24
+ const getTabErrorCounts = (errorFields, fields, namePath) => {
25
+ const uniqueErrors = /* @__PURE__ */ new Map();
26
+ errorFields.forEach((errorField) => {
27
+ var _a;
28
+ if (!((_a = errorField.errors) == null ? void 0 : _a.length) || errorField.name.length <= namePath.length + 1)
29
+ return;
30
+ const matchesList = namePath.every((name, index) => errorField.name[index] === name);
31
+ if (!matchesList)
32
+ return;
33
+ const fieldName = errorField.name[namePath.length];
34
+ const field = fields.find((item) => item.name === fieldName);
35
+ if (!field)
36
+ return;
37
+ const fieldKey = String(field.key);
38
+ const errorPath = JSON.stringify(errorField.name.slice(namePath.length + 1));
39
+ const paths = uniqueErrors.get(fieldKey) || /* @__PURE__ */ new Set();
40
+ paths.add(errorPath);
41
+ uniqueErrors.set(fieldKey, paths);
42
+ });
43
+ return new Map(Array.from(uniqueErrors, ([fieldKey, paths]) => [fieldKey, paths.size]));
44
+ };
45
+ const SortableTabLabel = ({
46
+ children,
47
+ disabled,
48
+ draggable,
49
+ fieldKey
50
+ }) => {
51
+ const {
52
+ attributes,
53
+ listeners,
54
+ setActivatorNodeRef,
55
+ setNodeRef,
56
+ transform,
57
+ transition,
58
+ isDragging
59
+ } = useSortable({
60
+ id: fieldKey,
61
+ disabled: disabled || !draggable
62
+ });
63
+ return /* @__PURE__ */ jsxs(
64
+ "div",
65
+ {
66
+ ref: setNodeRef,
67
+ className: "pro-form-list-tabs-label",
68
+ style: {
69
+ opacity: isDragging ? 0.4 : void 0,
70
+ transform: CSS.Translate.toString(transform),
71
+ transition
72
+ },
73
+ children: [
74
+ !disabled && draggable && /* @__PURE__ */ jsx(
75
+ "span",
76
+ {
77
+ ...attributes,
78
+ ...listeners,
79
+ ref: setActivatorNodeRef,
80
+ className: "pro-form-list-tabs-drag-handle",
81
+ children: /* @__PURE__ */ jsx(ProIcon, { component: dragSvg, size: 16, color: "#949599" })
82
+ }
83
+ ),
84
+ children
85
+ ]
86
+ }
87
+ );
88
+ };
89
+ const TabsFields = (props) => {
90
+ const {
91
+ actionProps,
92
+ diffConfig,
93
+ disabled,
94
+ draggable,
95
+ emptyBtnText,
96
+ fields,
97
+ form,
98
+ isView,
99
+ max,
100
+ min,
101
+ namePath,
102
+ operation,
103
+ processColumns,
104
+ span = 8,
105
+ title,
106
+ toolbarProps
107
+ } = props;
108
+ const fieldKeys = fields.map((field) => String(field.key));
109
+ const fieldKeysSignature = fieldKeys.join("\0");
110
+ const [activeKey, setActiveKey] = useState(fieldKeys[0]);
111
+ const [validationErrorFields, setValidationErrorFields] = useState([]);
112
+ const activeIndexRef = useRef(0);
113
+ const fieldKeysRef = useRef(fieldKeys);
114
+ const fieldsRef = useRef(fields);
115
+ const namePathRef = useRef(namePath);
116
+ const pendingAddKeysRef = useRef(null);
117
+ const validatingRef = useRef(false);
118
+ fieldKeysRef.current = fieldKeys;
119
+ fieldsRef.current = fields;
120
+ namePathRef.current = namePath;
121
+ const errorCounts = getTabErrorCounts(validationErrorFields, fields, namePath);
122
+ const currentIndex = activeKey ? fieldKeys.indexOf(activeKey) : -1;
123
+ if (currentIndex >= 0)
124
+ activeIndexRef.current = currentIndex;
125
+ useEffect(() => {
126
+ const pendingKeys = pendingAddKeysRef.current;
127
+ const addedKey = pendingKeys && fieldKeys.find((key) => !pendingKeys.has(key));
128
+ if (addedKey) {
129
+ pendingAddKeysRef.current = null;
130
+ activeIndexRef.current = fieldKeys.indexOf(addedKey);
131
+ setActiveKey(addedKey);
132
+ return;
133
+ }
134
+ if (activeKey && fieldKeys.includes(activeKey))
135
+ return;
136
+ const fallbackIndex = Math.min(activeIndexRef.current, fieldKeys.length - 1);
137
+ setActiveKey(fallbackIndex >= 0 ? fieldKeys[fallbackIndex] : void 0);
138
+ }, [activeKey, fieldKeysSignature]);
139
+ useEffect(
140
+ () => subscribeFormListTabsValidation(form, (event) => {
141
+ setValidationErrorFields(event.errorFields);
142
+ if (event.reason !== "submitFailed")
143
+ return;
144
+ const counts = getTabErrorCounts(event.errorFields, fieldsRef.current, namePathRef.current);
145
+ const firstErrorIndex = fieldsRef.current.findIndex(
146
+ (field) => counts.has(String(field.key))
147
+ );
148
+ if (firstErrorIndex < 0)
149
+ return;
150
+ activeIndexRef.current = firstErrorIndex;
151
+ setActiveKey(String(fieldsRef.current[firstErrorIndex].key));
152
+ }),
153
+ [form]
154
+ );
155
+ const validateCurrent = useCallback(async () => {
156
+ if (!activeKey)
157
+ return true;
158
+ const activeField = fields.find((field) => String(field.key) === activeKey);
159
+ if (!activeField || !(form == null ? void 0 : form.validateFields))
160
+ return true;
161
+ try {
162
+ await form.validateFields([[...namePath, activeField.name]], { recursive: true });
163
+ return true;
164
+ } catch {
165
+ return false;
166
+ }
167
+ }, [activeKey, fieldKeysSignature, form, namePath]);
168
+ const runAfterValidation = useCallback(
169
+ async (callback) => {
170
+ if (validatingRef.current)
171
+ return false;
172
+ validatingRef.current = true;
173
+ try {
174
+ if (!await validateCurrent())
175
+ return false;
176
+ return await callback();
177
+ } finally {
178
+ validatingRef.current = false;
179
+ }
180
+ },
181
+ [validateCurrent]
182
+ );
183
+ const normalizedToolbarProps = useMemo(
184
+ () => toolbarProps === false ? [] : normalizeToolbarActions(toolbarProps),
185
+ [toolbarProps]
186
+ );
187
+ const addAction = normalizedToolbarProps.find(
188
+ (item) => item.type === "add" && isToolbarActionVisible(item, form, namePath)
189
+ );
190
+ const addLabel = (addAction == null ? void 0 : addAction.label) ?? locale.ProForm.formListTabsAdd;
191
+ const hasReachedMax = max !== void 0 && max <= fields.length;
192
+ const hideAdd = !addAction || addAction.disabled || disabled || isView || hasReachedMax;
193
+ const handleAdd = async () => {
194
+ if (!addAction || hideAdd)
195
+ return;
196
+ await runAfterValidation(async () => {
197
+ pendingAddKeysRef.current = new Set(fieldKeysRef.current);
198
+ const added = await executeToolbarAdd({ action: addAction, form, namePath, operation });
199
+ if (!added)
200
+ pendingAddKeysRef.current = null;
201
+ return added;
202
+ });
203
+ };
204
+ const handleChange = (nextActiveKey) => {
205
+ if (nextActiveKey === activeKey)
206
+ return;
207
+ void runAfterValidation(() => {
208
+ const nextIndex = fieldKeysRef.current.indexOf(nextActiveKey);
209
+ if (nextIndex < 0)
210
+ return false;
211
+ activeIndexRef.current = nextIndex;
212
+ setActiveKey(nextActiveKey);
213
+ return true;
214
+ });
215
+ };
216
+ const handleDragEnd = ({ active, over }) => {
217
+ if (!over || active.id === over.id)
218
+ return;
219
+ const activeIndex = fieldKeys.indexOf(String(active.id));
220
+ const overIndex = fieldKeys.indexOf(String(over.id));
221
+ if (activeIndex >= 0 && overIndex >= 0)
222
+ operation.move(activeIndex, overIndex);
223
+ };
224
+ const wrapValidatedActions = (items2) => items2 == null ? void 0 : items2.filter((item) => item.type !== "moveUp" && item.type !== "moveDown").map((item) => {
225
+ if (item.type !== "add" && item.type !== "copy")
226
+ return item;
227
+ const callback = item.onClick || item.onHandle;
228
+ return {
229
+ ...item,
230
+ onHandle: void 0,
231
+ onClick: async (record, option) => {
232
+ let didRun = false;
233
+ const result = await runAfterValidation(() => {
234
+ didRun = true;
235
+ return callback ? callback(record, option) : item.type === "copy" ? true : void 0;
236
+ });
237
+ return didRun ? result : FORM_LIST_ACTION_ABORT;
238
+ }
239
+ };
240
+ });
241
+ const items = fields.map((field, index) => {
242
+ const fieldKey = String(field.key);
243
+ const itemNamePath = [...namePath, field.name];
244
+ const record = form.getFieldValue(itemNamePath);
245
+ const tabTitle = isFunction(title) ? title(record, index, form) : title;
246
+ const renderedTitle = tabTitle ?? `Tab ${index + 1}`;
247
+ const tabActionProps = wrapValidatedActions(actionProps || void 0);
248
+ const errorCount = errorCounts.get(fieldKey) || 0;
249
+ return {
250
+ key: fieldKey,
251
+ closable: false,
252
+ label: /* @__PURE__ */ jsx(SortableTabLabel, { fieldKey, draggable, disabled: disabled || isView, children: /* @__PURE__ */ jsx(
253
+ Badge,
254
+ {
255
+ className: "pro-form-list-tabs-error-badge",
256
+ count: errorCount,
257
+ overflowCount: 99,
258
+ size: "small",
259
+ children: /* @__PURE__ */ jsxs(
260
+ "span",
261
+ {
262
+ className: `pro-form-list-tabs-title-content${errorCount ? " pro-form-list-tabs-title-content-error" : ""}`,
263
+ children: [
264
+ /* @__PURE__ */ jsx("span", { className: "pro-form-list-tabs-title", children: renderedTitle }),
265
+ actionProps !== false && /* @__PURE__ */ jsx(
266
+ ActionButton,
267
+ {
268
+ min,
269
+ max,
270
+ index,
271
+ length: fields.length,
272
+ operation,
273
+ namePath: itemNamePath,
274
+ form,
275
+ field: { ...field, key: fieldKey },
276
+ fields,
277
+ actionProps: tabActionProps,
278
+ mode: "tabs",
279
+ disabled,
280
+ isView
281
+ }
282
+ )
283
+ ]
284
+ }
285
+ )
286
+ }
287
+ ) }),
288
+ children: /* @__PURE__ */ jsx("div", { className: "pro-form-list-tabs-content", children: /* @__PURE__ */ jsx(Row, { gutter: 16, className: "pro-form-list-fields", children: /* @__PURE__ */ jsx(
289
+ MemoRenderFields,
290
+ {
291
+ columns: processColumns(index, itemNamePath),
292
+ form,
293
+ colProps: { span },
294
+ disabled,
295
+ isView,
296
+ diffConfig
297
+ }
298
+ ) }) })
299
+ };
300
+ });
301
+ return /* @__PURE__ */ jsx(DndContext, { onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsxs(
302
+ SortableContext,
303
+ {
304
+ items: fieldKeys.map((key) => ({ id: key })),
305
+ strategy: horizontalListSortingStrategy,
306
+ children: [
307
+ /* @__PURE__ */ jsx(
308
+ Tabs,
309
+ {
310
+ className: "pro-form-list-tabs",
311
+ type: "editable-card",
312
+ size: "small",
313
+ activeKey,
314
+ addIcon: /* @__PURE__ */ jsxs("span", { className: "pro-form-list-tabs-add", children: [
315
+ /* @__PURE__ */ jsx(PlusOutlined, {}),
316
+ /* @__PURE__ */ jsx("span", { className: "pro-form-list-tabs-add-label", children: addLabel })
317
+ ] }),
318
+ hideAdd,
319
+ items,
320
+ onChange: handleChange,
321
+ onEdit: (_, action) => {
322
+ if (action === "add")
323
+ void handleAdd();
324
+ }
325
+ }
326
+ ),
327
+ fields.length === 0 && /* @__PURE__ */ jsx(
328
+ Empty,
329
+ {
330
+ disabled: hideAdd,
331
+ toolbarProps: addAction ? [{ ...addAction, show: true }] : false,
332
+ operation,
333
+ form,
334
+ namePath,
335
+ emptyBtnText,
336
+ onAdd: handleAdd
337
+ }
338
+ )
339
+ ]
340
+ }
341
+ ) });
342
+ };
343
+ var TabsFields_default = TabsFields;
344
+ export {
345
+ TabsFields_default as default
346
+ };
@@ -1,10 +1,14 @@
1
1
  import { Fragment, jsx } from "react/jsx-runtime";
2
2
  import { Space, Button } from "antd";
3
3
  import { PlusOutlined } from "@ant-design/icons";
4
- import isFunction from "lodash/isFunction";
5
4
  import omit from "lodash/omit";
6
5
  import { useMemo } from "react";
7
6
  import locale from "../../../../../locale";
7
+ import {
8
+ executeToolbarAdd,
9
+ isToolbarActionVisible,
10
+ normalizeToolbarActions
11
+ } from "../toolbarActions";
8
12
  const actions = {
9
13
  add: {
10
14
  onClick: (value, { operation }) => {
@@ -15,65 +19,27 @@ const actions = {
15
19
  icon: /* @__PURE__ */ jsx(PlusOutlined, {})
16
20
  }
17
21
  };
18
- const defaultActionProps = [{ type: "add" }];
19
22
  const filterKeys = ["actionType", "addIndex", "show"];
20
23
  const ToolbarButton = (props) => {
21
24
  const { namePath, form, operation, length, fields, min, max, disabled, isView } = props;
22
- const toolbarProps = useMemo(() => {
23
- var _a;
24
- const _toolbarProps = (_a = props.toolbarProps) == null ? void 0 : _a.map((item) => {
25
- return {
26
- ...item,
27
- type: item.actionType || item.type
28
- };
29
- });
30
- if (!(_toolbarProps == null ? void 0 : _toolbarProps.find((item) => item.type === "add"))) {
31
- return _toolbarProps ? [..._toolbarProps, ...defaultActionProps] : defaultActionProps;
32
- }
33
- return _toolbarProps;
34
- }, [props.toolbarProps]);
35
- const handleClick = async (defaultCallback, callback, item) => {
36
- const value = form.getFieldValue(namePath);
37
- const data = await (callback == null ? void 0 : callback(value, { operation, form, namePath, index: (value == null ? void 0 : value.length) || 0 }));
38
- if (!callback || data === true) {
39
- if ((item == null ? void 0 : item.type) === "add") {
40
- if (item.addIndex !== void 0) {
41
- const insertIndex = typeof item.addIndex === "function" ? item.addIndex(value, { namePath, form, operation, index: (value == null ? void 0 : value.length) || 0 }) : item.addIndex;
42
- operation.add(data, insertIndex);
43
- } else {
44
- operation.add(data);
45
- }
46
- } else {
47
- defaultCallback == null ? void 0 : defaultCallback(value, { operation, form, namePath, index: (value == null ? void 0 : value.length) || 0 });
48
- }
49
- return;
50
- }
51
- if ((item == null ? void 0 : item.type) === "add" && data) {
52
- if (item.addIndex !== void 0) {
53
- const insertIndex = typeof item.addIndex === "function" ? item.addIndex(value, { namePath, form, operation, index: (value == null ? void 0 : value.length) || 0 }) : item.addIndex;
54
- operation.add(data, insertIndex);
55
- } else {
56
- operation.add(data);
57
- }
58
- }
59
- };
25
+ const toolbarProps = useMemo(
26
+ () => normalizeToolbarActions(props.toolbarProps),
27
+ [props.toolbarProps]
28
+ );
60
29
  const customClick = (callback, item) => {
61
30
  const value = form.getFieldValue(namePath);
62
31
  callback == null ? void 0 : callback(value, { operation, form, namePath, index: 0 });
63
32
  };
64
33
  return /* @__PURE__ */ jsx(Space, { align: "start", className: "pro-form-list-toolbar", children: toolbarProps == null ? void 0 : toolbarProps.map((item) => {
65
- if (item.show === false)
34
+ if (!isToolbarActionVisible(item, form, namePath))
66
35
  return /* @__PURE__ */ jsx(Fragment, {});
67
- if (isFunction(item.show) && !item.show(form.getFieldValue(namePath), { namePath, form })) {
68
- return /* @__PURE__ */ jsx(Fragment, {});
69
- }
70
36
  const { label, onClick, onHandle, type, ...rest } = item;
71
37
  const toolbarKey = `${namePath.join(".")}-${type ?? "custom"}-${label ?? ""}`;
72
38
  const _onClick = onClick || onHandle;
73
39
  if (type === "add") {
74
40
  if (disabled || isView)
75
41
  return /* @__PURE__ */ jsx(Fragment, {});
76
- const { onClick: internalOnClick, label: defaultLabel, ...defaultRest } = actions[type];
42
+ const { label: defaultLabel, ...defaultRest } = actions[type];
77
43
  if (max && max <= fields.length && type === "add") {
78
44
  return false;
79
45
  }
@@ -83,7 +49,7 @@ const ToolbarButton = (props) => {
83
49
  ...actions[type],
84
50
  ...omit(rest, filterKeys),
85
51
  type: "link",
86
- onClick: () => handleClick(internalOnClick, _onClick, item),
52
+ onClick: () => executeToolbarAdd({ action: item, form, namePath, operation }),
87
53
  children: label || defaultLabel
88
54
  },
89
55
  toolbarKey
@@ -10,6 +10,7 @@ import ToolbarButton from "./components/ToolbarButton";
10
10
  import BlockFields from "./components/BlockFields";
11
11
  import LineFields from "./components/LineFields";
12
12
  import Empty from "./components/Empty";
13
+ import TabsFields from "./components/TabsFields";
13
14
  import ProForm from "../../../../ProForm";
14
15
  import { useProConfig } from "../../../../ProConfigProvider";
15
16
  const FormList = (props, ref) => {
@@ -108,6 +109,24 @@ const FormList = (props, ref) => {
108
109
  props.operation.move(activeIndex, overIndex);
109
110
  }
110
111
  };
112
+ if (mode === "tabs") {
113
+ return /* @__PURE__ */ jsxs("div", { className, children: [
114
+ /* @__PURE__ */ jsx(
115
+ TabsFields,
116
+ {
117
+ ...props,
118
+ mode: "tabs",
119
+ fields,
120
+ form,
121
+ isView,
122
+ namePath: _namePath,
123
+ processColumns,
124
+ diffConfig: _diffConfig
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsx(Form.ErrorList, { errors })
128
+ ] });
129
+ }
111
130
  return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(DndContext, { onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsxs(
112
131
  SortableContext,
113
132
  {
@@ -34,7 +34,7 @@ export interface ToolbarActionType extends Omit<ActionType, 'actionType' | 'onHa
34
34
  show?: boolean | ((record: any, option: Pick<Option, 'form' | 'namePath'>) => boolean);
35
35
  addIndex?: number | ((record: any, option: Pick<Option, 'index' | 'form' | 'namePath' | 'operation'>) => number);
36
36
  }
37
- export type FormListMode = 'block' | 'line' | 'less';
37
+ export type FormListMode = 'block' | 'line' | 'less' | 'tabs';
38
38
  export interface FormListType {
39
39
  columns: ProFormColumnType[];
40
40
  otherProps?: ProFormOtherType;