@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
@@ -1,7 +1,6 @@
1
- import {Fore} from '../fore.js';
2
- import {foreElementMixin} from '../ForeElementMixin.js';
3
- import {FxFore} from "../fx-fore.js";
4
- import {withDraggability} from "../withDraggability.js";
1
+ import { Fore } from '../fore.js';
2
+ import ForeElementMixin from '../ForeElementMixin.js';
3
+ import { withDraggability } from '../withDraggability.js';
5
4
 
6
5
  /**
7
6
  * `fx-repeat`
@@ -10,62 +9,59 @@ import {withDraggability} from "../withDraggability.js";
10
9
  * @customElement
11
10
  * @demo demo/index.html
12
11
  */
13
- export class FxRepeatitem extends withDraggability(foreElementMixin(HTMLElement), true) {
14
- static get properties() {
15
- return {
16
- inited: {
17
- type: Boolean,
18
- },
19
- };
20
- }
21
-
22
- constructor() {
23
- super();
24
- this.inited = false;
12
+ export class FxRepeatitem extends withDraggability(ForeElementMixin, true) {
13
+ static get properties() {
14
+ return {
15
+ inited: {
16
+ type: Boolean,
17
+ },
18
+ };
19
+ }
25
20
 
26
- this.addEventListener('click', this._dispatchIndexChange);
27
- // this.addEventListener('focusin', this._handleFocus);
28
- this.addEventListener('focusin', this._dispatchIndexChange);
21
+ constructor() {
22
+ super();
23
+ this.inited = false;
29
24
 
30
- this.attachShadow({mode: 'open', delegatesFocus: true});
25
+ this.addEventListener('click', this._dispatchIndexChange);
26
+ // this.addEventListener('focusin', this._handleFocus);
27
+ this.addEventListener('focusin', this._dispatchIndexChange);
31
28
 
32
- this.dropTarget = null;
29
+ this.attachShadow({ mode: 'open', delegatesFocus: true });
33
30
 
34
- }
31
+ this.dropTarget = null;
32
+ }
35
33
 
36
- connectedCallback() {
37
- super.connectedCallback();
38
- this.display = this.style.display;
34
+ connectedCallback() {
35
+ super.connectedCallback();
36
+ this.display = this.style.display;
39
37
 
40
- const html = `
38
+ const html = `
41
39
  <slot></slot>
42
40
  `;
43
41
 
44
- this.shadowRoot.innerHTML = `
42
+ this.shadowRoot.innerHTML = `
45
43
  ${html}
46
44
  `;
47
- this.getOwnerForm().registerLazyElement(this);
45
+ this.getOwnerForm().registerLazyElement(this);
48
46
 
49
- this.ref = `${this.parentNode.ref}`;
50
-
51
- this.tabindex = 0;
52
-
53
- }
47
+ this.ref = `${this.parentNode.ref}`;
54
48
 
55
- disconnectedCallback() {
56
- super.disconnectedCallback();
57
- this.removeEventListener('click', this._dispatchIndexChange);
58
- this.removeEventListener('focusin', this._handleFocus);
59
- }
49
+ this.tabindex = 0;
50
+ }
60
51
 
52
+ disconnectedCallback() {
53
+ super.disconnectedCallback();
54
+ this.removeEventListener('click', this._dispatchIndexChange);
55
+ this.removeEventListener('focusin', this._handleFocus);
56
+ }
61
57
 
62
- init() {
63
- // console.log('repeatitem init model ', this.nodeset);
64
- // this._initializeChildren(this);
65
- this.inited = true;
66
- }
58
+ init() {
59
+ // console.log('repeatitem init model ', this.nodeset);
60
+ // this._initializeChildren(this);
61
+ this.inited = true;
62
+ }
67
63
 
68
- /*
64
+ /*
69
65
  getModelItem() {
70
66
  super.getModelItem();
71
67
  // console.log('modelItem in repeatitem ', this.getModelItem()[this.index]);
@@ -73,32 +69,43 @@ export class FxRepeatitem extends withDraggability(foreElementMixin(HTMLElement)
73
69
  }
74
70
  */
75
71
 
76
- _dispatchIndexChange() {
77
- this.dispatchEvent(
78
- new CustomEvent('item-changed', {composed: false, bubbles: true, detail: {item: this, index: this.index}}),
79
- );
72
+ _dispatchIndexChange() {
73
+ /**
74
+ * @type {import('./fx-repeat.js').FxRepeat}
75
+ */
76
+ const repeat = this.parentNode;
77
+ if (repeat.index === this.index) {
78
+ // The index did not really change if it did not change :wink:
79
+ return;
80
80
  }
81
-
82
-
83
- refresh(force) {
84
- this.modelItem = this.getModelItem();
85
- // ### register ourselves as boundControl
86
- if (!this.modelItem.boundControls.includes(this)) {
87
- this.modelItem.boundControls.push(this);
88
-
89
- if (this.modelItem && !this.modelItem.relevant) {
90
- this.removeAttribute('relevant');
91
- this.setAttribute('nonrelevant', '');
92
- } else {
93
- this.removeAttribute('nonrelevant');
94
- this.setAttribute('relevant', '');
95
- }
96
- }
97
- // Always recurse for these refreshes, especially when forced
98
- Fore.refreshChildren(this, force);
81
+ this.dispatchEvent(
82
+ new CustomEvent('item-changed', {
83
+ composed: false,
84
+ bubbles: true,
85
+ detail: { item: this, index: this.index },
86
+ }),
87
+ );
88
+ }
89
+
90
+ refresh(force) {
91
+ this.modelItem = this.getModelItem();
92
+ // ### register ourselves as boundControl
93
+ if (!this.modelItem.boundControls.includes(this)) {
94
+ this.modelItem.boundControls.push(this);
95
+
96
+ if (this.modelItem && !this.modelItem.relevant) {
97
+ this.removeAttribute('relevant');
98
+ this.setAttribute('nonrelevant', '');
99
+ } else {
100
+ this.removeAttribute('nonrelevant');
101
+ this.setAttribute('relevant', '');
102
+ }
99
103
  }
104
+ // Always recurse for these refreshes, especially when forced
105
+ Fore.refreshChildren(this, force);
106
+ }
100
107
  }
101
108
 
102
109
  if (!customElements.get('fx-repeatitem')) {
103
- window.customElements.define('fx-repeatitem', FxRepeatitem);
104
- }
110
+ window.customElements.define('fx-repeatitem', FxRepeatitem);
111
+ }
@@ -41,41 +41,41 @@ class FxSwitch extends FxContainer {
41
41
  ${html}
42
42
  `;
43
43
  this.cases = [];
44
- this.formerCase=null;
44
+ this.formerCase = null;
45
45
  this.selectedCase = null;
46
-
47
46
  }
48
47
 
49
48
  async refresh(force) {
50
49
  super.refresh(force);
51
50
  // console.log('refresh on switch ');
52
- if(this.cases.length === 0){
51
+ if (this.cases.length === 0) {
53
52
  this.cases = Array.from(this.querySelectorAll(':scope > fx-case'));
54
53
  }
55
54
 
56
55
  if (this.isBound()) {
57
56
  this._handleBoundSwitch();
58
57
  }
59
- if(!this.selectedCase){
58
+ if (!this.selectedCase) {
60
59
  this.selectedCase = this.cases[0]; // first is always default
61
60
  this.toggle(this.selectedCase);
62
61
  }
63
62
 
64
- Fore.refreshChildren(this.selectedCase,force);
63
+ Fore.refreshChildren(this.selectedCase, force);
65
64
  }
66
65
 
67
- _dispatchEvents(){
68
- if(this.formerCase && this.formerCase !== this.selectedCase){
69
- Fore.dispatch(this.formerCase,'deselect',{});
66
+ _dispatchEvents() {
67
+ if(this.selectedCase === this.formerCase) return;
68
+ if (this.formerCase && this.formerCase !== this.selectedCase) {
69
+ Fore.dispatch(this.formerCase, 'deselect', {});
70
70
  }
71
- if(this.selectedCase.classList.contains('selected-case')){
72
- Fore.dispatch(this.selectedCase,'select',{});
71
+ if (this.selectedCase.classList.contains('selected-case')) {
72
+ Fore.dispatch(this.selectedCase, 'select', {});
73
73
  }
74
74
  }
75
75
 
76
- _resetVisited(){
76
+ _resetVisited() {
77
77
  const visited = this.selectedCase.querySelectorAll('.visited');
78
- Array.from(visited).forEach(v =>{
78
+ Array.from(visited).forEach(v => {
79
79
  v.classList.remove('visited');
80
80
  });
81
81
  }
@@ -93,11 +93,35 @@ class FxSwitch extends FxContainer {
93
93
  });
94
94
  }
95
95
 
96
+ /**
97
+ * Replace an old case with a new case element.
98
+ *
99
+ * @param {import('./fx-case.js').FxCase} oldCase
100
+ * @param {import('./fx-case.js').FxCase} newCase
101
+ */
102
+ async replaceCase(oldCase, newCase) {
103
+ this.cases.splice(this.cases.indexOf(oldCase), 1, newCase);
104
+
105
+ if (oldCase === this.selectedCase) {
106
+ this.selectedCase = newCase;
107
+ this.formerCase = newCase;
108
+ newCase.classList.add('selected-case');
109
+ newCase.classList.remove('deselected-case');
110
+ newCase.inert = false;
111
+ // Tell the owner form we might have new template expressions here
112
+ this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh();
113
+ } else {
114
+ newCase.classList.add('deselected-case');
115
+ newCase.classList.remove('selected-case');
116
+ newCase.inert = true;
117
+ }
118
+ }
119
+
96
120
  /**
97
121
  * Activates a fx-case element by switching CSS classes.
98
122
  * Dispatches 'select' and 'deselect' events as appropriate.
99
123
  *
100
- * @param caseElement the fx-case element to activate
124
+ * @param {import('./fx-case.js').FxCase} caseElement the fx-case element to activate
101
125
  */
102
126
  toggle(caseElement) {
103
127
  this.selectedCase = caseElement;
@@ -114,7 +138,7 @@ class FxSwitch extends FxContainer {
114
138
  }
115
139
  });
116
140
 
117
- if(this.selectedCase !== caseElement){
141
+ if (this.selectedCase !== caseElement) {
118
142
  this.selectedCase = caseElement;
119
143
  }
120
144
  this._dispatchEvents();
@@ -122,6 +146,7 @@ class FxSwitch extends FxContainer {
122
146
 
123
147
  // Tell the owner form we might have new template expressions here
124
148
  this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh();
149
+ this.getOwnerForm().getModel().updateModel();
125
150
  }
126
151
  }
127
152
 
@@ -23,10 +23,10 @@ export class FxTrigger extends XfAbstractControl {
23
23
  const slot = this.shadowRoot.querySelector('slot');
24
24
  slot.addEventListener('slotchange', () => {
25
25
  const elements = slot.assignedElements({ flatten: true });
26
- if(!elements[0].getAttribute('tabindex')){
26
+ if (!elements[0].getAttribute('tabindex')) {
27
27
  elements[0].setAttribute('tabindex', '0');
28
28
  }
29
- if(elements[0].nodeName !== 'BUTTON'){
29
+ if (elements[0].nodeName !== 'BUTTON') {
30
30
  elements[0].setAttribute('role', 'button');
31
31
  }
32
32
 
@@ -34,7 +34,7 @@ export class FxTrigger extends XfAbstractControl {
34
34
 
35
35
  this.addEventListener('mousedown', e => {
36
36
  console.log('target', e.target.nodeName);
37
- e.target.focus();
37
+ e.target.focus();
38
38
  });
39
39
 
40
40
  if (this.debounceDelay) {
@@ -108,7 +108,7 @@ export class FxTrigger extends XfAbstractControl {
108
108
  // We are handling the event. Stop it from going further
109
109
  e.preventDefault();
110
110
  e.stopPropagation();
111
- if(e.type && child.event && e.type !== child.event) return;
111
+ if (e.type && child.event && e.type !== child.event) return;
112
112
  }
113
113
  // eslint-disable-next-line no-await-in-loop
114
114
  await child.execute(e);