@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.
Files changed (42) hide show
  1. package/README.md +0 -2
  2. package/dist/fore-dev.js +9505 -6057
  3. package/dist/fore.js +9218 -5996
  4. package/index.js +1 -0
  5. package/package.json +4 -2
  6. package/src/DependentXPathQueries.js +37 -2
  7. package/src/ForeElementMixin.js +64 -38
  8. package/src/actions/fx-delete.js +424 -73
  9. package/src/actions/fx-insert.js +472 -73
  10. package/src/actions/fx-setattribute.js +5 -5
  11. package/src/actions/fx-setvalue.js +11 -9
  12. package/src/authoring-check.js +231 -0
  13. package/src/fore.js +32 -77
  14. package/src/functions/registerFunction.js +65 -20
  15. package/src/fx-bind.js +128 -73
  16. package/src/fx-fore.js +653 -219
  17. package/src/fx-instance.js +145 -143
  18. package/src/fx-model.js +292 -102
  19. package/src/fx-speech.js +268 -0
  20. package/src/fx-submission.js +246 -135
  21. package/src/fx-var.js +28 -4
  22. package/src/json/JSONDomFacade.js +84 -0
  23. package/src/json/JSONLens.js +67 -0
  24. package/src/json/JSONNode.js +248 -0
  25. package/src/json/lensFromNode.js +5 -0
  26. package/src/modelitem.js +16 -2
  27. package/src/tools/fx-action-log.js +1 -1
  28. package/src/ui/UIElement.js +16 -2
  29. package/src/ui/abstract-control.js +14 -7
  30. package/src/ui/fx-case.js +3 -1
  31. package/src/ui/fx-control.js +4 -2
  32. package/src/ui/fx-group.js +1 -1
  33. package/src/ui/fx-items.js +26 -32
  34. package/src/ui/fx-output.js +8 -38
  35. package/src/ui/fx-repeat-attributes.js +1 -1
  36. package/src/ui/fx-repeat.js +683 -247
  37. package/src/ui/fx-repeatitem.js +16 -1
  38. package/src/ui/repeat-base.js +9 -5
  39. package/src/withDraggability.js +0 -1
  40. package/src/xpath-evaluation.js +1763 -740
  41. package/src/xpath-path.js +274 -24
  42. package/src/xpath-util.js +92 -46
@@ -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
- val += ` ${item.getAttribute('value')}`;
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
- // ### xml / JSON
127
- if (node.nodeType) {
128
- const lblEvaluated = evaluateXPathToString(lblExpr, node, this);
129
- label.textContent = lblEvaluated;
130
- } else {
131
- const labelExpr = Fore.getExpression(lblExpr);
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
+ }
@@ -119,49 +119,19 @@ export class FxOutput extends XfAbstractControl {
119
119
  // }
120
120
 
121
121
  if (this.mediatype === 'html') {
122
- if (this.modelItem.node) {
123
- const defaultSlot = this.shadowRoot.querySelector('#default');
124
- const { node } = this.modelItem;
125
- if (node.nodeType) {
126
- valueWrapper.append(node);
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
- // ### try to parse as string
132
- const tmpDoc = new DOMParser().parseFromString(node, 'text/html');
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;