@rebilly/instruments 1.0.1-beta → 1.0.2-beta.10
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.
- package/.babelrc +23 -5
- package/.eslintrc.js +27 -0
- package/.prettierrc.js +11 -0
- package/CONTRIBUTING.md +4 -0
- package/README.md +361 -2
- package/dist/events/base-event.js +51 -37
- package/dist/events/events.spec.js +18 -0
- package/dist/events/index.js +11 -8
- package/dist/functions/destroy.js +27 -5
- package/dist/functions/destroy.spec.js +69 -0
- package/dist/functions/initialize.js +60 -41
- package/dist/functions/initialize.spec.js +13 -13
- package/dist/functions/mount/fetch-summary-data.js +46 -0
- package/dist/functions/mount/fetch-summary-data.spec.js +44 -0
- package/dist/functions/mount/index.js +346 -0
- package/dist/functions/mount/mount.spec.js +135 -0
- package/dist/functions/on.js +26 -18
- package/dist/functions/on.spec.js +45 -63
- package/dist/functions/purchase.js +41 -154
- package/dist/functions/purchase.spec.js +60 -76
- package/dist/functions/show.js +39 -43
- package/dist/functions/show.spec.js +57 -0
- package/dist/functions/update.js +60 -5
- package/dist/functions/update.spec.js +100 -0
- package/dist/i18n/en.json +19 -0
- package/dist/i18n/es.json +19 -0
- package/dist/i18n/i18n.spec.js +6 -23
- package/dist/i18n/index.js +44 -67
- package/dist/index.js +70 -71
- package/dist/index.spec.js +24 -44
- package/dist/loader/index.js +63 -62
- package/dist/loader/loader.spec.js +14 -11
- package/dist/storefront/index.js +28 -39
- package/dist/storefront/models/plan-model.js +37 -54
- package/dist/storefront/models/product-model.js +25 -36
- package/dist/storefront/models/ready-to-pay-model.js +38 -42
- package/dist/storefront/models/summary-model.js +72 -99
- package/dist/storefront/plans.js +37 -84
- package/dist/storefront/plans.spec.js +61 -151
- package/dist/storefront/products.js +35 -83
- package/dist/storefront/products.spec.js +60 -150
- package/dist/storefront/purchase.js +27 -64
- package/dist/storefront/purchase.spec.js +51 -87
- package/dist/storefront/ready-to-pay.js +45 -107
- package/dist/storefront/ready-to-pay.spec.js +72 -147
- package/dist/storefront/storefront.spec.js +6 -6
- package/dist/storefront/summary.js +37 -84
- package/dist/storefront/summary.spec.js +135 -240
- package/dist/style/base/__snapshots__/theme.spec.js.snap +52 -0
- package/dist/style/base/index.js +72 -0
- package/dist/style/base/theme.js +73 -0
- package/dist/style/base/theme.spec.js +30 -0
- package/dist/style/browserslist.js +8 -0
- package/dist/style/components/address.js +64 -0
- package/dist/style/components/button.js +61 -0
- package/dist/style/components/divider.js +48 -0
- package/dist/style/components/forms/checkbox.js +83 -0
- package/dist/style/components/forms/field.js +53 -0
- package/dist/style/components/forms/form.js +28 -0
- package/dist/style/components/forms/input.js +45 -0
- package/dist/style/components/forms/label.js +43 -0
- package/dist/style/components/forms/select.js +63 -0
- package/dist/style/components/forms/validation.js +34 -0
- package/dist/style/components/icons.js +22 -0
- package/dist/style/components/index.js +57 -0
- package/dist/style/components/loader.js +48 -0
- package/dist/style/components/methods.js +104 -0
- package/dist/style/components/overlay.js +33 -0
- package/dist/style/helpers/index.js +59 -0
- package/dist/style/index.js +48 -0
- package/dist/style/payment-instruments/content.js +17 -0
- package/dist/style/payment-instruments/index.js +20 -0
- package/dist/style/payment-instruments/payment-card.js +35 -0
- package/dist/style/utils/color-values.js +22 -0
- package/dist/style/vendor/framepay.js +34 -0
- package/dist/style/vendor/postmate.js +17 -0
- package/dist/style/views/confirmation.js +85 -0
- package/dist/style/views/index.js +29 -0
- package/dist/style/views/method-selector.js +20 -0
- package/dist/style/views/modal.js +93 -0
- package/dist/style/views/result.js +61 -0
- package/dist/style/views/summary.js +123 -0
- package/dist/utils/add-dom-element.js +12 -34
- package/dist/utils/format-currency.js +4 -4
- package/dist/utils/has-valid-css-selector.js +2 -2
- package/dist/utils/index.js +15 -31
- package/dist/utils/is-dom-element.js +1 -1
- package/dist/utils/process-property-as-dom-element.js +12 -17
- package/dist/utils/sleep.js +10 -0
- package/{src/components → dist/views}/__snapshots__/summary.spec.js.snap +7 -3
- package/dist/views/common/iframe/base-iframe.js +57 -0
- package/dist/views/common/iframe/event-listeners.js +50 -0
- package/dist/views/common/iframe/index.js +19 -0
- package/dist/views/common/iframe/method-iframe.js +33 -0
- package/dist/views/common/iframe/modal-iframe.js +38 -0
- package/dist/views/common/iframe/view-iframe.js +31 -0
- package/dist/views/common/render-utilities.js +11 -0
- package/dist/views/confirmation.js +82 -0
- package/dist/views/method-selector/__snapshots__/method-selector.spec.js.snap +3 -0
- package/dist/views/method-selector/express-methods/apple-pay.js +92 -0
- package/dist/views/method-selector/express-methods/google-pay.js +32 -0
- package/dist/views/method-selector/express-methods/paypal.js +19 -0
- package/dist/views/method-selector/generate-digital-wallet.js +59 -0
- package/dist/views/method-selector/generate-digital-wallet.spec.js +132 -0
- package/dist/views/method-selector/get-method-data.js +25 -0
- package/dist/views/method-selector/get-payment-methods.js +55 -0
- package/dist/views/method-selector/get-payment-methods.spec.js +44 -0
- package/dist/views/method-selector/index.js +133 -0
- package/dist/views/method-selector/method-selector.spec.js +139 -0
- package/dist/views/method-selector/mount-express-methods.js +69 -0
- package/dist/views/method-selector/mount-methods.js +78 -0
- package/dist/views/modal.js +83 -0
- package/dist/views/result.js +42 -0
- package/dist/views/summary.js +162 -0
- package/dist/views/summary.spec.js +148 -0
- package/package.json +12 -6
- package/src/events/base-event.js +35 -12
- package/src/events/events.spec.js +11 -0
- package/src/events/index.js +12 -6
- package/src/functions/destroy.js +22 -3
- package/src/functions/destroy.spec.js +63 -0
- package/src/functions/initialize.js +43 -20
- package/src/functions/initialize.spec.js +9 -7
- package/src/functions/mount/fetch-summary-data.js +29 -0
- package/src/functions/mount/fetch-summary-data.spec.js +41 -0
- package/src/functions/mount/index.js +312 -0
- package/src/functions/mount/mount.spec.js +171 -0
- package/src/functions/on.js +17 -14
- package/src/functions/on.spec.js +39 -29
- package/src/functions/purchase.js +24 -64
- package/src/functions/purchase.spec.js +19 -17
- package/src/functions/show.js +27 -7
- package/src/functions/show.spec.js +61 -0
- package/src/functions/update.js +50 -3
- package/src/functions/update.spec.js +107 -0
- package/src/i18n/i18n.spec.js +6 -4
- package/src/i18n/index.js +20 -12
- package/src/index.js +43 -49
- package/src/index.spec.js +11 -42
- package/src/loader/index.js +55 -39
- package/src/loader/loader.spec.js +30 -23
- package/src/storefront/index.js +9 -7
- package/src/storefront/models/plan-model.js +1 -1
- package/src/storefront/models/product-model.js +1 -1
- package/src/storefront/models/ready-to-pay-model.js +10 -4
- package/src/storefront/models/summary-model.js +8 -15
- package/src/storefront/plans.js +16 -12
- package/src/storefront/plans.spec.js +29 -37
- package/src/storefront/products.js +16 -12
- package/src/storefront/products.spec.js +28 -39
- package/src/storefront/purchase.js +8 -6
- package/src/storefront/purchase.spec.js +18 -17
- package/src/storefront/ready-to-pay.js +19 -13
- package/src/storefront/ready-to-pay.spec.js +41 -41
- package/src/storefront/storefront.spec.js +1 -1
- package/src/storefront/summary.js +14 -12
- package/src/storefront/summary.spec.js +37 -50
- package/src/style/base/__snapshots__/theme.spec.js.snap +52 -0
- package/src/style/base/index.js +63 -0
- package/src/style/base/theme.js +61 -0
- package/src/style/base/theme.spec.js +32 -0
- package/src/style/browserslist.js +1 -0
- package/src/style/components/address.js +55 -0
- package/src/style/components/button.js +54 -0
- package/src/style/components/divider.js +39 -0
- package/src/style/components/forms/checkbox.js +76 -0
- package/src/style/components/forms/field.js +44 -0
- package/src/style/components/forms/form.js +19 -0
- package/src/style/components/forms/input.js +36 -0
- package/src/style/components/forms/label.js +34 -0
- package/src/style/components/forms/select.js +54 -0
- package/src/style/components/forms/validation.js +25 -0
- package/src/style/components/icons.js +13 -0
- package/src/style/components/index.js +35 -0
- package/src/style/components/loader.js +41 -0
- package/src/style/components/methods.js +93 -0
- package/src/style/components/overlay.js +24 -0
- package/src/style/helpers/index.js +51 -0
- package/src/style/index.js +30 -0
- package/src/style/payment-instruments/content.js +8 -0
- package/src/style/payment-instruments/index.js +10 -0
- package/src/style/payment-instruments/payment-card.js +26 -0
- package/src/style/utils/color-values.js +9 -0
- package/src/style/vendor/framepay.js +25 -0
- package/src/style/vendor/postmate.js +8 -0
- package/src/style/views/confirmation.js +76 -0
- package/src/style/views/index.js +16 -0
- package/src/style/views/method-selector.js +11 -0
- package/src/style/views/modal.js +84 -0
- package/src/style/views/result.js +52 -0
- package/src/style/views/summary.js +114 -0
- package/src/utils/add-dom-element.js +12 -13
- package/src/utils/format-currency.js +4 -1
- package/src/utils/has-valid-css-selector.js +2 -2
- package/src/utils/index.js +2 -6
- package/src/utils/is-dom-element.js +1 -1
- package/src/utils/process-property-as-dom-element.js +27 -24
- package/src/utils/sleep.js +3 -0
- package/src/views/__snapshots__/summary.spec.js.snap +292 -0
- package/src/views/common/iframe/base-iframe.js +46 -0
- package/src/views/common/iframe/event-listeners.js +27 -0
- package/src/views/common/iframe/index.js +7 -0
- package/src/views/common/iframe/method-iframe.js +21 -0
- package/src/views/common/iframe/modal-iframe.js +27 -0
- package/src/views/common/iframe/view-iframe.js +18 -0
- package/src/views/common/render-utilities.js +4 -0
- package/src/views/confirmation.js +57 -0
- package/src/views/method-selector/__snapshots__/method-selector.spec.js.snap +3 -0
- package/src/views/method-selector/express-methods/apple-pay.js +78 -0
- package/src/views/method-selector/express-methods/google-pay.js +25 -0
- package/src/views/method-selector/express-methods/paypal.js +7 -0
- package/src/views/method-selector/generate-digital-wallet.js +44 -0
- package/src/views/method-selector/generate-digital-wallet.spec.js +131 -0
- package/src/{components/form → views/method-selector}/get-method-data.js +9 -5
- package/src/views/method-selector/get-payment-methods.js +40 -0
- package/src/views/method-selector/get-payment-methods.spec.js +40 -0
- package/src/views/method-selector/index.js +110 -0
- package/src/views/method-selector/method-selector.spec.js +146 -0
- package/src/views/method-selector/mount-express-methods.js +53 -0
- package/src/views/method-selector/mount-methods.js +71 -0
- package/src/views/modal.js +84 -0
- package/src/views/result.js +30 -0
- package/src/{components → views}/summary.js +90 -21
- package/src/views/summary.spec.js +170 -0
- package/tests/async-utilities.js +22 -0
- package/tests/mocks/rebilly-instruments-mock.js +105 -7
- package/dist/components/confirmation.js +0 -103
- package/dist/components/form/form.js +0 -110
- package/dist/components/form/form.spec.js +0 -135
- package/dist/components/form/get-method-data.js +0 -21
- package/dist/components/form/get-payment-methods.js +0 -42
- package/dist/components/form/method-selector.js +0 -61
- package/dist/components/form/mount-express-payment-methods.js +0 -102
- package/dist/components/form/process-digital-wallet-options.js +0 -20
- package/dist/components/form/zoid-helpers.js +0 -130
- package/dist/components/result.js +0 -66
- package/dist/components/summary.js +0 -60
- package/dist/components/summary.spec.js +0 -144
- package/dist/events/instrument-ready.js +0 -51
- package/dist/events/purchase-complete.js +0 -51
- package/dist/functions/mount.js +0 -311
- package/dist/functions/mount.spec.js +0 -203
- package/dist/styles/base-styles.js +0 -12
- package/dist/styles/flat-theme-object.js +0 -42
- package/dist/styles/framepay.js +0 -15
- package/dist/styles/main.js +0 -25
- package/dist/styles/payment-card.js +0 -12
- package/dist/styles/shade-tint-values-helper.js +0 -28
- package/dist/styles/style-variables.js +0 -43
- package/dist/utils/camel-case.js +0 -12
- package/dist/utils/kebab-case.js +0 -10
- package/dist/utils/un-kebab-case.js +0 -10
- package/src/components/confirmation.js +0 -77
- package/src/components/form/__snapshots__/form.spec.js.snap +0 -43
- package/src/components/form/form.js +0 -88
- package/src/components/form/form.spec.js +0 -109
- package/src/components/form/get-payment-methods.js +0 -32
- package/src/components/form/method-selector.js +0 -47
- package/src/components/form/mount-express-payment-methods.js +0 -84
- package/src/components/form/process-digital-wallet-options.js +0 -11
- package/src/components/form/zoid-helpers.js +0 -114
- package/src/components/result.js +0 -50
- package/src/components/summary.spec.js +0 -106
- package/src/events/instrument-ready.js +0 -11
- package/src/events/purchase-complete.js +0 -11
- package/src/functions/mount.js +0 -204
- package/src/functions/mount.spec.js +0 -172
- package/src/styles/base-styles.js +0 -741
- package/src/styles/flat-theme-object.js +0 -12
- package/src/styles/framepay.js +0 -30
- package/src/styles/main.js +0 -17
- package/src/styles/payment-card.js +0 -18
- package/src/styles/shade-tint-values-helper.js +0 -13
- package/src/styles/style-variables.js +0 -34
- package/src/utils/camel-case.js +0 -3
- package/src/utils/kebab-case.js +0 -3
- package/src/utils/un-kebab-case.js +0 -3
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------------
|
|
2
|
+
// This file contains all styles related to the summary view.
|
|
3
|
+
// -----------------------------------------------------------------------------
|
|
4
|
+
export const summary = (theme) => `
|
|
5
|
+
/**
|
|
6
|
+
* Summary
|
|
7
|
+
*/
|
|
8
|
+
.rebilly-instruments-summary-line-item {
|
|
9
|
+
border-bottom: 1px solid ${theme.getComputed.color.mutedBorder};
|
|
10
|
+
padding: ${theme.space.s} 0;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.rebilly-instruments-summary-line-item:first-child {
|
|
17
|
+
padding-top: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.rebilly-instruments-summary-line-item-figure {
|
|
21
|
+
margin: 0 ${theme.space.s} 0 0;
|
|
22
|
+
flex: 0 0 auto;
|
|
23
|
+
width: 48px;
|
|
24
|
+
height: 48px;
|
|
25
|
+
border-radius: ${theme.borderRadius};
|
|
26
|
+
border: 1px solid ${theme.getComputed.color.mutedBorder};
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.rebilly-instruments-summary-line-item-figure img {
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rebilly-instruments-summary-line-item-synopsis {
|
|
35
|
+
flex: 1 2 auto;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rebilly-instruments-summary-line-item-synopsis-title {
|
|
39
|
+
margin: 0;
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.rebilly-instruments-summary-line-item-synopsis-description {
|
|
44
|
+
color: ${theme.getComputed.color.mutedText};
|
|
45
|
+
margin: 0;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
line-height: 14px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.rebilly-instruments-summary-line-item-price-breakdown {
|
|
51
|
+
display: flex;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
align-items: center;
|
|
54
|
+
color: ${theme.getComputed.color.mutedText};
|
|
55
|
+
margin: 0 0 0 ${theme.spaceS};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.rebilly-instruments-summary-line-item-price-breakdown .rebilly-instruments-icon {
|
|
59
|
+
fill: ${theme.getComputed.color.mutedText};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.rebilly-instruments-summary-line-item-price-breakdown-unit-price {
|
|
63
|
+
color: ${theme.color.text};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.rebilly-instruments-summary-breakdown table {
|
|
67
|
+
width: 100%;
|
|
68
|
+
margin: ${theme.space.xs} 0;
|
|
69
|
+
color: inherit;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.rebilly-instruments-summary-breakdown table colgroup col:first-child {
|
|
73
|
+
width: 85%;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.rebilly-instruments-summary-breakdown table colgroup col {
|
|
77
|
+
width: 15%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.rebilly-instruments-summary-breakdown table tr td {
|
|
81
|
+
text-align: right;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.rebilly-instruments-summary-breakdown table tr td:first-child {
|
|
85
|
+
padding-right: ${theme.space.s};
|
|
86
|
+
font-weight: 500;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.rebilly-instruments-summary-breakdown-total {
|
|
90
|
+
padding-top: ${theme.space.xs};
|
|
91
|
+
display: flex;
|
|
92
|
+
border-top: 1px solid ${theme.getComputed.color.mutedBorder};
|
|
93
|
+
align-items: center;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.rebilly-instruments-summary-breakdown-total p {
|
|
97
|
+
margin: ${theme.space.s} 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.rebilly-instruments-summary-breakdown-total-amount {
|
|
101
|
+
flex: 1 2 80%;
|
|
102
|
+
font-size: 24px;
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
text-align: right;
|
|
105
|
+
font-weight: bold;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.rebilly-instruments-summary-breakdown-total-amount-currency {
|
|
109
|
+
font-size: ${theme.typography.fontSize};
|
|
110
|
+
font-weight: normal;
|
|
111
|
+
color: ${theme.getComputed.color.mutedText};
|
|
112
|
+
margin-right: ${theme.space.s};
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
export default function addDOMElement(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
1
|
+
export default function addDOMElement({
|
|
2
|
+
element = 'div',
|
|
3
|
+
attributes = {},
|
|
4
|
+
content = null,
|
|
5
|
+
target = 'body',
|
|
6
|
+
insertMethod = 'append'
|
|
7
|
+
} = {}) {
|
|
8
|
+
const ELEMENT = document.createElement(element);
|
|
9
|
+
const ELEMENT_ATTRIBUTES = Object.entries(attributes);
|
|
10
|
+
ELEMENT_ATTRIBUTES.forEach(([attribute, value]) => {
|
|
11
|
+
ELEMENT.setAttribute(attribute, value);
|
|
12
|
+
});
|
|
14
13
|
if (content) {
|
|
15
14
|
ELEMENT.innerHTML = content;
|
|
16
15
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export default function formatCurrency(number, currency = 'USD') {
|
|
2
|
-
|
|
2
|
+
if (!number) return '-';
|
|
3
|
+
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(
|
|
4
|
+
number
|
|
5
|
+
);
|
|
3
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export default function hasValidCSSSelector(selector) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const REGEX_CSS_SELECTOR = /([.#][_a-z]+[_a-z0-9-:\\]*)/gi;
|
|
3
|
+
return typeof selector === 'string' && selector.match(REGEX_CSS_SELECTOR);
|
|
4
4
|
}
|
package/src/utils/index.js
CHANGED
|
@@ -3,9 +3,7 @@ import processPropertyAsDOMElement from './process-property-as-dom-element';
|
|
|
3
3
|
import isDOMElement from './is-dom-element';
|
|
4
4
|
import hasValidCSSSelector from './has-valid-css-selector';
|
|
5
5
|
import formatCurrency from './format-currency';
|
|
6
|
-
import
|
|
7
|
-
import unKebabCase from './un-kebab-case';
|
|
8
|
-
import camelCase from './camel-case';
|
|
6
|
+
import sleep from './sleep';
|
|
9
7
|
|
|
10
8
|
export {
|
|
11
9
|
addDOMElement,
|
|
@@ -13,7 +11,5 @@ export {
|
|
|
13
11
|
isDOMElement,
|
|
14
12
|
hasValidCSSSelector,
|
|
15
13
|
formatCurrency,
|
|
16
|
-
|
|
17
|
-
unKebabCase,
|
|
18
|
-
camelCase,
|
|
14
|
+
sleep
|
|
19
15
|
};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import hasValidCSSSelector from './has-valid-css-selector';
|
|
2
2
|
import isDOMElement from './is-dom-element';
|
|
3
3
|
|
|
4
|
-
export default function processPropertyAsDOMElement(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
4
|
+
export default function processPropertyAsDOMElement({
|
|
5
|
+
prop,
|
|
6
|
+
propName = 'Mounting',
|
|
7
|
+
isRequired = true
|
|
8
|
+
} = {}) {
|
|
9
|
+
let DOMElement;
|
|
10
|
+
|
|
11
|
+
if (typeof prop === 'undefined') {
|
|
12
|
+
throw new Error('processPropertyDOMElement: Missing argument "prop"');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (hasValidCSSSelector(prop)) {
|
|
16
|
+
DOMElement = document.querySelector(prop);
|
|
17
|
+
} else if (isDOMElement(prop)) {
|
|
18
|
+
DOMElement = prop;
|
|
19
|
+
} else {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Please provide a valid CSS class, id or DOM element for "${propName}" property`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!DOMElement && isRequired) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Could not find DOM element with CSS class or id "${prop}" to mount ${propName}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return DOMElement;
|
|
28
31
|
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Summary component should render the summary correctly 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
class="rebilly-instruments-summary-line-items"
|
|
6
|
+
>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<div
|
|
10
|
+
class="rebilly-instruments-summary-line-item"
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
class="rebilly-instruments-summary-line-item-synopsis"
|
|
17
|
+
>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<p
|
|
21
|
+
class="rebilly-instruments-summary-line-item-synopsis-title"
|
|
22
|
+
>
|
|
23
|
+
My Awesome Product
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<p
|
|
29
|
+
class="rebilly-instruments-summary-line-item-synopsis-description"
|
|
30
|
+
>
|
|
31
|
+
My Awesome Product
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<div
|
|
40
|
+
class="rebilly-instruments-summary-line-item-price-breakdown"
|
|
41
|
+
>
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
<p
|
|
45
|
+
class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
|
|
46
|
+
>
|
|
47
|
+
1
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<svg
|
|
52
|
+
class="rebilly-instruments-icon"
|
|
53
|
+
viewBox="0 0 24 24"
|
|
54
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
55
|
+
>
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<path
|
|
59
|
+
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"
|
|
60
|
+
fill-rule="nonzero"
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
</svg>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
<p
|
|
68
|
+
class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
|
|
69
|
+
>
|
|
70
|
+
$30.00
|
|
71
|
+
</p>
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<div
|
|
82
|
+
class="rebilly-instruments-summary-line-item"
|
|
83
|
+
>
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
<div
|
|
88
|
+
class="rebilly-instruments-summary-line-item-synopsis"
|
|
89
|
+
>
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
<p
|
|
93
|
+
class="rebilly-instruments-summary-line-item-synopsis-title"
|
|
94
|
+
>
|
|
95
|
+
My Awesome T-Shirt
|
|
96
|
+
</p>
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<p
|
|
101
|
+
class="rebilly-instruments-summary-line-item-synopsis-description"
|
|
102
|
+
>
|
|
103
|
+
My Awesome T-Shirt
|
|
104
|
+
</p>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<div
|
|
112
|
+
class="rebilly-instruments-summary-line-item-price-breakdown"
|
|
113
|
+
>
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<p
|
|
117
|
+
class="rebilly-instruments-summary-line-item-price-breakdown-quantity"
|
|
118
|
+
>
|
|
119
|
+
2
|
|
120
|
+
</p>
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
<svg
|
|
124
|
+
class="rebilly-instruments-icon"
|
|
125
|
+
viewBox="0 0 24 24"
|
|
126
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
127
|
+
>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
<path
|
|
131
|
+
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"
|
|
132
|
+
fill-rule="nonzero"
|
|
133
|
+
/>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
</svg>
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
<p
|
|
140
|
+
class="rebilly-instruments-summary-line-item-price-breakdown-unit-price"
|
|
141
|
+
>
|
|
142
|
+
$20.00
|
|
143
|
+
</p>
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
</div>
|
|
153
|
+
`;
|
|
154
|
+
|
|
155
|
+
exports[`Summary component should render the summary correctly 2`] = `
|
|
156
|
+
<div
|
|
157
|
+
class="rebilly-instruments-summary-breakdown"
|
|
158
|
+
>
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
<table>
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
<colgroup>
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
<col />
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
<col />
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
</colgroup>
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
<tbody>
|
|
177
|
+
<tr
|
|
178
|
+
class="rebilly-instruments-summary-breakdown-sub-total"
|
|
179
|
+
>
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
<td
|
|
183
|
+
data-rebilly-i18n="summary.subTotal"
|
|
184
|
+
>
|
|
185
|
+
Sub Total
|
|
186
|
+
</td>
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
<td>
|
|
190
|
+
$70.00
|
|
191
|
+
</td>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
</tr>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
<tr
|
|
198
|
+
class="rebilly-instruments-summary-breakdown-discounts"
|
|
199
|
+
>
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
<td
|
|
203
|
+
data-rebilly-i18n="summary.discounts"
|
|
204
|
+
>
|
|
205
|
+
Discounts
|
|
206
|
+
</td>
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
<td>
|
|
210
|
+
-
|
|
211
|
+
</td>
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
</tr>
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
<tr
|
|
218
|
+
class="rebilly-instruments-summary-breakdown-taxes"
|
|
219
|
+
>
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
<td
|
|
223
|
+
data-rebilly-i18n="summary.taxes"
|
|
224
|
+
>
|
|
225
|
+
Taxes
|
|
226
|
+
</td>
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
<td>
|
|
230
|
+
-
|
|
231
|
+
</td>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
</tr>
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
<tr
|
|
238
|
+
class="rebilly-instruments-summary-breakdown-taxes"
|
|
239
|
+
>
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
<td
|
|
243
|
+
data-rebilly-i18n="summary.shipping"
|
|
244
|
+
>
|
|
245
|
+
Shipping
|
|
246
|
+
</td>
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
<td>
|
|
250
|
+
-
|
|
251
|
+
</td>
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
</tr>
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
</tbody>
|
|
258
|
+
</table>
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
<div
|
|
262
|
+
class="rebilly-instruments-summary-breakdown-total"
|
|
263
|
+
>
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
<p
|
|
267
|
+
data-rebilly-i18n="summary.total"
|
|
268
|
+
>
|
|
269
|
+
Total
|
|
270
|
+
</p>
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
<p
|
|
274
|
+
class="rebilly-instruments-summary-breakdown-total-amount"
|
|
275
|
+
>
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
<span
|
|
279
|
+
class="rebilly-instruments-summary-breakdown-total-amount-currency"
|
|
280
|
+
>
|
|
281
|
+
USD
|
|
282
|
+
</span>
|
|
283
|
+
$70.00
|
|
284
|
+
|
|
285
|
+
</p>
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
</div>
|
|
292
|
+
`;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Postmate from 'postmate';
|
|
2
|
+
|
|
3
|
+
export default class BaseIframe {
|
|
4
|
+
constructor({
|
|
5
|
+
name = '',
|
|
6
|
+
url = '',
|
|
7
|
+
model = {},
|
|
8
|
+
container = null,
|
|
9
|
+
classListArray = []
|
|
10
|
+
} = {}) {
|
|
11
|
+
classListArray = Array.isArray(classListArray) ? classListArray : [];
|
|
12
|
+
if (!classListArray.includes('rebilly-instruments-iframe')) {
|
|
13
|
+
classListArray.push('rebilly-instruments-iframe');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this.container = container;
|
|
17
|
+
this.classListArray = classListArray;
|
|
18
|
+
this.name = name;
|
|
19
|
+
this.url = url;
|
|
20
|
+
this.model = model;
|
|
21
|
+
this.component = null;
|
|
22
|
+
|
|
23
|
+
return (async () => {
|
|
24
|
+
this.component = await this.createComponent();
|
|
25
|
+
return this;
|
|
26
|
+
})();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async destroy() {
|
|
30
|
+
if (this.component.frame.parentNode) {
|
|
31
|
+
await this.component.destroy();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async createComponent() {
|
|
36
|
+
const component = await new Postmate({
|
|
37
|
+
name: this.name,
|
|
38
|
+
url: this.url,
|
|
39
|
+
container: this.container,
|
|
40
|
+
classListArray: this.classListArray,
|
|
41
|
+
model: this.model
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return component;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import camelCase from 'lodash.camelcase';
|
|
2
|
+
import Events from '../../../events';
|
|
3
|
+
|
|
4
|
+
export function dispatchRebillyInsturmentEventHandler(iframe) {
|
|
5
|
+
iframe.component.on(`${iframe.name}-dispatch`, ({ event, detail }) => {
|
|
6
|
+
Events[camelCase(event).replace(/-/, '')].dispatch(detail);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function resizeComponentHandler(iframe) {
|
|
11
|
+
iframe.component.on(`${iframe.name}-resize-frame`, (height) => {
|
|
12
|
+
iframe.component.frame.style.height = height;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function stopLoaderHandler(iframe, data = { section: 'form' }) {
|
|
17
|
+
iframe.component.on(`${iframe.name}-stop-loading`, (id = null) => {
|
|
18
|
+
data.loader?.stopLoading({ section: data.section, id: id || data.id });
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function changeIframeSrcHandler(iframe) {
|
|
23
|
+
iframe.component.on(`${iframe.name}-change-iframe-src`, (url = null) => {
|
|
24
|
+
iframe.component.frame.src = url;
|
|
25
|
+
iframe.component.frame.style.height = '75vh';
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MethodIframe as method } from './method-iframe';
|
|
2
|
+
import { ViewIframe as view } from './view-iframe';
|
|
3
|
+
import { ModalIframe as modal } from './modal-iframe';
|
|
4
|
+
|
|
5
|
+
export const MethodIframe = method;
|
|
6
|
+
export const ViewIframe = view;
|
|
7
|
+
export const ModalIframe = modal;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BaseIframe from './base-iframe';
|
|
2
|
+
import {
|
|
3
|
+
dispatchRebillyInsturmentEventHandler,
|
|
4
|
+
resizeComponentHandler,
|
|
5
|
+
stopLoaderHandler
|
|
6
|
+
} from './event-listeners';
|
|
7
|
+
|
|
8
|
+
export class MethodIframe extends BaseIframe {
|
|
9
|
+
constructor(args = {}) {
|
|
10
|
+
super(args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
bindEventListeners({ loader, id } = {}) {
|
|
14
|
+
dispatchRebillyInsturmentEventHandler(this);
|
|
15
|
+
resizeComponentHandler(this);
|
|
16
|
+
stopLoaderHandler(this, {
|
|
17
|
+
loader,
|
|
18
|
+
id
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import BaseIframe from './base-iframe';
|
|
2
|
+
import {
|
|
3
|
+
dispatchRebillyInsturmentEventHandler,
|
|
4
|
+
resizeComponentHandler,
|
|
5
|
+
changeIframeSrcHandler,
|
|
6
|
+
stopLoaderHandler
|
|
7
|
+
} from './event-listeners';
|
|
8
|
+
|
|
9
|
+
export class ModalIframe extends BaseIframe {
|
|
10
|
+
constructor(args = {}) {
|
|
11
|
+
super(args);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
bindEventListeners({ close = () => {}, loader } = {}) {
|
|
15
|
+
dispatchRebillyInsturmentEventHandler(this);
|
|
16
|
+
resizeComponentHandler(this);
|
|
17
|
+
changeIframeSrcHandler(this);
|
|
18
|
+
this.component.on(`${this.name}-close`, (...args) => {
|
|
19
|
+
close(...args);
|
|
20
|
+
});
|
|
21
|
+
stopLoaderHandler(this, {
|
|
22
|
+
loader,
|
|
23
|
+
section: 'modal',
|
|
24
|
+
id: 'modal-content'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BaseIframe from './base-iframe';
|
|
2
|
+
import {
|
|
3
|
+
dispatchRebillyInsturmentEventHandler,
|
|
4
|
+
resizeComponentHandler,
|
|
5
|
+
stopLoaderHandler
|
|
6
|
+
} from './event-listeners';
|
|
7
|
+
|
|
8
|
+
export class ViewIframe extends BaseIframe {
|
|
9
|
+
constructor(args = {}) {
|
|
10
|
+
super(args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
bindEventListeners({ loader } = {}) {
|
|
14
|
+
dispatchRebillyInsturmentEventHandler(this);
|
|
15
|
+
resizeComponentHandler(this);
|
|
16
|
+
stopLoaderHandler(this, { loader });
|
|
17
|
+
}
|
|
18
|
+
}
|