@revenuecat/purchases-ui-js 0.0.16 → 0.0.18

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 (67) hide show
  1. package/dist/components/button/Button.svelte +0 -13
  2. package/dist/components/button/Button.svelte.d.ts +4 -2
  3. package/dist/components/button/ButtonNode.stories.svelte +16 -11
  4. package/dist/components/button/ButtonNode.svelte +26 -1
  5. package/dist/components/button/ButtonNode.svelte.d.ts +1 -0
  6. package/dist/components/button/button-utils.d.ts +2 -0
  7. package/dist/components/button/button-utils.js +19 -0
  8. package/dist/components/footer/Footer.stories.svelte +47 -155
  9. package/dist/components/footer/Footer.stories.svelte.d.ts +1 -2
  10. package/dist/components/footer/Footer.svelte +10 -1
  11. package/dist/components/footer/Footer.svelte.d.ts +1 -0
  12. package/dist/components/image/Image.stories.svelte +13 -7
  13. package/dist/components/image/Image.svelte +37 -19
  14. package/dist/components/image/Image.svelte.d.ts +1 -0
  15. package/dist/components/image/image-utils.d.ts +2 -12
  16. package/dist/components/image/image-utils.js +28 -11
  17. package/dist/components/package/Package.stories.svelte +5 -5
  18. package/dist/components/package/Package.svelte +15 -6
  19. package/dist/components/package/Package.svelte.d.ts +1 -0
  20. package/dist/components/paywall/Node.svelte +77 -17
  21. package/dist/components/paywall/Node.svelte.d.ts +21 -2
  22. package/dist/components/paywall/Paywall.stories.svelte +93 -15
  23. package/dist/components/paywall/Paywall.svelte +110 -88
  24. package/dist/components/paywall/Paywall.svelte.d.ts +4 -0
  25. package/dist/components/paywall/paywall-utils.d.ts +1 -1
  26. package/dist/components/paywall/paywall-utils.js +11 -9
  27. package/dist/components/purchase-button/PurchaseButton.stories.svelte +7 -8
  28. package/dist/components/purchase-button/PurchaseButton.svelte +24 -10
  29. package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +1 -0
  30. package/dist/components/purchase-button/purchase-button-utils.d.ts +2 -0
  31. package/dist/components/purchase-button/purchase-button-utils.js +20 -0
  32. package/dist/components/stack/Stack.stories.svelte +1138 -6
  33. package/dist/components/stack/Stack.svelte +160 -42
  34. package/dist/components/stack/Stack.svelte.d.ts +1 -0
  35. package/dist/components/stack/stack-utils.d.ts +24 -24
  36. package/dist/components/stack/stack-utils.js +245 -12
  37. package/dist/components/text/Text.svelte +24 -19
  38. package/dist/components/text/Text.svelte.d.ts +4 -2
  39. package/dist/components/text/TextNode.stories.svelte +13 -13
  40. package/dist/components/text/TextNode.svelte +24 -34
  41. package/dist/components/text/TextNode.svelte.d.ts +1 -0
  42. package/dist/components/text/text-utils.d.ts +11 -14
  43. package/dist/components/text/text-utils.js +130 -15
  44. package/dist/components/timeline/Timeline.stories.svelte +640 -0
  45. package/dist/components/timeline/Timeline.stories.svelte.d.ts +19 -0
  46. package/dist/components/timeline/Timeline.svelte +40 -0
  47. package/dist/components/timeline/Timeline.svelte.d.ts +4 -0
  48. package/dist/components/timeline/TimelineItem.svelte +112 -0
  49. package/dist/components/timeline/TimelineItem.svelte.d.ts +4 -0
  50. package/dist/components/timeline/timeline-utils.d.ts +8 -0
  51. package/dist/components/timeline/timeline-utils.js +128 -0
  52. package/dist/data/entities.d.ts +89 -9
  53. package/dist/data/state.d.ts +2 -0
  54. package/dist/index.d.ts +3 -2
  55. package/dist/index.js +3 -2
  56. package/dist/stories/fixtures.d.ts +7 -1
  57. package/dist/stories/fixtures.js +6898 -7
  58. package/dist/stories/meta-templates.d.ts +0 -1
  59. package/dist/stories/meta-templates.js +0 -5
  60. package/dist/types.d.ts +16 -7
  61. package/dist/types.js +7 -0
  62. package/dist/utils/style-utils.d.ts +80 -41
  63. package/dist/utils/style-utils.js +157 -70
  64. package/dist/utils/variable-utils.d.ts +27 -0
  65. package/dist/utils/variable-utils.js +37 -0
  66. package/package.json +27 -25
  67. package/dist/components/paywall/global-styles.css +0 -9
