@jinntec/fore 2.1.1 → 2.3.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 +2 -2
- package/dist/fore-dev.js +2 -2
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -2
- package/dist/fore.js.map +1 -1
- package/index.js +4 -2
- package/package.json +10 -38
- package/resources/fore.css +263 -262
- package/resources/vars.css +8 -0
- package/src/DependencyNotifyingDomFacade.js +1 -0
- package/src/ForeElementMixin.js +243 -228
- package/src/actions/abstract-action.js +407 -398
- package/src/actions/fx-action.js +6 -6
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-call.js +63 -62
- package/src/actions/fx-confirm.js +11 -11
- package/src/actions/fx-construct-done.js +4 -4
- package/src/actions/fx-copy.js +36 -36
- package/src/actions/fx-delete.js +77 -79
- package/src/actions/fx-dispatch.js +14 -14
- package/src/actions/fx-hide.js +15 -15
- package/src/actions/fx-insert.js +9 -12
- package/src/actions/fx-insertchild.js +88 -0
- package/src/actions/fx-load.js +188 -185
- package/src/actions/fx-message.js +18 -19
- package/src/actions/fx-refresh.js +10 -10
- package/src/actions/fx-reload.js +16 -14
- package/src/actions/fx-replace.js +0 -1
- package/src/actions/fx-reset.js +31 -31
- package/src/actions/fx-send.js +59 -52
- package/src/actions/fx-setattribute.js +48 -49
- package/src/actions/fx-setfocus.js +54 -58
- package/src/actions/fx-setvalue.js +85 -81
- package/src/actions/fx-show.js +11 -11
- package/src/actions/fx-toggle.js +2 -2
- package/src/actions/fx-toggleboolean.js +38 -39
- package/src/actions/fx-unmodified.js +27 -0
- package/src/actions/fx-update.js +6 -6
- package/src/dep_graph.js +1 -1
- package/src/drawdown.js +23 -30
- package/src/events.js +19 -19
- package/src/fore.js +143 -125
- package/src/functions/common-function.js +24 -25
- package/src/functions/fx-function.js +6 -99
- package/src/functions/fx-functionlib.js +56 -0
- package/src/functions/registerFunction.js +112 -0
- package/src/fx-bind.js +19 -24
- package/src/fx-connection.js +226 -0
- package/src/fx-fore.js +844 -815
- package/src/fx-header.js +4 -4
- package/src/fx-instance.js +25 -29
- package/src/fx-model.js +405 -380
- package/src/fx-submission.js +399 -397
- package/src/fx-var.js +13 -12
- package/src/getInScopeContext.js +102 -89
- package/src/json-util.js +24 -24
- package/src/lab/fore-component.js +48 -52
- package/src/lab/instance-inspector.js +13 -16
- package/src/modelitem.js +48 -10
- package/src/relevance.js +12 -16
- package/src/tools/adi.js +858 -812
- package/src/tools/fx-action-log.js +377 -295
- package/src/tools/fx-devtools.js +210 -210
- package/src/tools/fx-dom-inspector.js +123 -122
- package/src/tools/fx-json-instance.js +262 -253
- package/src/tools/fx-log-item.js +6 -11
- package/src/tools/fx-log-settings.js +358 -301
- package/src/tools/fx-minimap.js +186 -177
- package/src/tools/helpers.js +1 -1
- package/src/ui/abstract-control.js +73 -53
- package/src/ui/fx-case.js +59 -7
- package/src/ui/fx-container.js +13 -14
- package/src/ui/fx-control.js +572 -538
- package/src/ui/fx-dialog.js +3 -3
- package/src/ui/fx-droptarget.js +3 -4
- package/src/ui/fx-group.js +4 -2
- package/src/ui/fx-hint.js +3 -0
- package/src/ui/fx-inspector.js +5 -5
- package/src/ui/fx-items.js +11 -11
- package/src/ui/fx-output.js +10 -12
- package/src/ui/fx-repeat-attributes.js +23 -27
- package/src/ui/fx-repeat.js +347 -344
- package/src/ui/fx-repeatitem.js +75 -68
- package/src/ui/fx-switch.js +39 -14
- package/src/ui/fx-trigger.js +4 -4
- package/src/withDraggability.js +193 -191
- package/src/xpath-evaluation.js +969 -958
- package/src/xpath-util.js +161 -134
package/src/fx-var.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { createTypedValueFactory, domFacade } from 'fontoxpath';
|
|
1
2
|
import { Fore } from './fore.js';
|
|
2
3
|
import './fx-instance.js';
|
|
3
4
|
import { evaluateXPath } from './xpath-evaluation.js';
|
|
4
|
-
import
|
|
5
|
+
import ForeElementMixin from './ForeElementMixin.js';
|
|
5
6
|
import getInScopeContext from './getInScopeContext.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// We are getting sequences here (evaluateXPath is returning all items, as an array)
|
|
9
|
+
// So wrap them into something so FontoXPath also understands they are sequences, always.
|
|
10
|
+
const typedValueFactory = createTypedValueFactory('item()*');
|
|
11
|
+
|
|
12
|
+
export class FxVariable extends ForeElementMixin {
|
|
11
13
|
constructor() {
|
|
12
14
|
super();
|
|
13
15
|
|
|
@@ -15,6 +17,7 @@ export class FxVariable extends foreElementMixin(HTMLElement) {
|
|
|
15
17
|
this.name = '';
|
|
16
18
|
this.valueQuery = '';
|
|
17
19
|
this.value = null;
|
|
20
|
+
this.precedingVariables = [];
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
connectedCallback() {
|
|
@@ -25,15 +28,13 @@ export class FxVariable extends foreElementMixin(HTMLElement) {
|
|
|
25
28
|
refresh() {
|
|
26
29
|
const inscope = getInScopeContext(this, this.valueQuery);
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
[this.value] = values;
|
|
31
|
-
} else {
|
|
32
|
-
// There is no value: set to null so it's interpreted as empty-sequence later on
|
|
33
|
-
this.value = null;
|
|
34
|
-
}
|
|
31
|
+
const values = evaluateXPath(this.valueQuery, inscope, this, this.precedingVariables);
|
|
32
|
+
this.value = typedValueFactory(values, domFacade);
|
|
35
33
|
}
|
|
36
34
|
|
|
35
|
+
/**
|
|
36
|
+
* @param {Map<string, FxVariable>} inScopeVariables
|
|
37
|
+
*/
|
|
37
38
|
setInScopeVariables(inScopeVariables) {
|
|
38
39
|
if (inScopeVariables.has(this.name)) {
|
|
39
40
|
console.error(`The variable ${this.name} is declared more than once`);
|
package/src/getInScopeContext.js
CHANGED
|
@@ -1,95 +1,108 @@
|
|
|
1
1
|
import { evaluateXPathToFirstNode } from './xpath-evaluation.js';
|
|
2
|
-
import {XPathUtil} from './xpath-util.js';
|
|
2
|
+
import { XPathUtil } from './xpath-util.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @param {Node} node
|
|
6
|
+
* @returns {HTMLElement}
|
|
7
|
+
*/
|
|
4
8
|
function _getElement(node) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
if (node && node.nodeType && node.nodeType === Node.ATTRIBUTE_NODE) {
|
|
10
|
+
// The context of an attribute is the ref of the element it's defined on
|
|
11
|
+
return node.ownerElement;
|
|
12
|
+
}
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
15
|
+
// The context of a query should be the element having a ref
|
|
16
|
+
return node;
|
|
17
|
+
}
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
// For text nodes, just start looking from the parent element
|
|
20
|
+
return node.parentNode;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
function _getForeContext(node) {
|
|
20
|
-
|
|
24
|
+
return XPathUtil.getClosest('fx-fore', node);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
function _getModelInContext(node) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
// const ownerForm = node.closest('fx-fore');
|
|
29
|
+
const ownerForm = _getForeContext(node);
|
|
30
|
+
return ownerForm.getModel();
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
function _getInitialContext(node, ref) {
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
const parentBind = XPathUtil.getClosest('[ref]', node);
|
|
35
|
+
const localFore = XPathUtil.getClosest('fx-fore', node);
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
const model = _getModelInContext(node);
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
if (parentBind !== null) {
|
|
40
|
+
/*
|
|
37
41
|
make sure that the closest ref belongs to the same fx-fore element
|
|
38
42
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
return model.getDefaultInstance().getDefaultContext();
|
|
43
|
+
const parentBindFore = parentBind.closest('fx-fore');
|
|
44
|
+
if (localFore === parentBindFore) {
|
|
45
|
+
return parentBind.nodeset;
|
|
44
46
|
}
|
|
47
|
+
return model.getDefaultInstance().getDefaultContext();
|
|
48
|
+
}
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
return model.getDefaultInstance().getDefaultContext();
|
|
50
|
+
if (XPathUtil.isAbsolutePath(ref)) {
|
|
51
|
+
const instanceId = XPathUtil.getInstanceId(ref);
|
|
52
|
+
if (instanceId) {
|
|
53
|
+
return model.getInstance(instanceId).getDefaultContext();
|
|
52
54
|
}
|
|
53
|
-
// should always return default context if all other fails
|
|
54
55
|
return model.getDefaultInstance().getDefaultContext();
|
|
56
|
+
}
|
|
57
|
+
// should always return default context if all other fails
|
|
58
|
+
return model.getDefaultInstance().getDefaultContext();
|
|
55
59
|
}
|
|
56
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Get the inscope context for an XPath defined on an element, attribute or in a textnode. Uses the
|
|
63
|
+
* current iterate status, repeats, etcetera
|
|
64
|
+
*
|
|
65
|
+
* @param {Node} node The context node at this point. Can be an attribute
|
|
66
|
+
* @param {string} ref The XPath to resolve for
|
|
67
|
+
* @return {Node} The context item for this XPath
|
|
68
|
+
*/
|
|
57
69
|
export default function getInScopeContext(node, ref) {
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
// console.log('getInScopeContext', ref, node);
|
|
60
71
|
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
const parentElement = _getElement(node);
|
|
73
|
+
// console.log('getInScopeContext parent', parentElement);
|
|
63
74
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
return context;
|
|
71
|
-
}
|
|
72
|
-
const parentBind = XPathUtil.getClosest('[ref]', parentElement.parentNode);
|
|
73
|
-
if (parentBind && (parentBind.nodeName === 'FX-GROUP' || parentBind.nodeName === 'FX-CONTROL')) {
|
|
74
|
-
return parentBind.nodeset;
|
|
75
|
+
if (parentElement.nodeName === 'FX-FORE') {
|
|
76
|
+
const context = parentElement.getModel().getDefaultInstance()?.getDefaultContext();
|
|
77
|
+
if (!context) {
|
|
78
|
+
// Edge-case, we are in an inner fore. Use the outer fore's default context
|
|
79
|
+
return getInScopeContext(parentElement.parentNode, ref);
|
|
75
80
|
}
|
|
81
|
+
return context;
|
|
82
|
+
}
|
|
83
|
+
const parentBind = XPathUtil.getClosest('[ref]', parentElement.parentNode);
|
|
84
|
+
if (parentBind && (parentBind.nodeName === 'FX-GROUP' || parentBind.nodeName === 'FX-CONTROL')) {
|
|
85
|
+
return parentBind.nodeset;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const parentActionWithIterateExpr = parentElement.matches('[iterate]')
|
|
89
|
+
? parentElement
|
|
90
|
+
: XPathUtil.getClosest('[iterate]', parentElement.parentNode);
|
|
91
|
+
if (parentActionWithIterateExpr && parentActionWithIterateExpr.currentContext) {
|
|
92
|
+
return parentActionWithIterateExpr.currentContext;
|
|
93
|
+
}
|
|
76
94
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return evaluateXPathToFirstNode(
|
|
86
|
-
node.nodeValue,
|
|
87
|
-
repeatItem.nodeset,
|
|
88
|
-
_getForeContext(parentElement),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
return repeatItem.nodeset;
|
|
95
|
+
const repeatItem = XPathUtil.getClosest('fx-repeatitem', parentElement);
|
|
96
|
+
if (repeatItem) {
|
|
97
|
+
if (node.nodeName === 'context') {
|
|
98
|
+
return evaluateXPathToFirstNode(
|
|
99
|
+
node.nodeValue,
|
|
100
|
+
repeatItem.nodeset,
|
|
101
|
+
_getForeContext(parentElement),
|
|
102
|
+
);
|
|
92
103
|
}
|
|
104
|
+
return repeatItem.nodeset;
|
|
105
|
+
}
|
|
93
106
|
|
|
94
107
|
// ### check for repeatitems created by fx-repeat-attributes - this could possibly be unified with standard repeats
|
|
95
108
|
// const repeatItemFromAttrs = XPathUtil.getClosest('.fx-repeatitem', parentElement);
|
|
@@ -107,34 +120,34 @@ export default function getInScopeContext(node, ref) {
|
|
|
107
120
|
return repeatFromAttributes.nodeset[index];
|
|
108
121
|
}
|
|
109
122
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
if (parentElement.hasAttribute('context')) {
|
|
124
|
+
const initialContext = _getInitialContext(parentElement.parentNode, ref);
|
|
125
|
+
const contextAttr = parentElement.getAttribute('context');
|
|
126
|
+
return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));
|
|
127
|
+
}
|
|
115
128
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Never resolve the context from a ref itself!
|
|
131
|
-
return _getInitialContext(parentElement.parentNode, ref);
|
|
129
|
+
if (node.nodeType === Node.ATTRIBUTE_NODE && node.nodeName === 'context') {
|
|
130
|
+
const initialContext = _getInitialContext(node.ownerElement.parentNode, ref);
|
|
131
|
+
const contextAttr = node.ownerElement.getAttribute('context');
|
|
132
|
+
return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));
|
|
133
|
+
}
|
|
134
|
+
if (node.nodeType === Node.ATTRIBUTE_NODE && node.nodeName === 'ref') {
|
|
135
|
+
// Note: do not consider the ref of the owner element since it should not be used to define the
|
|
136
|
+
// context
|
|
137
|
+
if (node.ownerElement.hasAttribute('context')) {
|
|
138
|
+
const initialContext = _getInitialContext(node.ownerElement.parentNode, ref);
|
|
139
|
+
const contextAttr = node.ownerElement.getAttribute('context');
|
|
140
|
+
return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));
|
|
132
141
|
}
|
|
133
142
|
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
// Never resolve the context from a ref itself!
|
|
144
|
+
return _getInitialContext(parentElement.parentNode, ref);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// if (node.nodeType === Node.ELEMENT_NODE && node.hasAttribute('context')) {
|
|
148
|
+
// const initialContext = _getInitialContext(node.parentNode, ref);
|
|
149
|
+
// const contextAttr = node.getAttribute('context');
|
|
150
|
+
// return evaluateXPathToFirstNode(contextAttr, initialContext, _getForeContext(parentElement));
|
|
151
|
+
// }
|
|
152
|
+
return _getInitialContext(parentElement, ref);
|
|
140
153
|
}
|
package/src/json-util.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const jsonToXml =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
xml += `</${key}>`;
|
|
21
|
-
}
|
|
1
|
+
const jsonToXml = json => {
|
|
2
|
+
const convert = obj => {
|
|
3
|
+
let xml = '';
|
|
4
|
+
for (const key in obj) {
|
|
5
|
+
if (obj.hasOwnProperty(key)) {
|
|
6
|
+
xml += `<${key}`;
|
|
7
|
+
if (typeof obj[key] === 'object') {
|
|
8
|
+
if (Array.isArray(obj[key])) {
|
|
9
|
+
xml += ' type="array">';
|
|
10
|
+
obj[key].forEach(item => {
|
|
11
|
+
xml += `<_>${convert(item)}</_>`;
|
|
12
|
+
});
|
|
13
|
+
} else {
|
|
14
|
+
xml += ' type="object">';
|
|
15
|
+
xml += convert(obj[key]);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
xml += ` type="${typeof obj[key]}">${obj[key]}</${key}>`;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
xml += `</${key}>`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return xml;
|
|
24
|
+
};
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
return `<json>${convert(json)}</json>`;
|
|
27
27
|
};
|
|
@@ -6,85 +6,81 @@
|
|
|
6
6
|
* @customElement
|
|
7
7
|
*/
|
|
8
8
|
export class ForeComponent extends HTMLElement {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.attachShadow({ mode: 'open' });
|
|
12
|
+
this.src = '';
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.src = this.getAttribute('src');
|
|
17
|
+
const style = `
|
|
18
18
|
:host {
|
|
19
19
|
display:block;
|
|
20
20
|
}
|
|
21
21
|
`;
|
|
22
|
-
|
|
22
|
+
const html = `
|
|
23
23
|
<fx-fore src="${this.src}">
|
|
24
24
|
</fx-fore>
|
|
25
25
|
<slot id="default"></slot>
|
|
26
26
|
`;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
this.shadowRoot.innerHTML = `
|
|
29
29
|
<style>
|
|
30
30
|
${style}
|
|
31
31
|
</style>
|
|
32
32
|
${html}
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.filter(Boolean)
|
|
58
|
-
.join('\n');
|
|
35
|
+
/*
|
|
36
|
+
* wait for slotchange, then filter document.stylesheets to construct CSSStyleSheet
|
|
37
|
+
*/
|
|
38
|
+
const slot = this.shadowRoot.querySelector('#default');
|
|
39
|
+
slot.addEventListener('slotchange', async event => {
|
|
40
|
+
const children = event.target.assignedElements();
|
|
41
|
+
const hostedStylesheet = children.filter(
|
|
42
|
+
linkElem => linkElem.nodeName.toUpperCase() === 'LINK',
|
|
43
|
+
);
|
|
44
|
+
if (!hostedStylesheet) return;
|
|
45
|
+
const allCSS = [...document.styleSheets]
|
|
46
|
+
.map(styleSheet => {
|
|
47
|
+
if (hostedStylesheet.find(sh => sh.href === styleSheet.href)) {
|
|
48
|
+
try {
|
|
49
|
+
return [...styleSheet.cssRules].map(rule => rule.cssText).join('');
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.log('Access to stylesheet %s is denied. Ignoring…', styleSheet.href);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join('\n');
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
const sheet = new CSSStyleSheet();
|
|
59
|
+
sheet.replaceSync(allCSS);
|
|
60
|
+
this.shadowRoot.adoptedStyleSheets = [sheet];
|
|
61
|
+
});
|
|
64
62
|
|
|
65
|
-
/*
|
|
63
|
+
/*
|
|
66
64
|
const eventSlot = this.shadowRoot.querySelector('slot[name="event"]');
|
|
67
65
|
eventSlot.addEventListener('slotchange', async event => {
|
|
68
66
|
const children = event.target.assignedElements();
|
|
69
67
|
console.log('events', children)
|
|
70
68
|
});
|
|
71
69
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const fore = this.shadowRoot.querySelector('fx-fore');
|
|
80
|
-
// fore.appendChild(content.firstElementChild);
|
|
81
|
-
fore.appendChild(clone);
|
|
82
|
-
}
|
|
70
|
+
const eventTmpl = this.querySelector('fx-action');
|
|
71
|
+
if (eventTmpl) {
|
|
72
|
+
// const clone = eventTmpl.content.cloneNode(true);
|
|
73
|
+
const clone = eventTmpl.cloneNode(true);
|
|
74
|
+
this.removeChild(eventTmpl);
|
|
75
|
+
// const content = document.importNode(clone, true);
|
|
83
76
|
|
|
77
|
+
const fore = this.shadowRoot.querySelector('fx-fore');
|
|
78
|
+
// fore.appendChild(content.firstElementChild);
|
|
79
|
+
fore.appendChild(clone);
|
|
84
80
|
}
|
|
85
|
-
|
|
81
|
+
}
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
if (!customElements.get('fore-component')) {
|
|
89
|
-
|
|
85
|
+
customElements.define('fore-component', ForeComponent);
|
|
90
86
|
}
|
|
@@ -9,14 +9,14 @@ import '../../index.js';
|
|
|
9
9
|
* @customElement
|
|
10
10
|
*/
|
|
11
11
|
export class InstanceInspector extends HTMLElement {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.attachShadow({ mode: 'open' });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
this.id = this.getAttribute('id');
|
|
19
|
+
const style = `
|
|
20
20
|
:host {
|
|
21
21
|
display:block;
|
|
22
22
|
background:blue;
|
|
@@ -27,7 +27,7 @@ export class InstanceInspector extends HTMLElement {
|
|
|
27
27
|
height:100%;
|
|
28
28
|
}
|
|
29
29
|
`;
|
|
30
|
-
|
|
30
|
+
const html = `
|
|
31
31
|
<section>
|
|
32
32
|
<fx-control ref="instance('${this.id}')" as="node">
|
|
33
33
|
<label>${this.id}</label>
|
|
@@ -37,20 +37,17 @@ export class InstanceInspector extends HTMLElement {
|
|
|
37
37
|
<slot></slot>
|
|
38
38
|
`;
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
this.innerHTML = `
|
|
41
41
|
<style>
|
|
42
42
|
${style}
|
|
43
43
|
</style>
|
|
44
44
|
${html}
|
|
45
45
|
`;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
47
|
+
this.closest('fx-fore').refresh();
|
|
48
|
+
}
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
if (!customElements.get('instance-inspector')) {
|
|
55
|
-
|
|
52
|
+
customElements.define('instance-inspector', InstanceInspector);
|
|
56
53
|
}
|
package/src/modelitem.js
CHANGED
|
@@ -8,28 +8,61 @@
|
|
|
8
8
|
export class ModelItem {
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
11
|
+
* @param {string} path calculated normalized path expression linking to data
|
|
12
|
+
* @param {string} ref relative binding expression
|
|
13
|
+
* @param {boolean} readonly - boolean to signal readonly/readwrite state
|
|
14
|
+
* @param {boolean} relevant - boolean to signal relevant/non-relevant state
|
|
15
|
+
* @param {boolean} required - boolean to signal required/optional state
|
|
16
|
+
* @param {boolean} constraint - boolean boolean to signal valid/invalid state
|
|
17
|
+
* @param {string} type - string expression to set a datatype
|
|
18
|
+
* @param {Node} node - the node the 'ref' expression is referring to
|
|
19
|
+
* @param {import('./fx-bind').FxBind} bind - the fx-bind element having created this modelItem
|
|
20
20
|
*/
|
|
21
21
|
constructor(path, ref, readonly, relevant, required, constraint, type, node, bind) {
|
|
22
|
+
/**
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
22
25
|
this.path = path;
|
|
26
|
+
/**
|
|
27
|
+
* @type {string}
|
|
28
|
+
*/
|
|
23
29
|
this.ref = ref;
|
|
30
|
+
/**
|
|
31
|
+
* @type {boolean}
|
|
32
|
+
*/
|
|
24
33
|
this.constraint = constraint;
|
|
34
|
+
/**
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
25
37
|
this.readonly = readonly;
|
|
38
|
+
/**
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
*/
|
|
26
41
|
this.relevant = relevant;
|
|
42
|
+
/**
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
*/
|
|
27
45
|
this.required = required;
|
|
46
|
+
/**
|
|
47
|
+
* @type {string}
|
|
48
|
+
*/
|
|
28
49
|
this.type = type;
|
|
50
|
+
/**
|
|
51
|
+
* @type {Node}
|
|
52
|
+
*/
|
|
29
53
|
this.node = node;
|
|
54
|
+
/**
|
|
55
|
+
* @type {import('./fx-bind').FxBind}
|
|
56
|
+
*/
|
|
30
57
|
this.bind = bind;
|
|
31
58
|
this.changed = false;
|
|
59
|
+
/**
|
|
60
|
+
* @type {import('./ui/fx-alert').FxAlert[]}
|
|
61
|
+
*/
|
|
32
62
|
this.alerts = [];
|
|
63
|
+
/**
|
|
64
|
+
* @type {import('./ui/fx-control').default[]}
|
|
65
|
+
*/
|
|
33
66
|
this.boundControls = [];
|
|
34
67
|
// this.value = this._getValue();
|
|
35
68
|
}
|
|
@@ -49,15 +82,20 @@ export class ModelItem {
|
|
|
49
82
|
return this.node.textContent;
|
|
50
83
|
}
|
|
51
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @param {Node} newVal
|
|
87
|
+
*/
|
|
52
88
|
set value(newVal) {
|
|
53
89
|
// console.log('modelitem.setvalue oldVal', this.value);
|
|
54
90
|
// console.log('modelitem.setvalue newVal', newVal);
|
|
55
91
|
|
|
56
92
|
if (newVal.nodeType === Node.DOCUMENT_NODE) {
|
|
57
93
|
this.node.replaceWith(newVal.firstElementChild);
|
|
94
|
+
this.node = newVal.firstElementChild;
|
|
58
95
|
// this.node.appendChild(newVal.firstElementChild);
|
|
59
96
|
} else if (newVal.nodeType === Node.ELEMENT_NODE) {
|
|
60
97
|
this.node.replaceWith(newVal);
|
|
98
|
+
this.node = newVal;
|
|
61
99
|
// this.node.appendChild(newVal);
|
|
62
100
|
} else if (this.node.nodeType === Node.ATTRIBUTE_NODE) {
|
|
63
101
|
this.node.nodeValue = newVal;
|
|
@@ -67,7 +105,7 @@ export class ModelItem {
|
|
|
67
105
|
}
|
|
68
106
|
|
|
69
107
|
addAlert(alert) {
|
|
70
|
-
if(!this.alerts.includes(alert)){
|
|
108
|
+
if (!this.alerts.includes(alert)) {
|
|
71
109
|
this.alerts.push(alert);
|
|
72
110
|
}
|
|
73
111
|
}
|