@ttoss/react-billing 0.7.4 → 0.8.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ pnpm add @ttoss/react-billing
12
12
 
13
13
  ## Quick Start
14
14
 
15
- This package expects your app to be wrapped with `@ttoss/ui` `ThemeProvider`.
15
+ This package expects your app to be wrapped with `@ttoss/ui` `ThemeProvider` and `@ttoss/react-i18n` `I18nProvider` (a peer dependency). `SubscriptionPanel`'s status badges are translatable messages with English sources; `i18n/lang/pt-BR.json` ships the Portuguese translations, which `ttoss-i18n` picks up from your dependencies when you compile your app's catalogs.
16
16
 
17
17
  ### PlanCard
18
18
 
package/dist/index.cjs CHANGED
@@ -35,6 +35,7 @@ let _ttoss_react_icons = require("@ttoss/react-icons");
35
35
  let react = require("react");
36
36
  react = __toESM(react);
37
37
  let _ttoss_components = require("@ttoss/components");
38
+ let _ttoss_react_i18n = require("@ttoss/react-i18n");
38
39
 
39
40
  //#region src/components/planCard/PlanCardCtaSlot.tsx
40
41
  var PlanCardCtaSlot = ({
@@ -666,6 +667,28 @@ var SubscriptionPanelActionsSlot = ({
666
667
 
667
668
  //#endregion
668
669
  //#region src/components/subscriptionPanel/SubscriptionPanel.tsx
670
+ var messages = (0, _ttoss_react_i18n.defineMessages)({
671
+ statusActive: {
672
+ defaultMessage: "Active",
673
+ description: "Subscription panel status badge: the subscription is active."
674
+ },
675
+ statusInactive: {
676
+ defaultMessage: "Inactive",
677
+ description: "Subscription panel status badge: the subscription is inactive."
678
+ },
679
+ statusCancelled: {
680
+ defaultMessage: "Cancelled",
681
+ description: "Subscription panel status badge: the subscription was cancelled."
682
+ },
683
+ scheduledUpdate: {
684
+ defaultMessage: "Update scheduled",
685
+ description: "Subscription panel badge: a plan change is scheduled for the next cycle."
686
+ },
687
+ renewalCancelled: {
688
+ defaultMessage: "Renewal cancelled",
689
+ description: "Subscription panel badge: the subscription will not renew at the end of the cycle."
690
+ }
691
+ });
669
692
  /**
670
693
  * Renders a metric card based on its type.
671
694
  */
@@ -729,6 +752,9 @@ var SubscriptionPanel = ({
729
752
  metrics = [],
730
753
  isLoading = false
731
754
  }) => {
755
+ const {
756
+ intl
757
+ } = (0, _ttoss_react_i18n.useI18n)();
732
758
  if (isLoading)
733
759
  /**
734
760
  * use skeleton loader in the future here
@@ -773,26 +799,26 @@ var SubscriptionPanel = ({
773
799
  title: planName,
774
800
  frontTitle: price.interval ? `${price.value}/${price.interval}` : price.value,
775
801
  topBadges: [...(status.status === "active" ? [{
776
- label: "Ativo",
802
+ label: intl.formatMessage(messages.statusActive),
777
803
  variant: "positive",
778
804
  icon: "fluent:checkmark-circle-24-filled"
779
805
  }] : status.status === "inactive" ? [{
780
- label: "Inativo",
806
+ label: intl.formatMessage(messages.statusInactive),
781
807
  variant: "muted",
782
808
  icon: "fluent:dismiss-circle-24-filled"
783
809
  }] : [{
784
- label: "Cancelado",
810
+ label: intl.formatMessage(messages.statusCancelled),
785
811
  variant: "negative",
786
812
  icon: "fluent:error-circle-24-filled"
787
813
  }]), ...(status.interval ? [{
788
814
  label: status.interval,
789
815
  variant: "informative"
790
816
  }] : []), ...(status.hasScheduledUpdate ? [{
791
- label: "Alteração Agendada",
817
+ label: intl.formatMessage(messages.scheduledUpdate),
792
818
  variant: "informative",
793
819
  icon: "fluent:clock-24-regular"
794
820
  }] : []), ...(status.hasCancellation ? [{
795
- label: "Renovação Cancelada",
821
+ label: intl.formatMessage(messages.renewalCancelled),
796
822
  variant: "negative",
797
823
  icon: "fluent:dismiss-circle-24-regular"
798
824
  }] : [])],
package/dist/index.mjs CHANGED
@@ -4,6 +4,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  import { Icon } from "@ttoss/react-icons";
5
5
  import * as React from "react";
6
6
  import { EnhancedTitle, MetricCard } from "@ttoss/components";
7
+ import { defineMessages, useI18n } from "@ttoss/react-i18n";
7
8
 
8
9
  //#region src/components/planCard/PlanCardCtaSlot.tsx
9
10
  var PlanCardCtaSlot = ({
@@ -635,6 +636,43 @@ var SubscriptionPanelActionsSlot = ({
635
636
 
636
637
  //#endregion
637
638
  //#region src/components/subscriptionPanel/SubscriptionPanel.tsx
639
+ var messages = defineMessages({
640
+ statusActive: {
641
+ id: "vRSfVR",
642
+ defaultMessage: [{
643
+ "type": 0,
644
+ "value": "Active"
645
+ }]
646
+ },
647
+ statusInactive: {
648
+ id: "BSgyVr",
649
+ defaultMessage: [{
650
+ "type": 0,
651
+ "value": "Inactive"
652
+ }]
653
+ },
654
+ statusCancelled: {
655
+ id: "4Es6pi",
656
+ defaultMessage: [{
657
+ "type": 0,
658
+ "value": "Cancelled"
659
+ }]
660
+ },
661
+ scheduledUpdate: {
662
+ id: "AhCpt2",
663
+ defaultMessage: [{
664
+ "type": 0,
665
+ "value": "Update scheduled"
666
+ }]
667
+ },
668
+ renewalCancelled: {
669
+ id: "FvMOyQ",
670
+ defaultMessage: [{
671
+ "type": 0,
672
+ "value": "Renewal cancelled"
673
+ }]
674
+ }
675
+ });
638
676
  /**
639
677
  * Renders a metric card based on its type.
640
678
  */
@@ -698,6 +736,9 @@ var SubscriptionPanel = ({
698
736
  metrics = [],
699
737
  isLoading = false
700
738
  }) => {
739
+ const {
740
+ intl
741
+ } = useI18n();
701
742
  if (isLoading)
702
743
  /**
703
744
  * use skeleton loader in the future here
@@ -742,26 +783,26 @@ var SubscriptionPanel = ({
742
783
  title: planName,
743
784
  frontTitle: price.interval ? `${price.value}/${price.interval}` : price.value,
744
785
  topBadges: [...(status.status === "active" ? [{
745
- label: "Ativo",
786
+ label: intl.formatMessage(messages.statusActive),
746
787
  variant: "positive",
747
788
  icon: "fluent:checkmark-circle-24-filled"
748
789
  }] : status.status === "inactive" ? [{
749
- label: "Inativo",
790
+ label: intl.formatMessage(messages.statusInactive),
750
791
  variant: "muted",
751
792
  icon: "fluent:dismiss-circle-24-filled"
752
793
  }] : [{
753
- label: "Cancelado",
794
+ label: intl.formatMessage(messages.statusCancelled),
754
795
  variant: "negative",
755
796
  icon: "fluent:error-circle-24-filled"
756
797
  }]), ...(status.interval ? [{
757
798
  label: status.interval,
758
799
  variant: "informative"
759
800
  }] : []), ...(status.hasScheduledUpdate ? [{
760
- label: "Alteração Agendada",
801
+ label: intl.formatMessage(messages.scheduledUpdate),
761
802
  variant: "informative",
762
803
  icon: "fluent:clock-24-regular"
763
804
  }] : []), ...(status.hasCancellation ? [{
764
- label: "Renovação Cancelada",
805
+ label: intl.formatMessage(messages.renewalCancelled),
765
806
  variant: "negative",
766
807
  icon: "fluent:dismiss-circle-24-regular"
767
808
  }] : [])],
@@ -0,0 +1,186 @@
1
+ {
2
+ "0EjvY6": [
3
+ {
4
+ "type": 0,
5
+ "value": "∞"
6
+ }
7
+ ],
8
+ "0oVaj5": [
9
+ {
10
+ "type": 0,
11
+ "value": "Would you like to install our app?"
12
+ }
13
+ ],
14
+ "1DbX9V": [
15
+ {
16
+ "type": 0,
17
+ "value": "Near limit"
18
+ }
19
+ ],
20
+ "4+7L57": [
21
+ {
22
+ "type": 0,
23
+ "value": "No notifications"
24
+ }
25
+ ],
26
+ "4Es6pi": [
27
+ {
28
+ "type": 0,
29
+ "value": "Cancelled"
30
+ }
31
+ ],
32
+ "4NwCn9": [
33
+ {
34
+ "type": 0,
35
+ "value": "Reached limit"
36
+ }
37
+ ],
38
+ "AhCpt2": [
39
+ {
40
+ "type": 0,
41
+ "value": "Update scheduled"
42
+ }
43
+ ],
44
+ "BSgyVr": [
45
+ {
46
+ "type": 0,
47
+ "value": "Inactive"
48
+ }
49
+ ],
50
+ "FvMOyQ": [
51
+ {
52
+ "type": 0,
53
+ "value": "Renewal cancelled"
54
+ }
55
+ ],
56
+ "G/yZLu": [
57
+ {
58
+ "type": 0,
59
+ "value": "Remove"
60
+ }
61
+ ],
62
+ "JEsxDw": [
63
+ {
64
+ "type": 0,
65
+ "value": "Uploading..."
66
+ }
67
+ ],
68
+ "UD/D6v": [
69
+ {
70
+ "type": 0,
71
+ "value": "Install"
72
+ }
73
+ ],
74
+ "WhMFgF": [
75
+ {
76
+ "type": 0,
77
+ "value": "Clear all"
78
+ }
79
+ ],
80
+ "XKyo5X": [
81
+ {
82
+ "type": 0,
83
+ "value": "File Upload"
84
+ }
85
+ ],
86
+ "dx4ZnR": [
87
+ {
88
+ "type": 1,
89
+ "value": "name"
90
+ },
91
+ {
92
+ "type": 0,
93
+ "value": " logo"
94
+ }
95
+ ],
96
+ "eRShvB": [
97
+ {
98
+ "type": 0,
99
+ "value": "Maximum files reached"
100
+ }
101
+ ],
102
+ "fDCMA6": [
103
+ {
104
+ "type": 0,
105
+ "value": "Select Files"
106
+ }
107
+ ],
108
+ "fOOwej": [
109
+ {
110
+ "type": 6,
111
+ "value": "max_files",
112
+ "options": {
113
+ "one": {
114
+ "value": [
115
+ {
116
+ "type": 0,
117
+ "value": "Up to "
118
+ },
119
+ {
120
+ "type": 7
121
+ },
122
+ {
123
+ "type": 0,
124
+ "value": " file"
125
+ }
126
+ ]
127
+ },
128
+ "other": {
129
+ "value": [
130
+ {
131
+ "type": 0,
132
+ "value": "Up to "
133
+ },
134
+ {
135
+ "type": 7
136
+ },
137
+ {
138
+ "type": 0,
139
+ "value": " files"
140
+ }
141
+ ]
142
+ }
143
+ },
144
+ "offset": 0,
145
+ "pluralType": "cardinal"
146
+ }
147
+ ],
148
+ "gy0Ynb": [
149
+ {
150
+ "type": 0,
151
+ "value": "Click or drag files here"
152
+ }
153
+ ],
154
+ "oYpm71": [
155
+ {
156
+ "type": 0,
157
+ "value": "of "
158
+ },
159
+ {
160
+ "type": 1,
161
+ "value": "max"
162
+ }
163
+ ],
164
+ "rskBv4": [
165
+ {
166
+ "type": 0,
167
+ "value": "Unlimited"
168
+ }
169
+ ],
170
+ "vRSfVR": [
171
+ {
172
+ "type": 0,
173
+ "value": "Active"
174
+ }
175
+ ],
176
+ "zr0OS6": [
177
+ {
178
+ "type": 1,
179
+ "value": "percentage"
180
+ },
181
+ {
182
+ "type": 0,
183
+ "value": "% used"
184
+ }
185
+ ]
186
+ }
@@ -0,0 +1,186 @@
1
+ {
2
+ "0EjvY6": [
3
+ {
4
+ "type": 0,
5
+ "value": "∞"
6
+ }
7
+ ],
8
+ "0oVaj5": [
9
+ {
10
+ "type": 0,
11
+ "value": "Deseja instalar o nosso aplicativo?"
12
+ }
13
+ ],
14
+ "1DbX9V": [
15
+ {
16
+ "type": 0,
17
+ "value": "Próximo do limite"
18
+ }
19
+ ],
20
+ "4+7L57": [
21
+ {
22
+ "type": 0,
23
+ "value": "Nenhuma notificação"
24
+ }
25
+ ],
26
+ "4Es6pi": [
27
+ {
28
+ "type": 0,
29
+ "value": "Cancelado"
30
+ }
31
+ ],
32
+ "4NwCn9": [
33
+ {
34
+ "type": 0,
35
+ "value": "Limite atingido"
36
+ }
37
+ ],
38
+ "AhCpt2": [
39
+ {
40
+ "type": 0,
41
+ "value": "Alteração Agendada"
42
+ }
43
+ ],
44
+ "BSgyVr": [
45
+ {
46
+ "type": 0,
47
+ "value": "Inativo"
48
+ }
49
+ ],
50
+ "FvMOyQ": [
51
+ {
52
+ "type": 0,
53
+ "value": "Renovação Cancelada"
54
+ }
55
+ ],
56
+ "G/yZLu": [
57
+ {
58
+ "type": 0,
59
+ "value": "Remover"
60
+ }
61
+ ],
62
+ "JEsxDw": [
63
+ {
64
+ "type": 0,
65
+ "value": "Enviando..."
66
+ }
67
+ ],
68
+ "UD/D6v": [
69
+ {
70
+ "type": 0,
71
+ "value": "Instalar"
72
+ }
73
+ ],
74
+ "WhMFgF": [
75
+ {
76
+ "type": 0,
77
+ "value": "Limpar Tudo"
78
+ }
79
+ ],
80
+ "XKyo5X": [
81
+ {
82
+ "type": 0,
83
+ "value": "Upload de Arquivo"
84
+ }
85
+ ],
86
+ "dx4ZnR": [
87
+ {
88
+ "type": 0,
89
+ "value": "Logo de "
90
+ },
91
+ {
92
+ "type": 1,
93
+ "value": "name"
94
+ }
95
+ ],
96
+ "eRShvB": [
97
+ {
98
+ "type": 0,
99
+ "value": "Máximo de arquivos atingido"
100
+ }
101
+ ],
102
+ "fDCMA6": [
103
+ {
104
+ "type": 0,
105
+ "value": "Selecionar Arquivos"
106
+ }
107
+ ],
108
+ "fOOwej": [
109
+ {
110
+ "type": 6,
111
+ "value": "max_files",
112
+ "options": {
113
+ "one": {
114
+ "value": [
115
+ {
116
+ "type": 0,
117
+ "value": "Até "
118
+ },
119
+ {
120
+ "type": 7
121
+ },
122
+ {
123
+ "type": 0,
124
+ "value": " arquivo"
125
+ }
126
+ ]
127
+ },
128
+ "other": {
129
+ "value": [
130
+ {
131
+ "type": 0,
132
+ "value": "Até "
133
+ },
134
+ {
135
+ "type": 7
136
+ },
137
+ {
138
+ "type": 0,
139
+ "value": " arquivos"
140
+ }
141
+ ]
142
+ }
143
+ },
144
+ "offset": 0,
145
+ "pluralType": "cardinal"
146
+ }
147
+ ],
148
+ "gy0Ynb": [
149
+ {
150
+ "type": 0,
151
+ "value": "Clique ou arraste arquivos aqui"
152
+ }
153
+ ],
154
+ "oYpm71": [
155
+ {
156
+ "type": 0,
157
+ "value": "de "
158
+ },
159
+ {
160
+ "type": 1,
161
+ "value": "max"
162
+ }
163
+ ],
164
+ "rskBv4": [
165
+ {
166
+ "type": 0,
167
+ "value": "Ilimitado"
168
+ }
169
+ ],
170
+ "vRSfVR": [
171
+ {
172
+ "type": 0,
173
+ "value": "Ativo"
174
+ }
175
+ ],
176
+ "zr0OS6": [
177
+ {
178
+ "type": 1,
179
+ "value": "percentage"
180
+ },
181
+ {
182
+ "type": 0,
183
+ "value": "% usado"
184
+ }
185
+ ]
186
+ }
@@ -0,0 +1,105 @@
1
+ {
2
+ "4Es6pi": {
3
+ "defaultMessage": "Cancelled",
4
+ "description": "Subscription panel status badge: the subscription was cancelled."
5
+ },
6
+ "AhCpt2": {
7
+ "defaultMessage": "Update scheduled",
8
+ "description": "Subscription panel badge: a plan change is scheduled for the next cycle."
9
+ },
10
+ "BSgyVr": {
11
+ "defaultMessage": "Inactive",
12
+ "description": "Subscription panel status badge: the subscription is inactive."
13
+ },
14
+ "FvMOyQ": {
15
+ "defaultMessage": "Renewal cancelled",
16
+ "description": "Subscription panel badge: the subscription will not renew at the end of the cycle."
17
+ },
18
+ "vRSfVR": {
19
+ "defaultMessage": "Active",
20
+ "description": "Subscription panel status badge: the subscription is active."
21
+ },
22
+ "0EjvY6": {
23
+ "module": "@ttoss/components",
24
+ "defaultMessage": "∞",
25
+ "description": "Infinity symbol used when the maximum limit is unlimited."
26
+ },
27
+ "0oVaj5": {
28
+ "module": "@ttoss/components",
29
+ "defaultMessage": "Would you like to install our app?",
30
+ "description": "PWA install banner: the question offering installation."
31
+ },
32
+ "1DbX9V": {
33
+ "module": "@ttoss/components",
34
+ "defaultMessage": "Near limit",
35
+ "description": "Alert shown when usage is close to the limit."
36
+ },
37
+ "4+7L57": {
38
+ "module": "@ttoss/components",
39
+ "defaultMessage": "No notifications",
40
+ "description": "Notifications menu: shown when there is nothing to list."
41
+ },
42
+ "4NwCn9": {
43
+ "module": "@ttoss/components",
44
+ "defaultMessage": "Reached limit",
45
+ "description": "Alert shown when usage has reached or exceeded the limit."
46
+ },
47
+ "G/yZLu": {
48
+ "module": "@ttoss/components",
49
+ "defaultMessage": "Remove"
50
+ },
51
+ "JEsxDw": {
52
+ "module": "@ttoss/components",
53
+ "defaultMessage": "Uploading..."
54
+ },
55
+ "UD/D6v": {
56
+ "module": "@ttoss/components",
57
+ "defaultMessage": "Install",
58
+ "description": "PWA install banner: button that starts the installation."
59
+ },
60
+ "WhMFgF": {
61
+ "module": "@ttoss/components",
62
+ "defaultMessage": "Clear all",
63
+ "description": "Notifications menu: button clearing every notification."
64
+ },
65
+ "XKyo5X": {
66
+ "module": "@ttoss/components",
67
+ "defaultMessage": "File Upload"
68
+ },
69
+ "dx4ZnR": {
70
+ "module": "@ttoss/components",
71
+ "defaultMessage": "{name} logo",
72
+ "description": "OAuth consent: alt text for the requesting application logo."
73
+ },
74
+ "eRShvB": {
75
+ "module": "@ttoss/components",
76
+ "defaultMessage": "Maximum files reached"
77
+ },
78
+ "fDCMA6": {
79
+ "module": "@ttoss/components",
80
+ "defaultMessage": "Select Files"
81
+ },
82
+ "fOOwej": {
83
+ "module": "@ttoss/components",
84
+ "defaultMessage": "{max_files, plural, one {Up to # file} other {Up to # files}}"
85
+ },
86
+ "gy0Ynb": {
87
+ "module": "@ttoss/components",
88
+ "defaultMessage": "Click or drag files here"
89
+ },
90
+ "oYpm71": {
91
+ "module": "@ttoss/components",
92
+ "defaultMessage": "of {max}",
93
+ "description": "Text shown before the max value, e.g. \"of 10\" or \"of ∞\"."
94
+ },
95
+ "rskBv4": {
96
+ "module": "@ttoss/components",
97
+ "defaultMessage": "Unlimited",
98
+ "description": "Shown when a metric has no maximum limit."
99
+ },
100
+ "zr0OS6": {
101
+ "module": "@ttoss/components",
102
+ "defaultMessage": "{percentage}% used",
103
+ "description": "Footer shown for percentage metrics, e.g. \"80% used\"."
104
+ }
105
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "4Es6pi": {
3
+ "defaultMessage": "Cancelado",
4
+ "description": "Subscription panel status badge: the subscription was cancelled."
5
+ },
6
+ "AhCpt2": {
7
+ "defaultMessage": "Alteração Agendada",
8
+ "description": "Subscription panel badge: a plan change is scheduled for the next cycle."
9
+ },
10
+ "BSgyVr": {
11
+ "defaultMessage": "Inativo",
12
+ "description": "Subscription panel status badge: the subscription is inactive."
13
+ },
14
+ "FvMOyQ": {
15
+ "defaultMessage": "Renovação Cancelada",
16
+ "description": "Subscription panel badge: the subscription will not renew at the end of the cycle."
17
+ },
18
+ "vRSfVR": {
19
+ "defaultMessage": "Ativo",
20
+ "description": "Subscription panel status badge: the subscription is active."
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-billing",
3
- "version": "0.7.4",
3
+ "version": "0.8.0",
4
4
  "description": "Billing UI components for React apps.",
5
5
  "keywords": [
6
6
  "React",
@@ -25,11 +25,12 @@
25
25
  }
26
26
  },
27
27
  "files": [
28
- "dist"
28
+ "dist",
29
+ "i18n"
29
30
  ],
30
31
  "dependencies": {
31
- "@ttoss/react-icons": "^0.10.0",
32
- "@ttoss/ui": "^6.10.1"
32
+ "@ttoss/react-icons": "^0.10.1",
33
+ "@ttoss/ui": "^6.10.2"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@jest/globals": "^29.7.0",
@@ -37,13 +38,16 @@
37
38
  "jest": "^30.4.2",
38
39
  "react": "^19.2.6",
39
40
  "tsdown": "^0.22.2",
40
- "@ttoss/components": "^2.21.1",
41
- "@ttoss/test-utils": "^4.3.0",
42
- "@ttoss/config": "^1.39.0"
41
+ "@ttoss/components": "^2.21.2",
42
+ "@ttoss/react-i18n": "^2.5.2",
43
+ "@ttoss/test-utils": "^4.3.1",
44
+ "@ttoss/i18n-cli": "^0.11.1",
45
+ "@ttoss/config": "^1.39.1"
43
46
  },
44
47
  "peerDependencies": {
45
48
  "react": ">=16.8.0",
46
- "@ttoss/components": "^2.21.1"
49
+ "@ttoss/components": "^2.21.2",
50
+ "@ttoss/react-i18n": "^2.5.2"
47
51
  },
48
52
  "publishConfig": {
49
53
  "access": "public",
@@ -51,6 +55,7 @@
51
55
  },
52
56
  "scripts": {
53
57
  "build": "tsdown",
58
+ "i18n": "ttoss-i18n",
54
59
  "test": "jest --projects tests/unit"
55
60
  }
56
61
  }