@revenuecat/purchases-ui-js 2.0.2 → 2.0.3

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 (127) hide show
  1. package/dist/components/button/ButtonNode.stories.svelte +66 -102
  2. package/dist/components/button/ButtonNode.svelte +2 -27
  3. package/dist/components/footer/Footer.stories.svelte +112 -102
  4. package/dist/components/footer/Footer.svelte +8 -4
  5. package/dist/components/icon/Icon.stories.svelte +100 -0
  6. package/dist/components/icon/Icon.stories.svelte.d.ts +19 -0
  7. package/dist/components/icon/Icon.svelte +73 -0
  8. package/dist/components/icon/Icon.svelte.d.ts +4 -0
  9. package/dist/components/image/ClipPath.svelte +49 -0
  10. package/dist/components/image/ClipPath.svelte.d.ts +9 -0
  11. package/dist/components/image/Image.stories.svelte +83 -188
  12. package/dist/components/image/Image.svelte +152 -136
  13. package/dist/components/image/Image.svelte.d.ts +1 -1
  14. package/dist/components/image/Overlay.svelte +36 -0
  15. package/dist/components/image/Overlay.svelte.d.ts +8 -0
  16. package/dist/components/package/Package.stories.svelte +10 -21
  17. package/dist/components/package/Package.svelte +8 -35
  18. package/dist/components/paywall/Node.svelte +27 -28
  19. package/dist/components/paywall/Node.svelte.d.ts +3 -6
  20. package/dist/components/paywall/Paywall.stories.svelte +36 -140
  21. package/dist/components/paywall/Paywall.svelte +22 -6
  22. package/dist/components/paywall/Paywall.svelte.d.ts +3 -2
  23. package/dist/components/paywall/fixtures/override-paywall.d.ts +2 -0
  24. package/dist/components/paywall/fixtures/override-paywall.js +1310 -0
  25. package/dist/components/paywall/fixtures/stack-paywall.d.ts +2 -0
  26. package/dist/components/paywall/fixtures/stack-paywall.js +5223 -0
  27. package/dist/components/paywall/fixtures/variables.d.ts +261 -0
  28. package/dist/components/paywall/fixtures/variables.js +262 -0
  29. package/dist/components/purchase-button/PurchaseButton.stories.svelte +10 -21
  30. package/dist/components/purchase-button/PurchaseButton.svelte +2 -27
  31. package/dist/components/stack/Stack.stories.svelte +2354 -978
  32. package/dist/components/stack/Stack.svelte +111 -134
  33. package/dist/components/stack/Stack.svelte.d.ts +6 -2
  34. package/dist/components/stack/stack-utils.d.ts +10 -30
  35. package/dist/components/stack/stack-utils.js +77 -255
  36. package/dist/components/text/Text.svelte +3 -37
  37. package/dist/components/text/Text.svelte.d.ts +1 -2
  38. package/dist/components/text/TextNode.stories.svelte +10 -36
  39. package/dist/components/text/TextNode.svelte +25 -28
  40. package/dist/components/text/TextNode.svelte.d.ts +1 -1
  41. package/dist/components/text/text-utils.d.ts +4 -9
  42. package/dist/components/text/text-utils.js +32 -117
  43. package/dist/components/timeline/Timeline.stories.svelte +640 -251
  44. package/dist/components/timeline/Timeline.svelte +42 -28
  45. package/dist/components/timeline/Timeline.svelte.d.ts +1 -1
  46. package/dist/components/timeline/TimelineItem.svelte +80 -112
  47. package/dist/components/timeline/TimelineItem.svelte.d.ts +6 -2
  48. package/dist/components/timeline/timeline-utils.d.ts +24 -6
  49. package/dist/components/timeline/timeline-utils.js +21 -113
  50. package/dist/data/entities.d.ts +19 -135
  51. package/dist/index.d.ts +2 -1
  52. package/dist/index.js +2 -1
  53. package/dist/stores/color-mode.d.ts +1 -1
  54. package/dist/stores/paywall.d.ts +5 -2
  55. package/dist/stores/selected.d.ts +5 -0
  56. package/dist/stores/selected.js +12 -0
  57. package/dist/stores/variables.d.ts +1 -1
  58. package/dist/stores/variables.js +0 -1
  59. package/dist/stories/component-decorator.d.ts +2 -0
  60. package/dist/stories/component-decorator.js +12 -0
  61. package/dist/stories/fixtures.d.ts +5 -3
  62. package/dist/stories/fixtures.js +5214 -4422
  63. package/dist/stories/paywall-decorator.js +6 -0
  64. package/dist/stories/variables-decorator.d.ts +1 -1
  65. package/dist/stories/viewport-decorator.d.ts +2 -0
  66. package/dist/stories/viewport-decorator.js +8 -0
  67. package/dist/stories/viewport-wrapper.svelte +53 -0
  68. package/dist/stories/viewport-wrapper.svelte.d.ts +10 -0
  69. package/dist/stories/with-layout.d.ts +2 -10
  70. package/dist/stories/with-layout.js +3 -5
  71. package/dist/types/alignment.d.ts +5 -3
  72. package/dist/types/background.d.ts +6 -5
  73. package/dist/types/base.d.ts +7 -0
  74. package/dist/types/base.js +1 -0
  75. package/dist/types/colors.d.ts +4 -4
  76. package/dist/types/component.d.ts +6 -2
  77. package/dist/types/components/button.d.ts +4 -1
  78. package/dist/types/components/footer.d.ts +2 -1
  79. package/dist/types/components/icon.d.ts +28 -0
  80. package/dist/types/components/icon.js +1 -0
  81. package/dist/types/components/image.d.ts +20 -0
  82. package/dist/types/components/image.js +1 -0
  83. package/dist/types/components/package.d.ts +2 -1
  84. package/dist/types/components/purchase-button.d.ts +2 -1
  85. package/dist/types/components/stack.d.ts +32 -0
  86. package/dist/types/components/stack.js +1 -0
  87. package/dist/types/components/text.d.ts +20 -0
  88. package/dist/types/components/text.js +1 -0
  89. package/dist/types/components/timeline.d.ts +35 -0
  90. package/dist/types/components/timeline.js +1 -0
  91. package/dist/types/localization.d.ts +2 -1
  92. package/dist/types/media.d.ts +4 -3
  93. package/dist/types/overrides.d.ts +48 -0
  94. package/dist/types/overrides.js +1 -0
  95. package/dist/types/variables.d.ts +13 -0
  96. package/dist/types/variables.js +10 -0
  97. package/dist/types.d.ts +17 -9
  98. package/dist/ui/atoms/typography.stories.svelte +1 -27
  99. package/dist/ui/molecules/button.stories.svelte +3 -8
  100. package/dist/ui/theme/colors.d.ts +0 -6
  101. package/dist/ui/theme/colors.js +1 -1
  102. package/dist/ui/theme/text.d.ts +3 -4
  103. package/dist/ui/theme/utils.d.ts +0 -10
  104. package/dist/ui/theme/utils.js +5 -5
  105. package/dist/utils/background-utils.d.ts +4 -0
  106. package/dist/utils/background-utils.js +39 -0
  107. package/dist/utils/base-utils.d.ts +18 -0
  108. package/dist/utils/base-utils.js +124 -0
  109. package/dist/utils/constants.d.ts +2 -2
  110. package/dist/utils/constants.js +6 -1
  111. package/dist/utils/font-utils.d.ts +4 -0
  112. package/dist/utils/font-utils.js +47 -0
  113. package/dist/utils/style-utils.d.ts +7 -120
  114. package/dist/utils/style-utils.js +22 -302
  115. package/dist/utils/variable-utils.d.ts +1 -22
  116. package/dist/utils/variable-utils.js +28 -24
  117. package/dist/web-components/index.css +1 -1
  118. package/dist/web-components/index.js +1323 -895
  119. package/package.json +34 -24
  120. package/dist/components/button/button-utils.d.ts +0 -2
  121. package/dist/components/button/button-utils.js +0 -19
  122. package/dist/components/image/image-utils.d.ts +0 -19
  123. package/dist/components/image/image-utils.js +0 -33
  124. package/dist/components/purchase-button/purchase-button-utils.d.ts +0 -2
  125. package/dist/components/purchase-button/purchase-button-utils.js +0 -20
  126. package/dist/stories/meta-templates.d.ts +0 -12
  127. package/dist/stories/meta-templates.js +0 -155
