@revenuecat/purchases-ui-js 2.0.0 → 2.0.1

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.
Files changed (93) hide show
  1. package/dist/components/button/Button.svelte +1 -5
  2. package/dist/components/button/ButtonNode.stories.svelte +62 -70
  3. package/dist/components/button/ButtonNode.stories.svelte.d.ts +0 -8
  4. package/dist/components/button/ButtonNode.svelte +11 -19
  5. package/dist/components/button/ButtonNode.svelte.d.ts +2 -2
  6. package/dist/components/button/button-utils.d.ts +2 -2
  7. package/dist/components/footer/Footer.stories.svelte +30 -22
  8. package/dist/components/footer/Footer.stories.svelte.d.ts +0 -5
  9. package/dist/components/footer/Footer.svelte +3 -10
  10. package/dist/components/footer/Footer.svelte.d.ts +1 -1
  11. package/dist/components/image/Image.stories.svelte +26 -7
  12. package/dist/components/image/Image.svelte +17 -15
  13. package/dist/components/image/image-utils.d.ts +2 -1
  14. package/dist/components/image/image-utils.js +2 -2
  15. package/dist/components/package/Package.stories.svelte +31 -27
  16. package/dist/components/package/Package.stories.svelte.d.ts +0 -6
  17. package/dist/components/package/Package.svelte +18 -22
  18. package/dist/components/package/Package.svelte.d.ts +1 -1
  19. package/dist/components/paywall/Node.svelte +12 -39
  20. package/dist/components/paywall/Node.svelte.d.ts +4 -8
  21. package/dist/components/paywall/Paywall.stories.svelte +21 -78
  22. package/dist/components/paywall/Paywall.svelte +71 -98
  23. package/dist/components/paywall/Paywall.svelte.d.ts +4 -4
  24. package/dist/components/paywall/paywall-utils.d.ts +3 -2
  25. package/dist/components/paywall/paywall-utils.js +5 -5
  26. package/dist/components/purchase-button/PurchaseButton.stories.svelte +32 -26
  27. package/dist/components/purchase-button/PurchaseButton.stories.svelte.d.ts +0 -5
  28. package/dist/components/purchase-button/PurchaseButton.svelte +7 -11
  29. package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +1 -1
  30. package/dist/components/purchase-button/purchase-button-utils.d.ts +1 -1
  31. package/dist/components/stack/Stack.stories.svelte +34 -79
  32. package/dist/components/stack/Stack.svelte +15 -25
  33. package/dist/components/stack/stack-utils.d.ts +4 -3
  34. package/dist/components/stack/stack-utils.js +7 -8
  35. package/dist/components/text/TextNode.stories.svelte +46 -141
  36. package/dist/components/text/TextNode.svelte +13 -12
  37. package/dist/components/text/text-utils.d.ts +7 -6
  38. package/dist/components/text/text-utils.js +7 -7
  39. package/dist/components/timeline/Timeline.stories.svelte +41 -47
  40. package/dist/components/timeline/TimelineItem.svelte +28 -11
  41. package/dist/components/timeline/timeline-utils.d.ts +3 -3
  42. package/dist/components/timeline/timeline-utils.js +7 -16
  43. package/dist/data/entities.d.ts +59 -120
  44. package/dist/data/state.d.ts +0 -5
  45. package/dist/stores/color-mode.d.ts +6 -0
  46. package/dist/stores/color-mode.js +15 -0
  47. package/dist/stores/localization.d.ts +13 -0
  48. package/dist/stores/localization.js +25 -0
  49. package/dist/stores/paywall.d.ts +10 -0
  50. package/dist/stores/paywall.js +13 -0
  51. package/dist/stores/variables.d.ts +6 -0
  52. package/dist/stores/variables.js +14 -0
  53. package/dist/stories/fixtures.js +7 -76
  54. package/dist/stories/localization-decorator.d.ts +3 -0
  55. package/dist/stories/localization-decorator.js +7 -0
  56. package/dist/stories/paywall-decorator.d.ts +2 -0
  57. package/dist/stories/paywall-decorator.js +18 -0
  58. package/dist/stories/variables-decorator.d.ts +3 -0
  59. package/dist/stories/variables-decorator.js +9 -0
  60. package/dist/stories/with-layout.svelte +1 -1
  61. package/dist/types/alignment.d.ts +19 -0
  62. package/dist/types/alignment.js +1 -0
  63. package/dist/types/background.d.ts +18 -0
  64. package/dist/types/background.js +1 -0
  65. package/dist/types/colors.d.ts +34 -0
  66. package/dist/types/colors.js +1 -0
  67. package/dist/types/components/button.d.ts +36 -0
  68. package/dist/types/components/button.js +1 -0
  69. package/dist/types/components/footer.d.ts +5 -0
  70. package/dist/types/components/footer.js +1 -0
  71. package/dist/types/components/package.d.ts +8 -0
  72. package/dist/types/components/package.js +1 -0
  73. package/dist/types/components/purchase-button.d.ts +5 -0
  74. package/dist/types/components/purchase-button.js +1 -0
  75. package/dist/types/localization.d.ts +4 -0
  76. package/dist/types/localization.js +1 -0
  77. package/dist/types/media.d.ts +18 -0
  78. package/dist/types/media.js +1 -0
  79. package/dist/types.d.ts +5 -35
  80. package/dist/ui/atoms/typography.stories.svelte +8 -14
  81. package/dist/ui/atoms/typography.svelte +1 -1
  82. package/dist/ui/molecules/button.stories.svelte +8 -15
  83. package/dist/ui/molecules/button.svelte +2 -1
  84. package/dist/ui/molecules/button.svelte.d.ts +2 -26
  85. package/dist/ui/molecules/types.d.ts +2 -1
  86. package/dist/utils/style-utils.d.ts +13 -11
  87. package/dist/utils/style-utils.js +8 -15
  88. package/dist/utils/variable-utils.d.ts +1 -38
  89. package/dist/utils/variable-utils.js +6 -48
  90. package/dist/web-components/index.js +519 -566
  91. package/package.json +33 -36
  92. package/dist/stores/theme.d.ts +0 -1
  93. package/dist/stores/theme.js +0 -17
