@availity/mui-datepicker 0.3.0 → 0.4.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/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/package.json +2 -2
- package/src/lib/Datepicker.stories.tsx +42 -1
- package/src/lib/Datepicker.tsx +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.4.0](https://github.com/Availity/element/compare/@availity/mui-datepicker@0.3.1...@availity/mui-datepicker@0.4.0) (2024-02-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **theme:** legacy datepicker ([44c334d](https://github.com/Availity/element/commit/44c334db86701314dbbcc34adb5ed8b863056a01))
|
|
11
|
+
|
|
12
|
+
## [0.3.1](https://github.com/Availity/element/compare/@availity/mui-datepicker@0.3.0...@availity/mui-datepicker@0.3.1) (2024-01-12)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* update datepicker styles ([43eae9a](https://github.com/Availity/element/commit/43eae9a4ab1b70d6a3a295bf8e54a3423ef6638a))
|
|
18
|
+
|
|
5
19
|
## [0.3.0](https://github.com/Availity/element/compare/@availity/mui-datepicker@0.2.0...@availity/mui-datepicker@0.3.0) (2023-12-14)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,11 @@ type DatepickerProps = {
|
|
|
6
6
|
value: Dayjs | string | null;
|
|
7
7
|
/** Props applied to the `TextField` component */
|
|
8
8
|
FieldProps?: TextFieldProps;
|
|
9
|
+
/** Determines where the Calendar will be placed when opened.
|
|
10
|
+
* @default bottom-start
|
|
11
|
+
*/
|
|
12
|
+
placement?: 'bottom-start' | 'bottom' | 'bottom-end';
|
|
9
13
|
} & Omit<DatePickerProps<Dayjs, Dayjs>, 'components' | 'componentsProps' | 'desktopModeMediaQuery' | 'DialogProps' | 'OpenPickerButtonProps' | 'openTo' | 'orientation' | 'PaperProps' | 'PopperProps' | 'reduceAnimations' | 'renderInput' | 'rifmFormatter' | 'showToolbar' | 'ToolbarComponent' | 'toolbarFormat' | 'toolbarPlaceholder' | 'toolbarTitle' | 'TransitionComponent' | 'value'>;
|
|
10
|
-
declare const Datepicker: ({ FieldProps, ...props }: DatepickerProps) => JSX.Element;
|
|
14
|
+
declare const Datepicker: ({ FieldProps, placement, ...props }: DatepickerProps) => JSX.Element;
|
|
11
15
|
|
|
12
16
|
export { Datepicker, DatepickerProps };
|
package/dist/index.js
CHANGED
|
@@ -28,9 +28,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
28
28
|
var import_mui_textfield = require("@availity/mui-textfield");
|
|
29
29
|
var import_DatePicker = require("@mui/x-date-pickers/DatePicker");
|
|
30
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
-
var
|
|
31
|
+
var paperProps = { elevation: 8, variant: "elevation", sx: { marginTop: "4px" } };
|
|
32
|
+
var Datepicker = ({ FieldProps, placement = "bottom-start", ...props }) => {
|
|
32
33
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DatePicker.DatePicker, {
|
|
33
34
|
...props,
|
|
35
|
+
PaperProps: paperProps,
|
|
36
|
+
PopperProps: { placement },
|
|
34
37
|
renderInput: (params) => {
|
|
35
38
|
if (params.inputProps) {
|
|
36
39
|
params.inputProps.placeholder = "MM/DD/YYYY";
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
import { TextField } from "@availity/mui-textfield";
|
|
3
3
|
import { DatePicker as MuiDatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var
|
|
5
|
+
var paperProps = { elevation: 8, variant: "elevation", sx: { marginTop: "4px" } };
|
|
6
|
+
var Datepicker = ({ FieldProps, placement = "bottom-start", ...props }) => {
|
|
6
7
|
return /* @__PURE__ */ jsx(MuiDatePicker, {
|
|
7
8
|
...props,
|
|
9
|
+
PaperProps: paperProps,
|
|
10
|
+
PopperProps: { placement },
|
|
8
11
|
renderInput: (params) => {
|
|
9
12
|
if (params.inputProps) {
|
|
10
13
|
params.inputProps.placeholder = "MM/DD/YYYY";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-datepicker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Availity MUI Datepicker Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@availity/mui-textfield": "0.5.
|
|
35
|
+
"@availity/mui-textfield": "0.5.10",
|
|
36
36
|
"@mui/x-date-pickers": "^5.0.15",
|
|
37
37
|
"dayjs": "^1.11.9"
|
|
38
38
|
},
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// Each exported component in the package should have its own stories file
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { CalendarPicker } from '@mui/x-date-pickers/CalendarPicker';
|
|
4
|
+
import { MonthPicker } from '@mui/x-date-pickers/MonthPicker';
|
|
5
|
+
import { YearPicker } from '@mui/x-date-pickers/YearPicker';
|
|
3
6
|
import { useState } from 'react';
|
|
4
|
-
import { Dayjs } from 'dayjs';
|
|
7
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
5
8
|
import { Datepicker, DatepickerProps } from './Datepicker';
|
|
9
|
+
import { Unstable_Grid2 as Grid, Paper, Typography } from '@mui/material';
|
|
6
10
|
|
|
7
11
|
const meta: Meta<typeof Datepicker> = {
|
|
8
12
|
title: 'Components/Datepicker/Datepicker',
|
|
@@ -35,3 +39,40 @@ export const _Datepicker: StoryObj<typeof Datepicker> = {
|
|
|
35
39
|
},
|
|
36
40
|
},
|
|
37
41
|
};
|
|
42
|
+
|
|
43
|
+
export const _PickerViews: StoryObj<typeof Datepicker> = {
|
|
44
|
+
render: () => {
|
|
45
|
+
const minDate = dayjs('2020-01-01T00:00:00.000');
|
|
46
|
+
const maxDate = dayjs('2034-01-01T00:00:00.000');
|
|
47
|
+
const [date, setDate] = useState<Dayjs | null>(null);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Grid container spacing={3}>
|
|
51
|
+
<Grid xs="auto">
|
|
52
|
+
<Typography variant="h3" component="span">
|
|
53
|
+
Day View
|
|
54
|
+
</Typography>
|
|
55
|
+
<Paper sx={{ width: 'min-content' }}>
|
|
56
|
+
<CalendarPicker date={date} onChange={(newDate) => setDate(newDate)} />
|
|
57
|
+
</Paper>
|
|
58
|
+
</Grid>
|
|
59
|
+
<Grid xs="auto">
|
|
60
|
+
<Typography variant="h3" component="span">
|
|
61
|
+
Month View
|
|
62
|
+
</Typography>
|
|
63
|
+
<Paper sx={{ width: 'min-content' }}>
|
|
64
|
+
<MonthPicker date={date} minDate={minDate} maxDate={maxDate} onChange={(newDate) => setDate(newDate)} />
|
|
65
|
+
</Paper>
|
|
66
|
+
</Grid>
|
|
67
|
+
<Grid xs="auto">
|
|
68
|
+
<Typography variant="h3" component="span">
|
|
69
|
+
Year View
|
|
70
|
+
</Typography>
|
|
71
|
+
<Paper sx={{ width: '320px' }}>
|
|
72
|
+
<YearPicker date={date} minDate={minDate} maxDate={maxDate} onChange={(newDate) => setDate(newDate)} />
|
|
73
|
+
</Paper>
|
|
74
|
+
</Grid>
|
|
75
|
+
</Grid>
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
};
|
package/src/lib/Datepicker.tsx
CHANGED
|
@@ -6,6 +6,10 @@ export type DatepickerProps = {
|
|
|
6
6
|
value: Dayjs | string | null;
|
|
7
7
|
/** Props applied to the `TextField` component */
|
|
8
8
|
FieldProps?: TextFieldProps;
|
|
9
|
+
/** Determines where the Calendar will be placed when opened.
|
|
10
|
+
* @default bottom-start
|
|
11
|
+
*/
|
|
12
|
+
placement?: 'bottom-start' | 'bottom' | 'bottom-end';
|
|
9
13
|
} & Omit<
|
|
10
14
|
MuiDatePickerProps<Dayjs, Dayjs>,
|
|
11
15
|
| 'components'
|
|
@@ -29,10 +33,14 @@ export type DatepickerProps = {
|
|
|
29
33
|
| 'value'
|
|
30
34
|
>;
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
const paperProps = { elevation: 8, variant: 'elevation', sx: { marginTop: '4px' } } as const;
|
|
37
|
+
|
|
38
|
+
export const Datepicker = ({ FieldProps, placement = 'bottom-start', ...props }: DatepickerProps): JSX.Element => {
|
|
33
39
|
return (
|
|
34
40
|
<MuiDatePicker
|
|
35
41
|
{...props}
|
|
42
|
+
PaperProps={paperProps}
|
|
43
|
+
PopperProps={{ placement }}
|
|
36
44
|
renderInput={(params) => {
|
|
37
45
|
if (params.inputProps) {
|
|
38
46
|
params.inputProps.placeholder = 'MM/DD/YYYY';
|