@k-int/stripes-kint-components 1.3.0 → 1.7.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 (251) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/es/artifacts/coverage-jest/lcov-report/block-navigation.js +109 -0
  3. package/es/artifacts/coverage-jest/lcov-report/prettify.js +998 -0
  4. package/es/artifacts/coverage-jest/lcov-report/sorter.js +238 -0
  5. package/es/index.js +69 -17
  6. package/es/lib/ActionList/ActionList.js +63 -24
  7. package/es/lib/ActionList/ActionListFieldArray.js +158 -96
  8. package/es/lib/ActionList/index.js +7 -3
  9. package/es/lib/EditableRefdataList/EditableRefdataList.js +69 -24
  10. package/es/lib/EditableRefdataList/index.js +7 -3
  11. package/es/lib/EditableSettingsList/EditableSettingsList.js +90 -0
  12. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +90 -0
  13. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +181 -0
  14. package/es/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +72 -9
  15. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +447 -0
  16. package/es/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +45 -7
  17. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +495 -0
  18. package/es/lib/EditableSettingsList/SettingField/SettingField.js +187 -0
  19. package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +180 -0
  20. package/es/lib/EditableSettingsList/SettingField/index.js +35 -0
  21. package/es/lib/EditableSettingsList/index.js +35 -0
  22. package/es/lib/NoResultsMessage/NoResultsMessage.js +122 -0
  23. package/es/lib/NoResultsMessage/index.js +19 -0
  24. package/es/lib/QueryTypedown/QueryTypedown.js +48 -9
  25. package/es/lib/QueryTypedown/index.js +6 -2
  26. package/es/lib/RefdataButtons/RefdataButtons.js +143 -0
  27. package/es/lib/RefdataButtons/index.js +19 -0
  28. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +202 -131
  29. package/es/lib/SASQLookupComponent/index.js +6 -2
  30. package/es/lib/SASQRoute/SASQRoute.js +55 -18
  31. package/es/lib/SASQRoute/index.js +6 -2
  32. package/es/lib/SASQViewComponent/SASQViewComponent.js +50 -11
  33. package/es/lib/SASQViewComponent/index.js +6 -2
  34. package/es/lib/SearchField/SearchField.js +48 -13
  35. package/es/lib/SearchField/index.js +6 -2
  36. package/es/lib/SettingPage/SettingPage.js +99 -0
  37. package/es/lib/SettingPage/SettingPagePane.js +83 -0
  38. package/es/lib/SettingPage/index.js +27 -0
  39. package/es/lib/TypeDown/TypeDown.js +143 -101
  40. package/es/lib/TypeDown/index.js +6 -2
  41. package/es/lib/Typedown/Typedown.js +140 -96
  42. package/es/lib/Typedown/index.js +6 -2
  43. package/es/lib/constants/eventCodes.js +31 -1
  44. package/es/lib/contexts/SettingsContext.js +41 -0
  45. package/es/lib/contexts/index.js +19 -0
  46. package/es/lib/hooks/index.js +42 -8
  47. package/es/lib/hooks/settingsHooks/index.js +27 -0
  48. package/es/lib/hooks/settingsHooks/useSettingSection.js +74 -0
  49. package/es/lib/hooks/settingsHooks/useSettings.js +175 -0
  50. package/es/lib/hooks/typedownHooks/index.js +8 -28
  51. package/es/lib/hooks/typedownHooks/useTypedown.js +129 -12
  52. package/es/lib/hooks/typedownHooks/useTypedownData.js +35 -2
  53. package/es/lib/hooks/typedownHooks/useTypedownToggle.js +39 -6
  54. package/es/lib/hooks/useActiveElement.js +33 -2
  55. package/es/lib/hooks/useHelperApp.js +51 -12
  56. package/es/lib/hooks/useKiwtFieldArray.js +142 -0
  57. package/es/lib/hooks/useKiwtSASQuery.js +62 -7
  58. package/es/lib/hooks/useLocalStorageState.js +37 -4
  59. package/es/lib/hooks/useMutateRefdataValue.js +42 -9
  60. package/es/lib/hooks/useQIndex.js +108 -0
  61. package/es/lib/hooks/useRefdata.js +56 -12
  62. package/es/lib/hooks/useTemplates.js +36 -3
  63. package/es/lib/utils/buildUrl.js +43 -10
  64. package/es/lib/utils/generateKiwtQuery.js +31 -108
  65. package/es/lib/utils/generateKiwtQueryParams.js +154 -0
  66. package/es/lib/utils/index.js +55 -3
  67. package/es/lib/utils/refdataOptions.js +43 -0
  68. package/es/lib/utils/renderHelpText.js +109 -0
  69. package/es/lib/utils/selectorSafe.js +31 -2
  70. package/es/lib/utils/sortByLabel.js +55 -0
  71. package/es/lib/utils/toCamelCase.js +48 -0
  72. package/jest.config.js +15 -1
  73. package/junit.xml +79 -0
  74. package/package.json +17 -10
  75. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +256 -0
  76. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +799 -0
  77. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +146 -0
  78. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +88 -0
  79. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +376 -0
  80. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +131 -0
  81. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +88 -0
  82. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +223 -0
  83. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +211 -0
  84. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +376 -0
  85. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +262 -0
  86. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +436 -0
  87. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +161 -0
  88. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +94 -0
  89. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +146 -0
  90. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +94 -0
  91. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +319 -0
  92. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +131 -0
  93. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +88 -0
  94. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +184 -0
  95. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +131 -0
  96. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +88 -0
  97. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +370 -0
  98. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +131 -0
  99. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +88 -0
  100. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +949 -0
  101. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +131 -0
  102. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +88 -0
  103. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +274 -0
  104. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +131 -0
  105. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +88 -0
  106. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +250 -0
  107. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +131 -0
  108. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +88 -0
  109. package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +214 -0
  110. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +131 -0
  111. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +88 -0
  112. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +211 -0
  113. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +178 -0
  114. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +146 -0
  115. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +91 -0
  116. package/src/artifacts/coverage-jest/lcov-report/TypeDown/TypeDown.js.html +769 -0
  117. package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.html +131 -0
  118. package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.js.html +88 -0
  119. package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +790 -0
  120. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +131 -0
  121. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +88 -0
  122. package/src/artifacts/coverage-jest/lcov-report/base.css +224 -0
  123. package/src/artifacts/coverage-jest/lcov-report/block-navigation.js +87 -0
  124. package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +94 -0
  125. package/src/artifacts/coverage-jest/lcov-report/constants/index.html +116 -0
  126. package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +97 -0
  127. package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +131 -0
  128. package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +91 -0
  129. package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
  130. package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +251 -0
  131. package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +115 -0
  132. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +146 -0
  133. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +91 -0
  134. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +163 -0
  135. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +403 -0
  136. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +161 -0
  137. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +94 -0
  138. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +520 -0
  139. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +163 -0
  140. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +163 -0
  141. package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +157 -0
  142. package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +283 -0
  143. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +274 -0
  144. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +178 -0
  145. package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +136 -0
  146. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +301 -0
  147. package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +208 -0
  148. package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +268 -0
  149. package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +166 -0
  150. package/src/artifacts/coverage-jest/lcov-report/index.html +401 -0
  151. package/src/artifacts/coverage-jest/lcov-report/prettify.css +1 -0
  152. package/src/artifacts/coverage-jest/lcov-report/prettify.js +2 -0
  153. package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
  154. package/src/artifacts/coverage-jest/lcov-report/sorter.js +196 -0
  155. package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +193 -0
  156. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +109 -0
  157. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +286 -0
  158. package/src/artifacts/coverage-jest/lcov-report/utils/index.html +236 -0
  159. package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +121 -0
  160. package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +106 -0
  161. package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +166 -0
  162. package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +103 -0
  163. package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +130 -0
  164. package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +127 -0
  165. package/src/artifacts/coverage-jest/lcov.info +1999 -0
  166. package/src/index.js +21 -6
  167. package/src/lib/ActionList/ActionList.js +5 -2
  168. package/src/lib/ActionList/ActionListFieldArray.js +20 -8
  169. package/src/lib/ActionList/README.md +1 -0
  170. package/src/lib/ActionList/index.js +1 -1
  171. package/src/lib/EditableRefdataList/EditableRefdataList.js +10 -5
  172. package/src/lib/EditableRefdataList/index.js +1 -1
  173. package/src/lib/{Settings → EditableSettingsList}/EditableSettingsList.js +0 -0
  174. package/src/lib/{Settings → EditableSettingsList}/EditableSettingsListFieldArray.js +2 -2
  175. package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +111 -0
  176. package/src/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +24 -1
  177. package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +379 -0
  178. package/src/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +2 -1
  179. package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +368 -0
  180. package/src/lib/{Settings → EditableSettingsList/SettingField}/SettingField.js +7 -7
  181. package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +80 -0
  182. package/src/lib/EditableSettingsList/SettingField/index.js +3 -0
  183. package/src/lib/EditableSettingsList/index.js +3 -0
  184. package/src/lib/NoResultsMessage/NoResultsMessage.js +78 -0
  185. package/src/lib/NoResultsMessage/index.js +1 -0
  186. package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
  187. package/src/lib/RefdataButtons/index.js +1 -0
  188. package/src/lib/SASQLookupComponent/SASQLookupComponent.js +36 -8
  189. package/src/lib/SASQRoute/README.md +1 -1
  190. package/src/lib/{Settings → SettingPage}/SettingPage.js +5 -5
  191. package/src/lib/{Settings → SettingPage}/SettingPagePane.js +12 -2
  192. package/src/lib/SettingPage/index.js +2 -0
  193. package/src/lib/TypeDown/README.md +1 -115
  194. package/src/lib/TypeDown/TypeDown.js +4 -2
  195. package/src/lib/Typedown/Typedown.js +2 -1
  196. package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
  197. package/src/lib/contexts/index.js +2 -0
  198. package/src/lib/hooks/README.md +107 -0
  199. package/src/lib/hooks/index.js +3 -0
  200. package/src/lib/hooks/settingsHooks/index.js +2 -0
  201. package/src/lib/{Settings → hooks/settingsHooks}/useSettingSection.js +0 -0
  202. package/src/lib/{Settings → hooks/settingsHooks}/useSettings.js +14 -6
  203. package/src/lib/hooks/typedownHooks/index.js +0 -3
  204. package/src/lib/hooks/typedownHooks/useTypedown.js +93 -11
  205. package/src/lib/hooks/useHelperApp.js +5 -1
  206. package/src/lib/hooks/useKiwtFieldArray.js +63 -0
  207. package/src/lib/hooks/useKiwtSASQuery.js +9 -1
  208. package/src/lib/hooks/useQIndex.js +41 -0
  209. package/src/lib/hooks/useRefdata.js +17 -6
  210. package/src/lib/utils/README.md +39 -1
  211. package/src/lib/utils/generateKiwtQuery.js +3 -62
  212. package/src/lib/utils/generateKiwtQueryParams.js +67 -0
  213. package/src/lib/utils/index.js +10 -0
  214. package/src/lib/utils/refdataOptions.js +7 -0
  215. package/src/lib/{Settings/utils → utils}/renderHelpText.js +1 -1
  216. package/src/lib/{Settings/utils → utils}/sortByLabel.js +1 -1
  217. package/src/lib/{Settings/utils → utils}/toCamelCase.js +0 -0
  218. package/styles/NoResultsMessage.css +38 -0
  219. package/test/helpers/index.js +1 -0
  220. package/test/helpers/translationsProperties.js +40 -0
  221. package/test/jest/helpers/KintHarness.js +36 -0
  222. package/test/jest/helpers/index.js +2 -0
  223. package/test/jest/helpers/renderWithKintHarness.js +15 -0
  224. package/test/jest/jest-transformer.js +4 -0
  225. package/test/jest/setupTests.js +1 -0
  226. package/translations/stripes-kint-components/en.json +4 -1
  227. package/babelOptions.js +0 -30
  228. package/es/lib/Settings/EditableSettingsList.js +0 -57
  229. package/es/lib/Settings/EditableSettingsListFieldArray.js +0 -59
  230. package/es/lib/Settings/RefdataButtons.js +0 -100
  231. package/es/lib/Settings/SettingField.js +0 -144
  232. package/es/lib/Settings/SettingPage.js +0 -64
  233. package/es/lib/Settings/SettingPagePane.js +0 -43
  234. package/es/lib/Settings/SettingsContext.js +0 -18
  235. package/es/lib/Settings/index.js +0 -71
  236. package/es/lib/Settings/useSettingSection.js +0 -41
  237. package/es/lib/Settings/useSettings.js +0 -126
  238. package/es/lib/Settings/utils/index.js +0 -31
  239. package/es/lib/Settings/utils/renderHelpText.js +0 -57
  240. package/es/lib/Settings/utils/sortByLabel.js +0 -26
  241. package/es/lib/Settings/utils/toCamelCase.js +0 -19
  242. package/es/lib/hooks/typedownHooks/useTypedownFooter.js +0 -47
  243. package/es/lib/hooks/typedownHooks/useTypedownList.js +0 -45
  244. package/es/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -47
  245. package/es/lib/utils/getFocusableElements.js +0 -132
  246. package/src/lib/Settings/index.js +0 -8
  247. package/src/lib/Settings/utils/index.js +0 -3
  248. package/src/lib/hooks/typedownHooks/useTypedownFooter.js +0 -43
  249. package/src/lib/hooks/typedownHooks/useTypedownList.js +0 -36
  250. package/src/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -39
  251. package/src/lib/utils/getFocusableElements.js +0 -99
