@availity/mui-menu 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,11 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## 0.1.0 (2023-06-06)
6
+
7
+
8
+ ### Features
9
+
10
+ * **mui-menu:** add menu component ([5cc8b1f](https://github.com/Availity/element/commit/5cc8b1f15e0aa987135e0bbac99943f2f46f6287))
11
+ * **mui-menu:** omit menu props ([b81152a](https://github.com/Availity/element/commit/b81152a0f7804d34055962617f32194b02f2557f))
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @availity/mui-menu
2
+
3
+ > Availity MUI Menu component to be used with @availity/element design system.
4
+
5
+ [![Version](https://img.shields.io/npm/v/@availity/mui-menu.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/mui-menu)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/@availity/mui-menu.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/mui-menu)
7
+ [![Dependency Status](https://img.shields.io/librariesio/release/npm/@availity/mui-menu?style=for-the-badge)](https://github.com/Availity/element/blob/main/packages/mui-menu/package.json)
8
+
9
+ ## Documentation
10
+
11
+ This package extends the MUI Menu component: [MUI Menu Docs](https://mui.com/components/menu/)
12
+
13
+ Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/components-menu-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-menu
41
+ ```
42
+
43
+ #### Yarn
44
+
45
+ ```bash
46
+ yarn add @availity/mui-menu
47
+ ```
48
+
49
+ ### Usage
50
+
51
+ #### Import through @availity/element
52
+
53
+ ```tsx
54
+ import { Menu } from '@availity/element';
55
+ ```
56
+
57
+ #### Direct import
58
+
59
+ ```tsx
60
+ import { Menu } from '@availity/mui-menu';
61
+ ```
@@ -0,0 +1,10 @@
1
+ import { MenuProps as MenuProps$1, MenuItemProps as MenuItemProps$1, MenuListProps as MenuListProps$1 } from '@mui/material';
2
+
3
+ type MenuProps = Omit<MenuProps$1, 'BackdropComponent' | 'BackdropProps' | 'classes' | 'disableAutoFocusItem' | 'disableEnforceFocus' | 'disableEscapeKeyDown' | 'onBackdropClick' | 'PopoverClasses' | 'ref' | 'sx' | 'TransitionComponent' | 'TransitionProps'>;
4
+ declare const Menu: (props: MenuProps) => JSX.Element;
5
+ type MenuItemProps = MenuItemProps$1;
6
+ declare const MenuItem: (props: MenuItemProps) => JSX.Element;
7
+ type MenuListProps = MenuListProps$1;
8
+ declare const MenuList: (props: MenuListProps) => JSX.Element;
9
+
10
+ export { Menu, MenuItem, MenuItemProps, MenuList, MenuListProps, MenuProps };
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
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
+ Menu: () => Menu,
24
+ MenuItem: () => MenuItem,
25
+ MenuList: () => MenuList
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/lib/Menu.tsx
30
+ var import_material = require("@mui/material");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ var Menu = (props) => {
33
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Menu, {
34
+ ...props
35
+ });
36
+ };
37
+ var MenuItem = (props) => {
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, {
39
+ ...props
40
+ });
41
+ };
42
+ var MenuList = (props) => {
43
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuList, {
44
+ ...props
45
+ });
46
+ };
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ Menu,
50
+ MenuItem,
51
+ MenuList
52
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,27 @@
1
+ // src/lib/Menu.tsx
2
+ import {
3
+ Menu as MuiMenu,
4
+ MenuItem as MuiMenuItem,
5
+ MenuList as MuiMenuList
6
+ } from "@mui/material";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var Menu = (props) => {
9
+ return /* @__PURE__ */ jsx(MuiMenu, {
10
+ ...props
11
+ });
12
+ };
13
+ var MenuItem = (props) => {
14
+ return /* @__PURE__ */ jsx(MuiMenuItem, {
15
+ ...props
16
+ });
17
+ };
18
+ var MenuList = (props) => {
19
+ return /* @__PURE__ */ jsx(MuiMenuList, {
20
+ ...props
21
+ });
22
+ };
23
+ export {
24
+ Menu,
25
+ MenuItem,
26
+ MenuList
27
+ };
@@ -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/Menu/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: 'menu',
6
+ coverageDirectory: '../../coverage/menu',
7
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@availity/mui-menu",
3
+ "version": "0.1.0",
4
+ "description": "Availity MUI Menu 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-menu-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/menu"
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-menu",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/menu/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "lint": {
9
+ "executor": "@nrwl/linter:eslint",
10
+ "options": {
11
+ "eslintConfig": ".eslintrc.json",
12
+ "lintFilePatterns": ["packages/menu/**/*.{js,ts}"],
13
+ "silent": false,
14
+ "fix": false,
15
+ "cache": true,
16
+ "cacheLocation": "./node_modules/.cache/menu/.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/menu"],
27
+ "options": {
28
+ "jestConfig": "packages/menu/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/Menu';
@@ -0,0 +1,61 @@
1
+ // Each exported component in the package should have its own stories file
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { Button } from '@availity/mui-button';
5
+ import { Menu, MenuItem } from './Menu';
6
+
7
+ const meta: Meta<typeof Menu> = {
8
+ title: 'Components/Menu/Menu',
9
+ component: Menu,
10
+ tags: ['autodocs'],
11
+ };
12
+
13
+ export default meta;
14
+
15
+ export const _Menu: StoryObj<typeof Menu> = {
16
+ render: ({ open, ...args }) => {
17
+ const anchorEl = useRef<HTMLButtonElement>(null);
18
+ const [controlledOpen, setControlledOpen] = useState(false);
19
+
20
+ useEffect(() => {
21
+ setControlledOpen(open);
22
+ }, [open]);
23
+
24
+ const handleClick = () => {
25
+ setControlledOpen((prev) => !prev);
26
+ };
27
+
28
+ const handleClose = () => {
29
+ setControlledOpen(false);
30
+ };
31
+
32
+ return (
33
+ <>
34
+ <Button
35
+ id="basic-button"
36
+ aria-controls={open ? 'basic-menu' : undefined}
37
+ aria-haspopup="true"
38
+ aria-expanded={open ? 'true' : undefined}
39
+ onClick={handleClick}
40
+ ref={anchorEl}
41
+ >
42
+ Dashboard
43
+ </Button>
44
+ <Menu
45
+ id="basic-menu"
46
+ anchorEl={anchorEl.current}
47
+ open={controlledOpen}
48
+ onClose={handleClose}
49
+ MenuListProps={{
50
+ 'aria-labelledby': 'basic-button',
51
+ }}
52
+ {...args}
53
+ >
54
+ <MenuItem onClick={handleClose}>Profile</MenuItem>
55
+ <MenuItem onClick={handleClose}>My account</MenuItem>
56
+ <MenuItem onClick={handleClose}>Logout</MenuItem>
57
+ </Menu>
58
+ </>
59
+ );
60
+ },
61
+ };
@@ -0,0 +1,22 @@
1
+ import { render } from '@testing-library/react';
2
+ import { Menu, MenuItem } from './Menu';
3
+
4
+ describe('Menu', () => {
5
+ test('should show menu items', () => {
6
+ const { getByText } = render(
7
+ <Menu open>
8
+ <MenuItem>Test</MenuItem>
9
+ </Menu>
10
+ );
11
+ expect(getByText('Test')).toBeTruthy();
12
+ });
13
+
14
+ test('should hide when not open', () => {
15
+ const { getByText } = render(
16
+ <Menu open={false}>
17
+ <MenuItem>Test</MenuItem>
18
+ </Menu>
19
+ );
20
+ expect(() => getByText('Test')).toThrowError();
21
+ });
22
+ });
@@ -0,0 +1,40 @@
1
+ import {
2
+ Menu as MuiMenu,
3
+ MenuProps as MuiMenuProps,
4
+ MenuItem as MuiMenuItem,
5
+ MenuItemProps as MuiMenuItemProps,
6
+ MenuList as MuiMenuList,
7
+ MenuListProps as MuiMenuListProps,
8
+ } from '@mui/material';
9
+
10
+ export type MenuProps = Omit<
11
+ MuiMenuProps,
12
+ | 'BackdropComponent'
13
+ | 'BackdropProps'
14
+ | 'classes'
15
+ | 'disableAutoFocusItem'
16
+ | 'disableEnforceFocus'
17
+ | 'disableEscapeKeyDown'
18
+ | 'onBackdropClick'
19
+ | 'PopoverClasses'
20
+ | 'ref'
21
+ | 'sx'
22
+ | 'TransitionComponent'
23
+ | 'TransitionProps'
24
+ >;
25
+
26
+ export const Menu = (props: MenuProps): JSX.Element => {
27
+ return <MuiMenu {...props} />;
28
+ };
29
+
30
+ export type MenuItemProps = MuiMenuItemProps;
31
+
32
+ export const MenuItem = (props: MenuItemProps) => {
33
+ return <MuiMenuItem {...props} />;
34
+ };
35
+
36
+ export type MenuListProps = MuiMenuListProps;
37
+
38
+ export const MenuList = (props: MenuListProps) => {
39
+ return <MuiMenuList {...props} />;
40
+ };
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
+ }