@revenuecat/purchases-ui-js 2.0.6 → 2.1.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/ButtonNode.stories.svelte +20 -0
- package/dist/components/button/ButtonNode.svelte +7 -1
- package/dist/components/package/Package.stories.svelte +0 -1
- package/dist/components/package/Package.svelte +13 -1
- package/dist/components/paywall/Paywall.svelte +26 -2
- package/dist/components/paywall/Paywall.svelte.d.ts +3 -1
- package/dist/components/text/TextNode.stories.svelte +151 -1
- package/dist/components/text/TextNode.svelte +15 -4
- package/dist/components/text/text-utils.d.ts +5 -5
- package/dist/components/text/text-utils.js +34 -19
- package/dist/components/timeline/TimelineItem.svelte +4 -8
- package/dist/index.d.ts +1 -1
- package/dist/stores/packageInfo.d.ts +5 -0
- package/dist/stores/packageInfo.js +13 -0
- package/dist/stores/paywall.d.ts +3 -2
- package/dist/stories/packageInfo-decorator.d.ts +3 -0
- package/dist/stories/packageInfo-decorator.js +9 -0
- package/dist/stories/paywall-decorator.js +2 -1
- package/dist/types/base.d.ts +1 -0
- package/dist/types/components/button.d.ts +7 -1
- package/dist/types/components/text.d.ts +2 -2
- package/dist/types/ui-config.d.ts +1 -1
- package/dist/types/variables.d.ts +4 -0
- package/dist/utils/base-utils.d.ts +2 -1
- package/dist/utils/base-utils.js +1 -1
- package/dist/utils/style-utils.d.ts +1 -30
- package/dist/utils/style-utils.js +8 -66
- package/dist/web-components/index.js +1083 -908
- package/package.json +19 -19
|
@@ -2,6 +2,9 @@ import type { BaseComponent } from "../base";
|
|
|
2
2
|
import type { Overrides } from "../overrides";
|
|
3
3
|
import type { SheetProps } from "./sheet";
|
|
4
4
|
import type { StackProps } from "./stack";
|
|
5
|
+
interface WorkflowAction {
|
|
6
|
+
type: "workflow";
|
|
7
|
+
}
|
|
5
8
|
interface RestorePurchasesAction {
|
|
6
9
|
type: "restore_purchases";
|
|
7
10
|
}
|
|
@@ -31,12 +34,15 @@ interface NavigateToUrlAction {
|
|
|
31
34
|
method: "deep_link" | "external_browser" | "in_app_browser";
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
|
-
export type Action = RestorePurchasesAction | NavigateBackAction | NavigateToAction | NavigateToSheetAction | NavigateToWebPurchase | NavigateToUrlAction;
|
|
37
|
+
export type Action = WorkflowAction | RestorePurchasesAction | NavigateBackAction | NavigateToAction | NavigateToSheetAction | NavigateToWebPurchase | NavigateToUrlAction;
|
|
35
38
|
export interface ButtonProps extends BaseComponent {
|
|
36
39
|
type: "button";
|
|
37
40
|
action: Action;
|
|
38
41
|
stack: StackProps;
|
|
39
42
|
transition?: null;
|
|
43
|
+
triggers?: {
|
|
44
|
+
on_press?: string;
|
|
45
|
+
};
|
|
40
46
|
overrides?: Overrides<ButtonProps>;
|
|
41
47
|
}
|
|
42
48
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FontSizes, FontWeights, SizeType, Spacing, TextAlignments } from "..";
|
|
2
2
|
import type { BaseComponent } from "../base";
|
|
3
|
-
import type { ColorGradientScheme
|
|
3
|
+
import type { ColorGradientScheme } from "../colors";
|
|
4
4
|
import type { Overrides } from "../overrides";
|
|
5
5
|
export interface TextNodeProps extends BaseComponent {
|
|
6
6
|
text_lid: string;
|
|
@@ -9,7 +9,7 @@ export interface TextNodeProps extends BaseComponent {
|
|
|
9
9
|
font_weight: keyof typeof FontWeights;
|
|
10
10
|
font_weight_int?: number;
|
|
11
11
|
horizontal_alignment: keyof typeof TextAlignments;
|
|
12
|
-
color:
|
|
12
|
+
color: ColorGradientScheme;
|
|
13
13
|
background_color?: ColorGradientScheme | null;
|
|
14
14
|
type: "text";
|
|
15
15
|
visible?: boolean | null;
|
|
@@ -10,4 +10,8 @@ export declare enum PackageIdentifier {
|
|
|
10
10
|
type VariableName = "product.price" | "product.price_per_period" | "product.price_per_period_abbreviated" | "product.price_per_day" | "product.price_per_week" | "product.price_per_month" | "product.price_per_year" | "product.period" | "product.period_abbreviated" | "product.periodly" | "product.period_in_days" | "product.period_in_weeks" | "product.period_in_months" | "product.period_in_years" | "product.period_with_unit" | "product.currency_code" | "product.currency_symbol" | "product.offer_price" | "product.offer_price_per_day" | "product.offer_price_per_week" | "product.offer_price_per_month" | "product.offer_price_per_year" | "product.offer_period" | "product.offer_period_abbreviated" | "product.offer_period_in_days" | "product.offer_period_in_weeks" | "product.offer_period_in_months" | "product.offer_period_in_years" | "product.offer_period_with_unit" | "product.offer_end_date" | "product.secondary_offer_price" | "product.secondary_offer_period" | "product.secondary_offer_period_abbreviated" | "product.relative_discount" | "product.store_product_name";
|
|
11
11
|
export type VariableDictionary = Record<VariableName, string>;
|
|
12
12
|
export type VariablesDictionary = Record<PackageIdentifier, VariableDictionary>;
|
|
13
|
+
export interface PackageInfo {
|
|
14
|
+
hasIntroOffer?: boolean;
|
|
15
|
+
hasTrial?: boolean;
|
|
16
|
+
}
|
|
13
17
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BorderType, CircleShape, ColorMode, ConcaveShape, ConvexShape, PillShape, RectangleShape, ShadowType, Size, Spacing } from "../types";
|
|
2
|
-
import type { ColorGradientScheme, ColorScheme } from "../types/colors";
|
|
2
|
+
import type { ColorGradientInfo, ColorGradientScheme, ColorScheme } from "../types/colors";
|
|
3
3
|
import type { FitMode } from "../types/media";
|
|
4
4
|
export type CSS = Record<string, string | number>;
|
|
5
5
|
export declare function css(props: CSS): string;
|
|
@@ -10,6 +10,7 @@ export declare function mapColorMode<T>(colorMode: ColorMode, value: {
|
|
|
10
10
|
}): T;
|
|
11
11
|
export declare function mapSize(size: Size): string;
|
|
12
12
|
export declare function mapSpacing(spacing?: Spacing | null): string;
|
|
13
|
+
export declare function mapColorInfo(info: ColorGradientInfo): string;
|
|
13
14
|
export declare function mapColor(colorMode: ColorMode, scheme: ColorScheme | ColorGradientScheme | null | undefined): string;
|
|
14
15
|
export declare function mapOverlay(colorMode: ColorMode, colorOverlay: ColorGradientScheme | null | undefined): string;
|
|
15
16
|
export declare function mapBorder(colorMode: ColorMode, border: BorderType | null | undefined): string;
|
package/dist/utils/base-utils.js
CHANGED
|
@@ -37,7 +37,7 @@ export function mapSpacing(spacing) {
|
|
|
37
37
|
const { top, bottom, leading, trailing } = spacing ?? DEFAULT_SPACING;
|
|
38
38
|
return mapTuple(top, trailing, bottom, leading);
|
|
39
39
|
}
|
|
40
|
-
function mapColorInfo(info) {
|
|
40
|
+
export function mapColorInfo(info) {
|
|
41
41
|
if (info.type === "alias" || info.type === "hex") {
|
|
42
42
|
return info.value;
|
|
43
43
|
}
|
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
import type { ColorGradientScheme } from "../types/colors.js";
|
|
2
1
|
import type { Component } from "../types/component.js";
|
|
3
|
-
import type { TextNodeProps } from "../types/components/text";
|
|
4
2
|
import type { Overrides } from "../types/overrides.js";
|
|
5
3
|
import type { RootPaywall } from "../types/paywall.js";
|
|
6
|
-
import { type ColorMode } from "../types.js";
|
|
7
|
-
/**
|
|
8
|
-
* Gets color value based on color mode with fallback
|
|
9
|
-
* @param params - Object containing color map, mode and fallback color
|
|
10
|
-
* @returns Color value as string
|
|
11
|
-
*/
|
|
12
|
-
export declare function getColor({ colorMap, colorMode, fallback, }: {
|
|
13
|
-
colorMap?: ColorGradientScheme | null;
|
|
14
|
-
colorMode?: ColorMode;
|
|
15
|
-
fallback?: string;
|
|
16
|
-
}): string;
|
|
17
|
-
type TextStyleVariables = {
|
|
18
|
-
"--text-align": string;
|
|
19
|
-
"--font-weight": number | string;
|
|
20
|
-
"--font-size": string;
|
|
21
|
-
"--font-family": string;
|
|
22
|
-
"--background-clip": string;
|
|
23
|
-
"--text-fill-color": string;
|
|
24
|
-
"--background": string;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Generates text-related styles
|
|
28
|
-
* @param props - Text component properties
|
|
29
|
-
* @param colorMode - The currently selected ColorMode (dark/light)
|
|
30
|
-
* @returns CSS style object with text formatting properties
|
|
31
|
-
*/
|
|
32
|
-
export declare function getTextStyles(props: TextNodeProps): TextStyleVariables;
|
|
33
4
|
/**
|
|
34
5
|
* Given an instance of PaywallData, returns the id of the first package marked as `is_selected_by_default` if any.
|
|
35
6
|
* @param paywallData
|
|
@@ -37,4 +8,4 @@ export declare function getTextStyles(props: TextNodeProps): TextStyleVariables;
|
|
|
37
8
|
*/
|
|
38
9
|
export declare function findSelectedPackageId({ stack, sticky_footer, }: RootPaywall): string | undefined;
|
|
39
10
|
export declare const getActiveStateProps: <T extends Component>(selectedState: boolean, overrides?: Overrides<T>) => Partial<T>;
|
|
40
|
-
export
|
|
11
|
+
export declare const getIntroOfferStateProps: <T extends Component>(hasIntroOffer: boolean, overrides?: Overrides<T>) => Partial<T>;
|
|
@@ -1,69 +1,3 @@
|
|
|
1
|
-
import { getPaywallContext } from "../stores/paywall.js";
|
|
2
|
-
import { DEFAULT_COLOR_MODE } from "./constants.js";
|
|
3
|
-
import { FontSizes, FontWeights, TextAlignments, } from "../types.js";
|
|
4
|
-
import { getScopedFontFamily, isFontRCFMManaged } from "./font-utils.js";
|
|
5
|
-
/**
|
|
6
|
-
* Gets color value based on color mode with fallback
|
|
7
|
-
* @param params - Object containing color map, mode and fallback color
|
|
8
|
-
* @returns Color value as string
|
|
9
|
-
*/
|
|
10
|
-
export function getColor({ colorMap, colorMode = DEFAULT_COLOR_MODE, fallback = "FFFFFF", }) {
|
|
11
|
-
if (!colorMap)
|
|
12
|
-
return fallback;
|
|
13
|
-
const color = colorMap[colorMode] || colorMap[DEFAULT_COLOR_MODE];
|
|
14
|
-
let colorPoints = "";
|
|
15
|
-
switch (color?.type) {
|
|
16
|
-
case "hex":
|
|
17
|
-
case "alias":
|
|
18
|
-
return color.value ?? fallback;
|
|
19
|
-
case "linear":
|
|
20
|
-
colorPoints = (color.points || [])
|
|
21
|
-
.map((point) => `${point.color} ${point.percent}%`)
|
|
22
|
-
.join(", ");
|
|
23
|
-
return `linear-gradient(${color.degrees}deg, ${colorPoints})`;
|
|
24
|
-
case "radial":
|
|
25
|
-
colorPoints = (color.points || [])
|
|
26
|
-
.map((point) => `${point.color} ${point.percent}%`)
|
|
27
|
-
.join(", ");
|
|
28
|
-
return `radial-gradient(${colorPoints})`;
|
|
29
|
-
default:
|
|
30
|
-
return fallback;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Generates text-related styles
|
|
35
|
-
* @param props - Text component properties
|
|
36
|
-
* @param colorMode - The currently selected ColorMode (dark/light)
|
|
37
|
-
* @returns CSS style object with text formatting properties
|
|
38
|
-
*/
|
|
39
|
-
export function getTextStyles(props) {
|
|
40
|
-
const { font_size, horizontal_alignment, font_weight, font_name, font_weight_int, } = props;
|
|
41
|
-
const paywall = getPaywallContext();
|
|
42
|
-
const uiConfig = paywall.uiConfig;
|
|
43
|
-
const { fonts } = uiConfig.app;
|
|
44
|
-
const font = fonts[font_name ?? ""];
|
|
45
|
-
const fontFamily = font?.web?.family;
|
|
46
|
-
const styles = {
|
|
47
|
-
"--text-align": "initial",
|
|
48
|
-
"--font-weight": "initial",
|
|
49
|
-
"--font-size": "initial",
|
|
50
|
-
"--font-family": "sans-serif",
|
|
51
|
-
"--background-clip": "none",
|
|
52
|
-
"--text-fill-color": "none",
|
|
53
|
-
"--background": "unset",
|
|
54
|
-
};
|
|
55
|
-
Object.assign(styles, {
|
|
56
|
-
"--text-align": TextAlignments[horizontal_alignment] || TextAlignments.leading,
|
|
57
|
-
"--font-weight": font_weight_int ?? FontWeights[font_weight] ?? FontWeights.regular,
|
|
58
|
-
"--font-size": Number.isInteger(Number(font_size))
|
|
59
|
-
? `${font_size}px`
|
|
60
|
-
: FontSizes[font_size] || FontSizes.body_m,
|
|
61
|
-
"--font-family": isFontRCFMManaged(font_name ?? "")
|
|
62
|
-
? getScopedFontFamily(fontFamily ?? "")
|
|
63
|
-
: "sans-serif",
|
|
64
|
-
});
|
|
65
|
-
return styles;
|
|
66
|
-
}
|
|
67
1
|
/**
|
|
68
2
|
* Given an instance of PaywallData, returns the id of the first package marked as `is_selected_by_default` if any.
|
|
69
3
|
* @param paywallData
|
|
@@ -109,3 +43,11 @@ export const getActiveStateProps = (selectedState, overrides) => {
|
|
|
109
43
|
const override = overrides?.find((override) => override.conditions.find((condition) => condition.type === "selected"));
|
|
110
44
|
return override?.properties ?? {};
|
|
111
45
|
};
|
|
46
|
+
export const getIntroOfferStateProps = (hasIntroOffer, overrides) => {
|
|
47
|
+
if (!hasIntroOffer) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
const override = overrides?.find((override) => override.conditions.find((condition) => condition.type === "intro_offer" ||
|
|
51
|
+
condition.type === "introductory_offer"));
|
|
52
|
+
return override?.properties ?? {};
|
|
53
|
+
};
|