@revenuecat/purchases-ui-js 2.0.2 → 2.0.3

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 (127) hide show
  1. package/dist/components/button/ButtonNode.stories.svelte +66 -102
  2. package/dist/components/button/ButtonNode.svelte +2 -27
  3. package/dist/components/footer/Footer.stories.svelte +112 -102
  4. package/dist/components/footer/Footer.svelte +8 -4
  5. package/dist/components/icon/Icon.stories.svelte +100 -0
  6. package/dist/components/icon/Icon.stories.svelte.d.ts +19 -0
  7. package/dist/components/icon/Icon.svelte +73 -0
  8. package/dist/components/icon/Icon.svelte.d.ts +4 -0
  9. package/dist/components/image/ClipPath.svelte +49 -0
  10. package/dist/components/image/ClipPath.svelte.d.ts +9 -0
  11. package/dist/components/image/Image.stories.svelte +83 -188
  12. package/dist/components/image/Image.svelte +152 -136
  13. package/dist/components/image/Image.svelte.d.ts +1 -1
  14. package/dist/components/image/Overlay.svelte +36 -0
  15. package/dist/components/image/Overlay.svelte.d.ts +8 -0
  16. package/dist/components/package/Package.stories.svelte +10 -21
  17. package/dist/components/package/Package.svelte +8 -35
  18. package/dist/components/paywall/Node.svelte +27 -28
  19. package/dist/components/paywall/Node.svelte.d.ts +3 -6
  20. package/dist/components/paywall/Paywall.stories.svelte +36 -140
  21. package/dist/components/paywall/Paywall.svelte +22 -6
  22. package/dist/components/paywall/Paywall.svelte.d.ts +3 -2
  23. package/dist/components/paywall/fixtures/override-paywall.d.ts +2 -0
  24. package/dist/components/paywall/fixtures/override-paywall.js +1310 -0
  25. package/dist/components/paywall/fixtures/stack-paywall.d.ts +2 -0
  26. package/dist/components/paywall/fixtures/stack-paywall.js +5223 -0
  27. package/dist/components/paywall/fixtures/variables.d.ts +261 -0
  28. package/dist/components/paywall/fixtures/variables.js +262 -0
  29. package/dist/components/purchase-button/PurchaseButton.stories.svelte +10 -21
  30. package/dist/components/purchase-button/PurchaseButton.svelte +2 -27
  31. package/dist/components/stack/Stack.stories.svelte +2354 -978
  32. package/dist/components/stack/Stack.svelte +111 -134
  33. package/dist/components/stack/Stack.svelte.d.ts +6 -2
  34. package/dist/components/stack/stack-utils.d.ts +10 -30
  35. package/dist/components/stack/stack-utils.js +77 -255
  36. package/dist/components/text/Text.svelte +3 -37
  37. package/dist/components/text/Text.svelte.d.ts +1 -2
  38. package/dist/components/text/TextNode.stories.svelte +10 -36
  39. package/dist/components/text/TextNode.svelte +25 -28
  40. package/dist/components/text/TextNode.svelte.d.ts +1 -1
  41. package/dist/components/text/text-utils.d.ts +4 -9
  42. package/dist/components/text/text-utils.js +32 -117
  43. package/dist/components/timeline/Timeline.stories.svelte +640 -251
  44. package/dist/components/timeline/Timeline.svelte +42 -28
  45. package/dist/components/timeline/Timeline.svelte.d.ts +1 -1
  46. package/dist/components/timeline/TimelineItem.svelte +80 -112
  47. package/dist/components/timeline/TimelineItem.svelte.d.ts +6 -2
  48. package/dist/components/timeline/timeline-utils.d.ts +24 -6
  49. package/dist/components/timeline/timeline-utils.js +21 -113
  50. package/dist/data/entities.d.ts +19 -135
  51. package/dist/index.d.ts +2 -1
  52. package/dist/index.js +2 -1
  53. package/dist/stores/color-mode.d.ts +1 -1
  54. package/dist/stores/paywall.d.ts +5 -2
  55. package/dist/stores/selected.d.ts +5 -0
  56. package/dist/stores/selected.js +12 -0
  57. package/dist/stores/variables.d.ts +1 -1
  58. package/dist/stores/variables.js +0 -1
  59. package/dist/stories/component-decorator.d.ts +2 -0
  60. package/dist/stories/component-decorator.js +12 -0
  61. package/dist/stories/fixtures.d.ts +5 -3
  62. package/dist/stories/fixtures.js +5214 -4422
  63. package/dist/stories/paywall-decorator.js +6 -0
  64. package/dist/stories/variables-decorator.d.ts +1 -1
  65. package/dist/stories/viewport-decorator.d.ts +2 -0
  66. package/dist/stories/viewport-decorator.js +8 -0
  67. package/dist/stories/viewport-wrapper.svelte +53 -0
  68. package/dist/stories/viewport-wrapper.svelte.d.ts +10 -0
  69. package/dist/stories/with-layout.d.ts +2 -10
  70. package/dist/stories/with-layout.js +3 -5
  71. package/dist/types/alignment.d.ts +5 -3
  72. package/dist/types/background.d.ts +6 -5
  73. package/dist/types/base.d.ts +7 -0
  74. package/dist/types/base.js +1 -0
  75. package/dist/types/colors.d.ts +4 -4
  76. package/dist/types/component.d.ts +6 -2
  77. package/dist/types/components/button.d.ts +4 -1
  78. package/dist/types/components/footer.d.ts +2 -1
  79. package/dist/types/components/icon.d.ts +28 -0
  80. package/dist/types/components/icon.js +1 -0
  81. package/dist/types/components/image.d.ts +20 -0
  82. package/dist/types/components/image.js +1 -0
  83. package/dist/types/components/package.d.ts +2 -1
  84. package/dist/types/components/purchase-button.d.ts +2 -1
  85. package/dist/types/components/stack.d.ts +32 -0
  86. package/dist/types/components/stack.js +1 -0
  87. package/dist/types/components/text.d.ts +20 -0
  88. package/dist/types/components/text.js +1 -0
  89. package/dist/types/components/timeline.d.ts +35 -0
  90. package/dist/types/components/timeline.js +1 -0
  91. package/dist/types/localization.d.ts +2 -1
  92. package/dist/types/media.d.ts +4 -3
  93. package/dist/types/overrides.d.ts +48 -0
  94. package/dist/types/overrides.js +1 -0
  95. package/dist/types/variables.d.ts +13 -0
  96. package/dist/types/variables.js +10 -0
  97. package/dist/types.d.ts +17 -9
  98. package/dist/ui/atoms/typography.stories.svelte +1 -27
  99. package/dist/ui/molecules/button.stories.svelte +3 -8
  100. package/dist/ui/theme/colors.d.ts +0 -6
  101. package/dist/ui/theme/colors.js +1 -1
  102. package/dist/ui/theme/text.d.ts +3 -4
  103. package/dist/ui/theme/utils.d.ts +0 -10
  104. package/dist/ui/theme/utils.js +5 -5
  105. package/dist/utils/background-utils.d.ts +4 -0
  106. package/dist/utils/background-utils.js +39 -0
  107. package/dist/utils/base-utils.d.ts +18 -0
  108. package/dist/utils/base-utils.js +124 -0
  109. package/dist/utils/constants.d.ts +2 -2
  110. package/dist/utils/constants.js +6 -1
  111. package/dist/utils/font-utils.d.ts +4 -0
  112. package/dist/utils/font-utils.js +47 -0
  113. package/dist/utils/style-utils.d.ts +7 -120
  114. package/dist/utils/style-utils.js +22 -302
  115. package/dist/utils/variable-utils.d.ts +1 -22
  116. package/dist/utils/variable-utils.js +28 -24
  117. package/dist/web-components/index.css +1 -1
  118. package/dist/web-components/index.js +1323 -895
  119. package/package.json +34 -24
  120. package/dist/components/button/button-utils.d.ts +0 -2
  121. package/dist/components/button/button-utils.js +0 -19
  122. package/dist/components/image/image-utils.d.ts +0 -19
  123. package/dist/components/image/image-utils.js +0 -33
  124. package/dist/components/purchase-button/purchase-button-utils.d.ts +0 -2
  125. package/dist/components/purchase-button/purchase-button-utils.js +0 -20
  126. package/dist/stories/meta-templates.d.ts +0 -12
  127. package/dist/stories/meta-templates.js +0 -155
