@k-int/stripes-kint-components 5.2.3 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/es/index.js +8 -0
  3. package/es/lib/ActionList/ActionListFieldArray.js +61 -43
  4. package/es/lib/ComboButton/ComboButton.js +6 -5
  5. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +7 -4
  6. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +32 -30
  7. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +58 -58
  8. package/es/lib/CustomProperties/Config/CustomPropertyForm.test.js +2 -2
  9. package/es/lib/CustomProperties/Config/CustomPropertyView.js +33 -32
  10. package/es/lib/CustomProperties/Config/CustomPropertyView.test.js +1 -1
  11. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +1 -1
  12. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +3 -3
  13. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +10 -5
  14. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +25 -19
  15. package/es/lib/CustomProperties/Edit/CustomPropertyField.test.js +5 -5
  16. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +2 -2
  17. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +1 -1
  18. package/es/lib/CustomProperties/Edit/testResources.js +12 -11
  19. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +11 -7
  20. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +28 -20
  21. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +1 -1
  22. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +6 -6
  23. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +8 -8
  24. package/es/lib/CustomProperties/Filter/testResources.js +2 -1
  25. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +2 -1
  26. package/es/lib/CustomProperties/View/CustomPropertiesView.js +1 -1
  27. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +26 -19
  28. package/es/lib/CustomProperties/View/CustomPropertyCard.js +11 -7
  29. package/es/lib/CycleButton/CycleButton.js +1 -1
  30. package/es/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +82 -29
  31. package/es/lib/EditableRefdataList/EditableRefdataList.js +33 -27
  32. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +1 -1
  33. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.js +5 -6
  34. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.js +12 -10
  35. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +0 -1
  36. package/es/lib/EditableSettingsList/SettingField/SettingField.js +4 -4
  37. package/es/lib/FormattedKintMessage/FormattedKintMessage.js +7 -4
  38. package/es/lib/IconSelect/IconSelect.js +9 -5
  39. package/es/lib/NoResultsMessage/NoResultsMessage.js +4 -4
  40. package/es/lib/RefdataButtons/RefdataButtons.js +3 -3
  41. package/es/lib/RefdataCategoriesSettings/RefdataCategoriesSettings.js +158 -0
  42. package/es/lib/RefdataCategoriesSettings/index.js +13 -0
  43. package/es/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +28 -21
  44. package/es/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +6 -5
  45. package/es/lib/RichSelect/RichSelect.js +19 -14
  46. package/es/lib/RichSelect/useSelectedOption.js +2 -1
  47. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +17 -14
  48. package/es/lib/SASQLookupComponent/TableBody/TableBody.js +6 -4
  49. package/es/lib/SASQRoute/SASQRoute.js +2 -2
  50. package/es/lib/SASQViewComponent/SASQViewComponent.js +9 -5
  51. package/es/lib/SettingPage/SettingPagePane.js +2 -2
  52. package/es/lib/SettingsFormContainer/SettingsFormContainer.js +2 -3
  53. package/es/lib/Typedown/Typedown.js +26 -20
  54. package/es/lib/hooks/__mocks__/index.js +4 -0
  55. package/es/lib/hooks/index.js +7 -0
  56. package/es/lib/hooks/typedownHooks/useTypedown.js +2 -2
  57. package/es/lib/hooks/typedownHooks/useTypedownToggle.js +2 -2
  58. package/es/lib/hooks/useActionListRef.js +34 -0
  59. package/es/lib/hooks/useActiveElement.js +1 -1
  60. package/es/lib/hooks/useCustomProperties.js +2 -2
  61. package/es/lib/hooks/useHelperApp.js +6 -6
  62. package/es/lib/hooks/useIntlKeyStore.js +7 -4
  63. package/es/lib/hooks/useKintIntl.js +11 -5
  64. package/es/lib/hooks/useKiwtSASQuery.js +1 -1
  65. package/es/lib/hooks/useModConfigEntries.js +2 -2
  66. package/es/lib/hooks/useMutateCustomProperties.js +8 -8
  67. package/es/lib/hooks/useMutateModConfigEntry.js +2 -2
  68. package/es/lib/hooks/useMutateRefdataCategory.js +4 -4
  69. package/es/lib/hooks/useMutateRefdataValue.js +6 -6
  70. package/es/lib/hooks/useQIndex.js +17 -9
  71. package/es/lib/hooks/useRefdata.js +3 -3
  72. package/es/lib/hooks/useTemplates.js +4 -4
  73. package/es/lib/settingsHooks/useAppSettings.js +11 -7
  74. package/es/lib/settingsHooks/useSettingSection.js +2 -2
  75. package/es/lib/settingsHooks/useSettings.js +3 -3
  76. package/es/lib/utils/buildUrl.js +3 -2
  77. package/es/lib/utils/filterParsers/deparseKiwtQueryFilters.js +5 -5
  78. package/es/lib/utils/filterParsers/parseKiwtQueryFilters.js +2 -2
  79. package/es/lib/utils/filterParsers/parseKiwtQueryGroups.js +5 -4
  80. package/es/lib/utils/filterParsers/parseKiwtQueryString.js +3 -2
  81. package/es/lib/utils/generateKiwtQueryParams.js +37 -28
  82. package/es/lib/utils/groupCustomPropertiesByCtx.js +3 -2
  83. package/es/lib/utils/matchString.js +1 -1
  84. package/es/lib/utils/parseErrorResponse.js +3 -2
  85. package/es/lib/utils/parseModConfigEntry.js +0 -1
  86. package/es/lib/utils/selectorSafe.js +3 -2
  87. package/es/lib/utils/sortByLabel.js +3 -2
  88. package/es/lib/validators/validators.js +3 -3
  89. package/package.json +1 -1
  90. package/src/index.js +3 -0
  91. package/src/lib/ActionList/ActionListFieldArray.js +29 -15
  92. package/src/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +67 -13
  93. package/src/lib/RefdataCategoriesSettings/RefdataCategoriesSettings.js +176 -0
  94. package/src/lib/RefdataCategoriesSettings/index.js +1 -0
  95. package/src/lib/hooks/__mocks__/index.js +4 -0
  96. package/src/lib/hooks/index.js +1 -0
  97. package/src/lib/hooks/useActionListRef.js +36 -0
  98. package/src/lib/hooks/useQIndex.js +12 -4
