@availity/mui-spaces 1.0.29 → 1.0.31

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
@@ -2,6 +2,15 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.0.31](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.30...@availity/mui-spaces@1.0.31) (2025-09-22)
6
+
7
+ ## [1.0.30](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.29...@availity/mui-spaces@1.0.30) (2025-08-21)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * spaces link full url only if starts with web ([5db57d4](https://github.com/Availity/element/commit/5db57d4c0e58f1b1c98b95186b6600ebb9d44493))
13
+
5
14
  ## [1.0.29](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.28...@availity/mui-spaces@1.0.29) (2025-07-02)
6
15
 
7
16
 
package/dist/index.js CHANGED
@@ -118,7 +118,7 @@ var spacesReducer = (state, action) => {
118
118
  const { type } = action;
119
119
  return actions[type](state, action);
120
120
  };
121
- var fetchSpaces = (_0) => __async(void 0, [_0], function* ({ query, clientId, variables }) {
121
+ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables }) {
122
122
  const headers = {};
123
123
  if (clientId) {
124
124
  headers["X-Client-ID"] = clientId;
@@ -144,7 +144,7 @@ var fetchSpaces = (_0) => __async(void 0, [_0], function* ({ query, clientId, va
144
144
  hasNextPage
145
145
  };
146
146
  });
147
- var fetchAllSpaces = (_0) => __async(void 0, [_0], function* ({
147
+ var fetchAllSpaces = (_0) => __async(null, [_0], function* ({
148
148
  query,
149
149
  clientId,
150
150
  variables,
@@ -330,7 +330,7 @@ var getLocalStorageTopApps = (akaname) => {
330
330
  const topAppsValues = getItemLocalStorage(`${TOP_APPS.KEYS.VALUES}-${akaname}`);
331
331
  return topAppsValues;
332
332
  };
333
- var updateTopApps = (space, akaname) => __async(void 0, null, function* () {
333
+ var updateTopApps = (space, akaname) => __async(null, null, function* () {
334
334
  if (!space.configurationId || !space.type) return;
335
335
  if (canTrackSpace(space.configurationId, space.type)) {
336
336
  const today = (0, import_dayjs.default)();
@@ -363,7 +363,7 @@ var disclaimerQuery = `query disclaimerFindOne($id: ID!) {
363
363
  var DisclaimerModal = ({ disclaimerId }) => {
364
364
  const [disclaimer, setDisclaimer] = (0, import_react.useState)("");
365
365
  (0, import_react.useEffect)(() => {
366
- const fetchDisclaimer = () => __async(void 0, null, function* () {
366
+ const fetchDisclaimer = () => __async(null, null, function* () {
367
367
  if (disclaimerId) {
368
368
  const result = yield import_api_axios2.avWebQLApi.create({ query: disclaimerQuery, variables: { id: disclaimerId } });
369
369
  setDisclaimer(result.data.data.configurationFindOne.description);
@@ -616,14 +616,14 @@ var Spaces = ({
616
616
  }
617
617
  if (spaceIds && spaceIds.length > 0) {
618
618
  for (const id of spaceIds) {
619
- if (!(spacesMap.has(id) || configIdsMap.has(id))) {
619
+ if (id && typeof id === "string" && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
620
620
  spaceIdsToQuery.add(id);
621
621
  }
622
622
  }
623
623
  }
624
624
  if (payerIds && payerIds.length > 0) {
625
625
  for (const pid of payerIds) {
626
- if (!payerIdsMap.has(pid)) {
626
+ if (pid && typeof pid === "string" && pid.trim() && !payerIdsMap.has(pid)) {
627
627
  payerIdsToQuery.add(pid);
628
628
  }
629
629
  }
@@ -780,7 +780,7 @@ var import_hooks = require("@availity/hooks");
780
780
  // src/lib/SpacesLink/linkHandlers.tsx
781
781
  var import_native_form = __toESM(require("@availity/native-form"));
782
782
  var import_resolve_url2 = require("@availity/resolve-url");
783
- var openLink = (space, params) => __async(void 0, null, function* () {
783
+ var openLink = (space, params) => __async(null, null, function* () {
784
784
  var _a, _b, _c;
785
785
  if (!((_a = space == null ? void 0 : space.link) == null ? void 0 : _a.url)) {
786
786
  return;
@@ -791,14 +791,14 @@ var openLink = (space, params) => __async(void 0, null, function* () {
791
791
  const needsSpaceId = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) || essentialsDomainRegex.test(space.link.url);
792
792
  const urlWithParams = needsSpaceId ? updateUrl(space.link.url, "spaceId", spaceId) : space.link.url;
793
793
  let url = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
794
- if (!(0, import_resolve_url2.isAbsoluteUrl)(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
794
+ if (!(0, import_resolve_url2.isAbsoluteUrl)(url) && !essentialsDomainRegex.test(document.referrer) && /^\/web\/|\/public\/(apps|spaces)/.test(url)) {
795
795
  const referrer = new URL(document.referrer);
796
796
  url = `${referrer.origin}${url}`;
797
797
  }
798
798
  const target = getTarget(space.link.target);
799
799
  window.open(url, target);
800
800
  });
801
- var openLinkWithSso = (_0, _1) => __async(void 0, [_0, _1], function* (space, { akaname, clientId, payerSpaceId, ssoParams }) {
801
+ var openLinkWithSso = (_0, _1) => __async(null, [_0, _1], function* (space, { akaname, clientId, payerSpaceId, ssoParams }) {
802
802
  var _a, _b;
803
803
  if (space.meta && space.meta.ssoId) {
804
804
  let options;
package/dist/index.mjs CHANGED
@@ -76,7 +76,7 @@ var spacesReducer = (state, action) => {
76
76
  const { type } = action;
77
77
  return actions[type](state, action);
78
78
  };
79
- var fetchSpaces = (_0) => __async(void 0, [_0], function* ({ query, clientId, variables }) {
79
+ var fetchSpaces = (_0) => __async(null, [_0], function* ({ query, clientId, variables }) {
80
80
  const headers = {};
81
81
  if (clientId) {
82
82
  headers["X-Client-ID"] = clientId;
@@ -102,7 +102,7 @@ var fetchSpaces = (_0) => __async(void 0, [_0], function* ({ query, clientId, va
102
102
  hasNextPage
103
103
  };
104
104
  });
105
- var fetchAllSpaces = (_0) => __async(void 0, [_0], function* ({
105
+ var fetchAllSpaces = (_0) => __async(null, [_0], function* ({
106
106
  query,
107
107
  clientId,
108
108
  variables,
@@ -288,7 +288,7 @@ var getLocalStorageTopApps = (akaname) => {
288
288
  const topAppsValues = getItemLocalStorage(`${TOP_APPS.KEYS.VALUES}-${akaname}`);
289
289
  return topAppsValues;
290
290
  };
291
- var updateTopApps = (space, akaname) => __async(void 0, null, function* () {
291
+ var updateTopApps = (space, akaname) => __async(null, null, function* () {
292
292
  if (!space.configurationId || !space.type) return;
293
293
  if (canTrackSpace(space.configurationId, space.type)) {
294
294
  const today = dayjs();
@@ -321,7 +321,7 @@ var disclaimerQuery = `query disclaimerFindOne($id: ID!) {
321
321
  var DisclaimerModal = ({ disclaimerId }) => {
322
322
  const [disclaimer, setDisclaimer] = useState("");
323
323
  useEffect(() => {
324
- const fetchDisclaimer = () => __async(void 0, null, function* () {
324
+ const fetchDisclaimer = () => __async(null, null, function* () {
325
325
  if (disclaimerId) {
326
326
  const result = yield avWebQLApi2.create({ query: disclaimerQuery, variables: { id: disclaimerId } });
327
327
  setDisclaimer(result.data.data.configurationFindOne.description);
@@ -574,14 +574,14 @@ var Spaces = ({
574
574
  }
575
575
  if (spaceIds && spaceIds.length > 0) {
576
576
  for (const id of spaceIds) {
577
- if (!(spacesMap.has(id) || configIdsMap.has(id))) {
577
+ if (id && typeof id === "string" && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
578
578
  spaceIdsToQuery.add(id);
579
579
  }
580
580
  }
581
581
  }
582
582
  if (payerIds && payerIds.length > 0) {
583
583
  for (const pid of payerIds) {
584
- if (!payerIdsMap.has(pid)) {
584
+ if (pid && typeof pid === "string" && pid.trim() && !payerIdsMap.has(pid)) {
585
585
  payerIdsToQuery.add(pid);
586
586
  }
587
587
  }
@@ -738,7 +738,7 @@ import { useCurrentUser } from "@availity/hooks";
738
738
  // src/lib/SpacesLink/linkHandlers.tsx
739
739
  import nativeForm from "@availity/native-form";
740
740
  import { isAbsoluteUrl as isAbsoluteUrl2 } from "@availity/resolve-url";
741
- var openLink = (space, params) => __async(void 0, null, function* () {
741
+ var openLink = (space, params) => __async(null, null, function* () {
742
742
  var _a, _b, _c;
743
743
  if (!((_a = space == null ? void 0 : space.link) == null ? void 0 : _a.url)) {
744
744
  return;
@@ -749,14 +749,14 @@ var openLink = (space, params) => __async(void 0, null, function* () {
749
749
  const needsSpaceId = !isAbsoluteUrl2(space.link.url) || essentialsDomainRegex.test(space.link.url);
750
750
  const urlWithParams = needsSpaceId ? updateUrl(space.link.url, "spaceId", spaceId) : space.link.url;
751
751
  let url = !isAbsoluteUrl2(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
752
- if (!isAbsoluteUrl2(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
752
+ if (!isAbsoluteUrl2(url) && !essentialsDomainRegex.test(document.referrer) && /^\/web\/|\/public\/(apps|spaces)/.test(url)) {
753
753
  const referrer = new URL(document.referrer);
754
754
  url = `${referrer.origin}${url}`;
755
755
  }
756
756
  const target = getTarget(space.link.target);
757
757
  window.open(url, target);
758
758
  });
759
- var openLinkWithSso = (_0, _1) => __async(void 0, [_0, _1], function* (space, { akaname, clientId, payerSpaceId, ssoParams }) {
759
+ var openLinkWithSso = (_0, _1) => __async(null, [_0, _1], function* (space, { akaname, clientId, payerSpaceId, ssoParams }) {
760
760
  var _a, _b;
761
761
  if (space.meta && space.meta.ssoId) {
762
762
  let options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-spaces",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Availity MUI Spaces Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -3,6 +3,7 @@ import { useState } from 'react';
3
3
  import { render, waitFor, fireEvent } from '@testing-library/react';
4
4
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5
5
  import { Spaces, useSpaces, useSpacesContext } from '..';
6
+ import { fetchAllSpaces } from './spaces-data';
6
7
 
7
8
  // eslint-disable-next-line @nx/enforce-module-boundaries
8
9
  import { server } from '../../../mock/src/lib/server';
@@ -258,3 +259,95 @@ it('returns first payer space with when no spaceId passed', async () => {
258
259
  expect(spc1).toBeDefined();
259
260
  expect(spc2).toBeDefined();
260
261
  });
262
+ describe('ID validation', () => {
263
+ let mockFetchAllSpaces: jest.SpyInstance;
264
+
265
+ beforeEach(() => {
266
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
267
+ mockFetchAllSpaces = jest.spyOn(require('./spaces-data'), 'fetchAllSpaces').mockResolvedValue([]);
268
+ });
269
+
270
+ afterEach(() => {
271
+ mockFetchAllSpaces.mockRestore();
272
+ });
273
+
274
+ it('filters invalid spaceIds before querying', async () => {
275
+ mockFetchAllSpaces.mockResolvedValue([]);
276
+ const queryClient = new QueryClient();
277
+
278
+ render(
279
+ <QueryClientProvider client={queryClient}>
280
+ <Spaces spaceIds={['valid-id', null, undefined, '', ' ', 123 as any] as any}>
281
+ <div>test</div>
282
+ </Spaces>
283
+ </QueryClientProvider>
284
+ );
285
+
286
+ await waitFor(() => {
287
+ expect(mockFetchAllSpaces).toHaveBeenCalledWith(
288
+ expect.objectContaining({
289
+ variables: expect.objectContaining({
290
+ ids: ['valid-id'],
291
+ }),
292
+ })
293
+ );
294
+ });
295
+ });
296
+
297
+ it('avoids querying if no valid spaceIds exist', async () => {
298
+ mockFetchAllSpaces.mockResolvedValue([]);
299
+ const queryClient = new QueryClient();
300
+
301
+ render(
302
+ <QueryClientProvider client={queryClient}>
303
+ <Spaces spaceIds={[null, undefined, '', ' ', 123 as any] as any}>
304
+ <div>test</div>
305
+ </Spaces>
306
+ </QueryClientProvider>
307
+ );
308
+
309
+ await waitFor(() => {
310
+ expect(mockFetchAllSpaces).not.toHaveBeenCalled();
311
+ });
312
+ });
313
+
314
+ it('filters invalid payerIds before querying', async () => {
315
+ mockFetchAllSpaces.mockResolvedValue([]);
316
+ const queryClient = new QueryClient();
317
+
318
+ render(
319
+ <QueryClientProvider client={queryClient}>
320
+ <Spaces payerIds={['valid-payer', null, undefined, '', ' ', 456 as any] as any}>
321
+ <div>test</div>
322
+ </Spaces>
323
+ </QueryClientProvider>
324
+ );
325
+
326
+ await waitFor(() => {
327
+ expect(mockFetchAllSpaces).toHaveBeenCalledWith(
328
+ expect.objectContaining({
329
+ variables: expect.objectContaining({
330
+ payerIDs: ['valid-payer'],
331
+ }),
332
+ })
333
+ );
334
+ });
335
+ });
336
+
337
+ it('avoids querying if no valid payerIds exist', async () => {
338
+ mockFetchAllSpaces.mockResolvedValue([]);
339
+ const queryClient = new QueryClient();
340
+
341
+ render(
342
+ <QueryClientProvider client={queryClient}>
343
+ <Spaces payerIds={[null, undefined, '', ' ', 456 as any] as any}>
344
+ <div>test</div>
345
+ </Spaces>
346
+ </QueryClientProvider>
347
+ );
348
+
349
+ await waitFor(() => {
350
+ expect(mockFetchAllSpaces).not.toHaveBeenCalled();
351
+ });
352
+ });
353
+ });
@@ -57,7 +57,7 @@ export const Spaces = ({
57
57
 
58
58
  if (spaceIds && spaceIds.length > 0) {
59
59
  for (const id of spaceIds) {
60
- if (!(spacesMap.has(id) || configIdsMap.has(id))) {
60
+ if (id && typeof id === 'string' && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
61
61
  spaceIdsToQuery.add(id);
62
62
  }
63
63
  }
@@ -65,7 +65,7 @@ export const Spaces = ({
65
65
 
66
66
  if (payerIds && payerIds.length > 0) {
67
67
  for (const pid of payerIds) {
68
- if (!payerIdsMap.has(pid)) {
68
+ if (pid && typeof pid === 'string' && pid.trim() && !payerIdsMap.has(pid)) {
69
69
  payerIdsToQuery.add(pid);
70
70
  }
71
71
  }
@@ -20,7 +20,7 @@ export const openLink: OpenLink = async (space, params) => {
20
20
 
21
21
  let url = !isAbsoluteUrl(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
22
22
 
23
- if (!isAbsoluteUrl(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
23
+ if (!isAbsoluteUrl(url) && !essentialsDomainRegex.test(document.referrer) && /^\/web\/|\/public\/(apps|spaces)/.test(url)) {
24
24
  const referrer = new URL(document.referrer);
25
25
  url = `${referrer.origin}${url}`
26
26
  }