@jinntec/fore 1.4.0 → 1.6.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 (71) hide show
  1. package/dist/fore-dev.js +2 -36
  2. package/dist/fore-dev.js.map +1 -1
  3. package/dist/fore.js +2 -30
  4. package/dist/fore.js.map +1 -1
  5. package/index.js +13 -0
  6. package/package.json +9 -5
  7. package/resources/fore.css +178 -92
  8. package/src/DependencyNotifyingDomFacade.js +1 -2
  9. package/src/ForeElementMixin.js +31 -5
  10. package/src/actions/abstract-action.js +379 -270
  11. package/src/actions/fx-action.js +0 -1
  12. package/src/actions/fx-append.js +1 -2
  13. package/src/actions/fx-confirm.js +12 -0
  14. package/src/actions/fx-copy.js +0 -1
  15. package/src/actions/fx-delete.js +31 -9
  16. package/src/actions/fx-dispatch.js +19 -5
  17. package/src/actions/fx-hide.js +19 -0
  18. package/src/actions/fx-insert.js +72 -8
  19. package/src/actions/fx-load.js +253 -0
  20. package/src/actions/fx-message.js +22 -7
  21. package/src/actions/fx-refresh.js +11 -1
  22. package/src/actions/fx-reload.js +12 -2
  23. package/src/actions/fx-replace.js +5 -4
  24. package/src/actions/fx-reset.js +48 -0
  25. package/src/actions/fx-return.js +0 -1
  26. package/src/actions/fx-send.js +40 -2
  27. package/src/actions/fx-setfocus.js +25 -7
  28. package/src/actions/fx-setvalue.js +32 -4
  29. package/src/actions/fx-show.js +14 -2
  30. package/src/actions/fx-toggle.js +0 -1
  31. package/src/actions/fx-update.js +9 -0
  32. package/src/events.js +0 -1
  33. package/src/fore.js +119 -63
  34. package/src/functions/common-function.js +28 -0
  35. package/src/fx-bind.js +7 -7
  36. package/src/fx-fore.js +207 -54
  37. package/src/fx-instance.js +55 -17
  38. package/src/fx-model.js +31 -33
  39. package/src/fx-submission.js +50 -47
  40. package/src/getInScopeContext.js +22 -8
  41. package/src/lab/fore-component.js +90 -0
  42. package/src/lab/instance-inspector.js +56 -0
  43. package/src/lab/template.html +16 -0
  44. package/src/relevance.js +27 -1
  45. package/src/tools/adi.js +1056 -0
  46. package/src/tools/fx-action-log.js +662 -0
  47. package/src/tools/fx-devtools.js +444 -0
  48. package/src/tools/fx-dom-inspector.js +609 -0
  49. package/src/tools/fx-json-instance.js +435 -0
  50. package/src/tools/fx-log-item.js +133 -0
  51. package/src/tools/fx-log-settings.js +474 -0
  52. package/src/tools/fx-minimap.js +194 -0
  53. package/src/tools/helpers.js +132 -0
  54. package/src/ui/abstract-control.js +41 -3
  55. package/src/ui/fx-action-log.js +358 -0
  56. package/src/ui/fx-alert.js +0 -1
  57. package/src/ui/fx-container.js +14 -3
  58. package/src/ui/fx-control.js +553 -474
  59. package/src/ui/fx-dialog.js +2 -0
  60. package/src/ui/fx-dom-inspector.js +1255 -0
  61. package/src/ui/fx-group.js +3 -4
  62. package/src/ui/fx-hint.js +2 -4
  63. package/src/ui/fx-inspector.js +5 -6
  64. package/src/ui/fx-items.js +55 -14
  65. package/src/ui/fx-output.js +36 -17
  66. package/src/ui/fx-repeat-attributes.js +409 -0
  67. package/src/ui/fx-repeat.js +12 -6
  68. package/src/ui/fx-switch.js +14 -3
  69. package/src/ui/fx-trigger.js +13 -1
  70. package/src/xpath-evaluation.js +109 -26
  71. package/src/xpath-util.js +55 -1
