@k-int/stripes-kint-components 5.16.0 → 5.17.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [5.17.0](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.16.0...v5.17.0) (2025-03-14)
2
+
3
+
4
+ ### Features
5
+
6
+ * Added the ability to generate a custom queryNamespace on SASQLookup and SASQView components ([df68645](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/df686452ed854fffc7724bad40a6b4de2d651a42))
7
+
1
8
  # [5.16.0](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.15.0...v5.16.0) (2025-03-14)
2
9
 
3
10
 
@@ -27,6 +27,22 @@ const SASQLookupComponent = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
27
27
  intlKey: passedIntlKey,
28
28
  intlNS: passedIntlNS,
29
29
  labelOverrides = {},
30
+ lookupQueryNamespaceGenerator = _ref => {
31
+ let {
32
+ currentPage,
33
+ namespace,
34
+ id: passedId,
35
+ query
36
+ } = _ref;
37
+ const queryNamespace = [namespace, 'SASQ'];
38
+ if (passedId) {
39
+ queryNamespace.push(passedId);
40
+ }
41
+ queryNamespace.push('viewAll');
42
+ queryNamespace.push(query);
43
+ queryNamespace.push(currentPage);
44
+ return queryNamespace;
45
+ },
30
46
  mainPaneProps = {},
31
47
  mclProps = {},
32
48
  noSearchField,
@@ -79,20 +95,21 @@ const SASQLookupComponent = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
79
95
  }, query ?? {}), [currentPage, fetchParameters.SASQ_MAP, query, queryParameterGenerator]);
80
96
  const [filterPaneVisible, setFilterPaneVisible] = (0, _hooks.useLocalStorageState)(filterPaneVisibileKey, true);
81
97
  const toggleFilterPane = () => setFilterPaneVisible(!filterPaneVisible);
