@beinformed/ui 1.9.0-beta.13 → 1.9.0-beta.14

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 (27) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/esm/models/attributes/AttributeContent.js +23 -12
  3. package/esm/models/attributes/AttributeContent.js.map +1 -1
  4. package/esm/models/attributes/AttributeDataHelper.js +2 -2
  5. package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
  6. package/esm/models/layouthint/LayoutHintCollection.js +3 -2
  7. package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
  8. package/lib/models/attributes/AttributeContent.js +24 -12
  9. package/lib/models/attributes/AttributeContent.js.flow +18 -9
  10. package/lib/models/attributes/AttributeContent.js.map +1 -1
  11. package/lib/models/attributes/AttributeDataHelper.js +2 -2
  12. package/lib/models/attributes/AttributeDataHelper.js.flow +2 -1
  13. package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
  14. package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +4 -2
  15. package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +16 -18
  16. package/lib/models/layouthint/LayoutHintCollection.js +4 -2
  17. package/lib/models/layouthint/LayoutHintCollection.js.flow +8 -7
  18. package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
  19. package/lib/models/types.js.flow +1 -0
  20. package/package.json +1 -1
  21. package/src/models/attributes/AttributeContent.js +18 -9
  22. package/src/models/attributes/AttributeDataHelper.js +2 -1
  23. package/src/models/attributes/__tests__/AttributeContent.spec.js +4 -2
  24. package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +16 -18
  25. package/src/models/form/__tests__/FormWithContentData.json +2 -1
  26. package/src/models/layouthint/LayoutHintCollection.js +8 -7
  27. package/src/models/types.js +1 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.9.0-beta.14](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.9.0-beta.13...v1.9.0-beta.14) (2021-09-21)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **form-content:** update structure of content in data ([044078f](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/044078f5ced2c61c9fcba7fe585029a022e3f3dd))
10
+
5
11
  ## [1.9.0-beta.13](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.9.0-beta.12...v1.9.0-beta.13) (2021-09-21)
6
12
 
7
13
  ### Bug Fixes
@@ -29,6 +29,7 @@ import { retrieveText } from "../../utils/helpers/text";
29
29
  import { hasAllContentInData } from "../../constants/Settings";
30
30
  import SectionModel from "../content/SectionModel";
31
31
  import LayoutHintCollection from "../layouthint/LayoutHintCollection";
32
+ import { isPlainObject } from "../../utils";
32
33
 
