@rebilly/instruments 2.1.1-beta.0 → 3.0.0-beta.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 (83) hide show
  1. package/dist/functions/mount/fetch-data.js +4 -0
  2. package/dist/functions/mount/index.js +6 -0
  3. package/dist/functions/mount/mount.spec.js +2 -4
  4. package/dist/functions/mount/setup-framepay-theme.js +95 -0
  5. package/dist/functions/mount/setup-options.js +3 -0
  6. package/dist/i18n/en.json +1 -1
  7. package/dist/style/base/__snapshots__/theme.spec.js.snap +188 -45
  8. package/dist/style/base/default-theme.js +699 -0
  9. package/dist/style/base/index.js +48 -16
  10. package/dist/style/base/theme.js +16 -49
  11. package/dist/style/base/theme.spec.js +4 -15
  12. package/dist/style/components/address.js +3 -3
  13. package/dist/style/components/button.js +32 -22
  14. package/dist/style/components/divider.js +9 -9
  15. package/dist/style/components/forms/checkbox.js +12 -9
  16. package/dist/style/components/forms/field.js +18 -6
  17. package/dist/style/components/forms/form.js +2 -2
  18. package/dist/style/components/forms/input.js +54 -13
  19. package/dist/style/components/forms/label.js +44 -18
  20. package/dist/style/components/forms/select.js +54 -22
  21. package/dist/style/components/forms/validation.js +53 -6
  22. package/dist/style/components/icons.js +4 -4
  23. package/dist/style/components/loader.js +5 -3
  24. package/dist/style/components/methods.js +18 -15
  25. package/dist/style/components/overlay.js +5 -5
  26. package/dist/style/helpers/index.js +46 -46
  27. package/dist/style/index.js +3 -1
  28. package/dist/style/payment-instruments/payment-card.js +4 -4
  29. package/dist/style/utils/border.js +47 -0
  30. package/dist/style/utils/color-values.js +39 -3
  31. package/dist/style/utils/remove-empty-null.js +20 -0
  32. package/dist/style/vendor/framepay.js +11 -8
  33. package/dist/style/vendor/postmate.js +2 -2
  34. package/dist/style/views/confirmation.js +13 -13
  35. package/dist/style/views/method-selector.js +2 -2
  36. package/dist/style/views/modal.js +6 -6
  37. package/dist/style/views/result.js +4 -4
  38. package/dist/style/views/summary.js +23 -23
  39. package/dist/views/__snapshots__/summary.spec.js.snap +4 -40
  40. package/dist/views/common/iframe/modal-iframe.js +6 -1
  41. package/dist/views/summary.js +17 -11
  42. package/package.json +3 -1
  43. package/src/functions/mount/fetch-data.js +4 -0
  44. package/src/functions/mount/index.js +2 -0
  45. package/src/functions/mount/mount.spec.js +3 -5
  46. package/src/functions/mount/setup-framepay-theme.js +82 -0
  47. package/src/functions/mount/setup-options.js +3 -0
  48. package/src/i18n/en.json +1 -1
  49. package/src/style/base/__snapshots__/theme.spec.js.snap +188 -45
  50. package/src/style/base/default-theme.js +674 -0
  51. package/src/style/base/index.js +48 -16
  52. package/src/style/base/theme.js +17 -47
  53. package/src/style/base/theme.spec.js +4 -16
  54. package/src/style/components/address.js +3 -3
  55. package/src/style/components/button.js +32 -24
  56. package/src/style/components/divider.js +9 -9
  57. package/src/style/components/forms/checkbox.js +11 -11
  58. package/src/style/components/forms/field.js +18 -6
  59. package/src/style/components/forms/form.js +2 -2
  60. package/src/style/components/forms/input.js +54 -13
  61. package/src/style/components/forms/label.js +44 -18
  62. package/src/style/components/forms/select.js +54 -22
  63. package/src/style/components/forms/validation.js +53 -6
  64. package/src/style/components/icons.js +4 -4
  65. package/src/style/components/loader.js +4 -5
  66. package/src/style/components/methods.js +18 -15
  67. package/src/style/components/overlay.js +5 -5
  68. package/src/style/helpers/index.js +46 -46
  69. package/src/style/index.js +2 -1
  70. package/src/style/payment-instruments/payment-card.js +4 -4
  71. package/src/style/utils/border.js +34 -0
  72. package/src/style/utils/color-values.js +27 -1
  73. package/src/style/utils/remove-empty-null.js +10 -0
  74. package/src/style/vendor/framepay.js +11 -8
  75. package/src/style/vendor/postmate.js +2 -2
  76. package/src/style/views/confirmation.js +13 -13
  77. package/src/style/views/method-selector.js +2 -2
  78. package/src/style/views/modal.js +6 -6
  79. package/src/style/views/result.js +4 -4
  80. package/src/style/views/summary.js +23 -23
  81. package/src/views/__snapshots__/summary.spec.js.snap +4 -40
  82. package/src/views/common/iframe/modal-iframe.js +7 -1
  83. package/src/views/summary.js +17 -11
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.alphaColor = alphaColor;
7
- exports.colorValues = void 0;
7
+ exports.lighten = exports.darken = exports.mutedBorderColor = exports.mutedTextColor = exports.colorValues = void 0;
8
8
 
