@collectionspace/cspace-public-browser 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/LICENSE.md +71 -0
  2. package/README.md +38 -0
  3. package/dist/cspacePublicBrowser.js +4680 -0
  4. package/dist/cspacePublicBrowser.min.js +2 -0
  5. package/dist/cspacePublicBrowser.min.js.LICENSE.txt +56 -0
  6. package/images/check.svg +3 -0
  7. package/images/close.svg +3 -0
  8. package/images/collapse.svg +3 -0
  9. package/images/collapseActive.svg +3 -0
  10. package/images/expand.svg +3 -0
  11. package/images/expandActive.svg +3 -0
  12. package/images/filter.svg +4 -0
  13. package/images/hideLeft.svg +4 -0
  14. package/images/linkBack.svg +4 -0
  15. package/images/linkDown.svg +4 -0
  16. package/images/linkNext.svg +4 -0
  17. package/images/linkPrev.svg +4 -0
  18. package/images/openNew.svg +4 -0
  19. package/images/search.svg +4 -0
  20. package/images/select.svg +4 -0
  21. package/images/top.svg +1 -0
  22. package/lib/actions/detailActions.js +177 -0
  23. package/lib/actions/filterActions.js +16 -0
  24. package/lib/actions/mediaActions.js +63 -0
  25. package/lib/actions/prefsActions.js +84 -0
  26. package/lib/actions/searchActions.js +140 -0
  27. package/lib/actions/searchEntryFormActions.js +19 -0
  28. package/lib/components/App.js +24 -0
  29. package/lib/components/detail/DetailNavBar.js +98 -0
  30. package/lib/components/detail/DetailPanel.js +171 -0
  31. package/lib/components/detail/DetailPanelContainer.js +22 -0
  32. package/lib/components/detail/ExhibitionSection.js +54 -0
  33. package/lib/components/detail/FieldList.js +95 -0
  34. package/lib/components/detail/FieldValueList.js +30 -0
  35. package/lib/components/detail/ImageGallery.js +137 -0
  36. package/lib/components/detail/ImageGalleryContainer.js +19 -0
  37. package/lib/components/detail/InstitutionHoldingList.js +155 -0
  38. package/lib/components/detail/InstitutionHoldingListContainer.js +22 -0
  39. package/lib/components/detail/InstitutionIndex.js +53 -0
  40. package/lib/components/detail/InstitutionIndexContainer.js +15 -0
  41. package/lib/components/detail/InstitutionSection.js +44 -0
  42. package/lib/components/detail/InstitutionSectionContainer.js +15 -0
  43. package/lib/components/layout/Fixed.js +26 -0
  44. package/lib/components/layout/IconButton.js +41 -0
  45. package/lib/components/layout/Panel.js +56 -0
  46. package/lib/components/layout/PanelContainer.js +19 -0
  47. package/lib/components/layout/PanelTitle.js +38 -0
  48. package/lib/components/layout/ScrollTopButton.js +70 -0
  49. package/lib/components/layout/ToggleFilterPanelButton.js +42 -0
  50. package/lib/components/pages/DetailPage.js +93 -0
  51. package/lib/components/pages/DetailPageContainer.js +20 -0
  52. package/lib/components/pages/RootPage.js +41 -0
  53. package/lib/components/pages/SearchPage.js +130 -0
  54. package/lib/components/pages/SearchPageContainer.js +23 -0
  55. package/lib/components/search/entry/SearchEntryForm.js +74 -0
  56. package/lib/components/search/entry/SearchEntryFormContainer.js +20 -0
  57. package/lib/components/search/entry/SearchEntryPanel.js +30 -0
  58. package/lib/components/search/entry/SearchQueryInput.js +89 -0
  59. package/lib/components/search/entry/SearchSubmitButton.js +22 -0
  60. package/lib/components/search/entry/SortSelect.js +89 -0
  61. package/lib/components/search/entry/SortSelectContainer.js +15 -0
  62. package/lib/components/search/result/ClearSearchParamsLink.js +42 -0
  63. package/lib/components/search/result/Filter.js +186 -0
  64. package/lib/components/search/result/FilterContainer.js +22 -0
  65. package/lib/components/search/result/FilterGroup.js +72 -0
  66. package/lib/components/search/result/FilterList.js +48 -0
  67. package/lib/components/search/result/FilterPanel.js +115 -0
  68. package/lib/components/search/result/FilterPanelContainer.js +16 -0
  69. package/lib/components/search/result/FilterSearchInput.js +63 -0
  70. package/lib/components/search/result/RemoveSearchParamLink.js +66 -0
  71. package/lib/components/search/result/SearchError.js +29 -0
  72. package/lib/components/search/result/SearchLoadMore.js +36 -0
  73. package/lib/components/search/result/SearchParamList.js +41 -0
  74. package/lib/components/search/result/SearchPending.js +21 -0
  75. package/lib/components/search/result/SearchResultImage.js +227 -0
  76. package/lib/components/search/result/SearchResultList.js +119 -0
  77. package/lib/components/search/result/SearchResultPanel.js +139 -0
  78. package/lib/components/search/result/SearchResultPanelContainer.js +23 -0
  79. package/lib/components/search/result/SearchResultStats.js +39 -0
  80. package/lib/components/search/result/SearchResultTile.js +61 -0
  81. package/lib/config/anthro.js +123 -0
  82. package/lib/config/bonsai.js +50 -0
  83. package/lib/config/botgarden.js +10 -0
  84. package/lib/config/default.js +530 -0
  85. package/lib/config/fcart.js +36 -0
  86. package/lib/config/herbarium.js +10 -0
  87. package/lib/config/index.js +53 -0
  88. package/lib/config/lhmc.js +10 -0
  89. package/lib/config/materials.js +982 -0
  90. package/lib/config/publicart.js +10 -0
  91. package/lib/constants/actionCodes.js +46 -0
  92. package/lib/constants/ids.js +12 -0
  93. package/lib/helpers/bodyClassName.js +11 -0
  94. package/lib/helpers/esQueryHelpers.js +206 -0
  95. package/lib/helpers/formatHelpers.js +293 -0
  96. package/lib/helpers/searchDimensions.js +28 -0
  97. package/lib/helpers/urlHelpers.js +43 -0
  98. package/lib/index.js +53 -0
  99. package/lib/intl/index.js +16 -0
  100. package/lib/reducers/detailReducer.js +145 -0
  101. package/lib/reducers/filterReducer.js +22 -0
  102. package/lib/reducers/index.js +66 -0
  103. package/lib/reducers/mediaReducer.js +43 -0
  104. package/lib/reducers/prefsReducer.js +27 -0
  105. package/lib/reducers/searchEntryFormReducer.js +24 -0
  106. package/lib/reducers/searchReducer.js +88 -0
  107. package/package.json +118 -0
  108. package/src/actions/detailActions.js +231 -0
  109. package/src/actions/filterActions.js +10 -0
  110. package/src/actions/mediaActions.js +65 -0
  111. package/src/actions/prefsActions.js +95 -0
  112. package/src/actions/searchActions.js +188 -0
  113. package/src/actions/searchEntryFormActions.js +15 -0
  114. package/src/components/App.jsx +18 -0
  115. package/src/components/detail/DetailNavBar.jsx +132 -0
  116. package/src/components/detail/DetailPanel.jsx +215 -0
  117. package/src/components/detail/DetailPanelContainer.js +29 -0
  118. package/src/components/detail/ExhibitionSection.jsx +71 -0
  119. package/src/components/detail/FieldList.jsx +122 -0
  120. package/src/components/detail/FieldValueList.jsx +31 -0
  121. package/src/components/detail/ImageGallery.jsx +153 -0
  122. package/src/components/detail/ImageGalleryContainer.js +17 -0
  123. package/src/components/detail/InstitutionHoldingList.jsx +188 -0
  124. package/src/components/detail/InstitutionHoldingListContainer.js +29 -0
  125. package/src/components/detail/InstitutionIndex.jsx +57 -0
  126. package/src/components/detail/InstitutionIndexContainer.js +11 -0
  127. package/src/components/detail/InstitutionSection.jsx +48 -0
  128. package/src/components/detail/InstitutionSectionContainer.js +11 -0
  129. package/src/components/layout/Fixed.jsx +29 -0
  130. package/src/components/layout/IconButton.jsx +41 -0
  131. package/src/components/layout/Panel.jsx +60 -0
  132. package/src/components/layout/PanelContainer.js +20 -0
  133. package/src/components/layout/PanelTitle.jsx +43 -0
  134. package/src/components/layout/ScrollTopButton.jsx +76 -0
  135. package/src/components/layout/ToggleFilterPanelButton.jsx +43 -0
  136. package/src/components/pages/DetailPage.jsx +101 -0
  137. package/src/components/pages/DetailPageContainer.js +18 -0
  138. package/src/components/pages/RootPage.jsx +37 -0
  139. package/src/components/pages/SearchPage.jsx +160 -0
  140. package/src/components/pages/SearchPageContainer.js +21 -0
  141. package/src/components/search/entry/SearchEntryForm.jsx +82 -0
  142. package/src/components/search/entry/SearchEntryFormContainer.js +22 -0
  143. package/src/components/search/entry/SearchEntryPanel.jsx +28 -0
  144. package/src/components/search/entry/SearchQueryInput.jsx +95 -0
  145. package/src/components/search/entry/SearchSubmitButton.jsx +22 -0
  146. package/src/components/search/entry/SortSelect.jsx +104 -0
  147. package/src/components/search/entry/SortSelectContainer.js +12 -0
  148. package/src/components/search/result/ClearSearchParamsLink.jsx +43 -0
  149. package/src/components/search/result/Filter.jsx +226 -0
  150. package/src/components/search/result/FilterContainer.js +20 -0
  151. package/src/components/search/result/FilterGroup.jsx +83 -0
  152. package/src/components/search/result/FilterList.jsx +51 -0
  153. package/src/components/search/result/FilterPanel.jsx +143 -0
  154. package/src/components/search/result/FilterPanelContainer.js +16 -0
  155. package/src/components/search/result/FilterSearchInput.jsx +68 -0
  156. package/src/components/search/result/RemoveSearchParamLink.jsx +79 -0
  157. package/src/components/search/result/SearchError.jsx +30 -0
  158. package/src/components/search/result/SearchLoadMore.jsx +37 -0
  159. package/src/components/search/result/SearchParamList.jsx +47 -0
  160. package/src/components/search/result/SearchPending.jsx +19 -0
  161. package/src/components/search/result/SearchResultImage.jsx +275 -0
  162. package/src/components/search/result/SearchResultList.jsx +144 -0
  163. package/src/components/search/result/SearchResultPanel.jsx +169 -0
  164. package/src/components/search/result/SearchResultPanelContainer.js +31 -0
  165. package/src/components/search/result/SearchResultStats.jsx +38 -0
  166. package/src/components/search/result/SearchResultTile.jsx +70 -0
  167. package/src/config/anthro.js +153 -0
  168. package/src/config/bonsai.js +50 -0
  169. package/src/config/botgarden.js +3 -0
  170. package/src/config/default.js +604 -0
  171. package/src/config/fcart.js +38 -0
  172. package/src/config/herbarium.js +3 -0
  173. package/src/config/index.js +51 -0
  174. package/src/config/lhmc.js +3 -0
  175. package/src/config/materials.js +1173 -0
  176. package/src/config/publicart.js +3 -0
  177. package/src/constants/actionCodes.js +26 -0
  178. package/src/constants/ids.js +3 -0
  179. package/src/helpers/bodyClassName.js +5 -0
  180. package/src/helpers/esQueryHelpers.js +224 -0
  181. package/src/helpers/formatHelpers.jsx +361 -0
  182. package/src/helpers/searchDimensions.js +21 -0
  183. package/src/helpers/urlHelpers.js +49 -0
  184. package/src/index.jsx +59 -0
  185. package/src/intl/index.js +16 -0
  186. package/src/reducers/detailReducer.js +201 -0
  187. package/src/reducers/filterReducer.js +16 -0
  188. package/src/reducers/index.js +56 -0
  189. package/src/reducers/mediaReducer.js +44 -0
  190. package/src/reducers/prefsReducer.js +24 -0
  191. package/src/reducers/searchEntryFormReducer.js +19 -0
  192. package/src/reducers/searchReducer.js +118 -0
  193. package/styles/colors.css +7 -0
  194. package/styles/cspace/DetailNavBar.css +17 -0
  195. package/styles/cspace/DetailPage.css +3 -0
  196. package/styles/cspace/DetailPanel.css +69 -0
  197. package/styles/cspace/ExhibitionSection.css +9 -0
  198. package/styles/cspace/FieldList.css +15 -0
  199. package/styles/cspace/FieldListField.css +7 -0
  200. package/styles/cspace/FieldListGroup.css +27 -0
  201. package/styles/cspace/FieldValueList.css +19 -0
  202. package/styles/cspace/Filter.css +64 -0
  203. package/styles/cspace/FilterGroup.css +21 -0
  204. package/styles/cspace/FilterPanel.css +45 -0
  205. package/styles/cspace/FilterSearchInput.css +13 -0
  206. package/styles/cspace/Fixed.css +8 -0
  207. package/styles/cspace/IconButton.css +11 -0
  208. package/styles/cspace/ImageGallery.css +43 -0
  209. package/styles/cspace/InstitutionHoldingList.css +109 -0
  210. package/styles/cspace/InstitutionIndex.css +13 -0
  211. package/styles/cspace/InstitutionSection.css +4 -0
  212. package/styles/cspace/Link.css +39 -0
  213. package/styles/cspace/Panel.css +53 -0
  214. package/styles/cspace/PanelTitle.css +48 -0
  215. package/styles/cspace/RemoveSearchParamLink.css +15 -0
  216. package/styles/cspace/RootPage.css +60 -0
  217. package/styles/cspace/ScrollTopButton.css +32 -0
  218. package/styles/cspace/SearchEntryForm.css +4 -0
  219. package/styles/cspace/SearchEntryPanel.css +11 -0
  220. package/styles/cspace/SearchPage.css +2 -0
  221. package/styles/cspace/SearchParamLink.css +21 -0
  222. package/styles/cspace/SearchParamList.css +6 -0
  223. package/styles/cspace/SearchQueryInput.css +30 -0
  224. package/styles/cspace/SearchResultImage.css +29 -0
  225. package/styles/cspace/SearchResultList.css +10 -0
  226. package/styles/cspace/SearchResultPanel.css +31 -0
  227. package/styles/cspace/SearchResultStats.css +4 -0
  228. package/styles/cspace/SearchResultTile.css +67 -0
  229. package/styles/cspace/SearchStatus.css +12 -0
  230. package/styles/cspace/SearchSubmitButton.css +3 -0
  231. package/styles/cspace/SortSelect.css +19 -0
  232. package/styles/cspace/ToggleFilterPanelButton.css +44 -0
  233. package/styles/dimensions.css +9 -0
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ gatewayUrl: 'http://localhost:8180/gateway/publicart'
9
+ };
10
+ exports.default = _default;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOGGLE_PANEL = exports.SET_SEARCH_PARAMS = exports.SET_SEARCH_PAGE_SIZE = exports.SET_SEARCH_ENTRY_FORM_PARAM = exports.SET_MEDIA = exports.SET_FILTER_SEARCH_VALUE = exports.SET_DETAIL_PARAMS = exports.SEARCH_STARTED = exports.SEARCH_REJECTED = exports.SEARCH_FULFILLED = exports.PREFS_LOADED = exports.OPEN_SEARCH = exports.INST_SEARCH_STARTED = exports.INST_SEARCH_REJECTED = exports.INST_SEARCH_FULFILLED = exports.EXPAND_PANEL = exports.DETAIL_READ_STARTED = exports.DETAIL_READ_REJECTED = exports.DETAIL_READ_FULFILLED = exports.CLEAR_DETAIL = void 0;
7
+ const PREFS_LOADED = 'PREFS_LOADED';
8
+ exports.PREFS_LOADED = PREFS_LOADED;
9
+ const EXPAND_PANEL = 'EXPAND_PANEL';
10
+ exports.EXPAND_PANEL = EXPAND_PANEL;
11
+ const TOGGLE_PANEL = 'TOGGLE_PANEL';
12
+ exports.TOGGLE_PANEL = TOGGLE_PANEL;
13
+ const SET_MEDIA = 'SET_MEDIA';
14
+ exports.SET_MEDIA = SET_MEDIA;
15
+ const OPEN_SEARCH = 'OPEN_SEARCH';
16
+ exports.OPEN_SEARCH = OPEN_SEARCH;
17
+ const SET_SEARCH_PAGE_SIZE = 'SET_SEARCH_PAGE_SIZE';
18
+ exports.SET_SEARCH_PAGE_SIZE = SET_SEARCH_PAGE_SIZE;
19
+ const SET_SEARCH_PARAMS = 'SET_SEARCH_PARAMS';
20
+ exports.SET_SEARCH_PARAMS = SET_SEARCH_PARAMS;
21
+ const SEARCH_STARTED = 'SEARCH_STARTED';
22
+ exports.SEARCH_STARTED = SEARCH_STARTED;
23
+ const SEARCH_FULFILLED = 'SEARCH_FULFILLED';
24
+ exports.SEARCH_FULFILLED = SEARCH_FULFILLED;
25
+ const SEARCH_REJECTED = 'SEARCH_REJECTED';
26
+ exports.SEARCH_REJECTED = SEARCH_REJECTED;
27
+ const SET_SEARCH_ENTRY_FORM_PARAM = 'SET_SEARCH_ENTRY_FORM_PARAM';
28
+ exports.SET_SEARCH_ENTRY_FORM_PARAM = SET_SEARCH_ENTRY_FORM_PARAM;
29
+ const SET_FILTER_SEARCH_VALUE = 'SET_FILTER_SEARCH_VALUE';
30
+ exports.SET_FILTER_SEARCH_VALUE = SET_FILTER_SEARCH_VALUE;
31
+ const CLEAR_DETAIL = 'CLEAR_DETAIL';
32
+ exports.CLEAR_DETAIL = CLEAR_DETAIL;
33
+ const SET_DETAIL_PARAMS = 'SET_DETAIL_PARAMS';
34
+ exports.SET_DETAIL_PARAMS = SET_DETAIL_PARAMS;
35
+ const DETAIL_READ_STARTED = 'DETAIL_READ_STARTED';
36
+ exports.DETAIL_READ_STARTED = DETAIL_READ_STARTED;
37
+ const DETAIL_READ_FULFILLED = 'DETAIL_READ_FULFILLED';
38
+ exports.DETAIL_READ_FULFILLED = DETAIL_READ_FULFILLED;
39
+ const DETAIL_READ_REJECTED = 'DETAIL_READ_REJECTED';
40
+ exports.DETAIL_READ_REJECTED = DETAIL_READ_REJECTED;
41
+ const INST_SEARCH_STARTED = 'INST_SEARCH_STARTED';
42
+ exports.INST_SEARCH_STARTED = INST_SEARCH_STARTED;
43
+ const INST_SEARCH_FULFILLED = 'INST_SEARCH_FULFILLED';
44
+ exports.INST_SEARCH_FULFILLED = INST_SEARCH_FULFILLED;
45
+ const INST_SEARCH_REJECTED = 'INST_SEARCH_REJECTED';
46
+ exports.INST_SEARCH_REJECTED = INST_SEARCH_REJECTED;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SORT_ID = exports.SEARCH_QUERY_ID = exports.FILTER_PANEL_ID = void 0;
7
+ const FILTER_PANEL_ID = 'filter';
8
+ exports.FILTER_PANEL_ID = FILTER_PANEL_ID;
9
+ const SEARCH_QUERY_ID = 'search';
10
+ exports.SEARCH_QUERY_ID = SEARCH_QUERY_ID;
11
+ const SORT_ID = 'sort';
12
+ exports.SORT_ID = SORT_ID;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = className => {
8
+ const name = className.split('--', 1)[0];
9
+ return `has-${name}`;
10
+ };
11
+ exports.default = _default;
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.termFilterParamToQuery = exports.histogramFilterParamToQuery = exports.getTermsAgg = exports.getSort = exports.getSearchResultPayload = exports.getSearchQuery = exports.getQuery = exports.getHistogramAgg = exports.getFilterQueries = exports.getFilterAgg = exports.getAggs = exports.fulltextParamToQuery = exports.filterParamToQuery = void 0;
7
+ var _config = _interopRequireDefault(require("../config"));
8
+ var _ids = require("../constants/ids");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const fulltextParamToQuery = value => {
11
+ if (!value) {
12
+ return undefined;
13
+ }
14
+ const fulltextSearchFields = _config.default.get('fulltextSearchFields');
15
+ return {
16
+ bool: {
17
+ should: [{
18
+ multi_match: {
19
+ query: value,
20
+ fields: fulltextSearchFields,
21
+ type: 'cross_fields',
22
+ operator: 'and'
23
+ }
24
+ }, {
25
+ multi_match: {
26
+ query: value,
27
+ fields: fulltextSearchFields,
28
+ type: 'phrase_prefix',
29
+ operator: 'and'
30
+ }
31
+ }],
32
+ minimum_should_match: '1'
33
+ }
34
+ };
35
+ };
36
+ exports.fulltextParamToQuery = fulltextParamToQuery;
37
+ const termFilterParamToQuery = (field, value) => ({
38
+ terms: {
39
+ [field]: value.toJS()
40
+ }
41
+ });
42
+ exports.termFilterParamToQuery = termFilterParamToQuery;
43
+ const histogramFilterParamToQuery = (field, value, interval) => {
44
+ const clauses = value.map(v => ({
45
+ range: {
46
+ [field]: {
47
+ gte: v,
48
+ lt: v + interval
49
+ }
50
+ }
51
+ })).toJS();
52
+ if (clauses.length === 1) {
53
+ return clauses[0];
54
+ }
55
+ return {
56
+ bool: {
57
+ should: clauses
58
+ }
59
+ };
60
+ };
61
+ exports.histogramFilterParamToQuery = histogramFilterParamToQuery;
62
+ const filterParamToQuery = (id, value) => {
63
+ const filterFieldConfig = _config.default.getFilterFieldConfig(id);
64
+ if (!filterFieldConfig) {
65
+ return undefined;
66
+ }
67
+ const {
68
+ field,
69
+ type
70
+ } = filterFieldConfig;
71
+ if (type === 'histogram') {
72
+ return histogramFilterParamToQuery(field, value, filterFieldConfig.interval);
73
+ }
74
+ return termFilterParamToQuery(field, value);
75
+ };
76
+ exports.filterParamToQuery = filterParamToQuery;
77
+ const getSearchQuery = params => fulltextParamToQuery(params.get(_ids.SEARCH_QUERY_ID));
78
+ exports.getSearchQuery = getSearchQuery;
79
+ const getFilterQueries = params => params.delete(_ids.SEARCH_QUERY_ID).entrySeq().map(_ref => {
80
+ let [id, value] = _ref;
81
+ return filterParamToQuery(id, value);
82
+ }).toJS();
83
+ exports.getFilterQueries = getFilterQueries;
84
+ const getQuery = params => {
85
+ const clauses = [_config.default.get('defaultQuery'), getSearchQuery(params), ...getFilterQueries(params)].filter(clause => !!clause);
86
+ if (clauses.length > 1) {
87
+ return {
88
+ bool: {
89
+ must: clauses
90
+ }
91
+ };
92
+ }
93
+ if (clauses.length > 0) {
94
+ return clauses[0];
95
+ }
96
+ return {
97
+ match_all: {}
98
+ };
99
+ };
100
+ exports.getQuery = getQuery;
101
+ const getHistogramAgg = function (field) {
102
+ let interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
103
+ return {
104
+ histogram: {
105
+ field,
106
+ interval,
107
+ min_doc_count: 1
108
+ }
109
+ };
110
+ };
111
+ exports.getHistogramAgg = getHistogramAgg;
112
+ const getTermsAgg = function (field) {
113
+ let order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
114
+ _term: 'asc'
115
+ };
116
+ return {
117
+ terms: {
118
+ field,
119
+ order,
120
+ size: 300
121
+ }
122
+ };
123
+ };
124
+ exports.getTermsAgg = getTermsAgg;
125
+ const getFilterAgg = filterFieldConfig => {
126
+ const {
127
+ field,
128
+ order,
129
+ type
130
+ } = filterFieldConfig;
131
+ if (type === 'histogram') {
132
+ return getHistogramAgg(field, filterFieldConfig.interval);
133
+ }
134
+ return getTermsAgg(field, order);
135
+ };
136
+ exports.getFilterAgg = getFilterAgg;
137
+ let aggs;
138
+ const getAggs = params => {
139
+ if (!aggs) {
140
+ aggs = {};
141
+ const filterFieldsConfig = _config.default.get('filters').fields;
142
+ Object.entries(filterFieldsConfig).forEach(_ref2 => {
143
+ let [id, filterFieldConfig] = _ref2;
144
+ const param = params.get(id);
145
+ const hasValue = param && param.size > 0;
146
+ if (!hasValue) {
147
+ aggs[id] = getFilterAgg(filterFieldConfig);
148
+ }
149
+ });
150
+ }
151
+ return aggs;
152
+ };
153
+ exports.getAggs = getAggs;
154
+ const getSort = params => {
155
+ const sortOrder = params.get(_ids.SORT_ID) || _config.default.get('defaultSortOrder');
156
+ const effectiveSortOrder = sortOrder === 'bestmatch' && params.delete(_ids.SORT_ID).isEmpty() ? 'newest' : sortOrder;
157
+ switch (effectiveSortOrder) {
158
+ case 'bestmatch':
159
+ return [{
160
+ _score: {
161
+ order: 'desc'
162
+ }
163
+ }, {
164
+ [_config.default.get('sortField')]: {
165
+ order: 'asc'
166
+ }
167
+ }];
168
+ case 'atoz':
169
+ return {
170
+ [_config.default.get('sortField')]: {
171
+ order: 'asc'
172
+ }
173
+ };
174
+ case 'ztoa':
175
+ return {
176
+ [_config.default.get('sortField')]: {
177
+ order: 'desc'
178
+ }
179
+ };
180
+ case 'newest':
181
+ return {
182
+ 'collectionspace_core:createdAt': {
183
+ order: 'desc'
184
+ }
185
+ };
186
+ case 'oldest':
187
+ return {
188
+ 'collectionspace_core:createdAt': {
189
+ order: 'asc'
190
+ }
191
+ };
192
+ default:
193
+ return {};
194
+ }
195
+ };
196
+ exports.getSort = getSort;
197
+ const getSearchResultPayload = (params, pageSize, offset) => ({
198
+ query: getQuery(params.delete(_ids.SORT_ID)),
199
+ from: offset,
200
+ size: pageSize,
201
+ _source: {
202
+ includes: _config.default.get('includeFields')
203
+ },
204
+ sort: getSort(params)
205
+ });
206
+ exports.getSearchResultPayload = getSearchResultPayload;
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.valueWithNote = exports.valueAt = exports.unqualifiedFieldName = exports.unformatted = exports.renderLink = exports.renderJoined = exports.renderFilterLink = exports.property = exports.pickFromList = exports.pickAllFromList = exports.paragraphs = exports.objectTypeValue = exports.numericRange = exports.nameValue = exports.nameRole = exports.literal = exports.listOf = exports.list = exports.linkedDisplayName = exports.linkText = exports.linkNote = exports.lines = exports.inlineListOf = exports.inlineList = exports.html = exports.filterLink = exports.displayNameFrom = exports.displayName = exports.decade = exports.collectionValue = exports.boolean = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _get = _interopRequireDefault(require("lodash/get"));
9
+ var _qs = _interopRequireDefault(require("qs"));
10
+ var _reactRouterDom = require("react-router-dom");
11
+ var _cspaceRefname = require("cspace-refname");
12
+ var _FieldValueList = _interopRequireDefault(require("../components/detail/FieldValueList"));
13
+ var _Link = _interopRequireDefault(require("../../styles/cspace/Link.css"));
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ const renderLink = (url, text, type) => {
16
+ if (!url) {
17
+ return text;
18
+ }
19
+ if (type === 'external') {
20
+ const fullUrl = !url.startsWith('http') ? `http://${url}` : url;
21
+ const content = text || url;
22
+
23
+ // Make sure urls with no spaces are able to wrap anywhere.
24
+
25
+ const inlineStyle = content.startsWith('http') ? {
26
+ overflowWrap: 'anywhere'
27
+ } : undefined;
28
+ return /*#__PURE__*/_react.default.createElement("a", {
29
+ className: _Link.default[type],
30
+ href: fullUrl,
31
+ rel: "noopener noreferrer",
32
+ style: inlineStyle,
33
+ target: "_blank"
34
+ }, content);
35
+ }
36
+ return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
37
+ className: type && _Link.default[type],
38
+ to: url
39
+ }, text || url);
40
+ };
41
+ exports.renderLink = renderLink;
42
+ const renderFilterLink = (filterId, filterValue, linkText) => {
43
+ if (!filterValue) {
44
+ return null;
45
+ }
46
+ const values = [filterValue];
47
+ const query = _qs.default.stringify({
48
+ [filterId]: JSON.stringify(values)
49
+ });
50
+ return renderLink(`/search?${query}`, typeof linkText === 'undefined' ? filterValue : linkText);
51
+ };
52
+ exports.renderFilterLink = renderFilterLink;
53
+ const renderJoined = function (parts) {
54
+ let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
55
+ const nonEmptyParts = parts.filter(part => typeof part !== 'undefined' && part !== null && part !== '');
56
+ if (nonEmptyParts.length === 0) {
57
+ return null;
58
+ }
59
+ const separatorElement = separator === '\n' ? /*#__PURE__*/_react.default.createElement("br", null) : separator;
60
+ return nonEmptyParts.reduce((joinedParts, nextPart) =>
61
+ /*#__PURE__*/
62
+ // eslint-disable-next-line react/jsx-one-expression-per-line
63
+ _react.default.createElement("span", null, joinedParts, separatorElement, nextPart));
64
+ };
65
+ exports.renderJoined = renderJoined;
66
+ const renderList = function (values) {
67
+ let inline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
68
+ if (Array.isArray(values)) {
69
+ if (values.length > 1) {
70
+ return /*#__PURE__*/_react.default.createElement(_FieldValueList.default, {
71
+ inline: inline
72
+ }, values.map((value, index) => /*#__PURE__*/_react.default.createElement("li", {
73
+ key: index
74
+ }, value)));
75
+ }
76
+ return values[0];
77
+ }
78
+ return values;
79
+ };
80
+ const unformatted = data => data;
81
+ exports.unformatted = unformatted;
82
+ const boolean = value => {
83
+ switch (value) {
84
+ case 0:
85
+ return 'No';
86
+ case 1:
87
+ return 'Yes';
88
+ default:
89
+ return value;
90
+ }
91
+ };
92
+ exports.boolean = boolean;
93
+ const literal = value => () => value;
94
+ exports.literal = literal;
95
+ const collectionValue = value => value.replace('_', '-');
96
+ exports.collectionValue = collectionValue;
97
+ const objectTypeValue = value => value.replace('_', '-');
98
+ exports.objectTypeValue = objectTypeValue;
99
+ const lines = values => values && values.join('\n');
100
+ exports.lines = lines;
101
+ const list = values => renderList(values);
102
+ exports.list = list;
103
+ const inlineList = values => renderJoined(values, ', ');
104
+ exports.inlineList = inlineList;
105
+ const listOf = format => (array, fieldName) => renderList(array.map(value => format(value, fieldName)));
106
+ exports.listOf = listOf;
107
+ const inlineListOf = format => (array, fieldName) => renderJoined(array.map(value => format(value, fieldName)), ', ');
108
+ exports.inlineListOf = inlineListOf;
109
+ const displayName = value => (0, _cspaceRefname.getDisplayName)(value) || value;
110
+ exports.displayName = displayName;
111
+ const displayNameFrom = name => data => displayName(data[name]);
112
+ exports.displayNameFrom = displayNameFrom;
113
+ const unqualifiedFieldName = (data, fieldName) => {
114
+ const parts = fieldName.split(':');
115
+ return parts.length > 1 ? parts[1] : parts[0];
116
+ };
117
+ exports.unqualifiedFieldName = unqualifiedFieldName;
118
+ const filterLink = config => (data, fieldName) => {
119
+ const {
120
+ filterIdFormat = unqualifiedFieldName,
121
+ filterValueFormat = unformatted,
122
+ linkTextFormat
123
+ } = config;
124
+ const formattedFilterId = filterIdFormat(data, fieldName);
125
+ const formattedFilterValue = filterValueFormat(data, fieldName);
126
+ const formattedLinkText = linkTextFormat ? linkTextFormat(data, fieldName) : formattedFilterValue;
127
+ return renderFilterLink(formattedFilterId, formattedFilterValue, formattedLinkText);
128
+ };
129
+ exports.filterLink = filterLink;
130
+ const linkNote = function (urlField, noteField) {
131
+ let separator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' - ';
132
+ return object => {
133
+ const {
134
+ [noteField]: note,
135
+ [urlField]: url
136
+ } = object;
137
+ const link = renderLink(url);
138
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, link, link && note && separator, note);
139
+ };
140
+ };
141
+ exports.linkNote = linkNote;
142
+ const linkedDisplayName = filterId => data => renderFilterLink(filterId, displayName(data));
143
+ exports.linkedDisplayName = linkedDisplayName;
144
+ const linkText = config => data => {
145
+ const {
146
+ urlFieldName,
147
+ textFieldName,
148
+ type
149
+ } = config;
150
+ return renderLink(data[urlFieldName], data[textFieldName], type);
151
+ };
152
+ exports.linkText = linkText;
153
+ const nameValue = config => (data, fieldName) => {
154
+ const {
155
+ nameFormat,
156
+ valueFormat,
157
+ separator = ': '
158
+ } = config;
159
+ const formattedName = nameFormat(data, fieldName);
160
+ const formattedValue = valueFormat(data, fieldName);
161
+ const parts = [formattedName, formattedValue];
162
+ return renderJoined(parts, separator);
163
+ };
164
+ exports.nameValue = nameValue;
165
+ const property = config => data => {
166
+ const {
167
+ nameFieldName,
168
+ valueFieldName,
169
+ separator = ': '
170
+ } = config;
171
+ const parts = [renderFilterLink(nameFieldName, displayName(data[nameFieldName])), data[valueFieldName]];
172
+ return renderJoined(parts, separator);
173
+ };
174
+ exports.property = property;
175
+ const nameRole = config => data => {
176
+ const {
177
+ nameFieldName,
178
+ roleFieldName,
179
+ linkName = true,
180
+ separator = ' '
181
+ } = config;
182
+ const name = displayName(data[nameFieldName]);
183
+ let role = displayName(data[roleFieldName]);
184
+ if (role) {
185
+ role = `(${role})`;
186
+ }
187
+ const parts = [linkName ? renderFilterLink(nameFieldName, name) : name, role];
188
+ return renderJoined(parts, separator);
189
+ };
190
+ exports.nameRole = nameRole;
191
+ const valueWithNote = config => data => {
192
+ const {
193
+ valueFieldName,
194
+ noteFieldName,
195
+ linkValue = true,
196
+ separator = '\n',
197
+ noteLabel = 'Note: '
198
+ } = config;
199
+ const value = displayName(data[valueFieldName]);
200
+ let note = data[noteFieldName];
201
+ if (note) {
202
+ note = `${noteLabel}${note}`;
203
+ }
204
+ const parts = [linkValue ? renderFilterLink(valueFieldName, value) : value, note];
205
+ return renderJoined(parts, separator);
206
+ };
207
+ exports.valueWithNote = valueWithNote;
208
+ const numericRange = config => data => {
209
+ const {
210
+ linkQualifier,
211
+ lowFieldName,
212
+ highFieldName,
213
+ unitFieldName,
214
+ qualifierFieldName,
215
+ qualifierSeparator = ' '
216
+ } = config;
217
+ let {
218
+ unit
219
+ } = config;
220
+ const low = data[lowFieldName];
221
+ const high = data[highFieldName];
222
+ const range = [low, high].filter(part => !!part).join('-');
223
+ if (range) {
224
+ unit = unit || displayName(data[unitFieldName]);
225
+ } else {
226
+ unit = null;
227
+ }
228
+ const qualifier = displayName(data[qualifierFieldName]);
229
+ const rangeUnit = renderJoined([range, unit], ' ');
230
+ return renderJoined([rangeUnit, linkQualifier ? renderFilterLink(qualifierFieldName, qualifier) : qualifier], qualifierSeparator);
231
+ };
232
+ exports.numericRange = numericRange;
233
+ const paragraphs = array =>
234
+ // eslint-disable-next-line react/no-array-index-key
235
+ array && array.length > 0 && array.map((value, index) => /*#__PURE__*/_react.default.createElement("p", {
236
+ key: index
237
+ }, value));
238
+ exports.paragraphs = paragraphs;
239
+ const valueAt = config => data => {
240
+ const {
241
+ path,
242
+ format = unformatted
243
+ } = config;
244
+ const value = (0, _get.default)(data, path);
245
+ const fieldName = Array.isArray(path) ? path[path.length - 1] : path;
246
+ return format(value, fieldName);
247
+ };
248
+ exports.valueAt = valueAt;
249
+ const pickFromList = config => array => {
250
+ const {
251
+ condition,
252
+ format
253
+ } = config;
254
+ const {
255
+ path,
256
+ value: targetValue
257
+ } = condition;
258
+ const value = array.find(candidateItem => {
259
+ const candidateValue = path ? (0, _get.default)(candidateItem, path) : candidateItem;
260
+ return candidateValue === targetValue;
261
+ });
262
+ return format ? format(value) : value;
263
+ };
264
+ exports.pickFromList = pickFromList;
265
+ const pickAllFromList = config => array => {
266
+ const {
267
+ condition,
268
+ format
269
+ } = config;
270
+ const {
271
+ path,
272
+ value: targetValue
273
+ } = condition;
274
+ const values = array.filter(candidateItem => {
275
+ const candidateValue = path ? (0, _get.default)(candidateItem, path) : candidateItem;
276
+ return candidateValue === targetValue;
277
+ });
278
+ return renderJoined(format ? values.map(format) : values, '\n');
279
+ };
280
+ exports.pickAllFromList = pickAllFromList;
281
+ const decade = startYear => {
282
+ const endYear = startYear + 9;
283
+ return `${startYear}–${endYear}`;
284
+ };
285
+
286
+ // eslint-disable-next-line react/no-danger
287
+ exports.decade = decade;
288
+ const html = value => /*#__PURE__*/_react.default.createElement("div", {
289
+ dangerouslySetInnerHTML: {
290
+ __html: value
291
+ }
292
+ });
293
+ exports.html = html;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.calculateSearchPageSize = calculateSearchPageSize;
7
+ exports.tileWidth = exports.tileHeight = exports.tileBodyHeight = void 0;
8
+ var _dimensions = _interopRequireDefault(require("../../styles/dimensions.css"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ /* global window */
11
+
12
+ const {
13
+ searchResultTileWidth: cssTileWidth,
14
+ searchResultTileBodyHeight: cssTileBodyHeight
15
+ } = _dimensions.default;
16
+ const tileWidth = parseInt(cssTileWidth, 10);
17
+ exports.tileWidth = tileWidth;
18
+ const tileBodyHeight = parseInt(cssTileBodyHeight, 10);
19
+ exports.tileBodyHeight = tileBodyHeight;
20
+ const tileHeight = tileWidth + tileBodyHeight;
21
+ exports.tileHeight = tileHeight;
22
+ function calculateSearchPageSize() {
23
+ const width = window.innerWidth;
24
+ const height = window.innerHeight;
25
+ const ratio = window.devicePixelRatio || 1;
26
+ const pageSize = width / tileWidth * (height / tileHeight + 2) / ratio;
27
+ return Math.max(Math.ceil(pageSize), 12);
28
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.searchParamsToQueryString = exports.locationToSearchParams = exports.locationToDetailParams = exports.blobUrl = void 0;
7
+ var _qs = _interopRequireDefault(require("qs"));
8
+ var _immutable = _interopRequireDefault(require("immutable"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const blobUrl = (gatewayUrl, mediaCsid, derivative) => `${gatewayUrl}/cspace-services/media/${mediaCsid}/blob/derivatives/${derivative}/content`;
11
+ exports.blobUrl = blobUrl;
12
+ const searchParamsToQueryString = params => _qs.default.stringify(params.map(value => value && JSON.stringify(value)).filter(value => !!value).toJS(), {
13
+ format: 'RFC1738'
14
+ });
15
+ exports.searchParamsToQueryString = searchParamsToQueryString;
16
+ const locationToSearchParams = location => _immutable.default.Map(_qs.default.parse(location.search, {
17
+ ignoreQueryPrefix: true
18
+ })).filter(value => !!value).map(value => _immutable.default.fromJS(JSON.parse(value)));
19
+ exports.locationToSearchParams = locationToSearchParams;
20
+ const locationToDetailParams = (location, match) => {
21
+ let params = _immutable.default.fromJS(match.params);
22
+ const {
23
+ hash,
24
+ state
25
+ } = location;
26
+ if (hash) {
27
+ params = params.set('#', hash.substring(1));
28
+ }
29
+ if (state) {
30
+ const {
31
+ index,
32
+ searchParams
33
+ } = state;
34
+ if (typeof index !== 'undefined') {
35
+ params = params.set('index', index);
36
+ }
37
+ if (typeof searchParams !== 'undefined') {
38
+ params = params.set('searchParams', _immutable.default.fromJS(searchParams));
39
+ }
40
+ }
41
+ return params;
42
+ };
43
+ exports.locationToDetailParams = locationToDetailParams;