@revenuecat/purchases-ui-js 0.0.12 → 0.0.14

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 (36) hide show
  1. package/dist/components/button/Button.svelte +1 -1
  2. package/dist/components/button/ButtonNode.stories.svelte +1 -1
  3. package/dist/components/button/ButtonNode.svelte +9 -3
  4. package/dist/components/footer/Footer.svelte +3 -3
  5. package/dist/components/image/Image.svelte +6 -3
  6. package/dist/components/image/image-utils.js +1 -1
  7. package/dist/components/package/Package.svelte +23 -7
  8. package/dist/components/paywall/Node.svelte +20 -14
  9. package/dist/components/paywall/Node.svelte.d.ts +2 -2
  10. package/dist/components/paywall/Paywall.stories.svelte +96 -1
  11. package/dist/components/paywall/Paywall.svelte +14 -2
  12. package/dist/components/paywall/Paywall.svelte.d.ts +2 -0
  13. package/dist/components/purchase-button/PurchaseButton.svelte +9 -4
  14. package/dist/components/stack/Stack.svelte +10 -4
  15. package/dist/components/stack/stack-utils.d.ts +2 -1
  16. package/dist/components/stack/stack-utils.js +1 -1
  17. package/dist/components/text/Text.svelte +17 -27
  18. package/dist/components/text/Text.svelte.d.ts +7 -2
  19. package/dist/components/text/{Text.stories.svelte → TextNode.stories.svelte} +55 -3
  20. package/dist/components/text/{Text.stories.svelte.d.ts → TextNode.stories.svelte.d.ts} +4 -4
  21. package/dist/components/text/TextNode.svelte +46 -0
  22. package/dist/components/text/TextNode.svelte.d.ts +3 -0
  23. package/dist/components/text/text-utils.d.ts +3 -3
  24. package/dist/components/text/text-utils.js +2 -2
  25. package/dist/data/entities.d.ts +4 -1
  26. package/dist/data/state.d.ts +2 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +1 -0
  29. package/dist/stories/fixtures.d.ts +3 -0
  30. package/dist/stories/fixtures.js +5331 -0
  31. package/dist/types.d.ts +8 -2
  32. package/dist/{utils.d.ts → utils/style-utils.d.ts} +14 -4
  33. package/dist/{utils.js → utils/style-utils.js} +33 -12
  34. package/dist/utils/variable-utils.d.ts +33 -0
  35. package/dist/utils/variable-utils.js +34 -0
  36. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import Text from "./Text.svelte";
1
+ import TextNode from "./TextNode.svelte";
2
2
  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> {
3
3
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
4
  $$bindings?: Bindings;
@@ -12,8 +12,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
12
12
  };
13
13
  z_$$bindings?: Bindings;
14
14
  }
15
- declare const Text: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ declare const TextNode: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
16
16
  [evt: string]: CustomEvent<any>;
17
17
  }, {}, {}, string>;
