@revenuecat/purchases-ui-js 0.0.12 → 0.0.13
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 +1 -1
- package/dist/components/image/Image.svelte +3 -2
- package/dist/components/image/image-utils.js +1 -1
- package/dist/components/paywall/Node.svelte +3 -12
- package/dist/components/paywall/Node.svelte.d.ts +0 -2
- package/dist/components/paywall/Paywall.stories.svelte +56 -2
- package/dist/components/paywall/Paywall.svelte +2 -2
- package/dist/components/stack/Stack.svelte +1 -2
- package/dist/components/stack/stack-utils.d.ts +1 -0
- package/dist/components/stack/stack-utils.js +1 -1
- package/dist/components/text/Text.svelte +16 -26
- package/dist/components/text/Text.svelte.d.ts +7 -2
- package/dist/components/text/{Text.stories.svelte → TextNode.stories.svelte} +55 -3
- package/dist/components/text/{Text.stories.svelte.d.ts → TextNode.stories.svelte.d.ts} +4 -4
- package/dist/components/text/TextNode.svelte +46 -0
- package/dist/components/text/TextNode.svelte.d.ts +3 -0
- package/dist/components/text/text-utils.d.ts +3 -3
- package/dist/components/text/text-utils.js +2 -2
- package/dist/data/entities.d.ts +3 -1
- package/dist/stories/fixtures.d.ts +1 -0
- package/dist/stories/fixtures.js +1075 -0
- package/dist/{utils.d.ts → utils/style-utils.d.ts} +3 -3
- package/dist/{utils.js → utils/style-utils.js} +8 -7
- package/dist/utils/variable-utils.d.ts +13 -0
- package/dist/utils/variable-utils.js +34 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentLocalizations, ImageMaskShapeType, PaywallData,
|
|
2
|
-
import { type BorderType, type ColorMode, type ColorType, type DimensionType, FontSizeTags, type ShadowType, type ShapeType, type SizeType, type Spacing } from "
|
|
1
|
+
import type { ComponentLocalizations, ImageMaskShapeType, PaywallData, TextNodeProps } from "../data/entities.js";
|
|
2
|
+
import { type BorderType, type ColorMode, type ColorType, type DimensionType, FontSizeTags, type ShadowType, type ShapeType, type SizeType, type Spacing } from "../types.js";
|
|
3
3
|
export type TextComponentTags = "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
4
4
|
/**
|
|
5
5
|
* Maps font size to appropriate HTML heading tag
|
|
@@ -79,7 +79,7 @@ export declare function getDimensionStyle(dimension: DimensionType): {
|
|
|
79
79
|
* @param props - Text component properties
|
|
80
80
|
* @returns CSS style object with text formatting properties
|
|
81
81
|
*/
|
|
82
|
-
export declare function getTextStyles(props:
|
|
82
|
+
export declare function getTextStyles(props: TextNodeProps): {
|
|
83
83
|
"--text-align": string;
|
|
84
84
|
"--font-weight": number;
|
|
85
85
|
"--font-size": string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FontSizes, FontSizeTags, FontWeights, StackAlignment, StackDirection, StackDistribution, } from "
|
|
1
|
+
import { FontSizes, FontSizeTags, FontWeights, StackAlignment, StackDirection, StackDistribution, } from "../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Generates CSS spacing styles for margin or padding
|
|
4
4
|
* @param spacing - The spacing object containing top, trailing, bottom, and leading values
|
|
@@ -97,11 +97,11 @@ export function getComponentStyles({ backgroundColor, border, margin, padding, t
|
|
|
97
97
|
stylesObject["--border-radius"] = getCornerRadiusStyle(shape.corners);
|
|
98
98
|
}
|
|
99
99
|
if (shape?.type === "pill") {
|
|
100
|
-
stylesObject["--border-radius"] = "9999px
|
|
100
|
+
stylesObject["--border-radius"] = "9999px";
|
|
101
101
|
}
|
|
102
102
|
if (shadow) {
|
|
103
103
|
stylesObject["--shadow"] = `${shadow.x}px ${shadow.y}px ${shadow.radius}px
|
|
104
|
-
${getColor({ colorMap: shadow.color, colorMode, fallback: "#000000" })}
|
|
104
|
+
${getColor({ colorMap: shadow.color, colorMode, fallback: "#000000" })}`;
|
|
105
105
|
}
|
|
106
106
|
return stylesObject;
|
|
107
107
|
}
|
|
@@ -119,6 +119,7 @@ export function getSizeStyle(size) {
|
|
|
119
119
|
return "fit-content";
|
|
120
120
|
}
|
|
121
121
|
if (size.type === "fill") {
|
|
122
|
+
// return "100%";
|
|
122
123
|
const userAgent = navigator.userAgent;
|
|
123
124
|
const isFirefox = userAgent.match(/firefox|fxios/i);
|
|
124
125
|
return isFirefox ? "-moz-available" : "-webkit-fill-available";
|
|
@@ -180,9 +181,9 @@ export const getMaskStyle = (maskShape) => {
|
|
|
180
181
|
*/
|
|
181
182
|
export function getDimensionStyle(dimension) {
|
|
182
183
|
const styles = {
|
|
183
|
-
"--direction": "
|
|
184
|
-
"--alignment": "
|
|
185
|
-
"--distribution": "
|
|
184
|
+
"--direction": "initial",
|
|
185
|
+
"--alignment": "initial",
|
|
186
|
+
"--distribution": "initial",
|
|
186
187
|
};
|
|
187
188
|
if (dimension.type === "zlayer") {
|
|
188
189
|
// TODO: Review with Monetization team
|
|
@@ -222,7 +223,7 @@ export function getTextStyles(props) {
|
|
|
222
223
|
*/
|
|
223
224
|
export function stringifyStyles(styles) {
|
|
224
225
|
return Object.entries(styles)
|
|
225
|
-
.map(([key, value]) => `${key}: ${value}
|
|
226
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
226
227
|
.join("; ");
|
|
227
228
|
}
|
|
228
229
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const VARIABLE_NAMES: string[];
|
|
2
|
+
export type VariableDictionary = Record<string, string | number | undefined>;
|
|
3
|
+
export type ReplaceVariablesProps = {
|
|
4
|
+
value?: string;
|
|
5
|
+
dictionary?: VariableDictionary;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Returns a string with the variables replaced by values from the dictionary
|
|
9
|
+
* @param value A string like "Try {{ product_name }} for only {{ total_price_and_per_month }}"
|
|
10
|
+
* @param dictionary Dictionary containing the values for the variables
|
|
11
|
+
* @returns The string with values: "Try CatGPT Annual for only $59.99/yr ($4.99/mo)"
|
|
12
|
+
*/
|
|
13
|
+
export declare const replaceVariables: ({ value, dictionary, }: ReplaceVariablesProps) => string | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const VARIABLE_NAMES = [
|
|
2
|
+
"product_name",
|
|
3
|
+
"price",
|
|
4
|
+
"price_per_period",
|
|
5
|
+
"price_per_period_full",
|
|
6
|
+
"total_price_and_per_month",
|
|
7
|
+
"total_price_and_per_month_full",
|
|
8
|
+
"sub_price_per_month",
|
|
9
|
+
"sub_price_per_week",
|
|
10
|
+
"sub_duration",
|
|
11
|
+
"sub_duration_in_months",
|
|
12
|
+
"sub_period",
|
|
13
|
+
"sub_period_length",
|
|
14
|
+
"sub_period_abbreviated",
|
|
15
|
+
"sub_offer_duration",
|
|
16
|
+
"sub_offer_duration_2",
|
|
17
|
+
"sub_offer_price",
|
|
18
|
+
"sub_offer_price_2",
|
|
19
|
+
"sub_relative_discount",
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Returns a string with the variables replaced by values from the dictionary
|
|
23
|
+
* @param value A string like "Try {{ product_name }} for only {{ total_price_and_per_month }}"
|
|
24
|
+
* @param dictionary Dictionary containing the values for the variables
|
|
25
|
+
* @returns The string with values: "Try CatGPT Annual for only $59.99/yr ($4.99/mo)"
|
|
26
|
+
*/
|
|
27
|
+
export const replaceVariables = ({ value = "", dictionary, }) => {
|
|
28
|
+
if (!dictionary)
|
|
29
|
+
return value;
|
|
30
|
+
return VARIABLE_NAMES.reduce((result, variableName) => {
|
|
31
|
+
const currentVariableReplaced = result.replaceAll(`{{ ${variableName} }}`, dictionary[variableName]?.toString() || "N/A");
|
|
32
|
+
return currentVariableReplaced;
|
|
33
|
+
}, value);
|
|
34
|
+
};
|