@@ -18,16 +18,3 @@
18
18
  <button onclick={handleClick} class={clz} disabled={!onclick} {style}>
19
19
  {@render children?.()}
20
20
  </button>
21
-
22
- <style>
23
- button {
24
- border: none;
25
- cursor: pointer;
26
- background: transparent;
27
- padding: 0;
28
- width: 100%;
29
- display: flex;
30
- align-items: center;
31
- justify-content: center;
32
- }
33
- </style>
@@ -1,8 +1,10 @@
1
1
  import type { Snippet } from "svelte";
2
- declare const Button: import("svelte").Component<{
2
+ interface ButtonProps {
3
3
  onclick?: () => void;
4
4
  children?: Snippet;
5
5
  style?: string;
6
6
  class?: string;
7
- }, {}, "">;
7
+ }
8
+ declare const Button: import("svelte").Component<ButtonProps, {}, "">;
9
+ type Button = ReturnType<typeof Button>;
8
10
  export default Button;
@@ -1,8 +1,13 @@
1
1
  <script module lang="ts">
2
2
  import { defineMeta } from "@storybook/addon-svelte-csf";
3
3
  import ButtonNode from "./ButtonNode.svelte";
4
- import { colorModeStoryMeta } from "../../stories/meta-templates";
5
- import type { SupportedActions, TextNodeProps } from "../../data/entities";
4
+ import type {
5
+ ComponentTypes,
6
+ StackProps,
7
+ SupportedActions,
8
+ } from "../../data/entities";
9
+ import type { PurchaseState } from "../../data/state";
10
+ import type { ColorMode } from "../../types";
6
11
 
7
12
  const onAction = (action: SupportedActions) => {
8
13
  alert(action.type);
@@ -30,7 +35,6 @@
30
35
  },
31
36
  },
32
37
  },
33
- colorMode: colorModeStoryMeta,
34
38
  stack: {
35
39
  control: { type: "object" },
36
40
  description: "Stack configuration for button content",
@@ -44,9 +48,10 @@
44
48
  },
45
49
  });
46
50
 
47
- const purchaseState = {
51
+ const purchaseState: PurchaseState = {
48
52
  locale: "en_US",
49
53
  defaultLocale: "en_US",
54
+ colorMode: "light" as ColorMode,
50
55
  };
51
56
 
52
57
  export const labelsData = {
@@ -59,7 +64,7 @@
59
64
  };
60
65
 
61
66
  const textProps = (id: number) => ({
62
- type: "text",
67
+ type: "text" as ComponentTypes,
63
68
  name: "Button Text",
64
69
  components: [],
65
70
  id: "button-text-1",
@@ -78,14 +83,13 @@
78
83
  margin: { top: 0, trailing: 0, bottom: 0, leading: 0 },
79
84
  padding: { top: 0, trailing: 0, bottom: 0, leading: 0 },
80
85
  labels: labelsData,
81
- colorMode: "light",
82
86
  size: {
83
87
  width: { type: "fit" },
84
88
  height: { type: "fit" },
85
89
  },
86
90
  });
87
91
 
88
- const baseStackProps = {
92
+ const baseStackProps: Partial<StackProps> = {
89
93
  type: "stack",
90
94
  size: { width: { type: "fill" }, height: { type: "fill" } },
91
95
  labels: labelsData,
@@ -118,7 +122,8 @@
118
122
  stack: {
119
123
  ...baseStackProps,
120
124
  components: [textProps(1)],
121
- },
125
+ purchaseState,
126
+ } as StackProps,
122
127
  purchaseState: purchaseState,
123
128
  onAction,
124
129
  }}
