@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 Tabs from "./Tabs.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 Tabs: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Tabs = InstanceType<typeof Tabs>;
|
|
19
|
+
export default Tabs;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getColorModeContext } from "../../stores/color-mode";
|
|
3
|
+
import { getSelectedStateContext } from "../../stores/selected";
|
|
4
|
+
import type { TabsProps } from "../../types/components/tabs";
|
|
5
|
+
import { mapBackground } from "../../utils/background-utils";
|
|
6
|
+
import {
|
|
7
|
+
css,
|
|
8
|
+
mapBorder,
|
|
9
|
+
mapBorderRadius,
|
|
10
|
+
mapShadow,
|
|
11
|
+
mapSize,
|
|
12
|
+
mapSpacing,
|
|
13
|
+
} from "../../utils/base-utils";
|
|
14
|
+
import { getActiveStateProps } from "../../utils/style-utils";
|
|
15
|
+
import { derived, readable, writable } from "svelte/store";
|
|
16
|
+
import Stack from "../stack/Stack.svelte";
|
|
17
|
+
import { setTabsContext, type SelectTab } from "./tabs-context";
|
|
18
|
+
|
|
19
|
+
const props: TabsProps = $props();
|
|
20
|
+
const { control, tabs, default_tab_id } = props;
|
|
21
|
+
|
|
22
|
+
const selectedState = getSelectedStateContext();
|
|
23
|
+
const { size, padding, margin, background, shape, border, shadow } =
|
|
24
|
+
$derived.by(() => {
|
|
25
|
+
return {
|
|
26
|
+
...props,
|
|
27
|
+
...getActiveStateProps($selectedState, props.overrides),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const getColorMode = getColorModeContext();
|
|
32
|
+
const colorMode = $derived(getColorMode());
|
|
33
|
+
|
|
34
|
+
const styles = $derived(
|
|
35
|
+
css({
|
|
36
|
+
width: mapSize(size.width),
|
|
37
|
+
height: mapSize(size.height),
|
|
38
|
+
margin: mapSpacing(margin),
|
|
39
|
+
padding: mapSpacing(padding),
|
|
40
|
+
...mapBackground(colorMode, null, background),
|
|
41
|
+
border: mapBorder(colorMode, border),
|
|
42
|
+
"border-radius": mapBorderRadius(shape),
|
|
43
|
+
"box-shadow": mapShadow(colorMode, shadow),
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const tab = writable(
|
|
48
|
+
tabs.find((tab) => tab.id === default_tab_id) ?? tabs.at(0),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const selectTab: SelectTab = (tabId, tabIndex) => {
|
|
52
|
+
const nextTab = tabs.find((tab) => tab.id === tabId) ?? tabs.at(tabIndex);
|
|
53
|
+
if (nextTab !== undefined) {
|
|
54
|
+
tab.set(nextTab);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
setTabsContext({
|
|
59
|
+
control: readable(control),
|
|
60
|
+
selectedTabId: derived(tab, (tab) => tab.id),
|
|
61
|
+
selectTab,
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<div style={styles}>
|
|
66
|
+
{#if $tab !== undefined}
|
|
67
|
+
<Stack {...$tab.stack} />
|
|
68
|
+
{/if}
|
|
69
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TabControl, TabProps } from "../../types/components/tabs";
|
|
2
|
+
import type { Readable } from "svelte/store";
|
|
3
|
+
export type SelectTab = (tabId: string, tabIndex: number) => void;
|
|
4
|
+
interface TabsContext {
|
|
5
|
+
control: Readable<TabControl>;
|
|
6
|
+
selectedTabId: Readable<TabProps["id"]>;
|
|
7
|
+
selectTab: SelectTab;
|
|
8
|
+
}
|
|
9
|
+
export declare function setTabsContext(context: TabsContext): void;
|
|
10
|
+
export declare function getTabsContext(): TabsContext;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
const key = Symbol("selected");
|
|
3
|
+
export function setTabsContext(context) {
|
|
4
|
+
setContext(key, context);
|
|
5
|
+
}
|
|
6
|
+
export function getTabsContext() {
|
|
7
|
+
const context = getContext(key);
|
|
8
|
+
if (context === undefined) {
|
|
9
|
+
throw new Error("Tabs context not found");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
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<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Readable } from "svelte/store";
|
|
2
2
|
type SelectedContext = Readable<boolean>;
|
|
3
|
-
export declare function setSelectedStateContext(
|
|
3
|
+
export declare function setSelectedStateContext(context: SelectedContext): void;
|
|
4
4
|
export declare function getSelectedStateContext(): SelectedContext;
|
|
5
5
|
export {};
|
package/dist/stores/selected.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getContext, setContext } from "svelte";
|
|
2
|
-
import {
|
|
3
|
-
import { getPaywallContext } from "./paywall";
|
|
2
|
+
import { readable } from "svelte/store";
|
|
4
3
|
const key = Symbol("selected");
|
|
5
|
-
export function setSelectedStateContext(
|
|
6
|
-
|
|
7
|
-
setContext(key, derived(selectedPackageId, (value) => value === packageId));
|
|
4
|
+
export function setSelectedStateContext(context) {
|
|
5
|
+
setContext(key, context);
|
|
8
6
|
}
|
|
9
7
|
export function getSelectedStateContext() {
|
|
10
8
|
const context = getContext(key);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { PaywallData
|
|
1
|
+
import type { PaywallData } from "../types/paywall";
|
|
2
|
+
import type { UIConfig } from "../types/ui-config";
|
|
2
3
|
import type { BrandingAppearance } from "../ui/utils/branding";
|
|
3
4
|
export declare const uiConfigData: UIConfig;
|
|
4
5
|
export declare const paywallData: PaywallData;
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<div class="container" {style}>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
{#if elements > 0}
|
|
18
|
+
<div class="content">
|
|
19
|
+
{#each Array(elements) as _, index}
|
|
20
|
+
<div>Item {index + 1}</div>
|
|
21
|
+
{/each}
|
|
22
|
+
</div>
|
|
23
|
+
{/if}
|
|
22
24
|
{@render children()}
|
|
23
25
|
</div>
|
|
24
26
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { TimelineProps } from "./components/timeline";
|
|
2
|
-
import type { TextNodeProps } from "./components/text";
|
|
3
1
|
import type { ButtonProps } from "./components/button";
|
|
2
|
+
import type { CarouselProps } from "./components/carousel";
|
|
4
3
|
import type { FooterProps } from "./components/footer";
|
|
5
4
|
import type { IconProps } from "./components/icon";
|
|
6
5
|
import type { ImageProps } from "./components/image";
|
|
7
6
|
import type { PackageProps } from "./components/package";
|
|
8
7
|
import type { PurchaseButtonProps } from "./components/purchase-button";
|
|
9
8
|
import type { StackProps } from "./components/stack";
|
|
10
|
-
|
|
9
|
+
import type { TabControlButtonProps, TabControlProps, TabsProps } from "./components/tabs";
|
|
10
|
+
import type { TextNodeProps } from "./components/text";
|
|
11
|
+
import type { TimelineProps } from "./components/timeline";
|
|
12
|
+
export type Component = ButtonProps | CarouselProps | FooterProps | IconProps | ImageProps | PackageProps | PurchaseButtonProps | StackProps | TabControlButtonProps | TabControlProps | TabsProps | TextNodeProps | TimelineProps;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { BaseComponent } from "../base";
|
|
2
|
+
import type { Overrides } from "../overrides";
|
|
3
|
+
import type { SheetProps } from "./sheet";
|
|
2
4
|
import type { StackProps } from "./stack";
|
|
3
5
|
interface RestorePurchasesAction {
|
|
4
6
|
type: "restore_purchases";
|
|
@@ -13,7 +15,7 @@ interface NavigateToAction {
|
|
|
13
15
|
interface NavigateToSheetAction {
|
|
14
16
|
type: "navigate_to";
|
|
15
17
|
destination: "sheet";
|
|
16
|
-
sheet?:
|
|
18
|
+
sheet?: SheetProps | null;
|
|
17
19
|
}
|
|
18
20
|
interface NavigateToWebPurchase {
|
|
19
21
|
type: "navigate_to";
|
|
@@ -35,5 +37,6 @@ export interface ButtonProps extends BaseComponent {
|
|
|
35
37
|
action: Action;
|
|
36
38
|
stack: StackProps;
|
|
37
39
|
transition?: null;
|
|
40
|
+
overrides?: Overrides<ButtonProps>;
|
|
38
41
|
}
|
|
39
42
|
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BorderType, ShadowType, ShapeType, Spacing } from "..";
|
|
2
|
+
import type { VerticalAlignment } from "../alignment";
|
|
3
|
+
import type { Background } from "../background";
|
|
4
|
+
import type { BaseComponent } from "../base";
|
|
5
|
+
import type { ColorScheme } from "../colors";
|
|
6
|
+
import type { Overrides } from "../overrides";
|
|
7
|
+
import type { StackProps } from "./stack";
|
|
8
|
+
export interface PageControlIndicator {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
color: ColorScheme;
|
|
12
|
+
stroke_color?: ColorScheme | null;
|
|
13
|
+
stroke_width?: number | null;
|
|
14
|
+
}
|
|
15
|
+
export interface PageControl {
|
|
16
|
+
position: "top" | "bottom";
|
|
17
|
+
spacing: number;
|
|
18
|
+
margin: Spacing;
|
|
19
|
+
padding: Spacing;
|
|
20
|
+
background_color?: ColorScheme | null;
|
|
21
|
+
border?: BorderType | null;
|
|
22
|
+
shape?: ShapeType | null;
|
|
23
|
+
shadow?: ShadowType | null;
|
|
24
|
+
active: PageControlIndicator;
|
|
25
|
+
default: PageControlIndicator;
|
|
26
|
+
}
|
|
27
|
+
type AutoAdvanceTransitionType = "fade" | "slide";
|
|
28
|
+
interface AutoAdvance {
|
|
29
|
+
ms_time_per_page: number;
|
|
30
|
+
ms_transition_time: number;
|
|
31
|
+
transition_type: AutoAdvanceTransitionType;
|
|
32
|
+
}
|
|
33
|
+
export interface CarouselProps extends BaseComponent {
|
|
34
|
+
type: "carousel";
|
|
35
|
+
pages: StackProps[];
|
|
36
|
+
padding: Spacing;
|
|
37
|
+
margin: Spacing;
|
|
38
|
+
background?: Background | null;
|
|
39
|
+
shape?: ShapeType | null;
|
|
40
|
+
border?: BorderType | null;
|
|
41
|
+
shadow?: ShadowType | null;
|
|
42
|
+
page_alignment: VerticalAlignment;
|
|
43
|
+
page_spacing: number;
|
|
44
|
+
page_peek: number;
|
|
45
|
+
page_control?: PageControl | null;
|
|
46
|
+
initial_page_index: number;
|
|
47
|
+
loop: boolean;
|
|
48
|
+
auto_advance?: AutoAdvance | null;
|
|
49
|
+
overrides?: Overrides<CarouselProps>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SizeType } from "..";
|
|
2
|
+
import type { Background } from "../background";
|
|
3
|
+
import type { BaseComponent } from "../base";
|
|
4
|
+
import type { Overrides } from "../overrides";
|
|
5
|
+
import type { StackProps } from "./stack";
|
|
6
|
+
type SheetPosition = "bottom" | "top" | "center" | "left" | "right";
|
|
7
|
+
export interface SheetProps extends BaseComponent {
|
|
8
|
+
type: "sheet";
|
|
9
|
+
stack: StackProps;
|
|
10
|
+
size: SizeType;
|
|
11
|
+
background?: Background | null;
|
|
12
|
+
background_blur: boolean;
|
|
13
|
+
position?: SheetPosition;
|
|
14
|
+
overrides?: Overrides<SheetProps>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { BorderType, ShadowType, ShapeType, SizeType, Spacing } from "..";
|
|
2
|
+
import type { Background } from "../background";
|
|
3
|
+
import type { BaseComponent } from "../base";
|
|
4
|
+
import type { Overrides } from "../overrides";
|
|
5
|
+
import type { StackProps } from "./stack";
|
|
6
|
+
type TabControlType = "buttons" | "toggle";
|
|
7
|
+
export interface TabControl {
|
|
8
|
+
type: TabControlType;
|
|
9
|
+
stack: StackProps;
|
|
10
|
+
}
|
|
11
|
+
export interface TabProps extends BaseComponent {
|
|
12
|
+
type: "tab";
|
|
13
|
+
stack: StackProps;
|
|
14
|
+
overrides?: Overrides<TabProps>;
|
|
15
|
+
}
|
|
16
|
+
export interface TabsProps extends BaseComponent {
|
|
17
|
+
type: "tabs";
|
|
18
|
+
visible?: boolean | null;
|
|
19
|
+
size: SizeType;
|
|
20
|
+
padding: Spacing;
|
|
21
|
+
margin: Spacing;
|
|
22
|
+
control: TabControl;
|
|
23
|
+
tabs: TabProps[];
|
|
24
|
+
default_tab_id: string;
|
|
25
|
+
background?: Background | null;
|
|
26
|
+
shape?: ShapeType | null;
|
|
27
|
+
border?: BorderType | null;
|
|
28
|
+
shadow?: ShadowType | null;
|
|
29
|
+
overrides?: Overrides<TabsProps>;
|
|
30
|
+
}
|
|
31
|
+
export interface TabControlProps extends BaseComponent {
|
|
32
|
+
type: "tab_control";
|
|
33
|
+
overrides?: Overrides<TabControlProps>;
|
|
34
|
+
}
|
|
35
|
+
export interface TabControlButtonProps extends BaseComponent {
|
|
36
|
+
type: "tab_control_button";
|
|
37
|
+
tab_id: string;
|
|
38
|
+
stack: StackProps;
|
|
39
|
+
overrides?: Overrides<TabControlButtonProps>;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `tab_id` instead. This stores the index of the tab the control is related to,
|
|
42
|
+
* we'll utilize the `tab_id` field instead but need this for backwards compatibility
|
|
43
|
+
*/
|
|
44
|
+
tab_index: number;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Background } from "./background";
|
|
2
|
+
import type { FooterProps } from "./components/footer";
|
|
3
|
+
import type { StackProps } from "./components/stack";
|
|
4
|
+
import type { Localizations } from "./localization";
|
|
5
|
+
export interface RootPaywall {
|
|
6
|
+
background?: Background;
|
|
7
|
+
stack: StackProps;
|
|
8
|
+
sticky_footer?: FooterProps | null;
|
|
9
|
+
}
|
|
10
|
+
export interface ComponentConfig {
|
|
11
|
+
colors?: Record<string, string>;
|
|
12
|
+
fonts?: {
|
|
13
|
+
[fontName: string]: {
|
|
14
|
+
ios: string;
|
|
15
|
+
android: string;
|
|
16
|
+
web: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
asset_base_url?: string;
|
|
20
|
+
base: RootPaywall;
|
|
21
|
+
}
|
|
22
|
+
export interface PaywallData {
|
|
23
|
+
default_locale: string;
|
|
24
|
+
components_config: ComponentConfig;
|
|
25
|
+
components_localizations: Localizations;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type AppFontFamilyConfig = {
|
|
2
|
+
type: "name" | "url";
|
|
3
|
+
value?: string;
|
|
4
|
+
family: string;
|
|
5
|
+
hash: string;
|
|
6
|
+
style: string;
|
|
7
|
+
url: string;
|
|
8
|
+
weight: number;
|
|
9
|
+
};
|
|
10
|
+
type AppFontsConfig = Record<string, {
|
|
11
|
+
ios?: AppFontFamilyConfig;
|
|
12
|
+
android?: AppFontFamilyConfig;
|
|
13
|
+
web?: AppFontFamilyConfig;
|
|
14
|
+
}>;
|
|
15
|
+
export type UIConfig = {
|
|
16
|
+
app: {
|
|
17
|
+
fonts: AppFontsConfig;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -45,10 +45,14 @@ type FixedSize = {
|
|
|
45
45
|
value: number;
|
|
46
46
|
};
|
|
47
47
|
type RelativeSize = {
|
|
48
|
-
type: "
|
|
48
|
+
type: "relative";
|
|
49
|
+
value: number;
|
|
50
|
+
};
|
|
51
|
+
type FitFillSize = {
|
|
52
|
+
type: "fit" | "fill";
|
|
49
53
|
value?: null;
|
|
50
54
|
};
|
|
51
|
-
export type Size = FixedSize | RelativeSize;
|
|
55
|
+
export type Size = FixedSize | RelativeSize | FitFillSize;
|
|
52
56
|
export type SizeType = {
|
|
53
57
|
width: Size;
|
|
54
58
|
height: Size;
|
|
@@ -8,7 +8,7 @@ export declare function mapColorMode<T>(colorMode: ColorMode, value: {
|
|
|
8
8
|
light: T;
|
|
9
9
|
dark?: T | null;
|
|
10
10
|
}): T;
|
|
11
|
-
export declare function mapSize(size: Size
|
|
11
|
+
export declare function mapSize(size: Size): string;
|
|
12
12
|
export declare function mapSpacing(spacing?: Spacing | null): string;
|
|
13
13
|
export declare function mapColor(colorMode: ColorMode, scheme: ColorScheme | ColorGradientScheme | null | undefined): string;
|
|
14
14
|
export declare function mapOverlay(colorMode: ColorMode, colorOverlay: ColorGradientScheme | null | undefined): string;
|
package/dist/utils/base-utils.js
CHANGED
|
@@ -14,7 +14,7 @@ export function mapColorMode(colorMode, value) {
|
|
|
14
14
|
const result = value[colorMode];
|
|
15
15
|
return result ?? value.light;
|
|
16
16
|
}
|
|
17
|
-
export function mapSize(size
|
|
17
|
+
export function mapSize(size) {
|
|
18
18
|
switch (size.type) {
|
|
19
19
|
case "fill":
|
|
20
20
|
// Support both webkit and mozilla browsers
|
|
@@ -29,22 +29,7 @@ export function mapSize(size, deviceFrameElement) {
|
|
|
29
29
|
case "fixed":
|
|
30
30
|
return px(size.value);
|
|
31
31
|
case "relative": {
|
|
32
|
-
|
|
33
|
-
if (!deviceFrameElement) {
|
|
34
|
-
console.error("[mapSizeConstraint] Device frame element is not available");
|
|
35
|
-
return `${(size.value ?? 0) * 100}%`;
|
|
36
|
-
}
|
|
37
|
-
// getBoundingClientRect returns device pixel values that may be affected by CSS transforms
|
|
38
|
-
// due to phone preview scaling.
|
|
39
|
-
// We need to account for any scaling that may be applied to the element
|
|
40
|
-
const rect = deviceFrameElement.getBoundingClientRect();
|
|
41
|
-
const computedStyle = window.getComputedStyle(
|
|
42
|
-
// Need to go up two levels to get the transformed viewport element.
|
|
43
|
-
deviceFrameElement.parentNode?.parentNode);
|
|
44
|
-
const { transform } = computedStyle;
|
|
45
|
-
const scale = transform === "none" ? 1 : parseFloat(transform.split("(")[1]);
|
|
46
|
-
const height = rect.height / (scale || 1);
|
|
47
|
-
return px((size.value ?? 0) * height);
|
|
32
|
+
return `${size.value * 100}%`;
|
|
48
33
|
}
|
|
49
34
|
}
|
|
50
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UIConfig } from "../
|
|
1
|
+
import type { UIConfig } from "../types/ui-config";
|
|
2
2
|
export declare function isFontRCFMManaged(fontName: string): boolean;
|
|
3
3
|
export declare function getScopedFontFamily(fontFamily: string): string;
|
|
4
4
|
export declare function registerFonts(uiConfig: UIConfig): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { PaywallData } from "../data/entities.js";
|
|
2
1
|
import type { ColorGradientScheme } from "../types/colors.js";
|
|
3
2
|
import type { Component } from "../types/component.js";
|
|
4
3
|
import type { TextNodeProps } from "../types/components/text";
|
|
5
4
|
import type { Overrides } from "../types/overrides.js";
|
|
5
|
+
import type { RootPaywall } from "../types/paywall.js";
|
|
6
6
|
import { type ColorMode } from "../types.js";
|
|
7
7
|
/**
|
|
8
8
|
* Gets color value based on color mode with fallback
|
|
@@ -30,18 +30,11 @@ type TextStyleVariables = {
|
|
|
30
30
|
* @returns CSS style object with text formatting properties
|
|
31
31
|
*/
|
|
32
32
|
export declare function getTextStyles(props: TextNodeProps): TextStyleVariables;
|
|
33
|
-
/**
|
|
34
|
-
* Converts a style object to a CSS string
|
|
35
|
-
* @param styles - Object containing CSS properties and values
|
|
36
|
-
* @returns CSS string
|
|
37
|
-
*/
|
|
38
|
-
export declare function stringifyStyles(styles: Record<string, string | number>): string;
|
|
39
33
|
/**
|
|
40
34
|
* Given an instance of PaywallData, returns the id of the first package marked as `is_selected_by_default` if any.
|
|
41
35
|
* @param paywallData
|
|
42
36
|
* @returns the id of the first package marked as `is_selected_by_default` or undefined
|
|
43
37
|
*/
|
|
44
|
-
export declare function findSelectedPackageId(
|
|
38
|
+
export declare function findSelectedPackageId({ stack, sticky_footer, }: RootPaywall): string | undefined;
|
|
45
39
|
export declare const getActiveStateProps: <T extends Component>(selectedState: boolean, overrides?: Overrides<T>) => Partial<T>;
|
|
46
|
-
export declare function prefixObject(object?: Record<string, string | number>, prefix?: string): Record<string, string | number>;
|
|
47
40
|
export {};
|
|
@@ -64,22 +64,12 @@ export function getTextStyles(props) {
|
|
|
64
64
|
});
|
|
65
65
|
return styles;
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Converts a style object to a CSS string
|
|
69
|
-
* @param styles - Object containing CSS properties and values
|
|
70
|
-
* @returns CSS string
|
|
71
|
-
*/
|
|
72
|
-
export function stringifyStyles(styles) {
|
|
73
|
-
return Object.entries(styles)
|
|
74
|
-
.map(([key, value]) => `${key}: ${value}`)
|
|
75
|
-
.join("; ");
|
|
76
|
-
}
|
|
77
67
|
/**
|
|
78
68
|
* Given an instance of PaywallData, returns the id of the first package marked as `is_selected_by_default` if any.
|
|
79
69
|
* @param paywallData
|
|
80
70
|
* @returns the id of the first package marked as `is_selected_by_default` or undefined
|
|
81
71
|
*/
|
|
82
|
-
export function findSelectedPackageId(
|
|
72
|
+
export function findSelectedPackageId({ stack, sticky_footer, }) {
|
|
83
73
|
const traverseNode = (node) => {
|
|
84
74
|
if (node.type === "package" && node.is_selected_by_default) {
|
|
85
75
|
return node;
|
|
@@ -100,8 +90,12 @@ export function findSelectedPackageId(paywallData) {
|
|
|
100
90
|
}
|
|
101
91
|
return undefined;
|
|
102
92
|
};
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
const pkg = traverseNode(stack);
|
|
94
|
+
if (pkg !== undefined) {
|
|
95
|
+
return pkg?.package_id;
|
|
96
|
+
}
|
|
97
|
+
if (sticky_footer != null) {
|
|
98
|
+
const pkg = traverseNode(sticky_footer);
|
|
105
99
|
if (pkg !== undefined) {
|
|
106
100
|
return pkg?.package_id;
|
|
107
101
|
}
|
|
@@ -115,14 +109,3 @@ export const getActiveStateProps = (selectedState, overrides) => {
|
|
|
115
109
|
const override = overrides?.find((override) => override.conditions.find((condition) => condition.type === "selected"));
|
|
116
110
|
return override?.properties ?? {};
|
|
117
111
|
};
|
|
118
|
-
export function prefixObject(object, prefix) {
|
|
119
|
-
if (!object)
|
|
120
|
-
return {};
|
|
121
|
-
if (!prefix)
|
|
122
|
-
return object;
|
|
123
|
-
return Object.entries(object).reduce((acc, [key, value]) => {
|
|
124
|
-
const replacedKey = key.replace(/^--/, `${prefix}-`);
|
|
125
|
-
acc[`--${replacedKey}`] = value;
|
|
126
|
-
return acc;
|
|
127
|
-
}, {});
|
|
128
|
-
}
|