@jinntec/fore 2.1.1 → 2.3.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 (88) hide show
  1. package/README.md +2 -2
  2. package/dist/fore-dev.js +2 -2
  3. package/dist/fore-dev.js.map +1 -1
  4. package/dist/fore.js +2 -2
  5. package/dist/fore.js.map +1 -1
  6. package/index.js +4 -2
  7. package/package.json +10 -38
  8. package/resources/fore.css +263 -262
  9. package/resources/vars.css +8 -0
  10. package/src/DependencyNotifyingDomFacade.js +1 -0
  11. package/src/ForeElementMixin.js +243 -228
  12. package/src/actions/abstract-action.js +407 -398
  13. package/src/actions/fx-action.js +6 -6
  14. package/src/actions/fx-append.js +1 -1
  15. package/src/actions/fx-call.js +63 -62
  16. package/src/actions/fx-confirm.js +11 -11
  17. package/src/actions/fx-construct-done.js +4 -4
  18. package/src/actions/fx-copy.js +36 -36
  19. package/src/actions/fx-delete.js +77 -79
  20. package/src/actions/fx-dispatch.js +14 -14
  21. package/src/actions/fx-hide.js +15 -15
  22. package/src/actions/fx-insert.js +9 -12
  23. package/src/actions/fx-insertchild.js +88 -0
  24. package/src/actions/fx-load.js +188 -185
  25. package/src/actions/fx-message.js +18 -19
  26. package/src/actions/fx-refresh.js +10 -10
  27. package/src/actions/fx-reload.js +16 -14
  28. package/src/actions/fx-replace.js +0 -1
  29. package/src/actions/fx-reset.js +31 -31
  30. package/src/actions/fx-send.js +59 -52
  31. package/src/actions/fx-setattribute.js +48 -49
  32. package/src/actions/fx-setfocus.js +54 -58
  33. package/src/actions/fx-setvalue.js +85 -81
  34. package/src/actions/fx-show.js +11 -11
  35. package/src/actions/fx-toggle.js +2 -2
  36. package/src/actions/fx-toggleboolean.js +38 -39
  37. package/src/actions/fx-unmodified.js +27 -0
  38. package/src/actions/fx-update.js +6 -6
  39. package/src/dep_graph.js +1 -1
  40. package/src/drawdown.js +23 -30
  41. package/src/events.js +19 -19
  42. package/src/fore.js +143 -125
  43. package/src/functions/common-function.js +24 -25
  44. package/src/functions/fx-function.js +6 -99
  45. package/src/functions/fx-functionlib.js +56 -0
  46. package/src/functions/registerFunction.js +112 -0
  47. package/src/fx-bind.js +19 -24
  48. package/src/fx-connection.js +226 -0
  49. package/src/fx-fore.js +844 -815
  50. package/src/fx-header.js +4 -4
  51. package/src/fx-instance.js +25 -29
  52. package/src/fx-model.js +405 -380
  53. package/src/fx-submission.js +399 -397
  54. package/src/fx-var.js +13 -12
  55. package/src/getInScopeContext.js +102 -89
  56. package/src/json-util.js +24 -24
  57. package/src/lab/fore-component.js +48 -52
  58. package/src/lab/instance-inspector.js +13 -16
  59. package/src/modelitem.js +48 -10
  60. package/src/relevance.js +12 -16
  61. package/src/tools/adi.js +858 -812
  62. package/src/tools/fx-action-log.js +377 -295
  63. package/src/tools/fx-devtools.js +210 -210
  64. package/src/tools/fx-dom-inspector.js +123 -122
  65. package/src/tools/fx-json-instance.js +262 -253
  66. package/src/tools/fx-log-item.js +6 -11
  67. package/src/tools/fx-log-settings.js +358 -301
  68. package/src/tools/fx-minimap.js +186 -177
  69. package/src/tools/helpers.js +1 -1
  70. package/src/ui/abstract-control.js +73 -53
  71. package/src/ui/fx-case.js +59 -7
  72. package/src/ui/fx-container.js +13 -14
  73. package/src/ui/fx-control.js +572 -538
  74. package/src/ui/fx-dialog.js +3 -3
  75. package/src/ui/fx-droptarget.js +3 -4
  76. package/src/ui/fx-group.js +4 -2
  77. package/src/ui/fx-hint.js +3 -0
  78. package/src/ui/fx-inspector.js +5 -5
  79. package/src/ui/fx-items.js +11 -11
  80. package/src/ui/fx-output.js +10 -12
  81. package/src/ui/fx-repeat-attributes.js +23 -27
  82. package/src/ui/fx-repeat.js +347 -344
  83. package/src/ui/fx-repeatitem.js +75 -68
  84. package/src/ui/fx-switch.js +39 -14
  85. package/src/ui/fx-trigger.js +4 -4
  86. package/src/withDraggability.js +193 -191
  87. package/src/xpath-evaluation.js +969 -958
  88. package/src/xpath-util.js +161 -134
