@neovici/cosmoz-treenode-navigator 5.5.0 → 5.6.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/demo/index.html DELETED
@@ -1,87 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
6
- <title>cosmoz-treenode-navigator demo</title>
7
- <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
8
- <script type="module">
9
- import "@polymer/iron-demo-helpers/demo-pages-shared-styles.js";
10
- import "@polymer/iron-demo-helpers/demo-snippet.js";
11
- import "@polymer/iron-ajax/iron-ajax.js";
12
- import "../cosmoz-treenode-navigator.js";
13
- import "../cosmoz-treenode-button-view.js";
14
-
15
- const $documentContainer = document.createElement('template');
16
- $documentContainer.innerHTML = `
17
- <custom-style>
18
- <style is="custom-style" include="demo-pages-shared-styles"></style>
19
- </custom-style>`;
20
- document.head.appendChild($documentContainer.content);
21
- </script>
22
- </head>
23
-
24
- <body>
25
- <h1>Cosmoz-treenode-navigator</h1>
26
-
27
- <div class="vertical-section-container">
28
- <h3>Navigator with multiple root tree data structure</h3>
29
- <p>
30
- The tree data structure simulate a windows file system, with 2 drives C: and D:
31
- </p>
32
- <demo-snippet>
33
- <template>
34
- <dom-bind id="demo1">
35
- <template is="dom-bind">
36
- <iron-ajax url="data/adminFiles.json" handle-as="json" last-response="{{ treeData1 }}" auto="[[ doRequest ]]">
37
- </iron-ajax>
38
- <cosmoz-treenode-button-view id="navigator" button-text-placeholder="Click to select a node"
39
- node-path="{{ path1 }}" selected-node="{{ selectedNode1 }}" tree="[[ getTree(treeData1) ]]"
40
- ></cosmoz-treenode-button-view>
41
- </template>
42
- </dom-bind>
43
- </template>
44
- </demo-snippet>
45
- </div>
46
-
47
- <div class="vertical-section-container">
48
- <h3>Navigator with multiple root tree data structure and missing ancestor nodes</h3>
49
- <p>
50
- The tree data structure is based on the one in the demo above, but showing only files accessible to a specific user.
51
- </p>
52
- <demo-snippet>
53
- <template>
54
- <dom-bind id="demo2">
55
- <template is="dom-bind">
56
- <iron-ajax url="data/johnFiles.json" handle-as="json" last-response="{{ treeData2 }}" auto="[[ doRequest ]]">
57
- </iron-ajax>
58
- <cosmoz-treenode-button-view id="navigator" button-text-placeholder="Click to select a node" node-path="{{ path2 }}" selected-node="{{ selectedNode2 }}"
59
- tree="[[ getTree(treeData2) ]]" multi-selection
60
- ></cosmoz-treenode-button-view>
61
- </template>
62
- </dom-bind>
63
- </template>
64
- </demo-snippet>
65
- </div>
66
-
67
- <script type="module">
68
- import { DefaultTree } from '@neovici/cosmoz-tree/cosmoz-default-tree';
69
-
70
- const getTree = data => {
71
- if (data) {
72
- return new DefaultTree(data);
73
- }
74
- },
75
- initTemplate = id => {
76
- let tpl = document.getElementById(id);
77
- tpl = !tpl.set ? tpl.firstElementChild : tpl;
78
- tpl.getTree = getTree;
79
- tpl.set('doRequest', true);
80
- };
81
-
82
- setTimeout(() => {
83
- initTemplate('demo1');
84
- initTemplate('demo2');
85
- });
86
- </script>
87
- </body></html>
package/demo/rtl.html DELETED
@@ -1,56 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
6
- <title>cosmoz-treenode-navigator demo</title>
7
- <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
8
- <script type="module">
9
- import "@polymer/iron-demo-helpers/demo-pages-shared-styles.js";
10
- import "@polymer/iron-demo-helpers/demo-snippet.js";
11
- import "../cosmoz-treenode-navigator.js";
12
- import "../cosmoz-treenode-button-view.js";
13
-
14
- const $documentContainer = document.createElement('template');
15
- $documentContainer.innerHTML = `
16
- <custom-style>
17
- <style is="custom-style" include="demo-pages-shared-styles"></style>
18
- </custom-style>`;
19
- document.head.appendChild($documentContainer.content);
20
- </script>
21
- </head>
22
-
23
- <body>
24
- <h1>Cosmoz-treenode-button-view rtl test</h1>
25
-
26
- <div class="vertical-section-container">
27
- <h3>Demonstrate issue caused by using direction: rtl to render the button label</h3>
28
- <p>Select node 1/2/3, and watch the button label</p>
29
- <demo-snippet>
30
- <template>
31
- <dom-bind id="demo1">
32
- <template is="dom-bind">
33
- <cosmoz-treenode-button-view id="navigator" button-text-placeholder="Click to select a node" node-path="{{ path1 }}" selected-node="{{ selectedNode1 }}" tree="[[ getTree(treeData1) ]]">
34
- </cosmoz-treenode-button-view>
35
- </template>
36
- </dom-bind>
37
- </template>
38
- </demo-snippet>
39
- </div>
40
- <script type="module">
41
- import { DefaultTree } from '@neovici/cosmoz-tree/cosmoz-default-tree';
42
- import treeData1 from '../test/data/rtlTest';
43
- const getTree = data => {
44
- if (data) {
45
- return new DefaultTree(data);
46
- }
47
- },
48
- initTemplate = id => {
49
- let tpl = document.getElementById(id);
50
- tpl = !tpl.set ? tpl.firstElementChild : tpl;
51
- tpl.getTree = getTree;
52
- tpl.treeData1 = treeData1;
53
- };
54
- initTemplate('demo1');
55
- </script>
56
- </body></html>
@@ -1,52 +0,0 @@
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
- });
@@ -1,102 +0,0 @@
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
- });
@@ -1,118 +0,0 @@
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
- };
@@ -1,22 +0,0 @@
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
-
@@ -1,10 +0,0 @@
1
- /* eslint-env node */
2
- export default {
3
- appIndex: 'demo/index.html',
4
- open: true,
5
- preserveSymlinks: true,
6
- nodeResolve: {
7
- mainFields: ['browser', 'jsnext', 'jsnext:main', 'module', 'main'],
8
- dedupe: pkg => ['@neovici', '@polymer', 'lit', 'haunted'].find(prefix => pkg.startsWith(prefix))
9
- }
10
- };
@@ -1 +0,0 @@
1
- export { default } from '@neovici/cfg/web/test-runner.mjs';