@revenuecat/purchases-ui-js 0.1.21 → 1.0.1

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./types";
2
+ export * from "./ui/globals";
2
3
  export { type PaywallData as PaywallData } from "./data/entities";
3
4
  export { type VariableDictionary } from "./utils/variable-utils";
4
5
  export { default as Paywall } from "./components/paywall/Paywall.svelte";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Reexport your entry components here
2
2
  export * from "./types";
3
+ export * from "./ui/globals";
3
4
  export {} from "./data/entities";
4
5
  export {} from "./utils/variable-utils";
5
6
  export { default as Paywall } from "./components/paywall/Paywall.svelte";
@@ -0,0 +1,9 @@
1
+ import type { UIButtonProps } from "./molecules/types";
2
+ declare module "react" {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ "ui-button": UIButtonProps;
6
+ }
7
+ }
8
+ }
9
+ export {};
@@ -0,0 +1,3 @@
1
+ // Namespacing is the only supported method to augment JSX.IntrinsicElements
2
+ /* eslint-disable @typescript-eslint/no-namespace */
3
+ export {};
@@ -0,0 +1,2 @@
1
+ import Button from "./molecules/button.svelte";
2
+ export { Button };
@@ -0,0 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore: Hide misleading 'missing type declaration' build error.
3
+ import Button from "./molecules/button.svelte";
4
+ export { Button };
@@ -1,9 +1,11 @@
1
1
  <script module>
2
+ import { brandingAppearances } from "../../stories/fixtures";
2
3
  import { default as Button } from "./button.svelte";
3
4
  import {
4
5
  type Args,
5
6
  defineMeta,
6
7
  setTemplate,
8
+ type StoryContext,
7
9
  } from "@storybook/addon-svelte-csf";
8
10
  import { withLayout } from "../../stories/with-layout";
9
11
 
@@ -32,12 +34,14 @@
32
34
  setTemplate(template);
33
35
  </script>
34
36
 
35
- {#snippet template({ ...args }: Args<typeof Story>)}
36
- <Button {...args}>
37
- {#snippet children()}
38
- Click Me
39
- {/snippet}
40
- </Button>
37
+ {#snippet template(
38
+ { ...args }: Args<typeof Story>,
39
+ context: StoryContext<typeof Story>,
40
+ )}
41
+ {@const brandingInfo = brandingAppearances[context.globals.brandingName]}
42
+ <Button {...args} brandingAppearance={brandingInfo ?? undefined}
43
+ >Click Me</Button
44
+ >
41
45
  {/snippet}
42
46
 
43
47
  <Story name="Default" {args} />
@@ -1,17 +1,10 @@
1
+ <svelte:options customElement="ui-button" />
2
+
1
3
  <script lang="ts">
2
- import { type Snippet } from "svelte";
3
4
  import ProcessingAnimation from "../utils/processing-animation.svelte";
4
5
  import Typography from "../atoms/typography.svelte";
5
-
6
- type Props = {
7
- onclick?: () => void;
8
- intent?: "primary";
9
- disabled?: boolean;
10
- testId?: string | undefined;
11
- type?: "reset" | "submit" | "button" | null | undefined;
12
- loading?: boolean;
13
- children: Snippet | undefined;
14
- };
6
+ import { Theme } from "../theme/theme";
7
+ import type { UIButtonProps } from "./types";
15
8
 
16
9
  const {
17
10
  onclick,
@@ -20,8 +13,21 @@
20
13
  testId,
21
14
  type,
22
15
  loading = false,
23
- children,
24
- }: Props = $props();
16
+ brandingAppearance,
17
+ styleOverrides,
18
+ }: UIButtonProps = $props();
19
+
20
+ const theme = $derived(new Theme(brandingAppearance));
21
+ const textStyle = $derived(theme.textStyleVars);
22
+ const spacingStyle = $derived(theme.spacingStyleVars);
23
+ const productInfoStyle = $derived(theme.productInfoStyleVars);
24
+ const formStyle = $derived(theme.formStyleVars);
25
+
26
+ const combinedStyle = $derived(
27
+ [styleOverrides, textStyle, spacingStyle, productInfoStyle, formStyle].join(
28
+ "; ",
29
+ ),
30
+ );
25
31
  </script>
26
32
 
27
33
  <button
@@ -30,11 +36,12 @@
30
36
  {disabled}
31
37
  data-testid={testId}
32
38
  {type}
39
+ style={combinedStyle}
33
40
  >
34
41
  {#if loading}
35
42
  <ProcessingAnimation size="small" />
36
43
  {:else}
37
- <Typography size="body-base">{@render children?.()}</Typography>
44
+ <Typography size="body-base"><slot></slot></Typography>
38
45
  {/if}
39
46
  </button>
40
47
 
@@ -1,13 +1,28 @@
1
- import { type Snippet } from "svelte";
2
- type Props = {
3
- onclick?: () => void;
4
- intent?: "primary";
5
- disabled?: boolean;
6
- testId?: string | undefined;
7
- type?: "reset" | "submit" | "button" | null | undefined;
8
- loading?: boolean;
9
- children: Snippet | undefined;
10
- };
11
- declare const Button: import("svelte").Component<Props, {}, "">;
12
- type Button = ReturnType<typeof Button>;
1
+ import type { UIButtonProps } from "./types";
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
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
16
+ default: any;
17
+ } ? Props extends Record<string, never> ? any : {
18
+ children?: any;
19
+ } : {});
20
+ declare const Button: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<UIButtonProps, {
21
+ default: {};
22
+ }>, {
23
+ [evt: string]: CustomEvent<any>;
24
+ }, {
25
+ default: {};
26
+ }, {}, "">;
27
+ type Button = InstanceType<typeof Button>;
13
28
  export default Button;
@@ -0,0 +1,13 @@
1
+ import type { BrandingAppearance } from "../utils/branding";
2
+ export interface UIButtonProps {
3
+ onclick?: (event: any) => void;
4
+ children?: unknown;
5
+ intent?: "primary";
6
+ disabled?: boolean;
7
+ testId?: string | undefined;
8
+ type?: "reset" | "submit" | "button" | null | undefined;
9
+ loading?: boolean;
10
+ brandingAppearance?: BrandingAppearance;
11
+ styleOverrides?: string;
12
+ style?: Record<string, string> | string | undefined;
13
+ }
@@ -0,0 +1 @@
1
+ export {};