@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
@@ -1,29 +1,18 @@
1
1
  <script lang="ts">
2
- import type { PurchaseButtonProps } from "../../data/entities";
2
+ import { getPurchaseButtonStyles } from "./purchase-button-utils";
3
3
  import Stack from "../stack/Stack.svelte";
4
4
  import { ButtonDeprecated } from "../../index";
5
- import { getPurchaseButtonStyles } from "./purchase-button-utils";
5
+ import { getPaywallContext } from "../../stores/paywall";
6
+ import type { PurchaseButtonProps } from "../../types/components/purchase-button";
7
+
8
+ const { stack, zStackChildStyles, ...restProps }: PurchaseButtonProps =
9
+ $props();
6
10
 
7
- const {
8
- stack,
9
- labels,
10
- onAction,
11
- purchaseState,
12
- variableDictionary,
13
- zStackChildStyles,
14
- ...restProps
15
- }: PurchaseButtonProps = $props();
16
- const handleClick = () => {
17
- onAction && onAction({ type: "purchase" });
18
- };
11
+ const { onPurchase } = getPaywallContext();
19
12
 
20
13
  const buttonStyles = $derived(
21
14
  getPurchaseButtonStyles({
22
15
  stack,
23
- labels,
24
- onAction,
25
- purchaseState,
26
- variableDictionary,
27
16
  zStackChildStyles,
28
17
  ...restProps,
29
18
  }),
@@ -31,11 +20,11 @@
31
20
  </script>
32
21
 
33
22
  <ButtonDeprecated
34
- onclick={handleClick}
23
+ onclick={onPurchase}
35
24
  class="rc-pw-purchase-button"
36
25
  style={buttonStyles}
37
26
  >
38
- <Stack {...stack} {labels} {purchaseState} {variableDictionary} />
27
+ <Stack {...stack} />
39
28
  </ButtonDeprecated>
40
29
 
41
30
  <style>
@@ -1,4 +1,4 @@
1
- import type { PurchaseButtonProps } from "../../data/entities";
1
+ import type { PurchaseButtonProps } from "../../types/components/purchase-button";
2
2
  declare const PurchaseButton: import("svelte").Component<PurchaseButtonProps, {}, "">;
3
3
  type PurchaseButton = ReturnType<typeof PurchaseButton>;
4
4
  export default PurchaseButton;
@@ -1,2 +1,2 @@
1
- import type { PurchaseButtonProps } from "../../data/entities";
1
+ import type { PurchaseButtonProps } from "../../types/components/purchase-button";
2
2
  export declare function getPurchaseButtonStyles({ stack, zStackChildStyles, }: PurchaseButtonProps): string;
@@ -1,6 +1,8 @@
1
1
  <script module lang="ts">
2
- import { defineMeta } from "@storybook/addon-svelte-csf";
3
2
  import Stack from "./Stack.svelte";
3
+ import type { StackProps, TextNodeProps } from "../../data/entities";
4
+ import { localizations } from "../../stories/fixtures";
5
+ import { localizationDecorator } from "../../stories/localization-decorator";
4
6
  import {
5
7
  borderStoryMeta,
6
8
  getColorStoryMeta,
@@ -9,19 +11,24 @@
9
11
  sizeStoryMeta,
10
12
  stackDimensionStoryMeta,
11
13
  } from "../../stories/meta-templates";
12
- import { labelsData as labels } from "../../stories/fixtures";
13
- import type { PurchaseState } from "../../data/state";
14
- import type { PaywallComponent } from "../../data/entities";
15
14
  import {
16
15
  DEFAULT_BACKGROUND_COLOR,
17
- DEFAULT_COLOR_MODE,
18
16
  DEFAULT_TEXT_COLOR,
19
17
  } from "../../utils/constants";
18
+ import { defineMeta } from "@storybook/addon-svelte-csf";
19
+
20
+ const defaultLocale = Object.keys(localizations)[0];
20
21
 
21
22
  const { Story } = defineMeta({
22
23
  title: "Components/Stack",
23
24
  component: Stack,
24
25
  tags: ["autodocs"],
26
+ decorators: [
27
+ localizationDecorator({
28
+ defaultLocale,
29
+ localizations,
30
+ }),
31
+ ],
25
32
  argTypes: {
26
33
  dimension: stackDimensionStoryMeta,
27
34
  spacing: {
@@ -37,13 +44,7 @@
37
44
  },
38
45
  });
39
46
 
40
- const purchaseState: PurchaseState = {
41
- locale: "en_US",
42
- defaultLocale: "en_US",
43
- colorMode: DEFAULT_COLOR_MODE,
44
- };
45
-
46
- const components: PaywallComponent[] = [
47
+ const components = [
47
48
  {
48
49
  type: "text",
49
50
  size: {
@@ -52,14 +53,12 @@
52
53
  },
53
54
  horizontal_alignment: "center",
54
55
  name: "Item 1",
55
- components: [],
56
56
  id: "1",
57
57
  text_lid: "id1",
58
58
  background_color: {
59
59
  dark: { type: "alias", value: "transparent" },
60
60
  light: { type: "alias", value: "transparent" },
61
61
  },
62
- purchaseState,
63
62
  },
64
63
  {
65
64
  type: "text",
@@ -69,14 +68,12 @@
69
68
  },
70
69
  horizontal_alignment: "center",
71
70
  name: "Item 2",
72
- components: [],
73
71
  id: "2",
74
72
  text_lid: "id2",
75
73
  background_color: {
76
74
  dark: { type: "alias", value: "transparent" },
77
75
  light: { type: "alias", value: "transparent" },
78
76
  },
79
- purchaseState,
80
77
  },
81
78
  {
82
79
  type: "text",
@@ -86,16 +83,14 @@
86
83
  },
87
84
  horizontal_alignment: "center",
88
85
  name: "Item 3",
89
- components: [],
90
86
  id: "3",
91
87
  text_lid: "id3",
92
88
  background_color: {
93
89
  dark: { type: "alias", value: "transparent" },
94
90
  light: { type: "alias", value: "transparent" },
95
91
  },
96
- purchaseState,
97
92
  },
98
- ];
93
+ ] as unknown as TextNodeProps[];
99
94
  </script>
