slicejs-web-framework 3.2.3 → 3.3.0
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/.opencode/opencode.json +13 -13
- package/LICENSE +21 -21
- package/README.md +97 -174
- package/Slice/Components/Structural/ContextManager/ContextManager.js +369 -369
- package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +420 -297
- package/Slice/Components/Structural/Controller/Controller.js +1131 -1131
- package/Slice/Components/Structural/Debugger/Debugger.html +72 -72
- package/Slice/Components/Structural/Debugger/Debugger.js +1497 -1547
- package/Slice/Components/Structural/EventManager/EventManager.js +338 -338
- package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +476 -361
- package/Slice/Components/Structural/Logger/Log.js +10 -10
- package/Slice/Components/Structural/Logger/Logger.js +146 -146
- package/Slice/Components/Structural/Router/Router.js +752 -721
- package/Slice/Components/Structural/StylesManager/StylesManager.js +78 -78
- package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +84 -84
- package/Slice/Slice.js +542 -542
- package/Slice/tests/build-bundled-component-without-category.test.js +103 -103
- package/Slice/tests/build-js-only-visual-components.test.js +144 -144
- package/Slice/tests/bundle-v2-runtime-contract.test.js +728 -728
- package/Slice/tests/public-env-runtime-accessors.test.js +44 -44
- package/Slice/tests/router-loading-finally.test.js +68 -68
- package/api/index.js +286 -286
- package/api/middleware/securityMiddleware.js +252 -252
- package/api/tests/public-env-resolver.test.js +193 -193
- package/api/utils/publicEnvResolver.js +117 -117
- package/package.json +40 -38
- package/sliceConfig.schema.json +109 -109
- package/src/App/index.html +16 -22
- package/src/App/index.js +20 -23
- package/src/App/style.css +11 -40
- package/src/Components/AppComponents/AboutSection/AboutSection.css +9 -0
- package/src/Components/AppComponents/AboutSection/AboutSection.html +8 -0
- package/src/Components/AppComponents/AboutSection/AboutSection.js +12 -0
- package/src/Components/AppComponents/AppShell/AppShell.css +10 -0
- package/src/Components/AppComponents/AppShell/AppShell.html +4 -0
- package/src/Components/AppComponents/AppShell/AppShell.js +36 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.css +20 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.html +10 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.js +19 -0
- package/src/Components/Service/FetchManager/FetchManager.js +133 -133
- package/src/Components/Service/IndexedDbManager/IndexedDbManager.js +141 -141
- package/src/Components/Service/LocalStorageManager/LocalStorageManager.js +45 -45
- package/src/Components/Visual/Button/Button.css +47 -47
- package/src/Components/Visual/Button/Button.html +5 -5
- package/src/Components/Visual/Button/Button.js +92 -92
- package/src/Components/Visual/Card/Card.css +68 -68
- package/src/Components/Visual/Card/Card.html +7 -7
- package/src/Components/Visual/Card/Card.js +107 -107
- package/src/Components/Visual/Checkbox/Checkbox.css +87 -87
- package/src/Components/Visual/Checkbox/Checkbox.html +8 -8
- package/src/Components/Visual/Checkbox/Checkbox.js +86 -86
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.css +129 -129
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.html +3 -3
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.js +262 -262
- package/src/Components/Visual/Details/Details.css +70 -70
- package/src/Components/Visual/Details/Details.html +9 -9
- package/src/Components/Visual/Details/Details.js +76 -76
- package/src/Components/Visual/DropDown/DropDown.css +60 -60
- package/src/Components/Visual/DropDown/DropDown.html +5 -5
- package/src/Components/Visual/DropDown/DropDown.js +63 -63
- package/src/Components/Visual/Grid/Grid.css +7 -7
- package/src/Components/Visual/Grid/Grid.html +1 -1
- package/src/Components/Visual/Grid/Grid.js +57 -57
- package/src/Components/Visual/Icon/Icon.css +510 -510
- package/src/Components/Visual/Icon/Icon.js +89 -89
- package/src/Components/Visual/Icon/slc.json +554 -554
- package/src/Components/Visual/Icon/slc.styl +507 -507
- package/src/Components/Visual/Icon/slc.svg +1485 -1485
- package/src/Components/Visual/Icon/slc.symbol.svg +1058 -1058
- package/src/Components/Visual/Input/Input.css +91 -91
- package/src/Components/Visual/Input/Input.html +4 -4
- package/src/Components/Visual/Input/Input.js +215 -215
- package/src/Components/Visual/Layout/Layout.js +49 -49
- package/src/Components/Visual/Link/Link.css +8 -8
- package/src/Components/Visual/Link/Link.html +1 -1
- package/src/Components/Visual/Link/Link.js +63 -63
- package/src/Components/Visual/Loading/Loading.css +56 -56
- package/src/Components/Visual/Loading/Loading.html +83 -83
- package/src/Components/Visual/Loading/Loading.js +38 -38
- package/src/Components/Visual/MultiRoute/MultiRoute.js +100 -93
- package/src/Components/Visual/Navbar/Navbar.css +115 -115
- package/src/Components/Visual/Navbar/Navbar.html +44 -44
- package/src/Components/Visual/Navbar/Navbar.js +141 -141
- package/src/Components/Visual/NotFound/NotFound.css +116 -116
- package/src/Components/Visual/NotFound/NotFound.html +23 -23
- package/src/Components/Visual/NotFound/NotFound.js +16 -16
- package/src/Components/Visual/Route/Route.js +93 -93
- package/src/Components/Visual/Select/Select.css +84 -84
- package/src/Components/Visual/Select/Select.html +8 -8
- package/src/Components/Visual/Select/Select.js +195 -195
- package/src/Components/Visual/Switch/Switch.css +76 -76
- package/src/Components/Visual/Switch/Switch.html +8 -8
- package/src/Components/Visual/Switch/Switch.js +102 -102
- package/src/Components/Visual/TreeItem/TreeItem.css +36 -36
- package/src/Components/Visual/TreeItem/TreeItem.html +1 -1
- package/src/Components/Visual/TreeItem/TreeItem.js +126 -126
- package/src/Components/Visual/TreeView/TreeView.css +8 -8
- package/src/Components/Visual/TreeView/TreeView.html +1 -1
- package/src/Components/Visual/TreeView/TreeView.js +48 -48
- package/src/Components/components.js +15 -27
- package/src/Styles/sliceStyles.css +34 -34
- package/src/Themes/Dark.css +42 -42
- package/src/Themes/Light.css +31 -31
- package/src/Themes/Slice.css +47 -47
- package/src/routes.js +9 -15
- package/src/sliceConfig.json +74 -73
- package/types/index.d.ts +207 -207
- package/Slice/Components/Structural/Debugger/Debugger.css +0 -620
- package/src/Components/AppComponents/HomePage/HomePage.css +0 -201
- package/src/Components/AppComponents/HomePage/HomePage.html +0 -37
- package/src/Components/AppComponents/HomePage/HomePage.js +0 -210
- package/src/Components/AppComponents/Playground/Playground.css +0 -12
- package/src/Components/AppComponents/Playground/Playground.html +0 -0
- package/src/Components/AppComponents/Playground/Playground.js +0 -111
- package/src/images/Slice.js-logo.png +0 -0
- package/src/images/im2/Slice.js-logo.png +0 -0
- package/src/testing.js +0 -888
|
@@ -1,102 +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);
|
|
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);
|
|
@@ -1,36 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<label class="slice_tree_item"></label>
|
|
1
|
+
<label class="slice_tree_item"></label>
|
|
@@ -1,126 +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);
|
|
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);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
.simple_treeview {
|
|
2
|
-
font-family: var(--font-family);
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
max-height: 100vh;
|
|
6
|
-
overflow-y: scroll;
|
|
7
|
-
overflow-x: hidden;
|
|
8
|
-
}
|
|
1
|
+
.simple_treeview {
|
|
2
|
+
font-family: var(--font-family);
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
max-height: 100vh;
|
|
6
|
+
overflow-y: scroll;
|
|
7
|
+
overflow-x: hidden;
|
|
8
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div class="simple_treeview"></div>
|
|
1
|
+
<div class="simple_treeview"></div>
|
|
@@ -1,48 +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);
|
|
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);
|