18
- type Text = InstanceType<typeof Text>;
19
- export default Text;
18
+ type TextNode = InstanceType<typeof TextNode>;
19
+ export default TextNode;
@@ -0,0 +1,46 @@
1
+ <script lang="ts">
2
+ import { getTextComponentStyles } from "./text-utils";
3
+ import Text from "./Text.svelte";
4
+ import type { TextNodeProps } from "../../data/entities";
5
+ import { getLabelById, stringifyStyles } from "../../utils/style-utils";
6
+ import { replaceVariables } from "../../utils/variable-utils";
7
+
8
+ const {
9
+ id,
10
+ labels,
11
+ text_lid,
12
+ purchaseState,
13
+ variableDictionary,
14
+ ...restProps
15
+ }: TextNodeProps = $props();
16
+
17
+ const { tagToRender, textStyles } = $derived(
18
+ getTextComponentStyles({
19
+ id,
20
+ labels,
21
+ text_lid,
22
+ purchaseState,
23
+ ...restProps,
24
+ }),
25
+ );
26
+ const styles = $derived(stringifyStyles(textStyles));
27
+
28
+ const label = $derived(
29
+ getLabelById(
30
+ text_lid,
31
+ purchaseState.locale,
32
+ purchaseState.defaultLocale,
33
+ labels,
34
+ ),
35
+ );
36
+ const parsedLabel = $derived(
37
+ replaceVariables({
38
+ value: label,
39
+ variableDictionary,
40
+ }),
41
+ );
42
+ </script>
43
+
44
+ <Text styleVariables={styles} component={tagToRender} {id}>
45
+ {parsedLabel}
46
+ </Text>
@@ -0,0 +1,3 @@
1
+ import type { TextNodeProps } from "../../data/entities";
2
+ declare const TextNode: import("svelte").Component<TextNodeProps, {}, "">;
3
+ export default TextNode;
@@ -1,5 +1,5 @@
1
- import { type TextComponentTags } from "../../utils";
2
- import type { TextProps } from "../../data/entities";
1
+ import { type TextComponentTags } from "../../utils/style-utils";
2
+ import type { TextNodeProps } from "../../data/entities";
3
3
  type TextStyleVariables = {
4
4
  "--width": string;
5
5
  "--height": string;
@@ -13,7 +13,7 @@ type TextStyleVariables = {
13
13
  * @param props - Text component properties including font, color, background, spacing etc.
14
14
  * @returns Object containing text style variables and the appropriate HTML tag to render
15
15
  */
16
- export declare const getTextComponentStyles: (props: TextProps) => {
16
+ export declare const getTextComponentStyles: (props: TextNodeProps) => {
17
17
  textStyles: TextStyleVariables;
18
18
  tagToRender: TextComponentTags;
19
19
  };
@@ -1,5 +1,5 @@
1
- import { getSizeStyle, getTextComponentTag, getTextStyles, } from "../../utils";
2
- import { getComponentStyles } from "../../utils";
1
+ import { getSizeStyle, getTextComponentTag, getTextStyles, } from "../../utils/style-utils";
2
+ import { getComponentStyles } from "../../utils/style-utils";
3
3
  /**
4
4
  * Generates comprehensive styles for text components by combining text, component and size styles
5
5
  * @param props - Text component properties including font, color, background, spacing etc.
@@ -1,5 +1,6 @@
1
1
  import type { BorderType, ColorMode, ColorType, CornerRadiusType, DimensionType, FitTypes, FontSizeTags, FontWeights, ShadowType, ShapeType, SizeType, Spacing, TextAlignment } from "../types";
2
2
  import type { PurchaseState } from "./state";
3
+ import type { VariableDictionary } from "../utils/variable-utils";
3
4
  export interface Extra {
4
5
  [key: string]: any;
5
6
  }
@@ -47,6 +48,7 @@ interface SharedComponentProps extends PaywallComponent, ActionsProps, PurchaseS
47
48
  id: string;
48
49
  colorMode: ColorMode;
49
50
  name: string;
51
+ variableDictionary?: VariableDictionary;
50
52
  }
51
53
  interface Action {
52
54
  type: "restore_purchases" | "navigate_to" | "navigate_back" | "purchase" | "select_package";
@@ -104,7 +106,7 @@ export interface StackProps extends SharedComponentProps {
104
106
  spacing?: number;
105
107
  type: "stack";
106
108
  }
107
- export interface TextProps extends SharedComponentProps {
109
+ export interface TextNodeProps extends SharedComponentProps {
108
110
  background_color?: ColorType;
109
111
  color: ColorType;
110
112
  components: PaywallComponent[];
@@ -117,6 +119,7 @@ export interface TextProps extends SharedComponentProps {
117
119
  text_lid: string;
118
120
  type: "text";
119
121
  size: SizeType;
122
+ variableDictionary?: VariableDictionary;
120
123
  }
121
124
  type ImageSourceDictionaryType = Record<"original" | "heic" | "heic_low_res" | "webp" | "webp_low_res", string>;
122
125
  type ImageSourceType = {
@@ -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,6 +3,9 @@ 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;
8
+ export declare const calmPaywallData: PaywallData;
6
9
  export declare const labelsData: {
7
10
  en_US: {
8
11
  id1: string;