@tenthbilling/paywall 0.0.0-stage → 0.1.1

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/dist/components/Badge.d.ts +8 -0
  4. package/dist/components/Badge.js +14 -0
  5. package/dist/components/Button.d.ts +17 -0
  6. package/dist/components/Button.js +60 -0
  7. package/dist/components/Card.d.ts +13 -0
  8. package/dist/components/Card.js +29 -0
  9. package/dist/components/CloseButton.d.ts +10 -0
  10. package/dist/components/CloseButton.js +21 -0
  11. package/dist/components/ComparisonTable.d.ts +20 -0
  12. package/dist/components/ComparisonTable.js +43 -0
  13. package/dist/components/CreditPackOption.d.ts +16 -0
  14. package/dist/components/CreditPackOption.js +38 -0
  15. package/dist/components/FeatureList.d.ts +14 -0
  16. package/dist/components/FeatureList.js +15 -0
  17. package/dist/components/PaywallFooter.d.ts +17 -0
  18. package/dist/components/PaywallFooter.js +46 -0
  19. package/dist/components/PaywallOption.d.ts +26 -0
  20. package/dist/components/PaywallOption.js +41 -0
  21. package/dist/components/Radio.d.ts +8 -0
  22. package/dist/components/Radio.js +21 -0
  23. package/dist/components/RadioGroup.d.ts +23 -0
  24. package/dist/components/RadioGroup.js +42 -0
  25. package/dist/components/Text.d.ts +10 -0
  26. package/dist/components/Text.js +8 -0
  27. package/dist/components/TextField.d.ts +19 -0
  28. package/dist/components/TextField.js +38 -0
  29. package/dist/components/dimensions.d.ts +29 -0
  30. package/dist/components/dimensions.js +21 -0
  31. package/dist/components/icons.d.ts +7 -0
  32. package/dist/components/icons.js +15 -0
  33. package/dist/controller.d.ts +97 -0
  34. package/dist/controller.js +1 -0
  35. package/dist/format.d.ts +5 -0
  36. package/dist/format.js +3 -0
  37. package/dist/index.d.ts +28 -0
  38. package/dist/index.js +26 -0
  39. package/dist/paywall/PaywallScaffold.d.ts +52 -0
  40. package/dist/paywall/PaywallScaffold.js +42 -0
  41. package/dist/paywall/PaywallView.d.ts +38 -0
  42. package/dist/paywall/PaywallView.js +219 -0
  43. package/dist/paywall/copy.d.ts +36 -0
  44. package/dist/paywall/copy.js +90 -0
  45. package/dist/paywall/price.d.ts +38 -0
  46. package/dist/paywall/price.js +124 -0
  47. package/dist/paywall/selection.d.ts +17 -0
  48. package/dist/paywall/selection.js +13 -0
  49. package/dist/paywall/slots.d.ts +46 -0
  50. package/dist/paywall/slots.js +1 -0
  51. package/dist/paywall/strings.d.ts +13 -0
  52. package/dist/paywall/strings.js +10 -0
  53. package/dist/paywall/templates.d.ts +31 -0
  54. package/dist/paywall/templates.js +60 -0
  55. package/dist/paywall/theme.d.ts +41 -0
  56. package/dist/paywall/theme.js +104 -0
  57. package/dist/paywall/url.d.ts +22 -0
  58. package/dist/paywall/url.js +48 -0
  59. package/dist/schema/config.d.ts +264 -0
  60. package/dist/schema/config.js +149 -0
  61. package/dist/schema/defaults.d.ts +2 -0
  62. package/dist/schema/defaults.js +20 -0
  63. package/dist/schema/index.d.ts +2 -0
  64. package/dist/schema/index.js +2 -0
  65. package/dist/theme.d.ts +14 -0
  66. package/dist/theme.js +14 -0
  67. package/package.json +66 -3
