@revenuecat/purchases-ui-js 2.0.3 → 2.0.4

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 (39) hide show
  1. package/dist/components/button/ButtonNode.svelte +20 -3
  2. package/dist/components/carousel/Carousel.stories.svelte +1039 -0
  3. package/dist/components/carousel/Carousel.stories.svelte.d.ts +19 -0
  4. package/dist/components/carousel/Carousel.svelte +298 -0
  5. package/dist/components/carousel/Carousel.svelte.d.ts +4 -0
  6. package/dist/components/carousel/CarouselPage.svelte +39 -0
  7. package/dist/components/carousel/CarouselPage.svelte.d.ts +11 -0
  8. package/dist/components/carousel/PageControl.svelte +93 -0
  9. package/dist/components/carousel/PageControl.svelte.d.ts +4 -0
  10. package/dist/components/carousel/carousel-utils.d.ts +4 -0
  11. package/dist/components/carousel/carousel-utils.js +21 -0
  12. package/dist/components/paywall/Node.svelte +4 -10
  13. package/dist/components/paywall/Node.svelte.d.ts +2 -1
  14. package/dist/components/paywall/Paywall.svelte +5 -5
  15. package/dist/components/paywall/Paywall.svelte.d.ts +2 -1
  16. package/dist/components/paywall/fixtures/override-paywall.d.ts +1 -1
  17. package/dist/components/paywall/fixtures/stack-paywall.d.ts +1 -1
  18. package/dist/components/paywall/paywall-utils.d.ts +1 -1
  19. package/dist/components/stack/Stack.svelte +6 -1
  20. package/dist/components/stack/Stack.svelte.d.ts +2 -0
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +2 -2
  23. package/dist/stores/paywall.d.ts +1 -1
  24. package/dist/stories/fixtures.d.ts +2 -1
  25. package/dist/stories/viewport-wrapper.svelte +7 -5
  26. package/dist/types/component.d.ts +2 -1
  27. package/dist/types/components/button.d.ts +2 -0
  28. package/dist/types/components/carousel.d.ts +51 -0
  29. package/dist/types/paywall.d.ts +27 -0
  30. package/dist/types/paywall.js +1 -0
  31. package/dist/types/ui-config.d.ts +20 -0
  32. package/dist/types/ui-config.js +1 -0
  33. package/dist/utils/font-utils.d.ts +1 -1
  34. package/dist/utils/style-utils.d.ts +1 -1
  35. package/dist/utils/style-utils.js +7 -2
  36. package/dist/web-components/index.js +969 -942
  37. package/package.json +20 -20
  38. package/dist/data/entities.d.ts +0 -46
  39. /package/dist/{data/entities.js → types/components/carousel.js} +0 -0
@@ -1,4 +1,5 @@
1
- import type { PaywallData, UIConfig } from "../data/entities";
1
+ import type { PaywallData } from "../types/paywall";
2
+ import type { UIConfig } from "../types/ui-config";
2
3
  import type { BrandingAppearance } from "../ui/utils/branding";
3
4
  export declare const uiConfigData: UIConfig;
4
5
  export declare const paywallData: PaywallData;
@@ -14,11 +14,13 @@
14
14
  </script>
15
15
 
16
16
  <div class="container" {style}>
