@financial-times/n-conversion-forms 28.1.4 → 28.3.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.
@@ -32,29 +32,41 @@ exports[`Position can render a disable select 1`] = `
32
32
  Broker/Trader/Advisor
33
33
  </option>
34
34
  <option value="BU">
35
- Business School Academic
35
+ Academic
36
36
  </option>
37
37
  <option value="CP">
38
- CEO/president/Chairman
38
+ CEO/President/Chairperson
39
39
  </option>
40
40
  <option value="CS">
41
41
  Consultant
42
42
  </option>
43
- <option value="DT">
43
+ <option value="CL">
44
+ C-Suite
45
+ </option>
46
+ <option value="GI">
44
47
  Diplomat/Sen Govt Officer
45
48
  </option>
46
49
  <option value="OE">
47
- Exec Mgmt (EVP/SVP/MD)
50
+ Executive Management
48
51
  </option>
49
52
  <option value="GI">
50
53
  Gov&#x27;t/Int&#x27;l org official
51
54
  </option>
55
+ <option value="IN">
56
+ Intern/Trainee/Student
57
+ </option>
58
+ <option value="DH">
59
+ VP/Director
60
+ </option>
52
61
  <option value="MB">
53
62
  MBA Student
54
63
  </option>
55
64
  <option value="MA">
56
65
  Manager/Supervisor
57
66
  </option>
67
+ <option value="NW">
68
+ Not working
69
+ </option>
58
70
  <option value="OT">
59
71
  Other
60
72
  </option>
@@ -62,11 +74,14 @@ exports[`Position can render a disable select 1`] = `
62
74
  Other C Level (CFO/COO/CIO/CMO)
63
75
  </option>
64
76
  <option value="OP">
65
- Owner/Partner/Proprietor
77
+ Founder/Owner
66
78
  </option>
67
79
  <option value="PO">
68
80
  Politician/Government Minister
69
81
  </option>
82
+ <option value="PA">
83
+ Partner/Principal
84
+ </option>
70
85
  <option value="PR">
71
86
  Professional
72
87
  </option>
@@ -82,8 +97,11 @@ exports[`Position can render a disable select 1`] = `
82
97
  <option value="TS">
83
98
  Technical/Business Specialist
84
99
  </option>
85
- <option value="DH">
86
- VP/Director
100
+ <option value="VP">
101
+ Vice President
102
+ </option>
103
+ <option value="DR">
104
+ Director
87
105
  </option>
88
106
  </select>
89
107
  <span class="o-forms-input__error">
@@ -124,29 +142,41 @@ exports[`Position can render an error message 1`] = `
124
142
  Broker/Trader/Advisor
125
143
  </option>
126
144
  <option value="BU">
127
- Business School Academic
145
+ Academic
128
146
  </option>
129
147
  <option value="CP">
130
- CEO/president/Chairman
148
+ CEO/President/Chairperson
131
149
  </option>
132
150
  <option value="CS">
133
151
  Consultant
134
152
  </option>
135
- <option value="DT">
153
+ <option value="CL">
154
+ C-Suite
155
+ </option>
156
+ <option value="GI">
136
157
  Diplomat/Sen Govt Officer
137
158
  </option>
138
159
  <option value="OE">
139
- Exec Mgmt (EVP/SVP/MD)
160
+ Executive Management
140
161
  </option>
141
162
  <option value="GI">
142
163
  Gov&#x27;t/Int&#x27;l org official
143
164
  </option>
165
+ <option value="IN">
166
+ Intern/Trainee/Student
167
+ </option>
168
+ <option value="DH">
169
+ VP/Director
170
+ </option>
144
171
  <option value="MB">
145
172
  MBA Student
146
173
  </option>
147
174
  <option value="MA">
148
175
  Manager/Supervisor
149
176
  </option>
177
+ <option value="NW">
178
+ Not working
179
+ </option>
150
180
  <option value="OT">
151
181
  Other
152
182
  </option>