@@ -0,0 +1,176 @@
1
+ import { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import { Button, Col, KeyValue, Pane, PaneHeader, PaneMenu, Row } from '@folio/stripes/components';
5
+
6
+ import { useActionListRef, useKintIntl } from '../hooks';
7
+
8
+ import EditableRefdataCategoryList from '../EditableRefdataCategoryList';
9
+ import EditableRefdataList from '../EditableRefdataList';
10
+ import FormattedKintMessage from '../FormattedKintMessage';
11
+
12
+
13
+ const propTypes = {
14
+ afterQueryCalls: PropTypes.object,
15
+ catchQueryCalls: PropTypes.object,
16
+ displayConditions: PropTypes.shape({
17
+ create: PropTypes.bool,
18
+ delete: PropTypes.bool,
19
+ view: PropTypes.bool,
20
+ }),
21
+ intlKey: PropTypes.string,
22
+ intlNS: PropTypes.string,
23
+ label: PropTypes.oneOfType([
24
+ PropTypes.string,
25
+ PropTypes.node
26
+ ]),
27
+ labelOverrides: PropTypes.object,
28
+ onClose: PropTypes.func,
29
+ refdataEndpoint: PropTypes.string
30
+ };
31
+
32
+ const RefdataCategoriesSettings = ({
33
+ /*
34
+ * Set of extra booleans for controlling access to actions
35
+ * create/delete (View should be handled externally)
36
+ * This will not overwrite "internal" behaviour, ie setting
37
+ * delete to 'true' here would still not render a delete button
38
+ * for a refdata category that has refdata values.
39
+ */
40
+ displayConditions = {
41
+ create: true,
42
+ delete: true,
43
+ edit: true
44
+ },
45
+ intlKey: passedIntlKey,
46
+ intlNS: passedIntlNS,
47
+ labelOverrides = {}, // An object containing translation alternatives
48
+ onClose,
49
+ refdataEndpoint
50
+ }) => {
51
+ /* A component that allows for editing of refdata categories */
52
+ const [refdataCategory, setRefdataCategory] = useState();
53
+ const [refState, rdclRef, passedRef] = useActionListRef();
54
+
55
+ const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
56
+
57
+ const handleRefdataCategoryClick = (rc) => {
58
+ setRefdataCategory(rc);
59
+ };
60
+
61
+ const pickListValuesLabel = kintIntl.formatKintMessage({
62
+ id: 'settings.pickListValues',
63
+ overrideValue: labelOverrides?.pickListValues
64
+ });
65
+
66
+ const renderViewPaneHeader = renderProps => (
67
+ <PaneHeader
68
+ {...renderProps}
69
+ dismissible
70
+ onClose={() => setRefdataCategory()}
71
+ paneTitle={
72
+ kintIntl.formatKintMessage(
73
+ {
74
+ id: 'refdataCategories.config.viewPaneTitle',
75
+ overrideValue: labelOverrides?.viewPaneTitle,
76
+ fallbackMessage: refdataCategory?.desc,
77
+ },
78
+ {
79
+ name: refdataCategory?.desc,
80
+ }
81
+ )
82
+ }
83
+ />
84
+ );
85
+
86
+ const renderLookupPaneHeader = renderProps => (
87
+ <PaneHeader
88
+ {...renderProps}
89
+ dismissible
90
+ lastMenu={
91
+ <PaneMenu>
92
+ <Button
93
+ disabled={!!refState?.editing}
94
+ marginBottom0
95
+ onClick={() => rdclRef?.current?.create()}
96
+ >
97
+ <FormattedKintMessage id="new" />
98
+ </Button>
99
+ </PaneMenu>
100
+ }
101
+ onClose={onClose}
102
+ paneTitle={kintIntl.formatKintMessage({
103
+ id: 'settings.pickLists',
104
+ overrideValue: labelOverrides?.pickLists
105
+ })}
106
+ />
107
+ );
108
+
109
+ return (
110
+ <>
111
+ <Pane
112
+ defaultWidth="fill"
113
+ id="edit-refdata-desc"
114
+ renderHeader={renderLookupPaneHeader}
115
+ >
116
+ <EditableRefdataCategoryList
117
+ ref={passedRef}
118
+ afterQueryCalls={{
119
+ post: (json) => { setRefdataCategory(json); }
120
+ }}
121
+ displayConditions={displayConditions}
122
+ handleRefdataCategoryClick={handleRefdataCategoryClick}
123
+ hideCreateButton
124
+ onConfirmDelete={(id) => {
125
+ if (refdataCategory?.id === id) {
126
+ setRefdataCategory();
127
+ }
128
+ }}
129
+ refdataEndpoint={refdataEndpoint}
130
+ />
131
+ </Pane>
132
+ {refdataCategory?.desc &&
133
+ <Pane
134
+ defaultWidth="fill"
135
+ id="settings-refdataCategories-viewPane"
136
+ renderHeader={renderViewPaneHeader}
137
+ >
138
+ <Row>
139
+ <Col xs={8}>
140
+ <KeyValue
141
+ label={kintIntl.formatKintMessage({
142
+ id: 'refdataCategory.refdataCategory',
143
+ overrideValue: labelOverrides?.refdataCategory
144
+ })}
145
+ value={refdataCategory.desc}
146
+ />
147
+ </Col>
148
+ <Col xs={4}>
149
+ <KeyValue
150
+ label={kintIntl.formatKintMessage({
151
+ id: 'refdataCategory.noOfValues',
152
+ overrideValue: labelOverrides?.noOfValues
153
+ })}
154
+ value={refdataCategory?.values?.length}
155
+ />
156
+ </Col>
157
+ </Row>
158
+ <EditableRefdataList
159
+ afterQueryCalls={{
160
+ put: json => setRefdataCategory(json),
161
+ delete: (json) => setRefdataCategory(json)
162
+ }}
163
+ desc={refdataCategory?.desc}
164
+ displayConditions={displayConditions}
165
+ label={pickListValuesLabel}
166
+ refdataEndpoint={refdataEndpoint}
167
+ />
168
+ </Pane>
169
+ }
170
+ </>
171
+ );
172
+ };
173
+
174
+ RefdataCategoriesSettings.propTypes = propTypes;
175
+
176
+ export default RefdataCategoriesSettings;
@@ -0,0 +1 @@
1
+ export { default } from './RefdataCategoriesSettings';
@@ -3,11 +3,15 @@ import customProperties from '../../../../test/jest/customProperties';
3
3
 
4
4
  import useKintIntl from '../useKintIntl';
5
5
 
6
+ /* EXAMPLE Grab actual hooks for anything not mocked here */
7
+ const hooks = jest.requireActual('../index');
8
+
6
9
  // We have to do this up here too so that our passed useKintIntl
7
10
  // ALSO has a mocked useIntlKeyStore... I think anyway
8
11
  jest.mock('../useIntlKeyStore', () => () => () => 'ui-test-implementor');
9
12
 
10
13
  module.exports = {
14
+ ...hooks,
11
15
  useRefdata: () => refdata,
12
16
  useTemplates: () => [], // We should set up some templates to test this properly
13
17
  useCustomProperties: () => ({ data: customProperties, isLoading: false }),
@@ -17,3 +17,4 @@ export { default as useIntlKey } from './useIntlKey';
17
17
  export { default as useSASQQueryMeta } from './useSASQQueryMeta';
18
18
  export { default as useModConfigEntries } from './useModConfigEntries';
19
19
  export { default as useMutateModConfigEntry } from './useMutateModConfigEntry';
20
+ export { default as useActionListRef } from './useActionListRef';
@@ -0,0 +1,36 @@
1
+ import {
2
+ useCallback,
3
+ useMemo,
4
+ useRef,
5
+ useState
6
+ } from 'react';
7
+
8
+ // Using the passed actionListRef in a stateful way
9
+ // is somewhat complicated, so here's a hook to simplify that work
10
+ const useActionListRef = () => {
11
+ const actionListRef = useRef();
12
+ const [editing, setEditing] = useState();
13
+
14
+ const passedRef = useCallback(node => {
15
+ // All functions must be present on here
16
+ actionListRef.current = node;
17
+ if (node?.editing) {
18
+ setEditing(node.editing);
19
+ } else {
20
+ setEditing();
21
+ }
22
+ }, []);
23
+
24
+ // We don't need this for actionListRef, but it serves as an example for building a stateful ref object (sans functions)
25
+ const refState = useMemo(() => ({
26
+ editing
27
+ }), [editing]);
28
+
29
+ return [
30
+ refState, // This is a state containing up to date "editing" state from within ActionList
31
+ actionListRef, // This is the ref which will contain the create function
32
+ passedRef // This is the ref to pass to ActionList
33
+ ];
34
+ };
35
+
36
+ export default useActionListRef;
@@ -12,10 +12,18 @@ const useQIndex = () => {
12
12
  const handleQindexChange = (newQindex) => {
13
13
  setCurrentQindex(newQindex);
14
14
  if (newQindex !== query?.qindex) {
15
- const newQuery = {
16
- ...query,
17
- qindex: newQindex
18
- };
15
+ let newQuery;
16
+ if (newQindex !== '') {
17
+ newQuery = {
18
+ ...query,
19
+ qindex: newQindex
20
+ };
21
+ } else {
22
+ newQuery = {
23
+ ...query,
24
+ qindex: undefined
25
+ };
26
+ }
19
27
 
20
28
  history.push({
21
29
  pathname: location.pathname,