slicejs-web-framework 2.3.5 → 2.4.1

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 (84) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +24 -5
  3. package/Slice/Components/Structural/Controller/Controller.js +156 -154
  4. package/Slice/Components/Structural/Debugger/Debugger.css +619 -619
  5. package/Slice/Components/Structural/Debugger/Debugger.html +72 -72
  6. package/Slice/Components/Structural/Logger/Log.js +10 -10
  7. package/Slice/Components/Structural/StylesManager/StylesManager.js +6 -3
  8. package/Slice/Slice.js +118 -51
  9. package/api/index.js +261 -233
  10. package/api/middleware/securityMiddleware.js +252 -252
  11. package/package.json +37 -37
  12. package/sliceConfig.schema.json +4 -0
  13. package/src/App/index.html +22 -22
  14. package/src/App/index.js +23 -23
  15. package/src/App/style.css +40 -40
  16. package/src/Components/AppComponents/HomePage/HomePage.css +204 -204
  17. package/src/Components/AppComponents/HomePage/HomePage.html +48 -48
  18. package/src/Components/AppComponents/HomePage/HomePage.js +195 -195
  19. package/src/Components/AppComponents/Playground/Playground.css +11 -11
  20. package/src/Components/AppComponents/Playground/Playground.js +111 -111
  21. package/src/Components/Service/FetchManager/FetchManager.js +133 -133
  22. package/src/Components/Service/IndexedDbManager/IndexedDbManager.js +141 -141
  23. package/src/Components/Service/LocalStorageManager/LocalStorageManager.js +45 -45
  24. package/src/Components/Visual/Button/Button.css +47 -47
  25. package/src/Components/Visual/Button/Button.html +5 -5
  26. package/src/Components/Visual/Button/Button.js +92 -92
  27. package/src/Components/Visual/Card/Card.css +68 -68
  28. package/src/Components/Visual/Card/Card.html +7 -7
  29. package/src/Components/Visual/Card/Card.js +107 -107
  30. package/src/Components/Visual/Checkbox/Checkbox.css +87 -87
  31. package/src/Components/Visual/Checkbox/Checkbox.html +8 -8
  32. package/src/Components/Visual/Checkbox/Checkbox.js +86 -86
  33. package/src/Components/Visual/CodeVisualizer/CodeVisualizer.css +129 -129
  34. package/src/Components/Visual/CodeVisualizer/CodeVisualizer.html +3 -3
  35. package/src/Components/Visual/CodeVisualizer/CodeVisualizer.js +259 -259
  36. package/src/Components/Visual/Details/Details.css +70 -70
  37. package/src/Components/Visual/Details/Details.html +9 -9
  38. package/src/Components/Visual/Details/Details.js +76 -76
  39. package/src/Components/Visual/DropDown/DropDown.css +60 -60
  40. package/src/Components/Visual/DropDown/DropDown.html +5 -5
  41. package/src/Components/Visual/DropDown/DropDown.js +63 -63
  42. package/src/Components/Visual/Grid/Grid.css +7 -7
  43. package/src/Components/Visual/Grid/Grid.html +1 -1
  44. package/src/Components/Visual/Grid/Grid.js +57 -57
  45. package/src/Components/Visual/Icon/Icon.css +510 -510
  46. package/src/Components/Visual/Icon/Icon.js +89 -89
  47. package/src/Components/Visual/Icon/slc.json +554 -554
  48. package/src/Components/Visual/Icon/slc.styl +507 -507
  49. package/src/Components/Visual/Icon/slc.svg +1485 -1485
  50. package/src/Components/Visual/Icon/slc.symbol.svg +1058 -1058
  51. package/src/Components/Visual/Input/Input.css +91 -91
  52. package/src/Components/Visual/Input/Input.html +4 -4
  53. package/src/Components/Visual/Input/Input.js +215 -215
  54. package/src/Components/Visual/Layout/Layout.js +49 -49
  55. package/src/Components/Visual/Loading/Loading.css +56 -56
  56. package/src/Components/Visual/Loading/Loading.html +83 -83
  57. package/src/Components/Visual/Loading/Loading.js +38 -38
  58. package/src/Components/Visual/MultiRoute/MultiRoute.js +93 -93
  59. package/src/Components/Visual/Navbar/Navbar.css +115 -115
  60. package/src/Components/Visual/Navbar/Navbar.html +44 -44
  61. package/src/Components/Visual/Navbar/Navbar.js +141 -141
  62. package/src/Components/Visual/NotFound/NotFound.css +116 -116
  63. package/src/Components/Visual/NotFound/NotFound.html +23 -23
  64. package/src/Components/Visual/NotFound/NotFound.js +16 -16
  65. package/src/Components/Visual/Route/Route.js +93 -93
  66. package/src/Components/Visual/Select/Select.css +84 -84
  67. package/src/Components/Visual/Select/Select.html +8 -8
  68. package/src/Components/Visual/Select/Select.js +195 -195
  69. package/src/Components/Visual/Switch/Switch.css +76 -76
  70. package/src/Components/Visual/Switch/Switch.html +8 -8
  71. package/src/Components/Visual/Switch/Switch.js +102 -102
  72. package/src/Components/Visual/TreeItem/TreeItem.css +36 -36
  73. package/src/Components/Visual/TreeItem/TreeItem.html +1 -1
  74. package/src/Components/Visual/TreeItem/TreeItem.js +126 -126
  75. package/src/Components/Visual/TreeView/TreeView.css +8 -8
  76. package/src/Components/Visual/TreeView/TreeView.html +1 -1
  77. package/src/Components/Visual/TreeView/TreeView.js +48 -48
  78. package/src/Styles/sliceStyles.css +34 -34
  79. package/src/Themes/Dark.css +42 -42
  80. package/src/Themes/Light.css +31 -31
  81. package/src/Themes/Slice.css +47 -47
  82. package/src/routes.js +15 -15
  83. package/src/sliceConfig.json +8 -3
  84. package/src/testing.js +887 -887
