@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
@@ -4,168 +4,166 @@ import './fx-json-instance.js';
4
4
  // import './fx-minimap.js';
5
5
 
6
6
  export class FxDevtools extends HTMLElement {
7
-
8
- static get properties() {
9
- return {
10
- fore:{
11
- type:Object,
12
- description:"The fx-fore element the devtools are attached to"
13
- },
14
- instances:{
15
- type:Array,
16
- description:"Instances of selected Fore element"
17
- },
18
- selector: {
19
- type: String,
20
- description: "optional selector to attach to a certain fx-fore element with given id",
21
- }
22
- };
7
+ static get properties() {
8
+ return {
9
+ fore: {
10
+ type: Object,
11
+ description: 'The fx-fore element the devtools are attached to',
12
+ },
13
+ instances: {
14
+ type: Array,
15
+ description: 'Instances of selected Fore element',
16
+ },
17
+ selector: {
18
+ type: String,
19
+ description: 'optional selector to attach to a certain fx-fore element with given id',
20
+ },
21
+ };
22
+ }
23
+
24
+ constructor() {
25
+ super();
26
+ this.attachShadow({ mode: 'open' });
27
+ Object.keys(this.constructor.properties).forEach(propertyName => {
28
+ const property = this.constructor.properties[propertyName];
29
+ const attribute = property.attribute || propertyName;
30
+ const value = this.getAttribute(attribute) || property.default;
31
+ const typedValue = property.type(value);
32
+ this[propertyName] = typedValue;
33
+ });
34
+
35
+ this.isResizing = false;
36
+ this.lastY = 0;
37
+ this.defaultHeight = '40vh';
38
+
39
+ this.buttonByInstanceId = new Map();
40
+
41
+ const attachToFore = fore => {
42
+ this.fore = fore;
43
+ this.instances = [...this.fore.getModel().instances];
44
+ // console.log('instances',this.instances);
45
+ const header = this.shadowRoot.querySelector('.instances header');
46
+ header.textContent = 'Data ';
47
+ this.instances.forEach(instance => {
48
+ const btn = document.createElement('button');
49
+ btn.setAttribute('type', 'button');
50
+ btn.textContent = instance.id;
51
+ header.appendChild(btn);
52
+ this.buttonByInstanceId.set(instance.id, btn);
53
+ btn.addEventListener('click', () => this.selectInstance(instance.id));
54
+ });
55
+ if (!this.instances.length) {
56
+ return;
57
+ }
58
+ this.selectInstance(this.instances[0].id);
59
+ };
60
+
61
+ const fore = document.querySelector('fx-fore');
62
+ if (fore) {
63
+ // If there's no `fore` element, there cannot be an inspector
64
+ if (fore.inited) {
65
+ // The fore element is already initialized. We can attach immediately.
66
+ // This can happen if the fore element does not use anything asynchronous and loads right away.
67
+ attachToFore(fore);
68
+ } else {
69
+ fore.addEventListener('model-construct-done', () => attachToFore(fore));
70
+ }
23
71
  }
24
72
 
25
- constructor() {
26
- super();
27
- this.attachShadow({mode: 'open'});
28
- Object.keys(this.constructor.properties).forEach((propertyName) => {
29
- const property = this.constructor.properties[propertyName];
30
- const attribute = property.attribute || propertyName;
31
- const value = this.getAttribute(attribute) || property.default;
32
- const typedValue = property.type(value);
33
- this[propertyName] = typedValue;
34
- });
35
-
36
- this.isResizing = false;
37
- this.lastY = 0;
38
- this.defaultHeight = '40vh';
39
-
40
- this.buttonByInstanceId = new Map();
41
-
42
- const attachToFore = (fore) => {
43
- this.fore = fore;
44
- this.instances = [...this.fore.getModel().instances];
45
- // console.log('instances',this.instances);
46
- const header = this.shadowRoot.querySelector('.instances header');
47
- header.textContent = 'Data ';
48
- this.instances.forEach(instance => {
49
- const btn = document.createElement('button');
50
- btn.setAttribute('type','button');
51
- btn.textContent = instance.id;
52
- header.appendChild(btn);
53
- this.buttonByInstanceId.set(instance.id, btn);
54
- btn.addEventListener('click', () => this.selectInstance(instance.id));
55
- });
56
- if (!this.instances.length) {
57
- return;
58
- }
59
- this.selectInstance(this.instances[0].id);
60
- };
61
-
62
- const fore = document.querySelector('fx-fore');
63
- if (fore) {
64
- // If there's no `fore` element, there cannot be an inspector
65
- if (fore.inited) {
66
- // The fore element is already initialized. We can attach immediately.
67
- // This can happen if the fore element does not use anything asynchronous and loads right away.
68
- attachToFore(fore);
69
- } else {
70
- fore.addEventListener('model-construct-done', () => attachToFore(fore));
71
- }
72
- }
73
-
74
- window.document.addEventListener('log-active-element', (e) => {
75
- const target = e ? e.detail?.target || e.target : window.event.srcElement;
76
-
77
- // Note that the event target or srcElement may be the document node.
78
- const closestFore = target.nodeType === Node.DOCUMENT_NODE ? null : target.closest('fx-fore');
79
- if (closestFore) {
80
- attachToFore(closestFore);
81
- }
82
-
83
- const instance = this.instances.find(
84
- instance => {
85
- if (instance.type !== 'xml') {
86
- // TODO: handle JSON instances!
87
- return false;
88
- }
89
- return instance.instanceData.contains(target);
90
- });
91
- // const instance = this._getInstanceForTarget(target);
92
-
93
- if (instance) {
94
- this.selectInstance(instance.id);
95
- }
96
- });
97
- }
73
+ window.document.addEventListener('log-active-element', e => {
74
+ const target = e ? e.detail?.target || e.target : window.event.srcElement;
98
75
 
99
- _getInstanceForTarget(node){
100
- this.instances.forEach(instance => {
101
- if(instance.type === 'xml' && instance.instanceData.contains(node)){
102
- return instance;
103
- }
104
- if(instance.type === 'json'){
105
- return instance;
106
- }
107
- });
108
- }
76
+ // Note that the event target or srcElement may be the document node.
77
+ const closestFore = target.nodeType === Node.DOCUMENT_NODE ? null : target.closest('fx-fore');
78
+ if (closestFore) {
79
+ attachToFore(closestFore);
80
+ }
109
81
 
110
- selectInstance (instanceId) {
111
- const button = this.buttonByInstanceId.get(instanceId);
112
- if (!button) {
113
- return;
114
- }
115
- if (button.classList.contains('selected-btn')) {
116
- return;
117
- }
118
-
119
- const selectedBtn = this.shadowRoot.querySelector('.selected-btn');
120
- if(selectedBtn){
121
- selectedBtn.classList.remove('selected-btn');
82
+ const instance = this.instances.find(instance => {
83
+ if (instance.type !== 'xml') {
84
+ // TODO: handle JSON instances!
85
+ return false;
122
86
  }
123
-
124
- button.classList.add('selected-btn');
125
-
126
- const instancePanel = this.shadowRoot.querySelector('.instance-panel');
127
- instancePanel.innerHTML = "";
128
-
129
- this.instances = [...this.fore.querySelectorAll('fx-instance')];
130
- const instance = Array.from(this.instances).find(inst => inst.id === instanceId);
131
- // console.log('wanted instance', instance);
132
-
133
- const panelContent = this._renderInstancePanel(instance);
134
- // console.log('panelContent', panelContent);
135
- // instancePanel.innerHTML = panelContent;
136
- instancePanel.append(panelContent);
137
- }
138
-
139
- connectedCallback() {
140
- this.render();
141
- // document.body.style.height = document.body.scrollHeight + 320 + 'px';
87
+ return instance.instanceData.contains(target);
88
+ });
89
+ // const instance = this._getInstanceForTarget(target);
90
+
91
+ if (instance) {
92
+ this.selectInstance(instance.id);
93
+ }
94
+ });
95
+ }
96
+
97
+ _getInstanceForTarget(node) {
98
+ this.instances.forEach(instance => {
99
+ if (instance.type === 'xml' && instance.instanceData.contains(node)) {
100
+ return instance;
101
+ }
102
+ if (instance.type === 'json') {
103
+ return instance;
104
+ }
105
+ });
106
+ }
107
+
108
+ selectInstance(instanceId) {
109
+ const button = this.buttonByInstanceId.get(instanceId);
110
+ if (!button) {
111
+ return;
142
112
  }
143
-
144
- _startResize(event) {
145
- this.isResizing = true;
146
- this.lastY = event.clientY;
113
+ if (button.classList.contains('selected-btn')) {
114
+ return;
147
115
  }
148
116
 
149
- _resizePanel(event) {
150
- if (!this.isResizing) return;
151
- const delta = event.clientY - this.lastY;
152
- this.style.height = `${this.offsetHeight - delta}px`;
153
- this.lastHeight = this.style.height;
154
- this.lastY = event.clientY;
117
+ const selectedBtn = this.shadowRoot.querySelector('.selected-btn');
118
+ if (selectedBtn) {
119
+ selectedBtn.classList.remove('selected-btn');
155
120
  }
156
121
 
157
- _stopResize(event) {
158
- event.preventDefault();
159
- event.stopPropagation();
160
- this.isResizing = false;
161
- document.body.style.height = 'inherit'; // reset before calculating scrollheight
162
- document.body.style.width = 'inherit'; // reset before calculating scrollheight
163
- const newHeight = document.body.scrollHeight + this.offsetHeight;
164
- document.body.style.height = `${newHeight}px`;
165
- }
166
-
167
- render() {
168
- const style = `
122
+ button.classList.add('selected-btn');
123
+
124
+ const instancePanel = this.shadowRoot.querySelector('.instance-panel');
125
+ instancePanel.innerHTML = '';
126
+
127
+ this.instances = [...this.fore.querySelectorAll('fx-instance')];
128
+ const instance = Array.from(this.instances).find(inst => inst.id === instanceId);
129
+ // console.log('wanted instance', instance);
130
+
131
+ const panelContent = this._renderInstancePanel(instance);
132
+ // console.log('panelContent', panelContent);
133
+ // instancePanel.innerHTML = panelContent;
134
+ instancePanel.append(panelContent);
135
+ }
136
+
137
+ connectedCallback() {
138
+ this.render();
139
+ // document.body.style.height = document.body.scrollHeight + 320 + 'px';
140
+ }
141
+
142
+ _startResize(event) {
143
+ this.isResizing = true;
144
+ this.lastY = event.clientY;
145
+ }
146
+
147
+ _resizePanel(event) {
148
+ if (!this.isResizing) return;
149
+ const delta = event.clientY - this.lastY;
150
+ this.style.height = `${this.offsetHeight - delta}px`;
151
+ this.lastHeight = this.style.height;
152
+ this.lastY = event.clientY;
153
+ }
154
+
155
+ _stopResize(event) {
156
+ event.preventDefault();
157
+ event.stopPropagation();
158
+ this.isResizing = false;
159
+ document.body.style.height = 'inherit'; // reset before calculating scrollheight
160
+ document.body.style.width = 'inherit'; // reset before calculating scrollheight
161
+ const newHeight = document.body.scrollHeight + this.offsetHeight;
162
+ document.body.style.height = `${newHeight}px`;
163
+ }
164
+
165
+ render() {
166
+ const style = `
169
167
  @import '../../resources/fore.css';
170
168
 
171
169
  :host {
@@ -320,9 +318,9 @@ export class FxDevtools extends HTMLElement {
320
318
  cursor: ew-resize;
321
319
  }
322
320
  `;
323
- // console.log('render instances',this.instances);
321
+ // console.log('render instances',this.instances);
324
322
 
325
- const html = `
323
+ const html = `
326
324
  <section class="wrapper">
327
325
  <slot></slot>
328
326
  <details class="fx-devtools" open>
@@ -357,88 +355,90 @@ export class FxDevtools extends HTMLElement {
357
355
  </section>
358
356
  `;
359
357
 
360
- this.shadowRoot.innerHTML = `
358
+ this.shadowRoot.innerHTML = `
361
359
  <style>
362
360
  ${style}
363
361
  </style>
364
362
  ${html}
365
363
  `;
366
364
 
367
- // resizing handler
368
- this.resizer = this.shadowRoot.querySelector('.resizer');
369
- this.resizer.addEventListener('mousedown', this._startResize.bind(this));
370
- document.addEventListener('mousemove', this._resizePanel.bind(this));
371
- document.addEventListener('mouseup', this._stopResize.bind(this));
372
-
373
- // setup handler for option button on the right of the panel
374
- const optionsTrigger = this.shadowRoot.querySelector('#optionsTrigger');
375
- optionsTrigger.addEventListener('click', () => {
376
- const tr = this.shadowRoot.querySelector('#options');
377
- tr.classList.toggle('open');
378
- tr.classList.contains('open')? optionsTrigger.style.background = 'lightsteelblue': optionsTrigger.style.background = 'transparent';
379
- });
380
-
381
- // opening/closing the devtools
382
- const caption = this.shadowRoot.querySelector('.fx-devtools');
383
- caption.addEventListener('click', ev => {
384
- if(ev.target.nodeName === 'DIV' && ev.target.classList.contains('resizer')) {
385
- return;
386
- }
387
- if(ev.target.parentNode.open){
388
- this.removeAttribute('open');
389
- this.lastHeight = this.style.height;
390
- this.style.height='3em';
391
- }else{
392
- this.setAttribute('open','');
393
- this.style.height= this.lastHeight ? this.lastHeight: '40vh';
394
- }
395
- });
396
-
397
- this.classList.add('open');
365
+ // resizing handler
366
+ this.resizer = this.shadowRoot.querySelector('.resizer');
367
+ this.resizer.addEventListener('mousedown', this._startResize.bind(this));
368
+ document.addEventListener('mousemove', this._resizePanel.bind(this));
369
+ document.addEventListener('mouseup', this._stopResize.bind(this));
370
+
371
+ // setup handler for option button on the right of the panel
372
+ const optionsTrigger = this.shadowRoot.querySelector('#optionsTrigger');
373
+ optionsTrigger.addEventListener('click', () => {
374
+ const tr = this.shadowRoot.querySelector('#options');
375
+ tr.classList.toggle('open');
376
+ tr.classList.contains('open')
377
+ ? (optionsTrigger.style.background = 'lightsteelblue')
378
+ : (optionsTrigger.style.background = 'transparent');
379
+ });
380
+
381
+ // opening/closing the devtools
382
+ const caption = this.shadowRoot.querySelector('.fx-devtools');
383
+ caption.addEventListener('click', ev => {
384
+ if (ev.target.nodeName === 'DIV' && ev.target.classList.contains('resizer')) {
385
+ return;
386
+ }
387
+ if (ev.target.parentNode.open) {
388
+ this.removeAttribute('open');
389
+ this.lastHeight = this.style.height;
390
+ this.style.height = '3em';
391
+ } else {
392
+ this.setAttribute('open', '');
393
+ this.style.height = this.lastHeight ? this.lastHeight : '40vh';
394
+ }
395
+ });
398
396
 
399
- /*
397
+ this.classList.add('open');
398
+
399
+ /*
400
400
  document.addEventListener('value-changed', e =>{
401
401
  console.log('value-changed hitting glass', e.target);
402
402
  })
403
403
  */
404
+ }
404
405
 
405
- }
406
-
407
- _handleOpen(ev){
408
- // console.log('that works')
406
+ _handleOpen(ev) {
407
+ // console.log('that works')
409
408
 
410
- document.body.style.height = '';
411
- }
409
+ document.body.style.height = '';
410
+ }
412
411
 
413
- _renderInstancePanel(instance){
414
- if(instance.type === 'xml'){
415
- const domInspector = document.createElement('fx-dom-inspector');
416
- domInspector.setInstance(instance);
417
- domInspector.setAttribute('instance', instance.id);
418
- return domInspector;
412
+ _renderInstancePanel(instance) {
413
+ if (instance.type === 'xml') {
414
+ const domInspector = document.createElement('fx-dom-inspector');
415
+ domInspector.setInstance(instance);
416
+ domInspector.setAttribute('instance', instance.id);
417
+ return domInspector;
419
418
 
420
- /*
419
+ /*
421
420
  return
422
421
  `<fx-dom-inspector instance="${instance.id}"> </fx-dom-inspector>`
423
422
  */
424
- } if(instance.type === 'json'){
425
- const jsonInspector = document.createElement('fx-json-instance');
426
- jsonInspector.setAttribute('instance', instance.id);
427
- const span = document.createElement('span');
428
- span.setAttribute('slot','header');
429
- jsonInspector.append(span);
430
- return jsonInspector;
431
- /*
423
+ }
424
+ if (instance.type === 'json') {
425
+ const jsonInspector = document.createElement('fx-json-instance');
426
+ jsonInspector.setAttribute('instance', instance.id);
427
+ const span = document.createElement('span');
428
+ span.setAttribute('slot', 'header');
429
+ jsonInspector.append(span);
430
+ return jsonInspector;
431
+ /*
432
432
  return `
433
433
  <fx-json-instance instance="${instance.id}">
434
434
  <span slot="header"></span>
435
435
  </fx-json-instance>
436
436
  `
437
437
  */
438
- }
439
438
  }
439
+ }
440
440
  }
441
441
 
442
442
  if (!customElements.get('fx-devtools')) {
443
- customElements.define('fx-devtools', FxDevtools);
443
+ customElements.define('fx-devtools', FxDevtools);
444
444
  }