@@ -148,7 +153,7 @@
148
153
  light: { type: "hex", value: "#2E7D32" },
149
154
  },
150
155
  components: [textProps(2)],
151
- },
156
+ } as StackProps,
152
157
  purchaseState: purchaseState,
153
158
  }}
154
159
  />
@@ -180,7 +185,7 @@
180
185
  light: { type: "hex", value: "#D32F2F" },
181
186
  },
182
187
  components: [textProps(3)],
183
- },
188
+ } as StackProps,
184
189
  purchaseState: purchaseState,
185
190
  }}
186
191
  />
@@ -207,7 +212,7 @@
207
212
  light: { type: "hex", value: "#4A90E2" },
208
213
  },
209
214
  components: [textProps(4)],
210
- },
215
+ } as StackProps,
211
216
  purchaseState: purchaseState,
212
217
  }}
213
218
  />
@@ -2,6 +2,7 @@
2
2
  import Button from "./Button.svelte";
3
3
  import type { ButtonNodeProps } from "../../data/entities";
4
4
  import Stack from "../stack/Stack.svelte";
5
+ import { getButtonStyles } from "./button-utils";
5
6
 
6
7
  const {
7
8
  stack,
@@ -10,12 +11,36 @@
10
11
  labels,
11
12
  purchaseState,
12
13
  variableDictionary,
14
+ ...restProps
13
15
  }: ButtonNodeProps = $props();
14
16
  const onClick = () => {
15
17
  onAction && onAction(action);
16
18
  };
19
+
20
+ const buttonStyles = $derived(
21
+ getButtonStyles({
22
+ stack,
23
+ action,
24
+ onAction,
25
+ labels,
26
+ purchaseState,
27
+ variableDictionary,
28
+ ...restProps,
29
+ }),
30
+ );
17
31
  </script>
18
32
 
19
- <Button onclick={onClick}>
33
+ <Button onclick={onClick} style={buttonStyles} class={"rc-pw-button"}>
20
34
  <Stack {...stack} {labels} {purchaseState} {variableDictionary} />
21
35
  </Button>
36
+
37
+ <style>
38
+ .rc-pw-button {
39
+ display: flex;
40
+ margin: 0;
41
+ padding: 0;
42
+ background: initial;
43
+ border: initial;
44
+ text-align: initial;
45
+ }
46
+ </style>
@@ -1,3 +1,4 @@
1
1
  import type { ButtonNodeProps } from "../../data/entities";
2
2
  declare const ButtonNode: import("svelte").Component<ButtonNodeProps, {}, "">;
3
+ type ButtonNode = ReturnType<typeof ButtonNode>;
3
4
  export default ButtonNode;
@@ -0,0 +1,2 @@
1
+ import type { ButtonNodeProps } from "../../data/entities";
2
+ export declare function getButtonStyles({ stack, zStackChildStyles }: ButtonNodeProps): string;
@@ -0,0 +1,19 @@
1
+ import { prefixObject, stringifyStyles } from "../../utils/style-utils";
2
+ export function getButtonStyles({ stack, zStackChildStyles }) {
3
+ // Get the width of the inner stack to adjust to the outer button wrapper
4
+ const width = stack?.size?.width?.type === "fill" ? "100%" : "fit-content";
5
+ // Define set of variables to be assigned to the button
6
+ // Define width as an inline style
7
+ const prefixedObject = prefixObject(zStackChildStyles || {}, "button");
8
+ const assignedVariables = {
9
+ position: "var(--button-position, relative)",
10
+ inset: "var(--button-inset, 0)",
11
+ transform: "var(--button-transform, initial)",
12
+ width,
13
+ };
14
+ const buttonInlineStyles = stringifyStyles({
15
+ ...prefixedObject,
16
+ ...assignedVariables,
17
+ });
18
+ return buttonInlineStyles;
19
+ }
@@ -1,96 +1,70 @@
1
1
  <script module lang="ts">
