@jinntec/fore 1.4.0 → 1.6.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 +2 -36
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -30
- package/dist/fore.js.map +1 -1
- package/index.js +13 -0
- package/package.json +9 -5
- package/resources/fore.css +178 -92
- package/src/DependencyNotifyingDomFacade.js +1 -2
- package/src/ForeElementMixin.js +31 -5
- package/src/actions/abstract-action.js +379 -270
- package/src/actions/fx-action.js +0 -1
- package/src/actions/fx-append.js +1 -2
- package/src/actions/fx-confirm.js +12 -0
- package/src/actions/fx-copy.js +0 -1
- package/src/actions/fx-delete.js +31 -9
- package/src/actions/fx-dispatch.js +19 -5
- package/src/actions/fx-hide.js +19 -0
- package/src/actions/fx-insert.js +72 -8
- package/src/actions/fx-load.js +253 -0
- package/src/actions/fx-message.js +22 -7
- package/src/actions/fx-refresh.js +11 -1
- package/src/actions/fx-reload.js +12 -2
- package/src/actions/fx-replace.js +5 -4
- package/src/actions/fx-reset.js +48 -0
- package/src/actions/fx-return.js +0 -1
- package/src/actions/fx-send.js +40 -2
- package/src/actions/fx-setfocus.js +25 -7
- package/src/actions/fx-setvalue.js +32 -4
- package/src/actions/fx-show.js +14 -2
- package/src/actions/fx-toggle.js +0 -1
- package/src/actions/fx-update.js +9 -0
- package/src/events.js +0 -1
- package/src/fore.js +119 -63
- package/src/functions/common-function.js +28 -0
- package/src/fx-bind.js +7 -7
- package/src/fx-fore.js +207 -54
- package/src/fx-instance.js +55 -17
- package/src/fx-model.js +31 -33
- package/src/fx-submission.js +50 -47
- package/src/getInScopeContext.js +22 -8
- package/src/lab/fore-component.js +90 -0
- package/src/lab/instance-inspector.js +56 -0
- package/src/lab/template.html +16 -0
- package/src/relevance.js +27 -1
- package/src/tools/adi.js +1056 -0
- package/src/tools/fx-action-log.js +662 -0
- package/src/tools/fx-devtools.js +444 -0
- package/src/tools/fx-dom-inspector.js +609 -0
- package/src/tools/fx-json-instance.js +435 -0
- package/src/tools/fx-log-item.js +133 -0
- package/src/tools/fx-log-settings.js +474 -0
- package/src/tools/fx-minimap.js +194 -0
- package/src/tools/helpers.js +132 -0
- package/src/ui/abstract-control.js +41 -3
- package/src/ui/fx-action-log.js +358 -0
- package/src/ui/fx-alert.js +0 -1
- package/src/ui/fx-container.js +14 -3
- package/src/ui/fx-control.js +553 -474
- package/src/ui/fx-dialog.js +2 -0
- package/src/ui/fx-dom-inspector.js +1255 -0
- package/src/ui/fx-group.js +3 -4
- package/src/ui/fx-hint.js +2 -4
- package/src/ui/fx-inspector.js +5 -6
- package/src/ui/fx-items.js +55 -14
- package/src/ui/fx-output.js +36 -17
- package/src/ui/fx-repeat-attributes.js +409 -0
- package/src/ui/fx-repeat.js +12 -6
- package/src/ui/fx-switch.js +14 -3
- package/src/ui/fx-trigger.js +13 -1
- package/src/xpath-evaluation.js +109 -26
- package/src/xpath-util.js +55 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { Fore } from '../fore.js';
|
|
2
|
+
import { evaluateXPath } from '../xpath-evaluation.js';
|
|
3
|
+
import getInScopeContext from '../getInScopeContext.js';
|
|
4
|
+
import { XPathUtil } from '../xpath-util.js';
|
|
5
|
+
import {foreElementMixin} from "../ForeElementMixin.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `fx-repeat`
|
|
9
|
+
*
|
|
10
|
+
* Repeats its template for each node in its' bound nodeset.
|
|
11
|
+
*
|
|
12
|
+
* Template is a standard HTML `<template>` element. Once instanciated the template
|
|
13
|
+
* is moved to the shadowDOM of the repeat for safe re-use.
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* @customElement
|
|
18
|
+
* @demo demo/todo.html
|
|
19
|
+
*
|
|
20
|
+
* todo: it should be seriously be considered to extend FxContainer instead but needs refactoring first.
|
|
21
|
+
*/
|
|
22
|
+
export class FxRepeatAttributes extends foreElementMixin(HTMLElement) {
|
|
23
|
+
static get properties() {
|
|
24
|
+
return {
|
|
25
|
+
...super.properties,
|
|
26
|
+
index: {
|
|
27
|
+
type: Number,
|
|
28
|
+
},
|
|
29
|
+
template: {
|
|
30
|
+
type: Object,
|
|
31
|
+
},
|
|
32
|
+
focusOnCreate: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
initDone: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
},
|
|
38
|
+
repeatIndex: {
|
|
39
|
+
type: Number,
|
|
40
|
+
},
|
|
41
|
+
repeatSize:{
|
|
42
|
+
type:Number,
|
|
43
|
+
},
|
|
44
|
+
nodeset: {
|
|
45
|
+
type: Array,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
constructor() {
|
|
51
|
+
super();
|
|
52
|
+
this.ref = '';
|
|
53
|
+
this.dataTemplate = [];
|
|
54
|
+
this.focusOnCreate = '';
|
|
55
|
+
this.initDone = false;
|
|
56
|
+
this.repeatIndex = 1;
|
|
57
|
+
this.nodeset = [];
|
|
58
|
+
this.inited = false;
|
|
59
|
+
this.host= {};
|
|
60
|
+
this.index = 1;
|
|
61
|
+
this.repeatSize = 0;
|
|
62
|
+
this.attachShadow({ mode: 'open', delegatesFocus: true });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get repeatSize() {
|
|
66
|
+
return this.querySelectorAll(':scope > .fx-repeatitem').length;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
set repeatSize(size) {
|
|
70
|
+
super.repeatSize = size;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
setIndex(index) {
|
|
75
|
+
// console.log('new repeat index ', index);
|
|
76
|
+
this.index = index;
|
|
77
|
+
const refd = this.querySelector('[data-ref]');
|
|
78
|
+
const rItems = refd.querySelectorAll(':scope > *');
|
|
79
|
+
this.applyIndex(rItems[this.index - 1]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
applyIndex(repeatItem) {
|
|
83
|
+
this._removeIndexMarker();
|
|
84
|
+
if (repeatItem) {
|
|
85
|
+
repeatItem.setAttribute('repeat-index', '');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get index() {
|
|
90
|
+
return this.getAttribute('index');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
set index(idx) {
|
|
94
|
+
this.setAttribute('index', idx);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_getRepeatedItems(){
|
|
98
|
+
const refd = this.querySelector('[data-ref]');
|
|
99
|
+
return refd.children;
|
|
100
|
+
}
|
|
101
|
+
async connectedCallback() {
|
|
102
|
+
// console.log('connectedCallback',this);
|
|
103
|
+
// this.display = window.getComputedStyle(this, null).getPropertyValue("display");
|
|
104
|
+
this.ref = this.getAttribute('ref');
|
|
105
|
+
// this.ref = this._getRef();
|
|
106
|
+
// console.log('### fx-repeat connected ', this.id);
|
|
107
|
+
this.addEventListener('item-changed', e => {
|
|
108
|
+
// console.log('handle index event ', e);
|
|
109
|
+
const { item } = e.detail;
|
|
110
|
+
const repeatedItems = this._getRepeatedItems();
|
|
111
|
+
const idx = Array.from(repeatedItems).indexOf(item);
|
|
112
|
+
this.applyIndex(repeatedItems[idx]);
|
|
113
|
+
this.index = idx + 1;
|
|
114
|
+
});
|
|
115
|
+
// todo: review - this is just used by append action - event consolidation ?
|
|
116
|
+
document.addEventListener('index-changed', e => {
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
if (!e.target === this) return;
|
|
119
|
+
const { index } = e.detail;
|
|
120
|
+
this.index = Number(index);
|
|
121
|
+
this.applyIndex(this.children[index - 1]);
|
|
122
|
+
});
|
|
123
|
+
/*
|
|
124
|
+
document.addEventListener('insert', e => {
|
|
125
|
+
const nodes = e.detail.insertedNodes;
|
|
126
|
+
this.index = e.detail.position;
|
|
127
|
+
console.log('insert catched', nodes, this.index);
|
|
128
|
+
});
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
// if (this.getOwnerForm().lazyRefresh) {
|
|
132
|
+
this.mutationObserver = new MutationObserver(mutations => {
|
|
133
|
+
|
|
134
|
+
if (mutations[0].type === 'childList') {
|
|
135
|
+
const added = mutations[0].addedNodes[0];
|
|
136
|
+
if (added) {
|
|
137
|
+
const path = XPathUtil.getPath(added);
|
|
138
|
+
// this.dispatch('path-mutated',{'path':path,'nodeset':this.nodeset,'index': this.index});
|
|
139
|
+
// this.index = index;
|
|
140
|
+
// const prev = mutations[0].previousSibling.previousElementSibling;
|
|
141
|
+
// const index = prev.index();
|
|
142
|
+
// this.applyIndex(this.index -1);
|
|
143
|
+
|
|
144
|
+
Fore.dispatch(this, 'path-mutated', { path, index: this.index });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
// }
|
|
149
|
+
this.getOwnerForm().registerLazyElement(this);
|
|
150
|
+
|
|
151
|
+
const style = `
|
|
152
|
+
:host{
|
|
153
|
+
}
|
|
154
|
+
.fade-out-bottom {
|
|
155
|
+
-webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
156
|
+
animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
157
|
+
}
|
|
158
|
+
.fade-out-bottom {
|
|
159
|
+
-webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
160
|
+
animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
const html = `
|
|
164
|
+
<slot></slot>
|
|
165
|
+
`;
|
|
166
|
+
this.shadowRoot.innerHTML = `
|
|
167
|
+
<style>
|
|
168
|
+
${style}
|
|
169
|
+
</style>
|
|
170
|
+
${html}
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
// this.init();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async init() {
|
|
177
|
+
// ### there must be a single 'template' child
|
|
178
|
+
|
|
179
|
+
const inited = new Promise(resolve => {
|
|
180
|
+
// console.log('##### repeat-attributes init ', this.id);
|
|
181
|
+
// if(!this.inited) this.init();
|
|
182
|
+
// does not use this.evalInContext as it is expecting a nodeset instead of single node
|
|
183
|
+
this._evalNodeset();
|
|
184
|
+
// console.log('##### ',this.id, this.nodeset);
|
|
185
|
+
|
|
186
|
+
this._initTemplate();
|
|
187
|
+
// this._initRepeatItems();
|
|
188
|
+
|
|
189
|
+
this.setAttribute('index', this.index);
|
|
190
|
+
this.inited = true;
|
|
191
|
+
resolve('done');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return inited;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_getRef(){
|
|
198
|
+
return this.getAttribute('ref');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* repeat has no own modelItems
|
|
203
|
+
* @private
|
|
204
|
+
*/
|
|
205
|
+
_evalNodeset() {
|
|
206
|
+
// const inscope = this.getInScopeContext();
|
|
207
|
+
const inscope = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
|
|
208
|
+
// console.log('##### inscope ', inscope);
|
|
209
|
+
// console.log('##### ref ', this.ref);
|
|
210
|
+
// now we got a nodeset and attach MutationObserver to it
|
|
211
|
+
|
|
212
|
+
if (this.mutationObserver && inscope.nodeName) {
|
|
213
|
+
this.mutationObserver.observe(inscope, {
|
|
214
|
+
childList: true,
|
|
215
|
+
subtree: true,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const rawNodeset = evaluateXPath(this.ref, inscope, this);
|
|
220
|
+
if (rawNodeset.length === 1 && Array.isArray(rawNodeset[0])) {
|
|
221
|
+
// This XPath likely returned an XPath array. Just collapse to that array
|
|
222
|
+
this.nodeset = rawNodeset[0];
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this.nodeset = rawNodeset;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async refresh(force) {
|
|
229
|
+
|
|
230
|
+
if (!this.inited) this.init();
|
|
231
|
+
this._evalNodeset();
|
|
232
|
+
|
|
233
|
+
let repeatItems = this.querySelectorAll('.fx-repeatitem');
|
|
234
|
+
let repeatItemCount = repeatItems.length;
|
|
235
|
+
|
|
236
|
+
let nodeCount = 1;
|
|
237
|
+
if (Array.isArray(this.nodeset)) {
|
|
238
|
+
nodeCount = this.nodeset.length;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// const contextSize = this.nodeset.length;
|
|
242
|
+
const contextSize = nodeCount;
|
|
243
|
+
// todo: review - cant the context really never be smaller than the repeat count?
|
|
244
|
+
// todo: this code can be deprecated probably but check first
|
|
245
|
+
if (contextSize < repeatItemCount) {
|
|
246
|
+
for (let position = repeatItemCount; position > contextSize; position -= 1) {
|
|
247
|
+
// remove repeatitem
|
|
248
|
+
const itemToRemove = repeatItems[position - 1];
|
|
249
|
+
itemToRemove.parentNode.removeChild(itemToRemove);
|
|
250
|
+
this.getOwnerForm().unRegisterLazyElement(itemToRemove);
|
|
251
|
+
// this._fadeOut(itemToRemove);
|
|
252
|
+
// Fore.fadeOutElement(itemToRemove)
|
|
253
|
+
this.getOwnerForm().someInstanceDataStructureChanged = true;
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (contextSize > repeatItemCount) {
|
|
259
|
+
for (let position = repeatItemCount + 1; position <= contextSize; position += 1) {
|
|
260
|
+
// add new repeatitem
|
|
261
|
+
|
|
262
|
+
const clonedTemplate = this._clone();
|
|
263
|
+
if(!clonedTemplate) return;
|
|
264
|
+
|
|
265
|
+
// ### cloned templates are always appended to the binding element - the one having the data-ref
|
|
266
|
+
const bindingElement = this.querySelector('[data-ref]');
|
|
267
|
+
bindingElement.appendChild(clonedTemplate);
|
|
268
|
+
clonedTemplate.classList.add('fx-repeatitem');
|
|
269
|
+
clonedTemplate.setAttribute('index',position);
|
|
270
|
+
|
|
271
|
+
clonedTemplate.addEventListener('click', this._dispatchIndexChange);
|
|
272
|
+
// this.addEventListener('focusin', this._handleFocus);
|
|
273
|
+
clonedTemplate.addEventListener('focusin', this._dispatchIndexChange);
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
// this._initVariables(clonedTemplate);
|
|
277
|
+
|
|
278
|
+
// newItem.nodeset = this.nodeset[position - 1];
|
|
279
|
+
// newItem.index = position;
|
|
280
|
+
this.getOwnerForm().someInstanceDataStructureChanged = true;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ### update nodeset of repeatitems
|
|
285
|
+
repeatItems = this.querySelectorAll(':scope > .fx-repeatitem');
|
|
286
|
+
repeatItemCount = repeatItems.length;
|
|
287
|
+
|
|
288
|
+
for (let position = 0; position < repeatItemCount; position += 1) {
|
|
289
|
+
const item = repeatItems[position];
|
|
290
|
+
this.getOwnerForm().registerLazyElement(item);
|
|
291
|
+
|
|
292
|
+
if (item.nodeset !== this.nodeset[position]) {
|
|
293
|
+
item.nodeset = this.nodeset[position];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Fore.refreshChildren(clone,true);
|
|
298
|
+
const fore = this.getOwnerForm();
|
|
299
|
+
if (!fore.lazyRefresh || force) {
|
|
300
|
+
Fore.refreshChildren(this, force);
|
|
301
|
+
}
|
|
302
|
+
// this.style.display = 'block';
|
|
303
|
+
// this.style.display = this.display;
|
|
304
|
+
this.setIndex(this.index);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
_dispatchIndexChange() {
|
|
308
|
+
this.dispatchEvent(
|
|
309
|
+
new CustomEvent('item-changed', { composed: false, bubbles: true, detail: { item: this , index:this.index } }),
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// eslint-disable-next-line class-methods-use-this
|
|
314
|
+
_fadeOut(el) {
|
|
315
|
+
el.style.opacity = 1;
|
|
316
|
+
|
|
317
|
+
(function fade() {
|
|
318
|
+
// eslint-disable-next-line no-cond-assign
|
|
319
|
+
if ((el.style.opacity -= 0.1) < 0) {
|
|
320
|
+
el.style.display = 'none';
|
|
321
|
+
} else {
|
|
322
|
+
requestAnimationFrame(fade);
|
|
323
|
+
}
|
|
324
|
+
})();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// eslint-disable-next-line class-methods-use-this
|
|
328
|
+
_fadeIn(el) {
|
|
329
|
+
if (!el) return;
|
|
330
|
+
|
|
331
|
+
el.style.opacity = 0;
|
|
332
|
+
el.style.display = this.display;
|
|
333
|
+
|
|
334
|
+
(function fade() {
|
|
335
|
+
// setTimeout(() => {
|
|
336
|
+
let val = parseFloat(el.style.opacity);
|
|
337
|
+
// eslint-disable-next-line no-cond-assign
|
|
338
|
+
if (!((val += 0.1) > 1)) {
|
|
339
|
+
el.style.opacity = val;
|
|
340
|
+
requestAnimationFrame(fade);
|
|
341
|
+
}
|
|
342
|
+
// }, 40);
|
|
343
|
+
})();
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
async _initTemplate() {
|
|
347
|
+
|
|
348
|
+
// const defaultSlot = this.shadowRoot.querySelector('slot');
|
|
349
|
+
// todo: this is still weak - should handle that better maybe by an explicit slot?
|
|
350
|
+
// this.template = this.firstElementChild;
|
|
351
|
+
this.template = this.querySelector('template');
|
|
352
|
+
|
|
353
|
+
/*
|
|
354
|
+
if (this.template === null) {
|
|
355
|
+
// console.error('### no template found for this repeat:', this.id);
|
|
356
|
+
// todo: catch this on form element
|
|
357
|
+
this.dispatchEvent(
|
|
358
|
+
new CustomEvent('no-template-error', {
|
|
359
|
+
composed: true,
|
|
360
|
+
bubbles: true,
|
|
361
|
+
detail: { message: `no template found for repeat:${this.id}` },
|
|
362
|
+
}),
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
*/
|
|
366
|
+
if(!this.template) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
this.shadowRoot.appendChild(this.template);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
_initVariables(newRepeatItem) {
|
|
375
|
+
const inScopeVariables = new Map(this.inScopeVariables);
|
|
376
|
+
newRepeatItem.setInScopeVariables(inScopeVariables);
|
|
377
|
+
(function registerVariables(node) {
|
|
378
|
+
for (const child of node.children) {
|
|
379
|
+
if ('setInScopeVariables' in child) {
|
|
380
|
+
child.setInScopeVariables(inScopeVariables);
|
|
381
|
+
}
|
|
382
|
+
registerVariables(child);
|
|
383
|
+
}
|
|
384
|
+
})(newRepeatItem);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
_clone() {
|
|
388
|
+
this.template = this.shadowRoot.querySelector('template');
|
|
389
|
+
if(!this.template) return;
|
|
390
|
+
return this.template.content.firstElementChild.cloneNode(true);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
_removeIndexMarker() {
|
|
394
|
+
const refd = this.querySelector('[data-ref]');
|
|
395
|
+
Array.from(refd.children).forEach(item => {
|
|
396
|
+
item.removeAttribute('repeat-index');
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
setInScopeVariables(inScopeVariables) {
|
|
401
|
+
// Repeats are interesting: the variables should be scoped per repeat item, they should not be
|
|
402
|
+
// able to see the variables in adjacent repeat items!
|
|
403
|
+
this.inScopeVariables = new Map(inScopeVariables);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (!customElements.get('fx-repeat-attributes')) {
|
|
408
|
+
window.customElements.define('fx-repeat-attributes', FxRepeatAttributes);
|
|
409
|
+
}
|
package/src/ui/fx-repeat.js
CHANGED
|
@@ -90,12 +90,17 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
90
90
|
this.setAttribute('index', idx);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
_getRef(){
|
|
94
|
+
return this.getAttribute('ref');
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
connectedCallback() {
|
|
98
|
+
// console.log('connectedCallback',this);
|
|
94
99
|
// this.display = window.getComputedStyle(this, null).getPropertyValue("display");
|
|
95
100
|
this.ref = this.getAttribute('ref');
|
|
101
|
+
// this.ref = this._getRef();
|
|
96
102
|
// console.log('### fx-repeat connected ', this.id);
|
|
97
103
|
this.addEventListener('item-changed', e => {
|
|
98
|
-
console.log('handle index event ', e);
|
|
99
104
|
const { item } = e.detail;
|
|
100
105
|
const idx = Array.from(this.children).indexOf(item);
|
|
101
106
|
this.applyIndex(this.children[idx]);
|
|
@@ -105,7 +110,6 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
105
110
|
document.addEventListener('index-changed', e => {
|
|
106
111
|
e.stopPropagation();
|
|
107
112
|
if (!e.target === this) return;
|
|
108
|
-
console.log('handle index event ', e);
|
|
109
113
|
// const { item } = e.detail;
|
|
110
114
|
// const idx = Array.from(this.children).indexOf(item);
|
|
111
115
|
const { index } = e.detail;
|
|
@@ -122,13 +126,13 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
122
126
|
|
|
123
127
|
// if (this.getOwnerForm().lazyRefresh) {
|
|
124
128
|
this.mutationObserver = new MutationObserver(mutations => {
|
|
125
|
-
console.log('mutations', mutations);
|
|
129
|
+
// console.log('mutations', mutations);
|
|
126
130
|
|
|
127
131
|
if (mutations[0].type === 'childList') {
|
|
128
132
|
const added = mutations[0].addedNodes[0];
|
|
129
133
|
if (added) {
|
|
130
134
|
const path = XPathUtil.getPath(added);
|
|
131
|
-
console.log('path mutated', path);
|
|
135
|
+
// console.log('path mutated', path);
|
|
132
136
|
// this.dispatch('path-mutated',{'path':path,'nodeset':this.nodeset,'index': this.index});
|
|
133
137
|
// this.index = index;
|
|
134
138
|
// const prev = mutations[0].previousSibling.previousElementSibling;
|
|
@@ -164,6 +168,8 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
164
168
|
</style>
|
|
165
169
|
${html}
|
|
166
170
|
`;
|
|
171
|
+
|
|
172
|
+
// this.init();
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
init() {
|
|
@@ -281,7 +287,6 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
281
287
|
|
|
282
288
|
// this.repeatCount = contextSize;
|
|
283
289
|
// console.log('repeatCount', this.repeatCount);
|
|
284
|
-
console.groupEnd();
|
|
285
290
|
}
|
|
286
291
|
|
|
287
292
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -357,7 +362,8 @@ export class FxRepeat extends foreElementMixin(HTMLElement) {
|
|
|
357
362
|
if (repeatItem.index === 1) {
|
|
358
363
|
this.applyIndex(repeatItem);
|
|
359
364
|
}
|
|
360
|
-
|
|
365
|
+
// console.log('*********repeat item created', repeatItem.nodeset)
|
|
366
|
+
Fore.dispatch(this,'item-created',{nodeset:repeatItem.nodeset, pos:index+1});
|
|
361
367
|
this._initVariables(repeatItem);
|
|
362
368
|
});
|
|
363
369
|
}
|
package/src/ui/fx-switch.js
CHANGED
|
@@ -15,6 +15,10 @@ class FxSwitch extends FxContainer {
|
|
|
15
15
|
}
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.formerCase = {};
|
|
21
|
+
}
|
|
18
22
|
connectedCallback() {
|
|
19
23
|
if (super.connectedCallback) {
|
|
20
24
|
super.connectedCallback();
|
|
@@ -39,11 +43,11 @@ class FxSwitch extends FxContainer {
|
|
|
39
43
|
super.refresh();
|
|
40
44
|
// console.log('refresh on switch ');
|
|
41
45
|
const cases = this.querySelectorAll(':scope > fx-case');
|
|
42
|
-
let selectedCase;
|
|
46
|
+
let selectedCase = cases[0]; // first is always default
|
|
43
47
|
if (this.isBound()) {
|
|
44
48
|
Array.from(cases).forEach(caseElem => {
|
|
45
49
|
const name = caseElem.getAttribute('name');
|
|
46
|
-
if (name === this.modelItem
|
|
50
|
+
if (name === this.modelItem?.value) {
|
|
47
51
|
Fore.dispatch(caseElem,'select',{});
|
|
48
52
|
caseElem.classList.add('selected-case');
|
|
49
53
|
selectedCase = caseElem;
|
|
@@ -58,13 +62,20 @@ class FxSwitch extends FxContainer {
|
|
|
58
62
|
selectedCase = this.querySelector(':scope > .selected-case');
|
|
59
63
|
// if none is selected select the first as default
|
|
60
64
|
if (!selectedCase) {
|
|
61
|
-
selectedCase = cases[0];
|
|
65
|
+
selectedCase = cases[0]; // if nothing is selected use the first case
|
|
62
66
|
Fore.dispatch(selectedCase,'select',{});
|
|
63
67
|
selectedCase.classList.add('selected-case');
|
|
64
68
|
}
|
|
65
69
|
}
|
|
70
|
+
if(this.formerCase !== selectedCase){
|
|
71
|
+
const visited = selectedCase.querySelectorAll('.visited');
|
|
72
|
+
Array.from(visited).forEach(v =>{
|
|
73
|
+
v.classList.remove('visited');
|
|
74
|
+
});
|
|
75
|
+
}
|
|
66
76
|
|
|
67
77
|
Fore.refreshChildren(selectedCase,force);
|
|
78
|
+
this.formerCase = selectedCase;
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
toggle(caseElement) {
|
package/src/ui/fx-trigger.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import XfAbstractControl from './abstract-control.js';
|
|
2
2
|
import { leadingDebounce } from '../events.js';
|
|
3
|
+
import {resolveId} from "../xpath-evaluation";
|
|
3
4
|
|
|
4
5
|
export class FxTrigger extends XfAbstractControl {
|
|
5
6
|
connectedCallback() {
|
|
@@ -28,6 +29,11 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
28
29
|
|
|
29
30
|
const element = elements[0];
|
|
30
31
|
|
|
32
|
+
this.addEventListener('mousedown', e => {
|
|
33
|
+
console.log('target', e.target.nodeName);
|
|
34
|
+
e.target.focus();
|
|
35
|
+
});
|
|
36
|
+
|
|
31
37
|
if (this.debounceDelay) {
|
|
32
38
|
this.addEventListener(
|
|
33
39
|
'click',
|
|
@@ -85,7 +91,7 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
85
91
|
// todo: support readonly for trigger not executing the action
|
|
86
92
|
const repeatedItem = this.closest('fx-repeatitem');
|
|
87
93
|
if (repeatedItem) {
|
|
88
|
-
console.log('repeated click');
|
|
94
|
+
// console.log('repeated click');
|
|
89
95
|
repeatedItem.click();
|
|
90
96
|
}
|
|
91
97
|
|
|
@@ -95,6 +101,12 @@ export class FxTrigger extends XfAbstractControl {
|
|
|
95
101
|
for (let i = 0; i < this.children.length; i += 1) {
|
|
96
102
|
const child = this.children[i];
|
|
97
103
|
if (typeof child.execute === 'function') {
|
|
104
|
+
if (e) {
|
|
105
|
+
// We are handling the event. Stop it from going further
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
if(e.type && child.event && e.type !== child.event) return;
|
|
109
|
+
}
|
|
98
110
|
// eslint-disable-next-line no-await-in-loop
|
|
99
111
|
await child.execute(e);
|
|
100
112
|
// child.execute(e);
|