@jinntec/fore 1.4.0 → 1.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/dist/fore-dev.js +2 -36
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -30
- package/dist/fore.js.map +1 -1
- package/index.js +13 -0
- package/package.json +9 -5
- package/resources/fore.css +178 -92
- package/src/DependencyNotifyingDomFacade.js +1 -2
- package/src/ForeElementMixin.js +31 -5
- package/src/actions/abstract-action.js +379 -270
- package/src/actions/fx-action.js +0 -1
- package/src/actions/fx-append.js +1 -2
- package/src/actions/fx-confirm.js +12 -0
- package/src/actions/fx-copy.js +0 -1
- package/src/actions/fx-delete.js +31 -9
- package/src/actions/fx-dispatch.js +19 -5
- package/src/actions/fx-hide.js +19 -0
- package/src/actions/fx-insert.js +72 -8
- package/src/actions/fx-load.js +253 -0
- package/src/actions/fx-message.js +22 -7
- package/src/actions/fx-refresh.js +11 -1
- package/src/actions/fx-reload.js +12 -2
- package/src/actions/fx-replace.js +5 -4
- package/src/actions/fx-reset.js +48 -0
- package/src/actions/fx-return.js +0 -1
- package/src/actions/fx-send.js +40 -2
- package/src/actions/fx-setfocus.js +25 -7
- package/src/actions/fx-setvalue.js +32 -4
- package/src/actions/fx-show.js +14 -2
- package/src/actions/fx-toggle.js +0 -1
- package/src/actions/fx-update.js +9 -0
- package/src/events.js +0 -1
- package/src/fore.js +119 -63
- package/src/functions/common-function.js +28 -0
- package/src/fx-bind.js +7 -7
- package/src/fx-fore.js +207 -54
- package/src/fx-instance.js +55 -17
- package/src/fx-model.js +31 -33
- package/src/fx-submission.js +50 -47
- package/src/getInScopeContext.js +22 -8
- package/src/lab/fore-component.js +90 -0
- package/src/lab/instance-inspector.js +56 -0
- package/src/lab/template.html +16 -0
- package/src/relevance.js +27 -1
- package/src/tools/adi.js +1056 -0
- package/src/tools/fx-action-log.js +662 -0
- package/src/tools/fx-devtools.js +444 -0
- package/src/tools/fx-dom-inspector.js +609 -0
- package/src/tools/fx-json-instance.js +435 -0
- package/src/tools/fx-log-item.js +133 -0
- package/src/tools/fx-log-settings.js +474 -0
- package/src/tools/fx-minimap.js +194 -0
- package/src/tools/helpers.js +132 -0
- package/src/ui/abstract-control.js +41 -3
- package/src/ui/fx-action-log.js +358 -0
- package/src/ui/fx-alert.js +0 -1
- package/src/ui/fx-container.js +14 -3
- package/src/ui/fx-control.js +553 -474
- package/src/ui/fx-dialog.js +2 -0
- package/src/ui/fx-dom-inspector.js +1255 -0
- package/src/ui/fx-group.js +3 -4
- package/src/ui/fx-hint.js +2 -4
- package/src/ui/fx-inspector.js +5 -6
- package/src/ui/fx-items.js +55 -14
- package/src/ui/fx-output.js +36 -17
- package/src/ui/fx-repeat-attributes.js +409 -0
- package/src/ui/fx-repeat.js +12 -6
- package/src/ui/fx-switch.js +14 -3
- package/src/ui/fx-trigger.js +13 -1
- package/src/xpath-evaluation.js +109 -26
- package/src/xpath-util.js +55 -1
package/src/ui/fx-group.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { html } from 'lit-element';
|
|
2
1
|
import { Fore } from '../fore.js';
|
|
3
2
|
// import XfAbstractControl from "./fx-abstract-control";
|
|
4
3
|
import { FxContainer } from './fx-container.js';
|
|
@@ -36,7 +35,7 @@ class FxGroup extends FxContainer {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
render() {
|
|
39
|
-
return
|
|
38
|
+
return `
|
|
40
39
|
<slot></slot>
|
|
41
40
|
`;
|
|
42
41
|
}
|
|
@@ -52,10 +51,10 @@ class FxGroup extends FxContainer {
|
|
|
52
51
|
|
|
53
52
|
initializeChildren(node) {
|
|
54
53
|
const children = Array.from(node.children);
|
|
55
|
-
console.log('_initializeChildren ', children);
|
|
54
|
+
// console.log('_initializeChildren ', children);
|
|
56
55
|
|
|
57
56
|
children.forEach(child => {
|
|
58
|
-
console.log('child ', child);
|
|
57
|
+
// console.log('child ', child);
|
|
59
58
|
|
|
60
59
|
if (Fore.isUiElement(child.nodeName)) {
|
|
61
60
|
child.init(this.model);
|
package/src/ui/fx-hint.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { html, css } from 'lit-element';
|
|
2
|
-
|
|
3
1
|
import XfAbstractControl from './abstract-control.js';
|
|
4
2
|
|
|
5
3
|
export class FxHint extends XfAbstractControl {
|
|
6
4
|
static get styles() {
|
|
7
|
-
return
|
|
5
|
+
return `
|
|
8
6
|
:host {
|
|
9
7
|
display: block;
|
|
10
8
|
height: auto;
|
|
@@ -22,7 +20,7 @@ export class FxHint extends XfAbstractControl {
|
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
render() {
|
|
25
|
-
return
|
|
23
|
+
return `
|
|
26
24
|
<slot></slot>
|
|
27
25
|
`;
|
|
28
26
|
}
|
package/src/ui/fx-inspector.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { prettifyXml } from '../functions/common-function.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* lists out all live instances in html 'details' and 'summary' elements.
|
|
@@ -92,10 +92,10 @@ export class FxInspector extends HTMLElement {
|
|
|
92
92
|
|
|
93
93
|
Array.from(pre).forEach(element => {
|
|
94
94
|
const inst = fore.getModel().getInstance(element.getAttribute('id'));
|
|
95
|
-
if (inst.type === 'xml') {
|
|
95
|
+
if (inst.getAttribute('type') === 'xml') {
|
|
96
96
|
element.innerText = this.serializeDOM(inst.instanceData);
|
|
97
97
|
}
|
|
98
|
-
if (inst.type === 'json') {
|
|
98
|
+
if (inst.getAttribute('type') === 'json') {
|
|
99
99
|
element.innerText = JSON.stringify(inst.instanceData, undefined, 2);
|
|
100
100
|
}
|
|
101
101
|
});
|
|
@@ -112,7 +112,7 @@ export class FxInspector extends HTMLElement {
|
|
|
112
112
|
<slot></slot>
|
|
113
113
|
<span class="handle"></span>
|
|
114
114
|
${instances.map(
|
|
115
|
-
(instance
|
|
115
|
+
(instance) => `
|
|
116
116
|
<details>
|
|
117
117
|
<summary>${instance.id}</summary>
|
|
118
118
|
<pre id="${instance.id}"></pre>
|
|
@@ -125,7 +125,6 @@ export class FxInspector extends HTMLElement {
|
|
|
125
125
|
const handle = this.shadowRoot.querySelector('.handle');
|
|
126
126
|
handle.addEventListener('click', e => {
|
|
127
127
|
// console.log('toggling');
|
|
128
|
-
const { target } = e;
|
|
129
128
|
if (this.hasAttribute('open')) {
|
|
130
129
|
this.removeAttribute('open');
|
|
131
130
|
} else {
|
|
@@ -141,7 +140,7 @@ export class FxInspector extends HTMLElement {
|
|
|
141
140
|
}
|
|
142
141
|
// console.log('serializeDOM', data);
|
|
143
142
|
const ser = new XMLSerializer().serializeToString(data);
|
|
144
|
-
return
|
|
143
|
+
return prettifyXml(ser);
|
|
145
144
|
}
|
|
146
145
|
}
|
|
147
146
|
|
package/src/ui/fx-items.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { evaluateXPathToString, resolveId } from '../xpath-evaluation.js';
|
|
1
|
+
import { evaluateXPath,evaluateXPathToString, resolveId } from '../xpath-evaluation.js';
|
|
2
2
|
import FxControl from './fx-control.js';
|
|
3
3
|
import { Fore } from '../fore.js';
|
|
4
|
+
import { XPathUtil} from "../xpath-util.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* FxItems provices a templated list over its bound nodes. It is not standalone but expects to be used
|
|
@@ -27,10 +28,38 @@ export class FxItems extends FxControl {
|
|
|
27
28
|
|
|
28
29
|
connectedCallback() {
|
|
29
30
|
super.connectedCallback();
|
|
31
|
+
// Some other library is stealing focus when clicking on the label of a checkbox list.
|
|
32
|
+
// The browser should handle this, but we need to manually focus the checkbox if the label is pressed
|
|
33
|
+
// TODO: find a better solution
|
|
34
|
+
this.addEventListener('mousedown', e => {
|
|
35
|
+
// const items = this.querySelectorAll('[value]');
|
|
36
|
+
|
|
37
|
+
if (!Fore.isWidget(e.target)) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
e.stopImmediatePropagation();
|
|
40
|
+
}
|
|
30
41
|
|
|
31
|
-
|
|
42
|
+
if (e.target.nodeName === 'LABEL') {
|
|
43
|
+
const target = resolveId(e.target.getAttribute('for'), this);
|
|
44
|
+
target.focus();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Some other library is stealing focus when clicking on the label of a checkbox list.
|
|
49
|
+
// The browser should handle this, but we need to manually focus the checkbox if the label is pressed
|
|
50
|
+
// TODO: find a better solution
|
|
51
|
+
this.addEventListener('mousedown', e => {
|
|
32
52
|
const items = this.querySelectorAll('[value]');
|
|
33
53
|
|
|
54
|
+
if (e.target.nodeName === 'LABEL') {
|
|
55
|
+
const target = resolveId(e.target.getAttribute('for'), this);
|
|
56
|
+
target.focus();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
this.addEventListener('click', e => {
|
|
60
|
+
e.preventDefault;
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
const items = this.querySelectorAll('[value]');
|
|
34
63
|
let target;
|
|
35
64
|
if (e.target.nodeName === 'LABEL') {
|
|
36
65
|
target = resolveId(e.target.getAttribute('for'), this);
|
|
@@ -46,7 +75,7 @@ export class FxItems extends FxControl {
|
|
|
46
75
|
this.setAttribute('value', val.trim());
|
|
47
76
|
|
|
48
77
|
// ### check for parent control
|
|
49
|
-
const parentBind =
|
|
78
|
+
const parentBind = XPathUtil.getClosest('[ref]', this.parentNode);
|
|
50
79
|
if (!parentBind) return;
|
|
51
80
|
const modelitem = parentBind.getModelItem();
|
|
52
81
|
const setval = this.shadowRoot.getElementById('setvalue');
|
|
@@ -62,7 +91,7 @@ export class FxItems extends FxControl {
|
|
|
62
91
|
async updateWidgetValue() {
|
|
63
92
|
// console.log('setting items value');
|
|
64
93
|
|
|
65
|
-
const parentBind =
|
|
94
|
+
const parentBind = XPathUtil.getClosest('[ref]', this.parentNode);
|
|
66
95
|
if (parentBind) {
|
|
67
96
|
this.value = parentBind.value;
|
|
68
97
|
}
|
|
@@ -84,28 +113,40 @@ export class FxItems extends FxControl {
|
|
|
84
113
|
*/
|
|
85
114
|
updateEntry(newEntry, node) {
|
|
86
115
|
// console.log('fx-items updateEntry', this.value);
|
|
87
|
-
// super.updateEntry(newEntry,node);
|
|
88
116
|
|
|
89
|
-
// ###
|
|
90
|
-
|
|
91
|
-
// ### danger zone - highly specific - assumes knowledge of the template structure ###
|
|
117
|
+
// ### create unique id to connect label and input
|
|
118
|
+
const id = Fore.createUUID();
|
|
92
119
|
|
|
120
|
+
// ### handle 'label'
|
|
93
121
|
const label = newEntry.querySelector('label');
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
122
|
+
const lblExpr = Fore.getExpression(label.textContent);
|
|
123
|
+
|
|
124
|
+
// ### xml / JSON
|
|
125
|
+
if(node.nodeType){
|
|
126
|
+
const lblEvaluated = evaluateXPathToString(lblExpr, node, this);
|
|
127
|
+
label.textContent = lblEvaluated;
|
|
128
|
+
} else{
|
|
129
|
+
const labelExpr = Fore.getExpression(lblExpr);
|
|
130
|
+
label.textContent = node[labelExpr];
|
|
131
|
+
}
|
|
97
132
|
label.setAttribute('for', id);
|
|
98
133
|
|
|
134
|
+
// ### handle the 'value'
|
|
99
135
|
// getting element which has 'value' attr
|
|
100
136
|
const input = newEntry.querySelector('[value]');
|
|
101
137
|
// getting expr
|
|
102
138
|
const expr = input.value;
|
|
103
|
-
const cutted = expr.substring(1, expr.length - 1);
|
|
104
|
-
const
|
|
139
|
+
// const cutted = expr.substring(1, expr.length - 1);
|
|
140
|
+
const cutted = Fore.getExpression(expr);
|
|
141
|
+
let evaluated;
|
|
142
|
+
if(node.nodeType){
|
|
143
|
+
evaluated = evaluateXPathToString(cutted, node, newEntry);
|
|
144
|
+
}else{
|
|
145
|
+
evaluated = node[cutted];
|
|
146
|
+
}
|
|
105
147
|
|
|
106
148
|
// adding space around value to allow matching of 'words'
|
|
107
149
|
const spaced = ` ${evaluated} `;
|
|
108
|
-
|
|
109
150
|
const valAttr = ` ${this.getAttribute('value')} `;
|
|
110
151
|
input.value = evaluated;
|
|
111
152
|
input.setAttribute('id', id);
|
package/src/ui/fx-output.js
CHANGED
|
@@ -31,6 +31,7 @@ export class FxOutput extends XfAbstractControl {
|
|
|
31
31
|
const style = `
|
|
32
32
|
:host {
|
|
33
33
|
display: inline-block;
|
|
34
|
+
max-width:100%;
|
|
34
35
|
}
|
|
35
36
|
#widget {
|
|
36
37
|
display: inline-block;
|
|
@@ -38,14 +39,8 @@ export class FxOutput extends XfAbstractControl {
|
|
|
38
39
|
.label{
|
|
39
40
|
display: inline-block;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
width:100%;
|
|
43
|
-
}
|
|
44
|
-
th{
|
|
45
|
-
text-align:left;
|
|
46
|
-
}
|
|
47
|
-
td{
|
|
48
|
-
padding-right:1rem;
|
|
42
|
+
#value{
|
|
43
|
+
max-width:100%;
|
|
49
44
|
}
|
|
50
45
|
`;
|
|
51
46
|
|
|
@@ -53,7 +48,7 @@ export class FxOutput extends XfAbstractControl {
|
|
|
53
48
|
<slot name="label"></slot>
|
|
54
49
|
|
|
55
50
|
<span id="value">
|
|
56
|
-
<slot></slot>
|
|
51
|
+
<slot name="default"></slot>
|
|
57
52
|
</span>
|
|
58
53
|
`;
|
|
59
54
|
|
|
@@ -117,7 +112,7 @@ export class FxOutput extends XfAbstractControl {
|
|
|
117
112
|
async updateWidgetValue() {
|
|
118
113
|
// console.log('updateWidgetValue');
|
|
119
114
|
const valueWrapper = this.shadowRoot.getElementById('value');
|
|
120
|
-
|
|
115
|
+
valueWrapper.innerHTML = '';
|
|
121
116
|
|
|
122
117
|
// if (this.mediatype === 'markdown') {
|
|
123
118
|
// const md = markdown(this.nodeset);
|
|
@@ -126,13 +121,27 @@ export class FxOutput extends XfAbstractControl {
|
|
|
126
121
|
|
|
127
122
|
if (this.mediatype === 'html') {
|
|
128
123
|
if (this.modelItem.node) {
|
|
129
|
-
/*
|
|
130
|
-
valueWrapper.innerHTML = this.modelItem.node.outerHTML;
|
|
131
|
-
return;
|
|
132
|
-
*/
|
|
133
124
|
|
|
125
|
+
const defaultSlot = this.shadowRoot.querySelector('#default');
|
|
134
126
|
const { node } = this.modelItem;
|
|
127
|
+
if (node.nodeType) {
|
|
128
|
+
|
|
129
|
+
valueWrapper.append(node);
|
|
130
|
+
// this.appendChild(node);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ### try to parse as string
|
|
135
|
+
const tmpDoc = new DOMParser().parseFromString(node,'text/html');
|
|
136
|
+
const theNode = tmpDoc.body.childNodes;
|
|
137
|
+
// console.log('actual node', theNode)
|
|
138
|
+
Array.from(theNode).forEach(n =>{
|
|
139
|
+
valueWrapper.append(n);
|
|
140
|
+
});
|
|
141
|
+
// valueWrapper.append(theNode);
|
|
135
142
|
|
|
143
|
+
// valueWrapper.innerHTML=node;
|
|
144
|
+
/*
|
|
136
145
|
if (node.nodeType) {
|
|
137
146
|
this.appendChild(node);
|
|
138
147
|
return;
|
|
@@ -141,11 +150,19 @@ export class FxOutput extends XfAbstractControl {
|
|
|
141
150
|
// valueWrapper.appendChild(obj[1]);
|
|
142
151
|
this.appendChild(obj[1]);
|
|
143
152
|
});
|
|
153
|
+
*/
|
|
154
|
+
/*
|
|
155
|
+
Object.entries(node).map(obj => {
|
|
156
|
+
// valueWrapper.appendChild(obj[1]);
|
|
157
|
+
this.appendChild(obj[1]);
|
|
158
|
+
});
|
|
159
|
+
*/
|
|
160
|
+
|
|
144
161
|
return;
|
|
145
162
|
}
|
|
146
163
|
|
|
147
164
|
// this.innerHTML = this.value.outerHTML;
|
|
148
|
-
valueWrapper.innerHTML = this.value.outerHTML;
|
|
165
|
+
// valueWrapper.innerHTML = this.value.outerHTML;
|
|
149
166
|
|
|
150
167
|
// this.shadowRoot.appendChild(this.value);
|
|
151
168
|
return;
|
|
@@ -153,8 +170,10 @@ export class FxOutput extends XfAbstractControl {
|
|
|
153
170
|
|
|
154
171
|
if(this.mediatype === 'image'){
|
|
155
172
|
const img = document.createElement('img');
|
|
156
|
-
|
|
157
|
-
|
|
173
|
+
img.setAttribute('src',this.value);
|
|
174
|
+
// Reset the output before adding the image
|
|
175
|
+
this.innerHTML = '';
|
|
176
|
+
valueWrapper.appendChild(img);
|
|
158
177
|
return;
|
|
159
178
|
}
|
|
160
179
|
|