@revenuecat/purchases-ui-js 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/components/button/ButtonNode.stories.svelte +66 -102
  2. package/dist/components/button/ButtonNode.svelte +18 -26
  3. package/dist/components/carousel/Carousel.stories.svelte +1039 -0
  4. package/dist/components/carousel/Carousel.stories.svelte.d.ts +19 -0
  5. package/dist/components/carousel/Carousel.svelte +298 -0
  6. package/dist/components/carousel/Carousel.svelte.d.ts +4 -0
  7. package/dist/components/carousel/CarouselPage.svelte +39 -0
  8. package/dist/components/carousel/CarouselPage.svelte.d.ts +11 -0
  9. package/dist/components/carousel/PageControl.svelte +93 -0
  10. package/dist/components/carousel/PageControl.svelte.d.ts +4 -0
  11. package/dist/components/carousel/carousel-utils.d.ts +4 -0
  12. package/dist/components/carousel/carousel-utils.js +21 -0
  13. package/dist/components/footer/Footer.stories.svelte +112 -102
  14. package/dist/components/footer/Footer.svelte +8 -4
  15. package/dist/components/icon/Icon.stories.svelte +100 -0
  16. package/dist/components/icon/Icon.stories.svelte.d.ts +19 -0
  17. package/dist/components/icon/Icon.svelte +73 -0
  18. package/dist/components/icon/Icon.svelte.d.ts +4 -0
  19. package/dist/components/image/ClipPath.svelte +49 -0
  20. package/dist/components/image/ClipPath.svelte.d.ts +9 -0
  21. package/dist/components/image/Image.stories.svelte +83 -188
  22. package/dist/components/image/Image.svelte +152 -136
  23. package/dist/components/image/Image.svelte.d.ts +1 -1
  24. package/dist/components/image/Overlay.svelte +36 -0
  25. package/dist/components/image/Overlay.svelte.d.ts +8 -0
  26. package/dist/components/package/Package.stories.svelte +10 -21
  27. package/dist/components/package/Package.svelte +8 -35
  28. package/dist/components/paywall/Node.svelte +25 -32
  29. package/dist/components/paywall/Node.svelte.d.ts +4 -6
  30. package/dist/components/paywall/Paywall.stories.svelte +36 -140
  31. package/dist/components/paywall/Paywall.svelte +23 -7
  32. package/dist/components/paywall/Paywall.svelte.d.ts +4 -2
  33. package/dist/components/paywall/fixtures/override-paywall.d.ts +2 -0
  34. package/dist/components/paywall/fixtures/override-paywall.js +1310 -0
  35. package/dist/components/paywall/fixtures/stack-paywall.d.ts +2 -0
  36. package/dist/components/paywall/fixtures/stack-paywall.js +5223 -0
  37. package/dist/components/paywall/fixtures/variables.d.ts +261 -0
  38. package/dist/components/paywall/fixtures/variables.js +262 -0
  39. package/dist/components/paywall/paywall-utils.d.ts +1 -1
  40. package/dist/components/purchase-button/PurchaseButton.stories.svelte +10 -21
  41. package/dist/components/purchase-button/PurchaseButton.svelte +2 -27
  42. package/dist/components/stack/Stack.stories.svelte +2354 -978
  43. package/dist/components/stack/Stack.svelte +116 -134
  44. package/dist/components/stack/Stack.svelte.d.ts +8 -2
  45. package/dist/components/stack/stack-utils.d.ts +10 -30
  46. package/dist/components/stack/stack-utils.js +77 -255
  47. package/dist/components/text/Text.svelte +3 -37
  48. package/dist/components/text/Text.svelte.d.ts +1 -2
  49. package/dist/components/text/TextNode.stories.svelte +10 -36
  50. package/dist/components/text/TextNode.svelte +25 -28
  51. package/dist/components/text/TextNode.svelte.d.ts +1 -1
  52. package/dist/components/text/text-utils.d.ts +4 -9
  53. package/dist/components/text/text-utils.js +32 -117
  54. package/dist/components/timeline/Timeline.stories.svelte +640 -251
  55. package/dist/components/timeline/Timeline.svelte +42 -28
  56. package/dist/components/timeline/Timeline.svelte.d.ts +1 -1
  57. package/dist/components/timeline/TimelineItem.svelte +80 -112
  58. package/dist/components/timeline/TimelineItem.svelte.d.ts +6 -2
  59. package/dist/components/timeline/timeline-utils.d.ts +24 -6
  60. package/dist/components/timeline/timeline-utils.js +21 -113
  61. package/dist/index.d.ts +3 -2
  62. package/dist/index.js +3 -2
  63. package/dist/stores/color-mode.d.ts +1 -1
  64. package/dist/stores/paywall.d.ts +5 -2
  65. package/dist/stores/selected.d.ts +5 -0
  66. package/dist/stores/selected.js +12 -0
  67. package/dist/stores/variables.d.ts +1 -1
  68. package/dist/stores/variables.js +0 -1
  69. package/dist/stories/component-decorator.d.ts +2 -0
  70. package/dist/stories/component-decorator.js +12 -0
  71. package/dist/stories/fixtures.d.ts +6 -3
  72. package/dist/stories/fixtures.js +5214 -4422
  73. package/dist/stories/paywall-decorator.js +6 -0
  74. package/dist/stories/variables-decorator.d.ts +1 -1
  75. package/dist/stories/viewport-decorator.d.ts +2 -0
  76. package/dist/stories/viewport-decorator.js +8 -0
  77. package/dist/stories/viewport-wrapper.svelte +55 -0
  78. package/dist/stories/viewport-wrapper.svelte.d.ts +10 -0
  79. package/dist/stories/with-layout.d.ts +2 -10
  80. package/dist/stories/with-layout.js +3 -5
  81. package/dist/types/alignment.d.ts +5 -3
  82. package/dist/types/background.d.ts +6 -5
  83. package/dist/types/base.d.ts +7 -0
  84. package/dist/types/colors.d.ts +4 -4
  85. package/dist/types/component.d.ts +7 -2
  86. package/dist/types/components/button.d.ts +6 -1
  87. package/dist/types/components/carousel.d.ts +51 -0
  88. package/dist/types/components/carousel.js +1 -0
  89. package/dist/types/components/footer.d.ts +2 -1
  90. package/dist/types/components/icon.d.ts +28 -0
  91. package/dist/types/components/icon.js +1 -0
  92. package/dist/types/components/image.d.ts +20 -0
  93. package/dist/types/components/image.js +1 -0
  94. package/dist/types/components/package.d.ts +2 -1
  95. package/dist/types/components/purchase-button.d.ts +2 -1
  96. package/dist/types/components/stack.d.ts +32 -0
  97. package/dist/types/components/stack.js +1 -0
  98. package/dist/types/components/text.d.ts +20 -0
  99. package/dist/types/components/text.js +1 -0
  100. package/dist/types/components/timeline.d.ts +35 -0
  101. package/dist/types/components/timeline.js +1 -0
  102. package/dist/types/localization.d.ts +2 -1
  103. package/dist/types/media.d.ts +4 -3
  104. package/dist/types/overrides.d.ts +48 -0
  105. package/dist/types/overrides.js +1 -0
  106. package/dist/types/paywall.d.ts +27 -0
  107. package/dist/types/paywall.js +1 -0
  108. package/dist/types/ui-config.d.ts +20 -0
  109. package/dist/types/ui-config.js +1 -0
  110. package/dist/types/variables.d.ts +13 -0
  111. package/dist/types/variables.js +10 -0
  112. package/dist/types.d.ts +17 -9
  113. package/dist/ui/atoms/typography.stories.svelte +1 -27
  114. package/dist/ui/molecules/button.stories.svelte +3 -8
  115. package/dist/ui/theme/colors.d.ts +0 -6
  116. package/dist/ui/theme/colors.js +1 -1
  117. package/dist/ui/theme/text.d.ts +3 -4
  118. package/dist/ui/theme/utils.d.ts +0 -10
  119. package/dist/ui/theme/utils.js +5 -5
  120. package/dist/utils/background-utils.d.ts +4 -0
  121. package/dist/utils/background-utils.js +39 -0
  122. package/dist/utils/base-utils.d.ts +18 -0
  123. package/dist/utils/base-utils.js +124 -0
  124. package/dist/utils/constants.d.ts +2 -2
  125. package/dist/utils/constants.js +6 -1
  126. package/dist/utils/font-utils.d.ts +4 -0
  127. package/dist/utils/font-utils.js +47 -0
  128. package/dist/utils/style-utils.d.ts +7 -120
  129. package/dist/utils/style-utils.js +29 -304
  130. package/dist/utils/variable-utils.d.ts +1 -22
  131. package/dist/utils/variable-utils.js +28 -24
  132. package/dist/web-components/index.css +1 -1
  133. package/dist/web-components/index.js +1435 -980
  134. package/package.json +36 -26
  135. package/dist/components/button/button-utils.d.ts +0 -2
  136. package/dist/components/button/button-utils.js +0 -19
  137. package/dist/components/image/image-utils.d.ts +0 -19
  138. package/dist/components/image/image-utils.js +0 -33
  139. package/dist/components/purchase-button/purchase-button-utils.d.ts +0 -2
  140. package/dist/components/purchase-button/purchase-button-utils.js +0 -20
  141. package/dist/data/entities.d.ts +0 -162
  142. package/dist/stories/meta-templates.d.ts +0 -12
  143. package/dist/stories/meta-templates.js +0 -155
  144. /package/dist/{data/entities.js → types/base.js} +0 -0
