@betterstore/react 0.3.43 → 0.3.44

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.44
4
+
5
+ ### Patch Changes
6
+
7
+ - bug fixes
8
+
3
9
  ## 0.3.43
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -570,25 +570,28 @@ const appearance = {
570
570
 
571
571
  function Appearance({ appearance, fonts, }) {
572
572
  React.useEffect(() => {
573
+ var _a;
573
574
  const variables = getVariablesFromAppearanceConfig(appearance);
574
- if (variables) {
575
+ const iframe = document.querySelector("iframe");
576
+ const iframeDoc = (iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) || ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
577
+ if (variables && iframeDoc) {
575
578
  Object.entries(variables).forEach(([key, value]) => {
576
- document.documentElement.style.setProperty(key, value);
579
+ iframeDoc.documentElement.style.setProperty(key, value);
577
580
  });
578
581
  }
579
582
  // Load fonts if provided
580
- if (fonts) {
583
+ if (fonts && iframeDoc) {
581
584
  fonts.forEach((font) => {
582
585
  if ("cssSrc" in font) {
583
586
  // Handle CSS font source
584
- const link = document.createElement("link");
587
+ const link = iframeDoc.createElement("link");
585
588
  link.rel = "stylesheet";
586
589
  link.href = font.cssSrc;
587
- document.head.appendChild(link);
590
+ iframeDoc.head.appendChild(link);
588
591
  }
589
592
  else if ("family" in font) {
590
593
  // Handle custom font source
591
- const style = document.createElement("style");
594
+ const style = iframeDoc.createElement("style");
592
595
  style.textContent = `
593
596
  @font-face {
594
597
  font-family: '${font.family}';
@@ -597,11 +600,11 @@ function Appearance({ appearance, fonts, }) {
597
600
  font-style: ${font.style || "normal"};
598
601
  }
599
602
  `;
600
- document.head.appendChild(style);
603
+ iframeDoc.head.appendChild(style);
601
604
  }
602
605
  });
603
606
  }
604
- }, [appearance]);
607
+ }, [appearance, fonts]);
605
608
  return null;
606
609
  }
607
610
  const getVariablesFromAppearanceConfig = (appearance) => {
package/dist/index.mjs CHANGED
@@ -547,25 +547,28 @@ const appearance = {
547
547
 
548
548
  function Appearance({ appearance, fonts, }) {
549
549
  useEffect(() => {
550
+ var _a;
550
551
  const variables = getVariablesFromAppearanceConfig(appearance);
551
- if (variables) {
552
+ const iframe = document.querySelector("iframe");
553
+ const iframeDoc = (iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) || ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
554
+ if (variables && iframeDoc) {
552
555
  Object.entries(variables).forEach(([key, value]) => {
553
- document.documentElement.style.setProperty(key, value);
556
+ iframeDoc.documentElement.style.setProperty(key, value);
554
557
  });
555
558
  }
556
559
  // Load fonts if provided
557
- if (fonts) {
560
+ if (fonts && iframeDoc) {
558
561
  fonts.forEach((font) => {
559
562
  if ("cssSrc" in font) {
560
563
  // Handle CSS font source
561
- const link = document.createElement("link");
564
+ const link = iframeDoc.createElement("link");
562
565
  link.rel = "stylesheet";
563
566
  link.href = font.cssSrc;
564
- document.head.appendChild(link);
567
+ iframeDoc.head.appendChild(link);
565
568
  }
566
569
  else if ("family" in font) {
567
570
  // Handle custom font source
568
- const style = document.createElement("style");
571
+ const style = iframeDoc.createElement("style");
569
572
  style.textContent = `
570
573
  @font-face {
571
574
  font-family: '${font.family}';
@@ -574,11 +577,11 @@ function Appearance({ appearance, fonts, }) {
574
577
  font-style: ${font.style || "normal"};
575
578
  }
576
579
  `;
577
- document.head.appendChild(style);
580
+ iframeDoc.head.appendChild(style);
578
581
  }
579
582
  });
580
583
  }
581
- }, [appearance]);
584
+ }, [appearance, fonts]);
582
585
  return null;
583
586
  }
584
587
  const getVariablesFromAppearanceConfig = (appearance) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/react",
3
- "version": "0.3.43",
3
+ "version": "0.3.44",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {