@salla.sa/twilight-components 1.0.13 → 1.0.15

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 (88) hide show
  1. package/dist/cjs/Helper-8852feaa.js +23 -0
  2. package/dist/cjs/index-0b5b5867.js +1656 -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.cjs.entry.js +77 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +77 -0
  8. package/dist/cjs/salla-login-6a54572d.js +14 -0
  9. package/dist/cjs/salla-login_2.cjs.entry.js +97 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +303 -0
  12. package/dist/cjs/salla-search-311c7053.js +81 -0
  13. package/dist/cjs/salla-search.cjs.entry.js +11 -0
  14. package/dist/cjs/salla-verify.cjs.entry.js +96 -0
  15. package/dist/cjs/twilight-components.cjs.js +19 -0
  16. package/dist/collection/Helpers/Helper.js +19 -0
  17. package/dist/collection/collection-manifest.json +20 -0
  18. package/dist/collection/components/generate-summary.js +35 -0
  19. package/dist/collection/components/salla-branches/salla-branches.css +12 -0
  20. package/dist/collection/components/salla-branches/salla-branches.js +235 -0
  21. package/dist/collection/components/salla-button/salla-button.css +3 -0
  22. package/dist/collection/components/salla-button/salla-button.js +243 -0
  23. package/dist/collection/components/salla-localization/salla-localization.js +200 -0
  24. package/dist/collection/components/salla-login/salla-login.js +31 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +360 -0
  26. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  27. package/dist/collection/components/salla-rating/salla-rating.css +3 -0
  28. package/dist/collection/components/salla-rating/salla-rating.js +488 -0
  29. package/dist/collection/components/salla-search/salla-search.js +132 -0
  30. package/dist/collection/components/salla-verify/salla-verify.js +99 -0
  31. package/dist/collection/index.js +2 -0
  32. package/dist/collection/interfaces/colors.js +1 -0
  33. package/dist/collection/interfaces/index.js +2 -0
  34. package/dist/collection/interfaces/ratio.js +1 -0
  35. package/dist/collection/plugins/tailwind-theme/generator.js +53 -0
  36. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  37. package/dist/{twilight-components → esm}/Helper-81ac9a8c.js +0 -0
  38. package/dist/esm/index-8b97d225.js +1628 -0
  39. package/dist/esm/index.js +4 -0
  40. package/dist/esm/loader.js +17 -0
  41. package/dist/esm/polyfills/core-js.js +11 -0
  42. package/dist/esm/polyfills/css-shim.js +1 -0
  43. package/dist/esm/polyfills/dom.js +79 -0
  44. package/dist/esm/polyfills/es5-html-element.js +1 -0
  45. package/dist/esm/polyfills/index.js +34 -0
  46. package/dist/esm/polyfills/system.js +6 -0
  47. package/dist/{twilight-components/multi-warehouse.entry.js → esm/salla-branches.entry.js} +16 -17
  48. package/dist/{twilight-components → esm}/salla-button.entry.js +5 -2
  49. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  50. package/dist/{twilight-components/salla-login-97e0a9ab.js → esm/salla-login-c9c9fa57.js} +1 -1
  51. package/dist/{twilight-components/salla-modal.entry.js → esm/salla-login_2.entry.js} +16 -9
  52. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +2 -2
  53. package/dist/{twilight-components → esm}/salla-rating.entry.js +9 -5
  54. package/dist/esm/salla-search-add7bdb6.js +79 -0
  55. package/dist/esm/salla-search.entry.js +3 -0
  56. package/dist/{twilight-components → esm}/salla-verify.entry.js +1 -1
  57. package/dist/esm/twilight-components.js +17 -0
  58. package/dist/index.cjs.js +1 -0
  59. package/dist/index.js +1 -0
  60. package/dist/twilight-components/index.esm.js +1 -3
  61. package/dist/twilight-components/p-010b8dfd.entry.js +1 -0
  62. package/dist/twilight-components/p-0ceecf63.js +1 -0
  63. package/dist/twilight-components/p-32d29245.entry.js +1 -0
  64. package/dist/twilight-components/p-50e70ad4.entry.js +1 -0
  65. package/dist/twilight-components/p-68c9f122.entry.js +1 -0
  66. package/dist/twilight-components/p-8126278e.entry.js +1 -0
  67. package/dist/twilight-components/p-9bc28e0c.js +1 -0
  68. package/dist/twilight-components/p-9d327a79.entry.js +1 -0
  69. package/dist/twilight-components/p-b05450bc.entry.js +1 -0
  70. package/dist/twilight-components/p-bd5da080.js +1 -0
  71. package/dist/twilight-components/p-cb1c59a2.js +1 -0
  72. package/dist/twilight-components/p-d584d0c7.entry.js +1 -0
  73. package/dist/twilight-components/twilight-components.css +1 -0
  74. package/dist/twilight-components/twilight-components.esm.js +1 -125
  75. package/dist/types/components/{multi-warehouse/multi-warehouse.d.ts → salla-branches/salla-branches.d.ts} +1 -1
  76. package/dist/types/components/salla-modal/salla-modal.d.ts +3 -0
  77. package/dist/types/components/salla-rating/salla-rating.d.ts +2 -2
  78. package/dist/types/components/salla-search/salla-search.d.ts +20 -17
  79. package/dist/types/components.d.ts +19 -15
  80. package/package.json +1 -1
  81. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  82. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  83. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  84. package/dist/twilight-components/index-8cf58712.js +0 -3010
  85. package/dist/twilight-components/salla-login.entry.js +0 -2
  86. package/dist/twilight-components/salla-search-df1c9b54.js +0 -95
  87. package/dist/twilight-components/salla-search.entry.js +0 -2
  88. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,99 @@
