@availity/mui-datepicker 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 +20 -0
- package/README.md +61 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +50 -0
- package/dist/index.mjs +23 -0
- package/introduction.mdx +7 -0
- package/jest.config.js +7 -0
- package/package.json +53 -0
- package/project.json +42 -0
- package/src/index.ts +1 -0
- package/src/lib/Datepicker.stories.tsx +34 -0
- package/src/lib/Datepicker.test.tsx +14 -0
- package/src/lib/Datepicker.tsx +46 -0
- package/tsconfig.json +5 -0
- package/tsconfig.spec.json +10 -0
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-11-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mui-datepicker:** add datepicker component ([2efdbf5](https://github.com/Availity/element/commit/2efdbf5112583c4322d588823f0ce0b7227fde6f))
|
|
11
|
+
* **mui-datepicker:** update styles for datepicker ([b250d38](https://github.com/Availity/element/commit/b250d382691a83bfc12c066a2d4eeb9af147689f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **mui-datepicker:** add label to story ([c2b8fd2](https://github.com/Availity/element/commit/c2b8fd27904c0713e98d1af51354e7059065ddae))
|
|
17
|
+
* **mui-datepicker:** remove bundlesize ([1e02c57](https://github.com/Availity/element/commit/1e02c5714dea965c54b783a38d195f17b9be43c7))
|
|
18
|
+
* **mui-datepicker:** update padding and add help topic ([efd3487](https://github.com/Availity/element/commit/efd3487fbc6c01b9fe48187da238b8137fde1c2e))
|
|
19
|
+
* **mui-datepicker:** update styles ([1c0aa8a](https://github.com/Availity/element/commit/1c0aa8a3a2ce13df6655561236ebfaacdaceb28e))
|
|
20
|
+
* **mui-datepicker:** use updated TextField ([23caa3a](https://github.com/Availity/element/commit/23caa3a0852f0249afb9ca0ef411db106c7049df))
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @availity/mui-datepicker
|
|
2
|
+
|
|
3
|
+
> Availity MUI Datepicker component to be used with @availity/element design system.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@availity/mui-datepicker)
|
|
6
|
+
[](https://www.npmjs.com/package/@availity/mui-datepicker)
|
|
7
|
+
[](https://github.com/Availity/element/blob/main/packages/mui-datepicker/package.json)
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
This package extends the MUI Datepicker component: [MUI Datepicker Docs](https://mui.com/components/datepicker/)
|
|
12
|
+
|
|
13
|
+
Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/components-datepicker-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-datepicker
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Yarn
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn add @availity/mui-datepicker
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Usage
|
|
50
|
+
|
|
51
|
+
#### Import through @availity/element
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Datepicker } from '@availity/element';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Direct import
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Datepicker } from '@availity/mui-datepicker';
|
|
61
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TextFieldProps } from '@availity/mui-textfield';
|
|
2
|
+
import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
3
|
+
import { Dayjs } from 'dayjs';
|
|
4
|
+
|
|
5
|
+
type DatepickerProps = {
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
size?: 'small' | 'medium';
|
|
8
|
+
helperText?: string;
|
|
9
|
+
helpTopicId?: string;
|
|
10
|
+
InputProps?: TextFieldProps;
|
|
11
|
+
} & Omit<DatePickerProps<Dayjs, Dayjs>, 'components' | 'componentsProps' | 'desktopModeMediaQuery' | 'DialogProps' | 'OpenPickerButtonProps' | 'openTo' | 'orientation' | 'PaperProps' | 'PopperProps' | 'reduceAnimations' | 'renderInput' | 'rifmFormatter' | 'showToolbar' | 'ToolbarComponent' | 'toolbarFormat' | 'toolbarPlaceholder' | 'toolbarTitle' | 'TransitionComponent'>;
|
|
12
|
+
declare const Datepicker: ({ size, helperText, helpTopicId, ...props }: DatepickerProps) => JSX.Element;
|
|
13
|
+
|
|
14
|
+
export { Datepicker, DatepickerProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
Datepicker: () => Datepicker
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
|
|
27
|
+
// src/lib/Datepicker.tsx
|
|
28
|
+
var import_mui_textfield = require("@availity/mui-textfield");
|
|
29
|
+
var import_DatePicker = require("@mui/x-date-pickers/DatePicker");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var Datepicker = ({ size, helperText, helpTopicId, ...props }) => {
|
|
32
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DatePicker.DatePicker, {
|
|
33
|
+
...props,
|
|
34
|
+
renderInput: (params) => {
|
|
35
|
+
if (params.inputProps) {
|
|
36
|
+
params.inputProps.placeholder = "MM/DD/YYYY";
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_textfield.TextField, {
|
|
39
|
+
helperText,
|
|
40
|
+
helpTopicId,
|
|
41
|
+
...params,
|
|
42
|
+
size
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
Datepicker
|
|
50
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/lib/Datepicker.tsx
|
|
2
|
+
import { TextField } from "@availity/mui-textfield";
|
|
3
|
+
import { DatePicker as MuiDatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var Datepicker = ({ size, helperText, helpTopicId, ...props }) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(MuiDatePicker, {
|
|
7
|
+
...props,
|
|
8
|
+
renderInput: (params) => {
|
|
9
|
+
if (params.inputProps) {
|
|
10
|
+
params.inputProps.placeholder = "MM/DD/YYYY";
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
13
|
+
helperText,
|
|
14
|
+
helpTopicId,
|
|
15
|
+
...params,
|
|
16
|
+
size
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
Datepicker
|
|
23
|
+
};
|
package/introduction.mdx
ADDED
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@availity/mui-datepicker",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Availity MUI Datepicker 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-datepicker-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/datepicker"
|
|
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
|
+
"dependencies": {
|
|
35
|
+
"@availity/mui-textfield": "0.3.0",
|
|
36
|
+
"@mui/x-date-pickers": "^5.0.15",
|
|
37
|
+
"dayjs": "^1.11.9"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@mui/material": "^5.11.9",
|
|
41
|
+
"react": "18.2.0",
|
|
42
|
+
"react-dom": "18.2.0",
|
|
43
|
+
"tsup": "^5.12.7",
|
|
44
|
+
"typescript": "^4.6.4"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@mui/material": "^5.11.9",
|
|
48
|
+
"react": ">=16.3.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mui-datepicker",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/datepicker/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"lint": {
|
|
9
|
+
"executor": "@nrwl/linter:eslint",
|
|
10
|
+
"options": {
|
|
11
|
+
"eslintConfig": ".eslintrc.json",
|
|
12
|
+
"lintFilePatterns": ["packages/datepicker/**/*.{js,ts}"],
|
|
13
|
+
"silent": false,
|
|
14
|
+
"fix": false,
|
|
15
|
+
"cache": true,
|
|
16
|
+
"cacheLocation": "./node_modules/.cache/datepicker/.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/datepicker"],
|
|
27
|
+
"options": {
|
|
28
|
+
"jestConfig": "packages/datepicker/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 @@
|
|
|
1
|
+
export * from './lib/Datepicker';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Each exported component in the package should have its own stories file
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Dayjs } from 'dayjs';
|
|
5
|
+
import { Datepicker, DatepickerProps } from './Datepicker';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Datepicker> = {
|
|
8
|
+
title: 'Components/Datepicker/Datepicker',
|
|
9
|
+
component: Datepicker,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
export const _Datepicker: StoryObj<typeof Datepicker> = {
|
|
16
|
+
render: (args: DatepickerProps) => {
|
|
17
|
+
const [value, setValue] = useState<Dayjs | null>(null);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Datepicker
|
|
21
|
+
{...args}
|
|
22
|
+
label="Date"
|
|
23
|
+
value={value}
|
|
24
|
+
onChange={(value) => {
|
|
25
|
+
setValue(value);
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
args: {
|
|
31
|
+
helperText: 'Help text for the field',
|
|
32
|
+
helpTopicId: '1234',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { ThemeProvider } from '@availity/theme-provider';
|
|
3
|
+
import { Datepicker } from './Datepicker';
|
|
4
|
+
|
|
5
|
+
describe('Datepicker', () => {
|
|
6
|
+
test('should render successfully', () => {
|
|
7
|
+
const { getAllByText } = render(
|
|
8
|
+
<ThemeProvider>
|
|
9
|
+
<Datepicker label="Test" onChange={jest.fn()} value={null} />
|
|
10
|
+
</ThemeProvider>
|
|
11
|
+
);
|
|
12
|
+
expect(getAllByText('Test')).toBeTruthy();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TextField, TextFieldProps } from '@availity/mui-textfield';
|
|
2
|
+
import { DatePicker as MuiDatePicker, DatePickerProps as MuiDatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
3
|
+
import type { Dayjs } from 'dayjs';
|
|
4
|
+
|
|
5
|
+
export type DatepickerProps = {
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
size?: 'small' | 'medium';
|
|
8
|
+
helperText?: string;
|
|
9
|
+
helpTopicId?: string;
|
|
10
|
+
InputProps?: TextFieldProps;
|
|
11
|
+
} & Omit<
|
|
12
|
+
MuiDatePickerProps<Dayjs, Dayjs>,
|
|
13
|
+
| 'components'
|
|
14
|
+
| 'componentsProps'
|
|
15
|
+
| 'desktopModeMediaQuery'
|
|
16
|
+
| 'DialogProps'
|
|
17
|
+
| 'OpenPickerButtonProps'
|
|
18
|
+
| 'openTo'
|
|
19
|
+
| 'orientation'
|
|
20
|
+
| 'PaperProps'
|
|
21
|
+
| 'PopperProps'
|
|
22
|
+
| 'reduceAnimations'
|
|
23
|
+
| 'renderInput'
|
|
24
|
+
| 'rifmFormatter'
|
|
25
|
+
| 'showToolbar'
|
|
26
|
+
| 'ToolbarComponent'
|
|
27
|
+
| 'toolbarFormat'
|
|
28
|
+
| 'toolbarPlaceholder'
|
|
29
|
+
| 'toolbarTitle'
|
|
30
|
+
| 'TransitionComponent'
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
export const Datepicker = ({ size, helperText, helpTopicId, ...props }: DatepickerProps): JSX.Element => {
|
|
34
|
+
return (
|
|
35
|
+
<MuiDatePicker
|
|
36
|
+
{...props}
|
|
37
|
+
renderInput={(params) => {
|
|
38
|
+
if (params.inputProps) {
|
|
39
|
+
params.inputProps.placeholder = 'MM/DD/YYYY';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return <TextField helperText={helperText} helpTopicId={helpTopicId} {...params} size={size} />;
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
};
|
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
|
+
}
|