@jinntec/fore 1.3.0 → 1.4.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/dist/fore-dev.js +4 -4
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +3 -3
- package/dist/fore.js.map +1 -1
- package/package.json +1 -1
- package/resources/fore.css +6 -1
- package/src/ForeElementMixin.js +4 -0
- package/src/actions/abstract-action.js +77 -35
- package/src/actions/fx-action.js +9 -9
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-confirm.js +1 -1
- package/src/actions/fx-copy.js +68 -0
- package/src/actions/fx-delete.js +1 -1
- package/src/actions/fx-dispatch.js +1 -1
- package/src/actions/fx-hide.js +1 -1
- package/src/actions/fx-insert.js +1 -1
- package/src/actions/fx-message.js +1 -1
- package/src/actions/fx-refresh.js +2 -2
- package/src/actions/fx-reload.js +1 -1
- package/src/actions/fx-replace.js +1 -1
- package/src/actions/fx-return.js +1 -1
- package/src/actions/fx-send.js +2 -2
- package/src/actions/fx-setfocus.js +1 -1
- package/src/actions/fx-setvalue.js +1 -1
- package/src/actions/fx-show.js +1 -1
- package/src/actions/fx-toggle.js +1 -1
- package/src/actions/fx-update.js +1 -1
- package/src/fore.js +58 -10
- package/src/fx-bind.js +5 -0
- package/src/fx-fore.js +36 -35
- package/src/fx-instance.js +70 -70
- package/src/fx-model.js +12 -17
- package/src/fx-submission.js +420 -416
- package/src/getInScopeContext.js +2 -4
- package/src/modelitem.js +3 -1
- package/src/ui/abstract-control.js +1 -1
- package/src/ui/fx-control.js +2 -2
- package/src/ui/fx-switch.js +9 -1
- package/src/ui/fx-trigger.js +19 -18
- package/src/xpath-evaluation.js +21 -9
- package/src/xpath-util.js +13 -28
package/package.json
CHANGED
package/resources/fore.css
CHANGED
|
@@ -130,7 +130,12 @@ fx-hint{
|
|
|
130
130
|
display: none;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
fx-model,
|
|
133
|
+
fx-model,
|
|
134
|
+
fx-model *,
|
|
135
|
+
fx-model ::slotted(fx-instance),
|
|
136
|
+
fx-instance,
|
|
137
|
+
fx-action,
|
|
138
|
+
fx-setvalue{
|
|
134
139
|
display:none;
|
|
135
140
|
}
|
|
136
141
|
|
package/src/ForeElementMixin.js
CHANGED
|
@@ -100,6 +100,10 @@ export const foreElementMixin = superclass =>
|
|
|
100
100
|
*/
|
|
101
101
|
evalInContext() {
|
|
102
102
|
// const inscopeContext = this.getInScopeContext();
|
|
103
|
+
const model = this.getModel();
|
|
104
|
+
if(!model){
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
103
107
|
let inscopeContext;
|
|
104
108
|
if (this.hasAttribute('context')) {
|
|
105
109
|
inscopeContext = getInScopeContext(this.getAttributeNode('context') || this, this.context);
|
|
@@ -117,55 +117,65 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
117
117
|
* @param e
|
|
118
118
|
*/
|
|
119
119
|
async execute(e) {
|
|
120
|
+
let resolveThisEvent = () => {};
|
|
121
|
+
if (e && e.listenerPromises) {
|
|
122
|
+
e.listenerPromises.push(
|
|
123
|
+
new Promise(resolve => {
|
|
124
|
+
resolveThisEvent = resolve;
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
120
129
|
// console.log('executing', this);
|
|
121
130
|
|
|
122
131
|
// console.log('executing e', e);
|
|
123
132
|
// console.log('executing e phase', e.eventPhase);
|
|
124
|
-
if(AbstractAction.outermostHandler === null){
|
|
133
|
+
if (AbstractAction.outermostHandler === null) {
|
|
134
|
+
console.time('outermostHandler');
|
|
125
135
|
console.info(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
`%coutermost Action `,
|
|
137
|
+
'background:#e65100; color:white; padding:0.3rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;',
|
|
138
|
+
this,
|
|
129
139
|
);
|
|
130
140
|
// console.log('starting outermost handler',this);
|
|
131
141
|
AbstractAction.outermostHandler = this;
|
|
132
142
|
}
|
|
133
143
|
|
|
134
|
-
if(AbstractAction.outermostHandler !== this){
|
|
144
|
+
if (AbstractAction.outermostHandler !== this) {
|
|
135
145
|
console.info(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
`%cAction `,
|
|
147
|
+
'background:orange; color:white; padding:0.3rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;',
|
|
148
|
+
this,
|
|
139
149
|
);
|
|
140
150
|
}
|
|
141
151
|
// console.log('>>> outermostHandler', AbstractAction.outermostHandler);
|
|
142
152
|
|
|
143
|
-
if(e && e.code){
|
|
153
|
+
if (e && e.code) {
|
|
144
154
|
const vars = new Map();
|
|
145
155
|
vars.set('code', e.code);
|
|
146
156
|
// this.setInScopeVariables(vars);
|
|
147
|
-
this.setInScopeVariables(new Map([
|
|
157
|
+
this.setInScopeVariables(new Map([...this.inScopeVariables, ...vars]));
|
|
148
158
|
}
|
|
149
159
|
|
|
150
160
|
if (e && e.detail) {
|
|
151
161
|
this.detail = e.detail;
|
|
152
162
|
const vars = new Map();
|
|
153
|
-
Object.keys(e.detail).forEach(function(key,index) {
|
|
163
|
+
Object.keys(e.detail).forEach(function(key, index) {
|
|
154
164
|
// key: the name of the object key
|
|
155
165
|
// index: the ordinal position of the key within the object
|
|
156
|
-
vars.set(key,e.detail[key]);
|
|
166
|
+
vars.set(key, e.detail[key]);
|
|
157
167
|
});
|
|
158
|
-
if(vars.size !== 0){
|
|
159
|
-
console.log(
|
|
168
|
+
if (vars.size !== 0) {
|
|
169
|
+
console.log('event detail vars', vars);
|
|
160
170
|
}
|
|
161
|
-
|
|
171
|
+
this.setInScopeVariables(new Map([...this.inScopeVariables, ...vars]));
|
|
162
172
|
}
|
|
163
173
|
this.needsUpdate = false;
|
|
164
174
|
|
|
165
|
-
try{
|
|
175
|
+
try {
|
|
166
176
|
this.evalInContext();
|
|
167
|
-
}catch (error){
|
|
168
|
-
console.warn('evaluation faild',error);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.warn('evaluation faild', error);
|
|
169
179
|
}
|
|
170
180
|
if (this.targetElement && this.targetElement.nodeset) {
|
|
171
181
|
this.nodeset = this.targetElement.nodeset;
|
|
@@ -173,6 +183,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
173
183
|
|
|
174
184
|
// First check if 'if' condition is true - otherwise exist right away
|
|
175
185
|
if (this.ifExpr && !evaluateXPathToBoolean(this.ifExpr, getInScopeContext(this), this)) {
|
|
186
|
+
this._finalizePerform(resolveThisEvent);
|
|
176
187
|
return;
|
|
177
188
|
}
|
|
178
189
|
|
|
@@ -196,13 +207,20 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
196
207
|
this.perform();
|
|
197
208
|
|
|
198
209
|
// Go for one more iteration
|
|
210
|
+
if (this.delay) {
|
|
211
|
+
// If we have a delay, fire and forget this.
|
|
212
|
+
// Otherwise, if we have no delay, keep waiting for all iterations to be done.
|
|
213
|
+
// The while is then uninteruptable and immediate
|
|
214
|
+
loop();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
199
217
|
await loop();
|
|
200
218
|
};
|
|
201
219
|
|
|
202
220
|
// After loop is done call actionPerformed to update the model and UI
|
|
203
221
|
await loop();
|
|
204
|
-
|
|
205
|
-
|
|
222
|
+
|
|
223
|
+
this._finalizePerform(resolveThisEvent);
|
|
206
224
|
return;
|
|
207
225
|
}
|
|
208
226
|
|
|
@@ -212,21 +230,29 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
212
230
|
if (!this.ownerDocument.contains(this)) {
|
|
213
231
|
// We are no longer in the document. Stop working
|
|
214
232
|
this.actionPerformed();
|
|
233
|
+
resolveThisEvent();
|
|
215
234
|
return;
|
|
216
235
|
}
|
|
217
236
|
}
|
|
218
237
|
|
|
219
|
-
this.perform();
|
|
238
|
+
await this.perform();
|
|
239
|
+
this._finalizePerform(resolveThisEvent);
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
_finalizePerform(resolveThisEvent) {
|
|
220
244
|
this.actionPerformed();
|
|
221
|
-
if(AbstractAction.outermostHandler === this){
|
|
245
|
+
if (AbstractAction.outermostHandler === this) {
|
|
222
246
|
AbstractAction.outermostHandler = null;
|
|
223
247
|
console.info(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
248
|
+
`%coutermost Action done`,
|
|
249
|
+
'background:#e65100; color:white; padding:0.3rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;',
|
|
250
|
+
this,
|
|
227
251
|
);
|
|
252
|
+
console.timeEnd('outermostHandler');
|
|
228
253
|
|
|
229
254
|
}
|
|
255
|
+
resolveThisEvent();
|
|
230
256
|
}
|
|
231
257
|
|
|
232
258
|
/**
|
|
@@ -235,13 +261,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
235
261
|
*
|
|
236
262
|
* This function should not called on any action directly - call execute() instead to ensure proper execution of 'if' and 'while'
|
|
237
263
|
*/
|
|
238
|
-
perform() {
|
|
239
|
-
console.info(
|
|
240
|
-
`%cperform `,
|
|
241
|
-
"background:orange; color:white; padding:0.3rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;",
|
|
242
|
-
this
|
|
243
|
-
);
|
|
244
|
-
|
|
264
|
+
async perform() {
|
|
245
265
|
//todo: review - this evaluation seems redundant as we already evaluated in execute
|
|
246
266
|
if (this.isBound() || this.nodeName === 'FX-ACTION') {
|
|
247
267
|
this.evalInContext();
|
|
@@ -252,14 +272,36 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
252
272
|
* calls the update cycle if action signalled that update is needed.
|
|
253
273
|
*/
|
|
254
274
|
actionPerformed() {
|
|
275
|
+
const model = this.getModel();
|
|
276
|
+
if(!model){
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (!model.inited) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (
|
|
283
|
+
AbstractAction.outermostHandler &&
|
|
284
|
+
!AbstractAction.outermostHandler.ownerDocument.contains(AbstractAction.outermostHandler)
|
|
285
|
+
) {
|
|
286
|
+
// The old outermosthandler fell out of the document. An error has happened.
|
|
287
|
+
// Just remove the old one and act like we are starting anew.
|
|
288
|
+
console.warn('Unsetting outermost handler');
|
|
289
|
+
AbstractAction.outermostHandler = null;
|
|
290
|
+
}
|
|
255
291
|
// console.log('actionPerformed action parentNode ', this.parentNode);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
292
|
+
if (
|
|
293
|
+
this.needsUpdate &&
|
|
294
|
+
(AbstractAction.outermostHandler === this || !AbstractAction.outermostHandler)
|
|
295
|
+
) {
|
|
296
|
+
console.log('Running actionperformed');
|
|
259
297
|
model.recalculate();
|
|
260
298
|
model.revalidate();
|
|
261
299
|
model.parentNode.refresh(true);
|
|
262
300
|
this.dispatchActionPerformed();
|
|
301
|
+
} else if (this.needsUpdate) {
|
|
302
|
+
// We need an update, but the outermost action handler may not. Make this clear!
|
|
303
|
+
AbstractAction.outermostHandler.needsUpdate = true;
|
|
304
|
+
console.log('Update surpressed!');
|
|
263
305
|
}
|
|
264
306
|
}
|
|
265
307
|
|
package/src/actions/fx-action.js
CHANGED
|
@@ -31,7 +31,7 @@ export class FxAction extends AbstractAction {
|
|
|
31
31
|
`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
perform() {
|
|
34
|
+
async perform() {
|
|
35
35
|
super.perform();
|
|
36
36
|
const { children } = this;
|
|
37
37
|
|
|
@@ -42,14 +42,14 @@ export class FxAction extends AbstractAction {
|
|
|
42
42
|
script.src = this.src;
|
|
43
43
|
this.appendChild(script);
|
|
44
44
|
} else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
action.execute();
|
|
52
|
-
}
|
|
45
|
+
for (const actionOrVar of children) {
|
|
46
|
+
if (actionOrVar.localName === 'fx-var') {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const action = actionOrVar;
|
|
50
|
+
action.detail = this.detail;
|
|
51
|
+
await action.execute();
|
|
52
|
+
}
|
|
53
53
|
this.dispatchActionPerformed();
|
|
54
54
|
this.needsUpdate = true;
|
|
55
55
|
}
|
package/src/actions/fx-append.js
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import '../fx-model.js';
|
|
2
|
+
import {AbstractAction} from './abstract-action.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `fx-copy`
|
|
6
|
+
* todo: demo + tests
|
|
7
|
+
* @customElement
|
|
8
|
+
*/
|
|
9
|
+
export default class FxCopy extends AbstractAction {
|
|
10
|
+
static get properties() {
|
|
11
|
+
return {
|
|
12
|
+
...super.properties,
|
|
13
|
+
ref: {
|
|
14
|
+
type: String,
|
|
15
|
+
},
|
|
16
|
+
to: {
|
|
17
|
+
type: String,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.ref = '';
|
|
25
|
+
this.to = '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
if (super.connectedCallback) {
|
|
30
|
+
super.connectedCallback();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (this.hasAttribute('ref')) {
|
|
34
|
+
this.ref = this.getAttribute('ref');
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error('fx-copy must specify a "ref" attribute');
|
|
37
|
+
}
|
|
38
|
+
this.to = this.getAttribute('to');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
perform() {
|
|
42
|
+
console.log('copying to clipboard')
|
|
43
|
+
super.perform();
|
|
44
|
+
|
|
45
|
+
if(this.nodeset.nodeType === Node.ATTRIBUTE_NODE){
|
|
46
|
+
navigator.clipboard.writeText(this.nodeset.nodeValue);
|
|
47
|
+
}else{
|
|
48
|
+
navigator.clipboard.writeText(this.nodeset);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
setValue(modelItem, newVal) {
|
|
54
|
+
const item = modelItem;
|
|
55
|
+
if (!item) return;
|
|
56
|
+
|
|
57
|
+
if (item.value !== newVal) {
|
|
58
|
+
item.value = newVal;
|
|
59
|
+
this.getModel().changed.push(modelItem);
|
|
60
|
+
this.needsUpdate = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
*/
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!customElements.get('fx-copy')) {
|
|
67
|
+
window.customElements.define('fx-copy', FxCopy);
|
|
68
|
+
}
|
package/src/actions/fx-delete.js
CHANGED
|
@@ -22,7 +22,7 @@ class FxDelete extends AbstractAction {
|
|
|
22
22
|
*
|
|
23
23
|
* Will NOT perform delete if nodeset is pointing to document node, document fragment, root node or being readonly.
|
|
24
24
|
*/
|
|
25
|
-
perform() {
|
|
25
|
+
async perform() {
|
|
26
26
|
console.log('##### fx-delete executing...');
|
|
27
27
|
const inscopeContext = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
|
|
28
28
|
this.nodeset = evaluateXPathToNodes(this.ref, inscopeContext, this);
|
package/src/actions/fx-hide.js
CHANGED
package/src/actions/fx-insert.js
CHANGED
|
@@ -9,7 +9,7 @@ import {resolveId} from "../xpath-evaluation.js";
|
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
class FxRefresh extends AbstractAction {
|
|
12
|
-
perform() {
|
|
12
|
+
async perform() {
|
|
13
13
|
if (this.hasAttribute('self')) {
|
|
14
14
|
const control = Fore.getClosest('fx-control', this);
|
|
15
15
|
if (control) {
|
|
@@ -24,7 +24,7 @@ class FxRefresh extends AbstractAction {
|
|
|
24
24
|
if(this.hasAttribute('control')){
|
|
25
25
|
const targetId = this.getAttribute('control');
|
|
26
26
|
const ctrl = resolveId(targetId, this);
|
|
27
|
-
if (Fore.isUiElement(ctrl.nodeName) && typeof ctrl.refresh === 'function') {
|
|
27
|
+
if (ctrl && Fore.isUiElement(ctrl.nodeName) && typeof ctrl.refresh === 'function') {
|
|
28
28
|
ctrl.refresh();
|
|
29
29
|
}
|
|
30
30
|
return;
|
package/src/actions/fx-reload.js
CHANGED
|
@@ -32,7 +32,7 @@ export default class FxReplace extends AbstractAction {
|
|
|
32
32
|
this.with = this.getAttribute('with');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
perform() {
|
|
35
|
+
async perform() {
|
|
36
36
|
super.perform();
|
|
37
37
|
console.log('replace action');
|
|
38
38
|
// console.log('replace action variables', this.inScopeVariables);
|
package/src/actions/fx-return.js
CHANGED
|
@@ -20,7 +20,7 @@ export class FxReturn extends AbstractAction {
|
|
|
20
20
|
// const nonrelevant = this.hasAttribute('nonrelevant') ? this.getAttribute('nonrelevant') : null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
perform() {
|
|
23
|
+
async perform() {
|
|
24
24
|
super.perform();
|
|
25
25
|
console.log('performing return with nodes', this.nodeset);
|
|
26
26
|
|
package/src/actions/fx-send.js
CHANGED
|
@@ -22,7 +22,7 @@ class FxSend extends AbstractAction {
|
|
|
22
22
|
this.submission = this.getAttribute('submission');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
perform() {
|
|
25
|
+
async perform() {
|
|
26
26
|
super.perform();
|
|
27
27
|
|
|
28
28
|
console.log('submitting ', this.submission);
|
|
@@ -44,7 +44,7 @@ class FxSend extends AbstractAction {
|
|
|
44
44
|
throw new Error(`submission with id: ${this.submission} not found`);
|
|
45
45
|
}
|
|
46
46
|
console.log('submission', submission);
|
|
47
|
-
|
|
47
|
+
await submission.submit();
|
|
48
48
|
/*
|
|
49
49
|
if(submission.replace === 'instance'){
|
|
50
50
|
this.getModel().updateModel();
|
|
@@ -13,7 +13,7 @@ export class FxSetfocus extends AbstractAction {
|
|
|
13
13
|
this.control = this.hasAttribute('control') ? this.getAttribute('control') : null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
perform() {
|
|
16
|
+
async perform() {
|
|
17
17
|
console.log('setting focus', this.control);
|
|
18
18
|
// super.perform();
|
|
19
19
|
const selector = '#'+this.control;
|
package/src/actions/fx-show.js
CHANGED
package/src/actions/fx-toggle.js
CHANGED
package/src/actions/fx-update.js
CHANGED
package/src/fore.js
CHANGED
|
@@ -9,6 +9,16 @@ export class Fore {
|
|
|
9
9
|
|
|
10
10
|
static TYPE_DEFAULT = 'xs:string';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* returns the next `fx-fore` element upwards in tree
|
|
14
|
+
*
|
|
15
|
+
* @param start
|
|
16
|
+
* @returns {*}
|
|
17
|
+
*/
|
|
18
|
+
static getFore(start) {
|
|
19
|
+
return start.nodeType === Node.TEXT_NODE ? start.parentNode.closest('fx-fore'):start.closest('fx-fore');
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
static get ACTION_ELEMENTS() {
|
|
13
23
|
return [
|
|
14
24
|
'FX-ACTION',
|
|
@@ -285,14 +295,23 @@ export class Fore {
|
|
|
285
295
|
return fadeOut();
|
|
286
296
|
}
|
|
287
297
|
|
|
288
|
-
static dispatch(target, eventName, detail) {
|
|
298
|
+
static async dispatch(target, eventName, detail) {
|
|
289
299
|
const event = new CustomEvent(eventName, {
|
|
290
300
|
composed: false,
|
|
291
301
|
bubbles: true,
|
|
292
302
|
detail,
|
|
293
303
|
});
|
|
294
|
-
|
|
295
|
-
|
|
304
|
+
event.listenerPromises = [];
|
|
305
|
+
// console.info('dispatching', event.type, target);
|
|
306
|
+
// console.log('!!! DISPATCH_START', eventName);
|
|
307
|
+
|
|
308
|
+
target.dispatchEvent(event);
|
|
309
|
+
|
|
310
|
+
// By now, all listeners for the event should have registered their completion promises to us.
|
|
311
|
+
if (event.listenerPromises.length) {
|
|
312
|
+
await Promise.all(event.listenerPromises);
|
|
313
|
+
}
|
|
314
|
+
// console.log('!!! DISPATCH_DONE', eventName);
|
|
296
315
|
}
|
|
297
316
|
|
|
298
317
|
static prettifyXml(source) {
|
|
@@ -409,13 +428,42 @@ export class Fore {
|
|
|
409
428
|
}),
|
|
410
429
|
);
|
|
411
430
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
431
|
+
const imported = document.importNode(theFore,true);
|
|
432
|
+
console.log(`########## loaded fore as component ##### ${hostElement.url}`);
|
|
433
|
+
imported.addEventListener(
|
|
434
|
+
'model-construct-done',
|
|
435
|
+
e => {
|
|
436
|
+
console.log('subcomponent ready', e.target);
|
|
437
|
+
const defaultInst = imported.querySelector('fx-instance');
|
|
438
|
+
// console.log('defaultInst', defaultInst);
|
|
439
|
+
if(hostElement.initialNode){
|
|
440
|
+
const doc = new DOMParser().parseFromString('<data></data>', 'application/xml');
|
|
441
|
+
// Note: Clone the input to prevent the inner fore from editing the outer node
|
|
442
|
+
doc.firstElementChild.appendChild(hostElement.initialNode.cloneNode(true));
|
|
443
|
+
// defaultinst.setInstanceData(this.initialNode);
|
|
444
|
+
defaultInst.setInstanceData(doc);
|
|
445
|
+
}
|
|
446
|
+
// console.log('new data', defaultInst.getInstanceData());
|
|
447
|
+
// theFore.getModel().modelConstruct();
|
|
448
|
+
imported.getModel().updateModel();
|
|
449
|
+
imported.refresh();
|
|
450
|
+
return 'done';
|
|
451
|
+
|
|
452
|
+
},
|
|
453
|
+
{ once: true },
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
const dummy = hostElement.querySelector('input');
|
|
457
|
+
if (hostElement.hasAttribute('shadow')) {
|
|
458
|
+
dummy.parentNode.removeChild(dummy);
|
|
459
|
+
hostElement.shadowRoot.appendChild(imported);
|
|
460
|
+
} else {
|
|
461
|
+
console.log(this, 'replacing widget with',theFore);
|
|
462
|
+
dummy.replaceWith(imported);
|
|
463
|
+
// this.appendChild(imported);
|
|
464
|
+
}
|
|
417
465
|
})
|
|
418
|
-
|
|
466
|
+
/*.catch(error => {
|
|
419
467
|
hostElement.dispatchEvent(
|
|
420
468
|
new CustomEvent('error', {
|
|
421
469
|
composed: false,
|
|
@@ -426,7 +474,7 @@ export class Fore {
|
|
|
426
474
|
},
|
|
427
475
|
}),
|
|
428
476
|
);
|
|
429
|
-
})
|
|
477
|
+
});*/
|
|
430
478
|
}
|
|
431
479
|
|
|
432
480
|
/**
|
package/src/fx-bind.js
CHANGED