@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.
Files changed (88) hide show
  1. package/README.md +2 -2
  2. package/dist/fore-dev.js +2 -2
  3. package/dist/fore-dev.js.map +1 -1
  4. package/dist/fore.js +2 -2
  5. package/dist/fore.js.map +1 -1
  6. package/index.js +4 -2
  7. package/package.json +10 -38
  8. package/resources/fore.css +263 -262
  9. package/resources/vars.css +8 -0
  10. package/src/DependencyNotifyingDomFacade.js +1 -0
  11. package/src/ForeElementMixin.js +243 -228
  12. package/src/actions/abstract-action.js +407 -398
  13. package/src/actions/fx-action.js +6 -6
  14. package/src/actions/fx-append.js +1 -1
  15. package/src/actions/fx-call.js +63 -62
  16. package/src/actions/fx-confirm.js +11 -11
  17. package/src/actions/fx-construct-done.js +4 -4
  18. package/src/actions/fx-copy.js +36 -36
  19. package/src/actions/fx-delete.js +77 -79
  20. package/src/actions/fx-dispatch.js +14 -14
  21. package/src/actions/fx-hide.js +15 -15
  22. package/src/actions/fx-insert.js +9 -12
  23. package/src/actions/fx-insertchild.js +88 -0
  24. package/src/actions/fx-load.js +188 -185
  25. package/src/actions/fx-message.js +18 -19
  26. package/src/actions/fx-refresh.js +10 -10
  27. package/src/actions/fx-reload.js +16 -14
  28. package/src/actions/fx-replace.js +0 -1
  29. package/src/actions/fx-reset.js +31 -31
  30. package/src/actions/fx-send.js +59 -52
  31. package/src/actions/fx-setattribute.js +48 -49
  32. package/src/actions/fx-setfocus.js +54 -58
  33. package/src/actions/fx-setvalue.js +85 -81
  34. package/src/actions/fx-show.js +11 -11
  35. package/src/actions/fx-toggle.js +2 -2
  36. package/src/actions/fx-toggleboolean.js +38 -39
  37. package/src/actions/fx-unmodified.js +27 -0
  38. package/src/actions/fx-update.js +6 -6
  39. package/src/dep_graph.js +1 -1
  40. package/src/drawdown.js +23 -30
  41. package/src/events.js +19 -19
  42. package/src/fore.js +143 -125
  43. package/src/functions/common-function.js +24 -25
  44. package/src/functions/fx-function.js +6 -99
  45. package/src/functions/fx-functionlib.js +56 -0
  46. package/src/functions/registerFunction.js +112 -0
  47. package/src/fx-bind.js +19 -24
  48. package/src/fx-connection.js +226 -0
  49. package/src/fx-fore.js +844 -815
  50. package/src/fx-header.js +4 -4
  51. package/src/fx-instance.js +25 -29
  52. package/src/fx-model.js +405 -380
  53. package/src/fx-submission.js +399 -397
  54. package/src/fx-var.js +13 -12
  55. package/src/getInScopeContext.js +102 -89
  56. package/src/json-util.js +24 -24
  57. package/src/lab/fore-component.js +48 -52
  58. package/src/lab/instance-inspector.js +13 -16
  59. package/src/modelitem.js +48 -10
  60. package/src/relevance.js +12 -16
  61. package/src/tools/adi.js +858 -812
  62. package/src/tools/fx-action-log.js +377 -295
  63. package/src/tools/fx-devtools.js +210 -210
  64. package/src/tools/fx-dom-inspector.js +123 -122
  65. package/src/tools/fx-json-instance.js +262 -253
  66. package/src/tools/fx-log-item.js +6 -11
  67. package/src/tools/fx-log-settings.js +358 -301
  68. package/src/tools/fx-minimap.js +186 -177
  69. package/src/tools/helpers.js +1 -1
  70. package/src/ui/abstract-control.js +73 -53
  71. package/src/ui/fx-case.js +59 -7
  72. package/src/ui/fx-container.js +13 -14
  73. package/src/ui/fx-control.js +572 -538
  74. package/src/ui/fx-dialog.js +3 -3
  75. package/src/ui/fx-droptarget.js +3 -4
  76. package/src/ui/fx-group.js +4 -2
  77. package/src/ui/fx-hint.js +3 -0
  78. package/src/ui/fx-inspector.js +5 -5
  79. package/src/ui/fx-items.js +11 -11
  80. package/src/ui/fx-output.js +10 -12
  81. package/src/ui/fx-repeat-attributes.js +23 -27
  82. package/src/ui/fx-repeat.js +347 -344
  83. package/src/ui/fx-repeatitem.js +75 -68
  84. package/src/ui/fx-switch.js +39 -14
  85. package/src/ui/fx-trigger.js +4 -4
  86. package/src/withDraggability.js +193 -191
  87. package/src/xpath-evaluation.js +969 -958
  88. package/src/xpath-util.js +161 -134
