@salla.sa/twilight-components 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/cjs/Helper-fcea994c.js +23 -0
  2. package/dist/cjs/index-714023c8.js +1653 -0
  3. package/dist/cjs/index.cjs.js +13 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/salla-branches.cjs.entry.js +92 -0
  6. package/dist/cjs/salla-button_5.cjs.entry.js +1727 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +82 -0
  8. package/dist/cjs/salla-login-c438bb35.js +128 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +79 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +195 -0
  12. package/dist/cjs/salla-search-45173394.js +85 -0
  13. package/dist/cjs/salla-search.cjs.entry.js +11 -0
  14. package/dist/cjs/twilight-components.cjs.js +19 -0
  15. package/dist/collection/Helpers/Helper.js +19 -0
  16. package/dist/collection/collection-manifest.json +22 -0
  17. package/dist/collection/components/generate-summary.js +35 -0
  18. package/dist/collection/components/salla-branches/salla-branches.css +12 -0
  19. package/dist/collection/components/salla-branches/salla-branches.js +233 -0
  20. package/dist/collection/components/salla-button/salla-button.css +3 -0
  21. package/dist/collection/components/salla-button/salla-button.js +246 -0
  22. package/dist/collection/components/salla-localization/salla-localization.js +208 -0
  23. package/dist/collection/components/salla-login/salla-login.css +3 -0
  24. package/dist/collection/components/salla-login/salla-login.js +380 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +477 -0
  26. package/dist/collection/components/salla-offer/offer-schema.js +1 -0
  27. package/dist/collection/components/salla-offer/salla-offer.js +110 -0
  28. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  29. package/dist/collection/components/salla-rating/order-feedback-response.js +1 -0
  30. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  31. package/dist/collection/components/salla-rating/salla-rating.js +277 -0
  32. package/dist/collection/components/salla-search/salla-search.css +24 -0
  33. package/dist/collection/components/salla-search/salla-search.js +143 -0
  34. package/dist/collection/components/salla-tel-input/salla-tel-input.js +121 -0
  35. package/dist/collection/components/salla-verify/salla-verify.js +280 -0
  36. package/dist/collection/index.js +2 -0
  37. package/dist/collection/interfaces/colors.js +1 -0
  38. package/dist/collection/interfaces/index.js +2 -0
  39. package/dist/collection/interfaces/ratio.js +1 -0
  40. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  41. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  42. package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
  43. package/dist/esm/index-a1bf769d.js +1625 -0
  44. package/dist/esm/index.js +4 -0
  45. package/dist/esm/loader.js +17 -0
  46. package/dist/esm/polyfills/core-js.js +11 -0
  47. package/dist/esm/polyfills/css-shim.js +1 -0
  48. package/dist/esm/polyfills/dom.js +79 -0
  49. package/dist/esm/polyfills/es5-html-element.js +1 -0
  50. package/dist/esm/polyfills/index.js +34 -0
  51. package/dist/esm/polyfills/system.js +6 -0
  52. package/dist/{twilight-components → esm}/salla-branches.entry.js +2 -2
  53. package/dist/{twilight-components/salla-tel-input.entry.js → esm/salla-button_5.entry.js} +337 -35
  54. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  55. package/dist/{twilight-components/salla-login-57b18c2c.js → esm/salla-login-dd957742.js} +26 -23
  56. package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
  57. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
  58. package/dist/{twilight-components → esm}/salla-rating.entry.js +71 -108
  59. package/dist/{twilight-components/salla-search-30fec1e8.js → esm/salla-search-5e691ebb.js} +15 -11
  60. package/dist/esm/salla-search.entry.js +3 -0
  61. package/dist/esm/twilight-components.js +17 -0
  62. package/dist/index.cjs.js +1 -0
  63. package/dist/index.js +1 -0
  64. package/dist/twilight-components/index.esm.js +1 -4
  65. package/dist/twilight-components/p-1a6d8171.entry.js +1 -0
  66. package/dist/twilight-components/p-1deb8111.entry.js +1 -0
  67. package/dist/twilight-components/p-3a4d963e.js +1 -0
  68. package/dist/twilight-components/p-47f17d3b.js +1 -0
  69. package/dist/twilight-components/p-5b2eb87d.entry.js +1 -0
  70. package/dist/twilight-components/p-6a5be894.js +1 -0
  71. package/dist/twilight-components/p-7fbdf746.entry.js +1 -0
  72. package/dist/twilight-components/p-7fe5d346.entry.js +1 -0
  73. package/dist/twilight-components/p-81a61f4e.js +1 -0
  74. package/dist/twilight-components/p-ce991664.entry.js +1 -0
  75. package/dist/twilight-components/p-da73fc9b.entry.js +1 -0
  76. package/dist/twilight-components/twilight-components.css +1 -3
  77. package/dist/twilight-components/twilight-components.esm.js +1 -125
  78. package/dist/types/components/salla-login/salla-login.d.ts +3 -3
  79. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  80. package/dist/types/components/salla-rating/salla-rating.d.ts +6 -23
  81. package/dist/types/components/salla-search/salla-search.d.ts +1 -1
  82. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +14 -0
  83. package/dist/types/components/salla-verify/salla-verify.d.ts +3 -1
  84. package/dist/types/components.d.ts +12 -35
  85. package/package.json +1 -1
  86. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  87. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  88. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  89. package/dist/twilight-components/index-9c087700.js +0 -3010
  90. package/dist/twilight-components/salla-button.entry.js +0 -75
  91. package/dist/twilight-components/salla-login.entry.js +0 -3
  92. package/dist/twilight-components/salla-modal.entry.js +0 -113
  93. package/dist/twilight-components/salla-search.entry.js +0 -3
  94. package/dist/twilight-components/salla-verify.entry.js +0 -114
  95. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -1,75 +0,0 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-9c087700.js';