2
2
  import { defineMeta } from "@storybook/addon-svelte-csf";
3
3
  import Footer from "./Footer.svelte";
4
- import { colorModeStoryMeta } from "../../stories/meta-templates";
4
+ import type { ColorMode } from "../../types";
5
5
 
6
6
  const purchaseState = {
7
7
  locale: "en_US",
8
8
  defaultLocale: "en_US",
9
+ colorMode: "light" as ColorMode,
9
10
  };
10
11
 
11
12
  const { Story } = defineMeta({
12
13
  title: "Components/Footer",
13
14
  component: Footer,
14
15
  tags: ["autodocs"],
15
- argTypes: {
16
- colorMode: colorModeStoryMeta,
17
-
18
- stack: {
19
- control: { type: "object" },
20
- description: "Stack configuration for package content",
21
- table: {
22
- type: {
23
- summary: "object",
24
- detail: "StackProps",
25
- },
26
- },
27
- },
28
- },
16
+ argTypes: {},
29
17
  });
30
18
 
31
19
  export const labelsData = {
32
20
  en_US: {
33
- "BcX-6YwhoV": "Monthly",
34
- QZ4ZmYsqjN: "$1.99",
21
+ GM2Sytqd5p: "Do it now before you regret it!",
35
22
  },
36
23
  };
37
24
  </script>
38
25
 
39
26
  <!-- Default -->
40
27
  <Story