@@ -0,0 +1,90 @@
1
+ /**
2
+ * a simple component that wraps a Fore page and puts it into shadowDom.
3
+ *
4
+ * HTML link elements passed as children will be used to construct a CSSStyleSheet that is passed
5
+ * to the shadowDOM.
6
+ * @customElement
7
+ */
8
+ export class ForeComponent extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.attachShadow({mode: 'open'})
12
+ this.src = ''
13
+ }
14
+
15
+ connectedCallback() {
16
+ this.src= this.getAttribute('src');
17
+ const style = `
18
+ :host {
19
+ display:block;
20
+ }
21
+ `;
22
+ const html = `
23
+ <fx-fore src="${this.src}">
24
+ </fx-fore>
25
+ <slot id="default"></slot>
26
+ `;
27
+
28
+ this.shadowRoot.innerHTML = `
29
+ <style>
30
+ ${style}
31
+ </style>
32
+ ${html}
33
+ `;
34
+
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]
50
+ .map((rule) => rule.cssText)
51
+ .join('');
52
+ } catch (e) {
53
+ console.log('Access to stylesheet %s is denied. Ignoring…', styleSheet.href);
54
+ }
55
+ }
56
+ })
57
+ .filter(Boolean)
58
+ .join('\n');
59
+
60
+ const sheet = new CSSStyleSheet();
61
+ sheet.replaceSync(allCSS);
62
+ this.shadowRoot.adoptedStyleSheets = [sheet];
63
+ });
64
+
65
+ /*
66
+ const eventSlot = this.shadowRoot.querySelector('slot[name="event"]');
67
+ eventSlot.addEventListener('slotchange', async event => {
68
+ const children = event.target.assignedElements();
69
+ console.log('events', children)
70
+ });
71
+ */
72
+ const eventTmpl = this.querySelector('fx-action');
73
+ if(eventTmpl){
74
+ // const clone = eventTmpl.content.cloneNode(true);
75
+ const clone = eventTmpl.cloneNode(true);
76
+ this.removeChild(eventTmpl);
77
+ // const content = document.importNode(clone, true);
78
+
79
+ const fore = this.shadowRoot.querySelector('fx-fore');
80
+ // fore.appendChild(content.firstElementChild);
81
+ fore.appendChild(clone);
82
+ }
83
+
84
+ }
85
+
86
+ }
87
+
88
+ if (!customElements.get('fore-component')) {
89
+ customElements.define('fore-component', ForeComponent);
90
+ }
@@ -0,0 +1,56 @@
1
+ import '../../index.js';
2
+ // import '@jinntec/jinn-codemirror/src/jinn-code-mirror.js';
3
+
4
+ /**
5
+ * a simple component that wraps a Fore page and puts it into shadowDom.
6
+ *
7
+ * HTML link elements passed as children will be used to construct a CSSStyleSheet that is passed
8
+ * to the shadowDOM.
9
+ * @customElement
10
+ */
11
+ export class InstanceInspector extends HTMLElement {
12
+ constructor() {
13
+ super();
14
+ this.attachShadow({mode: 'open'})
15
+ }
16
+
17
+ connectedCallback() {
18
+ this.id= this.getAttribute('id');
19
+ const style = `
20
+ :host {
21
+ display:block;
22
+ background:blue;
23
+ }
24
+ section, fx-control, jinn-codemirror{
25
+ display:block;
26
+ width:100%;
27
+ height:100%;
28
+ }
29
+ `;
30
+ const html = `
31
+ <section>
32
+ <fx-control ref="instance('${this.id}')" as="node">
33
+ <label>${this.id}</label>
34
+ <jinn-codemirror mode="xml" class="widget"></jinn-codemirror>
35
+ </fx-control>
36
+ </section>
37
+ <slot></slot>
38
+ `;
39
+
40
+ this.innerHTML = `
41
+ <style>
42
+ ${style}
43
+ </style>
44
+ ${html}
45
+ `;
46
+
47
+
48
+ this.closest('fx-fore').refresh();
49
+
50
+ }
51
+
52
+ }
53
+
54
+ if (!customElements.get('instance-inspector')) {
55
+ customElements.define('instance-inspector', InstanceInspector);
56
+ }
@@ -0,0 +1,16 @@
1
+ <fx-fore>
2
+ <fx-message event="ready">hey from component</fx-message>
3
+ <fx-model>
4
+ <fx-instance>
5
+ <data>
6
+ <greeting>Hello Universe</greeting>
7
+ </data>
8
+ </fx-instance>
9
+ </fx-model>
10
+
11
+ <div class="static {greeting}">Greeting: {greeting}</div>
12
+ <fx-control ref="greeting" update-event="input">
13
+ <label>Hey!</label>
14
+ </fx-control>
15
+ <!-- <slot></slot>-->
16
+ </fx-fore>
package/src/relevance.js CHANGED
@@ -38,6 +38,19 @@ export class Relevance {
38
38
  const { attributes } = n;
39
39
  if (attributes) {
40
40
  Array.from(attributes).forEach(attr => {
41
+ if (element.nonrelevant === 'empty' && !Relevance._isRelevant(element, attr)) {
42
+ clone.setAttribute(attr.nodeName, '');
43
+ }else
44
+ if (Relevance._isRelevant(element, attr)) {
45
+ clone.setAttribute(attr.nodeName, attr.value);
46
+ } else {
47
+ // if (element.nonrelevant === 'empty') {
48
+ // clone.setAttribute(attr.nodeName, '');
49
+ // } else{
50
+ clone.removeAttribute(attr.nodeName);
51
+ // }
52
+ }
53
+ /*
41
54
  if (Relevance._isRelevant(element, attr)) {
42
55
  clone.setAttribute(attr.nodeName, attr.value);
43
56
  } else if (element.nonrelevant === 'empty') {
@@ -45,6 +58,7 @@ export class Relevance {
45
58
  } else {
46
59
  clone.removeAttribute(attr.nodeName);
47
60
  }
61
+ */
48
62
  });
49
63
  }
50
64
  return Relevance._filterRelevant(element, n, clone);
@@ -56,9 +70,21 @@ export class Relevance {
56
70
 
57
71
  static _isRelevant(element, node) {
58
72
  const mi = element.getModel().getModelItem(node);
59
- if (!mi || mi.relevant) {
73
+
74
+ // ### remove empty attributes as these usually are not expected in most XML languages.
75
+ if(node.nodeType === Node.ATTRIBUTE_NODE
76
+ && node.nodeValue === ''){
77
+ return false;
78
+ }
79
+ // ### no modelItem means no constraints
80
+ if(!mi){
60
81
  return true;
61
82
  }
83
+ // ### modelItem 'relevant' is defined and 'true'
84
+ if ( mi.relevant) {
85
+ return true;
86
+ }
87
+
62
88
  return false;
63
89
  }
64
90
  }