@revenuecat/purchases-ui-js 2.0.3 → 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.svelte +20 -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/paywall/Node.svelte +4 -10
- package/dist/components/paywall/Node.svelte.d.ts +2 -1
- package/dist/components/paywall/Paywall.svelte +5 -5
- package/dist/components/paywall/Paywall.svelte.d.ts +2 -1
- package/dist/components/paywall/fixtures/override-paywall.d.ts +1 -1
- package/dist/components/paywall/fixtures/stack-paywall.d.ts +1 -1
- package/dist/components/paywall/paywall-utils.d.ts +1 -1
- package/dist/components/stack/Stack.svelte +6 -1
- package/dist/components/stack/Stack.svelte.d.ts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/stores/paywall.d.ts +1 -1
- package/dist/stories/fixtures.d.ts +2 -1
- package/dist/stories/viewport-wrapper.svelte +7 -5
- package/dist/types/component.d.ts +2 -1
- package/dist/types/components/button.d.ts +2 -0
- package/dist/types/components/carousel.d.ts +51 -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/utils/font-utils.d.ts +1 -1
- package/dist/utils/style-utils.d.ts +1 -1
- package/dist/utils/style-utils.js +7 -2
- package/dist/web-components/index.js +969 -942
- package/package.json +20 -20
- 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
|
+
}
|
|
@@ -11,11 +11,12 @@
|
|
|
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 Self from "./Node.svelte";
|
|
16
16
|
|
|
17
17
|
type SupportedComponents =
|
|
18
18
|
| ButtonNode
|
|
19
|
+
| Carousel
|
|
19
20
|
| Footer
|
|
20
21
|
| Icon
|
|
21
22
|
| Image
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
|
|
32
33
|
const ComponentTypes = {
|
|
33
34
|
button: ButtonNode,
|
|
35
|
+
carousel: Carousel,
|
|
34
36
|
footer: Footer,
|
|
35
37
|
icon: Icon,
|
|
36
38
|
image: Image,
|
|
@@ -84,16 +86,8 @@
|
|
|
84
86
|
const [ComponentToRender, dataToUse] = $derived(
|
|
85
87
|
getComponentClass(nodeData) ?? [],
|
|
86
88
|
);
|
|
87
|
-
|
|
88
|
-
const components = $derived(
|
|
89
|
-
("components" in nodeData ? nodeData.components : undefined) ?? [],
|
|
90
|
-
);
|
|
91
89
|
</script>
|
|
92
90
|
|
|
93
91
|
{#if ComponentToRender}
|
|
94
|
-
<ComponentToRender {...(dataToUse as any) || {}} {...restProps}
|
|
95
|
-
{#each components as childData}
|
|
96
|
-
<Self nodeData={childData} {...restProps} />
|
|
97
|
-
{/each}
|
|
98
|
-
</ComponentToRender>
|
|
92
|
+
<ComponentToRender {...(dataToUse as any) || {}} {...restProps} />
|
|
99
93
|
{/if}
|
|
@@ -3,8 +3,9 @@ import { Footer, Image, Package, PurchaseButton, Stack, Timeline } from "../..";
|
|
|
3
3
|
import ButtonNode from "../button/ButtonNode.svelte";
|
|
4
4
|
import TextNode from "../text/TextNode.svelte";
|
|
5
5
|
import type { Component } from "../../types/component";
|
|
6
|
+
import Carousel from "../carousel/Carousel.svelte";
|
|
6
7
|
import Icon from "../icon/Icon.svelte";
|
|
7
|
-
type SupportedComponents = ButtonNode | Footer | Icon | Image | Package | PurchaseButton | Stack | TextNode | Timeline;
|
|
8
|
+
type SupportedComponents = ButtonNode | Carousel | Footer | Icon | Image | Package | PurchaseButton | Stack | TextNode | Timeline;
|
|
8
9
|
interface Props {
|
|
9
10
|
nodeData: Component;
|
|
10
11
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { PaywallData, UIConfig } from "../../data/entities";
|
|
3
|
-
|
|
4
2
|
import Footer from "../footer/Footer.svelte";
|
|
5
3
|
import Node from "./Node.svelte";
|
|
6
4
|
import {
|
|
@@ -16,11 +14,13 @@
|
|
|
16
14
|
} from "../../stores/variables";
|
|
17
15
|
import type { ColorMode } from "../../types";
|
|
18
16
|
import type { Action } from "../../types/components/button";
|
|
19
|
-
import {
|
|
17
|
+
import type { PaywallData } from "../../types/paywall";
|
|
18
|
+
import type { UIConfig } from "../../types/ui-config";
|
|
19
|
+
import type { VariableDictionary } from "../../types/variables";
|
|
20
20
|
import { registerFonts } from "../../utils/font-utils";
|
|
21
|
-
import {
|
|
21
|
+
import { findSelectedPackageId } from "../../utils/style-utils";
|
|
22
22
|
import { onMount } from "svelte";
|
|
23
|
-
import
|
|
23
|
+
import { derived, readable, writable } from "svelte/store";
|
|
24
24
|
|
|
25
25
|
interface Props {
|
|
26
26
|
paywallData: PaywallData;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { PaywallData, UIConfig } from "../../data/entities";
|
|
2
1
|
import type { ColorMode } from "../../types";
|
|
2
|
+
import type { PaywallData } from "../../types/paywall";
|
|
3
|
+
import type { UIConfig } from "../../types/ui-config";
|
|
3
4
|
import type { VariableDictionary } from "../../types/variables";
|
|
4
5
|
interface Props {
|
|
5
6
|
paywallData: PaywallData;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { PaywallData } from "../../../
|
|
1
|
+
import type { PaywallData } from "../../../types/paywall";
|
|
2
2
|
export declare const OVERRIDE_PAYWALL: PaywallData;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { PaywallData } from "../../../
|
|
1
|
+
import type { PaywallData } from "../../../types/paywall";
|
|
2
2
|
export declare const STACK_PAYWALL: PaywallData;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PaywallData } from "../../data/entities";
|
|
2
1
|
import type { ColorMode } from "../../types";
|
|
3
2
|
import type { Background } from "../../types/background";
|
|
3
|
+
import type { PaywallData } from "../../types/paywall";
|
|
4
4
|
export declare function getBackgroundStyles({ background, colorMode, }: {
|
|
5
5
|
background?: Background;
|
|
6
6
|
colorMode: ColorMode;
|
|
@@ -14,13 +14,17 @@
|
|
|
14
14
|
px,
|
|
15
15
|
} from "../../utils/base-utils";
|
|
16
16
|
import { getActiveStateProps } from "../../utils/style-utils";
|
|
17
|
+
import type { Snippet } from "svelte";
|
|
17
18
|
import { mapBadge, mapDimension, mapLayerAlignment } from "./stack-utils";
|
|
18
19
|
|
|
19
20
|
interface MiscProps {
|
|
20
21
|
onclick?: () => void;
|
|
22
|
+
children?: Snippet;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const props: StackProps & MiscProps = $props();
|
|
26
|
+
const { onclick, children } = props;
|
|
27
|
+
|
|
24
28
|
const selectedState = getSelectedStateContext();
|
|
25
29
|
const {
|
|
26
30
|
components,
|
|
@@ -35,7 +39,6 @@
|
|
|
35
39
|
shape,
|
|
36
40
|
shadow,
|
|
37
41
|
badge,
|
|
38
|
-
onclick,
|
|
39
42
|
} = $derived.by(() => {
|
|
40
43
|
return {
|
|
41
44
|
...props,
|
|
@@ -110,6 +113,8 @@
|
|
|
110
113
|
<Node nodeData={component} />
|
|
111
114
|
{/each}
|
|
112
115
|
{/if}
|
|
116
|
+
|
|
117
|
+
{@render children?.()}
|
|
113
118
|
</svelte:element>
|
|
114
119
|
|
|
115
120
|
<style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { StackProps } from "../../types/components/stack";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
2
3
|
interface MiscProps {
|
|
3
4
|
onclick?: () => void;
|
|
5
|
+
children?: Snippet;
|
|
4
6
|
}
|
|
5
7
|
type $$ComponentProps = StackProps & MiscProps;
|
|
6
8
|
declare const Stack: import("svelte").Component<$$ComponentProps, {}, "">;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ export { default as PurchaseButton } from "./components/purchase-button/Purchase
|
|
|
7
7
|
export { default as Stack } from "./components/stack/Stack.svelte";
|
|
8
8
|
export { default as Text } from "./components/text/Text.svelte";
|
|
9
9
|
export { default as Timeline } from "./components/timeline/Timeline.svelte";
|
|
10
|
-
export { type PaywallData as PaywallData } from "./data/entities";
|
|
11
|
-
export { type UIConfig as UIConfig } from "./data/entities";
|
|
12
10
|
export * from "./types";
|
|
11
|
+
export { type PaywallData } from "./types/paywall";
|
|
12
|
+
export { type UIConfig } from "./types/ui-config";
|
|
13
13
|
export { type VariableDictionary } from "./types/variables";
|
|
14
14
|
export * from "./ui/globals";
|
|
15
15
|
export { default as Button } from "./ui/molecules/button.svelte";
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,9 @@ export { default as PurchaseButton } from "./components/purchase-button/Purchase
|
|
|
8
8
|
export { default as Stack } from "./components/stack/Stack.svelte";
|
|
9
9
|
export { default as Text } from "./components/text/Text.svelte";
|
|
10
10
|
export { default as Timeline } from "./components/timeline/Timeline.svelte";
|
|
11
|
-
export {} from "./data/entities";
|
|
12
|
-
export {} from "./data/entities";
|
|
13
11
|
export * from "./types";
|
|
12
|
+
export {} from "./types/paywall";
|
|
13
|
+
export {} from "./types/ui-config";
|
|
14
14
|
export {} from "./types/variables";
|
|
15
15
|
export * from "./ui/globals";
|
|
16
16
|
export { default as Button } from "./ui/molecules/button.svelte";
|
package/dist/stores/paywall.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UIConfig } from "../data/entities";
|
|
2
1
|
import type { Action } from "../types/components/button";
|
|
2
|
+
import type { UIConfig } from "../types/ui-config";
|
|
3
3
|
import type { VariableDictionary } from "../types/variables";
|
|
4
4
|
import { type Readable, type Writable } from "svelte/store";
|
|
5
5
|
type PaywallContext = Readonly<{
|