41
- name="Default Package"
28
+ name="Footer component"
42
29
  args={{
43
- id: "6rQSD5e2Kz",
44
- is_selected_by_default: false,
45
- name: "Package - Monthly",
46
- package_id: "$rc_annual",
47
- purchaseState: purchaseState,
30
+ id: "kHhCWlo9au",
31
+ name: "",
48
32
  stack: {
49
- purchaseState: purchaseState,
50
33
  background_color: {
51
34
  light: {
52
35
  type: "hex",
53
- value: "#09090b",
36
+ value: "#6c6c6cFF",
54
37
  },
55
38
  },
56
39
  labels: labelsData,
57
- border: {
58
- color: {
59
- light: {
60
- type: "hex",
61
- value: "#3b393f",
62
- },
63
- },
64
- width: 1,
65
- },
40
+ purchaseState,
41
+ border: undefined,
66
42
  components: [
67
43
  {
68
44
  background_color: null,
69
45
  color: {
70
46
  light: {
71
47
  type: "hex",
72
- value: "#ffffff",
48
+ value: "#ffffffFF",
73
49
  },
74
50
  },
75
- labels: labelsData,
76
- components: [],
77
51
  font_name: null,
78
- font_size: "heading_s",
79
- font_weight: "bold",
52
+ font_size: "body_m",
53
+ font_weight: "extra_bold",
80
54
  horizontal_alignment: "center",
81
- id: "aSK4Jf1zd4",
55
+ id: "pFC3qrx4-c",
82
56
  margin: {
83
57
  bottom: 0,
84
58
  leading: 0,
85
59
  top: 0,
86
60
  trailing: 0,
87
61
  },
88
- name: "Text",
62
+ name: "",
89
63
  padding: {
90
- bottom: 0,
91
- leading: 0,
92
- top: 0,
93
- trailing: 0,
64
+ bottom: 10,
65
+ leading: 10,
66
+ top: 10,
67
+ trailing: 10,
94
68
  },
95
69
  size: {
96
70
  height: {
@@ -98,124 +72,43 @@
98
72
  value: null,
99
73
  },
100
74
  width: {
101
- type: "fit",
75
+ type: "fill",
102
76
  value: null,
103
77
  },
104
78
  },
105
- text_lid: "BcX-6YwhoV",
79
+ text_lid: "GM2Sytqd5p",
106
80
  type: "text",
107
81
  },
108
- {
109
- background_color: {
110
- light: {
111
- type: "hex",
112
- value: "#292631",
113
- },
114
- },
115
- labels: labelsData,
116
- border: null,
117
- components: [
118
- {
119
- background_color: null,
120
- color: {
121
- light: {
122
- type: "hex",
123
- value: "#ffffff",
124
- },
125
- },
126
- components: [],
127
- font_name: null,
128
- font_size: "body_m",
129
- font_weight: "extra_bold",
130
- horizontal_alignment: "center",
131
- id: "unosKAXGp4",
132
- margin: {
133
- bottom: 0,
134
- leading: 0,
135
- top: 0,
136
- trailing: 0,
137
- },
138
- name: "Text",
139
- padding: {
140
- bottom: 8,
141
- leading: 16,
142
- top: 8,
143
- trailing: 16,
144
- },
145
- size: {
146
- height: {
147
- type: "fit",
148
- value: null,
149
- },
150
- width: {
151
- type: "fit",
152
- value: null,
153
- },
154
- },
155
- text_lid: "QZ4ZmYsqjN",
156
- type: "text",
157
- },
158
- ],
159
- dimension: {
160
- alignment: "leading",
161
- distribution: "space_between",
162
- type: "vertical",
163
- },
164
- id: "-41AkrT2Ha",
165
- margin: {
166
- bottom: 0,
167
- leading: 0,
168
- top: 0,
169
- trailing: 0,
170
- },
171
- name: "Stack",
172
- padding: {
173
- bottom: 0,
174
- leading: 0,
175
- top: 0,
176
- trailing: 0,
177
- },
178
- shape: {
179
- corners: {
180
- bottom_leading: 8,
181
- bottom_trailing: 8,
182
- top_leading: 8,
183
- top_trailing: 8,
184
- },
185
- type: "rectangle",
186
- },
187
- size: {
188
- height: {
189
- type: "fit",
190
- value: null,
191
- },
192
- width: {
193
- type: "fit",
194
- value: null,
195
- },
196
- },
197
- spacing: 8,
198
- type: "stack",
199
- },
200
82
  ],
201
83
  dimension: {
202
- alignment: "center",
84
+ alignment: "top",
203
85
  distribution: "space_between",
204
- type: "horizontal",
86
+ type: "vertical",
205
87
  },
206
- id: "u0KZLUZTQT",
88
+ id: "yI_0xF4hlJ",
207
89
  margin: {
208
90
  bottom: 0,
209
- leading: 16,
210
- top: 16,
211
- trailing: 16,
91
+ leading: 0,
92
+ top: 0,
93
+ trailing: 0,
212
94
  },
213
- name: "Stack",
95
+ name: "Footer",
214
96
  padding: {
215
- bottom: 16,
216
- leading: 16,
217
- top: 16,
218
- trailing: 16,
97
+ bottom: 0,
98
+ leading: 0,
99
+ top: 0,
100
+ trailing: 0,
101
+ },
102
+ shadow: {
103
+ color: {
104
+ light: {
105
+ type: "hex",
106
+ value: "#00000033",
107
+ },
108
+ },
109
+ radius: 16,
110
+ x: 0,
111
+ y: -4,
219
112
  },
220
113
  shape: {
221
114
  corners: {
@@ -229,17 +122,16 @@
229
122
  size: {
230
123
  height: {
231
124
  type: "fit",
232
- value: null,
233
125
  },
234
126
  width: {
235
- type: "fixed",
236
- value: 500,
127
+ type: "fill",
237
128
  },
238
129
  },
239
- spacing: 8,
130
+ spacing: 0,
240
131
  type: "stack",
241
132
  },
133
+ type: "footer",
134
+ purchaseState: purchaseState,
242
135
  labels: labelsData,
243
- type: "package",
244
136
  }}
245
137
  />
@@ -1,8 +1,7 @@
1
1
  import Footer from "./Footer.svelte";
2
2
  export declare const labelsData: {
3
3
  en_US: {
4
- "BcX-6YwhoV": string;
5
- QZ4ZmYsqjN: string;
4
+ GM2Sytqd5p: string;
6
5
  };
7
6
  };
8
7
  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> {
@@ -6,6 +6,15 @@
6
6
  $props();
7
7
  </script>
8
8
 
9
- <div class="footer" {id}>
9
+ <div class="rc-pw-footer" {id}>
10
10
  <Stack {...stack} {labels} {purchaseState} {variableDictionary} />
11
11
  </div>
12
+
13
+ <style>
14
+ .rc-pw-footer {
15
+ position: sticky;
16
+ bottom: 0;
17
+ transform: translateY(50%);
18
+ width: 100%;
19
+ }
20
+ </style>
@@ -1,3 +1,4 @@
1
1
  import type { FooterProps } from "../../data/entities";
2
2
  declare const Footer: import("svelte").Component<FooterProps, {}, "">;
3
+ type Footer = ReturnType<typeof Footer>;
3
4
  export default Footer;
@@ -1,7 +1,14 @@
1
1
  <script module lang="ts">
2
2
  import { defineMeta } from "@storybook/addon-svelte-csf";
3
3
  import Image from "./Image.svelte";
4
- import { colorModeStoryMeta } from "../../stories/meta-templates";
4
+ import type { PurchaseState } from "../../data/state";
5
+ import type { ColorMode } from "../../types";
6
+
7
+ const purchaseState: PurchaseState = {
8
+ colorMode: "light" as ColorMode,
9
+ locale: "en_US",
10
+ defaultLocale: "en_US",
11
+ };
5
12
 
6
13
  const { Story } = defineMeta({
7
14
  title: "Components/Image",
@@ -13,7 +20,6 @@
13
20
  control: "object",
14
21
  description: "Gradient colors for the overlay",
15
22
  },
16
- colorMode: colorModeStoryMeta,
17
23
  size: {
18
24
  control: "object",
19
25
  description: "Size configuration for the image",
@@ -39,6 +45,7 @@
39
45
  <Story
40
46
  name="Rectangle"
41
47
  args={{
48
+ purchaseState,
42
49
  id: "example-id",
43
50
  fit_mode: "fit",
44
51
  size: {
@@ -54,7 +61,6 @@
54
61
  webp_low_res: "https://placehold.co/600x400",
55
62
  },
56
63
  },
57
- colorMode: "light",
58
64
  mask_shape: { type: "rectangle" },
59
65
  }}
60
66
  />
@@ -62,6 +68,7 @@
62
68
  <Story
63
69
  name="Circle"
64
70
  args={{
71
+ purchaseState,
65
72
  id: "example-id",
66
73
  fit_mode: "fit",
67
74
  size: {
@@ -77,7 +84,6 @@
77
84
  webp_low_res: "https://placehold.co/600x400",
78
85
  },
79
86
  },
80
- colorMode: "light",
81
87
  mask_shape: { type: "circle" },
82
88
  }}
83
89
  />
@@ -85,6 +91,7 @@
85
91
  <Story
86
92
  name="Concave"
87
93
  args={{
94
+ purchaseState,
88
95
  id: "example-id",
89
96
  fit_mode: "fit",
90
97
  size: {
@@ -100,7 +107,6 @@
100
107
  webp_low_res: "https://placehold.co/600x400",
101
108
  },
102
109
  },
103
- colorMode: "light",
104
110
  mask_shape: { type: "concave" },
105
111
  }}
106
112
  />
@@ -108,6 +114,7 @@
108
114
  <Story
109
115
  name="Convex"
110
116
  args={{
117
+ purchaseState,
111
118
  id: "example-id",
112
119
  fit_mode: "fit",
113
120
  size: {
@@ -123,7 +130,6 @@
123
130
  webp_low_res: "https://placehold.co/600x400",
124
131
  },
125
132
  },
126
- colorMode: "light",
127
133
  mask_shape: { type: "convex" },
128
134
  }}
129
135
  />
@@ -131,6 +137,7 @@
131
137
  <Story
132
138
  name="Background Gradient"
133
139
  args={{
140
+ purchaseState,
134
141
  id: "example-id",
135
142
  fit_mode: "fit",
136
143
  size: {
@@ -146,7 +153,6 @@
146
153
  webp_low_res: "https://placehold.co/600x400",
147
154
  },
148
155
  },
149
- colorMode: "light",
150
156
  gradient_colors: [
151
157
  {
152
158
  dark: { type: "hex", value: "#FFFFFF80" },