@jinntec/fore 2.6.0 → 2.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 +4470 -2643
- package/dist/fore.js +4415 -2620
- package/index.js +2 -0
- package/package.json +10 -4
- package/resources/fore.css +2 -6
- package/src/DependencyNotifyingDomFacade.js +27 -21
- package/src/ForeElementMixin.js +282 -277
- package/src/actions/abstract-action.js +7 -12
- package/src/actions/fx-append.js +23 -2
- package/src/actions/fx-call.js +2 -2
- package/src/actions/fx-delete.js +54 -29
- package/src/actions/fx-insert.js +23 -15
- package/src/actions/fx-refresh.js +15 -5
- package/src/actions/fx-replace.js +18 -3
- package/src/actions/fx-reset.js +6 -0
- package/src/actions/fx-send.js +10 -7
- package/src/actions/fx-setattribute.js +12 -0
- package/src/actions/fx-setfocus.js +11 -8
- package/src/actions/fx-setvalue.js +93 -93
- package/src/actions/fx-toggle.js +1 -1
- package/src/extract-predicate-deps.js +57 -0
- package/src/extractPredicateDependencies.js +36 -0
- package/src/fore.js +41 -16
- package/src/fx-bind.js +128 -23
- package/src/fx-connection.js +24 -7
- package/src/fx-fore.js +506 -259
- package/src/fx-instance.js +9 -11
- package/src/fx-model.js +154 -65
- package/src/fx-submission.js +19 -30
- package/src/fx-var.js +5 -0
- package/src/getInScopeContext.js +7 -8
- package/src/modelitem.js +247 -112
- package/src/tools/fx-action-log.js +21 -19
- package/src/tools/fx-log-settings.js +4 -2
- package/src/ui/TemplateExpression.js +12 -0
- package/src/ui/UIElement.js +125 -10
- package/src/ui/abstract-control.js +5 -0
- package/src/ui/fx-case.js +15 -3
- package/src/ui/fx-container.js +5 -0
- package/src/ui/fx-control-menu.js +23 -14
- package/src/ui/fx-control.js +55 -15
- package/src/ui/fx-items.js +10 -4
- package/src/ui/fx-repeat-attributes.js +111 -35
- package/src/ui/fx-repeat.js +332 -85
- package/src/ui/fx-repeat.updated.js +821 -0
- package/src/ui/fx-repeatitem.js +23 -20
- package/src/ui/fx-switch.js +5 -3
- package/src/ui/fx-upload.js +36 -40
- package/src/ui/repeat-base.js +532 -0
- package/src/withDraggability.js +8 -4
- package/src/xpath-evaluation.js +26 -8
- package/src/xpath-path.js +79 -0
- package/src/xpath-util.js +357 -289
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as fx from 'fontoxpath';
|
|
2
|
+
import { evaluateXPathToString } from './xpath-evaluation.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} path
|
|
6
|
+
* @returns string
|
|
7
|
+
*/
|
|
8
|
+
function shortenPath(path) {
|
|
9
|
+
const tmp = path.replaceAll(/(Q{(.*?)\})/g, '');
|
|
10
|
+
if (tmp === 'root()') return tmp;
|
|
11
|
+
// cut off leading slash
|
|
12
|
+
const tmp1 = tmp.substring(1, tmp.length);
|
|
13
|
+
// ### cut-off root node ref
|
|
14
|
+
return tmp1.substring(tmp1.indexOf('/'), tmp.length);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {Node} node
|
|
19
|
+
* @returns string
|
|
20
|
+
*/
|
|
21
|
+
export function getDocPath(node) {
|
|
22
|
+
const path = fx.evaluateXPathToString('path()', node);
|
|
23
|
+
// Path is like `$default/x[1]/y[1]`
|
|
24
|
+
const shortened = shortenPath(path);
|
|
25
|
+
return shortened.startsWith('/') ? `${shortened}` : `/${shortened}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {Node} node
|
|
30
|
+
* @param {string} instanceId
|
|
31
|
+
* @returns string
|
|
32
|
+
*/
|
|
33
|
+
export function getPath(node, instanceId) {
|
|
34
|
+
const path = fx.evaluateXPathToString('path()', node);
|
|
35
|
+
// Path is like `$default/x[1]/y[1]`
|
|
36
|
+
const shortened = shortenPath(path);
|
|
37
|
+
return shortened.startsWith('/') ? `$${instanceId}${shortened}` : `$${instanceId}/${shortened}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a template expression is dynamic, i.e. refers to data (via XPath) or functions.
|
|
42
|
+
* Used to determine whether to set up data observers or evaluate on every refresh.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} expr - The raw XPath expression (from inside `{}`)
|
|
45
|
+
* @returns {boolean} - True if the expression is dynamic (data/function dependent)
|
|
46
|
+
*/
|
|
47
|
+
export function isDynamic(expr) {
|
|
48
|
+
try {
|
|
49
|
+
const result = evaluateXPathToString(expr, document, null);
|
|
50
|
+
|
|
51
|
+
// 1. Check for function calls with non-literal arguments
|
|
52
|
+
const functionCallPattern = /\b([\w-]+)\s*\(\s*([^)]+)\)/g;
|
|
53
|
+
let match;
|
|
54
|
+
while ((match = functionCallPattern.exec(expr)) !== null) {
|
|
55
|
+
const arg = match[2].trim();
|
|
56
|
+
if (!/^(['"]).*\1$/.test(arg) && isNaN(arg)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 2. Check for variable references
|
|
62
|
+
if (expr.includes('$')) return true;
|
|
63
|
+
|
|
64
|
+
// 3. Check for unquoted predicates
|
|
65
|
+
let inQuote = false;
|
|
66
|
+
for (let i = 0; i < expr.length; i++) {
|
|
67
|
+
const char = expr[i];
|
|
68
|
+
if (char === '"' || char === "'") {
|
|
69
|
+
inQuote = inQuote === char ? false : char;
|
|
70
|
+
} else if (!inQuote && char === '[') {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return false;
|
|
76
|
+
} catch {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|