@revenuecat/purchases-ui-js 2.0.0 → 2.0.2

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 (105) hide show
  1. package/dist/components/button/Button.svelte +1 -5
  2. package/dist/components/button/ButtonNode.stories.svelte +57 -71
  3. package/dist/components/button/ButtonNode.stories.svelte.d.ts +0 -8
  4. package/dist/components/button/ButtonNode.svelte +10 -21
  5. package/dist/components/button/ButtonNode.svelte.d.ts +2 -2
  6. package/dist/components/button/button-utils.d.ts +2 -2
  7. package/dist/components/footer/Footer.stories.svelte +26 -22
  8. package/dist/components/footer/Footer.stories.svelte.d.ts +0 -5
  9. package/dist/components/footer/Footer.svelte +3 -10
  10. package/dist/components/footer/Footer.svelte.d.ts +1 -1
  11. package/dist/components/image/Image.stories.svelte +27 -19
  12. package/dist/components/image/Image.svelte +18 -17
  13. package/dist/components/image/image-utils.d.ts +2 -1
  14. package/dist/components/image/image-utils.js +2 -2
  15. package/dist/components/package/Package.stories.svelte +31 -31
  16. package/dist/components/package/Package.stories.svelte.d.ts +0 -6
  17. package/dist/components/package/Package.svelte +19 -30
  18. package/dist/components/package/Package.svelte.d.ts +1 -1
  19. package/dist/components/paywall/Node.svelte +26 -50
  20. package/dist/components/paywall/Node.svelte.d.ts +11 -14
  21. package/dist/components/paywall/Paywall.stories.svelte +21 -78
  22. package/dist/components/paywall/Paywall.svelte +75 -100
  23. package/dist/components/paywall/Paywall.svelte.d.ts +4 -4
  24. package/dist/components/paywall/paywall-utils.d.ts +3 -2
  25. package/dist/components/paywall/paywall-utils.js +5 -5
  26. package/dist/components/purchase-button/PurchaseButton.stories.svelte +29 -31
  27. package/dist/components/purchase-button/PurchaseButton.stories.svelte.d.ts +0 -5
  28. package/dist/components/purchase-button/PurchaseButton.svelte +9 -20
  29. package/dist/components/purchase-button/PurchaseButton.svelte.d.ts +1 -1
  30. package/dist/components/purchase-button/purchase-button-utils.d.ts +1 -1
  31. package/dist/components/stack/Stack.stories.svelte +17 -94
  32. package/dist/components/stack/Stack.svelte +18 -48
  33. package/dist/components/stack/stack-utils.d.ts +4 -3
  34. package/dist/components/stack/stack-utils.js +7 -10
  35. package/dist/components/text/TextNode.stories.svelte +45 -152
  36. package/dist/components/text/TextNode.svelte +15 -23
  37. package/dist/components/text/text-utils.d.ts +7 -6
  38. package/dist/components/text/text-utils.js +7 -7
  39. package/dist/components/timeline/Timeline.stories.svelte +37 -48
  40. package/dist/components/timeline/Timeline.svelte +0 -2
  41. package/dist/components/timeline/TimelineItem.svelte +28 -11
  42. package/dist/components/timeline/timeline-utils.d.ts +3 -3
  43. package/dist/components/timeline/timeline-utils.js +7 -17
  44. package/dist/data/entities.d.ts +54 -145
  45. package/dist/index.d.ts +10 -10
  46. package/dist/index.js +10 -10
  47. package/dist/stores/color-mode.d.ts +6 -0
  48. package/dist/stores/color-mode.js +15 -0
  49. package/dist/stores/localization.d.ts +13 -0
  50. package/dist/stores/localization.js +26 -0
  51. package/dist/stores/paywall.d.ts +11 -0
  52. package/dist/stores/paywall.js +13 -0
  53. package/dist/stores/variables.d.ts +5 -0
  54. package/dist/stores/variables.js +14 -0
  55. package/dist/stories/fixtures.d.ts +1 -1
  56. package/dist/stories/fixtures.js +30 -135
  57. package/dist/stories/localization-decorator.d.ts +3 -0
  58. package/dist/stories/localization-decorator.js +7 -0
  59. package/dist/stories/paywall-decorator.d.ts +2 -0
  60. package/dist/stories/paywall-decorator.js +19 -0
  61. package/dist/stories/variables-decorator.d.ts +3 -0
  62. package/dist/stories/variables-decorator.js +9 -0
  63. package/dist/stories/with-layout.svelte +4 -4
  64. package/dist/types/alignment.d.ts +19 -0
  65. package/dist/types/background.d.ts +18 -0
  66. package/dist/types/background.js +1 -0
  67. package/dist/types/colors.d.ts +34 -0
  68. package/dist/types/colors.js +1 -0
  69. package/dist/types/component.d.ts +6 -0
  70. package/dist/types/component.js +1 -0
  71. package/dist/types/components/button.d.ts +36 -0
  72. package/dist/types/components/button.js +1 -0
  73. package/dist/types/components/footer.d.ts +5 -0
  74. package/dist/types/components/footer.js +1 -0
  75. package/dist/types/components/package.d.ts +8 -0
  76. package/dist/types/components/package.js +1 -0
  77. package/dist/types/components/purchase-button.d.ts +5 -0
  78. package/dist/types/components/purchase-button.js +1 -0
  79. package/dist/types/localization.d.ts +4 -0
  80. package/dist/types/localization.js +1 -0
  81. package/dist/types/media.d.ts +18 -0
  82. package/dist/types/media.js +1 -0
  83. package/dist/types.d.ts +5 -35
  84. package/dist/ui/atoms/typography.stories.svelte +7 -13
  85. package/dist/ui/atoms/typography.stories.svelte.d.ts +1 -1
  86. package/dist/ui/atoms/typography.svelte +1 -1
  87. package/dist/ui/layout/main-block.svelte +2 -2
  88. package/dist/ui/molecules/button.stories.svelte +8 -15
  89. package/dist/ui/molecules/button.svelte +3 -2
  90. package/dist/ui/molecules/button.svelte.d.ts +2 -26
  91. package/dist/ui/molecules/types.d.ts +2 -1
  92. package/dist/ui/theme/theme.d.ts +2 -2
  93. package/dist/ui/theme/theme.js +2 -2
  94. package/dist/ui/theme/utils.d.ts +2 -2
  95. package/dist/utils/style-utils.d.ts +13 -11
  96. package/dist/utils/style-utils.js +21 -27
  97. package/dist/utils/variable-utils.d.ts +1 -38
  98. package/dist/utils/variable-utils.js +6 -48
  99. package/dist/web-components/index.css +1 -1
  100. package/dist/web-components/index.js +610 -657
  101. package/package.json +33 -36
  102. package/dist/data/state.d.ts +0 -9
  103. package/dist/stores/theme.d.ts +0 -1
  104. package/dist/stores/theme.js +0 -17
  105. /package/dist/{data/state.js → types/alignment.js} +0 -0
