@k-int/stripes-kint-components 2.3.2 → 2.4.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 (226) hide show
  1. package/CHANGELOG.md +15 -4
  2. package/es/artifacts/coverage-jest/lcov-report/block-navigation.js +109 -0
  3. package/es/artifacts/coverage-jest/lcov-report/prettify.js +998 -0
  4. package/es/artifacts/coverage-jest/lcov-report/sorter.js +238 -0
  5. package/es/index.js +31 -3
  6. package/es/lib/ActionList/ActionList.js +31 -1
  7. package/es/lib/ActionList/ActionListFieldArray.js +39 -2
  8. package/es/lib/ActionList/index.js +5 -1
  9. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +35 -1
  10. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +46 -7
  11. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +34 -1
  12. package/es/lib/CustomProperties/Config/CustomPropertyView.js +30 -1
  13. package/es/lib/CustomProperties/Config/index.js +5 -1
  14. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +30 -1
  15. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +34 -1
  16. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +37 -1
  17. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +34 -1
  18. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +30 -1
  19. package/es/lib/CustomProperties/Edit/index.js +5 -1
  20. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +34 -1
  21. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +34 -1
  22. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +34 -1
  23. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +30 -1
  24. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +35 -1
  25. package/es/lib/CustomProperties/Filter/index.js +5 -1
  26. package/es/lib/CustomProperties/Filter/useOperators.js +39 -1
  27. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +34 -1
  28. package/es/lib/CustomProperties/Filter/useValueProps.js +35 -1
  29. package/es/lib/CustomProperties/View/CustomPropertiesView.js +30 -1
  30. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +56 -16
  31. package/es/lib/CustomProperties/View/CustomPropertyCard.js +33 -3
  32. package/es/lib/CustomProperties/View/index.js +5 -1
  33. package/es/lib/CustomProperties/index.js +5 -1
  34. package/es/lib/EditableRefdataList/EditableRefdataList.js +35 -1
  35. package/es/lib/EditableRefdataList/index.js +5 -1
  36. package/es/lib/EditableSettingsList/EditableSettingsList.js +30 -1
  37. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +30 -1
  38. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +30 -1
  39. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.js +34 -1
  40. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +34 -1
  41. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.js +34 -1
  42. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +41 -1
  43. package/es/lib/EditableSettingsList/SettingField/SettingField.js +34 -1
  44. package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +30 -1
  45. package/es/lib/EditableSettingsList/SettingField/index.js +5 -1
  46. package/es/lib/EditableSettingsList/index.js +5 -1
  47. package/es/lib/FormModal/FormModal.js +30 -1
  48. package/es/lib/FormModal/index.js +5 -1
  49. package/es/lib/NoResultsMessage/NoResultsMessage.js +30 -1
  50. package/es/lib/NoResultsMessage/index.js +5 -1
  51. package/es/lib/QueryTypedown/QueryTypedown.js +34 -1
  52. package/es/lib/QueryTypedown/index.js +5 -1
  53. package/es/lib/RefdataButtons/RefdataButtons.js +34 -1
  54. package/es/lib/RefdataButtons/index.js +5 -1
  55. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +94 -105
  56. package/es/lib/SASQLookupComponent/TableBody/TableBody.js +146 -0
  57. package/es/lib/SASQLookupComponent/TableBody/index.js +19 -0
  58. package/es/lib/SASQLookupComponent/index.js +14 -2
  59. package/es/lib/SASQRoute/SASQRoute.js +32 -3
  60. package/es/lib/SASQRoute/index.js +5 -1
  61. package/es/lib/SASQViewComponent/SASQViewComponent.js +34 -1
  62. package/es/lib/SASQViewComponent/index.js +5 -1
  63. package/es/lib/SearchField/SearchField.js +31 -1
  64. package/es/lib/SearchField/index.js +5 -1
  65. package/es/lib/SettingPage/SettingPage.js +34 -1
  66. package/es/lib/SettingPage/SettingPagePane.js +32 -1
  67. package/es/lib/SettingPage/index.js +5 -1
  68. package/es/lib/Typedown/Typedown.js +34 -1
  69. package/es/lib/Typedown/index.js +5 -1
  70. package/es/lib/constants/customProperties.js +38 -1
  71. package/es/lib/constants/eventCodes.js +31 -1
  72. package/es/lib/contexts/SettingsContext.js +30 -1
  73. package/es/lib/contexts/index.js +5 -1
  74. package/es/lib/hooks/index.js +5 -1
  75. package/es/lib/hooks/settingsHooks/index.js +5 -1
  76. package/es/lib/hooks/settingsHooks/useSettingSection.js +34 -1
  77. package/es/lib/hooks/settingsHooks/useSettings.js +36 -1
  78. package/es/lib/hooks/typedownHooks/index.js +5 -1
  79. package/es/lib/hooks/typedownHooks/useTypedown.js +34 -1
  80. package/es/lib/hooks/typedownHooks/useTypedownData.js +34 -1
  81. package/es/lib/hooks/typedownHooks/useTypedownToggle.js +34 -1
  82. package/es/lib/hooks/useActiveElement.js +32 -1
  83. package/es/lib/hooks/useAvailableCustomProperties.js +34 -1
  84. package/es/lib/hooks/useCustomProperties.js +34 -1
  85. package/es/lib/hooks/useHelperApp.js +34 -1
  86. package/es/lib/hooks/useInvalidateRefdata.js +34 -1
  87. package/es/lib/hooks/useKiwtFieldArray.js +34 -1
  88. package/es/lib/hooks/useKiwtSASQuery.js +35 -1
  89. package/es/lib/hooks/useLocalStorageState.js +34 -1
  90. package/es/lib/hooks/useMutateCustomProperties.js +34 -1
  91. package/es/lib/hooks/useMutateRefdataValue.js +34 -1
  92. package/es/lib/hooks/useQIndex.js +34 -1
  93. package/es/lib/hooks/useRefdata.js +34 -1
  94. package/es/lib/hooks/useTemplates.js +34 -1
  95. package/es/lib/utils/buildUrl.js +31 -2
  96. package/es/lib/utils/generateKiwtQuery.js +30 -1
  97. package/es/lib/utils/generateKiwtQueryParams.js +51 -5
  98. package/es/lib/utils/groupCustomPropertiesByCtx.js +30 -1
  99. package/es/lib/utils/highlightString.js +94 -0
  100. package/es/lib/utils/index.js +27 -1
  101. package/es/lib/utils/matchString.js +59 -0
  102. package/es/lib/utils/refdataOptions.js +30 -1
  103. package/es/lib/utils/refdataQueryKey.js +30 -1
  104. package/es/lib/utils/renderHelpText.js +30 -1
  105. package/es/lib/utils/selectorSafe.js +30 -1
  106. package/es/lib/utils/sortByLabel.js +30 -1
  107. package/es/lib/utils/toCamelCase.js +30 -1
  108. package/es/lib/utils/typedownQueryKey.js +30 -1
  109. package/es/lib/utils/validators.js +32 -1
  110. package/junit.xml +79 -0
  111. package/package.json +1 -1
  112. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +286 -0
  113. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +925 -0
  114. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +146 -0
  115. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +88 -0
  116. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesLookup.js.html +418 -0
  117. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesSettings.js.html +808 -0
  118. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesView.js.html +601 -0
  119. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +1135 -0
  120. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +176 -0
  121. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +97 -0
  122. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +373 -0
  123. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +131 -0
  124. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +88 -0
  125. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +223 -0
  126. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +211 -0
  127. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +376 -0
  128. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +262 -0
  129. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +436 -0
  130. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +161 -0
  131. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +94 -0
  132. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +146 -0
  133. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +94 -0
  134. package/src/artifacts/coverage-jest/lcov-report/FormModal/FormModal.js.html +283 -0
  135. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.html +131 -0
  136. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.js.html +88 -0
  137. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +319 -0
  138. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +131 -0
  139. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +88 -0
  140. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +184 -0
  141. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +131 -0
  142. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +88 -0
  143. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +370 -0
  144. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +131 -0
  145. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +88 -0
  146. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +949 -0
  147. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +131 -0
  148. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +88 -0
  149. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +301 -0
  150. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +131 -0
  151. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +88 -0
  152. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +253 -0
  153. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +131 -0
  154. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +88 -0
  155. package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +214 -0
  156. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +131 -0
  157. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +88 -0
  158. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +211 -0
  159. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +178 -0
  160. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +146 -0
  161. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +91 -0
  162. package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +919 -0
  163. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +131 -0
  164. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +88 -0
  165. package/src/artifacts/coverage-jest/lcov-report/base.css +224 -0
  166. package/src/artifacts/coverage-jest/lcov-report/block-navigation.js +87 -0
  167. package/src/artifacts/coverage-jest/lcov-report/constants/customProperties.js.html +112 -0
  168. package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +94 -0
  169. package/src/artifacts/coverage-jest/lcov-report/constants/index.html +131 -0
  170. package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +97 -0
  171. package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +131 -0
  172. package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +91 -0
  173. package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
  174. package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +281 -0
  175. package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +121 -0
  176. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +146 -0
  177. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +91 -0
  178. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +163 -0
  179. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +403 -0
  180. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +161 -0
  181. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +94 -0
  182. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +520 -0
  183. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +163 -0
  184. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +163 -0
  185. package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +157 -0
  186. package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +313 -0
  187. package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +283 -0
  188. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +274 -0
  189. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +178 -0
  190. package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +136 -0
  191. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateCustomProperties.js.html +271 -0
  192. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +301 -0
  193. package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +208 -0
  194. package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +268 -0
  195. package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +166 -0
  196. package/src/artifacts/coverage-jest/lcov-report/index.html +416 -0
  197. package/src/artifacts/coverage-jest/lcov-report/prettify.css +1 -0
  198. package/src/artifacts/coverage-jest/lcov-report/prettify.js +2 -0
  199. package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
  200. package/src/artifacts/coverage-jest/lcov-report/sorter.js +196 -0
  201. package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +193 -0
  202. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +109 -0
  203. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +454 -0
  204. package/src/artifacts/coverage-jest/lcov-report/utils/index.html +251 -0
  205. package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +121 -0
  206. package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +106 -0
  207. package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +166 -0
  208. package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +103 -0
  209. package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +130 -0
  210. package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +127 -0
  211. package/src/artifacts/coverage-jest/lcov-report/utils/validators.js.html +202 -0
  212. package/src/artifacts/coverage-jest/lcov.info +2562 -0
  213. package/src/index.js +6 -1
  214. package/src/lib/ActionList/ActionListFieldArray.js +1 -1
  215. package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +9 -6
  216. package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +13 -8
  217. package/src/lib/CustomProperties/View/CustomPropertyCard.js +2 -2
  218. package/src/lib/SASQLookupComponent/SASQLookupComponent.js +39 -77
  219. package/src/lib/SASQLookupComponent/TableBody/TableBody.js +96 -0
  220. package/src/lib/SASQLookupComponent/TableBody/index.js +1 -0
  221. package/src/lib/SASQLookupComponent/index.js +2 -1
  222. package/src/lib/SASQRoute/SASQRoute.js +1 -1
  223. package/src/lib/utils/generateKiwtQueryParams.js +10 -1
  224. package/src/lib/utils/highlightString.js +42 -0
  225. package/src/lib/utils/index.js +4 -0
  226. package/src/lib/utils/matchString.js +14 -0
