@jinntec/fore 0.25.0 → 1.0.0-2
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 +75 -22
- package/dist/fore-all.js +11 -11
- package/dist/fore.js +1 -1
- package/index.js +5 -1
- package/package.json +17 -6
- package/resources/fore.css +121 -4
- package/resources/toastify.css +3 -1
- package/src/DependencyNotifyingDomFacade.js +9 -1
- package/src/ForeElementMixin.js +83 -12
- package/src/actions/abstract-action.js +101 -27
- package/src/actions/fx-action.js +4 -2
- package/src/actions/fx-append.js +21 -18
- package/src/actions/fx-confirm.js +22 -0
- package/src/actions/fx-dispatch.js +10 -2
- package/src/actions/fx-insert.js +35 -30
- package/src/actions/fx-message.js +7 -1
- package/src/actions/fx-send.js +1 -1
- package/src/actions/fx-setvalue.js +2 -9
- package/src/dep_graph.js +9 -0
- package/src/drawdown.js +172 -0
- package/src/fore.js +126 -18
- package/src/functions/fx-function.js +2 -2
- package/src/fx-bind.js +11 -7
- package/src/fx-fore.js +283 -67
- package/src/fx-header.js +20 -0
- package/src/fx-instance.js +54 -10
- package/src/fx-model.js +175 -38
- package/src/fx-submission.js +235 -53
- package/src/getInScopeContext.js +2 -3
- package/src/ui/abstract-control.js +23 -44
- package/src/ui/fx-alert.js +20 -19
- package/src/ui/fx-container.js +9 -4
- package/src/ui/fx-control.js +92 -37
- package/src/ui/fx-inspector.js +44 -0
- package/src/ui/fx-items.js +104 -20
- package/src/ui/fx-output.js +92 -3
- package/src/ui/fx-repeat.js +87 -80
- package/src/ui/fx-repeatitem.js +38 -48
- package/src/ui/fx-trigger.js +49 -27
- package/src/xpath-evaluation.js +533 -235
- package/src/xpath-util.js +50 -12
package/src/xpath-util.js
CHANGED
|
@@ -9,16 +9,59 @@ import * as fx from 'fontoxpath';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export class XPathUtil {
|
|
12
|
+
static getParentBindingElement(start) {
|
|
13
|
+
/* if (start.parentNode.host) {
|
|
14
|
+
const { host } = start.parentNode;
|
|
15
|
+
if (host.hasAttribute('ref')) {
|
|
16
|
+
return host;
|
|
17
|
+
}
|
|
18
|
+
} else */
|
|
19
|
+
if (start.parentNode && start.parentNode.nodeType !== Node.DOCUMENT_NODE) {
|
|
20
|
+
if (start.parentNode.hasAttribute('ref')) {
|
|
21
|
+
return start.parentNode;
|
|
22
|
+
}
|
|
23
|
+
XPathUtil.getParentBindingElement(start.parentNode);
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
12
28
|
static isAbsolutePath(path) {
|
|
13
29
|
return path != null && (path.startsWith('/') || path.startsWith('instance('));
|
|
14
30
|
}
|
|
15
31
|
|
|
32
|
+
static isRepeated(element) {
|
|
33
|
+
return element.parentElement.closest('fx-repeatitem');
|
|
34
|
+
}
|
|
35
|
+
|
|
16
36
|
static isSelfReference(ref) {
|
|
17
37
|
return ref === '.' || ref === './text()' || ref === 'text()' || ref === '' || ref === null;
|
|
18
38
|
}
|
|
19
39
|
|
|
40
|
+
static getDefaultInstance(boundElement) {
|
|
41
|
+
// const fore = boundElement.closest('fx-fore');
|
|
42
|
+
const fore = XPathUtil.getForeElement(boundElement);
|
|
43
|
+
const defaultInstance = fore.querySelector('fx-instance');
|
|
44
|
+
if (!defaultInstance) {
|
|
45
|
+
throw new Error('no default instance present');
|
|
46
|
+
}
|
|
47
|
+
return defaultInstance;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static getForeElement(start) {
|
|
51
|
+
if (start.nodeName === 'FX-FORE') {
|
|
52
|
+
return start;
|
|
53
|
+
}
|
|
54
|
+
if (start.parentNode) {
|
|
55
|
+
return XPathUtil.getForeElement(start.parentNode);
|
|
56
|
+
}
|
|
57
|
+
throw new Error('no Fore element present');
|
|
58
|
+
}
|
|
59
|
+
|
|
20
60
|
// todo: this will need more work to look upward for instance() expr.
|
|
21
61
|
static getInstanceId(ref) {
|
|
62
|
+
if (!ref) {
|
|
63
|
+
return 'default';
|
|
64
|
+
}
|
|
22
65
|
if (ref.startsWith('instance(')) {
|
|
23
66
|
const result = ref.substring(ref.indexOf('(') + 1);
|
|
24
67
|
return result.substring(1, result.indexOf(')') - 1);
|
|
@@ -29,25 +72,20 @@ export class XPathUtil {
|
|
|
29
72
|
// todo: certainly not ideal to rely on duplicating instance id on instance document - better way later ;)
|
|
30
73
|
static getPath(node) {
|
|
31
74
|
const path = fx.evaluateXPath('path()', node);
|
|
75
|
+
/*
|
|
32
76
|
const instanceId = node.ownerDocument.firstElementChild.getAttribute('id');
|
|
33
77
|
if (instanceId !== null && instanceId !== 'default') {
|
|
34
78
|
return `#${instanceId}${XPathUtil.shortenPath(path)}`;
|
|
35
79
|
}
|
|
80
|
+
*/
|
|
36
81
|
return XPathUtil.shortenPath(path);
|
|
37
82
|
}
|
|
38
83
|
|
|
39
84
|
static shortenPath(path) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const q = step.split('{}');
|
|
46
|
-
result += `/${q[1]}`;
|
|
47
|
-
} else {
|
|
48
|
-
result += `/${step}`;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
85
|
+
const tmp = path.replaceAll(/(Q{(.*?)\})/g, '');
|
|
86
|
+
// cut off leading slash
|
|
87
|
+
const tmp1 = tmp.substring(1, tmp.length);
|
|
88
|
+
// ### cut-off root node ref
|
|
89
|
+
return tmp1.substring(tmp1.indexOf('/'), tmp.length);
|
|
52
90
|
}
|
|
53
91
|
}
|