@availity/mui-spaces 0.2.5 → 0.3.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/jest.config.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const global = require('../../jest.config.global');
2
2
 
3
3
  const esModules = [
4
+ '@availity/hooks',
4
5
  'bail',
5
6
  'character-entities',
6
7
  'comma-separated-tokens',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-spaces",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "Availity MUI Spaces Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -32,37 +32,43 @@
32
32
  "publish:canary": "yarn npm publish --access public --tag canary"
33
33
  },
34
34
  "devDependencies": {
35
- "@availity/mock": "^0.0.0",
36
35
  "@availity/mui-button": "^0.6.7",
36
+ "@availity/mui-dialog": "^0.1.8",
37
37
  "@availity/mui-disclaimer": "^0.1.1",
38
+ "@availity/mui-icon": "^0.8.2",
39
+ "@availity/mui-layout": "^0.1.6",
38
40
  "@availity/mui-modal": "^0.1.4",
39
41
  "@availity/mui-typography": "^0.2.0",
40
42
  "@mui/material": "^5.15.15",
41
43
  "react": "18.2.0",
42
44
  "react-dom": "18.2.0",
43
- "react-image": "^4.1.0",
44
- "react-markdown": "^9.0.1",
45
45
  "tsup": "^8.0.2",
46
46
  "typescript": "^5.4.5"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@availity/mui-button": "^0.6.7",
50
+ "@availity/mui-dialog": "^0.1.8",
50
51
  "@availity/mui-disclaimer": "^0.1.1",
52
+ "@availity/mui-icon": "^0.8.2",
53
+ "@availity/mui-layout": "^0.1.6",
51
54
  "@availity/mui-modal": "^0.1.4",
52
55
  "@availity/mui-typography": "^0.2.0",
53
56
  "@mui/material": "^5.11.9",
54
- "react": ">=16.3.0",
55
- "react-image": "^4.1.0",
56
- "react-markdown": "^9.0.1"
57
+ "react": ">=16.3.0"
57
58
  },
58
59
  "publishConfig": {
59
60
  "access": "public"
60
61
  },
61
62
  "dependencies": {
62
63
  "@availity/api-axios": "^8.0.8",
64
+ "@availity/hooks": "^5.0.2",
63
65
  "@availity/message-core": "^6.1.3",
66
+ "@availity/native-form": "^5.0.6",
67
+ "@availity/resolve-url": "^2.0.6",
64
68
  "@tanstack/react-query": "^4.36.1",
65
69
  "dayjs": "^1.11.10",
66
- "qs": "^6.12.1"
70
+ "qs": "^6.12.1",
71
+ "react-image": "^4.1.0",
72
+ "react-markdown": "^9.0.1"
67
73
  }
68
74
  }
package/src/index.ts CHANGED
@@ -1 +1,8 @@
1
1
  export * from './lib/Spaces';
2
+ export * from './lib/SpacesLink/SpacesLink';
3
+ export * from './lib/SpacesAgreement';
4
+ export * from './lib/SpacesDisclaimer';
5
+ export * from './lib/SpacesGhostText';
6
+ export * from './lib/SpacesImage';
7
+
8
+ export type { Space } from './lib/spaces-types';
@@ -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 type { Space } from './spaces-types';
6
7
 
7
8
  // eslint-disable-next-line @nx/enforce-module-boundaries
8
9
  import { server } from '../../../mock/src/lib/server';
@@ -179,10 +180,10 @@ describe('useSpaces', () => {
179
180
  );
180
181
 
181
182
  // Check that all spaces get returned when no configurationIds get passed to useSpaces hook
182
- await waitFor(() => getByText('Id: 1 Id: 2 Id: 3'));
183
+ await waitFor(() => getByText('Id: 11 Id: 22 Id: 33'));
183
184
 
184
185
  // Check that spaces for configurationIds get returned when configurationIds passed to useSpaces hook
185
- await waitFor(() => getByText('Id: 2 Id: 3'));
186
+ await waitFor(() => getByText('Id: 22 Id: 33'));
186
187
  });
187
188
 
