@rebilly/instruments 4.4.0 → 4.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.
Files changed (134) hide show
  1. package/.babelrc +24 -26
  2. package/CHANGELOG.md +14 -0
  3. package/dist/index.js +14 -40
  4. package/dist/index.min.js +14 -40
  5. package/package.json +16 -5
  6. package/project.json +9 -0
  7. package/rollup.config.mjs +21 -26
  8. package/src/data/options-schema/index.js +94 -78
  9. package/src/data/options-schema/schemas/options-schema.js +420 -408
  10. package/src/events/base-event.js +34 -34
  11. package/src/events/events.spec.js +6 -6
  12. package/src/events/index.js +5 -5
  13. package/src/functions/destroy.js +19 -19
  14. package/src/functions/destroy.spec.js +41 -41
  15. package/src/functions/mount/fetch-data.js +200 -193
  16. package/src/functions/mount/fetch-data.spec.js +287 -285
  17. package/src/functions/mount/get-lead-source-data.js +31 -31
  18. package/src/functions/mount/get-lead-source-data.spec.js +19 -19
  19. package/src/functions/mount/index.js +73 -65
  20. package/src/functions/mount/mount.spec.js +77 -66
  21. package/src/functions/mount/setup-element.js +23 -23
  22. package/src/functions/mount/setup-framepay-theme.js +86 -68
  23. package/src/functions/mount/setup-framepay.js +9 -5
  24. package/src/functions/mount/setup-i18n.js +15 -15
  25. package/src/functions/mount/setup-options.js +74 -74
  26. package/src/functions/mount/setup-options.spec.js +325 -289
  27. package/src/functions/mount/setup-storefront.js +15 -20
  28. package/src/functions/mount/setup-styles-vars.js +19 -22
  29. package/src/functions/mount/setup-user-flow.js +51 -47
  30. package/src/functions/on.js +5 -5
  31. package/src/functions/on.spec.js +60 -51
  32. package/src/functions/purchase.js +149 -134
  33. package/src/functions/purchase.spec.js +59 -56
  34. package/src/functions/setup.js +53 -49
  35. package/src/functions/setup.spec.js +88 -75
  36. package/src/functions/show.js +13 -14
  37. package/src/functions/show.spec.js +53 -53
  38. package/src/functions/update.js +30 -28
  39. package/src/functions/update.spec.js +94 -93
  40. package/src/i18n/en.json +32 -32
  41. package/src/i18n/es.json +29 -29
  42. package/src/i18n/i18n.spec.js +18 -18
  43. package/src/i18n/index.js +48 -48
  44. package/src/instance.js +36 -36
  45. package/src/instance.spec.js +29 -27
  46. package/src/loader/index.js +95 -70
  47. package/src/loader/loader.spec.js +63 -63
  48. package/src/state/iframes.js +21 -21
  49. package/src/state/index.js +56 -54
  50. package/src/storefront/account-and-website.js +10 -8
  51. package/src/storefront/account-and-website.spec.js +55 -55
  52. package/src/storefront/deposit-requests.js +6 -6
  53. package/src/storefront/fetch-plans-from-addons-bumpOffer.js +21 -19
  54. package/src/storefront/fetch-products-from-plans.js +52 -51
  55. package/src/storefront/fetch-products-from-plans.spec.js +90 -87
  56. package/src/storefront/index.js +56 -49
  57. package/src/storefront/invoices.js +15 -15
  58. package/src/storefront/invoices.spec.js +69 -65
  59. package/src/storefront/models/account-model.js +29 -32
  60. package/src/storefront/models/base-model.js +6 -9
  61. package/src/storefront/models/deposit-request-model.js +22 -13
  62. package/src/storefront/models/invoice-model.js +16 -16
  63. package/src/storefront/models/payment-metadata.js +4 -4
  64. package/src/storefront/models/plan-model.js +73 -64
  65. package/src/storefront/models/ready-to-pay-model.js +59 -59
  66. package/src/storefront/models/summary-model.js +43 -46
  67. package/src/storefront/models/transaction-model.js +11 -14
  68. package/src/storefront/payment-instruments.js +38 -35
  69. package/src/storefront/payment-instruments.spec.js +81 -62
  70. package/src/storefront/purchase.js +50 -44
  71. package/src/storefront/purchase.spec.js +40 -40
  72. package/src/storefront/ready-to-pay.js +75 -77
  73. package/src/storefront/ready-to-pay.spec.js +59 -54
  74. package/src/storefront/storefront.spec.js +9 -9
  75. package/src/storefront/summary.js +93 -67
  76. package/src/storefront/summary.spec.js +108 -106
  77. package/src/storefront/transactions.js +6 -6
  78. package/src/style/base/default-theme.js +928 -923
  79. package/src/style/base/theme.js +21 -21
  80. package/src/style/base/theme.spec.js +13 -13
  81. package/src/style/index.js +3 -3
  82. package/src/style/utils/border.js +40 -27
  83. package/src/style/utils/color-values.js +18 -18
  84. package/src/style/utils/minifyCss.js +6 -6
  85. package/src/utils/add-dom-element.js +14 -14
  86. package/src/utils/format-currency.js +6 -5
  87. package/src/utils/has-valid-css-selector.js +2 -2
  88. package/src/utils/index.js +6 -6
  89. package/src/utils/is-dom-element.js +1 -1
  90. package/src/utils/process-property-as-dom-element.js +22 -22
  91. package/src/utils/quantity.js +26 -28
  92. package/src/utils/sleep.js +3 -1
  93. package/src/views/amount-selector.js +37 -36
  94. package/src/views/common/iframe/base-iframe.js +53 -52
  95. package/src/views/common/iframe/events/change-iframe-src-handler.js +5 -5
  96. package/src/views/common/iframe/events/dispatch-event-handler.js +4 -4
  97. package/src/views/common/iframe/events/resize-component-handler.js +8 -8
  98. package/src/views/common/iframe/events/show-error-handler.js +2 -2
  99. package/src/views/common/iframe/events/stop-loader-handler.js +8 -8
  100. package/src/views/common/iframe/events/update-addons-handler.js +20 -13
  101. package/src/views/common/iframe/events/update-coupons-handler.js +9 -9
  102. package/src/views/common/iframe/events/update-items-handler.js +26 -22
  103. package/src/views/common/iframe/modal-iframe.js +67 -56
  104. package/src/views/common/iframe/view-iframe.js +11 -11
  105. package/src/views/common/render-utilities.js +2 -2
  106. package/src/views/confirmation.js +33 -30
  107. package/src/views/errors.js +89 -79
  108. package/src/views/form.js +41 -37
  109. package/src/views/method-selector/express-methods.js +46 -46
  110. package/src/views/method-selector/generate-digital-wallet.js +46 -45
  111. package/src/views/method-selector/generate-digital-wallet.spec.js +104 -102
  112. package/src/views/method-selector/generate-framepay-config.js +53 -51
  113. package/src/views/method-selector/generate-framepay-config.spec.js +197 -173
  114. package/src/views/method-selector/get-method-data.js +5 -6
  115. package/src/views/method-selector/get-payment-methods.js +18 -16
  116. package/src/views/method-selector/get-payment-methods.spec.js +29 -27
  117. package/src/views/method-selector/index.js +154 -139
  118. package/src/views/method-selector/method-selector.spec.js +13 -13
  119. package/src/views/method-selector/mount-bump-offer.js +65 -49
  120. package/src/views/method-selector/mount-express-methods.js +89 -85
  121. package/src/views/modal.js +74 -67
  122. package/src/views/result.js +14 -14
  123. package/src/views/summary.js +25 -26
  124. package/tests/async-utilities.js +13 -13
  125. package/tests/mocks/framepay-mock.js +9 -8
  126. package/tests/mocks/rebilly-api-mock.js +5 -3
  127. package/tests/mocks/rebilly-instruments-mock.js +121 -117
  128. package/tests/mocks/storefront-api-mock.js +55 -48
  129. package/tests/mocks/storefront-mock.js +10 -14
  130. package/tests/msw/server.js +6 -6
  131. package/tests/setup-test.js +14 -16
  132. package/vitest.config.js +14 -14
  133. package/.eslintrc.js +0 -34
  134. package/.prettierrc.js +0 -11
