openxiangda 1.0.34 → 1.0.36
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 +18 -0
- package/lib/cli.js +410 -1
- package/lib/workspace-init.js +1 -0
- package/openxiangda-skills/SKILL.md +5 -3
- package/openxiangda-skills/references/best-practices.md +11 -6
- package/openxiangda-skills/references/component-guide.md +10 -11
- package/openxiangda-skills/references/connector-resources.md +3 -0
- package/openxiangda-skills/references/data-views.md +217 -0
- package/openxiangda-skills/references/forms/component-registry.md +4 -3
- package/openxiangda-skills/references/forms/form-schema.md +31 -2
- package/openxiangda-skills/references/pages/page-sdk.md +43 -0
- package/openxiangda-skills/references/style-system.md +14 -18
- package/openxiangda-skills/references/troubleshooting.md +13 -13
- package/openxiangda-skills/references/workspace-state.md +9 -0
- package/openxiangda-skills/skills/openxiangda-form/SKILL.md +3 -3
- package/openxiangda-skills/skills/openxiangda-page/SKILL.md +2 -2
- package/openxiangda-skills/skills/openxiangda-permission-settings/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/sdk/dist/components/index.cjs +944 -765
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +18 -2
- package/packages/sdk/dist/components/index.d.ts +18 -2
- package/packages/sdk/dist/components/index.mjs +938 -761
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/index.cjs +114 -30
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +18 -1
- package/packages/sdk/dist/runtime/index.d.ts +18 -1
- package/packages/sdk/dist/runtime/index.mjs +114 -30
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/styles/antd-theme.cjs +11 -3
- package/packages/sdk/dist/styles/antd-theme.cjs.map +1 -1
- package/packages/sdk/dist/styles/antd-theme.d.mts +2 -1
- package/packages/sdk/dist/styles/antd-theme.d.ts +2 -1
- package/packages/sdk/dist/styles/antd-theme.mjs +11 -3
- package/packages/sdk/dist/styles/antd-theme.mjs.map +1 -1
- package/packages/sdk/dist/styles/tailwind-preset.cjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.cjs.map +1 -1
- package/packages/sdk/dist/styles/tailwind-preset.d.mts +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.d.ts +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.mjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.mjs.map +1 -1
- package/packages/sdk/dist/styles/tokens.css +1 -0
- package/packages/sdk/src/build-source/scripts/build-forms.mjs +135 -50
- package/packages/sdk/src/build-source/scripts/build-pages.mjs +37 -10
- package/packages/sdk/src/build-source/scripts/register.mjs +2 -0
- package/packages/sdk/src/build-source/scripts/utils/form-api.mjs +1 -0
- package/packages/sdk/src/build-source/scripts/utils/load-config.mjs +3 -2
- package/packages/sdk/src/build-source/scripts/utils/register-payload.test.ts +2 -1
- package/packages/sdk/src/build-source/scripts/utils/tailwind-config.mjs +9 -7
- package/packages/sdk/src/build-source/scripts/utils/tailwind-config.test.ts +6 -4
- package/packages/sdk/src/build-source/src/cli.mjs +17 -0
- package/templates/sy-lowcode-app-workspace/app-workspace.config.ts +3 -3
- package/templates/sy-lowcode-app-workspace/examples/best-practices/decision-guide.md +4 -3
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.test.ts +1 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/schema.ts +36 -18
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/schema.ts +36 -18
- package/templates/sy-lowcode-app-workspace/postcss.config.cjs +0 -15
- package/templates/sy-lowcode-app-workspace/src/main.tsx +1 -12
- package/templates/sy-lowcode-app-workspace/src/shared/form-schema.ts +0 -1
|
@@ -964,7 +964,7 @@ init_cjs_shims();
|
|
|
964
964
|
|
|
965
965
|
// packages/sdk/src/components/core/FormProvider.tsx
|
|
966
966
|
init_cjs_shims();
|
|
967
|
-
var
|
|
967
|
+
var import_react252 = __toESM(require("react"));
|
|
968
968
|
|
|
969
969
|
// packages/sdk/src/components/core/FormContext.ts
|
|
970
970
|
init_cjs_shims();
|
|
@@ -29976,10 +29976,11 @@ function TextAreaField(props) {
|
|
|
29976
29976
|
|
|
29977
29977
|
// packages/sdk/src/components/fields/SelectField/index.tsx
|
|
29978
29978
|
init_cjs_shims();
|
|
29979
|
-
var
|
|
29979
|
+
var import_react213 = require("react");
|
|
29980
29980
|
|
|
29981
29981
|
// packages/sdk/src/components/fields/SelectField/SelectFieldPC.tsx
|
|
29982
29982
|
init_cjs_shims();
|
|
29983
|
+
var import_react211 = require("react");
|
|
29983
29984
|
var import_antd5 = require("antd");
|
|
29984
29985
|
|
|
29985
29986
|
// packages/sdk/src/components/fields/shared/optionDisplay.tsx
|
|
@@ -30054,6 +30055,297 @@ function renderReadonlyOptions(options, coloredOptions, tagWhenPlain = false) {
|
|
|
30054
30055
|
) });
|
|
30055
30056
|
}
|
|
30056
30057
|
|
|
30058
|
+
// packages/sdk/src/components/fields/SelectField/useLinkedFormRemoteOptions.ts
|
|
30059
|
+
init_cjs_shims();
|
|
30060
|
+
var import_react210 = require("react");
|
|
30061
|
+
|
|
30062
|
+
// packages/sdk/src/components/core/optionSource.ts
|
|
30063
|
+
init_cjs_shims();
|
|
30064
|
+
var DEFAULT_OPTION_PAGE_SIZE = 200;
|
|
30065
|
+
function getOptionValueFieldId(config3) {
|
|
30066
|
+
return config3.valueFieldId || config3.fieldId;
|
|
30067
|
+
}
|
|
30068
|
+
function getOptionLabelFieldId(config3) {
|
|
30069
|
+
return config3.labelFieldId || config3.fieldId;
|
|
30070
|
+
}
|
|
30071
|
+
function getSearchFieldId(config3) {
|
|
30072
|
+
return config3.searchFieldId || config3.labelFieldId || config3.fieldId;
|
|
30073
|
+
}
|
|
30074
|
+
function readFieldValue(row, fieldId) {
|
|
30075
|
+
if (!fieldId) return void 0;
|
|
30076
|
+
return row?.[fieldId];
|
|
30077
|
+
}
|
|
30078
|
+
function normalizeOptionScalar(rawValue) {
|
|
30079
|
+
if (rawValue === void 0 || rawValue === null || rawValue === "") return null;
|
|
30080
|
+
if (typeof rawValue === "object" && !Array.isArray(rawValue)) {
|
|
30081
|
+
return rawValue.value ?? rawValue.id ?? rawValue.key ?? rawValue.label;
|
|
30082
|
+
}
|
|
30083
|
+
return rawValue;
|
|
30084
|
+
}
|
|
30085
|
+
function normalizeOptionLabel(rawLabel, rawValue, fallbackLabel, value) {
|
|
30086
|
+
if (rawLabel !== void 0 && rawLabel !== null && rawLabel !== "") {
|
|
30087
|
+
if (typeof rawLabel === "object" && !Array.isArray(rawLabel)) {
|
|
30088
|
+
return rawLabel.label ?? rawLabel.name ?? rawLabel.title ?? rawLabel.value ?? value;
|
|
30089
|
+
}
|
|
30090
|
+
return rawLabel;
|
|
30091
|
+
}
|
|
30092
|
+
if (typeof rawValue === "object" && rawValue && !Array.isArray(rawValue)) {
|
|
30093
|
+
return rawValue.label ?? rawValue.name ?? rawValue.title ?? rawValue.value ?? value;
|
|
30094
|
+
}
|
|
30095
|
+
if (fallbackLabel !== void 0 && fallbackLabel !== null && fallbackLabel !== "") {
|
|
30096
|
+
return fallbackLabel;
|
|
30097
|
+
}
|
|
30098
|
+
return value;
|
|
30099
|
+
}
|
|
30100
|
+
function normalizeOptionItem(row, config3) {
|
|
30101
|
+
const normalizedConfig = typeof config3 === "string" ? { fieldId: config3 } : { ...config3, fieldId: config3.fieldId };
|
|
30102
|
+
const valueFieldId = getOptionValueFieldId(normalizedConfig);
|
|
30103
|
+
const labelFieldId = getOptionLabelFieldId(normalizedConfig);
|
|
30104
|
+
const rawValue = readFieldValue(row, valueFieldId) ?? (valueFieldId !== normalizedConfig.fieldId ? readFieldValue(row, normalizedConfig.fieldId) : void 0) ?? row?.value;
|
|
30105
|
+
const value = normalizeOptionScalar(rawValue);
|
|
30106
|
+
if (value === void 0 || value === null || value === "") return null;
|
|
30107
|
+
const rawLabel = labelFieldId === valueFieldId ? void 0 : readFieldValue(row, labelFieldId);
|
|
30108
|
+
const label = normalizeOptionLabel(rawLabel, rawValue, row?.label, value);
|
|
30109
|
+
return {
|
|
30110
|
+
value: String(value),
|
|
30111
|
+
label: String(label ?? value)
|
|
30112
|
+
};
|
|
30113
|
+
}
|
|
30114
|
+
function extractComparableValue(value) {
|
|
30115
|
+
if (value === void 0 || value === null || value === "") return value;
|
|
30116
|
+
if (Array.isArray(value)) {
|
|
30117
|
+
return value.map(extractComparableValue).filter((item) => item !== void 0 && item !== null && item !== "");
|
|
30118
|
+
}
|
|
30119
|
+
if (typeof value === "object") {
|
|
30120
|
+
if ("start" in value || "end" in value) {
|
|
30121
|
+
return [value.start, value.end].filter(
|
|
30122
|
+
(item) => item !== void 0 && item !== null && item !== ""
|
|
30123
|
+
);
|
|
30124
|
+
}
|
|
30125
|
+
return value.value ?? value.id ?? value.key ?? value.userId ?? value.userid ?? value.departmentId ?? value.deptId ?? value.label ?? value.name;
|
|
30126
|
+
}
|
|
30127
|
+
return value;
|
|
30128
|
+
}
|
|
30129
|
+
function normalizeFilterOperator(operator, value) {
|
|
30130
|
+
const normalized = operator === "neq" ? "ne" : operator || "eq";
|
|
30131
|
+
if (Array.isArray(value) && value.length > 0 && (normalized === "eq" || normalized === "contains")) {
|
|
30132
|
+
return "in";
|
|
30133
|
+
}
|
|
30134
|
+
return normalized;
|
|
30135
|
+
}
|
|
30136
|
+
async function resolveOptions(config3, runtime, formData, searchKeyword) {
|
|
30137
|
+
switch (config3.type) {
|
|
30138
|
+
case "custom":
|
|
30139
|
+
return [];
|
|
30140
|
+
// custom 类型直接用 props.options
|
|
30141
|
+
case "linkedForm":
|
|
30142
|
+
if (!config3.linkedForm) return [];
|
|
30143
|
+
return resolveLinkedFormOptions(config3.linkedForm, runtime, searchKeyword);
|
|
30144
|
+
case "dataLinkage":
|
|
30145
|
+
if (!config3.dataLinkage) return [];
|
|
30146
|
+
return resolveDataLinkageOptions(config3.dataLinkage, runtime, formData);
|
|
30147
|
+
default:
|
|
30148
|
+
return [];
|
|
30149
|
+
}
|
|
30150
|
+
}
|
|
30151
|
+
async function resolveLinkedFormOptions(config3, runtime, searchKeyword) {
|
|
30152
|
+
if (!runtime?.fetchFormData) return [];
|
|
30153
|
+
try {
|
|
30154
|
+
const filters = config3.filters?.map((f) => ({
|
|
30155
|
+
fieldId: f.fieldId,
|
|
30156
|
+
operator: normalizeFilterOperator(f.operator, extractComparableValue(f.value)),
|
|
30157
|
+
value: extractComparableValue(f.value)
|
|
30158
|
+
})) || [];
|
|
30159
|
+
const trimmedKeyword = String(searchKeyword || "").trim();
|
|
30160
|
+
if (trimmedKeyword) {
|
|
30161
|
+
filters.push({
|
|
30162
|
+
fieldId: getSearchFieldId(config3),
|
|
30163
|
+
operator: "contains",
|
|
30164
|
+
value: trimmedKeyword
|
|
30165
|
+
});
|
|
30166
|
+
}
|
|
30167
|
+
const result = await runtime.fetchFormData({
|
|
30168
|
+
formUuid: config3.formUuid,
|
|
30169
|
+
appType: runtime.appType || "",
|
|
30170
|
+
filters,
|
|
30171
|
+
sort: config3.sortField ? { field: config3.sortField, order: config3.sortOrder || "asc" } : void 0,
|
|
30172
|
+
fieldId: config3.fieldId,
|
|
30173
|
+
deduplicate: config3.deduplicate,
|
|
30174
|
+
pageSize: config3.pageSize ?? DEFAULT_OPTION_PAGE_SIZE
|
|
30175
|
+
});
|
|
30176
|
+
const items = result.data.map((row) => normalizeOptionItem(row, config3)).filter((item) => Boolean(item));
|
|
30177
|
+
if (config3.deduplicate) {
|
|
30178
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30179
|
+
return items.filter((item) => {
|
|
30180
|
+
if (seen.has(item.value)) return false;
|
|
30181
|
+
seen.add(item.value);
|
|
30182
|
+
return true;
|
|
30183
|
+
});
|
|
30184
|
+
}
|
|
30185
|
+
return items;
|
|
30186
|
+
} catch (e2) {
|
|
30187
|
+
console.error("[FormComponents] resolveLinkedFormOptions failed:", e2);
|
|
30188
|
+
return [];
|
|
30189
|
+
}
|
|
30190
|
+
}
|
|
30191
|
+
async function resolveDataLinkageOptions(config3, runtime, formData) {
|
|
30192
|
+
if (!runtime?.fetchFormData) return [];
|
|
30193
|
+
try {
|
|
30194
|
+
const filters = config3.conditions.map((condition) => {
|
|
30195
|
+
const value = extractComparableValue(formData[condition.localFieldId]);
|
|
30196
|
+
return {
|
|
30197
|
+
fieldId: condition.remoteFieldId,
|
|
30198
|
+
operator: normalizeFilterOperator(condition.operator, value),
|
|
30199
|
+
value
|
|
30200
|
+
};
|
|
30201
|
+
});
|
|
30202
|
+
const result = await runtime.fetchFormData({
|
|
30203
|
+
formUuid: config3.formUuid,
|
|
30204
|
+
appType: runtime.appType || "",
|
|
30205
|
+
filters,
|
|
30206
|
+
conditionLogic: config3.conditionLogic,
|
|
30207
|
+
fieldId: config3.targetFieldId,
|
|
30208
|
+
deduplicate: config3.deduplicate,
|
|
30209
|
+
pageSize: DEFAULT_OPTION_PAGE_SIZE
|
|
30210
|
+
});
|
|
30211
|
+
const items = result.data.map((row) => normalizeOptionItem(row, config3.targetFieldId)).filter((item) => Boolean(item));
|
|
30212
|
+
if (config3.deduplicate) {
|
|
30213
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30214
|
+
return items.filter((item) => {
|
|
30215
|
+
if (seen.has(item.value)) return false;
|
|
30216
|
+
seen.add(item.value);
|
|
30217
|
+
return true;
|
|
30218
|
+
});
|
|
30219
|
+
}
|
|
30220
|
+
return items;
|
|
30221
|
+
} catch (e2) {
|
|
30222
|
+
console.error("[FormComponents] resolveDataLinkageOptions failed:", e2);
|
|
30223
|
+
return [];
|
|
30224
|
+
}
|
|
30225
|
+
}
|
|
30226
|
+
async function resolveDefaultValueLinkage(config3, runtime, formData) {
|
|
30227
|
+
if (!runtime?.fetchFormData) return void 0;
|
|
30228
|
+
try {
|
|
30229
|
+
const filters = config3.conditions.map((condition) => {
|
|
30230
|
+
const value = extractComparableValue(formData[condition.localFieldId]);
|
|
30231
|
+
return {
|
|
30232
|
+
fieldId: condition.remoteFieldId,
|
|
30233
|
+
operator: normalizeFilterOperator(condition.operator, value),
|
|
30234
|
+
value
|
|
30235
|
+
};
|
|
30236
|
+
});
|
|
30237
|
+
const result = await runtime.fetchFormData({
|
|
30238
|
+
formUuid: config3.formUuid,
|
|
30239
|
+
appType: runtime.appType || "",
|
|
30240
|
+
filters,
|
|
30241
|
+
conditionLogic: config3.conditionLogic,
|
|
30242
|
+
fieldId: config3.targetFieldId,
|
|
30243
|
+
pageSize: DEFAULT_OPTION_PAGE_SIZE
|
|
30244
|
+
});
|
|
30245
|
+
if (result.data.length > 0) {
|
|
30246
|
+
return result.data[0][config3.targetFieldId] ?? result.data[0].value ?? void 0;
|
|
30247
|
+
}
|
|
30248
|
+
return void 0;
|
|
30249
|
+
} catch (e2) {
|
|
30250
|
+
console.error("[FormComponents] resolveDefaultValueLinkage failed:", e2);
|
|
30251
|
+
return void 0;
|
|
30252
|
+
}
|
|
30253
|
+
}
|
|
30254
|
+
|
|
30255
|
+
// packages/sdk/src/components/fields/SelectField/useLinkedFormRemoteOptions.ts
|
|
30256
|
+
var DEFAULT_REMOTE_SEARCH_DEBOUNCE_MS = 350;
|
|
30257
|
+
function mergeOptionItems(...groups) {
|
|
30258
|
+
const result = [];
|
|
30259
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30260
|
+
for (const group of groups) {
|
|
30261
|
+
for (const option of group || []) {
|
|
30262
|
+
if (!option || option.value === void 0 || option.value === null) continue;
|
|
30263
|
+
const key = String(option.value);
|
|
30264
|
+
if (seen.has(key)) continue;
|
|
30265
|
+
seen.add(key);
|
|
30266
|
+
result.push(option);
|
|
30267
|
+
}
|
|
30268
|
+
}
|
|
30269
|
+
return result;
|
|
30270
|
+
}
|
|
30271
|
+
function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions) {
|
|
30272
|
+
const { runtime } = useFormContext();
|
|
30273
|
+
const linkedForm = optionSource?.type === "linkedForm" ? optionSource.linkedForm : void 0;
|
|
30274
|
+
const enabled = Boolean(linkedForm?.remoteSearch);
|
|
30275
|
+
const minChars = linkedForm?.remoteSearchMinChars ?? 0;
|
|
30276
|
+
const [remoteOptions, setRemoteOptions] = (0, import_react210.useState)(null);
|
|
30277
|
+
const [loading, setLoading] = (0, import_react210.useState)(false);
|
|
30278
|
+
const timerRef = (0, import_react210.useRef)(null);
|
|
30279
|
+
const requestRef = (0, import_react210.useRef)(0);
|
|
30280
|
+
const reset = (0, import_react210.useCallback)(() => {
|
|
30281
|
+
requestRef.current += 1;
|
|
30282
|
+
if (timerRef.current) {
|
|
30283
|
+
clearTimeout(timerRef.current);
|
|
30284
|
+
timerRef.current = null;
|
|
30285
|
+
}
|
|
30286
|
+
setRemoteOptions(null);
|
|
30287
|
+
setLoading(false);
|
|
30288
|
+
}, []);
|
|
30289
|
+
const search = (0, import_react210.useCallback)(
|
|
30290
|
+
(keyword) => {
|
|
30291
|
+
if (!enabled || !linkedForm) return;
|
|
30292
|
+
const trimmedKeyword = keyword.trim();
|
|
30293
|
+
if (!trimmedKeyword) {
|
|
30294
|
+
reset();
|
|
30295
|
+
return;
|
|
30296
|
+
}
|
|
30297
|
+
if (trimmedKeyword.length < minChars) {
|
|
30298
|
+
requestRef.current += 1;
|
|
30299
|
+
setRemoteOptions([]);
|
|
30300
|
+
setLoading(false);
|
|
30301
|
+
return;
|
|
30302
|
+
}
|
|
30303
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
30304
|
+
setLoading(true);
|
|
30305
|
+
timerRef.current = setTimeout(() => {
|
|
30306
|
+
const requestId = requestRef.current + 1;
|
|
30307
|
+
requestRef.current = requestId;
|
|
30308
|
+
void resolveLinkedFormOptions(linkedForm, runtime, trimmedKeyword).then((options2) => {
|
|
30309
|
+
if (requestRef.current !== requestId) return;
|
|
30310
|
+
setRemoteOptions(options2);
|
|
30311
|
+
setLoading(false);
|
|
30312
|
+
});
|
|
30313
|
+
}, DEFAULT_REMOTE_SEARCH_DEBOUNCE_MS);
|
|
30314
|
+
},
|
|
30315
|
+
[enabled, linkedForm, minChars, reset, runtime]
|
|
30316
|
+
);
|
|
30317
|
+
(0, import_react210.useEffect)(
|
|
30318
|
+
() => () => {
|
|
30319
|
+
requestRef.current += 1;
|
|
30320
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
30321
|
+
},
|
|
30322
|
+
[]
|
|
30323
|
+
);
|
|
30324
|
+
const options = (0, import_react210.useMemo)(
|
|
30325
|
+
() => mergeOptionItems(remoteOptions ?? baseOptions, selectedOptions),
|
|
30326
|
+
[baseOptions, remoteOptions, selectedOptions]
|
|
30327
|
+
);
|
|
30328
|
+
return {
|
|
30329
|
+
enabled,
|
|
30330
|
+
loading,
|
|
30331
|
+
options,
|
|
30332
|
+
reset,
|
|
30333
|
+
search
|
|
30334
|
+
};
|
|
30335
|
+
}
|
|
30336
|
+
|
|
30337
|
+
// packages/sdk/src/components/fields/SelectField/valueSync.ts
|
|
30338
|
+
init_cjs_shims();
|
|
30339
|
+
function syncSelectValueToFields(valueSync, option, setFieldValue) {
|
|
30340
|
+
if (!valueSync?.length) return;
|
|
30341
|
+
for (const rule of valueSync) {
|
|
30342
|
+
if (!rule.targetFieldId) continue;
|
|
30343
|
+
const valuePath = rule.valuePath || "value";
|
|
30344
|
+
const nextValue = option ? option[valuePath] : rule.emptyValue ?? "";
|
|
30345
|
+
setFieldValue(rule.targetFieldId, nextValue ?? "");
|
|
30346
|
+
}
|
|
30347
|
+
}
|
|
30348
|
+
|
|
30057
30349
|
// packages/sdk/src/components/fields/SelectField/SelectFieldPC.tsx
|
|
30058
30350
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
30059
30351
|
function SelectFieldPC({
|
|
@@ -30071,18 +30363,25 @@ function SelectFieldPC({
|
|
|
30071
30363
|
variant,
|
|
30072
30364
|
size: size2,
|
|
30073
30365
|
coloredOptions,
|
|
30366
|
+
optionSource,
|
|
30367
|
+
valueSync,
|
|
30074
30368
|
onChange
|
|
30075
30369
|
}) {
|
|
30076
30370
|
const { formData, setFieldValue } = useFormContext();
|
|
30077
30371
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
30078
30372
|
const disabled = behavior === "DISABLED";
|
|
30373
|
+
const selectedOptions = (0, import_react211.useMemo)(() => value ? [value] : [], [value]);
|
|
30374
|
+
const remote = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
30375
|
+
const displayOptions = remote.options;
|
|
30079
30376
|
const handleChange = (val) => {
|
|
30080
30377
|
if (val === void 0) {
|
|
30081
30378
|
setFieldValue(fieldId, null);
|
|
30379
|
+
syncSelectValueToFields(valueSync, null, setFieldValue);
|
|
30082
30380
|
onChange?.(null);
|
|
30083
30381
|
} else {
|
|
30084
|
-
const option =
|
|
30382
|
+
const option = displayOptions.find((o) => o.value === val) ?? null;
|
|
30085
30383
|
setFieldValue(fieldId, option);
|
|
30384
|
+
syncSelectValueToFields(valueSync, option, setFieldValue);
|
|
30086
30385
|
onChange?.(option);
|
|
30087
30386
|
}
|
|
30088
30387
|
};
|
|
@@ -30095,14 +30394,17 @@ function SelectFieldPC({
|
|
|
30095
30394
|
placeholder,
|
|
30096
30395
|
disabled,
|
|
30097
30396
|
allowClear,
|
|
30098
|
-
showSearch,
|
|
30099
30397
|
optionFilterProp: optionFilterProp || "label",
|
|
30100
30398
|
optionLabelProp,
|
|
30101
30399
|
placement,
|
|
30102
30400
|
variant,
|
|
30103
30401
|
size: size2,
|
|
30104
|
-
options: toAntdOptions(
|
|
30402
|
+
options: toAntdOptions(displayOptions, coloredOptions),
|
|
30403
|
+
filterOption: remote.enabled ? false : void 0,
|
|
30404
|
+
notFoundContent: remote.loading ? "\u52A0\u8F7D\u4E2D..." : void 0,
|
|
30405
|
+
onSearch: remote.enabled ? remote.search : void 0,
|
|
30105
30406
|
onChange: handleChange,
|
|
30407
|
+
showSearch: remote.enabled || showSearch,
|
|
30106
30408
|
"data-testid": `selectfield-input-${fieldId}`
|
|
30107
30409
|
}
|
|
30108
30410
|
);
|
|
@@ -30110,7 +30412,7 @@ function SelectFieldPC({
|
|
|
30110
30412
|
|
|
30111
30413
|
// packages/sdk/src/components/fields/SelectField/SelectFieldMobile.tsx
|
|
30112
30414
|
init_cjs_shims();
|
|
30113
|
-
var
|
|
30415
|
+
var import_react212 = require("react");
|
|
30114
30416
|
|
|
30115
30417
|
// packages/sdk/src/components/fields/shared/MobileField.tsx
|
|
30116
30418
|
init_cjs_shims();
|
|
@@ -30285,35 +30587,56 @@ function SelectFieldMobile({
|
|
|
30285
30587
|
options,
|
|
30286
30588
|
allowClear,
|
|
30287
30589
|
coloredOptions,
|
|
30590
|
+
optionSource,
|
|
30591
|
+
valueSync,
|
|
30288
30592
|
onChange
|
|
30289
30593
|
}) {
|
|
30290
30594
|
const { formData, setFieldValue } = useFormContext();
|
|
30291
30595
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
30292
30596
|
const disabled = behavior === "DISABLED";
|
|
30293
|
-
const [visible, setVisible] = (0,
|
|
30294
|
-
const [search, setSearch] = (0,
|
|
30295
|
-
const [tempValue, setTempValue] = (0,
|
|
30296
|
-
const
|
|
30597
|
+
const [visible, setVisible] = (0, import_react212.useState)(false);
|
|
30598
|
+
const [search, setSearch] = (0, import_react212.useState)("");
|
|
30599
|
+
const [tempValue, setTempValue] = (0, import_react212.useState)(value ?? null);
|
|
30600
|
+
const selectedOptions = (0, import_react212.useMemo)(() => value ? [value] : tempValue ? [tempValue] : [], [
|
|
30601
|
+
tempValue,
|
|
30602
|
+
value
|
|
30603
|
+
]);
|
|
30604
|
+
const {
|
|
30605
|
+
enabled: remoteEnabled,
|
|
30606
|
+
loading: remoteLoading,
|
|
30607
|
+
options: remoteOptions,
|
|
30608
|
+
reset: resetRemoteOptions,
|
|
30609
|
+
search: searchRemoteOptions
|
|
30610
|
+
} = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
30611
|
+
const filteredOptions = (0, import_react212.useMemo)(() => {
|
|
30612
|
+
if (remoteEnabled) return remoteOptions;
|
|
30297
30613
|
const keyword = search.trim().toLowerCase();
|
|
30298
30614
|
if (!keyword) return options;
|
|
30299
30615
|
return options.filter(
|
|
30300
30616
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
30301
30617
|
);
|
|
30302
|
-
}, [options, search]);
|
|
30618
|
+
}, [options, remoteEnabled, remoteOptions, search]);
|
|
30619
|
+
(0, import_react212.useEffect)(() => {
|
|
30620
|
+
if (!visible || !remoteEnabled) return;
|
|
30621
|
+
searchRemoteOptions(search);
|
|
30622
|
+
}, [remoteEnabled, search, searchRemoteOptions, visible]);
|
|
30303
30623
|
const openSheet = () => {
|
|
30304
30624
|
if (disabled) return;
|
|
30305
30625
|
setTempValue(value ?? null);
|
|
30306
30626
|
setSearch("");
|
|
30627
|
+
resetRemoteOptions();
|
|
30307
30628
|
setVisible(true);
|
|
30308
30629
|
};
|
|
30309
30630
|
const handleConfirm = () => {
|
|
30310
30631
|
setFieldValue(fieldId, tempValue);
|
|
30632
|
+
syncSelectValueToFields(valueSync, tempValue, setFieldValue);
|
|
30311
30633
|
onChange?.(tempValue);
|
|
30312
30634
|
setVisible(false);
|
|
30313
30635
|
};
|
|
30314
30636
|
const handleClear = () => {
|
|
30315
30637
|
setTempValue(null);
|
|
30316
30638
|
setFieldValue(fieldId, null);
|
|
30639
|
+
syncSelectValueToFields(valueSync, null, setFieldValue);
|
|
30317
30640
|
onChange?.(null);
|
|
30318
30641
|
};
|
|
30319
30642
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: inputClassName, "data-testid": `selectfield-input-${fieldId}`, children: [
|
|
@@ -30338,24 +30661,28 @@ function SelectFieldMobile({
|
|
|
30338
30661
|
testId: `selectfield-popup-${fieldId}`,
|
|
30339
30662
|
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "sy-mobile-option-sheet", children: [
|
|
30340
30663
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "sy-mobile-option-search", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MobileSearchBox, { value: search, onChange: setSearch }) }),
|
|
30341
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.
|
|
30342
|
-
|
|
30343
|
-
|
|
30344
|
-
|
|
30345
|
-
|
|
30346
|
-
|
|
30347
|
-
|
|
30348
|
-
|
|
30349
|
-
|
|
30350
|
-
|
|
30351
|
-
|
|
30352
|
-
|
|
30353
|
-
|
|
30354
|
-
|
|
30355
|
-
|
|
30356
|
-
|
|
30357
|
-
|
|
30358
|
-
|
|
30664
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "sy-mobile-option-list", children: [
|
|
30665
|
+
remoteLoading ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "sy-mobile-option-row", children: "\u52A0\u8F7D\u4E2D..." }) : null,
|
|
30666
|
+
!remoteLoading && filteredOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "sy-mobile-option-row", children: "\u6682\u65E0\u6570\u636E" }) : null,
|
|
30667
|
+
!remoteLoading && filteredOptions.map((option) => {
|
|
30668
|
+
const active = tempValue?.value === option.value;
|
|
30669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
30670
|
+
"button",
|
|
30671
|
+
{
|
|
30672
|
+
type: "button",
|
|
30673
|
+
className: `sy-mobile-option-row ${active ? "is-active" : ""}`,
|
|
30674
|
+
disabled: option.disabled,
|
|
30675
|
+
onClick: () => setTempValue(option),
|
|
30676
|
+
"data-testid": `selectfield-option-${option.value}`,
|
|
30677
|
+
children: [
|
|
30678
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "sy-mobile-option-check is-radio", "aria-hidden": "true" }),
|
|
30679
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "sy-mobile-option-label", children: renderOptionLabel(option, coloredOptions) })
|
|
30680
|
+
]
|
|
30681
|
+
},
|
|
30682
|
+
option.value
|
|
30683
|
+
);
|
|
30684
|
+
})
|
|
30685
|
+
] }),
|
|
30359
30686
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MobileSheetFooter, { onCancel: () => setVisible(false), onConfirm: handleConfirm })
|
|
30360
30687
|
] })
|
|
30361
30688
|
}
|
|
@@ -30402,7 +30729,7 @@ function SelectField(props) {
|
|
|
30402
30729
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
30403
30730
|
const { isMobile } = useDeviceDetect();
|
|
30404
30731
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
30405
|
-
(0,
|
|
30732
|
+
(0, import_react213.useEffect)(() => {
|
|
30406
30733
|
registerField(fieldId);
|
|
30407
30734
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
30408
30735
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -30428,7 +30755,7 @@ function SelectField(props) {
|
|
|
30428
30755
|
|
|
30429
30756
|
// packages/sdk/src/components/fields/MultiSelectField/index.tsx
|
|
30430
30757
|
init_cjs_shims();
|
|
30431
|
-
var
|
|
30758
|
+
var import_react215 = require("react");
|
|
30432
30759
|
|
|
30433
30760
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldPC.tsx
|
|
30434
30761
|
init_cjs_shims();
|
|
@@ -30490,7 +30817,7 @@ function MultiSelectFieldPC({
|
|
|
30490
30817
|
|
|
30491
30818
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldMobile.tsx
|
|
30492
30819
|
init_cjs_shims();
|
|
30493
|
-
var
|
|
30820
|
+
var import_react214 = require("react");
|
|
30494
30821
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
30495
30822
|
function MultiSelectFieldMobile({
|
|
30496
30823
|
fieldId,
|
|
@@ -30507,17 +30834,17 @@ function MultiSelectFieldMobile({
|
|
|
30507
30834
|
const { formData, setFieldValue } = useFormContext();
|
|
30508
30835
|
const value = controlledValue !== void 0 ? controlledValue ?? [] : formData[fieldId] ?? [];
|
|
30509
30836
|
const disabled = behavior === "DISABLED";
|
|
30510
|
-
const [visible, setVisible] = (0,
|
|
30511
|
-
const [search, setSearch] = (0,
|
|
30512
|
-
const [tempValues, setTempValues] = (0,
|
|
30513
|
-
const filteredOptions = (0,
|
|
30837
|
+
const [visible, setVisible] = (0, import_react214.useState)(false);
|
|
30838
|
+
const [search, setSearch] = (0, import_react214.useState)("");
|
|
30839
|
+
const [tempValues, setTempValues] = (0, import_react214.useState)(value);
|
|
30840
|
+
const filteredOptions = (0, import_react214.useMemo)(() => {
|
|
30514
30841
|
const keyword = search.trim().toLowerCase();
|
|
30515
30842
|
if (!keyword) return options;
|
|
30516
30843
|
return options.filter(
|
|
30517
30844
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
30518
30845
|
);
|
|
30519
30846
|
}, [options, search]);
|
|
30520
|
-
const tempValueSet = (0,
|
|
30847
|
+
const tempValueSet = (0, import_react214.useMemo)(
|
|
30521
30848
|
() => new Set(tempValues.map((option) => option.value)),
|
|
30522
30849
|
[tempValues]
|
|
30523
30850
|
);
|
|
@@ -30635,7 +30962,7 @@ function MultiSelectField(props) {
|
|
|
30635
30962
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
30636
30963
|
const { isMobile } = useDeviceDetect();
|
|
30637
30964
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
30638
|
-
(0,
|
|
30965
|
+
(0, import_react215.useEffect)(() => {
|
|
30639
30966
|
registerField(fieldId);
|
|
30640
30967
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
30641
30968
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -30661,7 +30988,7 @@ function MultiSelectField(props) {
|
|
|
30661
30988
|
|
|
30662
30989
|
// packages/sdk/src/components/fields/RadioField/index.tsx
|
|
30663
30990
|
init_cjs_shims();
|
|
30664
|
-
var
|
|
30991
|
+
var import_react216 = require("react");
|
|
30665
30992
|
|
|
30666
30993
|
// packages/sdk/src/components/fields/RadioField/RadioFieldPC.tsx
|
|
30667
30994
|
init_cjs_shims();
|
|
@@ -30810,7 +31137,7 @@ function RadioField(props) {
|
|
|
30810
31137
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
30811
31138
|
const { isMobile } = useDeviceDetect();
|
|
30812
31139
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
30813
|
-
(0,
|
|
31140
|
+
(0, import_react216.useEffect)(() => {
|
|
30814
31141
|
registerField(fieldId);
|
|
30815
31142
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
30816
31143
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -30836,7 +31163,7 @@ function RadioField(props) {
|
|
|
30836
31163
|
|
|
30837
31164
|
// packages/sdk/src/components/fields/CheckboxField/index.tsx
|
|
30838
31165
|
init_cjs_shims();
|
|
30839
|
-
var
|
|
31166
|
+
var import_react217 = require("react");
|
|
30840
31167
|
|
|
30841
31168
|
// packages/sdk/src/components/fields/CheckboxField/CheckboxFieldPC.tsx
|
|
30842
31169
|
init_cjs_shims();
|
|
@@ -30996,7 +31323,7 @@ function CheckboxField(props) {
|
|
|
30996
31323
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
30997
31324
|
const { isMobile } = useDeviceDetect();
|
|
30998
31325
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
30999
|
-
(0,
|
|
31326
|
+
(0, import_react217.useEffect)(() => {
|
|
31000
31327
|
registerField(fieldId);
|
|
31001
31328
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
31002
31329
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -31022,7 +31349,7 @@ function CheckboxField(props) {
|
|
|
31022
31349
|
|
|
31023
31350
|
// packages/sdk/src/components/fields/DateField/index.tsx
|
|
31024
31351
|
init_cjs_shims();
|
|
31025
|
-
var
|
|
31352
|
+
var import_react220 = require("react");
|
|
31026
31353
|
|
|
31027
31354
|
// packages/sdk/src/components/fields/DateField/DateFieldPC.tsx
|
|
31028
31355
|
init_cjs_shims();
|
|
@@ -31692,12 +32019,12 @@ function DateFieldPC({
|
|
|
31692
32019
|
|
|
31693
32020
|
// packages/sdk/src/components/fields/DateField/DateFieldMobile.tsx
|
|
31694
32021
|
init_cjs_shims();
|
|
31695
|
-
var
|
|
32022
|
+
var import_react219 = require("react");
|
|
31696
32023
|
var import_dayjs13 = __toESM(require("dayjs"));
|
|
31697
32024
|
|
|
31698
32025
|
// packages/sdk/src/components/fields/shared/MobileDatePicker.tsx
|
|
31699
32026
|
init_cjs_shims();
|
|
31700
|
-
var
|
|
32027
|
+
var import_react218 = __toESM(require("react"));
|
|
31701
32028
|
var import_dayjs12 = __toESM(require("dayjs"));
|
|
31702
32029
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
31703
32030
|
var pad2 = (value) => String(value).padStart(2, "0");
|
|
@@ -31794,7 +32121,7 @@ function MobileDateTimePickerView({
|
|
|
31794
32121
|
onChange
|
|
31795
32122
|
}) {
|
|
31796
32123
|
const precision = resolveTimePickerPrecision(dateFormat);
|
|
31797
|
-
const columns =
|
|
32124
|
+
const columns = import_react218.default.useMemo(
|
|
31798
32125
|
() => [getDateOptions(value, min2, max2), ...getTimePickerColumns(precision)],
|
|
31799
32126
|
[value, min2, max2, precision]
|
|
31800
32127
|
);
|
|
@@ -31825,12 +32152,12 @@ function DateFieldMobile({
|
|
|
31825
32152
|
const { formData, setFieldValue } = useFormContext();
|
|
31826
32153
|
const value = formData[fieldId];
|
|
31827
32154
|
const disabled = behavior === "DISABLED";
|
|
31828
|
-
const [visible, setVisible] = (0,
|
|
31829
|
-
const [mode, setMode] = (0,
|
|
32155
|
+
const [visible, setVisible] = (0, import_react219.useState)(false);
|
|
32156
|
+
const [mode, setMode] = (0, import_react219.useState)("date");
|
|
31830
32157
|
const format2 = getDateDisplayFormat(dateFormat, showTime);
|
|
31831
32158
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
31832
32159
|
const pickerValue = value && (0, import_dayjs13.default)(value).isValid() ? (0, import_dayjs13.default)(value).toDate() : /* @__PURE__ */ new Date();
|
|
31833
|
-
const [tempDate, setTempDate] = (0,
|
|
32160
|
+
const [tempDate, setTempDate] = (0, import_react219.useState)(pickerValue);
|
|
31834
32161
|
const { min: min2, max: max2 } = getDateMinMax(dateRestriction);
|
|
31835
32162
|
const openPicker = () => {
|
|
31836
32163
|
if (disabled) return;
|
|
@@ -31968,7 +32295,7 @@ function DateField(props) {
|
|
|
31968
32295
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
31969
32296
|
const { isMobile } = useDeviceDetect();
|
|
31970
32297
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
31971
|
-
(0,
|
|
32298
|
+
(0, import_react220.useEffect)(() => {
|
|
31972
32299
|
registerField(fieldId);
|
|
31973
32300
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
31974
32301
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -31994,7 +32321,7 @@ function DateField(props) {
|
|
|
31994
32321
|
|
|
31995
32322
|
// packages/sdk/src/components/fields/CascadeDateField/index.tsx
|
|
31996
32323
|
init_cjs_shims();
|
|
31997
|
-
var
|
|
32324
|
+
var import_react222 = require("react");
|
|
31998
32325
|
|
|
31999
32326
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldPC.tsx
|
|
32000
32327
|
init_cjs_shims();
|
|
@@ -32053,7 +32380,7 @@ function CascadeDateFieldPC({
|
|
|
32053
32380
|
|
|
32054
32381
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldMobile.tsx
|
|
32055
32382
|
init_cjs_shims();
|
|
32056
|
-
var
|
|
32383
|
+
var import_react221 = require("react");
|
|
32057
32384
|
var import_dayjs15 = __toESM(require("dayjs"));
|
|
32058
32385
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
32059
32386
|
function CascadeDateFieldMobile({
|
|
@@ -32070,11 +32397,11 @@ function CascadeDateFieldMobile({
|
|
|
32070
32397
|
const { formData, setFieldValue } = useFormContext();
|
|
32071
32398
|
const value = normalizeDateRangeValue(formData[fieldId]);
|
|
32072
32399
|
const disabled = behavior === "DISABLED";
|
|
32073
|
-
const [visible, setVisible] = (0,
|
|
32074
|
-
const [tempRange, setTempRange] = (0,
|
|
32075
|
-
const [timeStep, setTimeStep] = (0,
|
|
32076
|
-
const [tempStart, setTempStart] = (0,
|
|
32077
|
-
const [tempEnd, setTempEnd] = (0,
|
|
32400
|
+
const [visible, setVisible] = (0, import_react221.useState)(false);
|
|
32401
|
+
const [tempRange, setTempRange] = (0, import_react221.useState)(null);
|
|
32402
|
+
const [timeStep, setTimeStep] = (0, import_react221.useState)("start");
|
|
32403
|
+
const [tempStart, setTempStart] = (0, import_react221.useState)(/* @__PURE__ */ new Date());
|
|
32404
|
+
const [tempEnd, setTempEnd] = (0, import_react221.useState)(/* @__PURE__ */ new Date());
|
|
32078
32405
|
const format2 = getDateDisplayFormat(dateFormat, showTime);
|
|
32079
32406
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
32080
32407
|
const startValue = value?.start && (0, import_dayjs15.default)(value.start).isValid() ? (0, import_dayjs15.default)(value.start).toDate() : void 0;
|
|
@@ -32239,7 +32566,7 @@ function CascadeDateField(props) {
|
|
|
32239
32566
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
32240
32567
|
const { isMobile } = useDeviceDetect();
|
|
32241
32568
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
32242
|
-
(0,
|
|
32569
|
+
(0, import_react222.useEffect)(() => {
|
|
32243
32570
|
registerField(fieldId);
|
|
32244
32571
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
32245
32572
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -32265,11 +32592,11 @@ function CascadeDateField(props) {
|
|
|
32265
32592
|
|
|
32266
32593
|
// packages/sdk/src/components/fields/AttachmentField/index.tsx
|
|
32267
32594
|
init_cjs_shims();
|
|
32268
|
-
var
|
|
32595
|
+
var import_react225 = require("react");
|
|
32269
32596
|
|
|
32270
32597
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldPC.tsx
|
|
32271
32598
|
init_cjs_shims();
|
|
32272
|
-
var
|
|
32599
|
+
var import_react223 = __toESM(require("react"));
|
|
32273
32600
|
var import_antd11 = require("antd");
|
|
32274
32601
|
|
|
32275
32602
|
// packages/sdk/src/components/fields/shared/FileDisplay.tsx
|
|
@@ -32589,15 +32916,15 @@ function AttachmentFieldPC({
|
|
|
32589
32916
|
onChange
|
|
32590
32917
|
}) {
|
|
32591
32918
|
const { formData, setFieldValue, api } = useFormContext();
|
|
32592
|
-
const value =
|
|
32919
|
+
const value = import_react223.default.useMemo(
|
|
32593
32920
|
() => dedupeAttachmentItems(
|
|
32594
32921
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
32595
32922
|
),
|
|
32596
32923
|
[fieldId, formData]
|
|
32597
32924
|
);
|
|
32598
|
-
const valueRef =
|
|
32925
|
+
const valueRef = import_react223.default.useRef(value);
|
|
32599
32926
|
const disabled = behavior === "DISABLED";
|
|
32600
|
-
|
|
32927
|
+
import_react223.default.useEffect(() => {
|
|
32601
32928
|
valueRef.current = value;
|
|
32602
32929
|
}, [value]);
|
|
32603
32930
|
const setValue = (items) => {
|
|
@@ -32853,7 +33180,7 @@ function AttachmentFieldPC({
|
|
|
32853
33180
|
|
|
32854
33181
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldMobile.tsx
|
|
32855
33182
|
init_cjs_shims();
|
|
32856
|
-
var
|
|
33183
|
+
var import_react224 = __toESM(require("react"));
|
|
32857
33184
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
32858
33185
|
var PREVIEW_PAGE_EXTENSIONS2 = [
|
|
32859
33186
|
"pdf",
|
|
@@ -32906,16 +33233,16 @@ function AttachmentFieldMobile({
|
|
|
32906
33233
|
onChange
|
|
32907
33234
|
}) {
|
|
32908
33235
|
const { formData, setFieldValue, api } = useFormContext();
|
|
32909
|
-
const value =
|
|
33236
|
+
const value = import_react224.default.useMemo(
|
|
32910
33237
|
() => dedupeAttachmentItems(
|
|
32911
33238
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
32912
33239
|
),
|
|
32913
33240
|
[fieldId, formData]
|
|
32914
33241
|
);
|
|
32915
|
-
const valueRef =
|
|
32916
|
-
const inputRef =
|
|
33242
|
+
const valueRef = import_react224.default.useRef(value);
|
|
33243
|
+
const inputRef = import_react224.default.useRef(null);
|
|
32917
33244
|
const disabled = behavior === "DISABLED";
|
|
32918
|
-
|
|
33245
|
+
import_react224.default.useEffect(() => {
|
|
32919
33246
|
valueRef.current = value;
|
|
32920
33247
|
}, [value]);
|
|
32921
33248
|
const setValue = (items) => {
|
|
@@ -33277,7 +33604,7 @@ function AttachmentField(props) {
|
|
|
33277
33604
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
33278
33605
|
const { isMobile } = useDeviceDetect();
|
|
33279
33606
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
33280
|
-
(0,
|
|
33607
|
+
(0, import_react225.useEffect)(() => {
|
|
33281
33608
|
registerField(fieldId);
|
|
33282
33609
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
33283
33610
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -33303,11 +33630,11 @@ function AttachmentField(props) {
|
|
|
33303
33630
|
|
|
33304
33631
|
// packages/sdk/src/components/fields/ImageField/index.tsx
|
|
33305
33632
|
init_cjs_shims();
|
|
33306
|
-
var
|
|
33633
|
+
var import_react229 = require("react");
|
|
33307
33634
|
|
|
33308
33635
|
// packages/sdk/src/components/fields/ImageField/ImageFieldPC.tsx
|
|
33309
33636
|
init_cjs_shims();
|
|
33310
|
-
var
|
|
33637
|
+
var import_react226 = __toESM(require("react"));
|
|
33311
33638
|
var import_antd12 = require("antd");
|
|
33312
33639
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
33313
33640
|
var createLocalItem3 = (file) => {
|
|
@@ -33326,9 +33653,9 @@ var createLocalItem3 = (file) => {
|
|
|
33326
33653
|
};
|
|
33327
33654
|
};
|
|
33328
33655
|
function ImageThumbContent({ item }) {
|
|
33329
|
-
const [imageFailed, setImageFailed] =
|
|
33656
|
+
const [imageFailed, setImageFailed] = import_react226.default.useState(false);
|
|
33330
33657
|
const src = item.previewUrl || item.url;
|
|
33331
|
-
|
|
33658
|
+
import_react226.default.useEffect(() => {
|
|
33332
33659
|
setImageFailed(false);
|
|
33333
33660
|
}, [src]);
|
|
33334
33661
|
if (src && !imageFailed) {
|
|
@@ -33356,15 +33683,15 @@ function ImageFieldPC({
|
|
|
33356
33683
|
onChange
|
|
33357
33684
|
}) {
|
|
33358
33685
|
const { formData, setFieldValue, api } = useFormContext();
|
|
33359
|
-
const value =
|
|
33686
|
+
const value = import_react226.default.useMemo(
|
|
33360
33687
|
() => dedupeAttachmentItems(
|
|
33361
33688
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
33362
33689
|
),
|
|
33363
33690
|
[fieldId, formData]
|
|
33364
33691
|
);
|
|
33365
|
-
const valueRef =
|
|
33692
|
+
const valueRef = import_react226.default.useRef(value);
|
|
33366
33693
|
const disabled = behavior === "DISABLED";
|
|
33367
|
-
|
|
33694
|
+
import_react226.default.useEffect(() => {
|
|
33368
33695
|
valueRef.current = value;
|
|
33369
33696
|
}, [value]);
|
|
33370
33697
|
const setValue = (items) => {
|
|
@@ -33624,7 +33951,7 @@ function ImageFieldPC({
|
|
|
33624
33951
|
|
|
33625
33952
|
// packages/sdk/src/components/fields/ImageField/ImageFieldMobile.tsx
|
|
33626
33953
|
init_cjs_shims();
|
|
33627
|
-
var
|
|
33954
|
+
var import_react227 = __toESM(require("react"));
|
|
33628
33955
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
33629
33956
|
var createLocalItem4 = (file) => {
|
|
33630
33957
|
const uid = createUid("image");
|
|
@@ -33642,9 +33969,9 @@ var createLocalItem4 = (file) => {
|
|
|
33642
33969
|
};
|
|
33643
33970
|
};
|
|
33644
33971
|
function ImageThumbContent2({ item }) {
|
|
33645
|
-
const [imageFailed, setImageFailed] =
|
|
33972
|
+
const [imageFailed, setImageFailed] = import_react227.default.useState(false);
|
|
33646
33973
|
const src = item.previewUrl || item.url;
|
|
33647
|
-
|
|
33974
|
+
import_react227.default.useEffect(() => {
|
|
33648
33975
|
setImageFailed(false);
|
|
33649
33976
|
}, [src]);
|
|
33650
33977
|
if (src && !imageFailed) {
|
|
@@ -33671,16 +33998,16 @@ function ImageFieldMobile({
|
|
|
33671
33998
|
onChange
|
|
33672
33999
|
}) {
|
|
33673
34000
|
const { formData, setFieldValue, api } = useFormContext();
|
|
33674
|
-
const value =
|
|
34001
|
+
const value = import_react227.default.useMemo(
|
|
33675
34002
|
() => dedupeAttachmentItems(
|
|
33676
34003
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
33677
34004
|
),
|
|
33678
34005
|
[fieldId, formData]
|
|
33679
34006
|
);
|
|
33680
|
-
const valueRef =
|
|
33681
|
-
const inputRef =
|
|
34007
|
+
const valueRef = import_react227.default.useRef(value);
|
|
34008
|
+
const inputRef = import_react227.default.useRef(null);
|
|
33682
34009
|
const disabled = behavior === "DISABLED";
|
|
33683
|
-
|
|
34010
|
+
import_react227.default.useEffect(() => {
|
|
33684
34011
|
valueRef.current = value;
|
|
33685
34012
|
}, [value]);
|
|
33686
34013
|
const setValue = (items) => {
|
|
@@ -33843,13 +34170,13 @@ function ImageFieldMobile({
|
|
|
33843
34170
|
|
|
33844
34171
|
// packages/sdk/src/components/fields/ImageField/ImageFieldReadonly.tsx
|
|
33845
34172
|
init_cjs_shims();
|
|
33846
|
-
var
|
|
34173
|
+
var import_react228 = __toESM(require("react"));
|
|
33847
34174
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
33848
34175
|
var getTicketUrl2 = (ticket, fallback) => typeof ticket === "string" ? ticket : ticket?.previewUrl || ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || fallback;
|
|
33849
34176
|
function ImageThumbContent3({ item, testId }) {
|
|
33850
|
-
const [imageFailed, setImageFailed] =
|
|
34177
|
+
const [imageFailed, setImageFailed] = import_react228.default.useState(false);
|
|
33851
34178
|
const src = item.previewUrl || item.url;
|
|
33852
|
-
|
|
34179
|
+
import_react228.default.useEffect(() => {
|
|
33853
34180
|
setImageFailed(false);
|
|
33854
34181
|
}, [src]);
|
|
33855
34182
|
if (src && !imageFailed) {
|
|
@@ -33873,8 +34200,8 @@ function ImageFieldReadonly({
|
|
|
33873
34200
|
const { formData, api } = useFormContext();
|
|
33874
34201
|
const { isMobile } = useDeviceDetect();
|
|
33875
34202
|
const value = formData[fieldId] ?? [];
|
|
33876
|
-
const [previewUrl, setPreviewUrl] =
|
|
33877
|
-
const [previewName, setPreviewName] =
|
|
34203
|
+
const [previewUrl, setPreviewUrl] = import_react228.default.useState("");
|
|
34204
|
+
const [previewName, setPreviewName] = import_react228.default.useState("");
|
|
33878
34205
|
if (value.length === 0) {
|
|
33879
34206
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
33880
34207
|
"div",
|
|
@@ -34066,7 +34393,7 @@ function ImageField(props) {
|
|
|
34066
34393
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
34067
34394
|
const { isMobile } = useDeviceDetect();
|
|
34068
34395
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
34069
|
-
(0,
|
|
34396
|
+
(0, import_react229.useEffect)(() => {
|
|
34070
34397
|
registerField(fieldId);
|
|
34071
34398
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
34072
34399
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -34092,14 +34419,14 @@ function ImageField(props) {
|
|
|
34092
34419
|
|
|
34093
34420
|
// packages/sdk/src/components/fields/SubFormField/index.tsx
|
|
34094
34421
|
init_cjs_shims();
|
|
34095
|
-
var
|
|
34422
|
+
var import_react231 = require("react");
|
|
34096
34423
|
|
|
34097
34424
|
// packages/sdk/src/components/fields/SubFormField/SubFormFieldPC.tsx
|
|
34098
34425
|
init_cjs_shims();
|
|
34099
34426
|
|
|
34100
34427
|
// packages/sdk/src/components/fields/SubFormField/SubFormCell.tsx
|
|
34101
34428
|
init_cjs_shims();
|
|
34102
|
-
var
|
|
34429
|
+
var import_react230 = require("react");
|
|
34103
34430
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
34104
34431
|
var stringifyFallbackValue = (value) => {
|
|
34105
34432
|
if (value === void 0 || value === null) return "";
|
|
@@ -34120,7 +34447,7 @@ function SubFormCell({
|
|
|
34120
34447
|
const scopedFieldId = `${parentFieldId}.${rowIndex}.${column.fieldId}`;
|
|
34121
34448
|
const cellValue = row[column.fieldId];
|
|
34122
34449
|
const resolvedBehavior = behavior === "DISABLED" || behavior === "READONLY" ? behavior : column.behavior ?? behavior ?? "NORMAL";
|
|
34123
|
-
const childContext = (0,
|
|
34450
|
+
const childContext = (0, import_react230.useMemo)(
|
|
34124
34451
|
() => ({
|
|
34125
34452
|
...parentContext,
|
|
34126
34453
|
formData: {
|
|
@@ -34416,7 +34743,7 @@ function SubFormField(props) {
|
|
|
34416
34743
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
34417
34744
|
const { isMobile } = useDeviceDetect();
|
|
34418
34745
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
34419
|
-
(0,
|
|
34746
|
+
(0, import_react231.useEffect)(() => {
|
|
34420
34747
|
registerField(fieldId);
|
|
34421
34748
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
34422
34749
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -34442,22 +34769,22 @@ function SubFormField(props) {
|
|
|
34442
34769
|
|
|
34443
34770
|
// packages/sdk/src/components/fields/UserSelectField/index.tsx
|
|
34444
34771
|
init_cjs_shims();
|
|
34445
|
-
var
|
|
34772
|
+
var import_react237 = require("react");
|
|
34446
34773
|
|
|
34447
34774
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldPC.tsx
|
|
34448
34775
|
init_cjs_shims();
|
|
34449
|
-
var
|
|
34776
|
+
var import_react234 = require("react");
|
|
34450
34777
|
var import_antd14 = require("antd");
|
|
34451
34778
|
|
|
34452
34779
|
// packages/sdk/src/components/fields/shared/UserPicker.tsx
|
|
34453
34780
|
init_cjs_shims();
|
|
34454
|
-
var
|
|
34781
|
+
var import_react233 = require("react");
|
|
34455
34782
|
var import_antd13 = require("antd");
|
|
34456
34783
|
var import_icons3 = require("@ant-design/icons");
|
|
34457
34784
|
|
|
34458
34785
|
// packages/sdk/src/components/fields/shared/useLazyDepartmentTree.ts
|
|
34459
34786
|
init_cjs_shims();
|
|
34460
|
-
var
|
|
34787
|
+
var import_react232 = require("react");
|
|
34461
34788
|
var toLazyNode = (node) => {
|
|
34462
34789
|
const normalized = normalizeDepartmentNode(node);
|
|
34463
34790
|
const id = getDepartmentId(normalized);
|
|
@@ -34507,15 +34834,15 @@ function buildIndexes(nodes) {
|
|
|
34507
34834
|
return { nodeMap, parentMap, flatNodes };
|
|
34508
34835
|
}
|
|
34509
34836
|
function useLazyDepartmentTree(api, configuredTreeData) {
|
|
34510
|
-
const [treeData, setTreeDataState] = (0,
|
|
34837
|
+
const [treeData, setTreeDataState] = (0, import_react232.useState)(
|
|
34511
34838
|
() => (configuredTreeData || []).map(toLazyNode)
|
|
34512
34839
|
);
|
|
34513
|
-
const [treeLoading, setTreeLoading] = (0,
|
|
34514
|
-
const treeDataRef = (0,
|
|
34515
|
-
const rootsLoadedRef = (0,
|
|
34516
|
-
const rootPromiseRef = (0,
|
|
34517
|
-
const childPromiseRef = (0,
|
|
34518
|
-
const setTreeData = (0,
|
|
34840
|
+
const [treeLoading, setTreeLoading] = (0, import_react232.useState)(false);
|
|
34841
|
+
const treeDataRef = (0, import_react232.useRef)(treeData);
|
|
34842
|
+
const rootsLoadedRef = (0, import_react232.useRef)(Boolean(configuredTreeData?.length));
|
|
34843
|
+
const rootPromiseRef = (0, import_react232.useRef)(null);
|
|
34844
|
+
const childPromiseRef = (0, import_react232.useRef)({});
|
|
34845
|
+
const setTreeData = (0, import_react232.useCallback)(
|
|
34519
34846
|
(next) => {
|
|
34520
34847
|
const resolved = typeof next === "function" ? next(treeDataRef.current) : next;
|
|
34521
34848
|
treeDataRef.current = resolved;
|
|
@@ -34524,13 +34851,13 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
34524
34851
|
},
|
|
34525
34852
|
[]
|
|
34526
34853
|
);
|
|
34527
|
-
(0,
|
|
34854
|
+
(0, import_react232.useEffect)(() => {
|
|
34528
34855
|
if (!configuredTreeData) return;
|
|
34529
34856
|
const next = configuredTreeData.map(toLazyNode);
|
|
34530
34857
|
rootsLoadedRef.current = next.length > 0;
|
|
34531
34858
|
setTreeData(next);
|
|
34532
34859
|
}, [configuredTreeData, setTreeData]);
|
|
34533
|
-
const loadRootDepartments = (0,
|
|
34860
|
+
const loadRootDepartments = (0, import_react232.useCallback)(async () => {
|
|
34534
34861
|
if (rootsLoadedRef.current) return treeDataRef.current;
|
|
34535
34862
|
if (rootPromiseRef.current) return rootPromiseRef.current;
|
|
34536
34863
|
setTreeLoading(true);
|
|
@@ -34546,7 +34873,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
34546
34873
|
rootPromiseRef.current = promise;
|
|
34547
34874
|
return promise;
|
|
34548
34875
|
}, [api, setTreeData]);
|
|
34549
|
-
const loadChildren = (0,
|
|
34876
|
+
const loadChildren = (0, import_react232.useCallback)(
|
|
34550
34877
|
async (parentId) => {
|
|
34551
34878
|
const id = String(parentId || "");
|
|
34552
34879
|
if (!id) return [];
|
|
@@ -34567,8 +34894,8 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
34567
34894
|
},
|
|
34568
34895
|
[api, setTreeData]
|
|
34569
34896
|
);
|
|
34570
|
-
const indexes = (0,
|
|
34571
|
-
(0,
|
|
34897
|
+
const indexes = (0, import_react232.useMemo)(() => buildIndexes(treeData), [treeData]);
|
|
34898
|
+
(0, import_react232.useEffect)(() => {
|
|
34572
34899
|
void loadRootDepartments();
|
|
34573
34900
|
}, [loadRootDepartments]);
|
|
34574
34901
|
return {
|
|
@@ -34613,24 +34940,24 @@ function UserPickerPanel({
|
|
|
34613
34940
|
flatNodes,
|
|
34614
34941
|
loadChildren
|
|
34615
34942
|
} = useLazyDepartmentTree(api, treeData);
|
|
34616
|
-
const [departmentKeyword, setDepartmentKeyword] = (0,
|
|
34617
|
-
const [memberKeyword, setMemberKeyword] = (0,
|
|
34618
|
-
const [mobileKeyword, setMobileKeyword] = (0,
|
|
34619
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
34620
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
34621
|
-
const [members, setMembers] = (0,
|
|
34622
|
-
const [memberPage, setMemberPage] = (0,
|
|
34623
|
-
const [memberPageSize, setMemberPageSize] = (0,
|
|
34624
|
-
const [memberTotal, setMemberTotal] = (0,
|
|
34625
|
-
const [memberReloadKey, setMemberReloadKey] = (0,
|
|
34626
|
-
const [loading, setLoading] = (0,
|
|
34627
|
-
const [selected, setSelected] = (0,
|
|
34943
|
+
const [departmentKeyword, setDepartmentKeyword] = (0, import_react233.useState)("");
|
|
34944
|
+
const [memberKeyword, setMemberKeyword] = (0, import_react233.useState)("");
|
|
34945
|
+
const [mobileKeyword, setMobileKeyword] = (0, import_react233.useState)("");
|
|
34946
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react233.useState)("");
|
|
34947
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react233.useState)([]);
|
|
34948
|
+
const [members, setMembers] = (0, import_react233.useState)(() => normalizeUsers(dataSource));
|
|
34949
|
+
const [memberPage, setMemberPage] = (0, import_react233.useState)(1);
|
|
34950
|
+
const [memberPageSize, setMemberPageSize] = (0, import_react233.useState)(DEFAULT_MEMBER_PAGE_SIZE);
|
|
34951
|
+
const [memberTotal, setMemberTotal] = (0, import_react233.useState)(() => normalizeUsers(dataSource).length);
|
|
34952
|
+
const [memberReloadKey, setMemberReloadKey] = (0, import_react233.useState)(0);
|
|
34953
|
+
const [loading, setLoading] = (0, import_react233.useState)(false);
|
|
34954
|
+
const [selected, setSelected] = (0, import_react233.useState)(() => normalizeUsers(value));
|
|
34628
34955
|
const selectedIds = selected.map(getUserId);
|
|
34629
34956
|
const MobileSearchBar = getMobileComponent("SearchBar");
|
|
34630
34957
|
const activeMemberKeyword = (mobile ? mobileKeyword : memberKeyword).trim();
|
|
34631
|
-
const staticUsers = (0,
|
|
34958
|
+
const staticUsers = (0, import_react233.useMemo)(() => normalizeUsers(dataSource), [dataSource]);
|
|
34632
34959
|
const hasStaticUserSource = staticUsers.length > 0;
|
|
34633
|
-
(0,
|
|
34960
|
+
(0, import_react233.useEffect)(() => {
|
|
34634
34961
|
if (mobile) return;
|
|
34635
34962
|
if (currentDeptId || deptTreeData.length === 0) return;
|
|
34636
34963
|
setExpandedKeys(deptTreeData.map((node) => getDepartmentId(node)));
|
|
@@ -34638,17 +34965,17 @@ function UserPickerPanel({
|
|
|
34638
34965
|
setCurrentDeptId(getDepartmentId(deptTreeData[0]));
|
|
34639
34966
|
}
|
|
34640
34967
|
}, [currentDeptId, deptTreeData, loadAllWhenNoDepartment, mobile]);
|
|
34641
|
-
(0,
|
|
34968
|
+
(0, import_react233.useEffect)(() => {
|
|
34642
34969
|
setMemberPage(1);
|
|
34643
34970
|
}, [activeMemberKeyword, currentDeptId, dataSource, mobile]);
|
|
34644
|
-
const handleDepartmentSelect = (0,
|
|
34971
|
+
const handleDepartmentSelect = (0, import_react233.useCallback)((deptId) => {
|
|
34645
34972
|
const nextDeptId = String(deptId || "");
|
|
34646
34973
|
setCurrentDeptId(nextDeptId);
|
|
34647
34974
|
setMemberKeyword("");
|
|
34648
34975
|
setMemberPage(1);
|
|
34649
34976
|
setMemberReloadKey((current) => current + 1);
|
|
34650
34977
|
}, []);
|
|
34651
|
-
(0,
|
|
34978
|
+
(0, import_react233.useEffect)(() => {
|
|
34652
34979
|
let active = true;
|
|
34653
34980
|
const keyword = activeMemberKeyword;
|
|
34654
34981
|
if (hasStaticUserSource) {
|
|
@@ -34721,7 +35048,7 @@ function UserPickerPanel({
|
|
|
34721
35048
|
memberReloadKey,
|
|
34722
35049
|
staticUsers
|
|
34723
35050
|
]);
|
|
34724
|
-
const currentPath = (0,
|
|
35051
|
+
const currentPath = (0, import_react233.useMemo)(() => {
|
|
34725
35052
|
if (!currentDeptId) return [];
|
|
34726
35053
|
const path = [];
|
|
34727
35054
|
let cursor = currentDeptId;
|
|
@@ -34733,7 +35060,7 @@ function UserPickerPanel({
|
|
|
34733
35060
|
}
|
|
34734
35061
|
return path;
|
|
34735
35062
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
34736
|
-
const mobileDepartments = (0,
|
|
35063
|
+
const mobileDepartments = (0, import_react233.useMemo)(() => {
|
|
34737
35064
|
const keyword = mobileKeyword.trim().toLowerCase();
|
|
34738
35065
|
if (keyword) {
|
|
34739
35066
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(keyword)).map((item) => item.node);
|
|
@@ -34981,20 +35308,20 @@ function UserSelectFieldPC({
|
|
|
34981
35308
|
}) {
|
|
34982
35309
|
const { formData, setFieldValue, api } = useFormContext();
|
|
34983
35310
|
const rawValue = formData[fieldId];
|
|
34984
|
-
const value = (0,
|
|
35311
|
+
const value = (0, import_react234.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
34985
35312
|
const disabled = behavior === "DISABLED";
|
|
34986
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
35313
|
+
const [optionsSource, setOptionsSource] = (0, import_react234.useState)(
|
|
34987
35314
|
() => dataSource.map(normalizeUser)
|
|
34988
35315
|
);
|
|
34989
|
-
const [loading, setLoading] = (0,
|
|
34990
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
35316
|
+
const [loading, setLoading] = (0, import_react234.useState)(false);
|
|
35317
|
+
const [pickerOpen, setPickerOpen] = (0, import_react234.useState)(false);
|
|
34991
35318
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
34992
|
-
(0,
|
|
35319
|
+
(0, import_react234.useEffect)(() => {
|
|
34993
35320
|
if (dataSource.length) {
|
|
34994
35321
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
34995
35322
|
}
|
|
34996
35323
|
}, [dataSource]);
|
|
34997
|
-
(0,
|
|
35324
|
+
(0, import_react234.useEffect)(() => {
|
|
34998
35325
|
setOptionsSource((current) => {
|
|
34999
35326
|
const merged = [...current];
|
|
35000
35327
|
let changed = false;
|
|
@@ -35007,7 +35334,7 @@ function UserSelectFieldPC({
|
|
|
35007
35334
|
return changed ? merged : current;
|
|
35008
35335
|
});
|
|
35009
35336
|
}, [value]);
|
|
35010
|
-
(0,
|
|
35337
|
+
(0, import_react234.useEffect)(() => {
|
|
35011
35338
|
const missing = value.filter((item) => getUserId(item) && getUserNameLikeId(item));
|
|
35012
35339
|
if (missing.length === 0) return;
|
|
35013
35340
|
let cancelled = false;
|
|
@@ -35050,7 +35377,7 @@ function UserSelectFieldPC({
|
|
|
35050
35377
|
setLoading(false);
|
|
35051
35378
|
}
|
|
35052
35379
|
};
|
|
35053
|
-
(0,
|
|
35380
|
+
(0, import_react234.useEffect)(() => {
|
|
35054
35381
|
fetchUsers();
|
|
35055
35382
|
}, []);
|
|
35056
35383
|
const handleChange = (selectedIds) => {
|
|
@@ -35075,7 +35402,7 @@ function UserSelectFieldPC({
|
|
|
35075
35402
|
setFieldValue(fieldId, normalized);
|
|
35076
35403
|
onChange?.(normalized);
|
|
35077
35404
|
};
|
|
35078
|
-
const options = (0,
|
|
35405
|
+
const options = (0, import_react234.useMemo)(
|
|
35079
35406
|
() => optionsSource.map((u) => ({
|
|
35080
35407
|
value: getUserId(u),
|
|
35081
35408
|
label: formatUserDisplay(u, displayFormat)
|
|
@@ -35140,7 +35467,7 @@ function getUserNameLikeId(user) {
|
|
|
35140
35467
|
|
|
35141
35468
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldMobile.tsx
|
|
35142
35469
|
init_cjs_shims();
|
|
35143
|
-
var
|
|
35470
|
+
var import_react235 = require("react");
|
|
35144
35471
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
35145
35472
|
var getMobilePopup = () => {
|
|
35146
35473
|
try {
|
|
@@ -35164,19 +35491,19 @@ function UserSelectFieldMobile({
|
|
|
35164
35491
|
}) {
|
|
35165
35492
|
const { formData, setFieldValue, api } = useFormContext();
|
|
35166
35493
|
const rawValue = formData[fieldId];
|
|
35167
|
-
const value = (0,
|
|
35494
|
+
const value = (0, import_react235.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
35168
35495
|
const disabled = behavior === "DISABLED";
|
|
35169
|
-
const [showPicker, setShowPicker] = (0,
|
|
35170
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
35496
|
+
const [showPicker, setShowPicker] = (0, import_react235.useState)(false);
|
|
35497
|
+
const [optionsSource, setOptionsSource] = (0, import_react235.useState)(
|
|
35171
35498
|
() => dataSource.map(normalizeUser)
|
|
35172
35499
|
);
|
|
35173
35500
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
35174
|
-
(0,
|
|
35501
|
+
(0, import_react235.useEffect)(() => {
|
|
35175
35502
|
if (dataSource.length) {
|
|
35176
35503
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
35177
35504
|
}
|
|
35178
35505
|
}, [dataSource]);
|
|
35179
|
-
(0,
|
|
35506
|
+
(0, import_react235.useEffect)(() => {
|
|
35180
35507
|
setOptionsSource((current) => {
|
|
35181
35508
|
const merged = [...current];
|
|
35182
35509
|
let changed = false;
|
|
@@ -35273,7 +35600,7 @@ function UserSelectFieldMobile({
|
|
|
35273
35600
|
|
|
35274
35601
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldReadonly.tsx
|
|
35275
35602
|
init_cjs_shims();
|
|
35276
|
-
var
|
|
35603
|
+
var import_react236 = require("react");
|
|
35277
35604
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
35278
35605
|
function UserSelectFieldReadonly({
|
|
35279
35606
|
fieldId,
|
|
@@ -35282,8 +35609,8 @@ function UserSelectFieldReadonly({
|
|
|
35282
35609
|
}) {
|
|
35283
35610
|
const { formData, setFieldValue, api } = useFormContext();
|
|
35284
35611
|
const rawValue = formData[fieldId];
|
|
35285
|
-
const value = (0,
|
|
35286
|
-
(0,
|
|
35612
|
+
const value = (0, import_react236.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
35613
|
+
(0, import_react236.useEffect)(() => {
|
|
35287
35614
|
const missing = value.filter((item) => getUserNameLikeId2(item));
|
|
35288
35615
|
if (missing.length === 0) return;
|
|
35289
35616
|
let cancelled = false;
|
|
@@ -35335,7 +35662,7 @@ function UserSelectField(props) {
|
|
|
35335
35662
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
35336
35663
|
const { isMobile } = useDeviceDetect();
|
|
35337
35664
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
35338
|
-
(0,
|
|
35665
|
+
(0, import_react237.useEffect)(() => {
|
|
35339
35666
|
registerField(fieldId);
|
|
35340
35667
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
35341
35668
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -35361,16 +35688,16 @@ function UserSelectField(props) {
|
|
|
35361
35688
|
|
|
35362
35689
|
// packages/sdk/src/components/fields/DepartmentSelectField/index.tsx
|
|
35363
35690
|
init_cjs_shims();
|
|
35364
|
-
var
|
|
35691
|
+
var import_react242 = require("react");
|
|
35365
35692
|
|
|
35366
35693
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldPC.tsx
|
|
35367
35694
|
init_cjs_shims();
|
|
35368
|
-
var
|
|
35695
|
+
var import_react239 = require("react");
|
|
35369
35696
|
var import_antd16 = require("antd");
|
|
35370
35697
|
|
|
35371
35698
|
// packages/sdk/src/components/fields/shared/DepartmentPicker.tsx
|
|
35372
35699
|
init_cjs_shims();
|
|
35373
|
-
var
|
|
35700
|
+
var import_react238 = require("react");
|
|
35374
35701
|
var import_antd15 = require("antd");
|
|
35375
35702
|
var import_icons4 = require("@ant-design/icons");
|
|
35376
35703
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
@@ -35413,17 +35740,17 @@ function DepartmentPickerPanel({
|
|
|
35413
35740
|
flatNodes,
|
|
35414
35741
|
loadChildren
|
|
35415
35742
|
} = useLazyDepartmentTree(api, treeData);
|
|
35416
|
-
const [keyword, setKeyword] = (0,
|
|
35417
|
-
const [selected, setSelected] = (0,
|
|
35418
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
35419
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
35743
|
+
const [keyword, setKeyword] = (0, import_react238.useState)("");
|
|
35744
|
+
const [selected, setSelected] = (0, import_react238.useState)(() => normalizeSelection(value));
|
|
35745
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react238.useState)([]);
|
|
35746
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react238.useState)(null);
|
|
35420
35747
|
const selectedIds = selected.map((item) => item.id);
|
|
35421
35748
|
const MobileSearchBar = getMobileComponent2("SearchBar");
|
|
35422
|
-
const filteredTreeData = (0,
|
|
35749
|
+
const filteredTreeData = (0, import_react238.useMemo)(
|
|
35423
35750
|
() => matchSearch(loadedTreeData, keyword.trim()),
|
|
35424
35751
|
[keyword, loadedTreeData]
|
|
35425
35752
|
);
|
|
35426
|
-
const currentPath = (0,
|
|
35753
|
+
const currentPath = (0, import_react238.useMemo)(() => {
|
|
35427
35754
|
if (!currentDeptId) return [];
|
|
35428
35755
|
const path = [];
|
|
35429
35756
|
let cursor = currentDeptId;
|
|
@@ -35435,7 +35762,7 @@ function DepartmentPickerPanel({
|
|
|
35435
35762
|
}
|
|
35436
35763
|
return path;
|
|
35437
35764
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
35438
|
-
const mobileList = (0,
|
|
35765
|
+
const mobileList = (0, import_react238.useMemo)(() => {
|
|
35439
35766
|
if (keyword.trim()) {
|
|
35440
35767
|
const lower = keyword.trim().toLowerCase();
|
|
35441
35768
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(lower)).map((item) => item.node);
|
|
@@ -35658,13 +35985,13 @@ function DepartmentSelectFieldPC({
|
|
|
35658
35985
|
}) {
|
|
35659
35986
|
const { formData, setFieldValue, api } = useFormContext();
|
|
35660
35987
|
const rawValue = formData[fieldId];
|
|
35661
|
-
const value = (0,
|
|
35988
|
+
const value = (0, import_react239.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
35662
35989
|
const disabled = behavior === "DISABLED";
|
|
35663
35990
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA;
|
|
35664
|
-
const remoteLoadedRef = (0,
|
|
35665
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
35666
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
35667
|
-
(0,
|
|
35991
|
+
const remoteLoadedRef = (0, import_react239.useRef)(false);
|
|
35992
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react239.useState)(configuredTreeData);
|
|
35993
|
+
const [pickerOpen, setPickerOpen] = (0, import_react239.useState)(false);
|
|
35994
|
+
(0, import_react239.useEffect)(() => {
|
|
35668
35995
|
if (configuredTreeData.length) {
|
|
35669
35996
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
35670
35997
|
return;
|
|
@@ -35770,7 +36097,7 @@ function DepartmentSelectFieldPC({
|
|
|
35770
36097
|
|
|
35771
36098
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldMobile.tsx
|
|
35772
36099
|
init_cjs_shims();
|
|
35773
|
-
var
|
|
36100
|
+
var import_react240 = require("react");
|
|
35774
36101
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
35775
36102
|
var EMPTY_TREE_DATA2 = [];
|
|
35776
36103
|
function toDepartmentValue2(item) {
|
|
@@ -35800,13 +36127,13 @@ function DepartmentSelectFieldMobile({
|
|
|
35800
36127
|
}) {
|
|
35801
36128
|
const { formData, setFieldValue, api } = useFormContext();
|
|
35802
36129
|
const rawValue = formData[fieldId];
|
|
35803
|
-
const value = (0,
|
|
36130
|
+
const value = (0, import_react240.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
35804
36131
|
const disabled = behavior === "DISABLED";
|
|
35805
|
-
const [showPicker, setShowPicker] = (0,
|
|
36132
|
+
const [showPicker, setShowPicker] = (0, import_react240.useState)(false);
|
|
35806
36133
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA2;
|
|
35807
|
-
const remoteLoadedRef = (0,
|
|
35808
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
35809
|
-
(0,
|
|
36134
|
+
const remoteLoadedRef = (0, import_react240.useRef)(false);
|
|
36135
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react240.useState)(configuredTreeData);
|
|
36136
|
+
(0, import_react240.useEffect)(() => {
|
|
35810
36137
|
if (configuredTreeData.length) {
|
|
35811
36138
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
35812
36139
|
}
|
|
@@ -35901,7 +36228,7 @@ function DepartmentSelectFieldMobile({
|
|
|
35901
36228
|
|
|
35902
36229
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldReadonly.tsx
|
|
35903
36230
|
init_cjs_shims();
|
|
35904
|
-
var
|
|
36231
|
+
var import_react241 = require("react");
|
|
35905
36232
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
35906
36233
|
function DepartmentSelectFieldReadonly({
|
|
35907
36234
|
fieldId,
|
|
@@ -35911,7 +36238,7 @@ function DepartmentSelectFieldReadonly({
|
|
|
35911
36238
|
}) {
|
|
35912
36239
|
const { formData } = useFormContext();
|
|
35913
36240
|
const rawValue = formData[fieldId];
|
|
35914
|
-
const value = (0,
|
|
36241
|
+
const value = (0, import_react241.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
35915
36242
|
const display = value.length > 0 ? value.map(
|
|
35916
36243
|
(d) => showFullPath ? getDepartmentFullPath(getDepartmentId(d), treeData) || getDepartmentName(d) : getDepartmentName(d)
|
|
35917
36244
|
).join(", ") : "--";
|
|
@@ -35942,7 +36269,7 @@ function DepartmentSelectField(props) {
|
|
|
35942
36269
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
35943
36270
|
const { isMobile } = useDeviceDetect();
|
|
35944
36271
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
35945
|
-
(0,
|
|
36272
|
+
(0, import_react242.useEffect)(() => {
|
|
35946
36273
|
registerField(fieldId);
|
|
35947
36274
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
35948
36275
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -35968,7 +36295,7 @@ function DepartmentSelectField(props) {
|
|
|
35968
36295
|
|
|
35969
36296
|
// packages/sdk/src/components/fields/CascadeSelectField/index.tsx
|
|
35970
36297
|
init_cjs_shims();
|
|
35971
|
-
var
|
|
36298
|
+
var import_react243 = require("react");
|
|
35972
36299
|
var import_antd17 = require("antd");
|
|
35973
36300
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
35974
36301
|
var toValuePath = (value, multiple) => {
|
|
@@ -36007,7 +36334,7 @@ function CascadeSelectField(props) {
|
|
|
36007
36334
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
36008
36335
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
36009
36336
|
const value = formData[fieldId] ?? (multiple ? [] : []);
|
|
36010
|
-
(0,
|
|
36337
|
+
(0, import_react243.useEffect)(() => {
|
|
36011
36338
|
registerField(fieldId);
|
|
36012
36339
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
36013
36340
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -36061,7 +36388,7 @@ function CascadeSelectField(props) {
|
|
|
36061
36388
|
|
|
36062
36389
|
// packages/sdk/src/components/fields/AddressField/index.tsx
|
|
36063
36390
|
init_cjs_shims();
|
|
36064
|
-
var
|
|
36391
|
+
var import_react244 = require("react");
|
|
36065
36392
|
var import_antd18 = require("antd");
|
|
36066
36393
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
36067
36394
|
var LEVELS = ["province", "city", "district", "street"];
|
|
@@ -36112,19 +36439,19 @@ function AddressField(props) {
|
|
|
36112
36439
|
const { isMobile } = useDeviceDetect();
|
|
36113
36440
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
36114
36441
|
const value = formData[fieldId];
|
|
36115
|
-
const [options, setOptions] = (0,
|
|
36116
|
-
const [loadingRoots, setLoadingRoots] = (0,
|
|
36117
|
-
const [mobileOpen, setMobileOpen] = (0,
|
|
36118
|
-
const [mobileLevelIndex, setMobileLevelIndex] = (0,
|
|
36119
|
-
const [mobileOptions, setMobileOptions] = (0,
|
|
36120
|
-
const [mobileLoading, setMobileLoading] = (0,
|
|
36121
|
-
const [tempValue, setTempValue] = (0,
|
|
36442
|
+
const [options, setOptions] = (0, import_react244.useState)([]);
|
|
36443
|
+
const [loadingRoots, setLoadingRoots] = (0, import_react244.useState)(false);
|
|
36444
|
+
const [mobileOpen, setMobileOpen] = (0, import_react244.useState)(false);
|
|
36445
|
+
const [mobileLevelIndex, setMobileLevelIndex] = (0, import_react244.useState)(0);
|
|
36446
|
+
const [mobileOptions, setMobileOptions] = (0, import_react244.useState)([]);
|
|
36447
|
+
const [mobileLoading, setMobileLoading] = (0, import_react244.useState)(false);
|
|
36448
|
+
const [tempValue, setTempValue] = (0, import_react244.useState)();
|
|
36122
36449
|
const depth = modeDepth(mode);
|
|
36123
|
-
const levels = (0,
|
|
36450
|
+
const levels = (0, import_react244.useMemo)(() => activeLevels(mode), [mode]);
|
|
36124
36451
|
const detailEnabled = mode === "province-city-district-street-detail";
|
|
36125
36452
|
const disabled = behavior === "DISABLED";
|
|
36126
36453
|
const MobilePopup = getMobileComponent3("Popup");
|
|
36127
|
-
(0,
|
|
36454
|
+
(0, import_react244.useEffect)(() => {
|
|
36128
36455
|
registerField(fieldId);
|
|
36129
36456
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
36130
36457
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -36135,11 +36462,11 @@ function AddressField(props) {
|
|
|
36135
36462
|
const list = await api.getChinaDivisions(parentAdcode);
|
|
36136
36463
|
return list.map((item) => normalizeDivision(item, level, depth, index2));
|
|
36137
36464
|
};
|
|
36138
|
-
(0,
|
|
36465
|
+
(0, import_react244.useEffect)(() => {
|
|
36139
36466
|
setLoadingRoots(true);
|
|
36140
36467
|
loadDivisions(void 0, "province", 0).then(setOptions).finally(() => setLoadingRoots(false));
|
|
36141
36468
|
}, [api, depth]);
|
|
36142
|
-
(0,
|
|
36469
|
+
(0, import_react244.useEffect)(() => {
|
|
36143
36470
|
if (!mobileOpen) return;
|
|
36144
36471
|
const level = levels[mobileLevelIndex] || "province";
|
|
36145
36472
|
const parentLevel = levels[mobileLevelIndex - 1];
|
|
@@ -36318,7 +36645,7 @@ function AddressField(props) {
|
|
|
36318
36645
|
|
|
36319
36646
|
// packages/sdk/src/components/fields/AssociationFormField/index.tsx
|
|
36320
36647
|
init_cjs_shims();
|
|
36321
|
-
var
|
|
36648
|
+
var import_react245 = require("react");
|
|
36322
36649
|
var import_antd19 = require("antd");
|
|
36323
36650
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
36324
36651
|
var DEFAULT_PAGE_SIZE = 10;
|
|
@@ -36381,45 +36708,45 @@ function AssociationFormField(props) {
|
|
|
36381
36708
|
const { isMobile } = useDeviceDetect();
|
|
36382
36709
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
36383
36710
|
const rawValue = formData[fieldId];
|
|
36384
|
-
const value = (0,
|
|
36711
|
+
const value = (0, import_react245.useMemo)(() => normalizeValues(rawValue), [rawValue]);
|
|
36385
36712
|
const disabled = behavior === "DISABLED";
|
|
36386
|
-
const [options, setOptions] = (0,
|
|
36387
|
-
const [selectLoading, setSelectLoading] = (0,
|
|
36388
|
-
const [selectorOpen, setSelectorOpen] = (0,
|
|
36389
|
-
const [tableLoading, setTableLoading] = (0,
|
|
36390
|
-
const [tableData, setTableData] = (0,
|
|
36391
|
-
const [keyword, setKeyword] = (0,
|
|
36392
|
-
const [pagination, setPagination] = (0,
|
|
36713
|
+
const [options, setOptions] = (0, import_react245.useState)([]);
|
|
36714
|
+
const [selectLoading, setSelectLoading] = (0, import_react245.useState)(false);
|
|
36715
|
+
const [selectorOpen, setSelectorOpen] = (0, import_react245.useState)(false);
|
|
36716
|
+
const [tableLoading, setTableLoading] = (0, import_react245.useState)(false);
|
|
36717
|
+
const [tableData, setTableData] = (0, import_react245.useState)([]);
|
|
36718
|
+
const [keyword, setKeyword] = (0, import_react245.useState)("");
|
|
36719
|
+
const [pagination, setPagination] = (0, import_react245.useState)({
|
|
36393
36720
|
current: 1,
|
|
36394
36721
|
pageSize: DEFAULT_PAGE_SIZE,
|
|
36395
36722
|
total: 0
|
|
36396
36723
|
});
|
|
36397
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
36398
|
-
const [selectedRecords, setSelectedRecords] = (0,
|
|
36399
|
-
const formDataRef = (0,
|
|
36400
|
-
const associationFormRef = (0,
|
|
36401
|
-
(0,
|
|
36724
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react245.useState)([]);
|
|
36725
|
+
const [selectedRecords, setSelectedRecords] = (0, import_react245.useState)([]);
|
|
36726
|
+
const formDataRef = (0, import_react245.useRef)(formData);
|
|
36727
|
+
const associationFormRef = (0, import_react245.useRef)(associationForm);
|
|
36728
|
+
(0, import_react245.useEffect)(() => {
|
|
36402
36729
|
registerField(fieldId);
|
|
36403
36730
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
36404
36731
|
setFieldValue(fieldId, normalizeValues(defaultValue));
|
|
36405
36732
|
}
|
|
36406
36733
|
return () => unregisterField(fieldId);
|
|
36407
36734
|
}, [fieldId]);
|
|
36408
|
-
(0,
|
|
36735
|
+
(0, import_react245.useEffect)(() => {
|
|
36409
36736
|
formDataRef.current = formData;
|
|
36410
36737
|
}, [formData]);
|
|
36411
|
-
(0,
|
|
36738
|
+
(0, import_react245.useEffect)(() => {
|
|
36412
36739
|
associationFormRef.current = associationForm;
|
|
36413
36740
|
}, [associationForm]);
|
|
36414
36741
|
const associationAppType = associationForm?.appType;
|
|
36415
36742
|
const associationFormUuid = associationForm?.formUuid;
|
|
36416
36743
|
const associationMainFieldId = associationForm?.mainFieldId;
|
|
36417
36744
|
const canQuery = Boolean(associationAppType && associationFormUuid);
|
|
36418
|
-
const filterRulesKey = (0,
|
|
36745
|
+
const filterRulesKey = (0, import_react245.useMemo)(
|
|
36419
36746
|
() => stableSerialize(associationForm?.dataFilterRules || []),
|
|
36420
36747
|
[associationForm?.dataFilterRules]
|
|
36421
36748
|
);
|
|
36422
|
-
const currentFieldFilterKey = (0,
|
|
36749
|
+
const currentFieldFilterKey = (0, import_react245.useMemo)(() => {
|
|
36423
36750
|
const rules2 = associationForm?.dataFilterRules || [];
|
|
36424
36751
|
return stableSerialize(
|
|
36425
36752
|
rules2.map((rule) => {
|
|
@@ -36428,11 +36755,11 @@ function AssociationFormField(props) {
|
|
|
36428
36755
|
})
|
|
36429
36756
|
);
|
|
36430
36757
|
}, [formData, associationForm?.dataFilterRules]);
|
|
36431
|
-
const filterDependencyKey = (0,
|
|
36758
|
+
const filterDependencyKey = (0, import_react245.useMemo)(
|
|
36432
36759
|
() => `${filterRulesKey}:${currentFieldFilterKey}`,
|
|
36433
36760
|
[currentFieldFilterKey, filterRulesKey]
|
|
36434
36761
|
);
|
|
36435
|
-
const normalizeRecord = (0,
|
|
36762
|
+
const normalizeRecord = (0, import_react245.useCallback)(
|
|
36436
36763
|
(record2) => {
|
|
36437
36764
|
const mainFieldValue = associationMainFieldId ? record2?.[associationMainFieldId] : void 0;
|
|
36438
36765
|
const labelText = normalizeCellValue(mainFieldValue);
|
|
@@ -36445,7 +36772,7 @@ function AssociationFormField(props) {
|
|
|
36445
36772
|
},
|
|
36446
36773
|
[associationMainFieldId]
|
|
36447
36774
|
);
|
|
36448
|
-
const toValue = (0,
|
|
36775
|
+
const toValue = (0, import_react245.useCallback)(
|
|
36449
36776
|
(record2) => ({
|
|
36450
36777
|
label: record2.__associationLabel,
|
|
36451
36778
|
value: record2.__associationValue,
|
|
@@ -36453,7 +36780,7 @@ function AssociationFormField(props) {
|
|
|
36453
36780
|
}),
|
|
36454
36781
|
[]
|
|
36455
36782
|
);
|
|
36456
|
-
const buildFilters = (0,
|
|
36783
|
+
const buildFilters = (0, import_react245.useCallback)(() => {
|
|
36457
36784
|
void filterDependencyKey;
|
|
36458
36785
|
const rules2 = associationFormRef.current?.dataFilterRules || [];
|
|
36459
36786
|
const currentFormData = formDataRef.current;
|
|
@@ -36469,7 +36796,7 @@ function AssociationFormField(props) {
|
|
|
36469
36796
|
};
|
|
36470
36797
|
}).filter(Boolean);
|
|
36471
36798
|
}, [filterDependencyKey]);
|
|
36472
|
-
const fetchRecords = (0,
|
|
36799
|
+
const fetchRecords = (0, import_react245.useCallback)(
|
|
36473
36800
|
async (params) => {
|
|
36474
36801
|
if (!canQuery) return { list: [], total: 0 };
|
|
36475
36802
|
const filters = buildFilters();
|
|
@@ -36492,7 +36819,7 @@ function AssociationFormField(props) {
|
|
|
36492
36819
|
},
|
|
36493
36820
|
[api, associationAppType, associationFormUuid, buildFilters, canQuery, normalizeRecord]
|
|
36494
36821
|
);
|
|
36495
|
-
const loadOptions = (0,
|
|
36822
|
+
const loadOptions = (0, import_react245.useCallback)(
|
|
36496
36823
|
async (searchKeyWord) => {
|
|
36497
36824
|
setSelectLoading(true);
|
|
36498
36825
|
try {
|
|
@@ -36504,7 +36831,7 @@ function AssociationFormField(props) {
|
|
|
36504
36831
|
},
|
|
36505
36832
|
[fetchRecords, toValue]
|
|
36506
36833
|
);
|
|
36507
|
-
const loadTable = (0,
|
|
36834
|
+
const loadTable = (0, import_react245.useCallback)(
|
|
36508
36835
|
async (next) => {
|
|
36509
36836
|
setTableLoading(true);
|
|
36510
36837
|
const current = next?.current || 1;
|
|
@@ -36523,10 +36850,10 @@ function AssociationFormField(props) {
|
|
|
36523
36850
|
},
|
|
36524
36851
|
[fetchRecords, keyword, pagination.pageSize]
|
|
36525
36852
|
);
|
|
36526
|
-
(0,
|
|
36853
|
+
(0, import_react245.useEffect)(() => {
|
|
36527
36854
|
void loadOptions();
|
|
36528
36855
|
}, [loadOptions]);
|
|
36529
|
-
(0,
|
|
36856
|
+
(0, import_react245.useEffect)(() => {
|
|
36530
36857
|
setSelectedRowKeys(value.map((item) => item.value));
|
|
36531
36858
|
setSelectedRecords(
|
|
36532
36859
|
value.map(
|
|
@@ -36534,7 +36861,7 @@ function AssociationFormField(props) {
|
|
|
36534
36861
|
).filter(Boolean)
|
|
36535
36862
|
);
|
|
36536
36863
|
}, [normalizeRecord, value]);
|
|
36537
|
-
const applyDataFilling = (0,
|
|
36864
|
+
const applyDataFilling = (0, import_react245.useCallback)(
|
|
36538
36865
|
(next) => {
|
|
36539
36866
|
if (!associationForm?.dataFillingEnabled && !associationForm?.dataFillingRules?.mainRules) {
|
|
36540
36867
|
return;
|
|
@@ -36548,7 +36875,7 @@ function AssociationFormField(props) {
|
|
|
36548
36875
|
},
|
|
36549
36876
|
[associationForm?.dataFillingEnabled, associationForm?.dataFillingRules, setFieldValue]
|
|
36550
36877
|
);
|
|
36551
|
-
const commitSelection = (0,
|
|
36878
|
+
const commitSelection = (0, import_react245.useCallback)(
|
|
36552
36879
|
(next) => {
|
|
36553
36880
|
const normalized = multiple ? next : next.slice(0, 1);
|
|
36554
36881
|
setFieldValue(fieldId, normalized);
|
|
@@ -36557,7 +36884,7 @@ function AssociationFormField(props) {
|
|
|
36557
36884
|
},
|
|
36558
36885
|
[applyDataFilling, fieldId, multiple, onChange, setFieldValue]
|
|
36559
36886
|
);
|
|
36560
|
-
const selectorColumns = (0,
|
|
36887
|
+
const selectorColumns = (0, import_react245.useMemo)(() => {
|
|
36561
36888
|
const configured = associationForm?.selectorColumns || [];
|
|
36562
36889
|
if (configured.length) {
|
|
36563
36890
|
return configured.map((column) => {
|
|
@@ -36592,7 +36919,7 @@ function AssociationFormField(props) {
|
|
|
36592
36919
|
}
|
|
36593
36920
|
];
|
|
36594
36921
|
}, [associationForm?.mainFieldId, associationForm?.selectorColumns]);
|
|
36595
|
-
const selectOptions = (0,
|
|
36922
|
+
const selectOptions = (0, import_react245.useMemo)(
|
|
36596
36923
|
() => [...options, ...value].filter(
|
|
36597
36924
|
(item, index2, list) => list.findIndex((candidate) => candidate.value === item.value) === index2
|
|
36598
36925
|
).map((item) => ({ label: item.label, value: item.value })),
|
|
@@ -36801,9 +37128,9 @@ function AssociationFormField(props) {
|
|
|
36801
37128
|
|
|
36802
37129
|
// packages/sdk/src/components/fields/EditorField/index.tsx
|
|
36803
37130
|
init_cjs_shims();
|
|
36804
|
-
var
|
|
37131
|
+
var import_react246 = require("react");
|
|
36805
37132
|
var import_core4 = require("@tiptap/core");
|
|
36806
|
-
var
|
|
37133
|
+
var import_react247 = require("@tiptap/react");
|
|
36807
37134
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
36808
37135
|
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
36809
37136
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
@@ -37437,28 +37764,28 @@ function RichTextEditorCore({
|
|
|
37437
37764
|
fieldId = "richText",
|
|
37438
37765
|
mobile = false
|
|
37439
37766
|
}) {
|
|
37440
|
-
const inputRef = (0,
|
|
37441
|
-
const [uploading, setUploading] = (0,
|
|
37442
|
-
const [uploadError, setUploadError] = (0,
|
|
37443
|
-
const [charCount, setCharCount] = (0,
|
|
37444
|
-
const [linkOpen, setLinkOpen] = (0,
|
|
37445
|
-
const [linkUrl, setLinkUrl] = (0,
|
|
37446
|
-
const [linkError, setLinkError] = (0,
|
|
37447
|
-
const [imageUrlOpen, setImageUrlOpen] = (0,
|
|
37448
|
-
const [imageUrl, setImageUrl] = (0,
|
|
37449
|
-
const [imageAlt, setImageAlt] = (0,
|
|
37450
|
-
const [imageTitle, setImageTitle] = (0,
|
|
37451
|
-
const [imageUrlError, setImageUrlError] = (0,
|
|
37452
|
-
const [tableOpen, setTableOpen] = (0,
|
|
37453
|
-
const [tableRows, setTableRows] = (0,
|
|
37454
|
-
const [tableCols, setTableCols] = (0,
|
|
37455
|
-
const onChangeRef = (0,
|
|
37456
|
-
(0,
|
|
37767
|
+
const inputRef = (0, import_react246.useRef)(null);
|
|
37768
|
+
const [uploading, setUploading] = (0, import_react246.useState)(false);
|
|
37769
|
+
const [uploadError, setUploadError] = (0, import_react246.useState)("");
|
|
37770
|
+
const [charCount, setCharCount] = (0, import_react246.useState)(0);
|
|
37771
|
+
const [linkOpen, setLinkOpen] = (0, import_react246.useState)(false);
|
|
37772
|
+
const [linkUrl, setLinkUrl] = (0, import_react246.useState)("");
|
|
37773
|
+
const [linkError, setLinkError] = (0, import_react246.useState)("");
|
|
37774
|
+
const [imageUrlOpen, setImageUrlOpen] = (0, import_react246.useState)(false);
|
|
37775
|
+
const [imageUrl, setImageUrl] = (0, import_react246.useState)("");
|
|
37776
|
+
const [imageAlt, setImageAlt] = (0, import_react246.useState)("");
|
|
37777
|
+
const [imageTitle, setImageTitle] = (0, import_react246.useState)("");
|
|
37778
|
+
const [imageUrlError, setImageUrlError] = (0, import_react246.useState)("");
|
|
37779
|
+
const [tableOpen, setTableOpen] = (0, import_react246.useState)(false);
|
|
37780
|
+
const [tableRows, setTableRows] = (0, import_react246.useState)(3);
|
|
37781
|
+
const [tableCols, setTableCols] = (0, import_react246.useState)(3);
|
|
37782
|
+
const onChangeRef = (0, import_react246.useRef)(onChange);
|
|
37783
|
+
(0, import_react246.useEffect)(() => {
|
|
37457
37784
|
onChangeRef.current = onChange;
|
|
37458
37785
|
}, [onChange]);
|
|
37459
|
-
const actions = (0,
|
|
37786
|
+
const actions = (0, import_react246.useMemo)(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
|
|
37460
37787
|
const visibleActions = mobile ? [] : actions;
|
|
37461
|
-
const extensions = (0,
|
|
37788
|
+
const extensions = (0, import_react246.useMemo)(
|
|
37462
37789
|
() => [
|
|
37463
37790
|
import_starter_kit.default.configure({
|
|
37464
37791
|
heading: { levels: [1, 2, 3] },
|
|
@@ -37492,10 +37819,10 @@ function RichTextEditorCore({
|
|
|
37492
37819
|
],
|
|
37493
37820
|
[maxLength, placeholder]
|
|
37494
37821
|
);
|
|
37495
|
-
const updateHtml = (0,
|
|
37822
|
+
const updateHtml = (0, import_react246.useCallback)((next) => {
|
|
37496
37823
|
onChangeRef.current?.(next);
|
|
37497
37824
|
}, []);
|
|
37498
|
-
const editor = (0,
|
|
37825
|
+
const editor = (0, import_react247.useEditor)(
|
|
37499
37826
|
{
|
|
37500
37827
|
extensions,
|
|
37501
37828
|
content: value || "",
|
|
@@ -37522,11 +37849,11 @@ function RichTextEditorCore({
|
|
|
37522
37849
|
},
|
|
37523
37850
|
[fieldId, extensions, disabled, maxLength, updateHtml]
|
|
37524
37851
|
);
|
|
37525
|
-
(0,
|
|
37852
|
+
(0, import_react246.useEffect)(() => {
|
|
37526
37853
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
37527
37854
|
editor.setEditable(!disabled);
|
|
37528
37855
|
}, [disabled, editor]);
|
|
37529
|
-
(0,
|
|
37856
|
+
(0, import_react246.useEffect)(() => {
|
|
37530
37857
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
37531
37858
|
const currentHtml = getSafeEditorHtml(editor);
|
|
37532
37859
|
if ((value || "") !== currentHtml) {
|
|
@@ -37534,7 +37861,7 @@ function RichTextEditorCore({
|
|
|
37534
37861
|
}
|
|
37535
37862
|
setCharCount(countCharacters(editor));
|
|
37536
37863
|
}, [editor, value]);
|
|
37537
|
-
const insertImageFiles = (0,
|
|
37864
|
+
const insertImageFiles = (0, import_react246.useCallback)(
|
|
37538
37865
|
async (files) => {
|
|
37539
37866
|
if (!editor || isEditorDestroyed(editor) || disabled || files.length === 0) return;
|
|
37540
37867
|
const validFiles = files.filter((file) => {
|
|
@@ -37564,7 +37891,7 @@ function RichTextEditorCore({
|
|
|
37564
37891
|
},
|
|
37565
37892
|
[allowedImageTypes, api, disabled, editor, maxImageSize, uploadBucketName]
|
|
37566
37893
|
);
|
|
37567
|
-
const openLinkModal = (0,
|
|
37894
|
+
const openLinkModal = (0, import_react246.useCallback)(() => {
|
|
37568
37895
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
37569
37896
|
setLinkUrl(editor.getAttributes("link").href || "");
|
|
37570
37897
|
setLinkError("");
|
|
@@ -37590,7 +37917,7 @@ function RichTextEditorCore({
|
|
|
37590
37917
|
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
37591
37918
|
setLinkOpen(false);
|
|
37592
37919
|
};
|
|
37593
|
-
const openImageUrlModal = (0,
|
|
37920
|
+
const openImageUrlModal = (0, import_react246.useCallback)(() => {
|
|
37594
37921
|
setImageUrl("");
|
|
37595
37922
|
setImageAlt("");
|
|
37596
37923
|
setImageTitle("");
|
|
@@ -37667,7 +37994,7 @@ function RichTextEditorCore({
|
|
|
37667
37994
|
void insertImageFiles(files);
|
|
37668
37995
|
}
|
|
37669
37996
|
},
|
|
37670
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
37997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_react247.EditorContent, { editor })
|
|
37671
37998
|
}
|
|
37672
37999
|
),
|
|
37673
38000
|
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
@@ -37840,19 +38167,19 @@ function EditorField(props) {
|
|
|
37840
38167
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
37841
38168
|
const rawValue = formData[fieldId] ?? "";
|
|
37842
38169
|
const value = normalizeRichTextHtml(rawValue);
|
|
37843
|
-
(0,
|
|
38170
|
+
(0, import_react246.useEffect)(() => {
|
|
37844
38171
|
registerField(fieldId);
|
|
37845
38172
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
37846
38173
|
setFieldValue(fieldId, normalizeRichTextHtml(defaultValue));
|
|
37847
38174
|
}
|
|
37848
38175
|
return () => unregisterField(fieldId);
|
|
37849
38176
|
}, [fieldId]);
|
|
37850
|
-
(0,
|
|
38177
|
+
(0, import_react246.useEffect)(() => {
|
|
37851
38178
|
if (rawValue && rawValue !== value) {
|
|
37852
38179
|
setFieldValue(fieldId, value);
|
|
37853
38180
|
}
|
|
37854
38181
|
}, [fieldId, rawValue, setFieldValue, value]);
|
|
37855
|
-
const updateHtml = (0,
|
|
38182
|
+
const updateHtml = (0, import_react246.useCallback)(
|
|
37856
38183
|
(next) => {
|
|
37857
38184
|
setFieldValue(fieldId, next);
|
|
37858
38185
|
onChange?.(next);
|
|
@@ -37906,7 +38233,7 @@ function EditorField(props) {
|
|
|
37906
38233
|
|
|
37907
38234
|
// packages/sdk/src/components/fields/SerialNumberField/index.tsx
|
|
37908
38235
|
init_cjs_shims();
|
|
37909
|
-
var
|
|
38236
|
+
var import_react248 = require("react");
|
|
37910
38237
|
var import_antd21 = require("antd");
|
|
37911
38238
|
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
37912
38239
|
function SerialNumberField(props) {
|
|
@@ -37926,7 +38253,7 @@ function SerialNumberField(props) {
|
|
|
37926
38253
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
37927
38254
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
37928
38255
|
const value = formData[fieldId] ?? "";
|
|
37929
|
-
(0,
|
|
38256
|
+
(0, import_react248.useEffect)(() => {
|
|
37930
38257
|
registerField(fieldId);
|
|
37931
38258
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
37932
38259
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -37969,7 +38296,7 @@ function SerialNumberField(props) {
|
|
|
37969
38296
|
|
|
37970
38297
|
// packages/sdk/src/components/fields/LocationField/index.tsx
|
|
37971
38298
|
init_cjs_shims();
|
|
37972
|
-
var
|
|
38299
|
+
var import_react249 = require("react");
|
|
37973
38300
|
var import_antd22 = require("antd");
|
|
37974
38301
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
37975
38302
|
var getDingTalkApi = () => {
|
|
@@ -38011,9 +38338,9 @@ function LocationField(props) {
|
|
|
38011
38338
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
38012
38339
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
38013
38340
|
const value = formData[fieldId];
|
|
38014
|
-
const [locating, setLocating] = (0,
|
|
38015
|
-
const [error, setError] = (0,
|
|
38016
|
-
(0,
|
|
38341
|
+
const [locating, setLocating] = (0, import_react249.useState)(false);
|
|
38342
|
+
const [error, setError] = (0, import_react249.useState)("");
|
|
38343
|
+
(0, import_react249.useEffect)(() => {
|
|
38017
38344
|
registerField(fieldId);
|
|
38018
38345
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
38019
38346
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -38155,7 +38482,7 @@ function LocationField(props) {
|
|
|
38155
38482
|
|
|
38156
38483
|
// packages/sdk/src/components/fields/DigitalSignatureField/index.tsx
|
|
38157
38484
|
init_cjs_shims();
|
|
38158
|
-
var
|
|
38485
|
+
var import_react250 = require("react");
|
|
38159
38486
|
var import_antd23 = require("antd");
|
|
38160
38487
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
38161
38488
|
var CANVAS_HEIGHT = 260;
|
|
@@ -38189,21 +38516,21 @@ function DigitalSignatureField(props) {
|
|
|
38189
38516
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
38190
38517
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
38191
38518
|
const value = formData[fieldId];
|
|
38192
|
-
const [open, setOpen] = (0,
|
|
38193
|
-
const [saving, setSaving] = (0,
|
|
38194
|
-
const [drawn, setDrawn] = (0,
|
|
38195
|
-
const [error, setError] = (0,
|
|
38196
|
-
const canvasRef = (0,
|
|
38197
|
-
const drawingRef = (0,
|
|
38198
|
-
const pointsRef = (0,
|
|
38199
|
-
(0,
|
|
38519
|
+
const [open, setOpen] = (0, import_react250.useState)(false);
|
|
38520
|
+
const [saving, setSaving] = (0, import_react250.useState)(false);
|
|
38521
|
+
const [drawn, setDrawn] = (0, import_react250.useState)(false);
|
|
38522
|
+
const [error, setError] = (0, import_react250.useState)("");
|
|
38523
|
+
const canvasRef = (0, import_react250.useRef)(null);
|
|
38524
|
+
const drawingRef = (0, import_react250.useRef)(false);
|
|
38525
|
+
const pointsRef = (0, import_react250.useRef)([]);
|
|
38526
|
+
(0, import_react250.useEffect)(() => {
|
|
38200
38527
|
registerField(fieldId);
|
|
38201
38528
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
38202
38529
|
setFieldValue(fieldId, defaultValue);
|
|
38203
38530
|
}
|
|
38204
38531
|
return () => unregisterField(fieldId);
|
|
38205
38532
|
}, [fieldId]);
|
|
38206
|
-
const prepareCanvas = (0,
|
|
38533
|
+
const prepareCanvas = (0, import_react250.useCallback)(() => {
|
|
38207
38534
|
const canvas = canvasRef.current;
|
|
38208
38535
|
if (!canvas) return;
|
|
38209
38536
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -38225,7 +38552,7 @@ function DigitalSignatureField(props) {
|
|
|
38225
38552
|
ctx2.lineJoin = "round";
|
|
38226
38553
|
ctx2.strokeStyle = "#111827";
|
|
38227
38554
|
}, []);
|
|
38228
|
-
(0,
|
|
38555
|
+
(0, import_react250.useEffect)(() => {
|
|
38229
38556
|
if (!open) return;
|
|
38230
38557
|
pointsRef.current = [];
|
|
38231
38558
|
setDrawn(false);
|
|
@@ -38405,7 +38732,7 @@ function DigitalSignatureField(props) {
|
|
|
38405
38732
|
|
|
38406
38733
|
// packages/sdk/src/components/fields/JSONField/index.tsx
|
|
38407
38734
|
init_cjs_shims();
|
|
38408
|
-
var
|
|
38735
|
+
var import_react251 = require("react");
|
|
38409
38736
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
38410
38737
|
var formatJson = (value) => {
|
|
38411
38738
|
if (value === void 0 || value === null || value === "") return "--";
|
|
@@ -38432,7 +38759,7 @@ function JSONField(props) {
|
|
|
38432
38759
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
38433
38760
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
38434
38761
|
const value = formData[fieldId];
|
|
38435
|
-
(0,
|
|
38762
|
+
(0, import_react251.useEffect)(() => {
|
|
38436
38763
|
registerField(fieldId);
|
|
38437
38764
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
38438
38765
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -39144,156 +39471,6 @@ function createFormRuntimeApi(config3) {
|
|
|
39144
39471
|
return { ...defaults2, ...overrides, request };
|
|
39145
39472
|
}
|
|
39146
39473
|
|
|
39147
|
-
// packages/sdk/src/components/core/optionSource.ts
|
|
39148
|
-
init_cjs_shims();
|
|
39149
|
-
function normalizeOptionItem(row, fieldId) {
|
|
39150
|
-
const rawValue = row?.[fieldId] ?? row?.value;
|
|
39151
|
-
if (rawValue === void 0 || rawValue === null || rawValue === "") return null;
|
|
39152
|
-
if (typeof rawValue === "object" && !Array.isArray(rawValue)) {
|
|
39153
|
-
const value = rawValue.value ?? rawValue.id ?? rawValue.key ?? rawValue.label;
|
|
39154
|
-
const label = rawValue.label ?? rawValue.name ?? rawValue.title ?? rawValue.value ?? value;
|
|
39155
|
-
if (value === void 0 || value === null || value === "") return null;
|
|
39156
|
-
return { value: String(value), label: String(label ?? value) };
|
|
39157
|
-
}
|
|
39158
|
-
const fallbackLabel = row?.label;
|
|
39159
|
-
return {
|
|
39160
|
-
value: String(rawValue),
|
|
39161
|
-
label: fallbackLabel === void 0 || fallbackLabel === null ? String(rawValue) : String(fallbackLabel)
|
|
39162
|
-
};
|
|
39163
|
-
}
|
|
39164
|
-
function extractComparableValue(value) {
|
|
39165
|
-
if (value === void 0 || value === null || value === "") return value;
|
|
39166
|
-
if (Array.isArray(value)) {
|
|
39167
|
-
return value.map(extractComparableValue).filter((item) => item !== void 0 && item !== null && item !== "");
|
|
39168
|
-
}
|
|
39169
|
-
if (typeof value === "object") {
|
|
39170
|
-
if ("start" in value || "end" in value) {
|
|
39171
|
-
return [value.start, value.end].filter(
|
|
39172
|
-
(item) => item !== void 0 && item !== null && item !== ""
|
|
39173
|
-
);
|
|
39174
|
-
}
|
|
39175
|
-
return value.value ?? value.id ?? value.key ?? value.userId ?? value.userid ?? value.departmentId ?? value.deptId ?? value.label ?? value.name;
|
|
39176
|
-
}
|
|
39177
|
-
return value;
|
|
39178
|
-
}
|
|
39179
|
-
function normalizeFilterOperator(operator, value) {
|
|
39180
|
-
const normalized = operator === "neq" ? "ne" : operator || "eq";
|
|
39181
|
-
if (Array.isArray(value) && value.length > 0 && (normalized === "eq" || normalized === "contains")) {
|
|
39182
|
-
return "in";
|
|
39183
|
-
}
|
|
39184
|
-
return normalized;
|
|
39185
|
-
}
|
|
39186
|
-
async function resolveOptions(config3, runtime, formData) {
|
|
39187
|
-
switch (config3.type) {
|
|
39188
|
-
case "custom":
|
|
39189
|
-
return [];
|
|
39190
|
-
// custom 类型直接用 props.options
|
|
39191
|
-
case "linkedForm":
|
|
39192
|
-
if (!config3.linkedForm) return [];
|
|
39193
|
-
return resolveLinkedFormOptions(config3.linkedForm, runtime);
|
|
39194
|
-
case "dataLinkage":
|
|
39195
|
-
if (!config3.dataLinkage) return [];
|
|
39196
|
-
return resolveDataLinkageOptions(config3.dataLinkage, runtime, formData);
|
|
39197
|
-
default:
|
|
39198
|
-
return [];
|
|
39199
|
-
}
|
|
39200
|
-
}
|
|
39201
|
-
async function resolveLinkedFormOptions(config3, runtime) {
|
|
39202
|
-
if (!runtime?.fetchFormData) return [];
|
|
39203
|
-
try {
|
|
39204
|
-
const filters = config3.filters?.map((f) => ({
|
|
39205
|
-
fieldId: f.fieldId,
|
|
39206
|
-
operator: normalizeFilterOperator(f.operator, extractComparableValue(f.value)),
|
|
39207
|
-
value: extractComparableValue(f.value)
|
|
39208
|
-
})) || [];
|
|
39209
|
-
const result = await runtime.fetchFormData({
|
|
39210
|
-
formUuid: config3.formUuid,
|
|
39211
|
-
appType: runtime.appType || "",
|
|
39212
|
-
filters,
|
|
39213
|
-
sort: config3.sortField ? { field: config3.sortField, order: config3.sortOrder || "asc" } : void 0,
|
|
39214
|
-
fieldId: config3.fieldId,
|
|
39215
|
-
deduplicate: config3.deduplicate,
|
|
39216
|
-
pageSize: 200
|
|
39217
|
-
});
|
|
39218
|
-
const items = result.data.map((row) => normalizeOptionItem(row, config3.fieldId)).filter((item) => Boolean(item));
|
|
39219
|
-
if (config3.deduplicate) {
|
|
39220
|
-
const seen = /* @__PURE__ */ new Set();
|
|
39221
|
-
return items.filter((item) => {
|
|
39222
|
-
if (seen.has(item.value)) return false;
|
|
39223
|
-
seen.add(item.value);
|
|
39224
|
-
return true;
|
|
39225
|
-
});
|
|
39226
|
-
}
|
|
39227
|
-
return items;
|
|
39228
|
-
} catch (e2) {
|
|
39229
|
-
console.error("[FormComponents] resolveLinkedFormOptions failed:", e2);
|
|
39230
|
-
return [];
|
|
39231
|
-
}
|
|
39232
|
-
}
|
|
39233
|
-
async function resolveDataLinkageOptions(config3, runtime, formData) {
|
|
39234
|
-
if (!runtime?.fetchFormData) return [];
|
|
39235
|
-
try {
|
|
39236
|
-
const filters = config3.conditions.map((condition) => {
|
|
39237
|
-
const value = extractComparableValue(formData[condition.localFieldId]);
|
|
39238
|
-
return {
|
|
39239
|
-
fieldId: condition.remoteFieldId,
|
|
39240
|
-
operator: normalizeFilterOperator(condition.operator, value),
|
|
39241
|
-
value
|
|
39242
|
-
};
|
|
39243
|
-
});
|
|
39244
|
-
const result = await runtime.fetchFormData({
|
|
39245
|
-
formUuid: config3.formUuid,
|
|
39246
|
-
appType: runtime.appType || "",
|
|
39247
|
-
filters,
|
|
39248
|
-
conditionLogic: config3.conditionLogic,
|
|
39249
|
-
fieldId: config3.targetFieldId,
|
|
39250
|
-
deduplicate: config3.deduplicate,
|
|
39251
|
-
pageSize: 200
|
|
39252
|
-
});
|
|
39253
|
-
const items = result.data.map((row) => normalizeOptionItem(row, config3.targetFieldId)).filter((item) => Boolean(item));
|
|
39254
|
-
if (config3.deduplicate) {
|
|
39255
|
-
const seen = /* @__PURE__ */ new Set();
|
|
39256
|
-
return items.filter((item) => {
|
|
39257
|
-
if (seen.has(item.value)) return false;
|
|
39258
|
-
seen.add(item.value);
|
|
39259
|
-
return true;
|
|
39260
|
-
});
|
|
39261
|
-
}
|
|
39262
|
-
return items;
|
|
39263
|
-
} catch (e2) {
|
|
39264
|
-
console.error("[FormComponents] resolveDataLinkageOptions failed:", e2);
|
|
39265
|
-
return [];
|
|
39266
|
-
}
|
|
39267
|
-
}
|
|
39268
|
-
async function resolveDefaultValueLinkage(config3, runtime, formData) {
|
|
39269
|
-
if (!runtime?.fetchFormData) return void 0;
|
|
39270
|
-
try {
|
|
39271
|
-
const filters = config3.conditions.map((condition) => {
|
|
39272
|
-
const value = extractComparableValue(formData[condition.localFieldId]);
|
|
39273
|
-
return {
|
|
39274
|
-
fieldId: condition.remoteFieldId,
|
|
39275
|
-
operator: normalizeFilterOperator(condition.operator, value),
|
|
39276
|
-
value
|
|
39277
|
-
};
|
|
39278
|
-
});
|
|
39279
|
-
const result = await runtime.fetchFormData({
|
|
39280
|
-
formUuid: config3.formUuid,
|
|
39281
|
-
appType: runtime.appType || "",
|
|
39282
|
-
filters,
|
|
39283
|
-
conditionLogic: config3.conditionLogic,
|
|
39284
|
-
fieldId: config3.targetFieldId,
|
|
39285
|
-
pageSize: 200
|
|
39286
|
-
});
|
|
39287
|
-
if (result.data.length > 0) {
|
|
39288
|
-
return result.data[0][config3.targetFieldId] ?? result.data[0].value ?? void 0;
|
|
39289
|
-
}
|
|
39290
|
-
return void 0;
|
|
39291
|
-
} catch (e2) {
|
|
39292
|
-
console.error("[FormComponents] resolveDefaultValueLinkage failed:", e2);
|
|
39293
|
-
return void 0;
|
|
39294
|
-
}
|
|
39295
|
-
}
|
|
39296
|
-
|
|
39297
39474
|
// packages/sdk/src/components/core/FormProvider.tsx
|
|
39298
39475
|
var LINKAGE_DEBOUNCE_MS = 500;
|
|
39299
39476
|
function isInactiveBehavior(behavior) {
|
|
@@ -39428,9 +39605,9 @@ function FormProvider3({
|
|
|
39428
39605
|
runtime,
|
|
39429
39606
|
children
|
|
39430
39607
|
}) {
|
|
39431
|
-
const api = (0,
|
|
39432
|
-
const [runtimeDefaults, setRuntimeDefaults] = (0,
|
|
39433
|
-
const effects = (0,
|
|
39608
|
+
const api = (0, import_react252.useMemo)(() => createFormRuntimeApi(config3.api), [config3.api]);
|
|
39609
|
+
const [runtimeDefaults, setRuntimeDefaults] = (0, import_react252.useState)({});
|
|
39610
|
+
const effects = (0, import_react252.useMemo)(
|
|
39434
39611
|
() => [
|
|
39435
39612
|
...schema.rules ?? [],
|
|
39436
39613
|
...schema.fields.flatMap((field) => field.optionEffects ?? []),
|
|
@@ -39438,18 +39615,18 @@ function FormProvider3({
|
|
|
39438
39615
|
],
|
|
39439
39616
|
[schema.rules, schema.fields, config3.effects]
|
|
39440
39617
|
);
|
|
39441
|
-
const defaultRuntime = (0,
|
|
39618
|
+
const defaultRuntime = (0, import_react252.useMemo)(
|
|
39442
39619
|
() => ({
|
|
39443
39620
|
appType: config3.appType,
|
|
39444
39621
|
fetchFormData: (params) => fetchRuntimeFormData(api, config3.appType, params)
|
|
39445
39622
|
}),
|
|
39446
39623
|
[api, config3.appType]
|
|
39447
39624
|
);
|
|
39448
|
-
const mergedRuntime = (0,
|
|
39625
|
+
const mergedRuntime = (0, import_react252.useMemo)(
|
|
39449
39626
|
() => ({ ...defaultRuntime, ...schema.runtime, ...runtimeDefaults, ...runtime }),
|
|
39450
39627
|
[defaultRuntime, schema.runtime, runtimeDefaults, runtime]
|
|
39451
39628
|
);
|
|
39452
|
-
const computedInitialValues = (0,
|
|
39629
|
+
const computedInitialValues = (0, import_react252.useMemo)(() => {
|
|
39453
39630
|
const values = {};
|
|
39454
39631
|
for (const field of schema.fields) {
|
|
39455
39632
|
const defaultValue = resolveDefaultValue(field, mergedRuntime);
|
|
@@ -39459,11 +39636,11 @@ function FormProvider3({
|
|
|
39459
39636
|
}
|
|
39460
39637
|
return { ...values, ...initialValues };
|
|
39461
39638
|
}, [schema, initialValues, mergedRuntime]);
|
|
39462
|
-
const initialValuesRef = (0,
|
|
39463
|
-
const [formData, setFormData] = (0,
|
|
39464
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
39465
|
-
const [registeredFields] = (0,
|
|
39466
|
-
(0,
|
|
39639
|
+
const initialValuesRef = (0, import_react252.useRef)(computedInitialValues);
|
|
39640
|
+
const [formData, setFormData] = (0, import_react252.useState)({ ...computedInitialValues });
|
|
39641
|
+
const [fieldErrors, setFieldErrors] = (0, import_react252.useState)({});
|
|
39642
|
+
const [registeredFields] = (0, import_react252.useState)(/* @__PURE__ */ new Set());
|
|
39643
|
+
(0, import_react252.useEffect)(() => {
|
|
39467
39644
|
if (!schema.fields.some((field) => needsCurrentUserRuntime(field.defaultShortcut?.type)))
|
|
39468
39645
|
return;
|
|
39469
39646
|
if (mergedRuntime.currentUser && mergedRuntime.currentDepartment) return;
|
|
@@ -39487,7 +39664,7 @@ function FormProvider3({
|
|
|
39487
39664
|
cancelled = true;
|
|
39488
39665
|
};
|
|
39489
39666
|
}, [api, mergedRuntime.currentDepartment, mergedRuntime.currentUser, schema.fields]);
|
|
39490
|
-
(0,
|
|
39667
|
+
(0, import_react252.useEffect)(() => {
|
|
39491
39668
|
setFormData((prev) => {
|
|
39492
39669
|
let changed = false;
|
|
39493
39670
|
const next = { ...prev };
|
|
@@ -39501,7 +39678,7 @@ function FormProvider3({
|
|
|
39501
39678
|
return changed ? next : prev;
|
|
39502
39679
|
});
|
|
39503
39680
|
}, [mergedRuntime, schema.fields]);
|
|
39504
|
-
const fieldBehaviors = (0,
|
|
39681
|
+
const fieldBehaviors = (0, import_react252.useMemo)(() => {
|
|
39505
39682
|
const baseBehaviors = {};
|
|
39506
39683
|
for (const field of schema.fields) {
|
|
39507
39684
|
baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
|
|
@@ -39524,15 +39701,15 @@ function FormProvider3({
|
|
|
39524
39701
|
}
|
|
39525
39702
|
return computed;
|
|
39526
39703
|
}, [schema, effects, config3.permissions, config3.mode, formData]);
|
|
39527
|
-
const fieldOverrides = (0,
|
|
39704
|
+
const fieldOverrides = (0, import_react252.useMemo)(
|
|
39528
39705
|
() => evaluateFieldOverrides(effects, formData),
|
|
39529
39706
|
[effects, formData]
|
|
39530
39707
|
);
|
|
39531
|
-
const layoutBehaviors = (0,
|
|
39708
|
+
const layoutBehaviors = (0, import_react252.useMemo)(
|
|
39532
39709
|
() => evaluateLayoutBehaviors(effects, formData),
|
|
39533
39710
|
[effects, formData]
|
|
39534
39711
|
);
|
|
39535
|
-
(0,
|
|
39712
|
+
(0, import_react252.useEffect)(() => {
|
|
39536
39713
|
const valueActions = getValueActions(effects, formData);
|
|
39537
39714
|
if (valueActions.length === 0) return;
|
|
39538
39715
|
let changed = false;
|
|
@@ -39555,7 +39732,7 @@ function FormProvider3({
|
|
|
39555
39732
|
setFieldErrors(nextErrors);
|
|
39556
39733
|
}
|
|
39557
39734
|
}, [effects, formData, fieldErrors]);
|
|
39558
|
-
const setFieldValue = (0,
|
|
39735
|
+
const setFieldValue = (0, import_react252.useCallback)((fieldId, value) => {
|
|
39559
39736
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
39560
39737
|
setFieldErrors((prev) => {
|
|
39561
39738
|
if (prev[fieldId]) {
|
|
@@ -39566,9 +39743,9 @@ function FormProvider3({
|
|
|
39566
39743
|
return prev;
|
|
39567
39744
|
});
|
|
39568
39745
|
}, []);
|
|
39569
|
-
const getFieldValue = (0,
|
|
39570
|
-
const getFormData2 = (0,
|
|
39571
|
-
const validateFieldById = (0,
|
|
39746
|
+
const getFieldValue = (0, import_react252.useCallback)((fieldId) => formData[fieldId], [formData]);
|
|
39747
|
+
const getFormData2 = (0, import_react252.useCallback)(() => ({ ...formData }), [formData]);
|
|
39748
|
+
const validateFieldById = (0, import_react252.useCallback)(
|
|
39572
39749
|
async (fieldId) => {
|
|
39573
39750
|
const field = schema.fields.find((f) => f.fieldId === fieldId);
|
|
39574
39751
|
if (!field) {
|
|
@@ -39629,7 +39806,7 @@ function FormProvider3({
|
|
|
39629
39806
|
},
|
|
39630
39807
|
[schema, formData, fieldBehaviors, fieldOverrides]
|
|
39631
39808
|
);
|
|
39632
|
-
const validateAllWithErrors = (0,
|
|
39809
|
+
const validateAllWithErrors = (0, import_react252.useCallback)(async () => {
|
|
39633
39810
|
const fieldRules = {};
|
|
39634
39811
|
const validationData = { ...formData };
|
|
39635
39812
|
for (const field of schema.fields) {
|
|
@@ -39653,28 +39830,28 @@ function FormProvider3({
|
|
|
39653
39830
|
setFieldErrors(errors);
|
|
39654
39831
|
return errors;
|
|
39655
39832
|
}, [schema, formData, fieldBehaviors, fieldOverrides]);
|
|
39656
|
-
const validateAll = (0,
|
|
39833
|
+
const validateAll = (0, import_react252.useCallback)(async () => {
|
|
39657
39834
|
const errors = await validateAllWithErrors();
|
|
39658
39835
|
return Object.keys(errors).length === 0;
|
|
39659
39836
|
}, [validateAllWithErrors]);
|
|
39660
|
-
const resetForm = (0,
|
|
39837
|
+
const resetForm = (0, import_react252.useCallback)(() => {
|
|
39661
39838
|
setFormData({ ...initialValuesRef.current });
|
|
39662
39839
|
setFieldErrors({});
|
|
39663
39840
|
}, []);
|
|
39664
|
-
const registerField = (0,
|
|
39841
|
+
const registerField = (0, import_react252.useCallback)(
|
|
39665
39842
|
(fieldId) => {
|
|
39666
39843
|
registeredFields.add(fieldId);
|
|
39667
39844
|
},
|
|
39668
39845
|
[registeredFields]
|
|
39669
39846
|
);
|
|
39670
|
-
const unregisterField = (0,
|
|
39847
|
+
const unregisterField = (0, import_react252.useCallback)(
|
|
39671
39848
|
(fieldId) => {
|
|
39672
39849
|
registeredFields.delete(fieldId);
|
|
39673
39850
|
},
|
|
39674
39851
|
[registeredFields]
|
|
39675
39852
|
);
|
|
39676
|
-
const [dynamicOptions, setDynamicOptions] = (0,
|
|
39677
|
-
(0,
|
|
39853
|
+
const [dynamicOptions, setDynamicOptions] = (0, import_react252.useState)({});
|
|
39854
|
+
(0, import_react252.useEffect)(() => {
|
|
39678
39855
|
const loadDynamicOptions = async () => {
|
|
39679
39856
|
const updates = {};
|
|
39680
39857
|
for (const field of schema.fields) {
|
|
@@ -39692,7 +39869,7 @@ function FormProvider3({
|
|
|
39692
39869
|
};
|
|
39693
39870
|
loadDynamicOptions();
|
|
39694
39871
|
}, [schema.fields, mergedRuntime]);
|
|
39695
|
-
(0,
|
|
39872
|
+
(0, import_react252.useEffect)(() => {
|
|
39696
39873
|
let cancelled = false;
|
|
39697
39874
|
const loadDataLinkageOptions = async () => {
|
|
39698
39875
|
const updates = {};
|
|
@@ -39718,7 +39895,7 @@ function FormProvider3({
|
|
|
39718
39895
|
window.clearTimeout(timer);
|
|
39719
39896
|
};
|
|
39720
39897
|
}, [schema.fields, mergedRuntime, formData]);
|
|
39721
|
-
(0,
|
|
39898
|
+
(0, import_react252.useEffect)(() => {
|
|
39722
39899
|
let cancelled = false;
|
|
39723
39900
|
const loadDefaultValueLinkages = async () => {
|
|
39724
39901
|
const fields = schema.fields.filter((field) => field.defaultValueLinkage);
|
|
@@ -39752,7 +39929,7 @@ function FormProvider3({
|
|
|
39752
39929
|
window.clearTimeout(timer);
|
|
39753
39930
|
};
|
|
39754
39931
|
}, [schema.fields, mergedRuntime, formData]);
|
|
39755
|
-
const contextValue = (0,
|
|
39932
|
+
const contextValue = (0, import_react252.useMemo)(
|
|
39756
39933
|
() => ({
|
|
39757
39934
|
mode: config3.mode,
|
|
39758
39935
|
schema,
|
|
@@ -39763,6 +39940,7 @@ function FormProvider3({
|
|
|
39763
39940
|
layoutBehaviors,
|
|
39764
39941
|
dynamicOptions,
|
|
39765
39942
|
api,
|
|
39943
|
+
runtime: mergedRuntime,
|
|
39766
39944
|
config: {
|
|
39767
39945
|
mode: config3.mode,
|
|
39768
39946
|
formUuid: config3.formUuid,
|
|
@@ -39791,6 +39969,7 @@ function FormProvider3({
|
|
|
39791
39969
|
layoutBehaviors,
|
|
39792
39970
|
dynamicOptions,
|
|
39793
39971
|
api,
|
|
39972
|
+
mergedRuntime,
|
|
39794
39973
|
config3.appType,
|
|
39795
39974
|
config3.formInstanceId,
|
|
39796
39975
|
config3.submit,
|
|
@@ -39806,10 +39985,10 @@ function FormProvider3({
|
|
|
39806
39985
|
]
|
|
39807
39986
|
);
|
|
39808
39987
|
const registryComponents = components ?? defaultComponentRegistry;
|
|
39809
|
-
return
|
|
39988
|
+
return import_react252.default.createElement(
|
|
39810
39989
|
FormContext.Provider,
|
|
39811
39990
|
{ value: contextValue },
|
|
39812
|
-
|
|
39991
|
+
import_react252.default.createElement(ComponentRegistryProvider, { components: registryComponents, children })
|
|
39813
39992
|
);
|
|
39814
39993
|
}
|
|
39815
39994
|
function resolveDefaultValue(field, runtime) {
|
|
@@ -39921,7 +40100,7 @@ function coerceLinkedDefaultValue(field, value) {
|
|
|
39921
40100
|
|
|
39922
40101
|
// packages/sdk/src/components/core/FormRenderer.tsx
|
|
39923
40102
|
init_cjs_shims();
|
|
39924
|
-
var
|
|
40103
|
+
var import_react256 = __toESM(require("react"));
|
|
39925
40104
|
|
|
39926
40105
|
// packages/sdk/src/components/layout/index.ts
|
|
39927
40106
|
init_cjs_shims();
|
|
@@ -39929,7 +40108,7 @@ init_cjs_shims();
|
|
|
39929
40108
|
// packages/sdk/src/components/layout/FormSection/index.tsx
|
|
39930
40109
|
init_cjs_shims();
|
|
39931
40110
|
var import_icons6 = require("@ant-design/icons");
|
|
39932
|
-
var
|
|
40111
|
+
var import_react253 = require("react");
|
|
39933
40112
|
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
39934
40113
|
var sectionIconMap = {
|
|
39935
40114
|
user: import_icons6.UserOutlined,
|
|
@@ -39954,7 +40133,7 @@ function FormSection({
|
|
|
39954
40133
|
contentClassName,
|
|
39955
40134
|
children
|
|
39956
40135
|
}) {
|
|
39957
|
-
const [collapsed, setCollapsed] = (0,
|
|
40136
|
+
const [collapsed, setCollapsed] = (0, import_react253.useState)(defaultCollapsed);
|
|
39958
40137
|
const handleToggle = () => {
|
|
39959
40138
|
if (collapsible) {
|
|
39960
40139
|
setCollapsed((prev) => !prev);
|
|
@@ -40085,10 +40264,10 @@ function FormGrid({
|
|
|
40085
40264
|
|
|
40086
40265
|
// packages/sdk/src/components/layout/FormTabs/index.tsx
|
|
40087
40266
|
init_cjs_shims();
|
|
40088
|
-
var
|
|
40267
|
+
var import_react254 = require("react");
|
|
40089
40268
|
var import_jsx_runtime76 = require("react/jsx-runtime");
|
|
40090
40269
|
function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
40091
|
-
const [activeKey, setActiveKey] = (0,
|
|
40270
|
+
const [activeKey, setActiveKey] = (0, import_react254.useState)(defaultActiveKey || items[0]?.key || "");
|
|
40092
40271
|
const activeItem = items.find((item) => item.key === activeKey);
|
|
40093
40272
|
return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-tabs", children: [
|
|
40094
40273
|
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
@@ -40118,10 +40297,10 @@ function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
|
40118
40297
|
|
|
40119
40298
|
// packages/sdk/src/components/layout/FormSteps/index.tsx
|
|
40120
40299
|
init_cjs_shims();
|
|
40121
|
-
var
|
|
40300
|
+
var import_react255 = __toESM(require("react"));
|
|
40122
40301
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
40123
40302
|
function FormSteps({ items, className, onStepChange }) {
|
|
40124
|
-
const [currentStep, setCurrentStep] = (0,
|
|
40303
|
+
const [currentStep, setCurrentStep] = (0, import_react255.useState)(0);
|
|
40125
40304
|
const goTo = (step) => {
|
|
40126
40305
|
setCurrentStep(step);
|
|
40127
40306
|
onStepChange?.(step);
|
|
@@ -40137,7 +40316,7 @@ function FormSteps({ items, className, onStepChange }) {
|
|
|
40137
40316
|
}
|
|
40138
40317
|
};
|
|
40139
40318
|
return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-steps", children: [
|
|
40140
|
-
/* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "flex items-center mb-6", "data-testid": "form-steps-indicator", children: items.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
|
|
40319
|
+
/* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "flex items-center mb-6", "data-testid": "form-steps-indicator", children: items.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_react255.default.Fragment, { children: [
|
|
40141
40320
|
/* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "flex items-center", children: [
|
|
40142
40321
|
/* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
|
|
40143
40322
|
"div",
|
|
@@ -40238,7 +40417,7 @@ function FieldRenderer({
|
|
|
40238
40417
|
return null;
|
|
40239
40418
|
}
|
|
40240
40419
|
const { fieldId, componentName: _, ...fieldProps } = field;
|
|
40241
|
-
const element =
|
|
40420
|
+
const element = import_react256.default.createElement(Component5, {
|
|
40242
40421
|
...fieldProps,
|
|
40243
40422
|
fieldId,
|
|
40244
40423
|
className: fieldClassName ?? fieldProps.className
|
|
@@ -40402,7 +40581,7 @@ function FormRenderer({
|
|
|
40402
40581
|
const gridClass = columnsClassMap[columns];
|
|
40403
40582
|
const gapClass = sizeClassMap[size2];
|
|
40404
40583
|
const containerClassName = ["sy-form-renderer", "sy-grid", gridClass, gapClass, className].filter(Boolean).join(" ");
|
|
40405
|
-
const fieldMap =
|
|
40584
|
+
const fieldMap = import_react256.default.useMemo(() => {
|
|
40406
40585
|
return new Map(
|
|
40407
40586
|
schema.fields.map((field) => [
|
|
40408
40587
|
field.fieldId,
|
|
@@ -40474,7 +40653,7 @@ function isLayoutVisible(visibleWhen, formData) {
|
|
|
40474
40653
|
|
|
40475
40654
|
// packages/sdk/src/components/core/FormShell.tsx
|
|
40476
40655
|
init_cjs_shims();
|
|
40477
|
-
var
|
|
40656
|
+
var import_react257 = require("react");
|
|
40478
40657
|
var Antd2 = __toESM(require("antd"));
|
|
40479
40658
|
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
40480
40659
|
function normalizeMaxWidth(maxWidth) {
|
|
@@ -40504,10 +40683,10 @@ function FormShell({ children, appearance, className }) {
|
|
|
40504
40683
|
const [form] = useAntForm();
|
|
40505
40684
|
const { formData, setFieldValue } = useFormContext();
|
|
40506
40685
|
const maxWidth = normalizeMaxWidth(appearance?.maxWidth);
|
|
40507
|
-
(0,
|
|
40686
|
+
(0, import_react257.useEffect)(() => {
|
|
40508
40687
|
form?.setFieldsValue?.(formData);
|
|
40509
40688
|
}, [form, formData]);
|
|
40510
|
-
const style2 = (0,
|
|
40689
|
+
const style2 = (0, import_react257.useMemo)(() => {
|
|
40511
40690
|
if (!maxWidth) return void 0;
|
|
40512
40691
|
return {
|
|
40513
40692
|
maxWidth,
|
|
@@ -40544,7 +40723,7 @@ function FormShell({ children, appearance, className }) {
|
|
|
40544
40723
|
|
|
40545
40724
|
// packages/sdk/src/components/core/FormActions.tsx
|
|
40546
40725
|
init_cjs_shims();
|
|
40547
|
-
var
|
|
40726
|
+
var import_react258 = require("react");
|
|
40548
40727
|
var import_antd25 = require("antd");
|
|
40549
40728
|
|
|
40550
40729
|
// packages/sdk/src/components/core/validationFeedback.ts
|
|
@@ -40588,9 +40767,9 @@ function FormActions({
|
|
|
40588
40767
|
onSubmit
|
|
40589
40768
|
}) {
|
|
40590
40769
|
const { mode, validateAllWithErrors, getFormData: getFormData2, resetForm, api, config: config3 } = useFormContext();
|
|
40591
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
40592
|
-
const [submitError, setSubmitError] = (0,
|
|
40593
|
-
const handleSubmit = (0,
|
|
40770
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react258.useState)(false);
|
|
40771
|
+
const [submitError, setSubmitError] = (0, import_react258.useState)(null);
|
|
40772
|
+
const handleSubmit = (0, import_react258.useCallback)(async () => {
|
|
40594
40773
|
setSubmitError(null);
|
|
40595
40774
|
const valid = await validateAndNotify(validateAllWithErrors);
|
|
40596
40775
|
if (!valid) return;
|
|
@@ -40626,7 +40805,7 @@ function FormActions({
|
|
|
40626
40805
|
setIsSubmitting(false);
|
|
40627
40806
|
}
|
|
40628
40807
|
}, [api, config3, getFormData2, mode, onSubmit, validateAllWithErrors]);
|
|
40629
|
-
const handleReset = (0,
|
|
40808
|
+
const handleReset = (0, import_react258.useCallback)(() => {
|
|
40630
40809
|
resetForm();
|
|
40631
40810
|
}, [resetForm]);
|
|
40632
40811
|
if (mode === "readonly") return null;
|
|
@@ -41535,9 +41714,9 @@ init_cjs_shims();
|
|
|
41535
41714
|
|
|
41536
41715
|
// packages/sdk/src/components/hooks/useFormEngine.ts
|
|
41537
41716
|
init_cjs_shims();
|
|
41538
|
-
var
|
|
41717
|
+
var import_react259 = require("react");
|
|
41539
41718
|
function useFormEngine(schema, config3) {
|
|
41540
|
-
const initialValues = (0,
|
|
41719
|
+
const initialValues = (0, import_react259.useMemo)(() => {
|
|
41541
41720
|
const values = {};
|
|
41542
41721
|
for (const field of schema.fields) {
|
|
41543
41722
|
if (field.defaultValue !== void 0) {
|
|
@@ -41546,10 +41725,10 @@ function useFormEngine(schema, config3) {
|
|
|
41546
41725
|
}
|
|
41547
41726
|
return values;
|
|
41548
41727
|
}, [schema]);
|
|
41549
|
-
const initialValuesRef = (0,
|
|
41550
|
-
const [formData, setFormData] = (0,
|
|
41551
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
41552
|
-
const fieldBehaviors = (0,
|
|
41728
|
+
const initialValuesRef = (0, import_react259.useRef)(initialValues);
|
|
41729
|
+
const [formData, setFormData] = (0, import_react259.useState)({ ...initialValues });
|
|
41730
|
+
const [fieldErrors, setFieldErrors] = (0, import_react259.useState)({});
|
|
41731
|
+
const fieldBehaviors = (0, import_react259.useMemo)(() => {
|
|
41553
41732
|
const baseBehaviors = {};
|
|
41554
41733
|
for (const field of schema.fields) {
|
|
41555
41734
|
baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
|
|
@@ -41572,7 +41751,7 @@ function useFormEngine(schema, config3) {
|
|
|
41572
41751
|
}
|
|
41573
41752
|
return computed;
|
|
41574
41753
|
}, [schema, config3.effects, config3.permissions, config3.mode, formData]);
|
|
41575
|
-
const setFieldValue = (0,
|
|
41754
|
+
const setFieldValue = (0, import_react259.useCallback)((fieldId, value) => {
|
|
41576
41755
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
41577
41756
|
setFieldErrors((prev) => {
|
|
41578
41757
|
if (prev[fieldId]) {
|
|
@@ -41583,9 +41762,9 @@ function useFormEngine(schema, config3) {
|
|
|
41583
41762
|
return prev;
|
|
41584
41763
|
});
|
|
41585
41764
|
}, []);
|
|
41586
|
-
const getFieldValue = (0,
|
|
41587
|
-
const getFormData2 = (0,
|
|
41588
|
-
const validateAll = (0,
|
|
41765
|
+
const getFieldValue = (0, import_react259.useCallback)((fieldId) => formData[fieldId], [formData]);
|
|
41766
|
+
const getFormData2 = (0, import_react259.useCallback)(() => ({ ...formData }), [formData]);
|
|
41767
|
+
const validateAll = (0, import_react259.useCallback)(async () => {
|
|
41589
41768
|
const fieldRules = {};
|
|
41590
41769
|
for (const field of schema.fields) {
|
|
41591
41770
|
const rules2 = [];
|
|
@@ -41603,7 +41782,7 @@ function useFormEngine(schema, config3) {
|
|
|
41603
41782
|
setFieldErrors(errors);
|
|
41604
41783
|
return Object.keys(errors).length === 0;
|
|
41605
41784
|
}, [schema, formData]);
|
|
41606
|
-
const resetForm = (0,
|
|
41785
|
+
const resetForm = (0, import_react259.useCallback)(() => {
|
|
41607
41786
|
setFormData({ ...initialValuesRef.current });
|
|
41608
41787
|
setFieldErrors({});
|
|
41609
41788
|
}, []);
|
|
@@ -41622,12 +41801,12 @@ function useFormEngine(schema, config3) {
|
|
|
41622
41801
|
|
|
41623
41802
|
// packages/sdk/src/components/hooks/useFormData.ts
|
|
41624
41803
|
init_cjs_shims();
|
|
41625
|
-
var
|
|
41804
|
+
var import_react260 = require("react");
|
|
41626
41805
|
function useFormData(initialValues = {}) {
|
|
41627
|
-
const [formData, setFormData] = (0,
|
|
41628
|
-
const [dirtyFields, setDirtyFields] = (0,
|
|
41629
|
-
const initialValuesRef = (0,
|
|
41630
|
-
const setFieldValue = (0,
|
|
41806
|
+
const [formData, setFormData] = (0, import_react260.useState)({ ...initialValues });
|
|
41807
|
+
const [dirtyFields, setDirtyFields] = (0, import_react260.useState)(/* @__PURE__ */ new Set());
|
|
41808
|
+
const initialValuesRef = (0, import_react260.useRef)(initialValues);
|
|
41809
|
+
const setFieldValue = (0, import_react260.useCallback)((fieldId, value) => {
|
|
41631
41810
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
41632
41811
|
setDirtyFields((prev) => {
|
|
41633
41812
|
const next = new Set(prev);
|
|
@@ -41635,16 +41814,16 @@ function useFormData(initialValues = {}) {
|
|
|
41635
41814
|
return next;
|
|
41636
41815
|
});
|
|
41637
41816
|
}, []);
|
|
41638
|
-
const getFieldValue = (0,
|
|
41817
|
+
const getFieldValue = (0, import_react260.useCallback)(
|
|
41639
41818
|
(fieldId) => {
|
|
41640
41819
|
return formData[fieldId];
|
|
41641
41820
|
},
|
|
41642
41821
|
[formData]
|
|
41643
41822
|
);
|
|
41644
|
-
const getFormData2 = (0,
|
|
41823
|
+
const getFormData2 = (0, import_react260.useCallback)(() => {
|
|
41645
41824
|
return { ...formData };
|
|
41646
41825
|
}, [formData]);
|
|
41647
|
-
const resetForm = (0,
|
|
41826
|
+
const resetForm = (0, import_react260.useCallback)(() => {
|
|
41648
41827
|
setFormData({ ...initialValuesRef.current });
|
|
41649
41828
|
setDirtyFields(/* @__PURE__ */ new Set());
|
|
41650
41829
|
}, []);
|
|
@@ -41660,7 +41839,7 @@ function useFormData(initialValues = {}) {
|
|
|
41660
41839
|
|
|
41661
41840
|
// packages/sdk/src/components/hooks/useFieldBehavior.ts
|
|
41662
41841
|
init_cjs_shims();
|
|
41663
|
-
var
|
|
41842
|
+
var import_react261 = require("react");
|
|
41664
41843
|
function useFieldBehavior({
|
|
41665
41844
|
fieldId,
|
|
41666
41845
|
permissions,
|
|
@@ -41668,7 +41847,7 @@ function useFieldBehavior({
|
|
|
41668
41847
|
formData,
|
|
41669
41848
|
defaultBehavior = "NORMAL"
|
|
41670
41849
|
}) {
|
|
41671
|
-
return (0,
|
|
41850
|
+
return (0, import_react261.useMemo)(() => {
|
|
41672
41851
|
if (permissions && permissions[fieldId]) {
|
|
41673
41852
|
return permissions[fieldId];
|
|
41674
41853
|
}
|
|
@@ -41683,11 +41862,11 @@ function useFieldBehavior({
|
|
|
41683
41862
|
|
|
41684
41863
|
// packages/sdk/src/components/hooks/useFormSubmit.ts
|
|
41685
41864
|
init_cjs_shims();
|
|
41686
|
-
var
|
|
41865
|
+
var import_react262 = require("react");
|
|
41687
41866
|
function useFormSubmit(config3) {
|
|
41688
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
41689
|
-
const [submitError, setSubmitError] = (0,
|
|
41690
|
-
const submit = (0,
|
|
41867
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react262.useState)(false);
|
|
41868
|
+
const [submitError, setSubmitError] = (0, import_react262.useState)(null);
|
|
41869
|
+
const submit = (0, import_react262.useCallback)(
|
|
41691
41870
|
async (formData, validateFn) => {
|
|
41692
41871
|
setSubmitError(null);
|
|
41693
41872
|
const isValid = await validateFn();
|
|
@@ -41720,7 +41899,7 @@ function useFormSubmit(config3) {
|
|
|
41720
41899
|
|
|
41721
41900
|
// packages/sdk/src/components/hooks/useFieldPermission.ts
|
|
41722
41901
|
init_cjs_shims();
|
|
41723
|
-
var
|
|
41902
|
+
var import_react263 = require("react");
|
|
41724
41903
|
|
|
41725
41904
|
// packages/sdk/src/components/utils/permissions.ts
|
|
41726
41905
|
init_cjs_shims();
|
|
@@ -41794,7 +41973,7 @@ var normalizeFlowConfig = (config3) => {
|
|
|
41794
41973
|
};
|
|
41795
41974
|
function useFieldPermission(options) {
|
|
41796
41975
|
const { viewPermissions, processDefinition, currentTask, isApprover, mode } = options;
|
|
41797
|
-
const computeBehaviors = (0,
|
|
41976
|
+
const computeBehaviors = (0, import_react263.useCallback)(() => {
|
|
41798
41977
|
const behaviors = {};
|
|
41799
41978
|
if (!currentTask && viewPermissions) {
|
|
41800
41979
|
return normalizeFieldBehaviors(viewPermissions, mode);
|
|
@@ -41839,13 +42018,13 @@ function useFieldPermission(options) {
|
|
|
41839
42018
|
}
|
|
41840
42019
|
return behaviors;
|
|
41841
42020
|
}, [viewPermissions, processDefinition, currentTask, isApprover, mode]);
|
|
41842
|
-
const fieldBehaviors = (0,
|
|
42021
|
+
const fieldBehaviors = (0, import_react263.useMemo)(() => computeBehaviors(), [computeBehaviors]);
|
|
41843
42022
|
return { fieldBehaviors, computeBehaviors };
|
|
41844
42023
|
}
|
|
41845
42024
|
|
|
41846
42025
|
// packages/sdk/src/components/hooks/useFormDetail.ts
|
|
41847
42026
|
init_cjs_shims();
|
|
41848
|
-
var
|
|
42027
|
+
var import_react264 = require("react");
|
|
41849
42028
|
|
|
41850
42029
|
// packages/sdk/src/components/utils/formInstanceData.ts
|
|
41851
42030
|
init_cjs_shims();
|
|
@@ -42005,24 +42184,24 @@ function useFormDetail(options) {
|
|
|
42005
42184
|
const { formUuid, appType, formInstanceId, fieldIds, onPermissionDenied } = options;
|
|
42006
42185
|
const { api } = useFormContext();
|
|
42007
42186
|
const request = api.request;
|
|
42008
|
-
const [loading, setLoading] = (0,
|
|
42009
|
-
const [mode, setMode] = (0,
|
|
42010
|
-
const [formData, setFormData] = (0,
|
|
42011
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
42012
|
-
const [permissions, setPermissions] = (0,
|
|
42013
|
-
const mountedRef = (0,
|
|
42014
|
-
const onPermissionDeniedRef = (0,
|
|
42187
|
+
const [loading, setLoading] = (0, import_react264.useState)(true);
|
|
42188
|
+
const [mode, setMode] = (0, import_react264.useState)("readonly");
|
|
42189
|
+
const [formData, setFormData] = (0, import_react264.useState)(null);
|
|
42190
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react264.useState)(null);
|
|
42191
|
+
const [permissions, setPermissions] = (0, import_react264.useState)(null);
|
|
42192
|
+
const mountedRef = (0, import_react264.useRef)(true);
|
|
42193
|
+
const onPermissionDeniedRef = (0, import_react264.useRef)(onPermissionDenied);
|
|
42015
42194
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
42016
|
-
(0,
|
|
42195
|
+
(0, import_react264.useEffect)(() => {
|
|
42017
42196
|
mountedRef.current = true;
|
|
42018
42197
|
return () => {
|
|
42019
42198
|
mountedRef.current = false;
|
|
42020
42199
|
};
|
|
42021
42200
|
}, []);
|
|
42022
|
-
(0,
|
|
42201
|
+
(0, import_react264.useEffect)(() => {
|
|
42023
42202
|
onPermissionDeniedRef.current = onPermissionDenied;
|
|
42024
42203
|
}, [onPermissionDenied]);
|
|
42025
|
-
const loadData = (0,
|
|
42204
|
+
const loadData = (0, import_react264.useCallback)(async () => {
|
|
42026
42205
|
if (!mountedRef.current) return;
|
|
42027
42206
|
setLoading(true);
|
|
42028
42207
|
try {
|
|
@@ -42057,21 +42236,21 @@ function useFormDetail(options) {
|
|
|
42057
42236
|
}
|
|
42058
42237
|
}
|
|
42059
42238
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
42060
|
-
(0,
|
|
42239
|
+
(0, import_react264.useEffect)(() => {
|
|
42061
42240
|
loadData();
|
|
42062
42241
|
}, [loadData]);
|
|
42063
42242
|
const fieldBehaviors = normalizeFieldBehaviors(permissions, mode);
|
|
42064
42243
|
const canEdit = hasViewOperation(permissions?.operations, "edit");
|
|
42065
42244
|
const canDelete = hasViewOperation(permissions?.operations, "delete");
|
|
42066
42245
|
const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
|
|
42067
|
-
const switchToEdit = (0,
|
|
42246
|
+
const switchToEdit = (0, import_react264.useCallback)(() => {
|
|
42068
42247
|
setMode("edit");
|
|
42069
42248
|
loadData();
|
|
42070
42249
|
}, [loadData]);
|
|
42071
|
-
const switchToReadonly = (0,
|
|
42250
|
+
const switchToReadonly = (0, import_react264.useCallback)(() => {
|
|
42072
42251
|
setMode("readonly");
|
|
42073
42252
|
}, []);
|
|
42074
|
-
const saveChanges = (0,
|
|
42253
|
+
const saveChanges = (0, import_react264.useCallback)(
|
|
42075
42254
|
async (values) => {
|
|
42076
42255
|
try {
|
|
42077
42256
|
await api.updateFormData({
|
|
@@ -42092,7 +42271,7 @@ function useFormDetail(options) {
|
|
|
42092
42271
|
},
|
|
42093
42272
|
[api, formInstanceId, formUuid, appType]
|
|
42094
42273
|
);
|
|
42095
|
-
const deleteInstance = (0,
|
|
42274
|
+
const deleteInstance = (0, import_react264.useCallback)(async () => {
|
|
42096
42275
|
try {
|
|
42097
42276
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
42098
42277
|
return true;
|
|
@@ -42120,7 +42299,7 @@ function useFormDetail(options) {
|
|
|
42120
42299
|
|
|
42121
42300
|
// packages/sdk/src/components/hooks/useProcessDetail.ts
|
|
42122
42301
|
init_cjs_shims();
|
|
42123
|
-
var
|
|
42302
|
+
var import_react265 = require("react");
|
|
42124
42303
|
var DEFAULT_APPROVAL_ACTIONS = [
|
|
42125
42304
|
{ action: "agree", name: { zh_CN: "\u540C\u610F" } },
|
|
42126
42305
|
{ action: "rejected", name: { zh_CN: "\u62D2\u7EDD" } }
|
|
@@ -42148,29 +42327,29 @@ function useProcessDetail(options) {
|
|
|
42148
42327
|
const { formUuid, appType, formInstanceId, fieldIds } = options;
|
|
42149
42328
|
const { api } = useFormContext();
|
|
42150
42329
|
const request = api.request;
|
|
42151
|
-
const [loading, setLoading] = (0,
|
|
42152
|
-
const [mode, setMode] = (0,
|
|
42153
|
-
const [processInfo, setProcessInfo] = (0,
|
|
42154
|
-
const [progressList, setProgressList] = (0,
|
|
42155
|
-
const [formData, setFormData] = (0,
|
|
42156
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
42157
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
42158
|
-
const [loadError, setLoadError] = (0,
|
|
42159
|
-
const [isApprover, setIsApprover] = (0,
|
|
42160
|
-
const [canWithdraw, setCanWithdraw] = (0,
|
|
42161
|
-
const [approvalTasks, setApprovalTasks] = (0,
|
|
42162
|
-
const [permissions, setPermissions] = (0,
|
|
42163
|
-
const [processDefinition, setProcessDefinition] = (0,
|
|
42164
|
-
const [dataVersion, setDataVersion] = (0,
|
|
42165
|
-
const mountedRef = (0,
|
|
42330
|
+
const [loading, setLoading] = (0, import_react265.useState)(true);
|
|
42331
|
+
const [mode, setMode] = (0, import_react265.useState)("readonly");
|
|
42332
|
+
const [processInfo, setProcessInfo] = (0, import_react265.useState)(null);
|
|
42333
|
+
const [progressList, setProgressList] = (0, import_react265.useState)([]);
|
|
42334
|
+
const [formData, setFormData] = (0, import_react265.useState)(null);
|
|
42335
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react265.useState)(null);
|
|
42336
|
+
const [accessDenied, setAccessDenied] = (0, import_react265.useState)(false);
|
|
42337
|
+
const [loadError, setLoadError] = (0, import_react265.useState)(null);
|
|
42338
|
+
const [isApprover, setIsApprover] = (0, import_react265.useState)(false);
|
|
42339
|
+
const [canWithdraw, setCanWithdraw] = (0, import_react265.useState)(false);
|
|
42340
|
+
const [approvalTasks, setApprovalTasks] = (0, import_react265.useState)([]);
|
|
42341
|
+
const [permissions, setPermissions] = (0, import_react265.useState)(null);
|
|
42342
|
+
const [processDefinition, setProcessDefinition] = (0, import_react265.useState)(null);
|
|
42343
|
+
const [dataVersion, setDataVersion] = (0, import_react265.useState)(0);
|
|
42344
|
+
const mountedRef = (0, import_react265.useRef)(true);
|
|
42166
42345
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
42167
|
-
(0,
|
|
42346
|
+
(0, import_react265.useEffect)(() => {
|
|
42168
42347
|
mountedRef.current = true;
|
|
42169
42348
|
return () => {
|
|
42170
42349
|
mountedRef.current = false;
|
|
42171
42350
|
};
|
|
42172
42351
|
}, []);
|
|
42173
|
-
const currentTask = (0,
|
|
42352
|
+
const currentTask = (0, import_react265.useMemo)(
|
|
42174
42353
|
() => mergeCurrentTask(processInfo?.currentTask, approvalTasks[0]),
|
|
42175
42354
|
[processInfo?.currentTask, approvalTasks]
|
|
42176
42355
|
);
|
|
@@ -42190,7 +42369,7 @@ function useProcessDetail(options) {
|
|
|
42190
42369
|
isApprover: isProcessFinal ? false : isApprover,
|
|
42191
42370
|
mode
|
|
42192
42371
|
});
|
|
42193
|
-
const activeActions = (0,
|
|
42372
|
+
const activeActions = (0, import_react265.useMemo)(() => {
|
|
42194
42373
|
if (!isApprover || isProcessFinal) return [];
|
|
42195
42374
|
const actions = currentTask?.actions && currentTask.actions.length > 0 ? [...currentTask.actions] : [...DEFAULT_APPROVAL_ACTIONS];
|
|
42196
42375
|
if (canWithdraw && !actions.some((action) => action.action === "withdraw")) {
|
|
@@ -42198,7 +42377,7 @@ function useProcessDetail(options) {
|
|
|
42198
42377
|
}
|
|
42199
42378
|
return actions;
|
|
42200
42379
|
}, [isApprover, isProcessFinal, currentTask?.actions, canWithdraw]);
|
|
42201
|
-
const loadData = (0,
|
|
42380
|
+
const loadData = (0, import_react265.useCallback)(async () => {
|
|
42202
42381
|
if (!mountedRef.current) return;
|
|
42203
42382
|
setLoading(true);
|
|
42204
42383
|
setAccessDenied(false);
|
|
@@ -42280,24 +42459,24 @@ function useProcessDetail(options) {
|
|
|
42280
42459
|
}
|
|
42281
42460
|
}
|
|
42282
42461
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
42283
|
-
(0,
|
|
42462
|
+
(0, import_react265.useEffect)(() => {
|
|
42284
42463
|
loadData();
|
|
42285
42464
|
}, [loadData]);
|
|
42286
|
-
const switchToEdit = (0,
|
|
42465
|
+
const switchToEdit = (0, import_react265.useCallback)(() => {
|
|
42287
42466
|
setMode("edit");
|
|
42288
42467
|
void loadData();
|
|
42289
42468
|
}, [loadData]);
|
|
42290
|
-
const switchToReadonly = (0,
|
|
42469
|
+
const switchToReadonly = (0, import_react265.useCallback)(() => {
|
|
42291
42470
|
setMode("readonly");
|
|
42292
42471
|
}, []);
|
|
42293
|
-
const refreshDetail = (0,
|
|
42472
|
+
const refreshDetail = (0, import_react265.useCallback)(async () => {
|
|
42294
42473
|
setMode("readonly");
|
|
42295
42474
|
await loadData();
|
|
42296
42475
|
}, [loadData]);
|
|
42297
|
-
const refreshProgress = (0,
|
|
42476
|
+
const refreshProgress = (0, import_react265.useCallback)(async () => {
|
|
42298
42477
|
await refreshDetail();
|
|
42299
42478
|
}, [refreshDetail]);
|
|
42300
|
-
const saveChanges = (0,
|
|
42479
|
+
const saveChanges = (0, import_react265.useCallback)(
|
|
42301
42480
|
async (values) => {
|
|
42302
42481
|
try {
|
|
42303
42482
|
await api.updateFormData({
|
|
@@ -42316,7 +42495,7 @@ function useProcessDetail(options) {
|
|
|
42316
42495
|
},
|
|
42317
42496
|
[api, formInstanceId, formUuid, appType, loadData]
|
|
42318
42497
|
);
|
|
42319
|
-
const deleteInstance = (0,
|
|
42498
|
+
const deleteInstance = (0, import_react265.useCallback)(async () => {
|
|
42320
42499
|
try {
|
|
42321
42500
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
42322
42501
|
return true;
|
|
@@ -42358,29 +42537,29 @@ function useProcessDetail(options) {
|
|
|
42358
42537
|
|
|
42359
42538
|
// packages/sdk/src/components/hooks/useApprovalActions.ts
|
|
42360
42539
|
init_cjs_shims();
|
|
42361
|
-
var
|
|
42540
|
+
var import_react266 = require("react");
|
|
42362
42541
|
function useApprovalActions(options) {
|
|
42363
42542
|
const { formInstanceId, formUuid, appType, currentTaskId, onActionComplete, getFormValues } = options;
|
|
42364
42543
|
const { api } = useFormContext();
|
|
42365
42544
|
const request = api.request;
|
|
42366
|
-
const [isLoading, setIsLoading] = (0,
|
|
42367
|
-
const [currentAction, setCurrentAction] = (0,
|
|
42368
|
-
const [returnableNodes, setReturnableNodes] = (0,
|
|
42369
|
-
const [returnPolicy, setReturnPolicy] = (0,
|
|
42370
|
-
const mountedRef = (0,
|
|
42371
|
-
(0,
|
|
42545
|
+
const [isLoading, setIsLoading] = (0, import_react266.useState)(false);
|
|
42546
|
+
const [currentAction, setCurrentAction] = (0, import_react266.useState)(null);
|
|
42547
|
+
const [returnableNodes, setReturnableNodes] = (0, import_react266.useState)([]);
|
|
42548
|
+
const [returnPolicy, setReturnPolicy] = (0, import_react266.useState)(null);
|
|
42549
|
+
const mountedRef = (0, import_react266.useRef)(true);
|
|
42550
|
+
(0, import_react266.useEffect)(() => {
|
|
42372
42551
|
mountedRef.current = true;
|
|
42373
42552
|
return () => {
|
|
42374
42553
|
mountedRef.current = false;
|
|
42375
42554
|
};
|
|
42376
42555
|
}, []);
|
|
42377
|
-
const resetLoading = (0,
|
|
42556
|
+
const resetLoading = (0, import_react266.useCallback)(() => {
|
|
42378
42557
|
if (mountedRef.current) {
|
|
42379
42558
|
setIsLoading(false);
|
|
42380
42559
|
setCurrentAction(null);
|
|
42381
42560
|
}
|
|
42382
42561
|
}, []);
|
|
42383
|
-
const approve = (0,
|
|
42562
|
+
const approve = (0, import_react266.useCallback)(
|
|
42384
42563
|
async (comments) => {
|
|
42385
42564
|
setIsLoading(true);
|
|
42386
42565
|
setCurrentAction("approve");
|
|
@@ -42405,7 +42584,7 @@ function useApprovalActions(options) {
|
|
|
42405
42584
|
},
|
|
42406
42585
|
[request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
|
|
42407
42586
|
);
|
|
42408
|
-
const reject = (0,
|
|
42587
|
+
const reject = (0, import_react266.useCallback)(
|
|
42409
42588
|
async (comments) => {
|
|
42410
42589
|
setIsLoading(true);
|
|
42411
42590
|
setCurrentAction("reject");
|
|
@@ -42426,7 +42605,7 @@ function useApprovalActions(options) {
|
|
|
42426
42605
|
},
|
|
42427
42606
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
42428
42607
|
);
|
|
42429
|
-
const transfer = (0,
|
|
42608
|
+
const transfer = (0, import_react266.useCallback)(
|
|
42430
42609
|
async (userId, reason) => {
|
|
42431
42610
|
if (!currentTaskId) {
|
|
42432
42611
|
console.error("[useApprovalActions] transfer failed: no currentTaskId");
|
|
@@ -42451,7 +42630,7 @@ function useApprovalActions(options) {
|
|
|
42451
42630
|
},
|
|
42452
42631
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
42453
42632
|
);
|
|
42454
|
-
const returnTo = (0,
|
|
42633
|
+
const returnTo = (0, import_react266.useCallback)(
|
|
42455
42634
|
async (nodeId, reason) => {
|
|
42456
42635
|
if (!currentTaskId) {
|
|
42457
42636
|
console.error("[useApprovalActions] returnTo failed: no currentTaskId");
|
|
@@ -42476,7 +42655,7 @@ function useApprovalActions(options) {
|
|
|
42476
42655
|
},
|
|
42477
42656
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
42478
42657
|
);
|
|
42479
|
-
const withdraw = (0,
|
|
42658
|
+
const withdraw = (0, import_react266.useCallback)(
|
|
42480
42659
|
async (reason) => {
|
|
42481
42660
|
setIsLoading(true);
|
|
42482
42661
|
setCurrentAction("withdraw");
|
|
@@ -42496,7 +42675,7 @@ function useApprovalActions(options) {
|
|
|
42496
42675
|
},
|
|
42497
42676
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
42498
42677
|
);
|
|
42499
|
-
const save = (0,
|
|
42678
|
+
const save = (0, import_react266.useCallback)(async () => {
|
|
42500
42679
|
setIsLoading(true);
|
|
42501
42680
|
setCurrentAction("save");
|
|
42502
42681
|
try {
|
|
@@ -42516,7 +42695,7 @@ function useApprovalActions(options) {
|
|
|
42516
42695
|
return false;
|
|
42517
42696
|
}
|
|
42518
42697
|
}, [request, formInstanceId, formUuid, appType, getFormValues, onActionComplete, resetLoading]);
|
|
42519
|
-
const resubmit = (0,
|
|
42698
|
+
const resubmit = (0, import_react266.useCallback)(
|
|
42520
42699
|
async (comments, selectedApprovers) => {
|
|
42521
42700
|
if (!currentTaskId) {
|
|
42522
42701
|
console.error("[useApprovalActions] resubmit failed: no currentTaskId");
|
|
@@ -42546,7 +42725,7 @@ function useApprovalActions(options) {
|
|
|
42546
42725
|
},
|
|
42547
42726
|
[request, currentTaskId, formUuid, appType, getFormValues, onActionComplete, resetLoading]
|
|
42548
42727
|
);
|
|
42549
|
-
const callbackTask = (0,
|
|
42728
|
+
const callbackTask = (0, import_react266.useCallback)(
|
|
42550
42729
|
async (payload) => {
|
|
42551
42730
|
if (!currentTaskId) {
|
|
42552
42731
|
console.error("[useApprovalActions] callbackTask failed: no currentTaskId");
|
|
@@ -42570,7 +42749,7 @@ function useApprovalActions(options) {
|
|
|
42570
42749
|
},
|
|
42571
42750
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
42572
42751
|
);
|
|
42573
|
-
const loadReturnableNodes = (0,
|
|
42752
|
+
const loadReturnableNodes = (0, import_react266.useCallback)(async () => {
|
|
42574
42753
|
if (!currentTaskId) return [];
|
|
42575
42754
|
try {
|
|
42576
42755
|
const result = await getReturnableNodeResult(request, currentTaskId);
|
|
@@ -42607,7 +42786,7 @@ function useApprovalActions(options) {
|
|
|
42607
42786
|
|
|
42608
42787
|
// packages/sdk/src/components/hooks/useChangeRecords.ts
|
|
42609
42788
|
init_cjs_shims();
|
|
42610
|
-
var
|
|
42789
|
+
var import_react267 = require("react");
|
|
42611
42790
|
var normalizeChangeRecordList = (value) => {
|
|
42612
42791
|
const body = value && typeof value === "object" && !Array.isArray(value) ? Array.isArray(value.data) || Array.isArray(value.records) || Array.isArray(value.list) || Array.isArray(value.items) ? value : value.data ?? value.result ?? value : value;
|
|
42613
42792
|
const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
|
|
@@ -42622,18 +42801,18 @@ function useChangeRecords(options) {
|
|
|
42622
42801
|
const { formUuid, appType, formInstanceId, pageSize = 20, autoLoad = true } = options;
|
|
42623
42802
|
const { api } = useFormContext();
|
|
42624
42803
|
const request = api.request;
|
|
42625
|
-
const [records, setRecords] = (0,
|
|
42626
|
-
const [loading, setLoading] = (0,
|
|
42627
|
-
const [total, setTotal] = (0,
|
|
42628
|
-
const [page, setPage] = (0,
|
|
42629
|
-
const mountedRef = (0,
|
|
42630
|
-
(0,
|
|
42804
|
+
const [records, setRecords] = (0, import_react267.useState)([]);
|
|
42805
|
+
const [loading, setLoading] = (0, import_react267.useState)(false);
|
|
42806
|
+
const [total, setTotal] = (0, import_react267.useState)(0);
|
|
42807
|
+
const [page, setPage] = (0, import_react267.useState)(1);
|
|
42808
|
+
const mountedRef = (0, import_react267.useRef)(true);
|
|
42809
|
+
(0, import_react267.useEffect)(() => {
|
|
42631
42810
|
mountedRef.current = true;
|
|
42632
42811
|
return () => {
|
|
42633
42812
|
mountedRef.current = false;
|
|
42634
42813
|
};
|
|
42635
42814
|
}, []);
|
|
42636
|
-
const fetchRecords = (0,
|
|
42815
|
+
const fetchRecords = (0, import_react267.useCallback)(
|
|
42637
42816
|
async (pageNum, append) => {
|
|
42638
42817
|
if (!mountedRef.current) return;
|
|
42639
42818
|
setLoading(true);
|
|
@@ -42664,18 +42843,18 @@ function useChangeRecords(options) {
|
|
|
42664
42843
|
},
|
|
42665
42844
|
[request, formUuid, appType, formInstanceId, pageSize]
|
|
42666
42845
|
);
|
|
42667
|
-
(0,
|
|
42846
|
+
(0, import_react267.useEffect)(() => {
|
|
42668
42847
|
if (autoLoad) {
|
|
42669
42848
|
fetchRecords(1, false);
|
|
42670
42849
|
}
|
|
42671
42850
|
}, [autoLoad, fetchRecords]);
|
|
42672
42851
|
const safeRecords = Array.isArray(records) ? records : [];
|
|
42673
42852
|
const hasMore = safeRecords.length < total;
|
|
42674
|
-
const loadMore = (0,
|
|
42853
|
+
const loadMore = (0, import_react267.useCallback)(async () => {
|
|
42675
42854
|
if (!hasMore || loading) return;
|
|
42676
42855
|
await fetchRecords(page + 1, true);
|
|
42677
42856
|
}, [hasMore, loading, page, fetchRecords]);
|
|
42678
|
-
const refresh = (0,
|
|
42857
|
+
const refresh = (0, import_react267.useCallback)(async () => {
|
|
42679
42858
|
setRecords([]);
|
|
42680
42859
|
setPage(1);
|
|
42681
42860
|
setTotal(0);
|
|
@@ -42694,7 +42873,7 @@ function useChangeRecords(options) {
|
|
|
42694
42873
|
|
|
42695
42874
|
// packages/sdk/src/components/hooks/useFormNavigation.ts
|
|
42696
42875
|
init_cjs_shims();
|
|
42697
|
-
var
|
|
42876
|
+
var import_react268 = require("react");
|
|
42698
42877
|
var normalizeBasePath = (basePath) => {
|
|
42699
42878
|
const normalized = String(basePath || "").replace(/^\/+|\/+$/g, "");
|
|
42700
42879
|
return normalized ? `/${normalized}` : "";
|
|
@@ -42721,12 +42900,12 @@ function useFormNavigation(options) {
|
|
|
42721
42900
|
basePath,
|
|
42722
42901
|
onStay
|
|
42723
42902
|
} = options;
|
|
42724
|
-
const [isRedirecting, setIsRedirecting] = (0,
|
|
42725
|
-
const [countdown, setCountdown] = (0,
|
|
42726
|
-
const timerRef = (0,
|
|
42727
|
-
const redirectTargetRef = (0,
|
|
42728
|
-
const mountedRef = (0,
|
|
42729
|
-
(0,
|
|
42903
|
+
const [isRedirecting, setIsRedirecting] = (0, import_react268.useState)(false);
|
|
42904
|
+
const [countdown, setCountdown] = (0, import_react268.useState)(0);
|
|
42905
|
+
const timerRef = (0, import_react268.useRef)(null);
|
|
42906
|
+
const redirectTargetRef = (0, import_react268.useRef)(null);
|
|
42907
|
+
const mountedRef = (0, import_react268.useRef)(true);
|
|
42908
|
+
(0, import_react268.useEffect)(() => {
|
|
42730
42909
|
mountedRef.current = true;
|
|
42731
42910
|
return () => {
|
|
42732
42911
|
mountedRef.current = false;
|
|
@@ -42736,13 +42915,13 @@ function useFormNavigation(options) {
|
|
|
42736
42915
|
}
|
|
42737
42916
|
};
|
|
42738
42917
|
}, []);
|
|
42739
|
-
const navigateToDetail = (0,
|
|
42918
|
+
const navigateToDetail = (0, import_react268.useCallback)(
|
|
42740
42919
|
(formInstId) => {
|
|
42741
42920
|
window.location.href = buildDetailUrl(appType, formUuid, formInstId, "formDetail", basePath);
|
|
42742
42921
|
},
|
|
42743
42922
|
[appType, basePath, formUuid]
|
|
42744
42923
|
);
|
|
42745
|
-
const navigateToProcessDetail = (0,
|
|
42924
|
+
const navigateToProcessDetail = (0, import_react268.useCallback)(
|
|
42746
42925
|
(formInstId) => {
|
|
42747
42926
|
window.location.href = buildDetailUrl(
|
|
42748
42927
|
appType,
|
|
@@ -42754,7 +42933,7 @@ function useFormNavigation(options) {
|
|
|
42754
42933
|
},
|
|
42755
42934
|
[appType, basePath, formUuid]
|
|
42756
42935
|
);
|
|
42757
|
-
const startRedirectCountdown = (0,
|
|
42936
|
+
const startRedirectCountdown = (0, import_react268.useCallback)(
|
|
42758
42937
|
(targetUrl) => {
|
|
42759
42938
|
const totalSeconds = Math.ceil(redirectDelay / 1e3);
|
|
42760
42939
|
setIsRedirecting(true);
|
|
@@ -42787,7 +42966,7 @@ function useFormNavigation(options) {
|
|
|
42787
42966
|
},
|
|
42788
42967
|
[redirectDelay]
|
|
42789
42968
|
);
|
|
42790
|
-
const cancelRedirect = (0,
|
|
42969
|
+
const cancelRedirect = (0, import_react268.useCallback)(() => {
|
|
42791
42970
|
if (timerRef.current) {
|
|
42792
42971
|
clearInterval(timerRef.current);
|
|
42793
42972
|
timerRef.current = null;
|
|
@@ -42796,7 +42975,7 @@ function useFormNavigation(options) {
|
|
|
42796
42975
|
setCountdown(0);
|
|
42797
42976
|
redirectTargetRef.current = null;
|
|
42798
42977
|
}, []);
|
|
42799
|
-
const handlePostSubmit = (0,
|
|
42978
|
+
const handlePostSubmit = (0, import_react268.useCallback)(
|
|
42800
42979
|
(formInstId) => {
|
|
42801
42980
|
if (mode === "stay") {
|
|
42802
42981
|
onStay?.(formInstId);
|
|
@@ -42829,7 +43008,7 @@ function useFormNavigation(options) {
|
|
|
42829
43008
|
|
|
42830
43009
|
// packages/sdk/src/components/hooks/useDraftStorage.ts
|
|
42831
43010
|
init_cjs_shims();
|
|
42832
|
-
var
|
|
43011
|
+
var import_react269 = require("react");
|
|
42833
43012
|
function getDraftKey(appType, formUuid) {
|
|
42834
43013
|
return `${appType}__${formUuid}__draft`;
|
|
42835
43014
|
}
|
|
@@ -42849,10 +43028,10 @@ function readDraft(key) {
|
|
|
42849
43028
|
function useDraftStorage(options) {
|
|
42850
43029
|
const { appType, formUuid, autoRestore = false } = options;
|
|
42851
43030
|
const key = getDraftKey(appType, formUuid);
|
|
42852
|
-
const [hasDraft, setHasDraft] = (0,
|
|
42853
|
-
const [draftData, setDraftData] = (0,
|
|
42854
|
-
const [draftTimestamp, setDraftTimestamp] = (0,
|
|
42855
|
-
(0,
|
|
43031
|
+
const [hasDraft, setHasDraft] = (0, import_react269.useState)(false);
|
|
43032
|
+
const [draftData, setDraftData] = (0, import_react269.useState)(null);
|
|
43033
|
+
const [draftTimestamp, setDraftTimestamp] = (0, import_react269.useState)(null);
|
|
43034
|
+
(0, import_react269.useEffect)(() => {
|
|
42856
43035
|
const stored = readDraft(key);
|
|
42857
43036
|
if (stored) {
|
|
42858
43037
|
setHasDraft(true);
|
|
@@ -42866,7 +43045,7 @@ function useDraftStorage(options) {
|
|
|
42866
43045
|
setDraftTimestamp(null);
|
|
42867
43046
|
}
|
|
42868
43047
|
}, [key, autoRestore]);
|
|
42869
|
-
const saveDraft = (0,
|
|
43048
|
+
const saveDraft = (0, import_react269.useCallback)(
|
|
42870
43049
|
(data) => {
|
|
42871
43050
|
const payload = { data, ts: Date.now() };
|
|
42872
43051
|
try {
|
|
@@ -42880,7 +43059,7 @@ function useDraftStorage(options) {
|
|
|
42880
43059
|
},
|
|
42881
43060
|
[key]
|
|
42882
43061
|
);
|
|
42883
|
-
const restoreDraft = (0,
|
|
43062
|
+
const restoreDraft = (0, import_react269.useCallback)(() => {
|
|
42884
43063
|
const stored = readDraft(key);
|
|
42885
43064
|
if (stored) {
|
|
42886
43065
|
setDraftData(stored.data);
|
|
@@ -42888,7 +43067,7 @@ function useDraftStorage(options) {
|
|
|
42888
43067
|
}
|
|
42889
43068
|
return null;
|
|
42890
43069
|
}, [key]);
|
|
42891
|
-
const clearDraft = (0,
|
|
43070
|
+
const clearDraft = (0, import_react269.useCallback)(() => {
|
|
42892
43071
|
try {
|
|
42893
43072
|
localStorage.removeItem(key);
|
|
42894
43073
|
} catch (error) {
|
|
@@ -42993,7 +43172,7 @@ init_cjs_shims();
|
|
|
42993
43172
|
|
|
42994
43173
|
// packages/sdk/src/components/modules/RecordChangePanel.tsx
|
|
42995
43174
|
init_cjs_shims();
|
|
42996
|
-
var
|
|
43175
|
+
var import_react270 = require("react");
|
|
42997
43176
|
var import_antd26 = require("antd");
|
|
42998
43177
|
var import_icons7 = require("@ant-design/icons");
|
|
42999
43178
|
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
@@ -43039,7 +43218,7 @@ var RecordChangePanel = ({
|
|
|
43039
43218
|
onPageChange,
|
|
43040
43219
|
className = ""
|
|
43041
43220
|
}) => {
|
|
43042
|
-
const [expanded, setExpanded] = (0,
|
|
43221
|
+
const [expanded, setExpanded] = (0, import_react270.useState)(defaultExpanded);
|
|
43043
43222
|
const count = total ?? records.length;
|
|
43044
43223
|
const handleToggle = () => {
|
|
43045
43224
|
const next = !expanded;
|
|
@@ -43210,7 +43389,7 @@ var ChangeRecords = ({
|
|
|
43210
43389
|
|
|
43211
43390
|
// packages/sdk/src/components/modules/ApprovalTimeline.tsx
|
|
43212
43391
|
init_cjs_shims();
|
|
43213
|
-
var
|
|
43392
|
+
var import_react271 = require("react");
|
|
43214
43393
|
var import_icons8 = require("@ant-design/icons");
|
|
43215
43394
|
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
43216
43395
|
var systemNodeTypes = /* @__PURE__ */ new Set([
|
|
@@ -43359,8 +43538,8 @@ var ApprovalTimeline = ({
|
|
|
43359
43538
|
compactMode = false,
|
|
43360
43539
|
showApproverInfo = true
|
|
43361
43540
|
}) => {
|
|
43362
|
-
const taskList = (0,
|
|
43363
|
-
const groups = (0,
|
|
43541
|
+
const taskList = (0, import_react271.useMemo)(() => Array.isArray(tasks) ? tasks : [], [tasks]);
|
|
43542
|
+
const groups = (0, import_react271.useMemo)(() => groupTasks(taskList), [taskList]);
|
|
43364
43543
|
if (taskList.length === 0) {
|
|
43365
43544
|
return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
|
|
43366
43545
|
"div",
|
|
@@ -43456,13 +43635,13 @@ var ApprovalTimeline = ({
|
|
|
43456
43635
|
|
|
43457
43636
|
// packages/sdk/src/components/modules/ApprovalActionBar.tsx
|
|
43458
43637
|
init_cjs_shims();
|
|
43459
|
-
var
|
|
43638
|
+
var import_react273 = __toESM(require("react"));
|
|
43460
43639
|
var import_antd28 = require("antd");
|
|
43461
43640
|
var import_icons10 = require("@ant-design/icons");
|
|
43462
43641
|
|
|
43463
43642
|
// packages/sdk/src/components/modules/StickyActionBar.tsx
|
|
43464
43643
|
init_cjs_shims();
|
|
43465
|
-
var
|
|
43644
|
+
var import_react272 = require("react");
|
|
43466
43645
|
var import_antd27 = require("antd");
|
|
43467
43646
|
var import_icons9 = require("@ant-design/icons");
|
|
43468
43647
|
|
|
@@ -43499,14 +43678,14 @@ var StickyActionBar = ({
|
|
|
43499
43678
|
position = "sticky",
|
|
43500
43679
|
surface = "default"
|
|
43501
43680
|
}) => {
|
|
43502
|
-
const [isMobile, setIsMobile] = (0,
|
|
43503
|
-
(0,
|
|
43681
|
+
const [isMobile, setIsMobile] = (0, import_react272.useState)(false);
|
|
43682
|
+
(0, import_react272.useEffect)(() => {
|
|
43504
43683
|
const update3 = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
|
|
43505
43684
|
update3();
|
|
43506
43685
|
window.addEventListener("resize", update3);
|
|
43507
43686
|
return () => window.removeEventListener("resize", update3);
|
|
43508
43687
|
}, []);
|
|
43509
|
-
const visibleActions = (0,
|
|
43688
|
+
const visibleActions = (0, import_react272.useMemo)(
|
|
43510
43689
|
() => actions.filter((action) => action.visible !== false).sort((left, right) => getActionPriority(left) - getActionPriority(right)),
|
|
43511
43690
|
[actions]
|
|
43512
43691
|
);
|
|
@@ -43621,12 +43800,12 @@ function DefaultTransferSelector({
|
|
|
43621
43800
|
value,
|
|
43622
43801
|
onChange
|
|
43623
43802
|
}) {
|
|
43624
|
-
const formContext =
|
|
43803
|
+
const formContext = import_react273.default.useContext(FormContext);
|
|
43625
43804
|
const { isMobile } = useDeviceDetect();
|
|
43626
|
-
const fallbackApi = (0,
|
|
43805
|
+
const fallbackApi = (0, import_react273.useMemo)(() => createFormRuntimeApi(), []);
|
|
43627
43806
|
const api = formContext?.api ?? fallbackApi;
|
|
43628
|
-
const [open, setOpen] = (0,
|
|
43629
|
-
const [selectedUsers, setSelectedUsers] = (0,
|
|
43807
|
+
const [open, setOpen] = (0, import_react273.useState)(false);
|
|
43808
|
+
const [selectedUsers, setSelectedUsers] = (0, import_react273.useState)([]);
|
|
43630
43809
|
const selectedLabel = selectedUsers[0] ? getUserName(selectedUsers[0]) : value;
|
|
43631
43810
|
return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
|
|
43632
43811
|
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
@@ -43681,10 +43860,10 @@ var ApprovalActionBar = ({
|
|
|
43681
43860
|
maxWidth
|
|
43682
43861
|
}) => {
|
|
43683
43862
|
const [form] = import_antd28.Form.useForm();
|
|
43684
|
-
const [modalAction, setModalAction] = (0,
|
|
43685
|
-
const [activeAction, setActiveAction] = (0,
|
|
43686
|
-
const [loading, setLoading] = (0,
|
|
43687
|
-
const visibleActions = (0,
|
|
43863
|
+
const [modalAction, setModalAction] = (0, import_react273.useState)(null);
|
|
43864
|
+
const [activeAction, setActiveAction] = (0, import_react273.useState)(null);
|
|
43865
|
+
const [loading, setLoading] = (0, import_react273.useState)(false);
|
|
43866
|
+
const visibleActions = (0, import_react273.useMemo)(
|
|
43688
43867
|
() => actions.filter((action) => !action.hidden).sort((a, b) => (actionPriority[a.action] ?? 50) - (actionPriority[b.action] ?? 50)),
|
|
43689
43868
|
[actions]
|
|
43690
43869
|
);
|
|
@@ -43862,7 +44041,7 @@ var ApprovalActionBar = ({
|
|
|
43862
44041
|
|
|
43863
44042
|
// packages/sdk/src/components/modules/ApprovalActions.tsx
|
|
43864
44043
|
init_cjs_shims();
|
|
43865
|
-
var
|
|
44044
|
+
var import_react274 = require("react");
|
|
43866
44045
|
var import_antd29 = require("antd");
|
|
43867
44046
|
var import_icons11 = require("@ant-design/icons");
|
|
43868
44047
|
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
@@ -43890,11 +44069,11 @@ var ApprovalActions = ({
|
|
|
43890
44069
|
className = ""
|
|
43891
44070
|
}) => {
|
|
43892
44071
|
const [form] = import_antd29.Form.useForm();
|
|
43893
|
-
const [modalAction, setModalAction] = (0,
|
|
43894
|
-
const [activeAction, setActiveAction] = (0,
|
|
43895
|
-
const [loading, setLoading] = (0,
|
|
43896
|
-
const [saveLoading, setSaveLoading] = (0,
|
|
43897
|
-
const renderableActions = (0,
|
|
44072
|
+
const [modalAction, setModalAction] = (0, import_react274.useState)(null);
|
|
44073
|
+
const [activeAction, setActiveAction] = (0, import_react274.useState)(null);
|
|
44074
|
+
const [loading, setLoading] = (0, import_react274.useState)(false);
|
|
44075
|
+
const [saveLoading, setSaveLoading] = (0, import_react274.useState)(false);
|
|
44076
|
+
const renderableActions = (0, import_react274.useMemo)(
|
|
43898
44077
|
() => actions.filter((action) => !action.hidden).sort((a, b) => (priority2[a.action] ?? 50) - (priority2[b.action] ?? 50)),
|
|
43899
44078
|
[actions]
|
|
43900
44079
|
);
|
|
@@ -44025,7 +44204,7 @@ var ApprovalActions = ({
|
|
|
44025
44204
|
|
|
44026
44205
|
// packages/sdk/src/components/modules/FormActionBar.tsx
|
|
44027
44206
|
init_cjs_shims();
|
|
44028
|
-
var
|
|
44207
|
+
var import_react275 = require("react");
|
|
44029
44208
|
var import_antd30 = require("antd");
|
|
44030
44209
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
44031
44210
|
var FormActionBar = ({
|
|
@@ -44033,7 +44212,7 @@ var FormActionBar = ({
|
|
|
44033
44212
|
position = "bottom-fixed",
|
|
44034
44213
|
className = ""
|
|
44035
44214
|
}) => {
|
|
44036
|
-
const [loadingKeys, setLoadingKeys] = (0,
|
|
44215
|
+
const [loadingKeys, setLoadingKeys] = (0, import_react275.useState)(/* @__PURE__ */ new Set());
|
|
44037
44216
|
const visibleActions = actions.filter((a) => a.visible !== false);
|
|
44038
44217
|
const sortedActions = [...visibleActions].sort((a, b) => {
|
|
44039
44218
|
if (a.type === "danger" && b.type !== "danger") return -1;
|
|
@@ -44338,18 +44517,18 @@ var ProcessPreview = ({
|
|
|
44338
44517
|
|
|
44339
44518
|
// packages/sdk/src/components/modules/DataManagementList.tsx
|
|
44340
44519
|
init_cjs_shims();
|
|
44341
|
-
var
|
|
44520
|
+
var import_react281 = require("react");
|
|
44342
44521
|
var import_antd39 = require("antd");
|
|
44343
44522
|
var import_dayjs18 = __toESM(require("dayjs"));
|
|
44344
44523
|
var import_icons16 = require("@ant-design/icons");
|
|
44345
44524
|
|
|
44346
44525
|
// packages/sdk/src/components/templates/StandardFormPage.tsx
|
|
44347
44526
|
init_cjs_shims();
|
|
44348
|
-
var
|
|
44527
|
+
var import_react280 = require("react");
|
|
44349
44528
|
|
|
44350
44529
|
// packages/sdk/src/components/templates/FormDetailTemplate.tsx
|
|
44351
44530
|
init_cjs_shims();
|
|
44352
|
-
var
|
|
44531
|
+
var import_react276 = require("react");
|
|
44353
44532
|
var import_dayjs16 = __toESM(require("dayjs"));
|
|
44354
44533
|
|
|
44355
44534
|
// packages/sdk/src/components/templates/PageSkeleton.tsx
|
|
@@ -44446,10 +44625,10 @@ var InnerDetailContent = ({
|
|
|
44446
44625
|
onSave,
|
|
44447
44626
|
inDrawer = false
|
|
44448
44627
|
}) => {
|
|
44449
|
-
const formDataRef = (0,
|
|
44450
|
-
const validateRef = (0,
|
|
44451
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
44452
|
-
const fieldIds = (0,
|
|
44628
|
+
const formDataRef = (0, import_react276.useRef)(void 0);
|
|
44629
|
+
const validateRef = (0, import_react276.useRef)(void 0);
|
|
44630
|
+
const [accessDenied, setAccessDenied] = (0, import_react276.useState)(false);
|
|
44631
|
+
const fieldIds = (0, import_react276.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
44453
44632
|
const {
|
|
44454
44633
|
loading,
|
|
44455
44634
|
mode,
|
|
@@ -44484,7 +44663,7 @@ var InnerDetailContent = ({
|
|
|
44484
44663
|
formInstanceId,
|
|
44485
44664
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
44486
44665
|
});
|
|
44487
|
-
const handleSave = (0,
|
|
44666
|
+
const handleSave = (0, import_react276.useCallback)(async () => {
|
|
44488
44667
|
if (validateRef.current && !await validateAndNotify(validateRef.current)) return;
|
|
44489
44668
|
const values = formDataRef.current?.() ?? formData;
|
|
44490
44669
|
if (!values) return;
|
|
@@ -44493,13 +44672,13 @@ var InnerDetailContent = ({
|
|
|
44493
44672
|
onSave?.(values);
|
|
44494
44673
|
}
|
|
44495
44674
|
}, [formData, saveChanges, onSave]);
|
|
44496
|
-
const handleDelete = (0,
|
|
44675
|
+
const handleDelete = (0, import_react276.useCallback)(async () => {
|
|
44497
44676
|
const success = await deleteInstance();
|
|
44498
44677
|
if (success) {
|
|
44499
44678
|
onDelete?.();
|
|
44500
44679
|
}
|
|
44501
44680
|
}, [deleteInstance, onDelete]);
|
|
44502
|
-
const handleCancel = (0,
|
|
44681
|
+
const handleCancel = (0, import_react276.useCallback)(() => {
|
|
44503
44682
|
switchToReadonly();
|
|
44504
44683
|
}, [switchToReadonly]);
|
|
44505
44684
|
const readonlyActions = [];
|
|
@@ -44627,13 +44806,13 @@ var FormDetailTemplate = (props) => {
|
|
|
44627
44806
|
|
|
44628
44807
|
// packages/sdk/src/components/templates/FormSubmitTemplate.tsx
|
|
44629
44808
|
init_cjs_shims();
|
|
44630
|
-
var
|
|
44809
|
+
var import_react278 = require("react");
|
|
44631
44810
|
var import_antd37 = require("antd");
|
|
44632
44811
|
var import_icons15 = require("@ant-design/icons");
|
|
44633
44812
|
|
|
44634
44813
|
// packages/sdk/src/components/modules/InitiatorApproverSelector.tsx
|
|
44635
44814
|
init_cjs_shims();
|
|
44636
|
-
var
|
|
44815
|
+
var import_react277 = require("react");
|
|
44637
44816
|
var import_antd36 = require("antd");
|
|
44638
44817
|
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
44639
44818
|
var scopeText = {
|
|
@@ -44669,19 +44848,19 @@ var RequirementSelect = ({
|
|
|
44669
44848
|
selectedUsers,
|
|
44670
44849
|
onChange
|
|
44671
44850
|
}) => {
|
|
44672
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
44673
|
-
const initialCandidates = (0,
|
|
44851
|
+
const [pickerOpen, setPickerOpen] = (0, import_react277.useState)(false);
|
|
44852
|
+
const initialCandidates = (0, import_react277.useMemo)(
|
|
44674
44853
|
() => (requirement.candidateUsers || []).map(normalizeCandidate).filter(Boolean),
|
|
44675
44854
|
[requirement.candidateUsers]
|
|
44676
44855
|
);
|
|
44677
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
44678
|
-
const [loading, setLoading] = (0,
|
|
44679
|
-
(0,
|
|
44856
|
+
const [optionsSource, setOptionsSource] = (0, import_react277.useState)(initialCandidates);
|
|
44857
|
+
const [loading, setLoading] = (0, import_react277.useState)(false);
|
|
44858
|
+
(0, import_react277.useEffect)(() => {
|
|
44680
44859
|
setOptionsSource(
|
|
44681
44860
|
(current) => mergeUsers(initialCandidates, mergeUsers(current, selectedUsers))
|
|
44682
44861
|
);
|
|
44683
44862
|
}, [initialCandidates, selectedUsers]);
|
|
44684
|
-
const loadCandidates = (0,
|
|
44863
|
+
const loadCandidates = (0, import_react277.useCallback)(
|
|
44685
44864
|
async (keyword) => {
|
|
44686
44865
|
setLoading(true);
|
|
44687
44866
|
try {
|
|
@@ -44719,12 +44898,12 @@ var RequirementSelect = ({
|
|
|
44719
44898
|
},
|
|
44720
44899
|
[api, appType, formUuid, initialCandidates.length, requirement.nodeId, requirement.scope]
|
|
44721
44900
|
);
|
|
44722
|
-
(0,
|
|
44901
|
+
(0, import_react277.useEffect)(() => {
|
|
44723
44902
|
if (requirement.scope !== "all" && open && formUuid && appType && requirement.nodeId) {
|
|
44724
44903
|
void loadCandidates();
|
|
44725
44904
|
}
|
|
44726
44905
|
}, [appType, formUuid, loadCandidates, open, requirement.nodeId, requirement.scope]);
|
|
44727
|
-
const options = (0,
|
|
44906
|
+
const options = (0, import_react277.useMemo)(
|
|
44728
44907
|
() => optionsSource.map((user) => ({
|
|
44729
44908
|
value: user.id,
|
|
44730
44909
|
label: getUserLabel(user)
|
|
@@ -44809,9 +44988,9 @@ var InitiatorApproverSelector = ({
|
|
|
44809
44988
|
onOk,
|
|
44810
44989
|
onCancel
|
|
44811
44990
|
}) => {
|
|
44812
|
-
const [selected, setSelected] = (0,
|
|
44813
|
-
const wasOpenRef = (0,
|
|
44814
|
-
(0,
|
|
44991
|
+
const [selected, setSelected] = (0, import_react277.useState)({});
|
|
44992
|
+
const wasOpenRef = (0, import_react277.useRef)(false);
|
|
44993
|
+
(0, import_react277.useEffect)(() => {
|
|
44815
44994
|
if (open && !wasOpenRef.current) {
|
|
44816
44995
|
setSelected(value || EMPTY_SELECTED_MAP);
|
|
44817
44996
|
}
|
|
@@ -44967,26 +45146,26 @@ var InnerFormContent = ({
|
|
|
44967
45146
|
inDrawer = false
|
|
44968
45147
|
}) => {
|
|
44969
45148
|
const { validateAllWithErrors, getFormData: getFormData2, setFieldValue, resetForm, api } = useFormContext();
|
|
44970
|
-
const [submitted, setSubmitted] = (0,
|
|
44971
|
-
const [successInfo, setSuccessInfo] = (0,
|
|
44972
|
-
const [submitting, setSubmitting] = (0,
|
|
44973
|
-
const [departmentId, setDepartmentId] = (0,
|
|
44974
|
-
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = (0,
|
|
44975
|
-
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = (0,
|
|
44976
|
-
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = (0,
|
|
44977
|
-
const submissionDepartmentResolverRef = (0,
|
|
44978
|
-
const [previewOpen, setPreviewOpen] = (0,
|
|
44979
|
-
const [previewLoading, setPreviewLoading] = (0,
|
|
44980
|
-
const [previewRoutes, setPreviewRoutes] = (0,
|
|
44981
|
-
const [pendingFormData, setPendingFormData] = (0,
|
|
44982
|
-
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = (0,
|
|
44983
|
-
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = (0,
|
|
44984
|
-
const pendingSubmissionDepartmentIdRef = (0,
|
|
44985
|
-
const pendingInitiatorSelectedApproversRef = (0,
|
|
45149
|
+
const [submitted, setSubmitted] = (0, import_react278.useState)(false);
|
|
45150
|
+
const [successInfo, setSuccessInfo] = (0, import_react278.useState)(null);
|
|
45151
|
+
const [submitting, setSubmitting] = (0, import_react278.useState)(false);
|
|
45152
|
+
const [departmentId, setDepartmentId] = (0, import_react278.useState)();
|
|
45153
|
+
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = (0, import_react278.useState)(false);
|
|
45154
|
+
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = (0, import_react278.useState)([]);
|
|
45155
|
+
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = (0, import_react278.useState)();
|
|
45156
|
+
const submissionDepartmentResolverRef = (0, import_react278.useRef)(null);
|
|
45157
|
+
const [previewOpen, setPreviewOpen] = (0, import_react278.useState)(false);
|
|
45158
|
+
const [previewLoading, setPreviewLoading] = (0, import_react278.useState)(false);
|
|
45159
|
+
const [previewRoutes, setPreviewRoutes] = (0, import_react278.useState)([]);
|
|
45160
|
+
const [pendingFormData, setPendingFormData] = (0, import_react278.useState)(null);
|
|
45161
|
+
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = (0, import_react278.useState)();
|
|
45162
|
+
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = (0, import_react278.useState)();
|
|
45163
|
+
const pendingSubmissionDepartmentIdRef = (0, import_react278.useRef)(void 0);
|
|
45164
|
+
const pendingInitiatorSelectedApproversRef = (0, import_react278.useRef)(
|
|
44986
45165
|
void 0
|
|
44987
45166
|
);
|
|
44988
|
-
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0,
|
|
44989
|
-
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0,
|
|
45167
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react278.useState)(false);
|
|
45168
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react278.useState)([]);
|
|
44990
45169
|
const { hasDraft, draftTimestamp, saveDraft, restoreDraft, clearDraft } = useDraftStorage({
|
|
44991
45170
|
appType: config3.appType,
|
|
44992
45171
|
formUuid: config3.formUuid
|
|
@@ -44998,20 +45177,20 @@ var InnerFormContent = ({
|
|
|
44998
45177
|
mode: submitSuccessMode === "continue" ? "stay" : submitSuccessMode,
|
|
44999
45178
|
basePath: config3.navigation?.basePath
|
|
45000
45179
|
});
|
|
45001
|
-
(0,
|
|
45180
|
+
(0, import_react278.useEffect)(() => {
|
|
45002
45181
|
return () => {
|
|
45003
45182
|
submissionDepartmentResolverRef.current?.(null);
|
|
45004
45183
|
submissionDepartmentResolverRef.current = null;
|
|
45005
45184
|
};
|
|
45006
45185
|
}, []);
|
|
45007
|
-
const closeSubmissionDepartmentModal = (0,
|
|
45186
|
+
const closeSubmissionDepartmentModal = (0, import_react278.useCallback)((value = null) => {
|
|
45008
45187
|
setSubmissionDepartmentModalOpen(false);
|
|
45009
45188
|
setSubmissionDepartmentOptions([]);
|
|
45010
45189
|
setSelectedSubmissionDepartmentId(void 0);
|
|
45011
45190
|
submissionDepartmentResolverRef.current?.(value);
|
|
45012
45191
|
submissionDepartmentResolverRef.current = null;
|
|
45013
45192
|
}, []);
|
|
45014
|
-
const promptSubmissionDepartmentSelection = (0,
|
|
45193
|
+
const promptSubmissionDepartmentSelection = (0, import_react278.useCallback)(
|
|
45015
45194
|
(options, preferredDepartmentId) => {
|
|
45016
45195
|
return new Promise((resolve) => {
|
|
45017
45196
|
const selected = options.some((option) => option.value === preferredDepartmentId) ? preferredDepartmentId : options[0]?.value;
|
|
@@ -45023,7 +45202,7 @@ var InnerFormContent = ({
|
|
|
45023
45202
|
},
|
|
45024
45203
|
[]
|
|
45025
45204
|
);
|
|
45026
|
-
const resolveSubmissionDepartmentId = (0,
|
|
45205
|
+
const resolveSubmissionDepartmentId = (0, import_react278.useCallback)(async () => {
|
|
45027
45206
|
if (formType !== "process") {
|
|
45028
45207
|
return void 0;
|
|
45029
45208
|
}
|
|
@@ -45045,7 +45224,7 @@ var InnerFormContent = ({
|
|
|
45045
45224
|
}
|
|
45046
45225
|
return promptSubmissionDepartmentSelection(departments, departmentId);
|
|
45047
45226
|
}, [api, config3.formUuid, departmentId, formType, promptSubmissionDepartmentSelection, schema]);
|
|
45048
|
-
const performSubmit = (0,
|
|
45227
|
+
const performSubmit = (0, import_react278.useCallback)(
|
|
45049
45228
|
async (formData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
45050
45229
|
const submitData = normalizeFormDataForSubmit(schema, formData);
|
|
45051
45230
|
setSubmitting(true);
|
|
@@ -45102,7 +45281,7 @@ var InnerFormContent = ({
|
|
|
45102
45281
|
departmentId
|
|
45103
45282
|
]
|
|
45104
45283
|
);
|
|
45105
|
-
const continuePreparedSubmit = (0,
|
|
45284
|
+
const continuePreparedSubmit = (0, import_react278.useCallback)(
|
|
45106
45285
|
async (submitData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
45107
45286
|
if (formType === "process" && enableProcessPreview) {
|
|
45108
45287
|
setPendingFormData(submitData);
|
|
@@ -45134,7 +45313,7 @@ var InnerFormContent = ({
|
|
|
45134
45313
|
},
|
|
45135
45314
|
[api.request, config3.appType, config3.formUuid, enableProcessPreview, formType, performSubmit]
|
|
45136
45315
|
);
|
|
45137
|
-
const prepareSubmit = (0,
|
|
45316
|
+
const prepareSubmit = (0, import_react278.useCallback)(async () => {
|
|
45138
45317
|
const valid = await validateAndNotify(validateAllWithErrors);
|
|
45139
45318
|
if (!valid) return;
|
|
45140
45319
|
const formData = getFormData2();
|
|
@@ -45190,7 +45369,7 @@ var InnerFormContent = ({
|
|
|
45190
45369
|
resolveSubmissionDepartmentId,
|
|
45191
45370
|
continuePreparedSubmit
|
|
45192
45371
|
]);
|
|
45193
|
-
const handlePreviewConfirm = (0,
|
|
45372
|
+
const handlePreviewConfirm = (0, import_react278.useCallback)(async () => {
|
|
45194
45373
|
const data = pendingFormData ?? getFormData2();
|
|
45195
45374
|
const submissionDepartmentId = pendingSubmissionDepartmentIdRef.current ?? pendingSubmissionDepartmentId;
|
|
45196
45375
|
const initiatorSelectedApprovers = pendingInitiatorSelectedApproversRef.current ?? pendingInitiatorSelectedApprovers;
|
|
@@ -45208,7 +45387,7 @@ var InnerFormContent = ({
|
|
|
45208
45387
|
pendingSubmissionDepartmentId,
|
|
45209
45388
|
performSubmit
|
|
45210
45389
|
]);
|
|
45211
|
-
const handleInitiatorApproverConfirm = (0,
|
|
45390
|
+
const handleInitiatorApproverConfirm = (0, import_react278.useCallback)(
|
|
45212
45391
|
async (selectedUsersByNode) => {
|
|
45213
45392
|
const data = pendingFormData;
|
|
45214
45393
|
if (!data) {
|
|
@@ -45224,7 +45403,7 @@ var InnerFormContent = ({
|
|
|
45224
45403
|
},
|
|
45225
45404
|
[continuePreparedSubmit, pendingFormData, pendingSubmissionDepartmentId]
|
|
45226
45405
|
);
|
|
45227
|
-
const handleInitiatorApproverCancel = (0,
|
|
45406
|
+
const handleInitiatorApproverCancel = (0, import_react278.useCallback)(() => {
|
|
45228
45407
|
setInitiatorApproverOpen(false);
|
|
45229
45408
|
setInitiatorApproverRequirements([]);
|
|
45230
45409
|
setPendingFormData(null);
|
|
@@ -45233,23 +45412,23 @@ var InnerFormContent = ({
|
|
|
45233
45412
|
pendingSubmissionDepartmentIdRef.current = void 0;
|
|
45234
45413
|
pendingInitiatorSelectedApproversRef.current = void 0;
|
|
45235
45414
|
}, []);
|
|
45236
|
-
const handleSaveDraft = (0,
|
|
45415
|
+
const handleSaveDraft = (0, import_react278.useCallback)(() => {
|
|
45237
45416
|
const data = getFormData2();
|
|
45238
45417
|
saveDraft(data);
|
|
45239
45418
|
}, [getFormData2, saveDraft]);
|
|
45240
|
-
const handleRestoreDraft = (0,
|
|
45419
|
+
const handleRestoreDraft = (0, import_react278.useCallback)(() => {
|
|
45241
45420
|
const data = restoreDraft();
|
|
45242
45421
|
if (!data) return;
|
|
45243
45422
|
Object.entries(data).forEach(([fieldId, value]) => {
|
|
45244
45423
|
setFieldValue(fieldId, value);
|
|
45245
45424
|
});
|
|
45246
45425
|
}, [restoreDraft, setFieldValue]);
|
|
45247
|
-
const handleContinue = (0,
|
|
45426
|
+
const handleContinue = (0, import_react278.useCallback)(() => {
|
|
45248
45427
|
setSubmitted(false);
|
|
45249
45428
|
setSuccessInfo(null);
|
|
45250
45429
|
resetForm();
|
|
45251
45430
|
}, [resetForm]);
|
|
45252
|
-
const handleViewDetail = (0,
|
|
45431
|
+
const handleViewDetail = (0, import_react278.useCallback)(() => {
|
|
45253
45432
|
if (!successInfo) return;
|
|
45254
45433
|
if (formType === "process") {
|
|
45255
45434
|
navigateToProcessDetail(successInfo.formInstanceId);
|
|
@@ -45471,7 +45650,7 @@ var FormSubmitTemplate = ({
|
|
|
45471
45650
|
|
|
45472
45651
|
// packages/sdk/src/components/templates/ProcessDetailTemplate.tsx
|
|
45473
45652
|
init_cjs_shims();
|
|
45474
|
-
var
|
|
45653
|
+
var import_react279 = require("react");
|
|
45475
45654
|
var import_dayjs17 = __toESM(require("dayjs"));
|
|
45476
45655
|
var import_antd38 = require("antd");
|
|
45477
45656
|
var import_jsx_runtime99 = require("react/jsx-runtime");
|
|
@@ -45564,17 +45743,17 @@ var InnerProcessContent = ({
|
|
|
45564
45743
|
onDelete,
|
|
45565
45744
|
inDrawer = false
|
|
45566
45745
|
}) => {
|
|
45567
|
-
const formDataRef = (0,
|
|
45568
|
-
const validateRef = (0,
|
|
45746
|
+
const formDataRef = (0, import_react279.useRef)(void 0);
|
|
45747
|
+
const validateRef = (0, import_react279.useRef)(void 0);
|
|
45569
45748
|
const [withdrawForm] = import_antd38.Form.useForm();
|
|
45570
|
-
const [withdrawOpen, setWithdrawOpen] = (0,
|
|
45571
|
-
const [withdrawLoading, setWithdrawLoading] = (0,
|
|
45572
|
-
const [saveLoading, setSaveLoading] = (0,
|
|
45573
|
-
const [deleteLoading, setDeleteLoading] = (0,
|
|
45574
|
-
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0,
|
|
45575
|
-
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0,
|
|
45576
|
-
const [pendingResubmitComments, setPendingResubmitComments] = (0,
|
|
45577
|
-
const fieldIds = (0,
|
|
45749
|
+
const [withdrawOpen, setWithdrawOpen] = (0, import_react279.useState)(false);
|
|
45750
|
+
const [withdrawLoading, setWithdrawLoading] = (0, import_react279.useState)(false);
|
|
45751
|
+
const [saveLoading, setSaveLoading] = (0, import_react279.useState)(false);
|
|
45752
|
+
const [deleteLoading, setDeleteLoading] = (0, import_react279.useState)(false);
|
|
45753
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react279.useState)(false);
|
|
45754
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react279.useState)([]);
|
|
45755
|
+
const [pendingResubmitComments, setPendingResubmitComments] = (0, import_react279.useState)();
|
|
45756
|
+
const fieldIds = (0, import_react279.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
45578
45757
|
const { api } = useFormContext();
|
|
45579
45758
|
const {
|
|
45580
45759
|
loading,
|
|
@@ -45642,45 +45821,45 @@ var InnerProcessContent = ({
|
|
|
45642
45821
|
formInstanceId,
|
|
45643
45822
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
45644
45823
|
});
|
|
45645
|
-
const validateForm = (0,
|
|
45824
|
+
const validateForm = (0, import_react279.useCallback)(async () => {
|
|
45646
45825
|
return validateRef.current ? validateAndNotify(validateRef.current) : true;
|
|
45647
45826
|
}, []);
|
|
45648
|
-
const handleApprove = (0,
|
|
45827
|
+
const handleApprove = (0, import_react279.useCallback)(
|
|
45649
45828
|
async (comments) => {
|
|
45650
45829
|
if (!await validateForm()) return;
|
|
45651
45830
|
await approve(comments);
|
|
45652
45831
|
},
|
|
45653
45832
|
[approve, validateForm]
|
|
45654
45833
|
);
|
|
45655
|
-
const handleReject = (0,
|
|
45834
|
+
const handleReject = (0, import_react279.useCallback)(
|
|
45656
45835
|
async (comments) => {
|
|
45657
45836
|
await reject(comments);
|
|
45658
45837
|
},
|
|
45659
45838
|
[reject]
|
|
45660
45839
|
);
|
|
45661
|
-
const handleTransfer = (0,
|
|
45840
|
+
const handleTransfer = (0, import_react279.useCallback)(
|
|
45662
45841
|
async (userId, reason) => {
|
|
45663
45842
|
await transfer(userId, reason);
|
|
45664
45843
|
},
|
|
45665
45844
|
[transfer]
|
|
45666
45845
|
);
|
|
45667
|
-
const handleReturn = (0,
|
|
45846
|
+
const handleReturn = (0, import_react279.useCallback)(
|
|
45668
45847
|
async (nodeId, reason) => {
|
|
45669
45848
|
await returnTo(nodeId, reason);
|
|
45670
45849
|
},
|
|
45671
45850
|
[returnTo]
|
|
45672
45851
|
);
|
|
45673
|
-
const handleWithdraw = (0,
|
|
45852
|
+
const handleWithdraw = (0, import_react279.useCallback)(
|
|
45674
45853
|
async (reason) => {
|
|
45675
45854
|
await withdraw(reason);
|
|
45676
45855
|
},
|
|
45677
45856
|
[withdraw]
|
|
45678
45857
|
);
|
|
45679
|
-
const handleSave = (0,
|
|
45858
|
+
const handleSave = (0, import_react279.useCallback)(async () => {
|
|
45680
45859
|
if (!await validateForm()) return;
|
|
45681
45860
|
await save();
|
|
45682
45861
|
}, [save, validateForm]);
|
|
45683
|
-
const handleResubmit = (0,
|
|
45862
|
+
const handleResubmit = (0, import_react279.useCallback)(
|
|
45684
45863
|
async (comments) => {
|
|
45685
45864
|
if (!await validateForm()) return;
|
|
45686
45865
|
const values = formDataRef.current?.() ?? formData ?? {};
|
|
@@ -45714,7 +45893,7 @@ var InnerProcessContent = ({
|
|
|
45714
45893
|
},
|
|
45715
45894
|
[api.request, appType, currentTaskId, formData, formUuid, resubmit, validateForm]
|
|
45716
45895
|
);
|
|
45717
|
-
const handleInitiatorApproverConfirm = (0,
|
|
45896
|
+
const handleInitiatorApproverConfirm = (0, import_react279.useCallback)(
|
|
45718
45897
|
async (selectedUsersByNode) => {
|
|
45719
45898
|
const selectedApprovers = normalizeSelectedApprovers2(selectedUsersByNode);
|
|
45720
45899
|
setInitiatorApproverOpen(false);
|
|
@@ -45725,15 +45904,15 @@ var InnerProcessContent = ({
|
|
|
45725
45904
|
},
|
|
45726
45905
|
[pendingResubmitComments, resubmit]
|
|
45727
45906
|
);
|
|
45728
|
-
const handleInitiatorApproverCancel = (0,
|
|
45907
|
+
const handleInitiatorApproverCancel = (0, import_react279.useCallback)(() => {
|
|
45729
45908
|
setInitiatorApproverOpen(false);
|
|
45730
45909
|
setInitiatorApproverRequirements([]);
|
|
45731
45910
|
setPendingResubmitComments(void 0);
|
|
45732
45911
|
}, []);
|
|
45733
|
-
const handleCallback = (0,
|
|
45912
|
+
const handleCallback = (0, import_react279.useCallback)(async () => {
|
|
45734
45913
|
await callbackTask();
|
|
45735
45914
|
}, [callbackTask]);
|
|
45736
|
-
const handleCompletedSave = (0,
|
|
45915
|
+
const handleCompletedSave = (0, import_react279.useCallback)(async () => {
|
|
45737
45916
|
if (!await validateForm()) return;
|
|
45738
45917
|
const values = formDataRef.current?.() ?? formData;
|
|
45739
45918
|
if (!values) return;
|
|
@@ -45747,7 +45926,7 @@ var InnerProcessContent = ({
|
|
|
45747
45926
|
setSaveLoading(false);
|
|
45748
45927
|
}
|
|
45749
45928
|
}, [formData, onSave, saveChanges, validateForm]);
|
|
45750
|
-
const handleCompletedDelete = (0,
|
|
45929
|
+
const handleCompletedDelete = (0, import_react279.useCallback)(async () => {
|
|
45751
45930
|
setDeleteLoading(true);
|
|
45752
45931
|
try {
|
|
45753
45932
|
const success = await deleteInstance();
|
|
@@ -45758,7 +45937,7 @@ var InnerProcessContent = ({
|
|
|
45758
45937
|
setDeleteLoading(false);
|
|
45759
45938
|
}
|
|
45760
45939
|
}, [deleteInstance, onDelete]);
|
|
45761
|
-
const handleFooterWithdraw = (0,
|
|
45940
|
+
const handleFooterWithdraw = (0, import_react279.useCallback)(async () => {
|
|
45762
45941
|
const values = await withdrawForm.validateFields();
|
|
45763
45942
|
setWithdrawLoading(true);
|
|
45764
45943
|
try {
|
|
@@ -45769,11 +45948,11 @@ var InnerProcessContent = ({
|
|
|
45769
45948
|
setWithdrawLoading(false);
|
|
45770
45949
|
}
|
|
45771
45950
|
}, [handleWithdraw, withdrawForm]);
|
|
45772
|
-
const handleFooterWithdrawCancel = (0,
|
|
45951
|
+
const handleFooterWithdrawCancel = (0, import_react279.useCallback)(() => {
|
|
45773
45952
|
setWithdrawOpen(false);
|
|
45774
45953
|
withdrawForm.resetFields();
|
|
45775
45954
|
}, [withdrawForm]);
|
|
45776
|
-
const bottomActions = (0,
|
|
45955
|
+
const bottomActions = (0, import_react279.useMemo)(() => {
|
|
45777
45956
|
if (isApprover && !isOriginatorReturn && activeActions.length > 0) return [];
|
|
45778
45957
|
if (isProcessCompleted) {
|
|
45779
45958
|
if (mode === "readonly") {
|
|
@@ -46120,7 +46299,7 @@ var StandardFormPage = ({
|
|
|
46120
46299
|
const formType = normalizeStandardFormType(
|
|
46121
46300
|
schema.template?.formType || (resolvedMode === "process" ? "process" : "form")
|
|
46122
46301
|
);
|
|
46123
|
-
const submitApi = (0,
|
|
46302
|
+
const submitApi = (0, import_react280.useMemo)(() => {
|
|
46124
46303
|
if (!onSubmit) return void 0;
|
|
46125
46304
|
return {
|
|
46126
46305
|
submitFormData: async (payload) => onSubmit(
|
|
@@ -46133,7 +46312,7 @@ var StandardFormPage = ({
|
|
|
46133
46312
|
}
|
|
46134
46313
|
};
|
|
46135
46314
|
}, [formType, onSubmit]);
|
|
46136
|
-
const api = (0,
|
|
46315
|
+
const api = (0, import_react280.useMemo)(() => {
|
|
46137
46316
|
if (!externalApi && !submitApi) return void 0;
|
|
46138
46317
|
return {
|
|
46139
46318
|
...externalApi ?? {},
|
|
@@ -46722,10 +46901,10 @@ function AsyncEntityFilterSelect({
|
|
|
46722
46901
|
value,
|
|
46723
46902
|
onChange
|
|
46724
46903
|
}) {
|
|
46725
|
-
const [options, setOptions] = (0,
|
|
46726
|
-
const [fetching, setFetching] = (0,
|
|
46904
|
+
const [options, setOptions] = (0, import_react281.useState)([]);
|
|
46905
|
+
const [fetching, setFetching] = (0, import_react281.useState)(false);
|
|
46727
46906
|
const multiple = normalizeOperator(operator) === "IN";
|
|
46728
|
-
const loadOptions = (0,
|
|
46907
|
+
const loadOptions = (0, import_react281.useCallback)(
|
|
46729
46908
|
async (keyword = "") => {
|
|
46730
46909
|
setFetching(true);
|
|
46731
46910
|
try {
|
|
@@ -46767,7 +46946,7 @@ function AsyncEntityFilterSelect({
|
|
|
46767
46946
|
},
|
|
46768
46947
|
[api, entityType]
|
|
46769
46948
|
);
|
|
46770
|
-
(0,
|
|
46949
|
+
(0, import_react281.useEffect)(() => {
|
|
46771
46950
|
void loadOptions();
|
|
46772
46951
|
}, [loadOptions]);
|
|
46773
46952
|
return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
@@ -47076,7 +47255,7 @@ function ResizableColumnTitle({
|
|
|
47076
47255
|
onResize: onResize2,
|
|
47077
47256
|
onResizeEnd
|
|
47078
47257
|
}) {
|
|
47079
|
-
const dragRef = (0,
|
|
47258
|
+
const dragRef = (0, import_react281.useRef)({ startX: 0, startWidth: width, latestWidth: width });
|
|
47080
47259
|
const handleMouseDown = (event) => {
|
|
47081
47260
|
event.preventDefault();
|
|
47082
47261
|
event.stopPropagation();
|
|
@@ -47141,86 +47320,86 @@ var DataManagementList = ({
|
|
|
47141
47320
|
rowActions = [],
|
|
47142
47321
|
maxVisibleRowActions
|
|
47143
47322
|
}) => {
|
|
47144
|
-
const rootRef = (0,
|
|
47145
|
-
const api = (0,
|
|
47323
|
+
const rootRef = (0, import_react281.useRef)(null);
|
|
47324
|
+
const api = (0, import_react281.useMemo)(() => {
|
|
47146
47325
|
if (typeof requestOverride === "function") {
|
|
47147
47326
|
return createFormRuntimeApi({ request: requestOverride });
|
|
47148
47327
|
}
|
|
47149
47328
|
return createFormRuntimeApi(requestOverride);
|
|
47150
47329
|
}, [requestOverride]);
|
|
47151
|
-
const [fields, setFields] = (0,
|
|
47152
|
-
const [runtimeFormSchema, setRuntimeFormSchema] = (0,
|
|
47153
|
-
const [config3, setConfig] = (0,
|
|
47154
|
-
const [formType, setFormType] = (0,
|
|
47155
|
-
const [showFields, setShowFields] = (0,
|
|
47156
|
-
const [lockFieldIds, setLockFieldIds] = (0,
|
|
47157
|
-
const [widths, setWidths] = (0,
|
|
47158
|
-
const widthsRef = (0,
|
|
47159
|
-
const [sort, setSort] = (0,
|
|
47160
|
-
const [density, setDensity] = (0,
|
|
47161
|
-
const [detailOpenMode, setDetailOpenMode] = (0,
|
|
47162
|
-
const [searchKeyWord, setSearchKeyWord] = (0,
|
|
47163
|
-
const [filterGroup, setFilterGroup] = (0,
|
|
47164
|
-
const [dataSource, setDataSource] = (0,
|
|
47165
|
-
const [total, setTotal] = (0,
|
|
47166
|
-
const [current, setCurrent] = (0,
|
|
47167
|
-
const [pageSize, setPageSize] = (0,
|
|
47168
|
-
const [loading, setLoading] = (0,
|
|
47169
|
-
const [schemaLoading, setSchemaLoading] = (0,
|
|
47170
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
47171
|
-
const [filterOpen, setFilterOpen] = (0,
|
|
47172
|
-
const [columnOpen, setColumnOpen] = (0,
|
|
47173
|
-
const [exportOpen, setExportOpen] = (0,
|
|
47174
|
-
const [exportScope, setExportScope] = (0,
|
|
47175
|
-
const [exportFields, setExportFields] = (0,
|
|
47176
|
-
const [exporting, setExporting] = (0,
|
|
47177
|
-
const [importOpen, setImportOpen] = (0,
|
|
47178
|
-
const [importPreview, setImportPreview] = (0,
|
|
47179
|
-
const [importBase64, setImportBase64] = (0,
|
|
47180
|
-
const [templateDownloading, setTemplateDownloading] = (0,
|
|
47181
|
-
const [recordsOpen, setRecordsOpen] = (0,
|
|
47182
|
-
const [recordTab, setRecordTab] = (0,
|
|
47183
|
-
const [transferRecords, setTransferRecords] = (0,
|
|
47184
|
-
const [batchApprovalOpen, setBatchApprovalOpen] = (0,
|
|
47185
|
-
const [batchApprovalAction, setBatchApprovalAction] = (0,
|
|
47330
|
+
const [fields, setFields] = (0, import_react281.useState)([]);
|
|
47331
|
+
const [runtimeFormSchema, setRuntimeFormSchema] = (0, import_react281.useState)(null);
|
|
47332
|
+
const [config3, setConfig] = (0, import_react281.useState)({});
|
|
47333
|
+
const [formType, setFormType] = (0, import_react281.useState)("form");
|
|
47334
|
+
const [showFields, setShowFields] = (0, import_react281.useState)([]);
|
|
47335
|
+
const [lockFieldIds, setLockFieldIds] = (0, import_react281.useState)([]);
|
|
47336
|
+
const [widths, setWidths] = (0, import_react281.useState)({});
|
|
47337
|
+
const widthsRef = (0, import_react281.useRef)({});
|
|
47338
|
+
const [sort, setSort] = (0, import_react281.useState)([]);
|
|
47339
|
+
const [density, setDensity] = (0, import_react281.useState)("middle");
|
|
47340
|
+
const [detailOpenMode, setDetailOpenMode] = (0, import_react281.useState)("drawer");
|
|
47341
|
+
const [searchKeyWord, setSearchKeyWord] = (0, import_react281.useState)("");
|
|
47342
|
+
const [filterGroup, setFilterGroup] = (0, import_react281.useState)(createGroup);
|
|
47343
|
+
const [dataSource, setDataSource] = (0, import_react281.useState)([]);
|
|
47344
|
+
const [total, setTotal] = (0, import_react281.useState)(0);
|
|
47345
|
+
const [current, setCurrent] = (0, import_react281.useState)(1);
|
|
47346
|
+
const [pageSize, setPageSize] = (0, import_react281.useState)(10);
|
|
47347
|
+
const [loading, setLoading] = (0, import_react281.useState)(false);
|
|
47348
|
+
const [schemaLoading, setSchemaLoading] = (0, import_react281.useState)(true);
|
|
47349
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react281.useState)([]);
|
|
47350
|
+
const [filterOpen, setFilterOpen] = (0, import_react281.useState)(false);
|
|
47351
|
+
const [columnOpen, setColumnOpen] = (0, import_react281.useState)(false);
|
|
47352
|
+
const [exportOpen, setExportOpen] = (0, import_react281.useState)(false);
|
|
47353
|
+
const [exportScope, setExportScope] = (0, import_react281.useState)("all");
|
|
47354
|
+
const [exportFields, setExportFields] = (0, import_react281.useState)([]);
|
|
47355
|
+
const [exporting, setExporting] = (0, import_react281.useState)(false);
|
|
47356
|
+
const [importOpen, setImportOpen] = (0, import_react281.useState)(false);
|
|
47357
|
+
const [importPreview, setImportPreview] = (0, import_react281.useState)([]);
|
|
47358
|
+
const [importBase64, setImportBase64] = (0, import_react281.useState)("");
|
|
47359
|
+
const [templateDownloading, setTemplateDownloading] = (0, import_react281.useState)(false);
|
|
47360
|
+
const [recordsOpen, setRecordsOpen] = (0, import_react281.useState)(false);
|
|
47361
|
+
const [recordTab, setRecordTab] = (0, import_react281.useState)("export");
|
|
47362
|
+
const [transferRecords, setTransferRecords] = (0, import_react281.useState)([]);
|
|
47363
|
+
const [batchApprovalOpen, setBatchApprovalOpen] = (0, import_react281.useState)(false);
|
|
47364
|
+
const [batchApprovalAction, setBatchApprovalAction] = (0, import_react281.useState)(
|
|
47186
47365
|
"approved"
|
|
47187
47366
|
);
|
|
47188
|
-
const [batchApprovalComments, setBatchApprovalComments] = (0,
|
|
47189
|
-
const [batchApproving, setBatchApproving] = (0,
|
|
47190
|
-
const [activeRecord, setActiveRecord] = (0,
|
|
47191
|
-
const [detailOpen, setDetailOpen] = (0,
|
|
47192
|
-
const [submitOpen, setSubmitOpen] = (0,
|
|
47193
|
-
const fetchStateRef = (0,
|
|
47367
|
+
const [batchApprovalComments, setBatchApprovalComments] = (0, import_react281.useState)("");
|
|
47368
|
+
const [batchApproving, setBatchApproving] = (0, import_react281.useState)(false);
|
|
47369
|
+
const [activeRecord, setActiveRecord] = (0, import_react281.useState)(null);
|
|
47370
|
+
const [detailOpen, setDetailOpen] = (0, import_react281.useState)(false);
|
|
47371
|
+
const [submitOpen, setSubmitOpen] = (0, import_react281.useState)(false);
|
|
47372
|
+
const fetchStateRef = (0, import_react281.useRef)({});
|
|
47194
47373
|
const isProcessForm = isProcessFormType(formType);
|
|
47195
47374
|
const request = api.request;
|
|
47196
|
-
const getPopupContainer = (0,
|
|
47375
|
+
const getPopupContainer = (0, import_react281.useCallback)(
|
|
47197
47376
|
(triggerNode) => resolveDataManagementPopupContainer(rootRef.current, triggerNode),
|
|
47198
47377
|
[]
|
|
47199
47378
|
);
|
|
47200
|
-
const getOverlayContainer = (0,
|
|
47379
|
+
const getOverlayContainer = (0, import_react281.useCallback)(
|
|
47201
47380
|
() => resolveDataManagementPortalContainer(rootRef.current),
|
|
47202
47381
|
[]
|
|
47203
47382
|
);
|
|
47204
47383
|
const drawerWidth = "min(960px, calc(100vw - 48px))";
|
|
47205
|
-
const confirmDanger = (0,
|
|
47384
|
+
const confirmDanger = (0, import_react281.useCallback)((title2, content, onOk) => {
|
|
47206
47385
|
if (confirmAction(title2, content)) onOk();
|
|
47207
47386
|
}, []);
|
|
47208
|
-
const visibleFields = (0,
|
|
47387
|
+
const visibleFields = (0, import_react281.useMemo)(
|
|
47209
47388
|
() => showFields.map((fieldId) => fields.find((field) => field.fieldId === fieldId)).filter(Boolean),
|
|
47210
47389
|
[fields, showFields]
|
|
47211
47390
|
);
|
|
47212
|
-
const forcedShowFieldIds = (0,
|
|
47391
|
+
const forcedShowFieldIds = (0, import_react281.useMemo)(
|
|
47213
47392
|
() => new Set(forcedConfig?.showFields || []),
|
|
47214
47393
|
[forcedConfig?.showFields]
|
|
47215
47394
|
);
|
|
47216
|
-
const forcedLockFieldIds = (0,
|
|
47395
|
+
const forcedLockFieldIds = (0, import_react281.useMemo)(
|
|
47217
47396
|
() => new Set(forcedConfig?.lockFieldIds || []),
|
|
47218
47397
|
[forcedConfig?.lockFieldIds]
|
|
47219
47398
|
);
|
|
47220
|
-
(0,
|
|
47399
|
+
(0, import_react281.useEffect)(() => {
|
|
47221
47400
|
widthsRef.current = widths;
|
|
47222
47401
|
}, [widths]);
|
|
47223
|
-
(0,
|
|
47402
|
+
(0, import_react281.useEffect)(() => {
|
|
47224
47403
|
fetchStateRef.current = {
|
|
47225
47404
|
current,
|
|
47226
47405
|
pageSize,
|
|
@@ -47229,7 +47408,7 @@ var DataManagementList = ({
|
|
|
47229
47408
|
sort
|
|
47230
47409
|
};
|
|
47231
47410
|
}, [current, filterGroup, pageSize, searchKeyWord, sort]);
|
|
47232
|
-
const loadData = (0,
|
|
47411
|
+
const loadData = (0, import_react281.useCallback)(
|
|
47233
47412
|
async (overrides = {}) => {
|
|
47234
47413
|
if (!appType || !formUuid) return;
|
|
47235
47414
|
const fetchState = { ...fetchStateRef.current, ...overrides };
|
|
@@ -47273,7 +47452,7 @@ var DataManagementList = ({
|
|
|
47273
47452
|
},
|
|
47274
47453
|
[appType, forcedConfig, formUuid, request]
|
|
47275
47454
|
);
|
|
47276
|
-
(0,
|
|
47455
|
+
(0, import_react281.useEffect)(() => {
|
|
47277
47456
|
let mounted = true;
|
|
47278
47457
|
const loadSchemaAndConfig = async () => {
|
|
47279
47458
|
if (!appType || !formUuid) return;
|
|
@@ -47355,7 +47534,7 @@ var DataManagementList = ({
|
|
|
47355
47534
|
request,
|
|
47356
47535
|
title
|
|
47357
47536
|
]);
|
|
47358
|
-
const persistConfig = (0,
|
|
47537
|
+
const persistConfig = (0, import_react281.useCallback)(
|
|
47359
47538
|
async (patch) => {
|
|
47360
47539
|
const personalPatch = stripForcedConfigPatch(patch, forcedConfig);
|
|
47361
47540
|
const nextConfig = { ...config3, ...personalPatch };
|
|
@@ -47399,12 +47578,12 @@ var DataManagementList = ({
|
|
|
47399
47578
|
const handleRemoveSort = (index2) => {
|
|
47400
47579
|
setSort((prev) => prev.filter((_, itemIndex) => itemIndex !== index2));
|
|
47401
47580
|
};
|
|
47402
|
-
const updateColumnWidth = (0,
|
|
47581
|
+
const updateColumnWidth = (0, import_react281.useCallback)((fieldId, width) => {
|
|
47403
47582
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
47404
47583
|
widthsRef.current = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
47405
47584
|
setWidths(widthsRef.current);
|
|
47406
47585
|
}, []);
|
|
47407
|
-
const commitColumnWidth = (0,
|
|
47586
|
+
const commitColumnWidth = (0, import_react281.useCallback)(
|
|
47408
47587
|
(fieldId, width) => {
|
|
47409
47588
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
47410
47589
|
const nextWidths = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
@@ -47414,7 +47593,7 @@ var DataManagementList = ({
|
|
|
47414
47593
|
},
|
|
47415
47594
|
[persistConfig]
|
|
47416
47595
|
);
|
|
47417
|
-
const handleDetail = (0,
|
|
47596
|
+
const handleDetail = (0, import_react281.useCallback)(
|
|
47418
47597
|
(record2) => {
|
|
47419
47598
|
const formInstanceId = getRecordId(record2);
|
|
47420
47599
|
if (!formInstanceId) {
|
|
@@ -47439,7 +47618,7 @@ var DataManagementList = ({
|
|
|
47439
47618
|
},
|
|
47440
47619
|
[appType, detailBasePath, detailOpenMode, detailPageUrlBuilder, formType, formUuid]
|
|
47441
47620
|
);
|
|
47442
|
-
const handleDelete = (0,
|
|
47621
|
+
const handleDelete = (0, import_react281.useCallback)(
|
|
47443
47622
|
async (ids) => {
|
|
47444
47623
|
if (ids.length === 0) return;
|
|
47445
47624
|
await deleteDataManagementRows(request, { appType, formUuid, formInstanceIds: ids });
|
|
@@ -47448,7 +47627,7 @@ var DataManagementList = ({
|
|
|
47448
47627
|
},
|
|
47449
47628
|
[appType, current, formUuid, loadData, pageSize, request]
|
|
47450
47629
|
);
|
|
47451
|
-
const getSelectedRecordIds = (0,
|
|
47630
|
+
const getSelectedRecordIds = (0, import_react281.useCallback)(
|
|
47452
47631
|
() => selectedRowKeys.map((key) => {
|
|
47453
47632
|
const record2 = dataSource.find((item) => String(getRecordId(item)) === String(key));
|
|
47454
47633
|
return String(getSelectedRecordId(record2, key));
|
|
@@ -47575,7 +47754,7 @@ var DataManagementList = ({
|
|
|
47575
47754
|
ACTION_COLUMN_MIN_WIDTH,
|
|
47576
47755
|
Math.min(rowActionCount, visibleRowActionLimit) * ACTION_BUTTON_ESTIMATED_WIDTH + (rowActionCount > visibleRowActionLimit ? ACTION_MORE_BUTTON_WIDTH : 0) + ACTION_COLUMN_HORIZONTAL_PADDING
|
|
47577
47756
|
);
|
|
47578
|
-
const columns = (0,
|
|
47757
|
+
const columns = (0, import_react281.useMemo)(() => {
|
|
47579
47758
|
const baseColumns = visibleFields.map((field) => {
|
|
47580
47759
|
const columnWidth = widths[field.fieldId] || field.width || 160;
|
|
47581
47760
|
return {
|
|
@@ -47705,7 +47884,7 @@ var DataManagementList = ({
|
|
|
47705
47884
|
actionColumnWidth
|
|
47706
47885
|
)
|
|
47707
47886
|
);
|
|
47708
|
-
const importPreviewColumns = (0,
|
|
47887
|
+
const importPreviewColumns = (0, import_react281.useMemo)(() => {
|
|
47709
47888
|
const keys2 = Array.from(
|
|
47710
47889
|
new Set(importPreview.flatMap((record2) => Object.keys(record2 || {})))
|
|
47711
47890
|
).slice(0, 16);
|
|
@@ -48275,7 +48454,7 @@ init_cjs_shims();
|
|
|
48275
48454
|
|
|
48276
48455
|
// packages/sdk/src/components/templates/LowcodePageRenderer.tsx
|
|
48277
48456
|
init_cjs_shims();
|
|
48278
|
-
var
|
|
48457
|
+
var import_react282 = __toESM(require("react"));
|
|
48279
48458
|
var import_jsx_runtime102 = require("react/jsx-runtime");
|
|
48280
48459
|
function nodeChildren(node) {
|
|
48281
48460
|
if (Array.isArray(node.children)) return node.children;
|
|
@@ -48305,7 +48484,7 @@ function createRuntimeRequest(context) {
|
|
|
48305
48484
|
}
|
|
48306
48485
|
function LowcodePageRenderer({ schema, context }) {
|
|
48307
48486
|
const appType = context?.appType || schema.pageMeta.appType;
|
|
48308
|
-
const requestOverride = (0,
|
|
48487
|
+
const requestOverride = (0, import_react282.useMemo)(() => createRuntimeRequest(context), [context]);
|
|
48309
48488
|
const renderNode = (node) => {
|
|
48310
48489
|
const props = node.props || {};
|
|
48311
48490
|
const children = nodeChildren(node);
|
|
@@ -48330,7 +48509,7 @@ function LowcodePageRenderer({ schema, context }) {
|
|
|
48330
48509
|
if (node.type === "HeadingBlock") {
|
|
48331
48510
|
const level = Math.min(Math.max(Number(props.level || 2), 1), 4);
|
|
48332
48511
|
const tagName = `h${level}`;
|
|
48333
|
-
return
|
|
48512
|
+
return import_react282.default.createElement(
|
|
48334
48513
|
tagName,
|
|
48335
48514
|
{ key: node.id, className: "sy-page-heading" },
|
|
48336
48515
|
props.text || props.title || "\u6807\u9898"
|