react-side-sheet-pro 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Richard Dobroň
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,105 @@
1
+ # react-side-sheet-pro
2
+
3
+ A flexible React SideSheet component for displaying contextual information.
4
+
5
+ This panel can slide in from either the left or right side of the screen and is typically triggered by user actions like clicking a row in a table. It supports nested sheets, easy state management, and customizable layouts for a seamless and intuitive user experiences.
6
+
7
+ ## 👀 Live Preview
8
+
9
+ - [Codepen](https://codepen.io/richard-dobro/pen/LEEBGya)
10
+
11
+ ## 💡 Use cases
12
+ - Viewing a user's profile or related details
13
+ - Displaying transaction information (e.g., syncs or automation runs)
14
+ - Accessing settings or configurations that don’t require a direct URL
15
+ - Editing or creating records in a form without navigating away from the main view
16
+
17
+ ## ℹ️ Compatibility
18
+
19
+ React 0.14.0 - 18.x.x
20
+
21
+
22
+ ## 📦 Installation
23
+
24
+ Install the widget via npm or yarn:
25
+
26
+ ```shell
27
+ npm install react-side-sheet-pro
28
+ # or
29
+ yarn add react-side-sheet-pro
30
+ ```
31
+
32
+ ## ⚡️ Quick Start
33
+ ```typescript jsx
34
+ import React from 'react'
35
+ import { SideSheet, useSideSheet, SideElementProps } from 'react-side-sheet-pro'
36
+
37
+ const UserDetails: React.FC<SideElementProps & { user: any }> = ({
38
+ user,
39
+ sideId,
40
+ close,
41
+ }) => (
42
+ <>
43
+ <SideSheet.Header title={user.name} onClose={() => close(sideId)} />
44
+ <SideSheet.Content className="sidesheet-padding sidesheet-centered">
45
+ <div className="sidesheet-card">
46
+ <p>
47
+ <strong>ID:</strong> {user.id}
48
+ </p>
49
+ <p>
50
+ <strong>Name:</strong> {user.name}
51
+ </p>
52
+ <p>
53
+ <strong>Email:</strong> {user.email}
54
+ </p>
55
+ </div>
56
+ </SideSheet.Content>
57
+ </>
58
+ )
59
+
60
+ export const App = () => {
61
+ const { open } = useSideSheet()
62
+
63
+ const handleOpenSideSheet = () => {
64
+ open(
65
+ (props) => (
66
+ <UserDetails
67
+ {...props}
68
+ user={{
69
+ id: 1,
70
+ name: 'John Doe',
71
+ email: 'john@doe.com',
72
+ }}
73
+ />
74
+ ),
75
+ {
76
+ width: 600,
77
+ }
78
+ )
79
+ }
80
+
81
+ return (
82
+ <button onClick={handleOpenSideSheet}>Open Side Sheet</button>
83
+ )
84
+ }
85
+
86
+ export default () => (
87
+ <SideSheet.Provider>
88
+ <App />
89
+ </SideSheet.Provider>
90
+ )
91
+ ```
92
+
93
+ ## 🧪 Testing
94
+
95
+ ```bash
96
+ cd playground/ && npm start
97
+ ```
98
+
99
+ ## 🌟 Contributing
100
+
101
+ We welcome contributions! If you'd like to help improve this project, feel free to open an issue or submit a pull request.
102
+
103
+ ## License
104
+
105
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
package/dist/index.css ADDED
@@ -0,0 +1,191 @@
1
+ .sidesheet-overlay {
2
+ opacity: 0.30;
3
+ transition: all 0.4s;
4
+ background: #000;
5
+ bottom: 0;
6
+ left: 0;
7
+ position: fixed;
8
+ right: 0;
9
+ top: 0;
10
+ visibility: visible;
11
+ z-index: 10000;
12
+ }
13
+
14
+ .sidesheet-right {
15
+ right: 0;
16
+ transform: translateX(100%);
17
+ }
18
+
19
+ .sidesheet-left {
20
+ left: 0;
21
+ transform: translateX(-100%);
22
+ }
23
+
24
+ .sidesheet-right.sidesheet-animation-open {
25
+ animation: sidesheet-open-right 240ms cubic-bezier(0, 0, 0.3, 1);
26
+ }
27
+
28
+ .sidesheet-left.sidesheet-animation-open {
29
+ animation: sidesheet-open-left 240ms cubic-bezier(0, 0, 0.3, 1);
30
+ }
31
+
32
+ .sidesheet.sidesheet-animation-open {
33
+ transform: translateX(0);
34
+ }
35
+
36
+ .sidesheet-right.sidesheet-animation-closing {
37
+ animation: sidesheet-close-right 240ms cubic-bezier(0, 0, 0.3, 1);
38
+ }
39
+
40
+ .sidesheet-left.sidesheet-animation-closing {
41
+ animation: sidesheet-close-left 240ms cubic-bezier(0, 0, 0.3, 1);
42
+ }
43
+
44
+ @keyframes sidesheet-open-right {
45
+ from {
46
+ transform: translateX(100%);
47
+ }
48
+ to {
49
+ transform: translateX(0);
50
+ }
51
+ }
52
+
53
+ @keyframes sidesheet-close-right {
54
+ from {
55
+ transform: translateX(0);
56
+ }
57
+ to {
58
+ transform: translateX(100%);
59
+ }
60
+ }
61
+
62
+ @keyframes sidesheet-open-left {
63
+ from {
64
+ transform: translateX(-100%);
65
+ }
66
+ to {
67
+ transform: translateX(0);
68
+ }
69
+ }
70
+
71
+ @keyframes sidesheet-close-left {
72
+ from {
73
+ transform: translateX(0);
74
+ }
75
+ to {
76
+ transform: translateX(-100%);
77
+ }
78
+ }
79
+
80
+ .sidesheet {
81
+ flex-direction: column;
82
+ display: flex;
83
+ flex-wrap: nowrap;
84
+ background: #f1f3f4;
85
+ bottom: 0;
86
+ right: 0;
87
+ max-width: 100%;
88
+ overflow-x: hidden;
89
+ overflow-y: auto;
90
+ position: fixed;
91
+ z-index: 10000;
92
+ top: 0;
93
+ width: 100%;
94
+ box-shadow: 0 0 10px -5px rgba(0, 0, 0, 0.2),
95
+ 0 0 24px 2px rgba(0, 0, 0, 0.14), 0 0 30px 5px rgba(0, 0, 0, 0.12);
96
+ transition: transform 0.3s ease, width 0.3s ease;
97
+ }
98
+
99
+ .sheet-white {
100
+ background: #fff;
101
+ }
102
+
103
+ .sidesheet-header .sidesheet-header-btn {
104
+ background: transparent;
105
+ border: none;
106
+ cursor: pointer;
107
+ padding: 7px;
108
+ }
109
+
110
+ .sidesheet-header {
111
+ padding: 12px;
112
+ gap: 16px;
113
+ border-bottom: 1px solid #dadce0;
114
+ background: #fff;
115
+ display: flex;
116
+ justify-content: space-between;
117
+ align-items: center;
118
+ }
119
+
120
+ .sidesheet-header svg {
121
+ width: 24px;
122
+ height: 24px;
123
+ display: block;
124
+ }
125
+
126
+ .sidesheet-header .sidesheet-header-btn {
127
+ border-radius: 50%;
128
+ height: 40px;
129
+ line-height: 40px;
130
+ align-items: center;
131
+ width: 40px;
132
+ justify-content: center;
133
+ display: flex;
134
+ opacity: 0.8;
135
+ }
136
+
137
+ .sidesheet-header .sidesheet-header-btn:hover {
138
+ opacity: 1;
139
+ }
140
+
141
+ .sidesheet-header .sidesheet-header-btn:focus {
142
+ background-color: rgba(64, 64, 64, 0.12);
143
+ }
144
+
145
+ .sidesheet-header-close:hover {
146
+ cursor: pointer;
147
+ }
148
+
149
+ .sidesheet-header-title {
150
+ font-size: 20px;
151
+ font-weight: 400;
152
+ align-items: center;
153
+ display: flex;
154
+ flex: 1 1 auto;
155
+ overflow: hidden;
156
+ text-overflow: ellipsis;
157
+ white-space: nowrap;
158
+ padding: 6px 0;
159
+ }
160
+
161
+ .sidesheet-content.sidesheet-centered {
162
+ margin: 0 auto;
163
+ max-width: 768px;
164
+ width: 100%;
165
+ }
166
+
167
+ .sidesheet-content {
168
+ flex: 1 1 auto;
169
+ overflow-y: auto;
170
+ position: relative;
171
+ }
172
+
173
+ .sidesheet-content.sidesheet-padding {
174
+ padding: 24px;
175
+ }
176
+
177
+ .sidesheet-card {
178
+ background: #fff;
179
+ border-radius: 8px;
180
+ padding: 24px;
181
+ box-shadow: 0 0 0 1px #dadce0;
182
+ }
183
+
184
+ .sidesheet-footer {
185
+ padding: 16px;
186
+ border-top: 1px solid #dadce0;
187
+ background: #fff;
188
+ display: flex;
189
+ justify-content: space-between;
190
+ align-items: center;
191
+ }
@@ -0,0 +1,60 @@
1
+ /// <reference types="react" />
2
+ import { ReactNode } from "react";
3
+ type Sides = "left" | "right";
4
+ interface SideSheetOptions {
5
+ side: Sides;
6
+ mountStrategy: "all" | "top-only";
7
+ }
8
+ interface SideOptions {
9
+ width?: number;
10
+ className?: string;
11
+ confirmBeforeClose?: boolean;
12
+ confirmMessage?: string;
13
+ confirmCallback?: (message: string) => Promise<boolean>;
14
+ closeOnOverlayClick?: boolean;
15
+ closeOnEsc?: boolean;
16
+ animationDuration?: number;
17
+ onOpen?: (id: number) => void;
18
+ onClose?: (id: number) => void;
19
+ }
20
+ interface SideElementProps {
21
+ sideId: number;
22
+ close: (id: number | null) => Promise<void>;
23
+ open: (element: SideElement, options?: SideOptions) => number;
24
+ update: (id: number, options: SideOptions) => void;
25
+ options: SideOptions;
26
+ }
27
+ type SideElement = (props: SideElementProps) => ReactNode;
28
+ interface SideStackItem {
29
+ id: number;
30
+ element: SideElement;
31
+ options: Required<SideOptions>;
32
+ state: "opening" | "open" | "closing";
33
+ }
34
+ interface SideSheetContextValue {
35
+ open: (el: SideElement, opts?: SideOptions) => number;
36
+ close: (id: number | null) => Promise<void>;
37
+ update: (id: number, opts: SideOptions) => void;
38
+ config: SideSheetOptions;
39
+ }
40
+ declare const useSideSheet: () => SideSheetContextValue;
41
+ declare const SideSheet: {
42
+ Provider: import("react").FC<{
43
+ children: import("react").ReactNode;
44
+ configuration: Partial<SideSheetOptions>;
45
+ }>;
46
+ Header: import("react").FC<{
47
+ title: string;
48
+ onClose?: (() => void) | undefined;
49
+ actions?: import("react").ReactNode;
50
+ }>;
51
+ Content: import("react").FC<{
52
+ children: import("react").ReactNode;
53
+ className?: string | undefined;
54
+ }>;
55
+ Footer: import("react").FC<{
56
+ children: import("react").ReactNode;
57
+ className?: string | undefined;
58
+ }>;
59
+ };
60
+ export { useSideSheet, Sides, SideSheetOptions, SideOptions, SideElementProps, SideElement, SideStackItem, SideSheetContextValue, SideSheet };
@@ -0,0 +1,60 @@
1
+ /// <reference types="react" />
2
+ import { ReactNode } from "react";
3
+ type Sides = "left" | "right";
4
+ interface SideSheetOptions {
5
+ side: Sides;
6
+ mountStrategy: "all" | "top-only";
7
+ }
8
+ interface SideOptions {
9
+ width?: number;
10
+ className?: string;
11
+ confirmBeforeClose?: boolean;
12
+ confirmMessage?: string;
13
+ confirmCallback?: (message: string) => Promise<boolean>;
14
+ closeOnOverlayClick?: boolean;
15
+ closeOnEsc?: boolean;
16
+ animationDuration?: number;
17
+ onOpen?: (id: number) => void;
18
+ onClose?: (id: number) => void;
19
+ }
20
+ interface SideElementProps {
21
+ sideId: number;
22
+ close: (id: number | null) => Promise<void>;
23
+ open: (element: SideElement, options?: SideOptions) => number;
24
+ update: (id: number, options: SideOptions) => void;
25
+ options: SideOptions;
26
+ }
27
+ type SideElement = (props: SideElementProps) => ReactNode;
28
+ interface SideStackItem {
29
+ id: number;
30
+ element: SideElement;
31
+ options: Required<SideOptions>;
32
+ state: "opening" | "open" | "closing";
33
+ }
34
+ interface SideSheetContextValue {
35
+ open: (el: SideElement, opts?: SideOptions) => number;
36
+ close: (id: number | null) => Promise<void>;
37
+ update: (id: number, opts: SideOptions) => void;
38
+ config: SideSheetOptions;
39
+ }
40
+ declare const useSideSheet: () => SideSheetContextValue;
41
+ declare const SideSheet: {
42
+ Provider: import("react").FC<{
43
+ children: import("react").ReactNode;
44
+ configuration: Partial<SideSheetOptions>;
45
+ }>;
46
+ Header: import("react").FC<{
47
+ title: string;
48
+ onClose?: (() => void) | undefined;
49
+ actions?: import("react").ReactNode;
50
+ }>;
51
+ Content: import("react").FC<{
52
+ children: import("react").ReactNode;
53
+ className?: string | undefined;
54
+ }>;
55
+ Footer: import("react").FC<{
56
+ children: import("react").ReactNode;
57
+ className?: string | undefined;
58
+ }>;
59
+ };
60
+ export { useSideSheet, Sides, SideSheetOptions, SideOptions, SideElementProps, SideElement, SideStackItem, SideSheetContextValue, SideSheet };