@financial-times/n-conversion-forms 27.4.3 → 27.6.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.
@@ -60,6 +60,7 @@ exports[`Debug renders with isTest 1`] = `
60
60
  checkoutVisa: '4242424242424242',
61
61
  checkout3dsChallenge: 'Checkout1!',
62
62
  chaseVisa: '4011361100000010',
63
+ verificationEmail: SYSTEM_CODE + '-' + Date.now() + '@ftqa.org',
63
64
  };
64
65
 
65
66
  function logout () {
@@ -219,6 +220,7 @@ exports[`Debug renders with showHelpers 1`] = `
219
220
  checkoutVisa: '4242424242424242',
220
221
  checkout3dsChallenge: 'Checkout1!',
221
222
  chaseVisa: '4011361100000010',
223
+ verificationEmail: SYSTEM_CODE + '-' + Date.now() + '@ftqa.org',
222
224
  };
223
225
 
224
226
  function logout () {
@@ -0,0 +1,173 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`DeferredBillingTerms renders appropriately and checked 1`] = `""`;
4
+
5
+ exports[`DeferredBillingTerms renders appropriately if a isDeferredBilling 1`] = `
6
+ <p class="o-forms-input o-forms-input--checkbox">
7
+ <span class="ncf__paragraph">
8
+ I confirm I am 16 years or older and have read and agree to the
9
+ <a class="ncf__link--external"
10
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
11
+ title="FT Legal Terms and Conditions help page"
12
+ target="_blank"
13
+ rel="noopener noreferrer"
14
+ data-trackable="terms-and-conditions"
15
+ >
16
+ Terms &amp; Conditions
17
+ </a>
18
+ .
19
+ </span>
20
+ </p>
21
+ <p class="o-forms-input o-forms-input--checkbox">
22
+ <span class="ncf__paragraph">
23
+ I give consent for my chosen payment method to be charged automatically at the end of each subscription term until I cancel it by contacting Customer Care through chat, phone or email.
24
+ </span>
25
+ </p>
26
+ <p class="o-forms-input o-forms-input--checkbox">
27
+ <span class="ncf__paragraph">
28
+ By placing my order, I acknowledge that my subscription will start on the date given above. Any cancellation notice received after that date will take effect at the end of my subscription term and previously paid amounts are non-refundable.
29
+ </span>
30
+ </p>
31
+ <p class="o-forms-input o-forms-input--checkbox">
32
+ <span class="ncf__paragraph">
33
+ Find out more about our cancellation policy in our
34
+ <a class="ncf__link--external"
35
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
36
+ title="FT Legal Terms and Conditions help page"
37
+ target="_blank"
38
+ rel="noopener noreferrer"
39
+ data-trackable="terms-and-conditions"
40
+ >
41
+ Terms &amp; Conditions
42
+ </a>
43
+ .
44
+ </span>
45
+ </p>
46
+ <p class="o-forms-input o-forms-input--checkbox">
47
+ <span class="ncf__paragraph">
48
+ Please note that if you fail to make payment for your Deferred Billing Plan within the due date your subscription will be automatically cancelled.
49
+ <a class="ncf__link--external"
50
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
51
+ title="FT Legal Terms and Conditions help page"
52
+ target="_blank"
53
+ rel="noopener noreferrer"
54
+ data-trackable="terms-and-conditions"
55
+ >
56
+ Terms &amp; Conditions
57
+ </a>
58
+ .
59
+ </span>
60
+ </p>
61
+ <div id="acceptTermsField"
62
+ class="o-forms-field o-layout-typography ncf__validation-error"
63
+ data-validate="required,checked"
64
+ >
65
+ <label class="o-forms-input o-forms-input--checkbox"
66
+ for="accept-deferred-billing-terms"
67
+ id="accept-deferred-terms"
68
+ >
69
+ <input type="checkbox"
70
+ id="accept-deferred-billing-terms"
71
+ name="accept-deferred-billing-terms"
72
+ value="true"
73
+ data-trackable="field-terms"
74
+ aria-required="true"
75
+ required
76
+ >
77
+ <span class="o-forms-input__label">
78
+ I agree with terms &amp; conditions.
79
+ </span>
80
+ <p class="o-forms-input__error">
81
+ Please accept our terms &amp;amp; conditions
82
+ </p>
83
+ </label>
84
+ </div>
85
+ `;
86
+
87
+ exports[`DeferredBillingTerms renders appropriately if all props are set to false - no rendering of the component 1`] = `""`;
88
+
89
+ exports[`DeferredBillingTerms renders appropriately if all props are set to true - rendering of the component 1`] = `
90
+ <p class="o-forms-input o-forms-input--checkbox o-forms-input--invalid">
91
+ <span class="ncf__paragraph">
92
+ I confirm I am 16 years or older and have read and agree to the
93
+ <a class="ncf__link--external"
94
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
95
+ title="FT Legal Terms and Conditions help page"
96
+ target="_blank"
97
+ rel="noopener noreferrer"
98
+ data-trackable="terms-and-conditions"
99
+ >
100
+ Terms &amp; Conditions
101
+ </a>
102
+ .
103
+ </span>
104
+ </p>
105
+ <p class="o-forms-input o-forms-input--checkbox o-forms-input--invalid">
106
+ <span class="ncf__paragraph">
107
+ I give consent for my chosen payment method to be charged automatically at the end of each subscription term until I cancel it by contacting Customer Care through chat, phone or email.
108
+ </span>
109
+ </p>
110
+ <p class="o-forms-input o-forms-input--checkbox o-forms-input--invalid">
111
+ <span class="ncf__paragraph">
112
+ By placing my order, I acknowledge that my subscription will start on the date given above. Any cancellation notice received after that date will take effect at the end of my subscription term and previously paid amounts are non-refundable.
113
+ </span>
114
+ </p>
115
+ <p class="o-forms-input o-forms-input--checkbox o-forms-input--invalid">
116
+ <span class="ncf__paragraph">
117
+ Find out more about our cancellation policy in our
118
+ <a class="ncf__link--external"
119
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
120
+ title="FT Legal Terms and Conditions help page"
121
+ target="_blank"
122
+ rel="noopener noreferrer"
123
+ data-trackable="terms-and-conditions"
124
+ >
125
+ Terms &amp; Conditions
126
+ </a>
127
+ .
128
+ </span>
129
+ </p>
130
+ <p class="o-forms-input o-forms-input--checkbox o-forms-input--invalid">
131
+ <span class="ncf__paragraph">
132
+ Please note that if you fail to make payment for your Deferred Billing Plan within the due date your subscription will be automatically cancelled.
133
+ <a class="ncf__link--external"
134
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
135
+ title="FT Legal Terms and Conditions help page"
136
+ target="_blank"
137
+ rel="noopener noreferrer"
138
+ data-trackable="terms-and-conditions"
139
+ >
140
+ Terms &amp; Conditions
141
+ </a>
142
+ .
143
+ </span>
144
+ </p>
145
+ <div id="acceptTermsField"
146
+ class="o-forms-field o-layout-typography ncf__validation-error"
147
+ data-validate="required,checked"
148
+ >
149
+ <label class="o-forms-input o-forms-input--checkbox o-forms-input--invalid"
150
+ for="accept-deferred-billing-terms"
151
+ id="accept-deferred-terms"
152
+ >
153
+ <input type="checkbox"
154
+ id="accept-deferred-billing-terms"
155
+ name="accept-deferred-billing-terms"
156
+ value="true"
157
+ data-trackable="field-terms"
158
+ aria-required="true"
159
+ required
160
+ >
161
+ <span class="o-forms-input__label">
162
+ I agree with terms &amp; conditions.
163
+ </span>
164
+ <p class="o-forms-input__error">
165
+ Please accept our terms &amp;amp; conditions
166
+ </p>
167
+ </label>
168
+ </div>
169
+ `;
170
+
171
+ exports[`DeferredBillingTerms renders with an error 1`] = `""`;
172
+
173
+ exports[`DeferredBillingTerms renders with default props 1`] = `""`;
@@ -86,6 +86,7 @@ export function Debug ({ isTest = false, showHelpers = false, links = {} }) {
86
86
  checkoutVisa: '4242424242424242',
87
87
  checkout3dsChallenge: 'Checkout1!',
88
88
  chaseVisa: '4011361100000010',
89
+ verificationEmail: SYSTEM_CODE + '-' + Date.now() + '@ftqa.org',
89
90
  };
