@beinformed/ui 1.52.2 → 1.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/esm/hooks/useModelCatalog.js +34 -1
- package/esm/hooks/useModelCatalog.js.map +1 -1
- package/lib/hooks/useModelCatalog.js +37 -1
- package/lib/hooks/useModelCatalog.js.flow +48 -0
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/package.json +15 -15
- package/src/hooks/useModelCatalog.js +48 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.53.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.52.2...v1.53.0) (2024-09-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **modelcatalog:** new hooks for searching concepts or content by filter ([ef8e0a5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/ef8e0a5c6e6c9496756ecabdc3a9ec79469e98ed))
|
|
11
|
+
|
|
5
12
|
## [1.52.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.52.1...v1.52.2) (2024-08-23)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
1
2
|
import { useLocation } from "./useRouter";
|
|
2
3
|
import { createHref, filterParameters } from "../utils/helpers/createHref";
|
|
3
4
|
import ModelCatalogModel from "../models/modelcatalog/ModelCatalogModel";
|
|
@@ -9,7 +10,6 @@ import ContentTOCModel from "../models/content/ContentTOCModel";
|
|
|
9
10
|
import ContentModel from "../models/content/ContentModel";
|
|
10
11
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
11
12
|
import { ContentTypeModel } from "../models";
|
|
12
|
-
|
|
13
13
|
/**
|
|
14
14
|
*/
|
|
15
15
|
export const useModelCatalog = () => useModularUIBasic("modelcatalog", "/modelcatalog", {
|
|
@@ -83,4 +83,37 @@ export const useContentType = function (contentType) {
|
|
|
83
83
|
targetModel: ContentTypeModel
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
*/
|
|
89
|
+
const getSearchHref = (uri, filters) => {
|
|
90
|
+
const filterString = [];
|
|
91
|
+
for (const key of _Object$keys(filters)) {
|
|
92
|
+
const filterValue = filters[key];
|
|
93
|
+
if (filterValue) {
|
|
94
|
+
let value = Array.isArray(filterValue) ? filterValue.join(",") : filterValue;
|
|
95
|
+
if (key === "type") {
|
|
96
|
+
value = value.replace("#", "%23"); // handles un-encoded #
|
|
97
|
+
}
|
|
98
|
+
filterString.push(`${key}=${value}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return filterString.length ? `${uri}?${filterString.join("&")}` : uri;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*/
|
|
106
|
+
export const useConceptSearch = function (filters) {
|
|
107
|
+
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptSearch";
|
|
108
|
+
const href = getSearchHref("/concepts", filters);
|
|
109
|
+
return useConceptIndex(href, key);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*/
|
|
114
|
+
export const useContentSearch = function (filters) {
|
|
115
|
+
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentSearch";
|
|
116
|
+
const href = getSearchHref("/content", filters);
|
|
117
|
+
return useContentIndex(href, key);
|
|
118
|
+
};
|
|
86
119
|
//# sourceMappingURL=useModelCatalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","useModelCatalog","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","url","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","contentSection","useContentType","contentType"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,SAASC,UAAU,EAAEC,gBAAgB,QAAQ,6BAA6B;AAE1E,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,0CAA0C;AAC3F,OAAOC,iBAAiB,MAAM,qCAAqC;AACnE,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,OAAOC,YAAY,MAAM,gCAAgC;AAEzD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,WAAW
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","useModelCatalog","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","url","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","contentSection","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n): ?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,CAAC,CAAC,CAAC;MACrC;MACAP,YAAY,CAACQ,IAAI,CAAC,GAAG1B,GAAG,IAAIqB,KAAK,EAAE,CAAC;IACtC;EACF;EAEA,OAAOH,YAAY,CAAChB,MAAM,GAAG,GAAGc,GAAG,IAAIE,YAAY,CAACM,IAAI,CAAC,GAAG,CAAC,EAAE,GAAGR,GAAG;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMW,gBAAgB,GAAG,SAAAA,CAC9BV,OAAqB,EAEE;EAAA,IADvBjB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAE9B,MAAMF,IAAI,GAAGgB,aAAa,CAAC,WAAW,EAAEE,OAAO,CAAC;EAChD,OAAOnB,eAAe,CAACC,IAAI,EAAEC,GAAG,CAAC;AACnC,CAAC;;AAED;AACA;AACA,OAAO,MAAM4B,gBAAgB,GAAG,SAAAA,CAC9BX,OAAqB,EAEE;EAAA,IADvBjB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAE9B,MAAMF,IAAI,GAAGgB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOT,eAAe,CAACT,IAAI,EAAEC,GAAG,CAAC;AACnC,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,8 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useModelCatalog = exports.useContentType = exports.useContentTOC = exports.useContentIndex = exports.useContent = exports.useConceptIndex = exports.useConceptDetail = void 0;
|
|
7
|
+
exports.useModelCatalog = exports.useContentType = exports.useContentTOC = exports.useContentSearch = exports.useContentIndex = exports.useContent = exports.useConceptSearch = exports.useConceptIndex = exports.useConceptDetail = void 0;
|
|
8
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
8
9
|
var _useRouter = require("./useRouter");
|
|
9
10
|
var _createHref = require("../utils/helpers/createHref");
|
|
10
11
|
var _ModelCatalogModel = _interopRequireDefault(require("../models/modelcatalog/ModelCatalogModel"));
|
|
@@ -95,5 +96,40 @@ const useContentType = function (contentType) {
|
|
|
95
96
|
targetModel: _models.ContentTypeModel
|
|
96
97
|
});
|
|
97
98
|
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*/
|
|
98
102
|
exports.useContentType = useContentType;
|
|
103
|
+
const getSearchHref = (uri, filters) => {
|
|
104
|
+
const filterString = [];
|
|
105
|
+
for (const key of (0, _keys.default)(filters)) {
|
|
106
|
+
const filterValue = filters[key];
|
|
107
|
+
if (filterValue) {
|
|
108
|
+
let value = Array.isArray(filterValue) ? filterValue.join(",") : filterValue;
|
|
109
|
+
if (key === "type") {
|
|
110
|
+
value = value.replace("#", "%23"); // handles un-encoded #
|
|
111
|
+
}
|
|
112
|
+
filterString.push(`${key}=${value}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return filterString.length ? `${uri}?${filterString.join("&")}` : uri;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
*/
|
|
120
|
+
const useConceptSearch = function (filters) {
|
|
121
|
+
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptSearch";
|
|
122
|
+
const href = getSearchHref("/concepts", filters);
|
|
123
|
+
return useConceptIndex(href, key);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
*/
|
|
128
|
+
exports.useConceptSearch = useConceptSearch;
|
|
129
|
+
const useContentSearch = function (filters) {
|
|
130
|
+
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentSearch";
|
|
131
|
+
const href = getSearchHref("/content", filters);
|
|
132
|
+
return useContentIndex(href, key);
|
|
133
|
+
};
|
|
134
|
+
exports.useContentSearch = useContentSearch;
|
|
99
135
|
//# sourceMappingURL=useModelCatalog.js.map
|
|
@@ -14,6 +14,13 @@ import ContentModel from "../models/content/ContentModel";
|
|
|
14
14
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
15
15
|
import { ContentTypeModel } from "../models";
|
|
16
16
|
|
|
17
|
+
export type SearchFilter = {
|
|
18
|
+
index?: string,
|
|
19
|
+
label?: string,
|
|
20
|
+
type?: string | Array<string>,
|
|
21
|
+
entryDate?: string,
|
|
22
|
+
};
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
*/
|
|
19
26
|
export const useModelCatalog = (): ?ModelCatalogModel =>
|
|
@@ -101,3 +108,44 @@ export const useContentType = (
|
|
|
101
108
|
targetModel: ContentTypeModel,
|
|
102
109
|
});
|
|
103
110
|
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*/
|
|
114
|
+
const getSearchHref = (uri: string, filters: SearchFilter): string => {
|
|
115
|
+
const filterString = [];
|
|
116
|
+
|
|
117
|
+
for (const key of Object.keys(filters)) {
|
|
118
|
+
const filterValue = filters[key];
|
|
119
|
+
if (filterValue) {
|
|
120
|
+
let value: string = Array.isArray(filterValue)
|
|
121
|
+
? filterValue.join(",")
|
|
122
|
+
: filterValue;
|
|
123
|
+
if (key === "type") {
|
|
124
|
+
value = value.replace("#", "%23"); // handles un-encoded #
|
|
125
|
+
}
|
|
126
|
+
filterString.push(`${key}=${value}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return filterString.length ? `${uri}?${filterString.join("&")}` : uri;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
*/
|
|
135
|
+
export const useConceptSearch = (
|
|
136
|
+
filters: SearchFilter,
|
|
137
|
+
key?: string = "conceptSearch",
|
|
138
|
+
): ?ConceptIndexModel => {
|
|
139
|
+
const href = getSearchHref("/concepts", filters);
|
|
140
|
+
return useConceptIndex(href, key);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
*/
|
|
145
|
+
export const useContentSearch = (
|
|
146
|
+
filters: SearchFilter,
|
|
147
|
+
key?: string = "contentSearch",
|
|
148
|
+
): ?ContentIndexModel => {
|
|
149
|
+
const href = getSearchHref("/content", filters);
|
|
150
|
+
return useContentIndex(href, key);
|
|
151
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["_useRouter","require","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","useModelCatalog","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","url","filterParameters","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","contentSection","ContentModel","useContentType","contentType","ContentTypeModel"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["_useRouter","require","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","useModelCatalog","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","url","filterParameters","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","contentSection","ContentModel","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key);\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,mBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,sBAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,kBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,gBAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,aAAA,GAAAN,sBAAA,CAAAH,OAAA;AAEA,IAAAU,kBAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AASA;AACA;AACO,MAAMY,eAAe,GAAGA,CAAA,KAC7B,IAAAC,oCAAiB,EAAC,cAAc,EAAE,eAAe,EAAE;EACjDC,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEC;AACf,CAAC,CAAC;;AAEJ;AACA;AADAC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAEO,MAAMM,eAAe,GAAG,SAAAA,CAC7BC,IAAY,EAEW;EAAA,IADvBC,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAE7B,MAAMG,GAAG,GAAG,IAAAC,4BAAgB,EAACN,IAAI,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;EAC3E,OAAO,IAAAN,oCAAiB,EAACO,GAAG,EAAEI,GAAG,EAAE;IACjCV,cAAc,EAAE,CAAC,cAAc,CAAC;IACh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AA,MAAG,eAAe;EAE9B,MAAMF,IAAI,GAAGwB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOb,eAAe,CAACb,IAAI,EAAEC,GAAG,CAAC;AACnC,CAAC;AAACH,OAAA,CAAAwC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.53.0",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"styled-components": "^5.0.0"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@babel/runtime-corejs3": "^7.25.
|
|
86
|
-
"big.js": "^6.2.
|
|
87
|
-
"date-fns": "^
|
|
85
|
+
"@babel/runtime-corejs3": "^7.25.6",
|
|
86
|
+
"big.js": "^6.2.2",
|
|
87
|
+
"date-fns": "^4.1.0",
|
|
88
88
|
"deepmerge": "^4.3.1",
|
|
89
89
|
"dequal": "^2.0.3",
|
|
90
90
|
"file-size": "^1.0.0",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"setimmediate": "^1.0.5"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@babel/cli": "^7.
|
|
101
|
+
"@babel/cli": "^7.25.6",
|
|
102
102
|
"@babel/core": "^7.25.2",
|
|
103
103
|
"@babel/eslint-parser": "^7.25.1",
|
|
104
104
|
"@babel/eslint-plugin": "^7.25.1",
|
|
@@ -108,24 +108,24 @@
|
|
|
108
108
|
"@babel/preset-env": "^7.25.4",
|
|
109
109
|
"@babel/preset-flow": "^7.24.7",
|
|
110
110
|
"@babel/preset-react": "^7.24.7",
|
|
111
|
-
"@commitlint/cli": "^19.
|
|
112
|
-
"@commitlint/config-conventional": "^19.
|
|
113
|
-
"@testing-library/react": "^16.0.
|
|
111
|
+
"@commitlint/cli": "^19.5.0",
|
|
112
|
+
"@commitlint/config-conventional": "^19.5.0",
|
|
113
|
+
"@testing-library/react": "^16.0.1",
|
|
114
114
|
"auditjs": "^4.0.45",
|
|
115
115
|
"babel-jest": "^29.7.0",
|
|
116
116
|
"babel-plugin-styled-components": "^2.1.4",
|
|
117
117
|
"cherry-pick": "^0.5.0",
|
|
118
|
-
"commit-and-tag-version": "^12.4.
|
|
118
|
+
"commit-and-tag-version": "^12.4.4",
|
|
119
119
|
"cross-env": "^7.0.3",
|
|
120
120
|
"documentation": "^14.0.2",
|
|
121
121
|
"eslint": "^8.57.0",
|
|
122
122
|
"eslint-config-prettier": "^9.1.0",
|
|
123
123
|
"eslint-plugin-babel": "^5.3.1",
|
|
124
124
|
"eslint-plugin-ft-flow": "^3.0.11",
|
|
125
|
-
"eslint-plugin-import": "^2.
|
|
126
|
-
"eslint-plugin-jest": "^28.8.
|
|
127
|
-
"eslint-plugin-jsdoc": "^50.2.
|
|
128
|
-
"eslint-plugin-react": "^7.
|
|
125
|
+
"eslint-plugin-import": "^2.30.0",
|
|
126
|
+
"eslint-plugin-jest": "^28.8.3",
|
|
127
|
+
"eslint-plugin-jsdoc": "^50.2.3",
|
|
128
|
+
"eslint-plugin-react": "^7.36.1",
|
|
129
129
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
130
130
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|
|
131
131
|
"flow-bin": "^0.200.1",
|
|
@@ -133,13 +133,13 @@
|
|
|
133
133
|
"flow-typed": "^3.9.0",
|
|
134
134
|
"hermes-eslint": "^0.23.1",
|
|
135
135
|
"history": "^4.0.0",
|
|
136
|
-
"husky": "^9.1.
|
|
136
|
+
"husky": "^9.1.6",
|
|
137
137
|
"jest": "^29.7.0",
|
|
138
138
|
"jest-environment-jsdom": "^29.7.0",
|
|
139
139
|
"jest-junit": "^16.0.0",
|
|
140
140
|
"jest-sonar-reporter": "^2.0.0",
|
|
141
141
|
"jscodeshift": "^0.16.1",
|
|
142
|
-
"lint-staged": "^15.2.
|
|
142
|
+
"lint-staged": "^15.2.10",
|
|
143
143
|
"polished": "^4.0.0",
|
|
144
144
|
"prettier": "^3.3.3",
|
|
145
145
|
"react": "^18.3.1",
|
|
@@ -14,6 +14,13 @@ import ContentModel from "../models/content/ContentModel";
|
|
|
14
14
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
15
15
|
import { ContentTypeModel } from "../models";
|
|
16
16
|
|
|
17
|
+
export type SearchFilter = {
|
|
18
|
+
index?: string,
|
|
19
|
+
label?: string,
|
|
20
|
+
type?: string | Array<string>,
|
|
21
|
+
entryDate?: string,
|
|
22
|
+
};
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
*/
|
|
19
26
|
export const useModelCatalog = (): ?ModelCatalogModel =>
|
|
@@ -101,3 +108,44 @@ export const useContentType = (
|
|
|
101
108
|
targetModel: ContentTypeModel,
|
|
102
109
|
});
|
|
103
110
|
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*/
|
|
114
|
+
const getSearchHref = (uri: string, filters: SearchFilter): string => {
|
|
115
|
+
const filterString = [];
|
|
116
|
+
|
|
117
|
+
for (const key of Object.keys(filters)) {
|
|
118
|
+
const filterValue = filters[key];
|
|
119
|
+
if (filterValue) {
|
|
120
|
+
let value: string = Array.isArray(filterValue)
|
|
121
|
+
? filterValue.join(",")
|
|
122
|
+
: filterValue;
|
|
123
|
+
if (key === "type") {
|
|
124
|
+
value = value.replace("#", "%23"); // handles un-encoded #
|
|
125
|
+
}
|
|
126
|
+
filterString.push(`${key}=${value}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return filterString.length ? `${uri}?${filterString.join("&")}` : uri;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
*/
|
|
135
|
+
export const useConceptSearch = (
|
|
136
|
+
filters: SearchFilter,
|
|
137
|
+
key?: string = "conceptSearch",
|
|
138
|
+
): ?ConceptIndexModel => {
|
|
139
|
+
const href = getSearchHref("/concepts", filters);
|
|
140
|
+
return useConceptIndex(href, key);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
*/
|
|
145
|
+
export const useContentSearch = (
|
|
146
|
+
filters: SearchFilter,
|
|
147
|
+
key?: string = "contentSearch",
|
|
148
|
+
): ?ContentIndexModel => {
|
|
149
|
+
const href = getSearchHref("/content", filters);
|
|
150
|
+
return useContentIndex(href, key);
|
|
151
|
+
};
|