@salla.sa/twilight-components 1.0.5 → 1.0.6

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 (79) hide show
  1. package/dist/cjs/Helper-8c75b6ac.js +20 -0
  2. package/dist/cjs/index-e9451c82.js +1446 -0
  3. package/dist/cjs/index.cjs.js +12 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/salla-currency-language.cjs.entry.js +46 -0
  6. package/dist/cjs/salla-login-3ec94029.js +14 -0
  7. package/dist/cjs/salla-login_2.cjs.entry.js +57 -0
  8. package/dist/{twilight-components/search-modal-ee69bd04.js → cjs/salla-search-2b1d67e4.js} +12 -10
  9. package/dist/cjs/salla-search.cjs.entry.js +10 -0
  10. package/dist/cjs/twilight-components.cjs.js +19 -0
  11. package/dist/collection/Helpers/Helper.js +16 -0
  12. package/dist/collection/collection-manifest.json +15 -0
  13. package/dist/collection/components/currency-language/salla-currency-language.js +97 -0
  14. package/dist/collection/components/generate-summary.js +35 -0
  15. package/dist/collection/components/login/salla-login.js +31 -0
  16. package/dist/collection/components/modal/salla-modal.js +184 -0
  17. package/dist/collection/components/search/salla-search.js +154 -0
  18. package/dist/collection/index.js +2 -0
  19. package/dist/{types/components/salla-modal/test/salla-modal.e2e.d.ts → collection/interfaces/colors.js} +0 -0
  20. package/dist/collection/interfaces/index.js +2 -0
  21. package/dist/{types/components/salla-modal/test/salla-modal.spec.d.ts → collection/interfaces/ratio.js} +0 -0
  22. package/dist/collection/plugins/tailwind-theme/generator.js +53 -0
  23. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  24. package/dist/esm/Helper-23b2de40.js +18 -0
  25. package/dist/esm/index-8919a244.js +1418 -0
  26. package/dist/esm/index.js +3 -0
  27. package/dist/esm/loader.js +17 -0
  28. package/dist/esm/polyfills/core-js.js +11 -0
  29. package/dist/esm/polyfills/css-shim.js +1 -0
  30. package/dist/esm/polyfills/dom.js +79 -0
  31. package/dist/esm/polyfills/es5-html-element.js +1 -0
  32. package/dist/esm/polyfills/index.js +34 -0
  33. package/dist/esm/polyfills/system.js +6 -0
  34. package/dist/esm/salla-currency-language.entry.js +42 -0
  35. package/dist/{twilight-components/salla-login-0e725af9.js → esm/salla-login-4aa5bb90.js} +1 -1
  36. package/dist/esm/salla-login_2.entry.js +52 -0
  37. package/dist/{twilight-components/search-modal-c1babeb6.js → esm/salla-search-bd2f71b3.js} +3 -3
  38. package/dist/esm/salla-search.entry.js +2 -0
  39. package/dist/esm/twilight-components.js +17 -0
  40. package/dist/index.cjs.js +1 -0
  41. package/dist/index.js +1 -0
  42. package/dist/twilight-components/index.esm.js +1 -3
  43. package/dist/twilight-components/p-1abaafe4.entry.js +1 -0
  44. package/dist/twilight-components/p-41dc89e6.js +1 -0
  45. package/dist/twilight-components/p-520446eb.js +1 -0
  46. package/dist/twilight-components/p-58b1afae.js +1 -0
  47. package/dist/twilight-components/p-840f0daa.entry.js +1 -0
  48. package/dist/twilight-components/p-9f9af3e0.js +1 -0
  49. package/dist/twilight-components/p-b134c95d.entry.js +1 -0
  50. package/dist/twilight-components/twilight-components.esm.js +1 -125
  51. package/dist/types/Helpers/Helper.d.ts +8 -0
  52. package/dist/types/components/currency-language/salla-currency-language.d.ts +10 -0
  53. package/dist/types/components/{salla-login → login}/salla-login.d.ts +0 -0
  54. package/dist/types/components/modal/salla-modal.d.ts +16 -0
  55. package/dist/types/components/{search-modal/search-modal.d.ts → search/salla-search.d.ts} +1 -1
  56. package/dist/types/components.d.ts +28 -11
  57. package/dist/types/index.d.ts +2 -2
  58. package/package.json +1 -1
  59. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  60. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  61. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  62. package/dist/twilight-components/index-0aa9ca9b.js +0 -3010
  63. package/dist/twilight-components/index-d2312a61.js +0 -3010
  64. package/dist/twilight-components/index-d6ed984a.js +0 -3010
  65. package/dist/twilight-components/salla-login-2a48c6c7.js +0 -29
  66. package/dist/twilight-components/salla-login-2bfbce21.js +0 -16
  67. package/dist/twilight-components/salla-login-45a3f61c.js +0 -16
  68. package/dist/twilight-components/salla-login-5fe80dd7.js +0 -29
  69. package/dist/twilight-components/salla-login-69a00ca2.js +0 -12
  70. package/dist/twilight-components/salla-login-7bf31d85.js +0 -29
  71. package/dist/twilight-components/salla-login-cb872dc2.js +0 -16
  72. package/dist/twilight-components/salla-login.entry.js +0 -2
  73. package/dist/twilight-components/salla-modal.entry.js +0 -24
  74. package/dist/twilight-components/salla-search-modal.entry.js +0 -2
  75. package/dist/twilight-components/search-modal-5dc35a08.js +0 -94
  76. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
  77. package/dist/types/components/salla-modal/salla-modal.d.ts +0 -9
  78. package/dist/types/utils/utils.d.ts +0 -6
  79. package/dist/types/utils/utils.spec.d.ts +0 -1