82
- const queryNamespace = [namespace, 'SASQ'];
83
- if (id) {
84
- queryNamespace.push(id);
85
- }
86
- queryNamespace.push('viewAll');
87
- queryNamespace.push(query);
88
- queryNamespace.push(currentPage);
89
98
  const {
90
99
  data = {},
91
100
  ...restOfQueryProps
92
- } = (0, _reactQuery.useQuery)(queryNamespace, () => {
101
+ } = (0, _reactQuery.useQuery)(lookupQueryNamespaceGenerator({
102
+ currentPage,
103
+ endpoint: fetchParameters.endpoint,
104
+ namespace,
105
+ id,
106
+ query,
107
+ queryParams
108
+ }), () => {
93
109
  return ky.get(`${fetchParameters.endpoint}${queryParams}`).json();
94
110
  }, {
95
- enabled: (!!query?.filters || !!query?.query) && !!currentPage
111
+ enabled: (!!query?.filters || !!query?.query) && !!currentPage,
112
+ ...(fetchParameters.queryOptions ?? {})
96
113
  });
97
114
  (0, _react.useEffect)(() => {
98
115
  if (count !== data?.totalRecords) {
@@ -19,6 +19,20 @@ const SASQViewComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
19
19
  match,
20
20
  path,
21
21
  ViewComponent,
22
+ viewQueryNamespaceGenerator = _ref2 => {
23
+ let {
24
+ namespace,
25
+ componentId,
26
+ id: passedId
27
+ } = _ref2;
28
+ const queryNamespace = [namespace, 'SASQ'];
29
+ if (componentId) {
30
+ queryNamespace.push(componentId);
31
+ }
32
+ queryNamespace.push('view');
33
+ queryNamespace.push(passedId);
34
+ return queryNamespace;
35
+ },
22
36
  ...props
23
37
  } = _ref;
24
38
  const {
@@ -27,17 +41,17 @@ const SASQViewComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
27
41
 
28
42
  // If itemEndpoint is available, use that, otherwise use standard endpoint
29
43
  const endpoint = fetchParameters?.itemEndpoint ?? fetchParameters?.endpoint;
30
- const queryNamespace = [namespace, 'SASQ'];
31
- if (id) {
32
- queryNamespace.push(id);
33
- }
34
- queryNamespace.push('view');
35
- queryNamespace.push(match?.params?.id);
36
44
  const ky = (0, _core.useOkapiKy)();
37
45
  const {
38
46
  data = {},
39
47
  ...rest
40
- } = (0, _reactQuery.useQuery)(queryNamespace, () => ky(`${endpoint}/${match?.params?.id}`).json(), {
48
+ } = (0, _reactQuery.useQuery)(viewQueryNamespaceGenerator({
49
+ componentId: id,
50
+ namespace,
51
+ endpoint,
52
+ id: match?.params?.id,
53
+ match
54
+ }), () => ky(`${endpoint}/${match?.params?.id}`).json(), {
41
55
  enabled: !!match?.params?.id
42
56
  });
43
57
  (0, _react.useImperativeHandle)(ref, () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "5.16.0",
3
+ "version": "5.17.0",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -40,6 +40,17 @@ const SASQLookupComponent = forwardRef((props, ref) => {
40
40
  intlKey: passedIntlKey,
41
41
  intlNS: passedIntlNS,
42
42
  labelOverrides = {},
43
+ lookupQueryNamespaceGenerator = ({ currentPage, namespace, id: passedId, query }) => {
44
+ const queryNamespace = [namespace, 'SASQ'];
45
+ if (passedId) {
46
+ queryNamespace.push(passedId);
47
+ }
48
+ queryNamespace.push('viewAll');
49
+ queryNamespace.push(query);
50
+ queryNamespace.push(currentPage);
51
+
52
+ return queryNamespace;
53
+ },
43
54
  mainPaneProps = {},
44
55
  mclProps = {},
45
56
  noSearchField,
@@ -49,7 +60,7 @@ const SASQLookupComponent = forwardRef((props, ref) => {
49
60
  rowNavigation = true, // Default navigation onRowClick
50
61
  sasqProps,
51
62
  searchFieldAriaLabel,
52
- searchFieldProps
63
+ searchFieldProps,
53
64
  } = props;
54
65
  const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
55
66
  const [count, setCount] = useState(0);
@@ -95,24 +106,24 @@ const SASQLookupComponent = forwardRef((props, ref) => {
95
106
  const [filterPaneVisible, setFilterPaneVisible] = useLocalStorageState(filterPaneVisibileKey, true);
96
107
  const toggleFilterPane = () => setFilterPaneVisible(!filterPaneVisible);
97
108
 
98
- const queryNamespace = [namespace, 'SASQ'];
99
- if (id) {
100
- queryNamespace.push(id);
101
- }
102
- queryNamespace.push('viewAll');
103
- queryNamespace.push(query);
104
- queryNamespace.push(currentPage);
105
-
106
109
  const {
107
110
  data = {},
108
111
  ...restOfQueryProps
109
112
  } = useQuery(
110
- queryNamespace,
113
+ lookupQueryNamespaceGenerator({
114
+ currentPage,
115
+ endpoint: fetchParameters.endpoint,
116
+ namespace,
117
+ id,
118
+ query,
119
+ queryParams
120
+ }),
111
121
  () => {
112
122
  return ky.get(`${fetchParameters.endpoint}${queryParams}`).json();
113
123
  },
114
124
  {
115
125
  enabled: (!!query?.filters || !!query?.query) && !!currentPage,
126
+ ...(fetchParameters.queryOptions ?? {})
116
127
  }
117
128
  );
118
129
 
@@ -16,6 +16,16 @@ const SASQViewComponent = forwardRef(({
16
16
  match,
17
17
  path,
18
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);
26
+
27
+ return queryNamespace;
28
+ },
19
29
  ...props
20
30
  }, ref) => {
21
31
  const { 0: namespace } = useNamespace();
@@ -23,16 +33,15 @@ const SASQViewComponent = forwardRef(({
23
33
  // If itemEndpoint is available, use that, otherwise use standard endpoint
24
34
  const endpoint = fetchParameters?.itemEndpoint ?? fetchParameters?.endpoint;
25
35
 
26
- const queryNamespace = [namespace, 'SASQ'];
27
- if (id) {
28
- queryNamespace.push(id);
29
- }
30
- queryNamespace.push('view');
31
- queryNamespace.push(match?.params?.id);
32
-
33
36
  const ky = useOkapiKy();
34
37
  const { data = {}, ...rest } = useQuery(
35
- queryNamespace,
38
+ viewQueryNamespaceGenerator({
39
+ componentId: id,
40
+ namespace,
41
+ endpoint,
42
+ id: match?.params?.id,
43
+ match,
44
+ }),
36
45
  () => ky(`${endpoint}/${match?.params?.id}`).json(),
37
46
  {
38
47
  enabled: !!match?.params?.id