@@ -40,7 +40,6 @@ export default class FxReplace extends AbstractAction {
40
40
  const target = evaluateXPathToFirstNode(this.with, this.nodeset, this);
41
41
  if (!target) return;
42
42
 
43
-
44
43
  this.replace(this.nodeset, target);
45
44
  }
46
45
 
@@ -1,5 +1,5 @@
1
- import {Fore} from '../fore.js';
2
- import {AbstractAction} from './abstract-action.js';
1
+ import { Fore } from '../fore.js';
2
+ import { AbstractAction } from './abstract-action.js';
3
3
 
4
4
  /**
5
5
  * `fx-reset`
@@ -9,40 +9,40 @@ import {AbstractAction} from './abstract-action.js';
9
9
  * @demo demo/project.html
10
10
  */
11
11
  export class FxReset extends AbstractAction {
12
- static get properties() {
13
- return {
14
- ...super.properties,
15
- instance: {
16
- type: String,
17
- },
18
- };
19
- }
12
+ static get properties() {
13
+ return {
14
+ ...super.properties,
15
+ instance: {
16
+ type: String,
17
+ },
18
+ };
19
+ }
20
20
 
21
- connectedCallback() {
22
- super.connectedCallback();
23
- this.instance = this.getAttribute('instance');
24
- if (!this.instance) {
25
- Fore.dispatch(this, 'error', {message: 'instance does not exist'});
26
- }
21
+ connectedCallback() {
22
+ super.connectedCallback();
23
+ this.instance = this.getAttribute('instance');
24
+ if (!this.instance) {
25
+ Fore.dispatch(this, 'error', { message: 'instance does not exist' });
27
26
  }
27
+ }
28
28
 
29
- async perform() {
30
- this.dispatchEvent(
31
- new CustomEvent('execute-action', {
32
- composed: true,
33
- bubbles: true,
34
- cancelable: true,
35
- detail: {action: this, event: this.event},
36
- }),
37
- );
29
+ async perform() {
30
+ this.dispatchEvent(
31
+ new CustomEvent('execute-action', {
32
+ composed: true,
33
+ bubbles: true,
34
+ cancelable: true,
35
+ detail: { action: this, event: this.event },
36
+ }),
37
+ );
38
38
 
39
- const model = this.getModel();
40
- const data = model.getInstance(this.instance);
41
- data.reset();
42
- this.needsUpdate = true;
43
- }
39
+ const model = this.getModel();
40
+ const data = model.getInstance(this.instance);
41
+ data.reset();
42
+ this.needsUpdate = true;
43
+ }
44
44
  }
45
45
 
46
46
  if (!customElements.get('fx-reset')) {
47
- window.customElements.define('fx-reset', FxReset);
47
+ window.customElements.define('fx-reset', FxReset);
48
48
  }
@@ -1,12 +1,10 @@
1
1
  import '../fx-model.js';
2
2
  import '../fx-submission.js';
3
3
  import { AbstractAction } from './abstract-action.js';
4
- import {XPathUtil} from "../xpath-util.js";
4
+ import { XPathUtil } from '../xpath-util.js';
5
5
 
6
6
  /**
7
- * `fx-send` - finds and activates a `fx-submission` element.
8
- *
9
- * extension idea: allow params to be passed as with dispatch action which can be used to set properties on submission attributes
7
+ * `fx-send` - finds and activates a `fx-submission` or a `fx-connection` element.
10
8
  *
11
9
  * @customElement
12
10
  */
@@ -15,7 +13,7 @@ class FxSend extends AbstractAction {
15
13
  super();
16
14
  this.value = '';
17
15
  this.url = null;
18
- this.target=null;
16
+ this.target = null;
19
17
  }
20
18
 
21
19
  connectedCallback() {
@@ -23,79 +21,88 @@ class FxSend extends AbstractAction {
23
21
  super.connectedCallback();
24
22
  // console.log('connectedCallback ', this);
25
23
  this.submission = this.getAttribute('submission');
26
- this.url = this.hasAttribute('url') ? this.getAttribute('url'):null;
27
- this.target = this.hasAttribute('target') ? this.getAttribute('target'):null;
24
+ this.url = this.hasAttribute('url') ? this.getAttribute('url') : null;
25
+ this.target = this.hasAttribute('target') ? this.getAttribute('target') : null;
26
+ this.connection = this.hasAttribute('connection') ? this.getAttribute('connection') : null;
28
27
  }
29
28
 
30
29
  async perform() {
31
30
  super.perform();
32
31
 
33
- console.log('submitting ', this.submission);
34
32
  // reset CSS class that signalled validation error during last submit
35
33
  this.getOwnerForm().classList.remove('submit-validation-failed');
36
- // console.log('submitting model', this.getModel());
37
34
 
38
- // if not exists signal error
39
- // todo: instead of relying on model just use pure dom to find submission as the context could be broken due to a delete action
40
- // const fore = this.closest('fx-fore');
41
- // const submission = fore.querySelector(`#${this.submission}`);
35
+ if (this.connection) {
36
+ const connectionElement = this.getModel().querySelector(`#${this.connection}`);
37
+ if (connectionElement === null) {
38
+ this.dispatchEvent(
39
+ new CustomEvent('error', {
40
+ composed: false,
41
+ bubbles: true,
42
+ cancelable: true,
43
+ detail: {
44
+ id: this.id,
45
+ origin: this,
46
+ message: `<fx-connection id="${this.connection}"> not found`,
47
+ expr: XPathUtil.getDocPath(this),
48
+ level: 'Error',
49
+ },
50
+ }),
51
+ );
52
+ return;
53
+ }
54
+ this._emitToChannel();
55
+ return;
56
+ }
57
+
42
58
  const submission = this.getModel().querySelector(`#${this.submission}`);
43
59
  if (submission === null) {
44
- /*
45
60
  this.dispatchEvent(
46
61
  new CustomEvent('error', {
47
- composed: true,
62
+ composed: false,
48
63
  bubbles: true,
49
- detail: { message: `fx-submission element with id: '${this.submission}' not found - ${XPathUtil.getDocPath(this)}` },
64
+ cancelable: true,
65
+ detail: {
66
+ id: this.id,
67
+ origin: this,
68
+ message: `<fx-submission id="${this.submission}"> not found`,
69
+ expr: XPathUtil.getDocPath(this),
70
+ level: 'Error',
71
+ },
50
72
  }),
51
73
  );
52
- */
53
- this.dispatchEvent(
54
- new CustomEvent('error', {
55
- composed: false,
56
- bubbles: true,
57
- cancelable:true,
58
- detail: { id:this.id,
59
- origin: this,
60
- message: `<fx-submission id="${this.submission}"> not found`,
61
- expr:XPathUtil.getDocPath(this),
62
- level:'Error'},
63
- }),
64
- );
65
74
  return;
66
75
 
67
76
  // throw new Error(`submission with id: ${this.submission} not found`);
68
77
  }
78
+ // console.log('submission', submission);
69
79
 
70
- if(this.url){
71
- const resolved = this.evaluateAttributeTemplateExpression(this.url,this);
72
- submission.parameters.set('url',resolved);
80
+ if (this.url) {
81
+ const resolved = this.evaluateAttributeTemplateExpression(this.url, this);
82
+ submission.parameters.set('url', resolved);
73
83
  }
74
- if(this.target){
75
- const resolved = this.evaluateAttributeTemplateExpression(this.target,this);
76
- submission.parameters.set('target',resolved);
84
+ if (this.target) {
85
+ const resolved = this.evaluateAttributeTemplateExpression(this.target, this);
86
+ submission.parameters.set('target', resolved);
77
87
  }
78
88
 
79
-
80
- /*
81
- Array.from(this.attributes).forEach( attr => {
82
- if(attr.nodeName !== 'submission'){
83
- const resolved = this.evaluateAttributeTemplateExpression(attr,this);
84
- submission.parameters.set(attr.nodeName,resolved);
85
- }
86
- });
87
- */
88
-
89
- console.log('submission', submission);
90
89
  await submission.submit();
91
- /*
92
- if(submission.replace === 'instance'){
93
- this.getModel().updateModel();
94
- this.getOwnerForm().refresh();
95
- }
96
- */
90
+ /*
91
+ if(submission.replace === 'instance'){
92
+ this.getModel().updateModel();
93
+ this.getOwnerForm().refresh();
94
+ }
95
+ */
97
96
  // if not of type fx-submission signal error
98
97
  }
98
+
99
+ _emitToChannel() {
100
+ const channel = this.getModel().querySelector(`#${this.connection}`);
101
+ if (channel === null) {
102
+ return;
103
+ }
104
+ channel.send();
105
+ }
99
106
  }
100
107
 
101
108
  if (!customElements.get('fx-send')) {
@@ -1,9 +1,9 @@
1
1
  // import { FxAction } from './fx-action.js';
2
2
  import '../fx-model.js';
3
- import {AbstractAction} from './abstract-action.js';
4
- import {evaluateXPathToString} from '../xpath-evaluation.js';
5
- import {Fore} from '../fore.js';
6
- import getInScopeContext from "../getInScopeContext";
3
+ import { AbstractAction } from './abstract-action.js';
4
+ import { evaluateXPathToString } from '../xpath-evaluation.js';
5
+ import { Fore } from '../fore.js';
6
+ import getInScopeContext from '../getInScopeContext';
7
7
 
8
8
  /**
9
9
  * `fx-setattribute` allows to create and set an attribute value in the data.
@@ -11,58 +11,57 @@ import getInScopeContext from "../getInScopeContext";
11
11
  * @customElement
12
12
  */
13
13
  export default class FxSetattribute extends AbstractAction {
14
- static get properties() {
15
- return {
16
- ...super.properties,
17
- ref: {
18
- type: String,
19
- },
20
- attrName: {
21
- type: String,
22
- },
23
- attrValue:{
24
- type: String
25
- }
26
- };
27
- }
28
-
29
- constructor() {
30
- super();
31
- this.ref = '';
32
- this.attrName = '';
33
- this.attrValue = '';
34
- }
14
+ static get properties() {
15
+ return {
16
+ ...super.properties,
17
+ ref: {
18
+ type: String,
19
+ },
20
+ attrName: {
21
+ type: String,
22
+ },
23
+ attrValue: {
24
+ type: String,
25
+ },
26
+ };
27
+ }
35
28
 
36
- connectedCallback() {
37
- if (super.connectedCallback) {
38
- super.connectedCallback();
39
- }
29
+ constructor() {
30
+ super();
31
+ this.ref = '';
32
+ this.attrName = '';
33
+ this.attrValue = '';
34
+ }
40
35
 
41
- if (this.hasAttribute('ref')) {
42
- this.ref = this.getAttribute('ref');
43
- } else {
44
- throw new Error('fx-setvalue must specify a "ref" attribute');
45
- }
46
- this.attrName = this.hasAttribute('name') ? this.getAttribute('name') : null;
47
- this.attrValue = this.hasAttribute('value') ? this.getAttribute('value') : '';
48
- if(!this.attrName){
49
- Fore.dispatch('this', 'error',{message:'name or value not specified'});
50
- }
36
+ connectedCallback() {
37
+ if (super.connectedCallback) {
38
+ super.connectedCallback();
51
39
  }
52
40
 
53
- async perform() {
54
- super.perform();
55
- const mi = this.getModelItem();
56
- if(mi.node.nodeType !== Node.ELEMENT_NODE){
57
- Fore.dispatch('this', 'error',{message:'referenced item is not an element'});
58
- return;
59
- }
60
- mi.node.setAttribute(this.attrName, this.attrValue);
61
- this.needsUpdate = true;
41
+ if (this.hasAttribute('ref')) {
42
+ this.ref = this.getAttribute('ref');
43
+ } else {
44
+ throw new Error('fx-setvalue must specify a "ref" attribute');
62
45
  }
46
+ this.attrName = this.hasAttribute('name') ? this.getAttribute('name') : null;
47
+ this.attrValue = this.hasAttribute('value') ? this.getAttribute('value') : '';
48
+ if (!this.attrName) {
49
+ Fore.dispatch('this', 'error', { message: 'name or value not specified' });
50
+ }
51
+ }
63
52
 
53
+ async perform() {
54
+ super.perform();
55
+ const mi = this.getModelItem();
56
+ if (mi.node.nodeType !== Node.ELEMENT_NODE) {
57
+ Fore.dispatch('this', 'error', { message: 'referenced item is not an element' });
58
+ return;
59
+ }
60
+ mi.node.setAttribute(this.attrName, this.attrValue);
61
+ this.needsUpdate = true;
62
+ }
64
63
  }
65
64
 
66
65
  if (!customElements.get('fx-setattribute')) {
67
- window.customElements.define('fx-setattribute', FxSetattribute);
66
+ window.customElements.define('fx-setattribute', FxSetattribute);
68
67
  }
@@ -1,5 +1,5 @@
1
- import {AbstractAction} from "./abstract-action.js";
2
- import {Fore} from "../fore";
1
+ import { AbstractAction } from './abstract-action.js';
2
+ import { Fore } from '../fore';
3
3
 
4
4
  /**
5
5
  * `fx-setfocus`
@@ -9,79 +9,75 @@ import {Fore} from "../fore";
9
9
  */
10
10
  export class FxSetfocus extends AbstractAction {
11
11
  connectedCallback() {
12
- if (super.connectedCallback) {
12
+ if (super.connectedCallback) {
13
13
  super.connectedCallback();
14
- }
15
- this.control = this.hasAttribute('control') ? this.getAttribute('control') : null;
14
+ }
15
+ this.control = this.hasAttribute('control') ? this.getAttribute('control') : null;
16
16
  }
17
17
 
18
18
  async perform() {
19
+ this.dispatchEvent(
20
+ new CustomEvent('execute-action', {
21
+ composed: true,
22
+ bubbles: true,
23
+ cancelable: true,
24
+ detail: { action: this, event: this.event },
25
+ }),
26
+ );
19
27
 
20
- this.dispatchEvent(
21
- new CustomEvent('execute-action', {
22
- composed: true,
23
- bubbles: true,
24
- cancelable: true,
25
- detail: {action: this, event: this.event},
26
- }),
27
- );
28
-
29
- // super.perform();
30
- const selector = '#'+this.control;
28
+ // super.perform();
29
+ const selector = `#${this.control}`;
31
30
 
31
+ let targetElement = document.querySelector(selector);
32
32
 
33
- let targetElement = document.querySelector(selector);
34
-
35
- if(!targetElement) {
36
- Fore.dispatch(this, 'error', {
37
- origin: this,
38
- message: `Instance '${this.control}' not found`,
39
- level:'Error'
40
- });
41
- return;
42
- }
33
+ if (!targetElement) {
34
+ Fore.dispatch(this, 'error', {
35
+ origin: this,
36
+ message: `Instance '${this.control}' not found`,
37
+ level: 'Error',
38
+ });
39
+ return;
40
+ }
43
41
 
44
- // ### focus action is itself hosted within a repeat
45
- const parentIItem = targetElement.closest('fx-repeatitem');
46
- if(parentIItem){
47
- targetElement = parentIItem.querySelector(selector);
48
- this._focus(targetElement);
49
- // return;
50
- }
42
+ // ### focus action is itself hosted within a repeat
43
+ const parentIItem = targetElement.closest('fx-repeatitem');
44
+ if (parentIItem) {
45
+ targetElement = parentIItem.querySelector(selector);
46
+ this._focus(targetElement);
47
+ // return;
48
+ }
51
49
 
52
- // ### the target element is hosted within a repeat
53
- const repeatitem = targetElement.closest('fx-repeatitem, .fx-repeatitem');
54
- if(repeatitem){
55
- // targetElement is repeated
56
- // get the active repeatitem (only for fx-repeat for now - todo: support repeat attributes
57
- const repeat = repeatitem.parentNode;
58
- targetElement = repeat.querySelector('[repeat-index] ' + selector);
59
- }
50
+ // ### the target element is hosted within a repeat
51
+ const repeatitem = targetElement.closest('fx-repeatitem, .fx-repeatitem');
52
+ if (repeatitem) {
53
+ // targetElement is repeated
54
+ // get the active repeatitem (only for fx-repeat for now - todo: support repeat attributes
55
+ const repeat = repeatitem.parentNode;
56
+ targetElement = repeat.querySelector(`[repeat-index] ${selector}`);
57
+ }
60
58
 
61
- this._focus(targetElement);
62
- if(this.hasAttribute('select')){
63
- this._select(targetElement);
64
- }
59
+ this._focus(targetElement);
60
+ if (this.hasAttribute('select')) {
61
+ this._select(targetElement);
62
+ }
65
63
  }
66
64
 
67
- _focus(targetElement){
68
- if(targetElement && typeof targetElement.getWidget === 'function'){
69
- targetElement.getWidget().focus();
70
- }
71
- if(targetElement && targetElement.nodeType === Node.ELEMENT_NODE){
72
- targetElement.click();
73
- }
65
+ _focus(targetElement) {
66
+ if (targetElement && typeof targetElement.getWidget === 'function') {
67
+ targetElement.getWidget().focus();
74
68
  }
75
-
76
- _select(targetElement){
77
- if(targetElement){
78
- targetElement.getWidget().select();
79
- }
69
+ if (targetElement && targetElement.nodeType === Node.ELEMENT_NODE) {
70
+ targetElement.click();
80
71
  }
72
+ }
81
73
 
74
+ _select(targetElement) {
75
+ if (targetElement) {
76
+ targetElement.getWidget().select();
77
+ }
78
+ }
82
79
  }
83
80
 
84
-
85
81
  if (!customElements.get('fx-setfocus')) {
86
82
  window.customElements.define('fx-setfocus', FxSetfocus);
87
83
  }