norma-library 0.4.6 → 0.4.7
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/dist/esm/components/Avatar.d.ts +3 -0
- package/dist/esm/components/Avatar.js +17 -0
- package/dist/esm/components/Avatar.js.map +1 -0
- package/dist/esm/components/Badge.d.ts +3 -0
- package/dist/esm/components/Badge.js +14 -0
- package/dist/esm/components/Badge.js.map +1 -0
- package/dist/esm/components/DatePicker.d.ts +6 -0
- package/dist/esm/components/DatePicker.js +58 -0
- package/dist/esm/components/DatePicker.js.map +1 -0
- package/dist/esm/components/TimePicker.d.ts +9 -0
- package/dist/esm/components/TimePicker.js +66 -0
- package/dist/esm/components/TimePicker.js.map +1 -0
- package/dist/esm/components/index.d.ts +4 -0
- package/dist/esm/components/index.js +4 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/Avatar.d.ts +12 -0
- package/dist/esm/interfaces/Avatar.js +2 -0
- package/dist/esm/interfaces/Avatar.js.map +1 -0
- package/dist/esm/interfaces/Badge.d.ts +14 -0
- package/dist/esm/interfaces/Badge.js +2 -0
- package/dist/esm/interfaces/Badge.js.map +1 -0
- package/dist/esm/interfaces/DatePicker.d.ts +12 -0
- package/dist/esm/interfaces/DatePicker.js +2 -0
- package/dist/esm/interfaces/DatePicker.js.map +1 -0
- package/dist/esm/interfaces/TimePicker.d.ts +12 -0
- package/dist/esm/interfaces/TimePicker.js +2 -0
- package/dist/esm/interfaces/TimePicker.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +3 -0
- package/dist/esm/interfaces/index.js +3 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +5 -1
- package/dist/esm/types/index.js.map +1 -1
- package/norma-library.tar +0 -0
- package/package.json +3 -1
- package/src/components/Avatar.tsx +29 -0
- package/src/components/Badge.tsx +22 -0
- package/src/components/DatePicker.tsx +84 -0
- package/src/components/TimePicker.tsx +95 -0
- package/src/components/index.ts +4 -0
- package/src/index.ts +2 -0
- package/src/interfaces/Avatar.tsx +18 -0
- package/src/interfaces/Badge.ts +32 -0
- package/src/interfaces/DatePicker.ts +13 -0
- package/src/interfaces/TimePicker.ts +13 -0
- package/src/interfaces/index.ts +3 -0
- package/src/stories/Avatar.stories.tsx +139 -0
- package/src/stories/Badge.stories.tsx +47 -0
- package/src/stories/DatePicker.stories.tsx +77 -0
- package/src/stories/Tag.stories.tsx +2 -4
- package/src/stories/TimePicker.stories.tsx +113 -0
- package/src/types/index.ts +21 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { ThemeProvider, useMediaQuery } from "@mui/material";
|
|
3
|
+
import { DemoContainer } from "@mui/x-date-pickers/internals/demo";
|
|
4
|
+
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
|
5
|
+
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
6
|
+
import { TimePicker as MuiTimePicker } from "@mui/x-date-pickers/TimePicker";
|
|
7
|
+
import { MobileTimePicker as MuiMobileTimePicker } from "@mui/x-date-pickers/MobileTimePicker";
|
|
8
|
+
import { DesktopTimePicker as MuiDesktopTimePicker } from "@mui/x-date-pickers/DesktopTimePicker";
|
|
9
|
+
import { themes } from "../helpers";
|
|
10
|
+
import { styled } from "@mui/material/styles";
|
|
11
|
+
|
|
12
|
+
import "dayjs/locale/pt-br";
|
|
13
|
+
import "dayjs/locale/en";
|
|
14
|
+
import "dayjs/locale/es";
|
|
15
|
+
|
|
16
|
+
import dayjs from "dayjs";
|
|
17
|
+
import utc from "dayjs/plugin/utc";
|
|
18
|
+
import timezone from "dayjs/plugin/timezone";
|
|
19
|
+
|
|
20
|
+
import "dayjs/locale/pt-br";
|
|
21
|
+
import "dayjs/locale/en";
|
|
22
|
+
import "dayjs/locale/es";
|
|
23
|
+
import { TimePickerBaseProps } from "@/interfaces/TimePicker";
|
|
24
|
+
|
|
25
|
+
dayjs.extend(utc);
|
|
26
|
+
dayjs.extend(timezone);
|
|
27
|
+
|
|
28
|
+
const MuiTimePickerStyled = styled(MuiTimePicker)({
|
|
29
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
30
|
+
border: "none",
|
|
31
|
+
borderRadius: 0,
|
|
32
|
+
borderBottom: "1px solid #666666",
|
|
33
|
+
},
|
|
34
|
+
"& .MuiFormLabel-root": {
|
|
35
|
+
backgroundColor: "#fff",
|
|
36
|
+
padding: "0 5px",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const MuiMobileTimePickerStyled = styled(MuiMobileTimePicker)({
|
|
41
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
42
|
+
border: "none",
|
|
43
|
+
borderRadius: 0,
|
|
44
|
+
borderBottom: "1px solid #666666",
|
|
45
|
+
},
|
|
46
|
+
"& .MuiFormLabel-root": {
|
|
47
|
+
backgroundColor: "#fff",
|
|
48
|
+
padding: "0 5px",
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const MuiDesktopTimePickerStyled = styled(MuiDesktopTimePicker)({
|
|
53
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
54
|
+
border: "none",
|
|
55
|
+
borderRadius: 0,
|
|
56
|
+
borderBottom: "1px solid #666666",
|
|
57
|
+
},
|
|
58
|
+
"& .MuiFormLabel-root": {
|
|
59
|
+
backgroundColor: "#fff",
|
|
60
|
+
padding: "0 5px",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const TimePicker = ({
|
|
65
|
+
label,
|
|
66
|
+
timezone = "America/Sao_Paulo",
|
|
67
|
+
language = "pt-br",
|
|
68
|
+
variant = "desktop",
|
|
69
|
+
}: TimePickerBaseProps) => {
|
|
70
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
71
|
+
const theme = useMemo(
|
|
72
|
+
() => (prefersDarkMode ? themes.light : themes.dark),
|
|
73
|
+
[prefersDarkMode]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<ThemeProvider theme={theme}>
|
|
78
|
+
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale={language}>
|
|
79
|
+
<DemoContainer
|
|
80
|
+
components={["TimePicker", "MobileTimePicker", "DesktopTimePicker"]}
|
|
81
|
+
>
|
|
82
|
+
{variant === "responsive" && (
|
|
83
|
+
<MuiTimePickerStyled label={label} timezone={timezone} />
|
|
84
|
+
)}
|
|
85
|
+
{variant === "mobile" && (
|
|
86
|
+
<MuiMobileTimePickerStyled label={label} timezone={timezone} />
|
|
87
|
+
)}
|
|
88
|
+
{variant === "desktop" && (
|
|
89
|
+
<MuiDesktopTimePickerStyled label={label} timezone={timezone} />
|
|
90
|
+
)}
|
|
91
|
+
</DemoContainer>
|
|
92
|
+
</LocalizationProvider>
|
|
93
|
+
</ThemeProvider>
|
|
94
|
+
);
|
|
95
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./Accordion";
|
|
2
|
+
export * from "./Avatar";
|
|
3
|
+
export * from "./Badge";
|
|
2
4
|
export * from "./Button";
|
|
3
5
|
export * from "./Card";
|
|
4
6
|
export * from "./CheckBox";
|
|
7
|
+
export * from "./DatePicker";
|
|
5
8
|
export * from "./DropDown";
|
|
6
9
|
export * from "./IconButton";
|
|
7
10
|
export * from "./Icons";
|
|
@@ -14,3 +17,4 @@ export * from "./Select";
|
|
|
14
17
|
export * from "./Tabs";
|
|
15
18
|
export * from "./Tag";
|
|
16
19
|
export * from "./TextField";
|
|
20
|
+
export * from "./TimePicker";
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { Select } from "./components/Select";
|
|
|
13
13
|
import { Tabs } from "./components/Tabs";
|
|
14
14
|
import { Tag } from "./components/Tag";
|
|
15
15
|
import { TextField } from "./components/TextField";
|
|
16
|
+
import { DatePicker } from "./components/DatePicker";
|
|
16
17
|
import { themes, getPalette } from "./helpers";
|
|
17
18
|
|
|
18
19
|
export {
|
|
@@ -20,6 +21,7 @@ export {
|
|
|
20
21
|
Button,
|
|
21
22
|
Card,
|
|
22
23
|
CheckBox,
|
|
24
|
+
DatePicker,
|
|
23
25
|
getPalette,
|
|
24
26
|
IconButton,
|
|
25
27
|
Icons,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { Theme } from "@emotion/react";
|
|
3
|
+
|
|
4
|
+
import { AvatarPropsVariantOverrides, SxProps } from "@mui/material";
|
|
5
|
+
|
|
6
|
+
import { MuiAvatarBaseProps } from "../types";
|
|
7
|
+
import { OverridableStringUnion } from "@mui/types";
|
|
8
|
+
|
|
9
|
+
export interface AvatarBaseProps extends MuiAvatarBaseProps {
|
|
10
|
+
sx?: SxProps<Theme>;
|
|
11
|
+
src?: string;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
variant?: OverridableStringUnion<
|
|
14
|
+
"circular" | "rounded" | "square",
|
|
15
|
+
AvatarPropsVariantOverrides
|
|
16
|
+
>;
|
|
17
|
+
sizes?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { Theme } from "@emotion/react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BadgePropsColorOverrides,
|
|
6
|
+
BadgePropsVariantOverrides,
|
|
7
|
+
SxProps,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
import { MuiBadgeBaseProps } from "@/types";
|
|
10
|
+
import { OverridableStringUnion } from "@mui/types";
|
|
11
|
+
|
|
12
|
+
export interface BadgeBaseProps extends MuiBadgeBaseProps {
|
|
13
|
+
sx?: SxProps<Theme>;
|
|
14
|
+
className?: string;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
badgeContent?: ReactNode;
|
|
17
|
+
invisible?: boolean;
|
|
18
|
+
color?: OverridableStringUnion<
|
|
19
|
+
| "primary"
|
|
20
|
+
| "secondary"
|
|
21
|
+
| "default"
|
|
22
|
+
| "error"
|
|
23
|
+
| "info"
|
|
24
|
+
| "success"
|
|
25
|
+
| "warning",
|
|
26
|
+
BadgePropsColorOverrides
|
|
27
|
+
>;
|
|
28
|
+
variant?: OverridableStringUnion<
|
|
29
|
+
"standard" | "dot",
|
|
30
|
+
BadgePropsVariantOverrides
|
|
31
|
+
>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SxProps } from "@mui/material";
|
|
2
|
+
import { Theme } from "@emotion/react";
|
|
3
|
+
|
|
4
|
+
import { DatePickVariant } from "../types";
|
|
5
|
+
|
|
6
|
+
export interface DatePickerBaseProps {
|
|
7
|
+
sx?: SxProps<Theme>;
|
|
8
|
+
label?: string;
|
|
9
|
+
format?: string;
|
|
10
|
+
language?: string;
|
|
11
|
+
onChange?: React.ChangeEvent<HTMLInputElement>;
|
|
12
|
+
variant?: DatePickVariant;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SxProps } from "@mui/material";
|
|
2
|
+
import { Theme } from "@emotion/react";
|
|
3
|
+
|
|
4
|
+
import { DatePickVariant } from "../types";
|
|
5
|
+
|
|
6
|
+
export interface TimePickerBaseProps {
|
|
7
|
+
sx?: SxProps<Theme>;
|
|
8
|
+
label?: string;
|
|
9
|
+
timezone?: string;
|
|
10
|
+
language?: string;
|
|
11
|
+
onChange?: React.ChangeEvent<HTMLInputElement>;
|
|
12
|
+
variant?: DatePickVariant;
|
|
13
|
+
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./Accordion";
|
|
2
|
+
export * from "./Avatar";
|
|
3
|
+
export * from "./Badge";
|
|
2
4
|
export * from "./Button";
|
|
3
5
|
export * from "./Card";
|
|
4
6
|
export * from "./CheckBox";
|
|
7
|
+
export * from "./DatePicker";
|
|
5
8
|
export * from "./DropDown";
|
|
6
9
|
export * from "./IconButton";
|
|
7
10
|
export * from "./Icons";
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { Meta } from "@storybook/react";
|
|
4
|
+
import { Avatar, Icons } from "../components";
|
|
5
|
+
import { AvatarGroup, Stack } from "@mui/material";
|
|
6
|
+
import { green, pink } from "@mui/material/colors";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Display/Avatar",
|
|
10
|
+
component: Avatar,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
},
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
argTypes: {},
|
|
16
|
+
} satisfies Meta<typeof Avatar>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
|
|
20
|
+
function stringToColor(string: string) {
|
|
21
|
+
let hash = 0;
|
|
22
|
+
let i;
|
|
23
|
+
|
|
24
|
+
/* eslint-disable no-bitwise */
|
|
25
|
+
for (i = 0; i < string.length; i += 1) {
|
|
26
|
+
hash = string.charCodeAt(i) + ((hash << 5) - hash);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let color = "#";
|
|
30
|
+
|
|
31
|
+
for (i = 0; i < 3; i += 1) {
|
|
32
|
+
const value = (hash >> (i * 8)) & 0xff;
|
|
33
|
+
color += `00${value.toString(16)}`.slice(-2);
|
|
34
|
+
}
|
|
35
|
+
/* eslint-enable no-bitwise */
|
|
36
|
+
|
|
37
|
+
return color;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function stringAvatar(name: string) {
|
|
41
|
+
return {
|
|
42
|
+
sx: {
|
|
43
|
+
bgcolor: stringToColor(name),
|
|
44
|
+
},
|
|
45
|
+
children: `${name.split(" ")[0][0]}${name.split(" ")[1][0]}`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const AvatarBasic = () => {
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Avatar src="https://mui.com/static/images/avatar/2.jpg" />
|
|
53
|
+
</>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const AvatarVariants = () => {
|
|
58
|
+
return (
|
|
59
|
+
<Stack direction="row" spacing={2}>
|
|
60
|
+
<Avatar
|
|
61
|
+
src="https://mui.com/static/images/avatar/1.jpg"
|
|
62
|
+
variant="square"
|
|
63
|
+
/>
|
|
64
|
+
<Avatar
|
|
65
|
+
src="https://mui.com/static/images/avatar/2.jpg"
|
|
66
|
+
variant="rounded"
|
|
67
|
+
/>
|
|
68
|
+
<Avatar src="https://mui.com/static/images/avatar/3.jpg" />
|
|
69
|
+
</Stack>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const AvatarLetters = () => {
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<Stack direction="row" spacing={2}>
|
|
77
|
+
<Avatar {...stringAvatar("Kent Dodds")} />
|
|
78
|
+
<Avatar {...stringAvatar("Jed Watson")} />
|
|
79
|
+
<Avatar {...stringAvatar("Tim Neutkens")} />
|
|
80
|
+
</Stack>
|
|
81
|
+
</>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const AvatarSizes = () => {
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<Stack direction="row" spacing={2}>
|
|
89
|
+
<Avatar
|
|
90
|
+
src="https://mui.com/static/images/avatar/1.jpg"
|
|
91
|
+
variant="square"
|
|
92
|
+
sx={{ width: 24, height: 24 }}
|
|
93
|
+
/>
|
|
94
|
+
<Avatar
|
|
95
|
+
src="https://mui.com/static/images/avatar/2.jpg"
|
|
96
|
+
variant="rounded"
|
|
97
|
+
/>
|
|
98
|
+
<Avatar
|
|
99
|
+
src="https://mui.com/static/images/avatar/3.jpg"
|
|
100
|
+
sx={{ width: 56, height: 56 }}
|
|
101
|
+
/>
|
|
102
|
+
</Stack>
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const AvatarWidthIcons = () => {
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<Stack direction="row" spacing={2}>
|
|
111
|
+
<Avatar>
|
|
112
|
+
<Icons icon="user" color="white" />
|
|
113
|
+
</Avatar>
|
|
114
|
+
<Avatar sx={{ bgcolor: pink[500] }}>
|
|
115
|
+
<Icons icon="starOutlined" color="white" />
|
|
116
|
+
</Avatar>
|
|
117
|
+
<Avatar sx={{ bgcolor: green[500] }}>
|
|
118
|
+
<Icons icon="chartBar" color="white" />
|
|
119
|
+
</Avatar>
|
|
120
|
+
</Stack>
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const AvatarGrouped = () => {
|
|
126
|
+
return (
|
|
127
|
+
<>
|
|
128
|
+
<Stack direction="row" spacing={2}>
|
|
129
|
+
<AvatarGroup max={4}>
|
|
130
|
+
<Avatar src="https://mui.com/static/images/avatar/1.jpg" />
|
|
131
|
+
<Avatar src="https://mui.com/static/images/avatar/2.jpg" />
|
|
132
|
+
<Avatar src="https://mui.com/static/images/avatar/3.jpg" />
|
|
133
|
+
<Avatar src="https://mui.com/static/images/avatar/4.jpg" />
|
|
134
|
+
<Avatar src="https://mui.com/static/images/avatar/5.jpg" />
|
|
135
|
+
</AvatarGroup>
|
|
136
|
+
</Stack>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { Meta } from "@storybook/react";
|
|
4
|
+
import { Avatar, Badge, Icons } from "../components";
|
|
5
|
+
import { AvatarGroup, Stack } from "@mui/material";
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "Display/Badge",
|
|
9
|
+
component: Badge,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: "centered",
|
|
12
|
+
},
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
argTypes: {},
|
|
15
|
+
} satisfies Meta<typeof Badge>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
export const BadgeBasic = () => {
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<Badge badgeContent={4} color="primary">
|
|
23
|
+
<Icons icon="user" />
|
|
24
|
+
</Badge>
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const BadgeColors = () => {
|
|
30
|
+
return (
|
|
31
|
+
<Stack direction="row" spacing={2}>
|
|
32
|
+
{[
|
|
33
|
+
"primary",
|
|
34
|
+
"secondary",
|
|
35
|
+
"default",
|
|
36
|
+
"error",
|
|
37
|
+
"info",
|
|
38
|
+
"success",
|
|
39
|
+
"warning",
|
|
40
|
+
].map((color, key) => (
|
|
41
|
+
<Badge badgeContent={4} color={color} key={key}>
|
|
42
|
+
<Icons icon="user" />
|
|
43
|
+
</Badge>
|
|
44
|
+
))}
|
|
45
|
+
</Stack>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DatePicker } from "../components";
|
|
3
|
+
import type { Meta } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "Form/DatePicker",
|
|
7
|
+
component: DatePicker,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered",
|
|
10
|
+
},
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
argTypes: {},
|
|
13
|
+
} satisfies Meta<typeof DatePicker>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
export const BasicDatePicker = () => (
|
|
18
|
+
<DatePicker sx={{ minWidth: 275 }} label="DatePicker" />
|
|
19
|
+
);
|
|
20
|
+
BasicDatePicker.storyName = "DatePicker Basic";
|
|
21
|
+
|
|
22
|
+
export const DatePickerVariants = () => (
|
|
23
|
+
<>
|
|
24
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
25
|
+
<DatePicker
|
|
26
|
+
sx={{ minWidth: 275 }}
|
|
27
|
+
label="DatePicker Responsive"
|
|
28
|
+
variant="responsive"
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
32
|
+
<DatePicker
|
|
33
|
+
sx={{ minWidth: 275 }}
|
|
34
|
+
label="DatePicker Mobile"
|
|
35
|
+
variant="mobile"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
39
|
+
<DatePicker
|
|
40
|
+
sx={{ minWidth: 275 }}
|
|
41
|
+
label="DatePicker Desktop"
|
|
42
|
+
variant="desktop"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
DatePickerVariants.storyName = "DatePicker Variants";
|
|
49
|
+
|
|
50
|
+
export const DatePickerLanguage = () => (
|
|
51
|
+
<>
|
|
52
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
53
|
+
<DatePicker
|
|
54
|
+
sx={{ minWidth: 275 }}
|
|
55
|
+
label="DatePicker Brazil"
|
|
56
|
+
language="pt-br"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
60
|
+
<DatePicker
|
|
61
|
+
sx={{ minWidth: 275 }}
|
|
62
|
+
label="DatePicker English"
|
|
63
|
+
language="en"
|
|
64
|
+
format="YYYY-MM-DD"
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
68
|
+
<DatePicker
|
|
69
|
+
sx={{ minWidth: 275 }}
|
|
70
|
+
label="DatePicker Spain"
|
|
71
|
+
language="es"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
DatePickerLanguage.storyName = "DatePicker Languages";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import type { Meta
|
|
3
|
+
import type { Meta } from "@storybook/react";
|
|
4
4
|
import { Tag } from "../components";
|
|
5
|
-
import { ColorVariant,
|
|
5
|
+
import { ColorVariant, TextFieldSizeVariant } from "../types";
|
|
6
6
|
|
|
7
7
|
const colors: ColorVariant[] = [
|
|
8
8
|
"inherit",
|
|
@@ -28,8 +28,6 @@ const meta = {
|
|
|
28
28
|
|
|
29
29
|
export default meta;
|
|
30
30
|
|
|
31
|
-
type Story = StoryObj<typeof meta>;
|
|
32
|
-
|
|
33
31
|
export const TagBasic = () => {
|
|
34
32
|
return (
|
|
35
33
|
<>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DemoContainer } from "@mui/x-date-pickers/internals/demo";
|
|
3
|
+
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
|
4
|
+
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
5
|
+
import { TimePicker } from "@mui/x-date-pickers/TimePicker";
|
|
6
|
+
import { MobileTimePicker } from "@mui/x-date-pickers/MobileTimePicker";
|
|
7
|
+
import { DesktopTimePicker } from "@mui/x-date-pickers/DesktopTimePicker";
|
|
8
|
+
import type { Meta } from "@storybook/react";
|
|
9
|
+
import dayjs, { Dayjs } from "dayjs";
|
|
10
|
+
import utc from "dayjs/plugin/utc";
|
|
11
|
+
import timezone from "dayjs/plugin/timezone";
|
|
12
|
+
|
|
13
|
+
import "dayjs/locale/pt-br";
|
|
14
|
+
import "dayjs/locale/en";
|
|
15
|
+
import "dayjs/locale/es";
|
|
16
|
+
|
|
17
|
+
dayjs.extend(utc);
|
|
18
|
+
dayjs.extend(timezone);
|
|
19
|
+
|
|
20
|
+
const meta = {
|
|
21
|
+
title: "Form/TimePicker",
|
|
22
|
+
component: TimePicker,
|
|
23
|
+
parameters: {
|
|
24
|
+
layout: "centered",
|
|
25
|
+
},
|
|
26
|
+
tags: ["autodocs"],
|
|
27
|
+
argTypes: {},
|
|
28
|
+
} satisfies Meta<typeof TimePicker>;
|
|
29
|
+
|
|
30
|
+
export default meta;
|
|
31
|
+
|
|
32
|
+
export const BasicDatePicker = () => (
|
|
33
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
34
|
+
<DemoContainer components={["TimePicker"]}>
|
|
35
|
+
<TimePicker label="TimePicker" />
|
|
36
|
+
</DemoContainer>
|
|
37
|
+
</LocalizationProvider>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
BasicDatePicker.storyName = "TimePicker Basic";
|
|
41
|
+
|
|
42
|
+
export const TimePickerVariants = () => (
|
|
43
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
44
|
+
<DemoContainer
|
|
45
|
+
components={["TimePicker", "MobileTimePicker", "DesktopTimePicker"]}
|
|
46
|
+
>
|
|
47
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
48
|
+
<TimePicker
|
|
49
|
+
sx={{ minWidth: 275 }}
|
|
50
|
+
label="TimePicker Responsive"
|
|
51
|
+
timezone="America/Sao_Paulo"
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
55
|
+
<MobileTimePicker
|
|
56
|
+
sx={{ minWidth: 275 }}
|
|
57
|
+
label="TimePicker Mobile"
|
|
58
|
+
timezone="America/Sao_Paulo"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
62
|
+
<DesktopTimePicker
|
|
63
|
+
sx={{ minWidth: 275 }}
|
|
64
|
+
label="TimePicker Desktop"
|
|
65
|
+
timezone="America/Sao_Paulo"
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
</DemoContainer>
|
|
69
|
+
</LocalizationProvider>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
TimePickerVariants.storyName = "TimePicker Variants";
|
|
73
|
+
|
|
74
|
+
export const TimePickerLanguage = () => (
|
|
75
|
+
<>
|
|
76
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
77
|
+
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale={"pt-br"}>
|
|
78
|
+
<DemoContainer components={["TimePicker"]}>
|
|
79
|
+
<TimePicker
|
|
80
|
+
sx={{ minWidth: 275 }}
|
|
81
|
+
label="TimePicker Brazil"
|
|
82
|
+
timezone="America/Sao_Paulo"
|
|
83
|
+
/>
|
|
84
|
+
</DemoContainer>
|
|
85
|
+
</LocalizationProvider>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
89
|
+
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale={"en"}>
|
|
90
|
+
<DemoContainer components={["TimePicker"]}>
|
|
91
|
+
<TimePicker
|
|
92
|
+
sx={{ minWidth: 275 }}
|
|
93
|
+
label="TimePicker English"
|
|
94
|
+
timezone="America/Sao_Paulo"
|
|
95
|
+
/>
|
|
96
|
+
</DemoContainer>
|
|
97
|
+
</LocalizationProvider>
|
|
98
|
+
</div>
|
|
99
|
+
<div style={{ width: "480px", marginBottom: 30 }}>
|
|
100
|
+
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale={"es"}>
|
|
101
|
+
<DemoContainer components={["TimePicker"]}>
|
|
102
|
+
<TimePicker
|
|
103
|
+
sx={{ minWidth: 275 }}
|
|
104
|
+
label="TimePicker Spain"
|
|
105
|
+
timezone="America/Sao_Paulo"
|
|
106
|
+
/>
|
|
107
|
+
</DemoContainer>
|
|
108
|
+
</LocalizationProvider>
|
|
109
|
+
</div>
|
|
110
|
+
</>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
TimePickerLanguage.storyName = "TimePicker Languages";
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AvatarProps as MuiAvatarProps,
|
|
2
3
|
ButtonProps as MuiButtonProps,
|
|
4
|
+
BadgeProps as MuiBadgeProps,
|
|
3
5
|
IconButtonProps as MuiIconButtonProps,
|
|
4
6
|
TextFieldProps as MuiTextFieldProps,
|
|
5
7
|
CheckboxProps as MuiCheckBoxProps,
|
|
@@ -51,6 +53,7 @@ export type ButtonVariant = "text" | "outlined" | "contained";
|
|
|
51
53
|
export type DropVariant = "menu" | "selectedMenu";
|
|
52
54
|
export type TagVariant = "outlined" | "contained";
|
|
53
55
|
export type TabsVariant = "standard" | "scrollable" | "fullWidth";
|
|
56
|
+
export type DatePickVariant = "responsive" | "desktop" | "mobile";
|
|
54
57
|
export type ProgressVariant =
|
|
55
58
|
| "determinate"
|
|
56
59
|
| "indeterminate"
|
|
@@ -137,6 +140,24 @@ export type MuiSelectBaseProps = Omit<
|
|
|
137
140
|
|
|
138
141
|
export type MuiPaperBaseProps = Omit<MuiPaperProps, "sx">;
|
|
139
142
|
|
|
143
|
+
export type MuiDatePickerBaseProps = Omit<MuiTextFieldProps, "sx">;
|
|
144
|
+
|
|
145
|
+
export type MuiAvatarBaseProps = Omit<
|
|
146
|
+
MuiAvatarProps,
|
|
147
|
+
"sx" | "src" | "children" | "variant" | "sizes"
|
|
148
|
+
>;
|
|
149
|
+
|
|
150
|
+
export type MuiBadgeBaseProps = Omit<
|
|
151
|
+
MuiBadgeProps,
|
|
152
|
+
| "sx"
|
|
153
|
+
| "color"
|
|
154
|
+
| "children"
|
|
155
|
+
| "invisible"
|
|
156
|
+
| "variant"
|
|
157
|
+
| "className"
|
|
158
|
+
| "badgeContent"
|
|
159
|
+
>;
|
|
160
|
+
|
|
140
161
|
export type IconScale =
|
|
141
162
|
| "xsmall"
|
|
142
163
|
| "small"
|