2
- import { H as Helper } from './Helper-d07ebbc7.js';
3
-
4
- const sallaButtonCss = ":host{display:block}";
5
-
6
- const SallaButton = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.btnStyle = 'primary';
10
- this.loading = false;
11
- this.disabled = false;
12
- this.loaderPosition = 'before';
13
- this.wide = false;
14
- this.hostAttributes = {};
15
- //============= Initiate Button Attributes =============//
16
- for (let i = 0; i < this.host.attributes.length; i++) {
17
- this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
18
- }
19
- this.hostAttributes.type = this.hostAttributes.type || 'button';
20
- this.hostAttributes.class += ' s-button-btn btn--has-loading'
21
- + ' s-button-' + this.btnStyle
22
- + (this.wide ? ' s-button-wide ' : '')
23
- + ' loader-' + this.loaderPosition
24
- + (this.loaderPosition == 'before' ? ' s-button-loader-after' : '');
25
- delete this.hostAttributes['btn-style'];
26
- delete this.hostAttributes['id'];
27
- if (this.wide) {
28
- this.host.classList.add('s-button-wide');
29
- }
30
- }
31
- async load() {
32
- if (this.loaderPosition == 'center')
33
- this.text.classList.add('s-button-hide');
34
- this.host.setAttribute('loading', '');
35
- return this.host;
36
- }
37
- async stop() {
38
- this.host.removeAttribute('loading');
39
- return this.host;
40
- }
41
- async disable() {
42
- this.host.setAttribute('disabled', '');
43
- }
44
- async enable() {
45
- this.host.removeAttribute('disabled');
46
- }
47
- handleVisible(newKind, oldKind) {
48
- //todo::use united styles
49
- this.btn.classList.remove('btn-' + oldKind);
50
- this.btn.classList.add('btn-' + newKind);
51
- }
52
- handleLoading(newVal) {
53
- //todo::use united styles
54
- Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
55
- }
56
- render() {
57
- return (
58
- //TODO:: use HOST then fake button behaviours
59
- h(Host, { class: "s-button-host-tag" }, h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), h("span", { class: "s-button-text", ref: el => this.text = el }, h("slot", null)), this.loading ? h("span", { class: {
60
- //todo::use united styles
61
- 's-button-loader': true,
62
- 's-button-loader-start': this.loaderPosition === 'start',
63
- 's-button-loader-end': this.loaderPosition === 'end',
64
- 's-button-loader-center': this.loaderPosition === 'center',
65
- } }) : '')));
66
- }
67
- get host() { return getElement(this); }
68
- static get watchers() { return {
69
- "btnStyle": ["handleVisible"],
70
- "loading": ["handleLoading"]
71
- }; }
72
- };
73
- SallaButton.style = sallaButtonCss;
74
-
75
- export { SallaButton as salla_button };
@@ -1,3 +0,0 @@
1
- export { S as salla_login } from './salla-login-57b18c2c.js';
2
- import './index-9c087700.js';
3
- import './Helper-d07ebbc7.js';
@@ -1,113 +0,0 @@
1
- import { r as registerInstance, f as createEvent, h, e as Host, g as getElement } from './index-9c087700.js';
2
- import { H as Helper } from './Helper-d07ebbc7.js';
3
-
4
- const SallaModal = class {
5
- constructor(hostRef) {
6
- registerInstance(this, hostRef);
7
- this.modalOpened = createEvent(this, "modalOpened", 7);
8
- this.modalClosed = createEvent(this, "modalClosed", 7);
9
- var _a;
10
- //todo:: unite three colors (error, success, primary) in one prop
11
- this.error = false;
12
- this.success = false;
13
- this.primary = false;
14
- this.isClosable = true;
15
- this.width = 'md';
16
- this.visible = false;
17
- this.isLoading = false;
18
- this.subTitleFirst = false;
19
- this.subTitle = '';
20
- this.icon = '';
21
- this.imageIcon = '';
22
- Helper.setHost(this.host);
23
- salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.show());
24
- salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.hide());
25
- this.title = this.host.title;
26
- this.host.removeAttribute('title');
27
- (_a = Helper.getElement('[slot=body]')) === null || _a === void 0 ? void 0 : _a.classList.add('s-modal-body', 's-modal-' + this.width);
28
- }
29
- handleVisible(newValue) {
30
- if (!newValue) {
31
- this.toggleModal(false);
32
- this.modalClosed.emit();
33
- return;
34
- }
35
- this.host.classList.remove('hidden');
36
- setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
37
- this.modalOpened.emit();
38
- }
39
- async show() {
40
- this.host.setAttribute('visible', '');
41
- return this.host;
42
- }
43
- async hide() {
44
- this.host.removeAttribute('visible');
45
- return this.host;
46
- }
47
- async setTitle(title) {
48
- this.title = title;
49
- return this.host;
50
- }
51
- async loading() {
52
- this.isLoading = true;
53
- return this.host;
54
- }
55
- async stopLoading() {
56
- this.isLoading = false;
57
- return this.host;
58
- }
59
- toggleModal(isOpen) {
60
- Helper
61
- // .toggleElement(this.host.querySelector('.s-modal-body'), 's-modal-entering', 's-modal-leaving', () => isOpen)
62
- .toggleElement(this.host.querySelector('[slot=body]') || this.host, 's-modal-entering', 's-modal-leaving', () => isOpen)
63
- .toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
64
- //todo:: use united class names
65
- .toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
66
- if (!isOpen) {
67
- setTimeout(() => this.host.classList.add('hidden'), 350);
68
- }
69
- }
70
- closeModal() {
71
- if (!this.isClosable) {
72
- return;
73
- }
74
- this.host.removeAttribute('visible');
75
- }
76
- //todo:: pref for each modal
77
- render() {
78
- this.host.id = this.host.id || 'salla-modal';
79
- return (
80
- //todo:: use suitable class name instead of hidden
81
- h(Host, { class: 's-modal-container hidden', "aria-modal": "true", role: "dialog" }, h("div", { class: "s-modal-wrapper" }, h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), h("span", { class: "s-modal-spacer" }, "\u200B"), h("slot", { name: "body" }, h("div", { class: 's-modal-body ' + 's-modal-' + this.width, slot: "body" }, this.isLoading
82
- ? h("span", null, "Loading...")
83
- : [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
84
- //todo:: remove cursor-pointer
85
- h("button", { class: "s-modal-close cursor-pointer", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
86
- : '', this.error || this.success || this.icon
87
- ? h("div", { class: {
88
- 's-modal-icon': true,
89
- 's-modal-bg-error': this.error,
90
- 's-modal-bg-success': this.success,
91
- 's-modal-bg-normal': !this.error && !this.success,
92
- 's-modal-bg-primary': this.primary
93
- } }, h("i", { class: {
94
- [this.icon]: true,
95
- 's-modal-text-error': this.error,
96
- 's-modal-text-success': this.success,
97
- } }))
98
- : this.imageIcon ?
99
- h("img", { class: "s-modal-header-img", src: this.imageIcon })
100
- : '', this.title || this.subTitle ?
101
- h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
102
- : ''),
103
- h("slot", null),
104
- h("slot", { name: "footer" })
105
- ])))));
106
- }
107
- get host() { return getElement(this); }
108
- static get watchers() { return {
109
- "visible": ["handleVisible"]
110
- }; }
111
- };
112
-
113
- export { SallaModal as salla_modal };
@@ -1,3 +0,0 @@
1
- export { S as salla_search } from './salla-search-30fec1e8.js';
2
- import './index-9c087700.js';
3
- import './Helper-d07ebbc7.js';
@@ -1,114 +0,0 @@
1
- import { r as registerInstance, f as createEvent, h, g as getElement } from './index-9c087700.js';
2
- import { H as Helper } from './Helper-d07ebbc7.js';
3
-
4
- const SallaVerify = class {
5
- constructor(hostRef) {
6
- registerInstance(this, hostRef);
7
- this.verified = createEvent(this, "verified", 7);
8
- this.backClicked = createEvent(this, "backClicked", 7);
9
- this.url = 'profile/verify-mobile';
10
- this.by = 'sms';
11
- this.autoReload = true;
12
- Helper.setHost(this.host);
13
- if (this.withoutModal) {
14
- this.modal = { show: () => '', hide: () => '' };
15
- }
16
- else {
17
- salla.event.on('profile::verify.mobile', data => this.show(data));
18
- }
19
- }
20
- async getCode() {
21
- return this.code.value;
22
- }
23
- async show(data) {
24
- this.data = data;
25
- this.resendTimer();
26
- this.otpInputs = document.querySelectorAll('.s-verify-input');
27
- this.otpInputs[0].focus();
28
- Helper.on('input', '.s-verify-input', e => salla.helpers.digitsOnly(e.target));
29
- Helper.onKeyUp('.s-verify-input', event => {
30
- var _a, _b, _c, _d;
31
- let key = event.keyCode || event.charCode;
32
- if (event.target.value) {
33
- (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
34
- (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
35
- }
36
- else if ([8, 46].includes(key)) {
37
- (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
38
- (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
39
- }
40
- this.toggleOTPSubmit();
41
- });
42
- Helper.on('paste', '.s-verify-input', event => {
43
- let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
44
- this.otpInputs.forEach((input, i) => input.value = text[i] || '');
45
- this.toggleOTPSubmit();
46
- setTimeout(() => this.otpInputs[3].focus(), 100);
47
- });
48
- return this.modal.show();
49
- }
50
- toggleOTPSubmit() {
51
- let otp = [];
52
- this.otpInputs.forEach(input => input.value && otp.push(input.value));
53
- this.code.value = otp.join('');
54
- if (otp.length === 4) {
55
- this.btn.removeAttribute('disabled');
56
- this.btn.click();
57
- return;
58
- }
59
- this.btn.setAttribute('disabled', '');
60
- }
61
- resendTimer() {
62
- Helper.showElement(this.resendMessage).hideElement(this.resend);
63
- let resendAfter = 30;
64
- let timerId = setInterval(() => {
65
- if (resendAfter === -1) {
66
- clearTimeout(timerId);
67
- Helper.hideElement(this.resendMessage).showElement(this.resend);
68
- }
69
- else {
70
- this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
71
- resendAfter--;
72
- }
73
- }, 1000);
74
- }
75
- resendCode() {
76
- return this.btn.stop()
77
- .then(() => this.btn.disable())
78
- .then(() => {
79
- this.otpInputs.forEach(input => input.value = '');
80
- this.otpInputs[0].focus();
81
- })
82
- .then(() => salla.api.auth.resend(Object.assign({ resend_by: this.by }, this.data)))
83
- .then(() => this.resendTimer())
84
- .catch(() => this.resendTimer());
85
- }
86
- submit() {
87
- return this.btn.load()
88
- .then(() => this.btn.disable())
89
- .then(() => salla.document.api.request(this.url, Object.assign({ code: this.code.value }, this.data)))
90
- .then(response => this.verified.emit(response))
91
- .then(() => this.btn.stop() && this.btn.disable())
92
- .then(() => this.modal.hide())
93
- .then(() => this.autoReload && window.location.reload())
94
- .catch(() => this.btn.stop() && this.btn.enable());
95
- }
96
- render() {
97
- return this.withoutModal ? this.myBody() :
98
- h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, this.myBody());
99
- }
100
- myBody() {
101
- return [
102
- h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
103
- // <label class="s-verify-label">{salla.lang.get('pages.profile.verify_placeholder')}</label>,
104
- h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
105
- h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))),
106
- h("div", { slot: "footer", class: "s-verify-footer" }, h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), h("b", { class: "s-verify-timer", ref: el => this.timer = el })), h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')), this.backText ?
107
- h("a", { href: "#", class: "s-verify-resend", onClick: () => this.backClicked.emit() }, this.backText)
108
- : '')
109
- ];
110
- }
111
- get host() { return getElement(this); }
112
- };
113
-
114
- export { SallaVerify as salla_verify };