From 154b2e7b551e72ac04744beedec5db36aa355c00 Mon Sep 17 00:00:00 2001 From: BipanKishore Date: Mon, 6 May 2024 03:25:25 +0530 Subject: [PATCH] maxSizeClass minSizeClass --- src/@types/component-types.ts | 2 ++ src/components/pane.tsx | 1 + src/models/pane-model.ts | 5 +++++ src/models/utils.ts | 2 ++ 4 files changed, 10 insertions(+) diff --git a/src/@types/component-types.ts b/src/@types/component-types.ts index f53701b..14a1201 100644 --- a/src/@types/component-types.ts +++ b/src/@types/component-types.ts @@ -87,6 +87,8 @@ export interface IPane { minSize?: number; resizer?: ReactNode; resizerSize?: number; + minSizeClass?: string, + maxSizeClass?: string, onMinSize?: (id: string, minSize:number) => void, onMaxSize?: (id: string, maxSize:number) => void, onNormalSize?: (id: string) => void diff --git a/src/components/pane.tsx b/src/components/pane.tsx index b5fcdb4..7905e3c 100644 --- a/src/components/pane.tsx +++ b/src/components/pane.tsx @@ -31,6 +31,7 @@ export const Pane = (props: IPane) => { registerItem( { + node, destroy, setSize }, diff --git a/src/models/pane-model.ts b/src/models/pane-model.ts index 3bd9232..8be3367 100644 --- a/src/models/pane-model.ts +++ b/src/models/pane-model.ts @@ -207,12 +207,17 @@ export class PaneModel { if (this.sizeState !== newSetSize) { if (newSetSize === NORMAL_SIZE_STATE) { + this.api.node.classList.remove(props.minSizeClass, props.maxSizeClass) props.onNormalSize(id) } if (newSetSize === MIN_SIZE_STATE) { + this.api.node.classList.remove(props.maxSizeClass) + this.api.node.classList.add(props.minSizeClass) props.onMinSize(id, size) } if (newSetSize === MAX_SIZE_STATE) { + this.api.node.classList.remove(props.minSizeClass) + this.api.node.classList.add(props.maxSizeClass) props.onMaxSize(id, size) } this.sizeState = newSetSize diff --git a/src/models/utils.ts b/src/models/utils.ts index 23748d5..caa576f 100644 --- a/src/models/utils.ts +++ b/src/models/utils.ts @@ -17,6 +17,8 @@ export const attachDefaultPaneProps = (paneProps: IPane) => { onNormalSize: noop, onMinSize: noop, onMaxSize: noop, + maxSizeClass: '', + minSizeClass: '', minSize: 0, maxSize: Infinity, ...propsWithNoUndefined