@availity/mui-disclaimer 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 +14 -0
- package/README.md +61 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +109 -0
- package/dist/index.mjs +85 -0
- package/introduction.stories.mdx +7 -0
- package/jest.config.js +7 -0
- package/package.json +52 -0
- package/project.json +41 -0
- package/src/index.ts +1 -0
- package/src/lib/Disclaimer.stories.tsx +25 -0
- package/src/lib/Disclaimer.test.tsx +26 -0
- package/src/lib/Disclaimer.tsx +82 -0
- package/tsconfig.json +5 -0
- package/tsconfig.spec.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (2024-06-12)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-link` updated to version `0.1.0`
|
|
10
|
+
* `mui-typography` updated to version `0.1.0`
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **mui-disclaimer:** add disclaimer component ([841e989](https://github.com/Availity/element/commit/841e98900adc535171fc82865a931d802ddab96c))
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @availity/mui-disclaimer
|
|
2
|
+
|
|
3
|
+
> Availity MUI Disclaimer component to be used with @availity/element design system.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@availity/mui-disclaimer)
|
|
6
|
+
[](https://www.npmjs.com/package/@availity/mui-disclaimer)
|
|
7
|
+
[](https://github.com/Availity/element/blob/main/packages/mui-disclaimer/package.json)
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
This package extends the MUI Disclaimer component: [MUI Disclaimer Docs](https://mui.com/components/disclaimer/)
|
|
12
|
+
|
|
13
|
+
Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/components-disclaimer-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-disclaimer
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Yarn
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn add @availity/mui-disclaimer
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Usage
|
|
50
|
+
|
|
51
|
+
#### Import through @availity/element
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Disclaimer } from '@availity/element';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Direct import
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Disclaimer } from '@availity/mui-disclaimer';
|
|
61
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LinkProps } from '@availity/mui-link';
|
|
2
|
+
|
|
3
|
+
type AvDisclaimerProps = {
|
|
4
|
+
/** If true, the warning accent display on the left */
|
|
5
|
+
accent?: boolean;
|
|
6
|
+
/** If true, the Disclaimer displays with less padding */
|
|
7
|
+
dense?: boolean;
|
|
8
|
+
};
|
|
9
|
+
interface DisclaimerProps extends AvDisclaimerProps {
|
|
10
|
+
/** The text to display in the header */
|
|
11
|
+
headerText?: string;
|
|
12
|
+
/** The text to display in the body */
|
|
13
|
+
description: string;
|
|
14
|
+
/** The link to display */
|
|
15
|
+
link?: LinkProps;
|
|
16
|
+
}
|
|
17
|
+
declare const Disclaimer: ({ accent, dense, description, headerText, link, ...rest }: DisclaimerProps) => JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { Disclaimer, type DisclaimerProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LinkProps } from '@availity/mui-link';
|
|
2
|
+
|
|
3
|
+
type AvDisclaimerProps = {
|
|
4
|
+
/** If true, the warning accent display on the left */
|
|
5
|
+
accent?: boolean;
|
|
6
|
+
/** If true, the Disclaimer displays with less padding */
|
|
7
|
+
dense?: boolean;
|
|
8
|
+
};
|
|
9
|
+
interface DisclaimerProps extends AvDisclaimerProps {
|
|
10
|
+
/** The text to display in the header */
|
|
11
|
+
headerText?: string;
|
|
12
|
+
/** The text to display in the body */
|
|
13
|
+
description: string;
|
|
14
|
+
/** The link to display */
|
|
15
|
+
link?: LinkProps;
|
|
16
|
+
}
|
|
17
|
+
declare const Disclaimer: ({ accent, dense, description, headerText, link, ...rest }: DisclaimerProps) => JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { Disclaimer, type DisclaimerProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
|
|
49
|
+
// src/index.ts
|
|
50
|
+
var src_exports = {};
|
|
51
|
+
__export(src_exports, {
|
|
52
|
+
Disclaimer: () => Disclaimer
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(src_exports);
|
|
55
|
+
|
|
56
|
+
// src/lib/Disclaimer.tsx
|
|
57
|
+
var import_mui_typography = require("@availity/mui-typography");
|
|
58
|
+
var import_mui_link = require("@availity/mui-link");
|
|
59
|
+
var import_styles = require("@mui/material/styles");
|
|
60
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
|
+
var AvDisclaimer = (0, import_styles.styled)("div", {
|
|
62
|
+
name: "AvDisclaimer",
|
|
63
|
+
slot: "root",
|
|
64
|
+
overridesResolver: (props, styles) => [styles.root, props.accent && styles.accent, props.dense && styles.dense]
|
|
65
|
+
})({});
|
|
66
|
+
var AvDisclaimerHeader = (0, import_styles.styled)(import_mui_typography.Typography, {
|
|
67
|
+
name: "AvDisclaimer",
|
|
68
|
+
slot: "header"
|
|
69
|
+
})(({ ownerState }) => ({
|
|
70
|
+
marginBottom: ownerState.dense ? "4px" : "8px"
|
|
71
|
+
}));
|
|
72
|
+
var AvDisclaimerLink = (0, import_styles.styled)(import_mui_link.Link, {
|
|
73
|
+
name: "AvDisclaimer",
|
|
74
|
+
slot: "link"
|
|
75
|
+
})(({ ownerState }) => ({
|
|
76
|
+
marginTop: ownerState.dense ? "8px" : "16px",
|
|
77
|
+
display: "block"
|
|
78
|
+
}));
|
|
79
|
+
var Disclaimer = (_a) => {
|
|
80
|
+
var _b = _a, {
|
|
81
|
+
accent = true,
|
|
82
|
+
dense = false,
|
|
83
|
+
description,
|
|
84
|
+
headerText,
|
|
85
|
+
link
|
|
86
|
+
} = _b, rest = __objRest(_b, [
|
|
87
|
+
"accent",
|
|
88
|
+
"dense",
|
|
89
|
+
"description",
|
|
90
|
+
"headerText",
|
|
91
|
+
"link"
|
|
92
|
+
]);
|
|
93
|
+
let textVariant = "body1";
|
|
94
|
+
let headerVariant = "h5";
|
|
95
|
+
if (dense) {
|
|
96
|
+
textVariant = "body2";
|
|
97
|
+
headerVariant = "h6";
|
|
98
|
+
}
|
|
99
|
+
const ownerState = { dense };
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AvDisclaimer, __spreadProps(__spreadValues({ accent, dense }, rest), { children: [
|
|
101
|
+
headerText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvDisclaimerHeader, { variant: headerVariant, ownerState, color: "text.secondary", children: headerText }),
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_typography.Typography, { variant: textVariant, color: "text.secondary", children: description }),
|
|
103
|
+
link && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvDisclaimerLink, __spreadProps(__spreadValues({ ownerState }, link), { iconPosition: "end", variant: textVariant }))
|
|
104
|
+
] }));
|
|
105
|
+
};
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
Disclaimer
|
|
109
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/lib/Disclaimer.tsx
|
|
34
|
+
import { Typography } from "@availity/mui-typography";
|
|
35
|
+
import { Link } from "@availity/mui-link";
|
|
36
|
+
import { styled } from "@mui/material/styles";
|
|
37
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
38
|
+
var AvDisclaimer = styled("div", {
|
|
39
|
+
name: "AvDisclaimer",
|
|
40
|
+
slot: "root",
|
|
41
|
+
overridesResolver: (props, styles) => [styles.root, props.accent && styles.accent, props.dense && styles.dense]
|
|
42
|
+
})({});
|
|
43
|
+
var AvDisclaimerHeader = styled(Typography, {
|
|
44
|
+
name: "AvDisclaimer",
|
|
45
|
+
slot: "header"
|
|
46
|
+
})(({ ownerState }) => ({
|
|
47
|
+
marginBottom: ownerState.dense ? "4px" : "8px"
|
|
48
|
+
}));
|
|
49
|
+
var AvDisclaimerLink = styled(Link, {
|
|
50
|
+
name: "AvDisclaimer",
|
|
51
|
+
slot: "link"
|
|
52
|
+
})(({ ownerState }) => ({
|
|
53
|
+
marginTop: ownerState.dense ? "8px" : "16px",
|
|
54
|
+
display: "block"
|
|
55
|
+
}));
|
|
56
|
+
var Disclaimer = (_a) => {
|
|
57
|
+
var _b = _a, {
|
|
58
|
+
accent = true,
|
|
59
|
+
dense = false,
|
|
60
|
+
description,
|
|
61
|
+
headerText,
|
|
62
|
+
link
|
|
63
|
+
} = _b, rest = __objRest(_b, [
|
|
64
|
+
"accent",
|
|
65
|
+
"dense",
|
|
66
|
+
"description",
|
|
67
|
+
"headerText",
|
|
68
|
+
"link"
|
|
69
|
+
]);
|
|
70
|
+
let textVariant = "body1";
|
|
71
|
+
let headerVariant = "h5";
|
|
72
|
+
if (dense) {
|
|
73
|
+
textVariant = "body2";
|
|
74
|
+
headerVariant = "h6";
|
|
75
|
+
}
|
|
76
|
+
const ownerState = { dense };
|
|
77
|
+
return /* @__PURE__ */ jsxs(AvDisclaimer, __spreadProps(__spreadValues({ accent, dense }, rest), { children: [
|
|
78
|
+
headerText && /* @__PURE__ */ jsx(AvDisclaimerHeader, { variant: headerVariant, ownerState, color: "text.secondary", children: headerText }),
|
|
79
|
+
/* @__PURE__ */ jsx(Typography, { variant: textVariant, color: "text.secondary", children: description }),
|
|
80
|
+
link && /* @__PURE__ */ jsx(AvDisclaimerLink, __spreadProps(__spreadValues({ ownerState }, link), { iconPosition: "end", variant: textVariant }))
|
|
81
|
+
] }));
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
Disclaimer
|
|
85
|
+
};
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@availity/mui-disclaimer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Availity MUI Disclaimer Component - part of the @availity/element design system",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"typescript",
|
|
8
|
+
"availity",
|
|
9
|
+
"mui"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://availity.github.io/element/?path=/docs/components-disclaimer-introduction--docs",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Availity/element/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/Availity/element.git",
|
|
18
|
+
"directory": "packages/disclaimer"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Availity Developers <AVOSS@availity.com>",
|
|
22
|
+
"browser": "./dist/index.js",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
28
|
+
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"clean:nm": "rm -rf node_modules",
|
|
31
|
+
"publish": "yarn npm publish --tolerate-republish --access public",
|
|
32
|
+
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@mui/material": "^5.15.15",
|
|
36
|
+
"react": "18.2.0",
|
|
37
|
+
"react-dom": "18.2.0",
|
|
38
|
+
"tsup": "^8.0.2",
|
|
39
|
+
"typescript": "^5.4.5"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@mui/material": "^5.11.9",
|
|
43
|
+
"react": ">=16.3.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@availity/mui-link": "^0.4.0",
|
|
50
|
+
"@availity/mui-typography": "^0.1.8"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mui-disclaimer",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/disclaimer/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"lint": {
|
|
9
|
+
"executor": "@nx/eslint:lint",
|
|
10
|
+
"options": {
|
|
11
|
+
"eslintConfig": ".eslintrc.json",
|
|
12
|
+
"silent": false,
|
|
13
|
+
"fix": false,
|
|
14
|
+
"cache": true,
|
|
15
|
+
"cacheLocation": "./node_modules/.cache/disclaimer/.eslintcache",
|
|
16
|
+
"maxWarnings": -1,
|
|
17
|
+
"quiet": false,
|
|
18
|
+
"noEslintrc": false,
|
|
19
|
+
"hasTypeAwareRules": true,
|
|
20
|
+
"cacheStrategy": "metadata"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"test": {
|
|
24
|
+
"executor": "@nx/jest:jest",
|
|
25
|
+
"outputs": ["{workspaceRoot}/coverage/disclaimer"],
|
|
26
|
+
"options": {
|
|
27
|
+
"jestConfig": "packages/disclaimer/jest.config.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"version": {
|
|
31
|
+
"executor": "@jscutlery/semver:version",
|
|
32
|
+
"options": {
|
|
33
|
+
"preset": "conventional",
|
|
34
|
+
"commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
|
|
35
|
+
"tagPrefix": "@availity/{projectName}@",
|
|
36
|
+
"trackDeps": true,
|
|
37
|
+
"skipCommitTypes": ["docs"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/Disclaimer';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Each exported component in the package should have its own stories file
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import { Disclaimer, DisclaimerProps } from './Disclaimer';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Disclaimer> = {
|
|
7
|
+
title: 'Components/Disclaimer/Disclaimer',
|
|
8
|
+
component: Disclaimer,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
export const _Disclaimer: StoryObj<typeof Disclaimer> = {
|
|
15
|
+
render: (args: DisclaimerProps) => <Disclaimer {...args} />,
|
|
16
|
+
args: {
|
|
17
|
+
description: 'A description about the disclaimer.',
|
|
18
|
+
headerText: 'This is a header',
|
|
19
|
+
link: {
|
|
20
|
+
href: '#',
|
|
21
|
+
children: 'A link',
|
|
22
|
+
target: '_blank',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { Disclaimer } from './Disclaimer';
|
|
3
|
+
|
|
4
|
+
describe('Disclaimer', () => {
|
|
5
|
+
test('should render successfully', () => {
|
|
6
|
+
const { getByText } = render(
|
|
7
|
+
<Disclaimer headerText="header" description="test" link={{ href: '#', children: 'a link' }} />
|
|
8
|
+
);
|
|
9
|
+
expect(getByText('test')).toBeTruthy();
|
|
10
|
+
expect(getByText('test').classList.contains('MuiTypography-body1')).toBeTruthy();
|
|
11
|
+
expect(getByText('header')).toBeTruthy();
|
|
12
|
+
expect(getByText('header').tagName).toBe('H5');
|
|
13
|
+
expect(getByText('a link')).toBeTruthy();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('should render dense successfully', () => {
|
|
17
|
+
const { getByText } = render(
|
|
18
|
+
<Disclaimer dense headerText="header" description="test" link={{ href: '#', children: 'a link' }} />
|
|
19
|
+
);
|
|
20
|
+
expect(getByText('test')).toBeTruthy();
|
|
21
|
+
expect(getByText('test').classList.contains('MuiTypography-body2')).toBeTruthy();
|
|
22
|
+
expect(getByText('header')).toBeTruthy();
|
|
23
|
+
expect(getByText('header').tagName).toBe('H6');
|
|
24
|
+
expect(getByText('a link')).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// For bundling purposes, always use the direct import for an mui component, i.e. '@mui/material/xxx'
|
|
2
|
+
import { Typography, TypographyProps } from '@availity/mui-typography';
|
|
3
|
+
import { Link, LinkProps } from '@availity/mui-link';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
|
|
6
|
+
type AvDisclaimerProps = {
|
|
7
|
+
/** If true, the warning accent display on the left */
|
|
8
|
+
accent?: boolean;
|
|
9
|
+
/** If true, the Disclaimer displays with less padding */
|
|
10
|
+
dense?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface DisclaimerProps extends AvDisclaimerProps {
|
|
14
|
+
/** The text to display in the header */
|
|
15
|
+
headerText?: string;
|
|
16
|
+
/** The text to display in the body */
|
|
17
|
+
description: string;
|
|
18
|
+
/** The link to display */
|
|
19
|
+
link?: LinkProps;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface AvDisclaimerHeaderProps extends TypographyProps {
|
|
23
|
+
ownerState: { dense: boolean };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface AvDisclaimerLinkProps extends LinkProps {
|
|
27
|
+
ownerState: { dense: boolean };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const AvDisclaimer = styled('div', {
|
|
31
|
+
name: 'AvDisclaimer',
|
|
32
|
+
slot: 'root',
|
|
33
|
+
overridesResolver: (props, styles) => [styles.root, props.accent && styles.accent, props.dense && styles.dense],
|
|
34
|
+
})<AvDisclaimerProps>({});
|
|
35
|
+
|
|
36
|
+
const AvDisclaimerHeader = styled(Typography, {
|
|
37
|
+
name: 'AvDisclaimer',
|
|
38
|
+
slot: 'header',
|
|
39
|
+
})<AvDisclaimerHeaderProps>(({ ownerState }: { ownerState: { dense: boolean } }) => ({
|
|
40
|
+
marginBottom: ownerState.dense ? '4px' : '8px',
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
const AvDisclaimerLink = styled(Link, {
|
|
44
|
+
name: 'AvDisclaimer',
|
|
45
|
+
slot: 'link',
|
|
46
|
+
})<AvDisclaimerLinkProps>(({ ownerState }: { ownerState: { dense: boolean } }) => ({
|
|
47
|
+
marginTop: ownerState.dense ? '8px' : '16px',
|
|
48
|
+
display: 'block',
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
export const Disclaimer = ({
|
|
52
|
+
accent = true,
|
|
53
|
+
dense = false,
|
|
54
|
+
description,
|
|
55
|
+
headerText,
|
|
56
|
+
link,
|
|
57
|
+
...rest
|
|
58
|
+
}: DisclaimerProps): JSX.Element => {
|
|
59
|
+
let textVariant: 'body1' | 'body2' = 'body1';
|
|
60
|
+
let headerVariant: 'h5' | 'h6' = 'h5';
|
|
61
|
+
|
|
62
|
+
if (dense) {
|
|
63
|
+
textVariant = 'body2';
|
|
64
|
+
headerVariant = 'h6';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const ownerState = { dense };
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<AvDisclaimer accent={accent} dense={dense} {...rest}>
|
|
71
|
+
{headerText && (
|
|
72
|
+
<AvDisclaimerHeader variant={headerVariant} ownerState={ownerState} color="text.secondary">
|
|
73
|
+
{headerText}
|
|
74
|
+
</AvDisclaimerHeader>
|
|
75
|
+
)}
|
|
76
|
+
<Typography variant={textVariant} color="text.secondary">
|
|
77
|
+
{description}
|
|
78
|
+
</Typography>
|
|
79
|
+
{link && <AvDisclaimerLink ownerState={ownerState} {...link} iconPosition="end" variant={textVariant} />}
|
|
80
|
+
</AvDisclaimer>
|
|
81
|
+
);
|
|
82
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"types": ["jest", "node", "@testing-library/jest-dom"],
|
|
7
|
+
"allowJs": true
|
|
8
|
+
},
|
|
9
|
+
"include": ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
|
|
10
|
+
}
|