@salla.sa/twilight-components 1.0.1 → 1.0.3

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 (34) hide show
  1. package/README.md +3 -0
  2. package/dist/cjs/{index-a67728b4.js → index-9441fd8e.js} +361 -43
  3. package/dist/cjs/index.cjs.js +119 -0
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/salla-login_2.cjs.entry.js +4 -103
  6. package/dist/cjs/search-modal-722cccc3.js +129 -0
  7. package/dist/cjs/twilight-components.cjs.js +2 -2
  8. package/dist/collection/components/search-modal/search-modal.css +9 -0
  9. package/dist/collection/components/search-modal/search-modal.js +55 -20
  10. package/dist/collection/index.js +3 -1
  11. package/dist/collection/plugins/tailwind-theme/index.js +6 -10
  12. package/dist/esm/{index-aeba9f62.js → index-63e5409f.js} +361 -44
  13. package/dist/esm/index.js +114 -0
  14. package/dist/esm/loader.js +2 -2
  15. package/dist/esm/salla-login_2.entry.js +2 -105
  16. package/dist/esm/search-modal-d6e12d32.js +126 -0
  17. package/dist/esm/twilight-components.js +2 -2
  18. package/dist/loader/cdn.js +3 -0
  19. package/dist/loader/index.cjs.js +3 -0
  20. package/dist/loader/index.d.ts +13 -0
  21. package/dist/loader/index.es2017.js +3 -0
  22. package/dist/loader/index.js +4 -0
  23. package/dist/loader/package.json +10 -0
  24. package/dist/twilight-components/index.esm.js +1 -0
  25. package/dist/twilight-components/p-01102f97.entry.js +1 -0
  26. package/dist/twilight-components/p-3d53781c.js +1 -0
  27. package/dist/twilight-components/p-591a15cf.js +1 -0
  28. package/dist/twilight-components/twilight-components.esm.js +1 -1
  29. package/dist/types/components/search-modal/search-modal.d.ts +10 -6
  30. package/dist/types/components.d.ts +8 -0
  31. package/dist/types/index.d.ts +8 -1
  32. package/package.json +1 -1
  33. package/dist/twilight-components/p-0a7edc5f.entry.js +0 -1
  34. package/dist/twilight-components/p-b390bfd1.js +0 -1
