@revenuecat/purchases-ui-js 0.0.18 → 0.0.19
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/footer/Footer.svelte +9 -3
- package/dist/components/paywall/Node.svelte +3 -0
- package/dist/components/paywall/Node.svelte.d.ts +2 -1
- package/dist/components/paywall/Paywall.stories.svelte +66 -5
- package/dist/components/paywall/Paywall.svelte +1 -1
- package/dist/components/purchase-button/PurchaseButton.stories.svelte +6 -0
- package/dist/components/stack/Stack.svelte +2 -0
- package/dist/components/stack/stack-utils.d.ts +1 -1
- package/dist/components/stack/stack-utils.js +3 -3
- package/dist/components/text/text-utils.js +3 -3
- package/dist/data/entities.d.ts +8 -9
- package/dist/stories/fixtures.d.ts +1 -1
- package/dist/stories/fixtures.js +5961 -5434
- package/dist/utils/style-utils.d.ts +6 -4
- package/dist/utils/style-utils.js +6 -6
- package/package.json +1 -1
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
import type { FooterProps } from "../../data/entities";
|
|
3
3
|
import Stack from "../stack/Stack.svelte";
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
|
|
5
|
+
const {
|
|
6
|
+
stack,
|
|
7
|
+
id,
|
|
8
|
+
labels,
|
|
9
|
+
purchaseState,
|
|
10
|
+
variableDictionary,
|
|
11
|
+
onAction,
|
|
12
|
+
}: FooterProps = $props();
|
|
7
13
|
</script>
|
|
8
14
|
|
|
9
15
|
<div class="rc-pw-footer" {id}>
|
|
10
|
-
<Stack {...stack} {labels} {purchaseState} {variableDictionary} />
|
|
16
|
+
<Stack {...stack} {labels} {purchaseState} {variableDictionary} {onAction} />
|
|
11
17
|
</div>
|
|
12
18
|
|
|
13
19
|
<style>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
type ActionsProps,
|
|
5
5
|
type ComponentLocalizations,
|
|
6
|
+
type ComponentState,
|
|
6
7
|
type Extra,
|
|
7
8
|
type PaywallComponent,
|
|
8
9
|
type PurchaseStateProps,
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
onAction?: (action: SupportedActions, data?: Extra) => void;
|
|
40
41
|
variableDictionary?: VariableDictionary;
|
|
41
42
|
zStackChildStyles?: ZStackChildStyles;
|
|
43
|
+
componentState?: ComponentState;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
const ComponentTypes = {
|
|
@@ -116,6 +118,7 @@
|
|
|
116
118
|
{onAction}
|
|
117
119
|
{purchaseState}
|
|
118
120
|
{variableDictionary}
|
|
121
|
+
{...restProps}
|
|
119
122
|
/>
|
|
120
123
|
{/each}
|
|
121
124
|
</ComponentToRender>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionsProps, type ComponentLocalizations, type Extra, type PaywallComponent, type PurchaseStateProps, type SupportedActions } from "../../data/entities";
|
|
1
|
+
import { type ActionsProps, type ComponentLocalizations, type ComponentState, type Extra, type PaywallComponent, type PurchaseStateProps, type SupportedActions } from "../../data/entities";
|
|
2
2
|
import type { VariableDictionary } from "../../utils/variable-utils";
|
|
3
3
|
import type { ZStackChildStyles } from "../stack/stack-utils";
|
|
4
4
|
import TextNode from "../text/TextNode.svelte";
|
|
@@ -12,6 +12,7 @@ interface Props extends ActionsProps, PurchaseStateProps {
|
|
|
12
12
|
onAction?: (action: SupportedActions, data?: Extra) => void;
|
|
13
13
|
variableDictionary?: VariableDictionary;
|
|
14
14
|
zStackChildStyles?: ZStackChildStyles;
|
|
15
|
+
componentState?: ComponentState;
|
|
15
16
|
}
|
|
16
17
|
declare const Node: Component<Props, {
|
|
17
18
|
/**
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
paywallData,
|
|
11
11
|
gradientPaywallData,
|
|
12
12
|
variablesPastaPaywallData,
|
|
13
|
-
stateTemplate,
|
|
14
13
|
posterMakerTemplate,
|
|
15
14
|
e2eTestTemplate,
|
|
16
15
|
zStackTemplate,
|
|
@@ -145,7 +144,7 @@
|
|
|
145
144
|
<Story
|
|
146
145
|
name="Dynamic state style overrides"
|
|
147
146
|
args={{
|
|
148
|
-
paywallData:
|
|
147
|
+
paywallData: e2eTestTemplate,
|
|
149
148
|
onPurchaseClicked: fn(),
|
|
150
149
|
onBackClicked: fn(),
|
|
151
150
|
onNavigateToUrlClicked: fn(),
|
|
@@ -157,11 +156,11 @@
|
|
|
157
156
|
name="Dynamic state style overrides with background image"
|
|
158
157
|
args={{
|
|
159
158
|
paywallData: {
|
|
160
|
-
...
|
|
159
|
+
...e2eTestTemplate,
|
|
161
160
|
components_config: {
|
|
162
|
-
...
|
|
161
|
+
...e2eTestTemplate.components_config,
|
|
163
162
|
base: {
|
|
164
|
-
...
|
|
163
|
+
...e2eTestTemplate.components_config.base,
|
|
165
164
|
background: {
|
|
166
165
|
type: "image",
|
|
167
166
|
value: {
|
|
@@ -205,6 +204,68 @@
|
|
|
205
204
|
onBackClicked: fn(),
|
|
206
205
|
onNavigateToUrlClicked: fn(),
|
|
207
206
|
onRestorePurchasesClicked: fn(),
|
|
207
|
+
variablesPerPackage: {
|
|
208
|
+
$rc_annual: {
|
|
209
|
+
product_name: "Yearly sub",
|
|
210
|
+
price: "$19.99",
|
|
211
|
+
price_per_period: "$19.99/1yr",
|
|
212
|
+
price_per_period_full: "$19.99/1year",
|
|
213
|
+
total_price_and_per_month: "$19.99/1yr($1.67/mo)",
|
|
214
|
+
total_price_and_per_month_full: "$19.99/1year($1.67/month)",
|
|
215
|
+
sub_price_per_month: "$1.67",
|
|
216
|
+
sub_price_per_week: "$0.42",
|
|
217
|
+
sub_duration: "1 year",
|
|
218
|
+
sub_duration_in_months: "12 months",
|
|
219
|
+
sub_period: "yearly",
|
|
220
|
+
sub_period_length: "year",
|
|
221
|
+
sub_period_abbreviated: "yr",
|
|
222
|
+
sub_relative_discount: "33% off",
|
|
223
|
+
sub_offer_duration: "undefined",
|
|
224
|
+
sub_offer_duration_2: "undefined",
|
|
225
|
+
sub_offer_price: "undefined",
|
|
226
|
+
sub_offer_price_2: "undefined",
|
|
227
|
+
},
|
|
228
|
+
$rc_monthly: {
|
|
229
|
+
product_name: "Monthly sub",
|
|
230
|
+
price: "$30.00",
|
|
231
|
+
price_per_period: "$30.00/1mo",
|
|
232
|
+
price_per_period_full: "$30.00/1month",
|
|
233
|
+
total_price_and_per_month: "$30.00",
|
|
234
|
+
total_price_and_per_month_full: "$30.00",
|
|
235
|
+
sub_price_per_month: "$30.00",
|
|
236
|
+
sub_price_per_week: "$30.00",
|
|
237
|
+
sub_duration: "1 month",
|
|
238
|
+
sub_duration_in_months: "1 month",
|
|
239
|
+
sub_period: "monthly",
|
|
240
|
+
sub_period_length: "month",
|
|
241
|
+
sub_period_abbreviated: "mo",
|
|
242
|
+
sub_relative_discount: "",
|
|
243
|
+
sub_offer_duration: "undefined",
|
|
244
|
+
sub_offer_duration_2: "undefined",
|
|
245
|
+
sub_offer_price: "undefined",
|
|
246
|
+
sub_offer_price_2: "undefined",
|
|
247
|
+
},
|
|
248
|
+
$rc_weekly: {
|
|
249
|
+
product_name: "Weekly no trial",
|
|
250
|
+
price: "$1.25",
|
|
251
|
+
price_per_period: "$1.25/1wk",
|
|
252
|
+
price_per_period_full: "$1.25/1week",
|
|
253
|
+
total_price_and_per_month: "$1.25/1wk($5.00/mo)",
|
|
254
|
+
total_price_and_per_month_full: "$1.25/1week($5.00/month)",
|
|
255
|
+
sub_price_per_month: "$5.00",
|
|
256
|
+
sub_price_per_week: "$1.25",
|
|
257
|
+
sub_duration: "1 week",
|
|
258
|
+
sub_duration_in_months: "1 week",
|
|
259
|
+
sub_period: "weekly",
|
|
260
|
+
sub_period_length: "week",
|
|
261
|
+
sub_period_abbreviated: "wk",
|
|
262
|
+
sub_relative_discount: "96% off",
|
|
263
|
+
sub_offer_duration: "undefined",
|
|
264
|
+
sub_offer_duration_2: "undefined",
|
|
265
|
+
sub_offer_price: "undefined",
|
|
266
|
+
sub_offer_price_2: "undefined",
|
|
267
|
+
},
|
|
268
|
+
},
|
|
208
269
|
}}
|
|
209
270
|
/>
|
|
210
271
|
|
|
@@ -103,7 +103,6 @@
|
|
|
103
103
|
}
|
|
104
104
|
onPurchaseClicked?.(purchaseState.selectedPackageId);
|
|
105
105
|
};
|
|
106
|
-
|
|
107
106
|
const onAction = (action: SupportedActions, data?: Extra) => {
|
|
108
107
|
switch (action.type) {
|
|
109
108
|
case "select_package":
|
|
@@ -153,6 +152,7 @@
|
|
|
153
152
|
labels={paywallData.components_localizations}
|
|
154
153
|
{purchaseState}
|
|
155
154
|
{variableDictionary}
|
|
155
|
+
{onAction}
|
|
156
156
|
/>
|
|
157
157
|
{/if}
|
|
158
158
|
{#if paywallData.components_config.base.background?.type === "color"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
import PurchaseButton from "./PurchaseButton.svelte";
|
|
4
4
|
import type { PurchaseState } from "../../data/state";
|
|
5
5
|
import type { ColorMode, DimensionType } from "../../types";
|
|
6
|
+
import type { SupportedActions } from "../../data/entities";
|
|
7
|
+
|
|
8
|
+
const onAction = (action: SupportedActions) => {
|
|
9
|
+
alert(action.type);
|
|
10
|
+
};
|
|
6
11
|
|
|
7
12
|
const { Story } = defineMeta({
|
|
8
13
|
title: "Components/PurchaseButton",
|
|
@@ -135,5 +140,6 @@
|
|
|
135
140
|
},
|
|
136
141
|
labels: labelsData,
|
|
137
142
|
type: "purchase_button",
|
|
143
|
+
onAction,
|
|
138
144
|
}}
|
|
139
145
|
/>
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
{onAction}
|
|
97
97
|
{purchaseState}
|
|
98
98
|
{variableDictionary}
|
|
99
|
+
componentState={restProps.componentState}
|
|
99
100
|
zStackChildStyles={index > 0 ? zStackChildrenStyles : undefined}
|
|
100
101
|
/>
|
|
101
102
|
{:else}
|
|
@@ -105,6 +106,7 @@
|
|
|
105
106
|
{onAction}
|
|
106
107
|
{purchaseState}
|
|
107
108
|
{variableDictionary}
|
|
109
|
+
componentState={restProps.componentState}
|
|
108
110
|
/>
|
|
109
111
|
{/if}
|
|
110
112
|
{/each}
|
|
@@ -22,9 +22,9 @@ export declare function getStackBadgeTextStyles(props: StackProps): {
|
|
|
22
22
|
tagToRender: string;
|
|
23
23
|
textStyles: string;
|
|
24
24
|
};
|
|
25
|
+
export declare function getZStackChildStyles(props: StackProps): ZStackChildStyles | undefined;
|
|
25
26
|
export type ZStackChildStyles = {
|
|
26
27
|
"--inset": string;
|
|
27
28
|
"--transform": string;
|
|
28
29
|
"--position": string;
|
|
29
30
|
};
|
|
30
|
-
export declare function getZStackChildStyles(props: StackProps): ZStackChildStyles | undefined;
|
|
@@ -37,7 +37,7 @@ export const getStackComponentStyles = (props) => {
|
|
|
37
37
|
};
|
|
38
38
|
const activeStateProps = getActiveStateProps(overrides, componentState);
|
|
39
39
|
Object.assign(stackStyles, getComponentStyles({
|
|
40
|
-
|
|
40
|
+
background_color,
|
|
41
41
|
margin,
|
|
42
42
|
padding,
|
|
43
43
|
border,
|
|
@@ -91,8 +91,8 @@ export function getBadgeStyles(props) {
|
|
|
91
91
|
alignment: badge.alignment,
|
|
92
92
|
}), getComponentStyles({
|
|
93
93
|
...badge,
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
background_color: badge.background_color,
|
|
95
|
+
color: badge.color,
|
|
96
96
|
colorMode: props.purchaseState.colorMode,
|
|
97
97
|
}));
|
|
98
98
|
if (badge.style === "overlay") {
|
|
@@ -43,8 +43,8 @@ export const getTextComponentStyles = (props) => {
|
|
|
43
43
|
const tagToRender = getTextComponentTag(font_size);
|
|
44
44
|
const textStyles = getTextStyles({ ...props, ...activeStateProps }, purchaseState.colorMode);
|
|
45
45
|
const componentStyles = getComponentStyles({
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
background_color,
|
|
47
|
+
color,
|
|
48
48
|
margin,
|
|
49
49
|
padding,
|
|
50
50
|
colorMode: purchaseState.colorMode,
|
|
@@ -88,7 +88,7 @@ export function getTextWrapperStyles(restProps, size, background_color) {
|
|
|
88
88
|
"--transform": "initial",
|
|
89
89
|
};
|
|
90
90
|
Object.assign(styles, getComponentStyles({
|
|
91
|
-
|
|
91
|
+
background_color,
|
|
92
92
|
...restProps,
|
|
93
93
|
}), getSizeStyle(size));
|
|
94
94
|
Object.assign(styles, restProps.zStackChildStyles);
|
package/dist/data/entities.d.ts
CHANGED
|
@@ -79,6 +79,11 @@ interface SharedComponentProps extends PaywallComponent, ActionsProps, PurchaseS
|
|
|
79
79
|
interface Action {
|
|
80
80
|
type: "restore_purchases" | "navigate_to" | "navigate_back" | "purchase" | "select_package";
|
|
81
81
|
}
|
|
82
|
+
type OverrideProps<T> = {
|
|
83
|
+
states?: {
|
|
84
|
+
[state: string]: T;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
82
87
|
export interface RestorePurchasesAction extends Action {
|
|
83
88
|
type: "restore_purchases";
|
|
84
89
|
}
|
|
@@ -149,9 +154,7 @@ export interface StackProps extends SharedComponentProps {
|
|
|
149
154
|
horizontal_alignment: keyof typeof TextAlignments;
|
|
150
155
|
background_color: ColorType;
|
|
151
156
|
};
|
|
152
|
-
overrides?:
|
|
153
|
-
[state: string]: StackProps;
|
|
154
|
-
};
|
|
157
|
+
overrides?: OverrideProps<StackProps>;
|
|
155
158
|
}
|
|
156
159
|
export interface TextNodeProps extends SharedComponentProps {
|
|
157
160
|
background_color?: ColorType;
|
|
@@ -167,9 +170,7 @@ export interface TextNodeProps extends SharedComponentProps {
|
|
|
167
170
|
type: "text";
|
|
168
171
|
size: SizeType;
|
|
169
172
|
variableDictionary?: VariableDictionary;
|
|
170
|
-
overrides?:
|
|
171
|
-
[state: string]: TextNodeProps;
|
|
172
|
-
};
|
|
173
|
+
overrides?: OverrideProps<TextNodeProps>;
|
|
173
174
|
}
|
|
174
175
|
type ImageSourceDictionaryType = {
|
|
175
176
|
original: string;
|
|
@@ -197,9 +198,7 @@ export interface ImageProps extends SharedComponentProps {
|
|
|
197
198
|
mask_shape?: ImageMaskShapeType;
|
|
198
199
|
max_height?: number;
|
|
199
200
|
override_source_lid?: string;
|
|
200
|
-
overrides?:
|
|
201
|
-
[state: string]: ImageProps;
|
|
202
|
-
};
|
|
201
|
+
overrides?: OverrideProps<ImageProps>;
|
|
203
202
|
}
|
|
204
203
|
export type ItemProps = {
|
|
205
204
|
title: {
|
|
@@ -8,7 +8,6 @@ export declare const gradientPaywallData: PaywallData;
|
|
|
8
8
|
export declare const calmPaywallData: PaywallData;
|
|
9
9
|
export declare const stateTemplate: PaywallData;
|
|
10
10
|
export declare const posterMakerTemplate: PaywallData;
|
|
11
|
-
export declare const e2eTestTemplate: PaywallData;
|
|
12
11
|
export declare const zStackTemplate: PaywallData;
|
|
13
12
|
export declare const labelsData: {
|
|
14
13
|
en_US: {
|
|
@@ -22,3 +21,4 @@ export declare const colorModeOverrideTemplate: PaywallData;
|
|
|
22
21
|
export declare const paywallWithFooter: PaywallData;
|
|
23
22
|
export declare const errorPaywallData: PaywallData;
|
|
24
23
|
export declare const fallbackPaywallData: PaywallData;
|
|
24
|
+
export declare const e2eTestTemplate: PaywallData;
|