@jinntec/fore 2.9.0 → 3.1.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/README.md +0 -2
- package/dist/fore-dev.js +9505 -6057
- package/dist/fore.js +9218 -5996
- package/index.js +1 -0
- package/package.json +4 -2
- package/src/DependentXPathQueries.js +37 -2
- package/src/ForeElementMixin.js +64 -38
- package/src/actions/fx-delete.js +424 -73
- package/src/actions/fx-insert.js +472 -73
- package/src/actions/fx-setattribute.js +5 -5
- package/src/actions/fx-setvalue.js +11 -9
- package/src/authoring-check.js +231 -0
- package/src/fore.js +32 -77
- package/src/functions/registerFunction.js +65 -20
- package/src/fx-bind.js +128 -73
- package/src/fx-fore.js +653 -219
- package/src/fx-instance.js +145 -143
- package/src/fx-model.js +292 -102
- package/src/fx-speech.js +268 -0
- package/src/fx-submission.js +246 -135
- package/src/fx-var.js +28 -4
- package/src/json/JSONDomFacade.js +84 -0
- package/src/json/JSONLens.js +67 -0
- package/src/json/JSONNode.js +248 -0
- package/src/json/lensFromNode.js +5 -0
- package/src/modelitem.js +16 -2
- package/src/tools/fx-action-log.js +1 -1
- package/src/ui/UIElement.js +16 -2
- package/src/ui/abstract-control.js +14 -7
- package/src/ui/fx-case.js +3 -1
- package/src/ui/fx-control.js +4 -2
- package/src/ui/fx-group.js +1 -1
- package/src/ui/fx-items.js +26 -32
- package/src/ui/fx-output.js +8 -38
- package/src/ui/fx-repeat-attributes.js +1 -1
- package/src/ui/fx-repeat.js +683 -247
- package/src/ui/fx-repeatitem.js +16 -1
- package/src/ui/repeat-base.js +9 -5
- package/src/withDraggability.js +0 -1
- package/src/xpath-evaluation.js +1763 -740
- package/src/xpath-path.js +274 -24
- package/src/xpath-util.js +92 -46
package/src/ui/fx-items.js
CHANGED
|
@@ -7,8 +7,6 @@ import { XPathUtil } from '../xpath-util.js';
|
|
|
7
7
|
* FxItems provides a templated list over its bound nodes. It is not standalone but expects to be used
|
|
8
8
|
* within an fx-control element.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
10
|
* @demo demo/selects3.html
|
|
13
11
|
*/
|
|
14
12
|
export class FxItems extends FxControl {
|
|
@@ -56,22 +54,19 @@ export class FxItems extends FxControl {
|
|
|
56
54
|
target.focus();
|
|
57
55
|
}
|
|
58
56
|
});
|
|
57
|
+
|
|
59
58
|
this.addEventListener('click', e => {
|
|
60
|
-
e.preventDefault;
|
|
59
|
+
e.preventDefault; // keep as-is (do not change behavior here)
|
|
61
60
|
e.stopPropagation();
|
|
62
61
|
const items = this.querySelectorAll('[value]');
|
|
63
|
-
/*
|
|
64
|
-
let target;
|
|
65
|
-
if (e.target.nodeName === 'LABEL') {
|
|
66
|
-
target = resolveId(e.target.getAttribute('for'), this);
|
|
67
|
-
target.checked = !target.checked;
|
|
68
|
-
}
|
|
69
|
-
*/
|
|
70
62
|
|
|
71
63
|
let val = '';
|
|
72
64
|
Array.from(items).forEach(item => {
|
|
73
65
|
if (item.checked) {
|
|
74
|
-
|
|
66
|
+
// ROOT FIX: for generated inputs, attribute "value" may still be "{value}".
|
|
67
|
+
// The DOM property .value is the authoritative one.
|
|
68
|
+
const v = item.value != null ? item.value : item.getAttribute('value');
|
|
69
|
+
val += ` ${v}`;
|
|
75
70
|
}
|
|
76
71
|
});
|
|
77
72
|
this.setAttribute('value', val.trim());
|
|
@@ -90,6 +85,11 @@ export class FxItems extends FxControl {
|
|
|
90
85
|
return this;
|
|
91
86
|
}
|
|
92
87
|
|
|
88
|
+
async refresh(force = false) {
|
|
89
|
+
super.refresh(force);
|
|
90
|
+
// console.log('fx-items.refresh() called');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
93
|
async updateWidgetValue() {
|
|
94
94
|
// console.log('setting items value');
|
|
95
95
|
|
|
@@ -108,8 +108,6 @@ export class FxItems extends FxControl {
|
|
|
108
108
|
* attention: limitations here: assumes that there's an `label` element plus an element with an `value`
|
|
109
109
|
* attribute which it will update.
|
|
110
110
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
111
|
* @param newEntry
|
|
114
112
|
* @param node
|
|
115
113
|
*/
|
|
@@ -123,14 +121,12 @@ export class FxItems extends FxControl {
|
|
|
123
121
|
const label = newEntry.querySelector('label');
|
|
124
122
|
const lblExpr = Fore.getExpression(label.textContent);
|
|
125
123
|
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
label.textContent = node[labelExpr];
|
|
133
|
-
}
|
|
124
|
+
// ROOT FIX: JSON lens nodes are objects; do NOT use direct JS property access.
|
|
125
|
+
// Always go through evaluateXPathToString() for JSON too.
|
|
126
|
+
const lblEvaluated = evaluateXPathToString(lblExpr, node, this);
|
|
127
|
+
// console.log('lblEvaluated ', lblEvaluated);
|
|
128
|
+
label.textContent = lblEvaluated;
|
|
129
|
+
|
|
134
130
|
label.setAttribute('for', id);
|
|
135
131
|
|
|
136
132
|
// ### handle the 'value'
|
|
@@ -138,24 +134,22 @@ export class FxItems extends FxControl {
|
|
|
138
134
|
const input = newEntry.querySelector('[value]');
|
|
139
135
|
// getting expr
|
|
140
136
|
const expr = input.value;
|
|
141
|
-
// const cutted = expr.substring(1, expr.length - 1);
|
|
142
137
|
const cutted = Fore.getExpression(expr);
|
|
143
|
-
let evaluated;
|
|
144
|
-
if (node.nodeType) {
|
|
145
|
-
evaluated = evaluateXPathToString(cutted, node, newEntry);
|
|
146
|
-
} else {
|
|
147
|
-
evaluated = node[cutted];
|
|
148
|
-
}
|
|
149
138
|
|
|
139
|
+
// ROOT FIX: same here
|
|
140
|
+
const evaluated = evaluateXPathToString(cutted, node, this);
|
|
141
|
+
// console.log('evaluated ', lblEvaluated);
|
|
142
|
+
|
|
143
|
+
// Set both property and attribute so *any* downstream code path works
|
|
150
144
|
input.value = evaluated;
|
|
145
|
+
input.setAttribute('value', evaluated);
|
|
146
|
+
|
|
151
147
|
input.setAttribute('id', id);
|
|
148
|
+
|
|
152
149
|
// Normalize the current value (remove newlines, tabs, excessive spaces)
|
|
153
150
|
const currentValue = (this.getAttribute('value') || '').replace(/\s+/g, ' ').trim();
|
|
154
151
|
const valueList = currentValue.split(/\s+/); // Split on whitespace
|
|
155
152
|
|
|
156
|
-
// Check if the value is in the space-separated list of values
|
|
157
|
-
// const currentValue = this.getAttribute('value') || '';
|
|
158
|
-
// const valueList = currentValue.split(/\s+/);
|
|
159
153
|
if (valueList.includes(evaluated)) {
|
|
160
154
|
input.checked = true;
|
|
161
155
|
}
|
|
@@ -164,4 +158,4 @@ export class FxItems extends FxControl {
|
|
|
164
158
|
|
|
165
159
|
if (!customElements.get('fx-items')) {
|
|
166
160
|
customElements.define('fx-items', FxItems);
|
|
167
|
-
}
|
|
161
|
+
}
|
package/src/ui/fx-output.js
CHANGED
|
@@ -119,49 +119,19 @@ export class FxOutput extends XfAbstractControl {
|
|
|
119
119
|
// }
|
|
120
120
|
|
|
121
121
|
if (this.mediatype === 'html') {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
valueWrapper.append(
|
|
127
|
-
// this.appendChild(node);
|
|
122
|
+
// JSON instances use a lens, so modelItem.node is null — fall back to this.value
|
|
123
|
+
const source = this.modelItem.node ?? this.value;
|
|
124
|
+
if (source) {
|
|
125
|
+
if (source.nodeType) {
|
|
126
|
+
valueWrapper.append(source);
|
|
128
127
|
return;
|
|
129
128
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const theNode = tmpDoc.body.childNodes;
|
|
134
|
-
// console.log('actual node', theNode)
|
|
135
|
-
Array.from(theNode).forEach(n => {
|
|
129
|
+
// parse string as HTML
|
|
130
|
+
const tmpDoc = new DOMParser().parseFromString(source, 'text/html');
|
|
131
|
+
Array.from(tmpDoc.body.childNodes).forEach(n => {
|
|
136
132
|
valueWrapper.append(n);
|
|
137
133
|
});
|
|
138
|
-
// valueWrapper.append(theNode);
|
|
139
|
-
|
|
140
|
-
// valueWrapper.innerHTML=node;
|
|
141
|
-
/*
|
|
142
|
-
if (node.nodeType) {
|
|
143
|
-
this.appendChild(node);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
Object.entries(node).map(obj => {
|
|
147
|
-
// valueWrapper.appendChild(obj[1]);
|
|
148
|
-
this.appendChild(obj[1]);
|
|
149
|
-
});
|
|
150
|
-
*/
|
|
151
|
-
/*
|
|
152
|
-
Object.entries(node).map(obj => {
|
|
153
|
-
// valueWrapper.appendChild(obj[1]);
|
|
154
|
-
this.appendChild(obj[1]);
|
|
155
|
-
});
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
return;
|
|
159
134
|
}
|
|
160
|
-
|
|
161
|
-
// this.innerHTML = this.value.outerHTML;
|
|
162
|
-
// valueWrapper.innerHTML = this.value.outerHTML;
|
|
163
|
-
|
|
164
|
-
// this.shadowRoot.appendChild(this.value);
|
|
165
135
|
return;
|
|
166
136
|
}
|
|
167
137
|
|
|
@@ -344,7 +344,7 @@ export class FxRepeatAttributes extends withDraggability(RepeatBase, false) {
|
|
|
344
344
|
// Fore.refreshChildren(clone,true);
|
|
345
345
|
const fore = this.getOwnerForm();
|
|
346
346
|
if (!fore.lazyRefresh || force) {
|
|
347
|
-
Fore.refreshChildren(this, force);
|
|
347
|
+
await Fore.refreshChildren(this, force);
|
|
348
348
|
}
|
|
349
349
|
// this.style.display = 'block';
|
|
350
350
|
// this.style.display = this.display;
|