mui-drawer 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Virtual Internships
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # mui-drawer
2
+
3
+ A reusable drawer component for React applications built with Material-UI (MUI).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Using npm
9
+ npm install mui-drawer
10
+
11
+ # Using yarn
12
+ yarn add mui-drawer
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - Built with Material-UI (MUI) components
18
+ - TypeScript support
19
+ - Multiple drawer types:
20
+ - Information
21
+ - Input
22
+ - Customizable widths and layouts
23
+ - Support for primary, secondary, and tertiary actions
24
+ - Responsive design
25
+ - Theme customization
26
+ - Sticky header and footer
27
+
28
+ ## Usage
29
+
30
+ ```tsx
31
+ import { MuiDrawer } from "mui-drawer";
32
+ import { DRAWER_TYPES, INFORMATION_SUBTYPES } from "mui-drawer";
33
+
34
+ // Basic Information Drawer
35
+ const MyComponent = () => {
36
+ const [open, setOpen] = useState(false);
37
+
38
+ return (
39
+ <MuiDrawer
40
+ type={DRAWER_TYPES.INFORMATION}
41
+ subtype={INFORMATION_SUBTYPES.PASSIVE}
42
+ open={open}
43
+ onClose={() => setOpen(false)}
44
+ title="Drawer Title"
45
+ description="This is a drawer description"
46
+ actions={{
47
+ primaryCtaTitle: "Confirm",
48
+ onPrimaryCtaClick: () => {
49
+ // Handle primary action
50
+ setOpen(false);
51
+ },
52
+ }}
53
+ >
54
+ {/* Optional content */}
55
+ </MuiDrawer>
56
+ );
57
+ };
58
+ ```
59
+
60
+ ## Drawer Types
61
+
62
+ | Type | Description | Subtypes | Dismissibility |
63
+ | ------------- | ----------------------------------- | ------------------------ | ----------------- |
64
+ | `information` | For displaying information to users | `progress`, `passive` | Varies by subtype |
65
+ | `input` | For collecting user input | `default`, `destructive` | `partial` |
66
+
67
+ ### Subtype Details
68
+
69
+ #### Information Drawer Subtypes
70
+
71
+ | Subtype | Description | Dismissibility |
72
+ | ---------- | -------------------------------------- | -------------- |
73
+ | `progress` | For showing progress or status updates | `partial` |
74
+ | `passive` | For passive information display | `full` |
75
+
76
+ #### Input Drawer Subtypes
77
+
78
+ | Subtype | Description | Dismissibility |
79
+ | ------------- | ----------------------------- | -------------- |
80
+ | `default` | Standard input | `partial` |
81
+ | `destructive` | For destructive input actions | `partial` |
82
+
83
+ ## Props Reference
84
+
85
+ ### Base Props
86
+
87
+ | Prop | Type | Required | Default | Description |
88
+ | ---------------------- | --------------------------- | -------- | ------- | ------------------------------- |
89
+ | `type` | `"information" \| "input"` | Yes | - | Type of the drawer |
90
+ | `subtype` | `string` | Yes | - | Subtype of the drawer |
91
+ | `open` | `boolean` | Yes | - | Controls drawer visibility |
92
+ | `onClose` | `() => void` | Yes | - | Callback when drawer is closed |
93
+ | `title` | `string` | No | - | Drawer title |
94
+ | `subTitle` | `string \| React.ReactNode` | No | - | Drawer subtitle |
95
+ | `description` | `string` | No | - | Drawer description |
96
+ | `children` | `React.ReactNode` | Yes | - | Drawer content |
97
+ | `wrapperClassName` | `string` | No | - | Custom class for drawer wrapper |
98
+ | `bodyWrapperClassName` | `string` | No | - | Custom class for body wrapper |
99
+ | `showCloseIcon` | `boolean` | No | `true` | Show/hide close icon |
100
+ | `showDivider` | `boolean` | No | `true` | Show/hide divider |
101
+ | `showActions` | `boolean` | No | `true` | Show/hide action buttons |
102
+ | `width` | `string` | No | - | Custom width of the drawer |
103
+ | `maxWidth` | `string` | No | - | Maximum width of the drawer |
104
+
105
+ ### Action Props
106
+
107
+ | Prop | Type | Required | Default | Description |
108
+ | ------------------------- | ----------------- | -------- | ----------------------------------------------- | --------------------------------------- |
109
+ | `primaryCtaTitle` | `string` | No | - | Primary button text |
110
+ | `secondaryCtaTitle` | `string` | No | - | Secondary button text |
111
+ | `tertiaryCtaTitle` | `string` | No | - | Tertiary button text |
112
+ | `primaryCtaTooltipText` | `string` | No | - | Tooltip text for primary button |
113
+ | `secondaryCtaTooltipText` | `string` | No | - | Tooltip text for secondary button |
114
+ | `tertiaryCtaTooltipText` | `string` | No | - | Tooltip text for tertiary button |
115
+ | `isPrimaryCtaLoading` | `boolean` | No | `false` | Show loading state for primary button |
116
+ | `isSecondaryCtaLoading` | `boolean` | No | `false` | Show loading state for secondary button |
117
+ | `isTertiaryCtaLoading` | `boolean` | No | `false` | Show loading state for tertiary button |
118
+ | `isPrimaryCtaDisabled` | `boolean` | No | `isSecondaryCtaLoading or isTertiaryCtaLoading` | Disable primary button |
119
+ | `isSecondaryCtaDisabled` | `boolean` | No | `isPrimaryCtaLoading or isTertiaryCtaLoading` | Disable secondary button |
120
+ | `isTertiaryCtaDisabled` | `boolean` | No | `isPrimaryCtaLoading or isSecondaryCtaLoading` | Disable tertiary button |
121
+ | `onPrimaryCtaClick` | `() => void` | No | - | Primary button click handler |
122
+ | `onSecondaryCtaClick` | `() => void` | No | - | Secondary button click handler |
123
+ | `onTertiaryCtaClick` | `() => void` | No | - | Tertiary button click handler |
124
+ | `tertiaryCtaStartIcon` | `React.ReactNode` | No | - | Icon for tertiary button |
125
+
126
+ ## Responsive Design
@@ -0,0 +1,94 @@
1
+ import { DrawerProps as DrawerProps_2 } from '@mui/material';
2
+ import { JSX } from 'react/jsx-runtime';
3
+
4
+ export declare interface BaseDrawerProps extends DrawerProps_2 {
5
+ wrapperClassName?: string;
6
+ bodyWrapperClassName?: string;
7
+ onClose: () => void;
8
+ open: boolean;
9
+ showCloseIcon?: boolean;
10
+ title?: string;
11
+ subTitle?: string | React.ReactNode;
12
+ description?: string;
13
+ children: React.ReactNode;
14
+ actions?: IActions;
15
+ showActions?: boolean;
16
+ showDivider?: boolean;
17
+ width?: string;
18
+ maxWidth?: string;
19
+ }
20
+
21
+ export declare const DRAWER_CONFIGS: Record<DrawerType, DrawerTypeConfig>;
22
+
23
+ export declare const DRAWER_TYPES: {
24
+ readonly INFORMATION: "information";
25
+ readonly INPUT: "input";
26
+ };
27
+
28
+ declare type DrawerConfig = {
29
+ DISMISSIBLE: 'full' | 'partial';
30
+ };
31
+
32
+ declare type DrawerProps = InformationDrawerProps | InputDrawerProps;
33
+
34
+ export declare type DrawerType = (typeof DRAWER_TYPES)[keyof typeof DRAWER_TYPES];
35
+
36
+ declare type DrawerTypeConfig = {
37
+ [subtype: string]: DrawerConfig;
38
+ };
39
+
40
+ declare interface IActions {
41
+ primaryCtaTitle?: string;
42
+ secondaryCtaTitle?: string;
43
+ tertiaryCtaTitle?: string;
44
+ primaryCtaTooltipText?: string;
45
+ secondaryCtaTooltipText?: string;
46
+ tertiaryCtaTooltipText?: string;
47
+ isPrimaryCtaLoading?: boolean;
48
+ isPrimaryCtaDisabled?: boolean;
49
+ isSecondaryCtaLoading?: boolean;
50
+ isSecondaryCtaDisabled?: boolean;
51
+ onPrimaryCtaClick?: () => void;
52
+ onSecondaryCtaClick?: () => void;
53
+ tertiaryCtaStartIcon?: React.ReactNode;
54
+ isTertiaryCtaLoading?: boolean;
55
+ isTertiaryCtaDisabled?: boolean;
56
+ onTertiaryCtaClick?: () => void;
57
+ }
58
+
59
+ export declare const INFORMATION_SUBTYPES: {
60
+ readonly PROGRESS: "progress";
61
+ readonly PASSIVE: "passive";
62
+ };
63
+
64
+ export declare interface InformationDrawerProps extends BaseDrawerProps {
65
+ type: typeof DRAWER_TYPES.INFORMATION;
66
+ subtype: (typeof INFORMATION_SUBTYPES)[keyof typeof INFORMATION_SUBTYPES];
67
+ tertiaryCtaType?: (typeof TERTIARY_CTA_TYPES)[keyof typeof TERTIARY_CTA_TYPES];
68
+ }
69
+
70
+ export declare type InformationSubtype = (typeof INFORMATION_SUBTYPES)[keyof typeof INFORMATION_SUBTYPES];
71
+
72
+ export declare const INPUT_SUBTYPES: {
73
+ readonly DEFAULT: "default";
74
+ readonly DESTRUCTIVE: "destructive";
75
+ };
76
+
77
+ export declare interface InputDrawerProps extends BaseDrawerProps {
78
+ type: typeof DRAWER_TYPES.INPUT;
79
+ subtype: (typeof INPUT_SUBTYPES)[keyof typeof INPUT_SUBTYPES];
80
+ tertiaryCtaType?: (typeof TERTIARY_CTA_TYPES)[keyof typeof TERTIARY_CTA_TYPES];
81
+ }
82
+
83
+ export declare type InputSubtype = (typeof INPUT_SUBTYPES)[keyof typeof INPUT_SUBTYPES];
84
+
85
+ export declare const MuiDrawer: (props: DrawerProps) => JSX.Element;
86
+
87
+ export declare type SubtypeForType<T extends DrawerType> = T extends typeof DRAWER_TYPES.INFORMATION ? InformationSubtype : T extends typeof DRAWER_TYPES.INPUT ? InputSubtype : never;
88
+
89
+ export declare const TERTIARY_CTA_TYPES: {
90
+ DEFAULT: string;
91
+ DESTRUCTIVE: string;
92
+ };
93
+
94
+ export { }