openxiangda 1.0.154 → 1.0.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/openxiangda-skills/SKILL.md +1 -0
- package/openxiangda-skills/references/component-guide.md +2 -0
- package/openxiangda-skills/references/pages/page-sdk.md +19 -0
- package/openxiangda-skills/references/troubleshooting.md +5 -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/runtime/index.cjs +806 -795
- 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 +192 -181
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +234 -223
- 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 +106 -95
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
- package/templates/openxiangda-react-spa/AGENTS.md +1 -0
|
@@ -50,6 +50,7 @@ __export(runtime_exports, {
|
|
|
50
50
|
createBrowserPageBridge: () => createBrowserPageBridge,
|
|
51
51
|
createBrowserPageContext: () => createBrowserPageContext,
|
|
52
52
|
createBuiltinRouteRequest: () => createBuiltinRouteRequest,
|
|
53
|
+
createPageFormRuntimeApi: () => createPageFormRuntimeApi,
|
|
53
54
|
createPageSdk: () => createPageSdk,
|
|
54
55
|
createPublicAccessClient: () => createPublicAccessClient,
|
|
55
56
|
createReactPage: () => createReactPage,
|
|
@@ -79,6 +80,7 @@ __export(runtime_exports, {
|
|
|
79
80
|
useNavigation: () => useNavigation,
|
|
80
81
|
useOpenXiangda: () => useOpenXiangda,
|
|
81
82
|
usePageContext: () => usePageContext,
|
|
83
|
+
usePageFormRuntimeApi: () => usePageFormRuntimeApi,
|
|
82
84
|
usePageProps: () => usePageProps,
|
|
83
85
|
usePageRoute: () => usePageRoute,
|
|
84
86
|
usePageSdk: () => usePageSdk,
|
|
@@ -3034,9 +3036,8 @@ var usePageRoute = () => {
|
|
|
3034
3036
|
return usePageContext().route;
|
|
3035
3037
|
};
|
|
3036
3038
|
|
|
3037
|
-
// packages/sdk/src/runtime/react/
|
|
3038
|
-
var
|
|
3039
|
-
var import_antd5 = require("antd");
|
|
3039
|
+
// packages/sdk/src/runtime/react/formRuntime.ts
|
|
3040
|
+
var import_react7 = require("react");
|
|
3040
3041
|
|
|
3041
3042
|
// packages/sdk/src/components/core/imageCompression.ts
|
|
3042
3043
|
var DEFAULT_THUMB = {
|
|
@@ -3889,6 +3890,73 @@ function createFormRuntimeApi(config) {
|
|
|
3889
3890
|
return { ...defaults, ...overrides, request };
|
|
3890
3891
|
}
|
|
3891
3892
|
|
|
3893
|
+
// packages/sdk/src/runtime/react/formRuntime.ts
|
|
3894
|
+
var normalizeMethod2 = (method) => {
|
|
3895
|
+
const value = String(method || "get").toLowerCase();
|
|
3896
|
+
return ["get", "post", "put", "delete", "patch"].includes(value) ? value : "get";
|
|
3897
|
+
};
|
|
3898
|
+
var normalizeHeaders = (headers) => {
|
|
3899
|
+
if (!headers) return void 0;
|
|
3900
|
+
return Object.fromEntries(new Headers(headers).entries());
|
|
3901
|
+
};
|
|
3902
|
+
var toPageRequest = (config) => ({
|
|
3903
|
+
path: config.url,
|
|
3904
|
+
method: normalizeMethod2(config.method),
|
|
3905
|
+
query: config.params,
|
|
3906
|
+
body: config.data,
|
|
3907
|
+
headers: normalizeHeaders(config.headers)
|
|
3908
|
+
});
|
|
3909
|
+
var toRuntimeResponse = (response) => {
|
|
3910
|
+
if (response.raw && typeof response.raw === "object") {
|
|
3911
|
+
return response.raw;
|
|
3912
|
+
}
|
|
3913
|
+
return {
|
|
3914
|
+
code: Number(response.code) || 200,
|
|
3915
|
+
success: response.success,
|
|
3916
|
+
message: response.message,
|
|
3917
|
+
data: response.result,
|
|
3918
|
+
result: response.result
|
|
3919
|
+
};
|
|
3920
|
+
};
|
|
3921
|
+
var unwrapPageResult = (response) => response.result ?? response.data ?? null;
|
|
3922
|
+
var createPageFormRuntimeApi = (sdk) => {
|
|
3923
|
+
const request = async (config) => {
|
|
3924
|
+
const options = toPageRequest(config);
|
|
3925
|
+
if (config.responseType === "blob") {
|
|
3926
|
+
const response = await sdk.transport.download(options);
|
|
3927
|
+
return response.blob;
|
|
3928
|
+
}
|
|
3929
|
+
return toRuntimeResponse(await sdk.transport.request(options));
|
|
3930
|
+
};
|
|
3931
|
+
return createFormRuntimeApi({
|
|
3932
|
+
request,
|
|
3933
|
+
createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => unwrapPageResult(
|
|
3934
|
+
await sdk.createFileAccessTicket(
|
|
3935
|
+
bucketName,
|
|
3936
|
+
objectName,
|
|
3937
|
+
fileName,
|
|
3938
|
+
purpose,
|
|
3939
|
+
options
|
|
3940
|
+
)
|
|
3941
|
+
),
|
|
3942
|
+
createDownloadTicket: async (bucketName, objectName, fileName) => unwrapPageResult(
|
|
3943
|
+
await sdk.request({
|
|
3944
|
+
path: "/file/download-ticket",
|
|
3945
|
+
method: "post",
|
|
3946
|
+
body: { bucketName, objectName, fileName }
|
|
3947
|
+
})
|
|
3948
|
+
)
|
|
3949
|
+
});
|
|
3950
|
+
};
|
|
3951
|
+
var usePageFormRuntimeApi = () => {
|
|
3952
|
+
const sdk = usePageSdk();
|
|
3953
|
+
return (0, import_react7.useMemo)(() => createPageFormRuntimeApi(sdk), [sdk]);
|
|
3954
|
+
};
|
|
3955
|
+
|
|
3956
|
+
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
3957
|
+
var import_react11 = __toESM(require("react"));
|
|
3958
|
+
var import_antd5 = require("antd");
|
|
3959
|
+
|
|
3892
3960
|
// packages/sdk/src/components/fields/shared/fieldFormat.ts
|
|
3893
3961
|
function createUid(prefix = "field") {
|
|
3894
3962
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -4420,7 +4488,7 @@ var convertHeicPreview = async (request, url) => {
|
|
|
4420
4488
|
};
|
|
4421
4489
|
|
|
4422
4490
|
// packages/sdk/src/components/file-preview/FilePreviewContent.tsx
|
|
4423
|
-
var
|
|
4491
|
+
var import_react8 = require("react");
|
|
4424
4492
|
var import_antd2 = require("antd");
|
|
4425
4493
|
var import_icons = require("@ant-design/icons");
|
|
4426
4494
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -4504,11 +4572,11 @@ var PayloadPreview = ({
|
|
|
4504
4572
|
url,
|
|
4505
4573
|
mode
|
|
4506
4574
|
}) => {
|
|
4507
|
-
const [payload, setPayload] = (0,
|
|
4508
|
-
const [loading, setLoading] = (0,
|
|
4509
|
-
const [error, setError] = (0,
|
|
4510
|
-
const [reloadKey, setReloadKey] = (0,
|
|
4511
|
-
(0,
|
|
4575
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4576
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
4577
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4578
|
+
const [reloadKey, setReloadKey] = (0, import_react8.useState)(0);
|
|
4579
|
+
(0, import_react8.useEffect)(() => {
|
|
4512
4580
|
let disposed = false;
|
|
4513
4581
|
setPayload(null);
|
|
4514
4582
|
setError("");
|
|
@@ -4616,9 +4684,9 @@ var ClientTextPreview = ({
|
|
|
4616
4684
|
request,
|
|
4617
4685
|
url
|
|
4618
4686
|
}) => {
|
|
4619
|
-
const [payload, setPayload] = (0,
|
|
4620
|
-
const [error, setError] = (0,
|
|
4621
|
-
(0,
|
|
4687
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4688
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4689
|
+
(0, import_react8.useEffect)(() => {
|
|
4622
4690
|
let disposed = false;
|
|
4623
4691
|
let textLimit = 1024 * 1024;
|
|
4624
4692
|
loadPreviewBlob(request, url).then(async (blob) => {
|
|
@@ -4654,10 +4722,10 @@ var ClientTextPreview = ({
|
|
|
4654
4722
|
] });
|
|
4655
4723
|
};
|
|
4656
4724
|
var DocxPreview = ({ request, url }) => {
|
|
4657
|
-
const containerRef = (0,
|
|
4658
|
-
const [loading, setLoading] = (0,
|
|
4659
|
-
const [error, setError] = (0,
|
|
4660
|
-
(0,
|
|
4725
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
4726
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
4727
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4728
|
+
(0, import_react8.useEffect)(() => {
|
|
4661
4729
|
let disposed = false;
|
|
4662
4730
|
const container = containerRef.current;
|
|
4663
4731
|
if (!container || !url) return () => {
|
|
@@ -4716,9 +4784,9 @@ var HeicImagePreview = ({
|
|
|
4716
4784
|
url,
|
|
4717
4785
|
fileName
|
|
4718
4786
|
}) => {
|
|
4719
|
-
const [src, setSrc] = (0,
|
|
4720
|
-
const [error, setError] = (0,
|
|
4721
|
-
(0,
|
|
4787
|
+
const [src, setSrc] = (0, import_react8.useState)("");
|
|
4788
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4789
|
+
(0, import_react8.useEffect)(() => {
|
|
4722
4790
|
let disposed = false;
|
|
4723
4791
|
let objectUrl = "";
|
|
4724
4792
|
convertHeicPreview(request, url).then((result) => {
|
|
@@ -4747,9 +4815,9 @@ var ClientSpreadsheetPreview = ({
|
|
|
4747
4815
|
request,
|
|
4748
4816
|
url
|
|
4749
4817
|
}) => {
|
|
4750
|
-
const [payload, setPayload] = (0,
|
|
4751
|
-
const [error, setError] = (0,
|
|
4752
|
-
(0,
|
|
4818
|
+
const [payload, setPayload] = (0, import_react8.useState)(null);
|
|
4819
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4820
|
+
(0, import_react8.useEffect)(() => {
|
|
4753
4821
|
let disposed = false;
|
|
4754
4822
|
(async () => {
|
|
4755
4823
|
try {
|
|
@@ -4865,13 +4933,13 @@ var OnlyOfficePreview = ({
|
|
|
4865
4933
|
configUrl,
|
|
4866
4934
|
ticket
|
|
4867
4935
|
}) => {
|
|
4868
|
-
const editorId = (0,
|
|
4936
|
+
const editorId = (0, import_react8.useMemo)(
|
|
4869
4937
|
() => `openxiangda-onlyoffice-${String(ticket || "editor").replace(/[^a-zA-Z0-9_-]/g, "")}`,
|
|
4870
4938
|
[ticket]
|
|
4871
4939
|
);
|
|
4872
|
-
const [loading, setLoading] = (0,
|
|
4873
|
-
const [error, setError] = (0,
|
|
4874
|
-
(0,
|
|
4940
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
4941
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
4942
|
+
(0, import_react8.useEffect)(() => {
|
|
4875
4943
|
let disposed = false;
|
|
4876
4944
|
let editor;
|
|
4877
4945
|
setLoading(true);
|
|
@@ -5054,7 +5122,7 @@ var FilePreviewContent = ({
|
|
|
5054
5122
|
};
|
|
5055
5123
|
|
|
5056
5124
|
// packages/sdk/src/components/file-preview/FilePreviewPage.tsx
|
|
5057
|
-
var
|
|
5125
|
+
var import_react9 = require("react");
|
|
5058
5126
|
var import_antd3 = require("antd");
|
|
5059
5127
|
var import_icons2 = require("@ant-design/icons");
|
|
5060
5128
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -5063,11 +5131,11 @@ var FilePreviewPage = ({
|
|
|
5063
5131
|
request,
|
|
5064
5132
|
servicePrefix = "/service"
|
|
5065
5133
|
}) => {
|
|
5066
|
-
const [metadata, setMetadata] = (0,
|
|
5067
|
-
const [loading, setLoading] = (0,
|
|
5068
|
-
const [error, setError] = (0,
|
|
5069
|
-
const [reloadKey, setReloadKey] = (0,
|
|
5070
|
-
(0,
|
|
5134
|
+
const [metadata, setMetadata] = (0, import_react9.useState)(null);
|
|
5135
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
5136
|
+
const [error, setError] = (0, import_react9.useState)("");
|
|
5137
|
+
const [reloadKey, setReloadKey] = (0, import_react9.useState)(0);
|
|
5138
|
+
(0, import_react9.useEffect)(() => {
|
|
5071
5139
|
let disposed = false;
|
|
5072
5140
|
setMetadata(null);
|
|
5073
5141
|
setError("");
|
|
@@ -5092,7 +5160,7 @@ var FilePreviewPage = ({
|
|
|
5092
5160
|
};
|
|
5093
5161
|
}, [reloadKey, request, ticket]);
|
|
5094
5162
|
const downloadUrl = resolvePreviewServiceUrl(metadata?.downloadUrl, servicePrefix);
|
|
5095
|
-
const handleDownload = (0,
|
|
5163
|
+
const handleDownload = (0, import_react9.useCallback)(() => {
|
|
5096
5164
|
if (downloadUrl && typeof window !== "undefined") window.location.assign(downloadUrl);
|
|
5097
5165
|
}, [downloadUrl]);
|
|
5098
5166
|
const renderContent = () => {
|
|
@@ -5236,7 +5304,7 @@ var FilePreviewPage = ({
|
|
|
5236
5304
|
};
|
|
5237
5305
|
|
|
5238
5306
|
// packages/sdk/src/components/file-preview/useFilePreview.tsx
|
|
5239
|
-
var
|
|
5307
|
+
var import_react10 = require("react");
|
|
5240
5308
|
var import_antd4 = require("antd");
|
|
5241
5309
|
var import_icons3 = require("@ant-design/icons");
|
|
5242
5310
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -5265,7 +5333,7 @@ var useFilePreviewController = ({
|
|
|
5265
5333
|
enabled = true,
|
|
5266
5334
|
requireServerCapability = true
|
|
5267
5335
|
}) => {
|
|
5268
|
-
const itemSignature = (0,
|
|
5336
|
+
const itemSignature = (0, import_react10.useMemo)(
|
|
5269
5337
|
() => items.map(
|
|
5270
5338
|
(item, index) => [
|
|
5271
5339
|
getPreviewItemKey(item, index),
|
|
@@ -5278,17 +5346,17 @@ var useFilePreviewController = ({
|
|
|
5278
5346
|
).join("|"),
|
|
5279
5347
|
[items]
|
|
5280
5348
|
);
|
|
5281
|
-
const [capabilities, setCapabilities] = (0,
|
|
5349
|
+
const [capabilities, setCapabilities] = (0, import_react10.useState)(
|
|
5282
5350
|
() => buildCapabilityMap(items, requireServerCapability)
|
|
5283
5351
|
);
|
|
5284
|
-
const [openingKey, setOpeningKey] = (0,
|
|
5285
|
-
const [dialogPreview, setDialogPreview] = (0,
|
|
5286
|
-
const [imagePreview, setImagePreview] = (0,
|
|
5352
|
+
const [openingKey, setOpeningKey] = (0, import_react10.useState)("");
|
|
5353
|
+
const [dialogPreview, setDialogPreview] = (0, import_react10.useState)(null);
|
|
5354
|
+
const [imagePreview, setImagePreview] = (0, import_react10.useState)({
|
|
5287
5355
|
open: false,
|
|
5288
5356
|
current: 0,
|
|
5289
5357
|
items: []
|
|
5290
5358
|
});
|
|
5291
|
-
(0,
|
|
5359
|
+
(0, import_react10.useEffect)(() => {
|
|
5292
5360
|
let disposed = false;
|
|
5293
5361
|
const initial = buildCapabilityMap(items, requireServerCapability);
|
|
5294
5362
|
setCapabilities(initial);
|
|
@@ -5333,28 +5401,28 @@ var useFilePreviewController = ({
|
|
|
5333
5401
|
disposed = true;
|
|
5334
5402
|
};
|
|
5335
5403
|
}, [api, enabled, itemSignature, requireServerCapability]);
|
|
5336
|
-
const getCapability = (0,
|
|
5404
|
+
const getCapability = (0, import_react10.useCallback)(
|
|
5337
5405
|
(item) => {
|
|
5338
5406
|
const index = items.indexOf(item);
|
|
5339
5407
|
return capabilities[getPreviewItemKey(item, Math.max(index, 0))];
|
|
5340
5408
|
},
|
|
5341
5409
|
[capabilities, items]
|
|
5342
5410
|
);
|
|
5343
|
-
const canPreview = (0,
|
|
5411
|
+
const canPreview = (0, import_react10.useCallback)(
|
|
5344
5412
|
(item) => enabled && canActOnItem(item) && getCapability(item)?.canPreview === true,
|
|
5345
5413
|
[enabled, getCapability]
|
|
5346
5414
|
);
|
|
5347
|
-
const closeImagePreview = (0,
|
|
5415
|
+
const closeImagePreview = (0, import_react10.useCallback)(() => {
|
|
5348
5416
|
setImagePreview((current) => {
|
|
5349
5417
|
revokeImageItems(current.items);
|
|
5350
5418
|
return { open: false, current: 0, items: [] };
|
|
5351
5419
|
});
|
|
5352
5420
|
}, []);
|
|
5353
|
-
(0,
|
|
5421
|
+
(0, import_react10.useEffect)(
|
|
5354
5422
|
() => () => revokeImageItems(imagePreview.items),
|
|
5355
5423
|
[imagePreview.items]
|
|
5356
5424
|
);
|
|
5357
|
-
const resolvePreparedImageItem = (0,
|
|
5425
|
+
const resolvePreparedImageItem = (0, import_react10.useCallback)(
|
|
5358
5426
|
async (prepared, index) => {
|
|
5359
5427
|
const item = prepared.item;
|
|
5360
5428
|
const metadata = prepared.metadata;
|
|
@@ -5376,14 +5444,14 @@ var useFilePreviewController = ({
|
|
|
5376
5444
|
},
|
|
5377
5445
|
[api]
|
|
5378
5446
|
);
|
|
5379
|
-
const prepareImageItem = (0,
|
|
5447
|
+
const prepareImageItem = (0, import_react10.useCallback)(
|
|
5380
5448
|
async (item, index) => {
|
|
5381
5449
|
const prepared = await prepareFilePreview({ item, api, appType, bucketName });
|
|
5382
5450
|
return resolvePreparedImageItem(prepared, index);
|
|
5383
5451
|
},
|
|
5384
5452
|
[api, appType, bucketName, resolvePreparedImageItem]
|
|
5385
5453
|
);
|
|
5386
|
-
const openPreview = (0,
|
|
5454
|
+
const openPreview = (0, import_react10.useCallback)(
|
|
5387
5455
|
async (item) => {
|
|
5388
5456
|
const itemIndex = Math.max(items.indexOf(item), 0);
|
|
5389
5457
|
const key = getPreviewItemKey(item, itemIndex);
|
|
@@ -5446,7 +5514,7 @@ var useFilePreviewController = ({
|
|
|
5446
5514
|
resolvePreparedImageItem
|
|
5447
5515
|
]
|
|
5448
5516
|
);
|
|
5449
|
-
const downloadItem = (0,
|
|
5517
|
+
const downloadItem = (0, import_react10.useCallback)(
|
|
5450
5518
|
async (item, prepared) => {
|
|
5451
5519
|
let url = prepared?.metadata.downloadUrl || item.downloadUrl || item.publicUrl || item.url;
|
|
5452
5520
|
if (!isDirectStorageItem(item) && item.objectName && !prepared?.metadata.downloadUrl) {
|
|
@@ -5610,63 +5678,6 @@ function FileStatusText({
|
|
|
5610
5678
|
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
5611
5679
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
5612
5680
|
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
5681
|
var useFilePreview = ({
|
|
5671
5682
|
items = EMPTY_ITEMS,
|
|
5672
5683
|
appType,
|
|
@@ -5675,7 +5686,7 @@ var useFilePreview = ({
|
|
|
5675
5686
|
requireServerCapability = true
|
|
5676
5687
|
}) => {
|
|
5677
5688
|
const sdk = usePageSdk();
|
|
5678
|
-
const api = (0,
|
|
5689
|
+
const api = (0, import_react11.useMemo)(() => createPageFormRuntimeApi(sdk), [sdk]);
|
|
5679
5690
|
const preview = useFilePreviewController({
|
|
5680
5691
|
items,
|
|
5681
5692
|
api,
|
|
@@ -5767,8 +5778,8 @@ var AttachmentPreviewList = ({
|
|
|
5767
5778
|
};
|
|
5768
5779
|
var PreviewImageThumb = ({ item }) => {
|
|
5769
5780
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
5770
|
-
const [failed, setFailed] = (0,
|
|
5771
|
-
|
|
5781
|
+
const [failed, setFailed] = (0, import_react11.useState)(false);
|
|
5782
|
+
import_react11.default.useEffect(() => setFailed(false), [src]);
|
|
5772
5783
|
return src && !failed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src, alt: item.name || "\u56FE\u7247", onError: () => setFailed(true) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sy-image-state", children: item.name || "\u56FE\u7247" });
|
|
5773
5784
|
};
|
|
5774
5785
|
var ImagePreviewGrid = ({
|
|
@@ -5863,12 +5874,12 @@ var ImagePreviewGrid = ({
|
|
|
5863
5874
|
};
|
|
5864
5875
|
|
|
5865
5876
|
// packages/sdk/src/runtime/react/workflow.tsx
|
|
5866
|
-
var
|
|
5877
|
+
var import_react17 = require("react");
|
|
5867
5878
|
var import_antd10 = require("antd");
|
|
5868
5879
|
var import_icons9 = require("@ant-design/icons");
|
|
5869
5880
|
|
|
5870
5881
|
// packages/sdk/src/components/modules/StickyActionBar.tsx
|
|
5871
|
-
var
|
|
5882
|
+
var import_react12 = require("react");
|
|
5872
5883
|
var import_antd6 = require("antd");
|
|
5873
5884
|
var import_icons5 = require("@ant-design/icons");
|
|
5874
5885
|
|
|
@@ -5904,14 +5915,14 @@ var StickyActionBar = ({
|
|
|
5904
5915
|
position = "sticky",
|
|
5905
5916
|
surface = "default"
|
|
5906
5917
|
}) => {
|
|
5907
|
-
const [isMobile, setIsMobile] = (0,
|
|
5908
|
-
(0,
|
|
5918
|
+
const [isMobile, setIsMobile] = (0, import_react12.useState)(false);
|
|
5919
|
+
(0, import_react12.useEffect)(() => {
|
|
5909
5920
|
const update = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
|
|
5910
5921
|
update();
|
|
5911
5922
|
window.addEventListener("resize", update);
|
|
5912
5923
|
return () => window.removeEventListener("resize", update);
|
|
5913
5924
|
}, []);
|
|
5914
|
-
const visibleActions = (0,
|
|
5925
|
+
const visibleActions = (0, import_react12.useMemo)(
|
|
5915
5926
|
() => actions.filter((action) => action.visible !== false).sort((left, right) => getActionPriority(left) - getActionPriority(right)),
|
|
5916
5927
|
[actions]
|
|
5917
5928
|
);
|
|
@@ -5980,7 +5991,7 @@ var StickyActionBar = ({
|
|
|
5980
5991
|
};
|
|
5981
5992
|
|
|
5982
5993
|
// packages/sdk/src/components/modules/ApprovalTimeline.tsx
|
|
5983
|
-
var
|
|
5994
|
+
var import_react13 = require("react");
|
|
5984
5995
|
var import_icons6 = require("@ant-design/icons");
|
|
5985
5996
|
|
|
5986
5997
|
// packages/sdk/src/components/core/constants.ts
|
|
@@ -6144,8 +6155,8 @@ var ApprovalTimeline = ({
|
|
|
6144
6155
|
compactMode = false,
|
|
6145
6156
|
showApproverInfo = true
|
|
6146
6157
|
}) => {
|
|
6147
|
-
const taskList = (0,
|
|
6148
|
-
const groups = (0,
|
|
6158
|
+
const taskList = (0, import_react13.useMemo)(() => Array.isArray(tasks) ? tasks : [], [tasks]);
|
|
6159
|
+
const groups = (0, import_react13.useMemo)(() => groupTasks(taskList), [taskList]);
|
|
6149
6160
|
if (taskList.length === 0) {
|
|
6150
6161
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6151
6162
|
"div",
|
|
@@ -6291,7 +6302,7 @@ var ProcessPreview = ({
|
|
|
6291
6302
|
};
|
|
6292
6303
|
|
|
6293
6304
|
// packages/sdk/src/components/modules/InitiatorApproverSelector.tsx
|
|
6294
|
-
var
|
|
6305
|
+
var import_react16 = require("react");
|
|
6295
6306
|
var import_antd9 = require("antd");
|
|
6296
6307
|
|
|
6297
6308
|
// packages/sdk/src/components/core/processApi.ts
|
|
@@ -6655,13 +6666,13 @@ async function getViewPermission(request, params) {
|
|
|
6655
6666
|
}
|
|
6656
6667
|
|
|
6657
6668
|
// packages/sdk/src/components/fields/shared/UserPicker.tsx
|
|
6658
|
-
var
|
|
6669
|
+
var import_react15 = require("react");
|
|
6659
6670
|
var import_antd8 = require("antd");
|
|
6660
6671
|
var import_icons8 = require("@ant-design/icons");
|
|
6661
6672
|
var MobileAntd = __toESM(require("antd-mobile"));
|
|
6662
6673
|
|
|
6663
6674
|
// packages/sdk/src/components/fields/shared/useLazyDepartmentTree.ts
|
|
6664
|
-
var
|
|
6675
|
+
var import_react14 = require("react");
|
|
6665
6676
|
var toLazyNode = (node) => {
|
|
6666
6677
|
const normalized = normalizeDepartmentNode(node);
|
|
6667
6678
|
const id = getDepartmentId(normalized);
|
|
@@ -6711,15 +6722,15 @@ function buildIndexes(nodes) {
|
|
|
6711
6722
|
return { nodeMap, parentMap, flatNodes };
|
|
6712
6723
|
}
|
|
6713
6724
|
function useLazyDepartmentTree(api, configuredTreeData) {
|
|
6714
|
-
const [treeData, setTreeDataState] = (0,
|
|
6725
|
+
const [treeData, setTreeDataState] = (0, import_react14.useState)(
|
|
6715
6726
|
() => (configuredTreeData || []).map(toLazyNode)
|
|
6716
6727
|
);
|
|
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,
|
|
6728
|
+
const [treeLoading, setTreeLoading] = (0, import_react14.useState)(false);
|
|
6729
|
+
const treeDataRef = (0, import_react14.useRef)(treeData);
|
|
6730
|
+
const rootsLoadedRef = (0, import_react14.useRef)(Boolean(configuredTreeData?.length));
|
|
6731
|
+
const rootPromiseRef = (0, import_react14.useRef)(null);
|
|
6732
|
+
const childPromiseRef = (0, import_react14.useRef)({});
|
|
6733
|
+
const setTreeData = (0, import_react14.useCallback)(
|
|
6723
6734
|
(next) => {
|
|
6724
6735
|
const resolved = typeof next === "function" ? next(treeDataRef.current) : next;
|
|
6725
6736
|
treeDataRef.current = resolved;
|
|
@@ -6728,13 +6739,13 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6728
6739
|
},
|
|
6729
6740
|
[]
|
|
6730
6741
|
);
|
|
6731
|
-
(0,
|
|
6742
|
+
(0, import_react14.useEffect)(() => {
|
|
6732
6743
|
if (!configuredTreeData) return;
|
|
6733
6744
|
const next = configuredTreeData.map(toLazyNode);
|
|
6734
6745
|
rootsLoadedRef.current = next.length > 0;
|
|
6735
6746
|
setTreeData(next);
|
|
6736
6747
|
}, [configuredTreeData, setTreeData]);
|
|
6737
|
-
const loadRootDepartments = (0,
|
|
6748
|
+
const loadRootDepartments = (0, import_react14.useCallback)(async () => {
|
|
6738
6749
|
if (rootsLoadedRef.current) return treeDataRef.current;
|
|
6739
6750
|
if (rootPromiseRef.current) return rootPromiseRef.current;
|
|
6740
6751
|
setTreeLoading(true);
|
|
@@ -6750,7 +6761,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6750
6761
|
rootPromiseRef.current = promise;
|
|
6751
6762
|
return promise;
|
|
6752
6763
|
}, [api, setTreeData]);
|
|
6753
|
-
const loadChildren = (0,
|
|
6764
|
+
const loadChildren = (0, import_react14.useCallback)(
|
|
6754
6765
|
async (parentId) => {
|
|
6755
6766
|
const id = String(parentId || "");
|
|
6756
6767
|
if (!id) return [];
|
|
@@ -6771,8 +6782,8 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
6771
6782
|
},
|
|
6772
6783
|
[api, setTreeData]
|
|
6773
6784
|
);
|
|
6774
|
-
const indexes = (0,
|
|
6775
|
-
(0,
|
|
6785
|
+
const indexes = (0, import_react14.useMemo)(() => buildIndexes(treeData), [treeData]);
|
|
6786
|
+
(0, import_react14.useEffect)(() => {
|
|
6776
6787
|
void loadRootDepartments();
|
|
6777
6788
|
}, [loadRootDepartments]);
|
|
6778
6789
|
return {
|
|
@@ -6817,24 +6828,24 @@ function UserPickerPanel({
|
|
|
6817
6828
|
flatNodes,
|
|
6818
6829
|
loadChildren
|
|
6819
6830
|
} = 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,
|
|
6831
|
+
const [departmentKeyword, setDepartmentKeyword] = (0, import_react15.useState)("");
|
|
6832
|
+
const [memberKeyword, setMemberKeyword] = (0, import_react15.useState)("");
|
|
6833
|
+
const [mobileKeyword, setMobileKeyword] = (0, import_react15.useState)("");
|
|
6834
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react15.useState)("");
|
|
6835
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react15.useState)([]);
|
|
6836
|
+
const [members, setMembers] = (0, import_react15.useState)(() => normalizeUsers(dataSource));
|
|
6837
|
+
const [memberPage, setMemberPage] = (0, import_react15.useState)(1);
|
|
6838
|
+
const [memberPageSize, setMemberPageSize] = (0, import_react15.useState)(DEFAULT_MEMBER_PAGE_SIZE);
|
|
6839
|
+
const [memberTotal, setMemberTotal] = (0, import_react15.useState)(() => normalizeUsers(dataSource).length);
|
|
6840
|
+
const [memberReloadKey, setMemberReloadKey] = (0, import_react15.useState)(0);
|
|
6841
|
+
const [loading, setLoading] = (0, import_react15.useState)(false);
|
|
6842
|
+
const [selected, setSelected] = (0, import_react15.useState)(() => normalizeUsers(value));
|
|
6832
6843
|
const selectedIds = selected.map(getUserId);
|
|
6833
6844
|
const MobileSearchBar = getMobileComponent("SearchBar");
|
|
6834
6845
|
const activeMemberKeyword = (mobile ? mobileKeyword : memberKeyword).trim();
|
|
6835
|
-
const staticUsers = (0,
|
|
6846
|
+
const staticUsers = (0, import_react15.useMemo)(() => normalizeUsers(dataSource), [dataSource]);
|
|
6836
6847
|
const hasStaticUserSource = staticUsers.length > 0;
|
|
6837
|
-
(0,
|
|
6848
|
+
(0, import_react15.useEffect)(() => {
|
|
6838
6849
|
if (mobile) return;
|
|
6839
6850
|
if (currentDeptId || deptTreeData.length === 0) return;
|
|
6840
6851
|
setExpandedKeys(deptTreeData.map((node) => getDepartmentId(node)));
|
|
@@ -6842,17 +6853,17 @@ function UserPickerPanel({
|
|
|
6842
6853
|
setCurrentDeptId(getDepartmentId(deptTreeData[0]));
|
|
6843
6854
|
}
|
|
6844
6855
|
}, [currentDeptId, deptTreeData, loadAllWhenNoDepartment, mobile]);
|
|
6845
|
-
(0,
|
|
6856
|
+
(0, import_react15.useEffect)(() => {
|
|
6846
6857
|
setMemberPage(1);
|
|
6847
6858
|
}, [activeMemberKeyword, currentDeptId, dataSource, mobile]);
|
|
6848
|
-
const handleDepartmentSelect = (0,
|
|
6859
|
+
const handleDepartmentSelect = (0, import_react15.useCallback)((deptId) => {
|
|
6849
6860
|
const nextDeptId = String(deptId || "");
|
|
6850
6861
|
setCurrentDeptId(nextDeptId);
|
|
6851
6862
|
setMemberKeyword("");
|
|
6852
6863
|
setMemberPage(1);
|
|
6853
6864
|
setMemberReloadKey((current) => current + 1);
|
|
6854
6865
|
}, []);
|
|
6855
|
-
(0,
|
|
6866
|
+
(0, import_react15.useEffect)(() => {
|
|
6856
6867
|
let active = true;
|
|
6857
6868
|
const keyword = activeMemberKeyword;
|
|
6858
6869
|
if (hasStaticUserSource) {
|
|
@@ -6925,7 +6936,7 @@ function UserPickerPanel({
|
|
|
6925
6936
|
memberReloadKey,
|
|
6926
6937
|
staticUsers
|
|
6927
6938
|
]);
|
|
6928
|
-
const currentPath = (0,
|
|
6939
|
+
const currentPath = (0, import_react15.useMemo)(() => {
|
|
6929
6940
|
if (!currentDeptId) return [];
|
|
6930
6941
|
const path = [];
|
|
6931
6942
|
let cursor = currentDeptId;
|
|
@@ -6937,7 +6948,7 @@ function UserPickerPanel({
|
|
|
6937
6948
|
}
|
|
6938
6949
|
return path;
|
|
6939
6950
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
6940
|
-
const mobileDepartments = (0,
|
|
6951
|
+
const mobileDepartments = (0, import_react15.useMemo)(() => {
|
|
6941
6952
|
const keyword = mobileKeyword.trim().toLowerCase();
|
|
6942
6953
|
if (keyword) {
|
|
6943
6954
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(keyword)).map((item) => item.node);
|
|
@@ -7201,19 +7212,19 @@ var RequirementSelect = ({
|
|
|
7201
7212
|
selectedUsers,
|
|
7202
7213
|
onChange
|
|
7203
7214
|
}) => {
|
|
7204
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
7205
|
-
const initialCandidates = (0,
|
|
7215
|
+
const [pickerOpen, setPickerOpen] = (0, import_react16.useState)(false);
|
|
7216
|
+
const initialCandidates = (0, import_react16.useMemo)(
|
|
7206
7217
|
() => (requirement.candidateUsers || []).map(normalizeCandidate).filter(Boolean),
|
|
7207
7218
|
[requirement.candidateUsers]
|
|
7208
7219
|
);
|
|
7209
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
7210
|
-
const [loading, setLoading] = (0,
|
|
7211
|
-
(0,
|
|
7220
|
+
const [optionsSource, setOptionsSource] = (0, import_react16.useState)(initialCandidates);
|
|
7221
|
+
const [loading, setLoading] = (0, import_react16.useState)(false);
|
|
7222
|
+
(0, import_react16.useEffect)(() => {
|
|
7212
7223
|
setOptionsSource(
|
|
7213
7224
|
(current) => mergeUsers(initialCandidates, mergeUsers(current, selectedUsers))
|
|
7214
7225
|
);
|
|
7215
7226
|
}, [initialCandidates, selectedUsers]);
|
|
7216
|
-
const loadCandidates = (0,
|
|
7227
|
+
const loadCandidates = (0, import_react16.useCallback)(
|
|
7217
7228
|
async (keyword) => {
|
|
7218
7229
|
setLoading(true);
|
|
7219
7230
|
try {
|
|
@@ -7251,12 +7262,12 @@ var RequirementSelect = ({
|
|
|
7251
7262
|
},
|
|
7252
7263
|
[api, appType, formUuid, initialCandidates.length, requirement.nodeId, requirement.scope]
|
|
7253
7264
|
);
|
|
7254
|
-
(0,
|
|
7265
|
+
(0, import_react16.useEffect)(() => {
|
|
7255
7266
|
if (requirement.scope !== "all" && open && formUuid && appType && requirement.nodeId) {
|
|
7256
7267
|
void loadCandidates();
|
|
7257
7268
|
}
|
|
7258
7269
|
}, [appType, formUuid, loadCandidates, open, requirement.nodeId, requirement.scope]);
|
|
7259
|
-
const options = (0,
|
|
7270
|
+
const options = (0, import_react16.useMemo)(
|
|
7260
7271
|
() => optionsSource.map((user) => ({
|
|
7261
7272
|
value: user.id,
|
|
7262
7273
|
label: getUserLabel(user)
|
|
@@ -7341,9 +7352,9 @@ var InitiatorApproverSelector = ({
|
|
|
7341
7352
|
onOk,
|
|
7342
7353
|
onCancel
|
|
7343
7354
|
}) => {
|
|
7344
|
-
const [selected, setSelected] = (0,
|
|
7345
|
-
const wasOpenRef = (0,
|
|
7346
|
-
(0,
|
|
7355
|
+
const [selected, setSelected] = (0, import_react16.useState)({});
|
|
7356
|
+
const wasOpenRef = (0, import_react16.useRef)(false);
|
|
7357
|
+
(0, import_react16.useEffect)(() => {
|
|
7347
7358
|
if (open && !wasOpenRef.current) {
|
|
7348
7359
|
setSelected(value || EMPTY_SELECTED_MAP);
|
|
7349
7360
|
}
|
|
@@ -7401,20 +7412,20 @@ var normalizeCapabilities = (value) => {
|
|
|
7401
7412
|
function useProcessCapabilities(options) {
|
|
7402
7413
|
const { enabled = true, refreshKey, onError, ...params } = options;
|
|
7403
7414
|
const sdk = usePageSdk();
|
|
7404
|
-
const [capabilities, setCapabilities] = (0,
|
|
7415
|
+
const [capabilities, setCapabilities] = (0, import_react17.useState)(
|
|
7405
7416
|
null
|
|
7406
7417
|
);
|
|
7407
|
-
const [loading, setLoading] = (0,
|
|
7408
|
-
const [error, setError] = (0,
|
|
7409
|
-
const mountedRef = (0,
|
|
7418
|
+
const [loading, setLoading] = (0, import_react17.useState)(false);
|
|
7419
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
7420
|
+
const mountedRef = (0, import_react17.useRef)(true);
|
|
7410
7421
|
const paramsKey = JSON.stringify({ ...params, refreshKey });
|
|
7411
|
-
(0,
|
|
7422
|
+
(0, import_react17.useEffect)(() => {
|
|
7412
7423
|
mountedRef.current = true;
|
|
7413
7424
|
return () => {
|
|
7414
7425
|
mountedRef.current = false;
|
|
7415
7426
|
};
|
|
7416
7427
|
}, []);
|
|
7417
|
-
const refresh = (0,
|
|
7428
|
+
const refresh = (0, import_react17.useCallback)(async () => {
|
|
7418
7429
|
if (!enabled) return capabilities;
|
|
7419
7430
|
setLoading(true);
|
|
7420
7431
|
setError(null);
|
|
@@ -7440,7 +7451,7 @@ function useProcessCapabilities(options) {
|
|
|
7440
7451
|
}
|
|
7441
7452
|
}
|
|
7442
7453
|
}, [capabilities, enabled, onError, paramsKey, sdk]);
|
|
7443
|
-
(0,
|
|
7454
|
+
(0, import_react17.useEffect)(() => {
|
|
7444
7455
|
if (!enabled) return;
|
|
7445
7456
|
void refresh();
|
|
7446
7457
|
}, [enabled, paramsKey, refresh]);
|
|
@@ -7465,8 +7476,8 @@ var requireValue = (value, message7) => {
|
|
|
7465
7476
|
function useProcessActions(options) {
|
|
7466
7477
|
const { capabilities, formUuid, appType, getFormValues, onActionComplete } = options;
|
|
7467
7478
|
const sdk = usePageSdk();
|
|
7468
|
-
const [loadingAction, setLoadingAction] = (0,
|
|
7469
|
-
const buildUpdateFormDataJson = (0,
|
|
7479
|
+
const [loadingAction, setLoadingAction] = (0, import_react17.useState)(null);
|
|
7480
|
+
const buildUpdateFormDataJson = (0, import_react17.useCallback)(
|
|
7470
7481
|
(input) => {
|
|
7471
7482
|
if (input?.updateFormDataJson !== void 0) return input.updateFormDataJson;
|
|
7472
7483
|
const values = getFormValues?.();
|
|
@@ -7474,7 +7485,7 @@ function useProcessActions(options) {
|
|
|
7474
7485
|
},
|
|
7475
7486
|
[getFormValues]
|
|
7476
7487
|
);
|
|
7477
|
-
const executeOperation = (0,
|
|
7488
|
+
const executeOperation = (0, import_react17.useCallback)(
|
|
7478
7489
|
async (operation, input = {}) => {
|
|
7479
7490
|
if (!operation.enabled) return false;
|
|
7480
7491
|
setLoadingAction(operation.key);
|
|
@@ -7584,7 +7595,7 @@ function useProcessActions(options) {
|
|
|
7584
7595
|
sdk
|
|
7585
7596
|
]
|
|
7586
7597
|
);
|
|
7587
|
-
const execute = (0,
|
|
7598
|
+
const execute = (0, import_react17.useCallback)(
|
|
7588
7599
|
async (action, input) => {
|
|
7589
7600
|
const operation = (capabilities?.operations || []).find(
|
|
7590
7601
|
(item) => item.key === action
|
|
@@ -7659,7 +7670,7 @@ var ProcessActionBar = ({
|
|
|
7659
7670
|
position = "sticky"
|
|
7660
7671
|
}) => {
|
|
7661
7672
|
const [form] = import_antd10.Form.useForm();
|
|
7662
|
-
const [activeOperation, setActiveOperation] = (0,
|
|
7673
|
+
const [activeOperation, setActiveOperation] = (0, import_react17.useState)(null);
|
|
7663
7674
|
const autoCapabilities = useProcessCapabilities({
|
|
7664
7675
|
...capabilityParams || {},
|
|
7665
7676
|
enabled: Boolean(capabilityParams) && capabilityParams?.enabled !== false
|
|
@@ -7694,7 +7705,7 @@ var ProcessActionBar = ({
|
|
|
7694
7705
|
}
|
|
7695
7706
|
void actions.executeOperation(operation);
|
|
7696
7707
|
};
|
|
7697
|
-
const actionConfigs = (0,
|
|
7708
|
+
const actionConfigs = (0, import_react17.useMemo)(
|
|
7698
7709
|
() => operations.map((operation) => ({
|
|
7699
7710
|
key: operation.key,
|
|
7700
7711
|
label: operation.label || operation.key,
|
|
@@ -7808,7 +7819,7 @@ var ProcessTimeline = ({
|
|
|
7808
7819
|
var ProcessPreviewPanel = ProcessPreview;
|
|
7809
7820
|
|
|
7810
7821
|
// packages/sdk/src/runtime/react/openxiangdaProvider.tsx
|
|
7811
|
-
var
|
|
7822
|
+
var import_react19 = require("react");
|
|
7812
7823
|
|
|
7813
7824
|
// packages/sdk/src/runtime/host/browserHost.ts
|
|
7814
7825
|
var NAMESPACE_ROOT_CLASS2 = "sy-app-workspace";
|
|
@@ -8197,13 +8208,13 @@ var mountBrowserPageRuntime = async (options) => {
|
|
|
8197
8208
|
};
|
|
8198
8209
|
|
|
8199
8210
|
// packages/sdk/src/runtime/react/auth.tsx
|
|
8200
|
-
var
|
|
8211
|
+
var import_react18 = require("react");
|
|
8201
8212
|
var import_antd11 = require("antd");
|
|
8202
8213
|
var import_icons10 = require("@ant-design/icons");
|
|
8203
8214
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
8204
8215
|
var useAuth = (options = {}) => {
|
|
8205
8216
|
const runtime = useOpenXiangda();
|
|
8206
|
-
const client = (0,
|
|
8217
|
+
const client = (0, import_react18.useMemo)(
|
|
8207
8218
|
() => createAuthClient({
|
|
8208
8219
|
appType: options.appType || runtime.appType,
|
|
8209
8220
|
servicePrefix: options.servicePrefix || runtime.servicePrefix,
|
|
@@ -8218,7 +8229,7 @@ var useAuth = (options = {}) => {
|
|
|
8218
8229
|
runtime.servicePrefix
|
|
8219
8230
|
]
|
|
8220
8231
|
);
|
|
8221
|
-
return (0,
|
|
8232
|
+
return (0, import_react18.useMemo)(
|
|
8222
8233
|
() => ({
|
|
8223
8234
|
client,
|
|
8224
8235
|
getMethods: client.getMethods,
|
|
@@ -8238,12 +8249,12 @@ var useAuth = (options = {}) => {
|
|
|
8238
8249
|
};
|
|
8239
8250
|
var useLoginMethods = (options = {}) => {
|
|
8240
8251
|
const auth = useAuth(options);
|
|
8241
|
-
const [state, setState] = (0,
|
|
8252
|
+
const [state, setState] = (0, import_react18.useState)({
|
|
8242
8253
|
data: null,
|
|
8243
8254
|
loading: true,
|
|
8244
8255
|
error: null
|
|
8245
8256
|
});
|
|
8246
|
-
const reload = (0,
|
|
8257
|
+
const reload = (0, import_react18.useCallback)(async () => {
|
|
8247
8258
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
8248
8259
|
try {
|
|
8249
8260
|
const data = await auth.getMethods();
|
|
@@ -8256,7 +8267,7 @@ var useLoginMethods = (options = {}) => {
|
|
|
8256
8267
|
});
|
|
8257
8268
|
}
|
|
8258
8269
|
}, [auth]);
|
|
8259
|
-
(0,
|
|
8270
|
+
(0, import_react18.useEffect)(() => {
|
|
8260
8271
|
let disposed = false;
|
|
8261
8272
|
const run = async () => {
|
|
8262
8273
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
@@ -8300,17 +8311,17 @@ var LoginPage = ({
|
|
|
8300
8311
|
const methodsState = useLoginMethods(authOptions);
|
|
8301
8312
|
const [passwordForm] = import_antd11.Form.useForm();
|
|
8302
8313
|
const [phoneForm] = import_antd11.Form.useForm();
|
|
8303
|
-
const [activeMethod, setActiveMethod] = (0,
|
|
8314
|
+
const [activeMethod, setActiveMethod] = (0, import_react18.useState)(
|
|
8304
8315
|
defaultMethod || "password"
|
|
8305
8316
|
);
|
|
8306
|
-
const [phonePurpose, setPhonePurpose] = (0,
|
|
8317
|
+
const [phonePurpose, setPhonePurpose] = (0, import_react18.useState)(
|
|
8307
8318
|
"login"
|
|
8308
8319
|
);
|
|
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,
|
|
8320
|
+
const [phoneChallengeId, setPhoneChallengeId] = (0, import_react18.useState)("");
|
|
8321
|
+
const [passwordChallenge, setPasswordChallenge] = (0, import_react18.useState)(null);
|
|
8322
|
+
const [submitting, setSubmitting] = (0, import_react18.useState)(false);
|
|
8323
|
+
const [sendingCode, setSendingCode] = (0, import_react18.useState)(false);
|
|
8324
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
8314
8325
|
const methods = methodsState.methods.filter((method) => method.enabled !== false);
|
|
8315
8326
|
const passwordMethod = findMethod(methods, "password");
|
|
8316
8327
|
const phoneMethod = findMethod(methods, "phone_code");
|
|
@@ -8318,7 +8329,7 @@ var LoginPage = ({
|
|
|
8318
8329
|
const ssoMethod = findMethod(methods, "sso");
|
|
8319
8330
|
const guestMethod = findMethod(methods, "guest");
|
|
8320
8331
|
const allowRegister = methodsState.data?.registration?.mode !== "reject";
|
|
8321
|
-
const tabItems = (0,
|
|
8332
|
+
const tabItems = (0, import_react18.useMemo)(() => {
|
|
8322
8333
|
const items = [];
|
|
8323
8334
|
if (passwordMethod) {
|
|
8324
8335
|
items.push({
|
|
@@ -8437,7 +8448,7 @@ var LoginPage = ({
|
|
|
8437
8448
|
sendingCode,
|
|
8438
8449
|
submitting
|
|
8439
8450
|
]);
|
|
8440
|
-
(0,
|
|
8451
|
+
(0, import_react18.useEffect)(() => {
|
|
8441
8452
|
const firstKey = tabItems[0]?.key;
|
|
8442
8453
|
if (firstKey && !tabItems.some((item) => item.key === activeMethod)) {
|
|
8443
8454
|
setActiveMethod(firstKey);
|
|
@@ -8777,26 +8788,26 @@ var RuntimeHttpError = class extends Error {
|
|
|
8777
8788
|
this.payload = snapshot.payload;
|
|
8778
8789
|
}
|
|
8779
8790
|
};
|
|
8780
|
-
var OpenXiangdaRuntimeContext = (0,
|
|
8791
|
+
var OpenXiangdaRuntimeContext = (0, import_react19.createContext)(null);
|
|
8781
8792
|
var OpenXiangdaProvider = ({
|
|
8782
8793
|
appType,
|
|
8783
8794
|
servicePrefix = "/service",
|
|
8784
8795
|
fetchImpl,
|
|
8785
8796
|
children
|
|
8786
8797
|
}) => {
|
|
8787
|
-
const resolvedFetch = (0,
|
|
8788
|
-
const resolvedAppType = (0,
|
|
8798
|
+
const resolvedFetch = (0, import_react19.useMemo)(() => createBoundFetch(fetchImpl), [fetchImpl]);
|
|
8799
|
+
const resolvedAppType = (0, import_react19.useMemo)(
|
|
8789
8800
|
() => appType || resolveAppTypeFromLocation(),
|
|
8790
8801
|
[appType]
|
|
8791
8802
|
);
|
|
8792
|
-
const [, setAccessTokenState] = (0,
|
|
8793
|
-
const [authState, setAuthState] = (0,
|
|
8803
|
+
const [, setAccessTokenState] = (0, import_react19.useState)(null);
|
|
8804
|
+
const [authState, setAuthState] = (0, import_react19.useState)({
|
|
8794
8805
|
status: "unknown",
|
|
8795
8806
|
error: null
|
|
8796
8807
|
});
|
|
8797
|
-
const accessTokenRef = (0,
|
|
8798
|
-
const refreshRequestRef = (0,
|
|
8799
|
-
const applyAccessToken = (0,
|
|
8808
|
+
const accessTokenRef = (0, import_react19.useRef)(null);
|
|
8809
|
+
const refreshRequestRef = (0, import_react19.useRef)(null);
|
|
8810
|
+
const applyAccessToken = (0, import_react19.useCallback)(
|
|
8800
8811
|
(nextAccessToken, options = {}) => {
|
|
8801
8812
|
if (!nextAccessToken && options.clearIfToken && accessTokenRef.current?.token !== options.clearIfToken) {
|
|
8802
8813
|
return accessTokenRef.current;
|
|
@@ -8814,7 +8825,7 @@ var OpenXiangdaProvider = ({
|
|
|
8814
8825
|
},
|
|
8815
8826
|
[]
|
|
8816
8827
|
);
|
|
8817
|
-
const setAccessToken = (0,
|
|
8828
|
+
const setAccessToken = (0, import_react19.useCallback)(
|
|
8818
8829
|
(nextAccessToken, options = {}) => {
|
|
8819
8830
|
const previousState = accessTokenRef.current;
|
|
8820
8831
|
const nextState = applyAccessToken(nextAccessToken, options);
|
|
@@ -8830,7 +8841,7 @@ var OpenXiangdaProvider = ({
|
|
|
8830
8841
|
},
|
|
8831
8842
|
[applyAccessToken]
|
|
8832
8843
|
);
|
|
8833
|
-
const markUnauthenticated = (0,
|
|
8844
|
+
const markUnauthenticated = (0, import_react19.useCallback)(
|
|
8834
8845
|
(error) => {
|
|
8835
8846
|
const runtimeError = normalizeRuntimeError(error);
|
|
8836
8847
|
applyAccessToken(null);
|
|
@@ -8838,7 +8849,7 @@ var OpenXiangdaProvider = ({
|
|
|
8838
8849
|
},
|
|
8839
8850
|
[applyAccessToken]
|
|
8840
8851
|
);
|
|
8841
|
-
const refreshAccessToken = (0,
|
|
8852
|
+
const refreshAccessToken = (0, import_react19.useCallback)(async () => {
|
|
8842
8853
|
if (!resolvedAppType) return null;
|
|
8843
8854
|
if (!refreshRequestRef.current) {
|
|
8844
8855
|
setAuthState((prev) => ({ ...prev, status: "refreshing", error: null }));
|
|
@@ -8899,7 +8910,7 @@ var OpenXiangdaProvider = ({
|
|
|
8899
8910
|
}
|
|
8900
8911
|
return refreshRequestRef.current;
|
|
8901
8912
|
}, [applyAccessToken, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
8902
|
-
const authorizedFetch = (0,
|
|
8913
|
+
const authorizedFetch = (0, import_react19.useMemo)(
|
|
8903
8914
|
() => createAuthorizedFetch({
|
|
8904
8915
|
appType: resolvedAppType,
|
|
8905
8916
|
baseFetch: resolvedFetch,
|
|
@@ -8909,18 +8920,18 @@ var OpenXiangdaProvider = ({
|
|
|
8909
8920
|
}),
|
|
8910
8921
|
[markUnauthenticated, refreshAccessToken, resolvedAppType, resolvedFetch]
|
|
8911
8922
|
);
|
|
8912
|
-
const getAuthHeaders = (0,
|
|
8923
|
+
const getAuthHeaders = (0, import_react19.useCallback)(() => {
|
|
8913
8924
|
const state2 = accessTokenRef.current;
|
|
8914
8925
|
if (!state2) return {};
|
|
8915
8926
|
const token = resolveAccessTokenForCurrentRoute(state2);
|
|
8916
8927
|
return token ? { authorization: `Bearer ${token}` } : {};
|
|
8917
8928
|
}, []);
|
|
8918
|
-
const [state, setState] = (0,
|
|
8929
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
8919
8930
|
data: null,
|
|
8920
8931
|
loading: true,
|
|
8921
8932
|
error: null
|
|
8922
8933
|
});
|
|
8923
|
-
const reload = (0,
|
|
8934
|
+
const reload = (0, import_react19.useCallback)(async (options = {}) => {
|
|
8924
8935
|
if (!resolvedAppType) {
|
|
8925
8936
|
setState({
|
|
8926
8937
|
data: null,
|
|
@@ -8984,10 +8995,10 @@ var OpenXiangdaProvider = ({
|
|
|
8984
8995
|
}
|
|
8985
8996
|
}
|
|
8986
8997
|
}, [authorizedFetch, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
8987
|
-
(0,
|
|
8998
|
+
(0, import_react19.useEffect)(() => {
|
|
8988
8999
|
void reload();
|
|
8989
9000
|
}, [reload]);
|
|
8990
|
-
const value = (0,
|
|
9001
|
+
const value = (0, import_react19.useMemo)(
|
|
8991
9002
|
() => ({
|
|
8992
9003
|
...state,
|
|
8993
9004
|
appType: resolvedAppType,
|
|
@@ -9013,7 +9024,7 @@ var OpenXiangdaProvider = ({
|
|
|
9013
9024
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(OpenXiangdaRuntimeContext.Provider, { value, children });
|
|
9014
9025
|
};
|
|
9015
9026
|
var useOpenXiangda = () => {
|
|
9016
|
-
const context = (0,
|
|
9027
|
+
const context = (0, import_react19.useContext)(OpenXiangdaRuntimeContext);
|
|
9017
9028
|
if (!context) {
|
|
9018
9029
|
throw new Error("useOpenXiangda must be used inside OpenXiangdaProvider");
|
|
9019
9030
|
}
|
|
@@ -9030,7 +9041,7 @@ var OpenXiangdaPageProvider = ({
|
|
|
9030
9041
|
navigation
|
|
9031
9042
|
}) => {
|
|
9032
9043
|
const runtime = useOpenXiangda();
|
|
9033
|
-
const context = (0,
|
|
9044
|
+
const context = (0, import_react19.useMemo)(() => {
|
|
9034
9045
|
const bootstrap = runtime.data;
|
|
9035
9046
|
const app = toRuntimeRecord(bootstrap?.app);
|
|
9036
9047
|
const user = toRuntimeRecord(bootstrap?.user);
|
|
@@ -9128,12 +9139,12 @@ var usePermission = () => {
|
|
|
9128
9139
|
};
|
|
9129
9140
|
var useCanAccessRoute = (input) => {
|
|
9130
9141
|
const runtime = useOpenXiangda();
|
|
9131
|
-
const [state, setState] = (0,
|
|
9142
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
9132
9143
|
data: null,
|
|
9133
9144
|
loading: true,
|
|
9134
9145
|
error: null
|
|
9135
9146
|
});
|
|
9136
|
-
(0,
|
|
9147
|
+
(0, import_react19.useEffect)(() => {
|
|
9137
9148
|
let disposed = false;
|
|
9138
9149
|
const check = async () => {
|
|
9139
9150
|
const permissions = runtime.data?.permissions;
|
|
@@ -9264,7 +9275,7 @@ var PermissionBoundary = ({
|
|
|
9264
9275
|
};
|
|
9265
9276
|
var useRuntimeAuth = () => {
|
|
9266
9277
|
const runtime = useOpenXiangda();
|
|
9267
|
-
const resolveLoginUrl2 = (0,
|
|
9278
|
+
const resolveLoginUrl2 = (0, import_react19.useCallback)(
|
|
9268
9279
|
async (options = {}) => {
|
|
9269
9280
|
const redirectUri = options.redirectUri || getCurrentHref4();
|
|
9270
9281
|
const domain = options.domain || getCurrentHostname2();
|
|
@@ -9311,7 +9322,7 @@ var useRuntimeAuth = () => {
|
|
|
9311
9322
|
},
|
|
9312
9323
|
[runtime.baseFetchImpl, runtime.data?.app, runtime.servicePrefix]
|
|
9313
9324
|
);
|
|
9314
|
-
const redirectToLogin = (0,
|
|
9325
|
+
const redirectToLogin = (0, import_react19.useCallback)(
|
|
9315
9326
|
async (options = {}) => {
|
|
9316
9327
|
const loginUrl = await resolveLoginUrl2(options);
|
|
9317
9328
|
if (typeof window !== "undefined") {
|
|
@@ -9325,7 +9336,7 @@ var useRuntimeAuth = () => {
|
|
|
9325
9336
|
},
|
|
9326
9337
|
[resolveLoginUrl2]
|
|
9327
9338
|
);
|
|
9328
|
-
const logout = (0,
|
|
9339
|
+
const logout = (0, import_react19.useCallback)(async () => {
|
|
9329
9340
|
const response = await runtime.baseFetchImpl(
|
|
9330
9341
|
buildServiceUrl3(runtime.servicePrefix, "/api/auth/logout"),
|
|
9331
9342
|
{
|
|
@@ -9345,7 +9356,7 @@ var useRuntimeAuth = () => {
|
|
|
9345
9356
|
runtime.setAccessToken(null);
|
|
9346
9357
|
return payload;
|
|
9347
9358
|
}, [runtime.baseFetchImpl, runtime.servicePrefix, runtime.setAccessToken]);
|
|
9348
|
-
const logoutAndRedirect = (0,
|
|
9359
|
+
const logoutAndRedirect = (0, import_react19.useCallback)(
|
|
9349
9360
|
async (options = {}) => {
|
|
9350
9361
|
try {
|
|
9351
9362
|
await logout();
|
|
@@ -9356,7 +9367,7 @@ var useRuntimeAuth = () => {
|
|
|
9356
9367
|
},
|
|
9357
9368
|
[logout, redirectToLogin]
|
|
9358
9369
|
);
|
|
9359
|
-
return (0,
|
|
9370
|
+
return (0, import_react19.useMemo)(
|
|
9360
9371
|
() => ({
|
|
9361
9372
|
logout,
|
|
9362
9373
|
logoutAndRedirect,
|
|
@@ -9375,7 +9386,7 @@ var RuntimeAuthGuard = ({
|
|
|
9375
9386
|
}) => {
|
|
9376
9387
|
const runtime = useOpenXiangda();
|
|
9377
9388
|
const auth = useRuntimeAuth();
|
|
9378
|
-
const redirectedRef = (0,
|
|
9389
|
+
const redirectedRef = (0, import_react19.useRef)(false);
|
|
9379
9390
|
const currentPath = getCurrentPathname2();
|
|
9380
9391
|
const excluded = isRuntimeAuthGuardExcluded(
|
|
9381
9392
|
currentPath,
|
|
@@ -9383,7 +9394,7 @@ var RuntimeAuthGuard = ({
|
|
|
9383
9394
|
excludedPaths
|
|
9384
9395
|
);
|
|
9385
9396
|
const shouldRedirect = !disabled && !excluded && !runtime.loading && (runtime.authState.status === "unauthenticated" || runtime.error?.type === "unauthenticated");
|
|
9386
|
-
(0,
|
|
9397
|
+
(0, import_react19.useEffect)(() => {
|
|
9387
9398
|
if (!shouldRedirect || redirectedRef.current) return;
|
|
9388
9399
|
redirectedRef.current = true;
|
|
9389
9400
|
void auth.redirectToLogin({
|
|
@@ -9726,7 +9737,7 @@ var resolveAppTypeFromLocation = () => {
|
|
|
9726
9737
|
};
|
|
9727
9738
|
|
|
9728
9739
|
// packages/sdk/src/runtime/react/publicAccess.tsx
|
|
9729
|
-
var
|
|
9740
|
+
var import_react20 = require("react");
|
|
9730
9741
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
9731
9742
|
var usePublicAccess = (options = {}) => {
|
|
9732
9743
|
const runtime = useOpenXiangda();
|
|
@@ -9744,14 +9755,14 @@ var usePublicAccess = (options = {}) => {
|
|
|
9744
9755
|
autoStart = true,
|
|
9745
9756
|
...sessionInput
|
|
9746
9757
|
} = options;
|
|
9747
|
-
const [session, setSession] = (0,
|
|
9748
|
-
const [error, setError] = (0,
|
|
9749
|
-
const [loading, setLoading] = (0,
|
|
9750
|
-
const activeSessionRef = (0,
|
|
9751
|
-
const mountedRef = (0,
|
|
9758
|
+
const [session, setSession] = (0, import_react20.useState)(null);
|
|
9759
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
9760
|
+
const [loading, setLoading] = (0, import_react20.useState)(Boolean(autoStart));
|
|
9761
|
+
const activeSessionRef = (0, import_react20.useRef)(null);
|
|
9762
|
+
const mountedRef = (0, import_react20.useRef)(true);
|
|
9752
9763
|
const sessionInputKey = JSON.stringify(sessionInput);
|
|
9753
|
-
const stableSessionInput = (0,
|
|
9754
|
-
const client = (0,
|
|
9764
|
+
const stableSessionInput = (0, import_react20.useMemo)(() => sessionInput, [sessionInputKey]);
|
|
9765
|
+
const client = (0, import_react20.useMemo)(
|
|
9755
9766
|
() => createPublicAccessClient({
|
|
9756
9767
|
appType,
|
|
9757
9768
|
servicePrefix,
|
|
@@ -9759,7 +9770,7 @@ var usePublicAccess = (options = {}) => {
|
|
|
9759
9770
|
}),
|
|
9760
9771
|
[appType, fetchImpl, servicePrefix]
|
|
9761
9772
|
);
|
|
9762
|
-
const startSession = (0,
|
|
9773
|
+
const startSession = (0, import_react20.useCallback)(
|
|
9763
9774
|
async (input = {}) => {
|
|
9764
9775
|
setLoading(true);
|
|
9765
9776
|
setError(null);
|
|
@@ -9805,11 +9816,11 @@ var usePublicAccess = (options = {}) => {
|
|
|
9805
9816
|
},
|
|
9806
9817
|
[client, reloadRuntime, setAccessToken, stableSessionInput]
|
|
9807
9818
|
);
|
|
9808
|
-
(0,
|
|
9819
|
+
(0, import_react20.useEffect)(() => {
|
|
9809
9820
|
if (!autoStart) return;
|
|
9810
9821
|
void startSession().catch(() => void 0);
|
|
9811
9822
|
}, [autoStart, startSession]);
|
|
9812
|
-
(0,
|
|
9823
|
+
(0, import_react20.useEffect)(
|
|
9813
9824
|
() => {
|
|
9814
9825
|
mountedRef.current = true;
|
|
9815
9826
|
return () => {
|
|
@@ -9851,30 +9862,30 @@ var readTicketFromLocation = () => {
|
|
|
9851
9862
|
var readPathFromLocation = () => typeof window === "undefined" ? void 0 : window.location.pathname;
|
|
9852
9863
|
|
|
9853
9864
|
// packages/sdk/src/runtime/host/builtinRouteRenderer.tsx
|
|
9854
|
-
var
|
|
9865
|
+
var import_react88 = require("react");
|
|
9855
9866
|
var import_antd44 = require("antd");
|
|
9856
9867
|
|
|
9857
9868
|
// packages/sdk/src/components/modules/DataManagementList.tsx
|
|
9858
|
-
var
|
|
9869
|
+
var import_react87 = require("react");
|
|
9859
9870
|
var import_antd43 = require("antd");
|
|
9860
9871
|
var import_dayjs12 = __toESM(require("dayjs"));
|
|
9861
9872
|
var import_icons20 = require("@ant-design/icons");
|
|
9862
9873
|
|
|
9863
9874
|
// packages/sdk/src/components/templates/StandardFormPage.tsx
|
|
9864
|
-
var
|
|
9875
|
+
var import_react86 = require("react");
|
|
9865
9876
|
|
|
9866
9877
|
// packages/sdk/src/components/templates/FormDetailTemplate.tsx
|
|
9867
|
-
var
|
|
9878
|
+
var import_react77 = require("react");
|
|
9868
9879
|
var import_dayjs10 = __toESM(require("dayjs"));
|
|
9869
9880
|
|
|
9870
9881
|
// packages/sdk/src/components/core/FormProvider.tsx
|
|
9871
|
-
var
|
|
9882
|
+
var import_react68 = __toESM(require("react"));
|
|
9872
9883
|
|
|
9873
9884
|
// packages/sdk/src/components/core/FormContext.ts
|
|
9874
|
-
var
|
|
9875
|
-
var FormContext = (0,
|
|
9885
|
+
var import_react21 = require("react");
|
|
9886
|
+
var FormContext = (0, import_react21.createContext)(null);
|
|
9876
9887
|
function useFormContext() {
|
|
9877
|
-
const context = (0,
|
|
9888
|
+
const context = (0, import_react21.useContext)(FormContext);
|
|
9878
9889
|
if (!context) {
|
|
9879
9890
|
throw new Error("useFormContext must be used within a FormProvider");
|
|
9880
9891
|
}
|
|
@@ -9882,21 +9893,21 @@ function useFormContext() {
|
|
|
9882
9893
|
}
|
|
9883
9894
|
|
|
9884
9895
|
// packages/sdk/src/components/core/ComponentRegistry.tsx
|
|
9885
|
-
var
|
|
9886
|
-
var ComponentRegistryContext = (0,
|
|
9896
|
+
var import_react22 = __toESM(require("react"));
|
|
9897
|
+
var ComponentRegistryContext = (0, import_react22.createContext)(null);
|
|
9887
9898
|
function ComponentRegistryProvider({
|
|
9888
9899
|
components,
|
|
9889
9900
|
children
|
|
9890
9901
|
}) {
|
|
9891
|
-
const [registry, setRegistry] =
|
|
9892
|
-
const register =
|
|
9902
|
+
const [registry, setRegistry] = import_react22.default.useState(components);
|
|
9903
|
+
const register = import_react22.default.useCallback((name, component) => {
|
|
9893
9904
|
setRegistry((prev) => ({ ...prev, [name]: component }));
|
|
9894
9905
|
}, []);
|
|
9895
|
-
const value =
|
|
9896
|
-
return
|
|
9906
|
+
const value = import_react22.default.useMemo(() => ({ registry, register }), [registry, register]);
|
|
9907
|
+
return import_react22.default.createElement(ComponentRegistryContext.Provider, { value }, children);
|
|
9897
9908
|
}
|
|
9898
9909
|
function useComponent(componentName) {
|
|
9899
|
-
const context = (0,
|
|
9910
|
+
const context = (0, import_react22.useContext)(ComponentRegistryContext);
|
|
9900
9911
|
if (!context) {
|
|
9901
9912
|
return null;
|
|
9902
9913
|
}
|
|
@@ -9904,7 +9915,7 @@ function useComponent(componentName) {
|
|
|
9904
9915
|
}
|
|
9905
9916
|
|
|
9906
9917
|
// packages/sdk/src/components/fields/TextField/index.tsx
|
|
9907
|
-
var
|
|
9918
|
+
var import_react24 = require("react");
|
|
9908
9919
|
|
|
9909
9920
|
// packages/sdk/src/components/core/FieldWrapper.tsx
|
|
9910
9921
|
var Antd = __toESM(require("antd"));
|
|
@@ -10018,7 +10029,7 @@ function FieldWrapper({
|
|
|
10018
10029
|
}
|
|
10019
10030
|
|
|
10020
10031
|
// packages/sdk/src/components/hooks/useDeviceDetect.ts
|
|
10021
|
-
var
|
|
10032
|
+
var import_react23 = require("react");
|
|
10022
10033
|
var MOBILE_BREAKPOINT = 768;
|
|
10023
10034
|
function subscribe(callback) {
|
|
10024
10035
|
let prev = window.innerWidth < MOBILE_BREAKPOINT;
|
|
@@ -10036,7 +10047,7 @@ function getSnapshot() {
|
|
|
10036
10047
|
return window.innerWidth < MOBILE_BREAKPOINT;
|
|
10037
10048
|
}
|
|
10038
10049
|
function useDeviceDetect() {
|
|
10039
|
-
const isMobile = (0,
|
|
10050
|
+
const isMobile = (0, import_react23.useSyncExternalStore)(
|
|
10040
10051
|
subscribe,
|
|
10041
10052
|
getSnapshot,
|
|
10042
10053
|
/* v8 ignore next */
|
|
@@ -10192,7 +10203,7 @@ function TextField(props) {
|
|
|
10192
10203
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10193
10204
|
const { isMobile } = useDeviceDetect();
|
|
10194
10205
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10195
|
-
(0,
|
|
10206
|
+
(0, import_react24.useEffect)(() => {
|
|
10196
10207
|
registerField(fieldId);
|
|
10197
10208
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10198
10209
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10217,7 +10228,7 @@ function TextField(props) {
|
|
|
10217
10228
|
}
|
|
10218
10229
|
|
|
10219
10230
|
// packages/sdk/src/components/fields/NumberField/index.tsx
|
|
10220
|
-
var
|
|
10231
|
+
var import_react25 = require("react");
|
|
10221
10232
|
|
|
10222
10233
|
// packages/sdk/src/components/fields/NumberField/NumberFieldPC.tsx
|
|
10223
10234
|
var import_antd13 = require("antd");
|
|
@@ -10439,7 +10450,7 @@ function NumberField(props) {
|
|
|
10439
10450
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10440
10451
|
const { isMobile } = useDeviceDetect();
|
|
10441
10452
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10442
|
-
(0,
|
|
10453
|
+
(0, import_react25.useEffect)(() => {
|
|
10443
10454
|
registerField(fieldId);
|
|
10444
10455
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10445
10456
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10464,7 +10475,7 @@ function NumberField(props) {
|
|
|
10464
10475
|
}
|
|
10465
10476
|
|
|
10466
10477
|
// packages/sdk/src/components/fields/TextAreaField/index.tsx
|
|
10467
|
-
var
|
|
10478
|
+
var import_react26 = require("react");
|
|
10468
10479
|
|
|
10469
10480
|
// packages/sdk/src/components/fields/TextAreaField/TextAreaFieldPC.tsx
|
|
10470
10481
|
var import_antd14 = require("antd");
|
|
@@ -10611,7 +10622,7 @@ function TextAreaField(props) {
|
|
|
10611
10622
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
10612
10623
|
const { isMobile } = useDeviceDetect();
|
|
10613
10624
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
10614
|
-
(0,
|
|
10625
|
+
(0, import_react26.useEffect)(() => {
|
|
10615
10626
|
registerField(fieldId);
|
|
10616
10627
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
10617
10628
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10636,14 +10647,14 @@ function TextAreaField(props) {
|
|
|
10636
10647
|
}
|
|
10637
10648
|
|
|
10638
10649
|
// packages/sdk/src/components/fields/SelectField/index.tsx
|
|
10639
|
-
var
|
|
10650
|
+
var import_react31 = require("react");
|
|
10640
10651
|
|
|
10641
10652
|
// packages/sdk/src/components/fields/SelectField/SelectFieldPC.tsx
|
|
10642
|
-
var
|
|
10653
|
+
var import_react29 = require("react");
|
|
10643
10654
|
var import_antd16 = require("antd");
|
|
10644
10655
|
|
|
10645
10656
|
// packages/sdk/src/components/fields/shared/optionDisplay.tsx
|
|
10646
|
-
var
|
|
10657
|
+
var import_react27 = __toESM(require("react"));
|
|
10647
10658
|
var import_antd15 = require("antd");
|
|
10648
10659
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
10649
10660
|
var PRESET_COLORS = {
|
|
@@ -10709,12 +10720,12 @@ function renderReadonlyOptions(options, coloredOptions, tagWhenPlain = false) {
|
|
|
10709
10720
|
if (options.length === 0) return "--";
|
|
10710
10721
|
if (!coloredOptions && !tagWhenPlain) return options.map((option) => option.label).join(", ");
|
|
10711
10722
|
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)(
|
|
10723
|
+
(option) => coloredOptions && option.color ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react27.default.Fragment, { children: renderOptionLabel(option, coloredOptions) }, option.value) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_antd15.Tag, { children: option.label }, option.value)
|
|
10713
10724
|
) });
|
|
10714
10725
|
}
|
|
10715
10726
|
|
|
10716
10727
|
// packages/sdk/src/components/fields/SelectField/useLinkedFormRemoteOptions.ts
|
|
10717
|
-
var
|
|
10728
|
+
var import_react28 = require("react");
|
|
10718
10729
|
|
|
10719
10730
|
// packages/sdk/src/components/core/optionSource.ts
|
|
10720
10731
|
var DEFAULT_OPTION_PAGE_SIZE = 200;
|
|
@@ -10929,11 +10940,11 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10929
10940
|
const linkedForm = optionSource?.type === "linkedForm" ? optionSource.linkedForm : void 0;
|
|
10930
10941
|
const enabled = Boolean(linkedForm?.remoteSearch);
|
|
10931
10942
|
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,
|
|
10943
|
+
const [remoteOptions, setRemoteOptions] = (0, import_react28.useState)(null);
|
|
10944
|
+
const [loading, setLoading] = (0, import_react28.useState)(false);
|
|
10945
|
+
const timerRef = (0, import_react28.useRef)(null);
|
|
10946
|
+
const requestRef = (0, import_react28.useRef)(0);
|
|
10947
|
+
const reset = (0, import_react28.useCallback)(() => {
|
|
10937
10948
|
requestRef.current += 1;
|
|
10938
10949
|
if (timerRef.current) {
|
|
10939
10950
|
clearTimeout(timerRef.current);
|
|
@@ -10942,7 +10953,7 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10942
10953
|
setRemoteOptions(null);
|
|
10943
10954
|
setLoading(false);
|
|
10944
10955
|
}, []);
|
|
10945
|
-
const search = (0,
|
|
10956
|
+
const search = (0, import_react28.useCallback)(
|
|
10946
10957
|
(keyword) => {
|
|
10947
10958
|
if (!enabled || !linkedForm) return;
|
|
10948
10959
|
const trimmedKeyword = keyword.trim();
|
|
@@ -10970,14 +10981,14 @@ function useLinkedFormRemoteOptions(optionSource, baseOptions, selectedOptions)
|
|
|
10970
10981
|
},
|
|
10971
10982
|
[enabled, linkedForm, minChars, reset, runtime]
|
|
10972
10983
|
);
|
|
10973
|
-
(0,
|
|
10984
|
+
(0, import_react28.useEffect)(
|
|
10974
10985
|
() => () => {
|
|
10975
10986
|
requestRef.current += 1;
|
|
10976
10987
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
10977
10988
|
},
|
|
10978
10989
|
[]
|
|
10979
10990
|
);
|
|
10980
|
-
const options = (0,
|
|
10991
|
+
const options = (0, import_react28.useMemo)(
|
|
10981
10992
|
() => mergeOptionItems(remoteOptions ?? baseOptions, selectedOptions),
|
|
10982
10993
|
[baseOptions, remoteOptions, selectedOptions]
|
|
10983
10994
|
);
|
|
@@ -11025,7 +11036,7 @@ function SelectFieldPC({
|
|
|
11025
11036
|
const { formData, setFieldValue } = useFormContext();
|
|
11026
11037
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
11027
11038
|
const disabled = behavior === "DISABLED";
|
|
11028
|
-
const selectedOptions = (0,
|
|
11039
|
+
const selectedOptions = (0, import_react29.useMemo)(() => value ? [value] : [], [value]);
|
|
11029
11040
|
const remote = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
11030
11041
|
const displayOptions = remote.options;
|
|
11031
11042
|
const handleChange = (val) => {
|
|
@@ -11066,7 +11077,7 @@ function SelectFieldPC({
|
|
|
11066
11077
|
}
|
|
11067
11078
|
|
|
11068
11079
|
// packages/sdk/src/components/fields/SelectField/SelectFieldMobile.tsx
|
|
11069
|
-
var
|
|
11080
|
+
var import_react30 = require("react");
|
|
11070
11081
|
|
|
11071
11082
|
// packages/sdk/src/components/fields/shared/MobileField.tsx
|
|
11072
11083
|
var import_antd_mobile4 = require("antd-mobile");
|
|
@@ -11247,10 +11258,10 @@ function SelectFieldMobile({
|
|
|
11247
11258
|
const { formData, setFieldValue } = useFormContext();
|
|
11248
11259
|
const value = controlledValue !== void 0 ? controlledValue : formData[fieldId];
|
|
11249
11260
|
const disabled = behavior === "DISABLED";
|
|
11250
|
-
const [visible, setVisible] = (0,
|
|
11251
|
-
const [search, setSearch] = (0,
|
|
11252
|
-
const [tempValue, setTempValue] = (0,
|
|
11253
|
-
const selectedOptions = (0,
|
|
11261
|
+
const [visible, setVisible] = (0, import_react30.useState)(false);
|
|
11262
|
+
const [search, setSearch] = (0, import_react30.useState)("");
|
|
11263
|
+
const [tempValue, setTempValue] = (0, import_react30.useState)(value ?? null);
|
|
11264
|
+
const selectedOptions = (0, import_react30.useMemo)(() => value ? [value] : tempValue ? [tempValue] : [], [
|
|
11254
11265
|
tempValue,
|
|
11255
11266
|
value
|
|
11256
11267
|
]);
|
|
@@ -11261,7 +11272,7 @@ function SelectFieldMobile({
|
|
|
11261
11272
|
reset: resetRemoteOptions,
|
|
11262
11273
|
search: searchRemoteOptions
|
|
11263
11274
|
} = useLinkedFormRemoteOptions(optionSource, options, selectedOptions);
|
|
11264
|
-
const filteredOptions = (0,
|
|
11275
|
+
const filteredOptions = (0, import_react30.useMemo)(() => {
|
|
11265
11276
|
if (remoteEnabled) return remoteOptions;
|
|
11266
11277
|
const keyword = search.trim().toLowerCase();
|
|
11267
11278
|
if (!keyword) return options;
|
|
@@ -11269,7 +11280,7 @@ function SelectFieldMobile({
|
|
|
11269
11280
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
11270
11281
|
);
|
|
11271
11282
|
}, [options, remoteEnabled, remoteOptions, search]);
|
|
11272
|
-
(0,
|
|
11283
|
+
(0, import_react30.useEffect)(() => {
|
|
11273
11284
|
if (!visible || !remoteEnabled) return;
|
|
11274
11285
|
searchRemoteOptions(search);
|
|
11275
11286
|
}, [remoteEnabled, search, searchRemoteOptions, visible]);
|
|
@@ -11381,7 +11392,7 @@ function SelectField(props) {
|
|
|
11381
11392
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11382
11393
|
const { isMobile } = useDeviceDetect();
|
|
11383
11394
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11384
|
-
(0,
|
|
11395
|
+
(0, import_react31.useEffect)(() => {
|
|
11385
11396
|
registerField(fieldId);
|
|
11386
11397
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11387
11398
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11406,7 +11417,7 @@ function SelectField(props) {
|
|
|
11406
11417
|
}
|
|
11407
11418
|
|
|
11408
11419
|
// packages/sdk/src/components/fields/MultiSelectField/index.tsx
|
|
11409
|
-
var
|
|
11420
|
+
var import_react33 = require("react");
|
|
11410
11421
|
|
|
11411
11422
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldPC.tsx
|
|
11412
11423
|
var import_antd17 = require("antd");
|
|
@@ -11466,7 +11477,7 @@ function MultiSelectFieldPC({
|
|
|
11466
11477
|
}
|
|
11467
11478
|
|
|
11468
11479
|
// packages/sdk/src/components/fields/MultiSelectField/MultiSelectFieldMobile.tsx
|
|
11469
|
-
var
|
|
11480
|
+
var import_react32 = require("react");
|
|
11470
11481
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
11471
11482
|
function MultiSelectFieldMobile({
|
|
11472
11483
|
fieldId,
|
|
@@ -11483,17 +11494,17 @@ function MultiSelectFieldMobile({
|
|
|
11483
11494
|
const { formData, setFieldValue } = useFormContext();
|
|
11484
11495
|
const value = controlledValue !== void 0 ? controlledValue ?? [] : formData[fieldId] ?? [];
|
|
11485
11496
|
const disabled = behavior === "DISABLED";
|
|
11486
|
-
const [visible, setVisible] = (0,
|
|
11487
|
-
const [search, setSearch] = (0,
|
|
11488
|
-
const [tempValues, setTempValues] = (0,
|
|
11489
|
-
const filteredOptions = (0,
|
|
11497
|
+
const [visible, setVisible] = (0, import_react32.useState)(false);
|
|
11498
|
+
const [search, setSearch] = (0, import_react32.useState)("");
|
|
11499
|
+
const [tempValues, setTempValues] = (0, import_react32.useState)(value);
|
|
11500
|
+
const filteredOptions = (0, import_react32.useMemo)(() => {
|
|
11490
11501
|
const keyword = search.trim().toLowerCase();
|
|
11491
11502
|
if (!keyword) return options;
|
|
11492
11503
|
return options.filter(
|
|
11493
11504
|
(option) => String(option.label ?? option.value).toLowerCase().includes(keyword)
|
|
11494
11505
|
);
|
|
11495
11506
|
}, [options, search]);
|
|
11496
|
-
const tempValueSet = (0,
|
|
11507
|
+
const tempValueSet = (0, import_react32.useMemo)(
|
|
11497
11508
|
() => new Set(tempValues.map((option) => option.value)),
|
|
11498
11509
|
[tempValues]
|
|
11499
11510
|
);
|
|
@@ -11610,7 +11621,7 @@ function MultiSelectField(props) {
|
|
|
11610
11621
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11611
11622
|
const { isMobile } = useDeviceDetect();
|
|
11612
11623
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11613
|
-
(0,
|
|
11624
|
+
(0, import_react33.useEffect)(() => {
|
|
11614
11625
|
registerField(fieldId);
|
|
11615
11626
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11616
11627
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11635,7 +11646,7 @@ function MultiSelectField(props) {
|
|
|
11635
11646
|
}
|
|
11636
11647
|
|
|
11637
11648
|
// packages/sdk/src/components/fields/RadioField/index.tsx
|
|
11638
|
-
var
|
|
11649
|
+
var import_react34 = require("react");
|
|
11639
11650
|
|
|
11640
11651
|
// packages/sdk/src/components/fields/RadioField/RadioFieldPC.tsx
|
|
11641
11652
|
var import_antd18 = require("antd");
|
|
@@ -11781,7 +11792,7 @@ function RadioField(props) {
|
|
|
11781
11792
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11782
11793
|
const { isMobile } = useDeviceDetect();
|
|
11783
11794
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11784
|
-
(0,
|
|
11795
|
+
(0, import_react34.useEffect)(() => {
|
|
11785
11796
|
registerField(fieldId);
|
|
11786
11797
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11787
11798
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11806,7 +11817,7 @@ function RadioField(props) {
|
|
|
11806
11817
|
}
|
|
11807
11818
|
|
|
11808
11819
|
// packages/sdk/src/components/fields/CheckboxField/index.tsx
|
|
11809
|
-
var
|
|
11820
|
+
var import_react35 = require("react");
|
|
11810
11821
|
|
|
11811
11822
|
// packages/sdk/src/components/fields/CheckboxField/CheckboxFieldPC.tsx
|
|
11812
11823
|
var import_antd19 = require("antd");
|
|
@@ -11963,7 +11974,7 @@ function CheckboxField(props) {
|
|
|
11963
11974
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
11964
11975
|
const { isMobile } = useDeviceDetect();
|
|
11965
11976
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
11966
|
-
(0,
|
|
11977
|
+
(0, import_react35.useEffect)(() => {
|
|
11967
11978
|
registerField(fieldId);
|
|
11968
11979
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
11969
11980
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -11988,7 +11999,7 @@ function CheckboxField(props) {
|
|
|
11988
11999
|
}
|
|
11989
12000
|
|
|
11990
12001
|
// packages/sdk/src/components/fields/DateField/index.tsx
|
|
11991
|
-
var
|
|
12002
|
+
var import_react38 = require("react");
|
|
11992
12003
|
|
|
11993
12004
|
// packages/sdk/src/components/fields/DateField/DateFieldPC.tsx
|
|
11994
12005
|
var import_antd20 = require("antd");
|
|
@@ -12138,12 +12149,12 @@ function DateFieldPC({
|
|
|
12138
12149
|
}
|
|
12139
12150
|
|
|
12140
12151
|
// packages/sdk/src/components/fields/DateField/DateFieldMobile.tsx
|
|
12141
|
-
var
|
|
12152
|
+
var import_react37 = require("react");
|
|
12142
12153
|
var import_antd_mobile7 = require("antd-mobile");
|
|
12143
12154
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
12144
12155
|
|
|
12145
12156
|
// packages/sdk/src/components/fields/shared/MobileDatePicker.tsx
|
|
12146
|
-
var
|
|
12157
|
+
var import_react36 = __toESM(require("react"));
|
|
12147
12158
|
var import_antd_mobile5 = require("antd-mobile");
|
|
12148
12159
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
12149
12160
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
@@ -12241,7 +12252,7 @@ function MobileDateTimePickerView({
|
|
|
12241
12252
|
onChange
|
|
12242
12253
|
}) {
|
|
12243
12254
|
const precision = resolveTimePickerPrecision(dateFormat);
|
|
12244
|
-
const columns =
|
|
12255
|
+
const columns = import_react36.default.useMemo(
|
|
12245
12256
|
() => [getDateOptions(value, min, max), ...getTimePickerColumns(precision)],
|
|
12246
12257
|
[value, min, max, precision]
|
|
12247
12258
|
);
|
|
@@ -12279,12 +12290,12 @@ function DateFieldMobile({
|
|
|
12279
12290
|
const { formData, setFieldValue } = useFormContext();
|
|
12280
12291
|
const value = formData[fieldId];
|
|
12281
12292
|
const disabled = behavior === "DISABLED";
|
|
12282
|
-
const [visible, setVisible] = (0,
|
|
12283
|
-
const [mode, setMode] = (0,
|
|
12293
|
+
const [visible, setVisible] = (0, import_react37.useState)(false);
|
|
12294
|
+
const [mode, setMode] = (0, import_react37.useState)("date");
|
|
12284
12295
|
const format = getDateDisplayFormat(dateFormat, showTime);
|
|
12285
12296
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
12286
12297
|
const pickerValue = value && (0, import_dayjs7.default)(value).isValid() ? (0, import_dayjs7.default)(value).toDate() : /* @__PURE__ */ new Date();
|
|
12287
|
-
const [tempDate, setTempDate] = (0,
|
|
12298
|
+
const [tempDate, setTempDate] = (0, import_react37.useState)(pickerValue);
|
|
12288
12299
|
const { min, max } = getDateMinMax(dateRestriction);
|
|
12289
12300
|
const openPicker = () => {
|
|
12290
12301
|
if (disabled) return;
|
|
@@ -12421,7 +12432,7 @@ function DateField(props) {
|
|
|
12421
12432
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
12422
12433
|
const { isMobile } = useDeviceDetect();
|
|
12423
12434
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
12424
|
-
(0,
|
|
12435
|
+
(0, import_react38.useEffect)(() => {
|
|
12425
12436
|
registerField(fieldId);
|
|
12426
12437
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
12427
12438
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -12446,7 +12457,7 @@ function DateField(props) {
|
|
|
12446
12457
|
}
|
|
12447
12458
|
|
|
12448
12459
|
// packages/sdk/src/components/fields/CascadeDateField/index.tsx
|
|
12449
|
-
var
|
|
12460
|
+
var import_react40 = require("react");
|
|
12450
12461
|
|
|
12451
12462
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldPC.tsx
|
|
12452
12463
|
var import_antd21 = require("antd");
|
|
@@ -12502,7 +12513,7 @@ function CascadeDateFieldPC({
|
|
|
12502
12513
|
}
|
|
12503
12514
|
|
|
12504
12515
|
// packages/sdk/src/components/fields/CascadeDateField/CascadeDateFieldMobile.tsx
|
|
12505
|
-
var
|
|
12516
|
+
var import_react39 = require("react");
|
|
12506
12517
|
var import_antd_mobile8 = require("antd-mobile");
|
|
12507
12518
|
var import_dayjs9 = __toESM(require("dayjs"));
|
|
12508
12519
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
@@ -12520,11 +12531,11 @@ function CascadeDateFieldMobile({
|
|
|
12520
12531
|
const { formData, setFieldValue } = useFormContext();
|
|
12521
12532
|
const value = normalizeDateRangeValue(formData[fieldId]);
|
|
12522
12533
|
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,
|
|
12534
|
+
const [visible, setVisible] = (0, import_react39.useState)(false);
|
|
12535
|
+
const [tempRange, setTempRange] = (0, import_react39.useState)(null);
|
|
12536
|
+
const [timeStep, setTimeStep] = (0, import_react39.useState)("start");
|
|
12537
|
+
const [tempStart, setTempStart] = (0, import_react39.useState)(/* @__PURE__ */ new Date());
|
|
12538
|
+
const [tempEnd, setTempEnd] = (0, import_react39.useState)(/* @__PURE__ */ new Date());
|
|
12528
12539
|
const format = getDateDisplayFormat(dateFormat, showTime);
|
|
12529
12540
|
const inferredShowTime = shouldShowDateTime(dateFormat, showTime);
|
|
12530
12541
|
const startValue = value?.start && (0, import_dayjs9.default)(value.start).isValid() ? (0, import_dayjs9.default)(value.start).toDate() : void 0;
|
|
@@ -12688,7 +12699,7 @@ function CascadeDateField(props) {
|
|
|
12688
12699
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
12689
12700
|
const { isMobile } = useDeviceDetect();
|
|
12690
12701
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
12691
|
-
(0,
|
|
12702
|
+
(0, import_react40.useEffect)(() => {
|
|
12692
12703
|
registerField(fieldId);
|
|
12693
12704
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
12694
12705
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -12713,10 +12724,10 @@ function CascadeDateField(props) {
|
|
|
12713
12724
|
}
|
|
12714
12725
|
|
|
12715
12726
|
// packages/sdk/src/components/fields/AttachmentField/index.tsx
|
|
12716
|
-
var
|
|
12727
|
+
var import_react43 = require("react");
|
|
12717
12728
|
|
|
12718
12729
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldPC.tsx
|
|
12719
|
-
var
|
|
12730
|
+
var import_react41 = __toESM(require("react"));
|
|
12720
12731
|
var import_antd22 = require("antd");
|
|
12721
12732
|
|
|
12722
12733
|
// packages/sdk/src/components/fields/shared/fileTransfer.ts
|
|
@@ -12762,13 +12773,13 @@ function AttachmentFieldPC({
|
|
|
12762
12773
|
onChange
|
|
12763
12774
|
}) {
|
|
12764
12775
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
12765
|
-
const value =
|
|
12776
|
+
const value = import_react41.default.useMemo(
|
|
12766
12777
|
() => dedupeAttachmentItems(
|
|
12767
12778
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
12768
12779
|
),
|
|
12769
12780
|
[fieldId, formData]
|
|
12770
12781
|
);
|
|
12771
|
-
const valueRef =
|
|
12782
|
+
const valueRef = import_react41.default.useRef(value);
|
|
12772
12783
|
const disabled = behavior === "DISABLED";
|
|
12773
12784
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
12774
12785
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -12801,7 +12812,7 @@ function AttachmentFieldPC({
|
|
|
12801
12812
|
enabled: showPreview,
|
|
12802
12813
|
requireServerCapability: true
|
|
12803
12814
|
});
|
|
12804
|
-
|
|
12815
|
+
import_react41.default.useEffect(() => {
|
|
12805
12816
|
valueRef.current = value;
|
|
12806
12817
|
}, [value]);
|
|
12807
12818
|
const setValue = (items) => {
|
|
@@ -13051,7 +13062,7 @@ function AttachmentFieldPC({
|
|
|
13051
13062
|
}
|
|
13052
13063
|
|
|
13053
13064
|
// packages/sdk/src/components/fields/AttachmentField/AttachmentFieldMobile.tsx
|
|
13054
|
-
var
|
|
13065
|
+
var import_react42 = __toESM(require("react"));
|
|
13055
13066
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
13056
13067
|
var createLocalItem2 = (file) => {
|
|
13057
13068
|
const uid = createUid("attachment");
|
|
@@ -13087,14 +13098,14 @@ function AttachmentFieldMobile({
|
|
|
13087
13098
|
onChange
|
|
13088
13099
|
}) {
|
|
13089
13100
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13090
|
-
const value =
|
|
13101
|
+
const value = import_react42.default.useMemo(
|
|
13091
13102
|
() => dedupeAttachmentItems(
|
|
13092
13103
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13093
13104
|
),
|
|
13094
13105
|
[fieldId, formData]
|
|
13095
13106
|
);
|
|
13096
|
-
const valueRef =
|
|
13097
|
-
const inputRef =
|
|
13107
|
+
const valueRef = import_react42.default.useRef(value);
|
|
13108
|
+
const inputRef = import_react42.default.useRef(null);
|
|
13098
13109
|
const disabled = behavior === "DISABLED";
|
|
13099
13110
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13100
13111
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13127,7 +13138,7 @@ function AttachmentFieldMobile({
|
|
|
13127
13138
|
enabled: showPreview,
|
|
13128
13139
|
requireServerCapability: true
|
|
13129
13140
|
});
|
|
13130
|
-
|
|
13141
|
+
import_react42.default.useEffect(() => {
|
|
13131
13142
|
valueRef.current = value;
|
|
13132
13143
|
}, [value]);
|
|
13133
13144
|
const setValue = (items) => {
|
|
@@ -13461,7 +13472,7 @@ function AttachmentField(props) {
|
|
|
13461
13472
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
13462
13473
|
const { isMobile } = useDeviceDetect();
|
|
13463
13474
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
13464
|
-
(0,
|
|
13475
|
+
(0, import_react43.useEffect)(() => {
|
|
13465
13476
|
registerField(fieldId);
|
|
13466
13477
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
13467
13478
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -13486,10 +13497,10 @@ function AttachmentField(props) {
|
|
|
13486
13497
|
}
|
|
13487
13498
|
|
|
13488
13499
|
// packages/sdk/src/components/fields/ImageField/index.tsx
|
|
13489
|
-
var
|
|
13500
|
+
var import_react47 = require("react");
|
|
13490
13501
|
|
|
13491
13502
|
// packages/sdk/src/components/fields/ImageField/ImageFieldPC.tsx
|
|
13492
|
-
var
|
|
13503
|
+
var import_react44 = __toESM(require("react"));
|
|
13493
13504
|
var import_antd23 = require("antd");
|
|
13494
13505
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
13495
13506
|
var createLocalItem3 = (file) => {
|
|
@@ -13508,9 +13519,9 @@ var createLocalItem3 = (file) => {
|
|
|
13508
13519
|
};
|
|
13509
13520
|
};
|
|
13510
13521
|
function ImageThumbContent({ item }) {
|
|
13511
|
-
const [imageFailed, setImageFailed] =
|
|
13522
|
+
const [imageFailed, setImageFailed] = import_react44.default.useState(false);
|
|
13512
13523
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
13513
|
-
|
|
13524
|
+
import_react44.default.useEffect(() => {
|
|
13514
13525
|
setImageFailed(false);
|
|
13515
13526
|
}, [src]);
|
|
13516
13527
|
if (src && !imageFailed) {
|
|
@@ -13541,13 +13552,13 @@ function ImageFieldPC({
|
|
|
13541
13552
|
onChange
|
|
13542
13553
|
}) {
|
|
13543
13554
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13544
|
-
const value =
|
|
13555
|
+
const value = import_react44.default.useMemo(
|
|
13545
13556
|
() => dedupeAttachmentItems(
|
|
13546
13557
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13547
13558
|
),
|
|
13548
13559
|
[fieldId, formData]
|
|
13549
13560
|
);
|
|
13550
|
-
const valueRef =
|
|
13561
|
+
const valueRef = import_react44.default.useRef(value);
|
|
13551
13562
|
const disabled = behavior === "DISABLED";
|
|
13552
13563
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13553
13564
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13582,7 +13593,7 @@ function ImageFieldPC({
|
|
|
13582
13593
|
enabled: showPreviewIcon,
|
|
13583
13594
|
requireServerCapability: false
|
|
13584
13595
|
});
|
|
13585
|
-
|
|
13596
|
+
import_react44.default.useEffect(() => {
|
|
13586
13597
|
valueRef.current = value;
|
|
13587
13598
|
}, [value]);
|
|
13588
13599
|
const setValue = (items) => {
|
|
@@ -13847,7 +13858,7 @@ function ImageFieldPC({
|
|
|
13847
13858
|
}
|
|
13848
13859
|
|
|
13849
13860
|
// packages/sdk/src/components/fields/ImageField/ImageFieldMobile.tsx
|
|
13850
|
-
var
|
|
13861
|
+
var import_react45 = __toESM(require("react"));
|
|
13851
13862
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
13852
13863
|
var createLocalItem4 = (file) => {
|
|
13853
13864
|
const uid = createUid("image");
|
|
@@ -13865,9 +13876,9 @@ var createLocalItem4 = (file) => {
|
|
|
13865
13876
|
};
|
|
13866
13877
|
};
|
|
13867
13878
|
function ImageThumbContent2({ item }) {
|
|
13868
|
-
const [imageFailed, setImageFailed] =
|
|
13879
|
+
const [imageFailed, setImageFailed] = import_react45.default.useState(false);
|
|
13869
13880
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
13870
|
-
|
|
13881
|
+
import_react45.default.useEffect(() => {
|
|
13871
13882
|
setImageFailed(false);
|
|
13872
13883
|
}, [src]);
|
|
13873
13884
|
if (src && !imageFailed) {
|
|
@@ -13897,14 +13908,14 @@ function ImageFieldMobile({
|
|
|
13897
13908
|
onChange
|
|
13898
13909
|
}) {
|
|
13899
13910
|
const { formData, setFieldValue, api, config } = useFormContext();
|
|
13900
|
-
const value =
|
|
13911
|
+
const value = import_react45.default.useMemo(
|
|
13901
13912
|
() => dedupeAttachmentItems(
|
|
13902
13913
|
Array.isArray(formData[fieldId]) ? formData[fieldId] : []
|
|
13903
13914
|
),
|
|
13904
13915
|
[fieldId, formData]
|
|
13905
13916
|
);
|
|
13906
|
-
const valueRef =
|
|
13907
|
-
const inputRef =
|
|
13917
|
+
const valueRef = import_react45.default.useRef(value);
|
|
13918
|
+
const inputRef = import_react45.default.useRef(null);
|
|
13908
13919
|
const disabled = behavior === "DISABLED";
|
|
13909
13920
|
const fieldUploadProvider = uploadProvider || (storageCode ? "oss" : config.defaultUploadProvider || "platform");
|
|
13910
13921
|
const fieldUploadOptions = fieldUploadProvider === "builtin-oss" ? {
|
|
@@ -13936,7 +13947,7 @@ function ImageFieldMobile({
|
|
|
13936
13947
|
enabled: showPreviewIcon,
|
|
13937
13948
|
requireServerCapability: false
|
|
13938
13949
|
});
|
|
13939
|
-
|
|
13950
|
+
import_react45.default.useEffect(() => {
|
|
13940
13951
|
valueRef.current = value;
|
|
13941
13952
|
}, [value]);
|
|
13942
13953
|
const setValue = (items) => {
|
|
@@ -14103,14 +14114,14 @@ function ImageFieldMobile({
|
|
|
14103
14114
|
}
|
|
14104
14115
|
|
|
14105
14116
|
// packages/sdk/src/components/fields/ImageField/ImageFieldReadonly.tsx
|
|
14106
|
-
var
|
|
14117
|
+
var import_react46 = __toESM(require("react"));
|
|
14107
14118
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
14108
14119
|
var getTicketUrl2 = (ticket, fallback) => typeof ticket === "string" ? ticket : ticket?.previewUrl || ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || fallback;
|
|
14109
14120
|
var isDirectStorageItem3 = (item) => item.provider === "oss" || item.uploadProvider === "oss" || item.uploadProvider === "builtin-oss" || Boolean(item.storageCode);
|
|
14110
14121
|
function ImageThumbContent3({ item, testId }) {
|
|
14111
|
-
const [imageFailed, setImageFailed] =
|
|
14122
|
+
const [imageFailed, setImageFailed] = import_react46.default.useState(false);
|
|
14112
14123
|
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
14113
|
-
|
|
14124
|
+
import_react46.default.useEffect(() => {
|
|
14114
14125
|
setImageFailed(false);
|
|
14115
14126
|
}, [src]);
|
|
14116
14127
|
if (src && !imageFailed) {
|
|
@@ -14279,7 +14290,7 @@ function ImageField(props) {
|
|
|
14279
14290
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
14280
14291
|
const { isMobile } = useDeviceDetect();
|
|
14281
14292
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
14282
|
-
(0,
|
|
14293
|
+
(0, import_react47.useEffect)(() => {
|
|
14283
14294
|
registerField(fieldId);
|
|
14284
14295
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
14285
14296
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -14304,10 +14315,10 @@ function ImageField(props) {
|
|
|
14304
14315
|
}
|
|
14305
14316
|
|
|
14306
14317
|
// packages/sdk/src/components/fields/SubFormField/index.tsx
|
|
14307
|
-
var
|
|
14318
|
+
var import_react49 = require("react");
|
|
14308
14319
|
|
|
14309
14320
|
// packages/sdk/src/components/fields/SubFormField/SubFormCell.tsx
|
|
14310
|
-
var
|
|
14321
|
+
var import_react48 = require("react");
|
|
14311
14322
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
14312
14323
|
var stringifyFallbackValue = (value) => {
|
|
14313
14324
|
if (value === void 0 || value === null) return "";
|
|
@@ -14328,7 +14339,7 @@ function SubFormCell({
|
|
|
14328
14339
|
const scopedFieldId = `${parentFieldId}.${rowIndex}.${column.fieldId}`;
|
|
14329
14340
|
const cellValue = row[column.fieldId];
|
|
14330
14341
|
const resolvedBehavior = behavior === "DISABLED" || behavior === "READONLY" ? behavior : column.behavior ?? behavior ?? "NORMAL";
|
|
14331
|
-
const childContext = (0,
|
|
14342
|
+
const childContext = (0, import_react48.useMemo)(
|
|
14332
14343
|
() => ({
|
|
14333
14344
|
...parentContext,
|
|
14334
14345
|
formData: {
|
|
@@ -14622,7 +14633,7 @@ function SubFormField(props) {
|
|
|
14622
14633
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
14623
14634
|
const { isMobile } = useDeviceDetect();
|
|
14624
14635
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
14625
|
-
(0,
|
|
14636
|
+
(0, import_react49.useEffect)(() => {
|
|
14626
14637
|
registerField(fieldId);
|
|
14627
14638
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
14628
14639
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -14647,10 +14658,10 @@ function SubFormField(props) {
|
|
|
14647
14658
|
}
|
|
14648
14659
|
|
|
14649
14660
|
// packages/sdk/src/components/fields/UserSelectField/index.tsx
|
|
14650
|
-
var
|
|
14661
|
+
var import_react53 = require("react");
|
|
14651
14662
|
|
|
14652
14663
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldPC.tsx
|
|
14653
|
-
var
|
|
14664
|
+
var import_react50 = require("react");
|
|
14654
14665
|
var import_antd24 = require("antd");
|
|
14655
14666
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
14656
14667
|
function UserSelectFieldPC({
|
|
@@ -14670,20 +14681,20 @@ function UserSelectFieldPC({
|
|
|
14670
14681
|
}) {
|
|
14671
14682
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14672
14683
|
const rawValue = formData[fieldId];
|
|
14673
|
-
const value = (0,
|
|
14684
|
+
const value = (0, import_react50.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14674
14685
|
const disabled = behavior === "DISABLED";
|
|
14675
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
14686
|
+
const [optionsSource, setOptionsSource] = (0, import_react50.useState)(
|
|
14676
14687
|
() => dataSource.map(normalizeUser)
|
|
14677
14688
|
);
|
|
14678
|
-
const [loading, setLoading] = (0,
|
|
14679
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
14689
|
+
const [loading, setLoading] = (0, import_react50.useState)(false);
|
|
14690
|
+
const [pickerOpen, setPickerOpen] = (0, import_react50.useState)(false);
|
|
14680
14691
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
14681
|
-
(0,
|
|
14692
|
+
(0, import_react50.useEffect)(() => {
|
|
14682
14693
|
if (dataSource.length) {
|
|
14683
14694
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
14684
14695
|
}
|
|
14685
14696
|
}, [dataSource]);
|
|
14686
|
-
(0,
|
|
14697
|
+
(0, import_react50.useEffect)(() => {
|
|
14687
14698
|
setOptionsSource((current) => {
|
|
14688
14699
|
const merged = [...current];
|
|
14689
14700
|
let changed = false;
|
|
@@ -14696,7 +14707,7 @@ function UserSelectFieldPC({
|
|
|
14696
14707
|
return changed ? merged : current;
|
|
14697
14708
|
});
|
|
14698
14709
|
}, [value]);
|
|
14699
|
-
(0,
|
|
14710
|
+
(0, import_react50.useEffect)(() => {
|
|
14700
14711
|
const missing = value.filter((item) => getUserId(item) && getUserNameLikeId(item));
|
|
14701
14712
|
if (missing.length === 0) return;
|
|
14702
14713
|
let cancelled = false;
|
|
@@ -14739,7 +14750,7 @@ function UserSelectFieldPC({
|
|
|
14739
14750
|
setLoading(false);
|
|
14740
14751
|
}
|
|
14741
14752
|
};
|
|
14742
|
-
(0,
|
|
14753
|
+
(0, import_react50.useEffect)(() => {
|
|
14743
14754
|
fetchUsers();
|
|
14744
14755
|
}, []);
|
|
14745
14756
|
const handleChange = (selectedIds) => {
|
|
@@ -14764,7 +14775,7 @@ function UserSelectFieldPC({
|
|
|
14764
14775
|
setFieldValue(fieldId, normalized);
|
|
14765
14776
|
onChange?.(normalized);
|
|
14766
14777
|
};
|
|
14767
|
-
const options = (0,
|
|
14778
|
+
const options = (0, import_react50.useMemo)(
|
|
14768
14779
|
() => optionsSource.map((u) => ({
|
|
14769
14780
|
value: getUserId(u),
|
|
14770
14781
|
label: formatUserDisplay(u, displayFormat)
|
|
@@ -14828,7 +14839,7 @@ function getUserNameLikeId(user) {
|
|
|
14828
14839
|
}
|
|
14829
14840
|
|
|
14830
14841
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldMobile.tsx
|
|
14831
|
-
var
|
|
14842
|
+
var import_react51 = require("react");
|
|
14832
14843
|
var MobileAntd2 = __toESM(require("antd-mobile"));
|
|
14833
14844
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
14834
14845
|
var getMobilePopup = () => {
|
|
@@ -14853,19 +14864,19 @@ function UserSelectFieldMobile({
|
|
|
14853
14864
|
}) {
|
|
14854
14865
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14855
14866
|
const rawValue = formData[fieldId];
|
|
14856
|
-
const value = (0,
|
|
14867
|
+
const value = (0, import_react51.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14857
14868
|
const disabled = behavior === "DISABLED";
|
|
14858
|
-
const [showPicker, setShowPicker] = (0,
|
|
14859
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
14869
|
+
const [showPicker, setShowPicker] = (0, import_react51.useState)(false);
|
|
14870
|
+
const [optionsSource, setOptionsSource] = (0, import_react51.useState)(
|
|
14860
14871
|
() => dataSource.map(normalizeUser)
|
|
14861
14872
|
);
|
|
14862
14873
|
const pickerDataSource = dataSource.length > 0 ? dataSource : void 0;
|
|
14863
|
-
(0,
|
|
14874
|
+
(0, import_react51.useEffect)(() => {
|
|
14864
14875
|
if (dataSource.length) {
|
|
14865
14876
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
14866
14877
|
}
|
|
14867
14878
|
}, [dataSource]);
|
|
14868
|
-
(0,
|
|
14879
|
+
(0, import_react51.useEffect)(() => {
|
|
14869
14880
|
setOptionsSource((current) => {
|
|
14870
14881
|
const merged = [...current];
|
|
14871
14882
|
let changed = false;
|
|
@@ -14961,7 +14972,7 @@ function UserSelectFieldMobile({
|
|
|
14961
14972
|
}
|
|
14962
14973
|
|
|
14963
14974
|
// packages/sdk/src/components/fields/UserSelectField/UserSelectFieldReadonly.tsx
|
|
14964
|
-
var
|
|
14975
|
+
var import_react52 = require("react");
|
|
14965
14976
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
14966
14977
|
function UserSelectFieldReadonly({
|
|
14967
14978
|
fieldId,
|
|
@@ -14970,8 +14981,8 @@ function UserSelectFieldReadonly({
|
|
|
14970
14981
|
}) {
|
|
14971
14982
|
const { formData, setFieldValue, api } = useFormContext();
|
|
14972
14983
|
const rawValue = formData[fieldId];
|
|
14973
|
-
const value = (0,
|
|
14974
|
-
(0,
|
|
14984
|
+
const value = (0, import_react52.useMemo)(() => normalizeUserArray(rawValue), [rawValue]);
|
|
14985
|
+
(0, import_react52.useEffect)(() => {
|
|
14975
14986
|
const missing = value.filter((item) => getUserNameLikeId2(item));
|
|
14976
14987
|
if (missing.length === 0) return;
|
|
14977
14988
|
let cancelled = false;
|
|
@@ -15023,7 +15034,7 @@ function UserSelectField(props) {
|
|
|
15023
15034
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
15024
15035
|
const { isMobile } = useDeviceDetect();
|
|
15025
15036
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15026
|
-
(0,
|
|
15037
|
+
(0, import_react53.useEffect)(() => {
|
|
15027
15038
|
registerField(fieldId);
|
|
15028
15039
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15029
15040
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -15048,10 +15059,10 @@ function UserSelectField(props) {
|
|
|
15048
15059
|
}
|
|
15049
15060
|
|
|
15050
15061
|
// packages/sdk/src/components/fields/DepartmentSelectField/index.tsx
|
|
15051
|
-
var
|
|
15062
|
+
var import_react58 = require("react");
|
|
15052
15063
|
|
|
15053
15064
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldPC.tsx
|
|
15054
|
-
var
|
|
15065
|
+
var import_react55 = require("react");
|
|
15055
15066
|
var import_antd26 = require("antd");
|
|
15056
15067
|
|
|
15057
15068
|
// packages/sdk/src/components/fields/shared/departmentSearch.ts
|
|
@@ -15070,7 +15081,7 @@ function getDepartmentPathText(department, separator = "/") {
|
|
|
15070
15081
|
}
|
|
15071
15082
|
|
|
15072
15083
|
// packages/sdk/src/components/fields/shared/DepartmentPicker.tsx
|
|
15073
|
-
var
|
|
15084
|
+
var import_react54 = require("react");
|
|
15074
15085
|
var import_antd25 = require("antd");
|
|
15075
15086
|
var import_icons12 = require("@ant-design/icons");
|
|
15076
15087
|
var MobileAntd3 = __toESM(require("antd-mobile"));
|
|
@@ -15123,20 +15134,20 @@ function DepartmentPickerPanel({
|
|
|
15123
15134
|
flatNodes,
|
|
15124
15135
|
loadChildren
|
|
15125
15136
|
} = 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,
|
|
15137
|
+
const [keyword, setKeyword] = (0, import_react54.useState)("");
|
|
15138
|
+
const [selected, setSelected] = (0, import_react54.useState)(() => normalizeSelection(value));
|
|
15139
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react54.useState)([]);
|
|
15140
|
+
const [currentDeptId, setCurrentDeptId] = (0, import_react54.useState)(null);
|
|
15141
|
+
const [remoteSearchResults, setRemoteSearchResults] = (0, import_react54.useState)([]);
|
|
15142
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = (0, import_react54.useState)(false);
|
|
15143
|
+
const [remoteSearchError, setRemoteSearchError] = (0, import_react54.useState)("");
|
|
15144
|
+
const searchSeqRef = (0, import_react54.useRef)(0);
|
|
15134
15145
|
const selectedIds = selected.map((item) => item.id);
|
|
15135
15146
|
const MobileSearchBar = getMobileComponent2("SearchBar");
|
|
15136
15147
|
const trimmedKeyword = keyword.trim();
|
|
15137
15148
|
const canRemoteSearch = showSearch && searchScope === "all" && trimmedKeyword.length >= searchMinLength && canSearchAllDepartments(api, treeData);
|
|
15138
15149
|
const spinning = treeLoading || remoteSearchLoading;
|
|
15139
|
-
(0,
|
|
15150
|
+
(0, import_react54.useEffect)(() => {
|
|
15140
15151
|
if (!canRemoteSearch) {
|
|
15141
15152
|
searchSeqRef.current += 1;
|
|
15142
15153
|
setRemoteSearchResults([]);
|
|
@@ -15171,11 +15182,11 @@ function DepartmentPickerPanel({
|
|
|
15171
15182
|
window.clearTimeout(timer);
|
|
15172
15183
|
};
|
|
15173
15184
|
}, [api, canRemoteSearch, searchDebounceMs, trimmedKeyword]);
|
|
15174
|
-
const filteredTreeData = (0,
|
|
15185
|
+
const filteredTreeData = (0, import_react54.useMemo)(
|
|
15175
15186
|
() => showSearch ? matchSearch(loadedTreeData, trimmedKeyword) : loadedTreeData,
|
|
15176
15187
|
[loadedTreeData, showSearch, trimmedKeyword]
|
|
15177
15188
|
);
|
|
15178
|
-
const currentPath = (0,
|
|
15189
|
+
const currentPath = (0, import_react54.useMemo)(() => {
|
|
15179
15190
|
if (!currentDeptId) return [];
|
|
15180
15191
|
const path = [];
|
|
15181
15192
|
let cursor = currentDeptId;
|
|
@@ -15187,7 +15198,7 @@ function DepartmentPickerPanel({
|
|
|
15187
15198
|
}
|
|
15188
15199
|
return path;
|
|
15189
15200
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
15190
|
-
const mobileList = (0,
|
|
15201
|
+
const mobileList = (0, import_react54.useMemo)(() => {
|
|
15191
15202
|
if (canRemoteSearch) {
|
|
15192
15203
|
return remoteSearchResults;
|
|
15193
15204
|
}
|
|
@@ -15505,18 +15516,18 @@ function DepartmentSelectFieldPC({
|
|
|
15505
15516
|
}) {
|
|
15506
15517
|
const { formData, setFieldValue, api } = useFormContext();
|
|
15507
15518
|
const rawValue = formData[fieldId];
|
|
15508
|
-
const value = (0,
|
|
15519
|
+
const value = (0, import_react55.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15509
15520
|
const disabled = behavior === "DISABLED";
|
|
15510
15521
|
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,
|
|
15522
|
+
const remoteLoadedRef = (0, import_react55.useRef)(false);
|
|
15523
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react55.useState)(configuredTreeData);
|
|
15524
|
+
const [pickerOpen, setPickerOpen] = (0, import_react55.useState)(false);
|
|
15525
|
+
const [searchKeyword, setSearchKeyword] = (0, import_react55.useState)("");
|
|
15526
|
+
const [remoteSearchResults, setRemoteSearchResults] = (0, import_react55.useState)([]);
|
|
15527
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = (0, import_react55.useState)(false);
|
|
15528
|
+
const [selectedPathMap, setSelectedPathMap] = (0, import_react55.useState)({});
|
|
15529
|
+
const searchSeqRef = (0, import_react55.useRef)(0);
|
|
15530
|
+
(0, import_react55.useEffect)(() => {
|
|
15520
15531
|
if (configuredTreeData.length) {
|
|
15521
15532
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
15522
15533
|
return;
|
|
@@ -15529,7 +15540,7 @@ function DepartmentSelectFieldPC({
|
|
|
15529
15540
|
}, [api, configuredTreeData]);
|
|
15530
15541
|
const trimmedSearchKeyword = searchKeyword.trim();
|
|
15531
15542
|
const canRemoteSearch = showSearch && searchScope === "all" && trimmedSearchKeyword.length >= searchMinLength && canSearchAllDepartments(api, configuredTreeData);
|
|
15532
|
-
(0,
|
|
15543
|
+
(0, import_react55.useEffect)(() => {
|
|
15533
15544
|
if (!canRemoteSearch) {
|
|
15534
15545
|
searchSeqRef.current += 1;
|
|
15535
15546
|
setRemoteSearchResults([]);
|
|
@@ -15563,7 +15574,7 @@ function DepartmentSelectFieldPC({
|
|
|
15563
15574
|
}, [api, canRemoteSearch, searchDebounceMs, trimmedSearchKeyword]);
|
|
15564
15575
|
const scopedTreeData = filterTreeByScope(loadedTreeData, scopeType, specifiedDepts);
|
|
15565
15576
|
const allDepts = flattenDepartments(scopedTreeData);
|
|
15566
|
-
const scopedRemoteSearchResults = (0,
|
|
15577
|
+
const scopedRemoteSearchResults = (0, import_react55.useMemo)(() => {
|
|
15567
15578
|
if (scopeType !== "specified" || !specifiedDepts?.length) {
|
|
15568
15579
|
return remoteSearchResults;
|
|
15569
15580
|
}
|
|
@@ -15574,7 +15585,7 @@ function DepartmentSelectFieldPC({
|
|
|
15574
15585
|
return node.path?.some((item) => specifiedSet.has(item.id));
|
|
15575
15586
|
});
|
|
15576
15587
|
}, [remoteSearchResults, scopeType, specifiedDepts]);
|
|
15577
|
-
const remoteDeptMap = (0,
|
|
15588
|
+
const remoteDeptMap = (0, import_react55.useMemo)(() => {
|
|
15578
15589
|
const map = /* @__PURE__ */ new Map();
|
|
15579
15590
|
scopedRemoteSearchResults.forEach((node) => map.set(getDepartmentId(node), node));
|
|
15580
15591
|
return map;
|
|
@@ -15703,7 +15714,7 @@ function DepartmentSelectFieldPC({
|
|
|
15703
15714
|
}
|
|
15704
15715
|
|
|
15705
15716
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldMobile.tsx
|
|
15706
|
-
var
|
|
15717
|
+
var import_react56 = require("react");
|
|
15707
15718
|
var MobileAntd4 = __toESM(require("antd-mobile"));
|
|
15708
15719
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
15709
15720
|
var EMPTY_TREE_DATA2 = [];
|
|
@@ -15738,13 +15749,13 @@ function DepartmentSelectFieldMobile({
|
|
|
15738
15749
|
}) {
|
|
15739
15750
|
const { formData, setFieldValue, api } = useFormContext();
|
|
15740
15751
|
const rawValue = formData[fieldId];
|
|
15741
|
-
const value = (0,
|
|
15752
|
+
const value = (0, import_react56.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15742
15753
|
const disabled = behavior === "DISABLED";
|
|
15743
|
-
const [showPicker, setShowPicker] = (0,
|
|
15754
|
+
const [showPicker, setShowPicker] = (0, import_react56.useState)(false);
|
|
15744
15755
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA2;
|
|
15745
|
-
const remoteLoadedRef = (0,
|
|
15746
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
15747
|
-
(0,
|
|
15756
|
+
const remoteLoadedRef = (0, import_react56.useRef)(false);
|
|
15757
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react56.useState)(configuredTreeData);
|
|
15758
|
+
(0, import_react56.useEffect)(() => {
|
|
15748
15759
|
if (configuredTreeData.length) {
|
|
15749
15760
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
15750
15761
|
}
|
|
@@ -15843,7 +15854,7 @@ function DepartmentSelectFieldMobile({
|
|
|
15843
15854
|
}
|
|
15844
15855
|
|
|
15845
15856
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldReadonly.tsx
|
|
15846
|
-
var
|
|
15857
|
+
var import_react57 = require("react");
|
|
15847
15858
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
15848
15859
|
function DepartmentSelectFieldReadonly({
|
|
15849
15860
|
fieldId,
|
|
@@ -15853,7 +15864,7 @@ function DepartmentSelectFieldReadonly({
|
|
|
15853
15864
|
}) {
|
|
15854
15865
|
const { formData } = useFormContext();
|
|
15855
15866
|
const rawValue = formData[fieldId];
|
|
15856
|
-
const value = (0,
|
|
15867
|
+
const value = (0, import_react57.useMemo)(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
15857
15868
|
const display = value.length > 0 ? value.map(
|
|
15858
15869
|
(d) => showFullPath ? getDepartmentFullPath(getDepartmentId(d), treeData) || getDepartmentName(d) : getDepartmentName(d)
|
|
15859
15870
|
).join(", ") : "--";
|
|
@@ -15884,7 +15895,7 @@ function DepartmentSelectField(props) {
|
|
|
15884
15895
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
15885
15896
|
const { isMobile } = useDeviceDetect();
|
|
15886
15897
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15887
|
-
(0,
|
|
15898
|
+
(0, import_react58.useEffect)(() => {
|
|
15888
15899
|
registerField(fieldId);
|
|
15889
15900
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15890
15901
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -15909,7 +15920,7 @@ function DepartmentSelectField(props) {
|
|
|
15909
15920
|
}
|
|
15910
15921
|
|
|
15911
15922
|
// packages/sdk/src/components/fields/CascadeSelectField/index.tsx
|
|
15912
|
-
var
|
|
15923
|
+
var import_react59 = require("react");
|
|
15913
15924
|
var import_antd27 = require("antd");
|
|
15914
15925
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
15915
15926
|
var toValuePath = (value, multiple) => {
|
|
@@ -15948,7 +15959,7 @@ function CascadeSelectField(props) {
|
|
|
15948
15959
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
15949
15960
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
15950
15961
|
const value = formData[fieldId] ?? (multiple ? [] : []);
|
|
15951
|
-
(0,
|
|
15962
|
+
(0, import_react59.useEffect)(() => {
|
|
15952
15963
|
registerField(fieldId);
|
|
15953
15964
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
15954
15965
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -16001,7 +16012,7 @@ function CascadeSelectField(props) {
|
|
|
16001
16012
|
}
|
|
16002
16013
|
|
|
16003
16014
|
// packages/sdk/src/components/fields/AddressField/index.tsx
|
|
16004
|
-
var
|
|
16015
|
+
var import_react60 = require("react");
|
|
16005
16016
|
var import_antd28 = require("antd");
|
|
16006
16017
|
var MobileAntd5 = __toESM(require("antd-mobile"));
|
|
16007
16018
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
@@ -16147,41 +16158,41 @@ function AddressField(props) {
|
|
|
16147
16158
|
const { isMobile } = useDeviceDetect();
|
|
16148
16159
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
16149
16160
|
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,
|
|
16161
|
+
const value = (0, import_react60.useMemo)(() => normalizeAddressValue(rawValue), [rawValue]);
|
|
16162
|
+
const [options, setOptions] = (0, import_react60.useState)([]);
|
|
16163
|
+
const [loadingRoots, setLoadingRoots] = (0, import_react60.useState)(false);
|
|
16164
|
+
const [mobileOpen, setMobileOpen] = (0, import_react60.useState)(false);
|
|
16165
|
+
const [mobileLevelIndex, setMobileLevelIndex] = (0, import_react60.useState)(0);
|
|
16166
|
+
const [mobileOptions, setMobileOptions] = (0, import_react60.useState)([]);
|
|
16167
|
+
const [mobileLoading, setMobileLoading] = (0, import_react60.useState)(false);
|
|
16168
|
+
const [tempValue, setTempValue] = (0, import_react60.useState)();
|
|
16158
16169
|
const depth = modeDepth(mode);
|
|
16159
|
-
const levels = (0,
|
|
16160
|
-
const valuePath = (0,
|
|
16161
|
-
const displayOptions = (0,
|
|
16170
|
+
const levels = (0, import_react60.useMemo)(() => activeLevels(mode), [mode]);
|
|
16171
|
+
const valuePath = (0, import_react60.useMemo)(() => valueToPath(value, levels), [levels, value]);
|
|
16172
|
+
const displayOptions = (0, import_react60.useMemo)(
|
|
16162
16173
|
() => mergeValuePathIntoOptions(options, value, levels, depth),
|
|
16163
16174
|
[depth, levels, options, value]
|
|
16164
16175
|
);
|
|
16165
16176
|
const detailEnabled = mode === "province-city-district-street-detail";
|
|
16166
16177
|
const disabled = behavior === "DISABLED";
|
|
16167
16178
|
const MobilePopup = getMobileComponent3("Popup");
|
|
16168
|
-
(0,
|
|
16179
|
+
(0, import_react60.useEffect)(() => {
|
|
16169
16180
|
registerField(fieldId);
|
|
16170
16181
|
return () => unregisterField(fieldId);
|
|
16171
16182
|
}, [fieldId, registerField, unregisterField]);
|
|
16172
|
-
(0,
|
|
16183
|
+
(0, import_react60.useEffect)(() => {
|
|
16173
16184
|
if (defaultValue !== void 0 && rawValue === void 0) {
|
|
16174
16185
|
setFieldValue(fieldId, defaultValue);
|
|
16175
16186
|
}
|
|
16176
16187
|
}, [defaultValue, fieldId, rawValue, setFieldValue]);
|
|
16177
|
-
const loadDivisions = (0,
|
|
16188
|
+
const loadDivisions = (0, import_react60.useCallback)(
|
|
16178
16189
|
async (parentAdcode, level, index) => {
|
|
16179
16190
|
const list = await api.getChinaDivisions(parentAdcode);
|
|
16180
16191
|
return list.map((item) => normalizeDivision(item, level, depth, index));
|
|
16181
16192
|
},
|
|
16182
16193
|
[api, depth]
|
|
16183
16194
|
);
|
|
16184
|
-
(0,
|
|
16195
|
+
(0, import_react60.useEffect)(() => {
|
|
16185
16196
|
let mounted = true;
|
|
16186
16197
|
setLoadingRoots(true);
|
|
16187
16198
|
loadDivisions(void 0, "province", 0).then((nextOptions) => {
|
|
@@ -16193,7 +16204,7 @@ function AddressField(props) {
|
|
|
16193
16204
|
mounted = false;
|
|
16194
16205
|
};
|
|
16195
16206
|
}, [loadDivisions]);
|
|
16196
|
-
(0,
|
|
16207
|
+
(0, import_react60.useEffect)(() => {
|
|
16197
16208
|
if (!value) return;
|
|
16198
16209
|
let cancelled = false;
|
|
16199
16210
|
const hydrateMissingLabels = async () => {
|
|
@@ -16229,7 +16240,7 @@ function AddressField(props) {
|
|
|
16229
16240
|
cancelled = true;
|
|
16230
16241
|
};
|
|
16231
16242
|
}, [fieldId, levels, loadDivisions, setFieldValue, value]);
|
|
16232
|
-
(0,
|
|
16243
|
+
(0, import_react60.useEffect)(() => {
|
|
16233
16244
|
if (!mobileOpen) return;
|
|
16234
16245
|
const level = levels[mobileLevelIndex] || "province";
|
|
16235
16246
|
const parentLevel = levels[mobileLevelIndex - 1];
|
|
@@ -16409,7 +16420,7 @@ function AddressField(props) {
|
|
|
16409
16420
|
}
|
|
16410
16421
|
|
|
16411
16422
|
// packages/sdk/src/components/fields/AssociationFormField/index.tsx
|
|
16412
|
-
var
|
|
16423
|
+
var import_react61 = require("react");
|
|
16413
16424
|
var import_antd29 = require("antd");
|
|
16414
16425
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
16415
16426
|
var DEFAULT_PAGE_SIZE = 10;
|
|
@@ -16472,45 +16483,45 @@ function AssociationFormField(props) {
|
|
|
16472
16483
|
const { isMobile } = useDeviceDetect();
|
|
16473
16484
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
16474
16485
|
const rawValue = formData[fieldId];
|
|
16475
|
-
const value = (0,
|
|
16486
|
+
const value = (0, import_react61.useMemo)(() => normalizeValues(rawValue), [rawValue]);
|
|
16476
16487
|
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,
|
|
16488
|
+
const [options, setOptions] = (0, import_react61.useState)([]);
|
|
16489
|
+
const [selectLoading, setSelectLoading] = (0, import_react61.useState)(false);
|
|
16490
|
+
const [selectorOpen, setSelectorOpen] = (0, import_react61.useState)(false);
|
|
16491
|
+
const [tableLoading, setTableLoading] = (0, import_react61.useState)(false);
|
|
16492
|
+
const [tableData, setTableData] = (0, import_react61.useState)([]);
|
|
16493
|
+
const [keyword, setKeyword] = (0, import_react61.useState)("");
|
|
16494
|
+
const [pagination, setPagination] = (0, import_react61.useState)({
|
|
16484
16495
|
current: 1,
|
|
16485
16496
|
pageSize: DEFAULT_PAGE_SIZE,
|
|
16486
16497
|
total: 0
|
|
16487
16498
|
});
|
|
16488
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
16489
|
-
const [selectedRecords, setSelectedRecords] = (0,
|
|
16490
|
-
const formDataRef = (0,
|
|
16491
|
-
const associationFormRef = (0,
|
|
16492
|
-
(0,
|
|
16499
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react61.useState)([]);
|
|
16500
|
+
const [selectedRecords, setSelectedRecords] = (0, import_react61.useState)([]);
|
|
16501
|
+
const formDataRef = (0, import_react61.useRef)(formData);
|
|
16502
|
+
const associationFormRef = (0, import_react61.useRef)(associationForm);
|
|
16503
|
+
(0, import_react61.useEffect)(() => {
|
|
16493
16504
|
registerField(fieldId);
|
|
16494
16505
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
16495
16506
|
setFieldValue(fieldId, normalizeValues(defaultValue));
|
|
16496
16507
|
}
|
|
16497
16508
|
return () => unregisterField(fieldId);
|
|
16498
16509
|
}, [fieldId]);
|
|
16499
|
-
(0,
|
|
16510
|
+
(0, import_react61.useEffect)(() => {
|
|
16500
16511
|
formDataRef.current = formData;
|
|
16501
16512
|
}, [formData]);
|
|
16502
|
-
(0,
|
|
16513
|
+
(0, import_react61.useEffect)(() => {
|
|
16503
16514
|
associationFormRef.current = associationForm;
|
|
16504
16515
|
}, [associationForm]);
|
|
16505
16516
|
const associationAppType = associationForm?.appType;
|
|
16506
16517
|
const associationFormUuid = associationForm?.formUuid;
|
|
16507
16518
|
const associationMainFieldId = associationForm?.mainFieldId;
|
|
16508
16519
|
const canQuery = Boolean(associationAppType && associationFormUuid);
|
|
16509
|
-
const filterRulesKey = (0,
|
|
16520
|
+
const filterRulesKey = (0, import_react61.useMemo)(
|
|
16510
16521
|
() => stableSerialize(associationForm?.dataFilterRules || []),
|
|
16511
16522
|
[associationForm?.dataFilterRules]
|
|
16512
16523
|
);
|
|
16513
|
-
const currentFieldFilterKey = (0,
|
|
16524
|
+
const currentFieldFilterKey = (0, import_react61.useMemo)(() => {
|
|
16514
16525
|
const rules = associationForm?.dataFilterRules || [];
|
|
16515
16526
|
return stableSerialize(
|
|
16516
16527
|
rules.map((rule) => {
|
|
@@ -16519,11 +16530,11 @@ function AssociationFormField(props) {
|
|
|
16519
16530
|
})
|
|
16520
16531
|
);
|
|
16521
16532
|
}, [formData, associationForm?.dataFilterRules]);
|
|
16522
|
-
const filterDependencyKey = (0,
|
|
16533
|
+
const filterDependencyKey = (0, import_react61.useMemo)(
|
|
16523
16534
|
() => `${filterRulesKey}:${currentFieldFilterKey}`,
|
|
16524
16535
|
[currentFieldFilterKey, filterRulesKey]
|
|
16525
16536
|
);
|
|
16526
|
-
const normalizeRecord = (0,
|
|
16537
|
+
const normalizeRecord = (0, import_react61.useCallback)(
|
|
16527
16538
|
(record) => {
|
|
16528
16539
|
const mainFieldValue = associationMainFieldId ? record?.[associationMainFieldId] : void 0;
|
|
16529
16540
|
const labelText = normalizeCellValue(mainFieldValue);
|
|
@@ -16536,7 +16547,7 @@ function AssociationFormField(props) {
|
|
|
16536
16547
|
},
|
|
16537
16548
|
[associationMainFieldId]
|
|
16538
16549
|
);
|
|
16539
|
-
const toValue = (0,
|
|
16550
|
+
const toValue = (0, import_react61.useCallback)(
|
|
16540
16551
|
(record) => ({
|
|
16541
16552
|
label: record.__associationLabel,
|
|
16542
16553
|
value: record.__associationValue,
|
|
@@ -16544,7 +16555,7 @@ function AssociationFormField(props) {
|
|
|
16544
16555
|
}),
|
|
16545
16556
|
[]
|
|
16546
16557
|
);
|
|
16547
|
-
const buildFilters = (0,
|
|
16558
|
+
const buildFilters = (0, import_react61.useCallback)(() => {
|
|
16548
16559
|
void filterDependencyKey;
|
|
16549
16560
|
const rules = associationFormRef.current?.dataFilterRules || [];
|
|
16550
16561
|
const currentFormData = formDataRef.current;
|
|
@@ -16560,7 +16571,7 @@ function AssociationFormField(props) {
|
|
|
16560
16571
|
};
|
|
16561
16572
|
}).filter(Boolean);
|
|
16562
16573
|
}, [filterDependencyKey]);
|
|
16563
|
-
const fetchRecords = (0,
|
|
16574
|
+
const fetchRecords = (0, import_react61.useCallback)(
|
|
16564
16575
|
async (params) => {
|
|
16565
16576
|
if (!canQuery) return { list: [], total: 0 };
|
|
16566
16577
|
const filters = buildFilters();
|
|
@@ -16583,7 +16594,7 @@ function AssociationFormField(props) {
|
|
|
16583
16594
|
},
|
|
16584
16595
|
[api, associationAppType, associationFormUuid, buildFilters, canQuery, normalizeRecord]
|
|
16585
16596
|
);
|
|
16586
|
-
const loadOptions = (0,
|
|
16597
|
+
const loadOptions = (0, import_react61.useCallback)(
|
|
16587
16598
|
async (searchKeyWord) => {
|
|
16588
16599
|
setSelectLoading(true);
|
|
16589
16600
|
try {
|
|
@@ -16595,7 +16606,7 @@ function AssociationFormField(props) {
|
|
|
16595
16606
|
},
|
|
16596
16607
|
[fetchRecords, toValue]
|
|
16597
16608
|
);
|
|
16598
|
-
const loadTable = (0,
|
|
16609
|
+
const loadTable = (0, import_react61.useCallback)(
|
|
16599
16610
|
async (next) => {
|
|
16600
16611
|
setTableLoading(true);
|
|
16601
16612
|
const current = next?.current || 1;
|
|
@@ -16614,10 +16625,10 @@ function AssociationFormField(props) {
|
|
|
16614
16625
|
},
|
|
16615
16626
|
[fetchRecords, keyword, pagination.pageSize]
|
|
16616
16627
|
);
|
|
16617
|
-
(0,
|
|
16628
|
+
(0, import_react61.useEffect)(() => {
|
|
16618
16629
|
void loadOptions();
|
|
16619
16630
|
}, [loadOptions]);
|
|
16620
|
-
(0,
|
|
16631
|
+
(0, import_react61.useEffect)(() => {
|
|
16621
16632
|
setSelectedRowKeys(value.map((item) => item.value));
|
|
16622
16633
|
setSelectedRecords(
|
|
16623
16634
|
value.map(
|
|
@@ -16625,7 +16636,7 @@ function AssociationFormField(props) {
|
|
|
16625
16636
|
).filter(Boolean)
|
|
16626
16637
|
);
|
|
16627
16638
|
}, [normalizeRecord, value]);
|
|
16628
|
-
const applyDataFilling = (0,
|
|
16639
|
+
const applyDataFilling = (0, import_react61.useCallback)(
|
|
16629
16640
|
(next) => {
|
|
16630
16641
|
if (!associationForm?.dataFillingEnabled && !associationForm?.dataFillingRules?.mainRules) {
|
|
16631
16642
|
return;
|
|
@@ -16639,7 +16650,7 @@ function AssociationFormField(props) {
|
|
|
16639
16650
|
},
|
|
16640
16651
|
[associationForm?.dataFillingEnabled, associationForm?.dataFillingRules, setFieldValue]
|
|
16641
16652
|
);
|
|
16642
|
-
const commitSelection = (0,
|
|
16653
|
+
const commitSelection = (0, import_react61.useCallback)(
|
|
16643
16654
|
(next) => {
|
|
16644
16655
|
const normalized = multiple ? next : next.slice(0, 1);
|
|
16645
16656
|
setFieldValue(fieldId, normalized);
|
|
@@ -16648,7 +16659,7 @@ function AssociationFormField(props) {
|
|
|
16648
16659
|
},
|
|
16649
16660
|
[applyDataFilling, fieldId, multiple, onChange, setFieldValue]
|
|
16650
16661
|
);
|
|
16651
|
-
const selectorColumns = (0,
|
|
16662
|
+
const selectorColumns = (0, import_react61.useMemo)(() => {
|
|
16652
16663
|
const configured = associationForm?.selectorColumns || [];
|
|
16653
16664
|
if (configured.length) {
|
|
16654
16665
|
return configured.map((column) => {
|
|
@@ -16683,7 +16694,7 @@ function AssociationFormField(props) {
|
|
|
16683
16694
|
}
|
|
16684
16695
|
];
|
|
16685
16696
|
}, [associationForm?.mainFieldId, associationForm?.selectorColumns]);
|
|
16686
|
-
const selectOptions = (0,
|
|
16697
|
+
const selectOptions = (0, import_react61.useMemo)(
|
|
16687
16698
|
() => [...options, ...value].filter(
|
|
16688
16699
|
(item, index, list) => list.findIndex((candidate) => candidate.value === item.value) === index
|
|
16689
16700
|
).map((item) => ({ label: item.label, value: item.value })),
|
|
@@ -16891,9 +16902,9 @@ function AssociationFormField(props) {
|
|
|
16891
16902
|
}
|
|
16892
16903
|
|
|
16893
16904
|
// packages/sdk/src/components/fields/EditorField/index.tsx
|
|
16894
|
-
var
|
|
16905
|
+
var import_react62 = require("react");
|
|
16895
16906
|
var import_core = require("@tiptap/core");
|
|
16896
|
-
var
|
|
16907
|
+
var import_react63 = require("@tiptap/react");
|
|
16897
16908
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
16898
16909
|
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
16899
16910
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
@@ -17527,28 +17538,28 @@ function RichTextEditorCore({
|
|
|
17527
17538
|
fieldId = "richText",
|
|
17528
17539
|
mobile = false
|
|
17529
17540
|
}) {
|
|
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,
|
|
17541
|
+
const inputRef = (0, import_react62.useRef)(null);
|
|
17542
|
+
const [uploading, setUploading] = (0, import_react62.useState)(false);
|
|
17543
|
+
const [uploadError, setUploadError] = (0, import_react62.useState)("");
|
|
17544
|
+
const [charCount, setCharCount] = (0, import_react62.useState)(0);
|
|
17545
|
+
const [linkOpen, setLinkOpen] = (0, import_react62.useState)(false);
|
|
17546
|
+
const [linkUrl, setLinkUrl] = (0, import_react62.useState)("");
|
|
17547
|
+
const [linkError, setLinkError] = (0, import_react62.useState)("");
|
|
17548
|
+
const [imageUrlOpen, setImageUrlOpen] = (0, import_react62.useState)(false);
|
|
17549
|
+
const [imageUrl, setImageUrl] = (0, import_react62.useState)("");
|
|
17550
|
+
const [imageAlt, setImageAlt] = (0, import_react62.useState)("");
|
|
17551
|
+
const [imageTitle, setImageTitle] = (0, import_react62.useState)("");
|
|
17552
|
+
const [imageUrlError, setImageUrlError] = (0, import_react62.useState)("");
|
|
17553
|
+
const [tableOpen, setTableOpen] = (0, import_react62.useState)(false);
|
|
17554
|
+
const [tableRows, setTableRows] = (0, import_react62.useState)(3);
|
|
17555
|
+
const [tableCols, setTableCols] = (0, import_react62.useState)(3);
|
|
17556
|
+
const onChangeRef = (0, import_react62.useRef)(onChange);
|
|
17557
|
+
(0, import_react62.useEffect)(() => {
|
|
17547
17558
|
onChangeRef.current = onChange;
|
|
17548
17559
|
}, [onChange]);
|
|
17549
|
-
const actions = (0,
|
|
17560
|
+
const actions = (0, import_react62.useMemo)(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
|
|
17550
17561
|
const visibleActions = mobile ? [] : actions;
|
|
17551
|
-
const extensions = (0,
|
|
17562
|
+
const extensions = (0, import_react62.useMemo)(
|
|
17552
17563
|
() => [
|
|
17553
17564
|
import_starter_kit.default.configure({
|
|
17554
17565
|
heading: { levels: [1, 2, 3] },
|
|
@@ -17582,10 +17593,10 @@ function RichTextEditorCore({
|
|
|
17582
17593
|
],
|
|
17583
17594
|
[maxLength, placeholder]
|
|
17584
17595
|
);
|
|
17585
|
-
const updateHtml = (0,
|
|
17596
|
+
const updateHtml = (0, import_react62.useCallback)((next) => {
|
|
17586
17597
|
onChangeRef.current?.(next);
|
|
17587
17598
|
}, []);
|
|
17588
|
-
const editor = (0,
|
|
17599
|
+
const editor = (0, import_react63.useEditor)(
|
|
17589
17600
|
{
|
|
17590
17601
|
extensions,
|
|
17591
17602
|
content: value || "",
|
|
@@ -17612,11 +17623,11 @@ function RichTextEditorCore({
|
|
|
17612
17623
|
},
|
|
17613
17624
|
[fieldId, extensions, disabled, maxLength, updateHtml]
|
|
17614
17625
|
);
|
|
17615
|
-
(0,
|
|
17626
|
+
(0, import_react62.useEffect)(() => {
|
|
17616
17627
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17617
17628
|
editor.setEditable(!disabled);
|
|
17618
17629
|
}, [disabled, editor]);
|
|
17619
|
-
(0,
|
|
17630
|
+
(0, import_react62.useEffect)(() => {
|
|
17620
17631
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17621
17632
|
const currentHtml = getSafeEditorHtml(editor);
|
|
17622
17633
|
if ((value || "") !== currentHtml) {
|
|
@@ -17624,7 +17635,7 @@ function RichTextEditorCore({
|
|
|
17624
17635
|
}
|
|
17625
17636
|
setCharCount(countCharacters(editor));
|
|
17626
17637
|
}, [editor, value]);
|
|
17627
|
-
const insertImageFiles = (0,
|
|
17638
|
+
const insertImageFiles = (0, import_react62.useCallback)(
|
|
17628
17639
|
async (files) => {
|
|
17629
17640
|
if (!editor || isEditorDestroyed(editor) || disabled || files.length === 0) return;
|
|
17630
17641
|
const validFiles = files.filter((file) => {
|
|
@@ -17654,7 +17665,7 @@ function RichTextEditorCore({
|
|
|
17654
17665
|
},
|
|
17655
17666
|
[allowedImageTypes, api, disabled, editor, maxImageSize, uploadBucketName]
|
|
17656
17667
|
);
|
|
17657
|
-
const openLinkModal = (0,
|
|
17668
|
+
const openLinkModal = (0, import_react62.useCallback)(() => {
|
|
17658
17669
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
17659
17670
|
setLinkUrl(editor.getAttributes("link").href || "");
|
|
17660
17671
|
setLinkError("");
|
|
@@ -17680,7 +17691,7 @@ function RichTextEditorCore({
|
|
|
17680
17691
|
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
17681
17692
|
setLinkOpen(false);
|
|
17682
17693
|
};
|
|
17683
|
-
const openImageUrlModal = (0,
|
|
17694
|
+
const openImageUrlModal = (0, import_react62.useCallback)(() => {
|
|
17684
17695
|
setImageUrl("");
|
|
17685
17696
|
setImageAlt("");
|
|
17686
17697
|
setImageTitle("");
|
|
@@ -17757,7 +17768,7 @@ function RichTextEditorCore({
|
|
|
17757
17768
|
void insertImageFiles(files);
|
|
17758
17769
|
}
|
|
17759
17770
|
},
|
|
17760
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
17771
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_react63.EditorContent, { editor })
|
|
17761
17772
|
}
|
|
17762
17773
|
),
|
|
17763
17774
|
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
@@ -17930,19 +17941,19 @@ function EditorField(props) {
|
|
|
17930
17941
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
17931
17942
|
const rawValue = formData[fieldId] ?? "";
|
|
17932
17943
|
const value = normalizeRichTextHtml(rawValue);
|
|
17933
|
-
(0,
|
|
17944
|
+
(0, import_react62.useEffect)(() => {
|
|
17934
17945
|
registerField(fieldId);
|
|
17935
17946
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
17936
17947
|
setFieldValue(fieldId, normalizeRichTextHtml(defaultValue));
|
|
17937
17948
|
}
|
|
17938
17949
|
return () => unregisterField(fieldId);
|
|
17939
17950
|
}, [fieldId]);
|
|
17940
|
-
(0,
|
|
17951
|
+
(0, import_react62.useEffect)(() => {
|
|
17941
17952
|
if (rawValue && rawValue !== value) {
|
|
17942
17953
|
setFieldValue(fieldId, value);
|
|
17943
17954
|
}
|
|
17944
17955
|
}, [fieldId, rawValue, setFieldValue, value]);
|
|
17945
|
-
const updateHtml = (0,
|
|
17956
|
+
const updateHtml = (0, import_react62.useCallback)(
|
|
17946
17957
|
(next) => {
|
|
17947
17958
|
setFieldValue(fieldId, next);
|
|
17948
17959
|
onChange?.(next);
|
|
@@ -17995,7 +18006,7 @@ function EditorField(props) {
|
|
|
17995
18006
|
}
|
|
17996
18007
|
|
|
17997
18008
|
// packages/sdk/src/components/fields/SerialNumberField/index.tsx
|
|
17998
|
-
var
|
|
18009
|
+
var import_react64 = require("react");
|
|
17999
18010
|
var import_antd31 = require("antd");
|
|
18000
18011
|
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
18001
18012
|
function SerialNumberField(props) {
|
|
@@ -18015,7 +18026,7 @@ function SerialNumberField(props) {
|
|
|
18015
18026
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
18016
18027
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
18017
18028
|
const value = formData[fieldId] ?? "";
|
|
18018
|
-
(0,
|
|
18029
|
+
(0, import_react64.useEffect)(() => {
|
|
18019
18030
|
registerField(fieldId);
|
|
18020
18031
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18021
18032
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18057,7 +18068,7 @@ function SerialNumberField(props) {
|
|
|
18057
18068
|
}
|
|
18058
18069
|
|
|
18059
18070
|
// packages/sdk/src/components/fields/LocationField/index.tsx
|
|
18060
|
-
var
|
|
18071
|
+
var import_react65 = require("react");
|
|
18061
18072
|
var import_antd32 = require("antd");
|
|
18062
18073
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
18063
18074
|
var getDingTalkApi = () => {
|
|
@@ -18099,9 +18110,9 @@ function LocationField(props) {
|
|
|
18099
18110
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
18100
18111
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
18101
18112
|
const value = formData[fieldId];
|
|
18102
|
-
const [locating, setLocating] = (0,
|
|
18103
|
-
const [error, setError] = (0,
|
|
18104
|
-
(0,
|
|
18113
|
+
const [locating, setLocating] = (0, import_react65.useState)(false);
|
|
18114
|
+
const [error, setError] = (0, import_react65.useState)("");
|
|
18115
|
+
(0, import_react65.useEffect)(() => {
|
|
18105
18116
|
registerField(fieldId);
|
|
18106
18117
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18107
18118
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18242,7 +18253,7 @@ function LocationField(props) {
|
|
|
18242
18253
|
}
|
|
18243
18254
|
|
|
18244
18255
|
// packages/sdk/src/components/fields/DigitalSignatureField/index.tsx
|
|
18245
|
-
var
|
|
18256
|
+
var import_react66 = require("react");
|
|
18246
18257
|
var import_antd33 = require("antd");
|
|
18247
18258
|
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
18248
18259
|
var CANVAS_HEIGHT = 260;
|
|
@@ -18276,21 +18287,21 @@ function DigitalSignatureField(props) {
|
|
|
18276
18287
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
18277
18288
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
18278
18289
|
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,
|
|
18290
|
+
const [open, setOpen] = (0, import_react66.useState)(false);
|
|
18291
|
+
const [saving, setSaving] = (0, import_react66.useState)(false);
|
|
18292
|
+
const [drawn, setDrawn] = (0, import_react66.useState)(false);
|
|
18293
|
+
const [error, setError] = (0, import_react66.useState)("");
|
|
18294
|
+
const canvasRef = (0, import_react66.useRef)(null);
|
|
18295
|
+
const drawingRef = (0, import_react66.useRef)(false);
|
|
18296
|
+
const pointsRef = (0, import_react66.useRef)([]);
|
|
18297
|
+
(0, import_react66.useEffect)(() => {
|
|
18287
18298
|
registerField(fieldId);
|
|
18288
18299
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18289
18300
|
setFieldValue(fieldId, defaultValue);
|
|
18290
18301
|
}
|
|
18291
18302
|
return () => unregisterField(fieldId);
|
|
18292
18303
|
}, [fieldId]);
|
|
18293
|
-
const prepareCanvas = (0,
|
|
18304
|
+
const prepareCanvas = (0, import_react66.useCallback)(() => {
|
|
18294
18305
|
const canvas = canvasRef.current;
|
|
18295
18306
|
if (!canvas) return;
|
|
18296
18307
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -18312,7 +18323,7 @@ function DigitalSignatureField(props) {
|
|
|
18312
18323
|
ctx.lineJoin = "round";
|
|
18313
18324
|
ctx.strokeStyle = "#111827";
|
|
18314
18325
|
}, []);
|
|
18315
|
-
(0,
|
|
18326
|
+
(0, import_react66.useEffect)(() => {
|
|
18316
18327
|
if (!open) return;
|
|
18317
18328
|
pointsRef.current = [];
|
|
18318
18329
|
setDrawn(false);
|
|
@@ -18491,7 +18502,7 @@ function DigitalSignatureField(props) {
|
|
|
18491
18502
|
}
|
|
18492
18503
|
|
|
18493
18504
|
// packages/sdk/src/components/fields/JSONField/index.tsx
|
|
18494
|
-
var
|
|
18505
|
+
var import_react67 = require("react");
|
|
18495
18506
|
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
18496
18507
|
var formatJson = (value) => {
|
|
18497
18508
|
if (value === void 0 || value === null || value === "") return "--";
|
|
@@ -18518,7 +18529,7 @@ function JSONField(props) {
|
|
|
18518
18529
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
18519
18530
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
18520
18531
|
const value = formData[fieldId];
|
|
18521
|
-
(0,
|
|
18532
|
+
(0, import_react67.useEffect)(() => {
|
|
18522
18533
|
registerField(fieldId);
|
|
18523
18534
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
18524
18535
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -18990,9 +19001,9 @@ function FormProvider({
|
|
|
18990
19001
|
runtime,
|
|
18991
19002
|
children
|
|
18992
19003
|
}) {
|
|
18993
|
-
const api = (0,
|
|
18994
|
-
const [runtimeDefaults, setRuntimeDefaults] = (0,
|
|
18995
|
-
const effects = (0,
|
|
19004
|
+
const api = (0, import_react68.useMemo)(() => createFormRuntimeApi(config.api), [config.api]);
|
|
19005
|
+
const [runtimeDefaults, setRuntimeDefaults] = (0, import_react68.useState)({});
|
|
19006
|
+
const effects = (0, import_react68.useMemo)(
|
|
18996
19007
|
() => [
|
|
18997
19008
|
...schema.rules ?? [],
|
|
18998
19009
|
...schema.fields.flatMap((field) => field.optionEffects ?? []),
|
|
@@ -19000,18 +19011,18 @@ function FormProvider({
|
|
|
19000
19011
|
],
|
|
19001
19012
|
[schema.rules, schema.fields, config.effects]
|
|
19002
19013
|
);
|
|
19003
|
-
const defaultRuntime = (0,
|
|
19014
|
+
const defaultRuntime = (0, import_react68.useMemo)(
|
|
19004
19015
|
() => ({
|
|
19005
19016
|
appType: config.appType,
|
|
19006
19017
|
fetchFormData: (params) => fetchRuntimeFormData(api, config.appType, params)
|
|
19007
19018
|
}),
|
|
19008
19019
|
[api, config.appType]
|
|
19009
19020
|
);
|
|
19010
|
-
const mergedRuntime = (0,
|
|
19021
|
+
const mergedRuntime = (0, import_react68.useMemo)(
|
|
19011
19022
|
() => ({ ...defaultRuntime, ...schema.runtime, ...runtimeDefaults, ...runtime }),
|
|
19012
19023
|
[defaultRuntime, schema.runtime, runtimeDefaults, runtime]
|
|
19013
19024
|
);
|
|
19014
|
-
const computedInitialValues = (0,
|
|
19025
|
+
const computedInitialValues = (0, import_react68.useMemo)(() => {
|
|
19015
19026
|
const values = {};
|
|
19016
19027
|
for (const field of schema.fields) {
|
|
19017
19028
|
const defaultValue = resolveDefaultValue(field, mergedRuntime);
|
|
@@ -19021,11 +19032,11 @@ function FormProvider({
|
|
|
19021
19032
|
}
|
|
19022
19033
|
return { ...values, ...initialValues };
|
|
19023
19034
|
}, [schema, initialValues, mergedRuntime]);
|
|
19024
|
-
const initialValuesRef = (0,
|
|
19025
|
-
const [formData, setFormData] = (0,
|
|
19026
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
19027
|
-
const [registeredFields] = (0,
|
|
19028
|
-
(0,
|
|
19035
|
+
const initialValuesRef = (0, import_react68.useRef)(computedInitialValues);
|
|
19036
|
+
const [formData, setFormData] = (0, import_react68.useState)({ ...computedInitialValues });
|
|
19037
|
+
const [fieldErrors, setFieldErrors] = (0, import_react68.useState)({});
|
|
19038
|
+
const [registeredFields] = (0, import_react68.useState)(/* @__PURE__ */ new Set());
|
|
19039
|
+
(0, import_react68.useEffect)(() => {
|
|
19029
19040
|
if (!schema.fields.some((field) => needsCurrentUserRuntime(field.defaultShortcut?.type)))
|
|
19030
19041
|
return;
|
|
19031
19042
|
if (mergedRuntime.currentUser && mergedRuntime.currentDepartment) return;
|
|
@@ -19049,7 +19060,7 @@ function FormProvider({
|
|
|
19049
19060
|
cancelled = true;
|
|
19050
19061
|
};
|
|
19051
19062
|
}, [api, mergedRuntime.currentDepartment, mergedRuntime.currentUser, schema.fields]);
|
|
19052
|
-
(0,
|
|
19063
|
+
(0, import_react68.useEffect)(() => {
|
|
19053
19064
|
setFormData((prev) => {
|
|
19054
19065
|
let changed = false;
|
|
19055
19066
|
const next = { ...prev };
|
|
@@ -19063,7 +19074,7 @@ function FormProvider({
|
|
|
19063
19074
|
return changed ? next : prev;
|
|
19064
19075
|
});
|
|
19065
19076
|
}, [mergedRuntime, schema.fields]);
|
|
19066
|
-
const fieldBehaviors = (0,
|
|
19077
|
+
const fieldBehaviors = (0, import_react68.useMemo)(() => {
|
|
19067
19078
|
const baseBehaviors = {};
|
|
19068
19079
|
for (const field of schema.fields) {
|
|
19069
19080
|
baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
|
|
@@ -19086,15 +19097,15 @@ function FormProvider({
|
|
|
19086
19097
|
}
|
|
19087
19098
|
return computed;
|
|
19088
19099
|
}, [schema, effects, config.permissions, config.mode, formData]);
|
|
19089
|
-
const fieldOverrides = (0,
|
|
19100
|
+
const fieldOverrides = (0, import_react68.useMemo)(
|
|
19090
19101
|
() => evaluateFieldOverrides(effects, formData),
|
|
19091
19102
|
[effects, formData]
|
|
19092
19103
|
);
|
|
19093
|
-
const layoutBehaviors = (0,
|
|
19104
|
+
const layoutBehaviors = (0, import_react68.useMemo)(
|
|
19094
19105
|
() => evaluateLayoutBehaviors(effects, formData),
|
|
19095
19106
|
[effects, formData]
|
|
19096
19107
|
);
|
|
19097
|
-
(0,
|
|
19108
|
+
(0, import_react68.useEffect)(() => {
|
|
19098
19109
|
const valueActions = getValueActions(effects, formData);
|
|
19099
19110
|
if (valueActions.length === 0) return;
|
|
19100
19111
|
let changed = false;
|
|
@@ -19117,7 +19128,7 @@ function FormProvider({
|
|
|
19117
19128
|
setFieldErrors(nextErrors);
|
|
19118
19129
|
}
|
|
19119
19130
|
}, [effects, formData, fieldErrors]);
|
|
19120
|
-
const setFieldValue = (0,
|
|
19131
|
+
const setFieldValue = (0, import_react68.useCallback)((fieldId, value) => {
|
|
19121
19132
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
19122
19133
|
setFieldErrors((prev) => {
|
|
19123
19134
|
if (prev[fieldId]) {
|
|
@@ -19128,9 +19139,9 @@ function FormProvider({
|
|
|
19128
19139
|
return prev;
|
|
19129
19140
|
});
|
|
19130
19141
|
}, []);
|
|
19131
|
-
const getFieldValue = (0,
|
|
19132
|
-
const getFormData2 = (0,
|
|
19133
|
-
const validateFieldById = (0,
|
|
19142
|
+
const getFieldValue = (0, import_react68.useCallback)((fieldId) => formData[fieldId], [formData]);
|
|
19143
|
+
const getFormData2 = (0, import_react68.useCallback)(() => ({ ...formData }), [formData]);
|
|
19144
|
+
const validateFieldById = (0, import_react68.useCallback)(
|
|
19134
19145
|
async (fieldId) => {
|
|
19135
19146
|
const field = schema.fields.find((f) => f.fieldId === fieldId);
|
|
19136
19147
|
if (!field) {
|
|
@@ -19191,7 +19202,7 @@ function FormProvider({
|
|
|
19191
19202
|
},
|
|
19192
19203
|
[schema, formData, fieldBehaviors, fieldOverrides]
|
|
19193
19204
|
);
|
|
19194
|
-
const validateAllWithErrors = (0,
|
|
19205
|
+
const validateAllWithErrors = (0, import_react68.useCallback)(async () => {
|
|
19195
19206
|
const fieldRules = {};
|
|
19196
19207
|
const validationData = { ...formData };
|
|
19197
19208
|
for (const field of schema.fields) {
|
|
@@ -19215,28 +19226,28 @@ function FormProvider({
|
|
|
19215
19226
|
setFieldErrors(errors);
|
|
19216
19227
|
return errors;
|
|
19217
19228
|
}, [schema, formData, fieldBehaviors, fieldOverrides]);
|
|
19218
|
-
const validateAll = (0,
|
|
19229
|
+
const validateAll = (0, import_react68.useCallback)(async () => {
|
|
19219
19230
|
const errors = await validateAllWithErrors();
|
|
19220
19231
|
return Object.keys(errors).length === 0;
|
|
19221
19232
|
}, [validateAllWithErrors]);
|
|
19222
|
-
const resetForm = (0,
|
|
19233
|
+
const resetForm = (0, import_react68.useCallback)(() => {
|
|
19223
19234
|
setFormData({ ...initialValuesRef.current });
|
|
19224
19235
|
setFieldErrors({});
|
|
19225
19236
|
}, []);
|
|
19226
|
-
const registerField = (0,
|
|
19237
|
+
const registerField = (0, import_react68.useCallback)(
|
|
19227
19238
|
(fieldId) => {
|
|
19228
19239
|
registeredFields.add(fieldId);
|
|
19229
19240
|
},
|
|
19230
19241
|
[registeredFields]
|
|
19231
19242
|
);
|
|
19232
|
-
const unregisterField = (0,
|
|
19243
|
+
const unregisterField = (0, import_react68.useCallback)(
|
|
19233
19244
|
(fieldId) => {
|
|
19234
19245
|
registeredFields.delete(fieldId);
|
|
19235
19246
|
},
|
|
19236
19247
|
[registeredFields]
|
|
19237
19248
|
);
|
|
19238
|
-
const [dynamicOptions, setDynamicOptions] = (0,
|
|
19239
|
-
(0,
|
|
19249
|
+
const [dynamicOptions, setDynamicOptions] = (0, import_react68.useState)({});
|
|
19250
|
+
(0, import_react68.useEffect)(() => {
|
|
19240
19251
|
const loadDynamicOptions = async () => {
|
|
19241
19252
|
const updates = {};
|
|
19242
19253
|
for (const field of schema.fields) {
|
|
@@ -19254,7 +19265,7 @@ function FormProvider({
|
|
|
19254
19265
|
};
|
|
19255
19266
|
loadDynamicOptions();
|
|
19256
19267
|
}, [schema.fields, mergedRuntime]);
|
|
19257
|
-
(0,
|
|
19268
|
+
(0, import_react68.useEffect)(() => {
|
|
19258
19269
|
let cancelled = false;
|
|
19259
19270
|
const loadDataLinkageOptions = async () => {
|
|
19260
19271
|
const updates = {};
|
|
@@ -19280,7 +19291,7 @@ function FormProvider({
|
|
|
19280
19291
|
window.clearTimeout(timer);
|
|
19281
19292
|
};
|
|
19282
19293
|
}, [schema.fields, mergedRuntime, formData]);
|
|
19283
|
-
(0,
|
|
19294
|
+
(0, import_react68.useEffect)(() => {
|
|
19284
19295
|
let cancelled = false;
|
|
19285
19296
|
const loadDefaultValueLinkages = async () => {
|
|
19286
19297
|
const fields = schema.fields.filter((field) => field.defaultValueLinkage);
|
|
@@ -19314,7 +19325,7 @@ function FormProvider({
|
|
|
19314
19325
|
window.clearTimeout(timer);
|
|
19315
19326
|
};
|
|
19316
19327
|
}, [schema.fields, mergedRuntime, formData]);
|
|
19317
|
-
const contextValue = (0,
|
|
19328
|
+
const contextValue = (0, import_react68.useMemo)(
|
|
19318
19329
|
() => ({
|
|
19319
19330
|
mode: config.mode,
|
|
19320
19331
|
schema,
|
|
@@ -19370,10 +19381,10 @@ function FormProvider({
|
|
|
19370
19381
|
]
|
|
19371
19382
|
);
|
|
19372
19383
|
const registryComponents = components ?? defaultComponentRegistry;
|
|
19373
|
-
return
|
|
19384
|
+
return import_react68.default.createElement(
|
|
19374
19385
|
FormContext.Provider,
|
|
19375
19386
|
{ value: contextValue },
|
|
19376
|
-
|
|
19387
|
+
import_react68.default.createElement(ComponentRegistryProvider, { components: registryComponents, children })
|
|
19377
19388
|
);
|
|
19378
19389
|
}
|
|
19379
19390
|
function resolveDefaultValue(field, runtime) {
|
|
@@ -19484,11 +19495,11 @@ function coerceLinkedDefaultValue(field, value) {
|
|
|
19484
19495
|
}
|
|
19485
19496
|
|
|
19486
19497
|
// packages/sdk/src/components/core/FormRenderer.tsx
|
|
19487
|
-
var
|
|
19498
|
+
var import_react72 = __toESM(require("react"));
|
|
19488
19499
|
|
|
19489
19500
|
// packages/sdk/src/components/layout/FormSection/index.tsx
|
|
19490
19501
|
var import_icons14 = require("@ant-design/icons");
|
|
19491
|
-
var
|
|
19502
|
+
var import_react69 = require("react");
|
|
19492
19503
|
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
19493
19504
|
var sectionIconMap = {
|
|
19494
19505
|
user: import_icons14.UserOutlined,
|
|
@@ -19513,7 +19524,7 @@ function FormSection({
|
|
|
19513
19524
|
contentClassName,
|
|
19514
19525
|
children
|
|
19515
19526
|
}) {
|
|
19516
|
-
const [collapsed, setCollapsed] = (0,
|
|
19527
|
+
const [collapsed, setCollapsed] = (0, import_react69.useState)(defaultCollapsed);
|
|
19517
19528
|
const handleToggle = () => {
|
|
19518
19529
|
if (collapsible) {
|
|
19519
19530
|
setCollapsed((prev) => !prev);
|
|
@@ -19642,10 +19653,10 @@ function FormGrid({
|
|
|
19642
19653
|
}
|
|
19643
19654
|
|
|
19644
19655
|
// packages/sdk/src/components/layout/FormTabs/index.tsx
|
|
19645
|
-
var
|
|
19656
|
+
var import_react70 = require("react");
|
|
19646
19657
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
19647
19658
|
function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
19648
|
-
const [activeKey, setActiveKey] = (0,
|
|
19659
|
+
const [activeKey, setActiveKey] = (0, import_react70.useState)(defaultActiveKey || items[0]?.key || "");
|
|
19649
19660
|
const activeItem = items.find((item) => item.key === activeKey);
|
|
19650
19661
|
return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-tabs", children: [
|
|
19651
19662
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
@@ -19674,10 +19685,10 @@ function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
|
19674
19685
|
}
|
|
19675
19686
|
|
|
19676
19687
|
// packages/sdk/src/components/layout/FormSteps/index.tsx
|
|
19677
|
-
var
|
|
19688
|
+
var import_react71 = __toESM(require("react"));
|
|
19678
19689
|
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
19679
19690
|
function FormSteps({ items, className, onStepChange }) {
|
|
19680
|
-
const [currentStep, setCurrentStep] = (0,
|
|
19691
|
+
const [currentStep, setCurrentStep] = (0, import_react71.useState)(0);
|
|
19681
19692
|
const goTo = (step) => {
|
|
19682
19693
|
setCurrentStep(step);
|
|
19683
19694
|
onStepChange?.(step);
|
|
@@ -19693,7 +19704,7 @@ function FormSteps({ items, className, onStepChange }) {
|
|
|
19693
19704
|
}
|
|
19694
19705
|
};
|
|
19695
19706
|
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)(
|
|
19707
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center mb-6", "data-testid": "form-steps-indicator", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_react71.default.Fragment, { children: [
|
|
19697
19708
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex items-center", children: [
|
|
19698
19709
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
19699
19710
|
"div",
|
|
@@ -19794,7 +19805,7 @@ function FieldRenderer({
|
|
|
19794
19805
|
return null;
|
|
19795
19806
|
}
|
|
19796
19807
|
const { fieldId, componentName: _, ...fieldProps } = field;
|
|
19797
|
-
const element =
|
|
19808
|
+
const element = import_react72.default.createElement(Component, {
|
|
19798
19809
|
...fieldProps,
|
|
19799
19810
|
fieldId,
|
|
19800
19811
|
className: fieldClassName ?? fieldProps.className
|
|
@@ -19958,7 +19969,7 @@ function FormRenderer({
|
|
|
19958
19969
|
const gridClass = columnsClassMap[columns];
|
|
19959
19970
|
const gapClass = sizeClassMap[size];
|
|
19960
19971
|
const containerClassName = ["sy-form-renderer", "sy-grid", gridClass, gapClass, className].filter(Boolean).join(" ");
|
|
19961
|
-
const fieldMap =
|
|
19972
|
+
const fieldMap = import_react72.default.useMemo(() => {
|
|
19962
19973
|
return new Map(
|
|
19963
19974
|
schema.fields.map((field) => [
|
|
19964
19975
|
field.fieldId,
|
|
@@ -20029,7 +20040,7 @@ function isLayoutVisible(visibleWhen, formData) {
|
|
|
20029
20040
|
}
|
|
20030
20041
|
|
|
20031
20042
|
// packages/sdk/src/components/core/FormShell.tsx
|
|
20032
|
-
var
|
|
20043
|
+
var import_react73 = require("react");
|
|
20033
20044
|
var Antd2 = __toESM(require("antd"));
|
|
20034
20045
|
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
20035
20046
|
function normalizeMaxWidth(maxWidth) {
|
|
@@ -20059,10 +20070,10 @@ function FormShell({ children, appearance, className }) {
|
|
|
20059
20070
|
const [form] = useAntForm();
|
|
20060
20071
|
const { formData, setFieldValue } = useFormContext();
|
|
20061
20072
|
const maxWidth = normalizeMaxWidth(appearance?.maxWidth);
|
|
20062
|
-
(0,
|
|
20073
|
+
(0, import_react73.useEffect)(() => {
|
|
20063
20074
|
form?.setFieldsValue?.(formData);
|
|
20064
20075
|
}, [form, formData]);
|
|
20065
|
-
const style = (0,
|
|
20076
|
+
const style = (0, import_react73.useMemo)(() => {
|
|
20066
20077
|
if (!maxWidth) return void 0;
|
|
20067
20078
|
return {
|
|
20068
20079
|
maxWidth,
|
|
@@ -20128,7 +20139,7 @@ async function validateAndNotify(validateAllWithErrors) {
|
|
|
20128
20139
|
}
|
|
20129
20140
|
|
|
20130
20141
|
// packages/sdk/src/components/hooks/useFormDetail.ts
|
|
20131
|
-
var
|
|
20142
|
+
var import_react74 = require("react");
|
|
20132
20143
|
|
|
20133
20144
|
// packages/sdk/src/components/utils/formInstanceData.ts
|
|
20134
20145
|
var FORM_INSTANCE_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -20325,24 +20336,24 @@ function useFormDetail(options) {
|
|
|
20325
20336
|
const { formUuid, appType, formInstanceId, fieldIds, onPermissionDenied } = options;
|
|
20326
20337
|
const { api } = useFormContext();
|
|
20327
20338
|
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,
|
|
20339
|
+
const [loading, setLoading] = (0, import_react74.useState)(true);
|
|
20340
|
+
const [mode, setMode] = (0, import_react74.useState)("readonly");
|
|
20341
|
+
const [formData, setFormData] = (0, import_react74.useState)(null);
|
|
20342
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react74.useState)(null);
|
|
20343
|
+
const [permissions, setPermissions] = (0, import_react74.useState)(null);
|
|
20344
|
+
const mountedRef = (0, import_react74.useRef)(true);
|
|
20345
|
+
const onPermissionDeniedRef = (0, import_react74.useRef)(onPermissionDenied);
|
|
20335
20346
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
20336
|
-
(0,
|
|
20347
|
+
(0, import_react74.useEffect)(() => {
|
|
20337
20348
|
mountedRef.current = true;
|
|
20338
20349
|
return () => {
|
|
20339
20350
|
mountedRef.current = false;
|
|
20340
20351
|
};
|
|
20341
20352
|
}, []);
|
|
20342
|
-
(0,
|
|
20353
|
+
(0, import_react74.useEffect)(() => {
|
|
20343
20354
|
onPermissionDeniedRef.current = onPermissionDenied;
|
|
20344
20355
|
}, [onPermissionDenied]);
|
|
20345
|
-
const loadData = (0,
|
|
20356
|
+
const loadData = (0, import_react74.useCallback)(async () => {
|
|
20346
20357
|
if (!mountedRef.current) return;
|
|
20347
20358
|
setLoading(true);
|
|
20348
20359
|
try {
|
|
@@ -20377,21 +20388,21 @@ function useFormDetail(options) {
|
|
|
20377
20388
|
}
|
|
20378
20389
|
}
|
|
20379
20390
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
20380
|
-
(0,
|
|
20391
|
+
(0, import_react74.useEffect)(() => {
|
|
20381
20392
|
loadData();
|
|
20382
20393
|
}, [loadData]);
|
|
20383
20394
|
const fieldBehaviors = normalizeFieldBehaviors(permissions, mode);
|
|
20384
20395
|
const canEdit = hasViewOperation(permissions?.operations, "edit");
|
|
20385
20396
|
const canDelete = hasViewOperation(permissions?.operations, "delete");
|
|
20386
20397
|
const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
|
|
20387
|
-
const switchToEdit = (0,
|
|
20398
|
+
const switchToEdit = (0, import_react74.useCallback)(() => {
|
|
20388
20399
|
setMode("edit");
|
|
20389
20400
|
loadData();
|
|
20390
20401
|
}, [loadData]);
|
|
20391
|
-
const switchToReadonly = (0,
|
|
20402
|
+
const switchToReadonly = (0, import_react74.useCallback)(() => {
|
|
20392
20403
|
setMode("readonly");
|
|
20393
20404
|
}, []);
|
|
20394
|
-
const saveChanges = (0,
|
|
20405
|
+
const saveChanges = (0, import_react74.useCallback)(
|
|
20395
20406
|
async (values) => {
|
|
20396
20407
|
try {
|
|
20397
20408
|
await api.updateFormData({
|
|
@@ -20412,7 +20423,7 @@ function useFormDetail(options) {
|
|
|
20412
20423
|
},
|
|
20413
20424
|
[api, formInstanceId, formUuid, appType]
|
|
20414
20425
|
);
|
|
20415
|
-
const deleteInstance = (0,
|
|
20426
|
+
const deleteInstance = (0, import_react74.useCallback)(async () => {
|
|
20416
20427
|
try {
|
|
20417
20428
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
20418
20429
|
return true;
|
|
@@ -20439,7 +20450,7 @@ function useFormDetail(options) {
|
|
|
20439
20450
|
}
|
|
20440
20451
|
|
|
20441
20452
|
// packages/sdk/src/components/hooks/useChangeRecords.ts
|
|
20442
|
-
var
|
|
20453
|
+
var import_react75 = require("react");
|
|
20443
20454
|
var normalizeChangeRecordList = (value) => {
|
|
20444
20455
|
const body = value && typeof value === "object" && !Array.isArray(value) ? Array.isArray(value.data) || Array.isArray(value.records) || Array.isArray(value.list) || Array.isArray(value.items) ? value : value.data ?? value.result ?? value : value;
|
|
20445
20456
|
const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
|
|
@@ -20454,18 +20465,18 @@ function useChangeRecords(options) {
|
|
|
20454
20465
|
const { formUuid, appType, formInstanceId, pageSize = 20, autoLoad = true } = options;
|
|
20455
20466
|
const { api } = useFormContext();
|
|
20456
20467
|
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,
|
|
20468
|
+
const [records, setRecords] = (0, import_react75.useState)([]);
|
|
20469
|
+
const [loading, setLoading] = (0, import_react75.useState)(false);
|
|
20470
|
+
const [total, setTotal] = (0, import_react75.useState)(0);
|
|
20471
|
+
const [page, setPage] = (0, import_react75.useState)(1);
|
|
20472
|
+
const mountedRef = (0, import_react75.useRef)(true);
|
|
20473
|
+
(0, import_react75.useEffect)(() => {
|
|
20463
20474
|
mountedRef.current = true;
|
|
20464
20475
|
return () => {
|
|
20465
20476
|
mountedRef.current = false;
|
|
20466
20477
|
};
|
|
20467
20478
|
}, []);
|
|
20468
|
-
const fetchRecords = (0,
|
|
20479
|
+
const fetchRecords = (0, import_react75.useCallback)(
|
|
20469
20480
|
async (pageNum, append) => {
|
|
20470
20481
|
if (!mountedRef.current) return;
|
|
20471
20482
|
setLoading(true);
|
|
@@ -20496,18 +20507,18 @@ function useChangeRecords(options) {
|
|
|
20496
20507
|
},
|
|
20497
20508
|
[request, formUuid, appType, formInstanceId, pageSize]
|
|
20498
20509
|
);
|
|
20499
|
-
(0,
|
|
20510
|
+
(0, import_react75.useEffect)(() => {
|
|
20500
20511
|
if (autoLoad) {
|
|
20501
20512
|
fetchRecords(1, false);
|
|
20502
20513
|
}
|
|
20503
20514
|
}, [autoLoad, fetchRecords]);
|
|
20504
20515
|
const safeRecords = Array.isArray(records) ? records : [];
|
|
20505
20516
|
const hasMore = safeRecords.length < total;
|
|
20506
|
-
const loadMore = (0,
|
|
20517
|
+
const loadMore = (0, import_react75.useCallback)(async () => {
|
|
20507
20518
|
if (!hasMore || loading) return;
|
|
20508
20519
|
await fetchRecords(page + 1, true);
|
|
20509
20520
|
}, [hasMore, loading, page, fetchRecords]);
|
|
20510
|
-
const refresh = (0,
|
|
20521
|
+
const refresh = (0, import_react75.useCallback)(async () => {
|
|
20511
20522
|
setRecords([]);
|
|
20512
20523
|
setPage(1);
|
|
20513
20524
|
setTotal(0);
|
|
@@ -20661,7 +20672,7 @@ var SummaryPanel = ({
|
|
|
20661
20672
|
};
|
|
20662
20673
|
|
|
20663
20674
|
// packages/sdk/src/components/modules/RecordChangePanel.tsx
|
|
20664
|
-
var
|
|
20675
|
+
var import_react76 = require("react");
|
|
20665
20676
|
var import_antd37 = require("antd");
|
|
20666
20677
|
var import_icons16 = require("@ant-design/icons");
|
|
20667
20678
|
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
@@ -20707,7 +20718,7 @@ var RecordChangePanel = ({
|
|
|
20707
20718
|
onPageChange,
|
|
20708
20719
|
className = ""
|
|
20709
20720
|
}) => {
|
|
20710
|
-
const [expanded, setExpanded] = (0,
|
|
20721
|
+
const [expanded, setExpanded] = (0, import_react76.useState)(defaultExpanded);
|
|
20711
20722
|
const count = total ?? records.length;
|
|
20712
20723
|
const handleToggle = () => {
|
|
20713
20724
|
const next = !expanded;
|
|
@@ -20918,10 +20929,10 @@ var InnerDetailContent = ({
|
|
|
20918
20929
|
onSave,
|
|
20919
20930
|
inDrawer = false
|
|
20920
20931
|
}) => {
|
|
20921
|
-
const formDataRef = (0,
|
|
20922
|
-
const validateRef = (0,
|
|
20923
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
20924
|
-
const fieldIds = (0,
|
|
20932
|
+
const formDataRef = (0, import_react77.useRef)(void 0);
|
|
20933
|
+
const validateRef = (0, import_react77.useRef)(void 0);
|
|
20934
|
+
const [accessDenied, setAccessDenied] = (0, import_react77.useState)(false);
|
|
20935
|
+
const fieldIds = (0, import_react77.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
20925
20936
|
const {
|
|
20926
20937
|
loading,
|
|
20927
20938
|
mode,
|
|
@@ -20956,7 +20967,7 @@ var InnerDetailContent = ({
|
|
|
20956
20967
|
formInstanceId,
|
|
20957
20968
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
20958
20969
|
});
|
|
20959
|
-
const handleSave = (0,
|
|
20970
|
+
const handleSave = (0, import_react77.useCallback)(async () => {
|
|
20960
20971
|
if (validateRef.current && !await validateAndNotify(validateRef.current)) return;
|
|
20961
20972
|
const values = formDataRef.current?.() ?? formData;
|
|
20962
20973
|
if (!values) return;
|
|
@@ -20965,13 +20976,13 @@ var InnerDetailContent = ({
|
|
|
20965
20976
|
onSave?.(values);
|
|
20966
20977
|
}
|
|
20967
20978
|
}, [formData, saveChanges, onSave]);
|
|
20968
|
-
const handleDelete = (0,
|
|
20979
|
+
const handleDelete = (0, import_react77.useCallback)(async () => {
|
|
20969
20980
|
const success = await deleteInstance();
|
|
20970
20981
|
if (success) {
|
|
20971
20982
|
onDelete?.();
|
|
20972
20983
|
}
|
|
20973
20984
|
}, [deleteInstance, onDelete]);
|
|
20974
|
-
const handleCancel = (0,
|
|
20985
|
+
const handleCancel = (0, import_react77.useCallback)(() => {
|
|
20975
20986
|
switchToReadonly();
|
|
20976
20987
|
}, [switchToReadonly]);
|
|
20977
20988
|
const readonlyActions = [];
|
|
@@ -21098,12 +21109,12 @@ var FormDetailTemplate = (props) => {
|
|
|
21098
21109
|
};
|
|
21099
21110
|
|
|
21100
21111
|
// packages/sdk/src/components/templates/FormSubmitTemplate.tsx
|
|
21101
|
-
var
|
|
21112
|
+
var import_react80 = require("react");
|
|
21102
21113
|
var import_antd40 = require("antd");
|
|
21103
21114
|
var import_icons18 = require("@ant-design/icons");
|
|
21104
21115
|
|
|
21105
21116
|
// packages/sdk/src/components/hooks/useDraftStorage.ts
|
|
21106
|
-
var
|
|
21117
|
+
var import_react78 = require("react");
|
|
21107
21118
|
function getDraftKey(appType, formUuid) {
|
|
21108
21119
|
return `${appType}__${formUuid}__draft`;
|
|
21109
21120
|
}
|
|
@@ -21123,10 +21134,10 @@ function readDraft(key) {
|
|
|
21123
21134
|
function useDraftStorage(options) {
|
|
21124
21135
|
const { appType, formUuid, autoRestore = false } = options;
|
|
21125
21136
|
const key = getDraftKey(appType, formUuid);
|
|
21126
|
-
const [hasDraft, setHasDraft] = (0,
|
|
21127
|
-
const [draftData, setDraftData] = (0,
|
|
21128
|
-
const [draftTimestamp, setDraftTimestamp] = (0,
|
|
21129
|
-
(0,
|
|
21137
|
+
const [hasDraft, setHasDraft] = (0, import_react78.useState)(false);
|
|
21138
|
+
const [draftData, setDraftData] = (0, import_react78.useState)(null);
|
|
21139
|
+
const [draftTimestamp, setDraftTimestamp] = (0, import_react78.useState)(null);
|
|
21140
|
+
(0, import_react78.useEffect)(() => {
|
|
21130
21141
|
const stored = readDraft(key);
|
|
21131
21142
|
if (stored) {
|
|
21132
21143
|
setHasDraft(true);
|
|
@@ -21140,7 +21151,7 @@ function useDraftStorage(options) {
|
|
|
21140
21151
|
setDraftTimestamp(null);
|
|
21141
21152
|
}
|
|
21142
21153
|
}, [key, autoRestore]);
|
|
21143
|
-
const saveDraft = (0,
|
|
21154
|
+
const saveDraft = (0, import_react78.useCallback)(
|
|
21144
21155
|
(data) => {
|
|
21145
21156
|
const payload = { data, ts: Date.now() };
|
|
21146
21157
|
try {
|
|
@@ -21154,7 +21165,7 @@ function useDraftStorage(options) {
|
|
|
21154
21165
|
},
|
|
21155
21166
|
[key]
|
|
21156
21167
|
);
|
|
21157
|
-
const restoreDraft = (0,
|
|
21168
|
+
const restoreDraft = (0, import_react78.useCallback)(() => {
|
|
21158
21169
|
const stored = readDraft(key);
|
|
21159
21170
|
if (stored) {
|
|
21160
21171
|
setDraftData(stored.data);
|
|
@@ -21162,7 +21173,7 @@ function useDraftStorage(options) {
|
|
|
21162
21173
|
}
|
|
21163
21174
|
return null;
|
|
21164
21175
|
}, [key]);
|
|
21165
|
-
const clearDraft = (0,
|
|
21176
|
+
const clearDraft = (0, import_react78.useCallback)(() => {
|
|
21166
21177
|
try {
|
|
21167
21178
|
localStorage.removeItem(key);
|
|
21168
21179
|
} catch (error) {
|
|
@@ -21183,7 +21194,7 @@ function useDraftStorage(options) {
|
|
|
21183
21194
|
}
|
|
21184
21195
|
|
|
21185
21196
|
// packages/sdk/src/components/hooks/useFormNavigation.ts
|
|
21186
|
-
var
|
|
21197
|
+
var import_react79 = require("react");
|
|
21187
21198
|
var normalizeBasePath = (basePath) => {
|
|
21188
21199
|
const normalized = String(basePath || "").replace(/^\/+|\/+$/g, "");
|
|
21189
21200
|
return normalized ? `/${normalized}` : "";
|
|
@@ -21215,12 +21226,12 @@ function useFormNavigation(options) {
|
|
|
21215
21226
|
basePath,
|
|
21216
21227
|
onStay
|
|
21217
21228
|
} = 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,
|
|
21229
|
+
const [isRedirecting, setIsRedirecting] = (0, import_react79.useState)(false);
|
|
21230
|
+
const [countdown, setCountdown] = (0, import_react79.useState)(0);
|
|
21231
|
+
const timerRef = (0, import_react79.useRef)(null);
|
|
21232
|
+
const redirectTargetRef = (0, import_react79.useRef)(null);
|
|
21233
|
+
const mountedRef = (0, import_react79.useRef)(true);
|
|
21234
|
+
(0, import_react79.useEffect)(() => {
|
|
21224
21235
|
mountedRef.current = true;
|
|
21225
21236
|
return () => {
|
|
21226
21237
|
mountedRef.current = false;
|
|
@@ -21230,13 +21241,13 @@ function useFormNavigation(options) {
|
|
|
21230
21241
|
}
|
|
21231
21242
|
};
|
|
21232
21243
|
}, []);
|
|
21233
|
-
const navigateToDetail = (0,
|
|
21244
|
+
const navigateToDetail = (0, import_react79.useCallback)(
|
|
21234
21245
|
(formInstId) => {
|
|
21235
21246
|
window.location.href = buildDetailUrl(appType, formUuid, formInstId, "formDetail", basePath);
|
|
21236
21247
|
},
|
|
21237
21248
|
[appType, basePath, formUuid]
|
|
21238
21249
|
);
|
|
21239
|
-
const navigateToProcessDetail = (0,
|
|
21250
|
+
const navigateToProcessDetail = (0, import_react79.useCallback)(
|
|
21240
21251
|
(formInstId) => {
|
|
21241
21252
|
window.location.href = buildDetailUrl(
|
|
21242
21253
|
appType,
|
|
@@ -21248,7 +21259,7 @@ function useFormNavigation(options) {
|
|
|
21248
21259
|
},
|
|
21249
21260
|
[appType, basePath, formUuid]
|
|
21250
21261
|
);
|
|
21251
|
-
const startRedirectCountdown = (0,
|
|
21262
|
+
const startRedirectCountdown = (0, import_react79.useCallback)(
|
|
21252
21263
|
(targetUrl) => {
|
|
21253
21264
|
const totalSeconds = Math.ceil(redirectDelay / 1e3);
|
|
21254
21265
|
setIsRedirecting(true);
|
|
@@ -21281,7 +21292,7 @@ function useFormNavigation(options) {
|
|
|
21281
21292
|
},
|
|
21282
21293
|
[redirectDelay]
|
|
21283
21294
|
);
|
|
21284
|
-
const cancelRedirect = (0,
|
|
21295
|
+
const cancelRedirect = (0, import_react79.useCallback)(() => {
|
|
21285
21296
|
if (timerRef.current) {
|
|
21286
21297
|
clearInterval(timerRef.current);
|
|
21287
21298
|
timerRef.current = null;
|
|
@@ -21290,7 +21301,7 @@ function useFormNavigation(options) {
|
|
|
21290
21301
|
setCountdown(0);
|
|
21291
21302
|
redirectTargetRef.current = null;
|
|
21292
21303
|
}, []);
|
|
21293
|
-
const handlePostSubmit = (0,
|
|
21304
|
+
const handlePostSubmit = (0, import_react79.useCallback)(
|
|
21294
21305
|
(formInstId) => {
|
|
21295
21306
|
if (mode === "stay") {
|
|
21296
21307
|
onStay?.(formInstId);
|
|
@@ -21505,26 +21516,26 @@ var InnerFormContent = ({
|
|
|
21505
21516
|
inDrawer = false
|
|
21506
21517
|
}) => {
|
|
21507
21518
|
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,
|
|
21519
|
+
const [submitted, setSubmitted] = (0, import_react80.useState)(false);
|
|
21520
|
+
const [successInfo, setSuccessInfo] = (0, import_react80.useState)(null);
|
|
21521
|
+
const [submitting, setSubmitting] = (0, import_react80.useState)(false);
|
|
21522
|
+
const [departmentId, setDepartmentId] = (0, import_react80.useState)();
|
|
21523
|
+
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = (0, import_react80.useState)(false);
|
|
21524
|
+
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = (0, import_react80.useState)([]);
|
|
21525
|
+
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = (0, import_react80.useState)();
|
|
21526
|
+
const submissionDepartmentResolverRef = (0, import_react80.useRef)(null);
|
|
21527
|
+
const [previewOpen, setPreviewOpen] = (0, import_react80.useState)(false);
|
|
21528
|
+
const [previewLoading, setPreviewLoading] = (0, import_react80.useState)(false);
|
|
21529
|
+
const [previewRoutes, setPreviewRoutes] = (0, import_react80.useState)([]);
|
|
21530
|
+
const [pendingFormData, setPendingFormData] = (0, import_react80.useState)(null);
|
|
21531
|
+
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = (0, import_react80.useState)();
|
|
21532
|
+
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = (0, import_react80.useState)();
|
|
21533
|
+
const pendingSubmissionDepartmentIdRef = (0, import_react80.useRef)(void 0);
|
|
21534
|
+
const pendingInitiatorSelectedApproversRef = (0, import_react80.useRef)(
|
|
21524
21535
|
void 0
|
|
21525
21536
|
);
|
|
21526
|
-
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0,
|
|
21527
|
-
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0,
|
|
21537
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react80.useState)(false);
|
|
21538
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react80.useState)([]);
|
|
21528
21539
|
const { hasDraft, draftTimestamp, saveDraft, restoreDraft, clearDraft } = useDraftStorage({
|
|
21529
21540
|
appType: config.appType,
|
|
21530
21541
|
formUuid: config.formUuid
|
|
@@ -21536,20 +21547,20 @@ var InnerFormContent = ({
|
|
|
21536
21547
|
mode: submitSuccessMode === "continue" ? "stay" : submitSuccessMode,
|
|
21537
21548
|
basePath: config.navigation?.basePath
|
|
21538
21549
|
});
|
|
21539
|
-
(0,
|
|
21550
|
+
(0, import_react80.useEffect)(() => {
|
|
21540
21551
|
return () => {
|
|
21541
21552
|
submissionDepartmentResolverRef.current?.(null);
|
|
21542
21553
|
submissionDepartmentResolverRef.current = null;
|
|
21543
21554
|
};
|
|
21544
21555
|
}, []);
|
|
21545
|
-
const closeSubmissionDepartmentModal = (0,
|
|
21556
|
+
const closeSubmissionDepartmentModal = (0, import_react80.useCallback)((value = null) => {
|
|
21546
21557
|
setSubmissionDepartmentModalOpen(false);
|
|
21547
21558
|
setSubmissionDepartmentOptions([]);
|
|
21548
21559
|
setSelectedSubmissionDepartmentId(void 0);
|
|
21549
21560
|
submissionDepartmentResolverRef.current?.(value);
|
|
21550
21561
|
submissionDepartmentResolverRef.current = null;
|
|
21551
21562
|
}, []);
|
|
21552
|
-
const promptSubmissionDepartmentSelection = (0,
|
|
21563
|
+
const promptSubmissionDepartmentSelection = (0, import_react80.useCallback)(
|
|
21553
21564
|
(options, preferredDepartmentId) => {
|
|
21554
21565
|
return new Promise((resolve) => {
|
|
21555
21566
|
const selected = options.some((option) => option.value === preferredDepartmentId) ? preferredDepartmentId : options[0]?.value;
|
|
@@ -21561,7 +21572,7 @@ var InnerFormContent = ({
|
|
|
21561
21572
|
},
|
|
21562
21573
|
[]
|
|
21563
21574
|
);
|
|
21564
|
-
const resolveSubmissionDepartmentId = (0,
|
|
21575
|
+
const resolveSubmissionDepartmentId = (0, import_react80.useCallback)(async () => {
|
|
21565
21576
|
if (formType !== "process") {
|
|
21566
21577
|
return void 0;
|
|
21567
21578
|
}
|
|
@@ -21583,7 +21594,7 @@ var InnerFormContent = ({
|
|
|
21583
21594
|
}
|
|
21584
21595
|
return promptSubmissionDepartmentSelection(departments, departmentId);
|
|
21585
21596
|
}, [api, config.formUuid, departmentId, formType, promptSubmissionDepartmentSelection, schema]);
|
|
21586
|
-
const performSubmit = (0,
|
|
21597
|
+
const performSubmit = (0, import_react80.useCallback)(
|
|
21587
21598
|
async (formData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
21588
21599
|
const submitData = normalizeFormDataForSubmit(schema, formData);
|
|
21589
21600
|
setSubmitting(true);
|
|
@@ -21660,7 +21671,7 @@ var InnerFormContent = ({
|
|
|
21660
21671
|
departmentId
|
|
21661
21672
|
]
|
|
21662
21673
|
);
|
|
21663
|
-
const continuePreparedSubmit = (0,
|
|
21674
|
+
const continuePreparedSubmit = (0, import_react80.useCallback)(
|
|
21664
21675
|
async (submitData, submissionDepartmentId, initiatorSelectedApprovers) => {
|
|
21665
21676
|
if (formType === "process" && enableProcessPreview && !isSaveDraftSubmitBehavior(config)) {
|
|
21666
21677
|
setPendingFormData(submitData);
|
|
@@ -21692,7 +21703,7 @@ var InnerFormContent = ({
|
|
|
21692
21703
|
},
|
|
21693
21704
|
[api.request, config, enableProcessPreview, formType, performSubmit]
|
|
21694
21705
|
);
|
|
21695
|
-
const prepareSubmit = (0,
|
|
21706
|
+
const prepareSubmit = (0, import_react80.useCallback)(async () => {
|
|
21696
21707
|
const valid = await validateAndNotify(validateAllWithErrors);
|
|
21697
21708
|
if (!valid) return;
|
|
21698
21709
|
const formData = getFormData2();
|
|
@@ -21749,7 +21760,7 @@ var InnerFormContent = ({
|
|
|
21749
21760
|
resolveSubmissionDepartmentId,
|
|
21750
21761
|
continuePreparedSubmit
|
|
21751
21762
|
]);
|
|
21752
|
-
const handlePreviewConfirm = (0,
|
|
21763
|
+
const handlePreviewConfirm = (0, import_react80.useCallback)(async () => {
|
|
21753
21764
|
const data = pendingFormData ?? getFormData2();
|
|
21754
21765
|
const submissionDepartmentId = pendingSubmissionDepartmentIdRef.current ?? pendingSubmissionDepartmentId;
|
|
21755
21766
|
const initiatorSelectedApprovers = pendingInitiatorSelectedApproversRef.current ?? pendingInitiatorSelectedApprovers;
|
|
@@ -21767,7 +21778,7 @@ var InnerFormContent = ({
|
|
|
21767
21778
|
pendingSubmissionDepartmentId,
|
|
21768
21779
|
performSubmit
|
|
21769
21780
|
]);
|
|
21770
|
-
const handleInitiatorApproverConfirm = (0,
|
|
21781
|
+
const handleInitiatorApproverConfirm = (0, import_react80.useCallback)(
|
|
21771
21782
|
async (selectedUsersByNode) => {
|
|
21772
21783
|
const data = pendingFormData;
|
|
21773
21784
|
if (!data) {
|
|
@@ -21783,7 +21794,7 @@ var InnerFormContent = ({
|
|
|
21783
21794
|
},
|
|
21784
21795
|
[continuePreparedSubmit, pendingFormData, pendingSubmissionDepartmentId]
|
|
21785
21796
|
);
|
|
21786
|
-
const handleInitiatorApproverCancel = (0,
|
|
21797
|
+
const handleInitiatorApproverCancel = (0, import_react80.useCallback)(() => {
|
|
21787
21798
|
setInitiatorApproverOpen(false);
|
|
21788
21799
|
setInitiatorApproverRequirements([]);
|
|
21789
21800
|
setPendingFormData(null);
|
|
@@ -21792,23 +21803,23 @@ var InnerFormContent = ({
|
|
|
21792
21803
|
pendingSubmissionDepartmentIdRef.current = void 0;
|
|
21793
21804
|
pendingInitiatorSelectedApproversRef.current = void 0;
|
|
21794
21805
|
}, []);
|
|
21795
|
-
const handleSaveDraft = (0,
|
|
21806
|
+
const handleSaveDraft = (0, import_react80.useCallback)(() => {
|
|
21796
21807
|
const data = getFormData2();
|
|
21797
21808
|
saveDraft(data);
|
|
21798
21809
|
}, [getFormData2, saveDraft]);
|
|
21799
|
-
const handleRestoreDraft = (0,
|
|
21810
|
+
const handleRestoreDraft = (0, import_react80.useCallback)(() => {
|
|
21800
21811
|
const data = restoreDraft();
|
|
21801
21812
|
if (!data) return;
|
|
21802
21813
|
Object.entries(data).forEach(([fieldId, value]) => {
|
|
21803
21814
|
setFieldValue(fieldId, value);
|
|
21804
21815
|
});
|
|
21805
21816
|
}, [restoreDraft, setFieldValue]);
|
|
21806
|
-
const handleContinue = (0,
|
|
21817
|
+
const handleContinue = (0, import_react80.useCallback)(() => {
|
|
21807
21818
|
setSubmitted(false);
|
|
21808
21819
|
setSuccessInfo(null);
|
|
21809
21820
|
resetForm();
|
|
21810
21821
|
}, [resetForm]);
|
|
21811
|
-
const handleViewDetail = (0,
|
|
21822
|
+
const handleViewDetail = (0, import_react80.useCallback)(() => {
|
|
21812
21823
|
if (!successInfo) return;
|
|
21813
21824
|
if (formType === "process") {
|
|
21814
21825
|
navigateToProcessDetail(successInfo.formInstanceId);
|
|
@@ -22029,15 +22040,15 @@ var FormSubmitTemplate = ({
|
|
|
22029
22040
|
};
|
|
22030
22041
|
|
|
22031
22042
|
// packages/sdk/src/components/templates/ProcessDetailTemplate.tsx
|
|
22032
|
-
var
|
|
22043
|
+
var import_react85 = require("react");
|
|
22033
22044
|
var import_dayjs11 = __toESM(require("dayjs"));
|
|
22034
22045
|
var import_antd42 = require("antd");
|
|
22035
22046
|
|
|
22036
22047
|
// packages/sdk/src/components/hooks/useProcessDetail.ts
|
|
22037
|
-
var
|
|
22048
|
+
var import_react82 = require("react");
|
|
22038
22049
|
|
|
22039
22050
|
// packages/sdk/src/components/hooks/useFieldPermission.ts
|
|
22040
|
-
var
|
|
22051
|
+
var import_react81 = require("react");
|
|
22041
22052
|
var normalizeBehavior = (value) => {
|
|
22042
22053
|
if (value === "EDITABLE") return "NORMAL";
|
|
22043
22054
|
if (value === "READ_ONLY") return "READONLY";
|
|
@@ -22070,7 +22081,7 @@ var normalizeFlowConfig = (config) => {
|
|
|
22070
22081
|
};
|
|
22071
22082
|
function useFieldPermission(options) {
|
|
22072
22083
|
const { viewPermissions, processDefinition, currentTask, isApprover, mode } = options;
|
|
22073
|
-
const computeBehaviors = (0,
|
|
22084
|
+
const computeBehaviors = (0, import_react81.useCallback)(() => {
|
|
22074
22085
|
const behaviors = {};
|
|
22075
22086
|
if (!currentTask && viewPermissions) {
|
|
22076
22087
|
return normalizeFieldBehaviors(viewPermissions, mode);
|
|
@@ -22115,7 +22126,7 @@ function useFieldPermission(options) {
|
|
|
22115
22126
|
}
|
|
22116
22127
|
return behaviors;
|
|
22117
22128
|
}, [viewPermissions, processDefinition, currentTask, isApprover, mode]);
|
|
22118
|
-
const fieldBehaviors = (0,
|
|
22129
|
+
const fieldBehaviors = (0, import_react81.useMemo)(() => computeBehaviors(), [computeBehaviors]);
|
|
22119
22130
|
return { fieldBehaviors, computeBehaviors };
|
|
22120
22131
|
}
|
|
22121
22132
|
|
|
@@ -22147,29 +22158,29 @@ function useProcessDetail(options) {
|
|
|
22147
22158
|
const { formUuid, appType, formInstanceId, fieldIds } = options;
|
|
22148
22159
|
const { api } = useFormContext();
|
|
22149
22160
|
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,
|
|
22161
|
+
const [loading, setLoading] = (0, import_react82.useState)(true);
|
|
22162
|
+
const [mode, setMode] = (0, import_react82.useState)("readonly");
|
|
22163
|
+
const [processInfo, setProcessInfo] = (0, import_react82.useState)(null);
|
|
22164
|
+
const [progressList, setProgressList] = (0, import_react82.useState)([]);
|
|
22165
|
+
const [formData, setFormData] = (0, import_react82.useState)(null);
|
|
22166
|
+
const [instanceInfo, setInstanceInfo] = (0, import_react82.useState)(null);
|
|
22167
|
+
const [accessDenied, setAccessDenied] = (0, import_react82.useState)(false);
|
|
22168
|
+
const [loadError, setLoadError] = (0, import_react82.useState)(null);
|
|
22169
|
+
const [isApprover, setIsApprover] = (0, import_react82.useState)(false);
|
|
22170
|
+
const [canWithdraw, setCanWithdraw] = (0, import_react82.useState)(false);
|
|
22171
|
+
const [approvalTasks, setApprovalTasks] = (0, import_react82.useState)([]);
|
|
22172
|
+
const [permissions, setPermissions] = (0, import_react82.useState)(null);
|
|
22173
|
+
const [processDefinition, setProcessDefinition] = (0, import_react82.useState)(null);
|
|
22174
|
+
const [dataVersion, setDataVersion] = (0, import_react82.useState)(0);
|
|
22175
|
+
const mountedRef = (0, import_react82.useRef)(true);
|
|
22165
22176
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
22166
|
-
(0,
|
|
22177
|
+
(0, import_react82.useEffect)(() => {
|
|
22167
22178
|
mountedRef.current = true;
|
|
22168
22179
|
return () => {
|
|
22169
22180
|
mountedRef.current = false;
|
|
22170
22181
|
};
|
|
22171
22182
|
}, []);
|
|
22172
|
-
const currentTask = (0,
|
|
22183
|
+
const currentTask = (0, import_react82.useMemo)(
|
|
22173
22184
|
() => mergeCurrentTask(processInfo?.currentTask, approvalTasks[0]),
|
|
22174
22185
|
[processInfo?.currentTask, approvalTasks]
|
|
22175
22186
|
);
|
|
@@ -22189,7 +22200,7 @@ function useProcessDetail(options) {
|
|
|
22189
22200
|
isApprover: isProcessFinal ? false : isApprover,
|
|
22190
22201
|
mode
|
|
22191
22202
|
});
|
|
22192
|
-
const activeActions = (0,
|
|
22203
|
+
const activeActions = (0, import_react82.useMemo)(() => {
|
|
22193
22204
|
if (!isApprover || isProcessFinal) return [];
|
|
22194
22205
|
const actions = currentTask?.actions && currentTask.actions.length > 0 ? [...currentTask.actions] : [...DEFAULT_APPROVAL_ACTIONS];
|
|
22195
22206
|
if (canWithdraw && !actions.some((action) => action.action === "withdraw")) {
|
|
@@ -22197,7 +22208,7 @@ function useProcessDetail(options) {
|
|
|
22197
22208
|
}
|
|
22198
22209
|
return actions;
|
|
22199
22210
|
}, [isApprover, isProcessFinal, currentTask?.actions, canWithdraw]);
|
|
22200
|
-
const loadData = (0,
|
|
22211
|
+
const loadData = (0, import_react82.useCallback)(async () => {
|
|
22201
22212
|
if (!mountedRef.current) return;
|
|
22202
22213
|
setLoading(true);
|
|
22203
22214
|
setAccessDenied(false);
|
|
@@ -22279,24 +22290,24 @@ function useProcessDetail(options) {
|
|
|
22279
22290
|
}
|
|
22280
22291
|
}
|
|
22281
22292
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
22282
|
-
(0,
|
|
22293
|
+
(0, import_react82.useEffect)(() => {
|
|
22283
22294
|
loadData();
|
|
22284
22295
|
}, [loadData]);
|
|
22285
|
-
const switchToEdit = (0,
|
|
22296
|
+
const switchToEdit = (0, import_react82.useCallback)(() => {
|
|
22286
22297
|
setMode("edit");
|
|
22287
22298
|
void loadData();
|
|
22288
22299
|
}, [loadData]);
|
|
22289
|
-
const switchToReadonly = (0,
|
|
22300
|
+
const switchToReadonly = (0, import_react82.useCallback)(() => {
|
|
22290
22301
|
setMode("readonly");
|
|
22291
22302
|
}, []);
|
|
22292
|
-
const refreshDetail = (0,
|
|
22303
|
+
const refreshDetail = (0, import_react82.useCallback)(async () => {
|
|
22293
22304
|
setMode("readonly");
|
|
22294
22305
|
await loadData();
|
|
22295
22306
|
}, [loadData]);
|
|
22296
|
-
const refreshProgress = (0,
|
|
22307
|
+
const refreshProgress = (0, import_react82.useCallback)(async () => {
|
|
22297
22308
|
await refreshDetail();
|
|
22298
22309
|
}, [refreshDetail]);
|
|
22299
|
-
const saveChanges = (0,
|
|
22310
|
+
const saveChanges = (0, import_react82.useCallback)(
|
|
22300
22311
|
async (values) => {
|
|
22301
22312
|
try {
|
|
22302
22313
|
await api.updateFormData({
|
|
@@ -22315,7 +22326,7 @@ function useProcessDetail(options) {
|
|
|
22315
22326
|
},
|
|
22316
22327
|
[api, formInstanceId, formUuid, appType, loadData]
|
|
22317
22328
|
);
|
|
22318
|
-
const deleteInstance = (0,
|
|
22329
|
+
const deleteInstance = (0, import_react82.useCallback)(async () => {
|
|
22319
22330
|
try {
|
|
22320
22331
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
22321
22332
|
return true;
|
|
@@ -22356,29 +22367,29 @@ function useProcessDetail(options) {
|
|
|
22356
22367
|
}
|
|
22357
22368
|
|
|
22358
22369
|
// packages/sdk/src/components/hooks/useApprovalActions.ts
|
|
22359
|
-
var
|
|
22370
|
+
var import_react83 = require("react");
|
|
22360
22371
|
function useApprovalActions(options) {
|
|
22361
22372
|
const { formInstanceId, formUuid, appType, currentTaskId, onActionComplete, getFormValues } = options;
|
|
22362
22373
|
const { api } = useFormContext();
|
|
22363
22374
|
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,
|
|
22375
|
+
const [isLoading, setIsLoading] = (0, import_react83.useState)(false);
|
|
22376
|
+
const [currentAction, setCurrentAction] = (0, import_react83.useState)(null);
|
|
22377
|
+
const [returnableNodes, setReturnableNodes] = (0, import_react83.useState)([]);
|
|
22378
|
+
const [returnPolicy, setReturnPolicy] = (0, import_react83.useState)(null);
|
|
22379
|
+
const mountedRef = (0, import_react83.useRef)(true);
|
|
22380
|
+
(0, import_react83.useEffect)(() => {
|
|
22370
22381
|
mountedRef.current = true;
|
|
22371
22382
|
return () => {
|
|
22372
22383
|
mountedRef.current = false;
|
|
22373
22384
|
};
|
|
22374
22385
|
}, []);
|
|
22375
|
-
const resetLoading = (0,
|
|
22386
|
+
const resetLoading = (0, import_react83.useCallback)(() => {
|
|
22376
22387
|
if (mountedRef.current) {
|
|
22377
22388
|
setIsLoading(false);
|
|
22378
22389
|
setCurrentAction(null);
|
|
22379
22390
|
}
|
|
22380
22391
|
}, []);
|
|
22381
|
-
const approve = (0,
|
|
22392
|
+
const approve = (0, import_react83.useCallback)(
|
|
22382
22393
|
async (comments) => {
|
|
22383
22394
|
setIsLoading(true);
|
|
22384
22395
|
setCurrentAction("approve");
|
|
@@ -22403,7 +22414,7 @@ function useApprovalActions(options) {
|
|
|
22403
22414
|
},
|
|
22404
22415
|
[request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
|
|
22405
22416
|
);
|
|
22406
|
-
const reject = (0,
|
|
22417
|
+
const reject = (0, import_react83.useCallback)(
|
|
22407
22418
|
async (comments) => {
|
|
22408
22419
|
setIsLoading(true);
|
|
22409
22420
|
setCurrentAction("reject");
|
|
@@ -22424,7 +22435,7 @@ function useApprovalActions(options) {
|
|
|
22424
22435
|
},
|
|
22425
22436
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
22426
22437
|
);
|
|
22427
|
-
const transfer = (0,
|
|
22438
|
+
const transfer = (0, import_react83.useCallback)(
|
|
22428
22439
|
async (userId, reason) => {
|
|
22429
22440
|
if (!currentTaskId) {
|
|
22430
22441
|
console.error("[useApprovalActions] transfer failed: no currentTaskId");
|
|
@@ -22449,7 +22460,7 @@ function useApprovalActions(options) {
|
|
|
22449
22460
|
},
|
|
22450
22461
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22451
22462
|
);
|
|
22452
|
-
const returnTo = (0,
|
|
22463
|
+
const returnTo = (0, import_react83.useCallback)(
|
|
22453
22464
|
async (nodeId, reason) => {
|
|
22454
22465
|
if (!currentTaskId) {
|
|
22455
22466
|
console.error("[useApprovalActions] returnTo failed: no currentTaskId");
|
|
@@ -22474,7 +22485,7 @@ function useApprovalActions(options) {
|
|
|
22474
22485
|
},
|
|
22475
22486
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22476
22487
|
);
|
|
22477
|
-
const withdraw = (0,
|
|
22488
|
+
const withdraw = (0, import_react83.useCallback)(
|
|
22478
22489
|
async (reason) => {
|
|
22479
22490
|
setIsLoading(true);
|
|
22480
22491
|
setCurrentAction("withdraw");
|
|
@@ -22494,7 +22505,7 @@ function useApprovalActions(options) {
|
|
|
22494
22505
|
},
|
|
22495
22506
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
22496
22507
|
);
|
|
22497
|
-
const save = (0,
|
|
22508
|
+
const save = (0, import_react83.useCallback)(async () => {
|
|
22498
22509
|
setIsLoading(true);
|
|
22499
22510
|
setCurrentAction("save");
|
|
22500
22511
|
try {
|
|
@@ -22514,7 +22525,7 @@ function useApprovalActions(options) {
|
|
|
22514
22525
|
return false;
|
|
22515
22526
|
}
|
|
22516
22527
|
}, [request, formInstanceId, formUuid, appType, getFormValues, onActionComplete, resetLoading]);
|
|
22517
|
-
const resubmit = (0,
|
|
22528
|
+
const resubmit = (0, import_react83.useCallback)(
|
|
22518
22529
|
async (comments, selectedApprovers) => {
|
|
22519
22530
|
if (!currentTaskId) {
|
|
22520
22531
|
console.error("[useApprovalActions] resubmit failed: no currentTaskId");
|
|
@@ -22544,7 +22555,7 @@ function useApprovalActions(options) {
|
|
|
22544
22555
|
},
|
|
22545
22556
|
[request, currentTaskId, formUuid, appType, getFormValues, onActionComplete, resetLoading]
|
|
22546
22557
|
);
|
|
22547
|
-
const callbackTask = (0,
|
|
22558
|
+
const callbackTask = (0, import_react83.useCallback)(
|
|
22548
22559
|
async (payload) => {
|
|
22549
22560
|
if (!currentTaskId) {
|
|
22550
22561
|
console.error("[useApprovalActions] callbackTask failed: no currentTaskId");
|
|
@@ -22568,7 +22579,7 @@ function useApprovalActions(options) {
|
|
|
22568
22579
|
},
|
|
22569
22580
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
22570
22581
|
);
|
|
22571
|
-
const loadReturnableNodes = (0,
|
|
22582
|
+
const loadReturnableNodes = (0, import_react83.useCallback)(async () => {
|
|
22572
22583
|
if (!currentTaskId) return [];
|
|
22573
22584
|
try {
|
|
22574
22585
|
const result = await getReturnableNodeResult(request, currentTaskId);
|
|
@@ -22604,7 +22615,7 @@ function useApprovalActions(options) {
|
|
|
22604
22615
|
}
|
|
22605
22616
|
|
|
22606
22617
|
// packages/sdk/src/components/modules/ApprovalActionBar.tsx
|
|
22607
|
-
var
|
|
22618
|
+
var import_react84 = __toESM(require("react"));
|
|
22608
22619
|
var import_antd41 = require("antd");
|
|
22609
22620
|
var import_icons19 = require("@ant-design/icons");
|
|
22610
22621
|
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
@@ -22657,12 +22668,12 @@ function DefaultTransferSelector({
|
|
|
22657
22668
|
value,
|
|
22658
22669
|
onChange
|
|
22659
22670
|
}) {
|
|
22660
|
-
const formContext =
|
|
22671
|
+
const formContext = import_react84.default.useContext(FormContext);
|
|
22661
22672
|
const { isMobile } = useDeviceDetect();
|
|
22662
|
-
const fallbackApi = (0,
|
|
22673
|
+
const fallbackApi = (0, import_react84.useMemo)(() => createFormRuntimeApi(), []);
|
|
22663
22674
|
const api = formContext?.api ?? fallbackApi;
|
|
22664
|
-
const [open, setOpen] = (0,
|
|
22665
|
-
const [selectedUsers, setSelectedUsers] = (0,
|
|
22675
|
+
const [open, setOpen] = (0, import_react84.useState)(false);
|
|
22676
|
+
const [selectedUsers, setSelectedUsers] = (0, import_react84.useState)([]);
|
|
22666
22677
|
const selectedLabel = selectedUsers[0] ? getUserName(selectedUsers[0]) : value;
|
|
22667
22678
|
return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
|
|
22668
22679
|
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
@@ -22717,10 +22728,10 @@ var ApprovalActionBar = ({
|
|
|
22717
22728
|
maxWidth
|
|
22718
22729
|
}) => {
|
|
22719
22730
|
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,
|
|
22731
|
+
const [modalAction, setModalAction] = (0, import_react84.useState)(null);
|
|
22732
|
+
const [activeAction, setActiveAction] = (0, import_react84.useState)(null);
|
|
22733
|
+
const [loading, setLoading] = (0, import_react84.useState)(false);
|
|
22734
|
+
const visibleActions = (0, import_react84.useMemo)(
|
|
22724
22735
|
() => actions.filter((action) => !action.hidden).sort((a, b) => (actionPriority2[a.action] ?? 50) - (actionPriority2[b.action] ?? 50)),
|
|
22725
22736
|
[actions]
|
|
22726
22737
|
);
|
|
@@ -22987,17 +22998,17 @@ var InnerProcessContent = ({
|
|
|
22987
22998
|
onDelete,
|
|
22988
22999
|
inDrawer = false
|
|
22989
23000
|
}) => {
|
|
22990
|
-
const formDataRef = (0,
|
|
22991
|
-
const validateRef = (0,
|
|
23001
|
+
const formDataRef = (0, import_react85.useRef)(void 0);
|
|
23002
|
+
const validateRef = (0, import_react85.useRef)(void 0);
|
|
22992
23003
|
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,
|
|
23004
|
+
const [withdrawOpen, setWithdrawOpen] = (0, import_react85.useState)(false);
|
|
23005
|
+
const [withdrawLoading, setWithdrawLoading] = (0, import_react85.useState)(false);
|
|
23006
|
+
const [saveLoading, setSaveLoading] = (0, import_react85.useState)(false);
|
|
23007
|
+
const [deleteLoading, setDeleteLoading] = (0, import_react85.useState)(false);
|
|
23008
|
+
const [initiatorApproverOpen, setInitiatorApproverOpen] = (0, import_react85.useState)(false);
|
|
23009
|
+
const [initiatorApproverRequirements, setInitiatorApproverRequirements] = (0, import_react85.useState)([]);
|
|
23010
|
+
const [pendingResubmitComments, setPendingResubmitComments] = (0, import_react85.useState)();
|
|
23011
|
+
const fieldIds = (0, import_react85.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
23001
23012
|
const { api } = useFormContext();
|
|
23002
23013
|
const {
|
|
23003
23014
|
loading,
|
|
@@ -23065,45 +23076,45 @@ var InnerProcessContent = ({
|
|
|
23065
23076
|
formInstanceId,
|
|
23066
23077
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
23067
23078
|
});
|
|
23068
|
-
const validateForm = (0,
|
|
23079
|
+
const validateForm = (0, import_react85.useCallback)(async () => {
|
|
23069
23080
|
return validateRef.current ? validateAndNotify(validateRef.current) : true;
|
|
23070
23081
|
}, []);
|
|
23071
|
-
const handleApprove = (0,
|
|
23082
|
+
const handleApprove = (0, import_react85.useCallback)(
|
|
23072
23083
|
async (comments) => {
|
|
23073
23084
|
if (!await validateForm()) return;
|
|
23074
23085
|
await approve(comments);
|
|
23075
23086
|
},
|
|
23076
23087
|
[approve, validateForm]
|
|
23077
23088
|
);
|
|
23078
|
-
const handleReject = (0,
|
|
23089
|
+
const handleReject = (0, import_react85.useCallback)(
|
|
23079
23090
|
async (comments) => {
|
|
23080
23091
|
await reject(comments);
|
|
23081
23092
|
},
|
|
23082
23093
|
[reject]
|
|
23083
23094
|
);
|
|
23084
|
-
const handleTransfer = (0,
|
|
23095
|
+
const handleTransfer = (0, import_react85.useCallback)(
|
|
23085
23096
|
async (userId, reason) => {
|
|
23086
23097
|
await transfer(userId, reason);
|
|
23087
23098
|
},
|
|
23088
23099
|
[transfer]
|
|
23089
23100
|
);
|
|
23090
|
-
const handleReturn = (0,
|
|
23101
|
+
const handleReturn = (0, import_react85.useCallback)(
|
|
23091
23102
|
async (nodeId, reason) => {
|
|
23092
23103
|
await returnTo(nodeId, reason);
|
|
23093
23104
|
},
|
|
23094
23105
|
[returnTo]
|
|
23095
23106
|
);
|
|
23096
|
-
const handleWithdraw = (0,
|
|
23107
|
+
const handleWithdraw = (0, import_react85.useCallback)(
|
|
23097
23108
|
async (reason) => {
|
|
23098
23109
|
await withdraw(reason);
|
|
23099
23110
|
},
|
|
23100
23111
|
[withdraw]
|
|
23101
23112
|
);
|
|
23102
|
-
const handleSave = (0,
|
|
23113
|
+
const handleSave = (0, import_react85.useCallback)(async () => {
|
|
23103
23114
|
if (!await validateForm()) return;
|
|
23104
23115
|
await save();
|
|
23105
23116
|
}, [save, validateForm]);
|
|
23106
|
-
const handleResubmit = (0,
|
|
23117
|
+
const handleResubmit = (0, import_react85.useCallback)(
|
|
23107
23118
|
async (comments) => {
|
|
23108
23119
|
if (!await validateForm()) return;
|
|
23109
23120
|
const values = formDataRef.current?.() ?? formData ?? {};
|
|
@@ -23137,7 +23148,7 @@ var InnerProcessContent = ({
|
|
|
23137
23148
|
},
|
|
23138
23149
|
[api.request, appType, currentTaskId, formData, formUuid, resubmit, validateForm]
|
|
23139
23150
|
);
|
|
23140
|
-
const handleInitiatorApproverConfirm = (0,
|
|
23151
|
+
const handleInitiatorApproverConfirm = (0, import_react85.useCallback)(
|
|
23141
23152
|
async (selectedUsersByNode) => {
|
|
23142
23153
|
const selectedApprovers = normalizeSelectedApprovers2(selectedUsersByNode);
|
|
23143
23154
|
setInitiatorApproverOpen(false);
|
|
@@ -23148,15 +23159,15 @@ var InnerProcessContent = ({
|
|
|
23148
23159
|
},
|
|
23149
23160
|
[pendingResubmitComments, resubmit]
|
|
23150
23161
|
);
|
|
23151
|
-
const handleInitiatorApproverCancel = (0,
|
|
23162
|
+
const handleInitiatorApproverCancel = (0, import_react85.useCallback)(() => {
|
|
23152
23163
|
setInitiatorApproverOpen(false);
|
|
23153
23164
|
setInitiatorApproverRequirements([]);
|
|
23154
23165
|
setPendingResubmitComments(void 0);
|
|
23155
23166
|
}, []);
|
|
23156
|
-
const handleCallback = (0,
|
|
23167
|
+
const handleCallback = (0, import_react85.useCallback)(async () => {
|
|
23157
23168
|
await callbackTask();
|
|
23158
23169
|
}, [callbackTask]);
|
|
23159
|
-
const handleCompletedSave = (0,
|
|
23170
|
+
const handleCompletedSave = (0, import_react85.useCallback)(async () => {
|
|
23160
23171
|
if (!await validateForm()) return;
|
|
23161
23172
|
const values = formDataRef.current?.() ?? formData;
|
|
23162
23173
|
if (!values) return;
|
|
@@ -23170,7 +23181,7 @@ var InnerProcessContent = ({
|
|
|
23170
23181
|
setSaveLoading(false);
|
|
23171
23182
|
}
|
|
23172
23183
|
}, [formData, onSave, saveChanges, validateForm]);
|
|
23173
|
-
const handleCompletedDelete = (0,
|
|
23184
|
+
const handleCompletedDelete = (0, import_react85.useCallback)(async () => {
|
|
23174
23185
|
setDeleteLoading(true);
|
|
23175
23186
|
try {
|
|
23176
23187
|
const success = await deleteInstance();
|
|
@@ -23181,7 +23192,7 @@ var InnerProcessContent = ({
|
|
|
23181
23192
|
setDeleteLoading(false);
|
|
23182
23193
|
}
|
|
23183
23194
|
}, [deleteInstance, onDelete]);
|
|
23184
|
-
const handleFooterWithdraw = (0,
|
|
23195
|
+
const handleFooterWithdraw = (0, import_react85.useCallback)(async () => {
|
|
23185
23196
|
const values = await withdrawForm.validateFields();
|
|
23186
23197
|
setWithdrawLoading(true);
|
|
23187
23198
|
try {
|
|
@@ -23192,11 +23203,11 @@ var InnerProcessContent = ({
|
|
|
23192
23203
|
setWithdrawLoading(false);
|
|
23193
23204
|
}
|
|
23194
23205
|
}, [handleWithdraw, withdrawForm]);
|
|
23195
|
-
const handleFooterWithdrawCancel = (0,
|
|
23206
|
+
const handleFooterWithdrawCancel = (0, import_react85.useCallback)(() => {
|
|
23196
23207
|
setWithdrawOpen(false);
|
|
23197
23208
|
withdrawForm.resetFields();
|
|
23198
23209
|
}, [withdrawForm]);
|
|
23199
|
-
const bottomActions = (0,
|
|
23210
|
+
const bottomActions = (0, import_react85.useMemo)(() => {
|
|
23200
23211
|
if (isApprover && !isOriginatorReturn && activeActions.length > 0) return [];
|
|
23201
23212
|
if (isProcessCompleted) {
|
|
23202
23213
|
if (mode === "readonly") {
|
|
@@ -23546,7 +23557,7 @@ var StandardFormPage = ({
|
|
|
23546
23557
|
const formType = normalizeStandardFormType(
|
|
23547
23558
|
schema.template?.formType || (resolvedMode === "process" ? "process" : "form")
|
|
23548
23559
|
);
|
|
23549
|
-
const submitApi = (0,
|
|
23560
|
+
const submitApi = (0, import_react86.useMemo)(() => {
|
|
23550
23561
|
if (!onSubmit) return void 0;
|
|
23551
23562
|
return {
|
|
23552
23563
|
submitFormData: async (payload) => onSubmit(
|
|
@@ -23560,7 +23571,7 @@ var StandardFormPage = ({
|
|
|
23560
23571
|
startProcessFromExistingInstance: async (payload) => onSubmit(payload)
|
|
23561
23572
|
};
|
|
23562
23573
|
}, [formType, onSubmit]);
|
|
23563
|
-
const api = (0,
|
|
23574
|
+
const api = (0, import_react86.useMemo)(() => {
|
|
23564
23575
|
if (!externalApi && !submitApi) return void 0;
|
|
23565
23576
|
return {
|
|
23566
23577
|
...externalApi ?? {},
|
|
@@ -24623,10 +24634,10 @@ function AsyncEntityFilterSelect({
|
|
|
24623
24634
|
value,
|
|
24624
24635
|
onChange
|
|
24625
24636
|
}) {
|
|
24626
|
-
const [options, setOptions] = (0,
|
|
24627
|
-
const [fetching, setFetching] = (0,
|
|
24637
|
+
const [options, setOptions] = (0, import_react87.useState)([]);
|
|
24638
|
+
const [fetching, setFetching] = (0, import_react87.useState)(false);
|
|
24628
24639
|
const multiple = normalizeOperator(operator) === "IN";
|
|
24629
|
-
const loadOptions = (0,
|
|
24640
|
+
const loadOptions = (0, import_react87.useCallback)(
|
|
24630
24641
|
async (keyword = "") => {
|
|
24631
24642
|
setFetching(true);
|
|
24632
24643
|
try {
|
|
@@ -24668,7 +24679,7 @@ function AsyncEntityFilterSelect({
|
|
|
24668
24679
|
},
|
|
24669
24680
|
[api, entityType]
|
|
24670
24681
|
);
|
|
24671
|
-
(0,
|
|
24682
|
+
(0, import_react87.useEffect)(() => {
|
|
24672
24683
|
void loadOptions();
|
|
24673
24684
|
}, [loadOptions]);
|
|
24674
24685
|
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
@@ -24979,7 +24990,7 @@ function ResizableColumnTitle({
|
|
|
24979
24990
|
onResize,
|
|
24980
24991
|
onResizeEnd
|
|
24981
24992
|
}) {
|
|
24982
|
-
const dragRef = (0,
|
|
24993
|
+
const dragRef = (0, import_react87.useRef)({ startX: 0, startWidth: width, latestWidth: width });
|
|
24983
24994
|
const handleMouseDown = (event) => {
|
|
24984
24995
|
event.preventDefault();
|
|
24985
24996
|
event.stopPropagation();
|
|
@@ -25048,74 +25059,74 @@ var DataManagementList = ({
|
|
|
25048
25059
|
permissionMode = "auto",
|
|
25049
25060
|
actionOverrides
|
|
25050
25061
|
}) => {
|
|
25051
|
-
const rootRef = (0,
|
|
25052
|
-
const api = (0,
|
|
25062
|
+
const rootRef = (0, import_react87.useRef)(null);
|
|
25063
|
+
const api = (0, import_react87.useMemo)(() => {
|
|
25053
25064
|
if (typeof requestOverride === "function") {
|
|
25054
25065
|
return createFormRuntimeApi({ request: requestOverride });
|
|
25055
25066
|
}
|
|
25056
25067
|
return createFormRuntimeApi(requestOverride);
|
|
25057
25068
|
}, [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,
|
|
25069
|
+
const [fields, setFields] = (0, import_react87.useState)([]);
|
|
25070
|
+
const [runtimeFormSchema, setRuntimeFormSchema] = (0, import_react87.useState)(null);
|
|
25071
|
+
const [config, setConfig] = (0, import_react87.useState)({});
|
|
25072
|
+
const [formType, setFormType] = (0, import_react87.useState)("form");
|
|
25073
|
+
const [showFields, setShowFields] = (0, import_react87.useState)([]);
|
|
25074
|
+
const [lockFieldIds, setLockFieldIds] = (0, import_react87.useState)([]);
|
|
25075
|
+
const [widths, setWidths] = (0, import_react87.useState)({});
|
|
25076
|
+
const widthsRef = (0, import_react87.useRef)({});
|
|
25077
|
+
const [sort, setSort] = (0, import_react87.useState)([]);
|
|
25078
|
+
const [density, setDensity] = (0, import_react87.useState)("middle");
|
|
25079
|
+
const [detailOpenMode, setDetailOpenMode] = (0, import_react87.useState)("drawer");
|
|
25080
|
+
const [searchKeyWord, setSearchKeyWord] = (0, import_react87.useState)("");
|
|
25081
|
+
const [filterGroup, setFilterGroup] = (0, import_react87.useState)(createGroup);
|
|
25082
|
+
const [dataSource, setDataSource] = (0, import_react87.useState)([]);
|
|
25083
|
+
const [total, setTotal] = (0, import_react87.useState)(0);
|
|
25084
|
+
const [current, setCurrent] = (0, import_react87.useState)(1);
|
|
25085
|
+
const [pageSize, setPageSize] = (0, import_react87.useState)(10);
|
|
25086
|
+
const [loading, setLoading] = (0, import_react87.useState)(false);
|
|
25087
|
+
const [schemaLoading, setSchemaLoading] = (0, import_react87.useState)(true);
|
|
25088
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react87.useState)([]);
|
|
25089
|
+
const [filterOpen, setFilterOpen] = (0, import_react87.useState)(false);
|
|
25090
|
+
const [columnOpen, setColumnOpen] = (0, import_react87.useState)(false);
|
|
25091
|
+
const [exportOpen, setExportOpen] = (0, import_react87.useState)(false);
|
|
25092
|
+
const [exportScope, setExportScope] = (0, import_react87.useState)("all");
|
|
25093
|
+
const [exportFields, setExportFields] = (0, import_react87.useState)([]);
|
|
25094
|
+
const [exporting, setExporting] = (0, import_react87.useState)(false);
|
|
25095
|
+
const [importOpen, setImportOpen] = (0, import_react87.useState)(false);
|
|
25096
|
+
const [importPreview, setImportPreview] = (0, import_react87.useState)([]);
|
|
25097
|
+
const [importBase64, setImportBase64] = (0, import_react87.useState)("");
|
|
25098
|
+
const [templateDownloading, setTemplateDownloading] = (0, import_react87.useState)(false);
|
|
25099
|
+
const [recordsOpen, setRecordsOpen] = (0, import_react87.useState)(false);
|
|
25100
|
+
const [recordTab, setRecordTab] = (0, import_react87.useState)("export");
|
|
25101
|
+
const [transferRecords, setTransferRecords] = (0, import_react87.useState)([]);
|
|
25102
|
+
const [batchApprovalOpen, setBatchApprovalOpen] = (0, import_react87.useState)(false);
|
|
25103
|
+
const [batchApprovalAction, setBatchApprovalAction] = (0, import_react87.useState)(
|
|
25093
25104
|
"approved"
|
|
25094
25105
|
);
|
|
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,
|
|
25106
|
+
const [batchApprovalComments, setBatchApprovalComments] = (0, import_react87.useState)("");
|
|
25107
|
+
const [batchApproving, setBatchApproving] = (0, import_react87.useState)(false);
|
|
25108
|
+
const [activeRecord, setActiveRecord] = (0, import_react87.useState)(null);
|
|
25109
|
+
const [detailOpen, setDetailOpen] = (0, import_react87.useState)(false);
|
|
25110
|
+
const [submitOpen, setSubmitOpen] = (0, import_react87.useState)(false);
|
|
25111
|
+
const [actionSummary, setActionSummary] = (0, import_react87.useState)(null);
|
|
25112
|
+
const [permissionLoading, setPermissionLoading] = (0, import_react87.useState)(permissionMode === "auto");
|
|
25113
|
+
const [permissionError, setPermissionError] = (0, import_react87.useState)(null);
|
|
25114
|
+
const fetchStateRef = (0, import_react87.useRef)({});
|
|
25104
25115
|
const isProcessForm = isProcessFormType(formType);
|
|
25105
25116
|
const request = api.request;
|
|
25106
|
-
const getPopupContainer = (0,
|
|
25117
|
+
const getPopupContainer = (0, import_react87.useCallback)(
|
|
25107
25118
|
(triggerNode) => resolveDataManagementPopupContainer(rootRef.current, triggerNode),
|
|
25108
25119
|
[]
|
|
25109
25120
|
);
|
|
25110
|
-
const getOverlayContainer = (0,
|
|
25121
|
+
const getOverlayContainer = (0, import_react87.useCallback)(
|
|
25111
25122
|
() => resolveDataManagementPortalContainer(rootRef.current),
|
|
25112
25123
|
[]
|
|
25113
25124
|
);
|
|
25114
25125
|
const drawerWidth = "min(960px, calc(100vw - 48px))";
|
|
25115
|
-
const confirmDanger = (0,
|
|
25126
|
+
const confirmDanger = (0, import_react87.useCallback)((title2, content, onOk) => {
|
|
25116
25127
|
if (confirmAction(title2, content)) onOk();
|
|
25117
25128
|
}, []);
|
|
25118
|
-
(0,
|
|
25129
|
+
(0, import_react87.useEffect)(() => {
|
|
25119
25130
|
let mounted = true;
|
|
25120
25131
|
if (permissionMode !== "auto") {
|
|
25121
25132
|
setActionSummary(null);
|
|
@@ -25142,7 +25153,7 @@ var DataManagementList = ({
|
|
|
25142
25153
|
mounted = false;
|
|
25143
25154
|
};
|
|
25144
25155
|
}, [appType, formUuid, permissionMode, request]);
|
|
25145
|
-
const baseActionCan = (0,
|
|
25156
|
+
const baseActionCan = (0, import_react87.useMemo)(() => {
|
|
25146
25157
|
if (permissionMode === "auto") {
|
|
25147
25158
|
return FORM_ACTION_PERMISSIONS.reduce((result, action) => {
|
|
25148
25159
|
result[action] = Boolean(actionSummary?.can?.[action]);
|
|
@@ -25154,7 +25165,7 @@ var DataManagementList = ({
|
|
|
25154
25165
|
return result;
|
|
25155
25166
|
}, {});
|
|
25156
25167
|
}, [actionSummary?.can, permissionMode]);
|
|
25157
|
-
const canAction = (0,
|
|
25168
|
+
const canAction = (0, import_react87.useCallback)(
|
|
25158
25169
|
(action) => {
|
|
25159
25170
|
if (permissionLoading && permissionMode === "auto") return false;
|
|
25160
25171
|
if (permissionError && permissionMode === "auto") return action === "view";
|
|
@@ -25176,22 +25187,22 @@ var DataManagementList = ({
|
|
|
25176
25187
|
const canExport = canAction("export");
|
|
25177
25188
|
const canImport = canAction("import");
|
|
25178
25189
|
const canWorkflow = canAction("workflow");
|
|
25179
|
-
const visibleFields = (0,
|
|
25190
|
+
const visibleFields = (0, import_react87.useMemo)(
|
|
25180
25191
|
() => showFields.map((fieldId) => fields.find((field) => field.fieldId === fieldId)).filter(Boolean),
|
|
25181
25192
|
[fields, showFields]
|
|
25182
25193
|
);
|
|
25183
|
-
const forcedShowFieldIds = (0,
|
|
25194
|
+
const forcedShowFieldIds = (0, import_react87.useMemo)(
|
|
25184
25195
|
() => new Set(forcedConfig?.showFields || []),
|
|
25185
25196
|
[forcedConfig?.showFields]
|
|
25186
25197
|
);
|
|
25187
|
-
const forcedLockFieldIds = (0,
|
|
25198
|
+
const forcedLockFieldIds = (0, import_react87.useMemo)(
|
|
25188
25199
|
() => new Set(forcedConfig?.lockFieldIds || []),
|
|
25189
25200
|
[forcedConfig?.lockFieldIds]
|
|
25190
25201
|
);
|
|
25191
|
-
(0,
|
|
25202
|
+
(0, import_react87.useEffect)(() => {
|
|
25192
25203
|
widthsRef.current = widths;
|
|
25193
25204
|
}, [widths]);
|
|
25194
|
-
(0,
|
|
25205
|
+
(0, import_react87.useEffect)(() => {
|
|
25195
25206
|
fetchStateRef.current = {
|
|
25196
25207
|
current,
|
|
25197
25208
|
pageSize,
|
|
@@ -25200,7 +25211,7 @@ var DataManagementList = ({
|
|
|
25200
25211
|
sort
|
|
25201
25212
|
};
|
|
25202
25213
|
}, [current, filterGroup, pageSize, searchKeyWord, sort]);
|
|
25203
|
-
const loadData = (0,
|
|
25214
|
+
const loadData = (0, import_react87.useCallback)(
|
|
25204
25215
|
async (overrides = {}) => {
|
|
25205
25216
|
if (!appType || !formUuid) return;
|
|
25206
25217
|
const fetchState = { ...fetchStateRef.current, ...overrides };
|
|
@@ -25244,7 +25255,7 @@ var DataManagementList = ({
|
|
|
25244
25255
|
},
|
|
25245
25256
|
[appType, forcedConfig, formUuid, request]
|
|
25246
25257
|
);
|
|
25247
|
-
(0,
|
|
25258
|
+
(0, import_react87.useEffect)(() => {
|
|
25248
25259
|
let mounted = true;
|
|
25249
25260
|
const loadSchemaAndConfig = async () => {
|
|
25250
25261
|
if (!appType || !formUuid) return;
|
|
@@ -25336,7 +25347,7 @@ var DataManagementList = ({
|
|
|
25336
25347
|
request,
|
|
25337
25348
|
title
|
|
25338
25349
|
]);
|
|
25339
|
-
const persistConfig = (0,
|
|
25350
|
+
const persistConfig = (0, import_react87.useCallback)(
|
|
25340
25351
|
async (patch) => {
|
|
25341
25352
|
const personalPatch = stripForcedConfigPatch(patch, forcedConfig);
|
|
25342
25353
|
const nextConfig = { ...config, ...personalPatch };
|
|
@@ -25380,12 +25391,12 @@ var DataManagementList = ({
|
|
|
25380
25391
|
const handleRemoveSort = (index) => {
|
|
25381
25392
|
setSort((prev) => prev.filter((_, itemIndex) => itemIndex !== index));
|
|
25382
25393
|
};
|
|
25383
|
-
const updateColumnWidth = (0,
|
|
25394
|
+
const updateColumnWidth = (0, import_react87.useCallback)((fieldId, width) => {
|
|
25384
25395
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
25385
25396
|
widthsRef.current = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
25386
25397
|
setWidths(widthsRef.current);
|
|
25387
25398
|
}, []);
|
|
25388
|
-
const commitColumnWidth = (0,
|
|
25399
|
+
const commitColumnWidth = (0, import_react87.useCallback)(
|
|
25389
25400
|
(fieldId, width) => {
|
|
25390
25401
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
25391
25402
|
const nextWidths = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
@@ -25395,7 +25406,7 @@ var DataManagementList = ({
|
|
|
25395
25406
|
},
|
|
25396
25407
|
[persistConfig]
|
|
25397
25408
|
);
|
|
25398
|
-
const handleDetail = (0,
|
|
25409
|
+
const handleDetail = (0, import_react87.useCallback)(
|
|
25399
25410
|
(record) => {
|
|
25400
25411
|
const formInstanceId = getRecordId(record);
|
|
25401
25412
|
if (!formInstanceId) {
|
|
@@ -25420,7 +25431,7 @@ var DataManagementList = ({
|
|
|
25420
25431
|
},
|
|
25421
25432
|
[appType, detailBasePath, detailOpenMode, detailPageUrlBuilder, formType, formUuid]
|
|
25422
25433
|
);
|
|
25423
|
-
const handleDelete = (0,
|
|
25434
|
+
const handleDelete = (0, import_react87.useCallback)(
|
|
25424
25435
|
async (ids) => {
|
|
25425
25436
|
if (ids.length === 0) return;
|
|
25426
25437
|
if (!canDelete) {
|
|
@@ -25433,7 +25444,7 @@ var DataManagementList = ({
|
|
|
25433
25444
|
},
|
|
25434
25445
|
[appType, canDelete, current, formUuid, loadData, pageSize, request]
|
|
25435
25446
|
);
|
|
25436
|
-
const getSelectedRecordIds = (0,
|
|
25447
|
+
const getSelectedRecordIds = (0, import_react87.useCallback)(
|
|
25437
25448
|
() => selectedRowKeys.map((key) => {
|
|
25438
25449
|
const record = dataSource.find((item) => String(getRecordId(item)) === String(key));
|
|
25439
25450
|
return String(getSelectedRecordId(record, key));
|
|
@@ -25578,7 +25589,7 @@ var DataManagementList = ({
|
|
|
25578
25589
|
ACTION_COLUMN_MIN_WIDTH,
|
|
25579
25590
|
Math.min(rowActionCount, visibleRowActionLimit) * ACTION_BUTTON_ESTIMATED_WIDTH + (rowActionCount > visibleRowActionLimit ? ACTION_MORE_BUTTON_WIDTH : 0) + ACTION_COLUMN_HORIZONTAL_PADDING
|
|
25580
25591
|
);
|
|
25581
|
-
const columns = (0,
|
|
25592
|
+
const columns = (0, import_react87.useMemo)(() => {
|
|
25582
25593
|
const baseColumns = visibleFields.map((field) => {
|
|
25583
25594
|
const columnWidth = widths[field.fieldId] || field.width || 160;
|
|
25584
25595
|
return {
|
|
@@ -25710,7 +25721,7 @@ var DataManagementList = ({
|
|
|
25710
25721
|
actionColumnWidth
|
|
25711
25722
|
)
|
|
25712
25723
|
);
|
|
25713
|
-
const importPreviewColumns = (0,
|
|
25724
|
+
const importPreviewColumns = (0, import_react87.useMemo)(() => {
|
|
25714
25725
|
const keys = Array.from(
|
|
25715
25726
|
new Set(importPreview.flatMap((record) => Object.keys(record || {})))
|
|
25716
25727
|
).slice(0, 16);
|
|
@@ -26468,17 +26479,17 @@ function BuiltinRouteRenderer({
|
|
|
26468
26479
|
style
|
|
26469
26480
|
}) {
|
|
26470
26481
|
const normalizedServicePrefix = trimTrailingSlash3(servicePrefix);
|
|
26471
|
-
const [schema, setSchema] = (0,
|
|
26472
|
-
const [loading, setLoading] = (0,
|
|
26473
|
-
const [error, setError] = (0,
|
|
26474
|
-
const [reloadKey, setReloadKey] = (0,
|
|
26482
|
+
const [schema, setSchema] = (0, import_react88.useState)();
|
|
26483
|
+
const [loading, setLoading] = (0, import_react88.useState)(false);
|
|
26484
|
+
const [error, setError] = (0, import_react88.useState)("");
|
|
26485
|
+
const [reloadKey, setReloadKey] = (0, import_react88.useState)(0);
|
|
26475
26486
|
const requestConfig = requestOverride && typeof requestOverride === "object" ? requestOverride : void 0;
|
|
26476
|
-
const request = (0,
|
|
26487
|
+
const request = (0, import_react88.useMemo)(() => {
|
|
26477
26488
|
if (typeof requestOverride === "function") return requestOverride;
|
|
26478
26489
|
if (requestConfig?.request) return requestConfig.request;
|
|
26479
26490
|
return createBuiltinRouteRequest(requestConfig?.baseUrl || normalizedServicePrefix, fetchImpl);
|
|
26480
26491
|
}, [fetchImpl, normalizedServicePrefix, requestConfig, requestOverride]);
|
|
26481
|
-
const api = (0,
|
|
26492
|
+
const api = (0, import_react88.useMemo)(
|
|
26482
26493
|
() => createFormRuntimeApi({
|
|
26483
26494
|
baseUrl: normalizedServicePrefix,
|
|
26484
26495
|
...requestConfig || {},
|
|
@@ -26489,14 +26500,14 @@ function BuiltinRouteRenderer({
|
|
|
26489
26500
|
const appType = appTypeProp || route?.appType || "";
|
|
26490
26501
|
const formUuid = route ? pickRouteValue(route, "formUuid", "menuFormUuid") : "";
|
|
26491
26502
|
const formInstId = route ? pickRouteValue(route, "formInstId", "formInstanceId") : "";
|
|
26492
|
-
const routeConfig = (0,
|
|
26503
|
+
const routeConfig = (0, import_react88.useMemo)(
|
|
26493
26504
|
() => route ? resolveRouteConfig(route, config) : {},
|
|
26494
26505
|
[config, route]
|
|
26495
26506
|
);
|
|
26496
26507
|
const runtimeStorage = route?.runtime?.storage;
|
|
26497
26508
|
const permissionDenied = isRuntimePermissionDenied(route);
|
|
26498
|
-
const reload = (0,
|
|
26499
|
-
(0,
|
|
26509
|
+
const reload = (0, import_react88.useCallback)(() => setReloadKey((value) => value + 1), []);
|
|
26510
|
+
(0, import_react88.useEffect)(() => {
|
|
26500
26511
|
let cancelled = false;
|
|
26501
26512
|
setSchema(void 0);
|
|
26502
26513
|
setError("");
|