react-modal-sheet 5.0.0 → 5.1.1

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/README.md CHANGED
@@ -138,6 +138,7 @@ Also, by constructing the sheet from smaller pieces makes it easier to apply any
138
138
  | `prefersReducedMotion` | no | false | Skip sheet animations (sheet instantly snaps to desired location). |
139
139
  | `dragVelocityThreshold` | no | 500 | How fast the sheet must be flicked down to close. Higher values make the sheet harder to close. |
140
140
  | `dragCloseThreshold` | no | 0.6 | The portion of the sheet which must be dragged off-screen before it will close. |
141
+ | `unstyled` | no | false | Remove all decorative styles and only apply base functional styles. Useful when you want to completely customize the sheet appearance. |
141
142
 
142
143
  ## ⚙️ Methods and properties
143
144
 
@@ -283,6 +284,35 @@ Sheet header acts as a drag target and has a dragging direction indicator. Rende
283
284
  | ------------- | -------- | ------- | ---------------------------------- |
284
285
  | `disableDrag` | no | false | Disable drag for the sheet header. |
285
286
 
287
+ ### `Sheet.DragIndicator`
288
+
289
+ Sheet drag indicator renders two small animated lines that indicate the dragging direction. This component is automatically included in `Sheet.Header` but can be used standalone for custom header designs. The indicator lines animate with the sheet's drag state to provide visual feedback.
290
+
291
+ > 🖥 Rendered element: Two `motion.span` elements.
292
+
293
+ #### Usage example
294
+
295
+ ```tsx
296
+ function CustomHeaderExample() {
297
+ return (
298
+ <Sheet>
299
+ <Sheet.Container>
300
+ <Sheet.Header>
301
+ <div style={{ padding: '16px', textAlign: 'center' }}>
302
+ <h2>Custom Header</h2>
303
+ <Sheet.DragIndicator />
304
+ </div>
305
+ </Sheet.Header>
306
+ <Sheet.Content>
307
+ <p>Sheet content goes here...</p>
308
+ </Sheet.Content>
309
+ </Sheet.Container>
310
+ <Sheet.Backdrop />
311
+ </Sheet>
312
+ );
313
+ }
314
+ ```
315
+
286
316
  ### `Sheet.Content`
287
317
 
288
318
  Sheet content acts as a drag target and handles scrollable content internally. It automatically manages scroll behavior and keyboard avoidance.
