@revenuecat/purchases-ui-js 0.0.13 → 0.0.15

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 (35) hide show
  1. package/dist/components/button/Button.svelte +1 -1
  2. package/dist/components/button/ButtonNode.svelte +9 -3
  3. package/dist/components/footer/Footer.svelte +3 -3
  4. package/dist/components/image/Image.svelte +4 -2
  5. package/dist/components/image/image-utils.js +9 -5
  6. package/dist/components/package/Package.svelte +28 -8
  7. package/dist/components/paywall/Node.svelte +17 -2
  8. package/dist/components/paywall/Node.svelte.d.ts +2 -0
  9. package/dist/components/paywall/Paywall.stories.svelte +99 -1
  10. package/dist/components/paywall/Paywall.svelte +60 -3
  11. package/dist/components/paywall/Paywall.svelte.d.ts +2 -0
  12. package/dist/components/paywall/paywall-utils.d.ts +7 -0
  13. package/dist/components/paywall/paywall-utils.js +21 -0
  14. package/dist/components/purchase-button/PurchaseButton.svelte +9 -4
  15. package/dist/components/stack/Stack.svelte +9 -2
  16. package/dist/components/stack/stack-utils.d.ts +1 -1
  17. package/dist/components/stack/stack-utils.js +9 -4
  18. package/dist/components/text/Text.svelte +4 -3
  19. package/dist/components/text/TextNode.stories.svelte +118 -1
  20. package/dist/components/text/TextNode.svelte +35 -5
  21. package/dist/components/text/text-utils.d.ts +2 -0
  22. package/dist/components/text/text-utils.js +6 -5
  23. package/dist/data/entities.d.ts +40 -0
  24. package/dist/data/state.d.ts +2 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/stories/fixtures.d.ts +4 -0
  28. package/dist/stories/fixtures.js +7840 -585
  29. package/dist/types.d.ts +9 -3
  30. package/dist/types.js +1 -1
  31. package/dist/utils/style-utils.d.ts +15 -8
  32. package/dist/utils/style-utils.js +61 -11
  33. package/dist/utils/variable-utils.d.ts +23 -3
  34. package/dist/utils/variable-utils.js +1 -1
  35. package/package.json +13 -3
@@ -39,7 +39,12 @@
39
39
  },
40
40
  },
41
41
  args: {
42
- labels: { en_US: { lb123: "Test text" } },
42
+ labels: {
43
+ en_US: {
44
+ lb123:
45
+ "Do not allow people to dim your shine because they are blinded. Tell them to put some sunglasses on.",
46
+ },
47
+ },
43
48
  text_lid: "lb123",
44
49
  size: {
45
50
  width: { type: "fill" },
@@ -102,6 +107,118 @@
102
107
  name: "hello world!",
103
108
  }}
104
109
  />
110
+
111
+ <!-- Linear Gradient Color text story -->
112
+ <Story
113
+ name="LinearGradientColor"
114
+ args={{
115
+ font_weight: "regular",
116
+ text_style: "normal",
117
+ horizontal_alignment: "start",
118
+ size: { width: { type: "fixed", value: 200 }, height: { type: "fixed" } },
119
+ padding: { top: 20, trailing: 20, bottom: 20, leading: 20 },
120
+ color: {
121
+ dark: {
122
+ degrees: 90,
123
+ points: [
124
+ {
125
+ color: "#9f009f",
126
+ percent: 100,
127
+ },
128
+ {
129
+ color: "#090979ff",
130
+ percent: 35,
131
+ },
132
+ {
133
+ color: "#53d6ec",
134
+ percent: 0,
135
+ },
136
+ ],
137
+ type: "linear",
138
+ },
139
+ light: {
140
+ degrees: 45,
141
+ points: [
142
+ {
143
+ color: "#9f009f",
144
+ percent: 0,
145
+ },
146
+ {
147
+ color: "#090979ff",
148
+ percent: 50,
149
+ },
150
+
151
+ {
152
+ color: "#53d6ec",
153
+ percent: 100,
154
+ },
155
+ ],
156
+ type: "linear",
157
+ },
158
+ },
159
+ background_color: {
160
+ dark: { type: "hex", value: "#000000" },
161
+ light: { type: "hex", value: "#000000" },
162
+ },
163
+ name: "hello world!",
164
+ }}
165
+ />
166
+
167
+ <!-- Radial Gradient Color text story -->
168
+ <Story
169
+ name="RadialGradientColor"
170
+ args={{
171
+ font_weight: "regular",
172
+ text_style: "normal",
173
+ horizontal_alignment: "start",
174
+ size: { width: { type: "fixed", value: 200 }, height: { type: "fixed" } },
175
+ padding: { top: 20, trailing: 20, bottom: 20, leading: 20 },
176
+ color: {
177
+ dark: {
178
+ degrees: 90,
179
+ points: [
180
+ {
181
+ color: "#9f009f",
182
+ percent: 100,
183
+ },
184
+ {
185
+ color: "#090979ff",
186
+ percent: 35,
187
+ },
188
+ {
189
+ color: "#53d6ec",
190
+ percent: 0,
191
+ },
192
+ ],
193
+ type: "radial",
194
+ },
195
+ light: {
196
+ points: [
197
+ {
198
+ color: "#53d6ec",
199
+ percent: 0,
200
+ },
201
+ {
202
+ color: "#090979ff",
203
+ percent: 30,
204
+ },
205
+
206
+ {
207
+ color: "#9f009f",
208
+ percent: 50,
209
+ },
210
+ ],
211
+ type: "radial",
212
+ },
213
+ },
214
+ background_color: {
215
+ dark: { type: "hex", value: "#000000" },
216
+ light: { type: "hex", value: "#000000" },
217
+ },
218
+ name: "hello world!",
219
+ }}
220
+ />
221
+
105
222
  <!-- Text with spacing story -->
