@revenuecat/purchases-ui-js 2.2.1 → 3.0.0
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/countdown/Countdown.stories.svelte +365 -0
- package/dist/components/countdown/Countdown.stories.svelte.d.ts +19 -0
- package/dist/components/countdown/Countdown.svelte +55 -0
- package/dist/components/countdown/Countdown.svelte.d.ts +4 -0
- package/dist/components/countdown/countdown-utils.d.ts +13 -0
- package/dist/components/countdown/countdown-utils.js +66 -0
- package/dist/components/countdown/fixtures/countdown-paywall.d.ts +2 -0
- package/dist/components/countdown/fixtures/countdown-paywall.js +5362 -0
- package/dist/components/package/Package.stories.svelte +1 -0
- package/dist/components/paywall/Node.svelte +2 -0
- package/dist/components/paywall/Paywall.stories.svelte +18 -2
- package/dist/components/paywall/Paywall.svelte +3 -3
- package/dist/components/paywall/Paywall.svelte.d.ts +1 -1
- package/dist/components/purchase-button/PurchaseButton.svelte +48 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/stores/paywall.d.ts +1 -1
- package/dist/stories/fixtures.d.ts +4 -0
- package/dist/stories/fixtures.js +4 -0
- package/dist/types/component.d.ts +2 -1
- package/dist/types/components/countdown.d.ts +13 -0
- package/dist/types/components/countdown.js +1 -0
- package/package.json +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import Package from "./Package.svelte";
|
|
3
|
+
import type { PackageProps } from "../../types/components/package";
|
|
3
4
|
import { componentDecorator } from "../../stories/component-decorator";
|
|
4
5
|
import { localizationDecorator } from "../../stories/localization-decorator";
|
|
5
6
|
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Video,
|
|
10
10
|
} from "../..";
|
|
11
11
|
import ButtonNode from "../button/ButtonNode.svelte";
|
|
12
|
+
import Countdown from "../countdown/Countdown.svelte";
|
|
12
13
|
import InputMultipleChoice from "../options/InputMultipleChoice.svelte";
|
|
13
14
|
import InputOption from "../options/InputOption.svelte";
|
|
14
15
|
import InputSingleChoice from "../options/InputSingleChoice.svelte";
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
const ComponentTypes = {
|
|
30
31
|
button: ButtonNode,
|
|
31
32
|
carousel: Carousel,
|
|
33
|
+
countdown: Countdown,
|
|
32
34
|
footer: Footer,
|
|
33
35
|
icon: Icon,
|
|
34
36
|
image: Image,
|
|
@@ -26,13 +26,17 @@
|
|
|
26
26
|
import { SHEET_PAYWALL } from "./fixtures/sheet-paywall";
|
|
27
27
|
import { STACK_PAYWALL } from "./fixtures/stack-paywall";
|
|
28
28
|
import { VARIABLES } from "./fixtures/variables";
|
|
29
|
+
import { COUNTDOWN_PAYWALL } from "../countdown/fixtures/countdown-paywall";
|
|
30
|
+
import { mockDateDecorator } from "storybook-mock-date-decorator";
|
|
29
31
|
|
|
30
32
|
const { Story } = defineMeta({
|
|
31
33
|
title: "Example/Paywall",
|
|
32
34
|
component: Paywall,
|
|
33
35
|
args: {
|
|
34
|
-
onPurchaseClicked: (selectedPackageId: string) =>
|
|
35
|
-
alert(
|
|
36
|
+
onPurchaseClicked: (selectedPackageId: string, actionId: string) =>
|
|
37
|
+
alert(
|
|
38
|
+
`Purchase package ${selectedPackageId}${actionId ? ` with action ${actionId}` : ""}`,
|
|
39
|
+
),
|
|
36
40
|
onBackClicked: () => alert("Go back"),
|
|
37
41
|
onVisitCustomerCenterClicked: () => alert("Visit customer center"),
|
|
38
42
|
onRestorePurchasesClicked: () => alert("Restore purchases"),
|
|
@@ -323,6 +327,17 @@
|
|
|
323
327
|
}}
|
|
324
328
|
/>
|
|
325
329
|
|
|
330
|
+
<Story
|
|
331
|
+
name="With Countdown"
|
|
332
|
+
decorators={[mockDateDecorator]}
|
|
333
|
+
parameters={{
|
|
334
|
+
date: new Date("2024-01-15T12:00:00Z"),
|
|
335
|
+
}}
|
|
336
|
+
args={{
|
|
337
|
+
paywallData: COUNTDOWN_PAYWALL,
|
|
338
|
+
}}
|
|
339
|
+
/>
|
|
340
|
+
|
|
326
341
|
<Story
|
|
327
342
|
name="Wallet Button"
|
|
328
343
|
args={{
|
|
@@ -332,6 +347,7 @@
|
|
|
332
347
|
newDiv.innerText = "Hi! I was injected from the walletButtonRender";
|
|
333
348
|
newDiv.style.width = "100%";
|
|
334
349
|
newDiv.style.textAlign = "center";
|
|
350
|
+
newDiv.style.border = "1px solid black";
|
|
335
351
|
element.append(newDiv);
|
|
336
352
|
return {};
|
|
337
353
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
infoPerPackage?: Record<string, PackageInfo>;
|
|
34
34
|
uiConfig: UIConfig;
|
|
35
35
|
preferredColorMode?: ColorMode;
|
|
36
|
-
onPurchaseClicked?: (selectedPackageId: string) => void;
|
|
36
|
+
onPurchaseClicked?: (selectedPackageId: string, actionId: string) => void;
|
|
37
37
|
onBackClicked?: () => void;
|
|
38
38
|
onVisitCustomerCenterClicked?: () => void;
|
|
39
39
|
onRestorePurchasesClicked?: () => void;
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
findSelectedPackageId(base),
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
const onPurchase = () => {
|
|
86
|
+
const onPurchase = (actionId?: string) => {
|
|
87
87
|
const packageId = $selectedPackageId;
|
|
88
88
|
if (packageId !== undefined) {
|
|
89
|
-
onPurchaseClicked?.(packageId);
|
|
89
|
+
onPurchaseClicked?.(packageId, actionId ?? "");
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
|
|
@@ -9,7 +9,7 @@ interface Props {
|
|
|
9
9
|
infoPerPackage?: Record<string, PackageInfo>;
|
|
10
10
|
uiConfig: UIConfig;
|
|
11
11
|
preferredColorMode?: ColorMode;
|
|
12
|
-
onPurchaseClicked?: (selectedPackageId: string) => void;
|
|
12
|
+
onPurchaseClicked?: (selectedPackageId: string, actionId: string) => void;
|
|
13
13
|
onBackClicked?: () => void;
|
|
14
14
|
onVisitCustomerCenterClicked?: () => void;
|
|
15
15
|
onRestorePurchasesClicked?: () => void;
|
|
@@ -2,19 +2,61 @@
|
|
|
2
2
|
import Stack from "../stack/Stack.svelte";
|
|
3
3
|
import { getPaywallContext } from "../../stores/paywall";
|
|
4
4
|
import type { PurchaseButtonProps } from "../../types/components/purchase-button";
|
|
5
|
+
import { getSelectedStateContext } from "../../stores/selected";
|
|
6
|
+
import { getActiveStateProps } from "../../utils/style-utils";
|
|
7
|
+
import {
|
|
8
|
+
type CSS,
|
|
9
|
+
css,
|
|
10
|
+
mapSize,
|
|
11
|
+
mapSpacing,
|
|
12
|
+
px,
|
|
13
|
+
} from "../../utils/base-utils";
|
|
14
|
+
import { mapDimension } from "../stack/stack-utils";
|
|
15
|
+
import type { StackProps } from "../../types/components/stack";
|
|
16
|
+
|
|
17
|
+
const props: PurchaseButtonProps = $props();
|
|
18
|
+
const { stack } = props;
|
|
5
19
|
|
|
6
|
-
const { stack }: PurchaseButtonProps = $props();
|
|
7
20
|
const { onPurchase, walletButtonRender, selectedPackageId } =
|
|
8
21
|
getPaywallContext();
|
|
22
|
+
|
|
23
|
+
const stackProps: StackProps & { style?: CSS } = { ...stack };
|
|
24
|
+
const selectedState = getSelectedStateContext();
|
|
25
|
+
const { size, dimension, spacing, margin } = $derived.by(() => {
|
|
26
|
+
return {
|
|
27
|
+
...stackProps,
|
|
28
|
+
...getActiveStateProps($selectedState, stackProps.overrides),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const stackStyle = $derived(
|
|
33
|
+
css({
|
|
34
|
+
...stackProps.style,
|
|
35
|
+
display: "flex",
|
|
36
|
+
position: "relative",
|
|
37
|
+
width: mapSize(size.width),
|
|
38
|
+
height: mapSize(size.height),
|
|
39
|
+
...mapDimension(dimension),
|
|
40
|
+
gap: px(spacing),
|
|
41
|
+
margin: mapSpacing(margin),
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const onclick = () => {
|
|
46
|
+
const actionId = props.triggers?.on_purchase_press;
|
|
47
|
+
onPurchase(actionId);
|
|
48
|
+
};
|
|
9
49
|
</script>
|
|
10
50
|
|
|
11
51
|
{#if walletButtonRender}
|
|
12
52
|
{#if $selectedPackageId}
|
|
13
|
-
<div
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
53
|
+
<div style={stackStyle}>
|
|
54
|
+
<div
|
|
55
|
+
style="flex-grow: 1"
|
|
56
|
+
use:walletButtonRender={$selectedPackageId}
|
|
57
|
+
></div>
|
|
58
|
+
</div>
|
|
17
59
|
{/if}
|
|
18
60
|
{/if}
|
|
19
61
|
|
|
20
|
-
<Stack {...stack} onclick
|
|
62
|
+
<Stack {...stack} {onclick} />
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as ButtonDeprecated } from "./components/button/Button.svelte";
|
|
2
|
+
export { default as Countdown } from "./components/countdown/Countdown.svelte";
|
|
2
3
|
export { default as Footer } from "./components/footer/Footer.svelte";
|
|
3
4
|
export { default as Image } from "./components/image/Image.svelte";
|
|
4
5
|
export { default as InputMultipleChoice } from "./components/options/InputMultipleChoice.svelte";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Reexport your entry components here
|
|
2
2
|
export { default as ButtonDeprecated } from "./components/button/Button.svelte";
|
|
3
|
+
export { default as Countdown } from "./components/countdown/Countdown.svelte";
|
|
3
4
|
export { default as Footer } from "./components/footer/Footer.svelte";
|
|
4
5
|
export { default as Image } from "./components/image/Image.svelte";
|
|
5
6
|
export { default as InputMultipleChoice } from "./components/options/InputMultipleChoice.svelte";
|
package/dist/stores/paywall.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ type PaywallContext = Readonly<{
|
|
|
6
6
|
selectedPackageId: Writable<string | undefined>;
|
|
7
7
|
variablesPerPackage: Readable<Record<string, VariableDictionary> | undefined>;
|
|
8
8
|
infoPerPackage: Readable<Record<string, PackageInfo> | undefined>;
|
|
9
|
-
onPurchase: () => void;
|
|
9
|
+
onPurchase: (actionId?: string) => void;
|
|
10
10
|
walletButtonRender?: (node: HTMLElement, selectedPackageId: string) => {
|
|
11
11
|
destroy?: () => void;
|
|
12
12
|
update?: (selectedPackageId: string) => void;
|
package/dist/stories/fixtures.js
CHANGED
|
@@ -17307,6 +17307,10 @@ export const localizations = {
|
|
|
17307
17307
|
id2: "Item 2",
|
|
17308
17308
|
id3: "Item 3",
|
|
17309
17309
|
badge: "Badge Text",
|
|
17310
|
+
countdown: "{{ count_days_with_zero }} : {{ count_hours_with_zero }} : {{ count_minutes_with_zero }} : {{ count_seconds_with_zero }}",
|
|
17311
|
+
ended: "Time's up!",
|
|
17312
|
+
days: "{{ count_days_without_zero }} days",
|
|
17313
|
+
time: "{{ count_hours_with_zero }}:{{ count_minutes_with_zero }}:{{ count_seconds_with_zero }}",
|
|
17310
17314
|
},
|
|
17311
17315
|
};
|
|
17312
17316
|
export const colorModeOverrideTemplate = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ButtonProps } from "./components/button";
|
|
2
2
|
import type { CarouselProps } from "./components/carousel";
|
|
3
|
+
import type { CountdownProps } from "./components/countdown";
|
|
3
4
|
import type { FooterProps } from "./components/footer";
|
|
4
5
|
import type { IconProps } from "./components/icon";
|
|
5
6
|
import type { ImageProps } from "./components/image";
|
|
@@ -11,4 +12,4 @@ import type { TabControlButtonProps, TabControlProps, TabControlToggleProps, Tab
|
|
|
11
12
|
import type { TextNodeProps } from "./components/text";
|
|
12
13
|
import type { TimelineProps } from "./components/timeline";
|
|
13
14
|
import type { VideoProps } from "./components/video";
|
|
14
|
-
export type Component = ButtonProps | CarouselProps | FooterProps | IconProps | ImageProps | InputMultipleChoiceProps | InputOptionProps | InputSingleChoiceProps | PackageProps | PurchaseButtonProps | StackProps | TabControlButtonProps | TabControlToggleProps | TabControlProps | TabsProps | TextNodeProps | TimelineProps | VideoProps;
|
|
15
|
+
export type Component = ButtonProps | CarouselProps | CountdownProps | FooterProps | IconProps | ImageProps | InputMultipleChoiceProps | InputOptionProps | InputSingleChoiceProps | PackageProps | PurchaseButtonProps | StackProps | TabControlButtonProps | TabControlToggleProps | TabControlProps | TabsProps | TextNodeProps | TimelineProps | VideoProps;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BaseComponent } from "../base";
|
|
2
|
+
import type { StackProps } from "./stack";
|
|
3
|
+
export interface CountdownStyle {
|
|
4
|
+
type: "date";
|
|
5
|
+
date: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CountdownProps extends BaseComponent {
|
|
8
|
+
type: "countdown";
|
|
9
|
+
visible?: boolean | null;
|
|
10
|
+
style: CountdownStyle;
|
|
11
|
+
countdown_stack: StackProps;
|
|
12
|
+
end_stack: StackProps | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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": "
|
|
5
|
+
"version": "3.0.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "RevenueCat, Inc."
|
|
8
8
|
},
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"prettier-plugin-svelte": "3.4.0",
|
|
98
98
|
"publint": "0.3.15",
|
|
99
99
|
"storybook": "9.1.10",
|
|
100
|
+
"storybook-mock-date-decorator": "^3.0.0",
|
|
100
101
|
"svelte": "5.43.0",
|
|
101
102
|
"svelte-check": "4.3.3",
|
|
102
103
|
"typescript": "5.9.3",
|