@@ -39,10 +39,10 @@ export class FxDialog extends HTMLElement {
39
39
  this.classList.remove('show');
40
40
  });
41
41
  }
42
- this.setAttribute('role','dialog');
43
- this.setAttribute('aria-modal','false');
42
+ this.setAttribute('role', 'dialog');
43
+ this.setAttribute('aria-modal', 'false');
44
44
 
45
- /*
45
+ /*
46
46
  this.addEventListener('transitionend', () => {
47
47
  console.log('transitionend');
48
48
  // this.style.display = 'none';
@@ -1,9 +1,8 @@
1
- import { foreElementMixin } from '../ForeElementMixin.js';
1
+ import ForeElementMixin from '../ForeElementMixin.js';
2
2
  import { withDraggability } from '../withDraggability.js';
3
3
 
4
- class FxDroptarget extends withDraggability(foreElementMixin(HTMLElement)) {
5
- }
4
+ class FxDroptarget extends withDraggability(ForeElementMixin) {}
6
5
 
7
6
  if (!customElements.get('fx-droptarget')) {
8
- window.customElements.define('fx-droptarget', FxDroptarget);
7
+ window.customElements.define('fx-droptarget', FxDroptarget);
9
8
  }
@@ -33,10 +33,12 @@ class FxGroup extends FxContainer {
33
33
  super();
34
34
  this.collapse = false;
35
35
  }
36
+
36
37
  connectedCallback() {
37
38
  super.connectedCallback();
38
- this.setAttribute('role','group');
39
+ this.setAttribute('role', 'group');
39
40
  }
41
+
40
42
  render() {
41
43
  return `
42
44
  <slot></slot>
@@ -89,7 +91,7 @@ class FxGroup extends FxContainer {
89
91
 
90
92
  async refresh(force) {
91
93
  super.refresh(force);
92
- Fore.refreshChildren(this,force);
94
+ Fore.refreshChildren(this, force);
93
95
  }
94
96
  }
95
97
 
package/src/ui/fx-hint.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import XfAbstractControl from './abstract-control.js';
2
2
 
3
+ /**
4
+ * @deprecated - can easily be substituted with template expression and usual <span>.
5
+ */
3
6
  export class FxHint extends XfAbstractControl {
4
7
  static get styles() {
5
8
  return `
@@ -86,7 +86,7 @@ export class FxInspector extends HTMLElement {
86
86
 
87
87
  update() {
88
88
  // console.log('update');
89
- try{
89
+ try {
90
90
  const pre = this.shadowRoot.querySelectorAll('pre');
91
91
  // console.log('pre', pre);
92
92
  const fore = this.closest('fx-fore');
@@ -100,7 +100,7 @@ export class FxInspector extends HTMLElement {
100
100
  element.innerText = JSON.stringify(inst.instanceData, undefined, 2);
101
101
  }
102
102
  });
103
- }catch (e){
103
+ } catch (e) {
104
104
  console.warn('caught problem in inspector', e.message);
105
105
  }
106
106
  }
@@ -116,7 +116,7 @@ export class FxInspector extends HTMLElement {
116
116
  <slot></slot>
117
117
  <span class="handle"></span>
118
118
  ${instances.map(
119
- (instance) => `
119
+ instance => `
120
120
  <details>
121
121
  <summary>${instance.id}</summary>
122
122
  <pre id="${instance.id}"></pre>
@@ -138,9 +138,9 @@ export class FxInspector extends HTMLElement {
138
138
  }
139
139
 
140
140
  serializeDOM(data) {
141
- if(!data){
141
+ if (!data) {
142
142
  console.warn('no data to serialize');
143
- return ;
143
+ return;
144
144
  }
145
145
  // console.log('serializeDOM', data);
146
146
  const ser = new XMLSerializer().serializeToString(data);
@@ -1,10 +1,10 @@
1
- import { evaluateXPath,evaluateXPathToString, resolveId } from '../xpath-evaluation.js';
1
+ import { evaluateXPath, evaluateXPathToString, resolveId } from '../xpath-evaluation.js';
2
2
  import FxControl from './fx-control.js';
3
3
  import { Fore } from '../fore.js';
4
- import { XPathUtil} from "../xpath-util.js";
4
+ import { XPathUtil } from '../xpath-util.js';
5
5
 
6
6
  /**
7
- * FxItems provices a templated list over its bound nodes. It is not standalone but expects to be used
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
10
  *
@@ -52,10 +52,10 @@ export class FxItems extends FxControl {
52
52
  const items = this.querySelectorAll('[value]');
53
53
 
54
54
  if (e.target.nodeName === 'LABEL') {
55
- const target = resolveId(e.target.getAttribute('for'), this);
56
- target.focus();
55
+ const target = resolveId(e.target.getAttribute('for'), this);
56
+ target.focus();
57
57
  }
58
- });
58
+ });
59
59
  this.addEventListener('click', e => {
60
60
  e.preventDefault;
61
61
  e.stopPropagation();
@@ -122,10 +122,10 @@ export class FxItems extends FxControl {
122
122
  const lblExpr = Fore.getExpression(label.textContent);
123
123
 
124
124
  // ### xml / JSON
125
- if(node.nodeType){
125
+ if (node.nodeType) {
126
126
  const lblEvaluated = evaluateXPathToString(lblExpr, node, this);
127
127
  label.textContent = lblEvaluated;
128
- } else{
128
+ } else {
129
129
  const labelExpr = Fore.getExpression(lblExpr);
130
130
  label.textContent = node[labelExpr];
131
131
  }
@@ -139,9 +139,9 @@ export class FxItems extends FxControl {
139
139
  // const cutted = expr.substring(1, expr.length - 1);
140
140
  const cutted = Fore.getExpression(expr);
141
141
  let evaluated;
142
- if(node.nodeType){
143
- evaluated = evaluateXPathToString(cutted, node, newEntry);
144
- }else{
142
+ if (node.nodeType) {
143
+ evaluated = evaluateXPathToString(cutted, node, newEntry);
144
+ } else {
145
145
  evaluated = node[cutted];
146
146
  }
147
147
 
@@ -8,7 +8,7 @@ import getInScopeContext from '../getInScopeContext.js';
8
8
  * todo: review placing of value. should probably work with value attribute and not allow slotted content.
9
9
  */
10
10
  export class FxOutput extends XfAbstractControl {
11
- /*
11
+ /*
12
12
  static get properties() {
13
13
  return {
14
14
  ...super.properties,
@@ -63,7 +63,7 @@ export class FxOutput extends XfAbstractControl {
63
63
  // console.log('widget ', this.widget);
64
64
  this.mediatype = this.hasAttribute('mediatype') ? this.getAttribute('mediatype') : null;
65
65
 
66
- /*
66
+ /*
67
67
  this.addEventListener('slotchange', e => {
68
68
  console.log('slotchange ', e);
69
69
  });
@@ -121,27 +121,25 @@ export class FxOutput extends XfAbstractControl {
121
121
 
122
122
  if (this.mediatype === 'html') {
123
123
  if (this.modelItem.node) {
124
-
125
124
  const defaultSlot = this.shadowRoot.querySelector('#default');
126
125
  const { node } = this.modelItem;
127
126
  if (node.nodeType) {
128
-
129
127
  valueWrapper.append(node);
130
128
  // this.appendChild(node);
131
129
  return;
132
130
  }
133
131
 
134
132
  // ### try to parse as string
135
- const tmpDoc = new DOMParser().parseFromString(node,'text/html');
133
+ const tmpDoc = new DOMParser().parseFromString(node, 'text/html');
136
134
  const theNode = tmpDoc.body.childNodes;
137
135
  // console.log('actual node', theNode)
138
- Array.from(theNode).forEach(n =>{
136
+ Array.from(theNode).forEach(n => {
139
137
  valueWrapper.append(n);
140
138
  });
141
139
  // valueWrapper.append(theNode);
142
140
 
143
141
  // valueWrapper.innerHTML=node;
144
- /*
142
+ /*
145
143
  if (node.nodeType) {
146
144
  this.appendChild(node);
147
145
  return;
@@ -151,7 +149,7 @@ export class FxOutput extends XfAbstractControl {
151
149
  this.appendChild(obj[1]);
152
150
  });
153
151
  */
154
- /*
152
+ /*
155
153
  Object.entries(node).map(obj => {
156
154
  // valueWrapper.appendChild(obj[1]);
157
155
  this.appendChild(obj[1]);
@@ -168,11 +166,11 @@ export class FxOutput extends XfAbstractControl {
168
166
  return;
169
167
  }
170
168
 
171
- if(this.mediatype === 'image'){
169
+ if (this.mediatype === 'image') {
172
170
  const img = document.createElement('img');
173
- img.setAttribute('src',this.value);
174
- // Reset the output before adding the image
175
- this.innerHTML = '';
171
+ img.setAttribute('src', this.value);
172
+ // Reset the output before adding the image
173
+ this.innerHTML = '';
176
174
  valueWrapper.appendChild(img);
177
175
  return;
178
176
  }
@@ -2,8 +2,8 @@ import { Fore } from '../fore.js';
2
2
  import { evaluateXPath } from '../xpath-evaluation.js';
3
3
  import getInScopeContext from '../getInScopeContext.js';
4
4
  import { XPathUtil } from '../xpath-util.js';
5
- import {foreElementMixin} from "../ForeElementMixin.js";
6
- import {withDraggability} from "../withDraggability.js";
5
+ import ForeElementMixin from '../ForeElementMixin.js';
6
+ import { withDraggability } from '../withDraggability.js';
7
7
 
8
8
  /**
9
9
  * `fx-repeat`
@@ -20,7 +20,7 @@ import {withDraggability} from "../withDraggability.js";
20
20
  *
21
21
  * todo: it should be seriously be considered to extend FxContainer instead but needs refactoring first.
22
22
  */
23
- export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLElement), false) {
23
+ export class FxRepeatAttributes extends withDraggability(ForeElementMixin, false) {
24
24
  static get properties() {
25
25
  return {
26
26
  ...super.properties,
@@ -39,8 +39,8 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
39
39
  repeatIndex: {
40
40
  type: Number,
41
41
  },
42
- repeatSize:{
43
- type:Number,
42
+ repeatSize: {
43
+ type: Number,
44
44
  },
45
45
  nodeset: {
46
46
  type: Array,
@@ -52,13 +52,13 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
52
52
  super();
53
53
  this.ref = '';
54
54
  this.dataTemplate = [];
55
- this.isDraggable=null;
55
+ this.isDraggable = null;
56
56
  this.focusOnCreate = '';
57
57
  this.initDone = false;
58
58
  this.repeatIndex = 1;
59
59
  this.nodeset = [];
60
60
  this.inited = false;
61
- this.host= {};
61
+ this.host = {};
62
62
  this.index = 1;
63
63
  this.repeatSize = 0;
64
64
  this.attachShadow({ mode: 'open', delegatesFocus: true });
@@ -72,7 +72,6 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
72
72
  super.repeatSize = size;
73
73
  }
74
74
 
75
-
76
75
  setIndex(index) {
77
76
  // console.log('new repeat index ', index);
78
77
  this.index = index;
@@ -89,14 +88,14 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
89
88
  }
90
89
 
91
90
  get index() {
92
- return parseInt(this.getAttribute('index'), 10);
91
+ return parseInt(this.getAttribute('index'), 10);
93
92
  }
94
93
 
95
94
  set index(idx) {
96
95
  this.setAttribute('index', idx);
97
96
  }
98
97
 
99
- _getRepeatedItems(){
98
+ _getRepeatedItems() {
100
99
  const refd = this.querySelector('[data-ref]');
101
100
  return refd.children;
102
101
  }
@@ -133,12 +132,10 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
133
132
 
134
133
  // if (this.getOwnerForm().lazyRefresh) {
135
134
  this.mutationObserver = new MutationObserver(mutations => {
136
-
137
135
  if (mutations[0].type === 'childList') {
138
136
  const added = mutations[0].addedNodes[0];
139
137
  if (added) {
140
-
141
- const instance = XPathUtil.resolveInstance(this,this.ref);
138
+ const instance = XPathUtil.resolveInstance(this, this.ref);
142
139
  const path = XPathUtil.getPath(added, instance);
143
140
  // this.dispatch('path-mutated',{'path':path,'nodeset':this.nodeset,'index': this.index});
144
141
  // this.index = index;
@@ -199,7 +196,7 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
199
196
  return inited;
200
197
  }
201
198
 
202
- _getRef(){
199
+ _getRef() {
203
200
  return this.getAttribute('ref');
204
201
  }
205
202
 
@@ -231,7 +228,6 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
231
228
  }
232
229
 
233
230
  async refresh(force) {
234
-
235
231
  if (!this.inited) this.init();
236
232
  this._evalNodeset();
237
233
 
@@ -256,7 +252,6 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
256
252
  // this._fadeOut(itemToRemove);
257
253
  // Fore.fadeOutElement(itemToRemove)
258
254
  this.getOwnerForm().someInstanceDataStructureChanged = true;
259
-
260
255
  }
261
256
  }
262
257
 
@@ -265,19 +260,18 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
265
260
  // add new repeatitem
266
261
 
267
262
  const clonedTemplate = this._clone();
268
- if(!clonedTemplate) return;
263
+ if (!clonedTemplate) return;
269
264
 
270
265
  // ### cloned templates are always appended to the binding element - the one having the data-ref
271
266
  const bindingElement = this.querySelector('[data-ref]');
272
267
  bindingElement.appendChild(clonedTemplate);
273
268
  clonedTemplate.classList.add('fx-repeatitem');
274
- clonedTemplate.setAttribute('index',position);
269
+ clonedTemplate.setAttribute('index', position);
275
270
 
276
271
  clonedTemplate.addEventListener('click', this._dispatchIndexChange);
277
272
  // this.addEventListener('focusin', this._handleFocus);
278
273
  clonedTemplate.addEventListener('focusin', this._dispatchIndexChange);
279
274
 
280
-
281
275
  // this._initVariables(clonedTemplate);
282
276
 
283
277
  // newItem.nodeset = this.nodeset[position - 1];
@@ -310,9 +304,13 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
310
304
  }
311
305
 
312
306
  _dispatchIndexChange() {
313
- this.dispatchEvent(
314
- new CustomEvent('item-changed', { composed: false, bubbles: true, detail: { item: this , index:this.index } }),
315
- );
307
+ this.dispatchEvent(
308
+ new CustomEvent('item-changed', {
309
+ composed: false,
310
+ bubbles: true,
311
+ detail: { item: this, index: this.index },
312
+ }),
313
+ );
316
314
  }
317
315
 
318
316
  // eslint-disable-next-line class-methods-use-this
@@ -349,13 +347,12 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
349
347
  }
350
348
 
351
349
  async _initTemplate() {
352
-
353
350
  // const defaultSlot = this.shadowRoot.querySelector('slot');
354
351
  // todo: this is still weak - should handle that better maybe by an explicit slot?
355
352
  // this.template = this.firstElementChild;
356
353
  this.template = this.querySelector('template');
357
354
 
358
- /*
355
+ /*
359
356
  if (this.template === null) {
360
357
  // console.error('### no template found for this repeat:', this.id);
361
358
  // todo: catch this on form element
@@ -368,14 +365,13 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
368
365
  );
369
366
  }
370
367
  */
371
- if(!this.template) {
368
+ if (!this.template) {
372
369
  return;
373
370
  }
374
371
 
375
372
  this.shadowRoot.appendChild(this.template);
376
373
  }
377
374
 
378
-
379
375
  _initVariables(newRepeatItem) {
380
376
  const inScopeVariables = new Map(this.inScopeVariables);
381
377
  newRepeatItem.setInScopeVariables(inScopeVariables);
@@ -391,7 +387,7 @@ export class FxRepeatAttributes extends withDraggability(foreElementMixin(HTMLEl
391
387
 
392
388
  _clone() {
393
389
  this.template = this.shadowRoot.querySelector('template');
394
- if(!this.template) return;
390
+ if (!this.template) return;
395
391
  return this.template.content.firstElementChild.cloneNode(true);
396
392
  }
397
393