@k-int/stripes-kint-components 2.8.2 → 3.0.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.
Files changed (328) hide show
  1. package/CHANGELOG.md +15 -3
  2. package/es/index.js +48 -12
  3. package/es/lib/ActionList/ActionList.js +11 -5
  4. package/es/lib/ActionList/ActionListFieldArray.js +147 -77
  5. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +43 -31
  6. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.test.js +17 -14
  7. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +64 -46
  8. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.test.js +17 -24
  9. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +91 -70
  10. package/es/lib/CustomProperties/Config/CustomPropertyForm.test.js +53 -36
  11. package/es/lib/CustomProperties/Config/CustomPropertyView.js +50 -31
  12. package/es/lib/CustomProperties/Config/CustomPropertyView.test.js +13 -14
  13. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +6 -0
  14. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.test.js +8 -12
  15. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +22 -24
  16. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.test.js +9 -12
  17. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +62 -13
  18. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.test.js +12 -13
  19. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +91 -44
  20. package/es/lib/CustomProperties/Edit/CustomPropertyField.test.js +80 -73
  21. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +31 -32
  22. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +26 -24
  23. package/es/lib/CustomProperties/Edit/testResources.js +73 -908
  24. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +21 -29
  25. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.test.js +12 -10
  26. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +38 -39
  27. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +28 -13
  28. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +29 -44
  29. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.test.js +6 -6
  30. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +16 -10
  31. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.test.js +12 -12
  32. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +20 -11
  33. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.test.js +4 -3
  34. package/es/lib/CustomProperties/Filter/testResources.js +37 -233
  35. package/es/lib/CustomProperties/Filter/useOperators.js +69 -27
  36. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +3 -2
  37. package/es/lib/CustomProperties/Filter/useValueProps.js +7 -2
  38. package/es/lib/CustomProperties/View/CustomPropertiesView.js +6 -0
  39. package/es/lib/CustomProperties/View/CustomPropertiesView.test.js +4 -3
  40. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +13 -19
  41. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.test.js +4 -10
  42. package/es/lib/CustomProperties/View/CustomPropertyCard.js +34 -51
  43. package/es/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +35 -27
  44. package/es/lib/EditableRefdataList/EditableRefdataList.js +41 -31
  45. package/es/lib/EditableSettingsList/EditableSettingsList.js +11 -1
  46. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +10 -0
  47. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.js +19 -11
  48. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +9 -8
  49. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.js +21 -9
  50. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +1 -0
  51. package/es/lib/EditableSettingsList/SettingField/SettingField.js +83 -16
  52. package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +138 -65
  53. package/es/lib/FormModal/FormModal.js +14 -9
  54. package/es/lib/FormattedKintMessage/FormattedKintMessage.js +91 -0
  55. package/es/lib/FormattedKintMessage/index.js +15 -0
  56. package/es/lib/IconSelect/IconSelect.js +18 -12
  57. package/es/lib/NoResultsMessage/NoResultsMessage.js +13 -2
  58. package/es/lib/RichSelect/RichSelect.js +13 -34
  59. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +16 -5
  60. package/es/lib/SASQLookupComponent/TableBody/TableBody.js +11 -1
  61. package/es/lib/SettingPage/SettingPage.js +12 -13
  62. package/es/lib/SettingPage/SettingPagePane.js +12 -20
  63. package/es/lib/hooks/__mocks__/index.js +46 -0
  64. package/es/lib/hooks/index.js +24 -8
  65. package/es/lib/hooks/settingsHooks/useSettings.js +22 -17
  66. package/es/lib/hooks/useIntlKey.js +34 -0
  67. package/es/lib/hooks/useIntlKeyStore.js +84 -0
  68. package/es/lib/hooks/useKintIntl.js +93 -0
  69. package/es/lib/utils/index.js +40 -4
  70. package/es/lib/utils/parseErrorResponse.js +1 -1
  71. package/es/lib/utils/validators.js +76 -59
  72. package/jest.config.js +4 -1
  73. package/junit.xml +157 -656
  74. package/package.json +54 -33
  75. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +56 -8
  76. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +394 -64
  77. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +10 -10
  78. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +1 -1
  79. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesLookup.js.html +187 -52
  80. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesSettings.js.html +372 -87
  81. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +293 -74
  82. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyView.js.html +126 -54
  83. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +45 -60
  84. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +1 -1
  85. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEdit.js.html +23 -5
  86. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEditCtx.js.html +59 -47
  87. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesListField.js.html +259 -97
  88. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyField.js.html +399 -105
  89. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyFormCard.js.html +41 -68
  90. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/index.html +57 -57
  91. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/index.js.html +1 -1
  92. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/testResources.js.html +67 -688
  93. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilter.js.html +92 -53
  94. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterField.js.html +103 -64
  95. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js.html +54 -63
  96. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterForm.js.html +49 -16
  97. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesRule.js.html +69 -18
  98. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/index.html +89 -89
  99. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/index.js.html +1 -1
  100. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/testResources.js.html +33 -786
  101. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useOperators.js.html +46 -46
  102. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useParseActiveFilterStrings.js.html +45 -36
  103. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useValueProps.js.html +43 -28
  104. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesView.js.html +20 -2
  105. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesViewCtx.js.html +50 -41
  106. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertyCard.js.html +54 -75
  107. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/index.html +24 -24
  108. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/index.js.html +1 -1
  109. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/testResources.js.html +1 -1
  110. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/index.html +1 -1
  111. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/index.js.html +1 -1
  112. package/src/artifacts/coverage-jest/lcov-report/{hooks/useAvailableCustomProperties.js.html → CycleButton/CycleButton.js.html} +62 -50
  113. package/src/artifacts/coverage-jest/lcov-report/CycleButton/index.html +131 -0
  114. package/src/artifacts/coverage-jest/lcov-report/CycleButton/index.js.html +88 -0
  115. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataCategoryList/EditableRefdataCategoryList.js.html +664 -0
  116. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataCategoryList/index.html +131 -0
  117. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataCategoryList/index.js.html +88 -0
  118. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +264 -39
  119. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +9 -9
  120. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +1 -1
  121. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +41 -14
  122. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +45 -6
  123. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +47 -11
  124. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +65 -14
  125. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +154 -31
  126. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +26 -26
  127. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +1 -1
  128. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +18 -18
  129. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +1 -1
  130. package/src/artifacts/coverage-jest/lcov-report/FormModal/FormModal.js.html +35 -17
  131. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.html +15 -15
  132. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.js.html +1 -1
  133. package/src/artifacts/coverage-jest/lcov-report/FormattedKintMessage/FormattedKintMessage.js.html +247 -0
  134. package/src/artifacts/coverage-jest/lcov-report/FormattedKintMessage/index.html +131 -0
  135. package/src/artifacts/coverage-jest/lcov-report/FormattedKintMessage/index.js.html +88 -0
  136. package/src/artifacts/coverage-jest/lcov-report/{CustomProperties/Config/CustomPropertiesView.js.html → IconSelect/IconSelect.js.html} +158 -257
  137. package/src/artifacts/coverage-jest/lcov-report/IconSelect/index.html +131 -0
  138. package/src/artifacts/coverage-jest/lcov-report/IconSelect/index.js.html +88 -0
  139. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +48 -6
  140. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +7 -7
  141. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +1 -1
  142. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +1 -1
  143. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +1 -1
  144. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +1 -1
  145. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +3 -3
  146. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +1 -1
  147. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +1 -1
  148. package/src/artifacts/coverage-jest/lcov-report/{CustomProperties/Config/testResources.js.html → RichSelect/RichSelect.js.html} +256 -334
  149. package/src/artifacts/coverage-jest/lcov-report/RichSelect/index.html +146 -0
  150. package/src/artifacts/coverage-jest/lcov-report/RichSelect/index.js.html +91 -0
  151. package/src/artifacts/coverage-jest/lcov-report/RichSelect/useSelectedOption.js.html +127 -0
  152. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +52 -7
  153. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/TableBody.js.html +31 -4
  154. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/index.html +3 -3
  155. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/index.js.html +1 -1
  156. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +7 -7
  157. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +1 -1
  158. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +1 -1
  159. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +1 -1
  160. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +1 -1
  161. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +1 -1
  162. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +1 -1
  163. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +1 -1
  164. package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +1 -1
  165. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +1 -1
  166. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +1 -1
  167. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +24 -27
  168. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +47 -17
  169. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +22 -22
  170. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +1 -1
  171. package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +1 -1
  172. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +1 -1
  173. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +1 -1
  174. package/src/artifacts/coverage-jest/lcov-report/constants/customProperties.js.html +1 -1
  175. package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +1 -1
  176. package/src/artifacts/coverage-jest/lcov-report/constants/index.html +1 -1
  177. package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +2 -2
  178. package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +1 -1
  179. package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +1 -1
  180. package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
  181. package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +142 -97
  182. package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +13 -4
  183. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +35 -20
  184. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +5 -2
  185. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useAppSettings.js.html +7 -7
  186. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +7 -7
  187. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +61 -22
  188. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +1 -1
  189. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +1 -1
  190. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +1 -1
  191. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +1 -1
  192. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +1 -1
  193. package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +7 -7
  194. package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +19 -22
  195. package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +7 -7
  196. package/src/artifacts/coverage-jest/lcov-report/hooks/useIntlKey.js.html +151 -0
  197. package/src/artifacts/coverage-jest/lcov-report/{utils/renderHelpText.js.html → hooks/useIntlKeyStore.js.html} +71 -38
  198. package/src/artifacts/coverage-jest/lcov-report/hooks/useInvalidateRefdata.js.html +7 -7
  199. package/src/artifacts/coverage-jest/lcov-report/hooks/useKintIntl.js.html +238 -0
  200. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +7 -7
  201. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +9 -9
  202. package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +7 -7
  203. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateCustomProperties.js.html +23 -11
  204. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataCategory.js.html +274 -0
  205. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +19 -10
  206. package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +7 -7
  207. package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +9 -9
  208. package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +7 -7
  209. package/src/artifacts/coverage-jest/lcov-report/index.html +205 -130
  210. package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
  211. package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +1 -1
  212. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +2 -2
  213. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +2 -2
  214. package/src/artifacts/coverage-jest/lcov-report/utils/groupCustomPropertiesByCtx.js.html +7 -7
  215. package/src/artifacts/coverage-jest/lcov-report/utils/highlightString.js.html +3 -3
  216. package/src/artifacts/coverage-jest/lcov-report/utils/index.html +34 -34
  217. package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +42 -3
  218. package/src/artifacts/coverage-jest/lcov-report/utils/matchString.js.html +2 -2
  219. package/src/artifacts/coverage-jest/lcov-report/utils/parseErrorResponse.js.html +139 -0
  220. package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +5 -2
  221. package/src/artifacts/coverage-jest/lcov-report/utils/refdataQueryKey.js.html +2 -2
  222. package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +2 -2
  223. package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +2 -2
  224. package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +2 -2
  225. package/src/artifacts/coverage-jest/lcov-report/utils/typedownQueryKey.js.html +2 -2
  226. package/src/artifacts/coverage-jest/lcov-report/utils/validators.js.html +128 -80
  227. package/src/artifacts/coverage-jest/lcov.info +2603 -2086
  228. package/src/index.js +11 -4
  229. package/src/lib/ActionList/ActionList.js +9 -3
  230. package/src/lib/ActionList/ActionListFieldArray.js +115 -37
  231. package/src/lib/ActionList/README.md +2 -1
  232. package/src/lib/CustomProperties/Config/CustomPropertiesLookup.js +60 -16
  233. package/src/lib/CustomProperties/Config/CustomPropertiesLookup.test.js +14 -4
  234. package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +106 -33
  235. package/src/lib/CustomProperties/Config/CustomPropertiesSettings.test.js +16 -9
  236. package/src/lib/CustomProperties/Config/CustomPropertyForm.js +131 -58
  237. package/src/lib/CustomProperties/Config/CustomPropertyForm.test.js +52 -33
  238. package/src/lib/CustomProperties/Config/CustomPropertyView.js +71 -47
  239. package/src/lib/CustomProperties/Config/CustomPropertyView.test.js +8 -6
  240. package/src/lib/CustomProperties/Config/README.md +33 -28
  241. package/src/lib/CustomProperties/Edit/CustomPropertiesEdit.js +6 -0
  242. package/src/lib/CustomProperties/Edit/CustomPropertiesEdit.test.js +7 -3
  243. package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +23 -19
  244. package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.test.js +5 -3
  245. package/src/lib/CustomProperties/Edit/CustomPropertiesListField.js +65 -11
  246. package/src/lib/CustomProperties/Edit/CustomPropertiesListField.test.js +10 -8
  247. package/src/lib/CustomProperties/Edit/CustomPropertyField.js +115 -21
  248. package/src/lib/CustomProperties/Edit/CustomPropertyField.test.js +59 -60
  249. package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.js +24 -33
  250. package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +20 -27
  251. package/src/lib/CustomProperties/Edit/testResources.js +46 -1047
  252. package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.js +22 -22
  253. package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.test.js +12 -8
  254. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +44 -31
  255. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +26 -13
  256. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +33 -36
  257. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.test.js +3 -3
  258. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +19 -8
  259. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.test.js +9 -12
  260. package/src/lib/CustomProperties/Filter/CustomPropertiesRule.js +22 -5
  261. package/src/lib/CustomProperties/Filter/CustomPropertiesRule.test.js +3 -1
  262. package/src/lib/CustomProperties/Filter/testResources.js +14 -265
  263. package/src/lib/CustomProperties/Filter/useOperators.js +20 -20
  264. package/src/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +2 -2
  265. package/src/lib/CustomProperties/Filter/useValueProps.js +8 -3
  266. package/src/lib/CustomProperties/View/CustomPropertiesView.js +6 -0
  267. package/src/lib/CustomProperties/View/CustomPropertiesView.test.js +2 -1
  268. package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +15 -13
  269. package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.test.js +2 -5
  270. package/src/lib/CustomProperties/View/CustomPropertyCard.js +36 -43
  271. package/src/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +45 -27
  272. package/src/lib/EditableRefdataList/EditableRefdataList.js +56 -32
  273. package/src/lib/EditableSettingsList/EditableSettingsList.js +10 -1
  274. package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.js +14 -1
  275. package/src/lib/EditableSettingsList/SettingField/EditSettingValue.js +17 -5
  276. package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +9 -8
  277. package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.js +24 -7
  278. package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +1 -0
  279. package/src/lib/EditableSettingsList/SettingField/SettingField.js +57 -16
  280. package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +14 -19
  281. package/src/lib/FormModal/FormModal.js +15 -9
  282. package/src/lib/FormattedKintMessage/FormattedKintMessage.js +54 -0
  283. package/src/lib/FormattedKintMessage/index.js +1 -0
  284. package/src/lib/IconSelect/IconSelect.js +17 -8
  285. package/src/lib/NoResultsMessage/NoResultsMessage.js +15 -1
  286. package/src/lib/RichSelect/RichSelect.js +16 -36
  287. package/src/lib/SASQLookupComponent/SASQLookupComponent.js +17 -2
  288. package/src/lib/SASQLookupComponent/TableBody/TableBody.js +10 -1
  289. package/src/lib/SettingPage/SettingPage.js +12 -13
  290. package/src/lib/SettingPage/SettingPagePane.js +16 -6
  291. package/src/lib/hooks/__mocks__/index.js +17 -0
  292. package/src/lib/hooks/index.js +3 -1
  293. package/src/lib/hooks/settingsHooks/useSettings.js +25 -12
  294. package/src/lib/hooks/useIntlKey.js +22 -0
  295. package/src/lib/hooks/useIntlKeyStore.js +38 -0
  296. package/src/lib/hooks/useKintIntl.js +51 -0
  297. package/src/lib/utils/index.js +11 -1
  298. package/src/lib/utils/parseErrorResponse.js +1 -1
  299. package/src/lib/utils/validators.js +57 -41
  300. package/styles/RichSelect.css +7 -4
  301. package/test/helpers/test-implementor-translations.json +80 -0
  302. package/test/helpers/translationsProperties.js +6 -1
  303. package/test/jest/customProperties.js +166 -0
  304. package/test/jest/helpers/KintHarness.js +1 -1
  305. package/test/jest/helpers/renderWithKintHarness.js +2 -1
  306. package/test/jest/index.js +8 -0
  307. package/test/jest/refdata.js +471 -0
  308. package/test/jest/resolver.js +29 -0
  309. package/translations/stripes-kint-components/ar.json +1 -122
  310. package/translations/stripes-kint-components/cs_CZ.json +1 -122
  311. package/translations/stripes-kint-components/de.json +1 -122
  312. package/translations/stripes-kint-components/en.json +1 -148
  313. package/translations/stripes-kint-components/es.json +1 -122
  314. package/translations/stripes-kint-components/hi_IN.json +1 -122
  315. package/translations/stripes-kint-components/hu.json +1 -122
  316. package/translations/stripes-kint-components/it_IT.json +1 -122
  317. package/translations/stripes-kint-components/ja.json +1 -122
  318. package/translations/stripes-kint-components/ko.json +1 -122
  319. package/translations/stripes-kint-components/pt_PT.json +1 -122
  320. package/translations/stripes-kint-components/ru.json +1 -122
  321. package/translations/stripes-kint-components/sv.json +1 -122
  322. package/translations/stripes-kint-components/zh_CN.json +1 -122
  323. package/es/lib/CustomProperties/Config/testResources.js +0 -198
  324. package/es/lib/hooks/useAvailableCustomProperties.js +0 -73
  325. package/es/lib/utils/renderHelpText.js +0 -80
  326. package/src/lib/CustomProperties/Config/testResources.js +0 -236
  327. package/src/lib/hooks/useAvailableCustomProperties.js +0 -40
  328. package/src/lib/utils/renderHelpText.js +0 -27
