@revenuecat/purchases-ui-js 3.9.1 → 3.9.2
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.svelte +1 -1
- package/dist/components/input-text/InputText.svelte +164 -0
- package/dist/components/input-text/InputText.svelte.d.ts +4 -0
- package/dist/components/paywall/Node.svelte +2 -0
- package/dist/components/paywall/Paywall.svelte +3 -0
- package/dist/components/paywall/Paywall.svelte.d.ts +1 -0
- package/dist/components/text/TextNode.svelte +12 -12
- package/dist/components/workflows/Screen.svelte +3 -0
- package/dist/components/workflows/Screen.svelte.d.ts +1 -0
- package/dist/stores/paywall.d.ts +1 -0
- package/dist/types/component.d.ts +2 -1
- package/dist/types/components/input-text.d.ts +33 -0
- package/dist/types/components/input-text.js +1 -0
- package/dist/web-components/index.js +1250 -1058
- package/package.json +16 -16
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getColorModeContext } from "../../stores/color-mode";
|
|
3
|
+
import { getHoverStateContext } from "../../stores/hover";
|
|
4
|
+
import { getLocalizationContext } from "../../stores/localization";
|
|
5
|
+
import { getPackageInfoContext } from "../../stores/packageInfo";
|
|
6
|
+
import { getPaywallContext } from "../../stores/paywall";
|
|
7
|
+
import { getSelectedStateContext } from "../../stores/selected";
|
|
8
|
+
import { getVariablesContext } from "../../stores/variables";
|
|
9
|
+
import { FontWeights, TextAlignments } from "../../types";
|
|
10
|
+
import type { InputTextProps } from "../../types/components/input-text";
|
|
11
|
+
import { mapBackground } from "../../utils/background-utils";
|
|
12
|
+
import {
|
|
13
|
+
css,
|
|
14
|
+
mapBorder,
|
|
15
|
+
mapBorderRadius,
|
|
16
|
+
mapShadow,
|
|
17
|
+
mapSize,
|
|
18
|
+
mapSpacing,
|
|
19
|
+
} from "../../utils/base-utils";
|
|
20
|
+
import {
|
|
21
|
+
getScopedFontFamily,
|
|
22
|
+
isFontRCFMManaged,
|
|
23
|
+
} from "../../utils/font-utils";
|
|
24
|
+
import {
|
|
25
|
+
evaluateVisibilityConditions,
|
|
26
|
+
getActiveStateProps,
|
|
27
|
+
getHoverStateProps,
|
|
28
|
+
} from "../../utils/style-utils";
|
|
29
|
+
import { replaceVariables } from "../../utils/variable-utils";
|
|
30
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
31
|
+
import { mapTextColor } from "../text/text-utils";
|
|
32
|
+
|
|
33
|
+
const props: InputTextProps = $props();
|
|
34
|
+
|
|
35
|
+
console.log("Hello");
|
|
36
|
+
|
|
37
|
+
const selectedState = getSelectedStateContext();
|
|
38
|
+
const hoverState = getHoverStateContext();
|
|
39
|
+
const {
|
|
40
|
+
placeholder_lid,
|
|
41
|
+
keyboard_type,
|
|
42
|
+
capitalize,
|
|
43
|
+
field_id,
|
|
44
|
+
required,
|
|
45
|
+
size,
|
|
46
|
+
padding,
|
|
47
|
+
margin,
|
|
48
|
+
border,
|
|
49
|
+
shape,
|
|
50
|
+
shadow,
|
|
51
|
+
font_name,
|
|
52
|
+
font_weight_int,
|
|
53
|
+
font_size,
|
|
54
|
+
horizontal_alignment,
|
|
55
|
+
color,
|
|
56
|
+
placeholder_font_name,
|
|
57
|
+
placeholder_font_weight_int,
|
|
58
|
+
placeholder_font_size,
|
|
59
|
+
placeholder_horizontal_alignment,
|
|
60
|
+
placeholder_color,
|
|
61
|
+
background_color,
|
|
62
|
+
} = $derived.by(() => {
|
|
63
|
+
return {
|
|
64
|
+
...props,
|
|
65
|
+
...getHoverStateProps($hoverState, props.overrides),
|
|
66
|
+
...getActiveStateProps($selectedState, props.overrides),
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const getColorMode = getColorModeContext();
|
|
71
|
+
const colorMode = $derived(getColorMode());
|
|
72
|
+
const { uiConfig, onInputChanged } = getPaywallContext();
|
|
73
|
+
|
|
74
|
+
const inputStyle = $derived.by(() => {
|
|
75
|
+
const font = uiConfig.app.fonts[font_name ?? ""];
|
|
76
|
+
const fontFamily = font?.web?.family;
|
|
77
|
+
const placeholderFont = uiConfig.app.fonts[placeholder_font_name ?? ""];
|
|
78
|
+
const placeholderFontFamily = placeholderFont?.web?.family;
|
|
79
|
+
const placeholderColor = mapTextColor(colorMode, placeholder_color);
|
|
80
|
+
|
|
81
|
+
return css({
|
|
82
|
+
display: props.visible === false ? "none" : "flex",
|
|
83
|
+
position: "relative",
|
|
84
|
+
width: mapSize(size.width),
|
|
85
|
+
height: mapSize(size.height),
|
|
86
|
+
margin: mapSpacing(margin),
|
|
87
|
+
padding: mapSpacing(padding),
|
|
88
|
+
...mapBackground(colorMode, background_color, null),
|
|
89
|
+
border: mapBorder(colorMode, border),
|
|
90
|
+
"border-radius": mapBorderRadius(shape),
|
|
91
|
+
"box-shadow": mapShadow(colorMode, shadow),
|
|
92
|
+
|
|
93
|
+
...mapTextColor(colorMode, color),
|
|
94
|
+
"text-align":
|
|
95
|
+
TextAlignments[horizontal_alignment] || TextAlignments.leading,
|
|
96
|
+
"font-weight": font_weight_int ?? FontWeights.regular,
|
|
97
|
+
"font-size": `${font_size}px`,
|
|
98
|
+
"font-family": isFontRCFMManaged(font_name ?? "")
|
|
99
|
+
? getScopedFontFamily(fontFamily ?? "")
|
|
100
|
+
: "sans-serif",
|
|
101
|
+
|
|
102
|
+
"--placeholder-color": placeholderColor.color,
|
|
103
|
+
"--placeholder-background": placeholderColor.background,
|
|
104
|
+
"--placeholder-background-clip": placeholderColor["background-clip"],
|
|
105
|
+
"--placeholder-webkit-background-clip":
|
|
106
|
+
placeholderColor["-webkit-background-clip"],
|
|
107
|
+
"--placeholder-text-align":
|
|
108
|
+
TextAlignments[placeholder_horizontal_alignment] ||
|
|
109
|
+
TextAlignments.leading,
|
|
110
|
+
"--placeholder-font-weight":
|
|
111
|
+
placeholder_font_weight_int ?? FontWeights.regular,
|
|
112
|
+
"--placeholder-font-size": `${placeholder_font_size}px`,
|
|
113
|
+
"--placeholder-font-family": isFontRCFMManaged(
|
|
114
|
+
placeholder_font_name ?? "",
|
|
115
|
+
)
|
|
116
|
+
? getScopedFontFamily(placeholderFontFamily ?? "")
|
|
117
|
+
: "sans-serif",
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const variables = getVariablesContext();
|
|
122
|
+
const { getLocalizedString } = getLocalizationContext();
|
|
123
|
+
const placeholder = $derived(
|
|
124
|
+
replaceVariables(getLocalizedString(placeholder_lid), $variables),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const type = $derived.by((): HTMLInputAttributes["type"] => {
|
|
128
|
+
switch (props.keyboard_type) {
|
|
129
|
+
case "decimal":
|
|
130
|
+
case "numeric":
|
|
131
|
+
return "number";
|
|
132
|
+
case "email":
|
|
133
|
+
return "email";
|
|
134
|
+
case "tel":
|
|
135
|
+
return "tel";
|
|
136
|
+
case "text":
|
|
137
|
+
return "text";
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
</script>
|
|
141
|
+
|
|
142
|
+
<input
|
|
143
|
+
{type}
|
|
144
|
+
{placeholder}
|
|
145
|
+
{required}
|
|
146
|
+
inputmode={keyboard_type}
|
|
147
|
+
autocapitalize={capitalize}
|
|
148
|
+
style={inputStyle}
|
|
149
|
+
oninput={(event) => onInputChanged?.(field_id, event.currentTarget.value)}
|
|
150
|
+
/>
|
|
151
|
+
|
|
152
|
+
<style>
|
|
153
|
+
input::placeholder {
|
|
154
|
+
color: var(--placeholder-color);
|
|
155
|
+
background: var(--placeholder-background);
|
|
156
|
+
background-clip: var(--placeholder-background-clip);
|
|
157
|
+
-webkit-background-clip: var(--placeholder-webkit-background-clip);
|
|
158
|
+
|
|
159
|
+
text-align: var(--placeholder-text-align);
|
|
160
|
+
font-weight: var(--placeholder-font-weight);
|
|
161
|
+
font-size: var(--placeholder-font-size);
|
|
162
|
+
font-family: var(--placeholder-font-family);
|
|
163
|
+
}
|
|
164
|
+
</style>
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
} from "../..";
|
|
11
11
|
import ButtonNode from "../button/ButtonNode.svelte";
|
|
12
12
|
import Countdown from "../countdown/Countdown.svelte";
|
|
13
|
+
import InputText from "../input-text/InputText.svelte";
|
|
13
14
|
import InputMultipleChoice from "../options/InputMultipleChoice.svelte";
|
|
14
15
|
import InputOption from "../options/InputOption.svelte";
|
|
15
16
|
import InputSingleChoice from "../options/InputSingleChoice.svelte";
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
input_multiple_choice: InputMultipleChoice,
|
|
43
44
|
input_option: InputOption,
|
|
44
45
|
input_single_choice: InputSingleChoice,
|
|
46
|
+
input_text: InputText,
|
|
45
47
|
package: Package,
|
|
46
48
|
purchase_button: PurchaseButton,
|
|
47
49
|
redemption_button: RedemptionButton,
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
onError?: (error: unknown) => void;
|
|
66
66
|
hideBackButtons?: boolean;
|
|
67
67
|
walletButtonRender?: WalletButtonRender;
|
|
68
|
+
onInputChanged?: (fieldId: string, value: string) => void;
|
|
68
69
|
maxContentWidth?: string;
|
|
69
70
|
initialInputSelections?: InitialInputSelections;
|
|
70
71
|
/**
|
|
@@ -99,6 +100,7 @@
|
|
|
99
100
|
onError,
|
|
100
101
|
uiConfig,
|
|
101
102
|
walletButtonRender,
|
|
103
|
+
onInputChanged,
|
|
102
104
|
hideBackButtons = false,
|
|
103
105
|
maxContentWidth,
|
|
104
106
|
initialInputSelections = {},
|
|
@@ -183,6 +185,7 @@
|
|
|
183
185
|
infoPerPackage: readable(infoPerPackage),
|
|
184
186
|
onPurchase,
|
|
185
187
|
onButtonAction,
|
|
188
|
+
onInputChanged,
|
|
186
189
|
walletButtonRender,
|
|
187
190
|
uiConfig,
|
|
188
191
|
hideBackButtons,
|
|
@@ -31,6 +31,7 @@ interface Props {
|
|
|
31
31
|
onError?: (error: unknown) => void;
|
|
32
32
|
hideBackButtons?: boolean;
|
|
33
33
|
walletButtonRender?: WalletButtonRender;
|
|
34
|
+
onInputChanged?: (fieldId: string, value: string) => void;
|
|
34
35
|
maxContentWidth?: string;
|
|
35
36
|
initialInputSelections?: InitialInputSelections;
|
|
36
37
|
/**
|
|
@@ -35,18 +35,6 @@
|
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
const isVisible = $derived(
|
|
39
|
-
evaluateVisibilityConditions(
|
|
40
|
-
{
|
|
41
|
-
selectedPackageId: $selectedPackageId,
|
|
42
|
-
packageInfo: $packageInfo,
|
|
43
|
-
variables: $variables,
|
|
44
|
-
},
|
|
45
|
-
props.overrides,
|
|
46
|
-
props.visible,
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
|
-
|
|
50
38
|
const getColorMode = getColorModeContext();
|
|
51
39
|
const colorMode = $derived(getColorMode());
|
|
52
40
|
|
|
@@ -69,6 +57,18 @@
|
|
|
69
57
|
replaceVariables(getLocalizedString(actualProps.text_lid), $variables),
|
|
70
58
|
);
|
|
71
59
|
|
|
60
|
+
const isVisible = $derived(
|
|
61
|
+
evaluateVisibilityConditions(
|
|
62
|
+
{
|
|
63
|
+
selectedPackageId: $selectedPackageId,
|
|
64
|
+
packageInfo: $packageInfo,
|
|
65
|
+
variables: $variables ?? {},
|
|
66
|
+
},
|
|
67
|
+
props.overrides,
|
|
68
|
+
props.visible,
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
72
|
const markdownParsed = $derived(getHtmlFromMarkdown(label));
|
|
73
73
|
</script>
|
|
74
74
|
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
maxContentWidth?: string;
|
|
22
22
|
variablesPerPackage?: Record<string, VariableDictionary>;
|
|
23
23
|
initialInputSelections?: InitialInputSelections;
|
|
24
|
+
onInputChanged?: (fieldId: string, value: string) => void;
|
|
24
25
|
walletButtonRender?: WalletButtonRender;
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
maxContentWidth,
|
|
37
38
|
variablesPerPackage,
|
|
38
39
|
initialInputSelections = {},
|
|
40
|
+
onInputChanged,
|
|
39
41
|
walletButtonRender,
|
|
40
42
|
}: Props = $props();
|
|
41
43
|
</script>
|
|
@@ -60,6 +62,7 @@
|
|
|
60
62
|
onActionTriggered?.(actionId);
|
|
61
63
|
}}
|
|
62
64
|
{onPurchaseClicked}
|
|
65
|
+
{onInputChanged}
|
|
63
66
|
{walletButtonRender}
|
|
64
67
|
onError={(error) => {
|
|
65
68
|
console.error("Paywall error:", error);
|
|
@@ -15,6 +15,7 @@ interface Props {
|
|
|
15
15
|
maxContentWidth?: string;
|
|
16
16
|
variablesPerPackage?: Record<string, VariableDictionary>;
|
|
17
17
|
initialInputSelections?: InitialInputSelections;
|
|
18
|
+
onInputChanged?: (fieldId: string, value: string) => void;
|
|
18
19
|
walletButtonRender?: WalletButtonRender;
|
|
19
20
|
}
|
|
20
21
|
declare const Screen: import("svelte").Component<Props, {}, "">;
|
package/dist/stores/paywall.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ type PaywallContext = Readonly<{
|
|
|
16
16
|
baseVariables: Readable<VariableDictionary | undefined>;
|
|
17
17
|
infoPerPackage: Readable<Record<string, PackageInfo> | undefined>;
|
|
18
18
|
onPurchase: (actionId?: string) => void;
|
|
19
|
+
onInputChanged?: (fieldId: string, value: string) => void;
|
|
19
20
|
walletButtonRender?: WalletButtonRender;
|
|
20
21
|
onWalletButtonReady?: (walletButtonAvailable?: boolean) => void;
|
|
21
22
|
onButtonAction: (action: Action, actionId?: string) => void;
|
|
@@ -4,6 +4,7 @@ import type { CountdownProps } from "./components/countdown";
|
|
|
4
4
|
import type { FooterProps } from "./components/footer";
|
|
5
5
|
import type { IconProps } from "./components/icon";
|
|
6
6
|
import type { ImageProps } from "./components/image";
|
|
7
|
+
import type { InputTextProps } from "./components/input-text";
|
|
7
8
|
import type { InputMultipleChoiceProps, InputOptionProps, InputSingleChoiceProps } from "./components/options";
|
|
8
9
|
import type { PackageProps } from "./components/package";
|
|
9
10
|
import type { PurchaseButtonProps } from "./components/purchase-button";
|
|
@@ -16,4 +17,4 @@ import type { VideoProps } from "./components/video";
|
|
|
16
17
|
import type { WalletButtonProps } from "./components/wallet-button";
|
|
17
18
|
import type { SkeletonLoaderProps } from "./components/skeleton-loader-props";
|
|
18
19
|
import type { ExpressPurchaseButtonProps } from "./components/express-purchase-button-props";
|
|
19
|
-
export type Component = ButtonProps | CarouselProps | CountdownProps | ExpressPurchaseButtonProps | FooterProps | IconProps | ImageProps | InputMultipleChoiceProps | InputOptionProps | InputSingleChoiceProps | PackageProps | PurchaseButtonProps | RedemptionButtonProps | SkeletonLoaderProps | StackProps | TabControlButtonProps | TabControlToggleProps | TabControlProps | TabsProps | TextNodeProps | TimelineProps | WalletButtonProps | VideoProps;
|
|
20
|
+
export type Component = ButtonProps | CarouselProps | CountdownProps | ExpressPurchaseButtonProps | FooterProps | IconProps | ImageProps | InputMultipleChoiceProps | InputOptionProps | InputSingleChoiceProps | InputTextProps | PackageProps | PurchaseButtonProps | RedemptionButtonProps | SkeletonLoaderProps | StackProps | TabControlButtonProps | TabControlToggleProps | TabControlProps | TabsProps | TextNodeProps | TimelineProps | WalletButtonProps | VideoProps;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BorderType, ShapeType, ShadowType, SizeType, Spacing, TextAlignments } from "..";
|
|
2
|
+
import type { BaseComponent } from "../base";
|
|
3
|
+
import type { ColorGradientScheme } from "../colors";
|
|
4
|
+
import type { Overrides } from "../overrides";
|
|
5
|
+
export type InputTextCapitalizeType = "none" | "sentences" | "words" | "characters";
|
|
6
|
+
export type InputTextKeyboardType = "decimal" | "email" | "numeric" | "tel" | "text" | "url";
|
|
7
|
+
export interface InputTextProps extends BaseComponent {
|
|
8
|
+
type: "input_text";
|
|
9
|
+
visible?: boolean | null;
|
|
10
|
+
placeholder_lid: string;
|
|
11
|
+
keyboard_type: InputTextKeyboardType;
|
|
12
|
+
capitalize: InputTextCapitalizeType;
|
|
13
|
+
field_id: string;
|
|
14
|
+
required: boolean;
|
|
15
|
+
size: SizeType;
|
|
16
|
+
padding: Spacing;
|
|
17
|
+
margin: Spacing;
|
|
18
|
+
border?: BorderType | null;
|
|
19
|
+
shape?: ShapeType | null;
|
|
20
|
+
shadow?: ShadowType | null;
|
|
21
|
+
font_name?: string | null;
|
|
22
|
+
font_weight_int?: number | null;
|
|
23
|
+
font_size: number;
|
|
24
|
+
horizontal_alignment: keyof typeof TextAlignments;
|
|
25
|
+
color: ColorGradientScheme;
|
|
26
|
+
placeholder_font_name?: string | null;
|
|
27
|
+
placeholder_font_weight_int?: number | null;
|
|
28
|
+
placeholder_font_size: number;
|
|
29
|
+
placeholder_horizontal_alignment: keyof typeof TextAlignments;
|
|
30
|
+
placeholder_color: ColorGradientScheme;
|
|
31
|
+
background_color?: ColorGradientScheme | null;
|
|
32
|
+
overrides?: Overrides<InputTextProps>;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|