@entryscape/rdforms 10.10.0 → 10.11.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.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "application profile",
9
9
  "linked data"
10
10
  ],
11
- "version": "10.10.0",
11
+ "version": "10.11.0",
12
12
  "main": "dist/rdforms.node.js",
13
13
  "browser": "dist/rdforms.react.js",
14
14
  "module": "main.js",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@emotion/react": "^11.4.1",
20
20
  "@emotion/styled": "^11.3.0",
21
- "@entryscape/rdfjson": "2.5.8",
21
+ "@entryscape/rdfjson": "2.7.6",
22
22
  "@fortawesome/fontawesome-free": "^5.8.1",
23
23
  "@mui/icons-material": "^5.0.3",
24
24
  "@mui/material": "^5.0.3",
@@ -26,20 +26,20 @@
26
26
  "@mui/x-date-pickers": "^5.0.0-beta.7",
27
27
  "@selectize/selectize": "^0.13.5",
28
28
  "arrive": "^2.4.1",
29
- "bootstrap": "^4.3.1",
29
+ "bootstrap": "^4.6.2",
30
30
  "bootstrap-datepicker": "^1.9.0",
31
31
  "bootstrap-material-datetimepicker": "https://bitbucket.org/metasolutions/bootstrap-material-datetimepicker.git#webpack",
32
32
  "bootstrap-material-design": "^4.1.1",
33
33
  "circular-dependency-plugin": "^5.2.2",
34
34
  "core-js": "^3.4.0",
35
35
  "ifdef-loader": "^2.1.1",
36
- "jquery": "^3.3.1",
36
+ "jquery": "^3.7.0",
37
37
  "jquery-mousewheel": "^3.1.13",
38
38
  "lodash-es": "^4.17.10",
39
39
  "moment": "^2.22.2",
40
40
  "nls-loader": "https://bitbucket.org/metasolutions/nls-loader#master",
41
41
  "node-fetch": "^2.6.0",
42
- "popper.js": "^1.12.9",
42
+ "popper.js": "^1.16.1",
43
43
  "react": "^18.2.0",
44
44
  "react-dom": "^18.2.0",
45
45
  "react-hooks-lib": "^0.1.5",
@@ -51,46 +51,41 @@
51
51
  "whatwg-fetch": "^3.0.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@babel/cli": "^7.1.0",
55
- "@babel/core": "^7.1.0",
56
- "@babel/plugin-proposal-class-properties": "^7.4.4",
57
- "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
58
- "@babel/plugin-syntax-dynamic-import": "^7.0.0",
59
- "@babel/plugin-transform-modules-commonjs": "^7.1.0",
60
- "@babel/plugin-transform-react-jsx": "^7.3.0",
61
- "@babel/preset-env": "^7.1.0",
62
- "babel-eslint": "^10.0.3",
63
- "babel-loader": "^8.0.2",
64
- "babel-minify-webpack-plugin": "^0.3.1",
54
+ "@babel/cli": "^7.16.0",
55
+ "@babel/core": "^7.16.0",
56
+ "@babel/plugin-transform-class-properties": "^7.23.3",
57
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
58
+ "@babel/plugin-syntax-dynamic-import": "^7.2.0",
59
+ "@babel/plugin-transform-modules-commonjs": "^7.16.0",
60
+ "@babel/plugin-transform-react-jsx": "^7.16.0",
61
+ "@babel/preset-env": "^7.18.6",
62
+ "babel-loader": "^8.2.3",
65
63
  "babel-plugin-lodash": "^3.3.4",
66
64
  "babel-plugin-transform-react-jsx": "^6.24.1",
67
- "clean-webpack-plugin": "^0.1.18",
68
- "copy-webpack-plugin": "^5.0.5",
69
- "css-loader": "^3.5.3",
65
+ "clean-webpack-plugin": "^4.0.0",
66
+ "copy-webpack-plugin": "^9.0.1",
67
+ "css-loader": "^6.5.1",
70
68
  "eslint": "^8.23.0",
71
69
  "eslint-config-airbnb-base": "^11.1.1",
72
70
  "eslint-plugin-import": "^2.2.0",
73
71
  "eslint-plugin-requirejs": "^3.1.1",
74
- "file-loader": "^1.1.11",
75
- "html-loader": "^0.5.5",
76
- "html-webpack-plugin": "^3.2.0",
77
- "html-webpack-tags-plugin": "^2.0.17",
72
+ "html-loader": "^3.0.1",
73
+ "html-webpack-plugin": "^5.5.0",
74
+ "html-webpack-tags-plugin": "^3.0.2",
78
75
  "imports-loader": "^0.8.0",
