@jingx/lottery-components-react-jsx 1.0.25 → 1.0.26

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.esm.js CHANGED
@@ -38114,7 +38114,7 @@ function ScopeHost({ className, children, style }) {
38114
38114
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style, ref, className: `spacx bg-transparent ${className}`, children: typeof children === "function" ? children(container) : children });
38115
38115
  }
38116
38116
 
38117
- const totalStyle = { lineHeight: "15px", fontWeight: 600, fontSize: 25 };
38117
+ const totalStyle = { lineHeight: "25px", fontWeight: 600, fontSize: 25 };
38118
38118
  const dotStyle = { lineHeight: "13px", fontWeight: 800, fontSize: 25, color: "black" };
38119
38119
  const RenderRow = ({ children, label, isShow = true }) => {
38120
38120
  if (!isShow) return null;
@@ -46249,17 +46249,31 @@ var parseBackgroundColor = function (context, element, backgroundColorOverride)
46249
46249
  : defaultBackgroundColor;
46250
46250
  };
46251
46251
 
46252
+ const getCanvasScale = () => {
46253
+ const deviceScale = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
46254
+ return Math.max(deviceScale, 5);
46255
+ };
46256
+ const getCanvasOptions = (node, useCORS = true) => ({
46257
+ scale: getCanvasScale(),
46258
+ useCORS,
46259
+ backgroundColor: "#ffffff",
46260
+ logging: false,
46261
+ removeContainer: true,
46262
+ width: node.scrollWidth,
46263
+ height: node.scrollHeight,
46264
+ windowWidth: node.scrollWidth,
46265
+ windowHeight: node.scrollHeight
46266
+ });
46252
46267
  const exportToImage = async (reportRef, actionButtonsRef, lotteryType, ticketNumber) => {
46253
46268
  if (!reportRef.current || !actionButtonsRef.current) return;
46254
46269
  const originalVisibility = actionButtonsRef.current.style.visibility;
46255
46270
  try {
46256
46271
  actionButtonsRef.current.style.visibility = "hidden";
46257
- const scale = window.devicePixelRatio || 2;
46258
- const canvas = await html2canvas(reportRef.current, {
46259
- scale,
46260
- useCORS: false,
46261
- backgroundColor: "#ffffff"
46262
- });
46272
+ await waitForFontsAndImages(reportRef.current);
46273
+ const canvas = await html2canvas(
46274
+ reportRef.current,
46275
+ getCanvasOptions(reportRef.current, true)
46276
+ );
46263
46277
  const image = canvas.toDataURL(`image/png`, 1);
46264
46278
  const link = document.createElement("a");
46265
46279
  link.href = image;
@@ -46280,14 +46294,7 @@ const copyImageToClipboard = async (reportRef, actionButtonsRef, lotteryType, ti
46280
46294
  try {
46281
46295
  if (btn) btn.style.visibility = "hidden";
46282
46296
  await waitForFontsAndImages(node);
46283
- const scale = window.devicePixelRatio || 2;
46284
- const canvas = await html2canvas(node, {
46285
- scale,
46286
- useCORS: true,
46287
- backgroundColor: "#ffffff",
46288
- logging: false,
46289
- removeContainer: true
46290
- });
46297
+ const canvas = await html2canvas(node, getCanvasOptions(node));
46291
46298
  const blob = await canvasToBlob(canvas);
46292
46299
  if (!blob) throw new Error("Clipboard blob unavailable");
46293
46300
  if (!((_a = navigator.clipboard) == null ? void 0 : _a.write)) {
@@ -46333,15 +46340,7 @@ const exportToImageShare = async (reportRef, actionButtonsRef, lotteryType, tick
46333
46340
  try {
46334
46341
  if (btn) btn.style.visibility = "hidden";
46335
46342
  await waitForFontsAndImages(node);
46336
- const scale = window.devicePixelRatio || 2;
46337
- const canvas = await html2canvas(node, {
46338
- scale,
46339
- useCORS: true,
46340
- // enable if your images have CORS headers
46341
- backgroundColor: "#ffffff",
46342
- logging: false,
46343
- removeContainer: true
46344
- });
46343
+ const canvas = await html2canvas(node, getCanvasOptions(node));
46345
46344
  const blob = await canvasToBlob(canvas);
46346
46345
  if (!blob) return;
46347
46346
  const fileName = `${lotteryType}-#${ticketNumber}.png`;