@jinntec/fore 2.6.0 → 2.7.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 (53) hide show
  1. package/dist/fore-dev.js +4470 -2643
  2. package/dist/fore.js +4415 -2620
  3. package/index.js +2 -0
  4. package/package.json +10 -4
  5. package/resources/fore.css +2 -6
  6. package/src/DependencyNotifyingDomFacade.js +27 -21
  7. package/src/ForeElementMixin.js +282 -277
  8. package/src/actions/abstract-action.js +7 -12
  9. package/src/actions/fx-append.js +23 -2
  10. package/src/actions/fx-call.js +2 -2
  11. package/src/actions/fx-delete.js +54 -29
  12. package/src/actions/fx-insert.js +23 -15
  13. package/src/actions/fx-refresh.js +15 -5
  14. package/src/actions/fx-replace.js +18 -3
  15. package/src/actions/fx-reset.js +6 -0
  16. package/src/actions/fx-send.js +10 -7
  17. package/src/actions/fx-setattribute.js +12 -0
  18. package/src/actions/fx-setfocus.js +11 -8
  19. package/src/actions/fx-setvalue.js +93 -93
  20. package/src/actions/fx-toggle.js +1 -1
  21. package/src/extract-predicate-deps.js +57 -0
  22. package/src/extractPredicateDependencies.js +36 -0
  23. package/src/fore.js +41 -16
  24. package/src/fx-bind.js +128 -23
  25. package/src/fx-connection.js +24 -7
  26. package/src/fx-fore.js +506 -259
  27. package/src/fx-instance.js +9 -11
  28. package/src/fx-model.js +154 -65
  29. package/src/fx-submission.js +19 -30
  30. package/src/fx-var.js +5 -0
  31. package/src/getInScopeContext.js +7 -8
  32. package/src/modelitem.js +247 -112
  33. package/src/tools/fx-action-log.js +21 -19
  34. package/src/tools/fx-log-settings.js +4 -2
  35. package/src/ui/TemplateExpression.js +12 -0
  36. package/src/ui/UIElement.js +125 -10
  37. package/src/ui/abstract-control.js +5 -0
  38. package/src/ui/fx-case.js +15 -3
  39. package/src/ui/fx-container.js +5 -0
  40. package/src/ui/fx-control-menu.js +23 -14
  41. package/src/ui/fx-control.js +55 -15
  42. package/src/ui/fx-items.js +10 -4
  43. package/src/ui/fx-repeat-attributes.js +111 -35
  44. package/src/ui/fx-repeat.js +332 -85
  45. package/src/ui/fx-repeat.updated.js +821 -0
  46. package/src/ui/fx-repeatitem.js +23 -20
  47. package/src/ui/fx-switch.js +5 -3
  48. package/src/ui/fx-upload.js +36 -40
  49. package/src/ui/repeat-base.js +532 -0
  50. package/src/withDraggability.js +8 -4
  51. package/src/xpath-evaluation.js +26 -8
  52. package/src/xpath-path.js +79 -0
  53. package/src/xpath-util.js +357 -289
package/index.js CHANGED
@@ -67,3 +67,5 @@ import './src/ui/fx-control-menu.js';
67
67
 
68
68
  import './src/functions/fx-function.js';
69
69
  import './src/functions/fx-functionlib.js';