1
+ import { Component, Element, h } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ export class SallaVerify {
4
+ constructor() {
5
+ Helper.setHost(this.host);
6
+ salla.event.on('profile::verify.mobile', data => this.show(data));
7
+ }
8
+ show({ international_mobile: mobile, _country_iso2: country_code }) {
9
+ this.mobile = mobile;
10
+ this.country_code = country_code;
11
+ this.resendTimer();
12
+ this.otpInputs = document.querySelectorAll('.s-verify-input');
13
+ this.otpInputs[0].focus();
14
+ Helper.onKeyUp('.s-verify-input', event => {
15
+ var _a, _b, _c, _d;
16
+ let key = event.keyCode || event.charCode;
17
+ salla.helpers.digitsOnly(event.target);
18
+ if (event.target.value) {
19
+ (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
20
+ (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
21
+ }
22
+ else if ([8, 46].includes(key)) {
23
+ (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
24
+ (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
25
+ }
26
+ this.toggleOTPSubmit();
27
+ });
28
+ Helper.on('paste', '.s-verify-input', event => {
29
+ let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
30
+ this.otpInputs.forEach((input, i) => input.value = text[i] || '');
31
+ this.toggleOTPSubmit();
32
+ setTimeout(() => this.otpInputs[3].focus(), 100);
33
+ });
34
+ return this.modal.show();
35
+ }
36
+ toggleOTPSubmit() {
37
+ let otp = [];
38
+ this.otpInputs.forEach(input => input.value && otp.push(input.value));
39
+ this.code.value = otp.join('');
40
+ if (otp.length === 4) {
41
+ this.btn.removeAttribute('disabled');
42
+ this.btn.click();
43
+ return;
44
+ }
45
+ this.btn.setAttribute('disabled', '');
46
+ }
47
+ resendTimer() {
48
+ Helper.showElement(this.resendMessage).hideElement(this.resend);
49
+ let resendAfter = 30;
50
+ let timerId = setInterval(() => {
51
+ if (resendAfter === -1) {
52
+ clearTimeout(timerId);
53
+ Helper.hideElement(this.resendMessage).showElement(this.resend);
54
+ }
55
+ else {
56
+ this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
57
+ resendAfter--;
58
+ }
59
+ }, 1000);
60
+ }
61
+ submit() {
62
+ return this.btn.load()
63
+ .then(() => this.btn.disable())
64
+ .then(() => salla.document.api.request('profile/verify-mobile', {
65
+ mobile: this.mobile,
66
+ country_code: this.country_code,
67
+ code: this.code.value
68
+ })).then(() => this.btn.stop() && this.btn.disable())
69
+ .then(() => this.modal.hide())
70
+ .then(() => window.location.reload())
71
+ .catch(() => this.btn.stop() && this.btn.enable());
72
+ }
73
+ resendCode() {
74
+ return this.btn.stop()
75
+ .then(() => this.btn.disable())
76
+ .then(() => {
77
+ this.otpInputs.forEach(input => input.value = '');
78
+ this.otpInputs[0].focus();
79
+ })
80
+ .then(() => salla.api.auth.resend({ phone: this.mobile, country_code: this.country_code }))
81
+ .then(() => this.resendTimer())
82
+ .catch(() => this.resendTimer());
83
+ }
84
+ render() {
85
+ return (h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') },
86
+ h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }),
87
+ h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')),
88
+ h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }),
89
+ 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 }))),
90
+ h("div", { slot: "footer", class: "s-verify-footer" },
91
+ h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')),
92
+ h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el },
93
+ salla.lang.get('blocks.header.resend_after'),
94
+ h("b", { class: "s-verify-timer", ref: el => this.timer = el })),
95
+ h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))));
96
+ }
97
+ static get is() { return "salla-verify"; }
98
+ static get elementRef() { return "host"; }
99
+ }
@@ -0,0 +1,2 @@
1
+ export * from './components/salla-login/salla-login';
2
+ export * from './components/salla-search/salla-search';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './colors';
2
+ export * from './ratio';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ var fs = require('fs');
2
+ var path = require('path');
3
+ var _ = require('lodash');
4
+ var components = {};
5
+ let componentsPath=path.resolve(__dirname,'../../components');
6
+ fs.readdirSync(componentsPath, {withFileTypes: true})
7
+ .filter(parent => parent.isDirectory())
8
+ .forEach(directory => {
9
+ try {
10
+ components[directory.name.replace('salla-','')] = require(path.resolve(componentsPath , directory.name, 'utilities.json'));
11
+ } catch (e) {
12
+ // ignore
13
+ }
14
+ });
15
+ var utilities = {};
16
+
17
+ for (const [keyComponent, value] of Object.entries(components)) {
18
+ console.log('> Processing ' + keyComponent + ' ...');
19
+ _.forEach(value, function(value, keyUtility) {
20
+ keyUtility = '.s-' + keyComponent + '-' + keyUtility;
21
+ utilities[keyUtility] = {[`@apply ${value}`]: {}};
22
+ });
23
+ console.log('✓ Processed ' + keyComponent + '');
24
+ }
25
+
26
+ // write the utilities for the plugin
27
+ console.log('> Write utilities ...');
28
+ fs.writeFileSync(
29
+ path.resolve(__dirname, 'utilities.json'),
30
+ JSON.stringify(utilities),
31
+ function(err) {
32
+ if (err) {
33
+ return console.log(err);
34
+ }
35
+ console.log('The file was saved!');
36
+ }
37
+ );
38
+
39
+
40
+ // write the save list css
41
+ console.log('> Write safe-list-css ...');
42
+ fs.writeFileSync(
43
+ path.resolve(__dirname, 'safe-list-css.txt'),
44
+ Object.keys(utilities).map((name) => name.replace('.','')).join('\n'),
45
+ function(err) {
46
+ if (err) {
47
+ return console.log(err);
48
+ }
49
+ console.log('The file was saved!');
50
+ }
51
+ );
52
+
53
+ console.log('✓ Done ...');
@@ -0,0 +1,26 @@
1
+ module.exports = require('tailwindcss/plugin').withOptions(() => {
2
+ return function({addUtilities}) {
3
+ addUtilities({
4
+ // TODO :: find if there are used and defined them here if its.
5
+ '.anime-item': {},
6
+ '.text-md': {},
7
+ '.items-top': {},
8
+ '.error': {},
9
+ '.search-box': {},
10
+ '.spinner-loader-wrap': {}
11
+ });
12
+
13
+ // todo :: move it to global
14
+ addUtilities({
15
+ '.spinner-loader': {
16
+ 'border-right-color': 'var(--main-color) !important',
17
+ '&.reverse': {
18
+ 'border-right-color': '#9f7171 !important',
19
+ 'background-color': '#f98181'
20
+ }
21
+ }
22
+ });
23
+
24
+ addUtilities(require('./utilities.json'));
25
+ };
26
+ });