openxiangda 1.0.153 → 1.0.155
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/openxiangda-skills/SKILL.md +1 -0
- package/openxiangda-skills/references/component-guide.md +2 -0
- package/openxiangda-skills/references/pages/page-sdk.md +19 -0
- package/openxiangda-skills/references/troubleshooting.md +18 -5
- package/openxiangda-skills/skills/openxiangda-form/SKILL.md +1 -0
- package/openxiangda-skills/skills/openxiangda-page/SKILL.md +1 -0
- package/package.json +1 -1
- package/packages/sdk/dist/components/index.cjs +41 -1
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +2 -1
- package/packages/sdk/dist/components/index.d.ts +2 -1
- package/packages/sdk/dist/components/index.mjs +41 -1
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/index.cjs +846 -796
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +1 -1
- package/packages/sdk/dist/runtime/index.d.ts +1 -1
- package/packages/sdk/dist/runtime/index.mjs +232 -182
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +274 -224
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +10 -2
- package/packages/sdk/dist/runtime/react.d.ts +10 -2
- package/packages/sdk/dist/runtime/react.mjs +146 -96
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
- package/templates/openxiangda-react-spa/AGENTS.md +1 -0
|
@@ -50,6 +50,7 @@ __export(runtime_exports, {
|
|
|
50
50
|
createBrowserPageBridge: () => createBrowserPageBridge,
|
|
51
51
|
createBrowserPageContext: () => createBrowserPageContext,
|
|
52
52
|
createBuiltinRouteRequest: () => createBuiltinRouteRequest,
|
|
53
|
+
createPageFormRuntimeApi: () => createPageFormRuntimeApi,
|
|
53
54
|
createPageSdk: () => createPageSdk,
|
|
54
55
|
createPublicAccessClient: () => createPublicAccessClient,
|
|
55
56
|
createReactPage: () => createReactPage,
|
|
@@ -79,6 +80,7 @@ __export(runtime_exports, {
|
|
|
79
80
|
useNavigation: () => useNavigation,
|
|
80
81
|
useOpenXiangda: () => useOpenXiangda,
|
|
81
82
|
usePageContext: () => usePageContext,
|
|
83
|
+
usePageFormRuntimeApi: () => usePageFormRuntimeApi,
|
|
82
84
|
usePageProps: () => usePageProps,
|
|
83
85
|
usePageRoute: () => usePageRoute,
|
|
84
86
|
usePageSdk: () => usePageSdk,
|
|
@@ -3034,9 +3036,8 @@ var usePageRoute = () => {
|
|
|
3034
3036
|
return usePageContext().route;
|
|
3035
3037
|
};
|
|
3036
3038
|
|
|
3037
|
-
// packages/sdk/src/runtime/react/
|
|
3038
|
-
var
|
|
3039
|
-
var import_antd5 = require("antd");
|
|
3039
|
+
// packages/sdk/src/runtime/react/formRuntime.ts
|
|
3040
|
+
var import_react7 = require("react");
|
|
3040
3041
|
|
|
3041
3042
|
// packages/sdk/src/components/core/imageCompression.ts
|
|
3042
3043
|
var DEFAULT_THUMB = {
|
|
@@ -3889,6 +3890,73 @@ function createFormRuntimeApi(config) {
|
|
|
3889
3890
|
return { ...defaults, ...overrides, request };
|
|
3890
3891
|
}
|
|
3891
3892
|
|
|
3893
|
+
// packages/sdk/src/runtime/react/formRuntime.ts
|
|
3894
|
+
var normalizeMethod2 = (method) => {
|
|
3895
|
+
const value = String(method || "get").toLowerCase();
|
|
3896
|
+
return ["get", "post", "put", "delete", "patch"].includes(value) ? value : "get";
|
|
3897
|
+
};
|
|
3898
|
+
var normalizeHeaders = (headers) => {
|
|
3899
|
+
if (!headers) return void 0;
|
|
3900
|
+
return Object.fromEntries(new Headers(headers).entries());
|
|
3901
|
+
};
|
|
3902
|
+
var toPageRequest = (config) => ({
|
|
3903
|
+
path: config.url,
|
|
3904
|
+
method: normalizeMethod2(config.method),
|
|
3905
|
+
query: config.params,
|
|
3906
|
+
body: config.data,
|
|
3907
|
+
headers: normalizeHeaders(config.headers)
|
|
3908
|
+
});
|
|
3909
|
+
var toRuntimeResponse = (response) => {
|
|
3910
|
+
if (response.raw && typeof response.raw === "object") {
|
|
3911
|
+
return response.raw;
|
|
3912
|
+
}
|
|
3913
|
+
return {
|
|
3914
|
+
code: Number(response.code) || 200,
|
|
3915
|
+
success: response.success,
|
|
3916
|
+
message: response.message,
|
|
3917
|
+
data: response.result,
|
|
3918
|
+
result: response.result
|
|
3919
|
+
};
|
|
3920
|
+
};
|
|
3921
|
+
var unwrapPageResult = (response) => response.result ?? response.data ?? null;
|
|
3922
|
+
var createPageFormRuntimeApi = (sdk) => {
|
|
3923
|
+
const request = async (config) => {
|
|
3924
|
+
const options = toPageRequest(config);
|
|
3925
|
+
if (config.responseType === "blob") {
|
|
3926
|
+
const response = await sdk.transport.download(options);
|
|
3927
|
+
return response.blob;
|
|
3928
|
+
}
|
|
3929
|
+
return toRuntimeResponse(await sdk.transport.request(options));
|
|
3930
|
+
};
|
|
3931
|
+
return createFormRuntimeApi({
|
|
3932
|
+
request,
|
|
3933
|
+
createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => unwrapPageResult(
|
|
3934
|
+
await sdk.createFileAccessTicket(
|
|
3935
|
+
bucketName,
|
|
3936
|
+
objectName,
|
|
3937
|
+
fileName,
|
|
3938
|
+
purpose,
|
|
3939
|
+
options
|
|
3940
|
+
)
|
|
3941
|
+
),
|
|
3942
|
+
createDownloadTicket: async (bucketName, objectName, fileName) => unwrapPageResult(
|
|
3943
|
+
await sdk.request({
|
|
3944
|
+
path: "/file/download-ticket",
|
|
3945
|
+
method: "post",
|
|
3946
|
+
body: { bucketName, objectName, fileName }
|
|
3947
|
+
})
|
|
3948
|
+
)
|
|
3949
|
+
});
|
|
3950
|
+
};
|
|
3951
|
+
var usePageFormRuntimeApi = () => {
|
|
3952
|
+
const sdk = usePageSdk();
|
|
3953
|
+
return (0, import_react7.useMemo)(() => createPageFormRuntimeApi(sdk), [sdk]);
|
|
3954
|
+
};
|
|
3955
|
+
|
|
3956
|
+
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
3957
|
+
var import_react11 = __toESM(require("react"));
|
|
3958
|
+
var import_antd5 = require("antd");
|
|
3959
|
+
|
|
3892
3960
|
// packages/sdk/src/components/fields/shared/fieldFormat.ts
|
|
3893
3961
|
function createUid(prefix = "field") {
|
|
3894
3962
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -4190,6 +4258,45 @@ var normalizePreviewBlobResponse = (response) => {
|
|
|
4190
4258
|
if (blob) return blob;
|
|
4191
4259
|
throw new Error(getBinaryResponseMessage(payload) || "\u6587\u4EF6\u5185\u5BB9\u54CD\u5E94\u4E0D\u662F\u4E8C\u8FDB\u5236\u6570\u636E");
|
|
4192
4260
|
};
|
|
4261
|
+
var isZipBytes = (bytes) => bytes.length >= 4 && bytes[0] === 80 && bytes[1] === 75 && (bytes[2] === 3 && bytes[3] === 4 || bytes[2] === 5 && bytes[3] === 6 || bytes[2] === 7 && bytes[3] === 8);
|
|
4262
|
+
var decodeBase64ZipBlob = async (blob) => {
|
|
4263
|
+
const prefix = (await blob.slice(0, 96).text()).replace(/^\uFEFF/, "").replace(/\s+/g, "");
|
|
4264
|
+
if (!prefix.startsWith("UEsDB")) return blob;
|
|
4265
|
+
if (blob.size > 32 * 1024 * 1024) {
|
|
4266
|
+
throw new Error("Base64 \u6587\u4EF6\u8D85\u8FC7\u6D4F\u89C8\u5668\u517C\u5BB9\u89E3\u7801\u4E0A\u9650");
|
|
4267
|
+
}
|
|
4268
|
+
const base64 = (await blob.text()).replace(/^\uFEFF/, "").replace(/\s+/g, "");
|
|
4269
|
+
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(base64)) {
|
|
4270
|
+
throw new Error("\u6587\u4EF6\u5185\u5BB9\u662F\u65E0\u6548\u7684 Base64 \u4E8C\u8FDB\u5236\u6570\u636E");
|
|
4271
|
+
}
|
|
4272
|
+
let binary = "";
|
|
4273
|
+
try {
|
|
4274
|
+
binary = globalThis.atob(base64);
|
|
4275
|
+
} catch {
|
|
4276
|
+
throw new Error("\u6587\u4EF6\u5185\u5BB9\u662F\u65E0\u6548\u7684 Base64 \u4E8C\u8FDB\u5236\u6570\u636E");
|
|
4277
|
+
}
|
|
4278
|
+
const bytes = new Uint8Array(binary.length);
|
|
4279
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
4280
|
+
bytes[index] = binary.charCodeAt(index);
|
|
4281
|
+
}
|
|
4282
|
+
if (!isZipBytes(bytes)) {
|
|
4283
|
+
throw new Error("Base64 \u6587\u4EF6\u89E3\u7801\u540E\u4E0D\u662F\u6709\u6548\u7684 Office \u6587\u6863");
|
|
4284
|
+
}
|
|
4285
|
+
if (globalThis.btoa(binary).replace(/=+$/, "") !== base64.replace(/=+$/, "")) {
|
|
4286
|
+
throw new Error("\u6587\u4EF6\u5185\u5BB9\u662F\u65E0\u6548\u7684 Base64 \u4E8C\u8FDB\u5236\u6570\u636E");
|
|
4287
|
+
}
|
|
4288
|
+
return new Blob([bytes], { type: blob.type || "application/zip" });
|
|
4289
|
+
};
|
|
4290
|
+
var normalizePreviewBlobContent = async (response) => {
|
|
4291
|
+
const blob = normalizePreviewBlobResponse(response);
|
|
4292
|
+
if (String(blob.type || "").toLowerCase().includes("application/json")) {
|
|
4293
|
+
const payload = await blob.text().then((value) => JSON.parse(value)).catch(() => null);
|
|
4294
|
+
if (payload) {
|
|
4295
|
+
throw new Error(getBinaryResponseMessage(payload) || "\u6587\u4EF6\u5185\u5BB9\u8BF7\u6C42\u5931\u8D25");
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
return decodeBase64ZipBlob(blob);
|
|
4299
|
+
};
|
|
4193
4300
|
var isDirectStorageItem = (item) => item.provider === "oss" || item.uploadProvider === "oss" || item.uploadProvider === "builtin-oss" || Boolean(item.storageCode);
|
|
4194
4301
|
var getPreviewItemKey = (item, index = 0) => getAttachmentItemIdentity(item) || item.id || item.uid || `${item.name || "file"}-${index}`;
|
|
4195
4302
|
var getPreviewSourceUrl = (item) => item.previewUrl || item.publicUrl || item.url || "";
|
|
@@ -4363,7 +4470,7 @@ var prepareFilePreview = async (options) => {
|
|
|
4363
4470
|
};
|
|
4364
4471
|
var loadPreviewBlob = async (request, url) => {
|
|
4365
4472
|
const response = await request({ url, method: "get", responseType: "blob" });
|
|
4366
|
-
return
|
|
4473
|
+
return normalizePreviewBlobContent(response);
|
|
4367
4474
|
};
|
|
4368
4475
|
var convertHeicPreview = async (request, url) => {
|
|
4369
4476
|
const source = await loadPreviewBlob(request, url);
|
|
@@ -4381,7 +4488,7 @@ var convertHeicPreview = async (request, url) => {
|
|
|
4381
4488
|
};
|
|
4382
4489
|
|
|
4383
4490
|
// packages/sdk/src/components/file-preview/FilePreviewContent.tsx
|
|
4384
|
-
var
|
|
4491
|
+
var import_react8 = require("react");
|
|
4385
4492
|
var import_antd2 = require("antd");
|
|
4386
4493
|
var import_icons = require("@ant-design/icons");
|
|
4387
4494
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -4465,11 +4572,11 @@ var PayloadPreview = ({
|
|
|
4465
4572
|
url,
|
|
4466
4573
|
mode
|
|
4467
4574
|
}) => {
|
|
4468
|
-
const [payload, setPayload] = (0,
|
|
4469
|
-
const [loading, setLoading] = (0,
|
|
4470
|
-
const [error, setError] = (0,
|
|
4471
|
-
const [reloadKey, setReloadKey] = (0,
|
|
4472
|
-
(0,
|
|
4575
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4576
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
4577
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4578
|
+
const [reloadKey, setReloadKey] = (0, import_react8.useState)(0);
|
|
4579
|
+
(0, import_react8.useEffect)(() => {
|
|
4473
4580
|
let disposed = false;
|
|
4474
4581
|
setPayload(null);
|
|
4475
4582
|
setError("");
|
|
@@ -4577,9 +4684,9 @@ var ClientTextPreview = ({
|
|
|
4577
4684
|
request,
|
|
4578
4685
|
url
|
|
4579
4686
|
}) => {
|
|
4580
|
-
const [payload, setPayload] = (0,
|
|
4581
|
-
const [error, setError] = (0,
|
|
4582
|
-
(0,
|
|
4687
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4688
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4689
|
+
(0, import_react8.useEffect)(() => {
|
|
4583
4690
|
let disposed = false;
|
|
4584
4691
|
let textLimit = 1024 * 1024;
|
|
4585
4692
|
loadPreviewBlob(request, url).then(async (blob) => {
|
|
@@ -4615,10 +4722,10 @@ var ClientTextPreview = ({
|
|
|
4615
4722
|
] });
|
|
4616
4723
|
};
|
|
4617
4724
|
var DocxPreview = ({ request, url }) => {
|
|
4618
|
-
const containerRef = (0,
|
|
4619
|
-
const [loading, setLoading] = (0,
|
|
4620
|
-
const [error, setError] = (0,
|
|
4621
|
-
(0,
|
|
4725
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
4726
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
4727
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4728
|
+
(0, import_react8.useEffect)(() => {
|
|
4622
4729
|
let disposed = false;
|
|
4623
4730
|
const container = containerRef.current;
|
|
4624
4731
|
if (!container || !url) return () => {
|
|
@@ -4677,9 +4784,9 @@ var HeicImagePreview = ({
|
|
|
4677
4784
|
url,
|
|
4678
4785
|
fileName
|
|
4679
4786
|
}) => {
|
|
4680
|
-
const [src, setSrc] = (0,
|
|
4681
|
-
const [error, setError] = (0,
|
|
4682
|
-
(0,
|
|
4787
|
+
const [src, setSrc] = (0, import_react8.useState)("");
|
|
4788
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4789
|
+
(0, import_react8.useEffect)(() => {
|
|
4683
4790
|
let disposed = false;
|
|
4684
4791
|
let objectUrl = "";
|
|
4685
4792
|
convertHeicPreview(request, url).then((result) => {
|
|
@@ -4708,9 +4815,9 @@ var ClientSpreadsheetPreview = ({
|
|
|
4708
4815
|
request,
|
|
4709
4816
|
url
|
|
4710
4817
|
}) => {
|
|
4711
|
-
const [payload, setPayload] = (0,
|
|
4712
|
-
const [error, setError] = (0,
|
|
4713
|
-
(0,
|
|
4818
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4819
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4820
|
+
(0, import_react8.useEffect)(() => {
|
|
4714
4821
|
let disposed = false;
|
|
4715
4822
|
(async () => {
|
|
4716
4823
|
try {
|
|
@@ -4826,13 +4933,13 @@ var OnlyOfficePreview = ({
|
|
|
4826
4933
|
configUrl,
|
|
4827
4934
|
ticket
|
|
4828
4935
|
}) => {
|
|
4829
|
-
const editorId = (0,
|
|
4936
|
+
const editorId = (0, import_react8.useMemo)(
|
|
4830
4937
|
() => `openxiangda-onlyoffice-${String(ticket || "editor").replace(/[^a-zA-Z0-9_-]/g, "")}`,
|
|
4831
4938
|
[ticket]
|
|
4832
4939
|
);
|
|
4833
|
-
const [loading, setLoading] = (0,
|
|
4834
|
-
const [error, setError] = (0,
|
|
4835
|
-
(0,
|
|
4940
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
4941
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4942
|
+
(0, import_react8.useEffect)(() => {
|
|
4836
4943
|
let disposed = false;
|
|
4837
4944
|
let editor;
|
|
4838
4945
|
setLoading(true);
|
|
@@ -5015,7 +5122,7 @@ var FilePreviewContent = ({
|
|
|
5015
5122
|
};
|
|
5016
5123
|
|
|
5017
5124
|
// packages/sdk/src/components/file-preview/FilePreviewPage.tsx
|
|
5018
|
-
var
|
|
5125
|
+
var import_react9 = require("react");
|
|
5019
5126
|
var import_antd3 = require("antd");
|
|
5020
5127
|
var import_icons2 = require("@ant-design/icons");
|
|
5021
5128
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -5024,11 +5131,11 @@ var FilePreviewPage = ({
|
|
|
5024
5131
|
request,
|
|
5025
5132
|
servicePrefix = "/service"
|
|
5026
5133
|
}) => {
|
|
5027
|
-
const [metadata, setMetadata] = (0,
|
|
5028
|
-
const [loading, setLoading] = (0,
|
|
5029
|
-
const [error, setError] = (0,
|
|
5030
|
-
const [reloadKey, setReloadKey] = (0,
|
|
5031
|
-
(0,
|
|
5134
|
+
const [metadata, setMetadata] = (0, import_react9.useState)(null);
|
|
5135
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
5136
|
+
const [error, setError] = (0, import_react9.useState)("");
|
|
5137
|
+
const [reloadKey, setReloadKey] = (0, import_react9.useState)(0);
|
|
5138
|
+
(0, import_react9.useEffect)(() => {
|
|
5032
5139
|
let disposed = false;
|
|
5033
5140
|
setMetadata(null);
|
|
5034
5141
|
setError("");
|
|
@@ -5053,7 +5160,7 @@ var FilePreviewPage = ({
|
|
|
5053
5160
|
};
|
|
5054
5161
|
}, [reloadKey, request, ticket]);
|
|
5055
5162
|
const downloadUrl = resolvePreviewServiceUrl(metadata?.downloadUrl, servicePrefix);
|
|
5056
|
-
const handleDownload = (0,
|
|
5163
|
+
const handleDownload = (0, import_react9.useCallback)(() => {
|
|
5057
5164
|
if (downloadUrl && typeof window !== "undefined") window.location.assign(downloadUrl);
|
|
5058
5165
|
}, [downloadUrl]);
|
|
5059
5166
|
const renderContent = () => {
|
|
@@ -5197,7 +5304,7 @@ var FilePreviewPage = ({
|
|
|
5197
5304
|
};
|
|
5198
5305
|
|
|
5199
5306
|
// packages/sdk/src/components/file-preview/useFilePreview.tsx
|
|
5200
|
-
var
|
|
5307
|
+
var import_react10 = require("react");
|
|
5201
5308
|
var import_antd4 = require("antd");
|
|
5202
5309
|
var import_icons3 = require("@ant-design/icons");
|
|
5203
5310
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -5226,7 +5333,7 @@ var useFilePreviewController = ({
|
|
|
5226
5333
|
enabled = true,
|
|
5227
5334
|
requireServerCapability = true
|
|
5228
5335
|
}) => {
|
|
5229
|
-
const itemSignature = (0,
|
|
5336
|
+
const itemSignature = (0, import_react10.useMemo)(
|
|
5230
5337
|
() => items.map(
|
|
5231
5338
|
(item, index) => [
|
|
5232
5339
|
getPreviewItemKey(item, index),
|
|
@@ -5239,17 +5346,17 @@ var useFilePreviewController = ({
|
|
|
5239
5346
|
).join("|"),
|
|
5240
5347
|
[items]
|
|
5241
5348
|
);
|
|
5242
|
-
const [capabilities, setCapabilities] = (0,
|
|
5349
|
+
const [capabilities, setCapabilities] = (0, import_react10.useState)(
|
|
5243
5350
|
() => buildCapabilityMap(items, requireServerCapability)
|
|
5244
5351
|
);
|
|
5245
|
-
const [openingKey, setOpeningKey] = (0,
|
|
5246
|
-
const [dialogPreview, setDialogPreview] = (0,
|
|
5247
|
-
const [imagePreview, setImagePreview] = (0,
|
|
5352
|
+
const [openingKey, setOpeningKey] = (0, import_react10.useState)("");
|
|
5353
|
+
const [dialogPreview, setDialogPreview] = (0, import_react10.useState)(null);
|
|
5354
|
+
const [imagePreview, setImagePreview] = (0, import_react10.useState)({
|
|
5248
5355
|
open: false,
|
|
5249
5356
|
current: 0,
|
|
5250
5357
|
items: []
|
|
5251
5358
|
});
|
|
5252
|
-
(0,
|
|
5359
|
+
(0, import_react10.useEffect)(() => {
|
|
5253
5360
|
let disposed = false;
|
|
5254
5361
|
const initial = buildCapabilityMap(items, requireServerCapability);
|
|
5255
5362
|
setCapabilities(initial);
|
|
@@ -5294,28 +5401,28 @@ var useFilePreviewController = ({
|
|
|
5294
5401
|
disposed = true;
|
|
5295
5402
|
};
|
|
5296
5403
|
}, [api, enabled, itemSignature, requireServerCapability]);
|
|
5297
|
-
const getCapability = (0,
|
|
5404
|
+
const getCapability = (0, import_react10.useCallback)(
|
|
5298
5405
|
(item) => {
|
|
5299
5406
|
const index = items.indexOf(item);
|
|
5300
5407
|
return capabilities[getPreviewItemKey(item, Math.max(index, 0))];
|
|
5301
5408
|
},
|
|
5302
5409
|
[capabilities, items]
|
|
5303
5410
|
);
|
|
5304
|
-
const canPreview = (0,
|
|
5411
|
+
const canPreview = (0, import_react10.useCallback)(
|
|
5305
5412
|
(item) => enabled && canActOnItem(item) && getCapability(item)?.canPreview === true,
|
|
5306
5413
|
[enabled, getCapability]
|
|
5307
5414
|
);
|
|
5308
|
-
const closeImagePreview = (0,
|
|
5415
|
+
const closeImagePreview = (0, import_react10.useCallback)(() => {
|
|
5309
5416
|
setImagePreview((current) => {
|
|
5310
5417
|
revokeImageItems(current.items);
|
|
5311
5418
|
return { open: false, current: 0, items: [] };
|
|
5312
5419
|
});
|
|
5313
5420
|
}, []);
|
|
5314
|
-
(0,
|
|
5421
|
+
(0, import_react10.useEffect)(
|
|
5315
5422
|
() => () => revokeImageItems(imagePreview.items),
|
|
5316
5423
|
[imagePreview.items]
|
|
5317
5424
|
);
|
|
5318
|
-
const resolvePreparedImageItem = (0,
|
|
5425
|
+
const resolvePreparedImageItem = (0, import_react10.useCallback)(
|
|
5319
5426
|
async (prepared, index) => {
|
|
5320
5427
|
const item = prepared.item;
|
|
5321
5428
|
const metadata = prepared.metadata;
|
|
@@ -5337,14 +5444,14 @@ var useFilePreviewController = ({
|
|
|
5337
5444
|
},
|
|
5338
5445
|
[api]
|
|
5339
5446
|
);
|
|
5340
|
-
const prepareImageItem = (0,
|
|
5447
|
+
const prepareImageItem = (0, import_react10.useCallback)(
|
|
5341
5448
|
async (item, index) => {
|
|
5342
5449
|
const prepared = await prepareFilePreview({ item, api, appType, bucketName });
|
|
5343
5450
|
return resolvePreparedImageItem(prepared, index);
|
|
5344
5451
|
},
|
|
5345
5452
|
[api, appType, bucketName, resolvePreparedImageItem]
|
|
5346
5453
|
);
|
|
5347
|
-
const openPreview = (0,
|
|
5454
|
+
const openPreview = (0, import_react10.useCallback)(
|
|
5348
5455
|
async (item) => {
|
|
5349
5456
|
const itemIndex = Math.max(items.indexOf(item), 0);
|
|
5350
5457
|
const key = getPreviewItemKey(item, itemIndex);
|
|
@@ -5407,7 +5514,7 @@ var useFilePreviewController = ({
|
|
|
5407
5514
|
resolvePreparedImageItem
|
|
5408
5515
|
]
|
|
5409
5516
|
);
|
|
5410
|
-
const downloadItem = (0,
|
|
5517
|
+
const downloadItem = (0, import_react10.useCallback)(
|
|
5411
5518
|
async (item, prepared) => {
|
|
5412
5519
|
let url = prepared?.metadata.downloadUrl || item.downloadUrl || item.publicUrl || item.url;
|
|
5413
5520
|
if (!isDirectStorageItem(item) && item.objectName && !prepared?.metadata.downloadUrl) {
|
|
@@ -5571,63 +5678,6 @@ function FileStatusText({
|
|
|
5571
5678
|
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
5572
5679
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
5573
5680
|
var EMPTY_ITEMS = [];
|
|
5574
|
-
var normalizeMethod2 = (method) => {
|
|
5575
|
-
const value = String(method || "get").toLowerCase();
|
|
5576
|
-
return ["get", "post", "put", "delete", "patch"].includes(value) ? value : "get";
|
|
5577
|
-
};
|
|
5578
|
-
var normalizeHeaders = (headers) => {
|
|
5579
|
-
if (!headers) return void 0;
|
|
5580
|
-
return Object.fromEntries(new Headers(headers).entries());
|
|
5581
|
-
};
|
|
5582
|
-
var toPageRequest = (config) => ({
|
|
5583
|
-
path: config.url,
|
|
5584
|
-
method: normalizeMethod2(config.method),
|
|
5585
|
-
query: config.params,
|
|
5586
|
-
body: config.data,
|
|
5587
|
-
headers: normalizeHeaders(config.headers)
|
|
5588
|
-
});
|
|
5589
|
-
var toRuntimeResponse = (response) => {
|
|
5590
|
-
if (response.raw && typeof response.raw === "object") {
|
|
5591
|
-
return response.raw;
|
|
5592
|
-
}
|
|
5593
|
-
return {
|
|
5594
|
-
code: Number(response.code) || 200,
|
|
5595
|
-
success: response.success,
|
|
5596
|
-
message: response.message,
|
|
5597
|
-
data: response.result,
|
|
5598
|
-
result: response.result
|
|
5599
|
-
};
|
|
5600
|
-
};
|
|
5601
|
-
var unwrapPageResult = (response) => response.result ?? response.data ?? null;
|
|
5602
|
-
var createPageFileRuntimeApi = (sdk) => {
|
|
5603
|
-
const request = async (config) => {
|
|
5604
|
-
const options = toPageRequest(config);
|
|
5605
|
-
if (config.responseType === "blob") {
|
|
5606
|
-
const response = await sdk.transport.download(options);
|
|
5607
|
-
return response.blob;
|
|
5608
|
-
}
|
|
5609
|
-
return toRuntimeResponse(await sdk.transport.request(options));
|
|
5610
|
-
};
|
|
5611
|
-
return createFormRuntimeApi({
|
|
5612
|
-
request,
|
|
5613
|
-
createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => unwrapPageResult(
|
|
5614
|
-
await sdk.createFileAccessTicket(
|
|
5615
|
-
bucketName,
|
|
5616
|
-
objectName,
|
|
5617
|
-
fileName,
|
|
5618
|
-
purpose,
|
|
5619
|
-
options
|
|
5620
|
-
)
|
|
5621
|
-
),
|
|
5622
|
-
createDownloadTicket: async (bucketName, objectName, fileName) => unwrapPageResult(
|
|
5623
|
-
await sdk.request({
|
|
5624
|
-
path: "/file/download-ticket",
|
|
5625
|
-
method: "post",
|
|
5626
|
-
body: { bucketName, objectName, fileName }
|
|
5627
|
-
})
|
|
5628
|
-
)
|
|
5629
|
-
});
|
|
5630
|
-
};
|
|
5631
5681
|
var useFilePreview = ({
|
|
5632
5682
|
items = EMPTY_ITEMS,
|
|
5633
5683
|
appType,
|
|
@@ -5636,7 +5686,7 @@ var useFilePreview = ({
|
|
|
5636
5686
|
requireServerCapability = true
|
|
5637
5687
|
}) => {
|
|
5638
5688
|
const sdk = usePageSdk();
|
|
5639
|
-
const api = (0,
|
|
5689
|
+
const api = (0, import_react11.useMemo)(() => createPageFormRuntimeApi(sdk), [sdk]);
|
|
5640
5690
|
const preview = useFilePreviewController({
|
|
5641
5691
|
items,
|
|
5642
5692
|
api,
|
|
@@ -5728,8 +5778,8 @@ var AttachmentPreviewList = ({
|
|
|
5728
5778
|
};
|
|
5729
5779
|
var PreviewImageThumb = ({ item }) => {
|
|
5730
5780
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
5731
|
-
const [failed, setFailed] = (0,
|
|
5732
|
-
|
|
5781
|
+
const [failed, setFailed] = (0, import_react11.useState)(false);
|
|
5782
|
+
import_react11.default.useEffect(() => setFailed(false), [src]);
|
|
5733
5783
|
return src && !failed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src, alt: item.name || "\u56FE\u7247", onError: () => setFailed(true) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sy-image-state", children: item.name || "\u56FE\u7247" });
|
|
5734
5784
|
};
|
|
5735
5785
|
var ImagePreviewGrid = ({
|
|
@@ -5824,12 +5874,12 @@ var ImagePreviewGrid = ({
|
|
|
5824
5874
|
};
|
|
5825
5875
|
|
|
5826
5876
|
// packages/sdk/src/runtime/react/workflow.tsx
|
|
5827
|
-
var
|
|
5877
|
+
var import_react17 = require("react");
|
|
5828
5878
|
var import_antd10 = require("antd");
|
|
5829
5879
|
var import_icons9 = require("@ant-design/icons");
|
|
5830
5880
|
|
|
5831
5881
|
// packages/sdk/src/components/modules/StickyActionBar.tsx
|
|
5832
|
-
var
|
|
5882
|
+
var import_react12 = require("react");
|
|
5833
5883
|
var import_antd6 = require("antd");
|
|
5834
5884
|
var import_icons5 = require("@ant-design/icons");
|
|
5835
5885
|
|
|
@@ -5865,14 +5915,14 @@ var StickyActionBar = ({
|
|
|
5865
5915
|
position = "sticky",
|
|
5866
5916
|
surface = "default"
|
|
5867
5917
|
}) => {
|
|
5868
|
-
const [isMobile, setIsMobile] = (0,
|
|
5869
|
-
(0,
|
|
5918
|
+
const [isMobile, setIsMobile] = (0, import_react12.useState)(false);
|
|
5919
|
+
(0, import_react12.useEffect)(() => {
|
|
5870
5920
|
const update = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
|
|
5871
5921
|
update();
|
|
5872
5922
|
window.addEventListener("resize", update);
|
|
5873
5923
|
return () => window.removeEventListener("resize", update);
|
|
5874
5924
|
}, []);
|
|
5875
|
-
const visibleActions = (0,
|
|
5925
|
+
const visibleActions = (0, import_react12.useMemo)(
|
|
5876
5926
|
() => actions.filter((action) => action.visible !== false).sort((left, right) => getActionPriority(left) - getActionPriority(right)),
|
|
5877
5927
|
[actions]
|
|
5878
5928
|
);
|
|
@@ -5941,7 +5991,7 @@ var StickyActionBar = ({
|
|
|
5941
5991
|
};
|
|
5942
5992
|
|
|
5943
5993
|
// packages/sdk/src/components/modules/ApprovalTimeline.tsx
|
|
5944
|
-
var
|
|
5994
|
+
var import_react13 = require("react");
|
|
5945
5995
|
var import_icons6 = require("@ant-design/icons");
|
|
5946
5996
|
|
|
5947
5997
|
// packages/sdk/src/components/core/constants.ts
|
|
@@ -6105,8 +6155,8 @@ var ApprovalTimeline = ({
|
|
|
6105
6155
|
compactMode = false,
|
|
6106
6156
|
showApproverInfo = true
|
|
6107
6157
|
}) => {
|
|
6108
|
-
const taskList = (0,
|
|
6109
|
-
const groups = (0,
|
|
6158
|
+
const taskList = (0, import_react13.useMemo)(() => Array.isArray(tasks) ? tasks : [], [tasks]);
|
|
6159
|
+
const groups = (0, import_react13.useMemo)(() => groupTasks(taskList), [taskList]);
|
|
6110
6160
|
if (taskList.length === 0) {
|
|
6111
6161
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6112
6162
|
"div",
|
|
@@ -6252,7 +6302,7 @@ var ProcessPreview = ({
|
|
|
6252
6302
|
};
|
|
6253
6303
|
|
|
6254
6304
|
// packages/sdk/src/components/modules/InitiatorApproverSelector.tsx
|
|
6255
|
-
var
|
|
6305
|
+
var import_react16 = require("react");
|
|
6256
6306
|
var import_antd9 = require("antd");
|
|
6257
6307
|
|
|
6258
6308
|
// packages/sdk/src/components/core/processApi.ts
|
|
@@ -6616,13 +6666,13 @@ async function getViewPermission(request, params) {
|
|
|
6616
6666
|
}
|
|
6617
6667
|
|
|
6618
6668
|
// packages/sdk/src/components/fields/shared/UserPicker.tsx
|
|
6619
|
-
var
|
|
6669
|
+
var import_react15 = require("react");
|
|
6620
6670
|
var import_antd8 = require("antd");
|
|
6621
6671
|
var import_icons8 = require("@ant-design/icons");
|
|
6622
6672
|
var MobileAntd = __toESM(require("antd-mobile"));
|
|
6623
6673
|
|
|
6624
6674
|
// packages/sdk/src/components/fields/shared/useLazyDepartmentTree.ts
|
|
6625
|
-
var
|
|
6675
|
+
var import_react14 = require("react");
|
|
6626
6676
|
var toLazyNode = (node) => {
|
|
6627
6677
|
const normalized = normalizeDepartmentNode(node);
|
|
6628
6678
|
const id = getDepartmentId(normalized);
|
|
@@ -6672,15 +6722,15 @@ function buildIndexes(nodes) {
|
|
|
6672
6722
|
return { nodeMap, parentMap, flatNodes };
|
|
6673
6723
|
}
|
|
6674
6724
|
function useLazyDepartmentTree(api, configuredTreeData) {
|
|
6675
|
-
const [treeData, setTreeDataState] = (0,
|
|
6725
|
+
const [treeData, setTreeDataState] = (0, import_react14.useState)(
|
|
6676
6726
|
() => (configuredTreeData || []).map(toLazyNode)
|
|
6677
6727
|
);
|
|
6678
|
-
const [treeLoading, setTreeLoading] = (0,
|
|
6679
|
-
const treeDataRef = (0,
|
|
6680
|
-
const rootsLoadedRef = (0,
|
|
6681
|
-
const rootPromiseRef = (0,
|
|
6682
|
-
const childPromiseRef = (0,
|
|
6683
|
-
const setTreeData = (0,
|
|
6728
|
+
const [treeLoading, setTreeLoading] = (0, import_react14.useState)(false);
|
|
6729
|
+
const treeDataRef = (0, import_react14.useRef)(treeData);
|
|
6730
|
+
const rootsLoadedRef = (0, import_react14.useRef)(Boolean(configuredTreeData?.length));
|
|
6731
|
+
const rootPromiseRef = (0, import_react14.useRef)(null);
|
|
6732
|
+
const childPromiseRef = (0, import_react14.useRef)({});
|
|
6733
|
+
const setTreeData = (0, import_react14.useCallback)(
|
|
6684
6734
|
(next) => {
|
|
6685
6735
|
const resolved = typeof next === "function" ? next(treeDataRef.current) : next;
|
|
6686
6736
|
treeDataRef.current = resolved;
|
|
@@ -6689,13 +6739,13 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6689
6739
|
},
|
|
6690
6740
|
[]
|
|
6691
6741
|
);
|
|
6692
|
-
(0,
|
|
6742
|
+
(0, import_react14.useEffect)(() => {
|
|
6693
6743
|
if (!configuredTreeData) return;
|
|
6694
6744
|
const next = configuredTreeData.map(toLazyNode);
|
|
6695
6745
|
rootsLoadedRef.current = next.length > 0;
|
|
6696
6746
|
setTreeData(next);
|
|
6697
6747
|
}, [configuredTreeData, setTreeData]);
|
|
6698
|
-
const loadRootDepartments = (0,
|
|
6748
|
+
const loadRootDepartments = (0, import_react14.useCallback)(async () => {
|
|
6699
6749
|
if (rootsLoadedRef.current) return treeDataRef.current;
|
|
6700
6750
|
if (rootPromiseRef.current) return rootPromiseRef.current;
|
|
6701
6751
|
setTreeLoading(true);
|
|
@@ -6711,7 +6761,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6711
6761
|
rootPromiseRef.current = promise;
|
|
6712
6762
|
return promise;
|
|
6713
6763
|
}, [api, setTreeData]);
|
|
6714
|
-
const loadChildren = (0,
|
|
6764
|
+
const loadChildren = (0, import_react14.useCallback)(
|
|
6715
6765
|
async (parentId) => {
|
|
6716
6766
|
const id = String(parentId || "");
|
|
6717
6767
|
if (!id) return [];
|
|
@@ -6732,8 +6782,8 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6732
6782
|
},
|
|
6733
6783
|
[api, setTreeData]
|
|
6734
6784
|
);
|
|
6735
|
-
const indexes = (0,
|
|
6736
|
-
(0,
|
|
6785
|
+
const indexes = (0, import_react14.useMemo)(() => buildIndexes(treeData), [treeData]);
|
|
6786
|
+
(0, import_react14.useEffect)(() => {
|
|
6737
6787
|
void loadRootDepartments();
|
|
6738
6788
|
}, [loadRootDepartments]);
|
|
6739
6789
|
return {
|
|
@@ -6778,24 +6828,24 @@ function UserPickerPanel({
|
|
|
6778
6828
|
flatNodes,
|
|
6779
6829
|
loadChildren
|
|
6780
6830
|
} = useLazyDepartmentTree(api, treeData);
|
|
6781
|
-
const [departmentKeyword, setDepartmentKeyword] = (0,
|
|
6782
|
-
const [memberKeyword, setMemberKeyword] = (0,
|
|
6783
|
-
const [mobileKeyword, setMobileKeyword] = (0,
|
|
6784
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
6785
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
6786
|
-
const [members, setMembers] = (0,
|
|
6787
|
-
const [memberPage, setMemberPage] = (0,
|
|
6788
|
-
const [memberPageSize, setMemberPageSize] = (0,
|
|
6789
|
-
const [memberTotal, setMemberTotal] = (0,
|
|
6790
|
-
const [memberReloadKey, setMemberReloadKey] = (0,
|
|
6791
|
-
const [loading, setLoading] = (0,
|
|
6792
|
-
const [selected, setSelected] = (0,
|
|
6831
|
+
const [departmentKeyword, setDepartmentKeyword] = (0, import_react15.useState)("");
|
|
6832
|
+
const [memberKeyword, setMemberKeyword] = (0, import_react15.useState)("");
|
|
6833
|
+
const [mobileKeyword, setMobileKeyword] = (0, import_react15.useState)("");
|
|
6834
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react15.useState)("");
|
|
6835
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react15.useState)([]);
|
|
6836
|
+
const [members, setMembers] = (0, import_react15.useState)(() => normalizeUsers(dataSource));
|
|
6837
|
+
const [memberPage, setMemberPage] = (0, import_react15.useState)(1);
|
|
6838
|
+
const [memberPageSize, setMemberPageSize] = (0, import_react15.useState)(DEFAULT_MEMBER_PAGE_SIZE);
|
|
6839
|
+
const [memberTotal, setMemberTotal] = (0, import_react15.useState)(() => normalizeUsers(dataSource).length);
|
|
6840
|
+
const [memberReloadKey, setMemberReloadKey] = (0, import_react15.useState)(0);
|
|
6841
|
+
const [loading, setLoading] = (0, import_react15.useState)(false);
|
|
6842
|
+
const [selected, setSelected] = (0, import_react15.useState)(() => normalizeUsers(value));
|
|
6793
6843
|
const selectedIds = selected.map(getUserId);
|
|
6794
6844
|
const MobileSearchBar = getMobileComponent("SearchBar");
|
|
6795
6845
|
const activeMemberKeyword = (mobile ? mobileKeyword : memberKeyword).trim();
|
|
6796
|
-
const staticUsers = (0,
|
|
6846
|
+
const staticUsers = (0, import_react15.useMemo)(() => normalizeUsers(dataSource), [dataSource]);
|
|
6797
6847
|
const hasStaticUserSource = staticUsers.length > 0;
|
|
6798
|
-
(0,
|
|
6848
|
+
(0, import_react15.useEffect)(() => {
|
|
6799
6849
|
if (mobile) return;
|
|
6800
6850
|
if (currentDeptId || deptTreeData.length === 0) return;
|
|
6801
6851
|
setExpandedKeys(deptTreeData.map((node) => getDepartmentId(node)));
|
|
@@ -6803,17 +6853,17 @@ function UserPickerPanel({
|
|
|
6803
6853
|
setCurrentDeptId(getDepartmentId(deptTreeData[0]));
|
|
6804
6854
|
}
|
|
6805
6855
|
}, [currentDeptId, deptTreeData, loadAllWhenNoDepartment, mobile]);
|
|
6806
|
-
(0,
|
|
6856
|
+
(0, import_react15.useEffect)(() => {
|
|
6807
6857
|
setMemberPage(1);
|
|
6808
6858
|
}, [activeMemberKeyword, currentDeptId, dataSource, mobile]);
|
|
6809
|
-
const handleDepartmentSelect = (0,
|
|
6859
|
+
const handleDepartmentSelect = (0, import_react15.useCallback)((deptId) => {
|
|
6810
6860
|
const nextDeptId = String(deptId || "");
|
|
6811
6861
|
setCurrentDeptId(nextDeptId);
|
|
6812
6862
|
setMemberKeyword("");
|
|
6813
6863
|
setMemberPage(1);
|
|
6814
6864
|
setMemberReloadKey((current) => current + 1);
|
|
6815
6865
|
}, []);
|
|
6816
|
-
(0,
|
|
6866
|
+
(0, import_react15.useEffect)(() => {
|
|
6817
6867
|
let active = true;
|
|
6818
6868
|
const keyword = activeMemberKeyword;
|
|
6819
6869
|
if (hasStaticUserSource) {
|
|
@@ -6886,7 +6936,7 @@ function UserPickerPanel({
|
|
|
6886
6936
|
memberReloadKey,
|
|
6887
6937
|
staticUsers
|
|
6888
6938
|
]);
|
|
6889
|
-
const currentPath = (0,
|
|
6939
|
+
const currentPath = (0, import_react15.useMemo)(() => {
|
|
6890
6940
|
if (!currentDeptId) return [];
|
|
6891
6941
|
const path = [];
|
|
6892
6942
|
let cursor = currentDeptId;
|
|
@@ -6898,7 +6948,7 @@ function UserPickerPanel({
|
|
|
6898
6948
|
}
|
|
6899
6949
|
return path;
|
|
6900
6950
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
6901
|
-
const mobileDepartments = (0,
|
|
6951
|
+
const mobileDepartments = (0, import_react15.useMemo)(() => {
|
|
6902
6952
|
const keyword = mobileKeyword.trim().toLowerCase();
|
|
6903
6953
|
if (keyword) {
|
|
6904
6954
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(keyword)).map((item) => item.node);
|
|
@@ -7162,19 +7212,19 @@ var RequirementSelect = ({
|
|
|
7162
7212
|
selectedUsers,
|
|
7163
7213
|
onChange
|
|
7164
7214
|
}) => {
|
|
7165
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
7166
|
-
const initialCandidates = (0,
|
|
7215
|
+
const [pickerOpen, setPickerOpen] = (0, import_react16.useState)(false);
|
|
7216
|
+
const initialCandidates = (0, import_react16.useMemo)(
|
|
7167
7217
|
() => (requirement.candidateUsers || []).map(normalizeCandidate).filter(Boolean),
|
|
7168
7218
|
[requirement.candidateUsers]
|
|
7169
7219
|
);
|
|
7170
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
7171
|
-
const [loading, setLoading] = (0,
|
|
7172
|
-
(0,
|
|
7220
|
+
const [optionsSource, setOptionsSource] = (0, import_react16.useState)(initialCandidates);
|
|
7221
|
+
const [loading, setLoading] = (0, import_react16.useState)(false);
|
|
7222
|
+
(0, import_react16.useEffect)(() => {
|
|
7173
7223
|
setOptionsSource(
|
|
7174
7224
|
(current) => mergeUsers(initialCandidates, mergeUsers(current, selectedUsers))
|
|
7175
7225
|
);
|
|
7176
7226
|
}, [initialCandidates, selectedUsers]);
|
|
7177
|
-
const loadCandidates = (0,
|
|
7227
|
+
const loadCandidates = (0, import_react16.useCallback)(
|
|
7178
7228
|
async (keyword) => {
|
|
7179
7229
|
setLoading(true);
|
|
7180
7230
|
try {
|
|
@@ -7212,12 +7262,12 @@ var RequirementSelect = ({
|
|
|
7212
7262
|
},
|
|
7213
7263
|
[api, appType, formUuid, initialCandidates.length, requirement.nodeId, requirement.scope]
|
|
7214
7264
|
);
|
|
7215
|
-
(0,
|
|
7265
|
+
(0, import_react16.useEffect)(() => {
|
|
7216
7266
|
if (requirement.scope !== "all" && open && formUuid && appType && requirement.nodeId) {
|
|
7217
7267
|
void loadCandidates();
|
|
7218
7268
|
}
|
|
7219
7269
|
}, [appType, formUuid, loadCandidates, open, requirement.nodeId, requirement.scope]);
|
|
7220
|
-
const options = (0,
|
|
7270
|
+
const options = (0, import_react16.useMemo)(
|
|
7221
7271
|
() => optionsSource.map((user) => ({
|
|
7222
7272
|
value: user.id,
|
|
7223
7273
|
label: getUserLabel(user)
|
|
@@ -7302,9 +7352,9 @@ var InitiatorApproverSelector = ({
|
|
|
7302
7352
|
onOk,
|
|
7303
7353
|
onCancel
|
|
7304
7354
|
}) => {
|
|
7305
|
-
const [selected, setSelected] = (0,
|
|
7306
|
-
const wasOpenRef = (0,
|
|
7307
|
-
(0,
|
|
7355
|
+
const [selected, setSelected] = (0, import_react16.useState)({});
|
|
7356
|
+
const wasOpenRef = (0, import_react16.useRef)(false);
|
|
7357
|
+
(0, import_react16.useEffect)(() => {
|
|
7308
7358
|
if (open && !wasOpenRef.current) {
|
|
7309
7359
|
setSelected(value || EMPTY_SELECTED_MAP);
|
|
7310
7360
|
}
|
|
@@ -7362,20 +7412,20 @@ var normalizeCapabilities = (value) => {
|
|
|
7362
7412
|
function useProcessCapabilities(options) {
|
|
7363
7413
|
const { enabled = true, refreshKey, onError, ...params } = options;
|
|
7364
7414
|
const sdk = usePageSdk();
|
|
7365
|
-
const [capabilities, setCapabilities] = (0,
|
|
7415
|
+
const [capabilities, setCapabilities] = (0, import_react17.useState)(
|
|
7366
7416
|
null
|
|
7367
7417
|
);
|
|
7368
|
-
const [loading, setLoading] = (0,
|
|
7369
|
-
const [error, setError] = (0,
|
|
7370
|
-
const mountedRef = (0,
|
|
7418
|
+
const [loading, setLoading] = (0, import_react17.useState)(false);
|
|
7419
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
7420
|
+
const mountedRef = (0, import_react17.useRef)(true);
|
|
7371
7421
|
const paramsKey = JSON.stringify({ ...params, refreshKey });
|
|
7372
|
-
(0,
|
|
7422
|
+
(0, import_react17.useEffect)(() => {
|
|
7373
7423
|
mountedRef.current = true;
|
|
7374
7424
|
return () => {
|
|
7375
7425
|
mountedRef.current = false;
|
|
7376
7426
|
};
|
|
7377
7427
|
}, []);
|
|
7378
|
-
const refresh = (0,
|
|
7428
|
+
const refresh = (0, import_react17.useCallback)(async () => {
|
|
7379
7429
|
if (!enabled) return capabilities;
|
|
7380
7430
|
setLoading(true);
|
|
7381
7431
|
setError(null);
|
|
@@ -7401,7 +7451,7 @@ function useProcessCapabilities(options) {
|
|
|
7401
7451
|
}
|
|
7402
7452
|
}
|
|
7403
7453
|
}, [capabilities, enabled, onError, paramsKey, sdk]);
|
|
7404
|
-
(0,
|
|
7454
|
+
(0, import_react17.useEffect)(() => {
|
|
7405
7455
|
if (!enabled) return;
|
|
7406
7456
|
void refresh();
|
|
7407
7457
|
}, [enabled, paramsKey, refresh]);
|
|
@@ -7426,8 +7476,8 @@ var requireValue = (value, message7) => {
|
|
|
7426
7476
|
function useProcessActions(options) {
|
|
7427
7477
|
const { capabilities, formUuid, appType, getFormValues, onActionComplete } = options;
|
|
7428
7478
|
const sdk = usePageSdk();
|
|
7429
|
-
const [loadingAction, setLoadingAction] = (0,
|
|
7430
|
-
const buildUpdateFormDataJson = (0,
|
|
7479
|
+
const [loadingAction, setLoadingAction] = (0, import_react17.useState)(null);
|
|
7480
|
+
const buildUpdateFormDataJson = (0, import_react17.useCallback)(
|
|
7431
7481
|
(input) => {
|
|
7432
7482
|
if (input?.updateFormDataJson !== void 0) return input.updateFormDataJson;
|
|
7433
7483
|
const values = getFormValues?.();
|
|
@@ -7435,7 +7485,7 @@ function useProcessActions(options) {
|
|
|
7435
7485
|
},
|
|
7436
7486
|
[getFormValues]
|
|
7437
7487
|
);
|
|
7438
|
-
const executeOperation = (0,
|
|
7488
|
+
const executeOperation = (0, import_react17.useCallback)(
|
|
7439
7489
|
async (operation, input = {}) => {
|
|
7440
7490
|
if (!operation.enabled) return false;
|
|
7441
7491
|
setLoadingAction(operation.key);
|
|
@@ -7545,7 +7595,7 @@ function useProcessActions(options) {
|
|
|
7545
7595
|
sdk
|
|
7546
7596
|
]
|
|
7547
7597
|
);
|
|
7548
|
-
const execute = (0,
|
|
7598
|
+
const execute = (0, import_react17.useCallback)(
|
|
7549
7599
|
async (action, input) => {
|
|
7550
7600
|
const operation = (capabilities?.operations || []).find(
|
|
7551
7601
|
(item) => item.key === action
|
|
@@ -7620,7 +7670,7 @@ var ProcessActionBar = ({
|
|
|
7620
7670
|
position = "sticky"
|
|
7621
7671
|
}) => {
|
|
7622
7672
|
const [form] = import_antd10.Form.useForm();
|
|
7623
|
-
const [activeOperation, setActiveOperation] = (0,
|
|
7673
|
+
const [activeOperation, setActiveOperation] = (0, import_react17.useState)(null);
|
|
7624
7674
|
const autoCapabilities = useProcessCapabilities({
|
|
7625
7675
|
...capabilityParams || {},
|
|
7626
7676
|
enabled: Boolean(capabilityParams) && capabilityParams?.enabled !== false
|
|
@@ -7655,7 +7705,7 @@ var ProcessActionBar = ({
|
|
|
7655
7705
|
}
|
|
7656
7706
|
void actions.executeOperation(operation);
|
|
7657
7707
|
};
|
|
7658
|
-
const actionConfigs = (0,
|
|
7708
|
+
const actionConfigs = (0, import_react17.useMemo)(
|
|
7659
7709
|
() => operations.map((operation) => ({
|
|
7660
7710
|
key: operation.key,
|
|
7661
7711
|
label: operation.label || operation.key,
|
|
@@ -7769,7 +7819,7 @@ var ProcessTimeline = ({
|
|
|
7769
7819
|
var ProcessPreviewPanel = ProcessPreview;
|
|
7770
7820
|
|
|
7771
7821
|
// packages/sdk/src/runtime/react/openxiangdaProvider.tsx
|
|
7772
|
-
var
|
|
7822
|
+
var import_react19 = require("react");
|
|
7773
7823
|
|
|
7774
7824
|
// packages/sdk/src/runtime/host/browserHost.ts
|
|
7775
7825
|
var NAMESPACE_ROOT_CLASS2 = "sy-app-workspace";
|
|
@@ -8158,13 +8208,13 @@ var mountBrowserPageRuntime = async (options) => {
|
|
|
8158
8208
|
};
|
|
8159
8209
|
|
|
8160
8210
|
// packages/sdk/src/runtime/react/auth.tsx
|
|
8161
|
-
var
|
|
8211
|
+
var import_react18 = require("react");
|
|
8162
8212
|
var import_antd11 = require("antd");
|
|
8163
8213
|
var import_icons10 = require("@ant-design/icons");
|
|
8164
8214
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
8165
8215
|
var useAuth = (options = {}) => {
|
|
8166
8216
|
const runtime = useOpenXiangda();
|
|
8167
|
-
const client = (0,
|
|
8217
|
+
const client = (0, import_react18.useMemo)(
|
|
8168
8218
|
() => createAuthClient({
|
|
8169
8219
|
appType: options.appType || runtime.appType,
|
|
8170
8220
|
servicePrefix: options.servicePrefix || runtime.servicePrefix,
|
|
@@ -8179,7 +8229,7 @@ var useAuth = (options = {}) => {
|
|
|
8179
8229
|
runtime.servicePrefix
|
|
8180
8230
|
]
|
|
8181
8231
|
);
|
|
8182
|
-
return (0,
|
|
8232
|
+
return (0, import_react18.useMemo)(
|
|
8183
8233
|
() => ({
|
|
8184
8234
|
client,
|
|
8185
8235
|
getMethods: client.getMethods,
|
|
@@ -8199,12 +8249,12 @@ var useAuth = (options = {}) => {
|
|
|
8199
8249
|
};
|
|
8200
8250
|
var useLoginMethods = (options = {}) => {
|
|
8201
8251
|
const auth = useAuth(options);
|
|
8202
|
-
const [state, setState] = (0,
|
|
8252
|
+
const [state, setState] = (0, import_react18.useState)({
|
|
8203
8253
|
data: null,
|
|
8204
8254
|
loading: true,
|
|
8205
8255
|
error: null
|
|
8206
8256
|
});
|
|
8207
|
-
const reload = (0,
|
|
8257
|
+
const reload = (0, import_react18.useCallback)(async () => {
|
|
8208
8258
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
8209
8259
|
try {
|
|
8210
8260
|
const data = await auth.getMethods();
|
|
@@ -8217,7 +8267,7 @@ var useLoginMethods = (options = {}) => {
|
|
|
8217
8267
|
});
|
|
8218
8268
|
}
|
|
8219
8269
|
}, [auth]);
|
|
8220
|
-
(0,
|
|
8270
|
+
(0, import_react18.useEffect)(() => {
|
|
8221
8271
|
let disposed = false;
|
|
8222
8272
|
const run = async () => {
|
|
8223
8273
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
@@ -8261,17 +8311,17 @@ var LoginPage = ({
|
|
|
8261
8311
|
const methodsState = useLoginMethods(authOptions);
|
|
8262
8312
|
const [passwordForm] = import_antd11.Form.useForm();
|
|
8263
8313
|
const [phoneForm] = import_antd11.Form.useForm();
|
|
8264
|
-
const [activeMethod, setActiveMethod] = (0,
|
|
8314
|
+
const [activeMethod, setActiveMethod] = (0, import_react18.useState)(
|
|
8265
8315
|
defaultMethod || "password"
|
|
8266
8316
|
);
|
|
8267
|
-
const [phonePurpose, setPhonePurpose] = (0,
|
|
8317
|
+
const [phonePurpose, setPhonePurpose] = (0, import_react18.useState)(
|
|
8268
8318
|
"login"
|
|
8269
8319
|
);
|
|
8270
|
-
const [phoneChallengeId, setPhoneChallengeId] = (0,
|
|
8271
|
-
const [passwordChallenge, setPasswordChallenge] = (0,
|
|
8272
|
-
const [submitting, setSubmitting] = (0,
|
|
8273
|
-
const [sendingCode, setSendingCode] = (0,
|
|
8274
|
-
const [error, setError] = (0,
|
|
8320
|
+
const [phoneChallengeId, setPhoneChallengeId] = (0, import_react18.useState)("");
|
|
8321
|
+
const [passwordChallenge, setPasswordChallenge] = (0, import_react18.useState)(null);
|
|
8322
|
+
const [submitting, setSubmitting] = (0, import_react18.useState)(false);
|
|
8323
|
+
const [sendingCode, setSendingCode] = (0, import_react18.useState)(false);
|
|
8324
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
8275
8325
|
const methods = methodsState.methods.filter((method) => method.enabled !== false);
|
|
8276
8326
|
const passwordMethod = findMethod(methods, "password");
|
|
8277
8327
|
const phoneMethod = findMethod(methods, "phone_code");
|
|
@@ -8279,7 +8329,7 @@ var LoginPage = ({
|
|
|
8279
8329
|
const ssoMethod = findMethod(methods, "sso");
|
|
8280
8330
|
const guestMethod = findMethod(methods, "guest");
|
|
8281
8331
|
const allowRegister = methodsState.data?.registration?.mode !== "reject";
|
|
8282
|
-
const tabItems = (0,
|
|
8332
|
+
const tabItems = (0, import_react18.useMemo)(() => {
|
|
8283
8333
|
const items = [];
|
|
8284
8334
|
if (passwordMethod) {
|
|
8285
8335
|
items.push({
|
|
@@ -8398,7 +8448,7 @@ var LoginPage = ({
|
|
|
8398
8448
|
sendingCode,
|
|
8399
8449
|
submitting
|
|
8400
8450
|
]);
|
|
8401
|
-
(0,
|
|
8451
|
+
(0, import_react18.useEffect)(() => {
|
|
8402
8452
|
const firstKey = tabItems[0]?.key;
|
|
8403
8453
|
if (firstKey && !tabItems.some((item) => item.key === activeMethod)) {
|
|
8404
8454
|
setActiveMethod(firstKey);
|
|
@@ -8738,26 +8788,26 @@ var RuntimeHttpError = class extends Error {
|
|
|
8738
8788
|
this.payload = snapshot.payload;
|
|
8739
8789
|
}
|
|
8740
8790
|
};
|
|
8741
|
-
var OpenXiangdaRuntimeContext = (0,
|
|
8791
|
+
var OpenXiangdaRuntimeContext = (0, import_react19.createContext)(null);
|
|
8742
8792
|
var OpenXiangdaProvider = ({
|
|
8743
8793
|
appType,
|
|
8744
8794
|
servicePrefix = "/service",
|
|
8745
8795
|
fetchImpl,
|
|
8746
8796
|
children
|
|
8747
8797
|
}) => {
|
|
8748
|
-
const resolvedFetch = (0,
|
|
8749
|
-
const resolvedAppType = (0,
|
|
8798
|
+
const resolvedFetch = (0, import_react19.useMemo)(() => createBoundFetch(fetchImpl), [fetchImpl]);
|
|
8799
|
+
const resolvedAppType = (0, import_react19.useMemo)(
|
|
8750
8800
|
() => appType || resolveAppTypeFromLocation(),
|
|
8751
8801
|
[appType]
|
|
8752
8802
|
);
|
|
8753
|
-
const [, setAccessTokenState] = (0,
|
|
8754
|
-
const [authState, setAuthState] = (0,
|
|
8803
|
+
const [, setAccessTokenState] = (0, import_react19.useState)(null);
|
|
8804
|
+
const [authState, setAuthState] = (0, import_react19.useState)({
|
|
8755
8805
|
status: "unknown",
|
|
8756
8806
|
error: null
|
|
8757
8807
|
});
|
|
8758
|
-
const accessTokenRef = (0,
|
|
8759
|
-
const refreshRequestRef = (0,
|
|
8760
|
-
const applyAccessToken = (0,
|
|
8808
|
+
const accessTokenRef = (0, import_react19.useRef)(null);
|
|
8809
|
+
const refreshRequestRef = (0, import_react19.useRef)(null);
|
|
8810
|
+
const applyAccessToken = (0, import_react19.useCallback)(
|
|
8761
8811
|
(nextAccessToken, options = {}) => {
|
|
8762
8812
|
if (!nextAccessToken && options.clearIfToken && accessTokenRef.current?.token !== options.clearIfToken) {
|
|
8763
8813
|
return accessTokenRef.current;
|
|
@@ -8775,7 +8825,7 @@ var OpenXiangdaProvider = ({
|
|
|
8775
8825
|
},
|
|
8776
8826
|
[]
|
|
8777
8827
|
);
|
|
8778
|
-
const setAccessToken = (0,
|
|
8828
|
+
const setAccessToken = (0, import_react19.useCallback)(
|
|
8779
8829
|
(nextAccessToken, options = {}) => {
|
|
8780
8830
|
const previousState = accessTokenRef.current;
|
|
8781
8831
|
const nextState = applyAccessToken(nextAccessToken, options);
|
|
@@ -8791,7 +8841,7 @@ var OpenXiangdaProvider = ({
|
|
|
8791
8841
|
},
|
|
8792
8842
|
[applyAccessToken]
|
|
8793
8843
|
);
|
|
8794
|
-
const markUnauthenticated = (0,
|
|
8844
|
+
const markUnauthenticated = (0, import_react19.useCallback)(
|
|
8795
8845
|
(error) => {
|
|
8796
8846
|
const runtimeError = normalizeRuntimeError(error);
|
|
8797
8847
|
applyAccessToken(null);
|
|
@@ -8799,7 +8849,7 @@ var OpenXiangdaProvider = ({
|
|
|
8799
8849
|
},
|
|
8800
8850
|
[applyAccessToken]
|
|
8801
8851
|
);
|
|
8802
|
-
const refreshAccessToken = (0,
|
|
8852
|
+
const refreshAccessToken = (0, import_react19.useCallback)(async () => {
|
|
8803
8853
|
if (!resolvedAppType) return null;
|
|
8804
8854
|
if (!refreshRequestRef.current) {
|
|
8805
8855
|
setAuthState((prev) => ({ ...prev, status: "refreshing", error: null }));
|
|
@@ -8860,7 +8910,7 @@ var OpenXiangdaProvider = ({
|
|
|
8860
8910
|
}
|
|
8861
8911
|
return refreshRequestRef.current;
|
|
8862
8912
|
}, [applyAccessToken, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
8863
|
-
const authorizedFetch = (0,
|
|
8913
|
+
const authorizedFetch = (0, import_react19.useMemo)(
|
|
8864
8914
|
() => createAuthorizedFetch({
|
|
8865
8915
|
appType: resolvedAppType,
|
|
8866
8916
|
baseFetch: resolvedFetch,
|
|
@@ -8870,18 +8920,18 @@ var OpenXiangdaProvider = ({
|
|
|
8870
8920
|
}),
|
|
8871
8921
|
[markUnauthenticated, refreshAccessToken, resolvedAppType, resolvedFetch]
|
|
8872
8922
|
);
|
|
8873
|
-
const getAuthHeaders = (0,
|
|
8923
|
+
const getAuthHeaders = (0, import_react19.useCallback)(() => {
|
|
8874
8924
|
const state2 = accessTokenRef.current;
|
|
8875
8925
|
if (!state2) return {};
|
|
8876
8926
|
const token = resolveAccessTokenForCurrentRoute(state2);
|
|
8877
8927
|
return token ? { authorization: `Bearer ${token}` } : {};
|
|
8878
8928
|
}, []);
|
|
8879
|
-
const [state, setState] = (0,
|
|
8929
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
8880
8930
|
data: null,
|
|
8881
8931
|
loading: true,
|
|
8882
8932
|
error: null
|
|
8883
8933
|
});
|
|
8884
|
-
const reload = (0,
|
|
8934
|
+
const reload = (0, import_react19.useCallback)(async (options = {}) => {
|
|
8885
8935
|
if (!resolvedAppType) {
|
|
8886
8936
|
setState({
|
|
8887
8937
|
data: null,
|
|
@@ -8945,10 +8995,10 @@ var OpenXiangdaProvider = ({
|
|
|
8945
8995
|
}
|
|
8946
8996
|
}
|
|
8947
8997
|
}, [authorizedFetch, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
8948
|
-
(0,
|
|
8998
|
+
(0, import_react19.useEffect)(() => {
|
|
8949
8999
|
void reload();
|
|
8950
9000
|
}, [reload]);
|
|
8951
|
-
const value = (0,
|
|
9001
|
+
const value = (0, import_react19.useMemo)(
|
|
8952
9002
|
() => ({
|
|
8953
9003
|
...state,
|
|
8954
9004
|
appType: resolvedAppType,
|
|
@@ -8974,7 +9024,7 @@ var OpenXiangdaProvider = ({
|
|
|
8974
9024
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(OpenXiangdaRuntimeContext.Provider, { value, children });
|
|
8975
9025
|
};
|
|
8976
9026
|
var useOpenXiangda = () => {
|
|
8977
|
-
const context = (0,
|
|
9027
|
+
const context = (0, import_react19.useContext)(OpenXiangdaRuntimeContext);
|
|
8978
9028
|
if (!context) {
|
|
8979
9029
|
throw new Error("useOpenXiangda must be used inside OpenXiangdaProvider");
|
|
8980
9030
|
}
|
|
@@ -8991,7 +9041,7 @@ var OpenXiangdaPageProvider = ({
|
|
|
8991
9041
|
navigation
|
|
8992
9042
|
}) => {
|
|
8993
9043
|
const runtime = useOpenXiangda();
|
|
8994
|
-
const context = (0,
|
|
9044
|
+
const context = (0, import_react19.useMemo)(() => {
|
|
8995
9045
|
const bootstrap = runtime.data;
|
|
8996
9046
|
const app = toRuntimeRecord(bootstrap?.app);
|
|
8997
9047
|
const user = toRuntimeRecord(bootstrap?.user);
|
|
@@ -9089,12 +9139,12 @@ var usePermission = () => {
|
|
|
9089
9139
|
};
|
|
9090
9140
|
var useCanAccessRoute = (input) => {
|
|
9091
9141
|
const runtime = useOpenXiangda();
|
|
9092
|
-
const [state, setState] = (0,
|
|
9142
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
9093
9143
|
data: null,
|
|
9094
9144
|
loading: true,
|
|
9095
9145
|
error: null
|
|
9096
9146
|
});
|
|
9097
|
-
(0,
|
|
9147
|
+
(0, import_react19.useEffect)(() => {
|
|
9098
9148
|
let disposed = false;
|
|
9099
9149
|
const check = async () => {
|
|
9100
9150
|
const permissions = runtime.data?.permissions;
|
|
@@ -9225,7 +9275,7 @@ var PermissionBoundary = ({
|
|
|
9225
9275
|
};
|
|
9226
9276
|
var useRuntimeAuth = () => {
|
|
9227
9277
|
const runtime = useOpenXiangda();
|
|
9228
|
-
const resolveLoginUrl2 = (0,
|
|
9278
|
+
const resolveLoginUrl2 = (0, import_react19.useCallback)(
|
|
9229
9279
|
async (options = {}) => {
|
|
9230
9280
|
const redirectUri = options.redirectUri || getCurrentHref4();
|
|
9231
9281
|
const domain = options.domain || getCurrentHostname2();
|
|
@@ -9272,7 +9322,7 @@ var useRuntimeAuth = () => {
|
|
|
9272
9322
|
},
|
|
9273
9323
|
[runtime.baseFetchImpl, runtime.data?.app, runtime.servicePrefix]
|
|
9274
9324
|
);
|
|
9275
|
-
const redirectToLogin = (0,
|
|
9325
|
+
const redirectToLogin = (0, import_react19.useCallback)(
|
|
9276
9326
|
async (options = {}) => {
|
|
9277
9327
|
const loginUrl = await resolveLoginUrl2(options);
|
|
9278
9328
|
if (typeof window !== "undefined") {
|
|
@@ -9286,7 +9336,7 @@ var useRuntimeAuth = () => {
|
|
|
9286
9336
|
},
|
|
9287
9337
|
[resolveLoginUrl2]
|
|
9288
9338
|
);
|
|
9289
|
-
const logout = (0,
|
|
9339
|
+
const logout = (0, import_react19.useCallback)(async () => {
|
|
9290
9340
|
const response = await runtime.baseFetchImpl(
|
|
9291
9341
|
buildServiceUrl3(runtime.servicePrefix, "/api/auth/logout"),
|
|
9292
9342
|
{
|
|
@@ -9306,7 +9356,7 @@ var useRuntimeAuth = () => {
|
|
|
9306
9356
|
runtime.setAccessToken(null);
|
|
9307
9357
|
return payload;
|
|
9308
9358
|
}, [runtime.baseFetchImpl, runtime.servicePrefix, runtime.setAccessToken]);
|
|
9309
|
-
const logoutAndRedirect = (0,
|
|
9359
|
+
const logoutAndRedirect = (0, import_react19.useCallback)(
|
|
9310
9360
|
async (options = {}) => {
|
|
9311
9361
|
try {
|
|
9312
9362
|
await logout();
|
|
@@ -9317,7 +9367,7 @@ var useRuntimeAuth = () => {
|
|
|
9317
9367
|
},
|
|
9318
9368
|
[logout, redirectToLogin]
|
|
9319
9369
|
);
|
|
9320
|
-
return (0,
|
|
9370
|
+
return (0, import_react19.useMemo)(
|
|
9321
9371
|
() => ({
|
|
9322
9372
|
logout,
|
|
9323
9373
|
logoutAndRedirect,
|
|
@@ -9336,7 +9386,7 @@ var RuntimeAuthGuard = ({
|
|
|
9336
9386
|
}) => {
|
|
9337
9387
|
const runtime = useOpenXiangda();
|
|
9338
9388
|
const auth = useRuntimeAuth();
|
|
9339
|
-
const redirectedRef = (0,
|
|
9389
|
+
const redirectedRef = (0, import_react19.useRef)(false);
|
|
9340
9390
|
const currentPath = getCurrentPathname2();
|
|
9341
9391
|
const excluded = isRuntimeAuthGuardExcluded(
|
|
9342
9392
|
currentPath,
|
|
@@ -9344,7 +9394,7 @@ var RuntimeAuthGuard = ({
|
|
|
9344
9394
|
excludedPaths
|
|
9345
9395
|
);
|
|
9346
9396
|
const shouldRedirect = !disabled && !excluded && !runtime.loading && (runtime.authState.status === "unauthenticated" || runtime.error?.type === "unauthenticated");
|
|
9347
|
-
(0,
|
|
9397
|
+
(0, import_react19.useEffect)(() => {
|
|
9348
9398
|
if (!shouldRedirect || redirectedRef.current) return;
|
|
9349
9399
|
redirectedRef.current = true;
|
|
9350
9400
|
void auth.redirectToLogin({
|
|
@@ -9687,7 +9737,7 @@ var resolveAppTypeFromLocation = () => {
|
|
|
9687
9737
|
};
|
|
9688
9738
|
|
|
9689
9739
|
// packages/sdk/src/runtime/react/publicAccess.tsx
|
|
9690
|
-
var
|
|
9740
|
+
var import_react20 = require("react");
|
|
9691
9741
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
9692
9742
|
var usePublicAccess = (options = {}) => {
|
|
9693
9743
|
const runtime = useOpenXiangda();
|
|
@@ -9705,14 +9755,14 @@ var usePublicAccess = (options = {}) => {
|
|
|
9705
9755
|
autoStart = true,
|
|
9706
9756
|
...sessionInput
|
|
9707
9757
|
} = options;
|
|
9708
|
-
const [session, setSession] = (0,
|
|
9709
|
-
const [error, setError] = (0,
|
|
9710
|
-
const [loading, setLoading] = (0,
|
|
9711
|
-
const activeSessionRef = (0,
|
|
9712
|
-
const mountedRef = (0,
|
|
9758
|
+
const [session, setSession] = (0, import_react20.useState)(null);
|
|
9759
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
9760
|
+
const [loading, setLoading] = (0, import_react20.useState)(Boolean(autoStart));
|
|
9761
|
+
const activeSessionRef = (0, import_react20.useRef)(null);
|
|
9762
|
+
const mountedRef = (0, import_react20.useRef)(true);
|
|
9713
9763
|
const sessionInputKey = JSON.stringify(sessionInput);
|
|
9714
|
-
const stableSessionInput = (0,
|
|
9715
|
-
const client = (0,
|
|
9764
|
+
const stableSessionInput = (0, import_react20.useMemo)(() => sessionInput, [sessionInputKey]);
|
|
9765
|
+
const client = (0, import_react20.useMemo)(
|
|
9716
9766
|
() => createPublicAccessClient({
|
|
9717
9767
|
appType,
|
|
9718
9768
|
servicePrefix,
|
|
@@ -9720,7 +9770,7 @@ var usePublicAccess = (options = {}) => {
|
|
|
9720
9770
|
}),
|
|
9721
9771
|
[appType, fetchImpl, servicePrefix]
|
|
9722
9772
|
);
|
|
9723
|
-
const startSession = (0,
|
|
9773
|
+
const startSession = (0, import_react20.useCallback)(
|
|
9724
9774
|
async (input = {}) => {
|
|
9725
9775
|
setLoading(true);
|
|
9726
9776
|
setError(null);
|
|
@@ -9766,11 +9816,11 @@ var usePublicAccess = (options = {}) => {
|
|
|
9766
9816
|
},
|
|
9767
9817
|
[client, reloadRuntime, setAccessToken, stableSessionInput]
|
|
9768
9818
|
);
|
|
9769
|
-
(0,
|
|
9819
|
+
(0, import_react20.useEffect)(() => {
|
|
9770
9820
|
if (!autoStart) return;
|
|
9771
9821
|
void startSession().catch(() => void 0);
|
|
9772
9822
|
}, [autoStart, startSession]);
|
|
9773
|
-
(0,
|
|
9823
|
+
(0, import_react20.useEffect)(
|
|
9774
9824
|
() => {
|
|
9775
9825
|
mountedRef.current = true;
|
|
9776
9826
|
return () => {
|
|
@@ -9812,30 +9862,30 @@ var readTicketFromLocation = () => {
|
|
|
9812
9862
|
var readPathFromLocation = () => typeof window === "undefined" ? void 0 : window.location.pathname;
|
|
9813
9863
|
|
|
9814
9864
|
// packages/sdk/src/runtime/host/builtinRouteRenderer.tsx
|
|
9815
|
-
var
|
|
9865
|
+
var import_react88 = require("react");
|
|
9816
9866
|
var import_antd44 = require("antd");
|
|
9817
9867
|
|
|
9818
9868
|
// packages/sdk/src/components/modules/DataManagementList.tsx
|
|
9819
|
-
var
|
|
9869
|
+
var import_react87 = require("react");
|
|
9820
9870
|
var import_antd43 = require("antd");
|
|
9821
9871
|
var import_dayjs12 = __toESM(require("dayjs"));
|
|
9822
9872
|
var import_icons20 = require("@ant-design/icons");
|
|
9823
9873
|
|
|
9824
9874
|
// packages/sdk/src/components/templates/StandardFormPage.tsx
|
|
9825
|
-
var
|
|
9875
|
+
var import_react86 = require("react");
|
|
9826
9876
|
|
|
9827
9877
|
// packages/sdk/src/components/templates/FormDetailTemplate.tsx
|
|
9828
|
-
var
|
|
9878
|
+
var import_react77 = require("react");
|
|
9829
9879
|
var import_dayjs10 = __toESM(require("dayjs"));
|
|
9830
9880
|
|
|
9831
9881
|
// packages/sdk/src/components/core/FormProvider.tsx
|
|
9832
|
-
var
|
|
9882
|
+
var import_react68 = __toESM(require("react"));
|
|
9833
9883
|
|
|
9834
9884
|
// packages/sdk/src/components/core/FormContext.ts
|
|
9835
|
-
var
|
|
9836
|
-
var FormContext = (0,
|
|
9885
|
+
var import_react21 = require("react");
|
|
9886
|
+
var FormContext = (0, import_react21.createContext)(null);
|
|
9837
9887
|
function useFormContext() {
|
|
9838
|
-
const context = (0,
|
|
9888
|
+
const context = (0, import_react21.useContext)(FormContext);
|
|
9839
9889
|
if (!context) {
|
|
9840
9890
|
throw new Error("useFormContext must be used within a FormProvider");
|
|
9841
9891
|
}
|
|
@@ -9843,21 +9893,21 @@ function useFormContext() {
|
|
|
9843
9893
|
}
|
|
9844
9894
|
|
|
9845
9895
|
// packages/sdk/src/components/core/ComponentRegistry.tsx
|
|
9846
|
-
var
|
|
9847
|
-
var ComponentRegistryContext = (0,
|
|
9896
|
+
var import_react22 = __toESM(require("react"));
|
|
9897
|
+
var ComponentRegistryContext = (0, import_react22.createContext)(null);
|
|
9848
9898
|
function ComponentRegistryProvider({
|
|
9849
9899
|
components,
|
|
9850
9900
|
children
|
|
9851
9901
|
}) {
|
|
9852
|
-
const [registry, setRegistry] =
|
|
9853
|
-
const register =
|
|
9902
|
+
const [registry, setRegistry] = import_react22.default.useState(components);
|
|
9903
|
+
const register = import_react22.default.useCallback((name, component) => {
|
|
9854
9904
|
setRegistry((prev) => ({ ...prev, [name]: component }));
|
|
9855
9905
|
}, []);
|
|
9856
|
-
const value =
|
|
9857
|
-
return
|
|
9906
|
+
const value = import_react22.default.useMemo(() => ({ registry, register }), [registry, register]);
|
|
9907
|
+
return import_react22.default.createElement(ComponentRegistryContext.Provider, { value }, children);
|
|
9858
9908
|
}
|
|
9859
9909
|
function useComponent(componentName) {
|
|
9860
|
-
const context = (0,
|
|
9910
|
+
const context = (0, import_react22.useContext)(ComponentRegistryContext);
|
|
9861
9911
|
if (!context) {
|
|
9862
9912
|
return null;
|
|
9863
9913
|
}
|
|
@@ -9865,7 +9915,7 @@ function useComponent(componentName) {
|
|
|
9865
9915
|
}
|
|
9866
9916
|
|
|
9867
9917
|
// packages/sdk/src/components/fields/TextField/index.tsx
|
|
9868
|
-
var
|
|
9918
|
+
var import_react24 = require("react");
|
|
9869
9919
|
|
|
9870
9920
|
// packages/sdk/src/components/core/FieldWrapper.tsx
|
|
9871
9921
|
var Antd = __toESM(require("antd"));
|
|
@@ -9979,7 +10029,7 @@ function FieldWrapper({
|
|
|
9979
10029
|
}
|
|
9980
10030
|
|
|
9981
10031
|
// packages/sdk/src/components/hooks/useDeviceDetect.ts
|
|
9982
|
-
var
|
|
10032
|
+
var import_react23 = require("react");
|
|
9983
10033
|
var MOBILE_BREAKPOINT = 768;
|
|
9984
10034
|
function subscribe(callback) {
|
|
9985
10035
|
let prev = window.innerWidth < MOBILE_BREAKPOINT;
|
|
@@ -9997,7 +10047,7 @@ function getSnapshot() {
|
|
|
9997
10047
|
return window.innerWidth < MOBILE_BREAKPOINT;
|
|
9998
10048
|
}
|
|
9999
10049
|
function useDeviceDetect() {
|
|
10000
|
-
const isMobile = (0,
|
|
10050
|
+
const isMobile = (0, import_react23.useSyncExternalStore)(
|
|
10001
10051
|
subscribe,
|
|
10002
10052
|
getSnapshot,
|
|
10003
10053
|
/* v8 ignore next */
|
|
@@ -10153,7 +10203,7 @@ function TextField(props) {
|
|
|
10153
10203
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10154
10204
|
const { isMobile } = useDeviceDetect();
|
|
10155
10205
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10156
|
-
(0,
|
|
10206
|
+
(0, import_react24.useEffect)(() => {
|
|
10157
10207
|
registerField(fieldId);
|
|
10158
10208
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10159
10209
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10178,7 +10228,7 @@ function TextField(props) {
|
|
|
10178
10228
|
}
|
|
10179
10229
|
|
|
10180
10230
|
// packages/sdk/src/components/fields/NumberField/index.tsx
|
|
10181
|
-
var
|
|
10231
|
+
var import_react25 = require("react");
|
|
10182
10232
|
|
|
10183
10233
|
// packages/sdk/src/components/fields/NumberField/NumberFieldPC.tsx
|
|
10184
10234
|
var import_antd13 = require("antd");
|
|
@@ -10400,7 +10450,7 @@ function NumberField(props) {
|
|
|
10400
10450
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10401
10451
|
const { isMobile } = useDeviceDetect();
|
|
10402
10452
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10403
|
-
(0,
|
|
10453
|
+
(0, import_react25.useEffect)(() => {
|
|
10404
10454
|
registerField(fieldId);
|
|
10405
10455
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10406
10456
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10425,7 +10475,7 @@ function NumberField(props) {
|
|
|
10425
10475
|
}
|
|
10426
10476
|
|
|
10427
10477
|
// packages/sdk/src/components/fields/TextAreaField/index.tsx
|
|
10428
|
-
var
|
|
10478
|
+
var import_react26 = require("react");
|
|
10429
10479
|
|
|
10430
10480
|
// packages/sdk/src/components/fields/TextAreaField/TextAreaFieldPC.tsx
|
|
10431
10481
|
var import_antd14 = require("antd");
|
|
@@ -10572,7 +10622,7 @@ function TextAreaField(props) {
|
|
|
10572
10622
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10573
10623
|
const { isMobile } = useDeviceDetect();
|
|
10574
10624
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10575
|
-
(0,
|
|
10625
|
+
(0, import_react26.useEffect)(() => {
|
|
10576
10626
|
registerField(fieldId);
|
|
10577
10627
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10578
10628
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10597,14 +10647,14 @@ function TextAreaField(props) {
|
|
|
10597
10647
|
}
|
|
10598
10648
|
|
|
10599
10649
|
// packages/sdk/src/components/fields/SelectField/index.tsx
|
|
10600
|
-
var
|
|
10650
|
+
var import_react31 = require("react");
|
|
10601
10651
|
|
|
10602
10652
|
// packages/sdk/src/components/fields/SelectField/SelectFieldPC.tsx
|
|
10603
|
-
var
|
|
10653
|
+
var import_react29 = require("react");
|
|
10604
10654
|
var import_antd16 = require("antd");
|
|
10605
10655
|
|
|
10606
10656
|
// packages/sdk/src/components/fields/shared/optionDisplay.tsx
|
|
10607
|
-
var
|
|
10657
|
+
var import_react27 = __toESM(require("react"));
|
|
10608
10658
|
var import_antd15 = require("antd");
|
|
10609
10659
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
10610
10660
|
var PRESET_COLORS = {
|
|
@@ -10670,12 +10720,12 @@ function renderReadonlyOptions(options, coloredOptions, tagWhenPlain = false) {
|
|
|
10670
10720
|
if (options.length === 0) return "--";
|
|
10671
10721
|
if (!coloredOptions && !tagWhenPlain) return options.map((option) => option.label).join(", ");
|
|
10672
10722
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "sy-option-readonly-list", children: options.map(
|
|
10673
|
-
(option) => coloredOptions && option.color ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10723
|
+
(option) => coloredOptions && option.color ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react27.default.Fragment, { children: renderOptionLabel(option, coloredOptions) }, option.value) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_antd15.Tag, { children: option.label }, option.value)
|
|
10674
10724
|
) });
|
|
10675
10725
|
}
|
|
10676
10726
|
|
|
10677
10727
|
// packages/sdk/src/components/fields/SelectField/useLinkedFormRemoteOptions.ts
|
|
10678
|
-
var
|
|
10728
|
+
var import_react28 = require("react");
|
|
10679
10729
|
|
|
10680
10730
|
// packages/sdk/src/components/core/optionSource.ts
|
|
10681
10731
|
var DEFAULT_OPTION_PAGE_SIZE = 200;
|
|
@@ -10890,11 +10940,11 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10890
10940
|
const linkedForm = optionSource?.type === "linkedForm" ? optionSource.linkedForm : void 0;
|
|
10891
10941
|
const enabled = Boolean(linkedForm?.remoteSearch);
|
|
10892
10942
|
const minChars = linkedForm?.remoteSearchMinChars ?? 0;
|
|
10893
|
-
const [remoteOptions, setRemoteOptions] = (0,
|
|
10894
|
-
const [loading, setLoading] = (0,
|
|
10895
|
-
const timerRef = (0,
|
|
10896
|
-
const requestRef = (0,
|
|
10897
|
-
const reset = (0,
|
|
10943
|
+
const [remoteOptions, setRemoteOptions] = (0, import_react28.useState)(null);
|
|
10944
|
+
const [loading, setLoading] = (0, import_react28.useState)(false);
|
|
10945
|
+
const timerRef = (0, import_react28.useRef)(null);
|
|
10946
|
+
const requestRef = (0, import_react28.useRef)(0);
|
|
10947
|
+
const reset = (0, import_react28.useCallback)(() => {
|
|
10898
10948
|
requestRef.current += 1;
|
|
10899
10949
|
if (timerRef.current) {
|
|
10900
10950
|
clearTimeout(timerRef.current);
|
|
@@ -10903,7 +10953,7 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10903
10953
|
setRemoteOptions(null);
|
|
10904
10954
|
setLoading(false);
|
|
10905
10955
|
}, []);
|
|
10906
|
-
const search = (0,
|
|
10956
|
+
const search = (0, import_react28.useCallback)(
|
|
10907
10957
|
(keyword) => {
|
|
10908
10958
|
if (!enabled || !linkedForm) return;
|
|
10909
10959
|
const trimmedKeyword = keyword.trim();
|
|
@@ -10931,14 +10981,14 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10931
10981
|
},
|
|
10932
10982
|
[enabled, linkedForm, minChars, reset, runtime]
|
|
10933
10983
|
);
|
|
10934
|
-
(0,
|
|
10984
|
+
(0, import_react28.useEffect)(
|
|
10935
10985
|
() => () => {
|
|
10936
10986
|
requestRef.current += 1;
|
|
10937
10987
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
10938
10988
|
},
|
|
10939
10989
|
[]
|
|
10940
10990
|
);
|
|
10941
|
-
const options = (0,
|
|
10991
|
+
const options = (0, import_react28.useMemo)(
|
|
10942
10992
|
() => mergeOptionItems(remoteOptions ?? baseOptions, selectedOptions),
|
|
10943
10993
|
[baseOptions, remoteOptions, selectedOptions]
|
|
10944
10994
|
);
|
|
@@ -10986,7 +11036,7 @@ function SelectFieldPC({
|
|
|
10986
11036
|
const { formData, setFieldValue } = useFormContext();
|
|
10987
11037
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
10988
11038
|
const disabled = behavior === "DISABLED";
|
|
10989
|
-
const selectedOptions = (0,
|
|
11039
|
+
const selectedOptions = (0, import_react29.useMemo)(() => value ? [value] : [], [value]);
|
|
10990
11040
|
const remote = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
10991
11041
|
const displayOptions = remote.options;
|
|
10992
11042
|
const handleChange = (val) => {
|
|
@@ -11027,7 +11077,7 @@ function SelectFieldPC({
|
|
|
11027
11077
|
}
|
|
11028
11078
|
|
|
11029
11079
|
// packages/sdk/src/components/fields/SelectField/SelectFieldMobile.tsx
|
|
11030
|
-
var
|
|
11080
|
+
var import_react30 = require("react");
|
|
11031
11081
|
|
|
11032
11082
|
// packages/sdk/src/components/fields/shared/MobileField.tsx
|
|
11033
11083
|
var import_antd_mobile4 = require("antd-mobile");
|
|
@@ -11208,10 +11258,10 @@ function SelectFieldMobile({
|
|
|
11208
11258
|
const { formData, setFieldValue } = useFormContext();
|
|
11209
11259
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
11210
11260
|
const disabled = behavior === "DISABLED";
|
|
11211
|
-
const [visible, setVisible] = (0,
|
|
11212
|
-
const [search, setSearch] = (0,
|
|
11213
|
-
const [tempValue, setTempValue] = (0,
|
|
11214
|
-
const selectedOptions = (0,
|
|
11261
|
+
const [visible, setVisible] = (0, import_react30.useState)(false);
|
|
11262
|
+
const [search, setSearch] = (0, import_react30.useState)("");
|
|
11263
|
+
const [tempValue, setTempValue] = (0, import_react30.useState)(value ?? null);
|
|
11264
|
+
const selectedOptions = (0, import_react30.useMemo)(() => value ? [value] : tempValue ? [tempValue] : [], [
|
|
11215
11265
|
tempValue,
|
|
11216
11266
|
value
|
|
11217
11267
|
]);
|
|
@@ -11222,7 +11272,7 @@ function SelectFieldMobile({
|
|
|
11222
11272
|
reset: resetRemoteOptions,
|
|
11223
11273
|
search: searchRemoteOptions
|
|
11224
11274
|
} = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
11225
|
-
const filteredOptions = (0,
|
|
11275
|
+
const filteredOptions = (0, import_react30.useMemo)(() => {
|
|
11226
11276
|
if (remoteEnabled) return remoteOptions;
|
|
11227
11277
|
const keyword = search.trim().toLowerCase();
|
|
11228
11278
|
if (!keyword) return options;
|
|
@@ -11230,7 +11280,7 @@ function SelectFieldMobile({
|
|
|
11230
11280
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
11231
11281
|
);
|
|
11232
11282
|
}, [options, remoteEnabled, remoteOptions, search]);
|
|
11233
|
-
(0,
|
|
11283
|
+
(0, import_react30.useEffect)(() => {
|
|
11234
11284
|
if (!visible || !remoteEnabled) return;
|
|
11235
11285
|
searchRemoteOptions(search);
|
|
11236
11286
|
}, [remoteEnabled, search, searchRemoteOptions, visible]);
|
|
@@ -11342,7 +11392,7 @@ function SelectField(props) {
|
|
|
11342
11392
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11343
11393
|
const { isMobile } = useDeviceDetect();
|
|
11344
11394
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11345
|
-
(0,
|
|
11395
|
+
(0, import_react31.useEffect)(() => {
|
|
11346
11396
|
registerField(fieldId);
|
|
11347
11397
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11348
11398
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11367,7 +11417,7 @@ function SelectField(props) {
|
|
|
11367
11417
|
}
|
|
11368
11418
|
|
|
11369
11419
|
// packages/sdk/src/components/fields/MultiSelectField/index.tsx
|
|
11370
|
-
var
|
|
11420
|
+
var import_react33 = require("react");
|
|
11371
11421
|
|
|
11372
11422
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldPC.tsx
|
|
11373
11423
|
var import_antd17 = require("antd");
|
|
@@ -11427,7 +11477,7 @@ function MultiSelectFieldPC({
|
|
|
11427
11477
|
}
|
|
11428
11478
|
|
|
11429
11479
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldMobile.tsx
|
|
11430
|
-
var
|
|
11480
|
+
var import_react32 = require("react");
|
|
11431
11481
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
11432
11482
|
function MultiSelectFieldMobile({
|
|
11433
11483
|
fieldId,
|
|
@@ -11444,17 +11494,17 @@ function MultiSelectFieldMobile({
|
|
|
11444
11494
|
const { formData, setFieldValue } = useFormContext();
|
|
11445
11495
|
const value = controlledValue !== void 0 ? controlledValue ?? [] : formData[fieldId] ?? [];
|
|
11446
11496
|
const disabled = behavior === "DISABLED";
|
|
11447
|
-
const [visible, setVisible] = (0,
|
|
11448
|
-
const [search, setSearch] = (0,
|
|
11449
|
-
const [tempValues, setTempValues] = (0,
|
|
11450
|
-
const filteredOptions = (0,
|
|
11497
|
+
const [visible, setVisible] = (0, import_react32.useState)(false);
|
|
11498
|
+
const [search, setSearch] = (0, import_react32.useState)("");
|
|
11499
|
+
const [tempValues, setTempValues] = (0, import_react32.useState)(value);
|
|
11500
|
+
const filteredOptions = (0, import_react32.useMemo)(() => {
|
|
11451
11501
|
const keyword = search.trim().toLowerCase();
|
|
11452
11502
|
if (!keyword) return options;
|
|
11453
11503
|
return options.filter(
|
|
11454
11504
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
11455
11505
|
);
|
|
11456
11506
|
}, [options, search]);
|
|
11457
|
-
const tempValueSet = (0,
|
|
11507
|
+
const tempValueSet = (0, import_react32.useMemo)(
|
|
11458
11508
|
() => new Set(tempValues.map((option) => option.value)),
|
|
11459
11509
|
[tempValues]
|
|
11460
11510
|
);
|
|
@@ -11571,7 +11621,7 @@ function MultiSelectField(props) {
|
|
|
11571
11621
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11572
11622
|
const { isMobile } = useDeviceDetect();
|
|
11573
11623
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11574
|
-
(0,
|
|
11624
|
+
(0, import_react33.useEffect)(() => {
|
|
11575
11625
|
registerField(fieldId);
|
|
11576
11626
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11577
11627
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11596,7 +11646,7 @@ function MultiSelectField(props) {
|
|
|
11596
11646
|
}
|
|
11597
11647
|
|
|
11598
11648
|
// packages/sdk/src/components/fields/RadioField/index.tsx
|
|
11599
|
-
var
|
|
11649
|
+
var import_react34 = require("react");
|
|
11600
11650
|
|
|
11601
11651
|
// packages/sdk/src/components/fields/RadioField/RadioFieldPC.tsx
|
|
11602
11652
|
var import_antd18 = require("antd");
|
|
@@ -11742,7 +11792,7 @@ function RadioField(props) {
|
|
|
11742
11792
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11743
11793
|
const { isMobile } = useDeviceDetect();
|
|
11744
11794
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11745
|
-
(0,
|
|
11795
|
+
(0, import_react34.useEffect)(() => {
|
|
11746
11796
|
registerField(fieldId);
|
|
11747
11797
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11748
11798
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11767,7 +11817,7 @@ function RadioField(props) {
|
|
|
11767
11817
|
}
|
|
11768
11818
|
|
|
11769
11819
|
// packages/sdk/src/components/fields/CheckboxField/index.tsx
|
|
11770
|
-
var
|
|
11820
|
+
var import_react35 = require("react");
|
|
11771
11821
|
|
|
11772
11822
|
// packages/sdk/src/components/fields/CheckboxField/CheckboxFieldPC.tsx
|
|
11773
11823
|
var import_antd19 = require("antd");
|
|
@@ -11924,7 +11974,7 @@ function CheckboxField(props) {
|
|
|
11924
11974
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11925
11975
|
const { isMobile } = useDeviceDetect();
|
|
11926
11976
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11927
|
-
(0,
|
|
11977
|
+
(0, import_react35.useEffect)(() => {
|
|
11928
11978
|
registerField(fieldId);
|
|
11929
11979
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11930
11980
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11949,7 +11999,7 @@ function CheckboxField(props) {
|
|
|
11949
11999
|
}
|
|
11950
12000
|
|
|
11951
12001
|
// packages/sdk/src/components/fields/DateField/index.tsx
|
|
11952
|
-
var
|
|
12002
|
+
var import_react38 = require("react");
|
|
11953
12003
|
|
|
11954
12004
|
// packages/sdk/src/components/fields/DateField/DateFieldPC.tsx
|
|
11955
12005
|
var import_antd20 = require("antd");
|
|
@@ -12099,12 +12149,12 @@ function DateFieldPC({
|
|
|
12099
12149
|
}
|
|
12100
12150
|
|
|
12101
12151
|
// packages/sdk/src/components/fields/DateField/DateFieldMobile.tsx
|
|
12102
|
-
var
|
|
12152
|
+
var import_react37 = require("react");
|
|
12103
12153
|
var import_antd_mobile7 = require("antd-mobile");
|
|
12104
12154
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
12105
12155
|
|
|
12106
12156
|
// packages/sdk/src/components/fields/shared/MobileDatePicker.tsx
|
|
12107
|
-
var
|
|
12157
|
+
var import_react36 = __toESM(require("react"));
|
|
12108
12158
|
var import_antd_mobile5 = require("antd-mobile");
|
|
12109
12159
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
12110
12160
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
@@ -12202,7 +12252,7 @@ function MobileDateTimePickerView({
|
|
|
12202
12252
|
onChange
|
|
12203
12253
|
}) {
|
|
12204
12254
|
const precision = resolveTimePickerPrecision(dateFormat);
|
|
12205
|
-
const columns =
|
|
12255
|
+
const columns = import_react36.default.useMemo(
|
|
12206
12256
|
() => [getDateOptions(value, min, max), ...getTimePickerColumns(precision)],
|
|
12207
12257
|
[value, min, max, precision]
|
|
12208
12258
|
);
|
|
@@ -12240,12 +12290,12 @@ function DateFieldMobile({
|
|
|
12240
12290
|
const { formData, setFieldValue } = useFormContext();
|
|
12241
12291
|
const value = formData[fieldId];
|
|
12242
12292
|
const disabled = behavior === "DISABLED";
|
|
12243
|
-
const [visible, setVisible] = (0,
|
|
12244
|
-
const [mode, setMode] = (0,
|
|
12293
|
+
const [visible, setVisible] = (0, import_react37.useState)(false);
|
|
12294
|
+
const [mode, setMode] = (0, import_react37.useState)("date");
|
|
12245
12295
|
const format = getDateDisplayFormat(dateFormat, showTime);
|
|
12246
12296
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
12247
12297
|
const pickerValue = value && (0, import_dayjs7.default)(value).isValid() ? (0, import_dayjs7.default)(value).toDate() : /* @__PURE__ */ new Date();
|
|
12248
|
-
const [tempDate, setTempDate] = (0,
|
|
12298
|
+
const [tempDate, setTempDate] = (0, import_react37.useState)(pickerValue);
|
|
12249
12299
|
const { min, max } = getDateMinMax(dateRestriction);
|
|
12250
12300
|
const openPicker = () => {
|
|
12251
12301
|
if (disabled) return;
|
|
@@ -12382,7 +12432,7 @@ function DateField(props) {
|
|
|
12382
12432
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
12383
12433
|
const { isMobile } = useDeviceDetect();
|
|
12384
12434
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
12385
|
-
(0,
|
|
12435
|
+
(0, import_react38.useEffect)(() => {
|
|
12386
12436
|
registerField(fieldId);
|
|
12387
12437
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
12388
12438
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -12407,7 +12457,7 @@ function DateField(props) {
|
|
|
12407
12457
|
}
|
|
12408
12458
|
|
|
12409
12459
|
// packages/sdk/src/components/fields/CascadeDateField/index.tsx
|
|
12410
|
-
var
|
|
12460
|
+
var import_react40 = require("react");
|
|
12411
12461
|
|
|
12412
12462
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldPC.tsx
|
|
12413
12463
|
var import_antd21 = require("antd");
|
|
@@ -12463,7 +12513,7 @@ function CascadeDateFieldPC({
|
|
|
12463
12513
|
}
|
|
12464
12514
|
|
|
12465
12515
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldMobile.tsx
|
|
12466
|
-
var
|
|
12516
|
+
var import_react39 = require("react");
|
|
12467
12517
|
var import_antd_mobile8 = require("antd-mobile");
|
|
12468
12518
|
var import_dayjs9 = __toESM(require("dayjs"));
|
|
12469
12519
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
@@ -12481,11 +12531,11 @@ function CascadeDateFieldMobile({
|
|
|
12481
12531
|
const { formData, setFieldValue } = useFormContext();
|
|
12482
12532
|
const value = normalizeDateRangeValue(formData[fieldId]);
|
|
12483
12533
|
const disabled = behavior === "DISABLED";
|
|
12484
|
-
const [visible, setVisible] = (0,
|
|
12485
|
-
const [tempRange, setTempRange] = (0,
|
|
12486
|
-
const [timeStep, setTimeStep] = (0,
|
|
12487
|
-
const [tempStart, setTempStart] = (0,
|
|
12488
|
-
const [tempEnd, setTempEnd] = (0,
|
|
12534
|
+
const [visible, setVisible] = (0, import_react39.useState)(false);
|
|
12535
|
+
const [tempRange, setTempRange] = (0, import_react39.useState)(null);
|
|
12536
|
+
const [timeStep, setTimeStep] = (0, import_react39.useState)("start");
|
|
12537
|
+
const [tempStart, setTempStart] = (0, import_react39.useState)(/* @__PURE__ */ new Date());
|
|
12538
|
+
const [tempEnd, setTempEnd] = (0, import_react39.useState)(/* @__PURE__ */ new Date());
|
|
12489
12539
|
const format = getDateDisplayFormat(dateFormat, showTime);
|
|
12490
12540
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
12491
12541
|
const startValue = value?.start && (0, import_dayjs9.default)(value.start).isValid() ? (0, import_dayjs9.default)(value.start).toDate() : void 0;
|
|
@@ -12649,7 +12699,7 @@ function CascadeDateField(props) {
|
|
|
12649
12699
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
12650
12700
|
const { isMobile } = useDeviceDetect();
|
|
12651
12701
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
12652
|
-
(0,
|
|
12702
|
+
(0, import_react40.useEffect)(() => {
|
|
12653
12703
|
registerField(fieldId);
|
|
12654
12704
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
12655
12705
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -12674,10 +12724,10 @@ function CascadeDateField(props) {
|
|
|
12674
12724
|
}
|
|
12675
12725
|
|
|
12676
12726
|
// packages/sdk/src/components/fields/AttachmentField/index.tsx
|
|
12677
|
-
var
|
|
12727
|
+
var import_react43 = require("react");
|
|
12678
12728
|
|
|
12679
12729
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldPC.tsx
|
|
12680
|
-
var
|
|
12730
|
+
var import_react41 = __toESM(require("react"));
|
|
12681
12731
|
var import_antd22 = require("antd");
|
|
12682
12732
|
|
|
12683
12733
|
// packages/sdk/src/components/fields/shared/fileTransfer.ts
|
|
@@ -12723,13 +12773,13 @@ function AttachmentFieldPC({
|
|
|
12723
12773
|
onChange
|
|
12724
12774
|
}) {
|
|
12725
12775
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
12726
|
-
const value =
|
|
12776
|
+
const value = import_react41.default.useMemo(
|
|
12727
12777
|
() => dedupeAttachmentItems(
|
|
12728
12778
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
12729
12779
|
),
|
|
12730
12780
|
[fieldId, formData]
|
|
12731
12781
|
);
|
|
12732
|
-
const valueRef =
|
|
12782
|
+
const valueRef = import_react41.default.useRef(value);
|
|
12733
12783
|
const disabled = behavior === "DISABLED";
|
|
12734
12784
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
12735
12785
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -12762,7 +12812,7 @@ function AttachmentFieldPC({
|
|
|
12762
12812
|
enabled: showPreview,
|
|
12763
12813
|
requireServerCapability: true
|
|
12764
12814
|
});
|
|
12765
|
-
|
|
12815
|
+
import_react41.default.useEffect(() => {
|
|
12766
12816
|
valueRef.current = value;
|
|
12767
12817
|
}, [value]);
|
|
12768
12818
|
const setValue = (items) => {
|
|
@@ -13012,7 +13062,7 @@ function AttachmentFieldPC({
|
|
|
13012
13062
|
}
|
|
13013
13063
|
|
|
13014
13064
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldMobile.tsx
|
|
13015
|
-
var
|
|
13065
|
+
var import_react42 = __toESM(require("react"));
|
|
13016
13066
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
13017
13067
|
var createLocalItem2 = (file) => {
|
|
13018
13068
|
const uid = createUid("attachment");
|
|
@@ -13048,14 +13098,14 @@ function AttachmentFieldMobile({
|
|
|
13048
13098
|
onChange
|
|
13049
13099
|
}) {
|
|
13050
13100
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13051
|
-
const value =
|
|
13101
|
+
const value = import_react42.default.useMemo(
|
|
13052
13102
|
() => dedupeAttachmentItems(
|
|
13053
13103
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13054
13104
|
),
|
|
13055
13105
|
[fieldId, formData]
|
|
13056
13106
|
);
|
|
13057
|
-
const valueRef =
|
|
13058
|
-
const inputRef =
|
|
13107
|
+
const valueRef = import_react42.default.useRef(value);
|
|
13108
|
+
const inputRef = import_react42.default.useRef(null);
|
|
13059
13109
|
const disabled = behavior === "DISABLED";
|
|
13060
13110
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13061
13111
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13088,7 +13138,7 @@ function AttachmentFieldMobile({
|
|
|
13088
13138
|
enabled: showPreview,
|
|
13089
13139
|
requireServerCapability: true
|
|
13090
13140
|
});
|
|
13091
|
-
|
|
13141
|
+
import_react42.default.useEffect(() => {
|
|
13092
13142
|
valueRef.current = value;
|
|
13093
13143
|
}, [value]);
|
|
13094
13144
|
const setValue = (items) => {
|
|
@@ -13422,7 +13472,7 @@ function AttachmentField(props) {
|
|
|
13422
13472
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
13423
13473
|
const { isMobile } = useDeviceDetect();
|
|
13424
13474
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
13425
|
-
(0,
|
|
13475
|
+
(0, import_react43.useEffect)(() => {
|
|
13426
13476
|
registerField(fieldId);
|
|
13427
13477
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
13428
13478
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -13447,10 +13497,10 @@ function AttachmentField(props) {
|
|
|
13447
13497
|
}
|
|
13448
13498
|
|
|
13449
13499
|
// packages/sdk/src/components/fields/ImageField/index.tsx
|
|
13450
|
-
var
|
|
13500
|
+
var import_react47 = require("react");
|
|
13451
13501
|
|
|
13452
13502
|
// packages/sdk/src/components/fields/ImageField/ImageFieldPC.tsx
|
|
13453
|
-
var
|
|
13503
|
+
var import_react44 = __toESM(require("react"));
|
|
13454
13504
|
var import_antd23 = require("antd");
|
|
13455
13505
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
13456
13506
|
var createLocalItem3 = (file) => {
|
|
@@ -13469,9 +13519,9 @@ var createLocalItem3 = (file) => {
|
|
|
13469
13519
|
};
|
|
13470
13520
|
};
|
|
13471
13521
|
function ImageThumbContent({ item }) {
|
|
13472
|
-
const [imageFailed, setImageFailed] =
|
|
13522
|
+
const [imageFailed, setImageFailed] = import_react44.default.useState(false);
|
|
13473
13523
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
13474
|
-
|
|
13524
|
+
import_react44.default.useEffect(() => {
|
|
13475
13525
|
setImageFailed(false);
|
|
13476
13526
|
}, [src]);
|
|
13477
13527
|
if (src && !imageFailed) {
|
|
@@ -13502,13 +13552,13 @@ function ImageFieldPC({
|
|
|
13502
13552
|
onChange
|
|
13503
13553
|
}) {
|
|
13504
13554
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13505
|
-
const value =
|
|
13555
|
+
const value = import_react44.default.useMemo(
|
|
13506
13556
|
() => dedupeAttachmentItems(
|
|
13507
13557
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13508
13558
|
),
|
|
13509
13559
|
[fieldId, formData]
|
|
13510
13560
|
);
|
|
13511
|
-
const valueRef =
|
|
13561
|
+
const valueRef = import_react44.default.useRef(value);
|
|
13512
13562
|
const disabled = behavior === "DISABLED";
|
|
13513
13563
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13514
13564
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13543,7 +13593,7 @@ function ImageFieldPC({
|
|
|
13543
13593
|
enabled: showPreviewIcon,
|
|
13544
13594
|
requireServerCapability: false
|
|
13545
13595
|
});
|
|
13546
|
-
|
|
13596
|
+
import_react44.default.useEffect(() => {
|
|
13547
13597
|
valueRef.current = value;
|
|
13548
13598
|
}, [value]);
|
|
13549
13599
|
const setValue = (items) => {
|
|
@@ -13808,7 +13858,7 @@ function ImageFieldPC({
|
|
|
13808
13858
|
}
|
|
13809
13859
|
|
|
13810
13860
|
// packages/sdk/src/components/fields/ImageField/ImageFieldMobile.tsx
|
|
13811
|
-
var
|
|
13861
|
+
var import_react45 = __toESM(require("react"));
|
|
13812
13862
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
13813
13863
|
var createLocalItem4 = (file) => {
|
|
13814
13864
|
const uid = createUid("image");
|
|
@@ -13826,9 +13876,9 @@ var createLocalItem4 = (file) => {
|
|
|
13826
13876
|
};
|
|
13827
13877
|
};
|
|
13828
13878
|
function ImageThumbContent2({ item }) {
|
|
13829
|
-
const [imageFailed, setImageFailed] =
|
|
13879
|
+
const [imageFailed, setImageFailed] = import_react45.default.useState(false);
|
|
13830
13880
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
13831
|
-
|
|
13881
|
+
import_react45.default.useEffect(() => {
|
|
13832
13882
|
setImageFailed(false);
|
|
13833
13883
|
}, [src]);
|
|
13834
13884
|
if (src && !imageFailed) {
|
|
@@ -13858,14 +13908,14 @@ function ImageFieldMobile({
|
|
|
13858
13908
|
onChange
|
|
13859
13909
|
}) {
|
|
13860
13910
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13861
|
-
const value =
|
|
13911
|
+
const value = import_react45.default.useMemo(
|
|
13862
13912
|
() => dedupeAttachmentItems(
|
|
13863
13913
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13864
13914
|
),
|
|
13865
13915
|
[fieldId, formData]
|
|
13866
13916
|
);
|
|
13867
|
-
const valueRef =
|
|
13868
|
-
const inputRef =
|
|
13917
|
+
const valueRef = import_react45.default.useRef(value);
|
|
13918
|
+
const inputRef = import_react45.default.useRef(null);
|
|
13869
13919
|
const disabled = behavior === "DISABLED";
|
|
13870
13920
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13871
13921
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13897,7 +13947,7 @@ function ImageFieldMobile({
|
|
|
13897
13947
|
enabled: showPreviewIcon,
|
|
13898
13948
|
requireServerCapability: false
|
|
13899
13949
|
});
|
|
13900
|
-
|
|
13950
|
+
import_react45.default.useEffect(() => {
|
|
13901
13951
|
valueRef.current = value;
|
|
13902
13952
|
}, [value]);
|
|
13903
13953
|
const setValue = (items) => {
|
|
@@ -14064,14 +14114,14 @@ function ImageFieldMobile({
|
|
|
14064
14114
|
}
|
|
14065
14115
|
|
|
14066
14116
|
// packages/sdk/src/components/fields/ImageField/ImageFieldReadonly.tsx
|
|
14067
|
-
var
|
|
14117
|
+
var import_react46 = __toESM(require("react"));
|
|
14068
14118
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
14069
14119
|
var getTicketUrl2 = (ticket, fallback) => typeof ticket === "string" ? ticket : ticket?.previewUrl || ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || fallback;
|
|
14070
14120
|
var isDirectStorageItem3 = (item) => item.provider === "oss" || item.uploadProvider === "oss" || item.uploadProvider === "builtin-oss" || Boolean(item.storageCode);
|
|
14071
14121
|
function ImageThumbContent3({ item, testId }) {
|
|
14072
|
-
const [imageFailed, setImageFailed] =
|
|
14122
|
+
const [imageFailed, setImageFailed] = import_react46.default.useState(false);
|
|
14073
14123
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
14074
|
-
|
|
14124
|
+
import_react46.default.useEffect(() => {
|
|
14075
14125
|
setImageFailed(false);
|
|
14076
14126
|
}, [src]);
|
|
14077
14127
|
if (src && !imageFailed) {
|
|
@@ -14240,7 +14290,7 @@ function ImageField(props) {
|
|
|
14240
14290
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
14241
14291
|
const { isMobile } = useDeviceDetect();
|
|
14242
14292
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
14243
|
-
(0,
|
|
14293
|
+
(0, import_react47.useEffect)(() => {
|
|
14244
14294
|
registerField(fieldId);
|
|
14245
14295
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
14246
14296
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -14265,10 +14315,10 @@ function ImageField(props) {
|
|
|
14265
14315
|
}
|
|
14266
14316
|
|
|
14267
14317
|
// packages/sdk/src/components/fields/SubFormField/index.tsx
|
|
14268
|
-
var
|
|
14318
|
+
var import_react49 = require("react");
|
|
14269
14319
|
|
|
14270
14320
|
// packages/sdk/src/components/fields/SubFormField/SubFormCell.tsx
|
|
14271
|
-
var
|
|
14321
|
+
var import_react48 = require("react");
|
|
14272
14322
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
14273
14323
|
var stringifyFallbackValue = (value) => {
|
|
14274
14324
|
if (value === void 0 || value === null) return "";
|
|
@@ -14289,7 +14339,7 @@ function SubFormCell({
|
|
|
14289
14339
|
const scopedFieldId = `${parentFieldId}.${rowIndex}.${column.fieldId}`;
|
|
14290
14340
|
const cellValue = row[column.fieldId];
|
|
14291
14341
|
const resolvedBehavior = behavior === "DISABLED" || behavior === "READONLY" ? behavior : column.behavior ?? behavior ?? "NORMAL";
|
|
14292
|
-
const childContext = (0,
|
|
14342
|
+
const childContext = (0, import_react48.useMemo)(
|
|
14293
14343
|
() => ({
|
|
14294
14344
|
...parentContext,
|
|
14295
14345
|
formData: {
|
|
@@ -14583,7 +14633,7 @@ function SubFormField(props) {
|
|
|
14583
14633
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
14584
14634
|
const { isMobile } = useDeviceDetect();
|
|
14585
14635
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
14586
|
-
(0,
|
|
14636
|
+
(0, import_react49.useEffect)(() => {
|
|
14587
14637
|
registerField(fieldId);
|
|
14588
14638
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
14589
14639
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -14608,10 +14658,10 @@ function SubFormField(props) {
|
|
|
14608
14658
|
}
|
|
14609
14659
|
|
|
14610
14660
|
// packages/sdk/src/components/fields/UserSelectField/index.tsx
|
|
14611
|
-
var
|
|
14661
|
+
var import_react53 = require("react");
|
|
14612
14662
|
|
|
14613
14663
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldPC.tsx
|
|
14614
|
-
var
|
|
14664
|
+
var import_react50 = require("react");
|
|
14615
14665
|
var import_antd24 = require("antd");
|
|
14616
14666
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
14617
14667
|
function UserSelectFieldPC({
|
|
@@ -14631,20 +14681,20 @@ function UserSelectFieldPC({
|
|
|
14631
14681
|
}) {
|
|
14632
14682
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14633
14683
|
const rawValue = formData[fieldId];
|
|
14634
|
-
const value = (0,
|
|
14684
|
+
const value = (0, import_react50.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14635
14685
|
const disabled = behavior === "DISABLED";
|
|
14636
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
14686
|
+
const [optionsSource, setOptionsSource] = (0, import_react50.useState)(
|
|
14637
14687
|
() => dataSource.map(normalizeUser)
|
|
14638
14688
|
);
|
|
14639
|
-
const [loading, setLoading] = (0,
|
|
14640
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
14689
|
+
const [loading, setLoading] = (0, import_react50.useState)(false);
|
|
14690
|
+
const [pickerOpen, setPickerOpen] = (0, import_react50.useState)(false);
|
|
14641
14691
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
14642
|
-
(0,
|
|
14692
|
+
(0, import_react50.useEffect)(() => {
|
|
14643
14693
|
if (dataSource.length) {
|
|
14644
14694
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
14645
14695
|
}
|
|
14646
14696
|
}, [dataSource]);
|
|
14647
|
-
(0,
|
|
14697
|
+
(0, import_react50.useEffect)(() => {
|
|
14648
14698
|
setOptionsSource((current) => {
|
|
14649
14699
|
const merged = [...current];
|
|
14650
14700
|
let changed = false;
|
|
@@ -14657,7 +14707,7 @@ function UserSelectFieldPC({
|
|
|
14657
14707
|
return changed ? merged : current;
|
|
14658
14708
|
});
|
|
14659
14709
|
}, [value]);
|
|
14660
|
-
(0,
|
|
14710
|
+
(0, import_react50.useEffect)(() => {
|
|
14661
14711
|
const missing = value.filter((item) => getUserId(item) && getUserNameLikeId(item));
|
|
14662
14712
|
if (missing.length === 0) return;
|
|
14663
14713
|
let cancelled = false;
|
|
@@ -14700,7 +14750,7 @@ function UserSelectFieldPC({
|
|
|
14700
14750
|
setLoading(false);
|
|
14701
14751
|
}
|
|
14702
14752
|
};
|
|
14703
|
-
(0,
|
|
14753
|
+
(0, import_react50.useEffect)(() => {
|
|
14704
14754
|
fetchUsers();
|
|
14705
14755
|
}, []);
|
|
14706
14756
|
const handleChange = (selectedIds) => {
|
|
@@ -14725,7 +14775,7 @@ function UserSelectFieldPC({
|
|
|
14725
14775
|
setFieldValue(fieldId, normalized);
|
|
14726
14776
|
onChange?.(normalized);
|
|
14727
14777
|
};
|
|
14728
|
-
const options = (0,
|
|
14778
|
+
const options = (0, import_react50.useMemo)(
|
|
14729
14779
|
() => optionsSource.map((u) => ({
|
|
14730
14780
|
value: getUserId(u),
|
|
14731
14781
|
label: formatUserDisplay(u, displayFormat)
|
|
@@ -14789,7 +14839,7 @@ function getUserNameLikeId(user) {
|
|
|
14789
14839
|
}
|
|
14790
14840
|
|
|
14791
14841
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldMobile.tsx
|
|
14792
|
-
var
|
|
14842
|
+
var import_react51 = require("react");
|
|
14793
14843
|
var MobileAntd2 = __toESM(require("antd-mobile"));
|
|
14794
14844
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
14795
14845
|
var getMobilePopup = () => {
|
|
@@ -14814,19 +14864,19 @@ function UserSelectFieldMobile({
|
|
|
14814
14864
|
}) {
|
|
14815
14865
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14816
14866
|
const rawValue = formData[fieldId];
|
|
14817
|
-
const value = (0,
|
|
14867
|
+
const value = (0, import_react51.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14818
14868
|
const disabled = behavior === "DISABLED";
|
|
14819
|
-
const [showPicker, setShowPicker] = (0,
|
|
14820
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
14869
|
+
const [showPicker, setShowPicker] = (0, import_react51.useState)(false);
|
|
14870
|
+
const [optionsSource, setOptionsSource] = (0, import_react51.useState)(
|
|
14821
14871
|
() => dataSource.map(normalizeUser)
|
|
14822
14872
|
);
|
|
14823
14873
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
14824
|
-
(0,
|
|
14874
|
+
(0, import_react51.useEffect)(() => {
|
|
14825
14875
|
if (dataSource.length) {
|
|
14826
14876
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
14827
14877
|
}
|
|
14828
14878
|
}, [dataSource]);
|
|
14829
|
-
(0,
|
|
14879
|
+
(0, import_react51.useEffect)(() => {
|
|
14830
14880
|
setOptionsSource((current) => {
|
|
14831
14881
|
const merged = [...current];
|
|
14832
14882
|
let changed = false;
|
|
@@ -14922,7 +14972,7 @@ function UserSelectFieldMobile({
|
|
|
14922
14972
|
}
|
|
14923
14973
|
|
|
14924
14974
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldReadonly.tsx
|
|
14925
|
-
var
|
|
14975
|
+
var import_react52 = require("react");
|
|
14926
14976
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
14927
14977
|
function UserSelectFieldReadonly({
|
|
14928
14978
|
fieldId,
|
|
@@ -14931,8 +14981,8 @@ function UserSelectFieldReadonly({
|
|
|
14931
14981
|
}) {
|
|
14932
14982
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14933
14983
|
const rawValue = formData[fieldId];
|
|
14934
|
-
const value = (0,
|
|
14935
|
-
(0,
|
|
14984
|
+
const value = (0, import_react52.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14985
|
+
(0, import_react52.useEffect)(() => {
|
|
14936
14986
|
const missing = value.filter((item) => getUserNameLikeId2(item));
|
|
14937
14987
|
if (missing.length === 0) return;
|
|
14938
14988
|
let cancelled = false;
|
|
@@ -14984,7 +15034,7 @@ function UserSelectField(props) {
|
|
|
14984
15034
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
14985
15035
|
const { isMobile } = useDeviceDetect();
|
|
14986
15036
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
14987
|
-
(0,
|
|
15037
|
+
(0, import_react53.useEffect)(() => {
|
|
14988
15038
|
registerField(fieldId);
|
|
14989
15039
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
14990
15040
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -15009,10 +15059,10 @@ function UserSelectField(props) {
|
|
|
15009
15059
|
}
|
|
15010
15060
|
|
|
15011
15061
|
// packages/sdk/src/components/fields/DepartmentSelectField/index.tsx
|
|
15012
|
-
var
|
|
15062
|
+
var import_react58 = require("react");
|
|
15013
15063
|
|
|
15014
15064
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldPC.tsx
|
|
15015
|
-
var
|
|
15065
|
+
var import_react55 = require("react");
|
|
15016
15066
|
var import_antd26 = require("antd");
|
|
15017
15067
|
|
|
15018
15068
|
// packages/sdk/src/components/fields/shared/departmentSearch.ts
|
|
@@ -15031,7 +15081,7 @@ function getDepartmentPathText(department, separator = "/") {
|
|
|
15031
15081
|
}
|
|
15032
15082
|
|
|
15033
15083
|
// packages/sdk/src/components/fields/shared/DepartmentPicker.tsx
|
|
15034
|
-
var
|
|
15084
|
+
var import_react54 = require("react");
|
|
15035
15085
|
var import_antd25 = require("antd");
|
|
15036
15086
|
var import_icons12 = require("@ant-design/icons");
|
|
15037
15087
|
var MobileAntd3 = __toESM(require("antd-mobile"));
|
|
@@ -15084,20 +15134,20 @@ function DepartmentPickerPanel({
|
|
|
15084
15134
|
flatNodes,
|
|
15085
15135
|
loadChildren
|
|
15086
15136
|
} = useLazyDepartmentTree(api, treeData);
|
|
15087
|
-
const [keyword, setKeyword] = (0,
|
|
15088
|
-
const [selected, setSelected] = (0,
|
|
15089
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
15090
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
15091
|
-
const [remoteSearchResults, setRemoteSearchResults] = (0,
|
|
15092
|
-
const [remoteSearchLoading, setRemoteSearchLoading] = (0,
|
|
15093
|
-
const [remoteSearchError, setRemoteSearchError] = (0,
|
|
15094
|
-
const searchSeqRef = (0,
|
|
15137
|
+
const [keyword, setKeyword] = (0, import_react54.useState)("");
|
|
15138
|
+
const [selected, setSelected] = (0, import_react54.useState)(() => normalizeSelection(value));
|
|
15139
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react54.useState)([]);
|
|
15140
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react54.useState)(null);
|
|
15141
|
+
const [remoteSearchResults, setRemoteSearchResults] = (0, import_react54.useState)([]);
|
|
15142
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = (0, import_react54.useState)(false);
|
|
15143
|
+
const [remoteSearchError, setRemoteSearchError] = (0, import_react54.useState)("");
|
|
15144
|
+
const searchSeqRef = (0, import_react54.useRef)(0);
|
|
15095
15145
|
const selectedIds = selected.map((item) => item.id);
|
|
15096
15146
|
const MobileSearchBar = getMobileComponent2("SearchBar");
|
|
15097
15147
|
const trimmedKeyword = keyword.trim();
|
|
15098
15148
|
const canRemoteSearch = showSearch && searchScope === "all" && trimmedKeyword.length >= searchMinLength && canSearchAllDepartments(api, treeData);
|
|
15099
15149
|
const spinning = treeLoading || remoteSearchLoading;
|
|
15100
|
-
(0,
|
|
15150
|
+
(0, import_react54.useEffect)(() => {
|
|
15101
15151
|
if (!canRemoteSearch) {
|
|
15102
15152
|
searchSeqRef.current += 1;
|
|
15103
15153
|
setRemoteSearchResults([]);
|
|
@@ -15132,11 +15182,11 @@ function DepartmentPickerPanel({
|
|
|
15132
15182
|
window.clearTimeout(timer);
|
|
15133
15183
|
};
|
|
15134
15184
|
}, [api, canRemoteSearch, searchDebounceMs, trimmedKeyword]);
|
|
15135
|
-
const filteredTreeData = (0,
|
|
15185
|
+
const filteredTreeData = (0, import_react54.useMemo)(
|
|
15136
15186
|
() => showSearch ? matchSearch(loadedTreeData, trimmedKeyword) : loadedTreeData,
|
|
15137
15187
|
[loadedTreeData, showSearch, trimmedKeyword]
|
|
15138
15188
|
);
|
|
15139
|
-
const currentPath = (0,
|
|
15189
|
+
const currentPath = (0, import_react54.useMemo)(() => {
|
|
15140
15190
|
if (!currentDeptId) return [];
|
|
15141
15191
|
const path = [];
|
|
15142
15192
|
let cursor = currentDeptId;
|
|
@@ -15148,7 +15198,7 @@ function DepartmentPickerPanel({
|
|
|
15148
15198
|
}
|
|
15149
15199
|
return path;
|
|
15150
15200
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
15151
|
-
const mobileList = (0,
|
|
15201
|
+
const mobileList = (0, import_react54.useMemo)(() => {
|
|
15152
15202
|
if (canRemoteSearch) {
|
|
15153
15203
|
return remoteSearchResults;
|
|
15154
15204
|
}
|
|
@@ -15466,18 +15516,18 @@ function DepartmentSelectFieldPC({
|
|
|
15466
15516
|
}) {
|
|
15467
15517
|
const { formData, setFieldValue, api } = useFormContext();
|
|
15468
15518
|
const rawValue = formData[fieldId];
|
|
15469
|
-
const value = (0,
|
|
15519
|
+
const value = (0, import_react55.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15470
15520
|
const disabled = behavior === "DISABLED";
|
|
15471
15521
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA;
|
|
15472
|
-
const remoteLoadedRef = (0,
|
|
15473
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
15474
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
15475
|
-
const [searchKeyword, setSearchKeyword] = (0,
|
|
15476
|
-
const [remoteSearchResults, setRemoteSearchResults] = (0,
|
|
15477
|
-
const [remoteSearchLoading, setRemoteSearchLoading] = (0,
|
|
15478
|
-
const [selectedPathMap, setSelectedPathMap] = (0,
|
|
15479
|
-
const searchSeqRef = (0,
|
|
15480
|
-
(0,
|
|
15522
|
+
const remoteLoadedRef = (0, import_react55.useRef)(false);
|
|
15523
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react55.useState)(configuredTreeData);
|
|
15524
|
+
const [pickerOpen, setPickerOpen] = (0, import_react55.useState)(false);
|
|
15525
|
+
const [searchKeyword, setSearchKeyword] = (0, import_react55.useState)("");
|
|
15526
|
+
const [remoteSearchResults, setRemoteSearchResults] = (0, import_react55.useState)([]);
|
|
15527
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = (0, import_react55.useState)(false);
|
|
15528
|
+
const [selectedPathMap, setSelectedPathMap] = (0, import_react55.useState)({});
|
|
15529
|
+
const searchSeqRef = (0, import_react55.useRef)(0);
|
|
15530
|
+
(0, import_react55.useEffect)(() => {
|
|
15481
15531
|
if (configuredTreeData.length) {
|
|
15482
15532
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
15483
15533
|
return;
|
|
@@ -15490,7 +15540,7 @@ function DepartmentSelectFieldPC({
|
|
|
15490
15540
|
}, [api, configuredTreeData]);
|
|
15491
15541
|
const trimmedSearchKeyword = searchKeyword.trim();
|
|
15492
15542
|
const canRemoteSearch = showSearch && searchScope === "all" && trimmedSearchKeyword.length >= searchMinLength && canSearchAllDepartments(api, configuredTreeData);
|
|
15493
|
-
(0,
|
|
15543
|
+
(0, import_react55.useEffect)(() => {
|
|
15494
15544
|
if (!canRemoteSearch) {
|
|
15495
15545
|
searchSeqRef.current += 1;
|
|
15496
15546
|
setRemoteSearchResults([]);
|
|
@@ -15524,7 +15574,7 @@ function DepartmentSelectFieldPC({
|
|
|
15524
15574
|
}, [api, canRemoteSearch, searchDebounceMs, trimmedSearchKeyword]);
|
|
15525
15575
|
const scopedTreeData = filterTreeByScope(loadedTreeData, scopeType, specifiedDepts);
|
|
15526
15576
|
const allDepts = flattenDepartments(scopedTreeData);
|
|
15527
|
-
const scopedRemoteSearchResults = (0,
|
|
15577
|
+
const scopedRemoteSearchResults = (0, import_react55.useMemo)(() => {
|
|
15528
15578
|
if (scopeType !== "specified" || !specifiedDepts?.length) {
|
|
15529
15579
|
return remoteSearchResults;
|
|
15530
15580
|
}
|
|
@@ -15535,7 +15585,7 @@ function DepartmentSelectFieldPC({
|
|
|
15535
15585
|
return node.path?.some((item) => specifiedSet.has(item.id));
|
|
15536
15586
|
});
|
|
15537
15587
|
}, [remoteSearchResults, scopeType, specifiedDepts]);
|
|
15538
|
-
const remoteDeptMap = (0,
|
|
15588
|
+
const remoteDeptMap = (0, import_react55.useMemo)(() => {
|
|
15539
15589
|
const map = /* @__PURE__ */ new Map();
|
|
15540
15590
|
scopedRemoteSearchResults.forEach((node) => map.set(getDepartmentId(node), node));
|
|
15541
15591
|
return map;
|
|
@@ -15664,7 +15714,7 @@ function DepartmentSelectFieldPC({
|
|
|
15664
15714
|
}
|
|
15665
15715
|
|
|
15666
15716
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldMobile.tsx
|
|
15667
|
-
var
|
|
15717
|
+
var import_react56 = require("react");
|
|
15668
15718
|
var MobileAntd4 = __toESM(require("antd-mobile"));
|
|
15669
15719
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
15670
15720
|
var EMPTY_TREE_DATA2 = [];
|
|
@@ -15699,13 +15749,13 @@ function DepartmentSelectFieldMobile({
|
|
|
15699
15749
|
}) {
|
|
15700
15750
|
const { formData, setFieldValue, api } = useFormContext();
|
|
15701
15751
|
const rawValue = formData[fieldId];
|
|
15702
|
-
const value = (0,
|
|
15752
|
+
const value = (0, import_react56.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15703
15753
|
const disabled = behavior === "DISABLED";
|
|
15704
|
-
const [showPicker, setShowPicker] = (0,
|
|
15754
|
+
const [showPicker, setShowPicker] = (0, import_react56.useState)(false);
|
|
15705
15755
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA2;
|
|
15706
|
-
const remoteLoadedRef = (0,
|
|
15707
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
15708
|
-
(0,
|
|
15756
|
+
const remoteLoadedRef = (0, import_react56.useRef)(false);
|
|
15757
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react56.useState)(configuredTreeData);
|
|
15758
|
+
(0, import_react56.useEffect)(() => {
|
|
15709
15759
|
if (configuredTreeData.length) {
|
|
15710
15760
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
15711
15761
|
}
|
|
@@ -15804,7 +15854,7 @@ function DepartmentSelectFieldMobile({
|
|
|
15804
15854
|
}
|
|
15805
15855
|
|
|
15806
15856
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldReadonly.tsx
|
|
15807
|
-
var
|
|
15857
|
+
var import_react57 = require("react");
|
|
15808
15858
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
15809
15859
|
function DepartmentSelectFieldReadonly({
|
|
15810
15860
|
fieldId,
|
|
@@ -15814,7 +15864,7 @@ function DepartmentSelectFieldReadonly({
|
|
|
15814
15864
|
}) {
|
|
15815
15865
|
const { formData } = useFormContext();
|
|
15816
15866
|
const rawValue = formData[fieldId];
|
|
15817
|
-
const value = (0,
|
|
15867
|
+
const value = (0, import_react57.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15818
15868
|
const display = value.length > 0 ? value.map(
|
|
15819
15869
|
(d) => showFullPath ? getDepartmentFullPath(getDepartmentId(d), treeData) || getDepartmentName(d) : getDepartmentName(d)
|
|
15820
15870
|
).join(", ") : "--";
|
|
@@ -15845,7 +15895,7 @@ function DepartmentSelectField(props) {
|
|
|
15845
15895
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
15846
15896
|
const { isMobile } = useDeviceDetect();
|
|
15847
15897
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15848
|
-
(0,
|
|
15898
|
+
(0, import_react58.useEffect)(() => {
|
|
15849
15899
|
registerField(fieldId);
|
|
15850
15900
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15851
15901
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -15870,7 +15920,7 @@ function DepartmentSelectField(props) {
|
|
|
15870
15920
|
}
|
|
15871
15921
|
|
|
15872
15922
|
// packages/sdk/src/components/fields/CascadeSelectField/index.tsx
|
|
15873
|
-
var
|
|
15923
|
+
var import_react59 = require("react");
|
|
15874
15924
|
var import_antd27 = require("antd");
|
|
15875
15925
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
15876
15926
|
var toValuePath = (value, multiple) => {
|
|
@@ -15909,7 +15959,7 @@ function CascadeSelectField(props) {
|
|
|
15909
15959
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
15910
15960
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15911
15961
|
const value = formData[fieldId] ?? (multiple ? [] : []);
|
|
15912
|
-
(0,
|
|
15962
|
+
(0, import_react59.useEffect)(() => {
|
|
15913
15963
|
registerField(fieldId);
|
|
15914
15964
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15915
15965
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -15962,7 +16012,7 @@ function CascadeSelectField(props) {
|
|
|
15962
16012
|
}
|
|
15963
16013
|
|
|
15964
16014
|
// packages/sdk/src/components/fields/AddressField/index.tsx
|
|
15965
|
-
var
|
|
16015
|
+
var import_react60 = require("react");
|
|
15966
16016
|
var import_antd28 = require("antd");
|
|
15967
16017
|
var MobileAntd5 = __toESM(require("antd-mobile"));
|
|
15968
16018
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
@@ -16108,41 +16158,41 @@ function AddressField(props) {
|
|
|
16108
16158
|
const { isMobile } = useDeviceDetect();
|
|
16109
16159
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
16110
16160
|
const rawValue = formData[fieldId];
|
|
16111
|
-
const value = (0,
|
|
16112
|
-
const [options, setOptions] = (0,
|
|
16113
|
-
const [loadingRoots, setLoadingRoots] = (0,
|
|
16114
|
-
const [mobileOpen, setMobileOpen] = (0,
|
|
16115
|
-
const [mobileLevelIndex, setMobileLevelIndex] = (0,
|
|
16116
|
-
const [mobileOptions, setMobileOptions] = (0,
|
|
16117
|
-
const [mobileLoading, setMobileLoading] = (0,
|
|
16118
|
-
const [tempValue, setTempValue] = (0,
|
|
16161
|
+
const value = (0, import_react60.useMemo)(() => normalizeAddressValue(rawValue), [rawValue]);
|
|
16162
|
+
const [options, setOptions] = (0, import_react60.useState)([]);
|
|
16163
|
+
const [loadingRoots, setLoadingRoots] = (0, import_react60.useState)(false);
|
|
16164
|
+
const [mobileOpen, setMobileOpen] = (0, import_react60.useState)(false);
|
|
16165
|
+
const [mobileLevelIndex, setMobileLevelIndex] = (0, import_react60.useState)(0);
|
|
16166
|
+
const [mobileOptions, setMobileOptions] = (0, import_react60.useState)([]);
|
|
16167
|
+
const [mobileLoading, setMobileLoading] = (0, import_react60.useState)(false);
|
|
16168
|
+
const [tempValue, setTempValue] = (0, import_react60.useState)();
|
|
16119
16169
|
const depth = modeDepth(mode);
|
|
16120
|
-
const levels = (0,
|
|
16121
|
-
const valuePath = (0,
|
|
16122
|
-
const displayOptions = (0,
|
|
16170
|
+
const levels = (0, import_react60.useMemo)(() => activeLevels(mode), [mode]);
|
|
16171
|
+
const valuePath = (0, import_react60.useMemo)(() => valueToPath(value, levels), [levels, value]);
|
|
16172
|
+
const displayOptions = (0, import_react60.useMemo)(
|
|
16123
16173
|
() => mergeValuePathIntoOptions(options, value, levels, depth),
|
|
16124
16174
|
[depth, levels, options, value]
|
|
16125
16175
|
);
|
|
16126
16176
|
const detailEnabled = mode === "province-city-district-street-detail";
|
|
16127
16177
|
const disabled = behavior === "DISABLED";
|
|
16128
16178
|
const MobilePopup = getMobileComponent3("Popup");
|
|
16129
|
-
(0,
|
|
16179
|
+
(0, import_react60.useEffect)(() => {
|
|
16130
16180
|
registerField(fieldId);
|
|
16131
16181
|
return () => unregisterField(fieldId);
|
|
16132
16182
|
}, [fieldId, registerField, unregisterField]);
|
|
16133
|
-
(0,
|
|
16183
|
+
(0, import_react60.useEffect)(() => {
|
|
16134
16184
|
if (defaultValue !== void 0 && rawValue === void 0) {
|
|
16135
16185
|
setFieldValue(fieldId, defaultValue);
|
|
16136
16186
|
}
|
|
16137
16187
|
}, [defaultValue, fieldId, rawValue, setFieldValue]);
|
|
16138
|
-
const loadDivisions = (0,
|
|
16188
|
+
const loadDivisions = (0, import_react60.useCallback)(
|
|
16139
16189
|
async (parentAdcode, level, index) => {
|
|
16140
16190
|
const list = await api.getChinaDivisions(parentAdcode);
|
|
16141
16191
|
return list.map((item) => normalizeDivision(item, level, depth, index));
|
|
16142
16192
|
},
|
|
16143
16193
|
[api, depth]
|
|
16144
16194
|
);
|
|
16145
|
-
(0,
|
|
16195
|
+
(0, import_react60.useEffect)(() => {
|
|
16146
16196
|
let mounted = true;
|
|
16147
16197
|
setLoadingRoots(true);
|
|
16148
16198
|
loadDivisions(void 0, "province", 0).then((nextOptions) => {
|
|
@@ -16154,7 +16204,7 @@ function AddressField(props) {
|
|
|
16154
16204
|
mounted = false;
|
|
16155
16205
|
};
|
|
16156
16206
|
}, [loadDivisions]);
|
|
16157
|
-
(0,
|
|
16207
|
+
(0, import_react60.useEffect)(() => {
|
|
16158
16208
|
if (!value) return;
|
|
16159
16209
|
let cancelled = false;
|
|
16160
16210
|
const hydrateMissingLabels = async () => {
|
|
@@ -16190,7 +16240,7 @@ function AddressField(props) {
|
|
|
16190
16240
|
cancelled = true;
|
|
16191
16241
|
};
|
|
16192
16242
|
}, [fieldId, levels, loadDivisions, setFieldValue, value]);
|
|
16193
|
-
(0,
|
|
16243
|
+
(0, import_react60.useEffect)(() => {
|
|
16194
16244
|
if (!mobileOpen) return;
|
|
16195
16245
|
const level = levels[mobileLevelIndex] || "province";
|
|
16196
16246
|
const parentLevel = levels[mobileLevelIndex - 1];
|
|
@@ -16370,7 +16420,7 @@ function AddressField(props) {
|
|
|
16370
16420
|
}
|
|
16371
16421
|
|
|
16372
16422
|
// packages/sdk/src/components/fields/AssociationFormField/index.tsx
|
|
16373
|
-
var
|
|
16423
|
+
var import_react61 = require("react");
|
|
16374
16424
|
var import_antd29 = require("antd");
|
|
16375
16425
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
16376
16426
|
var DEFAULT_PAGE_SIZE = 10;
|
|
@@ -16433,45 +16483,45 @@ function AssociationFormField(props) {
|
|
|
16433
16483
|
const { isMobile } = useDeviceDetect();
|
|
16434
16484
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
16435
16485
|
const rawValue = formData[fieldId];
|
|
16436
|
-
const value = (0,
|
|
16486
|
+
const value = (0, import_react61.useMemo)(() => normalizeValues(rawValue), [rawValue]);
|
|
16437
16487
|
const disabled = behavior === "DISABLED";
|
|
16438
|
-
const [options, setOptions] = (0,
|
|
16439
|
-
const [selectLoading, setSelectLoading] = (0,
|
|
16440
|
-
const [selectorOpen, setSelectorOpen] = (0,
|
|
16441
|
-
const [tableLoading, setTableLoading] = (0,
|
|
16442
|
-
const [tableData, setTableData] = (0,
|
|
16443
|
-
const [keyword, setKeyword] = (0,
|
|
16444
|
-
const [pagination, setPagination] = (0,
|
|
16488
|
+
const [options, setOptions] = (0, import_react61.useState)([]);
|
|
16489
|
+
const [selectLoading, setSelectLoading] = (0, import_react61.useState)(false);
|
|
16490
|
+
const [selectorOpen, setSelectorOpen] = (0, import_react61.useState)(false);
|
|
16491
|
+
const [tableLoading, setTableLoading] = (0, import_react61.useState)(false);
|
|
16492
|
+
const [tableData, setTableData] = (0, import_react61.useState)([]);
|
|
16493
|
+
const [keyword, setKeyword] = (0, import_react61.useState)("");
|
|
16494
|
+
const [pagination, setPagination] = (0, import_react61.useState)({
|
|
16445
16495
|
current: 1,
|
|
16446
16496
|
pageSize: DEFAULT_PAGE_SIZE,
|
|
16447
16497
|
total: 0
|
|
16448
16498
|
});
|
|
16449
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
16450
|
-
const [selectedRecords, setSelectedRecords] = (0,
|
|
16451
|
-
const formDataRef = (0,
|
|
16452
|
-
const associationFormRef = (0,
|
|
16453
|
-
(0,
|
|
16499
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react61.useState)([]);
|
|
16500
|
+
const [selectedRecords, setSelectedRecords] = (0, import_react61.useState)([]);
|
|
16501
|
+
const formDataRef = (0, import_react61.useRef)(formData);
|
|
16502
|
+
const associationFormRef = (0, import_react61.useRef)(associationForm);
|
|
16503
|
+
(0, import_react61.useEffect)(() => {
|
|
16454
16504
|
registerField(fieldId);
|
|
16455
16505
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
16456
16506
|
setFieldValue(fieldId, normalizeValues(defaultValue));
|
|
16457
16507
|
}
|
|
16458
16508
|
return () => unregisterField(fieldId);
|
|
16459
16509
|
}, [fieldId]);
|
|
16460
|
-
(0,
|
|
16510
|
+
(0, import_react61.useEffect)(() => {
|
|
16461
16511
|
formDataRef.current = formData;
|
|
16462
16512
|
}, [formData]);
|
|
16463
|
-
(0,
|
|
16513
|
+
(0, import_react61.useEffect)(() => {
|
|
16464
16514
|
associationFormRef.current = associationForm;
|
|
16465
16515
|
}, [associationForm]);
|
|
16466
16516
|
const associationAppType = associationForm?.appType;
|
|
16467
16517
|
const associationFormUuid = associationForm?.formUuid;
|
|
16468
16518
|
const associationMainFieldId = associationForm?.mainFieldId;
|
|
16469
16519
|
const canQuery = Boolean(associationAppType && associationFormUuid);
|
|
16470
|
-
const filterRulesKey = (0,
|
|
16520
|
+
const filterRulesKey = (0, import_react61.useMemo)(
|
|
16471
16521
|
() => stableSerialize(associationForm?.dataFilterRules || []),
|
|
16472
16522
|
[associationForm?.dataFilterRules]
|
|
16473
16523
|
);
|
|
16474
|
-
const currentFieldFilterKey = (0,
|
|
16524
|
+
const currentFieldFilterKey = (0, import_react61.useMemo)(() => {
|
|
16475
16525
|
const rules = associationForm?.dataFilterRules || [];
|
|
16476
16526
|
return stableSerialize(
|
|
16477
16527
|
rules.map((rule) => {
|
|
@@ -16480,11 +16530,11 @@ function AssociationFormField(props) {
|
|
|
16480
16530
|
})
|
|
16481
16531
|
);
|
|
16482
16532
|
}, [formData, associationForm?.dataFilterRules]);
|
|
16483
|
-
const filterDependencyKey = (0,
|
|
16533
|
+
const filterDependencyKey = (0, import_react61.useMemo)(
|
|
16484
16534
|
() => `${filterRulesKey}:${currentFieldFilterKey}`,
|
|
16485
16535
|
[currentFieldFilterKey, filterRulesKey]
|
|
16486
16536
|
);
|
|
16487
|
-
const normalizeRecord = (0,
|
|
16537
|
+
const normalizeRecord = (0, import_react61.useCallback)(
|
|
16488
16538
|
(record) => {
|
|
16489
16539
|
const mainFieldValue = associationMainFieldId ? record?.[associationMainFieldId] : void 0;
|
|
16490
16540
|
const labelText = normalizeCellValue(mainFieldValue);
|
|
@@ -16497,7 +16547,7 @@ function AssociationFormField(props) {
|
|
|
16497
16547
|
},
|
|
16498
16548
|
[associationMainFieldId]
|
|
16499
16549
|
);
|
|
16500
|
-
const toValue = (0,
|
|
16550
|
+
const toValue = (0, import_react61.useCallback)(
|
|
16501
16551
|
(record) => ({
|
|
16502
16552
|
label: record.__associationLabel,
|
|
16503
16553
|
value: record.__associationValue,
|
|
@@ -16505,7 +16555,7 @@ function AssociationFormField(props) {
|
|
|
16505
16555
|
}),
|
|
16506
16556
|
[]
|
|
16507
16557
|
);
|
|
16508
|
-
const buildFilters = (0,
|
|
16558
|
+
const buildFilters = (0, import_react61.useCallback)(() => {
|
|
16509
16559
|
void filterDependencyKey;
|
|
16510
16560
|
const rules = associationFormRef.current?.dataFilterRules || [];
|
|
16511
16561
|
const currentFormData = formDataRef.current;
|
|
@@ -16521,7 +16571,7 @@ function AssociationFormField(props) {
|
|
|
16521
16571
|
};
|
|
16522
16572
|
}).filter(Boolean);
|
|
16523
16573
|
}, [filterDependencyKey]);
|
|
16524
|
-
const fetchRecords = (0,
|
|
16574
|
+
const fetchRecords = (0, import_react61.useCallback)(
|
|
16525
16575
|
async (params) => {
|
|
16526
16576
|
if (!canQuery) return { list: [], total: 0 };
|
|
16527
16577
|
const filters = buildFilters();
|
|
@@ -16544,7 +16594,7 @@ function AssociationFormField(props) {
|
|
|
16544
16594
|
},
|
|
16545
16595
|
[api, associationAppType, associationFormUuid, buildFilters, canQuery, normalizeRecord]
|
|
16546
16596
|
);
|
|
16547
|
-
const loadOptions = (0,
|
|
16597
|
+
const loadOptions = (0, import_react61.useCallback)(
|
|
16548
16598
|
async (searchKeyWord) => {
|
|
16549
16599
|
setSelectLoading(true);
|
|
16550
16600
|
try {
|
|
@@ -16556,7 +16606,7 @@ function AssociationFormField(props) {
|
|
|
16556
16606
|
},
|
|
16557
16607
|
[fetchRecords, toValue]
|
|
16558
16608
|
);
|
|
16559
|
-
const loadTable = (0,
|
|
16609
|
+
const loadTable = (0, import_react61.useCallback)(
|
|
16560
16610
|
async (next) => {
|
|
16561
16611
|
setTableLoading(true);
|
|
16562
16612
|
const current = next?.current || 1;
|
|
@@ -16575,10 +16625,10 @@ function AssociationFormField(props) {
|
|
|
16575
16625
|
},
|
|
16576
16626
|
[fetchRecords, keyword, pagination.pageSize]
|
|
16577
16627
|
);
|
|
16578
|
-
(0,
|
|
16628
|
+
(0, import_react61.useEffect)(() => {
|
|
16579
16629
|
void loadOptions();
|
|
16580
16630
|
}, [loadOptions]);
|
|
16581
|
-
(0,
|
|
16631
|
+
(0, import_react61.useEffect)(() => {
|
|
16582
16632
|
setSelectedRowKeys(value.map((item) => item.value));
|
|
16583
16633
|
setSelectedRecords(
|
|
16584
16634
|
value.map(
|
|
@@ -16586,7 +16636,7 @@ function AssociationFormField(props) {
|
|
|
16586
16636
|
).filter(Boolean)
|
|
16587
16637
|
);
|
|
16588
16638
|
}, [normalizeRecord, value]);
|
|
16589
|
-
const applyDataFilling = (0,
|
|
16639
|
+
const applyDataFilling = (0, import_react61.useCallback)(
|
|
16590
16640
|
(next) => {
|
|
16591
16641
|
if (!associationForm?.dataFillingEnabled && !associationForm?.dataFillingRules?.mainRules) {
|
|
16592
16642
|
return;
|
|
@@ -16600,7 +16650,7 @@ function AssociationFormField(props) {
|
|
|
16600
16650
|
},
|
|
16601
16651
|
[associationForm?.dataFillingEnabled, associationForm?.dataFillingRules, setFieldValue]
|
|
16602
16652
|
);
|
|
16603
|
-
const commitSelection = (0,
|
|
16653
|
+
const commitSelection = (0, import_react61.useCallback)(
|
|
16604
16654
|
(next) => {
|
|
16605
16655
|
const normalized = multiple ? next : next.slice(0, 1);
|
|
16606
16656
|
setFieldValue(fieldId, normalized);
|
|
@@ -16609,7 +16659,7 @@ function AssociationFormField(props) {
|
|
|
16609
16659
|
},
|
|
16610
16660
|
[applyDataFilling, fieldId, multiple, onChange, setFieldValue]
|
|
16611
16661
|
);
|
|
16612
|
-
const selectorColumns = (0,
|
|
16662
|
+
const selectorColumns = (0, import_react61.useMemo)(() => {
|
|
16613
16663
|
const configured = associationForm?.selectorColumns || [];
|
|
16614
16664
|
if (configured.length) {
|
|
16615
16665
|
return configured.map((column) => {
|
|
@@ -16644,7 +16694,7 @@ function AssociationFormField(props) {
|
|
|
16644
16694
|
}
|
|
16645
16695
|
];
|
|
16646
16696
|
}, [associationForm?.mainFieldId, associationForm?.selectorColumns]);
|
|
16647
|
-
const selectOptions = (0,
|
|
16697
|
+
const selectOptions = (0, import_react61.useMemo)(
|
|
16648
16698
|
() => [...options, ...value].filter(
|
|
16649
16699
|
(item, index, list) => list.findIndex((candidate) => candidate.value === item.value) === index
|
|
16650
16700
|
).map((item) => ({ label: item.label, value: item.value })),
|
|
@@ -16852,9 +16902,9 @@ function AssociationFormField(props) {
|
|
|
16852
16902
|
}
|
|
16853
16903
|
|
|
16854
16904
|
// packages/sdk/src/components/fields/EditorField/index.tsx
|
|
16855
|
-
var
|
|
16905
|
+
var import_react62 = require("react");
|
|
16856
16906
|
var import_core = require("@tiptap/core");
|
|
16857
|
-
var
|
|
16907
|
+
var import_react63 = require("@tiptap/react");
|
|
16858
16908
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
16859
16909
|
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
16860
16910
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
@@ -17488,28 +17538,28 @@ function RichTextEditorCore({
|
|
|
17488
17538
|
fieldId = "richText",
|
|
17489
17539
|
mobile = false
|
|
17490
17540
|
}) {
|
|
17491
|
-
const inputRef = (0,
|
|
17492
|
-
const [uploading, setUploading] = (0,
|
|
17493
|
-
const [uploadError, setUploadError] = (0,
|
|
17494
|
-
const [charCount, setCharCount] = (0,
|
|
17495
|
-
const [linkOpen, setLinkOpen] = (0,
|
|
17496
|
-
const [linkUrl, setLinkUrl] = (0,
|
|
17497
|
-
const [linkError, setLinkError] = (0,
|
|
17498
|
-
const [imageUrlOpen, setImageUrlOpen] = (0,
|
|
17499
|
-
const [imageUrl, setImageUrl] = (0,
|
|
17500
|
-
const [imageAlt, setImageAlt] = (0,
|
|
17501
|
-
const [imageTitle, setImageTitle] = (0,
|
|
17502
|
-
const [imageUrlError, setImageUrlError] = (0,
|
|
17503
|
-
const [tableOpen, setTableOpen] = (0,
|
|
17504
|
-
const [tableRows, setTableRows] = (0,
|
|
17505
|
-
const [tableCols, setTableCols] = (0,
|
|
17506
|
-
const onChangeRef = (0,
|
|
17507
|
-
(0,
|
|
17541
|
+
const inputRef = (0, import_react62.useRef)(null);
|
|
17542
|
+
const [uploading, setUploading] = (0, import_react62.useState)(false);
|
|
17543
|
+
const [uploadError, setUploadError] = (0, import_react62.useState)("");
|
|
17544
|
+
const [charCount, setCharCount] = (0, import_react62.useState)(0);
|
|
17545
|
+
const [linkOpen, setLinkOpen] = (0, import_react62.useState)(false);
|
|
17546
|
+
const [linkUrl, setLinkUrl] = (0, import_react62.useState)("");
|
|
17547
|
+
const [linkError, setLinkError] = (0, import_react62.useState)("");
|
|
17548
|
+
const [imageUrlOpen, setImageUrlOpen] = (0, import_react62.useState)(false);
|
|
17549
|
+
const [imageUrl, setImageUrl] = (0, import_react62.useState)("");
|
|
17550
|
+
const [imageAlt, setImageAlt] = (0, import_react62.useState)("");
|
|
17551
|
+
const [imageTitle, setImageTitle] = (0, import_react62.useState)("");
|
|
17552
|
+
const [imageUrlError, setImageUrlError] = (0, import_react62.useState)("");
|
|
17553
|
+
const [tableOpen, setTableOpen] = (0, import_react62.useState)(false);
|
|
17554
|
+
const [tableRows, setTableRows] = (0, import_react62.useState)(3);
|
|
17555
|
+
const [tableCols, setTableCols] = (0, import_react62.useState)(3);
|
|
17556
|
+
const onChangeRef = (0, import_react62.useRef)(onChange);
|
|
17557
|
+
(0, import_react62.useEffect)(() => {
|
|
17508
17558
|
onChangeRef.current = onChange;
|
|
17509
17559
|
}, [onChange]);
|
|
17510
|
-
const actions = (0,
|
|
17560
|
+
const actions = (0, import_react62.useMemo)(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
|
|
17511
17561
|
const visibleActions = mobile ? [] : actions;
|
|
17512
|
-
const extensions = (0,
|
|
17562
|
+
const extensions = (0, import_react62.useMemo)(
|
|
17513
17563
|
() => [
|
|
17514
17564
|
import_starter_kit.default.configure({
|
|
17515
17565
|
heading: { levels: [1, 2, 3] },
|
|
@@ -17543,10 +17593,10 @@ function RichTextEditorCore({
|
|
|
17543
17593
|
],
|
|
17544
17594
|
[maxLength, placeholder]
|
|
17545
17595
|
);
|
|
17546
|
-
const updateHtml = (0,
|
|
17596
|
+
const updateHtml = (0, import_react62.useCallback)((next) => {
|
|
17547
17597
|
onChangeRef.current?.(next);
|
|
17548
17598
|
}, []);
|
|
17549
|
-
const editor = (0,
|
|
17599
|
+
const editor = (0, import_react63.useEditor)(
|
|
17550
17600
|
{
|
|
17551
17601
|
extensions,
|
|
17552
17602
|
content: value || "",
|
|
@@ -17573,11 +17623,11 @@ function RichTextEditorCore({
|
|
|
17573
17623
|
},
|
|
17574
17624
|
[fieldId, extensions, disabled, maxLength, updateHtml]
|
|
17575
17625
|
);
|
|
17576
|
-
(0,
|
|
17626
|
+
(0, import_react62.useEffect)(() => {
|
|
17577
17627
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17578
17628
|
editor.setEditable(!disabled);
|
|
17579
17629
|
}, [disabled, editor]);
|
|
17580
|
-
(0,
|
|
17630
|
+
(0, import_react62.useEffect)(() => {
|
|
17581
17631
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17582
17632
|
const currentHtml = getSafeEditorHtml(editor);
|
|
17583
17633
|
if ((value || "") !== currentHtml) {
|
|
@@ -17585,7 +17635,7 @@ function RichTextEditorCore({
|
|
|
17585
17635
|
}
|
|
17586
17636
|
setCharCount(countCharacters(editor));
|
|
17587
17637
|
}, [editor, value]);
|
|
17588
|
-
const insertImageFiles = (0,
|
|
17638
|
+
const insertImageFiles = (0, import_react62.useCallback)(
|
|
17589
17639
|
async (files) => {
|
|
17590
17640
|
if (!editor || isEditorDestroyed(editor) || disabled || files.length === 0) return;
|
|
17591
17641
|
const validFiles = files.filter((file) => {
|
|
@@ -17615,7 +17665,7 @@ function RichTextEditorCore({
|
|
|
17615
17665
|
},
|
|
17616
17666
|
[allowedImageTypes, api, disabled, editor, maxImageSize, uploadBucketName]
|
|
17617
17667
|
);
|
|
17618
|
-
const openLinkModal = (0,
|
|
17668
|
+
const openLinkModal = (0, import_react62.useCallback)(() => {
|
|
17619
17669
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17620
17670
|
setLinkUrl(editor.getAttributes("link").href || "");
|
|
17621
17671
|
setLinkError("");
|
|
@@ -17641,7 +17691,7 @@ function RichTextEditorCore({
|
|
|
17641
17691
|
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
17642
17692
|
setLinkOpen(false);
|
|
17643
17693
|
};
|
|
17644
|
-
const openImageUrlModal = (0,
|
|
17694
|
+
const openImageUrlModal = (0, import_react62.useCallback)(() => {
|
|
17645
17695
|
setImageUrl("");
|
|
17646
17696
|
setImageAlt("");
|
|
17647
17697
|
setImageTitle("");
|
|
@@ -17718,7 +17768,7 @@ function RichTextEditorCore({
|
|
|
17718
17768
|
void insertImageFiles(files);
|
|
17719
17769
|
}
|
|
17720
17770
|
},
|
|
17721
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
17771
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_react63.EditorContent, { editor })
|
|
17722
17772
|
}
|
|
17723
17773
|
),
|
|
17724
17774
|
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
@@ -17891,19 +17941,19 @@ function EditorField(props) {
|
|
|
17891
17941
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
17892
17942
|
const rawValue = formData[fieldId] ?? "";
|
|
17893
17943
|
const value = normalizeRichTextHtml(rawValue);
|
|
17894
|
-
(0,
|
|
17944
|
+
(0, import_react62.useEffect)(() => {
|
|
17895
17945
|
registerField(fieldId);
|
|
17896
17946
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
17897
17947
|
setFieldValue(fieldId, normalizeRichTextHtml(defaultValue));
|
|
17898
17948
|
}
|
|
17899
17949
|
return () => unregisterField(fieldId);
|
|
17900
17950
|
}, [fieldId]);
|
|
17901
|
-
(0,
|
|
17951
|
+
(0, import_react62.useEffect)(() => {
|
|
17902
17952
|
if (rawValue && rawValue !== value) {
|
|
17903
17953
|
setFieldValue(fieldId, value);
|
|
17904
17954
|
}
|
|
17905
17955
|
}, [fieldId, rawValue, setFieldValue, value]);
|
|
17906
|
-
const updateHtml = (0,
|
|
17956
|
+
const updateHtml = (0, import_react62.useCallback)(
|
|
17907
17957
|
(next) => {
|
|
17908
17958
|
setFieldValue(fieldId, next);
|
|
17909
17959
|
onChange?.(next);
|
|
@@ -17956,7 +18006,7 @@ function EditorField(props) {
|
|
|
17956
18006
|
}
|
|
17957
18007
|
|
|
17958
18008
|
// packages/sdk/src/components/fields/SerialNumberField/index.tsx
|
|
17959
|
-
var
|
|
18009
|
+
var import_react64 = require("react");
|
|
17960
18010
|
var import_antd31 = require("antd");
|
|
17961
18011
|
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
17962
18012
|
function SerialNumberField(props) {
|
|
@@ -17976,7 +18026,7 @@ function SerialNumberField(props) {
|
|
|
17976
18026
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
17977
18027
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
17978
18028
|
const value = formData[fieldId] ?? "";
|
|
17979
|
-
(0,
|
|
18029
|
+
(0, import_react64.useEffect)(() => {
|
|
17980
18030
|
registerField(fieldId);
|
|
17981
18031
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
17982
18032
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18018,7 +18068,7 @@ function SerialNumberField(props) {
|
|
|
18018
18068
|
}
|
|
18019
18069
|
|
|
18020
18070
|
// packages/sdk/src/components/fields/LocationField/index.tsx
|
|
18021
|
-
var
|
|
18071
|
+
var import_react65 = require("react");
|
|
18022
18072
|
var import_antd32 = require("antd");
|
|
18023
18073
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
18024
18074
|
var getDingTalkApi = () => {
|
|
@@ -18060,9 +18110,9 @@ function LocationField(props) {
|
|
|
18060
18110
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
18061
18111
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
18062
18112
|
const value = formData[fieldId];
|
|
18063
|
-
const [locating, setLocating] = (0,
|
|
18064
|
-
const [error, setError] = (0,
|
|
18065
|
-
(0,
|
|
18113
|
+
const [locating, setLocating] = (0, import_react65.useState)(false);
|
|
18114
|
+
const [error, setError] = (0, import_react65.useState)("");
|
|
18115
|
+
(0, import_react65.useEffect)(() => {
|
|
18066
18116
|
registerField(fieldId);
|
|
18067
18117
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18068
18118
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18203,7 +18253,7 @@ function LocationField(props) {
|
|
|
18203
18253
|
}
|
|
18204
18254
|
|
|
18205
18255
|
// packages/sdk/src/components/fields/DigitalSignatureField/index.tsx
|
|
18206
|
-
var
|
|
18256
|
+
var import_react66 = require("react");
|
|
18207
18257
|
var import_antd33 = require("antd");
|
|
18208
18258
|
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
18209
18259
|
var CANVAS_HEIGHT = 260;
|
|
@@ -18237,21 +18287,21 @@ function DigitalSignatureField(props) {
|
|
|
18237
18287
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
18238
18288
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
18239
18289
|
const value = formData[fieldId];
|
|
18240
|
-
const [open, setOpen] = (0,
|
|
18241
|
-
const [saving, setSaving] = (0,
|
|
18242
|
-
const [drawn, setDrawn] = (0,
|
|
18243
|
-
const [error, setError] = (0,
|
|
18244
|
-
const canvasRef = (0,
|
|
18245
|
-
const drawingRef = (0,
|
|
18246
|
-
const pointsRef = (0,
|
|
18247
|
-
(0,
|
|
18290
|
+
const [open, setOpen] = (0, import_react66.useState)(false);
|
|
18291
|
+
const [saving, setSaving] = (0, import_react66.useState)(false);
|
|
18292
|
+
const [drawn, setDrawn] = (0, import_react66.useState)(false);
|
|
18293
|
+
const [error, setError] = (0, import_react66.useState)("");
|
|
18294
|
+
const canvasRef = (0, import_react66.useRef)(null);
|
|
18295
|
+
const drawingRef = (0, import_react66.useRef)(false);
|
|
18296
|
+
const pointsRef = (0, import_react66.useRef)([]);
|
|
18297
|
+
(0, import_react66.useEffect)(() => {
|
|
18248
18298
|
registerField(fieldId);
|
|
18249
18299
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18250
18300
|
setFieldValue(fieldId, defaultValue);
|
|
18251
18301
|
}
|
|
18252
18302
|
return () => unregisterField(fieldId);
|
|
18253
18303
|
}, [fieldId]);
|
|
18254
|
-
const prepareCanvas = (0,
|
|
18304
|
+
const prepareCanvas = (0, import_react66.useCallback)(() => {
|
|
18255
18305
|
const canvas = canvasRef.current;
|
|
18256
18306
|
if (!canvas) return;
|
|
18257
18307
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -18273,7 +18323,7 @@ function DigitalSignatureField(props) {
|
|
|
18273
18323
|
ctx.lineJoin = "round";
|
|
18274
18324
|
ctx.strokeStyle = "#111827";
|
|
18275
18325
|
}, []);
|
|
18276
|
-
(0,
|
|
18326
|
+
(0, import_react66.useEffect)(() => {
|
|
18277
18327
|
if (!open) return;
|
|
18278
18328
|
pointsRef.current = [];
|
|
18279
18329
|
setDrawn(false);
|
|
@@ -18452,7 +18502,7 @@ function DigitalSignatureField(props) {
|
|
|
18452
18502
|
}
|
|
18453
18503
|
|
|
18454
18504
|
// packages/sdk/src/components/fields/JSONField/index.tsx
|
|
18455
|
-
var
|
|
18505
|
+
var import_react67 = require("react");
|
|
18456
18506
|
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
18457
18507
|
var formatJson = (value) => {
|
|
18458
18508
|
if (value === void 0 || value === null || value === "") return "--";
|
|
@@ -18479,7 +18529,7 @@ function JSONField(props) {
|
|
|
18479
18529
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
18480
18530
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
18481
18531
|
const value = formData[fieldId];
|
|
18482
|
-
(0,
|
|
18532
|
+
(0, import_react67.useEffect)(() => {
|
|
18483
18533
|
registerField(fieldId);
|
|
18484
18534
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18485
18535
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18951,9 +19001,9 @@ function FormProvider({
|
|
|
18951
19001
|
runtime,
|
|
18952
19002
|
children
|
|
18953
19003
|
}) {
|
|
18954
|
-
const api = (0,
|
|
18955
|
-
const [runtimeDefaults, setRuntimeDefaults] = (0,
|
|
18956
|
-
const effects = (0,
|
|
19004
|
+
const api = (0, import_react68.useMemo)(() => createFormRuntimeApi(config.api), [config.api]);
|
|
19005
|
+
const [runtimeDefaults, setRuntimeDefaults] = (0, import_react68.useState)({});
|
|
19006
|
+
const effects = (0, import_react68.useMemo)(
|
|
18957
19007
|
() => [
|
|
18958
19008
|
...schema.rules ?? [],
|
|
18959
19009
|
...schema.fields.flatMap((field) => field.optionEffects ?? []),
|
|
@@ -18961,18 +19011,18 @@ function FormProvider({
|
|
|
18961
19011
|
],
|
|
18962
19012
|
[schema.rules, schema.fields, config.effects]
|
|
18963
19013
|
);
|
|
18964
|
-
const defaultRuntime = (0,
|
|
19014
|
+
const defaultRuntime = (0, import_react68.useMemo)(
|
|
18965
19015
|
() => ({
|
|
18966
19016
|
appType: config.appType,
|
|
18967
19017
|
fetchFormData: (params) => fetchRuntimeFormData(api, config.appType, params)
|
|
18968
19018
|
}),
|
|
18969
19019
|
[api, config.appType]
|
|
18970
19020
|
);
|
|
18971
|
-
const mergedRuntime = (0,
|
|
19021
|
+
const mergedRuntime = (0, import_react68.useMemo)(
|
|
18972
19022
|
() => ({ ...defaultRuntime, ...schema.runtime, ...runtimeDefaults, ...runtime }),
|
|
18973
19023
|
[defaultRuntime, schema.runtime, runtimeDefaults, runtime]
|
|
18974
19024
|
);
|
|
18975
|
-
const computedInitialValues = (0,
|
|
19025
|
+
const computedInitialValues = (0, import_react68.useMemo)(() => {
|
|
18976
19026
|
const values = {};
|
|
18977
19027
|
for (const field of schema.fields) {
|
|
18978
19028
|
const defaultValue = resolveDefaultValue(field, mergedRuntime);
|
|
@@ -18982,11 +19032,11 @@ function FormProvider({
|
|
|
18982
19032
|
}
|
|
18983
19033
|
return { ...values, ...initialValues };
|
|
18984
19034
|
}, [schema, initialValues, mergedRuntime]);
|
|
18985
|
-
const initialValuesRef = (0,
|
|
18986
|
-
const [formData, setFormData] = (0,
|
|
18987
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
18988
|
-
const [registeredFields] = (0,
|
|
18989
|
-
(0,
|
|
19035
|
+
const initialValuesRef = (0, import_react68.useRef)(computedInitialValues);
|
|
19036
|
+
const [formData, setFormData] = (0, import_react68.useState)({ ...computedInitialValues });
|
|
19037
|
+
const [fieldErrors, setFieldErrors] = (0, import_react68.useState)({});
|
|
19038
|
+
const [registeredFields] = (0, import_react68.useState)(/* @__PURE__ */ new Set());
|
|
19039
|
+
(0, import_react68.useEffect)(() => {
|
|
18990
19040
|
if (!schema.fields.some((field) => needsCurrentUserRuntime(field.defaultShortcut?.type)))
|
|
18991
19041
|
return;
|
|
18992
19042
|
if (mergedRuntime.currentUser && mergedRuntime.currentDepartment) return;
|
|
@@ -19010,7 +19060,7 @@ function FormProvider({
|
|
|
19010
19060
|
cancelled = true;
|
|
19011
19061
|
};
|
|
19012
19062
|
}, [api, mergedRuntime.currentDepartment, mergedRuntime.currentUser, schema.fields]);
|
|
19013
|
-
(0,
|
|
19063
|
+
(0, import_react68.useEffect)(() => {
|
|
19014
19064
|
setFormData((prev) => {
|
|
19015
19065
|
let changed = false;
|
|
19016
19066
|
const next = { ...prev };
|
|
@@ -19024,7 +19074,7 @@ function FormProvider({
|
|
|
19024
19074
|
return changed ? next : prev;
|
|
19025
19075
|
});
|
|
19026
19076
|
}, [mergedRuntime, schema.fields]);
|
|
19027
|
-
const fieldBehaviors = (0,
|
|
19077
|
+
const fieldBehaviors = (0, import_react68.useMemo)(() => {
|
|
19028
19078
|
const baseBehaviors = {};
|
|
19029
19079
|
for (const field of schema.fields) {
|
|
19030
19080
|
baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
|
|
@@ -19047,15 +19097,15 @@ function FormProvider({
|
|
|
19047
19097
|
}
|
|
19048
19098
|
return computed;
|
|
19049
19099
|
}, [schema, effects, config.permissions, config.mode, formData]);
|
|
19050
|
-
const fieldOverrides = (0,
|
|
19100
|
+
const fieldOverrides = (0, import_react68.useMemo)(
|
|
19051
19101
|
() => evaluateFieldOverrides(effects, formData),
|
|
19052
19102
|
[effects, formData]
|
|
19053
19103
|
);
|
|
19054
|
-
const layoutBehaviors = (0,
|
|
19104
|
+
const layoutBehaviors = (0, import_react68.useMemo)(
|
|
19055
19105
|
() => evaluateLayoutBehaviors(effects, formData),
|
|
19056
19106
|
[effects, formData]
|
|
19057
19107
|
);
|
|
19058
|
-
(0,
|
|
19108
|
+
(0, import_react68.useEffect)(() => {
|
|
19059
19109
|
const valueActions = getValueActions(effects, formData);
|
|
19060
19110
|
if (valueActions.length === 0) return;
|
|
19061
19111
|
let changed = false;
|
|
@@ -19078,7 +19128,7 @@ function FormProvider({
|
|
|
19078
19128
|
setFieldErrors(nextErrors);
|
|
19079
19129
|
}
|
|
19080
19130
|
}, [effects, formData, fieldErrors]);
|
|
19081
|
-
const setFieldValue = (0,
|
|
19131
|
+
const setFieldValue = (0, import_react68.useCallback)((fieldId, value) => {
|
|
19082
19132
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
19083
19133
|
setFieldErrors((prev) => {
|
|
19084
19134
|
if (prev[fieldId]) {
|
|
@@ -19089,9 +19139,9 @@ function FormProvider({
|
|
|
19089
19139
|
return prev;
|
|
19090
19140
|
});
|
|
19091
19141
|
}, []);
|
|
19092
|
-
const getFieldValue = (0,
|
|
19093
|
-
const getFormData2 = (0,
|
|
19094
|
-
const validateFieldById = (0,
|
|
19142
|
+
const getFieldValue = (0, import_react68.useCallback)((fieldId) => formData[fieldId], [formData]);
|
|
19143
|
+
const getFormData2 = (0, import_react68.useCallback)(() => ({ ...formData }), [formData]);
|
|
19144
|
+
const validateFieldById = (0, import_react68.useCallback)(
|
|
19095
19145
|
async (fieldId) => {
|
|
19096
19146
|
const field = schema.fields.find((f) => f.fieldId === fieldId);
|
|
19097
19147
|
if (!field) {
|
|
@@ -19152,7 +19202,7 @@ function FormProvider({
|
|
|
19152
19202
|
},
|
|
19153
19203
|
[schema, formData, fieldBehaviors, fieldOverrides]
|
|
19154
19204
|
);
|
|
19155
|
-
const validateAllWithErrors = (0,
|
|
19205
|
+
const validateAllWithErrors = (0, import_react68.useCallback)(async () => {
|
|
19156
19206
|
const fieldRules = {};
|
|
19157
19207
|
const validationData = { ...formData };
|
|
19158
19208
|
for (const field of schema.fields) {
|
|
@@ -19176,28 +19226,28 @@ function FormProvider({
|
|
|
19176
19226
|
setFieldErrors(errors);
|
|
19177
19227
|
return errors;
|
|
19178
19228
|
}, [schema, formData, fieldBehaviors, fieldOverrides]);
|
|
19179
|
-
const validateAll = (0,
|
|
19229
|
+
const validateAll = (0, import_react68.useCallback)(async () => {
|
|
19180
19230
|
const errors = await validateAllWithErrors();
|
|
19181
19231
|
return Object.keys(errors).length === 0;
|
|
19182
19232
|
}, [validateAllWithErrors]);
|
|
19183
|
-
const resetForm = (0,
|
|
19233
|
+
const resetForm = (0, import_react68.useCallback)(() => {
|
|
19184
19234
|
setFormData({ ...initialValuesRef.current });
|
|
19185
19235
|
setFieldErrors({});
|
|
19186
19236
|
}, []);
|
|
19187
|
-
const registerField = (0,
|
|
19237
|
+
const registerField = (0, import_react68.useCallback)(
|
|
19188
19238
|
(fieldId) => {
|
|
19189
19239
|
registeredFields.add(fieldId);
|
|
19190
19240
|
},
|
|
19191
19241
|
[registeredFields]
|
|
19192
19242
|
);
|
|
19193
|
-
const unregisterField = (0,
|
|
19243
|
+
const unregisterField = (0, import_react68.useCallback)(
|
|
19194
19244
|
(fieldId) => {
|
|
19195
19245
|
registeredFields.delete(fieldId);
|
|
19196
19246
|
},
|
|
19197
19247
|
[registeredFields]
|
|
19198
19248
|
);
|
|
19199
|
-
const [dynamicOptions, setDynamicOptions] = (0,
|
|
19200
|
-
(0,
|
|
19249
|
+
const [dynamicOptions, setDynamicOptions] = (0, import_react68.useState)({});
|
|
19250
|
+
(0, import_react68.useEffect)(() => {
|
|
19201
19251
|
const loadDynamicOptions = async () => {
|
|
19202
19252
|
const updates = {};
|
|
19203
19253
|
for (const field of schema.fields) {
|
|
@@ -19215,7 +19265,7 @@ function FormProvider({
|
|
|
19215
19265
|
};
|
|
19216
19266
|
loadDynamicOptions();
|
|
19217
19267
|
}, [schema.fields, mergedRuntime]);
|
|
19218
|
-
(0,
|
|
19268
|
+
(0, import_react68.useEffect)(() => {
|
|
19219
19269
|
let cancelled = false;
|
|
19220
19270
|
const loadDataLinkageOptions = async () => {
|
|
19221
19271
|
const updates = {};
|
|
@@ -19241,7 +19291,7 @@ function FormProvider({
|
|
|
19241
19291
|
window.clearTimeout(timer);
|
|
19242
19292
|
};
|
|
19243
19293
|
}, [schema.fields, mergedRuntime, formData]);
|
|
19244
|
-
(0,
|
|
19294
|
+
(0, import_react68.useEffect)(() => {
|
|
19245
19295
|
let cancelled = false;
|
|
19246
19296
|
const loadDefaultValueLinkages = async () => {
|
|
19247
19297
|
const fields = schema.fields.filter((field) => field.defaultValueLinkage);
|
|
@@ -19275,7 +19325,7 @@ function FormProvider({
|
|
|
19275
19325
|
window.clearTimeout(timer);
|
|
19276
19326
|
};
|
|
19277
19327
|
}, [schema.fields, mergedRuntime, formData]);
|
|
19278
|
-
const contextValue = (0,
|
|
19328
|
+
const contextValue = (0, import_react68.useMemo)(
|
|
19279
19329
|
() => ({
|
|
19280
19330
|
mode: config.mode,
|
|
19281
19331
|
schema,
|
|
@@ -19331,10 +19381,10 @@ function FormProvider({
|
|
|
19331
19381
|
]
|
|
19332
19382
|
);
|
|
19333
19383
|
const registryComponents = components ?? defaultComponentRegistry;
|
|
19334
|
-
return
|
|
19384
|
+
return import_react68.default.createElement(
|
|
19335
19385
|
FormContext.Provider,
|
|
19336
19386
|
{ value: contextValue },
|
|
19337
|
-
|
|
19387
|
+
import_react68.default.createElement(ComponentRegistryProvider, { components: registryComponents, children })
|
|
19338
19388
|
);
|
|
19339
19389
|
}
|
|
19340
19390
|
function resolveDefaultValue(field, runtime) {
|
|
@@ -19445,11 +19495,11 @@ function coerceLinkedDefaultValue(field, value) {
|
|
|
19445
19495
|
}
|
|
19446
19496
|
|
|
19447
19497
|
// packages/sdk/src/components/core/FormRenderer.tsx
|
|
19448
|
-
var
|
|
19498
|
+
var import_react72 = __toESM(require("react"));
|
|
19449
19499
|
|
|
19450
19500
|
// packages/sdk/src/components/layout/FormSection/index.tsx
|
|
19451
19501
|
var import_icons14 = require("@ant-design/icons");
|
|
19452
|
-
var
|
|
19502
|
+
var import_react69 = require("react");
|
|
19453
19503
|
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
19454
19504
|
var sectionIconMap = {
|
|
19455
19505
|
user: import_icons14.UserOutlined,
|
|
@@ -19474,7 +19524,7 @@ function FormSection({
|
|
|
19474
19524
|
contentClassName,
|
|
19475
19525
|
children
|
|
19476
19526
|
}) {
|
|
19477
|
-
const [collapsed, setCollapsed] = (0,
|
|
19527
|
+
const [collapsed, setCollapsed] = (0, import_react69.useState)(defaultCollapsed);
|
|
19478
19528
|
const handleToggle = () => {
|
|
19479
19529
|
if (collapsible) {
|
|
19480
19530
|
setCollapsed((prev) => !prev);
|
|
@@ -19603,10 +19653,10 @@ function FormGrid({
|
|
|
19603
19653
|
}
|
|
19604
19654
|
|
|
19605
19655
|
// packages/sdk/src/components/layout/FormTabs/index.tsx
|
|
19606
|
-
var
|
|
19656
|
+
var import_react70 = require("react");
|
|
19607
19657
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
19608
19658
|
function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
19609
|
-
const [activeKey, setActiveKey] = (0,
|
|
19659
|
+
const [activeKey, setActiveKey] = (0, import_react70.useState)(defaultActiveKey || items[0]?.key || "");
|
|
19610
19660
|
const activeItem = items.find((item) => item.key === activeKey);
|
|
19611
19661
|
return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-tabs", children: [
|
|
19612
19662
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
@@ -19635,10 +19685,10 @@ function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
|
19635
19685
|
}
|
|
19636
19686
|
|
|
19637
19687
|
// packages/sdk/src/components/layout/FormSteps/index.tsx
|
|
19638
|
-
var
|
|
19688
|
+
var import_react71 = __toESM(require("react"));
|
|
19639
19689
|
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
19640
19690
|
function FormSteps({ items, className, onStepChange }) {
|
|
19641
|
-
const [currentStep, setCurrentStep] = (0,
|
|
19691
|
+
const [currentStep, setCurrentStep] = (0, import_react71.useState)(0);
|
|
19642
19692
|
const goTo = (step) => {
|
|
19643
19693
|
setCurrentStep(step);
|
|
19644
19694
|
onStepChange?.(step);
|
|
@@ -19654,7 +19704,7 @@ function FormSteps({ items, className, onStepChange }) {
|
|
|
19654
19704
|
}
|
|
19655
19705
|
};
|
|
19656
19706
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-steps", children: [
|
|
19657
|
-
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center mb-6", "data-testid": "form-steps-indicator", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
19707
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center mb-6", "data-testid": "form-steps-indicator", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_react71.default.Fragment, { children: [
|
|
19658
19708
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex items-center", children: [
|
|
19659
19709
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
19660
19710
|
"div",
|
|
@@ -19755,7 +19805,7 @@ function FieldRenderer({
|
|
|
19755
19805
|
return null;
|
|
19756
19806
|
}
|
|
19757
19807
|
const { fieldId, componentName: _, ...fieldProps } = field;
|
|
19758
|
-
const element =
|
|
19808
|
+
const element = import_react72.default.createElement(Component, {
|
|
19759
19809
|
...fieldProps,
|
|
19760
19810
|
fieldId,
|
|
19761
19811
|
className: fieldClassName ?? fieldProps.className
|
|
@@ -19919,7 +19969,7 @@ function FormRenderer({
|
|
|
19919
19969
|
const gridClass = columnsClassMap[columns];
|
|
19920
19970
|
const gapClass = sizeClassMap[size];
|
|
19921
19971
|
const containerClassName = ["sy-form-renderer", "sy-grid", gridClass, gapClass, className].filter(Boolean).join(" ");
|
|
19922
|
-
const fieldMap =
|
|
19972
|
+
const fieldMap = import_react72.default.useMemo(() => {
|
|
19923
19973
|
return new Map(
|
|
19924
19974
|
schema.fields.map((field) => [
|
|
19925
19975
|
field.fieldId,
|
|
@@ -19990,7 +20040,7 @@ function isLayoutVisible(visibleWhen, formData) {
|
|
|
19990
20040
|
}
|
|
19991
20041
|
|
|
19992
20042
|
// packages/sdk/src/components/core/FormShell.tsx
|
|
19993
|
-
var
|
|
20043
|
+
var import_react73 = require("react");
|
|
19994
20044
|
var Antd2 = __toESM(require("antd"));
|
|
19995
20045
|
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
19996
20046
|
function normalizeMaxWidth(maxWidth) {
|
|
@@ -20020,10 +20070,10 @@ function FormShell({ children, appearance, className }) {
|
|
|
20020
20070
|
const [form] = useAntForm();
|
|
20021
20071
|
const { formData, setFieldValue } = useFormContext();
|
|
20022
20072
|
const maxWidth = normalizeMaxWidth(appearance?.maxWidth);
|
|
20023
|
-
(0,
|
|
20073
|
+
(0, import_react73.useEffect)(() => {
|
|
20024
20074
|
form?.setFieldsValue?.(formData);
|
|
20025
20075
|
}, [form, formData]);
|
|
20026
|
-
const style = (0,
|
|
20076
|
+
const style = (0, import_react73.useMemo)(() => {
|
|
20027
20077
|
if (!maxWidth) return void 0;
|
|
20028
20078
|
return {
|
|
20029
20079
|
maxWidth,
|
|
@@ -20089,7 +20139,7 @@ async function validateAndNotify(validateAllWithErrors) {
|
|
|
20089
20139
|
}
|
|
20090
20140
|
|
|
20091
20141
|
// packages/sdk/src/components/hooks/useFormDetail.ts
|
|
20092
|
-
var
|
|
20142
|
+
var import_react74 = require("react");
|
|
20093
20143
|
|
|
20094
20144
|
// packages/sdk/src/components/utils/formInstanceData.ts
|
|
20095
20145
|
var FORM_INSTANCE_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -20286,24 +20336,24 @@ function useFormDetail(options) {
|
|
|
20286
20336
|
const { formUuid, appType, formInstanceId, fieldIds, onPermissionDenied } = options;
|
|
20287
20337
|
const { api } = useFormContext();
|
|
20288
20338
|
const request = api.request;
|
|
20289
|
-
const [loading, setLoading] = (0,
|
|
20290
|
-
const [mode, setMode] = (0,
|
|
20291
|
-
const [formData, setFormData] = (0,
|
|
20292
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
20293
|
-
const [permissions, setPermissions] = (0,
|
|
20294
|
-
const mountedRef = (0,
|
|
20295
|
-
const onPermissionDeniedRef = (0,
|
|
20339
|
+
const [loading, setLoading] = (0, import_react74.useState)(true);
|
|
20340
|
+
const [mode, setMode] = (0, import_react74.useState)("readonly");
|
|
20341
|
+
const [formData, setFormData] = (0, import_react74.useState)(null);
|
|
20342
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react74.useState)(null);
|
|
20343
|
+
const [permissions, setPermissions] = (0, import_react74.useState)(null);
|
|
20344
|
+
const mountedRef = (0, import_react74.useRef)(true);
|
|
20345
|
+
const onPermissionDeniedRef = (0, import_react74.useRef)(onPermissionDenied);
|
|
20296
20346
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
20297
|
-
(0,
|
|
20347
|
+
(0, import_react74.useEffect)(() => {
|
|
20298
20348
|
mountedRef.current = true;
|
|
20299
20349
|
return () => {
|
|
20300
20350
|
mountedRef.current = false;
|
|
20301
20351
|
};
|
|
20302
20352
|
}, []);
|
|
20303
|
-
(0,
|
|
20353
|
+
(0, import_react74.useEffect)(() => {
|
|
20304
20354
|
onPermissionDeniedRef.current = onPermissionDenied;
|
|
20305
20355
|
}, [onPermissionDenied]);
|
|
20306
|
-
const loadData = (0,
|
|
20356
|
+
const loadData = (0, import_react74.useCallback)(async () => {
|
|
20307
20357
|
if (!mountedRef.current) return;
|
|
20308
20358
|
setLoading(true);
|
|
20309
20359
|
try {
|
|
@@ -20338,21 +20388,21 @@ function useFormDetail(options) {
|
|
|
20338
20388
|
}
|
|
20339
20389
|
}
|
|
20340
20390
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
20341
|
-
(0,
|
|
20391
|
+
(0, import_react74.useEffect)(() => {
|
|
20342
20392
|
loadData();
|
|
20343
20393
|
}, [loadData]);
|
|
20344
20394
|
const fieldBehaviors = normalizeFieldBehaviors(permissions, mode);
|
|
20345
20395
|
const canEdit = hasViewOperation(permissions?.operations, "edit");
|
|
20346
20396
|
const canDelete = hasViewOperation(permissions?.operations, "delete");
|
|
20347
20397
|
const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
|
|
20348
|
-
const switchToEdit = (0,
|
|
20398
|
+
const switchToEdit = (0, import_react74.useCallback)(() => {
|
|
20349
20399
|
setMode("edit");
|
|
20350
20400
|
loadData();
|
|
20351
20401
|
}, [loadData]);
|
|
20352
|
-
const switchToReadonly = (0,
|
|
20402
|
+
const switchToReadonly = (0, import_react74.useCallback)(() => {
|
|
20353
20403
|
setMode("readonly");
|
|
20354
20404
|
}, []);
|
|
20355
|
-
const saveChanges = (0,
|
|
20405
|
+
const saveChanges = (0, import_react74.useCallback)(
|
|
20356
20406
|
async (values) => {
|
|
20357
20407
|
try {
|
|
20358
20408
|
await api.updateFormData({
|
|
@@ -20373,7 +20423,7 @@ function useFormDetail(options) {
|
|
|
20373
20423
|
},
|
|
20374
20424
|
[api, formInstanceId, formUuid, appType]
|
|
20375
20425
|
);
|
|
20376
|
-
const deleteInstance = (0,
|
|
20426
|
+
const deleteInstance = (0, import_react74.useCallback)(async () => {
|
|
20377
20427
|
try {
|
|
20378
20428
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
20379
20429
|
return true;
|
|
@@ -20400,7 +20450,7 @@ function useFormDetail(options) {
|
|
|
20400
20450
|
}
|
|
20401
20451
|
|
|
20402
20452
|
// packages/sdk/src/components/hooks/useChangeRecords.ts
|
|
20403
|
-
var
|
|
20453
|
+
var import_react75 = require("react");
|
|
20404
20454
|
var normalizeChangeRecordList = (value) => {
|
|
20405
20455
|
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;
|
|
20406
20456
|
const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
|
|
@@ -20415,18 +20465,18 @@ function useChangeRecords(options) {
|
|
|
20415
20465
|
const { formUuid, appType, formInstanceId, pageSize = 20, autoLoad = true } = options;
|
|
20416
20466
|
const { api } = useFormContext();
|
|
20417
20467
|
const request = api.request;
|
|
20418
|
-
const [records, setRecords] = (0,
|
|
20419
|
-
const [loading, setLoading] = (0,
|
|
20420
|
-
const [total, setTotal] = (0,
|
|
20421
|
-
const [page, setPage] = (0,
|
|
20422
|
-
const mountedRef = (0,
|
|
20423
|
-
(0,
|
|
20468
|
+
const [records, setRecords] = (0, import_react75.useState)([]);
|
|
20469
|
+
const [loading, setLoading] = (0, import_react75.useState)(false);
|
|
20470
|
+
const [total, setTotal] = (0, import_react75.useState)(0);
|
|
20471
|
+
const [page, setPage] = (0, import_react75.useState)(1);
|
|
20472
|
+
const mountedRef = (0, import_react75.useRef)(true);
|
|
20473
|
+
(0, import_react75.useEffect)(() => {
|
|
20424
20474
|
mountedRef.current = true;
|
|
20425
20475
|
return () => {
|
|
20426
20476
|
mountedRef.current = false;
|
|
20427
20477
|
};
|
|
20428
20478
|
}, []);
|
|
20429
|
-
const fetchRecords = (0,
|
|
20479
|
+
const fetchRecords = (0, import_react75.useCallback)(
|
|
20430
20480
|
async (pageNum, append) => {
|
|
20431
20481
|
if (!mountedRef.current) return;
|
|
20432
20482
|
setLoading(true);
|
|
@@ -20457,18 +20507,18 @@ function useChangeRecords(options) {
|
|
|
20457
20507
|
},
|
|
20458
20508
|
[request, formUuid, appType, formInstanceId, pageSize]
|
|
20459
20509
|
);
|
|
20460
|
-
(0,
|
|
20510
|
+
(0, import_react75.useEffect)(() => {
|
|
20461
20511
|
if (autoLoad) {
|
|
20462
20512
|
fetchRecords(1, false);
|
|
20463
20513
|
}
|
|
20464
20514
|
}, [autoLoad, fetchRecords]);
|
|
20465
20515
|
const safeRecords = Array.isArray(records) ? records : [];
|
|
20466
20516
|
const hasMore = safeRecords.length < total;
|
|
20467
|
-
const loadMore = (0,
|
|
20517
|
+
const loadMore = (0, import_react75.useCallback)(async () => {
|
|
20468
20518
|
if (!hasMore || loading) return;
|
|
20469
20519
|
await fetchRecords(page + 1, true);
|
|
20470
20520
|
}, [hasMore, loading, page, fetchRecords]);
|
|
20471
|
-
const refresh = (0,
|
|
20521
|
+
const refresh = (0, import_react75.useCallback)(async () => {
|
|
20472
20522
|
setRecords([]);
|
|
20473
20523
|
setPage(1);
|
|
20474
20524
|
setTotal(0);
|
|
@@ -20622,7 +20672,7 @@ var SummaryPanel = ({
|
|
|
20622
20672
|
};
|
|
20623
20673
|
|
|
20624
20674
|
// packages/sdk/src/components/modules/RecordChangePanel.tsx
|
|
20625
|
-
var
|
|
20675
|
+
var import_react76 = require("react");
|
|
20626
20676
|
var import_antd37 = require("antd");
|
|
20627
20677
|
var import_icons16 = require("@ant-design/icons");
|
|
20628
20678
|
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
@@ -20668,7 +20718,7 @@ var RecordChangePanel = ({
|
|
|
20668
20718
|
onPageChange,
|
|
20669
20719
|
className = ""
|
|
20670
20720
|
}) => {
|
|
20671
|
-
const [expanded, setExpanded] = (0,
|
|
20721
|
+
const [expanded, setExpanded] = (0, import_react76.useState)(defaultExpanded);
|
|
20672
20722
|
const count = total ?? records.length;
|
|
20673
20723
|
const handleToggle = () => {
|
|
20674
20724
|
const next = !expanded;
|
|
@@ -20879,10 +20929,10 @@ var InnerDetailContent = ({
|
|
|
20879
20929
|
onSave,
|
|
20880
20930
|
inDrawer = false
|
|
20881
20931
|
}) => {
|
|
20882
|
-
const formDataRef = (0,
|
|
20883
|
-
const validateRef = (0,
|
|
20884
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
20885
|
-
const fieldIds = (0,
|
|
20932
|
+
const formDataRef = (0, import_react77.useRef)(void 0);
|
|
20933
|
+
const validateRef = (0, import_react77.useRef)(void 0);
|
|
20934
|
+
const [accessDenied, setAccessDenied] = (0, import_react77.useState)(false);
|
|
20935
|
+
const fieldIds = (0, import_react77.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
20886
20936
|
const {
|
|
20887
20937
|
loading,
|
|
20888
20938
|
mode,
|
|
@@ -20917,7 +20967,7 @@ var InnerDetailContent = ({
|
|
|
20917
20967
|
formInstanceId,
|
|
20918
20968
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
20919
20969
|
});
|
|
20920
|
-
const handleSave = (0,
|
|
20970
|
+
const handleSave = (0, import_react77.useCallback)(async () => {
|
|
20921
20971
|
if (validateRef.current && !await validateAndNotify(validateRef.current)) return;
|
|
20922
20972
|
const values = formDataRef.current?.() ?? formData;
|
|
20923
20973
|
if (!values) return;
|
|
@@ -20926,13 +20976,13 @@ var InnerDetailContent = ({
|
|
|
20926
20976
|
onSave?.(values);
|
|
20927
20977
|
}
|
|
20928
20978
|
}, [formData, saveChanges, onSave]);
|
|
20929
|
-
const handleDelete = (0,
|
|
20979
|
+
const handleDelete = (0, import_react77.useCallback)(async () => {
|
|
20930
20980
|
const success = await deleteInstance();
|
|
20931
20981
|
if (success) {
|
|
20932
20982
|
onDelete?.();
|
|
20933
20983
|
}
|
|
20934
20984
|
}, [deleteInstance, onDelete]);
|
|
20935
|
-
const handleCancel = (0,
|
|
20985
|
+
const handleCancel = (0, import_react77.useCallback)(() => {
|
|
20936
20986
|
switchToReadonly();
|
|
20937
20987
|
}, [switchToReadonly]);
|
|
20938
20988
|
const readonlyActions = [];
|
|
@@ -21059,12 +21109,12 @@ var FormDetailTemplate = (props) => {
|
|
|
21059
21109
|
};
|
|
21060
21110
|
|
|
21061
21111
|
// packages/sdk/src/components/templates/FormSubmitTemplate.tsx
|
|
21062
|
-
var
|
|
21112
|
+
var import_react80 = require("react");
|
|
21063
21113
|
var import_antd40 = require("antd");
|
|
21064
21114
|
var import_icons18 = require("@ant-design/icons");
|
|
21065
21115
|
|
|
21066
21116
|
// packages/sdk/src/components/hooks/useDraftStorage.ts
|
|
21067
|
-
var
|
|
21117
|
+
var import_react78 = require("react");
|
|
21068
21118
|
function getDraftKey(appType, formUuid) {
|
|
21069
21119
|
return `${appType}__${formUuid}__draft`;
|
|
21070
21120
|
}
|
|
@@ -21084,10 +21134,10 @@ function readDraft(key) {
|
|
|
21084
21134
|
function useDraftStorage(options) {
|
|
21085
21135
|
const { appType, formUuid, autoRestore = false } = options;
|
|
21086
21136
|
const key = getDraftKey(appType, formUuid);
|
|
21087
|
-
const [hasDraft, setHasDraft] = (0,
|
|
21088
|
-
const [draftData, setDraftData] = (0,
|
|
21089
|
-
const [draftTimestamp, setDraftTimestamp] = (0,
|
|
21090
|
-
(0,
|
|
21137
|
+
const [hasDraft, setHasDraft] = (0, import_react78.useState)(false);
|
|
21138
|
+
const [draftData, setDraftData] = (0, import_react78.useState)(null);
|
|
21139
|
+
const [draftTimestamp, setDraftTimestamp] = (0, import_react78.useState)(null);
|
|
21140
|
+
(0, import_react78.useEffect)(() => {
|
|
21091
21141
|
const stored = readDraft(key);
|
|
21092
21142
|
if (stored) {
|
|
21093
21143
|
setHasDraft(true);
|
|
@@ -21101,7 +21151,7 @@ function useDraftStorage(options) {
|
|
|
21101
21151
|
setDraftTimestamp(null);
|
|
21102
21152
|
}
|
|
21103
21153
|
}, [key, autoRestore]);
|
|
21104
|
-
const saveDraft = (0,
|
|
21154
|
+
const saveDraft = (0, import_react78.useCallback)(
|
|
21105
21155
|
(data) => {
|
|
21106
21156
|
const payload = { data, ts: Date.now() };
|
|
21107
21157
|
try {
|
|
@@ -21115,7 +21165,7 @@ function useDraftStorage(options) {
|
|
|
21115
21165
|
},
|
|
21116
21166
|
[key]
|
|
21117
21167
|
);
|
|
21118
|
-
const restoreDraft = (0,
|
|
21168
|
+
const restoreDraft = (0, import_react78.useCallback)(() => {
|
|
21119
21169
|
const stored = readDraft(key);
|
|
21120
21170
|
if (stored) {
|
|
21121
21171
|
setDraftData(stored.data);
|
|
@@ -21123,7 +21173,7 @@ function useDraftStorage(options) {
|
|
|
21123
21173
|
}
|
|
21124
21174
|
return null;
|
|
21125
21175
|
}, [key]);
|
|
21126
|
-
const clearDraft = (0,
|
|
21176
|
+
const clearDraft = (0, import_react78.useCallback)(() => {
|
|
21127
21177
|
try {
|
|
21128
21178
|
localStorage.removeItem(key);
|
|
21129
21179
|
} catch (error) {
|
|
@@ -21144,7 +21194,7 @@ function useDraftStorage(options) {
|
|
|
21144
21194
|
}
|
|
21145
21195
|
|
|
21146
21196
|
// packages/sdk/src/components/hooks/useFormNavigation.ts
|
|
21147
|
-
var
|
|
21197
|
+
var import_react79 = require("react");
|
|
21148
21198
|
var normalizeBasePath = (basePath) => {
|
|
21149
21199
|
const normalized = String(basePath || "").replace(/^\/+|\/+$/g, "");
|
|
21150
21200
|
return normalized ? `/${normalized}` : "";
|
|
@@ -21176,12 +21226,12 @@ function useFormNavigation(options) {
|
|
|
21176
21226
|
basePath,
|
|
21177
21227
|
onStay
|
|
21178
21228
|
} = options;
|
|
21179
|
-
const [isRedirecting, setIsRedirecting] = (0,
|
|
21180
|
-
const [countdown, setCountdown] = (0,
|
|
21181
|
-
const timerRef = (0,
|
|
21182
|
-
const redirectTargetRef = (0,
|
|
21183
|
-
const mountedRef = (0,
|
|
21184
|
-
(0,
|
|
21229
|
+
const [isRedirecting, setIsRedirecting] = (0, import_react79.useState)(false);
|
|
21230
|
+
const [countdown, setCountdown] = (0, import_react79.useState)(0);
|
|
21231
|
+
const timerRef = (0, import_react79.useRef)(null);
|
|
21232
|
+
const redirectTargetRef = (0, import_react79.useRef)(null);
|
|
21233
|
+
const mountedRef = (0, import_react79.useRef)(true);
|
|
21234
|
+
(0, import_react79.useEffect)(() => {
|
|
21185
21235
|
mountedRef.current = true;
|
|
21186
21236
|
return () => {
|
|
21187
21237
|
mountedRef.current = false;
|
|
@@ -21191,13 +21241,13 @@ function useFormNavigation(options) {
|
|
|
21191
21241
|
}
|
|
21192
21242
|
};
|
|
21193
21243
|
}, []);
|
|
21194
|
-
const navigateToDetail = (0,
|
|
21244
|
+
const navigateToDetail = (0, import_react79.useCallback)(
|
|
21195
21245
|
(formInstId) => {
|
|
21196
21246
|
window.location.href = buildDetailUrl(appType, formUuid, formInstId, "formDetail", basePath);
|
|
21197
21247
|
},
|
|
21198
21248
|
[appType, basePath, formUuid]
|
|
21199
21249
|
);
|
|
21200
|
-
const navigateToProcessDetail = (0,
|
|
21250
|
+
const navigateToProcessDetail = (0, import_react79.useCallback)(
|
|
21201
21251
|
(formInstId) => {
|
|
21202
21252
|
window.location.href = buildDetailUrl(
|
|
21203
21253
|
appType,
|
|
@@ -21209,7 +21259,7 @@ function useFormNavigation(options) {
|
|
|
21209
21259
|
},
|
|
21210
21260
|
[appType, basePath, formUuid]
|
|
21211
21261
|
);
|
|
21212
|
-
const startRedirectCountdown = (0,
|
|
21262
|
+
const startRedirectCountdown = (0, import_react79.useCallback)(
|
|
21213
21263
|
(targetUrl) => {
|
|
21214
21264
|
const totalSeconds = Math.ceil(redirectDelay / 1e3);
|
|
21215
21265
|
setIsRedirecting(true);
|
|
@@ -21242,7 +21292,7 @@ function useFormNavigation(options) {
|
|
|
21242
21292
|
},
|
|
21243
21293
|
[redirectDelay]
|
|
21244
21294
|
);
|
|
21245
|
-
const cancelRedirect = (0,
|
|
21295
|
+
const cancelRedirect = (0, import_react79.useCallback)(() => {
|
|
21246
21296
|
if (timerRef.current) {
|
|
21247
21297
|
clearInterval(timerRef.current);
|
|
21248
21298
|
timerRef.current = null;
|
|
@@ -21251,7 +21301,7 @@ function useFormNavigation(options) {
|
|
|
21251
21301
|
setCountdown(0);
|
|
21252
21302
|
redirectTargetRef.current = null;
|
|
21253
21303
|
}, []);
|
|
21254
|
-
const handlePostSubmit = (0,
|
|
21304
|
+
const handlePostSubmit = (0, import_react79.useCallback)(
|
|
21255
21305
|
(formInstId) => {
|
|
21256
21306
|
if (mode === "stay") {
|
|
21257
21307
|
onStay?.(formInstId);
|
|
@@ -21466,26 +21516,26 @@ var InnerFormContent = ({
|
|
|
21466
21516
|
inDrawer = false
|
|
21467
21517
|
}) => {
|
|
21468
21518
|
const { validateAllWithErrors, getFormData: getFormData2, setFieldValue, resetForm, api } = useFormContext();
|
|
21469
|
-
const [submitted, setSubmitted] = (0,
|
|
21470
|
-
const [successInfo, setSuccessInfo] = (0,
|
|
21471
|
-
const [submitting, setSubmitting] = (0,
|
|
21472
|
-
const [departmentId, setDepartmentId] = (0,
|
|
21473
|
-
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = (0,
|
|
21474
|
-
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = (0,
|
|
21475
|
-
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = (0,
|
|
21476
|
-
const submissionDepartmentResolverRef = (0,
|
|
21477
|
-
const [previewOpen, setPreviewOpen] = (0,
|
|
21478
|
-
const [previewLoading, setPreviewLoading] = (0,
|
|
21479
|
-
const [previewRoutes, setPreviewRoutes] = (0,
|
|
21480
|
-
const [pendingFormData, setPendingFormData] = (0,
|
|
21481
|
-
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = (0,
|
|
21482
|
-
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = (0,
|
|
21483
|
-
const pendingSubmissionDepartmentIdRef = (0,
|
|
21484
|
-
const pendingInitiatorSelectedApproversRef = (0,
|
|
21519
|
+
const [submitted, setSubmitted] = (0, import_react80.useState)(false);
|
|
21520
|
+
const [successInfo, setSuccessInfo] = (0, import_react80.useState)(null);
|
|
21521
|
+
const [submitting, setSubmitting] = (0, import_react80.useState)(false);
|
|
21522
|
+
const [departmentId, setDepartmentId] = (0, import_react80.useState)();
|
|
21523
|
+
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = (0, import_react80.useState)(false);
|
|
21524
|
+
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = (0, import_react80.useState)([]);
|
|
21525
|
+
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = (0, import_react80.useState)();
|
|
21526
|
+
const submissionDepartmentResolverRef = (0, import_react80.useRef)(null);
|
|
21527
|
+
const [previewOpen, setPreviewOpen] = (0, import_react80.useState)(false);
|
|
21528
|
+
const [previewLoading, setPreviewLoading] = (0, import_react80.useState)(false);
|
|
21529
|
+
const [previewRoutes, setPreviewRoutes] = (0, import_react80.useState)([]);
|
|
21530
|
+
const [pendingFormData, setPendingFormData] = (0, import_react80.useState)(null);
|
|
21531
|
+
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = (0, import_react80.useState)();
|
|
21532
|
+
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = (0, import_react80.useState)();
|
|
21533
|
+
const pendingSubmissionDepartmentIdRef = (0, import_react80.useRef)(void 0);
|
|
21534
|
+
const pendingInitiatorSelectedApproversRef = (0, import_react80.useRef)(
|
|
21485
21535
|
void 0
|
|
21486
21536
|
);
|
|
21487
|
-
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0,
|
|
21488
|
-
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0,
|
|
21537
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react80.useState)(false);
|
|
21538
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react80.useState)([]);
|
|
21489
21539
|
const { hasDraft, draftTimestamp, saveDraft, restoreDraft, clearDraft } = useDraftStorage({
|
|
21490
21540
|
appType: config.appType,
|
|
21491
21541
|
formUuid: config.formUuid
|
|
@@ -21497,20 +21547,20 @@ var InnerFormContent = ({
|
|
|
21497
21547
|
mode: submitSuccessMode === "continue" ? "stay" : submitSuccessMode,
|
|
21498
21548
|
basePath: config.navigation?.basePath
|
|
21499
21549
|
});
|
|
21500
|
-
(0,
|
|
21550
|
+
(0, import_react80.useEffect)(() => {
|
|
21501
21551
|
return () => {
|
|
21502
21552
|
submissionDepartmentResolverRef.current?.(null);
|
|
21503
21553
|
submissionDepartmentResolverRef.current = null;
|
|
21504
21554
|
};
|
|
21505
21555
|
}, []);
|
|
21506
|
-
const closeSubmissionDepartmentModal = (0,
|
|
21556
|
+
const closeSubmissionDepartmentModal = (0, import_react80.useCallback)((value = null) => {
|
|
21507
21557
|
setSubmissionDepartmentModalOpen(false);
|
|
21508
21558
|
setSubmissionDepartmentOptions([]);
|
|
21509
21559
|
setSelectedSubmissionDepartmentId(void 0);
|
|
21510
21560
|
submissionDepartmentResolverRef.current?.(value);
|
|
21511
21561
|
submissionDepartmentResolverRef.current = null;
|
|
21512
21562
|
}, []);
|
|
21513
|
-
const promptSubmissionDepartmentSelection = (0,
|
|
21563
|
+
const promptSubmissionDepartmentSelection = (0, import_react80.useCallback)(
|
|
21514
21564
|
(options, preferredDepartmentId) => {
|
|
21515
21565
|
return new Promise((resolve) => {
|
|
21516
21566
|
const selected = options.some((option) => option.value === preferredDepartmentId) ? preferredDepartmentId : options[0]?.value;
|
|
@@ -21522,7 +21572,7 @@ var InnerFormContent = ({
|
|
|
21522
21572
|
},
|
|
21523
21573
|
[]
|
|
21524
21574
|
);
|
|
21525
|
-
const resolveSubmissionDepartmentId = (0,
|
|
21575
|
+
const resolveSubmissionDepartmentId = (0, import_react80.useCallback)(async () => {
|
|
21526
21576
|
if (formType !== "process") {
|
|
21527
21577
|
return void 0;
|
|
21528
21578
|
}
|
|
@@ -21544,7 +21594,7 @@ var InnerFormContent = ({
|
|
|
21544
21594
|
}
|
|
21545
21595
|
return promptSubmissionDepartmentSelection(departments, departmentId);
|
|
21546
21596
|
}, [api, config.formUuid, departmentId, formType, promptSubmissionDepartmentSelection, schema]);
|
|
21547
|
-
const performSubmit = (0,
|
|
21597
|
+
const performSubmit = (0, import_react80.useCallback)(
|
|
21548
21598
|
async (formData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
21549
21599
|
const submitData = normalizeFormDataForSubmit(schema, formData);
|
|
21550
21600
|
setSubmitting(true);
|
|
@@ -21621,7 +21671,7 @@ var InnerFormContent = ({
|
|
|
21621
21671
|
departmentId
|
|
21622
21672
|
]
|
|
21623
21673
|
);
|
|
21624
|
-
const continuePreparedSubmit = (0,
|
|
21674
|
+
const continuePreparedSubmit = (0, import_react80.useCallback)(
|
|
21625
21675
|
async (submitData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
21626
21676
|
if (formType === "process" && enableProcessPreview && !isSaveDraftSubmitBehavior(config)) {
|
|
21627
21677
|
setPendingFormData(submitData);
|
|
@@ -21653,7 +21703,7 @@ var InnerFormContent = ({
|
|
|
21653
21703
|
},
|
|
21654
21704
|
[api.request, config, enableProcessPreview, formType, performSubmit]
|
|
21655
21705
|
);
|
|
21656
|
-
const prepareSubmit = (0,
|
|
21706
|
+
const prepareSubmit = (0, import_react80.useCallback)(async () => {
|
|
21657
21707
|
const valid = await validateAndNotify(validateAllWithErrors);
|
|
21658
21708
|
if (!valid) return;
|
|
21659
21709
|
const formData = getFormData2();
|
|
@@ -21710,7 +21760,7 @@ var InnerFormContent = ({
|
|
|
21710
21760
|
resolveSubmissionDepartmentId,
|
|
21711
21761
|
continuePreparedSubmit
|
|
21712
21762
|
]);
|
|
21713
|
-
const handlePreviewConfirm = (0,
|
|
21763
|
+
const handlePreviewConfirm = (0, import_react80.useCallback)(async () => {
|
|
21714
21764
|
const data = pendingFormData ?? getFormData2();
|
|
21715
21765
|
const submissionDepartmentId = pendingSubmissionDepartmentIdRef.current ?? pendingSubmissionDepartmentId;
|
|
21716
21766
|
const initiatorSelectedApprovers = pendingInitiatorSelectedApproversRef.current ?? pendingInitiatorSelectedApprovers;
|
|
@@ -21728,7 +21778,7 @@ var InnerFormContent = ({
|
|
|
21728
21778
|
pendingSubmissionDepartmentId,
|
|
21729
21779
|
performSubmit
|
|
21730
21780
|
]);
|
|
21731
|
-
const handleInitiatorApproverConfirm = (0,
|
|
21781
|
+
const handleInitiatorApproverConfirm = (0, import_react80.useCallback)(
|
|
21732
21782
|
async (selectedUsersByNode) => {
|
|
21733
21783
|
const data = pendingFormData;
|
|
21734
21784
|
if (!data) {
|
|
@@ -21744,7 +21794,7 @@ var InnerFormContent = ({
|
|
|
21744
21794
|
},
|
|
21745
21795
|
[continuePreparedSubmit, pendingFormData, pendingSubmissionDepartmentId]
|
|
21746
21796
|
);
|
|
21747
|
-
const handleInitiatorApproverCancel = (0,
|
|
21797
|
+
const handleInitiatorApproverCancel = (0, import_react80.useCallback)(() => {
|
|
21748
21798
|
setInitiatorApproverOpen(false);
|
|
21749
21799
|
setInitiatorApproverRequirements([]);
|
|
21750
21800
|
setPendingFormData(null);
|
|
@@ -21753,23 +21803,23 @@ var InnerFormContent = ({
|
|
|
21753
21803
|
pendingSubmissionDepartmentIdRef.current = void 0;
|
|
21754
21804
|
pendingInitiatorSelectedApproversRef.current = void 0;
|
|
21755
21805
|
}, []);
|
|
21756
|
-
const handleSaveDraft = (0,
|
|
21806
|
+
const handleSaveDraft = (0, import_react80.useCallback)(() => {
|
|
21757
21807
|
const data = getFormData2();
|
|
21758
21808
|
saveDraft(data);
|
|
21759
21809
|
}, [getFormData2, saveDraft]);
|
|
21760
|
-
const handleRestoreDraft = (0,
|
|
21810
|
+
const handleRestoreDraft = (0, import_react80.useCallback)(() => {
|
|
21761
21811
|
const data = restoreDraft();
|
|
21762
21812
|
if (!data) return;
|
|
21763
21813
|
Object.entries(data).forEach(([fieldId, value]) => {
|
|
21764
21814
|
setFieldValue(fieldId, value);
|
|
21765
21815
|
});
|
|
21766
21816
|
}, [restoreDraft, setFieldValue]);
|
|
21767
|
-
const handleContinue = (0,
|
|
21817
|
+
const handleContinue = (0, import_react80.useCallback)(() => {
|
|
21768
21818
|
setSubmitted(false);
|
|
21769
21819
|
setSuccessInfo(null);
|
|
21770
21820
|
resetForm();
|
|
21771
21821
|
}, [resetForm]);
|
|
21772
|
-
const handleViewDetail = (0,
|
|
21822
|
+
const handleViewDetail = (0, import_react80.useCallback)(() => {
|
|
21773
21823
|
if (!successInfo) return;
|
|
21774
21824
|
if (formType === "process") {
|
|
21775
21825
|
navigateToProcessDetail(successInfo.formInstanceId);
|
|
@@ -21990,15 +22040,15 @@ var FormSubmitTemplate = ({
|
|
|
21990
22040
|
};
|
|
21991
22041
|
|
|
21992
22042
|
// packages/sdk/src/components/templates/ProcessDetailTemplate.tsx
|
|
21993
|
-
var
|
|
22043
|
+
var import_react85 = require("react");
|
|
21994
22044
|
var import_dayjs11 = __toESM(require("dayjs"));
|
|
21995
22045
|
var import_antd42 = require("antd");
|
|
21996
22046
|
|
|
21997
22047
|
// packages/sdk/src/components/hooks/useProcessDetail.ts
|
|
21998
|
-
var
|
|
22048
|
+
var import_react82 = require("react");
|
|
21999
22049
|
|
|
22000
22050
|
// packages/sdk/src/components/hooks/useFieldPermission.ts
|
|
22001
|
-
var
|
|
22051
|
+
var import_react81 = require("react");
|
|
22002
22052
|
var normalizeBehavior = (value) => {
|
|
22003
22053
|
if (value === "EDITABLE") return "NORMAL";
|
|
22004
22054
|
if (value === "READ_ONLY") return "READONLY";
|
|
@@ -22031,7 +22081,7 @@ var normalizeFlowConfig = (config) => {
|
|
|
22031
22081
|
};
|
|
22032
22082
|
function useFieldPermission(options) {
|
|
22033
22083
|
const { viewPermissions, processDefinition, currentTask, isApprover, mode } = options;
|
|
22034
|
-
const computeBehaviors = (0,
|
|
22084
|
+
const computeBehaviors = (0, import_react81.useCallback)(() => {
|
|
22035
22085
|
const behaviors = {};
|
|
22036
22086
|
if (!currentTask && viewPermissions) {
|
|
22037
22087
|
return normalizeFieldBehaviors(viewPermissions, mode);
|
|
@@ -22076,7 +22126,7 @@ function useFieldPermission(options) {
|
|
|
22076
22126
|
}
|
|
22077
22127
|
return behaviors;
|
|
22078
22128
|
}, [viewPermissions, processDefinition, currentTask, isApprover, mode]);
|
|
22079
|
-
const fieldBehaviors = (0,
|
|
22129
|
+
const fieldBehaviors = (0, import_react81.useMemo)(() => computeBehaviors(), [computeBehaviors]);
|
|
22080
22130
|
return { fieldBehaviors, computeBehaviors };
|
|
22081
22131
|
}
|
|
22082
22132
|
|
|
@@ -22108,29 +22158,29 @@ function useProcessDetail(options) {
|
|
|
22108
22158
|
const { formUuid, appType, formInstanceId, fieldIds } = options;
|
|
22109
22159
|
const { api } = useFormContext();
|
|
22110
22160
|
const request = api.request;
|
|
22111
|
-
const [loading, setLoading] = (0,
|
|
22112
|
-
const [mode, setMode] = (0,
|
|
22113
|
-
const [processInfo, setProcessInfo] = (0,
|
|
22114
|
-
const [progressList, setProgressList] = (0,
|
|
22115
|
-
const [formData, setFormData] = (0,
|
|
22116
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
22117
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
22118
|
-
const [loadError, setLoadError] = (0,
|
|
22119
|
-
const [isApprover, setIsApprover] = (0,
|
|
22120
|
-
const [canWithdraw, setCanWithdraw] = (0,
|
|
22121
|
-
const [approvalTasks, setApprovalTasks] = (0,
|
|
22122
|
-
const [permissions, setPermissions] = (0,
|
|
22123
|
-
const [processDefinition, setProcessDefinition] = (0,
|
|
22124
|
-
const [dataVersion, setDataVersion] = (0,
|
|
22125
|
-
const mountedRef = (0,
|
|
22161
|
+
const [loading, setLoading] = (0, import_react82.useState)(true);
|
|
22162
|
+
const [mode, setMode] = (0, import_react82.useState)("readonly");
|
|
22163
|
+
const [processInfo, setProcessInfo] = (0, import_react82.useState)(null);
|
|
22164
|
+
const [progressList, setProgressList] = (0, import_react82.useState)([]);
|
|
22165
|
+
const [formData, setFormData] = (0, import_react82.useState)(null);
|
|
22166
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react82.useState)(null);
|
|
22167
|
+
const [accessDenied, setAccessDenied] = (0, import_react82.useState)(false);
|
|
22168
|
+
const [loadError, setLoadError] = (0, import_react82.useState)(null);
|
|
22169
|
+
const [isApprover, setIsApprover] = (0, import_react82.useState)(false);
|
|
22170
|
+
const [canWithdraw, setCanWithdraw] = (0, import_react82.useState)(false);
|
|
22171
|
+
const [approvalTasks, setApprovalTasks] = (0, import_react82.useState)([]);
|
|
22172
|
+
const [permissions, setPermissions] = (0, import_react82.useState)(null);
|
|
22173
|
+
const [processDefinition, setProcessDefinition] = (0, import_react82.useState)(null);
|
|
22174
|
+
const [dataVersion, setDataVersion] = (0, import_react82.useState)(0);
|
|
22175
|
+
const mountedRef = (0, import_react82.useRef)(true);
|
|
22126
22176
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
22127
|
-
(0,
|
|
22177
|
+
(0, import_react82.useEffect)(() => {
|
|
22128
22178
|
mountedRef.current = true;
|
|
22129
22179
|
return () => {
|
|
22130
22180
|
mountedRef.current = false;
|
|
22131
22181
|
};
|
|
22132
22182
|
}, []);
|
|
22133
|
-
const currentTask = (0,
|
|
22183
|
+
const currentTask = (0, import_react82.useMemo)(
|
|
22134
22184
|
() => mergeCurrentTask(processInfo?.currentTask, approvalTasks[0]),
|
|
22135
22185
|
[processInfo?.currentTask, approvalTasks]
|
|
22136
22186
|
);
|
|
@@ -22150,7 +22200,7 @@ function useProcessDetail(options) {
|
|
|
22150
22200
|
isApprover: isProcessFinal ? false : isApprover,
|
|
22151
22201
|
mode
|
|
22152
22202
|
});
|
|
22153
|
-
const activeActions = (0,
|
|
22203
|
+
const activeActions = (0, import_react82.useMemo)(() => {
|
|
22154
22204
|
if (!isApprover || isProcessFinal) return [];
|
|
22155
22205
|
const actions = currentTask?.actions && currentTask.actions.length > 0 ? [...currentTask.actions] : [...DEFAULT_APPROVAL_ACTIONS];
|
|
22156
22206
|
if (canWithdraw && !actions.some((action) => action.action === "withdraw")) {
|
|
@@ -22158,7 +22208,7 @@ function useProcessDetail(options) {
|
|
|
22158
22208
|
}
|
|
22159
22209
|
return actions;
|
|
22160
22210
|
}, [isApprover, isProcessFinal, currentTask?.actions, canWithdraw]);
|
|
22161
|
-
const loadData = (0,
|
|
22211
|
+
const loadData = (0, import_react82.useCallback)(async () => {
|
|
22162
22212
|
if (!mountedRef.current) return;
|
|
22163
22213
|
setLoading(true);
|
|
22164
22214
|
setAccessDenied(false);
|
|
@@ -22240,24 +22290,24 @@ function useProcessDetail(options) {
|
|
|
22240
22290
|
}
|
|
22241
22291
|
}
|
|
22242
22292
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
22243
|
-
(0,
|
|
22293
|
+
(0, import_react82.useEffect)(() => {
|
|
22244
22294
|
loadData();
|
|
22245
22295
|
}, [loadData]);
|
|
22246
|
-
const switchToEdit = (0,
|
|
22296
|
+
const switchToEdit = (0, import_react82.useCallback)(() => {
|
|
22247
22297
|
setMode("edit");
|
|
22248
22298
|
void loadData();
|
|
22249
22299
|
}, [loadData]);
|
|
22250
|
-
const switchToReadonly = (0,
|
|
22300
|
+
const switchToReadonly = (0, import_react82.useCallback)(() => {
|
|
22251
22301
|
setMode("readonly");
|
|
22252
22302
|
}, []);
|
|
22253
|
-
const refreshDetail = (0,
|
|
22303
|
+
const refreshDetail = (0, import_react82.useCallback)(async () => {
|
|
22254
22304
|
setMode("readonly");
|
|
22255
22305
|
await loadData();
|
|
22256
22306
|
}, [loadData]);
|
|
22257
|
-
const refreshProgress = (0,
|
|
22307
|
+
const refreshProgress = (0, import_react82.useCallback)(async () => {
|
|
22258
22308
|
await refreshDetail();
|
|
22259
22309
|
}, [refreshDetail]);
|
|
22260
|
-
const saveChanges = (0,
|
|
22310
|
+
const saveChanges = (0, import_react82.useCallback)(
|
|
22261
22311
|
async (values) => {
|
|
22262
22312
|
try {
|
|
22263
22313
|
await api.updateFormData({
|
|
@@ -22276,7 +22326,7 @@ function useProcessDetail(options) {
|
|
|
22276
22326
|
},
|
|
22277
22327
|
[api, formInstanceId, formUuid, appType, loadData]
|
|
22278
22328
|
);
|
|
22279
|
-
const deleteInstance = (0,
|
|
22329
|
+
const deleteInstance = (0, import_react82.useCallback)(async () => {
|
|
22280
22330
|
try {
|
|
22281
22331
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
22282
22332
|
return true;
|
|
@@ -22317,29 +22367,29 @@ function useProcessDetail(options) {
|
|
|
22317
22367
|
}
|
|
22318
22368
|
|
|
22319
22369
|
// packages/sdk/src/components/hooks/useApprovalActions.ts
|
|
22320
|
-
var
|
|
22370
|
+
var import_react83 = require("react");
|
|
22321
22371
|
function useApprovalActions(options) {
|
|
22322
22372
|
const { formInstanceId, formUuid, appType, currentTaskId, onActionComplete, getFormValues } = options;
|
|
22323
22373
|
const { api } = useFormContext();
|
|
22324
22374
|
const request = api.request;
|
|
22325
|
-
const [isLoading, setIsLoading] = (0,
|
|
22326
|
-
const [currentAction, setCurrentAction] = (0,
|
|
22327
|
-
const [returnableNodes, setReturnableNodes] = (0,
|
|
22328
|
-
const [returnPolicy, setReturnPolicy] = (0,
|
|
22329
|
-
const mountedRef = (0,
|
|
22330
|
-
(0,
|
|
22375
|
+
const [isLoading, setIsLoading] = (0, import_react83.useState)(false);
|
|
22376
|
+
const [currentAction, setCurrentAction] = (0, import_react83.useState)(null);
|
|
22377
|
+
const [returnableNodes, setReturnableNodes] = (0, import_react83.useState)([]);
|
|
22378
|
+
const [returnPolicy, setReturnPolicy] = (0, import_react83.useState)(null);
|
|
22379
|
+
const mountedRef = (0, import_react83.useRef)(true);
|
|
22380
|
+
(0, import_react83.useEffect)(() => {
|
|
22331
22381
|
mountedRef.current = true;
|
|
22332
22382
|
return () => {
|
|
22333
22383
|
mountedRef.current = false;
|
|
22334
22384
|
};
|
|
22335
22385
|
}, []);
|
|
22336
|
-
const resetLoading = (0,
|
|
22386
|
+
const resetLoading = (0, import_react83.useCallback)(() => {
|
|
22337
22387
|
if (mountedRef.current) {
|
|
22338
22388
|
setIsLoading(false);
|
|
22339
22389
|
setCurrentAction(null);
|
|
22340
22390
|
}
|
|
22341
22391
|
}, []);
|
|
22342
|
-
const approve = (0,
|
|
22392
|
+
const approve = (0, import_react83.useCallback)(
|
|
22343
22393
|
async (comments) => {
|
|
22344
22394
|
setIsLoading(true);
|
|
22345
22395
|
setCurrentAction("approve");
|
|
@@ -22364,7 +22414,7 @@ function useApprovalActions(options) {
|
|
|
22364
22414
|
},
|
|
22365
22415
|
[request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
|
|
22366
22416
|
);
|
|
22367
|
-
const reject = (0,
|
|
22417
|
+
const reject = (0, import_react83.useCallback)(
|
|
22368
22418
|
async (comments) => {
|
|
22369
22419
|
setIsLoading(true);
|
|
22370
22420
|
setCurrentAction("reject");
|
|
@@ -22385,7 +22435,7 @@ function useApprovalActions(options) {
|
|
|
22385
22435
|
},
|
|
22386
22436
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
22387
22437
|
);
|
|
22388
|
-
const transfer = (0,
|
|
22438
|
+
const transfer = (0, import_react83.useCallback)(
|
|
22389
22439
|
async (userId, reason) => {
|
|
22390
22440
|
if (!currentTaskId) {
|
|
22391
22441
|
console.error("[useApprovalActions] transfer failed: no currentTaskId");
|
|
@@ -22410,7 +22460,7 @@ function useApprovalActions(options) {
|
|
|
22410
22460
|
},
|
|
22411
22461
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22412
22462
|
);
|
|
22413
|
-
const returnTo = (0,
|
|
22463
|
+
const returnTo = (0, import_react83.useCallback)(
|
|
22414
22464
|
async (nodeId, reason) => {
|
|
22415
22465
|
if (!currentTaskId) {
|
|
22416
22466
|
console.error("[useApprovalActions] returnTo failed: no currentTaskId");
|
|
@@ -22435,7 +22485,7 @@ function useApprovalActions(options) {
|
|
|
22435
22485
|
},
|
|
22436
22486
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22437
22487
|
);
|
|
22438
|
-
const withdraw = (0,
|
|
22488
|
+
const withdraw = (0, import_react83.useCallback)(
|
|
22439
22489
|
async (reason) => {
|
|
22440
22490
|
setIsLoading(true);
|
|
22441
22491
|
setCurrentAction("withdraw");
|
|
@@ -22455,7 +22505,7 @@ function useApprovalActions(options) {
|
|
|
22455
22505
|
},
|
|
22456
22506
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
22457
22507
|
);
|
|
22458
|
-
const save = (0,
|
|
22508
|
+
const save = (0, import_react83.useCallback)(async () => {
|
|
22459
22509
|
setIsLoading(true);
|
|
22460
22510
|
setCurrentAction("save");
|
|
22461
22511
|
try {
|
|
@@ -22475,7 +22525,7 @@ function useApprovalActions(options) {
|
|
|
22475
22525
|
return false;
|
|
22476
22526
|
}
|
|
22477
22527
|
}, [request, formInstanceId, formUuid, appType, getFormValues, onActionComplete, resetLoading]);
|
|
22478
|
-
const resubmit = (0,
|
|
22528
|
+
const resubmit = (0, import_react83.useCallback)(
|
|
22479
22529
|
async (comments, selectedApprovers) => {
|
|
22480
22530
|
if (!currentTaskId) {
|
|
22481
22531
|
console.error("[useApprovalActions] resubmit failed: no currentTaskId");
|
|
@@ -22505,7 +22555,7 @@ function useApprovalActions(options) {
|
|
|
22505
22555
|
},
|
|
22506
22556
|
[request, currentTaskId, formUuid, appType, getFormValues, onActionComplete, resetLoading]
|
|
22507
22557
|
);
|
|
22508
|
-
const callbackTask = (0,
|
|
22558
|
+
const callbackTask = (0, import_react83.useCallback)(
|
|
22509
22559
|
async (payload) => {
|
|
22510
22560
|
if (!currentTaskId) {
|
|
22511
22561
|
console.error("[useApprovalActions] callbackTask failed: no currentTaskId");
|
|
@@ -22529,7 +22579,7 @@ function useApprovalActions(options) {
|
|
|
22529
22579
|
},
|
|
22530
22580
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22531
22581
|
);
|
|
22532
|
-
const loadReturnableNodes = (0,
|
|
22582
|
+
const loadReturnableNodes = (0, import_react83.useCallback)(async () => {
|
|
22533
22583
|
if (!currentTaskId) return [];
|
|
22534
22584
|
try {
|
|
22535
22585
|
const result = await getReturnableNodeResult(request, currentTaskId);
|
|
@@ -22565,7 +22615,7 @@ function useApprovalActions(options) {
|
|
|
22565
22615
|
}
|
|
22566
22616
|
|
|
22567
22617
|
// packages/sdk/src/components/modules/ApprovalActionBar.tsx
|
|
22568
|
-
var
|
|
22618
|
+
var import_react84 = __toESM(require("react"));
|
|
22569
22619
|
var import_antd41 = require("antd");
|
|
22570
22620
|
var import_icons19 = require("@ant-design/icons");
|
|
22571
22621
|
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
@@ -22618,12 +22668,12 @@ function DefaultTransferSelector({
|
|
|
22618
22668
|
value,
|
|
22619
22669
|
onChange
|
|
22620
22670
|
}) {
|
|
22621
|
-
const formContext =
|
|
22671
|
+
const formContext = import_react84.default.useContext(FormContext);
|
|
22622
22672
|
const { isMobile } = useDeviceDetect();
|
|
22623
|
-
const fallbackApi = (0,
|
|
22673
|
+
const fallbackApi = (0, import_react84.useMemo)(() => createFormRuntimeApi(), []);
|
|
22624
22674
|
const api = formContext?.api ?? fallbackApi;
|
|
22625
|
-
const [open, setOpen] = (0,
|
|
22626
|
-
const [selectedUsers, setSelectedUsers] = (0,
|
|
22675
|
+
const [open, setOpen] = (0, import_react84.useState)(false);
|
|
22676
|
+
const [selectedUsers, setSelectedUsers] = (0, import_react84.useState)([]);
|
|
22627
22677
|
const selectedLabel = selectedUsers[0] ? getUserName(selectedUsers[0]) : value;
|
|
22628
22678
|
return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
|
|
22629
22679
|
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
@@ -22678,10 +22728,10 @@ var ApprovalActionBar = ({
|
|
|
22678
22728
|
maxWidth
|
|
22679
22729
|
}) => {
|
|
22680
22730
|
const [form] = import_antd41.Form.useForm();
|
|
22681
|
-
const [modalAction, setModalAction] = (0,
|
|
22682
|
-
const [activeAction, setActiveAction] = (0,
|
|
22683
|
-
const [loading, setLoading] = (0,
|
|
22684
|
-
const visibleActions = (0,
|
|
22731
|
+
const [modalAction, setModalAction] = (0, import_react84.useState)(null);
|
|
22732
|
+
const [activeAction, setActiveAction] = (0, import_react84.useState)(null);
|
|
22733
|
+
const [loading, setLoading] = (0, import_react84.useState)(false);
|
|
22734
|
+
const visibleActions = (0, import_react84.useMemo)(
|
|
22685
22735
|
() => actions.filter((action) => !action.hidden).sort((a, b) => (actionPriority2[a.action] ?? 50) - (actionPriority2[b.action] ?? 50)),
|
|
22686
22736
|
[actions]
|
|
22687
22737
|
);
|
|
@@ -22948,17 +22998,17 @@ var InnerProcessContent = ({
|
|
|
22948
22998
|
onDelete,
|
|
22949
22999
|
inDrawer = false
|
|
22950
23000
|
}) => {
|
|
22951
|
-
const formDataRef = (0,
|
|
22952
|
-
const validateRef = (0,
|
|
23001
|
+
const formDataRef = (0, import_react85.useRef)(void 0);
|
|
23002
|
+
const validateRef = (0, import_react85.useRef)(void 0);
|
|
22953
23003
|
const [withdrawForm] = import_antd42.Form.useForm();
|
|
22954
|
-
const [withdrawOpen, setWithdrawOpen] = (0,
|
|
22955
|
-
const [withdrawLoading, setWithdrawLoading] = (0,
|
|
22956
|
-
const [saveLoading, setSaveLoading] = (0,
|
|
22957
|
-
const [deleteLoading, setDeleteLoading] = (0,
|
|
22958
|
-
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0,
|
|
22959
|
-
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0,
|
|
22960
|
-
const [pendingResubmitComments, setPendingResubmitComments] = (0,
|
|
22961
|
-
const fieldIds = (0,
|
|
23004
|
+
const [withdrawOpen, setWithdrawOpen] = (0, import_react85.useState)(false);
|
|
23005
|
+
const [withdrawLoading, setWithdrawLoading] = (0, import_react85.useState)(false);
|
|
23006
|
+
const [saveLoading, setSaveLoading] = (0, import_react85.useState)(false);
|
|
23007
|
+
const [deleteLoading, setDeleteLoading] = (0, import_react85.useState)(false);
|
|
23008
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react85.useState)(false);
|
|
23009
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react85.useState)([]);
|
|
23010
|
+
const [pendingResubmitComments, setPendingResubmitComments] = (0, import_react85.useState)();
|
|
23011
|
+
const fieldIds = (0, import_react85.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
22962
23012
|
const { api } = useFormContext();
|
|
22963
23013
|
const {
|
|
22964
23014
|
loading,
|
|
@@ -23026,45 +23076,45 @@ var InnerProcessContent = ({
|
|
|
23026
23076
|
formInstanceId,
|
|
23027
23077
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
23028
23078
|
});
|
|
23029
|
-
const validateForm = (0,
|
|
23079
|
+
const validateForm = (0, import_react85.useCallback)(async () => {
|
|
23030
23080
|
return validateRef.current ? validateAndNotify(validateRef.current) : true;
|
|
23031
23081
|
}, []);
|
|
23032
|
-
const handleApprove = (0,
|
|
23082
|
+
const handleApprove = (0, import_react85.useCallback)(
|
|
23033
23083
|
async (comments) => {
|
|
23034
23084
|
if (!await validateForm()) return;
|
|
23035
23085
|
await approve(comments);
|
|
23036
23086
|
},
|
|
23037
23087
|
[approve, validateForm]
|
|
23038
23088
|
);
|
|
23039
|
-
const handleReject = (0,
|
|
23089
|
+
const handleReject = (0, import_react85.useCallback)(
|
|
23040
23090
|
async (comments) => {
|
|
23041
23091
|
await reject(comments);
|
|
23042
23092
|
},
|
|
23043
23093
|
[reject]
|
|
23044
23094
|
);
|
|
23045
|
-
const handleTransfer = (0,
|
|
23095
|
+
const handleTransfer = (0, import_react85.useCallback)(
|
|
23046
23096
|
async (userId, reason) => {
|
|
23047
23097
|
await transfer(userId, reason);
|
|
23048
23098
|
},
|
|
23049
23099
|
[transfer]
|
|
23050
23100
|
);
|
|
23051
|
-
const handleReturn = (0,
|
|
23101
|
+
const handleReturn = (0, import_react85.useCallback)(
|
|
23052
23102
|
async (nodeId, reason) => {
|
|
23053
23103
|
await returnTo(nodeId, reason);
|
|
23054
23104
|
},
|
|
23055
23105
|
[returnTo]
|
|
23056
23106
|
);
|
|
23057
|
-
const handleWithdraw = (0,
|
|
23107
|
+
const handleWithdraw = (0, import_react85.useCallback)(
|
|
23058
23108
|
async (reason) => {
|
|
23059
23109
|
await withdraw(reason);
|
|
23060
23110
|
},
|
|
23061
23111
|
[withdraw]
|
|
23062
23112
|
);
|
|
23063
|
-
const handleSave = (0,
|
|
23113
|
+
const handleSave = (0, import_react85.useCallback)(async () => {
|
|
23064
23114
|
if (!await validateForm()) return;
|
|
23065
23115
|
await save();
|
|
23066
23116
|
}, [save, validateForm]);
|
|
23067
|
-
const handleResubmit = (0,
|
|
23117
|
+
const handleResubmit = (0, import_react85.useCallback)(
|
|
23068
23118
|
async (comments) => {
|
|
23069
23119
|
if (!await validateForm()) return;
|
|
23070
23120
|
const values = formDataRef.current?.() ?? formData ?? {};
|
|
@@ -23098,7 +23148,7 @@ var InnerProcessContent = ({
|
|
|
23098
23148
|
},
|
|
23099
23149
|
[api.request, appType, currentTaskId, formData, formUuid, resubmit, validateForm]
|
|
23100
23150
|
);
|
|
23101
|
-
const handleInitiatorApproverConfirm = (0,
|
|
23151
|
+
const handleInitiatorApproverConfirm = (0, import_react85.useCallback)(
|
|
23102
23152
|
async (selectedUsersByNode) => {
|
|
23103
23153
|
const selectedApprovers = normalizeSelectedApprovers2(selectedUsersByNode);
|
|
23104
23154
|
setInitiatorApproverOpen(false);
|
|
@@ -23109,15 +23159,15 @@ var InnerProcessContent = ({
|
|
|
23109
23159
|
},
|
|
23110
23160
|
[pendingResubmitComments, resubmit]
|
|
23111
23161
|
);
|
|
23112
|
-
const handleInitiatorApproverCancel = (0,
|
|
23162
|
+
const handleInitiatorApproverCancel = (0, import_react85.useCallback)(() => {
|
|
23113
23163
|
setInitiatorApproverOpen(false);
|
|
23114
23164
|
setInitiatorApproverRequirements([]);
|
|
23115
23165
|
setPendingResubmitComments(void 0);
|
|
23116
23166
|
}, []);
|
|
23117
|
-
const handleCallback = (0,
|
|
23167
|
+
const handleCallback = (0, import_react85.useCallback)(async () => {
|
|
23118
23168
|
await callbackTask();
|
|
23119
23169
|
}, [callbackTask]);
|
|
23120
|
-
const handleCompletedSave = (0,
|
|
23170
|
+
const handleCompletedSave = (0, import_react85.useCallback)(async () => {
|
|
23121
23171
|
if (!await validateForm()) return;
|
|
23122
23172
|
const values = formDataRef.current?.() ?? formData;
|
|
23123
23173
|
if (!values) return;
|
|
@@ -23131,7 +23181,7 @@ var InnerProcessContent = ({
|
|
|
23131
23181
|
setSaveLoading(false);
|
|
23132
23182
|
}
|
|
23133
23183
|
}, [formData, onSave, saveChanges, validateForm]);
|
|
23134
|
-
const handleCompletedDelete = (0,
|
|
23184
|
+
const handleCompletedDelete = (0, import_react85.useCallback)(async () => {
|
|
23135
23185
|
setDeleteLoading(true);
|
|
23136
23186
|
try {
|
|
23137
23187
|
const success = await deleteInstance();
|
|
@@ -23142,7 +23192,7 @@ var InnerProcessContent = ({
|
|
|
23142
23192
|
setDeleteLoading(false);
|
|
23143
23193
|
}
|
|
23144
23194
|
}, [deleteInstance, onDelete]);
|
|
23145
|
-
const handleFooterWithdraw = (0,
|
|
23195
|
+
const handleFooterWithdraw = (0, import_react85.useCallback)(async () => {
|
|
23146
23196
|
const values = await withdrawForm.validateFields();
|
|
23147
23197
|
setWithdrawLoading(true);
|
|
23148
23198
|
try {
|
|
@@ -23153,11 +23203,11 @@ var InnerProcessContent = ({
|
|
|
23153
23203
|
setWithdrawLoading(false);
|
|
23154
23204
|
}
|
|
23155
23205
|
}, [handleWithdraw, withdrawForm]);
|
|
23156
|
-
const handleFooterWithdrawCancel = (0,
|
|
23206
|
+
const handleFooterWithdrawCancel = (0, import_react85.useCallback)(() => {
|
|
23157
23207
|
setWithdrawOpen(false);
|
|
23158
23208
|
withdrawForm.resetFields();
|
|
23159
23209
|
}, [withdrawForm]);
|
|
23160
|
-
const bottomActions = (0,
|
|
23210
|
+
const bottomActions = (0, import_react85.useMemo)(() => {
|
|
23161
23211
|
if (isApprover && !isOriginatorReturn && activeActions.length > 0) return [];
|
|
23162
23212
|
if (isProcessCompleted) {
|
|
23163
23213
|
if (mode === "readonly") {
|
|
@@ -23507,7 +23557,7 @@ var StandardFormPage = ({
|
|
|
23507
23557
|
const formType = normalizeStandardFormType(
|
|
23508
23558
|
schema.template?.formType || (resolvedMode === "process" ? "process" : "form")
|
|
23509
23559
|
);
|
|
23510
|
-
const submitApi = (0,
|
|
23560
|
+
const submitApi = (0, import_react86.useMemo)(() => {
|
|
23511
23561
|
if (!onSubmit) return void 0;
|
|
23512
23562
|
return {
|
|
23513
23563
|
submitFormData: async (payload) => onSubmit(
|
|
@@ -23521,7 +23571,7 @@ var StandardFormPage = ({
|
|
|
23521
23571
|
startProcessFromExistingInstance: async (payload) => onSubmit(payload)
|
|
23522
23572
|
};
|
|
23523
23573
|
}, [formType, onSubmit]);
|
|
23524
|
-
const api = (0,
|
|
23574
|
+
const api = (0, import_react86.useMemo)(() => {
|
|
23525
23575
|
if (!externalApi && !submitApi) return void 0;
|
|
23526
23576
|
return {
|
|
23527
23577
|
...externalApi ?? {},
|
|
@@ -24584,10 +24634,10 @@ function AsyncEntityFilterSelect({
|
|
|
24584
24634
|
value,
|
|
24585
24635
|
onChange
|
|
24586
24636
|
}) {
|
|
24587
|
-
const [options, setOptions] = (0,
|
|
24588
|
-
const [fetching, setFetching] = (0,
|
|
24637
|
+
const [options, setOptions] = (0, import_react87.useState)([]);
|
|
24638
|
+
const [fetching, setFetching] = (0, import_react87.useState)(false);
|
|
24589
24639
|
const multiple = normalizeOperator(operator) === "IN";
|
|
24590
|
-
const loadOptions = (0,
|
|
24640
|
+
const loadOptions = (0, import_react87.useCallback)(
|
|
24591
24641
|
async (keyword = "") => {
|
|
24592
24642
|
setFetching(true);
|
|
24593
24643
|
try {
|
|
@@ -24629,7 +24679,7 @@ function AsyncEntityFilterSelect({
|
|
|
24629
24679
|
},
|
|
24630
24680
|
[api, entityType]
|
|
24631
24681
|
);
|
|
24632
|
-
(0,
|
|
24682
|
+
(0, import_react87.useEffect)(() => {
|
|
24633
24683
|
void loadOptions();
|
|
24634
24684
|
}, [loadOptions]);
|
|
24635
24685
|
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
@@ -24940,7 +24990,7 @@ function ResizableColumnTitle({
|
|
|
24940
24990
|
onResize,
|
|
24941
24991
|
onResizeEnd
|
|
24942
24992
|
}) {
|
|
24943
|
-
const dragRef = (0,
|
|
24993
|
+
const dragRef = (0, import_react87.useRef)({ startX: 0, startWidth: width, latestWidth: width });
|
|
24944
24994
|
const handleMouseDown = (event) => {
|
|
24945
24995
|
event.preventDefault();
|
|
24946
24996
|
event.stopPropagation();
|
|
@@ -25009,74 +25059,74 @@ var DataManagementList = ({
|
|
|
25009
25059
|
permissionMode = "auto",
|
|
25010
25060
|
actionOverrides
|
|
25011
25061
|
}) => {
|
|
25012
|
-
const rootRef = (0,
|
|
25013
|
-
const api = (0,
|
|
25062
|
+
const rootRef = (0, import_react87.useRef)(null);
|
|
25063
|
+
const api = (0, import_react87.useMemo)(() => {
|
|
25014
25064
|
if (typeof requestOverride === "function") {
|
|
25015
25065
|
return createFormRuntimeApi({ request: requestOverride });
|
|
25016
25066
|
}
|
|
25017
25067
|
return createFormRuntimeApi(requestOverride);
|
|
25018
25068
|
}, [requestOverride]);
|
|
25019
|
-
const [fields, setFields] = (0,
|
|
25020
|
-
const [runtimeFormSchema, setRuntimeFormSchema] = (0,
|
|
25021
|
-
const [config, setConfig] = (0,
|
|
25022
|
-
const [formType, setFormType] = (0,
|
|
25023
|
-
const [showFields, setShowFields] = (0,
|
|
25024
|
-
const [lockFieldIds, setLockFieldIds] = (0,
|
|
25025
|
-
const [widths, setWidths] = (0,
|
|
25026
|
-
const widthsRef = (0,
|
|
25027
|
-
const [sort, setSort] = (0,
|
|
25028
|
-
const [density, setDensity] = (0,
|
|
25029
|
-
const [detailOpenMode, setDetailOpenMode] = (0,
|
|
25030
|
-
const [searchKeyWord, setSearchKeyWord] = (0,
|
|
25031
|
-
const [filterGroup, setFilterGroup] = (0,
|
|
25032
|
-
const [dataSource, setDataSource] = (0,
|
|
25033
|
-
const [total, setTotal] = (0,
|
|
25034
|
-
const [current, setCurrent] = (0,
|
|
25035
|
-
const [pageSize, setPageSize] = (0,
|
|
25036
|
-
const [loading, setLoading] = (0,
|
|
25037
|
-
const [schemaLoading, setSchemaLoading] = (0,
|
|
25038
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
25039
|
-
const [filterOpen, setFilterOpen] = (0,
|
|
25040
|
-
const [columnOpen, setColumnOpen] = (0,
|
|
25041
|
-
const [exportOpen, setExportOpen] = (0,
|
|
25042
|
-
const [exportScope, setExportScope] = (0,
|
|
25043
|
-
const [exportFields, setExportFields] = (0,
|
|
25044
|
-
const [exporting, setExporting] = (0,
|
|
25045
|
-
const [importOpen, setImportOpen] = (0,
|
|
25046
|
-
const [importPreview, setImportPreview] = (0,
|
|
25047
|
-
const [importBase64, setImportBase64] = (0,
|
|
25048
|
-
const [templateDownloading, setTemplateDownloading] = (0,
|
|
25049
|
-
const [recordsOpen, setRecordsOpen] = (0,
|
|
25050
|
-
const [recordTab, setRecordTab] = (0,
|
|
25051
|
-
const [transferRecords, setTransferRecords] = (0,
|
|
25052
|
-
const [batchApprovalOpen, setBatchApprovalOpen] = (0,
|
|
25053
|
-
const [batchApprovalAction, setBatchApprovalAction] = (0,
|
|
25069
|
+
const [fields, setFields] = (0, import_react87.useState)([]);
|
|
25070
|
+
const [runtimeFormSchema, setRuntimeFormSchema] = (0, import_react87.useState)(null);
|
|
25071
|
+
const [config, setConfig] = (0, import_react87.useState)({});
|
|
25072
|
+
const [formType, setFormType] = (0, import_react87.useState)("form");
|
|
25073
|
+
const [showFields, setShowFields] = (0, import_react87.useState)([]);
|
|
25074
|
+
const [lockFieldIds, setLockFieldIds] = (0, import_react87.useState)([]);
|
|
25075
|
+
const [widths, setWidths] = (0, import_react87.useState)({});
|
|
25076
|
+
const widthsRef = (0, import_react87.useRef)({});
|
|
25077
|
+
const [sort, setSort] = (0, import_react87.useState)([]);
|
|
25078
|
+
const [density, setDensity] = (0, import_react87.useState)("middle");
|
|
25079
|
+
const [detailOpenMode, setDetailOpenMode] = (0, import_react87.useState)("drawer");
|
|
25080
|
+
const [searchKeyWord, setSearchKeyWord] = (0, import_react87.useState)("");
|
|
25081
|
+
const [filterGroup, setFilterGroup] = (0, import_react87.useState)(createGroup);
|
|
25082
|
+
const [dataSource, setDataSource] = (0, import_react87.useState)([]);
|
|
25083
|
+
const [total, setTotal] = (0, import_react87.useState)(0);
|
|
25084
|
+
const [current, setCurrent] = (0, import_react87.useState)(1);
|
|
25085
|
+
const [pageSize, setPageSize] = (0, import_react87.useState)(10);
|
|
25086
|
+
const [loading, setLoading] = (0, import_react87.useState)(false);
|
|
25087
|
+
const [schemaLoading, setSchemaLoading] = (0, import_react87.useState)(true);
|
|
25088
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react87.useState)([]);
|
|
25089
|
+
const [filterOpen, setFilterOpen] = (0, import_react87.useState)(false);
|
|
25090
|
+
const [columnOpen, setColumnOpen] = (0, import_react87.useState)(false);
|
|
25091
|
+
const [exportOpen, setExportOpen] = (0, import_react87.useState)(false);
|
|
25092
|
+
const [exportScope, setExportScope] = (0, import_react87.useState)("all");
|
|
25093
|
+
const [exportFields, setExportFields] = (0, import_react87.useState)([]);
|
|
25094
|
+
const [exporting, setExporting] = (0, import_react87.useState)(false);
|
|
25095
|
+
const [importOpen, setImportOpen] = (0, import_react87.useState)(false);
|
|
25096
|
+
const [importPreview, setImportPreview] = (0, import_react87.useState)([]);
|
|
25097
|
+
const [importBase64, setImportBase64] = (0, import_react87.useState)("");
|
|
25098
|
+
const [templateDownloading, setTemplateDownloading] = (0, import_react87.useState)(false);
|
|
25099
|
+
const [recordsOpen, setRecordsOpen] = (0, import_react87.useState)(false);
|
|
25100
|
+
const [recordTab, setRecordTab] = (0, import_react87.useState)("export");
|
|
25101
|
+
const [transferRecords, setTransferRecords] = (0, import_react87.useState)([]);
|
|
25102
|
+
const [batchApprovalOpen, setBatchApprovalOpen] = (0, import_react87.useState)(false);
|
|
25103
|
+
const [batchApprovalAction, setBatchApprovalAction] = (0, import_react87.useState)(
|
|
25054
25104
|
"approved"
|
|
25055
25105
|
);
|
|
25056
|
-
const [batchApprovalComments, setBatchApprovalComments] = (0,
|
|
25057
|
-
const [batchApproving, setBatchApproving] = (0,
|
|
25058
|
-
const [activeRecord, setActiveRecord] = (0,
|
|
25059
|
-
const [detailOpen, setDetailOpen] = (0,
|
|
25060
|
-
const [submitOpen, setSubmitOpen] = (0,
|
|
25061
|
-
const [actionSummary, setActionSummary] = (0,
|
|
25062
|
-
const [permissionLoading, setPermissionLoading] = (0,
|
|
25063
|
-
const [permissionError, setPermissionError] = (0,
|
|
25064
|
-
const fetchStateRef = (0,
|
|
25106
|
+
const [batchApprovalComments, setBatchApprovalComments] = (0, import_react87.useState)("");
|
|
25107
|
+
const [batchApproving, setBatchApproving] = (0, import_react87.useState)(false);
|
|
25108
|
+
const [activeRecord, setActiveRecord] = (0, import_react87.useState)(null);
|
|
25109
|
+
const [detailOpen, setDetailOpen] = (0, import_react87.useState)(false);
|
|
25110
|
+
const [submitOpen, setSubmitOpen] = (0, import_react87.useState)(false);
|
|
25111
|
+
const [actionSummary, setActionSummary] = (0, import_react87.useState)(null);
|
|
25112
|
+
const [permissionLoading, setPermissionLoading] = (0, import_react87.useState)(permissionMode === "auto");
|
|
25113
|
+
const [permissionError, setPermissionError] = (0, import_react87.useState)(null);
|
|
25114
|
+
const fetchStateRef = (0, import_react87.useRef)({});
|
|
25065
25115
|
const isProcessForm = isProcessFormType(formType);
|
|
25066
25116
|
const request = api.request;
|
|
25067
|
-
const getPopupContainer = (0,
|
|
25117
|
+
const getPopupContainer = (0, import_react87.useCallback)(
|
|
25068
25118
|
(triggerNode) => resolveDataManagementPopupContainer(rootRef.current, triggerNode),
|
|
25069
25119
|
[]
|
|
25070
25120
|
);
|
|
25071
|
-
const getOverlayContainer = (0,
|
|
25121
|
+
const getOverlayContainer = (0, import_react87.useCallback)(
|
|
25072
25122
|
() => resolveDataManagementPortalContainer(rootRef.current),
|
|
25073
25123
|
[]
|
|
25074
25124
|
);
|
|
25075
25125
|
const drawerWidth = "min(960px, calc(100vw - 48px))";
|
|
25076
|
-
const confirmDanger = (0,
|
|
25126
|
+
const confirmDanger = (0, import_react87.useCallback)((title2, content, onOk) => {
|
|
25077
25127
|
if (confirmAction(title2, content)) onOk();
|
|
25078
25128
|
}, []);
|
|
25079
|
-
(0,
|
|
25129
|
+
(0, import_react87.useEffect)(() => {
|
|
25080
25130
|
let mounted = true;
|
|
25081
25131
|
if (permissionMode !== "auto") {
|
|
25082
25132
|
setActionSummary(null);
|
|
@@ -25103,7 +25153,7 @@ var DataManagementList = ({
|
|
|
25103
25153
|
mounted = false;
|
|
25104
25154
|
};
|
|
25105
25155
|
}, [appType, formUuid, permissionMode, request]);
|
|
25106
|
-
const baseActionCan = (0,
|
|
25156
|
+
const baseActionCan = (0, import_react87.useMemo)(() => {
|
|
25107
25157
|
if (permissionMode === "auto") {
|
|
25108
25158
|
return FORM_ACTION_PERMISSIONS.reduce((result, action) => {
|
|
25109
25159
|
result[action] = Boolean(actionSummary?.can?.[action]);
|
|
@@ -25115,7 +25165,7 @@ var DataManagementList = ({
|
|
|
25115
25165
|
return result;
|
|
25116
25166
|
}, {});
|
|
25117
25167
|
}, [actionSummary?.can, permissionMode]);
|
|
25118
|
-
const canAction = (0,
|
|
25168
|
+
const canAction = (0, import_react87.useCallback)(
|
|
25119
25169
|
(action) => {
|
|
25120
25170
|
if (permissionLoading && permissionMode === "auto") return false;
|
|
25121
25171
|
if (permissionError && permissionMode === "auto") return action === "view";
|
|
@@ -25137,22 +25187,22 @@ var DataManagementList = ({
|
|
|
25137
25187
|
const canExport = canAction("export");
|
|
25138
25188
|
const canImport = canAction("import");
|
|
25139
25189
|
const canWorkflow = canAction("workflow");
|
|
25140
|
-
const visibleFields = (0,
|
|
25190
|
+
const visibleFields = (0, import_react87.useMemo)(
|
|
25141
25191
|
() => showFields.map((fieldId) => fields.find((field) => field.fieldId === fieldId)).filter(Boolean),
|
|
25142
25192
|
[fields, showFields]
|
|
25143
25193
|
);
|
|
25144
|
-
const forcedShowFieldIds = (0,
|
|
25194
|
+
const forcedShowFieldIds = (0, import_react87.useMemo)(
|
|
25145
25195
|
() => new Set(forcedConfig?.showFields || []),
|
|
25146
25196
|
[forcedConfig?.showFields]
|
|
25147
25197
|
);
|
|
25148
|
-
const forcedLockFieldIds = (0,
|
|
25198
|
+
const forcedLockFieldIds = (0, import_react87.useMemo)(
|
|
25149
25199
|
() => new Set(forcedConfig?.lockFieldIds || []),
|
|
25150
25200
|
[forcedConfig?.lockFieldIds]
|
|
25151
25201
|
);
|
|
25152
|
-
(0,
|
|
25202
|
+
(0, import_react87.useEffect)(() => {
|
|
25153
25203
|
widthsRef.current = widths;
|
|
25154
25204
|
}, [widths]);
|
|
25155
|
-
(0,
|
|
25205
|
+
(0, import_react87.useEffect)(() => {
|
|
25156
25206
|
fetchStateRef.current = {
|
|
25157
25207
|
current,
|
|
25158
25208
|
pageSize,
|
|
@@ -25161,7 +25211,7 @@ var DataManagementList = ({
|
|
|
25161
25211
|
sort
|
|
25162
25212
|
};
|
|
25163
25213
|
}, [current, filterGroup, pageSize, searchKeyWord, sort]);
|
|
25164
|
-
const loadData = (0,
|
|
25214
|
+
const loadData = (0, import_react87.useCallback)(
|
|
25165
25215
|
async (overrides = {}) => {
|
|
25166
25216
|
if (!appType || !formUuid) return;
|
|
25167
25217
|
const fetchState = { ...fetchStateRef.current, ...overrides };
|
|
@@ -25205,7 +25255,7 @@ var DataManagementList = ({
|
|
|
25205
25255
|
},
|
|
25206
25256
|
[appType, forcedConfig, formUuid, request]
|
|
25207
25257
|
);
|
|
25208
|
-
(0,
|
|
25258
|
+
(0, import_react87.useEffect)(() => {
|
|
25209
25259
|
let mounted = true;
|
|
25210
25260
|
const loadSchemaAndConfig = async () => {
|
|
25211
25261
|
if (!appType || !formUuid) return;
|
|
@@ -25297,7 +25347,7 @@ var DataManagementList = ({
|
|
|
25297
25347
|
request,
|
|
25298
25348
|
title
|
|
25299
25349
|
]);
|
|
25300
|
-
const persistConfig = (0,
|
|
25350
|
+
const persistConfig = (0, import_react87.useCallback)(
|
|
25301
25351
|
async (patch) => {
|
|
25302
25352
|
const personalPatch = stripForcedConfigPatch(patch, forcedConfig);
|
|
25303
25353
|
const nextConfig = { ...config, ...personalPatch };
|
|
@@ -25341,12 +25391,12 @@ var DataManagementList = ({
|
|
|
25341
25391
|
const handleRemoveSort = (index) => {
|
|
25342
25392
|
setSort((prev) => prev.filter((_, itemIndex) => itemIndex !== index));
|
|
25343
25393
|
};
|
|
25344
|
-
const updateColumnWidth = (0,
|
|
25394
|
+
const updateColumnWidth = (0, import_react87.useCallback)((fieldId, width) => {
|
|
25345
25395
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
25346
25396
|
widthsRef.current = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
25347
25397
|
setWidths(widthsRef.current);
|
|
25348
25398
|
}, []);
|
|
25349
|
-
const commitColumnWidth = (0,
|
|
25399
|
+
const commitColumnWidth = (0, import_react87.useCallback)(
|
|
25350
25400
|
(fieldId, width) => {
|
|
25351
25401
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
25352
25402
|
const nextWidths = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
@@ -25356,7 +25406,7 @@ var DataManagementList = ({
|
|
|
25356
25406
|
},
|
|
25357
25407
|
[persistConfig]
|
|
25358
25408
|
);
|
|
25359
|
-
const handleDetail = (0,
|
|
25409
|
+
const handleDetail = (0, import_react87.useCallback)(
|
|
25360
25410
|
(record) => {
|
|
25361
25411
|
const formInstanceId = getRecordId(record);
|
|
25362
25412
|
if (!formInstanceId) {
|
|
@@ -25381,7 +25431,7 @@ var DataManagementList = ({
|
|
|
25381
25431
|
},
|
|
25382
25432
|
[appType, detailBasePath, detailOpenMode, detailPageUrlBuilder, formType, formUuid]
|
|
25383
25433
|
);
|
|
25384
|
-
const handleDelete = (0,
|
|
25434
|
+
const handleDelete = (0, import_react87.useCallback)(
|
|
25385
25435
|
async (ids) => {
|
|
25386
25436
|
if (ids.length === 0) return;
|
|
25387
25437
|
if (!canDelete) {
|
|
@@ -25394,7 +25444,7 @@ var DataManagementList = ({
|
|
|
25394
25444
|
},
|
|
25395
25445
|
[appType, canDelete, current, formUuid, loadData, pageSize, request]
|
|
25396
25446
|
);
|
|
25397
|
-
const getSelectedRecordIds = (0,
|
|
25447
|
+
const getSelectedRecordIds = (0, import_react87.useCallback)(
|
|
25398
25448
|
() => selectedRowKeys.map((key) => {
|
|
25399
25449
|
const record = dataSource.find((item) => String(getRecordId(item)) === String(key));
|
|
25400
25450
|
return String(getSelectedRecordId(record, key));
|
|
@@ -25539,7 +25589,7 @@ var DataManagementList = ({
|
|
|
25539
25589
|
ACTION_COLUMN_MIN_WIDTH,
|
|
25540
25590
|
Math.min(rowActionCount, visibleRowActionLimit) * ACTION_BUTTON_ESTIMATED_WIDTH + (rowActionCount > visibleRowActionLimit ? ACTION_MORE_BUTTON_WIDTH : 0) + ACTION_COLUMN_HORIZONTAL_PADDING
|
|
25541
25591
|
);
|
|
25542
|
-
const columns = (0,
|
|
25592
|
+
const columns = (0, import_react87.useMemo)(() => {
|
|
25543
25593
|
const baseColumns = visibleFields.map((field) => {
|
|
25544
25594
|
const columnWidth = widths[field.fieldId] || field.width || 160;
|
|
25545
25595
|
return {
|
|
@@ -25671,7 +25721,7 @@ var DataManagementList = ({
|
|
|
25671
25721
|
actionColumnWidth
|
|
25672
25722
|
)
|
|
25673
25723
|
);
|
|
25674
|
-
const importPreviewColumns = (0,
|
|
25724
|
+
const importPreviewColumns = (0, import_react87.useMemo)(() => {
|
|
25675
25725
|
const keys = Array.from(
|
|
25676
25726
|
new Set(importPreview.flatMap((record) => Object.keys(record || {})))
|
|
25677
25727
|
).slice(0, 16);
|
|
@@ -26429,17 +26479,17 @@ function BuiltinRouteRenderer({
|
|
|
26429
26479
|
style
|
|
26430
26480
|
}) {
|
|
26431
26481
|
const normalizedServicePrefix = trimTrailingSlash3(servicePrefix);
|
|
26432
|
-
const [schema, setSchema] = (0,
|
|
26433
|
-
const [loading, setLoading] = (0,
|
|
26434
|
-
const [error, setError] = (0,
|
|
26435
|
-
const [reloadKey, setReloadKey] = (0,
|
|
26482
|
+
const [schema, setSchema] = (0, import_react88.useState)();
|
|
26483
|
+
const [loading, setLoading] = (0, import_react88.useState)(false);
|
|
26484
|
+
const [error, setError] = (0, import_react88.useState)("");
|
|
26485
|
+
const [reloadKey, setReloadKey] = (0, import_react88.useState)(0);
|
|
26436
26486
|
const requestConfig = requestOverride && typeof requestOverride === "object" ? requestOverride : void 0;
|
|
26437
|
-
const request = (0,
|
|
26487
|
+
const request = (0, import_react88.useMemo)(() => {
|
|
26438
26488
|
if (typeof requestOverride === "function") return requestOverride;
|
|
26439
26489
|
if (requestConfig?.request) return requestConfig.request;
|
|
26440
26490
|
return createBuiltinRouteRequest(requestConfig?.baseUrl || normalizedServicePrefix, fetchImpl);
|
|
26441
26491
|
}, [fetchImpl, normalizedServicePrefix, requestConfig, requestOverride]);
|
|
26442
|
-
const api = (0,
|
|
26492
|
+
const api = (0, import_react88.useMemo)(
|
|
26443
26493
|
() => createFormRuntimeApi({
|
|
26444
26494
|
baseUrl: normalizedServicePrefix,
|
|
26445
26495
|
...requestConfig || {},
|
|
@@ -26450,14 +26500,14 @@ function BuiltinRouteRenderer({
|
|
|
26450
26500
|
const appType = appTypeProp || route?.appType || "";
|
|
26451
26501
|
const formUuid = route ? pickRouteValue(route, "formUuid", "menuFormUuid") : "";
|
|
26452
26502
|
const formInstId = route ? pickRouteValue(route, "formInstId", "formInstanceId") : "";
|
|
26453
|
-
const routeConfig = (0,
|
|
26503
|
+
const routeConfig = (0, import_react88.useMemo)(
|
|
26454
26504
|
() => route ? resolveRouteConfig(route, config) : {},
|
|
26455
26505
|
[config, route]
|
|
26456
26506
|
);
|
|
26457
26507
|
const runtimeStorage = route?.runtime?.storage;
|
|
26458
26508
|
const permissionDenied = isRuntimePermissionDenied(route);
|
|
26459
|
-
const reload = (0,
|
|
26460
|
-
(0,
|
|
26509
|
+
const reload = (0, import_react88.useCallback)(() => setReloadKey((value) => value + 1), []);
|
|
26510
|
+
(0, import_react88.useEffect)(() => {
|
|
26461
26511
|
let cancelled = false;
|
|
26462
26512
|
setSchema(void 0);
|
|
26463
26513
|
setError("");
|