106
223
  <Story
107
224
  name="With Spacing"
@@ -2,7 +2,12 @@
2
2
  import { getTextComponentStyles } from "./text-utils";
3
3
  import Text from "./Text.svelte";
4
4
  import type { TextNodeProps } from "../../data/entities";
5
- import { getLabelById, stringifyStyles } from "../../utils/style-utils";
5
+ import {
6
+ getComponentStyles,
7
+ getLabelById,
8
+ getSizeStyle,
9
+ stringifyStyles,
10
+ } from "../../utils/style-utils";
6
11
  import { replaceVariables } from "../../utils/variable-utils";
7
12
 
8
13
  const {
@@ -11,6 +16,8 @@
11
16
  text_lid,
12
17
  purchaseState,
13
18
  variableDictionary,
19
+ background_color,
20
+ size,
14
21
  ...restProps
15
22
  }: TextNodeProps = $props();
16
23
 
@@ -20,9 +27,20 @@
20
27
  labels,
21
28
  text_lid,
22
29
  purchaseState,
30
+ background_color,
31
+ size,
23
32
  ...restProps,
24
33
  }),
25
34
  );
35
+ const wrapperStyles = $derived(
36
+ stringifyStyles({
37
+ ...getComponentStyles({
38
+ backgroundColor: background_color,
39
+ ...restProps,
40
+ }),
41
+ ...getSizeStyle(size),
42
+ }),
43
+ );
26
44
  const styles = $derived(stringifyStyles(textStyles));
27
45
 