@@ -13,18 +13,47 @@ import { updateSummary } from '../summary';
13
13
  import { mountAmountSelector } from '../amount-selector';
14
14
 
15
15
  function getElement(id, rootElement = state.form) {
16
- return rootElement.querySelector(`[data-rebilly-instruments="${id}"]`);
16
+ return rootElement.querySelector(`[data-rebilly-instruments="${id}"]`);
17
17
  }
18
18
 
19
- const bumpOfferElement = () => {
20
- const rootDiv = document.createElement('div');
21
- rootDiv.classList.add('rebilly-instruments-bump-offers');
22
- rootDiv.setAttribute('data-rebilly-instruments', 'bump-offer');
23
- return rootDiv;
19
+ const getBumpOfferElement = () => {
20
+ const rootDiv = document.createElement('div');
21
+ rootDiv.classList.add('rebilly-instruments-bump-offers');
22
+ rootDiv.setAttribute('data-rebilly-instruments', 'bump-offer');
23
+ return rootDiv;
24
+ };
25
+
26
+ export function hideExtraUI() {
27
+ const { expressMethods } = getPaymentMethods();
28
+
29
+ if (state.options?.deposit) {
30
+ const linkElement = getElement('deposit-back');
31
+ if (linkElement) {
32
+ linkElement.style.height = '0px';
33
+ linkElement.style.overflow = 'hidden';
34
+ }
35
+ }
36
+
37
+ if (expressMethods.length) {
38
+ const expressMethodsElement = getElement('express-methods');
39
+ if (expressMethodsElement) {
40
+ expressMethodsElement.style.height = '0px';
41
+ expressMethodsElement.style.overflow = 'hidden';
42
+ }
43
+ }
44
+
45
+ if (state.options?.bumpOffer?.length) {
46
+ const bumpOfferElement = getElement('bump-offer');
47
+ if (bumpOfferElement) {
48
+ bumpOfferElement.style.height = '0px';
49
+ bumpOfferElement.style.overflow = 'hidden';
50
+ bumpOfferElement.style.marginBottom = '0px';
51
+ }
52
+ }
24
53
  }
25
54
 
26
55
  const backToAmountElement = () => {
27
- const template = `
56
+ const template = `
28
57
  <div class="rebilly-instruments-confirmation-go-back-link" style="display: inline-block;margin-bottom: var(--rebilly-spacingM);margin-left: calc(var(--rebilly-spacingXs) * -1);">
29
58
  <a
30
59
  class="rebilly-instruments-link has-icon-left"
@@ -45,27 +74,24 @@ const backToAmountElement = () => {
45
74
  </a>
46
75
  </div>
47
76
  `;
48
- const rootDiv = document.createElement('div');
49
- rootDiv.setAttribute('data-rebilly-instruments', 'deposit-back');
50
- rootDiv.innerHTML += template;
51
-
52
- const link = rootDiv.querySelector('.rebilly-instruments-link');
53
- link.addEventListener('click', () => {
54
- hideExtraUI();
55
- mountAmountSelector();
56
- });
57
-
58
- return rootDiv;
59
- }
77
+ const rootDiv = document.createElement('div');
78
+ rootDiv.setAttribute('data-rebilly-instruments', 'deposit-back');
79
+ rootDiv.innerHTML += template;
80
+
81
+ const link = rootDiv.querySelector('.rebilly-instruments-link');
82
+ link.addEventListener('click', () => {
83
+ hideExtraUI();
84
+ mountAmountSelector();
85
+ });
60
86
 
87
+ return rootDiv;
88
+ };
61
89
 
62
- const expressMethodsElement = ({
63
- expressMethods,
64
- }) => {
65
- const rootDiv = document.createElement('div');
66
- rootDiv.classList.add('rebilly-instruments-method-selector');
67
- rootDiv.setAttribute('data-rebilly-instruments', 'express-methods');
68
- rootDiv.innerHTML = `
90
+ const expressMethodsElement = ({ expressMethods }) => {
91
+ const rootDiv = document.createElement('div');
92
+ rootDiv.classList.add('rebilly-instruments-method-selector');
93
+ rootDiv.setAttribute('data-rebilly-instruments', 'express-methods');
94
+ rootDiv.innerHTML = `
69
95
  <div class="rebilly-instruments-express-methods ">
70
96
  <span data-rebilly-i18n="form.expressCheckout" class="rebilly-instruments-express-methods-label">Express checkout</span>
71
97
  <div class="rebilly-instruments-express-methods-container" data-rebilly-instruments="express-methods-container"></div>
@@ -74,135 +100,124 @@ const expressMethodsElement = ({
74
100
  <span class="rebilly-instruments-divider-label" data-rebilly-i18n="form.or">Or</span>
75
101
  </div>
76
102
  `;
77
- const expressMethodsContainer = getElement('express-methods-container', rootDiv);
78
-
79
- const useCompactExpressInstruments = state.options.paymentInstruments.compactExpressInstruments && expressMethods.length;
80
- if (useCompactExpressInstruments) {
81
- rootDiv.classList.add('has-express-compact');
82
- expressMethodsContainer.classList.add('is-compact')
83
- }
84
-
85
- return rootDiv;
86
- }
87
-
88
- export function hideExtraUI() {
89
- const { expressMethods } = getPaymentMethods();
90
-
91
- if (state.options?.deposit) {
92
- const linkElement = getElement('deposit-back');
93
- if (linkElement) {
94
- linkElement.style.height = '0px';
95
- linkElement.style.overflow = 'hidden';
103
+ const expressMethodsContainer = getElement(
104
+ 'express-methods-container',
105
+ rootDiv,
106
+ );
107
+
108
+ const useCompactExpressInstruments =
109
+ state.options.paymentInstruments.compactExpressInstruments &&
110
+ expressMethods.length;
111
+ if (useCompactExpressInstruments) {
112
+ rootDiv.classList.add('has-express-compact');
113
+ expressMethodsContainer.classList.add('is-compact');
96
114
  }
97
- }
98
115
 
99
- if (expressMethods.length) {
100
- const expressMethodsElement = getElement('express-methods');
101
- if (expressMethodsElement) {
102
- expressMethodsElement.style.height = '0px';
103
- expressMethodsElement.style.overflow = 'hidden';
104
- }
105
- }
106
-
107
- if (state.options?.bumpOffer?.length) {
108
- const bumpOfferElement = getElement('bump-offer');
109
- if (bumpOfferElement) {
110
- bumpOfferElement.style.height = '0px';
111
- bumpOfferElement.style.overflow = 'hidden';
112
- bumpOfferElement.style.marginBottom = '0px';
113
- }
114
- }
115
- }
116
+ return rootDiv;
117
+ };
116
118
 
117
119
  export async function mountMethodSelector() {
118
- const contentEl = getElement('content');
119
- const formEl = getElement('form');
120
-
121
- const { expressMethods, methods } = getPaymentMethods();
122
-
123
- if (state.options?.deposit) {
124
- const existingDepositBackElement = getElement('deposit-back');
125
- if (existingDepositBackElement) {
126
- existingDepositBackElement.style.height = 'auto';
127
- } else {
128
- contentEl.insertBefore(backToAmountElement(), formEl);
120
+ const contentEl = getElement('content');
121
+ const formEl = getElement('form');
122
+
123
+ const { expressMethods, methods } = getPaymentMethods();
124
+
125
+ if (state.options?.deposit) {
126
+ const existingDepositBackElement = getElement('deposit-back');
127
+ if (existingDepositBackElement) {
128
+ existingDepositBackElement.style.height = 'auto';
129
+ } else {
130
+ contentEl.insertBefore(backToAmountElement(), formEl);
131
+ }
129
132
  }
130
- }
131
133
 
132
- if (expressMethods.length) {
133
- const existingExpressMethodElement = getElement('express-methods');
134
- if (existingExpressMethodElement) {
135
- existingExpressMethodElement.style.height = 'auto';
136
- } else {
137
- contentEl.insertBefore(expressMethodsElement({expressMethods}), formEl);
138
- state.options.digitalWallet = generateDigitalWallet({ expressMethods });
139
- const container = document.querySelector('[data-rebilly-instruments="express-methods-container"]');
140
- mountExpressMethods({
141
- methods: expressMethods,
142
- container,
143
- });
134
+ if (expressMethods.length) {
135
+ const existingExpressMethodElement = getElement('express-methods');
136
+ if (existingExpressMethodElement) {
137
+ existingExpressMethodElement.style.height = 'auto';
138
+ } else {
139
+ contentEl.insertBefore(
140
+ expressMethodsElement({ expressMethods }),
141
+ formEl,
142
+ );
143
+ state.options.digitalWallet = generateDigitalWallet({
144
+ expressMethods,
145
+ });
146
+ const container = document.querySelector(
147
+ '[data-rebilly-instruments="express-methods-container"]',
148
+ );
149
+ mountExpressMethods({
150
+ methods: expressMethods,
151
+ container,
152
+ });
153
+ }
144
154
  }
145
- }
146
155
 
147
- if (state.options?.bumpOffer?.length) {
148
- const existingExpressMethodElement = getElement('bump-offer');
149
- if (existingExpressMethodElement) {
150
- existingExpressMethodElement.style.height = 'auto';
151
- existingExpressMethodElement.style.marginBottom = 'calc(var(--rebilly-spacingM) + var(--rebilly-fontSizeS))';
152
- } else {
153
- contentEl.insertBefore(bumpOfferElement(), formEl);
154
- const container = getElement('bump-offer');
155
- mountBumpOffer({
156
- container,
157
- });
156
+ if (state.options?.bumpOffer?.length) {
157
+ const existingExpressMethodElement = getElement('bump-offer');
158
+ if (existingExpressMethodElement) {
159
+ existingExpressMethodElement.style.height = 'auto';
160
+ existingExpressMethodElement.style.marginBottom =
161
+ 'calc(var(--rebilly-spacingM) + var(--rebilly-fontSizeS))';
162
+ } else {
163
+ contentEl.insertBefore(getBumpOfferElement(), formEl);
164
+ const container = getElement('bump-offer');
165
+ mountBumpOffer({
166
+ container,
167
+ });
168
+ }
158
169
  }
159
- }
160
170
 
161
- if (methods.length) {
162
- const iframe = iframes.form;
163
- if (!iframe) {
164
- await mountForm();
171
+ if (methods.length) {
172
+ const iframe = iframes.form;
173
+ if (!iframe) {
174
+ await mountForm();
175
+ }
176
+
177
+ const modelSafeState = state.toModel();
178
+ const model = {
179
+ options: modelSafeState.options,
180
+ data: modelSafeState.data,
181
+ mainStyleVars: modelSafeState.mainStyleVars,
182
+ };
183
+
184
+ iframe?.component?.call('route', {
185
+ name: 'method-switch',
186
+ });
187
+
188
+ iframe?.component?.call('update', model);
189
+
190
+ iframe?.component?.on('choose-another-method', () => {
191
+ if (state.data.isPurchase) {
192
+ updateSummary();
193
+ }
194
+ mountMethodSelector();
195
+ });
196
+ } else {
197
+ state.loader.stopLoading({ id: 'rebilly-instruments-form' });
198
+ state.form.querySelector(
199
+ '[data-rebilly-instruments="form"]',
200
+ ).style.display = 'none';
201
+ document
202
+ .querySelectorAll('[data-rebilly-instruments="divider"]')
203
+ .forEach((el) => {
204
+ el.style.display = 'none';
205
+ });
165
206
  }
166
207
 
167
- const modelSafeState = state.toModel();
168
- const model = {
169
- options: modelSafeState.options,
170
- data: modelSafeState.data,
171
- mainStyleVars: modelSafeState.mainStyleVars,
172
- };
173
-
174
- iframe?.component?.call('route', {
175
- name: 'method-switch'
176
- });
177
-
178
- iframe?.component?.call('update', model);
179
-
180
- iframe?.component?.on('choose-another-method', () => {
181
- if (state.data.isPurchase) {
182
- updateSummary();
183
- }
184
- mountMethodSelector();
185
- });
186
-
187
- } else {
188
- state.loader.stopLoading({id: 'rebilly-instruments-form'});
189
- state.form.querySelector('[data-rebilly-instruments="form"]').style.display = 'none';
190
- document.querySelectorAll('[data-rebilly-instruments="divider"]').forEach(el => { el.style.display = 'none' });
191
- }
192
-
193
- state.translate.translateItems();
208
+ state.translate.translateItems();
194
209
  }
195
210
 
196
211
  export async function updateMethodSelector() {
197
- state.loader.startLoading({ id: 'rebilly-instruments-methods' });
212
+ state.loader.startLoading({ id: 'rebilly-instruments-methods' });
198
213
 
199
- const { riskMetadata } = await collectData();
200
- state.data = await fetchData({ riskMetadata });
201
- state.updateModel();
214
+ const { riskMetadata } = await collectData();
215
+ state.data = await fetchData({ riskMetadata });
216
+ state.updateModel();
202
217
 
203
- if (state.data.transaction && state.data.transaction?.type === 'setup') {
204
- state.options.transactionType = 'setup';
205
- }
218
+ if (state.data.transaction && state.data.transaction?.type === 'setup') {
219
+ state.options.transactionType = 'setup';
220
+ }
206
221
 
207
- mountMethodSelector();
222
+ mountMethodSelector();
208
223
  }
@@ -2,19 +2,19 @@ import { RenderMockRebillyInstruments } from 'tests/mocks/rebilly-instruments-mo
2
2
  import { updateMethodSelector } from './index';
3
3
 
4
4
  describe('Methods Selector Component', () => {
5
- it ('should inject the proper HTML for express methods', async () => {
6
- await RenderMockRebillyInstruments({
7
- form: '.rebilly-instruments-form'
8
- });
5
+ it('should inject the proper HTML for express methods', async () => {
6
+ await RenderMockRebillyInstruments({
7
+ form: '.rebilly-instruments-form',
8
+ });
9
9
 
10
- const form = document.querySelector('.rebilly-instruments-form');
11
- expect(form).toMatchSnapshot();
12
- });
10
+ const form = document.querySelector('.rebilly-instruments-form');
11
+ expect(form).toMatchSnapshot();
12
+ });
13
13
 
14
- it ('should allow updating method selector', async () => {
15
- await RenderMockRebillyInstruments();
16
- await updateMethodSelector({
17
- mainStyleVars: 'any main style'
14
+ it('should allow updating method selector', async () => {
15
+ await RenderMockRebillyInstruments();
16
+ await updateMethodSelector({
17
+ mainStyleVars: 'any main style',
18
+ });
18
19
  });
19
- });
20
- });
20
+ });
@@ -1,79 +1,94 @@
1
1
  import state from '../../state';
2
2
  import formatCurrency from '../../utils/format-currency';
3
- import {fetchSummary} from '../../storefront/summary'
3
+ import { fetchSummary } from '../../storefront/summary';
4
4
 
5
- function lineItem({offer}) {
6
- const plan = state.data.plans.find(item => item.id === offer.planId);
7
- const product = state.data.products.find(item => item.id === plan.productId);
5
+ function lineItem({ offer }) {
6
+ const plan = state.data.plans.find((item) => item.id === offer.planId);
7
+ const product = state.data.products.find(
8
+ (item) => item.id === plan.productId,
9
+ );
8
10
 
9
- const rif = (condition, template) => condition ? template : '';
11
+ const rif = (condition, template) => (condition ? template : '');
10
12
 
11
- function unitPrice() {
12
- const planPricing = plan.pricing.isBracket
13
- ? plan.pricing.brackets[0].price
14
- : plan.pricing.price;
13
+ function unitPrice() {
14
+ const planPricing = plan.pricing.isBracket
15
+ ? plan.pricing.brackets[0].price
16
+ : plan.pricing.price;
15
17
 
16
- const basePrice = formatCurrency(planPricing, plan.currency);
17
- return plan.pricing.isBracket
18
- ? state.translate.getTranslation('form.bumpOffer.startingAt')
19
- .replace('{basePrice}', basePrice)
20
- : basePrice;
21
- }
18
+ const basePrice = formatCurrency(planPricing, plan.currency);
19
+ return plan.pricing.isBracket
20
+ ? state.translate
21
+ .getTranslation('form.bumpOffer.startingAt')
22
+ .replace('{basePrice}', basePrice)
23
+ : basePrice;
24
+ }
22
25
 
23
- const thumbnail = (item) => rif(item.thumbnail, `
26
+ const thumbnail = (item) =>
27
+ rif(
28
+ item.thumbnail,
29
+ `
24
30
  <figure class="rebilly-instruments-bump-offer-line-item-figure">
25
31
  <img src="${item.thumbnail}" :alt="${item.name}"/>
26
32
  </figure>
27
- `);
33
+ `,
34
+ );
28
35
 
29
- const synopsis = (item) => `
36
+ const synopsis = (item) => `
30
37
  <div class="rebilly-instruments-bump-offer-line-item-synopsis">
31
38
  <p class="rebilly-instruments-bump-offer-line-item-synopsis-title">
32
39
  ${item.name}
33
40
  </p>
34
- ${rif(item.description, `
41
+ ${rif(
42
+ item.description,
43
+ `
35
44
  <p class="rebilly-instruments-bump-offer-line-item-synopsis-description">
36
45
  ${item.description}
37
46
  </p>
38
- `)}
47
+ `,
48
+ )}
39
49
  </div>
40
50
  `;
41
51
 
42
- const breakdown = (item) => `
52
+ const breakdown = (item) => `
43
53
  <div class="rebilly-instruments-bump-offer-line-item-price-breakdown">
44
- ${rif(item.quantity, `
54
+ ${rif(
55
+ item.quantity,
56
+ `
45
57
  <p class="rebilly-instruments-bump-offer-line-item-price-breakdown-quantity">
46
58
  ${item.quantity}
47
59
  </p>
48
60
  <svg class="rebilly-instruments-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
49
61
  <path d="M12 10.5858l2.8284-2.8284c.3906-.3906 1.0237-.3906 1.4142 0 .3906.3905.3906 1.0236 0 1.4142L13.4142 12l2.8284 2.8284c.3906.3906.3906 1.0237 0 1.4142-.3905.3906-1.0236.3906-1.4142 0L12 13.4142l-2.8284 2.8284c-.3906.3906-1.0237.3906-1.4142 0-.3906-.3905-.3906-1.0236 0-1.4142L10.5858 12 7.7574 9.1716c-.3906-.3906-.3906-1.0237 0-1.4142.3905-.3906 1.0236-.3906 1.4142 0L12 10.5858z" fill-rule="nonzero"/>
50
62
  </svg>
51
- `)}
63
+ `,
64
+ )}
52
65
  <p class="rebilly-instruments-bump-offer-line-item-price-breakdown-unit-price">
53
66
  ${item.unitPrice}
54
67
  </p>
55
68
  <div>
56
69
  `;
57
70
 
58
- const line = {
59
- ...offer,
60
- quantity: plan.pricing.isBracket ? null : offer.quantity,
61
- name: product.name,
62
- description: plan.name,
63
- unitPrice: unitPrice(),
64
- }
71
+ const line = {
72
+ ...offer,
73
+ quantity: plan.pricing.isBracket ? null : offer.quantity,
74
+ name: product.name,
75
+ description: plan.name,
76
+ unitPrice: unitPrice(),
77
+ };
65
78
 
66
- return `
79
+ return `
67
80
  <div class="rebilly-instruments-bump-offer-line-item">
68
81
  ${thumbnail(line)}
69
82
  ${synopsis(line)}
70
83
  ${breakdown(line)}
71
84
  </div>
72
- `
85
+ `;
73
86
  }
74
87
 
75
- export function mountBumpOffer ({container}) {
76
- container.insertAdjacentHTML('beforeEnd', `
88
+ export function mountBumpOffer({ container }) {
89
+ container.insertAdjacentHTML(
90
+ 'beforeEnd',
91
+ `
77
92
  <label for="rebilly-instruments-bump-offer" class="rebilly-instruments-form-field-checkbox">
78
93
  <div class="rebilly-instruments-bump-offer-label" data-rebilly-i18n="form.bumpOffer.title">
79
94
  ${state.translate.getTranslation('form.bumpOffer.title')}
@@ -84,21 +99,22 @@ export function mountBumpOffer ({container}) {
84
99
  />
85
100
  <span></span>
86
101
  </label>
87
- `);
102
+ `,
103
+ );
88
104
 
89
- const checkbox = document.getElementById('rebilly-instruments-bump-offer')
90
- checkbox.addEventListener('click', async () => {
91
- state.data.acceptBumpOffer = checkbox.checked;
92
- await fetchSummary();
93
- state.updateModel();
94
- });
105
+ const checkbox = document.getElementById('rebilly-instruments-bump-offer');
106
+ checkbox.addEventListener('click', async () => {
107
+ state.data.acceptBumpOffer = checkbox.checked;
108
+ await fetchSummary();
109
+ state.updateModel();
110
+ });
95
111
 
96
- checkbox.checked = state.data.acceptBumpOffer;
112
+ checkbox.checked = state.data.acceptBumpOffer;
97
113
 
98
- state.options.bumpOffer.forEach(offer => {
99
- const node = document.createElement('div');
100
- node.classList.add('rebilly-instruments-bump-offer');
101
- node.insertAdjacentHTML('beforeEnd', lineItem({offer}));
102
- container.appendChild(node);
103
- });
104
- }
114
+ state.options.bumpOffer.forEach((offer) => {
115
+ const node = document.createElement('div');
116
+ node.classList.add('rebilly-instruments-bump-offer');
117
+ node.insertAdjacentHTML('beforeEnd', lineItem({ offer }));
118
+ container.appendChild(node);
119
+ });
120
+ }