@jinntec/fore 1.0.0-5 → 1.2.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 +7 -28
- 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 +3 -1
- package/package.json +39 -41
- package/resources/fore.css +27 -54
- package/src/DependencyNotifyingDomFacade.js +5 -13
- package/src/ForeElementMixin.js +15 -22
- package/src/actions/abstract-action.js +34 -10
- package/src/actions/fx-action.js +7 -5
- package/src/actions/fx-append.js +8 -17
- package/src/actions/fx-confirm.js +5 -3
- 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 +24 -1
- package/src/actions/fx-replace.js +74 -0
- package/src/actions/fx-return.js +42 -0
- package/src/actions/fx-send.js +3 -1
- package/src/actions/fx-setfocus.js +37 -0
- package/src/actions/fx-setvalue.js +58 -51
- package/src/actions/fx-show.js +12 -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 +143 -26
- package/src/functions/fx-function.js +17 -3
- package/src/fx-bind.js +40 -200
- package/src/fx-fore.js +598 -568
- package/src/fx-header.js +3 -1
- package/src/fx-instance.js +9 -1
- package/src/fx-model.js +60 -27
- package/src/fx-submission.js +108 -51
- package/src/fx-var.js +7 -4
- package/src/getInScopeContext.js +23 -16
- package/src/modelitem.js +4 -4
- package/src/relevance.js +64 -0
- package/src/ui/abstract-control.js +65 -37
- package/src/ui/fx-alert.js +7 -1
- package/src/ui/fx-case.js +4 -3
- package/src/ui/fx-container.js +4 -2
- package/src/ui/fx-control.js +315 -34
- 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 +118 -17
- package/src/ui/fx-items.js +7 -5
- package/src/ui/fx-output.js +19 -6
- package/src/ui/fx-repeat.js +13 -26
- package/src/ui/fx-repeatitem.js +10 -4
- package/src/ui/fx-switch.js +5 -3
- package/src/ui/fx-trigger.js +3 -1
- package/src/xpath-evaluation.js +622 -553
- package/src/xpath-util.js +2 -6
- 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/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import './src/ui/fx-items.js';
|
|
|
27
27
|
// action classes
|
|
28
28
|
import './src/actions/fx-append.js';
|
|
29
29
|
import './src/actions/fx-delete.js';
|
|
30
|
+
import './src/actions/fx-setfocus.js';
|
|
30
31
|
import './src/actions/fx-insert.js';
|
|
31
32
|
import './src/actions/fx-message.js';
|
|
32
33
|
import './src/actions/fx-setvalue.js';
|
|
@@ -35,10 +36,11 @@ import './src/actions/fx-toggle.js';
|
|
|
35
36
|
import './src/actions/fx-dispatch.js';
|
|
36
37
|
import './src/actions/fx-update.js';
|
|
37
38
|
import './src/actions/fx-refresh.js';
|
|
39
|
+
import './src/actions/fx-replace.js';
|
|
40
|
+
import './src/actions/fx-return.js';
|
|
38
41
|
import './src/actions/fx-confirm.js';
|
|
39
42
|
import './src/actions/fx-show.js';
|
|
40
43
|
import './src/actions/fx-hide.js';
|
|
41
44
|
|
|
42
45
|
import './src/functions/fx-function.js';
|
|
43
46
|
|
|
44
|
-
// import '@teipublisher/pb-components/src/pb-components-bundle.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jinntec/fore",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Fore -
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Fore - declarative user interfaces in plain HTML",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -23,57 +23,53 @@
|
|
|
23
23
|
"resources/vars.css",
|
|
24
24
|
"resources/toastify.css",
|
|
25
25
|
"src/**/*",
|
|
26
|
-
"dist/fore
|
|
27
|
-
"dist/fore
|
|
26
|
+
"dist/fore.js",
|
|
27
|
+
"dist/fore.js.map",
|
|
28
|
+
"dist/fore-dev.js",
|
|
29
|
+
"dist/fore-dev.js.map",
|
|
30
|
+
"!.DS_Store"
|
|
28
31
|
],
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@jinntec/jinn-toast": "^1.0.
|
|
31
|
-
"
|
|
32
|
-
"@polymer/iron-demo-helpers": "^3.1.0",
|
|
33
|
-
"@polymer/paper-button": "^3.0.1",
|
|
34
|
-
"@polymer/paper-checkbox": "^3.1.0",
|
|
35
|
-
"@polymer/paper-dialog": "^3.0.1",
|
|
36
|
-
"@polymer/paper-dialog-scrollable": "^3.0.1",
|
|
37
|
-
"@polymer/paper-input": "^3.2.1",
|
|
38
|
-
"fontoxpath": "^3.20.4",
|
|
39
|
-
"web-component-analyzer": "^1.1.6"
|
|
33
|
+
"@jinntec/jinn-toast": "^1.0.4",
|
|
34
|
+
"fontoxpath": "^3.26.0"
|
|
40
35
|
},
|
|
41
36
|
"devDependencies": {
|
|
42
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
43
|
-
"@open-wc/building-rollup": "^0.
|
|
44
|
-
"@open-wc/eslint-config": "^
|
|
37
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
38
|
+
"@open-wc/building-rollup": "^2.0.1",
|
|
39
|
+
"@open-wc/eslint-config": "^7.0.0",
|
|
45
40
|
"@open-wc/prettier-config": "^0.1.10",
|
|
46
|
-
"@open-wc/semantic-dom-diff": "^0.19.
|
|
47
|
-
"@open-wc/testing": "^
|
|
41
|
+
"@open-wc/semantic-dom-diff": "^0.19.6",
|
|
42
|
+
"@open-wc/testing": "^3.1.5",
|
|
48
43
|
"@open-wc/testing-karma": "^4.0.9",
|
|
49
|
-
"@open-wc/testing-karma-bs": "^1.
|
|
50
|
-
"@rollup/plugin-commonjs": "^
|
|
51
|
-
"@rollup/plugin-node-resolve": "^
|
|
44
|
+
"@open-wc/testing-karma-bs": "^1.3.94",
|
|
45
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
46
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
52
47
|
"@rollup/plugin-strip": "^2.1.0",
|
|
53
48
|
"@skypack/package-check": "^0.2.2",
|
|
54
|
-
"@webcomponents/webcomponentsjs": "^2.
|
|
55
|
-
"deepmerge": "^
|
|
56
|
-
"es-dev-server": "^1.
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"husky": "^
|
|
59
|
-
"jsdoc": "^3.6.
|
|
60
|
-
"lint-staged": "^
|
|
61
|
-
"lit-html": "^
|
|
62
|
-
"mocha": "^
|
|
63
|
-
"np": "^7.
|
|
64
|
-
"rimraf": "^
|
|
65
|
-
"rollup": "^
|
|
49
|
+
"@webcomponents/webcomponentsjs": "^2.6.0",
|
|
50
|
+
"deepmerge": "^4.2.2",
|
|
51
|
+
"es-dev-server": "^2.1.0",
|
|
52
|
+
"eslint": "^8.16.0",
|
|
53
|
+
"husky": "^8.0.1",
|
|
54
|
+
"jsdoc": "^3.6.10",
|
|
55
|
+
"lint-staged": "^12.4.3",
|
|
56
|
+
"lit-html": "^2.2.5",
|
|
57
|
+
"mocha": "^10.0.0",
|
|
58
|
+
"np": "^7.6.1",
|
|
59
|
+
"rimraf": "^3.0.2",
|
|
60
|
+
"rollup": "^2.75.4",
|
|
66
61
|
"rollup-plugin-babel": "^4.4.0",
|
|
67
62
|
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
68
|
-
"typescript": "^
|
|
63
|
+
"typescript": "^4.7.2",
|
|
64
|
+
"web-component-analyzer": "^1.1.6",
|
|
69
65
|
"xmlserializer": "^0.6.1"
|
|
70
66
|
},
|
|
71
67
|
"scripts": {
|
|
72
68
|
"test": "karma start",
|
|
73
|
-
"lint:eslint": "eslint --ext .js,.html . --ignore-path .
|
|
74
|
-
"format:eslint": "eslint --ext .js,.html . --fix --ignore-path .
|
|
75
|
-
"lint:prettier": "prettier \"**/*.js\" --check --ignore-path .
|
|
76
|
-
"format:prettier": "prettier \"**/*.js\" --write --ignore-path .
|
|
69
|
+
"lint:eslint": "eslint --ext .js,.html . --ignore-path .eslintignore",
|
|
70
|
+
"format:eslint": "eslint --ext .js,.html . --fix --ignore-path .eslintignore",
|
|
71
|
+
"lint:prettier": "prettier \"**/*.js\" --check --ignore-path .eslintignore",
|
|
72
|
+
"format:prettier": "prettier \"**/*.js\" --write --ignore-path .eslintignore",
|
|
77
73
|
"docs": "wca src -f json --outFile fore-elements.json",
|
|
78
74
|
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
79
75
|
"lint:types": "tsc",
|
|
@@ -84,7 +80,7 @@
|
|
|
84
80
|
"test:bs": "karma start karma.bs.config.js --coverage",
|
|
85
81
|
"start:build": "cd dist && es-dev-server --open",
|
|
86
82
|
"build": "rimraf dist && rollup -c rollup.config.js",
|
|
87
|
-
"start": "es-dev-server --app-index index.html --node-resolve --watch --open"
|
|
83
|
+
"start": "es-dev-server --app-index doc/index.html --node-resolve --watch --open"
|
|
88
84
|
},
|
|
89
85
|
"keywords": [
|
|
90
86
|
"Fore",
|
|
@@ -94,7 +90,9 @@
|
|
|
94
90
|
"XQuery",
|
|
95
91
|
"form",
|
|
96
92
|
"xforms",
|
|
97
|
-
"html form"
|
|
93
|
+
"html form",
|
|
94
|
+
"declarative",
|
|
95
|
+
"user interface"
|
|
98
96
|
],
|
|
99
97
|
"author": "Joern Turner",
|
|
100
98
|
"license": "MIT",
|
package/resources/fore.css
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
@import 'vars.css';
|
|
3
3
|
|
|
4
4
|
html{
|
|
5
|
-
--inspector-bg:var(--paper-grey-
|
|
5
|
+
--inspector-bg:var(--paper-grey-300);
|
|
6
6
|
--inspector-pre-bg:var(--paper-grey-100);
|
|
7
7
|
--inspector-color:var(--paper-grey-800);
|
|
8
8
|
--inspector-instance-height:200px;
|
|
9
|
+
--inspector-handle-bg: var(--paper-blue-500);
|
|
10
|
+
--inspector-handle-width: 30px;
|
|
11
|
+
|
|
9
12
|
}
|
|
10
13
|
[unresolved]{
|
|
11
14
|
display: none;
|
|
@@ -14,12 +17,16 @@ html{
|
|
|
14
17
|
pointer-events: none;
|
|
15
18
|
cursor: default;
|
|
16
19
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
fx-fore.fx-ready{
|
|
21
|
-
opacity: 1;
|
|
20
|
+
input[readonly]{
|
|
21
|
+
background: lightgrey;
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/* fx-fore{ */
|
|
25
|
+
/* opacity: 0; */
|
|
26
|
+
/* } */
|
|
27
|
+
/* fx-fore.fx-ready{ */
|
|
28
|
+
/* opacity: 1; */
|
|
29
|
+
/* } */
|
|
23
30
|
fx-group, fx-switch, fx-repeat, fx-dialog{
|
|
24
31
|
display: block;
|
|
25
32
|
}
|
|
@@ -38,13 +45,18 @@ fx-alert{
|
|
|
38
45
|
font-size: 0.9rem;
|
|
39
46
|
}
|
|
40
47
|
|
|
48
|
+
/* case not displayed by default - if you want e.g. apply transitions you have to overwrite this rule with display='inline' or similar */
|
|
49
|
+
fx-case{
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
41
53
|
fx-model, fx-model *, fx-model ::slotted(fx-instance), fx-instance{
|
|
42
54
|
display:none;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
fx-control, fx-trigger{
|
|
46
58
|
white-space: nowrap;
|
|
47
|
-
position: relative;
|
|
59
|
+
/* position: relative; */
|
|
48
60
|
}
|
|
49
61
|
.fx-checkbox{
|
|
50
62
|
white-space: nowrap;
|
|
@@ -68,45 +80,6 @@ fx-repeatitem{
|
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
/* fx-inspector styles */
|
|
71
|
-
fx-inspector{
|
|
72
|
-
position:fixed;
|
|
73
|
-
left:0;
|
|
74
|
-
right:0;
|
|
75
|
-
bottom:0;
|
|
76
|
-
width: 100%;
|
|
77
|
-
background: var(--inspector-bg);
|
|
78
|
-
color: white;
|
|
79
|
-
max-height: 33%;
|
|
80
|
-
overflow: scroll;
|
|
81
|
-
border-top:3px solid black;
|
|
82
|
-
opacity: 0.9;
|
|
83
|
-
}
|
|
84
|
-
fx-inspector::before{
|
|
85
|
-
content:'Instance Inspector';
|
|
86
|
-
font-style:italic;
|
|
87
|
-
position:absolute;
|
|
88
|
-
top:0;
|
|
89
|
-
right: 0.3rem;
|
|
90
|
-
z-index: 10;
|
|
91
|
-
font-size: 0.8rem;
|
|
92
|
-
}
|
|
93
|
-
fx-inspector details{
|
|
94
|
-
padding: 1rem;
|
|
95
|
-
}
|
|
96
|
-
fx-inspector pre{
|
|
97
|
-
background: var(--inspector-pre-bg);
|
|
98
|
-
border-radius: 0.5rem;
|
|
99
|
-
padding: 0.3rem;
|
|
100
|
-
max-height: var(--inspector-instance-height);
|
|
101
|
-
/*overflow: scroll;*/
|
|
102
|
-
}
|
|
103
|
-
fx-inspector details{
|
|
104
|
-
overflow: auto;
|
|
105
|
-
margin:0;
|
|
106
|
-
}
|
|
107
|
-
fx-inspector summary{
|
|
108
|
-
padding: 0;
|
|
109
|
-
}
|
|
110
83
|
|
|
111
84
|
/* ### FX-DIALOG STYLES ### */
|
|
112
85
|
/* ### FX-DIALOG STYLES ### */
|
|
@@ -203,11 +176,11 @@ fx-dialog .action{
|
|
|
203
176
|
animation: none;
|
|
204
177
|
opacity: 1;
|
|
205
178
|
}
|
|
206
|
-
@keyframes fadein {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
179
|
+
/* @keyframes fadein { */
|
|
180
|
+
/* 0% { */
|
|
181
|
+
/* opacity:0; */
|
|
182
|
+
/* } */
|
|
183
|
+
/* 100% { */
|
|
184
|
+
/* opacity:1; */
|
|
185
|
+
/* } */
|
|
186
|
+
/* } */
|
|
@@ -45,15 +45,6 @@ export class DependencyNotifyingDomFacade {
|
|
|
45
45
|
* @param bucket - The bucket that matches the attribute that will be used.
|
|
46
46
|
*/
|
|
47
47
|
// eslint-disable-next-line class-methods-use-this
|
|
48
|
-
/*
|
|
49
|
-
getChildNodes(node, bucket) {
|
|
50
|
-
const matchingNodes = Array.from(node.childNodes).filter(
|
|
51
|
-
childNode => !bucket || getBucketsForNode(childNode).includes(bucket),
|
|
52
|
-
);
|
|
53
|
-
return matchingNodes;
|
|
54
|
-
}
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
48
|
getChildNodes(node, bucket) {
|
|
58
49
|
const matchingNodes = Array.from(node.childNodes).filter(
|
|
59
50
|
childNode => !bucket || getBucketsForNode(childNode).includes(bucket),
|
|
@@ -87,7 +78,7 @@ export class DependencyNotifyingDomFacade {
|
|
|
87
78
|
getFirstChild(node, bucket) {
|
|
88
79
|
for (const child of node.childNodes) {
|
|
89
80
|
if (!bucket || getBucketsForNode(child).includes(bucket)) {
|
|
90
|
-
this._onNodeTouched(
|
|
81
|
+
this._onNodeTouched(child);
|
|
91
82
|
return child;
|
|
92
83
|
}
|
|
93
84
|
}
|
|
@@ -122,12 +113,13 @@ export class DependencyNotifyingDomFacade {
|
|
|
122
113
|
*/
|
|
123
114
|
// eslint-disable-next-line class-methods-use-this
|
|
124
115
|
getNextSibling(node, bucket) {
|
|
125
|
-
for (let
|
|
126
|
-
if (!getBucketsForNode(
|
|
116
|
+
for (let sibling = node.nextSibling; sibling; sibling = sibling.nextSibling) {
|
|
117
|
+
if (!getBucketsForNode(sibling).includes(bucket)) {
|
|
127
118
|
// eslint-disable-next-line no-continue
|
|
128
119
|
continue;
|
|
129
120
|
}
|
|
130
|
-
|
|
121
|
+
this._onNodeTouched(sibling);
|
|
122
|
+
return sibling;
|
|
131
123
|
}
|
|
132
124
|
return null;
|
|
133
125
|
}
|
package/src/ForeElementMixin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { XPathUtil } from './xpath-util.js';
|
|
2
2
|
import { FxModel } from './fx-model.js';
|
|
3
|
+
import { Fore } from './fore.js';
|
|
3
4
|
import {
|
|
4
5
|
evaluateXPath,
|
|
5
6
|
evaluateXPathToFirstNode,
|
|
@@ -58,7 +59,7 @@ export const foreElementMixin = superclass =>
|
|
|
58
59
|
this.model = null;
|
|
59
60
|
this.modelItem = {};
|
|
60
61
|
this.ref = this.hasAttribute('ref') ? this.getAttribute('ref') : '';
|
|
61
|
-
this.inScopeVariables =
|
|
62
|
+
this.inScopeVariables = new Map();
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
getModel() {
|
|
@@ -100,17 +101,19 @@ export const foreElementMixin = superclass =>
|
|
|
100
101
|
evalInContext() {
|
|
101
102
|
// const inscopeContext = this.getInScopeContext();
|
|
102
103
|
let inscopeContext;
|
|
103
|
-
if(this.hasAttribute('context')){
|
|
104
|
+
if (this.hasAttribute('context')) {
|
|
104
105
|
inscopeContext = getInScopeContext(this.getAttributeNode('context') || this, this.context);
|
|
105
106
|
}
|
|
106
|
-
if(this.hasAttribute('ref')){
|
|
107
|
+
if (this.hasAttribute('ref')) {
|
|
107
108
|
inscopeContext = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
|
|
108
109
|
}
|
|
109
|
-
if (!inscopeContext) {
|
|
110
|
+
if (!inscopeContext && this.getModel().instances.length !== 0) {
|
|
110
111
|
// ### always fall back to default context with there's neither a 'context' or 'ref' present
|
|
111
|
-
inscopeContext = this.getModel()
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
inscopeContext = this.getModel()
|
|
113
|
+
.getDefaultInstance()
|
|
114
|
+
.getDefaultContext();
|
|
115
|
+
// console.warn('no in scopeContext for ', this);
|
|
116
|
+
// console.warn('using default context ', this);
|
|
114
117
|
// return;
|
|
115
118
|
}
|
|
116
119
|
if (this.ref === '') {
|
|
@@ -134,7 +137,7 @@ export const foreElementMixin = superclass =>
|
|
|
134
137
|
if (nodeType) {
|
|
135
138
|
this.nodeset = evaluateXPathToFirstNode(this.ref, inscopeContext, this);
|
|
136
139
|
} else {
|
|
137
|
-
this.nodeset = evaluateXPath(this.ref, inscopeContext, this);
|
|
140
|
+
[this.nodeset] = evaluateXPath(this.ref, inscopeContext, this);
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
// console.log('UiElement evaluated to nodeset: ', this.nodeset);
|
|
@@ -153,7 +156,7 @@ export const foreElementMixin = superclass =>
|
|
|
153
156
|
return this.getAttribute('ref');
|
|
154
157
|
}
|
|
155
158
|
// try to get closest parent bind
|
|
156
|
-
const parent =
|
|
159
|
+
const parent = Fore.getClosest('[ref]', this.parentNode);
|
|
157
160
|
if (!parent) {
|
|
158
161
|
return 'instance()'; // the default instance
|
|
159
162
|
}
|
|
@@ -192,10 +195,10 @@ export const foreElementMixin = superclass =>
|
|
|
192
195
|
this.modelItem = mi;
|
|
193
196
|
}
|
|
194
197
|
|
|
195
|
-
const repeated =
|
|
198
|
+
const repeated = Fore.getClosest('fx-repeatitem', this);
|
|
196
199
|
let existed;
|
|
197
200
|
if (repeated) {
|
|
198
|
-
const { index } =
|
|
201
|
+
const { index } = repeated;
|
|
199
202
|
if (Array.isArray(this.nodeset)) {
|
|
200
203
|
existed = this.getModel().getModelItem(this.nodeset[index - 1]);
|
|
201
204
|
} else {
|
|
@@ -225,7 +228,7 @@ export const foreElementMixin = superclass =>
|
|
|
225
228
|
return evaluateXPathToString(valAttr, inscopeContext, this.getOwnerForm());
|
|
226
229
|
} catch (error) {
|
|
227
230
|
console.error(error);
|
|
228
|
-
|
|
231
|
+
Fore.dispatch(this, 'error', { message: error });
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
if (this.textContent) {
|
|
@@ -241,14 +244,4 @@ export const foreElementMixin = superclass =>
|
|
|
241
244
|
setInScopeVariables(inScopeVariables) {
|
|
242
245
|
this.inScopeVariables = inScopeVariables;
|
|
243
246
|
}
|
|
244
|
-
|
|
245
|
-
dispatch(eventName, detail) {
|
|
246
|
-
const event = new CustomEvent(eventName, {
|
|
247
|
-
composed: true,
|
|
248
|
-
bubbles: true,
|
|
249
|
-
detail,
|
|
250
|
-
});
|
|
251
|
-
// console.log('firing', event);
|
|
252
|
-
this.dispatchEvent(event);
|
|
253
|
-
}
|
|
254
247
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { foreElementMixin } from '../ForeElementMixin.js';
|
|
2
|
-
import { evaluateXPathToBoolean } from '../xpath-evaluation.js';
|
|
2
|
+
import { evaluateXPathToBoolean, resolveId } from '../xpath-evaluation.js';
|
|
3
|
+
import getInScopeContext from '../getInScopeContext.js';
|
|
4
|
+
import { Fore } from '../fore.js';
|
|
3
5
|
|
|
4
6
|
async function wait(howLong) {
|
|
5
7
|
return new Promise(resolve => setTimeout(() => resolve(), howLong));
|
|
@@ -86,7 +88,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
86
88
|
} else if (this.target === '#document') {
|
|
87
89
|
document.addEventListener(this.event, e => this.execute(e));
|
|
88
90
|
} else {
|
|
89
|
-
this.targetElement =
|
|
91
|
+
this.targetElement = resolveId(this.target, this);
|
|
90
92
|
this.targetElement.addEventListener(this.event, e => this.execute(e));
|
|
91
93
|
}
|
|
92
94
|
} else {
|
|
@@ -112,19 +114,40 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
112
114
|
* @param e
|
|
113
115
|
*/
|
|
114
116
|
async execute(e) {
|
|
115
|
-
console.log('executing', this);
|
|
117
|
+
// console.log('executing', this);
|
|
118
|
+
// console.log('executing e', e);
|
|
119
|
+
// console.log('executing e phase', e.eventPhase);
|
|
120
|
+
if(e && e.code){
|
|
121
|
+
const vars = new Map();
|
|
122
|
+
vars.set('code',e.code);
|
|
123
|
+
// this.setInScopeVariables(vars);
|
|
124
|
+
this.setInScopeVariables(new Map([...vars, ...this.inScopeVariables]));
|
|
125
|
+
}
|
|
126
|
+
|
|
116
127
|
if (e && e.detail) {
|
|
117
128
|
this.detail = e.detail;
|
|
129
|
+
const vars = new Map();
|
|
130
|
+
Object.keys(e.detail).forEach(function(key,index) {
|
|
131
|
+
// key: the name of the object key
|
|
132
|
+
// index: the ordinal position of the key within the object
|
|
133
|
+
vars.set(key,e.detail[key]);
|
|
134
|
+
});
|
|
135
|
+
console.log("event detail vars", vars);
|
|
136
|
+
this.setInScopeVariables(new Map([...vars, ...this.inScopeVariables]));
|
|
118
137
|
}
|
|
119
138
|
this.needsUpdate = false;
|
|
120
139
|
|
|
121
|
-
|
|
140
|
+
try{
|
|
141
|
+
this.evalInContext();
|
|
142
|
+
}catch (error){
|
|
143
|
+
console.warn('evaluation faild',error);
|
|
144
|
+
}
|
|
122
145
|
if (this.targetElement && this.targetElement.nodeset) {
|
|
123
146
|
this.nodeset = this.targetElement.nodeset;
|
|
124
147
|
}
|
|
125
148
|
|
|
126
149
|
// First check if 'if' condition is true - otherwise exist right away
|
|
127
|
-
if (this.ifExpr && !evaluateXPathToBoolean(this.ifExpr, this
|
|
150
|
+
if (this.ifExpr && !evaluateXPathToBoolean(this.ifExpr, getInScopeContext(this), this)) {
|
|
128
151
|
return;
|
|
129
152
|
}
|
|
130
153
|
|
|
@@ -139,7 +162,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
139
162
|
return;
|
|
140
163
|
}
|
|
141
164
|
|
|
142
|
-
if (!evaluateXPathToBoolean(this.whileExpr, this
|
|
165
|
+
if (!evaluateXPathToBoolean(this.whileExpr, getInScopeContext(this), this)) {
|
|
143
166
|
// Done with iterating
|
|
144
167
|
return;
|
|
145
168
|
}
|
|
@@ -154,6 +177,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
154
177
|
// After loop is done call actionPerformed to update the model and UI
|
|
155
178
|
await loop();
|
|
156
179
|
this.actionPerformed();
|
|
180
|
+
Fore.dispatch(this, 'while-performed', {});
|
|
157
181
|
return;
|
|
158
182
|
}
|
|
159
183
|
|
|
@@ -204,10 +228,10 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
204
228
|
*/
|
|
205
229
|
dispatchActionPerformed() {
|
|
206
230
|
console.log('action-performed ', this);
|
|
207
|
-
|
|
208
|
-
new CustomEvent('action-performed', { composed: true, bubbles: true, detail: {} }),
|
|
209
|
-
);
|
|
231
|
+
Fore.dispatch(this, 'action-performed', {});
|
|
210
232
|
}
|
|
211
233
|
}
|
|
212
234
|
|
|
213
|
-
|
|
235
|
+
if (!customElements.get('abstract-action')) {
|
|
236
|
+
window.customElements.define('abstract-action', AbstractAction);
|
|
237
|
+
}
|
package/src/actions/fx-action.js
CHANGED
|
@@ -32,6 +32,7 @@ export class FxAction extends AbstractAction {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
perform() {
|
|
35
|
+
super.perform();
|
|
35
36
|
const { children } = this;
|
|
36
37
|
|
|
37
38
|
if (this.src) {
|
|
@@ -47,14 +48,15 @@ export class FxAction extends AbstractAction {
|
|
|
47
48
|
}
|
|
48
49
|
const action = actionOrVar;
|
|
49
50
|
action.detail = this.detail;
|
|
50
|
-
|
|
51
|
-
action.execute();
|
|
51
|
+
action.perform();
|
|
52
|
+
// action.execute();
|
|
52
53
|
});
|
|
53
54
|
this.dispatchActionPerformed();
|
|
54
|
-
|
|
55
|
+
this.needsUpdate = true;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
if (!customElements.get('fx-action')) {
|
|
61
|
+
window.customElements.define('fx-action', FxAction);
|
|
62
|
+
}
|
package/src/actions/fx-append.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
import { Fore } from '../fore.js';
|
|
3
|
+
import { resolveId } from '../xpath-evaluation.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* `fx-append` appends an entry to a repeat.
|
|
@@ -77,7 +78,7 @@ class FxAppend extends AbstractAction {
|
|
|
77
78
|
super.actionPerformed();
|
|
78
79
|
// const repeat = document.getElementById(this.repeat);
|
|
79
80
|
// repeat.setIndex(repeat.nodeset.length);
|
|
80
|
-
this.
|
|
81
|
+
this._dispatch();
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
/**
|
|
@@ -117,22 +118,10 @@ class FxAppend extends AbstractAction {
|
|
|
117
118
|
*
|
|
118
119
|
* The target repeat is a child of the same repeat-item as the append action.
|
|
119
120
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (Fore.isRepeated(this)) {
|
|
123
|
-
console.log('append repeated ', this.repeatContext);
|
|
124
|
-
targetRepeat = Fore.getRepeatTarget(this, this.repeat);
|
|
125
|
-
} else {
|
|
126
|
-
targetRepeat = document.getElementById(this.repeat);
|
|
127
|
-
}
|
|
121
|
+
_dispatch() {
|
|
122
|
+
const targetRepeat = resolveId(this.repeat, this);
|
|
128
123
|
console.log('dispatching index change ', targetRepeat.nodeset.length);
|
|
129
|
-
targetRepeat.
|
|
130
|
-
new CustomEvent('index-changed', {
|
|
131
|
-
composed: true,
|
|
132
|
-
bubbles: true,
|
|
133
|
-
detail: { index: targetRepeat.nodeset.length },
|
|
134
|
-
}),
|
|
135
|
-
);
|
|
124
|
+
Fore.dispatch(targetRepeat, 'index-changed', { index: targetRepeat.nodeset.length });
|
|
136
125
|
}
|
|
137
126
|
|
|
138
127
|
/**
|
|
@@ -213,4 +202,6 @@ class FxAppend extends AbstractAction {
|
|
|
213
202
|
*/
|
|
214
203
|
}
|
|
215
204
|
|
|
216
|
-
|
|
205
|
+
if (!customElements.get('fx-append')) {
|
|
206
|
+
window.customElements.define('fx-append', FxAppend);
|
|
207
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {AbstractAction} from "./abstract-action";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* `fx-confirm`
|
|
@@ -7,7 +7,7 @@ import { FxAction } from './fx-action.js';
|
|
|
7
7
|
* @customElement
|
|
8
8
|
* @demo demo/project.html
|
|
9
9
|
*/
|
|
10
|
-
export class FxConfirm extends
|
|
10
|
+
export class FxConfirm extends AbstractAction {
|
|
11
11
|
connectedCallback() {
|
|
12
12
|
this.message = this.hasAttribute('message') ? this.getAttribute('message') : null;
|
|
13
13
|
}
|
|
@@ -19,4 +19,6 @@ export class FxConfirm extends FxAction {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
if (!customElements.get('fx-confirm')) {
|
|
23
|
+
window.customElements.define('fx-confirm', FxConfirm);
|
|
24
|
+
}
|
package/src/actions/fx-delete.js
CHANGED
|
@@ -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-delete`
|
|
@@ -29,13 +30,13 @@ class FxDelete extends AbstractAction {
|
|
|
29
30
|
// ### if there's no repeat the delete action is inside of a repeat template
|
|
30
31
|
if (this.repeatId === '') {
|
|
31
32
|
// find the index to delete
|
|
32
|
-
const rItem =
|
|
33
|
+
const rItem = Fore.getClosest('fx-repeatitem', this.parentNode);
|
|
33
34
|
const idx = Array.from(rItem.parentNode.children).indexOf(rItem) + 1;
|
|
34
35
|
// console.log('>>> idx to delete ', idx);
|
|
35
36
|
|
|
36
37
|
// ### get the model now as it'll be hard once we've deleted ourselves ;)
|
|
37
38
|
this.model = this.getModel();
|
|
38
|
-
const repeat =
|
|
39
|
+
const repeat = Fore.getClosest('fx-repeat', this.parentNode);
|
|
39
40
|
|
|
40
41
|
// ### update the nodeset
|
|
41
42
|
let nodeToDelete;
|
|
@@ -77,4 +78,6 @@ class FxDelete extends AbstractAction {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
if (!customElements.get('fx-delete')) {
|
|
82
|
+
window.customElements.define('fx-delete', FxDelete);
|
|
83
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractAction } from './abstract-action.js';
|
|
2
2
|
import { evaluateXPath, resolveId } from '../xpath-evaluation.js';
|
|
3
|
-
import { XPathUtil } from '../xpath-util.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* `fx-dispatch`
|
|
@@ -68,7 +67,8 @@ export class FxDispatch extends AbstractAction {
|
|
|
68
67
|
if (value) {
|
|
69
68
|
throw new Error('if "expr" is given there must not be a "value" attribute');
|
|
70
69
|
}
|
|
71
|
-
const result = evaluateXPath(expr, this.getInScopeContext(), this.getOwnerForm());
|
|
70
|
+
const [result] = evaluateXPath(expr, this.getInScopeContext(), this.getOwnerForm());
|
|
71
|
+
|
|
72
72
|
let serialized = null;
|
|
73
73
|
if (result.nodeName) {
|
|
74
74
|
const serializer = new XMLSerializer();
|
|
@@ -90,11 +90,10 @@ export class FxDispatch extends AbstractAction {
|
|
|
90
90
|
|
|
91
91
|
// ### when targetid is given dispatch to that if present (throw an error if not) - otherwise dispatch to document
|
|
92
92
|
if (this.targetid) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
target
|
|
97
|
-
} else {
|
|
93
|
+
let target = resolveId(this.targetid, this.parentNode, null);
|
|
94
|
+
if (!target) {
|
|
95
|
+
// TODO: essentially, we want to highly prefer the closest target. in the same subcontrol.
|
|
96
|
+
// However, it may be that our target is elsewhere. Do a global search for that case
|
|
98
97
|
target = document.getElementById(this.targetid);
|
|
99
98
|
}
|
|
100
99
|
console.log('target', target);
|
|
@@ -120,4 +119,6 @@ export class FxDispatch extends AbstractAction {
|
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
|
|
122
|
+
if (!customElements.get('fx-dispatch')) {
|
|
123
|
+
window.customElements.define('fx-dispatch', FxDispatch);
|
|
124
|
+
}
|