@salla.sa/twilight-components 1.0.72 → 1.0.73
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/loader.cjs.js +1 -1
- package/dist/cjs/{salla-tel-input.cjs.entry.js → salla-add-product-button_6.cjs.entry.js} +519 -0
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.css +3 -0
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +230 -0
- package/dist/collection/components/salla-button/salla-button.css +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +1 -1
- package/dist/collection/components/salla-product-availability/salla-product-availability.css +1 -1
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +5 -3
- package/dist/components/salla-add-product-button.d.ts +11 -0
- package/dist/components/salla-add-product-button.js +121 -0
- package/dist/components/salla-button2.js +1 -1
- package/dist/components/salla-login-modal.js +1 -1
- package/dist/components/salla-product-availability.js +1 -155
- package/dist/{esm/salla-product-availability.entry.js → components/salla-product-availability2.js} +59 -12
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{salla-tel-input.entry.js → salla-add-product-button_6.entry.js} +515 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/{p-44b84f44.entry.js → p-20a8492d.entry.js} +1 -1
- package/dist/twilight-components/p-a970ba23.entry.js +4 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-add-product-button/salla-add-product-button.d.ts +25 -0
- package/dist/types/components.d.ts +35 -0
- package/package.json +1 -1
- package/dist/cjs/salla-button.cjs.entry.js +0 -122
- package/dist/cjs/salla-modal_2.cjs.entry.js +0 -239
- package/dist/cjs/salla-product-availability.cjs.entry.js +0 -119
- package/dist/esm/salla-button.entry.js +0 -118
- package/dist/esm/salla-modal_2.entry.js +0 -234
- package/dist/twilight-components/p-3aabd1b6.entry.js +0 -4
- package/dist/twilight-components/p-960c050e.entry.js +0 -4
- package/dist/twilight-components/p-c3b196f3.entry.js +0 -4
- package/dist/twilight-components/p-ca4cf691.entry.js +0 -4
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
|
-
|
|
8
|
-
const index = require('./index-c0f5bb97.js');
|
|
9
|
-
const Helper = require('./Helper-8ae6a805.js');
|
|
10
|
-
|
|
11
|
-
const sallaModalCss = "";
|
|
12
|
-
|
|
13
|
-
const SallaModal = class {
|
|
14
|
-
constructor(hostRef) {
|
|
15
|
-
index.registerInstance(this, hostRef);
|
|
16
|
-
this.modalOpened = index.createEvent(this, "modalOpened", 7);
|
|
17
|
-
this.modalClosed = index.createEvent(this, "modalClosed", 7);
|
|
18
|
-
this.isClosable = true; //todo::rename unclude
|
|
19
|
-
/**
|
|
20
|
-
* The size of the modal
|
|
21
|
-
*/
|
|
22
|
-
this.width = 'md';
|
|
23
|
-
/**
|
|
24
|
-
* The position of the modal
|
|
25
|
-
*/
|
|
26
|
-
this.position = 'middle';
|
|
27
|
-
/**
|
|
28
|
-
* Show the modal on rendering
|
|
29
|
-
*/
|
|
30
|
-
this.visible = false;
|
|
31
|
-
/**
|
|
32
|
-
* Show loading in the middle
|
|
33
|
-
*/
|
|
34
|
-
this.isLoading = false;
|
|
35
|
-
this.subTitleFirst = false; //todo:: choose better name
|
|
36
|
-
this.noPadding = false; //todo:: choose better name
|
|
37
|
-
this.subTitle = '';
|
|
38
|
-
/**
|
|
39
|
-
* Icon css class, default for types `error` is `sicon-alert-engine`, `success` is `sicon-check-circle2`
|
|
40
|
-
*/
|
|
41
|
-
this.icon = '';
|
|
42
|
-
this.iconStyle = '';
|
|
43
|
-
/**
|
|
44
|
-
* url of an image
|
|
45
|
-
*/
|
|
46
|
-
this.imageIcon = '';
|
|
47
|
-
Helper.Helper.setHost(this.host);
|
|
48
|
-
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
|
|
49
|
-
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
|
|
50
|
-
this.modalTitle = this.host.getAttribute('modal-title');
|
|
51
|
-
}
|
|
52
|
-
handleVisible(newValue) {
|
|
53
|
-
if (!newValue) {
|
|
54
|
-
this.toggleModal(false);
|
|
55
|
-
this.modalClosed.emit();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.host.classList.remove('s-hidden');
|
|
59
|
-
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
60
|
-
this.modalOpened.emit();
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Show the modal
|
|
64
|
-
*/
|
|
65
|
-
async show() {
|
|
66
|
-
this.host.setAttribute('visible', '');
|
|
67
|
-
return this.host;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* hide the modal
|
|
71
|
-
*/
|
|
72
|
-
async hide() {
|
|
73
|
-
this.host.removeAttribute('visible');
|
|
74
|
-
return this.host;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Change the Modal Title
|
|
78
|
-
* @param {string} modalTitle
|
|
79
|
-
*/
|
|
80
|
-
async setTitle(modalTitle) {
|
|
81
|
-
this.modalTitle = modalTitle;
|
|
82
|
-
return this.host;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Start loading
|
|
86
|
-
*/
|
|
87
|
-
async loading() {
|
|
88
|
-
this.isLoading = true;
|
|
89
|
-
return this.host;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Stop the loading
|
|
93
|
-
*/
|
|
94
|
-
async stopLoading() {
|
|
95
|
-
this.isLoading = false;
|
|
96
|
-
return this.host;
|
|
97
|
-
}
|
|
98
|
-
toggleModal(isOpen) {
|
|
99
|
-
const body = this.host.querySelector('.s-modal-body');
|
|
100
|
-
Helper.Helper.toggleElementClassIf(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
101
|
-
.toggleElementClassIf(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
102
|
-
.toggleElementClassIf(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
103
|
-
if (!isOpen) {
|
|
104
|
-
setTimeout(() => this.host.classList.add('s-hidden'), 350);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
closeModal() {
|
|
108
|
-
if (!this.isClosable) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this.host.removeAttribute('visible');
|
|
112
|
-
}
|
|
113
|
-
iconBlockClasses() {
|
|
114
|
-
return {
|
|
115
|
-
's-modal-icon': true,
|
|
116
|
-
's-modal-bg-error': this.iconStyle == 'error',
|
|
117
|
-
's-modal-bg-success': this.iconStyle == 'success',
|
|
118
|
-
's-modal-bg-normal': this.iconStyle != 'error' && this.iconStyle != 'success',
|
|
119
|
-
's-modal-bg-primary': this.iconStyle == 'primary'
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
iconClasses() {
|
|
123
|
-
return {
|
|
124
|
-
[this.icon]: true,
|
|
125
|
-
'sicon-alert-engine': !this.icon && this.iconStyle == 'error' && !this.imageIcon,
|
|
126
|
-
'sicon-check-circle2': !this.icon && this.iconStyle == 'success' && !this.imageIcon,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//todo:: pref for each modal
|
|
130
|
-
render() {
|
|
131
|
-
this.host.id = this.host.id || 'salla-modal';
|
|
132
|
-
return (index.h(index.Host, { class: 'salla-modal s-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("div", { class: "s-modal-wrapper" }, index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, this.isLoading ?
|
|
133
|
-
index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
|
|
134
|
-
:
|
|
135
|
-
[
|
|
136
|
-
index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
137
|
-
index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
|
|
138
|
-
: '', this.modalTitle || this.subTitle ?
|
|
139
|
-
index.h("div", { class: "s-modal-header-inner" }, this.iconStyle || this.icon
|
|
140
|
-
? index.h("div", { class: this.iconBlockClasses() }, index.h("i", { class: this.iconClasses() }))
|
|
141
|
-
: this.imageIcon ? index.h("img", { class: "s-modal-header-img", src: this.imageIcon }) : '', index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.modalTitle }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
|
|
142
|
-
: ''),
|
|
143
|
-
index.h("slot", null),
|
|
144
|
-
index.h("slot", { name: "footer" })
|
|
145
|
-
]))));
|
|
146
|
-
}
|
|
147
|
-
get host() { return index.getElement(this); }
|
|
148
|
-
static get watchers() { return {
|
|
149
|
-
"visible": ["handleVisible"]
|
|
150
|
-
}; }
|
|
151
|
-
};
|
|
152
|
-
SallaModal.style = sallaModalCss;
|
|
153
|
-
|
|
154
|
-
const sallaSearchCss = "#s-search-modal .s-search-inline{border:1px solid #eee}#s-search-modal .s-search-no-results .s-search-input,#s-search-modal .s-search-container-open .s-search-input{border-bottom:1px solid #f4f4f5}#s-search-modal .s-search-product-image{font-size:0;position:relative}#s-search-modal .s-search-product-image:before{content:\"\";position:absolute;width:100%;height:100%;left:0;top:0;background:#eee}#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem;background:transparent;overflow:visible}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";
|
|
155
|
-
|
|
156
|
-
const SallaSearch = class {
|
|
157
|
-
constructor(hostRef) {
|
|
158
|
-
index.registerInstance(this, hostRef);
|
|
159
|
-
var _a;
|
|
160
|
-
this.inputValue = '';
|
|
161
|
-
this.inline = false;
|
|
162
|
-
this.oval = false;
|
|
163
|
-
this.height = 60;
|
|
164
|
-
Helper.Helper.setHost(this.host);
|
|
165
|
-
this.productSlot = ((_a = Helper.Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
|
|
166
|
-
salla.event.on('search::show', () => this.modal.show());
|
|
167
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
168
|
-
this.placeholder = salla.lang.get('blocks.header.search_placeholder');
|
|
169
|
-
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
onModalOpen() {
|
|
173
|
-
this.modal.querySelector('.s-search-input').focus();
|
|
174
|
-
}
|
|
175
|
-
onModalClose() {
|
|
176
|
-
this.modal.querySelector('.s-search-input').value = '';
|
|
177
|
-
this.results = undefined;
|
|
178
|
-
this.afterSearching();
|
|
179
|
-
this.container.classList.remove('s-search-no-results');
|
|
180
|
-
}
|
|
181
|
-
getDefaultProductSlot() {
|
|
182
|
-
return '<div class="s-search-product-image-container">' +
|
|
183
|
-
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
184
|
-
'</div>' +
|
|
185
|
-
'<div class="s-search-product-details">' +
|
|
186
|
-
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div>' +
|
|
187
|
-
'</div>';
|
|
188
|
-
}
|
|
189
|
-
search(e) {
|
|
190
|
-
this.inputValue = e.target.value;
|
|
191
|
-
Helper.Helper.hideElement(this.noResults);
|
|
192
|
-
if (e.target.value.length === 0) {
|
|
193
|
-
this.results = undefined;
|
|
194
|
-
this.afterSearching();
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
if (e.target.value.length <= 2) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
//run loading spinner or stop it
|
|
201
|
-
Helper.Helper.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
|
|
202
|
-
salla.search.api.products(e.target.value)
|
|
203
|
-
.then(response => this.results = response)
|
|
204
|
-
.catch(err => err !== 'Query is same as previous one!' ? this.results = undefined : null)
|
|
205
|
-
.finally(() => this.afterSearching(/*isEmpty*/ false));
|
|
206
|
-
}
|
|
207
|
-
afterSearching(isEmpty = true) {
|
|
208
|
-
var _a;
|
|
209
|
-
this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
|
|
210
|
-
Helper.Helper.toggleElementClassIf(this.container, 's-search-container-open', 's-search-no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
|
|
211
|
-
.toggleElementClassIf(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
|
|
212
|
-
salla.search.api.previousQuery = ''; //avoid having error 'Query is same as previous one!' after reopen modal;
|
|
213
|
-
this.inputValue.length == 0 ? this.container.classList.remove('s-search-no-results') : '';
|
|
214
|
-
}
|
|
215
|
-
render() {
|
|
216
|
-
var _a;
|
|
217
|
-
const searchContent = index.h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), index.h("span", { class: "s-search-icon-wrap" }, index.h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
218
|
-
_a.data.map(item => index.h("a", { href: item.url, class: { "s-search-product": true, 's-search-product-not-available': !item.is_available }, innerHTML: this.productSlot
|
|
219
|
-
.replace(/\{name\}/g, item.name)
|
|
220
|
-
.replace(/\{price\}/g, salla.money(item.price))
|
|
221
|
-
.replace(/\{regular_price\}/g, item.has_special_price ? salla.money(item.regular_price) : '')
|
|
222
|
-
.replace(/\{image\}/g, item.thumbnail) })), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
|
|
223
|
-
return (this.inline ?
|
|
224
|
-
index.h("div", { id: "s-search-modal" }, searchContent)
|
|
225
|
-
:
|
|
226
|
-
index.h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, searchContent));
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Run it one time after load
|
|
230
|
-
*/
|
|
231
|
-
componentDidLoad() {
|
|
232
|
-
this.afterSearching();
|
|
233
|
-
}
|
|
234
|
-
get host() { return index.getElement(this); }
|
|
235
|
-
};
|
|
236
|
-
SallaSearch.style = sallaSearchCss;
|
|
237
|
-
|
|
238
|
-
exports.salla_modal = SallaModal;
|
|
239
|
-
exports.salla_search = SallaSearch;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
|
-
|
|
8
|
-
const index = require('./index-c0f5bb97.js');
|
|
9
|
-
const Helper = require('./Helper-8ae6a805.js');
|
|
10
|
-
|
|
11
|
-
const sallaProductAvailabilityCss = "";
|
|
12
|
-
|
|
13
|
-
const SallaProductAvailability = class {
|
|
14
|
-
constructor(hostRef) {
|
|
15
|
-
index.registerInstance(this, hostRef);
|
|
16
|
-
this.isUser = Helper.Helper.isUser();
|
|
17
|
-
/**
|
|
18
|
-
* product id that can visitor subscribe to its availability notification
|
|
19
|
-
*/
|
|
20
|
-
this.productId = salla.config.get('page.id');
|
|
21
|
-
/**
|
|
22
|
-
* is current user already subscribed
|
|
23
|
-
*/
|
|
24
|
-
this.isSubscribed = false;
|
|
25
|
-
// @Method()
|
|
26
|
-
this.submit = async () => {
|
|
27
|
-
if (this.isUser) {
|
|
28
|
-
return salla.api.product.availabilitySubscribe(this.productId)
|
|
29
|
-
.then(() => this.isSubscribed = true);
|
|
30
|
-
}
|
|
31
|
-
let { mobile, countryCode } = await this.mobileInput.getValues(), data = { id: this.productId, country_code: countryCode };
|
|
32
|
-
mobile !== '' && (data['mobile'] = mobile);
|
|
33
|
-
this.email.value !== '' && (data['email'] = this.email.value);
|
|
34
|
-
await this.validateform();
|
|
35
|
-
return this.btn.load()
|
|
36
|
-
.then(() => this.btn.disable())
|
|
37
|
-
.then(() => salla.api.product.availabilitySubscribe(data))
|
|
38
|
-
.then(() => {
|
|
39
|
-
this.isSubscribed = true;
|
|
40
|
-
salla.storage.set(`product-${this.productId}-subscribed`, true);
|
|
41
|
-
}) //no need to wait until finishing alert animation
|
|
42
|
-
.then(() => this.btn.stop())
|
|
43
|
-
.then(() => this.modal.hide())
|
|
44
|
-
.catch(() => this.btn.stop() && this.btn.enable());
|
|
45
|
-
};
|
|
46
|
-
// helpers
|
|
47
|
-
this.typing = (e, submitMethod) => {
|
|
48
|
-
const error = e.target.nextElementSibling;
|
|
49
|
-
e.target.classList.remove('s-has-error');
|
|
50
|
-
(error === null || error === void 0 ? void 0 : error.classList.contains('s-product-availability-error-msg')) && (error.innerText = '');
|
|
51
|
-
e.key == 'Enter' && submitMethod();
|
|
52
|
-
};
|
|
53
|
-
salla.event.on('languages::translations.loaded', () => {
|
|
54
|
-
var _a, _b, _c, _d;
|
|
55
|
-
// console.log('translations:', salla.lang);
|
|
56
|
-
this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
|
|
57
|
-
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
58
|
-
this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
|
|
59
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
60
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
61
|
-
this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
|
|
62
|
-
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
63
|
-
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
|
|
64
|
-
(_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('common.elements.submit'));
|
|
65
|
-
(_c = this.cancelBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('common.elements.cancel'));
|
|
66
|
-
(_d = this.inlineBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('pages.products.notify_availability'));
|
|
67
|
-
});
|
|
68
|
-
if (this.isUser)
|
|
69
|
-
return;
|
|
70
|
-
this.channelsWatcher(this.channels);
|
|
71
|
-
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
72
|
-
this.host.removeAttribute('title');
|
|
73
|
-
this.isVisitorSubscribed = salla.storage.get(`product-${this.productId}-subscribed`);
|
|
74
|
-
}
|
|
75
|
-
channelsWatcher(newValue) {
|
|
76
|
-
this.channels_ = newValue.split(',');
|
|
77
|
-
}
|
|
78
|
-
async validateform() {
|
|
79
|
-
if (this.channels_.includes('email')) {
|
|
80
|
-
const isEmailValid = Helper.Helper.isValidEmail(this.email.value);
|
|
81
|
-
if (isEmailValid)
|
|
82
|
-
return;
|
|
83
|
-
!isEmailValid && this.validateField(this.email, this.emailErrorMsg);
|
|
84
|
-
}
|
|
85
|
-
if (this.channels_.includes('sms')) {
|
|
86
|
-
const isPhoneValid = await this.mobileInput.isValid();
|
|
87
|
-
if (isPhoneValid)
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
throw ('Please insert required fields');
|
|
91
|
-
}
|
|
92
|
-
validateField(field, errorMsg) {
|
|
93
|
-
field.classList.add('s-has-error');
|
|
94
|
-
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
95
|
-
}
|
|
96
|
-
render() {
|
|
97
|
-
return (index.h(index.Host, { id: "s-product-availability" }, this.isSubscribed || this.isVisitorSubscribed
|
|
98
|
-
? index.h("div", { class: "s-product-availability-subscribed" }, index.h("i", { class: "sicon-bell-ring s-product-availability-subs-icon" }), " ", this.subscribedMessage)
|
|
99
|
-
:
|
|
100
|
-
index.h("salla-button", { width: "wide", onClick: () => this.isUser ? this.submit() : this.modal.show(), ref: btn => this.inlineBtn = btn }, salla.lang.get('pages.products.notify_availability')), this.isUser || this.isSubscribed || this.isVisitorSubscribed ? '' : this.renderModal()));
|
|
101
|
-
}
|
|
102
|
-
renderModal() {
|
|
103
|
-
return (index.h("salla-modal", { ref: modal => this.modal = modal, "modal-title": this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", width: "sm" }, index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
|
|
104
|
-
index.h("label", { class: "s-product-availability-label" }, this.emailLabel),
|
|
105
|
-
index.h("input", { class: "s-product-availability-input", onKeyDown: e => this.typing(e, this.submit), placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" }),
|
|
106
|
-
index.h("span", { class: "s-product-availability-error-msg" })
|
|
107
|
-
] : '', this.channels_.includes('sms') ? [
|
|
108
|
-
index.h("label", { class: "s-product-availability-label" }, this.mobileLabel),
|
|
109
|
-
index.h("salla-tel-input", { ref: el => this.mobileInput = el, onKeyDown: e => this.typing(e, this.submit) })
|
|
110
|
-
] : ''), index.h("div", { slot: "footer", class: "s-product-availability-footer" }, index.h("salla-button", { width: "wide", color: "light", fill: "outline", onClick: () => this.modal.hide(), ref: btn => this.cancelBtn = btn }, salla.lang.get('common.elements.cancel')), index.h("salla-button", { "loader-position": 'center', width: "wide", ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.submit')))));
|
|
111
|
-
}
|
|
112
|
-
get host() { return index.getElement(this); }
|
|
113
|
-
static get watchers() { return {
|
|
114
|
-
"channels": ["channelsWatcher"]
|
|
115
|
-
}; }
|
|
116
|
-
};
|
|
117
|
-
SallaProductAvailability.style = sallaProductAvailabilityCss;
|
|
118
|
-
|
|
119
|
-
exports.salla_product_availability = SallaProductAvailability;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import { r as registerInstance, h, H as Host, g as getElement } from './index-a1271335.js';
|
|
5
|
-
|
|
6
|
-
const sallaButtonCss = "salla-button{pointer-events:none}salla-button[type=submit]{-webkit-appearance:none}salla-button[width=wide]{width:100%}.s-button-wrap[loading]{pointer-events:none}.s-button-wrap[loading] .s-button-element{pointer-events:none !important}.s-button-wrap[loading] .s-button-loader-center .s-button-text{opacity:0}.s-button-wrap .s-button-element[loading]{pointer-events:none !important}.s-button-wrap .s-button-element:not(:disabled){pointer-events:auto}.s-button-wrap .s-button-solid .s-button-loader:before{border-color:#fff #fff rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.2)}.s-button-wrap .s-button-outline{border:1px solid currentColor}.s-button-wrap .s-button-outline:hover{border-color:transparent}.s-button-wrap .s-button-outline .s-button-loader:before{border-top-color:currentColor;border-left-color:currentColor}.s-button-wrap .s-button-icon.s-button-large{width:56px;height:56px}.s-button-wrap .s-button-icon.s-button-small{width:24px;height:24px}.s-button-wrap .s-button-icon.s-button-small .s-button-loader:before{width:0.85rem;height:0.85rem}.s-button-wrap .s-button-loader-after .s-button-load{flex-direction:row}.s-button-wrap .s-button-loader-start.s-button-element{padding-left:32px;padding-right:32px}.s-button-wrap .s-button-loader-start .s-button-loader{position:absolute;right:8px}.s-button-wrap .s-button-loader-start .s-button-loader [dir=ltr]{left:8px;right:auto}.s-button-wrap .s-button-loader-end.s-button-element{padding-left:32px;padding-right:32px}.s-button-wrap .s-button-loader-end .s-button-loader{position:absolute;left:8px}.s-button-wrap .s-button-loader-end .s-button-loader [dir=ltr]{right:8px;left:auto}.s-button-wrap .s-button-loader-center .s-button-loader{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);margin:0 !important}";
|
|
7
|
-
|
|
8
|
-
const SallaButton = class {
|
|
9
|
-
constructor(hostRef) {
|
|
10
|
-
registerInstance(this, hostRef);
|
|
11
|
-
this.hostAttributes = {};
|
|
12
|
-
/**
|
|
13
|
-
* Button Type
|
|
14
|
-
*/
|
|
15
|
-
this.shape = 'btn';
|
|
16
|
-
/**
|
|
17
|
-
* Button Color
|
|
18
|
-
*/
|
|
19
|
-
this.color = 'primary';
|
|
20
|
-
/**
|
|
21
|
-
* Button Fill
|
|
22
|
-
*/
|
|
23
|
-
this.fill = 'solid';
|
|
24
|
-
/**
|
|
25
|
-
* Button Size
|
|
26
|
-
*/
|
|
27
|
-
this.size = 'medium';
|
|
28
|
-
/**
|
|
29
|
-
* Button Width
|
|
30
|
-
*/
|
|
31
|
-
this.width = 'normal';
|
|
32
|
-
/**
|
|
33
|
-
* Is the button currently loading
|
|
34
|
-
*/
|
|
35
|
-
this.loading = false;
|
|
36
|
-
/**
|
|
37
|
-
* Is the button currently disabled
|
|
38
|
-
*/
|
|
39
|
-
this.disabled = false;
|
|
40
|
-
/**
|
|
41
|
-
* If there is need to change loader position, pass the position
|
|
42
|
-
*/
|
|
43
|
-
this.loaderPosition = 'after';
|
|
44
|
-
/**
|
|
45
|
-
* Is the button wide
|
|
46
|
-
*/
|
|
47
|
-
this.wide = false;
|
|
48
|
-
if (this.wide) {
|
|
49
|
-
this.host.classList.add('s-button-wide');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Run loading animation
|
|
54
|
-
*/
|
|
55
|
-
async load() {
|
|
56
|
-
if (this.loaderPosition == 'center')
|
|
57
|
-
this.text.classList.add('s-button-hide');
|
|
58
|
-
this.host.setAttribute('loading', '');
|
|
59
|
-
return this.host;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Stop loading animation
|
|
63
|
-
*/
|
|
64
|
-
async stop() {
|
|
65
|
-
this.host.removeAttribute('loading');
|
|
66
|
-
if (this.loaderPosition == 'center')
|
|
67
|
-
this.text.classList.remove('s-button-hide');
|
|
68
|
-
return this.host;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Changing the body of the button
|
|
72
|
-
* @param html
|
|
73
|
-
*/
|
|
74
|
-
async setText(html) {
|
|
75
|
-
this.text.innerHTML = html;
|
|
76
|
-
return this.host;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Add `disabled` attribute
|
|
80
|
-
*/
|
|
81
|
-
async disable() {
|
|
82
|
-
this.host.setAttribute('disabled', '');
|
|
83
|
-
return this.host;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Remove `disabled` attribute
|
|
87
|
-
*/
|
|
88
|
-
async enable() {
|
|
89
|
-
this.host.removeAttribute('disabled');
|
|
90
|
-
return this.host;
|
|
91
|
-
}
|
|
92
|
-
getBtnAttributes() {
|
|
93
|
-
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
94
|
-
if (!['color', 'fill', 'size', 'width', 'id', 'loading'].includes(this.host.attributes[i].name)) {
|
|
95
|
-
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
this.hostAttributes.type = this.hostAttributes.type || 'button';
|
|
99
|
-
this.hostAttributes.class +=
|
|
100
|
-
' s-button-element s-button-' + this.shape
|
|
101
|
-
+ ' s-button-' + (this.fill == "none" ? 'fill-none' : this.fill)
|
|
102
|
-
+ (this.size != "medium" ? ' s-button-' + this.size : '')
|
|
103
|
-
+ (this.width != "normal" ? ' s-button-' + this.width : '')
|
|
104
|
-
+ (this.shape == "link" ? ' s-button-' + this.color + '-link' : '')
|
|
105
|
-
+ (this.shape != "link" && this.fill != 'outline' ? ' s-button-' + this.color : '')
|
|
106
|
-
+ (this.fill == 'outline' ? ' s-button-' + this.color + '-outline' : '')
|
|
107
|
-
+ (this.disabled ? ' s-button-disabled ' : '')
|
|
108
|
-
+ (this.shape == 'icon' ? ' s-button-loader-center' : ' s-button-loader-' + this.loaderPosition);
|
|
109
|
-
return this.hostAttributes;
|
|
110
|
-
}
|
|
111
|
-
render() {
|
|
112
|
-
return (h(Host, { class: "s-button-wrap" }, h("button", Object.assign({}, this.getBtnAttributes(), { disabled: this.disabled }), h("span", { class: "s-button-text", ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: "s-button-loader" }) : '')));
|
|
113
|
-
}
|
|
114
|
-
get host() { return getElement(this); }
|
|
115
|
-
};
|
|
116
|
-
SallaButton.style = sallaButtonCss;
|
|
117
|
-
|
|
118
|
-
export { SallaButton as salla_button };
|