9
9
  var _values = _interopRequireDefault(require("values.js"));
10
10
 
@@ -15,8 +15,44 @@ const colorValues = color => new _values.default(color);
15
15
  exports.colorValues = colorValues;
16
16
 
17
17
  function alphaColor(color, alphaValue = 1) {
18
- const _alphaColor = new _values.default(color);
18
+ if (color === null) {
19
+ return color;
20
+ }
21
+
22
+ const _alphaColor = colorValues(color);
19
23
 
20
24
  _alphaColor.alpha = alphaValue;
21
25
  return _alphaColor.rgbString();
22
- }
26
+ }
27
+
28
+ const mutedTextColor = color => alphaColor(color, 0.6);
29
+
30
+ exports.mutedTextColor = mutedTextColor;
31
+
32
+ const mutedBorderColor = color => alphaColor(color, 0.25);
33
+
34
+ exports.mutedBorderColor = mutedBorderColor;
35
+
36
+ const darken = (color, percent) => {
37
+ if (color === null) {
38
+ return color;
39
+ }
40
+
41
+ const _color = colorValues(color);
42
+
43
+ return _color.shade(percent).hexString();
44
+ };
45
+
46
+ exports.darken = darken;
47
+
48
+ const lighten = (color, percent) => {
49
+ if (color === null) {
50
+ return color;
51
+ }
52
+
53
+ const _color = colorValues(color);
54
+
55
+ return _color.tint(percent).hexString();
56
+ };
57
+
58
+ exports.lighten = lighten;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _postcss = _interopRequireDefault(require("postcss"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _postcss.default.plugin('postcss-remove-empty-null', () => root => {
13
+ root.walkDecls(decl => {
14
+ if ((decl.value === '\'\'' || decl.value === '""' || decl.value.includes('null')) && decl.prop !== 'content') {
15
+ decl.remove();
16
+ }
17
+ });
18
+ });
19
+
20
+ exports.default = _default;
@@ -5,22 +5,25 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.framepayStyle = void 0;
7
7
 
8
- const framepayStyle = theme => `
8
+ const framepayStyle = () => `
9
9
  .rebilly-instruments-framepay .rebilly-framepay {
10
- box-shadow: none;
11
- min-height: ${theme.space.form.minHeight};
12
- border: 1px solid ${theme.getComputed.color.mutedBorder};
10
+ min-height: var(--rebilly-spacings-form-element-min-height);
11
+ border: var(--rebilly-inputBorder);
13
12
  margin-bottom: 0;
14
- background: ${theme.color.background};
13
+ background: var(--rebilly-inputColorBackground);
14
+ border-radius: var(--rebilly-inputBorderRadius);
15
+ box-shadow: var(--rebilly-inputBoxShadow);
15
16
  }
16
17
 
17
18
  .rebilly-instruments-framepay .rebilly-framepay.rebilly-framepay-focus {
18
- border: 1px solid ${theme.color.primary};
19
- box-shadow: 0 0 0 1px ${theme.color.primary};
19
+ background: var(--rebilly-inputFocusColorBackground);
20
+ border: var(--rebilly-inputFocusBorder);
21
+ border-radius: var(--rebilly-inputFocusBorderRadius);
22
+ box-shadow: var(--rebilly-inputFocusBoxShadow);
20
23
  }
21
24
 
22
25
  .rebilly-instruments-framepay .rebilly-framepay.rebilly-framepay-invalid {
23
- border: 1px solid ${theme.color.errorText};
26
+ border-color: var(--rebilly-colorDanger);
24
27
  box-shadow: none;
25
28
  }
26
29
 
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.postmateStyle = void 0;
7
7
 
8
- const postmateStyle = theme => `
8
+ const postmateStyle = () => `
9
9
  .rebilly-instruments-iframe {
10
10
  border: none;
11
11
  width: 100%;
12
- min-height: ${theme.space.form.minHeight};
12
+ min-height: var(--rebilly-spacings-form-element-min-height);
13
13
  transition: all 0.2s ease;
14
14
  }
15
15
  `;
@@ -8,7 +8,7 @@ exports.confirmation = void 0;
8
8
  // -----------------------------------------------------------------------------
9
9
  // This file contains all styles related to the confirmation view.
10
10
  // -----------------------------------------------------------------------------
11
- const confirmation = theme => `
11
+ const confirmation = () => `
12
12
  /**
13
13
  * Confirmation
14
14
  */
@@ -18,8 +18,8 @@ const confirmation = theme => `
18
18
 
19
19
  .rebilly-instruments-confirmation-go-back-link {
20
20
  display: inline-block;
21
- margin-bottom: ${theme.space.m};
22
- margin-left: -${theme.space.xs};
21
+ margin-bottom: var(--rebilly-spacings-base);
22
+ margin-left: calc(var(--rebilly-spacings-xs) * -1);
23
23
  }
24
24
 
25
25
  .rebilly-instruments-confirmation-address-title {
@@ -28,20 +28,20 @@ const confirmation = theme => `
28
28
  }
29
29
 
30
30
  .rebilly-instruments-confirmation-address-title .rebilly-instruments-link {
31
- margin-left: ${theme.space.s};
31
+ margin-left: var(--rebilly-spacings-s);
32
32
  }
33
33
 
34
34
  .rebilly-instruments-confirmation-address-actions {
35
- margin-top: ${theme.space.m};
35
+ margin-top: var(--rebilly-spacings-base);
36
36
  display: flex;
37
37
  }
38
38
 
39
39
  .rebilly-instruments-confirmation-address-actions :first-child {
40
- margin: 0 ${theme.space.xs} 0 0;
40
+ margin: 0 var(--rebilly-spacings-xs) 0 0;
41
41
  }
42
42
 
43
43
  .rebilly-instruments-confirmation-address-actions :last-child {
44
- margin: 0 0 0 ${theme.space.xs};
44
+ margin: 0 0 0 var(--rebilly-spacings-xs);
45
45
  }
46
46
 
47
47
  .rebilly-instruments-confirmation-payment-method {
@@ -49,18 +49,18 @@ const confirmation = theme => `
49
49
  align-items: center;
50
50
  justify-content: space-between;
51
51
  height: 26px;
52
- margin: 0 0 ${theme.space.l};
52
+ margin: 0 0 var(--rebilly-spacings-l);
53
53
  }
54
54
 
55
55
  .rebilly-instruments-confirmation-payment-method figure {
56
- margin: 0 ${theme.space.xxs} 0 0;
56
+ margin: 0 var(--rebilly-spacings-2xs) 0 0;
57
57
  height: 26px;
58
58
  padding: 0;
59
59
  }
60
60
 
61
61
  .rebilly-instruments-confirmation-payment-method figure img {
62
62
  width: 42px;
63
- border-radius: ${theme.borderRadius};
63
+ border-radius: 4px;
64
64
  }
65
65
 
66
66
  .rebilly-instruments-confirmation-payment-method-brand,
@@ -70,15 +70,15 @@ const confirmation = theme => `
70
70
  }
71
71
 
72
72
  .rebilly-instruments-confirmation-payment-method-brand {
73
- margin: 0 0 0 ${theme.space.s};
73
+ margin: 0 0 0 var(--rebilly-spacings-s);
74
74
  }
75
75
 
76
76
  .rebilly-instruments-confirmation-payment-method-last4 {
77
- margin: 0 ${theme.space.s};
77
+ margin: 0 var(--rebilly-spacings-s);
78
78
  }
79
79
 
80
80
  .rebilly-instruments-confirmation-payment-method-exp {
81
- color: ${theme.getComputed.color.mutedText};
81
+ color: var(--rebilly-colorMutedText);
82
82
  }
83
83
  `;
84
84
 
@@ -8,12 +8,12 @@ exports.methodSelector = void 0;
8
8
  // -----------------------------------------------------------------------------
9
9
  // This file contains all styles related to the selector view.
10
10
  // -----------------------------------------------------------------------------
11
- const methodSelector = theme => `
11
+ const methodSelector = () => `
12
12
  /**
13
13
  * Method selector
14
14
  */
15
15
  .rebilly-instruments-method-selector.has-express-compact {
16
- padding-top: ${theme.space.s};
16
+ padding-top: var(--rebilly-spacings-s);
17
17
  }
18
18
  `;
19
19
 
@@ -8,7 +8,7 @@ exports.modal = void 0;
8
8
  // -----------------------------------------------------------------------------
9
9
  // This file contains all styles related to the modal view.
10
10
  // -----------------------------------------------------------------------------
11
- const modal = theme => `
11
+ const modal = () => `
12
12
  /**
13
13
  * Modal
14
14
  */
@@ -38,10 +38,10 @@ const modal = theme => `
38
38
  transition: all .24s ease-in-out;
39
39
  position: relative;
40
40
  max-width: 800px;
41
- background: ${theme.color.background};
41
+ background: var(--rebilly-colorBackground);
42
42
  margin: 50px auto 20px;
43
43
  box-shadow: 0 19px 38px rgba(0,0,0,0.20), 0 15px 12px rgba(0,0,0,0.12);
44
- border-radius: ${theme.borderRadius};
44
+ border-radius: 4px;
45
45
  transform: translateY(-50px);
46
46
  opacity: 0;
47
47
  }
@@ -60,9 +60,9 @@ const modal = theme => `
60
60
  transition: all .15s;
61
61
  padding: 20px;
62
62
  overflow: hidden;
63
- background-color: ${theme.color.background};
63
+ background-color: var(--rebilly-colorBackground);
64
64
  text-align: center;
65
- border-radius: ${theme.borderRadius};
65
+ border-radius: 4px;
66
66
  }
67
67
 
68
68
  .rebilly-instruments-modal-content .rebilly-instruments-iframe {
@@ -81,7 +81,7 @@ const modal = theme => `
81
81
  height: 30px;
82
82
  top: -40px;
83
83
  right: 0;
84
- fill: #ffffff;
84
+ fill: #FFF;
85
85
  cursor: pointer;
86
86
  }
