@jinntec/fore 1.0.0-5 → 1.0.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 +6 -27
- 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 +2 -1
- package/package.json +35 -39
- package/resources/fore.css +22 -54
- package/src/DependencyNotifyingDomFacade.js +5 -13
- package/src/ForeElementMixin.js +13 -20
- package/src/actions/abstract-action.js +14 -9
- package/src/actions/fx-action.js +6 -5
- package/src/actions/fx-append.js +8 -17
- package/src/actions/fx-confirm.js +3 -1
- package/src/actions/fx-delete.js +6 -3
- package/src/actions/fx-dispatch.js +9 -8
- package/src/actions/fx-hide.js +9 -6
- package/src/actions/fx-insert.js +27 -14
- package/src/actions/fx-message.js +3 -1
- package/src/actions/fx-refresh.js +11 -1
- package/src/actions/fx-replace.js +68 -0
- package/src/actions/fx-return.js +42 -0
- package/src/actions/fx-send.js +3 -1
- package/src/actions/fx-setvalue.js +58 -51
- package/src/actions/fx-show.js +8 -4
- package/src/actions/fx-toggle.js +13 -9
- package/src/actions/fx-update.js +3 -1
- package/src/dep_graph.js +1 -1
- package/src/drawdown.js +67 -82
- package/src/fore.js +141 -25
- package/src/functions/fx-function.js +11 -3
- package/src/fx-bind.js +39 -199
- package/src/fx-fore.js +101 -68
- package/src/fx-header.js +3 -1
- package/src/fx-instance.js +9 -1
- package/src/fx-model.js +31 -23
- package/src/fx-submission.js +73 -47
- package/src/fx-var.js +7 -4
- package/src/getInScopeContext.js +23 -16
- package/src/modelitem.js +4 -4
- package/src/relevance.js +65 -0
- package/src/ui/abstract-control.js +55 -35
- package/src/ui/fx-alert.js +7 -1
- package/src/ui/fx-case.js +3 -1
- package/src/ui/fx-container.js +4 -2
- package/src/ui/fx-control.js +283 -33
- package/src/ui/fx-dialog.js +50 -45
- package/src/ui/fx-group.js +3 -1
- package/src/ui/fx-hint.js +4 -1
- package/src/ui/fx-inspector.js +117 -17
- package/src/ui/fx-items.js +7 -5
- package/src/ui/fx-output.js +14 -5
- package/src/ui/fx-repeat.js +13 -26
- package/src/ui/fx-repeatitem.js +10 -4
- package/src/ui/fx-switch.js +3 -1
- package/src/ui/fx-trigger.js +3 -1
- package/src/xpath-evaluation.js +114 -102
- package/src/xpath-util.js +1 -5
- 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
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);
|
|
@@ -88,15 +93,19 @@ export class FxInsert extends AbstractAction {
|
|
|
88
93
|
let inscope;
|
|
89
94
|
// ### 'context' attribute takes precedence over 'ref'
|
|
90
95
|
let targetSequence;
|
|
91
|
-
if(this.hasAttribute('context')){
|
|
96
|
+
if (this.hasAttribute('context')) {
|
|
92
97
|
inscope = getInScopeContext(this.getAttributeNode('context'), this.getAttribute('context'));
|
|
93
|
-
targetSequence = evaluateXPathToNodes(
|
|
98
|
+
targetSequence = evaluateXPathToNodes(
|
|
99
|
+
this.getAttribute('context'),
|
|
100
|
+
inscope,
|
|
101
|
+
this.getOwnerForm(),
|
|
102
|
+
);
|
|
94
103
|
}
|
|
95
104
|
|
|
96
|
-
if(this.hasAttribute('ref')){
|
|
97
|
-
if(inscope){
|
|
105
|
+
if (this.hasAttribute('ref')) {
|
|
106
|
+
if (inscope) {
|
|
98
107
|
targetSequence = evaluateXPathToNodes(this.ref, inscope, this.getOwnerForm());
|
|
99
|
-
}else{
|
|
108
|
+
} else {
|
|
100
109
|
inscope = getInScopeContext(this.getAttributeNode('ref'), this.ref);
|
|
101
110
|
targetSequence = evaluateXPathToNodes(this.ref, inscope, this.getOwnerForm());
|
|
102
111
|
}
|
|
@@ -117,7 +126,6 @@ export class FxInsert extends AbstractAction {
|
|
|
117
126
|
index = 1;
|
|
118
127
|
console.log('appended', inscope);
|
|
119
128
|
} else {
|
|
120
|
-
|
|
121
129
|
/* ### insert at position given by 'at' or use the last item in the targetSequence ### */
|
|
122
130
|
if (this.hasAttribute('at')) {
|
|
123
131
|
// todo: eval 'at'
|
|
@@ -137,7 +145,11 @@ export class FxInsert extends AbstractAction {
|
|
|
137
145
|
index = 1;
|
|
138
146
|
|
|
139
147
|
insertLocationNode = targetSequence;
|
|
140
|
-
const context =
|
|
148
|
+
const context = evaluateXPathToNumber(
|
|
149
|
+
'count(preceding::*)',
|
|
150
|
+
targetSequence,
|
|
151
|
+
this.getOwnerForm(),
|
|
152
|
+
);
|
|
141
153
|
// console.log('context', context);
|
|
142
154
|
index = context + 1;
|
|
143
155
|
// index = targetSequence.findIndex(insertLocationNode);
|
|
@@ -152,14 +164,13 @@ export class FxInsert extends AbstractAction {
|
|
|
152
164
|
// insertLocationNode.parentNode.append(originSequence);
|
|
153
165
|
// const nextSibl = insertLocationNode.nextSibling;
|
|
154
166
|
index += 1;
|
|
155
|
-
if(this.hasAttribute('context') && this.hasAttribute('ref')){
|
|
167
|
+
if (this.hasAttribute('context') && this.hasAttribute('ref')) {
|
|
156
168
|
// index=1;
|
|
157
169
|
inscope.append(originSequenceClone);
|
|
158
|
-
}else if(this.hasAttribute('context')){
|
|
159
|
-
|
|
160
|
-
index=1;
|
|
170
|
+
} else if (this.hasAttribute('context')) {
|
|
171
|
+
index = 1;
|
|
161
172
|
insertLocationNode.prepend(originSequenceClone);
|
|
162
|
-
}else{
|
|
173
|
+
} else {
|
|
163
174
|
insertLocationNode.insertAdjacentElement('afterend', originSequenceClone);
|
|
164
175
|
}
|
|
165
176
|
}
|
|
@@ -232,4 +243,6 @@ export class FxInsert extends AbstractAction {
|
|
|
232
243
|
}
|
|
233
244
|
}
|
|
234
245
|
|
|
235
|
-
|
|
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,17 @@ 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
|
+
}
|
|
11
19
|
this.getOwnerForm().refresh();
|
|
12
20
|
}
|
|
13
21
|
}
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
if (!customElements.get('fx-refresh')) {
|
|
24
|
+
window.customElements.define('fx-refresh', FxRefresh);
|
|
25
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// import { FxAction } from './fx-action.js';
|
|
2
|
+
import '../fx-model.js';
|
|
3
|
+
import { AbstractAction } from './abstract-action.js';
|
|
4
|
+
import { evaluateXPathToFirstNode } from '../xpath-evaluation.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `fx-replace` - replaces the node referred to with 'ref' with node referred to with 'with' attribute.
|
|
8
|
+
*
|
|
9
|
+
* @customElement
|
|
10
|
+
*/
|
|
11
|
+
export default class FxReplace extends AbstractAction {
|
|
12
|
+
static get properties() {
|
|
13
|
+
return {
|
|
14
|
+
...super.properties,
|
|
15
|
+
with: {
|
|
16
|
+
type: String,
|
|
17
|
+
},
|
|
18
|
+
replaceNode: Object,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.with = '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
if (super.connectedCallback) {
|
|
29
|
+
super.connectedCallback();
|
|
30
|
+
}
|
|
31
|
+
this.with = this.getAttribute('with');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
perform() {
|
|
35
|
+
super.perform();
|
|
36
|
+
console.log('replace action');
|
|
37
|
+
if (!this.nodeset) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const target = evaluateXPathToFirstNode(this.with, this.nodeset, this);
|
|
41
|
+
if (!target) return;
|
|
42
|
+
|
|
43
|
+
this.replace(this.nodeset, target);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
replace(toReplace, replaceWith) {
|
|
47
|
+
if (!toReplace || !replaceWith) return; // bail out silently
|
|
48
|
+
if (!toReplace.nodeName || !replaceWith.nodeName) {
|
|
49
|
+
console.warn('fx-replace: one argument is not a node');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (toReplace.nodeType === Node.ATTRIBUTE_NODE) {
|
|
54
|
+
const { ownerElement } = toReplace;
|
|
55
|
+
ownerElement.setAttribute(replaceWith.nodeName, replaceWith.textContent);
|
|
56
|
+
ownerElement.removeAttribute(toReplace.nodeName);
|
|
57
|
+
console.log('owner', ownerElement);
|
|
58
|
+
} else if (toReplace.nodeType === Node.ELEMENT_NODE) {
|
|
59
|
+
const cloned = replaceWith.cloneNode(true);
|
|
60
|
+
toReplace.replaceWith(cloned);
|
|
61
|
+
}
|
|
62
|
+
this.needsUpdate = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!customElements.get('fx-replace')) {
|
|
67
|
+
window.customElements.define('fx-replace', FxReplace);
|
|
68
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AbstractAction } from './abstract-action.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `fx-return`
|
|
5
|
+
* returns data from a nested Fore to it's host Fore.
|
|
6
|
+
*
|
|
7
|
+
* behaves like a `<fx-submission @replace='instance' with `targetref` and respects relevance processing.
|
|
8
|
+
*
|
|
9
|
+
* `targetref` will be the `ref` of the host control.
|
|
10
|
+
*
|
|
11
|
+
* todo: deos not relevant selection yet
|
|
12
|
+
*
|
|
13
|
+
* @customElement
|
|
14
|
+
*/
|
|
15
|
+
export class FxReturn extends AbstractAction {
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
if (super.connectedCallback) {
|
|
18
|
+
super.connectedCallback();
|
|
19
|
+
}
|
|
20
|
+
// const nonrelevant = this.hasAttribute('nonrelevant') ? this.getAttribute('nonrelevant') : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
perform() {
|
|
24
|
+
super.perform();
|
|
25
|
+
console.log('performing return with nodes', this.nodeset);
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
### note that this event does not use Fore.dispatch as the event uses 'composed:true' to let the event travel
|
|
29
|
+
up through the shadowRoot and being catched in outer form.
|
|
30
|
+
*/
|
|
31
|
+
const event = new CustomEvent('return', {
|
|
32
|
+
composed: true,
|
|
33
|
+
bubbles: true,
|
|
34
|
+
detail: { nodeset: this.nodeset },
|
|
35
|
+
});
|
|
36
|
+
this.getOwnerForm().dispatchEvent(event);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!customElements.get('fx-return')) {
|
|
41
|
+
window.customElements.define('fx-return', FxReturn);
|
|
42
|
+
}
|
package/src/actions/fx-send.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// import { FxAction } from './fx-action.js';
|
|
2
2
|
import '../fx-model.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import {AbstractAction} from './abstract-action.js';
|
|
4
|
+
import {evaluateXPath} from '../xpath-evaluation.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* `fx-setvalue`
|
|
@@ -9,64 +9,71 @@ import { evaluateXPath } from '../xpath-evaluation.js';
|
|
|
9
9
|
* @customElement
|
|
10
10
|
*/
|
|
11
11
|
export default class FxSetvalue extends AbstractAction {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
this.ref = '';
|
|
27
|
-
this.valueAttr = '';
|
|
28
|
-
}
|
|
12
|
+
static get properties() {
|
|
13
|
+
return {
|
|
14
|
+
...super.properties,
|
|
15
|
+
ref: {
|
|
16
|
+
type: String,
|
|
17
|
+
},
|
|
18
|
+
valueAttr: {
|
|
19
|
+
type: String,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.ref = '';
|
|
27
|
+
this.valueAttr = '';
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
if (super.connectedCallback) {
|
|
32
|
+
super.connectedCallback();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (this.hasAttribute('ref')) {
|
|
36
|
+
this.ref = this.getAttribute('ref');
|
|
37
|
+
} else {
|
|
38
|
+
throw new Error('fx-setvalue must specify a "ref" attribute');
|
|
39
|
+
}
|
|
40
|
+
this.valueAttr = this.getAttribute('value');
|
|
39
41
|
}
|
|
40
|
-
this.valueAttr = this.getAttribute('value');
|
|
41
|
-
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
perform() {
|
|
44
|
+
super.perform();
|
|
45
|
+
let {value} = this;
|
|
46
|
+
if (this.valueAttr !== null) {
|
|
47
|
+
[value] = evaluateXPath(this.valueAttr, this.nodeset, this, this.detail);
|
|
48
|
+
} else if (this.textContent !== '') {
|
|
49
|
+
value = this.textContent;
|
|
50
|
+
} else {
|
|
51
|
+
value = '';
|
|
52
|
+
}
|
|
53
|
+
console.log('value', value);
|
|
54
|
+
if (value.nodeType === Node.ATTRIBUTE_NODE) {
|
|
55
|
+
console.log('value', value.nodeValue);
|
|
56
|
+
value = value.nodeValue;
|
|
57
|
+
}
|
|
58
|
+
const mi = this.getModelItem();
|
|
59
|
+
this.setValue(mi, value);
|
|
52
60
|
}
|
|
53
|
-
const mi = this.getModelItem();
|
|
54
|
-
this.setValue(mi, value);
|
|
55
|
-
}
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
setValue(modelItem, newVal) {
|
|
63
|
+
console.log('setvalue[1] ', modelItem, newVal);
|
|
59
64
|
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
const item = modelItem;
|
|
66
|
+
if (!item) return;
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
if (item.value !== newVal) {
|
|
69
|
+
item.value = newVal;
|
|
70
|
+
this.getModel().changed.push(modelItem);
|
|
71
|
+
this.needsUpdate = true;
|
|
72
|
+
console.log('setvalue[2] ', item, newVal);
|
|
73
|
+
}
|
|
68
74
|
}
|
|
69
|
-
}
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
if (!customElements.get('fx-setvalue')) {
|
|
78
|
+
window.customElements.define('fx-setvalue', FxSetvalue);
|
|
79
|
+
}
|
package/src/actions/fx-show.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Fore } from '../fore.js';
|
|
1
2
|
import { FxAction } from './fx-action.js';
|
|
3
|
+
import { resolveId } from '../xpath-evaluation.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* `fx-confirm`
|
|
@@ -10,14 +12,16 @@ import { FxAction } from './fx-action.js';
|
|
|
10
12
|
export class FxShow extends FxAction {
|
|
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).open();
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
if (!customElements.get('fx-show')) {
|
|
26
|
+
window.customElements.define('fx-show', FxShow);
|
|
27
|
+
}
|
package/src/actions/fx-toggle.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* `fx-toggle`
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
|
-
class FxToggle extends
|
|
7
|
+
class FxToggle extends AbstractAction {
|
|
8
|
+
/*
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.attachShadow({ mode: 'open' });
|
|
12
|
+
}
|
|
13
|
+
*/
|
|
8
14
|
connectedCallback() {
|
|
15
|
+
super.connectedCallback();
|
|
9
16
|
if (this.hasAttribute('case')) {
|
|
10
17
|
this.case = this.getAttribute('case');
|
|
11
18
|
}
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
/*
|
|
15
|
-
disconnectedCallback() {
|
|
16
|
-
super.disconnectedCallback();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
21
|
perform() {
|
|
21
22
|
super.perform();
|
|
22
23
|
console.log('### fx-toggle.execute ');
|
|
@@ -26,7 +27,10 @@ class FxToggle extends FxAction {
|
|
|
26
27
|
const fxSwitch = caseElement.parentNode;
|
|
27
28
|
fxSwitch.toggle(caseElement);
|
|
28
29
|
}
|
|
30
|
+
// this.needsUpdate = true;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
if (!customElements.get('fx-toggle')) {
|
|
35
|
+
window.customElements.define('fx-toggle', FxToggle);
|
|
36
|
+
}
|
package/src/actions/fx-update.js
CHANGED
package/src/dep_graph.js
CHANGED