@@ -6,25 +6,26 @@
6
6
  alignmentPaywallData,
7
7
  calmPaywallData,
8
8
  colorModeOverrideTemplate,
9
- e2eTestTemplate,
10
9
  errorPaywallData,
11
10
  fallbackPaywallData,
12
11
  fontsPaywallData,
13
12
  gradientPaywallData,
13
+ listTemplate,
14
14
  pastaPaywallData,
15
15
  paywallData,
16
16
  paywallWithFooter,
17
17
  posterMakerTemplate,
18
- variablesPastaPaywallData,
18
+ timelineTemplate,
19
+ uiConfigData,
19
20
  zStackTemplate,
20
21
  } from "../../stories/fixtures";
21
- import type { VariableDictionary } from "../../utils/variable-utils";
22
+ import { OVERRIDE_PAYWALL } from "./fixtures/override-paywall";
23
+ import { STACK_PAYWALL } from "./fixtures/stack-paywall";
24
+ import { VARIABLES } from "./fixtures/variables";
22
25
 
23
26
  const { Story } = defineMeta({
24
27
  title: "Example/Paywall",
25
28
  component: Paywall,
26
- tags: ["autodocs"],
27
- argTypes: {},
28
29
  args: {
29
30
  onPurchaseClicked: (selectedPackageId: string) =>
30
31
  alert(`Purchase package ${selectedPackageId}`),
@@ -32,11 +33,26 @@
32
33
  onVisitCustomerCenterClicked: () => alert("Visit customer center"),
33
34
  onRestorePurchasesClicked: () => alert("Restore purchases"),
34
35
  onNavigateToUrlClicked: (url: string) => alert(`Navigate to ${url}`),
36
+ uiConfig: uiConfigData,
37
+ variablesPerPackage: VARIABLES,
35
38
  },
36
39
  });
