@availity/mui-spaces 0.1.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 +19 -0
- package/README.md +61 -0
- package/dist/index.d.mts +104 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.js +456 -0
- package/dist/index.mjs +428 -0
- package/introduction.stories.mdx +7 -0
- package/jest.config.js +7 -0
- package/package.json +59 -0
- package/project.json +41 -0
- package/src/index.ts +1 -0
- package/src/lib/Spaces.stories.tsx +75 -0
- package/src/lib/Spaces.test.tsx +265 -0
- package/src/lib/Spaces.tsx +202 -0
- package/src/lib/configurationFindMany.tsx +105 -0
- package/src/lib/helpers.test.tsx +26 -0
- package/src/lib/helpers.tsx +15 -0
- package/src/lib/spaces-data.test.tsx +57 -0
- package/src/lib/spaces-data.tsx +116 -0
- package/src/lib/spaces-types.tsx +136 -0
- package/src/lib/topApps.test.tsx +93 -0
- package/src/lib/topApps.tsx +65 -0
- package/tsconfig.json +5 -0
- package/tsconfig.spec.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (2024-05-17)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-button` updated to version `0.1.0`
|
|
10
|
+
* `mui-modal` updated to version `0.1.0`
|
|
11
|
+
* `mui-typography` updated to version `0.1.0`
|
|
12
|
+
* `mui-paper` updated to version `0.1.0`
|
|
13
|
+
* `mui-divider` updated to version `0.1.0`
|
|
14
|
+
* `mui-layout` updated to version `0.1.0`
|
|
15
|
+
* `@availity/mock` updated to version `0.1.0`
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **mui-spaces:** initial commit ([b0f84a1](https://github.com/Availity/element/commit/b0f84a1b53fe1fe47feba8a2784741dae9445ea9))
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @availity/mui-spaces
|
|
2
|
+
|
|
3
|
+
> Availity MUI Spaces component to be used with @availity/element design system.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@availity/mui-spaces)
|
|
6
|
+
[](https://www.npmjs.com/package/@availity/mui-spaces)
|
|
7
|
+
[](https://github.com/Availity/element/blob/main/packages/mui-spaces/package.json)
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
This package extends the MUI Spaces component: [MUI Spaces Docs](https://mui.com/components/spaces/)
|
|
12
|
+
|
|
13
|
+
Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/components-spaces-introduction--docs)
|
|
14
|
+
|
|
15
|
+
Availity standards for design and usage can be found in the [Availity Design Guide](https://zeroheight.com/2e36e50c7)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### Import Through @availity/element (Recommended)
|
|
20
|
+
|
|
21
|
+
#### NPM
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @availity/element
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### Yarn
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add @availity/element
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Direct Import
|
|
34
|
+
|
|
35
|
+
#### NPM
|
|
36
|
+
|
|
37
|
+
_This package has a few peer dependencies. Add `@mui/material` & `@emotion/react` to your project if not already installed._
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @availity/mui-spaces
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Yarn
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn add @availity/mui-spaces
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Usage
|
|
50
|
+
|
|
51
|
+
#### Import through @availity/element
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Spaces } from '@availity/element';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Direct import
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Spaces } from '@availity/mui-spaces';
|
|
61
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
type NameValuePair = {
|
|
4
|
+
/** The key of the of the data. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** The value of the data. */
|
|
7
|
+
value: string;
|
|
8
|
+
};
|
|
9
|
+
type Space = {
|
|
10
|
+
/** The name of the content or configuration. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** The configuration type. */
|
|
13
|
+
type: string;
|
|
14
|
+
/** Globally unique ID associated with the configuration object. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** The ID used to identify the configuration. */
|
|
17
|
+
configurationId: string;
|
|
18
|
+
/** A list of payerIds for the configuration or content. */
|
|
19
|
+
payerIDs?: string[];
|
|
20
|
+
/** The images associated with the configuration. */
|
|
21
|
+
images?: NameValuePair[];
|
|
22
|
+
/** Key-value data for a configuration. */
|
|
23
|
+
metadata?: NameValuePair[];
|
|
24
|
+
/** The feature box colors associated with the Payer Space. */
|
|
25
|
+
colors?: NameValuePair[];
|
|
26
|
+
/** Contains URL fragments that point to icons. */
|
|
27
|
+
icons?: NameValuePair[];
|
|
28
|
+
/** The key-value mapping pairs. */
|
|
29
|
+
mapping?: NameValuePair[];
|
|
30
|
+
};
|
|
31
|
+
type NormalizedPairField = {
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
};
|
|
34
|
+
interface NormalizedSpace extends Omit<Space, 'images' | 'metadata' | 'colors' | 'icons' | 'mapping'> {
|
|
35
|
+
/** The images associated with the configuration. */
|
|
36
|
+
images?: NormalizedPairField;
|
|
37
|
+
/** The feature box colors associated with the Payer Space. */
|
|
38
|
+
colors?: NormalizedPairField;
|
|
39
|
+
/** Contains URL fragments that point to icons. */
|
|
40
|
+
icons?: NormalizedPairField;
|
|
41
|
+
/** Key-value data for a configuration. */
|
|
42
|
+
metadata?: NormalizedPairField;
|
|
43
|
+
/** The key-value mapping pairs. */
|
|
44
|
+
mapping?: NormalizedPairField;
|
|
45
|
+
/** URL metadata for the configuration. */
|
|
46
|
+
link?: {
|
|
47
|
+
/** Contains a URL or URL Fragment that the hyperlink points to. */
|
|
48
|
+
url: string;
|
|
49
|
+
/** Specifies where to open the linked URL. */
|
|
50
|
+
target: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
type SpacesContextType = {
|
|
54
|
+
/** Array of spaces to be passed into the Spaces provider. */
|
|
55
|
+
spaces?: Map<string, Space>;
|
|
56
|
+
/** Array of spaces from previous page load. */
|
|
57
|
+
previousSpacesMap?: Map<string, Space>;
|
|
58
|
+
/** Array of spaces organized by configurationId. */
|
|
59
|
+
spacesByConfig?: Map<string, Space>;
|
|
60
|
+
/** Array of spaces organized by configurationId from previous page load. */
|
|
61
|
+
previousSpacesByConfigMap?: Map<string, Space>;
|
|
62
|
+
/** Array of spaces organized by payerId. */
|
|
63
|
+
spacesByPayer?: Map<string, Space[]>;
|
|
64
|
+
/** Array of spaces organized by payerId from previous page load. */
|
|
65
|
+
previousSpacesByPayerMap?: Map<string, Space[]>;
|
|
66
|
+
/** Whether or not spaces are loading. */
|
|
67
|
+
loading: boolean;
|
|
68
|
+
/** Errors associated with fetching spaces. */
|
|
69
|
+
error?: string;
|
|
70
|
+
/** Items that live within the spaces component and can access SpacesContext. */
|
|
71
|
+
children?: React.ReactNode;
|
|
72
|
+
};
|
|
73
|
+
type SpacesProps = {
|
|
74
|
+
/** Override the default thanos query. */
|
|
75
|
+
query?: string;
|
|
76
|
+
/** Override the default variables used in the thanos query. Default: { types: [PAYERSPACE] }.
|
|
77
|
+
* If the spaces provider should contain configurations of a type other than PAYERSPACE, you must override this prop */
|
|
78
|
+
variables?: object;
|
|
79
|
+
/** The Client ID obtained from APIConnect. Must be subscribed to the thanos API. */
|
|
80
|
+
clientId: string;
|
|
81
|
+
/** Children can be a react child or render prop. */
|
|
82
|
+
children?: React.ReactNode;
|
|
83
|
+
/** Array of payerIds the Spaces provider should fetch the spaces for.
|
|
84
|
+
* Any payerIds already included in spaces will not be fetched again.
|
|
85
|
+
* Note: If a payerId is associated with more than one payer space, the order in which they are returned should not be relied upon.
|
|
86
|
+
* If a specific payer space is required, you'll need to filter the list that is returned. */
|
|
87
|
+
payerIds?: string[];
|
|
88
|
+
/** Array of spaceIds the Spaces provider should fetch the spaces for.
|
|
89
|
+
* Any spaceIds already included in spaces will not be fetched again. */
|
|
90
|
+
spaceIds?: string[];
|
|
91
|
+
/** Array of spaces to be passed into the Spaces provider.
|
|
92
|
+
* Useful for if you already have the spaces in your app and don't want the spaces provider to have to fetch them again. */
|
|
93
|
+
spaces?: Space[];
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
declare const INITIAL_STATE: {
|
|
97
|
+
loading: boolean;
|
|
98
|
+
};
|
|
99
|
+
declare const SpacesContext: react.Context<SpacesContextType>;
|
|
100
|
+
declare const useSpacesContext: () => SpacesContextType;
|
|
101
|
+
declare const Spaces: ({ query, variables, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
|
|
102
|
+
declare const useSpaces: (...ids: string[]) => NormalizedSpace[] | undefined;
|
|
103
|
+
|
|
104
|
+
export { INITIAL_STATE, Spaces, SpacesContext, useSpaces, useSpacesContext };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
type NameValuePair = {
|
|
4
|
+
/** The key of the of the data. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** The value of the data. */
|
|
7
|
+
value: string;
|
|
8
|
+
};
|
|
9
|
+
type Space = {
|
|
10
|
+
/** The name of the content or configuration. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** The configuration type. */
|
|
13
|
+
type: string;
|
|
14
|
+
/** Globally unique ID associated with the configuration object. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** The ID used to identify the configuration. */
|
|
17
|
+
configurationId: string;
|
|
18
|
+
/** A list of payerIds for the configuration or content. */
|
|
19
|
+
payerIDs?: string[];
|
|
20
|
+
/** The images associated with the configuration. */
|
|
21
|
+
images?: NameValuePair[];
|
|
22
|
+
/** Key-value data for a configuration. */
|
|
23
|
+
metadata?: NameValuePair[];
|
|
24
|
+
/** The feature box colors associated with the Payer Space. */
|
|
25
|
+
colors?: NameValuePair[];
|
|
26
|
+
/** Contains URL fragments that point to icons. */
|
|
27
|
+
icons?: NameValuePair[];
|
|
28
|
+
/** The key-value mapping pairs. */
|
|
29
|
+
mapping?: NameValuePair[];
|
|
30
|
+
};
|
|
31
|
+
type NormalizedPairField = {
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
};
|
|
34
|
+
interface NormalizedSpace extends Omit<Space, 'images' | 'metadata' | 'colors' | 'icons' | 'mapping'> {
|
|
35
|
+
/** The images associated with the configuration. */
|
|
36
|
+
images?: NormalizedPairField;
|
|
37
|
+
/** The feature box colors associated with the Payer Space. */
|
|
38
|
+
colors?: NormalizedPairField;
|
|
39
|
+
/** Contains URL fragments that point to icons. */
|
|
40
|
+
icons?: NormalizedPairField;
|
|
41
|
+
/** Key-value data for a configuration. */
|
|
42
|
+
metadata?: NormalizedPairField;
|
|
43
|
+
/** The key-value mapping pairs. */
|
|
44
|
+
mapping?: NormalizedPairField;
|
|
45
|
+
/** URL metadata for the configuration. */
|
|
46
|
+
link?: {
|
|
47
|
+
/** Contains a URL or URL Fragment that the hyperlink points to. */
|
|
48
|
+
url: string;
|
|
49
|
+
/** Specifies where to open the linked URL. */
|
|
50
|
+
target: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
type SpacesContextType = {
|
|
54
|
+
/** Array of spaces to be passed into the Spaces provider. */
|
|
55
|
+
spaces?: Map<string, Space>;
|
|
56
|
+
/** Array of spaces from previous page load. */
|
|
57
|
+
previousSpacesMap?: Map<string, Space>;
|
|
58
|
+
/** Array of spaces organized by configurationId. */
|
|
59
|
+
spacesByConfig?: Map<string, Space>;
|
|
60
|
+
/** Array of spaces organized by configurationId from previous page load. */
|
|
61
|
+
previousSpacesByConfigMap?: Map<string, Space>;
|
|
62
|
+
/** Array of spaces organized by payerId. */
|
|
63
|
+
spacesByPayer?: Map<string, Space[]>;
|
|
64
|
+
/** Array of spaces organized by payerId from previous page load. */
|
|
65
|
+
previousSpacesByPayerMap?: Map<string, Space[]>;
|
|
66
|
+
/** Whether or not spaces are loading. */
|
|
67
|
+
loading: boolean;
|
|
68
|
+
/** Errors associated with fetching spaces. */
|
|
69
|
+
error?: string;
|
|
70
|
+
/** Items that live within the spaces component and can access SpacesContext. */
|
|
71
|
+
children?: React.ReactNode;
|
|
72
|
+
};
|
|
73
|
+
type SpacesProps = {
|
|
74
|
+
/** Override the default thanos query. */
|
|
75
|
+
query?: string;
|
|
76
|
+
/** Override the default variables used in the thanos query. Default: { types: [PAYERSPACE] }.
|
|
77
|
+
* If the spaces provider should contain configurations of a type other than PAYERSPACE, you must override this prop */
|
|
78
|
+
variables?: object;
|
|
79
|
+
/** The Client ID obtained from APIConnect. Must be subscribed to the thanos API. */
|
|
80
|
+
clientId: string;
|
|
81
|
+
/** Children can be a react child or render prop. */
|
|
82
|
+
children?: React.ReactNode;
|
|
83
|
+
/** Array of payerIds the Spaces provider should fetch the spaces for.
|
|
84
|
+
* Any payerIds already included in spaces will not be fetched again.
|
|
85
|
+
* Note: If a payerId is associated with more than one payer space, the order in which they are returned should not be relied upon.
|
|
86
|
+
* If a specific payer space is required, you'll need to filter the list that is returned. */
|
|
87
|
+
payerIds?: string[];
|
|
88
|
+
/** Array of spaceIds the Spaces provider should fetch the spaces for.
|
|
89
|
+
* Any spaceIds already included in spaces will not be fetched again. */
|
|
90
|
+
spaceIds?: string[];
|
|
91
|
+
/** Array of spaces to be passed into the Spaces provider.
|
|
92
|
+
* Useful for if you already have the spaces in your app and don't want the spaces provider to have to fetch them again. */
|
|
93
|
+
spaces?: Space[];
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
declare const INITIAL_STATE: {
|
|
97
|
+
loading: boolean;
|
|
98
|
+
};
|
|
99
|
+
declare const SpacesContext: react.Context<SpacesContextType>;
|
|
100
|
+
declare const useSpacesContext: () => SpacesContextType;
|
|
101
|
+
declare const Spaces: ({ query, variables, clientId, children, payerIds, spaceIds, spaces: spacesFromProps, }: SpacesProps) => JSX.Element;
|
|
102
|
+
declare const useSpaces: (...ids: string[]) => NormalizedSpace[] | undefined;
|
|
103
|
+
|
|
104
|
+
export { INITIAL_STATE, Spaces, SpacesContext, useSpaces, useSpacesContext };
|