slicejs-cli 2.0.5 → 2.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.
- package/ProjectTemplate/api/index.js +97 -0
- package/ProjectTemplate/src/App/index.html +22 -0
- package/ProjectTemplate/src/App/index.js +63 -0
- package/ProjectTemplate/src/App/style.css +40 -0
- package/ProjectTemplate/src/Components/AppComponents/ButtonDocumentation/ButtonDocumentation.css +16 -0
- package/ProjectTemplate/src/Components/AppComponents/ButtonDocumentation/ButtonDocumentation.html +22 -0
- package/ProjectTemplate/src/Components/AppComponents/ButtonDocumentation/ButtonDocumentation.js +102 -0
- package/ProjectTemplate/src/Components/AppComponents/CardDocumentation/CardDocumentation.css +15 -0
- package/ProjectTemplate/src/Components/AppComponents/CardDocumentation/CardDocumentation.html +38 -0
- package/ProjectTemplate/src/Components/AppComponents/CardDocumentation/CardDocumentation.js +113 -0
- package/ProjectTemplate/src/Components/AppComponents/CheckboxDocumentation/CheckboxDocumentation.css +21 -0
- package/ProjectTemplate/src/Components/AppComponents/CheckboxDocumentation/CheckboxDocumentation.html +35 -0
- package/ProjectTemplate/src/Components/AppComponents/CheckboxDocumentation/CheckboxDocumentation.js +103 -0
- package/ProjectTemplate/src/Components/AppComponents/CodeVisualizer/CodeVisualizer.css +14 -0
- package/ProjectTemplate/src/Components/AppComponents/CodeVisualizer/CodeVisualizer.html +3 -0
- package/ProjectTemplate/src/Components/AppComponents/CodeVisualizer/CodeVisualizer.js +45 -0
- package/ProjectTemplate/src/Components/AppComponents/Documentation/Documentation.css +0 -0
- package/ProjectTemplate/src/Components/AppComponents/Documentation/Documentation.html +30 -0
- package/ProjectTemplate/src/Components/AppComponents/Documentation/Documentation.js +75 -0
- package/ProjectTemplate/src/Components/AppComponents/DocumentationPage/DocumentationPage.css +62 -0
- package/ProjectTemplate/src/Components/AppComponents/DocumentationPage/DocumentationPage.html +0 -0
- package/ProjectTemplate/src/Components/AppComponents/DocumentationPage/DocumentationPage.js +241 -0
- package/ProjectTemplate/src/Components/AppComponents/InputDocumentation/InputDocumentation.css +41 -0
- package/ProjectTemplate/src/Components/AppComponents/InputDocumentation/InputDocumentation.html +95 -0
- package/ProjectTemplate/src/Components/AppComponents/InputDocumentation/InputDocumentation.js +315 -0
- package/ProjectTemplate/src/Components/AppComponents/LandingMenu/LandingMenu.css +108 -0
- package/ProjectTemplate/src/Components/AppComponents/LandingMenu/LandingMenu.html +16 -0
- package/ProjectTemplate/src/Components/AppComponents/LandingMenu/LandingMenu.js +33 -0
- package/ProjectTemplate/src/Components/AppComponents/LandingPage/LandingPage.css +14 -0
- package/ProjectTemplate/src/Components/AppComponents/LandingPage/LandingPage.html +0 -0
- package/ProjectTemplate/src/Components/AppComponents/LandingPage/LandingPage.js +53 -0
- package/ProjectTemplate/src/Components/AppComponents/MainMenu/MainMenu.css +80 -0
- package/ProjectTemplate/src/Components/AppComponents/MainMenu/MainMenu.html +39 -0
- package/ProjectTemplate/src/Components/AppComponents/MainMenu/MainMenu.js +42 -0
- package/ProjectTemplate/src/Components/AppComponents/MyLayout/MyLayout.css +0 -0
- package/ProjectTemplate/src/Components/AppComponents/MyLayout/MyLayout.html +0 -0
- package/ProjectTemplate/src/Components/AppComponents/MyLayout/MyLayout.js +13 -0
- package/ProjectTemplate/src/Components/AppComponents/MyNavigation/MyNavigation.css +49 -0
- package/ProjectTemplate/src/Components/AppComponents/MyNavigation/MyNavigation.html +1 -0
- package/ProjectTemplate/src/Components/AppComponents/MyNavigation/MyNavigation.js +60 -0
- package/ProjectTemplate/src/Components/AppComponents/Playground/Playground.css +12 -0
- package/ProjectTemplate/src/Components/AppComponents/Playground/Playground.html +0 -0
- package/ProjectTemplate/src/Components/AppComponents/Playground/Playground.js +126 -0
- package/ProjectTemplate/src/Components/AppComponents/SliceTeamCard/SliceTeamCard.css +104 -0
- package/ProjectTemplate/src/Components/AppComponents/SliceTeamCard/SliceTeamCard.html +12 -0
- package/ProjectTemplate/src/Components/AppComponents/SliceTeamCard/SliceTeamCard.js +74 -0
- package/ProjectTemplate/src/Components/AppComponents/SwitchDocumentation/SwitchDocumentation.css +21 -0
- package/ProjectTemplate/src/Components/AppComponents/SwitchDocumentation/SwitchDocumentation.html +35 -0
- package/ProjectTemplate/src/Components/AppComponents/SwitchDocumentation/SwitchDocumentation.js +103 -0
- package/ProjectTemplate/src/Components/AppComponents/TheSliceTeam/TheSliceTeam.css +23 -0
- package/ProjectTemplate/src/Components/AppComponents/TheSliceTeam/TheSliceTeam.html +6 -0
- package/ProjectTemplate/src/Components/AppComponents/TheSliceTeam/TheSliceTeam.js +129 -0
- package/ProjectTemplate/src/Components/AppComponents/WhatIsSlice/WhatIsSlice.css +0 -0
- package/ProjectTemplate/src/Components/AppComponents/WhatIsSlice/WhatIsSlice.html +7 -0
- package/ProjectTemplate/src/Components/AppComponents/WhatIsSlice/WhatIsSlice.js +15 -0
- package/ProjectTemplate/src/Components/Service/FetchManager/FetchManager.js +133 -0
- package/ProjectTemplate/src/Components/Service/IndexedDbManager/IndexedDbManager.js +141 -0
- package/ProjectTemplate/src/Components/Service/Link/Link.js +26 -0
- package/ProjectTemplate/src/Components/Visual/Button/Button.css +47 -0
- package/ProjectTemplate/src/Components/Visual/Button/Button.html +5 -0
- package/ProjectTemplate/src/Components/Visual/Button/Button.js +70 -0
- package/ProjectTemplate/src/Components/Visual/Card/Card.css +68 -0
- package/ProjectTemplate/src/Components/Visual/Card/Card.html +7 -0
- package/ProjectTemplate/src/Components/Visual/Card/Card.js +107 -0
- package/ProjectTemplate/src/Components/Visual/Checkbox/Checkbox.css +87 -0
- package/ProjectTemplate/src/Components/Visual/Checkbox/Checkbox.html +8 -0
- package/ProjectTemplate/src/Components/Visual/Checkbox/Checkbox.js +86 -0
- package/ProjectTemplate/src/Components/Visual/Details/Details.css +70 -0
- package/ProjectTemplate/src/Components/Visual/Details/Details.html +9 -0
- package/ProjectTemplate/src/Components/Visual/Details/Details.js +76 -0
- package/ProjectTemplate/src/Components/Visual/DropDown/DropDown.css +60 -0
- package/ProjectTemplate/src/Components/Visual/DropDown/DropDown.html +5 -0
- package/ProjectTemplate/src/Components/Visual/DropDown/DropDown.js +63 -0
- package/ProjectTemplate/src/Components/Visual/Grid/Grid.css +7 -0
- package/ProjectTemplate/src/Components/Visual/Grid/Grid.html +1 -0
- package/ProjectTemplate/src/Components/Visual/Grid/Grid.js +57 -0
- package/ProjectTemplate/src/Components/Visual/Icon/Icon.css +510 -0
- package/ProjectTemplate/src/Components/Visual/Icon/Icon.html +1 -0
- package/ProjectTemplate/src/Components/Visual/Icon/Icon.js +89 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.eot +0 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.json +555 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.styl +507 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.svg +1485 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.symbol.svg +1059 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.ttf +0 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.woff +0 -0
- package/ProjectTemplate/src/Components/Visual/Icon/slc.woff2 +0 -0
- package/ProjectTemplate/src/Components/Visual/Input/Input.css +91 -0
- package/ProjectTemplate/src/Components/Visual/Input/Input.html +4 -0
- package/ProjectTemplate/src/Components/Visual/Input/Input.js +215 -0
- package/ProjectTemplate/src/Components/Visual/Layout/Layout.css +0 -0
- package/ProjectTemplate/src/Components/Visual/Layout/Layout.html +0 -0
- package/ProjectTemplate/src/Components/Visual/Layout/Layout.js +49 -0
- package/ProjectTemplate/src/Components/Visual/Loading/Loading.css +56 -0
- package/ProjectTemplate/src/Components/Visual/Loading/Loading.html +83 -0
- package/ProjectTemplate/src/Components/Visual/Loading/Loading.js +38 -0
- package/ProjectTemplate/src/Components/Visual/MultiRoute/MultiRoute.js +93 -0
- package/ProjectTemplate/src/Components/Visual/Navbar/Navbar.css +115 -0
- package/ProjectTemplate/src/Components/Visual/Navbar/Navbar.html +44 -0
- package/ProjectTemplate/src/Components/Visual/Navbar/Navbar.js +141 -0
- package/ProjectTemplate/src/Components/Visual/NotFound/NotFound.css +117 -0
- package/ProjectTemplate/src/Components/Visual/NotFound/NotFound.html +24 -0
- package/ProjectTemplate/src/Components/Visual/NotFound/NotFound.js +16 -0
- package/ProjectTemplate/src/Components/Visual/Route/Route.js +93 -0
- package/ProjectTemplate/src/Components/Visual/Select/Select.css +84 -0
- package/ProjectTemplate/src/Components/Visual/Select/Select.html +8 -0
- package/ProjectTemplate/src/Components/Visual/Select/Select.js +195 -0
- package/ProjectTemplate/src/Components/Visual/Switch/Switch.css +76 -0
- package/ProjectTemplate/src/Components/Visual/Switch/Switch.html +8 -0
- package/ProjectTemplate/src/Components/Visual/Switch/Switch.js +102 -0
- package/ProjectTemplate/src/Components/Visual/TreeItem/TreeItem.css +36 -0
- package/ProjectTemplate/src/Components/Visual/TreeItem/TreeItem.html +1 -0
- package/ProjectTemplate/src/Components/Visual/TreeItem/TreeItem.js +126 -0
- package/ProjectTemplate/src/Components/Visual/TreeView/TreeView.css +8 -0
- package/ProjectTemplate/src/Components/Visual/TreeView/TreeView.html +1 -0
- package/ProjectTemplate/src/Components/Visual/TreeView/TreeView.js +48 -0
- package/ProjectTemplate/src/Components/components.js +42 -0
- package/ProjectTemplate/src/Styles/sliceStyles.css +34 -0
- package/ProjectTemplate/src/Themes/Dark.css +42 -0
- package/ProjectTemplate/src/Themes/Light.css +31 -0
- package/ProjectTemplate/src/Themes/Slice.css +47 -0
- package/ProjectTemplate/src/images/Slice.js-logo.png +0 -0
- package/ProjectTemplate/src/images/favicon.ico +0 -0
- package/ProjectTemplate/src/images/im2/Slice.js-logo.png +0 -0
- package/ProjectTemplate/src/routes.js +36 -0
- package/ProjectTemplate/src/sliceConfig.json +58 -0
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.slice_select_dropdown {
|
|
2
|
+
font-family: var(--font-family);
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
margin-bottom: 25px;
|
|
5
|
+
margin-top: 25px;
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
.slice_select_container {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
display: flex;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
border-radius: var(--border-radius-slice);
|
|
13
|
+
border: var(--slice-border) solid var(--primary-color);
|
|
14
|
+
background-color: var(--primary-background-color);
|
|
15
|
+
justify-content: space-between;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
.slice_select {
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
color: var(--font-primary-color);
|
|
21
|
+
width: 100%;
|
|
22
|
+
background: none;
|
|
23
|
+
outline: none;
|
|
24
|
+
border: none;
|
|
25
|
+
}
|
|
26
|
+
.slice_select_label {
|
|
27
|
+
color: var(--primary-color);
|
|
28
|
+
position: absolute;
|
|
29
|
+
transition: all 0.5s;
|
|
30
|
+
user-select: none;
|
|
31
|
+
}
|
|
32
|
+
.slice_select_value {
|
|
33
|
+
scale: 0.8;
|
|
34
|
+
transform: translateY(-200%);
|
|
35
|
+
transition: all 0.5s;
|
|
36
|
+
}
|
|
37
|
+
.slice_select_menu {
|
|
38
|
+
display: none;
|
|
39
|
+
border: var(--slice-border) solid var(--primary-color);
|
|
40
|
+
list-style: none;
|
|
41
|
+
font-family: var(--font-family);
|
|
42
|
+
visibility: hidden;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
position: absolute;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transition: 0s, opacity 0.3s;
|
|
47
|
+
top: 100%;
|
|
48
|
+
width: 100%;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
background-color: var(--primary-background-color);
|
|
51
|
+
border-radius: var(--border-radius-slice);
|
|
52
|
+
box-shadow: 0 0 10px 0 #00000050;
|
|
53
|
+
div {
|
|
54
|
+
color: var(--font-primary-color);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
padding: 10px;
|
|
57
|
+
&:hover {
|
|
58
|
+
color: var(--secondary-color-contrast);
|
|
59
|
+
background-color: var(--secondary-color);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
.menu_open {
|
|
64
|
+
display: block;
|
|
65
|
+
overflow-y: scroll;
|
|
66
|
+
min-height: min-content;
|
|
67
|
+
max-height: 400%;
|
|
68
|
+
visibility: visible;
|
|
69
|
+
opacity: 1;
|
|
70
|
+
}
|
|
71
|
+
.menu_open::-webkit-scrollbar {
|
|
72
|
+
width: 5px;
|
|
73
|
+
}
|
|
74
|
+
.menu_open::-webkit-scrollbar-thumb {
|
|
75
|
+
background: var(--secondary-color);
|
|
76
|
+
border-radius: var(--border-radius-slice);
|
|
77
|
+
}
|
|
78
|
+
.active {
|
|
79
|
+
/* color: var(--primary-color); */
|
|
80
|
+
background-color: var(--secondary-background-color);
|
|
81
|
+
}
|
|
82
|
+
.slice_select_container .caret {
|
|
83
|
+
border-top-color: var(--primary-color);
|
|
84
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export default class Select extends HTMLElement {
|
|
2
|
+
constructor(props) {
|
|
3
|
+
super();
|
|
4
|
+
slice.attachTemplate(this);
|
|
5
|
+
this.$dropdown = this.querySelector('.slice_select_dropdown');
|
|
6
|
+
this.$selectContainer = this.querySelector('.slice_select_container');
|
|
7
|
+
this.$label = this.querySelector('.slice_select_label');
|
|
8
|
+
this.$select = this.querySelector('.slice_select');
|
|
9
|
+
this.$menu = this.querySelector('.slice_select_menu');
|
|
10
|
+
this.$caret = this.querySelector('.caret');
|
|
11
|
+
|
|
12
|
+
this.$selectContainer.addEventListener('click', () => {
|
|
13
|
+
this.$menu.classList.toggle('menu_open');
|
|
14
|
+
this.$caret.classList.toggle('caret_open');
|
|
15
|
+
});
|
|
16
|
+
this.$dropdown.addEventListener('mouseleave', () => {
|
|
17
|
+
this.$menu.classList.remove('menu_open');
|
|
18
|
+
this.$caret.classList.remove('caret_open');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (props.visibleProp) {
|
|
22
|
+
this.visibleProp = props.visibleProp;
|
|
23
|
+
}
|
|
24
|
+
this._value = [];
|
|
25
|
+
|
|
26
|
+
if (props.onOptionSelect) {
|
|
27
|
+
this.onOptionSelect = props.onOptionSelect;
|
|
28
|
+
}
|
|
29
|
+
slice.controller.setComponentProps(this, props);
|
|
30
|
+
this.debuggerProps = ['options', 'disabled', 'label', 'multiple', 'visibleProp'];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
init() {
|
|
34
|
+
if (!this.disabled) {
|
|
35
|
+
this._disabled = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!this._multiple) {
|
|
39
|
+
this._multiple = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get options() {
|
|
44
|
+
return this._options;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
removeOptionFromValue(option) {
|
|
48
|
+
const optionIndex = this.isObjectInArray(option, this._value).index;
|
|
49
|
+
if (optionIndex !== -1) {
|
|
50
|
+
this._value.splice(optionIndex, 1);
|
|
51
|
+
// Actualizar la representación visual en el elemento select
|
|
52
|
+
this.updateSelectLabel();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this._value.length === 0) {
|
|
56
|
+
this.$label.classList.remove('slice_select_value');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
updateSelectLabel() {
|
|
61
|
+
// Limpiar el contenido actual del elemento select
|
|
62
|
+
this.$select.value = '';
|
|
63
|
+
|
|
64
|
+
// Volver a agregar los valores seleccionados
|
|
65
|
+
if (this._value.length > 0) {
|
|
66
|
+
this.$select.value = this._value.map((option) => option[this.visibleProp]).join(', ');
|
|
67
|
+
this.$label.classList.add('slice_select_value');
|
|
68
|
+
} else {
|
|
69
|
+
this.$label.classList.remove('slice_select_value');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
addSelectedOption(option) {
|
|
74
|
+
this._value.push(option);
|
|
75
|
+
this.updateSelectLabel();
|
|
76
|
+
this.$label.classList.add('slice_select_value');
|
|
77
|
+
if (!this.multiple) {
|
|
78
|
+
this.$menu.classList.remove('menu_open');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
set options(values) {
|
|
83
|
+
this._options = values;
|
|
84
|
+
values.forEach((option) => {
|
|
85
|
+
const opt = document.createElement('div');
|
|
86
|
+
opt.textContent = option[this.visibleProp];
|
|
87
|
+
opt.addEventListener('click', async () => {
|
|
88
|
+
if (this.$menu.querySelector('.active') && !this.multiple) {
|
|
89
|
+
this.$menu.querySelector('.active').classList.remove('active');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this._value.length === 1 && !this.multiple) {
|
|
93
|
+
this.removeOptionFromValue(this._value[0]);
|
|
94
|
+
this.addSelectedOption(option);
|
|
95
|
+
if (this.onOptionSelect) await this.onOptionSelect();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.isObjectInArray(option, this._value).found) {
|
|
100
|
+
this.removeOptionFromValue(option);
|
|
101
|
+
opt.classList.remove('active');
|
|
102
|
+
} else {
|
|
103
|
+
this.addSelectedOption(option);
|
|
104
|
+
opt.classList.add('active');
|
|
105
|
+
}
|
|
106
|
+
if (this.onOptionSelect) await this.onOptionSelect();
|
|
107
|
+
});
|
|
108
|
+
this.$menu.appendChild(opt);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get value() {
|
|
113
|
+
if (this._value.length === 1) {
|
|
114
|
+
return this._value[0];
|
|
115
|
+
}
|
|
116
|
+
return this._value;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
set value(valueParam) {
|
|
120
|
+
this._value = [];
|
|
121
|
+
|
|
122
|
+
if (valueParam.length > 1 && !this.multiple) {
|
|
123
|
+
return console.error('Select is not multiple, you can only select one option');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const validOptions = valueParam.every((option) => this.isObjectInArray(option, this._options).found);
|
|
127
|
+
|
|
128
|
+
if (!validOptions) {
|
|
129
|
+
console.error('Error: Al menos una de las opciones proporcionadas no está en this.options.');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Agregar las opciones a _value
|
|
134
|
+
this.$label.classList.add('slice_select_value');
|
|
135
|
+
valueParam.forEach((option) => this.addSelectedOption(option));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get label() {
|
|
139
|
+
return this._label;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
set label(value) {
|
|
143
|
+
this._label = value;
|
|
144
|
+
this.$label.textContent = value;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
get multiple() {
|
|
148
|
+
return this._multiple;
|
|
149
|
+
}
|
|
150
|
+
set multiple(value) {
|
|
151
|
+
this._multiple = value;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
get disabled() {
|
|
155
|
+
return this._disabled;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
set disabled(value) {
|
|
159
|
+
this._disabled = value;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
isObjectInArray(objeto, arreglo) {
|
|
163
|
+
for (let i = 0; i < arreglo.length; i++) {
|
|
164
|
+
if (this.sameObject(arreglo[i], objeto)) {
|
|
165
|
+
return { found: true, index: i };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { found: false, index: -1 };
|
|
169
|
+
}
|
|
170
|
+
sameObject(objetoA, objetoB) {
|
|
171
|
+
const keysA = Object.keys(objetoA);
|
|
172
|
+
const keysB = Object.keys(objetoB);
|
|
173
|
+
|
|
174
|
+
if (keysA.length !== keysB.length) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
for (const key of keysA) {
|
|
179
|
+
const valueA = objetoA[key];
|
|
180
|
+
const valueB = objetoB[key];
|
|
181
|
+
|
|
182
|
+
if (typeof valueA === 'object' && typeof valueB === 'object') {
|
|
183
|
+
if (!this.sameObject(valueA, valueB)) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
} else if (valueA !== valueB) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
customElements.define('slice-select', Select);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.slice_switch {
|
|
2
|
+
--button-width: calc(var(--button-height) * 2);
|
|
3
|
+
--button-height: 1.8em;
|
|
4
|
+
--toggle-diameter: calc(var(--button-width) / 3);
|
|
5
|
+
--button-toggle-offset: calc(
|
|
6
|
+
(var(--button-height) - var(--toggle-diameter)) / 2
|
|
7
|
+
);
|
|
8
|
+
--toggle-shadow-offset: 10px;
|
|
9
|
+
--toggle-wider: 1.8em;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.slice_switch_container {
|
|
13
|
+
width: fit-content;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.slice_switch {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: row;
|
|
19
|
+
align-items: center;
|
|
20
|
+
user-select: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.switch_label {
|
|
24
|
+
margin: 5px;
|
|
25
|
+
font-family: var(--font-family);
|
|
26
|
+
color: var(--font-primary-color);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.slider {
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
display: inline-block;
|
|
32
|
+
width: var(--button-width);
|
|
33
|
+
height: var(--button-height);
|
|
34
|
+
background-color: var(--secondary-background-color);
|
|
35
|
+
border: var(--slice-border) solid var(--primary-color);
|
|
36
|
+
border-radius: calc(var(--button-height) / 2);
|
|
37
|
+
position: relative;
|
|
38
|
+
transition: 0.3s all ease-in-out;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.slider::after {
|
|
42
|
+
content: "";
|
|
43
|
+
display: inline-block;
|
|
44
|
+
width: var(--toggle-diameter);
|
|
45
|
+
height: var(--toggle-diameter);
|
|
46
|
+
background-color: #fff;
|
|
47
|
+
border-radius: calc(var(--toggle-diameter) / 2);
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: var(--button-toggle-offset);
|
|
50
|
+
transform: translateX(var(--button-toggle-offset));
|
|
51
|
+
transition: 0.3s all ease-in-out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.slice_switch input[type="checkbox"]:checked + .slider {
|
|
55
|
+
background-color: var(--success-color);
|
|
56
|
+
border: var(--slice-border) solid var(--success-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.slice_switch input[type="checkbox"]:checked + .slider::after {
|
|
60
|
+
transform: translateX(
|
|
61
|
+
calc(
|
|
62
|
+
var(--button-width) - var(--toggle-diameter) - var(--button-toggle-offset)
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.slice_switch input[type="checkbox"] {
|
|
68
|
+
display: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.disabled {
|
|
72
|
+
border-color: var(--disabled-color);
|
|
73
|
+
background-color: var(--primary-color-shade);
|
|
74
|
+
color: var(--disabled-color);
|
|
75
|
+
cursor: not-allowed;
|
|
76
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export default class Switch extends HTMLElement {
|
|
2
|
+
constructor(props) {
|
|
3
|
+
super();
|
|
4
|
+
slice.attachTemplate(this);
|
|
5
|
+
this.$switch = this.querySelector('.slice_switch');
|
|
6
|
+
this.$checkbox = this.querySelector('input');
|
|
7
|
+
this.toggle = props.toggle;
|
|
8
|
+
if (this.toggle) {
|
|
9
|
+
this.$checkbox.addEventListener('click', () => this.toggle());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
slice.controller.setComponentProps(this, props);
|
|
13
|
+
this.debuggerProps = ['checked', 'disabled', 'label', 'customColor', 'labelPlacement'];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
init() {
|
|
17
|
+
if (this._checked === undefined) {
|
|
18
|
+
this.checked = false;
|
|
19
|
+
}
|
|
20
|
+
if (this.labelPlacement === undefined) {
|
|
21
|
+
this.labelPlacement = 'right';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!this.disabled) {
|
|
25
|
+
this._disabled = false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.querySelector('input').addEventListener('change', (e) => {
|
|
29
|
+
this.checked = e.target.checked;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get checked() {
|
|
34
|
+
return this._checked;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
set checked(value) {
|
|
38
|
+
this._checked = value;
|
|
39
|
+
this.$checkbox.checked = value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get label() {
|
|
43
|
+
return this._label;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
set label(value) {
|
|
47
|
+
this._label = value;
|
|
48
|
+
if (this.querySelector('.switch_label')) {
|
|
49
|
+
this.querySelector('.switch_label').textContent = value;
|
|
50
|
+
} else {
|
|
51
|
+
const label = document.createElement('label');
|
|
52
|
+
label.classList.add('switch_label');
|
|
53
|
+
label.textContent = value;
|
|
54
|
+
this.$switch.appendChild(label);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get customColor() {
|
|
59
|
+
return this._customColor;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
set customColor(value) {
|
|
63
|
+
this._customColor = value;
|
|
64
|
+
this.style = `--success-color: ${value};`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get labelPlacement() {
|
|
68
|
+
return this._labelPlacement;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
set labelPlacement(value) {
|
|
72
|
+
if (value === 'left') {
|
|
73
|
+
this.$switch.style = ` flex-direction: row-reverse;`;
|
|
74
|
+
}
|
|
75
|
+
if (value === 'right') {
|
|
76
|
+
this.$switch.style = `flex-direction: row;`;
|
|
77
|
+
}
|
|
78
|
+
if (value === 'top') {
|
|
79
|
+
this.$switch.style = `flex-direction: column-reverse;`;
|
|
80
|
+
}
|
|
81
|
+
if (value === 'bottom') {
|
|
82
|
+
this.$switch.style = `flex-direction: column;`;
|
|
83
|
+
}
|
|
84
|
+
this._labelPlacement = value;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get disabled() {
|
|
88
|
+
return this._disabled;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
set disabled(value) {
|
|
92
|
+
this._disabled = value;
|
|
93
|
+
this.$checkbox.disabled = value;
|
|
94
|
+
if (value === true) {
|
|
95
|
+
this.querySelector('.slider').classList.add('disabled');
|
|
96
|
+
} else {
|
|
97
|
+
this.querySelector('.slider').classList.remove('disabled');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
customElements.define('slice-switch', Switch);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.slice_tree_item,
|
|
2
|
+
.container_open .slice_tree_item {
|
|
3
|
+
color: var(--font-primary-color);
|
|
4
|
+
user-select: none;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
width: fit-content;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row-reverse;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding: 10px;
|
|
11
|
+
border-radius: var(--border-radius-slice);
|
|
12
|
+
}
|
|
13
|
+
.slice_tree_item .caret {
|
|
14
|
+
color: var(--primary-color);
|
|
15
|
+
margin-right: 5px;
|
|
16
|
+
transform: rotate(-90deg);
|
|
17
|
+
}
|
|
18
|
+
.slice_tree_item .caret_open {
|
|
19
|
+
transform: rotate(0deg);
|
|
20
|
+
}
|
|
21
|
+
.container {
|
|
22
|
+
margin-left: 14px;
|
|
23
|
+
border-left: 2px solid var(--primary-color);
|
|
24
|
+
height: 0;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
transition: height 0.3s ease;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.container_open {
|
|
30
|
+
height: auto; /* Esto se ajustará después de la transición */
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.slice_tree_item:hover {
|
|
34
|
+
background-color: #ffffff25;
|
|
35
|
+
color: var(--primary-color);
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<label class="slice_tree_item"></label>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export default class TreeItem extends HTMLElement {
|
|
2
|
+
constructor(props) {
|
|
3
|
+
super();
|
|
4
|
+
slice.attachTemplate(this);
|
|
5
|
+
|
|
6
|
+
this.$item = this.querySelector('.slice_tree_item');
|
|
7
|
+
|
|
8
|
+
this.debuggerProps = ['value', 'path', 'onClickCallback'];
|
|
9
|
+
slice.controller.setComponentProps(this, props);
|
|
10
|
+
|
|
11
|
+
if (props.onClickCallback) {
|
|
12
|
+
this.onClickCallback = props.onClickCallback;
|
|
13
|
+
this.$item.addEventListener('click', async () => {
|
|
14
|
+
await this.onClickCallback(this);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async init() {
|
|
20
|
+
if (this._items) {
|
|
21
|
+
for (let i = 0; i < this._items.length; i++) {
|
|
22
|
+
await this.setItem(this._items[i], this.$container);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Restaurar el estado del contenedor desde el localStorage
|
|
26
|
+
this.restoreState();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set value(value) {
|
|
30
|
+
this.$item.textContent = value;
|
|
31
|
+
this._value = value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get value() {
|
|
35
|
+
return this._value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
set path(value) {
|
|
39
|
+
this.$item.path = value;
|
|
40
|
+
this._path = value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get path() {
|
|
44
|
+
return this._path;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
set items(values) {
|
|
48
|
+
this._items = values;
|
|
49
|
+
const caret = document.createElement('div');
|
|
50
|
+
caret.classList.add('caret');
|
|
51
|
+
// Crear un contenedor para items
|
|
52
|
+
const container = document.createElement('div');
|
|
53
|
+
container.classList.add('container');
|
|
54
|
+
this.appendChild(container);
|
|
55
|
+
// Añadir
|
|
56
|
+
this.$container = container;
|
|
57
|
+
|
|
58
|
+
const toggleContainer = () => {
|
|
59
|
+
const isOpen = caret.classList.toggle('caret_open');
|
|
60
|
+
|
|
61
|
+
if (isOpen) {
|
|
62
|
+
// Calcular la altura completa del contenedor
|
|
63
|
+
const fullHeight = this.$container.scrollHeight + 'px';
|
|
64
|
+
|
|
65
|
+
// Establecer la altura para iniciar la animación
|
|
66
|
+
this.$container.style.height = fullHeight;
|
|
67
|
+
|
|
68
|
+
// Después de que la animación termine, ajustar la altura a 'auto'
|
|
69
|
+
this.$container.addEventListener('transitionend', function onTransitionEnd() {
|
|
70
|
+
this.style.height = 'auto';
|
|
71
|
+
this.removeEventListener('transitionend', onTransitionEnd);
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
// Establecer la altura para iniciar la animación de cierre
|
|
75
|
+
this.$container.style.height = this.$container.scrollHeight + 'px';
|
|
76
|
+
|
|
77
|
+
// Forzar el reflujo para que la transición funcione
|
|
78
|
+
requestAnimationFrame(() => {
|
|
79
|
+
this.$container.style.height = '0';
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Alternar la clase container_open
|
|
84
|
+
this.$container.classList.toggle('container_open');
|
|
85
|
+
|
|
86
|
+
// Guardar el estado en localStorage
|
|
87
|
+
localStorage.setItem(this.getContainerKey(), isOpen ? 'open' : 'closed');
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
caret.addEventListener('click', toggleContainer);
|
|
91
|
+
|
|
92
|
+
if (!this.path) {
|
|
93
|
+
this.$item.addEventListener('click', toggleContainer);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.$item.appendChild(caret);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getContainerKey() {
|
|
100
|
+
return `treeitem-${this._value}`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
restoreState() {
|
|
104
|
+
const state = localStorage.getItem(this.getContainerKey());
|
|
105
|
+
if (state === 'open') {
|
|
106
|
+
const caret = this.$item.querySelector('.caret');
|
|
107
|
+
if (caret) {
|
|
108
|
+
caret.classList.add('caret_open');
|
|
109
|
+
}
|
|
110
|
+
if (this.$container) {
|
|
111
|
+
this.$container.classList.add('container_open');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async setItem(value, addTo) {
|
|
117
|
+
if (this.onClickCallback) {
|
|
118
|
+
value.onClickCallback = this.onClickCallback;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const item = await slice.build('TreeItem', value);
|
|
122
|
+
addTo.appendChild(item);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
customElements.define('slice-treeitem', TreeItem);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="simple_treeview"></div>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export default class TreeView extends HTMLElement {
|
|
2
|
+
constructor(props) {
|
|
3
|
+
super();
|
|
4
|
+
slice.attachTemplate(this);
|
|
5
|
+
|
|
6
|
+
console.log(props);
|
|
7
|
+
this.$treeView = this.querySelector('.simple_treeview');
|
|
8
|
+
slice.controller.setComponentProps(this, props);
|
|
9
|
+
|
|
10
|
+
if (props.onClickCallback) {
|
|
11
|
+
this.onClickCallback = props.onClickCallback;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
this.debuggerProps = [];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async init() {
|
|
18
|
+
if (this.items) {
|
|
19
|
+
await this.setTreeItems(this.items);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
set items(values) {
|
|
24
|
+
this._items = values;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get items() {
|
|
28
|
+
return this._items;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async setTreeItem(item) {
|
|
32
|
+
if (this.onClickCallback) {
|
|
33
|
+
item.onClickCallback = this.onClickCallback;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const treeItem = await slice.build('TreeItem', item);
|
|
37
|
+
treeItem.classList.add('tree_item');
|
|
38
|
+
this.$treeView.appendChild(treeItem);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async setTreeItems(items) {
|
|
42
|
+
for (let i = 0; i < items.length; i++) {
|
|
43
|
+
await this.setTreeItem(items[i]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
customElements.define('slice-treeview', TreeView);
|