@@ -154,11 +184,14 @@ exports[`Position can render an error message 1`] = `
154
184
  Other C Level (CFO/COO/CIO/CMO)
155
185
  </option>
156
186
  <option value="OP">
157
- Owner/Partner/Proprietor
187
+ Founder/Owner
158
188
  </option>
159
189
  <option value="PO">
160
190
  Politician/Government Minister
161
191
  </option>
192
+ <option value="PA">
193
+ Partner/Principal
194
+ </option>
162
195
  <option value="PR">
163
196
  Professional
164
197
  </option>
@@ -174,8 +207,11 @@ exports[`Position can render an error message 1`] = `
174
207
  <option value="TS">
175
208
  Technical/Business Specialist
176
209
  </option>
177
- <option value="DH">
178
- VP/Director
210
+ <option value="VP">
211
+ Vice President
212
+ </option>
213
+ <option value="DR">
214
+ Director
179
215
  </option>
180
216
  </select>
181
217
  <span class="o-forms-input__error">
@@ -216,31 +252,43 @@ exports[`Position can render an initial selected value 1`] = `
216
252
  Broker/Trader/Advisor
217
253
  </option>
218
254
  <option value="BU">
219
- Business School Academic
255
+ Academic
220
256
  </option>
221
257
  <option selected
222
258
  value="CP"
223
259
  >
224
- CEO/president/Chairman
260
+ CEO/President/Chairperson
225
261
  </option>
226
262
  <option value="CS">
227
263
  Consultant
228
264
  </option>
229
- <option value="DT">
265
+ <option value="CL">
266
+ C-Suite
267
+ </option>
268
+ <option value="GI">
230
269
  Diplomat/Sen Govt Officer
231
270
  </option>
232
271
  <option value="OE">
233
- Exec Mgmt (EVP/SVP/MD)
272
+ Executive Management
234
273
  </option>
235
274
  <option value="GI">
236
275
  Gov&#x27;t/Int&#x27;l org official
237
276
  </option>
277
+ <option value="IN">
278
+ Intern/Trainee/Student
279
+ </option>
280
+ <option value="DH">
281
+ VP/Director
282
+ </option>
238
283
  <option value="MB">
239
284
  MBA Student
240
285
  </option>
241
286
  <option value="MA">
242
287
  Manager/Supervisor
243
288
  </option>
289
+ <option value="NW">
290
+ Not working
291
+ </option>
244
292
  <option value="OT">
245
293
  Other
246
294
  </option>
@@ -248,11 +296,14 @@ exports[`Position can render an initial selected value 1`] = `
248
296
  Other C Level (CFO/COO/CIO/CMO)
249
297
  </option>
250
298
  <option value="OP">
251
- Owner/Partner/Proprietor
299
+ Founder/Owner
252
300
  </option>
253
301
  <option value="PO">
254
302
  Politician/Government Minister
255
303
  </option>
304
+ <option value="PA">
305
+ Partner/Principal
306
+ </option>
256
307
  <option value="PR">
257
308
  Professional
258
309
  </option>
@@ -268,8 +319,11 @@ exports[`Position can render an initial selected value 1`] = `
268
319
  <option value="TS">
269
320
  Technical/Business Specialist
270
321
  </option>
271
- <option value="DH">
272
- VP/Director
322
+ <option value="VP">
323
+ Vice President
324
+ </option>
325
+ <option value="DR">
326
+ Director
273
327
  </option>
274
328
  </select>
275
329
  <span class="o-forms-input__error">
@@ -310,29 +364,41 @@ exports[`Position render a select with a label 1`] = `
310
364
  Broker/Trader/Advisor
311
365
  </option>
312
366
  <option value="BU">
313
- Business School Academic
367
+ Academic
314
368
  </option>
315
369
  <option value="CP">
316
- CEO/president/Chairman
370
+ CEO/President/Chairperson
317
371
  </option>
318
372
  <option value="CS">
319
373
  Consultant
320
374
  </option>
321
- <option value="DT">
375
+ <option value="CL">
376
+ C-Suite
377
+ </option>
378
+ <option value="GI">
322
379
  Diplomat/Sen Govt Officer
323
380
  </option>
324
381
  <option value="OE">
325
- Exec Mgmt (EVP/SVP/MD)
382
+ Executive Management
326
383
  </option>
327
384
  <option value="GI">
328
385
  Gov&#x27;t/Int&#x27;l org official
329
386
  </option>
387
+ <option value="IN">
388
+ Intern/Trainee/Student
389
+ </option>
390
+ <option value="DH">
391
+ VP/Director
392
+ </option>
330
393
  <option value="MB">
