@yudaocode/univer-bases-ui 1.6.218 → 1.6.219
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/README.md +11 -10
- package/lib/cjs/index.js +2470 -741
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/locale/en-US.js +2 -0
- package/lib/cjs/locale/en-US.js.map +1 -1
- package/lib/cjs/locale/zh-CN.js +2 -0
- package/lib/cjs/locale/zh-CN.js.map +1 -1
- package/lib/es/{chunk-NBBZZM27.js → chunk-BXSQSOFB.js} +3 -1
- package/lib/es/chunk-BXSQSOFB.js.map +1 -0
- package/lib/es/{chunk-7QP7AUQ5.js → chunk-S5N3EF6I.js} +3 -1
- package/lib/es/chunk-S5N3EF6I.js.map +1 -0
- package/lib/es/index.js +2447 -711
- package/lib/es/index.js.map +1 -1
- package/lib/es/locale/en-US.js +1 -1
- package/lib/es/locale/zh-CN.js +1 -1
- package/lib/index.css +260 -0
- package/lib/types/index.d.ts +15 -2
- package/lib/types/locale/zh-CN.d.ts +2 -0
- package/package.json +3 -3
- package/lib/es/chunk-7QP7AUQ5.js.map +0 -1
- package/lib/es/chunk-NBBZZM27.js.map +0 -1
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
zh_CN_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BXSQSOFB.js";
|
|
4
4
|
import {
|
|
5
5
|
en_US_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S5N3EF6I.js";
|
|
7
7
|
import {
|
|
8
8
|
__decorateClass,
|
|
9
9
|
__decorateParam
|
|
@@ -107,6 +107,63 @@ var BaseFormIcon = createSvgIcon(
|
|
|
107
107
|
/* @__PURE__ */ jsx("path", { d: "M5.2 5.2H10.8M5.2 8H10.8M5.2 10.8H8.5", strokeWidth: "1.3", strokeLinecap: "round" })
|
|
108
108
|
] })
|
|
109
109
|
);
|
|
110
|
+
var BaseListIcon = createSvgIcon(
|
|
111
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
112
|
+
/* @__PURE__ */ jsx("circle", { cx: "3.2", cy: "4", r: "1", fill: "currentColor", stroke: "none" }),
|
|
113
|
+
/* @__PURE__ */ jsx("path", { d: "M5.5 4H13.5", strokeWidth: "1.35", strokeLinecap: "round" }),
|
|
114
|
+
/* @__PURE__ */ jsx("path", { d: "M3.2 5.5V12H5.5", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
115
|
+
/* @__PURE__ */ jsx("path", { d: "M3.2 8.2H5.5", strokeWidth: "1.2", strokeLinecap: "round" }),
|
|
116
|
+
/* @__PURE__ */ jsx("path", { d: "M7.2 8.2H13.5M7.2 12H13.5", strokeWidth: "1.35", strokeLinecap: "round" })
|
|
117
|
+
] })
|
|
118
|
+
);
|
|
119
|
+
var BaseBoltIcon = createSvgIcon(
|
|
120
|
+
/* @__PURE__ */ jsx(
|
|
121
|
+
"path",
|
|
122
|
+
{
|
|
123
|
+
d: "M8.8 1.8L3.6 8.6H7.8L7.2 14.2L12.4 7.4H8.2L8.8 1.8Z",
|
|
124
|
+
strokeWidth: "1.3",
|
|
125
|
+
strokeLinejoin: "round"
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
var BasePlayIcon = createSvgIcon(
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
"path",
|
|
132
|
+
{
|
|
133
|
+
d: "M4.5 3.2L12.5 8L4.5 12.8V3.2Z",
|
|
134
|
+
strokeWidth: "1.35",
|
|
135
|
+
strokeLinejoin: "round"
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
var BaseEditIcon = createSvgIcon(
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
"path",
|
|
142
|
+
{
|
|
143
|
+
d: "M10.8 2.6L13.4 5.2L5.6 13H3V10.4L10.8 2.6Z",
|
|
144
|
+
strokeWidth: "1.3",
|
|
145
|
+
strokeLinejoin: "round"
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
var BaseColumnsIcon = createSvgIcon(
|
|
150
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
151
|
+
/* @__PURE__ */ jsx("rect", { x: "2", y: "2.5", width: "12", height: "11", rx: "1.5", strokeWidth: "1.3" }),
|
|
152
|
+
/* @__PURE__ */ jsx("path", { d: "M8 2.5V13.5", strokeWidth: "1.3" })
|
|
153
|
+
] })
|
|
154
|
+
);
|
|
155
|
+
var BaseIndentIcon = createSvgIcon(
|
|
156
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
157
|
+
/* @__PURE__ */ jsx("path", { d: "M3 3.5H13M8 7.5H13M8 11.5H13", strokeWidth: "1.35", strokeLinecap: "round" }),
|
|
158
|
+
/* @__PURE__ */ jsx("path", { d: "M2.8 6.5L5.6 9L2.8 11.5", strokeWidth: "1.35", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
159
|
+
] })
|
|
160
|
+
);
|
|
161
|
+
var BaseOutdentIcon = createSvgIcon(
|
|
162
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
163
|
+
/* @__PURE__ */ jsx("path", { d: "M3 3.5H13M8 7.5H13M8 11.5H13", strokeWidth: "1.35", strokeLinecap: "round" }),
|
|
164
|
+
/* @__PURE__ */ jsx("path", { d: "M5.6 6.5L2.8 9L5.6 11.5", strokeWidth: "1.35", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
165
|
+
] })
|
|
166
|
+
);
|
|
110
167
|
var BaseDashboardIcon = createSvgIcon(
|
|
111
168
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
112
169
|
/* @__PURE__ */ jsx("rect", { x: "2", y: "2.2", width: "5.3", height: "4.8", rx: "1", strokeWidth: "1.3" }),
|
|
@@ -205,6 +262,8 @@ var BaseStarSvg = ({
|
|
|
205
262
|
);
|
|
206
263
|
var BaseViewTypeIcon = ({ type }) => {
|
|
207
264
|
switch (type) {
|
|
265
|
+
case "list":
|
|
266
|
+
return /* @__PURE__ */ jsx(BaseListIcon, {});
|
|
208
267
|
case "kanban":
|
|
209
268
|
return /* @__PURE__ */ jsx(BaseKanbanIcon, {});
|
|
210
269
|
case "calendar":
|
|
@@ -289,6 +348,8 @@ var BaseFieldTypeIcon = ({ type }) => {
|
|
|
289
348
|
var BASE_ICON_MAP = {
|
|
290
349
|
BaseTableIcon,
|
|
291
350
|
BaseGridIcon,
|
|
351
|
+
BaseListIcon,
|
|
352
|
+
BaseBoltIcon,
|
|
292
353
|
BaseKanbanIcon,
|
|
293
354
|
BaseCalendarIcon,
|
|
294
355
|
BaseGalleryIcon,
|
|
@@ -1000,25 +1061,92 @@ var DashboardView = () => {
|
|
|
1000
1061
|
};
|
|
1001
1062
|
|
|
1002
1063
|
// src/views/drawer/RecordDetailDrawer.tsx
|
|
1064
|
+
import { generateRandomId } from "@univerjs/core";
|
|
1003
1065
|
import {
|
|
1004
1066
|
DeleteBaseRecordsCommand,
|
|
1005
1067
|
formatBaseCellValue,
|
|
1006
1068
|
isComputedBaseField,
|
|
1007
1069
|
resolveBaseCellValue,
|
|
1070
|
+
resolveBaseDetailLayout,
|
|
1008
1071
|
resolveLinkedRecordItems,
|
|
1009
1072
|
toNumericValue,
|
|
1073
|
+
UpdateBaseDetailLayoutCommand,
|
|
1010
1074
|
UpdateBaseRecordCommand
|
|
1011
1075
|
} from "@yudaocode/univer-bases";
|
|
1076
|
+
import { useState as useState3 } from "react";
|
|
1012
1077
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1013
1078
|
var RecordDetailDrawer = () => {
|
|
1014
1079
|
const { unit, snapshot, commandService, selectionService, selectionState } = useActiveBaseWorkspace();
|
|
1080
|
+
const [creatingSection, setCreatingSection] = useState3(false);
|
|
1081
|
+
const [newSectionTitle, setNewSectionTitle] = useState3("");
|
|
1082
|
+
const [newSectionFieldIds, setNewSectionFieldIds] = useState3([]);
|
|
1015
1083
|
const recordId = selectionState.activeRecordDrawerId;
|
|
1016
1084
|
if (!unit || !snapshot || !recordId) return null;
|
|
1017
1085
|
const table = unit.getActiveTable();
|
|
1086
|
+
const activeView = unit.getActiveView();
|
|
1018
1087
|
const record = table?.records[recordId];
|
|
1019
1088
|
if (!table || !record) return null;
|
|
1020
1089
|
const unitId = unit.getUnitId();
|
|
1021
1090
|
const fields = table.fieldOrder.map((fid) => table.fields[fid]).filter((f) => Boolean(f));
|
|
1091
|
+
const currentLayout = activeView?.detailLayout ?? table.detailLayout ?? {
|
|
1092
|
+
columns: 1
|
|
1093
|
+
};
|
|
1094
|
+
const resolvedLayout = resolveBaseDetailLayout(table, activeView);
|
|
1095
|
+
const commitDetailLayout = (nextLayout) => {
|
|
1096
|
+
commandService.syncExecuteCommand(UpdateBaseDetailLayoutCommand.id, {
|
|
1097
|
+
unitId,
|
|
1098
|
+
tableId: table.id,
|
|
1099
|
+
...activeView?.detailLayout ? { viewId: activeView.id } : {},
|
|
1100
|
+
detailLayout: nextLayout
|
|
1101
|
+
});
|
|
1102
|
+
};
|
|
1103
|
+
const toggleSectionCollapsed = (sectionId) => {
|
|
1104
|
+
const existingSections = currentLayout.sections && currentLayout.sections.length > 0 ? currentLayout.sections : resolvedLayout.sections.map((s) => ({
|
|
1105
|
+
id: s.id,
|
|
1106
|
+
title: s.title,
|
|
1107
|
+
collapsed: s.collapsed,
|
|
1108
|
+
fieldIds: s.fields.map((f) => f.id)
|
|
1109
|
+
}));
|
|
1110
|
+
commitDetailLayout({
|
|
1111
|
+
...currentLayout,
|
|
1112
|
+
sections: existingSections.map(
|
|
1113
|
+
(s) => s.id === sectionId ? { ...s, collapsed: !s.collapsed } : s
|
|
1114
|
+
)
|
|
1115
|
+
});
|
|
1116
|
+
};
|
|
1117
|
+
const handleCreateSection = () => {
|
|
1118
|
+
const title = newSectionTitle.trim() || `\u81EA\u5B9A\u4E49\u5206\u7EC4 ${(currentLayout.sections?.length ?? 0) + 1}`;
|
|
1119
|
+
const chosenFieldIds = newSectionFieldIds.length > 0 ? newSectionFieldIds : fields.slice(0, Math.min(3, fields.length)).map((f) => f.id);
|
|
1120
|
+
const prevSections = currentLayout.sections ?? [];
|
|
1121
|
+
const cleanedPrev = prevSections.map((sec) => ({
|
|
1122
|
+
...sec,
|
|
1123
|
+
fieldIds: sec.fieldIds.filter((fid) => !chosenFieldIds.includes(fid))
|
|
1124
|
+
}));
|
|
1125
|
+
const nextSections = [
|
|
1126
|
+
...cleanedPrev,
|
|
1127
|
+
{
|
|
1128
|
+
id: `sec_${generateRandomId(5)}`,
|
|
1129
|
+
title,
|
|
1130
|
+
collapsed: false,
|
|
1131
|
+
fieldIds: chosenFieldIds
|
|
1132
|
+
}
|
|
1133
|
+
];
|
|
1134
|
+
commitDetailLayout({
|
|
1135
|
+
...currentLayout,
|
|
1136
|
+
sections: nextSections
|
|
1137
|
+
});
|
|
1138
|
+
setNewSectionTitle("");
|
|
1139
|
+
setNewSectionFieldIds([]);
|
|
1140
|
+
setCreatingSection(false);
|
|
1141
|
+
};
|
|
1142
|
+
const handleDeleteSection = (sectionId) => {
|
|
1143
|
+
if (!currentLayout.sections) return;
|
|
1144
|
+
const nextSections = currentLayout.sections.filter((s) => s.id !== sectionId);
|
|
1145
|
+
commitDetailLayout({
|
|
1146
|
+
...currentLayout,
|
|
1147
|
+
sections: nextSections.length > 0 ? nextSections : void 0
|
|
1148
|
+
});
|
|
1149
|
+
};
|
|
1022
1150
|
const updateCell = (fieldId, value) => {
|
|
1023
1151
|
commandService.syncExecuteCommand(UpdateBaseRecordCommand.id, {
|
|
1024
1152
|
unitId,
|
|
@@ -1034,192 +1162,362 @@ var RecordDetailDrawer = () => {
|
|
|
1034
1162
|
primaryField,
|
|
1035
1163
|
resolveBaseCellValue(snapshot, table.id, record, primaryField)
|
|
1036
1164
|
) : record.id;
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
"
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
/* @__PURE__ */ jsx4("h3", { className: "univer-bases-drawer__title", children: recordTitle || "\u672A\u547D\u540D\u8BB0\u5F55" })
|
|
1165
|
+
const renderFieldControl = (field) => {
|
|
1166
|
+
const val = resolveBaseCellValue(snapshot, table.id, record, field);
|
|
1167
|
+
const disp = formatBaseCellValue(snapshot, table.id, field, val);
|
|
1168
|
+
return /* @__PURE__ */ jsxs4(
|
|
1169
|
+
"div",
|
|
1170
|
+
{
|
|
1171
|
+
className: "univer-bases-drawer__field",
|
|
1172
|
+
"data-testid": `bases-detail-field-${field.id}`,
|
|
1173
|
+
children: [
|
|
1174
|
+
/* @__PURE__ */ jsxs4("label", { className: "univer-bases-form-field-label", children: [
|
|
1175
|
+
/* @__PURE__ */ jsx4(BaseFieldTypeIcon, { type: field.type }),
|
|
1176
|
+
/* @__PURE__ */ jsx4("span", { children: field.name }),
|
|
1177
|
+
isComputedBaseField(field.type) && /* @__PURE__ */ jsx4("span", { className: "univer-bases-computed-badge", children: "\u81EA\u52A8\u8BA1\u7B97" })
|
|
1051
1178
|
] }),
|
|
1052
|
-
/* @__PURE__ */
|
|
1053
|
-
/* @__PURE__ */ jsxs4(
|
|
1054
|
-
"button",
|
|
1055
|
-
{
|
|
1056
|
-
type: "button",
|
|
1057
|
-
className: "univer-bases-btn univer-bases-btn--danger univer-bases-btn--sm",
|
|
1058
|
-
onClick: () => {
|
|
1059
|
-
commandService.syncExecuteCommand(DeleteBaseRecordsCommand.id, {
|
|
1060
|
-
unitId,
|
|
1061
|
-
tableId: table.id,
|
|
1062
|
-
recordIds: [record.id]
|
|
1063
|
-
});
|
|
1064
|
-
selectionService.openRecordDrawer(null);
|
|
1065
|
-
},
|
|
1066
|
-
children: [
|
|
1067
|
-
/* @__PURE__ */ jsx4(BaseTrashIcon, {}),
|
|
1068
|
-
/* @__PURE__ */ jsx4("span", { children: "\u5220\u9664" })
|
|
1069
|
-
]
|
|
1070
|
-
}
|
|
1071
|
-
),
|
|
1179
|
+
isComputedBaseField(field.type) ? /* @__PURE__ */ jsx4("div", { className: "univer-bases-drawer__readonly", children: disp || "\u2014" }) : field.type === "checkbox" ? /* @__PURE__ */ jsxs4("label", { className: "univer-bases-checkbox-label", children: [
|
|
1072
1180
|
/* @__PURE__ */ jsx4(
|
|
1073
|
-
"
|
|
1181
|
+
"input",
|
|
1074
1182
|
{
|
|
1075
|
-
type: "
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
children: /* @__PURE__ */ jsx4(BaseCloseIcon, {})
|
|
1183
|
+
type: "checkbox",
|
|
1184
|
+
checked: Boolean(val),
|
|
1185
|
+
onChange: (e) => updateCell(field.id, e.target.checked)
|
|
1079
1186
|
}
|
|
1080
|
-
)
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1187
|
+
),
|
|
1188
|
+
/* @__PURE__ */ jsx4("span", { children: val ? "\u5DF2\u52FE\u9009" : "\u672A\u52FE\u9009" })
|
|
1189
|
+
] }) : field.type === "singleSelect" ? /* @__PURE__ */ jsxs4(
|
|
1190
|
+
"select",
|
|
1191
|
+
{
|
|
1192
|
+
className: "univer-bases-select",
|
|
1193
|
+
value: String(val ?? ""),
|
|
1194
|
+
onChange: (e) => updateCell(field.id, e.target.value),
|
|
1195
|
+
children: [
|
|
1196
|
+
/* @__PURE__ */ jsx4("option", { value: "", children: "-- \u672A\u9009\u62E9 --" }),
|
|
1197
|
+
(field.config?.options ?? []).map((opt) => /* @__PURE__ */ jsx4("option", { value: opt.name, children: opt.name }, opt.id))
|
|
1198
|
+
]
|
|
1199
|
+
}
|
|
1200
|
+
) : field.type === "multiSelect" ? /* @__PURE__ */ jsx4("div", { className: "univer-bases-tag-wrap", children: (field.config?.options ?? []).map((opt) => {
|
|
1201
|
+
const arr = Array.isArray(val) ? val.map(String) : [];
|
|
1202
|
+
const active = arr.includes(opt.name);
|
|
1203
|
+
return /* @__PURE__ */ jsxs4("label", { className: "univer-bases-checkbox-label", children: [
|
|
1093
1204
|
/* @__PURE__ */ jsx4(
|
|
1094
1205
|
"input",
|
|
1095
1206
|
{
|
|
1096
1207
|
type: "checkbox",
|
|
1097
|
-
checked:
|
|
1098
|
-
onChange: (
|
|
1208
|
+
checked: active,
|
|
1209
|
+
onChange: () => {
|
|
1210
|
+
const next = active ? arr.filter((v) => v !== opt.name) : [...arr, opt.name];
|
|
1211
|
+
updateCell(field.id, next);
|
|
1212
|
+
}
|
|
1099
1213
|
}
|
|
1100
1214
|
),
|
|
1101
|
-
/* @__PURE__ */ jsx4("span", { children:
|
|
1102
|
-
] }
|
|
1103
|
-
|
|
1215
|
+
/* @__PURE__ */ jsx4("span", { children: opt.name })
|
|
1216
|
+
] }, opt.id);
|
|
1217
|
+
}) }) : field.type === "rating" ? /* @__PURE__ */ jsx4("div", { className: "univer-bases-rating-stars", children: Array.from({ length: field.config?.maxRating ?? 5 }, (_, idx) => /* @__PURE__ */ jsx4(
|
|
1218
|
+
BaseStarSvg,
|
|
1219
|
+
{
|
|
1220
|
+
filled: idx + 1 <= Math.round(toNumericValue(val) ?? 0),
|
|
1221
|
+
onClick: () => updateCell(field.id, idx + 1)
|
|
1222
|
+
},
|
|
1223
|
+
idx
|
|
1224
|
+
)) }) : field.type === "link" ? /* @__PURE__ */ jsxs4("div", { className: "univer-bases-link-cell", children: [
|
|
1225
|
+
resolveLinkedRecordItems(snapshot, record, field).map((item) => /* @__PURE__ */ jsxs4("span", { className: "univer-bases-link-chip", children: [
|
|
1226
|
+
/* @__PURE__ */ jsx4(BaseLinkIcon, {}),
|
|
1227
|
+
/* @__PURE__ */ jsx4("span", { children: item.title })
|
|
1228
|
+
] }, item.id)),
|
|
1229
|
+
field.config?.linkedTableId && /* @__PURE__ */ jsxs4(
|
|
1230
|
+
"button",
|
|
1104
1231
|
{
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1232
|
+
type: "button",
|
|
1233
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
1234
|
+
onClick: () => {
|
|
1235
|
+
selectionService.openLinkPicker({
|
|
1236
|
+
tableId: table.id,
|
|
1237
|
+
recordId: record.id,
|
|
1238
|
+
fieldId: field.id,
|
|
1239
|
+
linkedTableId: field.config.linkedTableId,
|
|
1240
|
+
allowMultiple: field.config?.allowMultiple !== false
|
|
1241
|
+
});
|
|
1242
|
+
},
|
|
1108
1243
|
children: [
|
|
1109
|
-
/* @__PURE__ */ jsx4(
|
|
1110
|
-
|
|
1244
|
+
/* @__PURE__ */ jsx4(BasePlusIcon, {}),
|
|
1245
|
+
/* @__PURE__ */ jsx4("span", { children: "\u914D\u7F6E\u5173\u8054\u8BB0\u5F55" })
|
|
1111
1246
|
]
|
|
1112
1247
|
}
|
|
1113
|
-
)
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1248
|
+
)
|
|
1249
|
+
] }) : field.type === "date" ? /* @__PURE__ */ jsx4(
|
|
1250
|
+
"input",
|
|
1251
|
+
{
|
|
1252
|
+
type: "date",
|
|
1253
|
+
className: "univer-bases-input",
|
|
1254
|
+
value: typeof val === "string" ? val.slice(0, 10) : "",
|
|
1255
|
+
onChange: (e) => updateCell(field.id, e.target.value)
|
|
1256
|
+
}
|
|
1257
|
+
) : /* @__PURE__ */ jsx4(
|
|
1258
|
+
"input",
|
|
1259
|
+
{
|
|
1260
|
+
type: "text",
|
|
1261
|
+
className: "univer-bases-input",
|
|
1262
|
+
value: disp,
|
|
1263
|
+
onChange: (e) => {
|
|
1264
|
+
const raw = e.target.value;
|
|
1265
|
+
if (field.type === "number" || field.type === "currency" || field.type === "percent") {
|
|
1266
|
+
updateCell(field.id, toNumericValue(raw) ?? raw);
|
|
1267
|
+
} else {
|
|
1268
|
+
updateCell(field.id, raw);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
)
|
|
1273
|
+
]
|
|
1274
|
+
},
|
|
1275
|
+
field.id
|
|
1276
|
+
);
|
|
1277
|
+
};
|
|
1278
|
+
return /* @__PURE__ */ jsx4(
|
|
1279
|
+
"div",
|
|
1280
|
+
{
|
|
1281
|
+
className: "univer-bases-drawer-backdrop",
|
|
1282
|
+
onClick: () => selectionService.openRecordDrawer(null),
|
|
1283
|
+
children: /* @__PURE__ */ jsxs4(
|
|
1284
|
+
"aside",
|
|
1285
|
+
{
|
|
1286
|
+
className: `univer-bases-drawer ${resolvedLayout.columns === 2 ? "is-two-col" : ""}`,
|
|
1287
|
+
"data-testid": "bases-record-detail-drawer",
|
|
1288
|
+
"data-columns": resolvedLayout.columns,
|
|
1289
|
+
onClick: (e) => e.stopPropagation(),
|
|
1290
|
+
children: [
|
|
1291
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-drawer__header", children: [
|
|
1292
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
1293
|
+
/* @__PURE__ */ jsxs4("span", { className: "univer-bases-muted-key", children: [
|
|
1294
|
+
table.name,
|
|
1295
|
+
" \xB7 \u8BB0\u5F55\u8BE6\u60C5"
|
|
1296
|
+
] }),
|
|
1297
|
+
/* @__PURE__ */ jsx4("h3", { className: "univer-bases-drawer__title", children: recordTitle || "\u672A\u547D\u540D\u8BB0\u5F55" })
|
|
1298
|
+
] }),
|
|
1299
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-inline-flex", children: [
|
|
1300
|
+
/* @__PURE__ */ jsxs4(
|
|
1301
|
+
"button",
|
|
1119
1302
|
{
|
|
1120
|
-
type: "
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1303
|
+
type: "button",
|
|
1304
|
+
className: "univer-bases-btn univer-bases-btn--danger univer-bases-btn--sm",
|
|
1305
|
+
onClick: () => {
|
|
1306
|
+
commandService.syncExecuteCommand(DeleteBaseRecordsCommand.id, {
|
|
1307
|
+
unitId,
|
|
1308
|
+
tableId: table.id,
|
|
1309
|
+
recordIds: [record.id]
|
|
1310
|
+
});
|
|
1311
|
+
selectionService.openRecordDrawer(null);
|
|
1312
|
+
},
|
|
1313
|
+
children: [
|
|
1314
|
+
/* @__PURE__ */ jsx4(BaseTrashIcon, {}),
|
|
1315
|
+
/* @__PURE__ */ jsx4("span", { children: "\u5220\u9664" })
|
|
1316
|
+
]
|
|
1126
1317
|
}
|
|
1127
1318
|
),
|
|
1128
|
-
/* @__PURE__ */ jsx4(
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
/* @__PURE__ */
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1319
|
+
/* @__PURE__ */ jsx4(
|
|
1320
|
+
"button",
|
|
1321
|
+
{
|
|
1322
|
+
type: "button",
|
|
1323
|
+
className: "univer-bases-icon-btn",
|
|
1324
|
+
onClick: () => selectionService.openRecordDrawer(null),
|
|
1325
|
+
children: /* @__PURE__ */ jsx4(BaseCloseIcon, {})
|
|
1326
|
+
}
|
|
1327
|
+
)
|
|
1328
|
+
] })
|
|
1329
|
+
] }),
|
|
1330
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-drawer__layout-bar", "data-testid": "bases-detail-layout-bar", children: [
|
|
1331
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-inline-flex", children: [
|
|
1332
|
+
/* @__PURE__ */ jsx4(BaseColumnsIcon, {}),
|
|
1333
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-segmented", role: "group", "aria-label": "\u5355\u680F\u53CC\u680F\u5207\u6362", children: [
|
|
1334
|
+
/* @__PURE__ */ jsx4(
|
|
1335
|
+
"button",
|
|
1336
|
+
{
|
|
1337
|
+
type: "button",
|
|
1338
|
+
className: `univer-bases-segmented__item ${resolvedLayout.columns === 1 ? "is-active" : ""}`,
|
|
1339
|
+
"data-testid": "bases-detail-col-1",
|
|
1340
|
+
onClick: () => commitDetailLayout({ ...currentLayout, columns: 1 }),
|
|
1341
|
+
children: "\u5355\u680F"
|
|
1342
|
+
}
|
|
1343
|
+
),
|
|
1344
|
+
/* @__PURE__ */ jsx4(
|
|
1345
|
+
"button",
|
|
1346
|
+
{
|
|
1347
|
+
type: "button",
|
|
1348
|
+
className: `univer-bases-segmented__item ${resolvedLayout.columns === 2 ? "is-active" : ""}`,
|
|
1349
|
+
"data-testid": "bases-detail-col-2",
|
|
1350
|
+
onClick: () => commitDetailLayout({ ...currentLayout, columns: 2 }),
|
|
1351
|
+
children: "\u53CC\u680F"
|
|
1352
|
+
}
|
|
1353
|
+
)
|
|
1354
|
+
] })
|
|
1355
|
+
] }),
|
|
1356
|
+
/* @__PURE__ */ jsxs4(
|
|
1146
1357
|
"button",
|
|
1147
1358
|
{
|
|
1148
1359
|
type: "button",
|
|
1149
1360
|
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
tableId: table.id,
|
|
1153
|
-
recordId: record.id,
|
|
1154
|
-
fieldId: field.id,
|
|
1155
|
-
linkedTableId: field.config.linkedTableId,
|
|
1156
|
-
allowMultiple: field.config?.allowMultiple !== false
|
|
1157
|
-
});
|
|
1158
|
-
},
|
|
1361
|
+
"data-testid": "bases-detail-add-section-btn",
|
|
1362
|
+
onClick: () => setCreatingSection((prev) => !prev),
|
|
1159
1363
|
children: [
|
|
1160
1364
|
/* @__PURE__ */ jsx4(BasePlusIcon, {}),
|
|
1161
|
-
/* @__PURE__ */ jsx4("span", { children: "\
|
|
1365
|
+
/* @__PURE__ */ jsx4("span", { children: "\u65B0\u5EFA\u5B57\u6BB5\u5206\u7EC4" })
|
|
1162
1366
|
]
|
|
1163
1367
|
}
|
|
1164
1368
|
)
|
|
1165
|
-
] })
|
|
1166
|
-
|
|
1167
|
-
{
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
className: "univer-bases-input",
|
|
1178
|
-
value: disp,
|
|
1179
|
-
onChange: (e) => {
|
|
1180
|
-
const raw = e.target.value;
|
|
1181
|
-
if (field.type === "number" || field.type === "currency" || field.type === "percent") {
|
|
1182
|
-
updateCell(field.id, toNumericValue(raw) ?? raw);
|
|
1183
|
-
} else {
|
|
1184
|
-
updateCell(field.id, raw);
|
|
1369
|
+
] }),
|
|
1370
|
+
creatingSection && /* @__PURE__ */ jsxs4("div", { className: "univer-bases-drawer__new-section", "data-testid": "bases-detail-new-section-box", children: [
|
|
1371
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-form-row", children: [
|
|
1372
|
+
/* @__PURE__ */ jsx4("label", { children: "\u5206\u7EC4\u6807\u9898" }),
|
|
1373
|
+
/* @__PURE__ */ jsx4(
|
|
1374
|
+
"input",
|
|
1375
|
+
{
|
|
1376
|
+
type: "text",
|
|
1377
|
+
className: "univer-bases-input",
|
|
1378
|
+
placeholder: "\u4F8B\u5982\uFF1A\u6392\u671F\u4E0E\u9884\u7B97\u4FE1\u606F",
|
|
1379
|
+
value: newSectionTitle,
|
|
1380
|
+
onChange: (e) => setNewSectionTitle(e.target.value)
|
|
1185
1381
|
}
|
|
1186
|
-
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1382
|
+
)
|
|
1383
|
+
] }),
|
|
1384
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-form-row", children: [
|
|
1385
|
+
/* @__PURE__ */ jsx4("label", { children: "\u9009\u62E9\u7EB3\u5165\u8BE5\u5206\u7EC4\u7684\u5B57\u6BB5" }),
|
|
1386
|
+
/* @__PURE__ */ jsx4("div", { className: "univer-bases-tag-wrap", children: fields.map((f) => {
|
|
1387
|
+
const checked = newSectionFieldIds.includes(f.id);
|
|
1388
|
+
return /* @__PURE__ */ jsxs4("label", { className: "univer-bases-checkbox-label", children: [
|
|
1389
|
+
/* @__PURE__ */ jsx4(
|
|
1390
|
+
"input",
|
|
1391
|
+
{
|
|
1392
|
+
type: "checkbox",
|
|
1393
|
+
checked,
|
|
1394
|
+
onChange: () => setNewSectionFieldIds(
|
|
1395
|
+
(prev) => checked ? prev.filter((id) => id !== f.id) : [...prev, f.id]
|
|
1396
|
+
)
|
|
1397
|
+
}
|
|
1398
|
+
),
|
|
1399
|
+
/* @__PURE__ */ jsx4("span", { children: f.name })
|
|
1400
|
+
] }, f.id);
|
|
1401
|
+
}) })
|
|
1402
|
+
] }),
|
|
1403
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-inline-flex", style: { justifyContent: "flex-end" }, children: [
|
|
1404
|
+
/* @__PURE__ */ jsx4(
|
|
1405
|
+
"button",
|
|
1406
|
+
{
|
|
1407
|
+
type: "button",
|
|
1408
|
+
className: "univer-bases-btn univer-bases-btn--ghost univer-bases-btn--sm",
|
|
1409
|
+
onClick: () => setCreatingSection(false),
|
|
1410
|
+
children: "\u53D6\u6D88"
|
|
1411
|
+
}
|
|
1412
|
+
),
|
|
1413
|
+
/* @__PURE__ */ jsx4(
|
|
1414
|
+
"button",
|
|
1415
|
+
{
|
|
1416
|
+
type: "button",
|
|
1417
|
+
className: "univer-bases-btn univer-bases-btn--primary univer-bases-btn--sm",
|
|
1418
|
+
onClick: handleCreateSection,
|
|
1419
|
+
children: "\u521B\u5EFA\u5206\u7EC4"
|
|
1420
|
+
}
|
|
1421
|
+
)
|
|
1422
|
+
] })
|
|
1423
|
+
] }),
|
|
1424
|
+
/* @__PURE__ */ jsx4("div", { className: "univer-bases-drawer__body", children: resolvedLayout.sections.map((section) => {
|
|
1425
|
+
const isCustom = Boolean(
|
|
1426
|
+
currentLayout.sections?.some((s) => s.id === section.id)
|
|
1427
|
+
);
|
|
1428
|
+
return /* @__PURE__ */ jsxs4(
|
|
1429
|
+
"section",
|
|
1430
|
+
{
|
|
1431
|
+
className: "univer-bases-drawer__section",
|
|
1432
|
+
"data-testid": `bases-detail-section-${section.id}`,
|
|
1433
|
+
children: [
|
|
1434
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-drawer__section-header", children: [
|
|
1435
|
+
/* @__PURE__ */ jsxs4(
|
|
1436
|
+
"button",
|
|
1437
|
+
{
|
|
1438
|
+
type: "button",
|
|
1439
|
+
className: "univer-bases-drawer__section-toggle",
|
|
1440
|
+
onClick: () => toggleSectionCollapsed(section.id),
|
|
1441
|
+
children: [
|
|
1442
|
+
section.collapsed ? /* @__PURE__ */ jsx4(BaseChevronRightIcon, {}) : /* @__PURE__ */ jsx4(BaseChevronDownIcon, {}),
|
|
1443
|
+
/* @__PURE__ */ jsx4("strong", { children: section.title }),
|
|
1444
|
+
/* @__PURE__ */ jsx4("span", { className: "univer-bases-badge-count", children: section.fields.length })
|
|
1445
|
+
]
|
|
1446
|
+
}
|
|
1447
|
+
),
|
|
1448
|
+
isCustom && /* @__PURE__ */ jsx4(
|
|
1449
|
+
"button",
|
|
1450
|
+
{
|
|
1451
|
+
type: "button",
|
|
1452
|
+
className: "univer-bases-icon-btn",
|
|
1453
|
+
title: "\u79FB\u9664\u6B64\u5206\u7EC4\uFF08\u5B57\u6BB5\u81EA\u52A8\u5F52\u8FD8\uFF09",
|
|
1454
|
+
onClick: () => handleDeleteSection(section.id),
|
|
1455
|
+
children: /* @__PURE__ */ jsx4(BaseTrashIcon, {})
|
|
1456
|
+
}
|
|
1457
|
+
)
|
|
1458
|
+
] }),
|
|
1459
|
+
!section.collapsed && /* @__PURE__ */ jsx4(
|
|
1460
|
+
"div",
|
|
1461
|
+
{
|
|
1462
|
+
className: `univer-bases-drawer__fields-grid ${resolvedLayout.columns === 2 ? "is-two-columns" : "is-one-column"}`,
|
|
1463
|
+
"data-testid": `bases-detail-grid-${section.id}`,
|
|
1464
|
+
children: section.fields.map((field) => renderFieldControl(field))
|
|
1465
|
+
}
|
|
1466
|
+
)
|
|
1467
|
+
]
|
|
1468
|
+
},
|
|
1469
|
+
section.id
|
|
1470
|
+
);
|
|
1471
|
+
}) }),
|
|
1472
|
+
/* @__PURE__ */ jsxs4("div", { className: "univer-bases-drawer__footer", children: [
|
|
1473
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1474
|
+
"\u521B\u5EFA\u65F6\u95F4: ",
|
|
1475
|
+
record.createdTime
|
|
1476
|
+
] }),
|
|
1477
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1478
|
+
"\u6700\u540E\u66F4\u65B0: ",
|
|
1479
|
+
record.lastModifiedTime
|
|
1480
|
+
] })
|
|
1481
|
+
] })
|
|
1482
|
+
]
|
|
1483
|
+
}
|
|
1484
|
+
)
|
|
1202
1485
|
}
|
|
1203
|
-
)
|
|
1486
|
+
);
|
|
1204
1487
|
};
|
|
1205
1488
|
|
|
1206
1489
|
// src/views/form/FormView.tsx
|
|
1490
|
+
import { generateRandomId as generateRandomId2 } from "@univerjs/core";
|
|
1207
1491
|
import {
|
|
1208
1492
|
isCellValueEmpty,
|
|
1209
1493
|
isComputedBaseField as isComputedBaseField2,
|
|
1494
|
+
isFormFieldRequired,
|
|
1495
|
+
isFormFieldVisible,
|
|
1210
1496
|
SubmitBaseFormResponseCommand,
|
|
1211
1497
|
toNumericValue as toNumericValue2,
|
|
1212
1498
|
UpdateBaseViewCommand as UpdateBaseViewCommand2
|
|
1213
1499
|
} from "@yudaocode/univer-bases";
|
|
1214
|
-
import { useState as
|
|
1500
|
+
import { useState as useState4 } from "react";
|
|
1215
1501
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1502
|
+
var CONDITION_OPERATORS = [
|
|
1503
|
+
{ value: "is", label: "\u7B49\u4E8E" },
|
|
1504
|
+
{ value: "isNot", label: "\u4E0D\u7B49\u4E8E" },
|
|
1505
|
+
{ value: "contains", label: "\u5305\u542B" },
|
|
1506
|
+
{ value: "notContains", label: "\u4E0D\u5305\u542B" },
|
|
1507
|
+
{ value: "gt", label: "\u5927\u4E8E" },
|
|
1508
|
+
{ value: "gte", label: "\u5927\u4E8E\u7B49\u4E8E" },
|
|
1509
|
+
{ value: "lt", label: "\u5C0F\u4E8E" },
|
|
1510
|
+
{ value: "lte", label: "\u5C0F\u4E8E\u7B49\u4E8E" },
|
|
1511
|
+
{ value: "isEmpty", label: "\u4E3A\u7A7A" },
|
|
1512
|
+
{ value: "isNotEmpty", label: "\u4E0D\u4E3A\u7A7A" }
|
|
1513
|
+
];
|
|
1216
1514
|
var FormView = ({ query }) => {
|
|
1217
|
-
const { unit, commandService } = useActiveBaseWorkspace();
|
|
1218
|
-
const [formMode, setFormMode] =
|
|
1219
|
-
const [values, setValues] =
|
|
1220
|
-
const [errorMsg, setErrorMsg] =
|
|
1221
|
-
const [submittedRecordId, setSubmittedRecordId] =
|
|
1222
|
-
if (!unit) return null;
|
|
1515
|
+
const { unit, snapshot, commandService } = useActiveBaseWorkspace();
|
|
1516
|
+
const [formMode, setFormMode] = useState4("fill");
|
|
1517
|
+
const [values, setValues] = useState4({});
|
|
1518
|
+
const [errorMsg, setErrorMsg] = useState4(null);
|
|
1519
|
+
const [submittedRecordId, setSubmittedRecordId] = useState4(null);
|
|
1520
|
+
if (!unit || !snapshot) return null;
|
|
1223
1521
|
const unitId = unit.getUnitId();
|
|
1224
1522
|
const { table, view, allFields } = query;
|
|
1225
1523
|
const editableFields = allFields.filter(
|
|
@@ -1240,12 +1538,22 @@ var FormView = ({ query }) => {
|
|
|
1240
1538
|
const configMap = new Map(resolvedConfig.fields.map((item) => [item.fieldId, item]));
|
|
1241
1539
|
const mergedFormItems = editableFields.map((f) => {
|
|
1242
1540
|
const existing = configMap.get(f.id);
|
|
1243
|
-
|
|
1541
|
+
const ruleOverride = resolvedConfig.fieldRules?.[f.id];
|
|
1542
|
+
const baseItem = existing ?? {
|
|
1244
1543
|
fieldId: f.id,
|
|
1245
1544
|
visible: true,
|
|
1246
1545
|
required: Boolean(f.isPrimary || f.required),
|
|
1247
1546
|
label: f.name
|
|
1248
1547
|
};
|
|
1548
|
+
if (ruleOverride && !baseItem.visibleWhen) {
|
|
1549
|
+
return {
|
|
1550
|
+
...baseItem,
|
|
1551
|
+
visibleWhen: ruleOverride.visibleWhen,
|
|
1552
|
+
visibleWhenConjunction: ruleOverride.visibleWhenConjunction,
|
|
1553
|
+
conditionalRequired: baseItem.conditionalRequired ?? ruleOverride.conditionalRequired
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
return baseItem;
|
|
1249
1557
|
});
|
|
1250
1558
|
const saveFormConfig = (nextConfig) => {
|
|
1251
1559
|
commandService.syncExecuteCommand(UpdateBaseViewCommand2.id, {
|
|
@@ -1255,11 +1563,16 @@ var FormView = ({ query }) => {
|
|
|
1255
1563
|
patch: { formConfig: nextConfig }
|
|
1256
1564
|
});
|
|
1257
1565
|
};
|
|
1566
|
+
const updateFieldItemAt = (idx, patch) => {
|
|
1567
|
+
const nextItems = mergedFormItems.map((it, i) => i === idx ? { ...it, ...patch } : it);
|
|
1568
|
+
saveFormConfig({ ...resolvedConfig, fields: nextItems });
|
|
1569
|
+
};
|
|
1258
1570
|
const handleSubmit = (e) => {
|
|
1259
1571
|
e.preventDefault();
|
|
1260
1572
|
setErrorMsg(null);
|
|
1261
1573
|
for (const item of mergedFormItems) {
|
|
1262
|
-
if (!item
|
|
1574
|
+
if (!isFormFieldVisible(item, values, table, snapshot, resolvedConfig)) continue;
|
|
1575
|
+
if (!isFormFieldRequired(item, values, table, snapshot, resolvedConfig)) continue;
|
|
1263
1576
|
const f = table.fields[item.fieldId];
|
|
1264
1577
|
if (!f) continue;
|
|
1265
1578
|
const v = values[f.id];
|
|
@@ -1286,6 +1599,9 @@ var FormView = ({ query }) => {
|
|
|
1286
1599
|
setErrorMsg("\u8868\u5355\u6821\u9A8C\u672A\u901A\u8FC7\uFF0C\u8BF7\u68C0\u67E5\u5FC5\u586B\u9879\u540E\u91CD\u8BD5\u3002");
|
|
1287
1600
|
}
|
|
1288
1601
|
};
|
|
1602
|
+
const visibleFillItems = mergedFormItems.filter(
|
|
1603
|
+
(item) => isFormFieldVisible(item, values, table, snapshot, resolvedConfig)
|
|
1604
|
+
);
|
|
1289
1605
|
return /* @__PURE__ */ jsxs5("div", { className: "univer-bases-form-view", "data-testid": "bases-form-view", children: [
|
|
1290
1606
|
/* @__PURE__ */ jsx5("div", { className: "univer-bases-subbar", style: { justifyContent: "center" }, children: /* @__PURE__ */ jsxs5("div", { className: "univer-bases-segmented", role: "tablist", children: [
|
|
1291
1607
|
/* @__PURE__ */ jsx5(
|
|
@@ -1348,62 +1664,201 @@ var FormView = ({ query }) => {
|
|
|
1348
1664
|
)
|
|
1349
1665
|
] }),
|
|
1350
1666
|
/* @__PURE__ */ jsxs5("div", { className: "univer-bases-form-design-list", children: [
|
|
1351
|
-
/* @__PURE__ */ jsx5("strong", { children: "\u5B57\u6BB5\u663E\u9690\
|
|
1667
|
+
/* @__PURE__ */ jsx5("strong", { children: "\u5B57\u6BB5\u663E\u9690\u3001\u5FC5\u586B\u4E0E\u6761\u4EF6\u8054\u52A8\u914D\u7F6E" }),
|
|
1352
1668
|
mergedFormItems.map((item, idx) => {
|
|
1353
1669
|
const field = table.fields[item.fieldId];
|
|
1354
1670
|
if (!field) return null;
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
)
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
)
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1671
|
+
const condRules = item.visibleWhen ?? [];
|
|
1672
|
+
const candidateTriggerFields = editableFields.filter(
|
|
1673
|
+
(ef) => ef.id !== field.id
|
|
1674
|
+
);
|
|
1675
|
+
return /* @__PURE__ */ jsxs5(
|
|
1676
|
+
"div",
|
|
1677
|
+
{
|
|
1678
|
+
className: "univer-bases-form-design-block",
|
|
1679
|
+
"data-testid": `bases-form-design-item-${field.id}`,
|
|
1680
|
+
children: [
|
|
1681
|
+
/* @__PURE__ */ jsxs5("div", { className: "univer-bases-form-design-item", children: [
|
|
1682
|
+
/* @__PURE__ */ jsxs5("div", { className: "univer-bases-inline-flex", style: { flex: 1 }, children: [
|
|
1683
|
+
/* @__PURE__ */ jsx5(BaseFieldTypeIcon, { type: field.type }),
|
|
1684
|
+
/* @__PURE__ */ jsx5(
|
|
1685
|
+
"input",
|
|
1686
|
+
{
|
|
1687
|
+
type: "text",
|
|
1688
|
+
className: "univer-bases-input",
|
|
1689
|
+
value: item.label ?? field.name,
|
|
1690
|
+
onChange: (e) => updateFieldItemAt(idx, { label: e.target.value })
|
|
1691
|
+
}
|
|
1692
|
+
)
|
|
1693
|
+
] }),
|
|
1694
|
+
/* @__PURE__ */ jsxs5("label", { className: "univer-bases-checkbox-label", children: [
|
|
1695
|
+
/* @__PURE__ */ jsx5(
|
|
1696
|
+
"input",
|
|
1697
|
+
{
|
|
1698
|
+
type: "checkbox",
|
|
1699
|
+
checked: item.visible,
|
|
1700
|
+
disabled: Boolean(field.isPrimary),
|
|
1701
|
+
onChange: (e) => updateFieldItemAt(idx, { visible: e.target.checked })
|
|
1702
|
+
}
|
|
1703
|
+
),
|
|
1704
|
+
/* @__PURE__ */ jsx5("span", { children: "\u663E\u793A" })
|
|
1705
|
+
] }),
|
|
1706
|
+
/* @__PURE__ */ jsxs5("label", { className: "univer-bases-checkbox-label", children: [
|
|
1707
|
+
/* @__PURE__ */ jsx5(
|
|
1708
|
+
"input",
|
|
1709
|
+
{
|
|
1710
|
+
type: "checkbox",
|
|
1711
|
+
checked: Boolean(item.required),
|
|
1712
|
+
onChange: (e) => updateFieldItemAt(idx, { required: e.target.checked })
|
|
1713
|
+
}
|
|
1714
|
+
),
|
|
1715
|
+
/* @__PURE__ */ jsx5("span", { children: "\u5FC5\u586B" })
|
|
1716
|
+
] }),
|
|
1717
|
+
!field.isPrimary && candidateTriggerFields.length > 0 && /* @__PURE__ */ jsxs5(
|
|
1718
|
+
"button",
|
|
1719
|
+
{
|
|
1720
|
+
type: "button",
|
|
1721
|
+
className: `univer-bases-btn univer-bases-btn--sm ${condRules.length > 0 ? "is-tinted" : "univer-bases-btn--outline"}`,
|
|
1722
|
+
"data-testid": `bases-form-add-cond-${field.id}`,
|
|
1723
|
+
onClick: () => {
|
|
1724
|
+
const refField = candidateTriggerFields[0];
|
|
1725
|
+
const defaultVal = refField.type === "singleSelect" ? refField.config?.options?.[0]?.name ?? "" : "";
|
|
1726
|
+
const nextRule = {
|
|
1727
|
+
id: `fvis_${generateRandomId2(5)}`,
|
|
1728
|
+
fieldId: refField.id,
|
|
1729
|
+
operator: "is",
|
|
1730
|
+
value: defaultVal
|
|
1731
|
+
};
|
|
1732
|
+
updateFieldItemAt(idx, {
|
|
1733
|
+
visibleWhen: [...condRules, nextRule]
|
|
1734
|
+
});
|
|
1735
|
+
},
|
|
1736
|
+
children: [
|
|
1737
|
+
/* @__PURE__ */ jsx5(BaseFilterIcon, {}),
|
|
1738
|
+
/* @__PURE__ */ jsxs5("span", { children: [
|
|
1739
|
+
"\u663E\u793A\u6761\u4EF6",
|
|
1740
|
+
condRules.length > 0 ? ` (${condRules.length})` : ""
|
|
1741
|
+
] })
|
|
1742
|
+
]
|
|
1743
|
+
}
|
|
1744
|
+
)
|
|
1745
|
+
] }),
|
|
1746
|
+
condRules.length > 0 && /* @__PURE__ */ jsxs5(
|
|
1747
|
+
"div",
|
|
1748
|
+
{
|
|
1749
|
+
className: "univer-bases-form-cond-box",
|
|
1750
|
+
"data-testid": `bases-form-cond-box-${field.id}`,
|
|
1751
|
+
children: [
|
|
1752
|
+
/* @__PURE__ */ jsxs5("div", { className: "univer-bases-inline-flex", style: { justifyContent: "space-between", width: "100%" }, children: [
|
|
1753
|
+
/* @__PURE__ */ jsx5("span", { className: "univer-bases-muted-key", children: "\u663E\u793A\u6761\u4EF6\uFF08\u5982\uFF1A\u5F53 \u4EFB\u52A1\u72B6\u6001 = \u4EE3\u7801\u8BC4\u5BA1 \u65F6\u663E\u793A\uFF09" }),
|
|
1754
|
+
/* @__PURE__ */ jsxs5("label", { className: "univer-bases-checkbox-label", children: [
|
|
1755
|
+
/* @__PURE__ */ jsx5(
|
|
1756
|
+
"input",
|
|
1757
|
+
{
|
|
1758
|
+
type: "checkbox",
|
|
1759
|
+
checked: Boolean(item.conditionalRequired),
|
|
1760
|
+
onChange: (e) => updateFieldItemAt(idx, {
|
|
1761
|
+
conditionalRequired: e.target.checked
|
|
1762
|
+
})
|
|
1763
|
+
}
|
|
1764
|
+
),
|
|
1765
|
+
/* @__PURE__ */ jsx5("span", { children: "\u663E\u793A\u65F6\u8BBE\u4E3A\u5FC5\u586B" })
|
|
1766
|
+
] })
|
|
1767
|
+
] }),
|
|
1768
|
+
condRules.map((rule) => /* @__PURE__ */ jsxs5("div", { className: "univer-bases-rule-row", children: [
|
|
1769
|
+
/* @__PURE__ */ jsx5("span", { className: "univer-bases-muted-key", children: "\u5F53" }),
|
|
1770
|
+
/* @__PURE__ */ jsx5(
|
|
1771
|
+
"select",
|
|
1772
|
+
{
|
|
1773
|
+
className: "univer-bases-select",
|
|
1774
|
+
value: rule.fieldId,
|
|
1775
|
+
onChange: (e) => {
|
|
1776
|
+
const next = condRules.map(
|
|
1777
|
+
(r) => r.id === rule.id ? { ...r, fieldId: e.target.value } : r
|
|
1778
|
+
);
|
|
1779
|
+
updateFieldItemAt(idx, { visibleWhen: next });
|
|
1780
|
+
},
|
|
1781
|
+
children: candidateTriggerFields.map((tf) => /* @__PURE__ */ jsx5("option", { value: tf.id, children: tf.name }, tf.id))
|
|
1782
|
+
}
|
|
1783
|
+
),
|
|
1784
|
+
/* @__PURE__ */ jsx5(
|
|
1785
|
+
"select",
|
|
1786
|
+
{
|
|
1787
|
+
className: "univer-bases-select univer-bases-select--xs",
|
|
1788
|
+
value: rule.operator,
|
|
1789
|
+
onChange: (e) => {
|
|
1790
|
+
const next = condRules.map(
|
|
1791
|
+
(r) => r.id === rule.id ? { ...r, operator: e.target.value } : r
|
|
1792
|
+
);
|
|
1793
|
+
updateFieldItemAt(idx, { visibleWhen: next });
|
|
1794
|
+
},
|
|
1795
|
+
children: CONDITION_OPERATORS.map((op) => /* @__PURE__ */ jsx5("option", { value: op.value, children: op.label }, op.value))
|
|
1796
|
+
}
|
|
1797
|
+
),
|
|
1798
|
+
rule.operator !== "isEmpty" && rule.operator !== "isNotEmpty" && /* @__PURE__ */ jsx5(
|
|
1799
|
+
"input",
|
|
1800
|
+
{
|
|
1801
|
+
type: "text",
|
|
1802
|
+
className: "univer-bases-input",
|
|
1803
|
+
placeholder: "\u89E6\u53D1\u5339\u914D\u503C...",
|
|
1804
|
+
value: String(rule.value ?? ""),
|
|
1805
|
+
onChange: (e) => {
|
|
1806
|
+
const next = condRules.map(
|
|
1807
|
+
(r) => r.id === rule.id ? { ...r, value: e.target.value } : r
|
|
1808
|
+
);
|
|
1809
|
+
updateFieldItemAt(idx, { visibleWhen: next });
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
),
|
|
1813
|
+
/* @__PURE__ */ jsx5("span", { className: "univer-bases-muted-key", children: "\u65F6\u663E\u793A" }),
|
|
1814
|
+
/* @__PURE__ */ jsx5(
|
|
1815
|
+
"button",
|
|
1816
|
+
{
|
|
1817
|
+
type: "button",
|
|
1818
|
+
className: "univer-bases-icon-btn",
|
|
1819
|
+
onClick: () => {
|
|
1820
|
+
const next = condRules.filter((r) => r.id !== rule.id);
|
|
1821
|
+
updateFieldItemAt(idx, {
|
|
1822
|
+
visibleWhen: next.length > 0 ? next : void 0
|
|
1823
|
+
});
|
|
1824
|
+
},
|
|
1825
|
+
children: /* @__PURE__ */ jsx5(BaseTrashIcon, {})
|
|
1826
|
+
}
|
|
1827
|
+
)
|
|
1828
|
+
] }, rule.id)),
|
|
1829
|
+
/* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsxs5(
|
|
1830
|
+
"button",
|
|
1831
|
+
{
|
|
1832
|
+
type: "button",
|
|
1833
|
+
className: "univer-bases-btn univer-bases-btn--ghost univer-bases-btn--sm",
|
|
1834
|
+
onClick: () => {
|
|
1835
|
+
const refField = candidateTriggerFields[0];
|
|
1836
|
+
if (!refField) return;
|
|
1837
|
+
updateFieldItemAt(idx, {
|
|
1838
|
+
visibleWhen: [
|
|
1839
|
+
...condRules,
|
|
1840
|
+
{
|
|
1841
|
+
id: `fvis_${generateRandomId2(5)}`,
|
|
1842
|
+
fieldId: refField.id,
|
|
1843
|
+
operator: "is",
|
|
1844
|
+
value: ""
|
|
1845
|
+
}
|
|
1846
|
+
]
|
|
1847
|
+
});
|
|
1848
|
+
},
|
|
1849
|
+
children: [
|
|
1850
|
+
/* @__PURE__ */ jsx5(BasePlusIcon, {}),
|
|
1851
|
+
/* @__PURE__ */ jsx5("span", { children: "\u8FFD\u52A0\u8054\u52A8\u6761\u4EF6" })
|
|
1852
|
+
]
|
|
1853
|
+
}
|
|
1854
|
+
) })
|
|
1855
|
+
]
|
|
1856
|
+
}
|
|
1857
|
+
)
|
|
1858
|
+
]
|
|
1859
|
+
},
|
|
1860
|
+
item.fieldId
|
|
1861
|
+
);
|
|
1407
1862
|
})
|
|
1408
1863
|
] })
|
|
1409
1864
|
] })
|
|
@@ -1429,87 +1884,100 @@ var FormView = ({ query }) => {
|
|
|
1429
1884
|
/* @__PURE__ */ jsx5("h2", { className: "univer-bases-form-title", children: resolvedConfig.title }),
|
|
1430
1885
|
resolvedConfig.description && /* @__PURE__ */ jsx5("p", { className: "univer-bases-form-desc", children: resolvedConfig.description }),
|
|
1431
1886
|
errorMsg && /* @__PURE__ */ jsx5("div", { className: "univer-bases-alert-error", children: errorMsg }),
|
|
1432
|
-
|
|
1887
|
+
visibleFillItems.map((item) => {
|
|
1433
1888
|
const field = table.fields[item.fieldId];
|
|
1434
1889
|
if (!field) return null;
|
|
1435
1890
|
const curVal = values[field.id];
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
"
|
|
1444
|
-
{
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
/* @__PURE__ */ jsx5("
|
|
1450
|
-
|
|
1451
|
-
]
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1891
|
+
const isReq = isFormFieldRequired(item, values, table, snapshot, resolvedConfig);
|
|
1892
|
+
const hasCond = Boolean(
|
|
1893
|
+
item.visibleWhen && item.visibleWhen.length > 0 || resolvedConfig.fieldRules?.[field.id]?.visibleWhen?.length
|
|
1894
|
+
);
|
|
1895
|
+
return /* @__PURE__ */ jsxs5(
|
|
1896
|
+
"div",
|
|
1897
|
+
{
|
|
1898
|
+
className: "univer-bases-form-row",
|
|
1899
|
+
"data-testid": `bases-form-field-${field.id}`,
|
|
1900
|
+
children: [
|
|
1901
|
+
/* @__PURE__ */ jsxs5("label", { className: "univer-bases-form-field-label", children: [
|
|
1902
|
+
/* @__PURE__ */ jsx5(BaseFieldTypeIcon, { type: field.type }),
|
|
1903
|
+
/* @__PURE__ */ jsx5("span", { children: item.label || field.name }),
|
|
1904
|
+
isReq && /* @__PURE__ */ jsx5("span", { className: "univer-bases-required-dot", children: "*" }),
|
|
1905
|
+
hasCond && /* @__PURE__ */ jsx5("span", { className: "univer-bases-computed-badge", children: "\u6761\u4EF6\u8054\u52A8" })
|
|
1906
|
+
] }),
|
|
1907
|
+
field.type === "singleSelect" ? /* @__PURE__ */ jsxs5(
|
|
1908
|
+
"select",
|
|
1909
|
+
{
|
|
1910
|
+
className: "univer-bases-select",
|
|
1911
|
+
value: String(curVal ?? ""),
|
|
1912
|
+
onChange: (e) => setValues((prev) => ({ ...prev, [field.id]: e.target.value })),
|
|
1913
|
+
children: [
|
|
1914
|
+
/* @__PURE__ */ jsx5("option", { value: "", children: "\u8BF7\u9009\u62E9..." }),
|
|
1915
|
+
(field.config?.options ?? []).map((opt) => /* @__PURE__ */ jsx5("option", { value: opt.name, children: opt.name }, opt.id))
|
|
1916
|
+
]
|
|
1917
|
+
}
|
|
1918
|
+
) : field.type === "multiSelect" ? /* @__PURE__ */ jsx5("div", { className: "univer-bases-tag-wrap", children: (field.config?.options ?? []).map((opt) => {
|
|
1919
|
+
const arr = Array.isArray(curVal) ? curVal.map(String) : [];
|
|
1920
|
+
const active = arr.includes(opt.name);
|
|
1921
|
+
return /* @__PURE__ */ jsxs5("label", { className: "univer-bases-checkbox-label", children: [
|
|
1922
|
+
/* @__PURE__ */ jsx5(
|
|
1923
|
+
"input",
|
|
1924
|
+
{
|
|
1925
|
+
type: "checkbox",
|
|
1926
|
+
checked: active,
|
|
1927
|
+
onChange: () => {
|
|
1928
|
+
const next = active ? arr.filter((v) => v !== opt.name) : [...arr, opt.name];
|
|
1929
|
+
setValues((prev) => ({ ...prev, [field.id]: next }));
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
),
|
|
1933
|
+
/* @__PURE__ */ jsx5("span", { children: opt.name })
|
|
1934
|
+
] }, opt.id);
|
|
1935
|
+
}) }) : field.type === "checkbox" ? /* @__PURE__ */ jsxs5("label", { className: "univer-bases-checkbox-label", children: [
|
|
1936
|
+
/* @__PURE__ */ jsx5(
|
|
1937
|
+
"input",
|
|
1938
|
+
{
|
|
1939
|
+
type: "checkbox",
|
|
1940
|
+
checked: Boolean(curVal),
|
|
1941
|
+
onChange: (e) => setValues((prev) => ({ ...prev, [field.id]: e.target.checked }))
|
|
1942
|
+
}
|
|
1943
|
+
),
|
|
1944
|
+
/* @__PURE__ */ jsx5("span", { children: "\u786E\u8BA4\u52FE\u9009" })
|
|
1945
|
+
] }) : field.type === "rating" ? /* @__PURE__ */ jsx5("div", { className: "univer-bases-rating-stars", children: Array.from(
|
|
1946
|
+
{ length: field.config?.maxRating ?? 5 },
|
|
1947
|
+
(_, sIdx) => /* @__PURE__ */ jsx5(
|
|
1948
|
+
BaseStarSvg,
|
|
1949
|
+
{
|
|
1950
|
+
filled: sIdx + 1 <= Math.round(toNumericValue2(curVal) ?? 0),
|
|
1951
|
+
onClick: () => setValues((prev) => ({ ...prev, [field.id]: sIdx + 1 }))
|
|
1952
|
+
},
|
|
1953
|
+
sIdx
|
|
1954
|
+
)
|
|
1955
|
+
) }) : field.type === "date" ? /* @__PURE__ */ jsx5(
|
|
1956
|
+
"input",
|
|
1957
|
+
{
|
|
1958
|
+
type: "date",
|
|
1959
|
+
className: "univer-bases-input",
|
|
1960
|
+
value: String(curVal ?? ""),
|
|
1961
|
+
onChange: (e) => setValues((prev) => ({ ...prev, [field.id]: e.target.value }))
|
|
1962
|
+
}
|
|
1963
|
+
) : /* @__PURE__ */ jsx5(
|
|
1458
1964
|
"input",
|
|
1459
1965
|
{
|
|
1460
|
-
type: "
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1966
|
+
type: field.type === "number" || field.type === "currency" || field.type === "percent" ? "number" : field.type === "email" ? "email" : "text",
|
|
1967
|
+
className: "univer-bases-input",
|
|
1968
|
+
placeholder: item.placeholder || `\u8BF7\u8F93\u5165${item.label || field.name}...`,
|
|
1969
|
+
value: curVal === void 0 || curVal === null ? "" : String(curVal),
|
|
1970
|
+
onChange: (e) => {
|
|
1971
|
+
const raw = e.target.value;
|
|
1972
|
+
const parsed = field.type === "number" || field.type === "currency" || field.type === "percent" ? toNumericValue2(raw) ?? raw : raw;
|
|
1973
|
+
setValues((prev) => ({ ...prev, [field.id]: parsed }));
|
|
1465
1974
|
}
|
|
1466
1975
|
}
|
|
1467
|
-
)
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
"input",
|
|
1473
|
-
{
|
|
1474
|
-
type: "checkbox",
|
|
1475
|
-
checked: Boolean(curVal),
|
|
1476
|
-
onChange: (e) => setValues((prev) => ({ ...prev, [field.id]: e.target.checked }))
|
|
1477
|
-
}
|
|
1478
|
-
),
|
|
1479
|
-
/* @__PURE__ */ jsx5("span", { children: "\u786E\u8BA4\u52FE\u9009" })
|
|
1480
|
-
] }) : field.type === "rating" ? /* @__PURE__ */ jsx5("div", { className: "univer-bases-rating-stars", children: Array.from(
|
|
1481
|
-
{ length: field.config?.maxRating ?? 5 },
|
|
1482
|
-
(_, sIdx) => /* @__PURE__ */ jsx5(
|
|
1483
|
-
BaseStarSvg,
|
|
1484
|
-
{
|
|
1485
|
-
filled: sIdx + 1 <= Math.round(toNumericValue2(curVal) ?? 0),
|
|
1486
|
-
onClick: () => setValues((prev) => ({ ...prev, [field.id]: sIdx + 1 }))
|
|
1487
|
-
},
|
|
1488
|
-
sIdx
|
|
1489
|
-
)
|
|
1490
|
-
) }) : field.type === "date" ? /* @__PURE__ */ jsx5(
|
|
1491
|
-
"input",
|
|
1492
|
-
{
|
|
1493
|
-
type: "date",
|
|
1494
|
-
className: "univer-bases-input",
|
|
1495
|
-
value: String(curVal ?? ""),
|
|
1496
|
-
onChange: (e) => setValues((prev) => ({ ...prev, [field.id]: e.target.value }))
|
|
1497
|
-
}
|
|
1498
|
-
) : /* @__PURE__ */ jsx5(
|
|
1499
|
-
"input",
|
|
1500
|
-
{
|
|
1501
|
-
type: field.type === "number" || field.type === "currency" || field.type === "percent" ? "number" : field.type === "email" ? "email" : "text",
|
|
1502
|
-
className: "univer-bases-input",
|
|
1503
|
-
placeholder: `\u8BF7\u8F93\u5165${item.label || field.name}...`,
|
|
1504
|
-
value: curVal === void 0 || curVal === null ? "" : String(curVal),
|
|
1505
|
-
onChange: (e) => {
|
|
1506
|
-
const raw = e.target.value;
|
|
1507
|
-
const parsed = field.type === "number" || field.type === "currency" || field.type === "percent" ? toNumericValue2(raw) ?? raw : raw;
|
|
1508
|
-
setValues((prev) => ({ ...prev, [field.id]: parsed }));
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
)
|
|
1512
|
-
] }, field.id);
|
|
1976
|
+
)
|
|
1977
|
+
]
|
|
1978
|
+
},
|
|
1979
|
+
field.id
|
|
1980
|
+
);
|
|
1513
1981
|
}),
|
|
1514
1982
|
/* @__PURE__ */ jsx5("div", { style: { marginTop: 18 }, children: /* @__PURE__ */ jsx5(
|
|
1515
1983
|
"button",
|
|
@@ -1909,17 +2377,17 @@ import {
|
|
|
1909
2377
|
UpdateBaseRecordCommand as UpdateBaseRecordCommand2,
|
|
1910
2378
|
UpdateBaseViewCommand as UpdateBaseViewCommand4
|
|
1911
2379
|
} from "@yudaocode/univer-bases";
|
|
1912
|
-
import
|
|
2380
|
+
import React7, { useState as useState7 } from "react";
|
|
1913
2381
|
|
|
1914
2382
|
// src/views/grid/FieldConfigPopover.tsx
|
|
1915
|
-
import { generateRandomId } from "@univerjs/core";
|
|
2383
|
+
import { generateRandomId as generateRandomId3 } from "@univerjs/core";
|
|
1916
2384
|
import {
|
|
1917
2385
|
AddBaseFieldCommand,
|
|
1918
2386
|
BASE_SELECT_PALETTE,
|
|
1919
2387
|
DeleteBaseFieldCommand,
|
|
1920
2388
|
UpdateBaseFieldCommand
|
|
1921
2389
|
} from "@yudaocode/univer-bases";
|
|
1922
|
-
import { useState as
|
|
2390
|
+
import { useState as useState5 } from "react";
|
|
1923
2391
|
import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1924
2392
|
var FIELD_TYPE_LABELS = [
|
|
1925
2393
|
{ type: "text", label: "\u5355\u884C/\u591A\u884C\u6587\u672C (Text)", group: "\u57FA\u7840\u5B57\u6BB5" },
|
|
@@ -1951,38 +2419,38 @@ var FIELD_TYPE_LABELS = [
|
|
|
1951
2419
|
{ type: "lastModifiedBy", label: "\u6700\u540E\u4FEE\u6539\u4EBA (Modified By)", group: "\u7CFB\u7EDF\u81EA\u52A8\u5B57\u6BB5" }
|
|
1952
2420
|
];
|
|
1953
2421
|
var FieldConfigPopover = ({ mode, unitData, table, field, onExecuteCommand, onClose }) => {
|
|
1954
|
-
const [name, setName] =
|
|
1955
|
-
const [type, setType] =
|
|
1956
|
-
const [currencySymbol, setCurrencySymbol] =
|
|
1957
|
-
const [precision, setPrecision] =
|
|
1958
|
-
const [options, setOptions] =
|
|
2422
|
+
const [name, setName] = useState5(field?.name ?? "\u65B0\u5B57\u6BB5");
|
|
2423
|
+
const [type, setType] = useState5(field?.type ?? "text");
|
|
2424
|
+
const [currencySymbol, setCurrencySymbol] = useState5(field?.config?.currencySymbol ?? "\xA5");
|
|
2425
|
+
const [precision, setPrecision] = useState5(field?.config?.precision ?? 2);
|
|
2426
|
+
const [options, setOptions] = useState5(
|
|
1959
2427
|
field?.config?.options ?? [
|
|
1960
2428
|
{ id: "opt_1", name: "\u5F85\u5904\u7406", color: BASE_SELECT_PALETTE[0] },
|
|
1961
2429
|
{ id: "opt_2", name: "\u8FDB\u884C\u4E2D", color: BASE_SELECT_PALETTE[1] },
|
|
1962
2430
|
{ id: "opt_3", name: "\u5DF2\u5B8C\u6210", color: BASE_SELECT_PALETTE[2] }
|
|
1963
2431
|
]
|
|
1964
2432
|
);
|
|
1965
|
-
const [linkedTableId, setLinkedTableId] =
|
|
2433
|
+
const [linkedTableId, setLinkedTableId] = useState5(
|
|
1966
2434
|
field?.config?.linkedTableId ?? unitData.tableOrder.find((tid) => tid !== table.id) ?? table.id
|
|
1967
2435
|
);
|
|
1968
|
-
const [createSymmetric, setCreateSymmetric] =
|
|
2436
|
+
const [createSymmetric, setCreateSymmetric] = useState5(true);
|
|
1969
2437
|
const linkFieldsInTable = Object.values(table.fields).filter((f) => f.type === "link");
|
|
1970
|
-
const [linkFieldId, setLinkFieldId] =
|
|
2438
|
+
const [linkFieldId, setLinkFieldId] = useState5(
|
|
1971
2439
|
field?.config?.linkFieldId ?? linkFieldsInTable[0]?.id ?? ""
|
|
1972
2440
|
);
|
|
1973
2441
|
const selectedLinkField = table.fields[linkFieldId];
|
|
1974
2442
|
const lookupTargetTable = selectedLinkField?.config?.linkedTableId ? unitData.tables[selectedLinkField.config.linkedTableId] : void 0;
|
|
1975
2443
|
const lookupTargetFields = lookupTargetTable ? lookupTargetTable.fieldOrder.map((id) => lookupTargetTable.fields[id]).filter(Boolean) : [];
|
|
1976
|
-
const [lookupFieldId, setLookupFieldId] =
|
|
2444
|
+
const [lookupFieldId, setLookupFieldId] = useState5(
|
|
1977
2445
|
field?.config?.lookupFieldId ?? lookupTargetFields[0]?.id ?? ""
|
|
1978
2446
|
);
|
|
1979
|
-
const [rollupFunction, setRollupFunction] =
|
|
2447
|
+
const [rollupFunction, setRollupFunction] = useState5(
|
|
1980
2448
|
field?.config?.rollupFunction ?? "sum"
|
|
1981
2449
|
);
|
|
1982
|
-
const [formula, setFormula] =
|
|
2450
|
+
const [formula, setFormula] = useState5(
|
|
1983
2451
|
field?.config?.formula ?? 'IF({\u4EFB\u52A1\u72B6\u6001} = "\u5DF2\u5B8C\u6210", "\u8FBE\u6807", "\u8FDB\u884C\u4E2D")'
|
|
1984
2452
|
);
|
|
1985
|
-
const [buttonLabel, setButtonLabel] =
|
|
2453
|
+
const [buttonLabel, setButtonLabel] = useState5(field?.config?.buttonLabel ?? "\u89E6\u53D1\u6D41\u7A0B");
|
|
1986
2454
|
const handleSave = () => {
|
|
1987
2455
|
const config = { ...field?.config ?? {} };
|
|
1988
2456
|
if (type === "singleSelect" || type === "multiSelect") {
|
|
@@ -2122,7 +2590,7 @@ var FieldConfigPopover = ({ mode, unitData, table, field, onExecuteCommand, onCl
|
|
|
2122
2590
|
onClick: () => setOptions([
|
|
2123
2591
|
...options,
|
|
2124
2592
|
{
|
|
2125
|
-
id: `opt_${
|
|
2593
|
+
id: `opt_${generateRandomId3(4)}`,
|
|
2126
2594
|
name: `\u9009\u9879 ${options.length + 1}`,
|
|
2127
2595
|
color: BASE_SELECT_PALETTE[options.length % BASE_SELECT_PALETTE.length]
|
|
2128
2596
|
}
|
|
@@ -2305,7 +2773,7 @@ import {
|
|
|
2305
2773
|
resolveLinkedRecordItems as resolveLinkedRecordItems2,
|
|
2306
2774
|
toNumericValue as toNumericValue4
|
|
2307
2775
|
} from "@yudaocode/univer-bases";
|
|
2308
|
-
import { useState as
|
|
2776
|
+
import { useState as useState6 } from "react";
|
|
2309
2777
|
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2310
2778
|
var GridCellEditor = ({
|
|
2311
2779
|
unitData,
|
|
@@ -2316,8 +2784,8 @@ var GridCellEditor = ({
|
|
|
2316
2784
|
onOpenLinkPicker,
|
|
2317
2785
|
onTriggerButton
|
|
2318
2786
|
}) => {
|
|
2319
|
-
const [editing, setEditing] =
|
|
2320
|
-
const [draft, setDraft] =
|
|
2787
|
+
const [editing, setEditing] = useState6(false);
|
|
2788
|
+
const [draft, setDraft] = useState6("");
|
|
2321
2789
|
const rawValue = row.values[field.id];
|
|
2322
2790
|
const displayValue = row.displayValues[field.id] ?? "";
|
|
2323
2791
|
if (isComputedBaseField3(field.type)) {
|
|
@@ -2604,9 +3072,9 @@ var SUMMARY_OPTIONS = [
|
|
|
2604
3072
|
];
|
|
2605
3073
|
var GridView = ({ query }) => {
|
|
2606
3074
|
const { unit, snapshot, commandService, selectionService, selectionState } = useActiveBaseWorkspace();
|
|
2607
|
-
const [configuringFieldId, setConfiguringFieldId] =
|
|
2608
|
-
const [creatingFieldOpen, setCreatingFieldOpen] =
|
|
2609
|
-
const [collapsedGroupKeys, setCollapsedGroupKeys] =
|
|
3075
|
+
const [configuringFieldId, setConfiguringFieldId] = useState7(null);
|
|
3076
|
+
const [creatingFieldOpen, setCreatingFieldOpen] = useState7(false);
|
|
3077
|
+
const [collapsedGroupKeys, setCollapsedGroupKeys] = useState7({});
|
|
2610
3078
|
if (!unit || !snapshot) return null;
|
|
2611
3079
|
const unitId = unit.getUnitId();
|
|
2612
3080
|
const { table, view, visibleFields, rows, groups, summaryByField } = query;
|
|
@@ -2695,7 +3163,7 @@ var GridView = ({ query }) => {
|
|
|
2695
3163
|
const renderGroupNodes = (nodes) => {
|
|
2696
3164
|
return nodes.map((group) => {
|
|
2697
3165
|
const isCollapsed = collapsedGroupKeys[group.key] ?? group.collapsed;
|
|
2698
|
-
return /* @__PURE__ */ jsxs10(
|
|
3166
|
+
return /* @__PURE__ */ jsxs10(React7.Fragment, { children: [
|
|
2699
3167
|
/* @__PURE__ */ jsx10("tr", { className: "univer-bases-grid__group-row", "data-testid": "bases-grid-group-header", children: /* @__PURE__ */ jsx10("td", { colSpan: visibleFields.length + 2, children: /* @__PURE__ */ jsxs10(
|
|
2700
3168
|
"div",
|
|
2701
3169
|
{
|
|
@@ -2919,12 +3387,12 @@ import {
|
|
|
2919
3387
|
UpdateBaseRecordCommand as UpdateBaseRecordCommand3,
|
|
2920
3388
|
UpdateBaseViewCommand as UpdateBaseViewCommand5
|
|
2921
3389
|
} from "@yudaocode/univer-bases";
|
|
2922
|
-
import { useState as
|
|
3390
|
+
import { useState as useState8 } from "react";
|
|
2923
3391
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2924
3392
|
var KanbanView = ({ query }) => {
|
|
2925
3393
|
const { unit, commandService, selectionService } = useActiveBaseWorkspace();
|
|
2926
|
-
const [draggingRecordId, setDraggingRecordId] =
|
|
2927
|
-
const [dragOverColKey, setDragOverColKey] =
|
|
3394
|
+
const [draggingRecordId, setDraggingRecordId] = useState8(null);
|
|
3395
|
+
const [dragOverColKey, setDragOverColKey] = useState8(null);
|
|
2928
3396
|
if (!unit) return null;
|
|
2929
3397
|
const unitId = unit.getUnitId();
|
|
2930
3398
|
const { table, view, allFields, rows } = query;
|
|
@@ -3189,113 +3657,461 @@ var KanbanView = ({ query }) => {
|
|
|
3189
3657
|
] });
|
|
3190
3658
|
};
|
|
3191
3659
|
|
|
3192
|
-
// src/views/
|
|
3193
|
-
import { generateRandomId as generateRandomId2 } from "@univerjs/core";
|
|
3660
|
+
// src/views/list/ListView.tsx
|
|
3194
3661
|
import {
|
|
3662
|
+
AddBaseFieldCommand as AddBaseFieldCommand2,
|
|
3195
3663
|
AddBaseRecordCommand as AddBaseRecordCommand5,
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
SetActiveBaseViewCommand as SetActiveBaseViewCommand2,
|
|
3199
|
-
SetBaseWorkspaceModeCommand as SetBaseWorkspaceModeCommand2,
|
|
3664
|
+
computeBaseHierarchicalList,
|
|
3665
|
+
UpdateBaseRecordCommand as UpdateBaseRecordCommand4,
|
|
3200
3666
|
UpdateBaseViewCommand as UpdateBaseViewCommand6
|
|
3201
3667
|
} from "@yudaocode/univer-bases";
|
|
3202
|
-
import { useState as useState8 } from "react";
|
|
3203
3668
|
import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3204
|
-
var
|
|
3205
|
-
{
|
|
3206
|
-
|
|
3207
|
-
{ value: "contains", label: "\u5305\u542B" },
|
|
3208
|
-
{ value: "notContains", label: "\u4E0D\u5305\u542B" },
|
|
3209
|
-
{ value: "gt", label: "\u5927\u4E8E" },
|
|
3210
|
-
{ value: "gte", label: "\u5927\u4E8E\u7B49\u4E8E" },
|
|
3211
|
-
{ value: "lt", label: "\u5C0F\u4E8E" },
|
|
3212
|
-
{ value: "lte", label: "\u5C0F\u4E8E\u7B49\u4E8E" },
|
|
3213
|
-
{ value: "isEmpty", label: "\u4E3A\u7A7A" },
|
|
3214
|
-
{ value: "isNotEmpty", label: "\u4E0D\u4E3A\u7A7A" }
|
|
3215
|
-
];
|
|
3216
|
-
var QUICK_VIEW_MODES = [
|
|
3217
|
-
{ type: "grid", label: "\u8868\u683C" },
|
|
3218
|
-
{ type: "kanban", label: "\u770B\u677F" },
|
|
3219
|
-
{ type: "calendar", label: "\u65E5\u5386" },
|
|
3220
|
-
{ type: "gallery", label: "\u753B\u5ECA" },
|
|
3221
|
-
{ type: "gantt", label: "\u7518\u7279\u56FE" },
|
|
3222
|
-
{ type: "timeline", label: "\u65F6\u95F4\u8F74" },
|
|
3223
|
-
{ type: "form", label: "\u8868\u5355" },
|
|
3224
|
-
{ type: "dashboard", label: "\u4EEA\u8868\u76D8" }
|
|
3225
|
-
];
|
|
3226
|
-
var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
3227
|
-
const { unit, commandService, selectionService, selectionState } = useActiveBaseWorkspace();
|
|
3228
|
-
const [openPopover, setOpenPopover] = useState8(null);
|
|
3229
|
-
const [newViewName, setNewViewName] = useState8("");
|
|
3230
|
-
const [newViewType, setNewViewType] = useState8("grid");
|
|
3231
|
-
if (!unit) return null;
|
|
3669
|
+
var ListView = ({ query }) => {
|
|
3670
|
+
const { unit, snapshot, commandService, selectionService, selectionState } = useActiveBaseWorkspace();
|
|
3671
|
+
if (!unit || !snapshot) return null;
|
|
3232
3672
|
const unitId = unit.getUnitId();
|
|
3233
|
-
const
|
|
3234
|
-
const
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
const
|
|
3673
|
+
const { table, view, allFields } = query;
|
|
3674
|
+
const listResult = computeBaseHierarchicalList(snapshot, table.id, view.id, {
|
|
3675
|
+
overrides: {
|
|
3676
|
+
searchQuery: selectionState.searchQuery || view.searchQuery
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
const selfLinkFields = allFields.filter(
|
|
3680
|
+
(f) => f.type === "link" && f.config?.linkedTableId === table.id
|
|
3681
|
+
);
|
|
3682
|
+
const parentField = listResult.parentField;
|
|
3683
|
+
const primaryField = table.fields[table.primaryFieldId] ?? allFields[0];
|
|
3684
|
+
const statusField = allFields.find((f) => f.type === "singleSelect");
|
|
3685
|
+
const personField = allFields.find((f) => f.type === "person");
|
|
3686
|
+
const dateField = allFields.find((f) => f.type === "date");
|
|
3687
|
+
const progressField = allFields.find((f) => f.type === "percent");
|
|
3688
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
3689
|
+
const walkRegister = (nodes) => {
|
|
3690
|
+
for (const n of nodes) {
|
|
3691
|
+
nodeMap.set(n.recordId, n);
|
|
3692
|
+
if (n.children.length > 0) walkRegister(n.children);
|
|
3693
|
+
}
|
|
3694
|
+
};
|
|
3695
|
+
walkRegister(listResult.roots);
|
|
3696
|
+
const ensureParentFieldId = () => {
|
|
3697
|
+
if (parentField) return parentField.id;
|
|
3698
|
+
let createdFieldId = null;
|
|
3699
|
+
commandService.syncExecuteCommand(AddBaseFieldCommand2.id, {
|
|
3700
|
+
unitId,
|
|
3701
|
+
tableId: table.id,
|
|
3702
|
+
name: "\u4E0A\u7EA7\u8BB0\u5F55",
|
|
3703
|
+
type: "link",
|
|
3704
|
+
config: { linkedTableId: table.id, allowMultiple: false },
|
|
3705
|
+
createSymmetric: false,
|
|
3706
|
+
onCreated: (fid) => {
|
|
3707
|
+
createdFieldId = fid;
|
|
3708
|
+
}
|
|
3709
|
+
});
|
|
3710
|
+
if (createdFieldId) {
|
|
3711
|
+
commandService.syncExecuteCommand(UpdateBaseViewCommand6.id, {
|
|
3712
|
+
unitId,
|
|
3713
|
+
tableId: table.id,
|
|
3714
|
+
viewId: view.id,
|
|
3715
|
+
patch: { listParentFieldId: createdFieldId }
|
|
3716
|
+
});
|
|
3717
|
+
}
|
|
3718
|
+
return createdFieldId;
|
|
3719
|
+
};
|
|
3720
|
+
const toggleNodeCollapsed = (recordId) => {
|
|
3721
|
+
const cur = view.listCollapsedRecordIds ?? [];
|
|
3722
|
+
const next = cur.includes(recordId) ? cur.filter((id) => id !== recordId) : [...cur, recordId];
|
|
3240
3723
|
commandService.syncExecuteCommand(UpdateBaseViewCommand6.id, {
|
|
3241
3724
|
unitId,
|
|
3242
3725
|
tableId: table.id,
|
|
3243
|
-
viewId:
|
|
3244
|
-
patch
|
|
3726
|
+
viewId: view.id,
|
|
3727
|
+
patch: { listCollapsedRecordIds: next }
|
|
3245
3728
|
});
|
|
3246
3729
|
};
|
|
3247
|
-
const
|
|
3248
|
-
|
|
3730
|
+
const setAllCollapsed = (collapseAll) => {
|
|
3731
|
+
const parentRecordIds = [];
|
|
3732
|
+
if (collapseAll) {
|
|
3733
|
+
for (const n of nodeMap.values()) {
|
|
3734
|
+
if (n.children.length > 0) parentRecordIds.push(n.recordId);
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
commandService.syncExecuteCommand(UpdateBaseViewCommand6.id, {
|
|
3738
|
+
unitId,
|
|
3739
|
+
tableId: table.id,
|
|
3740
|
+
viewId: view.id,
|
|
3741
|
+
patch: { listCollapsedRecordIds: parentRecordIds }
|
|
3742
|
+
});
|
|
3249
3743
|
};
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3744
|
+
const handleAddChildRecord = (parentNode) => {
|
|
3745
|
+
const pFieldId = ensureParentFieldId();
|
|
3746
|
+
if (!pFieldId) return;
|
|
3747
|
+
if (parentNode.collapsed) {
|
|
3748
|
+
toggleNodeCollapsed(parentNode.recordId);
|
|
3749
|
+
}
|
|
3750
|
+
commandService.syncExecuteCommand(AddBaseRecordCommand5.id, {
|
|
3751
|
+
unitId,
|
|
3752
|
+
tableId: table.id,
|
|
3753
|
+
cells: {
|
|
3754
|
+
...primaryField ? { [primaryField.id]: `${parentNode.title} \xB7 \u5B50\u4EFB\u52A1` } : {},
|
|
3755
|
+
[pFieldId]: [parentNode.recordId]
|
|
3756
|
+
}
|
|
3757
|
+
});
|
|
3758
|
+
};
|
|
3759
|
+
const handlePromoteNode = (node) => {
|
|
3760
|
+
if (!parentField || !node.parentId) return;
|
|
3761
|
+
const parentNode = nodeMap.get(node.parentId);
|
|
3762
|
+
const grandParentId = parentNode?.parentId ?? null;
|
|
3763
|
+
commandService.syncExecuteCommand(UpdateBaseRecordCommand4.id, {
|
|
3764
|
+
unitId,
|
|
3765
|
+
tableId: table.id,
|
|
3766
|
+
recordId: node.recordId,
|
|
3767
|
+
cells: {
|
|
3768
|
+
[parentField.id]: grandParentId ? [grandParentId] : []
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3771
|
+
};
|
|
3772
|
+
const handleDemoteNode = (node) => {
|
|
3773
|
+
const pFieldId = ensureParentFieldId();
|
|
3774
|
+
if (!pFieldId) return;
|
|
3775
|
+
const siblings = node.parentId ? nodeMap.get(node.parentId)?.children ?? [] : listResult.roots;
|
|
3776
|
+
const idx = siblings.findIndex((s) => s.recordId === node.recordId);
|
|
3777
|
+
if (idx <= 0) return;
|
|
3778
|
+
const prevSibling = siblings[idx - 1];
|
|
3779
|
+
commandService.syncExecuteCommand(UpdateBaseRecordCommand4.id, {
|
|
3780
|
+
unitId,
|
|
3781
|
+
tableId: table.id,
|
|
3782
|
+
recordId: node.recordId,
|
|
3783
|
+
cells: {
|
|
3784
|
+
[pFieldId]: [prevSibling.recordId]
|
|
3785
|
+
}
|
|
3786
|
+
});
|
|
3787
|
+
};
|
|
3788
|
+
return /* @__PURE__ */ jsxs12("div", { className: "univer-bases-list-view", "data-testid": "bases-list-view", children: [
|
|
3789
|
+
/* @__PURE__ */ jsxs12("div", { className: "univer-bases-subbar", children: [
|
|
3790
|
+
/* @__PURE__ */ jsxs12("div", { className: "univer-bases-inline-flex", children: [
|
|
3791
|
+
/* @__PURE__ */ jsx12("span", { className: "univer-bases-subbar__label", children: "\u5C42\u7EA7\u6811\u7236\u8282\u70B9\u5B57\u6BB5:" }),
|
|
3792
|
+
selfLinkFields.length > 0 ? /* @__PURE__ */ jsx12(
|
|
3793
|
+
"select",
|
|
3258
3794
|
{
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
"
|
|
3262
|
-
|
|
3263
|
-
commandService.syncExecuteCommand(
|
|
3795
|
+
className: "univer-bases-select univer-bases-select--xs",
|
|
3796
|
+
"data-testid": "bases-list-parent-field-select",
|
|
3797
|
+
value: parentField?.id ?? "",
|
|
3798
|
+
onChange: (e) => {
|
|
3799
|
+
commandService.syncExecuteCommand(UpdateBaseViewCommand6.id, {
|
|
3264
3800
|
unitId,
|
|
3265
3801
|
tableId: table.id,
|
|
3266
|
-
viewId:
|
|
3802
|
+
viewId: view.id,
|
|
3803
|
+
patch: { listParentFieldId: e.target.value || void 0 }
|
|
3267
3804
|
});
|
|
3268
3805
|
},
|
|
3806
|
+
children: selfLinkFields.map((lf) => /* @__PURE__ */ jsx12("option", { value: lf.id, children: lf.name }, lf.id))
|
|
3807
|
+
}
|
|
3808
|
+
) : /* @__PURE__ */ jsxs12(
|
|
3809
|
+
"button",
|
|
3810
|
+
{
|
|
3811
|
+
type: "button",
|
|
3812
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
3813
|
+
onClick: () => ensureParentFieldId(),
|
|
3269
3814
|
children: [
|
|
3270
|
-
/* @__PURE__ */ jsx12(
|
|
3271
|
-
/* @__PURE__ */ jsx12("span", { children:
|
|
3815
|
+
/* @__PURE__ */ jsx12(BasePlusIcon, {}),
|
|
3816
|
+
/* @__PURE__ */ jsx12("span", { children: "\u521D\u59CB\u5316\u7236\u5B50\u5C42\u7EA7\u5B57\u6BB5" })
|
|
3272
3817
|
]
|
|
3273
|
-
}
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3818
|
+
}
|
|
3819
|
+
),
|
|
3820
|
+
/* @__PURE__ */ jsxs12("span", { className: "univer-bases-muted-key", children: [
|
|
3821
|
+
"\u5171 ",
|
|
3822
|
+
listResult.totalNodeCount,
|
|
3823
|
+
" \u9879 \xB7 \u6700\u5927\u6DF1\u5EA6 ",
|
|
3824
|
+
listResult.maxDepth + 1,
|
|
3825
|
+
" \u5C42"
|
|
3826
|
+
] })
|
|
3827
|
+
] }),
|
|
3828
|
+
/* @__PURE__ */ jsxs12("div", { className: "univer-bases-inline-flex", children: [
|
|
3829
|
+
/* @__PURE__ */ jsx12(
|
|
3830
|
+
"button",
|
|
3831
|
+
{
|
|
3832
|
+
type: "button",
|
|
3833
|
+
className: "univer-bases-btn univer-bases-btn--ghost univer-bases-btn--sm",
|
|
3834
|
+
onClick: () => setAllCollapsed(false),
|
|
3835
|
+
children: "\u5168\u90E8\u5C55\u5F00"
|
|
3836
|
+
}
|
|
3837
|
+
),
|
|
3838
|
+
/* @__PURE__ */ jsx12(
|
|
3839
|
+
"button",
|
|
3840
|
+
{
|
|
3841
|
+
type: "button",
|
|
3842
|
+
className: "univer-bases-btn univer-bases-btn--ghost univer-bases-btn--sm",
|
|
3843
|
+
onClick: () => setAllCollapsed(true),
|
|
3844
|
+
children: "\u5168\u90E8\u6298\u53E0"
|
|
3845
|
+
}
|
|
3846
|
+
),
|
|
3847
|
+
/* @__PURE__ */ jsxs12(
|
|
3848
|
+
"button",
|
|
3849
|
+
{
|
|
3850
|
+
type: "button",
|
|
3851
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
3852
|
+
"data-testid": "bases-list-add-root-btn",
|
|
3853
|
+
onClick: () => {
|
|
3854
|
+
commandService.syncExecuteCommand(AddBaseRecordCommand5.id, {
|
|
3855
|
+
unitId,
|
|
3856
|
+
tableId: table.id,
|
|
3857
|
+
cells: primaryField ? { [primaryField.id]: "\u65B0\u5EFA\u6839\u5C42\u7EA7\u8BB0\u5F55" } : {}
|
|
3858
|
+
});
|
|
3859
|
+
},
|
|
3860
|
+
children: [
|
|
3861
|
+
/* @__PURE__ */ jsx12(BasePlusIcon, {}),
|
|
3862
|
+
/* @__PURE__ */ jsx12("span", { children: "\u65B0\u589E\u9876\u5C42\u9879" })
|
|
3863
|
+
]
|
|
3864
|
+
}
|
|
3865
|
+
)
|
|
3866
|
+
] })
|
|
3867
|
+
] }),
|
|
3868
|
+
/* @__PURE__ */ jsxs12("div", { className: "univer-bases-list-scroll", children: [
|
|
3869
|
+
/* @__PURE__ */ jsxs12("div", { className: "univer-bases-list-header", children: [
|
|
3870
|
+
/* @__PURE__ */ jsx12("span", { className: "univer-bases-list-col-title", children: "\u5C42\u7EA7\u7ED3\u6784\u4E0E\u8BB0\u5F55\u540D\u79F0" }),
|
|
3871
|
+
/* @__PURE__ */ jsx12("span", { className: "univer-bases-list-col-badges", children: "\u72B6\u6001 \xB7 \u8D1F\u8D23\u4EBA \xB7 \u6392\u671F\u4E0E\u8FDB\u5EA6" }),
|
|
3872
|
+
/* @__PURE__ */ jsx12("span", { className: "univer-bases-list-col-actions", children: "\u5FEB\u6377\u5C42\u7EA7\u64CD\u4F5C" })
|
|
3873
|
+
] }),
|
|
3874
|
+
listResult.flattenedVisibleNodes.length === 0 ? /* @__PURE__ */ jsx12("div", { className: "univer-bases-empty-hint", children: "\u6682\u65E0\u5339\u914D\u8BB0\u5F55" }) : /* @__PURE__ */ jsx12("div", { className: "univer-bases-list-rows", children: listResult.flattenedVisibleNodes.map((node) => {
|
|
3875
|
+
const siblings = node.parentId ? nodeMap.get(node.parentId)?.children ?? [] : listResult.roots;
|
|
3876
|
+
const siblingIdx = siblings.findIndex((s) => s.recordId === node.recordId);
|
|
3877
|
+
const canPromote = Boolean(parentField && node.parentId);
|
|
3878
|
+
const canDemote = siblingIdx > 0;
|
|
3879
|
+
const statusVal = statusField ? node.row.displayValues[statusField.id] : "";
|
|
3880
|
+
const statusOpt = statusField?.config?.options?.find(
|
|
3881
|
+
(o) => o.name === statusVal || o.id === node.row.values[statusField.id]
|
|
3882
|
+
);
|
|
3883
|
+
const rawPersons = personField ? node.row.values[personField.id] : void 0;
|
|
3884
|
+
const personNames = Array.isArray(rawPersons) ? rawPersons.map((p) => typeof p === "string" ? p : p.name).filter(Boolean).join(", ") : personField ? node.row.displayValues[personField.id] : "";
|
|
3885
|
+
const dateVal = dateField ? node.row.displayValues[dateField.id] : "";
|
|
3886
|
+
const progressVal = progressField ? node.row.displayValues[progressField.id] : "";
|
|
3887
|
+
return /* @__PURE__ */ jsxs12(
|
|
3888
|
+
"div",
|
|
3889
|
+
{
|
|
3890
|
+
className: "univer-bases-list-row",
|
|
3891
|
+
"data-testid": `bases-list-row-${node.recordId}`,
|
|
3892
|
+
"data-depth": node.depth,
|
|
3893
|
+
style: node.row.rowColor ? { backgroundColor: node.row.rowColor } : void 0,
|
|
3894
|
+
onClick: () => selectionService.openRecordDrawer(node.recordId),
|
|
3895
|
+
children: [
|
|
3896
|
+
/* @__PURE__ */ jsxs12(
|
|
3897
|
+
"div",
|
|
3898
|
+
{
|
|
3899
|
+
className: "univer-bases-list-row__main",
|
|
3900
|
+
style: { paddingLeft: `${node.depth * 22 + 12}px` },
|
|
3901
|
+
children: [
|
|
3902
|
+
node.depth > 0 && /* @__PURE__ */ jsx12(
|
|
3903
|
+
"span",
|
|
3904
|
+
{
|
|
3905
|
+
className: "univer-bases-list-indent-guide",
|
|
3906
|
+
"aria-hidden": "true"
|
|
3907
|
+
}
|
|
3908
|
+
),
|
|
3909
|
+
node.children.length > 0 ? /* @__PURE__ */ jsx12(
|
|
3910
|
+
"button",
|
|
3911
|
+
{
|
|
3912
|
+
type: "button",
|
|
3913
|
+
className: "univer-bases-icon-btn univer-bases-list-chevron",
|
|
3914
|
+
"data-testid": `bases-list-toggle-${node.recordId}`,
|
|
3915
|
+
"aria-label": node.collapsed ? "\u5C55\u5F00\u5B50\u9879" : "\u6298\u53E0\u5B50\u9879",
|
|
3916
|
+
onClick: (e) => {
|
|
3917
|
+
e.stopPropagation();
|
|
3918
|
+
toggleNodeCollapsed(node.recordId);
|
|
3919
|
+
},
|
|
3920
|
+
children: node.collapsed ? /* @__PURE__ */ jsx12(BaseChevronRightIcon, {}) : /* @__PURE__ */ jsx12(BaseChevronDownIcon, {})
|
|
3921
|
+
}
|
|
3922
|
+
) : /* @__PURE__ */ jsx12("span", { className: "univer-bases-list-leaf-dot", "aria-hidden": "true" }),
|
|
3923
|
+
/* @__PURE__ */ jsx12("span", { className: "univer-bases-list-row__title", children: node.title }),
|
|
3924
|
+
node.descendantCount > 0 && /* @__PURE__ */ jsxs12("span", { className: "univer-bases-badge-count", children: [
|
|
3925
|
+
node.descendantCount,
|
|
3926
|
+
" \u5B50\u9879"
|
|
3927
|
+
] }),
|
|
3928
|
+
node.cycleDetected && /* @__PURE__ */ jsx12("span", { className: "univer-bases-pill univer-bases-pill--neutral", children: "\u73AF\u8DEF\u4FDD\u62A4" })
|
|
3929
|
+
]
|
|
3930
|
+
}
|
|
3931
|
+
),
|
|
3932
|
+
/* @__PURE__ */ jsxs12("div", { className: "univer-bases-list-row__badges", children: [
|
|
3933
|
+
statusVal && /* @__PURE__ */ jsx12(
|
|
3934
|
+
"span",
|
|
3935
|
+
{
|
|
3936
|
+
className: "univer-bases-pill",
|
|
3937
|
+
style: {
|
|
3938
|
+
backgroundColor: statusOpt ? `${statusOpt.color}18` : "#f1f5f9",
|
|
3939
|
+
color: statusOpt?.color ?? "#334155",
|
|
3940
|
+
borderColor: statusOpt ? `${statusOpt.color}40` : "#e2e8f0"
|
|
3941
|
+
},
|
|
3942
|
+
children: statusVal
|
|
3943
|
+
}
|
|
3944
|
+
),
|
|
3945
|
+
personNames && /* @__PURE__ */ jsx12("span", { className: "univer-bases-pill univer-bases-pill--neutral", children: personNames }),
|
|
3946
|
+
dateVal && /* @__PURE__ */ jsxs12("span", { className: "univer-bases-inline-flex univer-bases-muted-key", children: [
|
|
3947
|
+
/* @__PURE__ */ jsx12(BaseCalendarIcon, {}),
|
|
3948
|
+
/* @__PURE__ */ jsx12("span", { children: dateVal })
|
|
3949
|
+
] }),
|
|
3950
|
+
progressVal && /* @__PURE__ */ jsx12("span", { className: "univer-bases-pill univer-bases-pill--neutral", children: progressVal })
|
|
3951
|
+
] }),
|
|
3952
|
+
/* @__PURE__ */ jsxs12(
|
|
3953
|
+
"div",
|
|
3954
|
+
{
|
|
3955
|
+
className: "univer-bases-list-row__actions",
|
|
3956
|
+
onClick: (e) => e.stopPropagation(),
|
|
3957
|
+
children: [
|
|
3958
|
+
/* @__PURE__ */ jsxs12(
|
|
3959
|
+
"button",
|
|
3960
|
+
{
|
|
3961
|
+
type: "button",
|
|
3962
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
3963
|
+
"data-testid": `bases-list-add-child-${node.recordId}`,
|
|
3964
|
+
onClick: () => handleAddChildRecord(node),
|
|
3965
|
+
children: [
|
|
3966
|
+
/* @__PURE__ */ jsx12(BasePlusIcon, {}),
|
|
3967
|
+
/* @__PURE__ */ jsx12("span", { children: "\u5B50\u8BB0\u5F55" })
|
|
3968
|
+
]
|
|
3969
|
+
}
|
|
3970
|
+
),
|
|
3971
|
+
/* @__PURE__ */ jsx12(
|
|
3972
|
+
"button",
|
|
3973
|
+
{
|
|
3974
|
+
type: "button",
|
|
3975
|
+
className: "univer-bases-icon-btn",
|
|
3976
|
+
title: "\u63D0\u5347\u5C42\u7EA7 (\u5347\u7EA7\u4E3A\u4E0A\u7EA7\u8282\u70B9\u540C\u7EA7)",
|
|
3977
|
+
"data-testid": `bases-list-promote-${node.recordId}`,
|
|
3978
|
+
disabled: !canPromote,
|
|
3979
|
+
onClick: () => handlePromoteNode(node),
|
|
3980
|
+
children: /* @__PURE__ */ jsx12(BaseOutdentIcon, {})
|
|
3981
|
+
}
|
|
3982
|
+
),
|
|
3983
|
+
/* @__PURE__ */ jsx12(
|
|
3984
|
+
"button",
|
|
3985
|
+
{
|
|
3986
|
+
type: "button",
|
|
3987
|
+
className: "univer-bases-icon-btn",
|
|
3988
|
+
title: "\u964D\u4F4E\u5C42\u7EA7 (\u7F29\u8FDB\u4E3A\u4E0A\u4E00\u540C\u7EA7\u8282\u70B9\u7684\u5B50\u9879)",
|
|
3989
|
+
"data-testid": `bases-list-demote-${node.recordId}`,
|
|
3990
|
+
disabled: !canDemote,
|
|
3991
|
+
onClick: () => handleDemoteNode(node),
|
|
3992
|
+
children: /* @__PURE__ */ jsx12(BaseIndentIcon, {})
|
|
3993
|
+
}
|
|
3994
|
+
)
|
|
3995
|
+
]
|
|
3996
|
+
}
|
|
3997
|
+
)
|
|
3998
|
+
]
|
|
3999
|
+
},
|
|
4000
|
+
node.recordId
|
|
4001
|
+
);
|
|
4002
|
+
}) })
|
|
4003
|
+
] })
|
|
4004
|
+
] });
|
|
4005
|
+
};
|
|
4006
|
+
|
|
4007
|
+
// src/views/toolbar/BasesViewToolbar.tsx
|
|
4008
|
+
import { generateRandomId as generateRandomId4 } from "@univerjs/core";
|
|
4009
|
+
import {
|
|
4010
|
+
AddBaseRecordCommand as AddBaseRecordCommand6,
|
|
4011
|
+
AddBaseViewCommand as AddBaseViewCommand2,
|
|
4012
|
+
BASE_ROW_COLOR_PALETTE,
|
|
4013
|
+
SetActiveBaseViewCommand as SetActiveBaseViewCommand2,
|
|
4014
|
+
SetBaseWorkspaceModeCommand as SetBaseWorkspaceModeCommand2,
|
|
4015
|
+
UpdateBaseViewCommand as UpdateBaseViewCommand7
|
|
4016
|
+
} from "@yudaocode/univer-bases";
|
|
4017
|
+
import { useState as useState9 } from "react";
|
|
4018
|
+
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4019
|
+
var FILTER_OPERATOR_OPTIONS = [
|
|
4020
|
+
{ value: "is", label: "\u7B49\u4E8E" },
|
|
4021
|
+
{ value: "isNot", label: "\u4E0D\u7B49\u4E8E" },
|
|
4022
|
+
{ value: "contains", label: "\u5305\u542B" },
|
|
4023
|
+
{ value: "notContains", label: "\u4E0D\u5305\u542B" },
|
|
4024
|
+
{ value: "gt", label: "\u5927\u4E8E" },
|
|
4025
|
+
{ value: "gte", label: "\u5927\u4E8E\u7B49\u4E8E" },
|
|
4026
|
+
{ value: "lt", label: "\u5C0F\u4E8E" },
|
|
4027
|
+
{ value: "lte", label: "\u5C0F\u4E8E\u7B49\u4E8E" },
|
|
4028
|
+
{ value: "isEmpty", label: "\u4E3A\u7A7A" },
|
|
4029
|
+
{ value: "isNotEmpty", label: "\u4E0D\u4E3A\u7A7A" }
|
|
4030
|
+
];
|
|
4031
|
+
var QUICK_VIEW_MODES = [
|
|
4032
|
+
{ type: "grid", label: "\u8868\u683C\u89C6\u56FE" },
|
|
4033
|
+
{ type: "list", label: "\u5217\u8868\u89C6\u56FE" },
|
|
4034
|
+
{ type: "kanban", label: "\u770B\u677F" },
|
|
4035
|
+
{ type: "calendar", label: "\u65E5\u5386" },
|
|
4036
|
+
{ type: "gallery", label: "\u753B\u5ECA" },
|
|
4037
|
+
{ type: "gantt", label: "\u7518\u7279\u56FE" },
|
|
4038
|
+
{ type: "timeline", label: "\u65F6\u95F4\u8F74" },
|
|
4039
|
+
{ type: "form", label: "\u8868\u5355" },
|
|
4040
|
+
{ type: "dashboard", label: "\u4EEA\u8868\u76D8" }
|
|
4041
|
+
];
|
|
4042
|
+
var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
4043
|
+
const { unit, commandService, selectionService, selectionState } = useActiveBaseWorkspace();
|
|
4044
|
+
const [openPopover, setOpenPopover] = useState9(null);
|
|
4045
|
+
const [newViewName, setNewViewName] = useState9("");
|
|
4046
|
+
const [newViewType, setNewViewType] = useState9("grid");
|
|
4047
|
+
if (!unit) return null;
|
|
4048
|
+
const unitId = unit.getUnitId();
|
|
4049
|
+
const fields = table.fieldOrder.map((fid) => table.fields[fid]).filter((f) => Boolean(f));
|
|
4050
|
+
const filters = activeView.filters ?? [];
|
|
4051
|
+
const sorts = activeView.sorts ?? [];
|
|
4052
|
+
const groups = activeView.groups ?? [];
|
|
4053
|
+
const colorRules = activeView.colorRules ?? [];
|
|
4054
|
+
const conjunction = activeView.filterConjunction ?? "and";
|
|
4055
|
+
const patchView = (patch) => {
|
|
4056
|
+
commandService.syncExecuteCommand(UpdateBaseViewCommand7.id, {
|
|
4057
|
+
unitId,
|
|
4058
|
+
tableId: table.id,
|
|
4059
|
+
viewId: activeView.id,
|
|
4060
|
+
patch
|
|
4061
|
+
});
|
|
4062
|
+
};
|
|
4063
|
+
const togglePopover = (target) => {
|
|
4064
|
+
setOpenPopover((prev) => prev === target ? null : target);
|
|
4065
|
+
};
|
|
4066
|
+
return /* @__PURE__ */ jsxs13("div", { className: "univer-bases-toolbar", "data-testid": "bases-view-toolbar", children: [
|
|
4067
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-toolbar__tabs", children: [
|
|
4068
|
+
table.viewOrder.map((vid) => {
|
|
4069
|
+
const vw = table.views[vid];
|
|
4070
|
+
if (!vw) return null;
|
|
4071
|
+
const isActive = workspaceMode === "table" && activeView.id === vw.id;
|
|
4072
|
+
return /* @__PURE__ */ jsxs13(
|
|
4073
|
+
"button",
|
|
4074
|
+
{
|
|
4075
|
+
type: "button",
|
|
4076
|
+
className: `univer-bases-view-tab ${isActive ? "is-active" : ""}`,
|
|
4077
|
+
"data-testid": `bases-view-tab-${vw.type}`,
|
|
4078
|
+
onClick: () => {
|
|
4079
|
+
commandService.syncExecuteCommand(SetActiveBaseViewCommand2.id, {
|
|
4080
|
+
unitId,
|
|
4081
|
+
tableId: table.id,
|
|
4082
|
+
viewId: vw.id
|
|
4083
|
+
});
|
|
4084
|
+
},
|
|
4085
|
+
children: [
|
|
4086
|
+
/* @__PURE__ */ jsx13(BaseViewTypeIcon, { type: vw.type }),
|
|
4087
|
+
/* @__PURE__ */ jsx13("span", { children: vw.name })
|
|
4088
|
+
]
|
|
4089
|
+
},
|
|
4090
|
+
vw.id
|
|
4091
|
+
);
|
|
4092
|
+
}),
|
|
4093
|
+
/* @__PURE__ */ jsxs13(
|
|
4094
|
+
"button",
|
|
4095
|
+
{
|
|
4096
|
+
type: "button",
|
|
4097
|
+
className: `univer-bases-view-tab ${workspaceMode === "dashboard" ? "is-active" : ""}`,
|
|
4098
|
+
"data-testid": "bases-view-tab-dashboard",
|
|
4099
|
+
onClick: () => {
|
|
4100
|
+
commandService.syncExecuteCommand(SetBaseWorkspaceModeCommand2.id, {
|
|
4101
|
+
unitId,
|
|
4102
|
+
mode: "dashboard"
|
|
4103
|
+
});
|
|
4104
|
+
},
|
|
4105
|
+
children: [
|
|
4106
|
+
/* @__PURE__ */ jsx13(BaseViewTypeIcon, { type: "dashboard" }),
|
|
4107
|
+
/* @__PURE__ */ jsx13("span", { children: "\u6570\u636E\u4EEA\u8868\u76D8" })
|
|
4108
|
+
]
|
|
4109
|
+
}
|
|
4110
|
+
),
|
|
4111
|
+
/* @__PURE__ */ jsx13("div", { className: "univer-bases-toolbar__quick-modes", "aria-label": "\u89C6\u56FE\u6A21\u5F0F\u5FEB\u6377\u5207\u6362", children: QUICK_VIEW_MODES.map((m) => {
|
|
4112
|
+
const existsInTabs = m.type === "dashboard" || table.viewOrder.some((vid) => table.views[vid]?.type === m.type);
|
|
4113
|
+
if (existsInTabs) return null;
|
|
4114
|
+
return /* @__PURE__ */ jsxs13(
|
|
3299
4115
|
"button",
|
|
3300
4116
|
{
|
|
3301
4117
|
type: "button",
|
|
@@ -3306,15 +4122,15 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3306
4122
|
});
|
|
3307
4123
|
},
|
|
3308
4124
|
children: [
|
|
3309
|
-
/* @__PURE__ */
|
|
3310
|
-
/* @__PURE__ */
|
|
4125
|
+
/* @__PURE__ */ jsx13(BaseViewTypeIcon, { type: m.type }),
|
|
4126
|
+
/* @__PURE__ */ jsx13("span", { children: m.label })
|
|
3311
4127
|
]
|
|
3312
4128
|
},
|
|
3313
4129
|
m.type
|
|
3314
4130
|
);
|
|
3315
4131
|
}) }),
|
|
3316
|
-
/* @__PURE__ */
|
|
3317
|
-
/* @__PURE__ */
|
|
4132
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover-anchor", children: [
|
|
4133
|
+
/* @__PURE__ */ jsxs13(
|
|
3318
4134
|
"button",
|
|
3319
4135
|
{
|
|
3320
4136
|
type: "button",
|
|
@@ -3322,27 +4138,27 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3322
4138
|
"data-testid": "bases-new-view-btn",
|
|
3323
4139
|
onClick: () => togglePopover("newView"),
|
|
3324
4140
|
children: [
|
|
3325
|
-
/* @__PURE__ */
|
|
3326
|
-
/* @__PURE__ */
|
|
4141
|
+
/* @__PURE__ */ jsx13(BasePlusIcon, {}),
|
|
4142
|
+
/* @__PURE__ */ jsx13("span", { children: "\u65B0\u5EFA\u89C6\u56FE" })
|
|
3327
4143
|
]
|
|
3328
4144
|
}
|
|
3329
4145
|
),
|
|
3330
|
-
openPopover === "newView" && /* @__PURE__ */
|
|
3331
|
-
/* @__PURE__ */
|
|
3332
|
-
/* @__PURE__ */
|
|
3333
|
-
/* @__PURE__ */
|
|
4146
|
+
openPopover === "newView" && /* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover", "data-testid": "bases-new-view-popover", children: [
|
|
4147
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover__header", children: [
|
|
4148
|
+
/* @__PURE__ */ jsx13("strong", { children: "\u65B0\u5EFA\u591A\u7EF4\u89C6\u56FE" }),
|
|
4149
|
+
/* @__PURE__ */ jsx13(
|
|
3334
4150
|
"button",
|
|
3335
4151
|
{
|
|
3336
4152
|
type: "button",
|
|
3337
4153
|
className: "univer-bases-icon-btn",
|
|
3338
4154
|
onClick: () => setOpenPopover(null),
|
|
3339
|
-
children: /* @__PURE__ */
|
|
4155
|
+
children: /* @__PURE__ */ jsx13(BaseCloseIcon, {})
|
|
3340
4156
|
}
|
|
3341
4157
|
)
|
|
3342
4158
|
] }),
|
|
3343
|
-
/* @__PURE__ */
|
|
3344
|
-
/* @__PURE__ */
|
|
3345
|
-
/* @__PURE__ */
|
|
4159
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-form-row", children: [
|
|
4160
|
+
/* @__PURE__ */ jsx13("label", { children: "\u89C6\u56FE\u540D\u79F0" }),
|
|
4161
|
+
/* @__PURE__ */ jsx13(
|
|
3346
4162
|
"input",
|
|
3347
4163
|
{
|
|
3348
4164
|
type: "text",
|
|
@@ -3353,27 +4169,28 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3353
4169
|
}
|
|
3354
4170
|
)
|
|
3355
4171
|
] }),
|
|
3356
|
-
/* @__PURE__ */
|
|
3357
|
-
/* @__PURE__ */
|
|
3358
|
-
/* @__PURE__ */
|
|
4172
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-form-row", children: [
|
|
4173
|
+
/* @__PURE__ */ jsx13("label", { children: "\u89C6\u56FE\u7C7B\u578B" }),
|
|
4174
|
+
/* @__PURE__ */ jsxs13(
|
|
3359
4175
|
"select",
|
|
3360
4176
|
{
|
|
3361
4177
|
className: "univer-bases-select",
|
|
3362
4178
|
value: newViewType,
|
|
3363
4179
|
onChange: (e) => setNewViewType(e.target.value),
|
|
3364
4180
|
children: [
|
|
3365
|
-
/* @__PURE__ */
|
|
3366
|
-
/* @__PURE__ */
|
|
3367
|
-
/* @__PURE__ */
|
|
3368
|
-
/* @__PURE__ */
|
|
3369
|
-
/* @__PURE__ */
|
|
3370
|
-
/* @__PURE__ */
|
|
3371
|
-
/* @__PURE__ */
|
|
4181
|
+
/* @__PURE__ */ jsx13("option", { value: "grid", children: "\u8868\u683C\u89C6\u56FE (Grid)" }),
|
|
4182
|
+
/* @__PURE__ */ jsx13("option", { value: "list", children: "\u5217\u8868\u89C6\u56FE (List)" }),
|
|
4183
|
+
/* @__PURE__ */ jsx13("option", { value: "kanban", children: "\u770B\u677F\u89C6\u56FE (Kanban)" }),
|
|
4184
|
+
/* @__PURE__ */ jsx13("option", { value: "calendar", children: "\u65E5\u5386\u89C6\u56FE (Calendar)" }),
|
|
4185
|
+
/* @__PURE__ */ jsx13("option", { value: "gallery", children: "\u753B\u5ECA\u89C6\u56FE (Gallery)" }),
|
|
4186
|
+
/* @__PURE__ */ jsx13("option", { value: "gantt", children: "\u7518\u7279\u56FE (Gantt)" }),
|
|
4187
|
+
/* @__PURE__ */ jsx13("option", { value: "timeline", children: "\u65F6\u95F4\u8F74 (Timeline)" }),
|
|
4188
|
+
/* @__PURE__ */ jsx13("option", { value: "form", children: "\u8868\u5355\u6536\u96C6 (Form)" })
|
|
3372
4189
|
]
|
|
3373
4190
|
}
|
|
3374
4191
|
)
|
|
3375
4192
|
] }),
|
|
3376
|
-
/* @__PURE__ */
|
|
4193
|
+
/* @__PURE__ */ jsx13("div", { className: "univer-bases-popover__footer", children: /* @__PURE__ */ jsx13(
|
|
3377
4194
|
"button",
|
|
3378
4195
|
{
|
|
3379
4196
|
type: "button",
|
|
@@ -3395,16 +4212,16 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3395
4212
|
] })
|
|
3396
4213
|
] })
|
|
3397
4214
|
] }),
|
|
3398
|
-
workspaceMode === "table" && /* @__PURE__ */
|
|
3399
|
-
/* @__PURE__ */
|
|
3400
|
-
/* @__PURE__ */
|
|
4215
|
+
workspaceMode === "table" && /* @__PURE__ */ jsxs13("div", { className: "univer-bases-toolbar__actions", children: [
|
|
4216
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-toolbar__left", children: [
|
|
4217
|
+
/* @__PURE__ */ jsxs13(
|
|
3401
4218
|
"button",
|
|
3402
4219
|
{
|
|
3403
4220
|
type: "button",
|
|
3404
4221
|
className: "univer-bases-btn univer-bases-btn--primary univer-bases-btn--sm",
|
|
3405
4222
|
"data-testid": "bases-toolbar-add-record",
|
|
3406
4223
|
onClick: () => {
|
|
3407
|
-
commandService.syncExecuteCommand(
|
|
4224
|
+
commandService.syncExecuteCommand(AddBaseRecordCommand6.id, {
|
|
3408
4225
|
unitId,
|
|
3409
4226
|
tableId: table.id,
|
|
3410
4227
|
cells: { [table.primaryFieldId]: "\u65B0\u8BB0\u5F55" },
|
|
@@ -3412,13 +4229,13 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3412
4229
|
});
|
|
3413
4230
|
},
|
|
3414
4231
|
children: [
|
|
3415
|
-
/* @__PURE__ */
|
|
3416
|
-
/* @__PURE__ */
|
|
4232
|
+
/* @__PURE__ */ jsx13(BasePlusIcon, {}),
|
|
4233
|
+
/* @__PURE__ */ jsx13("span", { children: "\u65B0\u589E\u8BB0\u5F55" })
|
|
3417
4234
|
]
|
|
3418
4235
|
}
|
|
3419
4236
|
),
|
|
3420
|
-
/* @__PURE__ */
|
|
3421
|
-
/* @__PURE__ */
|
|
4237
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover-anchor", children: [
|
|
4238
|
+
/* @__PURE__ */ jsxs13(
|
|
3422
4239
|
"button",
|
|
3423
4240
|
{
|
|
3424
4241
|
type: "button",
|
|
@@ -3426,43 +4243,43 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3426
4243
|
"data-testid": "bases-filter-btn",
|
|
3427
4244
|
onClick: () => togglePopover("filter"),
|
|
3428
4245
|
children: [
|
|
3429
|
-
/* @__PURE__ */
|
|
3430
|
-
/* @__PURE__ */
|
|
4246
|
+
/* @__PURE__ */ jsx13(BaseFilterIcon, {}),
|
|
4247
|
+
/* @__PURE__ */ jsxs13("span", { children: [
|
|
3431
4248
|
"\u7B5B\u9009",
|
|
3432
4249
|
filters.length > 0 ? ` (${filters.length})` : ""
|
|
3433
4250
|
] })
|
|
3434
4251
|
]
|
|
3435
4252
|
}
|
|
3436
4253
|
),
|
|
3437
|
-
openPopover === "filter" && /* @__PURE__ */
|
|
3438
|
-
/* @__PURE__ */
|
|
3439
|
-
/* @__PURE__ */
|
|
3440
|
-
/* @__PURE__ */
|
|
3441
|
-
/* @__PURE__ */
|
|
4254
|
+
openPopover === "filter" && /* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover univer-bases-popover--wide", "data-testid": "bases-filter-popover", children: [
|
|
4255
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover__header", children: [
|
|
4256
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-inline-flex", children: [
|
|
4257
|
+
/* @__PURE__ */ jsx13("strong", { children: "\u7B5B\u9009\u6761\u4EF6" }),
|
|
4258
|
+
/* @__PURE__ */ jsxs13(
|
|
3442
4259
|
"select",
|
|
3443
4260
|
{
|
|
3444
4261
|
className: "univer-bases-select univer-bases-select--xs",
|
|
3445
4262
|
value: conjunction,
|
|
3446
4263
|
onChange: (e) => patchView({ filterConjunction: e.target.value }),
|
|
3447
4264
|
children: [
|
|
3448
|
-
/* @__PURE__ */
|
|
3449
|
-
/* @__PURE__ */
|
|
4265
|
+
/* @__PURE__ */ jsx13("option", { value: "and", children: "\u6EE1\u8DB3\u5168\u90E8 (AND)" }),
|
|
4266
|
+
/* @__PURE__ */ jsx13("option", { value: "or", children: "\u6EE1\u8DB3\u4EFB\u4E00 (OR)" })
|
|
3450
4267
|
]
|
|
3451
4268
|
}
|
|
3452
4269
|
)
|
|
3453
4270
|
] }),
|
|
3454
|
-
/* @__PURE__ */
|
|
4271
|
+
/* @__PURE__ */ jsx13(
|
|
3455
4272
|
"button",
|
|
3456
4273
|
{
|
|
3457
4274
|
type: "button",
|
|
3458
4275
|
className: "univer-bases-icon-btn",
|
|
3459
4276
|
onClick: () => setOpenPopover(null),
|
|
3460
|
-
children: /* @__PURE__ */
|
|
4277
|
+
children: /* @__PURE__ */ jsx13(BaseCloseIcon, {})
|
|
3461
4278
|
}
|
|
3462
4279
|
)
|
|
3463
4280
|
] }),
|
|
3464
|
-
filters.length === 0 ? /* @__PURE__ */
|
|
3465
|
-
/* @__PURE__ */
|
|
4281
|
+
filters.length === 0 ? /* @__PURE__ */ jsx13("div", { className: "univer-bases-empty-hint", children: "\u6682\u65E0\u7B5B\u9009\u89C4\u5219\uFF0C\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u6DFB\u52A0\u6761\u4EF6" }) : /* @__PURE__ */ jsx13("div", { className: "univer-bases-rule-list", children: filters.map((rule) => /* @__PURE__ */ jsxs13("div", { className: "univer-bases-rule-row", children: [
|
|
4282
|
+
/* @__PURE__ */ jsx13(
|
|
3466
4283
|
"select",
|
|
3467
4284
|
{
|
|
3468
4285
|
className: "univer-bases-select",
|
|
@@ -3473,10 +4290,10 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3473
4290
|
);
|
|
3474
4291
|
patchView({ filters: next });
|
|
3475
4292
|
},
|
|
3476
|
-
children: fields.map((f) => /* @__PURE__ */
|
|
4293
|
+
children: fields.map((f) => /* @__PURE__ */ jsx13("option", { value: f.id, children: f.name }, f.id))
|
|
3477
4294
|
}
|
|
3478
4295
|
),
|
|
3479
|
-
/* @__PURE__ */
|
|
4296
|
+
/* @__PURE__ */ jsx13(
|
|
3480
4297
|
"select",
|
|
3481
4298
|
{
|
|
3482
4299
|
className: "univer-bases-select",
|
|
@@ -3487,10 +4304,10 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3487
4304
|
);
|
|
3488
4305
|
patchView({ filters: next });
|
|
3489
4306
|
},
|
|
3490
|
-
children: FILTER_OPERATOR_OPTIONS.map((op) => /* @__PURE__ */
|
|
4307
|
+
children: FILTER_OPERATOR_OPTIONS.map((op) => /* @__PURE__ */ jsx13("option", { value: op.value, children: op.label }, op.value))
|
|
3491
4308
|
}
|
|
3492
4309
|
),
|
|
3493
|
-
rule.operator !== "isEmpty" && rule.operator !== "isNotEmpty" && /* @__PURE__ */
|
|
4310
|
+
rule.operator !== "isEmpty" && rule.operator !== "isNotEmpty" && /* @__PURE__ */ jsx13(
|
|
3494
4311
|
"input",
|
|
3495
4312
|
{
|
|
3496
4313
|
type: "text",
|
|
@@ -3505,17 +4322,17 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3505
4322
|
}
|
|
3506
4323
|
}
|
|
3507
4324
|
),
|
|
3508
|
-
/* @__PURE__ */
|
|
4325
|
+
/* @__PURE__ */ jsx13(
|
|
3509
4326
|
"button",
|
|
3510
4327
|
{
|
|
3511
4328
|
type: "button",
|
|
3512
4329
|
className: "univer-bases-icon-btn",
|
|
3513
4330
|
onClick: () => patchView({ filters: filters.filter((r) => r.id !== rule.id) }),
|
|
3514
|
-
children: /* @__PURE__ */
|
|
4331
|
+
children: /* @__PURE__ */ jsx13(BaseTrashIcon, {})
|
|
3515
4332
|
}
|
|
3516
4333
|
)
|
|
3517
4334
|
] }, rule.id)) }),
|
|
3518
|
-
/* @__PURE__ */
|
|
4335
|
+
/* @__PURE__ */ jsx13("div", { className: "univer-bases-popover__footer", children: /* @__PURE__ */ jsxs13(
|
|
3519
4336
|
"button",
|
|
3520
4337
|
{
|
|
3521
4338
|
type: "button",
|
|
@@ -3527,7 +4344,7 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3527
4344
|
filters: [
|
|
3528
4345
|
...filters,
|
|
3529
4346
|
{
|
|
3530
|
-
id: `flt_${
|
|
4347
|
+
id: `flt_${generateRandomId4(5)}`,
|
|
3531
4348
|
fieldId: firstField.id,
|
|
3532
4349
|
operator: "contains",
|
|
3533
4350
|
value: ""
|
|
@@ -3536,15 +4353,15 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3536
4353
|
});
|
|
3537
4354
|
},
|
|
3538
4355
|
children: [
|
|
3539
|
-
/* @__PURE__ */
|
|
3540
|
-
/* @__PURE__ */
|
|
4356
|
+
/* @__PURE__ */ jsx13(BasePlusIcon, {}),
|
|
4357
|
+
/* @__PURE__ */ jsx13("span", { children: "\u6DFB\u52A0\u7B5B\u9009\u6761\u4EF6" })
|
|
3541
4358
|
]
|
|
3542
4359
|
}
|
|
3543
4360
|
) })
|
|
3544
4361
|
] })
|
|
3545
4362
|
] }),
|
|
3546
|
-
/* @__PURE__ */
|
|
3547
|
-
/* @__PURE__ */
|
|
4363
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover-anchor", children: [
|
|
4364
|
+
/* @__PURE__ */ jsxs13(
|
|
3548
4365
|
"button",
|
|
3549
4366
|
{
|
|
3550
4367
|
type: "button",
|
|
@@ -3552,29 +4369,29 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3552
4369
|
"data-testid": "bases-sort-btn",
|
|
3553
4370
|
onClick: () => togglePopover("sort"),
|
|
3554
4371
|
children: [
|
|
3555
|
-
/* @__PURE__ */
|
|
3556
|
-
/* @__PURE__ */
|
|
4372
|
+
/* @__PURE__ */ jsx13(BaseSortIcon, {}),
|
|
4373
|
+
/* @__PURE__ */ jsxs13("span", { children: [
|
|
3557
4374
|
"\u6392\u5E8F",
|
|
3558
4375
|
sorts.length > 0 ? ` (${sorts.length})` : ""
|
|
3559
4376
|
] })
|
|
3560
4377
|
]
|
|
3561
4378
|
}
|
|
3562
4379
|
),
|
|
3563
|
-
openPopover === "sort" && /* @__PURE__ */
|
|
3564
|
-
/* @__PURE__ */
|
|
3565
|
-
/* @__PURE__ */
|
|
3566
|
-
/* @__PURE__ */
|
|
4380
|
+
openPopover === "sort" && /* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover univer-bases-popover--wide", "data-testid": "bases-sort-popover", children: [
|
|
4381
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover__header", children: [
|
|
4382
|
+
/* @__PURE__ */ jsx13("strong", { children: "\u591A\u5217\u6392\u5E8F\u89C4\u5219" }),
|
|
4383
|
+
/* @__PURE__ */ jsx13(
|
|
3567
4384
|
"button",
|
|
3568
4385
|
{
|
|
3569
4386
|
type: "button",
|
|
3570
4387
|
className: "univer-bases-icon-btn",
|
|
3571
4388
|
onClick: () => setOpenPopover(null),
|
|
3572
|
-
children: /* @__PURE__ */
|
|
4389
|
+
children: /* @__PURE__ */ jsx13(BaseCloseIcon, {})
|
|
3573
4390
|
}
|
|
3574
4391
|
)
|
|
3575
4392
|
] }),
|
|
3576
|
-
sorts.length === 0 ? /* @__PURE__ */
|
|
3577
|
-
/* @__PURE__ */
|
|
4393
|
+
sorts.length === 0 ? /* @__PURE__ */ jsx13("div", { className: "univer-bases-empty-hint", children: "\u5F53\u524D\u6309\u9ED8\u8BA4\u8BB0\u5F55\u987A\u5E8F\u6392\u5217" }) : /* @__PURE__ */ jsx13("div", { className: "univer-bases-rule-list", children: sorts.map((sr) => /* @__PURE__ */ jsxs13("div", { className: "univer-bases-rule-row", children: [
|
|
4394
|
+
/* @__PURE__ */ jsx13(
|
|
3578
4395
|
"select",
|
|
3579
4396
|
{
|
|
3580
4397
|
className: "univer-bases-select",
|
|
@@ -3585,10 +4402,10 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3585
4402
|
);
|
|
3586
4403
|
patchView({ sorts: next });
|
|
3587
4404
|
},
|
|
3588
|
-
children: fields.map((f) => /* @__PURE__ */
|
|
4405
|
+
children: fields.map((f) => /* @__PURE__ */ jsx13("option", { value: f.id, children: f.name }, f.id))
|
|
3589
4406
|
}
|
|
3590
4407
|
),
|
|
3591
|
-
/* @__PURE__ */
|
|
4408
|
+
/* @__PURE__ */ jsxs13(
|
|
3592
4409
|
"select",
|
|
3593
4410
|
{
|
|
3594
4411
|
className: "univer-bases-select",
|
|
@@ -3600,22 +4417,22 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3600
4417
|
patchView({ sorts: next });
|
|
3601
4418
|
},
|
|
3602
4419
|
children: [
|
|
3603
|
-
/* @__PURE__ */
|
|
3604
|
-
/* @__PURE__ */
|
|
4420
|
+
/* @__PURE__ */ jsx13("option", { value: "asc", children: "\u5347\u5E8F (A \u2192 Z / 0 \u2192 9)" }),
|
|
4421
|
+
/* @__PURE__ */ jsx13("option", { value: "desc", children: "\u964D\u5E8F (Z \u2192 A / 9 \u2192 0)" })
|
|
3605
4422
|
]
|
|
3606
4423
|
}
|
|
3607
4424
|
),
|
|
3608
|
-
/* @__PURE__ */
|
|
4425
|
+
/* @__PURE__ */ jsx13(
|
|
3609
4426
|
"button",
|
|
3610
4427
|
{
|
|
3611
4428
|
type: "button",
|
|
3612
4429
|
className: "univer-bases-icon-btn",
|
|
3613
4430
|
onClick: () => patchView({ sorts: sorts.filter((s) => s.id !== sr.id) }),
|
|
3614
|
-
children: /* @__PURE__ */
|
|
4431
|
+
children: /* @__PURE__ */ jsx13(BaseTrashIcon, {})
|
|
3615
4432
|
}
|
|
3616
4433
|
)
|
|
3617
4434
|
] }, sr.id)) }),
|
|
3618
|
-
/* @__PURE__ */
|
|
4435
|
+
/* @__PURE__ */ jsx13("div", { className: "univer-bases-popover__footer", children: /* @__PURE__ */ jsxs13(
|
|
3619
4436
|
"button",
|
|
3620
4437
|
{
|
|
3621
4438
|
type: "button",
|
|
@@ -3627,7 +4444,7 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3627
4444
|
sorts: [
|
|
3628
4445
|
...sorts,
|
|
3629
4446
|
{
|
|
3630
|
-
id: `srt_${
|
|
4447
|
+
id: `srt_${generateRandomId4(5)}`,
|
|
3631
4448
|
fieldId: firstField.id,
|
|
3632
4449
|
direction: "asc"
|
|
3633
4450
|
}
|
|
@@ -3635,15 +4452,15 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3635
4452
|
});
|
|
3636
4453
|
},
|
|
3637
4454
|
children: [
|
|
3638
|
-
/* @__PURE__ */
|
|
3639
|
-
/* @__PURE__ */
|
|
4455
|
+
/* @__PURE__ */ jsx13(BasePlusIcon, {}),
|
|
4456
|
+
/* @__PURE__ */ jsx13("span", { children: "\u6DFB\u52A0\u6392\u5E8F\u5B57\u6BB5" })
|
|
3640
4457
|
]
|
|
3641
4458
|
}
|
|
3642
4459
|
) })
|
|
3643
4460
|
] })
|
|
3644
4461
|
] }),
|
|
3645
|
-
/* @__PURE__ */
|
|
3646
|
-
/* @__PURE__ */
|
|
4462
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover-anchor", children: [
|
|
4463
|
+
/* @__PURE__ */ jsxs13(
|
|
3647
4464
|
"button",
|
|
3648
4465
|
{
|
|
3649
4466
|
type: "button",
|
|
@@ -3651,29 +4468,29 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3651
4468
|
"data-testid": "bases-group-btn",
|
|
3652
4469
|
onClick: () => togglePopover("group"),
|
|
3653
4470
|
children: [
|
|
3654
|
-
/* @__PURE__ */
|
|
3655
|
-
/* @__PURE__ */
|
|
4471
|
+
/* @__PURE__ */ jsx13(BaseGroupIcon, {}),
|
|
4472
|
+
/* @__PURE__ */ jsxs13("span", { children: [
|
|
3656
4473
|
"\u5206\u7EC4",
|
|
3657
4474
|
groups.length > 0 ? ` (${groups.length})` : ""
|
|
3658
4475
|
] })
|
|
3659
4476
|
]
|
|
3660
4477
|
}
|
|
3661
4478
|
),
|
|
3662
|
-
openPopover === "group" && /* @__PURE__ */
|
|
3663
|
-
/* @__PURE__ */
|
|
3664
|
-
/* @__PURE__ */
|
|
3665
|
-
/* @__PURE__ */
|
|
4479
|
+
openPopover === "group" && /* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover", "data-testid": "bases-group-popover", children: [
|
|
4480
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover__header", children: [
|
|
4481
|
+
/* @__PURE__ */ jsx13("strong", { children: "\u5C42\u7EA7\u5206\u7EC4\u8BBE\u7F6E" }),
|
|
4482
|
+
/* @__PURE__ */ jsx13(
|
|
3666
4483
|
"button",
|
|
3667
4484
|
{
|
|
3668
4485
|
type: "button",
|
|
3669
4486
|
className: "univer-bases-icon-btn",
|
|
3670
4487
|
onClick: () => setOpenPopover(null),
|
|
3671
|
-
children: /* @__PURE__ */
|
|
4488
|
+
children: /* @__PURE__ */ jsx13(BaseCloseIcon, {})
|
|
3672
4489
|
}
|
|
3673
4490
|
)
|
|
3674
4491
|
] }),
|
|
3675
|
-
groups.length === 0 ? /* @__PURE__ */
|
|
3676
|
-
/* @__PURE__ */
|
|
4492
|
+
groups.length === 0 ? /* @__PURE__ */ jsx13("div", { className: "univer-bases-empty-hint", children: "\u672A\u542F\u7528\u5206\u7EC4\uFF0C\u652F\u6301\u591A\u7EA7\u5B57\u6BB5\u5D4C\u5957\u5206\u7EC4" }) : /* @__PURE__ */ jsx13("div", { className: "univer-bases-rule-list", children: groups.map((gr, idx) => /* @__PURE__ */ jsxs13("div", { className: "univer-bases-rule-row", children: [
|
|
4493
|
+
/* @__PURE__ */ jsx13(
|
|
3677
4494
|
"select",
|
|
3678
4495
|
{
|
|
3679
4496
|
className: "univer-bases-select",
|
|
@@ -3684,20 +4501,20 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3684
4501
|
);
|
|
3685
4502
|
patchView({ groups: next });
|
|
3686
4503
|
},
|
|
3687
|
-
children: fields.map((f) => /* @__PURE__ */
|
|
4504
|
+
children: fields.map((f) => /* @__PURE__ */ jsx13("option", { value: f.id, children: f.name }, f.id))
|
|
3688
4505
|
}
|
|
3689
4506
|
),
|
|
3690
|
-
/* @__PURE__ */
|
|
4507
|
+
/* @__PURE__ */ jsx13(
|
|
3691
4508
|
"button",
|
|
3692
4509
|
{
|
|
3693
4510
|
type: "button",
|
|
3694
4511
|
className: "univer-bases-icon-btn",
|
|
3695
4512
|
onClick: () => patchView({ groups: groups.filter((_, i) => i !== idx) }),
|
|
3696
|
-
children: /* @__PURE__ */
|
|
4513
|
+
children: /* @__PURE__ */ jsx13(BaseTrashIcon, {})
|
|
3697
4514
|
}
|
|
3698
4515
|
)
|
|
3699
4516
|
] }, `${gr.fieldId}-${idx}`)) }),
|
|
3700
|
-
/* @__PURE__ */
|
|
4517
|
+
/* @__PURE__ */ jsx13("div", { className: "univer-bases-popover__footer", children: /* @__PURE__ */ jsxs13(
|
|
3701
4518
|
"button",
|
|
3702
4519
|
{
|
|
3703
4520
|
type: "button",
|
|
@@ -3713,15 +4530,15 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3713
4530
|
});
|
|
3714
4531
|
},
|
|
3715
4532
|
children: [
|
|
3716
|
-
/* @__PURE__ */
|
|
3717
|
-
/* @__PURE__ */
|
|
4533
|
+
/* @__PURE__ */ jsx13(BasePlusIcon, {}),
|
|
4534
|
+
/* @__PURE__ */ jsx13("span", { children: "\u6DFB\u52A0\u5206\u7EC4\u5C42\u7EA7" })
|
|
3718
4535
|
]
|
|
3719
4536
|
}
|
|
3720
4537
|
) })
|
|
3721
4538
|
] })
|
|
3722
4539
|
] }),
|
|
3723
|
-
/* @__PURE__ */
|
|
3724
|
-
/* @__PURE__ */
|
|
4540
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover-anchor", children: [
|
|
4541
|
+
/* @__PURE__ */ jsxs13(
|
|
3725
4542
|
"button",
|
|
3726
4543
|
{
|
|
3727
4544
|
type: "button",
|
|
@@ -3729,29 +4546,29 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3729
4546
|
"data-testid": "bases-color-btn",
|
|
3730
4547
|
onClick: () => togglePopover("color"),
|
|
3731
4548
|
children: [
|
|
3732
|
-
/* @__PURE__ */
|
|
3733
|
-
/* @__PURE__ */
|
|
4549
|
+
/* @__PURE__ */ jsx13(BaseColorIcon, {}),
|
|
4550
|
+
/* @__PURE__ */ jsxs13("span", { children: [
|
|
3734
4551
|
"\u6761\u4EF6\u7740\u8272",
|
|
3735
4552
|
colorRules.length > 0 ? ` (${colorRules.length})` : ""
|
|
3736
4553
|
] })
|
|
3737
4554
|
]
|
|
3738
4555
|
}
|
|
3739
4556
|
),
|
|
3740
|
-
openPopover === "color" && /* @__PURE__ */
|
|
3741
|
-
/* @__PURE__ */
|
|
3742
|
-
/* @__PURE__ */
|
|
3743
|
-
/* @__PURE__ */
|
|
4557
|
+
openPopover === "color" && /* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover univer-bases-popover--wide", "data-testid": "bases-color-popover", children: [
|
|
4558
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-popover__header", children: [
|
|
4559
|
+
/* @__PURE__ */ jsx13("strong", { children: "\u6761\u4EF6\u884C\u7740\u8272\u89C4\u5219" }),
|
|
4560
|
+
/* @__PURE__ */ jsx13(
|
|
3744
4561
|
"button",
|
|
3745
4562
|
{
|
|
3746
4563
|
type: "button",
|
|
3747
4564
|
className: "univer-bases-icon-btn",
|
|
3748
4565
|
onClick: () => setOpenPopover(null),
|
|
3749
|
-
children: /* @__PURE__ */
|
|
4566
|
+
children: /* @__PURE__ */ jsx13(BaseCloseIcon, {})
|
|
3750
4567
|
}
|
|
3751
4568
|
)
|
|
3752
4569
|
] }),
|
|
3753
|
-
colorRules.length === 0 ? /* @__PURE__ */
|
|
3754
|
-
/* @__PURE__ */
|
|
4570
|
+
colorRules.length === 0 ? /* @__PURE__ */ jsx13("div", { className: "univer-bases-empty-hint", children: "\u6309\u5B57\u6BB5\u6761\u4EF6\u81EA\u52A8\u9AD8\u4EAE\u6574\u884C\u80CC\u666F\u8272" }) : /* @__PURE__ */ jsx13("div", { className: "univer-bases-rule-list", children: colorRules.map((cr) => /* @__PURE__ */ jsxs13("div", { className: "univer-bases-rule-row", children: [
|
|
4571
|
+
/* @__PURE__ */ jsx13(
|
|
3755
4572
|
"select",
|
|
3756
4573
|
{
|
|
3757
4574
|
className: "univer-bases-select univer-bases-select--xs",
|
|
@@ -3763,10 +4580,10 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3763
4580
|
);
|
|
3764
4581
|
patchView({ colorRules: next });
|
|
3765
4582
|
},
|
|
3766
|
-
children: BASE_ROW_COLOR_PALETTE.map((sw) => /* @__PURE__ */
|
|
4583
|
+
children: BASE_ROW_COLOR_PALETTE.map((sw) => /* @__PURE__ */ jsx13("option", { value: sw.color, children: sw.label }, sw.color))
|
|
3767
4584
|
}
|
|
3768
4585
|
),
|
|
3769
|
-
/* @__PURE__ */
|
|
4586
|
+
/* @__PURE__ */ jsx13(
|
|
3770
4587
|
"select",
|
|
3771
4588
|
{
|
|
3772
4589
|
className: "univer-bases-select",
|
|
@@ -3777,10 +4594,10 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3777
4594
|
);
|
|
3778
4595
|
patchView({ colorRules: next });
|
|
3779
4596
|
},
|
|
3780
|
-
children: fields.map((f) => /* @__PURE__ */
|
|
4597
|
+
children: fields.map((f) => /* @__PURE__ */ jsx13("option", { value: f.id, children: f.name }, f.id))
|
|
3781
4598
|
}
|
|
3782
4599
|
),
|
|
3783
|
-
/* @__PURE__ */
|
|
4600
|
+
/* @__PURE__ */ jsx13(
|
|
3784
4601
|
"select",
|
|
3785
4602
|
{
|
|
3786
4603
|
className: "univer-bases-select univer-bases-select--xs",
|
|
@@ -3791,10 +4608,10 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3791
4608
|
);
|
|
3792
4609
|
patchView({ colorRules: next });
|
|
3793
4610
|
},
|
|
3794
|
-
children: FILTER_OPERATOR_OPTIONS.map((op) => /* @__PURE__ */
|
|
4611
|
+
children: FILTER_OPERATOR_OPTIONS.map((op) => /* @__PURE__ */ jsx13("option", { value: op.value, children: op.label }, op.value))
|
|
3795
4612
|
}
|
|
3796
4613
|
),
|
|
3797
|
-
/* @__PURE__ */
|
|
4614
|
+
/* @__PURE__ */ jsx13(
|
|
3798
4615
|
"input",
|
|
3799
4616
|
{
|
|
3800
4617
|
type: "text",
|
|
@@ -3809,17 +4626,17 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3809
4626
|
}
|
|
3810
4627
|
}
|
|
3811
4628
|
),
|
|
3812
|
-
/* @__PURE__ */
|
|
4629
|
+
/* @__PURE__ */ jsx13(
|
|
3813
4630
|
"button",
|
|
3814
4631
|
{
|
|
3815
4632
|
type: "button",
|
|
3816
4633
|
className: "univer-bases-icon-btn",
|
|
3817
4634
|
onClick: () => patchView({ colorRules: colorRules.filter((c) => c.id !== cr.id) }),
|
|
3818
|
-
children: /* @__PURE__ */
|
|
4635
|
+
children: /* @__PURE__ */ jsx13(BaseTrashIcon, {})
|
|
3819
4636
|
}
|
|
3820
4637
|
)
|
|
3821
4638
|
] }, cr.id)) }),
|
|
3822
|
-
/* @__PURE__ */
|
|
4639
|
+
/* @__PURE__ */ jsx13("div", { className: "univer-bases-popover__footer", children: /* @__PURE__ */ jsxs13(
|
|
3823
4640
|
"button",
|
|
3824
4641
|
{
|
|
3825
4642
|
type: "button",
|
|
@@ -3831,7 +4648,7 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3831
4648
|
colorRules: [
|
|
3832
4649
|
...colorRules,
|
|
3833
4650
|
{
|
|
3834
|
-
id: `clr_${
|
|
4651
|
+
id: `clr_${generateRandomId4(5)}`,
|
|
3835
4652
|
fieldId: firstField.id,
|
|
3836
4653
|
operator: "contains",
|
|
3837
4654
|
value: "",
|
|
@@ -3841,18 +4658,18 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3841
4658
|
});
|
|
3842
4659
|
},
|
|
3843
4660
|
children: [
|
|
3844
|
-
/* @__PURE__ */
|
|
3845
|
-
/* @__PURE__ */
|
|
4661
|
+
/* @__PURE__ */ jsx13(BasePlusIcon, {}),
|
|
4662
|
+
/* @__PURE__ */ jsx13("span", { children: "\u6DFB\u52A0\u7740\u8272\u6761\u4EF6" })
|
|
3846
4663
|
]
|
|
3847
4664
|
}
|
|
3848
4665
|
) })
|
|
3849
4666
|
] })
|
|
3850
4667
|
] })
|
|
3851
4668
|
] }),
|
|
3852
|
-
/* @__PURE__ */
|
|
3853
|
-
/* @__PURE__ */
|
|
3854
|
-
/* @__PURE__ */
|
|
3855
|
-
/* @__PURE__ */
|
|
4669
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-toolbar__right", children: [
|
|
4670
|
+
/* @__PURE__ */ jsxs13("div", { className: "univer-bases-search-box", children: [
|
|
4671
|
+
/* @__PURE__ */ jsx13(BaseSearchIcon, {}),
|
|
4672
|
+
/* @__PURE__ */ jsx13(
|
|
3856
4673
|
"input",
|
|
3857
4674
|
{
|
|
3858
4675
|
type: "text",
|
|
@@ -3862,17 +4679,17 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3862
4679
|
onChange: (e) => selectionService.setSearchQuery(e.target.value)
|
|
3863
4680
|
}
|
|
3864
4681
|
),
|
|
3865
|
-
selectionState.searchQuery && /* @__PURE__ */
|
|
4682
|
+
selectionState.searchQuery && /* @__PURE__ */ jsx13(
|
|
3866
4683
|
"button",
|
|
3867
4684
|
{
|
|
3868
4685
|
type: "button",
|
|
3869
4686
|
className: "univer-bases-icon-btn",
|
|
3870
4687
|
onClick: () => selectionService.setSearchQuery(""),
|
|
3871
|
-
children: /* @__PURE__ */
|
|
4688
|
+
children: /* @__PURE__ */ jsx13(BaseCloseIcon, {})
|
|
3872
4689
|
}
|
|
3873
4690
|
)
|
|
3874
4691
|
] }),
|
|
3875
|
-
/* @__PURE__ */
|
|
4692
|
+
/* @__PURE__ */ jsxs13(
|
|
3876
4693
|
"button",
|
|
3877
4694
|
{
|
|
3878
4695
|
type: "button",
|
|
@@ -3880,12 +4697,12 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3880
4697
|
"data-testid": "bases-import-btn",
|
|
3881
4698
|
onClick: () => selectionService.openModal("import"),
|
|
3882
4699
|
children: [
|
|
3883
|
-
/* @__PURE__ */
|
|
3884
|
-
/* @__PURE__ */
|
|
4700
|
+
/* @__PURE__ */ jsx13(BaseUploadIcon, {}),
|
|
4701
|
+
/* @__PURE__ */ jsx13("span", { children: "\u5BFC\u5165" })
|
|
3885
4702
|
]
|
|
3886
4703
|
}
|
|
3887
4704
|
),
|
|
3888
|
-
/* @__PURE__ */
|
|
4705
|
+
/* @__PURE__ */ jsxs13(
|
|
3889
4706
|
"button",
|
|
3890
4707
|
{
|
|
3891
4708
|
type: "button",
|
|
@@ -3893,8 +4710,8 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3893
4710
|
"data-testid": "bases-export-btn",
|
|
3894
4711
|
onClick: () => selectionService.openModal("export"),
|
|
3895
4712
|
children: [
|
|
3896
|
-
/* @__PURE__ */
|
|
3897
|
-
/* @__PURE__ */
|
|
4713
|
+
/* @__PURE__ */ jsx13(BaseDownloadIcon, {}),
|
|
4714
|
+
/* @__PURE__ */ jsx13("span", { children: "\u5BFC\u51FA" })
|
|
3898
4715
|
]
|
|
3899
4716
|
}
|
|
3900
4717
|
)
|
|
@@ -3904,11 +4721,11 @@ var BasesViewToolbar = ({ table, activeView, workspaceMode }) => {
|
|
|
3904
4721
|
};
|
|
3905
4722
|
|
|
3906
4723
|
// src/views/BasesMainView.tsx
|
|
3907
|
-
import { jsx as
|
|
4724
|
+
import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3908
4725
|
var BasesMainView = () => {
|
|
3909
4726
|
const { unit, snapshot, selectionState, selectionService } = useActiveBaseWorkspace();
|
|
3910
4727
|
if (!unit || !snapshot) {
|
|
3911
|
-
return /* @__PURE__ */
|
|
4728
|
+
return /* @__PURE__ */ jsx14("div", { className: "univer-bases-empty-workspace", "data-testid": "bases-empty-workspace", children: "\u672A\u6302\u8F7D\u591A\u7EF4\u6570\u636E\u8868\u5355\u5143 (UNIVER_BASE)" });
|
|
3912
4729
|
}
|
|
3913
4730
|
const activeTable = unit.getActiveTable();
|
|
3914
4731
|
const activeView = unit.getActiveView();
|
|
@@ -3921,28 +4738,30 @@ var BasesMainView = () => {
|
|
|
3921
4738
|
});
|
|
3922
4739
|
const renderActiveContent = () => {
|
|
3923
4740
|
if (workspaceMode === "dashboard") {
|
|
3924
|
-
return /* @__PURE__ */
|
|
4741
|
+
return /* @__PURE__ */ jsx14(DashboardView, {});
|
|
3925
4742
|
}
|
|
3926
4743
|
switch (activeView.type) {
|
|
4744
|
+
case "list":
|
|
4745
|
+
return /* @__PURE__ */ jsx14(ListView, { query });
|
|
3927
4746
|
case "kanban":
|
|
3928
|
-
return /* @__PURE__ */
|
|
4747
|
+
return /* @__PURE__ */ jsx14(KanbanView, { query });
|
|
3929
4748
|
case "calendar":
|
|
3930
|
-
return /* @__PURE__ */
|
|
4749
|
+
return /* @__PURE__ */ jsx14(CalendarView, { query });
|
|
3931
4750
|
case "gallery":
|
|
3932
|
-
return /* @__PURE__ */
|
|
4751
|
+
return /* @__PURE__ */ jsx14(GalleryView, { query });
|
|
3933
4752
|
case "gantt":
|
|
3934
|
-
return /* @__PURE__ */
|
|
4753
|
+
return /* @__PURE__ */ jsx14(GanttTimelineView, { query, mode: "gantt" });
|
|
3935
4754
|
case "timeline":
|
|
3936
|
-
return /* @__PURE__ */
|
|
4755
|
+
return /* @__PURE__ */ jsx14(GanttTimelineView, { query, mode: "timeline" });
|
|
3937
4756
|
case "form":
|
|
3938
|
-
return /* @__PURE__ */
|
|
4757
|
+
return /* @__PURE__ */ jsx14(FormView, { query });
|
|
3939
4758
|
case "grid":
|
|
3940
4759
|
default:
|
|
3941
|
-
return /* @__PURE__ */
|
|
4760
|
+
return /* @__PURE__ */ jsx14(GridView, { query });
|
|
3942
4761
|
}
|
|
3943
4762
|
};
|
|
3944
|
-
return /* @__PURE__ */
|
|
3945
|
-
/* @__PURE__ */
|
|
4763
|
+
return /* @__PURE__ */ jsxs14("div", { className: "univer-bases-main", "data-testid": "bases-main-view", children: [
|
|
4764
|
+
/* @__PURE__ */ jsx14(
|
|
3946
4765
|
BasesViewToolbar,
|
|
3947
4766
|
{
|
|
3948
4767
|
table: activeTable,
|
|
@@ -3950,26 +4769,26 @@ var BasesMainView = () => {
|
|
|
3950
4769
|
workspaceMode
|
|
3951
4770
|
}
|
|
3952
4771
|
),
|
|
3953
|
-
selectionState.lastToastMessage && /* @__PURE__ */
|
|
3954
|
-
/* @__PURE__ */
|
|
3955
|
-
/* @__PURE__ */
|
|
4772
|
+
selectionState.lastToastMessage && /* @__PURE__ */ jsxs14("div", { className: "univer-bases-toast", role: "status", children: [
|
|
4773
|
+
/* @__PURE__ */ jsx14("span", { children: selectionState.lastToastMessage }),
|
|
4774
|
+
/* @__PURE__ */ jsx14(
|
|
3956
4775
|
"button",
|
|
3957
4776
|
{
|
|
3958
4777
|
type: "button",
|
|
3959
4778
|
className: "univer-bases-icon-btn",
|
|
3960
4779
|
onClick: () => selectionService.notifyToast(null),
|
|
3961
|
-
children: /* @__PURE__ */
|
|
4780
|
+
children: /* @__PURE__ */ jsx14(BaseCloseIcon, {})
|
|
3962
4781
|
}
|
|
3963
4782
|
)
|
|
3964
4783
|
] }),
|
|
3965
|
-
/* @__PURE__ */
|
|
3966
|
-
/* @__PURE__ */
|
|
4784
|
+
/* @__PURE__ */ jsx14("div", { className: "univer-bases-main__viewport", children: renderActiveContent() }),
|
|
4785
|
+
/* @__PURE__ */ jsx14(RecordDetailDrawer, {})
|
|
3967
4786
|
] });
|
|
3968
4787
|
};
|
|
3969
4788
|
|
|
3970
4789
|
// src/views/footer/BasesStatusBar.tsx
|
|
3971
4790
|
import { queryBaseTableView as queryBaseTableView2 } from "@yudaocode/univer-bases";
|
|
3972
|
-
import { jsx as
|
|
4791
|
+
import { jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3973
4792
|
var BasesStatusBar = () => {
|
|
3974
4793
|
const { unit, snapshot, selectionState } = useActiveBaseWorkspace();
|
|
3975
4794
|
if (!unit || !snapshot) return null;
|
|
@@ -3980,39 +4799,39 @@ var BasesStatusBar = () => {
|
|
|
3980
4799
|
const query = queryBaseTableView2(snapshot, activeTable.id, activeView.id, {
|
|
3981
4800
|
searchQuery: selectionState.searchQuery || activeView.searchQuery
|
|
3982
4801
|
});
|
|
3983
|
-
return /* @__PURE__ */
|
|
3984
|
-
/* @__PURE__ */
|
|
3985
|
-
/* @__PURE__ */
|
|
3986
|
-
/* @__PURE__ */
|
|
3987
|
-
/* @__PURE__ */
|
|
4802
|
+
return /* @__PURE__ */ jsxs15("footer", { className: "univer-bases-statusbar", "data-testid": "bases-status-bar", children: [
|
|
4803
|
+
/* @__PURE__ */ jsxs15("div", { className: "univer-bases-statusbar__left", children: [
|
|
4804
|
+
/* @__PURE__ */ jsxs15("span", { className: "univer-bases-statusbar__chip", children: [
|
|
4805
|
+
/* @__PURE__ */ jsx15(BaseTableIcon, {}),
|
|
4806
|
+
/* @__PURE__ */ jsx15("strong", { children: activeTable.name })
|
|
3988
4807
|
] }),
|
|
3989
|
-
/* @__PURE__ */
|
|
3990
|
-
/* @__PURE__ */
|
|
4808
|
+
/* @__PURE__ */ jsxs15("span", { className: "univer-bases-statusbar__chip", children: [
|
|
4809
|
+
/* @__PURE__ */ jsx15(
|
|
3991
4810
|
BaseViewTypeIcon,
|
|
3992
4811
|
{
|
|
3993
4812
|
type: workspaceMode === "dashboard" ? "dashboard" : activeView.type
|
|
3994
4813
|
}
|
|
3995
4814
|
),
|
|
3996
|
-
/* @__PURE__ */
|
|
4815
|
+
/* @__PURE__ */ jsx15("span", { children: workspaceMode === "dashboard" ? "\u6570\u636E\u4EEA\u8868\u76D8" : activeView.name })
|
|
3997
4816
|
] }),
|
|
3998
|
-
/* @__PURE__ */
|
|
4817
|
+
/* @__PURE__ */ jsxs15("span", { className: "univer-bases-statusbar__meta", children: [
|
|
3999
4818
|
"\u663E\u793A ",
|
|
4000
4819
|
query.filteredRecordCount,
|
|
4001
4820
|
" / \u5171 ",
|
|
4002
4821
|
query.totalRecordCount,
|
|
4003
4822
|
" \u6761\u8BB0\u5F55"
|
|
4004
4823
|
] }),
|
|
4005
|
-
/* @__PURE__ */
|
|
4824
|
+
/* @__PURE__ */ jsxs15("span", { className: "univer-bases-statusbar__meta", children: [
|
|
4006
4825
|
query.visibleFields.length,
|
|
4007
4826
|
" \u4E2A\u53EF\u89C1\u5B57\u6BB5"
|
|
4008
4827
|
] }),
|
|
4009
|
-
selectionState.selectedRecordIds.length > 0 && /* @__PURE__ */
|
|
4828
|
+
selectionState.selectedRecordIds.length > 0 && /* @__PURE__ */ jsxs15("span", { className: "univer-bases-statusbar__selected", children: [
|
|
4010
4829
|
"\u5DF2\u9009\u4E2D ",
|
|
4011
4830
|
selectionState.selectedRecordIds.length,
|
|
4012
4831
|
" \u6761"
|
|
4013
4832
|
] })
|
|
4014
4833
|
] }),
|
|
4015
|
-
/* @__PURE__ */
|
|
4834
|
+
/* @__PURE__ */ jsx15("div", { className: "univer-bases-statusbar__right", children: /* @__PURE__ */ jsxs15("span", { className: "univer-bases-statusbar__meta", children: [
|
|
4016
4835
|
"\u5171 ",
|
|
4017
4836
|
snapshot.tableOrder.length,
|
|
4018
4837
|
" \u5F20\u5173\u8054\u6570\u636E\u8868 \xB7 \u7248\u672C r",
|
|
@@ -4022,21 +4841,29 @@ var BasesStatusBar = () => {
|
|
|
4022
4841
|
};
|
|
4023
4842
|
|
|
4024
4843
|
// src/views/inspector/BasesInspectorPanel.tsx
|
|
4025
|
-
import {
|
|
4026
|
-
|
|
4844
|
+
import {
|
|
4845
|
+
DeleteBaseAutomationRuleCommand,
|
|
4846
|
+
normalizeAutomationSteps,
|
|
4847
|
+
ToggleBaseAutomationRuleCommand,
|
|
4848
|
+
TriggerBaseAutomationCommand,
|
|
4849
|
+
UpdateBaseTableCommand
|
|
4850
|
+
} from "@yudaocode/univer-bases";
|
|
4851
|
+
import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4027
4852
|
var BasesInspectorPanel = () => {
|
|
4028
|
-
const { unit, snapshot, commandService } = useActiveBaseWorkspace();
|
|
4853
|
+
const { unit, snapshot, commandService, selectionService } = useActiveBaseWorkspace();
|
|
4029
4854
|
if (!unit || !snapshot) return null;
|
|
4030
4855
|
const activeTable = unit.getActiveTable();
|
|
4031
4856
|
if (!activeTable) return null;
|
|
4032
4857
|
const unitId = unit.getUnitId();
|
|
4033
4858
|
const fields = activeTable.fieldOrder.map((fid) => activeTable.fields[fid]).filter((f) => Boolean(f));
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4859
|
+
const rules = snapshot.automations ?? [];
|
|
4860
|
+
const recentLogs = [...snapshot.automationLogs ?? []].reverse().slice(0, 8);
|
|
4861
|
+
return /* @__PURE__ */ jsxs16("div", { className: "univer-bases-inspector", "data-testid": "bases-inspector-panel", children: [
|
|
4862
|
+
/* @__PURE__ */ jsxs16("section", { className: "univer-bases-inspector__section", children: [
|
|
4863
|
+
/* @__PURE__ */ jsx16("h4", { children: "\u5F53\u524D\u6570\u636E\u8868\u5C5E\u6027" }),
|
|
4864
|
+
/* @__PURE__ */ jsxs16("div", { className: "univer-bases-form-row", children: [
|
|
4865
|
+
/* @__PURE__ */ jsx16("label", { children: "\u6570\u636E\u8868\u540D\u79F0" }),
|
|
4866
|
+
/* @__PURE__ */ jsx16(
|
|
4040
4867
|
"input",
|
|
4041
4868
|
{
|
|
4042
4869
|
type: "text",
|
|
@@ -4052,9 +4879,9 @@ var BasesInspectorPanel = () => {
|
|
|
4052
4879
|
}
|
|
4053
4880
|
)
|
|
4054
4881
|
] }),
|
|
4055
|
-
/* @__PURE__ */
|
|
4056
|
-
/* @__PURE__ */
|
|
4057
|
-
/* @__PURE__ */
|
|
4882
|
+
/* @__PURE__ */ jsxs16("div", { className: "univer-bases-form-row", children: [
|
|
4883
|
+
/* @__PURE__ */ jsx16("label", { children: "\u4E1A\u52A1\u63CF\u8FF0" }),
|
|
4884
|
+
/* @__PURE__ */ jsx16(
|
|
4058
4885
|
"textarea",
|
|
4059
4886
|
{
|
|
4060
4887
|
className: "univer-bases-textarea",
|
|
@@ -4071,88 +4898,239 @@ var BasesInspectorPanel = () => {
|
|
|
4071
4898
|
)
|
|
4072
4899
|
] })
|
|
4073
4900
|
] }),
|
|
4074
|
-
/* @__PURE__ */
|
|
4075
|
-
/* @__PURE__ */
|
|
4901
|
+
/* @__PURE__ */ jsxs16("section", { className: "univer-bases-inspector__section", children: [
|
|
4902
|
+
/* @__PURE__ */ jsxs16("h4", { children: [
|
|
4076
4903
|
"\u5B57\u6BB5\u6A21\u578B\u6E05\u5355 (",
|
|
4077
4904
|
fields.length,
|
|
4078
4905
|
")"
|
|
4079
4906
|
] }),
|
|
4080
|
-
/* @__PURE__ */
|
|
4081
|
-
/* @__PURE__ */
|
|
4082
|
-
/* @__PURE__ */
|
|
4083
|
-
/* @__PURE__ */
|
|
4907
|
+
/* @__PURE__ */ jsx16("div", { className: "univer-bases-inspector__field-list", children: fields.map((f) => /* @__PURE__ */ jsxs16("div", { className: "univer-bases-inspector__field-item", children: [
|
|
4908
|
+
/* @__PURE__ */ jsxs16("div", { className: "univer-bases-inline-flex", children: [
|
|
4909
|
+
/* @__PURE__ */ jsx16(BaseFieldTypeIcon, { type: f.type }),
|
|
4910
|
+
/* @__PURE__ */ jsx16("span", { children: f.name })
|
|
4084
4911
|
] }),
|
|
4085
|
-
/* @__PURE__ */
|
|
4912
|
+
/* @__PURE__ */ jsx16("span", { className: "univer-bases-pill univer-bases-pill--neutral", children: f.type })
|
|
4086
4913
|
] }, f.id)) })
|
|
4087
4914
|
] }),
|
|
4088
|
-
/* @__PURE__ */
|
|
4089
|
-
/* @__PURE__ */
|
|
4090
|
-
"
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
if (!unit || !snapshot) return null;
|
|
4121
|
-
const unitId = unit.getUnitId();
|
|
4122
|
-
const workspaceMode = snapshot.workspaceMode ?? "table";
|
|
4123
|
-
return /* @__PURE__ */ jsxs16("aside", { className: "univer-bases-left-sidebar", "data-testid": "bases-left-sidebar", children: [
|
|
4124
|
-
/* @__PURE__ */ jsxs16("div", { className: "univer-bases-sidebar-section", children: [
|
|
4125
|
-
/* @__PURE__ */ jsxs16("div", { className: "univer-bases-sidebar-section__header", children: [
|
|
4126
|
-
/* @__PURE__ */ jsx16("span", { children: "\u6570\u636E\u8868\u76EE\u5F55" }),
|
|
4127
|
-
/* @__PURE__ */ jsx16(
|
|
4128
|
-
"button",
|
|
4129
|
-
{
|
|
4130
|
-
type: "button",
|
|
4131
|
-
className: "univer-bases-icon-btn",
|
|
4132
|
-
title: "\u65B0\u5EFA\u6570\u636E\u8868",
|
|
4133
|
-
"data-testid": "bases-sidebar-add-table",
|
|
4134
|
-
onClick: () => setCreatingTable((v) => !v),
|
|
4135
|
-
children: /* @__PURE__ */ jsx16(BasePlusIcon, {})
|
|
4136
|
-
}
|
|
4137
|
-
)
|
|
4138
|
-
] }),
|
|
4139
|
-
creatingTable && /* @__PURE__ */ jsxs16("div", { className: "univer-bases-sidebar-create-box", children: [
|
|
4140
|
-
/* @__PURE__ */ jsx16(
|
|
4141
|
-
"input",
|
|
4142
|
-
{
|
|
4143
|
-
type: "text",
|
|
4144
|
-
className: "univer-bases-input",
|
|
4145
|
-
placeholder: "\u8F93\u5165\u65B0\u6570\u636E\u8868\u540D\u79F0...",
|
|
4146
|
-
value: newTableName,
|
|
4147
|
-
onChange: (e) => setNewTableName(e.target.value)
|
|
4148
|
-
}
|
|
4149
|
-
),
|
|
4150
|
-
/* @__PURE__ */ jsx16(
|
|
4151
|
-
"button",
|
|
4915
|
+
/* @__PURE__ */ jsxs16("section", { className: "univer-bases-inspector__section", children: [
|
|
4916
|
+
/* @__PURE__ */ jsxs16(
|
|
4917
|
+
"div",
|
|
4918
|
+
{
|
|
4919
|
+
className: "univer-bases-inline-flex",
|
|
4920
|
+
style: { justifyContent: "space-between", width: "100%", marginBottom: 8 },
|
|
4921
|
+
children: [
|
|
4922
|
+
/* @__PURE__ */ jsxs16("h4", { style: { margin: 0 }, children: [
|
|
4923
|
+
"\u81EA\u52A8\u5316\u89E6\u53D1\u89C4\u5219 (",
|
|
4924
|
+
rules.length,
|
|
4925
|
+
")"
|
|
4926
|
+
] }),
|
|
4927
|
+
/* @__PURE__ */ jsxs16(
|
|
4928
|
+
"button",
|
|
4929
|
+
{
|
|
4930
|
+
type: "button",
|
|
4931
|
+
className: "univer-bases-btn univer-bases-btn--primary univer-bases-btn--sm",
|
|
4932
|
+
"data-testid": "bases-new-automation-btn",
|
|
4933
|
+
onClick: () => selectionService.openAutomationBuilder(null),
|
|
4934
|
+
children: [
|
|
4935
|
+
/* @__PURE__ */ jsx16(BasePlusIcon, {}),
|
|
4936
|
+
/* @__PURE__ */ jsx16("span", { children: "\u65B0\u5EFA\u81EA\u52A8\u5316\u6D41\u7A0B" })
|
|
4937
|
+
]
|
|
4938
|
+
}
|
|
4939
|
+
)
|
|
4940
|
+
]
|
|
4941
|
+
}
|
|
4942
|
+
),
|
|
4943
|
+
rules.length === 0 ? /* @__PURE__ */ jsx16("p", { className: "univer-bases-muted-key", children: "\u6682\u65E0\u81EA\u52A8\u5316\u89C4\u5219" }) : /* @__PURE__ */ jsx16("div", { className: "univer-bases-inspector__field-list", children: rules.map((rule) => {
|
|
4944
|
+
const stepCount = normalizeAutomationSteps(rule).length;
|
|
4945
|
+
return /* @__PURE__ */ jsxs16(
|
|
4946
|
+
"div",
|
|
4152
4947
|
{
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4948
|
+
className: "univer-bases-inspector__auto-card",
|
|
4949
|
+
"data-testid": `bases-inspector-auto-${rule.id}`,
|
|
4950
|
+
children: [
|
|
4951
|
+
/* @__PURE__ */ jsxs16(
|
|
4952
|
+
"div",
|
|
4953
|
+
{
|
|
4954
|
+
className: "univer-bases-inline-flex",
|
|
4955
|
+
style: { justifyContent: "space-between", width: "100%" },
|
|
4956
|
+
children: [
|
|
4957
|
+
/* @__PURE__ */ jsxs16("div", { className: "univer-bases-inline-flex", children: [
|
|
4958
|
+
/* @__PURE__ */ jsx16(BaseBoltIcon, {}),
|
|
4959
|
+
/* @__PURE__ */ jsx16("strong", { children: rule.name })
|
|
4960
|
+
] }),
|
|
4961
|
+
/* @__PURE__ */ jsxs16("label", { className: "univer-bases-checkbox-label", children: [
|
|
4962
|
+
/* @__PURE__ */ jsx16(
|
|
4963
|
+
"input",
|
|
4964
|
+
{
|
|
4965
|
+
type: "checkbox",
|
|
4966
|
+
checked: rule.enabled,
|
|
4967
|
+
onChange: (e) => {
|
|
4968
|
+
commandService.syncExecuteCommand(
|
|
4969
|
+
ToggleBaseAutomationRuleCommand.id,
|
|
4970
|
+
{
|
|
4971
|
+
unitId,
|
|
4972
|
+
ruleId: rule.id,
|
|
4973
|
+
enabled: e.target.checked
|
|
4974
|
+
}
|
|
4975
|
+
);
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
),
|
|
4979
|
+
/* @__PURE__ */ jsx16("span", { children: rule.enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528" })
|
|
4980
|
+
] })
|
|
4981
|
+
]
|
|
4982
|
+
}
|
|
4983
|
+
),
|
|
4984
|
+
/* @__PURE__ */ jsxs16("span", { className: "univer-bases-muted-key", children: [
|
|
4985
|
+
"\u89E6\u53D1\u5668: ",
|
|
4986
|
+
rule.trigger,
|
|
4987
|
+
" \u2192 \u5171 ",
|
|
4988
|
+
stepCount,
|
|
4989
|
+
" \u4E2A\u52A8\u4F5C\u6B65\u9AA4"
|
|
4990
|
+
] }),
|
|
4991
|
+
/* @__PURE__ */ jsxs16("div", { className: "univer-bases-inline-flex", style: { marginTop: 4 }, children: [
|
|
4992
|
+
/* @__PURE__ */ jsxs16(
|
|
4993
|
+
"button",
|
|
4994
|
+
{
|
|
4995
|
+
type: "button",
|
|
4996
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
4997
|
+
onClick: () => selectionService.openAutomationBuilder(rule.id),
|
|
4998
|
+
children: [
|
|
4999
|
+
/* @__PURE__ */ jsx16(BaseEditIcon, {}),
|
|
5000
|
+
/* @__PURE__ */ jsx16("span", { children: "\u7F16\u8F91" })
|
|
5001
|
+
]
|
|
5002
|
+
}
|
|
5003
|
+
),
|
|
5004
|
+
/* @__PURE__ */ jsxs16(
|
|
5005
|
+
"button",
|
|
5006
|
+
{
|
|
5007
|
+
type: "button",
|
|
5008
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
5009
|
+
onClick: () => {
|
|
5010
|
+
commandService.syncExecuteCommand(
|
|
5011
|
+
TriggerBaseAutomationCommand.id,
|
|
5012
|
+
{
|
|
5013
|
+
unitId,
|
|
5014
|
+
ruleId: rule.id,
|
|
5015
|
+
tableId: rule.tableId,
|
|
5016
|
+
onExecuted: (logs) => {
|
|
5017
|
+
const latest = logs[logs.length - 1];
|
|
5018
|
+
selectionService.notifyToast(
|
|
5019
|
+
latest ? `\u8BD5\u8FD0\u884C [${rule.name}]\uFF1A${latest.summary}` : `\u5DF2\u89E6\u53D1\u8BD5\u8FD0\u884C [${rule.name}]`
|
|
5020
|
+
);
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
);
|
|
5024
|
+
},
|
|
5025
|
+
children: [
|
|
5026
|
+
/* @__PURE__ */ jsx16(BasePlayIcon, {}),
|
|
5027
|
+
/* @__PURE__ */ jsx16("span", { children: "\u7ACB\u5373\u8BD5\u8FD0\u884C" })
|
|
5028
|
+
]
|
|
5029
|
+
}
|
|
5030
|
+
),
|
|
5031
|
+
/* @__PURE__ */ jsx16(
|
|
5032
|
+
"button",
|
|
5033
|
+
{
|
|
5034
|
+
type: "button",
|
|
5035
|
+
className: "univer-bases-icon-btn",
|
|
5036
|
+
title: "\u5220\u9664\u81EA\u52A8\u5316\u89C4\u5219",
|
|
5037
|
+
onClick: () => {
|
|
5038
|
+
commandService.syncExecuteCommand(
|
|
5039
|
+
DeleteBaseAutomationRuleCommand.id,
|
|
5040
|
+
{
|
|
5041
|
+
unitId,
|
|
5042
|
+
ruleId: rule.id
|
|
5043
|
+
}
|
|
5044
|
+
);
|
|
5045
|
+
},
|
|
5046
|
+
children: /* @__PURE__ */ jsx16(BaseTrashIcon, {})
|
|
5047
|
+
}
|
|
5048
|
+
)
|
|
5049
|
+
] })
|
|
5050
|
+
]
|
|
5051
|
+
},
|
|
5052
|
+
rule.id
|
|
5053
|
+
);
|
|
5054
|
+
}) })
|
|
5055
|
+
] }),
|
|
5056
|
+
/* @__PURE__ */ jsxs16("section", { className: "univer-bases-inspector__section", "data-testid": "bases-inspector-logs", children: [
|
|
5057
|
+
/* @__PURE__ */ jsxs16("h4", { children: [
|
|
5058
|
+
"\u6267\u884C\u65E5\u5FD7 (",
|
|
5059
|
+
snapshot.automationLogs?.length ?? 0,
|
|
5060
|
+
")"
|
|
5061
|
+
] }),
|
|
5062
|
+
recentLogs.length === 0 ? /* @__PURE__ */ jsx16("p", { className: "univer-bases-muted-key", children: "\u6682\u65E0\u6267\u884C\u8BB0\u5F55" }) : /* @__PURE__ */ jsx16("div", { className: "univer-bases-inspector__field-list", children: recentLogs.map((log) => /* @__PURE__ */ jsxs16("div", { className: "univer-bases-inspector__auto-card", children: [
|
|
5063
|
+
/* @__PURE__ */ jsxs16(
|
|
5064
|
+
"div",
|
|
5065
|
+
{
|
|
5066
|
+
className: "univer-bases-inline-flex",
|
|
5067
|
+
style: { justifyContent: "space-between", width: "100%" },
|
|
5068
|
+
children: [
|
|
5069
|
+
/* @__PURE__ */ jsx16("strong", { children: log.ruleName }),
|
|
5070
|
+
/* @__PURE__ */ jsxs16("span", { className: "univer-bases-pill univer-bases-pill--neutral", children: [
|
|
5071
|
+
log.status,
|
|
5072
|
+
" \xB7 ",
|
|
5073
|
+
log.executedSteps,
|
|
5074
|
+
"\u6B65"
|
|
5075
|
+
] })
|
|
5076
|
+
]
|
|
5077
|
+
}
|
|
5078
|
+
),
|
|
5079
|
+
/* @__PURE__ */ jsx16("span", { className: "univer-bases-muted-key", children: log.summary })
|
|
5080
|
+
] }, log.id)) })
|
|
5081
|
+
] })
|
|
5082
|
+
] });
|
|
5083
|
+
};
|
|
5084
|
+
|
|
5085
|
+
// src/views/left-sidebar/BasesLeftSidebar.tsx
|
|
5086
|
+
import {
|
|
5087
|
+
AddBaseTableCommand,
|
|
5088
|
+
DeleteBaseTableCommand,
|
|
5089
|
+
SetActiveBaseTableCommand,
|
|
5090
|
+
SetBaseWorkspaceModeCommand as SetBaseWorkspaceModeCommand3
|
|
5091
|
+
} from "@yudaocode/univer-bases";
|
|
5092
|
+
import { useState as useState10 } from "react";
|
|
5093
|
+
import { jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5094
|
+
var BasesLeftSidebar = () => {
|
|
5095
|
+
const { unit, snapshot, commandService, selectionService } = useActiveBaseWorkspace();
|
|
5096
|
+
const [creatingTable, setCreatingTable] = useState10(false);
|
|
5097
|
+
const [newTableName, setNewTableName] = useState10("");
|
|
5098
|
+
if (!unit || !snapshot) return null;
|
|
5099
|
+
const unitId = unit.getUnitId();
|
|
5100
|
+
const workspaceMode = snapshot.workspaceMode ?? "table";
|
|
5101
|
+
return /* @__PURE__ */ jsxs17("aside", { className: "univer-bases-left-sidebar", "data-testid": "bases-left-sidebar", children: [
|
|
5102
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-sidebar-section", children: [
|
|
5103
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-sidebar-section__header", children: [
|
|
5104
|
+
/* @__PURE__ */ jsx17("span", { children: "\u6570\u636E\u8868\u76EE\u5F55" }),
|
|
5105
|
+
/* @__PURE__ */ jsx17(
|
|
5106
|
+
"button",
|
|
5107
|
+
{
|
|
5108
|
+
type: "button",
|
|
5109
|
+
className: "univer-bases-icon-btn",
|
|
5110
|
+
title: "\u65B0\u5EFA\u6570\u636E\u8868",
|
|
5111
|
+
"data-testid": "bases-sidebar-add-table",
|
|
5112
|
+
onClick: () => setCreatingTable((v) => !v),
|
|
5113
|
+
children: /* @__PURE__ */ jsx17(BasePlusIcon, {})
|
|
5114
|
+
}
|
|
5115
|
+
)
|
|
5116
|
+
] }),
|
|
5117
|
+
creatingTable && /* @__PURE__ */ jsxs17("div", { className: "univer-bases-sidebar-create-box", children: [
|
|
5118
|
+
/* @__PURE__ */ jsx17(
|
|
5119
|
+
"input",
|
|
5120
|
+
{
|
|
5121
|
+
type: "text",
|
|
5122
|
+
className: "univer-bases-input",
|
|
5123
|
+
placeholder: "\u8F93\u5165\u65B0\u6570\u636E\u8868\u540D\u79F0...",
|
|
5124
|
+
value: newTableName,
|
|
5125
|
+
onChange: (e) => setNewTableName(e.target.value)
|
|
5126
|
+
}
|
|
5127
|
+
),
|
|
5128
|
+
/* @__PURE__ */ jsx17(
|
|
5129
|
+
"button",
|
|
5130
|
+
{
|
|
5131
|
+
type: "button",
|
|
5132
|
+
className: "univer-bases-btn univer-bases-btn--primary univer-bases-btn--sm",
|
|
5133
|
+
onClick: () => {
|
|
4156
5134
|
commandService.syncExecuteCommand(AddBaseTableCommand.id, {
|
|
4157
5135
|
unitId,
|
|
4158
5136
|
name: newTableName.trim() || void 0,
|
|
@@ -4165,11 +5143,11 @@ var BasesLeftSidebar = () => {
|
|
|
4165
5143
|
}
|
|
4166
5144
|
)
|
|
4167
5145
|
] }),
|
|
4168
|
-
/* @__PURE__ */
|
|
5146
|
+
/* @__PURE__ */ jsx17("div", { className: "univer-bases-sidebar-list", children: snapshot.tableOrder.map((tid) => {
|
|
4169
5147
|
const tbl = snapshot.tables[tid];
|
|
4170
5148
|
if (!tbl) return null;
|
|
4171
5149
|
const isActive = workspaceMode === "table" && snapshot.activeTableId === tid;
|
|
4172
|
-
return /* @__PURE__ */
|
|
5150
|
+
return /* @__PURE__ */ jsxs17(
|
|
4173
5151
|
"div",
|
|
4174
5152
|
{
|
|
4175
5153
|
className: `univer-bases-sidebar-item ${isActive ? "is-active" : ""}`,
|
|
@@ -4183,13 +5161,13 @@ var BasesLeftSidebar = () => {
|
|
|
4183
5161
|
});
|
|
4184
5162
|
},
|
|
4185
5163
|
children: [
|
|
4186
|
-
/* @__PURE__ */
|
|
4187
|
-
/* @__PURE__ */
|
|
4188
|
-
/* @__PURE__ */
|
|
5164
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-inline-flex", style: { overflow: "hidden" }, children: [
|
|
5165
|
+
/* @__PURE__ */ jsx17(BaseTableIcon, {}),
|
|
5166
|
+
/* @__PURE__ */ jsx17("span", { className: "univer-bases-sidebar-item__name", children: tbl.name })
|
|
4189
5167
|
] }),
|
|
4190
|
-
/* @__PURE__ */
|
|
4191
|
-
/* @__PURE__ */
|
|
4192
|
-
snapshot.tableOrder.length > 1 && /* @__PURE__ */
|
|
5168
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-inline-flex", children: [
|
|
5169
|
+
/* @__PURE__ */ jsx17("span", { className: "univer-bases-badge-count", children: tbl.recordOrder.length }),
|
|
5170
|
+
snapshot.tableOrder.length > 1 && /* @__PURE__ */ jsx17(
|
|
4193
5171
|
"button",
|
|
4194
5172
|
{
|
|
4195
5173
|
type: "button",
|
|
@@ -4202,7 +5180,7 @@ var BasesLeftSidebar = () => {
|
|
|
4202
5180
|
tableId: tid
|
|
4203
5181
|
});
|
|
4204
5182
|
},
|
|
4205
|
-
children: /* @__PURE__ */
|
|
5183
|
+
children: /* @__PURE__ */ jsx17(BaseTrashIcon, {})
|
|
4206
5184
|
}
|
|
4207
5185
|
)
|
|
4208
5186
|
] })
|
|
@@ -4212,11 +5190,11 @@ var BasesLeftSidebar = () => {
|
|
|
4212
5190
|
);
|
|
4213
5191
|
}) })
|
|
4214
5192
|
] }),
|
|
4215
|
-
/* @__PURE__ */
|
|
4216
|
-
/* @__PURE__ */
|
|
4217
|
-
/* @__PURE__ */
|
|
5193
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-sidebar-section", children: [
|
|
5194
|
+
/* @__PURE__ */ jsx17("div", { className: "univer-bases-sidebar-section__header", children: /* @__PURE__ */ jsx17("span", { children: "\u6570\u636E\u5168\u666F\u4EEA\u8868\u76D8" }) }),
|
|
5195
|
+
/* @__PURE__ */ jsx17("div", { className: "univer-bases-sidebar-list", children: (snapshot.dashboards ?? []).map((dash) => {
|
|
4218
5196
|
const isActive = workspaceMode === "dashboard" && (snapshot.activeDashboardId ?? snapshot.dashboards?.[0]?.id) === dash.id;
|
|
4219
|
-
return /* @__PURE__ */
|
|
5197
|
+
return /* @__PURE__ */ jsxs17(
|
|
4220
5198
|
"div",
|
|
4221
5199
|
{
|
|
4222
5200
|
className: `univer-bases-sidebar-item ${isActive ? "is-active" : ""}`,
|
|
@@ -4229,21 +5207,21 @@ var BasesLeftSidebar = () => {
|
|
|
4229
5207
|
});
|
|
4230
5208
|
},
|
|
4231
5209
|
children: [
|
|
4232
|
-
/* @__PURE__ */
|
|
4233
|
-
/* @__PURE__ */
|
|
4234
|
-
/* @__PURE__ */
|
|
5210
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-inline-flex", children: [
|
|
5211
|
+
/* @__PURE__ */ jsx17(BaseDashboardIcon, {}),
|
|
5212
|
+
/* @__PURE__ */ jsx17("span", { className: "univer-bases-sidebar-item__name", children: dash.name })
|
|
4235
5213
|
] }),
|
|
4236
|
-
/* @__PURE__ */
|
|
5214
|
+
/* @__PURE__ */ jsx17("span", { className: "univer-bases-badge-count", children: dash.widgets.length })
|
|
4237
5215
|
]
|
|
4238
5216
|
},
|
|
4239
5217
|
dash.id
|
|
4240
5218
|
);
|
|
4241
5219
|
}) })
|
|
4242
5220
|
] }),
|
|
4243
|
-
/* @__PURE__ */
|
|
4244
|
-
/* @__PURE__ */
|
|
4245
|
-
/* @__PURE__ */
|
|
4246
|
-
/* @__PURE__ */
|
|
5221
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-sidebar-section", children: [
|
|
5222
|
+
/* @__PURE__ */ jsx17("div", { className: "univer-bases-sidebar-section__header", children: /* @__PURE__ */ jsx17("span", { children: "\u4F01\u4E1A\u5185\u7F6E\u793A\u4F8B\u5E93" }) }),
|
|
5223
|
+
/* @__PURE__ */ jsxs17("div", { className: "univer-bases-sidebar-presets", children: [
|
|
5224
|
+
/* @__PURE__ */ jsx17(
|
|
4247
5225
|
"button",
|
|
4248
5226
|
{
|
|
4249
5227
|
type: "button",
|
|
@@ -4254,7 +5232,7 @@ var BasesLeftSidebar = () => {
|
|
|
4254
5232
|
children: "\u7814\u53D1\u9879\u76EE\u4E0E\u51B2\u523A\u534F\u540C\u5E93"
|
|
4255
5233
|
}
|
|
4256
5234
|
),
|
|
4257
|
-
/* @__PURE__ */
|
|
5235
|
+
/* @__PURE__ */ jsx17(
|
|
4258
5236
|
"button",
|
|
4259
5237
|
{
|
|
4260
5238
|
type: "button",
|
|
@@ -4280,10 +5258,746 @@ import {
|
|
|
4280
5258
|
normalizeLinkIds,
|
|
4281
5259
|
ReplaceBaseSnapshotCommand as ReplaceBaseSnapshotCommand2,
|
|
4282
5260
|
resolveBaseCellValue as resolveBaseCellValue2,
|
|
4283
|
-
UpdateBaseRecordCommand as
|
|
5261
|
+
UpdateBaseRecordCommand as UpdateBaseRecordCommand5
|
|
4284
5262
|
} from "@yudaocode/univer-bases";
|
|
4285
|
-
import { useState as
|
|
4286
|
-
|
|
5263
|
+
import { useState as useState12 } from "react";
|
|
5264
|
+
|
|
5265
|
+
// src/views/modals/AutomationBuilderModal.tsx
|
|
5266
|
+
import { generateRandomId as generateRandomId5 } from "@univerjs/core";
|
|
5267
|
+
import {
|
|
5268
|
+
normalizeAutomationSteps as normalizeAutomationSteps2,
|
|
5269
|
+
SaveBaseAutomationRuleCommand,
|
|
5270
|
+
TriggerBaseAutomationCommand as TriggerBaseAutomationCommand2
|
|
5271
|
+
} from "@yudaocode/univer-bases";
|
|
5272
|
+
import { useState as useState11 } from "react";
|
|
5273
|
+
import { jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
5274
|
+
var TRIGGER_OPTIONS = [
|
|
5275
|
+
{ value: "recordCreated", label: "\u5F53\u65B0\u5EFA\u8BB0\u5F55\u65F6 (recordCreated)" },
|
|
5276
|
+
{ value: "recordUpdated", label: "\u5F53\u8BB0\u5F55\u66F4\u65B0\u65F6 (recordUpdated)" },
|
|
5277
|
+
{ value: "fieldChanged", label: "\u5F53\u6307\u5B9A\u5B57\u6BB5\u53D8\u66F4\u65F6 (fieldChanged)" },
|
|
5278
|
+
{ value: "conditionMatched", label: "\u5F53\u8BB0\u5F55\u6EE1\u8DB3\u6761\u4EF6\u65F6 (conditionMatched)" },
|
|
5279
|
+
{ value: "scheduled", label: "\u5B9A\u65F6\u5468\u671F\u89E6\u53D1 (scheduled)" },
|
|
5280
|
+
{ value: "webhookReceived", label: "\u6536\u5230\u5916\u90E8 Webhook \u56DE\u8C03\u65F6 (webhookReceived)" }
|
|
5281
|
+
];
|
|
5282
|
+
var OPERATOR_OPTIONS = [
|
|
5283
|
+
{ value: "is", label: "\u7B49\u4E8E" },
|
|
5284
|
+
{ value: "isNot", label: "\u4E0D\u7B49\u4E8E" },
|
|
5285
|
+
{ value: "contains", label: "\u5305\u542B" },
|
|
5286
|
+
{ value: "notContains", label: "\u4E0D\u5305\u542B" },
|
|
5287
|
+
{ value: "gt", label: "\u5927\u4E8E" },
|
|
5288
|
+
{ value: "gte", label: "\u5927\u4E8E\u7B49\u4E8E" },
|
|
5289
|
+
{ value: "lt", label: "\u5C0F\u4E8E" },
|
|
5290
|
+
{ value: "lte", label: "\u5C0F\u4E8E\u7B49\u4E8E" },
|
|
5291
|
+
{ value: "isEmpty", label: "\u4E3A\u7A7A" },
|
|
5292
|
+
{ value: "isNotEmpty", label: "\u4E0D\u4E3A\u7A7A" }
|
|
5293
|
+
];
|
|
5294
|
+
var STEP_TYPE_LABELS = {
|
|
5295
|
+
updateRecord: "\u4FEE\u6539\u8BB0\u5F55",
|
|
5296
|
+
createLinkedRecord: "\u65B0\u5EFA\u5173\u8054\u8BB0\u5F55",
|
|
5297
|
+
ifElse: "If/Else \u6761\u4EF6\u5206\u652F",
|
|
5298
|
+
loopRecords: "\u5FAA\u73AF\u5904\u7406\u8BB0\u5F55",
|
|
5299
|
+
httpWebhook: "\u53D1\u9001 Webhook",
|
|
5300
|
+
notify: "\u53D1\u9001\u6D88\u606F\u901A\u77E5"
|
|
5301
|
+
};
|
|
5302
|
+
var AutomationBuilderModal = () => {
|
|
5303
|
+
const { unit, snapshot, commandService, selectionService, selectionState } = useActiveBaseWorkspace();
|
|
5304
|
+
if (!unit || !snapshot) return null;
|
|
5305
|
+
const unitId = unit.getUnitId();
|
|
5306
|
+
const activeTable = unit.getActiveTable();
|
|
5307
|
+
const tables = snapshot.tableOrder.map((tid) => snapshot.tables[tid]).filter((t) => Boolean(t));
|
|
5308
|
+
const editingRule = selectionState.editingAutomationRuleId ? (snapshot.automations ?? []).find((r) => r.id === selectionState.editingAutomationRuleId) : void 0;
|
|
5309
|
+
const defaultTableId = editingRule?.tableId ?? activeTable?.id ?? tables[0]?.id ?? "";
|
|
5310
|
+
const initialDefaultFieldId = snapshot.tables[defaultTableId]?.fieldOrder[0] ?? "";
|
|
5311
|
+
const [activeTab, setActiveTab] = useState11("pipeline");
|
|
5312
|
+
const [name, setName] = useState11(editingRule?.name ?? "\u591A\u6B65\u4E1A\u52A1\u81EA\u52A8\u5316\u6D41\u6C34\u7EBF");
|
|
5313
|
+
const [tableId, setTableId] = useState11(defaultTableId);
|
|
5314
|
+
const [enabled, setEnabled] = useState11(editingRule?.enabled ?? true);
|
|
5315
|
+
const [trigger, setTrigger] = useState11(
|
|
5316
|
+
editingRule?.trigger === "fieldMatches" ? "fieldChanged" : editingRule?.trigger ?? "recordCreated"
|
|
5317
|
+
);
|
|
5318
|
+
const [triggerFieldIds, setTriggerFieldIds] = useState11(
|
|
5319
|
+
editingRule?.triggerFieldIds ?? (editingRule?.triggerFieldId ? [editingRule.triggerFieldId] : [])
|
|
5320
|
+
);
|
|
5321
|
+
const [scheduleCron, setScheduleCron] = useState11(editingRule?.scheduleCron ?? "0 9 * * 1-5");
|
|
5322
|
+
const [conditionConjunction, setConditionConjunction] = useState11(
|
|
5323
|
+
editingRule?.conditionConjunction ?? "and"
|
|
5324
|
+
);
|
|
5325
|
+
const [conditions, setConditions] = useState11(
|
|
5326
|
+
editingRule?.conditions ?? []
|
|
5327
|
+
);
|
|
5328
|
+
const [steps, setSteps] = useState11(() => {
|
|
5329
|
+
if (editingRule) {
|
|
5330
|
+
const normalized = normalizeAutomationSteps2(editingRule);
|
|
5331
|
+
if (normalized.length > 0) return normalized;
|
|
5332
|
+
}
|
|
5333
|
+
return [
|
|
5334
|
+
{
|
|
5335
|
+
id: `stp_${generateRandomId5(5)}`,
|
|
5336
|
+
type: "updateRecord",
|
|
5337
|
+
fieldUpdates: initialDefaultFieldId ? { [initialDefaultFieldId]: "{" + (snapshot.tables[defaultTableId]?.fields[initialDefaultFieldId]?.name ?? "\u6807\u9898") + "}" } : {}
|
|
5338
|
+
}
|
|
5339
|
+
];
|
|
5340
|
+
});
|
|
5341
|
+
const currentTable = snapshot.tables[tableId] ?? tables[0];
|
|
5342
|
+
const currentFields = currentTable ? currentTable.fieldOrder.map((fid) => currentTable.fields[fid]).filter((f) => Boolean(f)) : [];
|
|
5343
|
+
const closeModal = () => {
|
|
5344
|
+
selectionService.openModal(null);
|
|
5345
|
+
};
|
|
5346
|
+
const addStep = (type) => {
|
|
5347
|
+
const firstFid = currentFields[0]?.id ?? "";
|
|
5348
|
+
const otherTable = tables.find((t) => t.id !== tableId) ?? currentTable;
|
|
5349
|
+
const otherPrimaryFid = otherTable?.primaryFieldId ?? "";
|
|
5350
|
+
let newStep;
|
|
5351
|
+
switch (type) {
|
|
5352
|
+
case "updateRecord":
|
|
5353
|
+
newStep = {
|
|
5354
|
+
id: `stp_${generateRandomId5(5)}`,
|
|
5355
|
+
type: "updateRecord",
|
|
5356
|
+
fieldUpdates: firstFid ? { [firstFid]: "\u5DF2\u81EA\u52A8\u5904\u7406" } : {}
|
|
5357
|
+
};
|
|
5358
|
+
break;
|
|
5359
|
+
case "createLinkedRecord":
|
|
5360
|
+
newStep = {
|
|
5361
|
+
id: `stp_${generateRandomId5(5)}`,
|
|
5362
|
+
type: "createLinkedRecord",
|
|
5363
|
+
targetTableId: otherTable?.id ?? tableId,
|
|
5364
|
+
recordCells: otherPrimaryFid ? { [otherPrimaryFid]: `[\u81EA\u52A8\u5173\u8054] {${currentFields[0]?.name ?? "\u6807\u9898"}}` } : {}
|
|
5365
|
+
};
|
|
5366
|
+
break;
|
|
5367
|
+
case "ifElse":
|
|
5368
|
+
newStep = {
|
|
5369
|
+
id: `stp_${generateRandomId5(5)}`,
|
|
5370
|
+
type: "ifElse",
|
|
5371
|
+
conditions: firstFid ? [{ id: `cnd_${generateRandomId5(4)}`, fieldId: firstFid, operator: "isNotEmpty" }] : [],
|
|
5372
|
+
thenSteps: [
|
|
5373
|
+
{
|
|
5374
|
+
id: `stp_${generateRandomId5(4)}`,
|
|
5375
|
+
type: "updateRecord",
|
|
5376
|
+
fieldUpdates: firstFid ? { [firstFid]: "\u5206\u652F\u901A\u8FC7" } : {}
|
|
5377
|
+
}
|
|
5378
|
+
],
|
|
5379
|
+
elseSteps: []
|
|
5380
|
+
};
|
|
5381
|
+
break;
|
|
5382
|
+
case "loopRecords":
|
|
5383
|
+
newStep = {
|
|
5384
|
+
id: `stp_${generateRandomId5(5)}`,
|
|
5385
|
+
type: "loopRecords",
|
|
5386
|
+
loopTableId: tableId,
|
|
5387
|
+
loopConditions: [],
|
|
5388
|
+
loopSteps: [
|
|
5389
|
+
{
|
|
5390
|
+
id: `stp_${generateRandomId5(4)}`,
|
|
5391
|
+
type: "updateRecord",
|
|
5392
|
+
fieldUpdates: firstFid ? { [firstFid]: "\u6279\u91CF\u66F4\u65B0\u9879" } : {}
|
|
5393
|
+
}
|
|
5394
|
+
]
|
|
5395
|
+
};
|
|
5396
|
+
break;
|
|
5397
|
+
case "httpWebhook":
|
|
5398
|
+
default:
|
|
5399
|
+
newStep = {
|
|
5400
|
+
id: `stp_${generateRandomId5(5)}`,
|
|
5401
|
+
type: "httpWebhook",
|
|
5402
|
+
webhookMethod: "POST",
|
|
5403
|
+
webhookUrl: "https://api.example.com/webhooks/bases-sync",
|
|
5404
|
+
webhookBodyTemplate: `{"recordId": "{recordId}", "title": "{${currentFields[0]?.name ?? "\u6807\u9898"}}"}`
|
|
5405
|
+
};
|
|
5406
|
+
break;
|
|
5407
|
+
}
|
|
5408
|
+
setSteps((prev) => [...prev, newStep]);
|
|
5409
|
+
};
|
|
5410
|
+
const updateStepAt = (idx, patch) => {
|
|
5411
|
+
setSteps((prev) => prev.map((s, i) => i === idx ? { ...s, ...patch } : s));
|
|
5412
|
+
};
|
|
5413
|
+
const buildRulePayload = () => ({
|
|
5414
|
+
...editingRule?.id ? { id: editingRule.id } : {},
|
|
5415
|
+
name: name.trim() || "\u672A\u547D\u540D\u81EA\u52A8\u5316\u6D41\u7A0B",
|
|
5416
|
+
tableId,
|
|
5417
|
+
enabled,
|
|
5418
|
+
trigger,
|
|
5419
|
+
triggerFieldIds: trigger === "fieldChanged" ? triggerFieldIds : void 0,
|
|
5420
|
+
scheduleCron: trigger === "scheduled" ? scheduleCron : void 0,
|
|
5421
|
+
conditionConjunction,
|
|
5422
|
+
conditions,
|
|
5423
|
+
steps
|
|
5424
|
+
});
|
|
5425
|
+
const handleSave = () => {
|
|
5426
|
+
commandService.syncExecuteCommand(SaveBaseAutomationRuleCommand.id, {
|
|
5427
|
+
unitId,
|
|
5428
|
+
rule: buildRulePayload(),
|
|
5429
|
+
onSaved: () => {
|
|
5430
|
+
selectionService.notifyToast(`\u5DF2\u4FDD\u5B58\u81EA\u52A8\u5316\u6D41\u7A0B\u300C${name.trim() || "\u672A\u547D\u540D\u6D41\u7A0B"}\u300D`);
|
|
5431
|
+
}
|
|
5432
|
+
});
|
|
5433
|
+
closeModal();
|
|
5434
|
+
};
|
|
5435
|
+
const handleSaveAndDryRun = () => {
|
|
5436
|
+
let savedId = editingRule?.id ?? "";
|
|
5437
|
+
const ok = commandService.syncExecuteCommand(SaveBaseAutomationRuleCommand.id, {
|
|
5438
|
+
unitId,
|
|
5439
|
+
rule: buildRulePayload(),
|
|
5440
|
+
onSaved: (rid) => {
|
|
5441
|
+
savedId = rid;
|
|
5442
|
+
}
|
|
5443
|
+
});
|
|
5444
|
+
if (ok && savedId) {
|
|
5445
|
+
commandService.syncExecuteCommand(TriggerBaseAutomationCommand2.id, {
|
|
5446
|
+
unitId,
|
|
5447
|
+
ruleId: savedId,
|
|
5448
|
+
tableId,
|
|
5449
|
+
onExecuted: (logs2) => {
|
|
5450
|
+
const latest = logs2[logs2.length - 1];
|
|
5451
|
+
selectionService.notifyToast(
|
|
5452
|
+
latest ? `\u8BD5\u8FD0\u884C\u5B8C\u6210 [${latest.status}]\uFF1A${latest.summary}` : "\u8BD5\u8FD0\u884C\u5DF2\u6267\u884C"
|
|
5453
|
+
);
|
|
5454
|
+
}
|
|
5455
|
+
});
|
|
5456
|
+
setActiveTab("logs");
|
|
5457
|
+
}
|
|
5458
|
+
};
|
|
5459
|
+
const logs = [...snapshot.automationLogs ?? []].reverse();
|
|
5460
|
+
return /* @__PURE__ */ jsx18("div", { className: "univer-bases-modal-backdrop", onClick: closeModal, children: /* @__PURE__ */ jsxs18(
|
|
5461
|
+
"div",
|
|
5462
|
+
{
|
|
5463
|
+
className: "univer-bases-modal univer-bases-modal--automation",
|
|
5464
|
+
"data-testid": "bases-automation-builder-modal",
|
|
5465
|
+
onClick: (e) => e.stopPropagation(),
|
|
5466
|
+
children: [
|
|
5467
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-popover__header", children: [
|
|
5468
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", children: [
|
|
5469
|
+
/* @__PURE__ */ jsx18(BaseBoltIcon, {}),
|
|
5470
|
+
/* @__PURE__ */ jsx18("strong", { children: editingRule ? `\u7F16\u8F91\u81EA\u52A8\u5316\u6D41\u7A0B \xB7 ${editingRule.name}` : "\u65B0\u5EFA\u53EF\u89C6\u5316\u591A\u6B65\u81EA\u52A8\u5316\u6D41\u7A0B" })
|
|
5471
|
+
] }),
|
|
5472
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", children: [
|
|
5473
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-segmented", role: "tablist", children: [
|
|
5474
|
+
/* @__PURE__ */ jsx18(
|
|
5475
|
+
"button",
|
|
5476
|
+
{
|
|
5477
|
+
type: "button",
|
|
5478
|
+
className: `univer-bases-segmented__item ${activeTab === "pipeline" ? "is-active" : ""}`,
|
|
5479
|
+
onClick: () => setActiveTab("pipeline"),
|
|
5480
|
+
children: "\u6D41\u7A0B\u7F16\u6392"
|
|
5481
|
+
}
|
|
5482
|
+
),
|
|
5483
|
+
/* @__PURE__ */ jsxs18(
|
|
5484
|
+
"button",
|
|
5485
|
+
{
|
|
5486
|
+
type: "button",
|
|
5487
|
+
className: `univer-bases-segmented__item ${activeTab === "logs" ? "is-active" : ""}`,
|
|
5488
|
+
"data-testid": "bases-auto-modal-logs-tab",
|
|
5489
|
+
onClick: () => setActiveTab("logs"),
|
|
5490
|
+
children: [
|
|
5491
|
+
"\u6267\u884C\u65E5\u5FD7 (",
|
|
5492
|
+
logs.length,
|
|
5493
|
+
")"
|
|
5494
|
+
]
|
|
5495
|
+
}
|
|
5496
|
+
)
|
|
5497
|
+
] }),
|
|
5498
|
+
/* @__PURE__ */ jsx18("button", { type: "button", className: "univer-bases-icon-btn", onClick: closeModal, children: /* @__PURE__ */ jsx18(BaseCloseIcon, {}) })
|
|
5499
|
+
] })
|
|
5500
|
+
] }),
|
|
5501
|
+
activeTab === "logs" ? /* @__PURE__ */ jsx18("div", { className: "univer-bases-auto-logs-panel", "data-testid": "bases-auto-modal-logs-list", children: logs.length === 0 ? /* @__PURE__ */ jsx18("div", { className: "univer-bases-empty-hint", children: "\u6682\u65E0\u81EA\u52A8\u5316\u8FD0\u884C\u65E5\u5FD7\uFF0C\u53EF\u70B9\u51FB\u4E0B\u65B9\u300C\u7ACB\u5373\u8BD5\u8FD0\u884C\u300D\u9A8C\u8BC1\u6D41\u6C34\u7EBF\u6548\u679C" }) : logs.map((log) => /* @__PURE__ */ jsxs18("div", { className: "univer-bases-auto-log-item", children: [
|
|
5502
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", style: { justifyContent: "space-between", width: "100%" }, children: [
|
|
5503
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", children: [
|
|
5504
|
+
/* @__PURE__ */ jsx18(
|
|
5505
|
+
"span",
|
|
5506
|
+
{
|
|
5507
|
+
className: `univer-bases-pill ${log.status === "success" ? "univer-bases-auto-status--success" : log.status === "error" ? "univer-bases-auto-status--error" : "univer-bases-pill--neutral"}`,
|
|
5508
|
+
children: log.status === "success" ? "\u6210\u529F" : log.status === "error" ? "\u5F02\u5E38" : "\u5DF2\u8DF3\u8FC7"
|
|
5509
|
+
}
|
|
5510
|
+
),
|
|
5511
|
+
/* @__PURE__ */ jsx18("strong", { children: log.ruleName }),
|
|
5512
|
+
/* @__PURE__ */ jsxs18("span", { className: "univer-bases-muted-key", children: [
|
|
5513
|
+
"\u6267\u884C ",
|
|
5514
|
+
log.executedSteps,
|
|
5515
|
+
" \u6B65"
|
|
5516
|
+
] })
|
|
5517
|
+
] }),
|
|
5518
|
+
/* @__PURE__ */ jsx18("span", { className: "univer-bases-muted-key", children: log.timestamp })
|
|
5519
|
+
] }),
|
|
5520
|
+
/* @__PURE__ */ jsx18("div", { className: "univer-bases-muted-key", children: log.summary })
|
|
5521
|
+
] }, log.id)) }) : /* @__PURE__ */ jsxs18("div", { className: "univer-bases-auto-builder-body", children: [
|
|
5522
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-auto-grid-2", children: [
|
|
5523
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-form-row", children: [
|
|
5524
|
+
/* @__PURE__ */ jsx18("label", { children: "\u81EA\u52A8\u5316\u6D41\u7A0B\u540D\u79F0" }),
|
|
5525
|
+
/* @__PURE__ */ jsx18(
|
|
5526
|
+
"input",
|
|
5527
|
+
{
|
|
5528
|
+
type: "text",
|
|
5529
|
+
className: "univer-bases-input",
|
|
5530
|
+
"data-testid": "bases-auto-name-input",
|
|
5531
|
+
value: name,
|
|
5532
|
+
onChange: (e) => setName(e.target.value)
|
|
5533
|
+
}
|
|
5534
|
+
)
|
|
5535
|
+
] }),
|
|
5536
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-form-row", children: [
|
|
5537
|
+
/* @__PURE__ */ jsx18("label", { children: "\u76D1\u542C\u76EE\u6807\u6570\u636E\u8868" }),
|
|
5538
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", children: [
|
|
5539
|
+
/* @__PURE__ */ jsx18(
|
|
5540
|
+
"select",
|
|
5541
|
+
{
|
|
5542
|
+
className: "univer-bases-select",
|
|
5543
|
+
value: tableId,
|
|
5544
|
+
onChange: (e) => {
|
|
5545
|
+
setTableId(e.target.value);
|
|
5546
|
+
setTriggerFieldIds([]);
|
|
5547
|
+
},
|
|
5548
|
+
children: tables.map((t) => /* @__PURE__ */ jsx18("option", { value: t.id, children: t.name }, t.id))
|
|
5549
|
+
}
|
|
5550
|
+
),
|
|
5551
|
+
/* @__PURE__ */ jsxs18("label", { className: "univer-bases-checkbox-label", children: [
|
|
5552
|
+
/* @__PURE__ */ jsx18(
|
|
5553
|
+
"input",
|
|
5554
|
+
{
|
|
5555
|
+
type: "checkbox",
|
|
5556
|
+
checked: enabled,
|
|
5557
|
+
onChange: (e) => setEnabled(e.target.checked)
|
|
5558
|
+
}
|
|
5559
|
+
),
|
|
5560
|
+
/* @__PURE__ */ jsx18("span", { children: "\u542F\u7528" })
|
|
5561
|
+
] })
|
|
5562
|
+
] })
|
|
5563
|
+
] })
|
|
5564
|
+
] }),
|
|
5565
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-auto-stage-card", children: [
|
|
5566
|
+
/* @__PURE__ */ jsx18("div", { className: "univer-bases-auto-stage-title", children: "1. \u89E6\u53D1\u5668 (Trigger)" }),
|
|
5567
|
+
/* @__PURE__ */ jsx18("div", { className: "univer-bases-form-row", children: /* @__PURE__ */ jsx18(
|
|
5568
|
+
"select",
|
|
5569
|
+
{
|
|
5570
|
+
className: "univer-bases-select",
|
|
5571
|
+
"data-testid": "bases-auto-trigger-select",
|
|
5572
|
+
value: trigger,
|
|
5573
|
+
onChange: (e) => setTrigger(e.target.value),
|
|
5574
|
+
children: TRIGGER_OPTIONS.map((opt) => /* @__PURE__ */ jsx18("option", { value: opt.value, children: opt.label }, opt.value))
|
|
5575
|
+
}
|
|
5576
|
+
) }),
|
|
5577
|
+
trigger === "fieldChanged" && /* @__PURE__ */ jsxs18("div", { className: "univer-bases-form-row", style: { marginTop: 8 }, children: [
|
|
5578
|
+
/* @__PURE__ */ jsx18("label", { children: "\u9009\u62E9\u76D1\u542C\u53D8\u66F4\u7684\u5B57\u6BB5\uFF08\u4E0D\u9009\u5219\u4EFB\u610F\u5B57\u6BB5\u53D8\u66F4\u5747\u89E6\u53D1\uFF09" }),
|
|
5579
|
+
/* @__PURE__ */ jsx18("div", { className: "univer-bases-tag-wrap", children: currentFields.map((f) => {
|
|
5580
|
+
const checked = triggerFieldIds.includes(f.id);
|
|
5581
|
+
return /* @__PURE__ */ jsxs18("label", { className: "univer-bases-checkbox-label", children: [
|
|
5582
|
+
/* @__PURE__ */ jsx18(
|
|
5583
|
+
"input",
|
|
5584
|
+
{
|
|
5585
|
+
type: "checkbox",
|
|
5586
|
+
checked,
|
|
5587
|
+
onChange: () => {
|
|
5588
|
+
setTriggerFieldIds(
|
|
5589
|
+
(prev) => checked ? prev.filter((id) => id !== f.id) : [...prev, f.id]
|
|
5590
|
+
);
|
|
5591
|
+
}
|
|
5592
|
+
}
|
|
5593
|
+
),
|
|
5594
|
+
/* @__PURE__ */ jsx18("span", { children: f.name })
|
|
5595
|
+
] }, f.id);
|
|
5596
|
+
}) })
|
|
5597
|
+
] }),
|
|
5598
|
+
trigger === "scheduled" && /* @__PURE__ */ jsxs18("div", { className: "univer-bases-form-row", style: { marginTop: 8 }, children: [
|
|
5599
|
+
/* @__PURE__ */ jsx18("label", { children: "Cron \u5468\u671F\u8868\u8FBE\u5F0F" }),
|
|
5600
|
+
/* @__PURE__ */ jsx18(
|
|
5601
|
+
"input",
|
|
5602
|
+
{
|
|
5603
|
+
type: "text",
|
|
5604
|
+
className: "univer-bases-input",
|
|
5605
|
+
value: scheduleCron,
|
|
5606
|
+
onChange: (e) => setScheduleCron(e.target.value)
|
|
5607
|
+
}
|
|
5608
|
+
)
|
|
5609
|
+
] })
|
|
5610
|
+
] }),
|
|
5611
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-auto-stage-card", children: [
|
|
5612
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", style: { justifyContent: "space-between", width: "100%" }, children: [
|
|
5613
|
+
/* @__PURE__ */ jsx18("span", { className: "univer-bases-auto-stage-title", children: "2. \u89E6\u53D1\u51C6\u5165\u6761\u4EF6 (Conditions)" }),
|
|
5614
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", children: [
|
|
5615
|
+
/* @__PURE__ */ jsxs18(
|
|
5616
|
+
"select",
|
|
5617
|
+
{
|
|
5618
|
+
className: "univer-bases-select univer-bases-select--xs",
|
|
5619
|
+
value: conditionConjunction,
|
|
5620
|
+
onChange: (e) => setConditionConjunction(e.target.value),
|
|
5621
|
+
children: [
|
|
5622
|
+
/* @__PURE__ */ jsx18("option", { value: "and", children: "\u6EE1\u8DB3\u5168\u90E8 (AND)" }),
|
|
5623
|
+
/* @__PURE__ */ jsx18("option", { value: "or", children: "\u6EE1\u8DB3\u4EFB\u4E00 (OR)" })
|
|
5624
|
+
]
|
|
5625
|
+
}
|
|
5626
|
+
),
|
|
5627
|
+
/* @__PURE__ */ jsxs18(
|
|
5628
|
+
"button",
|
|
5629
|
+
{
|
|
5630
|
+
type: "button",
|
|
5631
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
5632
|
+
onClick: () => {
|
|
5633
|
+
const f0 = currentFields[0];
|
|
5634
|
+
if (!f0) return;
|
|
5635
|
+
setConditions((prev) => [
|
|
5636
|
+
...prev,
|
|
5637
|
+
{
|
|
5638
|
+
id: `acnd_${generateRandomId5(5)}`,
|
|
5639
|
+
fieldId: f0.id,
|
|
5640
|
+
operator: "is",
|
|
5641
|
+
value: ""
|
|
5642
|
+
}
|
|
5643
|
+
]);
|
|
5644
|
+
},
|
|
5645
|
+
children: [
|
|
5646
|
+
/* @__PURE__ */ jsx18(BasePlusIcon, {}),
|
|
5647
|
+
/* @__PURE__ */ jsx18("span", { children: "\u6DFB\u52A0\u6761\u4EF6" })
|
|
5648
|
+
]
|
|
5649
|
+
}
|
|
5650
|
+
)
|
|
5651
|
+
] })
|
|
5652
|
+
] }),
|
|
5653
|
+
conditions.length > 0 && /* @__PURE__ */ jsx18("div", { className: "univer-bases-rule-list", style: { marginTop: 8 }, children: conditions.map((cnd) => /* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-row", children: [
|
|
5654
|
+
/* @__PURE__ */ jsx18(
|
|
5655
|
+
"select",
|
|
5656
|
+
{
|
|
5657
|
+
className: "univer-bases-select",
|
|
5658
|
+
value: cnd.fieldId,
|
|
5659
|
+
onChange: (e) => setConditions(
|
|
5660
|
+
(prev) => prev.map(
|
|
5661
|
+
(c) => c.id === cnd.id ? { ...c, fieldId: e.target.value } : c
|
|
5662
|
+
)
|
|
5663
|
+
),
|
|
5664
|
+
children: currentFields.map((f) => /* @__PURE__ */ jsx18("option", { value: f.id, children: f.name }, f.id))
|
|
5665
|
+
}
|
|
5666
|
+
),
|
|
5667
|
+
/* @__PURE__ */ jsx18(
|
|
5668
|
+
"select",
|
|
5669
|
+
{
|
|
5670
|
+
className: "univer-bases-select univer-bases-select--xs",
|
|
5671
|
+
value: cnd.operator,
|
|
5672
|
+
onChange: (e) => setConditions(
|
|
5673
|
+
(prev) => prev.map(
|
|
5674
|
+
(c) => c.id === cnd.id ? { ...c, operator: e.target.value } : c
|
|
5675
|
+
)
|
|
5676
|
+
),
|
|
5677
|
+
children: OPERATOR_OPTIONS.map((op) => /* @__PURE__ */ jsx18("option", { value: op.value, children: op.label }, op.value))
|
|
5678
|
+
}
|
|
5679
|
+
),
|
|
5680
|
+
cnd.operator !== "isEmpty" && cnd.operator !== "isNotEmpty" && /* @__PURE__ */ jsx18(
|
|
5681
|
+
"input",
|
|
5682
|
+
{
|
|
5683
|
+
type: "text",
|
|
5684
|
+
className: "univer-bases-input",
|
|
5685
|
+
placeholder: "\u6761\u4EF6\u503C...",
|
|
5686
|
+
value: String(cnd.value ?? ""),
|
|
5687
|
+
onChange: (e) => setConditions(
|
|
5688
|
+
(prev) => prev.map(
|
|
5689
|
+
(c) => c.id === cnd.id ? { ...c, value: e.target.value } : c
|
|
5690
|
+
)
|
|
5691
|
+
)
|
|
5692
|
+
}
|
|
5693
|
+
),
|
|
5694
|
+
/* @__PURE__ */ jsx18(
|
|
5695
|
+
"button",
|
|
5696
|
+
{
|
|
5697
|
+
type: "button",
|
|
5698
|
+
className: "univer-bases-icon-btn",
|
|
5699
|
+
onClick: () => setConditions((prev) => prev.filter((c) => c.id !== cnd.id)),
|
|
5700
|
+
children: /* @__PURE__ */ jsx18(BaseTrashIcon, {})
|
|
5701
|
+
}
|
|
5702
|
+
)
|
|
5703
|
+
] }, cnd.id)) })
|
|
5704
|
+
] }),
|
|
5705
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-auto-stage-card", children: [
|
|
5706
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-auto-stage-title", children: [
|
|
5707
|
+
"3. \u591A\u6B65\u6267\u884C\u52A8\u4F5C\u6D41\u6C34\u7EBF (",
|
|
5708
|
+
steps.length,
|
|
5709
|
+
" \u4E2A\u6B65\u9AA4)"
|
|
5710
|
+
] }),
|
|
5711
|
+
/* @__PURE__ */ jsx18("div", { className: "univer-bases-auto-step-list", children: steps.map((step, idx) => {
|
|
5712
|
+
const targetTbl = step.targetTableId ? snapshot.tables[step.targetTableId] : currentTable;
|
|
5713
|
+
const targetTblFields = targetTbl ? targetTbl.fieldOrder.map((fid) => targetTbl.fields[fid]).filter(Boolean) : [];
|
|
5714
|
+
const updateEntries = Object.entries(step.fieldUpdates ?? {});
|
|
5715
|
+
const firstUpdateFid = updateEntries[0]?.[0] ?? currentFields[0]?.id ?? "";
|
|
5716
|
+
const firstUpdateVal = String(updateEntries[0]?.[1] ?? "");
|
|
5717
|
+
const createEntries = Object.entries(step.recordCells ?? {});
|
|
5718
|
+
const firstCreateFid = createEntries[0]?.[0] ?? targetTblFields[0]?.id ?? "";
|
|
5719
|
+
const firstCreateVal = String(createEntries[0]?.[1] ?? "");
|
|
5720
|
+
const ifCond = step.conditions?.[0];
|
|
5721
|
+
return /* @__PURE__ */ jsxs18(
|
|
5722
|
+
"div",
|
|
5723
|
+
{
|
|
5724
|
+
className: "univer-bases-auto-step-card",
|
|
5725
|
+
"data-testid": `bases-auto-step-${idx}`,
|
|
5726
|
+
children: [
|
|
5727
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", style: { justifyContent: "space-between", width: "100%" }, children: [
|
|
5728
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", children: [
|
|
5729
|
+
/* @__PURE__ */ jsx18("span", { className: "univer-bases-badge-count", children: idx + 1 }),
|
|
5730
|
+
/* @__PURE__ */ jsx18("strong", { children: STEP_TYPE_LABELS[step.type] ?? step.type })
|
|
5731
|
+
] }),
|
|
5732
|
+
/* @__PURE__ */ jsx18(
|
|
5733
|
+
"button",
|
|
5734
|
+
{
|
|
5735
|
+
type: "button",
|
|
5736
|
+
className: "univer-bases-icon-btn",
|
|
5737
|
+
onClick: () => setSteps((prev) => prev.filter((_, i) => i !== idx)),
|
|
5738
|
+
children: /* @__PURE__ */ jsx18(BaseTrashIcon, {})
|
|
5739
|
+
}
|
|
5740
|
+
)
|
|
5741
|
+
] }),
|
|
5742
|
+
step.type === "updateRecord" && /* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-row", style: { marginTop: 6 }, children: [
|
|
5743
|
+
/* @__PURE__ */ jsx18(
|
|
5744
|
+
"select",
|
|
5745
|
+
{
|
|
5746
|
+
className: "univer-bases-select",
|
|
5747
|
+
value: firstUpdateFid,
|
|
5748
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5749
|
+
fieldUpdates: { [e.target.value]: firstUpdateVal }
|
|
5750
|
+
}),
|
|
5751
|
+
children: currentFields.map((f) => /* @__PURE__ */ jsx18("option", { value: f.id, children: f.name }, f.id))
|
|
5752
|
+
}
|
|
5753
|
+
),
|
|
5754
|
+
/* @__PURE__ */ jsx18(
|
|
5755
|
+
"input",
|
|
5756
|
+
{
|
|
5757
|
+
type: "text",
|
|
5758
|
+
className: "univer-bases-input",
|
|
5759
|
+
placeholder: "\u5199\u5165\u503C\uFF0C\u652F\u6301 {\u5B57\u6BB5\u540D} \u6216 =\u516C\u5F0F...",
|
|
5760
|
+
value: firstUpdateVal,
|
|
5761
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5762
|
+
fieldUpdates: { [firstUpdateFid]: e.target.value }
|
|
5763
|
+
})
|
|
5764
|
+
}
|
|
5765
|
+
)
|
|
5766
|
+
] }),
|
|
5767
|
+
step.type === "createLinkedRecord" && /* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-list", style: { marginTop: 6 }, children: [
|
|
5768
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-row", children: [
|
|
5769
|
+
/* @__PURE__ */ jsx18("span", { className: "univer-bases-muted-key", children: "\u76EE\u6807\u8868:" }),
|
|
5770
|
+
/* @__PURE__ */ jsx18(
|
|
5771
|
+
"select",
|
|
5772
|
+
{
|
|
5773
|
+
className: "univer-bases-select",
|
|
5774
|
+
value: step.targetTableId ?? "",
|
|
5775
|
+
onChange: (e) => updateStepAt(idx, { targetTableId: e.target.value }),
|
|
5776
|
+
children: tables.map((t) => /* @__PURE__ */ jsx18("option", { value: t.id, children: t.name }, t.id))
|
|
5777
|
+
}
|
|
5778
|
+
)
|
|
5779
|
+
] }),
|
|
5780
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-row", children: [
|
|
5781
|
+
/* @__PURE__ */ jsx18(
|
|
5782
|
+
"select",
|
|
5783
|
+
{
|
|
5784
|
+
className: "univer-bases-select",
|
|
5785
|
+
value: firstCreateFid,
|
|
5786
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5787
|
+
recordCells: { [e.target.value]: firstCreateVal }
|
|
5788
|
+
}),
|
|
5789
|
+
children: targetTblFields.map((f) => /* @__PURE__ */ jsx18("option", { value: f.id, children: f.name }, f.id))
|
|
5790
|
+
}
|
|
5791
|
+
),
|
|
5792
|
+
/* @__PURE__ */ jsx18(
|
|
5793
|
+
"input",
|
|
5794
|
+
{
|
|
5795
|
+
type: "text",
|
|
5796
|
+
className: "univer-bases-input",
|
|
5797
|
+
placeholder: "\u5173\u8054\u65B0\u8BB0\u5F55\u6807\u9898/\u6A21\u677F\uFF0C\u5982 {\u4EFB\u52A1\u6807\u9898}...",
|
|
5798
|
+
value: firstCreateVal,
|
|
5799
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5800
|
+
recordCells: { [firstCreateFid]: e.target.value }
|
|
5801
|
+
})
|
|
5802
|
+
}
|
|
5803
|
+
)
|
|
5804
|
+
] })
|
|
5805
|
+
] }),
|
|
5806
|
+
step.type === "ifElse" && /* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-list", style: { marginTop: 6 }, children: [
|
|
5807
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-row", children: [
|
|
5808
|
+
/* @__PURE__ */ jsx18("span", { className: "univer-bases-muted-key", children: "\u82E5:" }),
|
|
5809
|
+
/* @__PURE__ */ jsx18(
|
|
5810
|
+
"select",
|
|
5811
|
+
{
|
|
5812
|
+
className: "univer-bases-select",
|
|
5813
|
+
value: ifCond?.fieldId ?? currentFields[0]?.id ?? "",
|
|
5814
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5815
|
+
conditions: [
|
|
5816
|
+
{
|
|
5817
|
+
id: ifCond?.id ?? `ifc_${generateRandomId5(4)}`,
|
|
5818
|
+
fieldId: e.target.value,
|
|
5819
|
+
operator: ifCond?.operator ?? "is",
|
|
5820
|
+
value: ifCond?.value ?? ""
|
|
5821
|
+
}
|
|
5822
|
+
]
|
|
5823
|
+
}),
|
|
5824
|
+
children: currentFields.map((f) => /* @__PURE__ */ jsx18("option", { value: f.id, children: f.name }, f.id))
|
|
5825
|
+
}
|
|
5826
|
+
),
|
|
5827
|
+
/* @__PURE__ */ jsx18(
|
|
5828
|
+
"select",
|
|
5829
|
+
{
|
|
5830
|
+
className: "univer-bases-select univer-bases-select--xs",
|
|
5831
|
+
value: ifCond?.operator ?? "is",
|
|
5832
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5833
|
+
conditions: [
|
|
5834
|
+
{
|
|
5835
|
+
id: ifCond?.id ?? `ifc_${generateRandomId5(4)}`,
|
|
5836
|
+
fieldId: ifCond?.fieldId ?? currentFields[0]?.id ?? "",
|
|
5837
|
+
operator: e.target.value,
|
|
5838
|
+
value: ifCond?.value ?? ""
|
|
5839
|
+
}
|
|
5840
|
+
]
|
|
5841
|
+
}),
|
|
5842
|
+
children: OPERATOR_OPTIONS.map((op) => /* @__PURE__ */ jsx18("option", { value: op.value, children: op.label }, op.value))
|
|
5843
|
+
}
|
|
5844
|
+
),
|
|
5845
|
+
/* @__PURE__ */ jsx18(
|
|
5846
|
+
"input",
|
|
5847
|
+
{
|
|
5848
|
+
type: "text",
|
|
5849
|
+
className: "univer-bases-input",
|
|
5850
|
+
placeholder: "\u6BD4\u8F83\u503C...",
|
|
5851
|
+
value: String(ifCond?.value ?? ""),
|
|
5852
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5853
|
+
conditions: [
|
|
5854
|
+
{
|
|
5855
|
+
id: ifCond?.id ?? `ifc_${generateRandomId5(4)}`,
|
|
5856
|
+
fieldId: ifCond?.fieldId ?? currentFields[0]?.id ?? "",
|
|
5857
|
+
operator: ifCond?.operator ?? "is",
|
|
5858
|
+
value: e.target.value
|
|
5859
|
+
}
|
|
5860
|
+
]
|
|
5861
|
+
})
|
|
5862
|
+
}
|
|
5863
|
+
)
|
|
5864
|
+
] }),
|
|
5865
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-muted-key", children: [
|
|
5866
|
+
"\u6EE1\u8DB3\u6761\u4EF6\u6267\u884C Then \u5206\u652F (",
|
|
5867
|
+
step.thenSteps?.length ?? 0,
|
|
5868
|
+
" \u6B65) / \u5426\u5219\u6267\u884C Else \u5206\u652F (",
|
|
5869
|
+
step.elseSteps?.length ?? 0,
|
|
5870
|
+
" \u6B65)"
|
|
5871
|
+
] })
|
|
5872
|
+
] }),
|
|
5873
|
+
step.type === "httpWebhook" && /* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-list", style: { marginTop: 6 }, children: [
|
|
5874
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-rule-row", children: [
|
|
5875
|
+
/* @__PURE__ */ jsxs18(
|
|
5876
|
+
"select",
|
|
5877
|
+
{
|
|
5878
|
+
className: "univer-bases-select univer-bases-select--xs",
|
|
5879
|
+
value: step.webhookMethod ?? "POST",
|
|
5880
|
+
onChange: (e) => updateStepAt(idx, {
|
|
5881
|
+
webhookMethod: e.target.value
|
|
5882
|
+
}),
|
|
5883
|
+
children: [
|
|
5884
|
+
/* @__PURE__ */ jsx18("option", { value: "POST", children: "POST" }),
|
|
5885
|
+
/* @__PURE__ */ jsx18("option", { value: "PUT", children: "PUT" }),
|
|
5886
|
+
/* @__PURE__ */ jsx18("option", { value: "GET", children: "GET" })
|
|
5887
|
+
]
|
|
5888
|
+
}
|
|
5889
|
+
),
|
|
5890
|
+
/* @__PURE__ */ jsx18(
|
|
5891
|
+
"input",
|
|
5892
|
+
{
|
|
5893
|
+
type: "text",
|
|
5894
|
+
className: "univer-bases-input",
|
|
5895
|
+
placeholder: "https://api.example.com/webhook",
|
|
5896
|
+
value: step.webhookUrl ?? "",
|
|
5897
|
+
onChange: (e) => updateStepAt(idx, { webhookUrl: e.target.value })
|
|
5898
|
+
}
|
|
5899
|
+
)
|
|
5900
|
+
] }),
|
|
5901
|
+
/* @__PURE__ */ jsx18(
|
|
5902
|
+
"textarea",
|
|
5903
|
+
{
|
|
5904
|
+
className: "univer-bases-textarea",
|
|
5905
|
+
rows: 2,
|
|
5906
|
+
placeholder: "JSON \u8BF7\u6C42\u4F53\u6A21\u677F\uFF0C\u652F\u6301 {\u5B57\u6BB5\u540D} \u53D8\u91CF",
|
|
5907
|
+
value: typeof step.webhookBodyTemplate === "string" ? step.webhookBodyTemplate : JSON.stringify(step.webhookBodyTemplate ?? {}),
|
|
5908
|
+
onChange: (e) => updateStepAt(idx, { webhookBodyTemplate: e.target.value })
|
|
5909
|
+
}
|
|
5910
|
+
)
|
|
5911
|
+
] })
|
|
5912
|
+
]
|
|
5913
|
+
},
|
|
5914
|
+
step.id
|
|
5915
|
+
);
|
|
5916
|
+
}) }),
|
|
5917
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-inline-flex", style: { marginTop: 10, flexWrap: "wrap" }, children: [
|
|
5918
|
+
/* @__PURE__ */ jsxs18(
|
|
5919
|
+
"button",
|
|
5920
|
+
{
|
|
5921
|
+
type: "button",
|
|
5922
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
5923
|
+
onClick: () => addStep("updateRecord"),
|
|
5924
|
+
children: [
|
|
5925
|
+
/* @__PURE__ */ jsx18(BasePlusIcon, {}),
|
|
5926
|
+
/* @__PURE__ */ jsx18("span", { children: "\u4FEE\u6539\u8BB0\u5F55" })
|
|
5927
|
+
]
|
|
5928
|
+
}
|
|
5929
|
+
),
|
|
5930
|
+
/* @__PURE__ */ jsxs18(
|
|
5931
|
+
"button",
|
|
5932
|
+
{
|
|
5933
|
+
type: "button",
|
|
5934
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
5935
|
+
onClick: () => addStep("createLinkedRecord"),
|
|
5936
|
+
children: [
|
|
5937
|
+
/* @__PURE__ */ jsx18(BasePlusIcon, {}),
|
|
5938
|
+
/* @__PURE__ */ jsx18("span", { children: "\u65B0\u5EFA\u5173\u8054\u8BB0\u5F55" })
|
|
5939
|
+
]
|
|
5940
|
+
}
|
|
5941
|
+
),
|
|
5942
|
+
/* @__PURE__ */ jsxs18(
|
|
5943
|
+
"button",
|
|
5944
|
+
{
|
|
5945
|
+
type: "button",
|
|
5946
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
5947
|
+
onClick: () => addStep("ifElse"),
|
|
5948
|
+
children: [
|
|
5949
|
+
/* @__PURE__ */ jsx18(BasePlusIcon, {}),
|
|
5950
|
+
/* @__PURE__ */ jsx18("span", { children: "If/Else \u5206\u652F" })
|
|
5951
|
+
]
|
|
5952
|
+
}
|
|
5953
|
+
),
|
|
5954
|
+
/* @__PURE__ */ jsxs18(
|
|
5955
|
+
"button",
|
|
5956
|
+
{
|
|
5957
|
+
type: "button",
|
|
5958
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
5959
|
+
onClick: () => addStep("httpWebhook"),
|
|
5960
|
+
children: [
|
|
5961
|
+
/* @__PURE__ */ jsx18(BasePlusIcon, {}),
|
|
5962
|
+
/* @__PURE__ */ jsx18("span", { children: "\u53D1\u9001 Webhook" })
|
|
5963
|
+
]
|
|
5964
|
+
}
|
|
5965
|
+
)
|
|
5966
|
+
] })
|
|
5967
|
+
] })
|
|
5968
|
+
] }),
|
|
5969
|
+
/* @__PURE__ */ jsxs18("div", { className: "univer-bases-popover__footer", children: [
|
|
5970
|
+
/* @__PURE__ */ jsxs18(
|
|
5971
|
+
"button",
|
|
5972
|
+
{
|
|
5973
|
+
type: "button",
|
|
5974
|
+
className: "univer-bases-btn univer-bases-btn--outline univer-bases-btn--sm",
|
|
5975
|
+
"data-testid": "bases-auto-dry-run-btn",
|
|
5976
|
+
onClick: handleSaveAndDryRun,
|
|
5977
|
+
children: [
|
|
5978
|
+
/* @__PURE__ */ jsx18(BasePlayIcon, {}),
|
|
5979
|
+
/* @__PURE__ */ jsx18("span", { children: "\u7ACB\u5373\u8BD5\u8FD0\u884C" })
|
|
5980
|
+
]
|
|
5981
|
+
}
|
|
5982
|
+
),
|
|
5983
|
+
/* @__PURE__ */ jsx18(
|
|
5984
|
+
"button",
|
|
5985
|
+
{
|
|
5986
|
+
type: "button",
|
|
5987
|
+
className: "univer-bases-btn univer-bases-btn--primary univer-bases-btn--sm",
|
|
5988
|
+
"data-testid": "bases-auto-save-btn",
|
|
5989
|
+
onClick: handleSave,
|
|
5990
|
+
children: "\u4FDD\u5B58\u81EA\u52A8\u5316\u6D41\u7A0B"
|
|
5991
|
+
}
|
|
5992
|
+
)
|
|
5993
|
+
] })
|
|
5994
|
+
]
|
|
5995
|
+
}
|
|
5996
|
+
) });
|
|
5997
|
+
};
|
|
5998
|
+
|
|
5999
|
+
// src/views/modals/BasesModalsHost.tsx
|
|
6000
|
+
import { jsx as jsx19, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4287
6001
|
function triggerBrowserDownload(content, fileName, mimeType) {
|
|
4288
6002
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
4289
6003
|
const blob = typeof content === "string" ? new Blob([content], { type: mimeType }) : new Blob([content], { type: mimeType });
|
|
@@ -4298,9 +6012,9 @@ function triggerBrowserDownload(content, fileName, mimeType) {
|
|
|
4298
6012
|
}
|
|
4299
6013
|
var BasesModalsHost = () => {
|
|
4300
6014
|
const { unit, snapshot, commandService, selectionService, selectionState } = useActiveBaseWorkspace();
|
|
4301
|
-
const [csvPasteText, setCsvPasteText] =
|
|
4302
|
-
const [pickerSearch, setPickerSearch] =
|
|
4303
|
-
const [importError, setImportError] =
|
|
6015
|
+
const [csvPasteText, setCsvPasteText] = useState12("");
|
|
6016
|
+
const [pickerSearch, setPickerSearch] = useState12("");
|
|
6017
|
+
const [importError, setImportError] = useState12(null);
|
|
4304
6018
|
if (!unit || !snapshot || !selectionState.activeModal) return null;
|
|
4305
6019
|
const unitId = unit.getUnitId();
|
|
4306
6020
|
const activeTable = unit.getActiveTable();
|
|
@@ -4334,7 +6048,7 @@ var BasesModalsHost = () => {
|
|
|
4334
6048
|
} else {
|
|
4335
6049
|
nextIds = exists ? [] : [targetRecId];
|
|
4336
6050
|
}
|
|
4337
|
-
commandService.syncExecuteCommand(
|
|
6051
|
+
commandService.syncExecuteCommand(UpdateBaseRecordCommand5.id, {
|
|
4338
6052
|
unitId,
|
|
4339
6053
|
tableId: session.tableId,
|
|
4340
6054
|
recordId: session.recordId,
|
|
@@ -4344,23 +6058,23 @@ var BasesModalsHost = () => {
|
|
|
4344
6058
|
closeModal();
|
|
4345
6059
|
}
|
|
4346
6060
|
};
|
|
4347
|
-
return /* @__PURE__ */
|
|
6061
|
+
return /* @__PURE__ */ jsx19("div", { className: "univer-bases-modal-backdrop", onClick: closeModal, children: /* @__PURE__ */ jsxs19(
|
|
4348
6062
|
"div",
|
|
4349
6063
|
{
|
|
4350
6064
|
className: "univer-bases-modal",
|
|
4351
6065
|
"data-testid": "bases-link-picker-modal",
|
|
4352
6066
|
onClick: (e) => e.stopPropagation(),
|
|
4353
6067
|
children: [
|
|
4354
|
-
/* @__PURE__ */
|
|
4355
|
-
/* @__PURE__ */
|
|
6068
|
+
/* @__PURE__ */ jsxs19("div", { className: "univer-bases-popover__header", children: [
|
|
6069
|
+
/* @__PURE__ */ jsxs19("strong", { children: [
|
|
4356
6070
|
"\u9009\u62E9\u5173\u8054\u8BB0\u5F55 \xB7 ",
|
|
4357
6071
|
targetTable.name
|
|
4358
6072
|
] }),
|
|
4359
|
-
/* @__PURE__ */
|
|
6073
|
+
/* @__PURE__ */ jsx19("button", { type: "button", className: "univer-bases-icon-btn", onClick: closeModal, children: /* @__PURE__ */ jsx19(BaseCloseIcon, {}) })
|
|
4360
6074
|
] }),
|
|
4361
|
-
/* @__PURE__ */
|
|
4362
|
-
/* @__PURE__ */
|
|
4363
|
-
/* @__PURE__ */
|
|
6075
|
+
/* @__PURE__ */ jsxs19("div", { className: "univer-bases-search-box", style: { marginBottom: 10 }, children: [
|
|
6076
|
+
/* @__PURE__ */ jsx19(BaseSearchIcon, {}),
|
|
6077
|
+
/* @__PURE__ */ jsx19(
|
|
4364
6078
|
"input",
|
|
4365
6079
|
{
|
|
4366
6080
|
type: "text",
|
|
@@ -4370,16 +6084,16 @@ var BasesModalsHost = () => {
|
|
|
4370
6084
|
}
|
|
4371
6085
|
)
|
|
4372
6086
|
] }),
|
|
4373
|
-
/* @__PURE__ */
|
|
6087
|
+
/* @__PURE__ */ jsx19("div", { className: "univer-bases-picker-list", children: candidateRecords.map((item) => {
|
|
4374
6088
|
const selected = currentIds.includes(item.id);
|
|
4375
|
-
return /* @__PURE__ */
|
|
6089
|
+
return /* @__PURE__ */ jsxs19(
|
|
4376
6090
|
"div",
|
|
4377
6091
|
{
|
|
4378
6092
|
className: `univer-bases-picker-item ${selected ? "is-selected" : ""}`,
|
|
4379
6093
|
onClick: () => toggleTargetRecord(item.id),
|
|
4380
6094
|
children: [
|
|
4381
|
-
/* @__PURE__ */
|
|
4382
|
-
selected && /* @__PURE__ */
|
|
6095
|
+
/* @__PURE__ */ jsx19("span", { children: item.title }),
|
|
6096
|
+
selected && /* @__PURE__ */ jsx19(BaseCheckIcon, {})
|
|
4383
6097
|
]
|
|
4384
6098
|
},
|
|
4385
6099
|
item.id
|
|
@@ -4432,22 +6146,22 @@ var BasesModalsHost = () => {
|
|
|
4432
6146
|
setImportError(err instanceof Error ? err.message : "\u5BFC\u5165\u6587\u4EF6\u89E3\u6790\u5931\u8D25");
|
|
4433
6147
|
}
|
|
4434
6148
|
};
|
|
4435
|
-
return /* @__PURE__ */
|
|
6149
|
+
return /* @__PURE__ */ jsx19("div", { className: "univer-bases-modal-backdrop", onClick: closeModal, children: /* @__PURE__ */ jsxs19(
|
|
4436
6150
|
"div",
|
|
4437
6151
|
{
|
|
4438
6152
|
className: "univer-bases-modal",
|
|
4439
6153
|
"data-testid": "bases-import-modal",
|
|
4440
6154
|
onClick: (e) => e.stopPropagation(),
|
|
4441
6155
|
children: [
|
|
4442
|
-
/* @__PURE__ */
|
|
4443
|
-
/* @__PURE__ */
|
|
4444
|
-
/* @__PURE__ */
|
|
6156
|
+
/* @__PURE__ */ jsxs19("div", { className: "univer-bases-popover__header", children: [
|
|
6157
|
+
/* @__PURE__ */ jsx19("strong", { children: "\u5BFC\u5165\u591A\u7EF4\u6570\u636E\u8868 (.xlsx / .csv / .tsv)" }),
|
|
6158
|
+
/* @__PURE__ */ jsx19("button", { type: "button", className: "univer-bases-icon-btn", onClick: closeModal, children: /* @__PURE__ */ jsx19(BaseCloseIcon, {}) })
|
|
4445
6159
|
] }),
|
|
4446
|
-
importError && /* @__PURE__ */
|
|
4447
|
-
/* @__PURE__ */
|
|
4448
|
-
/* @__PURE__ */
|
|
4449
|
-
/* @__PURE__ */
|
|
4450
|
-
/* @__PURE__ */
|
|
6160
|
+
importError && /* @__PURE__ */ jsx19("div", { className: "univer-bases-alert-error", children: importError }),
|
|
6161
|
+
/* @__PURE__ */ jsxs19("label", { className: "univer-bases-upload-dropzone", children: [
|
|
6162
|
+
/* @__PURE__ */ jsx19(BaseUploadIcon, {}),
|
|
6163
|
+
/* @__PURE__ */ jsx19("span", { children: "\u70B9\u51FB\u9009\u62E9\u672C\u5730 .xlsx \u5DE5\u4F5C\u7C3F\u6216 .csv/.tsv \u8868\u683C\u6587\u4EF6" }),
|
|
6164
|
+
/* @__PURE__ */ jsx19(
|
|
4451
6165
|
"input",
|
|
4452
6166
|
{
|
|
4453
6167
|
type: "file",
|
|
@@ -4460,9 +6174,9 @@ var BasesModalsHost = () => {
|
|
|
4460
6174
|
}
|
|
4461
6175
|
)
|
|
4462
6176
|
] }),
|
|
4463
|
-
/* @__PURE__ */
|
|
4464
|
-
/* @__PURE__ */
|
|
4465
|
-
/* @__PURE__ */
|
|
6177
|
+
/* @__PURE__ */ jsxs19("div", { className: "univer-bases-form-row", style: { marginTop: 12 }, children: [
|
|
6178
|
+
/* @__PURE__ */ jsx19("label", { children: "\u6216\u76F4\u63A5\u7C98\u8D34 CSV \u6587\u672C\u5FEB\u901F\u5EFA\u8868" }),
|
|
6179
|
+
/* @__PURE__ */ jsx19(
|
|
4466
6180
|
"textarea",
|
|
4467
6181
|
{
|
|
4468
6182
|
className: "univer-bases-textarea",
|
|
@@ -4473,7 +6187,7 @@ var BasesModalsHost = () => {
|
|
|
4473
6187
|
}
|
|
4474
6188
|
)
|
|
4475
6189
|
] }),
|
|
4476
|
-
/* @__PURE__ */
|
|
6190
|
+
/* @__PURE__ */ jsx19("div", { className: "univer-bases-popover__footer", children: /* @__PURE__ */ jsx19(
|
|
4477
6191
|
"button",
|
|
4478
6192
|
{
|
|
4479
6193
|
type: "button",
|
|
@@ -4504,19 +6218,19 @@ var BasesModalsHost = () => {
|
|
|
4504
6218
|
) });
|
|
4505
6219
|
}
|
|
4506
6220
|
if (selectionState.activeModal === "export") {
|
|
4507
|
-
return /* @__PURE__ */
|
|
6221
|
+
return /* @__PURE__ */ jsx19("div", { className: "univer-bases-modal-backdrop", onClick: closeModal, children: /* @__PURE__ */ jsxs19(
|
|
4508
6222
|
"div",
|
|
4509
6223
|
{
|
|
4510
6224
|
className: "univer-bases-modal",
|
|
4511
6225
|
"data-testid": "bases-export-modal",
|
|
4512
6226
|
onClick: (e) => e.stopPropagation(),
|
|
4513
6227
|
children: [
|
|
4514
|
-
/* @__PURE__ */
|
|
4515
|
-
/* @__PURE__ */
|
|
4516
|
-
/* @__PURE__ */
|
|
6228
|
+
/* @__PURE__ */ jsxs19("div", { className: "univer-bases-popover__header", children: [
|
|
6229
|
+
/* @__PURE__ */ jsx19("strong", { children: "\u5BFC\u51FA\u591A\u7EF4\u6570\u636E\u8868" }),
|
|
6230
|
+
/* @__PURE__ */ jsx19("button", { type: "button", className: "univer-bases-icon-btn", onClick: closeModal, children: /* @__PURE__ */ jsx19(BaseCloseIcon, {}) })
|
|
4517
6231
|
] }),
|
|
4518
|
-
/* @__PURE__ */
|
|
4519
|
-
/* @__PURE__ */
|
|
6232
|
+
/* @__PURE__ */ jsxs19("div", { className: "univer-bases-export-options", children: [
|
|
6233
|
+
/* @__PURE__ */ jsxs19(
|
|
4520
6234
|
"button",
|
|
4521
6235
|
{
|
|
4522
6236
|
type: "button",
|
|
@@ -4531,10 +6245,10 @@ var BasesModalsHost = () => {
|
|
|
4531
6245
|
closeModal();
|
|
4532
6246
|
},
|
|
4533
6247
|
children: [
|
|
4534
|
-
/* @__PURE__ */
|
|
4535
|
-
/* @__PURE__ */
|
|
4536
|
-
/* @__PURE__ */
|
|
4537
|
-
/* @__PURE__ */
|
|
6248
|
+
/* @__PURE__ */ jsx19(BaseDownloadIcon, {}),
|
|
6249
|
+
/* @__PURE__ */ jsxs19("div", { children: [
|
|
6250
|
+
/* @__PURE__ */ jsx19("strong", { children: "\u5BFC\u51FA\u5168\u5E93\u4E3A\u591A\u5DE5\u4F5C\u8868 Excel (.xlsx)" }),
|
|
6251
|
+
/* @__PURE__ */ jsxs19("p", { children: [
|
|
4538
6252
|
"\u5C06\u5168\u90E8 ",
|
|
4539
6253
|
snapshot.tableOrder.length,
|
|
4540
6254
|
" \u5F20\u5173\u8054\u6570\u636E\u8868\u5BFC\u51FA\u4E3A\u5E26\u8868\u5934\u6837\u5F0F\u7684\u6807\u51C6 OpenXML \u5DE5\u4F5C\u7C3F"
|
|
@@ -4543,7 +6257,7 @@ var BasesModalsHost = () => {
|
|
|
4543
6257
|
]
|
|
4544
6258
|
}
|
|
4545
6259
|
),
|
|
4546
|
-
activeTable && /* @__PURE__ */
|
|
6260
|
+
activeTable && /* @__PURE__ */ jsxs19(
|
|
4547
6261
|
"button",
|
|
4548
6262
|
{
|
|
4549
6263
|
type: "button",
|
|
@@ -4560,14 +6274,14 @@ var BasesModalsHost = () => {
|
|
|
4560
6274
|
closeModal();
|
|
4561
6275
|
},
|
|
4562
6276
|
children: [
|
|
4563
|
-
/* @__PURE__ */
|
|
4564
|
-
/* @__PURE__ */
|
|
4565
|
-
/* @__PURE__ */
|
|
6277
|
+
/* @__PURE__ */ jsx19(BaseDownloadIcon, {}),
|
|
6278
|
+
/* @__PURE__ */ jsxs19("div", { children: [
|
|
6279
|
+
/* @__PURE__ */ jsxs19("strong", { children: [
|
|
4566
6280
|
"\u5BFC\u51FA\u5F53\u524D\u8868\u300C",
|
|
4567
6281
|
activeTable.name,
|
|
4568
6282
|
"\u300D\u4E3A CSV (.csv)"
|
|
4569
6283
|
] }),
|
|
4570
|
-
/* @__PURE__ */
|
|
6284
|
+
/* @__PURE__ */ jsx19("p", { children: "\u9075\u5FAA RFC-4180 \u6807\u51C6\uFF0C\u5305\u542B UTF-8 BOM \u4EE5\u517C\u5BB9\u684C\u9762\u8868\u683C\u8F6F\u4EF6" })
|
|
4571
6285
|
] })
|
|
4572
6286
|
]
|
|
4573
6287
|
}
|
|
@@ -4577,6 +6291,9 @@ var BasesModalsHost = () => {
|
|
|
4577
6291
|
}
|
|
4578
6292
|
) });
|
|
4579
6293
|
}
|
|
6294
|
+
if (selectionState.activeModal === "automationBuilder") {
|
|
6295
|
+
return /* @__PURE__ */ jsx19(AutomationBuilderModal, {});
|
|
6296
|
+
}
|
|
4580
6297
|
return null;
|
|
4581
6298
|
};
|
|
4582
6299
|
|
|
@@ -4588,8 +6305,8 @@ import {
|
|
|
4588
6305
|
RibbonViewGroup
|
|
4589
6306
|
} from "@univerjs/ui";
|
|
4590
6307
|
import {
|
|
4591
|
-
AddBaseFieldCommand as
|
|
4592
|
-
AddBaseRecordCommand as
|
|
6308
|
+
AddBaseFieldCommand as AddBaseFieldCommand3,
|
|
6309
|
+
AddBaseRecordCommand as AddBaseRecordCommand7,
|
|
4593
6310
|
AddBaseTableCommand as AddBaseTableCommand2
|
|
4594
6311
|
} from "@yudaocode/univer-bases";
|
|
4595
6312
|
function createMenuButton(config) {
|
|
@@ -4610,7 +6327,7 @@ var basesMenuSchema = {
|
|
|
4610
6327
|
order: 1,
|
|
4611
6328
|
menuItemFactory: createMenuButton({
|
|
4612
6329
|
id: "bases-ui.menu.add-record",
|
|
4613
|
-
commandId:
|
|
6330
|
+
commandId: AddBaseRecordCommand7.id,
|
|
4614
6331
|
title: "bases.ribbon.addRecord",
|
|
4615
6332
|
label: "bases.ribbon.addRecord",
|
|
4616
6333
|
icon: "BasePlusIcon"
|
|
@@ -4620,7 +6337,7 @@ var basesMenuSchema = {
|
|
|
4620
6337
|
order: 2,
|
|
4621
6338
|
menuItemFactory: createMenuButton({
|
|
4622
6339
|
id: "bases-ui.menu.add-field",
|
|
4623
|
-
commandId:
|
|
6340
|
+
commandId: AddBaseFieldCommand3.id,
|
|
4624
6341
|
title: "bases.ribbon.addField",
|
|
4625
6342
|
label: "bases.ribbon.addField",
|
|
4626
6343
|
icon: "BaseTableIcon",
|
|
@@ -4676,7 +6393,7 @@ var basesMenuSchema = {
|
|
|
4676
6393
|
order: 1,
|
|
4677
6394
|
menuItemFactory: createMenuButton({
|
|
4678
6395
|
id: "bases-ui.menu.insert-record",
|
|
4679
|
-
commandId:
|
|
6396
|
+
commandId: AddBaseRecordCommand7.id,
|
|
4680
6397
|
title: "bases.ribbon.addRecord",
|
|
4681
6398
|
label: "bases.ribbon.addRecord",
|
|
4682
6399
|
icon: "BasePlusIcon"
|
|
@@ -4704,6 +6421,16 @@ var basesMenuSchema = {
|
|
|
4704
6421
|
params: { viewType: "grid" }
|
|
4705
6422
|
})
|
|
4706
6423
|
},
|
|
6424
|
+
["bases-ui.menu.view-list"]: {
|
|
6425
|
+
order: 1.5,
|
|
6426
|
+
menuItemFactory: createMenuButton({
|
|
6427
|
+
id: "bases-ui.menu.view-list",
|
|
6428
|
+
commandId: SwitchBaseViewTypeOperation.id,
|
|
6429
|
+
title: "bases.ribbon.listView",
|
|
6430
|
+
icon: "BaseListIcon",
|
|
6431
|
+
params: { viewType: "list" }
|
|
6432
|
+
})
|
|
6433
|
+
},
|
|
4707
6434
|
["bases-ui.menu.view-kanban"]: {
|
|
4708
6435
|
order: 2,
|
|
4709
6436
|
menuItemFactory: createMenuButton({
|
|
@@ -4890,11 +6617,13 @@ UniverBasesUIPlugin = __decorateClass([
|
|
|
4890
6617
|
], UniverBasesUIPlugin);
|
|
4891
6618
|
|
|
4892
6619
|
// src/index.ts
|
|
4893
|
-
var VERSION = "1.6.
|
|
6620
|
+
var VERSION = "1.6.219";
|
|
4894
6621
|
export {
|
|
6622
|
+
AutomationBuilderModal,
|
|
4895
6623
|
BASE_ICON_MAP,
|
|
4896
6624
|
BASE_INSPECTOR_COMPONENT_KEY,
|
|
4897
6625
|
BASE_INSPECTOR_SIDEBAR_ID,
|
|
6626
|
+
BaseBoltIcon,
|
|
4898
6627
|
BaseCalendarIcon,
|
|
4899
6628
|
BaseCheckIcon,
|
|
4900
6629
|
BaseChevronDownIcon,
|
|
@@ -4902,8 +6631,10 @@ export {
|
|
|
4902
6631
|
BaseChevronRightIcon,
|
|
4903
6632
|
BaseCloseIcon,
|
|
4904
6633
|
BaseColorIcon,
|
|
6634
|
+
BaseColumnsIcon,
|
|
4905
6635
|
BaseDashboardIcon,
|
|
4906
6636
|
BaseDownloadIcon,
|
|
6637
|
+
BaseEditIcon,
|
|
4907
6638
|
BaseExpandIcon,
|
|
4908
6639
|
BaseFieldTypeIcon,
|
|
4909
6640
|
BaseFilterIcon,
|
|
@@ -4912,9 +6643,13 @@ export {
|
|
|
4912
6643
|
BaseGanttIcon,
|
|
4913
6644
|
BaseGridIcon,
|
|
4914
6645
|
BaseGroupIcon,
|
|
6646
|
+
BaseIndentIcon,
|
|
4915
6647
|
BaseInspectorIcon,
|
|
4916
6648
|
BaseKanbanIcon,
|
|
4917
6649
|
BaseLinkIcon,
|
|
6650
|
+
BaseListIcon,
|
|
6651
|
+
BaseOutdentIcon,
|
|
6652
|
+
BasePlayIcon,
|
|
4918
6653
|
BasePlusIcon,
|
|
4919
6654
|
BaseSearchIcon,
|
|
4920
6655
|
BaseSortIcon,
|
|
@@ -4941,6 +6676,7 @@ export {
|
|
|
4941
6676
|
GridCellEditor,
|
|
4942
6677
|
GridView,
|
|
4943
6678
|
KanbanView,
|
|
6679
|
+
ListView,
|
|
4944
6680
|
LoadBasePresetOperation,
|
|
4945
6681
|
OpenBaseModalOperation,
|
|
4946
6682
|
RecordDetailDrawer,
|