@tenthbilling/paywall 0.0.0-stage → 0.1.0

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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Apps LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # @tenthbilling/paywall
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The paywall renderer, templates and remote-config schema behind `<Paywall />` in `@tenthbilling/expo`. The Expo SDK installs it and re-exports what apps need (`PaywallView`, `PaywallOption`, slot and theme types), so import from `@tenthbilling/expo` rather than from here.
4
+
5
+ The optional peers (`react`, `react-native`, `lucide-react-native`, `react-native-svg`) are needed to render; `@tenthbilling/paywall/schema` works without them.
6
+
7
+ Docs: https://tenthbilling.com/docs/expo
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The paywall's one badge ("Best value", "Save 29%"): a `stamp` fill with `on-stamp` text
3
+ * (design system "PaywallOption"). It's the screen's single stamp element, so render at most one.
4
+ * `label` style, `radius-sm`, pill padding (`space-1` block, `space-2` inline).
5
+ */
6
+ export declare function Badge({ label }: {
7
+ label: string;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useTheme } from '../theme';
4
+ import { Text } from './Text';
5
+ export function Badge({ label }) {
6
+ const { colors, space, radius } = useTheme();
7
+ return (_jsx(View, { style: {
8
+ alignSelf: 'flex-start',
9
+ backgroundColor: colors.stamp,
10
+ borderRadius: radius.sm,
11
+ paddingVertical: space[1],
12
+ paddingHorizontal: space[2],
13
+ }, children: _jsx(Text, { variant: "label", color: "onStamp", numberOfLines: 1, children: label }) }));
14
+ }
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from 'react';
2
+ export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
3
+ export type ButtonSize = 'default' | 'sm' | 'block';
4
+ export interface ButtonProps {
5
+ /** Sentence case, names the action ("Create API key"), no trailing punctuation. */
6
+ label: string;
7
+ onPress: () => void;
8
+ variant?: ButtonVariant;
9
+ size?: ButtonSize;
10
+ disabled?: boolean;
11
+ loading?: boolean;
12
+ /** Optional leading Lucide icon at 16px. */
13
+ icon?: ReactNode;
14
+ accessibilityHint?: string;
15
+ }
16
+ /** Design system "Button": primary, secondary, ghost and danger; default, sm and block sizes. */
17
+ export declare function Button({ label, onPress, variant, size, disabled, loading, icon, accessibilityHint, }: ButtonProps): import("react").JSX.Element;
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ActivityIndicator, Pressable, View, } from 'react-native';
3
+ import { useTheme } from '../theme';
4
+ import { Text } from './Text';
5
+ const HEIGHT = { default: 40, sm: 32, block: 48 };
6
+ export function Button({ label, onPress, variant = 'secondary', size = 'default', disabled, loading, icon, accessibilityHint, }) {
7
+ const { colors, space, radius, typography } = useTheme();
8
+ const inactive = disabled || loading;
9
+ const style = (state) => {
10
+ const { pressed, hovered, focused } = state;
11
+ const active = (pressed || hovered) && !inactive;
12
+ const base = {
13
+ height: HEIGHT[size],
14
+ paddingHorizontal: size === 'sm' ? space[3] : space[4],
15
+ borderRadius: radius.md,
16
+ flexDirection: 'row',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ gap: space[2],
20
+ borderWidth: 1,
21
+ alignSelf: size === 'block' ? 'stretch' : 'flex-start',
22
+ opacity: disabled ? 0.45 : 1,
23
+ };
24
+ const byVariant = {
25
+ primary: {
26
+ backgroundColor: active ? colors.brandHover : colors.brand,
27
+ borderColor: active ? colors.brandHover : colors.brand,
28
+ },
29
+ secondary: {
30
+ backgroundColor: active ? colors.surfaceSunken : colors.surfaceRaised,
31
+ borderColor: colors.lineStrong,
32
+ },
33
+ ghost: {
34
+ backgroundColor: active ? colors.surfaceSunken : 'transparent',
35
+ borderColor: 'transparent',
36
+ },
37
+ danger: {
38
+ backgroundColor: active ? colors.dangerTint : colors.surfaceRaised,
39
+ borderColor: colors.danger,
40
+ },
41
+ };
42
+ const focusRing = focused
43
+ ? {
44
+ outlineStyle: 'solid',
45
+ outlineWidth: 2,
46
+ outlineColor: colors.focus,
47
+ outlineOffset: 2,
48
+ }
49
+ : {};
50
+ return [base, byVariant[variant], focusRing];
51
+ };
52
+ const textColor = variant === 'primary'
53
+ ? 'onBrand'
54
+ : variant === 'danger'
55
+ ? 'danger'
56
+ : variant === 'ghost'
57
+ ? 'brand'
58
+ : 'ink';
59
+ return (_jsxs(Pressable, { accessibilityRole: "button", accessibilityState: { disabled: !!inactive, busy: !!loading }, accessibilityHint: accessibilityHint, disabled: inactive, onPress: onPress, style: style, children: [loading ? (_jsx(ActivityIndicator, { size: "small", color: colors[textColor] })) : icon ? (_jsx(View, { children: icon })) : null, _jsx(Text, { variant: "body", color: textColor, style: { fontFamily: typography.label.fontFamily }, children: label })] }));
60
+ }
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type ViewStyle } from 'react-native';
3
+ /** surface-raised card with a 1px line border and radius-lg; space-5 padding (space-4 on phones). */
4
+ export declare function Card({ title, children, style, }: {
5
+ title?: string;
6
+ children: ReactNode;
7
+ style?: ViewStyle;
8
+ }): import("react").JSX.Element;
9
+ /** Full-width banner for notices; the test-mode banner uses kind="info". */
10
+ export declare function Banner({ kind, children, }: {
11
+ kind: 'info' | 'warning' | 'danger' | 'success';
12
+ children: ReactNode;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View, useWindowDimensions } from 'react-native';
3
+ import { useTheme } from '../theme';
4
+ import { Text } from './Text';
5
+ export function Card({ title, children, style, }) {
6
+ const { colors, space, radius } = useTheme();
7
+ const { width } = useWindowDimensions();
8
+ return (_jsxs(View, { style: [
9
+ {
10
+ backgroundColor: colors.surfaceRaised,
11
+ borderColor: colors.line,
12
+ borderWidth: 1,
13
+ borderRadius: radius.lg,
14
+ padding: width < 640 ? space[4] : space[5],
15
+ gap: space[4],
16
+ },
17
+ style,
18
+ ], children: [title ? (_jsx(Text, { variant: "heading2", accessibilityRole: "header", children: title })) : null, children] }));
19
+ }
20
+ export function Banner({ kind, children, }) {
21
+ const { colors, space, radius } = useTheme();
22
+ const tint = {
23
+ info: colors.infoTint,
24
+ warning: colors.warningTint,
25
+ danger: colors.dangerTint,
26
+ success: colors.successTint,
27
+ }[kind];
28
+ return (_jsx(View, { accessibilityRole: "alert", style: { backgroundColor: tint, padding: space[3], borderRadius: radius.md }, children: _jsx(Text, { variant: "bodySm", color: kind, children: children }) }));
29
+ }
@@ -0,0 +1,10 @@
1
+ export interface CloseButtonProps {
2
+ onPress: () => void;
3
+ /** Accessible name. Defaults to "Close". */
4
+ label?: string;
5
+ }
6
+ /**
7
+ * Dismisses the paywall (design addition): a Lucide X at 20px in `ink-muted` inside a 44 × 44
8
+ * target, `surface-sunken` on hover and press like a ghost button, focus ring on keyboard focus.
9
+ */
10
+ export declare function CloseButton({ onPress, label }: CloseButtonProps): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { XIcon } from 'lucide-react-native';
3
+ import { Pressable } from 'react-native';
4
+ import { useTheme } from '../theme';
5
+ import { focusRing, ICON_STROKE, MIN_TOUCH_TARGET, NAV_ICON_SIZE } from './dimensions';
6
+ export function CloseButton({ onPress, label = 'Close' }) {
7
+ const { colors, radius } = useTheme();
8
+ const style = (state) => {
9
+ const { pressed, hovered, focused } = state;
10
+ return {
11
+ width: MIN_TOUCH_TARGET,
12
+ height: MIN_TOUCH_TARGET,
13
+ alignItems: 'center',
14
+ justifyContent: 'center',
15
+ borderRadius: radius.md,
16
+ backgroundColor: pressed || hovered ? colors.surfaceSunken : 'transparent',
17
+ ...(focused ? focusRing(colors.focus) : {}),
18
+ };
19
+ };
20
+ return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress: onPress, style: style, children: _jsx(XIcon, { size: NAV_ICON_SIZE, strokeWidth: ICON_STROKE, color: colors.inkMuted }) }));
21
+ }
@@ -0,0 +1,20 @@
1
+ import type { PaywallProduct } from '../controller';
2
+ export interface ComparisonRow {
3
+ label: string;
4
+ /** Per product key: true (included), false (not included) or a short value ("5 GB"). */
5
+ values: Readonly<Record<string, boolean | string>>;
6
+ }
7
+ export interface ComparisonTableProps {
8
+ rows: readonly ComparisonRow[];
9
+ products: readonly PaywallProduct[];
10
+ selectedKey: string | null;
11
+ }
12
+ /**
13
+ * The comparison template's table (design addition, built from LedgerTable's rules): a
14
+ * `surface-raised` box with a 1px `line` border and `radius-lg`; header row on `surface-sunken` in
15
+ * the `label` style; rows at least 44px with `line` rules; text in `body-sm`. Included and not
16
+ * included are a Lucide check in `ink` and an x in `ink-muted`, each with a text alternative
17
+ * ("Included", "Not included"), so the icon is never the only cue. The selected product's column
18
+ * header is on `brand-tint`. A product with no value for a row shows "Not included".
19
+ */
20
+ export declare function ComparisonTable({ rows, products, selectedKey }: ComparisonTableProps): import("react").JSX.Element | null;
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CheckIcon, XIcon } from 'lucide-react-native';
3
+ import { View } from 'react-native';
4
+ import { useTheme } from '../theme';
5
+ import { BORDER_WIDTH, ICON_SIZE, ICON_STROKE, MIN_TOUCH_TARGET } from './dimensions';
6
+ import { Text } from './Text';
7
+ function valueFor(row, key) {
8
+ return Object.prototype.hasOwnProperty.call(row.values, key) ? row.values[key] : undefined;
9
+ }
10
+ export function ComparisonTable({ rows, products, selectedKey }) {
11
+ const { colors, space, radius } = useTheme();
12
+ if (rows.length === 0 || products.length === 0)
13
+ return null;
14
+ const cell = { flex: 1, paddingVertical: space[2], paddingHorizontal: space[3] };
15
+ return (_jsxs(View, { role: "table", style: {
16
+ borderWidth: BORDER_WIDTH,
17
+ borderColor: colors.line,
18
+ borderRadius: radius.lg,
19
+ overflow: 'hidden',
20
+ backgroundColor: colors.surfaceRaised,
21
+ }, children: [_jsxs(View, { role: "row", style: {
22
+ flexDirection: 'row',
23
+ backgroundColor: colors.surfaceSunken,
24
+ minHeight: MIN_TOUCH_TARGET,
25
+ alignItems: 'stretch',
26
+ }, children: [_jsx(View, { role: "columnheader", style: [cell, { flex: 2, justifyContent: 'center' }], children: _jsx(Text, { variant: "label", children: "Feature" }) }), products.map((p) => (_jsx(View, { role: "columnheader", style: [
27
+ cell,
28
+ {
29
+ justifyContent: 'center',
30
+ alignItems: 'center',
31
+ backgroundColor: p.key === selectedKey ? colors.brandTint : 'transparent',
32
+ },
33
+ ], children: _jsx(Text, { variant: "label", color: "ink", style: { textAlign: 'center' }, children: p.name }) }, p.key)))] }), rows.map((row, i) => (_jsxs(View, { role: "row", style: {
34
+ flexDirection: 'row',
35
+ minHeight: MIN_TOUCH_TARGET,
36
+ borderTopWidth: BORDER_WIDTH,
37
+ borderTopColor: colors.line,
38
+ alignItems: 'stretch',
39
+ }, children: [_jsx(View, { role: "rowheader", style: [cell, { flex: 2, justifyContent: 'center' }], children: _jsx(Text, { variant: "bodySm", children: row.label }) }), products.map((p) => {
40
+ const value = valueFor(row, p.key);
41
+ return (_jsx(View, { role: "cell", style: [cell, { justifyContent: 'center', alignItems: 'center' }], children: typeof value === 'string' ? (_jsx(Text, { variant: "bodySm", style: { textAlign: 'center' }, children: value })) : (_jsx(View, { accessible: true, role: "img", accessibilityLabel: value ? 'Included' : 'Not included', children: value ? (_jsx(CheckIcon, { size: ICON_SIZE, strokeWidth: ICON_STROKE, color: colors.ink })) : (_jsx(XIcon, { size: ICON_SIZE, strokeWidth: ICON_STROKE, color: colors.inkMuted })) })) }, p.key));
42
+ })] }, i)))] }));
43
+ }
@@ -0,0 +1,16 @@
1
+ import type { PaywallProduct } from '../controller';
2
+ import type { RadioItemProps } from './RadioGroup';
3
+ export interface CreditPackOptionProps {
4
+ product: PaywallProduct;
5
+ selected: boolean;
6
+ onSelect: () => void;
7
+ locale: string;
8
+ showBadge?: boolean;
9
+ radio?: RadioItemProps;
10
+ }
11
+ /**
12
+ * A credit pack in the credits template's grid (design addition, built from PaywallOption): the
13
+ * same box, border and selected states, stacked as a tile. The credit amount in `figure-lg`, the
14
+ * word "credits" and the pack name in `body-sm` `ink-muted`, the store price in `figure`.
15
+ */
16
+ export declare function CreditPackOption({ product, selected, onSelect, locale, showBadge, radio, }: CreditPackOptionProps): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, View } from 'react-native';
3
+ import { formatCount } from '../paywall/price';
4
+ import { useTheme } from '../theme';
5
+ import { Badge } from './Badge';
6
+ import { focusRing } from './dimensions';
7
+ import { paywallOptionStyle } from './PaywallOption';
8
+ import { Radio } from './Radio';
9
+ import { Text } from './Text';
10
+ export function CreditPackOption({ product, selected, onSelect, locale, showBadge = false, radio, }) {
11
+ const theme = useTheme();
12
+ const grant = product.credits[0];
13
+ const amount = grant && Number.isFinite(grant.amount) ? formatCount(grant.amount, locale) : null;
14
+ const noun = grant?.amount === 1 ? 'credit' : 'credits';
15
+ const badge = showBadge && product.badge ? product.badge : null;
16
+ const label = [
17
+ amount ? `${amount} ${noun}` : product.name,
18
+ product.price.formatted,
19
+ amount ? product.name : null,
20
+ badge,
21
+ ]
22
+ .filter(Boolean)
23
+ .join(', ');
24
+ return (_jsxs(Pressable, { ...(radio ?? {}), accessibilityRole: "radio", accessibilityState: { checked: selected }, "aria-checked": selected, accessibilityLabel: label, onPress: onSelect, style: (state) => {
25
+ const { focused } = state;
26
+ return [
27
+ paywallOptionStyle(theme, selected),
28
+ { flexDirection: 'column', alignItems: 'flex-start', gap: theme.space[2] },
29
+ focused ? focusRing(theme.colors.focus) : null,
30
+ ];
31
+ }, children: [_jsxs(View, { style: {
32
+ flexDirection: 'row',
33
+ alignSelf: 'stretch',
34
+ justifyContent: 'space-between',
35
+ alignItems: 'center',
36
+ gap: theme.space[2],
37
+ }, children: [_jsx(Radio, { selected: selected }), badge ? _jsx(Badge, { label: badge }) : null] }), amount ? (_jsxs(View, { children: [_jsx(Text, { variant: "figureLg", children: amount }), _jsx(Text, { variant: "bodySm", color: "inkMuted", children: noun })] })) : (_jsx(Text, { variant: "body", style: { fontFamily: theme.typography.heading3.fontFamily }, children: product.name })), _jsx(Text, { variant: "figure", children: product.price.formatted })] }));
38
+ }
@@ -0,0 +1,14 @@
1
+ import type { FeatureIcon } from '../schema/config';
2
+ export interface PaywallFeature {
3
+ text: string;
4
+ icon?: FeatureIcon;
5
+ }
6
+ export interface FeatureListProps {
7
+ features: readonly PaywallFeature[];
8
+ }
9
+ /**
10
+ * The paywall's feature rows (design addition): a Lucide icon at 16px with a 1.75px stroke,
11
+ * colored like the `body` `ink` text beside it, `space-2` from the text; rows `space-2` apart.
12
+ * Icons are decorative; the text carries the meaning. Defaults to `check`.
13
+ */
14
+ export declare function FeatureList({ features }: FeatureListProps): import("react").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useTheme } from '../theme';
4
+ import { ICON_SIZE, ICON_STROKE } from './dimensions';
5
+ import { FEATURE_ICON_COMPONENTS } from './icons';
6
+ import { Text } from './Text';
7
+ export function FeatureList({ features }) {
8
+ const { colors, space, typography } = useTheme();
9
+ if (features.length === 0)
10
+ return null;
11
+ return (_jsx(View, { accessibilityRole: "list", style: { gap: space[2] }, children: features.map((feature, i) => {
12
+ const Icon = FEATURE_ICON_COMPONENTS[feature.icon ?? 'check'] ?? FEATURE_ICON_COMPONENTS.check;
13
+ return (_jsxs(View, { accessibilityRole: "listitem", style: { flexDirection: 'row', alignItems: 'flex-start', gap: space[2] }, children: [_jsx(View, { "aria-hidden": true, importantForAccessibility: "no-hide-descendants", style: { height: typography.body.lineHeight, justifyContent: 'center' }, children: _jsx(Icon, { size: ICON_SIZE, strokeWidth: ICON_STROKE, color: colors.ink }) }), _jsx(Text, { variant: "body", style: { flex: 1 }, children: feature.text })] }, i));
14
+ }) }));
15
+ }
@@ -0,0 +1,17 @@
1
+ export interface PaywallFooterProps {
2
+ /** Shows "Restore purchases" when given. */
3
+ onRestore?: (() => void) | null;
4
+ restoring?: boolean;
5
+ /** Disables Restore while a purchase is in progress. */
6
+ disabled?: boolean;
7
+ termsUrl?: string | null;
8
+ privacyUrl?: string | null;
9
+ }
10
+ /** Opens a legal link in the browser, only after re-checking that it's https. */
11
+ export declare function openLegalUrl(url: string | null | undefined): void;
12
+ /**
13
+ * The paywall footer (design addition, from "The paywall"): "Restore purchases" as a ghost button
14
+ * and the Terms and Privacy links, all in `body-sm` `ink-muted` with 44px targets, centered and
15
+ * wrapping. A link renders only when its URL is https.
16
+ */
17
+ export declare function PaywallFooter({ onRestore, restoring, disabled, termsUrl, privacyUrl, }: PaywallFooterProps): import("react").JSX.Element | null;
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ActivityIndicator, Linking, Pressable, View, } from 'react-native';
3
+ import { safeHttpsUrl } from '../paywall/url';
4
+ import { useTheme } from '../theme';
5
+ import { DISABLED_OPACITY, focusRing, MIN_TOUCH_TARGET } from './dimensions';
6
+ import { Text } from './Text';
7
+ function FooterAction({ label, role, onPress, disabled, busy, }) {
8
+ const { colors, space, radius } = useTheme();
9
+ return (_jsxs(Pressable, { accessibilityRole: role, accessibilityState: { disabled: !!disabled, busy: !!busy }, disabled: disabled, onPress: onPress, style: (state) => {
10
+ const { pressed, hovered, focused } = state;
11
+ return [
12
+ {
13
+ minHeight: MIN_TOUCH_TARGET,
14
+ minWidth: MIN_TOUCH_TARGET,
15
+ paddingHorizontal: space[3],
16
+ borderRadius: radius.md,
17
+ flexDirection: 'row',
18
+ alignItems: 'center',
19
+ justifyContent: 'center',
20
+ gap: space[2],
21
+ backgroundColor: (pressed || hovered) && !disabled ? colors.surfaceSunken : 'transparent',
22
+ opacity: disabled ? DISABLED_OPACITY : 1,
23
+ },
24
+ focused ? focusRing(colors.focus) : null,
25
+ ];
26
+ }, children: [busy ? _jsx(ActivityIndicator, { size: "small", color: colors.inkMuted }) : null, _jsx(Text, { variant: "bodySm", color: "inkMuted", children: label })] }));
27
+ }
28
+ export function openLegalUrl(url) {
29
+ const safe = safeHttpsUrl(url);
30
+ if (safe)
31
+ void Linking.openURL(safe).catch(() => undefined);
32
+ }
33
+ export function PaywallFooter({ onRestore, restoring = false, disabled = false, termsUrl, privacyUrl, }) {
34
+ const { space } = useTheme();
35
+ const terms = safeHttpsUrl(termsUrl);
36
+ const privacy = safeHttpsUrl(privacyUrl);
37
+ if (!onRestore && !terms && !privacy)
38
+ return null;
39
+ return (_jsxs(View, { style: {
40
+ flexDirection: 'row',
41
+ flexWrap: 'wrap',
42
+ justifyContent: 'center',
43
+ alignItems: 'center',
44
+ columnGap: space[1],
45
+ }, children: [onRestore ? (_jsx(FooterAction, { role: "button", label: restoring ? 'Restoring purchases' : 'Restore purchases', onPress: onRestore, disabled: disabled || restoring, busy: restoring })) : null, terms ? (_jsx(FooterAction, { role: "link", label: "Terms", onPress: () => openLegalUrl(terms) })) : null, privacy ? (_jsx(FooterAction, { role: "link", label: "Privacy", onPress: () => openLegalUrl(privacy) })) : null] }));
46
+ }
@@ -0,0 +1,26 @@
1
+ import type { Theme } from '@tenthbilling/design';
2
+ import { type ViewStyle } from 'react-native';
3
+ import type { PaywallProduct } from '../controller';
4
+ import type { RadioItemProps } from './RadioGroup';
5
+ export interface PaywallOptionProps {
6
+ product: PaywallProduct;
7
+ selected: boolean;
8
+ onSelect: () => void;
9
+ /** Locale for the per-month equivalent and credit counts. */
10
+ locale: string;
11
+ /** Show the product's badge. The paywall shows at most one (see `badgedProductKey`). */
12
+ showBadge?: boolean;
13
+ /** Radio group keyboard support from `useRadioGroup`. */
14
+ radio?: RadioItemProps;
15
+ }
16
+ /**
17
+ * The option row's box (design system "PaywallOption"): `surface-raised` with a 1px `line-strong`
18
+ * border, `radius-lg`, 16px (`space-4`) padding; selected is a 2px `brand` border on `brand-tint`.
19
+ */
20
+ export declare function paywallOptionStyle(theme: Theme, selected: boolean): ViewStyle;
21
+ /**
22
+ * One selectable product in the paywall, as a radio row (design system "PaywallOption"): radio on
23
+ * the left; name in `body` semibold and the detail line in `body-sm` `ink-muted` in the middle;
24
+ * the price in `figure` on the right. The optional badge is a `stamp` fill with `on-stamp` text.
25
+ */
26
+ export declare function PaywallOption({ product, selected, onSelect, locale, showBadge, radio, }: PaywallOptionProps): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, View } from 'react-native';
3
+ import { optionDetail, optionPrice } from '../paywall/copy';
4
+ import { useTheme } from '../theme';
5
+ import { Badge } from './Badge';
6
+ import { BORDER_WIDTH, focusRing, MIN_TOUCH_TARGET, SELECTED_BORDER_WIDTH } from './dimensions';
7
+ import { Radio } from './Radio';
8
+ import { Text } from './Text';
9
+ export function paywallOptionStyle(theme, selected) {
10
+ const { colors, space, radius } = theme;
11
+ return {
12
+ flexDirection: 'row',
13
+ alignItems: 'center',
14
+ gap: space[3],
15
+ minHeight: MIN_TOUCH_TARGET,
16
+ padding: space[4],
17
+ borderRadius: radius.lg,
18
+ borderWidth: selected ? SELECTED_BORDER_WIDTH : BORDER_WIDTH,
19
+ borderColor: selected ? colors.brand : colors.lineStrong,
20
+ backgroundColor: selected ? colors.brandTint : colors.surfaceRaised,
21
+ };
22
+ }
23
+ export function PaywallOption({ product, selected, onSelect, locale, showBadge = false, radio, }) {
24
+ const theme = useTheme();
25
+ const detail = optionDetail(product, locale);
26
+ const price = optionPrice(product);
27
+ const badge = showBadge && product.badge ? product.badge : null;
28
+ const label = [product.name, price, detail, badge].filter(Boolean).join(', ');
29
+ return (_jsxs(Pressable, { ...(radio ?? {}), accessibilityRole: "radio", accessibilityState: { checked: selected }, "aria-checked": selected, accessibilityLabel: label, onPress: onSelect, style: (state) => {
30
+ const { focused } = state;
31
+ return [
32
+ paywallOptionStyle(theme, selected),
33
+ focused ? focusRing(theme.colors.focus) : null,
34
+ ];
35
+ }, children: [_jsx(Radio, { selected: selected }), _jsxs(View, { style: { flex: 1, gap: theme.space[1] }, children: [_jsxs(View, { style: {
36
+ flexDirection: 'row',
37
+ flexWrap: 'wrap',
38
+ alignItems: 'center',
39
+ gap: theme.space[2],
40
+ }, children: [_jsx(Text, { variant: "body", style: { fontFamily: theme.typography.heading3.fontFamily }, children: product.name }), badge ? _jsx(Badge, { label: badge }) : null] }), detail ? (_jsx(Text, { variant: "bodySm", color: "inkMuted", children: detail })) : null] }), _jsx(Text, { variant: "figure", style: { textAlign: 'right' }, children: price })] }));
41
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The radio mark inside a selectable row (design addition). Visual only: the row it sits in
3
+ * carries the radio role and checked state. Unselected: a line-strong ring (a control border,
4
+ * 3:1). Selected: a brand ring with a brand dot ("filled radio").
5
+ */
6
+ export declare function Radio({ selected }: {
7
+ selected: boolean;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useTheme } from '../theme';
4
+ import { RADIO_DOT_SIZE, RADIO_SIZE, SELECTED_BORDER_WIDTH } from './dimensions';
5
+ export function Radio({ selected }) {
6
+ const { colors } = useTheme();
7
+ return (_jsx(View, { accessible: false, importantForAccessibility: "no-hide-descendants", "aria-hidden": true, style: {
8
+ width: RADIO_SIZE,
9
+ height: RADIO_SIZE,
10
+ borderRadius: RADIO_SIZE / 2,
11
+ borderWidth: SELECTED_BORDER_WIDTH,
12
+ borderColor: selected ? colors.brand : colors.lineStrong,
13
+ alignItems: 'center',
14
+ justifyContent: 'center',
15
+ }, children: selected ? (_jsx(View, { style: {
16
+ width: RADIO_DOT_SIZE,
17
+ height: RADIO_DOT_SIZE,
18
+ borderRadius: RADIO_DOT_SIZE / 2,
19
+ backgroundColor: colors.brand,
20
+ } })) : null }));
21
+ }
@@ -0,0 +1,23 @@
1
+ import { type ComponentRef, type ReactNode } from 'react';
2
+ import { View, type ViewStyle } from 'react-native';
3
+ type ViewInstance = ComponentRef<typeof View>;
4
+ /** Props a radio row spreads onto its Pressable for keyboard support. */
5
+ export interface RadioItemProps {
6
+ /** Roving tab stop: only the selected radio is in the tab order (WAI-ARIA radio group). */
7
+ tabIndex: 0 | -1;
8
+ onKeyDown: (event: unknown) => void;
9
+ ref: (node: ViewInstance | null) => void;
10
+ }
11
+ /**
12
+ * Radio group keyboard behavior (design system "PaywallOption": arrow keys move the selection).
13
+ * Arrow down/right selects and focuses the next option, up/left the previous, wrapping around.
14
+ * Keyboard events arrive on web (React Native Web) and on platforms with hardware keyboards.
15
+ */
16
+ export declare function useRadioGroup(keys: readonly string[], selectedKey: string | null, select: (key: string) => void): (key: string) => RadioItemProps;
17
+ /** A container with radiogroup semantics and an accessible name. */
18
+ export declare function RadioGroup({ label, children, style, }: {
19
+ label: string;
20
+ children: ReactNode;
21
+ style?: ViewStyle;
22
+ }): import("react").JSX.Element;
23
+ export {};
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useRef } from 'react';
3
+ import { View } from 'react-native';
4
+ const NEXT = new Set(['ArrowDown', 'ArrowRight']);
5
+ const PREVIOUS = new Set(['ArrowUp', 'ArrowLeft']);
6
+ function keyOf(event) {
7
+ const e = event;
8
+ const key = typeof e?.key === 'string' ? e.key : e?.nativeEvent?.key;
9
+ return typeof key === 'string' ? key : undefined;
10
+ }
11
+ export function useRadioGroup(keys, selectedKey, select) {
12
+ const nodes = useRef(new Map());
13
+ const move = useCallback((from, step) => {
14
+ if (keys.length === 0)
15
+ return;
16
+ const index = keys.indexOf(from);
17
+ const next = keys[(index + step + keys.length) % keys.length];
18
+ if (next === undefined)
19
+ return;
20
+ select(next);
21
+ nodes.current.get(next)?.focus?.();
22
+ }, [keys, select]);
23
+ return (key) => ({
24
+ tabIndex: key === selectedKey ? 0 : -1,
25
+ onKeyDown: (event) => {
26
+ const pressed = keyOf(event);
27
+ if (!pressed || (!NEXT.has(pressed) && !PREVIOUS.has(pressed)))
28
+ return;
29
+ event.preventDefault?.();
30
+ move(key, NEXT.has(pressed) ? 1 : -1);
31
+ },
32
+ ref: (node) => {
33
+ if (node)
34
+ nodes.current.set(key, node);
35
+ else
36
+ nodes.current.delete(key);
37
+ },
38
+ });
39
+ }
40
+ export function RadioGroup({ label, children, style, }) {
41
+ return (_jsx(View, { accessibilityRole: "radiogroup", accessibilityLabel: label, style: style, children: children }));
42
+ }
@@ -0,0 +1,10 @@
1
+ import type { ColorToken, TypographyStyle } from '@tenthbilling/design';
2
+ import { type TextProps as RNTextProps } from 'react-native';
3
+ export interface TextProps extends RNTextProps {
4
+ /** Type style from the design system. Defaults to body. */
5
+ variant?: TypographyStyle;
6
+ /** Color token. Defaults to ink; labels default to ink-muted. */
7
+ color?: ColorToken;
8
+ }
9
+ /** Text set in a design-system type style. Never pass raw font sizes or colors. */
10
+ export declare function Text({ variant, color, style, ...rest }: TextProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Text as RNText } from 'react-native';
3
+ import { useTheme } from '../theme';
4
+ export function Text({ variant = 'body', color, style, ...rest }) {
5
+ const theme = useTheme();
6
+ const fallback = variant === 'label' ? 'inkMuted' : 'ink';
7
+ return (_jsx(RNText, { ...rest, style: [theme.typography[variant], { color: theme.colors[color ?? fallback] }, style] }));
8
+ }