react-resizable-panels 0.0.53 → 0.0.55

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/declarations/src/Panel.d.ts +6 -5
  3. package/dist/declarations/src/PanelGroup.d.ts +8 -4
  4. package/dist/declarations/src/PanelResizeHandle.d.ts +5 -2
  5. package/dist/declarations/src/index.d.ts +9 -8
  6. package/dist/declarations/src/types.d.ts +4 -2
  7. package/dist/declarations/src/utils/group.d.ts +29 -0
  8. package/dist/react-resizable-panels.browser.cjs.js +1709 -0
  9. package/dist/react-resizable-panels.browser.cjs.mjs +6 -0
  10. package/dist/react-resizable-panels.browser.development.cjs.js +1764 -0
  11. package/dist/react-resizable-panels.browser.development.cjs.mjs +6 -0
  12. package/dist/react-resizable-panels.browser.development.esm.js +1737 -0
  13. package/dist/react-resizable-panels.browser.esm.js +1682 -0
  14. package/dist/react-resizable-panels.cjs.js +395 -126
  15. package/dist/react-resizable-panels.cjs.js.map +1 -0
  16. package/dist/react-resizable-panels.cjs.mjs +2 -1
  17. package/dist/react-resizable-panels.development.cjs.js +452 -135
  18. package/dist/react-resizable-panels.development.cjs.mjs +6 -0
  19. package/dist/react-resizable-panels.development.esm.js +452 -136
  20. package/dist/react-resizable-panels.development.node.cjs.js +1579 -0
  21. package/dist/react-resizable-panels.development.node.cjs.mjs +6 -0
  22. package/dist/react-resizable-panels.development.node.esm.js +1552 -0
  23. package/dist/react-resizable-panels.esm.js +395 -127
  24. package/dist/react-resizable-panels.esm.js.map +1 -0
  25. package/dist/react-resizable-panels.node.cjs.js +1523 -0
  26. package/dist/react-resizable-panels.node.cjs.mjs +6 -0
  27. package/dist/react-resizable-panels.node.esm.js +1496 -0
  28. package/package.json +26 -1
  29. package/src/Panel.ts +37 -37
  30. package/src/PanelContexts.ts +5 -6
  31. package/src/PanelGroup.ts +269 -121
  32. package/src/PanelResizeHandle.ts +1 -4
  33. package/src/env-conditions/browser.ts +1 -0
  34. package/src/env-conditions/node.ts +1 -0
  35. package/src/env-conditions/unknown.ts +1 -0
  36. package/src/hooks/useIsomorphicEffect.ts +2 -9
  37. package/src/hooks/useWindowSplitterBehavior.ts +14 -11
  38. package/src/index.ts +11 -3
  39. package/src/types.ts +3 -1
  40. package/src/utils/group.ts +327 -28
  41. package/src/utils/ssr.ts +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.55