@@ -0,0 +1,73 @@
1
+ <script lang="ts">
2
+ import { getColorModeContext } from "../../stores/color-mode";
3
+ import { getSelectedStateContext } from "../../stores/selected";
4
+ import type { IconProps } from "../../types/components/icon";
5
+ import {
6
+ css,
7
+ mapBorder,
8
+ mapBorderRadius,
9
+ mapColor,
10
+ mapShadow,
11
+ mapSize,
12
+ mapSpacing,
13
+ } from "../../utils/base-utils";
14
+ import { getActiveStateProps } from "../../utils/style-utils";
15
+
16
+ const props: IconProps = $props();
17
+ const selectedState = getSelectedStateContext();
18
+ const {
19
+ base_url,
20
+ formats,
21
+ size,
22
+ margin,
23
+ padding,
24
+ color,
25
+ icon_background: background,
26
+ } = $derived.by(() => {
27
+ return {
28
+ ...props,
29
+ ...getActiveStateProps($selectedState, props.overrides),
30
+ };
31
+ });
32
+
33
+ const getColorMode = getColorModeContext();
34
+ const colorMode = $derived(getColorMode());
35
+
36
+ const container = $derived(
37
+ css({
38
+ width: mapSize(size.width),
39
+ height: mapSize(size.height),
40
+ margin: mapSpacing(margin),
41
+ padding: mapSpacing(padding),
42
+ "background-color": mapColor(colorMode, background?.color),
43
+ border: mapBorder(colorMode, background?.border),
44
+ "border-radius": mapBorderRadius(background?.shape),
45
+ "box-shadow": mapShadow(colorMode, background?.shadow),
46
+ flex: "0 0 auto",
47
+ }),
48
+ );
49
+
50
+ const webpUrl = $derived(`${base_url}/${formats.webp}`);
51
+ const icon = $derived(
52
+ css({
53
+ width: "100%",
54
+ height: "100%",
55
+ position: "relative",
56
+ "z-index": 1,
57
+ overflow: "hidden",
58
+ "background-color": mapColor(colorMode, color),
59
+ "mask-image": `url(${webpUrl})`,
60
+ "webkit-mask-image": `url(${webpUrl})`,
61
+ "mask-size": "contain",
62
+ "webkit-mask-size": "contain",
63
+ "mask-position": "center",
64
+ "webkit-mask-position": "center",
65
+ "mask-repeat": "no-repeat",
66
+ "webkit-mask-repeat": "no-repeat",
67
+ }),
68
+ );
69
+ </script>
70
+
71
+ <div style={container}>
72
+ <div style={icon}></div>
73
+ </div>
@@ -0,0 +1,4 @@
1
+ import type { IconProps } from "../../types/components/icon";
2
+ declare const Icon: import("svelte").Component<IconProps, {}, "">;
3
+ type Icon = ReturnType<typeof Icon>;
4
+ export default Icon;
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import type { ImageProps } from "../../types/components/image";
3
+
4
+ interface ClipPathProps {
5
+ shape: ImageProps["mask_shape"];
6
+ width: number;
7
+ height: number;
8
+ }
9
+
10
+ const { shape, width, height }: ClipPathProps = $props();
11
+
12
+ const [topLeft, topRight, bottomRight, bottomLeft] = $derived.by(() => {
13
+ if (shape?.type !== "rectangle") {
14
+ return [0, 0, 0, 0];
15
+ }
16
+
17
+ const { corners } = shape;
18
+ return [
19
+ corners?.top_leading ?? 0,
20
+ corners?.top_trailing ?? 0,
21
+ corners?.bottom_trailing ?? 0,
22
+ corners?.bottom_leading ?? 0,
23
+ ];
24
+ });
25
+ </script>
26
+
27
+ {#if shape?.type === "circle"}
28
+ <circle cx={width / 2} cy={height / 2} r={Math.min(width, height) / 2} />
29
+ {/if}
30
+
31
+ {#if shape?.type === "concave"}
32
+ <path
33
+ d={`M 0 0 L ${width} 0 L ${width} ${height} Q ${width / 2} ${height - 54} 0 ${height} Z`}
34
+ />
35
+ {/if}
36
+ {#if shape?.type === "convex"}
37
+ <path
38
+ d={`M 0 0 L ${width} 0 L ${width} ${height - 27} Q ${width / 2} ${height + 27} 0 ${height - 27} Z`}
39
+ />
40
+ {/if}
41
+
42
+ {#if shape?.type === "rectangle" || shape?.type === undefined}
43
+ <path
44
+ d={`M ${topLeft} 0 H ${width - topRight} A ${topRight} ${topRight} 0 0 1 ${width} ${topRight}
45
+ V ${height - bottomRight} A ${bottomRight} ${bottomRight} 0 0 1 ${width - bottomRight} ${height}
46
+ H ${bottomLeft} A ${bottomLeft} ${bottomLeft} 0 0 1 0 ${height - bottomLeft}
47
+ V ${topLeft} A ${topLeft} ${topLeft} 0 0 1 ${topLeft} 0 Z`}
48
+ />
49
+ {/if}
@@ -0,0 +1,9 @@
1
+ import type { ImageProps } from "../../types/components/image";
2
+ interface ClipPathProps {
3
+ shape: ImageProps["mask_shape"];
4
+ width: number;
5
+ height: number;
6
+ }
7
+ declare const ClipPath: import("svelte").Component<ClipPathProps, {}, "">;
8
+ type ClipPath = ReturnType<typeof ClipPath>;
9
+ export default ClipPath;
@@ -1,86 +1,55 @@
1
1
  <script module lang="ts">
2
2
  import Image from "./Image.svelte";
3
+ import { componentDecorator } from "../../stories/component-decorator";
3
4
  import { defineMeta } from "@storybook/addon-svelte-csf";
4
5
 
5
6
  const { Story } = defineMeta({
6
7
  title: "Components/Image",
7
8
  component: Image,
8
- tags: ["autodocs"],
9
- argTypes: {
10
- id: { control: "text", description: "Unique identifier for the image" },
11
- color_overlay: {
12
- control: "object",
13
- description: "Image overlay",
14
- },
9
+ decorators: [componentDecorator()],
10
+ args: {
11
+ type: "image",
12
+ id: "image",
13
+ name: "Image",
14
+ fit_mode: "fill",
15
15
  size: {
16
- control: "object",
17
- description: "Size configuration for the image",
18
- },
19
- max_height: {
20
- control: "number",
21
- description: "Maximum height of the image",
22
- },
23
- override_source_lid: {
24
- control: "text",
25
- description: "Override source lid",
26
- },
27
- fit_mode: {
28
- control: { type: "select" },
29
- options: ["fit", "fill"],
30
- description: "Fit mode for the image",
16
+ width: { type: "fill" },
17
+ height: { type: "fill" },
18
+ },
19
+ source: {
20
+ dark: null,
21
+ light: {
22
+ width: 600,
23
+ height: 400,
24
+ original: "https://placehold.co/600x400",
25
+ heic: "https://placehold.co/600x400",
26
+ heic_low_res: "https://placehold.co/600x400",
27
+ webp: "https://placehold.co/600x400",
28
+ webp_low_res: "https://placehold.co/600x400",
29
+ },
31
30
  },
32
31
  },
33
32
  });
34
33
  </script>
35
34
 
36
- <!-- Rectangle story -->
37
35
  <Story
38
36
  name="Rectangle"
39
37
  args={{
40
- id: "example-id",
41
- fit_mode: "fit",
42
- size: {
43
- width: { type: "fill" },
44
- height: { type: "fill" },
45
- },
46
- source: {
47
- light: {
48
- width: 600,
49
- height: 400,
50
- original: "https://placehold.co/600x400",
51
- heic: "https://placehold.co/600x400",
52
- heic_low_res: "https://placehold.co/600x400",
53
- webp: "https://placehold.co/600x400",
54
- webp_low_res: "https://placehold.co/600x400",
38
+ mask_shape: {
39
+ type: "rectangle",
40
+ corners: {
41
+ top_leading: 0,
42
+ top_trailing: 0,
43
+ bottom_leading: 0,
44
+ bottom_trailing: 0,
55
45
  },
56
- dark: null,
57
46
  },
58
- mask_shape: { type: "rectangle" },
59
47
  }}
60
48
  />
61
49
 
62
- <!-- Rounded Rectangle story -->
63
50
  <Story
64
51
  name="Rounded Rectangle"
65
52
  args={{
66
- id: "example-id",
67
- fit_mode: "fit",
68
- size: {
69
- width: { type: "fill" },
70
- height: { type: "fill" },
71
- },
72
- source: {
73
- light: {
74
- width: 600,
75
- height: 400,
76
- original: "https://placehold.co/600x400",
77
- heic: "https://placehold.co/600x400",
78
- heic_low_res: "https://placehold.co/600x400",
79
- webp: "https://placehold.co/600x400",
80
- webp_low_res: "https://placehold.co/600x400",
81
- },
82
- dark: null,
83
- },
84
53
  mask_shape: {
85
54
  type: "rectangle",
86
55
  corners: {
@@ -92,161 +61,63 @@
92
61
  },
93
62
  }}
94
63
  />
95
- <!-- Circle story -->
64
+
96
65
  <Story
97
66
  name="Circle"
98
67
  args={{
99
- id: "example-id",
100
- fit_mode: "fit",
101
- size: {
102
- width: { type: "fill" },
103
- height: { type: "fill" },
104
- },
105
- source: {
106
- light: {
107
- width: 600,
108
- height: 400,
109
- original: "https://placehold.co/600x400",
110
- heic: "https://placehold.co/600x400",
111
- heic_low_res: "https://placehold.co/600x400",
112
- webp: "https://placehold.co/600x400",
113
- webp_low_res: "https://placehold.co/600x400",
114
- },
115
- dark: null,
116
- },
117
68
  mask_shape: { type: "circle" },
118
69
  }}
119
70
  />
120
- <!-- Concave story -->
71
+
121
72
  <Story
122
73
  name="Concave"
123
74
  args={{
124
- id: "example-id",
125
- fit_mode: "fit",
126
- size: {
127
- width: { type: "fill" },
128
- height: { type: "fill" },
129
- },
130
- source: {
131
- light: {
132
- width: 600,
133
- height: 400,
134
- original: "https://placehold.co/600x400",
135
- heic: "https://placehold.co/600x400",
136
- heic_low_res: "https://placehold.co/600x400",
137
- webp: "https://placehold.co/600x400",
138
- webp_low_res: "https://placehold.co/600x400",
139
- },
140
- dark: null,
141
- },
142
75
  mask_shape: { type: "concave" },
143
76
  }}
144
77
  />
145
- <!-- Convex story -->
78
+
146
79
  <Story
147
80
  name="Convex"
148
81
  args={{
149
- id: "example-id",
150
- fit_mode: "fit",
151
- size: {
152
- width: { type: "fill" },
153
- height: { type: "fill" },
154
- },
155
- source: {
156
- light: {
157
- width: 600,
158
- height: 400,
159
- original: "https://placehold.co/600x400",
160
- heic: "https://placehold.co/600x400",
161
- heic_low_res: "https://placehold.co/600x400",
162
- webp: "https://placehold.co/600x400",
163
- webp_low_res: "https://placehold.co/600x400",
164
- },
165
- dark: null,
166
- },
167
82
  mask_shape: { type: "convex" },
168
83
  }}
169
84
  />
170
- <!-- Radial Gradient story -->
85
+
171
86
  <Story
172
87
  name="Overlay Radial Gradient"
173
88
  args={{
174
- id: "example-id",
175
- fit_mode: "fit",
176
- size: {
177
- width: { type: "fill" },
178
- height: { type: "fill" },
179
- },
180
- source: {
181
- light: {
182
- width: 600,
183
- height: 400,
184
- original: "https://placehold.co/600x400",
185
- heic: "https://placehold.co/600x400",
186
- heic_low_res: "https://placehold.co/600x400",
187
- webp: "https://placehold.co/600x400",
188
- webp_low_res: "https://placehold.co/600x400",
189
- },
190
- dark: null,
191
- },
192
89
  color_overlay: {
193
- dark: {
194
- type: "hex",
195
- value: "#000000FF",
196
- },
197
90
  light: {
91
+ type: "radial",
198
92
  points: [
199
93
  {
200
- color: "#020024ff",
201
94
  percent: 0,
95
+ color: "#020024ff",
202
96
  },
203
97
  {
204
- color: "#00d4ff00",
205
98
  percent: 100,
99
+ color: "#00d4ff00",
206
100
  },
207
101
  ],
208
- type: "radial",
209
102
  },
210
103
  },
211
104
  }}
212
105
  />
213
- <!-- Linear Gradient story -->
106
+
214
107
  <Story
215
108
  name="Overlay Linear Gradient"
216
109
  args={{
217
- id: "example-id",
218
- fit_mode: "fit",
219
- size: {
220
- width: { type: "fill" },
221
- height: { type: "fill" },
222
- },
223
- source: {
224
- light: {
225
- width: 600,
226
- height: 400,
227
- original: "https://placehold.co/600x400",
228
- heic: "https://placehold.co/600x400",
229
- heic_low_res: "https://placehold.co/600x400",
230
- webp: "https://placehold.co/600x400",
231
- webp_low_res: "https://placehold.co/600x400",
232
- },
233
- dark: null,
234
- },
235
110
  color_overlay: {
236
- dark: {
237
- type: "hex",
238
- value: "#000000FF",
239
- },
240
111
  light: {
241
112
  degrees: 180,
242
113
  points: [
243
114
  {
244
- color: "#020024ff",
245
115
  percent: 0,
116
+ color: "#020024ff",
246
117
  },
247
118
  {
248
- color: "#00d4ff00",
249
119
  percent: 100,
120
+ color: "#00d4ff00",
250
121
  },
251
122
  ],
252
123
  type: "linear",
@@ -254,36 +125,60 @@
254
125
  },
255
126
  }}
256
127
  />
257
- <!-- Solid overlay -->
128
+
258
129
  <Story
259
130
  name="Overlay Solid"
260
131
  args={{
261
- id: "example-id",
262
- fit_mode: "fit",
132
+ color_overlay: {
133
+ light: {
134
+ type: "hex",
135
+ value: "#e7c00069",
136
+ },
137
+ },
138
+ }}
139
+ />
140
+
141
+ <Story
142
+ name="Complex"
143
+ args={{
263
144
  size: {
264
- width: { type: "fill" },
265
- height: { type: "fill" },
145
+ width: { type: "fixed", value: 128 },
146
+ height: { type: "fixed", value: 128 },
266
147
  },
267
- source: {
268
- light: {
269
- width: 600,
270
- height: 400,
271
- original: "https://placehold.co/600x400",
272
- heic: "https://placehold.co/600x400",
273
- heic_low_res: "https://placehold.co/600x400",
274
- webp: "https://placehold.co/600x400",
275
- webp_low_res: "https://placehold.co/600x400",
148
+ mask_shape: {
149
+ type: "rectangle",
150
+ corners: {
151
+ top_leading: 0,
152
+ top_trailing: 16,
153
+ bottom_trailing: 32,
154
+ bottom_leading: 64,
276
155
  },
277
- dark: null,
278
156
  },
157
+ fit_mode: "fill",
158
+ padding: { top: 0, bottom: 0, leading: 0, trailing: 0 },
159
+ margin: { top: 0, bottom: 0, leading: 0, trailing: 0 },
279
160
  color_overlay: {
280
- dark: {
281
- type: "hex",
282
- value: "#000000FF",
283
- },
284
161
  light: {
285
- type: "hex",
286
- value: "#e7c00069",
162
+ type: "linear",
163
+ degrees: 180,
164
+ points: [
165
+ { percent: 0, color: "#ff000080" },
166
+ { percent: 100, color: "#ff00ff00" },
167
+ ],
168
+ },
169
+ },
170
+ border: {
171
+ width: 3,
172
+ color: {
173
+ light: { type: "hex", value: "#00ff0080" },
174
+ },
175
+ },
176
+ shadow: {
177
+ x: 0,
178
+ y: 0,
179
+ radius: 16,
180
+ color: {
181
+ light: { type: "hex", value: "#0000ff80" },
287
182
  },
288
183
  },
289
184
  }}