@beinformed/ui 1.61.0 → 1.62.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/CHANGELOG.md +16 -0
- package/esm/models/attributes/__tests__/AttributeContent.spec.js.flow +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +1 -1
- package/esm/models/concepts/ConceptIndexModel.js.flow +3 -1
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.d.ts +15 -0
- package/esm/models/concepts/ConceptLinkModel.js +14 -0
- package/esm/models/concepts/ConceptLinkModel.js.flow +21 -0
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.d.ts +9 -0
- package/esm/models/concepts/SourceReferenceModel.js +14 -0
- package/esm/models/concepts/SourceReferenceModel.js.flow +15 -1
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/concepts/__mock__/related_concepts.js.flow +12 -0
- package/esm/models/concepts/__tests__/RelatedConcepts.spec.js.flow +60 -0
- package/esm/models/concepts/__tests__/SourceReferenceModel.spec.js.flow +58 -0
- package/esm/models/content/ContentLinkModel.d.ts +8 -0
- package/esm/models/content/ContentLinkModel.js +20 -0
- package/esm/models/content/ContentLinkModel.js.flow +22 -0
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/ContentTOCModel.d.ts +3 -0
- package/esm/models/content/ContentTOCModel.js +6 -0
- package/esm/models/content/ContentTOCModel.js.flow +6 -0
- package/esm/models/content/ContentTOCModel.js.map +1 -1
- package/esm/models/content/__tests__/ContentIndexModel.spec.js.flow +3 -0
- package/esm/models/content/__tests__/ContentModel.spec.js.flow +5 -5
- package/esm/models/content/__tests__/Formalsource.spec.js.flow +4 -0
- package/esm/models/form/FormObjectModel.js +5 -3
- package/esm/models/form/FormObjectModel.js.flow +12 -11
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/types.d.ts +6 -0
- package/esm/models/types.js.flow +7 -0
- package/esm/models/types.js.map +1 -1
- package/esm/utils/helpers/__tests__/createHash.spec.js.flow +5 -5
- package/esm/utils/helpers/createHash.d.ts +2 -1
- package/esm/utils/helpers/createHash.js +10 -9
- package/esm/utils/helpers/createHash.js.flow +10 -10
- package/esm/utils/helpers/createHash.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +1 -1
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.d.ts +15 -0
- package/lib/models/concepts/ConceptLinkModel.js +14 -0
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.d.ts +9 -0
- package/lib/models/concepts/SourceReferenceModel.js +14 -0
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.d.ts +8 -0
- package/lib/models/content/ContentLinkModel.js +20 -0
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.d.ts +3 -0
- package/lib/models/content/ContentTOCModel.js +6 -0
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js +5 -3
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/types.d.ts +6 -0
- package/lib/models/types.js.map +1 -1
- package/lib/utils/helpers/createHash.d.ts +2 -1
- package/lib/utils/helpers/createHash.js +11 -9
- package/lib/utils/helpers/createHash.js.map +1 -1
- package/package.json +3 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +1 -1
- package/src/models/concepts/ConceptIndexModel.js +3 -1
- package/src/models/concepts/ConceptLinkModel.js +21 -0
- package/src/models/concepts/SourceReferenceModel.js +15 -1
- package/src/models/concepts/__mock__/related_concepts.js +12 -0
- package/src/models/concepts/__mock__/related_concepts_contributions.json +41 -0
- package/src/models/concepts/__mock__/related_concepts_data.json +2292 -0
- package/src/models/concepts/__tests__/RelatedConcepts.spec.js +60 -0
- package/src/models/concepts/__tests__/SourceReferenceModel.spec.js +58 -0
- package/src/models/content/ContentLinkModel.js +22 -0
- package/src/models/content/ContentTOCModel.js +6 -0
- package/src/models/content/__tests__/ContentIndexModel.spec.js +3 -0
- package/src/models/content/__tests__/ContentModel.spec.js +5 -5
- package/src/models/content/__tests__/Formalsource.spec.js +4 -0
- package/src/models/content/__tests__/content-index.json +1 -0
- package/src/models/content/__tests__/formalsource-complete.json +1 -0
- package/src/models/form/FormObjectModel.js +12 -11
- package/src/models/types.js +7 -0
- package/src/utils/helpers/__tests__/createHash.spec.js +5 -5
- package/src/utils/helpers/createHash.js +10 -10
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.createHashFromHref = exports.createHash = void 0;
|
|
8
|
+
var _hashIt = _interopRequireDefault(require("hash-it"));
|
|
7
9
|
/**
|
|
8
10
|
* https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
|
9
11
|
*/
|
|
10
12
|
const createHash = str => {
|
|
11
|
-
|
|
12
|
-
let hash = 0;
|
|
13
|
-
for (let i = 0; i < str.length; i++) {
|
|
14
|
-
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
15
|
-
hash = hash & hash;
|
|
16
|
-
}
|
|
17
|
-
return hash;
|
|
13
|
+
return (0, _hashIt.default)(str);
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
/**
|
|
21
17
|
*/
|
|
22
18
|
exports.createHash = createHash;
|
|
23
|
-
const createHashFromHref = href => {
|
|
19
|
+
const createHashFromHref = (href, fragment) => {
|
|
24
20
|
const hrefString = href.hash ? [href.toString(), href.hash].join("#") : href.toString();
|
|
25
|
-
|
|
21
|
+
if (fragment) {
|
|
22
|
+
return (0, _hashIt.default)({
|
|
23
|
+
hrefString,
|
|
24
|
+
fragment
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return (0, _hashIt.default)(hrefString);
|
|
26
28
|
};
|
|
27
29
|
exports.createHashFromHref = createHashFromHref;
|
|
28
30
|
//# sourceMappingURL=createHash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHash.js","names":["
|
|
1
|
+
{"version":3,"file":"createHash.js","names":["_hashIt","_interopRequireDefault","require","createHash","str","hash","exports","createHashFromHref","href","fragment","hrefString","toString","join"],"sources":["../../../src/utils/helpers/createHash.js"],"sourcesContent":["// @flow\nimport hash from \"hash-it\";\n\nimport type Href from \"../../models/href/Href\";\nimport type { SectionFragment } from \"../../models\";\n\n/**\n * https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/\n */\nconst createHash = (str: string): number => {\n return hash(str);\n};\n\n/**\n */\nconst createHashFromHref = (href: Href, fragment?: SectionFragment): number => {\n const hrefString = href.hash\n ? [href.toString(), href.hash].join(\"#\")\n : href.toString();\n\n if (fragment) {\n return hash({ hrefString, fragment });\n }\n\n return hash(hrefString);\n};\n\nexport { createHash, createHashFromHref };\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,GAAW,IAAa;EAC1C,OAAO,IAAAC,eAAI,EAACD,GAAG,CAAC;AAClB,CAAC;;AAED;AACA;AADAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEA,MAAMI,kBAAkB,GAAGA,CAACC,IAAU,EAAEC,QAA0B,KAAa;EAC7E,MAAMC,UAAU,GAAGF,IAAI,CAACH,IAAI,GACxB,CAACG,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAEH,IAAI,CAACH,IAAI,CAAC,CAACO,IAAI,CAAC,GAAG,CAAC,GACtCJ,IAAI,CAACG,QAAQ,CAAC,CAAC;EAEnB,IAAIF,QAAQ,EAAE;IACZ,OAAO,IAAAJ,eAAI,EAAC;MAAEK,UAAU;MAAED;IAAS,CAAC,CAAC;EACvC;EAEA,OAAO,IAAAJ,eAAI,EAACK,UAAU,CAAC;AACzB,CAAC;AAACJ,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.0",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "https://support.beinformed.com",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"clean": "rimraf lib dist esm coverage && npm run clean:proxies",
|
|
28
28
|
"clean:proxies": "node .build/proxies.js --clean",
|
|
29
29
|
"lint": "eslint --cache .",
|
|
30
|
+
"lint:fix": "eslint --cache . --fix",
|
|
30
31
|
"prettier": "prettier --write \"./src/**/*.js\"",
|
|
31
32
|
"flow": "flow",
|
|
32
33
|
"flow:ci": "flow check",
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
"dequal": "^2.0.3",
|
|
77
78
|
"file-size": "^1.0.0",
|
|
78
79
|
"format-message": "^6.2.4",
|
|
80
|
+
"hash-it": "^6.0.0",
|
|
79
81
|
"html-entities": "^2.6.0",
|
|
80
82
|
"iban": "^0.0.14",
|
|
81
83
|
"js-cookie": "^3.0.5",
|
|
@@ -205,7 +205,7 @@ describe("AttributeContent", () => {
|
|
|
205
205
|
|
|
206
206
|
expect(firstSection.childSections).toHaveLength(2);
|
|
207
207
|
expect(firstSection.subSections).toHaveLength(2);
|
|
208
|
-
expect(firstSection.referenceHash).toBe(
|
|
208
|
+
expect(firstSection.referenceHash).toBe(4345174491453);
|
|
209
209
|
});
|
|
210
210
|
|
|
211
211
|
it("can handle referredSections", () => {
|
|
@@ -67,7 +67,9 @@ export default class ConceptIndexModel extends ResourceModel {
|
|
|
67
67
|
static isApplicableModel(data: ModularUIResponse): boolean {
|
|
68
68
|
const resourceType = data.contributions?.resourcetype;
|
|
69
69
|
return (
|
|
70
|
-
resourceType === "ConceptSearch" ||
|
|
70
|
+
resourceType === "ConceptSearch" ||
|
|
71
|
+
resourceType === "relatedConcepts" ||
|
|
72
|
+
resourceType === "RelatedConcepts"
|
|
71
73
|
);
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -12,6 +12,13 @@ import type {
|
|
|
12
12
|
} from "../types";
|
|
13
13
|
import type Href from "../href/Href";
|
|
14
14
|
|
|
15
|
+
type SectionFragment = {
|
|
16
|
+
sectionId: string,
|
|
17
|
+
text: string,
|
|
18
|
+
startOffset: number,
|
|
19
|
+
endOffset: number,
|
|
20
|
+
};
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* Link to a concept
|
|
17
24
|
*/
|
|
@@ -184,4 +191,18 @@ export default class ConceptLinkModel
|
|
|
184
191
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
185
192
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
186
193
|
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
*/
|
|
198
|
+
get modelCategory(): string {
|
|
199
|
+
return this.getData("modelCategory");
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
*
|
|
204
|
+
*/
|
|
205
|
+
get fragment(): SectionFragment {
|
|
206
|
+
return this.getData("sectionFragment");
|
|
207
|
+
}
|
|
187
208
|
}
|
|
@@ -4,7 +4,7 @@ import { createHashFromHref } from "../../utils/helpers/createHash";
|
|
|
4
4
|
import ContentLinkModel from "../content/ContentLinkModel";
|
|
5
5
|
import Href from "../href/Href";
|
|
6
6
|
import { getBasePathModularUI } from "../../constants";
|
|
7
|
-
import type { ModelOptions } from "../types";
|
|
7
|
+
import type { ModelOptions, SectionFragment } from "../types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*/
|
|
@@ -74,11 +74,25 @@ class SourceReferenceModel {
|
|
|
74
74
|
return this._sourceReference.sourceLabel;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
get sourceAbbreviation(): string {
|
|
81
|
+
return this._sourceReference.sourceAbbreviation;
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
/**
|
|
78
85
|
*/
|
|
79
86
|
get referenceHash(): number {
|
|
80
87
|
return createHashFromHref(this.selfhref);
|
|
81
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
get fragment(): SectionFragment | void {
|
|
94
|
+
return this._sourceReference.sectionFragment;
|
|
95
|
+
}
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
export default SourceReferenceModel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ModularUIResponse from "../../../modularui/ModularUIResponse";
|
|
2
|
+
import data from "./related_concepts_data.json";
|
|
3
|
+
import contributions from "./related_concepts_contributions.json";
|
|
4
|
+
import ConceptIndexModel from "../ConceptIndexModel";
|
|
5
|
+
|
|
6
|
+
const response = ModularUIResponse.create({
|
|
7
|
+
key: "concept",
|
|
8
|
+
data,
|
|
9
|
+
contributions,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const relatedConcepts = new ConceptIndexModel(response);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"RelatedConceptsOfContentSection": {
|
|
3
|
+
"label": "Related concepts of content",
|
|
4
|
+
"resourcetype": "RelatedConcepts",
|
|
5
|
+
"filter": [
|
|
6
|
+
{
|
|
7
|
+
"entryDate": {
|
|
8
|
+
"type": "datefilter",
|
|
9
|
+
"label": "Entry date",
|
|
10
|
+
"format": "dd-MM-yyyy",
|
|
11
|
+
"formatlabel": "dd-mm-yyyy",
|
|
12
|
+
"operator": "greater-than-or-equal"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"modelCategory": {
|
|
17
|
+
"type": "stringfilter",
|
|
18
|
+
"label": "Model category",
|
|
19
|
+
"multiplechoice": false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"results": {
|
|
24
|
+
"concept": {
|
|
25
|
+
"metadata": {
|
|
26
|
+
"_id": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"attributes": [
|
|
31
|
+
{
|
|
32
|
+
"label": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"label": "concept label"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|