@availity/mui-spaces 0.2.6 → 0.3.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 +21 -0
- package/dist/index.d.mts +167 -11
- package/dist/index.d.ts +167 -11
- package/dist/index.js +1209 -10
- package/dist/index.mjs +1198 -10
- package/jest.config.js +1 -0
- package/package.json +14 -8
- package/src/index.ts +7 -0
- package/src/lib/Spaces.test.tsx +5 -4
- package/src/lib/Spaces.tsx +17 -6
- package/src/lib/SpacesGhostText.tsx +1 -1
- package/src/lib/SpacesImage.test.tsx +1 -1
- package/src/lib/SpacesLink/SpacesLink.test.tsx +605 -0
- package/src/lib/SpacesLink/SpacesLink.tsx +239 -0
- package/src/lib/SpacesLink/linkHandlers.tsx +45 -0
- package/src/lib/SpacesLink/spaces-link-types.tsx +143 -0
- package/src/lib/SpacesLink/useLink.test.tsx +280 -0
- package/src/lib/SpacesLink/useLink.tsx +111 -0
- package/src/lib/helpers.test.tsx +3 -0
- package/src/lib/helpers.tsx +26 -2
- package/src/lib/modals/DisclaimerModal.test.tsx +66 -0
- package/src/lib/modals/DisclaimerModal.tsx +34 -0
- package/src/lib/modals/ModalProvider.tsx +162 -0
- package/src/lib/modals/MultiPayerModal.test.tsx +61 -0
- package/src/lib/modals/MultiPayerModal.tsx +19 -0
- package/src/lib/modals/modal-types.tsx +91 -0
- package/src/lib/spaces-data.test.tsx +8 -3
- package/src/lib/spaces-types.tsx +16 -12
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-spaces",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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';
|
package/src/lib/Spaces.test.tsx
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
201
|
-
await waitFor(() => getByText('Id:
|
|
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 () => {
|
package/src/lib/Spaces.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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?.
|
|
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('/
|
|
43
|
+
expect(mockImage.mock.calls[0][0].src).toEqual('/spaces/tile.jpg');
|
|
44
44
|
});
|
|
45
45
|
});
|