@financial-times/n-conversion-forms 27.7.1 → 28.0.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.
Files changed (119) hide show
  1. package/.eslintignore +1 -0
  2. package/build-state/npm-shrinkwrap.json +1808 -1324
  3. package/components/__snapshots__/payment-type.spec.js.snap +0 -2
  4. package/components/accept-terms.jsx +18 -16
  5. package/components/app-banner.jsx +1 -1
  6. package/components/b2c-partnership-confirmation.jsx +1 -1
  7. package/components/billing-city.jsx +1 -1
  8. package/components/billing-country.jsx +1 -1
  9. package/components/billing-postcode.jsx +1 -1
  10. package/components/company-name.jsx +1 -1
  11. package/components/confirmation.jsx +5 -4
  12. package/components/continue-reading.jsx +1 -1
  13. package/components/continue-reading.stories.js +1 -1
  14. package/components/country.jsx +1 -1
  15. package/components/customer-care.jsx +1 -1
  16. package/components/debug.jsx +1 -1
  17. package/components/decision-maker.jsx +1 -1
  18. package/components/decision-maker.spec.js +1 -1
  19. package/components/deferred-billing-terms.jsx +92 -76
  20. package/components/deferred-billing-terms.spec.js +5 -1
  21. package/components/deferred-billing-terms.stories.js +3 -3
  22. package/components/delivery-address-type.jsx +4 -4
  23. package/components/delivery-address.jsx +1 -1
  24. package/components/delivery-city.jsx +9 -5
  25. package/components/delivery-county.jsx +1 -1
  26. package/components/delivery-instructions.jsx +30 -21
  27. package/components/delivery-option.jsx +5 -2
  28. package/components/delivery-po-box.jsx +1 -1
  29. package/components/delivery-postcode.jsx +32 -28
  30. package/components/delivery-security-instructions.jsx +1 -1
  31. package/components/delivery-start-date.jsx +1 -1
  32. package/components/education-job-title.jsx +1 -1
  33. package/components/email.jsx +1 -1
  34. package/components/error-page.jsx +1 -1
  35. package/components/fieldset.jsx +1 -1
  36. package/components/first-name.jsx +1 -1
  37. package/components/form.jsx +1 -1
  38. package/components/google-sign-in.jsx +1 -1
  39. package/components/graduation-date.jsx +1 -1
  40. package/components/industry.jsx +1 -1
  41. package/components/job-title.jsx +1 -1
  42. package/components/last-name.jsx +1 -1
  43. package/components/licence-confirmation.jsx +10 -8
  44. package/components/licence-header.jsx +3 -3
  45. package/components/licence-sign-in.jsx +2 -2
  46. package/components/licence-title.jsx +2 -2
  47. package/components/lite-sub-confirmation.jsx +1 -1
  48. package/components/loader.jsx +1 -1
  49. package/components/message.jsx +1 -1
  50. package/components/organisation.jsx +1 -1
  51. package/components/package-change.jsx +1 -1
  52. package/components/password.jsx +1 -1
  53. package/components/payment-term.jsx +52 -43
  54. package/components/payment-term.spec.js +15 -9
  55. package/components/payment-term.stories.js +63 -63
  56. package/components/payment-type.jsx +4 -4
  57. package/components/personal-title.jsx +1 -1
  58. package/components/phone.jsx +1 -1
  59. package/components/position.jsx +1 -1
  60. package/components/progress-indicator.jsx +3 -3
  61. package/components/province.jsx +1 -1
  62. package/components/registration-confirmation.jsx +1 -1
  63. package/components/responsibility.jsx +1 -1
  64. package/components/section.jsx +1 -1
  65. package/components/state.jsx +1 -1
  66. package/components/submit.jsx +1 -1
  67. package/components/text-input.jsx +1 -1
  68. package/components/trial-banner.jsx +1 -1
  69. package/dist/deferred-billing-terms.js +2 -3
  70. package/dist/payment-term.js +1 -1
  71. package/dist/payment-type.js +2 -2
  72. package/helpers/index.js +11 -8
  73. package/helpers/ncf-countries.spec.js +1 -1
  74. package/helpers/supportedCountries.js +12 -5
  75. package/helpers/supportedPostcodeExamples.js +5 -5
  76. package/helpers/supportedPostcodeValidators.js +5 -5
  77. package/helpers/supportedPostcodeValidators.spec.js +30 -10
  78. package/helpers/utilities.js +4 -4
  79. package/jest.config.js +1 -5
  80. package/package.json +14 -17
  81. package/styles/message.scss +0 -16
  82. package/test-jest/helpers/expect-to-render-correctly.js +1 -1
  83. package/utils/app-banner.js +1 -1
  84. package/utils/apple-pay.js +15 -15
  85. package/utils/billing-city.js +1 -1
  86. package/utils/billing-country.js +3 -3
  87. package/utils/billing-postcode.js +1 -1
  88. package/utils/company-name.js +1 -1
  89. package/utils/countries.js +2 -2
  90. package/utils/country.js +3 -3
  91. package/utils/delivery-address-type.js +3 -3
  92. package/utils/delivery-address-type.spec.js +6 -2
  93. package/utils/delivery-address.js +1 -1
  94. package/utils/delivery-instructions.js +1 -1
  95. package/utils/delivery-option-messages.js +11 -11
  96. package/utils/delivery-option-messages.spec.js +4 -13
  97. package/utils/delivery-option.js +5 -5
  98. package/utils/delivery-po-box.js +1 -1
  99. package/utils/delivery-postcode.js +1 -1
  100. package/utils/delivery-start-date.js +4 -4
  101. package/utils/delivery-start-date.spec.js +3 -2
  102. package/utils/email.js +4 -4
  103. package/utils/email.spec.js +2 -1
  104. package/utils/event-notifier.js +1 -1
  105. package/utils/form-element.js +8 -8
  106. package/utils/loader.js +10 -10
  107. package/utils/password.js +2 -2
  108. package/utils/payment-term.js +16 -15
  109. package/utils/payment-type.js +14 -14
  110. package/utils/postcode.js +3 -3
  111. package/utils/postcode.spec.js +21 -12
  112. package/utils/province.js +1 -1
  113. package/utils/salesforce.js +2 -2
  114. package/utils/state.js +1 -1
  115. package/utils/submit.js +5 -5
  116. package/utils/tracking.js +7 -7
  117. package/utils/validation.js +18 -11
  118. package/utils/zuora-error-map.js +5 -5
  119. package/utils/zuora.js +17 -12