17
- <div class="content">
18
- {#each Array(elements) as _, index}
19
- <div>Item {index + 1}</div>
20
- {/each}
21
- </div>
17
+ {#if elements > 0}
18
+ <div class="content">
19
+ {#each Array(elements) as _, index}
20
+ <div>Item {index + 1}</div>
21
+ {/each}
22
+ </div>
23
+ {/if}
22
24
  {@render children()}
23
25
  </div>
24
26
 
@@ -7,4 +7,5 @@ import type { ImageProps } from "./components/image";
7
7
  import type { PackageProps } from "./components/package";
8
8
  import type { PurchaseButtonProps } from "./components/purchase-button";
9
9
  import type { StackProps } from "./components/stack";
10
- export type Component = ButtonProps | FooterProps | IconProps | ImageProps | PackageProps | PurchaseButtonProps | StackProps | TextNodeProps | TimelineProps;
10
+ import type { CarouselProps } from "./components/carousel";
11
+ export type Component = ButtonProps | CarouselProps | FooterProps | IconProps | ImageProps | PackageProps | PurchaseButtonProps | StackProps | TextNodeProps | TimelineProps;
@@ -1,4 +1,5 @@
1
1
  import type { BaseComponent } from "../base";
2
+ import type { Overrides } from "../overrides";
2
3
  import type { StackProps } from "./stack";
3
4
  interface RestorePurchasesAction {
4
5
  type: "restore_purchases";
@@ -35,5 +36,6 @@ export interface ButtonProps extends BaseComponent {
35
36
  action: Action;
36
37
  stack: StackProps;
37
38
  transition?: null;
39
+ overrides?: Overrides<ButtonProps>;
38
40
  }
39
41
  export {};
@@ -0,0 +1,51 @@
1
+ import type { BorderType, ShadowType, ShapeType, Spacing } from "..";
2
+ import type { VerticalAlignment } from "../alignment";
3
+ import type { Background } from "../background";
4
+ import type { BaseComponent } from "../base";
5
+ import type { ColorScheme } from "../colors";
6
+ import type { Overrides } from "../overrides";
7
+ import type { StackProps } from "./stack";
8
+ export interface PageControlIndicator {
9
+ width: number;
10
+ height: number;
11
+ color: ColorScheme;
12
+ stroke_color?: ColorScheme | null;
13
+ stroke_width?: number | null;
14
+ }
15
+ export interface PageControl {
16
+ position: "top" | "bottom";
17
+ spacing: number;
18
+ margin: Spacing;
19
+ padding: Spacing;
20
+ background_color?: ColorScheme | null;
21
+ border?: BorderType | null;
22
+ shape?: ShapeType | null;
23
+ shadow?: ShadowType | null;
24
+ active: PageControlIndicator;
25
+ default: PageControlIndicator;
26
+ }
27
+ type AutoAdvanceTransitionType = "fade" | "slide";
28
+ interface AutoAdvance {
29
+ ms_time_per_page: number;
30
+ ms_transition_time: number;
31
+ transition_type: AutoAdvanceTransitionType;
32
+ }
33
+ export interface CarouselProps extends BaseComponent {
34
+ type: "carousel";
35
+ pages: StackProps[];
36
+ padding: Spacing;
37
+ margin: Spacing;
38
+ background?: Background | null;
39
+ shape?: ShapeType | null;
40
+ border?: BorderType | null;
41
+ shadow?: ShadowType | null;
42
+ page_alignment: VerticalAlignment;
43
+ page_spacing: number;
44
+ page_peek: number;
45
+ page_control?: PageControl | null;
46
+ initial_page_index: number;
47
+ loop: boolean;
48
+ auto_advance?: AutoAdvance | null;
49
+ overrides?: Overrides<CarouselProps>;
50
+ }
51
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { Background } from "./background";
2
+ import type { FooterProps } from "./components/footer";
3
+ import type { StackProps } from "./components/stack";
4
+ import type { Localizations } from "./localization";
5
+ interface RootPaywall {
6
+ background?: Background;
7
+ stack: StackProps;
8
+ sticky_footer?: FooterProps | null;
9
+ }
10
+ export interface ComponentConfig {
11
+ colors?: Record<string, string>;
12
+ fonts?: {
13
+ [fontName: string]: {
14
+ ios: string;
15
+ android: string;
16
+ web: string;
17
+ };
18
+ };
19
+ asset_base_url?: string;
20
+ base: RootPaywall;
21
+ }
22
+ export interface PaywallData {
23
+ default_locale: string;
24
+ components_config: ComponentConfig;
25
+ components_localizations: Localizations;
26
+ }
27
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ type AppFontFamilyConfig = {
2
+ type: "name" | "url";
3
+ value?: string;
4
+ family: string;
5
+ hash: string;
6
+ style: string;
7
+ url: string;
8
+ weight: number;
9
+ };
10
+ type AppFontsConfig = Record<string, {
11
+ ios?: AppFontFamilyConfig;
12
+ android?: AppFontFamilyConfig;
13
+ web?: AppFontFamilyConfig;
14
+ }>;
15
+ export type UIConfig = {
16
+ app: {
17
+ fonts: AppFontsConfig;
18
+ };
19
+ };
20
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { UIConfig } from "../data/entities";
1
+ import type { UIConfig } from "../types/ui-config";
2
2
  export declare function isFontRCFMManaged(fontName: string): boolean;
3
3
  export declare function getScopedFontFamily(fontFamily: string): string;
4
4
  export declare function registerFonts(uiConfig: UIConfig): Promise<void>;
@@ -1,8 +1,8 @@
1
- import type { PaywallData } from "../data/entities.js";
2
1
  import type { ColorGradientScheme } from "../types/colors.js";
3
2
  import type { Component } from "../types/component.js";
4
3
  import type { TextNodeProps } from "../types/components/text";
5
4
  import type { Overrides } from "../types/overrides.js";
5
+ import type { PaywallData } from "../types/paywall.js";
6
6
  import { type ColorMode } from "../types.js";
7
7
  /**
8
8
  * Gets color value based on color mode with fallback
@@ -100,8 +100,13 @@ export function findSelectedPackageId(paywallData) {
100
100
  }
101
101
  return undefined;
102
102
  };
103
- for (const component of paywallData.components_config.base.stack.components) {
104
- const pkg = traverseNode(component);
103
+ const { stack, sticky_footer } = paywallData.components_config.base;
104
+ const pkg = traverseNode(stack);
105
+ if (pkg !== undefined) {
106
+ return pkg?.package_id;
107
+ }
108
+ if (sticky_footer != null) {
109
+ const pkg = traverseNode(sticky_footer);
105
110
  if (pkg !== undefined) {
106
111
  return pkg?.package_id;
107
112
  }