@revenuecat/purchases-ui-js 0.0.8

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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/dist/components/button/Button.svelte +33 -0
  4. package/dist/components/button/Button.svelte.d.ts +8 -0
  5. package/dist/components/button/ButtonNode.stories.svelte +204 -0
  6. package/dist/components/button/ButtonNode.stories.svelte.d.ts +27 -0
  7. package/dist/components/button/ButtonNode.svelte +15 -0
  8. package/dist/components/button/ButtonNode.svelte.d.ts +3 -0
  9. package/dist/components/footer/Footer.stories.svelte +237 -0
  10. package/dist/components/footer/Footer.stories.svelte.d.ts +25 -0
  11. package/dist/components/footer/Footer.svelte +11 -0
  12. package/dist/components/footer/Footer.svelte.d.ts +3 -0
  13. package/dist/components/image/Image.stories.svelte +165 -0
  14. package/dist/components/image/Image.stories.svelte.d.ts +19 -0
  15. package/dist/components/image/Image.svelte +45 -0
  16. package/dist/components/image/Image.svelte.d.ts +3 -0
  17. package/dist/components/image/image-utils.d.ts +20 -0
  18. package/dist/components/image/image-utils.js +19 -0
  19. package/dist/components/package/Package.stories.svelte +243 -0
  20. package/dist/components/package/Package.stories.svelte.d.ts +25 -0
  21. package/dist/components/package/Package.svelte +39 -0
  22. package/dist/components/package/Package.svelte.d.ts +3 -0
  23. package/dist/components/paywall/Node.svelte +55 -0
  24. package/dist/components/paywall/Node.svelte.d.ts +9 -0
  25. package/dist/components/paywall/Paywall.stories.svelte +24 -0
  26. package/dist/components/paywall/Paywall.stories.svelte.d.ts +19 -0
  27. package/dist/components/paywall/Paywall.svelte +122 -0
  28. package/dist/components/paywall/Paywall.svelte.d.ts +6 -0
  29. package/dist/components/paywall/global-styles.css +9 -0
  30. package/dist/components/purchase-button/PurchaseButton.stories.svelte +133 -0
  31. package/dist/components/purchase-button/PurchaseButton.stories.svelte.d.ts +24 -0
  32. package/dist/components/purchase-button/PurchaseButton.svelte +28 -0
  33. package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +3 -0
  34. package/dist/components/stack/Stack.stories.svelte +306 -0
  35. package/dist/components/stack/Stack.stories.svelte.d.ts +19 -0
  36. package/dist/components/stack/Stack.svelte +61 -0
  37. package/dist/components/stack/Stack.svelte.d.ts +3 -0
  38. package/dist/components/stack/stack-utils.d.ts +29 -0
  39. package/dist/components/stack/stack-utils.js +26 -0
  40. package/dist/components/text/Text.stories.svelte +101 -0
  41. package/dist/components/text/Text.stories.svelte.d.ts +19 -0
  42. package/dist/components/text/Text.svelte +40 -0
  43. package/dist/components/text/Text.svelte.d.ts +3 -0
  44. package/dist/components/text/text-utils.d.ts +20 -0
  45. package/dist/components/text/text-utils.js +34 -0
  46. package/dist/data/entities.d.ts +139 -0
  47. package/dist/data/entities.js +1 -0
  48. package/dist/data/state.d.ts +3 -0
  49. package/dist/data/state.js +1 -0
  50. package/dist/index.d.ts +10 -0
  51. package/dist/index.js +11 -0
  52. package/dist/stores/theme.d.ts +1 -0
  53. package/dist/stores/theme.js +17 -0
  54. package/dist/stories/fixtures.d.ts +12 -0
  55. package/dist/stories/fixtures.js +6855 -0
  56. package/dist/stories/meta-templates.d.ts +13 -0
  57. package/dist/stories/meta-templates.js +156 -0
  58. package/dist/types.d.ts +125 -0
  59. package/dist/types.js +61 -0
  60. package/dist/utils.d.ts +93 -0
  61. package/dist/utils.js +227 -0
  62. package/package.json +91 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 RevenueCat
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Purchases UI Web
2
+
3
+ Web components for Paywalls. Powered by RevenueCat
4
+
5
+ ## Building
6
+
7
+ To build your library:
8
+
9
+ ```bash
10
+ npm run package
11
+ ```
@@ -0,0 +1,33 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+
4
+ interface ButtonProps {
5
+ onclick?: () => void;
6
+ children?: Snippet;
7
+ style?: string;
8
+ class?: string;
9
+ }
10
+
11
+ const { onclick, children, style, class: clz }: ButtonProps = $props();
12
+
13
+ const handleClick = () => {
14
+ onclick?.();
15
+ };
16
+ </script>
17
+
18
+ <button onclick={handleClick} class={clz} disabled={!onclick} {style}>
19
+ {@render children?.()}
20
+ </button>
21
+
22
+ <style>
23
+ button {
24
+ border: none;
25
+ cursor: pointer;
26
+ background-color: transparent;
27
+ padding: 0;
28
+ width: 100%;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ }
33
+ </style>
@@ -0,0 +1,8 @@
1
+ import type { Snippet } from "svelte";
2
+ declare const Button: import("svelte").Component<{
3
+ onclick?: () => void;
4
+ children?: Snippet;
5
+ style?: string;
6
+ class?: string;
7
+ }, {}, "">;
8
+ export default Button;
@@ -0,0 +1,204 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from "@storybook/addon-svelte-csf";
3
+ import ButtonNode from "./ButtonNode.svelte";
4
+ import { colorModeStoryMeta } from "../../stories/meta-templates";
5
+ import type { SupportedActions, TextProps } from "../../data/entities";
6
+
7
+ const onAction = (action: SupportedActions) => {
8
+ alert(action.type);
9
+ };
10
+
11
+ const { Story } = defineMeta({
12
+ title: "Components/Button",
13
+ component: ButtonNode,
14
+ tags: ["autodocs"],
15
+ argTypes: {
16
+ action: {
17
+ control: { type: "object" },
18
+ description: "Action configuration for the button",
19
+ table: {
20
+ type: {
21
+ summary: "object",
22
+ detail: `{
23
+ type: "restore_purchases" | "navigate_back" | "navigate_to",
24
+ destination?: "customer_center" | "privacy_policy" | "terms" | "url",
25
+ url?: {
26
+ url_lid: string,
27
+ method: "in_app_browser" | "external_browser" | "deep_link"
28
+ }
29
+ }`,
30
+ },
31
+ },
32
+ },
33
+ colorMode: colorModeStoryMeta,
34
+ stack: {
35
+ control: { type: "object" },
36
+ description: "Stack configuration for button content",
37
+ table: {
38
+ type: {
39
+ summary: "object",
40
+ detail: "StackProps",
41
+ },
42
+ },
43
+ },
44
+ },
45
+ });
46
+
47
+ export const labelsData = {
48
+ en_US: {
49
+ id1: "Restore purchases",
50
+ id2: "Navigate back",
51
+ id3: "Navigate to",
52
+ id4: "URL navigation",
53
+ },
54
+ };
55
+
56
+ const textProps = (id: number): TextProps => ({
57
+ type: "text",
58
+ name: "Button Text",
59
+ components: [],
60
+ id: "button-text-1",
61
+ text_lid: `id${id}`,
62
+ font_weight: "medium",
63
+ horizontal_alignment: "center",
64
+ background_color: {
65
+ dark: { type: "hex", value: "transparent" },
66
+ light: { type: "hex", value: "transparent" },
67
+ },
68
+ color: {
69
+ dark: { type: "hex", value: "#000000" },
70
+ light: { type: "hex", value: "#ffffff" },
71
+ },
72
+ font_size: "body_m",
73
+ margin: { top: 0, trailing: 0, bottom: 0, leading: 0 },
74
+ padding: { top: 0, trailing: 0, bottom: 0, leading: 0 },
75
+ labels: labelsData,
76
+ colorMode: "light",
77
+ size: {
78
+ width: { type: "fit" },
79
+ height: { type: "fit" },
80
+ },
81
+ });
82
+
83
+ const baseStackProps = {
84
+ type: "stack",
85
+ size: { width: { type: "fill" }, height: { type: "fill" } },
86
+ labels: labelsData,
87
+ dimension: {
88
+ type: "horizontal",
89
+ alignment: "center",
90
+ distribution: "center",
91
+ },
92
+ components: [],
93
+ spacing: 16,
94
+ padding: { top: 16, trailing: 16, bottom: 16, leading: 16 },
95
+ margin: { top: 0, trailing: 0, bottom: 0, leading: 0 },
96
+ shape: { type: "pill" },
97
+ id: "vertical-stack",
98
+ name: "Vertical Stack",
99
+ background_color: {
100
+ dark: { type: "hex", value: "#3471eb" },
101
+ light: { type: "hex", value: "#3471eb" },
102
+ },
103
+ };
104
+ </script>
105
+
106
+ <!-- Restore purchases -->
107
+ <Story
108
+ name="Restore purchases"
109
+ args={{
110
+ type: "button",
111
+ action: { type: "restore_purchases" },
112
+ labels: labelsData,
113
+ stack: {
114
+ ...baseStackProps,
115
+ components: [textProps(1)],
116
+ },
117
+ onAction,
118
+ }}
119
+ />
120
+
121
+ <!-- Navigate Back story -->
122
+ <Story
123
+ name="Navigate Back"
124
+ args={{
125
+ type: "button",
126
+ action: { type: "navigate_back" },
127
+ onAction,
128
+ labels: labelsData,
129
+ stack: {
130
+ ...baseStackProps,
131
+ shape: {
132
+ type: "rectangle",
133
+ corners: {
134
+ top_leading: 16,
135
+ top_trailing: 16,
136
+ bottom_leading: 16,
137
+ bottom_trailing: 16,
138
+ },
139
+ },
140
+ background_color: {
141
+ dark: { type: "hex", value: "#2E7D32" },
142
+ light: { type: "hex", value: "#2E7D32" },
143
+ },
144
+ components: [textProps(2)],
145
+ },
146
+ }}
147
+ />
148
+
149
+ <!-- Navigate To story -->
150
+ <Story
151
+ name="Navigate To"
152
+ args={{
153
+ type: "button",
154
+ labels: labelsData,
155
+ action: {
156
+ type: "navigate_to",
157
+ destination: "customer_center",
158
+ },
159
+ onAction,
160
+ stack: {
161
+ ...baseStackProps,
162
+ shape: {
163
+ type: "rectangle",
164
+ corners: {
165
+ top_leading: 8,
166
+ top_trailing: 8,
167
+ bottom_leading: 8,
168
+ bottom_trailing: 8,
169
+ },
170
+ },
171
+ background_color: {
172
+ dark: { type: "hex", value: "#D32F2F" },
173
+ light: { type: "hex", value: "#D32F2F" },
174
+ },
175
+ components: [textProps(3)],
176
+ },
177
+ }}
178
+ />
179
+
180
+ <!-- URL Navigation story -->
181
+ <Story
182
+ name="URL Navigation"
183
+ args={{
184
+ type: "button",
185
+ labels: labelsData,
186
+ action: {
187
+ type: "navigate_to",
188
+ destination: "url",
189
+ url: {
190
+ url_lid: "terms_url",
191
+ method: "in_app_browser",
192
+ },
193
+ },
194
+ onAction,
195
+ stack: {
196
+ ...baseStackProps,
197
+ background_color: {
198
+ dark: { type: "hex", value: "#4A90E2" },
199
+ light: { type: "hex", value: "#4A90E2" },
200
+ },
201
+ components: [textProps(4)],
202
+ },
203
+ }}
204
+ />
@@ -0,0 +1,27 @@
1
+ import ButtonNode from "./ButtonNode.svelte";
2
+ export declare const labelsData: {
3
+ en_US: {
4
+ id1: string;
5
+ id2: string;
6
+ id3: string;
7
+ id4: string;
8
+ };
9
+ };
10
+ 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> {
11
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
12
+ $$bindings?: Bindings;
13
+ } & Exports;
14
+ (internal: unknown, props: {
15
+ $$events?: Events;
16
+ $$slots?: Slots;
17
+ }): Exports & {
18
+ $set?: any;
19
+ $on?: any;
20
+ };
21
+ z_$$bindings?: Bindings;
22
+ }
23
+ declare const ButtonNode: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
24
+ [evt: string]: CustomEvent<any>;
25
+ }, {}, {}, string>;
26
+ type ButtonNode = InstanceType<typeof ButtonNode>;
27
+ export default ButtonNode;
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import Button from "./Button.svelte";
3
+ import type { ButtonNodeProps } from "../../data/entities";
4
+ import Stack from "../stack/Stack.svelte";
5
+
6
+ const { stack, action, labels, onAction, purchaseState }: ButtonNodeProps =
7
+ $props();
8
+ const onClick = () => {
9
+ onAction && onAction(action);
10
+ };
11
+ </script>
12
+
13
+ <Button onclick={onClick}>
14
+ <Stack {...stack} {labels} {purchaseState} />
15
+ </Button>
@@ -0,0 +1,3 @@
1
+ import type { ButtonNodeProps } from "../../data/entities";
2
+ declare const ButtonNode: import("svelte").Component<ButtonNodeProps, {}, "">;
3
+ export default ButtonNode;
@@ -0,0 +1,237 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from "@storybook/addon-svelte-csf";
3
+ import Footer from "./Footer.svelte";
4
+ import { colorModeStoryMeta } from "../../stories/meta-templates";
5
+
6
+ const { Story } = defineMeta({
7
+ title: "Components/Footer",
8
+ component: Footer,
9
+ tags: ["autodocs"],
10
+ argTypes: {
11
+ colorMode: colorModeStoryMeta,
12
+ stack: {
13
+ control: { type: "object" },
14
+ description: "Stack configuration for package content",
15
+ table: {
16
+ type: {
17
+ summary: "object",
18
+ detail: "StackProps",
19
+ },
20
+ },
21
+ },
22
+ },
23
+ });
24
+
25
+ export const labelsData = {
26
+ en_US: {
27
+ "BcX-6YwhoV": "Monthly",
28
+ QZ4ZmYsqjN: "$1.99",
29
+ },
30
+ };
31
+ </script>
32
+
33
+ <!-- Default -->
34
+ <Story
35
+ name="Default Package"
36
+ args={{
37
+ id: "6rQSD5e2Kz",
38
+ is_selected_by_default: false,
39
+ name: "Package - Monthly",
40
+ package_id: "$rc_annual",
41
+ stack: {
42
+ background_color: {
43
+ light: {
44
+ type: "hex",
45
+ value: "#09090b",
46
+ },
47
+ },
48
+ labels: labelsData,
49
+ border: {
50
+ color: {
51
+ light: {
52
+ type: "hex",
53
+ value: "#3b393f",
54
+ },
55
+ },
56
+ width: 1,
57
+ },
58
+ components: [
59
+ {
60
+ background_color: null,
61
+ color: {
62
+ light: {
63
+ type: "hex",
64
+ value: "#ffffff",
65
+ },
66
+ },
67
+ labels: labelsData,
68
+ components: [],
69
+ font_name: null,
70
+ font_size: "heading_s",
71
+ font_weight: "bold",
72
+ horizontal_alignment: "center",
73
+ id: "aSK4Jf1zd4",
74
+ margin: {
75
+ bottom: 0,
76
+ leading: 0,
77
+ top: 0,
78
+ trailing: 0,
79
+ },
80
+ name: "Text",
81
+ padding: {
82
+ bottom: 0,
83
+ leading: 0,
84
+ top: 0,
85
+ trailing: 0,
86
+ },
87
+ size: {
88
+ height: {
89
+ type: "fit",
90
+ value: null,
91
+ },
92
+ width: {
93
+ type: "fit",
94
+ value: null,
95
+ },
96
+ },
97
+ text_lid: "BcX-6YwhoV",
98
+ type: "text",
99
+ },
100
+ {
101
+ background_color: {
102
+ light: {
103
+ type: "hex",
104
+ value: "#292631",
105
+ },
106
+ },
107
+ labels: labelsData,
108
+ border: null,
109
+ components: [
110
+ {
111
+ background_color: null,
112
+ color: {
113
+ light: {
114
+ type: "hex",
115
+ value: "#ffffff",
116
+ },
117
+ },
118
+ components: [],
119
+ font_name: null,
120
+ font_size: "body_m",
121
+ font_weight: "extra_bold",
122
+ horizontal_alignment: "center",
123
+ id: "unosKAXGp4",
124
+ margin: {
125
+ bottom: 0,
126
+ leading: 0,
127
+ top: 0,
128
+ trailing: 0,
129
+ },
130
+ name: "Text",
131
+ padding: {
132
+ bottom: 8,
133
+ leading: 16,
134
+ top: 8,
135
+ trailing: 16,
136
+ },
137
+ size: {
138
+ height: {
139
+ type: "fit",
140
+ value: null,
141
+ },
142
+ width: {
143
+ type: "fit",
144
+ value: null,
145
+ },
146
+ },
147
+ text_lid: "QZ4ZmYsqjN",
148
+ type: "text",
149
+ },
150
+ ],
151
+ dimension: {
152
+ alignment: "leading",
153
+ distribution: "space_between",
154
+ type: "vertical",
155
+ },
156
+ id: "-41AkrT2Ha",
157
+ margin: {
158
+ bottom: 0,
159
+ leading: 0,
160
+ top: 0,
161
+ trailing: 0,
162
+ },
163
+ name: "Stack",
164
+ padding: {
165
+ bottom: 0,
166
+ leading: 0,
167
+ top: 0,
168
+ trailing: 0,
169
+ },
170
+ shape: {
171
+ corners: {
172
+ bottom_leading: 8,
173
+ bottom_trailing: 8,
174
+ top_leading: 8,
175
+ top_trailing: 8,
176
+ },
177
+ type: "rectangle",
178
+ },
179
+ size: {
180
+ height: {
181
+ type: "fit",
182
+ value: null,
183
+ },
184
+ width: {
185
+ type: "fit",
186
+ value: null,
187
+ },
188
+ },
189
+ spacing: 8,
190
+ type: "stack",
191
+ },
192
+ ],
193
+ dimension: {
194
+ alignment: "center",
195
+ distribution: "space_between",
196
+ type: "horizontal",
197
+ },
198
+ id: "u0KZLUZTQT",
199
+ margin: {
200
+ bottom: 0,
201
+ leading: 16,
202
+ top: 16,
203
+ trailing: 16,
204
+ },
205
+ name: "Stack",
206
+ padding: {
207
+ bottom: 16,
208
+ leading: 16,
209
+ top: 16,
210
+ trailing: 16,
211
+ },
212
+ shape: {
213
+ corners: {
214
+ bottom_leading: 0,
215
+ bottom_trailing: 0,
216
+ top_leading: 8,
217
+ top_trailing: 8,
218
+ },
219
+ type: "rectangle",
220
+ },
221
+ size: {
222
+ height: {
223
+ type: "fit",
224
+ value: null,
225
+ },
226
+ width: {
227
+ type: "fixed",
228
+ value: 500,
229
+ },
230
+ },
231
+ spacing: 8,
232
+ type: "stack",
233
+ },
234
+ labels: labelsData,
235
+ type: "package",
236
+ }}
237
+ />
@@ -0,0 +1,25 @@
1
+ import Footer from "./Footer.svelte";
2
+ export declare const labelsData: {
3
+ en_US: {
4
+ "BcX-6YwhoV": string;
5
+ QZ4ZmYsqjN: string;
6
+ };
7
+ };
8
+ 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
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
10
+ $$bindings?: Bindings;
11
+ } & Exports;
12
+ (internal: unknown, props: {
13
+ $$events?: Events;
14
+ $$slots?: Slots;
15
+ }): Exports & {
16
+ $set?: any;
17
+ $on?: any;
18
+ };
19
+ z_$$bindings?: Bindings;
20
+ }
21
+ declare const Footer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
22
+ [evt: string]: CustomEvent<any>;
23
+ }, {}, {}, string>;
24
+ type Footer = InstanceType<typeof Footer>;
25
+ export default Footer;
@@ -0,0 +1,11 @@
1
+ <script lang="ts">
2
+ import type { FooterProps } from "../../data/entities";
3
+ import Stack from "../stack/Stack.svelte";
4
+
5
+ const props: FooterProps = $props();
6
+ const { stack, labels, id } = $derived(props);
7
+ </script>
8
+
9
+ <div class="footer" {id}>
10
+ <Stack {...stack} {labels} />
11
+ </div>
@@ -0,0 +1,3 @@
1
+ import type { FooterProps } from "../../data/entities";
2
+ declare const Footer: import("svelte").Component<FooterProps, {}, "">;
3
+ export default Footer;