@@ -4,12 +4,12 @@ import { Button, KeyValue } from '@folio/stripes-testing';
4
4
  import { TestForm } from '@folio/stripes-erm-components/test/jest/helpers';
5
5
  import { waitFor } from '@testing-library/react';
6
6
 
7
- import { data, initialValues } from './testResources';
7
+ import { initialValues } from './testResources';
8
8
  import CustomPropertiesListField from './CustomPropertiesListField';
9
- import { renderWithKintHarness } from '../../../../test/jest/helpers';
9
+ import { customProperties, renderWithKintHarness } from '../../../../test/jest';
10
10
 
11
11
  const onSubmit = jest.fn();
12
-
12
+ jest.mock('../../hooks');
13
13
  jest.mock('./CustomPropertyFormCard', () => () => <div>CustomPropertyFormCard</div>);
14
14
 
15
15
  describe('CustomPropertiesListField', () => {
@@ -21,18 +21,20 @@ describe('CustomPropertiesListField', () => {
21
21
  onSubmit={onSubmit}
22
22
  >
23
23
  <CustomPropertiesListField
24
- {...data}
24
+ ctx="isNull"
25
+ customProperties={customProperties}
26
+ name="customProperties"
25
27
  />
26
28
  </TestForm>
27
29
  );
28
30
  });
29
31
 
30
- test('displays expected Primary terms key value', async () => {
31
- await KeyValue('Primary terms').exists();
32
+ test('displays expected primary properties key value', async () => {
33
+ await KeyValue('Primary properties').exists();
32
34
  });
33
35
 
34
- test('displays expected Optional terms key value', async () => {
35
- await KeyValue('Optional terms').exists();
36
+ test('displays expected optional properties key value', async () => {
37
+ await KeyValue('Optional properties').exists();
36
38
  });
37
39
 
38
40
  it('renders CustomPropertyFormCard component ', () => {
@@ -1,7 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
2
 
3
- import { FormattedMessage, useIntl } from 'react-intl';
4
-
5
3
  import { Field } from 'react-final-form';
6
4
 
7
5
  import {
@@ -16,7 +14,14 @@ import {
16
14
 
17
15
  import * as CUSTOM_PROPERTY_TYPES from '../../constants/customProperties';
18
16
 
19
- import { customPropertyValidator } from '../../utils/validators';
17
+ import { useKintIntl } from '../../hooks';
18
+
19
+ import {
20
+ composeValidatorsWithArgs,
21
+ invalidNumber,
22
+ rangeOverflow,
23
+ rangeUnderflow
24
+ } from '../../utils';
20
25
 
21
26
  const CustomPropertyField = ({
22
27
  availableCustomProperties,
@@ -24,13 +29,67 @@ const CustomPropertyField = ({
24
29
  customPropertyType,
25
30
  customProperties,
26
31
  index,
32
+ intlKey: passedIntlKey,
33
+ intlNS: passedIntlNS,
27
34
  labelOverrides = {},
28
35
  name,
29
36
  onChange,
30
37
  value,
31
38
  setCustomProperties
32
39
  }) => {
33
- const intl = useIntl();
40
+ const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
41
+
42
+ // Set up the validator for the customProperty
43
+ const customPropertyValidator = (fieldValue, allValues) => {
44
+ const { note, publicNote, value: currentValue } = allValues?.customProperties?.[customProperty?.value]?.[0] ?? {};
45
+
46
+ if ((note && !currentValue) || (publicNote && !currentValue)) {
47
+ if (
48
+ customProperty.type === CUSTOM_PROPERTY_TYPES.DECIMAL_CLASS_NAME ||
49
+ customProperty.type === CUSTOM_PROPERTY_TYPES.INTEGER_CLASS_NAME
50
+ ) {
51
+ return (
52
+ kintIntl.formatKintMessage({
53
+ id: 'customProperties.errors.customPropertyNoteInvalidNumber',
54
+ overrideValue: labelOverrides.customPropertyNoteInvalidNumberError
55
+ })
56
+ );
57
+ } else {
58
+ return (
59
+ kintIntl.formatKintMessage({
60
+ id: 'customProperties.errors.customPropertyNoteWithoutValue',
61
+ overrideValue: labelOverrides.customPropertyNoteWithoutValueError
62
+ })
63
+ );
64
+ }
65
+ }
66
+
67
+ if (customProperty.type === CUSTOM_PROPERTY_TYPES.DECIMAL_CLASS_NAME) {
68
+ const regexp = /^-?[\d]*(\.[\d]{0,2})?$/;
69
+ return (fieldValue && !regexp.test(fieldValue)) ?
70
+ kintIntl.formatKintMessage({
71
+ id: 'errors.maxTwoDecimals',
72
+ overrideValue: labelOverrides.maxTwoDecimalsError
73
+ }) : undefined;
74
+ }
75
+
76
+ if (customProperty.type === CUSTOM_PROPERTY_TYPES.INTEGER_CLASS_NAME) {
77
+ const min = Number.MIN_SAFE_INTEGER;
78
+ const max = Number.MAX_SAFE_INTEGER;
79
+
80
+ return (fieldValue && !Number.isInteger(+fieldValue)) ?
81
+ kintIntl.formatKintMessage({
82
+ id: 'errors.valueNotInRange',
83
+ overrideValue: labelOverrides.valueNotInRangeError
84
+ }, { min, max }) : undefined;
85
+ }
86
+
87
+ if (!customProperty.primary && !currentValue) {
88
+ return kintIntl.formatMessage({ id: 'stripes-core.label.missingRequiredField' });
89
+ }
90
+
91
+ return undefined;
92
+ };
34
93
 
35
94
  const getCustomProperty = (customPropertyValue) => {
36
95
  return availableCustomProperties.find(cp => cp.value === customPropertyValue);
@@ -60,8 +119,10 @@ const CustomPropertyField = ({
60
119
  dataOptions={[customProperty, ...unsetCustomProperties]} // The selected customProperty, and the available unset customProperties
61
120
  id={`edit-customproperty-${index}-name`}
62
121
  label={
63
- labelOverrides.name ??
64
- <FormattedMessage id="stripes-kint-components.customProperty.name" />
122
+ kintIntl.formatKintMessage({
123
+ id: 'customProperties.name',
124
+ overrideValue: labelOverrides.name
125
+ })
65
126
  }
66
127
  onChange={e => {
67
128
  const newValue = e.target.value;
@@ -140,14 +201,25 @@ const CustomPropertyField = ({
140
201
  case CUSTOM_PROPERTY_TYPES.INTEGER_CLASS_NAME:
141
202
  case CUSTOM_PROPERTY_TYPES.DECIMAL_CLASS_NAME:
142
203
  fieldProps = {
143
- badInput: intl.formatMessage({ id: 'stripes-kint-components.errors.customPropertyInvalidNumber' }),
144
204
  component: TextField,
145
205
  max,
146
206
  min,
147
- rangeOverflow: intl.formatMessage({ id: 'stripes-kint-components.errors.customPropertyDecimalValueNotInRange' }, { min, max }),
148
- rangeUnderflow: intl.formatMessage({ id: 'stripes-kint-components.errors.customPropertyDecimalValueNotInRange' }, { min, max }),
149
207
  step: 'any',
150
208
  type: 'number',
209
+ validate: (validateValue) => {
210
+ return composeValidatorsWithArgs(
211
+ invalidNumber,
212
+ rangeOverflow,
213
+ rangeUnderflow
214
+ )(
215
+ validateValue,
216
+ min,
217
+ max,
218
+ passedIntlKey,
219
+ passedIntlNS,
220
+ labelOverrides
221
+ );
222
+ }
151
223
  };
152
224
  handleChange = e => {
153
225
  onChange({
@@ -184,14 +256,15 @@ const CustomPropertyField = ({
184
256
  data-test-customproperty-value
185
257
  id={`edit-customproperty-${index}-value`}
186
258
  label={
187
- labelOverrides.value ??
188
- <FormattedMessage id="stripes-kint-components.customProperty.value" />
259
+ kintIntl.formatKintMessage({
260
+ id: 'customProperties.value',
261
+ overrideValue: labelOverrides.value
262
+ })
189
263
  }
190
264
  name={`${name}.${customProperty.value}[0].value`}
191
265
  onChange={handleChange}
192
266
  required={!customProperty.primary}
193
- validate={(fieldValue, allValues) => customPropertyValidator(fieldValue, allValues, customProperty)}
194
- valueMissing={intl.formatMessage({ id: 'stripes-core.label.missingRequiredField' })}
267
+ validate={(fieldValue, allValues) => customPropertyValidator(fieldValue, allValues)}
195
268
  {...fieldProps}
196
269
  />
197
270
  );
@@ -214,13 +287,27 @@ const CustomPropertyField = ({
214
287
  <Select
215
288
  data-test-customproperty-visibility
216
289
  dataOptions={[
217
- { value: true, label: intl.formatMessage({ id: 'stripes-kint-components.customProperty.internalTrue' }) },
218
- { value: false, label: intl.formatMessage({ id: 'stripes-kint-components.customProperty.internalFalse' }) }
290
+ {
291
+ value: true,
292
+ label: kintIntl.formatKintMessage({
293
+ id: 'customProperties.internalTrue',
294
+ overrideValue: labelOverrides.internalTrue
295
+ })
296
+ },
297
+ {
298
+ value: false,
299
+ label: kintIntl.formatKintMessage({
300
+ id: 'customProperties.internalFalse',
301
+ overrideValue: labelOverrides.internalFalse
302
+ })
303
+ }
219
304
  ]}
220
305
  id={`edit-customproperty-${index}-visibility`}
221
306
  label={
222
- labelOverrides.visibility ??
223
- <FormattedMessage id="stripes-kint-components.customProperty.visibility" />
307
+ kintIntl.formatKintMessage({
308
+ id: 'customProperties.visibility',
309
+ overrideValue: labelOverrides.visibility
310
+ })
224
311
  }
225
312
  onChange={handleChange}
226
313
  value={customPropertyObject?.internal ?? customProperty.defaultInternal}
@@ -246,8 +333,11 @@ const CustomPropertyField = ({
246
333
  data-test-customproperty-note
247
334
  id={`edit-customproperty-${index}-internal-note`}
248
335
  label={
249
- labelOverrides.internalNote ??
250
- <FormattedMessage id="stripes-kint-components.customProperty.internalNote" />}
336
+ kintIntl.formatKintMessage({
337
+ id: 'customProperties.internalNote',
338
+ overrideValue: labelOverrides.internalNote
339
+ })
340
+ }
251
341
  onChange={handleChange}
252
342
  value={customPropertyObject?.note}
253
343
  />
@@ -272,8 +362,10 @@ const CustomPropertyField = ({
272
362
  data-test-customproperty-public-note
273
363
  id={`edit-customproperty-${index}-public-note`}
274
364
  label={
275
- labelOverrides.publicNote ??
276
- <FormattedMessage id="stripes-kint-components.customProperty.publicNote" />
365
+ kintIntl.formatKintMessage({
366
+ id: 'customProperties.publicNote',
367
+ overrideValue: labelOverrides.publicNote
368
+ })
277
369
  }
278
370
  onChange={handleChange}
279
371
  value={customPropertyObject?.publicNote}
@@ -321,6 +413,8 @@ CustomPropertyField.propTypes = {
321
413
  customPropertyType: PropTypes.string,
322
414
  customProperties: PropTypes.arrayOf(PropTypes.object),
323
415
  index: PropTypes.number,
416
+ intlKey: PropTypes.string,
417
+ intlNS: PropTypes.string,
324
418
  labelOverrides: PropTypes.object,
325
419
  name: PropTypes.string,
326
420
  onChange: PropTypes.func,
@@ -1,27 +1,37 @@
1
1
  import React from 'react';
2
2
  import '@folio/stripes-erm-components/test/jest/__mock__';
3
3
  import { TextArea, MultiSelect, TextInput, Datepicker } from '@folio/stripes-testing';
4
+
4
5
  import { TestForm } from '@folio/stripes-erm-components/test/jest/helpers';
5
6
  import CustomPropertyField from './CustomPropertyField';
6
- import {
7
- availableCustomProperties,
8
- customProperties,
9
- customProperty,
10
- labelOverrides,
11
- value,
12
- initialValues,
13
- dateData,
14
- integerData,
15
- decimalData,
16
- multiSelectData,
17
- } from './testResources';
18
- import { renderWithKintHarness } from '../../../../test/jest/helpers';
7
+
8
+ import { availableCustomProperties, customProperties, renderWithKintHarness } from '../../../../test/jest';
9
+
10
+ import { value, initialValues } from './testResources';
19
11
 
20
12
  const onSubmit = jest.fn();
13
+ jest.mock('../../hooks');
21
14
 
22
15
  const onChange = () => {};
23
16
  const setCustomProperties = () => {};
24
17
 
18
+ const authIdentCustom = availableCustomProperties?.find(cp => cp.value === 'AuthorIdentification');
19
+ const decimalCustProp = availableCustomProperties?.find(cp => cp.value === 'decimal');
20
+ const integerCustProp = availableCustomProperties?.find(cp => cp.value === 'integer');
21
+ const dateCustProp = availableCustomProperties?.find(cp => cp.value === 'date');
22
+ const multiRefdataCustProp = availableCustomProperties?.find(cp => cp.value === 'MultiRefdata');
23
+
24
+ const defaultProps = {
25
+ availableCustomProperties,
26
+ customProperties,
27
+ customPropertyType: 'primary',
28
+ internalPropertyCounter: 1,
29
+ name: 'customProperties',
30
+ onChange,
31
+ setCustomProperties,
32
+ value
33
+ };
34
+
25
35
  describe('CustomPropertyField', () => {
26
36
  let renderComponent;
27
37
  describe('CustomPropertyField', () => {
@@ -32,17 +42,9 @@ describe('CustomPropertyField', () => {
32
42
  onSubmit={onSubmit}
33
43
  >
34
44
  <CustomPropertyField
35
- availableCustomProperties={availableCustomProperties}
36
- customProperties={customProperties}
37
- customProperty={customProperty}
38
- customPropertyType="primary"
45
+ {...defaultProps}
46
+ customProperty={authIdentCustom}
39
47
  index={0}
40
- internalPropertyCounter={1}
41
- labelOverrides={labelOverrides}
42
- name="customProperties"
43
- onChange={onChange}
44
- setCustomProperties={setCustomProperties}
45
- value={value}
46
48
  />
47
49
  </TestForm>
48
50
  );
@@ -50,35 +52,36 @@ describe('CustomPropertyField', () => {
50
52
  expect(getByTestId('customPropertyField')).toBeInTheDocument();
51
53
  });
52
54
 
53
- it('Displays expected value(s) lable ', () => {
55
+
56
+ it('Displays expected value(s) label ', () => {
54
57
  const { getByText } = renderComponent;
55
58
  expect(getByText('Value(s)')).toBeInTheDocument();
56
59
  });
57
60
 
58
- test('Displays expected Valu(s) dropdwon values ', () => {
61
+ test('Displays expected Value(s) dropdown values ', () => {
59
62
  MultiSelect('Value(s)').select(['Not set', 'ORCID', 'Ringgold ID', 'Email Domain', 'Over IP Range', 'FOR ID', 'Other', 'Over Institute']);
60
63
  });
61
64
 
62
- it('Displays expected Internal note lable ', () => {
65
+ it('Displays expected Internal note label ', () => {
63
66
  const { getByText } = renderComponent;
64
67
  expect(getByText('Internal note')).toBeInTheDocument();
65
68
  });
66
69
 
67
70
  test('Displays expected internal note value', async () => {
68
- await TextArea({ id: 'edit-customproperty-0-internal-note' }).has({ value: 'internal note' });
71
+ await TextArea('Internal note').has({ value: 'this is an internal note' });
69
72
  });
70
73
 
71
74
  test('Displays expected visibilities dropdwon values ', () => {
72
75
  MultiSelect('Visibility').select(['Internal', 'Public']);
73
76
  });
74
77
 
75
- it('Displays expected Public note lable ', () => {
78
+ it('Displays expected Public note label ', () => {
76
79
  const { getByText } = renderComponent;
77
80
  expect(getByText('Public note')).toBeInTheDocument();
78
81
  });
79
82
 
80
83
  test('Displays expected public note value', async () => {
81
- await TextArea({ id: 'edit-customproperty-0-public-note' }).has({ value: 'public note' });
84
+ await TextArea('Public note').has({ value: 'this is a public note' });
82
85
  });
83
86
  });
84
87
 
@@ -90,10 +93,9 @@ describe('CustomPropertyField', () => {
90
93
  onSubmit={onSubmit}
91
94
  >
92
95
  <CustomPropertyField
93
- {...decimalData}
94
- availableCustomProperties={availableCustomProperties}
95
- onChange={onChange}
96
- setCustomProperties={setCustomProperties}
96
+ {...defaultProps}
97
+ customProperty={decimalCustProp}
98
+ index={2}
97
99
  />
98
100
  </TestForm>
99
101
  );
@@ -112,10 +114,9 @@ describe('CustomPropertyField', () => {
112
114
  onSubmit={onSubmit}
113
115
  >
114
116
  <CustomPropertyField
115
- {...integerData}
116
- availableCustomProperties={availableCustomProperties}
117
- onChange={onChange}
118
- setCustomProperties={setCustomProperties}
117
+ {...defaultProps}
118
+ customProperty={integerCustProp}
119
+ index={3}
119
120
  />
120
121
  </TestForm>
121
122
  );
@@ -126,7 +127,7 @@ describe('CustomPropertyField', () => {
126
127
  });
127
128
  });
128
129
 
129
- describe('Date field', () => {
130
+ describe('Refdata multi-select field', () => {
130
131
  beforeEach(() => {
131
132
  renderComponent = renderWithKintHarness(
132
133
  <TestForm
@@ -134,25 +135,29 @@ describe('CustomPropertyField', () => {
134
135
  onSubmit={onSubmit}
135
136
  >
136
137
  <CustomPropertyField
137
- {...dateData}
138
- availableCustomProperties={availableCustomProperties}
139
- onChange={onChange}
140
- setCustomProperties={setCustomProperties}
138
+ {...defaultProps}
139
+ customProperty={multiRefdataCustProp}
140
+ index={4}
141
141
  />
142
142
  </TestForm>
143
143
  );
144
144
  });
145
145
 
146
- test('renders values DatePicker', async () => {
147
- await Datepicker('Value(s)').exists();
146
+ test('Displays expected multi-select Refdata Field', async () => {
147
+ await MultiSelect('Value(s)').exists();
148
148
  });
149
149
 
150
- test('Displays expected date Field', async () => {
151
- await TextInput({ id: 'edit-customproperty-5-value' }).exists();
150
+ it('Displays expected value(s) label ', () => {
151
+ const { getByText } = renderComponent;
152
+ expect(getByText('Value(s)')).toBeInTheDocument();
153
+ });
154
+
155
+ test('renders multi-select Refdata values', async () => {
156
+ await MultiSelect('Value(s)').select(['Future', 'Current', 'Historical', 'Does not apply']);
152
157
  });
153
158
  });
154
159
 
155
- describe('Refdata multi-select field', () => {
160
+ describe('Date field', () => {
156
161
  beforeEach(() => {
157
162
  renderComponent = renderWithKintHarness(
158
163
  <TestForm
@@ -160,26 +165,20 @@ describe('CustomPropertyField', () => {
160
165
  onSubmit={onSubmit}
161
166
  >
162
167
  <CustomPropertyField
163
- {...multiSelectData}
164
- availableCustomProperties={availableCustomProperties}
165
- onChange={onChange}
166
- setCustomProperties={setCustomProperties}
168
+ {...defaultProps}
169
+ customProperty={dateCustProp}
170
+ index={5}
167
171
  />
168
172
  </TestForm>
169
173
  );
170
174
  });
171
175
 
172
- test('Displays expected multi-select Refdata Field', async () => {
173
- await TextInput({ id: 'edit-customproperty-4-value-input' }).exists();
174
- });
175
-
176
- it('Displays expected value(s) lable ', () => {
177
- const { getByText } = renderComponent;
178
- expect(getByText('Value(s)')).toBeInTheDocument();
176
+ test('renders values DatePicker', async () => {
177
+ await Datepicker('Value(s)').exists();
179
178
  });
180
179
 
181
- test('renders multi-select Refdata values', async () => {
182
- await MultiSelect('Value(s)').select(['Ceased', 'Superseded', 'Rejected', 'Cancelled']);
180
+ test('Displays expected date Field', async () => {
181
+ await TextInput({ id: 'edit-customproperty-5-value' }).exists();
183
182
  });
184
183
  });
185
184
  });
@@ -1,7 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
2
 
3
- import { FormattedMessage } from 'react-intl';
4
-
5
3
  import {
6
4
  Card,
7
5
  IconButton,
@@ -10,6 +8,7 @@ import {
10
8
  } from '@folio/stripes/components';
11
9
 
12
10
  import CustomPropertyField from './CustomPropertyField';
11
+ import { useKintIntl } from '../../hooks';
13
12
 
14
13
  const CustomPropertyFormCard = ({
15
14
  availableCustomProperties,
@@ -19,49 +18,37 @@ const CustomPropertyFormCard = ({
19
18
  handleDeleteCustomProperty,
20
19
  index,
21
20
  internalPropertyCounter,
21
+ intlKey: passedIntlKey,
22
+ intlNS: passedIntlNS,
22
23
  labelOverrides = {},
23
24
  name,
24
25
  onChange,
25
26
  setCustomProperties,
26
27
  value
27
28
  }) => {
29
+ const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
30
+
28
31
  const getHeader = () => {
29
32
  if (customPropertyType === 'optional') {
30
- if (labelOverrides.optionalPropertyHeader && typeof labelOverrides.optionalPropertyHeader === 'function') {
31
- return labelOverrides.optionalPropertyHeader(internalPropertyCounter);
32
- }
33
-
34
- // Label override for optionalPropertyHeader or finally built in default
35
- return (
36
- labelOverrides.optionalPropertyHeader ??
37
- <FormattedMessage
38
- id="stripes-kint-components.customProperty.optionalPropertyHeader"
39
- values={{ number: internalPropertyCounter }}
40
- />
41
- );
33
+ return kintIntl.formatKintMessage({
34
+ id: 'customProperty.optionalPropertyHeader',
35
+ overrideValue: labelOverrides.optionalPropertyHeader,
36
+ }, { number: internalPropertyCounter, name: customProperty.value });
42
37
  }
43
38
 
44
- // Label override for primaryPropertyHeader or finally built in default
45
- return (
46
- labelOverrides.primaryPropertyHeader ??
47
- customProperty.label
48
- );
39
+ return kintIntl.formatKintMessage({
40
+ id: 'customProperty.primaryPropertyHeader',
41
+ overrideValue: labelOverrides.primaryPropertyHeader,
42
+ fallbackMessage: customProperty.label
43
+ }, { number: internalPropertyCounter, name: customProperty.value });
49
44
  };
50
45
 
51
- const getTooltipText = () => {
52
- if (labelOverrides.remove && typeof labelOverrides.remove === 'function') {
53
- return labelOverrides.remove(internalPropertyCounter);
54
- }
55
-
56
- // Label override for optionalPropertyHeader or finally built in default
57
- return (
58
- labelOverrides.remove ??
59
- <FormattedMessage
60
- id="stripes-kint-components.customProperty.remove"
61
- values={{ number: internalPropertyCounter }}
62
- />
63
- );
64
- };
46
+ const getTooltipText = () => (
47
+ kintIntl.formatKintMessage({
48
+ id: 'customProperty.remove',
49
+ overrideValue: labelOverrides.remove
50
+ }, { number: internalPropertyCounter, name: customProperty.value })
51
+ );
65
52
 
66
53
  return (
67
54
  <Card
@@ -103,6 +90,8 @@ const CustomPropertyFormCard = ({
103
90
  customProperties,
104
91
  index,
105
92
  internalPropertyCounter,
93
+ intlKey: passedIntlKey,
94
+ intlNS: passedIntlNS,
106
95
  labelOverrides,
107
96
  name,
108
97
  onChange,
@@ -122,6 +111,8 @@ CustomPropertyFormCard.propTypes = {
122
111
  handleDeleteCustomProperty: PropTypes.func,
123
112
  index: PropTypes.number,
124
113
  internalPropertyCounter: PropTypes.number,
114
+ intlKey: PropTypes.string,
115
+ intlNS: PropTypes.string,
125
116
  labelOverrides: PropTypes.object,
126
117
  name: PropTypes.string,
127
118
  onChange: PropTypes.func,
@@ -1,42 +1,35 @@
1
1
  import React from 'react';
2
2
  import '@folio/stripes-erm-components/test/jest/__mock__';
3
- import { StaticRouter as Router } from 'react-router-dom';
4
3
 
5
- import { renderWithKintHarness } from '../../../../test/jest/helpers';
6
-
7
- import {
8
- availableCustomProperties,
9
- customProperties,
10
- customProperty,
11
- labelOverrides,
12
- cardFormValue
13
- } from './testResources';
14
4
  import CustomPropertyFormCard from './CustomPropertyFormCard';
15
5
 
6
+ import customProperties, { availableCustomProperties } from '../../../../test/jest/customProperties';
7
+ import { renderWithKintHarness } from '../../../../test/jest';
8
+
9
+ jest.mock('../../hooks');
16
10
  jest.mock('./CustomPropertyField', () => () => <div>CustomPropertyField</div>);
17
11
 
18
- const onChange = () => {};
19
- const setCustomProperties = () => {};
12
+ const customProperty = availableCustomProperties?.find(cp => cp.value === 'AuthorIdentification');
13
+
14
+ const onChange = jest.fn();
15
+ const setCustomProperties = jest.fn();
20
16
 
21
17
  describe('CustomPropertyFormCard', () => {
22
18
  let renderComponent;
23
19
  beforeEach(() => {
24
20
  renderComponent = renderWithKintHarness(
25
- <Router>
26
- <CustomPropertyFormCard
27
- availableCustomProperties={availableCustomProperties}
28
- customProperties={customProperties}
29
- customProperty={customProperty}
30
- customPropertyType="primary"
31
- index={0}
32
- internalPropertyCounter={1}
33
- labelOverrides={labelOverrides}
34
- name="customProperties"
35
- onChange={onChange}
36
- setCustomProperties={setCustomProperties}
37
- value={cardFormValue}
38
- />
39
- </Router>
21
+ <CustomPropertyFormCard
22
+ availableCustomProperties={availableCustomProperties}
23
+ customProperties={customProperties}
24
+ customProperty={customProperty}
25
+ customPropertyType="primary"
26
+ index={0}
27
+ internalPropertyCounter={1}
28
+ name="customProperties"
29
+ onChange={onChange}
30
+ setCustomProperties={setCustomProperties}
31
+ value={{}}
32
+ />
40
33
  );
41
34
  });
42
35