87
87
 
@@ -8,7 +8,7 @@ exports.result = void 0;
8
8
  // -----------------------------------------------------------------------------
9
9
  // This file contains all styles related to the result view.
10
10
  // -----------------------------------------------------------------------------
11
- const result = theme => `
11
+ const result = () => `
12
12
  /**
13
13
  * Result
14
14
  */
@@ -19,16 +19,16 @@ const result = theme => `
19
19
 
20
20
  .rebilly-instruments-results-icon {
21
21
  width: 160px;
22
- margin: 0 auto ${theme.space.m} auto;
22
+ margin: 0 auto var(--rebilly-spacings-base) auto;
23
23
  display: block;
24
24
  }
25
25
 
26
26
  .rebilly-instruments-results-icon g {
27
- stroke: ${theme.color.primary};
27
+ stroke: var(--rebilly-colorPrimary);
28
28
  }
29
29
 
30
30
  .rebilly-instruments-results-icon.is-error g {
31
- stroke: ${theme.color.errorText};
31
+ stroke: var(--rebilly-colorDanger);
32
32
  }
33
33
 
34
34
  .rebilly-instruments-results-icon path {
@@ -8,13 +8,13 @@ exports.summary = void 0;
8
8
  // -----------------------------------------------------------------------------
9
9
  // This file contains all styles related to the summary view.
10
10
  // -----------------------------------------------------------------------------
11
- const summary = theme => `
11
+ const summary = () => `
12
12
  /**
13
13
  * Summary
14
14
  */
15
15
  .rebilly-instruments-summary-line-item {
16
- border-bottom: 1px solid ${theme.getComputed.color.mutedBorder};
17
- padding: ${theme.space.s} 0;
16
+ border-bottom: 1px solid var(--rebilly-colorMutedBorder);
17
+ padding: var(--rebilly-spacings-s) 0;
18
18
  display: flex;
19
19
  align-items: center;
20
20
  position: relative;
@@ -25,12 +25,12 @@ const summary = theme => `
25
25
  }