4
+ * New `units` prop added to `PanelGroup` to support pixel-based panel size constraints.
5
+
6
+ This prop defaults to "percentage" but can be set to "pixels" for static, pixel based layout constraints.
7
+
8
+ This can be used to add enable pixel-based min/max and default size values, e.g.:
9
+ ```tsx
10
+ <PanelGroup direction="horizontal" units="pixels">
11
+ {/* Will be constrained to 100-200 pixels (assuming group is large enough to permit this) */}
12
+ <Panel minSize={100} maxSize={200} />
13
+ <PanelResizeHandle />
14
+ <Panel />
15
+ <PanelResizeHandle />
16
+ <Panel />
17
+ </PanelGroup>
18
+ ```
19
+
20
+ Imperative API methods are also able to work with either pixels or percentages now. They default to whatever units the group has been configured to use, but can be overridden with an additional, optional parameter, e.g.
21
+ ```ts
22
+ panelRef.resize(100, "pixels");
23
+ panelGroupRef.setLayout([25, 50, 25], "percentages");
24
+
25
+ // Works for getters too, e.g.
26
+ const percentage = panelRef.getSize("percentages");
27
+ const pixels = panelRef.getSize("pixels");
28
+
29
+ const layout = panelGroupRef.getLayout("pixels");
30
+ ```
31
+
32
+ ## 0.0.54
33
+ * [172](https://github.com/bvaughn/react-resizable-panels/issues/172): Development warning added to `PanelGroup` for conditionally-rendered `Panel`(s) that don't have `id` and `order` props
34
+ * [156](https://github.com/bvaughn/react-resizable-panels/pull/156): Package exports now used to select between node (server-rendering) and browser (client-rendering) bundles
35
+
3
36
  ## 0.0.53
4
37
  * Fix edge case race condition for `onResize` callbacks during initial mount
5
38
 
@@ -1,5 +1,5 @@
1
- import { CSSProperties, ElementType, ReactNode } from "./vendor/react";
2
- import { PanelOnCollapse, PanelOnResize } from "./types";
1
+ import { CSSProperties, ElementType, ReactNode } from "./vendor/react.js";
2
+ import { PanelOnCollapse, PanelOnResize, Units } from "./types.js";
3
3
  export type PanelProps = {
4
4
  children?: ReactNode;
5
5
  className?: string;
@@ -7,7 +7,7 @@ export type PanelProps = {
7
7
  collapsible?: boolean;
8
8
  defaultSize?: number | null;
9
9
  id?: string | null;
10
- maxSize?: number;
10
+ maxSize?: number | null;
11
11
  minSize?: number;
12
12
  onCollapse?: PanelOnCollapse | null;
13
13
  onResize?: PanelOnResize | null;
@@ -19,7 +19,8 @@ export type ImperativePanelHandle = {
19
19
  collapse: () => void;
20
20
  expand: () => void;
21
21
  getCollapsed(): boolean;
22
- getSize(): number;
23
- resize: (percentage: number) => void;
22
+ getId(): string;
23
+ getSize(units?: Units): number;
24
+ resize: (percentage: number, units?: Units) => void;
24
25
  };
25
26
  export declare const Panel: import("react").ForwardRefExoticComponent<PanelProps & import("react").RefAttributes<ImperativePanelHandle>>;
@@ -1,9 +1,11 @@
1
- import { CSSProperties, ElementType, ReactNode } from "./vendor/react";
2
- import { Direction, PanelData, PanelGroupOnLayout, PanelGroupStorage } from "./types";
1
+ import { CSSProperties, ElementType, ReactNode } from "./vendor/react.js";
2
+ import { Direction, PanelData, PanelGroupOnLayout, PanelGroupStorage, Units } from "./types.js";
3
3
  export type CommittedValues = {
4
4
  direction: Direction;
5
+ id: string;
5
6
  panels: Map<string, PanelData>;
6
7
  sizes: number[];
8
+ units: Units;
7
9
  };
8
10
  export type PanelDataMap = Map<string, PanelData>;
9
11
  export type InitialDragState = {
@@ -22,9 +24,11 @@ export type PanelGroupProps = {
22
24
  storage?: PanelGroupStorage;
23
25
  style?: CSSProperties;
24
26
  tagName?: ElementType;
27
+ units?: Units;
25
28
  };
26
29
  export type ImperativePanelGroupHandle = {
27
- getLayout: () => number[];
28
- setLayout: (panelSizes: number[]) => void;
30
+ getId: () => string;
31
+ getLayout: (units?: Units) => number[];
32
+ setLayout: (panelSizes: number[], units?: Units) => void;
29
33
  };
30
34
  export declare const PanelGroup: import("react").ForwardRefExoticComponent<PanelGroupProps & import("react").RefAttributes<ImperativePanelGroupHandle>>;
@@ -1,5 +1,5 @@
1
- import { CSSProperties, ElementType, ReactNode } from "./vendor/react";
2
- import type { PanelResizeHandleOnDragging } from "./types";
1
+ import { CSSProperties, ElementType, ReactNode } from "./vendor/react.js";
2
+ import type { PanelResizeHandleOnDragging } from "./types.js";
3
3
  export type PanelResizeHandleProps = {
4
4
  children?: ReactNode;
5
5
  className?: string;
@@ -10,3 +10,6 @@ export type PanelResizeHandleProps = {
10
10
  tagName?: ElementType;
11
11
  };
12
12
  export declare function PanelResizeHandle({ children, className: classNameFromProps, disabled, id: idFromProps, onDragging, style: styleFromProps, tagName: Type, }: PanelResizeHandleProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
13
+ export declare namespace PanelResizeHandle {
14
+ var displayName: string;
15
+ }
@@ -1,8 +1,9 @@
1
- import { Panel } from "./Panel";
2
- import { PanelGroup } from "./PanelGroup";
3
- import { PanelResizeHandle } from "./PanelResizeHandle";
4
- import type { ImperativePanelHandle, PanelProps } from "./Panel";
5
- import type { ImperativePanelGroupHandle, PanelGroupProps } from "./PanelGroup";
6
- import type { PanelResizeHandleProps } from "./PanelResizeHandle";
7
- import type { PanelGroupOnLayout, PanelGroupStorage, PanelOnCollapse, PanelOnResize, PanelResizeHandleOnDragging } from "./types";
8
- export { ImperativePanelGroupHandle, ImperativePanelHandle, Panel, PanelOnCollapse, PanelOnResize, PanelGroup, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage, PanelProps, PanelResizeHandle, PanelResizeHandleOnDragging, PanelResizeHandleProps, };
1
+ import { Panel } from "./Panel.js";
2
+ import { PanelGroup } from "./PanelGroup.js";
3
+ import { PanelResizeHandle } from "./PanelResizeHandle.js";
4
+ import type { ImperativePanelHandle, PanelProps } from "./Panel.js";
5
+ import type { ImperativePanelGroupHandle, PanelGroupProps } from "./PanelGroup.js";
6
+ import type { PanelResizeHandleProps } from "./PanelResizeHandle.js";
7
+ import { getAvailableGroupSizePixels } from "./utils/group.js";
8
+ import type { PanelGroupOnLayout, PanelGroupStorage, PanelOnCollapse, PanelOnResize, PanelResizeHandleOnDragging, Units } from "./types.js";
9
+ export { ImperativePanelGroupHandle, ImperativePanelHandle, PanelOnCollapse, PanelOnResize, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage, PanelProps, PanelResizeHandleOnDragging, PanelResizeHandleProps, Units, Panel, PanelGroup, PanelResizeHandle, getAvailableGroupSizePixels, };
@@ -1,5 +1,6 @@
1
- import { RefObject } from "./vendor/react";
1
+ import { RefObject } from "./vendor/react.js";
2
2
  export type Direction = "horizontal" | "vertical";
3
+ export type Units = "percentages" | "pixels";
3
4
  export type PanelGroupStorage = {
4
5
  getItem(name: string): string | null;
5
6
  setItem(name: string, value: string): void;
@@ -19,7 +20,8 @@ export type PanelData = {
19
20
  collapsible: boolean;
20
21
  defaultSize: number | null;
21
22
  id: string;
22
- maxSize: number;
23
+ idWasAutoGenerated: boolean;
24
+ maxSize: number | null;
23
25
  minSize: number;
24
26
  order: number | null;
25
27
  };
@@ -0,0 +1,29 @@
1
+ import { CommittedValues, InitialDragState } from "../PanelGroup.js";
2
+ import { PanelData, ResizeEvent, Units } from "../types.js";
3
+ export declare function adjustByDelta(event: ResizeEvent | null, committedValues: CommittedValues, idBefore: string, idAfter: string, deltaPixels: number, prevSizes: number[], panelSizeBeforeCollapse: Map<string, number>, initialDragState: InitialDragState | null): number[];
4
+ export declare function callPanelCallbacks(panelsArray: PanelData[], sizes: number[], panelIdToLastNotifiedSizeMap: Record<string, number>): void;
5
+ export declare function calculateDefaultLayout({ groupId, panels, units, }: {
6
+ groupId: string;
7
+ panels: Map<string, PanelData>;
8
+ units: Units;
9
+ }): number[];
10
+ export declare function getBeforeAndAfterIds(id: string, panelsArray: PanelData[]): [idBefore: string | null, idAFter: string | null];
11
+ export declare function getAvailableGroupSizePixels(groupId: string): number;
12
+ export declare function getFlexGrow(panels: Map<string, PanelData>, id: string, sizes: number[]): string;
13
+ export declare function getPanel(id: string): HTMLDivElement | null;
14
+ export declare function getPanelGroup(id: string): HTMLDivElement | null;
15
+ export declare function getResizeHandle(id: string): HTMLDivElement | null;
16
+ export declare function getResizeHandleIndex(id: string): number | null;
17
+ export declare function getResizeHandles(): HTMLDivElement[];
18
+ export declare function getResizeHandlesForGroup(groupId: string): HTMLDivElement[];
19
+ export declare function getResizeHandlePanelIds(groupId: string, handleId: string, panelsArray: PanelData[]): [idBefore: string | null, idAfter: string | null];
20
+ export declare function panelsMapToSortedArray(panels: Map<string, PanelData>): PanelData[];
21
+ export declare function safeResizePanel(units: Units, groupSizePixels: number, panel: PanelData, prevSize: number, nextSize: number, event?: ResizeEvent | null): number;
22
+ export declare function validatePanelProps(units: Units, panelData: PanelData): void;
23
+ export declare function validatePanelGroupLayout({ groupId, panels, nextSizes, prevSizes, units, }: {
24
+ groupId: string;
25
+ panels: Map<string, PanelData>;
26
+ nextSizes: number[];
27
+ prevSizes: number[];
28
+ units: Units;
29
+ }): number[];