@@ -4,21 +4,38 @@
4
4
  getTimelineItemTextStyles,
5
5
  } from "./timeline-utils";
6
6
  import type { TimelineItemProps } from "../../data/entities";
7
+ import { getColorModeContext } from "../../stores/color-mode";
8
+ import { getLocalizationContext } from "../../stores/localization";
9
+ import { getVariablesContext } from "../../stores/variables";
10
+ import { replaceVariables } from "../../utils/variable-utils";
7
11
 
8
12
  const props: TimelineItemProps = $props();
9
- const styles = $derived(getTimelineItemStyles(props));
10
13
 
11
- const {
12
- tagToRender: titleTagToRender,
13
- textStyles: titleStyles,
14
- textLabel: titleLabel,
15
- } = $derived(getTimelineItemTextStyles(props, "title"));
14
+ const getColorMode = getColorModeContext();
15
+ const colorMode = $derived(getColorMode());
16
16
 
17
- const {
18
- tagToRender: descriptionTagToRender,
19
- textStyles: descriptionStyles,
20
- textLabel: descriptionLabel,
21
- } = $derived(getTimelineItemTextStyles(props, "description"));
17
+ const styles = $derived(getTimelineItemStyles(colorMode, props));
18
+
19
+ const { getLocalizedString } = getLocalizationContext();
20
+
21
+ const variables = getVariablesContext();
22
+ const titleLabel = $derived(
23
+ replaceVariables(getLocalizedString(props.title.text_lid), $variables),
24
+ );
25
+
26
+ const descriptionLabel = $derived(
27
+ replaceVariables(
28
+ getLocalizedString(props.description?.text_lid),
29
+ $variables,
30
+ ),
31
+ );
32
+
33
+ const { tagToRender: titleTagToRender, textStyles: titleStyles } = $derived(
34
+ getTimelineItemTextStyles(colorMode, props, "title"),
35
+ );
36
+
37
+ const { tagToRender: descriptionTagToRender, textStyles: descriptionStyles } =
38
+ $derived(getTimelineItemTextStyles(colorMode, props, "description"));
22
39
  // TODO: Object mapping icon name to icon component
