@revenuecat/purchases-ui-js 0.0.16 → 0.0.17

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 (51) hide show
  1. package/dist/components/button/Button.svelte.d.ts +4 -2
  2. package/dist/components/button/ButtonNode.stories.svelte +2 -4
  3. package/dist/components/button/ButtonNode.svelte.d.ts +1 -0
  4. package/dist/components/footer/Footer.stories.svelte +46 -156
  5. package/dist/components/footer/Footer.stories.svelte.d.ts +1 -2
  6. package/dist/components/footer/Footer.svelte +9 -0
  7. package/dist/components/footer/Footer.svelte.d.ts +1 -0
  8. package/dist/components/image/Image.stories.svelte +9 -7
  9. package/dist/components/image/Image.svelte +18 -3
  10. package/dist/components/image/Image.svelte.d.ts +1 -0
  11. package/dist/components/image/image-utils.js +3 -3
  12. package/dist/components/package/Package.stories.svelte +0 -2
  13. package/dist/components/package/Package.svelte.d.ts +1 -0
  14. package/dist/components/paywall/Node.svelte +8 -1
  15. package/dist/components/paywall/Node.svelte.d.ts +4 -2
  16. package/dist/components/paywall/Paywall.stories.svelte +79 -15
  17. package/dist/components/paywall/Paywall.svelte +41 -22
  18. package/dist/components/paywall/Paywall.svelte.d.ts +4 -0
  19. package/dist/components/purchase-button/PurchaseButton.stories.svelte +0 -2
  20. package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +1 -0
  21. package/dist/components/stack/Stack.stories.svelte +0 -2
  22. package/dist/components/stack/Stack.svelte +3 -0
  23. package/dist/components/stack/Stack.svelte.d.ts +1 -0
  24. package/dist/components/stack/stack-utils.js +3 -3
  25. package/dist/components/text/Text.svelte.d.ts +4 -2
  26. package/dist/components/text/TextNode.stories.svelte +1 -2
  27. package/dist/components/text/TextNode.svelte +5 -12
  28. package/dist/components/text/TextNode.svelte.d.ts +1 -0
  29. package/dist/components/text/text-utils.d.ts +3 -0
  30. package/dist/components/text/text-utils.js +9 -9
  31. package/dist/components/timeline/Timeline.stories.svelte +640 -0
  32. package/dist/components/timeline/Timeline.stories.svelte.d.ts +19 -0
  33. package/dist/components/timeline/Timeline.svelte +40 -0
  34. package/dist/components/timeline/Timeline.svelte.d.ts +4 -0
  35. package/dist/components/timeline/TimelineItem.svelte +100 -0
  36. package/dist/components/timeline/TimelineItem.svelte.d.ts +4 -0
  37. package/dist/components/timeline/timeline-utils.d.ts +25 -0
  38. package/dist/components/timeline/timeline-utils.js +93 -0
  39. package/dist/data/entities.d.ts +57 -8
  40. package/dist/data/state.d.ts +2 -0
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.js +1 -0
  43. package/dist/stories/fixtures.d.ts +5 -1
  44. package/dist/stories/fixtures.js +2958 -1
  45. package/dist/stories/meta-templates.d.ts +0 -1
  46. package/dist/stories/meta-templates.js +0 -5
  47. package/dist/types.d.ts +12 -4
  48. package/dist/types.js +7 -0
  49. package/dist/utils/style-utils.d.ts +34 -2
  50. package/dist/utils/style-utils.js +77 -8
  51. package/package.json +25 -24
@@ -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,7 @@
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 { SupportedActions } from "../../data/entities";
6
5
 
7
6
  const onAction = (action: SupportedActions) => {
8
7
  alert(action.type);
@@ -30,7 +29,6 @@
30
29
  },
31
30
  },
32
31
  },
