@revenuecat/purchases-ui-js 2.0.1 → 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.
- package/dist/components/button/ButtonNode.stories.svelte +66 -108
- package/dist/components/button/ButtonNode.svelte +3 -31
- package/dist/components/footer/Footer.stories.svelte +112 -106
- package/dist/components/footer/Footer.svelte +10 -6
- package/dist/components/icon/Icon.stories.svelte +100 -0
- package/dist/components/icon/Icon.stories.svelte.d.ts +19 -0
- package/dist/components/icon/Icon.svelte +73 -0
- package/dist/components/icon/Icon.svelte.d.ts +4 -0
- package/dist/components/image/ClipPath.svelte +49 -0
- package/dist/components/image/ClipPath.svelte.d.ts +9 -0
- package/dist/components/image/Image.stories.svelte +83 -199
- package/dist/components/image/Image.svelte +152 -137
- package/dist/components/image/Image.svelte.d.ts +1 -1
- package/dist/components/image/Overlay.svelte +36 -0
- package/dist/components/image/Overlay.svelte.d.ts +8 -0
- package/dist/components/package/Package.stories.svelte +12 -27
- package/dist/components/package/Package.svelte +10 -44
- package/dist/components/paywall/Node.svelte +45 -43
- package/dist/components/paywall/Node.svelte.d.ts +10 -12
- package/dist/components/paywall/Paywall.stories.svelte +36 -140
- package/dist/components/paywall/Paywall.svelte +38 -20
- package/dist/components/paywall/Paywall.svelte.d.ts +3 -2
- package/dist/components/paywall/fixtures/override-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/override-paywall.js +1310 -0
- package/dist/components/paywall/fixtures/stack-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/stack-paywall.js +5223 -0
- package/dist/components/paywall/fixtures/variables.d.ts +261 -0
- package/dist/components/paywall/fixtures/variables.js +262 -0
- package/dist/components/purchase-button/PurchaseButton.stories.svelte +10 -29
- package/dist/components/purchase-button/PurchaseButton.svelte +2 -34
- package/dist/components/stack/Stack.stories.svelte +2364 -1020
- package/dist/components/stack/Stack.svelte +108 -151
- package/dist/components/stack/Stack.svelte.d.ts +6 -2
- package/dist/components/stack/stack-utils.d.ts +10 -30
- package/dist/components/stack/stack-utils.js +77 -257
- package/dist/components/text/Text.svelte +3 -37
- package/dist/components/text/Text.svelte.d.ts +1 -2
- package/dist/components/text/TextNode.stories.svelte +10 -48
- package/dist/components/text/TextNode.svelte +25 -37
- package/dist/components/text/TextNode.svelte.d.ts +1 -1
- package/dist/components/text/text-utils.d.ts +4 -9
- package/dist/components/text/text-utils.js +32 -117
- package/dist/components/timeline/Timeline.stories.svelte +640 -256
- package/dist/components/timeline/Timeline.svelte +42 -30
- package/dist/components/timeline/Timeline.svelte.d.ts +1 -1
- package/dist/components/timeline/TimelineItem.svelte +80 -112
- package/dist/components/timeline/TimelineItem.svelte.d.ts +6 -2
- package/dist/components/timeline/timeline-utils.d.ts +24 -6
- package/dist/components/timeline/timeline-utils.js +21 -114
- package/dist/data/entities.d.ts +23 -169
- package/dist/index.d.ts +11 -10
- package/dist/index.js +11 -10
- package/dist/stores/color-mode.d.ts +1 -1
- package/dist/stores/localization.d.ts +1 -1
- package/dist/stores/localization.js +3 -2
- package/dist/stores/paywall.d.ts +7 -3
- package/dist/stores/selected.d.ts +5 -0
- package/dist/stores/selected.js +12 -0
- package/dist/stores/variables.d.ts +2 -3
- package/dist/stores/variables.js +0 -1
- package/dist/stories/component-decorator.d.ts +2 -0
- package/dist/stories/component-decorator.js +12 -0
- package/dist/stories/fixtures.d.ts +6 -4
- package/dist/stories/fixtures.js +6241 -5485
- package/dist/stories/localization-decorator.js +1 -1
- package/dist/stories/paywall-decorator.js +8 -1
- package/dist/stories/variables-decorator.d.ts +1 -1
- package/dist/stories/viewport-decorator.d.ts +2 -0
- package/dist/stories/viewport-decorator.js +8 -0
- package/dist/stories/viewport-wrapper.svelte +53 -0
- package/dist/stories/viewport-wrapper.svelte.d.ts +10 -0
- package/dist/stories/with-layout.d.ts +2 -10
- package/dist/stories/with-layout.js +3 -5
- package/dist/stories/with-layout.svelte +3 -3
- package/dist/types/alignment.d.ts +5 -3
- package/dist/types/background.d.ts +6 -5
- package/dist/types/base.d.ts +7 -0
- package/dist/types/colors.d.ts +4 -4
- package/dist/types/component.d.ts +10 -0
- package/dist/types/component.js +1 -0
- package/dist/types/components/button.d.ts +5 -2
- package/dist/types/components/footer.d.ts +3 -2
- package/dist/types/components/icon.d.ts +28 -0
- package/dist/types/components/icon.js +1 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/image.js +1 -0
- package/dist/types/components/package.d.ts +3 -2
- package/dist/types/components/purchase-button.d.ts +3 -2
- package/dist/types/components/stack.d.ts +32 -0
- package/dist/types/components/stack.js +1 -0
- package/dist/types/components/text.d.ts +20 -0
- package/dist/types/components/text.js +1 -0
- package/dist/types/components/timeline.d.ts +35 -0
- package/dist/types/components/timeline.js +1 -0
- package/dist/types/localization.d.ts +2 -1
- package/dist/types/media.d.ts +4 -3
- package/dist/types/overrides.d.ts +48 -0
- package/dist/types/overrides.js +1 -0
- package/dist/types/variables.d.ts +13 -0
- package/dist/types/variables.js +10 -0
- package/dist/types.d.ts +17 -9
- package/dist/ui/atoms/typography.stories.svelte +3 -29
- package/dist/ui/atoms/typography.stories.svelte.d.ts +1 -1
- package/dist/ui/layout/main-block.svelte +2 -2
- package/dist/ui/molecules/button.stories.svelte +5 -10
- package/dist/ui/molecules/button.svelte +1 -1
- package/dist/ui/theme/colors.d.ts +0 -6
- package/dist/ui/theme/colors.js +1 -1
- package/dist/ui/theme/text.d.ts +3 -4
- package/dist/ui/theme/theme.d.ts +2 -2
- package/dist/ui/theme/theme.js +2 -2
- package/dist/ui/theme/utils.d.ts +2 -12
- package/dist/ui/theme/utils.js +5 -5
- package/dist/utils/background-utils.d.ts +4 -0
- package/dist/utils/background-utils.js +39 -0
- package/dist/utils/base-utils.d.ts +18 -0
- package/dist/utils/base-utils.js +124 -0
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +6 -1
- package/dist/utils/font-utils.d.ts +4 -0
- package/dist/utils/font-utils.js +47 -0
- package/dist/utils/style-utils.d.ts +7 -120
- package/dist/utils/style-utils.js +35 -314
- package/dist/utils/variable-utils.d.ts +1 -22
- package/dist/utils/variable-utils.js +28 -24
- package/dist/web-components/index.css +1 -1
- package/dist/web-components/index.js +1415 -987
- package/package.json +34 -24
- package/dist/components/button/button-utils.d.ts +0 -2
- package/dist/components/button/button-utils.js +0 -19
- package/dist/components/image/image-utils.d.ts +0 -19
- package/dist/components/image/image-utils.js +0 -33
- package/dist/components/purchase-button/purchase-button-utils.d.ts +0 -2
- package/dist/components/purchase-button/purchase-button-utils.js +0 -20
- package/dist/data/state.d.ts +0 -4
- package/dist/stories/meta-templates.d.ts +0 -12
- package/dist/stories/meta-templates.js +0 -155
- /package/dist/{data/state.js → types/base.js} +0 -0
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
1
2
|
import { Footer, Image, Package, PurchaseButton, Stack, Timeline } from "../..";
|
|
2
3
|
import ButtonNode from "../button/ButtonNode.svelte";
|
|
3
|
-
import type { ZStackChildStyles } from "../stack/stack-utils";
|
|
4
4
|
import TextNode from "../text/TextNode.svelte";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
type SupportedComponents =
|
|
8
|
-
interface Props
|
|
9
|
-
nodeData:
|
|
10
|
-
zStackChildStyles?: ZStackChildStyles;
|
|
11
|
-
componentState?: ComponentState;
|
|
5
|
+
import type { Component } from "../../types/component";
|
|
6
|
+
import Icon from "../icon/Icon.svelte";
|
|
7
|
+
type SupportedComponents = ButtonNode | Footer | Icon | Image | Package | PurchaseButton | Stack | TextNode | Timeline;
|
|
8
|
+
interface Props {
|
|
9
|
+
nodeData: Component;
|
|
12
10
|
}
|
|
13
|
-
declare const Node: Component<Props, {
|
|
11
|
+
declare const Node: import("svelte").Component<Props, {
|
|
14
12
|
/**
|
|
15
13
|
* This function returns the component class and the node data for a given paywall component.
|
|
16
14
|
* It first checks if the component type is supported and returns the corresponding component class.
|
|
17
15
|
* If not supported, it checks if the fallback component type is supported and returns the corresponding component class,
|
|
18
16
|
* finally it throws an error if the component type is not supported and the fallback component type is not supported.
|
|
19
|
-
* @param nodeData:
|
|
20
|
-
* @returns [Component<SupportedComponents>,
|
|
17
|
+
* @param nodeData:Component - the Component object representing a Node in the paywall
|
|
18
|
+
* @returns [Component<SupportedComponents>, Component] - a tuple containing the component class and the node data
|
|
21
19
|
* @throws Error - if the component type and the fallback component type are not supported
|
|
22
|
-
*/ getComponentClass: (nodeData:
|
|
20
|
+
*/ getComponentClass: (nodeData: Component) => [SvelteComponent<SupportedComponents>, Component] | undefined;
|
|
23
21
|
}, "">;
|
|
24
22
|
type Node = ReturnType<typeof Node>;
|
|
25
23
|
export default Node;
|
|
@@ -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
|
-
|
|
18
|
+
timelineTemplate,
|
|
19
|
+
uiConfigData,
|
|
19
20
|
zStackTemplate,
|
|
20
21
|
} from "../../stories/fixtures";
|
|
21
|
-
import
|
|
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
|
-
|
|
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,
|
|
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";
|
|
@@ -7,21 +7,26 @@
|
|
|
7
7
|
getBackgroundImageSource,
|
|
8
8
|
getBackgroundStyles,
|
|
9
9
|
} from "./paywall-utils";
|
|
10
|
-
import type { PurchaseState } from "../../data/state";
|
|
11
10
|
import { setColorModeContext } from "../../stores/color-mode";
|
|
12
11
|
import { setLocalizationContext } from "../../stores/localization";
|
|
13
12
|
import { setPaywallContext } from "../../stores/paywall";
|
|
14
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
setVariablesContext,
|
|
15
|
+
type VariablesStore,
|
|
16
|
+
} from "../../stores/variables";
|
|
15
17
|
import type { ColorMode } from "../../types";
|
|
16
18
|
import type { Action } from "../../types/components/button";
|
|
17
19
|
import { findSelectedPackageId } from "../../utils/style-utils";
|
|
18
|
-
import {
|
|
19
|
-
import { derived, writable } from "svelte/store";
|
|
20
|
+
import { registerFonts } from "../../utils/font-utils";
|
|
21
|
+
import { derived, readable, writable } from "svelte/store";
|
|
22
|
+
import { onMount } from "svelte";
|
|
23
|
+
import type { VariableDictionary } from "../../types/variables";
|
|
20
24
|
|
|
21
25
|
interface Props {
|
|
22
26
|
paywallData: PaywallData;
|
|
23
27
|
selectedLocale?: string;
|
|
24
28
|
variablesPerPackage?: Record<string, VariableDictionary>;
|
|
29
|
+
uiConfig: UIConfig;
|
|
25
30
|
preferredColorMode?: ColorMode;
|
|
26
31
|
onPurchaseClicked?: (selectedPackageId: string) => void;
|
|
27
32
|
onBackClicked?: () => void;
|
|
@@ -42,20 +47,17 @@
|
|
|
42
47
|
onRestorePurchasesClicked,
|
|
43
48
|
onNavigateToUrlClicked,
|
|
44
49
|
onError,
|
|
50
|
+
uiConfig,
|
|
45
51
|
}: Props = $props();
|
|
46
52
|
|
|
47
53
|
const getColorMode = setColorModeContext(() => preferredColorMode);
|
|
48
54
|
const colorMode = $derived(getColorMode());
|
|
49
55
|
|
|
50
|
-
const { getLocalizedString } = setLocalizationContext({
|
|
56
|
+
const { getLocalizedString } = setLocalizationContext(() => ({
|
|
51
57
|
defaultLocale: paywallData.default_locale,
|
|
52
58
|
selectedLocale,
|
|
53
59
|
localizations: paywallData.components_localizations!,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
let purchaseState = $state({
|
|
57
|
-
variablesPerPackage,
|
|
58
|
-
} satisfies PurchaseState);
|
|
60
|
+
}));
|
|
59
61
|
|
|
60
62
|
const selectedPackageId = writable<string | undefined>(
|
|
61
63
|
findSelectedPackageId(paywallData),
|
|
@@ -98,11 +100,17 @@
|
|
|
98
100
|
}
|
|
99
101
|
};
|
|
100
102
|
|
|
101
|
-
setPaywallContext({
|
|
103
|
+
setPaywallContext({
|
|
104
|
+
selectedPackageId,
|
|
105
|
+
variablesPerPackage: readable(variablesPerPackage),
|
|
106
|
+
onPurchase,
|
|
107
|
+
onButtonAction,
|
|
108
|
+
uiConfig,
|
|
109
|
+
});
|
|
102
110
|
|
|
103
|
-
const variables = derived(
|
|
111
|
+
const variables: VariablesStore = derived(
|
|
104
112
|
selectedPackageId,
|
|
105
|
-
(packageId) => variablesPerPackage[packageId || ""]
|
|
113
|
+
(packageId) => variablesPerPackage[packageId || ""],
|
|
106
114
|
);
|
|
107
115
|
|
|
108
116
|
setVariablesContext(variables);
|
|
@@ -116,18 +124,20 @@
|
|
|
116
124
|
const backgroundImgSource = $derived(
|
|
117
125
|
getBackgroundImageSource(paywallData, colorMode),
|
|
118
126
|
);
|
|
127
|
+
|
|
128
|
+
onMount(() => {
|
|
129
|
+
registerFonts(uiConfig);
|
|
130
|
+
});
|
|
119
131
|
</script>
|
|
120
132
|
|
|
121
133
|
<svelte:boundary onerror={onError}>
|
|
122
134
|
<div class="rc-pw-paywall">
|
|
123
|
-
<Node nodeData={paywallData.components_config.base.stack}
|
|
135
|
+
<Node nodeData={paywallData.components_config.base.stack} />
|
|
124
136
|
|
|
125
137
|
{#if paywallData.components_config.base.sticky_footer}
|
|
126
138
|
<Footer
|
|
127
139
|
{...paywallData.components_config.base.sticky_footer}
|
|
128
|
-
stack={paywallData.components_config.base.sticky_footer
|
|
129
|
-
.stack as StackProps}
|
|
130
|
-
{purchaseState}
|
|
140
|
+
stack={paywallData.components_config.base.sticky_footer.stack}
|
|
131
141
|
/>
|
|
132
142
|
{/if}
|
|
133
143
|
{#if paywallData.components_config.base.background?.type === "color"}
|
|
@@ -143,8 +153,16 @@
|
|
|
143
153
|
<style>
|
|
144
154
|
.rc-pw-paywall {
|
|
145
155
|
position: relative;
|
|
146
|
-
display:
|
|
147
|
-
|
|
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
|
+
}
|
|
148
166
|
}
|
|
149
167
|
|
|
150
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 {
|
|
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;
|