37
40
  </script>
38
41
 
39
- <!-- Default story -->
42
+ <Story
43
+ name="Stack paywall"
44
+ args={{
45
+ paywallData: STACK_PAYWALL,
46
+ }}
47
+ />
48
+
49
+ <Story
50
+ name="Override paywall"
51
+ args={{
52
+ paywallData: OVERRIDE_PAYWALL,
53
+ }}
54
+ />
55
+
40
56
  <Story
41
57
  name="Primary"
42
58
  args={{
@@ -75,30 +91,6 @@
75
91
  selectedLocale: "en_US",
76
92
  }}
77
93
  />
78
- <Story
79
- name="Pasta paywall example(with variables)"
80
- args={{
81
- paywallData: variablesPastaPaywallData,
82
- selectedLocale: "en_US",
83
- variablesPerPackage: {
84
- trial: {
85
- product_name: "This was a variable: Product A",
86
- price: "$19.99",
87
- price_per_period: "$19.99/yr",
88
- } as VariableDictionary,
89
- $rc_weekly: {
90
- product_name: "This was a variable: Product B",
91
- price: "$29.99",
92
- price_per_period: "$29.99/yr",
93
- } as VariableDictionary,
94
- $rc_daily: {
95
- product_name: "This was a variable: Product C",
96
- price: "$39.99",
97
- price_per_period: "$19.99/yr",
98
- } as VariableDictionary,
99
- },
100
- }}
101
- />
102
94
 
103
95
  <Story
104
96
  name="Calm paywall example"
@@ -115,47 +107,6 @@
115
107
  }}
116
108
  />
117
109
 