188
189
  it('returns all matching spaces when searching by payerId', async () => {
@@ -197,8 +198,8 @@ describe('useSpaces', () => {
197
198
  );
198
199
 
199
200
  // Check that spaces for payer ids get returned when ids passed to useSpaces hook
200
- await waitFor(() => getByText('Id: 1 Id: 2'));
201
- await waitFor(() => getByText('Id: 1 Id: 2 Id: 3'));
201
+ await waitFor(() => getByText('Id: 11 Id: 22'));
202
+ await waitFor(() => getByText('Id: 11 Id: 22 Id: 33'));
202
203
  });
203
204
 
204
205
  it('renders with warning when returning all spaces because no ids were passed in', async () => {
@@ -1,8 +1,11 @@
1
1
  import { createContext, useContext, useReducer, useEffect } from 'react';
2
2
  import { useQueries } from '@tanstack/react-query';
3
3
  import { spacesReducer, fetchAllSpaces } from './spaces-data';
4
- import { Space, SpacesProps, SpacesContextType } from './spaces-types';
5
4
  import configurationFindMany from './configurationFindMany';
5
+ import { ModalProvider } from './modals/ModalProvider';
6
+ import type { Space, SpacesProps, SpacesContextType, UseSpaces } from './spaces-types';
7
+ import type { SsoTypeSpace } from './SpacesLink/spaces-link-types';
8
+ import { isReactNodeFunction } from './helpers';
6
9
 
7
10
  export const INITIAL_STATE = {
8
11
  loading: true,
@@ -168,10 +171,16 @@ export const Spaces = ({
168
171
  });
169
172
  }, [spacesBySpaceIds, spacesByPayerIds, payerIds, spaceIds]);
170
173
 
171
- // const hasParentModalProvider = useModal() !== undefined;
174
+ const spacesChildren = () => {
175
+ if (children) {
176
+ return isReactNodeFunction(children)
177
+ ? (() => children({ spaces: [spacesMap.values()], loading, error }))()
178
+ : children;
179
+ }
180
+ };
181
+
172
182
  return (
173
183
  <SpacesContext.Provider
174
- children={children}
175
184
  value={{
176
185
  spaces: spacesMap,
177
186
  spacesByConfig: configIdsMap,
@@ -179,11 +188,13 @@ export const Spaces = ({
179
188
  loading: loading || isLoadingByPayerIds || isLoadingBySpaceIds,
180
189
  error,
181
190
  }}
182
- />
191
+ >
192
+ <ModalProvider>{spacesChildren()}</ModalProvider>
193
+ </SpacesContext.Provider>
183
194
  );
184
195
  };
185
196
 
186
- export const useSpaces = (...ids: string[]) => {
197
+ export const useSpaces: UseSpaces = (...ids) => {
187
198
  const { spaces, spacesByConfig, spacesByPayer } = useSpacesContext();
188
199
 
189
200
  const idsIsEmpty = !ids || ids.length === 0;
@@ -195,7 +206,7 @@ export const useSpaces = (...ids: string[]) => {
195
206
  return spaces && [...spaces.values()];
196
207
  }
197
208
 
198
- return ids.reduce((acc: Space[], id) => {
209
+ return ids.reduce((acc: (Space | SsoTypeSpace)[], id) => {
199
210
  const matchedSpace = spaces?.get(id) || spacesByConfig?.get(id);
200
211
 
201
212
  if (matchedSpace) {
@@ -10,7 +10,7 @@ export const SpacesGhostText = ({ spaceId, id, ...props }: SpacesGhostTextProps)
10
10
 
11
11
  const space = spaces?.[0];
12
12
 
13
- if (space?.isGhost) {
13
+ if (space?.isGhosted) {
14
14
  return (
15
15
  <small id={id || `app-ghost-text-${spaceId}`} {...props}>
16
16
  <em>{space?.meta?.ghostText}</em>
@@ -40,6 +40,6 @@ describe('SpacesImage', () => {
40
40
  await waitForElementToBeRemoved(getByRole('progressbar'));
41
41
 
42
42
  // Ensure the correct src was selected.
43
- expect(mockImage.mock.calls[0][0].src).toEqual('/element/spaces/tile.jpg');
43
+ expect(mockImage.mock.calls[0][0].src).toEqual('/spaces/tile.jpg');
44
44
  });
45
45
  });