70
+
71
+ export default {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinntec/fore",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Fore - declarative user interfaces in plain HTML",
5
5
  "module": "./index.js",
6
6
  "publishConfig": {
@@ -32,10 +32,12 @@
32
32
  "dependencies": {
33
33
  "@jinntec/jinn-toast": "^1.0.5",
34
34
  "@picocss/pico": "^2.0.6",
35
+ "chai": "^5.2.1",
35
36
  "fontoxpath": "^3.33.0"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@babel/plugin-proposal-class-properties": "^7.17.12",
40
+ "@jinntec/jinn-codemirror": "^1.17.6",
39
41
  "@open-wc/building-rollup": "^2.0.1",
40
42
  "@open-wc/eslint-config": "^7.0.0",
41
43
  "@open-wc/prettier-config": "^0.1.10",
@@ -43,6 +45,7 @@
43
45
  "@open-wc/testing": "^3.1.5",
44
46
  "@open-wc/testing-karma": "^4.0.9",
45
47
  "@open-wc/testing-karma-bs": "^1.3.94",
48
+ "@polymer/iron-iconset": "^3.0.1",
46
49
  "@rollup/plugin-commonjs": "^22.0.0",
47
50
  "@rollup/plugin-node-resolve": "^13.3.0",
48
51
  "@rollup/plugin-strip": "^2.1.0",
@@ -51,7 +54,6 @@
51
54
  "@webcomponents/webcomponentsjs": "^2.6.0",
52
55
  "cypress": "^13.16.0",
53
56
  "deepmerge": "^4.2.2",
54
- "es-dev-server": "^2.1.0",
55
57
  "eslint": "^8.16.0",
56
58
  "eslint-plugin-prettier": "^5.1.3",
57
59
  "husky": "^8.0.1",
@@ -66,12 +68,16 @@
66
68
  "rollup-plugin-babel": "^4.4.0",
67
69
  "rollup-plugin-minify-html-literals": "^1.2.6",
68
70
  "rollup-plugin-version-injector": "^1.3.3",
71
+ "sinon": "^15.2.0",
72
+ "sinon-chai": "^4.0.0",
69
73
  "typescript": "^4.7.2",
74
+ "vite": "^7.0.5",
70
75
  "web-component-analyzer": "^1.1.6",
71
76
  "xmlserializer": "^0.6.1"
72
77
  },
73
78
  "scripts": {
74
79
  "test": "karma start",
80
+ "test:all": "karma start --grep test/**/*.test.js",
75
81
  "lint:eslint": "eslint .",
76
82
  "format:eslint": "eslint . --fix",
77
83
  "lint:prettier": "prettier \"**/*.js\" --check --ignore-path .eslintignore",
@@ -86,11 +92,11 @@
86
92
  "test:bs": "karma start karma.bs.config.js --coverage",
87
93
  "start:build": "cd dist && es-dev-server --open",
88
94
  "build": "rimraf dist && rollup -c rollup.config.js",
89
- "start": "es-dev-server --app-index doc/index.html --node-resolve --watch --open",
95
+ "start": "vite --open --port 8090 --host",
90
96
  "preversion": "npm run test",
91
97
  "prepare": "npm run build",
92
98
  "install-demos": "npm i && cd demo && npm i",
93
- "start-cypress": "es-dev-server --app-index doc/index.html --node-resolve",
99
+ "start-cypress": "npm run start",
94
100
  "websocket-server": "node websocket-server.js"
95
101
  },
96
102
  "keywords": [
@@ -12,10 +12,6 @@
12
12
  --inspector-handle-width: 30px;
13
13
  }
14
14
 
15
- [unresolved] {
16
- display: none;
17
- }
18
-
19
15
  [disabled] {
20
16
  pointer-events: none;
21
17
  cursor: default;
@@ -145,7 +141,7 @@
145
141
  }
146
142
 
147
143
  fx-group, fx-switch, fx-repeat, fx-dialog {
148
- display: block;
144
+ /*display: block;*/
149
145
  position: relative;
150
146
  }
151
147
 
@@ -294,5 +290,5 @@
294
290
  * For on-demand stuff, if it has no value initially,hide it
295
291
  */
296
292
  [on-demand] {
297
- display: none
293
+ display: none !important;
298
294
  }
@@ -24,6 +24,7 @@ export class DependencyNotifyingDomFacade {
24
24
  */
25
25
  // eslint-disable-next-line class-methods-use-this
26
26
  getAllAttributes(node) {
27
+ this._onNodeTouched(node); // <== Important!
27
28
  return Array.from(node.attributes);
28
29
  }
29
30
 
@@ -35,7 +36,10 @@ export class DependencyNotifyingDomFacade {
35
36
  */
36
37
  // eslint-disable-next-line class-methods-use-this
37
38
  getAttribute(node, attributeName) {
38
- return node.getAttribute(attributeName);
39
+ const attr = node.getAttributeNode(attributeName);
40
+ console.log('[DomFacade] getAttribute touched:', attr);
41
+ if (attr) this._onNodeTouched(attr);
42
+ return attr?.value ?? null;
39
43
  }
40
44
 
41
45
  /**
@@ -61,10 +65,12 @@ export class DependencyNotifyingDomFacade {
61
65
  */
62
66
  getData(node) {
63
67
  if (node.nodeType === Node.ATTRIBUTE_NODE) {
68
+ // console.log('[DomFacade] getData on attribute:', node);
64
69
  this._onNodeTouched(node);
65
70
  return node.value;
66
71
  }
67
72
  // Text node
73
+ // console.log('[DomFacade] getData on text node parent:', node.parentNode);
68
74
  this._onNodeTouched(node.parentNode);
69
75
  return node.data;
70
76
  }
@@ -95,14 +101,12 @@ export class DependencyNotifyingDomFacade {
95
101
  */
96
102
  // eslint-disable-next-line class-methods-use-this
97
103
  getLastChild(node, bucket) {
98
- const matchingNodes = node
99
- .getChildNodes()
100
- .filter(childNode => !bucket || getBucketsForNode(childNode).includes(bucket));
101
- const matchNode = matchingNodes[matchingNodes.length - 1];
102
- if (matchNode) {
103
- return matchNode;
104
- }
105
- return null;
104
+ const children = Array.from(node.childNodes).filter(
105
+ child => !bucket || getBucketsForNode(child).includes(bucket),
106
+ );
107
+ const last = children[children.length - 1];
108
+ if (last) this._onNodeTouched(last);
109
+ return last || null;
106
110
  }
107
111
 
108
112
  /**
@@ -133,7 +137,16 @@ export class DependencyNotifyingDomFacade {
133
137
  */
134
138
  // eslint-disable-next-line class-methods-use-this
135
139
  getParentNode(node) {
136
- return node.parentNode;
140
+ const parent = node.parentNode;
141
+ /*
142
+ if (
143
+ parent &&
144
+ (parent.nodeType === Node.ELEMENT_NODE || parent.nodeType === Node.ATTRIBUTE_NODE)
145
+ ) {
146
+ this._onNodeTouched(parent);
147
+ }
148
+ */
149
+ return parent;
137
150
  }
138
151
 
139
152
  /**
@@ -145,17 +158,10 @@ export class DependencyNotifyingDomFacade {
145
158
  */
146
159
  // eslint-disable-next-line class-methods-use-this
147
160
  getPreviousSibling(node, bucket) {
148
- for (
149
- let { previousSibling } = node;
150
- previousSibling;
151
- previousSibling = previousSibling.previousSibling
152
- ) {
153
- if (bucket && !getBucketsForNode(previousSibling).includes(bucket)) {
154
- // eslint-disable-next-line no-continue
155
- continue;
156
- }
157
-
158
- return previousSibling;
161
+ for (let sibling = node.previousSibling; sibling; sibling = sibling.previousSibling) {
162
+ if (bucket && !getBucketsForNode(sibling).includes(bucket)) continue;
163
+ this._onNodeTouched(sibling);
164
+ return sibling;
159
165
  }
160
166
  return null;
161
167
  }