90
91
 
91
92
  function logout () {
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ const CONSENT_AGE = 16;
5
+ export function DeferredBillingTerms ({ isDeferredBilling = false, checkBoxTrackableAttr = 'field-terms', trackableAttr = 'deferred-billing-terms', errorMessage = 'Please accept our terms &amp; conditions', inputId = 'accept-deferred-billing-terms', fieldId = 'accept-deferred-terms', isChecked = false, hasError = false }) {
6
+ const labelClassName = classNames([
7
+ 'o-forms-input',
8
+ 'o-forms-input--checkbox',
9
+ { 'o-forms-input--invalid': hasError },
10
+ ]);
11
+
12
+ const inputProps = {
13
+ id: `${inputId}`,
14
+ type: 'checkbox',
15
+ name: `${inputId}`,
16
+ value: 'true',
17
+ 'data-trackable': checkBoxTrackableAttr,
18
+ 'aria-required': 'true',
19
+ required: true,
20
+ ...(isChecked && { defaultChecked: true }),
21
+ };
22
+ const divProps = {
23
+ id: 'acceptTermsField',
24
+ className: 'o-forms-field o-layout-typography ncf__validation-error',
25
+ 'data-validate': 'required,checked',
26
+ ...(isChecked && { 'data-trackable': trackableAttr }),
27
+ };
28
+ return isDeferredBilling && (<>
29
+ <p className={labelClassName}>
30
+ <span className="ncf__paragraph">
31
+ I confirm I am {CONSENT_AGE} years or older and have read and agree to the
32
+ {' '}
33
+ <a
34
+ className="ncf__link--external"
35
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
36
+ title="FT Legal Terms and Conditions help page"
37
+ target="_blank"
38
+ rel="noopener noreferrer"
39
+ data-trackable="terms-and-conditions"
40
+ >
41
+ Terms &amp; Conditions
42
+ </a>
43
+ .
44
+ </span>
45
+ </p>
46
+ <p className={labelClassName}>
47
+ <span className="ncf__paragraph">
48
+ I give consent for my chosen payment method to be charged automatically at the end of each subscription term until I cancel it by contacting Customer Care through chat, phone or email.
49
+ </span>
50
+ </p>
51
+ <p className={labelClassName}>
52
+ <span className="ncf__paragraph">
53
+ By placing my order, I acknowledge that my subscription will start on the date given above. Any cancellation notice received after that date will take effect at the end of my subscription term and previously paid amounts are non-refundable.
54
+ </span>
55
+ </p>
56
+ <p className={labelClassName}>
57
+ <span className="ncf__paragraph">
58
+ Find out more about our cancellation policy in our {' '}
59
+ <a
60
+ className="ncf__link--external"
61
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
62
+ title="FT Legal Terms and Conditions help page"
63
+ target="_blank"
64
+ rel="noopener noreferrer"
65
+ data-trackable="terms-and-conditions"
66
+ >
67
+ Terms &amp; Conditions
68
+ </a>
69
+ .
70
+ </span>
71
+ </p>
72
+ <p className={labelClassName}>
73
+ <span className="ncf__paragraph">
74
+ Please note that if you fail to make payment for your Deferred Billing Plan within the due date your subscription will be automatically cancelled.
75
+ {' '} <a
76
+ className="ncf__link--external"
77
+ href="https://help.ft.com/legal-privacy/terms-and-conditions/"
78
+ title="FT Legal Terms and Conditions help page"
79
+ target="_blank"
80
+ rel="noopener noreferrer"
81
+ data-trackable="terms-and-conditions"
82
+ >
83
+ Terms &amp; Conditions
84
+ </a>
85
+ .
86
+ </span>
87
+ </p>
88
+ <div {...divProps}>
89
+ <label className={labelClassName} htmlFor={inputId} id={fieldId}>
90
+ <input {...inputProps} />
91
+ <span className="o-forms-input__label">
92
+ I agree with terms &amp; conditions.
93
+
94
+ </span>
95
+ <p className="o-forms-input__error">
96
+ {errorMessage}
97
+ </p>
98
+ </label>
99
+ </div>
100
+ </>);
101
+
102
+ };
103
+
104
+ DeferredBillingTerms.propTypes = {
105
+ hasError: PropTypes.bool,
106
+ isChecked: PropTypes.bool,
107
+ isDeferredBilling: PropTypes.bool,
108
+ fieldId: PropTypes.string,
109
+ inputId: PropTypes.string,
110
+ trackableAttr: PropTypes.string,
111
+ errorMessage: PropTypes.string
112
+ };
@@ -0,0 +1,42 @@
1
+ import { DeferredBillingTerms } from './index';
2
+ import { expectToRenderCorrectly } from '../test-jest/helpers/expect-to-render-correctly';
3
+
4
+ expect.extend(expectToRenderCorrectly);
5
+
6
+ describe('DeferredBillingTerms', () => {
7
+ it('renders with default props', () => {
8
+ const props = {};
9
+
10
+ expect(DeferredBillingTerms).toRenderCorrectly(props);
11
+ });
12
+
13
+ it('renders with an error', () => {
14
+ const props = { hasError: true };
15
+
16
+ expect(DeferredBillingTerms).toRenderCorrectly(props);
17
+ });
18
+
19
+ it('renders appropriately if a isDeferredBilling', () => {
20
+ const props = { isDeferredBilling: true };
21
+
22
+ expect(DeferredBillingTerms).toRenderCorrectly(props);
23
+ });
24
+
25
+ it('renders appropriately and checked', () => {
26
+ const props = { isChecked: true };
27
+
28
+ expect(DeferredBillingTerms).toRenderCorrectly(props);
29
+ });
30
+
31
+ it('renders appropriately if all props are set to false - no rendering of the component', () => {
32
+ const props = { isChecked: false, isDeferredBilling: false, hasError: false };
33
+
34
+ expect(DeferredBillingTerms).toRenderCorrectly(props);
35
+ });
36
+
37
+ it('renders appropriately if all props are set to true - rendering of the component', () => {
38
+ const props = { iisChecked: true, isDeferredBilling: true, hasError: true };
39
+
40
+ expect(DeferredBillingTerms).toRenderCorrectly(props);
41
+ });
42
+ });
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { DeferredBillingTerms } from './deferred-billing-terms';
3
+
4
+ export default {
5
+ title: 'Deferred Billing Terms',
6
+ component: DeferredBillingTerms,
7
+ argTypes: {
8
+ hasError: { control: 'boolean' },
9
+ isChecked: { control: 'boolean' },
10
+ inputId: { control: 'string' },
11
+ fieldId: { control: 'string' },
12
+ trackableAttr: { control: 'string' },
13
+ errorMessage: { control: 'string' },
14
+ isDeferredBilling: { control: 'boolean' }
15
+ }
16
+ };
17
+
18
+ export const Basic = (args) => <DeferredBillingTerms {...args} />;
19
+ Basic.args = {};
20
+
21
+ export const CheckedFlow = (args) => <DeferredBillingTerms {...args} />;
22
+ CheckedFlow.args = {
23
+ isChecked: true,
24
+ isDeferredBilling: true,
25
+ hasError: false
26
+ };
@@ -54,3 +54,4 @@ export { GraduationDate } from './graduation-date';
54
54
  export { LiteSubConfirmation } from './lite-sub-confirmation';
55
55
  export { GoogleSignIn } from './google-sign-in';
56
56
  export { TextInput } from './text-input';
57
+ export { DeferredBillingTerms } from './deferred-billing-terms';
package/dist/debug.js CHANGED
@@ -33,7 +33,7 @@ function Debug(_ref) {
33
33
  __html: "".concat(isTest ? testEnvironment : productionEnvironment).concat(showHelpers ? helpers : '')
34
34
  };
35
35
  var javascript = {
36
- __html: "\n\tvar FORM_SELECTOR = 'form.ncf';\n\tvar INPUT_SELECTOR = FORM_SELECTOR + ' input:not([type=\"checkbox\"]):not([type=\"radio\"])';\n\tvar SELECT_SELECTOR = FORM_SELECTOR + ' select';\n\tvar CHECKBOX_SELECTOR = FORM_SELECTOR + ' input[type=\"checkbox\"]';\n\tvar RADIO_SELECTOR = FORM_SELECTOR + ' input[type=\"radio\"]';\n\t// This env var gets set in production. We use this when creating email addresses in case any\n\t// get into production so Membership know who to come to about deleting them.\n\tvar SYSTEM_CODE = document.documentElement.getAttribute('data-next-app') || 'n-conversion-forms';\n\tvar COUNTRY_CODE = window.FT && window.FT.country || 'GBR';\n\n\tvar postcodeByCountry = {\n\t\tGBR: 'EC4M9BT',\n\t\tUSA: '10028',\n\t\tCAN: 'K0E 9Z9'\n\t};\n\n\tvar debugData = {\n\t\tbillingCity: 'London',\n\t\tbillingCountry: COUNTRY_CODE,\n\t\tbillingPostcode: postcodeByCountry[COUNTRY_CODE],\n\t\tcountry: COUNTRY_CODE,\n\t\tdeliveryAddressLine1: 'delivery test1',\n\t\tdeliveryAddressLine2: 'delivery test2',\n\t\tdeliveryAddressLine3: 'delivery test3',\n\t\tdeliveryCity: 'delivery city',\n\t\tdeliveryCounty: 'delivery county',\n\t\tdeliveryPostcode: postcodeByCountry[COUNTRY_CODE],\n\t\temail: SYSTEM_CODE + '-' + Date.now() + '@ftqa.org',\n\t\tfirstName: 'Test',\n\t\tindustry: 'DEF',\n\t\tlastName: 'Test',\n\t\tjobTitle: 'CEO',\n\t\torganisation: 'ft-org',\n\t\tpassword: 'password123',\n\t\tposition: 'AS',\n\t\tpostCode: postcodeByCountry[COUNTRY_CODE],\n\t\tprimaryTelephone: '0987654321',\n\t\tresponsibility: 'ADL',\n\t\tukVisaWorldpay: '4111111111111111',\n\t\tusAmex: '378282246310005',\n\t\tusVisaWorldpay: '4112344112344113',\n\t\tcheckoutVisa: '4242424242424242',\n\t\tcheckout3dsChallenge: 'Checkout1!',\n\t\tchaseVisa: '4011361100000010',\n\t};\n\n\tfunction logout () {\n\t\tconst options = {\n\t\t\tmode: 'no-cors',\n\t\t\tcredentials: 'include'\n\t\t};\n\t\tfetch('https://www.ft.com/logout', options).then(function () {\n\t\t\twindow.location.reload();\n\t\t});\n\t}\n\n\tfunction fillForm () {\n\t\tvar changeEvent = document.createEvent('HTMLEvents');\n\t\tchangeEvent.initEvent('change', false, true);\n\n\t\tvar inputs = document.querySelectorAll(INPUT_SELECTOR + ', ' + SELECT_SELECTOR);\n\t\tinputs.forEach(function (input) {\n\t\t\tif (!/hidden/i.test(input.type) && input.disabled === false) {\n\t\t\t\tvar value = debugData[input.name];\n\t\t\t\tinput.value = value;\n\t\t\t\tinput.dispatchEvent(changeEvent);\n\t\t\t}\n\t\t});\n\t\tvar checkboxes = document.querySelectorAll(CHECKBOX_SELECTOR + ', ' + RADIO_SELECTOR);\n\t\tcheckboxes.forEach(function (checkbox) {\n\t\t\tcheckbox.checked = true;\n\t\t\tcheckbox.dispatchEvent(changeEvent);\n\t\t});\n\t}\n\n\tfunction submitForm () {\n\t\tdocument.querySelector(FORM_SELECTOR).submit();\n\t}\n\n\tfunction copyToClipboard (name) {\n\t\tvar string = debugData[name];\n\t\tvar textarea = document.createElement('textarea');\n\t\ttextarea.value = string;\n\t\tdocument.body.appendChild(textarea);\n\t\ttextarea.select();\n\t\tdocument.execCommand('copy');\n\t\tdocument.body.removeChild(textarea);\n\t}\n\n\tfunction setTestEnvironment (state) {\n\t\tvar flags = document.cookie.match('(^|[^;]+)\\\\s*next-flags\\\\s*=\\\\s*([^;]+)').pop();\n\t\tvar flag = 'conversionSandbox%3A';\n\t\tflags = flags.replace(flag + 'on', '');\n\t\tflags = flags.replace(flag + 'off', '');\n\t\tdocument.cookie = 'next-flags=' + flags + '%2C' + flag + state + '; path=/; domain=.ft.com;';\n\t\twindow.location.reload();\n\t}\n\t"
36
+ __html: "\n\tvar FORM_SELECTOR = 'form.ncf';\n\tvar INPUT_SELECTOR = FORM_SELECTOR + ' input:not([type=\"checkbox\"]):not([type=\"radio\"])';\n\tvar SELECT_SELECTOR = FORM_SELECTOR + ' select';\n\tvar CHECKBOX_SELECTOR = FORM_SELECTOR + ' input[type=\"checkbox\"]';\n\tvar RADIO_SELECTOR = FORM_SELECTOR + ' input[type=\"radio\"]';\n\t// This env var gets set in production. We use this when creating email addresses in case any\n\t// get into production so Membership know who to come to about deleting them.\n\tvar SYSTEM_CODE = document.documentElement.getAttribute('data-next-app') || 'n-conversion-forms';\n\tvar COUNTRY_CODE = window.FT && window.FT.country || 'GBR';\n\n\tvar postcodeByCountry = {\n\t\tGBR: 'EC4M9BT',\n\t\tUSA: '10028',\n\t\tCAN: 'K0E 9Z9'\n\t};\n\n\tvar debugData = {\n\t\tbillingCity: 'London',\n\t\tbillingCountry: COUNTRY_CODE,\n\t\tbillingPostcode: postcodeByCountry[COUNTRY_CODE],\n\t\tcountry: COUNTRY_CODE,\n\t\tdeliveryAddressLine1: 'delivery test1',\n\t\tdeliveryAddressLine2: 'delivery test2',\n\t\tdeliveryAddressLine3: 'delivery test3',\n\t\tdeliveryCity: 'delivery city',\n\t\tdeliveryCounty: 'delivery county',\n\t\tdeliveryPostcode: postcodeByCountry[COUNTRY_CODE],\n\t\temail: SYSTEM_CODE + '-' + Date.now() + '@ftqa.org',\n\t\tfirstName: 'Test',\n\t\tindustry: 'DEF',\n\t\tlastName: 'Test',\n\t\tjobTitle: 'CEO',\n\t\torganisation: 'ft-org',\n\t\tpassword: 'password123',\n\t\tposition: 'AS',\n\t\tpostCode: postcodeByCountry[COUNTRY_CODE],\n\t\tprimaryTelephone: '0987654321',\n\t\tresponsibility: 'ADL',\n\t\tukVisaWorldpay: '4111111111111111',\n\t\tusAmex: '378282246310005',\n\t\tusVisaWorldpay: '4112344112344113',\n\t\tcheckoutVisa: '4242424242424242',\n\t\tcheckout3dsChallenge: 'Checkout1!',\n\t\tchaseVisa: '4011361100000010',\n\t\tverificationEmail: SYSTEM_CODE + '-' + Date.now() + '@ftqa.org',\n\t};\n\n\tfunction logout () {\n\t\tconst options = {\n\t\t\tmode: 'no-cors',\n\t\t\tcredentials: 'include'\n\t\t};\n\t\tfetch('https://www.ft.com/logout', options).then(function () {\n\t\t\twindow.location.reload();\n\t\t});\n\t}\n\n\tfunction fillForm () {\n\t\tvar changeEvent = document.createEvent('HTMLEvents');\n\t\tchangeEvent.initEvent('change', false, true);\n\n\t\tvar inputs = document.querySelectorAll(INPUT_SELECTOR + ', ' + SELECT_SELECTOR);\n\t\tinputs.forEach(function (input) {\n\t\t\tif (!/hidden/i.test(input.type) && input.disabled === false) {\n\t\t\t\tvar value = debugData[input.name];\n\t\t\t\tinput.value = value;\n\t\t\t\tinput.dispatchEvent(changeEvent);\n\t\t\t}\n\t\t});\n\t\tvar checkboxes = document.querySelectorAll(CHECKBOX_SELECTOR + ', ' + RADIO_SELECTOR);\n\t\tcheckboxes.forEach(function (checkbox) {\n\t\t\tcheckbox.checked = true;\n\t\t\tcheckbox.dispatchEvent(changeEvent);\n\t\t});\n\t}\n\n\tfunction submitForm () {\n\t\tdocument.querySelector(FORM_SELECTOR).submit();\n\t}\n\n\tfunction copyToClipboard (name) {\n\t\tvar string = debugData[name];\n\t\tvar textarea = document.createElement('textarea');\n\t\ttextarea.value = string;\n\t\tdocument.body.appendChild(textarea);\n\t\ttextarea.select();\n\t\tdocument.execCommand('copy');\n\t\tdocument.body.removeChild(textarea);\n\t}\n\n\tfunction setTestEnvironment (state) {\n\t\tvar flags = document.cookie.match('(^|[^;]+)\\\\s*next-flags\\\\s*=\\\\s*([^;]+)').pop();\n\t\tvar flag = 'conversionSandbox%3A';\n\t\tflags = flags.replace(flag + 'on', '');\n\t\tflags = flags.replace(flag + 'off', '');\n\t\tdocument.cookie = 'next-flags=' + flags + '%2C' + flag + state + '; path=/; domain=.ft.com;';\n\t\twindow.location.reload();\n\t}\n\t"
37
37
  };
38
38
  var style = {
39
39
  __html: "\n\t.ncf__debug-panel {\n\t\tposition: absolute;\n\t\tbackground-color: #262a33;\n\t\tcolor: #ffffff;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\tpadding: 10px;\n\t\tposition: fixed;\n\t\tz-index: 1000;\n\t\topacity: 0.8;\n\t}\n\t.ncf__debug-button--test {\n\t\tbackground-color: #008040;\n\t}\n\t.ncf__debug-button--production {\n\t\tbackground-color: #990000;\n\t}\n\t.ncf__button--debug {\n\t\tpadding: 0px 5px;\n\t}\n\t"
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.DeferredBillingTerms = DeferredBillingTerms;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
16
+ var _classnames = _interopRequireDefault(require("classnames"));
17
+
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19
+
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
+
22
+ var CONSENT_AGE = 16;
23
+
24
+ function DeferredBillingTerms(_ref) {
25
+ var _ref$isDeferredBillin = _ref.isDeferredBilling,
26
+ isDeferredBilling = _ref$isDeferredBillin === void 0 ? false : _ref$isDeferredBillin,
27
+ _ref$checkBoxTrackabl = _ref.checkBoxTrackableAttr,
28
+ checkBoxTrackableAttr = _ref$checkBoxTrackabl === void 0 ? 'field-terms' : _ref$checkBoxTrackabl,
29
+ _ref$trackableAttr = _ref.trackableAttr,
30
+ trackableAttr = _ref$trackableAttr === void 0 ? 'deferred-billing-terms' : _ref$trackableAttr,
31
+ _ref$errorMessage = _ref.errorMessage,
32
+ errorMessage = _ref$errorMessage === void 0 ? 'Please accept our terms &amp; conditions' : _ref$errorMessage,
33
+ _ref$inputId = _ref.inputId,
34
+ inputId = _ref$inputId === void 0 ? 'accept-deferred-billing-terms' : _ref$inputId,
35
+ _ref$fieldId = _ref.fieldId,
36
+ fieldId = _ref$fieldId === void 0 ? 'accept-deferred-terms' : _ref$fieldId,
37
+ _ref$isChecked = _ref.isChecked,
38
+ isChecked = _ref$isChecked === void 0 ? false : _ref$isChecked,
39
+ _ref$hasError = _ref.hasError,
40
+ hasError = _ref$hasError === void 0 ? false : _ref$hasError;
41
+ var labelClassName = (0, _classnames["default"])(['o-forms-input', 'o-forms-input--checkbox', {
42
+ 'o-forms-input--invalid': hasError
43
+ }]);
44
+
45
+ var inputProps = _objectSpread({
46
+ id: "".concat(inputId),
47
+ type: 'checkbox',
48
+ name: "".concat(inputId),
49
+ value: 'true',
50
+ 'data-trackable': checkBoxTrackableAttr,
51
+ 'aria-required': 'true',
52
+ required: true
53
+ }, isChecked && {
54
+ defaultChecked: true
55
+ });
56
+
57
+ var divProps = _objectSpread({
58
+ id: 'acceptTermsField',
59
+ className: 'o-forms-field o-layout-typography ncf__validation-error',
60
+ 'data-validate': 'required,checked'
61
+ }, isChecked && {
62
+ 'data-trackable': trackableAttr
63
+ });
64
+
65
+ return isDeferredBilling && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("p", {
66
+ className: labelClassName
67
+ }, /*#__PURE__*/_react["default"].createElement("span", {
68
+ className: "ncf__paragraph"
69
+ }, "I confirm I am ", CONSENT_AGE, " years or older and have read and agree to the", ' ', /*#__PURE__*/_react["default"].createElement("a", {
70
+ className: "ncf__link--external",
71
+ href: "https://help.ft.com/legal-privacy/terms-and-conditions/",
72
+ title: "FT Legal Terms and Conditions help page",
73
+ target: "_blank",
74
+ rel: "noopener noreferrer",
75
+ "data-trackable": "terms-and-conditions"
76
+ }, "Terms & Conditions"), ".")), /*#__PURE__*/_react["default"].createElement("p", {
77
+ className: labelClassName
78
+ }, /*#__PURE__*/_react["default"].createElement("span", {
79
+ className: "ncf__paragraph"
80
+ }, "I give consent for my chosen payment method to be charged automatically at the end of each subscription term until I cancel it by contacting Customer Care through chat, phone or email.")), /*#__PURE__*/_react["default"].createElement("p", {
81
+ className: labelClassName
82
+ }, /*#__PURE__*/_react["default"].createElement("span", {
83
+ className: "ncf__paragraph"
84
+ }, "By placing my order, I acknowledge that my subscription will start on the date given above. Any cancellation notice received after that date will take effect at the end of my subscription term and previously paid amounts are non-refundable.")), /*#__PURE__*/_react["default"].createElement("p", {
85
+ className: labelClassName
86
+ }, /*#__PURE__*/_react["default"].createElement("span", {
87
+ className: "ncf__paragraph"
88
+ }, "Find out more about our cancellation policy in our ", ' ', /*#__PURE__*/_react["default"].createElement("a", {
89
+ className: "ncf__link--external",
90
+ href: "https://help.ft.com/legal-privacy/terms-and-conditions/",
91
+ title: "FT Legal Terms and Conditions help page",
92
+ target: "_blank",
93
+ rel: "noopener noreferrer",
94
+ "data-trackable": "terms-and-conditions"
95
+ }, "Terms & Conditions"), ".")), /*#__PURE__*/_react["default"].createElement("p", {
96
+ className: labelClassName
97
+ }, /*#__PURE__*/_react["default"].createElement("span", {
98
+ className: "ncf__paragraph"
99
+ }, "Please note that if you fail to make payment for your Deferred Billing Plan within the due date your subscription will be automatically cancelled.", ' ', " ", /*#__PURE__*/_react["default"].createElement("a", {
100
+ className: "ncf__link--external",
101
+ href: "https://help.ft.com/legal-privacy/terms-and-conditions/",
102
+ title: "FT Legal Terms and Conditions help page",
103
+ target: "_blank",
104
+ rel: "noopener noreferrer",
105
+ "data-trackable": "terms-and-conditions"
106
+ }, "Terms & Conditions"), ".")), /*#__PURE__*/_react["default"].createElement("div", divProps, /*#__PURE__*/_react["default"].createElement("label", {
107
+ className: labelClassName,
108
+ htmlFor: inputId,
109
+ id: fieldId
110
+ }, /*#__PURE__*/_react["default"].createElement("input", inputProps), /*#__PURE__*/_react["default"].createElement("span", {
111
+ className: "o-forms-input__label"
112
+ }, "I agree with terms & conditions."), /*#__PURE__*/_react["default"].createElement("p", {
113
+ className: "o-forms-input__error"
114
+ }, errorMessage))));
115
+ }
116
+
117
+ ;
118
+ DeferredBillingTerms.propTypes = {
119
+ hasError: _propTypes["default"].bool,
120
+ isChecked: _propTypes["default"].bool,
121
+ isDeferredBilling: _propTypes["default"].bool,
122
+ fieldId: _propTypes["default"].string,
123
+ inputId: _propTypes["default"].string,
124
+ trackableAttr: _propTypes["default"].string,
125
+ errorMessage: _propTypes["default"].string
126
+ };
package/dist/index.js CHANGED
@@ -81,6 +81,12 @@ Object.defineProperty(exports, "DecisionMaker", {
81
81
  return _decisionMaker.DecisionMaker;
82
82
  }
83
83
  });
84
+ Object.defineProperty(exports, "DeferredBillingTerms", {
85
+ enumerable: true,
86
+ get: function get() {
87
+ return _deferredBillingTerms.DeferredBillingTerms;
88
+ }
89
+ });
84
90
  Object.defineProperty(exports, "DeliveryAddress", {
85
91
  enumerable: true,
86
92
  get: function get() {
@@ -450,4 +456,6 @@ var _liteSubConfirmation = require("./lite-sub-confirmation");
450
456
 
451
457
  var _googleSignIn = require("./google-sign-in");
452
458
 
453
- var _textInput = require("./text-input");
459
+ var _textInput = require("./text-input");
460
+
461
+ var _deferredBillingTerms = require("./deferred-billing-terms");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "27.4.3",
3
+ "version": "27.6.0",
4
4
  "description": "Containing jsx components and styles for forms included on Accounts and Acqusition apps (next-signup, next-profile, next-retention, etc).",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {