@neovici/cosmoz-treenode-navigator 5.6.0 → 6.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-treenode-navigator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "A Polymer component that lets you navigate and search through hierarchically structured data-nodes and select one of them.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polymer",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"cosmoz-*.js",
|
|
25
|
-
"helpers.js"
|
|
25
|
+
"helpers.js",
|
|
26
|
+
"test/data"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
29
|
"lint": "eslint --cache --ext .js .",
|
|
@@ -62,21 +63,21 @@
|
|
|
62
63
|
"@neovici/cfg": "^1.33.0",
|
|
63
64
|
"@neovici/cosmoz-dialog": "^3.0.0",
|
|
64
65
|
"@neovici/cosmoz-i18next": "^3.2.0",
|
|
65
|
-
"@neovici/cosmoz-input": "^
|
|
66
|
+
"@neovici/cosmoz-input": "^4.0.0",
|
|
66
67
|
"@neovici/cosmoz-tree": "^3.0.0",
|
|
67
|
-
"@neovici/cosmoz-utils": "^
|
|
68
|
+
"@neovici/cosmoz-utils": "^6.0.0",
|
|
69
|
+
"@pionjs/pion": "^2.0.0",
|
|
68
70
|
"@polymer/iron-icons": "^3.0.0",
|
|
69
71
|
"@polymer/paper-button": "^3.0.0",
|
|
70
72
|
"@polymer/paper-icon-button": "^3.0.0",
|
|
71
73
|
"@polymer/paper-input": "^3.2.0",
|
|
72
74
|
"@polymer/polymer": "^3.4.0",
|
|
73
|
-
"
|
|
74
|
-
"lit-html": "^2.0.0"
|
|
75
|
+
"lit-html": "^2.0.0 || ^3.0.0"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
|
-
"@commitlint/cli": "^
|
|
78
|
-
"@commitlint/config-conventional": "^
|
|
79
|
-
"@open-wc/testing": "^
|
|
78
|
+
"@commitlint/cli": "^18.0.0",
|
|
79
|
+
"@commitlint/config-conventional": "^18.0.0",
|
|
80
|
+
"@open-wc/testing": "^4.0.0",
|
|
80
81
|
"@polymer/iron-ajax": "^3.0.0",
|
|
81
82
|
"@polymer/iron-component-page": "^4.0.0",
|
|
82
83
|
"@polymer/iron-demo-helpers": "^3.0.0",
|
|
@@ -86,6 +87,6 @@
|
|
|
86
87
|
"@semantic-release/git": "^10.0.0",
|
|
87
88
|
"@webcomponents/webcomponentsjs": "^2.0.0",
|
|
88
89
|
"husky": "^8.0.0",
|
|
89
|
-
"semantic-release": "^
|
|
90
|
+
"semantic-release": "^22.0.0"
|
|
90
91
|
}
|
|
91
92
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import { DefaultTree } from '@neovici/cosmoz-tree/cosmoz-default-tree';
|
|
3
|
+
import rtlData from './data/rtlTest.js';
|
|
4
|
+
import '../cosmoz-treenode-button-view';
|
|
5
|
+
|
|
6
|
+
suite('rtl', () => {
|
|
7
|
+
let treeButton;
|
|
8
|
+
|
|
9
|
+
suiteSetup(async () => {
|
|
10
|
+
treeButton = await fixture(html`<cosmoz-treenode-button-view .tree=${ new DefaultTree(rtlData) }>`);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('button renders selected path', done => {
|
|
14
|
+
treeButton.nodePath = '1.2.3';
|
|
15
|
+
|
|
16
|
+
// Button view label depends on a binding in a cosmoz-treenode-navigator
|
|
17
|
+
// stamped asynchronously, so we need to wait a bit.
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
const buttonLabel = treeButton.shadowRoot.querySelector('.pathToNode').textContent;
|
|
20
|
+
assert.isTrue(buttonLabel.endsWith('1 / 2 / 3'));
|
|
21
|
+
done();
|
|
22
|
+
}, 500);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
// commented out because test is unstable
|
|
27
|
+
function isIdActiveElement(id, element, idPreviouslyFound) {
|
|
28
|
+
let idFound = idPreviouslyFound || element && element.id === id;
|
|
29
|
+
|
|
30
|
+
if (element != null && element.shadowRoot != null) {
|
|
31
|
+
return isIdActiveElement(id, element.shadowRoot.activeElement, idFound);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// active element not null means that it has focus
|
|
35
|
+
return element != null && idFound;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
test('search input has focus when dialog has opened', done => {
|
|
39
|
+
treeButton.$$('.pathToNode').click();
|
|
40
|
+
Polymer.Base.async(() => {
|
|
41
|
+
// real focus can only be tested here, not valid outside test()
|
|
42
|
+
if (window.document.hasFocus()) {
|
|
43
|
+
assert.equal(isIdActiveElement('searchInput', window.document.activeElement), true);
|
|
44
|
+
}
|
|
45
|
+
if (treeButton.$.dialogTree != null) {
|
|
46
|
+
treeButton.$.dialogTree.close();
|
|
47
|
+
}
|
|
48
|
+
done();
|
|
49
|
+
}, 50);
|
|
50
|
+
});
|
|
51
|
+
*/
|
|
52
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import { DefaultTree } from '@neovici/cosmoz-tree/cosmoz-default-tree';
|
|
3
|
+
import basicTree from './data/basicTree.js';
|
|
4
|
+
import '../cosmoz-treenode-navigator';
|
|
5
|
+
import { computeDataPlane } from '../helpers';
|
|
6
|
+
|
|
7
|
+
suite('cosmoz-treenode-navigator', () => {
|
|
8
|
+
let navigator;
|
|
9
|
+
|
|
10
|
+
setup(async () => {
|
|
11
|
+
navigator = await fixture(html` <cosmoz-treenode-navigator
|
|
12
|
+
.tree=${new DefaultTree(basicTree)}
|
|
13
|
+
.searchPlaceholder="${'Custom search placeholder'}"
|
|
14
|
+
.searchMinLength="${2}"
|
|
15
|
+
></cosmoz-treenode-navigator>`);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('instantiating the element', () => {
|
|
19
|
+
assert.equal(navigator.tagName, 'COSMOZ-TREENODE-NAVIGATOR');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('tree length and sort', () => {
|
|
23
|
+
// given a node navigator with some data
|
|
24
|
+
|
|
25
|
+
// when I enter the first node
|
|
26
|
+
navigator.openNodePath = '1000';
|
|
27
|
+
|
|
28
|
+
const dataPlane = computeDataPlane(
|
|
29
|
+
navigator.tree,
|
|
30
|
+
navigator.searchValue,
|
|
31
|
+
navigator.openNodePath
|
|
32
|
+
);
|
|
33
|
+
// then I can see the contents of the node
|
|
34
|
+
// and it is ordered folder-first, then alphabetically
|
|
35
|
+
assert.equal(dataPlane[0].name, 'Data');
|
|
36
|
+
assert.equal(dataPlane[1].name, 'Backup');
|
|
37
|
+
assert.equal(dataPlane.length, 2);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('set proper search placeholder', () => {
|
|
41
|
+
assert.equal(
|
|
42
|
+
navigator.shadowRoot
|
|
43
|
+
.querySelector('cosmoz-input')
|
|
44
|
+
.shadowRoot.querySelector('input').placeholder,
|
|
45
|
+
'Custom search placeholder'
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('should check if node has children', () => {
|
|
50
|
+
const node = {
|
|
51
|
+
name: 'D:',
|
|
52
|
+
path: '1000',
|
|
53
|
+
children: {
|
|
54
|
+
1001: {
|
|
55
|
+
name: 'Data',
|
|
56
|
+
pathLocator: '1000.1001',
|
|
57
|
+
children: { 1002: { name: 'John', pathLocator: '1000.1001.1002' } },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
parentSectionName: 'D:',
|
|
61
|
+
pathLocator: '1000',
|
|
62
|
+
};
|
|
63
|
+
assert.equal(navigator.tree.hasChildren(node), true);
|
|
64
|
+
const node2 = {
|
|
65
|
+
name: 'Git',
|
|
66
|
+
path: '1.5.7',
|
|
67
|
+
parentSectionName: 'C:/Program Files',
|
|
68
|
+
pathLocator: '1.5.7',
|
|
69
|
+
};
|
|
70
|
+
assert.equal(navigator.tree.hasChildren(node2), false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('match search string', () => {
|
|
74
|
+
// given a node navigator with some data
|
|
75
|
+
// when I search for 'John'
|
|
76
|
+
navigator.searchValue = 'John';
|
|
77
|
+
|
|
78
|
+
const dataPlane = computeDataPlane(
|
|
79
|
+
navigator.tree,
|
|
80
|
+
navigator.searchValue,
|
|
81
|
+
'1000'
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
//then I can see only 1 item matching 'John'
|
|
85
|
+
assert.lengthOf(dataPlane, 1);
|
|
86
|
+
assert.equal(dataPlane[0].name, 'John');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('not match search string', () => {
|
|
90
|
+
// given a node navigator with some data
|
|
91
|
+
// when I search for 'NONEXISTING'
|
|
92
|
+
navigator.searchValue = 'NONEXISTING';
|
|
93
|
+
const dataPlane = computeDataPlane(
|
|
94
|
+
navigator.tree,
|
|
95
|
+
navigator.searchValue,
|
|
96
|
+
'1000'
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
//then I can see that is no contents
|
|
100
|
+
assert.lengthOf(dataPlane, 0);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
1: {
|
|
3
|
+
name: 'C:',
|
|
4
|
+
pathLocator: '1',
|
|
5
|
+
children: {
|
|
6
|
+
2: {
|
|
7
|
+
name: 'Windows',
|
|
8
|
+
pathLocator: '1.2',
|
|
9
|
+
children: {
|
|
10
|
+
3: {
|
|
11
|
+
name: 'System',
|
|
12
|
+
pathLocator: '1.2.3',
|
|
13
|
+
children: {}
|
|
14
|
+
},
|
|
15
|
+
4: {
|
|
16
|
+
name: 'Microsoft.NET',
|
|
17
|
+
pathLocator: '1.2.4',
|
|
18
|
+
children: {}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
5: {
|
|
23
|
+
name: 'Program Files',
|
|
24
|
+
pathLocator: '1.5',
|
|
25
|
+
children: {
|
|
26
|
+
6: {
|
|
27
|
+
name: 'Microsoft VS Code',
|
|
28
|
+
pathLocator: '1.5.6'
|
|
29
|
+
},
|
|
30
|
+
7: {
|
|
31
|
+
name: 'Git',
|
|
32
|
+
pathLocator: '1.5.7'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
100: {
|
|
37
|
+
name: 'Users',
|
|
38
|
+
pathLocator: '1.100',
|
|
39
|
+
children: {
|
|
40
|
+
200: {
|
|
41
|
+
name: 'Default',
|
|
42
|
+
pathLocator: '1.100.200',
|
|
43
|
+
children: {
|
|
44
|
+
201: {
|
|
45
|
+
name: 'Documents',
|
|
46
|
+
pathLocator: '1.100.200.201'
|
|
47
|
+
},
|
|
48
|
+
202: {
|
|
49
|
+
name: 'Music',
|
|
50
|
+
pathLocator: '1.100.200.202'
|
|
51
|
+
},
|
|
52
|
+
203: {
|
|
53
|
+
name: 'Pictures',
|
|
54
|
+
pathLocator: '1.100.200.203'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
300: {
|
|
59
|
+
name: 'John',
|
|
60
|
+
pathLocator: '1.100.300',
|
|
61
|
+
children: {
|
|
62
|
+
301: {
|
|
63
|
+
name: 'Documents',
|
|
64
|
+
pathLocator: '1.100.300.301'
|
|
65
|
+
},
|
|
66
|
+
302: {
|
|
67
|
+
name: 'Music',
|
|
68
|
+
pathLocator: '1.100.300.302'
|
|
69
|
+
},
|
|
70
|
+
303: {
|
|
71
|
+
name: 'Pictures',
|
|
72
|
+
pathLocator: '1.100.300.303'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
400: {
|
|
77
|
+
name: 'Public',
|
|
78
|
+
pathLocator: '1.100.400',
|
|
79
|
+
children: {
|
|
80
|
+
401: {
|
|
81
|
+
name: 'Public Documents',
|
|
82
|
+
pathLocator: '1.100.400.401'
|
|
83
|
+
},
|
|
84
|
+
402: {
|
|
85
|
+
name: 'Public Music',
|
|
86
|
+
pathLocator: '1.100.400.402'
|
|
87
|
+
},
|
|
88
|
+
403: {
|
|
89
|
+
name: 'Public Pictures',
|
|
90
|
+
pathLocator: '1.100.400.403'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
1000: {
|
|
99
|
+
name: 'D:',
|
|
100
|
+
pathLocator: '1000',
|
|
101
|
+
children: {
|
|
102
|
+
1001: {
|
|
103
|
+
name: 'Data',
|
|
104
|
+
pathLocator: '1000.1001',
|
|
105
|
+
children: {
|
|
106
|
+
1002: {
|
|
107
|
+
name: 'John',
|
|
108
|
+
pathLocator: '1000.1001.1002'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
1002: {
|
|
113
|
+
name: 'Backup',
|
|
114
|
+
pathLocator: '1000.1002'
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
1: {
|
|
3
|
+
id: '11111111-1111-1111-1111-111111111111',
|
|
4
|
+
name: '1',
|
|
5
|
+
pathLocator: '1',
|
|
6
|
+
children: {
|
|
7
|
+
2: {
|
|
8
|
+
id: '167d1485-7d4f-4c7d-86cd-a4fb00f31245',
|
|
9
|
+
name: '2',
|
|
10
|
+
pathLocator: '1.2',
|
|
11
|
+
children: {
|
|
12
|
+
3: {
|
|
13
|
+
id: '3a7654f1-e3e6-49c7-b6a8-a4fb00f31245',
|
|
14
|
+
name: '3',
|
|
15
|
+
pathLocator: '1.2.3'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|