@@ -1,9 +1,9 @@
1
1
  import React, { useContext } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
- import EditableSettingsList from './EditableSettingsList';
5
- import SettingsContext from './SettingsContext';
6
- import useSettingSection from './useSettingSection';
4
+ import { EditableSettingsList } from '../EditableSettingsList';
5
+ import { SettingsContext } from '../contexts';
6
+ import { useSettingSection } from '../hooks';
7
7
 
8
8
  const SettingPage = ({ sectionName }) => {
9
9
  const { settingEndpoint } = useContext(SettingsContext);
@@ -31,10 +31,10 @@ SettingPage.propTypes = {
31
31
  sectionName: PropTypes.string,
32
32
  resources: PropTypes.shape({
33
33
  settings: PropTypes.shape({
34
- records: PropTypes.array
34
+ records: PropTypes.arrayOf(PropTypes.object)
35
35
  }),
36
36
  refdatavalues: PropTypes.shape({
37
- records: PropTypes.array
37
+ records: PropTypes.arrayOf(PropTypes.object)
38
38
  })
39
39
  })
40
40
  };
@@ -1,8 +1,10 @@
1
1
  import React, { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
2
4
  import { Pane } from '@folio/stripes/components';
3
5
  import { FormattedMessage } from 'react-intl';
4
- import SettingsContext from './SettingsContext';
5
- import { toCamelCase } from './utils';
6
+ import { SettingsContext } from '../contexts';
7
+ import { toCamelCase } from '../utils';
6
8
 
7
9
  const SettingPagePane = ({ sectionName, children }) => {
8
10
  const { intlKey } = useContext(SettingsContext);
@@ -18,4 +20,12 @@ const SettingPagePane = ({ sectionName, children }) => {
18
20
  );
19
21
  };
20
22
 
23
+ SettingPagePane.propTypes = {
24
+ sectionName: PropTypes.string,
25
+ children: PropTypes.oneOfType([
26
+ PropTypes.func,
27
+ PropTypes.node
28
+ ])
29
+ };
30
+
21
31
  export default SettingPagePane;
@@ -0,0 +1,2 @@
1
+ export { default as SettingPagePane } from './SettingPagePane';
2
+ export { default as SettingPage } from './SettingPage';
@@ -1,115 +1 @@
1
- ```
2
- import React from 'react';
3
-
4
- import { Button, Col, Pane, Row, TextField } from '@folio/stripes/components';
5
- import { AppIcon } from '@folio/stripes/core';
6
- import { generateKiwtQuery, TypeDown } from '@k-int/stripes-kint-components';
7
-
8
- import { Form, Field, useFormState } from 'react-final-form';
9
-
10
- const TestField = () => {
11
- const pathMutator = (input, path) => {
12
- const query = generateKiwtQuery(
13
- {
14
- searchKey: 'name,alternateNames.name',
15
- stats: false
16
- }, {
17
- sort: 'name',
18
- query: input,
19
- }
20
- );
21
-
22
- return `${path}${query}`;
23
- };
24
-
25
- console.log("Current values: %o", useFormState()?.values)
26
- return (
27
- <Field
28
- component={TypeDown}
29
- name="test"
30
- path="erm/sas"
31
- pathMutator={pathMutator}
32
- renderFooter={() => (
33
- <>
34
- <Button
35
- id="footer button 1"
36
- marginBottom0
37
- onClick={() => {
38
- alert('sup')
39
- }}
40
- type="button"
41
- >
42
- Hello 1
43
- </Button>
44
- <Button
45
- id="footer button 2"
46
- marginBottom0
47
- onClick={() => {
48
- alert('sup 2')
49
- }}
50
- type="button"
51
- >
52
- Hello 2
53
- </Button>
54
- </>
55
- )}
56
- renderListItem={agreement => {
57
- return (
58
- <>
59
- <AppIcon
60
- app="agreements"
61
- size="small"
62
- >
63
- {agreement.name}
64
- </AppIcon>
65
- </>
66
- );
67
- }}
68
- />
69
- );
70
- };
71
-
72
-
73
- const TestComponent = () => {
74
- return (
75
- <Pane
76
- defaultWidth="fill"
77
- dismissible
78
- id="test-typedown"
79
- paneTitle={"Test typedown"}
80
- >
81
- <Form
82
- enableReinitialize
83
- navigationCheck
84
- onSubmit={(values) => console.log("submitting: %o", values)}
85
- subscription={{ values: true }}
86
- >
87
- {({ handleSubmit }) => {
88
- return (
89
- <form onSubmit={handleSubmit}>
90
- <Row>
91
- <Col xs={6}>
92
- <TestField />
93
- </Col>
94
- <Col xs={6}>
95
- <Field
96
- component={TextField}
97
- name="test2"
98
- />
99
- </Col>
100
- </Row>
101
- <Button
102
- type="submit"
103
- >
104
- submit
105
- </Button>
106
- </form>
107
- );
108
- }}
109
- </Form>
110
- </Pane>
111
- );
112
- };
113
-
114
- export default TestComponent;
115
- ```
1
+ DEPRECATED - DO NOT USE. You probably want Typedown
@@ -30,6 +30,7 @@ const TypeDown = ({
30
30
  }) => {
31
31
  useEffect(() => {
32
32
  if (process.env.NODE_ENV === 'development') {
33
+ // eslint-disable-next-line no-console
33
34
  console.warn('TypeDown component is deprecated, you likely want either Typedown or QueryTypedown');
34
35
  }
35
36
  }, []);
@@ -71,13 +72,13 @@ const TypeDown = ({
71
72
  </div>
72
73
  ), [renderListItem, uniqueIdentificationPath]);
73
74
 
74
- const handleChange = value => {
75
+ const handleChange = useCallback(value => {
75
76
  input.onChange(value);
76
77
 
77
78
  if (typeof onChange === 'function') {
78
79
  onChange(value);
79
80
  }
80
- };
81
+ }, [input, onChange]);
81
82
 
82
83
  const dropDown = useCallback(() => {
83
84
  return (
@@ -132,6 +133,7 @@ const TypeDown = ({
132
133
  }, [
133
134
  data,
134
135
  footerRef,
136
+ handleChange,
135
137
  handleNextFocus,
136
138
  input,
137
139
  listKeyDownHandler,
@@ -131,7 +131,7 @@ const Typedown = ({
131
131
  <div
132
132
  ref={footerRef}
133
133
  className={css.footer}
134
- id="typedown-footer"
134
+ id={`typedown-footer-${selectorSafe(input.name)}`}
135
135
  >
136
136
  {renderFooter()}
137
137
  </div>
@@ -222,6 +222,7 @@ const Typedown = ({
222
222
 
223
223
  Typedown.propTypes = {
224
224
  dataOptions: PropTypes.arrayOf(PropTypes.object),
225
+ filterPath: PropTypes.string,
225
226
  input: PropTypes.object,
226
227
  meta: PropTypes.object,
227
228
  onChange: PropTypes.func,
@@ -1,4 +1,4 @@
1
- import React, { createContext } from 'react';
1
+ import { createContext } from 'react';
2
2
 
3
3
  const SettingsContext = createContext();
4
4
  export default SettingsContext;
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export { default as SettingsContext } from './SettingsContext';
@@ -21,6 +21,7 @@ endpoint | string | The endpoint to fetch refdataValues from | | ✓ |
21
21
  desc | string | The refdataCategory (usually of the form `DomainClass.Field`) | | ✕ |
22
22
  queryParams | object | A set of queryParameters to hand to react-query's `useQuery` | | ✕ |
23
23
  returnQueryObject | bool | A switch to return the entirety of the queryObject from useQuery. If `false`, the data will be destructured, if `true` the return will be the full object returned by react-query's `useQuery` | false | ✕ |
24
+ options | object | An object of the shape SASQ_MAP (See generateKiwtQuery) to pass to the generateKiwtQuery inside. Any passed desc "d" will be passed as a filter `DescKey.${d}`, with DescKey acting as FilterName, assuming `filterKeys: { DescKey: "desc" }` in options, so `desc==${d}` is passed directly to the backend. | `{filterKeys: {DescKey: "desc" }, stats: false, max: 100}` | ✕ |
24
25
 
25
26
  ## useMutateRefdataValue
26
27
  A hook for mutations (Create/Delete/Edit) of refdataValues.
@@ -117,6 +118,8 @@ A hook which takes an object containing various helper components to render, and
117
118
  When the url contains a query of the form `helper={name}`, this hook will check the helpers object it was handed for a key matching `{name}`, and if there is one it will return the component value for that key.
118
119
 
119
120
  The hook also returns an object `helperToggleFunctions`, which will have the same keys as were handed to the hook, and values corresponding to "toggle" functions for that key. These functions are a simple way to change the helper query in the url.
121
+
122
+ Finally the hook also returns an ease-of-use function `isOpen`, which takes a string input and returns a boolean if the current helper in the URL matches that string or not.
120
123
  ### Basic usage
121
124
  ```
122
125
  import { useHelperApp } from '@k-int/stripes-kint-components'
@@ -181,3 +184,107 @@ import { useQuery } from 'react-query';
181
184
  </SearchAndSortQuery>
182
185
 
183
186
  ```
187
+
188
+ ## useQIndex
189
+ A hook with a similar API to setState, but instead stores a value in the `qindex` parameter in the URL.
190
+ Returns an array `[qindex, setQindex]`. There is no way to set an initialValue with the hook, as the state is derived from the URL rather than the other way around. This means that multiple `useQIndex` hooks can exist at once.
191
+
192
+ ### BasicUsage
193
+ ```
194
+ import {
195
+ Button,
196
+ } from '@folio/stripes/components';
197
+ import useQindex from '../../../../stripes-kint-components/src/lib/hooks/useQIndex';
198
+
199
+ const Test() {
200
+ const [qindex, setQindex] = useQindex();
201
+
202
+ return (
203
+ <>
204
+ <Button
205
+ onClick={() => setQindex(qindex + "1")}
206
+ >
207
+ change the qindex
208
+ </Button>
209
+ <div>
210
+ {`The current qindex is: ${qindex}`
211
+ </div>
212
+ </>
213
+ );
214
+ }
215
+
216
+ export default Test;
217
+ ```
218
+
219
+ ## useKiwtFieldArray
220
+ A hook to replace `withKiwtFieldArray` [from stripes-erm-components](https://github.com/folio-org/stripes-erm-components/tree/master/lib/withKiwtFieldArray). Provides functions for adding and deleting items in a way which the backend endpoints will understand, as well as an "items" array to track the current set of valid items in the form.
221
+
222
+
223
+ ### BasicUsage
224
+ ```
225
+ ...
226
+ import useKiwtFieldArray from '../../../util/useKiwtFieldArray';
227
+ ...
228
+
229
+ const TestFieldArray = () => {
230
+ const {
231
+ items,
232
+ onAddField,
233
+ onDeleteField
234
+ } = useKiwtFieldArray(name, true);
235
+
236
+ return (
237
+ <>
238
+ {items.map((item, index) => {
239
+ return (
240
+ <Row>
241
+ <Col xs={3}>
242
+ <Field
243
+ name={`${name}[${index}].name`}
244
+ component={TextField}
245
+ required
246
+ validate={requiredValidator}
247
+ />
248
+ </Col>
249
+ <Col xs={1}>
250
+ <IconButton
251
+ icon="trash"
252
+ id="remove-volume-button"
253
+ onClick={() => onDeleteField(index, volume)}
254
+ />
255
+ </Col>
256
+ </Row>
257
+ );
258
+ })}
259
+ <Button
260
+ onClick={() => onAddField({}})}
261
+ >
262
+ ADD NEW
263
+ </Button>
264
+ </>
265
+ );
266
+ };
267
+
268
+ const Test = ({}) => {
269
+ return (
270
+ <Form
271
+ ...
272
+ render={({ handleSubmit, submitting, form }) => (
273
+ <form onSubmit={handleSubmit}>
274
+ <FieldArray
275
+ name="test"
276
+ component={TestFieldArray}
277
+ />
278
+ </form>
279
+ )}
280
+ />
281
+ );
282
+ };
283
+ export default Test
284
+ ```
285
+
286
+ ### Props
287
+ Name | Type | Description | default | required
288
+ --- | --- | --- | --- | ---
289
+ name | String | The name of the fieldArray, used to hook into the final form state for that field. | | ✓ |
290
+ submitWholeDeletedObject | bool | a boolean flag to ensure that a deleted object is sent whole to the backend, rather than just as an id. | false | ✕ |
@@ -5,3 +5,6 @@ export { default as useActiveElement } from './useActiveElement';
5
5
  export { default as useKiwtSASQuery } from './useKiwtSASQuery';
6
6
  export { default as useHelperApp } from './useHelperApp';
7
7
  export { default as useLocalStorageState } from './useLocalStorageState';
8
+ export { default as useQIndex } from './useQIndex';
9
+ export { useSettings, useSettingSection } from './settingsHooks';
10
+ export { default as useKiwtFieldArray } from './useKiwtFieldArray';
@@ -0,0 +1,2 @@
1
+ export { default as useSettings } from './useSettings';
2
+ export { default as useSettingSection } from './useSettingSection';
@@ -1,15 +1,16 @@
1
1
  import React, { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
2
4
  import { useQuery } from 'react-query';
3
5
  import { FormattedMessage, useIntl } from 'react-intl';
4
6
  import { useOkapiKy } from '@folio/stripes/core';
5
7
 
6
8
  import { Settings } from '@folio/stripes/smart-components';
7
9
 
8
- import SettingPage from './SettingPage';
9
- import SettingPagePane from './SettingPagePane';
10
- import SettingsContext from './SettingsContext';
10
+ import { SettingPage, SettingPagePane } from '../../SettingPage';
11
+ import { SettingsContext } from '../../contexts';
11
12
 
12
- import { sortByLabel, toCamelCase } from './utils';
13
+ import { sortByLabel, toCamelCase } from '../../utils';
13
14
 
14
15
  const useSettings = ({
15
16
  dynamicPageExclusions,
@@ -21,7 +22,7 @@ const useSettings = ({
21
22
  }) => {
22
23
  const ky = useOkapiKy();
23
24
  const intl = useIntl();
24
- const extraPathItems = dynamicPageExclusions.map(dpe => `filters=section!=${dpe}`)
25
+ const extraPathItems = dynamicPageExclusions.map(dpe => `filters=section!=${dpe}`);
25
26
  extraPathItems.push('max=500');
26
27
 
27
28
  const { data: appSettings = [], isLoading } = useQuery(
@@ -50,7 +51,7 @@ const useSettings = ({
50
51
  );
51
52
  });
52
53
 
53
- const pageList = persistentPages.concat(dynamic).sort(sortByLabel)
54
+ const pageList = persistentPages.concat(dynamic).sort(sortByLabel);
54
55
 
55
56
  const SettingsContextProvider = ({ children }) => {
56
57
  return (
@@ -67,6 +68,13 @@ const useSettings = ({
67
68
  );
68
69
  };
69
70
 
71
+ SettingsContextProvider.propTypes = {
72
+ children: PropTypes.oneOfType([
73
+ PropTypes.func,
74
+ PropTypes.node
75
+ ])
76
+ };
77
+
70
78
  const SettingsComponent = (props) => {
71
79
  const settingsData = useContext(SettingsContext);
72
80
 
@@ -1,6 +1,3 @@
1
1
  export { default as useTypedown } from './useTypedown';
2
- export { default as useTypedownFooter } from './useTypedownFooter';
3
- export { default as useTypedownList } from './useTypedownList';
4
- export { default as useTypedownSearchField } from './useTypedownSearchField';
5
2
  export { default as useTypedownToggle } from './useTypedownToggle';
6
3
  export { default as useTypedownData } from './useTypedownData';
@@ -1,19 +1,22 @@
1
1
  import { useRef } from 'react';
2
2
  import { useResizeDetector } from 'react-resize-detector';
3
3
 
4
- // TODO swap to stripes-components export once available (Will need <= peer dep bump)
5
4
  import {
5
+ getFirstFocusable,
6
+ getLastFocusable,
6
7
  getNextFocusable,
7
- } from '../../utils/getFocusableElements';
8
+ getPreviousFocusable,
9
+ } from '@folio/stripes/components';
10
+
11
+ import {
12
+ DOWN_ARROW,
13
+ TAB,
14
+ UP_ARROW
15
+ } from '../../constants/eventCodes';
8
16
 
9
17
  import selectorSafe from '../../utils/selectorSafe';
10
18
 
11
- import {
12
- useTypedownToggle,
13
- useTypedownFooter,
14
- useTypedownSearchField,
15
- useTypedownList
16
- } from '.';
19
+ import useTypedownToggle from './useTypedownToggle';
17
20
 
18
21
  const useTypedown = (name) => {
19
22
  // SEARCHFIELD COMPONENT
@@ -23,11 +26,90 @@ const useTypedown = (name) => {
23
26
  const listRef = useRef();
24
27
  const triggerRef = useRef();
25
28
  const overlayRef = useRef();
26
- const footerRef = useTypedownFooter(searchFieldComponent);
29
+ const footerRef = useRef();
30
+
31
+ const footer = document.getElementById(`typedown-footer-${selectorSafe(name)}`);
32
+ // Add an event listener to the footer, so that we can control tab behaviour between footer elements
33
+
34
+ if (footer && footer.getAttribute('hasListener') !== 'true') {
35
+ footer.addEventListener('keydown', e => {
36
+ // We want special behaviour on tab
37
+ if (e.code === TAB) {
38
+ // Prevent the default behaviour
39
+ e.preventDefault();
40
+ const focusFunc = e.shiftKey ? getPreviousFocusable : getNextFocusable;
41
+ const elem = focusFunc(footerRef.current, true, true, false, true);
42
+
43
+ if (elem) {
44
+ // Focus on next focusable element
45
+ elem.focus();
46
+ } else if (e.shiftKey) {
47
+ // We are at the beginning of the list, refocus on search bar
48
+ searchFieldComponent.focus();
49
+ } else {
50
+ // We are at the end of the list, move onto next focusable element in page
51
+ getNextFocusable(searchFieldComponent, false).focus();
52
+ }
53
+ }
54
+ });
55
+
56
+ footer.setAttribute('hasListener', 'true');
57
+ }
27
58
 
28
59
  // SET UP HANDLERS
29
- const searchFieldKeyDownHandler = useTypedownSearchField(listRef, footerRef, searchFieldComponent);
30
- const listKeyDownHandler = useTypedownList(listRef, footerRef, searchFieldComponent);
60
+ const searchFieldKeyDownHandler = e => {
61
+ if (e.code === UP_ARROW) {
62
+ const elem = getLastFocusable(listRef.current, true, true);
63
+ if (elem) {
64
+ elem.focus();
65
+ }
66
+ }
67
+
68
+ if (e.code === DOWN_ARROW) {
69
+ const elem = getFirstFocusable(listRef.current, true, true);
70
+ if (elem) {
71
+ elem.focus();
72
+ }
73
+ }
74
+
75
+ // Tab key (But not while shifting)
76
+ if (e.code === TAB && !e.shiftKey) {
77
+ e.preventDefault();
78
+ // If we have focusable elements in the footer, then focus on them, else unfocus searchbar
79
+ const elem = getNextFocusable(footerRef.current, true, true, true, true);
80
+ if (elem) {
81
+ elem.focus();
82
+ } else {
83
+ getNextFocusable(searchFieldComponent, false).focus();
84
+ }
85
+ }
86
+ };
87
+
88
+ const listKeyDownHandler = e => {
89
+ if (e.code === DOWN_ARROW) {
90
+ const elem = getNextFocusable(listRef.current, true, true);
91
+ elem.focus();
92
+ }
93
+
94
+ if (e.code === UP_ARROW) {
95
+ const elem = getPreviousFocusable(listRef.current, true, true);
96
+ elem.focus();
97
+ }
98
+
99
+ if (e.code === TAB) {
100
+ e.preventDefault();
101
+ let elem;
102
+ if (!e.shiftKey && !footerRef.current) {
103
+ elem = getNextFocusable(searchFieldComponent, false);
104
+ } else if (!e.shiftKey) {
105
+ elem = getNextFocusable(footerRef.current, true, true, true, true);
106
+ } else {
107
+ elem = searchFieldComponent;
108
+ }
109
+ elem.focus();
110
+ }
111
+ };
112
+
31
113
  const handleNextFocus = () => getNextFocusable(searchFieldComponent, false).focus();
32
114
 
33
115
  // SET UP VARIABLES
@@ -13,6 +13,10 @@ const useHelperApp = (helpers) => {
13
13
  setCurrentHelper(helper !== currentHelper ? helper : undefined);
14
14
  }, [currentHelper]);
15
15
 
16
+ const isOpen = (hlp) => {
17
+ return currentHelper === hlp;
18
+ };
19
+
16
20
  useEffect(() => {
17
21
  if (currentHelper !== query?.helper) {
18
22
  const newQuery = {
@@ -56,7 +60,7 @@ const useHelperApp = (helpers) => {
56
60
  helperToggleFunctions[h] = () => handleToggleHelper(h);
57
61
  });
58
62
 
59
- return { HelperComponent, helperToggleFunctions };
63
+ return { HelperComponent, helperToggleFunctions, isOpen };
60
64
  };
61
65
 
62
66
  export default useHelperApp;
@@ -0,0 +1,63 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { useFieldArray } from 'react-final-form-arrays';
3
+
4
+ const useKiwtFieldArray = (name, submitWholeDeletedObject = false) => {
5
+ const { fields } = useFieldArray(name);
6
+ const { value: values = [] } = fields;
7
+ const [endOfList, setEndOfList] = useState(0);
8
+
9
+ useEffect(() => {
10
+ const i = values.filter(line => !line._delete);
11
+ setEndOfList(i.length);
12
+ }, [values]);
13
+
14
+ const onAddField = (field = { _delete: false }) => {
15
+ fields.insert(endOfList, field);
16
+ };
17
+
18
+ const onMarkForDeletion = (field) => {
19
+ if (field && field.id) {
20
+ if (submitWholeDeletedObject) {
21
+ fields.push({ ...field, _delete: true });
22
+ } else {
23
+ fields.push({ id: field.id, _delete: true });
24
+ }
25
+ }
26
+ };
27
+
28
+ const onDeleteField = (index, field) => {
29
+ fields.remove(index);
30
+ onMarkForDeletion(field);
31
+ };
32
+
33
+ const onPrependField = (field = { _delete: false }) => {
34
+ fields.unshift(field);
35
+ };
36
+
37
+ const onReplaceField = (index, field) => {
38
+ if (fields.update) { // react-final-form-arrays
39
+ fields.update(index, field);
40
+ }
41
+ };
42
+
43
+ const onUpdateField = (index, field) => {
44
+ fields.update(index, {
45
+ ...fields.value[index],
46
+ ...field,
47
+ });
48
+ };
49
+
50
+ const items = values.slice(0, endOfList);
51
+
52
+ return {
53
+ items,
54
+ onAddField,
55
+ onDeleteField,
56
+ onMarkForDeletion,
57
+ onPrependField,
58
+ onReplaceField,
59
+ onUpdateField,
60
+ };
61
+ };
62
+
63
+ export default useKiwtFieldArray;
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
2
2
  import { useLocation, useHistory } from 'react-router-dom';
3
3
 
4
4
  import buildUrl from '../utils/buildUrl';
5
+ import useQindex from './useQIndex';
5
6
 
6
7
  const locationQuerySetter = ({ location, history, nsValues }) => {
7
8
  const url = buildUrl(location, nsValues);
@@ -13,8 +14,15 @@ const useKiwtSASQuery = () => {
13
14
  const location = useLocation();
14
15
  const [query, setQuery] = useState({});
15
16
  const queryGetter = () => query;
17
+
18
+ const [qindex] = useQindex();
19
+ // Ensure we update the query along with the querySetter
20
+ if (query.qindex !== qindex) {
21
+ setQuery({ ...query, qindex });
22
+ }
23
+
16
24
  const querySetter = ({ nsValues }) => {
17
- setQuery(nsValues);
25
+ setQuery({ ...query, ...nsValues, qindex });
18
26
  locationQuerySetter({ location, history, nsValues });
19
27
  };
20
28
  return { query, queryGetter, querySetter };