@@ -0,0 +1,19 @@
1
+ export interface TextFieldProps {
2
+ /** Stable id; links the label and help text for assistive tech. */
3
+ id: string;
4
+ label: string;
5
+ value: string;
6
+ onChange: (value: string) => void;
7
+ /** Validate on blur, never on every keystroke. */
8
+ onBlur?: () => void;
9
+ help?: string;
10
+ /** A full sentence explaining the fix. Switches the field to its error state. */
11
+ error?: string | null;
12
+ /** Bundle ids, package names and keys use the identifier style. */
13
+ identifier?: boolean;
14
+ type?: 'text' | 'email' | 'url';
15
+ autoFocus?: boolean;
16
+ onSubmitEditing?: () => void;
17
+ }
18
+ /** Design system "TextField": label above, help or error below, line-strong border, 40px. */
19
+ export declare function TextField({ id, label, value, onChange, onBlur, help, error, identifier, type, autoFocus, onSubmitEditing, }: TextFieldProps): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { TextInput, View } from 'react-native';
4
+ import { useTheme } from '../theme';
5
+ import { Text } from './Text';
6
+ const KEYBOARD = {
7
+ text: 'default',
8
+ email: 'email-address',
9
+ url: 'url',
10
+ };
11
+ export function TextField({ id, label, value, onChange, onBlur, help, error, identifier, type = 'text', autoFocus, onSubmitEditing, }) {
12
+ const { colors, space, radius, typography } = useTheme();
13
+ const [focused, setFocused] = useState(false);
14
+ const message = error ?? help;
15
+ return (_jsxs(View, { style: { gap: space[1] }, children: [_jsx(Text, { variant: "label", nativeID: `${id}-label`, children: label }), _jsx(TextInput, { nativeID: id, accessibilityLabel: label, "aria-labelledby": `${id}-label`, "aria-describedby": message ? `${id}-help` : undefined, "aria-invalid": !!error, value: value, onChangeText: onChange, onFocus: () => setFocused(true), onBlur: () => {
16
+ setFocused(false);
17
+ onBlur?.();
18
+ }, onSubmitEditing: onSubmitEditing, autoFocus: autoFocus, autoCapitalize: type === 'text' && !identifier ? 'sentences' : 'none', autoCorrect: !identifier && type === 'text', keyboardType: KEYBOARD[type], placeholderTextColor: colors.inkMuted, style: [
19
+ identifier ? typography.identifier : typography.body,
20
+ {
21
+ height: 40,
22
+ paddingHorizontal: space[3],
23
+ borderRadius: radius.md,
24
+ borderWidth: 1,
25
+ borderColor: error ? colors.danger : colors.lineStrong,
26
+ backgroundColor: colors.surfaceRaised,
27
+ color: colors.ink,
28
+ },
29
+ focused
30
+ ? {
31
+ outlineStyle: 'solid',
32
+ outlineWidth: 2,
33
+ outlineColor: colors.focus,
34
+ outlineOffset: 2,
35
+ }
36
+ : null,
37
+ ] }), message ? (_jsx(Text, { variant: "bodySm", color: error ? 'danger' : 'inkMuted', nativeID: `${id}-help`, children: message })) : null] }));
38
+ }
@@ -0,0 +1,29 @@
1
+ /** "Accessibility": touch targets are at least 44 × 44px on phones. */
2
+ export declare const MIN_TOUCH_TARGET = 44;
3
+ /** "Color" / "Borders, radii and shadows": surfaces and controls take a 1px border. */
4
+ export declare const BORDER_WIDTH = 1;
5
+ /** "PaywallOption" / "The paywall": the selected option gets a 2px brand border. */
6
+ export declare const SELECTED_BORDER_WIDTH = 2;
7
+ /** "Iconography": Lucide at 16px in tables and controls. */
8
+ export declare const ICON_SIZE = 16;
9
+ /** "Iconography": Lucide at 20px in navigation (the paywall's close button dismisses it). */
10
+ export declare const NAV_ICON_SIZE = 20;
11
+ /** "Iconography": 1.75px stroke. */
12
+ export declare const ICON_STROKE = 1.75;
13
+ /** "The paywall": a centered card up to 440px on web. */
14
+ export declare const SHEET_MAX_WIDTH = 440;
15
+ /** "Motion": the paywall sheet slides up over 240ms on phones. */
16
+ export declare const SHEET_DURATION_MS = 240;
17
+ /**
18
+ * Radio (design addition, docs/design-additions.md): a 20px ring, the 16px control icon size plus
19
+ * the 2px selected border on each side, with a 10px dot when selected.
20
+ */
21
+ export declare const RADIO_SIZE = 20;
22
+ export declare const RADIO_DOT_SIZE = 10;
23
+ /** "States and focus": a 2px solid `focus` ring with a 2px offset on keyboard focus. */
24
+ export declare const FOCUS_RING_WIDTH = 2;
25
+ export declare const FOCUS_RING_OFFSET = 2;
26
+ /** The keyboard focus ring (web; React Native Web supports outline styles). */
27
+ export declare function focusRing(focusColor: string): object;
28
+ /** "States and focus": disabled controls drop to 45% opacity and keep their layout. */
29
+ export declare const DISABLED_OPACITY = 0.45;
@@ -0,0 +1,21 @@
1
+ export const MIN_TOUCH_TARGET = 44;
2
+ export const BORDER_WIDTH = 1;
3
+ export const SELECTED_BORDER_WIDTH = 2;
4
+ export const ICON_SIZE = 16;
5
+ export const NAV_ICON_SIZE = 20;
6
+ export const ICON_STROKE = 1.75;
7
+ export const SHEET_MAX_WIDTH = 440;
8
+ export const SHEET_DURATION_MS = 240;
9
+ export const RADIO_SIZE = 20;
10
+ export const RADIO_DOT_SIZE = 10;
11
+ export const FOCUS_RING_WIDTH = 2;
12
+ export const FOCUS_RING_OFFSET = 2;
13
+ export function focusRing(focusColor) {
14
+ return {
15
+ outlineStyle: 'solid',
16
+ outlineWidth: FOCUS_RING_WIDTH,
17
+ outlineColor: focusColor,
18
+ outlineOffset: FOCUS_RING_OFFSET,
19
+ };
20
+ }
21
+ export const DISABLED_OPACITY = 0.45;
@@ -0,0 +1,7 @@
1
+ import { type LucideIcon } from 'lucide-react-native';
2
+ import type { FeatureIcon } from '../schema/config';
3
+ /**
4
+ * Lucide components for the icons a config may name (`FEATURE_ICONS`). A fixed map, so a config
5
+ * can only pick from this list; it can't name an arbitrary component.
6
+ */
7
+ export declare const FEATURE_ICON_COMPONENTS: Readonly<Record<FeatureIcon, LucideIcon>>;
@@ -0,0 +1,15 @@
1
+ import { CheckIcon, ClockIcon, CloudIcon, DownloadIcon, GiftIcon, InfinityIcon, LockOpenIcon, ShieldCheckIcon, SparklesIcon, StarIcon, UsersIcon, ZapIcon, } from 'lucide-react-native';
2
+ export const FEATURE_ICON_COMPONENTS = {
3
+ check: CheckIcon,
4
+ sparkles: SparklesIcon,
5
+ zap: ZapIcon,
6
+ 'shield-check': ShieldCheckIcon,
7
+ cloud: CloudIcon,
8
+ download: DownloadIcon,
9
+ infinity: InfinityIcon,
10
+ 'lock-open': LockOpenIcon,
11
+ star: StarIcon,
12
+ users: UsersIcon,
13
+ clock: ClockIcon,
14
+ gift: GiftIcon,
15
+ };
@@ -0,0 +1,97 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { PaywallConfig } from './schema/config';
3
+ export type PeriodUnit = 'day' | 'week' | 'month' | 'year';
4
+ export interface Period {
5
+ unit: PeriodUnit;
6
+ count: number;
7
+ }
8
+ /** A price as the store or Stripe reported it at runtime. Never from remote config. */
9
+ export interface DisplayPrice {
10
+ /** The store's own localized string, such as "$59.99" or "59,99 €". Shown as is. */
11
+ formatted: string;
12
+ /** Exact amount in millionths of the currency unit (Play's micros; StoreKit's Decimal × 10⁶). */
13
+ amountMicros: bigint;
14
+ /** ISO 4217 code. */
15
+ currency: string;
16
+ }
17
+ export interface IntroOffer {
18
+ kind: 'free_trial' | 'pay_as_you_go' | 'pay_up_front';
19
+ period: Period;
20
+ /** Number of periods the offer lasts (1 for a free trial). */
21
+ periods: number;
22
+ /** Null for a free trial. */
23
+ price: DisplayPrice | null;
24
+ }
25
+ export interface PaywallProduct {
26
+ /** Catalog key. */
27
+ key: string;
28
+ type: 'subscription' | 'non_consumable' | 'consumable';
29
+ /** Name to show: the offering's label, else the catalog display name, else the store's name. */
30
+ name: string;
31
+ /** The offering's badge for this product ("Best value"), if any. */
32
+ badge: string | null;
33
+ /** The offering's highlighted product: selected when the paywall opens. */
34
+ highlighted: boolean;
35
+ price: DisplayPrice;
36
+ /** Billing period for subscriptions; null for one-time purchases. */
37
+ period: Period | null;
38
+ /** The introductory offer this customer is eligible for, if any. */
39
+ intro: IntroOffer | null;
40
+ /** Credits granted, for credit packs. */
41
+ credits: {
42
+ creditType: string;
43
+ amount: number;
44
+ per: 'purchase' | 'period';
45
+ }[];
46
+ entitlements: string[];
47
+ }
48
+ export type PurchaseResult = {
49
+ status: 'purchased';
50
+ }
51
+ /** Paid, but access hasn't appeared within the polling window, or the store is deferring it. */
52
+ | {
53
+ status: 'pending';
54
+ } | {
55
+ status: 'cancelled';
56
+ } | {
57
+ status: 'failed';
58
+ error: PaywallError;
59
+ };
60
+ export interface RestoreResult {
61
+ status: 'restored' | 'nothing_to_restore' | 'failed';
62
+ error?: PaywallError;
63
+ }
64
+ export interface PaywallError {
65
+ /** Tenth's stable error code, or an SDK code such as `store_unavailable`. */
66
+ code: string;
67
+ /** A full sentence for the customer: what went wrong and what to do. */
68
+ message: string;
69
+ }
70
+ export interface PaywallController {
71
+ status: 'loading' | 'ready' | 'empty' | 'error';
72
+ error: PaywallError | null;
73
+ /** The config to render: the published one, or the bundled default. */
74
+ config: PaywallConfig;
75
+ /** Asset id → URL (on Tenth's API origin). */
76
+ assets: Readonly<Record<string, string>>;
77
+ products: readonly PaywallProduct[];
78
+ selectedKey: string | null;
79
+ select(key: string): void;
80
+ /** Buys the selected product (or `key`). Resolves when it's done; never throws. */
81
+ purchase(key?: string): Promise<PurchaseResult>;
82
+ restore(): Promise<RestoreResult>;
83
+ purchasing: boolean;
84
+ restoring: boolean;
85
+ /**
86
+ * An embedded payment step to show in place of the product list, such as Stripe's Payment
87
+ * Element on web. Set by the driver after `purchase()` starts; null otherwise.
88
+ */
89
+ paymentStep: ReactNode | null;
90
+ /** Leaves the payment step and returns to the product list. */
91
+ cancelPaymentStep(): void;
92
+ /** Preview mode (Expo Go, or no native store): purchases are simulated on the device only. */
93
+ preview: boolean;
94
+ environment: 'test' | 'live';
95
+ /** The locale to pick copy for, such as `en-US`. */
96
+ locale: string;
97
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Truncates a long identifier in the middle (design system "Type"): `tenth_live_pk_8Kd2…f9Qa`.
3
+ * Show the full value on hover and copy.
4
+ */
5
+ export declare function formatIdentifier(value: string, head?: number, tail?: number): string;
package/dist/format.js ADDED
@@ -0,0 +1,3 @@
1
+ export function formatIdentifier(value, head = 18, tail = 4) {
2
+ return value.length <= head + tail + 1 ? value : `${value.slice(0, head)}…${value.slice(-tail)}`;
3
+ }
@@ -0,0 +1,28 @@
1
+ export { ThemeProvider, useTheme, type ThemePreference } from './theme';
2
+ export { Text, type TextProps } from './components/Text';
3
+ export { Button, type ButtonProps, type ButtonVariant, type ButtonSize } from './components/Button';
4
+ export { TextField, type TextFieldProps } from './components/TextField';
5
+ export { Card, Banner } from './components/Card';
6
+ export { formatIdentifier } from './format';
7
+ export { Badge } from './components/Badge';
8
+ export { Radio } from './components/Radio';
9
+ export { RadioGroup, useRadioGroup, type RadioItemProps } from './components/RadioGroup';
10
+ export { PaywallOption, paywallOptionStyle, type PaywallOptionProps, } from './components/PaywallOption';
11
+ export { CreditPackOption, type CreditPackOptionProps } from './components/CreditPackOption';
12
+ export { ComparisonTable, type ComparisonRow, type ComparisonTableProps, } from './components/ComparisonTable';
13
+ export { FeatureList, type FeatureListProps, type PaywallFeature } from './components/FeatureList';
14
+ export { FEATURE_ICON_COMPONENTS } from './components/icons';
15
+ export { CloseButton, type CloseButtonProps } from './components/CloseButton';
16
+ export { PaywallFooter, openLegalUrl, type PaywallFooterProps } from './components/PaywallFooter';
17
+ export { PaywallView, type PaywallViewProps, type PaywallPresentation, } from './paywall/PaywallView';
18
+ export { PaywallScaffold, EnvironmentBanner, type PaywallTemplateProps, type PaywallNotice, } from './paywall/PaywallScaffold';
19
+ export { HeroTemplate, TiersTemplate, ComparisonTemplate, CreditsTemplate, PAYWALL_TEMPLATES, visibleProducts, } from './paywall/templates';
20
+ export type { PaywallSlots, PaywallHeaderSlotProps, PaywallProductCardSlotProps, PaywallFeatureListSlotProps, PaywallFooterSlotProps, PaywallCloseButtonSlotProps, } from './paywall/slots';
21
+ export { resolveCopy, ctaLabel, optionDetail, optionPrice } from './paywall/copy';
22
+ export { safeLocale, currencyDigits, formatMicros, monthsIn, perMonthMicros, perMonthLabel, periodLabel, priceWithPeriod, durationAdjective, durationPhrase, formatCount, creditsLabel, } from './paywall/price';
23
+ export { resolvePaywallTheme, resolveColorScheme, deriveBrandHover, mixHex, type ResolvedPaywallTheme, type PaywallThemeOverrides, } from './paywall/theme';
24
+ export { defaultProductKey, selectedProduct, badgedProductKey } from './paywall/selection';
25
+ export { safeHttpsUrl, safeBlobUrl, assetUrl, previewAssetUrl, type PaywallAssetResolver, } from './paywall/url';
26
+ export * from './paywall/strings';
27
+ export type { PaywallController, PaywallProduct, DisplayPrice, IntroOffer, Period, PeriodUnit, PurchaseResult, RestoreResult, PaywallError, } from './controller';
28
+ export { parseServedPaywall, validatePaywallConfig, defaultPaywallConfig, PAYWALL_SCHEMA_VERSION, TEMPLATES, FEATURE_ICONS, type PaywallConfig, type PaywallTemplate, type PaywallTheme, type PaywallCopy, type PaywallLocalizedCopy, type PaywallLayout, type ServedPaywall, type FeatureIcon, } from './schema';
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ export { ThemeProvider, useTheme } from './theme';
2
+ export { Text } from './components/Text';
3
+ export { Button } from './components/Button';
4
+ export { TextField } from './components/TextField';
5
+ export { Card, Banner } from './components/Card';
6
+ export { formatIdentifier } from './format';
7
+ export { Badge } from './components/Badge';
8
+ export { Radio } from './components/Radio';
9
+ export { RadioGroup, useRadioGroup } from './components/RadioGroup';
10
+ export { PaywallOption, paywallOptionStyle, } from './components/PaywallOption';
11
+ export { CreditPackOption } from './components/CreditPackOption';
12
+ export { ComparisonTable, } from './components/ComparisonTable';
13
+ export { FeatureList } from './components/FeatureList';
14
+ export { FEATURE_ICON_COMPONENTS } from './components/icons';
15
+ export { CloseButton } from './components/CloseButton';
16
+ export { PaywallFooter, openLegalUrl } from './components/PaywallFooter';
17
+ export { PaywallView, } from './paywall/PaywallView';
18
+ export { PaywallScaffold, EnvironmentBanner, } from './paywall/PaywallScaffold';
19
+ export { HeroTemplate, TiersTemplate, ComparisonTemplate, CreditsTemplate, PAYWALL_TEMPLATES, visibleProducts, } from './paywall/templates';
20
+ export { resolveCopy, ctaLabel, optionDetail, optionPrice } from './paywall/copy';
21
+ export { safeLocale, currencyDigits, formatMicros, monthsIn, perMonthMicros, perMonthLabel, periodLabel, priceWithPeriod, durationAdjective, durationPhrase, formatCount, creditsLabel, } from './paywall/price';
22
+ export { resolvePaywallTheme, resolveColorScheme, deriveBrandHover, mixHex, } from './paywall/theme';
23
+ export { defaultProductKey, selectedProduct, badgedProductKey } from './paywall/selection';
24
+ export { safeHttpsUrl, safeBlobUrl, assetUrl, previewAssetUrl, } from './paywall/url';
25
+ export * from './paywall/strings';
26
+ export { parseServedPaywall, validatePaywallConfig, defaultPaywallConfig, PAYWALL_SCHEMA_VERSION, TEMPLATES, FEATURE_ICONS, } from './schema';
@@ -0,0 +1,52 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { PaywallController, PaywallProduct } from '../controller';
3
+ import type { PaywallLocalizedCopy } from '../schema/config';
4
+ import type { PaywallSlots } from './slots';
5
+ import { type PaywallAssetResolver } from './url';
6
+ /** A sentence shown above the purchase button after a purchase or restore. */
7
+ export interface PaywallNotice {
8
+ kind: 'info' | 'warning' | 'danger' | 'success';
9
+ message: string;
10
+ }
11
+ /** What every template receives from `<PaywallView>`. */
12
+ export interface PaywallTemplateProps {
13
+ controller: PaywallController;
14
+ /** The copy for the paywall's locale (`resolveCopy`). */
15
+ copy: PaywallLocalizedCopy;
16
+ /** A locale Intl accepts (`safeLocale`). */
17
+ locale: string;
18
+ /** The products this template shows (`visibleProducts`). */
19
+ products: readonly PaywallProduct[];
20
+ /** The selected product; exactly one whenever there are products. */
21
+ selected: PaywallProduct | null;
22
+ select: (key: string) => void;
23
+ slots?: PaywallSlots;
24
+ onPurchase: () => void;
25
+ /** Null when the config hides Restore purchases. */
26
+ onRestore: (() => void) | null;
27
+ /** Null when there's no close button. */
28
+ onClose: (() => void) | null;
29
+ notice: PaywallNotice | null;
30
+ /** Editor preview only: URLs for images not in `controller.assets` (see PaywallViewProps). */
31
+ previewAssets?: PaywallAssetResolver;
32
+ }
33
+ /** Banners for preview mode and test mode (design system "States and focus"). */
34
+ export declare function EnvironmentBanner({ controller }: {
35
+ controller: PaywallController;
36
+ }): import("react").JSX.Element | null;
37
+ /** The close button row, or the `closeButton` slot. */
38
+ export declare function CloseRow({ onClose, slots, }: {
39
+ onClose: (() => void) | null;
40
+ slots?: PaywallSlots;
41
+ }): import("react").JSX.Element | null;
42
+ /**
43
+ * The layout every template shares (design system "The paywall"): title in `display`, one line
44
+ * of `body`, the template's products, one full-width primary `Button` naming the action, then
45
+ * Restore purchases and legal links in `body-sm` `ink-muted`. While `controller.paymentStep` is
46
+ * set (Stripe's Payment Element on web) it replaces the products and the button,
47
+ * with a "Back" ghost button that calls `cancelPaymentStep`.
48
+ */
49
+ export declare function PaywallScaffold({ controller, copy, locale, selected, slots, onPurchase, onRestore, onClose, notice, previewAssets, showHeroImage, children, }: PaywallTemplateProps & {
50
+ showHeroImage?: boolean;
51
+ children: ReactNode;
52
+ }): import("react").JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Image, View } from 'react-native';
3
+ import { Button } from '../components/Button';
4
+ import { Banner } from '../components/Card';
5
+ import { CloseButton } from '../components/CloseButton';
6
+ import { FeatureList } from '../components/FeatureList';
7
+ import { PaywallFooter } from '../components/PaywallFooter';
8
+ import { Text } from '../components/Text';
9
+ import { useTheme } from '../theme';
10
+ import { ctaLabel } from './copy';
11
+ import { PREVIEW_MESSAGE, TEST_MODE_MESSAGE } from './strings';
12
+ import { assetUrl, previewAssetUrl, safeHttpsUrl } from './url';
13
+ export function EnvironmentBanner({ controller }) {
14
+ if (controller.preview)
15
+ return _jsx(Banner, { kind: "info", children: PREVIEW_MESSAGE });
16
+ if (controller.environment === 'test')
17
+ return _jsx(Banner, { kind: "info", children: TEST_MODE_MESSAGE });
18
+ return null;
19
+ }
20
+ export function CloseRow({ onClose, slots, }) {
21
+ if (!onClose)
22
+ return null;
23
+ const Slot = slots?.closeButton;
24
+ return (_jsx(View, { style: { flexDirection: 'row', justifyContent: 'flex-end' }, children: Slot ? _jsx(Slot, { close: onClose }) : _jsx(CloseButton, { onPress: onClose }) }));
25
+ }
26
+ export function PaywallScaffold({ controller, copy, locale, selected, slots, onPurchase, onRestore, onClose, notice, previewAssets, showHeroImage = false, children, }) {
27
+ const { space, radius } = useTheme();
28
+ const heroImage = controller.config.layout.hero_image;
29
+ const heroImageUrl = showHeroImage
30
+ ? ((previewAssets ? previewAssetUrl(previewAssets, heroImage) : null) ??
31
+ assetUrl(controller.assets, heroImage))
32
+ : null;
33
+ const subtitle = copy.subtitle ?? null;
34
+ const features = copy.features ?? [];
35
+ const termsUrl = safeHttpsUrl(controller.config.layout.terms_url);
36
+ const privacyUrl = safeHttpsUrl(controller.config.layout.privacy_url);
37
+ const busy = controller.purchasing || controller.restoring;
38
+ const Header = slots?.header;
39
+ const Features = slots?.featureList;
40
+ const Footer = slots?.footer;
41
+ return (_jsxs(View, { style: { gap: space[5] }, children: [_jsxs(View, { style: { gap: space[3] }, children: [_jsx(CloseRow, { onClose: onClose, slots: slots }), _jsx(EnvironmentBanner, { controller: controller })] }), Header ? (_jsx(Header, { title: copy.title, subtitle: subtitle, heroImageUrl: heroImageUrl })) : (_jsxs(View, { style: { gap: space[2] }, children: [heroImageUrl ? (_jsx(Image, { source: { uri: heroImageUrl }, testID: "paywall-hero-image", accessible: false, "aria-hidden": true, resizeMode: "cover", style: { width: '100%', aspectRatio: 16 / 9, borderRadius: radius.lg } })) : null, _jsx(Text, { variant: "display", accessibilityRole: "header", children: copy.title }), subtitle ? _jsx(Text, { variant: "body", children: subtitle }) : null] })), Features ? _jsx(Features, { features: features }) : _jsx(FeatureList, { features: features }), controller.paymentStep ? (_jsxs(View, { style: { gap: space[4] }, children: [controller.paymentStep, _jsx(Button, { label: "Back", variant: "ghost", onPress: () => controller.cancelPaymentStep() })] })) : (_jsxs(View, { style: { gap: space[4] }, children: [children, notice ? _jsx(Banner, { kind: notice.kind, children: notice.message }) : null, _jsxs(View, { style: { gap: space[2] }, children: [_jsx(Button, { label: ctaLabel(selected, { override: copy.cta, locale }), variant: "primary", size: "block", onPress: onPurchase, disabled: !selected || busy, loading: controller.purchasing }), copy.footnote ? (_jsx(Text, { variant: "bodySm", color: "inkMuted", style: { textAlign: 'center' }, children: copy.footnote })) : null] })] })), Footer ? (_jsx(Footer, { restore: onRestore, restoring: controller.restoring, termsUrl: termsUrl, privacyUrl: privacyUrl })) : (_jsx(PaywallFooter, { onRestore: onRestore, restoring: controller.restoring, disabled: controller.purchasing, termsUrl: termsUrl, privacyUrl: privacyUrl }))] }));
42
+ }
@@ -0,0 +1,38 @@
1
+ import type { PaywallController, PaywallProduct } from '../controller';
2
+ import type { PaywallSlots } from './slots';
3
+ import type { PaywallAssetResolver } from './url';
4
+ import { type PaywallThemeOverrides } from './theme';
5
+ export type PaywallPresentation = 'modal' | 'sheet' | 'inline';
6
+ export interface PaywallViewProps {
7
+ controller: PaywallController;
8
+ /**
9
+ * `inline` (default) renders in place. `sheet` slides a `surface-raised` sheet up from the
10
+ * bottom on phones (a centered card up to 440px on web). `modal` uses React Native's Modal.
11
+ */
12
+ presentation?: PaywallPresentation;
13
+ /** Replace regions of the paywall. See `PaywallSlots`. */
14
+ slots?: PaywallSlots;
15
+ /** Developer theme overrides; they win over the remote config's theme. */
16
+ theme?: PaywallThemeOverrides;
17
+ /** Overrides `controller.locale` for picking copy and formatting. */
18
+ locale?: string;
19
+ /**
20
+ * Called when the customer closes the paywall. For `inline`, the close button shows only when
21
+ * this is given (and the config doesn't hide it); `modal` and `sheet` always have one.
22
+ */
23
+ onDismiss?: () => void;
24
+ /** Called after a completed purchase, with the product bought. */
25
+ onPurchased?: (product: PaywallProduct) => void;
26
+ /**
27
+ * Editor preview only. Draft images aren't public, so the dashboard fetches them with
28
+ * its session and supplies object URLs here. Only https and page-created `blob:` URLs are used;
29
+ * anything else falls back to `controller.assets`. Apps never need this.
30
+ */
31
+ previewAssets?: PaywallAssetResolver;
32
+ }
33
+ /**
34
+ * The paywall: renders `controller.config` with the
35
+ * template it names, themed with the tenant's overrides, in the customer's locale. All store
36
+ * work goes through `controller`; this component has no network or store access of its own.
37
+ */
38
+ export declare function PaywallView({ controller, presentation, slots, theme: themeOverrides, locale: localeProp, onDismiss, onPurchased, previewAssets, }: PaywallViewProps): import("react").JSX.Element;