@@ -1,91 +1,91 @@
1
- .eye {
2
- color: var(--primary-color);
3
- position: absolute;
4
- user-select: none;
5
- cursor: pointer;
6
- right: 10px;
7
- }
8
- .input_area::-webkit-inner-spin-button {
9
- -webkit-appearance: none;
10
- margin: 0;
11
- }
12
- .input_area {
13
- color: var(--font-primary-color);
14
- width: 100%;
15
- background: none;
16
- outline: none;
17
- border: none;
18
- }
19
- .slice_input {
20
- display: flex;
21
- align-items: center;
22
- padding: 10px;
23
- max-width: 100%;
24
- border-radius: var(--border-radius-slice);
25
- font-family: var(--font-family);
26
- border: var(--slice-border) solid var(--primary-color);
27
- background-color: var(--primary-background-color);
28
- margin-bottom: 25px;
29
- margin-top: 25px;
30
- position: relative;
31
- }
32
- .slice_input_placeholder {
33
- color: var(--primary-color);
34
- position: absolute;
35
- transition: all 0.5s;
36
- user-select: none;
37
- }
38
- .slice_input_value {
39
- scale: 0.8;
40
- transform: translateY(-200%);
41
- transition: all 0.5s;
42
- }
43
- .required,
44
- .required label,
45
- .required input {
46
- border-color: var(--danger-color);
47
- --primary-color: var(--danger-color);
48
- }
49
-
50
- .disabled,
51
- .disabled label {
52
- border-color: var(--disabled-color);
53
- cursor: not-allowed;
54
- pointer-events: none;
55
- color: var(--disabled-color);
56
- div {
57
- background-color: var(--primary-color-shade);
58
- }
59
- }
60
- .color_input {
61
- border-radius: 100%;
62
- height: 50px;
63
- width: 50px;
64
- }
65
- .message {
66
- color: var(--danger-color);
67
- font-size: small;
68
- }
69
-
70
- @keyframes shake {
71
- 0% {
72
- transform: translateX(0);
73
- }
74
- 25% {
75
- transform: translateX(-5px) rotate(0.5deg);
76
- }
77
- 50% {
78
- transform: translateX(5px) rotate(-0.5deg);
79
- }
80
- 75% {
81
- transform: translateX(-3px) rotate(0.3deg);
82
- }
83
- 100% {
84
- transform: translateX(0);
85
- }
86
- }
87
-
88
- .error {
89
- --primary-color: var(--danger-color);
90
- animation: shake 0.5s infinite; /* Establece la animación y su duración */
91
- }
1
+ .eye {
2
+ color: var(--primary-color);
3
+ position: absolute;
4
+ user-select: none;
5
+ cursor: pointer;
6
+ right: 10px;
7
+ }
8
+ .input_area::-webkit-inner-spin-button {
9
+ -webkit-appearance: none;
10
+ margin: 0;
11
+ }
12
+ .input_area {
13
+ color: var(--font-primary-color);
14
+ width: 100%;
15
+ background: none;
16
+ outline: none;
17
+ border: none;
18
+ }
19
+ .slice_input {
20
+ display: flex;
21
+ align-items: center;
22
+ padding: 10px;
23
+ max-width: 100%;
24
+ border-radius: var(--border-radius-slice);
25
+ font-family: var(--font-family);
26
+ border: var(--slice-border) solid var(--primary-color);
27
+ background-color: var(--primary-background-color);
28
+ margin-bottom: 25px;
29
+ margin-top: 25px;
30
+ position: relative;
31
+ }
32
+ .slice_input_placeholder {
33
+ color: var(--primary-color);
34
+ position: absolute;
35
+ transition: all 0.5s;
36
+ user-select: none;
37
+ }
38
+ .slice_input_value {
39
+ scale: 0.8;
40
+ transform: translateY(-200%);
41
+ transition: all 0.5s;
42
+ }
43
+ .required,
44
+ .required label,
45
+ .required input {
46
+ border-color: var(--danger-color);
47
+ --primary-color: var(--danger-color);
48
+ }
49
+
50
+ .disabled,
51
+ .disabled label {
52
+ border-color: var(--disabled-color);
53
+ cursor: not-allowed;
54
+ pointer-events: none;
55
+ color: var(--disabled-color);
56
+ div {
57
+ background-color: var(--primary-color-shade);
58
+ }
59
+ }
60
+ .color_input {
61
+ border-radius: 100%;
62
+ height: 50px;
63
+ width: 50px;
64
+ }
65
+ .message {
66
+ color: var(--danger-color);
67
+ font-size: small;
68
+ }
69
+
70
+ @keyframes shake {
71
+ 0% {
72
+ transform: translateX(0);
73
+ }
74
+ 25% {
75
+ transform: translateX(-5px) rotate(0.5deg);
76
+ }
77
+ 50% {
78
+ transform: translateX(5px) rotate(-0.5deg);
79
+ }
80
+ 75% {
81
+ transform: translateX(-3px) rotate(0.3deg);
82
+ }
83
+ 100% {
84
+ transform: translateX(0);
85
+ }
86
+ }
87
+
88
+ .error {
89
+ --primary-color: var(--danger-color);
90
+ animation: shake 0.5s infinite; /* Establece la animación y su duración */
91
+ }
@@ -1,4 +1,4 @@
1
- <div class="slice_input">
2
- <label class="slice_input_placeholder"></label>
3
- <input class="input_area" type="text" />
4
- </div>
1
+ <div class="slice_input">
2
+ <label class="slice_input_placeholder"></label>
3
+ <input class="input_area" type="text" />
4
+ </div>
@@ -1,215 +1,215 @@
1
- export default class Input extends HTMLElement {
2
- constructor(props) {
3
- super();
4
- slice.attachTemplate(this);
5
- this.$inputContainer = this.querySelector('.slice_input');
6
- this.$input = this.querySelector('.input_area');
7
- this.$placeholder = this.querySelector('.slice_input_placeholder');
8
-
9
- this.$inputContainer.addEventListener('click', () => {
10
- this.$input.focus(); // Hacer que el input obtenga el foco al hacer clic en el contenedor
11
- });
12
-
13
- slice.controller.setComponentProps(this, props);
14
- this.debuggerProps = ['value', 'placeholder', 'type', 'required', 'conditions', 'disabled', 'secret'];
15
- }
16
-
17
- get placeholder() {
18
- return this._placeholder;
19
- }
20
-
21
- set placeholder(value) {
22
- this._placeholder = value;
23
- this.$placeholder.textContent = value;
24
- }
25
-
26
- get value() {
27
- return this.$input.value;
28
- }
29
-
30
- set value(value) {
31
- if (value) {
32
- this._value = value;
33
- this.$input.value = value;
34
- this.$placeholder.classList.add('slice_input_value');
35
- } else {
36
- this.$placeholder.classList.remove('slice_input_value');
37
- this.$input.value = '';
38
- }
39
- }
40
-
41
- get type() {
42
- return this._type;
43
- }
44
-
45
- set type(value) {
46
- const allowedTypes = ['text', 'password', 'email', 'number', 'date'];
47
-
48
- if (!allowedTypes.includes(value)) {
49
- throw new Error(`This type is not allowed: ${value}`);
50
- }
51
-
52
- this._type = value;
53
- this.$input.type = value;
54
- if (value === 'date') {
55
- this.$placeholder.classList.add('slice_input_value');
56
- }
57
- }
58
-
59
- get required() {
60
- return this._required;
61
- }
62
-
63
- set required(boolean) {
64
- this._required = boolean;
65
- this.$input.required = boolean;
66
- }
67
-
68
- get disabled() {
69
- return this._disabled;
70
- }
71
-
72
- set disabled(boolean) {
73
- this._disabled = boolean;
74
- this.$input.disabled = boolean;
75
- if (boolean) {
76
- this.$inputContainer.classList.add('disabled');
77
- } else {
78
- this.$inputContainer.classList.remove('disabled');
79
- }
80
- }
81
-
82
- get secret() {
83
- return this._secret;
84
- }
85
-
86
- set secret(boolean) {
87
- this._secret = boolean;
88
- if (boolean) {
89
- this.$input.type = 'password';
90
- if (!this.querySelector('.eye')) {
91
- const reveal = document.createElement('label');
92
-
93
- const eyeSlash = `<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
94
- <path stroke="var(--primary-color)" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M3.933 13.909A4.357 4.357 0 0 1 3 12c0-1 4-6 9-6m7.6 3.8A5.068 5.068 0 0 1 21 12c0 1-3 6-9 6-.314 0-.62-.014-.918-.04M5 19 19 5m-4 7a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/>
95
- </svg>`;
96
- const eye = `<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
97
- <path stroke="var(--primary-color)" stroke-width="1.5" d="M21 12c0 1.2-4.03 6-9 6s-9-4.8-9-6c0-1.2 4.03-6 9-6s9 4.8 9 6Z"/>
98
- <path stroke="var(--primary-color)" stroke-width="1.5" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/>
99
- </svg>`;
100
-
101
- reveal.classList.add('eye');
102
- reveal.innerHTML = eye;
103
- reveal.addEventListener('click', () => {
104
- if (this.$input.type === 'password') {
105
- this.$input.type = 'text';
106
- reveal.innerHTML = eyeSlash;
107
- } else {
108
- this.$input.type = 'password';
109
- reveal.innerHTML = eye;
110
- }
111
- });
112
- this.$inputContainer.appendChild(reveal);
113
- } else {
114
- this.querySelector('.eye').remove();
115
- }
116
- }
117
- }
118
-
119
- get conditions() {
120
- return this._conditions;
121
- }
122
-
123
- set conditions(value) {
124
- const {
125
- regex = '',
126
- minLength = 0,
127
- maxLength = '',
128
- minMinusc = 0,
129
- maxMinusc = '',
130
- minMayusc = 0,
131
- maxMayusc = '',
132
- minNumber = 0,
133
- maxNumber = '',
134
- minSymbol = 0,
135
- maxSymbol = '',
136
- } = value;
137
-
138
- let regexPattern = '';
139
-
140
- if (regex !== '') {
141
- regexPattern = regex;
142
- } else {
143
- regexPattern =
144
- `^(?=.*[a-z]{${minMinusc},${maxMinusc}})` +
145
- `(?=.*[A-Z]{${minMayusc},${maxMayusc}})` +
146
- `(?=.*\\d{${minNumber},${maxNumber}})` +
147
- `(?=.*[\\W$]{${minSymbol},${maxSymbol}})` +
148
- `.{${minLength},${maxLength}}$`;
149
- }
150
-
151
- this._conditions = new RegExp(regexPattern);
152
- }
153
-
154
- init() {
155
- if (!this.type) {
156
- this.type = 'text';
157
- }
158
-
159
- if (!this.disabled) {
160
- this._disabled = false;
161
- }
162
-
163
- if (!this.required) {
164
- this._required = false;
165
- }
166
-
167
- this.$input.addEventListener('input', () => {
168
- this.update();
169
- });
170
- }
171
-
172
- update() {
173
- if (this.$input.value !== '' || !undefined) {
174
- if (this.$input.value !== '') {
175
- this.$placeholder.classList.add('slice_input_value');
176
- this.triggerSuccess();
177
- } else {
178
- this.$placeholder.classList.remove('slice_input_value');
179
- if (this.required) {
180
- this.triggerError();
181
- }
182
- }
183
- }
184
- }
185
-
186
- validateValue() {
187
- if (this._conditions && !this._conditions.test(this.$input.value)) {
188
- this.triggerError();
189
- return false;
190
- }
191
- this.triggerSuccess();
192
- return true;
193
- }
194
-
195
- clear() {
196
- if (this.$input.value !== '') {
197
- this.$input.value = '';
198
- this.$placeholder.className = 'slice_input_placeholder';
199
- }
200
- }
201
-
202
- triggerSuccess() {
203
- this.$inputContainer.classList.remove('required');
204
- }
205
-
206
- triggerError() {
207
- this.$inputContainer.classList.add('error');
208
- this.$inputContainer.classList.add('required');
209
- setTimeout(() => {
210
- this.$inputContainer.classList.remove('error');
211
- }, 500);
212
- }
213
- }
214
-
215
- customElements.define('slice-input', Input);
1
+ export default class Input extends HTMLElement {
2
+ constructor(props) {
3
+ super();
4
+ slice.attachTemplate(this);
5
+ this.$inputContainer = this.querySelector('.slice_input');
6
+ this.$input = this.querySelector('.input_area');
7
+ this.$placeholder = this.querySelector('.slice_input_placeholder');
8
+
9
+ this.$inputContainer.addEventListener('click', () => {
10
+ this.$input.focus(); // Hacer que el input obtenga el foco al hacer clic en el contenedor
11
+ });
12
+
13
+ slice.controller.setComponentProps(this, props);
14
+ this.debuggerProps = ['value', 'placeholder', 'type', 'required', 'conditions', 'disabled', 'secret'];
15
+ }
16
+
17
+ get placeholder() {
18
+ return this._placeholder;
19
+ }
20
+
21
+ set placeholder(value) {
22
+ this._placeholder = value;
23
+ this.$placeholder.textContent = value;
24
+ }
25
+
26
+ get value() {
27
+ return this.$input.value;
28
+ }
29
+
30
+ set value(value) {
31
+ if (value) {
32
+ this._value = value;
33
+ this.$input.value = value;
34
+ this.$placeholder.classList.add('slice_input_value');
35
+ } else {
36
+ this.$placeholder.classList.remove('slice_input_value');
37
+ this.$input.value = '';
38
+ }
39
+ }
40
+
41
+ get type() {
42
+ return this._type;
43
+ }
44
+
45
+ set type(value) {
46
+ const allowedTypes = ['text', 'password', 'email', 'number', 'date'];
47
+
48
+ if (!allowedTypes.includes(value)) {
49
+ throw new Error(`This type is not allowed: ${value}`);
50
+ }
51
+
52
+ this._type = value;
53
+ this.$input.type = value;
54
+ if (value === 'date') {
55
+ this.$placeholder.classList.add('slice_input_value');
56
+ }
57
+ }
58
+
59
+ get required() {
60
+ return this._required;
61
+ }
62
+
63
+ set required(boolean) {
64
+ this._required = boolean;
65
+ this.$input.required = boolean;
66
+ }
67
+
68
+ get disabled() {
69
+ return this._disabled;
70
+ }
71
+
72
+ set disabled(boolean) {
73
+ this._disabled = boolean;
74
+ this.$input.disabled = boolean;
75
+ if (boolean) {
76
+ this.$inputContainer.classList.add('disabled');
77
+ } else {
78
+ this.$inputContainer.classList.remove('disabled');
79
+ }
80
+ }
81
+
82
+ get secret() {
83
+ return this._secret;
84
+ }
85
+
86
+ set secret(boolean) {
87
+ this._secret = boolean;
88
+ if (boolean) {
89
+ this.$input.type = 'password';
90
+ if (!this.querySelector('.eye')) {
91
+ const reveal = document.createElement('label');
92
+
93
+ const eyeSlash = `<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
94
+ <path stroke="var(--primary-color)" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M3.933 13.909A4.357 4.357 0 0 1 3 12c0-1 4-6 9-6m7.6 3.8A5.068 5.068 0 0 1 21 12c0 1-3 6-9 6-.314 0-.62-.014-.918-.04M5 19 19 5m-4 7a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/>
95
+ </svg>`;
96
+ const eye = `<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
97
+ <path stroke="var(--primary-color)" stroke-width="1.5" d="M21 12c0 1.2-4.03 6-9 6s-9-4.8-9-6c0-1.2 4.03-6 9-6s9 4.8 9 6Z"/>
98
+ <path stroke="var(--primary-color)" stroke-width="1.5" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/>
99
+ </svg>`;
100
+
101
+ reveal.classList.add('eye');
102
+ reveal.innerHTML = eye;
103
+ reveal.addEventListener('click', () => {
104
+ if (this.$input.type === 'password') {
105
+ this.$input.type = 'text';
106
+ reveal.innerHTML = eyeSlash;
107
+ } else {
108
+ this.$input.type = 'password';
109
+ reveal.innerHTML = eye;
110
+ }
111
+ });
112
+ this.$inputContainer.appendChild(reveal);
113
+ } else {
114
+ this.querySelector('.eye').remove();
115
+ }
116
+ }
117
+ }
118
+
119
+ get conditions() {
120
+ return this._conditions;
121
+ }
122
+
123
+ set conditions(value) {
124
+ const {
125
+ regex = '',
126
+ minLength = 0,
127
+ maxLength = '',
128
+ minMinusc = 0,
129
+ maxMinusc = '',
130
+ minMayusc = 0,
131
+ maxMayusc = '',
132
+ minNumber = 0,
133
+ maxNumber = '',
134
+ minSymbol = 0,
135
+ maxSymbol = '',
136
+ } = value;
137
+
138
+ let regexPattern = '';
139
+
140
+ if (regex !== '') {
141
+ regexPattern = regex;
142
+ } else {
143
+ regexPattern =
144
+ `^(?=.*[a-z]{${minMinusc},${maxMinusc}})` +
145
+ `(?=.*[A-Z]{${minMayusc},${maxMayusc}})` +
146
+ `(?=.*\\d{${minNumber},${maxNumber}})` +
147
+ `(?=.*[\\W$]{${minSymbol},${maxSymbol}})` +
148
+ `.{${minLength},${maxLength}}$`;
149
+ }
150
+
151
+ this._conditions = new RegExp(regexPattern);
152
+ }
153
+
154
+ init() {
155
+ if (!this.type) {
156
+ this.type = 'text';
157
+ }
158
+
159
+ if (!this.disabled) {
160
+ this._disabled = false;
161
+ }
162
+
163
+ if (!this.required) {
164
+ this._required = false;
165
+ }
166
+
167
+ this.$input.addEventListener('input', () => {
168
+ this.update();
169
+ });
170
+ }
171
+
172
+ update() {
173
+ if (this.$input.value !== '' || !undefined) {
174
+ if (this.$input.value !== '') {
175
+ this.$placeholder.classList.add('slice_input_value');
176
+ this.triggerSuccess();
177
+ } else {
178
+ this.$placeholder.classList.remove('slice_input_value');
179
+ if (this.required) {
180
+ this.triggerError();
181
+ }
182
+ }
183
+ }
184
+ }
185
+
186
+ validateValue() {
187
+ if (this._conditions && !this._conditions.test(this.$input.value)) {
188
+ this.triggerError();
189
+ return false;
190
+ }
191
+ this.triggerSuccess();
192
+ return true;
193
+ }
194
+
195
+ clear() {
196
+ if (this.$input.value !== '') {
197
+ this.$input.value = '';
198
+ this.$placeholder.className = 'slice_input_placeholder';
199
+ }
200
+ }
201
+
202
+ triggerSuccess() {
203
+ this.$inputContainer.classList.remove('required');
204
+ }
205
+
206
+ triggerError() {
207
+ this.$inputContainer.classList.add('error');
208
+ this.$inputContainer.classList.add('required');
209
+ setTimeout(() => {
210
+ this.$inputContainer.classList.remove('error');
211
+ }, 500);
212
+ }
213
+ }
214
+
215
+ customElements.define('slice-input', Input);