118
- <Story
119
- name="Dynamic state style overrides"
120
- args={{
121
- paywallData: e2eTestTemplate,
122
- }}
123
- />
124
-
125
- <Story
126
- name="Dynamic state style overrides with background image"
127
- args={{
128
- paywallData: {
129
- ...e2eTestTemplate,
130
- components_config: {
131
- ...e2eTestTemplate.components_config,
132
- base: {
133
- ...e2eTestTemplate.components_config.base,
134
- background: {
135
- type: "image",
136
- fit_mode: "fit",
137
- color_overlay: null,
138
- value: {
139
- light: {
140
- width: 1792,
141
- height: 1024,
142
- original: "https://assets.pawwalls.com/1005820_1732028636.jpeg",
143
- heic: "https://assets.pawwalls.com/1005820_1732028636.heic",
144
- heic_low_res:
145
- "https://assets.pawwalls.com/1005820_low_res_1732028636.heic",
146
- webp: "https://assets.pawwalls.com/1005820_1732028636.webp",
147
- webp_low_res:
148
- "https://assets.pawwalls.com/1005820_low_res_1732028636.webp",
149
- },
150
- dark: null,
151
- },
152
- },
153
- },
154
- },
155
- },
156
- }}
157
- />
158
-
159
110
  <Story
160
111
  name="Poster Maker"
161
112
  args={{
@@ -163,75 +114,6 @@
163
114
  }}
164
115
  />
165
116
 
166
- <Story
167
- name="E2E Test with variables"
168
- args={{
169
- paywallData: e2eTestTemplate,
170
- variablesPerPackage: {
171
- $rc_annual: {
172
- product_name: "Yearly sub",
173
- price: "$19.99",
174
- price_per_period: "$19.99/1yr",
175
- price_per_period_full: "$19.99/1year",
176
- total_price_and_per_month: "$19.99/1yr($1.67/mo)",
177
- total_price_and_per_month_full: "$19.99/1year($1.67/month)",
178
- sub_price_per_month: "$1.67",
179
- sub_price_per_week: "$0.42",
180
- sub_duration: "1 year",
181
- sub_duration_in_months: "12 months",
182
- sub_period: "yearly",
183
- sub_period_length: "year",
184
- sub_period_abbreviated: "yr",
185
- sub_relative_discount: "33% off",
186
- sub_offer_duration: "undefined",
187
- sub_offer_duration_2: "undefined",
188
- sub_offer_price: "undefined",
189
- sub_offer_price_2: "undefined",
190
- },
191
- $rc_monthly: {
192
- product_name: "Monthly sub",
193
- price: "$30.00",
194
- price_per_period: "$30.00/1mo",
195
- price_per_period_full: "$30.00/1month",
196
- total_price_and_per_month: "$30.00",
197
- total_price_and_per_month_full: "$30.00",
198
- sub_price_per_month: "$30.00",
199
- sub_price_per_week: "$30.00",
200
- sub_duration: "1 month",
201
- sub_duration_in_months: "1 month",
202
- sub_period: "monthly",
203
- sub_period_length: "month",
204
- sub_period_abbreviated: "mo",
205
- sub_relative_discount: "",
206
- sub_offer_duration: "undefined",
207
- sub_offer_duration_2: "undefined",
208
- sub_offer_price: "undefined",
209
- sub_offer_price_2: "undefined",
210
- },
211
- $rc_weekly: {
212
- product_name: "Weekly no trial",
213
- price: "$1.25",
214
- price_per_period: "$1.25/1wk",
215
- price_per_period_full: "$1.25/1week",
216
- total_price_and_per_month: "$1.25/1wk($5.00/mo)",
217
- total_price_and_per_month_full: "$1.25/1week($5.00/month)",
218
- sub_price_per_month: "$5.00",
219
- sub_price_per_week: "$1.25",
220
- sub_duration: "1 week",
221
- sub_duration_in_months: "1 week",
222
- sub_period: "weekly",
223
- sub_period_length: "week",
224
- sub_period_abbreviated: "wk",
225
- sub_relative_discount: "96% off",
226
- sub_offer_duration: "undefined",
227
- sub_offer_duration_2: "undefined",
228
- sub_offer_price: "undefined",
229
- sub_offer_price_2: "undefined",
230
- },
231
- },
232
- }}
233
- />
234
-
235
117
  <Story
236
118
  name="Z Stack"
237
119
  args={{
@@ -271,3 +153,17 @@
271
153
  paywallData: paywallWithFooter,
272
154
  }}
273
155
  />
156
+
157
+ <Story
158
+ name="Timeline"
159
+ args={{
160
+ paywallData: timelineTemplate,
161
+ }}
162
+ />
163
+
164
+ <Story
165
+ name="List"
166
+ args={{
167
+ paywallData: listTemplate,
168
+ }}
169
+ />
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { PaywallData, StackProps } from "../../data/entities";
2
+ import type { PaywallData, UIConfig } from "../../data/entities";
3
3
 