26
26
 
27
27
  .rebilly-instruments-summary-line-item-figure {
28
- margin: 0 ${theme.space.s} 0 0;
28
+ margin: 0 var(--rebilly-spacings-s) 0 0;
29
29
  flex: 0 0 auto;
30
30
  width: 48px;
31
31
  height: 48px;
32
- border-radius: ${theme.borderRadius};
33
- border: 1px solid ${theme.getComputed.color.mutedBorder};
32
+ border-radius: var(--rebilly-borderRadius);
33
+ border: 1px solid var(--rebilly-colorMutedBorder);
34
34
  overflow: hidden;
35
35
  }
36
36
 
@@ -48,31 +48,31 @@ const summary = theme => `
48
48
  }
49
49
 
50
50
  .rebilly-instruments-summary-line-item-synopsis-description {
51
- color: ${theme.getComputed.color.mutedText};
51
+ color: var(--rebilly-colorMutedText);
52
52
  margin: 0;
53
- font-size: 14px;
54
- line-height: 14px;
53
+ font-size: calc(var(--rebilly-fontSizeBase) * 0.875);
54
+ line-height: 1;
55
55
  }
56
56
 
57
57
  .rebilly-instruments-summary-line-item-price-breakdown {
58
58
  display: flex;
59
59
  justify-content: center;
60
60
  align-items: center;
61
- color: ${theme.getComputed.color.mutedText};
62
- margin: 0 0 0 ${theme.spaceS};
61
+ color: var(--rebilly-colorMutedText);
62
+ margin: 0 0 0 var(--rebilly-spacings-s);
63
63
  }
64
64
 
65
65
  .rebilly-instruments-summary-line-item-price-breakdown .rebilly-instruments-icon {
66
- fill: ${theme.getComputed.color.mutedText};
66
+ fill: var(--rebilly-colorMutedText);
67
67
  }
68
68
 
69
69
  .rebilly-instruments-summary-line-item-price-breakdown-unit-price {
70
- color: ${theme.color.text};
70
+ color: var(--rebilly-colorText);
71
71
  }
72
72
 
73
73
  .rebilly-instruments-summary-breakdown table {
74
74
  width: 100%;
75
- margin: ${theme.space.xs} 0;
75
+ margin: var(--rebilly-spacings-xs) 0;
76
76
  color: inherit;
77
77
  }
78
78
 
@@ -89,38 +89,38 @@ const summary = theme => `
89
89
  }
