@jinntec/fore 2.1.1 → 2.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.
Files changed (88) hide show
  1. package/README.md +2 -2
  2. package/dist/fore-dev.js +2 -2
  3. package/dist/fore-dev.js.map +1 -1
  4. package/dist/fore.js +2 -2
  5. package/dist/fore.js.map +1 -1
  6. package/index.js +4 -2
  7. package/package.json +10 -38
  8. package/resources/fore.css +263 -262
  9. package/resources/vars.css +8 -0
  10. package/src/DependencyNotifyingDomFacade.js +1 -0
  11. package/src/ForeElementMixin.js +243 -228
  12. package/src/actions/abstract-action.js +407 -398
  13. package/src/actions/fx-action.js +6 -6
  14. package/src/actions/fx-append.js +1 -1
  15. package/src/actions/fx-call.js +63 -62
  16. package/src/actions/fx-confirm.js +11 -11
  17. package/src/actions/fx-construct-done.js +4 -4
  18. package/src/actions/fx-copy.js +36 -36
  19. package/src/actions/fx-delete.js +77 -79
  20. package/src/actions/fx-dispatch.js +14 -14
  21. package/src/actions/fx-hide.js +15 -15
  22. package/src/actions/fx-insert.js +9 -12
  23. package/src/actions/fx-insertchild.js +88 -0
  24. package/src/actions/fx-load.js +188 -185
  25. package/src/actions/fx-message.js +18 -19
  26. package/src/actions/fx-refresh.js +10 -10
  27. package/src/actions/fx-reload.js +16 -14
  28. package/src/actions/fx-replace.js +0 -1
  29. package/src/actions/fx-reset.js +31 -31
  30. package/src/actions/fx-send.js +59 -52
  31. package/src/actions/fx-setattribute.js +48 -49
  32. package/src/actions/fx-setfocus.js +54 -58
  33. package/src/actions/fx-setvalue.js +85 -81
  34. package/src/actions/fx-show.js +11 -11
  35. package/src/actions/fx-toggle.js +2 -2
  36. package/src/actions/fx-toggleboolean.js +38 -39
  37. package/src/actions/fx-unmodified.js +27 -0
  38. package/src/actions/fx-update.js +6 -6
  39. package/src/dep_graph.js +1 -1
  40. package/src/drawdown.js +23 -30
  41. package/src/events.js +19 -19
  42. package/src/fore.js +143 -125
  43. package/src/functions/common-function.js +24 -25
  44. package/src/functions/fx-function.js +6 -99
  45. package/src/functions/fx-functionlib.js +56 -0
  46. package/src/functions/registerFunction.js +112 -0
  47. package/src/fx-bind.js +19 -24
  48. package/src/fx-connection.js +226 -0
  49. package/src/fx-fore.js +844 -815
  50. package/src/fx-header.js +4 -4
  51. package/src/fx-instance.js +25 -29
  52. package/src/fx-model.js +405 -380
  53. package/src/fx-submission.js +399 -397
  54. package/src/fx-var.js +13 -12
  55. package/src/getInScopeContext.js +102 -89
  56. package/src/json-util.js +24 -24
  57. package/src/lab/fore-component.js +48 -52
  58. package/src/lab/instance-inspector.js +13 -16
  59. package/src/modelitem.js +48 -10
  60. package/src/relevance.js +12 -16
  61. package/src/tools/adi.js +858 -812
  62. package/src/tools/fx-action-log.js +377 -295
  63. package/src/tools/fx-devtools.js +210 -210
  64. package/src/tools/fx-dom-inspector.js +123 -122
  65. package/src/tools/fx-json-instance.js +262 -253
  66. package/src/tools/fx-log-item.js +6 -11
  67. package/src/tools/fx-log-settings.js +358 -301
  68. package/src/tools/fx-minimap.js +186 -177
  69. package/src/tools/helpers.js +1 -1
  70. package/src/ui/abstract-control.js +73 -53
  71. package/src/ui/fx-case.js +59 -7
  72. package/src/ui/fx-container.js +13 -14
  73. package/src/ui/fx-control.js +572 -538
  74. package/src/ui/fx-dialog.js +3 -3
  75. package/src/ui/fx-droptarget.js +3 -4
  76. package/src/ui/fx-group.js +4 -2
  77. package/src/ui/fx-hint.js +3 -0
  78. package/src/ui/fx-inspector.js +5 -5
  79. package/src/ui/fx-items.js +11 -11
  80. package/src/ui/fx-output.js +10 -12
  81. package/src/ui/fx-repeat-attributes.js +23 -27
  82. package/src/ui/fx-repeat.js +347 -344
  83. package/src/ui/fx-repeatitem.js +75 -68
  84. package/src/ui/fx-switch.js +39 -14
  85. package/src/ui/fx-trigger.js +4 -4
  86. package/src/withDraggability.js +193 -191
  87. package/src/xpath-evaluation.js +969 -958
  88. package/src/xpath-util.js +161 -134
