@k-int/stripes-kint-components 5.24.1 → 5.25.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [5.25.1](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.25.0...v5.25.1) (2025-08-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deprecationWarnings:** Add deprecation warnings to mod-config hooks and components ([716b3cf](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/716b3cf999635dc8e01ef19afeab043012d63907))
7
+ * **deps:** update dependency zustand to v5 ([bfd0134](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/bfd013486176db77c94c5db77dd6bbda661d17b9))
8
+
9
+ # [5.25.0](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.24.1...v5.25.0) (2025-08-06)
10
+
11
+
12
+ ### Features
13
+
14
+ * SASQRoute ViewComponent QueryPromise/ResponseTransform -- ERM-3771 ([ce4eba3](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/ce4eba3162628bfd89940b60ddf9b41b9beb093f))
15
+
1
16
  ## [5.24.1](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.24.0...v5.24.1) (2025-07-15)
2
17
 
3
18
 
@@ -390,6 +390,7 @@ const ActionListFieldArray = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
390
390
  className: _ActionListFieldArray.default.headerText,
391
391
  children: label
392
392
  }), !hideCreateButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
393
+ buttonStyle: "primary",
393
394
  disabled: !!editing || !createCallback,
394
395
  marginBottom0: true,
395
396
  onClick: handleClickCreate,
@@ -18,13 +18,22 @@ const SASQViewComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
18
18
  location,
19
19
  match,
20
20
  path,
21
+ viewQueryPromise = _ref2 => {
22
+ let {
23
+ endpoint,
24
+ ky,
25
+ resourceId
26
+ } = _ref2;
27
+ return ky.get(`${endpoint}/${resourceId}`).json();
28
+ },
29
+ viewResponseTransform = response => response,
21
30
  ViewComponent,
22
- viewQueryNamespaceGenerator = _ref2 => {
31
+ viewQueryNamespaceGenerator = _ref3 => {
23
32
  let {
24
33
  namespace,
25
34
  componentId,
26
35
  id: passedId
27
- } = _ref2;
36
+ } = _ref3;
28
37
  const queryNamespace = [namespace, 'SASQ'];
29
38
  if (componentId) {
30
39
  queryNamespace.push(componentId);
@@ -51,8 +60,20 @@ const SASQViewComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
51
60
  endpoint,
52
61
  id: match?.params?.id,
53
62
  match
54
- }), () => ky(`${endpoint}/${match?.params?.id}`).json(), {
55
- enabled: !!match?.params?.id
63
+ }), () => {
64
+ return viewQueryPromise({
65
+ ky,
66
+ resourceId: match?.params?.id,
67
+ endpoint: fetchParameters.endpoint
68
+ });
69
+ }, {
70
+ enabled: !!match?.params?.id,
71
+ // select is a parameter supported by useQuery to transform the response
72
+ // Could be possible to instead pass this down along with the queryOptions
73
+ // Additionally this is assuming the viewResponseTransform is a func as opposed to an object
74
+ select: selectData => {
75
+ return viewResponseTransform(selectData);
76
+ }
56
77
  });
