@jinntec/fore 1.0.0 → 1.1.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 +1 -1
- package/dist/fore-dev.js +8 -8
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +7 -7
- package/dist/fore.js.map +1 -1
- package/index.js +1 -0
- package/package.json +5 -3
- package/resources/fore.css +5 -0
- package/src/ForeElementMixin.js +1 -1
- package/src/actions/abstract-action.js +14 -1
- package/src/actions/fx-confirm.js +2 -2
- package/src/actions/fx-refresh.js +4 -0
- package/src/actions/fx-replace.js +8 -3
- package/src/actions/fx-setfocus.js +37 -0
- package/src/actions/fx-show.js +5 -1
- package/src/fore.js +2 -1
- package/src/functions/fx-function.js +6 -0
- package/src/fx-fore.js +587 -590
- package/src/fx-model.js +32 -4
- package/src/fx-submission.js +40 -8
- package/src/relevance.js +1 -2
- package/src/ui/abstract-control.js +10 -3
- package/src/ui/fx-case.js +1 -2
- package/src/ui/fx-control.js +36 -11
- package/src/ui/fx-inspector.js +9 -6
- package/src/ui/fx-output.js +2 -0
- package/src/ui/fx-switch.js +2 -2
- package/src/xpath-evaluation.js +609 -554
- package/src/xpath-util.js +1 -1
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';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jinntec/fore",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Fore -
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Fore - declarative user interfaces in plain HTML",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -90,7 +90,9 @@
|
|
|
90
90
|
"XQuery",
|
|
91
91
|
"form",
|
|
92
92
|
"xforms",
|
|
93
|
-
"html form"
|
|
93
|
+
"html form",
|
|
94
|
+
"declarative",
|
|
95
|
+
"user interface"
|
|
94
96
|
],
|
|
95
97
|
"author": "Joern Turner",
|
|
96
98
|
"license": "MIT",
|
package/resources/fore.css
CHANGED
|
@@ -45,6 +45,11 @@ fx-alert{
|
|
|
45
45
|
font-size: 0.9rem;
|
|
46
46
|
}
|
|
47
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
|
+
|
|
48
53
|
fx-model, fx-model *, fx-model ::slotted(fx-instance), fx-instance{
|
|
49
54
|
display:none;
|
|
50
55
|
}
|
package/src/ForeElementMixin.js
CHANGED
|
@@ -107,7 +107,7 @@ export const foreElementMixin = superclass =>
|
|
|
107
107
|
if (this.hasAttribute('ref')) {
|
|
108
108
|
inscopeContext = getInScopeContext(this.getAttributeNode('ref') || this, this.ref);
|
|
109
109
|
}
|
|
110
|
-
if (!inscopeContext) {
|
|
110
|
+
if (!inscopeContext && this.getModel().instances.length !== 0) {
|
|
111
111
|
// ### always fall back to default context with there's neither a 'context' or 'ref' present
|
|
112
112
|
inscopeContext = this.getModel()
|
|
113
113
|
.getDefaultInstance()
|
|
@@ -117,9 +117,22 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
117
117
|
// console.log('executing', this);
|
|
118
118
|
// console.log('executing e', e);
|
|
119
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
|
+
}
|
|
125
|
+
|
|
120
126
|
if (e && e.detail) {
|
|
121
127
|
this.detail = e.detail;
|
|
122
|
-
|
|
128
|
+
const vars = new Map();
|
|
129
|
+
Object.keys(e.detail).forEach(function(key,index) {
|
|
130
|
+
// key: the name of the object key
|
|
131
|
+
// index: the ordinal position of the key within the object
|
|
132
|
+
vars.set(key,e.detail[key]);
|
|
133
|
+
});
|
|
134
|
+
console.log("event detail vars", vars);
|
|
135
|
+
this.setInScopeVariables(vars);
|
|
123
136
|
}
|
|
124
137
|
this.needsUpdate = false;
|
|
125
138
|
|
|
@@ -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
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import '../fx-model.js';
|
|
3
3
|
import { AbstractAction } from './abstract-action.js';
|
|
4
4
|
import { evaluateXPathToFirstNode } from '../xpath-evaluation.js';
|
|
5
|
+
import getInScopeContext from "../getInScopeContext";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* `fx-replace` - replaces the node referred to with 'ref' with node referred to with 'with' attribute.
|
|
@@ -34,12 +35,14 @@ export default class FxReplace extends AbstractAction {
|
|
|
34
35
|
perform() {
|
|
35
36
|
super.perform();
|
|
36
37
|
console.log('replace action');
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// console.log('replace action variables', this.inScopeVariables);
|
|
39
|
+
// if (!this.nodeset) {
|
|
40
|
+
// return;
|
|
41
|
+
// }
|
|
40
42
|
const target = evaluateXPathToFirstNode(this.with, this.nodeset, this);
|
|
41
43
|
if (!target) return;
|
|
42
44
|
|
|
45
|
+
|
|
43
46
|
this.replace(this.nodeset, target);
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -59,6 +62,8 @@ export default class FxReplace extends AbstractAction {
|
|
|
59
62
|
const cloned = replaceWith.cloneNode(true);
|
|
60
63
|
toReplace.replaceWith(cloned);
|
|
61
64
|
}
|
|
65
|
+
// const modelitem = this.getModelItem();
|
|
66
|
+
// this.getModel().changed.push(modelitem);
|
|
62
67
|
this.needsUpdate = true;
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {AbstractAction} from "./abstract-action";
|
|
2
|
+
import {resolveId} from "../xpath-evaluation";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `fx-setfocus`
|
|
6
|
+
* Set the focus to a target control.
|
|
7
|
+
*
|
|
8
|
+
* @customElement
|
|
9
|
+
*/
|
|
10
|
+
export class FxSetfocus extends AbstractAction {
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
super.connectedCallback();
|
|
13
|
+
this.control = this.hasAttribute('control') ? this.getAttribute('control') : null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
perform() {
|
|
17
|
+
console.log('setting focus', this.control);
|
|
18
|
+
// super.perform();
|
|
19
|
+
|
|
20
|
+
// const targetElement = resolveId(this.control, this);
|
|
21
|
+
const selector = '#'+this.control;
|
|
22
|
+
let targetElement = document.querySelector(selector);
|
|
23
|
+
const repeatitem = targetElement.closest('fx-repeatitem, .fx-repeatitem');
|
|
24
|
+
if(repeatitem){
|
|
25
|
+
// targetElement is repeated
|
|
26
|
+
// get the active repeatitem (only for fx-repeat for now - todo: support repeat attributes
|
|
27
|
+
const repeat = repeatitem.parentNode;
|
|
28
|
+
targetElement = repeat.querySelector('[repeat-index] ' + selector);
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
targetElement.getWidget().focus();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!customElements.get('fx-setfocus')) {
|
|
36
|
+
window.customElements.define('fx-setfocus', FxSetfocus);
|
|
37
|
+
}
|
package/src/actions/fx-show.js
CHANGED
|
@@ -18,7 +18,11 @@ export class FxShow extends FxAction {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
perform() {
|
|
21
|
-
resolveId(this.dialog,
|
|
21
|
+
const targetDlg = resolveId(this.dialog,this);
|
|
22
|
+
if(!targetDlg){
|
|
23
|
+
console.error('target dialog with given id does not exist',this.dialog);
|
|
24
|
+
}
|
|
25
|
+
targetDlg.open();
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
|
package/src/fore.js
CHANGED
|
@@ -131,6 +131,7 @@ export class Fore {
|
|
|
131
131
|
resolve('done');
|
|
132
132
|
}
|
|
133
133
|
if (Fore.isUiElement(element.nodeName) && typeof element.refresh === 'function') {
|
|
134
|
+
// console.log('refreshing', element, element?.ref);
|
|
134
135
|
// console.log('refreshing ',element);
|
|
135
136
|
element.refresh();
|
|
136
137
|
} else if (element.nodeName.toUpperCase() !== 'FX-MODEL') {
|
|
@@ -227,7 +228,7 @@ export class Fore {
|
|
|
227
228
|
bubbles: true,
|
|
228
229
|
detail,
|
|
229
230
|
});
|
|
230
|
-
console.log('
|
|
231
|
+
console.log('dispatching', event);
|
|
231
232
|
target.dispatchEvent(event);
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -83,7 +83,12 @@ export class FxFunction extends foreElementMixin(HTMLElement) {
|
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
case 'text/xquf':
|
|
87
|
+
case 'text/xquery':
|
|
86
88
|
case 'text/xpath': {
|
|
89
|
+
const language = type === 'text/xpath' ?
|
|
90
|
+
'XPath3.1' : type === 'text/xquery' ?
|
|
91
|
+
'XQuery3.1' : 'XQueryUpdate3.1';
|
|
87
92
|
const fun = (domFacade, ...args) =>
|
|
88
93
|
evaluateXPath(
|
|
89
94
|
this.functionBody,
|
|
@@ -93,6 +98,7 @@ export class FxFunction extends foreElementMixin(HTMLElement) {
|
|
|
93
98
|
variablesByName[paramPart.variableName.replace('$', '')] = args[i];
|
|
94
99
|
return variablesByName;
|
|
95
100
|
}, {}),
|
|
101
|
+
{language}
|
|
96
102
|
);
|
|
97
103
|
registerCustomXPathFunction(
|
|
98
104
|
functionIdentifier,
|