package/src/index.js CHANGED
@@ -18,9 +18,12 @@ export {
18
18
 
19
19
  // Useful utility functions
20
20
  export {
21
+ boldString,
21
22
  generateKiwtQuery,
22
23
  generateKiwtQueryParams,
23
24
  groupCustomPropertiesByCtx,
25
+ highlightString,
26
+ matchString,
24
27
  refdataOptions,
25
28
  refdataQueryKey,
26
29
  selectorSafe,
@@ -59,6 +62,7 @@ export {
59
62
  default as QueryTypedown
60
63
  } from './lib/QueryTypedown';
61
64
 
65
+ /* SASQ Stuff */
62
66
  // SearchField
63
67
  export {
64
68
  default as SearchField
@@ -71,7 +75,8 @@ export {
71
75
 
72
76
  // SASQLookupComponent
73
77
  export {
74
- default as SASQLookupComponent
78
+ SASQLookupComponent,
79
+ TableBody as SASQTableBody
75
80
  } from './lib/SASQLookupComponent';
76
81
 
77
82
  // SASQViewComponent
@@ -228,7 +228,7 @@ const ActionListFieldArray = ({
228
228
  name: `${fieldName}.${key}`
229
229
  }) :
230
230
  <Field
231
- autofocus={fieldIndex === 0}
231
+ autoFocus={fieldIndex === 0}
232
232
  component={TextField}
233
233
  marginBottom0
234
234
  name={`${fieldName}.${key}`}
@@ -78,20 +78,23 @@ const CustomPropertiesSettings = ({
78
78
  delete: deleteCustProp
79
79
  } = useMutateCustomProperties({
80
80
  afterQueryCalls: {
81
- put: () => {
81
+ put: res => {
82
82
  setMode(VIEWING);
83
83
  queryClient.invalidateQueries(['stripes-kint-components', 'useCustomProperties', 'custprops']);
84
- afterQueryCallsSafe.put();
84
+ setCustomProperty(res);
85
+ afterQueryCallsSafe.put(res);
85
86
  },
86
- post: () => {
87
+ post: res => {
87
88
  setMode(VIEWING);
88
89
  queryClient.invalidateQueries(['stripes-kint-components', 'useCustomProperties', 'custprops']);
89
- afterQueryCallsSafe.post();
90
+ setCustomProperty(res);
91
+ afterQueryCallsSafe.post(res);
90
92
  },
91
- delete: () => {
93
+ delete: res => {
92
94
  setMode(VIEWING);
93
95
  queryClient.invalidateQueries(['stripes-kint-components', 'useCustomProperties', 'custprops']);
94
- afterQueryCallsSafe.delete();
96
+ setCustomProperty();
97
+ afterQueryCallsSafe.delete(res);
95
98
  }
96
99
  },
97
100
  endpoint: customPropertiesEndpoint,
@@ -69,21 +69,26 @@ const CustomPropertiesViewCtx = ({
69
69
  );
70
70
  }
71
71
 
72
+ const countSetProperties = (primary) => (
73
+ Object.entries(customProperties)?.filter(
74
+ ([_key, cp]) => (
75
+ (cp[0]?.type?.ctx === ctx || (ctx === 'isNull' && !cp[0]?.type?.ctx)) && // Either the ctx string matches, or isNull matches blank
76
+ cp[0]?.type?.primary === primary // Only count non-primary set custprops
77
+ )
78
+ )?.length ?? 0
79
+ );
80
+
72
81
  // We need to display any set properties, along with any non-set primary properties
73
82
  const primaryCount = custprops?.filter(cp => cp.primary === true)?.length ?? 0;
74
- const optionalCount = Object.entries(customProperties)?.filter(
75
- ([_key, cp]) => (
76
- (cp[0]?.type?.ctx === ctx || (ctx === 'isNull' && !cp[0]?.type?.ctx)) && // Either the ctx string matches, or isNull matches blank
77
- cp[0]?.type?.primary === false // Only count non-primary set custprops
78
- )
79
- )?.length ?? 0;
83
+ const optionalCount = countSetProperties(false);
84
+ const setPrimaryCount = countSetProperties(true);
80
85
 
81
86
  return (
82
87
  (primaryCount + optionalCount) > 0 &&
83
88
  <Accordion
84
89
  closedByDefault
85
- displayWhenClosed={<Badge>{primaryCount + optionalCount}</Badge>}
86
- displayWhenOpen={<Badge>{primaryCount + optionalCount}</Badge>}
90
+ displayWhenClosed={<Badge>{setPrimaryCount + optionalCount}</Badge>}
91
+ displayWhenOpen={<Badge>{setPrimaryCount + optionalCount}</Badge>}
87
92
  id={`${id}-accordion-${ctx}`}
88
93
  label={getAccordionLabel()}
89
94
  >
@@ -16,7 +16,7 @@ import * as CUSTPROP_TYPES from '../../constants/customProperties';
16
16
  const CustomPropertyCard = ({
17
17
  ctx,
18
18
  customProperty,
19
- customPropertyDefinition,
19
+ customPropertyDefinition = {},
20
20
  index,
21
21
  labelOverrides
22
22
  }) => {
@@ -35,7 +35,7 @@ const CustomPropertyCard = ({
35
35
  // Label override for default card title,
36
36
  if (labelOverrides.retiredName && typeof labelOverrides.retiredName === 'function') {
37
37
  return (
38
- labelOverrides.retiredName(customPropertyDefinition)
38
+ labelOverrides.retiredName(customPropertyDefinition.name)
39
39
  );
40
40
  }
41
41
 
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
3
2
  import { FormattedMessage } from 'react-intl';
4
3
  import { useInfiniteQuery } from 'react-query';
@@ -17,34 +16,30 @@ import {
17
16
  Button,
18
17
  IconButton,
19
18
  Icon,
20
- MultiColumnList,
21
19
  Pane,
22
20
  PaneMenu,
23
21
  SearchField,
24
22
  } from '@folio/stripes/components';
25
- import NoResultsMessage from '../NoResultsMessage';
26
23
 
27
24
  import { generateKiwtQuery } from '../utils';
28
25
  import { useKiwtSASQuery, useLocalStorageState } from '../hooks';
29
26
 
27
+ import TableBody from './TableBody';
28
+
29
+ const SASQLookupComponent = (props) => {
30
+ const {
31
+ children,
32
+ fetchParameters = {},
33
+ FilterComponent = () => null,
34
+ FilterPaneHeaderComponent = () => null,
35
+ filterPaneProps,
36
+ id,
37
+ mainPaneProps,
38
+ noSearchField,
39
+ RenderBody,
40
+ sasqProps,
41
+ } = props;
30
42
 
31
- const SASQLookupComponent = ({
32
- children,
33
- fetchParameters = {},
34
- FilterPaneHeaderComponent = () => null,
35
- FilterComponent = () => null,
36
- history,
37
- id,
38
- location,
39
- mainPaneProps,
40
- match,
41
- mclProps,
42
- noSearchField,
43
- path,
44
- resultColumns = [],
45
- RenderBody,
46
- sasqProps,
47
- }) => {
48
43
  const { query, queryGetter, querySetter } = useKiwtSASQuery();
49
44
  const { 0: namespace } = useNamespace();
50
45
  const ky = useOkapiKy();
@@ -62,10 +57,7 @@ const SASQLookupComponent = ({
62
57
 
63
58
  const {
64
59
  data: totalData = {},
65
- error,
66
- isError,
67
- isLoading,
68
- fetchNextPage,
60
+ ...restOfInfiniteQueryProps
69
61
  } = useInfiniteQuery(
70
62
  [namespace, id, 'data', query],
71
63
  fetchPageData
@@ -93,20 +85,6 @@ const SASQLookupComponent = ({
93
85
  {}
94
86
  ) ?? {};
95
87
 
96
- // TODO focus handling to stop redraw movin to top
97
-
98
- const onNeedMoreData = (_askAmount, index) => {
99
- fetchNextPage({ pageParam: index });
100
- };
101
-
102
- // Build the map of column definitions
103
- const columnMapping = Object.fromEntries(
104
- resultColumns.map(e => [e.propertyPath, e.label])
105
- );
106
-
107
- // Build the list of visible columns
108
- const visibleColumns = resultColumns.map(e => e.propertyPath);
109
-
110
88
  return (
111
89
  <SearchAndSortQuery
112
90
  initialSearchState={{ query: '' }}
@@ -115,56 +93,23 @@ const SASQLookupComponent = ({
115
93
  {...sasqProps}
116
94
  >
117
95
  {
118
- ({
96
+ (sasqRenderProps) => {
97
+ const {
119
98
  activeFilters,
120
99
  filterChanged,
121
100
  getFilterHandlers,
122
101
  getSearchHandlers,
123
- onSort,
124
102
  onSubmitSearch,
125
103
  resetAll,
126
104
  searchChanged,
127
105
  searchValue
128
- }) => {
106
+ } = sasqRenderProps;
107
+
129
108
  const searchHandlers = getSearchHandlers();
130
- const sortOrder = query.sort ?? '';
131
109
  const disableReset = !filterChanged && !searchChanged;
132
110
 
133
111
  const filterCount = activeFilters.string ? activeFilters.string.split(',').length : 0;
134
112
 
135
- const TableBody = () => (
136
- <MultiColumnList
137
- autosize
138
- columnMapping={columnMapping}
139
- contentData={data?.results}
140
- isEmptyMessage={
141
- <NoResultsMessage
142
- {...{
143
- error,
144
- isError,
145
- isLoading,
146
- filterPaneIsVisible: filterPaneVisible,
147
- searchTerm: query.query,
148
- toggleFilterPane
149
- }}
150
- />
151
- }
152
- isSelected={({ item }) => item.id === match?.params?.id}
153
- onHeaderClick={onSort}
154
- onNeedMoreData={onNeedMoreData}
155
- onRowClick={(_e, rowData) => {
156
- history.push(`${path}/${rowData?.id}${location?.search}`);
157
- }}
158
- pagingType="click"
159
- sortDirection={sortOrder.startsWith('-') ? 'descending' : 'ascending'}
160
- sortOrder={sortOrder.replace(/^-/, '').replace(/,.*/, '')}
161
- totalCount={data.totalRecords}
162
- virtualize
163
- visibleColumns={visibleColumns}
164
- {...mclProps}
165
- />
166
- );
167
-
168
113
  const Body = RenderBody ?? TableBody;
169
114
 
170
115
  return (
@@ -184,6 +129,7 @@ const SASQLookupComponent = ({
184
129
  </PaneMenu>
185
130
  }
186
131
  paneTitle={<FormattedMessage id="stripes-smart-components.searchAndFilter" />}
132
+ {...filterPaneProps}
187
133
  >
188
134
  <form onSubmit={onSubmitSearch}>
189
135
  <FilterPaneHeaderComponent />
@@ -192,7 +138,13 @@ const SASQLookupComponent = ({
192
138
  <SearchField
193
139
  autoFocus
194
140
  name="query"
195
- onChange={searchHandlers.query}
141
+ onChange={e => {
142
+ if (e.target?.value) {
143
+ searchHandlers.query(e); // SASQ needs the whole event here
144
+ } else {
145
+ searchHandlers.reset();
146
+ }
147
+ }}
196
148
  onClear={searchHandlers.reset}
197
149
  value={searchValue.query}
198
150
  />
@@ -240,10 +192,19 @@ const SASQLookupComponent = ({
240
192
  </PaneMenu>
241
193
  :
242
194
  null}
195
+ noOverflow
196
+ padContent={false}
243
197
  paneSub={<FormattedMessage id="stripes-kint-components.sasqLookupComponent.mainPane.found" values={{ total: data?.total }} />}
244
198
  {...mainPaneProps}
245
199
  >
246
- <Body data={data} />
200
+ <Body
201
+ data={data}
202
+ query={query}
203
+ toggleFilterPane={toggleFilterPane}
204
+ {...restOfInfiniteQueryProps}
205
+ {...sasqProps}
206
+ {...props}
207
+ />
247
208
  </Pane>
248
209
  {children}
249
210
  </PersistedPaneset>
@@ -260,6 +221,7 @@ SASQLookupComponent.propTypes = {
260
221
  PropTypes.node
261
222
  ]),
262
223
  fetchParameters: PropTypes.object,
224
+ filterPaneProps: PropTypes.object,
263
225
  FilterComponent: PropTypes.oneOfType([
264
226
  PropTypes.func,
265
227
  PropTypes.node
@@ -0,0 +1,96 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ import { useHistory, useLocation } from 'react-router-dom';
4
+
5
+ import {
6
+ MultiColumnList,
7
+ } from '@folio/stripes/components';
8
+ import NoResultsMessage from '../../NoResultsMessage';
9
+
10
+ const TableBody = ({
11
+ data,
12
+ error,
13
+ fetchNextPage,
14
+ filterPaneVisible,
15
+ isError,
16
+ isLoading,
17
+ match,
18
+ mclProps,
19
+ onSort,
20
+ path,
21
+ resultColumns,
22
+ toggleFilterPane,
23
+ query,
24
+ }) => {
25
+ const sortOrder = query.sort ?? '';
26
+ const history = useHistory();
27
+ const location = useLocation();
28
+
29
+ const onNeedMoreData = (_askAmount, index) => {
30
+ fetchNextPage({ pageParam: index });
31
+ };
32
+
33
+ // Build the map of column definitions
34
+ const columnMapping = Object.fromEntries(
35
+ resultColumns.map(e => [e.propertyPath, e.label])
36
+ );
37
+
38
+ // Build the list of visible columns
39
+ const visibleColumns = resultColumns.map(e => e.propertyPath);
40
+
41
+ return (
42
+ <MultiColumnList
43
+ autosize
44
+ columnMapping={columnMapping}
45
+ contentData={data?.results}
46
+ hasMargin
47
+ isEmptyMessage={
48
+ <NoResultsMessage
49
+ {...{
50
+ error,
51
+ isError,
52
+ isLoading,
53
+ filterPaneIsVisible: filterPaneVisible,
54
+ searchTerm: query.query,
55
+ toggleFilterPane
56
+ }}
57
+ />
58
+ }
59
+ isSelected={({ item }) => item.id === match?.params?.id}
60
+ onHeaderClick={onSort}
61
+ onNeedMoreData={onNeedMoreData}
62
+ onRowClick={(_e, rowData) => {
63
+ history.push(`${path}/${rowData?.id}${location?.search}`);
64
+ }}
65
+ pagingType="click"
66
+ sortDirection={sortOrder.startsWith('-') ? 'descending' : 'ascending'}
67
+ sortOrder={sortOrder.replace(/^-/, '').replace(/,.*/, '')}
68
+ totalCount={data.totalRecords}
69
+ visibleColumns={visibleColumns}
70
+ {...mclProps}
71
+ />
72
+ );
73
+ };
74
+
75
+ TableBody.propTypes = {
76
+ data: PropTypes.shape({
77
+ totalRecords: PropTypes.number,
78
+ results: PropTypes.arrayOf(PropTypes.object)
79
+ }),
80
+ error: PropTypes.object,
81
+ fetchNextPage: PropTypes.func,
82
+ filterPaneVisible: PropTypes.bool,
83
+ history: PropTypes.object,
84
+ isError: PropTypes.bool,
85
+ isLoading: PropTypes.bool,
86
+ location: PropTypes.object,
87
+ match: PropTypes.object,
88
+ mclProps: PropTypes.object,
89
+ onSort: PropTypes.func,
90
+ path: PropTypes.string.isRequired,
91
+ query: PropTypes.object,
92
+ resultColumns: PropTypes.arrayOf(PropTypes.object),
93
+ toggleFilterPane: PropTypes.func
94
+ };
95
+
96
+ export default TableBody;
@@ -0,0 +1 @@
1
+ export { default } from './TableBody';
@@ -1 +1,2 @@
1
- export { default } from './SASQLookupComponent';
1
+ export { default as SASQLookupComponent } from './SASQLookupComponent';
2
+ export { default as TableBody } from './TableBody';
@@ -6,7 +6,7 @@ import {
6
6
  Switch
7
7
  } from 'react-router-dom';
8
8
 
9
- import SASQLookupComponent from '../SASQLookupComponent';
9
+ import { SASQLookupComponent } from '../SASQLookupComponent';
10
10
  import SASQViewComponent from '../SASQViewComponent';
11
11
 
12
12
  const SASQRoute = ({ children, path, fetchParameters, ...props }) => {
@@ -2,6 +2,7 @@ const generateKiwtQueryParams = (options, nsValues) => {
2
2
  const { qindex, query, filters, sort } = nsValues;
3
3
  const {
4
4
  searchKey = '',
5
+ filterConfig = [],
5
6
  /* Assumtion made that if no filterKey is provided then the given filterValues for that key are standalaone, ie require no comparator or key */
6
7
  filterKeys = {},
7
8
  sortKeys = {},
@@ -74,9 +75,17 @@ const generateKiwtQueryParams = (options, nsValues) => {
74
75
 
75
76
  // We now have a filterMap of shape { status: ['active', 'cancelled'], type: ['local'] }
76
77
  Object.entries(filterMap).forEach(([filterName, filterValues]) => {
78
+ const filterConfigEntry = filterConfig.find(conf => conf.name === filterName);
77
79
  const filterKey = filterKeys[filterName];
80
+ if (filterConfigEntry) {
81
+ // We have a direct mapping instruction, use it
82
+ const filterString = filterValues.map(v => {
83
+ const fceValue = filterConfigEntry?.values?.find(fce => fce.name === v)?.value;
84
+ return `${filterName}==${fceValue ?? v}`;
85
+ }).join('||');
78
86
 
79
- if (!filterKey) {
87
+ paramsArray.push(`filters=${filterString}`);
88
+ } else if (!filterKey) {
80
89
  // These filters have no key mapping so we just pass the values to the backend as-is.
81
90
  paramsArray.push(...filterValues?.map(f => `filters=${f}`));
82
91
  } else {
@@ -0,0 +1,42 @@
1
+ import matchString from './matchString';
2
+
3
+ const highlightString = (match, str, ignoreNull = true) => {
4
+ const [parts, regex] = matchString(match, str, ignoreNull);
5
+
6
+ return (
7
+ parts.filter(part => part).map((part, i) => (
8
+ regex.test(part) ?
9
+ <mark
10
+ key={i}
11
+ >
12
+ {part}
13
+ </mark> :
14
+ <span key={i}>
15
+ {part}
16
+ </span>
17
+ ))
18
+ );
19
+ };
20
+
21
+ const boldString = (match, str, ignoreNull = true) => {
22
+ const [parts, regex] = matchString(match, str, ignoreNull);
23
+
24
+ return (
25
+ parts.filter(part => part).map((part, i) => (
26
+ regex.test(part) ?
27
+ <strong
28
+ key={i}
29
+ >
30
+ {part}
31
+ </strong> :
32
+ <span key={i}>
33
+ {part}
34
+ </span>
35
+ ))
36
+ );
37
+ };
38
+
39
+ export {
40
+ boldString,
41
+ highlightString
42
+ };
@@ -15,3 +15,7 @@ export { default as groupCustomPropertiesByCtx } from './groupCustomPropertiesBy
15
15
  export { default as renderHelpText } from './renderHelpText';
16
16
  export { default as sortByLabel } from './sortByLabel';
17
17
  export { default as toCamelCase } from './toCamelCase'; // I hate that this exists
18
+
19
+
20
+ export { default as matchString } from './matchString';
21
+ export { boldString, highlightString } from './highlightString';
@@ -0,0 +1,14 @@
1
+ import escapeRegExp from 'lodash/escapeRegExp';
2
+
3
+ const matchString = (match, str, ignoreNull = true) => {
4
+ const regex = new RegExp(`${match.split(/(\s+)/).filter(h => h.trim()).map(hl => '(' + escapeRegExp(hl) + ')').join('|')}`, 'gi')
5
+ if (ignoreNull && !match) {
6
+ const nullRegex = /a^/gi; // Should match nothing
7
+
8
+ return [[str], nullRegex];
9
+ }
10
+
11
+ return [str.split(regex), regex];
12
+ };
13
+
14
+ export default matchString;