331
394
  MBA Student
332
395
  </option>
333
396
  <option value="MA">
334
397
  Manager/Supervisor
335
398
  </option>
399
+ <option value="NW">
400
+ Not working
401
+ </option>
336
402
  <option value="OT">
337
403
  Other
338
404
  </option>
@@ -340,11 +406,14 @@ exports[`Position render a select with a label 1`] = `
340
406
  Other C Level (CFO/COO/CIO/CMO)
341
407
  </option>
342
408
  <option value="OP">
343
- Owner/Partner/Proprietor
409
+ Founder/Owner
344
410
  </option>
345
411
  <option value="PO">
346
412
  Politician/Government Minister
347
413
  </option>
414
+ <option value="PA">
415
+ Partner/Principal
416
+ </option>
348
417
  <option value="PR">
349
418
  Professional
350
419
  </option>
@@ -360,8 +429,11 @@ exports[`Position render a select with a label 1`] = `
360
429
  <option value="TS">
361
430
  Technical/Business Specialist
362
431
  </option>
363
- <option value="DH">
364
- VP/Director
432
+ <option value="VP">
433
+ Vice President
434
+ </option>
435
+ <option value="DR">
436
+ Director
365
437
  </option>
366
438
  </select>
367
439
  <span class="o-forms-input__error">
