@jinntec/fore 2.2.0 → 2.3.1

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 +1 -1
  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 +3 -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 +4 -6
  45. package/src/functions/fx-functionlib.js +39 -42
  46. package/src/functions/registerFunction.js +95 -86
  47. package/src/fx-bind.js +19 -24
  48. package/src/fx-connection.js +226 -0
  49. package/src/fx-fore.js +846 -815
  50. package/src/fx-header.js +4 -4
  51. package/src/fx-instance.js +23 -27
  52. package/src/fx-model.js +405 -383
  53. package/src/fx-submission.js +399 -397
  54. package/src/fx-var.js +6 -5
  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 +74 -56
  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 -959
  88. package/src/xpath-util.js +161 -134
@@ -1,166 +1,168 @@
1
1
  import getInScopeContext from './getInScopeContext.js';
2
2
 
3
3
  export const withDraggability = (superclass, isAlsoDraggable) =>
4
+ /**
5
+ * Adds draggability to generic components.
6
+ * Add the `dnd` attribute to make it draggable
7
+ */
8
+ class DraggableComponent extends superclass {
9
+ static get properties() {
10
+ return {
11
+ ...superclass.properties,
12
+ dnd: {
13
+ type: Boolean,
14
+ },
15
+ };
16
+ }
4
17
 
5
- /**
6
- * Adds draggability to generic components.
7
- * Add the `dnd` attribute to make it draggable
8
- */
9
- class DraggableComponent extends superclass {
10
- static get properties() {
11
- return {
12
- ...superclass.properties,
13
- dnd: {
14
- type: Boolean
15
- }
16
- };
17
- }
18
-
19
- constructor() {
20
- super();
18
+ constructor() {
19
+ super();
20
+ }
21
21
 
22
+ connectedCallback() {
23
+ this.drop = event => this._drop(event);
24
+ this.addEventListener('drop', this.drop);
25
+ this.dragOver = event => this._dragOver(event);
26
+ this.addEventListener('dragover', this.dragOver);
27
+ this.dragLeave = event => this._dragLeave(event);
28
+ this.addEventListener('dragleave', this.dragLeave);
29
+ this.dragEnd = event => this._dragEnd(event);
30
+ this.addEventListener('dragend', this._dragEnd);
22
31
  }
23
32
 
24
- connectedCallback() {
25
- this.drop = (event) => this._drop(event);
26
- this.addEventListener('drop', this.drop);
27
- this.dragOver = (event) => this._dragOver(event);
28
- this.addEventListener('dragover', this.dragOver);
29
- this.dragLeave = (event) => this._dragLeave(event);
30
- this.addEventListener('dragleave', this.dragLeave);
31
- this.dragEnd = (event) => this._dragEnd(event);
32
- this.addEventListener('dragend', this._dragEnd);
33
- }
34
-
35
- disconnectedCallback() {
36
- this.removeEventListener('drop', this.drop);
37
- this.removeEventListener('dragover', this.dragOver);
38
- this.removeEventListener('dragleave', this.dragLeave);
39
- this.removeEventListener('dragend', this.dragEnd);
40
- }
33
+ disconnectedCallback() {
34
+ this.removeEventListener('drop', this.drop);
35
+ this.removeEventListener('dragover', this.dragOver);
36
+ this.removeEventListener('dragleave', this.dragLeave);
37
+ this.removeEventListener('dragend', this.dragEnd);
38
+ }
41
39
 
42
40
  _dragOver(event) {
43
- // console.log('dragover ',this);
44
- // console.log('event target ',event.target);
45
- if(event.target.classList.contains('no-drop')) {
46
- return false;
47
- }
48
- event.stopPropagation();
49
- const repeatItem = event.target.closest('fx-repeatitem');
50
- if (!this.getOwnerForm().draggedItem) {
51
- // Not dragging
52
- return;
53
- }
54
- // Only allow drag and drop in similar repeats
55
- if (this === this.getOwnerForm().draggedItem) {
56
- // Ignore: drop on itself
57
- return;
58
- }
59
- const {draggedItem} = this.getOwnerForm();
60
-
61
- if (this.accepts(draggedItem)) {
62
- this.classList.remove('no-drop');
63
- } else {
64
- this.classList.add('no-drop');
65
- }
66
-
67
- const thisClosestRepeat = this.hasAttribute('id') ? this : this.closest('[id]');
68
- const draggingClosestRepeat = draggedItem.hasAttribute('id') ? draggedItem : draggedItem.closest('[id]');
69
- if (thisClosestRepeat?.id === draggingClosestRepeat?.id) {
70
- if (repeatItem !== this.getOwnerForm().draggedItem) {
71
- this.classList.add('drag-over');
72
- }
73
-
74
- event.preventDefault();
75
- }
41
+ // console.log('dragover ',this);
42
+ // console.log('event target ',event.target);
43
+ if (event.target.classList.contains('no-drop')) {
44
+ return false;
45
+ }
46
+ event.stopPropagation();
47
+ const repeatItem = event.target.closest('fx-repeatitem');
48
+ if (!this.getOwnerForm().draggedItem) {
49
+ // Not dragging
50
+ return;
51
+ }
52
+ // Only allow drag and drop in similar repeats
53
+ if (this === this.getOwnerForm().draggedItem) {
54
+ // Ignore: drop on itself
55
+ return;
56
+ }
57
+ const { draggedItem } = this.getOwnerForm();
58
+
59
+ if (this.accepts(draggedItem)) {
60
+ this.classList.remove('no-drop');
61
+ } else {
62
+ this.classList.add('no-drop');
63
+ }
64
+
65
+ const thisClosestRepeat = this.hasAttribute('id') ? this : this.closest('[id]');
66
+ const draggingClosestRepeat = draggedItem.hasAttribute('id')
67
+ ? draggedItem
68
+ : draggedItem.closest('[id]');
69
+ if (thisClosestRepeat?.id === draggingClosestRepeat?.id) {
70
+ if (repeatItem !== this.getOwnerForm().draggedItem) {
71
+ this.classList.add('drag-over');
72
+ }
73
+
74
+ event.preventDefault();
75
+ }
76
76
  }
77
77
 
78
- _dragLeave(event){
79
- this.classList.remove('drag-over');
80
- this.classList.remove('no-drop');
78
+ _dragLeave(event) {
79
+ this.classList.remove('drag-over');
80
+ this.classList.remove('no-drop');
81
81
  }
82
82
 
83
- _dragEnd (event) {
84
- const item = this.getOwnerForm().draggedItem
85
- if (item.getAttribute('drop-action') === 'copy') {
86
- item.remove();
87
- }
88
- this.classList.remove('drag-over');
89
- // event.stopPropagation();
90
- }
91
-
92
- _getDataNode () {
93
- const dataNode = this.getOwnerForm().draggedItem?.getModelItem()?.node;
94
- if (!dataNode) {
95
- return null;
96
- }
97
-
98
- const {draggedItem} = this.getOwnerForm();
99
- const thisClosestRepeat = this.hasAttribute('id') ? this : this.closest('[id]');
100
- const draggingClosestRepeat = draggedItem.hasAttribute('id') ? draggedItem : draggedItem.closest('[id]');
101
- if (thisClosestRepeat?.id !== draggingClosestRepeat?.id) {
102
- // Moving between different repeats: this can make the items 'lost': placed into a
103
- // different set
104
- return null;
105
- }
106
-
107
- return dataNode;
108
- }
109
-
110
- accepts (draggedItem) {
111
- if (!this.hasAttribute('accept')) {
112
- return;
113
- }
114
- const accept = this.getAttribute('accept');
115
- const isAccepted = draggedItem.matches(accept);
116
- // console.log('accepted', isAccepted);
117
- return isAccepted;
118
- }
119
-
120
- _drop(event){
121
- this.classList.remove('drag-over');
122
- event.stopPropagation();
123
- if (this.localName === 'fx-droptarget') {
124
- if(this.children.length !== 0){
125
- console.log("we have to do something");
126
- }
127
-
128
- let {draggedItem} = this.getOwnerForm();
83
+ _dragEnd(event) {
84
+ const item = this.getOwnerForm().draggedItem;
85
+ if (item.getAttribute('drop-action') === 'copy') {
86
+ item.remove();
87
+ }
88
+ this.classList.remove('drag-over');
89
+ // event.stopPropagation();
90
+ }
129
91
 
130
- if (draggedItem.getAttribute('drop-action') === 'copy') {
131
- draggedItem = draggedItem.cloneNode(true);
132
- }
92
+ _getDataNode() {
93
+ const dataNode = this.getOwnerForm().draggedItem?.getModelItem()?.node;
94
+ if (!dataNode) {
95
+ return null;
96
+ }
97
+
98
+ const { draggedItem } = this.getOwnerForm();
99
+ const thisClosestRepeat = this.hasAttribute('id') ? this : this.closest('[id]');
100
+ const draggingClosestRepeat = draggedItem.hasAttribute('id')
101
+ ? draggedItem
102
+ : draggedItem.closest('[id]');
103
+ if (thisClosestRepeat?.id !== draggingClosestRepeat?.id) {
104
+ // Moving between different repeats: this can make the items 'lost': placed into a
105
+ // different set
106
+ return null;
107
+ }
108
+
109
+ return dataNode;
110
+ }
133
111
 
134
- if (!this.accepts(draggedItem)) {
135
- this.classList.remove('no-drop');
136
- return;
137
- }
138
- if(draggedItem === this){
139
- return;
140
- }
141
- if(draggedItem.localName === 'fx-droptarget'){
142
- // todo : this looks still a bit weak
143
- if(this.hasAttribute('drop-position')){
144
- this.replaceChildren(draggedItem);
145
- event.preventDefault();
146
- return;
147
- }
148
- if(this.parentNode.lastElementChild === this){
149
- this.parentNode.append(draggedItem);
150
- event.stopImmediatePropagation();
151
- // return;
152
- }else if (draggedItem === this.previousElementSibling) {
153
- // insertBefore of draggedItem before us would be a no-op: it is already before us.
154
- // Instead: insert _after_ us, so we can still do something!
155
- this.parentNode.insertBefore(draggedItem, this.nextElementSibling);
156
- } else {
157
- this.parentNode.insertBefore(draggedItem, this);
158
- }
159
- }else{
160
- this.appendChild(draggedItem);
161
- }
112
+ accepts(draggedItem) {
113
+ if (!this.hasAttribute('accept')) {
114
+ return;
115
+ }
116
+ const accept = this.getAttribute('accept');
117
+ const isAccepted = draggedItem.matches(accept);
118
+ // console.log('accepted', isAccepted);
119
+ return isAccepted;
120
+ }
162
121
 
163
- /*
122
+ _drop(event) {
123
+ this.classList.remove('drag-over');
124
+ event.stopPropagation();
125
+ if (this.localName === 'fx-droptarget') {
126
+ if (this.children.length !== 0) {
127
+ console.log('we have to do something');
128
+ }
129
+
130
+ let { draggedItem } = this.getOwnerForm();
131
+
132
+ if (draggedItem.getAttribute('drop-action') === 'copy') {
133
+ draggedItem = draggedItem.cloneNode(true);
134
+ }
135
+
136
+ if (!this.accepts(draggedItem)) {
137
+ this.classList.remove('no-drop');
138
+ return;
139
+ }
140
+ if (draggedItem === this) {
141
+ return;
142
+ }
143
+ if (draggedItem.localName === 'fx-droptarget') {
144
+ // todo : this looks still a bit weak
145
+ if (this.hasAttribute('drop-position')) {
146
+ this.replaceChildren(draggedItem);
147
+ event.preventDefault();
148
+ return;
149
+ }
150
+ if (this.parentNode.lastElementChild === this) {
151
+ this.parentNode.append(draggedItem);
152
+ event.stopImmediatePropagation();
153
+ // return;
154
+ } else if (draggedItem === this.previousElementSibling) {
155
+ // insertBefore of draggedItem before us would be a no-op: it is already before us.
156
+ // Instead: insert _after_ us, so we can still do something!
157
+ this.parentNode.insertBefore(draggedItem, this.nextElementSibling);
158
+ } else {
159
+ this.parentNode.insertBefore(draggedItem, this);
160
+ }
161
+ } else {
162
+ this.appendChild(draggedItem);
163
+ }
164
+
165
+ /*
164
166
  if(this.hasAttribute('drop-position')){
165
167
  if(this.getAttribute('drop-position') === 'before'){
166
168
  this.parentNode.insertBefore(draggedItem,this);
@@ -171,48 +173,48 @@ class DraggableComponent extends superclass {
171
173
  this.replaceChildren(draggedItem);
172
174
  }
173
175
  */
174
- event.preventDefault();
175
- this.getOwnerForm().getModel().updateModel();
176
- this.getOwnerForm().refresh(true);
177
- return;
178
- }
179
- const dataNode = this._getDataNode();
180
- if (!dataNode) {
181
- return;
182
- }
183
-
184
- if (this.localName === 'fx-repeat') {
185
- // We are sure we'll handle this event!
186
- event.preventDefault();
187
- // Dropping on repeat itself always means to *append* the dropped item
188
-
189
- let contextNode = this.nodeset;
190
- if (Array.isArray(contextNode) && !contextNode.length) {
191
- // Guess: just append it to the context node. Hope that the `ref` is actually a
192
- // child axis, like `ref="./item"`. A ref like `./items/item` breaks.
193
- const context = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
194
- context.append(dataNode);
195
- } else {
196
- // Guess: just insert it after it to the context node. Hope that the `ref` is
197
- // actually listing siblings, like `ref="./item"` or
198
- // `ref="./items/item"`. `ref="descendant::item[@category='a']"` breaks
199
- contextNode = contextNode[contextNode.length - 1];
200
- contextNode.after(dataNode);
201
- }
202
- } else if (this.localName === 'fx-repeatitem') {
203
- const repeatItemNode = this.getModelItem().node;
204
-
205
- if (repeatItemNode.previousSibling === dataNode) {
206
- // moving before will make it do nothing, move after
207
- repeatItemNode.after(dataNode);
208
- } else {
209
- repeatItemNode.before(dataNode);
210
- }
211
- }
212
-
213
- // Note: full refresh needed since multiple model items may be affected.
214
- // TODO: Leverage the changedPaths trick
215
- this.getOwnerForm().getModel().updateModel();
216
- this.getOwnerForm().refresh(true);
176
+ event.preventDefault();
177
+ this.getOwnerForm().getModel().updateModel();
178
+ this.getOwnerForm().refresh(true);
179
+ return;
180
+ }
181
+ const dataNode = this._getDataNode();
182
+ if (!dataNode) {
183
+ return;
184
+ }
185
+
186
+ if (this.localName === 'fx-repeat') {
187
+ // We are sure we'll handle this event!
188
+ event.preventDefault();
189
+ // Dropping on repeat itself always means to *append* the dropped item
190
+
191
+ let contextNode = this.nodeset;
192
+ if (Array.isArray(contextNode) && !contextNode.length) {
193
+ // Guess: just append it to the context node. Hope that the `ref` is actually a
194
+ // child axis, like `ref="./item"`. A ref like `./items/item` breaks.
195
+ const context = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
196
+ context.append(dataNode);
197
+ } else {
198
+ // Guess: just insert it after it to the context node. Hope that the `ref` is
199
+ // actually listing siblings, like `ref="./item"` or
200
+ // `ref="./items/item"`. `ref="descendant::item[@category='a']"` breaks
201
+ contextNode = contextNode[contextNode.length - 1];
202
+ contextNode.after(dataNode);
203
+ }
204
+ } else if (this.localName === 'fx-repeatitem') {
205
+ const repeatItemNode = this.getModelItem().node;
206
+
207
+ if (repeatItemNode.previousSibling === dataNode) {
208
+ // moving before will make it do nothing, move after
209
+ repeatItemNode.after(dataNode);
210
+ } else {
211
+ repeatItemNode.before(dataNode);
212
+ }
213
+ }
214
+
215
+ // Note: full refresh needed since multiple model items may be affected.
216
+ // TODO: Leverage the changedPaths trick
217
+ this.getOwnerForm().getModel().updateModel();
218
+ this.getOwnerForm().refresh(true);
217
219
  }
218
- };
220
+ };