openxiangda 1.0.154 → 1.0.156
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 +17 -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 +2 -1
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.mjs +2 -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,111 @@ 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 FILE_URL_KEYS = [
|
|
3923
|
+
"url",
|
|
3924
|
+
"downloadUrl",
|
|
3925
|
+
"publicUrl",
|
|
3926
|
+
"relayUrl",
|
|
3927
|
+
"previewUrl",
|
|
3928
|
+
"metadataUrl",
|
|
3929
|
+
"officeTextPreviewUrl"
|
|
3930
|
+
];
|
|
3931
|
+
var resolveServicePrefix = (sdk) => {
|
|
3932
|
+
const value = sdk.context?.env?.servicePrefix;
|
|
3933
|
+
return typeof value === "string" && value.trim() ? value.trim().replace(/\/+$/, "") : "/service";
|
|
3934
|
+
};
|
|
3935
|
+
var normalizeServiceFileUrl = (value, servicePrefix) => {
|
|
3936
|
+
if (typeof value !== "string" || !value) return value;
|
|
3937
|
+
if (/^(https?:)?\/\//i.test(value) || /^(blob|data):/i.test(value)) return value;
|
|
3938
|
+
if (value === servicePrefix || value.startsWith(`${servicePrefix}/`)) return value;
|
|
3939
|
+
return value.startsWith("/file/") ? `${servicePrefix}${value}` : value;
|
|
3940
|
+
};
|
|
3941
|
+
var normalizeFileTicketResult2 = (payload, servicePrefix) => {
|
|
3942
|
+
if (typeof payload === "string") {
|
|
3943
|
+
return normalizeServiceFileUrl(payload, servicePrefix);
|
|
3944
|
+
}
|
|
3945
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return payload;
|
|
3946
|
+
const normalized = { ...payload };
|
|
3947
|
+
FILE_URL_KEYS.forEach((key) => {
|
|
3948
|
+
normalized[key] = normalizeServiceFileUrl(normalized[key], servicePrefix);
|
|
3949
|
+
});
|
|
3950
|
+
return normalized;
|
|
3951
|
+
};
|
|
3952
|
+
var createPageFormRuntimeApi = (sdk) => {
|
|
3953
|
+
const servicePrefix = resolveServicePrefix(sdk);
|
|
3954
|
+
const request = async (config) => {
|
|
3955
|
+
const options = toPageRequest(config);
|
|
3956
|
+
if (config.responseType === "blob") {
|
|
3957
|
+
const response = await sdk.transport.download(options);
|
|
3958
|
+
return response.blob;
|
|
3959
|
+
}
|
|
3960
|
+
return toRuntimeResponse(await sdk.transport.request(options));
|
|
3961
|
+
};
|
|
3962
|
+
return createFormRuntimeApi({
|
|
3963
|
+
baseUrl: servicePrefix,
|
|
3964
|
+
request,
|
|
3965
|
+
createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => normalizeFileTicketResult2(
|
|
3966
|
+
unwrapPageResult(
|
|
3967
|
+
await sdk.createFileAccessTicket(
|
|
3968
|
+
bucketName,
|
|
3969
|
+
objectName,
|
|
3970
|
+
fileName,
|
|
3971
|
+
purpose,
|
|
3972
|
+
options
|
|
3973
|
+
)
|
|
3974
|
+
),
|
|
3975
|
+
servicePrefix
|
|
3976
|
+
),
|
|
3977
|
+
createDownloadTicket: async (bucketName, objectName, fileName) => normalizeFileTicketResult2(
|
|
3978
|
+
unwrapPageResult(
|
|
3979
|
+
await sdk.request({
|
|
3980
|
+
path: "/file/download-ticket",
|
|
3981
|
+
method: "post",
|
|
3982
|
+
body: { bucketName, objectName, fileName }
|
|
3983
|
+
})
|
|
3984
|
+
),
|
|
3985
|
+
servicePrefix
|
|
3986
|
+
)
|
|
3987
|
+
});
|
|
3988
|
+
};
|
|
3989
|
+
var usePageFormRuntimeApi = () => {
|
|
3990
|
+
const sdk = usePageSdk();
|
|
3991
|
+
return (0, import_react7.useMemo)(() => createPageFormRuntimeApi(sdk), [sdk]);
|
|
3992
|
+
};
|
|
3993
|
+
|
|
3994
|
+
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
3995
|
+
var import_react11 = __toESM(require("react"));
|
|
3996
|
+
var import_antd5 = require("antd");
|
|
3997
|
+
|
|
3892
3998
|
// packages/sdk/src/components/fields/shared/fieldFormat.ts
|
|
3893
3999
|
function createUid(prefix = "field") {
|
|
3894
4000
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -4420,7 +4526,7 @@ var convertHeicPreview = async (request, url) => {
|
|
|
4420
4526
|
};
|
|
4421
4527
|
|
|
4422
4528
|
// packages/sdk/src/components/file-preview/FilePreviewContent.tsx
|
|
4423
|
-
var
|
|
4529
|
+
var import_react8 = require("react");
|
|
4424
4530
|
var import_antd2 = require("antd");
|
|
4425
4531
|
var import_icons = require("@ant-design/icons");
|
|
4426
4532
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -4504,11 +4610,11 @@ var PayloadPreview = ({
|
|
|
4504
4610
|
url,
|
|
4505
4611
|
mode
|
|
4506
4612
|
}) => {
|
|
4507
|
-
const [payload, setPayload] = (0,
|
|
4508
|
-
const [loading, setLoading] = (0,
|
|
4509
|
-
const [error, setError] = (0,
|
|
4510
|
-
const [reloadKey, setReloadKey] = (0,
|
|
4511
|
-
(0,
|
|
4613
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4614
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
4615
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4616
|
+
const [reloadKey, setReloadKey] = (0, import_react8.useState)(0);
|
|
4617
|
+
(0, import_react8.useEffect)(() => {
|
|
4512
4618
|
let disposed = false;
|
|
4513
4619
|
setPayload(null);
|
|
4514
4620
|
setError("");
|
|
@@ -4616,9 +4722,9 @@ var ClientTextPreview = ({
|
|
|
4616
4722
|
request,
|
|
4617
4723
|
url
|
|
4618
4724
|
}) => {
|
|
4619
|
-
const [payload, setPayload] = (0,
|
|
4620
|
-
const [error, setError] = (0,
|
|
4621
|
-
(0,
|
|
4725
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4726
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4727
|
+
(0, import_react8.useEffect)(() => {
|
|
4622
4728
|
let disposed = false;
|
|
4623
4729
|
let textLimit = 1024 * 1024;
|
|
4624
4730
|
loadPreviewBlob(request, url).then(async (blob) => {
|
|
@@ -4654,10 +4760,10 @@ var ClientTextPreview = ({
|
|
|
4654
4760
|
] });
|
|
4655
4761
|
};
|
|
4656
4762
|
var DocxPreview = ({ request, url }) => {
|
|
4657
|
-
const containerRef = (0,
|
|
4658
|
-
const [loading, setLoading] = (0,
|
|
4659
|
-
const [error, setError] = (0,
|
|
4660
|
-
(0,
|
|
4763
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
4764
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
4765
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4766
|
+
(0, import_react8.useEffect)(() => {
|
|
4661
4767
|
let disposed = false;
|
|
4662
4768
|
const container = containerRef.current;
|
|
4663
4769
|
if (!container || !url) return () => {
|
|
@@ -4716,9 +4822,9 @@ var HeicImagePreview = ({
|
|
|
4716
4822
|
url,
|
|
4717
4823
|
fileName
|
|
4718
4824
|
}) => {
|
|
4719
|
-
const [src, setSrc] = (0,
|
|
4720
|
-
const [error, setError] = (0,
|
|
4721
|
-
(0,
|
|
4825
|
+
const [src, setSrc] = (0, import_react8.useState)("");
|
|
4826
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4827
|
+
(0, import_react8.useEffect)(() => {
|
|
4722
4828
|
let disposed = false;
|
|
4723
4829
|
let objectUrl = "";
|
|
4724
4830
|
convertHeicPreview(request, url).then((result) => {
|
|
@@ -4747,9 +4853,9 @@ var ClientSpreadsheetPreview = ({
|
|
|
4747
4853
|
request,
|
|
4748
4854
|
url
|
|
4749
4855
|
}) => {
|
|
4750
|
-
const [payload, setPayload] = (0,
|
|
4751
|
-
const [error, setError] = (0,
|
|
4752
|
-
(0,
|
|
4856
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4857
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4858
|
+
(0, import_react8.useEffect)(() => {
|
|
4753
4859
|
let disposed = false;
|
|
4754
4860
|
(async () => {
|
|
4755
4861
|
try {
|
|
@@ -4865,13 +4971,13 @@ var OnlyOfficePreview = ({
|
|
|
4865
4971
|
configUrl,
|
|
4866
4972
|
ticket
|
|
4867
4973
|
}) => {
|
|
4868
|
-
const editorId = (0,
|
|
4974
|
+
const editorId = (0, import_react8.useMemo)(
|
|
4869
4975
|
() => `openxiangda-onlyoffice-${String(ticket || "editor").replace(/[^a-zA-Z0-9_-]/g, "")}`,
|
|
4870
4976
|
[ticket]
|
|
4871
4977
|
);
|
|
4872
|
-
const [loading, setLoading] = (0,
|
|
4873
|
-
const [error, setError] = (0,
|
|
4874
|
-
(0,
|
|
4978
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
4979
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4980
|
+
(0, import_react8.useEffect)(() => {
|
|
4875
4981
|
let disposed = false;
|
|
4876
4982
|
let editor;
|
|
4877
4983
|
setLoading(true);
|
|
@@ -5054,7 +5160,7 @@ var FilePreviewContent = ({
|
|
|
5054
5160
|
};
|
|
5055
5161
|
|
|
5056
5162
|
// packages/sdk/src/components/file-preview/FilePreviewPage.tsx
|
|
5057
|
-
var
|
|
5163
|
+
var import_react9 = require("react");
|
|
5058
5164
|
var import_antd3 = require("antd");
|
|
5059
5165
|
var import_icons2 = require("@ant-design/icons");
|
|
5060
5166
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -5063,11 +5169,11 @@ var FilePreviewPage = ({
|
|
|
5063
5169
|
request,
|
|
5064
5170
|
servicePrefix = "/service"
|
|
5065
5171
|
}) => {
|
|
5066
|
-
const [metadata, setMetadata] = (0,
|
|
5067
|
-
const [loading, setLoading] = (0,
|
|
5068
|
-
const [error, setError] = (0,
|
|
5069
|
-
const [reloadKey, setReloadKey] = (0,
|
|
5070
|
-
(0,
|
|
5172
|
+
const [metadata, setMetadata] = (0, import_react9.useState)(null);
|
|
5173
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
5174
|
+
const [error, setError] = (0, import_react9.useState)("");
|
|
5175
|
+
const [reloadKey, setReloadKey] = (0, import_react9.useState)(0);
|
|
5176
|
+
(0, import_react9.useEffect)(() => {
|
|
5071
5177
|
let disposed = false;
|
|
5072
5178
|
setMetadata(null);
|
|
5073
5179
|
setError("");
|
|
@@ -5092,7 +5198,7 @@ var FilePreviewPage = ({
|
|
|
5092
5198
|
};
|
|
5093
5199
|
}, [reloadKey, request, ticket]);
|
|
5094
5200
|
const downloadUrl = resolvePreviewServiceUrl(metadata?.downloadUrl, servicePrefix);
|
|
5095
|
-
const handleDownload = (0,
|
|
5201
|
+
const handleDownload = (0, import_react9.useCallback)(() => {
|
|
5096
5202
|
if (downloadUrl && typeof window !== "undefined") window.location.assign(downloadUrl);
|
|
5097
5203
|
}, [downloadUrl]);
|
|
5098
5204
|
const renderContent = () => {
|
|
@@ -5236,7 +5342,7 @@ var FilePreviewPage = ({
|
|
|
5236
5342
|
};
|
|
5237
5343
|
|
|
5238
5344
|
// packages/sdk/src/components/file-preview/useFilePreview.tsx
|
|
5239
|
-
var
|
|
5345
|
+
var import_react10 = require("react");
|
|
5240
5346
|
var import_antd4 = require("antd");
|
|
5241
5347
|
var import_icons3 = require("@ant-design/icons");
|
|
5242
5348
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -5265,7 +5371,7 @@ var useFilePreviewController = ({
|
|
|
5265
5371
|
enabled = true,
|
|
5266
5372
|
requireServerCapability = true
|
|
5267
5373
|
}) => {
|
|
5268
|
-
const itemSignature = (0,
|
|
5374
|
+
const itemSignature = (0, import_react10.useMemo)(
|
|
5269
5375
|
() => items.map(
|
|
5270
5376
|
(item, index) => [
|
|
5271
5377
|
getPreviewItemKey(item, index),
|
|
@@ -5278,17 +5384,17 @@ var useFilePreviewController = ({
|
|
|
5278
5384
|
).join("|"),
|
|
5279
5385
|
[items]
|
|
5280
5386
|
);
|
|
5281
|
-
const [capabilities, setCapabilities] = (0,
|
|
5387
|
+
const [capabilities, setCapabilities] = (0, import_react10.useState)(
|
|
5282
5388
|
() => buildCapabilityMap(items, requireServerCapability)
|
|
5283
5389
|
);
|
|
5284
|
-
const [openingKey, setOpeningKey] = (0,
|
|
5285
|
-
const [dialogPreview, setDialogPreview] = (0,
|
|
5286
|
-
const [imagePreview, setImagePreview] = (0,
|
|
5390
|
+
const [openingKey, setOpeningKey] = (0, import_react10.useState)("");
|
|
5391
|
+
const [dialogPreview, setDialogPreview] = (0, import_react10.useState)(null);
|
|
5392
|
+
const [imagePreview, setImagePreview] = (0, import_react10.useState)({
|
|
5287
5393
|
open: false,
|
|
5288
5394
|
current: 0,
|
|
5289
5395
|
items: []
|
|
5290
5396
|
});
|
|
5291
|
-
(0,
|
|
5397
|
+
(0, import_react10.useEffect)(() => {
|
|
5292
5398
|
let disposed = false;
|
|
5293
5399
|
const initial = buildCapabilityMap(items, requireServerCapability);
|
|
5294
5400
|
setCapabilities(initial);
|
|
@@ -5333,28 +5439,28 @@ var useFilePreviewController = ({
|
|
|
5333
5439
|
disposed = true;
|
|
5334
5440
|
};
|
|
5335
5441
|
}, [api, enabled, itemSignature, requireServerCapability]);
|
|
5336
|
-
const getCapability = (0,
|
|
5442
|
+
const getCapability = (0, import_react10.useCallback)(
|
|
5337
5443
|
(item) => {
|
|
5338
5444
|
const index = items.indexOf(item);
|
|
5339
5445
|
return capabilities[getPreviewItemKey(item, Math.max(index, 0))];
|
|
5340
5446
|
},
|
|
5341
5447
|
[capabilities, items]
|
|
5342
5448
|
);
|
|
5343
|
-
const canPreview = (0,
|
|
5449
|
+
const canPreview = (0, import_react10.useCallback)(
|
|
5344
5450
|
(item) => enabled && canActOnItem(item) && getCapability(item)?.canPreview === true,
|
|
5345
5451
|
[enabled, getCapability]
|
|
5346
5452
|
);
|
|
5347
|
-
const closeImagePreview = (0,
|
|
5453
|
+
const closeImagePreview = (0, import_react10.useCallback)(() => {
|
|
5348
5454
|
setImagePreview((current) => {
|
|
5349
5455
|
revokeImageItems(current.items);
|
|
5350
5456
|
return { open: false, current: 0, items: [] };
|
|
5351
5457
|
});
|
|
5352
5458
|
}, []);
|
|
5353
|
-
(0,
|
|
5459
|
+
(0, import_react10.useEffect)(
|
|
5354
5460
|
() => () => revokeImageItems(imagePreview.items),
|
|
5355
5461
|
[imagePreview.items]
|
|
5356
5462
|
);
|
|
5357
|
-
const resolvePreparedImageItem = (0,
|
|
5463
|
+
const resolvePreparedImageItem = (0, import_react10.useCallback)(
|
|
5358
5464
|
async (prepared, index) => {
|
|
5359
5465
|
const item = prepared.item;
|
|
5360
5466
|
const metadata = prepared.metadata;
|
|
@@ -5376,14 +5482,14 @@ var useFilePreviewController = ({
|
|
|
5376
5482
|
},
|
|
5377
5483
|
[api]
|
|
5378
5484
|
);
|
|
5379
|
-
const prepareImageItem = (0,
|
|
5485
|
+
const prepareImageItem = (0, import_react10.useCallback)(
|
|
5380
5486
|
async (item, index) => {
|
|
5381
5487
|
const prepared = await prepareFilePreview({ item, api, appType, bucketName });
|
|
5382
5488
|
return resolvePreparedImageItem(prepared, index);
|
|
5383
5489
|
},
|
|
5384
5490
|
[api, appType, bucketName, resolvePreparedImageItem]
|
|
5385
5491
|
);
|
|
5386
|
-
const openPreview = (0,
|
|
5492
|
+
const openPreview = (0, import_react10.useCallback)(
|
|
5387
5493
|
async (item) => {
|
|
5388
5494
|
const itemIndex = Math.max(items.indexOf(item), 0);
|
|
5389
5495
|
const key = getPreviewItemKey(item, itemIndex);
|
|
@@ -5446,7 +5552,7 @@ var useFilePreviewController = ({
|
|
|
5446
5552
|
resolvePreparedImageItem
|
|
5447
5553
|
]
|
|
5448
5554
|
);
|
|
5449
|
-
const downloadItem = (0,
|
|
5555
|
+
const downloadItem = (0, import_react10.useCallback)(
|
|
5450
5556
|
async (item, prepared) => {
|
|
5451
5557
|
let url = prepared?.metadata.downloadUrl || item.downloadUrl || item.publicUrl || item.url;
|
|
5452
5558
|
if (!isDirectStorageItem(item) && item.objectName && !prepared?.metadata.downloadUrl) {
|
|
@@ -5457,7 +5563,8 @@ var useFilePreviewController = ({
|
|
|
5457
5563
|
);
|
|
5458
5564
|
url = typeof ticket === "string" ? ticket : ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || url;
|
|
5459
5565
|
}
|
|
5460
|
-
|
|
5566
|
+
const resolvedUrl = resolvePreviewServiceUrl(url);
|
|
5567
|
+
if (resolvedUrl && typeof window !== "undefined") window.location.assign(resolvedUrl);
|
|
5461
5568
|
},
|
|
5462
5569
|
[api, bucketName]
|
|
5463
5570
|
);
|
|
@@ -5610,63 +5717,6 @@ function FileStatusText({
|
|
|
5610
5717
|
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
5611
5718
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
5612
5719
|
var EMPTY_ITEMS = [];
|
|
5613
|
-
var normalizeMethod2 = (method) => {
|
|
5614
|
-
const value = String(method || "get").toLowerCase();
|
|
5615
|
-
return ["get", "post", "put", "delete", "patch"].includes(value) ? value : "get";
|
|
5616
|
-
};
|
|
5617
|
-
var normalizeHeaders = (headers) => {
|
|
5618
|
-
if (!headers) return void 0;
|
|
5619
|
-
return Object.fromEntries(new Headers(headers).entries());
|
|
5620
|
-
};
|
|
5621
|
-
var toPageRequest = (config) => ({
|
|
5622
|
-
path: config.url,
|
|
5623
|
-
method: normalizeMethod2(config.method),
|
|
5624
|
-
query: config.params,
|
|
5625
|
-
body: config.data,
|
|
5626
|
-
headers: normalizeHeaders(config.headers)
|
|
5627
|
-
});
|
|
5628
|
-
var toRuntimeResponse = (response) => {
|
|
5629
|
-
if (response.raw && typeof response.raw === "object") {
|
|
5630
|
-
return response.raw;
|
|
5631
|
-
}
|
|
5632
|
-
return {
|
|
5633
|
-
code: Number(response.code) || 200,
|
|
5634
|
-
success: response.success,
|
|
5635
|
-
message: response.message,
|
|
5636
|
-
data: response.result,
|
|
5637
|
-
result: response.result
|
|
5638
|
-
};
|
|
5639
|
-
};
|
|
5640
|
-
var unwrapPageResult = (response) => response.result ?? response.data ?? null;
|
|
5641
|
-
var createPageFileRuntimeApi = (sdk) => {
|
|
5642
|
-
const request = async (config) => {
|
|
5643
|
-
const options = toPageRequest(config);
|
|
5644
|
-
if (config.responseType === "blob") {
|
|
5645
|
-
const response = await sdk.transport.download(options);
|
|
5646
|
-
return response.blob;
|
|
5647
|
-
}
|
|
5648
|
-
return toRuntimeResponse(await sdk.transport.request(options));
|
|
5649
|
-
};
|
|
5650
|
-
return createFormRuntimeApi({
|
|
5651
|
-
request,
|
|
5652
|
-
createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => unwrapPageResult(
|
|
5653
|
-
await sdk.createFileAccessTicket(
|
|
5654
|
-
bucketName,
|
|
5655
|
-
objectName,
|
|
5656
|
-
fileName,
|
|
5657
|
-
purpose,
|
|
5658
|
-
options
|
|
5659
|
-
)
|
|
5660
|
-
),
|
|
5661
|
-
createDownloadTicket: async (bucketName, objectName, fileName) => unwrapPageResult(
|
|
5662
|
-
await sdk.request({
|
|
5663
|
-
path: "/file/download-ticket",
|
|
5664
|
-
method: "post",
|
|
5665
|
-
body: { bucketName, objectName, fileName }
|
|
5666
|
-
})
|
|
5667
|
-
)
|
|
5668
|
-
});
|
|
5669
|
-
};
|
|
5670
5720
|
var useFilePreview = ({
|
|
5671
5721
|
items = EMPTY_ITEMS,
|
|
5672
5722
|
appType,
|
|
@@ -5675,7 +5725,7 @@ var useFilePreview = ({
|
|
|
5675
5725
|
requireServerCapability = true
|
|
5676
5726
|
}) => {
|
|
5677
5727
|
const sdk = usePageSdk();
|
|
5678
|
-
const api = (0,
|
|
5728
|
+
const api = (0, import_react11.useMemo)(() => createPageFormRuntimeApi(sdk), [sdk]);
|
|
5679
5729
|
const preview = useFilePreviewController({
|
|
5680
5730
|
items,
|
|
5681
5731
|
api,
|
|
@@ -5767,8 +5817,8 @@ var AttachmentPreviewList = ({
|
|
|
5767
5817
|
};
|
|
5768
5818
|
var PreviewImageThumb = ({ item }) => {
|
|
5769
5819
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
5770
|
-
const [failed, setFailed] = (0,
|
|
5771
|
-
|
|
5820
|
+
const [failed, setFailed] = (0, import_react11.useState)(false);
|
|
5821
|
+
import_react11.default.useEffect(() => setFailed(false), [src]);
|
|
5772
5822
|
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" });
|
|
5773
5823
|
};
|
|
5774
5824
|
var ImagePreviewGrid = ({
|
|
@@ -5863,12 +5913,12 @@ var ImagePreviewGrid = ({
|
|
|
5863
5913
|
};
|
|
5864
5914
|
|
|
5865
5915
|
// packages/sdk/src/runtime/react/workflow.tsx
|
|
5866
|
-
var
|
|
5916
|
+
var import_react17 = require("react");
|
|
5867
5917
|
var import_antd10 = require("antd");
|
|
5868
5918
|
var import_icons9 = require("@ant-design/icons");
|
|
5869
5919
|
|
|
5870
5920
|
// packages/sdk/src/components/modules/StickyActionBar.tsx
|
|
5871
|
-
var
|
|
5921
|
+
var import_react12 = require("react");
|
|
5872
5922
|
var import_antd6 = require("antd");
|
|
5873
5923
|
var import_icons5 = require("@ant-design/icons");
|
|
5874
5924
|
|
|
@@ -5904,14 +5954,14 @@ var StickyActionBar = ({
|
|
|
5904
5954
|
position = "sticky",
|
|
5905
5955
|
surface = "default"
|
|
5906
5956
|
}) => {
|
|
5907
|
-
const [isMobile, setIsMobile] = (0,
|
|
5908
|
-
(0,
|
|
5957
|
+
const [isMobile, setIsMobile] = (0, import_react12.useState)(false);
|
|
5958
|
+
(0, import_react12.useEffect)(() => {
|
|
5909
5959
|
const update = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
|
|
5910
5960
|
update();
|
|
5911
5961
|
window.addEventListener("resize", update);
|
|
5912
5962
|
return () => window.removeEventListener("resize", update);
|
|
5913
5963
|
}, []);
|
|
5914
|
-
const visibleActions = (0,
|
|
5964
|
+
const visibleActions = (0, import_react12.useMemo)(
|
|
5915
5965
|
() => actions.filter((action) => action.visible !== false).sort((left, right) => getActionPriority(left) - getActionPriority(right)),
|
|
5916
5966
|
[actions]
|
|
5917
5967
|
);
|
|
@@ -5980,7 +6030,7 @@ var StickyActionBar = ({
|
|
|
5980
6030
|
};
|
|
5981
6031
|
|
|
5982
6032
|
// packages/sdk/src/components/modules/ApprovalTimeline.tsx
|
|
5983
|
-
var
|
|
6033
|
+
var import_react13 = require("react");
|
|
5984
6034
|
var import_icons6 = require("@ant-design/icons");
|
|
5985
6035
|
|
|
5986
6036
|
// packages/sdk/src/components/core/constants.ts
|
|
@@ -6144,8 +6194,8 @@ var ApprovalTimeline = ({
|
|
|
6144
6194
|
compactMode = false,
|
|
6145
6195
|
showApproverInfo = true
|
|
6146
6196
|
}) => {
|
|
6147
|
-
const taskList = (0,
|
|
6148
|
-
const groups = (0,
|
|
6197
|
+
const taskList = (0, import_react13.useMemo)(() => Array.isArray(tasks) ? tasks : [], [tasks]);
|
|
6198
|
+
const groups = (0, import_react13.useMemo)(() => groupTasks(taskList), [taskList]);
|
|
6149
6199
|
if (taskList.length === 0) {
|
|
6150
6200
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6151
6201
|
"div",
|
|
@@ -6291,7 +6341,7 @@ var ProcessPreview = ({
|
|
|
6291
6341
|
};
|
|
6292
6342
|
|
|
6293
6343
|
// packages/sdk/src/components/modules/InitiatorApproverSelector.tsx
|
|
6294
|
-
var
|
|
6344
|
+
var import_react16 = require("react");
|
|
6295
6345
|
var import_antd9 = require("antd");
|
|
6296
6346
|
|
|
6297
6347
|
// packages/sdk/src/components/core/processApi.ts
|
|
@@ -6655,13 +6705,13 @@ async function getViewPermission(request, params) {
|
|
|
6655
6705
|
}
|
|
6656
6706
|
|
|
6657
6707
|
// packages/sdk/src/components/fields/shared/UserPicker.tsx
|
|
6658
|
-
var
|
|
6708
|
+
var import_react15 = require("react");
|
|
6659
6709
|
var import_antd8 = require("antd");
|
|
6660
6710
|
var import_icons8 = require("@ant-design/icons");
|
|
6661
6711
|
var MobileAntd = __toESM(require("antd-mobile"));
|
|
6662
6712
|
|
|
6663
6713
|
// packages/sdk/src/components/fields/shared/useLazyDepartmentTree.ts
|
|
6664
|
-
var
|
|
6714
|
+
var import_react14 = require("react");
|
|
6665
6715
|
var toLazyNode = (node) => {
|
|
6666
6716
|
const normalized = normalizeDepartmentNode(node);
|
|
6667
6717
|
const id = getDepartmentId(normalized);
|
|
@@ -6711,15 +6761,15 @@ function buildIndexes(nodes) {
|
|
|
6711
6761
|
return { nodeMap, parentMap, flatNodes };
|
|
6712
6762
|
}
|
|
6713
6763
|
function useLazyDepartmentTree(api, configuredTreeData) {
|
|
6714
|
-
const [treeData, setTreeDataState] = (0,
|
|
6764
|
+
const [treeData, setTreeDataState] = (0, import_react14.useState)(
|
|
6715
6765
|
() => (configuredTreeData || []).map(toLazyNode)
|
|
6716
6766
|
);
|
|
6717
|
-
const [treeLoading, setTreeLoading] = (0,
|
|
6718
|
-
const treeDataRef = (0,
|
|
6719
|
-
const rootsLoadedRef = (0,
|
|
6720
|
-
const rootPromiseRef = (0,
|
|
6721
|
-
const childPromiseRef = (0,
|
|
6722
|
-
const setTreeData = (0,
|
|
6767
|
+
const [treeLoading, setTreeLoading] = (0, import_react14.useState)(false);
|
|
6768
|
+
const treeDataRef = (0, import_react14.useRef)(treeData);
|
|
6769
|
+
const rootsLoadedRef = (0, import_react14.useRef)(Boolean(configuredTreeData?.length));
|
|
6770
|
+
const rootPromiseRef = (0, import_react14.useRef)(null);
|
|
6771
|
+
const childPromiseRef = (0, import_react14.useRef)({});
|
|
6772
|
+
const setTreeData = (0, import_react14.useCallback)(
|
|
6723
6773
|
(next) => {
|
|
6724
6774
|
const resolved = typeof next === "function" ? next(treeDataRef.current) : next;
|
|
6725
6775
|
treeDataRef.current = resolved;
|
|
@@ -6728,13 +6778,13 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6728
6778
|
},
|
|
6729
6779
|
[]
|
|
6730
6780
|
);
|
|
6731
|
-
(0,
|
|
6781
|
+
(0, import_react14.useEffect)(() => {
|
|
6732
6782
|
if (!configuredTreeData) return;
|
|
6733
6783
|
const next = configuredTreeData.map(toLazyNode);
|
|
6734
6784
|
rootsLoadedRef.current = next.length > 0;
|
|
6735
6785
|
setTreeData(next);
|
|
6736
6786
|
}, [configuredTreeData, setTreeData]);
|
|
6737
|
-
const loadRootDepartments = (0,
|
|
6787
|
+
const loadRootDepartments = (0, import_react14.useCallback)(async () => {
|
|
6738
6788
|
if (rootsLoadedRef.current) return treeDataRef.current;
|
|
6739
6789
|
if (rootPromiseRef.current) return rootPromiseRef.current;
|
|
6740
6790
|
setTreeLoading(true);
|
|
@@ -6750,7 +6800,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6750
6800
|
rootPromiseRef.current = promise;
|
|
6751
6801
|
return promise;
|
|
6752
6802
|
}, [api, setTreeData]);
|
|
6753
|
-
const loadChildren = (0,
|
|
6803
|
+
const loadChildren = (0, import_react14.useCallback)(
|
|
6754
6804
|
async (parentId) => {
|
|
6755
6805
|
const id = String(parentId || "");
|
|
6756
6806
|
if (!id) return [];
|
|
@@ -6771,8 +6821,8 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6771
6821
|
},
|
|
6772
6822
|
[api, setTreeData]
|
|
6773
6823
|
);
|
|
6774
|
-
const indexes = (0,
|
|
6775
|
-
(0,
|
|
6824
|
+
const indexes = (0, import_react14.useMemo)(() => buildIndexes(treeData), [treeData]);
|
|
6825
|
+
(0, import_react14.useEffect)(() => {
|
|
6776
6826
|
void loadRootDepartments();
|
|
6777
6827
|
}, [loadRootDepartments]);
|
|
6778
6828
|
return {
|
|
@@ -6817,24 +6867,24 @@ function UserPickerPanel({
|
|
|
6817
6867
|
flatNodes,
|
|
6818
6868
|
loadChildren
|
|
6819
6869
|
} = useLazyDepartmentTree(api, treeData);
|
|
6820
|
-
const [departmentKeyword, setDepartmentKeyword] = (0,
|
|
6821
|
-
const [memberKeyword, setMemberKeyword] = (0,
|
|
6822
|
-
const [mobileKeyword, setMobileKeyword] = (0,
|
|
6823
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
6824
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
6825
|
-
const [members, setMembers] = (0,
|
|
6826
|
-
const [memberPage, setMemberPage] = (0,
|
|
6827
|
-
const [memberPageSize, setMemberPageSize] = (0,
|
|
6828
|
-
const [memberTotal, setMemberTotal] = (0,
|
|
6829
|
-
const [memberReloadKey, setMemberReloadKey] = (0,
|
|
6830
|
-
const [loading, setLoading] = (0,
|
|
6831
|
-
const [selected, setSelected] = (0,
|
|
6870
|
+
const [departmentKeyword, setDepartmentKeyword] = (0, import_react15.useState)("");
|
|
6871
|
+
const [memberKeyword, setMemberKeyword] = (0, import_react15.useState)("");
|
|
6872
|
+
const [mobileKeyword, setMobileKeyword] = (0, import_react15.useState)("");
|
|
6873
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react15.useState)("");
|
|
6874
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react15.useState)([]);
|
|
6875
|
+
const [members, setMembers] = (0, import_react15.useState)(() => normalizeUsers(dataSource));
|
|
6876
|
+
const [memberPage, setMemberPage] = (0, import_react15.useState)(1);
|
|
6877
|
+
const [memberPageSize, setMemberPageSize] = (0, import_react15.useState)(DEFAULT_MEMBER_PAGE_SIZE);
|
|
6878
|
+
const [memberTotal, setMemberTotal] = (0, import_react15.useState)(() => normalizeUsers(dataSource).length);
|
|
6879
|
+
const [memberReloadKey, setMemberReloadKey] = (0, import_react15.useState)(0);
|
|
6880
|
+
const [loading, setLoading] = (0, import_react15.useState)(false);
|
|
6881
|
+
const [selected, setSelected] = (0, import_react15.useState)(() => normalizeUsers(value));
|
|
6832
6882
|
const selectedIds = selected.map(getUserId);
|
|
6833
6883
|
const MobileSearchBar = getMobileComponent("SearchBar");
|
|
6834
6884
|
const activeMemberKeyword = (mobile ? mobileKeyword : memberKeyword).trim();
|
|
6835
|
-
const staticUsers = (0,
|
|
6885
|
+
const staticUsers = (0, import_react15.useMemo)(() => normalizeUsers(dataSource), [dataSource]);
|
|
6836
6886
|
const hasStaticUserSource = staticUsers.length > 0;
|
|
6837
|
-
(0,
|
|
6887
|
+
(0, import_react15.useEffect)(() => {
|
|
6838
6888
|
if (mobile) return;
|
|
6839
6889
|
if (currentDeptId || deptTreeData.length === 0) return;
|
|
6840
6890
|
setExpandedKeys(deptTreeData.map((node) => getDepartmentId(node)));
|
|
@@ -6842,17 +6892,17 @@ function UserPickerPanel({
|
|
|
6842
6892
|
setCurrentDeptId(getDepartmentId(deptTreeData[0]));
|
|
6843
6893
|
}
|
|
6844
6894
|
}, [currentDeptId, deptTreeData, loadAllWhenNoDepartment, mobile]);
|
|
6845
|
-
(0,
|
|
6895
|
+
(0, import_react15.useEffect)(() => {
|
|
6846
6896
|
setMemberPage(1);
|
|
6847
6897
|
}, [activeMemberKeyword, currentDeptId, dataSource, mobile]);
|
|
6848
|
-
const handleDepartmentSelect = (0,
|
|
6898
|
+
const handleDepartmentSelect = (0, import_react15.useCallback)((deptId) => {
|
|
6849
6899
|
const nextDeptId = String(deptId || "");
|
|
6850
6900
|
setCurrentDeptId(nextDeptId);
|
|
6851
6901
|
setMemberKeyword("");
|
|
6852
6902
|
setMemberPage(1);
|
|
6853
6903
|
setMemberReloadKey((current) => current + 1);
|
|
6854
6904
|
}, []);
|
|
6855
|
-
(0,
|
|
6905
|
+
(0, import_react15.useEffect)(() => {
|
|
6856
6906
|
let active = true;
|
|
6857
6907
|
const keyword = activeMemberKeyword;
|
|
6858
6908
|
if (hasStaticUserSource) {
|
|
@@ -6925,7 +6975,7 @@ function UserPickerPanel({
|
|
|
6925
6975
|
memberReloadKey,
|
|
6926
6976
|
staticUsers
|
|
6927
6977
|
]);
|
|
6928
|
-
const currentPath = (0,
|
|
6978
|
+
const currentPath = (0, import_react15.useMemo)(() => {
|
|
6929
6979
|
if (!currentDeptId) return [];
|
|
6930
6980
|
const path = [];
|
|
6931
6981
|
let cursor = currentDeptId;
|
|
@@ -6937,7 +6987,7 @@ function UserPickerPanel({
|
|
|
6937
6987
|
}
|
|
6938
6988
|
return path;
|
|
6939
6989
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
6940
|
-
const mobileDepartments = (0,
|
|
6990
|
+
const mobileDepartments = (0, import_react15.useMemo)(() => {
|
|
6941
6991
|
const keyword = mobileKeyword.trim().toLowerCase();
|
|
6942
6992
|
if (keyword) {
|
|
6943
6993
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(keyword)).map((item) => item.node);
|
|
@@ -7201,19 +7251,19 @@ var RequirementSelect = ({
|
|
|
7201
7251
|
selectedUsers,
|
|
7202
7252
|
onChange
|
|
7203
7253
|
}) => {
|
|
7204
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
7205
|
-
const initialCandidates = (0,
|
|
7254
|
+
const [pickerOpen, setPickerOpen] = (0, import_react16.useState)(false);
|
|
7255
|
+
const initialCandidates = (0, import_react16.useMemo)(
|
|
7206
7256
|
() => (requirement.candidateUsers || []).map(normalizeCandidate).filter(Boolean),
|
|
7207
7257
|
[requirement.candidateUsers]
|
|
7208
7258
|
);
|
|
7209
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
7210
|
-
const [loading, setLoading] = (0,
|
|
7211
|
-
(0,
|
|
7259
|
+
const [optionsSource, setOptionsSource] = (0, import_react16.useState)(initialCandidates);
|
|
7260
|
+
const [loading, setLoading] = (0, import_react16.useState)(false);
|
|
7261
|
+
(0, import_react16.useEffect)(() => {
|
|
7212
7262
|
setOptionsSource(
|
|
7213
7263
|
(current) => mergeUsers(initialCandidates, mergeUsers(current, selectedUsers))
|
|
7214
7264
|
);
|
|
7215
7265
|
}, [initialCandidates, selectedUsers]);
|
|
7216
|
-
const loadCandidates = (0,
|
|
7266
|
+
const loadCandidates = (0, import_react16.useCallback)(
|
|
7217
7267
|
async (keyword) => {
|
|
7218
7268
|
setLoading(true);
|
|
7219
7269
|
try {
|
|
@@ -7251,12 +7301,12 @@ var RequirementSelect = ({
|
|
|
7251
7301
|
},
|
|
7252
7302
|
[api, appType, formUuid, initialCandidates.length, requirement.nodeId, requirement.scope]
|
|
7253
7303
|
);
|
|
7254
|
-
(0,
|
|
7304
|
+
(0, import_react16.useEffect)(() => {
|
|
7255
7305
|
if (requirement.scope !== "all" && open && formUuid && appType && requirement.nodeId) {
|
|
7256
7306
|
void loadCandidates();
|
|
7257
7307
|
}
|
|
7258
7308
|
}, [appType, formUuid, loadCandidates, open, requirement.nodeId, requirement.scope]);
|
|
7259
|
-
const options = (0,
|
|
7309
|
+
const options = (0, import_react16.useMemo)(
|
|
7260
7310
|
() => optionsSource.map((user) => ({
|
|
7261
7311
|
value: user.id,
|
|
7262
7312
|
label: getUserLabel(user)
|
|
@@ -7341,9 +7391,9 @@ var InitiatorApproverSelector = ({
|
|
|
7341
7391
|
onOk,
|
|
7342
7392
|
onCancel
|
|
7343
7393
|
}) => {
|
|
7344
|
-
const [selected, setSelected] = (0,
|
|
7345
|
-
const wasOpenRef = (0,
|
|
7346
|
-
(0,
|
|
7394
|
+
const [selected, setSelected] = (0, import_react16.useState)({});
|
|
7395
|
+
const wasOpenRef = (0, import_react16.useRef)(false);
|
|
7396
|
+
(0, import_react16.useEffect)(() => {
|
|
7347
7397
|
if (open && !wasOpenRef.current) {
|
|
7348
7398
|
setSelected(value || EMPTY_SELECTED_MAP);
|
|
7349
7399
|
}
|
|
@@ -7401,20 +7451,20 @@ var normalizeCapabilities = (value) => {
|
|
|
7401
7451
|
function useProcessCapabilities(options) {
|
|
7402
7452
|
const { enabled = true, refreshKey, onError, ...params } = options;
|
|
7403
7453
|
const sdk = usePageSdk();
|
|
7404
|
-
const [capabilities, setCapabilities] = (0,
|
|
7454
|
+
const [capabilities, setCapabilities] = (0, import_react17.useState)(
|
|
7405
7455
|
null
|
|
7406
7456
|
);
|
|
7407
|
-
const [loading, setLoading] = (0,
|
|
7408
|
-
const [error, setError] = (0,
|
|
7409
|
-
const mountedRef = (0,
|
|
7457
|
+
const [loading, setLoading] = (0, import_react17.useState)(false);
|
|
7458
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
7459
|
+
const mountedRef = (0, import_react17.useRef)(true);
|
|
7410
7460
|
const paramsKey = JSON.stringify({ ...params, refreshKey });
|
|
7411
|
-
(0,
|
|
7461
|
+
(0, import_react17.useEffect)(() => {
|
|
7412
7462
|
mountedRef.current = true;
|
|
7413
7463
|
return () => {
|
|
7414
7464
|
mountedRef.current = false;
|
|
7415
7465
|
};
|
|
7416
7466
|
}, []);
|
|
7417
|
-
const refresh = (0,
|
|
7467
|
+
const refresh = (0, import_react17.useCallback)(async () => {
|
|
7418
7468
|
if (!enabled) return capabilities;
|
|
7419
7469
|
setLoading(true);
|
|
7420
7470
|
setError(null);
|
|
@@ -7440,7 +7490,7 @@ function useProcessCapabilities(options) {
|
|
|
7440
7490
|
}
|
|
7441
7491
|
}
|
|
7442
7492
|
}, [capabilities, enabled, onError, paramsKey, sdk]);
|
|
7443
|
-
(0,
|
|
7493
|
+
(0, import_react17.useEffect)(() => {
|
|
7444
7494
|
if (!enabled) return;
|
|
7445
7495
|
void refresh();
|
|
7446
7496
|
}, [enabled, paramsKey, refresh]);
|
|
@@ -7465,8 +7515,8 @@ var requireValue = (value, message7) => {
|
|
|
7465
7515
|
function useProcessActions(options) {
|
|
7466
7516
|
const { capabilities, formUuid, appType, getFormValues, onActionComplete } = options;
|
|
7467
7517
|
const sdk = usePageSdk();
|
|
7468
|
-
const [loadingAction, setLoadingAction] = (0,
|
|
7469
|
-
const buildUpdateFormDataJson = (0,
|
|
7518
|
+
const [loadingAction, setLoadingAction] = (0, import_react17.useState)(null);
|
|
7519
|
+
const buildUpdateFormDataJson = (0, import_react17.useCallback)(
|
|
7470
7520
|
(input) => {
|
|
7471
7521
|
if (input?.updateFormDataJson !== void 0) return input.updateFormDataJson;
|
|
7472
7522
|
const values = getFormValues?.();
|
|
@@ -7474,7 +7524,7 @@ function useProcessActions(options) {
|
|
|
7474
7524
|
},
|
|
7475
7525
|
[getFormValues]
|
|
7476
7526
|
);
|
|
7477
|
-
const executeOperation = (0,
|
|
7527
|
+
const executeOperation = (0, import_react17.useCallback)(
|
|
7478
7528
|
async (operation, input = {}) => {
|
|
7479
7529
|
if (!operation.enabled) return false;
|
|
7480
7530
|
setLoadingAction(operation.key);
|
|
@@ -7584,7 +7634,7 @@ function useProcessActions(options) {
|
|
|
7584
7634
|
sdk
|
|
7585
7635
|
]
|
|
7586
7636
|
);
|
|
7587
|
-
const execute = (0,
|
|
7637
|
+
const execute = (0, import_react17.useCallback)(
|
|
7588
7638
|
async (action, input) => {
|
|
7589
7639
|
const operation = (capabilities?.operations || []).find(
|
|
7590
7640
|
(item) => item.key === action
|
|
@@ -7659,7 +7709,7 @@ var ProcessActionBar = ({
|
|
|
7659
7709
|
position = "sticky"
|
|
7660
7710
|
}) => {
|
|
7661
7711
|
const [form] = import_antd10.Form.useForm();
|
|
7662
|
-
const [activeOperation, setActiveOperation] = (0,
|
|
7712
|
+
const [activeOperation, setActiveOperation] = (0, import_react17.useState)(null);
|
|
7663
7713
|
const autoCapabilities = useProcessCapabilities({
|
|
7664
7714
|
...capabilityParams || {},
|
|
7665
7715
|
enabled: Boolean(capabilityParams) && capabilityParams?.enabled !== false
|
|
@@ -7694,7 +7744,7 @@ var ProcessActionBar = ({
|
|
|
7694
7744
|
}
|
|
7695
7745
|
void actions.executeOperation(operation);
|
|
7696
7746
|
};
|
|
7697
|
-
const actionConfigs = (0,
|
|
7747
|
+
const actionConfigs = (0, import_react17.useMemo)(
|
|
7698
7748
|
() => operations.map((operation) => ({
|
|
7699
7749
|
key: operation.key,
|
|
7700
7750
|
label: operation.label || operation.key,
|
|
@@ -7808,7 +7858,7 @@ var ProcessTimeline = ({
|
|
|
7808
7858
|
var ProcessPreviewPanel = ProcessPreview;
|
|
7809
7859
|
|
|
7810
7860
|
// packages/sdk/src/runtime/react/openxiangdaProvider.tsx
|
|
7811
|
-
var
|
|
7861
|
+
var import_react19 = require("react");
|
|
7812
7862
|
|
|
7813
7863
|
// packages/sdk/src/runtime/host/browserHost.ts
|
|
7814
7864
|
var NAMESPACE_ROOT_CLASS2 = "sy-app-workspace";
|
|
@@ -8197,13 +8247,13 @@ var mountBrowserPageRuntime = async (options) => {
|
|
|
8197
8247
|
};
|
|
8198
8248
|
|
|
8199
8249
|
// packages/sdk/src/runtime/react/auth.tsx
|
|
8200
|
-
var
|
|
8250
|
+
var import_react18 = require("react");
|
|
8201
8251
|
var import_antd11 = require("antd");
|
|
8202
8252
|
var import_icons10 = require("@ant-design/icons");
|
|
8203
8253
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
8204
8254
|
var useAuth = (options = {}) => {
|
|
8205
8255
|
const runtime = useOpenXiangda();
|
|
8206
|
-
const client = (0,
|
|
8256
|
+
const client = (0, import_react18.useMemo)(
|
|
8207
8257
|
() => createAuthClient({
|
|
8208
8258
|
appType: options.appType || runtime.appType,
|
|
8209
8259
|
servicePrefix: options.servicePrefix || runtime.servicePrefix,
|
|
@@ -8218,7 +8268,7 @@ var useAuth = (options = {}) => {
|
|
|
8218
8268
|
runtime.servicePrefix
|
|
8219
8269
|
]
|
|
8220
8270
|
);
|
|
8221
|
-
return (0,
|
|
8271
|
+
return (0, import_react18.useMemo)(
|
|
8222
8272
|
() => ({
|
|
8223
8273
|
client,
|
|
8224
8274
|
getMethods: client.getMethods,
|
|
@@ -8238,12 +8288,12 @@ var useAuth = (options = {}) => {
|
|
|
8238
8288
|
};
|
|
8239
8289
|
var useLoginMethods = (options = {}) => {
|
|
8240
8290
|
const auth = useAuth(options);
|
|
8241
|
-
const [state, setState] = (0,
|
|
8291
|
+
const [state, setState] = (0, import_react18.useState)({
|
|
8242
8292
|
data: null,
|
|
8243
8293
|
loading: true,
|
|
8244
8294
|
error: null
|
|
8245
8295
|
});
|
|
8246
|
-
const reload = (0,
|
|
8296
|
+
const reload = (0, import_react18.useCallback)(async () => {
|
|
8247
8297
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
8248
8298
|
try {
|
|
8249
8299
|
const data = await auth.getMethods();
|
|
@@ -8256,7 +8306,7 @@ var useLoginMethods = (options = {}) => {
|
|
|
8256
8306
|
});
|
|
8257
8307
|
}
|
|
8258
8308
|
}, [auth]);
|
|
8259
|
-
(0,
|
|
8309
|
+
(0, import_react18.useEffect)(() => {
|
|
8260
8310
|
let disposed = false;
|
|
8261
8311
|
const run = async () => {
|
|
8262
8312
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
@@ -8300,17 +8350,17 @@ var LoginPage = ({
|
|
|
8300
8350
|
const methodsState = useLoginMethods(authOptions);
|
|
8301
8351
|
const [passwordForm] = import_antd11.Form.useForm();
|
|
8302
8352
|
const [phoneForm] = import_antd11.Form.useForm();
|
|
8303
|
-
const [activeMethod, setActiveMethod] = (0,
|
|
8353
|
+
const [activeMethod, setActiveMethod] = (0, import_react18.useState)(
|
|
8304
8354
|
defaultMethod || "password"
|
|
8305
8355
|
);
|
|
8306
|
-
const [phonePurpose, setPhonePurpose] = (0,
|
|
8356
|
+
const [phonePurpose, setPhonePurpose] = (0, import_react18.useState)(
|
|
8307
8357
|
"login"
|
|
8308
8358
|
);
|
|
8309
|
-
const [phoneChallengeId, setPhoneChallengeId] = (0,
|
|
8310
|
-
const [passwordChallenge, setPasswordChallenge] = (0,
|
|
8311
|
-
const [submitting, setSubmitting] = (0,
|
|
8312
|
-
const [sendingCode, setSendingCode] = (0,
|
|
8313
|
-
const [error, setError] = (0,
|
|
8359
|
+
const [phoneChallengeId, setPhoneChallengeId] = (0, import_react18.useState)("");
|
|
8360
|
+
const [passwordChallenge, setPasswordChallenge] = (0, import_react18.useState)(null);
|
|
8361
|
+
const [submitting, setSubmitting] = (0, import_react18.useState)(false);
|
|
8362
|
+
const [sendingCode, setSendingCode] = (0, import_react18.useState)(false);
|
|
8363
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
8314
8364
|
const methods = methodsState.methods.filter((method) => method.enabled !== false);
|
|
8315
8365
|
const passwordMethod = findMethod(methods, "password");
|
|
8316
8366
|
const phoneMethod = findMethod(methods, "phone_code");
|
|
@@ -8318,7 +8368,7 @@ var LoginPage = ({
|
|
|
8318
8368
|
const ssoMethod = findMethod(methods, "sso");
|
|
8319
8369
|
const guestMethod = findMethod(methods, "guest");
|
|
8320
8370
|
const allowRegister = methodsState.data?.registration?.mode !== "reject";
|
|
8321
|
-
const tabItems = (0,
|
|
8371
|
+
const tabItems = (0, import_react18.useMemo)(() => {
|
|
8322
8372
|
const items = [];
|
|
8323
8373
|
if (passwordMethod) {
|
|
8324
8374
|
items.push({
|
|
@@ -8437,7 +8487,7 @@ var LoginPage = ({
|
|
|
8437
8487
|
sendingCode,
|
|
8438
8488
|
submitting
|
|
8439
8489
|
]);
|
|
8440
|
-
(0,
|
|
8490
|
+
(0, import_react18.useEffect)(() => {
|
|
8441
8491
|
const firstKey = tabItems[0]?.key;
|
|
8442
8492
|
if (firstKey && !tabItems.some((item) => item.key === activeMethod)) {
|
|
8443
8493
|
setActiveMethod(firstKey);
|
|
@@ -8777,26 +8827,26 @@ var RuntimeHttpError = class extends Error {
|
|
|
8777
8827
|
this.payload = snapshot.payload;
|
|
8778
8828
|
}
|
|
8779
8829
|
};
|
|
8780
|
-
var OpenXiangdaRuntimeContext = (0,
|
|
8830
|
+
var OpenXiangdaRuntimeContext = (0, import_react19.createContext)(null);
|
|
8781
8831
|
var OpenXiangdaProvider = ({
|
|
8782
8832
|
appType,
|
|
8783
8833
|
servicePrefix = "/service",
|
|
8784
8834
|
fetchImpl,
|
|
8785
8835
|
children
|
|
8786
8836
|
}) => {
|
|
8787
|
-
const resolvedFetch = (0,
|
|
8788
|
-
const resolvedAppType = (0,
|
|
8837
|
+
const resolvedFetch = (0, import_react19.useMemo)(() => createBoundFetch(fetchImpl), [fetchImpl]);
|
|
8838
|
+
const resolvedAppType = (0, import_react19.useMemo)(
|
|
8789
8839
|
() => appType || resolveAppTypeFromLocation(),
|
|
8790
8840
|
[appType]
|
|
8791
8841
|
);
|
|
8792
|
-
const [, setAccessTokenState] = (0,
|
|
8793
|
-
const [authState, setAuthState] = (0,
|
|
8842
|
+
const [, setAccessTokenState] = (0, import_react19.useState)(null);
|
|
8843
|
+
const [authState, setAuthState] = (0, import_react19.useState)({
|
|
8794
8844
|
status: "unknown",
|
|
8795
8845
|
error: null
|
|
8796
8846
|
});
|
|
8797
|
-
const accessTokenRef = (0,
|
|
8798
|
-
const refreshRequestRef = (0,
|
|
8799
|
-
const applyAccessToken = (0,
|
|
8847
|
+
const accessTokenRef = (0, import_react19.useRef)(null);
|
|
8848
|
+
const refreshRequestRef = (0, import_react19.useRef)(null);
|
|
8849
|
+
const applyAccessToken = (0, import_react19.useCallback)(
|
|
8800
8850
|
(nextAccessToken, options = {}) => {
|
|
8801
8851
|
if (!nextAccessToken && options.clearIfToken && accessTokenRef.current?.token !== options.clearIfToken) {
|
|
8802
8852
|
return accessTokenRef.current;
|
|
@@ -8814,7 +8864,7 @@ var OpenXiangdaProvider = ({
|
|
|
8814
8864
|
},
|
|
8815
8865
|
[]
|
|
8816
8866
|
);
|
|
8817
|
-
const setAccessToken = (0,
|
|
8867
|
+
const setAccessToken = (0, import_react19.useCallback)(
|
|
8818
8868
|
(nextAccessToken, options = {}) => {
|
|
8819
8869
|
const previousState = accessTokenRef.current;
|
|
8820
8870
|
const nextState = applyAccessToken(nextAccessToken, options);
|
|
@@ -8830,7 +8880,7 @@ var OpenXiangdaProvider = ({
|
|
|
8830
8880
|
},
|
|
8831
8881
|
[applyAccessToken]
|
|
8832
8882
|
);
|
|
8833
|
-
const markUnauthenticated = (0,
|
|
8883
|
+
const markUnauthenticated = (0, import_react19.useCallback)(
|
|
8834
8884
|
(error) => {
|
|
8835
8885
|
const runtimeError = normalizeRuntimeError(error);
|
|
8836
8886
|
applyAccessToken(null);
|
|
@@ -8838,7 +8888,7 @@ var OpenXiangdaProvider = ({
|
|
|
8838
8888
|
},
|
|
8839
8889
|
[applyAccessToken]
|
|
8840
8890
|
);
|
|
8841
|
-
const refreshAccessToken = (0,
|
|
8891
|
+
const refreshAccessToken = (0, import_react19.useCallback)(async () => {
|
|
8842
8892
|
if (!resolvedAppType) return null;
|
|
8843
8893
|
if (!refreshRequestRef.current) {
|
|
8844
8894
|
setAuthState((prev) => ({ ...prev, status: "refreshing", error: null }));
|
|
@@ -8899,7 +8949,7 @@ var OpenXiangdaProvider = ({
|
|
|
8899
8949
|
}
|
|
8900
8950
|
return refreshRequestRef.current;
|
|
8901
8951
|
}, [applyAccessToken, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
8902
|
-
const authorizedFetch = (0,
|
|
8952
|
+
const authorizedFetch = (0, import_react19.useMemo)(
|
|
8903
8953
|
() => createAuthorizedFetch({
|
|
8904
8954
|
appType: resolvedAppType,
|
|
8905
8955
|
baseFetch: resolvedFetch,
|
|
@@ -8909,18 +8959,18 @@ var OpenXiangdaProvider = ({
|
|
|
8909
8959
|
}),
|
|
8910
8960
|
[markUnauthenticated, refreshAccessToken, resolvedAppType, resolvedFetch]
|
|
8911
8961
|
);
|
|
8912
|
-
const getAuthHeaders = (0,
|
|
8962
|
+
const getAuthHeaders = (0, import_react19.useCallback)(() => {
|
|
8913
8963
|
const state2 = accessTokenRef.current;
|
|
8914
8964
|
if (!state2) return {};
|
|
8915
8965
|
const token = resolveAccessTokenForCurrentRoute(state2);
|
|
8916
8966
|
return token ? { authorization: `Bearer ${token}` } : {};
|
|
8917
8967
|
}, []);
|
|
8918
|
-
const [state, setState] = (0,
|
|
8968
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
8919
8969
|
data: null,
|
|
8920
8970
|
loading: true,
|
|
8921
8971
|
error: null
|
|
8922
8972
|
});
|
|
8923
|
-
const reload = (0,
|
|
8973
|
+
const reload = (0, import_react19.useCallback)(async (options = {}) => {
|
|
8924
8974
|
if (!resolvedAppType) {
|
|
8925
8975
|
setState({
|
|
8926
8976
|
data: null,
|
|
@@ -8984,10 +9034,10 @@ var OpenXiangdaProvider = ({
|
|
|
8984
9034
|
}
|
|
8985
9035
|
}
|
|
8986
9036
|
}, [authorizedFetch, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
8987
|
-
(0,
|
|
9037
|
+
(0, import_react19.useEffect)(() => {
|
|
8988
9038
|
void reload();
|
|
8989
9039
|
}, [reload]);
|
|
8990
|
-
const value = (0,
|
|
9040
|
+
const value = (0, import_react19.useMemo)(
|
|
8991
9041
|
() => ({
|
|
8992
9042
|
...state,
|
|
8993
9043
|
appType: resolvedAppType,
|
|
@@ -9013,7 +9063,7 @@ var OpenXiangdaProvider = ({
|
|
|
9013
9063
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(OpenXiangdaRuntimeContext.Provider, { value, children });
|
|
9014
9064
|
};
|
|
9015
9065
|
var useOpenXiangda = () => {
|
|
9016
|
-
const context = (0,
|
|
9066
|
+
const context = (0, import_react19.useContext)(OpenXiangdaRuntimeContext);
|
|
9017
9067
|
if (!context) {
|
|
9018
9068
|
throw new Error("useOpenXiangda must be used inside OpenXiangdaProvider");
|
|
9019
9069
|
}
|
|
@@ -9030,7 +9080,7 @@ var OpenXiangdaPageProvider = ({
|
|
|
9030
9080
|
navigation
|
|
9031
9081
|
}) => {
|
|
9032
9082
|
const runtime = useOpenXiangda();
|
|
9033
|
-
const context = (0,
|
|
9083
|
+
const context = (0, import_react19.useMemo)(() => {
|
|
9034
9084
|
const bootstrap = runtime.data;
|
|
9035
9085
|
const app = toRuntimeRecord(bootstrap?.app);
|
|
9036
9086
|
const user = toRuntimeRecord(bootstrap?.user);
|
|
@@ -9128,12 +9178,12 @@ var usePermission = () => {
|
|
|
9128
9178
|
};
|
|
9129
9179
|
var useCanAccessRoute = (input) => {
|
|
9130
9180
|
const runtime = useOpenXiangda();
|
|
9131
|
-
const [state, setState] = (0,
|
|
9181
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
9132
9182
|
data: null,
|
|
9133
9183
|
loading: true,
|
|
9134
9184
|
error: null
|
|
9135
9185
|
});
|
|
9136
|
-
(0,
|
|
9186
|
+
(0, import_react19.useEffect)(() => {
|
|
9137
9187
|
let disposed = false;
|
|
9138
9188
|
const check = async () => {
|
|
9139
9189
|
const permissions = runtime.data?.permissions;
|
|
@@ -9264,7 +9314,7 @@ var PermissionBoundary = ({
|
|
|
9264
9314
|
};
|
|
9265
9315
|
var useRuntimeAuth = () => {
|
|
9266
9316
|
const runtime = useOpenXiangda();
|
|
9267
|
-
const resolveLoginUrl2 = (0,
|
|
9317
|
+
const resolveLoginUrl2 = (0, import_react19.useCallback)(
|
|
9268
9318
|
async (options = {}) => {
|
|
9269
9319
|
const redirectUri = options.redirectUri || getCurrentHref4();
|
|
9270
9320
|
const domain = options.domain || getCurrentHostname2();
|
|
@@ -9311,7 +9361,7 @@ var useRuntimeAuth = () => {
|
|
|
9311
9361
|
},
|
|
9312
9362
|
[runtime.baseFetchImpl, runtime.data?.app, runtime.servicePrefix]
|
|
9313
9363
|
);
|
|
9314
|
-
const redirectToLogin = (0,
|
|
9364
|
+
const redirectToLogin = (0, import_react19.useCallback)(
|
|
9315
9365
|
async (options = {}) => {
|
|
9316
9366
|
const loginUrl = await resolveLoginUrl2(options);
|
|
9317
9367
|
if (typeof window !== "undefined") {
|
|
@@ -9325,7 +9375,7 @@ var useRuntimeAuth = () => {
|
|
|
9325
9375
|
},
|
|
9326
9376
|
[resolveLoginUrl2]
|
|
9327
9377
|
);
|
|
9328
|
-
const logout = (0,
|
|
9378
|
+
const logout = (0, import_react19.useCallback)(async () => {
|
|
9329
9379
|
const response = await runtime.baseFetchImpl(
|
|
9330
9380
|
buildServiceUrl3(runtime.servicePrefix, "/api/auth/logout"),
|
|
9331
9381
|
{
|
|
@@ -9345,7 +9395,7 @@ var useRuntimeAuth = () => {
|
|
|
9345
9395
|
runtime.setAccessToken(null);
|
|
9346
9396
|
return payload;
|
|
9347
9397
|
}, [runtime.baseFetchImpl, runtime.servicePrefix, runtime.setAccessToken]);
|
|
9348
|
-
const logoutAndRedirect = (0,
|
|
9398
|
+
const logoutAndRedirect = (0, import_react19.useCallback)(
|
|
9349
9399
|
async (options = {}) => {
|
|
9350
9400
|
try {
|
|
9351
9401
|
await logout();
|
|
@@ -9356,7 +9406,7 @@ var useRuntimeAuth = () => {
|
|
|
9356
9406
|
},
|
|
9357
9407
|
[logout, redirectToLogin]
|
|
9358
9408
|
);
|
|
9359
|
-
return (0,
|
|
9409
|
+
return (0, import_react19.useMemo)(
|
|
9360
9410
|
() => ({
|
|
9361
9411
|
logout,
|
|
9362
9412
|
logoutAndRedirect,
|
|
@@ -9375,7 +9425,7 @@ var RuntimeAuthGuard = ({
|
|
|
9375
9425
|
}) => {
|
|
9376
9426
|
const runtime = useOpenXiangda();
|
|
9377
9427
|
const auth = useRuntimeAuth();
|
|
9378
|
-
const redirectedRef = (0,
|
|
9428
|
+
const redirectedRef = (0, import_react19.useRef)(false);
|
|
9379
9429
|
const currentPath = getCurrentPathname2();
|
|
9380
9430
|
const excluded = isRuntimeAuthGuardExcluded(
|
|
9381
9431
|
currentPath,
|
|
@@ -9383,7 +9433,7 @@ var RuntimeAuthGuard = ({
|
|
|
9383
9433
|
excludedPaths
|
|
9384
9434
|
);
|
|
9385
9435
|
const shouldRedirect = !disabled && !excluded && !runtime.loading && (runtime.authState.status === "unauthenticated" || runtime.error?.type === "unauthenticated");
|
|
9386
|
-
(0,
|
|
9436
|
+
(0, import_react19.useEffect)(() => {
|
|
9387
9437
|
if (!shouldRedirect || redirectedRef.current) return;
|
|
9388
9438
|
redirectedRef.current = true;
|
|
9389
9439
|
void auth.redirectToLogin({
|
|
@@ -9726,7 +9776,7 @@ var resolveAppTypeFromLocation = () => {
|
|
|
9726
9776
|
};
|
|
9727
9777
|
|
|
9728
9778
|
// packages/sdk/src/runtime/react/publicAccess.tsx
|
|
9729
|
-
var
|
|
9779
|
+
var import_react20 = require("react");
|
|
9730
9780
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
9731
9781
|
var usePublicAccess = (options = {}) => {
|
|
9732
9782
|
const runtime = useOpenXiangda();
|
|
@@ -9744,14 +9794,14 @@ var usePublicAccess = (options = {}) => {
|
|
|
9744
9794
|
autoStart = true,
|
|
9745
9795
|
...sessionInput
|
|
9746
9796
|
} = options;
|
|
9747
|
-
const [session, setSession] = (0,
|
|
9748
|
-
const [error, setError] = (0,
|
|
9749
|
-
const [loading, setLoading] = (0,
|
|
9750
|
-
const activeSessionRef = (0,
|
|
9751
|
-
const mountedRef = (0,
|
|
9797
|
+
const [session, setSession] = (0, import_react20.useState)(null);
|
|
9798
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
9799
|
+
const [loading, setLoading] = (0, import_react20.useState)(Boolean(autoStart));
|
|
9800
|
+
const activeSessionRef = (0, import_react20.useRef)(null);
|
|
9801
|
+
const mountedRef = (0, import_react20.useRef)(true);
|
|
9752
9802
|
const sessionInputKey = JSON.stringify(sessionInput);
|
|
9753
|
-
const stableSessionInput = (0,
|
|
9754
|
-
const client = (0,
|
|
9803
|
+
const stableSessionInput = (0, import_react20.useMemo)(() => sessionInput, [sessionInputKey]);
|
|
9804
|
+
const client = (0, import_react20.useMemo)(
|
|
9755
9805
|
() => createPublicAccessClient({
|
|
9756
9806
|
appType,
|
|
9757
9807
|
servicePrefix,
|
|
@@ -9759,7 +9809,7 @@ var usePublicAccess = (options = {}) => {
|
|
|
9759
9809
|
}),
|
|
9760
9810
|
[appType, fetchImpl, servicePrefix]
|
|
9761
9811
|
);
|
|
9762
|
-
const startSession = (0,
|
|
9812
|
+
const startSession = (0, import_react20.useCallback)(
|
|
9763
9813
|
async (input = {}) => {
|
|
9764
9814
|
setLoading(true);
|
|
9765
9815
|
setError(null);
|
|
@@ -9805,11 +9855,11 @@ var usePublicAccess = (options = {}) => {
|
|
|
9805
9855
|
},
|
|
9806
9856
|
[client, reloadRuntime, setAccessToken, stableSessionInput]
|
|
9807
9857
|
);
|
|
9808
|
-
(0,
|
|
9858
|
+
(0, import_react20.useEffect)(() => {
|
|
9809
9859
|
if (!autoStart) return;
|
|
9810
9860
|
void startSession().catch(() => void 0);
|
|
9811
9861
|
}, [autoStart, startSession]);
|
|
9812
|
-
(0,
|
|
9862
|
+
(0, import_react20.useEffect)(
|
|
9813
9863
|
() => {
|
|
9814
9864
|
mountedRef.current = true;
|
|
9815
9865
|
return () => {
|
|
@@ -9851,30 +9901,30 @@ var readTicketFromLocation = () => {
|
|
|
9851
9901
|
var readPathFromLocation = () => typeof window === "undefined" ? void 0 : window.location.pathname;
|
|
9852
9902
|
|
|
9853
9903
|
// packages/sdk/src/runtime/host/builtinRouteRenderer.tsx
|
|
9854
|
-
var
|
|
9904
|
+
var import_react88 = require("react");
|
|
9855
9905
|
var import_antd44 = require("antd");
|
|
9856
9906
|
|
|
9857
9907
|
// packages/sdk/src/components/modules/DataManagementList.tsx
|
|
9858
|
-
var
|
|
9908
|
+
var import_react87 = require("react");
|
|
9859
9909
|
var import_antd43 = require("antd");
|
|
9860
9910
|
var import_dayjs12 = __toESM(require("dayjs"));
|
|
9861
9911
|
var import_icons20 = require("@ant-design/icons");
|
|
9862
9912
|
|
|
9863
9913
|
// packages/sdk/src/components/templates/StandardFormPage.tsx
|
|
9864
|
-
var
|
|
9914
|
+
var import_react86 = require("react");
|
|
9865
9915
|
|
|
9866
9916
|
// packages/sdk/src/components/templates/FormDetailTemplate.tsx
|
|
9867
|
-
var
|
|
9917
|
+
var import_react77 = require("react");
|
|
9868
9918
|
var import_dayjs10 = __toESM(require("dayjs"));
|
|
9869
9919
|
|
|
9870
9920
|
// packages/sdk/src/components/core/FormProvider.tsx
|
|
9871
|
-
var
|
|
9921
|
+
var import_react68 = __toESM(require("react"));
|
|
9872
9922
|
|
|
9873
9923
|
// packages/sdk/src/components/core/FormContext.ts
|
|
9874
|
-
var
|
|
9875
|
-
var FormContext = (0,
|
|
9924
|
+
var import_react21 = require("react");
|
|
9925
|
+
var FormContext = (0, import_react21.createContext)(null);
|
|
9876
9926
|
function useFormContext() {
|
|
9877
|
-
const context = (0,
|
|
9927
|
+
const context = (0, import_react21.useContext)(FormContext);
|
|
9878
9928
|
if (!context) {
|
|
9879
9929
|
throw new Error("useFormContext must be used within a FormProvider");
|
|
9880
9930
|
}
|
|
@@ -9882,21 +9932,21 @@ function useFormContext() {
|
|
|
9882
9932
|
}
|
|
9883
9933
|
|
|
9884
9934
|
// packages/sdk/src/components/core/ComponentRegistry.tsx
|
|
9885
|
-
var
|
|
9886
|
-
var ComponentRegistryContext = (0,
|
|
9935
|
+
var import_react22 = __toESM(require("react"));
|
|
9936
|
+
var ComponentRegistryContext = (0, import_react22.createContext)(null);
|
|
9887
9937
|
function ComponentRegistryProvider({
|
|
9888
9938
|
components,
|
|
9889
9939
|
children
|
|
9890
9940
|
}) {
|
|
9891
|
-
const [registry, setRegistry] =
|
|
9892
|
-
const register =
|
|
9941
|
+
const [registry, setRegistry] = import_react22.default.useState(components);
|
|
9942
|
+
const register = import_react22.default.useCallback((name, component) => {
|
|
9893
9943
|
setRegistry((prev) => ({ ...prev, [name]: component }));
|
|
9894
9944
|
}, []);
|
|
9895
|
-
const value =
|
|
9896
|
-
return
|
|
9945
|
+
const value = import_react22.default.useMemo(() => ({ registry, register }), [registry, register]);
|
|
9946
|
+
return import_react22.default.createElement(ComponentRegistryContext.Provider, { value }, children);
|
|
9897
9947
|
}
|
|
9898
9948
|
function useComponent(componentName) {
|
|
9899
|
-
const context = (0,
|
|
9949
|
+
const context = (0, import_react22.useContext)(ComponentRegistryContext);
|
|
9900
9950
|
if (!context) {
|
|
9901
9951
|
return null;
|
|
9902
9952
|
}
|
|
@@ -9904,7 +9954,7 @@ function useComponent(componentName) {
|
|
|
9904
9954
|
}
|
|
9905
9955
|
|
|
9906
9956
|
// packages/sdk/src/components/fields/TextField/index.tsx
|
|
9907
|
-
var
|
|
9957
|
+
var import_react24 = require("react");
|
|
9908
9958
|
|
|
9909
9959
|
// packages/sdk/src/components/core/FieldWrapper.tsx
|
|
9910
9960
|
var Antd = __toESM(require("antd"));
|
|
@@ -10018,7 +10068,7 @@ function FieldWrapper({
|
|
|
10018
10068
|
}
|
|
10019
10069
|
|
|
10020
10070
|
// packages/sdk/src/components/hooks/useDeviceDetect.ts
|
|
10021
|
-
var
|
|
10071
|
+
var import_react23 = require("react");
|
|
10022
10072
|
var MOBILE_BREAKPOINT = 768;
|
|
10023
10073
|
function subscribe(callback) {
|
|
10024
10074
|
let prev = window.innerWidth < MOBILE_BREAKPOINT;
|
|
@@ -10036,7 +10086,7 @@ function getSnapshot() {
|
|
|
10036
10086
|
return window.innerWidth < MOBILE_BREAKPOINT;
|
|
10037
10087
|
}
|
|
10038
10088
|
function useDeviceDetect() {
|
|
10039
|
-
const isMobile = (0,
|
|
10089
|
+
const isMobile = (0, import_react23.useSyncExternalStore)(
|
|
10040
10090
|
subscribe,
|
|
10041
10091
|
getSnapshot,
|
|
10042
10092
|
/* v8 ignore next */
|
|
@@ -10192,7 +10242,7 @@ function TextField(props) {
|
|
|
10192
10242
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10193
10243
|
const { isMobile } = useDeviceDetect();
|
|
10194
10244
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10195
|
-
(0,
|
|
10245
|
+
(0, import_react24.useEffect)(() => {
|
|
10196
10246
|
registerField(fieldId);
|
|
10197
10247
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10198
10248
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10217,7 +10267,7 @@ function TextField(props) {
|
|
|
10217
10267
|
}
|
|
10218
10268
|
|
|
10219
10269
|
// packages/sdk/src/components/fields/NumberField/index.tsx
|
|
10220
|
-
var
|
|
10270
|
+
var import_react25 = require("react");
|
|
10221
10271
|
|
|
10222
10272
|
// packages/sdk/src/components/fields/NumberField/NumberFieldPC.tsx
|
|
10223
10273
|
var import_antd13 = require("antd");
|
|
@@ -10439,7 +10489,7 @@ function NumberField(props) {
|
|
|
10439
10489
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10440
10490
|
const { isMobile } = useDeviceDetect();
|
|
10441
10491
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10442
|
-
(0,
|
|
10492
|
+
(0, import_react25.useEffect)(() => {
|
|
10443
10493
|
registerField(fieldId);
|
|
10444
10494
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10445
10495
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10464,7 +10514,7 @@ function NumberField(props) {
|
|
|
10464
10514
|
}
|
|
10465
10515
|
|
|
10466
10516
|
// packages/sdk/src/components/fields/TextAreaField/index.tsx
|
|
10467
|
-
var
|
|
10517
|
+
var import_react26 = require("react");
|
|
10468
10518
|
|
|
10469
10519
|
// packages/sdk/src/components/fields/TextAreaField/TextAreaFieldPC.tsx
|
|
10470
10520
|
var import_antd14 = require("antd");
|
|
@@ -10611,7 +10661,7 @@ function TextAreaField(props) {
|
|
|
10611
10661
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10612
10662
|
const { isMobile } = useDeviceDetect();
|
|
10613
10663
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10614
|
-
(0,
|
|
10664
|
+
(0, import_react26.useEffect)(() => {
|
|
10615
10665
|
registerField(fieldId);
|
|
10616
10666
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10617
10667
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10636,14 +10686,14 @@ function TextAreaField(props) {
|
|
|
10636
10686
|
}
|
|
10637
10687
|
|
|
10638
10688
|
// packages/sdk/src/components/fields/SelectField/index.tsx
|
|
10639
|
-
var
|
|
10689
|
+
var import_react31 = require("react");
|
|
10640
10690
|
|
|
10641
10691
|
// packages/sdk/src/components/fields/SelectField/SelectFieldPC.tsx
|
|
10642
|
-
var
|
|
10692
|
+
var import_react29 = require("react");
|
|
10643
10693
|
var import_antd16 = require("antd");
|
|
10644
10694
|
|
|
10645
10695
|
// packages/sdk/src/components/fields/shared/optionDisplay.tsx
|
|
10646
|
-
var
|
|
10696
|
+
var import_react27 = __toESM(require("react"));
|
|
10647
10697
|
var import_antd15 = require("antd");
|
|
10648
10698
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
10649
10699
|
var PRESET_COLORS = {
|
|
@@ -10709,12 +10759,12 @@ function renderReadonlyOptions(options, coloredOptions, tagWhenPlain = false) {
|
|
|
10709
10759
|
if (options.length === 0) return "--";
|
|
10710
10760
|
if (!coloredOptions && !tagWhenPlain) return options.map((option) => option.label).join(", ");
|
|
10711
10761
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "sy-option-readonly-list", children: options.map(
|
|
10712
|
-
(option) => coloredOptions && option.color ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10762
|
+
(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)
|
|
10713
10763
|
) });
|
|
10714
10764
|
}
|
|
10715
10765
|
|
|
10716
10766
|
// packages/sdk/src/components/fields/SelectField/useLinkedFormRemoteOptions.ts
|
|
10717
|
-
var
|
|
10767
|
+
var import_react28 = require("react");
|
|
10718
10768
|
|
|
10719
10769
|
// packages/sdk/src/components/core/optionSource.ts
|
|
10720
10770
|
var DEFAULT_OPTION_PAGE_SIZE = 200;
|
|
@@ -10929,11 +10979,11 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10929
10979
|
const linkedForm = optionSource?.type === "linkedForm" ? optionSource.linkedForm : void 0;
|
|
10930
10980
|
const enabled = Boolean(linkedForm?.remoteSearch);
|
|
10931
10981
|
const minChars = linkedForm?.remoteSearchMinChars ?? 0;
|
|
10932
|
-
const [remoteOptions, setRemoteOptions] = (0,
|
|
10933
|
-
const [loading, setLoading] = (0,
|
|
10934
|
-
const timerRef = (0,
|
|
10935
|
-
const requestRef = (0,
|
|
10936
|
-
const reset = (0,
|
|
10982
|
+
const [remoteOptions, setRemoteOptions] = (0, import_react28.useState)(null);
|
|
10983
|
+
const [loading, setLoading] = (0, import_react28.useState)(false);
|
|
10984
|
+
const timerRef = (0, import_react28.useRef)(null);
|
|
10985
|
+
const requestRef = (0, import_react28.useRef)(0);
|
|
10986
|
+
const reset = (0, import_react28.useCallback)(() => {
|
|
10937
10987
|
requestRef.current += 1;
|
|
10938
10988
|
if (timerRef.current) {
|
|
10939
10989
|
clearTimeout(timerRef.current);
|
|
@@ -10942,7 +10992,7 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10942
10992
|
setRemoteOptions(null);
|
|
10943
10993
|
setLoading(false);
|
|
10944
10994
|
}, []);
|
|
10945
|
-
const search = (0,
|
|
10995
|
+
const search = (0, import_react28.useCallback)(
|
|
10946
10996
|
(keyword) => {
|
|
10947
10997
|
if (!enabled || !linkedForm) return;
|
|
10948
10998
|
const trimmedKeyword = keyword.trim();
|
|
@@ -10970,14 +11020,14 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10970
11020
|
},
|
|
10971
11021
|
[enabled, linkedForm, minChars, reset, runtime]
|
|
10972
11022
|
);
|
|
10973
|
-
(0,
|
|
11023
|
+
(0, import_react28.useEffect)(
|
|
10974
11024
|
() => () => {
|
|
10975
11025
|
requestRef.current += 1;
|
|
10976
11026
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
10977
11027
|
},
|
|
10978
11028
|
[]
|
|
10979
11029
|
);
|
|
10980
|
-
const options = (0,
|
|
11030
|
+
const options = (0, import_react28.useMemo)(
|
|
10981
11031
|
() => mergeOptionItems(remoteOptions ?? baseOptions, selectedOptions),
|
|
10982
11032
|
[baseOptions, remoteOptions, selectedOptions]
|
|
10983
11033
|
);
|
|
@@ -11025,7 +11075,7 @@ function SelectFieldPC({
|
|
|
11025
11075
|
const { formData, setFieldValue } = useFormContext();
|
|
11026
11076
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
11027
11077
|
const disabled = behavior === "DISABLED";
|
|
11028
|
-
const selectedOptions = (0,
|
|
11078
|
+
const selectedOptions = (0, import_react29.useMemo)(() => value ? [value] : [], [value]);
|
|
11029
11079
|
const remote = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
11030
11080
|
const displayOptions = remote.options;
|
|
11031
11081
|
const handleChange = (val) => {
|
|
@@ -11066,7 +11116,7 @@ function SelectFieldPC({
|
|
|
11066
11116
|
}
|
|
11067
11117
|
|
|
11068
11118
|
// packages/sdk/src/components/fields/SelectField/SelectFieldMobile.tsx
|
|
11069
|
-
var
|
|
11119
|
+
var import_react30 = require("react");
|
|
11070
11120
|
|
|
11071
11121
|
// packages/sdk/src/components/fields/shared/MobileField.tsx
|
|
11072
11122
|
var import_antd_mobile4 = require("antd-mobile");
|
|
@@ -11247,10 +11297,10 @@ function SelectFieldMobile({
|
|
|
11247
11297
|
const { formData, setFieldValue } = useFormContext();
|
|
11248
11298
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
11249
11299
|
const disabled = behavior === "DISABLED";
|
|
11250
|
-
const [visible, setVisible] = (0,
|
|
11251
|
-
const [search, setSearch] = (0,
|
|
11252
|
-
const [tempValue, setTempValue] = (0,
|
|
11253
|
-
const selectedOptions = (0,
|
|
11300
|
+
const [visible, setVisible] = (0, import_react30.useState)(false);
|
|
11301
|
+
const [search, setSearch] = (0, import_react30.useState)("");
|
|
11302
|
+
const [tempValue, setTempValue] = (0, import_react30.useState)(value ?? null);
|
|
11303
|
+
const selectedOptions = (0, import_react30.useMemo)(() => value ? [value] : tempValue ? [tempValue] : [], [
|
|
11254
11304
|
tempValue,
|
|
11255
11305
|
value
|
|
11256
11306
|
]);
|
|
@@ -11261,7 +11311,7 @@ function SelectFieldMobile({
|
|
|
11261
11311
|
reset: resetRemoteOptions,
|
|
11262
11312
|
search: searchRemoteOptions
|
|
11263
11313
|
} = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
11264
|
-
const filteredOptions = (0,
|
|
11314
|
+
const filteredOptions = (0, import_react30.useMemo)(() => {
|
|
11265
11315
|
if (remoteEnabled) return remoteOptions;
|
|
11266
11316
|
const keyword = search.trim().toLowerCase();
|
|
11267
11317
|
if (!keyword) return options;
|
|
@@ -11269,7 +11319,7 @@ function SelectFieldMobile({
|
|
|
11269
11319
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
11270
11320
|
);
|
|
11271
11321
|
}, [options, remoteEnabled, remoteOptions, search]);
|
|
11272
|
-
(0,
|
|
11322
|
+
(0, import_react30.useEffect)(() => {
|
|
11273
11323
|
if (!visible || !remoteEnabled) return;
|
|
11274
11324
|
searchRemoteOptions(search);
|
|
11275
11325
|
}, [remoteEnabled, search, searchRemoteOptions, visible]);
|
|
@@ -11381,7 +11431,7 @@ function SelectField(props) {
|
|
|
11381
11431
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11382
11432
|
const { isMobile } = useDeviceDetect();
|
|
11383
11433
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11384
|
-
(0,
|
|
11434
|
+
(0, import_react31.useEffect)(() => {
|
|
11385
11435
|
registerField(fieldId);
|
|
11386
11436
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11387
11437
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11406,7 +11456,7 @@ function SelectField(props) {
|
|
|
11406
11456
|
}
|
|
11407
11457
|
|
|
11408
11458
|
// packages/sdk/src/components/fields/MultiSelectField/index.tsx
|
|
11409
|
-
var
|
|
11459
|
+
var import_react33 = require("react");
|
|
11410
11460
|
|
|
11411
11461
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldPC.tsx
|
|
11412
11462
|
var import_antd17 = require("antd");
|
|
@@ -11466,7 +11516,7 @@ function MultiSelectFieldPC({
|
|
|
11466
11516
|
}
|
|
11467
11517
|
|
|
11468
11518
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldMobile.tsx
|
|
11469
|
-
var
|
|
11519
|
+
var import_react32 = require("react");
|
|
11470
11520
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
11471
11521
|
function MultiSelectFieldMobile({
|
|
11472
11522
|
fieldId,
|
|
@@ -11483,17 +11533,17 @@ function MultiSelectFieldMobile({
|
|
|
11483
11533
|
const { formData, setFieldValue } = useFormContext();
|
|
11484
11534
|
const value = controlledValue !== void 0 ? controlledValue ?? [] : formData[fieldId] ?? [];
|
|
11485
11535
|
const disabled = behavior === "DISABLED";
|
|
11486
|
-
const [visible, setVisible] = (0,
|
|
11487
|
-
const [search, setSearch] = (0,
|
|
11488
|
-
const [tempValues, setTempValues] = (0,
|
|
11489
|
-
const filteredOptions = (0,
|
|
11536
|
+
const [visible, setVisible] = (0, import_react32.useState)(false);
|
|
11537
|
+
const [search, setSearch] = (0, import_react32.useState)("");
|
|
11538
|
+
const [tempValues, setTempValues] = (0, import_react32.useState)(value);
|
|
11539
|
+
const filteredOptions = (0, import_react32.useMemo)(() => {
|
|
11490
11540
|
const keyword = search.trim().toLowerCase();
|
|
11491
11541
|
if (!keyword) return options;
|
|
11492
11542
|
return options.filter(
|
|
11493
11543
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
11494
11544
|
);
|
|
11495
11545
|
}, [options, search]);
|
|
11496
|
-
const tempValueSet = (0,
|
|
11546
|
+
const tempValueSet = (0, import_react32.useMemo)(
|
|
11497
11547
|
() => new Set(tempValues.map((option) => option.value)),
|
|
11498
11548
|
[tempValues]
|
|
11499
11549
|
);
|
|
@@ -11610,7 +11660,7 @@ function MultiSelectField(props) {
|
|
|
11610
11660
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11611
11661
|
const { isMobile } = useDeviceDetect();
|
|
11612
11662
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11613
|
-
(0,
|
|
11663
|
+
(0, import_react33.useEffect)(() => {
|
|
11614
11664
|
registerField(fieldId);
|
|
11615
11665
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11616
11666
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11635,7 +11685,7 @@ function MultiSelectField(props) {
|
|
|
11635
11685
|
}
|
|
11636
11686
|
|
|
11637
11687
|
// packages/sdk/src/components/fields/RadioField/index.tsx
|
|
11638
|
-
var
|
|
11688
|
+
var import_react34 = require("react");
|
|
11639
11689
|
|
|
11640
11690
|
// packages/sdk/src/components/fields/RadioField/RadioFieldPC.tsx
|
|
11641
11691
|
var import_antd18 = require("antd");
|
|
@@ -11781,7 +11831,7 @@ function RadioField(props) {
|
|
|
11781
11831
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11782
11832
|
const { isMobile } = useDeviceDetect();
|
|
11783
11833
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11784
|
-
(0,
|
|
11834
|
+
(0, import_react34.useEffect)(() => {
|
|
11785
11835
|
registerField(fieldId);
|
|
11786
11836
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11787
11837
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11806,7 +11856,7 @@ function RadioField(props) {
|
|
|
11806
11856
|
}
|
|
11807
11857
|
|
|
11808
11858
|
// packages/sdk/src/components/fields/CheckboxField/index.tsx
|
|
11809
|
-
var
|
|
11859
|
+
var import_react35 = require("react");
|
|
11810
11860
|
|
|
11811
11861
|
// packages/sdk/src/components/fields/CheckboxField/CheckboxFieldPC.tsx
|
|
11812
11862
|
var import_antd19 = require("antd");
|
|
@@ -11963,7 +12013,7 @@ function CheckboxField(props) {
|
|
|
11963
12013
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11964
12014
|
const { isMobile } = useDeviceDetect();
|
|
11965
12015
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11966
|
-
(0,
|
|
12016
|
+
(0, import_react35.useEffect)(() => {
|
|
11967
12017
|
registerField(fieldId);
|
|
11968
12018
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11969
12019
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11988,7 +12038,7 @@ function CheckboxField(props) {
|
|
|
11988
12038
|
}
|
|
11989
12039
|
|
|
11990
12040
|
// packages/sdk/src/components/fields/DateField/index.tsx
|
|
11991
|
-
var
|
|
12041
|
+
var import_react38 = require("react");
|
|
11992
12042
|
|
|
11993
12043
|
// packages/sdk/src/components/fields/DateField/DateFieldPC.tsx
|
|
11994
12044
|
var import_antd20 = require("antd");
|
|
@@ -12138,12 +12188,12 @@ function DateFieldPC({
|
|
|
12138
12188
|
}
|
|
12139
12189
|
|
|
12140
12190
|
// packages/sdk/src/components/fields/DateField/DateFieldMobile.tsx
|
|
12141
|
-
var
|
|
12191
|
+
var import_react37 = require("react");
|
|
12142
12192
|
var import_antd_mobile7 = require("antd-mobile");
|
|
12143
12193
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
12144
12194
|
|
|
12145
12195
|
// packages/sdk/src/components/fields/shared/MobileDatePicker.tsx
|
|
12146
|
-
var
|
|
12196
|
+
var import_react36 = __toESM(require("react"));
|
|
12147
12197
|
var import_antd_mobile5 = require("antd-mobile");
|
|
12148
12198
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
12149
12199
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
@@ -12241,7 +12291,7 @@ function MobileDateTimePickerView({
|
|
|
12241
12291
|
onChange
|
|
12242
12292
|
}) {
|
|
12243
12293
|
const precision = resolveTimePickerPrecision(dateFormat);
|
|
12244
|
-
const columns =
|
|
12294
|
+
const columns = import_react36.default.useMemo(
|
|
12245
12295
|
() => [getDateOptions(value, min, max), ...getTimePickerColumns(precision)],
|
|
12246
12296
|
[value, min, max, precision]
|
|
12247
12297
|
);
|
|
@@ -12279,12 +12329,12 @@ function DateFieldMobile({
|
|
|
12279
12329
|
const { formData, setFieldValue } = useFormContext();
|
|
12280
12330
|
const value = formData[fieldId];
|
|
12281
12331
|
const disabled = behavior === "DISABLED";
|
|
12282
|
-
const [visible, setVisible] = (0,
|
|
12283
|
-
const [mode, setMode] = (0,
|
|
12332
|
+
const [visible, setVisible] = (0, import_react37.useState)(false);
|
|
12333
|
+
const [mode, setMode] = (0, import_react37.useState)("date");
|
|
12284
12334
|
const format = getDateDisplayFormat(dateFormat, showTime);
|
|
12285
12335
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
12286
12336
|
const pickerValue = value && (0, import_dayjs7.default)(value).isValid() ? (0, import_dayjs7.default)(value).toDate() : /* @__PURE__ */ new Date();
|
|
12287
|
-
const [tempDate, setTempDate] = (0,
|
|
12337
|
+
const [tempDate, setTempDate] = (0, import_react37.useState)(pickerValue);
|
|
12288
12338
|
const { min, max } = getDateMinMax(dateRestriction);
|
|
12289
12339
|
const openPicker = () => {
|
|
12290
12340
|
if (disabled) return;
|
|
@@ -12421,7 +12471,7 @@ function DateField(props) {
|
|
|
12421
12471
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
12422
12472
|
const { isMobile } = useDeviceDetect();
|
|
12423
12473
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
12424
|
-
(0,
|
|
12474
|
+
(0, import_react38.useEffect)(() => {
|
|
12425
12475
|
registerField(fieldId);
|
|
12426
12476
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
12427
12477
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -12446,7 +12496,7 @@ function DateField(props) {
|
|
|
12446
12496
|
}
|
|
12447
12497
|
|
|
12448
12498
|
// packages/sdk/src/components/fields/CascadeDateField/index.tsx
|
|
12449
|
-
var
|
|
12499
|
+
var import_react40 = require("react");
|
|
12450
12500
|
|
|
12451
12501
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldPC.tsx
|
|
12452
12502
|
var import_antd21 = require("antd");
|
|
@@ -12502,7 +12552,7 @@ function CascadeDateFieldPC({
|
|
|
12502
12552
|
}
|
|
12503
12553
|
|
|
12504
12554
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldMobile.tsx
|
|
12505
|
-
var
|
|
12555
|
+
var import_react39 = require("react");
|
|
12506
12556
|
var import_antd_mobile8 = require("antd-mobile");
|
|
12507
12557
|
var import_dayjs9 = __toESM(require("dayjs"));
|
|
12508
12558
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
@@ -12520,11 +12570,11 @@ function CascadeDateFieldMobile({
|
|
|
12520
12570
|
const { formData, setFieldValue } = useFormContext();
|
|
12521
12571
|
const value = normalizeDateRangeValue(formData[fieldId]);
|
|
12522
12572
|
const disabled = behavior === "DISABLED";
|
|
12523
|
-
const [visible, setVisible] = (0,
|
|
12524
|
-
const [tempRange, setTempRange] = (0,
|
|
12525
|
-
const [timeStep, setTimeStep] = (0,
|
|
12526
|
-
const [tempStart, setTempStart] = (0,
|
|
12527
|
-
const [tempEnd, setTempEnd] = (0,
|
|
12573
|
+
const [visible, setVisible] = (0, import_react39.useState)(false);
|
|
12574
|
+
const [tempRange, setTempRange] = (0, import_react39.useState)(null);
|
|
12575
|
+
const [timeStep, setTimeStep] = (0, import_react39.useState)("start");
|
|
12576
|
+
const [tempStart, setTempStart] = (0, import_react39.useState)(/* @__PURE__ */ new Date());
|
|
12577
|
+
const [tempEnd, setTempEnd] = (0, import_react39.useState)(/* @__PURE__ */ new Date());
|
|
12528
12578
|
const format = getDateDisplayFormat(dateFormat, showTime);
|
|
12529
12579
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
12530
12580
|
const startValue = value?.start && (0, import_dayjs9.default)(value.start).isValid() ? (0, import_dayjs9.default)(value.start).toDate() : void 0;
|
|
@@ -12688,7 +12738,7 @@ function CascadeDateField(props) {
|
|
|
12688
12738
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
12689
12739
|
const { isMobile } = useDeviceDetect();
|
|
12690
12740
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
12691
|
-
(0,
|
|
12741
|
+
(0, import_react40.useEffect)(() => {
|
|
12692
12742
|
registerField(fieldId);
|
|
12693
12743
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
12694
12744
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -12713,10 +12763,10 @@ function CascadeDateField(props) {
|
|
|
12713
12763
|
}
|
|
12714
12764
|
|
|
12715
12765
|
// packages/sdk/src/components/fields/AttachmentField/index.tsx
|
|
12716
|
-
var
|
|
12766
|
+
var import_react43 = require("react");
|
|
12717
12767
|
|
|
12718
12768
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldPC.tsx
|
|
12719
|
-
var
|
|
12769
|
+
var import_react41 = __toESM(require("react"));
|
|
12720
12770
|
var import_antd22 = require("antd");
|
|
12721
12771
|
|
|
12722
12772
|
// packages/sdk/src/components/fields/shared/fileTransfer.ts
|
|
@@ -12762,13 +12812,13 @@ function AttachmentFieldPC({
|
|
|
12762
12812
|
onChange
|
|
12763
12813
|
}) {
|
|
12764
12814
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
12765
|
-
const value =
|
|
12815
|
+
const value = import_react41.default.useMemo(
|
|
12766
12816
|
() => dedupeAttachmentItems(
|
|
12767
12817
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
12768
12818
|
),
|
|
12769
12819
|
[fieldId, formData]
|
|
12770
12820
|
);
|
|
12771
|
-
const valueRef =
|
|
12821
|
+
const valueRef = import_react41.default.useRef(value);
|
|
12772
12822
|
const disabled = behavior === "DISABLED";
|
|
12773
12823
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
12774
12824
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -12801,7 +12851,7 @@ function AttachmentFieldPC({
|
|
|
12801
12851
|
enabled: showPreview,
|
|
12802
12852
|
requireServerCapability: true
|
|
12803
12853
|
});
|
|
12804
|
-
|
|
12854
|
+
import_react41.default.useEffect(() => {
|
|
12805
12855
|
valueRef.current = value;
|
|
12806
12856
|
}, [value]);
|
|
12807
12857
|
const setValue = (items) => {
|
|
@@ -13051,7 +13101,7 @@ function AttachmentFieldPC({
|
|
|
13051
13101
|
}
|
|
13052
13102
|
|
|
13053
13103
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldMobile.tsx
|
|
13054
|
-
var
|
|
13104
|
+
var import_react42 = __toESM(require("react"));
|
|
13055
13105
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
13056
13106
|
var createLocalItem2 = (file) => {
|
|
13057
13107
|
const uid = createUid("attachment");
|
|
@@ -13087,14 +13137,14 @@ function AttachmentFieldMobile({
|
|
|
13087
13137
|
onChange
|
|
13088
13138
|
}) {
|
|
13089
13139
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13090
|
-
const value =
|
|
13140
|
+
const value = import_react42.default.useMemo(
|
|
13091
13141
|
() => dedupeAttachmentItems(
|
|
13092
13142
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13093
13143
|
),
|
|
13094
13144
|
[fieldId, formData]
|
|
13095
13145
|
);
|
|
13096
|
-
const valueRef =
|
|
13097
|
-
const inputRef =
|
|
13146
|
+
const valueRef = import_react42.default.useRef(value);
|
|
13147
|
+
const inputRef = import_react42.default.useRef(null);
|
|
13098
13148
|
const disabled = behavior === "DISABLED";
|
|
13099
13149
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13100
13150
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13127,7 +13177,7 @@ function AttachmentFieldMobile({
|
|
|
13127
13177
|
enabled: showPreview,
|
|
13128
13178
|
requireServerCapability: true
|
|
13129
13179
|
});
|
|
13130
|
-
|
|
13180
|
+
import_react42.default.useEffect(() => {
|
|
13131
13181
|
valueRef.current = value;
|
|
13132
13182
|
}, [value]);
|
|
13133
13183
|
const setValue = (items) => {
|
|
@@ -13461,7 +13511,7 @@ function AttachmentField(props) {
|
|
|
13461
13511
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
13462
13512
|
const { isMobile } = useDeviceDetect();
|
|
13463
13513
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
13464
|
-
(0,
|
|
13514
|
+
(0, import_react43.useEffect)(() => {
|
|
13465
13515
|
registerField(fieldId);
|
|
13466
13516
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
13467
13517
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -13486,10 +13536,10 @@ function AttachmentField(props) {
|
|
|
13486
13536
|
}
|
|
13487
13537
|
|
|
13488
13538
|
// packages/sdk/src/components/fields/ImageField/index.tsx
|
|
13489
|
-
var
|
|
13539
|
+
var import_react47 = require("react");
|
|
13490
13540
|
|
|
13491
13541
|
// packages/sdk/src/components/fields/ImageField/ImageFieldPC.tsx
|
|
13492
|
-
var
|
|
13542
|
+
var import_react44 = __toESM(require("react"));
|
|
13493
13543
|
var import_antd23 = require("antd");
|
|
13494
13544
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
13495
13545
|
var createLocalItem3 = (file) => {
|
|
@@ -13508,9 +13558,9 @@ var createLocalItem3 = (file) => {
|
|
|
13508
13558
|
};
|
|
13509
13559
|
};
|
|
13510
13560
|
function ImageThumbContent({ item }) {
|
|
13511
|
-
const [imageFailed, setImageFailed] =
|
|
13561
|
+
const [imageFailed, setImageFailed] = import_react44.default.useState(false);
|
|
13512
13562
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
13513
|
-
|
|
13563
|
+
import_react44.default.useEffect(() => {
|
|
13514
13564
|
setImageFailed(false);
|
|
13515
13565
|
}, [src]);
|
|
13516
13566
|
if (src && !imageFailed) {
|
|
@@ -13541,13 +13591,13 @@ function ImageFieldPC({
|
|
|
13541
13591
|
onChange
|
|
13542
13592
|
}) {
|
|
13543
13593
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13544
|
-
const value =
|
|
13594
|
+
const value = import_react44.default.useMemo(
|
|
13545
13595
|
() => dedupeAttachmentItems(
|
|
13546
13596
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13547
13597
|
),
|
|
13548
13598
|
[fieldId, formData]
|
|
13549
13599
|
);
|
|
13550
|
-
const valueRef =
|
|
13600
|
+
const valueRef = import_react44.default.useRef(value);
|
|
13551
13601
|
const disabled = behavior === "DISABLED";
|
|
13552
13602
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13553
13603
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13582,7 +13632,7 @@ function ImageFieldPC({
|
|
|
13582
13632
|
enabled: showPreviewIcon,
|
|
13583
13633
|
requireServerCapability: false
|
|
13584
13634
|
});
|
|
13585
|
-
|
|
13635
|
+
import_react44.default.useEffect(() => {
|
|
13586
13636
|
valueRef.current = value;
|
|
13587
13637
|
}, [value]);
|
|
13588
13638
|
const setValue = (items) => {
|
|
@@ -13847,7 +13897,7 @@ function ImageFieldPC({
|
|
|
13847
13897
|
}
|
|
13848
13898
|
|
|
13849
13899
|
// packages/sdk/src/components/fields/ImageField/ImageFieldMobile.tsx
|
|
13850
|
-
var
|
|
13900
|
+
var import_react45 = __toESM(require("react"));
|
|
13851
13901
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
13852
13902
|
var createLocalItem4 = (file) => {
|
|
13853
13903
|
const uid = createUid("image");
|
|
@@ -13865,9 +13915,9 @@ var createLocalItem4 = (file) => {
|
|
|
13865
13915
|
};
|
|
13866
13916
|
};
|
|
13867
13917
|
function ImageThumbContent2({ item }) {
|
|
13868
|
-
const [imageFailed, setImageFailed] =
|
|
13918
|
+
const [imageFailed, setImageFailed] = import_react45.default.useState(false);
|
|
13869
13919
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
13870
|
-
|
|
13920
|
+
import_react45.default.useEffect(() => {
|
|
13871
13921
|
setImageFailed(false);
|
|
13872
13922
|
}, [src]);
|
|
13873
13923
|
if (src && !imageFailed) {
|
|
@@ -13897,14 +13947,14 @@ function ImageFieldMobile({
|
|
|
13897
13947
|
onChange
|
|
13898
13948
|
}) {
|
|
13899
13949
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13900
|
-
const value =
|
|
13950
|
+
const value = import_react45.default.useMemo(
|
|
13901
13951
|
() => dedupeAttachmentItems(
|
|
13902
13952
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13903
13953
|
),
|
|
13904
13954
|
[fieldId, formData]
|
|
13905
13955
|
);
|
|
13906
|
-
const valueRef =
|
|
13907
|
-
const inputRef =
|
|
13956
|
+
const valueRef = import_react45.default.useRef(value);
|
|
13957
|
+
const inputRef = import_react45.default.useRef(null);
|
|
13908
13958
|
const disabled = behavior === "DISABLED";
|
|
13909
13959
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13910
13960
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13936,7 +13986,7 @@ function ImageFieldMobile({
|
|
|
13936
13986
|
enabled: showPreviewIcon,
|
|
13937
13987
|
requireServerCapability: false
|
|
13938
13988
|
});
|
|
13939
|
-
|
|
13989
|
+
import_react45.default.useEffect(() => {
|
|
13940
13990
|
valueRef.current = value;
|
|
13941
13991
|
}, [value]);
|
|
13942
13992
|
const setValue = (items) => {
|
|
@@ -14103,14 +14153,14 @@ function ImageFieldMobile({
|
|
|
14103
14153
|
}
|
|
14104
14154
|
|
|
14105
14155
|
// packages/sdk/src/components/fields/ImageField/ImageFieldReadonly.tsx
|
|
14106
|
-
var
|
|
14156
|
+
var import_react46 = __toESM(require("react"));
|
|
14107
14157
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
14108
14158
|
var getTicketUrl2 = (ticket, fallback) => typeof ticket === "string" ? ticket : ticket?.previewUrl || ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || fallback;
|
|
14109
14159
|
var isDirectStorageItem3 = (item) => item.provider === "oss" || item.uploadProvider === "oss" || item.uploadProvider === "builtin-oss" || Boolean(item.storageCode);
|
|
14110
14160
|
function ImageThumbContent3({ item, testId }) {
|
|
14111
|
-
const [imageFailed, setImageFailed] =
|
|
14161
|
+
const [imageFailed, setImageFailed] = import_react46.default.useState(false);
|
|
14112
14162
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
14113
|
-
|
|
14163
|
+
import_react46.default.useEffect(() => {
|
|
14114
14164
|
setImageFailed(false);
|
|
14115
14165
|
}, [src]);
|
|
14116
14166
|
if (src && !imageFailed) {
|
|
@@ -14279,7 +14329,7 @@ function ImageField(props) {
|
|
|
14279
14329
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
14280
14330
|
const { isMobile } = useDeviceDetect();
|
|
14281
14331
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
14282
|
-
(0,
|
|
14332
|
+
(0, import_react47.useEffect)(() => {
|
|
14283
14333
|
registerField(fieldId);
|
|
14284
14334
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
14285
14335
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -14304,10 +14354,10 @@ function ImageField(props) {
|
|
|
14304
14354
|
}
|
|
14305
14355
|
|
|
14306
14356
|
// packages/sdk/src/components/fields/SubFormField/index.tsx
|
|
14307
|
-
var
|
|
14357
|
+
var import_react49 = require("react");
|
|
14308
14358
|
|
|
14309
14359
|
// packages/sdk/src/components/fields/SubFormField/SubFormCell.tsx
|
|
14310
|
-
var
|
|
14360
|
+
var import_react48 = require("react");
|
|
14311
14361
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
14312
14362
|
var stringifyFallbackValue = (value) => {
|
|
14313
14363
|
if (value === void 0 || value === null) return "";
|
|
@@ -14328,7 +14378,7 @@ function SubFormCell({
|
|
|
14328
14378
|
const scopedFieldId = `${parentFieldId}.${rowIndex}.${column.fieldId}`;
|
|
14329
14379
|
const cellValue = row[column.fieldId];
|
|
14330
14380
|
const resolvedBehavior = behavior === "DISABLED" || behavior === "READONLY" ? behavior : column.behavior ?? behavior ?? "NORMAL";
|
|
14331
|
-
const childContext = (0,
|
|
14381
|
+
const childContext = (0, import_react48.useMemo)(
|
|
14332
14382
|
() => ({
|
|
14333
14383
|
...parentContext,
|
|
14334
14384
|
formData: {
|
|
@@ -14622,7 +14672,7 @@ function SubFormField(props) {
|
|
|
14622
14672
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
14623
14673
|
const { isMobile } = useDeviceDetect();
|
|
14624
14674
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
14625
|
-
(0,
|
|
14675
|
+
(0, import_react49.useEffect)(() => {
|
|
14626
14676
|
registerField(fieldId);
|
|
14627
14677
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
14628
14678
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -14647,10 +14697,10 @@ function SubFormField(props) {
|
|
|
14647
14697
|
}
|
|
14648
14698
|
|
|
14649
14699
|
// packages/sdk/src/components/fields/UserSelectField/index.tsx
|
|
14650
|
-
var
|
|
14700
|
+
var import_react53 = require("react");
|
|
14651
14701
|
|
|
14652
14702
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldPC.tsx
|
|
14653
|
-
var
|
|
14703
|
+
var import_react50 = require("react");
|
|
14654
14704
|
var import_antd24 = require("antd");
|
|
14655
14705
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
14656
14706
|
function UserSelectFieldPC({
|
|
@@ -14670,20 +14720,20 @@ function UserSelectFieldPC({
|
|
|
14670
14720
|
}) {
|
|
14671
14721
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14672
14722
|
const rawValue = formData[fieldId];
|
|
14673
|
-
const value = (0,
|
|
14723
|
+
const value = (0, import_react50.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14674
14724
|
const disabled = behavior === "DISABLED";
|
|
14675
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
14725
|
+
const [optionsSource, setOptionsSource] = (0, import_react50.useState)(
|
|
14676
14726
|
() => dataSource.map(normalizeUser)
|
|
14677
14727
|
);
|
|
14678
|
-
const [loading, setLoading] = (0,
|
|
14679
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
14728
|
+
const [loading, setLoading] = (0, import_react50.useState)(false);
|
|
14729
|
+
const [pickerOpen, setPickerOpen] = (0, import_react50.useState)(false);
|
|
14680
14730
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
14681
|
-
(0,
|
|
14731
|
+
(0, import_react50.useEffect)(() => {
|
|
14682
14732
|
if (dataSource.length) {
|
|
14683
14733
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
14684
14734
|
}
|
|
14685
14735
|
}, [dataSource]);
|
|
14686
|
-
(0,
|
|
14736
|
+
(0, import_react50.useEffect)(() => {
|
|
14687
14737
|
setOptionsSource((current) => {
|
|
14688
14738
|
const merged = [...current];
|
|
14689
14739
|
let changed = false;
|
|
@@ -14696,7 +14746,7 @@ function UserSelectFieldPC({
|
|
|
14696
14746
|
return changed ? merged : current;
|
|
14697
14747
|
});
|
|
14698
14748
|
}, [value]);
|
|
14699
|
-
(0,
|
|
14749
|
+
(0, import_react50.useEffect)(() => {
|
|
14700
14750
|
const missing = value.filter((item) => getUserId(item) && getUserNameLikeId(item));
|
|
14701
14751
|
if (missing.length === 0) return;
|
|
14702
14752
|
let cancelled = false;
|
|
@@ -14739,7 +14789,7 @@ function UserSelectFieldPC({
|
|
|
14739
14789
|
setLoading(false);
|
|
14740
14790
|
}
|
|
14741
14791
|
};
|
|
14742
|
-
(0,
|
|
14792
|
+
(0, import_react50.useEffect)(() => {
|
|
14743
14793
|
fetchUsers();
|
|
14744
14794
|
}, []);
|
|
14745
14795
|
const handleChange = (selectedIds) => {
|
|
@@ -14764,7 +14814,7 @@ function UserSelectFieldPC({
|
|
|
14764
14814
|
setFieldValue(fieldId, normalized);
|
|
14765
14815
|
onChange?.(normalized);
|
|
14766
14816
|
};
|
|
14767
|
-
const options = (0,
|
|
14817
|
+
const options = (0, import_react50.useMemo)(
|
|
14768
14818
|
() => optionsSource.map((u) => ({
|
|
14769
14819
|
value: getUserId(u),
|
|
14770
14820
|
label: formatUserDisplay(u, displayFormat)
|
|
@@ -14828,7 +14878,7 @@ function getUserNameLikeId(user) {
|
|
|
14828
14878
|
}
|
|
14829
14879
|
|
|
14830
14880
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldMobile.tsx
|
|
14831
|
-
var
|
|
14881
|
+
var import_react51 = require("react");
|
|
14832
14882
|
var MobileAntd2 = __toESM(require("antd-mobile"));
|
|
14833
14883
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
14834
14884
|
var getMobilePopup = () => {
|
|
@@ -14853,19 +14903,19 @@ function UserSelectFieldMobile({
|
|
|
14853
14903
|
}) {
|
|
14854
14904
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14855
14905
|
const rawValue = formData[fieldId];
|
|
14856
|
-
const value = (0,
|
|
14906
|
+
const value = (0, import_react51.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14857
14907
|
const disabled = behavior === "DISABLED";
|
|
14858
|
-
const [showPicker, setShowPicker] = (0,
|
|
14859
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
14908
|
+
const [showPicker, setShowPicker] = (0, import_react51.useState)(false);
|
|
14909
|
+
const [optionsSource, setOptionsSource] = (0, import_react51.useState)(
|
|
14860
14910
|
() => dataSource.map(normalizeUser)
|
|
14861
14911
|
);
|
|
14862
14912
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
14863
|
-
(0,
|
|
14913
|
+
(0, import_react51.useEffect)(() => {
|
|
14864
14914
|
if (dataSource.length) {
|
|
14865
14915
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
14866
14916
|
}
|
|
14867
14917
|
}, [dataSource]);
|
|
14868
|
-
(0,
|
|
14918
|
+
(0, import_react51.useEffect)(() => {
|
|
14869
14919
|
setOptionsSource((current) => {
|
|
14870
14920
|
const merged = [...current];
|
|
14871
14921
|
let changed = false;
|
|
@@ -14961,7 +15011,7 @@ function UserSelectFieldMobile({
|
|
|
14961
15011
|
}
|
|
14962
15012
|
|
|
14963
15013
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldReadonly.tsx
|
|
14964
|
-
var
|
|
15014
|
+
var import_react52 = require("react");
|
|
14965
15015
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
14966
15016
|
function UserSelectFieldReadonly({
|
|
14967
15017
|
fieldId,
|
|
@@ -14970,8 +15020,8 @@ function UserSelectFieldReadonly({
|
|
|
14970
15020
|
}) {
|
|
14971
15021
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14972
15022
|
const rawValue = formData[fieldId];
|
|
14973
|
-
const value = (0,
|
|
14974
|
-
(0,
|
|
15023
|
+
const value = (0, import_react52.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
15024
|
+
(0, import_react52.useEffect)(() => {
|
|
14975
15025
|
const missing = value.filter((item) => getUserNameLikeId2(item));
|
|
14976
15026
|
if (missing.length === 0) return;
|
|
14977
15027
|
let cancelled = false;
|
|
@@ -15023,7 +15073,7 @@ function UserSelectField(props) {
|
|
|
15023
15073
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
15024
15074
|
const { isMobile } = useDeviceDetect();
|
|
15025
15075
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15026
|
-
(0,
|
|
15076
|
+
(0, import_react53.useEffect)(() => {
|
|
15027
15077
|
registerField(fieldId);
|
|
15028
15078
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15029
15079
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -15048,10 +15098,10 @@ function UserSelectField(props) {
|
|
|
15048
15098
|
}
|
|
15049
15099
|
|
|
15050
15100
|
// packages/sdk/src/components/fields/DepartmentSelectField/index.tsx
|
|
15051
|
-
var
|
|
15101
|
+
var import_react58 = require("react");
|
|
15052
15102
|
|
|
15053
15103
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldPC.tsx
|
|
15054
|
-
var
|
|
15104
|
+
var import_react55 = require("react");
|
|
15055
15105
|
var import_antd26 = require("antd");
|
|
15056
15106
|
|
|
15057
15107
|
// packages/sdk/src/components/fields/shared/departmentSearch.ts
|
|
@@ -15070,7 +15120,7 @@ function getDepartmentPathText(department, separator = "/") {
|
|
|
15070
15120
|
}
|
|
15071
15121
|
|
|
15072
15122
|
// packages/sdk/src/components/fields/shared/DepartmentPicker.tsx
|
|
15073
|
-
var
|
|
15123
|
+
var import_react54 = require("react");
|
|
15074
15124
|
var import_antd25 = require("antd");
|
|
15075
15125
|
var import_icons12 = require("@ant-design/icons");
|
|
15076
15126
|
var MobileAntd3 = __toESM(require("antd-mobile"));
|
|
@@ -15123,20 +15173,20 @@ function DepartmentPickerPanel({
|
|
|
15123
15173
|
flatNodes,
|
|
15124
15174
|
loadChildren
|
|
15125
15175
|
} = useLazyDepartmentTree(api, treeData);
|
|
15126
|
-
const [keyword, setKeyword] = (0,
|
|
15127
|
-
const [selected, setSelected] = (0,
|
|
15128
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
15129
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
15130
|
-
const [remoteSearchResults, setRemoteSearchResults] = (0,
|
|
15131
|
-
const [remoteSearchLoading, setRemoteSearchLoading] = (0,
|
|
15132
|
-
const [remoteSearchError, setRemoteSearchError] = (0,
|
|
15133
|
-
const searchSeqRef = (0,
|
|
15176
|
+
const [keyword, setKeyword] = (0, import_react54.useState)("");
|
|
15177
|
+
const [selected, setSelected] = (0, import_react54.useState)(() => normalizeSelection(value));
|
|
15178
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react54.useState)([]);
|
|
15179
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react54.useState)(null);
|
|
15180
|
+
const [remoteSearchResults, setRemoteSearchResults] = (0, import_react54.useState)([]);
|
|
15181
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = (0, import_react54.useState)(false);
|
|
15182
|
+
const [remoteSearchError, setRemoteSearchError] = (0, import_react54.useState)("");
|
|
15183
|
+
const searchSeqRef = (0, import_react54.useRef)(0);
|
|
15134
15184
|
const selectedIds = selected.map((item) => item.id);
|
|
15135
15185
|
const MobileSearchBar = getMobileComponent2("SearchBar");
|
|
15136
15186
|
const trimmedKeyword = keyword.trim();
|
|
15137
15187
|
const canRemoteSearch = showSearch && searchScope === "all" && trimmedKeyword.length >= searchMinLength && canSearchAllDepartments(api, treeData);
|
|
15138
15188
|
const spinning = treeLoading || remoteSearchLoading;
|
|
15139
|
-
(0,
|
|
15189
|
+
(0, import_react54.useEffect)(() => {
|
|
15140
15190
|
if (!canRemoteSearch) {
|
|
15141
15191
|
searchSeqRef.current += 1;
|
|
15142
15192
|
setRemoteSearchResults([]);
|
|
@@ -15171,11 +15221,11 @@ function DepartmentPickerPanel({
|
|
|
15171
15221
|
window.clearTimeout(timer);
|
|
15172
15222
|
};
|
|
15173
15223
|
}, [api, canRemoteSearch, searchDebounceMs, trimmedKeyword]);
|
|
15174
|
-
const filteredTreeData = (0,
|
|
15224
|
+
const filteredTreeData = (0, import_react54.useMemo)(
|
|
15175
15225
|
() => showSearch ? matchSearch(loadedTreeData, trimmedKeyword) : loadedTreeData,
|
|
15176
15226
|
[loadedTreeData, showSearch, trimmedKeyword]
|
|
15177
15227
|
);
|
|
15178
|
-
const currentPath = (0,
|
|
15228
|
+
const currentPath = (0, import_react54.useMemo)(() => {
|
|
15179
15229
|
if (!currentDeptId) return [];
|
|
15180
15230
|
const path = [];
|
|
15181
15231
|
let cursor = currentDeptId;
|
|
@@ -15187,7 +15237,7 @@ function DepartmentPickerPanel({
|
|
|
15187
15237
|
}
|
|
15188
15238
|
return path;
|
|
15189
15239
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
15190
|
-
const mobileList = (0,
|
|
15240
|
+
const mobileList = (0, import_react54.useMemo)(() => {
|
|
15191
15241
|
if (canRemoteSearch) {
|
|
15192
15242
|
return remoteSearchResults;
|
|
15193
15243
|
}
|
|
@@ -15505,18 +15555,18 @@ function DepartmentSelectFieldPC({
|
|
|
15505
15555
|
}) {
|
|
15506
15556
|
const { formData, setFieldValue, api } = useFormContext();
|
|
15507
15557
|
const rawValue = formData[fieldId];
|
|
15508
|
-
const value = (0,
|
|
15558
|
+
const value = (0, import_react55.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15509
15559
|
const disabled = behavior === "DISABLED";
|
|
15510
15560
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA;
|
|
15511
|
-
const remoteLoadedRef = (0,
|
|
15512
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
15513
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
15514
|
-
const [searchKeyword, setSearchKeyword] = (0,
|
|
15515
|
-
const [remoteSearchResults, setRemoteSearchResults] = (0,
|
|
15516
|
-
const [remoteSearchLoading, setRemoteSearchLoading] = (0,
|
|
15517
|
-
const [selectedPathMap, setSelectedPathMap] = (0,
|
|
15518
|
-
const searchSeqRef = (0,
|
|
15519
|
-
(0,
|
|
15561
|
+
const remoteLoadedRef = (0, import_react55.useRef)(false);
|
|
15562
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react55.useState)(configuredTreeData);
|
|
15563
|
+
const [pickerOpen, setPickerOpen] = (0, import_react55.useState)(false);
|
|
15564
|
+
const [searchKeyword, setSearchKeyword] = (0, import_react55.useState)("");
|
|
15565
|
+
const [remoteSearchResults, setRemoteSearchResults] = (0, import_react55.useState)([]);
|
|
15566
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = (0, import_react55.useState)(false);
|
|
15567
|
+
const [selectedPathMap, setSelectedPathMap] = (0, import_react55.useState)({});
|
|
15568
|
+
const searchSeqRef = (0, import_react55.useRef)(0);
|
|
15569
|
+
(0, import_react55.useEffect)(() => {
|
|
15520
15570
|
if (configuredTreeData.length) {
|
|
15521
15571
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
15522
15572
|
return;
|
|
@@ -15529,7 +15579,7 @@ function DepartmentSelectFieldPC({
|
|
|
15529
15579
|
}, [api, configuredTreeData]);
|
|
15530
15580
|
const trimmedSearchKeyword = searchKeyword.trim();
|
|
15531
15581
|
const canRemoteSearch = showSearch && searchScope === "all" && trimmedSearchKeyword.length >= searchMinLength && canSearchAllDepartments(api, configuredTreeData);
|
|
15532
|
-
(0,
|
|
15582
|
+
(0, import_react55.useEffect)(() => {
|
|
15533
15583
|
if (!canRemoteSearch) {
|
|
15534
15584
|
searchSeqRef.current += 1;
|
|
15535
15585
|
setRemoteSearchResults([]);
|
|
@@ -15563,7 +15613,7 @@ function DepartmentSelectFieldPC({
|
|
|
15563
15613
|
}, [api, canRemoteSearch, searchDebounceMs, trimmedSearchKeyword]);
|
|
15564
15614
|
const scopedTreeData = filterTreeByScope(loadedTreeData, scopeType, specifiedDepts);
|
|
15565
15615
|
const allDepts = flattenDepartments(scopedTreeData);
|
|
15566
|
-
const scopedRemoteSearchResults = (0,
|
|
15616
|
+
const scopedRemoteSearchResults = (0, import_react55.useMemo)(() => {
|
|
15567
15617
|
if (scopeType !== "specified" || !specifiedDepts?.length) {
|
|
15568
15618
|
return remoteSearchResults;
|
|
15569
15619
|
}
|
|
@@ -15574,7 +15624,7 @@ function DepartmentSelectFieldPC({
|
|
|
15574
15624
|
return node.path?.some((item) => specifiedSet.has(item.id));
|
|
15575
15625
|
});
|
|
15576
15626
|
}, [remoteSearchResults, scopeType, specifiedDepts]);
|
|
15577
|
-
const remoteDeptMap = (0,
|
|
15627
|
+
const remoteDeptMap = (0, import_react55.useMemo)(() => {
|
|
15578
15628
|
const map = /* @__PURE__ */ new Map();
|
|
15579
15629
|
scopedRemoteSearchResults.forEach((node) => map.set(getDepartmentId(node), node));
|
|
15580
15630
|
return map;
|
|
@@ -15703,7 +15753,7 @@ function DepartmentSelectFieldPC({
|
|
|
15703
15753
|
}
|
|
15704
15754
|
|
|
15705
15755
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldMobile.tsx
|
|
15706
|
-
var
|
|
15756
|
+
var import_react56 = require("react");
|
|
15707
15757
|
var MobileAntd4 = __toESM(require("antd-mobile"));
|
|
15708
15758
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
15709
15759
|
var EMPTY_TREE_DATA2 = [];
|
|
@@ -15738,13 +15788,13 @@ function DepartmentSelectFieldMobile({
|
|
|
15738
15788
|
}) {
|
|
15739
15789
|
const { formData, setFieldValue, api } = useFormContext();
|
|
15740
15790
|
const rawValue = formData[fieldId];
|
|
15741
|
-
const value = (0,
|
|
15791
|
+
const value = (0, import_react56.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15742
15792
|
const disabled = behavior === "DISABLED";
|
|
15743
|
-
const [showPicker, setShowPicker] = (0,
|
|
15793
|
+
const [showPicker, setShowPicker] = (0, import_react56.useState)(false);
|
|
15744
15794
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA2;
|
|
15745
|
-
const remoteLoadedRef = (0,
|
|
15746
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
15747
|
-
(0,
|
|
15795
|
+
const remoteLoadedRef = (0, import_react56.useRef)(false);
|
|
15796
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react56.useState)(configuredTreeData);
|
|
15797
|
+
(0, import_react56.useEffect)(() => {
|
|
15748
15798
|
if (configuredTreeData.length) {
|
|
15749
15799
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
15750
15800
|
}
|
|
@@ -15843,7 +15893,7 @@ function DepartmentSelectFieldMobile({
|
|
|
15843
15893
|
}
|
|
15844
15894
|
|
|
15845
15895
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldReadonly.tsx
|
|
15846
|
-
var
|
|
15896
|
+
var import_react57 = require("react");
|
|
15847
15897
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
15848
15898
|
function DepartmentSelectFieldReadonly({
|
|
15849
15899
|
fieldId,
|
|
@@ -15853,7 +15903,7 @@ function DepartmentSelectFieldReadonly({
|
|
|
15853
15903
|
}) {
|
|
15854
15904
|
const { formData } = useFormContext();
|
|
15855
15905
|
const rawValue = formData[fieldId];
|
|
15856
|
-
const value = (0,
|
|
15906
|
+
const value = (0, import_react57.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15857
15907
|
const display = value.length > 0 ? value.map(
|
|
15858
15908
|
(d) => showFullPath ? getDepartmentFullPath(getDepartmentId(d), treeData) || getDepartmentName(d) : getDepartmentName(d)
|
|
15859
15909
|
).join(", ") : "--";
|
|
@@ -15884,7 +15934,7 @@ function DepartmentSelectField(props) {
|
|
|
15884
15934
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
15885
15935
|
const { isMobile } = useDeviceDetect();
|
|
15886
15936
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15887
|
-
(0,
|
|
15937
|
+
(0, import_react58.useEffect)(() => {
|
|
15888
15938
|
registerField(fieldId);
|
|
15889
15939
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15890
15940
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -15909,7 +15959,7 @@ function DepartmentSelectField(props) {
|
|
|
15909
15959
|
}
|
|
15910
15960
|
|
|
15911
15961
|
// packages/sdk/src/components/fields/CascadeSelectField/index.tsx
|
|
15912
|
-
var
|
|
15962
|
+
var import_react59 = require("react");
|
|
15913
15963
|
var import_antd27 = require("antd");
|
|
15914
15964
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
15915
15965
|
var toValuePath = (value, multiple) => {
|
|
@@ -15948,7 +15998,7 @@ function CascadeSelectField(props) {
|
|
|
15948
15998
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
15949
15999
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15950
16000
|
const value = formData[fieldId] ?? (multiple ? [] : []);
|
|
15951
|
-
(0,
|
|
16001
|
+
(0, import_react59.useEffect)(() => {
|
|
15952
16002
|
registerField(fieldId);
|
|
15953
16003
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15954
16004
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -16001,7 +16051,7 @@ function CascadeSelectField(props) {
|
|
|
16001
16051
|
}
|
|
16002
16052
|
|
|
16003
16053
|
// packages/sdk/src/components/fields/AddressField/index.tsx
|
|
16004
|
-
var
|
|
16054
|
+
var import_react60 = require("react");
|
|
16005
16055
|
var import_antd28 = require("antd");
|
|
16006
16056
|
var MobileAntd5 = __toESM(require("antd-mobile"));
|
|
16007
16057
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
@@ -16147,41 +16197,41 @@ function AddressField(props) {
|
|
|
16147
16197
|
const { isMobile } = useDeviceDetect();
|
|
16148
16198
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
16149
16199
|
const rawValue = formData[fieldId];
|
|
16150
|
-
const value = (0,
|
|
16151
|
-
const [options, setOptions] = (0,
|
|
16152
|
-
const [loadingRoots, setLoadingRoots] = (0,
|
|
16153
|
-
const [mobileOpen, setMobileOpen] = (0,
|
|
16154
|
-
const [mobileLevelIndex, setMobileLevelIndex] = (0,
|
|
16155
|
-
const [mobileOptions, setMobileOptions] = (0,
|
|
16156
|
-
const [mobileLoading, setMobileLoading] = (0,
|
|
16157
|
-
const [tempValue, setTempValue] = (0,
|
|
16200
|
+
const value = (0, import_react60.useMemo)(() => normalizeAddressValue(rawValue), [rawValue]);
|
|
16201
|
+
const [options, setOptions] = (0, import_react60.useState)([]);
|
|
16202
|
+
const [loadingRoots, setLoadingRoots] = (0, import_react60.useState)(false);
|
|
16203
|
+
const [mobileOpen, setMobileOpen] = (0, import_react60.useState)(false);
|
|
16204
|
+
const [mobileLevelIndex, setMobileLevelIndex] = (0, import_react60.useState)(0);
|
|
16205
|
+
const [mobileOptions, setMobileOptions] = (0, import_react60.useState)([]);
|
|
16206
|
+
const [mobileLoading, setMobileLoading] = (0, import_react60.useState)(false);
|
|
16207
|
+
const [tempValue, setTempValue] = (0, import_react60.useState)();
|
|
16158
16208
|
const depth = modeDepth(mode);
|
|
16159
|
-
const levels = (0,
|
|
16160
|
-
const valuePath = (0,
|
|
16161
|
-
const displayOptions = (0,
|
|
16209
|
+
const levels = (0, import_react60.useMemo)(() => activeLevels(mode), [mode]);
|
|
16210
|
+
const valuePath = (0, import_react60.useMemo)(() => valueToPath(value, levels), [levels, value]);
|
|
16211
|
+
const displayOptions = (0, import_react60.useMemo)(
|
|
16162
16212
|
() => mergeValuePathIntoOptions(options, value, levels, depth),
|
|
16163
16213
|
[depth, levels, options, value]
|
|
16164
16214
|
);
|
|
16165
16215
|
const detailEnabled = mode === "province-city-district-street-detail";
|
|
16166
16216
|
const disabled = behavior === "DISABLED";
|
|
16167
16217
|
const MobilePopup = getMobileComponent3("Popup");
|
|
16168
|
-
(0,
|
|
16218
|
+
(0, import_react60.useEffect)(() => {
|
|
16169
16219
|
registerField(fieldId);
|
|
16170
16220
|
return () => unregisterField(fieldId);
|
|
16171
16221
|
}, [fieldId, registerField, unregisterField]);
|
|
16172
|
-
(0,
|
|
16222
|
+
(0, import_react60.useEffect)(() => {
|
|
16173
16223
|
if (defaultValue !== void 0 && rawValue === void 0) {
|
|
16174
16224
|
setFieldValue(fieldId, defaultValue);
|
|
16175
16225
|
}
|
|
16176
16226
|
}, [defaultValue, fieldId, rawValue, setFieldValue]);
|
|
16177
|
-
const loadDivisions = (0,
|
|
16227
|
+
const loadDivisions = (0, import_react60.useCallback)(
|
|
16178
16228
|
async (parentAdcode, level, index) => {
|
|
16179
16229
|
const list = await api.getChinaDivisions(parentAdcode);
|
|
16180
16230
|
return list.map((item) => normalizeDivision(item, level, depth, index));
|
|
16181
16231
|
},
|
|
16182
16232
|
[api, depth]
|
|
16183
16233
|
);
|
|
16184
|
-
(0,
|
|
16234
|
+
(0, import_react60.useEffect)(() => {
|
|
16185
16235
|
let mounted = true;
|
|
16186
16236
|
setLoadingRoots(true);
|
|
16187
16237
|
loadDivisions(void 0, "province", 0).then((nextOptions) => {
|
|
@@ -16193,7 +16243,7 @@ function AddressField(props) {
|
|
|
16193
16243
|
mounted = false;
|
|
16194
16244
|
};
|
|
16195
16245
|
}, [loadDivisions]);
|
|
16196
|
-
(0,
|
|
16246
|
+
(0, import_react60.useEffect)(() => {
|
|
16197
16247
|
if (!value) return;
|
|
16198
16248
|
let cancelled = false;
|
|
16199
16249
|
const hydrateMissingLabels = async () => {
|
|
@@ -16229,7 +16279,7 @@ function AddressField(props) {
|
|
|
16229
16279
|
cancelled = true;
|
|
16230
16280
|
};
|
|
16231
16281
|
}, [fieldId, levels, loadDivisions, setFieldValue, value]);
|
|
16232
|
-
(0,
|
|
16282
|
+
(0, import_react60.useEffect)(() => {
|
|
16233
16283
|
if (!mobileOpen) return;
|
|
16234
16284
|
const level = levels[mobileLevelIndex] || "province";
|
|
16235
16285
|
const parentLevel = levels[mobileLevelIndex - 1];
|
|
@@ -16409,7 +16459,7 @@ function AddressField(props) {
|
|
|
16409
16459
|
}
|
|
16410
16460
|
|
|
16411
16461
|
// packages/sdk/src/components/fields/AssociationFormField/index.tsx
|
|
16412
|
-
var
|
|
16462
|
+
var import_react61 = require("react");
|
|
16413
16463
|
var import_antd29 = require("antd");
|
|
16414
16464
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
16415
16465
|
var DEFAULT_PAGE_SIZE = 10;
|
|
@@ -16472,45 +16522,45 @@ function AssociationFormField(props) {
|
|
|
16472
16522
|
const { isMobile } = useDeviceDetect();
|
|
16473
16523
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
16474
16524
|
const rawValue = formData[fieldId];
|
|
16475
|
-
const value = (0,
|
|
16525
|
+
const value = (0, import_react61.useMemo)(() => normalizeValues(rawValue), [rawValue]);
|
|
16476
16526
|
const disabled = behavior === "DISABLED";
|
|
16477
|
-
const [options, setOptions] = (0,
|
|
16478
|
-
const [selectLoading, setSelectLoading] = (0,
|
|
16479
|
-
const [selectorOpen, setSelectorOpen] = (0,
|
|
16480
|
-
const [tableLoading, setTableLoading] = (0,
|
|
16481
|
-
const [tableData, setTableData] = (0,
|
|
16482
|
-
const [keyword, setKeyword] = (0,
|
|
16483
|
-
const [pagination, setPagination] = (0,
|
|
16527
|
+
const [options, setOptions] = (0, import_react61.useState)([]);
|
|
16528
|
+
const [selectLoading, setSelectLoading] = (0, import_react61.useState)(false);
|
|
16529
|
+
const [selectorOpen, setSelectorOpen] = (0, import_react61.useState)(false);
|
|
16530
|
+
const [tableLoading, setTableLoading] = (0, import_react61.useState)(false);
|
|
16531
|
+
const [tableData, setTableData] = (0, import_react61.useState)([]);
|
|
16532
|
+
const [keyword, setKeyword] = (0, import_react61.useState)("");
|
|
16533
|
+
const [pagination, setPagination] = (0, import_react61.useState)({
|
|
16484
16534
|
current: 1,
|
|
16485
16535
|
pageSize: DEFAULT_PAGE_SIZE,
|
|
16486
16536
|
total: 0
|
|
16487
16537
|
});
|
|
16488
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
16489
|
-
const [selectedRecords, setSelectedRecords] = (0,
|
|
16490
|
-
const formDataRef = (0,
|
|
16491
|
-
const associationFormRef = (0,
|
|
16492
|
-
(0,
|
|
16538
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react61.useState)([]);
|
|
16539
|
+
const [selectedRecords, setSelectedRecords] = (0, import_react61.useState)([]);
|
|
16540
|
+
const formDataRef = (0, import_react61.useRef)(formData);
|
|
16541
|
+
const associationFormRef = (0, import_react61.useRef)(associationForm);
|
|
16542
|
+
(0, import_react61.useEffect)(() => {
|
|
16493
16543
|
registerField(fieldId);
|
|
16494
16544
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
16495
16545
|
setFieldValue(fieldId, normalizeValues(defaultValue));
|
|
16496
16546
|
}
|
|
16497
16547
|
return () => unregisterField(fieldId);
|
|
16498
16548
|
}, [fieldId]);
|
|
16499
|
-
(0,
|
|
16549
|
+
(0, import_react61.useEffect)(() => {
|
|
16500
16550
|
formDataRef.current = formData;
|
|
16501
16551
|
}, [formData]);
|
|
16502
|
-
(0,
|
|
16552
|
+
(0, import_react61.useEffect)(() => {
|
|
16503
16553
|
associationFormRef.current = associationForm;
|
|
16504
16554
|
}, [associationForm]);
|
|
16505
16555
|
const associationAppType = associationForm?.appType;
|
|
16506
16556
|
const associationFormUuid = associationForm?.formUuid;
|
|
16507
16557
|
const associationMainFieldId = associationForm?.mainFieldId;
|
|
16508
16558
|
const canQuery = Boolean(associationAppType && associationFormUuid);
|
|
16509
|
-
const filterRulesKey = (0,
|
|
16559
|
+
const filterRulesKey = (0, import_react61.useMemo)(
|
|
16510
16560
|
() => stableSerialize(associationForm?.dataFilterRules || []),
|
|
16511
16561
|
[associationForm?.dataFilterRules]
|
|
16512
16562
|
);
|
|
16513
|
-
const currentFieldFilterKey = (0,
|
|
16563
|
+
const currentFieldFilterKey = (0, import_react61.useMemo)(() => {
|
|
16514
16564
|
const rules = associationForm?.dataFilterRules || [];
|
|
16515
16565
|
return stableSerialize(
|
|
16516
16566
|
rules.map((rule) => {
|
|
@@ -16519,11 +16569,11 @@ function AssociationFormField(props) {
|
|
|
16519
16569
|
})
|
|
16520
16570
|
);
|
|
16521
16571
|
}, [formData, associationForm?.dataFilterRules]);
|
|
16522
|
-
const filterDependencyKey = (0,
|
|
16572
|
+
const filterDependencyKey = (0, import_react61.useMemo)(
|
|
16523
16573
|
() => `${filterRulesKey}:${currentFieldFilterKey}`,
|
|
16524
16574
|
[currentFieldFilterKey, filterRulesKey]
|
|
16525
16575
|
);
|
|
16526
|
-
const normalizeRecord = (0,
|
|
16576
|
+
const normalizeRecord = (0, import_react61.useCallback)(
|
|
16527
16577
|
(record) => {
|
|
16528
16578
|
const mainFieldValue = associationMainFieldId ? record?.[associationMainFieldId] : void 0;
|
|
16529
16579
|
const labelText = normalizeCellValue(mainFieldValue);
|
|
@@ -16536,7 +16586,7 @@ function AssociationFormField(props) {
|
|
|
16536
16586
|
},
|
|
16537
16587
|
[associationMainFieldId]
|
|
16538
16588
|
);
|
|
16539
|
-
const toValue = (0,
|
|
16589
|
+
const toValue = (0, import_react61.useCallback)(
|
|
16540
16590
|
(record) => ({
|
|
16541
16591
|
label: record.__associationLabel,
|
|
16542
16592
|
value: record.__associationValue,
|
|
@@ -16544,7 +16594,7 @@ function AssociationFormField(props) {
|
|
|
16544
16594
|
}),
|
|
16545
16595
|
[]
|
|
16546
16596
|
);
|
|
16547
|
-
const buildFilters = (0,
|
|
16597
|
+
const buildFilters = (0, import_react61.useCallback)(() => {
|
|
16548
16598
|
void filterDependencyKey;
|
|
16549
16599
|
const rules = associationFormRef.current?.dataFilterRules || [];
|
|
16550
16600
|
const currentFormData = formDataRef.current;
|
|
@@ -16560,7 +16610,7 @@ function AssociationFormField(props) {
|
|
|
16560
16610
|
};
|
|
16561
16611
|
}).filter(Boolean);
|
|
16562
16612
|
}, [filterDependencyKey]);
|
|
16563
|
-
const fetchRecords = (0,
|
|
16613
|
+
const fetchRecords = (0, import_react61.useCallback)(
|
|
16564
16614
|
async (params) => {
|
|
16565
16615
|
if (!canQuery) return { list: [], total: 0 };
|
|
16566
16616
|
const filters = buildFilters();
|
|
@@ -16583,7 +16633,7 @@ function AssociationFormField(props) {
|
|
|
16583
16633
|
},
|
|
16584
16634
|
[api, associationAppType, associationFormUuid, buildFilters, canQuery, normalizeRecord]
|
|
16585
16635
|
);
|
|
16586
|
-
const loadOptions = (0,
|
|
16636
|
+
const loadOptions = (0, import_react61.useCallback)(
|
|
16587
16637
|
async (searchKeyWord) => {
|
|
16588
16638
|
setSelectLoading(true);
|
|
16589
16639
|
try {
|
|
@@ -16595,7 +16645,7 @@ function AssociationFormField(props) {
|
|
|
16595
16645
|
},
|
|
16596
16646
|
[fetchRecords, toValue]
|
|
16597
16647
|
);
|
|
16598
|
-
const loadTable = (0,
|
|
16648
|
+
const loadTable = (0, import_react61.useCallback)(
|
|
16599
16649
|
async (next) => {
|
|
16600
16650
|
setTableLoading(true);
|
|
16601
16651
|
const current = next?.current || 1;
|
|
@@ -16614,10 +16664,10 @@ function AssociationFormField(props) {
|
|
|
16614
16664
|
},
|
|
16615
16665
|
[fetchRecords, keyword, pagination.pageSize]
|
|
16616
16666
|
);
|
|
16617
|
-
(0,
|
|
16667
|
+
(0, import_react61.useEffect)(() => {
|
|
16618
16668
|
void loadOptions();
|
|
16619
16669
|
}, [loadOptions]);
|
|
16620
|
-
(0,
|
|
16670
|
+
(0, import_react61.useEffect)(() => {
|
|
16621
16671
|
setSelectedRowKeys(value.map((item) => item.value));
|
|
16622
16672
|
setSelectedRecords(
|
|
16623
16673
|
value.map(
|
|
@@ -16625,7 +16675,7 @@ function AssociationFormField(props) {
|
|
|
16625
16675
|
).filter(Boolean)
|
|
16626
16676
|
);
|
|
16627
16677
|
}, [normalizeRecord, value]);
|
|
16628
|
-
const applyDataFilling = (0,
|
|
16678
|
+
const applyDataFilling = (0, import_react61.useCallback)(
|
|
16629
16679
|
(next) => {
|
|
16630
16680
|
if (!associationForm?.dataFillingEnabled && !associationForm?.dataFillingRules?.mainRules) {
|
|
16631
16681
|
return;
|
|
@@ -16639,7 +16689,7 @@ function AssociationFormField(props) {
|
|
|
16639
16689
|
},
|
|
16640
16690
|
[associationForm?.dataFillingEnabled, associationForm?.dataFillingRules, setFieldValue]
|
|
16641
16691
|
);
|
|
16642
|
-
const commitSelection = (0,
|
|
16692
|
+
const commitSelection = (0, import_react61.useCallback)(
|
|
16643
16693
|
(next) => {
|
|
16644
16694
|
const normalized = multiple ? next : next.slice(0, 1);
|
|
16645
16695
|
setFieldValue(fieldId, normalized);
|
|
@@ -16648,7 +16698,7 @@ function AssociationFormField(props) {
|
|
|
16648
16698
|
},
|
|
16649
16699
|
[applyDataFilling, fieldId, multiple, onChange, setFieldValue]
|
|
16650
16700
|
);
|
|
16651
|
-
const selectorColumns = (0,
|
|
16701
|
+
const selectorColumns = (0, import_react61.useMemo)(() => {
|
|
16652
16702
|
const configured = associationForm?.selectorColumns || [];
|
|
16653
16703
|
if (configured.length) {
|
|
16654
16704
|
return configured.map((column) => {
|
|
@@ -16683,7 +16733,7 @@ function AssociationFormField(props) {
|
|
|
16683
16733
|
}
|
|
16684
16734
|
];
|
|
16685
16735
|
}, [associationForm?.mainFieldId, associationForm?.selectorColumns]);
|
|
16686
|
-
const selectOptions = (0,
|
|
16736
|
+
const selectOptions = (0, import_react61.useMemo)(
|
|
16687
16737
|
() => [...options, ...value].filter(
|
|
16688
16738
|
(item, index, list) => list.findIndex((candidate) => candidate.value === item.value) === index
|
|
16689
16739
|
).map((item) => ({ label: item.label, value: item.value })),
|
|
@@ -16891,9 +16941,9 @@ function AssociationFormField(props) {
|
|
|
16891
16941
|
}
|
|
16892
16942
|
|
|
16893
16943
|
// packages/sdk/src/components/fields/EditorField/index.tsx
|
|
16894
|
-
var
|
|
16944
|
+
var import_react62 = require("react");
|
|
16895
16945
|
var import_core = require("@tiptap/core");
|
|
16896
|
-
var
|
|
16946
|
+
var import_react63 = require("@tiptap/react");
|
|
16897
16947
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
16898
16948
|
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
16899
16949
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
@@ -17527,28 +17577,28 @@ function RichTextEditorCore({
|
|
|
17527
17577
|
fieldId = "richText",
|
|
17528
17578
|
mobile = false
|
|
17529
17579
|
}) {
|
|
17530
|
-
const inputRef = (0,
|
|
17531
|
-
const [uploading, setUploading] = (0,
|
|
17532
|
-
const [uploadError, setUploadError] = (0,
|
|
17533
|
-
const [charCount, setCharCount] = (0,
|
|
17534
|
-
const [linkOpen, setLinkOpen] = (0,
|
|
17535
|
-
const [linkUrl, setLinkUrl] = (0,
|
|
17536
|
-
const [linkError, setLinkError] = (0,
|
|
17537
|
-
const [imageUrlOpen, setImageUrlOpen] = (0,
|
|
17538
|
-
const [imageUrl, setImageUrl] = (0,
|
|
17539
|
-
const [imageAlt, setImageAlt] = (0,
|
|
17540
|
-
const [imageTitle, setImageTitle] = (0,
|
|
17541
|
-
const [imageUrlError, setImageUrlError] = (0,
|
|
17542
|
-
const [tableOpen, setTableOpen] = (0,
|
|
17543
|
-
const [tableRows, setTableRows] = (0,
|
|
17544
|
-
const [tableCols, setTableCols] = (0,
|
|
17545
|
-
const onChangeRef = (0,
|
|
17546
|
-
(0,
|
|
17580
|
+
const inputRef = (0, import_react62.useRef)(null);
|
|
17581
|
+
const [uploading, setUploading] = (0, import_react62.useState)(false);
|
|
17582
|
+
const [uploadError, setUploadError] = (0, import_react62.useState)("");
|
|
17583
|
+
const [charCount, setCharCount] = (0, import_react62.useState)(0);
|
|
17584
|
+
const [linkOpen, setLinkOpen] = (0, import_react62.useState)(false);
|
|
17585
|
+
const [linkUrl, setLinkUrl] = (0, import_react62.useState)("");
|
|
17586
|
+
const [linkError, setLinkError] = (0, import_react62.useState)("");
|
|
17587
|
+
const [imageUrlOpen, setImageUrlOpen] = (0, import_react62.useState)(false);
|
|
17588
|
+
const [imageUrl, setImageUrl] = (0, import_react62.useState)("");
|
|
17589
|
+
const [imageAlt, setImageAlt] = (0, import_react62.useState)("");
|
|
17590
|
+
const [imageTitle, setImageTitle] = (0, import_react62.useState)("");
|
|
17591
|
+
const [imageUrlError, setImageUrlError] = (0, import_react62.useState)("");
|
|
17592
|
+
const [tableOpen, setTableOpen] = (0, import_react62.useState)(false);
|
|
17593
|
+
const [tableRows, setTableRows] = (0, import_react62.useState)(3);
|
|
17594
|
+
const [tableCols, setTableCols] = (0, import_react62.useState)(3);
|
|
17595
|
+
const onChangeRef = (0, import_react62.useRef)(onChange);
|
|
17596
|
+
(0, import_react62.useEffect)(() => {
|
|
17547
17597
|
onChangeRef.current = onChange;
|
|
17548
17598
|
}, [onChange]);
|
|
17549
|
-
const actions = (0,
|
|
17599
|
+
const actions = (0, import_react62.useMemo)(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
|
|
17550
17600
|
const visibleActions = mobile ? [] : actions;
|
|
17551
|
-
const extensions = (0,
|
|
17601
|
+
const extensions = (0, import_react62.useMemo)(
|
|
17552
17602
|
() => [
|
|
17553
17603
|
import_starter_kit.default.configure({
|
|
17554
17604
|
heading: { levels: [1, 2, 3] },
|
|
@@ -17582,10 +17632,10 @@ function RichTextEditorCore({
|
|
|
17582
17632
|
],
|
|
17583
17633
|
[maxLength, placeholder]
|
|
17584
17634
|
);
|
|
17585
|
-
const updateHtml = (0,
|
|
17635
|
+
const updateHtml = (0, import_react62.useCallback)((next) => {
|
|
17586
17636
|
onChangeRef.current?.(next);
|
|
17587
17637
|
}, []);
|
|
17588
|
-
const editor = (0,
|
|
17638
|
+
const editor = (0, import_react63.useEditor)(
|
|
17589
17639
|
{
|
|
17590
17640
|
extensions,
|
|
17591
17641
|
content: value || "",
|
|
@@ -17612,11 +17662,11 @@ function RichTextEditorCore({
|
|
|
17612
17662
|
},
|
|
17613
17663
|
[fieldId, extensions, disabled, maxLength, updateHtml]
|
|
17614
17664
|
);
|
|
17615
|
-
(0,
|
|
17665
|
+
(0, import_react62.useEffect)(() => {
|
|
17616
17666
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17617
17667
|
editor.setEditable(!disabled);
|
|
17618
17668
|
}, [disabled, editor]);
|
|
17619
|
-
(0,
|
|
17669
|
+
(0, import_react62.useEffect)(() => {
|
|
17620
17670
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17621
17671
|
const currentHtml = getSafeEditorHtml(editor);
|
|
17622
17672
|
if ((value || "") !== currentHtml) {
|
|
@@ -17624,7 +17674,7 @@ function RichTextEditorCore({
|
|
|
17624
17674
|
}
|
|
17625
17675
|
setCharCount(countCharacters(editor));
|
|
17626
17676
|
}, [editor, value]);
|
|
17627
|
-
const insertImageFiles = (0,
|
|
17677
|
+
const insertImageFiles = (0, import_react62.useCallback)(
|
|
17628
17678
|
async (files) => {
|
|
17629
17679
|
if (!editor || isEditorDestroyed(editor) || disabled || files.length === 0) return;
|
|
17630
17680
|
const validFiles = files.filter((file) => {
|
|
@@ -17654,7 +17704,7 @@ function RichTextEditorCore({
|
|
|
17654
17704
|
},
|
|
17655
17705
|
[allowedImageTypes, api, disabled, editor, maxImageSize, uploadBucketName]
|
|
17656
17706
|
);
|
|
17657
|
-
const openLinkModal = (0,
|
|
17707
|
+
const openLinkModal = (0, import_react62.useCallback)(() => {
|
|
17658
17708
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17659
17709
|
setLinkUrl(editor.getAttributes("link").href || "");
|
|
17660
17710
|
setLinkError("");
|
|
@@ -17680,7 +17730,7 @@ function RichTextEditorCore({
|
|
|
17680
17730
|
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
17681
17731
|
setLinkOpen(false);
|
|
17682
17732
|
};
|
|
17683
|
-
const openImageUrlModal = (0,
|
|
17733
|
+
const openImageUrlModal = (0, import_react62.useCallback)(() => {
|
|
17684
17734
|
setImageUrl("");
|
|
17685
17735
|
setImageAlt("");
|
|
17686
17736
|
setImageTitle("");
|
|
@@ -17757,7 +17807,7 @@ function RichTextEditorCore({
|
|
|
17757
17807
|
void insertImageFiles(files);
|
|
17758
17808
|
}
|
|
17759
17809
|
},
|
|
17760
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
17810
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_react63.EditorContent, { editor })
|
|
17761
17811
|
}
|
|
17762
17812
|
),
|
|
17763
17813
|
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
@@ -17930,19 +17980,19 @@ function EditorField(props) {
|
|
|
17930
17980
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
17931
17981
|
const rawValue = formData[fieldId] ?? "";
|
|
17932
17982
|
const value = normalizeRichTextHtml(rawValue);
|
|
17933
|
-
(0,
|
|
17983
|
+
(0, import_react62.useEffect)(() => {
|
|
17934
17984
|
registerField(fieldId);
|
|
17935
17985
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
17936
17986
|
setFieldValue(fieldId, normalizeRichTextHtml(defaultValue));
|
|
17937
17987
|
}
|
|
17938
17988
|
return () => unregisterField(fieldId);
|
|
17939
17989
|
}, [fieldId]);
|
|
17940
|
-
(0,
|
|
17990
|
+
(0, import_react62.useEffect)(() => {
|
|
17941
17991
|
if (rawValue && rawValue !== value) {
|
|
17942
17992
|
setFieldValue(fieldId, value);
|
|
17943
17993
|
}
|
|
17944
17994
|
}, [fieldId, rawValue, setFieldValue, value]);
|
|
17945
|
-
const updateHtml = (0,
|
|
17995
|
+
const updateHtml = (0, import_react62.useCallback)(
|
|
17946
17996
|
(next) => {
|
|
17947
17997
|
setFieldValue(fieldId, next);
|
|
17948
17998
|
onChange?.(next);
|
|
@@ -17995,7 +18045,7 @@ function EditorField(props) {
|
|
|
17995
18045
|
}
|
|
17996
18046
|
|
|
17997
18047
|
// packages/sdk/src/components/fields/SerialNumberField/index.tsx
|
|
17998
|
-
var
|
|
18048
|
+
var import_react64 = require("react");
|
|
17999
18049
|
var import_antd31 = require("antd");
|
|
18000
18050
|
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
18001
18051
|
function SerialNumberField(props) {
|
|
@@ -18015,7 +18065,7 @@ function SerialNumberField(props) {
|
|
|
18015
18065
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
18016
18066
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
18017
18067
|
const value = formData[fieldId] ?? "";
|
|
18018
|
-
(0,
|
|
18068
|
+
(0, import_react64.useEffect)(() => {
|
|
18019
18069
|
registerField(fieldId);
|
|
18020
18070
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18021
18071
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18057,7 +18107,7 @@ function SerialNumberField(props) {
|
|
|
18057
18107
|
}
|
|
18058
18108
|
|
|
18059
18109
|
// packages/sdk/src/components/fields/LocationField/index.tsx
|
|
18060
|
-
var
|
|
18110
|
+
var import_react65 = require("react");
|
|
18061
18111
|
var import_antd32 = require("antd");
|
|
18062
18112
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
18063
18113
|
var getDingTalkApi = () => {
|
|
@@ -18099,9 +18149,9 @@ function LocationField(props) {
|
|
|
18099
18149
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
18100
18150
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
18101
18151
|
const value = formData[fieldId];
|
|
18102
|
-
const [locating, setLocating] = (0,
|
|
18103
|
-
const [error, setError] = (0,
|
|
18104
|
-
(0,
|
|
18152
|
+
const [locating, setLocating] = (0, import_react65.useState)(false);
|
|
18153
|
+
const [error, setError] = (0, import_react65.useState)("");
|
|
18154
|
+
(0, import_react65.useEffect)(() => {
|
|
18105
18155
|
registerField(fieldId);
|
|
18106
18156
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18107
18157
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18242,7 +18292,7 @@ function LocationField(props) {
|
|
|
18242
18292
|
}
|
|
18243
18293
|
|
|
18244
18294
|
// packages/sdk/src/components/fields/DigitalSignatureField/index.tsx
|
|
18245
|
-
var
|
|
18295
|
+
var import_react66 = require("react");
|
|
18246
18296
|
var import_antd33 = require("antd");
|
|
18247
18297
|
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
18248
18298
|
var CANVAS_HEIGHT = 260;
|
|
@@ -18276,21 +18326,21 @@ function DigitalSignatureField(props) {
|
|
|
18276
18326
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
18277
18327
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
18278
18328
|
const value = formData[fieldId];
|
|
18279
|
-
const [open, setOpen] = (0,
|
|
18280
|
-
const [saving, setSaving] = (0,
|
|
18281
|
-
const [drawn, setDrawn] = (0,
|
|
18282
|
-
const [error, setError] = (0,
|
|
18283
|
-
const canvasRef = (0,
|
|
18284
|
-
const drawingRef = (0,
|
|
18285
|
-
const pointsRef = (0,
|
|
18286
|
-
(0,
|
|
18329
|
+
const [open, setOpen] = (0, import_react66.useState)(false);
|
|
18330
|
+
const [saving, setSaving] = (0, import_react66.useState)(false);
|
|
18331
|
+
const [drawn, setDrawn] = (0, import_react66.useState)(false);
|
|
18332
|
+
const [error, setError] = (0, import_react66.useState)("");
|
|
18333
|
+
const canvasRef = (0, import_react66.useRef)(null);
|
|
18334
|
+
const drawingRef = (0, import_react66.useRef)(false);
|
|
18335
|
+
const pointsRef = (0, import_react66.useRef)([]);
|
|
18336
|
+
(0, import_react66.useEffect)(() => {
|
|
18287
18337
|
registerField(fieldId);
|
|
18288
18338
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18289
18339
|
setFieldValue(fieldId, defaultValue);
|
|
18290
18340
|
}
|
|
18291
18341
|
return () => unregisterField(fieldId);
|
|
18292
18342
|
}, [fieldId]);
|
|
18293
|
-
const prepareCanvas = (0,
|
|
18343
|
+
const prepareCanvas = (0, import_react66.useCallback)(() => {
|
|
18294
18344
|
const canvas = canvasRef.current;
|
|
18295
18345
|
if (!canvas) return;
|
|
18296
18346
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -18312,7 +18362,7 @@ function DigitalSignatureField(props) {
|
|
|
18312
18362
|
ctx.lineJoin = "round";
|
|
18313
18363
|
ctx.strokeStyle = "#111827";
|
|
18314
18364
|
}, []);
|
|
18315
|
-
(0,
|
|
18365
|
+
(0, import_react66.useEffect)(() => {
|
|
18316
18366
|
if (!open) return;
|
|
18317
18367
|
pointsRef.current = [];
|
|
18318
18368
|
setDrawn(false);
|
|
@@ -18491,7 +18541,7 @@ function DigitalSignatureField(props) {
|
|
|
18491
18541
|
}
|
|
18492
18542
|
|
|
18493
18543
|
// packages/sdk/src/components/fields/JSONField/index.tsx
|
|
18494
|
-
var
|
|
18544
|
+
var import_react67 = require("react");
|
|
18495
18545
|
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
18496
18546
|
var formatJson = (value) => {
|
|
18497
18547
|
if (value === void 0 || value === null || value === "") return "--";
|
|
@@ -18518,7 +18568,7 @@ function JSONField(props) {
|
|
|
18518
18568
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
18519
18569
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
18520
18570
|
const value = formData[fieldId];
|
|
18521
|
-
(0,
|
|
18571
|
+
(0, import_react67.useEffect)(() => {
|
|
18522
18572
|
registerField(fieldId);
|
|
18523
18573
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18524
18574
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18990,9 +19040,9 @@ function FormProvider({
|
|
|
18990
19040
|
runtime,
|
|
18991
19041
|
children
|
|
18992
19042
|
}) {
|
|
18993
|
-
const api = (0,
|
|
18994
|
-
const [runtimeDefaults, setRuntimeDefaults] = (0,
|
|
18995
|
-
const effects = (0,
|
|
19043
|
+
const api = (0, import_react68.useMemo)(() => createFormRuntimeApi(config.api), [config.api]);
|
|
19044
|
+
const [runtimeDefaults, setRuntimeDefaults] = (0, import_react68.useState)({});
|
|
19045
|
+
const effects = (0, import_react68.useMemo)(
|
|
18996
19046
|
() => [
|
|
18997
19047
|
...schema.rules ?? [],
|
|
18998
19048
|
...schema.fields.flatMap((field) => field.optionEffects ?? []),
|
|
@@ -19000,18 +19050,18 @@ function FormProvider({
|
|
|
19000
19050
|
],
|
|
19001
19051
|
[schema.rules, schema.fields, config.effects]
|
|
19002
19052
|
);
|
|
19003
|
-
const defaultRuntime = (0,
|
|
19053
|
+
const defaultRuntime = (0, import_react68.useMemo)(
|
|
19004
19054
|
() => ({
|
|
19005
19055
|
appType: config.appType,
|
|
19006
19056
|
fetchFormData: (params) => fetchRuntimeFormData(api, config.appType, params)
|
|
19007
19057
|
}),
|
|
19008
19058
|
[api, config.appType]
|
|
19009
19059
|
);
|
|
19010
|
-
const mergedRuntime = (0,
|
|
19060
|
+
const mergedRuntime = (0, import_react68.useMemo)(
|
|
19011
19061
|
() => ({ ...defaultRuntime, ...schema.runtime, ...runtimeDefaults, ...runtime }),
|
|
19012
19062
|
[defaultRuntime, schema.runtime, runtimeDefaults, runtime]
|
|
19013
19063
|
);
|
|
19014
|
-
const computedInitialValues = (0,
|
|
19064
|
+
const computedInitialValues = (0, import_react68.useMemo)(() => {
|
|
19015
19065
|
const values = {};
|
|
19016
19066
|
for (const field of schema.fields) {
|
|
19017
19067
|
const defaultValue = resolveDefaultValue(field, mergedRuntime);
|
|
@@ -19021,11 +19071,11 @@ function FormProvider({
|
|
|
19021
19071
|
}
|
|
19022
19072
|
return { ...values, ...initialValues };
|
|
19023
19073
|
}, [schema, initialValues, mergedRuntime]);
|
|
19024
|
-
const initialValuesRef = (0,
|
|
19025
|
-
const [formData, setFormData] = (0,
|
|
19026
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
19027
|
-
const [registeredFields] = (0,
|
|
19028
|
-
(0,
|
|
19074
|
+
const initialValuesRef = (0, import_react68.useRef)(computedInitialValues);
|
|
19075
|
+
const [formData, setFormData] = (0, import_react68.useState)({ ...computedInitialValues });
|
|
19076
|
+
const [fieldErrors, setFieldErrors] = (0, import_react68.useState)({});
|
|
19077
|
+
const [registeredFields] = (0, import_react68.useState)(/* @__PURE__ */ new Set());
|
|
19078
|
+
(0, import_react68.useEffect)(() => {
|
|
19029
19079
|
if (!schema.fields.some((field) => needsCurrentUserRuntime(field.defaultShortcut?.type)))
|
|
19030
19080
|
return;
|
|
19031
19081
|
if (mergedRuntime.currentUser && mergedRuntime.currentDepartment) return;
|
|
@@ -19049,7 +19099,7 @@ function FormProvider({
|
|
|
19049
19099
|
cancelled = true;
|
|
19050
19100
|
};
|
|
19051
19101
|
}, [api, mergedRuntime.currentDepartment, mergedRuntime.currentUser, schema.fields]);
|
|
19052
|
-
(0,
|
|
19102
|
+
(0, import_react68.useEffect)(() => {
|
|
19053
19103
|
setFormData((prev) => {
|
|
19054
19104
|
let changed = false;
|
|
19055
19105
|
const next = { ...prev };
|
|
@@ -19063,7 +19113,7 @@ function FormProvider({
|
|
|
19063
19113
|
return changed ? next : prev;
|
|
19064
19114
|
});
|
|
19065
19115
|
}, [mergedRuntime, schema.fields]);
|
|
19066
|
-
const fieldBehaviors = (0,
|
|
19116
|
+
const fieldBehaviors = (0, import_react68.useMemo)(() => {
|
|
19067
19117
|
const baseBehaviors = {};
|
|
19068
19118
|
for (const field of schema.fields) {
|
|
19069
19119
|
baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
|
|
@@ -19086,15 +19136,15 @@ function FormProvider({
|
|
|
19086
19136
|
}
|
|
19087
19137
|
return computed;
|
|
19088
19138
|
}, [schema, effects, config.permissions, config.mode, formData]);
|
|
19089
|
-
const fieldOverrides = (0,
|
|
19139
|
+
const fieldOverrides = (0, import_react68.useMemo)(
|
|
19090
19140
|
() => evaluateFieldOverrides(effects, formData),
|
|
19091
19141
|
[effects, formData]
|
|
19092
19142
|
);
|
|
19093
|
-
const layoutBehaviors = (0,
|
|
19143
|
+
const layoutBehaviors = (0, import_react68.useMemo)(
|
|
19094
19144
|
() => evaluateLayoutBehaviors(effects, formData),
|
|
19095
19145
|
[effects, formData]
|
|
19096
19146
|
);
|
|
19097
|
-
(0,
|
|
19147
|
+
(0, import_react68.useEffect)(() => {
|
|
19098
19148
|
const valueActions = getValueActions(effects, formData);
|
|
19099
19149
|
if (valueActions.length === 0) return;
|
|
19100
19150
|
let changed = false;
|
|
@@ -19117,7 +19167,7 @@ function FormProvider({
|
|
|
19117
19167
|
setFieldErrors(nextErrors);
|
|
19118
19168
|
}
|
|
19119
19169
|
}, [effects, formData, fieldErrors]);
|
|
19120
|
-
const setFieldValue = (0,
|
|
19170
|
+
const setFieldValue = (0, import_react68.useCallback)((fieldId, value) => {
|
|
19121
19171
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
19122
19172
|
setFieldErrors((prev) => {
|
|
19123
19173
|
if (prev[fieldId]) {
|
|
@@ -19128,9 +19178,9 @@ function FormProvider({
|
|
|
19128
19178
|
return prev;
|
|
19129
19179
|
});
|
|
19130
19180
|
}, []);
|
|
19131
|
-
const getFieldValue = (0,
|
|
19132
|
-
const getFormData2 = (0,
|
|
19133
|
-
const validateFieldById = (0,
|
|
19181
|
+
const getFieldValue = (0, import_react68.useCallback)((fieldId) => formData[fieldId], [formData]);
|
|
19182
|
+
const getFormData2 = (0, import_react68.useCallback)(() => ({ ...formData }), [formData]);
|
|
19183
|
+
const validateFieldById = (0, import_react68.useCallback)(
|
|
19134
19184
|
async (fieldId) => {
|
|
19135
19185
|
const field = schema.fields.find((f) => f.fieldId === fieldId);
|
|
19136
19186
|
if (!field) {
|
|
@@ -19191,7 +19241,7 @@ function FormProvider({
|
|
|
19191
19241
|
},
|
|
19192
19242
|
[schema, formData, fieldBehaviors, fieldOverrides]
|
|
19193
19243
|
);
|
|
19194
|
-
const validateAllWithErrors = (0,
|
|
19244
|
+
const validateAllWithErrors = (0, import_react68.useCallback)(async () => {
|
|
19195
19245
|
const fieldRules = {};
|
|
19196
19246
|
const validationData = { ...formData };
|
|
19197
19247
|
for (const field of schema.fields) {
|
|
@@ -19215,28 +19265,28 @@ function FormProvider({
|
|
|
19215
19265
|
setFieldErrors(errors);
|
|
19216
19266
|
return errors;
|
|
19217
19267
|
}, [schema, formData, fieldBehaviors, fieldOverrides]);
|
|
19218
|
-
const validateAll = (0,
|
|
19268
|
+
const validateAll = (0, import_react68.useCallback)(async () => {
|
|
19219
19269
|
const errors = await validateAllWithErrors();
|
|
19220
19270
|
return Object.keys(errors).length === 0;
|
|
19221
19271
|
}, [validateAllWithErrors]);
|
|
19222
|
-
const resetForm = (0,
|
|
19272
|
+
const resetForm = (0, import_react68.useCallback)(() => {
|
|
19223
19273
|
setFormData({ ...initialValuesRef.current });
|
|
19224
19274
|
setFieldErrors({});
|
|
19225
19275
|
}, []);
|
|
19226
|
-
const registerField = (0,
|
|
19276
|
+
const registerField = (0, import_react68.useCallback)(
|
|
19227
19277
|
(fieldId) => {
|
|
19228
19278
|
registeredFields.add(fieldId);
|
|
19229
19279
|
},
|
|
19230
19280
|
[registeredFields]
|
|
19231
19281
|
);
|
|
19232
|
-
const unregisterField = (0,
|
|
19282
|
+
const unregisterField = (0, import_react68.useCallback)(
|
|
19233
19283
|
(fieldId) => {
|
|
19234
19284
|
registeredFields.delete(fieldId);
|
|
19235
19285
|
},
|
|
19236
19286
|
[registeredFields]
|
|
19237
19287
|
);
|
|
19238
|
-
const [dynamicOptions, setDynamicOptions] = (0,
|
|
19239
|
-
(0,
|
|
19288
|
+
const [dynamicOptions, setDynamicOptions] = (0, import_react68.useState)({});
|
|
19289
|
+
(0, import_react68.useEffect)(() => {
|
|
19240
19290
|
const loadDynamicOptions = async () => {
|
|
19241
19291
|
const updates = {};
|
|
19242
19292
|
for (const field of schema.fields) {
|
|
@@ -19254,7 +19304,7 @@ function FormProvider({
|
|
|
19254
19304
|
};
|
|
19255
19305
|
loadDynamicOptions();
|
|
19256
19306
|
}, [schema.fields, mergedRuntime]);
|
|
19257
|
-
(0,
|
|
19307
|
+
(0, import_react68.useEffect)(() => {
|
|
19258
19308
|
let cancelled = false;
|
|
19259
19309
|
const loadDataLinkageOptions = async () => {
|
|
19260
19310
|
const updates = {};
|
|
@@ -19280,7 +19330,7 @@ function FormProvider({
|
|
|
19280
19330
|
window.clearTimeout(timer);
|
|
19281
19331
|
};
|
|
19282
19332
|
}, [schema.fields, mergedRuntime, formData]);
|
|
19283
|
-
(0,
|
|
19333
|
+
(0, import_react68.useEffect)(() => {
|
|
19284
19334
|
let cancelled = false;
|
|
19285
19335
|
const loadDefaultValueLinkages = async () => {
|
|
19286
19336
|
const fields = schema.fields.filter((field) => field.defaultValueLinkage);
|
|
@@ -19314,7 +19364,7 @@ function FormProvider({
|
|
|
19314
19364
|
window.clearTimeout(timer);
|
|
19315
19365
|
};
|
|
19316
19366
|
}, [schema.fields, mergedRuntime, formData]);
|
|
19317
|
-
const contextValue = (0,
|
|
19367
|
+
const contextValue = (0, import_react68.useMemo)(
|
|
19318
19368
|
() => ({
|
|
19319
19369
|
mode: config.mode,
|
|
19320
19370
|
schema,
|
|
@@ -19370,10 +19420,10 @@ function FormProvider({
|
|
|
19370
19420
|
]
|
|
19371
19421
|
);
|
|
19372
19422
|
const registryComponents = components ?? defaultComponentRegistry;
|
|
19373
|
-
return
|
|
19423
|
+
return import_react68.default.createElement(
|
|
19374
19424
|
FormContext.Provider,
|
|
19375
19425
|
{ value: contextValue },
|
|
19376
|
-
|
|
19426
|
+
import_react68.default.createElement(ComponentRegistryProvider, { components: registryComponents, children })
|
|
19377
19427
|
);
|
|
19378
19428
|
}
|
|
19379
19429
|
function resolveDefaultValue(field, runtime) {
|
|
@@ -19484,11 +19534,11 @@ function coerceLinkedDefaultValue(field, value) {
|
|
|
19484
19534
|
}
|
|
19485
19535
|
|
|
19486
19536
|
// packages/sdk/src/components/core/FormRenderer.tsx
|
|
19487
|
-
var
|
|
19537
|
+
var import_react72 = __toESM(require("react"));
|
|
19488
19538
|
|
|
19489
19539
|
// packages/sdk/src/components/layout/FormSection/index.tsx
|
|
19490
19540
|
var import_icons14 = require("@ant-design/icons");
|
|
19491
|
-
var
|
|
19541
|
+
var import_react69 = require("react");
|
|
19492
19542
|
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
19493
19543
|
var sectionIconMap = {
|
|
19494
19544
|
user: import_icons14.UserOutlined,
|
|
@@ -19513,7 +19563,7 @@ function FormSection({
|
|
|
19513
19563
|
contentClassName,
|
|
19514
19564
|
children
|
|
19515
19565
|
}) {
|
|
19516
|
-
const [collapsed, setCollapsed] = (0,
|
|
19566
|
+
const [collapsed, setCollapsed] = (0, import_react69.useState)(defaultCollapsed);
|
|
19517
19567
|
const handleToggle = () => {
|
|
19518
19568
|
if (collapsible) {
|
|
19519
19569
|
setCollapsed((prev) => !prev);
|
|
@@ -19642,10 +19692,10 @@ function FormGrid({
|
|
|
19642
19692
|
}
|
|
19643
19693
|
|
|
19644
19694
|
// packages/sdk/src/components/layout/FormTabs/index.tsx
|
|
19645
|
-
var
|
|
19695
|
+
var import_react70 = require("react");
|
|
19646
19696
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
19647
19697
|
function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
19648
|
-
const [activeKey, setActiveKey] = (0,
|
|
19698
|
+
const [activeKey, setActiveKey] = (0, import_react70.useState)(defaultActiveKey || items[0]?.key || "");
|
|
19649
19699
|
const activeItem = items.find((item) => item.key === activeKey);
|
|
19650
19700
|
return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-tabs", children: [
|
|
19651
19701
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
@@ -19674,10 +19724,10 @@ function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
|
19674
19724
|
}
|
|
19675
19725
|
|
|
19676
19726
|
// packages/sdk/src/components/layout/FormSteps/index.tsx
|
|
19677
|
-
var
|
|
19727
|
+
var import_react71 = __toESM(require("react"));
|
|
19678
19728
|
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
19679
19729
|
function FormSteps({ items, className, onStepChange }) {
|
|
19680
|
-
const [currentStep, setCurrentStep] = (0,
|
|
19730
|
+
const [currentStep, setCurrentStep] = (0, import_react71.useState)(0);
|
|
19681
19731
|
const goTo = (step) => {
|
|
19682
19732
|
setCurrentStep(step);
|
|
19683
19733
|
onStepChange?.(step);
|
|
@@ -19693,7 +19743,7 @@ function FormSteps({ items, className, onStepChange }) {
|
|
|
19693
19743
|
}
|
|
19694
19744
|
};
|
|
19695
19745
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-steps", children: [
|
|
19696
|
-
/* @__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)(
|
|
19746
|
+
/* @__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: [
|
|
19697
19747
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex items-center", children: [
|
|
19698
19748
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
19699
19749
|
"div",
|
|
@@ -19794,7 +19844,7 @@ function FieldRenderer({
|
|
|
19794
19844
|
return null;
|
|
19795
19845
|
}
|
|
19796
19846
|
const { fieldId, componentName: _, ...fieldProps } = field;
|
|
19797
|
-
const element =
|
|
19847
|
+
const element = import_react72.default.createElement(Component, {
|
|
19798
19848
|
...fieldProps,
|
|
19799
19849
|
fieldId,
|
|
19800
19850
|
className: fieldClassName ?? fieldProps.className
|
|
@@ -19958,7 +20008,7 @@ function FormRenderer({
|
|
|
19958
20008
|
const gridClass = columnsClassMap[columns];
|
|
19959
20009
|
const gapClass = sizeClassMap[size];
|
|
19960
20010
|
const containerClassName = ["sy-form-renderer", "sy-grid", gridClass, gapClass, className].filter(Boolean).join(" ");
|
|
19961
|
-
const fieldMap =
|
|
20011
|
+
const fieldMap = import_react72.default.useMemo(() => {
|
|
19962
20012
|
return new Map(
|
|
19963
20013
|
schema.fields.map((field) => [
|
|
19964
20014
|
field.fieldId,
|
|
@@ -20029,7 +20079,7 @@ function isLayoutVisible(visibleWhen, formData) {
|
|
|
20029
20079
|
}
|
|
20030
20080
|
|
|
20031
20081
|
// packages/sdk/src/components/core/FormShell.tsx
|
|
20032
|
-
var
|
|
20082
|
+
var import_react73 = require("react");
|
|
20033
20083
|
var Antd2 = __toESM(require("antd"));
|
|
20034
20084
|
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
20035
20085
|
function normalizeMaxWidth(maxWidth) {
|
|
@@ -20059,10 +20109,10 @@ function FormShell({ children, appearance, className }) {
|
|
|
20059
20109
|
const [form] = useAntForm();
|
|
20060
20110
|
const { formData, setFieldValue } = useFormContext();
|
|
20061
20111
|
const maxWidth = normalizeMaxWidth(appearance?.maxWidth);
|
|
20062
|
-
(0,
|
|
20112
|
+
(0, import_react73.useEffect)(() => {
|
|
20063
20113
|
form?.setFieldsValue?.(formData);
|
|
20064
20114
|
}, [form, formData]);
|
|
20065
|
-
const style = (0,
|
|
20115
|
+
const style = (0, import_react73.useMemo)(() => {
|
|
20066
20116
|
if (!maxWidth) return void 0;
|
|
20067
20117
|
return {
|
|
20068
20118
|
maxWidth,
|
|
@@ -20128,7 +20178,7 @@ async function validateAndNotify(validateAllWithErrors) {
|
|
|
20128
20178
|
}
|
|
20129
20179
|
|
|
20130
20180
|
// packages/sdk/src/components/hooks/useFormDetail.ts
|
|
20131
|
-
var
|
|
20181
|
+
var import_react74 = require("react");
|
|
20132
20182
|
|
|
20133
20183
|
// packages/sdk/src/components/utils/formInstanceData.ts
|
|
20134
20184
|
var FORM_INSTANCE_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -20325,24 +20375,24 @@ function useFormDetail(options) {
|
|
|
20325
20375
|
const { formUuid, appType, formInstanceId, fieldIds, onPermissionDenied } = options;
|
|
20326
20376
|
const { api } = useFormContext();
|
|
20327
20377
|
const request = api.request;
|
|
20328
|
-
const [loading, setLoading] = (0,
|
|
20329
|
-
const [mode, setMode] = (0,
|
|
20330
|
-
const [formData, setFormData] = (0,
|
|
20331
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
20332
|
-
const [permissions, setPermissions] = (0,
|
|
20333
|
-
const mountedRef = (0,
|
|
20334
|
-
const onPermissionDeniedRef = (0,
|
|
20378
|
+
const [loading, setLoading] = (0, import_react74.useState)(true);
|
|
20379
|
+
const [mode, setMode] = (0, import_react74.useState)("readonly");
|
|
20380
|
+
const [formData, setFormData] = (0, import_react74.useState)(null);
|
|
20381
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react74.useState)(null);
|
|
20382
|
+
const [permissions, setPermissions] = (0, import_react74.useState)(null);
|
|
20383
|
+
const mountedRef = (0, import_react74.useRef)(true);
|
|
20384
|
+
const onPermissionDeniedRef = (0, import_react74.useRef)(onPermissionDenied);
|
|
20335
20385
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
20336
|
-
(0,
|
|
20386
|
+
(0, import_react74.useEffect)(() => {
|
|
20337
20387
|
mountedRef.current = true;
|
|
20338
20388
|
return () => {
|
|
20339
20389
|
mountedRef.current = false;
|
|
20340
20390
|
};
|
|
20341
20391
|
}, []);
|
|
20342
|
-
(0,
|
|
20392
|
+
(0, import_react74.useEffect)(() => {
|
|
20343
20393
|
onPermissionDeniedRef.current = onPermissionDenied;
|
|
20344
20394
|
}, [onPermissionDenied]);
|
|
20345
|
-
const loadData = (0,
|
|
20395
|
+
const loadData = (0, import_react74.useCallback)(async () => {
|
|
20346
20396
|
if (!mountedRef.current) return;
|
|
20347
20397
|
setLoading(true);
|
|
20348
20398
|
try {
|
|
@@ -20377,21 +20427,21 @@ function useFormDetail(options) {
|
|
|
20377
20427
|
}
|
|
20378
20428
|
}
|
|
20379
20429
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
20380
|
-
(0,
|
|
20430
|
+
(0, import_react74.useEffect)(() => {
|
|
20381
20431
|
loadData();
|
|
20382
20432
|
}, [loadData]);
|
|
20383
20433
|
const fieldBehaviors = normalizeFieldBehaviors(permissions, mode);
|
|
20384
20434
|
const canEdit = hasViewOperation(permissions?.operations, "edit");
|
|
20385
20435
|
const canDelete = hasViewOperation(permissions?.operations, "delete");
|
|
20386
20436
|
const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
|
|
20387
|
-
const switchToEdit = (0,
|
|
20437
|
+
const switchToEdit = (0, import_react74.useCallback)(() => {
|
|
20388
20438
|
setMode("edit");
|
|
20389
20439
|
loadData();
|
|
20390
20440
|
}, [loadData]);
|
|
20391
|
-
const switchToReadonly = (0,
|
|
20441
|
+
const switchToReadonly = (0, import_react74.useCallback)(() => {
|
|
20392
20442
|
setMode("readonly");
|
|
20393
20443
|
}, []);
|
|
20394
|
-
const saveChanges = (0,
|
|
20444
|
+
const saveChanges = (0, import_react74.useCallback)(
|
|
20395
20445
|
async (values) => {
|
|
20396
20446
|
try {
|
|
20397
20447
|
await api.updateFormData({
|
|
@@ -20412,7 +20462,7 @@ function useFormDetail(options) {
|
|
|
20412
20462
|
},
|
|
20413
20463
|
[api, formInstanceId, formUuid, appType]
|
|
20414
20464
|
);
|
|
20415
|
-
const deleteInstance = (0,
|
|
20465
|
+
const deleteInstance = (0, import_react74.useCallback)(async () => {
|
|
20416
20466
|
try {
|
|
20417
20467
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
20418
20468
|
return true;
|
|
@@ -20439,7 +20489,7 @@ function useFormDetail(options) {
|
|
|
20439
20489
|
}
|
|
20440
20490
|
|
|
20441
20491
|
// packages/sdk/src/components/hooks/useChangeRecords.ts
|
|
20442
|
-
var
|
|
20492
|
+
var import_react75 = require("react");
|
|
20443
20493
|
var normalizeChangeRecordList = (value) => {
|
|
20444
20494
|
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;
|
|
20445
20495
|
const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
|
|
@@ -20454,18 +20504,18 @@ function useChangeRecords(options) {
|
|
|
20454
20504
|
const { formUuid, appType, formInstanceId, pageSize = 20, autoLoad = true } = options;
|
|
20455
20505
|
const { api } = useFormContext();
|
|
20456
20506
|
const request = api.request;
|
|
20457
|
-
const [records, setRecords] = (0,
|
|
20458
|
-
const [loading, setLoading] = (0,
|
|
20459
|
-
const [total, setTotal] = (0,
|
|
20460
|
-
const [page, setPage] = (0,
|
|
20461
|
-
const mountedRef = (0,
|
|
20462
|
-
(0,
|
|
20507
|
+
const [records, setRecords] = (0, import_react75.useState)([]);
|
|
20508
|
+
const [loading, setLoading] = (0, import_react75.useState)(false);
|
|
20509
|
+
const [total, setTotal] = (0, import_react75.useState)(0);
|
|
20510
|
+
const [page, setPage] = (0, import_react75.useState)(1);
|
|
20511
|
+
const mountedRef = (0, import_react75.useRef)(true);
|
|
20512
|
+
(0, import_react75.useEffect)(() => {
|
|
20463
20513
|
mountedRef.current = true;
|
|
20464
20514
|
return () => {
|
|
20465
20515
|
mountedRef.current = false;
|
|
20466
20516
|
};
|
|
20467
20517
|
}, []);
|
|
20468
|
-
const fetchRecords = (0,
|
|
20518
|
+
const fetchRecords = (0, import_react75.useCallback)(
|
|
20469
20519
|
async (pageNum, append) => {
|
|
20470
20520
|
if (!mountedRef.current) return;
|
|
20471
20521
|
setLoading(true);
|
|
@@ -20496,18 +20546,18 @@ function useChangeRecords(options) {
|
|
|
20496
20546
|
},
|
|
20497
20547
|
[request, formUuid, appType, formInstanceId, pageSize]
|
|
20498
20548
|
);
|
|
20499
|
-
(0,
|
|
20549
|
+
(0, import_react75.useEffect)(() => {
|
|
20500
20550
|
if (autoLoad) {
|
|
20501
20551
|
fetchRecords(1, false);
|
|
20502
20552
|
}
|
|
20503
20553
|
}, [autoLoad, fetchRecords]);
|
|
20504
20554
|
const safeRecords = Array.isArray(records) ? records : [];
|
|
20505
20555
|
const hasMore = safeRecords.length < total;
|
|
20506
|
-
const loadMore = (0,
|
|
20556
|
+
const loadMore = (0, import_react75.useCallback)(async () => {
|
|
20507
20557
|
if (!hasMore || loading) return;
|
|
20508
20558
|
await fetchRecords(page + 1, true);
|
|
20509
20559
|
}, [hasMore, loading, page, fetchRecords]);
|
|
20510
|
-
const refresh = (0,
|
|
20560
|
+
const refresh = (0, import_react75.useCallback)(async () => {
|
|
20511
20561
|
setRecords([]);
|
|
20512
20562
|
setPage(1);
|
|
20513
20563
|
setTotal(0);
|
|
@@ -20661,7 +20711,7 @@ var SummaryPanel = ({
|
|
|
20661
20711
|
};
|
|
20662
20712
|
|
|
20663
20713
|
// packages/sdk/src/components/modules/RecordChangePanel.tsx
|
|
20664
|
-
var
|
|
20714
|
+
var import_react76 = require("react");
|
|
20665
20715
|
var import_antd37 = require("antd");
|
|
20666
20716
|
var import_icons16 = require("@ant-design/icons");
|
|
20667
20717
|
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
@@ -20707,7 +20757,7 @@ var RecordChangePanel = ({
|
|
|
20707
20757
|
onPageChange,
|
|
20708
20758
|
className = ""
|
|
20709
20759
|
}) => {
|
|
20710
|
-
const [expanded, setExpanded] = (0,
|
|
20760
|
+
const [expanded, setExpanded] = (0, import_react76.useState)(defaultExpanded);
|
|
20711
20761
|
const count = total ?? records.length;
|
|
20712
20762
|
const handleToggle = () => {
|
|
20713
20763
|
const next = !expanded;
|
|
@@ -20918,10 +20968,10 @@ var InnerDetailContent = ({
|
|
|
20918
20968
|
onSave,
|
|
20919
20969
|
inDrawer = false
|
|
20920
20970
|
}) => {
|
|
20921
|
-
const formDataRef = (0,
|
|
20922
|
-
const validateRef = (0,
|
|
20923
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
20924
|
-
const fieldIds = (0,
|
|
20971
|
+
const formDataRef = (0, import_react77.useRef)(void 0);
|
|
20972
|
+
const validateRef = (0, import_react77.useRef)(void 0);
|
|
20973
|
+
const [accessDenied, setAccessDenied] = (0, import_react77.useState)(false);
|
|
20974
|
+
const fieldIds = (0, import_react77.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
20925
20975
|
const {
|
|
20926
20976
|
loading,
|
|
20927
20977
|
mode,
|
|
@@ -20956,7 +21006,7 @@ var InnerDetailContent = ({
|
|
|
20956
21006
|
formInstanceId,
|
|
20957
21007
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
20958
21008
|
});
|
|
20959
|
-
const handleSave = (0,
|
|
21009
|
+
const handleSave = (0, import_react77.useCallback)(async () => {
|
|
20960
21010
|
if (validateRef.current && !await validateAndNotify(validateRef.current)) return;
|
|
20961
21011
|
const values = formDataRef.current?.() ?? formData;
|
|
20962
21012
|
if (!values) return;
|
|
@@ -20965,13 +21015,13 @@ var InnerDetailContent = ({
|
|
|
20965
21015
|
onSave?.(values);
|
|
20966
21016
|
}
|
|
20967
21017
|
}, [formData, saveChanges, onSave]);
|
|
20968
|
-
const handleDelete = (0,
|
|
21018
|
+
const handleDelete = (0, import_react77.useCallback)(async () => {
|
|
20969
21019
|
const success = await deleteInstance();
|
|
20970
21020
|
if (success) {
|
|
20971
21021
|
onDelete?.();
|
|
20972
21022
|
}
|
|
20973
21023
|
}, [deleteInstance, onDelete]);
|
|
20974
|
-
const handleCancel = (0,
|
|
21024
|
+
const handleCancel = (0, import_react77.useCallback)(() => {
|
|
20975
21025
|
switchToReadonly();
|
|
20976
21026
|
}, [switchToReadonly]);
|
|
20977
21027
|
const readonlyActions = [];
|
|
@@ -21098,12 +21148,12 @@ var FormDetailTemplate = (props) => {
|
|
|
21098
21148
|
};
|
|
21099
21149
|
|
|
21100
21150
|
// packages/sdk/src/components/templates/FormSubmitTemplate.tsx
|
|
21101
|
-
var
|
|
21151
|
+
var import_react80 = require("react");
|
|
21102
21152
|
var import_antd40 = require("antd");
|
|
21103
21153
|
var import_icons18 = require("@ant-design/icons");
|
|
21104
21154
|
|
|
21105
21155
|
// packages/sdk/src/components/hooks/useDraftStorage.ts
|
|
21106
|
-
var
|
|
21156
|
+
var import_react78 = require("react");
|
|
21107
21157
|
function getDraftKey(appType, formUuid) {
|
|
21108
21158
|
return `${appType}__${formUuid}__draft`;
|
|
21109
21159
|
}
|
|
@@ -21123,10 +21173,10 @@ function readDraft(key) {
|
|
|
21123
21173
|
function useDraftStorage(options) {
|
|
21124
21174
|
const { appType, formUuid, autoRestore = false } = options;
|
|
21125
21175
|
const key = getDraftKey(appType, formUuid);
|
|
21126
|
-
const [hasDraft, setHasDraft] = (0,
|
|
21127
|
-
const [draftData, setDraftData] = (0,
|
|
21128
|
-
const [draftTimestamp, setDraftTimestamp] = (0,
|
|
21129
|
-
(0,
|
|
21176
|
+
const [hasDraft, setHasDraft] = (0, import_react78.useState)(false);
|
|
21177
|
+
const [draftData, setDraftData] = (0, import_react78.useState)(null);
|
|
21178
|
+
const [draftTimestamp, setDraftTimestamp] = (0, import_react78.useState)(null);
|
|
21179
|
+
(0, import_react78.useEffect)(() => {
|
|
21130
21180
|
const stored = readDraft(key);
|
|
21131
21181
|
if (stored) {
|
|
21132
21182
|
setHasDraft(true);
|
|
@@ -21140,7 +21190,7 @@ function useDraftStorage(options) {
|
|
|
21140
21190
|
setDraftTimestamp(null);
|
|
21141
21191
|
}
|
|
21142
21192
|
}, [key, autoRestore]);
|
|
21143
|
-
const saveDraft = (0,
|
|
21193
|
+
const saveDraft = (0, import_react78.useCallback)(
|
|
21144
21194
|
(data) => {
|
|
21145
21195
|
const payload = { data, ts: Date.now() };
|
|
21146
21196
|
try {
|
|
@@ -21154,7 +21204,7 @@ function useDraftStorage(options) {
|
|
|
21154
21204
|
},
|
|
21155
21205
|
[key]
|
|
21156
21206
|
);
|
|
21157
|
-
const restoreDraft = (0,
|
|
21207
|
+
const restoreDraft = (0, import_react78.useCallback)(() => {
|
|
21158
21208
|
const stored = readDraft(key);
|
|
21159
21209
|
if (stored) {
|
|
21160
21210
|
setDraftData(stored.data);
|
|
@@ -21162,7 +21212,7 @@ function useDraftStorage(options) {
|
|
|
21162
21212
|
}
|
|
21163
21213
|
return null;
|
|
21164
21214
|
}, [key]);
|
|
21165
|
-
const clearDraft = (0,
|
|
21215
|
+
const clearDraft = (0, import_react78.useCallback)(() => {
|
|
21166
21216
|
try {
|
|
21167
21217
|
localStorage.removeItem(key);
|
|
21168
21218
|
} catch (error) {
|
|
@@ -21183,7 +21233,7 @@ function useDraftStorage(options) {
|
|
|
21183
21233
|
}
|
|
21184
21234
|
|
|
21185
21235
|
// packages/sdk/src/components/hooks/useFormNavigation.ts
|
|
21186
|
-
var
|
|
21236
|
+
var import_react79 = require("react");
|
|
21187
21237
|
var normalizeBasePath = (basePath) => {
|
|
21188
21238
|
const normalized = String(basePath || "").replace(/^\/+|\/+$/g, "");
|
|
21189
21239
|
return normalized ? `/${normalized}` : "";
|
|
@@ -21215,12 +21265,12 @@ function useFormNavigation(options) {
|
|
|
21215
21265
|
basePath,
|
|
21216
21266
|
onStay
|
|
21217
21267
|
} = options;
|
|
21218
|
-
const [isRedirecting, setIsRedirecting] = (0,
|
|
21219
|
-
const [countdown, setCountdown] = (0,
|
|
21220
|
-
const timerRef = (0,
|
|
21221
|
-
const redirectTargetRef = (0,
|
|
21222
|
-
const mountedRef = (0,
|
|
21223
|
-
(0,
|
|
21268
|
+
const [isRedirecting, setIsRedirecting] = (0, import_react79.useState)(false);
|
|
21269
|
+
const [countdown, setCountdown] = (0, import_react79.useState)(0);
|
|
21270
|
+
const timerRef = (0, import_react79.useRef)(null);
|
|
21271
|
+
const redirectTargetRef = (0, import_react79.useRef)(null);
|
|
21272
|
+
const mountedRef = (0, import_react79.useRef)(true);
|
|
21273
|
+
(0, import_react79.useEffect)(() => {
|
|
21224
21274
|
mountedRef.current = true;
|
|
21225
21275
|
return () => {
|
|
21226
21276
|
mountedRef.current = false;
|
|
@@ -21230,13 +21280,13 @@ function useFormNavigation(options) {
|
|
|
21230
21280
|
}
|
|
21231
21281
|
};
|
|
21232
21282
|
}, []);
|
|
21233
|
-
const navigateToDetail = (0,
|
|
21283
|
+
const navigateToDetail = (0, import_react79.useCallback)(
|
|
21234
21284
|
(formInstId) => {
|
|
21235
21285
|
window.location.href = buildDetailUrl(appType, formUuid, formInstId, "formDetail", basePath);
|
|
21236
21286
|
},
|
|
21237
21287
|
[appType, basePath, formUuid]
|
|
21238
21288
|
);
|
|
21239
|
-
const navigateToProcessDetail = (0,
|
|
21289
|
+
const navigateToProcessDetail = (0, import_react79.useCallback)(
|
|
21240
21290
|
(formInstId) => {
|
|
21241
21291
|
window.location.href = buildDetailUrl(
|
|
21242
21292
|
appType,
|
|
@@ -21248,7 +21298,7 @@ function useFormNavigation(options) {
|
|
|
21248
21298
|
},
|
|
21249
21299
|
[appType, basePath, formUuid]
|
|
21250
21300
|
);
|
|
21251
|
-
const startRedirectCountdown = (0,
|
|
21301
|
+
const startRedirectCountdown = (0, import_react79.useCallback)(
|
|
21252
21302
|
(targetUrl) => {
|
|
21253
21303
|
const totalSeconds = Math.ceil(redirectDelay / 1e3);
|
|
21254
21304
|
setIsRedirecting(true);
|
|
@@ -21281,7 +21331,7 @@ function useFormNavigation(options) {
|
|
|
21281
21331
|
},
|
|
21282
21332
|
[redirectDelay]
|
|
21283
21333
|
);
|
|
21284
|
-
const cancelRedirect = (0,
|
|
21334
|
+
const cancelRedirect = (0, import_react79.useCallback)(() => {
|
|
21285
21335
|
if (timerRef.current) {
|
|
21286
21336
|
clearInterval(timerRef.current);
|
|
21287
21337
|
timerRef.current = null;
|
|
@@ -21290,7 +21340,7 @@ function useFormNavigation(options) {
|
|
|
21290
21340
|
setCountdown(0);
|
|
21291
21341
|
redirectTargetRef.current = null;
|
|
21292
21342
|
}, []);
|
|
21293
|
-
const handlePostSubmit = (0,
|
|
21343
|
+
const handlePostSubmit = (0, import_react79.useCallback)(
|
|
21294
21344
|
(formInstId) => {
|
|
21295
21345
|
if (mode === "stay") {
|
|
21296
21346
|
onStay?.(formInstId);
|
|
@@ -21505,26 +21555,26 @@ var InnerFormContent = ({
|
|
|
21505
21555
|
inDrawer = false
|
|
21506
21556
|
}) => {
|
|
21507
21557
|
const { validateAllWithErrors, getFormData: getFormData2, setFieldValue, resetForm, api } = useFormContext();
|
|
21508
|
-
const [submitted, setSubmitted] = (0,
|
|
21509
|
-
const [successInfo, setSuccessInfo] = (0,
|
|
21510
|
-
const [submitting, setSubmitting] = (0,
|
|
21511
|
-
const [departmentId, setDepartmentId] = (0,
|
|
21512
|
-
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = (0,
|
|
21513
|
-
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = (0,
|
|
21514
|
-
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = (0,
|
|
21515
|
-
const submissionDepartmentResolverRef = (0,
|
|
21516
|
-
const [previewOpen, setPreviewOpen] = (0,
|
|
21517
|
-
const [previewLoading, setPreviewLoading] = (0,
|
|
21518
|
-
const [previewRoutes, setPreviewRoutes] = (0,
|
|
21519
|
-
const [pendingFormData, setPendingFormData] = (0,
|
|
21520
|
-
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = (0,
|
|
21521
|
-
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = (0,
|
|
21522
|
-
const pendingSubmissionDepartmentIdRef = (0,
|
|
21523
|
-
const pendingInitiatorSelectedApproversRef = (0,
|
|
21558
|
+
const [submitted, setSubmitted] = (0, import_react80.useState)(false);
|
|
21559
|
+
const [successInfo, setSuccessInfo] = (0, import_react80.useState)(null);
|
|
21560
|
+
const [submitting, setSubmitting] = (0, import_react80.useState)(false);
|
|
21561
|
+
const [departmentId, setDepartmentId] = (0, import_react80.useState)();
|
|
21562
|
+
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = (0, import_react80.useState)(false);
|
|
21563
|
+
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = (0, import_react80.useState)([]);
|
|
21564
|
+
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = (0, import_react80.useState)();
|
|
21565
|
+
const submissionDepartmentResolverRef = (0, import_react80.useRef)(null);
|
|
21566
|
+
const [previewOpen, setPreviewOpen] = (0, import_react80.useState)(false);
|
|
21567
|
+
const [previewLoading, setPreviewLoading] = (0, import_react80.useState)(false);
|
|
21568
|
+
const [previewRoutes, setPreviewRoutes] = (0, import_react80.useState)([]);
|
|
21569
|
+
const [pendingFormData, setPendingFormData] = (0, import_react80.useState)(null);
|
|
21570
|
+
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = (0, import_react80.useState)();
|
|
21571
|
+
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = (0, import_react80.useState)();
|
|
21572
|
+
const pendingSubmissionDepartmentIdRef = (0, import_react80.useRef)(void 0);
|
|
21573
|
+
const pendingInitiatorSelectedApproversRef = (0, import_react80.useRef)(
|
|
21524
21574
|
void 0
|
|
21525
21575
|
);
|
|
21526
|
-
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0,
|
|
21527
|
-
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0,
|
|
21576
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react80.useState)(false);
|
|
21577
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react80.useState)([]);
|
|
21528
21578
|
const { hasDraft, draftTimestamp, saveDraft, restoreDraft, clearDraft } = useDraftStorage({
|
|
21529
21579
|
appType: config.appType,
|
|
21530
21580
|
formUuid: config.formUuid
|
|
@@ -21536,20 +21586,20 @@ var InnerFormContent = ({
|
|
|
21536
21586
|
mode: submitSuccessMode === "continue" ? "stay" : submitSuccessMode,
|
|
21537
21587
|
basePath: config.navigation?.basePath
|
|
21538
21588
|
});
|
|
21539
|
-
(0,
|
|
21589
|
+
(0, import_react80.useEffect)(() => {
|
|
21540
21590
|
return () => {
|
|
21541
21591
|
submissionDepartmentResolverRef.current?.(null);
|
|
21542
21592
|
submissionDepartmentResolverRef.current = null;
|
|
21543
21593
|
};
|
|
21544
21594
|
}, []);
|
|
21545
|
-
const closeSubmissionDepartmentModal = (0,
|
|
21595
|
+
const closeSubmissionDepartmentModal = (0, import_react80.useCallback)((value = null) => {
|
|
21546
21596
|
setSubmissionDepartmentModalOpen(false);
|
|
21547
21597
|
setSubmissionDepartmentOptions([]);
|
|
21548
21598
|
setSelectedSubmissionDepartmentId(void 0);
|
|
21549
21599
|
submissionDepartmentResolverRef.current?.(value);
|
|
21550
21600
|
submissionDepartmentResolverRef.current = null;
|
|
21551
21601
|
}, []);
|
|
21552
|
-
const promptSubmissionDepartmentSelection = (0,
|
|
21602
|
+
const promptSubmissionDepartmentSelection = (0, import_react80.useCallback)(
|
|
21553
21603
|
(options, preferredDepartmentId) => {
|
|
21554
21604
|
return new Promise((resolve) => {
|
|
21555
21605
|
const selected = options.some((option) => option.value === preferredDepartmentId) ? preferredDepartmentId : options[0]?.value;
|
|
@@ -21561,7 +21611,7 @@ var InnerFormContent = ({
|
|
|
21561
21611
|
},
|
|
21562
21612
|
[]
|
|
21563
21613
|
);
|
|
21564
|
-
const resolveSubmissionDepartmentId = (0,
|
|
21614
|
+
const resolveSubmissionDepartmentId = (0, import_react80.useCallback)(async () => {
|
|
21565
21615
|
if (formType !== "process") {
|
|
21566
21616
|
return void 0;
|
|
21567
21617
|
}
|
|
@@ -21583,7 +21633,7 @@ var InnerFormContent = ({
|
|
|
21583
21633
|
}
|
|
21584
21634
|
return promptSubmissionDepartmentSelection(departments, departmentId);
|
|
21585
21635
|
}, [api, config.formUuid, departmentId, formType, promptSubmissionDepartmentSelection, schema]);
|
|
21586
|
-
const performSubmit = (0,
|
|
21636
|
+
const performSubmit = (0, import_react80.useCallback)(
|
|
21587
21637
|
async (formData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
21588
21638
|
const submitData = normalizeFormDataForSubmit(schema, formData);
|
|
21589
21639
|
setSubmitting(true);
|
|
@@ -21660,7 +21710,7 @@ var InnerFormContent = ({
|
|
|
21660
21710
|
departmentId
|
|
21661
21711
|
]
|
|
21662
21712
|
);
|
|
21663
|
-
const continuePreparedSubmit = (0,
|
|
21713
|
+
const continuePreparedSubmit = (0, import_react80.useCallback)(
|
|
21664
21714
|
async (submitData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
21665
21715
|
if (formType === "process" && enableProcessPreview && !isSaveDraftSubmitBehavior(config)) {
|
|
21666
21716
|
setPendingFormData(submitData);
|
|
@@ -21692,7 +21742,7 @@ var InnerFormContent = ({
|
|
|
21692
21742
|
},
|
|
21693
21743
|
[api.request, config, enableProcessPreview, formType, performSubmit]
|
|
21694
21744
|
);
|
|
21695
|
-
const prepareSubmit = (0,
|
|
21745
|
+
const prepareSubmit = (0, import_react80.useCallback)(async () => {
|
|
21696
21746
|
const valid = await validateAndNotify(validateAllWithErrors);
|
|
21697
21747
|
if (!valid) return;
|
|
21698
21748
|
const formData = getFormData2();
|
|
@@ -21749,7 +21799,7 @@ var InnerFormContent = ({
|
|
|
21749
21799
|
resolveSubmissionDepartmentId,
|
|
21750
21800
|
continuePreparedSubmit
|
|
21751
21801
|
]);
|
|
21752
|
-
const handlePreviewConfirm = (0,
|
|
21802
|
+
const handlePreviewConfirm = (0, import_react80.useCallback)(async () => {
|
|
21753
21803
|
const data = pendingFormData ?? getFormData2();
|
|
21754
21804
|
const submissionDepartmentId = pendingSubmissionDepartmentIdRef.current ?? pendingSubmissionDepartmentId;
|
|
21755
21805
|
const initiatorSelectedApprovers = pendingInitiatorSelectedApproversRef.current ?? pendingInitiatorSelectedApprovers;
|
|
@@ -21767,7 +21817,7 @@ var InnerFormContent = ({
|
|
|
21767
21817
|
pendingSubmissionDepartmentId,
|
|
21768
21818
|
performSubmit
|
|
21769
21819
|
]);
|
|
21770
|
-
const handleInitiatorApproverConfirm = (0,
|
|
21820
|
+
const handleInitiatorApproverConfirm = (0, import_react80.useCallback)(
|
|
21771
21821
|
async (selectedUsersByNode) => {
|
|
21772
21822
|
const data = pendingFormData;
|
|
21773
21823
|
if (!data) {
|
|
@@ -21783,7 +21833,7 @@ var InnerFormContent = ({
|
|
|
21783
21833
|
},
|
|
21784
21834
|
[continuePreparedSubmit, pendingFormData, pendingSubmissionDepartmentId]
|
|
21785
21835
|
);
|
|
21786
|
-
const handleInitiatorApproverCancel = (0,
|
|
21836
|
+
const handleInitiatorApproverCancel = (0, import_react80.useCallback)(() => {
|
|
21787
21837
|
setInitiatorApproverOpen(false);
|
|
21788
21838
|
setInitiatorApproverRequirements([]);
|
|
21789
21839
|
setPendingFormData(null);
|
|
@@ -21792,23 +21842,23 @@ var InnerFormContent = ({
|
|
|
21792
21842
|
pendingSubmissionDepartmentIdRef.current = void 0;
|
|
21793
21843
|
pendingInitiatorSelectedApproversRef.current = void 0;
|
|
21794
21844
|
}, []);
|
|
21795
|
-
const handleSaveDraft = (0,
|
|
21845
|
+
const handleSaveDraft = (0, import_react80.useCallback)(() => {
|
|
21796
21846
|
const data = getFormData2();
|
|
21797
21847
|
saveDraft(data);
|
|
21798
21848
|
}, [getFormData2, saveDraft]);
|
|
21799
|
-
const handleRestoreDraft = (0,
|
|
21849
|
+
const handleRestoreDraft = (0, import_react80.useCallback)(() => {
|
|
21800
21850
|
const data = restoreDraft();
|
|
21801
21851
|
if (!data) return;
|
|
21802
21852
|
Object.entries(data).forEach(([fieldId, value]) => {
|
|
21803
21853
|
setFieldValue(fieldId, value);
|
|
21804
21854
|
});
|
|
21805
21855
|
}, [restoreDraft, setFieldValue]);
|
|
21806
|
-
const handleContinue = (0,
|
|
21856
|
+
const handleContinue = (0, import_react80.useCallback)(() => {
|
|
21807
21857
|
setSubmitted(false);
|
|
21808
21858
|
setSuccessInfo(null);
|
|
21809
21859
|
resetForm();
|
|
21810
21860
|
}, [resetForm]);
|
|
21811
|
-
const handleViewDetail = (0,
|
|
21861
|
+
const handleViewDetail = (0, import_react80.useCallback)(() => {
|
|
21812
21862
|
if (!successInfo) return;
|
|
21813
21863
|
if (formType === "process") {
|
|
21814
21864
|
navigateToProcessDetail(successInfo.formInstanceId);
|
|
@@ -22029,15 +22079,15 @@ var FormSubmitTemplate = ({
|
|
|
22029
22079
|
};
|
|
22030
22080
|
|
|
22031
22081
|
// packages/sdk/src/components/templates/ProcessDetailTemplate.tsx
|
|
22032
|
-
var
|
|
22082
|
+
var import_react85 = require("react");
|
|
22033
22083
|
var import_dayjs11 = __toESM(require("dayjs"));
|
|
22034
22084
|
var import_antd42 = require("antd");
|
|
22035
22085
|
|
|
22036
22086
|
// packages/sdk/src/components/hooks/useProcessDetail.ts
|
|
22037
|
-
var
|
|
22087
|
+
var import_react82 = require("react");
|
|
22038
22088
|
|
|
22039
22089
|
// packages/sdk/src/components/hooks/useFieldPermission.ts
|
|
22040
|
-
var
|
|
22090
|
+
var import_react81 = require("react");
|
|
22041
22091
|
var normalizeBehavior = (value) => {
|
|
22042
22092
|
if (value === "EDITABLE") return "NORMAL";
|
|
22043
22093
|
if (value === "READ_ONLY") return "READONLY";
|
|
@@ -22070,7 +22120,7 @@ var normalizeFlowConfig = (config) => {
|
|
|
22070
22120
|
};
|
|
22071
22121
|
function useFieldPermission(options) {
|
|
22072
22122
|
const { viewPermissions, processDefinition, currentTask, isApprover, mode } = options;
|
|
22073
|
-
const computeBehaviors = (0,
|
|
22123
|
+
const computeBehaviors = (0, import_react81.useCallback)(() => {
|
|
22074
22124
|
const behaviors = {};
|
|
22075
22125
|
if (!currentTask && viewPermissions) {
|
|
22076
22126
|
return normalizeFieldBehaviors(viewPermissions, mode);
|
|
@@ -22115,7 +22165,7 @@ function useFieldPermission(options) {
|
|
|
22115
22165
|
}
|
|
22116
22166
|
return behaviors;
|
|
22117
22167
|
}, [viewPermissions, processDefinition, currentTask, isApprover, mode]);
|
|
22118
|
-
const fieldBehaviors = (0,
|
|
22168
|
+
const fieldBehaviors = (0, import_react81.useMemo)(() => computeBehaviors(), [computeBehaviors]);
|
|
22119
22169
|
return { fieldBehaviors, computeBehaviors };
|
|
22120
22170
|
}
|
|
22121
22171
|
|
|
@@ -22147,29 +22197,29 @@ function useProcessDetail(options) {
|
|
|
22147
22197
|
const { formUuid, appType, formInstanceId, fieldIds } = options;
|
|
22148
22198
|
const { api } = useFormContext();
|
|
22149
22199
|
const request = api.request;
|
|
22150
|
-
const [loading, setLoading] = (0,
|
|
22151
|
-
const [mode, setMode] = (0,
|
|
22152
|
-
const [processInfo, setProcessInfo] = (0,
|
|
22153
|
-
const [progressList, setProgressList] = (0,
|
|
22154
|
-
const [formData, setFormData] = (0,
|
|
22155
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
22156
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
22157
|
-
const [loadError, setLoadError] = (0,
|
|
22158
|
-
const [isApprover, setIsApprover] = (0,
|
|
22159
|
-
const [canWithdraw, setCanWithdraw] = (0,
|
|
22160
|
-
const [approvalTasks, setApprovalTasks] = (0,
|
|
22161
|
-
const [permissions, setPermissions] = (0,
|
|
22162
|
-
const [processDefinition, setProcessDefinition] = (0,
|
|
22163
|
-
const [dataVersion, setDataVersion] = (0,
|
|
22164
|
-
const mountedRef = (0,
|
|
22200
|
+
const [loading, setLoading] = (0, import_react82.useState)(true);
|
|
22201
|
+
const [mode, setMode] = (0, import_react82.useState)("readonly");
|
|
22202
|
+
const [processInfo, setProcessInfo] = (0, import_react82.useState)(null);
|
|
22203
|
+
const [progressList, setProgressList] = (0, import_react82.useState)([]);
|
|
22204
|
+
const [formData, setFormData] = (0, import_react82.useState)(null);
|
|
22205
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react82.useState)(null);
|
|
22206
|
+
const [accessDenied, setAccessDenied] = (0, import_react82.useState)(false);
|
|
22207
|
+
const [loadError, setLoadError] = (0, import_react82.useState)(null);
|
|
22208
|
+
const [isApprover, setIsApprover] = (0, import_react82.useState)(false);
|
|
22209
|
+
const [canWithdraw, setCanWithdraw] = (0, import_react82.useState)(false);
|
|
22210
|
+
const [approvalTasks, setApprovalTasks] = (0, import_react82.useState)([]);
|
|
22211
|
+
const [permissions, setPermissions] = (0, import_react82.useState)(null);
|
|
22212
|
+
const [processDefinition, setProcessDefinition] = (0, import_react82.useState)(null);
|
|
22213
|
+
const [dataVersion, setDataVersion] = (0, import_react82.useState)(0);
|
|
22214
|
+
const mountedRef = (0, import_react82.useRef)(true);
|
|
22165
22215
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
22166
|
-
(0,
|
|
22216
|
+
(0, import_react82.useEffect)(() => {
|
|
22167
22217
|
mountedRef.current = true;
|
|
22168
22218
|
return () => {
|
|
22169
22219
|
mountedRef.current = false;
|
|
22170
22220
|
};
|
|
22171
22221
|
}, []);
|
|
22172
|
-
const currentTask = (0,
|
|
22222
|
+
const currentTask = (0, import_react82.useMemo)(
|
|
22173
22223
|
() => mergeCurrentTask(processInfo?.currentTask, approvalTasks[0]),
|
|
22174
22224
|
[processInfo?.currentTask, approvalTasks]
|
|
22175
22225
|
);
|
|
@@ -22189,7 +22239,7 @@ function useProcessDetail(options) {
|
|
|
22189
22239
|
isApprover: isProcessFinal ? false : isApprover,
|
|
22190
22240
|
mode
|
|
22191
22241
|
});
|
|
22192
|
-
const activeActions = (0,
|
|
22242
|
+
const activeActions = (0, import_react82.useMemo)(() => {
|
|
22193
22243
|
if (!isApprover || isProcessFinal) return [];
|
|
22194
22244
|
const actions = currentTask?.actions && currentTask.actions.length > 0 ? [...currentTask.actions] : [...DEFAULT_APPROVAL_ACTIONS];
|
|
22195
22245
|
if (canWithdraw && !actions.some((action) => action.action === "withdraw")) {
|
|
@@ -22197,7 +22247,7 @@ function useProcessDetail(options) {
|
|
|
22197
22247
|
}
|
|
22198
22248
|
return actions;
|
|
22199
22249
|
}, [isApprover, isProcessFinal, currentTask?.actions, canWithdraw]);
|
|
22200
|
-
const loadData = (0,
|
|
22250
|
+
const loadData = (0, import_react82.useCallback)(async () => {
|
|
22201
22251
|
if (!mountedRef.current) return;
|
|
22202
22252
|
setLoading(true);
|
|
22203
22253
|
setAccessDenied(false);
|
|
@@ -22279,24 +22329,24 @@ function useProcessDetail(options) {
|
|
|
22279
22329
|
}
|
|
22280
22330
|
}
|
|
22281
22331
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
22282
|
-
(0,
|
|
22332
|
+
(0, import_react82.useEffect)(() => {
|
|
22283
22333
|
loadData();
|
|
22284
22334
|
}, [loadData]);
|
|
22285
|
-
const switchToEdit = (0,
|
|
22335
|
+
const switchToEdit = (0, import_react82.useCallback)(() => {
|
|
22286
22336
|
setMode("edit");
|
|
22287
22337
|
void loadData();
|
|
22288
22338
|
}, [loadData]);
|
|
22289
|
-
const switchToReadonly = (0,
|
|
22339
|
+
const switchToReadonly = (0, import_react82.useCallback)(() => {
|
|
22290
22340
|
setMode("readonly");
|
|
22291
22341
|
}, []);
|
|
22292
|
-
const refreshDetail = (0,
|
|
22342
|
+
const refreshDetail = (0, import_react82.useCallback)(async () => {
|
|
22293
22343
|
setMode("readonly");
|
|
22294
22344
|
await loadData();
|
|
22295
22345
|
}, [loadData]);
|
|
22296
|
-
const refreshProgress = (0,
|
|
22346
|
+
const refreshProgress = (0, import_react82.useCallback)(async () => {
|
|
22297
22347
|
await refreshDetail();
|
|
22298
22348
|
}, [refreshDetail]);
|
|
22299
|
-
const saveChanges = (0,
|
|
22349
|
+
const saveChanges = (0, import_react82.useCallback)(
|
|
22300
22350
|
async (values) => {
|
|
22301
22351
|
try {
|
|
22302
22352
|
await api.updateFormData({
|
|
@@ -22315,7 +22365,7 @@ function useProcessDetail(options) {
|
|
|
22315
22365
|
},
|
|
22316
22366
|
[api, formInstanceId, formUuid, appType, loadData]
|
|
22317
22367
|
);
|
|
22318
|
-
const deleteInstance = (0,
|
|
22368
|
+
const deleteInstance = (0, import_react82.useCallback)(async () => {
|
|
22319
22369
|
try {
|
|
22320
22370
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
22321
22371
|
return true;
|
|
@@ -22356,29 +22406,29 @@ function useProcessDetail(options) {
|
|
|
22356
22406
|
}
|
|
22357
22407
|
|
|
22358
22408
|
// packages/sdk/src/components/hooks/useApprovalActions.ts
|
|
22359
|
-
var
|
|
22409
|
+
var import_react83 = require("react");
|
|
22360
22410
|
function useApprovalActions(options) {
|
|
22361
22411
|
const { formInstanceId, formUuid, appType, currentTaskId, onActionComplete, getFormValues } = options;
|
|
22362
22412
|
const { api } = useFormContext();
|
|
22363
22413
|
const request = api.request;
|
|
22364
|
-
const [isLoading, setIsLoading] = (0,
|
|
22365
|
-
const [currentAction, setCurrentAction] = (0,
|
|
22366
|
-
const [returnableNodes, setReturnableNodes] = (0,
|
|
22367
|
-
const [returnPolicy, setReturnPolicy] = (0,
|
|
22368
|
-
const mountedRef = (0,
|
|
22369
|
-
(0,
|
|
22414
|
+
const [isLoading, setIsLoading] = (0, import_react83.useState)(false);
|
|
22415
|
+
const [currentAction, setCurrentAction] = (0, import_react83.useState)(null);
|
|
22416
|
+
const [returnableNodes, setReturnableNodes] = (0, import_react83.useState)([]);
|
|
22417
|
+
const [returnPolicy, setReturnPolicy] = (0, import_react83.useState)(null);
|
|
22418
|
+
const mountedRef = (0, import_react83.useRef)(true);
|
|
22419
|
+
(0, import_react83.useEffect)(() => {
|
|
22370
22420
|
mountedRef.current = true;
|
|
22371
22421
|
return () => {
|
|
22372
22422
|
mountedRef.current = false;
|
|
22373
22423
|
};
|
|
22374
22424
|
}, []);
|
|
22375
|
-
const resetLoading = (0,
|
|
22425
|
+
const resetLoading = (0, import_react83.useCallback)(() => {
|
|
22376
22426
|
if (mountedRef.current) {
|
|
22377
22427
|
setIsLoading(false);
|
|
22378
22428
|
setCurrentAction(null);
|
|
22379
22429
|
}
|
|
22380
22430
|
}, []);
|
|
22381
|
-
const approve = (0,
|
|
22431
|
+
const approve = (0, import_react83.useCallback)(
|
|
22382
22432
|
async (comments) => {
|
|
22383
22433
|
setIsLoading(true);
|
|
22384
22434
|
setCurrentAction("approve");
|
|
@@ -22403,7 +22453,7 @@ function useApprovalActions(options) {
|
|
|
22403
22453
|
},
|
|
22404
22454
|
[request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
|
|
22405
22455
|
);
|
|
22406
|
-
const reject = (0,
|
|
22456
|
+
const reject = (0, import_react83.useCallback)(
|
|
22407
22457
|
async (comments) => {
|
|
22408
22458
|
setIsLoading(true);
|
|
22409
22459
|
setCurrentAction("reject");
|
|
@@ -22424,7 +22474,7 @@ function useApprovalActions(options) {
|
|
|
22424
22474
|
},
|
|
22425
22475
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
22426
22476
|
);
|
|
22427
|
-
const transfer = (0,
|
|
22477
|
+
const transfer = (0, import_react83.useCallback)(
|
|
22428
22478
|
async (userId, reason) => {
|
|
22429
22479
|
if (!currentTaskId) {
|
|
22430
22480
|
console.error("[useApprovalActions] transfer failed: no currentTaskId");
|
|
@@ -22449,7 +22499,7 @@ function useApprovalActions(options) {
|
|
|
22449
22499
|
},
|
|
22450
22500
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22451
22501
|
);
|
|
22452
|
-
const returnTo = (0,
|
|
22502
|
+
const returnTo = (0, import_react83.useCallback)(
|
|
22453
22503
|
async (nodeId, reason) => {
|
|
22454
22504
|
if (!currentTaskId) {
|
|
22455
22505
|
console.error("[useApprovalActions] returnTo failed: no currentTaskId");
|
|
@@ -22474,7 +22524,7 @@ function useApprovalActions(options) {
|
|
|
22474
22524
|
},
|
|
22475
22525
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22476
22526
|
);
|
|
22477
|
-
const withdraw = (0,
|
|
22527
|
+
const withdraw = (0, import_react83.useCallback)(
|
|
22478
22528
|
async (reason) => {
|
|
22479
22529
|
setIsLoading(true);
|
|
22480
22530
|
setCurrentAction("withdraw");
|
|
@@ -22494,7 +22544,7 @@ function useApprovalActions(options) {
|
|
|
22494
22544
|
},
|
|
22495
22545
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
22496
22546
|
);
|
|
22497
|
-
const save = (0,
|
|
22547
|
+
const save = (0, import_react83.useCallback)(async () => {
|
|
22498
22548
|
setIsLoading(true);
|
|
22499
22549
|
setCurrentAction("save");
|
|
22500
22550
|
try {
|
|
@@ -22514,7 +22564,7 @@ function useApprovalActions(options) {
|
|
|
22514
22564
|
return false;
|
|
22515
22565
|
}
|
|
22516
22566
|
}, [request, formInstanceId, formUuid, appType, getFormValues, onActionComplete, resetLoading]);
|
|
22517
|
-
const resubmit = (0,
|
|
22567
|
+
const resubmit = (0, import_react83.useCallback)(
|
|
22518
22568
|
async (comments, selectedApprovers) => {
|
|
22519
22569
|
if (!currentTaskId) {
|
|
22520
22570
|
console.error("[useApprovalActions] resubmit failed: no currentTaskId");
|
|
@@ -22544,7 +22594,7 @@ function useApprovalActions(options) {
|
|
|
22544
22594
|
},
|
|
22545
22595
|
[request, currentTaskId, formUuid, appType, getFormValues, onActionComplete, resetLoading]
|
|
22546
22596
|
);
|
|
22547
|
-
const callbackTask = (0,
|
|
22597
|
+
const callbackTask = (0, import_react83.useCallback)(
|
|
22548
22598
|
async (payload) => {
|
|
22549
22599
|
if (!currentTaskId) {
|
|
22550
22600
|
console.error("[useApprovalActions] callbackTask failed: no currentTaskId");
|
|
@@ -22568,7 +22618,7 @@ function useApprovalActions(options) {
|
|
|
22568
22618
|
},
|
|
22569
22619
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22570
22620
|
);
|
|
22571
|
-
const loadReturnableNodes = (0,
|
|
22621
|
+
const loadReturnableNodes = (0, import_react83.useCallback)(async () => {
|
|
22572
22622
|
if (!currentTaskId) return [];
|
|
22573
22623
|
try {
|
|
22574
22624
|
const result = await getReturnableNodeResult(request, currentTaskId);
|
|
@@ -22604,7 +22654,7 @@ function useApprovalActions(options) {
|
|
|
22604
22654
|
}
|
|
22605
22655
|
|
|
22606
22656
|
// packages/sdk/src/components/modules/ApprovalActionBar.tsx
|
|
22607
|
-
var
|
|
22657
|
+
var import_react84 = __toESM(require("react"));
|
|
22608
22658
|
var import_antd41 = require("antd");
|
|
22609
22659
|
var import_icons19 = require("@ant-design/icons");
|
|
22610
22660
|
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
@@ -22657,12 +22707,12 @@ function DefaultTransferSelector({
|
|
|
22657
22707
|
value,
|
|
22658
22708
|
onChange
|
|
22659
22709
|
}) {
|
|
22660
|
-
const formContext =
|
|
22710
|
+
const formContext = import_react84.default.useContext(FormContext);
|
|
22661
22711
|
const { isMobile } = useDeviceDetect();
|
|
22662
|
-
const fallbackApi = (0,
|
|
22712
|
+
const fallbackApi = (0, import_react84.useMemo)(() => createFormRuntimeApi(), []);
|
|
22663
22713
|
const api = formContext?.api ?? fallbackApi;
|
|
22664
|
-
const [open, setOpen] = (0,
|
|
22665
|
-
const [selectedUsers, setSelectedUsers] = (0,
|
|
22714
|
+
const [open, setOpen] = (0, import_react84.useState)(false);
|
|
22715
|
+
const [selectedUsers, setSelectedUsers] = (0, import_react84.useState)([]);
|
|
22666
22716
|
const selectedLabel = selectedUsers[0] ? getUserName(selectedUsers[0]) : value;
|
|
22667
22717
|
return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
|
|
22668
22718
|
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
@@ -22717,10 +22767,10 @@ var ApprovalActionBar = ({
|
|
|
22717
22767
|
maxWidth
|
|
22718
22768
|
}) => {
|
|
22719
22769
|
const [form] = import_antd41.Form.useForm();
|
|
22720
|
-
const [modalAction, setModalAction] = (0,
|
|
22721
|
-
const [activeAction, setActiveAction] = (0,
|
|
22722
|
-
const [loading, setLoading] = (0,
|
|
22723
|
-
const visibleActions = (0,
|
|
22770
|
+
const [modalAction, setModalAction] = (0, import_react84.useState)(null);
|
|
22771
|
+
const [activeAction, setActiveAction] = (0, import_react84.useState)(null);
|
|
22772
|
+
const [loading, setLoading] = (0, import_react84.useState)(false);
|
|
22773
|
+
const visibleActions = (0, import_react84.useMemo)(
|
|
22724
22774
|
() => actions.filter((action) => !action.hidden).sort((a, b) => (actionPriority2[a.action] ?? 50) - (actionPriority2[b.action] ?? 50)),
|
|
22725
22775
|
[actions]
|
|
22726
22776
|
);
|
|
@@ -22987,17 +23037,17 @@ var InnerProcessContent = ({
|
|
|
22987
23037
|
onDelete,
|
|
22988
23038
|
inDrawer = false
|
|
22989
23039
|
}) => {
|
|
22990
|
-
const formDataRef = (0,
|
|
22991
|
-
const validateRef = (0,
|
|
23040
|
+
const formDataRef = (0, import_react85.useRef)(void 0);
|
|
23041
|
+
const validateRef = (0, import_react85.useRef)(void 0);
|
|
22992
23042
|
const [withdrawForm] = import_antd42.Form.useForm();
|
|
22993
|
-
const [withdrawOpen, setWithdrawOpen] = (0,
|
|
22994
|
-
const [withdrawLoading, setWithdrawLoading] = (0,
|
|
22995
|
-
const [saveLoading, setSaveLoading] = (0,
|
|
22996
|
-
const [deleteLoading, setDeleteLoading] = (0,
|
|
22997
|
-
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0,
|
|
22998
|
-
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0,
|
|
22999
|
-
const [pendingResubmitComments, setPendingResubmitComments] = (0,
|
|
23000
|
-
const fieldIds = (0,
|
|
23043
|
+
const [withdrawOpen, setWithdrawOpen] = (0, import_react85.useState)(false);
|
|
23044
|
+
const [withdrawLoading, setWithdrawLoading] = (0, import_react85.useState)(false);
|
|
23045
|
+
const [saveLoading, setSaveLoading] = (0, import_react85.useState)(false);
|
|
23046
|
+
const [deleteLoading, setDeleteLoading] = (0, import_react85.useState)(false);
|
|
23047
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react85.useState)(false);
|
|
23048
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react85.useState)([]);
|
|
23049
|
+
const [pendingResubmitComments, setPendingResubmitComments] = (0, import_react85.useState)();
|
|
23050
|
+
const fieldIds = (0, import_react85.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
23001
23051
|
const { api } = useFormContext();
|
|
23002
23052
|
const {
|
|
23003
23053
|
loading,
|
|
@@ -23065,45 +23115,45 @@ var InnerProcessContent = ({
|
|
|
23065
23115
|
formInstanceId,
|
|
23066
23116
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
23067
23117
|
});
|
|
23068
|
-
const validateForm = (0,
|
|
23118
|
+
const validateForm = (0, import_react85.useCallback)(async () => {
|
|
23069
23119
|
return validateRef.current ? validateAndNotify(validateRef.current) : true;
|
|
23070
23120
|
}, []);
|
|
23071
|
-
const handleApprove = (0,
|
|
23121
|
+
const handleApprove = (0, import_react85.useCallback)(
|
|
23072
23122
|
async (comments) => {
|
|
23073
23123
|
if (!await validateForm()) return;
|
|
23074
23124
|
await approve(comments);
|
|
23075
23125
|
},
|
|
23076
23126
|
[approve, validateForm]
|
|
23077
23127
|
);
|
|
23078
|
-
const handleReject = (0,
|
|
23128
|
+
const handleReject = (0, import_react85.useCallback)(
|
|
23079
23129
|
async (comments) => {
|
|
23080
23130
|
await reject(comments);
|
|
23081
23131
|
},
|
|
23082
23132
|
[reject]
|
|
23083
23133
|
);
|
|
23084
|
-
const handleTransfer = (0,
|
|
23134
|
+
const handleTransfer = (0, import_react85.useCallback)(
|
|
23085
23135
|
async (userId, reason) => {
|
|
23086
23136
|
await transfer(userId, reason);
|
|
23087
23137
|
},
|
|
23088
23138
|
[transfer]
|
|
23089
23139
|
);
|
|
23090
|
-
const handleReturn = (0,
|
|
23140
|
+
const handleReturn = (0, import_react85.useCallback)(
|
|
23091
23141
|
async (nodeId, reason) => {
|
|
23092
23142
|
await returnTo(nodeId, reason);
|
|
23093
23143
|
},
|
|
23094
23144
|
[returnTo]
|
|
23095
23145
|
);
|
|
23096
|
-
const handleWithdraw = (0,
|
|
23146
|
+
const handleWithdraw = (0, import_react85.useCallback)(
|
|
23097
23147
|
async (reason) => {
|
|
23098
23148
|
await withdraw(reason);
|
|
23099
23149
|
},
|
|
23100
23150
|
[withdraw]
|
|
23101
23151
|
);
|
|
23102
|
-
const handleSave = (0,
|
|
23152
|
+
const handleSave = (0, import_react85.useCallback)(async () => {
|
|
23103
23153
|
if (!await validateForm()) return;
|
|
23104
23154
|
await save();
|
|
23105
23155
|
}, [save, validateForm]);
|
|
23106
|
-
const handleResubmit = (0,
|
|
23156
|
+
const handleResubmit = (0, import_react85.useCallback)(
|
|
23107
23157
|
async (comments) => {
|
|
23108
23158
|
if (!await validateForm()) return;
|
|
23109
23159
|
const values = formDataRef.current?.() ?? formData ?? {};
|
|
@@ -23137,7 +23187,7 @@ var InnerProcessContent = ({
|
|
|
23137
23187
|
},
|
|
23138
23188
|
[api.request, appType, currentTaskId, formData, formUuid, resubmit, validateForm]
|
|
23139
23189
|
);
|
|
23140
|
-
const handleInitiatorApproverConfirm = (0,
|
|
23190
|
+
const handleInitiatorApproverConfirm = (0, import_react85.useCallback)(
|
|
23141
23191
|
async (selectedUsersByNode) => {
|
|
23142
23192
|
const selectedApprovers = normalizeSelectedApprovers2(selectedUsersByNode);
|
|
23143
23193
|
setInitiatorApproverOpen(false);
|
|
@@ -23148,15 +23198,15 @@ var InnerProcessContent = ({
|
|
|
23148
23198
|
},
|
|
23149
23199
|
[pendingResubmitComments, resubmit]
|
|
23150
23200
|
);
|
|
23151
|
-
const handleInitiatorApproverCancel = (0,
|
|
23201
|
+
const handleInitiatorApproverCancel = (0, import_react85.useCallback)(() => {
|
|
23152
23202
|
setInitiatorApproverOpen(false);
|
|
23153
23203
|
setInitiatorApproverRequirements([]);
|
|
23154
23204
|
setPendingResubmitComments(void 0);
|
|
23155
23205
|
}, []);
|
|
23156
|
-
const handleCallback = (0,
|
|
23206
|
+
const handleCallback = (0, import_react85.useCallback)(async () => {
|
|
23157
23207
|
await callbackTask();
|
|
23158
23208
|
}, [callbackTask]);
|
|
23159
|
-
const handleCompletedSave = (0,
|
|
23209
|
+
const handleCompletedSave = (0, import_react85.useCallback)(async () => {
|
|
23160
23210
|
if (!await validateForm()) return;
|
|
23161
23211
|
const values = formDataRef.current?.() ?? formData;
|
|
23162
23212
|
if (!values) return;
|
|
@@ -23170,7 +23220,7 @@ var InnerProcessContent = ({
|
|
|
23170
23220
|
setSaveLoading(false);
|
|
23171
23221
|
}
|
|
23172
23222
|
}, [formData, onSave, saveChanges, validateForm]);
|
|
23173
|
-
const handleCompletedDelete = (0,
|
|
23223
|
+
const handleCompletedDelete = (0, import_react85.useCallback)(async () => {
|
|
23174
23224
|
setDeleteLoading(true);
|
|
23175
23225
|
try {
|
|
23176
23226
|
const success = await deleteInstance();
|
|
@@ -23181,7 +23231,7 @@ var InnerProcessContent = ({
|
|
|
23181
23231
|
setDeleteLoading(false);
|
|
23182
23232
|
}
|
|
23183
23233
|
}, [deleteInstance, onDelete]);
|
|
23184
|
-
const handleFooterWithdraw = (0,
|
|
23234
|
+
const handleFooterWithdraw = (0, import_react85.useCallback)(async () => {
|
|
23185
23235
|
const values = await withdrawForm.validateFields();
|
|
23186
23236
|
setWithdrawLoading(true);
|
|
23187
23237
|
try {
|
|
@@ -23192,11 +23242,11 @@ var InnerProcessContent = ({
|
|
|
23192
23242
|
setWithdrawLoading(false);
|
|
23193
23243
|
}
|
|
23194
23244
|
}, [handleWithdraw, withdrawForm]);
|
|
23195
|
-
const handleFooterWithdrawCancel = (0,
|
|
23245
|
+
const handleFooterWithdrawCancel = (0, import_react85.useCallback)(() => {
|
|
23196
23246
|
setWithdrawOpen(false);
|
|
23197
23247
|
withdrawForm.resetFields();
|
|
23198
23248
|
}, [withdrawForm]);
|
|
23199
|
-
const bottomActions = (0,
|
|
23249
|
+
const bottomActions = (0, import_react85.useMemo)(() => {
|
|
23200
23250
|
if (isApprover && !isOriginatorReturn && activeActions.length > 0) return [];
|
|
23201
23251
|
if (isProcessCompleted) {
|
|
23202
23252
|
if (mode === "readonly") {
|
|
@@ -23546,7 +23596,7 @@ var StandardFormPage = ({
|
|
|
23546
23596
|
const formType = normalizeStandardFormType(
|
|
23547
23597
|
schema.template?.formType || (resolvedMode === "process" ? "process" : "form")
|
|
23548
23598
|
);
|
|
23549
|
-
const submitApi = (0,
|
|
23599
|
+
const submitApi = (0, import_react86.useMemo)(() => {
|
|
23550
23600
|
if (!onSubmit) return void 0;
|
|
23551
23601
|
return {
|
|
23552
23602
|
submitFormData: async (payload) => onSubmit(
|
|
@@ -23560,7 +23610,7 @@ var StandardFormPage = ({
|
|
|
23560
23610
|
startProcessFromExistingInstance: async (payload) => onSubmit(payload)
|
|
23561
23611
|
};
|
|
23562
23612
|
}, [formType, onSubmit]);
|
|
23563
|
-
const api = (0,
|
|
23613
|
+
const api = (0, import_react86.useMemo)(() => {
|
|
23564
23614
|
if (!externalApi && !submitApi) return void 0;
|
|
23565
23615
|
return {
|
|
23566
23616
|
...externalApi ?? {},
|
|
@@ -24623,10 +24673,10 @@ function AsyncEntityFilterSelect({
|
|
|
24623
24673
|
value,
|
|
24624
24674
|
onChange
|
|
24625
24675
|
}) {
|
|
24626
|
-
const [options, setOptions] = (0,
|
|
24627
|
-
const [fetching, setFetching] = (0,
|
|
24676
|
+
const [options, setOptions] = (0, import_react87.useState)([]);
|
|
24677
|
+
const [fetching, setFetching] = (0, import_react87.useState)(false);
|
|
24628
24678
|
const multiple = normalizeOperator(operator) === "IN";
|
|
24629
|
-
const loadOptions = (0,
|
|
24679
|
+
const loadOptions = (0, import_react87.useCallback)(
|
|
24630
24680
|
async (keyword = "") => {
|
|
24631
24681
|
setFetching(true);
|
|
24632
24682
|
try {
|
|
@@ -24668,7 +24718,7 @@ function AsyncEntityFilterSelect({
|
|
|
24668
24718
|
},
|
|
24669
24719
|
[api, entityType]
|
|
24670
24720
|
);
|
|
24671
|
-
(0,
|
|
24721
|
+
(0, import_react87.useEffect)(() => {
|
|
24672
24722
|
void loadOptions();
|
|
24673
24723
|
}, [loadOptions]);
|
|
24674
24724
|
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
@@ -24979,7 +25029,7 @@ function ResizableColumnTitle({
|
|
|
24979
25029
|
onResize,
|
|
24980
25030
|
onResizeEnd
|
|
24981
25031
|
}) {
|
|
24982
|
-
const dragRef = (0,
|
|
25032
|
+
const dragRef = (0, import_react87.useRef)({ startX: 0, startWidth: width, latestWidth: width });
|
|
24983
25033
|
const handleMouseDown = (event) => {
|
|
24984
25034
|
event.preventDefault();
|
|
24985
25035
|
event.stopPropagation();
|
|
@@ -25048,74 +25098,74 @@ var DataManagementList = ({
|
|
|
25048
25098
|
permissionMode = "auto",
|
|
25049
25099
|
actionOverrides
|
|
25050
25100
|
}) => {
|
|
25051
|
-
const rootRef = (0,
|
|
25052
|
-
const api = (0,
|
|
25101
|
+
const rootRef = (0, import_react87.useRef)(null);
|
|
25102
|
+
const api = (0, import_react87.useMemo)(() => {
|
|
25053
25103
|
if (typeof requestOverride === "function") {
|
|
25054
25104
|
return createFormRuntimeApi({ request: requestOverride });
|
|
25055
25105
|
}
|
|
25056
25106
|
return createFormRuntimeApi(requestOverride);
|
|
25057
25107
|
}, [requestOverride]);
|
|
25058
|
-
const [fields, setFields] = (0,
|
|
25059
|
-
const [runtimeFormSchema, setRuntimeFormSchema] = (0,
|
|
25060
|
-
const [config, setConfig] = (0,
|
|
25061
|
-
const [formType, setFormType] = (0,
|
|
25062
|
-
const [showFields, setShowFields] = (0,
|
|
25063
|
-
const [lockFieldIds, setLockFieldIds] = (0,
|
|
25064
|
-
const [widths, setWidths] = (0,
|
|
25065
|
-
const widthsRef = (0,
|
|
25066
|
-
const [sort, setSort] = (0,
|
|
25067
|
-
const [density, setDensity] = (0,
|
|
25068
|
-
const [detailOpenMode, setDetailOpenMode] = (0,
|
|
25069
|
-
const [searchKeyWord, setSearchKeyWord] = (0,
|
|
25070
|
-
const [filterGroup, setFilterGroup] = (0,
|
|
25071
|
-
const [dataSource, setDataSource] = (0,
|
|
25072
|
-
const [total, setTotal] = (0,
|
|
25073
|
-
const [current, setCurrent] = (0,
|
|
25074
|
-
const [pageSize, setPageSize] = (0,
|
|
25075
|
-
const [loading, setLoading] = (0,
|
|
25076
|
-
const [schemaLoading, setSchemaLoading] = (0,
|
|
25077
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
25078
|
-
const [filterOpen, setFilterOpen] = (0,
|
|
25079
|
-
const [columnOpen, setColumnOpen] = (0,
|
|
25080
|
-
const [exportOpen, setExportOpen] = (0,
|
|
25081
|
-
const [exportScope, setExportScope] = (0,
|
|
25082
|
-
const [exportFields, setExportFields] = (0,
|
|
25083
|
-
const [exporting, setExporting] = (0,
|
|
25084
|
-
const [importOpen, setImportOpen] = (0,
|
|
25085
|
-
const [importPreview, setImportPreview] = (0,
|
|
25086
|
-
const [importBase64, setImportBase64] = (0,
|
|
25087
|
-
const [templateDownloading, setTemplateDownloading] = (0,
|
|
25088
|
-
const [recordsOpen, setRecordsOpen] = (0,
|
|
25089
|
-
const [recordTab, setRecordTab] = (0,
|
|
25090
|
-
const [transferRecords, setTransferRecords] = (0,
|
|
25091
|
-
const [batchApprovalOpen, setBatchApprovalOpen] = (0,
|
|
25092
|
-
const [batchApprovalAction, setBatchApprovalAction] = (0,
|
|
25108
|
+
const [fields, setFields] = (0, import_react87.useState)([]);
|
|
25109
|
+
const [runtimeFormSchema, setRuntimeFormSchema] = (0, import_react87.useState)(null);
|
|
25110
|
+
const [config, setConfig] = (0, import_react87.useState)({});
|
|
25111
|
+
const [formType, setFormType] = (0, import_react87.useState)("form");
|
|
25112
|
+
const [showFields, setShowFields] = (0, import_react87.useState)([]);
|
|
25113
|
+
const [lockFieldIds, setLockFieldIds] = (0, import_react87.useState)([]);
|
|
25114
|
+
const [widths, setWidths] = (0, import_react87.useState)({});
|
|
25115
|
+
const widthsRef = (0, import_react87.useRef)({});
|
|
25116
|
+
const [sort, setSort] = (0, import_react87.useState)([]);
|
|
25117
|
+
const [density, setDensity] = (0, import_react87.useState)("middle");
|
|
25118
|
+
const [detailOpenMode, setDetailOpenMode] = (0, import_react87.useState)("drawer");
|
|
25119
|
+
const [searchKeyWord, setSearchKeyWord] = (0, import_react87.useState)("");
|
|
25120
|
+
const [filterGroup, setFilterGroup] = (0, import_react87.useState)(createGroup);
|
|
25121
|
+
const [dataSource, setDataSource] = (0, import_react87.useState)([]);
|
|
25122
|
+
const [total, setTotal] = (0, import_react87.useState)(0);
|
|
25123
|
+
const [current, setCurrent] = (0, import_react87.useState)(1);
|
|
25124
|
+
const [pageSize, setPageSize] = (0, import_react87.useState)(10);
|
|
25125
|
+
const [loading, setLoading] = (0, import_react87.useState)(false);
|
|
25126
|
+
const [schemaLoading, setSchemaLoading] = (0, import_react87.useState)(true);
|
|
25127
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react87.useState)([]);
|
|
25128
|
+
const [filterOpen, setFilterOpen] = (0, import_react87.useState)(false);
|
|
25129
|
+
const [columnOpen, setColumnOpen] = (0, import_react87.useState)(false);
|
|
25130
|
+
const [exportOpen, setExportOpen] = (0, import_react87.useState)(false);
|
|
25131
|
+
const [exportScope, setExportScope] = (0, import_react87.useState)("all");
|
|
25132
|
+
const [exportFields, setExportFields] = (0, import_react87.useState)([]);
|
|
25133
|
+
const [exporting, setExporting] = (0, import_react87.useState)(false);
|
|
25134
|
+
const [importOpen, setImportOpen] = (0, import_react87.useState)(false);
|
|
25135
|
+
const [importPreview, setImportPreview] = (0, import_react87.useState)([]);
|
|
25136
|
+
const [importBase64, setImportBase64] = (0, import_react87.useState)("");
|
|
25137
|
+
const [templateDownloading, setTemplateDownloading] = (0, import_react87.useState)(false);
|
|
25138
|
+
const [recordsOpen, setRecordsOpen] = (0, import_react87.useState)(false);
|
|
25139
|
+
const [recordTab, setRecordTab] = (0, import_react87.useState)("export");
|
|
25140
|
+
const [transferRecords, setTransferRecords] = (0, import_react87.useState)([]);
|
|
25141
|
+
const [batchApprovalOpen, setBatchApprovalOpen] = (0, import_react87.useState)(false);
|
|
25142
|
+
const [batchApprovalAction, setBatchApprovalAction] = (0, import_react87.useState)(
|
|
25093
25143
|
"approved"
|
|
25094
25144
|
);
|
|
25095
|
-
const [batchApprovalComments, setBatchApprovalComments] = (0,
|
|
25096
|
-
const [batchApproving, setBatchApproving] = (0,
|
|
25097
|
-
const [activeRecord, setActiveRecord] = (0,
|
|
25098
|
-
const [detailOpen, setDetailOpen] = (0,
|
|
25099
|
-
const [submitOpen, setSubmitOpen] = (0,
|
|
25100
|
-
const [actionSummary, setActionSummary] = (0,
|
|
25101
|
-
const [permissionLoading, setPermissionLoading] = (0,
|
|
25102
|
-
const [permissionError, setPermissionError] = (0,
|
|
25103
|
-
const fetchStateRef = (0,
|
|
25145
|
+
const [batchApprovalComments, setBatchApprovalComments] = (0, import_react87.useState)("");
|
|
25146
|
+
const [batchApproving, setBatchApproving] = (0, import_react87.useState)(false);
|
|
25147
|
+
const [activeRecord, setActiveRecord] = (0, import_react87.useState)(null);
|
|
25148
|
+
const [detailOpen, setDetailOpen] = (0, import_react87.useState)(false);
|
|
25149
|
+
const [submitOpen, setSubmitOpen] = (0, import_react87.useState)(false);
|
|
25150
|
+
const [actionSummary, setActionSummary] = (0, import_react87.useState)(null);
|
|
25151
|
+
const [permissionLoading, setPermissionLoading] = (0, import_react87.useState)(permissionMode === "auto");
|
|
25152
|
+
const [permissionError, setPermissionError] = (0, import_react87.useState)(null);
|
|
25153
|
+
const fetchStateRef = (0, import_react87.useRef)({});
|
|
25104
25154
|
const isProcessForm = isProcessFormType(formType);
|
|
25105
25155
|
const request = api.request;
|
|
25106
|
-
const getPopupContainer = (0,
|
|
25156
|
+
const getPopupContainer = (0, import_react87.useCallback)(
|
|
25107
25157
|
(triggerNode) => resolveDataManagementPopupContainer(rootRef.current, triggerNode),
|
|
25108
25158
|
[]
|
|
25109
25159
|
);
|
|
25110
|
-
const getOverlayContainer = (0,
|
|
25160
|
+
const getOverlayContainer = (0, import_react87.useCallback)(
|
|
25111
25161
|
() => resolveDataManagementPortalContainer(rootRef.current),
|
|
25112
25162
|
[]
|
|
25113
25163
|
);
|
|
25114
25164
|
const drawerWidth = "min(960px, calc(100vw - 48px))";
|
|
25115
|
-
const confirmDanger = (0,
|
|
25165
|
+
const confirmDanger = (0, import_react87.useCallback)((title2, content, onOk) => {
|
|
25116
25166
|
if (confirmAction(title2, content)) onOk();
|
|
25117
25167
|
}, []);
|
|
25118
|
-
(0,
|
|
25168
|
+
(0, import_react87.useEffect)(() => {
|
|
25119
25169
|
let mounted = true;
|
|
25120
25170
|
if (permissionMode !== "auto") {
|
|
25121
25171
|
setActionSummary(null);
|
|
@@ -25142,7 +25192,7 @@ var DataManagementList = ({
|
|
|
25142
25192
|
mounted = false;
|
|
25143
25193
|
};
|
|
25144
25194
|
}, [appType, formUuid, permissionMode, request]);
|
|
25145
|
-
const baseActionCan = (0,
|
|
25195
|
+
const baseActionCan = (0, import_react87.useMemo)(() => {
|
|
25146
25196
|
if (permissionMode === "auto") {
|
|
25147
25197
|
return FORM_ACTION_PERMISSIONS.reduce((result, action) => {
|
|
25148
25198
|
result[action] = Boolean(actionSummary?.can?.[action]);
|
|
@@ -25154,7 +25204,7 @@ var DataManagementList = ({
|
|
|
25154
25204
|
return result;
|
|
25155
25205
|
}, {});
|
|
25156
25206
|
}, [actionSummary?.can, permissionMode]);
|
|
25157
|
-
const canAction = (0,
|
|
25207
|
+
const canAction = (0, import_react87.useCallback)(
|
|
25158
25208
|
(action) => {
|
|
25159
25209
|
if (permissionLoading && permissionMode === "auto") return false;
|
|
25160
25210
|
if (permissionError && permissionMode === "auto") return action === "view";
|
|
@@ -25176,22 +25226,22 @@ var DataManagementList = ({
|
|
|
25176
25226
|
const canExport = canAction("export");
|
|
25177
25227
|
const canImport = canAction("import");
|
|
25178
25228
|
const canWorkflow = canAction("workflow");
|
|
25179
|
-
const visibleFields = (0,
|
|
25229
|
+
const visibleFields = (0, import_react87.useMemo)(
|
|
25180
25230
|
() => showFields.map((fieldId) => fields.find((field) => field.fieldId === fieldId)).filter(Boolean),
|
|
25181
25231
|
[fields, showFields]
|
|
25182
25232
|
);
|
|
25183
|
-
const forcedShowFieldIds = (0,
|
|
25233
|
+
const forcedShowFieldIds = (0, import_react87.useMemo)(
|
|
25184
25234
|
() => new Set(forcedConfig?.showFields || []),
|
|
25185
25235
|
[forcedConfig?.showFields]
|
|
25186
25236
|
);
|
|
25187
|
-
const forcedLockFieldIds = (0,
|
|
25237
|
+
const forcedLockFieldIds = (0, import_react87.useMemo)(
|
|
25188
25238
|
() => new Set(forcedConfig?.lockFieldIds || []),
|
|
25189
25239
|
[forcedConfig?.lockFieldIds]
|
|
25190
25240
|
);
|
|
25191
|
-
(0,
|
|
25241
|
+
(0, import_react87.useEffect)(() => {
|
|
25192
25242
|
widthsRef.current = widths;
|
|
25193
25243
|
}, [widths]);
|
|
25194
|
-
(0,
|
|
25244
|
+
(0, import_react87.useEffect)(() => {
|
|
25195
25245
|
fetchStateRef.current = {
|
|
25196
25246
|
current,
|
|
25197
25247
|
pageSize,
|
|
@@ -25200,7 +25250,7 @@ var DataManagementList = ({
|
|
|
25200
25250
|
sort
|
|
25201
25251
|
};
|
|
25202
25252
|
}, [current, filterGroup, pageSize, searchKeyWord, sort]);
|
|
25203
|
-
const loadData = (0,
|
|
25253
|
+
const loadData = (0, import_react87.useCallback)(
|
|
25204
25254
|
async (overrides = {}) => {
|
|
25205
25255
|
if (!appType || !formUuid) return;
|
|
25206
25256
|
const fetchState = { ...fetchStateRef.current, ...overrides };
|
|
@@ -25244,7 +25294,7 @@ var DataManagementList = ({
|
|
|
25244
25294
|
},
|
|
25245
25295
|
[appType, forcedConfig, formUuid, request]
|
|
25246
25296
|
);
|
|
25247
|
-
(0,
|
|
25297
|
+
(0, import_react87.useEffect)(() => {
|
|
25248
25298
|
let mounted = true;
|
|
25249
25299
|
const loadSchemaAndConfig = async () => {
|
|
25250
25300
|
if (!appType || !formUuid) return;
|
|
@@ -25336,7 +25386,7 @@ var DataManagementList = ({
|
|
|
25336
25386
|
request,
|
|
25337
25387
|
title
|
|
25338
25388
|
]);
|
|
25339
|
-
const persistConfig = (0,
|
|
25389
|
+
const persistConfig = (0, import_react87.useCallback)(
|
|
25340
25390
|
async (patch) => {
|
|
25341
25391
|
const personalPatch = stripForcedConfigPatch(patch, forcedConfig);
|
|
25342
25392
|
const nextConfig = { ...config, ...personalPatch };
|
|
@@ -25380,12 +25430,12 @@ var DataManagementList = ({
|
|
|
25380
25430
|
const handleRemoveSort = (index) => {
|
|
25381
25431
|
setSort((prev) => prev.filter((_, itemIndex) => itemIndex !== index));
|
|
25382
25432
|
};
|
|
25383
|
-
const updateColumnWidth = (0,
|
|
25433
|
+
const updateColumnWidth = (0, import_react87.useCallback)((fieldId, width) => {
|
|
25384
25434
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
25385
25435
|
widthsRef.current = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
25386
25436
|
setWidths(widthsRef.current);
|
|
25387
25437
|
}, []);
|
|
25388
|
-
const commitColumnWidth = (0,
|
|
25438
|
+
const commitColumnWidth = (0, import_react87.useCallback)(
|
|
25389
25439
|
(fieldId, width) => {
|
|
25390
25440
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
25391
25441
|
const nextWidths = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
@@ -25395,7 +25445,7 @@ var DataManagementList = ({
|
|
|
25395
25445
|
},
|
|
25396
25446
|
[persistConfig]
|
|
25397
25447
|
);
|
|
25398
|
-
const handleDetail = (0,
|
|
25448
|
+
const handleDetail = (0, import_react87.useCallback)(
|
|
25399
25449
|
(record) => {
|
|
25400
25450
|
const formInstanceId = getRecordId(record);
|
|
25401
25451
|
if (!formInstanceId) {
|
|
@@ -25420,7 +25470,7 @@ var DataManagementList = ({
|
|
|
25420
25470
|
},
|
|
25421
25471
|
[appType, detailBasePath, detailOpenMode, detailPageUrlBuilder, formType, formUuid]
|
|
25422
25472
|
);
|
|
25423
|
-
const handleDelete = (0,
|
|
25473
|
+
const handleDelete = (0, import_react87.useCallback)(
|
|
25424
25474
|
async (ids) => {
|
|
25425
25475
|
if (ids.length === 0) return;
|
|
25426
25476
|
if (!canDelete) {
|
|
@@ -25433,7 +25483,7 @@ var DataManagementList = ({
|
|
|
25433
25483
|
},
|
|
25434
25484
|
[appType, canDelete, current, formUuid, loadData, pageSize, request]
|
|
25435
25485
|
);
|
|
25436
|
-
const getSelectedRecordIds = (0,
|
|
25486
|
+
const getSelectedRecordIds = (0, import_react87.useCallback)(
|
|
25437
25487
|
() => selectedRowKeys.map((key) => {
|
|
25438
25488
|
const record = dataSource.find((item) => String(getRecordId(item)) === String(key));
|
|
25439
25489
|
return String(getSelectedRecordId(record, key));
|
|
@@ -25578,7 +25628,7 @@ var DataManagementList = ({
|
|
|
25578
25628
|
ACTION_COLUMN_MIN_WIDTH,
|
|
25579
25629
|
Math.min(rowActionCount, visibleRowActionLimit) * ACTION_BUTTON_ESTIMATED_WIDTH + (rowActionCount > visibleRowActionLimit ? ACTION_MORE_BUTTON_WIDTH : 0) + ACTION_COLUMN_HORIZONTAL_PADDING
|
|
25580
25630
|
);
|
|
25581
|
-
const columns = (0,
|
|
25631
|
+
const columns = (0, import_react87.useMemo)(() => {
|
|
25582
25632
|
const baseColumns = visibleFields.map((field) => {
|
|
25583
25633
|
const columnWidth = widths[field.fieldId] || field.width || 160;
|
|
25584
25634
|
return {
|
|
@@ -25710,7 +25760,7 @@ var DataManagementList = ({
|
|
|
25710
25760
|
actionColumnWidth
|
|
25711
25761
|
)
|
|
25712
25762
|
);
|
|
25713
|
-
const importPreviewColumns = (0,
|
|
25763
|
+
const importPreviewColumns = (0, import_react87.useMemo)(() => {
|
|
25714
25764
|
const keys = Array.from(
|
|
25715
25765
|
new Set(importPreview.flatMap((record) => Object.keys(record || {})))
|
|
25716
25766
|
).slice(0, 16);
|
|
@@ -26468,17 +26518,17 @@ function BuiltinRouteRenderer({
|
|
|
26468
26518
|
style
|
|
26469
26519
|
}) {
|
|
26470
26520
|
const normalizedServicePrefix = trimTrailingSlash3(servicePrefix);
|
|
26471
|
-
const [schema, setSchema] = (0,
|
|
26472
|
-
const [loading, setLoading] = (0,
|
|
26473
|
-
const [error, setError] = (0,
|
|
26474
|
-
const [reloadKey, setReloadKey] = (0,
|
|
26521
|
+
const [schema, setSchema] = (0, import_react88.useState)();
|
|
26522
|
+
const [loading, setLoading] = (0, import_react88.useState)(false);
|
|
26523
|
+
const [error, setError] = (0, import_react88.useState)("");
|
|
26524
|
+
const [reloadKey, setReloadKey] = (0, import_react88.useState)(0);
|
|
26475
26525
|
const requestConfig = requestOverride && typeof requestOverride === "object" ? requestOverride : void 0;
|
|
26476
|
-
const request = (0,
|
|
26526
|
+
const request = (0, import_react88.useMemo)(() => {
|
|
26477
26527
|
if (typeof requestOverride === "function") return requestOverride;
|
|
26478
26528
|
if (requestConfig?.request) return requestConfig.request;
|
|
26479
26529
|
return createBuiltinRouteRequest(requestConfig?.baseUrl || normalizedServicePrefix, fetchImpl);
|
|
26480
26530
|
}, [fetchImpl, normalizedServicePrefix, requestConfig, requestOverride]);
|
|
26481
|
-
const api = (0,
|
|
26531
|
+
const api = (0, import_react88.useMemo)(
|
|
26482
26532
|
() => createFormRuntimeApi({
|
|
26483
26533
|
baseUrl: normalizedServicePrefix,
|
|
26484
26534
|
...requestConfig || {},
|
|
@@ -26489,14 +26539,14 @@ function BuiltinRouteRenderer({
|
|
|
26489
26539
|
const appType = appTypeProp || route?.appType || "";
|
|
26490
26540
|
const formUuid = route ? pickRouteValue(route, "formUuid", "menuFormUuid") : "";
|
|
26491
26541
|
const formInstId = route ? pickRouteValue(route, "formInstId", "formInstanceId") : "";
|
|
26492
|
-
const routeConfig = (0,
|
|
26542
|
+
const routeConfig = (0, import_react88.useMemo)(
|
|
26493
26543
|
() => route ? resolveRouteConfig(route, config) : {},
|
|
26494
26544
|
[config, route]
|
|
26495
26545
|
);
|
|
26496
26546
|
const runtimeStorage = route?.runtime?.storage;
|
|
26497
26547
|
const permissionDenied = isRuntimePermissionDenied(route);
|
|
26498
|
-
const reload = (0,
|
|
26499
|
-
(0,
|
|
26548
|
+
const reload = (0, import_react88.useCallback)(() => setReloadKey((value) => value + 1), []);
|
|
26549
|
+
(0, import_react88.useEffect)(() => {
|
|
26500
26550
|
let cancelled = false;
|
|
26501
26551
|
setSchema(void 0);
|
|
26502
26552
|
setError("");
|