79
76
  "mini-css-extract-plugin": "^0.4.1",
80
- "optimize-css-assets-webpack-plugin": "^5.0.0",
81
- "parallel-webpack": "^2.4.0",
77
+ "optimize-css-assets-webpack-plugin": "^6.0.1",
78
+ "parallel-webpack": "^2.6.0",
82
79
  "print-licenses": "https://bitbucket.org/metasolutions/print-licenses#master",
83
80
  "q": "^1.5.0",
84
- "raw-loader": "^0.5.1",
85
- "style-loader": "^0.20.3",
81
+ "raw-loader": "^4.0.2",
82
+ "style-loader": "^3.3.1",
86
83
  "svg-inline-loader": "^0.8.0",
87
84
  "ttf-loader": "^1.0.2",
88
- "webpack": "^4.41.2",
89
- "webpack-cli": "^3.1.1",
90
- "webpack-dev-server": "^3.1.10",
91
- "webpack-jarvis": "^0.3.2",
92
- "webpack-merge": "^4.1.4",
93
- "webpack-node-externals": "^1.6.0"
85
+ "webpack": "^5.88.2",
86
+ "webpack-cli": "^5.1.4",
87
+ "webpack-dev-server": "^4.15.1",
88
+ "webpack-merge": "^5.8.0"
94
89
  },
95
90
  "files": [
96
91
  "dist",
@@ -99,15 +94,15 @@
99
94
  "renderers"
100
95
  ],
101
96
  "scripts": {
102
- "build:all": "webpack --display-modules --mode=production --config webpack.all.js",
103
- "build:node": "webpack --display-modules --config webpack.node.js",
104
- "build:node:dev": "webpack --mode=development --display-modules --config webpack.node.js",
97
+ "build:all": "webpack --mode=production --config webpack.all.js",
98
+ "build:node": "webpack --config webpack.node.js",
99
+ "build:node:dev": "webpack --mode=development --config webpack.node.js",
105
100
  "build:samples": "webpack --config webpack.samples.js",
106
- "dev:bmd": "webpack-dev-server --watch --config webpack.dev.js",
107
- "dev:bootstrap": "webpack-dev-server --watch --config webpack.dev.js --type=bootstrap",
108
- "dev:jquery": "webpack-dev-server --watch --config webpack.dev.js --type=jquery",
109
- "dev:react": "webpack-dev-server --watch --config webpack.dev.js --type=react",
110
- "serve:samples": "webpack-dev-server --config webpack.samples.serve.js",
101
+ "dev:bmd": "webpack serve --config webpack.dev.js",
102
+ "dev:bootstrap": "webpack serve --config webpack.dev.js --env type=bootstrap",
103
+ "dev:jquery": "webpack serve --config webpack.dev.js --env type=jquery",
104
+ "dev:react": "webpack serve --config webpack.dev.js --env type=react",
105
+ "serve:samples": "webpack serve --config webpack.samples.serve.js",
111
106
  "print-licenses": "print-licenses"
112
107
  },
113
108
  "author": {
@@ -0,0 +1,35 @@
1
+ {
2
+ "tocHeading": "Innehållsförteckning",
3
+ "introHeading": "Introduktion",
4
+ "nsHeading": "Namnrymder",
5
+ "mainAPHeading": "Primära klasser",
6
+ "suppAPHeading": "Stödjande klasser",
7
+ "vocsHeading": "Vokabulärer",
8
+ "apxHeadings": "Appendix",
9
+ "apxHeading": "Appendix ${id} - ${name}",
10
+ "vocabTableHeadingLabel": "Beteckning",
11
+ "vocabTableHeadingValue": "Värde",
12
+ "vocabLabel": "Beteckning",
13
+ "vocabLiteralValue": "Värde",
14
+ "vocabURIValue": "Värde",
15
+ "vocabDescription": "Beskrivning",
16
+ "vocabSeeAlso": "Se också",
17
+ "fieldLiteral": "Sträng",
18
+ "fieldLangLit": "Sträng med språk",
19
+ "fieldDatatype": "Datatyp (${datatype})",
20
+ "fieldURI": "Webbadress (URI)",
21
+ "fieldRef": "Entiteten beskrivs av ",
22
+ "fieldLabel": "Beteckning",
23
+ "fieldDescription": "Beskrivning",
24
+ "fieldProperty": "Egenskap",
25
+ "fieldRange": "Värdemängd",
26
+ "fieldLevel": "Kravnivå",
27
+ "unlimited": "n",
28
+ "fieldCardinality": "Kardinalitet",
29
+ "fieldTableHeaderProperty": "Property",
30
+ "fieldTableHeaderLevel": "Kravnivå",
31
+ "levelMandatory": "Obligatorisk",
32
+ "levelRecommended": "Rekommenderad",
33
+ "levelOptional": "Valfri",
34
+ "class": "Klass"
35
+ }
@@ -70,7 +70,10 @@ export default class Item {
70
70
  'deprecated',
71
71
  'inline',
72
72
  'truncate',
73
- 'noTruncate'
73
+ 'noTruncate',
74
+ 'card',
75
+ 'cardInPresent',
76
+ 'cardInEdit'
74
77
  ];
75
78
  this._getLocalizedValue = utils.getLocalizedValue;
76
79
  }