@@ -31,7 +31,6 @@ export default {
31
31
  isTransition: { control: 'boolean' },
32
32
  isPrintProduct: { control: 'boolean' },
33
33
  isSingleTerm: { control: 'boolean' },
34
- isNewDigitalBuyFlowConsent: { control: 'boolean' },
35
34
  hideConfirmTermsAndConditions: { control: 'boolean' },
36
35
  isDeferredBilling: { control: 'boolean' },
37
36
  children: {
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import { getCountries } from '../utils/countries';
3
+ import { Country } from './country';
5
4
 
6
5
  export function BillingCountry({
7
6
  fieldId = 'billingCountryField',
@@ -11,58 +10,19 @@ export function BillingCountry({
11
10
  isDisabled = false,
12
11
  value,
13
12
  }) {
14
- const selectWrapperClassName = classNames([
15
- 'o-forms-input',
16
- 'o-forms-input--select',
17
- { 'o-forms-input--invalid': hasError },
18
- ]);
19
- const props = {
20
- id: inputId,
21
- className: 'js-field__input js-item__value',
22
- 'aria-required': true,
23
- required: true,
24
- name: inputId,
25
- 'data-trackable': 'field-billing-country',
26
- disabled: isDisabled,
27
- };
28
- const countries = getCountries({ filter: filterList, value });
29
-
30
- const createOption = (country) => (
31
- <option key={country.code} value={country.code} selected={country.selected}>
32
- {country.name}
33
- </option>
34
- );
35
- const createOptGroup = (country) => (
36
- <optgroup key={country.label} label={country.label}>
37
- {country.countries.map((country) => createOption(country))}
38
- </optgroup>
39
- );
40
- const createSelect = (countries) => (
41
- <select {...props}>
42
- <option value="" disabled>
43
- Please select a country
44
- </option>
45
- {countries.map((country) =>
46
- country.label ? createOptGroup(country) : createOption(country)
47
- )}
48
- </select>
49
- );
50
-
51
13
  return (
52
- <label
53
- id={fieldId}
54
- className="o-forms-field"
55
- data-validate="required"
56
- htmlFor={inputId}
57
- >
58
- <span className="o-forms-title">
59
- <span className="o-forms-title__main">Billing Country</span>
60
- </span>
61
- <span className={selectWrapperClassName}>
62
- {createSelect(countries)}
63
- <span className="o-forms-input__error">Please select your country</span>
64
- </span>
65
- </label>
14
+ <Country
15
+ dataTrackable="field-billing-country"
16
+ fieldId={fieldId}
17
+ filterList={filterList}
18
+ hasError={hasError}
19
+ inputId={inputId}
20
+ isB2b={false}
21
+ isDisabled={isDisabled}
22
+ isPlaceholderDisabled={true}
23
+ label="Billing Country"
24
+ value={value}
25
+ />
66
26
  );
67
27
  }
68
28
 
@@ -3,7 +3,7 @@ import { expectToRenderCorrectly } from '../test-jest/helpers/expect-to-render-c
3
3
 
4
4
  expect.extend(expectToRenderCorrectly);
5
5
 
6
- describe('Country', () => {
6
+ describe('BillingCountry', () => {
7
7
  it('renders with default props', () => {
8
8
  const props = {};
9
9
 
@@ -4,28 +4,30 @@ import classNames from 'classnames';
4
4
  import { getCountries } from '../utils/countries';
5
5
 
6
6
  export function Country({
7
+ additionalFieldInformation,
8
+ dataTrackable = 'field-country',
7
9
  fieldId = 'countryField',
8
10
  filterList = [],
9
11
  hasError = false,
10
12
  inputId = 'country',
11
13
  isB2b = false,
12
14
  isDisabled = false,
15
+ isPlaceholderDisabled = false,
13
16
  value,
14
- additionalFieldInformation,
17
+ label = `Country${isB2b ? '/Region' : ''}`,
18
+ errorText = `Please select your country${isB2b ? '/region' : ''}`,
15
19
  }) {
16
20
  const selectWrapperClassName = classNames([
17
21
  'o-forms-input',
18
22
  'o-forms-input--select',
19
23
  { 'o-forms-input--invalid': hasError },
20
24
  ]);
21
- const label = `Country${isB2b ? '/Region' : ''}`;
22
- const error = `Please select your country${isB2b ? '/region' : ''}`;
23
25
  const selectProps = {
24
26
  id: inputId,
25
27
  'aria-required': true,
26
28
  required: true,
27
- name: 'country',
28
- 'data-trackable': 'field-country',
29
+ name: inputId,
30
+ 'data-trackable': dataTrackable,
29
31
  disabled: isDisabled,
30
32
  };
31
33
  const countries = getCountries({ filter: filterList, value });
@@ -42,7 +44,9 @@ export function Country({
42
44
  );
43
45
  const createSelect = (countries) => (
44
46
  <select {...selectProps}>
45
- <option value="">Please select a country{isB2b ? '/region' : ''}</option>
47
+ <option value="" disabled={isPlaceholderDisabled}>
48
+ Please select a country{isB2b ? '/region' : ''}
49
+ </option>
46
50
  {countries.map((country) =>
47
51
  country.label ? createOptGroup(country) : createOption(country)
48
52
  )}
@@ -60,7 +64,7 @@ export function Country({
60
64
  return (
61
65
  <label
62
66
  id={fieldId}
63
- className="o-forms-field js-unknown-user-field ncf__validation-error"
67
+ className="o-forms-field ncf__validation-error"
64
68
  data-validate="required"
65
69
  htmlFor={selectProps.id}
66
70
  >
@@ -69,7 +73,7 @@ export function Country({
69
73
  </span>
70
74
  <span className={selectWrapperClassName}>
71
75
  {createSelect(countries)}
72
- <span className={fieldErrorClassNames}>{error}</span>
76
+ <span className={fieldErrorClassNames}>{errorText}</span>
73
77
  {additionalFieldInformation ? (
74
78
  <p className="additional-field-information">
75
79
  {additionalFieldInformation}
@@ -81,12 +85,16 @@ export function Country({
81
85
  }
82
86
 
83
87
  Country.propTypes = {
88
+ additionalFieldInformation: PropTypes.node,
89
+ dataTrackable: PropTypes.string,
90
+ errorText: PropTypes.string,
84
91
  fieldId: PropTypes.string,
85
92
  filterList: PropTypes.arrayOf(PropTypes.string),
86
93
  hasError: PropTypes.bool,
87
94
  inputId: PropTypes.string,
88
95
  isB2b: PropTypes.bool,
89
96
  isDisabled: PropTypes.bool,
97
+ isPlaceholderDisabled: PropTypes.bool,
98
+ label: PropTypes.string,
90
99
  value: PropTypes.string,
91
- additionalFieldInformation: PropTypes.node,
92
100
  };
@@ -18,6 +18,14 @@ describe('Country', () => {
18
18
  expect(Country).toRenderCorrectly(props);
19
19
  });
20
20
 
21
+ it('renders with dataTrackable', () => {
22
+ const props = {
23
+ dataTrackable: 'some-trackable',
24
+ };
25
+
26
+ expect(Country).toRenderCorrectly(props);
27
+ });
28
+
21
29
  it('renders with large filterList', () => {
22
30
  const props = {
23
31
  filterList: [
@@ -78,4 +86,28 @@ describe('Country', () => {
78
86
 
79
87
  expect(Country).toRenderCorrectly(props);
80
88
  });
89
+
90
+ it('renders with inputId', () => {
91
+ const props = {
92
+ inputId: 'some-other-name',
93
+ };
94
+
95
+ expect(Country).toRenderCorrectly(props);
96
+ });
97
+
98
+ it('renders with label', () => {
99
+ const props = {
100
+ label: 'Some Label',
101
+ };
102
+
103
+ expect(Country).toRenderCorrectly(props);
104
+ });
105
+
106
+ it('renders with errorText', () => {
107
+ const props = {
108
+ errorText: 'Some Error Text',
109
+ };
110
+
111
+ expect(Country).toRenderCorrectly(props);
112
+ });
81
113
  });
@@ -7,8 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.BillingCountry = BillingCountry;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _countries = require("../utils/countries");
10
+ var _country = require("./country");
12
11
  function BillingCountry(_ref) {
13
12
  var _ref$fieldId = _ref.fieldId,
14
13
  fieldId = _ref$fieldId === void 0 ? 'billingCountryField' : _ref$fieldId,
@@ -21,59 +20,18 @@ function BillingCountry(_ref) {
21
20
  _ref$isDisabled = _ref.isDisabled,
22
21
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
23
22
  value = _ref.value;
24
- var selectWrapperClassName = (0, _classnames["default"])(['o-forms-input', 'o-forms-input--select', {
25
- 'o-forms-input--invalid': hasError
26
- }]);
27
- var props = {
28
- id: inputId,
29
- className: 'js-field__input js-item__value',
30
- 'aria-required': true,
31
- required: true,
32
- name: inputId,
33
- 'data-trackable': 'field-billing-country',
34
- disabled: isDisabled
35
- };
36
- var countries = (0, _countries.getCountries)({
37
- filter: filterList,
23
+ return /*#__PURE__*/_react["default"].createElement(_country.Country, {
24
+ dataTrackable: "field-billing-country",
25
+ fieldId: fieldId,
26
+ filterList: filterList,
27
+ hasError: hasError,
28
+ inputId: inputId,
29
+ isB2b: false,
30
+ isDisabled: isDisabled,
31
+ isPlaceholderDisabled: true,
32
+ label: "Billing Country",
38
33
  value: value
39
34
  });
40
- var createOption = function createOption(country) {
41
- return /*#__PURE__*/_react["default"].createElement("option", {
42
- key: country.code,
43
- value: country.code,
44
- selected: country.selected
45
- }, country.name);
46
- };
47
- var createOptGroup = function createOptGroup(country) {
48
- return /*#__PURE__*/_react["default"].createElement("optgroup", {
49
- key: country.label,
50
- label: country.label
51
- }, country.countries.map(function (country) {
52
- return createOption(country);
53
- }));
54
- };
55
- var createSelect = function createSelect(countries) {
56
- return /*#__PURE__*/_react["default"].createElement("select", props, /*#__PURE__*/_react["default"].createElement("option", {
57
- value: "",
58
- disabled: true
59
- }, "Please select a country"), countries.map(function (country) {
60
- return country.label ? createOptGroup(country) : createOption(country);
61
- }));
62
- };
63
- return /*#__PURE__*/_react["default"].createElement("label", {
64
- id: fieldId,
65
- className: "o-forms-field",
66
- "data-validate": "required",
67
- htmlFor: inputId
68
- }, /*#__PURE__*/_react["default"].createElement("span", {
69
- className: "o-forms-title"
70
- }, /*#__PURE__*/_react["default"].createElement("span", {
71
- className: "o-forms-title__main"
72
- }, "Billing Country")), /*#__PURE__*/_react["default"].createElement("span", {
73
- className: selectWrapperClassName
74
- }, createSelect(countries), /*#__PURE__*/_react["default"].createElement("span", {
75
- className: "o-forms-input__error"
76
- }, "Please select your country")));
77
35
  }
78
36
  BillingCountry.propTypes = {
79
37
  fieldId: _propTypes["default"].string,