@@ -1,157 +1,139 @@
1
1
  <script lang="ts">
2
2
  import Node from "../paywall/Node.svelte";
3
- import {
4
- getBadgeStyles,
5
- getStackBadgeTextStyles,
6
- getStackComponentStyles,
7
- getZStackChildStyles,
8
- } from "./stack-utils";
9
- import Text from "../text/Text.svelte";
10
- import type { StackProps } from "../../data/entities";
11
3
  import { getColorModeContext } from "../../stores/color-mode";
12
- import { getLocalizationContext } from "../../stores/localization";
13
- import { getVariablesContext } from "../../stores/variables";
14
- import { replaceVariables } from "../../utils/variable-utils";
4
+ import { getSelectedStateContext } from "../../stores/selected";
5
+ import type { StackProps } from "../../types/components/stack";
6
+ import { mapBackground } from "../../utils/background-utils";
7
+ import {
8
+ css,
9
+ mapBorder,
10
+ mapBorderRadius,
11
+ mapShadow,
12
+ mapSize,
13
+ mapSpacing,
14
+ px,
15
+ } from "../../utils/base-utils";
16
+ import { getActiveStateProps } from "../../utils/style-utils";
17
+ import type { Snippet } from "svelte";
18
+ import { mapBadge, mapDimension, mapLayerAlignment } from "./stack-utils";
19
+
20
+ interface MiscProps {
21
+ onclick?: () => void;
22
+ children?: Snippet;
23
+ }
24
+
25
+ const props: StackProps & MiscProps = $props();
26
+ const { onclick, children } = props;
15
27
 
