sales-frontend-bridge 0.0.29 → 0.0.31

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 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
 
@@ -2098,6 +2116,7 @@ var OZViewerEvent = /* @__PURE__ */ ((OZViewerEvent2) => {
2098
2116
  OZViewerEvent2["OZEFormInputEventCommand"] = "OZEFormInputEventCommand";
2099
2117
  OZViewerEvent2["OZExportCommand"] = "OZExportCommand";
2100
2118
  OZViewerEvent2["OZBtnTouchEvent"] = "btnTouchEvent";
2119
+ OZViewerEvent2["OZReportCreated"] = "OZReportCreated";
2101
2120
  return OZViewerEvent2;
2102
2121
  })(OZViewerEvent || {});
2103
2122
 
@@ -2128,6 +2147,7 @@ var commonOzParam = [
2128
2147
  `eform.prev_next_required_rule=required_only`,
2129
2148
  `eform.prev_next_navigation_rule=required_only`,
2130
2149
  `eform.prev_next_constraint_rule=empty_only`,
2150
+ // `eform.onvaluechanged_callrule_json=${JSON.stringify({ signpad: 'changed' })}`,
2131
2151
  `viewer.pagenavigate_by_prev_next=true`,
2132
2152
  `eform.imagepicker_id_info=${JSON.stringify({
2133
2153
  ids: [
@@ -2217,9 +2237,9 @@ var commentPenDefaultParam = [
2217
2237
  `comment.selectedpen=highlightpen`,
2218
2238
  `comment.highlightpen_thick=15`
2219
2239
  ];
2220
- var commentPenYellow = [...commentPenDefaultParam, `comment.highlightpen_color=ffcc00`];
2221
- var commentPenPink = [...commentPenDefaultParam, `comment.highlightpen_color=ff29a2`];
2222
- var commentPenGreen = [...commentPenDefaultParam, `comment.highlightpen_color=00e536`];
2240
+ var commentPenYellow = [...commentPenDefaultParam, `comment.highlightpen_color=ffd900`];
2241
+ var commentPenPink = [...commentPenDefaultParam, `comment.highlightpen_color=f48fb1`];
2242
+ var commentPenGreen = [...commentPenDefaultParam, `comment.highlightpen_color=81c784`];
2223
2243
  var commentPenEraser = [`comment.selectedpen=eraser`];
2224
2244
  var wrapperStyle = { display: "flex", flexFlow: "column", gap: "10px" };
2225
2245
  var btnStyle = { border: "1px solid red", minHeight: "40px" };
@@ -2284,6 +2304,9 @@ async function getReportCount() {
2284
2304
  const { data } = await Bridge.nativeOz.getInformation({ command: "REPORT_COUNT" });
2285
2305
  return Number(data);
2286
2306
  }
2307
+ async function MovePage(page) {
2308
+ return await Bridge.nativeOz.script({ command: `movepage=${page}` });
2309
+ }
2287
2310
  async function enableFocusOnValidation(reportCount) {
2288
2311
  const count = reportCount ?? await getReportCount();
2289
2312
  for (let i = 0; i < count; i++) {
@@ -2341,24 +2364,12 @@ async function checkDocumentsValidityByIndex(indexList) {
2341
2364
  }
2342
2365
  return true;
2343
2366
  }
2344
- async function validatePages(pageList) {
2367
+ async function validateAllPages(pageCount) {
2345
2368
  const VALID = "valid";
2346
- for (let i = 0; i < pageList.length; i++) {
2369
+ const count = pageCount ?? await getTotalPage();
2370
+ for (let i = 1; i <= count; i++) {
2347
2371
  await sleep();
2348
- const command = `INPUT_CHECK_VALIDITY_PAGE_AT=${pageList[i]}`;
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}`;
2372
+ const command = `INPUT_CHECK_VALIDITY_PAGE_AT=${i}`;
2362
2373
  const { data } = await Bridge.nativeOz.getInformation({ command });
2363
2374
  if (data !== VALID) {
2364
2375
  return false;
@@ -2407,6 +2418,113 @@ async function setDisableCommentMode() {
2407
2418
  const command = `mode_input_all`;
2408
2419
  return await Bridge.nativeOz.script({ command });
2409
2420
  }
2421
+ async function CommentHandler({ type, btnID }) {
2422
+ if (type !== "comment") {
2423
+ throw `Unexpected Type ${type}`;
2424
+ }
2425
+ if (btnID === "yellow") {
2426
+ await setEnableCommentMode("yellow");
2427
+ } else if (btnID === "pink") {
2428
+ await setEnableCommentMode("pink");
2429
+ } else if (btnID === "green") {
2430
+ await setEnableCommentMode("green");
2431
+ } else if (btnID === "eraser") {
2432
+ await setEnableCommentMode("eraser");
2433
+ } else {
2434
+ await setDisableCommentMode();
2435
+ }
2436
+ }
2437
+ async function CategoryHandler(documentInfo, { type, btnID }) {
2438
+ if (type !== "category") {
2439
+ throw `Unexpected Type ${type}`;
2440
+ }
2441
+ const target = documentInfo.find((i) => i.name === btnID);
2442
+ if (!target) {
2443
+ return;
2444
+ }
2445
+ await MovePage(target.startPage);
2446
+ }
2447
+ async function SignatureHandler({ type, btnID }) {
2448
+ if (type !== "signature") {
2449
+ throw `Unexpected Type ${type}`;
2450
+ }
2451
+ const reportCount = await getReportCount();
2452
+ const pageCount = await getTotalPage();
2453
+ if (btnID === "signatureInProgress") {
2454
+ await enableFocusOnValidation(reportCount);
2455
+ await validateAllPages(pageCount);
2456
+ } else {
2457
+ try {
2458
+ await Bridge.native.showLoader();
2459
+ await disableFocusOnValidation(reportCount);
2460
+ const isAllValid = await validateAllPages(pageCount);
2461
+ if (!isAllValid) {
2462
+ throw "MissingAlert";
2463
+ }
2464
+ const filePath = await SaveTotalPdf();
2465
+ await Bridge.nativeOz.createOzPdfViewer({ filePath });
2466
+ } catch (e) {
2467
+ if (e === "MissingAlert") {
2468
+ await Bridge.nativeOz.showMissingAlert();
2469
+ } else {
2470
+ alert("PDF export \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD558\uC600\uC2B5\uB2C8\uB2E4");
2471
+ }
2472
+ } finally {
2473
+ await Bridge.native.hideLoader();
2474
+ }
2475
+ }
2476
+ }
2477
+ async function TopHandler({ type, btnID }) {
2478
+ if (type !== "top") {
2479
+ throw `Unexpected Type ${type}`;
2480
+ }
2481
+ if (btnID === "btnExit") {
2482
+ await Bridge.native.hideOZViewer();
2483
+ }
2484
+ }
2485
+ async function PdfHandler({ type, btnID }) {
2486
+ if (type !== "pdf") {
2487
+ throw `Unexpected Type ${type}`;
2488
+ }
2489
+ if (btnID === "modify") {
2490
+ await Bridge.nativeOz.hideOzPdfViewer();
2491
+ } else {
2492
+ await Bridge.nativeOz.hideOzPdfViewer();
2493
+ await Bridge.native.hideOZViewer();
2494
+ }
2495
+ }
2496
+ function PromiseWithResolvers() {
2497
+ let resolve;
2498
+ let reject;
2499
+ const promise = new Promise((res, rej) => {
2500
+ resolve = res;
2501
+ reject = rej;
2502
+ });
2503
+ return { promise, resolve, reject };
2504
+ }
2505
+ async function SaveTotalPdf() {
2506
+ const { promise, resolve } = PromiseWithResolvers();
2507
+ window.addEventListener(
2508
+ "OZExportCommand" /* OZExportCommand */,
2509
+ // 이벤트를 CustomEvent로 타입 캐스팅하고, detail에서 파일 경로 추출
2510
+ (e) => resolve(e.detail.filepaths),
2511
+ // 이벤트 리스너는 한 번만 실행되도록 설정
2512
+ { once: true }
2513
+ );
2514
+ const totalPage = await getTotalPage();
2515
+ await Bridge.nativeOz.savePdf({
2516
+ param: [
2517
+ // 저장할 파일명 설정
2518
+ `pdf.filename=${"total.pdf"}`,
2519
+ // 1페이지부터 마지막 페이지까지 저장
2520
+ `export.pages=${1}-${totalPage}`,
2521
+ // 공통 PDF 내보내기 파라미터 추가
2522
+ ...commonPdfExportParam
2523
+ ].join("\n")
2524
+ });
2525
+ const filepath = await promise;
2526
+ return filepath;
2527
+ }
2410
2528
 
2411
2529
  // src/oz/use-create-report.ts
2412
2530
  function useCreateReport({ documentList, extraData = {} }) {
@@ -2475,6 +2593,7 @@ function useDocumentInfo(initialValue) {
2475
2593
  });
2476
2594
  return acc;
2477
2595
  }, []), [documentIndexMap, documentInfo]);
