@gfazioli/mantine-split-pane 1.1.7 → 2.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.
@@ -1,20 +1,54 @@
1
1
  import React from 'react';
2
2
  import { BoxProps, Factory, StylesApiProps } from '@mantine/core';
3
- import { SplitPaneResizerBaseProps, SplitPaneResizerVariant } from '../Resizer/SplitPaneResizer';
3
+ import { SplitPaneResizerVariant } from '../Resizer/SplitPaneResizer';
4
4
  export type SplitPaneStylesNames = 'root';
5
5
  export type SplitPaneVariant = SplitPaneResizerVariant;
6
6
  export type SplitPaneCssVariables = {};
7
- export interface SplitPaneProps extends BoxProps, Omit<SplitPaneResizerBaseProps, 'paneRef'>, StylesApiProps<SplitPaneFactory> {
8
- /** Split pane content */
9
- children: React.ReactNode;
7
+ export interface SplitPaneHandlers {
8
+ resetInitialSize?: (e: React.MouseEvent<HTMLButtonElement>) => void;
9
+ getMinWidth?: () => number;
10
+ getMinHeight?: () => number;
11
+ getMaxWidth?: () => number;
12
+ getMaxHeight?: () => number;
13
+ getInitialWidth?: () => number;
14
+ getInitialHeight?: () => number;
15
+ onResizeStart?: () => void;
16
+ onResizing?: (size: SPLIT_PANE_SIZE) => void;
17
+ onResizeEnd?: (size: SPLIT_PANE_SIZE) => void;
18
+ splitPane?: HTMLDivElement;
19
+ }
20
+ export type SPLIT_PANE_SIZE = {
21
+ width: number;
22
+ height: number;
23
+ };
24
+ export interface SplitPaneBaseProps {
10
25
  /** Grow pane to fill available space */
11
26
  grow?: boolean;
12
27
  /** Initial width of the pane */
13
28
  initialWidth?: number | string;
14
29
  /** Initial height of the pane */
15
30
  initialHeight?: number | string;
16
- /** Usually you won't need to use this prop directly, it's used internally by Split component */
17
- withResizer?: boolean;
31
+ /** The minimum width of the pane when orientation is vertical */
32
+ minWidth?: number | string;
33
+ /** The minimum height of the pane when orientation is horizontal */
34
+ minHeight?: number | string;
35
+ /** The maximum width of the pane when orientation is vertical */
36
+ maxWidth?: number | string;
37
+ /** The maximum height of the pane when orientation is horizontal */
38
+ maxHeight?: number | string;
39
+ /** Event called when pane size starts changing */
40
+ onResizeStart?: () => void;
41
+ /** Event called when pane size changes */
42
+ onResizing?: (size: SPLIT_PANE_SIZE) => void;
43
+ /** Event called when pane size changes */
44
+ onResizeEnd?: (size: SPLIT_PANE_SIZE) => void;
45
+ /** Event called to reset initial size */
46
+ onResetInitialSize?: (e: React.MouseEvent<HTMLButtonElement>) => void;
47
+ }
48
+ export interface SplitPaneProps extends BoxProps, SplitPaneBaseProps, StylesApiProps<SplitPaneFactory> {
49
+ /** Split pane content */
50
+ children: React.ReactNode;
51
+ ref?: React.RefObject<HTMLDivElement & SplitPaneHandlers>;
18
52
  }
19
53
  export type SplitPaneFactory = Factory<{
20
54
  props: SplitPaneProps;
@@ -1,13 +1,16 @@
1
- import React, { CSSProperties, MutableRefObject } from 'react';
2
- import { BoxProps, Factory, MantineColor, MantineRadius, MantineSize, MantineSpacing, StylesApiProps } from '@mantine/core';
1
+ import React, { CSSProperties } from 'react';
2
+ import { BoxProps, Factory, MantineColor, MantineRadius, MantineSize, MantineSpacing, StyleProp, StylesApiProps } from '@mantine/core';
3
+ import { SplitPaneHandlers } from '../Pane/SplitPane';
3
4
  export type SplitPaneResizerStylesNames = 'root';
4
5
  export type SplitPaneResizerVariant = 'default' | 'filled' | 'outline' | 'transparent' | 'dotted' | 'dashed';
5
6
  export type SplitPaneResizerCssVariables = {
6
7
  root: '--split-resizer-size' | '--split-resizer-color' | '--split-resizer-color-light' | '--split-resizer-color-dark' | '--split-resizer-hover-color-light' | '--split-resizer-hover-color-dark' | '--split-resizer-radius' | '--split-resizer-knob-size' | '--split-resizer-knob-opacity' | '--split-resizer-knob-radius' | '--split-resizer-knob-color' | '--split-resizer-knob-hover-color' | '--split-resizer-spacing' | '--split-resizer-cursor-vertical' | '--split-resizer-cursor-horizontal';
7
8
  };
8
- export interface SplitPaneResizerSharedProps {
9
+ export interface SplitPaneResizerContextProps {
9
10
  /** Split orientation, `'vertical'` by default */
10
11
  orientation?: 'horizontal' | 'vertical';
12
+ /** Resizer opacity */
13
+ opacity?: StyleProp<React.CSSProperties['opacity']>;
11
14
  /** Resizer size */
12
15
  size?: MantineSize | number | (string & {});
13
16
  /** Resizer radius */
@@ -41,31 +44,37 @@ export interface SplitPaneResizerSharedProps {
41
44
  /** The CSS cursor property for horizontal orientation */
42
45
  cursorHorizontal?: CSSProperties['cursor'];
43
46
  }
44
- export type SPLIT_PANE_RESIZE_SIZE = {
45
- width: string;
46
- height: string;
47
+ export type SPLIT_PANE_RESIZE_SIZES = {
48
+ beforePane: {
49
+ width: number;
50
+ height: number;
51
+ };
52
+ afterPane: {
53
+ width: number;
54
+ height: number;
55
+ };
47
56
  };
48
- export interface SplitPaneResizerBaseProps extends SplitPaneResizerSharedProps {
49
- /** The minimum width of the pane when orientation is vertical */
50
- minWidth?: number;
51
- /** The minimum height of the pane when orientation is horizontal */
52
- minHeight?: number;
53
- /** The maximum width of the pane when orientation is vertical */
54
- maxWidth?: number;
55
- /** The maximum height of the pane when orientation is horizontal */
56
- maxHeight?: number;
57
+ export interface SplitPaneResizerBaseProps extends SplitPaneResizerContextProps {
57
58
  /** Event called when resizer is double clicked */
58
59
  onDoubleClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
59
60
  /** Event called when pane size starts changing */
60
61
  onResizeStart?: () => void;
61
62
  /** Event called when pane size changes */
62
- onResizing?: (size: SPLIT_PANE_RESIZE_SIZE) => void;
63
+ onResizing?: (sizes: SPLIT_PANE_RESIZE_SIZES) => void;
63
64
  /** Event called when pane size changes */
64
- onResizeEnd?: (size: SPLIT_PANE_RESIZE_SIZE) => void;
65
- /** The pane ref */
66
- paneRef: MutableRefObject<HTMLDivElement | null>;
65
+ onResizeEnd?: (sizes: SPLIT_PANE_RESIZE_SIZES) => void;
67
66
  }
68
67
  export interface SplitPaneResizerProps extends BoxProps, SplitPaneResizerBaseProps, StylesApiProps<SplitPaneResizerFactory> {
68
+ /**
69
+ * The before (left | up) componentRef
70
+ * @access private
71
+ * */
72
+ __beforeRef?: React.RefObject<HTMLDivElement & SplitPaneHandlers>;
73
+ /**
74
+ * The after (right | down) componentRef
75
+ * @access private
76
+ * */
77
+ __afterRef?: React.RefObject<HTMLDivElement & SplitPaneHandlers>;
69
78
  }
70
79
  export type SplitPaneResizerFactory = Factory<{
71
80
  props: SplitPaneResizerProps;
@@ -74,6 +83,7 @@ export type SplitPaneResizerFactory = Factory<{
74
83
  vars: SplitPaneResizerCssVariables;
75
84
  variant: SplitPaneResizerVariant;
76
85
  }>;
86
+ export declare const defaultProps: Partial<SplitPaneResizerContextProps>;
77
87
  export declare const SplitPaneResizer: import("@mantine/core").MantineComponent<{
78
88
  props: SplitPaneResizerProps;
79
89
  ref: HTMLButtonElement;
@@ -1,6 +1,8 @@
1
1
  import { MantineSpacing } from '@mantine/core';
2
- import { SplitPaneResizerProps } from './Resizer/SplitPaneResizer';
3
- interface SplitContext extends Omit<SplitPaneResizerProps, 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'onDoubleClick' | 'onResizeEnd' | 'onResizeStart' | 'onResize' | 'paneRef'> {
2
+ import { SplitPaneResizerContextProps, SplitPaneResizerVariant } from './Resizer/SplitPaneResizer';
3
+ interface SplitContext extends SplitPaneResizerContextProps {
4
+ /** Resizer Variant */
5
+ variant?: SplitPaneResizerVariant;
4
6
  /** Spacing between resizer and pane */
5
7
  spacing?: MantineSpacing;
6
8
  }
@@ -1,17 +1,17 @@
1
1
  import React from 'react';
2
2
  import { BoxProps, Factory, StylesApiProps } from '@mantine/core';
3
3
  import { SplitPane } from './Pane/SplitPane';
4
- import { SplitPaneResizerSharedProps, SplitPaneResizerVariant } from './Resizer/SplitPaneResizer';
4
+ import { SplitPaneResizer, type SplitPaneResizerContextProps, type SplitPaneResizerVariant } from './Resizer/SplitPaneResizer';
5
5
  export type SplitStylesNames = 'root';
6
6
  export type SplitVariant = SplitPaneResizerVariant;
7
7
  export type SplitCssVariables = {
8
8
  root: '--split-inline';
9
9
  };
10
- export interface SplitBaseProps extends SplitPaneResizerSharedProps {
10
+ export interface SplitBaseProps extends SplitPaneResizerContextProps {
11
11
  /** Make main split container inline */
12
12
  inline?: boolean;
13
13
  /** Split children */
14
- children?: React.ReactNode;
14
+ children: React.ReactNode;
15
15
  }
16
16
  export interface SplitProps extends BoxProps, SplitBaseProps, StylesApiProps<SplitFactory> {
17
17
  }
@@ -24,6 +24,7 @@ export type SplitFactory = Factory<{
24
24
  variant: SplitVariant;
25
25
  staticComponents: {
26
26
  Pane: typeof SplitPane;
27
+ Resizer: typeof SplitPaneResizer;
27
28
  };
28
29
  }>;
29
30
  export declare const Split: import("@mantine/core").MantineComponent<{
@@ -35,5 +36,6 @@ export declare const Split: import("@mantine/core").MantineComponent<{
35
36
  variant: SplitVariant;
36
37
  staticComponents: {
37
38
  Pane: typeof SplitPane;
39
+ Resizer: typeof SplitPaneResizer;
38
40
  };
39
41
  }>;
@@ -1,7 +1,5 @@
1
- export { SplitPane } from './Pane';
2
- export type { SplitPaneFactory, SplitPaneProps } from './Pane/SplitPane';
3
- export { SplitPaneResizer } from './Resizer';
4
- export type { SplitPaneResizerFactory, SplitPaneResizerProps } from './Resizer/SplitPaneResizer';
5
- export { Split } from './Split';
6
- export type { SplitBaseProps, SplitCssVariables, SplitFactory } from './Split';
7
1
  export { useSplitContext } from './Split.context';
2
+ export { Split } from './Split';
3
+ export type { SplitCssVariables, SplitFactory, SplitProps } from './Split';
4
+ export type { SPLIT_PANE_SIZE, SplitPaneFactory, SplitPaneProps } from './Pane/SplitPane';
5
+ export type { SPLIT_PANE_RESIZE_SIZES, SplitPaneResizerFactory, SplitPaneResizerProps, } from './Resizer/SplitPaneResizer';
@@ -1,7 +1,5 @@
1
- export { SplitPane } from './Pane';
2
- export type { SplitPaneFactory, SplitPaneProps } from './Pane/SplitPane';
3
- export { SplitPaneResizer } from './Resizer';
4
- export type { SplitPaneResizerFactory, SplitPaneResizerProps } from './Resizer/SplitPaneResizer';
5
- export { Split } from './Split';
6
- export type { SplitBaseProps, SplitCssVariables, SplitFactory } from './Split';
7
1
  export { useSplitContext } from './Split.context';
2
+ export { Split } from './Split';
3
+ export type { SplitCssVariables, SplitFactory, SplitProps } from './Split';
4
+ export type { SPLIT_PANE_SIZE, SplitPaneFactory, SplitPaneProps } from './Pane/SplitPane';
5
+ export type { SPLIT_PANE_RESIZE_SIZES, SplitPaneResizerFactory, SplitPaneResizerProps, } from './Resizer/SplitPaneResizer';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gfazioli/mantine-split-pane",
3
- "version": "1.1.7",
3
+ "version": "2.0.0",
4
4
  "description": "A React component that manages split panes allows users to divide and resize content areas within a layout efficiently.",
5
5
  "homepage": "https://gfazioli.github.io/mantine-split-pane/",
6
6
  "packageManager": "yarn@4.0.1",
@@ -1,8 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- const SPLIT_ERRORS = {
5
- context: "Split component was not found in the tree"};
6
-
7
- exports.SPLIT_ERRORS = SPLIT_ERRORS;
8
- //# sourceMappingURL=Split.errors.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Split.errors.cjs","sources":["../../src/Split.errors.ts"],"sourcesContent":["export const SPLIT_ERRORS = {\n context: 'Split component was not found in the tree',\n children:\n 'Split.Pane component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported',\n};\n"],"names":[],"mappings":";;;AAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,YAAY,CAAG,CAAA,CAAA,CAAA;AAC5B,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,EAAE,CAEX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}
@@ -1,6 +0,0 @@
1
- 'use client';
2
- const SPLIT_ERRORS = {
3
- context: "Split component was not found in the tree"};
4
-
5
- export { SPLIT_ERRORS };
6
- //# sourceMappingURL=Split.errors.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Split.errors.mjs","sources":["../../src/Split.errors.ts"],"sourcesContent":["export const SPLIT_ERRORS = {\n context: 'Split component was not found in the tree',\n children:\n 'Split.Pane component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported',\n};\n"],"names":[],"mappings":";AAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,YAAY,CAAG,CAAA,CAAA,CAAA;AAC5B,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,EAAE,CAEX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}