90
90
 
91
91
  .rebilly-instruments-summary-breakdown table tr td:first-child {
92
- padding-right: ${theme.space.s};
92
+ padding-right: var(--rebilly-spacings-s);
93
93
  font-weight: 500;
94
94
  }
95
95
 
96
96
  .rebilly-instruments-summary-breakdown table {
97
- border-bottom: 1px solid ${theme.getComputed.color.mutedBorder};
98
- padding-bottom: ${theme.space.xs};
97
+ border-bottom: 1px solid var(--rebilly-colorMutedBorder);
98
+ padding-bottom: var(--rebilly-spacings-xs);
99
99
  }
100
100
 
101
101
  .rebilly-instruments-summary-breakdown-total {
102
- padding-top: ${theme.space.xs};
102
+ padding-top: var(--rebilly-spacings-xs);
103
103
  display: flex;
104
104
  align-items: center;
105
105
  }
106
106
 
107
107
  .rebilly-instruments-summary-breakdown-total p {
108
- margin: ${theme.space.s} 0;
108
+ margin: var(--rebilly-spacings-s) 0;
109
109
  }
110
110
 
111
111
  .rebilly-instruments-summary-breakdown-total-amount {
112
112
  flex: 1 2 80%;
113
- font-size: 24px;
113
+ font-size: calc(var(--rebilly-fontSizeBase) * 1.5);
114
114
  font-weight: 500;
115
115
  text-align: right;
116
116
  font-weight: bold;
117
117
  }
