@ostack.tech/ui 1.3.1 → 1.3.2

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.
@@ -327,7 +327,7 @@
327
327
  }
328
328
  }
329
329
  @media not print {
330
- .o-ui-print-only {
330
+ body:not(.o-ui-printer__iframe) .o-ui-print-only {
331
331
  display: none !important;
332
332
  }
333
333
  }
package/dist/ostack-ui.js CHANGED
@@ -12288,35 +12288,6 @@ function usePrintInProgress() {
12288
12288
  function usePrint() {
12289
12289
  return usePrinterContext().print;
12290
12290
  }
12291
- // src/components/Printer/usePrintClassNames.ts
12292
- /** Hook which exposes print-related class names. */
12293
- function usePrintClassNames() {
12294
- const $ = c(7);
12295
- const prefix = usePrefix();
12296
- let t0;
12297
- if ($[0] !== prefix) {
12298
- t0 = prefix("print-only");
12299
- $[0] = prefix;
12300
- $[1] = t0;
12301
- } else t0 = $[1];
12302
- let t1;
12303
- if ($[2] !== prefix) {
12304
- t1 = prefix("print-hidden");
12305
- $[2] = prefix;
12306
- $[3] = t1;
12307
- } else t1 = $[3];
12308
- let t2;
12309
- if ($[4] !== t0 || $[5] !== t1) {
12310
- t2 = {
12311
- printOnly: t0,
12312
- printHidden: t1
12313
- };
12314
- $[4] = t0;
12315
- $[5] = t1;
12316
- $[6] = t2;
12317
- } else t2 = $[6];
12318
- return t2;
12319
- }
12320
12291
  // src/components/Printer/Printer.tsx
12321
12292
  /**
12322
12293
  * Component used to print content using the browser's printing functionality. The content is copied
@@ -12356,11 +12327,10 @@ function usePrintClassNames() {
12356
12327
  * ```
12357
12328
  */
12358
12329
  function Printer(t0) {
12359
- const $ = c(46);
12360
- const { preview, printInForeground, documentTitle, pageSize, pageMargin, printColorAdjust: t1, fonts, copyShadowRoots, nonce, printFn, onBeforePrint, onAfterPrint, iframeProps, children } = t0;
12330
+ const $ = c(42);
12331
+ const { preview, printInForeground, documentTitle: documentTitleProp, pageSize, pageMargin, printColorAdjust: t1, fonts, copyShadowRoots, nonce, printFn, onBeforePrint, onAfterPrint, iframeProps, children } = t0;
12361
12332
  const printColorAdjust = t1 === void 0 ? "exact" : t1;
12362
12333
  const prefix = usePrefix();
12363
- const { printOnly } = usePrintClassNames();
12364
12334
  const triggerRef = useRef(null);
12365
12335
  const contentRef = useRef(null);
12366
12336
  const [printInProgress, setPrintInProgress] = useState(false);
@@ -12421,19 +12391,19 @@ function Printer(t0) {
12421
12391
  $[3] = t5;
12422
12392
  } else t5 = $[3];
12423
12393
  const waitForPrintingTasks = t5;
12424
- const relevantDocumentTitle = printOptions?.documentTitle ?? documentTitle;
12394
+ const documentTitle = printOptions?.documentTitle ?? documentTitleProp;
12425
12395
  let t6;
12426
12396
  if ($[4] !== prefix || $[5] !== preview || $[6] !== printInForeground) {
12427
- t6 = preview || printInForeground ? prefix("root") : void 0;
12397
+ t6 = cx(prefix("printer__iframe"), (preview || printInForeground) && prefix("root"));
12428
12398
  $[4] = prefix;
12429
12399
  $[5] = preview;
12430
12400
  $[6] = printInForeground;
12431
12401
  $[7] = t6;
12432
12402
  } else t6 = $[7];
12433
12403
  let t7;
12434
- if ($[8] !== relevantDocumentTitle) {
12435
- t7 = typeof relevantDocumentTitle === "function" ? () => relevantDocumentTitle() ?? getDocumentTitle() : relevantDocumentTitle ?? getDocumentTitle();
12436
- $[8] = relevantDocumentTitle;
12404
+ if ($[8] !== documentTitle) {
12405
+ t7 = typeof documentTitle === "function" ? () => documentTitle() ?? getDocumentTitle() : documentTitle ?? getDocumentTitle();
12406
+ $[8] = documentTitle;
12437
12407
  $[9] = t7;
12438
12408
  } else t7 = $[9];
12439
12409
  const t8 = printOptions?.pageSize ?? pageSize;
@@ -12455,26 +12425,9 @@ function Printer(t0) {
12455
12425
  const t13 = printOptions?.copyShadowRoots ?? copyShadowRoots;
12456
12426
  const t14 = printOptions?.nonce ?? nonce;
12457
12427
  const t15 = printOptions?.iframeProps ?? iframeProps;
12458
- let t16;
12459
- if ($[14] !== printFn || $[15] !== printOnly || $[16] !== printOptions?.printFn) {
12460
- t16 = async (iframe) => {
12461
- const doc = iframe.contentDocument;
12462
- const win = iframe.contentWindow;
12463
- if (doc && win) {
12464
- for (const el of doc.querySelectorAll(`.${printOnly}`)) el.classList.remove(printOnly);
12465
- await new Promise((res) => win.requestAnimationFrame(res));
12466
- }
12467
- const customPrintFn = printOptions?.printFn ?? printFn;
12468
- if (customPrintFn) return customPrintFn(iframe);
12469
- win?.print();
12470
- };
12471
- $[14] = printFn;
12472
- $[15] = printOnly;
12473
- $[16] = printOptions?.printFn;
12474
- $[17] = t16;
12475
- } else t16 = $[17];
12428
+ const t16 = printOptions?.printFn ?? printFn;
12476
12429
  let t17;
12477
- if ($[18] !== onAfterPrint) {
12430
+ if ($[14] !== onAfterPrint) {
12478
12431
  t17 = () => {
12479
12432
  let event;
12480
12433
  withCleanup(() => onAfterPrint?.(event = new Event("ostack-ui.afterPrint")), () => {
@@ -12482,19 +12435,19 @@ function Printer(t0) {
12482
12435
  finishPrint(!event?.defaultPrevented);
12483
12436
  });
12484
12437
  };
12485
- $[18] = onAfterPrint;
12486
- $[19] = t17;
12487
- } else t17 = $[19];
12438
+ $[14] = onAfterPrint;
12439
+ $[15] = t17;
12440
+ } else t17 = $[15];
12488
12441
  let t18;
12489
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
12442
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
12490
12443
  t18 = (_errorLocation, error) => {
12491
12444
  rejectPrintRef.current?.(error);
12492
12445
  finishPrint();
12493
12446
  };
12494
- $[20] = t18;
12495
- } else t18 = $[20];
12447
+ $[16] = t18;
12448
+ } else t18 = $[16];
12496
12449
  let t19;
12497
- if ($[21] !== t11 || $[22] !== t12 || $[23] !== t13 || $[24] !== t14 || $[25] !== t15 || $[26] !== t16 || $[27] !== t17 || $[28] !== t6 || $[29] !== t7) {
12450
+ if ($[17] !== t11 || $[18] !== t12 || $[19] !== t13 || $[20] !== t14 || $[21] !== t15 || $[22] !== t16 || $[23] !== t17 || $[24] !== t6 || $[25] !== t7) {
12498
12451
  t19 = {
12499
12452
  bodyClass: t6,
12500
12453
  documentTitle: t7,
@@ -12508,33 +12461,33 @@ function Printer(t0) {
12508
12461
  onAfterPrint: t17,
12509
12462
  onPrintError: t18
12510
12463
  };
12511
- $[21] = t11;
12512
- $[22] = t12;
12513
- $[23] = t13;
12514
- $[24] = t14;
12515
- $[25] = t15;
12516
- $[26] = t16;
12517
- $[27] = t17;
12518
- $[28] = t6;
12519
- $[29] = t7;
12520
- $[30] = t19;
12521
- } else t19 = $[30];
12464
+ $[17] = t11;
12465
+ $[18] = t12;
12466
+ $[19] = t13;
12467
+ $[20] = t14;
12468
+ $[21] = t15;
12469
+ $[22] = t16;
12470
+ $[23] = t17;
12471
+ $[24] = t6;
12472
+ $[25] = t7;
12473
+ $[26] = t19;
12474
+ } else t19 = $[26];
12522
12475
  const reactToPrintFn = useReactToPrint(t19);
12523
12476
  let t20;
12524
- if ($[31] !== onBeforePrint || $[32] !== printInProgress || $[33] !== reactToPrintFn) {
12477
+ if ($[27] !== onBeforePrint || $[28] !== printInProgress || $[29] !== reactToPrintFn) {
12525
12478
  t20 = {
12526
12479
  printInProgress,
12527
12480
  reactToPrintFn,
12528
12481
  onBeforePrint
12529
12482
  };
12530
- $[31] = onBeforePrint;
12531
- $[32] = printInProgress;
12532
- $[33] = reactToPrintFn;
12533
- $[34] = t20;
12534
- } else t20 = $[34];
12483
+ $[27] = onBeforePrint;
12484
+ $[28] = printInProgress;
12485
+ $[29] = reactToPrintFn;
12486
+ $[30] = t20;
12487
+ } else t20 = $[30];
12535
12488
  const latestRef = useLatestRef(t20);
12536
12489
  let t21;
12537
- if ($[35] !== latestRef) {
12490
+ if ($[31] !== latestRef) {
12538
12491
  t21 = async (options) => {
12539
12492
  const { printInProgress: printInProgress_0, onBeforePrint: onBeforePrint_0 } = latestRef.current;
12540
12493
  if (printInProgress_0) throw new Error("Printing is already in progress.");
@@ -12554,45 +12507,45 @@ function Printer(t0) {
12554
12507
  finishPrint();
12555
12508
  throw error_0;
12556
12509
  }
12557
- return new Promise((res_0, rej) => {
12558
- resolvePrintRef.current = res_0;
12510
+ return new Promise((res, rej) => {
12511
+ resolvePrintRef.current = res;
12559
12512
  rejectPrintRef.current = rej;
12560
12513
  latestRef.current.reactToPrintFn(() => contentRef.current);
12561
12514
  });
12562
12515
  };
12563
- $[35] = latestRef;
12564
- $[36] = t21;
12565
- } else t21 = $[36];
12516
+ $[31] = latestRef;
12517
+ $[32] = t21;
12518
+ } else t21 = $[32];
12566
12519
  const handlePrint = t21;
12567
12520
  let t22;
12568
- if ($[37] !== documentTitle || $[38] !== handlePrint || $[39] !== preview || $[40] !== printInForeground || $[41] !== printInProgress) {
12521
+ if ($[33] !== documentTitleProp || $[34] !== handlePrint || $[35] !== preview || $[36] !== printInForeground || $[37] !== printInProgress) {
12569
12522
  t22 = {
12570
12523
  preview,
12571
12524
  printInForeground,
12572
- documentTitle,
12525
+ documentTitle: documentTitleProp,
12573
12526
  printInProgress,
12574
12527
  triggerRef,
12575
12528
  contentRef,
12576
12529
  print: handlePrint,
12577
12530
  startPrintingTask
12578
12531
  };
12579
- $[37] = documentTitle;
12580
- $[38] = handlePrint;
12581
- $[39] = preview;
12582
- $[40] = printInForeground;
12583
- $[41] = printInProgress;
12584
- $[42] = t22;
12585
- } else t22 = $[42];
12532
+ $[33] = documentTitleProp;
12533
+ $[34] = handlePrint;
12534
+ $[35] = preview;
12535
+ $[36] = printInForeground;
12536
+ $[37] = printInProgress;
12537
+ $[38] = t22;
12538
+ } else t22 = $[38];
12586
12539
  let t23;
12587
- if ($[43] !== children || $[44] !== t22) {
12540
+ if ($[39] !== children || $[40] !== t22) {
12588
12541
  t23 = /* @__PURE__ */ jsx(PrinterContext, {
12589
12542
  value: t22,
12590
12543
  children
12591
12544
  });
12592
- $[43] = children;
12593
- $[44] = t22;
12594
- $[45] = t23;
12595
- } else t23 = $[45];
12545
+ $[39] = children;
12546
+ $[40] = t22;
12547
+ $[41] = t23;
12548
+ } else t23 = $[41];
12596
12549
  return t23;
12597
12550
  }
12598
12551
  function _temp$41(resolve) {
@@ -12612,6 +12565,35 @@ function printPageStyle({ pageSize, pageMargin, printColorAdjust }) {
12612
12565
  if (pageMargin != null) pageStyle += `@page { margin: ${pageMargin} }`;
12613
12566
  return pageStyle;
12614
12567
  }
12568
+ // src/components/Printer/usePrintClassNames.ts
12569
+ /** Hook which exposes print-related class names. */
12570
+ function usePrintClassNames() {
12571
+ const $ = c(7);
12572
+ const prefix = usePrefix();
12573
+ let t0;
12574
+ if ($[0] !== prefix) {
12575
+ t0 = prefix("print-only");
12576
+ $[0] = prefix;
12577
+ $[1] = t0;
12578
+ } else t0 = $[1];
12579
+ let t1;
12580
+ if ($[2] !== prefix) {
12581
+ t1 = prefix("print-hidden");
12582
+ $[2] = prefix;
12583
+ $[3] = t1;
12584
+ } else t1 = $[3];
12585
+ let t2;
12586
+ if ($[4] !== t0 || $[5] !== t1) {
12587
+ t2 = {
12588
+ printOnly: t0,
12589
+ printHidden: t1
12590
+ };
12591
+ $[4] = t0;
12592
+ $[5] = t1;
12593
+ $[6] = t2;
12594
+ } else t2 = $[6];
12595
+ return t2;
12596
+ }
12615
12597
  // src/components/Printer/PrinterContent.tsx
12616
12598
  /**
12617
12599
  * Content to be printed.