@jinntec/fore 1.3.0 → 1.5.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 (44) 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 +1 -1
  7. package/resources/fore.css +6 -1
  8. package/src/ForeElementMixin.js +4 -0
  9. package/src/actions/abstract-action.js +117 -48
  10. package/src/actions/fx-action.js +9 -9
  11. package/src/actions/fx-append.js +1 -1
  12. package/src/actions/fx-confirm.js +1 -1
  13. package/src/actions/fx-copy.js +68 -0
  14. package/src/actions/fx-delete.js +1 -1
  15. package/src/actions/fx-dispatch.js +1 -1
  16. package/src/actions/fx-hide.js +1 -1
  17. package/src/actions/fx-insert.js +1 -1
  18. package/src/actions/fx-message.js +1 -1
  19. package/src/actions/fx-refresh.js +2 -2
  20. package/src/actions/fx-reload.js +1 -1
  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 +2 -2
  24. package/src/actions/fx-setfocus.js +1 -1
  25. package/src/actions/fx-setvalue.js +1 -1
  26. package/src/actions/fx-show.js +1 -1
  27. package/src/actions/fx-toggle.js +1 -1
  28. package/src/actions/fx-update.js +1 -1
  29. package/src/fore.js +59 -10
  30. package/src/fx-bind.js +5 -0
  31. package/src/fx-fore.js +92 -35
  32. package/src/fx-instance.js +70 -70
  33. package/src/fx-model.js +12 -17
  34. package/src/fx-submission.js +420 -416
  35. package/src/getInScopeContext.js +19 -5
  36. package/src/modelitem.js +3 -1
  37. package/src/ui/abstract-control.js +1 -1
  38. package/src/ui/fx-control.js +2 -2
  39. package/src/ui/fx-repeat-attributes.js +442 -0
  40. package/src/ui/fx-repeat.js +8 -0
  41. package/src/ui/fx-switch.js +9 -1
  42. package/src/ui/fx-trigger.js +19 -18
  43. package/src/xpath-evaluation.js +21 -9
  44. package/src/xpath-util.js +13 -28
@@ -47,8 +47,21 @@ const xhtmlNamespaceResolver = prefix => {
47
47
  * Resolve an id in scope. Behaves like the algorithm defined on https://www.w3.org/community/xformsusers/wiki/XForms_2.0#idref-resolve
48
48
  */
49
49
  export function resolveId(id, sourceObject, nodeName = null) {
50
- const allMatchingTargetObjects = fxEvaluateXPathToNodes(
51
- 'outermost(ancestor-or-self::fx-fore[1]/(descendant::fx-fore|descendant::*[@id = $id]))[not(self::fx-fore)]',
50
+ let query = 'outermost(ancestor-or-self::fx-fore[1]/(descendant::fx-fore|descendant::*[@id = $id]))[not(self::fx-fore)]';
51
+ /*
52
+ if (nodeName === 'fx-instance') {
53
+ // Instance elements can only be in the `model` element
54
+ // query = 'ancestor-or-self::fx-fore[1]/fx-model/fx-instance[@id = $id]';
55
+
56
+ const fore = Fore.getFore(sourceObject);
57
+ const instances = fore.getModel().instances;
58
+ const targetInstance = instances.find(i => i.id === id);
59
+ return targetInstance;
60
+ return document.getElementById(id);
61
+ }
62
+ */
63
+
64
+ const allMatchingTargetObjects = fxEvaluateXPathToNodes(query,
52
65
  sourceObject,
53
66
  null,
54
67
  {id},
@@ -749,19 +762,18 @@ const instance = (dynamicContext, string) => {
749
762
  {namespaceResolver: xhtmlNamespaceResolver},
750
763
  );
751
764
 
752
- // console.log('fnInstance dynamicContext: ', dynamicContext);
753
- // console.log('fnInstance string: ', string);
765
+ const inst = string
766
+ ? formElement.querySelector(`#${string}`)
767
+ : formElement.querySelector(`fx-instance`);
754
768
 
769
+ /*
755
770
  const inst = string
756
771
  ? resolveId(string, formElement, 'fx-instance')
757
772
  : formElement.querySelector(`fx-instance`);
773
+ */
758
774
 
759
- // const def = instance.getInstanceData();
760
775
  if (inst) {
761
- const def = inst.getDefaultContext();
762
- // console.log('target instance root node: ', def);
763
-
764
- return def;
776
+ return inst.getDefaultContext();
765
777
  }
766
778
  return null;
767
779
  };
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
  *