@revenuecat/purchases-ui-js 2.0.3 → 2.0.5
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/button/ButtonNode.svelte +27 -3
- 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/package/Package.svelte +3 -1
- package/dist/components/paywall/Node.svelte +12 -24
- package/dist/components/paywall/Node.svelte.d.ts +1 -6
- package/dist/components/paywall/Paywall.stories.svelte +155 -0
- package/dist/components/paywall/Paywall.svelte +50 -59
- package/dist/components/paywall/Paywall.svelte.d.ts +2 -1
- package/dist/components/paywall/Sheet.svelte +126 -0
- package/dist/components/paywall/Sheet.svelte.d.ts +4 -0
- package/dist/components/paywall/fixtures/background-paywall.d.ts +3 -0
- package/dist/components/paywall/fixtures/background-paywall.js +62 -0
- package/dist/components/paywall/fixtures/override-paywall.d.ts +1 -1
- package/dist/components/paywall/fixtures/sheet-paywall.d.ts +2 -0
- package/dist/components/paywall/fixtures/sheet-paywall.js +325 -0
- package/dist/components/paywall/fixtures/stack-paywall.d.ts +1 -1
- package/dist/components/stack/Stack.svelte +6 -1
- package/dist/components/stack/Stack.svelte.d.ts +2 -0
- package/dist/components/tabs/TabControl.svelte +11 -0
- package/dist/components/tabs/TabControl.svelte.d.ts +4 -0
- package/dist/components/tabs/TabControlButton.svelte +19 -0
- package/dist/components/tabs/TabControlButton.svelte.d.ts +4 -0
- package/dist/components/tabs/Tabs.stories.svelte +929 -0
- package/dist/components/tabs/Tabs.stories.svelte.d.ts +19 -0
- package/dist/components/tabs/Tabs.svelte +69 -0
- package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
- package/dist/components/tabs/tabs-context.d.ts +11 -0
- package/dist/components/tabs/tabs-context.js +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/stores/paywall.d.ts +1 -1
- package/dist/stores/selected.d.ts +1 -1
- package/dist/stores/selected.js +3 -5
- package/dist/stories/fixtures.d.ts +2 -1
- package/dist/stories/viewport-wrapper.svelte +7 -5
- package/dist/types/component.d.ts +5 -3
- package/dist/types/components/button.d.ts +4 -1
- package/dist/types/components/carousel.d.ts +51 -0
- package/dist/types/components/sheet.d.ts +16 -0
- package/dist/types/components/sheet.js +1 -0
- package/dist/types/components/tabs.d.ts +46 -0
- package/dist/types/components/tabs.js +1 -0
- package/dist/types/paywall.d.ts +26 -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.d.ts +6 -2
- package/dist/utils/base-utils.d.ts +1 -1
- package/dist/utils/base-utils.js +2 -17
- package/dist/utils/font-utils.d.ts +1 -1
- package/dist/utils/style-utils.d.ts +2 -9
- package/dist/utils/style-utils.js +7 -24
- package/dist/web-components/index.js +969 -942
- package/package.json +20 -20
- package/dist/components/paywall/paywall-utils.d.ts +0 -8
- package/dist/components/paywall/paywall-utils.js +0 -24
- package/dist/data/entities.d.ts +0 -46
- /package/dist/{data/entities.js → types/components/carousel.js} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Carousel from "./Carousel.svelte";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Carousel: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Carousel = InstanceType<typeof Carousel>;
|
|
19
|
+
export default Carousel;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getColorModeContext } from "../../stores/color-mode";
|
|
3
|
+
import { getSelectedStateContext } from "../../stores/selected";
|
|
4
|
+
import type { CarouselProps } from "../../types/components/carousel";
|
|
5
|
+
import { mapBackground } from "../../utils/background-utils";
|
|
6
|
+
import {
|
|
7
|
+
css,
|
|
8
|
+
mapBorder,
|
|
9
|
+
mapBorderRadius,
|
|
10
|
+
mapShadow,
|
|
11
|
+
mapSpacing,
|
|
12
|
+
px,
|
|
13
|
+
} from "../../utils/base-utils";
|
|
14
|
+
import { getActiveStateProps } from "../../utils/style-utils";
|
|
15
|
+
import { onMount } from "svelte";
|
|
16
|
+
import { clamp, getTranslation, mapPageAlignment } from "./carousel-utils";
|
|
17
|
+
import CarouselPage from "./CarouselPage.svelte";
|
|
18
|
+
import PageControl from "./PageControl.svelte";
|
|
19
|
+
|
|
20
|
+
const props: CarouselProps = $props();
|
|
21
|
+
const selectedState = getSelectedStateContext();
|
|
22
|
+
const {
|
|
23
|
+
pages,
|
|
24
|
+
padding,
|
|
25
|
+
margin,
|
|
26
|
+
background,
|
|
27
|
+
shape,
|
|
28
|
+
border,
|
|
29
|
+
shadow,
|
|
30
|
+
page_alignment,
|
|
31
|
+
page_spacing,
|
|
32
|
+
page_peek,
|
|
33
|
+
page_control,
|
|
34
|
+
initial_page_index,
|
|
35
|
+
loop,
|
|
36
|
+
auto_advance,
|
|
37
|
+
} = $derived.by(() => {
|
|
38
|
+
return {
|
|
39
|
+
...props,
|
|
40
|
+
...getActiveStateProps($selectedState, props.overrides),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const getColorMode = getColorModeContext();
|
|
45
|
+
const colorMode = $derived(getColorMode());
|
|
46
|
+
|
|
47
|
+
const carouselStyle = $derived(
|
|
48
|
+
css({
|
|
49
|
+
margin: mapSpacing(margin),
|
|
50
|
+
padding: mapSpacing(padding),
|
|
51
|
+
...mapBackground(colorMode, null, background),
|
|
52
|
+
border: mapBorder(colorMode, border),
|
|
53
|
+
"border-radius": mapBorderRadius(shape),
|
|
54
|
+
"box-shadow": mapShadow(colorMode, shadow),
|
|
55
|
+
"transition-duration": `${auto_advance?.ms_transition_time ?? 0}ms`,
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const sliderStyle = $derived(
|
|
60
|
+
css({
|
|
61
|
+
gap: px(page_spacing),
|
|
62
|
+
padding: `0 ${page_peek + page_spacing}px`,
|
|
63
|
+
"align-items": mapPageAlignment(page_alignment),
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const prevPages = $derived.by(() => {
|
|
68
|
+
if (!loop) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const last = pages.length - 1;
|
|
73
|
+
switch (pages.length) {
|
|
74
|
+
case 0:
|
|
75
|
+
return [];
|
|
76
|
+
case 1:
|
|
77
|
+
return [0, 0];
|
|
78
|
+
case 2:
|
|
79
|
+
return [0, last];
|
|
80
|
+
default:
|
|
81
|
+
return [last - 1, last];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const nextPages = $derived.by(() => {
|
|
86
|
+
if (!loop) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
switch (pages.length) {
|
|
91
|
+
case 0:
|
|
92
|
+
return [];
|
|
93
|
+
case 1:
|
|
94
|
+
return [0, 0];
|
|
95
|
+
default:
|
|
96
|
+
return [0, 1];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
let slider: HTMLElement | null = null;
|
|
101
|
+
let currentPage = $state(0);
|
|
102
|
+
let carouselWidth = $state(0);
|
|
103
|
+
let pageOffset = $derived(2 * page_peek + page_spacing);
|
|
104
|
+
let pageWidth = $derived(carouselWidth - pageOffset);
|
|
105
|
+
|
|
106
|
+
function startTransition(withDelay: boolean = true, durationMs?: number) {
|
|
107
|
+
if (slider === null) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const delayMs = withDelay ? (auto_advance?.ms_time_per_page ?? 0) : 0;
|
|
112
|
+
durationMs ??= auto_advance?.ms_transition_time ?? 0;
|
|
113
|
+
slider.style.transition = `transform ${durationMs}ms ease-in-out ${delayMs}ms`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function stopTransition() {
|
|
117
|
+
if (slider !== null) {
|
|
118
|
+
slider.style.transition = "none";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const loopOffset = $derived(loop ? 2 : 0);
|
|
123
|
+
|
|
124
|
+
function setSliderTranslate(translate: number) {
|
|
125
|
+
if (slider !== null) {
|
|
126
|
+
slider.style.transform = `translateX(${translate}px)`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function moveTo(index: number) {
|
|
131
|
+
if (slider === null) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
index += loopOffset;
|
|
136
|
+
const translate = index * -pageWidth;
|
|
137
|
+
setSliderTranslate(translate);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function setCurrentPage(index: number) {
|
|
141
|
+
index %= pages.length + loopOffset;
|
|
142
|
+
startTransition(true);
|
|
143
|
+
moveTo(index);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function startAutoAdvance() {
|
|
147
|
+
if (auto_advance == null) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
requestAnimationFrame(() => {
|
|
152
|
+
setCurrentPage(currentPage + 1);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
onMount(() => {
|
|
157
|
+
const initialPage =
|
|
158
|
+
pages.at(initial_page_index) !== undefined ? initial_page_index : 0;
|
|
159
|
+
currentPage = initialPage;
|
|
160
|
+
|
|
161
|
+
stopTransition();
|
|
162
|
+
moveTo(currentPage);
|
|
163
|
+
startAutoAdvance();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
function getPageFromTranslation(translation: number) {
|
|
167
|
+
return Math.round(translation / -pageWidth) - loopOffset;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function ontransitionend() {
|
|
171
|
+
const translation = getTranslation(slider);
|
|
172
|
+
const page = getPageFromTranslation(translation);
|
|
173
|
+
currentPage = (page + pages.length) % pages.length;
|
|
174
|
+
stopTransition();
|
|
175
|
+
moveTo(currentPage);
|
|
176
|
+
|
|
177
|
+
requestAnimationFrame(() => {
|
|
178
|
+
startAutoAdvance();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let startTranslation = $state(0);
|
|
183
|
+
|
|
184
|
+
function onpointerdown(event: PointerEvent) {
|
|
185
|
+
const target = event.currentTarget as HTMLElement;
|
|
186
|
+
target.setPointerCapture(event.pointerId);
|
|
187
|
+
startTranslation = getTranslation(slider);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function onpointerup(event: PointerEvent) {
|
|
191
|
+
const target = event.currentTarget as HTMLElement;
|
|
192
|
+
target.releasePointerCapture(event.pointerId);
|
|
193
|
+
|
|
194
|
+
const translation = getTranslation(slider);
|
|
195
|
+
const page = getPageFromTranslation(translation);
|
|
196
|
+
startTransition(false, 500);
|
|
197
|
+
moveTo(page);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function onpointermove(event: PointerEvent) {
|
|
201
|
+
const target = event.currentTarget as HTMLElement;
|
|
202
|
+
if (!target.hasPointerCapture(event.pointerId)) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const [min, max] = loop
|
|
207
|
+
? [startTranslation - carouselWidth, startTranslation + carouselWidth]
|
|
208
|
+
: [-(pages.length - 1) * pageWidth, 0];
|
|
209
|
+
const translation = getTranslation(slider);
|
|
210
|
+
const newTranslation = clamp(translation + event.movementX, min, max);
|
|
211
|
+
|
|
212
|
+
const page = getPageFromTranslation(newTranslation);
|
|
213
|
+
currentPage = (page + pages.length) % pages.length;
|
|
214
|
+
|
|
215
|
+
setSliderTranslate(newTranslation);
|
|
216
|
+
stopTransition();
|
|
217
|
+
}
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<div class="carousel" style={carouselStyle}>
|
|
221
|
+
<div
|
|
222
|
+
bind:this={slider}
|
|
223
|
+
bind:clientWidth={carouselWidth}
|
|
224
|
+
{ontransitionend}
|
|
225
|
+
{onpointerdown}
|
|
226
|
+
{onpointerup}
|
|
227
|
+
{onpointermove}
|
|
228
|
+
class="slider"
|
|
229
|
+
style={sliderStyle}
|
|
230
|
+
role="region"
|
|
231
|
+
aria-label="Feature carousel"
|
|
232
|
+
aria-roledescription="carousel"
|
|
233
|
+
aria-live="polite"
|
|
234
|
+
>
|
|
235
|
+
{#each prevPages as index}
|
|
236
|
+
<CarouselPage
|
|
237
|
+
page={pages[index]}
|
|
238
|
+
{index}
|
|
239
|
+
pages={pages.length}
|
|
240
|
+
selected={currentPage === index}
|
|
241
|
+
hidden
|
|
242
|
+
/>
|
|
243
|
+
{/each}
|
|
244
|
+
{#each pages as page, index}
|
|
245
|
+
<CarouselPage
|
|
246
|
+
{page}
|
|
247
|
+
{index}
|
|
248
|
+
pages={pages.length}
|
|
249
|
+
selected={currentPage === index}
|
|
250
|
+
/>
|
|
251
|
+
{/each}
|
|
252
|
+
{#each nextPages as index}
|
|
253
|
+
<CarouselPage
|
|
254
|
+
page={pages[index]}
|
|
255
|
+
{index}
|
|
256
|
+
pages={pages.length}
|
|
257
|
+
selected={currentPage === index}
|
|
258
|
+
hidden
|
|
259
|
+
/>
|
|
260
|
+
{/each}
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
{#if page_control != null}
|
|
264
|
+
<PageControl
|
|
265
|
+
{...page_control}
|
|
266
|
+
length={pages.length}
|
|
267
|
+
selected={currentPage}
|
|
268
|
+
/>
|
|
269
|
+
{/if}
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
<style>
|
|
273
|
+
.carousel {
|
|
274
|
+
max-width: 100%;
|
|
275
|
+
display: flex;
|
|
276
|
+
flex-direction: column;
|
|
277
|
+
overflow: hidden;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.slider {
|
|
281
|
+
display: flex;
|
|
282
|
+
flex-direction: row;
|
|
283
|
+
flex-wrap: nowrap;
|
|
284
|
+
|
|
285
|
+
transition-property: transform;
|
|
286
|
+
transition-duration: 500ms;
|
|
287
|
+
transition-timing-function: ease-in-out;
|
|
288
|
+
transition-delay: 2500ms;
|
|
289
|
+
transform: translateX(0);
|
|
290
|
+
|
|
291
|
+
cursor: grab;
|
|
292
|
+
|
|
293
|
+
&:active {
|
|
294
|
+
cursor: grabbing;
|
|
295
|
+
user-select: none;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { StackProps } from "../../types/components/stack";
|
|
3
|
+
import Stack from "../stack/Stack.svelte";
|
|
4
|
+
|
|
5
|
+
interface CarouselPageProps {
|
|
6
|
+
page: StackProps;
|
|
7
|
+
index: number;
|
|
8
|
+
pages: number;
|
|
9
|
+
selected: boolean;
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
index,
|
|
15
|
+
pages,
|
|
16
|
+
selected,
|
|
17
|
+
page,
|
|
18
|
+
hidden = false,
|
|
19
|
+
}: CarouselPageProps = $props();
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
class="page"
|
|
24
|
+
role="group"
|
|
25
|
+
aria-roledescription="slide"
|
|
26
|
+
aria-label={`Slide ${index + 1} of ${pages}`}
|
|
27
|
+
aria-current={selected}
|
|
28
|
+
aria-hidden={hidden}
|
|
29
|
+
>
|
|
30
|
+
<Stack {...page} />
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
div {
|
|
35
|
+
flex: 0 0 100%;
|
|
36
|
+
scroll-snap-align: center;
|
|
37
|
+
scroll-snap-stop: always;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StackProps } from "../../types/components/stack";
|
|
2
|
+
interface CarouselPageProps {
|
|
3
|
+
page: StackProps;
|
|
4
|
+
index: number;
|
|
5
|
+
pages: number;
|
|
6
|
+
selected: boolean;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const CarouselPage: import("svelte").Component<CarouselPageProps, {}, "">;
|
|
10
|
+
type CarouselPage = ReturnType<typeof CarouselPage>;
|
|
11
|
+
export default CarouselPage;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getColorModeContext } from "../../stores/color-mode";
|
|
3
|
+
import type {
|
|
4
|
+
PageControl,
|
|
5
|
+
PageControlIndicator,
|
|
6
|
+
} from "../../types/components/carousel";
|
|
7
|
+
import { mapBackground } from "../../utils/background-utils";
|
|
8
|
+
import {
|
|
9
|
+
css,
|
|
10
|
+
mapBorder,
|
|
11
|
+
mapBorderRadius,
|
|
12
|
+
mapColor,
|
|
13
|
+
mapShadow,
|
|
14
|
+
mapSpacing,
|
|
15
|
+
px,
|
|
16
|
+
} from "../../utils/base-utils";
|
|
17
|
+
|
|
18
|
+
interface ExtraProps {
|
|
19
|
+
length: number;
|
|
20
|
+
selected: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
position,
|
|
25
|
+
spacing,
|
|
26
|
+
margin,
|
|
27
|
+
padding,
|
|
28
|
+
background_color = null,
|
|
29
|
+
border = null,
|
|
30
|
+
shape = null,
|
|
31
|
+
shadow = null,
|
|
32
|
+
active: activeIndicator,
|
|
33
|
+
default: defaultIndicator,
|
|
34
|
+
length,
|
|
35
|
+
selected,
|
|
36
|
+
}: PageControl & ExtraProps = $props();
|
|
37
|
+
|
|
38
|
+
const getColorMode = getColorModeContext();
|
|
39
|
+
const colorMode = $derived(getColorMode());
|
|
40
|
+
|
|
41
|
+
function mapIndicatorBorder(indicator: PageControlIndicator) {
|
|
42
|
+
if (indicator.stroke_width == null || indicator.stroke_color == null) {
|
|
43
|
+
return "none";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return mapBorder(colorMode, {
|
|
47
|
+
width: indicator.stroke_width,
|
|
48
|
+
color: indicator.stroke_color,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function mapIndicatorStyle(indicator: PageControlIndicator) {
|
|
53
|
+
return css({
|
|
54
|
+
width: px(indicator.width),
|
|
55
|
+
height: px(indicator.height),
|
|
56
|
+
background: mapColor(colorMode, indicator.color),
|
|
57
|
+
border: mapIndicatorBorder(indicator),
|
|
58
|
+
"border-radius": "9999px",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const defaultStyle = $derived(mapIndicatorStyle(defaultIndicator));
|
|
63
|
+
const activeStyle = $derived(mapIndicatorStyle(activeIndicator));
|
|
64
|
+
|
|
65
|
+
const style = $derived(
|
|
66
|
+
css({
|
|
67
|
+
order: position === "top" ? -1 : 1,
|
|
68
|
+
gap: px(spacing),
|
|
69
|
+
margin: mapSpacing(margin),
|
|
70
|
+
padding: mapSpacing(padding),
|
|
71
|
+
...mapBackground(colorMode, background_color, null),
|
|
72
|
+
border: mapBorder(colorMode, border),
|
|
73
|
+
"border-radius": mapBorderRadius(shape),
|
|
74
|
+
"box-shadow": mapShadow(colorMode, shadow),
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<div class="control" {style}>
|
|
80
|
+
{#each { length }, index}
|
|
81
|
+
<div style={index === selected ? activeStyle : defaultStyle}></div>
|
|
82
|
+
{/each}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<style>
|
|
86
|
+
.control {
|
|
87
|
+
align-self: center;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: row;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VerticalAlignment } from "../../types/alignment";
|
|
2
|
+
export declare function mapPageAlignment(alignment: VerticalAlignment): string;
|
|
3
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
4
|
+
export declare function getTranslation(element: HTMLElement | null): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function mapPageAlignment(alignment) {
|
|
2
|
+
switch (alignment) {
|
|
3
|
+
case "top":
|
|
4
|
+
return "flex-start";
|
|
5
|
+
case "center":
|
|
6
|
+
return "center";
|
|
7
|
+
case "bottom":
|
|
8
|
+
return "flex-end";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function clamp(value, min, max) {
|
|
12
|
+
return Math.max(min, Math.min(value, max));
|
|
13
|
+
}
|
|
14
|
+
export function getTranslation(element) {
|
|
15
|
+
if (element === null) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
const style = window.getComputedStyle(element);
|
|
19
|
+
const trasform = new WebKitCSSMatrix(style.transform);
|
|
20
|
+
return trasform.m41;
|
|
21
|
+
}
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
const { selectedPackageId, variablesPerPackage } = getPaywallContext();
|
|
15
15
|
|
|
16
|
-
setSelectedStateContext(
|
|
16
|
+
setSelectedStateContext(
|
|
17
|
+
derived(selectedPackageId, (value) => value === package_id),
|
|
18
|
+
);
|
|
17
19
|
|
|
18
20
|
const onPackageClick = () => {
|
|
19
21
|
$selectedPackageId = package_id;
|
|
@@ -11,19 +11,11 @@
|
|
|
11
11
|
import TextNode from "../text/TextNode.svelte";
|
|
12
12
|
import type { Component } from "../../types/component";
|
|
13
13
|
import type { Component as SvelteComponent } from "svelte";
|
|
14
|
+
import Carousel from "../carousel/Carousel.svelte";
|
|
14
15
|
import Icon from "../icon/Icon.svelte";
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| ButtonNode
|
|
19
|
-
| Footer
|
|
20
|
-
| Icon
|
|
21
|
-
| Image
|
|
22
|
-
| Package
|
|
23
|
-
| PurchaseButton
|
|
24
|
-
| Stack
|
|
25
|
-
| TextNode
|
|
26
|
-
| Timeline;
|
|
16
|
+
import TabControl from "../tabs/TabControl.svelte";
|
|
17
|
+
import TabControlButton from "../tabs/TabControlButton.svelte";
|
|
18
|
+
import Tabs from "../tabs/Tabs.svelte";
|
|
27
19
|
|
|
28
20
|
interface Props {
|
|
29
21
|
nodeData: Component;
|
|
@@ -31,12 +23,16 @@
|
|
|
31
23
|
|
|
32
24
|
const ComponentTypes = {
|
|
33
25
|
button: ButtonNode,
|
|
26
|
+
carousel: Carousel,
|
|
34
27
|
footer: Footer,
|
|
35
28
|
icon: Icon,
|
|
36
29
|
image: Image,
|
|
37
30
|
package: Package,
|
|
38
31
|
purchase_button: PurchaseButton,
|
|
39
32
|
stack: Stack,
|
|
33
|
+
tab_control_button: TabControlButton,
|
|
34
|
+
tab_control: TabControl,
|
|
35
|
+
tabs: Tabs,
|
|
40
36
|
text: TextNode,
|
|
41
37
|
timeline: Timeline,
|
|
42
38
|
} satisfies {
|
|
@@ -56,12 +52,12 @@
|
|
|
56
52
|
*/
|
|
57
53
|
export const getComponentClass: (
|
|
58
54
|
nodeData: Component,
|
|
59
|
-
) => [SvelteComponent<
|
|
55
|
+
) => [SvelteComponent<Component>, Component] | undefined = (
|
|
60
56
|
nodeData: Component,
|
|
61
57
|
) => {
|
|
62
58
|
if (ComponentTypes[nodeData.type]) {
|
|
63
59
|
return [
|
|
64
|
-
ComponentTypes[nodeData.type] as SvelteComponent<
|
|
60
|
+
ComponentTypes[nodeData.type] as SvelteComponent<Component>,
|
|
65
61
|
nodeData,
|
|
66
62
|
];
|
|
67
63
|
}
|
|
@@ -69,7 +65,7 @@
|
|
|
69
65
|
const { fallback } = nodeData;
|
|
70
66
|
if (fallback && ComponentTypes[fallback?.type]) {
|
|
71
67
|
return [
|
|
72
|
-
ComponentTypes[fallback.type] as SvelteComponent<
|
|
68
|
+
ComponentTypes[fallback.type] as SvelteComponent<Component>,
|
|
73
69
|
fallback,
|
|
74
70
|
];
|
|
75
71
|
}
|
|
@@ -84,16 +80,8 @@
|
|
|
84
80
|
const [ComponentToRender, dataToUse] = $derived(
|
|
85
81
|
getComponentClass(nodeData) ?? [],
|
|
86
82
|
);
|
|
87
|
-
|
|
88
|
-
const components = $derived(
|
|
89
|
-
("components" in nodeData ? nodeData.components : undefined) ?? [],
|
|
90
|
-
);
|
|
91
83
|
</script>
|
|
92
84
|
|
|
93
85
|
{#if ComponentToRender}
|
|
94
|
-
<ComponentToRender {...(dataToUse as any) || {}} {...restProps}
|
|
95
|
-
{#each components as childData}
|
|
96
|
-
<Self nodeData={childData} {...restProps} />
|
|
97
|
-
{/each}
|
|
98
|
-
</ComponentToRender>
|
|
86
|
+
<ComponentToRender {...(dataToUse as any) || {}} {...restProps} />
|
|
99
87
|
{/if}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { Footer, Image, Package, PurchaseButton, Stack, Timeline } from "../..";
|
|
3
|
-
import ButtonNode from "../button/ButtonNode.svelte";
|
|
4
|
-
import TextNode from "../text/TextNode.svelte";
|
|
5
2
|
import type { Component } from "../../types/component";
|
|
6
|
-
import Icon from "../icon/Icon.svelte";
|
|
7
|
-
type SupportedComponents = ButtonNode | Footer | Icon | Image | Package | PurchaseButton | Stack | TextNode | Timeline;
|
|
8
3
|
interface Props {
|
|
9
4
|
nodeData: Component;
|
|
10
5
|
}
|
|
@@ -17,7 +12,7 @@ declare const Node: import("svelte").Component<Props, {
|
|
|
17
12
|
* @param nodeData:Component - the Component object representing a Node in the paywall
|
|
18
13
|
* @returns [Component<SupportedComponents>, Component] - a tuple containing the component class and the node data
|
|
19
14
|
* @throws Error - if the component type and the fallback component type are not supported
|
|
20
|
-
*/ getComponentClass: (nodeData: Component) => [SvelteComponent<
|
|
15
|
+
*/ getComponentClass: (nodeData: Component) => [SvelteComponent<Component>, Component] | undefined;
|
|
21
16
|
}, "">;
|
|
22
17
|
type Node = ReturnType<typeof Node>;
|
|
23
18
|
export default Node;
|