57
78
  (0, _react.useImperativeHandle)(ref, () => ({
58
79
  queryProps: {
@@ -75,6 +96,8 @@ SASQViewComponent.propTypes = {
75
96
  id: _propTypes.default.string,
76
97
  location: _propTypes.default.object,
77
98
  match: _propTypes.default.object,
99
+ viewQueryPromise: _propTypes.default.func,
100
+ viewResponseTransform: _propTypes.default.func,
78
101
  path: _propTypes.default.string.isRequired,
79
102
  ViewComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node])
80
103
  };
@@ -4,6 +4,7 @@ var _react = require("react");
4
4
  var _react2 = require("@folio/jest-config-stripes/testing-library/react");
5
5
  var _stripesErmTesting = require("@folio/stripes-erm-testing");
6
6
  var _SearchKeyControl = _interopRequireDefault(require("./SearchKeyControl"));
7
+ var _jest = require("../../../test/jest");
7
8
  var _jsxRuntime = require("react/jsx-runtime");
8
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
10
  const mockUseQIndex = jest.fn();
@@ -17,7 +18,7 @@ describe('SearchKeyControl', () => {
17
18
  mockUseQIndex.mockImplementation(() => {
18
19
  return (0, _react.useState)();
19
20
  });
20
- (0, _stripesErmTesting.renderWithIntl)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchKeyControl.default, {
21
+ (0, _jest.renderWithKintHarness)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchKeyControl.default, {
21
22
  options: [{
22
23
  label: 'Opt 1',
23
24
  key: 'opt1'
@@ -89,7 +90,7 @@ describe('SearchKeyControl', () => {
89
90
  mockUseQIndex.mockImplementation(() => {
90
91
  return (0, _react.useState)('opt1,opt3');
91
92
  });
92
- (0, _stripesErmTesting.renderWithIntl)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchKeyControl.default, {
93
+ (0, _jest.renderWithKintHarness)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SearchKeyControl.default, {
93
94
  options: [{
94
95
  label: 'Opt 1',
95
96
  key: 'opt1'
@@ -11,6 +11,9 @@ var _jsxRuntime = require("react/jsx-runtime");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  /*
13
13
  * API is similar to ConfigManager
14
+ *
15
+ * DEPRECATED -- As far as I can see this is now unused anyway
16
+ * KInt modules are swapping to AppSettings instead of mod-settings, so no centralised components should be needed
14
17
  */const SettingsFormContainer = _ref => {
15
18
  let {
16
19
  ConfigFormComponent,
@@ -24,6 +27,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
24
27
  // We don't use this currently but it's here for future reference
25
28
  ...rest
26
29
  } = _ref;
30
+ // eslint-disable-next-line no-console
31
+ console.warn('SettingsFormContainer is deprecated, as it utilises mod-config');
27
32
  const callout = (0, _core.useCallout)();
28
33
  const kintIntl = (0, _hooks.useKintIntl)(passedIntlKey, passedIntlNS);
29
34
 
@@ -10,6 +10,8 @@ var _core = require("@folio/stripes/core");
10
10
  var _utils = require("../utils");
11
11
  var _endpoints = require("../constants/endpoints");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ // DEPRECATED -- As far as I can see this is now unused anyway
14
+ // KInt modules are swapping to AppSettings instead of mod-settings, so no centralised components should be needed
13
15
  const useModConfigEntries = _ref => {
14
16
  let {
15
17
  configName,
@@ -17,6 +19,8 @@ const useModConfigEntries = _ref => {
17
19
  namespaceAppend,
18
20
  queryParams
19
21
  } = _ref;
22
+ // eslint-disable-next-line no-console
23
+ console.warn('useModConfigEntries is deprecated, as it utilises mod-config');
20
24
  const ky = (0, _core.useOkapiKy)();
21
25
  const query = `?query=(module=${moduleName} and configName=${configName})`;
22
26
  const path = `${_endpoints.MOD_SETTINGS_ENDPOINT}${query}`;
@@ -9,12 +9,16 @@ var _core = require("@folio/stripes/core");
9
9
  var _utils = require("../utils");
10
10
  var _endpoints = require("../constants/endpoints");
11
11
  // This will simply take in some information and decide whether to mutate via POST or via PUT
12
+ // DEPRECATED -- As far as I can see this is now unused anyway
13
+ // KInt modules are swapping to AppSettings instead of mod-settings, so no centralised components should be needed
12
14
  const useMutateModConfigEntry = _ref => {
13
15
  let {
14
16
  configName,
15
17
  moduleName,
16
18
  id
17
19
  } = _ref;
20
+ // eslint-disable-next-line no-console
21
+ console.warn('useMutateModConfigEntry is deprecated, as it utilises mod-config');
18
22
  const ky = (0, _core.useOkapiKy)();
19
23
  const queryClient = (0, _reactQuery.useQueryClient)();
20
24
  const baseNamespace = (0, _utils.modConfigEntriesQueryKey)({
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _generateKiwtQuery = _interopRequireDefault(require("../generateKiwtQuery"));
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
+ // FIXME we need to test more than this
6
+ describe('generateKiwtQueryParams', () => {
7
+ describe('generateKiwtQueryParams nested group filters', () => {
8
+ test('EXAMPLE nested AND shape', () => {
9
+ expect((0, _generateKiwtQuery.default)({
10
+ filters: [{
11
+ groupValues: {
12
+ AND: [{
13
+ path: 'wobble',
14
+ value: 'test'
15
+ }, {
16
+ groupValues: {
17
+ OR: [{
18
+ value: 'test2'
19
+ }, {
20
+ path: 'sup',
21
+ value: 'test3'
22
+ }, {
23
+ groupValues: {
24
+ AND: [{
25
+ value: 'test4'
26
+ }, {
27
+ path: 'help',
28
+ comparator: '!=',
29
+ value: 'false'
30
+ }]
31
+ }
32
+ }]
33
+ }
34
+ }]
35
+ }
36
+ }]
37
+ }, {}, false)).toEqual('?filters=wobble==test&&(test2||sup==test3||(test4&&help!=false))&stats=true');
38
+ });
39
+ });
40
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "5.24.1",
3
+ "version": "5.25.1",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -25,7 +25,7 @@
25
25
  "@rehooks/local-storage": "^2.4.4",
26
26
  "compose-function": "^3.0.3",
27
27
  "react-resize-detector": "^11.0.0",
28
- "zustand": "^4.0.0"
28
+ "zustand": "^5.0.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/cli": "^7.18.10",
@@ -66,10 +66,8 @@
66
66
  "react-dom": "^18.2.0",
67
67
  "react-intl": "^6.4.4 || ^7.1.5",
68
68
  "react-query": "^3.6.0",
69
- "react-redux": "^9.0.0",
70
69
  "react-router": "^5.2.0",
71
70
  "react-router-dom": "^5.2.0",
72
- "redux": "^5.0.0",
73
71
  "redux-observable": "^2.0.0",
74
72
  "regenerator-runtime": "^0.14.0",
75
73
  "rxjs": "^7.0.0",
@@ -421,6 +421,7 @@ const ActionListFieldArray = forwardRef(({
421
421
  </Headline>
422
422
  {!hideCreateButton &&
423
423
  <Button
424
+ buttonStyle="primary"
424
425
  disabled={!!editing || !createCallback}
425
426
  marginBottom0
426
427
  onClick={handleClickCreate}
@@ -65,7 +65,8 @@ const SASQLookupComponent = forwardRef((props, ref) => {
65
65
 
66
66
  return queryNamespace;
67
67
  },
68
- lookupQueryPromise = ({ endpoint, ky, queryParams }) => ky.get(`${endpoint}${queryParams}`).json(),
68
+ lookupQueryPromise = ({ endpoint, ky, queryParams }) =>
69
+ ky.get(`${endpoint}${queryParams}`).json(),
69
70
  lookupResponseTransform = (response) => response, // Function to transform the response from the query
70
71
  mainPaneProps = {},
71
72
  mclProps = {},
@@ -125,7 +126,8 @@ const SASQLookupComponent = forwardRef((props, ref) => {
125
126
  const filterPaneVisibileKey = `${namespace}-${id}-filterPaneVisibility`;
126
127
 
127
128
  const queryParams = useMemo(
128
- () => queryParameterGenerator(
129
+ () =>
130
+ queryParameterGenerator(
129
131
  // With Typescript this would be a type of SASQ_MAP, and so totalRecords is a valid property in our new shape
130
132
  // In generateKiwtQueryParams we can choose to ignore totalRecords, which while being a valid property is not necessary for KIWT queries
131
133
  {
@@ -135,7 +137,13 @@ const SASQLookupComponent = forwardRef((props, ref) => {
135
137
  },
136
138
  query ?? {}
137
139
  ),
138
- [count, currentPage, fetchParameters.SASQ_MAP, query, queryParameterGenerator]
140
+ [
141
+ count,
142
+ currentPage,
143
+ fetchParameters.SASQ_MAP,
144
+ query,
145
+ queryParameterGenerator,
146
+ ]
139
147
  );
140
148
 
141
149
  const [filterPaneVisible, setFilterPaneVisible] = useLocalStorageState(
@@ -157,7 +165,7 @@ const SASQLookupComponent = forwardRef((props, ref) => {
157
165
  return lookupQueryPromise({
158
166
  ky,
159
167
  queryParams,
160
- endpoint: fetchParameters.endpoint
168
+ endpoint: fetchParameters.endpoint,
161
169
  });
162
170
  },
163
171
  {
@@ -3,69 +3,88 @@ import PropTypes from 'prop-types';
3
3
 
4
4
  import { useQuery } from 'react-query';
5
5
 
6
- import {
7
- useNamespace,
8
- useOkapiKy
9
- } from '@folio/stripes/core';
6
+ import { useNamespace, useOkapiKy } from '@folio/stripes/core';
10
7
 
11
- const SASQViewComponent = forwardRef(({
12
- fetchParameters,
13
- history,
14
- id,
15
- location,
16
- match,
17
- path,
18
- ViewComponent,
19
- viewQueryNamespaceGenerator = ({ namespace, componentId, id: passedId }) => {
20
- const queryNamespace = [namespace, 'SASQ'];
21
- if (componentId) {
22
- queryNamespace.push(componentId);
23
- }
24
- queryNamespace.push('view');
25
- queryNamespace.push(passedId);
8
+ const SASQViewComponent = forwardRef(
9
+ (
10
+ {
11
+ fetchParameters,
12
+ history,
13
+ id,
14
+ location,
15
+ match,
16
+ path,
17
+ viewQueryPromise = ({ endpoint, ky, resourceId }) =>
18
+ ky.get(`${endpoint}/${resourceId}`).json(),
19
+ viewResponseTransform = (response) => response,
20
+ ViewComponent,
21
+ viewQueryNamespaceGenerator = ({
22
+ namespace,
23
+ componentId,
24
+ id: passedId,
25
+ }) => {
26
+ const queryNamespace = [namespace, 'SASQ'];
27
+ if (componentId) {
28
+ queryNamespace.push(componentId);
29
+ }
30
+ queryNamespace.push('view');
31
+ queryNamespace.push(passedId);
26
32
 
27
- return queryNamespace;
28
- },
29
- ...props
30
- }, ref) => {
31
- const { 0: namespace } = useNamespace();
33
+ return queryNamespace;
34
+ },
35
+ ...props
36
+ },
37
+ ref
38
+ ) => {
39
+ const { 0: namespace } = useNamespace();
32
40
 
33
- // If itemEndpoint is available, use that, otherwise use standard endpoint
34
- const endpoint = fetchParameters?.itemEndpoint ?? fetchParameters?.endpoint;
41
+ // If itemEndpoint is available, use that, otherwise use standard endpoint
42
+ const endpoint = fetchParameters?.itemEndpoint ?? fetchParameters?.endpoint;
35
43
 
36
- const ky = useOkapiKy();
37
- const { data = {}, ...rest } = useQuery(
38
- viewQueryNamespaceGenerator({
39
- componentId: id,
40
- namespace,
41
- endpoint,
42
- id: match?.params?.id,
43
- match,
44
- }),
45
- () => ky(`${endpoint}/${match?.params?.id}`).json(),
46
- {
47
- enabled: !!match?.params?.id
48
- }
49
- );
44
+ const ky = useOkapiKy();
45
+ const { data = {}, ...rest } = useQuery(
46
+ viewQueryNamespaceGenerator({
47
+ componentId: id,
48
+ namespace,
49
+ endpoint,
50
+ id: match?.params?.id,
51
+ match,
52
+ }),
53
+ () => {
54
+ return viewQueryPromise({
55
+ ky,
56
+ resourceId: match?.params?.id,
57
+ endpoint: fetchParameters.endpoint,
58
+ });
59
+ },
60
+ {
61
+ enabled: !!match?.params?.id,
62
+ // select is a parameter supported by useQuery to transform the response
63
+ // Could be possible to instead pass this down along with the queryOptions
64
+ // Additionally this is assuming the viewResponseTransform is a func as opposed to an object
65
+ select: (selectData) => {
66
+ return viewResponseTransform(selectData);
67
+ },
68
+ }
69
+ );
50
70
 
51
- useImperativeHandle(ref, () => (
52
- {
71
+ useImperativeHandle(ref, () => ({
53
72
  queryProps: {
54
73
  data,
55
- ...rest
56
- }
57
- }
58
- ));
74
+ ...rest,
75
+ },
76
+ }));
59
77
 
60
- return (
61
- <ViewComponent
62
- onClose={() => history.push(`${path}${location.search}`)}
63
- queryProps={{ ...rest }}
64
- resource={data}
65
- {...props}
66
- />
67
- );
68
- });
78
+ return (
79
+ <ViewComponent
80
+ onClose={() => history.push(`${path}${location.search}`)}
81
+ queryProps={{ ...rest }}
82
+ resource={data}
83
+ {...props}
84
+ />
85
+ );
86
+ }
87
+ );
69
88
 
70
89
  SASQViewComponent.propTypes = {
71
90
  fetchParameters: PropTypes.object,
@@ -73,11 +92,10 @@ SASQViewComponent.propTypes = {
73
92
  id: PropTypes.string,
74
93
  location: PropTypes.object,
75
94
  match: PropTypes.object,
95
+ viewQueryPromise: PropTypes.func,
96
+ viewResponseTransform: PropTypes.func,
76
97
  path: PropTypes.string.isRequired,
77
- ViewComponent: PropTypes.oneOfType([
78
- PropTypes.func,
79
- PropTypes.node
80
- ]),
98
+ ViewComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
81
99
  };
82
100
 
83
101
  export default SASQViewComponent;
@@ -1,9 +1,10 @@
1
1
  import { useState } from 'react';
2
2
 
3
3
  import { waitFor } from '@folio/jest-config-stripes/testing-library/react';
4
- import { renderWithIntl, Checkbox } from '@folio/stripes-erm-testing';
4
+ import { Checkbox } from '@folio/stripes-erm-testing';
5
5
 
6
6
  import SearchKeyControl from './SearchKeyControl';
7
+ import { renderWithKintHarness } from '../../../test/jest';
7
8
 
8
9
  const mockUseQIndex = jest.fn();
9
10
 
@@ -19,7 +20,7 @@ describe('SearchKeyControl', () => {
19
20
  return useState();
20
21
  });
21
22
 
22
- renderWithIntl(
23
+ renderWithKintHarness(
23
24
  <SearchKeyControl
24
25
  options={[
25
26
  {
@@ -87,7 +88,7 @@ describe('SearchKeyControl', () => {
87
88
  return useState('opt1,opt3');
88
89
  });
89
90
 
90
- renderWithIntl(
91
+ renderWithKintHarness(
91
92
  <SearchKeyControl
92
93
  options={[
93
94
  {
@@ -5,6 +5,9 @@ import { useKintIntl, useModConfigEntries, useMutateModConfigEntry } from '../ho
5
5
 
6
6
  /*
7
7
  * API is similar to ConfigManager
8
+ *
9
+ * DEPRECATED -- As far as I can see this is now unused anyway
10
+ * KInt modules are swapping to AppSettings instead of mod-settings, so no centralised components should be needed
8
11
  */
9
12
  const SettingsFormContainer = ({
10
13
  ConfigFormComponent,
@@ -17,6 +20,9 @@ const SettingsFormContainer = ({
17
20
  scope, // We don't use this currently but it's here for future reference
18
21
  ...rest
19
22
  }) => {
23
+ // eslint-disable-next-line no-console
24
+ console.warn('SettingsFormContainer is deprecated, as it utilises mod-config');
25
+
20
26
  const callout = useCallout();
21
27
  const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
22
28
 
@@ -5,12 +5,17 @@ import { useOkapiKy } from '@folio/stripes/core';
5
5
  import { modConfigEntriesQueryKey, parseModConfigEntry } from '../utils';
6
6
  import { MOD_SETTINGS_ENDPOINT } from '../constants/endpoints';
7
7
 
8
+ // DEPRECATED -- As far as I can see this is now unused anyway
9
+ // KInt modules are swapping to AppSettings instead of mod-settings, so no centralised components should be needed
8
10
  const useModConfigEntries = ({
9
11
  configName,
10
12
  moduleName,
11
13
  namespaceAppend,
12
14
  queryParams
13
15
  }) => {
16
+ // eslint-disable-next-line no-console
17
+ console.warn('useModConfigEntries is deprecated, as it utilises mod-config');
18
+
14
19
  const ky = useOkapiKy();
15
20
 
16
21
  const query = `?query=(module=${moduleName} and configName=${configName})`;
@@ -6,11 +6,16 @@ import { modConfigEntriesQueryKey } from '../utils';
6
6
  import { MOD_SETTINGS_ENDPOINT } from '../constants/endpoints';
7
7
 
8
8
  // This will simply take in some information and decide whether to mutate via POST or via PUT
9
+ // DEPRECATED -- As far as I can see this is now unused anyway
10
+ // KInt modules are swapping to AppSettings instead of mod-settings, so no centralised components should be needed
9
11
  const useMutateModConfigEntry = ({
10
12
  configName,
11
13
  moduleName,
12
14
  id
13
15
  }) => {
16
+ // eslint-disable-next-line no-console
17
+ console.warn('useMutateModConfigEntry is deprecated, as it utilises mod-config');
18
+
14
19
  const ky = useOkapiKy();
15
20
  const queryClient = useQueryClient();
16
21
 
@@ -0,0 +1,27 @@
1
+ import generateKiwtQuery from '../generateKiwtQuery';
2
+
3
+ // FIXME we need to test more than this
4
+ describe('generateKiwtQueryParams', () => {
5
+ describe('generateKiwtQueryParams nested group filters', () => {
6
+ test('EXAMPLE nested AND shape', () => {
7
+ expect(generateKiwtQuery({
8
+ filters: [{
9
+ groupValues: {
10
+ AND: [
11
+ { path: 'wobble', value: 'test' },
12
+ {
13
+ groupValues: {
14
+ OR: [
15
+ { value: 'test2' },
16
+ { path: 'sup', value: 'test3' },
17
+ { groupValues: { AND: [{ value: 'test4' }, { path: 'help', comparator: '!=', value: 'false' }] } },
18
+ ]
19
+ }
20
+ },
21
+ ]
22
+ }
23
+ }]
24
+ }, {}, false)).toEqual('?filters=wobble==test&&(test2||sup==test3||(test4&&help!=false))&stats=true');
25
+ });
26
+ });
27
+ });