@@ -478,6 +508,61 @@ function Example() {
478
508
 
479
509
  You can add your own styles or override the default sheet styles via the exposed class names. Note that you might need to use `!important` for style overrides since the inner styles are applied as inline styles which have higher specificity.
480
510
 
511
+ #### Unstyled mode
512
+
513
+ For complete control over the sheet's appearance, you can use the `unstyled` prop to remove all decorative styles while keeping only the essential functional styles.
514
+
515
+ When `unstyled={true}` is set on the root `Sheet` component, it removes decorative styles like: border radius, shadows, and background colors:
516
+
517
+ ```tsx
518
+ function UnstyledExample() {
519
+ return (
520
+ <Sheet unstyled>
521
+ <Sheet.Container>
522
+ <Sheet.Header />
523
+ <Sheet.Content>{/* Your content */}</Sheet.Content>
524
+ </Sheet.Container>
525
+ <Sheet.Backdrop />
526
+ </Sheet>
527
+ );
528
+ }
529
+ ```
530
+
531
+ The `unstyled` prop can also be applied to individual sheet components to selectively remove their decorative styles:
532
+
533
+ ```tsx
534
+ function SelectiveUnstyledExample() {
535
+ return (
536
+ <Sheet>
537
+ <Sheet.Container unstyled>
538
+ <Sheet.Header />
539
+ <Sheet.Content>{/* Your content */}</Sheet.Content>
540
+ </Sheet.Container>
541
+ {/* Keep the backdrop styled */}
542
+ <Sheet.Backdrop />
543
+ </Sheet>
544
+ );
545
+ }
546
+ ```
547
+
548
+ This is particularly useful when building custom designs or when integrating with design systems that require complete control over styling.
549
+
550
+ You can also remove all styles at the root level and then override it for individual components if you want to keep some default styles:
551
+
552
+ ```tsx
553
+ function MixedUnstyledExample() {
554
+ return (
555
+ <Sheet unstyled>
556
+ <Sheet.Container>
557
+ <Sheet.Header />
558
+ <Sheet.Content>{/* Your content */}</Sheet.Content>
559
+ </Sheet.Container>
560
+ <Sheet.Backdrop unstyled={false} />
561
+ </Sheet>
562
+ );
563
+ }
564
+ ```
565
+
481
566
  ### CSS Modules
482
567
 
483
568
  ```tsx
@@ -527,6 +612,12 @@ You can also use vanilla CSS to override the styles by targeting the exposed cla
527
612
  .react-modal-sheet-header {
528
613
  /* custom styles */
529
614
  }
615
+ .react-modal-sheet-header-container {
616
+ /* custom styles */
617
+ }
618
+ .react-modal-sheet-drag-indicator-container {
619
+ /* custom styles */
620
+ }
530
621
  .react-modal-sheet-drag-indicator {
531
622
  /* custom styles */
532
623
  }
package/dist/index.d.mts CHANGED
@@ -1,16 +1,18 @@
1
- import { EasingDefinition, motion, MotionProps, MotionValue } from 'motion/react';
2
- import { ForwardRefExoticComponent, ReactNode, ComponentPropsWithoutRef, RefAttributes, RefObject } from 'react';
1
+ import { EasingDefinition, motion, MotionValue } from 'motion/react';
2
+ import { ForwardRefExoticComponent, ReactNode, ComponentPropsWithoutRef, RefAttributes, FunctionComponent, HTMLAttributes, RefObject } from 'react';
3
3
 
4
4
  type SheetDetent = 'default' | 'full' | 'content';
5
- type CommonProps = MotionProps & {
5
+ type CommonProps = {
6
6
  className?: string;
7
+ unstyled?: boolean;
7
8
  };
8
- type MotionDivProps = ComponentPropsWithoutRef<typeof motion.div>;
9
+ type MotionCommonProps = Omit<ComponentPropsWithoutRef<typeof motion.div>, 'initial' | 'animate' | 'exit'>;
9
10
  interface SheetTweenConfig {
10
11
  ease: EasingDefinition;
11
12
  duration: number;
12
13
  }
13
14
  type SheetProps = {
15
+ unstyled?: boolean;
14
16
  avoidKeyboard?: boolean;
15
17
  children: ReactNode;
16
18
  detent?: SheetDetent;
@@ -33,38 +35,40 @@ type SheetProps = {
33
35
  onOpenEnd?: () => void;
34
36
  onOpenStart?: () => void;
35
37
  onSnap?: (index: number) => void;
36
- } & MotionDivProps;
37
- type SheetContainerProps = Omit<CommonProps, 'initial' | 'animate' | 'exit' | 'onAnimationComplete'> & {
38
+ } & MotionCommonProps;
39
+ type SheetContainerProps = MotionCommonProps & CommonProps & {
38
40
  children: ReactNode;
39
41
  };
40
- type SheetDraggableProps = MotionDivProps & {
42
+ type SheetHeaderProps = MotionCommonProps & CommonProps & {
41
43
  children?: ReactNode;
42
44
  disableDrag?: boolean;
43
45
  };
44
- type SheetBackdropProps = Omit<CommonProps, 'initial' | 'animate' | 'exit'>;
45
- type SheetStateInfo = {
46
- scrollPosition?: 'top' | 'bottom' | 'middle';
47
- currentSnap?: number;
48
- };
49
- type SheetContentScrollableProps = MotionDivProps & {
46
+ type SheetContentProps = MotionCommonProps & CommonProps & {
50
47
  disableDrag?: boolean | ((args: SheetStateInfo) => boolean);
51
48
  disableScroll?: boolean | ((args: SheetStateInfo) => boolean);
52
49
  scrollRef?: RefObject<HTMLDivElement | null>;
53
50
  };
51
+ type SheetBackdropProps = MotionCommonProps & CommonProps;
52
+ type SheetDragIndicatorProps = HTMLAttributes<HTMLDivElement> & CommonProps;
53
+ type SheetStateInfo = {
54
+ scrollPosition?: 'top' | 'bottom' | 'middle';
55
+ currentSnap?: number;
56
+ };
54
57
  type SheetSnapPoint = {
55
58
  snapIndex: number;
56
59
  snapValue: number;
57
60
  snapValueY: number;
58
61
  };
62
+ type SheetComponent = ForwardRefExoticComponent<SheetProps & RefAttributes<any>>;
59
63
  type ContainerComponent = ForwardRefExoticComponent<SheetContainerProps & RefAttributes<any>>;
60
- type DraggableComponent = ForwardRefExoticComponent<SheetDraggableProps & RefAttributes<any>>;
64
+ type HeaderComponent = ForwardRefExoticComponent<SheetHeaderProps & RefAttributes<any>>;
61
65
  type BackdropComponent = ForwardRefExoticComponent<SheetBackdropProps & RefAttributes<any>>;
62
- type SheetComponent = ForwardRefExoticComponent<SheetProps & RefAttributes<any>>;
63
- type ContentScrollableComponent = ForwardRefExoticComponent<SheetContentScrollableProps & RefAttributes<any>>;
66
+ type ContentComponent = ForwardRefExoticComponent<SheetContentProps & RefAttributes<any>>;
64
67
  interface SheetCompoundComponent {
65
68
  Container: ContainerComponent;
66
- Header: DraggableComponent;
67
- Content: ContentScrollableComponent;
69
+ Header: HeaderComponent;
70
+ DragIndicator: FunctionComponent<SheetDragIndicatorProps>;
71
+ Content: ContentComponent;
68
72
  Backdrop: BackdropComponent;
69
73
  }
70
74
  type SheetCompound = SheetComponent & SheetCompoundComponent;
@@ -76,7 +80,5 @@ interface SheetRef {
76
80
  snapTo: (index: number) => Promise<void>;
77
81
  }
78
82
  declare const Sheet: SheetCompound;
79
- type SheetHeaderProps = SheetDraggableProps;
80
- type SheetContentProps = SheetDraggableProps;
81
83
 
82
- export { Sheet, type SheetBackdropProps, type SheetContainerProps, type SheetContentProps, type SheetHeaderProps, type SheetProps, type SheetRef, type SheetSnapPoint, type SheetStateInfo };
84
+ export { Sheet, type SheetBackdropProps, type SheetContainerProps, type SheetContentProps, type SheetDetent, type SheetDragIndicatorProps, type SheetHeaderProps, type SheetProps, type SheetRef, type SheetSnapPoint, type SheetStateInfo, type SheetTweenConfig };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,18 @@
1
- import { EasingDefinition, motion, MotionProps, MotionValue } from 'motion/react';
2
- import { ForwardRefExoticComponent, ReactNode, ComponentPropsWithoutRef, RefAttributes, RefObject } from 'react';
1
+ import { EasingDefinition, motion, MotionValue } from 'motion/react';
2
+ import { ForwardRefExoticComponent, ReactNode, ComponentPropsWithoutRef, RefAttributes, FunctionComponent, HTMLAttributes, RefObject } from 'react';
3
3
 
4
4
  type SheetDetent = 'default' | 'full' | 'content';
5
- type CommonProps = MotionProps & {
5
+ type CommonProps = {
6
6
  className?: string;
7
+ unstyled?: boolean;
7
8
  };
8
- type MotionDivProps = ComponentPropsWithoutRef<typeof motion.div>;
9
+ type MotionCommonProps = Omit<ComponentPropsWithoutRef<typeof motion.div>, 'initial' | 'animate' | 'exit'>;
9
10
  interface SheetTweenConfig {
10
11
  ease: EasingDefinition;
11
12
  duration: number;
12
13
  }
13
14
  type SheetProps = {
15
+ unstyled?: boolean;
14
16
  avoidKeyboard?: boolean;
15
17
  children: ReactNode;
16
18
  detent?: SheetDetent;
@@ -33,38 +35,40 @@ type SheetProps = {
33
35
  onOpenEnd?: () => void;
34
36
  onOpenStart?: () => void;
35
37
  onSnap?: (index: number) => void;
36
- } & MotionDivProps;
37
- type SheetContainerProps = Omit<CommonProps, 'initial' | 'animate' | 'exit' | 'onAnimationComplete'> & {
38
+ } & MotionCommonProps;
39
+ type SheetContainerProps = MotionCommonProps & CommonProps & {
38
40
  children: ReactNode;
39
41
  };
40
- type SheetDraggableProps = MotionDivProps & {
42
+ type SheetHeaderProps = MotionCommonProps & CommonProps & {
41
43
  children?: ReactNode;
42
44
  disableDrag?: boolean;
43
45
  };
44
- type SheetBackdropProps = Omit<CommonProps, 'initial' | 'animate' | 'exit'>;
45
- type SheetStateInfo = {
46
- scrollPosition?: 'top' | 'bottom' | 'middle';
47
- currentSnap?: number;
48
- };
49
- type SheetContentScrollableProps = MotionDivProps & {
46
+ type SheetContentProps = MotionCommonProps & CommonProps & {
50
47
  disableDrag?: boolean | ((args: SheetStateInfo) => boolean);
51
48
  disableScroll?: boolean | ((args: SheetStateInfo) => boolean);
52
49
  scrollRef?: RefObject<HTMLDivElement | null>;
53
50
  };
51
+ type SheetBackdropProps = MotionCommonProps & CommonProps;
52
+ type SheetDragIndicatorProps = HTMLAttributes<HTMLDivElement> & CommonProps;
53
+ type SheetStateInfo = {
54
+ scrollPosition?: 'top' | 'bottom' | 'middle';
55
+ currentSnap?: number;
56
+ };
54
57
  type SheetSnapPoint = {
55
58
  snapIndex: number;
56
59
  snapValue: number;
57
60
  snapValueY: number;
58
61
  };
62
+ type SheetComponent = ForwardRefExoticComponent<SheetProps & RefAttributes<any>>;
59
63
  type ContainerComponent = ForwardRefExoticComponent<SheetContainerProps & RefAttributes<any>>;
60
- type DraggableComponent = ForwardRefExoticComponent<SheetDraggableProps & RefAttributes<any>>;
64
+ type HeaderComponent = ForwardRefExoticComponent<SheetHeaderProps & RefAttributes<any>>;
61
65
  type BackdropComponent = ForwardRefExoticComponent<SheetBackdropProps & RefAttributes<any>>;
62
- type SheetComponent = ForwardRefExoticComponent<SheetProps & RefAttributes<any>>;
63
- type ContentScrollableComponent = ForwardRefExoticComponent<SheetContentScrollableProps & RefAttributes<any>>;
66
+ type ContentComponent = ForwardRefExoticComponent<SheetContentProps & RefAttributes<any>>;
64
67
  interface SheetCompoundComponent {
65
68
  Container: ContainerComponent;
66
- Header: DraggableComponent;
67
- Content: ContentScrollableComponent;
69
+ Header: HeaderComponent;
70
+ DragIndicator: FunctionComponent<SheetDragIndicatorProps>;
71
+ Content: ContentComponent;
68
72
  Backdrop: BackdropComponent;
69
73
  }
70
74
  type SheetCompound = SheetComponent & SheetCompoundComponent;
@@ -76,7 +80,5 @@ interface SheetRef {
76
80
  snapTo: (index: number) => Promise<void>;
77
81
  }
78
82
  declare const Sheet: SheetCompound;
79
- type SheetHeaderProps = SheetDraggableProps;
80
- type SheetContentProps = SheetDraggableProps;
81
83
 
82
- export { Sheet, type SheetBackdropProps, type SheetContainerProps, type SheetContentProps, type SheetHeaderProps, type SheetProps, type SheetRef, type SheetSnapPoint, type SheetStateInfo };
84
+ export { Sheet, type SheetBackdropProps, type SheetContainerProps, type SheetContentProps, type SheetDetent, type SheetDragIndicatorProps, type SheetHeaderProps, type SheetProps, type SheetRef, type SheetSnapPoint, type SheetStateInfo, type SheetTweenConfig };