@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
@@ -1,8 +1,8 @@
1
1
  // import { FxAction } from './fx-action.js';
2
2
  import '../fx-model.js';
3
- import {AbstractAction} from './abstract-action.js';
4
- import {evaluateXPath} from '../xpath-evaluation.js';
5
- import {Fore} from '../fore.js';
3
+ import { AbstractAction } from './abstract-action.js';
4
+ import { evaluateXPath } from '../xpath-evaluation.js';
5
+ import { Fore } from '../fore.js';
6
6
 
7
7
  /**
8
8
  * `fx-setvalue`
@@ -10,98 +10,102 @@ import {Fore} from '../fore.js';
10
10
  * @customElement
11
11
  */
12
12
  export default class FxSetvalue extends AbstractAction {
13
- static get properties() {
14
- return {
15
- ...super.properties,
16
- ref: {
17
- type: String,
18
- },
19
- valueAttr: {
20
- type: String,
21
- },
22
- };
23
- }
13
+ static get properties() {
14
+ return {
15
+ ...super.properties,
16
+ ref: {
17
+ type: String,
18
+ },
19
+ valueAttr: {
20
+ type: String,
21
+ },
22
+ };
23
+ }
24
24
 
25
- constructor() {
26
- super();
27
- this.ref = '';
28
- this.valueAttr = '';
29
- }
25
+ constructor() {
26
+ super();
27
+ this.ref = '';
28
+ this.valueAttr = '';
29
+ }
30
30
 
31
- connectedCallback() {
32
- if (super.connectedCallback) {
33
- super.connectedCallback();
34
- }
35
-
36
- if (this.hasAttribute('ref')) {
37
- this.ref = this.getAttribute('ref');
38
- } else {
39
- throw new Error('fx-setvalue must specify a "ref" attribute');
40
- }
41
- this.valueAttr = this.getAttribute('value');
31
+ connectedCallback() {
32
+ if (super.connectedCallback) {
33
+ super.connectedCallback();
42
34
  }
43
35
 
44
- async perform() {
45
- super.perform();
46
- let {value} = this;
47
- if (this.valueAttr !== null) {
48
- [value] = evaluateXPath(this.valueAttr, this.nodeset, this, this.detail);
49
- } else if (this.textContent !== '') {
50
- value = this.textContent;
51
- } else {
52
- value = '';
53
- }
54
- if (value?.nodeType && value.nodeType === Node.ATTRIBUTE_NODE) {
55
- value = value.nodeValue;
56
- }
57
- const mi = this.getModelItem();
58
- this.setValue(mi, value);
59
- // todo: check this again - logically needsUpate should be set but makes tests fail
60
- // this.needsUpdate = true;
36
+ if (this.hasAttribute('ref')) {
37
+ this.ref = this.getAttribute('ref');
38
+ } else {
39
+ throw new Error('fx-setvalue must specify a "ref" attribute');
40
+ }
41
+ this.valueAttr = this.getAttribute('value');
42
+ }
61
43
 
44
+ async perform() {
45
+ super.perform();
46
+ let { value } = this;
47
+ if (this.valueAttr !== null) {
48
+ [value] = evaluateXPath(this.valueAttr, this.nodeset, this, this.detail);
49
+ } else if (this.textContent !== '') {
50
+ value = this.textContent;
51
+ } else {
52
+ value = '';
62
53
  }
54
+ if (value?.nodeType && value.nodeType === Node.ATTRIBUTE_NODE) {
55
+ value = value.nodeValue;
56
+ }
57
+ const mi = this.getModelItem();
58
+ this.setValue(mi, value);
59
+ // todo: check this again - logically needsUpate should be set but makes tests fail
60
+ // this.needsUpdate = true;
61
+ }
63
62
 
64
- /**
65
- * need to overwrite default dispatchExecute to do it ourselves. This is necessary for tracking control value changes
66
- * which call setvalue directly without perform().
67
- */
68
- dispatchExecute() {}
63
+ /**
64
+ * need to overwrite default dispatchExecute to do it ourselves. This is necessary for tracking control value changes
65
+ * which call setvalue directly without perform().
66
+ */
67
+ dispatchExecute() {}
69
68
 
70
- setValue(modelItem, newVal) {
71
- const item = modelItem;
72
- if (!item) return;
69
+ setValue(modelItem, newVal) {
70
+ const item = modelItem;
71
+ if (!item) return;
73
72
 
74
- if (item.value !== newVal) {
75
- // const path = XPathUtil.getPath(modelItem.node);
76
- const path = Fore.getDomNodeIndexString(modelItem.node)
73
+ if (item.value !== newVal) {
74
+ // const path = XPathUtil.getPath(modelItem.node);
75
+ const path = Fore.getDomNodeIndexString(modelItem.node);
77
76
 
78
- const ev = this.event;
79
- const targetElem = this;
80
- this.dispatchEvent(
81
- new CustomEvent('execute-action', {
82
- composed: true,
83
- bubbles: true,
84
- cancelable:true,
85
- detail: { action: targetElem, event:ev, value:newVal, path:path},
86
- }),
87
- );
77
+ const ev = this.event;
78
+ const targetElem = this;
79
+ this.dispatchEvent(
80
+ new CustomEvent('execute-action', {
81
+ composed: true,
82
+ bubbles: true,
83
+ cancelable: true,
84
+ detail: {
85
+ action: targetElem,
86
+ event: ev,
87
+ value: newVal,
88
+ path,
89
+ },
90
+ }),
91
+ );
88
92
 
89
- if(newVal?.nodeType){
90
- if(newVal.nodeType === Node.ELEMENT_NODE){
91
- item.value = newVal.textContent;
92
- }
93
- if(newVal.nodeType === Node.ATTRIBUTE_NODE){
94
- item.value = newVal.getValue()
95
- }
96
- }else{
97
- item.value = newVal;
98
- }
99
- this.getModel().changed.push(modelItem);
100
- this.needsUpdate = true;
93
+ if (newVal?.nodeType) {
94
+ if (newVal.nodeType === Node.ELEMENT_NODE) {
95
+ item.value = newVal.textContent;
96
+ }
97
+ if (newVal.nodeType === Node.ATTRIBUTE_NODE) {
98
+ item.value = newVal.getValue();
101
99
  }
100
+ } else {
101
+ item.value = newVal;
102
+ }
103
+ this.getModel().changed.push(modelItem);
104
+ this.needsUpdate = true;
102
105
  }
106
+ }
103
107
  }
104
108
 
105
109
  if (!customElements.get('fx-setvalue')) {
106
- window.customElements.define('fx-setvalue', FxSetvalue);
110
+ window.customElements.define('fx-setvalue', FxSetvalue);
107
111
  }
@@ -12,7 +12,7 @@ import { resolveId } from '../xpath-evaluation.js';
12
12
  export class FxShow extends FxAction {
13
13
  connectedCallback() {
14
14
  if (super.connectedCallback) {
15
- super.connectedCallback();
15
+ super.connectedCallback();
16
16
  }
17
17
  this.dialog = this.getAttribute('dialog');
18
18
  if (!this.dialog) {
@@ -22,20 +22,20 @@ export class FxShow extends FxAction {
22
22
 
23
23
  async perform() {
24
24
  this.dispatchEvent(
25
- new CustomEvent('execute-action', {
26
- composed: true,
27
- bubbles: true,
28
- cancelable:true,
29
- detail: { action: this, event:this.event},
30
- }),
25
+ new CustomEvent('execute-action', {
26
+ composed: true,
27
+ bubbles: true,
28
+ cancelable: true,
29
+ detail: { action: this, event: this.event },
30
+ }),
31
31
  );
32
32
 
33
- const targetDlg = resolveId(this.dialog,this);
34
- if(!targetDlg){
35
- console.error('target dialog with given id does not exist',this.dialog);
33
+ const targetDlg = resolveId(this.dialog, this);
34
+ if (!targetDlg) {
35
+ console.error('target dialog with given id does not exist', this.dialog);
36
36
  }
37
37
  targetDlg.open();
38
- Fore.dispatch(targetDlg,'dialog-shown',{});
38
+ Fore.dispatch(targetDlg, 'dialog-shown', {});
39
39
  }
40
40
  }
41
41
 
@@ -1,5 +1,5 @@
1
1
  import { AbstractAction } from './abstract-action.js';
2
- import {Fore} from "../fore";
2
+ import { Fore } from '../fore';
3
3
 
4
4
  /**
5
5
  * `fx-toggle`
@@ -25,7 +25,7 @@ class FxToggle extends AbstractAction {
25
25
  const ownerForm = this.getOwnerForm();
26
26
  // todo: id resolution!!!
27
27
  const caseElement = ownerForm.querySelector(`#${this.case}`);
28
- if(!caseElement){
28
+ if (!caseElement) {
29
29
  Fore.dispatch(this, 'error', { message: `fx-case id not found: ${this.case}` });
30
30
  return;
31
31
  }
@@ -1,8 +1,8 @@
1
1
  // import { FxAction } from './fx-action.js';
2
2
  import '../fx-model.js';
3
- import {AbstractAction} from './abstract-action.js';
4
- import {evaluateXPath} from '../xpath-evaluation.js';
5
- import {Fore} from '../fore.js';
3
+ import { AbstractAction } from './abstract-action.js';
4
+ import { evaluateXPath } from '../xpath-evaluation.js';
5
+ import { Fore } from '../fore.js';
6
6
 
7
7
  /**
8
8
  * `fx-setvalue`
@@ -10,49 +10,48 @@ import {Fore} from '../fore.js';
10
10
  * @customElement
11
11
  */
12
12
  export default class FxToggleboolean extends AbstractAction {
13
- static get properties() {
14
- return {
15
- ...super.properties,
16
- ref: {
17
- type: String,
18
- },
19
- valueAttr: {
20
- type: String,
21
- },
22
- value:{
23
- type: Boolean
24
- }
25
- };
26
- }
27
-
28
- constructor() {
29
- super();
30
- this.ref = '';
31
- this.valueAttr = '';
32
- this.value = false;
33
- }
13
+ static get properties() {
14
+ return {
15
+ ...super.properties,
16
+ ref: {
17
+ type: String,
18
+ },
19
+ valueAttr: {
20
+ type: String,
21
+ },
22
+ value: {
23
+ type: Boolean,
24
+ },
25
+ };
26
+ }
34
27
 
35
- connectedCallback() {
36
- if (super.connectedCallback) {
37
- super.connectedCallback();
38
- }
28
+ constructor() {
29
+ super();
30
+ this.ref = '';
31
+ this.valueAttr = '';
32
+ this.value = false;
33
+ }
39
34
 
40
- if (this.hasAttribute('ref')) {
41
- this.ref = this.getAttribute('ref');
42
- } else {
43
- throw new Error('fx-togglealue must specify a "ref" attribute');
44
- }
35
+ connectedCallback() {
36
+ if (super.connectedCallback) {
37
+ super.connectedCallback();
45
38
  }
46
39
 
47
- async perform() {
48
- super.perform();
49
- const mi = this.getModelItem();
50
- mi.value === 'true' ? mi.node.textContent='false' : mi.node.textContent='true';
51
- this.needsUpdate = true;
40
+ if (this.hasAttribute('ref')) {
41
+ this.ref = this.getAttribute('ref');
42
+ } else {
43
+ throw new Error('fx-togglealue must specify a "ref" attribute');
52
44
  }
45
+ }
53
46
 
47
+ async perform() {
48
+ super.perform();
49
+ const mi = this.getModelItem();
50
+ mi.value === 'true' ? (mi.node.textContent = 'false') : (mi.node.textContent = 'true');
51
+ this.needsUpdate = true;
52
+ }
54
53
  }
55
54
 
56
55
  if (!customElements.get('fx-toggleboolean')) {
57
- window.customElements.define('fx-toggleboolean', FxToggleboolean);
56
+ window.customElements.define('fx-toggleboolean', FxToggleboolean);
58
57
  }
@@ -0,0 +1,27 @@
1
+ import { AbstractAction } from './abstract-action.js';
2
+
3
+ /**
4
+ * `fx-unmodified` Action to reset the 'modified' state of Fore. A Fore page is considered
5
+ * modified when a 'value-changed' event has occurred. If the respective Fore element uses
6
+ * `show-confirmation="true"` it will display a page exit confirmation in case the data
7
+ * are modified. The `fx-unmodified` action allows to return to 'clean' state again avoiding
8
+ * the dialog box after data have been saved and are considered unmodified again.
9
+ *
10
+ * Typically this action could be called on a `submit-done` event of a submission.
11
+ *
12
+ *
13
+ * @customElement
14
+ */
15
+ export default class FxUnmodified extends AbstractAction {
16
+ constructor() {
17
+ super();
18
+ }
19
+
20
+ async perform() {
21
+ this.getOwnerForm().markAsClean();
22
+ }
23
+ }
24
+
25
+ if (!customElements.get('fx-unmodified')) {
26
+ window.customElements.define('fx-unmodified', FxUnmodified);
27
+ }
@@ -9,12 +9,12 @@ import { AbstractAction } from './abstract-action.js';
9
9
  class FxUpdate extends AbstractAction {
10
10
  async perform() {
11
11
  this.dispatchEvent(
12
- new CustomEvent('execute-action', {
13
- composed: true,
14
- bubbles: true,
15
- cancelable:true,
16
- detail: { action: this, event:this.event},
17
- }),
12
+ new CustomEvent('execute-action', {
13
+ composed: true,
14
+ bubbles: true,
15
+ cancelable: true,
16
+ detail: { action: this, event: this.event },
17
+ }),
18
18
  );
19
19
 
20
20
  this.getModel().updateModel();
package/src/dep_graph.js CHANGED
@@ -50,7 +50,7 @@ Object.setPrototypeOf(DepGraphCycleError, Error);
50
50
  function createDFS(edges, leavesOnly, result, circular) {
51
51
  const visited = {};
52
52
  // eslint-disable-next-line func-names
53
- return function(start) {
53
+ return function (start) {
54
54
  // console.log('start ', start);
55
55
  if (visited[start]) {
56
56
  return;
package/src/drawdown.js CHANGED
@@ -32,9 +32,7 @@ function markdown(src) {
32
32
  }
33
33
 
34
34
  function blockquote(src) {
35
- return src.replace(rx_blockquote, (all, content) =>
36
- element('blockquote', blockquote(highlight(content.replace(/^ *> */gm, '')))),
37
- );
35
+ return src.replace(rx_blockquote, (all, content) => element('blockquote', blockquote(highlight(content.replace(/^ *> */gm, '')))));
38
36
  }
39
37
 
40
38
  function list(src) {
@@ -52,10 +50,10 @@ function markdown(src) {
52
50
  return `\n${
53
51
  ol
54
52
  ? `<ol start="${
55
- num
56
- ? `${ol}">`
57
- : `${parseInt(ol, 36) - 9}" style="list-style-type:${low ? 'low' : 'upp'}er-alpha">`
58
- }${entry}</ol>`
53
+ num
54
+ ? `${ol}">`
55
+ : `${parseInt(ol, 36) - 9}" style="list-style-type:${low ? 'low' : 'upp'}er-alpha">`
56
+ }${entry}</ol>`
59
57
  : element('ul', entry)
60
58
  }`;
61
59
  });
@@ -64,24 +62,23 @@ function markdown(src) {
64
62
  function highlight(src) {
65
63
  return src.replace(
66
64
  rx_highlight,
67
- (all, _, p1, emp, sub, sup, small, big, p2, content) =>
68
- _ +
69
- element(
65
+ (all, _, p1, emp, sub, sup, small, big, p2, content) => _
66
+ + element(
70
67
  emp
71
68
  ? p2
72
69
  ? 'strong'
73
70
  : 'em'
74
71
  : sub
75
- ? p2
76
- ? 's'
77
- : 'sub'
78
- : sup
79
- ? 'sup'
80
- : small
81
- ? 'small'
82
- : big
83
- ? 'big'
84
- : 'code',
72
+ ? p2
73
+ ? 's'
74
+ : 'sub'
75
+ : sup
76
+ ? 'sup'
77
+ : small
78
+ ? 'small'
79
+ : big
80
+ ? 'big'
81
+ : 'code',
85
82
  highlight(content),
86
83
  ),
87
84
  );
@@ -131,16 +128,12 @@ function markdown(src) {
131
128
  const sep = table.match(rx_thead)[1];
132
129
  return `\n${element(
133
130
  'table',
134
- table.replace(rx_row, (row, ri) =>
135
- row == sep
136
- ? ''
137
- : element(
138
- 'tr',
139
- row.replace(rx_cell, (all, cell, ci) =>
140
- ci ? element(sep && !ri ? 'th' : 'td', unesc(highlight(cell || ''))) : '',
141
- ),
142
- ),
143
- ),
131
+ table.replace(rx_row, (row, ri) => (row == sep
132
+ ? ''
133
+ : element(
134
+ 'tr',
135
+ row.replace(rx_cell, (all, cell, ci) => (ci ? element(sep && !ri ? 'th' : 'td', unesc(highlight(cell || ''))) : '')),
136
+ ))),
144
137
  )}`;
145
138
  });
146
139
 
package/src/events.js CHANGED
@@ -1,23 +1,23 @@
1
- export function leadingDebounce(caller, func, timeout = 300){
2
- let timer;
3
- return (...args) => {
4
- if (!timer) {
5
- func.apply(caller, args);
6
- }
7
- clearTimeout(timer);
8
- timer = setTimeout(() => {
9
- timer = undefined;
10
- return null;
11
- }, timeout);
12
- };
1
+ export function leadingDebounce(caller, func, timeout = 300) {
2
+ let timer;
3
+ return (...args) => {
4
+ if (!timer) {
5
+ func.apply(caller, args);
6
+ }
7
+ clearTimeout(timer);
8
+ timer = setTimeout(() => {
9
+ timer = undefined;
10
+ return null;
11
+ }, timeout);
12
+ };
13
13
  }
14
14
 
15
15
  export function debounce(caller, func, timeout = 300) {
16
- let timer;
17
- return (...args) => {
18
- clearTimeout(timer);
19
- timer = setTimeout(() => {
20
- func.apply(caller, args);
21
- }, timeout);
22
- };
16
+ let timer;
17
+ return (...args) => {
18
+ clearTimeout(timer);
19
+ timer = setTimeout(() => {
20
+ func.apply(caller, args);
21
+ }, timeout);
22
+ };
23
23
  }