@k-int/stripes-kint-components 5.15.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,19 @@
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
+
8
+ # [5.16.0](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.15.0...v5.16.0) (2025-03-14)
9
+
10
+
11
+ ### Features
12
+
13
+ * Added ability for SASQLookupComponent to accept sasqProps.syncToLocation/query(Getter/Setter) and have that impact on results ([351b503](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/351b50313e0a320191b24fa1df6227103021f106))
14
+ * SASQRoute allow tweaking of SASQLookupComponent and SASQViewComponent component directly in SASQRoute ([6c812b2](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/6c812b2c4c10a049b8a9e56e624cc3dceee3a8fe))
15
+ * SASQRoute override paths for lookup/view ([994b976](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/994b976cbec3af6382066bc6bf6dd945d4a3e239))
16
+
1
17
  # [5.15.0](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.14.0...v5.15.0) (2025-02-21)
2
18
 
3
19
 
@@ -34,25 +34,26 @@ const NoResultsMessage = _ref => {
34
34
  searchTerm
35
35
  }
36
36
  });
37
-
38
- // No search term but no results
39
- if (!searchTerm) {
37
+ if (!isLoading && !searchTerm) {
38
+ // No search term and not loading
39
+ icon = filterPaneIsVisible ? 'arrow-left' : null;
40
+ label = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
41
+ id: "stripes-smart-components.sas.noResults.noTerms"
42
+ });
43
+ } else if (!isLoading) {
44
+ // Search term but not loading
40
45
  icon = 'search';
41
46
  label = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
42
47
  id: "stripes-smart-components.sas.noResults.noResults"
43
48
  });
44
- }
45
-
46
- // Loading results
47
- if (isLoading) {
49
+ } else if (isLoading) {
50
+ // Loading
48
51
  icon = 'spinner-ellipsis';
49
52
  label = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
50
53
  id: "stripes-smart-components.sas.noResults.loading"
51
54
  });
52
- }
53
-
54
- // Request failure
55
- if (isError) {
55
+ } else if (isError) {
56
+ // Request failure
56
57
  icon = 'exclamation-circle';
57
58
  label = error?.message;
58
59
  }
@@ -27,10 +27,28 @@ const SASQLookupComponent = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
27
27
  intlKey: passedIntlKey,
28
28
  intlNS: passedIntlNS,
29
29
  labelOverrides = {},
30
- mainPaneProps,
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
+ },
46
+ mainPaneProps = {},
31
47
  mclProps = {},
32
48
  noSearchField,
33
49
  persistedPanesetProps = {},
50
+ queryParameterGenerator = _utils.generateKiwtQuery,
51
+ // Expects a function which accepts SASQ_MAP and nsValues
34
52
  RenderBody,
35
53
  rowNavigation = true,
36
54
  // Default navigation onRowClick
@@ -40,44 +58,58 @@ const SASQLookupComponent = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
40
58
  } = props;
41
59
  const kintIntl = (0, _hooks.useKintIntl)(passedIntlKey, passedIntlNS);
42
60
  const [count, setCount] = (0, _react.useState)(0);
61
+
62
+ // Grab things we might need from sasqProps if passed
63
+ const {
64
+ query: sasqPropsQuery,
65
+ // If these are overriden we need to make use of them
66
+ queryGetter: sasqPropsQueryGetter,
67
+ querySetter: sasqPropsQuerySetter,
68
+ syncToLocation = true
69
+ } = sasqProps ?? {};
43
70
  const {
44
71
  currentPage,
45
72
  paginationMCLProps,
46
73
  paginationSASQProps
47
74
  } = (0, _hooks.usePrevNextPagination)({
48
75
  count,
49
- pageSize: fetchParameters.SASQ_MAP?.perPage
76
+ pageSize: fetchParameters.SASQ_MAP?.perPage,
77
+ syncToLocation
50
78
  });