23
40
  </script>
24
41
 
@@ -1,8 +1,8 @@
1
1
  import type { TimelineItemProps, TimelineProps } from "../../data/entities";
2
+ import type { ColorMode } from "../../types";
2
3
  export declare function getTimelineStyles(props: TimelineProps): string;
3
- export declare function getTimelineItemStyles(props: TimelineItemProps): string;
4
- export declare function getTimelineItemTextStyles(props: TimelineItemProps, kind?: "title" | "description"): {
4
+ export declare function getTimelineItemStyles(colorMode: ColorMode, props: TimelineItemProps): string;
5
+ export declare function getTimelineItemTextStyles(colorMode: ColorMode, props: TimelineItemProps, kind?: "title" | "description"): {
5
6
  textStyles: string;
6
7
  tagToRender: import("../../utils/style-utils").TextComponentTags;
7
- textLabel: string | undefined;
8
8
  };
@@ -1,6 +1,5 @@
1
1
  import { defaultColor, getTextComponentStyles, } from "../text/text-utils";
2
2
  import { getBorderStyle, getColor, getCornerRadiusStyle, getSizeStyle, prefixObject, stringifyStyles, } from "../../utils/style-utils";
3
- import { getLabelAndReplaceVariables } from "../../utils/variable-utils";
4
3
  export function getTimelineStyles(props) {
5
4
  const styles = {
6
5
  "--item-spacing": `${props.item_spacing}px`,
@@ -16,19 +15,19 @@ export function getTimelineStyles(props) {
16
15
  const prefixedStyles = prefixObject(styles, "timeline");
17
16
  return stringifyStyles(prefixedStyles);
18
17
  }
19
- export function getTimelineItemStyles(props) {
18
+ export function getTimelineItemStyles(colorMode, props) {
20
19
  const styles = {
21
20
  "--icon-size": `${props.icon.width_and_height}px`,
22
21
  "--icon-padding": `${props.icon.padding}px`,
23
22
  "--icon-color": getColor({
24
23
  colorMap: props.icon.color,
25
- colorMode: props.purchaseState?.colorMode,
24
+ colorMode,
26
25
  }),
27
26
  "--icon-background-color": getColor({
28
27
  colorMap: props.icon_background?.color,
29
- colorMode: props.purchaseState.colorMode,
28
+ colorMode,
30
29
  }),
31
- "--icon-border": getBorderStyle(props.icon_background?.border, props.purchaseState?.colorMode),
30
+ "--icon-border": getBorderStyle(props.icon_background?.border, colorMode),
32
31
  "--text-spacing": `${props.text_spacing}px`,
33
32
  "--border-start-start-radius": `0px`,
34
33
  "--border-start-end-radius": `0px`,
@@ -36,7 +35,7 @@ export function getTimelineItemStyles(props) {
36
35
  "--border-end-end-radius": `0px`,
37
36
  "--connector-color": getColor({
38
37
  colorMap: props.connector?.color,
39
- colorMode: props.purchaseState.colorMode,
38
+ colorMode,
40
39
  }),
41
40
  "--connector-width": `${props.connector?.width || 0}px`,
42
41
  "--connector-top": "0px",
@@ -80,7 +79,7 @@ export function getTimelineItemStyles(props) {
80
79
  const prefixedStyles = prefixObject(styles, "timeline-item");
81
80
  return stringifyStyles(prefixedStyles);
82
81
  }
83
- export function getTimelineItemTextStyles(props, kind = "title") {
82
+ export function getTimelineItemTextStyles(colorMode, props, kind = "title") {
84
83
  const styles = {
85
84
  "--text-color": "inherit",
86
85
  "--text-font-size": "initial",
@@ -101,9 +100,8 @@ export function getTimelineItemTextStyles(props, kind = "title") {
101
100
  font_weight: props[kind]?.font_weight || "regular",
102
101
  horizontal_alignment: props[kind]?.horizontal_alignment || "leading",
103
102
  };
104
- const { tagToRender, textStyles } = getTextComponentStyles({
103
+ const { tagToRender, textStyles } = getTextComponentStyles(colorMode, {
105
104
  ...props,
106
- components: [],
107
105
  ...textProps,
108
106
  size: { width: { type: "fit" }, height: { type: "fit" } },
109
107
  type: "text",
@@ -113,16 +111,8 @@ export function getTimelineItemTextStyles(props, kind = "title") {
113
111
  });
114
112
  Object.assign(styles, textStyles);
115
113
  const stringifiedStyles = stringifyStyles(prefixObject(styles, "timeline-item"));
116
- const textLabel = getLabelAndReplaceVariables({
117
- text_lid: props[kind]?.text_lid,
118
- locale: props.purchaseState.locale,
119
- defaultLocale: props.purchaseState.defaultLocale,
120
- labels: props.labels,
121
- variableDictionary: props.variableDictionary,
122
- });
123
114
  return {
124
115
  textStyles: stringifiedStyles,
125
116
  tagToRender,
126
- textLabel,
127
117
  };
128
118
  }
@@ -1,32 +1,17 @@
1
- import type { AlignmentType, BorderType, CircleShape, ColorType, CornerRadiusType, DimensionType, FitTypes, FontSizeTags, FontWeights, RectangleShape, ShadowType, ShapeType, SizeType, Spacing, TextAlignments } from "../types";
2
- import type { PurchaseState } from "./state";
3
- import type { VariableDictionary } from "../utils/variable-utils";
4
1
  import type { ZStackChildStyles } from "../components/stack/stack-utils";
5
- export interface Extra {
6
- [key: string]: unknown;
7
- }
8
- export type ComponentTypes = "stack" | "text" | "image" | "button" | "purchase_button" | "footer" | "package" | "timeline";
9
- export interface PaywallComponent extends Extra {
10
- type: ComponentTypes;
11
- id: string;
12
- name: string;
13
- fallback?: PaywallComponent;
14
- }
15
- export interface Stack extends PaywallComponent {
16
- spacing: number;
17
- components: PaywallComponent[];
2
+ import type { AlignmentType, BorderType, CircleShape, CornerRadiusType, FontSizeTags, FontWeights, RectangleShape, ShadowType, ShapeType, SizeType, Spacing, TextAlignments } from "../types";
3
+ import type { Dimension } from "../types/alignment";
4
+ import type { Background } from "../types/background";
5
+ import type { ColorGradientScheme, ColorScheme } from "../types/colors";
6
+ import type { Component } from "../types/component";
7
+ import type { FooterProps } from "../types/components/footer";
8
+ import type { Localizations } from "../types/localization";
9
+ import type { ImageInfo, ImageObjectFit } from "../types/media";
10
+ export interface RootPaywall {
11
+ background?: Background;
12
+ stack: StackProps;
13
+ sticky_footer?: FooterProps | null;
18
14
  }
19
- type BaseNodeBackgroundColor = {
20
- type: "color";
21
- value: ColorType;
22
- };
23
- export type BaseNodeBackgroundImage = {
24
- type: "image";
25
- value: ImageSourceType;
26
- color_overlay?: ColorType;
27
- fit_mode?: FitTypes;
28
- };
29
- export type BaseNodeBackgroundType = BaseNodeBackgroundColor | BaseNodeBackgroundImage;
30
15
  export interface ComponentConfig {
31
16
  colors?: Record<string, string>;
32
17
  fonts?: {
@@ -37,130 +22,69 @@ export interface ComponentConfig {
37
22
  };
38
23
  };
39
24
  asset_base_url?: string;
40
- base: {
41
- default_font_name?: string;
42
- background?: BaseNodeBackgroundType;
43
- stack: Stack;
44
- sticky_footer?: {
45
- stack: Stack;
46
- id: string;
47
- name: string;
48
- type: "footer";
49
- } | null;
50
- };
25
+ base: RootPaywall;
51
26
  }
52
- export interface ComponentLocalizations extends Extra {
53
- [locale: string]: {
54
- [label_id: string]: string;
55
- };
56
- }
57
- export interface PaywallData extends Extra {
58
- components_config: ComponentConfig;
59
- components_localizations: ComponentLocalizations;
27
+ export interface PaywallData {
60
28
  default_locale: string;
61
- }
62
- export interface ActionsProps {
63
- onAction?: (action: SupportedActions, data?: Extra) => void;
64
- }
65
- export interface PurchaseStateProps {
66
- purchaseState: PurchaseState;
29
+ components_config: ComponentConfig;
30
+ components_localizations: Localizations;
67
31
  }
68
32
  export type ComponentState = {
69
33
  [state: string]: boolean;
70
34
  };
71
- interface SharedComponentProps extends PaywallComponent, ActionsProps, PurchaseStateProps {
72
- labels: ComponentLocalizations;
35
+ export interface BaseComponent {
36
+ type: string;
73
37
  id: string;
74
38
  name: string;
75
- variableDictionary?: VariableDictionary;
39
+ fallback?: Component;
76
40
  componentState?: ComponentState;
77
41
  zStackChildStyles?: ZStackChildStyles;
78
42
  }
79
- interface Action {
80
- type: "restore_purchases" | "navigate_to" | "navigate_back" | "purchase" | "select_package";
81
- }
82
- type OverrideProps<T> = {
43
+ export type OverrideProps<T> = {
83
44
  states?: {
84
45
  [state: string]: T;
85
46
  };
86
47
  };
87
- export interface RestorePurchasesAction extends Action {
88
- type: "restore_purchases";
89
- }
90
- export interface NavigateBackAction extends Action {
91
- type: "navigate_back";
92
- }
93
- export interface NavigateToAction extends Action {
94
- type: "navigate_to";
95
- destination: "customer_center" | "privacy_policy" | "terms" | "url";
96
- url?: {
97
- url_lid: string;
98
- method: "in_app_browser" | "external_browser" | "deep_link";
99
- };
100
- }
101
- export interface PurchaseAction extends Action {
102
- type: "purchase";
103
- }
104
- export interface SelectPackageAction extends Action {
105
- type: "select_package";
106
- }
107
- export type SupportedActions = RestorePurchasesAction | NavigateBackAction | NavigateToAction | PurchaseAction | SelectPackageAction;
108
- export interface ButtonNodeProps extends SharedComponentProps {
109
- type: "button";
110
- action: SupportedActions;
111
- stack: StackProps;
112
- }
113
- export interface PurchaseButtonProps extends SharedComponentProps {
114
- type: "purchase_button";
115
- stack: StackProps;
116
- }
117
- export interface FooterProps extends SharedComponentProps {
118
- type: "footer";
119
- stack: StackProps;
120
- }
121
- export interface PackageProps extends SharedComponentProps {
122
- type: "package";
123
- stack: StackProps;
124
- package_id: string;
125
- is_selected_by_default: boolean;
126
- }
127
- export interface StackProps extends SharedComponentProps {
128
- background_color?: ColorType;
129
- border?: BorderType;
130
- components: PaywallComponent[];
131
- dimension: DimensionType;
48
+ export interface StackProps extends BaseComponent {
49
+ type: "stack";
50
+ visible?: boolean | null;
51
+ components: Component[];
52
+ size: SizeType;
53
+ dimension: Dimension;
54
+ spacing: number;
132
55
  margin: Spacing;
133
56
  padding: Spacing;
134
- shadow?: ShadowType;
135
- shape?: ShapeType;
136
- size: SizeType;
137
- spacing?: number;
138
- type: "stack";
139
- badge?: {
57
+ background_color: ColorGradientScheme | null;
58
+ background: Background | null;
59
+ border: BorderType | null;
60
+ shape: ShapeType | null;
61
+ shadow: ShadowType | null;
62
+ badge?: null | {
140
63
  stack: {
141
- components: PaywallComponent[];
64
+ components: Component[];
142
65
  type: "stack";
143
66
  };
144
67
  style: "overlay" | "edge_to_edge" | "nested";
145
68
  alignment: Exclude<AlignmentType, "center">;
146
- shape: ShapeType;
69
+ border?: BorderType | null;
70
+ shape: ShapeType | null;
71
+ shadow?: ShadowType | null;
147
72
  padding: Spacing;
148
73
  margin: Spacing;
149
74
  text_lid: string;
150
- color: ColorType;
75
+ color: ColorScheme;
151
76
  font_name?: string;
152
77
  font_weight: keyof typeof FontWeights;
153
78
  font_size: keyof typeof FontSizeTags;
154
79
  horizontal_alignment: keyof typeof TextAlignments;
155
- background_color: ColorType;
80
+ background_color: ColorGradientScheme;
156
81
  };
157
82
  overrides?: OverrideProps<StackProps>;
158
83
  }
159
- export interface TextNodeProps extends SharedComponentProps {
160
- background_color?: ColorType;
161
- color: ColorType;
162
- components: PaywallComponent[];
163
- font_name?: string;
84
+ export interface TextNodeProps extends BaseComponent {
85
+ background_color?: ColorGradientScheme | null;
86
+ color: ColorScheme;
87
+ font_name?: string | null;
164
88
  font_size: keyof typeof FontSizeTags;
165
89
  font_weight: keyof typeof FontWeights;
166
90
  horizontal_alignment: keyof typeof TextAlignments;
@@ -169,32 +93,18 @@ export interface TextNodeProps extends SharedComponentProps {
169
93
  text_lid: string;
170
94
  type: "text";
171
95
  size: SizeType;
172
- variableDictionary?: VariableDictionary;
173
96
  overrides?: OverrideProps<TextNodeProps>;
174
97
  }
175
- type ImageSourceDictionaryType = {
176
- original: string;
177
- heic: string;
178
- heic_low_res: string;
179
- webp: string;
180
- webp_low_res: string;
181
- width?: number;
182
- height?: number;
183
- };
184
- type ImageSourceType = {
185
- light: ImageSourceDictionaryType;
186
- dark?: ImageSourceDictionaryType;
187
- };
188
98
  export interface ImageMaskShapeType {
189
99
  type: "circle" | "rectangle" | "concave" | "convex";
190
100
  corners?: CornerRadiusType;
191
101
  }
192
- export interface ImageProps extends SharedComponentProps {
102
+ export interface ImageProps extends BaseComponent {
193
103
  type: "image";
194
- fit_mode: FitTypes;
104
+ fit_mode: ImageObjectFit;
195
105
  size: SizeType;
196
- source: ImageSourceType;
197
- color_overlay?: ColorType;
106
+ source: ImageInfo;
107
+ color_overlay?: ColorGradientScheme | null;
198
108
  mask_shape?: ImageMaskShapeType;
199
109
  max_height?: number;
200
110
  override_source_lid?: string;
@@ -203,7 +113,7 @@ export interface ImageProps extends SharedComponentProps {
203
113
  export type ItemProps = {
204
114
  title: {
205
115
  text_lid: string;
206
- color: ColorType;
116
+ color: ColorScheme;
207
117
  font_name?: string;
208
118
  font_weight?: keyof typeof FontWeights;
209
119
  font_size?: keyof typeof FontSizeTags;
@@ -211,7 +121,7 @@ export type ItemProps = {
211
121
  };
212
122
  description?: {
213
123
  text_lid: string;
214
- color: ColorType;
124
+ color: ColorScheme;
215
125
  font_name?: string;
216
126
  font_weight?: keyof typeof FontWeights;
217
127
  font_size?: keyof typeof FontSizeTags;
@@ -219,13 +129,13 @@ export type ItemProps = {
219
129
  };
220
130
  icon: {
221
131
  name: string;
222
- color: ColorType;
132
+ color: ColorScheme;
223
133
  width_and_height: number;
224
134
  padding: number;
225
135
  };
226
136
  icon_background?: {
227
137
  shape: CircleShape | RectangleShape;
228
- color: ColorType;
138
+ color: ColorScheme;
229
139
  border?: BorderType;
230
140
  };
231
141
  connector?: {
@@ -234,10 +144,10 @@ export type ItemProps = {
234
144
  top: number;
235
145
  bottom: number;
236
146
  };
237
- color: ColorType;
147
+ color: ColorGradientScheme;
238
148
  };
239
149
  };
240
- export interface TimelineProps extends SharedComponentProps {
150
+ export interface TimelineProps extends BaseComponent {
241
151
  type: "timeline";
242
152
  item_spacing: number;
243
153
  text_spacing: number;
@@ -246,8 +156,7 @@ export interface TimelineProps extends SharedComponentProps {
246
156
  margin: Spacing;
247
157
  items: ItemProps[];
248
158
  }
249
- export interface TimelineItemProps extends ItemProps, SharedComponentProps {
159
+ export interface TimelineItemProps extends ItemProps, BaseComponent {
250
160
  text_spacing: number;
251
161
  item_spacing: number;
252
162
  }
253
- export {};
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export * from "./types";
2
- export * from "./ui/globals";
3
- export { type PaywallData as PaywallData } from "./data/entities";
4
- export { type VariableDictionary } from "./utils/variable-utils";
5
- export { default as Paywall } from "./components/paywall/Paywall.svelte";
6
- export { default as Stack } from "./components/stack/Stack.svelte";
7
1
  export { default as ButtonDeprecated } from "./components/button/Button.svelte";
8
- export { default as Button } from "./ui/molecules/button.svelte";
9
- export { default as Text } from "./components/text/Text.svelte";
2
+ export { default as Footer } from "./components/footer/Footer.svelte";
10
3
  export { default as Image } from "./components/image/Image.svelte";
11
- export { default as PurchaseButton } from "./components/purchase-button/PurchaseButton.svelte";
12
4
  export { default as Package } from "./components/package/Package.svelte";
13
- export { default as Footer } from "./components/footer/Footer.svelte";
5
+ export { default as Paywall } from "./components/paywall/Paywall.svelte";
6
+ export { default as PurchaseButton } from "./components/purchase-button/PurchaseButton.svelte";
7
+ export { default as Stack } from "./components/stack/Stack.svelte";
8
+ export { default as Text } from "./components/text/Text.svelte";
14
9
  export { default as Timeline } from "./components/timeline/Timeline.svelte";
10
+ export { type PaywallData as PaywallData } from "./data/entities";
11
+ export * from "./types";
12
+ export * from "./ui/globals";
13
+ export { default as Button } from "./ui/molecules/button.svelte";
14
+ export { type VariableDictionary } from "./utils/variable-utils";
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  // Reexport your entry components here
2
- export * from "./types";
3
- export * from "./ui/globals";
4
- export {} from "./data/entities";
5
- export {} from "./utils/variable-utils";
6
- export { default as Paywall } from "./components/paywall/Paywall.svelte";
7
- export { default as Stack } from "./components/stack/Stack.svelte";
8
2
  export { default as ButtonDeprecated } from "./components/button/Button.svelte";
9
- export { default as Button } from "./ui/molecules/button.svelte";
10
- export { default as Text } from "./components/text/Text.svelte";
3
+ export { default as Footer } from "./components/footer/Footer.svelte";
11
4
  export { default as Image } from "./components/image/Image.svelte";
12
- export { default as PurchaseButton } from "./components/purchase-button/PurchaseButton.svelte";
13
5
  export { default as Package } from "./components/package/Package.svelte";
14
- export { default as Footer } from "./components/footer/Footer.svelte";
6
+ export { default as Paywall } from "./components/paywall/Paywall.svelte";
7
+ export { default as PurchaseButton } from "./components/purchase-button/PurchaseButton.svelte";
8
+ export { default as Stack } from "./components/stack/Stack.svelte";
9
+ export { default as Text } from "./components/text/Text.svelte";
15
10
  export { default as Timeline } from "./components/timeline/Timeline.svelte";
11
+ export {} from "./data/entities";
12
+ export * from "./types";
13
+ export * from "./ui/globals";
14
+ export { default as Button } from "./ui/molecules/button.svelte";
15
+ export {} from "./utils/variable-utils";
@@ -0,0 +1,6 @@
1
+ import type { ColorMode } from "../types";
2
+ export type ColorModeOverride = () => ColorMode | undefined;
3
+ type GetColorMode = () => ColorMode;
4
+ export declare function setColorModeContext(colorModeOverride?: ColorModeOverride): GetColorMode;
5
+ export declare function getColorModeContext(): GetColorMode;
6
+ export {};
@@ -0,0 +1,15 @@
1
+ import { DEFAULT_COLOR_MODE } from "../utils/constants";
2
+ import { getContext, setContext } from "svelte";
3
+ import { MediaQuery } from "svelte/reactivity";
4
+ const key = Symbol("color-mode");
5
+ export function setColorModeContext(colorModeOverride) {
6
+ const prefersDarkMode = new MediaQuery("prefers-color-scheme: dark", (colorModeOverride?.() ?? DEFAULT_COLOR_MODE) === "dark");
7
+ const context = () => colorModeOverride?.() ??
8
+ (prefersDarkMode.current ? "dark" : DEFAULT_COLOR_MODE);
9
+ setContext(key, context);
10
+ return context;
11
+ }
12
+ export function getColorModeContext() {
13
+ const context = getContext(key);
14
+ return context ?? (() => DEFAULT_COLOR_MODE);
15
+ }
@@ -0,0 +1,13 @@
1
+ import type { Localizations } from "../types/localization";
2
+ type GetLocalizedString = (id?: string) => string | undefined;
3
+ interface LocalizationContext {
4
+ getLocalizedString: GetLocalizedString;
5
+ }
6
+ export interface LocalizationContextProps {
7
+ defaultLocale: string;
8
+ selectedLocale?: string;
9
+ localizations: Localizations;
10
+ }
11
+ export declare function setLocalizationContext(props: () => LocalizationContextProps): LocalizationContext;
12
+ export declare function getLocalizationContext(): LocalizationContext;
13
+ export {};
@@ -0,0 +1,26 @@
1
+ import { getContext, setContext } from "svelte";
2
+ const key = Symbol("localization");
3
+ export function setLocalizationContext(props) {
4
+ const getLocalizedString = (id) => {
5
+ if (!id) {
6
+ return "";
7
+ }
8
+ const { selectedLocale, defaultLocale, localizations } = props();
9
+ const locale = selectedLocale ?? defaultLocale;
10
+ const selected = localizations[locale]?.[id];
11
+ const fallback = localizations[defaultLocale]?.[id];
12
+ return selected ?? fallback;
13
+ };
14
+ const context = {
15
+ getLocalizedString,
16
+ };
17
+ setContext(key, context);
18
+ return context;
19
+ }
20
+ export function getLocalizationContext() {
21
+ const context = getContext(key);
22
+ if (context === undefined) {
23
+ throw new Error("Localization context not found");
24
+ }
25
+ return context;
26
+ }
@@ -0,0 +1,11 @@
1
+ import type { Action } from "../types/components/button";
2
+ import type { VariableDictionary } from "../utils/variable-utils";
3
+ import { type Readable, type Writable } from "svelte/store";
4
+ export type PaywallContext = Readonly<{
5
+ selectedPackageId: Writable<string | undefined>;
6
+ variablesPerPackage: Readable<Record<string, VariableDictionary> | undefined>;
7
+ onPurchase: () => void;
8
+ onButtonAction: (action: Action) => void;
9
+ }>;
10
+ export declare function setPaywallContext(context: PaywallContext): void;
11
+ export declare function getPaywallContext(): PaywallContext;
@@ -0,0 +1,13 @@
1
+ import { getContext, setContext } from "svelte";
2
+ import {} from "svelte/store";
3
+ const key = Symbol("paywall");
4
+ export function setPaywallContext(context) {
5
+ setContext(key, context);
6
+ }
7
+ export function getPaywallContext() {
8
+ const context = getContext(key);
9
+ if (context === undefined) {
10
+ throw new Error("Paywall context not found");
11
+ }
12
+ return context;
13
+ }
@@ -0,0 +1,5 @@
1
+ import { type VariableDictionary } from "../utils/variable-utils";
2
+ import { type Readable } from "svelte/store";
3
+ export type VariablesStore = Readable<VariableDictionary | undefined>;
4
+ export declare function setVariablesContext(variables: VariablesStore): void;
5
+ export declare function getVariablesContext(): VariablesStore;
@@ -0,0 +1,14 @@
1
+ import {} from "../utils/variable-utils";
2
+ import { getContext, setContext } from "svelte";
3
+ import {} from "svelte/store";
4
+ const key = Symbol("variables");
5
+ export function setVariablesContext(variables) {
6
+ setContext(key, variables);
7
+ }
8
+ export function getVariablesContext() {
9
+ const context = getContext(key);
10
+ if (context === undefined) {
11
+ throw new Error("Variables context not found");
12
+ }
13
+ return context;
14
+ }
@@ -10,7 +10,7 @@ export declare const calmPaywallData: PaywallData;
10
10
  export declare const stateTemplate: PaywallData;
11
11
  export declare const posterMakerTemplate: PaywallData;
12
12
  export declare const zStackTemplate: PaywallData;
13
- export declare const labelsData: {
13
+ export declare const localizations: {
14
14
  en_US: {
15
15
  id1: string;
16
16
  id2: string;