@@ -1,25 +1,24 @@
1
-
2
1
  /**
3
2
  * A simple collapsible treeview for showing JSON data.
4
3
  *
5
4
  */
6
5
  class FxJsonInstance extends HTMLElement {
7
- // constructor(container, options = {}) {
8
- constructor() {
9
- super();
10
- const shadowRoot = this.attachShadow({mode: 'open'});
11
- this.instanceElement = null;
12
- this.foreSelector = null;
13
- }
14
-
15
- connectedCallback() {
16
- this.container = this.querySelector('.json-path-picker-container');
17
- this.foreSelector = this.hasAttribute('fore') ? this.getAttribute('fore') : 'fx-fore'; // default to first one in doc
18
- this.render();
19
- }
20
-
21
- render() {
22
- const style = `
6
+ // constructor(container, options = {}) {
7
+ constructor() {
8
+ super();
9
+ const shadowRoot = this.attachShadow({ mode: 'open' });
10
+ this.instanceElement = null;
11
+ this.foreSelector = null;
12
+ }
13
+
14
+ connectedCallback() {
15
+ this.container = this.querySelector('.json-path-picker-container');
16
+ this.foreSelector = this.hasAttribute('fore') ? this.getAttribute('fore') : 'fx-fore'; // default to first one in doc
17
+ this.render();
18
+ }
19
+
20
+ render() {
21
+ const style = `
23
22
  @import '../../resources/fore.css';
24
23
 
25
24
  :host {
@@ -96,17 +95,17 @@ class FxJsonInstance extends HTMLElement {
96
95
 
97
96
  `;
98
97
 
99
- const instanceId = this.hasAttribute('instance') ? this.getAttribute('instance') : 'default';
100
- const fore = document.querySelector(this.foreSelector);
101
- if(!fore){
102
- throw new Error(`this '${this.foreSelector}' does not match a fx-fore element`);
103
- }
98
+ const instanceId = this.hasAttribute('instance') ? this.getAttribute('instance') : 'default';
99
+ const fore = document.querySelector(this.foreSelector);
100
+ if (!fore) {
101
+ throw new Error(`this '${this.foreSelector}' does not match a fx-fore element`);
102
+ }
104
103
 
105
- const html = `
104
+ const html = `
106
105
  <div class="container"></div>
107
106
  `;
108
107
 
109
- this.shadowRoot.innerHTML = `
108
+ this.shadowRoot.innerHTML = `
110
109
  <style>
111
110
  ${style}
112
111
  </style>
@@ -117,204 +116,218 @@ class FxJsonInstance extends HTMLElement {
117
116
  ${html}
118
117
  `;
119
118
 
120
- // fore.addEventListener('ready', e => {
121
-
122
- const instanceElement = document.querySelector(`#${instanceId}`);
123
- if(!instanceElement || instanceElement.nodeName !== 'FX-INSTANCE' || instanceElement.getAttribute('type') !== 'json'){
124
- throw new Error(`this '${instanceId}' does not match an fx-instance element or is not of type JSON`);
125
- }
126
- const container = this.shadowRoot.querySelector('.container');
127
-
128
- const json = instanceElement.instanceData;
129
- let tree = this.json2html(json,{"outputWithQuotes":true});
130
- if (this.isCollapsable(json)) tree = "<a href='#' class=\"json-toggle\"></a>".concat(tree); // Insert HTML in target DOM element
131
-
132
- container.innerHTML = tree;
133
-
134
- const toggles = this.shadowRoot.querySelectorAll('.json-toggle');
135
- toggles.forEach(toggle => {
136
- toggle.addEventListener('click', this._handleToggleEvent.bind(this));
137
- });
138
- // container.addEventListener('click', (event) => this._handleToggleEvent);
139
- // });
140
- }
141
-
142
-
143
- disconnectedCallback() {
144
- }
145
-
146
- _isHidden(elem) {
147
- var width = elem.offsetWidth;
148
- var height = elem.offsetHeight;
149
- return width === 0 && height === 0 || window.getComputedStyle(elem).display === 'none';
119
+ // fore.addEventListener('ready', e => {
120
+
121
+ const instanceElement = document.querySelector(`#${instanceId}`);
122
+ if (
123
+ !instanceElement ||
124
+ instanceElement.nodeName !== 'FX-INSTANCE' ||
125
+ instanceElement.getAttribute('type') !== 'json'
126
+ ) {
127
+ throw new Error(
128
+ `this '${instanceId}' does not match an fx-instance element or is not of type JSON`,
129
+ );
150
130
  }
151
-
152
- _handleToggleEvent(event) {
153
- // Change class
154
- // event.preventDefault();
155
- // event.stopPropagation();
156
-
157
- const elm = event.target;
158
- elm.classList.toggle('collapsed'); // Fetch every json-dict and json-array to toggle them
159
-
160
- var subTarget = this._siblings(elm, 'ul.json-dict, ol.json-array', function (el) {
161
- el.style.display = el.style.display === '' || el.style.display === 'block' ? 'none' : 'block';
162
- }); // ForEach subtarget, previous siblings return array so we parse it
163
-
164
- for (var i = 0; i < subTarget.length; i += 1) {
165
- if (!this._isHidden(subTarget[i])) {
166
- // Parse every siblings with '.json-placehoder' and remove them (previous add by else)
167
- this._siblings(subTarget[i], '.json-placeholder', function (el) {
168
- return el.parentNode.removeChild(el);
169
- });
170
- } else {
171
- // count item in object / array
172
- var childs = subTarget[i].children;
173
- var count = 0;
174
-
175
- for (var j = 0; j < childs.length; j += 1) {
176
- if (childs[j].tagName === 'LI') {
177
- count += 1;
178
- }
179
- }
180
-
181
- var placeholder = count + (count > 1 ? ' items' : ' item'); // Append a placeholder
182
- subTarget[i].insertAdjacentHTML('afterend', "<a href class=\"json-placeholder\">".concat(placeholder, "</a>"));
183
- }
184
- } // Prevent propagation
185
-
186
-
187
- event.stopPropagation();
188
- event.preventDefault();
189
- }
190
-
191
- _siblings(el, sel, callback) {
192
- var sibs = [];
193
-
194
- for (var i = 0; i < el.parentNode.children.length; i += 1) {
195
- var child = el.parentNode.children[i];
196
-
197
- if (child !== el && typeof sel === 'string' && child.matches(sel)) {
198
- sibs.push(child);
199
- }
200
- } // If a callback is passed, call it on each sibs
201
-
202
-
203
- if (callback && typeof callback === 'function') {
204
- for (var _i = 0; _i < sibs.length; _i += 1) {
205
- callback(sibs[_i]);
206
- }
131
+ const container = this.shadowRoot.querySelector('.container');
132
+
133
+ const json = instanceElement.instanceData;
134
+ let tree = this.json2html(json, { outputWithQuotes: true });
135
+ if (this.isCollapsable(json)) tree = '<a href=\'#\' class="json-toggle"></a>'.concat(tree); // Insert HTML in target DOM element
136
+
137
+ container.innerHTML = tree;
138
+
139
+ const toggles = this.shadowRoot.querySelectorAll('.json-toggle');
140
+ toggles.forEach(toggle => {
141
+ toggle.addEventListener('click', this._handleToggleEvent.bind(this));
142
+ });
143
+ // container.addEventListener('click', (event) => this._handleToggleEvent);
144
+ // });
145
+ }
146
+
147
+ disconnectedCallback() {}
148
+
149
+ _isHidden(elem) {
150
+ const width = elem.offsetWidth;
151
+ const height = elem.offsetHeight;
152
+ return (width === 0 && height === 0) || window.getComputedStyle(elem).display === 'none';
153
+ }
154
+
155
+ _handleToggleEvent(event) {
156
+ // Change class
157
+ // event.preventDefault();
158
+ // event.stopPropagation();
159
+
160
+ const elm = event.target;
161
+ elm.classList.toggle('collapsed'); // Fetch every json-dict and json-array to toggle them
162
+
163
+ const subTarget = this._siblings(elm, 'ul.json-dict, ol.json-array', el => {
164
+ el.style.display = el.style.display === '' || el.style.display === 'block' ? 'none' : 'block';
165
+ }); // ForEach subtarget, previous siblings return array so we parse it
166
+
167
+ for (let i = 0; i < subTarget.length; i += 1) {
168
+ if (!this._isHidden(subTarget[i])) {
169
+ // Parse every siblings with '.json-placehoder' and remove them (previous add by else)
170
+ this._siblings(subTarget[i], '.json-placeholder', el => el.parentNode.removeChild(el));
171
+ } else {
172
+ // count item in object / array
173
+ const childs = subTarget[i].children;
174
+ let count = 0;
175
+
176
+ for (let j = 0; j < childs.length; j += 1) {
177
+ if (childs[j].tagName === 'LI') {
178
+ count += 1;
179
+ }
207
180
  }
208
181
 
209
- return sibs;
182
+ const placeholder = count + (count > 1 ? ' items' : ' item'); // Append a placeholder
183
+ subTarget[i].insertAdjacentHTML(
184
+ 'afterend',
185
+ '<a href class="json-placeholder">'.concat(placeholder, '</a>'),
186
+ );
187
+ }
188
+ } // Prevent propagation
189
+
190
+ event.stopPropagation();
191
+ event.preventDefault();
192
+ }
193
+
194
+ _siblings(el, sel, callback) {
195
+ const sibs = [];
196
+
197
+ for (let i = 0; i < el.parentNode.children.length; i += 1) {
198
+ const child = el.parentNode.children[i];
199
+
200
+ if (child !== el && typeof sel === 'string' && child.matches(sel)) {
201
+ sibs.push(child);
202
+ }
203
+ } // If a callback is passed, call it on each sibs
204
+
205
+ if (callback && typeof callback === 'function') {
206
+ for (let _i = 0; _i < sibs.length; _i += 1) {
207
+ callback(sibs[_i]);
208
+ }
210
209
  }
211
210
 
212
- json2html(json, options) {
213
- let html = '';
214
-
215
- if (typeof json === 'string') {
216
- // Escape tags
217
- const tmp = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
218
-
219
- if (this.isUrl(tmp)) {
220
- html += "<a href=\"".concat(tmp, "\" class=\"json-string\">").concat(tmp, "</a>");
221
- } else {
222
- html += "<span class=\"json-string\">\"".concat(tmp, "\"</span>");
223
- }
224
- } else if (typeof json === 'number') {
225
- html += "<span class=\"json-literal\">".concat(json, "</span>");
226
- } else if (typeof json === 'boolean') {
227
- html += "<span class=\"json-literal\">".concat(json, "</span>");
228
- } else if (json === null) {
229
- html += '<span class="json-literal">null</span>';
230
- } else if (json instanceof Array) {
231
- if (json.length > 0) {
232
- html += '[<ol class="json-array">';
233
-
234
- for (var i = 0; i < json.length; i += 1) {
235
- html += "<li data-key-type=\"array\" data-key=\"".concat(i, "\">"); // Add toggle button if item is collapsable
236
-
237
- if (this.isCollapsable(json[i])) {
238
- html += '<a href="#" class="json-toggle"></a>';
239
- }
240
-
241
- html += this.json2html(json[i], options); // Add comma if item is not last
242
-
243
- if (i < json.length - 1) {
244
- html += ',';
245
- }
246
-
247
- html += '</li>';
248
- }
211
+ return sibs;
212
+ }
213
+
214
+ json2html(json, options) {
215
+ let html = '';
216
+
217
+ if (typeof json === 'string') {
218
+ // Escape tags
219
+ const tmp = json
220
+ .replace(/&/g, '&amp;')
221
+ .replace(/</g, '&lt;')
222
+ .replace(/>/g, '&gt;')
223
+ .replace(/"/g, '&quot;');
224
+
225
+ if (this.isUrl(tmp)) {
226
+ html += '<a href="'.concat(tmp, '" class="json-string">').concat(tmp, '</a>');
227
+ } else {
228
+ html += '<span class="json-string">"'.concat(tmp, '"</span>');
229
+ }
230
+ } else if (typeof json === 'number') {
231
+ html += '<span class="json-literal">'.concat(json, '</span>');
232
+ } else if (typeof json === 'boolean') {
233
+ html += '<span class="json-literal">'.concat(json, '</span>');
234
+ } else if (json === null) {
235
+ html += '<span class="json-literal">null</span>';
236
+ } else if (json instanceof Array) {
237
+ if (json.length > 0) {
238
+ html += '[<ol class="json-array">';
239
+
240
+ for (let i = 0; i < json.length; i += 1) {
241
+ html += '<li data-key-type="array" data-key="'.concat(i, '">'); // Add toggle button if item is collapsable
242
+
243
+ if (this.isCollapsable(json[i])) {
244
+ html += '<a href="#" class="json-toggle"></a>';
245
+ }
246
+
247
+ html += this.json2html(json[i], options); // Add comma if item is not last
248
+
249
+ if (i < json.length - 1) {
250
+ html += ',';
251
+ }
252
+
253
+ html += '</li>';
254
+ }
249
255
 
250
- html += '</ol>]';
256
+ html += '</ol>]';
257
+ } else {
258
+ html += '[]';
259
+ }
260
+ } else if (this._typeof(json) === 'object') {
261
+ let keyCount = Object.keys(json).length;
262
+
263
+ if (keyCount > 0) {
264
+ html += '{<ul class="json-dict">';
265
+
266
+ for (const key in json) {
267
+ if (json.hasOwnProperty(key)) {
268
+ html += '<li data-key-type="object" data-key="'.concat(key, '">');
269
+ const keyRepr = options.outputWithQuotes
270
+ ? '<span class="json-string">"'.concat(key, '"</span>')
271
+ : key; // Add toggle button if item is collapsable
272
+
273
+ if (this.isCollapsable(json[key])) {
274
+ html += '<a href=\'#\' class="json-toggle">'.concat(keyRepr, '</a>');
251
275
  } else {
252
- html += '[]';
276
+ html += keyRepr;
253
277
  }
254
- } else if (this._typeof(json) === 'object') {
255
- let keyCount = Object.keys(json).length;
256
278
 
257
- if (keyCount > 0) {
258
- html += '{<ul class="json-dict">';
279
+ // ### keep the following comment for later - pick path is a good idea but needs to be adapted to XPath syntax
280
+ // html += '<span class="pick-path" title="Pick path">&#10697;</span>';
281
+ html += ': '.concat(this.json2html(json[key], options)); // Add comma if item is not last
259
282
 
260
- for (var key in json) {
261
- if (json.hasOwnProperty(key)) {
262
- html += "<li data-key-type=\"object\" data-key=\"".concat(key, "\">");
263
- const keyRepr = options.outputWithQuotes ? "<span class=\"json-string\">\"".concat(key, "\"</span>") : key; // Add toggle button if item is collapsable
283
+ keyCount -= 1;
264
284
 
265
- if (this.isCollapsable(json[key])) {
266
- html += "<a href='#' class=\"json-toggle\">".concat(keyRepr, "</a>");
267
- } else {
268
- html += keyRepr;
269
- }
270
-
271
- // ### keep the following comment for later - pick path is a good idea but needs to be adapted to XPath syntax
272
- // html += '<span class="pick-path" title="Pick path">&#10697;</span>';
273
- html += ": ".concat(this.json2html(json[key], options)); // Add comma if item is not last
274
-
275
- keyCount -= 1;
276
-
277
- if (keyCount > 0) {
278
- html += ',';
279
- }
280
-
281
- html += '</li>';
282
- }
283
- }
284
-
285
- html += '</ul>}';
286
- } else {
287
- html += '{}';
285
+ if (keyCount > 0) {
286
+ html += ',';
288
287
  }
289
- }
290
-
291
- return html;
292
- }
293
-
294
- isUrl(string) {
295
- var regexp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#:.?+=&%@!\-/]))?/;
296
- return regexp.test(string);
297
- }
298
288
 
299
- _typeof(obj) {
300
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
301
- this._typeof = function _typeof(obj) {
302
- return typeof obj;
303
- };
304
- } else {
305
- this._typeof = function _typeof(obj) {
306
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
307
- };
289
+ html += '</li>';
290
+ }
308
291
  }
309
- return this._typeof(obj);
292
+
293
+ html += '</ul>}';
294
+ } else {
295
+ html += '{}';
296
+ }
310
297
  }
311
298
 
312
- isCollapsable(arg) {
313
- return arg instanceof Object && Object.keys(arg).length > 0;
299
+ return html;
300
+ }
301
+
302
+ isUrl(string) {
303
+ const regexp =
304
+ /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#:.?+=&%@!\-/]))?/;
305
+ return regexp.test(string);
306
+ }
307
+
308
+ _typeof(obj) {
309
+ if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
310
+ this._typeof = function _typeof(obj) {
311
+ return typeof obj;
312
+ };
313
+ } else {
314
+ this._typeof = function _typeof(obj) {
315
+ return obj &&
316
+ typeof Symbol === 'function' &&
317
+ obj.constructor === Symbol &&
318
+ obj !== Symbol.prototype
319
+ ? 'symbol'
320
+ : typeof obj;
321
+ };
314
322
  }
323
+ return this._typeof(obj);
324
+ }
315
325
 
326
+ isCollapsable(arg) {
327
+ return arg instanceof Object && Object.keys(arg).length > 0;
328
+ }
316
329
 
317
- /*
330
+ /*
318
331
  setup() {
319
332
  // Create shadow DOM
320
333
 
@@ -375,61 +388,57 @@ class FxJsonInstance extends HTMLElement {
375
388
  }
376
389
  */
377
390
 
391
+ static get observedAttributes() {
392
+ return ['data'];
393
+ }
378
394
 
379
- static get observedAttributes() {
380
- return ['data'];
381
- }
382
-
383
- attributeChangedCallback(name, oldValue, newValue) {
384
- if (name === 'data') {
385
- this.jsonTextarea.value = newValue;
386
- this.updateTree(newValue);
387
- }
395
+ attributeChangedCallback(name, oldValue, newValue) {
396
+ if (name === 'data') {
397
+ this.jsonTextarea.value = newValue;
398
+ this.updateTree(newValue);
388
399
  }
389
-
390
-
391
- updateTree(jsonString) {
392
- try {
393
- this.data = JSON.parse(jsonString);
394
- this.treeView.innerHTML = "";
395
- this.treeView.appendChild(this.createTreeView(this.data, ""));
396
- } catch (e) {
397
- console.error(e);
398
- alert("Invalid JSON");
399
- }
400
+ }
401
+
402
+ updateTree(jsonString) {
403
+ try {
404
+ this.data = JSON.parse(jsonString);
405
+ this.treeView.innerHTML = '';
406
+ this.treeView.appendChild(this.createTreeView(this.data, ''));
407
+ } catch (e) {
408
+ console.error(e);
409
+ alert('Invalid JSON');
400
410
  }
401
-
402
- createTreeView(data, path) {
403
- let ul = document.createElement("ul");
404
- ul.classList.add("jp-ul");
405
- if (Array.isArray(data)) {
406
- data.forEach((item, index) => {
407
- let li = document.createElement("li");
408
- li.classList.add("jp-li");
409
- let newPath = path + "[" + index + "]";
410
- li.appendChild(this.createItemView(newPath, item));
411
- ul.appendChild(li);
412
- });
413
- } else if (typeof data === "object" && data !== null) {
414
- Object.keys(data).forEach(key => {
415
- let li = document.createElement("li");
416
- li.classList.add("jp-li");
417
- let newPath = path + "." + key;
418
- li.appendChild(this.createItemView(newPath, data[key]));
419
- ul.appendChild(li);
420
- });
421
- } else {
422
- let li = document.createElement("li");
423
- li.classList.add("jp-li");
424
- li.appendChild(this.createItemView(path, data));
425
- ul.appendChild(li);
426
- }
427
- return ul;
411
+ }
412
+
413
+ createTreeView(data, path) {
414
+ const ul = document.createElement('ul');
415
+ ul.classList.add('jp-ul');
416
+ if (Array.isArray(data)) {
417
+ data.forEach((item, index) => {
418
+ const li = document.createElement('li');
419
+ li.classList.add('jp-li');
420
+ const newPath = `${path}[${index}]`;
421
+ li.appendChild(this.createItemView(newPath, item));
422
+ ul.appendChild(li);
423
+ });
424
+ } else if (typeof data === 'object' && data !== null) {
425
+ Object.keys(data).forEach(key => {
426
+ const li = document.createElement('li');
427
+ li.classList.add('jp-li');
428
+ const newPath = `${path}.${key}`;
429
+ li.appendChild(this.createItemView(newPath, data[key]));
430
+ ul.appendChild(li);
431
+ });
432
+ } else {
433
+ const li = document.createElement('li');
434
+ li.classList.add('jp-li');
435
+ li.appendChild(this.createItemView(path, data));
436
+ ul.appendChild(li);
428
437
  }
429
-
438
+ return ul;
439
+ }
430
440
  }
431
441
 
432
-
433
442
  if (!customElements.get('fx-json-instance')) {
434
- customElements.define('fx-json-instance', FxJsonInstance);
443
+ customElements.define('fx-json-instance', FxJsonInstance);
435
444
  }
@@ -1,17 +1,14 @@
1
-
2
1
  export class FxLogItem extends HTMLElement {
3
-
4
2
  constructor() {
5
3
  super();
6
4
  this.attachShadow({ mode: 'open' });
7
5
  this.eventName = '';
8
6
  this.shortName = '';
9
7
  this.shortInfo = '';
10
- this.shortPath='';
11
- this.xpath ='';
8
+ this.shortPath = '';
9
+ this.xpath = '';
12
10
  }
13
11
 
14
-
15
12
  connectedCallback() {
16
13
  const style = `
17
14
  :host {
@@ -100,13 +97,12 @@ export class FxLogItem extends HTMLElement {
100
97
 
101
98
  this.eventName = this.getAttribute('event-name');
102
99
  this.shortName = this.getAttribute('short-name');
103
- this.shortInfo = this.hasAttribute('short-info') ? this.getAttribute('short-info'):'';
100
+ this.shortInfo = this.hasAttribute('short-info') ? this.getAttribute('short-info') : '';
104
101
  this.xpath = this.getAttribute('xpath');
105
102
 
106
-
107
- const cut = this.xpath.substring(this.xpath.indexOf('/fx-fore'), this.xpath.length);;
108
- const xpathCut = "/" + cut;
109
- const shortPath = xpathCut.replaceAll('fx-','');
103
+ const cut = this.xpath.substring(this.xpath.indexOf('/fx-fore'), this.xpath.length);
104
+ const xpathCut = `/${cut}`;
105
+ const shortPath = xpathCut.replaceAll('fx-', '');
110
106
 
111
107
  const html = `
112
108
  <details class="info send">
@@ -126,7 +122,6 @@ export class FxLogItem extends HTMLElement {
126
122
  ${html}
127
123
  `;
128
124
  }
129
-
130
125
  }
131
126
  if (!customElements.get('fx-log-item')) {
132
127
  customElements.define('fx-log-item', FxLogItem);