@thecb/components 12.1.0-beta.11 → 12.1.0-beta.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "12.1.0-beta.11",
3
+ "version": "12.1.0-beta.13",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -21,6 +21,7 @@ const meta = {
21
21
  extraStyles: undefined,
22
22
  textExtraStyles: undefined,
23
23
  labelledById: undefined,
24
+ customAriaLabel: undefined,
24
25
  dataQa: null
25
26
  },
26
27
  argTypes: {
@@ -52,6 +53,13 @@ const meta = {
52
53
  type: { summary: "string" }
53
54
  }
54
55
  },
56
+ customAriaLabel: {
57
+ table: {
58
+ description:
59
+ "Overrides the default aria-label derived from `name` or `labelledById`",
60
+ type: { summary: "string" }
61
+ }
62
+ },
55
63
  extraStyles: {
56
64
  table: {
57
65
  type: { summary: "string" }
@@ -147,3 +155,20 @@ export const Hidden = {
147
155
  },
148
156
  render: args => <CheckboxWithHooks {...args} />
149
157
  };
158
+
159
+ export const CustomAriaLabel = {
160
+ args: {
161
+ title: "Save to wallet (optional).",
162
+ customAriaLabel: "Save to wallet (optional).",
163
+ name: "save to wallet"
164
+ },
165
+ render: args => <CheckboxWithHooks {...args} />
166
+ };
167
+
168
+ export const SpacesInName = {
169
+ args: {
170
+ title: "Accept terms and conditions",
171
+ name: "accept terms and conditions"
172
+ },
173
+ render: args => <RequiredCheckbox {...args} />
174
+ };
@@ -198,7 +198,7 @@ const PaymentFormCard = ({
198
198
  )}
199
199
  {showWalletCheckbox && (
200
200
  <Checkbox
201
- name="bank checkbox"
201
+ name="credit card checkbox"
202
202
  dataQa="Save credit card to wallet"
203
203
  customAriaLabel="Save credit card to wallet (optional)."
204
204
  title={
@@ -0,0 +1,166 @@
1
+ import TermsAndConditionsControlV2 from "./TermsAndConditionsControlV2";
2
+ import React, { useState } from "react";
3
+
4
+ const sampleTerms =
5
+ "By using this service, you agree to the terms and conditions set forth by the provider. All payments are subject to review.";
6
+
7
+ const meta = {
8
+ title: "Molecules/TermsAndConditionsControlV2",
9
+ component: TermsAndConditionsControlV2,
10
+ parameters: {
11
+ layout: "centered"
12
+ },
13
+ tags: ["!autodocs"],
14
+ args: {
15
+ showCheckbox: true,
16
+ isChecked: false,
17
+ hasError: false,
18
+ errorMessage: "Please accept Terms and Conditions",
19
+ description: "I agree to the",
20
+ linkText: "Terms and Conditions",
21
+ terms: sampleTerms,
22
+ id: "terms-and-conditions",
23
+ displayInline: true,
24
+ modalVariant: "default",
25
+ checkboxMargin: "4px 8px 4px 4px",
26
+ modalTitle: "Terms and Conditions",
27
+ initialFocusSelector: ".modal-close-button",
28
+ isRequired: false
29
+ },
30
+ argTypes: {
31
+ showCheckbox: {
32
+ description: "Whether to show the checkbox",
33
+ table: {
34
+ type: { summary: "boolean" },
35
+ defaultValue: { summary: true }
36
+ }
37
+ },
38
+ isChecked: {
39
+ table: {
40
+ type: { summary: "boolean" },
41
+ defaultValue: { summary: false }
42
+ }
43
+ },
44
+ hasError: {
45
+ description: "Whether the checkbox is in an error state",
46
+ table: {
47
+ type: { summary: "boolean" },
48
+ defaultValue: { summary: false }
49
+ }
50
+ },
51
+ errorMessage: {
52
+ table: {
53
+ type: { summary: "string" },
54
+ defaultValue: { summary: "Please accept Terms and Conditions" }
55
+ }
56
+ },
57
+ description: {
58
+ description: "Text displayed before the terms link",
59
+ table: {
60
+ type: { summary: "string" },
61
+ defaultValue: { summary: '""' }
62
+ }
63
+ },
64
+ linkText: {
65
+ description: "Text for the modal trigger link",
66
+ table: {
67
+ type: { summary: "string" },
68
+ defaultValue: { summary: "Terms and Conditions" }
69
+ }
70
+ },
71
+ terms: {
72
+ description: "Terms content displayed inside the modal",
73
+ table: {
74
+ type: { summary: "string" }
75
+ }
76
+ },
77
+ displayInline: {
78
+ description:
79
+ "When true with showCheckbox=false, renders inline terms using InlineTermsWrapper",
80
+ table: {
81
+ type: { summary: "boolean" },
82
+ defaultValue: { summary: true }
83
+ }
84
+ },
85
+ modalVariant: {
86
+ table: {
87
+ type: { summary: "string" },
88
+ defaultValue: { summary: "default" }
89
+ }
90
+ },
91
+ id: {
92
+ table: {
93
+ type: { summary: "string" },
94
+ defaultValue: { summary: "terms-and-conditions" }
95
+ }
96
+ },
97
+ checkboxMargin: {
98
+ table: {
99
+ type: { summary: "string" },
100
+ defaultValue: { summary: "4px 8px 4px 4px" }
101
+ }
102
+ },
103
+ modalTitle: {
104
+ table: {
105
+ type: { summary: "string" },
106
+ defaultValue: { summary: "Terms and Conditions" }
107
+ }
108
+ },
109
+ initialFocusSelector: {
110
+ table: {
111
+ type: { summary: "string" },
112
+ defaultValue: { summary: '""' }
113
+ }
114
+ },
115
+ isRequired: {
116
+ table: {
117
+ type: { summary: "boolean" },
118
+ defaultValue: { summary: false }
119
+ }
120
+ }
121
+ }
122
+ };
123
+
124
+ const TermsWithCheckbox = props => {
125
+ const [isChecked, setIsChecked] = useState(false);
126
+
127
+ return (
128
+ <TermsAndConditionsControlV2
129
+ {...props}
130
+ isChecked={isChecked}
131
+ onCheck={() => setIsChecked(!isChecked)}
132
+ />
133
+ );
134
+ };
135
+
136
+ export default meta;
137
+
138
+ export const Default = {
139
+ render: args => <TermsWithCheckbox {...args} />
140
+ };
141
+
142
+ export const InlineWithoutCheckbox = {
143
+ args: {
144
+ showCheckbox: false,
145
+ displayInline: true,
146
+ description: "View "
147
+ },
148
+ render: args => <TermsAndConditionsControlV2 {...args} />
149
+ };
150
+
151
+ export const NonInlineWithoutCheckbox = {
152
+ args: {
153
+ showCheckbox: false,
154
+ displayInline: false,
155
+ description: "View "
156
+ },
157
+ render: args => <TermsAndConditionsControlV2 {...args} />
158
+ };
159
+
160
+ export const WithError = {
161
+ args: {
162
+ hasError: true,
163
+ isRequired: true
164
+ },
165
+ render: args => <TermsWithCheckbox {...args} hasError={!args.isChecked} />
166
+ };