33
34
  var AttributeContent = /*#__PURE__*/function () {
34
35
  function AttributeContent(content) {
@@ -53,13 +54,29 @@ var AttributeContent = /*#__PURE__*/function () {
53
54
  }, {
54
55
  key: "header",
55
56
  get: function get() {
56
- var _this$_content, _this$_content$header, _this$_content2, _this$_content2$heade, _this$_content2$heade2;
57
+ var _this$_content, _this$_content$header, _this$_content2, _this$_content2$heade;
57
58
 
59
+ var headerLabel = null;
60
+ var headerDescription = null;
58
61
  var label = (_this$_content = this._content) === null || _this$_content === void 0 ? void 0 : (_this$_content$header = _this$_content.header) === null || _this$_content$header === void 0 ? void 0 : _this$_content$header.label;
59
- var description = (_this$_content2 = this._content) === null || _this$_content2 === void 0 ? void 0 : (_this$_content2$heade = _this$_content2.header) === null || _this$_content2$heade === void 0 ? void 0 : (_this$_content2$heade2 = _this$_content2$heade.description) === null || _this$_content2$heade2 === void 0 ? void 0 : _this$_content2$heade2.message;
62
+
63
+ if (label) {
64
+ headerLabel = label;
65
+ }
66
+
67
+ var description = (_this$_content2 = this._content) === null || _this$_content2 === void 0 ? void 0 : (_this$_content2$heade = _this$_content2.header) === null || _this$_content2$heade === void 0 ? void 0 : _this$_content2$heade.description;
68
+
69
+ if (description) {
70
+ if (isPlainObject(description) && "message" in description) {
71
+ headerDescription = description.message;
72
+ } else if (typeof description === "string") {
73
+ headerDescription = description;
74
+ }
75
+ }
76
+
60
77
  return {
61
- label: label,
62
- description: description
78
+ label: headerLabel,
79
+ description: headerDescription
63
80
  };
64
81
  }
65
82
  /**
@@ -138,15 +155,9 @@ var AttributeContent = /*#__PURE__*/function () {
138
155
  }, {
139
156
  key: "label",
140
157
  get: function get() {
141
- return this.header.label;
142
- }
143
- /**
144
- */
158
+ var _this$_content4;
145
159
 
146
- }, {
147
- key: "description",
148
- get: function get() {
149
- return this.header.description;
160
+ return (_this$_content4 = this._content) === null || _this$_content4 === void 0 ? void 0 : _this$_content4.label;
150
161
  }
151
162
  /**
152
163
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["retrieveText","hasAllContentInData","SectionModel","LayoutHintCollection","AttributeContent","content","_content","label","header","description","message","elements","element","propertyElement","layouthint","properties","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","elementName","collectionName","getContentElements","ids","property","type","keys","types","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,YAAT,QAA6B,0BAA7B;AACA,SAASC,mBAAT,QAAoC,0BAApC;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AASA,OAAOC,oBAAP,MAAiC,oCAAjC;;IAEMC,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;;AAAA;;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAOJ,mBAAmB,EAA1B;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAMM,KAAK,qBAAG,KAAKD,QAAR,4EAAG,eAAeE,MAAlB,0DAAG,sBAAuBD,KAArC;AACA,UAAME,W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D,GAAG,MAAH,CAAAA,GAAG,EAAUC,QAAQ,CAACC,IAAnB,CAAjB;AAAA,OAAvB,CAAP;AACD;AAED;AACF;;;;SACE,eAA6C;AAC3C,aAAO,KAAKH,kBAAL,CACL,qBADK,EAEL,eAFK,CAAP;AAID;AAED;AACF;AACA;;;;WACE,+BAAsBI,IAAtB,EAAoE;AAAA;;AAClE,aAAO,yCAAKZ,aAAL,kBAA0B,UAACC,YAAD;AAAA,eAC/B,0BAAAW,IAAI,MAAJ,CAAAA,IAAI,EAAUX,YAAY,CAACU,IAAvB,CAD2B;AAAA,OAA1B,CAAP;AAGD;AAED;AACF;;;;SACE,eAAoC;AAClC,aAAO,KAAKH,kBAAL,CAAsC,gBAAtC,EAAwD,UAAxD,CAAP;AACD;AAED;AACF;;;;WACE,2BAAkBK,KAAlB,EAA6D;AAAA;;AAC3D,aAAO,yCAAKT,QAAL,kBAAqB,UAACC,OAAD;AAAA,eAAa,0BAAAQ,KAAK,MAAL,CAAAA,KAAK,EAAUR,OAAO,CAACM,IAAlB,CAAlB;AAAA,OAArB,CAAP;AACD;AAED;AACF;;;;WACE,+BAA6D;AAC3D,UAAMG,gBAAgB,GAAG,EAAzB;;AAD2D,iDAGrC,KAAKV,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCS,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,qBAAST,OAAO,CAACW,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;;AAGH,eAAe3B,gBAAf","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport type {\n ContentData,\n PropertyData,\n TextFragmentData,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n const label = this._content?.header?.label;\n const description = this._content?.header?.description?.message;\n\n return { label, description };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (\"propertyElement\" in element) {\n // $FlowIssue\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (\"textFragmentElement\" in element) {\n const { label, layouthint, textfragments } =\n // $FlowIssue\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (\"contentElement\" in element) {\n // $FlowIssue\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this.header.label;\n }\n\n /**\n */\n get description(): ?string {\n return this.header.description;\n }\n\n /**\n */\n getContentElements<T>(elementName: string, collectionName: string): Array<T> {\n return this.elements\n .filter((element) => elementName in element)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElements<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by id\n */\n getConceptPropertiesByIds(ids: Array<string>): Array<PropertyData> {\n return this.properties.filter((property) => ids.includes(property.type));\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElements<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by type\n */\n getTextFragmentByKeys(keys: Array<string>): Array<TextFragmentData> {\n return this.textfragments.filter((textfragment) =>\n keys.includes(textfragment.type)\n );\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElements<SectionModel>(\"contentElement\", \"sections\");\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["retrieveText","hasAllContentInData","SectionModel","LayoutHintCollection","isPlainObject","AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","elementName","collectionName","getContentElements","ids","property","type","keys","types","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,YAAT,QAA6B,0BAA7B;AACA,SAASC,mBAAT,QAAoC,0BAApC;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AASA,OAAOC,oBAAP,MAAiC,oCAAjC;AACA,SAASC,aAAT,QAA8B,aAA9B;;IAEMC,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;;AAAA;;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAOL,mBAAmB,EAA1B;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIO,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;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;AAGH,eAAe7B,gBAAf","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport type {\n ContentData,\n PropertyData,\n TextFragmentData,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (\"propertyElement\" in element) {\n // $FlowIssue\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (\"textFragmentElement\" in element) {\n const { label, layouthint, textfragments } =\n // $FlowIssue\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (\"contentElement\" in element) {\n // $FlowIssue\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string, collectionName: string): Array<T> {\n return this.elements\n .filter((element) => elementName in element)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElements<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by id\n */\n getConceptPropertiesByIds(ids: Array<string>): Array<PropertyData> {\n return this.properties.filter((property) => ids.includes(property.type));\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElements<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by type\n */\n getTextFragmentByKeys(keys: Array<string>): Array<TextFragmentData> {\n return this.textfragments.filter((textfragment) =>\n keys.includes(textfragment.type)\n );\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElements<SectionModel>(\"contentElement\", \"sections\");\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
@@ -77,7 +77,7 @@ var AttributeDataHelper = /*#__PURE__*/function () {
77
77
 
78
78
  if (isPlainObject(parentData) && (_data$content = data.content) !== null && _data$content !== void 0 && _data$content[childKey]) {
79
79
  return _objectSpread(_objectSpread({}, parentData), {}, {
80
- content: data.content[childKey].content
80
+ content: data.content[childKey]
81
81
  });
82
82
  }
83
83
 
@@ -300,7 +300,7 @@ var AttributeDataHelper = /*#__PURE__*/function () {
300
300
  key: "content",
301
301
  get: function get() {
302
302
  if (this._attribute.content) {
303
- var pickedContent = pick(this._attribute.content, ["header", "elements", "layouthint"]);
303
+ var pickedContent = pick(this._attribute.content, ["header", "label", "elements", "layouthint"]);
304
304
 
305
305
  if (_Object$keys(pickedContent).length > 0) {
306
306
  return pickedContent;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"names":["cloneDeep","pick","has","isPlainObject","AttributeDataHelper","data","key","childrenKeys","_key","Array","isArray","_attribute","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","parentKey","childKey","elements","element","parentData","content","childData","keyObject","dynamicschema","dynamicschemaId","children","childrenIsArray","value","createChild","attribute","suggestions","suggestion","options","option","selected","code","static","attrDS","message","isResult","referenceDate","pickedContent","length","links","child","subChild","getData"],"mappings":";;;;;;;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,kBAAtB;AACA,OAAOC,IAAP,MAAiB,aAAjB;AAEA,SAASC,GAAT,EAAcC,aAAd,QAAmC,6BAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;;IACMC,mB;AAMJ;AACF;AACE,+BACEC,IADF,EAEEC,GAFF,EAGEC,YAHF,EAIE;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACA,SAAKC,IAAL,GAAYF,GAAZ;;AAEA,QAAIG,KAAK,CAACC,OAAN,CAAcL,IAAd,CAAJ,EAAyB;AACvB,WAAKM,UAAL,GACE,sBAAAN,IAAI,MAAJ,CAAAA,IAAI,EACF,UAACO,IAAD;AAAA,eACEA,IAAI,CAACC,SAAL,KAAmBP,GAAnB,IAA0BM,IAAI,CAACE,IAAL,KAAcR,GAAxC,IAA+CM,IAAI,CAACG,KAAL,KAAeT,GADhE;AAAA,OADE,CAAJ,IAGK,EAJP;AAKA,WAAKU,MAAL,GAAc,KAAKC,QAAL,CAAc,KAAKN,UAAnB,CAAd;AACD,KAPD,MAOO;AACL,UAAMO,aAAa,GAAGlB,SAAS,CAACK,IAAD,CAA/B;AACAa,MAAAA,aAAa,CAACC,MAAd,GAAuBlB,IAAI,CAACI,IAAI,CAACc,MAAN,EAAc,CACvC,SADu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;;;;AAGH,eAAexB,mBAAf","sourcesContent":["// @flow\nimport cloneDeep from \"lodash/cloneDeep\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = cloneDeep(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n this._value = data[key] === undefined ? this.getValue(data) : data[key];\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey].content };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = []\n ): Array<AttributeDataHelper> {\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n })\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return null;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"elements\",\n \"layouthint\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n return {\n key: this.key,\n value: this.value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData()\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"file":"AttributeDataHelper.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"names":["cloneDeep","pick","has","isPlainObject","AttributeDataHelper","data","key","childrenKeys","_key","Array","isArray","_attribute","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","parentKey","childKey","elements","element","parentData","content","childData","keyObject","dynamicschema","dynamicschemaId","children","childrenIsArray","value","createChild","attribute","suggestions","suggestion","options","option","selected","code","static","attrDS","message","isResult","referenceDate","pickedContent","length","links","child","subChild","getData"],"mappings":";;;;;;;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,kBAAtB;AACA,OAAOC,IAAP,MAAiB,aAAjB;AAEA,SAASC,GAAT,EAAcC,aAAd,QAAmC,6BAAn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AAEL6B,QAAAA,KAAK,EAAE,KAAKA,KAFP;AAGLS,QAAAA,MAAM,EAAE,KAAKA,MAHR;AAILzB,QAAAA,MAAM,EAAE,KAAKgC,KAJR;AAKLpB,QAAAA,aAAa,EAAE,KAAKA,aALf;AAMLC,QAAAA,eAAe,EAAE,KAAKA,eANjB;AAOLQ,QAAAA,OAAO,EAAE,KAAKA,OAPT;AAQLM,QAAAA,OAAO,EAAE,KAAKA,OART;AASLC,QAAAA,QAAQ,EAAE,KAAKA,QATV;AAULC,QAAAA,aAAa,EAAE,KAAKA,aAVf;AAWLf,QAAAA,QAAQ,EAAE,sCAAKA,QAAL,kBAAkB,UAACmB,KAAD;AAAA,iBAC1B3C,KAAK,CAACC,OAAN,CAAc0C,KAAd,IACI,qBAAAA,KAAK,MAAL,CAAAA,KAAK,EAAK,UAACC,QAAD;AAAA,mBAAcA,QAAQ,CAACC,OAAT,EAAd;AAAA,WAAL,CADT,GAEIF,KAAK,CAACE,OAAN,EAHsB;AAAA,SAAlB,CAXL;AAgBL1B,QAAAA,OAAO,EAAE,KAAKA;AAhBT,OAAP;AAkBD;;;;;;AAGH,eAAexB,mBAAf","sourcesContent":["// @flow\nimport cloneDeep from \"lodash/cloneDeep\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = cloneDeep(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n this._value = data[key] === undefined ? this.getValue(data) : data[key];\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey] };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = []\n ): Array<AttributeDataHelper> {\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n })\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return null;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"label\",\n \"elements\",\n \"layouthint\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n return {\n key: this.key,\n value: this.value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData()\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"file":"AttributeDataHelper.js"}
@@ -5,6 +5,7 @@ import _inherits from "@babel/runtime-corejs3/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime-corejs3/helpers/esm/getPrototypeOf";
7
7
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
8
+ import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
8
9
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
9
10
  import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
10
11
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
@@ -72,7 +73,7 @@ var LayoutHintCollection = /*#__PURE__*/function (_BaseCollection) {
72
73
  }
73
74
 
74
75
  var hintArray = hints.length > 0 ? _concatInstanceProperty(_context = []).call(_context, hints) : [];
75
- return hintArray.some(function (hint) {
76
+ return _flatInstanceProperty(hintArray).call(hintArray).some(function (hint) {
76
77
  var _context2;
77
78
 
78
79
  return _includesInstanceProperty(_context2 = _this2.layouthint).call(_context2, hint) || _this2.layouthint.some(function (hint2) {
@@ -99,7 +100,7 @@ var LayoutHintCollection = /*#__PURE__*/function (_BaseCollection) {
99
100
  }
100
101
 
101
102
  var hintArray = hints.length > 0 ? _concatInstanceProperty(_context3 = []).call(_context3, hints) : [];
102
- return hintArray.some(function (hint) {
103
+ return _flatInstanceProperty(hintArray).call(hintArray).some(function (hint) {
103
104
  var _context4;
104
105
 
105
106
  return _includesInstanceProperty(_context4 = _this3.layouthint).call(_context4, hint);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/layouthint/LayoutHintCollection.js"],"names":["BaseCollection","IllegalArgumentException","LayoutHintCollection","layouthint","Array","isArray","collection","hints","hintArray","length","some","hint","hint2","foundHint","toString","checkHint","substr","match","getByLayoutHint","has","value","getLayoutHintValue","split"],"mappings":";;;;;;;;;;;;;;;;AACA,OAAOA,cAAP,MAA2B,wBAA3B;AACA,SAASC,wBAAT,QAAyC,kBAAzC;AAEA;AACA;AACA;;IACqBC,oB;;;;;AACnB;AACF;AACA;AACE,kCAA4C;AAAA;;AAAA,QAAhCC,UAAgC,uEAAJ,EAAI;;AAAA;;AAC1C;;AAEA,QAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,UAAd,CAAL,EAAgC;AAC9B,YAAM,IAAIF,wBAAJ,WAAgCE,UAAhC,sBAAN;AACD;;AAED,UAAKG,UAAL,GAAkBH,UAAlB;AAP0C;AAQ3C;AAED;AACF;AACA;;;;;SACE,eAAgC;AAC9B,aAAO,KAAKG,UAAZ;AACD;AAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,eAAsC;AAAA;AAAA;;AAAA,wCAA/BC,KAA+B;AAA/BA,QAAAA,KAA+B;AAAA;;AACpC,UAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,GAAe,CAAf,yDAAuBF,KAAvB,IAAgC,EAAlD;AAEA,aAAOC,SAAS,CAACE,IAAV,CACL,UAACC,IAAD;AAAA;;AAAA,eACE,sCAAA,MAAI,CAACR,UAAL,kBAAyBQ,IAAzB,KACA,MAAI,CAACR,UAAL,CAAgBO,IAAhB,CAAqB,UAACE,KAAD;AAAA,iBAAW,4BAAAA,KAAK,MAAL,CAAAA,KAAK,EAAYD,IAAZ,CAAhB;AAAA,SAArB,CAFF;AAAA,OADK,CAAP;AAKD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;WACE,oBAA2C;AAAA;AAAA;;AAAA,yCAA/BJ,KAA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ACD,MAAN,CAAaD,SAAS,CAACN,MAAV,GAAmB,CAAhC,CAAP;AACD;AAED;AACF;AACA;AACA;;;;WACE,6BAAoBE,IAApB,EAAwD;AACtD,UAAI,CAAC,KAAKQ,GAAL,CAASR,IAAT,CAAL,EAAqB;AACnB,eAAO,IAAP;AACD;;AAED,UAAMS,KAAK,GAAG,KAAKC,kBAAL,CAAwBV,IAAxB,CAAd;;AAEA,UAAI,CAACS,KAAL,EAAY;AACV,eAAO,EAAP;AACD;;AAED,aAAOA,KAAK,CAACE,KAAN,CAAY,GAAZ,CAAP;AACD;;;;EA1G+CtB,c;;SAA7BE,oB","sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\n/**\n * Collection of layouthint\n */\nexport default class LayoutHintCollection extends BaseCollection<string> {\n /**\n * Constructs the layouthint collection\n */\n constructor(layouthint: Array<string> = []) {\n super();\n\n if (!Array.isArray(layouthint)) {\n throw new IllegalArgumentException(`${layouthint} is not an Array`);\n }\n\n this.collection = layouthint;\n }\n\n /**\n * Retrieve layout hints\n */\n get layouthint(): Array<string> {\n return this.collection;\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration\n * This method matches all exact matches and hints starting with. For example\n * when calling layouth.has(\"hide\"), this will return true for both \"hide\" and \"hide-when-empty\".\n * If only exact matches are required, use the method {@link hasExact}.\n */\n has(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n\n return hintArray.some(\n (hint) =>\n this.layouthint.includes(hint) ||\n this.layouthint.some((hint2) => hint2.startsWith(hint))\n );\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration,\n * only checks on exact matches.\n * If layouthints that start with the given hint should also match, use {@link has}.\n * @param hints\n * @returns {boolean}\n */\n hasExact(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n\n return hintArray.some((hint) => this.layouthint.includes(hint));\n }\n\n /**\n * Retrieve the first layouthint starting with hint\n */\n getByLayoutHint(hint: Function | string): null | string {\n let foundHint = null;\n\n if (typeof hint === \"function\") {\n foundHint = this.layouthint.find(hint);\n }\n\n if (typeof hint === \"string\") {\n foundHint = this.layouthint.find((hint2) =>\n hint2.startsWith(hint.toString())\n );\n }\n\n return foundHint || null;\n }\n\n /**\n * Get the value of a specific hint\n * Format: hint=value\n */\n getLayoutHintValue(hint: string): ?string {\n const checkHint = hint.endsWith(\":\")\n ? hint.substr(0, hint.length - 1)\n : hint;\n\n const match = this.getByLayoutHint(\n (hint2) =>\n hint2.startsWith(`${checkHint}=`) || hint2.startsWith(`${checkHint}:`)\n );\n\n if (!match) {\n return null;\n }\n\n return match.substr(checkHint.length + 1);\n }\n\n /**\n * Get an array of multiple values from a specific hint\n * Format: hint=value1;value2;value3\n */\n getLayoutHintValues(hint: string): Array<string> | null {\n if (!this.has(hint)) {\n return null;\n }\n\n const value = this.getLayoutHintValue(hint);\n\n if (!value) {\n return [];\n }\n\n return value.split(\";\");\n }\n}\n"],"file":"LayoutHintCollection.js"}
1
+ {"version":3,"sources":["../../../src/models/layouthint/LayoutHintCollection.js"],"names":["BaseCollection","IllegalArgumentException","LayoutHintCollection","layouthint","Array","isArray","collection","hints","hintArray","length","some","hint","hint2","foundHint","toString","checkHint","substr","match","getByLayoutHint","has","value","getLayoutHintValue","split"],"mappings":";;;;;;;;;;;;;;;;;AACA,OAAOA,cAAP,MAA2B,wBAA3B;AACA,SAASC,wBAAT,QAAyC,kBAAzC;AAEA;AACA;AACA;;IACqBC,oB;;;;;AACnB;AACF;AACA;AACE,kCAA4C;AAAA;;AAAA,QAAhCC,UAAgC,uEAAJ,EAAI;;AAAA;;AAC1C;;AAEA,QAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,UAAd,CAAL,EAAgC;AAC9B,YAAM,IAAIF,wBAAJ,WAAgCE,UAAhC,sBAAN;AACD;;AAED,UAAKG,UAAL,GAAkBH,UAAlB;AAP0C;AAQ3C;AAED;AACF;AACA;;;;;SACE,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ACS,KAAD;AAAA,iBAC/B,4BAAAA,KAAK,MAAL,CAAAA,KAAK,EAAYD,IAAI,CAACG,QAAL,EAAZ,CAD0B;AAAA,SAArB,CAAZ;AAGD;;AAED,aAAOD,SAAS,IAAI,IAApB;AACD;AAED;AACF;AACA;AACA;;;;WACE,4BAAmBF,IAAnB,EAA0C;AACxC,UAAMI,SAAS,GAAG,0BAAAJ,IAAI,MAAJ,CAAAA,IAAI,EAAU,GAAV,CAAJ,GACdA,IAAI,CAACK,MAAL,CAAY,CAAZ,EAAeL,IAAI,CAACF,MAAL,GAAc,CAA7B,CADc,GAEdE,IAFJ;AAIA,UAAMM,KAAK,GAAG,KAAKC,eAAL,CACZ,UAACN,KAAD;AAAA,eACE,4BAAAA,KAAK,MAAL,CAAAA,KAAK,YAAeG,SAAf,OAAL,IAAqC,4BAAAH,KAAK,MAAL,CAAAA,KAAK,YAAeG,SAAf,OAD5C;AAAA,OADY,CAAd;;AAKA,UAAI,CAACE,KAAL,EAAY;AACV,eAAO,IAAP;AACD;;AAED,aAAOA,KAAK,CAACD,MAAN,CAAaD,SAAS,CAACN,MAAV,GAAmB,CAAhC,CAAP;AACD;AAED;AACF;AACA;AACA;;;;WACE,6BAAoBE,IAApB,EAAwD;AACtD,UAAI,CAAC,KAAKQ,GAAL,CAASR,IAAT,CAAL,EAAqB;AACnB,eAAO,IAAP;AACD;;AAED,UAAMS,KAAK,GAAG,KAAKC,kBAAL,CAAwBV,IAAxB,CAAd;;AAEA,UAAI,CAACS,KAAL,EAAY;AACV,eAAO,EAAP;AACD;;AAED,aAAOA,KAAK,CAACE,KAAN,CAAY,GAAZ,CAAP;AACD;;;;EA3G+CtB,c;;SAA7BE,oB","sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\n/**\n * Collection of layouthint\n */\nexport default class LayoutHintCollection extends BaseCollection<string> {\n /**\n * Constructs the layouthint collection\n */\n constructor(layouthint: Array<string> = []) {\n super();\n\n if (!Array.isArray(layouthint)) {\n throw new IllegalArgumentException(`${layouthint} is not an Array`);\n }\n\n this.collection = layouthint;\n }\n\n /**\n * Retrieve layout hints\n */\n get layouthint(): Array<string> {\n return this.collection;\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration\n * This method matches all exact matches and hints starting with. For example\n * when calling layouth.has(\"hide\"), this will return true for both \"hide\" and \"hide-when-empty\".\n * If only exact matches are required, use the method {@link hasExact}.\n */\n has(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n\n return hintArray\n .flat()\n .some(\n (hint) =>\n this.layouthint.includes(hint) ||\n this.layouthint.some((hint2) => hint2.startsWith(hint))\n );\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration,\n * only checks on exact matches.\n * If layouthints that start with the given hint should also match, use {@link has}.\n * @param hints\n * @returns {boolean}\n */\n hasExact(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n return hintArray.flat().some((hint) => this.layouthint.includes(hint));\n }\n\n /**\n * Retrieve the first layouthint starting with hint\n */\n getByLayoutHint(hint: Function | string): null | string {\n let foundHint = null;\n\n if (typeof hint === \"function\") {\n foundHint = this.layouthint.find(hint);\n }\n\n if (typeof hint === \"string\") {\n foundHint = this.layouthint.find((hint2) =>\n hint2.startsWith(hint.toString())\n );\n }\n\n return foundHint || null;\n }\n\n /**\n * Get the value of a specific hint\n * Format: hint=value\n */\n getLayoutHintValue(hint: string): ?string {\n const checkHint = hint.endsWith(\":\")\n ? hint.substr(0, hint.length - 1)\n : hint;\n\n const match = this.getByLayoutHint(\n (hint2) =>\n hint2.startsWith(`${checkHint}=`) || hint2.startsWith(`${checkHint}:`)\n );\n\n if (!match) {\n return null;\n }\n\n return match.substr(checkHint.length + 1);\n }\n\n /**\n * Get an array of multiple values from a specific hint\n * Format: hint=value1;value2;value3\n */\n getLayoutHintValues(hint: string): Array<string> | null {\n if (!this.has(hint)) {\n return null;\n }\n\n const value = this.getLayoutHintValue(hint);\n\n if (!value) {\n return [];\n }\n\n return value.split(\";\");\n }\n}\n"],"file":"LayoutHintCollection.js"}
@@ -49,6 +49,8 @@ var _SectionModel = _interopRequireDefault(require("../content/SectionModel"));
49
49
 
50
50
  var _LayoutHintCollection = _interopRequireDefault(require("../layouthint/LayoutHintCollection"));
51
51
 
52
+ var _utils = require("../../utils");
53
+
52
54
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
53
55
 
54
56
  function _unsupportedIterableToArray(o, minLen) { var _context7; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -80,13 +82,29 @@ var AttributeContent = /*#__PURE__*/function () {
80
82
  }, {
81
83
  key: "header",
82
84
  get: function get() {
83
- var _this$_content, _this$_content$header, _this$_content2, _this$_content2$heade, _this$_content2$heade2;
85
+ var _this$_content, _this$_content$header, _this$_content2, _this$_content2$heade;
84
86
 
87
+ var headerLabel = null;
88
+ var headerDescription = null;
85
89
  var label = (_this$_content = this._content) === null || _this$_content === void 0 ? void 0 : (_this$_content$header = _this$_content.header) === null || _this$_content$header === void 0 ? void 0 : _this$_content$header.label;
86
- var description = (_this$_content2 = this._content) === null || _this$_content2 === void 0 ? void 0 : (_this$_content2$heade = _this$_content2.header) === null || _this$_content2$heade === void 0 ? void 0 : (_this$_content2$heade2 = _this$_content2$heade.description) === null || _this$_content2$heade2 === void 0 ? void 0 : _this$_content2$heade2.message;
90
+
91
+ if (label) {
92
+ headerLabel = label;
93
+ }
94
+
95
+ var description = (_this$_content2 = this._content) === null || _this$_content2 === void 0 ? void 0 : (_this$_content2$heade = _this$_content2.header) === null || _this$_content2$heade === void 0 ? void 0 : _this$_content2$heade.description;
96
+
97
+ if (description) {
98
+ if ((0, _utils.isPlainObject)(description) && "message" in description) {
99
+ headerDescription = description.message;
100
+ } else if (typeof description === "string") {
101
+ headerDescription = description;
102
+ }
103
+ }
104
+
87
105
  return {
88
- label: label,
89
- description: description
106
+ label: headerLabel,
107
+ description: headerDescription
90
108
  };
91
109
  }
92
110
  /**
@@ -165,15 +183,9 @@ var AttributeContent = /*#__PURE__*/function () {
165
183
  }, {
166
184
  key: "label",
167
185
  get: function get() {
168
- return this.header.label;
169
- }
170
- /**
171
- */
186
+ var _this$_content4;
172
187
 
173
- }, {
174
- key: "description",
175
- get: function get() {
176
- return this.header.description;
188
+ return (_this$_content4 = this._content) === null || _this$_content4 === void 0 ? void 0 : _this$_content4.label;
177
189
  }
178
190
  /**
179
191
  */
@@ -11,6 +11,7 @@ import type {
11
11
  } from "../types";
12
12
  import type SubSectionModel from "../content/SubSectionModel";
13
13
  import LayoutHintCollection from "../layouthint/LayoutHintCollection";
14
+ import { isPlainObject } from "../../utils";
14
15
 
15
16
  class AttributeContent {
16
17
  _content: ?ContentData;
@@ -31,10 +32,24 @@ class AttributeContent {
31
32
  label: ?string,
32
33
  description: ?string,
33
34
  } {
35
+ let headerLabel = null;
36
+ let headerDescription = null;
37
+
34
38
  const label = this._content?.header?.label;
35
- const description = this._content?.header?.description?.message;
39
+ if (label) {
40
+ headerLabel = label;
41
+ }
42
+
43
+ const description = this._content?.header?.description;
44
+ if (description) {
45
+ if (isPlainObject(description) && "message" in description) {
46
+ headerDescription = description.message;
47
+ } else if (typeof description === "string") {
48
+ headerDescription = description;
49
+ }
50
+ }
36
51
 
37
- return { label, description };
52
+ return { label: headerLabel, description: headerDescription };
38
53
  }
39
54
 
40
55
  /**
@@ -96,13 +111,7 @@ class AttributeContent {
96
111
  /**
97
112
  */
98
113
  get label(): ?string {
99
- return this.header.label;
100
- }
101
-
102
- /**
103
- */
104
- get description(): ?string {
105
- return this.header.description;
114
+ return this._content?.label;
106
115
  }
107
116
 
108
117
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","ids","property","type","keys","types","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AASA;;;;;;;;;;;;IAEMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAME,KAAK,qBAAG,KAAKD,QAAR,4EAAG,eAAeE,MAAlB,0DAAG,sBAAuBD,KAArC;AACA,UAAME,WAAW,sBAAG,KAAKH,QAAR,6EAAG,gBAAeE,MAAlB,oFAAG,sBAAuBC,WAA1B,2DAAG,uBAAoCC,OAAxD;AAEA,aAAO;AAAEH,QAAAA,KAAK,EAALA,KAAF;AAASE,QAAAA,WAAW,EAAXA;AAAT,OAA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F;AACA;;;;WACE,+BAAsBI,IAAtB,EAAoE;AAAA;;AAClE,aAAO,sCAAKb,aAAL,kBAA0B,UAACC,YAAD;AAAA,eAC/B,uBAAAY,IAAI,MAAJ,CAAAA,IAAI,EAAUZ,YAAY,CAACW,IAAvB,CAD2B;AAAA,OAA1B,CAAP;AAGD;AAED;AACF;;;;SACE,eAAoC;AAClC,aAAO,KAAKH,kBAAL,CAAsC,gBAAtC,EAAwD,UAAxD,CAAP;AACD;AAED;AACF;;;;WACE,2BAAkBK,KAAlB,EAA6D;AAAA;;AAC3D,aAAO,sCAAKV,QAAL,kBAAqB,UAACC,OAAD;AAAA,eAAa,uBAAAS,KAAK,MAAL,CAAAA,KAAK,EAAUT,OAAO,CAACO,IAAlB,CAAlB;AAAA,OAArB,CAAP;AACD;AAED;AACF;;;;WACE,+BAA6D;AAC3D,UAAMG,gBAAgB,GAAG,EAAzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY7B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport type {\n ContentData,\n PropertyData,\n TextFragmentData,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n const label = this._content?.header?.label;\n const description = this._content?.header?.description?.message;\n\n return { label, description };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (\"propertyElement\" in element) {\n // $FlowIssue\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (\"textFragmentElement\" in element) {\n const { label, layouthint, textfragments } =\n // $FlowIssue\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (\"contentElement\" in element) {\n // $FlowIssue\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this.header.label;\n }\n\n /**\n */\n get description(): ?string {\n return this.header.description;\n }\n\n /**\n */\n getContentElements<T>(elementName: string, collectionName: string): Array<T> {\n return this.elements\n .filter((element) => elementName in element)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElements<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by id\n */\n getConceptPropertiesByIds(ids: Array<string>): Array<PropertyData> {\n return this.properties.filter((property) => ids.includes(property.type));\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElements<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by type\n */\n getTextFragmentByKeys(keys: Array<string>): Array<TextFragmentData> {\n return this.textfragments.filter((textfragment) =>\n keys.includes(textfragment.type)\n );\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElements<SectionModel>(\"contentElement\", \"sections\");\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","ids","property","type","keys","types","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AASA;;AACA;;;;;;;;;;;;IAEMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG,KAAKL,QAAR,6EAAG,gBAAeI,MAAlB,0DAAG,sBAAuBC,WAA3C;;AACA,UAAIA,WAAJ,EAAiB;AACf,YAAI,0BAAcA,WAAd,KAA8B,aAAaA,WAA/C,EAA4D;AAC1DH,UAAAA,iBAAiB,GAAGG,WAAW,CAACC,OAAhC;AACD,SAFD,MAEO,IAAI,OAAOD,WAAP,KAAuB,QAA3B,EAA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;;SACE,eAA6C;AAC3C,aAAO,KAAKH,kBAAL,CACL,qBADK,EAEL,eAFK,CAAP;AAID;AAED;AACF;AACA;;;;WACE,+BAAsBI,IAAtB,EAAoE;AAAA;;AAClE,aAAO,sCAAKb,aAAL,kBAA0B,UAACC,YAAD;AAAA,eAC/B,uBAAAY,IAAI,MAAJ,CAAAA,IAAI,EAAUZ,YAAY,CAACW,IAAvB,CAD2B;AAAA,OAA1B,CAAP;AAGD;AAED;AACF;;;;SACE,eAAoC;AAClC,aAAO,KAAKH,kBAAL,CAAsC,gBAAtC,EAAwD,UAAxD,CAAP;AACD;AAED;AACF;;;;WACE,2BAAkBK,KAAlB,EAA6D;AAAA;;AAC3D,aAAO,sCAAKV,QAAL,kBAAqB,UAACC,OAAD;AAAA,eAAa,uBAAAS,KAAK,MAAL,CAAAA,KAAK,EAAUT,OAAO,CAACO,IAAlB,CAAlB;AAAA,OAArB,CAAP;AACD;AAED;AACF;;;;WACE,+BAA6D;AAC3D,UAAMG,gBAAgB,GAAG,EAAzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport type {\n ContentData,\n PropertyData,\n TextFragmentData,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (\"propertyElement\" in element) {\n // $FlowIssue\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (\"textFragmentElement\" in element) {\n const { label, layouthint, textfragments } =\n // $FlowIssue\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (\"contentElement\" in element) {\n // $FlowIssue\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string, collectionName: string): Array<T> {\n return this.elements\n .filter((element) => elementName in element)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElements<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by id\n */\n getConceptPropertiesByIds(ids: Array<string>): Array<PropertyData> {\n return this.properties.filter((property) => ids.includes(property.type));\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElements<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by type\n */\n getTextFragmentByKeys(keys: Array<string>): Array<TextFragmentData> {\n return this.textfragments.filter((textfragment) =>\n keys.includes(textfragment.type)\n );\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElements<SectionModel>(\"contentElement\", \"sections\");\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
@@ -98,7 +98,7 @@ var AttributeDataHelper = /*#__PURE__*/function () {
98
98
 
99
99
  if ((0, _objects.isPlainObject)(parentData) && (_data$content = data.content) !== null && _data$content !== void 0 && _data$content[childKey]) {
100
100
  return _objectSpread(_objectSpread({}, parentData), {}, {
101
- content: data.content[childKey].content
101
+ content: data.content[childKey]
102
102
  });
103
103
  }
104
104
 
@@ -321,7 +321,7 @@ var AttributeDataHelper = /*#__PURE__*/function () {
321
321
  key: "content",
322
322
  get: function get() {
323
323
  if (this._attribute.content) {
324
- var pickedContent = (0, _pick.default)(this._attribute.content, ["header", "elements", "layouthint"]);
324
+ var pickedContent = (0, _pick.default)(this._attribute.content, ["header", "label", "elements", "layouthint"]);
325
325
 
326
326
  if ((0, _keys.default)(pickedContent).length > 0) {
327
327
  return pickedContent;
@@ -65,7 +65,7 @@ class AttributeDataHelper {
65
65
  } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {
66
66
  const parentData = data[parentKey];
67
67
  if (isPlainObject(parentData) && data.content?.[childKey]) {
68
- return { ...parentData, content: data.content[childKey].content };
68
+ return { ...parentData, content: data.content[childKey] };
69
69
  }
70
70
  return parentData;
71
71
  } else if (has(data, childKey) && isPlainObject(data[childKey])) {
@@ -266,6 +266,7 @@ class AttributeDataHelper {
266
266
  if (this._attribute.content) {
267
267
  const pickedContent = pick(this._attribute.content, [
268
268
  "header",
269
+ "label",
269
270
  "elements",
270
271
  "layouthint",
271
272
  ]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"names":["AttributeDataHelper","data","key","childrenKeys","_key","Array","isArray","_attribute","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","parentKey","childKey","elements","element","parentData","content","childData","keyObject","dynamicschema","dynamicschemaId","children","childrenIsArray","value","createChild","attribute","suggestions","suggestion","options","option","selected","code","static","attrDS","message","isResult","referenceDate","pickedContent","length","links","child","subChild","getData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;IACMA,mB;AAMJ;AACF;AACE,+BACEC,IADF,EAEEC,GAFF,EAGEC,YAHF,EAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAKC,IAAL,GAAYF,GAAZ;;AAEA,QAAIG,KAAK,CAACC,OAAN,CAAcL,IAAd,CAAJ,EAAyB;AACvB,WAAKM,UAAL,GACE,mBAAAN,IAAI,MAAJ,CAAAA,IAAI,EACF,UAACO,IAAD;AAAA,eACEA,IAAI,CAACC,SAAL,KAAmBP,GAAnB,IAA0BM,IAAI,CAACE,IAAL,KAAcR,GAAxC,IAA+CM,IAAI,CAACG,KAAL,KAAeT,GADhE;AAAA,OADE,CAAJ,IAGK,EAJP;AAKA,WAAKU,MAAL,GAAc,KAAKC,QAAL,CAAc,KAAKN,UAAnB,CAAd;AACD,KAPD,MAOO;AACL,UAAMO,aAAa,GAAG,wBAAUb,IAAV,CAAtB;AACAa,MAAAA,aAAa,CAACC,MAAd,GAAuB,mBAAKd,IAAI,CAACc,MAAV,EAAkB,CACvC,SADuC,EAEvC,UAFuC,EAGvC,eAHuC,EAIvC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SAAL,IAAkB,EAAzB;AACD;AAED;AACF;;;;SACE,eAAsB;AACpB,UAAI,KAAKV,UAAL,CAAgBiB,OAApB,EAA6B;AAC3B,YAAMqB,aAAa,GAAG,mBAAK,KAAKtC,UAAL,CAAgBiB,OAArB,EAA8B,CAClD,QADkD,EAElD,UAFkD,EAGlD,YAHkD,CAA9B,CAAtB;;AAMA,YAAI,mBAAYqB,aAAZ,EAA2BC,MAA3B,GAAoC,CAAxC,EAA2C;AACzC,iBAAOD,aAAP;AACD;AACF;;AAED,aAAO,IAAP;AACD;AAED;AACF;;;;WACE,mBAAkB;AAAA;;AAChB,aAAO;AACL3C,QAAAA,GAAG,EAAE,KAAKA,GADL;AAEL6B,QAAAA,KAAK,EAAE,KAAKA,KAFP;AAGLS,QAAAA,MAAM,EAAE,KAAKA,MAHR;AAILzB,QAAAA,MAAM,EAAE,KAAKgC,KAJR;AAKLpB,QAAAA,aAAa,EAAE,KAAKA,aALf;AAMLC,QAAAA,eAAe,EAAE,KAAKA,eANjB;AAOLQ,QAAAA,OAAO,EAAE,KAAKA,OAPT;AAQLM,QAAAA,OAAO,EAAE,KAAKA,OART;AASLC,QAAAA,QAAQ,EAAE,KAAKA,QATV;AAULC,QAAAA,aAAa,EAAE,KAAKA,aAVf;AAWLf,QAAAA,QAAQ,EAAE,mCAAKA,QAAL,kBAAkB,UAACmB,KAAD;AAAA,iBAC1B3C,KAAK,CAACC,OAAN,CAAc0C,KAAd,IACI,kBAAAA,KAAK,MAAL,CAAAA,KAAK,EAAK,UAACC,QAAD;AAAA,mBAAcA,QAAQ,CAACC,OAAT,EAAd;AAAA,WAAL,CADT,GAEIF,KAAK,CAACE,OAAN,EAHsB;AAAA,SAAlB,CAXL;AAgBL1B,QAAAA,OAAO,EAAE,KAAKA;AAhBT,OAAP;AAkBD;;;;;eAGYxB,mB","sourcesContent":["// @flow\nimport cloneDeep from \"lodash/cloneDeep\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = cloneDeep(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n this._value = data[key] === undefined ? this.getValue(data) : data[key];\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey].content };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = []\n ): Array<AttributeDataHelper> {\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n })\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return null;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"elements\",\n \"layouthint\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n return {\n key: this.key,\n value: this.value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData()\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"file":"AttributeDataHelper.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"names":["AttributeDataHelper","data","key","childrenKeys","_key","Array","isArray","_attribute","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","parentKey","childKey","elements","element","parentData","content","childData","keyObject","dynamicschema","dynamicschemaId","children","childrenIsArray","value","createChild","attribute","suggestions","suggestion","options","option","selected","code","static","attrDS","message","isResult","referenceDate","pickedContent","length","links","child","subChild","getData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;IACMA,mB;AAMJ;AACF;AACE,+BACEC,IADF,EAEEC,GAFF,EAGEC,YAHF,EAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAKC,IAAL,GAAYF,GAAZ;;AAEA,QAAIG,KAAK,CAACC,OAAN,CAAcL,IA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EAAE,KAAKA,QATV;AAULC,QAAAA,aAAa,EAAE,KAAKA,aAVf;AAWLf,QAAAA,QAAQ,EAAE,mCAAKA,QAAL,kBAAkB,UAACmB,KAAD;AAAA,iBAC1B3C,KAAK,CAACC,OAAN,CAAc0C,KAAd,IACI,kBAAAA,KAAK,MAAL,CAAAA,KAAK,EAAK,UAACC,QAAD;AAAA,mBAAcA,QAAQ,CAACC,OAAT,EAAd;AAAA,WAAL,CADT,GAEIF,KAAK,CAACE,OAAN,EAHsB;AAAA,SAAlB,CAXL;AAgBL1B,QAAAA,OAAO,EAAE,KAAKA;AAhBT,OAAP;AAkBD;;;;;eAGYxB,mB","sourcesContent":["// @flow\nimport cloneDeep from \"lodash/cloneDeep\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = cloneDeep(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n this._value = data[key] === undefined ? this.getValue(data) : data[key];\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey] };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = []\n ): Array<AttributeDataHelper> {\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n })\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return null;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"label\",\n \"elements\",\n \"layouthint\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n return {\n key: this.key,\n value: this.value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData()\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"file":"AttributeDataHelper.js"}
@@ -3,11 +3,12 @@ import SectionModel from "../../content/SectionModel";
3
3
 
4
4
  const json = {
5
5
  header: {
6
- label: "Blaastest geslaagd",
6
+ label: "Header label",
7
7
  description: {
8
8
  message: "Dit is de beschrijving",
9
9
  },
10
10
  },
11
+ label: "Blaastest geslaagd",
11
12
  elements: [
12
13
  {
13
14
  propertyElement: {
@@ -152,7 +153,8 @@ describe("AttributeContent", () => {
152
153
  it("Handles basic content elements", () => {
153
154
  const content = new AttributeContent(json);
154
155
  expect(content.label).toBe("Blaastest geslaagd");
155
- expect(content.description).toBe("Dit is de beschrijving");
156
+ expect(content.header.label).toBe("Header label");
157
+ expect(content.header.description).toBe("Dit is de beschrijving");
156
158
  expect(content.properties).toHaveLength(2);
157
159
  expect(content.textfragments).toHaveLength(1);
158
160
  expect(content.sections).toHaveLength(1);
@@ -499,25 +499,23 @@ describe("attributeDataHelper", () => {
499
499
  key: "results",
500
500
  content: {
501
501
  InvestigationNecessary: {
502
- content: {
503
- header: {
504
- label: "label",
505
- description: "description",
506
- },
507
- elements: [
508
- {
509
- textFragmentElement: {
510
- label: "Text fragment: Description",
511
- textfragments: [
512
- {
513
- text: "Text fragment for investigation necessary",
514
- },
515
- ],
516
- layouthint: ["full"],
517
- },
518
- },
519
- ],
502
+ header: {
503
+ label: "label",
504
+ description: "description",
520
505
  },
506
+ elements: [
507
+ {
508
+ textFragmentElement: {
509
+ label: "Text fragment: Description",
510
+ textfragments: [
511
+ {
512
+ text: "Text fragment for investigation necessary",
513
+ },
514
+ ],
515
+ layouthint: ["full"],
516
+ },
517
+ },
518
+ ],
521
519
  },
522
520
  },
523
521
  results: { InvestigationNecessary: true },
@@ -11,6 +11,8 @@ exports.default = void 0;
11
11
 
12
12
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
13
13
 
14
+ var _flat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/flat"));
15
+
14
16
  var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
15
17
 
16
18
  var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
@@ -90,7 +92,7 @@ var LayoutHintCollection = /*#__PURE__*/function (_BaseCollection) {
90
92
  }
91
93
 
92
94
  var hintArray = hints.length > 0 ? (0, _concat.default)(_context = []).call(_context, hints) : [];
93
- return hintArray.some(function (hint) {
95
+ return (0, _flat.default)(hintArray).call(hintArray).some(function (hint) {
94
96
  var _context2;
95
97
 
96
98
  return (0, _includes.default)(_context2 = _this2.layouthint).call(_context2, hint) || _this2.layouthint.some(function (hint2) {
@@ -117,7 +119,7 @@ var LayoutHintCollection = /*#__PURE__*/function (_BaseCollection) {
117
119
  }
118
120
 
119
121
  var hintArray = hints.length > 0 ? (0, _concat.default)(_context3 = []).call(_context3, hints) : [];
120
- return hintArray.some(function (hint) {
122
+ return (0, _flat.default)(hintArray).call(hintArray).some(function (hint) {
121
123
  var _context4;
122
124
 
123
125
  return (0, _includes.default)(_context4 = _this3.layouthint).call(_context4, hint);
@@ -35,11 +35,13 @@ export default class LayoutHintCollection extends BaseCollection<string> {
35
35
  has(...hints: Array<string>): boolean {
36
36
  const hintArray = hints.length > 0 ? [...hints] : [];
37
37
 
38
- return hintArray.some(
39
- (hint) =>
40
- this.layouthint.includes(hint) ||
41
- this.layouthint.some((hint2) => hint2.startsWith(hint))
42
- );
38
+ return hintArray
39
+ .flat()
40
+ .some(
41
+ (hint) =>
42
+ this.layouthint.includes(hint) ||
43
+ this.layouthint.some((hint2) => hint2.startsWith(hint))
44
+ );
43
45
  }
44
46
 
45
47
  /**
@@ -51,8 +53,7 @@ export default class LayoutHintCollection extends BaseCollection<string> {
51
53
  */
52
54
  hasExact(...hints: Array<string>): boolean {
53
55
  const hintArray = hints.length > 0 ? [...hints] : [];
54
-
55
- return hintArray.some((hint) => this.layouthint.includes(hint));
56
+ return hintArray.flat().some((hint) => this.layouthint.includes(hint));
56
57
  }
57
58
 
58
59
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/layouthint/LayoutHintCollection.js"],"names":["LayoutHintCollection","layouthint","Array","isArray","IllegalArgumentException","collection","hints","hintArray","length","some","hint","hint2","foundHint","toString","checkHint","substr","match","getByLayoutHint","has","value","getLayoutHintValue","split","BaseCollection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;AAEA;AACA;AACA;IACqBA,oB;;;;;AACnB;AACF;AACA;AACE,kCAA4C;AAAA;;AAAA,QAAhCC,UAAgC,uEAAJ,EAAI;AAAA;AAC1C;;AAEA,QAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,UAAd,CAAL,EAAgC;AAC9B,YAAM,IAAIG,oCAAJ,WAAgCH,UAAhC,sBAAN;AACD;;AAED,UAAKI,UAAL,GAAkBJ,UAAlB;AAP0C;AAQ3C;AAED;AACF;AACA;;;;;SACE,eAAgC;AAC9B,aAAO,KAAKI,UAAZ;AACD;AAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,eAAsC;AAAA;AAAA;;AAAA,wCAA/BC,KAA+B;AAA/BA,QAAAA,KAA+B;AAAA;;AACpC,UAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,GAAe,CAAf,sDAAuBF,KAAvB,IAAgC,EAAlD;AAEA,aAAOC,SAAS,CAACE,IAAV,CACL,UAACC,IAAD;AAAA;;AAAA,eACE,mCAAA,MAAI,CAACT,UAAL,kBAAyBS,IAAzB,KACA,MAAI,CAACT,UAAL,CAAgBQ,IAAhB,CAAqB,UAACE,KAAD;AAAA,iBAAW,yBAAAA,KAAK,MAAL,CAAAA,KAAK,EAAYD,IAAZ,CAAhB;AAAA,SAArB,CAFF;AAAA,OADK,CAAP;AAKD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;WACE,oBAA2C;AAAA;AAAA;;AAAA,yCAA/BJ,KAA+B;AAA/BA,QAAAA,KAA+B;AAAA;;AACzC,UAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,GAAe,CAAf,wDAAuBF,KAAvB,IAAgC,EAAlD;AAE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,KAAKQ,GAAL,CAASR,IAAT,CAAL,EAAqB;AACnB,eAAO,IAAP;AACD;;AAED,UAAMS,KAAK,GAAG,KAAKC,kBAAL,CAAwBV,IAAxB,CAAd;;AAEA,UAAI,CAACS,KAAL,EAAY;AACV,eAAO,EAAP;AACD;;AAED,aAAOA,KAAK,CAACE,KAAN,CAAY,GAAZ,CAAP;AACD;;;EA1G+CC,wB","sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\n/**\n * Collection of layouthint\n */\nexport default class LayoutHintCollection extends BaseCollection<string> {\n /**\n * Constructs the layouthint collection\n */\n constructor(layouthint: Array<string> = []) {\n super();\n\n if (!Array.isArray(layouthint)) {\n throw new IllegalArgumentException(`${layouthint} is not an Array`);\n }\n\n this.collection = layouthint;\n }\n\n /**\n * Retrieve layout hints\n */\n get layouthint(): Array<string> {\n return this.collection;\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration\n * This method matches all exact matches and hints starting with. For example\n * when calling layouth.has(\"hide\"), this will return true for both \"hide\" and \"hide-when-empty\".\n * If only exact matches are required, use the method {@link hasExact}.\n */\n has(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n\n return hintArray.some(\n (hint) =>\n this.layouthint.includes(hint) ||\n this.layouthint.some((hint2) => hint2.startsWith(hint))\n );\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration,\n * only checks on exact matches.\n * If layouthints that start with the given hint should also match, use {@link has}.\n * @param hints\n * @returns {boolean}\n */\n hasExact(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n\n return hintArray.some((hint) => this.layouthint.includes(hint));\n }\n\n /**\n * Retrieve the first layouthint starting with hint\n */\n getByLayoutHint(hint: Function | string): null | string {\n let foundHint = null;\n\n if (typeof hint === \"function\") {\n foundHint = this.layouthint.find(hint);\n }\n\n if (typeof hint === \"string\") {\n foundHint = this.layouthint.find((hint2) =>\n hint2.startsWith(hint.toString())\n );\n }\n\n return foundHint || null;\n }\n\n /**\n * Get the value of a specific hint\n * Format: hint=value\n */\n getLayoutHintValue(hint: string): ?string {\n const checkHint = hint.endsWith(\":\")\n ? hint.substr(0, hint.length - 1)\n : hint;\n\n const match = this.getByLayoutHint(\n (hint2) =>\n hint2.startsWith(`${checkHint}=`) || hint2.startsWith(`${checkHint}:`)\n );\n\n if (!match) {\n return null;\n }\n\n return match.substr(checkHint.length + 1);\n }\n\n /**\n * Get an array of multiple values from a specific hint\n * Format: hint=value1;value2;value3\n */\n getLayoutHintValues(hint: string): Array<string> | null {\n if (!this.has(hint)) {\n return null;\n }\n\n const value = this.getLayoutHintValue(hint);\n\n if (!value) {\n return [];\n }\n\n return value.split(\";\");\n }\n}\n"],"file":"LayoutHintCollection.js"}
1
+ {"version":3,"sources":["../../../src/models/layouthint/LayoutHintCollection.js"],"names":["LayoutHintCollection","layouthint","Array","isArray","IllegalArgumentException","collection","hints","hintArray","length","some","hint","hint2","foundHint","toString","checkHint","substr","match","getByLayoutHint","has","value","getLayoutHintValue","split","BaseCollection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;AAEA;AACA;AACA;IACqBA,oB;;;;;AACnB;AACF;AACA;AACE,kCAA4C;AAAA;;AAAA,QAAhCC,UAAgC,uEAAJ,EAAI;AAAA;AAC1C;;AAEA,QAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,UAAd,CAAL,EAAgC;AAC9B,YAAM,IAAIG,oCAAJ,WAAgCH,UAAhC,sBAAN;AACD;;AAED,UAAKI,UAAL,GAAkBJ,UAAlB;AAP0C;AAQ3C;AAED;AACF;AACA;;;;;SACE,eAAgC;AAC9B,aAAO,KAAKI,UAAZ;AACD;AAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,eAAsC;AAAA;AAAA;;AAAA,wCAA/BC,KAA+B;AAA/BA,QAAAA,KAA+B;AAAA;;AACpC,UAAMC,SAAS,GAAGD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;;;WACE,4BAAmBF,IAAnB,EAA0C;AACxC,UAAMI,SAAS,GAAG,uBAAAJ,IAAI,MAAJ,CAAAA,IAAI,EAAU,GAAV,CAAJ,GACdA,IAAI,CAACK,MAAL,CAAY,CAAZ,EAAeL,IAAI,CAACF,MAAL,GAAc,CAA7B,CADc,GAEdE,IAFJ;AAIA,UAAMM,KAAK,GAAG,KAAKC,eAAL,CACZ,UAACN,KAAD;AAAA,eACE,yBAAAA,KAAK,MAAL,CAAAA,KAAK,YAAeG,SAAf,OAAL,IAAqC,yBAAAH,KAAK,MAAL,CAAAA,KAAK,YAAeG,SAAf,OAD5C;AAAA,OADY,CAAd;;AAKA,UAAI,CAACE,KAAL,EAAY;AACV,eAAO,IAAP;AACD;;AAED,aAAOA,KAAK,CAACD,MAAN,CAAaD,SAAS,CAACN,MAAV,GAAmB,CAAhC,CAAP;AACD;AAED;AACF;AACA;AACA;;;;WACE,6BAAoBE,IAApB,EAAwD;AACtD,UAAI,CAAC,KAAKQ,GAAL,CAASR,IAAT,CAAL,EAAqB;AACnB,eAAO,IAAP;AACD;;AAED,UAAMS,KAAK,GAAG,KAAKC,kBAAL,CAAwBV,IAAxB,CAAd;;AAEA,UAAI,CAACS,KAAL,EAAY;AACV,eAAO,EAAP;AACD;;AAED,aAAOA,KAAK,CAACE,KAAN,CAAY,GAAZ,CAAP;AACD;;;EA3G+CC,wB","sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\n/**\n * Collection of layouthint\n */\nexport default class LayoutHintCollection extends BaseCollection<string> {\n /**\n * Constructs the layouthint collection\n */\n constructor(layouthint: Array<string> = []) {\n super();\n\n if (!Array.isArray(layouthint)) {\n throw new IllegalArgumentException(`${layouthint} is not an Array`);\n }\n\n this.collection = layouthint;\n }\n\n /**\n * Retrieve layout hints\n */\n get layouthint(): Array<string> {\n return this.collection;\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration\n * This method matches all exact matches and hints starting with. For example\n * when calling layouth.has(\"hide\"), this will return true for both \"hide\" and \"hide-when-empty\".\n * If only exact matches are required, use the method {@link hasExact}.\n */\n has(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n\n return hintArray\n .flat()\n .some(\n (hint) =>\n this.layouthint.includes(hint) ||\n this.layouthint.some((hint2) => hint2.startsWith(hint))\n );\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration,\n * only checks on exact matches.\n * If layouthints that start with the given hint should also match, use {@link has}.\n * @param hints\n * @returns {boolean}\n */\n hasExact(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n return hintArray.flat().some((hint) => this.layouthint.includes(hint));\n }\n\n /**\n * Retrieve the first layouthint starting with hint\n */\n getByLayoutHint(hint: Function | string): null | string {\n let foundHint = null;\n\n if (typeof hint === \"function\") {\n foundHint = this.layouthint.find(hint);\n }\n\n if (typeof hint === \"string\") {\n foundHint = this.layouthint.find((hint2) =>\n hint2.startsWith(hint.toString())\n );\n }\n\n return foundHint || null;\n }\n\n /**\n * Get the value of a specific hint\n * Format: hint=value\n */\n getLayoutHintValue(hint: string): ?string {\n const checkHint = hint.endsWith(\":\")\n ? hint.substr(0, hint.length - 1)\n : hint;\n\n const match = this.getByLayoutHint(\n (hint2) =>\n hint2.startsWith(`${checkHint}=`) || hint2.startsWith(`${checkHint}:`)\n );\n\n if (!match) {\n return null;\n }\n\n return match.substr(checkHint.length + 1);\n }\n\n /**\n * Get an array of multiple values from a specific hint\n * Format: hint=value1;value2;value3\n */\n getLayoutHintValues(hint: string): Array<string> | null {\n if (!this.has(hint)) {\n return null;\n }\n\n const value = this.getLayoutHintValue(hint);\n\n if (!value) {\n return [];\n }\n\n return value.split(\";\");\n }\n}\n"],"file":"LayoutHintCollection.js"}
@@ -246,5 +246,6 @@ export type ContentData = {
246
246
  label?: string,
247
247
  description?: { id?: string, message: string, properties?: Object },
248
248
  },
249
+ label?: string,
249
250
  elements: Array<PropertyElement | TextFragmentElement | ContentElement>,
250
251
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.9.0-beta.13",
3
+ "version": "1.9.0-beta.14",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -11,6 +11,7 @@ import type {
11
11
  } from "../types";
12
12
  import type SubSectionModel from "../content/SubSectionModel";
13
13
  import LayoutHintCollection from "../layouthint/LayoutHintCollection";
14
+ import { isPlainObject } from "../../utils";
14
15
 
15
16
  class AttributeContent {
16
17
  _content: ?ContentData;
@@ -31,10 +32,24 @@ class AttributeContent {
31
32
  label: ?string,
32
33
  description: ?string,
33
34
  } {
35
+ let headerLabel = null;
36
+ let headerDescription = null;
37
+
34
38
  const label = this._content?.header?.label;
35
- const description = this._content?.header?.description?.message;
39
+ if (label) {
40
+ headerLabel = label;
41
+ }
42
+
43
+ const description = this._content?.header?.description;
44
+ if (description) {
45
+ if (isPlainObject(description) && "message" in description) {
46
+ headerDescription = description.message;
47
+ } else if (typeof description === "string") {
48
+ headerDescription = description;
49
+ }
50
+ }
36
51
 
37
- return { label, description };
52
+ return { label: headerLabel, description: headerDescription };
38
53
  }
39
54
 
40
55
  /**
@@ -96,13 +111,7 @@ class AttributeContent {
96
111
  /**
97
112
  */
98
113
  get label(): ?string {
99
- return this.header.label;
100
- }
101
-
102
- /**
103
- */
104
- get description(): ?string {
105
- return this.header.description;
114
+ return this._content?.label;
106
115
  }
107
116
 
108
117
  /**
@@ -65,7 +65,7 @@ class AttributeDataHelper {
65
65
  } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {
66
66
  const parentData = data[parentKey];
67
67
  if (isPlainObject(parentData) && data.content?.[childKey]) {
68
- return { ...parentData, content: data.content[childKey].content };
68
+ return { ...parentData, content: data.content[childKey] };
69
69
  }
70
70
  return parentData;
71
71
  } else if (has(data, childKey) && isPlainObject(data[childKey])) {
@@ -266,6 +266,7 @@ class AttributeDataHelper {
266
266
  if (this._attribute.content) {
267
267
  const pickedContent = pick(this._attribute.content, [
268
268
  "header",
269
+ "label",
269
270
  "elements",
270
271
  "layouthint",
271
272
  ]);
@@ -3,11 +3,12 @@ import SectionModel from "../../content/SectionModel";
3
3
 
4
4
  const json = {
5
5
  header: {
6
- label: "Blaastest geslaagd",
6
+ label: "Header label",
7
7
  description: {
8
8
  message: "Dit is de beschrijving",
9
9
  },
10
10
  },
11
+ label: "Blaastest geslaagd",
11
12
  elements: [
12
13
  {
13
14
  propertyElement: {
@@ -152,7 +153,8 @@ describe("AttributeContent", () => {
152
153
  it("Handles basic content elements", () => {
153
154
  const content = new AttributeContent(json);
154
155
  expect(content.label).toBe("Blaastest geslaagd");
155
- expect(content.description).toBe("Dit is de beschrijving");
156
+ expect(content.header.label).toBe("Header label");
157
+ expect(content.header.description).toBe("Dit is de beschrijving");
156
158
  expect(content.properties).toHaveLength(2);
157
159
  expect(content.textfragments).toHaveLength(1);
158
160
  expect(content.sections).toHaveLength(1);
@@ -499,25 +499,23 @@ describe("attributeDataHelper", () => {
499
499
  key: "results",
500
500
  content: {
501
501
  InvestigationNecessary: {
502
- content: {
503
- header: {
504
- label: "label",
505
- description: "description",
506
- },
507
- elements: [
508
- {
509
- textFragmentElement: {
510
- label: "Text fragment: Description",
511
- textfragments: [
512
- {
513
- text: "Text fragment for investigation necessary",
514
- },
515
- ],
516
- layouthint: ["full"],
517
- },
518
- },
519
- ],
502
+ header: {
503
+ label: "label",
504
+ description: "description",
520
505
  },
506
+ elements: [
507
+ {
508
+ textFragmentElement: {
509
+ label: "Text fragment: Description",
510
+ textfragments: [
511
+ {
512
+ text: "Text fragment for investigation necessary",
513
+ },
514
+ ],
515
+ layouthint: ["full"],
516
+ },
517
+ },
518
+ ],
521
519
  },
522
520
  },
523
521
  results: { InvestigationNecessary: true },
@@ -19,7 +19,8 @@
19
19
  {
20
20
  "elementid": "UitslagBlaastestType",
21
21
  "content": {
22
- "header": { "label": "Uitslag blaastest label" },
22
+ "header": { "label": "Header label" },
23
+ "label": "Uitslag blaastest label",
23
24
  "elements": [
24
25
  {
25
26
  "contentElement": {
@@ -35,11 +35,13 @@ export default class LayoutHintCollection extends BaseCollection<string> {
35
35
  has(...hints: Array<string>): boolean {
36
36
  const hintArray = hints.length > 0 ? [...hints] : [];
37
37
 
38
- return hintArray.some(
39
- (hint) =>
40
- this.layouthint.includes(hint) ||
41
- this.layouthint.some((hint2) => hint2.startsWith(hint))
42
- );
38
+ return hintArray
39
+ .flat()
40
+ .some(
41
+ (hint) =>
42
+ this.layouthint.includes(hint) ||
43
+ this.layouthint.some((hint2) => hint2.startsWith(hint))
44
+ );
43
45
  }
44
46
 
45
47
  /**
@@ -51,8 +53,7 @@ export default class LayoutHintCollection extends BaseCollection<string> {
51
53
  */
52
54
  hasExact(...hints: Array<string>): boolean {
53
55
  const hintArray = hints.length > 0 ? [...hints] : [];
54
-
55
- return hintArray.some((hint) => this.layouthint.includes(hint));
56
+ return hintArray.flat().some((hint) => this.layouthint.includes(hint));
56
57
  }
57
58
 
58
59
  /**
@@ -246,5 +246,6 @@ export type ContentData = {
246
246
  label?: string,
247
247
  description?: { id?: string, message: string, properties?: Object },
248
248
  },
249
+ label?: string,
249
250
  elements: Array<PropertyElement | TextFragmentElement | ContentElement>,
250
251
  };