51
79
  const {
52
- query,
53
- queryGetter,
54
- querySetter
80
+ query: kintSASQQuery,
81
+ queryGetter: kintSASQQueryGetter,
82
+ querySetter: kintSASQQuerySetter
55
83
  } = (0, _hooks.useKiwtSASQuery)();
84
+ const query = (0, _react.useMemo)(() => sasqPropsQuery ?? kintSASQQuery, [sasqPropsQuery, kintSASQQuery]);
85
+ const queryGetter = (0, _react.useMemo)(() => sasqPropsQueryGetter ?? kintSASQQueryGetter, [sasqPropsQueryGetter, kintSASQQueryGetter]);
86
+ const querySetter = (0, _react.useMemo)(() => sasqPropsQuerySetter ?? kintSASQQuerySetter, [sasqPropsQuerySetter, kintSASQQuerySetter]);
56
87
  const {
57
88
  0: namespace
58
89
  } = (0, _core.useNamespace)();
59
90
  const ky = (0, _core.useOkapiKy)();
60
91
  const filterPaneVisibileKey = `${namespace}-${id}-filterPaneVisibility`;
61
- const queryParams = (0, _react.useMemo)(() => (0, _utils.generateKiwtQuery)({
92
+ const queryParams = (0, _react.useMemo)(() => queryParameterGenerator({
62
93
  ...fetchParameters.SASQ_MAP,
63
94
  page: currentPage
64
- }, query ?? {}), [currentPage, fetchParameters.SASQ_MAP, query]);
95
+ }, query ?? {}), [currentPage, fetchParameters.SASQ_MAP, query, queryParameterGenerator]);
65
96
  const [filterPaneVisible, setFilterPaneVisible] = (0, _hooks.useLocalStorageState)(filterPaneVisibileKey, true);
66
97
  const toggleFilterPane = () => setFilterPaneVisible(!filterPaneVisible);