118
118
 
119
119
  .rebilly-instruments-summary-breakdown-total-amount-currency {
120
- font-size: ${theme.typography.fontSize};
120
+ font-size: var(--rebilly-fontSizeBase);
121
121
  font-weight: normal;
122
- color: ${theme.getComputed.color.mutedText};
123
- margin-right: ${theme.space.s};
122
+ color: var(--rebilly-colorMutedText);
123
+ margin-right: var(--rebilly-spacings-s);
124
124
  }
125
125
  `;
126
126
 
@@ -176,73 +176,37 @@ exports[`Summary component should render the summary correctly 2`] = `
176
176
  class="rebilly-instruments-summary-breakdown-sub-total"
177
177
  >
178
178
 
179
-
179
+
180
180
  <td
181
181
  data-rebilly-i18n="summary.subTotal"
182
182
  >
183
183
  Sub Total
184
184
  </td>
185
185
 
186
-
186
+
187
187
  <td>
188
188
  $70.00
189
189
  </td>
190
190
 
191
-
192
- </tr>
193
- <tr
194
- class="rebilly-instruments-summary-breakdown-discounts"
195
- >
196
-
197
191
 
198
- <td
199
- data-rebilly-i18n="summary.discounts"
200
- >
201
- Discounts
202
- </td>
203
-
204
-
205
- <td>
206
- $0.00
207
- </td>
208
-
209
-
210
192
  </tr>
211
193
  <tr
212
194
  class="rebilly-instruments-summary-breakdown-taxes"
213
195
  >
214
196
 
215
-
197
+
216
198
  <td
217
199
  data-rebilly-i18n="summary.taxes"
218
200
  >
219
201
  Taxes
220
202
  </td>
221
203
 
222
-
204
+
223
205
  <td>
224
206
  $0.00
225
207
  </td>
226
208
 
227
-
228
- </tr>
229
- <tr
230
- class="rebilly-instruments-summary-breakdown-shipping"
231
- >
232
-
233
209
 
234
- <td
235
- data-rebilly-i18n="summary.shipping"
236
- >
237
- Shipping
238
- </td>
239
-
240
-
241
- <td>
242
- $0.00
243
- </td>
244
-
245
-
246
210
  </tr>
247
211
  </table>
248
212
  <div