@@ -182,6 +185,24 @@ export default class Item {
182
185
  getSpecificationMap(original) { return this.getSource(original).specification; }
183
186
  setSpecificationMap(map) { this._setTextMap('specification', map); }
184
187
 
188
+ getText(attr, returnDetails, original) {
189
+ const s = this.getSource(original);
190
+ const t = s.text || {};
191
+ return returnDetails ? utils.getLocalizedValue(t[attr]) : utils.getLocalizedValue(t[attr]).value;
192
+ }
193
+ setText(attr, value, lang) {
194
+ const s = this.getSource(true);
195
+ const t = s.text = s.text || {};
196
+ t[attr] = this._setLangHash(t[attr], value, lang);
197
+ this.refreshExtends();
198
+ }
199
+ setTextMap(attr, map) {
200
+ const s = this.getSource(true);
201
+ const t = s.text = s.text || {};
202
+ setObjAttr(t, attr, map);
203
+ this.refreshExtends();
204
+ }
205
+
185
206
  /**
186
207
  * @return {String|null} as a URI, may be null for Groups, never null for Text or choice
187
208
  * item types.
@@ -16,7 +16,11 @@ export default class ItemStore {
16
16
  */
17
17
  constructor(ontologyStore) {
18
18
  this.automaticSortAllowed = true;
19
- this.ignoreMissingItems = true;
19
+ /**
20
+ * Value may be console methods or 'throw'.
21
+ * @type {string}
22
+ */
23
+ this.handleErrorAs = 'throw';
20
24
 
21
25
  //= =================================================;
22
26
  // Private Attribute;
@@ -63,10 +67,12 @@ export default class ItemStore {
63
67
 
64
68
  renameItem(from, to) {
65
69
  if (this._registry[to]) {
66
- throw new Error(`Cannot rename to ${to} since an item with that id already exists.`);
70
+ this._handleError(`Cannot rename to ${to} since an item with that id already exists.`);
71
+ return;
67
72
  }
68
73
  if (to === '' || to === null) {
69
- throw new Error('Cannot give an item an empty string or null as id.');
74
+ this._handleError('Cannot give an item an empty string or null as id.');
75
+ return;
70
76
  }
71
77
  const item = this._registry[from];
72
78
  if (item) {
@@ -180,8 +186,8 @@ export default class ItemStore {
180
186
  if (source.extends) {
181
187
  // Explicit extends given
182
188
  const extItem = this._registry[source.extends];
183
- if (extItem == null && !this.ignoreMissingItems) {
184
- throw new Error(`Cannot find item to extend with id: ${source.extends}`);
189
+ if (extItem == null) {
190
+ this._handleError(`Cannot find item to extend with id: ${source.extends}`);
185
191
  }
186
192
  if (extItem) {
187
193
  const newSource = this.createExtendedSource(extItem.getSource(), source);
@@ -234,10 +240,12 @@ export default class ItemStore {
234
240
  }
235
241
  // No type means it is a reference, check that the referred item (via id) exists
236
242
  if (id == null) {
237
- throw new Error('Cannot create subitem, `type` for creating new or `id` for referencing external are required.');
243
+ this._handleError('Cannot create subitem, `type` for creating new or `id` for referencing external are required.');
244
+ return;
238
245
  }
239
246
  if (this._registry[id] == null) {
240
- throw new Error(`Cannot find referenced subitem using identifier: ${id}`);
247
+ this._handleError(`Cannot find referenced subitem using identifier: ${id}`);
248
+ return;
241
249
  }
242
250
 
243
251
  // Clone if forceClone set to true or if the source contains non-id properties.
@@ -274,6 +282,13 @@ export default class ItemStore {
274
282
  // If child is not a object but a direct string reference,
275
283
  const childToUse = typeof child === 'string' ? sourceArray[index] = { id: child } : child;
276
284
  return this.createItem(childToUse, forceClone, false, bundle);
277
- });
285
+ }).filter(item => item);
286
+ }
287
+
288
+ _handleError(message) {
289
+ if (this.handleErrorAs === 'throw') {
290
+ throw new Error(message);
291
+ }
292
+ console[this.handleErrorAs](message);
278
293
  }
279
294
  }
@@ -174,7 +174,7 @@ export default class Editor extends Presenter {
174
174
  } else {
175
175
  target = 1;
176
176
  }
177
- if (item.hasStyle('nonEditable') && !item.hasStyle('autoInitDate') && !item.hasStyle('autoUpdateDate') && !item.hasStyle('autoUUID') && !item.hasStyle('autoValue')) {
177
+ if (item.hasStyle('nonEditable') && !item.hasStyle('autoInitDate') && !item.hasStyle('autoUpdateDate') && !item.hasStyle('autoUUID') && !item.hasStyle('autoValue') && !item.getValue()) {
178
178
  return _bindings;
179
179
  }
180
180
  if (target > _bindings.length) {
package/src/view/View.js CHANGED
@@ -353,7 +353,11 @@ export default class View {
353
353
  renderingContext.domClassToggle(rowNode, 'hiddenProperty', true);
354
354
  }
355
355
 
356
- if (item.hasStyle('card')) {
356
+ const isEditor = this._subEditors !== undefined;
357
+ if (item.hasStyle('card') ||
358
+ (item.hasStyle('cardInEdit') && isEditor) ||
359
+ (item.hasStyle('cardInPresent') && !isEditor)
360
+ ) {
357
361
  renderingContext.domClassToggle(rowNode, 'rdformsCard', true);
358
362
  }
359
363
  return rowNode;
@@ -57,17 +57,17 @@ presenters.itemtype('choice').register(choicify(
57
57
  } else {
58
58
  system.attachLinkBehaviour($el[0], binding);
59
59
  }
60
- if (choice.load != null) {
61
- choice.load(() => {
62
- const locValue2 = utils.getLocalizedValue(choice.label);
63
- $el.text(locValue2.value);
64
- if (locValue2.lang) {
65
- $el.attr('lang', locValue2.lang);
66
- } else {
67
- $el.attr('lang', undefined);
68
- }
69
- });
70
- }
60
+ }
61
+ if (choice.load != null) {
62
+ choice.load(() => {
63
+ const locValue2 = utils.getLocalizedValue(choice.label);
64
+ $el.text(locValue2.value);
65
+ if (locValue2.lang) {
66
+ $el.attr('lang', locValue2.lang);
67
+ } else {
68
+ $el.attr('lang', undefined);
69
+ }
70
+ });
71
71
  }
72
72
  if (locValue.lang) {
73
73
  $el.attr('lang', locValue.lang);
@@ -49,10 +49,18 @@ presenters.itemtype('choice').register(choicify(
49
49
  const item = binding.getItem();
50
50
  const title = desc || choice.seeAlso || choice.value;
51
51
  if ((item.hasStaticChoices() && !item.hasStyle('externalLink')) || item.hasStyle('noLink')) {
52
- const locValue = getLocalizedLabel(choice, isEditor);
53
- const langAttr = locValue.lang ? { lang: locValue.lang } : {};
54
- fieldDiv.appendChild(<div key={binding.getHash()} {...langAttr} title={title} src={choice.value
55
- }>{locValue.value}</div>);
52
+ fieldDiv.appendChild(React.createElement(() => {
53
+ const [locValue, setLocValue] = useState(getLocalizedLabel(choice, isEditor));
54
+ useEffect(() => {
55
+ if (choice.load != null) {
56
+ choice.load(() => {
57
+ setLocValue(getLocalizedLabel(choice, isEditor));
58
+ });
59
+ }
60
+ }, []);
61
+ const langAttr = locValue.lang ? {lang: locValue.lang} : {};
62
+ return <div key={binding.getHash()} {...langAttr} title={title}>{locValue.value}</div>
63
+ }));
56
64
  } else {
57
65
  let attrs;
58
66
  if (item.hasStyle('externalLink')) {
@@ -6,7 +6,7 @@ export const fromDuration = (value) => {
6
6
  const days = f(value.match(/([0-9])*D/));
7
7
  const hours = f(value.match(/([0-9])*H/));
8
8
  let months;
9
- let minutes;
9
+ let minutes = 0;
10
10
  if (value.indexOf('T') === -1) {
11
11
  months = f(value.match(/([0-9])*M/));
12
12
  } else {