@jinntec/fore 1.2.0 → 1.4.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 (51) hide show
  1. package/dist/fore-dev.js +8 -8
  2. package/dist/fore-dev.js.map +1 -1
  3. package/dist/fore.js +7 -7
  4. package/dist/fore.js.map +1 -1
  5. package/index.js +1 -0
  6. package/package.json +2 -2
  7. package/resources/fore.css +100 -72
  8. package/src/ForeElementMixin.js +4 -0
  9. package/src/actions/abstract-action.js +102 -18
  10. package/src/actions/fx-action.js +9 -10
  11. package/src/actions/fx-append.js +1 -1
  12. package/src/actions/fx-confirm.js +3 -3
  13. package/src/actions/fx-copy.js +68 -0
  14. package/src/actions/fx-delete.js +53 -62
  15. package/src/actions/fx-dispatch.js +1 -1
  16. package/src/actions/fx-hide.js +4 -2
  17. package/src/actions/fx-insert.js +1 -1
  18. package/src/actions/fx-message.js +26 -2
  19. package/src/actions/fx-refresh.js +2 -2
  20. package/src/actions/fx-reload.js +30 -0
  21. package/src/actions/fx-replace.js +1 -1
  22. package/src/actions/fx-return.js +1 -1
  23. package/src/actions/fx-send.js +13 -3
  24. package/src/actions/fx-setfocus.js +33 -6
  25. package/src/actions/fx-setvalue.js +5 -5
  26. package/src/actions/fx-show.js +2 -1
  27. package/src/actions/fx-toggle.js +6 -1
  28. package/src/actions/fx-update.js +1 -1
  29. package/src/events.js +24 -0
  30. package/src/fore.js +128 -17
  31. package/src/fx-bind.js +6 -1
  32. package/src/fx-fore.js +93 -41
  33. package/src/fx-instance.js +95 -70
  34. package/src/fx-model.js +430 -441
  35. package/src/fx-submission.js +423 -405
  36. package/src/getInScopeContext.js +88 -82
  37. package/src/modelitem.js +5 -3
  38. package/src/relevance.js +1 -1
  39. package/src/ui/abstract-control.js +108 -22
  40. package/src/ui/fx-alert.js +0 -1
  41. package/src/ui/fx-container.js +22 -26
  42. package/src/ui/fx-control.js +84 -34
  43. package/src/ui/fx-group.js +5 -0
  44. package/src/ui/fx-inspector.js +5 -0
  45. package/src/ui/fx-output.js +14 -14
  46. package/src/ui/fx-repeat.js +2 -2
  47. package/src/ui/fx-repeatitem.js +5 -3
  48. package/src/ui/fx-switch.js +20 -8
  49. package/src/ui/fx-trigger.js +26 -19
  50. package/src/xpath-evaluation.js +49 -26
  51. package/src/xpath-util.js +26 -28
package/src/xpath-util.js CHANGED
@@ -1,14 +1,12 @@
1
1
  import * as fx from 'fontoxpath';
2
2
 
3
- /**
4
- * Checks wether the specified path expression is an absolute path.
5
- *
6
- * @param path the path expression.
7
- * @return <code>true</code> if specified path expression is an absolute
8
- * path, otherwise <code>false</code>.
9
- */
10
-
11
3
  export class XPathUtil {
4
+
5
+ /**
6
+ * returns next bound element upwards in tree
7
+ * @param start where to start the search
8
+ * @returns {*|null}
9
+ */
12
10
  static getParentBindingElement(start) {
13
11
  /* if (start.parentNode.host) {
14
12
  const { host } = start.parentNode;
@@ -25,6 +23,13 @@ export class XPathUtil {
25
23
  return null;
26
24
  }
27
25
 
26
+ /**
27
+ * Checks whether the specified path expression is an absolute path.
28
+ *
29
+ * @param path the path expression.
30
+ * @return <code>true</code> if specified path expression is an absolute
31
+ * path, otherwise <code>false</code>.
32
+ */
28
33
  static isAbsolutePath(path) {
29
34
  return path != null && (path.startsWith('/') || path.startsWith('instance('));
30
35
  }
@@ -33,26 +38,6 @@ export class XPathUtil {
33
38
  return ref === '.' || ref === './text()' || ref === 'text()' || ref === '' || ref === null;
34
39
  }
35
40
 
36
- static getDefaultInstance(boundElement) {
37
- // const fore = boundElement.closest('fx-fore');
38
- const fore = XPathUtil.getForeElement(boundElement);
39
- const defaultInstance = fore.querySelector('fx-instance');
40
- if (!defaultInstance) {
41
- throw new Error('no default instance present');
42
- }
43
- return defaultInstance;
44
- }
45
-
46
- static getForeElement(start) {
47
- if (start.nodeName === 'FX-FORE') {
48
- return start;
49
- }
50
- if (start.parentNode) {
51
- return XPathUtil.getForeElement(start.parentNode);
52
- }
53
- throw new Error('no Fore element present');
54
- }
55
-
56
41
  /**
57
42
  * returns the instance id from a complete XPath using `instance()` function.
58
43
  *
@@ -76,6 +61,19 @@ export class XPathUtil {
76
61
  return null;
77
62
  }
78
63
 
64
+ static resolveInstance(boundElement){
65
+ const instanceId = XPathUtil.getInstanceId(boundElement.getAttribute('ref'));
66
+ if(instanceId !== null){
67
+ return instanceId;
68
+ }
69
+
70
+ const parentBinding = XPathUtil.getParentBindingElement(boundElement);
71
+ if(parentBinding){
72
+ return this.resolveInstance(parentBinding);
73
+ }
74
+ return 'default';
75
+ }
76
+
79
77
  // todo: certainly not ideal to rely on duplicating instance id on instance document - better way later ;)
80
78
  static getPath(node) {
81
79
  const path = fx.evaluateXPathToString('path()', node);