@@ -1,10 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { getImageComponentStyles } from "./image-utils";
3
3
  import type { ImageProps } from "../../data/entities";
4
+ import { getColorModeContext } from "../../stores/color-mode";
4
5
  import { DEFAULT_COLOR_MODE } from "../../utils/constants";
5
6
 
6
7
  const { id, source, purchaseState, ...restProps }: ImageProps = $props();
7
8
 
9
+ const getColorMode = getColorModeContext();
10
+ const colorMode = $derived(getColorMode());
11
+
8
12
  let imageAspectRatio = $state(0);
9
13
  let imageElement: HTMLImageElement | null;
10
14
 
@@ -14,10 +18,10 @@
14
18
  imageAspectRatio = imageElement.naturalHeight / imageElement.naturalWidth;
15
19
  }
16
20
  }
21
+
17
22
  const { imageStyles, maskPath, linearGradientAngle } = $derived(
18
- getImageComponentStyles({
23
+ getImageComponentStyles(colorMode, {
19
24
  id,
20
- colorMode: purchaseState.colorMode,
21
25
  source,
22
26
  purchaseState,
23
27
  ...restProps,
@@ -26,13 +30,17 @@
26
30
  );
27
31
 
28
32
  const imageSource = $derived.by(() => {
29
- const colorMode = purchaseState.colorMode;
30
33
  if (source[colorMode]?.original) {
31
34
  return source[colorMode].original;
32
35
  } else {
33
36
  return source[DEFAULT_COLOR_MODE]?.original as string;
34
37
  }
35
38
  });
39
+
40
+ const colorOverlay = $derived(restProps.color_overlay);
41
+ const colorInfo = $derived(
42
+ colorOverlay?.[colorMode] ?? colorOverlay?.[DEFAULT_COLOR_MODE],
43
+ );
36
44
  </script>
37
45
 
38
46
  <img
@@ -64,7 +72,7 @@
64
72
  {/if}
65
73
  </clipPath>
66
74
 
67
- {#if restProps.color_overlay?.[purchaseState.colorMode]?.type === "linear"}
75
+ {#if colorInfo?.type === "linear"}
68
76
  <linearGradient
69
77
  id={`gradient-${id}`}
70
78
  x1={linearGradientAngle.x1}
@@ -72,14 +80,14 @@
72
80
  x2={linearGradientAngle.x2}
73
81
  y2={linearGradientAngle.y2}
74
82
  >
75
- {#each restProps.color_overlay?.[purchaseState.colorMode]?.points || restProps.color_overlay?.[DEFAULT_COLOR_MODE]?.points || [] as stop}
83
+ {#each colorInfo?.points || [] as stop}
76
84
  <stop
77
85
  offset={`${stop.percent}%`}
78
86
  style={`stop-color: ${stop.color}`}
79
87
  />
80
88
  {/each}
81
89
  </linearGradient>
82
- {:else if restProps.color_overlay?.[purchaseState.colorMode]?.type === "radial"}
90
+ {:else if colorInfo?.type === "radial"}
83
91
  <radialGradient
84
92
  id={`gradient-${id}`}
85
93
  cx="50%"
@@ -88,22 +96,16 @@
88
96
  fx="50%"
89
97
  fy="50%"
90
98
  >
91
- {#each restProps.color_overlay?.[purchaseState.colorMode]?.points || restProps.color_overlay?.[DEFAULT_COLOR_MODE]?.points || [] as stop}
99
+ {#each colorInfo?.points || [] as stop}
92
100
  <stop
93
101
  offset={`${stop.percent}%`}
94
102
  style={`stop-color: ${stop.color}`}
95
103
  />
96
104
  {/each}
97
105
  </radialGradient>
98
- {:else if restProps.color_overlay?.[purchaseState.colorMode]?.type === "hex"}
106
+ {:else if colorInfo?.type === "hex"}
99
107
  <linearGradient id={`gradient-${id}`}>
100
- <stop
101
- offset="0%"
102
- style={`stop-color: ${
103
- restProps.color_overlay[purchaseState.colorMode]?.value ||
104
- restProps.color_overlay?.[DEFAULT_COLOR_MODE]?.value
105
- }`}
106
- />
108
+ <stop offset="0%" style={`stop-color: ${colorInfo?.value}`} />
107
109
  </linearGradient>
108
110
  {/if}
109
111
  </defs>
@@ -1,10 +1,11 @@
1
1
  import type { ImageProps } from "../../data/entities";
2
+ import type { ColorMode } from "../../types";
2
3
  /**
3
4
  * Generates comprehensive styles for image components by combining gradient and size styles
4
5
  * @param props - Image component properties including gradient, mask and size
5
6
  * @returns Object containing image style variables and gradient style variables
6
7
  */
7
- export declare const getImageComponentStyles: (props: ImageProps & {
8
+ export declare const getImageComponentStyles: (colorMode: ColorMode, props: ImageProps & {
8
9
  imageAspectRatio: number;
9
10
  }) => {
10
11
  imageStyles: string;
@@ -4,7 +4,7 @@ import { getActiveStateProps, getLinearGradientAngle, getMaskPath, getMaskStyle,
4
4
  * @param props - Image component properties including gradient, mask and size
5
5
  * @returns Object containing image style variables and gradient style variables
6
6
  */
7
- export const getImageComponentStyles = (props) => {
7
+ export const getImageComponentStyles = (colorMode, props) => {
8
8
  const { size, overrides, componentState, zStackChildStyles } = props;
9
9
  const imageStyles = {
10
10
  "--height": "unset",
@@ -24,7 +24,7 @@ export const getImageComponentStyles = (props) => {
24
24
  Object.assign(imageStyles, getMaskStyle(props.mask_shape));
25
25
  const prefixedImageStyles = prefixObject(imageStyles, "image");
26
26
  const maskPath = getMaskPath(props);
27
- const linearGradientAngle = getLinearGradientAngle(props);
27
+ const linearGradientAngle = getLinearGradientAngle(colorMode, props);
28
28
  return {
29
29
  imageStyles: stringifyStyles(prefixedImageStyles),
30
30
  maskPath,
@@ -1,18 +1,30 @@
1
1
  <script module lang="ts">
2
- import { defineMeta } from "@storybook/addon-svelte-csf";
3
2
  import Package from "./Package.svelte";
4
- import type { Extra, SupportedActions } from "../../data/entities";
5
3
  import type { PurchaseState } from "../../data/state";
6
- import { DEFAULT_COLOR_MODE } from "../../utils/constants";
4
+ import { localizationDecorator } from "../../stories/localization-decorator";
5
+ import { defineMeta } from "@storybook/addon-svelte-csf";
7
6
 
8
- const onAction = (action: SupportedActions, data?: Extra) => {
9
- alert(`${action.type} ${JSON.stringify(data)}`);
10
- };
7
+ const defaultLocale = "en_US";
8
+ const priceLid = "QZ4ZmYsqjN";
9
+ const nameLid = "BcX-6YwhoV";
10
+ const purchaseState: PurchaseState = {};
11
11
 
12
12
  const { Story } = defineMeta({
13
13
  title: "Components/Package",
14
14
  component: Package,
15
15
  tags: ["autodocs"],
16
+ decorators: [
17
+ localizationDecorator({
18
+ defaultLocale,
19
+ localizations: {
20
+ [defaultLocale]: {
21
+ [nameLid]: "Monthly",
22
+ [priceLid]: "$1.99",
23
+ },
24
+ },
25
+ }),
26
+ ],
27
+ args: { purchaseState },
16
28
  argTypes: {
17
29
  stack: {
18
30
  control: { type: "object" },
@@ -26,18 +38,6 @@
26
38
  },
27
39
  },
28
40
  });
29
-
30
- export const labelsData = {
31
- en_US: {
32
- "BcX-6YwhoV": "Monthly",
33
- QZ4ZmYsqjN: "$1.99",
34
- },
35
- };
36
- const purchaseState: PurchaseState = {
37
- colorMode: DEFAULT_COLOR_MODE,
38
- locale: "en_US",
39
- defaultLocale: "en_US",
40
- };
41
41
  </script>
42
42
 
43
43
  <!-- Default -->
@@ -47,8 +47,7 @@
47
47
  id: "6rQSD5e2Kz",
48
48
  is_selected_by_default: false,
49
49
  name: "Package - Monthly",
50
- package_id: "$rc_annual",
51
- purchaseState,
50
+ package_id: "$rc_monthly",
52
51
  stack: {
53
52
  purchaseState,
54
53
  background_color: {
@@ -57,7 +56,15 @@
57
56
  value: "#09090b",
58
57
  },
59
58
  },
60
- labels: labelsData,
59
+ background: {
60
+ type: "color",
61
+ value: {
62
+ light: {
63
+ type: "hex",
64
+ value: "#09090b",
65
+ },
66
+ },
67
+ },
61
68
  border: {
62
69
  color: {
63
70
  light: {
@@ -76,7 +83,6 @@
76
83
  value: "#ffffff",
77
84
  },
78
85
  },
79
- labels: labelsData,
80
86
  components: [],
81
87
  font_name: null,
82
88
  font_size: "heading_s",
@@ -106,7 +112,7 @@
106
112
  value: null,
107
113
  },
108
114
  },
109
- text_lid: "BcX-6YwhoV",
115
+ text_lid: nameLid,
110
116
  type: "text",
111
117
  },
112
118
  {
@@ -116,7 +122,6 @@
116
122
  value: "#292631",
117
123
  },
118
124
  },
119
- labels: labelsData,
120
125
  border: null,
121
126
  components: [
122
127
  {
@@ -156,7 +161,7 @@
156
161
  value: null,
157
162
  },
158
163
  },
159
- text_lid: "QZ4ZmYsqjN",
164
+ text_lid: priceLid,
160
165
  type: "text",
161
166
  },
162
167
  ],
@@ -241,9 +246,8 @@
241
246
  },
242
247
  spacing: 8,
243
248
  type: "stack",
249
+ shadow: null,
244
250
  },
245
- onAction,
246
- labels: labelsData,
247
251
  type: "package",
248
252
  }}
249
253
  />
@@ -1,10 +1,4 @@
1
1
  import Package from "./Package.svelte";
2
- export declare const labelsData: {
3
- en_US: {
4
- "BcX-6YwhoV": string;
5
- QZ4ZmYsqjN: string;
6
- };
7
- };
8
2
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
9
3
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
10
4
  $$bindings?: Bindings;
@@ -1,33 +1,36 @@
1
1
  <script lang="ts">
2
- import type { PackageProps, SelectPackageAction } from "../../data/entities";
3
2
  import Stack from "../stack/Stack.svelte";
3
+ import { getPaywallContext } from "../../stores/paywall";
4
+ import {
5
+ getVariablesContext,
6
+ setVariablesContext,
7
+ } from "../../stores/variables";
8
+ import type { PackageProps } from "../../types/components/package";
4
9
  import { prefixObject, stringifyStyles } from "../../utils/style-utils";
10
+ import { derived } from "svelte/store";
5
11
 
6
12
  const {
7
13
  stack,
8
14
  package_id,
9
15
  labels,
10
16
  id,
11
- onAction,
12
17
  purchaseState,
13
- variableDictionary,
14
18
  zStackChildStyles,
15
19
  }: PackageProps = $props();
16
- const onPackageClick = (evt: MouseEvent) => {
17
- evt.preventDefault();
18
- evt.stopPropagation();
19
- onAction &&
20
- onAction({ type: "select_package" } as SelectPackageAction, {
21
- packageId: package_id,
22
- });
23
- };
24
20
 
25
- const packageVariables = $derived(
26
- purchaseState.variablesPerPackage?.[package_id] || variableDictionary,
21
+ const { selectedPackageId } = getPaywallContext();
22
+
23
+ const onPackageClick = () => ($selectedPackageId = package_id);
24
+
25
+ const fallbackVariables = getVariablesContext();
26
+ const variables = derived(
27
+ fallbackVariables,
28
+ (fallback) => purchaseState.variablesPerPackage?.[package_id] ?? fallback,
27
29
  );
30
+ setVariablesContext(variables);
28
31
 
29
32
  const componentState = $derived({
30
- selected: purchaseState?.selectedPackageId === package_id,
33
+ selected: $selectedPackageId === package_id,
31
34
  });
32
35
 
33
36
  const styles = $derived(
@@ -42,14 +45,7 @@
42
45
  onclick={onPackageClick}
43
46
  style={styles}
44
47
  >
45
- <Stack
46
- {...stack}
47
- {labels}
48
- {onAction}
49
- {purchaseState}
50
- {componentState}
51
- variableDictionary={packageVariables}
52
- />
48
+ <Stack {...stack} {labels} {purchaseState} {componentState} />
53
49
  </button>
54
50
 
55
51
  <style>
@@ -1,4 +1,4 @@
1
- import type { PackageProps } from "../../data/entities";
1
+ import type { PackageProps } from "../../types/components/package";
2
2
  declare const Package: import("svelte").Component<PackageProps, {}, "">;
3
3
  type Package = ReturnType<typeof Package>;
4
4
  export default Package;
@@ -1,18 +1,4 @@
1
1
  <script lang="ts">
2
- import Self from "./Node.svelte";
3
- import {
4
- type ActionsProps,
5
- type ComponentLocalizations,
6
- type ComponentState,
7
- type Extra,
8
- type PaywallComponent,
9
- type PurchaseStateProps,
10
- type SupportedActions,
11
- } from "../../data/entities";
12
- import { prefersDarkMode } from "../../stores/theme";
13
- import type { VariableDictionary } from "../../utils/variable-utils";
14
- import type { ZStackChildStyles } from "../stack/stack-utils";
15
- import TextNode from "../text/TextNode.svelte";
16
2
  import {
17
3
  Footer,
18
4
  Image,
@@ -22,7 +8,15 @@
22
8
  Timeline,
23
9
  } from "../..";
24
10
  import ButtonNode from "../button/ButtonNode.svelte";
11
+ import type { ZStackChildStyles } from "../stack/stack-utils";
12
+ import TextNode from "../text/TextNode.svelte";
13
+ import {
14
+ type ComponentState,
15
+ type PaywallComponent,
16
+ type PurchaseStateProps,
17
+ } from "../../data/entities";
25
18
  import type { Component } from "svelte";
19
+ import Self from "./Node.svelte";
26
20
 
27
21
  type SupportedComponents =
28
22
  | TextNode
@@ -34,11 +28,8 @@
34
28
  | Footer
35
29
  | Timeline;
36
30
 
37
- interface Props extends ActionsProps, PurchaseStateProps {
31
+ interface Props extends PurchaseStateProps {
38
32
  nodeData: PaywallComponent;
39
- labels: ComponentLocalizations;
40
- onAction?: (action: SupportedActions, data?: Extra) => void;
41
- variableDictionary?: VariableDictionary;
42
33
  zStackChildStyles?: ZStackChildStyles;
43
34
  componentState?: ComponentState;
44
35
  }
@@ -88,37 +79,19 @@
88
79
  throw new Error(`Invalid component type: ${nodeData.type}`);
89
80
  };
90
81
 
91
- const {
92
- nodeData,
93
- labels,
94
- onAction,
95
- purchaseState,
96
- variableDictionary,
97
- zStackChildStyles,
98
- ...restProps
99
- }: Props = $props();
82
+ const { nodeData, purchaseState, zStackChildStyles, ...restProps }: Props =
83
+ $props();
100
84
 
101
85
  const [ComponentToRender, dataToUse] = $derived(getComponentClass(nodeData));
102
86
  </script>
103
87
 
104
88
  <ComponentToRender
105
89
  {...(dataToUse as any) || {}}
106
- {labels}
107
- prefersDarkMode={$prefersDarkMode}
108
- {onAction}
109
90
  {purchaseState}
110
- {variableDictionary}
111
91
  {zStackChildStyles}
112
92
  {...restProps}
113
93
  >
114
94
  {#each nodeData.components as PaywallComponent[] as childData}
115
- <Self
116
- nodeData={childData}
117
- {labels}
118
- {onAction}
119
- {purchaseState}
120
- {variableDictionary}
121
- {...restProps}
122
- />
95
+ <Self nodeData={childData} {purchaseState} {...restProps} />
123
96
  {/each}
124
97
  </ComponentToRender>
@@ -1,16 +1,12 @@
1
- import { type ActionsProps, type ComponentLocalizations, type ComponentState, type Extra, type PaywallComponent, type PurchaseStateProps, type SupportedActions } from "../../data/entities";
2
- import type { VariableDictionary } from "../../utils/variable-utils";
3
- import type { ZStackChildStyles } from "../stack/stack-utils";
4
- import TextNode from "../text/TextNode.svelte";
5
1
  import { Footer, Image, Package, PurchaseButton, Stack, Timeline } from "../..";
6
2
  import ButtonNode from "../button/ButtonNode.svelte";
3
+ import type { ZStackChildStyles } from "../stack/stack-utils";
4
+ import TextNode from "../text/TextNode.svelte";
5
+ import { type ComponentState, type PaywallComponent, type PurchaseStateProps } from "../../data/entities";
7
6
  import type { Component } from "svelte";
8
7
  type SupportedComponents = TextNode | Stack | Image | ButtonNode | PurchaseButton | Package | Footer | Timeline;
9
- interface Props extends ActionsProps, PurchaseStateProps {
8
+ interface Props extends PurchaseStateProps {
10
9
  nodeData: PaywallComponent;
11
- labels: ComponentLocalizations;
12
- onAction?: (action: SupportedActions, data?: Extra) => void;
13
- variableDictionary?: VariableDictionary;
14
10
  zStackChildStyles?: ZStackChildStyles;
15
11
  componentState?: ComponentState;
16
12
  }
@@ -5,20 +5,19 @@
5
5
  import {
6
6
  alignmentPaywallData,
7
7
  calmPaywallData,
8
+ colorModeOverrideTemplate,
9
+ e2eTestTemplate,
10
+ errorPaywallData,
11
+ fallbackPaywallData,
8
12
  fontsPaywallData,
13
+ gradientPaywallData,
9
14
  pastaPaywallData,
10
15
  paywallData,
11
- gradientPaywallData,
12
- variablesPastaPaywallData,
16
+ paywallWithFooter,
13
17
  posterMakerTemplate,
14
- e2eTestTemplate,
18
+ variablesPastaPaywallData,
15
19
  zStackTemplate,
16
- colorModeOverrideTemplate,
17
- errorPaywallData,
18
- paywallWithFooter,
19
- fallbackPaywallData,
20
20
  } from "../../stories/fixtures";
21
- import { fn } from "@storybook/test";
22
21
  import type { VariableDictionary } from "../../utils/variable-utils";
23
22
 
24
23
  const { Story } = defineMeta({
@@ -26,7 +25,14 @@
26
25
  component: Paywall,
27
26
  tags: ["autodocs"],
28
27
  argTypes: {},
29
- args: {},
28
+ args: {
29
+ onPurchaseClicked: (selectedPackageId: string) =>
30
+ alert(`Purchase package ${selectedPackageId}`),
31
+ onBackClicked: () => alert("Go back"),
32
+ onVisitCustomerCenterClicked: () => alert("Visit customer center"),
33
+ onRestorePurchasesClicked: () => alert("Restore purchases"),
34
+ onNavigateToUrlClicked: (url: string) => alert(`Navigate to ${url}`),
35
+ },
30
36
  });
31
37
  </script>
32
38
 
@@ -35,10 +41,6 @@
35
41
  name="Primary"
36
42
  args={{
37
43
  paywallData: paywallData,
38
- onPurchaseClicked: fn(),
39
- onBackClicked: fn(),
40
- onNavigateToUrlClicked: fn(),
41
- onRestorePurchasesClicked: fn(),
42
44
  }}
43
45
  />
44
46
 
@@ -47,10 +49,6 @@
47
49
  args={{
48
50
  paywallData: paywallData,
49
51
  selectedLocale: "it_IT",
50
- onPurchaseClicked: fn(),
51
- onBackClicked: fn(),
52
- onNavigateToUrlClicked: fn(),
53
- onRestorePurchasesClicked: fn(),
54
52
  }}
55
53
  />
56
54
 
@@ -59,10 +57,6 @@
59
57
  args={{
60
58
  paywallData: alignmentPaywallData,
61
59
  selectedLocale: "en_US",
62
- onPurchaseClicked: fn(),
63
- onBackClicked: fn(),
64
- onNavigateToUrlClicked: fn(),
65
- onRestorePurchasesClicked: fn(),
66
60
  }}
67
61
  />
68
62
 
@@ -71,10 +65,6 @@
71
65
  args={{
72
66
  paywallData: fontsPaywallData,
73
67
  selectedLocale: "en_US",
74
- onPurchaseClicked: fn(),
75
- onBackClicked: fn(),
76
- onNavigateToUrlClicked: fn(),
77
- onRestorePurchasesClicked: fn(),
78
68
  }}
79
69
  />
80
70
 
@@ -83,10 +73,6 @@
83
73
  args={{
84
74
  paywallData: pastaPaywallData,
85
75
  selectedLocale: "en_US",
86
- onPurchaseClicked: fn(),
87
- onBackClicked: fn(),
88
- onNavigateToUrlClicked: fn(),
89
- onRestorePurchasesClicked: fn(),
90
76
  }}
91
77
  />
92
78
  <Story
@@ -94,10 +80,6 @@
94
80
  args={{
95
81
  paywallData: variablesPastaPaywallData,
96
82
  selectedLocale: "en_US",
97
- onPurchaseClicked: fn(),
98
- onBackClicked: fn(),
99
- onNavigateToUrlClicked: fn(),
100
- onRestorePurchasesClicked: fn(),
101
83
  variablesPerPackage: {
102
84
  trial: {
103
85
  product_name: "This was a variable: Product A",
@@ -123,10 +105,6 @@
123
105
  args={{
124
106
  paywallData: calmPaywallData,
125
107
  selectedLocale: "en_US",
126
- onPurchaseClicked: fn(),
127
- onBackClicked: fn(),
128
- onNavigateToUrlClicked: fn(),
129
- onRestorePurchasesClicked: fn(),
130
108
  }}
131
109
  />
132
110
 
@@ -134,10 +112,6 @@
134
112
  name="Healthy Cat (Gradient)"
135
113
  args={{
136
114
  paywallData: gradientPaywallData,
137
- onPurchaseClicked: fn(),
138
- onBackClicked: fn(),
139
- onNavigateToUrlClicked: fn(),
140
- onRestorePurchasesClicked: fn(),
141
115
  }}
142
116
  />
143
117
 
@@ -145,10 +119,6 @@
145
119
  name="Dynamic state style overrides"
146
120
  args={{
147
121
  paywallData: e2eTestTemplate,
148
- onPurchaseClicked: fn(),
149
- onBackClicked: fn(),
150
- onNavigateToUrlClicked: fn(),
151
- onRestorePurchasesClicked: fn(),
152
122
  }}
153
123
  />
154
124
 
@@ -163,25 +133,26 @@
163
133
  ...e2eTestTemplate.components_config.base,
164
134
  background: {
165
135
  type: "image",
136
+ fit_mode: "fit",
137
+ color_overlay: null,
166
138
  value: {
167
139
  light: {
140
+ width: 1792,
141
+ height: 1024,
142
+ original: "https://assets.pawwalls.com/1005820_1732028636.jpeg",
168
143
  heic: "https://assets.pawwalls.com/1005820_1732028636.heic",
169
144
  heic_low_res:
170
145
  "https://assets.pawwalls.com/1005820_low_res_1732028636.heic",
171
- original: "https://assets.pawwalls.com/1005820_1732028636.jpeg",
172
146
  webp: "https://assets.pawwalls.com/1005820_1732028636.webp",
173
147
  webp_low_res:
174
148
  "https://assets.pawwalls.com/1005820_low_res_1732028636.webp",
175
149
  },
150
+ dark: null,
176
151
  },
177
152
  },
178
153
  },
179
154
  },
180
155
  },
181
- onPurchaseClicked: fn(),
182
- onBackClicked: fn(),
183
- onNavigateToUrlClicked: fn(),
184
- onRestorePurchasesClicked: fn(),
185
156
  }}
186
157
  />
187
158
 
@@ -189,10 +160,6 @@
189
160
  name="Poster Maker"
190
161
  args={{
191
162
  paywallData: posterMakerTemplate,
192
- onPurchaseClicked: fn(),
193
- onBackClicked: fn(),
194
- onNavigateToUrlClicked: fn(),
195
- onRestorePurchasesClicked: fn(),
196
163
  }}
197
164
  />
198
165
 
@@ -200,10 +167,6 @@
200
167
  name="E2E Test with variables"
201
168
  args={{
202
169
  paywallData: e2eTestTemplate,
203
- onPurchaseClicked: fn(),
204
- onBackClicked: fn(),
205
- onNavigateToUrlClicked: fn(),
206
- onRestorePurchasesClicked: fn(),
207
170
  variablesPerPackage: {
208
171
  $rc_annual: {
209
172
  product_name: "Yearly sub",
@@ -273,10 +236,6 @@
273
236
  name="Z Stack"
274
237
  args={{
275
238
  paywallData: zStackTemplate,
276
- onPurchaseClicked: fn(),
277
- onBackClicked: fn(),
278
- onNavigateToUrlClicked: fn(),
279
- onRestorePurchasesClicked: fn(),
280
239
  }}
281
240
  />
282
241
 
@@ -284,10 +243,6 @@
284
243
  name="Color Mode Override"
285
244
  args={{
286
245
  paywallData: colorModeOverrideTemplate,
287
- onPurchaseClicked: fn(),
288
- onBackClicked: fn(),
289
- onNavigateToUrlClicked: fn(),
290
- onRestorePurchasesClicked: fn(),
291
246
  preferredColorMode: "dark",
292
247
  }}
293
248
  />
@@ -296,10 +251,6 @@
296
251
  name="Invalid component type"
297
252
  args={{
298
253
  paywallData: errorPaywallData,
299
- onPurchaseClicked: fn(),
300
- onBackClicked: fn(),
301
- onNavigateToUrlClicked: fn(),
302
- onRestorePurchasesClicked: fn(),
303
254
  preferredColorMode: "dark",
304
255
  onError: (error: unknown) => alert(`Error - ${error}`),
305
256
  }}
@@ -309,10 +260,6 @@
309
260
  name="Fallback Paywall"
310
261
  args={{
311
262
  paywallData: fallbackPaywallData,
312
- onPurchaseClicked: fn(),
313
- onBackClicked: fn(),
314
- onNavigateToUrlClicked: fn(),
315
- onRestorePurchasesClicked: fn(),
316
263
  preferredColorMode: "dark",
317
264
  onError: (error: unknown) => console.error(`Error - ${error}`),
318
265
  }}
@@ -322,9 +269,5 @@
322
269
  name="Sticky Footer"
323
270
  args={{
324
271
  paywallData: paywallWithFooter,
325
- onPurchaseClicked: fn(),
326
- onBackClicked: fn(),
327
- onNavigateToUrlClicked: fn(),
328
- onRestorePurchasesClicked: fn(),
329
272
  }}
330
273
  />