16
- const { id, components, badge, zStackChildStyles, ...restProps }: StackProps =
17
- $props();
28
+ const selectedState = getSelectedStateContext();
29
+ const {
30
+ components,
31
+ size,
32
+ dimension,
33
+ spacing,
34
+ margin,
35
+ padding,
36
+ background_color,
37
+ background,
38
+ border,
39
+ shape,
40
+ shadow,
41
+ badge,
42
+ } = $derived.by(() => {
43
+ return {
44
+ ...props,
45
+ ...getActiveStateProps($selectedState, props.overrides),
46
+ };
47
+ });
18
48
 
19
49
  const getColorMode = getColorModeContext();
20
50
  const colorMode = $derived(getColorMode());
21
51
 
22
- const stackStyles = $derived(
23
- getStackComponentStyles(colorMode, {
24
- id,
25
- components,
26
- zStackChildStyles,
27
- ...restProps,
28
- }),
29
- );
30
- const badgeStyles = $derived(
31
- getBadgeStyles(colorMode, {
32
- id,
33
- components,
34
- badge,
35
- ...restProps,
52
+ const style = $derived(
53
+ css({
54
+ display: "flex",
55
+ position: "relative",
56
+ width: mapSize(size.width),
57
+ height: mapSize(size.height),
58
+ ...mapDimension(dimension),
59
+ gap: px(spacing),
60
+ margin: mapSpacing(margin),
61
+ padding: mapSpacing(padding),
62
+ ...mapBackground(colorMode, background_color, background),
63
+ border: mapBorder(colorMode, border),
64
+ "border-radius": mapBorderRadius(shape),
65
+ "box-shadow": mapShadow(colorMode, shadow),
36
66
  }),
37
67
  );
38
68
 
39
- const zStackChildrenStyles = $derived(
40
- getZStackChildStyles({
41
- id,
42
- components,
43
- ...restProps,
44
- }),
45
- );
69
+ const getLayerStyle = (index: number): string => {
70
+ if (index === 0 || dimension.type !== "zlayer") {
71
+ return "";
72
+ }
46
73
 
47
- const variables = getVariablesContext();
48
- const { getLocalizedString } = getLocalizationContext();
49
- const label = $derived(
50
- replaceVariables(getLocalizedString(badge?.text_lid), $variables),
51
- );
74
+ const { justifyContent, alignItems } = mapLayerAlignment(
75
+ dimension.alignment,
76
+ );
77
+ return css({
78
+ position: "absolute",
79
+ inset: 0,
80
+ display: "flex",
81
+ "justify-content": justifyContent,
82
+ "align-items": alignItems,
83
+ "z-index": index + 1,
84
+ });
85
+ };
52
86
 
53
- const { tagToRender, textStyles } = $derived(
54
- getStackBadgeTextStyles(colorMode, {
55
- id,
56
- components,
57
- badge,
58
- ...restProps,
59
- }),
60
- );
87
+ const badgeStyle = $derived(css(mapBadge(badge, border?.width)));
61
88
  </script>
62
89
 
63
- <div {id} class="rc-pw-stack-wrapper" style={stackStyles}>
90
+ <svelte:element
91
+ this={onclick !== undefined ? "button" : "div"}
92
+ role={onclick !== undefined ? "button" : undefined}
93
+ {onclick}
94
+ {style}
95
+ class="stack"
96
+ >
64
97
  {#if badge}
65
- <span class="rc-pw-badge" style={badgeStyles}>
66
- <Text styleVariables={textStyles} component={tagToRender}>
67
- {label}
68
- </Text>
69
- </span>
98
+ <div style={badgeStyle}>
99
+ <Node nodeData={badge.stack} />
100
+ </div>
70
101
  {/if}
71
- <div class="rc-pw-stack">
72
- {#each components as component, index}
73
- {#if zStackChildrenStyles}
74
- <Node
75
- nodeData={component}
76
- componentState={restProps.componentState}
77
- zStackChildStyles={index > 0 ? zStackChildrenStyles : undefined}
78
- />
79
- {:else}
80
- <Node nodeData={component} componentState={restProps.componentState} />
81
- {/if}
102
+
103
+ {#if dimension.type === "zlayer"}
104
+ <div style="position: relative; width: 100%; height: 100%;">
105
+ {#each components as component, index}
106
+ <div style={getLayerStyle(index)}>
107
+ <Node nodeData={component} />
108
+ </div>
109
+ {/each}
110
+ </div>
111
+ {:else}
112
+ {#each components as component}
113
+ <Node nodeData={component} />
82
114
  {/each}
83
- </div>
84
- </div>
115
+ {/if}
116
+
117
+ {@render children?.()}
118
+ </svelte:element>
85
119
 
86
120
  <style>
87
- .rc-pw-stack-wrapper {
88
- display: block;
89
- box-sizing: border-box;
90
- width: var(--stack-width, unset);
91
- height: var(--stack-height, unset);
92
- box-shadow: var(--stack-shadow, none);
93
- background: var(--stack-background, unset);
94
- position: var(--stack-position, relative);
95
- transform: var(--stack-transform, initial);
96
- inset: var(--stack-inset, initial);
97
- margin-block-start: var(--stack-margin-block-start, 0);
98
- margin-inline-end: var(--stack-margin-inline-end, 0);
99
- margin-block-end: var(--stack-margin-block-end, 0);
100
- margin-inline-start: var(--stack-margin-inline-start, 0);
101
- border: var(--stack-border, none);
102
- border-end-start-radius: var(--stack-border-end-start-radius, 0px);
103
- border-end-end-radius: var(--stack-border-end-end-radius, 0px);
104
- border-start-start-radius: var(--stack-border-start-start-radius, 0px);
105
- border-start-end-radius: var(--stack-border-start-end-radius, 0px);
106
- }
121
+ .stack {
122
+ appearance: none;
123
+ position: relative;
107
124
 
108
- .rc-pw-stack {
109
- background: none;
110
- overflow: hidden;
111
- box-sizing: border-box;
112
- width: 100%;
113
- height: 100%;
114
- display: flex;
115
- gap: var(--stack-spacing, 0);
116
- flex: var(--stack-flex, 0 1 auto);
117
- flex-direction: var(--stack-direction, unset);
118
- justify-content: var(--stack-distribution, flex-start);
119
- align-items: var(--stack-alignment, flex-start);
120
- padding-block-start: var(--stack-padding-block-start, 0);
121
- padding-inline-end: var(--stack-padding-inline-end, 0);
122
- padding-block-end: var(--stack-padding-block-end, 0);
123
- padding-inline-start: var(--stack-padding-inline-start, 0);
124
- }
125
- .rc-pw-badge {
126
- box-sizing: border-box;
127
- font-family: var(--stack-badge-font-family, sans-serif);
128
- position: absolute;
129
- inset: var(--stack-badge-inset, unset);
130
- transform: var(--stack-badge-transform, initial);
131
- margin-block-start: var(--stack-badge-margin-block-start, 0px);
132
- margin-inline-end: var(--stack-badge-margin-inline-end, 0px);
133
- margin-block-end: var(--stack-badge-margin-block-end, 0px);
134
- margin-inline-start: var(--stack-badge-margin-inline-start, 0px);
135
- padding-block-start: var(--stack-badge-padding-block-start, 0px);
136
- padding-inline-end: var(--stack-badge-padding-inline-end, 0px);
137
- padding-block-end: var(--stack-badge-padding-block-end, 0px);
138
- padding-inline-start: var(--stack-badge-padding-inline-start, 0px);
139
- background: var(--stack-badge-background, initial);
140
- color: var(--stack-badge-text-color, inherit);
141
- border: var(--stack-badge-border, none);
142
- border-end-start-radius: var(--stack-badge-border-end-start-radius, 0px);
143
- border-end-end-radius: var(--stack-badge-border-end-end-radius, 0px);
144
- border-start-start-radius: var(
145
- --stack-badge-border-start-start-radius,
146
- 0px
147
- );
148
- border-start-end-radius: var(--stack-badge-border-start-end-radius, 0px);
149
- box-shadow: var(--stack-badge-shadow, none);
150
- display: flex;
151
- align-items: center;
152
- justify-content: center;
153
- width: var(--stack-badge-badge-width, max-content);
154
- height: var(--stack-badge-badge-height, max-content);
155
- z-index: var(--stack-badge-z-index, 1);
125
+ &[role="button"] {
126
+ cursor: pointer;
127
+ }
128
+
129
+ &::before {
130
+ content: "";
131
+ position: absolute;
132
+ top: 0;
133
+ left: 0;
134
+ width: 100%;
135
+ height: 100%;
136
+ background: var(--overlay);
137
+ }
156
138
  }
157
139
  </style>
@@ -1,4 +1,10 @@
1
- import type { StackProps } from "../../data/entities";
2
- declare const Stack: import("svelte").Component<StackProps, {}, "">;
1
+ import type { StackProps } from "../../types/components/stack";
2
+ import type { Snippet } from "svelte";
3
+ interface MiscProps {
4
+ onclick?: () => void;
5
+ children?: Snippet;
6
+ }
7
+ type $$ComponentProps = StackProps & MiscProps;
8
+ declare const Stack: import("svelte").Component<$$ComponentProps, {}, "">;
3
9
  type Stack = ReturnType<typeof Stack>;
4
10
  export default Stack;
@@ -1,31 +1,11 @@
1
- import type { StackProps } from "../../data/entities";
2
- import type { ColorMode } from "../../types";
3
- /**
4
- * Generates comprehensive styles for stack components by combining component, dimension and size styles
5
- * @param props - Stack component properties including background, spacing, size, border etc.
6
- * @returns CSS style variables object with all stack-specific styles
7
- */
8
- export declare const getStackComponentStyles: (colorMode: ColorMode, props: StackProps) => string;
9
- /**
10
- * Generates styles for badge component within a stack
11
- * @param props - Stack component properties containing badge configuration
12
- * @returns CSS style object with badge-specific styles including positioning, dimensions and appearance
13
- */
14
- export declare function getBadgeStyles(colorMode: ColorMode, props: StackProps): string;
15
- /**
16
- * Generates text styles and HTML tag for a stack's badge component
17
- * @param props - Stack component properties containing badge configuration
18
- * @returns Object containing:
19
- * - tagToRender: HTML tag to use for the badge text
20
- * - textStyles: CSS styles string for the badge text
21
- */
22
- export declare function getStackBadgeTextStyles(colorMode: ColorMode, props: StackProps): {
23
- tagToRender: string;
24
- textStyles: string;
25
- };
26
- export declare function getZStackChildStyles(props: StackProps): ZStackChildStyles | undefined;
27
- export type ZStackChildStyles = {
28
- "--inset": string;
29
- "--transform": string;
30
- "--position": string;
1
+ import type { Dimension, ZAlignment } from "../../types/alignment";
2
+ import type { Badge } from "../../types/components/stack";
3
+ import { type CSS } from "../../utils/base-utils";
4
+ export declare function mapDimension(dimension: Dimension): Record<string, string>;
5
+ type JustifyAlign = {
6
+ justifyContent: string;
7
+ alignItems: string;
31
8
  };
9
+ export declare function mapLayerAlignment(alignment: ZAlignment): JustifyAlign;
10
+ export declare function mapBadge(badge?: Badge | null, parentBorderWidth?: number): CSS;
11
+ export {};