@@ -64,7 +64,7 @@ const deliveryOptionMessages = [
64
64
  country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
65
65
  title: 'Hand delivery',
66
66
  description:
67
- 'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: We fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT\'s control. In those circumstances, your newspaper will be delivered on the next delivery day.',
67
+ "Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: We fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT's control. In those circumstances, your newspaper will be delivered on the next delivery day.",
68
68
  },
69
69
  {
70
70
  deliveryFrequency: [
@@ -90,7 +90,7 @@ const deliveryOptionMessages = [
90
90
  country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
91
91
  title: 'Hand delivery',
92
92
  description:
93
- 'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: We fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT\'s control. In those circumstances, your newspaper will be delivered on the next delivery day. Please also be aware that your FT Weekend will be delivered on Sunday.',
93
+ "Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: We fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT's control. In those circumstances, your newspaper will be delivered on the next delivery day. Please also be aware that your FT Weekend will be delivered on Sunday.",
94
94
  },
95
95
  {
96
96
  deliveryFrequency: [
@@ -184,7 +184,7 @@ const deliveryOptionMessages = [
184
184
  title: 'Mail',
185
185
  customId: 'ML',
186
186
  description:
187
- 'We can only deliver the newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT\'s control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.',
187
+ "We can only deliver the newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT's control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.",
188
188
  },
189
189
  {
190
190
  deliveryFrequency: [ONLY_WEEKEND_DELIVERY_FREQ],
@@ -194,7 +194,7 @@ const deliveryOptionMessages = [
194
194
  country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
195
195
  title: 'Hand delivery',
196
196
  description:
197
- 'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: We fly the newspapers to your location which means delivery is subject to flight delays/cancellations outside of the FT\'s control. In those circumstances, your newspaper will be delivered the next delivery day.',
197
+ "Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: We fly the newspapers to your location which means delivery is subject to flight delays/cancellations outside of the FT's control. In those circumstances, your newspaper will be delivered the next delivery day.",
198
198
  },
199
199
  {
200
200
  deliveryFrequency: [ONLY_WEEKEND_DELIVERY_FREQ],
@@ -214,7 +214,7 @@ const deliveryOptionMessages = [
214
214
  country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
215
215
  title: 'Hand delivery',
216
216
  description:
217
- 'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note we fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT\'s control. In those circumstances, your newspaper will be delivered on the next delivery day. Please also be aware that your FT Weekend will be delivered on Sunday.',
217
+ "Enjoy delivery of the newspaper daily to your home or office address. \nPlease note we fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT's control. In those circumstances, your newspaper will be delivered on the next delivery day. Please also be aware that your FT Weekend will be delivered on Sunday.",
218
218
  },
219
219
  {
220
220
  deliveryFrequency: [ONLY_WEEKEND_DELIVERY_FREQ],
@@ -233,18 +233,18 @@ const deliveryOptionMessages = [
233
233
  title: 'Mail',
234
234
  customId: 'ML',
235
235
  description:
236
- 'We can only deliver the FT Weekend newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT\'s control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.',
236
+ "We can only deliver the FT Weekend newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT's control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.",
237
237
  },
238
238
  ];
239
239
 
240
- function includesDeliveryFrequency (productCode = '', item) {
240
+ function includesDeliveryFrequency(productCode = '', item) {
241
241
  return item.deliveryFrequency.find((freq) => {
242
242
  const productCodePattern = deliveryFrequencyProductsMapping[freq];
243
243
  return productCode.includes(productCodePattern);
244
244
  });
245
245
  }
246
246
 
247
- function mailStrategy (productCode, option, FTShippingZone, item) {
247
+ function mailStrategy(productCode, option, FTShippingZone, item) {
248
248
  return (
249
249
  includesDeliveryFrequency(productCode, item) &&
250
250
  item.distributorType === MAIL &&
@@ -252,7 +252,7 @@ function mailStrategy (productCode, option, FTShippingZone, item) {
252
252
  );
253
253
  }
254
254
 
255
- function handDeliveryStrategy (productCode, option, FTShippingZone, item) {
255
+ function handDeliveryStrategy(productCode, option, FTShippingZone, item) {
256
256
  return (
257
257
  includesDeliveryFrequency(productCode, item) &&
258
258
  item.distributorType === HAND_DELIVERY &&
@@ -268,7 +268,7 @@ function handDeliveryStrategy (productCode, option, FTShippingZone, item) {
268
268
  * Both cases are represented by system option code 'HD', but differ on the mailDelivery property value.
269
269
  * If no message matchs, then undefined is returned.
270
270
  */
271
- function findCustomDeliveryOption (productCode, option, FTShippingZone) {
271
+ function findCustomDeliveryOption(productCode, option, FTShippingZone) {
272
272
  let deliveryOption;
273
273
 
274
274
  if (option.value === HAND_DELIVERY) {
@@ -287,7 +287,7 @@ function findCustomDeliveryOption (productCode, option, FTShippingZone) {
287
287
  return deliveryOption;
288
288
  }
289
289
 
290
- function getDeliveryOption (productCode, option, FTShippingZone) {
290
+ function getDeliveryOption(productCode, option, FTShippingZone) {
291
291
  return FTShippingZone === UK_COUNTRY_CODE
292
292
  ? UKDeliveryOptions[option.value]
293
293
  : findCustomDeliveryOption(productCode, option, FTShippingZone);
@@ -86,7 +86,7 @@ describe('Find Custom Delivery Option', () => {
86
86
  title: 'Mail',
87
87
  customId: 'ML',
88
88
  description:
89
- 'We can only deliver the newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT\'s control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.',
89
+ "We can only deliver the newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT's control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.",
90
90
  };
91
91
 
92
92
  const deliveryOption = getDeliveryOption(
@@ -103,7 +103,7 @@ describe('Find Custom Delivery Option', () => {
103
103
  title: 'Mail',
104
104
  customId: 'ML',
105
105
  description:
106
- 'We can only deliver the FT Weekend newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT\'s control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.',
106
+ "We can only deliver the FT Weekend newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT's control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.",
107
107
  };
108
108
 
109
109
  const deliveryOption = getDeliveryOption(
@@ -135,7 +135,6 @@ describe('Find Custom Delivery Option', () => {
135
135
  });
136
136
 
137
137
  describe('Find CEMEA/APAC Delivery Option', () => {
138
-
139
138
  it('returns CEMEA/APAC HD delivery option', () => {
140
139
  stubOption.flightMarket = true;
141
140
  stubOption.deliveryOnPublicationDate = false;
@@ -146,11 +145,7 @@ describe('Find Custom Delivery Option', () => {
146
145
  'Enjoy the delivery of the newspaper to your home or office address. Please note we fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT’s control. In those circumstances, your newspaper will be delivered the next delivery day. Please also be aware that your FT weekend will be delivered on Sunday.',
147
146
  };
148
147
 
149
- const deliveryOption = getDeliveryOption(
150
- 'N6D',
151
- stubOption,
152
- 'CEMEA_V1'
153
- );
148
+ const deliveryOption = getDeliveryOption('N6D', stubOption, 'CEMEA_V1');
154
149
 
155
150
  expect(deliveryOption).toEqual(expected);
156
151
  });
@@ -165,11 +160,7 @@ describe('Find Custom Delivery Option', () => {
165
160
  'Enjoy delivery of the newspaper to your home or office address. Note this is a postal delivery - expect delivery after the day of publication. If you would prefer to read the newspaper on the day of publication, purchase an FT ePaper subscription, our digital replica of the each daily edition.',
166
161
  };
167
162
 
168
- const deliveryOption = getDeliveryOption(
169
- 'N6D',
170
- stubOption,
171
- 'APAC'
172
- );
163
+ const deliveryOption = getDeliveryOption('N6D', stubOption, 'APAC');
173
164
 
174
165
  expect(deliveryOption).toEqual(expected);
175
166
  });
@@ -9,7 +9,7 @@ class DeliveryOption {
9
9
  * @param {Element} element Usually the window.document
10
10
  * @throws If the element not passed
11
11
  */
12
- constructor (element) {
12
+ constructor(element) {
13
13
  if (!element) {
14
14
  throw new Error('Please supply the DOM element');
15
15
  }
@@ -27,7 +27,7 @@ class DeliveryOption {
27
27
  * Binds the given callback to the field's onchange event.
28
28
  * @param {Function} callback The callback function to call when a change event occurs.
29
29
  */
30
- handleDeliveryOptionChange (callback) {
30
+ handleDeliveryOptionChange(callback) {
31
31
  if (this.$form.elements['deliveryOption'].length === undefined) {
32
32
  this.$form.elements['deliveryOption'].addEventListener(
33
33
  'change',
@@ -43,7 +43,7 @@ class DeliveryOption {
43
43
  /**
44
44
  * Hide a specific radio input item.
45
45
  */
46
- hideItem (itemId) {
46
+ hideItem(itemId) {
47
47
  const labelNodes = this.$form.querySelectorAll(
48
48
  '.ncf__delivery-option__item'
49
49
  );
@@ -56,7 +56,7 @@ class DeliveryOption {
56
56
  /**
57
57
  * Show a specific radio input item.
58
58
  */
59
- showItem (itemId) {
59
+ showItem(itemId) {
60
60
  const labelNodes = this.$form.querySelectorAll(
61
61
  '.ncf__delivery-option__item'
62
62
  );
@@ -69,7 +69,7 @@ class DeliveryOption {
69
69
  /**
70
70
  * Mark an input item as checked
71
71
  */
72
- checkItem (itemId) {
72
+ checkItem(itemId) {
73
73
  const inputNodes = this.$form.elements['deliveryOption'];
74
74
  const item = Array.from(inputNodes).find((node) => node.id === itemId);
75
75
  if (item) {
@@ -1,7 +1,7 @@
1
1
  const FormElement = require('./form-element');
2
2
 
3
3
  class DeliveryPOBox extends FormElement {
4
- constructor (document, fieldId = 'deliveryPOBoxField') {
4
+ constructor(document, fieldId = 'deliveryPOBoxField') {
5
5
  super(document, `.ncf #${fieldId}`);
6
6
  }
7
7
  }
@@ -1,7 +1,7 @@
1
1
  const Postcode = require('./postcode');
2
2
 
3
3
  class DeliveryPostcode extends Postcode {
4
- constructor (document) {
4
+ constructor(document) {
5
5
  super(document, '.ncf #deliveryPostcodeField');
6
6
  }
7
7
  }
@@ -11,7 +11,7 @@ class DeliveryStartDate {
11
11
  * @param {Element} element Usually the window.document
12
12
  * @throws If the element not passed
13
13
  */
14
- constructor (element) {
14
+ constructor(element) {
15
15
  if (!element) {
16
16
  throw new Error('Please supply the DOM element');
17
17
  }
@@ -60,7 +60,7 @@ class DeliveryStartDate {
60
60
  * @returns {boolean} Whether or not the start date is valid.
61
61
  * @throws If there was an error calling the endpoint to check this.
62
62
  */
63
- async handleDeliveryStartDateChange (url, getData) {
63
+ async handleDeliveryStartDateChange(url, getData) {
64
64
  const isNewValue =
65
65
  this.previousDeliveryDateValue !== this.$deliveryStartDate.value;
66
66
  this.previousDeliveryDateValue = this.$deliveryStartDate.value;
@@ -103,14 +103,14 @@ class DeliveryStartDate {
103
103
  /**
104
104
  * Enables the start date field
105
105
  */
106
- enable () {
106
+ enable() {
107
107
  this.$deliveryStartDate.removeAttribute('disabled');
108
108
  }
109
109
 
110
110
  /**
111
111
  * Disables the start date field
112
112
  */
113
- disable () {
113
+ disable() {
114
114
  this.$deliveryStartDate.setAttribute('disabled', 'true');
115
115
  }
116
116
  }
@@ -73,7 +73,7 @@ describe('DeliveryStartDate', () => {
73
73
  let startDateUtil;
74
74
  let startDateChangeResult;
75
75
 
76
- async function setup () {
76
+ async function setup() {
77
77
  global.fetch = jest.fn(() =>
78
78
  Promise.resolve({
79
79
  json: () =>
@@ -136,7 +136,8 @@ describe('DeliveryStartDate', () => {
136
136
  });
137
137
 
138
138
  it('displays an error and return false if the fetch call errors', async () => {
139
- global.fetch = jest.fn(() => Promise.reject('API is down'));
139
+ const fetchError = new Error('API is down');
140
+ global.fetch = jest.fn(() => Promise.reject(fetchError));
140
141
  startDateUtil = new DeliveryStartDate(document);
141
142
 
142
143
  let startDateChangeResult =
package/utils/email.js CHANGED
@@ -12,7 +12,7 @@ class Email {
12
12
  * @throws If the element not passed
13
13
  * @throws When the email element not found
14
14
  */
15
- constructor (element) {
15
+ constructor(element) {
16
16
  if (!element) {
17
17
  throw new Error('Please supply the DOM element');
18
18
  }
@@ -35,7 +35,7 @@ class Email {
35
35
  /**
36
36
  * Check the values of the two fields and update error state accordingly.
37
37
  */
38
- checkMatch () {
38
+ checkMatch() {
39
39
  if (this.$emailConfirm.value) {
40
40
  if (this.$email.value !== this.$emailConfirm.value) {
41
41
  this.$emailConfirmField.classList.add('o-forms--error');
@@ -54,7 +54,7 @@ class Email {
54
54
  * @param {Function} onNotFound Callback function to run if email does *not* exist.
55
55
  * @returns {Function} The handler function so the caller can unregister it if they need.
56
56
  */
57
- registerEmailExistsCheck (url, onFound, onNotFound) {
57
+ registerEmailExistsCheck(url, onFound, onNotFound) {
58
58
  const handler = () => {
59
59
  this.handleEmailExistsChange(url, onFound, onNotFound);
60
60
  };
@@ -71,7 +71,7 @@ class Email {
71
71
  * @param {Function} onNotFound Function to call when not found
72
72
  * @return {Promise}
73
73
  */
74
- handleEmailExistsChange (url, onFound, onNotFound) {
74
+ handleEmailExistsChange(url, onFound, onNotFound) {
75
75
  if (this.$email.value) {
76
76
  return fetch(url, {
77
77
  method: 'POST',
@@ -170,7 +170,8 @@ describe('Email', () => {
170
170
  });
171
171
 
172
172
  it('calls the onNotFound callback if the call to the url fails', async () => {
173
- global.fetch = jest.fn(() => Promise.reject('API is down'));
173
+ const fetchError = new Error('API is down');
174
+ global.fetch = jest.fn(() => Promise.reject(fetchError));
174
175
 
175
176
  emailElement.value = 'test@example.com';
176
177
  await email.handleEmailExistsChange(url, onFound, onNotFound);
@@ -44,6 +44,6 @@ module.exports = {
44
44
  },
45
45
  };
46
46
 
47
- function notifier (payload, windowObject) {
47
+ function notifier(payload, windowObject) {
48
48
  windowObject.postMessage(JSON.stringify(payload), '*');
49
49
  }
@@ -10,7 +10,7 @@ class FormElement {
10
10
  * @param {object} document The global document object
11
11
  * @param {string} querySelector The selector for the main element used by this component.
12
12
  */
13
- constructor (document, querySelector) {
13
+ constructor(document, querySelector) {
14
14
  this.$document = document;
15
15
 
16
16
  if (!this.$document) {
@@ -31,21 +31,21 @@ class FormElement {
31
31
  /**
32
32
  * Hides the form element.
33
33
  */
34
- hide () {
34
+ hide() {
35
35
  this.$el.classList.add('ncf__hidden');
36
36
  }
37
37
 
38
38
  /**
39
39
  * Shows the form element.
40
40
  */
41
- show () {
41
+ show() {
42
42
  this.$el.classList.remove('ncf__hidden');
43
43
  }
44
44
 
45
45
  /**
46
46
  * Disable any inputs or selects inside form element
47
47
  */
48
- disable () {
48
+ disable() {
49
49
  for (let i = 0; i < this.inputs.length; i++) {
50
50
  this.inputs[i].disabled = true;
51
51
  }
@@ -54,7 +54,7 @@ class FormElement {
54
54
  /**
55
55
  * Enable any inputs or selects inside form element
56
56
  */
57
- enable () {
57
+ enable() {
58
58
  for (let i = 0; i < this.inputs.length; i++) {
59
59
  this.inputs[i].disabled = false;
60
60
  }
@@ -64,14 +64,14 @@ class FormElement {
64
64
  * Get the value of the form element
65
65
  * Assumes the first input or select is what's required
66
66
  */
67
- value () {
67
+ value() {
68
68
  return this.$el.querySelector('input,select').value;
69
69
  }
70
70
 
71
71
  /**
72
72
  * Make first input element required
73
73
  */
74
- makeRequired () {
74
+ makeRequired() {
75
75
  if (this.inputs && this.inputs.length) {
76
76
  this.inputs[0].required = true;
77
77
  }
@@ -81,7 +81,7 @@ class FormElement {
81
81
  /**
82
82
  * Make first input element not required (optional)
83
83
  */
84
- makeOptional () {
84
+ makeOptional() {
85
85
  if (this.inputs && this.inputs.length) {
86
86
  this.inputs[0].required = false;
87
87
  }
package/utils/loader.js CHANGED
@@ -12,7 +12,7 @@ class Loader {
12
12
  * @throws If the document not passed
13
13
  * @throws When the loader element not found
14
14
  */
15
- constructor (element) {
15
+ constructor(element) {
16
16
  if (!element) {
17
17
  throw new Error('Please supply a DOM element');
18
18
  }
@@ -38,7 +38,7 @@ class Loader {
38
38
  /**
39
39
  * Clear the content.
40
40
  */
41
- clearContent () {
41
+ clearContent() {
42
42
  this.$loaderContent.innerHTML = '';
43
43
  }
44
44
 
@@ -48,7 +48,7 @@ class Loader {
48
48
  * @param {string} title The HTML markup/string containing the title of the message.
49
49
  * @param {string} content The HTML markup/string containing the main content of the message.
50
50
  */
51
- setContent ({ title, content }) {
51
+ setContent({ title, content }) {
52
52
  if (title) {
53
53
  if (!this.$loaderContentTitle) {
54
54
  this.$loaderContentTitle = document.createElement('div');
@@ -70,7 +70,7 @@ class Loader {
70
70
  *
71
71
  * @param {object} content The optional content to set *before* showing the loader.
72
72
  */
73
- show (content) {
73
+ show(content) {
74
74
  this._previouslyFocused = document.activeElement;
75
75
 
76
76
  if (content) {
@@ -88,7 +88,7 @@ class Loader {
88
88
  *
89
89
  * @param {object} content The optional content to set *before* showing the loader.
90
90
  */
91
- showAndPreventTabbing (content) {
91
+ showAndPreventTabbing(content) {
92
92
  this.show(content);
93
93
 
94
94
  this.element.addEventListener('keydown', this.interceptTab);
@@ -97,7 +97,7 @@ class Loader {
97
97
  /**
98
98
  * Hide the loader
99
99
  */
100
- hide () {
100
+ hide() {
101
101
  this.$loader.classList.add(this.HIDDEN_CLASS);
102
102
  this.$loader.classList.remove(this.VISIBLE_CLASS);
103
103
  this.$loader.removeAttribute('tabindex');
@@ -114,7 +114,7 @@ class Loader {
114
114
  * Intercepts Tab key events that normally navigate through the content on the page.
115
115
  * @param {object} event The event object for the keypress.
116
116
  */
117
- interceptTab (event) {
117
+ interceptTab(event) {
118
118
  if (event.keyCode === 9) {
119
119
  event.preventDefault();
120
120
  }
@@ -125,7 +125,7 @@ class Loader {
125
125
  * @param {DOMElement} element Show loader over this
126
126
  * @param {Object} content Content for the loader in standard format
127
127
  */
128
- showOnElement (element, content) {
128
+ showOnElement(element, content) {
129
129
  const existingLoader = element.querySelector('.ncf__loader');
130
130
  const loader = new DOMParser()
131
131
  .parseFromString(this.template(content), 'text/html')
@@ -142,7 +142,7 @@ class Loader {
142
142
  * Remove loader from a given element
143
143
  * @param {DOMElement} element Loader inside
144
144
  */
145
- removeFromElement (element) {
145
+ removeFromElement(element) {
146
146
  element.querySelector('.ncf__loader').remove();
147
147
  }
148
148
 
@@ -151,7 +151,7 @@ class Loader {
151
151
  * @param {String} title
152
152
  * @param {String} content
153
153
  */
154
- template ({ title = 'Loading', content = '' }) {
154
+ template({ title = 'Loading', content = '' }) {
155
155
  return `
156
156
  <div class="ncf__loader is-visible ncf__loader--element"
157
157
  role="dialog"
package/utils/password.js CHANGED
@@ -13,7 +13,7 @@ class Password {
13
13
  * @throws If the document not passed
14
14
  * @throws When the password element not found
15
15
  */
16
- constructor (element) {
16
+ constructor(element) {
17
17
  if (!element) {
18
18
  throw new Error('Please supply a DOM element');
19
19
  }
@@ -34,7 +34,7 @@ class Password {
34
34
  * Toggle whether the password is shown in plain text or not
35
35
  * @param {Boolean} mask Pass false to show plain text
36
36
  */
37
- toggleMask (mask) {
37
+ toggleMask(mask) {
38
38
  this.$password.type = mask ? 'password' : 'text';
39
39
  }
40
40
  }
@@ -1,7 +1,4 @@
1
- const {
2
- Period,
3
- Monthly,
4
- } = require('@financial-times/n-pricing');
1
+ const { Period, Monthly } = require('@financial-times/n-pricing');
5
2
 
6
3
  /**
7
4
  * Utility for the `n-conversion-forms/partial/payment-term.html` partial
@@ -33,7 +30,7 @@ class PaymentTerm {
33
30
  * @throws If the document not passed
34
31
  * @throws When the paymentTermField element not found
35
32
  */
36
- constructor (element) {
33
+ constructor(element) {
37
34
  if (!element) {
38
35
  throw new Error('Please supply a DOM element');
39
36
  }
@@ -51,7 +48,7 @@ class PaymentTerm {
51
48
  * @return {String}
52
49
  * @throws If nothing has been selected
53
50
  */
54
- getSelected () {
51
+ getSelected() {
55
52
  const checked = this.$paymentTerm.querySelector('input:checked');
56
53
  if (!checked) {
57
54
  throw new Error('No payment term has been selected');
@@ -64,7 +61,7 @@ class PaymentTerm {
64
61
  * @return {Number}
65
62
  * @throws If no payment term has been selected
66
63
  */
67
- getBaseAmount () {
64
+ getBaseAmount() {
68
65
  const checked = this.$paymentTerm.querySelector('input:checked');
69
66
  if (!checked) {
70
67
  throw new Error('No payment term has been selected');
@@ -76,11 +73,11 @@ class PaymentTerm {
76
73
  * Register on change an event listener
77
74
  * @param {Function} callback Called with event when changed
78
75
  */
79
- onChange (callback = () => {}) {
76
+ onChange(callback = () => {}) {
80
77
  return this.$paymentTerm.addEventListener('change', callback);
81
78
  }
82
79
 
83
- isValidPeriod (period) {
80
+ isValidPeriod(period) {
84
81
  try {
85
82
  // Period should throw an error if it is not properly provided
86
83
  // in order to validate it, we just send in case type is string
@@ -89,9 +86,9 @@ class PaymentTerm {
89
86
  } catch (e) {
90
87
  return false;
91
88
  }
92
- };
89
+ }
93
90
 
94
- getMontlyPriceFromPeriod (amount, currency, period) {
91
+ getMontlyPriceFromPeriod(amount, currency, period) {
95
92
  const periodObj = new Period(period);
96
93
  const monthlyPrice = periodObj.calculatePrice('P1M', amount);
97
94
  return new Monthly({ value: monthlyPrice, currency }).getAmount('monthly');
@@ -101,7 +98,7 @@ class PaymentTerm {
101
98
  * Update the payment term options
102
99
  * @param {Array} options Array of objects contain terms information
103
100
  */
104
- updateOptions (options) {
101
+ updateOptions(options) {
105
102
  const terms = this.$paymentTerm.querySelectorAll(ITEM_CLASS);
106
103
  for (let i = 0; i < terms.length; i++) {
107
104
  const term = terms[i];
@@ -126,9 +123,13 @@ class PaymentTerm {
126
123
  trialPrice.innerHTML = update.trialPrice;
127
124
  }
128
125
  if (monthlyPrice) {
129
- monthlyPrice.innerHTML = this.isValidPeriod(update.value) ?
130
- this.getMontlyPriceFromPeriod(update.amount, update.currency, update.value) :
131
- update.monthlyPrice;
126
+ monthlyPrice.innerHTML = this.isValidPeriod(update.value)
127
+ ? this.getMontlyPriceFromPeriod(
128
+ update.amount,
129
+ update.currency,
130
+ update.value
131
+ )
132
+ : update.monthlyPrice;
132
133
  }
133
134
  }
134
135
  }