@jinntec/fore 1.5.0 → 1.7.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 -297
- 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-toggleboolean.js +58 -0
- package/src/actions/fx-update.js +9 -0
- package/src/events.js +0 -1
- package/src/fore.js +118 -63
- package/src/functions/common-function.js +28 -0
- package/src/fx-bind.js +9 -7
- package/src/fx-fore.js +153 -55
- 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 +8 -10
- 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-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 +10 -43
- package/src/ui/fx-repeat.js +5 -7
- 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
|
|
|
@@ -99,13 +99,13 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
99
99
|
return refd.children;
|
|
100
100
|
}
|
|
101
101
|
async connectedCallback() {
|
|
102
|
-
console.log('connectedCallback',this);
|
|
102
|
+
// console.log('connectedCallback',this);
|
|
103
103
|
// this.display = window.getComputedStyle(this, null).getPropertyValue("display");
|
|
104
104
|
this.ref = this.getAttribute('ref');
|
|
105
105
|
// this.ref = this._getRef();
|
|
106
106
|
// console.log('### fx-repeat connected ', this.id);
|
|
107
107
|
this.addEventListener('item-changed', e => {
|
|
108
|
-
console.log('handle index event ', e);
|
|
108
|
+
// console.log('handle index event ', e);
|
|
109
109
|
const { item } = e.detail;
|
|
110
110
|
const repeatedItems = this._getRepeatedItems();
|
|
111
111
|
const idx = Array.from(repeatedItems).indexOf(item);
|
|
@@ -116,9 +116,6 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
116
116
|
document.addEventListener('index-changed', e => {
|
|
117
117
|
e.stopPropagation();
|
|
118
118
|
if (!e.target === this) return;
|
|
119
|
-
console.log('handle index event ', e);
|
|
120
|
-
// const { item } = e.detail;
|
|
121
|
-
// const idx = Array.from(this.children).indexOf(item);
|
|
122
119
|
const { index } = e.detail;
|
|
123
120
|
this.index = Number(index);
|
|
124
121
|
this.applyIndex(this.children[index - 1]);
|
|
@@ -133,13 +130,11 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
133
130
|
|
|
134
131
|
// if (this.getOwnerForm().lazyRefresh) {
|
|
135
132
|
this.mutationObserver = new MutationObserver(mutations => {
|
|
136
|
-
console.log('mutations', mutations);
|
|
137
133
|
|
|
138
134
|
if (mutations[0].type === 'childList') {
|
|
139
135
|
const added = mutations[0].addedNodes[0];
|
|
140
136
|
if (added) {
|
|
141
137
|
const path = XPathUtil.getPath(added);
|
|
142
|
-
console.log('path mutated', path);
|
|
143
138
|
// this.dispatch('path-mutated',{'path':path,'nodeset':this.nodeset,'index': this.index});
|
|
144
139
|
// this.index = index;
|
|
145
140
|
// const prev = mutations[0].previousSibling.previousElementSibling;
|
|
@@ -182,7 +177,7 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
182
177
|
// ### there must be a single 'template' child
|
|
183
178
|
|
|
184
179
|
const inited = new Promise(resolve => {
|
|
185
|
-
console.log('##### repeat-attributes init ', this.id);
|
|
180
|
+
// console.log('##### repeat-attributes init ', this.id);
|
|
186
181
|
// if(!this.inited) this.init();
|
|
187
182
|
// does not use this.evalInContext as it is expecting a nodeset instead of single node
|
|
188
183
|
this._evalNodeset();
|
|
@@ -231,12 +226,9 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
231
226
|
}
|
|
232
227
|
|
|
233
228
|
async refresh(force) {
|
|
234
|
-
// console.group('fx-repeat.refresh on', this.id);
|
|
235
229
|
|
|
236
230
|
if (!this.inited) this.init();
|
|
237
|
-
console.time('repeat-refresh', this);
|
|
238
231
|
this._evalNodeset();
|
|
239
|
-
// console.log('repeat refresh nodeset ', this.nodeset);
|
|
240
232
|
|
|
241
233
|
let repeatItems = this.querySelectorAll('.fx-repeatitem');
|
|
242
234
|
let repeatItemCount = repeatItems.length;
|
|
@@ -268,6 +260,7 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
268
260
|
// add new repeatitem
|
|
269
261
|
|
|
270
262
|
const clonedTemplate = this._clone();
|
|
263
|
+
if(!clonedTemplate) return;
|
|
271
264
|
|
|
272
265
|
// ### cloned templates are always appended to the binding element - the one having the data-ref
|
|
273
266
|
const bindingElement = this.querySelector('[data-ref]');
|
|
@@ -309,13 +302,9 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
309
302
|
// this.style.display = 'block';
|
|
310
303
|
// this.style.display = this.display;
|
|
311
304
|
this.setIndex(this.index);
|
|
312
|
-
console.timeEnd('repeat-refresh');
|
|
313
|
-
|
|
314
|
-
console.groupEnd();
|
|
315
305
|
}
|
|
316
306
|
|
|
317
307
|
_dispatchIndexChange() {
|
|
318
|
-
// console.log('_dispatchIndexChange on index ', this.index);
|
|
319
308
|
this.dispatchEvent(
|
|
320
309
|
new CustomEvent('item-changed', { composed: false, bubbles: true, detail: { item: this , index:this.index } }),
|
|
321
310
|
);
|
|
@@ -355,15 +344,13 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
355
344
|
}
|
|
356
345
|
|
|
357
346
|
async _initTemplate() {
|
|
358
|
-
// const shadowTemplate = this.shadowRoot.querySelector('template');
|
|
359
|
-
// console.log('shadowtempl ', shadowTemplate);
|
|
360
347
|
|
|
361
348
|
// const defaultSlot = this.shadowRoot.querySelector('slot');
|
|
362
349
|
// todo: this is still weak - should handle that better maybe by an explicit slot?
|
|
363
350
|
// this.template = this.firstElementChild;
|
|
364
351
|
this.template = this.querySelector('template');
|
|
365
|
-
console.log('### init template for repeat ', this.id, this.template);
|
|
366
352
|
|
|
353
|
+
/*
|
|
367
354
|
if (this.template === null) {
|
|
368
355
|
// console.error('### no template found for this repeat:', this.id);
|
|
369
356
|
// todo: catch this on form element
|
|
@@ -375,31 +362,14 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
375
362
|
}),
|
|
376
363
|
);
|
|
377
364
|
}
|
|
365
|
+
*/
|
|
366
|
+
if(!this.template) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
378
369
|
|
|
379
370
|
this.shadowRoot.appendChild(this.template);
|
|
380
371
|
}
|
|
381
372
|
|
|
382
|
-
/*
|
|
383
|
-
_initRepeatItems() {
|
|
384
|
-
console.log('_initRepeatItems', this.nodeset);
|
|
385
|
-
// const model = this.getModel();
|
|
386
|
-
// this.textContent = '';
|
|
387
|
-
Array.from(this.nodeset).forEach((item, index) => {
|
|
388
|
-
|
|
389
|
-
const clone = this._clone();
|
|
390
|
-
this.appendChild(clone);
|
|
391
|
-
/!*
|
|
392
|
-
this.appendChild(repeatItem);
|
|
393
|
-
|
|
394
|
-
if (item.index === 1) {
|
|
395
|
-
this.applyIndex(item);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
this._initVariables(item);
|
|
399
|
-
*!/
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
*/
|
|
403
373
|
|
|
404
374
|
_initVariables(newRepeatItem) {
|
|
405
375
|
const inScopeVariables = new Map(this.inScopeVariables);
|
|
@@ -415,11 +385,8 @@ export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
|
415
385
|
}
|
|
416
386
|
|
|
417
387
|
_clone() {
|
|
418
|
-
// const content = this.template.content.cloneNode(true);
|
|
419
388
|
this.template = this.shadowRoot.querySelector('template');
|
|
420
|
-
|
|
421
|
-
// const content = this.template.content.cloneNode(true);
|
|
422
|
-
// return document.importNode(content, true);
|
|
389
|
+
if(!this.template) return;
|
|
423
390
|
return this.template.content.firstElementChild.cloneNode(true);
|
|
424
391
|
}
|
|
425
392
|
|
package/src/ui/fx-repeat.js
CHANGED
|
@@ -95,13 +95,12 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
connectedCallback() {
|
|
98
|
-
console.log('connectedCallback',this);
|
|
98
|
+
// console.log('connectedCallback',this);
|
|
99
99
|
// this.display = window.getComputedStyle(this, null).getPropertyValue("display");
|
|
100
100
|
this.ref = this.getAttribute('ref');
|
|
101
101
|
// this.ref = this._getRef();
|
|
102
102
|
// console.log('### fx-repeat connected ', this.id);
|
|
103
103
|
this.addEventListener('item-changed', e => {
|
|
104
|
-
console.log('handle index event ', e);
|
|
105
104
|
const { item } = e.detail;
|
|
106
105
|
const idx = Array.from(this.children).indexOf(item);
|
|
107
106
|
this.applyIndex(this.children[idx]);
|
|
@@ -111,7 +110,6 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
111
110
|
document.addEventListener('index-changed', e => {
|
|
112
111
|
e.stopPropagation();
|
|
113
112
|
if (!e.target === this) return;
|
|
114
|
-
console.log('handle index event ', e);
|
|
115
113
|
// const { item } = e.detail;
|
|
116
114
|
// const idx = Array.from(this.children).indexOf(item);
|
|
117
115
|
const { index } = e.detail;
|
|
@@ -128,13 +126,13 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
128
126
|
|
|
129
127
|
// if (this.getOwnerForm().lazyRefresh) {
|
|
130
128
|
this.mutationObserver = new MutationObserver(mutations => {
|
|
131
|
-
console.log('mutations', mutations);
|
|
129
|
+
// console.log('mutations', mutations);
|
|
132
130
|
|
|
133
131
|
if (mutations[0].type === 'childList') {
|
|
134
132
|
const added = mutations[0].addedNodes[0];
|
|
135
133
|
if (added) {
|
|
136
134
|
const path = XPathUtil.getPath(added);
|
|
137
|
-
console.log('path mutated', path);
|
|
135
|
+
// console.log('path mutated', path);
|
|
138
136
|
// this.dispatch('path-mutated',{'path':path,'nodeset':this.nodeset,'index': this.index});
|
|
139
137
|
// this.index = index;
|
|
140
138
|
// const prev = mutations[0].previousSibling.previousElementSibling;
|
|
@@ -289,7 +287,6 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
289
287
|
|
|
290
288
|
// this.repeatCount = contextSize;
|
|
291
289
|
// console.log('repeatCount', this.repeatCount);
|
|
292
|
-
console.groupEnd();
|
|
293
290
|
}
|
|
294
291
|
|
|
295
292
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -365,7 +362,8 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
365
362
|
if (repeatItem.index === 1) {
|
|
366
363
|
this.applyIndex(repeatItem);
|
|
367
364
|
}
|
|
368
|
-
|
|
365
|
+
// console.log('*********repeat item created', repeatItem.nodeset)
|
|
366
|
+
Fore.dispatch(this,'item-created',{nodeset:repeatItem.nodeset, pos:index+1});
|
|
369
367
|
this._initVariables(repeatItem);
|
|
370
368
|
});
|
|
371
369
|
}
|
package/src/ui/fx-switch.js
CHANGED
|
@@ -15,6 +15,10 @@ class FxSwitch extends FxContainer {
|
|
|
15
15
|
}
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.formerCase = {};
|
|
21
|
+
}
|
|
18
22
|
connectedCallback() {
|
|
19
23
|
if (super.connectedCallback) {
|
|
20
24
|
super.connectedCallback();
|
|
@@ -39,11 +43,11 @@ class FxSwitch extends FxContainer {
|
|
|
39
43
|
super.refresh();
|
|
40
44
|
// console.log('refresh on switch ');
|
|
41
45
|
const cases = this.querySelectorAll(':scope > fx-case');
|
|
42
|
-
let selectedCase;
|
|
46
|
+
let selectedCase = cases[0]; // first is always default
|
|
43
47
|
if (this.isBound()) {
|
|
44
48
|
Array.from(cases).forEach(caseElem => {
|
|
45
49
|
const name = caseElem.getAttribute('name');
|
|
46
|
-
if (name === this.modelItem
|
|
50
|
+
if (name === this.modelItem?.value) {
|
|
47
51
|
Fore.dispatch(caseElem,'select',{});
|
|
48
52
|
caseElem.classList.add('selected-case');
|
|
49
53
|
selectedCase = caseElem;
|
|
@@ -58,13 +62,20 @@ class FxSwitch extends FxContainer {
|
|
|
58
62
|
selectedCase = this.querySelector(':scope > .selected-case');
|
|
59
63
|
// if none is selected select the first as default
|
|
60
64
|
if (!selectedCase) {
|
|
61
|
-
selectedCase = cases[0];
|
|
65
|
+
selectedCase = cases[0]; // if nothing is selected use the first case
|
|
62
66
|
Fore.dispatch(selectedCase,'select',{});
|
|
63
67
|
selectedCase.classList.add('selected-case');
|
|
64
68
|
}
|
|
65
69
|
}
|
|
70
|
+
if(this.formerCase !== selectedCase){
|
|
71
|
+
const visited = selectedCase.querySelectorAll('.visited');
|
|
72
|
+
Array.from(visited).forEach(v =>{
|
|
73
|
+
v.classList.remove('visited');
|
|
74
|
+
});
|
|
75
|
+
}
|
|
66
76
|
|
|
67
77
|
Fore.refreshChildren(selectedCase,force);
|
|
78
|
+
this.formerCase = selectedCase;
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
toggle(caseElement) {
|
package/src/ui/fx-trigger.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import XfAbstractControl from './abstract-control.js';
|
|
2
2
|
import { leadingDebounce } from '../events.js';
|
|
3
|
+
import {resolveId} from "../xpath-evaluation";
|
|
3
4
|
|
|
4
5
|
export class FxTrigger extends XfAbstractControl {
|
|
5
6
|
connectedCallback() {
|
|
@@ -28,6 +29,11 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
28
29
|
|
|
29
30
|
const element = elements[0];
|
|
30
31
|
|
|
32
|
+
this.addEventListener('mousedown', e => {
|
|
33
|
+
console.log('target', e.target.nodeName);
|
|
34
|
+
e.target.focus();
|
|
35
|
+
});
|
|
36
|
+
|
|
31
37
|
if (this.debounceDelay) {
|
|
32
38
|
this.addEventListener(
|
|
33
39
|
'click',
|
|
@@ -85,7 +91,7 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
85
91
|
// todo: support readonly for trigger not executing the action
|
|
86
92
|
const repeatedItem = this.closest('fx-repeatitem');
|
|
87
93
|
if (repeatedItem) {
|
|
88
|
-
console.log('repeated click');
|
|
94
|
+
// console.log('repeated click');
|
|
89
95
|
repeatedItem.click();
|
|
90
96
|
}
|
|
91
97
|
|
|
@@ -95,6 +101,12 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
95
101
|
for (let i = 0; i < this.children.length; i += 1) {
|
|
96
102
|
const child = this.children[i];
|
|
97
103
|
if (typeof child.execute === 'function') {
|
|
104
|
+
if (e) {
|
|
105
|
+
// We are handling the event. Stop it from going further
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
if(e.type && child.event && e.type !== child.event) return;
|
|
109
|
+
}
|
|
98
110
|
// eslint-disable-next-line no-await-in-loop
|
|
99
111
|
await child.execute(e);
|
|
100
112
|
// child.execute(e);
|