@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.
- package/README.md +2 -2
- package/dist/fore-dev.js +2 -2
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -2
- package/dist/fore.js.map +1 -1
- package/index.js +4 -2
- package/package.json +10 -38
- package/resources/fore.css +263 -262
- package/resources/vars.css +8 -0
- package/src/DependencyNotifyingDomFacade.js +1 -0
- package/src/ForeElementMixin.js +243 -228
- package/src/actions/abstract-action.js +407 -398
- package/src/actions/fx-action.js +6 -6
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-call.js +63 -62
- package/src/actions/fx-confirm.js +11 -11
- package/src/actions/fx-construct-done.js +4 -4
- package/src/actions/fx-copy.js +36 -36
- package/src/actions/fx-delete.js +77 -79
- package/src/actions/fx-dispatch.js +14 -14
- package/src/actions/fx-hide.js +15 -15
- package/src/actions/fx-insert.js +9 -12
- package/src/actions/fx-insertchild.js +88 -0
- package/src/actions/fx-load.js +188 -185
- package/src/actions/fx-message.js +18 -19
- package/src/actions/fx-refresh.js +10 -10
- package/src/actions/fx-reload.js +16 -14
- package/src/actions/fx-replace.js +0 -1
- package/src/actions/fx-reset.js +31 -31
- package/src/actions/fx-send.js +59 -52
- package/src/actions/fx-setattribute.js +48 -49
- package/src/actions/fx-setfocus.js +54 -58
- package/src/actions/fx-setvalue.js +85 -81
- package/src/actions/fx-show.js +11 -11
- package/src/actions/fx-toggle.js +2 -2
- package/src/actions/fx-toggleboolean.js +38 -39
- package/src/actions/fx-unmodified.js +27 -0
- package/src/actions/fx-update.js +6 -6
- package/src/dep_graph.js +1 -1
- package/src/drawdown.js +23 -30
- package/src/events.js +19 -19
- package/src/fore.js +143 -125
- package/src/functions/common-function.js +24 -25
- package/src/functions/fx-function.js +6 -99
- package/src/functions/fx-functionlib.js +56 -0
- package/src/functions/registerFunction.js +112 -0
- package/src/fx-bind.js +19 -24
- package/src/fx-connection.js +226 -0
- package/src/fx-fore.js +844 -815
- package/src/fx-header.js +4 -4
- package/src/fx-instance.js +25 -29
- package/src/fx-model.js +405 -380
- package/src/fx-submission.js +399 -397
- package/src/fx-var.js +13 -12
- package/src/getInScopeContext.js +102 -89
- package/src/json-util.js +24 -24
- package/src/lab/fore-component.js +48 -52
- package/src/lab/instance-inspector.js +13 -16
- package/src/modelitem.js +48 -10
- package/src/relevance.js +12 -16
- package/src/tools/adi.js +858 -812
- package/src/tools/fx-action-log.js +377 -295
- package/src/tools/fx-devtools.js +210 -210
- package/src/tools/fx-dom-inspector.js +123 -122
- package/src/tools/fx-json-instance.js +262 -253
- package/src/tools/fx-log-item.js +6 -11
- package/src/tools/fx-log-settings.js +358 -301
- package/src/tools/fx-minimap.js +186 -177
- package/src/tools/helpers.js +1 -1
- package/src/ui/abstract-control.js +73 -53
- package/src/ui/fx-case.js +59 -7
- package/src/ui/fx-container.js +13 -14
- package/src/ui/fx-control.js +572 -538
- package/src/ui/fx-dialog.js +3 -3
- package/src/ui/fx-droptarget.js +3 -4
- package/src/ui/fx-group.js +4 -2
- package/src/ui/fx-hint.js +3 -0
- package/src/ui/fx-inspector.js +5 -5
- package/src/ui/fx-items.js +11 -11
- package/src/ui/fx-output.js +10 -12
- package/src/ui/fx-repeat-attributes.js +23 -27
- package/src/ui/fx-repeat.js +347 -344
- package/src/ui/fx-repeatitem.js +75 -68
- package/src/ui/fx-switch.js +39 -14
- package/src/ui/fx-trigger.js +4 -4
- package/src/withDraggability.js +193 -191
- package/src/xpath-evaluation.js +969 -958
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
104
|
+
const html = `
|
|
106
105
|
<div class="container"></div>
|
|
107
106
|
`;
|
|
108
107
|
|
|
109
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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, '&')
|
|
221
|
+
.replace(/</g, '<')
|
|
222
|
+
.replace(/>/g, '>')
|
|
223
|
+
.replace(/"/g, '"');
|
|
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
|
-
|
|
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
|
-
|
|
276
|
+
html += keyRepr;
|
|
253
277
|
}
|
|
254
|
-
} else if (this._typeof(json) === 'object') {
|
|
255
|
-
let keyCount = Object.keys(json).length;
|
|
256
278
|
|
|
257
|
-
|
|
258
|
-
|
|
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">⧉</span>';
|
|
281
|
+
html += ': '.concat(this.json2html(json[key], options)); // Add comma if item is not last
|
|
259
282
|
|
|
260
|
-
|
|
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
|
-
|
|
266
|
-
|
|
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">⧉</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
|
-
|
|
300
|
-
|
|
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
|
-
|
|
292
|
+
|
|
293
|
+
html += '</ul>}';
|
|
294
|
+
} else {
|
|
295
|
+
html += '{}';
|
|
296
|
+
}
|
|
310
297
|
}
|
|
311
298
|
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
380
|
-
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
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
|
-
|
|
443
|
+
customElements.define('fx-json-instance', FxJsonInstance);
|
|
435
444
|
}
|
package/src/tools/fx-log-item.js
CHANGED
|
@@ -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
|
|
108
|
-
const
|
|
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);
|