2596
+ const isAllComplete = (0, import_react2.useMemo)(() => documentInfo.every((i) => i.complete), [documentInfo]);
2478
2597
  return {
2479
2598
  setDocumentInfo,
2480
2599
  documentInfo,
@@ -2482,7 +2601,8 @@ function useDocumentInfo(initialValue) {
2482
2601
  documentTemplateMap,
2483
2602
  documentIndexMap,
2484
2603
  nameTemplateMap,
2485
- groupIndexes
2604
+ groupIndexes,
2605
+ isAllComplete
2486
2606
  };
2487
2607
  }
2488
2608
 
@@ -2529,7 +2649,15 @@ react/cjs/react.development.js:
2529
2649
  */
2530
2650
 
2531
2651
  exports.Bridge = Bridge;
2652
+ exports.CategoryHandler = CategoryHandler;
2653
+ exports.CommentHandler = CommentHandler;
2654
+ exports.MovePage = MovePage;
2532
2655
  exports.OZViewerEvent = OZViewerEvent;
2656
+ exports.PdfHandler = PdfHandler;
2657
+ exports.PromiseWithResolvers = PromiseWithResolvers;
2658
+ exports.SaveTotalPdf = SaveTotalPdf;
2659
+ exports.SignatureHandler = SignatureHandler;
2660
+ exports.TopHandler = TopHandler;
2533
2661
  exports.btnStyle = btnStyle;
2534
2662
  exports.categorizeByPageRange = categorizeByPageRange;
2535
2663
  exports.checkDocumentsValidityByIndex = checkDocumentsValidityByIndex;
@@ -2558,8 +2686,7 @@ exports.triggerCropImageOnAllDocuments = triggerCropImageOnAllDocuments;
2558
2686
  exports.useCreateReport = useCreateReport;
2559
2687
  exports.useDocumentInfo = useDocumentInfo;
2560
2688
  exports.useOzEventListener = useOzEventListener;
2561
- exports.validateAllDocuments = validateAllDocuments;
2562
- exports.validatePages = validatePages;
2689
+ exports.validateAllPages = validateAllPages;
2563
2690
  exports.wrapperStyle = wrapperStyle;
2564
2691
  //# sourceMappingURL=index.cjs.map
2565
2692
  //# sourceMappingURL=index.cjs.map