@@ -1,2 +1,121 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const searchModal = require('./search-modal-722cccc3.js');
6
+ require('./index-9441fd8e.js');
7
+
8
+ const utilities = {
9
+ ".s-search-modal-search-button-icon": {
10
+ "@apply bg-gray-bg2 hover:bg-gray-150 dark:hover:bg-opacity-10 transition duration-300 mx-3 text-sm rounded-full w-9 h-9": {
11
+ }
12
+ },
13
+ ".s-search-modal-container": {
14
+ "@apply fixed inset-0 z-50 flex items-top justify-center overflow-auto items-top": {
15
+ }
16
+ },
17
+ ".s-search-modal-wrapper": {
18
+ "@apply bg-transparent w-full": {
19
+ }
20
+ },
21
+ ".s-search-modal-inner": {
22
+ "@apply mx-auto w-11/12 lg:w-6/12": {
23
+ }
24
+ },
25
+ ".s-search-modal-search-box-container": {
26
+ "@apply mt-36 search-box anime-item": {
27
+ }
28
+ },
29
+ ".s-search-modal-search-box-inner": {
30
+ "@apply relative bg-white rounded-tiny border border-border-color": {
31
+ }
32
+ },
33
+ ".s-search-modal-search-box-inner-open": {
34
+ "@apply relative bg-white rounded-tiny border border-border-color rounded-b-none": {
35
+ }
36
+ },
37
+ ".s-search-modal-input": {
38
+ "@apply anime-item bg-transparent border-0 form-input w-full ps-10 pt-6 pb-7 rounded-tiny text-gray-600": {
39
+ }
40
+ },
41
+ ".s-search-modal-search-icon": {
42
+ "@apply anime-item flex justify-end items-center absolute top-4 start-4 text-md text-gray-text": {
43
+ }
44
+ },
45
+ ".s-search-modal-spinner": {
46
+ "@apply spinner-loader-wrap absolute top-1/2 transform -translate-y-1/2 start-4 w-4 h-4": {
47
+ }
48
+ },
49
+ ".s-search-modal-spinner-loader": {
50
+ "@apply block spinner-loader w-4 h-4 animate-spin border-2 border-gray-300 rounded-full": {
51
+ }
52
+ },
53
+ ".s-search-modal-search-results": {
54
+ "@apply m-auto max-h-96 overflow-y-auto bg-white rounded-b-tiny": {
55
+ }
56
+ },
57
+ ".s-search-modal-no-results": {
58
+ "@apply error p-4 text-sm text-gray-text": {
59
+ }
60
+ },
61
+ ".s-search-modal-product": {
62
+ "@apply h-full transition duration-500 bg-transparent justify-around overflow-hidden flex transition-colors duration-300 hover:bg-gray-bg2 px-4 xs:px-5 py-5 border-t-0": {
63
+ }
64
+ },
65
+ ".s-search-modal-product-image-container": {
66
+ "@apply relative overflow-hidden w-20 h-20 sm:w-28 sm:h-28 rounded-md": {
67
+ }
68
+ },
69
+ ".s-search-modal-product-image": {
70
+ "@apply h-full w-full object-cover": {
71
+ }
72
+ },
73
+ ".s-search-modal-product-details": {
74
+ "@apply flex-1 ps-4 xs:ps-5 pt-1": {
75
+ }
76
+ },
77
+ ".s-search-modal-product-title": {
78
+ "@apply flex flex-col justify-start items-baseline text-sm font-bold text-title-color leading-6 mb-2.5": {
79
+ }
80
+ },
81
+ ".s-search-modal-product-price": {
82
+ "@apply w-full flex justify-between items-center mb-5 text-primary font-bold text-sm": {
83
+ }
84
+ }
85
+ };
86
+
87
+ const componentsClasses = /*#__PURE__*/Object.freeze({
88
+ __proto__: null,
89
+ 'default': utilities
90
+ });
91
+
92
+ let tailwind=require('tailwindcss/plugin').withOptions(() => {
93
+ return function({addUtilities}) {
94
+ addUtilities({
95
+ // TODO :: find if there are used and defined them here if its.
96
+ '.anime-item': {},
97
+ '.text-md': {},
98
+ '.items-top': {},
99
+ '.error': {},
100
+ '.search-box': {},
101
+ '.spinner-loader-wrap': {}
102
+ });
103
+
104
+ // todo :: move it to global
105
+ addUtilities({
106
+ '.spinner-loader': {
107
+ 'border-right-color': 'var(--main-color) !important',
108
+ '&.reverse': {
109
+ 'border-right-color': '#9f7171 !important',
110
+ 'background-color': '#f98181'
111
+ }
112
+ }
113
+ });
114
+
115
+ addUtilities(componentsClasses);
116
+ };
117
+ });
118
+
119
+ exports.SallaLogin = searchModal.SallaLogin;
120
+ exports.SearchModal = searchModal.SearchModal;
121
+ exports.tailwind = tailwind;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-a67728b4.js');
5
+ const index = require('./index-9441fd8e.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.8.1 | MIT Licensed | https://stenciljs.com
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-login_2.cjs",[[1,"salla-login",{"searchIcon":[1,"search-icon"],"visible":[1540],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32]},[[8,"click","handleClick"]]],[0,"salla-search-modal",{"searchPlaceholder":[1,"search-placeholder"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
17
+ return index.bootstrapLazy([["salla-login_2.cjs",[[1,"salla-login",{"searchIcon":[1,"search-icon"],"visible":[1540],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32]},[[8,"click","handleClick"]]],[4,"salla-search-modal",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -2,109 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-a67728b4.js');
5
+ const searchModal = require('./search-modal-722cccc3.js');
6
+ require('./index-9441fd8e.js');
6
7
 
7
- const sallaLoginCss = ".wrapper{opacity:0;visibility:hidden;position:fixed;width:100%;height:100%;top:0;left:0;background:#fcfcfc;-webkit-transition:opacity 0.5s, visibility 0s 0.5s;transition:opacity 0.5s, visibility 0s 0.5s;display:flex;align-items:center;justify-content:center;z-index:1050}.wrapper .modal{font-family:Helvetica, sans-serif;font-size:14px;background-color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:90%;border:1px solid rgba(0, 0, 0, 0.2);border-radius:0.3rem}@media (min-width: 576px){.wrapper .modal{max-width:500px}}.wrapper .modal .displayed{display:flex}.wrapper .modal .modal-body{position:relative;-ms-flex:1 1 auto;flex:1 1 auto;padding:1rem}.visible{opacity:1;visibility:visible;transform:scale(1);transition:visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s}.hide{display:none !important}.show{display:block !important}.search-box{display:flex}.search-box input{width:100%;padding:10px;padding-inline-start:32px}.search-box button{background-color:transparent;border:0;position:absolute;padding:12px;left:12px}.results{list-style:none;padding:0;margin:0;max-height:300px;overflow-y:scroll}.results .product-img{width:50px;margin-inline-end:10px}.results a:first-child{margin-top:20px}.results a{display:flex;border-bottom:1px solid #ddd}.results a h5{margin-top:5px}";
8
8
 
9
- const SallaLogin = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.fetchStatus = '';
13
- this.searchIcon = 'Search_Icon.svg';
14
- /**
15
- * If 'true' will make the modal visible.
16
- */
17
- this.visible = false;
18
- this.handleClose = () => {
19
- this.visible = false;
20
- };
21
- }
22
- handleClick(ev) {
23
- if (!ev.path.some(x => x.className && x.className.includes('modal-body')) &&
24
- ev.target.localName === 'salla-search-modal') {
25
- this.visible = false;
26
- }
27
- }
28
- render() {
29
- return (index.h("div", { class: this.visible ? 'wrapper visible' : 'wrapper' }, index.h("div", { class: "modal" }, index.h("div", { class: 'modal-header' }, index.h("h5", { class: "title" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644 \u0625\u0644\u064A \u0627\u0644\u0645\u0648\u0642\u0639"), index.h("button", { type: "button", class: "close", "data-dismiss": "modal", "aria-label": "Close", onClick: this.handleClose }, index.h("span", { "aria-hidden": "true" }, "\u00D7"))), index.h("div", { class: "modal-body" }, index.h("div", { id: "showLoginMethods" }, index.h("p", { class: "text-sm text-gray-text mb-5" }, "\u0627\u062E\u062A\u0631 \u0627\u0644\u0648\u0633\u064A\u0644\u0629 \u0627\u0644\u0645\u0646\u0627\u0633\u0628\u0629"), index.h("div", { id: "openEmailLogin", class: "mb-2.5 box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, index.h("div", { class: "flex-shrink-0" }, index.h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, index.h("i", { class: "sicon-mail" }))), index.h("div", { class: "flex-1 min-w-0" }, index.h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, index.h("div", { class: "flex-1" }, index.h("span", { class: "absolute inset-0", "aria-hidden": "true" }), index.h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), index.h("h6", { class: "font-boldf" }, "\u0627\u0644\u0628\u0631\u064A\u062F \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A")), index.h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))), index.h("div", { class: "box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, index.h("div", { class: "flex-shrink-0" }, index.h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, index.h("i", { class: "sicon-phone" }))), index.h("div", { class: "flex-1 min-w-0" }, index.h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, index.h("div", { class: "flex-1" }, index.h("span", { class: "absolute inset-0", "aria-hidden": "true" }), index.h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), index.h("h6", { class: "font-boldf" }, "\u0627\u0644\u0647\u0627\u062A\u0641")), index.h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))))))));
30
- }
31
- static get assetsDirs() { return ["assets"]; }
32
- };
33
- SallaLogin.style = sallaLoginCss;
34
9
 
35
- const searchModalCss = "";
36
-
37
- const SearchModal = class {
38
- constructor(hostRef) {
39
- index.registerInstance(this, hostRef);
40
- this.fetchStatus = '';
41
- this.showModal = false;
42
- /**
43
- * The text to overwrite search placeholder.
44
- */
45
- this.searchPlaceholder = 'Search here ...';
46
- this.handleChange = event => {
47
- this.searchTerm = event.target.value;
48
- console.log('this.value', this.searchTerm);
49
- this.fetchStatus = 'loading';
50
- this.showResult = false;
51
- this.results = [];
52
- if (this.searchTerm.length > 2) {
53
- window.salla.search.api
54
- .search(this.searchTerm)
55
- .then(response => response)
56
- .then(response => {
57
- console.log('response', response);
58
- this.fetchStatus = 'idle';
59
- this.results = response.results;
60
- this.showResult = true;
61
- if (this.results.length < 1) {
62
- this.fetchStatus = 'error';
63
- }
64
- })
65
- .catch(err => {
66
- this.showResult = true;
67
- this.fetchStatus = 'error';
68
- console.log(err);
69
- });
70
- }
71
- };
72
- this.openSearch = () => {
73
- console.log('openSearchModal');
74
- this.searchTerm = '';
75
- this.fetchStatus = '';
76
- this.results = [];
77
- this.showModal = true;
78
- window.scrollTo(0, 0);
79
- document.getElementsByTagName('html')[0].style.position = 'fixed';
80
- document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
81
- //this.$nextTick(() => { this.$refs.searchInput.focus(); });
82
- };
83
- this.closeSearch = () => {
84
- console.log('closeSearchModal');
85
- this.searchTerm = '';
86
- this.fetchStatus = '';
87
- this.results = [];
88
- document.getElementsByTagName('html')[0].style.position = 'static';
89
- document.getElementsByTagName('html')[0].style.overflowY = 'auto';
90
- this.showModal = false;
91
- };
92
- }
93
- getProduct(item) {
94
- var _a;
95
- return (index.h("div", { key: item.id, class: "s-search-modal-results-item" }, index.h("div", { class: "s-search-modal-product" }, index.h("a", { target: "_blank", href: item.url, class: "s-search-modal-product-image-container" }, index.h("img", { class: "s-search-modal-product-image", src: item.thumb })), index.h("div", { class: "s-search-modal-product-details" }, index.h("div", { class: "s-search-modal-product-title" }, index.h("h3", { class: "s-search-modal-product-title-h3" }, item.title)), index.h("div", { class: "s-search-modal-product-price" }, index.h("h4", { class: "s-search-modal-product-price-h4" }, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after))))));
96
- }
97
- render() {
98
- return (index.h(index.Host, { class: "s-search-modal" }, index.h("button", { type: "button", onClick: this.openSearch, class: "s-search-modal-search-button-icon" }, index.h("i", { class: "sicon-search font-bold" })), this.showModal && (index.h("div", { class: "s-search-modal-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } }, index.h("div", { class: "s-search-modal-wrapper", onClick: this.closeSearch }, index.h("div", { class: "s-search-modal-inner" }, index.h("div", { class: "s-search-modal-search-box-container" }, index.h("div", { class: !this.showResult ? 's-search-modal-search-box-inner' : 's-search-modal-search-box-inner-open' }, index.h("input", { onClick: e => {
99
- e.stopPropagation();
100
- }, class: "s-search-modal-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }), this.fetchStatus != 'loading' ? (index.h("button", { class: "s-search-modal-search-icon" }, index.h("i", { class: "sicon-search" }))) : (index.h("span", { class: "s-search-modal-spinner" }, index.h("span", { class: "s-search-modal-spinner-loader" }))))), index.h("div", { class: "s-search-modal-search-results" }, this.fetchStatus === 'error' && (index.h("p", { class: "s-search-modal-no-results error p-4 text-sm text-gray-text" }, "\u0644\u0627 \u064A\u0648\u062C\u062F \u0646\u062A\u0627\u0626\u062C")), this.results &&
101
- this.results.map(item => {
102
- return this.getProduct(item);
103
- }))))))));
104
- }
105
- static get assetsDirs() { return ["assets"]; }
106
- };
107
- SearchModal.style = searchModalCss;
108
-
109
- exports.salla_login = SallaLogin;
110
- exports.salla_search_modal = SearchModal;
10
+ exports.salla_login = searchModal.SallaLogin;
11
+ exports.salla_search_modal = searchModal.SearchModal;
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-9441fd8e.js');
4
+
5
+ const sallaLoginCss = ".wrapper{opacity:0;visibility:hidden;position:fixed;width:100%;height:100%;top:0;left:0;background:#fcfcfc;-webkit-transition:opacity 0.5s, visibility 0s 0.5s;transition:opacity 0.5s, visibility 0s 0.5s;display:flex;align-items:center;justify-content:center;z-index:1050}.wrapper .modal{font-family:Helvetica, sans-serif;font-size:14px;background-color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:90%;border:1px solid rgba(0, 0, 0, 0.2);border-radius:0.3rem}@media (min-width: 576px){.wrapper .modal{max-width:500px}}.wrapper .modal .displayed{display:flex}.wrapper .modal .modal-body{position:relative;-ms-flex:1 1 auto;flex:1 1 auto;padding:1rem}.visible{opacity:1;visibility:visible;transform:scale(1);transition:visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s}.hide{display:none !important}.show{display:block !important}.search-box{display:flex}.search-box input{width:100%;padding:10px;padding-inline-start:32px}.search-box button{background-color:transparent;border:0;position:absolute;padding:12px;left:12px}.results{list-style:none;padding:0;margin:0;max-height:300px;overflow-y:scroll}.results .product-img{width:50px;margin-inline-end:10px}.results a:first-child{margin-top:20px}.results a{display:flex;border-bottom:1px solid #ddd}.results a h5{margin-top:5px}";
6
+
7
+ const SallaLogin = class {
8
+ constructor(hostRef) {
9
+ index.registerInstance(this, hostRef);
10
+ this.fetchStatus = '';
11
+ this.searchIcon = 'Search_Icon.svg';
12
+ /**
13
+ * If 'true' will make the modal visible.
14
+ */
15
+ this.visible = false;
16
+ this.handleClose = () => {
17
+ this.visible = false;
18
+ };
19
+ }
20
+ handleClick(ev) {
21
+ if (!ev.path.some(x => x.className && x.className.includes('modal-body')) &&
22
+ ev.target.localName === 'salla-search-modal') {
23
+ this.visible = false;
24
+ }
25
+ }
26
+ render() {
27
+ return (index.h("div", { class: this.visible ? 'wrapper visible' : 'wrapper' }, index.h("div", { class: "modal" }, index.h("div", { class: 'modal-header' }, index.h("h5", { class: "title" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644 \u0625\u0644\u064A \u0627\u0644\u0645\u0648\u0642\u0639"), index.h("button", { type: "button", class: "close", "data-dismiss": "modal", "aria-label": "Close", onClick: this.handleClose }, index.h("span", { "aria-hidden": "true" }, "\u00D7"))), index.h("div", { class: "modal-body" }, index.h("div", { id: "showLoginMethods" }, index.h("p", { class: "text-sm text-gray-text mb-5" }, "\u0627\u062E\u062A\u0631 \u0627\u0644\u0648\u0633\u064A\u0644\u0629 \u0627\u0644\u0645\u0646\u0627\u0633\u0628\u0629"), index.h("div", { id: "openEmailLogin", class: "mb-2.5 box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, index.h("div", { class: "flex-shrink-0" }, index.h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, index.h("i", { class: "sicon-mail" }))), index.h("div", { class: "flex-1 min-w-0" }, index.h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, index.h("div", { class: "flex-1" }, index.h("span", { class: "absolute inset-0", "aria-hidden": "true" }), index.h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), index.h("h6", { class: "font-boldf" }, "\u0627\u0644\u0628\u0631\u064A\u062F \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A")), index.h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))), index.h("div", { class: "box-content relative rounded-md border border-border-color bg-white py-5 pe-4 ps-5 flex items-center space-s-3 hover:border-gray-200" }, index.h("div", { class: "flex-shrink-0" }, index.h("div", { class: "bg-primary w-12 h-12 text-lg text-white rounded-icon" }, index.h("i", { class: "sicon-phone" }))), index.h("div", { class: "flex-1 min-w-0" }, index.h("a", { href: "#", class: "focus:outline-none flex justify-between items-center" }, index.h("div", { class: "flex-1" }, index.h("span", { class: "absolute inset-0", "aria-hidden": "true" }), index.h("p", { class: "text-sm text-gray-text" }, "\u0633\u062C\u0644 \u062F\u062E\u0648\u0644"), index.h("h6", { class: "font-boldf" }, "\u0627\u0644\u0647\u0627\u062A\u0641")), index.h("i", { class: "sicon-keyboard_arrow_left text-primary text-xl" })))))))));
28
+ }
29
+ static get assetsDirs() { return ["assets"]; }
30
+ };
31
+ SallaLogin.style = sallaLoginCss;
32
+
33
+ const searchModalCss = "";
34
+
35
+ const SearchModal = class {
36
+ constructor(hostRef) {
37
+ index.registerInstance(this, hostRef);
38
+ this.fetchStatus = '';
39
+ this.showModal = false;
40
+ /**
41
+ * The text to overwrite search placeholder.
42
+ */
43
+ this.searchPlaceholder = 'Search here ...';
44
+ /**
45
+ * The text to overwrite no results text.
46
+ */
47
+ this.noResultsText = 'There are no results at the moment';
48
+ this.handleChange = event => {
49
+ this.searchTerm = event.target.value;
50
+ this.fetchStatus = 'loading';
51
+ this.showResult = false;
52
+ this.results = [];
53
+ if (this.searchTerm.length > 2) {
54
+ window.salla.search.api
55
+ .search(this.searchTerm)
56
+ .then(response => response)
57
+ .then(response => {
58
+ console.log('response', response);
59
+ this.fetchStatus = 'idle';
60
+ this.results = response.results;
61
+ this.showResult = true;
62
+ if (this.results.length < 1) {
63
+ this.fetchStatus = 'error';
64
+ }
65
+ })
66
+ .catch(err => {
67
+ this.showResult = true;
68
+ this.fetchStatus = 'error';
69
+ console.log(err);
70
+ });
71
+ }
72
+ };
73
+ this.openSearch = () => {
74
+ this.searchTerm = '';
75
+ this.fetchStatus = '';
76
+ this.results = [];
77
+ this.showModal = true;
78
+ window.scrollTo(0, 0);
79
+ document.getElementsByTagName('html')[0].style.position = 'fixed';
80
+ document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
81
+ };
82
+ this.closeSearch = () => {
83
+ this.searchTerm = '';
84
+ this.fetchStatus = '';
85
+ this.results = [];
86
+ document.getElementsByTagName('html')[0].style.position = 'static';
87
+ document.getElementsByTagName('html')[0].style.overflowY = 'auto';
88
+ this.showModal = false;
89
+ };
90
+ }
91
+ componentWillLoad() {
92
+ this.hasSearchIconSlot = !!this.hostElement.querySelector('[slot="search-icon"]');
93
+ this.hasProductTemplateSlot = !!this.hostElement.querySelector('[slot="product-template"]');
94
+ if (this.hasProductTemplateSlot) {
95
+ this.productTemplateHtml = this.hostElement.querySelector('[slot="product-template"]').innerHTML;
96
+ }
97
+ }
98
+ getProduct(item) {
99
+ var _a, _b;
100
+ // todo use art-template https://aui.github.io/art-template/docs/.
101
+ if (this.hasProductTemplateSlot) {
102
+ let product = this.productTemplateHtml
103
+ .replace("{title}", item.title)
104
+ .replace("{price}", (_a = item.price) === null || _a === void 0 ? void 0 : _a.after)
105
+ .replace("{url}", item.url)
106
+ .replace("{thumb}", item.thumb);
107
+ return (index.h("div", { class: "s-search-modal-product", innerHTML: product }));
108
+ }
109
+ else {
110
+ return (index.h("div", { class: "s-search-modal-product" }, index.h("a", { target: "_blank", href: item.url, class: "s-search-modal-product-image-container" }, index.h("img", { class: "s-search-modal-product-image", src: item.thumb })), index.h("div", { class: "s-search-modal-product-details" }, index.h("div", { class: "s-search-modal-product-title" }, item.title), index.h("div", { class: "s-search-modal-product-price" }, (_b = item.price) === null || _b === void 0 ? void 0 : _b.after))));
111
+ }
112
+ }
113
+ render() {
114
+ return (index.h(index.Host, { class: "s-search-modal" }, index.h("button", { type: "button", onClick: this.openSearch, class: "s-search-modal-search-button-icon" }, this.hasSearchIconSlot ? (index.h("slot", { name: "search-icon" })) : (index.h("i", { class: "sicon-search font-bold" }))), this.showModal && (index.h("div", { class: "s-search-modal-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } }, index.h("div", { class: "s-search-modal-wrapper", onClick: this.closeSearch }, index.h("div", { class: "s-search-modal-inner", onClick: e => {
115
+ e.stopPropagation();
116
+ } }, index.h("div", { class: "s-search-modal-search-box-container" }, index.h("div", { class: !this.showResult
117
+ ? 's-search-modal-search-box-inner'
118
+ : 's-search-modal-search-box-inner-open' }, index.h("input", { class: "s-search-modal-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }), this.fetchStatus != 'loading' ? (index.h("button", { class: "s-search-modal-search-icon" }, index.h("i", { class: "sicon-search" }))) : (index.h("span", { class: "s-search-modal-spinner" }, index.h("span", { class: "s-search-modal-spinner-loader" }))))), index.h("div", { class: "s-search-modal-search-results" }, this.fetchStatus === 'error' && (index.h("p", { class: "s-search-modal-no-results error p-4 text-sm text-gray-text" }, this.noResultsText)), this.results &&
119
+ this.results.map(item => {
120
+ return this.getProduct(item);
121
+ }))))))));
122
+ }
123
+ static get assetsDirs() { return ["assets"]; }
124
+ get hostElement() { return index.getElement(this); }
125
+ };
126
+ SearchModal.style = searchModalCss;
127
+
128
+ exports.SallaLogin = SallaLogin;
129
+ exports.SearchModal = SearchModal;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-a67728b4.js');
3
+ const index = require('./index-9441fd8e.js');
4
4
 
5
5
  /*
6
6
  Stencil Client Patch Browser v2.8.1 | MIT Licensed | https://stenciljs.com
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["salla-login_2.cjs",[[1,"salla-login",{"searchIcon":[1,"search-icon"],"visible":[1540],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32]},[[8,"click","handleClick"]]],[0,"salla-search-modal",{"searchPlaceholder":[1,"search-placeholder"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
18
+ return index.bootstrapLazy([["salla-login_2.cjs",[[1,"salla-login",{"searchIcon":[1,"search-icon"],"visible":[1540],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32]},[[8,"click","handleClick"]]],[4,"salla-search-modal",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
19
19
  });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Initial Variables
3
+ */
4
+ /**
5
+ * Functions
6
+ */
7
+ /**
8
+ * Delivered variables
9
+ */
@@ -1,4 +1,4 @@
1
- import { Component, h, Host, Prop, State } from '@stencil/core';
1
+ import { Component, h, Host, Prop, State, Element } from '@stencil/core';
2
2
  export class SearchModal {
3
3
  constructor() {
4
4
  this.fetchStatus = '';
@@ -7,9 +7,12 @@ export class SearchModal {
7
7
  * The text to overwrite search placeholder.
8
8
  */
9
9
  this.searchPlaceholder = 'Search here ...';
10
+ /**
11
+ * The text to overwrite no results text.
12
+ */
13
+ this.noResultsText = 'There are no results at the moment';
10
14
  this.handleChange = event => {
11
15
  this.searchTerm = event.target.value;
12
- console.log('this.value', this.searchTerm);
13
16
  this.fetchStatus = 'loading';
14
17
  this.showResult = false;
15
18
  this.results = [];
@@ -34,7 +37,6 @@ export class SearchModal {
34
37
  }
35
38
  };
36
39
  this.openSearch = () => {
37
- console.log('openSearchModal');
38
40
  this.searchTerm = '';
39
41
  this.fetchStatus = '';
40
42
  this.results = [];
@@ -42,10 +44,8 @@ export class SearchModal {
42
44
  window.scrollTo(0, 0);
43
45
  document.getElementsByTagName('html')[0].style.position = 'fixed';
44
46
  document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
45
- //this.$nextTick(() => { this.$refs.searchInput.focus(); });
46
47
  };
47
48
  this.closeSearch = () => {
48
- console.log('closeSearchModal');
49
49
  this.searchTerm = '';
50
50
  this.fetchStatus = '';
51
51
  this.results = [];
@@ -54,35 +54,51 @@ export class SearchModal {
54
54
  this.showModal = false;
55
55
  };
56
56
  }
57
+ componentWillLoad() {
58
+ this.hasSearchIconSlot = !!this.hostElement.querySelector('[slot="search-icon"]');
59
+ this.hasProductTemplateSlot = !!this.hostElement.querySelector('[slot="product-template"]');
60
+ if (this.hasProductTemplateSlot) {
61
+ this.productTemplateHtml = this.hostElement.querySelector('[slot="product-template"]').innerHTML;
62
+ }
63
+ }
57
64
  getProduct(item) {
58
- var _a;
59
- return (h("div", { key: item.id, class: "s-search-modal-results-item" },
60
- h("div", { class: "s-search-modal-product" },
65
+ var _a, _b;
66
+ // todo use art-template https://aui.github.io/art-template/docs/.
67
+ if (this.hasProductTemplateSlot) {
68
+ let product = this.productTemplateHtml
69
+ .replace("{title}", item.title)
70
+ .replace("{price}", (_a = item.price) === null || _a === void 0 ? void 0 : _a.after)
71
+ .replace("{url}", item.url)
72
+ .replace("{thumb}", item.thumb);
73
+ return (h("div", { class: "s-search-modal-product", innerHTML: product }));
74
+ }
75
+ else {
76
+ return (h("div", { class: "s-search-modal-product" },
61
77
  h("a", { target: "_blank", href: item.url, class: "s-search-modal-product-image-container" },
62
78
  h("img", { class: "s-search-modal-product-image", src: item.thumb })),
63
79
  h("div", { class: "s-search-modal-product-details" },
64
- h("div", { class: "s-search-modal-product-title" },
65
- h("h3", { class: "s-search-modal-product-title-h3" }, item.title)),
66
- h("div", { class: "s-search-modal-product-price" },
67
- h("h4", { class: "s-search-modal-product-price-h4" }, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after))))));
80
+ h("div", { class: "s-search-modal-product-title" }, item.title),
81
+ h("div", { class: "s-search-modal-product-price" }, (_b = item.price) === null || _b === void 0 ? void 0 : _b.after))));
82
+ }
68
83
  }
69
84
  render() {
70
85
  return (h(Host, { class: "s-search-modal" },
71
- h("button", { type: "button", onClick: this.openSearch, class: "s-search-modal-search-button-icon" },
72
- h("i", { class: "sicon-search font-bold" })),
86
+ h("button", { type: "button", onClick: this.openSearch, class: "s-search-modal-search-button-icon" }, this.hasSearchIconSlot ? (h("slot", { name: "search-icon" })) : (h("i", { class: "sicon-search font-bold" }))),
73
87
  this.showModal && (h("div", { class: "s-search-modal-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } },
74
88
  h("div", { class: "s-search-modal-wrapper", onClick: this.closeSearch },
75
- h("div", { class: "s-search-modal-inner" },
89
+ h("div", { class: "s-search-modal-inner", onClick: e => {
90
+ e.stopPropagation();
91
+ } },
76
92
  h("div", { class: "s-search-modal-search-box-container" },
77
- h("div", { class: !this.showResult ? 's-search-modal-search-box-inner' : 's-search-modal-search-box-inner-open' },
78
- h("input", { onClick: e => {
79
- e.stopPropagation();
80
- }, class: "s-search-modal-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }),
93
+ h("div", { class: !this.showResult
94
+ ? 's-search-modal-search-box-inner'
95
+ : 's-search-modal-search-box-inner-open' },
96
+ h("input", { class: "s-search-modal-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }),
81
97
  this.fetchStatus != 'loading' ? (h("button", { class: "s-search-modal-search-icon" },
82
98
  h("i", { class: "sicon-search" }))) : (h("span", { class: "s-search-modal-spinner" },
83
99
  h("span", { class: "s-search-modal-spinner-loader" }))))),
84
100
  h("div", { class: "s-search-modal-search-results" },
85
- this.fetchStatus === 'error' && (h("p", { class: "s-search-modal-no-results error p-4 text-sm text-gray-text" }, "\u0644\u0627 \u064A\u0648\u062C\u062F \u0646\u062A\u0627\u0626\u062C")),
101
+ this.fetchStatus === 'error' && (h("p", { class: "s-search-modal-no-results error p-4 text-sm text-gray-text" }, this.noResultsText)),
86
102
  this.results &&
87
103
  this.results.map(item => {
88
104
  return this.getProduct(item);
@@ -114,6 +130,24 @@ export class SearchModal {
114
130
  "attribute": "search-placeholder",
115
131
  "reflect": false,
116
132
  "defaultValue": "'Search here ...'"
133
+ },
134
+ "noResultsText": {
135
+ "type": "string",
136
+ "mutable": false,
137
+ "complexType": {
138
+ "original": "string",
139
+ "resolved": "string",
140
+ "references": {}
141
+ },
142
+ "required": false,
143
+ "optional": false,
144
+ "docs": {
145
+ "tags": [],
146
+ "text": "The text to overwrite no results text."
147
+ },
148
+ "attribute": "no-results-text",
149
+ "reflect": false,
150
+ "defaultValue": "'There are no results at the moment'"
117
151
  }
118
152
  }; }
119
153
  static get states() { return {
@@ -123,4 +157,5 @@ export class SearchModal {
123
157
  "showResult": {},
124
158
  "showModal": {}
125
159
  }; }
160
+ static get elementRef() { return "hostElement"; }
126
161
  }
@@ -1 +1,3 @@
1
- export * from './components';
1
+ export * from './components/salla-login/salla-login';
2
+ export * from './components/search-modal/search-modal';
3
+ export * from './plugins/tailwind-theme/index';
@@ -1,8 +1,6 @@
1
- const plugin = require('tailwindcss/plugin');
2
- const fs = require('fs');
3
- const path = require('path');
1
+ import * as componentsClasses from './utilities.json';
4
2
 
5
- module.exports = plugin.withOptions(() => {
3
+ let tailwind=require('tailwindcss/plugin').withOptions(() => {
6
4
  return function({addUtilities}) {
7
5
  addUtilities({
8
6
  // TODO :: find if there are used and defined them here if its.
@@ -10,11 +8,6 @@ module.exports = plugin.withOptions(() => {
10
8
  '.text-md': {},
11
9
  '.items-top': {},
12
10
  '.error': {},
13
-
14
- // wrapper class
15
- // todo :: rename it with the statnder
16
- '.results__item': {},
17
-
18
11
  '.search-box': {},
19
12
  '.spinner-loader-wrap': {}
20
13
  });
@@ -30,6 +23,9 @@ module.exports = plugin.withOptions(() => {
30
23
  }
31
24
  });
32
25
 
33
- addUtilities(JSON.parse(fs.readFileSync(path.resolve(__dirname, 'utilities.json'), 'UTF-8')));
26
+ addUtilities(componentsClasses);
34
27
  };
35
28
  });
29
+ export {
30
+ tailwind
31
+ };