@revenuecat/purchases-ui-js 4.8.4 → 4.8.5

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.
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import Stack from "../stack/Stack.svelte";
3
3
  import { getPaywallContext } from "../../stores/paywall";
4
+ import { setPackageIdContext } from "../../stores/packageId";
4
5
  import { setSelectedStateContext } from "../../stores/selected";
5
6
  import {
6
7
  getVariablesContext,
@@ -18,6 +19,8 @@
18
19
  const { stack, package_id, is_selected_by_default, name }: PackageProps =
19
20
  $props();
20
21
 
22
+ setPackageIdContext(package_id);
23
+
21
24
  const {
22
25
  defaultPackageId,
23
26
  emitComponentInteraction,
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import Stack from "../stack/Stack.svelte";
3
3
  import { getLocalizationContext } from "../../stores/localization";
4
+ import { getOptionalPackageIdContext } from "../../stores/packageId";
4
5
  import { getPaywallContext } from "../../stores/paywall";
5
6
  import type { PurchaseButtonProps } from "../../types/components/purchase-button";
6
7
  import type { PurchaseButtonInteractionData } from "../../types/paywall-component-interaction";
@@ -16,6 +17,9 @@
16
17
  } = getPaywallContext();
17
18
  const { getLocalizedString } = getLocalizationContext();
18
19
 
20
+ // Set when embedded in a package; standalone buttons fall back to the store.
21
+ const enclosingPackageId = getOptionalPackageIdContext();
22
+
19
23
  const appendQueryParam = (url: string, key: string, value: string) => {
20
24
  const hashIndex = url.indexOf("#");
21
25
  const hash = hashIndex === -1 ? "" : url.slice(hashIndex);
@@ -64,8 +68,10 @@
64
68
  };
65
69
 
66
70
  const onclick = () => {
67
- const packageId = $selectedPackageId;
71
+ const packageId = enclosingPackageId ?? $selectedPackageId;
68
72
  if (packageId !== undefined) {
73
+ // Sync before purchasing so onPurchase reads this package, not a stale one.
74
+ $selectedPackageId = packageId;
69
75
  emitComponentInteraction(getPurchaseButtonInteractionData(packageId));
70
76
  }
71
77
 
@@ -187,7 +187,7 @@
187
187
  style="position: relative; width: 100%; height: 100%; isolation: isolate;"
188
188
  >
189
189
  {#each components as component, index}
190
- <div style={getLayerStyle(index)}>
190
+ <div class="rc-zlayer-layer" style={getLayerStyle(index)}>
191
191
  <Node nodeData={component} />
192
192
  </div>
193
193
  {/each}
@@ -236,4 +236,18 @@
236
236
  position: relative;
237
237
  z-index: 3;
238
238
  }
239
+
240
+ /*
241
+ * Each overlay layer is a full-size (inset:0) box, so by default it swallows
242
+ * clicks anywhere over the stack — including where it has no content —
243
+ * blocking interactive elements on the layers beneath. Only its own content
244
+ * should be hit-testable.
245
+ */
246
+ .rc-zlayer-layer {
247
+ pointer-events: none;
248
+ }
249
+
250
+ .rc-zlayer-layer > :global(*) {
251
+ pointer-events: auto;
252
+ }
239
253
  </style>
@@ -0,0 +1,2 @@
1
+ export declare function setPackageIdContext(packageId: string): void;
2
+ export declare function getOptionalPackageIdContext(): string | undefined;
@@ -0,0 +1,8 @@
1
+ import { getContext, setContext } from "svelte";
2
+ const key = Symbol("packageId");
3
+ export function setPackageIdContext(packageId) {
4
+ setContext(key, packageId);
5
+ }
6
+ export function getOptionalPackageIdContext() {
7
+ return getContext(key);
8
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@revenuecat/purchases-ui-js",
3
3
  "description": "Web components for Paywalls. Powered by RevenueCat",
4
4
  "private": false,
5
- "version": "4.8.4",
5
+ "version": "4.8.5",
6
6
  "author": {
7
7
  "name": "RevenueCat, Inc."
8
8
  },