@jinntec/fore 1.3.0 → 1.4.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 +4 -4
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +3 -3
- package/dist/fore.js.map +1 -1
- package/package.json +1 -1
- package/resources/fore.css +6 -1
- package/src/ForeElementMixin.js +4 -0
- package/src/actions/abstract-action.js +77 -35
- package/src/actions/fx-action.js +9 -9
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-confirm.js +1 -1
- package/src/actions/fx-copy.js +68 -0
- package/src/actions/fx-delete.js +1 -1
- package/src/actions/fx-dispatch.js +1 -1
- package/src/actions/fx-hide.js +1 -1
- package/src/actions/fx-insert.js +1 -1
- package/src/actions/fx-message.js +1 -1
- package/src/actions/fx-refresh.js +2 -2
- package/src/actions/fx-reload.js +1 -1
- package/src/actions/fx-replace.js +1 -1
- package/src/actions/fx-return.js +1 -1
- package/src/actions/fx-send.js +2 -2
- package/src/actions/fx-setfocus.js +1 -1
- package/src/actions/fx-setvalue.js +1 -1
- package/src/actions/fx-show.js +1 -1
- package/src/actions/fx-toggle.js +1 -1
- package/src/actions/fx-update.js +1 -1
- package/src/fore.js +58 -10
- package/src/fx-bind.js +5 -0
- package/src/fx-fore.js +36 -35
- package/src/fx-instance.js +70 -70
- package/src/fx-model.js +12 -17
- package/src/fx-submission.js +420 -416
- package/src/getInScopeContext.js +2 -4
- package/src/modelitem.js +3 -1
- package/src/ui/abstract-control.js +1 -1
- package/src/ui/fx-control.js +2 -2
- package/src/ui/fx-switch.js +9 -1
- package/src/ui/fx-trigger.js +19 -18
- package/src/xpath-evaluation.js +21 -9
- package/src/xpath-util.js +13 -28
package/src/getInScopeContext.js
CHANGED
|
@@ -52,10 +52,8 @@ function _getInitialContext(node, ref) {
|
|
|
52
52
|
}
|
|
53
53
|
return model.getDefaultInstance().getDefaultContext();
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
return [];
|
|
55
|
+
// should always return default context if all other fails
|
|
56
|
+
return model.getDefaultInstance().getDefaultContext();
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
export default function getInScopeContext(node, ref) {
|
package/src/modelitem.js
CHANGED
|
@@ -257,7 +257,7 @@ export default class AbstractControl extends foreElementMixin(HTMLElement) {
|
|
|
257
257
|
const alert = this.querySelector('fx-alert');
|
|
258
258
|
|
|
259
259
|
const mi = this.getModelItem();
|
|
260
|
-
console.log('late modelItem', mi);
|
|
260
|
+
// console.log('late modelItem', mi);
|
|
261
261
|
if (this.isValid() !== this.modelItem.constraint) {
|
|
262
262
|
if (this.modelItem.constraint) {
|
|
263
263
|
// if (alert) alert.style.display = 'none';
|
package/src/ui/fx-control.js
CHANGED
|
@@ -482,7 +482,7 @@ export default class FxControl extends XfAbstractControl {
|
|
|
482
482
|
if (nodeset.length) {
|
|
483
483
|
// console.log('nodeset', nodeset);
|
|
484
484
|
const fragment = document.createDocumentFragment();
|
|
485
|
-
console.time('offscreen');
|
|
485
|
+
// console.time('offscreen');
|
|
486
486
|
/*
|
|
487
487
|
Array.from(nodeset).forEach(node => {
|
|
488
488
|
// console.log('#### node', node);
|
|
@@ -504,7 +504,7 @@ export default class FxControl extends XfAbstractControl {
|
|
|
504
504
|
this.updateEntry(newEntry, node);
|
|
505
505
|
});
|
|
506
506
|
this.template.parentNode.appendChild(fragment);
|
|
507
|
-
console.timeEnd('offscreen');
|
|
507
|
+
// console.timeEnd('offscreen');
|
|
508
508
|
} else {
|
|
509
509
|
const newEntry = this.createEntry();
|
|
510
510
|
this.template.parentNode.appendChild(newEntry);
|
package/src/ui/fx-switch.js
CHANGED
|
@@ -5,7 +5,6 @@ import { FxContainer } from './fx-container.js';
|
|
|
5
5
|
* `fx-switch`
|
|
6
6
|
* a container allowing to switch between fx-case elements
|
|
7
7
|
*
|
|
8
|
-
* * todo: implement
|
|
9
8
|
* @customElement
|
|
10
9
|
*/
|
|
11
10
|
class FxSwitch extends FxContainer {
|
|
@@ -45,9 +44,13 @@ class FxSwitch extends FxContainer {
|
|
|
45
44
|
Array.from(cases).forEach(caseElem => {
|
|
46
45
|
const name = caseElem.getAttribute('name');
|
|
47
46
|
if (name === this.modelItem.value) {
|
|
47
|
+
Fore.dispatch(caseElem,'select',{});
|
|
48
48
|
caseElem.classList.add('selected-case');
|
|
49
49
|
selectedCase = caseElem;
|
|
50
50
|
} else {
|
|
51
|
+
if(caseElem.classList.contains('selected-case')){
|
|
52
|
+
Fore.dispatch(caseElem,'deselect',{});
|
|
53
|
+
}
|
|
51
54
|
caseElem.classList.remove('selected-case');
|
|
52
55
|
}
|
|
53
56
|
});
|
|
@@ -56,6 +59,7 @@ class FxSwitch extends FxContainer {
|
|
|
56
59
|
// if none is selected select the first as default
|
|
57
60
|
if (!selectedCase) {
|
|
58
61
|
selectedCase = cases[0];
|
|
62
|
+
Fore.dispatch(selectedCase,'select',{});
|
|
59
63
|
selectedCase.classList.add('selected-case');
|
|
60
64
|
}
|
|
61
65
|
}
|
|
@@ -69,9 +73,13 @@ class FxSwitch extends FxContainer {
|
|
|
69
73
|
if (caseElement === c) {
|
|
70
74
|
// eslint-disable-next-line no-param-reassign
|
|
71
75
|
c.classList.add('selected-case');
|
|
76
|
+
Fore.dispatch(c,'select',{});
|
|
72
77
|
this.refresh();
|
|
73
78
|
} else {
|
|
74
79
|
// eslint-disable-next-line no-param-reassign
|
|
80
|
+
if(c.classList.contains('selected-case')){
|
|
81
|
+
Fore.dispatch(c,'deselect',{});
|
|
82
|
+
}
|
|
75
83
|
c.classList.remove('selected-case');
|
|
76
84
|
}
|
|
77
85
|
});
|
package/src/ui/fx-trigger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import XfAbstractControl from './abstract-control.js';
|
|
2
|
-
import {leadingDebounce} from
|
|
2
|
+
import { leadingDebounce } from '../events.js';
|
|
3
3
|
|
|
4
4
|
export class FxTrigger extends XfAbstractControl {
|
|
5
5
|
connectedCallback() {
|
|
@@ -28,14 +28,18 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
28
28
|
|
|
29
29
|
const element = elements[0];
|
|
30
30
|
|
|
31
|
-
if(this.debounceDelay){
|
|
31
|
+
if (this.debounceDelay) {
|
|
32
32
|
this.addEventListener(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
'click',
|
|
34
|
+
leadingDebounce(
|
|
35
|
+
this,
|
|
36
|
+
e => {
|
|
37
|
+
this.performActions(e);
|
|
38
|
+
},
|
|
39
|
+
this.debounceDelay,
|
|
40
|
+
),
|
|
37
41
|
);
|
|
38
|
-
}else{
|
|
42
|
+
} else {
|
|
39
43
|
element.addEventListener('click', e => this.performActions(e));
|
|
40
44
|
}
|
|
41
45
|
this.widget = element;
|
|
@@ -63,7 +67,7 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
async updateWidgetValue() {
|
|
66
|
-
console.log('trigger update', this);
|
|
70
|
+
// console.log('trigger update', this);
|
|
67
71
|
return null;
|
|
68
72
|
}
|
|
69
73
|
|
|
@@ -88,17 +92,14 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
88
92
|
// Update all child variables, but only once
|
|
89
93
|
this.querySelectorAll('fx-var').forEach(variableElement => variableElement.refresh());
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// child.execute(e);
|
|
98
|
-
}
|
|
95
|
+
for (let i = 0; i < this.children.length; i += 1) {
|
|
96
|
+
const child = this.children[i];
|
|
97
|
+
if (typeof child.execute === 'function') {
|
|
98
|
+
// eslint-disable-next-line no-await-in-loop
|
|
99
|
+
await child.execute(e);
|
|
100
|
+
// child.execute(e);
|
|
99
101
|
}
|
|
100
|
-
}
|
|
101
|
-
forLoop();
|
|
102
|
+
}
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
/*
|
package/src/xpath-evaluation.js
CHANGED
|
@@ -47,8 +47,21 @@ const xhtmlNamespaceResolver = prefix => {
|
|
|
47
47
|
* Resolve an id in scope. Behaves like the algorithm defined on https://www.w3.org/community/xformsusers/wiki/XForms_2.0#idref-resolve
|
|
48
48
|
*/
|
|
49
49
|
export function resolveId(id, sourceObject, nodeName = null) {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
let query = 'outermost(ancestor-or-self::fx-fore[1]/(descendant::fx-fore|descendant::*[@id = $id]))[not(self::fx-fore)]';
|
|
51
|
+
/*
|
|
52
|
+
if (nodeName === 'fx-instance') {
|
|
53
|
+
// Instance elements can only be in the `model` element
|
|
54
|
+
// query = 'ancestor-or-self::fx-fore[1]/fx-model/fx-instance[@id = $id]';
|
|
55
|
+
|
|
56
|
+
const fore = Fore.getFore(sourceObject);
|
|
57
|
+
const instances = fore.getModel().instances;
|
|
58
|
+
const targetInstance = instances.find(i => i.id === id);
|
|
59
|
+
return targetInstance;
|
|
60
|
+
return document.getElementById(id);
|
|
61
|
+
}
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
const allMatchingTargetObjects = fxEvaluateXPathToNodes(query,
|
|
52
65
|
sourceObject,
|
|
53
66
|
null,
|
|
54
67
|
{id},
|
|
@@ -749,19 +762,18 @@ const instance = (dynamicContext, string) => {
|
|
|
749
762
|
{namespaceResolver: xhtmlNamespaceResolver},
|
|
750
763
|
);
|
|
751
764
|
|
|
752
|
-
|
|
753
|
-
|
|
765
|
+
const inst = string
|
|
766
|
+
? formElement.querySelector(`#${string}`)
|
|
767
|
+
: formElement.querySelector(`fx-instance`);
|
|
754
768
|
|
|
769
|
+
/*
|
|
755
770
|
const inst = string
|
|
756
771
|
? resolveId(string, formElement, 'fx-instance')
|
|
757
772
|
: formElement.querySelector(`fx-instance`);
|
|
773
|
+
*/
|
|
758
774
|
|
|
759
|
-
// const def = instance.getInstanceData();
|
|
760
775
|
if (inst) {
|
|
761
|
-
|
|
762
|
-
// console.log('target instance root node: ', def);
|
|
763
|
-
|
|
764
|
-
return def;
|
|
776
|
+
return inst.getDefaultContext();
|
|
765
777
|
}
|
|
766
778
|
return null;
|
|
767
779
|
};
|
package/src/xpath-util.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import * as fx from 'fontoxpath';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Checks wether the specified path expression is an absolute path.
|
|
5
|
-
*
|
|
6
|
-
* @param path the path expression.
|
|
7
|
-
* @return <code>true</code> if specified path expression is an absolute
|
|
8
|
-
* path, otherwise <code>false</code>.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
3
|
export class XPathUtil {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* returns next bound element upwards in tree
|
|
7
|
+
* @param start where to start the search
|
|
8
|
+
* @returns {*|null}
|
|
9
|
+
*/
|
|
12
10
|
static getParentBindingElement(start) {
|
|
13
11
|
/* if (start.parentNode.host) {
|
|
14
12
|
const { host } = start.parentNode;
|
|
@@ -25,6 +23,13 @@ export class XPathUtil {
|
|
|
25
23
|
return null;
|
|
26
24
|
}
|
|
27
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether the specified path expression is an absolute path.
|
|
28
|
+
*
|
|
29
|
+
* @param path the path expression.
|
|
30
|
+
* @return <code>true</code> if specified path expression is an absolute
|
|
31
|
+
* path, otherwise <code>false</code>.
|
|
32
|
+
*/
|
|
28
33
|
static isAbsolutePath(path) {
|
|
29
34
|
return path != null && (path.startsWith('/') || path.startsWith('instance('));
|
|
30
35
|
}
|
|
@@ -33,26 +38,6 @@ export class XPathUtil {
|
|
|
33
38
|
return ref === '.' || ref === './text()' || ref === 'text()' || ref === '' || ref === null;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
static getDefaultInstance(boundElement) {
|
|
37
|
-
// const fore = boundElement.closest('fx-fore');
|
|
38
|
-
const fore = XPathUtil.getForeElement(boundElement);
|
|
39
|
-
const defaultInstance = fore.querySelector('fx-instance');
|
|
40
|
-
if (!defaultInstance) {
|
|
41
|
-
throw new Error('no default instance present');
|
|
42
|
-
}
|
|
43
|
-
return defaultInstance;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static getForeElement(start) {
|
|
47
|
-
if (start.nodeName === 'FX-FORE') {
|
|
48
|
-
return start;
|
|
49
|
-
}
|
|
50
|
-
if (start.parentNode) {
|
|
51
|
-
return XPathUtil.getForeElement(start.parentNode);
|
|
52
|
-
}
|
|
53
|
-
throw new Error('no Fore element present');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
41
|
/**
|
|
57
42
|
* returns the instance id from a complete XPath using `instance()` function.
|
|
58
43
|
*
|