@k-int/stripes-kint-components 2.2.0 → 2.3.2

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 (274) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/es/index.js +125 -9
  3. package/es/lib/ActionList/ActionList.js +8 -33
  4. package/es/lib/ActionList/ActionListFieldArray.js +50 -49
  5. package/es/lib/ActionList/index.js +1 -5
  6. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +1 -35
  7. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +3 -39
  8. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +1 -34
  9. package/es/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +4 -33
  10. package/es/lib/CustomProperties/Config/index.js +7 -9
  11. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +43 -0
  12. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +100 -0
  13. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +243 -0
  14. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +337 -0
  15. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +127 -0
  16. package/es/lib/CustomProperties/Edit/index.js +47 -0
  17. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +183 -0
  18. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +204 -0
  19. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +126 -0
  20. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +90 -0
  21. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +139 -0
  22. package/es/lib/CustomProperties/Filter/index.js +55 -0
  23. package/es/lib/CustomProperties/Filter/useOperators.js +100 -0
  24. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +64 -0
  25. package/es/lib/CustomProperties/Filter/useValueProps.js +67 -0
  26. package/es/lib/CustomProperties/View/CustomPropertiesView.js +44 -0
  27. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +155 -0
  28. package/es/lib/CustomProperties/View/CustomPropertyCard.js +175 -0
  29. package/es/lib/CustomProperties/View/index.js +31 -0
  30. package/es/lib/CustomProperties/index.js +121 -0
  31. package/es/lib/EditableRefdataList/EditableRefdataList.js +13 -51
  32. package/es/lib/EditableRefdataList/index.js +1 -5
  33. package/es/lib/EditableSettingsList/EditableSettingsList.js +1 -30
  34. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +1 -30
  35. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +1 -30
  36. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.js +1 -34
  37. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +1 -34
  38. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.js +1 -34
  39. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +1 -41
  40. package/es/lib/EditableSettingsList/SettingField/SettingField.js +1 -34
  41. package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +1 -30
  42. package/es/lib/EditableSettingsList/SettingField/index.js +1 -5
  43. package/es/lib/EditableSettingsList/index.js +1 -5
  44. package/es/lib/FormModal/FormModal.js +21 -34
  45. package/es/lib/FormModal/index.js +1 -5
  46. package/es/lib/NoResultsMessage/NoResultsMessage.js +1 -30
  47. package/es/lib/NoResultsMessage/index.js +1 -5
  48. package/es/lib/QueryTypedown/QueryTypedown.js +9 -37
  49. package/es/lib/QueryTypedown/index.js +1 -5
  50. package/es/lib/RefdataButtons/RefdataButtons.js +1 -34
  51. package/es/lib/RefdataButtons/index.js +1 -5
  52. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +1 -34
  53. package/es/lib/SASQLookupComponent/index.js +1 -5
  54. package/es/lib/SASQRoute/SASQRoute.js +1 -30
  55. package/es/lib/SASQRoute/index.js +1 -5
  56. package/es/lib/SASQViewComponent/SASQViewComponent.js +1 -34
  57. package/es/lib/SASQViewComponent/index.js +1 -5
  58. package/es/lib/SearchField/SearchField.js +1 -31
  59. package/es/lib/SearchField/index.js +1 -5
  60. package/es/lib/SettingPage/SettingPage.js +1 -34
  61. package/es/lib/SettingPage/SettingPagePane.js +1 -32
  62. package/es/lib/SettingPage/index.js +1 -5
  63. package/es/lib/Typedown/Typedown.js +1 -34
  64. package/es/lib/Typedown/index.js +1 -5
  65. package/es/lib/constants/customProperties.js +3 -37
  66. package/es/lib/constants/eventCodes.js +1 -31
  67. package/es/lib/contexts/SettingsContext.js +1 -30
  68. package/es/lib/contexts/index.js +1 -5
  69. package/es/lib/hooks/index.js +16 -4
  70. package/es/lib/hooks/settingsHooks/index.js +1 -5
  71. package/es/lib/hooks/settingsHooks/useSettingSection.js +1 -34
  72. package/es/lib/hooks/settingsHooks/useSettings.js +1 -36
  73. package/es/lib/hooks/typedownHooks/index.js +1 -5
  74. package/es/lib/hooks/typedownHooks/useTypedown.js +1 -34
  75. package/es/lib/hooks/typedownHooks/useTypedownData.js +9 -35
  76. package/es/lib/hooks/typedownHooks/useTypedownToggle.js +1 -34
  77. package/es/lib/hooks/useActiveElement.js +1 -32
  78. package/es/lib/hooks/useAvailableCustomProperties.js +73 -0
  79. package/es/lib/hooks/useCustomProperties.js +1 -34
  80. package/es/lib/hooks/useHelperApp.js +1 -34
  81. package/es/lib/hooks/useInvalidateRefdata.js +20 -0
  82. package/es/lib/hooks/useKiwtFieldArray.js +1 -34
  83. package/es/lib/hooks/useKiwtSASQuery.js +1 -35
  84. package/es/lib/hooks/useLocalStorageState.js +1 -34
  85. package/es/lib/hooks/useMutateCustomProperties.js +1 -34
  86. package/es/lib/hooks/useMutateRefdataValue.js +10 -38
  87. package/es/lib/hooks/useQIndex.js +1 -34
  88. package/es/lib/hooks/useRefdata.js +2 -37
  89. package/es/lib/hooks/useTemplates.js +1 -34
  90. package/es/lib/utils/buildUrl.js +2 -31
  91. package/es/lib/utils/generateKiwtQuery.js +1 -30
  92. package/es/lib/utils/generateKiwtQueryParams.js +1 -30
  93. package/es/lib/utils/groupCustomPropertiesByCtx.js +41 -0
  94. package/es/lib/utils/index.js +25 -5
  95. package/es/lib/utils/refdataOptions.js +1 -30
  96. package/es/lib/utils/refdataQueryKey.js +19 -0
  97. package/es/lib/utils/renderHelpText.js +1 -30
  98. package/es/lib/utils/selectorSafe.js +1 -30
  99. package/es/lib/utils/sortByLabel.js +1 -30
  100. package/es/lib/utils/toCamelCase.js +1 -30
  101. package/es/lib/utils/typedownQueryKey.js +19 -0
  102. package/es/lib/utils/validators.js +59 -31
  103. package/git_translate.sh +8 -0
  104. package/package.json +1 -1
  105. package/src/index.js +27 -3
  106. package/src/lib/ActionList/ActionList.js +5 -2
  107. package/src/lib/ActionList/ActionListFieldArray.js +31 -9
  108. package/src/lib/ActionList/README.md +23 -20
  109. package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +2 -2
  110. package/src/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +3 -3
  111. package/src/lib/CustomProperties/Config/index.js +1 -1
  112. package/src/lib/CustomProperties/Edit/CustomPropertiesEdit.js +35 -0
  113. package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +85 -0
  114. package/src/lib/CustomProperties/Edit/CustomPropertiesListField.js +194 -0
  115. package/src/lib/CustomProperties/Edit/CustomPropertyField.js +299 -0
  116. package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.js +131 -0
  117. package/src/lib/CustomProperties/Edit/index.js +5 -0
  118. package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.js +125 -0
  119. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +148 -0
  120. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +113 -0
  121. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +74 -0
  122. package/src/lib/CustomProperties/Filter/CustomPropertiesRule.js +122 -0
  123. package/src/lib/CustomProperties/Filter/index.js +6 -0
  124. package/src/lib/CustomProperties/Filter/useOperators.js +55 -0
  125. package/src/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +35 -0
  126. package/src/lib/CustomProperties/Filter/useValueProps.js +45 -0
  127. package/src/lib/CustomProperties/View/CustomPropertiesView.js +36 -0
  128. package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +112 -0
  129. package/src/lib/CustomProperties/View/CustomPropertyCard.js +177 -0
  130. package/src/lib/CustomProperties/View/index.js +3 -0
  131. package/src/lib/CustomProperties/index.js +30 -0
  132. package/src/lib/EditableRefdataList/EditableRefdataList.js +13 -10
  133. package/src/lib/FormModal/FormModal.js +39 -17
  134. package/src/lib/QueryTypedown/QueryTypedown.js +3 -1
  135. package/src/lib/constants/customProperties.js +1 -0
  136. package/src/lib/hooks/index.js +2 -0
  137. package/src/lib/hooks/typedownHooks/useTypedownData.js +9 -3
  138. package/src/lib/hooks/useAvailableCustomProperties.js +40 -0
  139. package/src/lib/hooks/useInvalidateRefdata.js +11 -0
  140. package/src/lib/hooks/useMutateRefdataValue.js +7 -3
  141. package/src/lib/hooks/useRefdata.js +2 -3
  142. package/src/lib/utils/groupCustomPropertiesByCtx.js +13 -0
  143. package/src/lib/utils/index.js +5 -0
  144. package/src/lib/utils/refdataQueryKey.js +9 -0
  145. package/src/lib/utils/typedownQueryKey.js +9 -0
  146. package/src/lib/utils/validators.js +40 -0
  147. package/translate.sh +63 -0
  148. package/translations/stripes-kint-components/ar.json +105 -0
  149. package/translations/stripes-kint-components/ca.json +1 -0
  150. package/translations/stripes-kint-components/cs_CZ.json +105 -0
  151. package/translations/stripes-kint-components/da.json +1 -0
  152. package/translations/stripes-kint-components/de.json +105 -0
  153. package/translations/stripes-kint-components/en.json +54 -2
  154. package/translations/stripes-kint-components/es.json +105 -0
  155. package/translations/stripes-kint-components/fr.json +105 -0
  156. package/translations/stripes-kint-components/he.json +1 -0
  157. package/translations/stripes-kint-components/hi_IN.json +105 -0
  158. package/translations/stripes-kint-components/hu.json +105 -0
  159. package/translations/stripes-kint-components/it_IT.json +105 -0
  160. package/translations/stripes-kint-components/ja.json +105 -0
  161. package/translations/stripes-kint-components/ko.json +105 -0
  162. package/translations/stripes-kint-components/nb.json +1 -0
  163. package/translations/stripes-kint-components/nn.json +1 -0
  164. package/translations/stripes-kint-components/pl.json +105 -0
  165. package/translations/stripes-kint-components/pt_PT.json +105 -0
  166. package/translations/stripes-kint-components/ru.json +105 -0
  167. package/translations/stripes-kint-components/sv.json +105 -0
  168. package/translations/stripes-kint-components/ur.json +1 -0
  169. package/translations/stripes-kint-components/zh_CN.json +105 -0
  170. package/es/artifacts/coverage-jest/lcov-report/block-navigation.js +0 -109
  171. package/es/artifacts/coverage-jest/lcov-report/prettify.js +0 -998
  172. package/es/artifacts/coverage-jest/lcov-report/sorter.js +0 -238
  173. package/junit.xml +0 -79
  174. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +0 -286
  175. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +0 -925
  176. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +0 -146
  177. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +0 -88
  178. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesLookup.js.html +0 -418
  179. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesSettings.js.html +0 -808
  180. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesView.js.html +0 -601
  181. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +0 -1135
  182. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +0 -176
  183. package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +0 -97
  184. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +0 -373
  185. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +0 -131
  186. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +0 -88
  187. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +0 -223
  188. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +0 -211
  189. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +0 -376
  190. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +0 -262
  191. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +0 -436
  192. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +0 -161
  193. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +0 -94
  194. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +0 -146
  195. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +0 -94
  196. package/src/artifacts/coverage-jest/lcov-report/FormModal/FormModal.js.html +0 -283
  197. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.html +0 -131
  198. package/src/artifacts/coverage-jest/lcov-report/FormModal/index.js.html +0 -88
  199. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +0 -319
  200. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +0 -131
  201. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +0 -88
  202. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +0 -184
  203. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +0 -131
  204. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +0 -88
  205. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +0 -370
  206. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +0 -131
  207. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +0 -88
  208. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +0 -949
  209. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +0 -131
  210. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +0 -88
  211. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +0 -301
  212. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +0 -131
  213. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +0 -88
  214. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +0 -253
  215. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +0 -131
  216. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +0 -88
  217. package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +0 -214
  218. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +0 -131
  219. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +0 -88
  220. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +0 -211
  221. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +0 -178
  222. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +0 -146
  223. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +0 -91
  224. package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +0 -919
  225. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +0 -131
  226. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +0 -88
  227. package/src/artifacts/coverage-jest/lcov-report/base.css +0 -224
  228. package/src/artifacts/coverage-jest/lcov-report/block-navigation.js +0 -87
  229. package/src/artifacts/coverage-jest/lcov-report/constants/customProperties.js.html +0 -112
  230. package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +0 -94
  231. package/src/artifacts/coverage-jest/lcov-report/constants/index.html +0 -131
  232. package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +0 -97
  233. package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +0 -131
  234. package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +0 -91
  235. package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
  236. package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +0 -281
  237. package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +0 -121
  238. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +0 -146
  239. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +0 -91
  240. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +0 -163
  241. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +0 -403
  242. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +0 -161
  243. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +0 -94
  244. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +0 -520
  245. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +0 -163
  246. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +0 -163
  247. package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +0 -157
  248. package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +0 -313
  249. package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +0 -283
  250. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +0 -274
  251. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +0 -178
  252. package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +0 -136
  253. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateCustomProperties.js.html +0 -271
  254. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +0 -301
  255. package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +0 -208
  256. package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +0 -268
  257. package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +0 -166
  258. package/src/artifacts/coverage-jest/lcov-report/index.html +0 -416
  259. package/src/artifacts/coverage-jest/lcov-report/prettify.css +0 -1
  260. package/src/artifacts/coverage-jest/lcov-report/prettify.js +0 -2
  261. package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
  262. package/src/artifacts/coverage-jest/lcov-report/sorter.js +0 -196
  263. package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +0 -193
  264. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +0 -109
  265. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +0 -454
  266. package/src/artifacts/coverage-jest/lcov-report/utils/index.html +0 -251
  267. package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +0 -121
  268. package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +0 -106
  269. package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +0 -166
  270. package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +0 -103
  271. package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +0 -130
  272. package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +0 -127
  273. package/src/artifacts/coverage-jest/lcov-report/utils/validators.js.html +0 -202
  274. package/src/artifacts/coverage-jest/lcov.info +0 -2562
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _reactIntl = require("react-intl");
15
+
16
+ var _reactFinalForm = require("react-final-form");
17
+
18
+ var _components = require("@folio/stripes/components");
19
+
20
+ var _validators = require("../../utils/validators");
21
+
22
+ var _useValueProps = _interopRequireDefault(require("./useValueProps"));
23
+
24
+ var _useOperators = _interopRequireDefault(require("./useOperators"));
25
+
26
+ var _jsxRuntime = require("react/jsx-runtime");
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
+
32
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
+
34
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
+
36
+ var propTypes = {
37
+ ariaLabelledby: _propTypes.default.string.isRequired,
38
+ clearRuleValue: _propTypes.default.func.isRequired,
39
+ index: _propTypes.default.number.isRequired,
40
+ name: _propTypes.default.string.isRequired,
41
+ onDelete: _propTypes.default.func.isRequired,
42
+ custPropDefinition: _propTypes.default.shape({
43
+ type: _propTypes.default.string,
44
+ category: _propTypes.default.shape({
45
+ values: _propTypes.default.arrayOf(_propTypes.default.object)
46
+ })
47
+ }),
48
+ value: _propTypes.default.shape({
49
+ operator: _propTypes.default.string,
50
+ value: _propTypes.default.string
51
+ })
52
+ };
53
+
54
+ var CustomPropertiesRule = function CustomPropertiesRule(_ref) {
55
+ var ariaLabelledby = _ref.ariaLabelledby,
56
+ clearRuleValue = _ref.clearRuleValue,
57
+ index = _ref.index,
58
+ name = _ref.name,
59
+ onDelete = _ref.onDelete,
60
+ _ref$custPropDefiniti = _ref.custPropDefinition,
61
+ custPropDefinition = _ref$custPropDefiniti === void 0 ? {} : _ref$custPropDefiniti,
62
+ value = _ref.value;
63
+ var operators = (0, _useOperators.default)(custPropDefinition.type);
64
+ var valueProps = (0, _useValueProps.default)(custPropDefinition);
65
+ var selectedOperator = operators.find(function (o) {
66
+ return o.value === (value === null || value === void 0 ? void 0 : value.operator);
67
+ });
68
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Row, {
69
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
70
+ xs: 2,
71
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Layout, {
72
+ className: "textCentered",
73
+ children: index === 0 ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
74
+ id: "stripes-kint-components.OR"
75
+ })
76
+ })
77
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
78
+ xs: 4,
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
80
+ name: "".concat(name, ".operator"),
81
+ validate: _validators.required,
82
+ children: function children(_ref2) {
83
+ var input = _ref2.input,
84
+ meta = _ref2.meta;
85
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Select, _objectSpread(_objectSpread({}, input), {}, {
86
+ "aria-labelledby": "".concat(ariaLabelledby, "-rule-column-header-comparator"),
87
+ dataOptions: operators,
88
+ error: (meta === null || meta === void 0 ? void 0 : meta.touched) && (meta === null || meta === void 0 ? void 0 : meta.error),
89
+ onChange: function onChange(e) {
90
+ input.onChange(e);
91
+ var newlySelectedOperator = operators.find(function (o) {
92
+ return o.value === e.target.value;
93
+ });
94
+
95
+ if (newlySelectedOperator !== null && newlySelectedOperator !== void 0 && newlySelectedOperator.noValueAllowed) {
96
+ clearRuleValue();
97
+ }
98
+ },
99
+ placeholder: " ",
100
+ required: true
101
+ }));
102
+ }
103
+ })
104
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
105
+ xs: 4,
106
+ children: selectedOperator !== null && selectedOperator !== void 0 && selectedOperator.noValueAllowed ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, _objectSpread({
107
+ "aria-labelledby": "".concat(ariaLabelledby, "-rule-column-header-value"),
108
+ name: "".concat(name, ".value"),
109
+ required: true,
110
+ validate: _validators.required
111
+ }, valueProps))
112
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
113
+ xs: 2,
114
+ children: index ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
115
+ id: (0, _uniqueId2.default)('delete-rule-btn'),
116
+ text: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
117
+ id: "stripes-kint-components.customProperty.removeRule",
118
+ values: {
119
+ number: index + 1
120
+ }
121
+ }),
122
+ children: function children(_ref3) {
123
+ var ref = _ref3.ref,
124
+ ariaIds = _ref3.ariaIds;
125
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
126
+ ref: ref,
127
+ "aria-labelledby": ariaIds.text,
128
+ icon: "trash",
129
+ onClick: onDelete
130
+ });
131
+ }
132
+ }) : null
133
+ })]
134
+ }, name);
135
+ };
136
+
137
+ CustomPropertiesRule.propTypes = propTypes;
138
+ var _default = CustomPropertiesRule;
139
+ exports.default = _default;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CustomPropertiesFilter", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _CustomPropertiesFilter.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "CustomPropertiesFilterField", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _CustomPropertiesFilterField.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "CustomPropertiesFilterFieldArray", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _CustomPropertiesFilterFieldArray.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "CustomPropertiesFilterForm", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _CustomPropertiesFilterForm.default;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "useOperators", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _useOperators.default;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "useParseActiveFilterStrings", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _useParseActiveFilterStrings.default;
40
+ }
41
+ });
42
+
43
+ var _CustomPropertiesFilter = _interopRequireDefault(require("./CustomPropertiesFilter"));
44
+
45
+ var _CustomPropertiesFilterForm = _interopRequireDefault(require("./CustomPropertiesFilterForm"));
46
+
47
+ var _useOperators = _interopRequireDefault(require("./useOperators"));
48
+
49
+ var _useParseActiveFilterStrings = _interopRequireDefault(require("./useParseActiveFilterStrings"));
50
+
51
+ var _CustomPropertiesFilterField = _interopRequireDefault(require("./CustomPropertiesFilterField"));
52
+
53
+ var _CustomPropertiesFilterFieldArray = _interopRequireDefault(require("./CustomPropertiesFilterFieldArray"));
54
+
55
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _reactIntl = require("react-intl");
11
+
12
+ var CUSTPROP_TYPES = _interopRequireWildcard(require("../../constants/customProperties"));
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ var REFDATA = CUSTPROP_TYPES.REFDATA_CLASS_NAME,
19
+ DECIMAL = CUSTPROP_TYPES.DECIMAL_CLASS_NAME,
20
+ INTEGER = CUSTPROP_TYPES.INTEGER_CLASS_NAME,
21
+ DATE = CUSTPROP_TYPES.DATE_CLASS_NAME,
22
+ TEXT = CUSTPROP_TYPES.TEXT_CLASS_NAME;
23
+
24
+ var useOperators = function useOperators(type) {
25
+ var intl = (0, _reactIntl.useIntl)();
26
+
27
+ var getLabel = function getLabel(id) {
28
+ return intl.formatMessage({
29
+ id: id
30
+ });
31
+ };
32
+
33
+ var operators = [{
34
+ value: ' isSet',
35
+ label: getLabel('stripes-kint-components.operator.isSet'),
36
+ noValueAllowed: true
37
+ }, {
38
+ value: ' isNotSet',
39
+ label: getLabel('stripes-kint-components.operator.isNotSet'),
40
+ noValueAllowed: true
41
+ }];
42
+
43
+ if (!type || type === INTEGER || type === DECIMAL) {
44
+ operators.push({
45
+ value: '==',
46
+ label: getLabel('stripes-kint-components.operator.equals')
47
+ }, {
48
+ value: '!=',
49
+ label: getLabel('stripes-kint-components.operator.doesNotEqual')
50
+ }, {
51
+ value: '>=',
52
+ label: getLabel('stripes-kint-components.operator.isGreaterThanOrEqual')
53
+ }, {
54
+ value: '<=',
55
+ label: getLabel('stripes-kint-components.operator.isLessThanOrEqual')
56
+ });
57
+ }
58
+
59
+ if (type === DATE) {
60
+ // Basically the same as the "number" types above, so no need to reassign if there is no type
61
+ operators.push({
62
+ value: '==',
63
+ label: getLabel('stripes-kint-components.operator.equals')
64
+ }, {
65
+ value: '!=',
66
+ label: getLabel('stripes-kint-components.operator.doesNotEqual')
67
+ }, {
68
+ value: '>=',
69
+ label: getLabel('stripes-kint-components.operator.isOnOrAfter')
70
+ }, {
71
+ value: '<=',
72
+ label: getLabel('stripes-kint-components.operator.isOnOrBefore')
73
+ });
74
+ }
75
+
76
+ if (!type || type === REFDATA) {
77
+ operators.push({
78
+ value: '==',
79
+ label: getLabel('stripes-kint-components.operator.is')
80
+ }, {
81
+ value: '!=',
82
+ label: getLabel('stripes-kint-components.operator.isNot')
83
+ });
84
+ }
85
+
86
+ if (!type || type === TEXT) {
87
+ operators.push({
88
+ value: '=~',
89
+ label: getLabel('stripes-kint-components.operator.contains')
90
+ }, {
91
+ value: '!~',
92
+ label: getLabel('stripes-kint-components.operator.doesNotContain')
93
+ });
94
+ }
95
+
96
+ return operators;
97
+ };
98
+
99
+ var _default = useOperators;
100
+ exports.default = _default;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _useOperators = _interopRequireDefault(require("./useOperators"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+
16
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
19
+
20
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
21
+
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+
24
+ var useParseActiveFilterStrings = function useParseActiveFilterStrings(filterStrings) {
25
+ var operators = (0, _useOperators.default)().map(function (o) {
26
+ return o.value;
27
+ });
28
+ var numberOfFilters = 0;
29
+ var filters = filterStrings.map(function (filter) {
30
+ var customProperty;
31
+ var rules = filter.split('||').map(function (ruleString) {
32
+ var _operators$find;
33
+
34
+ // ruleString is constructed in this.handleSubmit passed to CustomPropertyFiltersForm
35
+ // and has shape "customProperties.foo.value!=42"
36
+ var _ruleString$split = ruleString.split('.value'),
37
+ _ruleString$split2 = _slicedToArray(_ruleString$split, 2),
38
+ customPropertyPath = _ruleString$split2[0],
39
+ rule = _ruleString$split2[1];
40
+
41
+ customProperty = customPropertyPath.replace('customProperties.', '');
42
+ var operator = (_operators$find = operators.find(function (o) {
43
+ return rule.startsWith(o);
44
+ })) !== null && _operators$find !== void 0 ? _operators$find : '';
45
+ var value = rule.substring(operator.length);
46
+ numberOfFilters += 1;
47
+ return {
48
+ operator: operator,
49
+ value: value
50
+ };
51
+ });
52
+ return {
53
+ customProperty: customProperty,
54
+ rules: rules
55
+ };
56
+ });
57
+ return {
58
+ filters: filters,
59
+ numberOfFilters: numberOfFilters
60
+ };
61
+ };
62
+
63
+ var _default = useParseActiveFilterStrings;
64
+ exports.default = _default;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _components = require("@folio/stripes/components");
11
+
12
+ var CUSTPROP_TYPES = _interopRequireWildcard(require("../../constants/customProperties"));
13
+
14
+ var _validators = require("../../utils/validators");
15
+
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
20
+ var REFDATA = CUSTPROP_TYPES.REFDATA_CLASS_NAME,
21
+ DECIMAL = CUSTPROP_TYPES.DECIMAL_CLASS_NAME,
22
+ INTEGER = CUSTPROP_TYPES.INTEGER_CLASS_NAME,
23
+ DATE = CUSTPROP_TYPES.DATE_CLASS_NAME,
24
+ TEXT = CUSTPROP_TYPES.TEXT_CLASS_NAME;
25
+
26
+ var useValueProps = function useValueProps(custPropDefinition) {
27
+ var props = {
28
+ validate: _validators.required
29
+ };
30
+
31
+ switch (custPropDefinition.type) {
32
+ case INTEGER:
33
+ case DECIMAL:
34
+ props.component = _components.TextField;
35
+ props.type = 'number';
36
+ props.validate = _validators.invalidNumber;
37
+ break;
38
+
39
+ case REFDATA:
40
+ props.component = _components.Select;
41
+ props.dataOptions = custPropDefinition.category.values.map(function (rdv) {
42
+ return {
43
+ label: rdv.label,
44
+ value: rdv.id
45
+ };
46
+ });
47
+ props.placeholder = ' ';
48
+ break;
49
+
50
+ case DATE:
51
+ props.component = _components.Datepicker;
52
+ props.backendDateStandard = 'YYYY-MM-DD';
53
+ props.timeZone = 'UTC';
54
+ props.usePortal = true;
55
+ break;
56
+
57
+ case TEXT:
58
+ default:
59
+ props.component = _components.TextField;
60
+ break;
61
+ }
62
+
63
+ return props;
64
+ };
65
+
66
+ var _default = useValueProps;
67
+ exports.default = _default;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _CustomPropertiesViewCtx = _interopRequireDefault(require("./CustomPropertiesViewCtx"));
11
+
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ var CustomPropertiesView = function CustomPropertiesView(_ref) {
17
+ var _ref$contexts = _ref.contexts,
18
+ contexts = _ref$contexts === void 0 ? [] : _ref$contexts,
19
+ customProperties = _ref.customProperties,
20
+ customPropertiesEndpoint = _ref.customPropertiesEndpoint,
21
+ id = _ref.id,
22
+ _ref$labelOverrides = _ref.labelOverrides,
23
+ labelOverrides = _ref$labelOverrides === void 0 ? {} : _ref$labelOverrides;
24
+ return contexts.map(function (ctx) {
25
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesViewCtx.default, {
26
+ ctx: ctx,
27
+ customProperties: customProperties,
28
+ customPropertiesEndpoint: customPropertiesEndpoint,
29
+ id: id,
30
+ labelOverrides: labelOverrides
31
+ }, "customPropertiesView-".concat(ctx));
32
+ });
33
+ };
34
+
35
+ CustomPropertiesView.propTypes = {
36
+ contexts: _propTypes.default.arrayOf(_propTypes.default.string),
37
+ customProperties: _propTypes.default.object,
38
+ customPropertiesEndpoint: _propTypes.default.string,
39
+ id: _propTypes.default.string,
40
+ labelOverrides: _propTypes.default.object,
41
+ nameOverride: _propTypes.default.string
42
+ };
43
+ var _default = CustomPropertiesView;
44
+ exports.default = _default;
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _reactIntl = require("react-intl");
11
+
12
+ var _components = require("@folio/stripes/components");
13
+
14
+ var _hooks = require("../../hooks");
15
+
16
+ var _CustomPropertyCard = _interopRequireDefault(require("./CustomPropertyCard"));
17
+
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
+
24
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
+
26
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
+
28
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
29
+
30
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
31
+
32
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
+
34
+ var CustomPropertiesViewCtx = function CustomPropertiesViewCtx(_ref) {
35
+ var _custprops$filter$len, _custprops$filter, _Object$entries$filte, _Object$entries, _Object$entries$filte2;
36
+
37
+ var ctx = _ref.ctx,
38
+ _ref$customProperties = _ref.customProperties,
39
+ customProperties = _ref$customProperties === void 0 ? [] : _ref$customProperties,
40
+ customPropertiesEndpoint = _ref.customPropertiesEndpoint,
41
+ id = _ref.id,
42
+ labelOverrides = _ref.labelOverrides;
43
+
44
+ // Deal with all the possible label override options
45
+ var getAccordionLabel = function getAccordionLabel() {
46
+ var _labelOverrides$defau;
47
+
48
+ // Special case for null context
49
+ if (ctx === 'isNull') {
50
+ var _labelOverrides$noCon;
51
+
52
+ return (_labelOverrides$noCon = labelOverrides.noContext) !== null && _labelOverrides$noCon !== void 0 ? _labelOverrides$noCon : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
53
+ id: "stripes-kint-components.customProperties"
54
+ });
55
+ } // Label overrides for specific contexts
56
+
57
+
58
+ if (labelOverrides[ctx]) {
59
+ return labelOverrides[ctx];
60
+ } // Label override for default title, taking ctx into account
61
+
62
+
63
+ if (labelOverrides.defaultTitle && typeof labelOverrides.defaultTitle === 'function') {
64
+ return labelOverrides.defaultTitle(ctx);
65
+ } // Label override for default title or finally built in default
66
+
67
+
68
+ return (_labelOverrides$defau = labelOverrides.defaultTitle) !== null && _labelOverrides$defau !== void 0 ? _labelOverrides$defau : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
69
+ id: "stripes-kint-components.customProperties.ctx.title",
70
+ values: {
71
+ ctx: ctx
72
+ }
73
+ });
74
+ };
75
+
76
+ var _useCustomProperties = (0, _hooks.useCustomProperties)({
77
+ ctx: ctx,
78
+ endpoint: customPropertiesEndpoint,
79
+ returnQueryObject: true,
80
+ options: {
81
+ sort: [{
82
+ path: 'retired'
83
+ }, // Place retired custprops at the end
84
+ {
85
+ path: 'primary',
86
+ direction: 'desc'
87
+ }, // Primary properties should display before optional
88
+ {
89
+ path: 'label'
90
+ } // Within those groups, sort by label
91
+ ]
92
+ }
93
+ }),
94
+ custprops = _useCustomProperties.data,
95
+ isLoading = _useCustomProperties.isLoading;
96
+
97
+ if (isLoading) {
98
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Accordion, {
99
+ closedByDefault: true,
100
+ displayWhenClosed: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {}),
101
+ displayWhenOpen: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {}),
102
+ id: "".concat(id, "-accordion-").concat(ctx),
103
+ label: getAccordionLabel(),
104
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
105
+ });
106
+ } // We need to display any set properties, along with any non-set primary properties
107
+
108
+
109
+ var primaryCount = (_custprops$filter$len = custprops === null || custprops === void 0 ? void 0 : (_custprops$filter = custprops.filter(function (cp) {
110
+ return cp.primary === true;
111
+ })) === null || _custprops$filter === void 0 ? void 0 : _custprops$filter.length) !== null && _custprops$filter$len !== void 0 ? _custprops$filter$len : 0;
112
+ var optionalCount = (_Object$entries$filte = (_Object$entries = Object.entries(customProperties)) === null || _Object$entries === void 0 ? void 0 : (_Object$entries$filte2 = _Object$entries.filter(function (_ref2) {
113
+ var _cp$, _cp$$type, _cp$2, _cp$2$type, _cp$3, _cp$3$type;
114
+
115
+ var _ref3 = _slicedToArray(_ref2, 2),
116
+ _key = _ref3[0],
117
+ cp = _ref3[1];
118
+
119
+ return (((_cp$ = cp[0]) === null || _cp$ === void 0 ? void 0 : (_cp$$type = _cp$.type) === null || _cp$$type === void 0 ? void 0 : _cp$$type.ctx) === ctx || ctx === 'isNull' && !((_cp$2 = cp[0]) !== null && _cp$2 !== void 0 && (_cp$2$type = _cp$2.type) !== null && _cp$2$type !== void 0 && _cp$2$type.ctx)) && // Either the ctx string matches, or isNull matches blank
120
+ ((_cp$3 = cp[0]) === null || _cp$3 === void 0 ? void 0 : (_cp$3$type = _cp$3.type) === null || _cp$3$type === void 0 ? void 0 : _cp$3$type.primary) === false // Only count non-primary set custprops
121
+ ;
122
+ })) === null || _Object$entries$filte2 === void 0 ? void 0 : _Object$entries$filte2.length) !== null && _Object$entries$filte !== void 0 ? _Object$entries$filte : 0;
123
+ return primaryCount + optionalCount > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Accordion, {
124
+ closedByDefault: true,
125
+ displayWhenClosed: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Badge, {
126
+ children: primaryCount + optionalCount
127
+ }),
128
+ displayWhenOpen: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Badge, {
129
+ children: primaryCount + optionalCount
130
+ }),
131
+ id: "".concat(id, "-accordion-").concat(ctx),
132
+ label: getAccordionLabel(),
133
+ children: custprops.map(function (cp, index) {
134
+ var _customProperties$cp$;
135
+
136
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertyCard.default, {
137
+ ctx: ctx,
138
+ customProperty: customProperties === null || customProperties === void 0 ? void 0 : (_customProperties$cp$ = customProperties[cp.name]) === null || _customProperties$cp$ === void 0 ? void 0 : _customProperties$cp$[0],
139
+ customPropertyDefinition: cp,
140
+ index: index,
141
+ labelOverrides: labelOverrides
142
+ }, "custom-property-card-".concat(ctx, "[").concat(index, "]"));
143
+ })
144
+ });
145
+ };
146
+
147
+ CustomPropertiesViewCtx.propTypes = {
148
+ ctx: _propTypes.default.string,
149
+ customProperties: _propTypes.default.object,
150
+ customPropertiesEndpoint: _propTypes.default.string,
151
+ id: _propTypes.default.string,
152
+ labelOverrides: _propTypes.default.object
153
+ };
154
+ var _default = CustomPropertiesViewCtx;
155
+ exports.default = _default;