33
- colorMode: colorModeStoryMeta,
34
32
  stack: {
35
33
  control: { type: "object" },
36
34
  description: "Stack configuration for button content",
@@ -47,6 +45,7 @@
47
45
  const purchaseState = {
48
46
  locale: "en_US",
49
47
  defaultLocale: "en_US",
48
+ colorMode: "light",
50
49
  };
51
50
 
52
51
  export const labelsData = {
@@ -78,7 +77,6 @@
78
77
  margin: { top: 0, trailing: 0, bottom: 0, leading: 0 },
79
78
  padding: { top: 0, trailing: 0, bottom: 0, leading: 0 },
80
79
  labels: labelsData,
81
- colorMode: "light",
82
80
  size: {
83
81
  width: { type: "fit" },
84
82
  height: { type: "fit" },
@@ -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;
@@ -1,96 +1,68 @@
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
- labels: labelsData,
57
- border: {
58
- color: {
59
- light: {
60
- type: "hex",
61
- value: "#3b393f",
62
- },
63
- },
64
- width: 1,
65
- },
39
+ border: undefined,
66
40
  components: [
67
41
  {
68
42
  background_color: null,
69
43
  color: {
70
44
  light: {
71
45
  type: "hex",
72
- value: "#ffffff",
46
+ value: "#ffffffFF",
73
47
  },
74
48
  },
75
- labels: labelsData,
76
- components: [],
77
49
  font_name: null,
78
- font_size: "heading_s",
79
- font_weight: "bold",
50
+ font_size: "body_m",
51
+ font_weight: "extra_bold",
80
52
  horizontal_alignment: "center",
81
- id: "aSK4Jf1zd4",
53
+ id: "pFC3qrx4-c",
82
54
  margin: {
83
55
  bottom: 0,
84
56
  leading: 0,
85
57
  top: 0,
86
58
  trailing: 0,
87
59
  },
88
- name: "Text",
60
+ name: "",
89
61
  padding: {
90
- bottom: 0,
91
- leading: 0,
92
- top: 0,
93
- trailing: 0,
62
+ bottom: 10,
63
+ leading: 10,
64
+ top: 10,
65
+ trailing: 10,
94
66
  },
95
67
  size: {
96
68
  height: {
@@ -98,124 +70,43 @@
98
70
  value: null,
99
71
  },
100
72
  width: {
101
- type: "fit",
73
+ type: "fill",
102
74
  value: null,
103
75
  },
104
76
  },
105
- text_lid: "BcX-6YwhoV",
77
+ text_lid: "GM2Sytqd5p",
106
78
  type: "text",
107
79
  },
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
80
  ],
201
81
  dimension: {
202
- alignment: "center",
82
+ alignment: "top",
203
83
  distribution: "space_between",
204
- type: "horizontal",
84
+ type: "vertical",
205
85
  },
206
- id: "u0KZLUZTQT",
86
+ id: "yI_0xF4hlJ",
207
87
  margin: {
208
88
  bottom: 0,
209
- leading: 16,
210
- top: 16,
211
- trailing: 16,
89
+ leading: 0,
90
+ top: 0,
91
+ trailing: 0,
212
92
  },
213
- name: "Stack",
93
+ name: "Footer",
214
94
  padding: {
215
- bottom: 16,
216
- leading: 16,
217
- top: 16,
218
- trailing: 16,
95
+ bottom: 0,
96
+ leading: 0,
97
+ top: 0,
98
+ trailing: 0,
99
+ },
100
+ shadow: {
101
+ color: {
102
+ light: {
103
+ type: "hex",
104
+ value: "#00000033",
105
+ },
106
+ },
107
+ radius: 16,
108
+ x: 0,
109
+ y: -4,
219
110
  },
220
111
  shape: {
221
112
  corners: {
@@ -229,17 +120,16 @@
229
120
  size: {
230
121
  height: {
231
122
  type: "fit",
232
- value: null,
233
123
  },
234
124
  width: {
235
- type: "fixed",
236
- value: 500,
125
+ type: "fill",
237
126
  },
238
127
  },
239
- spacing: 8,
128
+ spacing: 0,
240
129
  type: "stack",
241
130
  },
131
+ type: "footer",
132
+ purchaseState: purchaseState,
242
133
  labels: labelsData,
243
- type: "package",
244
134
  }}
245
135
  />
@@ -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> {
@@ -9,3 +9,12 @@
9
9
  <div class="footer" {id}>
10
10
  <Stack {...stack} {labels} {purchaseState} {variableDictionary} />
11
11
  </div>
12
+
13
+ <style>
14
+ .footer {
15
+ position: absolute;
16
+ bottom: 0;
17
+ left: 0;
18
+ right: 0;
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,10 @@
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
+
5
+ const purchaseState = {
6
+ colorMode: "light",
7
+ };
5
8
 
6
9
  const { Story } = defineMeta({
7
10
  title: "Components/Image",
@@ -13,7 +16,6 @@
13
16
  control: "object",
14
17
  description: "Gradient colors for the overlay",
15
18
  },
16
- colorMode: colorModeStoryMeta,
17
19
  size: {
18
20
  control: "object",
19
21
  description: "Size configuration for the image",
@@ -39,6 +41,7 @@
39
41
  <Story
40
42
  name="Rectangle"
41
43
  args={{
44
+ purchaseState,
42
45
  id: "example-id",
43
46
  fit_mode: "fit",
44
47
  size: {
@@ -54,7 +57,6 @@
54
57
  webp_low_res: "https://placehold.co/600x400",
55
58
  },
56
59
  },
57
- colorMode: "light",
58
60
  mask_shape: { type: "rectangle" },
59
61
  }}
60
62
  />
@@ -62,6 +64,7 @@
62
64
  <Story
63
65
  name="Circle"
64
66
  args={{
67
+ purchaseState,
65
68
  id: "example-id",
66
69
  fit_mode: "fit",
67
70
  size: {
@@ -77,7 +80,6 @@
77
80
  webp_low_res: "https://placehold.co/600x400",
78
81
  },
79
82
  },
80
- colorMode: "light",
81
83
  mask_shape: { type: "circle" },
82
84
  }}
83
85
  />
@@ -85,6 +87,7 @@
85
87
  <Story
86
88
  name="Concave"
87
89
  args={{
90
+ purchaseState,
88
91
  id: "example-id",
89
92
  fit_mode: "fit",
90
93
  size: {
@@ -100,7 +103,6 @@
100
103
  webp_low_res: "https://placehold.co/600x400",
101
104
  },
102
105
  },
103
- colorMode: "light",
104
106
  mask_shape: { type: "concave" },
105
107
  }}
106
108
  />
@@ -108,6 +110,7 @@
108
110
  <Story
109
111
  name="Convex"
110
112
  args={{
113
+ purchaseState,
111
114
  id: "example-id",
112
115
  fit_mode: "fit",
113
116
  size: {
@@ -123,7 +126,6 @@
123
126
  webp_low_res: "https://placehold.co/600x400",
124
127
  },
125
128
  },
126
- colorMode: "light",
127
129
  mask_shape: { type: "convex" },
128
130
  }}
129
131
  />
@@ -131,6 +133,7 @@
131
133
  <Story
132
134
  name="Background Gradient"
133
135
  args={{
136
+ purchaseState,
134
137
  id: "example-id",
135
138
  fit_mode: "fit",
136
139
  size: {
@@ -146,7 +149,6 @@
146
149
  webp_low_res: "https://placehold.co/600x400",
147
150
  },
148
151
  },
149
- colorMode: "light",
150
152
  gradient_colors: [
151
153
  {
152
154
  dark: { type: "hex", value: "#FFFFFF80" },
@@ -3,13 +3,28 @@
3
3
  import { stringifyStyles } from "../../utils/style-utils";
4
4
  import type { ImageProps } from "../../data/entities";
5
5
 
6
- const { id, colorMode, source, ...restProps }: ImageProps = $props();
6
+ const { id, source, purchaseState, ...restProps }: ImageProps = $props();
7
7
 
8
8
  const { gradientStyles, imageStyles } = $derived(
9
- getImageComponentStyles({ id, colorMode, source, ...restProps }),
9
+ getImageComponentStyles({
10
+ id,
11
+ colorMode: purchaseState.colorMode,
12
+ source,
13
+ purchaseState,
14
+ ...restProps,
15
+ }),
10
16
  );
11
17
  const gradientStylesString = $derived(stringifyStyles(gradientStyles));
12
18
  const imageStylesString = $derived(stringifyStyles(imageStyles));
19
+
20
+ const imageSource = $derived.by(() => {
21
+ const colorMode = purchaseState.colorMode;
22
+ if (source[colorMode]?.original) {
23
+ return source[colorMode].original;
24
+ } else {
25
+ return source["light"].original as string;
26
+ }
27
+ });
13
28
  </script>
14
29
 
15
30
  <div
@@ -17,7 +32,7 @@
17
32
  id={`image-container-${id}`}
18
33
  style={imageStylesString}
19
34
  >
20
- <img class="image" src={source[colorMode || "light"]?.original} alt="" {id} />
35
+ <img class="image" src={imageSource} alt="" {id} />
21
36
  <span class="image-overlay" style={gradientStylesString}></span>
22
37
  </div>
23
38
 
@@ -1,3 +1,4 @@
1
1
  import type { ImageProps } from "../../data/entities";
2
2
  declare const Image: import("svelte").Component<ImageProps, {}, "">;
3
+ type Image = ReturnType<typeof Image>;
3
4
  export default Image;
@@ -5,12 +5,12 @@ import { getActiveStateProps, getGradientStyle, getMaskStyle, getSizeStyle, } fr
5
5
  * @returns Object containing image style variables and gradient style variables
6
6
  */
7
7
  export const getImageComponentStyles = (props) => {
8
- const { gradient_colors, colorMode, mask_shape, size,
8
+ const { gradient_colors, mask_shape, size,
9
9
  // max_height, // TODO: implement this. still waiting on spec
10
10
  // override_source_lid, // TODO: Implement this once structure is defined
11
- overrides, componentState, } = props;
11
+ overrides, componentState, purchaseState, } = props;
12
12
  const activeStateProps = getActiveStateProps(overrides, componentState);
13
- const gradientStyles = getGradientStyle(colorMode, activeStateProps?.gradient_colors || gradient_colors);
13
+ const gradientStyles = getGradientStyle(purchaseState.colorMode, activeStateProps?.gradient_colors || gradient_colors);
14
14
  const sizeStyles = getSizeStyle({ ...size, ...activeStateProps });
15
15
  const maskStyles = getMaskStyle({
16
16
  ...mask_shape,
@@ -1,7 +1,6 @@
1
1
  <script module lang="ts">
2
2
  import { defineMeta } from "@storybook/addon-svelte-csf";
3
3
  import Package from "./Package.svelte";
4
- import { colorModeStoryMeta } from "../../stories/meta-templates";
5
4
  import type { Extra, SupportedActions } from "../../data/entities";
6
5
 
7
6
  const onAction = (action: SupportedActions, data: Extra) => {
@@ -13,7 +12,6 @@
13
12
  component: Package,
14
13
  tags: ["autodocs"],
15
14
  argTypes: {
16
- colorMode: colorModeStoryMeta,
17
15
  stack: {
18
16
  control: { type: "object" },
19
17
  description: "Stack configuration for package content",
@@ -1,3 +1,4 @@
1
1
  import type { PackageProps } from "../../data/entities";
2
2
  declare const Package: import("svelte").Component<PackageProps, {}, "">;
3
+ type Package = ReturnType<typeof Package>;
3
4
  export default Package;
@@ -13,6 +13,7 @@
13
13
  import ButtonNode from "../button/ButtonNode.svelte";
14
14
  import TextNode from "../text/TextNode.svelte";
15
15
  import type { VariableDictionary } from "../../utils/variable-utils";
16
+ import Timeline from "../timeline/Timeline.svelte";
16
17
 
17
18
  interface Props extends ActionsProps, PurchaseStateProps {
18
19
  nodeData: PaywallComponent;
@@ -37,7 +38,13 @@
37
38
  purchase_button: PurchaseButton,
38
39
  package: Package,
39
40
  footer: Footer,
41
+ timeline: Timeline,
40
42
  };
43
+ if (!ComponentTypes[nodeData.type]) {
44
+ // manually throwing error for this specific case until
45
+ // it's handled with fallback components
46
+ throw new Error(`Invalid component type: ${nodeData.type}`);
47
+ }
41
48
  const MyComponent = $derived(ComponentTypes[nodeData.type]);
42
49
  </script>
43
50
 
@@ -49,7 +56,7 @@
49
56
  {purchaseState}
50
57
  {variableDictionary}
51
58
  >
52
- {#each nodeData.components as childData}
59
+ {#each nodeData.components as PaywallComponent[] as childData}
53
60
  <Self
54
61
  nodeData={childData}
55
62
  {labels}
@@ -1,9 +1,11 @@
1
1
  import { type ActionsProps, type ComponentLocalizations, type Extra, type PaywallComponent, type PurchaseStateProps, type SupportedActions } from "../../data/entities";
2
2
  import type { VariableDictionary } from "../../utils/variable-utils";
3
- declare const Node: import("svelte").Component<ActionsProps & PurchaseStateProps & {
3
+ interface Props extends ActionsProps, PurchaseStateProps {
4
4
  nodeData: PaywallComponent;
5
5
  labels: ComponentLocalizations;
6
6
  onAction?: (action: SupportedActions, data?: Extra) => void;
7
7
  variableDictionary?: VariableDictionary;
8
- }, {}, "">;
8
+ }
9
+ declare const Node: import("svelte").Component<Props, {}, "">;
10
+ type Node = ReturnType<typeof Node>;
9
11
  export default Node;