@revenuecat/purchases-ui-js 2.0.0 → 2.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/components/button/Button.svelte +1 -5
- package/dist/components/button/ButtonNode.stories.svelte +62 -70
- package/dist/components/button/ButtonNode.stories.svelte.d.ts +0 -8
- package/dist/components/button/ButtonNode.svelte +11 -19
- package/dist/components/button/ButtonNode.svelte.d.ts +2 -2
- package/dist/components/button/button-utils.d.ts +2 -2
- package/dist/components/footer/Footer.stories.svelte +30 -22
- package/dist/components/footer/Footer.stories.svelte.d.ts +0 -5
- package/dist/components/footer/Footer.svelte +3 -10
- package/dist/components/footer/Footer.svelte.d.ts +1 -1
- package/dist/components/image/Image.stories.svelte +26 -7
- package/dist/components/image/Image.svelte +17 -15
- package/dist/components/image/image-utils.d.ts +2 -1
- package/dist/components/image/image-utils.js +2 -2
- package/dist/components/package/Package.stories.svelte +31 -27
- package/dist/components/package/Package.stories.svelte.d.ts +0 -6
- package/dist/components/package/Package.svelte +18 -22
- package/dist/components/package/Package.svelte.d.ts +1 -1
- package/dist/components/paywall/Node.svelte +12 -39
- package/dist/components/paywall/Node.svelte.d.ts +4 -8
- package/dist/components/paywall/Paywall.stories.svelte +21 -78
- package/dist/components/paywall/Paywall.svelte +71 -98
- package/dist/components/paywall/Paywall.svelte.d.ts +4 -4
- package/dist/components/paywall/paywall-utils.d.ts +3 -2
- package/dist/components/paywall/paywall-utils.js +5 -5
- package/dist/components/purchase-button/PurchaseButton.stories.svelte +32 -26
- package/dist/components/purchase-button/PurchaseButton.stories.svelte.d.ts +0 -5
- package/dist/components/purchase-button/PurchaseButton.svelte +7 -11
- package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +1 -1
- package/dist/components/purchase-button/purchase-button-utils.d.ts +1 -1
- package/dist/components/stack/Stack.stories.svelte +34 -79
- package/dist/components/stack/Stack.svelte +15 -25
- package/dist/components/stack/stack-utils.d.ts +4 -3
- package/dist/components/stack/stack-utils.js +7 -8
- package/dist/components/text/TextNode.stories.svelte +46 -141
- package/dist/components/text/TextNode.svelte +13 -12
- package/dist/components/text/text-utils.d.ts +7 -6
- package/dist/components/text/text-utils.js +7 -7
- package/dist/components/timeline/Timeline.stories.svelte +41 -47
- package/dist/components/timeline/TimelineItem.svelte +28 -11
- package/dist/components/timeline/timeline-utils.d.ts +3 -3
- package/dist/components/timeline/timeline-utils.js +7 -16
- package/dist/data/entities.d.ts +59 -120
- package/dist/data/state.d.ts +0 -5
- package/dist/stores/color-mode.d.ts +6 -0
- package/dist/stores/color-mode.js +15 -0
- package/dist/stores/localization.d.ts +13 -0
- package/dist/stores/localization.js +25 -0
- package/dist/stores/paywall.d.ts +10 -0
- package/dist/stores/paywall.js +13 -0
- package/dist/stores/variables.d.ts +6 -0
- package/dist/stores/variables.js +14 -0
- package/dist/stories/fixtures.js +7 -76
- package/dist/stories/localization-decorator.d.ts +3 -0
- package/dist/stories/localization-decorator.js +7 -0
- package/dist/stories/paywall-decorator.d.ts +2 -0
- package/dist/stories/paywall-decorator.js +18 -0
- package/dist/stories/variables-decorator.d.ts +3 -0
- package/dist/stories/variables-decorator.js +9 -0
- package/dist/stories/with-layout.svelte +1 -1
- package/dist/types/alignment.d.ts +19 -0
- package/dist/types/alignment.js +1 -0
- package/dist/types/background.d.ts +18 -0
- package/dist/types/background.js +1 -0
- package/dist/types/colors.d.ts +34 -0
- package/dist/types/colors.js +1 -0
- package/dist/types/components/button.d.ts +36 -0
- package/dist/types/components/button.js +1 -0
- package/dist/types/components/footer.d.ts +5 -0
- package/dist/types/components/footer.js +1 -0
- package/dist/types/components/package.d.ts +8 -0
- package/dist/types/components/package.js +1 -0
- package/dist/types/components/purchase-button.d.ts +5 -0
- package/dist/types/components/purchase-button.js +1 -0
- package/dist/types/localization.d.ts +4 -0
- package/dist/types/localization.js +1 -0
- package/dist/types/media.d.ts +18 -0
- package/dist/types/media.js +1 -0
- package/dist/types.d.ts +5 -35
- package/dist/ui/atoms/typography.stories.svelte +8 -14
- package/dist/ui/atoms/typography.svelte +1 -1
- package/dist/ui/molecules/button.stories.svelte +8 -15
- package/dist/ui/molecules/button.svelte +2 -1
- package/dist/ui/molecules/button.svelte.d.ts +2 -26
- package/dist/ui/molecules/types.d.ts +2 -1
- package/dist/utils/style-utils.d.ts +13 -11
- package/dist/utils/style-utils.js +8 -15
- package/dist/utils/variable-utils.d.ts +1 -38
- package/dist/utils/variable-utils.js +6 -48
- package/dist/web-components/index.js +519 -566
- package/package.json +33 -36
- package/dist/stores/theme.d.ts +0 -1
- package/dist/stores/theme.js +0 -17
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { setPaywallContext } from "../stores/paywall";
|
|
2
|
+
import { writable } from "svelte/store";
|
|
3
|
+
export function paywallDecorator() {
|
|
4
|
+
return (Story) => {
|
|
5
|
+
const selectedPackageId = writable(undefined);
|
|
6
|
+
selectedPackageId.subscribe((packageId) => {
|
|
7
|
+
if (packageId !== undefined) {
|
|
8
|
+
window.alert(`Selected package ${packageId}`);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
setPaywallContext({
|
|
12
|
+
selectedPackageId,
|
|
13
|
+
onPurchase: () => window.alert("Purchase clicked"),
|
|
14
|
+
onButtonAction: (action) => window.alert(`Button clicked: ${JSON.stringify(action, undefined, 2)}`),
|
|
15
|
+
});
|
|
16
|
+
return Story();
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { VariableDictionary } from "../utils/variable-utils";
|
|
2
|
+
import type { DecoratorFunction, Renderer } from "storybook/internal/csf";
|
|
3
|
+
export declare function variablesDecorator<TRenderer extends Renderer, TArgs>(variables?: VariableDictionary): DecoratorFunction<TRenderer, TArgs>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { setVariablesContext } from "../stores/variables";
|
|
2
|
+
import { readable } from "svelte/store";
|
|
3
|
+
export function variablesDecorator(variables) {
|
|
4
|
+
const store = readable(variables);
|
|
5
|
+
return (Story) => {
|
|
6
|
+
setVariablesContext(store);
|
|
7
|
+
return Story();
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Distribution = "start" | "center" | "end" | "space_between" | "space_around" | "space_evenly";
|
|
2
|
+
export type VerticalAlignment = "top" | "center" | "bottom";
|
|
3
|
+
export type HorizontalDimension = {
|
|
4
|
+
type: "horizontal";
|
|
5
|
+
alignment: VerticalAlignment;
|
|
6
|
+
distribution: Distribution;
|
|
7
|
+
};
|
|
8
|
+
export type HorizontalAlignment = "leading" | "center" | "trailing";
|
|
9
|
+
export type VerticalDimension = {
|
|
10
|
+
type: "vertical";
|
|
11
|
+
alignment: HorizontalAlignment;
|
|
12
|
+
distribution: Distribution;
|
|
13
|
+
};
|
|
14
|
+
export type ZAlignment = "top_leading" | "top" | "top_trailing" | "leading" | "center" | "trailing" | "bottom_leading" | "bottom" | "bottom_trailing";
|
|
15
|
+
export type ZDimension = {
|
|
16
|
+
type: "zlayer";
|
|
17
|
+
alignment: ZAlignment;
|
|
18
|
+
};
|
|
19
|
+
export type Dimension = HorizontalDimension | VerticalDimension | ZDimension;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ColorGradientScheme } from "./colors";
|
|
2
|
+
import type { ImageInfo, ImageObjectFit, VideoInfo } from "./media";
|
|
3
|
+
export type BackgroundColor = {
|
|
4
|
+
type: "color";
|
|
5
|
+
value: ColorGradientScheme;
|
|
6
|
+
};
|
|
7
|
+
export type BackgroundImage = {
|
|
8
|
+
type: "image";
|
|
9
|
+
value: ImageInfo;
|
|
10
|
+
color_overlay: ColorGradientScheme | null;
|
|
11
|
+
fit_mode: ImageObjectFit;
|
|
12
|
+
};
|
|
13
|
+
export type BackgroundVideo = {
|
|
14
|
+
type: "video";
|
|
15
|
+
value: VideoInfo;
|
|
16
|
+
color_overlay: ColorGradientScheme | null;
|
|
17
|
+
};
|
|
18
|
+
export type Background = BackgroundColor | BackgroundImage | BackgroundVideo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type GradientPoint = {
|
|
2
|
+
percent: number;
|
|
3
|
+
color: string;
|
|
4
|
+
};
|
|
5
|
+
type GradientColorInfo = {
|
|
6
|
+
type: "linear" | "radial";
|
|
7
|
+
points: GradientPoint[];
|
|
8
|
+
};
|
|
9
|
+
export type LinearGradientColorInfo = GradientColorInfo & {
|
|
10
|
+
type: "linear";
|
|
11
|
+
degrees: number;
|
|
12
|
+
};
|
|
13
|
+
export type RadialGradientColorInfo = GradientColorInfo & {
|
|
14
|
+
type: "radial";
|
|
15
|
+
};
|
|
16
|
+
type AliasColorInfo = {
|
|
17
|
+
type: "alias";
|
|
18
|
+
value: string;
|
|
19
|
+
};
|
|
20
|
+
type HexColorInfo = {
|
|
21
|
+
type: "hex";
|
|
22
|
+
value: string;
|
|
23
|
+
};
|
|
24
|
+
export type ColorInfo = AliasColorInfo | HexColorInfo;
|
|
25
|
+
export type ColorGradientInfo = ColorInfo | LinearGradientColorInfo | RadialGradientColorInfo;
|
|
26
|
+
export type ColorScheme = {
|
|
27
|
+
light: ColorInfo;
|
|
28
|
+
dark?: ColorInfo | null;
|
|
29
|
+
};
|
|
30
|
+
export type ColorGradientScheme = {
|
|
31
|
+
light: ColorGradientInfo;
|
|
32
|
+
dark?: ColorGradientInfo | null;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SharedComponentProps, StackProps } from "../../data/entities";
|
|
2
|
+
interface RestorePurchasesAction {
|
|
3
|
+
type: "restore_purchases";
|
|
4
|
+
}
|
|
5
|
+
interface NavigateBackAction {
|
|
6
|
+
type: "navigate_back";
|
|
7
|
+
}
|
|
8
|
+
interface NavigateToAction {
|
|
9
|
+
type: "navigate_to";
|
|
10
|
+
destination: "customer_center" | "offer_code";
|
|
11
|
+
}
|
|
12
|
+
interface NavigateToSheetAction {
|
|
13
|
+
type: "navigate_to";
|
|
14
|
+
destination: "sheet";
|
|
15
|
+
sheet?: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface NavigateToWebPurchase {
|
|
18
|
+
type: "navigate_to";
|
|
19
|
+
destination: "web_paywall_link";
|
|
20
|
+
custom_url_options?: unknown;
|
|
21
|
+
}
|
|
22
|
+
interface NavigateToUrlAction {
|
|
23
|
+
type: "navigate_to";
|
|
24
|
+
destination: "privacy_policy" | "terms" | "url";
|
|
25
|
+
url: {
|
|
26
|
+
url_lid: string;
|
|
27
|
+
method: "deep_link" | "external_browser" | "in_app_browser";
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export type Action = RestorePurchasesAction | NavigateBackAction | NavigateToAction | NavigateToSheetAction | NavigateToWebPurchase | NavigateToUrlAction;
|
|
31
|
+
export interface ButtonProps extends SharedComponentProps {
|
|
32
|
+
type: "button";
|
|
33
|
+
action: Action;
|
|
34
|
+
stack: StackProps;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SharedComponentProps, StackProps } from "../../data/entities";
|
|
2
|
+
export interface PackageProps extends SharedComponentProps {
|
|
3
|
+
type: "package";
|
|
4
|
+
package_id: string;
|
|
5
|
+
is_selected_by_default: boolean;
|
|
6
|
+
apple_promo_offer_product_code?: string | null;
|
|
7
|
+
stack: StackProps;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ImageFiles = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
original: string;
|
|
5
|
+
heic: string;
|
|
6
|
+
heic_low_res: string;
|
|
7
|
+
webp: string;
|
|
8
|
+
webp_low_res: string;
|
|
9
|
+
};
|
|
10
|
+
export type ImageInfo = {
|
|
11
|
+
light: ImageFiles;
|
|
12
|
+
dark: ImageFiles | null;
|
|
13
|
+
};
|
|
14
|
+
export type VideoInfo = {
|
|
15
|
+
light: string;
|
|
16
|
+
dark: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type ImageObjectFit = "fit" | "fill";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
+
import type { ColorScheme } from "./types/colors";
|
|
1
2
|
export type ColorMode = "light" | "dark";
|
|
2
|
-
export type ColorStop = {
|
|
3
|
-
color: string;
|
|
4
|
-
percent: number;
|
|
5
|
-
};
|
|
6
|
-
export type Color = {
|
|
7
|
-
type: "hex" | "alias" | "linear" | "radial";
|
|
8
|
-
value?: string;
|
|
9
|
-
degrees?: number;
|
|
10
|
-
points?: ColorStop[];
|
|
11
|
-
};
|
|
12
|
-
export type ColorType = {
|
|
13
|
-
dark?: Color;
|
|
14
|
-
light: Color;
|
|
15
|
-
};
|
|
16
3
|
export declare enum FontSizeTags {
|
|
17
4
|
body_s = "p",
|
|
18
5
|
body_m = "p",
|
|
@@ -58,13 +45,13 @@ export type SizeType = {
|
|
|
58
45
|
height: Size;
|
|
59
46
|
};
|
|
60
47
|
export type Size = FixedSize | RelativeSize;
|
|
61
|
-
export type FitTypes = "fit" | "fill";
|
|
62
48
|
type FixedSize = {
|
|
63
49
|
type: "fixed";
|
|
64
50
|
value: number;
|
|
65
51
|
};
|
|
66
52
|
type RelativeSize = {
|
|
67
|
-
type:
|
|
53
|
+
type: "fit" | "fill";
|
|
54
|
+
value?: null;
|
|
68
55
|
};
|
|
69
56
|
export type ShapeType = RectangleShape | PillShape;
|
|
70
57
|
export type RectangleShape = {
|
|
@@ -78,7 +65,7 @@ type PillShape = {
|
|
|
78
65
|
type: "pill";
|
|
79
66
|
};
|
|
80
67
|
export type BorderType = {
|
|
81
|
-
color:
|
|
68
|
+
color: ColorScheme;
|
|
82
69
|
width: number;
|
|
83
70
|
};
|
|
84
71
|
export type Spacing = {
|
|
@@ -93,29 +80,12 @@ export type CornerRadiusType = {
|
|
|
93
80
|
top_leading: number;
|
|
94
81
|
top_trailing: number;
|
|
95
82
|
};
|
|
96
|
-
export type DimensionType = VerticalAlignment | HorizontalAlignment | ZAlignment;
|
|
97
|
-
type VerticalAlignment = {
|
|
98
|
-
type: "vertical";
|
|
99
|
-
alignment: "top" | "center" | "bottom";
|
|
100
|
-
distribution?: Distribution;
|
|
101
|
-
};
|
|
102
|
-
type HorizontalAlignment = {
|
|
103
|
-
type: "horizontal";
|
|
104
|
-
alignment: "leading" | "center" | "trailing";
|
|
105
|
-
distribution?: Distribution;
|
|
106
|
-
};
|
|
107
83
|
export type AlignmentType = "top_leading" | "top" | "top_trailing" | "leading" | "center" | "trailing" | "bottom_leading" | "bottom" | "bottom_trailing";
|
|
108
|
-
export type ZAlignment = {
|
|
109
|
-
type: "zlayer";
|
|
110
|
-
alignment: AlignmentType;
|
|
111
|
-
distribution?: never;
|
|
112
|
-
};
|
|
113
|
-
type Distribution = "space_between" | "space_around" | "space_evenly" | "start" | "center" | "end";
|
|
114
84
|
export type ShadowType = {
|
|
115
85
|
x: number;
|
|
116
86
|
y: number;
|
|
117
87
|
radius: number;
|
|
118
|
-
color:
|
|
88
|
+
color: ColorScheme;
|
|
119
89
|
};
|
|
120
90
|
export declare enum StackDirection {
|
|
121
91
|
vertical = "column",
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
type Args,
|
|
5
|
-
defineMeta,
|
|
6
|
-
setTemplate,
|
|
7
|
-
} from "@storybook/addon-svelte-csf";
|
|
8
|
-
import { withLayout } from "../../stories/with-layout";
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import { type ComponentProps } from "svelte";
|
|
9
4
|
import { brandingViewportModes } from "../../../../.storybook/modes";
|
|
5
|
+
import { withLayout } from "../../stories/with-layout";
|
|
6
|
+
import { default as Typography } from "../../ui/atoms/typography.svelte";
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
const { Story } = defineMeta({
|
|
12
9
|
component: Typography,
|
|
13
10
|
title: "Atoms/Typography",
|
|
14
11
|
// @ts-expect-error ignore typing of decorator
|
|
@@ -35,16 +32,13 @@
|
|
|
35
32
|
modes: brandingViewportModes,
|
|
36
33
|
},
|
|
37
34
|
},
|
|
35
|
+
render: template,
|
|
38
36
|
});
|
|
39
37
|
|
|
40
38
|
const baseContent = "The quick brown fox jumps over the lazy dog";
|
|
41
39
|
</script>
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
setTemplate(template);
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
{#snippet template({ size = "body-base" }: Args<typeof Story>)}
|
|
41
|
+
{#snippet template({ size = "body-base" }: ComponentProps<typeof Typography>)}
|
|
48
42
|
<Typography {size}>
|
|
49
43
|
{#snippet children()}
|
|
50
44
|
Default text
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
<script module>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta, type StoryContext } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import type { ComponentProps } from "svelte";
|
|
2
4
|
import { brandingAppearances } from "../../stories/fixtures";
|
|
3
|
-
import { default as Button } from "./button.svelte";
|
|
4
|
-
import {
|
|
5
|
-
type Args,
|
|
6
|
-
defineMeta,
|
|
7
|
-
setTemplate,
|
|
8
|
-
type StoryContext,
|
|
9
|
-
} from "@storybook/addon-svelte-csf";
|
|
10
5
|
import { withLayout } from "../../stories/with-layout";
|
|
6
|
+
import { default as Button } from "./button.svelte";
|
|
11
7
|
|
|
12
|
-
|
|
8
|
+
const { Story } = defineMeta({
|
|
13
9
|
component: Button,
|
|
14
10
|
title: "Molecules/Button",
|
|
15
11
|
// @ts-expect-error ignore typing of decorator
|
|
@@ -20,6 +16,7 @@
|
|
|
20
16
|
options: ["primary", undefined],
|
|
21
17
|
},
|
|
22
18
|
},
|
|
19
|
+
render: template,
|
|
23
20
|
});
|
|
24
21
|
|
|
25
22
|
const args = {
|
|
@@ -30,13 +27,9 @@
|
|
|
30
27
|
};
|
|
31
28
|
</script>
|
|
32
29
|
|
|
33
|
-
<script lang="ts">
|
|
34
|
-
setTemplate(template);
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
30
|
{#snippet template(
|
|
38
|
-
{ ...args }:
|
|
39
|
-
context: StoryContext<typeof
|
|
31
|
+
{ ...args }: ComponentProps<typeof Button>,
|
|
32
|
+
context: StoryContext<typeof Button>,
|
|
40
33
|
)}
|
|
41
34
|
{@const brandingInfo = brandingAppearances[context.globals.brandingName]}
|
|
42
35
|
<Button {...args} brandingAppearance={brandingInfo ?? undefined}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
loading = false,
|
|
14
14
|
brandingAppearance,
|
|
15
15
|
styleOverrides,
|
|
16
|
+
children,
|
|
16
17
|
}: UIButtonProps = $props();
|
|
17
18
|
|
|
18
19
|
const theme = $derived(new Theme(brandingAppearance));
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
{#if loading}
|
|
40
41
|
<ProcessingAnimation size="small" />
|
|
41
42
|
{:else}
|
|
42
|
-
<Typography size="body-base"
|
|
43
|
+
<Typography size="body-base">{@render children?.()}</Typography>
|
|
43
44
|
{/if}
|
|
44
45
|
</button>
|
|
45
46
|
|
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
import type { UIButtonProps } from "./types";
|
|
2
|
-
|
|
3
|
-
|
|
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>;
|
|
2
|
+
declare const Button: import("svelte").Component<UIButtonProps, {}, "">;
|
|
3
|
+
type Button = ReturnType<typeof Button>;
|
|
28
4
|
export default Button;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
1
2
|
import type { BrandingAppearance } from "../utils/branding";
|
|
2
3
|
export interface UIButtonProps {
|
|
3
4
|
onclick?: (event: any) => void;
|
|
4
|
-
children?:
|
|
5
|
+
children?: Snippet;
|
|
5
6
|
intent?: "primary";
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
testId?: string | undefined;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ComponentState, ImageMaskShapeType, ImageProps, PaywallData, TextNodeProps } from "../data/entities.js";
|
|
2
|
-
import
|
|
2
|
+
import type { Dimension } from "../types/alignment.js";
|
|
3
|
+
import type { ColorGradientScheme, ColorScheme } from "../types/colors.js";
|
|
4
|
+
import { type BorderType, type ColorMode, type CornerRadiusType, FontSizeTags, type ShadowType, type ShapeType, type SizeType, type Spacing } from "../types.js";
|
|
3
5
|
type MarginVariables = {
|
|
4
6
|
"--margin-block-start": string;
|
|
5
7
|
"--margin-inline-end": string;
|
|
@@ -26,7 +28,7 @@ export declare function getTextComponentTag(fontSize: keyof typeof FontSizeTags)
|
|
|
26
28
|
* @returns Color value as string
|
|
27
29
|
*/
|
|
28
30
|
export declare function getColor({ colorMap, colorMode, fallback, }: {
|
|
29
|
-
colorMap?:
|
|
31
|
+
colorMap?: ColorGradientScheme | null;
|
|
30
32
|
colorMode?: ColorMode;
|
|
31
33
|
fallback?: string;
|
|
32
34
|
}): string;
|
|
@@ -63,12 +65,12 @@ type ComponentStyleVariables = {
|
|
|
63
65
|
export declare function getComponentStyles({ background_color, border, margin, padding, color, colorMode, shape, shadow, }: {
|
|
64
66
|
padding?: Spacing;
|
|
65
67
|
margin?: Spacing;
|
|
66
|
-
background_color?:
|
|
67
|
-
color?:
|
|
68
|
-
border?: BorderType;
|
|
68
|
+
background_color?: ColorGradientScheme | null;
|
|
69
|
+
color?: ColorScheme;
|
|
70
|
+
border?: BorderType | null;
|
|
69
71
|
colorMode?: ColorMode;
|
|
70
|
-
shape?: ShapeType;
|
|
71
|
-
shadow?: ShadowType;
|
|
72
|
+
shape?: ShapeType | null;
|
|
73
|
+
shadow?: ShadowType | null;
|
|
72
74
|
}): ComponentStyleVariables;
|
|
73
75
|
type SizeStyleVariables = {
|
|
74
76
|
"--width": string;
|
|
@@ -85,7 +87,7 @@ type InsetStyleVariables = {
|
|
|
85
87
|
"--inset": string;
|
|
86
88
|
"--transform": string;
|
|
87
89
|
};
|
|
88
|
-
export declare function getInsetStyles(dimension:
|
|
90
|
+
export declare function getInsetStyles(dimension: Dimension): InsetStyleVariables;
|
|
89
91
|
type DimensionVariableType = {
|
|
90
92
|
"--direction": string;
|
|
91
93
|
"--alignment": string;
|
|
@@ -99,7 +101,7 @@ type DimensionVariableType = {
|
|
|
99
101
|
* @param dimension - Dimension configuration object
|
|
100
102
|
* @returns CSS style object with flex layout properties
|
|
101
103
|
*/
|
|
102
|
-
export declare function getDimensionStyle(dimension:
|
|
104
|
+
export declare function getDimensionStyle(dimension: Dimension): DimensionVariableType;
|
|
103
105
|
type TextStyleVariables = {
|
|
104
106
|
"--text-align": string;
|
|
105
107
|
"--font-weight": number | string;
|
|
@@ -115,7 +117,7 @@ type TextStyleVariables = {
|
|
|
115
117
|
* @param colorMode - The currently selected ColorMode (dark/light)
|
|
116
118
|
* @returns CSS style object with text formatting properties
|
|
117
119
|
*/
|
|
118
|
-
export declare function getTextStyles(props: TextNodeProps
|
|
120
|
+
export declare function getTextStyles(props: TextNodeProps): TextStyleVariables;
|
|
119
121
|
/**
|
|
120
122
|
* Converts a style object to a CSS string
|
|
121
123
|
* @param styles - Object containing CSS properties and values
|
|
@@ -147,7 +149,7 @@ type MaskStyleVariables = {
|
|
|
147
149
|
* @returns CSS style object with mask properties
|
|
148
150
|
*/
|
|
149
151
|
export declare const getMaskStyle: (maskShape?: ImageMaskShapeType) => MaskStyleVariables;
|
|
150
|
-
export declare function getLinearGradientAngle(props: ImageProps & {
|
|
152
|
+
export declare function getLinearGradientAngle(colorMode: ColorMode, props: ImageProps & {
|
|
151
153
|
imageAspectRatio: number;
|
|
152
154
|
}): {
|
|
153
155
|
x1: string;
|
|
@@ -41,7 +41,7 @@ export function getColor({ colorMap, colorMode = DEFAULT_COLOR_MODE, fallback =
|
|
|
41
41
|
return fallback;
|
|
42
42
|
const color = colorMap[colorMode] || colorMap[DEFAULT_COLOR_MODE];
|
|
43
43
|
let colorPoints = "";
|
|
44
|
-
switch (color
|
|
44
|
+
switch (color?.type) {
|
|
45
45
|
case "hex":
|
|
46
46
|
case "alias":
|
|
47
47
|
return color.value ?? fallback;
|
|
@@ -257,8 +257,8 @@ export function getDimensionStyle(dimension) {
|
|
|
257
257
|
* @param colorMode - The currently selected ColorMode (dark/light)
|
|
258
258
|
* @returns CSS style object with text formatting properties
|
|
259
259
|
*/
|
|
260
|
-
export function getTextStyles(props
|
|
261
|
-
const { font_size, horizontal_alignment, font_weight, font_name
|
|
260
|
+
export function getTextStyles(props) {
|
|
261
|
+
const { font_size, horizontal_alignment, font_weight, font_name } = props;
|
|
262
262
|
const styles = {
|
|
263
263
|
"--text-align": "initial",
|
|
264
264
|
"--font-weight": "initial",
|
|
@@ -274,14 +274,6 @@ export function getTextStyles(props, colorMode = DEFAULT_COLOR_MODE) {
|
|
|
274
274
|
"--font-size": FontSizes[font_size] || FontSizes.body_m,
|
|
275
275
|
"--font-family": font_name || "sans-serif",
|
|
276
276
|
});
|
|
277
|
-
if (color &&
|
|
278
|
-
(color[colorMode]?.type === "linear" || color[colorMode]?.type === "radial")) {
|
|
279
|
-
Object.assign(styles, {
|
|
280
|
-
"--background-clip": "text",
|
|
281
|
-
"--text-fill-color": "transparent",
|
|
282
|
-
"--background": getColor({ colorMap: color, colorMode }),
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
277
|
return styles;
|
|
286
278
|
}
|
|
287
279
|
/**
|
|
@@ -400,12 +392,13 @@ export const getMaskStyle = (maskShape) => {
|
|
|
400
392
|
}
|
|
401
393
|
return maskStyles;
|
|
402
394
|
};
|
|
403
|
-
export function getLinearGradientAngle(props) {
|
|
404
|
-
|
|
395
|
+
export function getLinearGradientAngle(colorMode, props) {
|
|
396
|
+
const { color_overlay: colorOverlay } = props;
|
|
397
|
+
if (colorOverlay?.[colorMode]?.type !== "linear") {
|
|
405
398
|
return { x1: "0%", y1: "0%", x2: "0%", y2: "0%" };
|
|
406
399
|
}
|
|
407
|
-
const
|
|
408
|
-
const angle =
|
|
400
|
+
const defaultColor = colorOverlay?.[DEFAULT_COLOR_MODE];
|
|
401
|
+
const angle = defaultColor?.type === "linear" ? defaultColor.degrees : 0;
|
|
409
402
|
const x1 = "50%";
|
|
410
403
|
const y1 = "0%";
|
|
411
404
|
const x2 = `${Math.round(50 + Math.sin(((angle + 90) * Math.PI) / 90) * 50)}%`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ComponentLocalizations } from "../data/entities";
|
|
2
1
|
export declare const VARIABLE_NAMES: string[];
|
|
3
2
|
export type VariableDictionary = {
|
|
4
3
|
product_name: string | number | undefined;
|
|
@@ -21,40 +20,4 @@ export type VariableDictionary = {
|
|
|
21
20
|
sub_relative_discount: string | number | undefined;
|
|
22
21
|
[key: string]: string | number | undefined;
|
|
23
22
|
};
|
|
24
|
-
export
|
|
25
|
-
value?: string;
|
|
26
|
-
variableDictionary?: VariableDictionary;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Returns a string with the variables replaced by values from the dictionary
|
|
30
|
-
* @param value A string like "Try {{ product_name }} for only {{ total_price_and_per_month }}"
|
|
31
|
-
* @param dictionary Dictionary containing the values for the variables
|
|
32
|
-
* @returns The string with values: "Try CatGPT Annual for only $59.99/yr ($4.99/mo)"
|
|
33
|
-
*/
|
|
34
|
-
export declare const replaceVariables: ({ value, variableDictionary: dictionary, }: ReplaceVariablesProps) => string | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Given a ComponentLocalizations object and a locale returns the label with label_id in the chosen locale, if any. Falls
|
|
37
|
-
* back to the label with the same label_id in the fallbackLocale, if any. Finally returns undefined if no label can be
|
|
38
|
-
* found for the requested label_id.
|
|
39
|
-
* @param label_id - The id of the label to be returned
|
|
40
|
-
* @param locale - The preferred locale to return the label
|
|
41
|
-
* @param fallbackLocale - The locale to fall back to in case no label is found in the preferred one
|
|
42
|
-
* @param labels - A ComponentLocalizations instance
|
|
43
|
-
* @returns The label in the preferred or fallback locale, or undefined.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getLabelById(label_id: string | null | undefined, locale: string, fallbackLocale: string, labels: ComponentLocalizations): string | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Gets a label by ID and replaces any variables in it with values from the dictionary
|
|
48
|
-
* @param text_lid - The ID of the text label to retrieve
|
|
49
|
-
* @param purchaseState - Object containing locale and defaultLocale
|
|
50
|
-
* @param labels - ComponentLocalizations containing the labels
|
|
51
|
-
* @param variableDictionary - Dictionary of variables to replace in the label text
|
|
52
|
-
* @returns The label with variables replaced, or undefined if label not found
|
|
53
|
-
*/
|
|
54
|
-
export declare function getLabelAndReplaceVariables({ text_lid, locale, defaultLocale, labels, variableDictionary, }: {
|
|
55
|
-
text_lid?: string;
|
|
56
|
-
locale: string;
|
|
57
|
-
defaultLocale: string;
|
|
58
|
-
labels: ComponentLocalizations;
|
|
59
|
-
variableDictionary?: VariableDictionary;
|
|
60
|
-
}): string | undefined;
|
|
23
|
+
export declare function replaceVariables(input?: string, variables?: VariableDictionary): string | undefined;
|