28
46
  const label = $derived(
@@ -36,11 +54,23 @@
36
54
  const parsedLabel = $derived(
37
55
  replaceVariables({
38
56
  value: label,
39
- dictionary: variableDictionary,
57
+ variableDictionary,
40
58
  }),
41
59
  );
42
60
  </script>
43
61
 
44
- <Text styleVariables={styles} component={tagToRender} {id}>
45
- {parsedLabel}
46
- </Text>
62
+ <span style={wrapperStyles} class="text-wrapper">
63
+ <Text styleVariables={styles} component={tagToRender} {id}>
64
+ {parsedLabel}
65
+ </Text>
66
+ </span>
67
+
68
+ <style>
69
+ .text-wrapper {
70
+ display: block;
71
+
72
+ height: var(--height, unset);
73
+ width: var(--width, unset);
74
+ background: var(--background, none);
75
+ }
76
+ </style>
@@ -7,6 +7,8 @@ type TextStyleVariables = {
7
7
  "--font-weight": number | string;
8
8
  "--font-size": string;
9
9
  "--font-family": string;
10
+ "--background-clip": string;
11
+ "--text-fill-color": string;
10
12
  };
11
13
  /**
12
14
  * Generates comprehensive styles for text components by combining text, component and size styles
@@ -1,5 +1,4 @@
1
- import { getSizeStyle, getTextComponentTag, getTextStyles, } from "../../utils/style-utils";
2
- import { getComponentStyles } from "../../utils/style-utils";
1
+ import { getActiveStateProps, getComponentStyles, getSizeStyle, getTextComponentTag, getTextStyles, } from "../../utils/style-utils";
3
2
  /**
4
3
  * Generates comprehensive styles for text components by combining text, component and size styles
5
4
  * @param props - Text component properties including font, color, background, spacing etc.
@@ -13,20 +12,22 @@ export const getTextComponentStyles = (props) => {
13
12
  dark: { type: "hex", value: "#FFFFFF" },
14
13
  light: { type: "hex", value: "#FFFFFF" },
15
14
  }, padding, margin, colorMode, size, } = props;
15
+ const activeStateProps = getActiveStateProps(props.overrides, props.componentState);
16
16
  const tagToRender = getTextComponentTag(font_size);
17
- const textStyles = getTextStyles(props);
17
+ const textStyles = getTextStyles({ ...props, ...activeStateProps }, colorMode);
18
18
  const componentStyles = getComponentStyles({
19
19
  backgroundColor: background_color,
20
20
  textColor: color,
21
21
  margin,
22
22
  padding,
23
23
  colorMode,
24
+ ...activeStateProps,
24
25
  });
25
- const sizeStyles = getSizeStyle(size);
26
+ const sizeStyles = getSizeStyle({ ...size, ...activeStateProps });
26
27
  return {
27
28
  textStyles: {
28
- ...textStyles,
29
29
  ...componentStyles,
30
+ ...textStyles,
30
31
  ...sizeStyles,
31
32
  },
32
33
  tagToRender,
@@ -16,8 +16,28 @@ export interface Stack extends PaywallComponent {
16
16
  spacing: number;
17
17
  components: PaywallComponent[];
18
18
  }
19
+ type BaseNodeBackgroundColor = {
20
+ type: "color";
21
+ value: ColorType;
22
+ };
23
+ export type BaseNodeBackgroundImage = {
24
+ type: "image";
25
+ value: ImageSourceType;
26
+ };
27
+ export type BaseNodeBackgroundType = BaseNodeBackgroundColor | BaseNodeBackgroundImage;
19
28
  export interface ComponentConfig {
29
+ colors?: Record<string, string>;
30
+ fonts?: {
31
+ [fontName: string]: {
32
+ ios: string;
33
+ android: string;
34
+ web: string;
35
+ };
36
+ };
37
+ asset_base_url?: string;
20
38
  base: {
39
+ default_font_name?: string;
40
+ background?: BaseNodeBackgroundType;
21
41
  stack: Stack;
22
42
  sticky_footer?: {
23
43
  stack: {
@@ -43,11 +63,16 @@ export interface ActionsProps {
43
63
  export interface PurchaseStateProps {
44
64
  purchaseState: PurchaseState;
45
65
  }
66
+ export type ComponentState = {
67
+ [state: string]: boolean;
68
+ };
46
69
  interface SharedComponentProps extends PaywallComponent, ActionsProps, PurchaseStateProps {
47
70
  labels: ComponentLocalizations;
48
71
  id: string;
49
72
  colorMode: ColorMode;
50
73
  name: string;
74
+ variableDictionary?: VariableDictionary;
75
+ componentState?: ComponentState;
51
76
  }
52
77
  interface Action {
53
78
  type: "restore_purchases" | "navigate_to" | "navigate_back" | "purchase" | "select_package";
@@ -104,6 +129,11 @@ export interface StackProps extends SharedComponentProps {
104
129
  size: SizeType;
105
130
  spacing?: number;
106
131
  type: "stack";
132
+ overrides?: {
133
+ states: {
134
+ [state: string]: StackProps;
135
+ };
136
+ };
107
137
  }
108
138
  export interface TextNodeProps extends SharedComponentProps {
109
139
  background_color?: ColorType;
@@ -119,6 +149,11 @@ export interface TextNodeProps extends SharedComponentProps {
119
149
  type: "text";
120
150
  size: SizeType;
121
151
  variableDictionary?: VariableDictionary;
152
+ overrides?: {
153
+ states: {
154
+ [state: string]: TextNodeProps;
155
+ };
156
+ };
122
157
  }
123
158
  type ImageSourceDictionaryType = Record<"original" | "heic" | "heic_low_res" | "webp" | "webp_low_res", string>;
124
159
  type ImageSourceType = {
@@ -138,5 +173,10 @@ export interface ImageProps extends SharedComponentProps {
138
173
  mask_shape?: ImageMaskShapeType;
139
174
  max_height?: number;
140
175
  override_source_lid?: string;
176
+ overrides?: {
177
+ states: {
178
+ [state: string]: ImageProps;
179
+ };
180
+ };
141
181
  }
142
182
  export {};
@@ -1,5 +1,7 @@
1
+ import type { VariableDictionary } from "../utils/variable-utils";
1
2
  export interface PurchaseState {
2
3
  selectedPackageId?: string;
3
4
  locale: string;
4
5
  defaultLocale: string;
6
+ variablesPerPackage?: Record<string, VariableDictionary>;
5
7
  }
package/dist/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export { default as Image } from "./components/image/Image.svelte";
8
8
  export { default as PurchaseButton } from "./components/purchase-button/PurchaseButton.svelte";
9
9
  export { default as Package } from "./components/package/Package.svelte";
10
10
  export { default as Footer } from "./components/footer/Footer.svelte";
11
+ export { type VariableDictionary } from "./utils/variable-utils";
package/dist/index.js CHANGED
@@ -9,3 +9,4 @@ export { default as Image } from "./components/image/Image.svelte";
9
9
  export { default as PurchaseButton } from "./components/purchase-button/PurchaseButton.svelte";
10
10
  export { default as Package } from "./components/package/Package.svelte";
11
11
  export { default as Footer } from "./components/footer/Footer.svelte";
12
+ export {} from "./utils/variable-utils";
@@ -3,7 +3,11 @@ export declare const paywallData: PaywallData;
3
3
  export declare const alignmentPaywallData: PaywallData;
4
4
  export declare const fontsPaywallData: PaywallData;
5
5
  export declare const pastaPaywallData: PaywallData;
6
+ export declare const variablesPastaPaywallData: PaywallData;
7
+ export declare const gradientPaywallData: PaywallData;
6
8
  export declare const calmPaywallData: PaywallData;
9
+ export declare const stateTemplate: PaywallData;
10
+ export declare const posterMakerTemplate: PaywallData;
7
11
  export declare const labelsData: {
8
12
  en_US: {
9
13
  id1: string;