@availity/mui-card 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 ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## 0.1.0 (2023-07-03)
6
+
7
+
8
+ ### Features
9
+
10
+ * **mui-card:** add CardActionArea ([ddb874a](https://github.com/Availity/element/commit/ddb874a5857f494e74d4e177624d8796435634dc))
11
+ * **mui-card:** add CardActions ([e6c40f7](https://github.com/Availity/element/commit/e6c40f73ce629254f5bad9bcda66ebcec963bc17))
12
+ * **mui-card:** add CardContent ([54e7163](https://github.com/Availity/element/commit/54e716326bd73429905feb86a3f13afbcbbf2a29))
13
+ * **mui-card:** add CardHeader ([0f2a6d4](https://github.com/Availity/element/commit/0f2a6d4a321907e0a394120096efc26985aab45f))
14
+ * **mui-card:** add CardMedia ([9b4b5bd](https://github.com/Availity/element/commit/9b4b5bdba2dde82035e52ffb5db0d482e652725a))
15
+ * **mui-card:** initial commit ([0b68ac9](https://github.com/Availity/element/commit/0b68ac90897d16278d82d02a590ba884d00bb693))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **mui-card:** header lineHeights and add action example ([71456f8](https://github.com/Availity/element/commit/71456f82a5ace78ef7da752dc649dba709174e02))
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @availity/mui-card
2
+
3
+ > Availity MUI Card component to be used with @availity/element design system.
4
+
5
+ [![Version](https://img.shields.io/npm/v/@availity/mui-card.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/mui-card)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/@availity/mui-card.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/mui-card)
7
+ [![Dependency Status](https://img.shields.io/librariesio/release/npm/@availity/mui-card?style=for-the-badge)](https://github.com/Availity/element/blob/main/packages/mui-card/package.json)
8
+
9
+ ## Documentation
10
+
11
+ This package extends the MUI Card component: [MUI Card Docs](https://mui.com/components/card/)
12
+
13
+ Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/components-card-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-card
41
+ ```
42
+
43
+ #### Yarn
44
+
45
+ ```bash
46
+ yarn add @availity/mui-card
47
+ ```
48
+
49
+ ### Usage
50
+
51
+ #### Import through @availity/element
52
+
53
+ ```tsx
54
+ import { Card } from '@availity/element';
55
+ ```
56
+
57
+ #### Direct import
58
+
59
+ ```tsx
60
+ import { Card } from '@availity/mui-card';
61
+ ```
@@ -0,0 +1,8 @@
1
+ import { CardProps as CardProps$1 } from '@mui/material';
2
+
3
+ interface CardProps extends Omit<CardProps$1, 'elevation' | 'variant' | 'raised' | 'square'> {
4
+ children?: React.ReactNode;
5
+ }
6
+ declare const Card: ({ children, ...rest }: CardProps) => JSX.Element;
7
+
8
+ export { Card, CardProps };
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Card: () => Card
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+
27
+ // src/lib/Card.tsx
28
+ var import_material = require("@mui/material");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var Card = ({ children, ...rest }) => {
31
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Card, {
32
+ ...rest,
33
+ variant: "elevation",
34
+ elevation: 1,
35
+ children
36
+ });
37
+ };
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ Card
41
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ // src/lib/Card.tsx
2
+ import { Card as MuiCard } from "@mui/material";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var Card = ({ children, ...rest }) => {
5
+ return /* @__PURE__ */ jsx(MuiCard, {
6
+ ...rest,
7
+ variant: "elevation",
8
+ elevation: 1,
9
+ children
10
+ });
11
+ };
12
+ export {
13
+ Card
14
+ };
@@ -0,0 +1,7 @@
1
+ import { Markdown } from '@storybook/blocks';
2
+ import { Meta } from '@storybook/addon-docs';
3
+ import ReadMe from './README.md?raw';
4
+
5
+ <Meta title="Components/Card/Introduction" />
6
+
7
+ <Markdown>{ReadMe}</Markdown>
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ const global = require('../../jest.config.global');
2
+
3
+ module.exports = {
4
+ ...global,
5
+ displayName: 'card',
6
+ coverageDirectory: '../../coverage/card',
7
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@availity/mui-card",
3
+ "version": "0.1.0",
4
+ "description": "Availity MUI Card 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-card-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/card"
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
+ "bundlesize": "bundlesize",
32
+ "publish": "yarn npm publish --tolerate-republish --access public",
33
+ "publish:canary": "yarn npm publish --access public --tag canary"
34
+ },
35
+ "devDependencies": {
36
+ "@mui/material": "^5.11.9",
37
+ "react": "18.2.0",
38
+ "react-dom": "18.2.0",
39
+ "tsup": "^5.12.7",
40
+ "typescript": "^4.6.4"
41
+ },
42
+ "peerDependencies": {
43
+ "@mui/material": "^5.11.9",
44
+ "react": ">=16.3.0"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }
package/project.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "mui-card",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/card/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "lint": {
9
+ "executor": "@nrwl/linter:eslint",
10
+ "options": {
11
+ "eslintConfig": ".eslintrc.json",
12
+ "lintFilePatterns": ["packages/card/**/*.{js,ts}"],
13
+ "silent": false,
14
+ "fix": false,
15
+ "cache": true,
16
+ "cacheLocation": "./node_modules/.cache/card/.eslintcache",
17
+ "maxWarnings": -1,
18
+ "quiet": false,
19
+ "noEslintrc": false,
20
+ "hasTypeAwareRules": true,
21
+ "cacheStrategy": "metadata"
22
+ }
23
+ },
24
+ "test": {
25
+ "executor": "@nrwl/jest:jest",
26
+ "outputs": ["coverage/card"],
27
+ "options": {
28
+ "jestConfig": "packages/card/jest.config.js",
29
+ "passWithNoTests": true
30
+ }
31
+ },
32
+ "version": {
33
+ "executor": "@jscutlery/semver:version",
34
+ "options": {
35
+ "preset": "conventional",
36
+ "commitMessageFormat": "chore(${projectName}): release version ${version} [skip ci]",
37
+ "tagPrefix": "@availity/${projectName}@"
38
+ }
39
+ }
40
+ }
41
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/Card';
@@ -0,0 +1,34 @@
1
+ // Each exported component in the package should have its own stories file
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { Button } from '../../../button';
5
+ import { Card, CardProps } from './Card';
6
+ import { CardHeader } from './CardHeader';
7
+ import { CardMedia } from './CardMedia';
8
+ import { CardContent } from './CardContent';
9
+ import { CardActions } from './CardActions';
10
+
11
+ const meta: Meta<typeof Card> = {
12
+ title: 'Components/Card/Card',
13
+ component: Card,
14
+ tags: ['autodocs'],
15
+ };
16
+
17
+ export default meta;
18
+
19
+ export const _Card: StoryObj<typeof Card> = {
20
+ render: (args: CardProps) => (
21
+ <Card {...args}>
22
+ <CardHeader title="Card header" subheader="Subheader" />
23
+ <CardMedia sx={{ height: '100px' }} image="https://avatars.githubusercontent.com/u/329985?s=200&v=4" />
24
+ <CardContent>This is the content of the Card.</CardContent>
25
+ <CardActions>
26
+ <Button size="small" color="primary">
27
+ Submit
28
+ </Button>
29
+ <Button size="small">Cancel</Button>
30
+ </CardActions>
31
+ </Card>
32
+ ),
33
+ args: {},
34
+ };
@@ -0,0 +1,9 @@
1
+ import { render } from '@testing-library/react';
2
+ import { Card } from './Card';
3
+
4
+ describe('Card', () => {
5
+ test('should render successfully', () => {
6
+ const { getByText } = render(<Card>Test</Card>);
7
+ expect(getByText('Test')).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,13 @@
1
+ import { Card as MuiCard, CardProps as MuiCardProps } from '@mui/material';
2
+
3
+ export interface CardProps extends Omit<MuiCardProps, 'elevation' | 'variant' | 'raised' | 'square'> {
4
+ children?: React.ReactNode;
5
+ }
6
+
7
+ export const Card = ({ children, ...rest }: CardProps): JSX.Element => {
8
+ return (
9
+ <MuiCard {...rest} variant="elevation" elevation={1}>
10
+ {children}
11
+ </MuiCard>
12
+ );
13
+ };
@@ -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 { CardActionArea, CardActionAreaProps } from './CardActionArea';
5
+ import { Card } from './Card';
6
+ import { CardContent } from './CardContent';
7
+
8
+ const meta: Meta<typeof CardActionArea> = {
9
+ title: 'Components/Card/CardActionArea',
10
+ component: CardActionArea,
11
+ tags: ['autodocs'],
12
+ };
13
+
14
+ export default meta;
15
+
16
+ export const _CardActionArea: StoryObj<typeof CardActionArea> = {
17
+ render: (args: CardActionAreaProps) => (
18
+ <Card>
19
+ <CardActionArea {...args}>
20
+ <CardContent>You can click on this card</CardContent>
21
+ </CardActionArea>
22
+ </Card>
23
+ ),
24
+ args: {},
25
+ };
@@ -0,0 +1,9 @@
1
+ import { render } from '@testing-library/react';
2
+ import { CardActionArea } from './CardActionArea';
3
+
4
+ describe('CardActionArea', () => {
5
+ test('should render successfully', () => {
6
+ const { getByText } = render(<CardActionArea>Test</CardActionArea>);
7
+ expect(getByText('Test')).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,17 @@
1
+ import { CardActionArea as MuiCardActionArea, CardActionAreaProps as MuiCardActionAreaProps } from '@mui/material';
2
+
3
+ export interface CardActionAreaProps
4
+ extends Omit<
5
+ MuiCardActionAreaProps,
6
+ 'centerRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'TouchRippleProps' | 'touchRippleRef'
7
+ > {
8
+ children?: React.ReactNode;
9
+ }
10
+
11
+ export const CardActionArea = ({ children, ...rest }: CardActionAreaProps): JSX.Element => {
12
+ return (
13
+ <MuiCardActionArea {...rest} disableRipple>
14
+ {children}
15
+ </MuiCardActionArea>
16
+ );
17
+ };
@@ -0,0 +1,41 @@
1
+ // Each exported component in the package should have its own stories file
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { CardActions, CardActionsProps } from './CardActions';
5
+ import { Card } from './Card';
6
+ import { Button, IconButton } from '../../../button';
7
+ import { SearchIcon } from '@availity/mui-icon';
8
+
9
+ const meta: Meta<typeof CardActions> = {
10
+ title: 'Components/Card/CardActions',
11
+ component: CardActions,
12
+ tags: ['autodocs'],
13
+ };
14
+
15
+ export default meta;
16
+
17
+ export const _CardActions: StoryObj<typeof CardActions> = {
18
+ render: (args: CardActionsProps) => (
19
+ <Card>
20
+ <CardActions {...args}>
21
+ <Button size="small" color="primary">
22
+ Submit
23
+ </Button>
24
+ <Button size="small">Cancel</Button>
25
+ </CardActions>
26
+ </Card>
27
+ ),
28
+ args: {},
29
+ };
30
+ export const _CardActionsIconButtons: StoryObj<typeof CardActions> = {
31
+ render: (args: CardActionsProps) => (
32
+ <Card>
33
+ <CardActions {...args}>
34
+ <IconButton size="small" color="primary" title="search">
35
+ <SearchIcon />
36
+ </IconButton>
37
+ </CardActions>
38
+ </Card>
39
+ ),
40
+ args: {},
41
+ };
@@ -0,0 +1,9 @@
1
+ import { render } from '@testing-library/react';
2
+ import { CardActions } from './CardActions';
3
+
4
+ describe('CardActions', () => {
5
+ test('should render successfully', () => {
6
+ const { getByText } = render(<CardActions>Test</CardActions>);
7
+ expect(getByText('Test')).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,9 @@
1
+ import { CardActions as MuiCardActions, CardActionsProps as MuiCardActionsProps } from '@mui/material';
2
+
3
+ export interface CardActionsProps extends MuiCardActionsProps {
4
+ children?: React.ReactNode;
5
+ }
6
+
7
+ export const CardActions = ({ children, ...rest }: CardActionsProps): JSX.Element => {
8
+ return <MuiCardActions {...rest}>{children}</MuiCardActions>;
9
+ };
@@ -0,0 +1,24 @@
1
+ // Each exported component in the package should have its own stories file
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { CardContent, CardContentProps } from './CardContent';
5
+ import { Card } from './Card';
6
+
7
+ const meta: Meta<typeof CardContent> = {
8
+ title: 'Components/Card/CardContent',
9
+ component: CardContent,
10
+ tags: ['autodocs'],
11
+ };
12
+
13
+ export default meta;
14
+
15
+ export const _CardContent: StoryObj<typeof CardContent> = {
16
+ render: (args: CardContentProps) => (
17
+ <Card>
18
+ <CardContent {...args} />
19
+ </Card>
20
+ ),
21
+ args: {
22
+ children: 'This text is a child of CardContent',
23
+ },
24
+ };
@@ -0,0 +1,9 @@
1
+ import { render } from '@testing-library/react';
2
+ import { CardContent } from './CardContent';
3
+
4
+ describe('CardContent', () => {
5
+ test('should render successfully', () => {
6
+ const { getByText } = render(<CardContent>Test</CardContent>);
7
+ expect(getByText('Test')).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,9 @@
1
+ import { CardContent as MuiCardContent, CardContentProps as MuiCardContentProps } from '@mui/material';
2
+
3
+ export interface CardContentProps extends MuiCardContentProps {
4
+ children?: React.ReactNode;
5
+ }
6
+
7
+ export const CardContent = ({ children, ...rest }: CardContentProps): JSX.Element => {
8
+ return <MuiCardContent {...rest}>{children}</MuiCardContent>;
9
+ };
@@ -0,0 +1,44 @@
1
+ // Each exported component in the package should have its own stories file
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { Card } from './Card';
5
+ import { CardHeader, CardHeaderProps } from './CardHeader';
6
+ import { IconButton } from '../../../button';
7
+ import { MoreVerticalIcon } from '@availity/mui-icon';
8
+
9
+ const meta: Meta<typeof CardHeader> = {
10
+ title: 'Components/Card/CardHeader',
11
+ component: CardHeader,
12
+ tags: ['autodocs'],
13
+ };
14
+
15
+ export default meta;
16
+
17
+ export const _CardHeader: StoryObj<typeof CardHeader> = {
18
+ render: (args: CardHeaderProps) => (
19
+ <Card>
20
+ <CardHeader {...args} />
21
+ </Card>
22
+ ),
23
+ args: {
24
+ title: 'Card header',
25
+ subheader: 'Subheader',
26
+ },
27
+ };
28
+
29
+ export const _CardHeaderAction: StoryObj<typeof CardHeader> = {
30
+ render: (args: CardHeaderProps) => (
31
+ <Card>
32
+ <CardHeader {...args} />
33
+ </Card>
34
+ ),
35
+ args: {
36
+ title: 'Card header',
37
+ // subheader: 'Subheader',
38
+ action: (
39
+ <IconButton color="primary" title="More" size="medium">
40
+ <MoreVerticalIcon />
41
+ </IconButton>
42
+ ),
43
+ },
44
+ };
@@ -0,0 +1,9 @@
1
+ import { render } from '@testing-library/react';
2
+ import { CardHeader } from './CardHeader';
3
+
4
+ describe('CardHeader', () => {
5
+ test('should render successfully', () => {
6
+ const { getByText } = render(<CardHeader title="Test" />);
7
+ expect(getByText('Test')).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,15 @@
1
+ import { CardHeader as MuiCardHeader, CardHeaderProps as MuiCardHeaderProps } from '@mui/material';
2
+
3
+ export interface CardHeaderProps extends Omit<MuiCardHeaderProps, 'avatar'> {
4
+ children?: React.ReactNode;
5
+ }
6
+
7
+ export const CardHeader = ({ ...rest }: CardHeaderProps): JSX.Element => {
8
+ return (
9
+ <MuiCardHeader
10
+ {...rest}
11
+ titleTypographyProps={{ variant: 'h6' }}
12
+ subheaderTypographyProps={{ variant: 'subtitle2' }}
13
+ />
14
+ );
15
+ };
@@ -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 { CardMedia, CardMediaProps } from './CardMedia';
5
+ import { Card } from './Card';
6
+
7
+ const meta: Meta<typeof CardMedia> = {
8
+ title: 'Components/Card/CardMedia',
9
+ component: CardMedia,
10
+ tags: ['autodocs'],
11
+ };
12
+
13
+ export default meta;
14
+
15
+ export const _CardMedia: StoryObj<typeof CardMedia> = {
16
+ render: (args: CardMediaProps) => (
17
+ <Card>
18
+ <CardMedia {...args} />
19
+ </Card>
20
+ ),
21
+ args: {
22
+ image: 'https://avatars.githubusercontent.com/u/329985?s=200&v=4',
23
+ sx: { height: '100px' },
24
+ },
25
+ };
@@ -0,0 +1,9 @@
1
+ import { render } from '@testing-library/react';
2
+ import { CardMedia } from './CardMedia';
3
+
4
+ describe('CardMedia', () => {
5
+ test('should render successfully', () => {
6
+ const { getByText } = render(<CardMedia>Test</CardMedia>);
7
+ expect(getByText('Test')).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,9 @@
1
+ import { CardMedia as MuiCardMedia, CardMediaProps as MuiCardMediaProps } from '@mui/material';
2
+
3
+ export interface CardMediaProps extends MuiCardMediaProps {
4
+ children?: React.ReactNode;
5
+ }
6
+
7
+ export const CardMedia = ({ children, ...rest }: CardMediaProps): JSX.Element => {
8
+ return <MuiCardMedia {...rest}>{children}</MuiCardMedia>;
9
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["."],
4
+ "exclude": ["dist", "build", "node_modules"]
5
+ }
@@ -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
+ }