67
- const queryNamespace = [namespace, 'SASQ'];
68
- if (id) {
69
- queryNamespace.push(id);
70
- }
71
- queryNamespace.push('viewAll');
72
- queryNamespace.push(query);
73
- queryNamespace.push(currentPage);
74
98
  const {
75
99
  data = {},
76
100
  ...restOfQueryProps
77
- } = (0, _reactQuery.useQuery)(queryNamespace, () => {
101
+ } = (0, _reactQuery.useQuery)(lookupQueryNamespaceGenerator({
102
+ currentPage,
103
+ endpoint: fetchParameters.endpoint,
104
+ namespace,
105
+ id,
106
+ query,
107
+ queryParams
108
+ }), () => {
78
109
  return ky.get(`${fetchParameters.endpoint}${queryParams}`).json();
79
110
  }, {
80
- enabled: (!!query?.filters || !!query?.query) && !!currentPage
111
+ enabled: (!!query?.filters || !!query?.query) && !!currentPage,
112
+ ...(fetchParameters.queryOptions ?? {})
81
113
  });
82
114
  (0, _react.useEffect)(() => {
83
115
  if (count !== data?.totalRecords) {
@@ -97,6 +129,7 @@ const SASQLookupComponent = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
97
129
  },
98
130
  queryGetter: queryGetter,
99
131
  querySetter: querySetter,
132
+ syncToLocation: syncToLocation,
100
133
  ...sasqProps,
101
134
  ...paginationSASQProps,
102
135
  children: sasqRenderProps => {
@@ -246,6 +279,7 @@ SASQLookupComponent.propTypes = {
246
279
  filterPaneProps: _propTypes.default.object,
247
280
  FilterComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
248
281
  FilterPaneHeaderComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
282
+ queryParameterGenerator: _propTypes.default.func,
249
283
  history: _propTypes.default.object,
250
284
  id: _propTypes.default.string.isRequired,
251
285
  intlKey: _propTypes.default.string,
@@ -15,7 +15,11 @@ const SASQRoute = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
15
15
  let {
16
16
  children,
17
17
  fetchParameters,
18
+ getPathLookup = path => `${path}/:id?`,
19
+ getPathView = path => `${path}/:id`,
20
+ SASQLookupComponent: RouteLookupComponent = _SASQLookupComponent.SASQLookupComponent,
18
21
  path,
22
+ SASQViewComponent: RouteViewComponent = _SASQViewComponent.default,
19
23
  ...props
20
24
  } = _ref;
21
25
  // Grab the SASQ_MAP and tweak it
@@ -36,9 +40,9 @@ const SASQRoute = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
36
40
  // Reinsert the SASQ_MAP
37
41
  fetchParameters.SASQ_MAP = SASQ_MAP;
38
42
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
39
- path: `${path}/:id?`,
43
+ path: getPathLookup(path),
40
44
  render: routeProps => {
41
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SASQLookupComponent.SASQLookupComponent, {
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(RouteLookupComponent, {
42
46
  ref: lookupRef,
43
47
  ...routeProps,
44
48
  fetchParameters: fetchParameters,
@@ -46,8 +50,8 @@ const SASQRoute = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
46
50
  ...props,
47
51
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Switch, {
48
52
  children: [children, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Route, {
49
- path: `${path}/:id`,
50
- render: innerProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_SASQViewComponent.default, {
53
+ path: getPathView(path),
54
+ render: innerProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(RouteViewComponent, {
51
55
  ref: viewRef,
52
56
  ...innerProps,
53
57
  fetchParameters: fetchParameters,
@@ -64,7 +68,11 @@ const SASQRoute = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
64
68
  SASQRoute.propTypes = {
65
69
  children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.element, _propTypes.default.func]),
66
70
  fetchParameters: _propTypes.default.object,
71
+ getPathLookup: _propTypes.default.func,
72
+ getPathView: _propTypes.default.func,
67
73
  path: _propTypes.default.string,
74
+ SASQLookupComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
75
+ SASQViewComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
68
76
  ViewComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node])
69
77
  };
70
78
  var _default = exports.default = SASQRoute;
@@ -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.15.0",
3
+ "version": "5.17.0",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -44,7 +44,7 @@
44
44
  "@folio/jest-config-stripes": "^2.0.0 || ^3.0.0",
45
45
  "@folio/stripes": "^9.0.0 || ^10.0.0",
46
46
  "@folio/stripes-cli": "^3.0.0 || ^4.0.0",
47
- "@folio/stripes-erm-testing": "^2.0.0",
47
+ "@folio/stripes-erm-testing": "^2.0.0 || ^3.0.0",
48
48
  "@formatjs/cli": "^6.6.0",
49
49
  "@semantic-release/changelog": "^6.0.3",
50
50
  "@semantic-release/git": "^10.0.1",
@@ -23,20 +23,20 @@ const NoResultsMessage = ({
23
23
  let icon = 'search';
24
24
  let label = <FormattedMessage id="stripes-smart-components.sas.noResults.default" values={{ searchTerm }} />;
25
25
 
26
- // No search term but no results
27
- if (!searchTerm) {
26
+ if (!isLoading && !searchTerm) {
27
+ // No search term and not loading
28
+ icon = filterPaneIsVisible ? 'arrow-left' : null;
29
+ label = <FormattedMessage id="stripes-smart-components.sas.noResults.noTerms" />;
30
+ } else if (!isLoading) {
31
+ // Search term but not loading
28
32
  icon = 'search';
29
33
  label = <FormattedMessage id="stripes-smart-components.sas.noResults.noResults" />;
30
- }
31
-
32
- // Loading results
33
- if (isLoading) {
34
+ } else if (isLoading) {
35
+ // Loading
34
36
  icon = 'spinner-ellipsis';
35
37
  label = <FormattedMessage id="stripes-smart-components.sas.noResults.loading" />;
36
- }
37
-
38
- // Request failure
39
- if (isError) {
38
+ } else if (isError) {
39
+ // Request failure
40
40
  icon = 'exclamation-circle';
41
41
  label = error?.message;
42
42
  }
@@ -40,60 +40,90 @@ const SASQLookupComponent = forwardRef((props, ref) => {
40
40
  intlKey: passedIntlKey,
41
41
  intlNS: passedIntlNS,
42
42
  labelOverrides = {},
43
- mainPaneProps,
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
+ },
54
+ mainPaneProps = {},
44
55
  mclProps = {},
45
56
  noSearchField,
46
57
  persistedPanesetProps = {},
58
+ queryParameterGenerator = generateKiwtQuery, // Expects a function which accepts SASQ_MAP and nsValues
47
59
  RenderBody,
48
60
  rowNavigation = true, // Default navigation onRowClick
49
61
  sasqProps,
50
62
  searchFieldAriaLabel,
51
- searchFieldProps
63
+ searchFieldProps,
52
64
  } = props;
53
65
  const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
54
66
  const [count, setCount] = useState(0);
55
67
 
68
+ // Grab things we might need from sasqProps if passed
69
+ const {
70
+ query: sasqPropsQuery, // If these are overriden we need to make use of them
71
+ queryGetter: sasqPropsQueryGetter,
72
+ querySetter: sasqPropsQuerySetter,
73
+ syncToLocation = true
74
+ } = sasqProps ?? {};
75
+
56
76
  const { currentPage, paginationMCLProps, paginationSASQProps } = usePrevNextPagination({
57
77
  count,
58
- pageSize: fetchParameters.SASQ_MAP?.perPage
78
+ pageSize: fetchParameters.SASQ_MAP?.perPage,
79
+ syncToLocation
59
80
  });
60
81
 
61
- const { query, queryGetter, querySetter } = useKiwtSASQuery();
82
+ const {
83
+ query: kintSASQQuery,
84
+ queryGetter: kintSASQQueryGetter,
85
+ querySetter: kintSASQQuerySetter
86
+ } = useKiwtSASQuery();
87
+
88
+ const query = useMemo(() => sasqPropsQuery ?? kintSASQQuery, [sasqPropsQuery, kintSASQQuery]);
89
+ const queryGetter = useMemo(() => sasqPropsQueryGetter ?? kintSASQQueryGetter, [sasqPropsQueryGetter, kintSASQQueryGetter]);
90
+ const querySetter = useMemo(() => sasqPropsQuerySetter ?? kintSASQQuerySetter, [sasqPropsQuerySetter, kintSASQQuerySetter]);
91
+
62
92
  const { 0: namespace } = useNamespace();
63
93
  const ky = useOkapiKy();
64
94
 
65
95
  const filterPaneVisibileKey = `${namespace}-${id}-filterPaneVisibility`;
66
96
 
67
97
  const queryParams = useMemo(() => (
68
- generateKiwtQuery(
98
+ queryParameterGenerator(
69
99
  {
70
100
  ...fetchParameters.SASQ_MAP,
71
101
  page: currentPage,
72
102
  }, (query ?? {})
73
103
  )
74
- ), [currentPage, fetchParameters.SASQ_MAP, query]);
104
+ ), [currentPage, fetchParameters.SASQ_MAP, query, queryParameterGenerator]);
75
105
 
76
106
  const [filterPaneVisible, setFilterPaneVisible] = useLocalStorageState(filterPaneVisibileKey, true);
77
107
  const toggleFilterPane = () => setFilterPaneVisible(!filterPaneVisible);
78
108
 
79
- const queryNamespace = [namespace, 'SASQ'];
80
- if (id) {
81
- queryNamespace.push(id);
82
- }
83
- queryNamespace.push('viewAll');
84
- queryNamespace.push(query);
85
- queryNamespace.push(currentPage);
86
-
87
109
  const {
88
110
  data = {},
89
111
  ...restOfQueryProps
90
112
  } = useQuery(
91
- queryNamespace,
113
+ lookupQueryNamespaceGenerator({
114
+ currentPage,
115
+ endpoint: fetchParameters.endpoint,
116
+ namespace,
117
+ id,
118
+ query,
119
+ queryParams
120
+ }),
92
121
  () => {
93
122
  return ky.get(`${fetchParameters.endpoint}${queryParams}`).json();
94
123
  },
95
124
  {
96
125
  enabled: (!!query?.filters || !!query?.query) && !!currentPage,
126
+ ...(fetchParameters.queryOptions ?? {})
97
127
  }
98
128
  );
99
129
 
@@ -118,6 +148,7 @@ const SASQLookupComponent = forwardRef((props, ref) => {
118
148
  initialSearchState={{ query: '' }}
119
149
  queryGetter={queryGetter}
120
150
  querySetter={querySetter}
151
+ syncToLocation={syncToLocation}
121
152
  {...sasqProps}
122
153
  {...paginationSASQProps}
123
154
  >
@@ -315,6 +346,7 @@ SASQLookupComponent.propTypes = {
315
346
  PropTypes.func,
316
347
  PropTypes.node
317
348
  ]),
349
+ queryParameterGenerator: PropTypes.func,
318
350
  history: PropTypes.object,
319
351
  id: PropTypes.string.isRequired,
320
352
  intlKey: PropTypes.string,
@@ -12,7 +12,11 @@ import SASQViewComponent from '../SASQViewComponent';
12
12
  const SASQRoute = forwardRef(({
13
13
  children,
14
14
  fetchParameters,
15
+ getPathLookup = (path) => `${path}/:id?`,
16
+ getPathView = (path) => `${path}/:id`,
17
+ SASQLookupComponent: RouteLookupComponent = SASQLookupComponent,
15
18
  path,
19
+ SASQViewComponent: RouteViewComponent = SASQViewComponent,
16
20
  ...props
17
21
  }, ref) => {
18
22
  // Grab the SASQ_MAP and tweak it
@@ -37,10 +41,10 @@ const SASQRoute = forwardRef(({
37
41
 
38
42
  return (
39
43
  <Route
40
- path={`${path}/:id?`}
44
+ path={getPathLookup(path)}
41
45
  render={routeProps => {
42
46
  return (
43
- <SASQLookupComponent
47
+ <RouteLookupComponent
44
48
  ref={lookupRef}
45
49
  {...routeProps}
46
50
  fetchParameters={fetchParameters}
@@ -50,9 +54,9 @@ const SASQRoute = forwardRef(({
50
54
  <Switch>
51
55
  {children}
52
56
  <Route
53
- path={`${path}/:id`}
57
+ path={getPathView(path)}
54
58
  render={innerProps => (
55
- <SASQViewComponent
59
+ <RouteViewComponent
56
60
  ref={viewRef}
57
61
  {...innerProps}
58
62
  fetchParameters={fetchParameters}
@@ -63,7 +67,7 @@ const SASQRoute = forwardRef(({
63
67
  )}
64
68
  />
65
69
  </Switch>
66
- </SASQLookupComponent>
70
+ </RouteLookupComponent>
67
71
  );
68
72
  }}
69
73
  />
@@ -77,7 +81,17 @@ SASQRoute.propTypes = {
77
81
  PropTypes.func
78
82
  ]),
79
83
  fetchParameters: PropTypes.object,
84
+ getPathLookup: PropTypes.func,
85
+ getPathView: PropTypes.func,
80
86
  path: PropTypes.string,
87
+ SASQLookupComponent: PropTypes.oneOfType([
88
+ PropTypes.func,
89
+ PropTypes.node
90
+ ]),
91
+ SASQViewComponent: PropTypes.oneOfType([
92
+ PropTypes.func,
93
+ PropTypes.node
94
+ ]),
81
95
  ViewComponent: PropTypes.oneOfType([
82
96
  PropTypes.func,
83
97
  PropTypes.node
@@ -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