4
4
  import Footer from "../footer/Footer.svelte";
5
5
  import Node from "./Node.svelte";
@@ -17,13 +17,16 @@
17
17
  import type { ColorMode } from "../../types";
18
18
  import type { Action } from "../../types/components/button";
19
19
  import { findSelectedPackageId } from "../../utils/style-utils";
20
- import { type VariableDictionary } from "../../utils/variable-utils";
20
+ import { registerFonts } from "../../utils/font-utils";
21
21
  import { derived, readable, writable } from "svelte/store";
22
+ import { onMount } from "svelte";
23
+ import type { VariableDictionary } from "../../types/variables";
22
24
 
23
25
  interface Props {
24
26
  paywallData: PaywallData;
25
27
  selectedLocale?: string;
26
28
  variablesPerPackage?: Record<string, VariableDictionary>;
29
+ uiConfig: UIConfig;
27
30
  preferredColorMode?: ColorMode;
28
31
  onPurchaseClicked?: (selectedPackageId: string) => void;
29
32
  onBackClicked?: () => void;
@@ -44,6 +47,7 @@
44
47
  onRestorePurchasesClicked,
45
48
  onNavigateToUrlClicked,
46
49
  onError,
50
+ uiConfig,
47
51
  }: Props = $props();
48
52
 
49
53
  const getColorMode = setColorModeContext(() => preferredColorMode);
@@ -101,6 +105,7 @@
101
105
  variablesPerPackage: readable(variablesPerPackage),
102
106
  onPurchase,
103
107
  onButtonAction,
108
+ uiConfig,
104
109
  });
105
110
 
106
111
  const variables: VariablesStore = derived(
@@ -119,6 +124,10 @@
119
124
  const backgroundImgSource = $derived(
120
125
  getBackgroundImageSource(paywallData, colorMode),
121
126
  );
127
+
128
+ onMount(() => {
129
+ registerFonts(uiConfig);
130
+ });
122
131
  </script>
123
132
 
124
133
  <svelte:boundary onerror={onError}>
@@ -128,8 +137,7 @@
128
137
  {#if paywallData.components_config.base.sticky_footer}
129
138
  <Footer
130
139
  {...paywallData.components_config.base.sticky_footer}
131
- stack={paywallData.components_config.base.sticky_footer
132
- .stack as StackProps}
140
+ stack={paywallData.components_config.base.sticky_footer.stack}
133
141
  />
134
142
  {/if}
135
143
  {#if paywallData.components_config.base.background?.type === "color"}
@@ -145,8 +153,16 @@
145
153
  <style>
146
154
  .rc-pw-paywall {
147
155
  position: relative;
148
- display: block;
149
- max-height: 100%;
156
+ display: flex;
157
+ flex-direction: column;
158
+ align-items: stretch;
159
+ height: 100%;
160
+ overflow: hidden;
161
+
162
+ & > :global(*:first-child) {
163
+ flex-grow: 1;
164
+ overflow-y: auto;
165
+ }
150
166
  }
151
167
 
152
168
  .rc-pw-paywall-background {
@@ -1,10 +1,11 @@
1
- import type { PaywallData } from "../../data/entities";
1
+ import type { PaywallData, UIConfig } from "../../data/entities";
2
2
  import type { ColorMode } from "../../types";
3
- import { type VariableDictionary } from "../../utils/variable-utils";
3
+ import type { VariableDictionary } from "../../types/variables";
4
4
  interface Props {
5
5
  paywallData: PaywallData;
6
6
  selectedLocale?: string;
7
7
  variablesPerPackage?: Record<string, VariableDictionary>;
8
+ uiConfig: UIConfig;
8
9
  preferredColorMode?: ColorMode;
9
10
  onPurchaseClicked?: (selectedPackageId: string) => void;
10
11
  onBackClicked?: () => void;
@@ -0,0 +1,2 @@
1
+ import type { PaywallData } from "../../../data/entities";
2
+ export declare const OVERRIDE_PAYWALL: PaywallData;