@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.
- package/README.md +1 -1
- package/dist/fore-dev.js +2 -2
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -2
- package/dist/fore.js.map +1 -1
- package/index.js +3 -2
- package/package.json +10 -38
- package/resources/fore.css +263 -262
- package/resources/vars.css +8 -0
- package/src/DependencyNotifyingDomFacade.js +1 -0
- package/src/ForeElementMixin.js +243 -228
- package/src/actions/abstract-action.js +407 -398
- package/src/actions/fx-action.js +6 -6
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-call.js +63 -62
- package/src/actions/fx-confirm.js +11 -11
- package/src/actions/fx-construct-done.js +4 -4
- package/src/actions/fx-copy.js +36 -36
- package/src/actions/fx-delete.js +77 -79
- package/src/actions/fx-dispatch.js +14 -14
- package/src/actions/fx-hide.js +15 -15
- package/src/actions/fx-insert.js +9 -12
- package/src/actions/fx-insertchild.js +88 -0
- package/src/actions/fx-load.js +188 -185
- package/src/actions/fx-message.js +18 -19
- package/src/actions/fx-refresh.js +10 -10
- package/src/actions/fx-reload.js +16 -14
- package/src/actions/fx-replace.js +0 -1
- package/src/actions/fx-reset.js +31 -31
- package/src/actions/fx-send.js +59 -52
- package/src/actions/fx-setattribute.js +48 -49
- package/src/actions/fx-setfocus.js +54 -58
- package/src/actions/fx-setvalue.js +85 -81
- package/src/actions/fx-show.js +11 -11
- package/src/actions/fx-toggle.js +2 -2
- package/src/actions/fx-toggleboolean.js +38 -39
- package/src/actions/fx-unmodified.js +27 -0
- package/src/actions/fx-update.js +6 -6
- package/src/dep_graph.js +1 -1
- package/src/drawdown.js +23 -30
- package/src/events.js +19 -19
- package/src/fore.js +143 -125
- package/src/functions/common-function.js +24 -25
- package/src/functions/fx-function.js +4 -6
- package/src/functions/fx-functionlib.js +39 -42
- package/src/functions/registerFunction.js +95 -86
- package/src/fx-bind.js +19 -24
- package/src/fx-connection.js +226 -0
- package/src/fx-fore.js +846 -815
- package/src/fx-header.js +4 -4
- package/src/fx-instance.js +23 -27
- package/src/fx-model.js +405 -383
- package/src/fx-submission.js +399 -397
- package/src/fx-var.js +6 -5
- package/src/getInScopeContext.js +102 -89
- package/src/json-util.js +24 -24
- package/src/lab/fore-component.js +48 -52
- package/src/lab/instance-inspector.js +13 -16
- package/src/modelitem.js +48 -10
- package/src/relevance.js +12 -16
- package/src/tools/adi.js +858 -812
- package/src/tools/fx-action-log.js +377 -295
- package/src/tools/fx-devtools.js +210 -210
- package/src/tools/fx-dom-inspector.js +123 -122
- package/src/tools/fx-json-instance.js +262 -253
- package/src/tools/fx-log-item.js +6 -11
- package/src/tools/fx-log-settings.js +358 -301
- package/src/tools/fx-minimap.js +186 -177
- package/src/tools/helpers.js +1 -1
- package/src/ui/abstract-control.js +74 -56
- package/src/ui/fx-case.js +59 -7
- package/src/ui/fx-container.js +13 -14
- package/src/ui/fx-control.js +572 -538
- package/src/ui/fx-dialog.js +3 -3
- package/src/ui/fx-droptarget.js +3 -4
- package/src/ui/fx-group.js +4 -2
- package/src/ui/fx-hint.js +3 -0
- package/src/ui/fx-inspector.js +5 -5
- package/src/ui/fx-items.js +11 -11
- package/src/ui/fx-output.js +10 -12
- package/src/ui/fx-repeat-attributes.js +23 -27
- package/src/ui/fx-repeat.js +347 -344
- package/src/ui/fx-repeatitem.js +75 -68
- package/src/ui/fx-switch.js +39 -14
- package/src/ui/fx-trigger.js +4 -4
- package/src/withDraggability.js +193 -191
- package/src/xpath-evaluation.js +969 -959
- package/src/xpath-util.js +161 -134
package/src/withDraggability.js
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
80
|
-
|
|
78
|
+
_dragLeave(event) {
|
|
79
|
+
this.classList.remove('drag-over');
|
|
80
|
+
this.classList.remove('no-drop');
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
131
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
+
};
|