@availity/mui-pagination 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,10 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## 0.1.0 (2023-09-11)
6
+
7
+
8
+ ### Features
9
+
10
+ * **mui-pagination:** add pagination package ([dfe53b0](https://github.com/Availity/element/commit/dfe53b0a3e3b02506fc922ca8beef70d6919b3b0))
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @availity/mui-pagination
2
+
3
+ > Availity MUI Pagination component to be used with @availity/element design system.
4
+
5
+ [![Version](https://img.shields.io/npm/v/@availity/mui-pagination.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/mui-pagination)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/@availity/mui-pagination.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/mui-pagination)
7
+ [![Dependency Status](https://img.shields.io/librariesio/release/npm/@availity/mui-pagination?style=for-the-badge)](https://github.com/Availity/element/blob/main/packages/mui-pagination/package.json)
8
+
9
+ ## Documentation
10
+
11
+ This package extends the MUI Pagination component: [MUI Pagination Docs](https://mui.com/components/pagination/)
12
+
13
+ Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/components-pagination-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-pagination
41
+ ```
42
+
43
+ #### Yarn
44
+
45
+ ```bash
46
+ yarn add @availity/mui-pagination
47
+ ```
48
+
49
+ ### Usage
50
+
51
+ #### Import through @availity/element
52
+
53
+ ```tsx
54
+ import { Pagination } from '@availity/element';
55
+ ```
56
+
57
+ #### Direct import
58
+
59
+ ```tsx
60
+ import { Pagination } from '@availity/mui-pagination';
61
+ ```
@@ -0,0 +1,9 @@
1
+ import { PaginationProps as PaginationProps$1, PaginationItemProps as PaginationItemProps$1 } from '@mui/material';
2
+
3
+ type PaginationProps = Omit<PaginationProps$1, 'color' | 'shape' | 'renderItem'>;
4
+ declare const Pagination: ({ ...rest }: PaginationProps) => JSX.Element;
5
+
6
+ type PaginationItemProps = Omit<PaginationItemProps$1, 'components' | 'color' | 'shape'>;
7
+ declare const PaginationItem: (props: PaginationItemProps) => JSX.Element;
8
+
9
+ export { Pagination, PaginationItem, PaginationItemProps, PaginationProps };
package/dist/index.js ADDED
@@ -0,0 +1,90 @@
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
+ Pagination: () => Pagination,
24
+ PaginationItem: () => PaginationItem
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/lib/Pagination.tsx
29
+ var import_material2 = require("@mui/material");
30
+
31
+ // src/lib/PaginationItem.tsx
32
+ var import_material = require("@mui/material");
33
+ var import_mui_icon = require("@availity/mui-icon");
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var slots = {
36
+ first: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
37
+ children: [
38
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_icon.NavigatePreviousIcon, {
39
+ sx: { mr: ".2rem" }
40
+ }),
41
+ " First"
42
+ ]
43
+ }),
44
+ previous: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
45
+ children: [
46
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_icon.NavigatePreviousIcon, {
47
+ sx: { mr: ".2rem" }
48
+ }),
49
+ " Prev"
50
+ ]
51
+ }),
52
+ next: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
53
+ children: [
54
+ "Next ",
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_icon.NavigateNextIcon, {
56
+ sx: { ml: ".2rem" }
57
+ })
58
+ ]
59
+ }),
60
+ last: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
61
+ children: [
62
+ "Last ",
63
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_icon.NavigateNextIcon, {
64
+ sx: { ml: ".2rem" }
65
+ })
66
+ ]
67
+ })
68
+ };
69
+ var PaginationItem = (props) => {
70
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.PaginationItem, {
71
+ slots,
72
+ ...props
73
+ });
74
+ };
75
+
76
+ // src/lib/Pagination.tsx
77
+ var import_jsx_runtime = require("react/jsx-runtime");
78
+ var Pagination = ({ ...rest }) => {
79
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material2.Pagination, {
80
+ ...rest,
81
+ renderItem: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaginationItem, {
82
+ ...item
83
+ })
84
+ });
85
+ };
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ Pagination,
89
+ PaginationItem
90
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,64 @@
1
+ // src/lib/Pagination.tsx
2
+ import {
3
+ Pagination as MuiPagination
4
+ } from "@mui/material";
5
+
6
+ // src/lib/PaginationItem.tsx
7
+ import { PaginationItem as MuiPaginationItem } from "@mui/material";
8
+ import { NavigateNextIcon, NavigatePreviousIcon } from "@availity/mui-icon";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ var slots = {
11
+ first: () => /* @__PURE__ */ jsxs(Fragment, {
12
+ children: [
13
+ /* @__PURE__ */ jsx(NavigatePreviousIcon, {
14
+ sx: { mr: ".2rem" }
15
+ }),
16
+ " First"
17
+ ]
18
+ }),
19
+ previous: () => /* @__PURE__ */ jsxs(Fragment, {
20
+ children: [
21
+ /* @__PURE__ */ jsx(NavigatePreviousIcon, {
22
+ sx: { mr: ".2rem" }
23
+ }),
24
+ " Prev"
25
+ ]
26
+ }),
27
+ next: () => /* @__PURE__ */ jsxs(Fragment, {
28
+ children: [
29
+ "Next ",
30
+ /* @__PURE__ */ jsx(NavigateNextIcon, {
31
+ sx: { ml: ".2rem" }
32
+ })
33
+ ]
34
+ }),
35
+ last: () => /* @__PURE__ */ jsxs(Fragment, {
36
+ children: [
37
+ "Last ",
38
+ /* @__PURE__ */ jsx(NavigateNextIcon, {
39
+ sx: { ml: ".2rem" }
40
+ })
41
+ ]
42
+ })
43
+ };
44
+ var PaginationItem = (props) => {
45
+ return /* @__PURE__ */ jsx(MuiPaginationItem, {
46
+ slots,
47
+ ...props
48
+ });
49
+ };
50
+
51
+ // src/lib/Pagination.tsx
52
+ import { jsx as jsx2 } from "react/jsx-runtime";
53
+ var Pagination = ({ ...rest }) => {
54
+ return /* @__PURE__ */ jsx2(MuiPagination, {
55
+ ...rest,
56
+ renderItem: (item) => /* @__PURE__ */ jsx2(PaginationItem, {
57
+ ...item
58
+ })
59
+ });
60
+ };
61
+ export {
62
+ Pagination,
63
+ PaginationItem
64
+ };
@@ -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/Pagination/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: 'pagination',
6
+ coverageDirectory: '../../coverage/pagination',
7
+ };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@availity/mui-pagination",
3
+ "version": "0.1.0",
4
+ "description": "Availity MUI Pagination 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-pagination-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/pagination"
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
+ "@availity/mui-icon": "0.4.1",
37
+ "@mui/material": "^5.11.9",
38
+ "react": "18.2.0",
39
+ "react-dom": "18.2.0",
40
+ "tsup": "^5.12.7",
41
+ "typescript": "^4.6.4"
42
+ },
43
+ "peerDependencies": {
44
+ "@availity/mui-icon": "0.4.1",
45
+ "@mui/material": "^5.11.9",
46
+ "react": ">=16.3.0"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }
package/project.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "mui-pagination",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/pagination/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "lint": {
9
+ "executor": "@nrwl/linter:eslint",
10
+ "options": {
11
+ "eslintConfig": ".eslintrc.json",
12
+ "lintFilePatterns": ["packages/pagination/**/*.{js,ts}"],
13
+ "silent": false,
14
+ "fix": false,
15
+ "cache": true,
16
+ "cacheLocation": "./node_modules/.cache/pagination/.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/pagination"],
27
+ "options": {
28
+ "jestConfig": "packages/pagination/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
+ "trackDeps": true
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/Pagination';
2
+ export * from './lib/PaginationItem';
@@ -0,0 +1,81 @@
1
+ // Each exported component in the package should have its own stories file
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { Grid } from '@mui/material';
5
+ import { Pagination, PaginationProps } from './Pagination';
6
+
7
+ const meta: Meta<typeof Pagination> = {
8
+ title: 'Components/Pagination/Pagination',
9
+ component: Pagination,
10
+ tags: ['autodocs'],
11
+ args: {
12
+ count: 10,
13
+ },
14
+ argTypes: {
15
+ size: {
16
+ table: {
17
+ defaultValue: { summary: `determined by Theme` },
18
+ },
19
+ },
20
+ },
21
+ };
22
+
23
+ export default meta;
24
+
25
+ export const _Pagination: StoryObj<typeof Pagination> = {
26
+ render: (args: PaginationProps) => <Pagination {...args} />,
27
+ };
28
+
29
+ export const _Variants: StoryObj<typeof Pagination> = {
30
+ render: () => (
31
+ <Grid container spacing={1}>
32
+ <Grid item xs={2}>
33
+ Text
34
+ </Grid>
35
+ <Grid item xs={10}>
36
+ <Pagination variant="text" count={10} />
37
+ </Grid>
38
+ <Grid item xs={2}>
39
+ Outlined
40
+ </Grid>
41
+ <Grid item xs={10}>
42
+ <Pagination variant="outlined" count={10} />
43
+ </Grid>
44
+ </Grid>
45
+ ),
46
+ };
47
+
48
+ export const _FirstLast: StoryObj<typeof Pagination> = {
49
+ render: () => (
50
+ <Grid container spacing={1}>
51
+ <Grid item xs={2}>
52
+ Text
53
+ </Grid>
54
+ <Grid item xs={10}>
55
+ <Pagination
56
+ variant="text"
57
+ count={10}
58
+ boundaryCount={0}
59
+ hideNextButton
60
+ hidePrevButton
61
+ showFirstButton
62
+ showLastButton
63
+ />
64
+ </Grid>
65
+ <Grid item xs={2}>
66
+ Outlined
67
+ </Grid>
68
+ <Grid item xs={10}>
69
+ <Pagination
70
+ variant="outlined"
71
+ count={10}
72
+ boundaryCount={0}
73
+ hideNextButton
74
+ hidePrevButton
75
+ showFirstButton
76
+ showLastButton
77
+ />
78
+ </Grid>
79
+ </Grid>
80
+ ),
81
+ };
@@ -0,0 +1,9 @@
1
+ import { render } from '@testing-library/react';
2
+ import { Pagination } from './Pagination';
3
+
4
+ describe('Pagination', () => {
5
+ test('should render successfully', () => {
6
+ const { getByRole } = render(<Pagination count={10} />);
7
+ expect(getByRole('navigation')).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,12 @@
1
+ import {
2
+ Pagination as MuiPagination,
3
+ PaginationProps as MuiPaginationProps,
4
+ PaginationPropsSizeOverrides,
5
+ } from '@mui/material';
6
+ import { PaginationItem } from './PaginationItem';
7
+
8
+ export type PaginationProps = Omit<MuiPaginationProps, 'color' | 'shape' | 'renderItem'>;
9
+
10
+ export const Pagination = ({ ...rest }: PaginationProps): JSX.Element => {
11
+ return <MuiPagination {...rest} renderItem={(item) => <PaginationItem {...item} />} />;
12
+ };
@@ -0,0 +1,76 @@
1
+ // Each exported component in the package should have its own stories file
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { Grid } from '@mui/material';
5
+ import { PaginationItem, PaginationItemProps } from './PaginationItem';
6
+
7
+ const meta: Meta<typeof PaginationItem> = {
8
+ title: 'Components/Pagination/PaginationItem',
9
+ component: PaginationItem,
10
+ tags: ['autodocs'],
11
+ args: {
12
+ type: 'next',
13
+ },
14
+ argTypes: {
15
+ size: {
16
+ table: {
17
+ defaultValue: { summary: `determined by Theme` },
18
+ },
19
+ },
20
+ },
21
+ };
22
+
23
+ export default meta;
24
+
25
+ export const _PaginationItem: StoryObj<typeof PaginationItem> = {
26
+ render: (args: PaginationItemProps) => <PaginationItem {...args} />,
27
+ };
28
+
29
+ export const _Types: StoryObj<typeof PaginationItem> = {
30
+ render: () => (
31
+ <Grid container spacing={1}>
32
+ <Grid item xs={3}>
33
+ Text
34
+ </Grid>
35
+ <Grid item xs={9}>
36
+ Outlined
37
+ </Grid>
38
+ <Grid item xs={3}>
39
+ <PaginationItem variant="text" type="page" page="1" selected />
40
+ </Grid>
41
+ <Grid item xs={9}>
42
+ <PaginationItem variant="outlined" type="page" page="1" selected />
43
+ </Grid>
44
+ <Grid item xs={3}>
45
+ <PaginationItem variant="text" type="page" page="1" />
46
+ </Grid>
47
+ <Grid item xs={9}>
48
+ <PaginationItem variant="outlined" type="page" page="1" />
49
+ </Grid>
50
+ <Grid item xs={3}>
51
+ <PaginationItem variant="text" type="first" />
52
+ </Grid>
53
+ <Grid item xs={9}>
54
+ <PaginationItem variant="outlined" type="first" />
55
+ </Grid>
56
+ <Grid item xs={3}>
57
+ <PaginationItem variant="text" type="previous" />
58
+ </Grid>
59
+ <Grid item xs={9}>
60
+ <PaginationItem variant="outlined" type="previous" />
61
+ </Grid>
62
+ <Grid item xs={3}>
63
+ <PaginationItem variant="text" type="next" />
64
+ </Grid>
65
+ <Grid item xs={9}>
66
+ <PaginationItem variant="outlined" type="next" />
67
+ </Grid>
68
+ <Grid item xs={3}>
69
+ <PaginationItem variant="text" type="last" />
70
+ </Grid>
71
+ <Grid item xs={9}>
72
+ <PaginationItem variant="outlined" type="last" />
73
+ </Grid>
74
+ </Grid>
75
+ ),
76
+ };
@@ -0,0 +1,13 @@
1
+ import { render } from '@testing-library/react';
2
+ import { PaginationItem } from './PaginationItem';
3
+
4
+ describe('PaginationItem', () => {
5
+ test('should render successfully', () => {
6
+ const { getByText } = render(<PaginationItem page={1} />);
7
+ expect(getByText('1')).toBeTruthy();
8
+ });
9
+ test('should replace default MUI prev/next iconbuttons', () => {
10
+ const { getByText } = render(<PaginationItem type="previous" />);
11
+ expect(getByText('Prev')).toBeTruthy();
12
+ });
13
+ });
@@ -0,0 +1,31 @@
1
+ import { PaginationItem as MuiPaginationItem, PaginationItemProps as MuiPaginationItemProps } from '@mui/material';
2
+ import { NavigateNextIcon, NavigatePreviousIcon } from '@availity/mui-icon';
3
+
4
+ export type PaginationItemProps = Omit<MuiPaginationItemProps, 'components' | 'color' | 'shape'>;
5
+
6
+ const slots = {
7
+ first: () => (
8
+ <>
9
+ <NavigatePreviousIcon sx={{ mr: '.2rem' }} /> First
10
+ </>
11
+ ),
12
+ previous: () => (
13
+ <>
14
+ <NavigatePreviousIcon sx={{ mr: '.2rem' }} /> Prev
15
+ </>
16
+ ),
17
+ next: () => (
18
+ <>
19
+ Next <NavigateNextIcon sx={{ ml: '.2rem' }} />
20
+ </>
21
+ ),
22
+ last: () => (
23
+ <>
24
+ Last <NavigateNextIcon sx={{ ml: '.2rem' }} />
25
+ </>
26
+ ),
27
+ };
28
+
29
+ export const PaginationItem = (props: PaginationItemProps): JSX.Element => {
30
+ return <MuiPaginationItem slots={slots} {...props} />;
31
+ };
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
+ }