@salla.sa/twilight-components 2.11.73 → 2.11.75
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/dist/cjs/salla-add-product-button.cjs.entry.js +5 -2
- package/dist/cjs/salla-button_37.cjs.entry.js +12 -19
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +5 -2
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +17 -25
- package/dist/components/salla-add-product-button.js +5 -2
- package/dist/components/salla-quick-buy2.js +12 -19
- package/dist/esm/salla-add-product-button.entry.js +5 -2
- package/dist/esm/salla-button_37.entry.js +12 -19
- package/dist/esm-es5/salla-add-product-button.entry.js +2 -2
- package/dist/esm-es5/salla-button_37.entry.js +1 -1
- package/dist/twilight/p-1bcb8eb7.system.entry.js +4 -0
- package/dist/twilight/{p-b2216a7f.entry.js → p-276a23f9.entry.js} +1 -1
- package/dist/twilight/p-60fb9bb5.system.js +1 -1
- package/dist/twilight/p-b21e1fb8.entry.js +4 -0
- package/dist/twilight/{p-39a28c32.system.entry.js → p-e8ad817e.system.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-add-product-button/salla-add-product-button.d.ts +1 -0
- package/dist/types/components/salla-quick-buy/salla-quick-buy.d.ts +4 -4
- package/dist/types/components.d.ts +8 -8
- package/package.json +2 -2
- package/dist/twilight/p-8c7b124e.system.entry.js +0 -4
- package/dist/twilight/p-91f5d041.entry.js +0 -4
|
@@ -88,6 +88,9 @@ const SallaAddProductButton = class {
|
|
|
88
88
|
}
|
|
89
89
|
return this.hostAttributes;
|
|
90
90
|
}
|
|
91
|
+
getQuickBuyBtnAttributes() {
|
|
92
|
+
return Object.assign(Object.assign({}, this.getBtnAttributes()), { type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : 'buy' });
|
|
93
|
+
}
|
|
91
94
|
componentWillLoad() {
|
|
92
95
|
this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();
|
|
93
96
|
if (this.host.hasAttribute('type') && this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {
|
|
@@ -114,7 +117,7 @@ const SallaAddProductButton = class {
|
|
|
114
117
|
if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {
|
|
115
118
|
return index.h(index.Host, null, index.h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), index.h("span", { class: "s-hidden" }, index.h("slot", null))));
|
|
116
119
|
}
|
|
117
|
-
return index.h(index.Host, { class: { 's-add-product-button-with-quick-buy': this.showQuickBuy, 's-add-product-button-with-sticky-bar': this.supportStickyBar } }, index.h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), index.h("slot", null)), this.showQuickBuy ? index.h("salla-quick-buy", Object.assign({}, this.
|
|
120
|
+
return index.h(index.Host, { class: { 's-add-product-button-with-quick-buy': this.showQuickBuy, 's-add-product-button-with-sticky-bar': this.supportStickyBar } }, index.h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), index.h("slot", null)), this.showQuickBuy ? index.h("salla-quick-buy", Object.assign({}, this.getQuickBuyBtnAttributes())) : '');
|
|
118
121
|
}
|
|
119
122
|
componentDidLoad() {
|
|
120
123
|
if (!this.notifyOptionsAvailability) {
|
|
@@ -144,7 +147,7 @@ const SallaAddProductButton = class {
|
|
|
144
147
|
componentDidRender() {
|
|
145
148
|
var _a;
|
|
146
149
|
//if label not passed, get label
|
|
147
|
-
if (!!this.passedLabel &&
|
|
150
|
+
if (!!this.passedLabel && !this.supportStickyBar) {
|
|
148
151
|
return;
|
|
149
152
|
}
|
|
150
153
|
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(this.getLabel());
|
|
@@ -25998,16 +25998,9 @@ const SallaQuickBuy = class {
|
|
|
25998
25998
|
* Button type.
|
|
25999
25999
|
*
|
|
26000
26000
|
* @type {string}
|
|
26001
|
-
* @default
|
|
26001
|
+
* @default buy
|
|
26002
26002
|
**/
|
|
26003
26003
|
this.type = 'buy';
|
|
26004
|
-
/**
|
|
26005
|
-
* Product amount.
|
|
26006
|
-
*
|
|
26007
|
-
* @type {number}
|
|
26008
|
-
* @default 0
|
|
26009
|
-
**/
|
|
26010
|
-
this.amount = 0;
|
|
26011
26004
|
/**
|
|
26012
26005
|
* Product options, if is empty will get the data from the document.querySelector('salla-product-options[product-id="X"]')
|
|
26013
26006
|
*
|
|
@@ -26051,7 +26044,7 @@ const SallaQuickBuy = class {
|
|
|
26051
26044
|
// noinspection TypeScriptValidateJSTypes
|
|
26052
26045
|
salla.event.dispatch('payments::apple-pay.start-transaction', {
|
|
26053
26046
|
amount: this.amount,
|
|
26054
|
-
currency: this.currency,
|
|
26047
|
+
currency: this.currency || 'SAR',
|
|
26055
26048
|
requiredShippingContactFields: this.isRequireShipping ? ['postalAddress'] : null,
|
|
26056
26049
|
shippingMethods: this.isRequireShipping ? [] : null,
|
|
26057
26050
|
supportedNetworks: salla.config.get('store.settings.buy_now.networks'),
|
|
@@ -26110,16 +26103,13 @@ const SallaQuickBuy = class {
|
|
|
26110
26103
|
componentWillLoad() {
|
|
26111
26104
|
return new Promise((resolve, reject) => {
|
|
26112
26105
|
salla.onReady(async () => {
|
|
26106
|
+
// if (!this.currency) {
|
|
26107
|
+
// this.currency = salla.config.get('user.currency_code');
|
|
26108
|
+
// }
|
|
26113
26109
|
var _a, _b;
|
|
26114
|
-
if (!this.currency) {
|
|
26115
|
-
this.currency = salla.config.get('user.currency_code');
|
|
26116
|
-
}
|
|
26117
26110
|
if (!this.productId && salla.config.get('page.id')) {
|
|
26118
26111
|
this.productId = salla.config.get('page.id');
|
|
26119
26112
|
}
|
|
26120
|
-
if (window.innerWidth <= 768 && this.type !== 'plain') {
|
|
26121
|
-
this.type = 'plain';
|
|
26122
|
-
}
|
|
26123
26113
|
if (!this.productId) {
|
|
26124
26114
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, the product id is missing');
|
|
26125
26115
|
return reject();
|
|
@@ -26127,7 +26117,8 @@ const SallaQuickBuy = class {
|
|
|
26127
26117
|
if (!this.amount && this.productId) {
|
|
26128
26118
|
await salla.product.getDetails(this.productId, []).then((response) => {
|
|
26129
26119
|
var _a;
|
|
26130
|
-
this.amount = response.data.
|
|
26120
|
+
this.amount = response.data.base_currency_price.amount;
|
|
26121
|
+
this.currency = response.data.base_currency_price.currency;
|
|
26131
26122
|
this.isRequireShipping = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.is_require_shipping) || false;
|
|
26132
26123
|
}).catch((error) => {
|
|
26133
26124
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, get the product details failed: ', error);
|
|
@@ -26135,11 +26126,13 @@ const SallaQuickBuy = class {
|
|
|
26135
26126
|
});
|
|
26136
26127
|
}
|
|
26137
26128
|
if (salla.url.is_page('product.single')) {
|
|
26138
|
-
salla.product.event.onPriceUpdated(response =>
|
|
26129
|
+
salla.product.event.onPriceUpdated(response => {
|
|
26130
|
+
this.amount = response.data.base_currency_price.amount;
|
|
26131
|
+
this.currency = response.data.base_currency_price.currency;
|
|
26132
|
+
});
|
|
26139
26133
|
}
|
|
26140
26134
|
this.isApplePayActive = ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePayments())
|
|
26141
|
-
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'))
|
|
26142
|
-
&& salla.config.get('user.currency_code') === 'SAR';
|
|
26135
|
+
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'));
|
|
26143
26136
|
let applePaySdk = document.getElementById('apple-pay-sdk');
|
|
26144
26137
|
if (applePaySdk || !this.isApplePayActive) {
|
|
26145
26138
|
salla.logger.warn('🍏 Pay: Skipped load apple pay because ' + (applePaySdk ? 'already loaded' : 'is not available in the browser'));
|
|
@@ -78,6 +78,9 @@ export class SallaAddProductButton {
|
|
|
78
78
|
}
|
|
79
79
|
return this.hostAttributes;
|
|
80
80
|
}
|
|
81
|
+
getQuickBuyBtnAttributes() {
|
|
82
|
+
return Object.assign(Object.assign({}, this.getBtnAttributes()), { type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : 'buy' });
|
|
83
|
+
}
|
|
81
84
|
componentWillLoad() {
|
|
82
85
|
this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();
|
|
83
86
|
if (this.host.hasAttribute('type') && this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {
|
|
@@ -113,7 +116,7 @@ export class SallaAddProductButton {
|
|
|
113
116
|
return h(Host, { class: { 's-add-product-button-with-quick-buy': this.showQuickBuy, 's-add-product-button-with-sticky-bar': this.supportStickyBar } },
|
|
114
117
|
h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }),
|
|
115
118
|
h("slot", null)),
|
|
116
|
-
this.showQuickBuy ? h("salla-quick-buy", Object.assign({}, this.
|
|
119
|
+
this.showQuickBuy ? h("salla-quick-buy", Object.assign({}, this.getQuickBuyBtnAttributes())) : '');
|
|
117
120
|
}
|
|
118
121
|
componentDidLoad() {
|
|
119
122
|
if (!this.notifyOptionsAvailability) {
|
|
@@ -143,7 +146,7 @@ export class SallaAddProductButton {
|
|
|
143
146
|
componentDidRender() {
|
|
144
147
|
var _a;
|
|
145
148
|
//if label not passed, get label
|
|
146
|
-
if (!!this.passedLabel &&
|
|
149
|
+
if (!!this.passedLabel && !this.supportStickyBar) {
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
152
|
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(this.getLabel());
|
|
@@ -10,16 +10,9 @@ export class SallaQuickBuy {
|
|
|
10
10
|
* Button type.
|
|
11
11
|
*
|
|
12
12
|
* @type {string}
|
|
13
|
-
* @default
|
|
13
|
+
* @default buy
|
|
14
14
|
**/
|
|
15
15
|
this.type = 'buy';
|
|
16
|
-
/**
|
|
17
|
-
* Product amount.
|
|
18
|
-
*
|
|
19
|
-
* @type {number}
|
|
20
|
-
* @default 0
|
|
21
|
-
**/
|
|
22
|
-
this.amount = 0;
|
|
23
16
|
/**
|
|
24
17
|
* Product options, if is empty will get the data from the document.querySelector('salla-product-options[product-id="X"]')
|
|
25
18
|
*
|
|
@@ -63,7 +56,7 @@ export class SallaQuickBuy {
|
|
|
63
56
|
// noinspection TypeScriptValidateJSTypes
|
|
64
57
|
salla.event.dispatch('payments::apple-pay.start-transaction', {
|
|
65
58
|
amount: this.amount,
|
|
66
|
-
currency: this.currency,
|
|
59
|
+
currency: this.currency || 'SAR',
|
|
67
60
|
requiredShippingContactFields: this.isRequireShipping ? ['postalAddress'] : null,
|
|
68
61
|
shippingMethods: this.isRequireShipping ? [] : null,
|
|
69
62
|
supportedNetworks: salla.config.get('store.settings.buy_now.networks'),
|
|
@@ -122,16 +115,13 @@ export class SallaQuickBuy {
|
|
|
122
115
|
componentWillLoad() {
|
|
123
116
|
return new Promise((resolve, reject) => {
|
|
124
117
|
salla.onReady(async () => {
|
|
118
|
+
// if (!this.currency) {
|
|
119
|
+
// this.currency = salla.config.get('user.currency_code');
|
|
120
|
+
// }
|
|
125
121
|
var _a, _b;
|
|
126
|
-
if (!this.currency) {
|
|
127
|
-
this.currency = salla.config.get('user.currency_code');
|
|
128
|
-
}
|
|
129
122
|
if (!this.productId && salla.config.get('page.id')) {
|
|
130
123
|
this.productId = salla.config.get('page.id');
|
|
131
124
|
}
|
|
132
|
-
if (window.innerWidth <= 768 && this.type !== 'plain') {
|
|
133
|
-
this.type = 'plain';
|
|
134
|
-
}
|
|
135
125
|
if (!this.productId) {
|
|
136
126
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, the product id is missing');
|
|
137
127
|
return reject();
|
|
@@ -139,7 +129,8 @@ export class SallaQuickBuy {
|
|
|
139
129
|
if (!this.amount && this.productId) {
|
|
140
130
|
await salla.product.getDetails(this.productId, []).then((response) => {
|
|
141
131
|
var _a;
|
|
142
|
-
this.amount = response.data.
|
|
132
|
+
this.amount = response.data.base_currency_price.amount;
|
|
133
|
+
this.currency = response.data.base_currency_price.currency;
|
|
143
134
|
this.isRequireShipping = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.is_require_shipping) || false;
|
|
144
135
|
}).catch((error) => {
|
|
145
136
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, get the product details failed: ', error);
|
|
@@ -147,11 +138,13 @@ export class SallaQuickBuy {
|
|
|
147
138
|
});
|
|
148
139
|
}
|
|
149
140
|
if (salla.url.is_page('product.single')) {
|
|
150
|
-
salla.product.event.onPriceUpdated(response =>
|
|
141
|
+
salla.product.event.onPriceUpdated(response => {
|
|
142
|
+
this.amount = response.data.base_currency_price.amount;
|
|
143
|
+
this.currency = response.data.base_currency_price.currency;
|
|
144
|
+
});
|
|
151
145
|
}
|
|
152
146
|
this.isApplePayActive = ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePayments())
|
|
153
|
-
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'))
|
|
154
|
-
&& salla.config.get('user.currency_code') === 'SAR';
|
|
147
|
+
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'));
|
|
155
148
|
let applePaySdk = document.getElementById('apple-pay-sdk');
|
|
156
149
|
if (applePaySdk || !this.isApplePayActive) {
|
|
157
150
|
salla.logger.warn('🍏 Pay: Skipped load apple pay because ' + (applePaySdk ? 'already loaded' : 'is not available in the browser'));
|
|
@@ -202,7 +195,7 @@ export class SallaQuickBuy {
|
|
|
202
195
|
"text": "{string}"
|
|
203
196
|
}, {
|
|
204
197
|
"name": "default",
|
|
205
|
-
"text": "
|
|
198
|
+
"text": "buy"
|
|
206
199
|
}],
|
|
207
200
|
"text": "Button type."
|
|
208
201
|
},
|
|
@@ -248,11 +241,10 @@ export class SallaQuickBuy {
|
|
|
248
241
|
"name": "default",
|
|
249
242
|
"text": "0"
|
|
250
243
|
}],
|
|
251
|
-
"text": "Product amount."
|
|
244
|
+
"text": "Product amount in base currency (SAR)."
|
|
252
245
|
},
|
|
253
246
|
"attribute": "amount",
|
|
254
|
-
"reflect": true
|
|
255
|
-
"defaultValue": "0"
|
|
247
|
+
"reflect": true
|
|
256
248
|
},
|
|
257
249
|
"currency": {
|
|
258
250
|
"type": "string",
|
|
@@ -270,9 +262,9 @@ export class SallaQuickBuy {
|
|
|
270
262
|
"text": "{string}"
|
|
271
263
|
}, {
|
|
272
264
|
"name": "default",
|
|
273
|
-
"text": "
|
|
265
|
+
"text": "SAR"
|
|
274
266
|
}],
|
|
275
|
-
"text": "
|
|
267
|
+
"text": "base currency"
|
|
276
268
|
},
|
|
277
269
|
"attribute": "currency",
|
|
278
270
|
"reflect": false
|
|
@@ -91,6 +91,9 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
|
|
|
91
91
|
}
|
|
92
92
|
return this.hostAttributes;
|
|
93
93
|
}
|
|
94
|
+
getQuickBuyBtnAttributes() {
|
|
95
|
+
return Object.assign(Object.assign({}, this.getBtnAttributes()), { type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : 'buy' });
|
|
96
|
+
}
|
|
94
97
|
componentWillLoad() {
|
|
95
98
|
this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();
|
|
96
99
|
if (this.host.hasAttribute('type') && this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {
|
|
@@ -117,7 +120,7 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
|
|
|
117
120
|
if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {
|
|
118
121
|
return h(Host, null, h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), h("span", { class: "s-hidden" }, h("slot", null))));
|
|
119
122
|
}
|
|
120
|
-
return h(Host, { class: { 's-add-product-button-with-quick-buy': this.showQuickBuy, 's-add-product-button-with-sticky-bar': this.supportStickyBar } }, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), h("slot", null)), this.showQuickBuy ? h("salla-quick-buy", Object.assign({}, this.
|
|
123
|
+
return h(Host, { class: { 's-add-product-button-with-quick-buy': this.showQuickBuy, 's-add-product-button-with-sticky-bar': this.supportStickyBar } }, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), h("slot", null)), this.showQuickBuy ? h("salla-quick-buy", Object.assign({}, this.getQuickBuyBtnAttributes())) : '');
|
|
121
124
|
}
|
|
122
125
|
componentDidLoad() {
|
|
123
126
|
if (!this.notifyOptionsAvailability) {
|
|
@@ -147,7 +150,7 @@ const SallaAddProductButton$1 = /*@__PURE__*/ proxyCustomElement(class extends H
|
|
|
147
150
|
componentDidRender() {
|
|
148
151
|
var _a;
|
|
149
152
|
//if label not passed, get label
|
|
150
|
-
if (!!this.passedLabel &&
|
|
153
|
+
if (!!this.passedLabel && !this.supportStickyBar) {
|
|
151
154
|
return;
|
|
152
155
|
}
|
|
153
156
|
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(this.getLabel());
|
|
@@ -2413,16 +2413,9 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
2413
2413
|
* Button type.
|
|
2414
2414
|
*
|
|
2415
2415
|
* @type {string}
|
|
2416
|
-
* @default
|
|
2416
|
+
* @default buy
|
|
2417
2417
|
**/
|
|
2418
2418
|
this.type = 'buy';
|
|
2419
|
-
/**
|
|
2420
|
-
* Product amount.
|
|
2421
|
-
*
|
|
2422
|
-
* @type {number}
|
|
2423
|
-
* @default 0
|
|
2424
|
-
**/
|
|
2425
|
-
this.amount = 0;
|
|
2426
2419
|
/**
|
|
2427
2420
|
* Product options, if is empty will get the data from the document.querySelector('salla-product-options[product-id="X"]')
|
|
2428
2421
|
*
|
|
@@ -2466,7 +2459,7 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
2466
2459
|
// noinspection TypeScriptValidateJSTypes
|
|
2467
2460
|
salla.event.dispatch('payments::apple-pay.start-transaction', {
|
|
2468
2461
|
amount: this.amount,
|
|
2469
|
-
currency: this.currency,
|
|
2462
|
+
currency: this.currency || 'SAR',
|
|
2470
2463
|
requiredShippingContactFields: this.isRequireShipping ? ['postalAddress'] : null,
|
|
2471
2464
|
shippingMethods: this.isRequireShipping ? [] : null,
|
|
2472
2465
|
supportedNetworks: salla.config.get('store.settings.buy_now.networks'),
|
|
@@ -2525,16 +2518,13 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
2525
2518
|
componentWillLoad() {
|
|
2526
2519
|
return new Promise((resolve, reject) => {
|
|
2527
2520
|
salla.onReady(async () => {
|
|
2521
|
+
// if (!this.currency) {
|
|
2522
|
+
// this.currency = salla.config.get('user.currency_code');
|
|
2523
|
+
// }
|
|
2528
2524
|
var _a, _b;
|
|
2529
|
-
if (!this.currency) {
|
|
2530
|
-
this.currency = salla.config.get('user.currency_code');
|
|
2531
|
-
}
|
|
2532
2525
|
if (!this.productId && salla.config.get('page.id')) {
|
|
2533
2526
|
this.productId = salla.config.get('page.id');
|
|
2534
2527
|
}
|
|
2535
|
-
if (window.innerWidth <= 768 && this.type !== 'plain') {
|
|
2536
|
-
this.type = 'plain';
|
|
2537
|
-
}
|
|
2538
2528
|
if (!this.productId) {
|
|
2539
2529
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, the product id is missing');
|
|
2540
2530
|
return reject();
|
|
@@ -2542,7 +2532,8 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
2542
2532
|
if (!this.amount && this.productId) {
|
|
2543
2533
|
await salla.product.getDetails(this.productId, []).then((response) => {
|
|
2544
2534
|
var _a;
|
|
2545
|
-
this.amount = response.data.
|
|
2535
|
+
this.amount = response.data.base_currency_price.amount;
|
|
2536
|
+
this.currency = response.data.base_currency_price.currency;
|
|
2546
2537
|
this.isRequireShipping = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.is_require_shipping) || false;
|
|
2547
2538
|
}).catch((error) => {
|
|
2548
2539
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, get the product details failed: ', error);
|
|
@@ -2550,11 +2541,13 @@ const SallaQuickBuy = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
2550
2541
|
});
|
|
2551
2542
|
}
|
|
2552
2543
|
if (salla.url.is_page('product.single')) {
|
|
2553
|
-
salla.product.event.onPriceUpdated(response =>
|
|
2544
|
+
salla.product.event.onPriceUpdated(response => {
|
|
2545
|
+
this.amount = response.data.base_currency_price.amount;
|
|
2546
|
+
this.currency = response.data.base_currency_price.currency;
|
|
2547
|
+
});
|
|
2554
2548
|
}
|
|
2555
2549
|
this.isApplePayActive = ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePayments())
|
|
2556
|
-
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'))
|
|
2557
|
-
&& salla.config.get('user.currency_code') === 'SAR';
|
|
2550
|
+
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'));
|
|
2558
2551
|
let applePaySdk = document.getElementById('apple-pay-sdk');
|
|
2559
2552
|
if (applePaySdk || !this.isApplePayActive) {
|
|
2560
2553
|
salla.logger.warn('🍏 Pay: Skipped load apple pay because ' + (applePaySdk ? 'already loaded' : 'is not available in the browser'));
|
|
@@ -84,6 +84,9 @@ const SallaAddProductButton = class {
|
|
|
84
84
|
}
|
|
85
85
|
return this.hostAttributes;
|
|
86
86
|
}
|
|
87
|
+
getQuickBuyBtnAttributes() {
|
|
88
|
+
return Object.assign(Object.assign({}, this.getBtnAttributes()), { type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : 'buy' });
|
|
89
|
+
}
|
|
87
90
|
componentWillLoad() {
|
|
88
91
|
this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();
|
|
89
92
|
if (this.host.hasAttribute('type') && this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {
|
|
@@ -110,7 +113,7 @@ const SallaAddProductButton = class {
|
|
|
110
113
|
if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {
|
|
111
114
|
return h(Host, null, h("salla-product-availability", Object.assign({}, this.getBtnAttributes()), h("span", { class: "s-hidden" }, h("slot", null))));
|
|
112
115
|
}
|
|
113
|
-
return h(Host, { class: { 's-add-product-button-with-quick-buy': this.showQuickBuy, 's-add-product-button-with-sticky-bar': this.supportStickyBar } }, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), h("slot", null)), this.showQuickBuy ? h("salla-quick-buy", Object.assign({}, this.
|
|
116
|
+
return h(Host, { class: { 's-add-product-button-with-quick-buy': this.showQuickBuy, 's-add-product-button-with-sticky-bar': this.supportStickyBar } }, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), h("slot", null)), this.showQuickBuy ? h("salla-quick-buy", Object.assign({}, this.getQuickBuyBtnAttributes())) : '');
|
|
114
117
|
}
|
|
115
118
|
componentDidLoad() {
|
|
116
119
|
if (!this.notifyOptionsAvailability) {
|
|
@@ -140,7 +143,7 @@ const SallaAddProductButton = class {
|
|
|
140
143
|
componentDidRender() {
|
|
141
144
|
var _a;
|
|
142
145
|
//if label not passed, get label
|
|
143
|
-
if (!!this.passedLabel &&
|
|
146
|
+
if (!!this.passedLabel && !this.supportStickyBar) {
|
|
144
147
|
return;
|
|
145
148
|
}
|
|
146
149
|
(_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(this.getLabel());
|
|
@@ -25994,16 +25994,9 @@ const SallaQuickBuy = class {
|
|
|
25994
25994
|
* Button type.
|
|
25995
25995
|
*
|
|
25996
25996
|
* @type {string}
|
|
25997
|
-
* @default
|
|
25997
|
+
* @default buy
|
|
25998
25998
|
**/
|
|
25999
25999
|
this.type = 'buy';
|
|
26000
|
-
/**
|
|
26001
|
-
* Product amount.
|
|
26002
|
-
*
|
|
26003
|
-
* @type {number}
|
|
26004
|
-
* @default 0
|
|
26005
|
-
**/
|
|
26006
|
-
this.amount = 0;
|
|
26007
26000
|
/**
|
|
26008
26001
|
* Product options, if is empty will get the data from the document.querySelector('salla-product-options[product-id="X"]')
|
|
26009
26002
|
*
|
|
@@ -26047,7 +26040,7 @@ const SallaQuickBuy = class {
|
|
|
26047
26040
|
// noinspection TypeScriptValidateJSTypes
|
|
26048
26041
|
salla.event.dispatch('payments::apple-pay.start-transaction', {
|
|
26049
26042
|
amount: this.amount,
|
|
26050
|
-
currency: this.currency,
|
|
26043
|
+
currency: this.currency || 'SAR',
|
|
26051
26044
|
requiredShippingContactFields: this.isRequireShipping ? ['postalAddress'] : null,
|
|
26052
26045
|
shippingMethods: this.isRequireShipping ? [] : null,
|
|
26053
26046
|
supportedNetworks: salla.config.get('store.settings.buy_now.networks'),
|
|
@@ -26106,16 +26099,13 @@ const SallaQuickBuy = class {
|
|
|
26106
26099
|
componentWillLoad() {
|
|
26107
26100
|
return new Promise((resolve, reject) => {
|
|
26108
26101
|
salla.onReady(async () => {
|
|
26102
|
+
// if (!this.currency) {
|
|
26103
|
+
// this.currency = salla.config.get('user.currency_code');
|
|
26104
|
+
// }
|
|
26109
26105
|
var _a, _b;
|
|
26110
|
-
if (!this.currency) {
|
|
26111
|
-
this.currency = salla.config.get('user.currency_code');
|
|
26112
|
-
}
|
|
26113
26106
|
if (!this.productId && salla.config.get('page.id')) {
|
|
26114
26107
|
this.productId = salla.config.get('page.id');
|
|
26115
26108
|
}
|
|
26116
|
-
if (window.innerWidth <= 768 && this.type !== 'plain') {
|
|
26117
|
-
this.type = 'plain';
|
|
26118
|
-
}
|
|
26119
26109
|
if (!this.productId) {
|
|
26120
26110
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, the product id is missing');
|
|
26121
26111
|
return reject();
|
|
@@ -26123,7 +26113,8 @@ const SallaQuickBuy = class {
|
|
|
26123
26113
|
if (!this.amount && this.productId) {
|
|
26124
26114
|
await salla.product.getDetails(this.productId, []).then((response) => {
|
|
26125
26115
|
var _a;
|
|
26126
|
-
this.amount = response.data.
|
|
26116
|
+
this.amount = response.data.base_currency_price.amount;
|
|
26117
|
+
this.currency = response.data.base_currency_price.currency;
|
|
26127
26118
|
this.isRequireShipping = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.is_require_shipping) || false;
|
|
26128
26119
|
}).catch((error) => {
|
|
26129
26120
|
salla.logger.warn('🍏 Pay: Failed load the quick buy, get the product details failed: ', error);
|
|
@@ -26131,11 +26122,13 @@ const SallaQuickBuy = class {
|
|
|
26131
26122
|
});
|
|
26132
26123
|
}
|
|
26133
26124
|
if (salla.url.is_page('product.single')) {
|
|
26134
|
-
salla.product.event.onPriceUpdated(response =>
|
|
26125
|
+
salla.product.event.onPriceUpdated(response => {
|
|
26126
|
+
this.amount = response.data.base_currency_price.amount;
|
|
26127
|
+
this.currency = response.data.base_currency_price.currency;
|
|
26128
|
+
});
|
|
26135
26129
|
}
|
|
26136
26130
|
this.isApplePayActive = ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePayments())
|
|
26137
|
-
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'))
|
|
26138
|
-
&& salla.config.get('user.currency_code') === 'SAR';
|
|
26131
|
+
&& ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'));
|
|
26139
26132
|
let applePaySdk = document.getElementById('apple-pay-sdk');
|
|
26140
26133
|
if (applePaySdk || !this.isApplePayActive) {
|
|
26141
26134
|
salla.logger.warn('🍏 Pay: Skipped load apple pay because ' + (applePaySdk ? 'already loaded' : 'is not available in the browser'));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,e,i,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,i,s){function n(t){return t instanceof i?t:new i((function(e){e(t)}))}return new(i||(i=Promise))((function(i,o){function r(t){try{u(s.next(t))}catch(t){o(t)}}function a(t){try{u(s["throw"](t))}catch(t){o(t)}}function u(t){t.done?i(t.value):n(t.value).then(r,a)}u((s=s.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,r;return r={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function a(t){return function(e){return u([t,e])}}function u(r){if(s)throw new TypeError("Generator is already executing.");while(i)try{if(s=1,n&&(o=r[0]&2?n["return"]:r[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,r[1])).done)return o;if(n=0,o)r=[r[0]&2,o.value];switch(r[0]){case 0:case 1:o=r;break;case 4:i.label++;return{value:r[1],done:false};case 5:i.label++;n=r[1];r=[0];continue;case 7:r=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(r[0]===6||r[0]===2)){i=0;continue}if(r[0]===3&&(!o||r[1]>o[0]&&r[1]<o[3])){i.label=r[1];break}if(r[0]===6&&i.label<o[1]){i.label=o[1];o=r;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(r);break}if(o[2])i.ops.pop();i.trys.pop();continue}r=e.call(t,i)}catch(t){r=[6,t];n=0}finally{s=o=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};
|
|
2
2
|
/*!
|
|
3
3
|
* Crafted with ❤ by Salla
|
|
4
|
-
*/import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-f1d446ac.js";import{C as Cart}from"./cart-8c60b447.js";var sallaAddProductButtonCss=":host{display:block}salla-add-product-button[width=wide]{width:100%}";var SallaAddProductButton=function(){function t(t){var e=this;registerInstance(this,t);this.success=createEvent(this,"success",7);this.failed=createEvent(this,"failed",7);this.hostAttributes={};this.productStatus="sale";this.productType="product";this.selectedOptions=[];salla.onReady((function(){e.showQuickBuy=e.quickBuy&&!!salla.config.get("store.settings.buy_now")}))}t.prototype.getLabel=function(){if(this.productStatus==="sale"){if(this.supportStickyBar&&window.innerWidth<=768){return Cart}return salla.lang.get("pages.cart.add_to_cart")}if(this.productType!=="donating"){return salla.lang.get("pages.products.out_of_stock")}return salla.lang.get("pages.products.donation_exceed")};t.prototype.addProductToCart=function(t){var e=this;if(this.productType==="booking"){t.preventDefault();return this.addBookingProduct()}if(this.hostAttributes.type==="submit"){return false}t.preventDefault();var i=Object.entries({id:this.productId,donating_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd"}).reduce((function(t,e){var i=e[0],
|
|
4
|
+
*/import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-f1d446ac.js";import{C as Cart}from"./cart-8c60b447.js";var sallaAddProductButtonCss=":host{display:block}salla-add-product-button[width=wide]{width:100%}";var SallaAddProductButton=function(){function t(t){var e=this;registerInstance(this,t);this.success=createEvent(this,"success",7);this.failed=createEvent(this,"failed",7);this.hostAttributes={};this.productStatus="sale";this.productType="product";this.selectedOptions=[];salla.onReady((function(){e.showQuickBuy=e.quickBuy&&!!salla.config.get("store.settings.buy_now")}))}t.prototype.getLabel=function(){if(this.productStatus==="sale"){if(this.supportStickyBar&&window.innerWidth<=768){return Cart}return salla.lang.get("pages.cart.add_to_cart")}if(this.productType!=="donating"){return salla.lang.get("pages.products.out_of_stock")}return salla.lang.get("pages.products.donation_exceed")};t.prototype.addProductToCart=function(t){var e=this;if(this.productType==="booking"){t.preventDefault();return this.addBookingProduct()}if(this.hostAttributes.type==="submit"){return false}t.preventDefault();var i=Object.entries({id:this.productId,donating_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd"}).reduce((function(t,e){var i=e[0],s=e[1];return s?(t[i]=s,t):t}),{});return salla.cart.addItem(i).then((function(t){e.selectedOptions=[];e.success.emit(t)})).catch((function(t){return e.failed.emit(t)}))};t.prototype.addBookingProduct=function(){var t=this;if(salla.config.isGuest()){salla.auth.api.setAfterLoginEvent("booking::add",this.productId);salla.event.dispatch("login::open");return}return salla.booking.add(this.productId).then((function(e){return t.success.emit(e)})).catch((function(e){return t.failed.emit(e)}))};t.prototype.getBtnAttributes=function(){for(var t=0;t<this.host.attributes.length;t++){if(!["id","class"].includes(this.host.attributes[t].name)){this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value}}return this.hostAttributes};t.prototype.getQuickBuyBtnAttributes=function(){return Object.assign(Object.assign({},this.getBtnAttributes()),{type:this.supportStickyBar&&window.innerWidth<=768?"plain":"buy"})};t.prototype.componentWillLoad=function(){var t=this;this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim();if(this.host.hasAttribute("type")&&this.host.getAttribute("type")==="submit"&&this.supportStickyBar){window.addEventListener("resize",(function(){var e,i;if(window.innerWidth>=768&&!!t.passedLabel){(e=t.btn)===null||e===void 0?void 0:e.setText(t.passedLabel)}else{(i=t.btn)===null||i===void 0?void 0:i.setText(t.getLabel())}}))}};t.prototype.render=function(){var t=this;var e;if((e=this.host.closest(".swiper-slide"))===null||e===void 0?void 0:e.classList.contains("swiper-slide-duplicate")){return""}if(this.hasSubscribedOptions){return h(Host,null,h("salla-product-availability",Object.assign({},this.getBtnAttributes(),{"is-subscribed":true}),h("span",{class:"s-hidden"},h("slot",null))))}if(this.productStatus==="out-and-notify"&&this.channels||this.hasOutOfStockOption){return h(Host,null,h("salla-product-availability",Object.assign({},this.getBtnAttributes()),h("span",{class:"s-hidden"},h("slot",null))))}return h(Host,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar}},h("salla-button",Object.assign({color:this.productStatus==="sale"?"primary":"light",type:"button",fill:this.productStatus==="sale"?"solid":"outline",ref:function(e){return t.btn=e},onClick:function(e){return t.addProductToCart(e)},disabled:this.productStatus!=="sale"},this.getBtnAttributes(),{"loader-position":"center"}),h("slot",null)),this.showQuickBuy?h("salla-quick-buy",Object.assign({},this.getQuickBuyBtnAttributes())):"")};t.prototype.componentDidLoad=function(){var t=this;if(!this.notifyOptionsAvailability){return}salla.event.on("product-options::change",(function(e){return __awaiter(t,void 0,void 0,(function(){var t,i,s,n,o,r;var a=this;return __generator(this,(function(u){switch(u.label){case 0:if(!["thumbnail","color","single-option"].includes(e.option.type)){return[2]}this.hasSubscribedOptions=false;s=this;return[4,(t=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||t===void 0?void 0:t.getSelectedOptions()];case 1:s.selectedOptions=u.sent();n=this;return[4,(i=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||i===void 0?void 0:i.hasOutOfStockOption()];case 2:n.hasOutOfStockOption=u.sent();o=salla.storage.get("product-".concat(this.productId,"-subscribed-options"));if(!o&&!this.subscribedOptions||!this.hasOutOfStockOption){return[2]}if(salla.config.isGuest()){r=o?o.map((function(t){return t.split(",").map((function(t){return parseInt(t)}))})):[];this.hasSubscribedOptions=r.length>0&&r.some((function(t){return t.every((function(t){return a.selectedOptions.some((function(e){return e.id===t}))}))}))}else{this.hasSubscribedOptions=this.subscribedOptions&&this.subscribedOptions!=="null"&&this.subscribedOptions!=="[]"?JSON.parse(this.subscribedOptions).some((function(t){return t.every((function(t){return a.selectedOptions.some((function(e){return e.id===t}))}))})):false}return[2]}}))}))}))};t.prototype.componentDidRender=function(){var t=this;var e;if(!!this.passedLabel&&!this.supportStickyBar){return}(e=this.btn)===null||e===void 0?void 0:e.setText(this.getLabel());salla.lang.onLoaded((function(){var e;return(e=t.btn)===null||e===void 0?void 0:e.setText(t.getLabel())}))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaAddProductButton.style=sallaAddProductButtonCss;export{SallaAddProductButton as salla_add_product_button};
|