@@ -0,0 +1,154 @@
1
+ import { Component, h, Host, Prop, State, Element } from '@stencil/core';
2
+ export class SallaSearch {
3
+ constructor() {
4
+ this.fetchStatus = '';
5
+ this.showModal = false;
6
+ /**
7
+ * The text to overwrite search placeholder.
8
+ */
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';
14
+ this.handleChange = event => {
15
+ this.searchTerm = event.target.value;
16
+ this.fetchStatus = 'loading';
17
+ this.showResult = false;
18
+ this.results = [];
19
+ if (this.searchTerm.length > 2) {
20
+ window.salla.search.api
21
+ .search(this.searchTerm)
22
+ .then(response => response)
23
+ .then(response => {
24
+ console.log('response', response);
25
+ this.fetchStatus = 'idle';
26
+ this.results = response.results;
27
+ this.showResult = true;
28
+ if (this.results.length < 1) {
29
+ this.fetchStatus = 'error';
30
+ }
31
+ })
32
+ .catch(err => {
33
+ this.showResult = true;
34
+ this.fetchStatus = 'error';
35
+ console.log(err);
36
+ });
37
+ }
38
+ };
39
+ this.openSearch = () => {
40
+ this.searchTerm = '';
41
+ this.fetchStatus = '';
42
+ this.results = [];
43
+ this.showModal = true;
44
+ window.scrollTo(0, 0);
45
+ document.getElementsByTagName('html')[0].style.position = 'fixed';
46
+ document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
47
+ };
48
+ this.closeSearch = () => {
49
+ this.searchTerm = '';
50
+ this.fetchStatus = '';
51
+ this.results = [];
52
+ document.getElementsByTagName('html')[0].style.position = 'static';
53
+ document.getElementsByTagName('html')[0].style.overflowY = 'auto';
54
+ this.showModal = false;
55
+ };
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
+ }
64
+ getProduct(item) {
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" },
77
+ h("a", { target: "_blank", href: item.url, class: "s-search-modal-product-image-container" },
78
+ h("img", { class: "s-search-modal-product-image", src: item.thumb })),
79
+ h("div", { class: "s-search-modal-product-details" },
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
+ }
83
+ }
84
+ render() {
85
+ return (h(Host, { class: "s-search-modal" },
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" }))),
87
+ this.showModal && (h("div", { class: "s-search-modal-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } },
88
+ h("div", { class: "s-search-modal-wrapper", onClick: this.closeSearch },
89
+ h("div", { class: "s-search-modal-inner", onClick: e => {
90
+ e.stopPropagation();
91
+ } },
92
+ h("div", { class: "s-search-modal-search-box-container" },
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) }),
97
+ this.fetchStatus != 'loading' ? (h("button", { class: "s-search-modal-search-icon" },
98
+ h("i", { class: "sicon-search" }))) : (h("span", { class: "s-search-modal-spinner" },
99
+ h("span", { class: "s-search-modal-spinner-loader" }))))),
100
+ h("div", { class: "s-search-modal-search-results" },
101
+ this.fetchStatus === 'error' && (h("p", { class: "s-search-modal-no-results error p-4 text-sm text-gray-text" }, this.noResultsText)),
102
+ this.results &&
103
+ this.results.map(item => {
104
+ return this.getProduct(item);
105
+ }))))))));
106
+ }
107
+ static get is() { return "salla-search"; }
108
+ static get properties() { return {
109
+ "searchPlaceholder": {
110
+ "type": "string",
111
+ "mutable": false,
112
+ "complexType": {
113
+ "original": "string",
114
+ "resolved": "string",
115
+ "references": {}
116
+ },
117
+ "required": false,
118
+ "optional": false,
119
+ "docs": {
120
+ "tags": [],
121
+ "text": "The text to overwrite search placeholder."
122
+ },
123
+ "attribute": "search-placeholder",
124
+ "reflect": false,
125
+ "defaultValue": "'Search here ...'"
126
+ },
127
+ "noResultsText": {
128
+ "type": "string",
129
+ "mutable": false,
130
+ "complexType": {
131
+ "original": "string",
132
+ "resolved": "string",
133
+ "references": {}
134
+ },
135
+ "required": false,
136
+ "optional": false,
137
+ "docs": {
138
+ "tags": [],
139
+ "text": "The text to overwrite no results text."
140
+ },
141
+ "attribute": "no-results-text",
142
+ "reflect": false,
143
+ "defaultValue": "'There are no results at the moment'"
144
+ }
145
+ }; }
146
+ static get states() { return {
147
+ "searchTerm": {},
148
+ "results": {},
149
+ "fetchStatus": {},
150
+ "showResult": {},
151
+ "showModal": {}
152
+ }; }
153
+ static get elementRef() { return "hostElement"; }
154
+ }
@@ -0,0 +1,2 @@
1
+ export * from './components/login/salla-login';
2
+ export * from './components/search/salla-search';
@@ -0,0 +1,2 @@
1
+ export * from './colors';
2
+ export * from './ratio';
@@ -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] = 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
+ });
@@ -0,0 +1,18 @@
1
+ class Helper extends salla.AppHelpers {
2
+ setHost(host) {
3
+ this.host = host;
4
+ }
5
+ getElement(selector) {
6
+ return this.host.querySelector(selector);
7
+ }
8
+ getAttribute(selector, attribute) {
9
+ var _a;
10
+ return (_a = this.getElement(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute(attribute);
11
+ }
12
+ val(selector) {
13
+ return this.getAttribute(selector, 'value');
14
+ }
15
+ }
16
+ const Helper$1 = new Helper;
17
+
18
+ export { Helper$1 as H };