@revenuecat/purchases-ui-js 2.0.2 → 2.0.4
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 +66 -102
- package/dist/components/button/ButtonNode.svelte +18 -26
- package/dist/components/carousel/Carousel.stories.svelte +1039 -0
- package/dist/components/carousel/Carousel.stories.svelte.d.ts +19 -0
- package/dist/components/carousel/Carousel.svelte +298 -0
- package/dist/components/carousel/Carousel.svelte.d.ts +4 -0
- package/dist/components/carousel/CarouselPage.svelte +39 -0
- package/dist/components/carousel/CarouselPage.svelte.d.ts +11 -0
- package/dist/components/carousel/PageControl.svelte +93 -0
- package/dist/components/carousel/PageControl.svelte.d.ts +4 -0
- package/dist/components/carousel/carousel-utils.d.ts +4 -0
- package/dist/components/carousel/carousel-utils.js +21 -0
- package/dist/components/footer/Footer.stories.svelte +112 -102
- package/dist/components/footer/Footer.svelte +8 -4
- package/dist/components/icon/Icon.stories.svelte +100 -0
- package/dist/components/icon/Icon.stories.svelte.d.ts +19 -0
- package/dist/components/icon/Icon.svelte +73 -0
- package/dist/components/icon/Icon.svelte.d.ts +4 -0
- package/dist/components/image/ClipPath.svelte +49 -0
- package/dist/components/image/ClipPath.svelte.d.ts +9 -0
- package/dist/components/image/Image.stories.svelte +83 -188
- package/dist/components/image/Image.svelte +152 -136
- package/dist/components/image/Image.svelte.d.ts +1 -1
- package/dist/components/image/Overlay.svelte +36 -0
- package/dist/components/image/Overlay.svelte.d.ts +8 -0
- package/dist/components/package/Package.stories.svelte +10 -21
- package/dist/components/package/Package.svelte +8 -35
- package/dist/components/paywall/Node.svelte +25 -32
- package/dist/components/paywall/Node.svelte.d.ts +4 -6
- package/dist/components/paywall/Paywall.stories.svelte +36 -140
- package/dist/components/paywall/Paywall.svelte +23 -7
- package/dist/components/paywall/Paywall.svelte.d.ts +4 -2
- package/dist/components/paywall/fixtures/override-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/override-paywall.js +1310 -0
- package/dist/components/paywall/fixtures/stack-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/stack-paywall.js +5223 -0
- package/dist/components/paywall/fixtures/variables.d.ts +261 -0
- package/dist/components/paywall/fixtures/variables.js +262 -0
- package/dist/components/paywall/paywall-utils.d.ts +1 -1
- package/dist/components/purchase-button/PurchaseButton.stories.svelte +10 -21
- package/dist/components/purchase-button/PurchaseButton.svelte +2 -27
- package/dist/components/stack/Stack.stories.svelte +2354 -978
- package/dist/components/stack/Stack.svelte +116 -134
- package/dist/components/stack/Stack.svelte.d.ts +8 -2
- package/dist/components/stack/stack-utils.d.ts +10 -30
- package/dist/components/stack/stack-utils.js +77 -255
- package/dist/components/text/Text.svelte +3 -37
- package/dist/components/text/Text.svelte.d.ts +1 -2
- package/dist/components/text/TextNode.stories.svelte +10 -36
- package/dist/components/text/TextNode.svelte +25 -28
- package/dist/components/text/TextNode.svelte.d.ts +1 -1
- package/dist/components/text/text-utils.d.ts +4 -9
- package/dist/components/text/text-utils.js +32 -117
- package/dist/components/timeline/Timeline.stories.svelte +640 -251
- package/dist/components/timeline/Timeline.svelte +42 -28
- package/dist/components/timeline/Timeline.svelte.d.ts +1 -1
- package/dist/components/timeline/TimelineItem.svelte +80 -112
- package/dist/components/timeline/TimelineItem.svelte.d.ts +6 -2
- package/dist/components/timeline/timeline-utils.d.ts +24 -6
- package/dist/components/timeline/timeline-utils.js +21 -113
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/stores/color-mode.d.ts +1 -1
- package/dist/stores/paywall.d.ts +5 -2
- package/dist/stores/selected.d.ts +5 -0
- package/dist/stores/selected.js +12 -0
- package/dist/stores/variables.d.ts +1 -1
- package/dist/stores/variables.js +0 -1
- package/dist/stories/component-decorator.d.ts +2 -0
- package/dist/stories/component-decorator.js +12 -0
- package/dist/stories/fixtures.d.ts +6 -3
- package/dist/stories/fixtures.js +5214 -4422
- package/dist/stories/paywall-decorator.js +6 -0
- package/dist/stories/variables-decorator.d.ts +1 -1
- package/dist/stories/viewport-decorator.d.ts +2 -0
- package/dist/stories/viewport-decorator.js +8 -0
- package/dist/stories/viewport-wrapper.svelte +55 -0
- package/dist/stories/viewport-wrapper.svelte.d.ts +10 -0
- package/dist/stories/with-layout.d.ts +2 -10
- package/dist/stories/with-layout.js +3 -5
- package/dist/types/alignment.d.ts +5 -3
- package/dist/types/background.d.ts +6 -5
- package/dist/types/base.d.ts +7 -0
- package/dist/types/colors.d.ts +4 -4
- package/dist/types/component.d.ts +7 -2
- package/dist/types/components/button.d.ts +6 -1
- package/dist/types/components/carousel.d.ts +51 -0
- package/dist/types/components/carousel.js +1 -0
- package/dist/types/components/footer.d.ts +2 -1
- package/dist/types/components/icon.d.ts +28 -0
- package/dist/types/components/icon.js +1 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/image.js +1 -0
- package/dist/types/components/package.d.ts +2 -1
- package/dist/types/components/purchase-button.d.ts +2 -1
- package/dist/types/components/stack.d.ts +32 -0
- package/dist/types/components/stack.js +1 -0
- package/dist/types/components/text.d.ts +20 -0
- package/dist/types/components/text.js +1 -0
- package/dist/types/components/timeline.d.ts +35 -0
- package/dist/types/components/timeline.js +1 -0
- package/dist/types/localization.d.ts +2 -1
- package/dist/types/media.d.ts +4 -3
- package/dist/types/overrides.d.ts +48 -0
- package/dist/types/overrides.js +1 -0
- package/dist/types/paywall.d.ts +27 -0
- package/dist/types/paywall.js +1 -0
- package/dist/types/ui-config.d.ts +20 -0
- package/dist/types/ui-config.js +1 -0
- package/dist/types/variables.d.ts +13 -0
- package/dist/types/variables.js +10 -0
- package/dist/types.d.ts +17 -9
- package/dist/ui/atoms/typography.stories.svelte +1 -27
- package/dist/ui/molecules/button.stories.svelte +3 -8
- package/dist/ui/theme/colors.d.ts +0 -6
- package/dist/ui/theme/colors.js +1 -1
- package/dist/ui/theme/text.d.ts +3 -4
- package/dist/ui/theme/utils.d.ts +0 -10
- package/dist/ui/theme/utils.js +5 -5
- package/dist/utils/background-utils.d.ts +4 -0
- package/dist/utils/background-utils.js +39 -0
- package/dist/utils/base-utils.d.ts +18 -0
- package/dist/utils/base-utils.js +124 -0
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +6 -1
- package/dist/utils/font-utils.d.ts +4 -0
- package/dist/utils/font-utils.js +47 -0
- package/dist/utils/style-utils.d.ts +7 -120
- package/dist/utils/style-utils.js +29 -304
- package/dist/utils/variable-utils.d.ts +1 -22
- package/dist/utils/variable-utils.js +28 -24
- package/dist/web-components/index.css +1 -1
- package/dist/web-components/index.js +1435 -980
- package/package.json +36 -26
- package/dist/components/button/button-utils.d.ts +0 -2
- package/dist/components/button/button-utils.js +0 -19
- package/dist/components/image/image-utils.d.ts +0 -19
- package/dist/components/image/image-utils.js +0 -33
- package/dist/components/purchase-button/purchase-button-utils.d.ts +0 -2
- package/dist/components/purchase-button/purchase-button-utils.js +0 -20
- package/dist/data/entities.d.ts +0 -162
- package/dist/stories/meta-templates.d.ts +0 -12
- package/dist/stories/meta-templates.js +0 -155
- /package/dist/{data/entities.js → types/base.js} +0 -0
|
@@ -1,104 +1,52 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import ButtonNode from "./ButtonNode.svelte";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TextNodeProps } from "../../types/components/text";
|
|
4
|
+
import { componentDecorator } from "../../stories/component-decorator";
|
|
4
5
|
import { localizationDecorator } from "../../stories/localization-decorator";
|
|
6
|
+
import type { ButtonProps } from "../../types/components/button";
|
|
7
|
+
import type { StackProps } from "../../types/components/stack";
|
|
5
8
|
import { DEFAULT_TEXT_COLOR } from "../../utils/constants";
|
|
6
9
|
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
7
10
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
control: { type: "object" },
|
|
30
|
-
description: "Action configuration for the button",
|
|
31
|
-
table: {
|
|
32
|
-
type: {
|
|
33
|
-
summary: "object",
|
|
34
|
-
detail: `{
|
|
35
|
-
type: "restore_purchases" | "navigate_back" | "navigate_to",
|
|
36
|
-
destination?: "customer_center" | "privacy_policy" | "terms" | "url",
|
|
37
|
-
url?: {
|
|
38
|
-
url_lid: string,
|
|
39
|
-
method: "in_app_browser" | "external_browser" | "deep_link"
|
|
40
|
-
}
|
|
41
|
-
}`,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
stack: {
|
|
46
|
-
control: { type: "object" },
|
|
47
|
-
description: "Stack configuration for button content",
|
|
48
|
-
table: {
|
|
49
|
-
type: {
|
|
50
|
-
summary: "object",
|
|
51
|
-
detail: "StackProps",
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
11
|
+
const textProps = (id: number): TextNodeProps => ({
|
|
12
|
+
type: "text",
|
|
13
|
+
id: `button-text-${id}`,
|
|
14
|
+
name: `button-text-${id}`,
|
|
15
|
+
text_lid: `id${id}`,
|
|
16
|
+
font_size: "body_m",
|
|
17
|
+
font_weight: "medium",
|
|
18
|
+
horizontal_alignment: "center",
|
|
19
|
+
size: {
|
|
20
|
+
width: { type: "fit" },
|
|
21
|
+
height: { type: "fit" },
|
|
22
|
+
},
|
|
23
|
+
margin: { top: 0, trailing: 0, bottom: 0, leading: 0 },
|
|
24
|
+
padding: { top: 0, trailing: 0, bottom: 0, leading: 0 },
|
|
25
|
+
color: {
|
|
26
|
+
dark: { type: "hex", value: DEFAULT_TEXT_COLOR },
|
|
27
|
+
light: { type: "hex", value: "#ffffff" },
|
|
28
|
+
},
|
|
29
|
+
background_color: {
|
|
30
|
+
dark: { type: "hex", value: "transparent" },
|
|
31
|
+
light: { type: "hex", value: "transparent" },
|
|
55
32
|
},
|
|
56
33
|
});
|
|
57
34
|
|
|
58
|
-
const
|
|
59
|
-
({
|
|
60
|
-
type: "text",
|
|
61
|
-
name: "Button Text",
|
|
62
|
-
id: "button-text-1",
|
|
63
|
-
text_lid: `id${id}`,
|
|
64
|
-
font_weight: "medium",
|
|
65
|
-
horizontal_alignment: "center",
|
|
66
|
-
background_color: {
|
|
67
|
-
dark: { type: "hex", value: "transparent" },
|
|
68
|
-
light: { type: "hex", value: "transparent" },
|
|
69
|
-
},
|
|
70
|
-
color: {
|
|
71
|
-
dark: { type: "hex", value: DEFAULT_TEXT_COLOR },
|
|
72
|
-
light: { type: "hex", value: "#ffffff" },
|
|
73
|
-
},
|
|
74
|
-
font_size: "body_m",
|
|
75
|
-
margin: { top: 0, trailing: 0, bottom: 0, leading: 0 },
|
|
76
|
-
padding: { top: 0, trailing: 0, bottom: 0, leading: 0 },
|
|
77
|
-
size: {
|
|
78
|
-
width: { type: "fit" },
|
|
79
|
-
height: { type: "fit" },
|
|
80
|
-
},
|
|
81
|
-
}) satisfies Partial<TextNodeProps>;
|
|
82
|
-
|
|
83
|
-
const baseStackProps = {
|
|
35
|
+
const stackProps = (id: number): StackProps => ({
|
|
84
36
|
type: "stack",
|
|
37
|
+
id: `stack-${id}`,
|
|
38
|
+
name: `Stack ${id}`,
|
|
39
|
+
components: [textProps(id)],
|
|
85
40
|
size: { width: { type: "fill" }, height: { type: "fill" } },
|
|
86
41
|
dimension: {
|
|
87
42
|
type: "horizontal",
|
|
88
43
|
alignment: "center",
|
|
89
44
|
distribution: "center",
|
|
90
45
|
},
|
|
91
|
-
components: [],
|
|
92
46
|
spacing: 16,
|
|
93
|
-
padding: { top: 16, trailing: 16, bottom: 16, leading: 16 },
|
|
94
47
|
margin: { top: 0, trailing: 0, bottom: 0, leading: 0 },
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
name: "Vertical Stack",
|
|
98
|
-
background_color: {
|
|
99
|
-
dark: { type: "hex", value: "#3471eb" },
|
|
100
|
-
light: { type: "hex", value: "#3471eb" },
|
|
101
|
-
},
|
|
48
|
+
padding: { top: 16, trailing: 16, bottom: 16, leading: 16 },
|
|
49
|
+
background_color: null,
|
|
102
50
|
background: {
|
|
103
51
|
type: "color",
|
|
104
52
|
value: {
|
|
@@ -107,31 +55,54 @@
|
|
|
107
55
|
},
|
|
108
56
|
},
|
|
109
57
|
border: null,
|
|
58
|
+
shape: { type: "pill" },
|
|
110
59
|
shadow: null,
|
|
111
|
-
|
|
60
|
+
badge: null,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const defaultLocale = "en_US";
|
|
64
|
+
|
|
65
|
+
const { Story } = defineMeta({
|
|
66
|
+
title: "Components/Button",
|
|
67
|
+
component: ButtonNode,
|
|
68
|
+
decorators: [
|
|
69
|
+
componentDecorator(),
|
|
70
|
+
localizationDecorator({
|
|
71
|
+
defaultLocale,
|
|
72
|
+
localizations: {
|
|
73
|
+
[defaultLocale]: {
|
|
74
|
+
id1: "Restore purchases",
|
|
75
|
+
id2: "Navigate back",
|
|
76
|
+
id3: "Navigate to",
|
|
77
|
+
id4: "URL navigation",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
82
|
+
args: {
|
|
83
|
+
type: "button",
|
|
84
|
+
id: "button",
|
|
85
|
+
name: "Button",
|
|
86
|
+
action: { type: "navigate_back" },
|
|
87
|
+
stack: stackProps(1),
|
|
88
|
+
} satisfies ButtonProps,
|
|
89
|
+
});
|
|
112
90
|
</script>
|
|
113
91
|
|
|
114
|
-
<!-- Restore purchases -->
|
|
115
92
|
<Story
|
|
116
93
|
name="Restore purchases"
|
|
117
94
|
args={{
|
|
118
|
-
type: "button",
|
|
119
95
|
action: { type: "restore_purchases" },
|
|
120
|
-
stack:
|
|
121
|
-
...baseStackProps,
|
|
122
|
-
components: [textProps(1)],
|
|
123
|
-
},
|
|
96
|
+
stack: stackProps(1),
|
|
124
97
|
}}
|
|
125
98
|
/>
|
|
126
99
|
|
|
127
|
-
<!-- Navigate Back story -->
|
|
128
100
|
<Story
|
|
129
101
|
name="Navigate Back"
|
|
130
102
|
args={{
|
|
131
|
-
type: "button",
|
|
132
103
|
action: { type: "navigate_back" },
|
|
133
104
|
stack: {
|
|
134
|
-
...
|
|
105
|
+
...stackProps(2),
|
|
135
106
|
shape: {
|
|
136
107
|
type: "rectangle",
|
|
137
108
|
corners: {
|
|
@@ -145,22 +116,19 @@
|
|
|
145
116
|
dark: { type: "hex", value: "#2E7D32" },
|
|
146
117
|
light: { type: "hex", value: "#2E7D32" },
|
|
147
118
|
},
|
|
148
|
-
components: [textProps(2)],
|
|
149
119
|
},
|
|
150
120
|
}}
|
|
151
121
|
/>
|
|
152
122
|
|
|
153
|
-
<!-- Navigate To story -->
|
|
154
123
|
<Story
|
|
155
124
|
name="Navigate To"
|
|
156
125
|
args={{
|
|
157
|
-
type: "button",
|
|
158
126
|
action: {
|
|
159
127
|
type: "navigate_to",
|
|
160
128
|
destination: "customer_center",
|
|
161
129
|
},
|
|
162
130
|
stack: {
|
|
163
|
-
...
|
|
131
|
+
...stackProps(3),
|
|
164
132
|
shape: {
|
|
165
133
|
type: "rectangle",
|
|
166
134
|
corners: {
|
|
@@ -174,16 +142,13 @@
|
|
|
174
142
|
dark: { type: "hex", value: "#D32F2F" },
|
|
175
143
|
light: { type: "hex", value: "#D32F2F" },
|
|
176
144
|
},
|
|
177
|
-
components: [textProps(3)],
|
|
178
145
|
},
|
|
179
146
|
}}
|
|
180
147
|
/>
|
|
181
148
|
|
|
182
|
-
<!-- URL Navigation story -->
|
|
183
149
|
<Story
|
|
184
150
|
name="URL Navigation"
|
|
185
151
|
args={{
|
|
186
|
-
type: "button",
|
|
187
152
|
action: {
|
|
188
153
|
type: "navigate_to",
|
|
189
154
|
destination: "url",
|
|
@@ -193,12 +158,11 @@
|
|
|
193
158
|
},
|
|
194
159
|
},
|
|
195
160
|
stack: {
|
|
196
|
-
...
|
|
161
|
+
...stackProps(4),
|
|
197
162
|
background_color: {
|
|
198
163
|
dark: { type: "hex", value: "#4A90E2" },
|
|
199
164
|
light: { type: "hex", value: "#4A90E2" },
|
|
200
165
|
},
|
|
201
|
-
components: [textProps(4)],
|
|
202
166
|
},
|
|
203
167
|
}}
|
|
204
168
|
/>
|
|
@@ -1,37 +1,29 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { getButtonStyles } from "./button-utils";
|
|
3
2
|
import Stack from "../stack/Stack.svelte";
|
|
4
|
-
import { ButtonDeprecated } from "../../index";
|
|
5
3
|
import { getPaywallContext } from "../../stores/paywall";
|
|
4
|
+
import { getSelectedStateContext } from "../../stores/selected";
|
|
6
5
|
import type { ButtonProps } from "../../types/components/button";
|
|
6
|
+
import { getActiveStateProps } from "../../utils/style-utils";
|
|
7
|
+
|
|
8
|
+
const props: ButtonProps = $props();
|
|
9
|
+
|
|
10
|
+
const selectedState = getSelectedStateContext();
|
|
11
|
+
const { action } = $derived.by(() => {
|
|
12
|
+
return {
|
|
13
|
+
...props,
|
|
14
|
+
...getActiveStateProps($selectedState, props.overrides),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
7
17
|
|
|
8
|
-
const { stack, action, ...restProps }: ButtonProps = $props();
|
|
9
18
|
const { onButtonAction } = getPaywallContext();
|
|
10
19
|
|
|
11
|
-
const onclick = () => onButtonAction(action);
|
|
20
|
+
const onclick = () => onButtonAction(props.action);
|
|
12
21
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
stack,
|
|
16
|
-
action,
|
|
17
|
-
...restProps,
|
|
18
|
-
}),
|
|
22
|
+
const isWebPurchaseLink = $derived(
|
|
23
|
+
action.type === "navigate_to" && action.destination === "web_paywall_link",
|
|
19
24
|
);
|
|
20
25
|
</script>
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
<Stack {...stack} />
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<style>
|
|
27
|
-
.rc-pw-button {
|
|
28
|
-
display: flex;
|
|
29
|
-
margin: 0;
|
|
30
|
-
padding: 0;
|
|
31
|
-
text-align: initial;
|
|
32
|
-
border: none;
|
|
33
|
-
cursor: pointer;
|
|
34
|
-
background: transparent;
|
|
35
|
-
width: fit-content;
|
|
36
|
-
}
|
|
37
|
-
</style>
|
|
27
|
+
{#if !isWebPurchaseLink}
|
|
28
|
+
<Stack {...props.stack} {onclick} />
|
|
29
|
+
{/if}
|