100
95
 
101
96
  <!-- Vertical Stack -->
@@ -103,9 +98,7 @@
103
98
  name="Vertical Stack"
104
99
  args={{
105
100
  type: "stack",
106
- purchaseState,
107
101
  size: { width: { type: "fill" }, height: { type: "fill" } },
108
- labels,
109
102
  dimension: {
110
103
  type: "vertical",
111
104
  alignment: "center",
@@ -125,13 +118,11 @@
125
118
  name="Horizontal Stack"
126
119
  args={{
127
120
  type: "stack",
128
- purchaseState,
129
121
  dimension: {
130
122
  type: "horizontal",
131
123
  alignment: "center",
132
124
  distribution: "space_between",
133
125
  },
134
- labels,
135
126
  components,
136
127
  spacing: 16,
137
128
  padding: { top: 16, trailing: 16, bottom: 16, leading: 16 },
@@ -147,13 +138,11 @@
147
138
  name="Space Around"
148
139
  args={{
149
140
  type: "stack",
150
- purchaseState,
151
141
  dimension: {
152
142
  type: "horizontal",
153
143
  alignment: "center",
154
144
  distribution: "space_around",
155
145
  },
156
- labels,
157
146
  components,
158
147
  spacing: 16,
159
148
  padding: { top: 16, trailing: 16, bottom: 16, leading: 16 },
@@ -169,14 +158,12 @@
169
158
  name="Background Colors"
170
159
  args={{
171
160
  type: "stack",
172
- purchaseState,
173
161
  dimension: {
174
162
  type: "vertical",
175
163
  alignment: "center",
176
164
  distribution: "start",
177
165
  },
178
166
  components,
179
- labels,
180
167
  background_color: {
181
168
  light: { type: "hex", value: "#C8E6FF" },
182
169
  dark: { type: "hex", value: "#C8E6FF" },
@@ -192,14 +179,12 @@
192
179
  name="Border Styles"
193
180
  args={{
194
181
  type: "stack",
195
- purchaseState,
196
182
  dimension: {
197
183
  type: "vertical",
198
184
  alignment: "center",
199
185
  distribution: "start",
200
186
  },
201
187
  components,
202
- labels,
203
188
  border: {
204
189
  width: 2,
205
190
  color: {
@@ -227,14 +212,12 @@
227
212
  name="Rounded Corners"
228
213
  args={{
229
214
  type: "stack",
230
- purchaseState,
231
215
  dimension: {
232
216
  type: "vertical",
233
217
  alignment: "center",
234
218
  distribution: "start",
235
219
  },
236
220
  components,
237
- labels,
238
221
  shape: {
239
222
  type: "rectangle",
240
223
  corners: {
@@ -259,14 +242,12 @@
259
242
  name="Fixed Size"
260
243
  args={{
261
244
  type: "stack",
262
- purchaseState,
263
245
  dimension: {
264
246
  type: "vertical",
265
247
  alignment: "center",
266
248
  distribution: "start",
267
249
  },
268
250
  components,
269
- labels,
270
251
  size: {
271
252
  width: { type: "fixed", value: 300 },
272
253
  height: { type: "fixed", value: 200 },
@@ -300,8 +281,6 @@
300
281
  distribution: "start",
301
282
  },
302
283
  components,
303
- purchaseState,
304
- labels,
305
284
  border: {
306
285
  width: 2,
307
286
  color: {
@@ -328,7 +307,6 @@
328
307
  name="Badge - Nested"
329
308
  args={{
330
309
  type: "stack",
331
- purchaseState,
332
310
  dimension: {
333
311
  type: "zlayer",
334
312
  alignment: "center",
@@ -336,8 +314,6 @@
336
314
  components: [
337
315
  {
338
316
  type: "stack",
339
- labels,
340
- purchaseState,
341
317
  dimension: {
342
318
  type: "zlayer",
343
319
  alignment: "center",
@@ -352,8 +328,6 @@
352
328
  },
353
329
  {
354
330
  type: "stack",
355
- labels,
356
- purchaseState,
357
331
  dimension: {
358
332
  type: "zlayer",
359
333
  alignment: "center",
@@ -395,8 +369,6 @@
395
369
  },
396
370
  {
397
371
  type: "stack",
398
- labels,
399
- purchaseState,
400
372
  dimension: {
401
373
  type: "zlayer",
402
374
  alignment: "center",
@@ -438,8 +410,6 @@
438
410
  },
439
411
  {
440
412
  type: "stack",
441
- labels,
442
- purchaseState,
443
413
  dimension: {
444
414
  type: "zlayer",
445
415
  alignment: "center",
@@ -481,8 +451,6 @@
481
451
  },
482
452
  {
483
453
  type: "stack",
484
- labels,
485
- purchaseState,
486
454
  dimension: {
487
455
  type: "zlayer",
488
456
  alignment: "center",
@@ -524,8 +492,6 @@
524
492
  },
525
493
  {
526
494
  type: "stack",
527
- labels,
528
- purchaseState,
529
495
  dimension: {
530
496
  type: "zlayer",
531
497
  alignment: "center",
@@ -567,8 +533,6 @@
567
533
  },
568
534
  {
569
535
  type: "stack",
570
- labels,
571
- purchaseState,
572
536
  dimension: {
573
537
  type: "zlayer",
574
538
  alignment: "center",
@@ -610,8 +574,6 @@
610
574
  },
611
575
  {
612
576
  type: "stack",
613
- labels,
614
- purchaseState,
615
577
  dimension: {
616
578
  type: "zlayer",
617
579
  alignment: "center",
@@ -653,8 +615,6 @@
653
615
  },
654
616
  {
655
617
  type: "stack",
656
- labels,
657
- purchaseState,
658
618
  dimension: {
659
619
  type: "zlayer",
660
620
  alignment: "center",
@@ -694,8 +654,7 @@
694
654
  },
695
655
  },
696
656
  },
697
- ],
698
- labels,
657
+ ] as unknown as StackProps[],
699
658
  border: {
700
659
  width: 2,
701
660
  color: {
@@ -724,7 +683,6 @@
724
683
  name="Badge - Overlaid"
725
684
  args={{
726
685
  type: "stack",
727
- purchaseState,
728
686
  dimension: {
729
687
  type: "zlayer",
730
688
  alignment: "center",
@@ -732,8 +690,6 @@
732
690
  components: [
733
691
  {
734
692
  type: "stack",
735
- labels,
736
- purchaseState,
737
693
  dimension: {
738
694
  type: "zlayer",
739
695
  alignment: "center",
@@ -748,8 +704,6 @@
748
704
  },
749
705
  {
750
706
  type: "stack",
751
- labels,
752
- purchaseState,
753
707
  dimension: {
754
708
  type: "zlayer",
755
709
  alignment: "center",
@@ -791,8 +745,6 @@
791
745
  },
792
746
  {
793
747
  type: "stack",
794
- labels,
795
- purchaseState,
796
748
  dimension: {
797
749
  type: "zlayer",
798
750
  alignment: "center",
@@ -834,8 +786,6 @@
834
786
  },
835
787
  {
836
788
  type: "stack",
837
- labels,
838
- purchaseState,
839
789
  dimension: {
840
790
  type: "zlayer",
841
791
  alignment: "center",
@@ -877,8 +827,6 @@
877
827
  },
878
828
  {
879
829
  type: "stack",
880
- labels,
881
- purchaseState,
882
830
  dimension: {
883
831
  type: "zlayer",
884
832
  alignment: "center",
@@ -920,8 +868,6 @@
920
868
  },
921
869
  {
922
870
  type: "stack",
923
- labels,
924
- purchaseState,
925
871
  dimension: {
926
872
  type: "zlayer",
927
873
  alignment: "center",
@@ -963,8 +909,6 @@
963
909
  },
964
910
  {
965
911
  type: "stack",
966
- labels,
967
- purchaseState,
968
912
  dimension: {
969
913
  type: "zlayer",
970
914
  alignment: "center",
@@ -1004,8 +948,7 @@
1004
948
  },
1005
949
  },
1006
950
  },
1007
- ],
1008
- labels,
951
+ ] as unknown as StackProps[],
1009
952
  border: {
1010
953
  width: 2,
1011
954
  color: {
@@ -1034,7 +977,6 @@
1034
977
  name="Badge - edge-to-edge top centered"
1035
978
  args={{
1036
979
  type: "stack",
1037
- purchaseState,
1038
980
  dimension: {
1039
981
  type: "vertical",
1040
982
  alignment: "center",
@@ -1045,7 +987,6 @@
1045
987
  dark: { type: "hex", value: DEFAULT_BACKGROUND_COLOR },
1046
988
  },
1047
989
  components,
1048
- labels,
1049
990
  border: {
1050
991
  width: 2,
1051
992
  color: {
@@ -1102,7 +1043,6 @@
1102
1043
  name="Badge - edge-to-edge bottom centered"
1103
1044
  args={{
1104
1045
  type: "stack",
1105
- purchaseState,
1106
1046
  dimension: {
1107
1047
  type: "vertical",
1108
1048
  alignment: "center",
@@ -1113,7 +1053,6 @@
1113
1053
  dark: { type: "hex", value: DEFAULT_BACKGROUND_COLOR },
1114
1054
  },
1115
1055
  components,
1116
- labels,
1117
1056
  border: {
1118
1057
  width: 2,
1119
1058
  color: {
@@ -1170,7 +1109,6 @@
1170
1109
  name="Badge - edge-to-edge side centered"
1171
1110
  args={{
1172
1111
  type: "stack",
1173
- purchaseState,
1174
1112
  dimension: {
1175
1113
  type: "zlayer",
1176
1114
  alignment: "center",
@@ -1181,8 +1119,6 @@
1181
1119
  components: [
1182
1120
  {
1183
1121
  type: "stack",
1184
- labels,
1185
- purchaseState,
1186
1122
  dimension: {
1187
1123
  type: "zlayer",
1188
1124
  alignment: "center",
@@ -1197,14 +1133,11 @@
1197
1133
  },
1198
1134
  {
1199
1135
  type: "stack",
1200
- labels,
1201
- purchaseState,
1202
1136
  dimension: {
1203
1137
  type: "zlayer",
1204
1138
  alignment: "center",
1205
1139
  },
1206
1140
  components: [],
1207
-
1208
1141
  border: {
1209
1142
  width: 2,
1210
1143
  color: {
@@ -1256,14 +1189,11 @@
1256
1189
  },
1257
1190
  {
1258
1191
  type: "stack",
1259
- labels,
1260
- purchaseState,
1261
1192
  dimension: {
1262
1193
  type: "zlayer",
1263
1194
  alignment: "center",
1264
1195
  },
1265
1196
  components: [],
1266
-
1267
1197
  border: {
1268
1198
  width: 2,
1269
1199
  color: {
@@ -1315,14 +1245,11 @@
1315
1245
  },
1316
1246
  {
1317
1247
  type: "stack",
1318
- labels,
1319
- purchaseState,
1320
1248
  dimension: {
1321
1249
  type: "zlayer",
1322
1250
  alignment: "center",
1323
1251
  },
1324
1252
  components: [],
1325
-
1326
1253
  border: {
1327
1254
  width: 2,
1328
1255
  color: {
@@ -1374,14 +1301,11 @@
1374
1301
  },
1375
1302
  {
1376
1303
  type: "stack",
1377
- labels,
1378
- purchaseState,
1379
1304
  dimension: {
1380
1305
  type: "zlayer",
1381
1306
  alignment: "center",
1382
1307
  },
1383
1308
  components: [],
1384
-
1385
1309
  border: {
1386
1310
  width: 2,
1387
1311
  color: {
@@ -1431,8 +1355,7 @@
1431
1355
  },
1432
1356
  },
1433
1357
  },
1434
- ],
1435
- labels,
1358
+ ] as unknown as StackProps[],
1436
1359
  border: {
1437
1360
  width: 2,
1438
1361
  color: {
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import type { StackProps } from "../../data/entities";
3
2
  import Node from "../paywall/Node.svelte";
4
3
  import {
5
4
  getBadgeStyles,
@@ -8,38 +7,30 @@
8
7
  getZStackChildStyles,
9
8
  } from "./stack-utils";
10
9
  import Text from "../text/Text.svelte";
11
- import { getLabelAndReplaceVariables } from "../../utils/variable-utils";
10
+ import type { StackProps } from "../../data/entities";
11
+ 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";
15
+
16
+ const { id, components, badge, zStackChildStyles, ...restProps }: StackProps =
17
+ $props();
12
18
 
13
- const {
14
- id,
15
- components,
16
- labels,
17
- onAction,
18
- purchaseState,
19
- variableDictionary,
20
- badge,
21
- zStackChildStyles,
22
- ...restProps
23
- }: StackProps = $props();
19
+ const getColorMode = getColorModeContext();
20
+ const colorMode = $derived(getColorMode());
24
21
 
25
22
  const stackStyles = $derived(
26
- getStackComponentStyles({
23
+ getStackComponentStyles(colorMode, {
27
24
  id,
28
25
  components,
29
- labels,
30
- onAction,
31
- purchaseState,
32
26
  zStackChildStyles,
33
27
  ...restProps,
34
28
  }),
35
29
  );
36
30
  const badgeStyles = $derived(
37
- getBadgeStyles({
31
+ getBadgeStyles(colorMode, {
38
32
  id,
39
33
  components,
40
- labels,
41
- onAction,
42
- purchaseState,
43
34
  badge,
44
35
  ...restProps,
45
36
  }),
@@ -49,30 +40,20 @@
49
40
  getZStackChildStyles({
50
41
  id,
51
42
  components,
52
- labels,
53
- onAction,
54
- purchaseState,
55
43
  ...restProps,
56
44
  }),
57
45
  );
46
+
47
+ const variables = getVariablesContext();
48
+ const { getLocalizedString } = getLocalizationContext();
58
49
  const label = $derived(
59
- getLabelAndReplaceVariables({
60
- defaultLocale: purchaseState.defaultLocale,
61
- locale: purchaseState.locale,
62
- labels,
63
- variableDictionary,
64
- text_lid: badge?.text_lid,
65
- }),
50
+ replaceVariables(getLocalizedString(badge?.text_lid), $variables),
66
51
  );
67
52
 
68
53
  const { tagToRender, textStyles } = $derived(
69
- getStackBadgeTextStyles({
54
+ getStackBadgeTextStyles(colorMode, {
70
55
  id,
71
56
  components,
72
- labels,
73
- onAction,
74
- purchaseState,
75
- variableDictionary,
76
57
  badge,
77
58
  ...restProps,
78
59
  }),
@@ -92,22 +73,11 @@
92
73
  {#if zStackChildrenStyles}
93
74
  <Node
94
75
  nodeData={component}
95
- {labels}
96
- {onAction}
97
- {purchaseState}
98
- {variableDictionary}
99
76
  componentState={restProps.componentState}
100
77
  zStackChildStyles={index > 0 ? zStackChildrenStyles : undefined}
101
78
  />
102
79
  {:else}
103
- <Node
104
- nodeData={component}
105
- {labels}
106
- {onAction}
107
- {purchaseState}
108
- {variableDictionary}
109
- componentState={restProps.componentState}
110
- />
80
+ <Node nodeData={component} componentState={restProps.componentState} />
111
81
  {/if}
112
82
  {/each}
113
83
  </div>
@@ -1,16 +1,17 @@
1
1
  import type { StackProps } from "../../data/entities";
2
+ import type { ColorMode } from "../../types";
2
3
  /**
3
4
  * Generates comprehensive styles for stack components by combining component, dimension and size styles
4
5
  * @param props - Stack component properties including background, spacing, size, border etc.
5
6
  * @returns CSS style variables object with all stack-specific styles
6
7
  */
7
- export declare const getStackComponentStyles: (props: StackProps) => string;
8
+ export declare const getStackComponentStyles: (colorMode: ColorMode, props: StackProps) => string;
8
9
  /**
9
10
  * Generates styles for badge component within a stack
10
11
  * @param props - Stack component properties containing badge configuration
11
12
  * @returns CSS style object with badge-specific styles including positioning, dimensions and appearance
12
13
  */
13
- export declare function getBadgeStyles(props: StackProps): string;
14
+ export declare function getBadgeStyles(colorMode: ColorMode, props: StackProps): string;
14
15
  /**
15
16
  * Generates text styles and HTML tag for a stack's badge component
16
17
  * @param props - Stack component properties containing badge configuration
@@ -18,7 +19,7 @@ export declare function getBadgeStyles(props: StackProps): string;
18
19
  * - tagToRender: HTML tag to use for the badge text
19
20
  * - textStyles: CSS styles string for the badge text
20
21
  */
21
- export declare function getStackBadgeTextStyles(props: StackProps): {
22
+ export declare function getStackBadgeTextStyles(colorMode: ColorMode, props: StackProps): {
22
23
  tagToRender: string;
23
24
  textStyles: string;
24
25
  };