@jinntec/fore 0.25.0 → 1.0.0-2
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 +75 -22
- package/dist/fore-all.js +11 -11
- package/dist/fore.js +1 -1
- package/index.js +5 -1
- package/package.json +17 -6
- package/resources/fore.css +121 -4
- package/resources/toastify.css +3 -1
- package/src/DependencyNotifyingDomFacade.js +9 -1
- package/src/ForeElementMixin.js +83 -12
- package/src/actions/abstract-action.js +101 -27
- package/src/actions/fx-action.js +4 -2
- package/src/actions/fx-append.js +21 -18
- package/src/actions/fx-confirm.js +22 -0
- package/src/actions/fx-dispatch.js +10 -2
- package/src/actions/fx-insert.js +35 -30
- package/src/actions/fx-message.js +7 -1
- package/src/actions/fx-send.js +1 -1
- package/src/actions/fx-setvalue.js +2 -9
- package/src/dep_graph.js +9 -0
- package/src/drawdown.js +172 -0
- package/src/fore.js +126 -18
- package/src/functions/fx-function.js +2 -2
- package/src/fx-bind.js +11 -7
- package/src/fx-fore.js +283 -67
- package/src/fx-header.js +20 -0
- package/src/fx-instance.js +54 -10
- package/src/fx-model.js +175 -38
- package/src/fx-submission.js +235 -53
- package/src/getInScopeContext.js +2 -3
- package/src/ui/abstract-control.js +23 -44
- package/src/ui/fx-alert.js +20 -19
- package/src/ui/fx-container.js +9 -4
- package/src/ui/fx-control.js +92 -37
- package/src/ui/fx-inspector.js +44 -0
- package/src/ui/fx-items.js +104 -20
- package/src/ui/fx-output.js +92 -3
- package/src/ui/fx-repeat.js +87 -80
- package/src/ui/fx-repeatitem.js +38 -48
- package/src/ui/fx-trigger.js +49 -27
- package/src/xpath-evaluation.js +533 -235
- package/src/xpath-util.js +50 -12
package/src/actions/fx-insert.js
CHANGED
|
@@ -38,28 +38,32 @@ export class FxInsert extends AbstractAction {
|
|
|
38
38
|
this.at = Number(this.hasAttribute('at') ? this.getAttribute('at') : 0); // default: size of nodeset, determined later
|
|
39
39
|
this.position = this.hasAttribute('position') ? this.getAttribute('position') : 'after';
|
|
40
40
|
this.origin = this.hasAttribute('origin') ? this.getAttribute('origin') : null; // last item of context seq
|
|
41
|
-
this.keepValues = this.hasAttribute('keep-values')
|
|
41
|
+
this.keepValues = !!this.hasAttribute('keep-values');
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
let
|
|
44
|
+
_cloneOriginSequence(inscope, targetSequence) {
|
|
45
|
+
let originSequenceClone;
|
|
46
46
|
if (this.origin) {
|
|
47
47
|
// ### if there's an origin attribute use it
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let originTarget;
|
|
49
|
+
try {
|
|
50
|
+
originTarget = evaluateXPathToFirstNode(this.origin, inscope, this.getOwnerForm());
|
|
51
|
+
if (Array.isArray(originTarget) && originTarget.length === 0) {
|
|
52
|
+
console.warn('invalid origin for this insert action - ignoring...', this);
|
|
53
|
+
originSequenceClone = null;
|
|
54
|
+
}
|
|
55
|
+
originSequenceClone = originTarget.cloneNode(true);
|
|
56
|
+
} catch (error) {
|
|
50
57
|
console.warn('invalid origin for this insert action - ignoring...', this);
|
|
51
|
-
// return;
|
|
52
|
-
originSequence = null;
|
|
53
58
|
}
|
|
54
|
-
originSequence = originTarget.cloneNode(true);
|
|
55
59
|
} else if (targetSequence) {
|
|
56
60
|
// ### use last item of targetSequence
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
this._clear(
|
|
61
|
+
originSequenceClone = this._cloneTargetSequence(targetSequence);
|
|
62
|
+
if (originSequenceClone && !this.keepValues) {
|
|
63
|
+
this._clear(originSequenceClone);
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
|
-
return
|
|
66
|
+
return originSequenceClone;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
_getInsertIndex(inscope, targetSequence) {
|
|
@@ -73,7 +77,7 @@ export class FxInsert extends AbstractAction {
|
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
perform() {
|
|
76
|
-
super.perform();
|
|
80
|
+
// super.perform();
|
|
77
81
|
|
|
78
82
|
/*
|
|
79
83
|
todo: !!! calling super here does not correctly give the nodeset - it's likely still a bug in ForeElementMixin !!!
|
|
@@ -86,7 +90,7 @@ export class FxInsert extends AbstractAction {
|
|
|
86
90
|
|
|
87
91
|
// @ts-ignore
|
|
88
92
|
const targetSequence = evaluateXPathToNodes(this.ref, inscope, this.getOwnerForm());
|
|
89
|
-
console.log('insert nodeset ', targetSequence);
|
|
93
|
+
// console.log('insert nodeset ', targetSequence);
|
|
90
94
|
|
|
91
95
|
// ### obtaining originSequence
|
|
92
96
|
/*
|
|
@@ -107,19 +111,19 @@ export class FxInsert extends AbstractAction {
|
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
*/
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
114
|
+
const originSequenceClone = this._cloneOriginSequence(inscope, targetSequence);
|
|
115
|
+
if (!originSequenceClone) return; // if no origin back out without effect
|
|
112
116
|
|
|
113
117
|
let insertLocationNode;
|
|
114
118
|
let index;
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
console.log('insert index', idx);
|
|
120
|
+
// const idx = this._getInsertIndex(inscope, targetSequence);
|
|
121
|
+
// console.log('insert index', idx);
|
|
118
122
|
|
|
119
123
|
// if the targetSequence is empty but we got an originSequence use inscope as context and ignore 'at' and 'position'
|
|
120
124
|
if (targetSequence.length === 0) {
|
|
121
125
|
insertLocationNode = inscope;
|
|
122
|
-
inscope.appendChild(
|
|
126
|
+
inscope.appendChild(originSequenceClone);
|
|
123
127
|
index = 1;
|
|
124
128
|
console.log('appended', inscope);
|
|
125
129
|
} else {
|
|
@@ -147,38 +151,39 @@ export class FxInsert extends AbstractAction {
|
|
|
147
151
|
|
|
148
152
|
insertLocationNode = targetSequence;
|
|
149
153
|
const context = evaluateXPath('count(preceding::*)', targetSequence, this.getOwnerForm());
|
|
150
|
-
console.log('context', context);
|
|
154
|
+
// console.log('context', context);
|
|
151
155
|
index = context + 1;
|
|
152
156
|
// index = targetSequence.findIndex(insertLocationNode);
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
if (this.position && this.position === 'before') {
|
|
156
160
|
// this.at -= 1;
|
|
157
|
-
insertLocationNode.parentNode.insertBefore(
|
|
158
|
-
originSequence.cloneNode(true),
|
|
159
|
-
insertLocationNode,
|
|
160
|
-
);
|
|
161
|
+
insertLocationNode.parentNode.insertBefore(originSequenceClone, insertLocationNode);
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
if (this.position && this.position === 'after') {
|
|
164
165
|
// insertLocationNode.parentNode.append(originSequence);
|
|
165
166
|
// const nextSibl = insertLocationNode.nextSibling;
|
|
166
167
|
index += 1;
|
|
167
|
-
insertLocationNode.insertAdjacentElement('afterend',
|
|
168
|
+
insertLocationNode.insertAdjacentElement('afterend', originSequenceClone);
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
// console.log('insert context item ', insertLocationNode);
|
|
172
173
|
// console.log('parent ', insertLocationNode.parentNode);
|
|
173
|
-
console.log('instance ', this.getModel().getDefaultContext());
|
|
174
|
+
// console.log('instance ', this.getModel().getDefaultContext());
|
|
174
175
|
|
|
175
|
-
console.log('<<<<<<< at', this.at);
|
|
176
|
-
console.log('<<<<<<< index', index);
|
|
176
|
+
// console.log('<<<<<<< at', this.at);
|
|
177
|
+
// console.log('<<<<<<< index', index);
|
|
178
|
+
// todo: this actually should dispatch to respective instance
|
|
177
179
|
document.dispatchEvent(
|
|
178
180
|
new CustomEvent('insert', {
|
|
179
181
|
composed: true,
|
|
180
182
|
bubbles: true,
|
|
181
|
-
detail: {
|
|
183
|
+
detail: {
|
|
184
|
+
insertedNodes: originSequenceClone,
|
|
185
|
+
position: index,
|
|
186
|
+
},
|
|
182
187
|
}),
|
|
183
188
|
);
|
|
184
189
|
|
|
@@ -209,7 +214,7 @@ export class FxInsert extends AbstractAction {
|
|
|
209
214
|
_clear(n) {
|
|
210
215
|
const attrs = n.attributes;
|
|
211
216
|
|
|
212
|
-
//clear attrs
|
|
217
|
+
// clear attrs
|
|
213
218
|
for (let i = 0; i < attrs.length; i += 1) {
|
|
214
219
|
// n.setAttribute(attrs[i].name,'');
|
|
215
220
|
attrs[i].value = '';
|
|
@@ -44,7 +44,13 @@ class FxMessage extends AbstractAction {
|
|
|
44
44
|
|
|
45
45
|
perform() {
|
|
46
46
|
super.perform();
|
|
47
|
-
|
|
47
|
+
let message;
|
|
48
|
+
if (this.hasAttribute('value')) {
|
|
49
|
+
message = this.getValue();
|
|
50
|
+
} else {
|
|
51
|
+
message = this.textContent;
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
this.dispatchEvent(
|
|
49
55
|
new CustomEvent('message', {
|
|
50
56
|
composed: true,
|
package/src/actions/fx-send.js
CHANGED
|
@@ -17,7 +17,7 @@ class FxSend extends AbstractAction {
|
|
|
17
17
|
connectedCallback() {
|
|
18
18
|
// eslint-disable-next-line wc/guard-super-call
|
|
19
19
|
super.connectedCallback();
|
|
20
|
-
console.log('connectedCallback ', this);
|
|
20
|
+
// console.log('connectedCallback ', this);
|
|
21
21
|
this.submission = this.getAttribute('submission');
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -44,12 +44,7 @@ export default class FxSetvalue extends AbstractAction {
|
|
|
44
44
|
super.perform();
|
|
45
45
|
let { value } = this;
|
|
46
46
|
if (this.valueAttr !== null) {
|
|
47
|
-
value = evaluateXPath(
|
|
48
|
-
this.valueAttr,
|
|
49
|
-
this.getInScopeContext(),
|
|
50
|
-
this.getOwnerForm(),
|
|
51
|
-
this.detail,
|
|
52
|
-
);
|
|
47
|
+
value = evaluateXPath(this.valueAttr, this.nodeset, this.getOwnerForm(), this.detail);
|
|
53
48
|
} else if (this.textContent !== '') {
|
|
54
49
|
value = this.textContent;
|
|
55
50
|
} else {
|
|
@@ -67,10 +62,8 @@ export default class FxSetvalue extends AbstractAction {
|
|
|
67
62
|
|
|
68
63
|
if (item.value !== newVal) {
|
|
69
64
|
item.value = newVal;
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
this.getModel().changed.push(modelItem);
|
|
72
66
|
this.needsUpdate = true;
|
|
73
|
-
|
|
74
67
|
console.log('setvalue[2] ', item, newVal);
|
|
75
68
|
}
|
|
76
69
|
}
|
package/src/dep_graph.js
CHANGED
|
@@ -320,6 +320,15 @@ DepGraph.prototype = {
|
|
|
320
320
|
}
|
|
321
321
|
throw new Error(`Node does not exist: ${node}`);
|
|
322
322
|
},
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Get an array of nodes that have no dependants (i.e. nothing depends on them).
|
|
326
|
+
*/
|
|
327
|
+
entryNodes() {
|
|
328
|
+
const self = this;
|
|
329
|
+
return Object.keys(this.nodes).filter(node => self.incomingEdges[node].length === 0);
|
|
330
|
+
},
|
|
331
|
+
|
|
323
332
|
/**
|
|
324
333
|
* Construct the overall processing order for the dependency graph.
|
|
325
334
|
*
|
package/src/drawdown.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drawdown.js
|
|
3
|
+
* (c) Adam Leggett
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
function markdown(src) {
|
|
7
|
+
var rx_lt = /</g;
|
|
8
|
+
var rx_gt = />/g;
|
|
9
|
+
var rx_space = /\t|\r|\uf8ff/g;
|
|
10
|
+
var rx_escape = /\\([\\\|`*_{}\[\]()#+\-~])/g;
|
|
11
|
+
var rx_hr = /^([*\-=_] *){3,}$/gm;
|
|
12
|
+
var rx_blockquote = /\n *> *([^]*?)(?=(\n|$){2})/g;
|
|
13
|
+
var rx_list = /\n( *)(?:[*\-+]|((\d+)|([a-z])|[A-Z])[.)]) +([^]*?)(?=(\n|$){2})/g;
|
|
14
|
+
var rx_listjoin = /<\/(ol|ul)>\n\n<\1>/g;
|
|
15
|
+
var rx_highlight = /(^|[^A-Za-z\d\\])(([*_])|(~)|(\^)|(--)|(\+\+)|`)(\2?)([^<]*?)\2\8(?!\2)(?=\W|_|$)/g;
|
|
16
|
+
var rx_code = /\n((```|~~~).*\n?([^]*?)\n?\2|(( .*?\n)+))/g;
|
|
17
|
+
var rx_link = /((!?)\[(.*?)\]\((.*?)( ".*")?\)|\\([\\`*_{}\[\]()#+\-.!~]))/g;
|
|
18
|
+
var rx_table = /\n(( *\|.*?\| *\n)+)/g;
|
|
19
|
+
var rx_thead = /^.*\n( *\|( *\:?-+\:?-+\:? *\|)* *\n|)/;
|
|
20
|
+
var rx_row = /.*\n/g;
|
|
21
|
+
var rx_cell = /\||(.*?[^\\])\|/g;
|
|
22
|
+
var rx_heading = /(?=^|>|\n)([>\s]*?)(#{1,6}) (.*?)( #*)? *(?=\n|$)/g;
|
|
23
|
+
var rx_para = /(?=^|>|\n)\s*\n+([^<]+?)\n+\s*(?=\n|<|$)/g;
|
|
24
|
+
var rx_stash = /-\d+\uf8ff/g;
|
|
25
|
+
|
|
26
|
+
function replace(rex, fn) {
|
|
27
|
+
src = src.replace(rex, fn);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function element(tag, content) {
|
|
31
|
+
return '<' + tag + '>' + content + '</' + tag + '>';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function blockquote(src) {
|
|
35
|
+
return src.replace(rx_blockquote, function(all, content) {
|
|
36
|
+
return element('blockquote', blockquote(highlight(content.replace(/^ *> */gm, ''))));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function list(src) {
|
|
41
|
+
return src.replace(rx_list, function(all, ind, ol, num, low, content) {
|
|
42
|
+
var entry = element(
|
|
43
|
+
'li',
|
|
44
|
+
highlight(
|
|
45
|
+
content
|
|
46
|
+
.split(RegExp('\n ?' + ind + '(?:(?:\\d+|[a-zA-Z])[.)]|[*\\-+]) +', 'g'))
|
|
47
|
+
.map(list)
|
|
48
|
+
.join('</li><li>'),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
'\n' +
|
|
54
|
+
(ol
|
|
55
|
+
? '<ol start="' +
|
|
56
|
+
(num
|
|
57
|
+
? ol + '">'
|
|
58
|
+
: parseInt(ol, 36) -
|
|
59
|
+
9 +
|
|
60
|
+
'" style="list-style-type:' +
|
|
61
|
+
(low ? 'low' : 'upp') +
|
|
62
|
+
'er-alpha">') +
|
|
63
|
+
entry +
|
|
64
|
+
'</ol>'
|
|
65
|
+
: element('ul', entry))
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function highlight(src) {
|
|
71
|
+
return src.replace(rx_highlight, function(all, _, p1, emp, sub, sup, small, big, p2, content) {
|
|
72
|
+
return (
|
|
73
|
+
_ +
|
|
74
|
+
element(
|
|
75
|
+
emp
|
|
76
|
+
? p2
|
|
77
|
+
? 'strong'
|
|
78
|
+
: 'em'
|
|
79
|
+
: sub
|
|
80
|
+
? p2
|
|
81
|
+
? 's'
|
|
82
|
+
: 'sub'
|
|
83
|
+
: sup
|
|
84
|
+
? 'sup'
|
|
85
|
+
: small
|
|
86
|
+
? 'small'
|
|
87
|
+
: big
|
|
88
|
+
? 'big'
|
|
89
|
+
: 'code',
|
|
90
|
+
highlight(content),
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function unesc(str) {
|
|
97
|
+
return str.replace(rx_escape, '$1');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var stash = [];
|
|
101
|
+
var si = 0;
|
|
102
|
+
|
|
103
|
+
src = '\n' + src + '\n';
|
|
104
|
+
|
|
105
|
+
replace(rx_lt, '<');
|
|
106
|
+
replace(rx_gt, '>');
|
|
107
|
+
replace(rx_space, ' ');
|
|
108
|
+
|
|
109
|
+
// blockquote
|
|
110
|
+
src = blockquote(src);
|
|
111
|
+
|
|
112
|
+
// horizontal rule
|
|
113
|
+
replace(rx_hr, '<hr/>');
|
|
114
|
+
|
|
115
|
+
// list
|
|
116
|
+
src = list(src);
|
|
117
|
+
replace(rx_listjoin, '');
|
|
118
|
+
|
|
119
|
+
// code
|
|
120
|
+
replace(rx_code, function(all, p1, p2, p3, p4) {
|
|
121
|
+
stash[--si] = element('pre', element('code', p3 || p4.replace(/^ /gm, '')));
|
|
122
|
+
return si + '\uf8ff';
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// link or image
|
|
126
|
+
replace(rx_link, function(all, p1, p2, p3, p4, p5, p6) {
|
|
127
|
+
stash[--si] = p4
|
|
128
|
+
? p2
|
|
129
|
+
? '<img src="' + p4 + '" alt="' + p3 + '"/>'
|
|
130
|
+
: '<a href="' + p4 + '">' + unesc(highlight(p3)) + '</a>'
|
|
131
|
+
: p6;
|
|
132
|
+
return si + '\uf8ff';
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// table
|
|
136
|
+
replace(rx_table, function(all, table) {
|
|
137
|
+
var sep = table.match(rx_thead)[1];
|
|
138
|
+
return (
|
|
139
|
+
'\n' +
|
|
140
|
+
element(
|
|
141
|
+
'table',
|
|
142
|
+
table.replace(rx_row, function(row, ri) {
|
|
143
|
+
return row == sep
|
|
144
|
+
? ''
|
|
145
|
+
: element(
|
|
146
|
+
'tr',
|
|
147
|
+
row.replace(rx_cell, function(all, cell, ci) {
|
|
148
|
+
return ci ? element(sep && !ri ? 'th' : 'td', unesc(highlight(cell || ''))) : '';
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
151
|
+
}),
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// heading
|
|
157
|
+
replace(rx_heading, function(all, _, p1, p2) {
|
|
158
|
+
return _ + element('h' + p1.length, unesc(highlight(p2)));
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// paragraph
|
|
162
|
+
replace(rx_para, function(all, content) {
|
|
163
|
+
return element('p', unesc(highlight(content)));
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// stash
|
|
167
|
+
replace(rx_stash, function(all) {
|
|
168
|
+
return stash[parseInt(all)];
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return src.trim();
|
|
172
|
+
}
|
package/src/fore.js
CHANGED
|
@@ -34,6 +34,21 @@ export class Fore {
|
|
|
34
34
|
];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
static createUUID() {
|
|
38
|
+
// http://www.ietf.org/rfc/rfc4122.txt
|
|
39
|
+
const s = [];
|
|
40
|
+
const hexDigits = '0123456789abcdef';
|
|
41
|
+
for (let i = 0; i < 36; i += 1) {
|
|
42
|
+
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
|
43
|
+
}
|
|
44
|
+
s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
|
|
45
|
+
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
|
46
|
+
s[8] = s[13] = s[18] = s[23] = '-';
|
|
47
|
+
|
|
48
|
+
const uuid = s.join('');
|
|
49
|
+
return uuid;
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
static get XFORMS_NAMESPACE_URI() {
|
|
38
53
|
// todo: should be centralized somewhere as constant. Exists in several? places
|
|
39
54
|
return 'http://www.w3.org/2002/xforms';
|
|
@@ -55,7 +70,7 @@ export class Fore {
|
|
|
55
70
|
'FX-GROUP',
|
|
56
71
|
'FX-HINT',
|
|
57
72
|
'FX-INPUT',
|
|
58
|
-
'FX-
|
|
73
|
+
'FX-ITEMS',
|
|
59
74
|
'FX-LABEL',
|
|
60
75
|
'FX-OUTPUT',
|
|
61
76
|
'FX-RANGE',
|
|
@@ -79,17 +94,40 @@ export class Fore {
|
|
|
79
94
|
return Fore.UI_ELEMENTS.includes(elementName);
|
|
80
95
|
}
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
/**
|
|
98
|
+
* recursively refreshes all UI Elements.
|
|
99
|
+
*
|
|
100
|
+
* todo: this could probably made more efficient with significant impact on rendering perf
|
|
101
|
+
*
|
|
102
|
+
* @param startElement
|
|
103
|
+
* @param force
|
|
104
|
+
* @returns {Promise<unknown>}
|
|
105
|
+
*/
|
|
106
|
+
static async refreshChildren(startElement, force) {
|
|
84
107
|
const refreshed = new Promise(resolve => {
|
|
108
|
+
/*
|
|
109
|
+
if there's an 'refresh-on-view' attribute the element wants to be handled by
|
|
110
|
+
handleIntersect function that calls the refresh of the respective element and
|
|
111
|
+
not the global one.
|
|
112
|
+
*/
|
|
113
|
+
// if(!force && startElement.hasAttribute('refresh-on-view')) return;
|
|
114
|
+
|
|
115
|
+
/* ### attempt with querySelectorAll is even slower than iterating recursively
|
|
116
|
+
|
|
117
|
+
const children = startElement.querySelectorAll('[ref]');
|
|
118
|
+
Array.from(children).forEach(uiElement => {
|
|
119
|
+
if (Fore.isUiElement(uiElement.nodeName) && typeof uiElement.refresh === 'function') {
|
|
120
|
+
uiElement.refresh();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
*/
|
|
85
124
|
const { children } = startElement;
|
|
86
125
|
if (children) {
|
|
87
126
|
Array.from(children).forEach(element => {
|
|
88
|
-
// todo: later - check for AVTs
|
|
89
127
|
if (Fore.isUiElement(element.nodeName) && typeof element.refresh === 'function') {
|
|
90
128
|
element.refresh();
|
|
91
|
-
} else if (element.nodeName !== '
|
|
92
|
-
Fore.refreshChildren(element);
|
|
129
|
+
} else if (element.nodeName.toUpperCase() !== 'FX-MODEL') {
|
|
130
|
+
Fore.refreshChildren(element, force);
|
|
93
131
|
}
|
|
94
132
|
});
|
|
95
133
|
}
|
|
@@ -109,24 +147,94 @@ export class Fore {
|
|
|
109
147
|
return target;
|
|
110
148
|
}
|
|
111
149
|
|
|
150
|
+
/**
|
|
151
|
+
* returns the proper content-type for instance.
|
|
152
|
+
*
|
|
153
|
+
* @param instance an fx-instance element
|
|
154
|
+
* @returns {string|null}
|
|
155
|
+
*/
|
|
156
|
+
static getContentType(instance, method) {
|
|
157
|
+
if (method === 'urlencoded-post') {
|
|
158
|
+
return 'application/x-www-form-urlencoded; charset=UTF-8';
|
|
159
|
+
}
|
|
160
|
+
if (instance.type === 'xml') {
|
|
161
|
+
return 'application/xml; charset=UTF-8';
|
|
162
|
+
}
|
|
163
|
+
if (instance.type === 'json') {
|
|
164
|
+
return 'application/json';
|
|
165
|
+
}
|
|
166
|
+
console.warn('content-type unknown ', instance.type);
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
static fadeInElement(element) {
|
|
171
|
+
const duration = 600;
|
|
172
|
+
let fadeIn = () => {
|
|
173
|
+
// Stop all current animations
|
|
174
|
+
if (element.getAnimations) {
|
|
175
|
+
element.getAnimations().map(anim => anim.finish());
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Play the animation with the newly specified duration
|
|
179
|
+
fadeIn = element.animate(
|
|
180
|
+
{
|
|
181
|
+
opacity: [0, 1],
|
|
182
|
+
},
|
|
183
|
+
duration,
|
|
184
|
+
);
|
|
185
|
+
return fadeIn.finished;
|
|
186
|
+
};
|
|
187
|
+
return fadeIn();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static fadeOutElement(element) {
|
|
191
|
+
const duration = 2600;
|
|
192
|
+
let fadeOut = () => {
|
|
193
|
+
// Stop all current animations
|
|
194
|
+
if (element.getAnimations) {
|
|
195
|
+
element.getAnimations().map(anim => anim.finish());
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Play the animation with the newly specified duration
|
|
199
|
+
fadeOut = element.animate(
|
|
200
|
+
{
|
|
201
|
+
opacity: [1, 0],
|
|
202
|
+
},
|
|
203
|
+
duration,
|
|
204
|
+
);
|
|
205
|
+
return fadeOut.finished;
|
|
206
|
+
};
|
|
207
|
+
return fadeOut();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static dispatch(target, eventName, detail) {
|
|
211
|
+
const event = new CustomEvent(eventName, {
|
|
212
|
+
composed: true,
|
|
213
|
+
bubbles: true,
|
|
214
|
+
detail,
|
|
215
|
+
});
|
|
216
|
+
console.log('firing', event);
|
|
217
|
+
target.dispatchEvent(event);
|
|
218
|
+
}
|
|
219
|
+
|
|
112
220
|
/**
|
|
113
221
|
* clear all text nodes and attribute values to get a 'clean' template.
|
|
114
222
|
* @param n
|
|
115
223
|
* @private
|
|
116
224
|
*/
|
|
117
225
|
/*
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
226
|
+
static clear(n) {
|
|
227
|
+
n.textContent = '';
|
|
228
|
+
if (n.hasAttributes()) {
|
|
229
|
+
const attrs = n.attributes;
|
|
230
|
+
for (let i = 0; i < attrs.length; i+= 1) {
|
|
231
|
+
attrs[i].value = '';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const { children } = n;
|
|
235
|
+
for (let i = 0; i < children.length; i+= 1) {
|
|
236
|
+
Fore.clear(children[i]);
|
|
124
237
|
}
|
|
125
238
|
}
|
|
126
|
-
|
|
127
|
-
for (let i = 0; i < children.length; i+= 1) {
|
|
128
|
-
Fore.clear(children[i]);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
*/
|
|
239
|
+
*/
|
|
132
240
|
}
|
|
@@ -28,9 +28,9 @@ export class FxFunction extends foreElementMixin(HTMLElement) {
|
|
|
28
28
|
const type = this.getAttribute('type') || 'text/xpath';
|
|
29
29
|
|
|
30
30
|
// Parse the signature to something useful
|
|
31
|
-
// Signature is of the form `my:sumproduct($p as xs:decimal*, $q as xs:decimal*) as xs:decimal`
|
|
31
|
+
// Signature is of the form `my:sumproduct($p as xs:decimal*, $q as xs:decimal*) as xs:decimal` or local:something($a as item()*) as item()*
|
|
32
32
|
const signatureParseResult = this.signature.match(
|
|
33
|
-
/(?:(?<prefix>[^:]*):)?(?<localName>[^(]+)\((?<params>[^)]*)\)(?: as (?<returnType>.*))?/,
|
|
33
|
+
/(?:(?<prefix>[^:]*):)?(?<localName>[^(]+)\((?<params>(?:\(\)|[^)])*)\)(?: as (?<returnType>.*))?/,
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
if (!signatureParseResult) {
|
package/src/fx-bind.js
CHANGED
|
@@ -182,12 +182,11 @@ export class FxBind extends foreElementMixin(HTMLElement) {
|
|
|
182
182
|
if (this.bindType === 'xml') {
|
|
183
183
|
this.nodeset.forEach(node => {
|
|
184
184
|
const path = XPathUtil.getPath(node);
|
|
185
|
+
this.model.mainGraph.addNode(path, node);
|
|
185
186
|
|
|
186
187
|
if (this.calculate) {
|
|
187
188
|
this.model.mainGraph.addNode(`${path}:calculate`, node);
|
|
188
189
|
// Calculated values are a dependency of the model item.
|
|
189
|
-
// Make `model1` depend on `model1:calculate`
|
|
190
|
-
this.model.mainGraph.addNode(path, node);
|
|
191
190
|
this.model.mainGraph.addDependency(path, `${path}:calculate`);
|
|
192
191
|
}
|
|
193
192
|
|
|
@@ -196,11 +195,13 @@ export class FxBind extends foreElementMixin(HTMLElement) {
|
|
|
196
195
|
this._addDependencies(calculateRefs, node, path, 'calculate');
|
|
197
196
|
}
|
|
198
197
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.
|
|
198
|
+
if (!this.calculate) {
|
|
199
|
+
const readonlyRefs = this._getReferencesForProperty(this.readonly, node);
|
|
200
|
+
if (readonlyRefs.length !== 0) {
|
|
201
|
+
this._addDependencies(readonlyRefs, node, path, 'readonly');
|
|
202
|
+
} else if (this.readonly) {
|
|
203
|
+
this.model.mainGraph.addNode(`${path}:readonly`, node);
|
|
204
|
+
}
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
// const requiredRefs = this.requiredReferences;
|
|
@@ -466,6 +467,7 @@ export class FxBind extends foreElementMixin(HTMLElement) {
|
|
|
466
467
|
|
|
467
468
|
// let value = null;
|
|
468
469
|
// const mItem = {};
|
|
470
|
+
/*
|
|
469
471
|
let targetNode = {};
|
|
470
472
|
if (node.nodeType === node.TEXT_NODE) {
|
|
471
473
|
// const parent = node.parentNode;
|
|
@@ -474,6 +476,8 @@ export class FxBind extends foreElementMixin(HTMLElement) {
|
|
|
474
476
|
} else {
|
|
475
477
|
targetNode = node;
|
|
476
478
|
}
|
|
479
|
+
*/
|
|
480
|
+
const targetNode = node;
|
|
477
481
|
|
|
478
482
|
// const path = fx.evaluateXPath('path()',node);
|
|
479
483
|
// const path = this.getPath(node);
|