@entryscape/rdforms 10.6.0 → 10.6.1

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.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "application profile",
9
9
  "linked data"
10
10
  ],
11
- "version": "10.6.0",
11
+ "version": "10.6.1",
12
12
  "main": "dist/rdforms.node.js",
13
13
  "browser": "dist/rdforms.react.js",
14
14
  "module": "main.js",
@@ -29,6 +29,7 @@
29
29
  "bootstrap-material-datetimepicker": "https://bitbucket.org/metasolutions/bootstrap-material-datetimepicker.git#webpack",
30
30
  "bootstrap-material-design": "^4.1.1",
31
31
  "core-js": "^3.1.4",
32
+ "circular-dependency-plugin": "^5.2.2",
32
33
  "ifdef-loader": "^2.1.1",
33
34
  "jquery": "^3.3.1",
34
35
  "jquery-mousewheel": "^3.1.13",
@@ -0,0 +1,17 @@
1
+ export default {
2
+ UNKNOWN: 'unknown', // Used as a marker initially, to not mark everything red initially
3
+ OK: 'correct',
4
+ TOO_FEW_VALUES: 'few', // deprecated
5
+ TOO_FEW_VALUES_MIN: 'min',
6
+ TOO_FEW_VALUES_PREF: 'pref',
7
+ TOO_MANY_VALUES: 'many',
8
+ AT_MOST_ONE_CHILD: 'atmostonechild',
9
+ AT_LEAST_ONE_CHILD: 'atleastonechild',
10
+ EXACTLY_ONE_CHILD: 'exactlyonechild',
11
+ WRONG_VALUE: 'value',
12
+ WRONG_PATTERN: 'pattern',
13
+ WRONG_NODETYPE: 'nodetype',
14
+ WRONG_DATATYPE: 'datatype',
15
+ MISSING_LANGUAGE: 'language',
16
+ MISSING_CONSTRAINTS: 'constraints',
17
+ };
@@ -1,4 +1,5 @@
1
- import { CODES } from './engine';
1
+ import CODES from './CODES';
2
+
2
3
  export default class CardinalityTracker {
3
4
  /**
4
5
  * A counter paired with a item with cardinality restrictions.
@@ -1,5 +1,5 @@
1
1
  import ValueBinding from './ValueBinding';
2
- import {CODES} from './engine';
2
+ import CODES from './CODES';
3
3
 
4
4
  const label = 'http://www.w3.org/2000/01/rdf-schema#label';
5
5
  const seeAlso = 'http://www.w3.org/2000/01/rdf-schema#seeAlso';
@@ -11,6 +11,7 @@ import ValueBinding from './ValueBinding';
11
11
  import ChoiceBinding from './ChoiceBinding';
12
12
  import GroupURIBinding from './GroupURIBinding';
13
13
  import utils from '../utils';
14
+ import CODES from './CODES';
14
15
 
15
16
  // See public API at the bottom of this file.
16
17
 
@@ -871,27 +872,8 @@ export { levelProfile };
871
872
  */
872
873
  export { detectLevel };
873
874
 
874
- const CODES = {
875
- UNKNOWN: 'unknown', // Used as a marker initially, to not mark everything red initially
876
- OK: 'correct',
877
- TOO_FEW_VALUES: 'few', // deprecated
878
- TOO_FEW_VALUES_MIN: 'min',
879
- TOO_FEW_VALUES_PREF: 'pref',
880
- TOO_MANY_VALUES: 'many',
881
- AT_MOST_ONE_CHILD: 'atmostonechild',
882
- AT_LEAST_ONE_CHILD: 'atleastonechild',
883
- EXACTLY_ONE_CHILD: 'exactlyonechild',
884
- WRONG_VALUE: 'value',
885
- WRONG_PATTERN: 'pattern',
886
- WRONG_NODETYPE: 'nodetype',
887
- WRONG_DATATYPE: 'datatype',
888
- MISSING_LANGUAGE: 'language',
889
- MISSING_CONSTRAINTS: 'constraints',
890
- };
891
-
892
875
  export { CODES };
893
876
 
894
-
895
877
  export default { // TODO @valentino anti-pattern. This is done because engine is used in EntryScape. It shouldn't really...
896
878
  detectLevel,
897
879
  levelProfile,
@@ -1,8 +1,9 @@
1
1
  import { namespaces as ns } from '@entryscape/rdfjson';
2
- import * as engine from './engine';
2
+ import { fuzzyMatch, findBindingRelativeToParentBinding, matchPathBelowBinding } from './engine';
3
+ import CODES from './CODES';
3
4
 
4
5
  const _clearMatchingCodes = (binding) => {
5
- binding.setMatchingCode(engine.CODES.OK);
6
+ binding.setMatchingCode(CODES.OK);
6
7
  if (binding.getItem().getType() === 'group') {
7
8
  binding.getChildBindings().forEach(childBinding => _clearMatchingCodes(childBinding));
8
9
  }
@@ -66,8 +67,8 @@ const doNotProceedFurther = (groupBinding, childItem) => {
66
67
  // Don't check further if the binding is hidden due to missing dependencies
67
68
  const childPath = childItem.getDeps();
68
69
  if (childPath) {
69
- const fromBinding = engine.findBindingRelativeToParentBinding(groupBinding, childPath);
70
- if (!engine.matchPathBelowBinding(fromBinding, childPath)) {
70
+ const fromBinding = findBindingRelativeToParentBinding(groupBinding, childPath);
71
+ if (!matchPathBelowBinding(fromBinding, childPath)) {
71
72
  return true;
72
73
  }
73
74
  }
@@ -75,7 +76,7 @@ const doNotProceedFurther = (groupBinding, childItem) => {
75
76
  };
76
77
 
77
78
  const _createReport = (groupbinding, report, firstLevel) => {
78
- if (groupbinding.getMatchingCode() !== engine.CODES.OK) {
79
+ if (groupbinding.getMatchingCode() !== CODES.OK) {
79
80
  return undefined;
80
81
  }
81
82
  const groupitem = groupbinding.getItem();
@@ -84,8 +85,8 @@ const _createReport = (groupbinding, report, firstLevel) => {
84
85
  // Check disabled since it is done for each child before recursive call
85
86
  /* const path = groupitem.getDeps();
86
87
  if (path && groupbinding.getParent() != null) {
87
- const fromBinding = engine.findBindingRelativeToParentBinding(groupbinding.getParent(), path);
88
- if (!engine.matchPathBelowBinding(fromBinding, path)) {
88
+ const fromBinding = findBindingRelativeToParentBinding(groupbinding.getParent(), path);
89
+ if (!matchPathBelowBinding(fromBinding, path)) {
89
90
  return undefined;
90
91
  }
91
92
  } */
@@ -101,11 +102,11 @@ const _createReport = (groupbinding, report, firstLevel) => {
101
102
  const nrOfValid = _countValidBindings(bindings);
102
103
  let code;
103
104
  if (nrOfValid > 1 && (groupitem.hasStyle('disjoint') || groupitem.hasStyle('atMostOneChild'))) {
104
- code = engine.CODES.AT_MOST_ONE_CHILD;
105
+ code = CODES.AT_MOST_ONE_CHILD;
105
106
  } else if (nrOfValid !== 1 && groupitem.hasStyle('exactlyOneChild')) {
106
- code = engine.CODES.EXACTLY_ONE_CHILD;
107
+ code = CODES.EXACTLY_ONE_CHILD;
107
108
  } else if (nrOfValid === 0 && groupitem.hasStyle('atLeastOneChild')) {
108
- code = engine.CODES.AT_LEAST_ONE_CHILD;
109
+ code = CODES.AT_LEAST_ONE_CHILD;
109
110
  }
110
111
  if (code) {
111
112
  updateViaCardinalityTracker([groupbinding], code);
@@ -129,15 +130,15 @@ const _createReport = (groupbinding, report, firstLevel) => {
129
130
  report.errors.push({
130
131
  parentBinding: groupbinding,
131
132
  item: childItem,
132
- code: engine.CODES.TOO_FEW_VALUES_MIN,
133
+ code: CODES.TOO_FEW_VALUES_MIN,
133
134
  });
134
- updateViaCardinalityTracker(bindings, engine.CODES.TOO_FEW_VALUES_MIN);
135
+ updateViaCardinalityTracker(bindings, CODES.TOO_FEW_VALUES_MIN);
135
136
  /* let counter = 0;
136
137
  bindings.forEach((binding) => {
137
138
  if (!binding.isValid()) {
138
139
  if (counter < card.min) {
139
140
  counter += 1;
140
- binding.setMatchingCode(engine.CODES.TOO_FEW_VALUES_MIN);
141
+ binding.setMatchingCode(CODES.TOO_FEW_VALUES_MIN);
141
142
  }
142
143
  }
143
144
  }); */
@@ -145,23 +146,23 @@ const _createReport = (groupbinding, report, firstLevel) => {
145
146
  report.warnings.push({
146
147
  parentBinding: groupbinding,
147
148
  item: childItem,
148
- code: engine.CODES.TOO_FEW_VALUES_PREF,
149
+ code: CODES.TOO_FEW_VALUES_PREF,
149
150
  });
150
- // updateViaCardinalityTracker(bindings, engine.CODES.TOO_FEW_VALUES_PREF);
151
+ // updateViaCardinalityTracker(bindings, CODES.TOO_FEW_VALUES_PREF);
151
152
  }
152
153
  if (card.max != null && card.max < nrOfValid) {
153
154
  report.errors.push({
154
155
  parentBinding: groupbinding,
155
156
  item: childItem,
156
- code: engine.CODES.TOO_MANY_VALUES,
157
+ code: CODES.TOO_MANY_VALUES,
157
158
  });
158
- updateViaCardinalityTracker(bindings, engine.CODES.TOO_MANY_VALUES);
159
+ updateViaCardinalityTracker(bindings, CODES.TOO_MANY_VALUES);
159
160
  /* let counter = 0;
160
161
  bindings.forEach((binding) => {
161
162
  if (binding.isValid()) {
162
163
  counter += 1;
163
164
  if (counter > card.max) {
164
- binding.setMatchingCode(engine.CODES.TOO_MANY_VALUES);
165
+ binding.setMatchingCode(CODES.TOO_MANY_VALUES);
165
166
  }
166
167
  }
167
168
  }); */
@@ -172,7 +173,7 @@ const _createReport = (groupbinding, report, firstLevel) => {
172
173
 
173
174
  groupbinding.getChildBindings().forEach((binding) => {
174
175
  const item = binding.getItem();
175
- if (binding.getMatchingCode() !== engine.CODES.OK) {
176
+ if (binding.getMatchingCode() !== CODES.OK) {
176
177
  report.errors.push({
177
178
  parentBinding: binding,
178
179
  item,
@@ -330,7 +331,7 @@ const _simplifyReport = (report) => {
330
331
  };
331
332
 
332
333
  const _resourceReport = (resource, graph, template, ignoreResources) => {
333
- const binding = engine.fuzzyMatch(graph, resource, template);
334
+ const binding = fuzzyMatch(graph, resource, template);
334
335
  const report = bindingReport(binding);
335
336
  _filterReport(report, resource, ignoreResources || {});
336
337
  _simplifyReport(report);
@@ -1,5 +1,6 @@
1
1
  import renderingContext from './renderingContext';
2
2
  import Presenter from './Presenter';
3
+ import CODES from '../model/CODES';
3
4
  import * as engine from '../model/engine';
4
5
  import { bindingReport } from '../model/validate';
5
6
 
@@ -74,7 +75,7 @@ export default class Editor extends Presenter {
74
75
  for (let j = 0; j < _report.errors.length; j++) {
75
76
  const err = _report.errors[j];
76
77
  if (err.parentBinding === this.binding) {
77
- if (err.code === engine.CODES.TOO_FEW_VALUES_MIN) {
78
+ if (err.code === CODES.TOO_FEW_VALUES_MIN) {
78
79
  const item = err.item;
79
80
  let counter = item.getCardinality().min;
80
81
 
@@ -86,9 +87,9 @@ export default class Editor extends Presenter {
86
87
  }
87
88
  return counter === 0;
88
89
  });
89
- } else if (err.code === engine.CODES.AT_MOST_ONE_CHILD) {
90
+ } else if (err.code === CODES.AT_MOST_ONE_CHILD) {
90
91
  this.binding.getChildBindings().forEach((binding) => {
91
- if (binding.getMatchingCode() !== engine.CODES.OK) {
92
+ if (binding.getMatchingCode() !== CODES.OK) {
92
93
  renderingContext.domClassToggle(this._binding2node[binding.getHash()],
93
94
  'errorReport', true);
94
95
  }
@@ -1,6 +1,7 @@
1
1
  import renderingContext from './renderingContext';
2
2
  import Presenter from './Presenter';
3
- import engine, { CODES } from '../model/engine';
3
+ import CODES from '../model/CODES';
4
+ import engine from '../model/engine';
4
5
  import { bindingReport } from '../model/validate';
5
6
 
6
7
  const localize = (bundle, key, val) => {
@@ -5,7 +5,7 @@ import { styled } from '@mui/material/styles';
5
5
  import ClickAwayListener from '@mui/material/ClickAwayListener';
6
6
  import renderingContext from '../renderingContext';
7
7
  import { Editor } from './Wrappers';
8
- import { CODES } from '../../model/engine';
8
+ import CODES from '../../model/CODES';
9
9
 
10
10
  const StyledTooltip = styled(
11
11
  forwardRef(({ className, ...props }, ref) => (