sales-frontend-bridge 0.0.30 → 0.0.32
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/dist/index.cjs +179 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +132 -68
- package/dist/index.d.ts +132 -68
- package/dist/index.js +171 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2063,18 +2063,36 @@ var NativeBridgeOz = class extends CommonBridge {
|
|
|
2063
2063
|
async hideOzPdfViewer() {
|
|
2064
2064
|
return this.core.callToTarget("hideOzPdfViewer");
|
|
2065
2065
|
}
|
|
2066
|
+
/**
|
|
2067
|
+
* 서식 바로가기 버튼 화면에 표시하기
|
|
2068
|
+
*/
|
|
2066
2069
|
async showSignatureShortcut() {
|
|
2067
2070
|
return this.core.callToTarget("showSignatureShortcut");
|
|
2068
2071
|
}
|
|
2072
|
+
/**
|
|
2073
|
+
* 서식 바로가기 버튼 숨기기
|
|
2074
|
+
*/
|
|
2069
2075
|
async hideSignatureShortcut() {
|
|
2070
2076
|
return this.core.callToTarget("hideSignatureShortcut");
|
|
2071
2077
|
}
|
|
2078
|
+
/**
|
|
2079
|
+
* 느낌표 버튼(미입력 서식 발생 알림 버튼) 화면에 표시하기
|
|
2080
|
+
*/
|
|
2072
2081
|
async showMissingFieldWarning() {
|
|
2073
2082
|
return this.core.callToTarget("showMissingFieldWarning");
|
|
2074
2083
|
}
|
|
2084
|
+
/**
|
|
2085
|
+
* 느낌표 버튼(미입력 서식 발생 알림 버튼) 숨기기
|
|
2086
|
+
*/
|
|
2075
2087
|
async hideMissingFieldWarning() {
|
|
2076
2088
|
return this.core.callToTarget("hideMissingFieldWarning");
|
|
2077
2089
|
}
|
|
2090
|
+
/**
|
|
2091
|
+
* 미입력 서식 Alert 표시하기
|
|
2092
|
+
*/
|
|
2093
|
+
async showMissingAlert() {
|
|
2094
|
+
return this.core.callToTarget("showMissingAlert");
|
|
2095
|
+
}
|
|
2078
2096
|
// TODO: 필요 플러그인들 추가
|
|
2079
2097
|
};
|
|
2080
2098
|
|
|
@@ -2087,21 +2105,7 @@ var Bridge = {
|
|
|
2087
2105
|
iframeCore: new IframeBridgeCore()
|
|
2088
2106
|
};
|
|
2089
2107
|
|
|
2090
|
-
// src/oz/
|
|
2091
|
-
var OZViewerEvent = /* @__PURE__ */ ((OZViewerEvent2) => {
|
|
2092
|
-
OZViewerEvent2["OZProgressCommand"] = "OZProgressCommand";
|
|
2093
|
-
OZViewerEvent2["OZErrorCommand"] = "OZErrorCommand";
|
|
2094
|
-
OZViewerEvent2["OZPageChangeCommand"] = "OZPageChangeCommand";
|
|
2095
|
-
OZViewerEvent2["OZReportChangeCommand"] = "OZReportChangeCommand";
|
|
2096
|
-
OZViewerEvent2["OZUserEvent"] = "OZUserEvent";
|
|
2097
|
-
OZViewerEvent2["OZPageBindCommand"] = "OZPageBindCommand";
|
|
2098
|
-
OZViewerEvent2["OZEFormInputEventCommand"] = "OZEFormInputEventCommand";
|
|
2099
|
-
OZViewerEvent2["OZExportCommand"] = "OZExportCommand";
|
|
2100
|
-
OZViewerEvent2["OZBtnTouchEvent"] = "btnTouchEvent";
|
|
2101
|
-
return OZViewerEvent2;
|
|
2102
|
-
})(OZViewerEvent || {});
|
|
2103
|
-
|
|
2104
|
-
// src/oz/constant.ts
|
|
2108
|
+
// src/oz/constant/index.ts
|
|
2105
2109
|
var commonOzParam = [
|
|
2106
2110
|
`information.debug = true`,
|
|
2107
2111
|
`global.inheritparameter=true`,
|
|
@@ -2128,6 +2132,7 @@ var commonOzParam = [
|
|
|
2128
2132
|
`eform.prev_next_required_rule=required_only`,
|
|
2129
2133
|
`eform.prev_next_navigation_rule=required_only`,
|
|
2130
2134
|
`eform.prev_next_constraint_rule=empty_only`,
|
|
2135
|
+
// `eform.onvaluechanged_callrule_json=${JSON.stringify({ signpad: 'changed' })}`,
|
|
2131
2136
|
`viewer.pagenavigate_by_prev_next=true`,
|
|
2132
2137
|
`eform.imagepicker_id_info=${JSON.stringify({
|
|
2133
2138
|
ids: [
|
|
@@ -2217,26 +2222,32 @@ var commentPenDefaultParam = [
|
|
|
2217
2222
|
`comment.selectedpen=highlightpen`,
|
|
2218
2223
|
`comment.highlightpen_thick=15`
|
|
2219
2224
|
];
|
|
2220
|
-
var commentPenYellow = [...commentPenDefaultParam, `comment.highlightpen_color=
|
|
2221
|
-
var commentPenPink = [...commentPenDefaultParam, `comment.highlightpen_color=
|
|
2222
|
-
var commentPenGreen = [...commentPenDefaultParam, `comment.highlightpen_color=
|
|
2225
|
+
var commentPenYellow = [...commentPenDefaultParam, `comment.highlightpen_color=ffd900`];
|
|
2226
|
+
var commentPenPink = [...commentPenDefaultParam, `comment.highlightpen_color=f48fb1`];
|
|
2227
|
+
var commentPenGreen = [...commentPenDefaultParam, `comment.highlightpen_color=81c784`];
|
|
2223
2228
|
var commentPenEraser = [`comment.selectedpen=eraser`];
|
|
2224
2229
|
var wrapperStyle = { display: "flex", flexFlow: "column", gap: "10px" };
|
|
2225
2230
|
var btnStyle = { border: "1px solid red", minHeight: "40px" };
|
|
2226
2231
|
|
|
2227
|
-
// src/oz/use-create-report.ts
|
|
2232
|
+
// src/oz/hooks/use-create-report.ts
|
|
2228
2233
|
var import_react = __toESM(require_react());
|
|
2229
2234
|
|
|
2230
|
-
// src/oz/
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2235
|
+
// src/oz/types/oz-event.types.ts
|
|
2236
|
+
var OZViewerEvent = /* @__PURE__ */ ((OZViewerEvent2) => {
|
|
2237
|
+
OZViewerEvent2["OZProgressCommand"] = "OZProgressCommand";
|
|
2238
|
+
OZViewerEvent2["OZErrorCommand"] = "OZErrorCommand";
|
|
2239
|
+
OZViewerEvent2["OZPageChangeCommand"] = "OZPageChangeCommand";
|
|
2240
|
+
OZViewerEvent2["OZReportChangeCommand"] = "OZReportChangeCommand";
|
|
2241
|
+
OZViewerEvent2["OZUserEvent"] = "OZUserEvent";
|
|
2242
|
+
OZViewerEvent2["OZPageBindCommand"] = "OZPageBindCommand";
|
|
2243
|
+
OZViewerEvent2["OZEFormInputEventCommand"] = "OZEFormInputEventCommand";
|
|
2244
|
+
OZViewerEvent2["OZExportCommand"] = "OZExportCommand";
|
|
2245
|
+
OZViewerEvent2["OZBtnTouchEvent"] = "btnTouchEvent";
|
|
2246
|
+
OZViewerEvent2["OZReportCreated"] = "OZReportCreated";
|
|
2247
|
+
return OZViewerEvent2;
|
|
2248
|
+
})(OZViewerEvent || {});
|
|
2249
|
+
|
|
2250
|
+
// src/oz/utils/common-util.ts
|
|
2240
2251
|
function categorizeByPageRange(data, pageCounts) {
|
|
2241
2252
|
let pageStart = 1;
|
|
2242
2253
|
const result = [];
|
|
@@ -2280,10 +2291,36 @@ function getFileListByGlobalIndex(index, data) {
|
|
|
2280
2291
|
}
|
|
2281
2292
|
return null;
|
|
2282
2293
|
}
|
|
2294
|
+
async function sleep(ms = 10) {
|
|
2295
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2296
|
+
}
|
|
2297
|
+
function PromiseWithResolvers() {
|
|
2298
|
+
let resolve;
|
|
2299
|
+
let reject;
|
|
2300
|
+
const promise = new Promise((res, rej) => {
|
|
2301
|
+
resolve = res;
|
|
2302
|
+
reject = rej;
|
|
2303
|
+
});
|
|
2304
|
+
return { promise, resolve, reject };
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
// src/oz/utils/bridge-util.ts
|
|
2308
|
+
async function fetchDocument(options) {
|
|
2309
|
+
const { data } = await Bridge.native.downloadDocument({ data: options });
|
|
2310
|
+
return data.map((i) => ({ ...i, startPage: 0, endPage: 0 }));
|
|
2311
|
+
}
|
|
2312
|
+
async function fetchFont() {
|
|
2313
|
+
const { data: fontMap } = await Bridge.native.getOzFontParam();
|
|
2314
|
+
const fontParms = Object.keys(fontMap).map((i) => `font.${i}=${fontMap[i]}`);
|
|
2315
|
+
return fontParms;
|
|
2316
|
+
}
|
|
2283
2317
|
async function getReportCount() {
|
|
2284
2318
|
const { data } = await Bridge.nativeOz.getInformation({ command: "REPORT_COUNT" });
|
|
2285
2319
|
return Number(data);
|
|
2286
2320
|
}
|
|
2321
|
+
async function MovePage(page) {
|
|
2322
|
+
return await Bridge.nativeOz.script({ command: `movepage=${page}` });
|
|
2323
|
+
}
|
|
2287
2324
|
async function enableFocusOnValidation(reportCount) {
|
|
2288
2325
|
const count = reportCount ?? await getReportCount();
|
|
2289
2326
|
for (let i = 0; i < count; i++) {
|
|
@@ -2300,9 +2337,6 @@ async function disableFocusOnValidation(reportCount) {
|
|
|
2300
2337
|
}
|
|
2301
2338
|
return;
|
|
2302
2339
|
}
|
|
2303
|
-
async function sleep(ms = 10) {
|
|
2304
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2305
|
-
}
|
|
2306
2340
|
async function triggerClickOnAllDocuments(reportCount) {
|
|
2307
2341
|
const count = reportCount ?? await getReportCount();
|
|
2308
2342
|
for (let i = 0; i < count; i++) {
|
|
@@ -2341,24 +2375,12 @@ async function checkDocumentsValidityByIndex(indexList) {
|
|
|
2341
2375
|
}
|
|
2342
2376
|
return true;
|
|
2343
2377
|
}
|
|
2344
|
-
async function
|
|
2378
|
+
async function validateAllPages(pageCount) {
|
|
2345
2379
|
const VALID = "valid";
|
|
2346
|
-
|
|
2380
|
+
const count = pageCount ?? await getTotalPage();
|
|
2381
|
+
for (let i = 1; i <= count; i++) {
|
|
2347
2382
|
await sleep();
|
|
2348
|
-
const command = `INPUT_CHECK_VALIDITY_PAGE_AT=${
|
|
2349
|
-
const { data } = await Bridge.nativeOz.getInformation({ command });
|
|
2350
|
-
if (data !== VALID) {
|
|
2351
|
-
return false;
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
return true;
|
|
2355
|
-
}
|
|
2356
|
-
async function validateAllDocuments(reportCount) {
|
|
2357
|
-
const VALID = "valid";
|
|
2358
|
-
const count = reportCount ?? await getReportCount();
|
|
2359
|
-
for (let i = 0; i < count; i++) {
|
|
2360
|
-
await sleep();
|
|
2361
|
-
const command = `INPUT_CHECK_VALIDITY_AT=${i}`;
|
|
2383
|
+
const command = `INPUT_CHECK_VALIDITY_PAGE_AT=${i}`;
|
|
2362
2384
|
const { data } = await Bridge.nativeOz.getInformation({ command });
|
|
2363
2385
|
if (data !== VALID) {
|
|
2364
2386
|
return false;
|
|
@@ -2407,11 +2429,106 @@ async function setDisableCommentMode() {
|
|
|
2407
2429
|
const command = `mode_input_all`;
|
|
2408
2430
|
return await Bridge.nativeOz.script({ command });
|
|
2409
2431
|
}
|
|
2410
|
-
function
|
|
2411
|
-
|
|
2432
|
+
async function CommentHandler({ type, btnID }) {
|
|
2433
|
+
if (type !== "comment") {
|
|
2434
|
+
throw `Unexpected Type ${type}`;
|
|
2435
|
+
}
|
|
2436
|
+
if (btnID === "yellow") {
|
|
2437
|
+
await setEnableCommentMode("yellow");
|
|
2438
|
+
} else if (btnID === "pink") {
|
|
2439
|
+
await setEnableCommentMode("pink");
|
|
2440
|
+
} else if (btnID === "green") {
|
|
2441
|
+
await setEnableCommentMode("green");
|
|
2442
|
+
} else if (btnID === "eraser") {
|
|
2443
|
+
await setEnableCommentMode("eraser");
|
|
2444
|
+
} else {
|
|
2445
|
+
await setDisableCommentMode();
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
async function CategoryHandler(documentInfo, { type, btnID }) {
|
|
2449
|
+
if (type !== "category") {
|
|
2450
|
+
throw `Unexpected Type ${type}`;
|
|
2451
|
+
}
|
|
2452
|
+
const target = documentInfo.find((i) => i.name === btnID);
|
|
2453
|
+
if (!target) {
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
await MovePage(target.startPage);
|
|
2457
|
+
}
|
|
2458
|
+
async function SignatureHandler({ type, btnID }) {
|
|
2459
|
+
if (type !== "signature") {
|
|
2460
|
+
throw `Unexpected Type ${type}`;
|
|
2461
|
+
}
|
|
2462
|
+
const reportCount = await getReportCount();
|
|
2463
|
+
const pageCount = await getTotalPage();
|
|
2464
|
+
if (btnID === "signatureInProgress") {
|
|
2465
|
+
await enableFocusOnValidation(reportCount);
|
|
2466
|
+
await validateAllPages(pageCount);
|
|
2467
|
+
} else {
|
|
2468
|
+
try {
|
|
2469
|
+
await Bridge.native.showLoader();
|
|
2470
|
+
await disableFocusOnValidation(reportCount);
|
|
2471
|
+
const isAllValid = await validateAllPages(pageCount);
|
|
2472
|
+
if (!isAllValid) {
|
|
2473
|
+
throw "MissingAlert";
|
|
2474
|
+
}
|
|
2475
|
+
const filePath = await SaveTotalPdf();
|
|
2476
|
+
await Bridge.nativeOz.createOzPdfViewer({ filePath });
|
|
2477
|
+
} catch (e) {
|
|
2478
|
+
if (e === "MissingAlert") {
|
|
2479
|
+
await Bridge.nativeOz.showMissingAlert();
|
|
2480
|
+
} else {
|
|
2481
|
+
alert("PDF export \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD558\uC600\uC2B5\uB2C8\uB2E4");
|
|
2482
|
+
}
|
|
2483
|
+
} finally {
|
|
2484
|
+
await Bridge.native.hideLoader();
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
async function TopHandler({ type, btnID }) {
|
|
2489
|
+
if (type !== "top") {
|
|
2490
|
+
throw `Unexpected Type ${type}`;
|
|
2491
|
+
}
|
|
2492
|
+
if (btnID === "btnExit") {
|
|
2493
|
+
await Bridge.native.hideOZViewer();
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
async function PdfHandler({ type, btnID }) {
|
|
2497
|
+
if (type !== "pdf") {
|
|
2498
|
+
throw `Unexpected Type ${type}`;
|
|
2499
|
+
}
|
|
2500
|
+
if (btnID === "modify") {
|
|
2501
|
+
await Bridge.nativeOz.hideOzPdfViewer();
|
|
2502
|
+
} else {
|
|
2503
|
+
await Bridge.nativeOz.hideOzPdfViewer();
|
|
2504
|
+
await Bridge.native.hideOZViewer();
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
async function SaveTotalPdf() {
|
|
2508
|
+
const { promise, resolve } = PromiseWithResolvers();
|
|
2509
|
+
window.addEventListener(
|
|
2510
|
+
"OZExportCommand" /* OZExportCommand */,
|
|
2511
|
+
// 이벤트를 CustomEvent로 타입 캐스팅하고, detail에서 파일 경로 추출
|
|
2512
|
+
(e) => resolve(e.detail.filepaths),
|
|
2513
|
+
// 이벤트 리스너는 한 번만 실행되도록 설정
|
|
2514
|
+
{ once: true }
|
|
2515
|
+
);
|
|
2516
|
+
const totalPage = await getTotalPage();
|
|
2517
|
+
await Bridge.nativeOz.savePdf({
|
|
2518
|
+
param: [
|
|
2519
|
+
// 저장할 파일명 설정
|
|
2520
|
+
`pdf.filename=${"total.pdf"}`,
|
|
2521
|
+
// 1페이지부터 마지막 페이지까지 저장
|
|
2522
|
+
`export.pages=${1}-${totalPage}`,
|
|
2523
|
+
// 공통 PDF 내보내기 파라미터 추가
|
|
2524
|
+
...commonPdfExportParam
|
|
2525
|
+
].join("\n")
|
|
2526
|
+
});
|
|
2527
|
+
const filepath = await promise;
|
|
2528
|
+
return filepath;
|
|
2412
2529
|
}
|
|
2413
2530
|
|
|
2414
|
-
// src/oz/use-create-report.ts
|
|
2531
|
+
// src/oz/hooks/use-create-report.ts
|
|
2415
2532
|
function useCreateReport({ documentList, extraData = {} }) {
|
|
2416
2533
|
const CreateReport = (0, import_react.useCallback)(async () => {
|
|
2417
2534
|
if (documentList.length === 0) {
|
|
@@ -2447,7 +2564,7 @@ function useCreateReport({ documentList, extraData = {} }) {
|
|
|
2447
2564
|
return { CreateReport };
|
|
2448
2565
|
}
|
|
2449
2566
|
|
|
2450
|
-
// src/oz/use-document-info.tsx
|
|
2567
|
+
// src/oz/hooks/use-document-info.tsx
|
|
2451
2568
|
var import_react2 = __toESM(require_react());
|
|
2452
2569
|
function useDocumentInfo(initialValue) {
|
|
2453
2570
|
const [documentInfo, setDocumentInfo] = (0, import_react2.useState)([...initialValue]);
|
|
@@ -2478,10 +2595,6 @@ function useDocumentInfo(initialValue) {
|
|
|
2478
2595
|
});
|
|
2479
2596
|
return acc;
|
|
2480
2597
|
}, []), [documentIndexMap, documentInfo]);
|
|
2481
|
-
const globalIndexPerTemplate = (0, import_react2.useMemo)(() => documentList.reduce((acc, cur, idx) => {
|
|
2482
|
-
acc[idx] = documentTemplateMap[cur];
|
|
2483
|
-
return acc;
|
|
2484
|
-
}, {}), [documentList, documentTemplateMap]);
|
|
2485
2598
|
const isAllComplete = (0, import_react2.useMemo)(() => documentInfo.every((i) => i.complete), [documentInfo]);
|
|
2486
2599
|
return {
|
|
2487
2600
|
setDocumentInfo,
|
|
@@ -2491,12 +2604,11 @@ function useDocumentInfo(initialValue) {
|
|
|
2491
2604
|
documentIndexMap,
|
|
2492
2605
|
nameTemplateMap,
|
|
2493
2606
|
groupIndexes,
|
|
2494
|
-
globalIndexPerTemplate,
|
|
2495
2607
|
isAllComplete
|
|
2496
2608
|
};
|
|
2497
2609
|
}
|
|
2498
2610
|
|
|
2499
|
-
// src/oz/use-oz-event-listener.tsx
|
|
2611
|
+
// src/oz/hooks/use-oz-event-listener.tsx
|
|
2500
2612
|
var import_react3 = __toESM(require_react());
|
|
2501
2613
|
function useOzEventListener({ event, handler }) {
|
|
2502
2614
|
const handleEvent = (0, import_react3.useCallback)(
|
|
@@ -2539,7 +2651,15 @@ react/cjs/react.development.js:
|
|
|
2539
2651
|
*/
|
|
2540
2652
|
|
|
2541
2653
|
exports.Bridge = Bridge;
|
|
2654
|
+
exports.CategoryHandler = CategoryHandler;
|
|
2655
|
+
exports.CommentHandler = CommentHandler;
|
|
2656
|
+
exports.MovePage = MovePage;
|
|
2542
2657
|
exports.OZViewerEvent = OZViewerEvent;
|
|
2658
|
+
exports.PdfHandler = PdfHandler;
|
|
2659
|
+
exports.PromiseWithResolvers = PromiseWithResolvers;
|
|
2660
|
+
exports.SaveTotalPdf = SaveTotalPdf;
|
|
2661
|
+
exports.SignatureHandler = SignatureHandler;
|
|
2662
|
+
exports.TopHandler = TopHandler;
|
|
2543
2663
|
exports.btnStyle = btnStyle;
|
|
2544
2664
|
exports.categorizeByPageRange = categorizeByPageRange;
|
|
2545
2665
|
exports.checkDocumentsValidityByIndex = checkDocumentsValidityByIndex;
|
|
@@ -2560,7 +2680,6 @@ exports.getReportCount = getReportCount;
|
|
|
2560
2680
|
exports.getTotalPage = getTotalPage;
|
|
2561
2681
|
exports.getTotalPageOnAllDocuments = getTotalPageOnAllDocuments;
|
|
2562
2682
|
exports.isCommentMode = isCommentMode;
|
|
2563
|
-
exports.rangeArray = rangeArray;
|
|
2564
2683
|
exports.setDisableCommentMode = setDisableCommentMode;
|
|
2565
2684
|
exports.setEnableCommentMode = setEnableCommentMode;
|
|
2566
2685
|
exports.sleep = sleep;
|
|
@@ -2569,8 +2688,7 @@ exports.triggerCropImageOnAllDocuments = triggerCropImageOnAllDocuments;
|
|
|
2569
2688
|
exports.useCreateReport = useCreateReport;
|
|
2570
2689
|
exports.useDocumentInfo = useDocumentInfo;
|
|
2571
2690
|
exports.useOzEventListener = useOzEventListener;
|
|
2572
|
-
exports.
|
|
2573
|
-
exports.validatePages = validatePages;
|
|
2691
|
+
exports.validateAllPages = validateAllPages;
|
|
2574
2692
|
exports.wrapperStyle = wrapperStyle;
|
|
2575
2693
|
//# sourceMappingURL=index.cjs.map
|
|
2576
2694
|
//# sourceMappingURL=index.cjs.map
|