@@ -27,7 +27,12 @@ class ModalIframe extends _baseIframe.default {
27
27
  loader,
28
28
  section: 'modal',
29
29
  id: 'modal-content'
30
- });
30
+ }); // Close modal via postmate
31
+
32
+ this.component.on(`${this.name}-close`, (...args) => {
33
+ close(...args);
34
+ }); // Close modal via postMessage (specifically during approal url flow)
35
+
31
36
  window.addEventListener('message', async event => {
32
37
  if (event.data === 'rebilly-instruments-approval-url-close') {
33
38
  if (this.state.options.transactionType === 'purchase') {
@@ -79,22 +79,26 @@ function summaryBreakdownHTML({
79
79
  label: 'Sub Total',
80
80
  class: 'sub-total',
81
81
  i18n: 'summary.subTotal',
82
- value: subtotalAmount
82
+ value: subtotalAmount,
83
+ show: true
83
84
  }, {
84
85
  label: 'Discounts',
85
86
  class: 'discounts',
86
87
  i18n: 'summary.discounts',
87
- value: discountsAmount
88
+ value: discountsAmount,
89
+ show: discountsAmount > 0
88
90
  }, {
89
91
  label: 'Taxes',
90
92
  class: 'taxes',
91
93
  i18n: 'summary.taxes',
92
- value: taxAmount
94
+ value: taxAmount,
95
+ show: true
93
96
  }, {
94
97
  label: 'Shipping',
95
98
  class: 'shipping',
96
99
  i18n: 'summary.shipping',
97
- value: shippingAmount
100
+ value: shippingAmount,
101
+ show: state.data.isShippingRequired
98
102
  }].filter(({
99
103
  value
100
104
  }) => value !== null).forEach(item => {
@@ -108,13 +112,15 @@ function summaryBreakdownHTML({
108
112
  `);
109
113
  }
110
114
 
111
- const row = document.createElement('tr');
112
- row.setAttribute('class', `rebilly-instruments-summary-breakdown-${item.class}`);
113
- row.insertAdjacentHTML('beforeend', `
114
- <td data-rebilly-i18n="${item.i18n}">${item.label}</td>
115
- <td>${(0, _utils.formatCurrency)(item.value, currency)}</td>
116
- `);
117
- table.appendChild(row);
115
+ if (item.show) {
116
+ const row = document.createElement('tr');
117
+ row.setAttribute('class', `rebilly-instruments-summary-breakdown-${item.class}`);
118
+ row.insertAdjacentHTML('beforeend', `
119
+ <td data-rebilly-i18n="${item.i18n}">${item.label}</td>
120
+ <td>${(0, _utils.formatCurrency)(item.value, currency)}</td>
121
+ `);
122
+ table.appendChild(row);
123
+ }
118
124
  });
119
125
 
120
126
  if (table) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebilly/instruments",
3
- "version": "2.1.1-beta.0",
3
+ "version": "3.0.0-beta.0",
4
4
  "author": "Rebilly",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -16,12 +16,14 @@
16
16
  "@babel/preset-env": "^7.14.7",
17
17
  "@rebilly/risk-data-collector": "^2.0.1",
18
18
  "autoprefixer": "^10.3.4",
19
+ "css": "^3.0.0",
19
20
  "lodash.camelcase": "^4.3.0",
20
21
  "lodash.isequal": "^4.5.0",
21
22
  "lodash.kebabcase": "^4.1.1",
22
23
  "lodash.merge": "^4.6.2",
23
24
  "popostmate": "^1.6.4",
24
25
  "postcss": "^8.3.6",
26
+ "postcss-custom-properties": "^12.0.0",
25
27
  "rebilly-js-sdk": "^44.4.0",
26
28
  "values.js": "^2.0.0"
27
29
  },
@@ -81,6 +81,10 @@ export class DataInstance {
81
81
 
82
82
  return lineItems;
83
83
  }
84
+
85
+ get isShippingRequired() {
86
+ return this.products.some(product => product.requiresShipping);
87
+ }
84
88
  }
85
89
 
86
90
  export async function fetchData({
@@ -10,6 +10,7 @@ import setupOptions from './setup-options';
10
10
  import setupFramepay from './setup-framepay';
11
11
  import setupStyles from './setup-styles';
12
12
  import setupI18n from './setup-i18n';
13
+ import setupFramepayTheme from './setup-framepay-theme';
13
14
 
14
15
  /**
15
16
  * @typedef {object} Item
@@ -95,6 +96,7 @@ export async function mount({
95
96
  state.options = setupOptions({ options });
96
97
  state.mainStyle = await setupStyles({ options });
97
98
  state.data = await fetchData({ state });
99
+ state.options.themeFramepay = await setupFramepayTheme({ state, options });
98
100
  const i18n = setupI18n({ state });
99
101
  setupFramepay({ state });
100
102
 
@@ -23,9 +23,7 @@ describe('RebillyInstruments instance', () => {
23
23
  }
24
24
  ],
25
25
  theme: {
26
- color: {
27
- background: '#000'
28
- }
26
+ colorBackground: '#000'
29
27
  },
30
28
  css: `
31
29
  .rebilly-instruments-summary-line-item-synopsis-title {
@@ -47,8 +45,8 @@ describe('RebillyInstruments instance', () => {
47
45
  const SUMMARY_CONTAINER = summarySelector.querySelector(
48
46
  '.rebilly-instruments-content'
49
47
  );
50
- expect(getComputedStyle(SUMMARY_CONTAINER).background).toEqual(
51
- 'rgb(0, 0, 0)'
48
+ expect(getComputedStyle(SUMMARY_CONTAINER).getPropertyValue('--rebilly-colorBackground')).toEqual(
49
+ '#000'
52
50
  );
53
51
 
54
52
  // CSS config property overrides initial styles