@jinntec/fore 1.0.0-4 → 1.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.
- package/README.md +26 -38
- package/dist/fore-dev.js +43 -0
- package/dist/fore-dev.js.map +1 -0
- package/dist/fore.js +37 -0
- package/dist/fore.js.map +1 -0
- package/index.js +4 -0
- package/package.json +42 -42
- package/resources/fore.css +186 -0
- package/resources/toastify.css +87 -0
- package/resources/{fore-styles.css → vars.css} +0 -292
- package/src/DependencyNotifyingDomFacade.js +10 -16
- package/src/ForeElementMixin.js +26 -19
- package/src/actions/abstract-action.js +30 -9
- package/src/actions/fx-action.js +6 -4
- package/src/actions/fx-append.js +8 -17
- package/src/actions/fx-confirm.js +5 -3
- package/src/actions/fx-delete.js +6 -3
- package/src/actions/fx-dispatch.js +9 -8
- package/src/actions/fx-hide.js +10 -6
- package/src/actions/fx-insert.js +49 -39
- package/src/actions/fx-message.js +3 -1
- package/src/actions/fx-refresh.js +15 -1
- package/src/actions/fx-replace.js +73 -0
- package/src/actions/fx-return.js +42 -0
- package/src/actions/fx-send.js +3 -1
- package/src/actions/fx-setfocus.js +37 -0
- package/src/actions/fx-setvalue.js +58 -51
- package/src/actions/fx-show.js +12 -4
- package/src/actions/fx-toggle.js +15 -10
- package/src/actions/fx-update.js +3 -1
- package/src/dep_graph.js +4 -2
- package/src/drawdown.js +67 -82
- package/src/fore.js +158 -12
- package/src/functions/fx-function.js +17 -3
- package/src/fx-bind.js +42 -202
- package/src/fx-fore.js +599 -567
- package/src/fx-header.js +3 -1
- package/src/fx-instance.js +9 -1
- package/src/fx-model.js +59 -23
- package/src/fx-submission.js +106 -48
- package/src/fx-var.js +7 -4
- package/src/getInScopeContext.js +37 -11
- package/src/modelitem.js +4 -4
- package/src/relevance.js +64 -0
- package/src/ui/abstract-control.js +64 -37
- package/src/ui/fx-alert.js +7 -1
- package/src/ui/fx-case.js +4 -3
- package/src/ui/fx-container.js +7 -1
- package/src/ui/fx-control.js +309 -34
- package/src/ui/fx-dialog.js +54 -40
- package/src/ui/fx-group.js +3 -1
- package/src/ui/fx-hint.js +4 -1
- package/src/ui/fx-inspector.js +120 -17
- package/src/ui/fx-items.js +8 -8
- package/src/ui/fx-output.js +16 -5
- package/src/ui/fx-repeat.js +33 -41
- package/src/ui/fx-repeatitem.js +10 -4
- package/src/ui/fx-switch.js +5 -3
- package/src/ui/fx-trigger.js +3 -1
- package/src/xpath-evaluation.js +621 -576
- package/src/xpath-util.js +15 -8
- package/dist/fore-all.js +0 -140
- package/dist/fore-debug.js +0 -140
- package/src/.DS_Store +0 -0
- package/src/actions/.DS_Store +0 -0
- package/src/ui/.DS_Store +0 -0
|
@@ -45,21 +45,14 @@ export class DependencyNotifyingDomFacade {
|
|
|
45
45
|
* @param bucket - The bucket that matches the attribute that will be used.
|
|
46
46
|
*/
|
|
47
47
|
// eslint-disable-next-line class-methods-use-this
|
|
48
|
-
/*
|
|
49
48
|
getChildNodes(node, bucket) {
|
|
50
49
|
const matchingNodes = Array.from(node.childNodes).filter(
|
|
51
50
|
childNode => !bucket || getBucketsForNode(childNode).includes(bucket),
|
|
52
51
|
);
|
|
53
|
-
return matchingNodes;
|
|
54
|
-
}
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
getChildNodes(node, bucket) {
|
|
58
|
-
const matchingNodes = Array.from(node.childNodes).filter(
|
|
59
|
-
childNode => !bucket || getBucketsForNode(childNode).includes(bucket));
|
|
60
52
|
matchingNodes.forEach(matchingNode => this._onNodeTouched(matchingNode));
|
|
61
53
|
return matchingNodes;
|
|
62
54
|
}
|
|
55
|
+
|
|
63
56
|
/**
|
|
64
57
|
* Get the data of this node.
|
|
65
58
|
*
|
|
@@ -83,11 +76,11 @@ export class DependencyNotifyingDomFacade {
|
|
|
83
76
|
* @param bucket - The bucket that matches the attribute that will be used.
|
|
84
77
|
*/
|
|
85
78
|
getFirstChild(node, bucket) {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
for (const child of node.childNodes) {
|
|
80
|
+
if (!bucket || getBucketsForNode(child).includes(bucket)) {
|
|
81
|
+
this._onNodeTouched(child);
|
|
82
|
+
return child;
|
|
83
|
+
}
|
|
91
84
|
}
|
|
92
85
|
return null;
|
|
93
86
|
}
|
|
@@ -120,12 +113,13 @@ export class DependencyNotifyingDomFacade {
|
|
|
120
113
|
*/
|
|
121
114
|
// eslint-disable-next-line class-methods-use-this
|
|
122
115
|
getNextSibling(node, bucket) {
|
|
123
|
-
for (let
|
|
124
|
-
if (!getBucketsForNode(
|
|
116
|
+
for (let sibling = node.nextSibling; sibling; sibling = sibling.nextSibling) {
|
|
117
|
+
if (!getBucketsForNode(sibling).includes(bucket)) {
|
|
125
118
|
// eslint-disable-next-line no-continue
|
|
126
119
|
continue;
|
|
127
120
|
}
|
|
128
|
-
|
|
121
|
+
this._onNodeTouched(sibling);
|
|
122
|
+
return sibling;
|
|
129
123
|
}
|
|
130
124
|
return null;
|
|
131
125
|
}
|
package/src/ForeElementMixin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { XPathUtil } from './xpath-util.js';
|
|
2
2
|
import { FxModel } from './fx-model.js';
|
|
3
|
+
import { Fore } from './fore.js';
|
|
3
4
|
import {
|
|
4
5
|
evaluateXPath,
|
|
5
6
|
evaluateXPathToFirstNode,
|
|
@@ -7,6 +8,11 @@ import {
|
|
|
7
8
|
} from './xpath-evaluation.js';
|
|
8
9
|
import getInScopeContext from './getInScopeContext.js';
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Mixin containing all general functions that are shared by all Fore element classes.
|
|
13
|
+
* @param superclass
|
|
14
|
+
* @returns {{readonly properties: {ref: {type: StringConstructor}, context: {type: ObjectConstructor}, nodeset: {type: ObjectConstructor}, model: {type: ObjectConstructor}, inScopeVariables: {type: MapConstructor}, modelItem: {type: ObjectConstructor}}, new(): ForeElementMixin, context: null, model: null, modelItem: {}, ref: *|string, inScopeVariables: null, nodeset: *, prototype: ForeElementMixin}}
|
|
15
|
+
*/
|
|
10
16
|
export const foreElementMixin = superclass =>
|
|
11
17
|
class ForeElementMixin extends superclass {
|
|
12
18
|
static get properties() {
|
|
@@ -94,10 +100,21 @@ export const foreElementMixin = superclass =>
|
|
|
94
100
|
*/
|
|
95
101
|
evalInContext() {
|
|
96
102
|
// const inscopeContext = this.getInScopeContext();
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
let inscopeContext;
|
|
104
|
+
if (this.hasAttribute('context')) {
|
|
105
|
+
inscopeContext = getInScopeContext(this.getAttributeNode('context') || this, this.context);
|
|
106
|
+
}
|
|
107
|
+
if (this.hasAttribute('ref')) {
|
|
108
|
+
inscopeContext = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
|
|
109
|
+
}
|
|
110
|
+
if (!inscopeContext && this.getModel().instances.length !== 0) {
|
|
111
|
+
// ### always fall back to default context with there's neither a 'context' or 'ref' present
|
|
112
|
+
inscopeContext = this.getModel()
|
|
113
|
+
.getDefaultInstance()
|
|
114
|
+
.getDefaultContext();
|
|
115
|
+
// console.warn('no in scopeContext for ', this);
|
|
116
|
+
// console.warn('using default context ', this);
|
|
117
|
+
// return;
|
|
101
118
|
}
|
|
102
119
|
if (this.ref === '') {
|
|
103
120
|
this.nodeset = inscopeContext;
|
|
@@ -120,7 +137,7 @@ export const foreElementMixin = superclass =>
|
|
|
120
137
|
if (nodeType) {
|
|
121
138
|
this.nodeset = evaluateXPathToFirstNode(this.ref, inscopeContext, this);
|
|
122
139
|
} else {
|
|
123
|
-
this.nodeset = evaluateXPath(this.ref, inscopeContext, this);
|
|
140
|
+
[this.nodeset] = evaluateXPath(this.ref, inscopeContext, this);
|
|
124
141
|
}
|
|
125
142
|
}
|
|
126
143
|
// console.log('UiElement evaluated to nodeset: ', this.nodeset);
|
|
@@ -139,7 +156,7 @@ export const foreElementMixin = superclass =>
|
|
|
139
156
|
return this.getAttribute('ref');
|
|
140
157
|
}
|
|
141
158
|
// try to get closest parent bind
|
|
142
|
-
const parent =
|
|
159
|
+
const parent = Fore.getClosest('[ref]', this.parentNode);
|
|
143
160
|
if (!parent) {
|
|
144
161
|
return 'instance()'; // the default instance
|
|
145
162
|
}
|
|
@@ -178,10 +195,10 @@ export const foreElementMixin = superclass =>
|
|
|
178
195
|
this.modelItem = mi;
|
|
179
196
|
}
|
|
180
197
|
|
|
181
|
-
const repeated =
|
|
198
|
+
const repeated = Fore.getClosest('fx-repeatitem', this);
|
|
182
199
|
let existed;
|
|
183
200
|
if (repeated) {
|
|
184
|
-
const { index } =
|
|
201
|
+
const { index } = repeated;
|
|
185
202
|
if (Array.isArray(this.nodeset)) {
|
|
186
203
|
existed = this.getModel().getModelItem(this.nodeset[index - 1]);
|
|
187
204
|
} else {
|
|
@@ -211,7 +228,7 @@ export const foreElementMixin = superclass =>
|
|
|
211
228
|
return evaluateXPathToString(valAttr, inscopeContext, this.getOwnerForm());
|
|
212
229
|
} catch (error) {
|
|
213
230
|
console.error(error);
|
|
214
|
-
|
|
231
|
+
Fore.dispatch(this, 'error', { message: error });
|
|
215
232
|
}
|
|
216
233
|
}
|
|
217
234
|
if (this.textContent) {
|
|
@@ -227,14 +244,4 @@ export const foreElementMixin = superclass =>
|
|
|
227
244
|
setInScopeVariables(inScopeVariables) {
|
|
228
245
|
this.inScopeVariables = inScopeVariables;
|
|
229
246
|
}
|
|
230
|
-
|
|
231
|
-
dispatch(eventName, detail) {
|
|
232
|
-
const event = new CustomEvent(eventName, {
|
|
233
|
-
composed: true,
|
|
234
|
-
bubbles: true,
|
|
235
|
-
detail,
|
|
236
|
-
});
|
|
237
|
-
// console.log('firing', event);
|
|
238
|
-
this.dispatchEvent(event);
|
|
239
|
-
}
|
|
240
247
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { foreElementMixin } from '../ForeElementMixin.js';
|
|
2
|
-
import { evaluateXPathToBoolean } from '../xpath-evaluation.js';
|
|
2
|
+
import { evaluateXPathToBoolean, resolveId } from '../xpath-evaluation.js';
|
|
3
|
+
import getInScopeContext from '../getInScopeContext.js';
|
|
4
|
+
import { Fore } from '../fore.js';
|
|
3
5
|
|
|
4
6
|
async function wait(howLong) {
|
|
5
7
|
return new Promise(resolve => setTimeout(() => resolve(), howLong));
|
|
@@ -86,7 +88,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
86
88
|
} else if (this.target === '#document') {
|
|
87
89
|
document.addEventListener(this.event, e => this.execute(e));
|
|
88
90
|
} else {
|
|
89
|
-
this.targetElement =
|
|
91
|
+
this.targetElement = resolveId(this.target, this);
|
|
90
92
|
this.targetElement.addEventListener(this.event, e => this.execute(e));
|
|
91
93
|
}
|
|
92
94
|
} else {
|
|
@@ -112,9 +114,25 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
112
114
|
* @param e
|
|
113
115
|
*/
|
|
114
116
|
async execute(e) {
|
|
115
|
-
console.log('executing', this);
|
|
117
|
+
// console.log('executing', this);
|
|
118
|
+
// console.log('executing e', e);
|
|
119
|
+
// console.log('executing e phase', e.eventPhase);
|
|
120
|
+
if(e && e.code){
|
|
121
|
+
const vars = new Map();
|
|
122
|
+
vars.set('code',e.code);
|
|
123
|
+
this.setInScopeVariables(vars);
|
|
124
|
+
}
|
|
125
|
+
|
|
116
126
|
if (e && e.detail) {
|
|
117
127
|
this.detail = e.detail;
|
|
128
|
+
const vars = new Map();
|
|
129
|
+
Object.keys(e.detail).forEach(function(key,index) {
|
|
130
|
+
// key: the name of the object key
|
|
131
|
+
// index: the ordinal position of the key within the object
|
|
132
|
+
vars.set(key,e.detail[key]);
|
|
133
|
+
});
|
|
134
|
+
console.log("event detail vars", vars);
|
|
135
|
+
this.setInScopeVariables(vars);
|
|
118
136
|
}
|
|
119
137
|
this.needsUpdate = false;
|
|
120
138
|
|
|
@@ -124,7 +142,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
124
142
|
}
|
|
125
143
|
|
|
126
144
|
// First check if 'if' condition is true - otherwise exist right away
|
|
127
|
-
if (this.ifExpr && !evaluateXPathToBoolean(this.ifExpr, this
|
|
145
|
+
if (this.ifExpr && !evaluateXPathToBoolean(this.ifExpr, getInScopeContext(this), this)) {
|
|
128
146
|
return;
|
|
129
147
|
}
|
|
130
148
|
|
|
@@ -139,7 +157,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
139
157
|
return;
|
|
140
158
|
}
|
|
141
159
|
|
|
142
|
-
if (!evaluateXPathToBoolean(this.whileExpr, this
|
|
160
|
+
if (!evaluateXPathToBoolean(this.whileExpr, getInScopeContext(this), this)) {
|
|
143
161
|
// Done with iterating
|
|
144
162
|
return;
|
|
145
163
|
}
|
|
@@ -198,13 +216,16 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
198
216
|
}
|
|
199
217
|
|
|
200
218
|
/**
|
|
219
|
+
* dispathes action-performed event
|
|
220
|
+
*
|
|
221
|
+
* @event action-performed - whenever an action has been run
|
|
201
222
|
*/
|
|
202
223
|
dispatchActionPerformed() {
|
|
203
224
|
console.log('action-performed ', this);
|
|
204
|
-
|
|
205
|
-
new CustomEvent('action-performed', { composed: true, bubbles: true, detail: {} }),
|
|
206
|
-
);
|
|
225
|
+
Fore.dispatch(this, 'action-performed', {});
|
|
207
226
|
}
|
|
208
227
|
}
|
|
209
228
|
|
|
210
|
-
|
|
229
|
+
if (!customElements.get('abstract-action')) {
|
|
230
|
+
window.customElements.define('abstract-action', AbstractAction);
|
|
231
|
+
}
|
package/src/actions/fx-action.js
CHANGED
|
@@ -47,13 +47,15 @@ export class FxAction extends AbstractAction {
|
|
|
47
47
|
}
|
|
48
48
|
const action = actionOrVar;
|
|
49
49
|
action.detail = this.detail;
|
|
50
|
-
|
|
51
|
-
action.execute();
|
|
50
|
+
action.perform();
|
|
51
|
+
// action.execute();
|
|
52
52
|
});
|
|
53
53
|
this.dispatchActionPerformed();
|
|
54
|
-
|
|
54
|
+
this.needsUpdate = true;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
if (!customElements.get('fx-action')) {
|
|
60
|
+
window.customElements.define('fx-action', FxAction);
|
|
61
|
+
}
|
package/src/actions/fx-append.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
import { Fore } from '../fore.js';
|
|
3
|
+
import { resolveId } from '../xpath-evaluation.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* `fx-append` appends an entry to a repeat.
|
|
@@ -77,7 +78,7 @@ class FxAppend extends AbstractAction {
|
|
|
77
78
|
super.actionPerformed();
|
|
78
79
|
// const repeat = document.getElementById(this.repeat);
|
|
79
80
|
// repeat.setIndex(repeat.nodeset.length);
|
|
80
|
-
this.
|
|
81
|
+
this._dispatch();
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
/**
|
|
@@ -117,22 +118,10 @@ class FxAppend extends AbstractAction {
|
|
|
117
118
|
*
|
|
118
119
|
* The target repeat is a child of the same repeat-item as the append action.
|
|
119
120
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (Fore.isRepeated(this)) {
|
|
123
|
-
console.log('append repeated ', this.repeatContext);
|
|
124
|
-
targetRepeat = Fore.getRepeatTarget(this, this.repeat);
|
|
125
|
-
} else {
|
|
126
|
-
targetRepeat = document.getElementById(this.repeat);
|
|
127
|
-
}
|
|
121
|
+
_dispatch() {
|
|
122
|
+
const targetRepeat = resolveId(this.repeat, this);
|
|
128
123
|
console.log('dispatching index change ', targetRepeat.nodeset.length);
|
|
129
|
-
targetRepeat.
|
|
130
|
-
new CustomEvent('index-changed', {
|
|
131
|
-
composed: true,
|
|
132
|
-
bubbles: true,
|
|
133
|
-
detail: { index: targetRepeat.nodeset.length },
|
|
134
|
-
}),
|
|
135
|
-
);
|
|
124
|
+
Fore.dispatch(targetRepeat, 'index-changed', { index: targetRepeat.nodeset.length });
|
|
136
125
|
}
|
|
137
126
|
|
|
138
127
|
/**
|
|
@@ -213,4 +202,6 @@ class FxAppend extends AbstractAction {
|
|
|
213
202
|
*/
|
|
214
203
|
}
|
|
215
204
|
|
|
216
|
-
|
|
205
|
+
if (!customElements.get('fx-append')) {
|
|
206
|
+
window.customElements.define('fx-append', FxAppend);
|
|
207
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {AbstractAction} from "./abstract-action";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* `fx-confirm`
|
|
@@ -7,7 +7,7 @@ import { FxAction } from './fx-action.js';
|
|
|
7
7
|
* @customElement
|
|
8
8
|
* @demo demo/project.html
|
|
9
9
|
*/
|
|
10
|
-
export class FxConfirm extends
|
|
10
|
+
export class FxConfirm extends AbstractAction {
|
|
11
11
|
connectedCallback() {
|
|
12
12
|
this.message = this.hasAttribute('message') ? this.getAttribute('message') : null;
|
|
13
13
|
}
|
|
@@ -19,4 +19,6 @@ export class FxConfirm extends FxAction {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
if (!customElements.get('fx-confirm')) {
|
|
23
|
+
window.customElements.define('fx-confirm', FxConfirm);
|
|
24
|
+
}
|
package/src/actions/fx-delete.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
|
+
import { Fore } from '../fore.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* `fx-delete`
|
|
@@ -29,13 +30,13 @@ class FxDelete extends AbstractAction {
|
|
|
29
30
|
// ### if there's no repeat the delete action is inside of a repeat template
|
|
30
31
|
if (this.repeatId === '') {
|
|
31
32
|
// find the index to delete
|
|
32
|
-
const rItem =
|
|
33
|
+
const rItem = Fore.getClosest('fx-repeatitem', this.parentNode);
|
|
33
34
|
const idx = Array.from(rItem.parentNode.children).indexOf(rItem) + 1;
|
|
34
35
|
// console.log('>>> idx to delete ', idx);
|
|
35
36
|
|
|
36
37
|
// ### get the model now as it'll be hard once we've deleted ourselves ;)
|
|
37
38
|
this.model = this.getModel();
|
|
38
|
-
const repeat =
|
|
39
|
+
const repeat = Fore.getClosest('fx-repeat', this.parentNode);
|
|
39
40
|
|
|
40
41
|
// ### update the nodeset
|
|
41
42
|
let nodeToDelete;
|
|
@@ -77,4 +78,6 @@ class FxDelete extends AbstractAction {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
if (!customElements.get('fx-delete')) {
|
|
82
|
+
window.customElements.define('fx-delete', FxDelete);
|
|
83
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
import { evaluateXPath, resolveId } from '../xpath-evaluation.js';
|
|
3
|
-
import { XPathUtil } from '../xpath-util.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* `fx-dispatch`
|
|
@@ -68,7 +67,8 @@ export class FxDispatch extends AbstractAction {
|
|
|
68
67
|
if (value) {
|
|
69
68
|
throw new Error('if "expr" is given there must not be a "value" attribute');
|
|
70
69
|
}
|
|
71
|
-
const result = evaluateXPath(expr, this.getInScopeContext(), this.getOwnerForm());
|
|
70
|
+
const [result] = evaluateXPath(expr, this.getInScopeContext(), this.getOwnerForm());
|
|
71
|
+
|
|
72
72
|
let serialized = null;
|
|
73
73
|
if (result.nodeName) {
|
|
74
74
|
const serializer = new XMLSerializer();
|
|
@@ -90,11 +90,10 @@ export class FxDispatch extends AbstractAction {
|
|
|
90
90
|
|
|
91
91
|
// ### when targetid is given dispatch to that if present (throw an error if not) - otherwise dispatch to document
|
|
92
92
|
if (this.targetid) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
target
|
|
97
|
-
} else {
|
|
93
|
+
let target = resolveId(this.targetid, this.parentNode, null);
|
|
94
|
+
if (!target) {
|
|
95
|
+
// TODO: essentially, we want to highly prefer the closest target. in the same subcontrol.
|
|
96
|
+
// However, it may be that our target is elsewhere. Do a global search for that case
|
|
98
97
|
target = document.getElementById(this.targetid);
|
|
99
98
|
}
|
|
100
99
|
console.log('target', target);
|
|
@@ -120,4 +119,6 @@ export class FxDispatch extends AbstractAction {
|
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
|
|
122
|
+
if (!customElements.get('fx-dispatch')) {
|
|
123
|
+
window.customElements.define('fx-dispatch', FxDispatch);
|
|
124
|
+
}
|
package/src/actions/fx-hide.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fore } from '../fore.js';
|
|
2
|
+
import { AbstractAction } from './abstract-action.js';
|
|
3
|
+
import { resolveId } from '../xpath-evaluation.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* `fx-hide`
|
|
@@ -7,17 +9,19 @@ import { FxAction } from './fx-action.js';
|
|
|
7
9
|
* @customElement
|
|
8
10
|
* @demo demo/project.html
|
|
9
11
|
*/
|
|
10
|
-
export class FxHide extends
|
|
12
|
+
export class FxHide extends AbstractAction {
|
|
11
13
|
connectedCallback() {
|
|
12
14
|
this.dialog = this.getAttribute('dialog');
|
|
13
|
-
if(!this.dialog){
|
|
14
|
-
|
|
15
|
+
if (!this.dialog) {
|
|
16
|
+
Fore.dispatch(this, 'error', { message: 'dialog does not exist' });
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
perform() {
|
|
19
|
-
|
|
21
|
+
resolveId(this.dialog, this).hide();
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
if (!customElements.get('fx-hide')) {
|
|
26
|
+
window.customElements.define('fx-hide', FxHide);
|
|
27
|
+
}
|
package/src/actions/fx-insert.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
import getInScopeContext from '../getInScopeContext.js';
|
|
3
3
|
import {
|
|
4
|
-
evaluateXPath,
|
|
5
4
|
evaluateXPathToNodes,
|
|
6
5
|
evaluateXPathToFirstNode,
|
|
7
6
|
evaluateXPathToNumber,
|
|
@@ -47,6 +46,12 @@ export class FxInsert extends AbstractAction {
|
|
|
47
46
|
// ### if there's an origin attribute use it
|
|
48
47
|
let originTarget;
|
|
49
48
|
try {
|
|
49
|
+
/*
|
|
50
|
+
todo: discuss where to pass vars from event.detail into function context
|
|
51
|
+
*/
|
|
52
|
+
// this.setInScopeVariables(this.detail);
|
|
53
|
+
|
|
54
|
+
// originTarget = evaluateXPathToFirstNode(this.origin, inscope, this);
|
|
50
55
|
originTarget = evaluateXPathToFirstNode(this.origin, inscope, this.getOwnerForm());
|
|
51
56
|
if (Array.isArray(originTarget) && originTarget.length === 0) {
|
|
52
57
|
console.warn('invalid origin for this insert action - ignoring...', this);
|
|
@@ -85,32 +90,26 @@ export class FxInsert extends AbstractAction {
|
|
|
85
90
|
console.log('this.nodeset', this.nodeset);
|
|
86
91
|
*/
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
let inscope;
|
|
94
|
+
// ### 'context' attribute takes precedence over 'ref'
|
|
95
|
+
let targetSequence;
|
|
96
|
+
if (this.hasAttribute('context')) {
|
|
97
|
+
inscope = getInScopeContext(this.getAttributeNode('context'), this.getAttribute('context'));
|
|
98
|
+
targetSequence = evaluateXPathToNodes(
|
|
99
|
+
this.getAttribute('context'),
|
|
100
|
+
inscope,
|
|
101
|
+
this.getOwnerForm(),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
originSequence = originTarget.cloneNode(true);
|
|
106
|
-
} else if (targetSequence) {
|
|
107
|
-
// ### use last item of targetSequence
|
|
108
|
-
originSequence = this._cloneTargetSequence(targetSequence);
|
|
109
|
-
if(originSequence && !this.keepValues){
|
|
110
|
-
this._clear(originSequence);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
*/
|
|
105
|
+
if (this.hasAttribute('ref')) {
|
|
106
|
+
if (inscope) {
|
|
107
|
+
targetSequence = evaluateXPathToNodes(this.ref, inscope, this.getOwnerForm());
|
|
108
|
+
} else {
|
|
109
|
+
inscope = getInScopeContext(this.getAttributeNode('ref'), this.ref);
|
|
110
|
+
targetSequence = evaluateXPathToNodes(this.ref, inscope, this.getOwnerForm());
|
|
111
|
+
}
|
|
112
|
+
}
|
|
114
113
|
const originSequenceClone = this._cloneOriginSequence(inscope, targetSequence);
|
|
115
114
|
if (!originSequenceClone) return; // if no origin back out without effect
|
|
116
115
|
|
|
@@ -127,13 +126,9 @@ export class FxInsert extends AbstractAction {
|
|
|
127
126
|
index = 1;
|
|
128
127
|
console.log('appended', inscope);
|
|
129
128
|
} else {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/*
|
|
133
|
-
insert at position given by 'at' or use the last item in the targetSequence
|
|
134
|
-
*/
|
|
135
|
-
// if (this.at) {
|
|
129
|
+
/* ### insert at position given by 'at' or use the last item in the targetSequence ### */
|
|
136
130
|
if (this.hasAttribute('at')) {
|
|
131
|
+
// todo: eval 'at'
|
|
137
132
|
// index = this.at;
|
|
138
133
|
// insertLocationNode = targetSequence[this.at - 1];
|
|
139
134
|
|
|
@@ -150,7 +145,11 @@ export class FxInsert extends AbstractAction {
|
|
|
150
145
|
index = 1;
|
|
151
146
|
|
|
152
147
|
insertLocationNode = targetSequence;
|
|
153
|
-
const context =
|
|
148
|
+
const context = evaluateXPathToNumber(
|
|
149
|
+
'count(preceding::*)',
|
|
150
|
+
targetSequence,
|
|
151
|
+
this.getOwnerForm(),
|
|
152
|
+
);
|
|
154
153
|
// console.log('context', context);
|
|
155
154
|
index = context + 1;
|
|
156
155
|
// index = targetSequence.findIndex(insertLocationNode);
|
|
@@ -165,7 +164,15 @@ export class FxInsert extends AbstractAction {
|
|
|
165
164
|
// insertLocationNode.parentNode.append(originSequence);
|
|
166
165
|
// const nextSibl = insertLocationNode.nextSibling;
|
|
167
166
|
index += 1;
|
|
168
|
-
|
|
167
|
+
if (this.hasAttribute('context') && this.hasAttribute('ref')) {
|
|
168
|
+
// index=1;
|
|
169
|
+
inscope.append(originSequenceClone);
|
|
170
|
+
} else if (this.hasAttribute('context')) {
|
|
171
|
+
index = 1;
|
|
172
|
+
insertLocationNode.prepend(originSequenceClone);
|
|
173
|
+
} else {
|
|
174
|
+
insertLocationNode.insertAdjacentElement('afterend', originSequenceClone);
|
|
175
|
+
}
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
178
|
|
|
@@ -173,16 +180,17 @@ export class FxInsert extends AbstractAction {
|
|
|
173
180
|
// console.log('parent ', insertLocationNode.parentNode);
|
|
174
181
|
// console.log('instance ', this.getModel().getDefaultContext());
|
|
175
182
|
|
|
176
|
-
|
|
177
|
-
|
|
183
|
+
console.log('<<<<<<< at', this.at);
|
|
184
|
+
console.log('<<<<<<< index', index);
|
|
178
185
|
// todo: this actually should dispatch to respective instance
|
|
179
186
|
document.dispatchEvent(
|
|
180
|
-
new CustomEvent('insert', {
|
|
187
|
+
// new CustomEvent('insert', {
|
|
188
|
+
new CustomEvent('index-changed', {
|
|
181
189
|
composed: true,
|
|
182
190
|
bubbles: true,
|
|
183
191
|
detail: {
|
|
184
192
|
insertedNodes: originSequenceClone,
|
|
185
|
-
|
|
193
|
+
index,
|
|
186
194
|
},
|
|
187
195
|
}),
|
|
188
196
|
);
|
|
@@ -235,4 +243,6 @@ export class FxInsert extends AbstractAction {
|
|
|
235
243
|
}
|
|
236
244
|
}
|
|
237
245
|
|
|
238
|
-
|
|
246
|
+
if (!customElements.get('fx-insert')) {
|
|
247
|
+
window.customElements.define('fx-insert', FxInsert);
|
|
248
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
|
+
import { Fore } from '../fore.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* `fx-refresh`
|
|
@@ -8,8 +9,21 @@ import { AbstractAction } from './abstract-action.js';
|
|
|
8
9
|
*/
|
|
9
10
|
class FxRefresh extends AbstractAction {
|
|
10
11
|
perform() {
|
|
12
|
+
if (this.hasAttribute('self')) {
|
|
13
|
+
const control = Fore.getClosest('fx-control', this);
|
|
14
|
+
if (control) {
|
|
15
|
+
control.refresh();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if(this.hasAttribute('force')){
|
|
20
|
+
this.getOwnerForm().forceRefresh();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
11
23
|
this.getOwnerForm().refresh();
|
|
12
24
|
}
|
|
13
25
|
}
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
if (!customElements.get('fx-refresh')) {
|
|
28
|
+
window.customElements.define('fx-refresh', FxRefresh);
|
|
29
|
+
}
|