mirror of
https://github.com/mathuo/dockview
synced 2025-02-02 22:45:48 +00:00
chore: v1.8.3 docs
This commit is contained in:
parent
bac862a5fc
commit
3ea9f21e90
25
packages/docs/blog/2023-09-15-dockview-1.8.3.md
Normal file
25
packages/docs/blog/2023-09-15-dockview-1.8.3.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
slug: dockview-1.8.3-release
|
||||||
|
title: Dockview 1.8.3
|
||||||
|
tags: [release]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Release Notes
|
||||||
|
|
||||||
|
Please reference to docs @ [dockview.dev](https://dockview.dev).
|
||||||
|
|
||||||
|
## 🚀 Features
|
||||||
|
|
||||||
|
- Additional to DockviewDefaultTab component [#321](https://github.com/mathuo/dockview/issues/321)
|
||||||
|
|
||||||
|
- Additional group drop target options [#316](https://github.com/mathuo/dockview/issues/316)
|
||||||
|
|
||||||
|
- Intercept events to attach custom DataTransfer object to tabs [#299](https://github.com/mathuo/dockview/issues/299)
|
||||||
|
|
||||||
|
- Floating groups viewport overflow options [#326](https://github.com/mathuo/dockview/issues/326)
|
||||||
|
|
||||||
|
## 🛠 Miscs
|
||||||
|
|
||||||
|
- Bug: Close button on tab shouldn't bring panel to active state [#330](https://github.com/mathuo/dockview/issues/330)
|
||||||
|
|
||||||
|
## 🔥 Breaking changes
|
10
packages/docs/versioned_docs/version-1.8.3/components/_category_.json
vendored
Normal file
10
packages/docs/versioned_docs/version-1.8.3/components/_category_.json
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"label": "Components",
|
||||||
|
"collapsible": true,
|
||||||
|
"collapsed": false,
|
||||||
|
"position": 2,
|
||||||
|
"link": {
|
||||||
|
"type": "generated-index",
|
||||||
|
"title": "Components"
|
||||||
|
}
|
||||||
|
}
|
913
packages/docs/versioned_docs/version-1.8.3/components/dockview.mdx
vendored
Normal file
913
packages/docs/versioned_docs/version-1.8.3/components/dockview.mdx
vendored
Normal file
@ -0,0 +1,913 @@
|
|||||||
|
---
|
||||||
|
description: Dockview Documentation
|
||||||
|
---
|
||||||
|
|
||||||
|
import { MultiFrameworkContainer } from '@site/src/components/ui/container';
|
||||||
|
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
|
|
||||||
|
import DockviewPersistance from '@site/sandboxes/layout-dockview/src/app';
|
||||||
|
import SimpleDockview from '@site/sandboxes/simple-dockview/src/app';
|
||||||
|
import ResizeDockview from '@site/sandboxes/resize-dockview/src/app';
|
||||||
|
import DockviewWatermark from '@site/sandboxes/watermark-dockview/src/app';
|
||||||
|
import DockviewConstraints from '@site/sandboxes/constraints-dockview/src/app';
|
||||||
|
import DndDockview from '@site/sandboxes/dnd-dockview/src/app';
|
||||||
|
import NestedDockview from '@site/sandboxes/nested-dockview/src/app';
|
||||||
|
import EventsDockview from '@site/sandboxes/events-dockview/src/app';
|
||||||
|
import DockviewGroupControl from '@site/sandboxes/headeractions-dockview/src/app';
|
||||||
|
import CustomHeadersDockview from '@site/sandboxes/customheader-dockview/src/app';
|
||||||
|
import DockviewNative from '@site/sandboxes/fullwidthtab-dockview/src/app';
|
||||||
|
import DockviewNative2 from '@site/sandboxes/nativeapp-dockview/src/app';
|
||||||
|
import DockviewSetTitle from '@site/sandboxes/updatetitle-dockview/src/app';
|
||||||
|
import RenderingDockview from '@site/sandboxes/rendering-dockview/src/app';
|
||||||
|
import DockviewExternalDnd from '@site/sandboxes/externaldnd-dockview/src/app';
|
||||||
|
import DockviewResizeContainer from '@site/sandboxes/resizecontainer-dockview/src/app';
|
||||||
|
import DockviewTabheight from '@site/sandboxes/tabheight-dockview/src/app';
|
||||||
|
import DockviewWithIFrames from '@site/sandboxes/iframe-dockview/src/app';
|
||||||
|
import DockviewFloating from '@site/sandboxes/floatinggroup-dockview/src/app';
|
||||||
|
import DockviewLockedGroup from '@site/sandboxes/lockedgroup-dockview/src/app';
|
||||||
|
|
||||||
|
import { attach as attachDockviewVanilla } from '@site/sandboxes/javascript/vanilla-dockview/src/app';
|
||||||
|
import { attach as attachSimpleDockview } from '@site/sandboxes/javascript/simple-dockview/src/app';
|
||||||
|
import { attach as attachTabHeightDockview } from '@site/sandboxes/javascript/tabheight-dockview/src/app';
|
||||||
|
import { attach as attachNativeDockview } from '@site/sandboxes/javascript/fullwidthtab-dockview/src/app';
|
||||||
|
|
||||||
|
# Dockview
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Dockview is an abstraction built on top of [Gridviews](./gridview) where each view is a container of many tabbed panels.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="simple-dockview"
|
||||||
|
react={SimpleDockview}
|
||||||
|
typescript={attachSimpleDockview}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
> You can access the panels associated group through the `panel.group` variable.
|
||||||
|
> The group will always be defined and will change if a panel is moved into another group.
|
||||||
|
|
||||||
|
## DockviewReact Component
|
||||||
|
|
||||||
|
You can create a Dockview through the use of the `DockviewReact` component.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { DockviewReact } from 'dockview';
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Optional | Default | Description |
|
||||||
|
| --------------------------- | ------------------------------------ | -------- | --------- | ----------- |
|
||||||
|
| onReady | (event: SplitviewReadyEvent) => void | No | | |
|
||||||
|
| components | object | No | | |
|
||||||
|
| tabComponents | object | Yes | | |
|
||||||
|
| watermarkComponent | object | Yes | | |
|
||||||
|
| hideBorders | boolean | Yes | false | |
|
||||||
|
| className | string | Yes | '' | |
|
||||||
|
| disableAutoResizing | boolean | Yes | false | |
|
||||||
|
| onDidDrop | Event | Yes | false | |
|
||||||
|
| showDndOverlay | Event | Yes | false | |
|
||||||
|
| defaultTabComponent | object | Yes | | |
|
||||||
|
| leftHeaderActionsComponent | object | Yes | | |
|
||||||
|
| rightHeaderActionsComponent | object | Yes | | |
|
||||||
|
| singleTabMode | 'fullwidth' \| 'default' | Yes | 'default' | |
|
||||||
|
|
||||||
|
## Dockview API
|
||||||
|
|
||||||
|
The Dockview API is exposed both at the `onReady` event and on each panel through `props.containerApi`.
|
||||||
|
Through this API you can control general features of the component and access all added panels.
|
||||||
|
|
||||||
|
```tsx title="Dockview API via Panel component"
|
||||||
|
const MyComponent = (props: IDockviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.containerApi...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx title="Dockview API via the onReady callback"
|
||||||
|
const onReady = (event: DockviewReadyEvent) => {
|
||||||
|
// event.api...
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ---------------------- | ---------------------------------------------------- | ------------------------- |
|
||||||
|
| height | `number` | Component pixel height |
|
||||||
|
| width | `number` | Component pixel width |
|
||||||
|
| minimumHeight | `number` | |
|
||||||
|
| maximumHeight | `number` | |
|
||||||
|
| maximumWidth | `number` | |
|
||||||
|
| maximumWidth | `number` | |
|
||||||
|
| length | `number` | Number of panels |
|
||||||
|
| size | `number` | Number of Groups |
|
||||||
|
| panels | `IDockviewPanel[]` | |
|
||||||
|
| groups | `GroupPanel[]` | |
|
||||||
|
| activePanel | `IDockviewPanel \| undefined` | |
|
||||||
|
| activeGroup | `IDockviewPanel \| undefined` | |
|
||||||
|
| | | |
|
||||||
|
| onDidLayoutChange | `Event<void>` | |
|
||||||
|
| onDidLayoutFromJSON | `Event<void>` | |
|
||||||
|
| onDidAddGroup | `Event<GroupPanel>` | |
|
||||||
|
| onDidRemoveGroup | `Event<GroupPanel>` | |
|
||||||
|
| onDidActiveGroupChange | `Event<GroupPanel \| undefined>` | |
|
||||||
|
| onDidAddPanel | `Event<IDockviewPanel>` | |
|
||||||
|
| onDidRemovePanel | `Event<IDockviewPanel>` | |
|
||||||
|
| onDidActivePanelChange | `Event<IDockviewPanel \| undefined>` | |
|
||||||
|
| onDidDrop | `Event<DockviewDropEvent` | |
|
||||||
|
| | | |
|
||||||
|
| addPanel | `addPanel(options: AddPanelOptions): IDockviewPanel` | |
|
||||||
|
| getPanel | `(id: string) \| IDockviewPanel \| undefined` | |
|
||||||
|
| addGroup | `(options? AddGroupOptions): void` | |
|
||||||
|
| closeAllGroups | `(): void` | |
|
||||||
|
| removeGroup | `(group: GroupPanel): void` | |
|
||||||
|
| getGroup | `(id: string): GroupPanel \| undefined` | |
|
||||||
|
| | | |
|
||||||
|
| updateOptions | `(options:SplitviewComponentUpdateOptions): void` | |
|
||||||
|
| focus | `(): void` | |
|
||||||
|
| layout | `(width: number, height:number): void` | |
|
||||||
|
| fromJSON | `(data: SerializedDockview): void` | |
|
||||||
|
| toJSON | `(): SerializedDockview` | |
|
||||||
|
| clear | `(): void` | Clears the current layout |
|
||||||
|
|
||||||
|
## Dockview Panel API
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const MyComponent = (props: IDockviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.api...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ---------------------- | ----------------------------------------------------------- | ---------------- |
|
||||||
|
| id | `string` | Panel id |
|
||||||
|
| isFocused | `boolean` | Is panel focused |
|
||||||
|
| isActive | `boolean` | Is panel active |
|
||||||
|
| width | `number` | Panel width |
|
||||||
|
| height | `number` | Panel height |
|
||||||
|
| onDidDimensionsChange | `Event<PanelDimensionChangeEvent>` | |
|
||||||
|
| onDidFocusChange | `Event<FocusEvent>` | |
|
||||||
|
| onDidVisibilityChange | `Event<VisibilityEvent>` | |
|
||||||
|
| onDidActiveChange | `Event<ActiveEvent>` | |
|
||||||
|
| setActive | `(): void` | |
|
||||||
|
| | | |
|
||||||
|
| onDidConstraintsChange | `onDidConstraintsChange: Event<PanelConstraintChangeEvent>` | |
|
||||||
|
| setConstraints | `(value: PanelConstraintChangeEvent2): void;` | |
|
||||||
|
| setSize | `(event: SizeEvent): void` | |
|
||||||
|
| | | |
|
||||||
|
| group | `GroupPanel | undefined` |
|
||||||
|
| isGroupActive | `boolean` | |
|
||||||
|
| title | `string` | |
|
||||||
|
| close | `(): void` | |
|
||||||
|
| setTitle | `(title: string): void` | |
|
||||||
|
|
||||||
|
## Theme
|
||||||
|
|
||||||
|
As well as importing the `dockview` stylesheet you must provide a class-based theme somewhere in your application. For example.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// Providing a theme directly through the DockviewReact component props
|
||||||
|
<DockviewReact className="dockview-theme-dark" />
|
||||||
|
|
||||||
|
// Providing a theme somewhere in the DOM tree
|
||||||
|
<div className="dockview-theme-dark">
|
||||||
|
<div>
|
||||||
|
{/**... */}
|
||||||
|
<DockviewReact />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can find more details on theming <Link to="../theme">here</Link>.
|
||||||
|
|
||||||
|
## Layout Persistance
|
||||||
|
|
||||||
|
Layouts are loaded and saved via to `fromJSON` and `toJSON` methods on the Dockview api.
|
||||||
|
The api also exposes an event `onDidLayoutChange` you can listen on to determine when the layout has changed.
|
||||||
|
Below are some snippets showing how you might load from and save to localStorage.
|
||||||
|
|
||||||
|
```tsx title="Saving the layout state to localStorage"
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!api) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const disposable = api.onDidLayoutChange(() => {
|
||||||
|
const layout = api.toJSON();
|
||||||
|
|
||||||
|
localStorage.setItem(
|
||||||
|
'dockview_persistance_layout',
|
||||||
|
JSON.stringify(layout)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
disposable.dispose();
|
||||||
|
};
|
||||||
|
}, [api]);
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx title="Loading a layout from localStorage"
|
||||||
|
const onReady = (event: DockviewReadyEvent) => {
|
||||||
|
const layoutString = localStorage.getItem('dockview_persistance_layout');
|
||||||
|
|
||||||
|
let success = false;
|
||||||
|
|
||||||
|
if (layoutString) {
|
||||||
|
try {
|
||||||
|
const layout = JSON.parse(layoutString);
|
||||||
|
event.api.fromJSON(layout);
|
||||||
|
success = true;
|
||||||
|
} catch (err) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
// do something if there is no layout or there was a loading error
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is an example using the above code loading from and saving to localStorage.
|
||||||
|
If you refresh the page you should notice your layout is loaded as you left it.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="layout-dockview"
|
||||||
|
react={DockviewPersistance}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Resizing
|
||||||
|
|
||||||
|
### Panel Resizing
|
||||||
|
|
||||||
|
Each Dockview contains of a number of groups and each group has a number of panels.
|
||||||
|
Logically a user may want to resize a panel, but this translates to resizing the group which contains that panel.
|
||||||
|
|
||||||
|
You can set the size of a panel using `props.api.setSize(...)`.
|
||||||
|
You can also set the size of the group associated with the panel using `props.api.group.api.setSize(...)` although this isn't recommended
|
||||||
|
due to the clunky syntax.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// it's mandatory to provide either a height or a width, providing both is optional
|
||||||
|
props.api.setSize({
|
||||||
|
height: 100,
|
||||||
|
width: 200,
|
||||||
|
});
|
||||||
|
|
||||||
|
// you could also resize the panels group, although not recommended it achieved the same result
|
||||||
|
props.api.group.api.setSize({
|
||||||
|
height: 100,
|
||||||
|
width: 200,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
You can see an example invoking both approaches below.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer sandboxId="resize-dockview" react={ResizeDockview} />
|
||||||
|
|
||||||
|
### Container Resizing
|
||||||
|
|
||||||
|
The component will automatically resize to it's container.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="resizecontainer-dockview"
|
||||||
|
react={DockviewResizeContainer}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Watermark
|
||||||
|
|
||||||
|
When the dockview is empty you may want to display some fallback content, this is refered to as the `watermark`.
|
||||||
|
By default there the watermark has no content but you can provide as a prop to `DockviewReact` a `watermarkComponent`
|
||||||
|
which will be rendered when there are no panels or groups.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="watermark-dockview"
|
||||||
|
react={DockviewWatermark}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Drag And Drop
|
||||||
|
|
||||||
|
### Built-in behaviours
|
||||||
|
|
||||||
|
Dockview supports a wide variety of built-in Drag and Drop possibilities.
|
||||||
|
Below are some examples of the operations you can perform.
|
||||||
|
|
||||||
|
<img style={{ width: '60%' }} src={useBaseUrl('/img/add_to_tab.svg')} />
|
||||||
|
|
||||||
|
> Drag a tab onto another tab to place it inbetween existing tabs.
|
||||||
|
|
||||||
|
<img style={{ width: '60%' }} src={useBaseUrl('/img/add_to_empty_space.svg')} />
|
||||||
|
|
||||||
|
> Drag a tab to the right of the last tab to place it after the existing tabs.
|
||||||
|
|
||||||
|
<img style={{ width: '60%' }} src={useBaseUrl('/img/add_to_group.svg')} />
|
||||||
|
|
||||||
|
> Drag a group onto an existing group to merge the two groups.
|
||||||
|
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'space-around' }}>
|
||||||
|
<img style={{ width: '40%' }} src={useBaseUrl('/img/drop_positions.svg')} />
|
||||||
|
<img
|
||||||
|
style={{ width: '40%' }}
|
||||||
|
src={useBaseUrl('/img/magnet_drop_positions.svg')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
> Drag into the left/right/top/bottom target zone of a panel to create a new group in the selected direction.
|
||||||
|
|
||||||
|
> Drag into the center of a panel to add to that group.
|
||||||
|
|
||||||
|
> Drag to the edge of the dockview component to create a new group on the selected edge.
|
||||||
|
|
||||||
|
### Extended behaviours
|
||||||
|
|
||||||
|
For interaction with the Drag events directly the component exposes some method to help determine whether external drag events should be interacted with or not.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
/**
|
||||||
|
* called when an ondrop event which does not originate from the dockview libray and
|
||||||
|
* passes the showDndOverlay condition occurs
|
||||||
|
**/
|
||||||
|
const onDidDrop = (event: DockviewDropEvent) => {
|
||||||
|
const { group } = event;
|
||||||
|
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'test',
|
||||||
|
component: 'default',
|
||||||
|
position: {
|
||||||
|
referencePanel: group.activePanel.id,
|
||||||
|
direction: 'within',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called for drag over events which do not originate from the dockview library
|
||||||
|
* allowing the developer to decide where the overlay should be shown for a
|
||||||
|
* particular drag event
|
||||||
|
**/
|
||||||
|
const showDndOverlay = (event: DockviewDndOverlayEvent) => {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DockviewReact
|
||||||
|
components={components}
|
||||||
|
onReady={onReady}
|
||||||
|
className="dockview-theme-abyss"
|
||||||
|
onDidDrop={onDidDrop}
|
||||||
|
showDndOverlay={showDndOverlay}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Intercepting Drag Events
|
||||||
|
|
||||||
|
You can intercept drag events to attach your own metadata using the `onWillDragPanel` and `onWillDragGroup` api methods.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer sandboxId="dnd-dockview" react={DndDockview} />
|
||||||
|
|
||||||
|
### Third Party Dnd Libraries
|
||||||
|
|
||||||
|
This shows a simple example of a third-party library used inside a panel that relies on drag
|
||||||
|
and drop functionalities. This examples serves to show that `dockview` doesn't interfer with
|
||||||
|
any drag and drop logic for other controls.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="externaldnd-dockview"
|
||||||
|
react={DockviewExternalDnd}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Floating Groups
|
||||||
|
|
||||||
|
Dockview has built-in support for floating groups. Each floating container can contain a single group with many panels
|
||||||
|
and you can have as many floating containers as needed. You cannot dock multiple groups together in the same floating container.
|
||||||
|
|
||||||
|
Floating groups can be interacted with whilst holding the `shift` key activating the `event.shiftKey` boolean property on `KeyboardEvent` events.
|
||||||
|
|
||||||
|
> Float an existing tab by holding `shift` whilst interacting with the tab
|
||||||
|
|
||||||
|
<img style={{ width: '60%' }} src={useBaseUrl('/img/float_add.svg')} />
|
||||||
|
|
||||||
|
> Move a floating tab by holding `shift` whilst moving the cursor or dragging the empty
|
||||||
|
> header space
|
||||||
|
|
||||||
|
<img style={{ width: '60%' }} src={useBaseUrl('/img/float_move.svg')} />
|
||||||
|
|
||||||
|
> Move an entire floating group by holding `shift` whilst dragging the empty header space
|
||||||
|
|
||||||
|
<img style={{ width: '60%' }} src={useBaseUrl('/img/float_group.svg')} />
|
||||||
|
|
||||||
|
Floating groups can be programatically added through the dockview `api` method `api.addFloatingGroup(...)` and you can check whether
|
||||||
|
a group is floating via the `group.api.isFloating` property. See examples for full code.
|
||||||
|
|
||||||
|
You can control the bounding box of floating groups through the optional `floatingGroupBounds` options:
|
||||||
|
|
||||||
|
- `boundedWithinViewport` will force the entire floating group to be bounded within the docks viewport.
|
||||||
|
- `{minimumHeightWithinViewport?: number, minimumWidthWithinViewport?: number}` sets the respective dimension minimums that must appears within the docks viewport
|
||||||
|
- If no options are provided the defaults of `100px` minimum height and width within the viewport are set.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
height={600}
|
||||||
|
sandboxId="floatinggroup-dockview"
|
||||||
|
react={DockviewFloating}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Panels
|
||||||
|
|
||||||
|
### Add Panel
|
||||||
|
|
||||||
|
Using the dockview API you can access the `addPanel` method which returns an instance of the created panel.
|
||||||
|
The minimum method signature is:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const panel = api.addPanel({
|
||||||
|
id: 'my_unique_panel_id',
|
||||||
|
component: 'my_component',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
where `id` is the unique id of the panel and `component` is the implenentation which
|
||||||
|
will be used to render the panel. You will have registered this using the `components` prop of the `DockviewReactComponent` component.
|
||||||
|
|
||||||
|
You can optionally provide a `tabComponent` parameters to the `addPanel` method which will render the tab using a custom renderer.
|
||||||
|
You will have registered this using the `tabComponents` prop of the `DockviewReactComponent` component.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const panel = api.addPanel({
|
||||||
|
id: 'my_unique_panel_id',
|
||||||
|
component: 'my_component',
|
||||||
|
tabComponent: 'my_tab_component',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
You can pass properties to the panel using the `params` key.
|
||||||
|
You can update these properties through the panels `api` object and its `updateParameters` method.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const panel = api.addPanel({
|
||||||
|
id: 'my_unique_panel_id',
|
||||||
|
component: 'my_component',
|
||||||
|
params: {
|
||||||
|
myCustomKey: 'my_custom_value',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
panel.api.updateParameters({
|
||||||
|
myCustomKey: 'my_custom_value',
|
||||||
|
myOtherCustomKey: 'my_other_custom_key',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note `updateParameters` does not accept partial parameter updates, you should call it with the entire set of parameters
|
||||||
|
> you want the panel to receive.
|
||||||
|
|
||||||
|
Finally `addPanel` accepts a `position` object which tells dockview where to place the panel.
|
||||||
|
|
||||||
|
- This object optionally accepts either a `referencePanel` or `referenceGroup` which can be the associated id as a string
|
||||||
|
or the panel/group object reference.
|
||||||
|
- This object accepts a `direction` property which dictates where,
|
||||||
|
relative to the provided reference the new panel will be placed.
|
||||||
|
|
||||||
|
> If neither a `referencePanel` or `referenceGroup` then the provided `direction` will be treated as absolute.
|
||||||
|
|
||||||
|
> If no `direction` is provided the library will place the new panel in a pre-determined position.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const panel = api.addPanel({
|
||||||
|
id: 'panel_1',
|
||||||
|
component: 'default',
|
||||||
|
});
|
||||||
|
|
||||||
|
const panel2 = api.addPanel({
|
||||||
|
id: 'panel_2',
|
||||||
|
component: 'default',
|
||||||
|
position: {
|
||||||
|
referencePanel: panel1,
|
||||||
|
direction: 'right',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
To add a floating panel you should include the `floating` variable which can be either a `boolean` or an object defining it's bounds.
|
||||||
|
These bounds are relative to the dockview component.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const panel1 = api.addPanel({
|
||||||
|
id: 'panel_2',
|
||||||
|
component: 'default',
|
||||||
|
floating: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const panel2 = api.addPanel({
|
||||||
|
id: 'panel_2',
|
||||||
|
component: 'default',
|
||||||
|
floating: { x: 10, y: 10, width: 300, height: 300 },
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update Panel
|
||||||
|
|
||||||
|
You can programatically update the `params` passed through to the panel through the panal api using `api.updateParameters`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const panel = api.addPanel({
|
||||||
|
id: 'panel_1',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
keyA: 'valueA',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
panel.api.updateParameters({
|
||||||
|
keyB: 'valueB',
|
||||||
|
});
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
panel.api.updateParameters({
|
||||||
|
keyA: 'anotherValueA',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
To delete a parameter you should pass a value of `undefined` for the key.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
panel.api.updateParameters({
|
||||||
|
keyA: undefined, // this will delete 'keyA'.
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Move panel
|
||||||
|
|
||||||
|
You can programatically move a panel using the panel `api`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
panel.api.moveTo({ group, position, index });
|
||||||
|
```
|
||||||
|
|
||||||
|
An equivalent method for moving groups is avaliable on the group `api`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const group = panel.api.group;
|
||||||
|
group.api.moveTo({ group, position });
|
||||||
|
```
|
||||||
|
|
||||||
|
### Remove panel
|
||||||
|
|
||||||
|
You can programatically remove a panel using the panel `api`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
panel.api.close();
|
||||||
|
```
|
||||||
|
|
||||||
|
Given a reference to the panel you can also use the component `api` to remove it.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const panel = api.getPanel('myPanel');
|
||||||
|
api.removePanel(panel);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Panel Rendering
|
||||||
|
|
||||||
|
By default `DockviewReact` only adds to the DOM those panels that are visible,
|
||||||
|
if a panel is not the active tab and not shown the contents of the hidden panel will be removed from the DOM.
|
||||||
|
|
||||||
|
However the React Components associated with each panel are only created once and will always exist for as long as the panel exists, hidden or not.
|
||||||
|
|
||||||
|
> For example this means that any hooks in those components will run whether the panel is visible or not which may lead to excessive background work depending
|
||||||
|
> on the panels implementation.
|
||||||
|
|
||||||
|
This is the default behaviour to ensure the greatest flexibility for the user but through the panels `props.api` you can listen to the visiblity state of the panel
|
||||||
|
and write additional logic to optimize your application.
|
||||||
|
|
||||||
|
For example if you wanted to unmount the React Components when the panel is not visible you could create a Higher-Order-Component that listens to the panels
|
||||||
|
visiblity state and only renders the panel when visible.
|
||||||
|
|
||||||
|
```tsx title="Only rendering the React Component when the panel is visible, otherwise rendering a null React Component"
|
||||||
|
import { IDockviewPanelProps } from 'dockview';
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
function RenderWhenVisible(
|
||||||
|
component: React.FunctionComponent<IDockviewPanelProps>
|
||||||
|
) {
|
||||||
|
const HigherOrderComponent = (props: IDockviewPanelProps) => {
|
||||||
|
const [visible, setVisible] = React.useState<boolean>(
|
||||||
|
props.api.isVisible
|
||||||
|
);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const disposable = props.api.onDidVisibilityChange((event) =>
|
||||||
|
setVisible(event.isVisible)
|
||||||
|
);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
disposable.dispose();
|
||||||
|
};
|
||||||
|
}, [props.api]);
|
||||||
|
|
||||||
|
if (!visible) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return React.createElement(component, props);
|
||||||
|
};
|
||||||
|
return HigherOrderComponent;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const components = { default: RenderWhenVisible(MyComponent) };
|
||||||
|
```
|
||||||
|
|
||||||
|
Toggling the checkbox you can see that when you only render those panels which are visible the underling React component is destroyed when it becomes hidden and re-created when it becomes visible.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="rendering-dockview"
|
||||||
|
react={RenderingDockview}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Headers
|
||||||
|
|
||||||
|
### Custom Tab Headers
|
||||||
|
|
||||||
|
You can provide custom renderers for your tab headers for maximum customization.
|
||||||
|
A default implementation of `DockviewDefaultTab` is provided should you only wish to attach minor
|
||||||
|
changes and events that do not alter the default behaviour, for example to add a custom context menu event
|
||||||
|
handler.
|
||||||
|
|
||||||
|
The `DockviewDefaulTab` component accepts a `hideClose` prop if you wish only to hide the close button.
|
||||||
|
|
||||||
|
```tsx title="Attaching a custom context menu event handlers to a custom header"
|
||||||
|
import { IDockviewPanelHeaderProps, DockviewDefaultTab } from 'dockview';
|
||||||
|
|
||||||
|
const MyCustomheader = (props: IDockviewPanelHeaderProps) => {
|
||||||
|
const onContextMenu = (event: React.MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
alert('context menu');
|
||||||
|
};
|
||||||
|
return <DockviewDefaultTab onContextMenu={onContextMenu} {...props} />;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
You are also free to define a custom renderer entirely from scratch and not make use of the `DockviewDefaultTab` component.
|
||||||
|
To use a custom renderer you can must register a collection of tab components.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const tabComponents = {
|
||||||
|
myCustomHeader: MyCustomHeader,
|
||||||
|
};
|
||||||
|
|
||||||
|
return <DockviewReact tabComponents={tabComponents} ... />;
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.addPanel({
|
||||||
|
id: 'panel_1',
|
||||||
|
component: 'default',
|
||||||
|
tabComponent: 'myCustomHeader', // <-- your registered renderers
|
||||||
|
title: 'Panel 1',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also override the default tab renderer which will be used when no `tabComponent` is provided to the `addPanel` function.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
<DockviewReact defaultTabComponent={MyCustomHeader} ... />;
|
||||||
|
```
|
||||||
|
|
||||||
|
As a simple example the below attaches a custom event handler for the context menu on all tabs as a default tab renderer
|
||||||
|
|
||||||
|
The below example uses a custom tab renderer to reigster a popover when the user right clicked on a tab.
|
||||||
|
This still makes use of the `DockviewDefaultTab` since it's only a minor change.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="customheader-dockview"
|
||||||
|
react={CustomHeadersDockview}
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Default Tab Title
|
||||||
|
|
||||||
|
If you are using the default tab renderer you can set the title of a tab when creating it
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.addPanel({
|
||||||
|
id: 'panel_1',
|
||||||
|
component: 'my_component',
|
||||||
|
title: 'my_custom_title', // <-- special param for title
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
You can update the title through the panel api which can be accessed via `props.api` if you are inside the panel
|
||||||
|
component or via `api.getPanel('panel1').api` if you are accessing from outside of the panel component.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.setTitle('my_new_custom_title');
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note this only works when using the default tab implementation.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="updatetitle-dockview"
|
||||||
|
react={DockviewSetTitle}
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Custom Tab Title
|
||||||
|
|
||||||
|
If you are using a custom tab implementation you should pass variables through as a parameter and render them
|
||||||
|
through your tab components implementation.
|
||||||
|
|
||||||
|
```tsx title="Add a panel with custom parameters"
|
||||||
|
api.addPanel({
|
||||||
|
id: 'panel_2',
|
||||||
|
component: 'my_component',
|
||||||
|
tabComponent: 'my_tab',
|
||||||
|
params: {
|
||||||
|
myTitle: 'Window 2', // <-- passing a variable to use as a title
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx title="Accessing custom parameters from a custom tab renderer"
|
||||||
|
const tabComponents = {
|
||||||
|
default: (props: IDockviewPanelHeaderProps<{ myTitle: string }>) => {
|
||||||
|
const title = props.params.myTitle; // <-- accessing my custom varaible
|
||||||
|
return <div>{/** tab implementation as chosen by developer */}</div>;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Hidden Headers
|
||||||
|
|
||||||
|
You may wish to hide the header section of a group. This can achieved through the `hidden` variable on `panel.group.header`.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
panel.group.header.hidden = true;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Full width tabs
|
||||||
|
|
||||||
|
`DockviewReactComponent` accepts the prop `singleTabMode`. If set `singleTabMode=fullwidth` then when there is only one tab in a group this tab will expand
|
||||||
|
to the entire width of the group. For example:
|
||||||
|
|
||||||
|
> This can be conmbined with <Link to="./dockview/#locked-group">Locked Groups</Link> to create an application that feels more like a Window Manager
|
||||||
|
> rather than a collection of groups and tabs.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
<DockviewReactComponent singleTabMode="fullwidth" {...otherProps} />
|
||||||
|
```
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="fullwidthtab-dockview"
|
||||||
|
react={DockviewNative}
|
||||||
|
typescript={attachNativeDockview}
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Tab Height
|
||||||
|
|
||||||
|
Tab height can be controlled through CSS.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="tabheight-dockview"
|
||||||
|
react={DockviewTabheight}
|
||||||
|
typescript={attachTabHeightDockview}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Groups
|
||||||
|
|
||||||
|
### Locked group
|
||||||
|
|
||||||
|
Locking a group will disable all drop events for this group ensuring no additional panels can be added to the group through drop events.
|
||||||
|
You can still add groups to a locked panel programatically using the API though.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
panel.group.locked = true;
|
||||||
|
|
||||||
|
// Or
|
||||||
|
|
||||||
|
panel.group.locked = 'no-drop-target';
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `true` to keep drop zones top, right, bottom, left for the group. Use `no-drop-target` to disable all drop zones. For you to get a
|
||||||
|
better understanding of what this means, try and drag the panels in the example below to the locked groups.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="lockedgroup-dockview"
|
||||||
|
react={DockviewLockedGroup}
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Group Controls Panel
|
||||||
|
|
||||||
|
`DockviewReact` accepts `leftHeaderActionsComponent` and `rightHeaderActionsComponent` which expect a React component with props `IDockviewHeaderActionsProps`.
|
||||||
|
These controls are rendered of the left and right side of the space to the right of the tabs in the header bar.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const Component: React.FunctionComponent<IDockviewHeaderActionsProps> = () => {
|
||||||
|
return <div>{'...'}</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
return <DockviewReact {...props} leftHeaderActionsComponent={Component} rightHeaderActionsComponent={...} />;
|
||||||
|
```
|
||||||
|
|
||||||
|
As a simple example the below uses the `groupControlComponent` to render a small control that indicates whether the group
|
||||||
|
is active and which panel is active in that group.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const RightHeaderActionsComponent = (props: IDockviewHeaderActionsProps) => {
|
||||||
|
const isGroupActive = props.isGroupActive;
|
||||||
|
const activePanel = props.activePanel;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="dockview-groupcontrol-demo">
|
||||||
|
<span
|
||||||
|
className="dockview-groupcontrol-demo-group-active"
|
||||||
|
style={{
|
||||||
|
background: isGroupActive ? 'green' : 'red',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isGroupActive ? 'Group Active' : 'Group Inactive'}
|
||||||
|
</span>
|
||||||
|
<span className="dockview-groupcontrol-demo-active-panel">{`activePanel: ${
|
||||||
|
activePanel?.id || 'null'
|
||||||
|
}`}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="groupcontrol-dockview"
|
||||||
|
react={DockviewGroupControl}
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Constraints
|
||||||
|
|
||||||
|
You may wish to specify a minimum or maximum height or width for a group which can be done through the group api.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.group.api.setConstraints(...)
|
||||||
|
```
|
||||||
|
|
||||||
|
> Constraints are currently only supported for groups and not individual panels.
|
||||||
|
> If you specific a constraint on a group and move a panel within that group to another group it will no
|
||||||
|
> longer be subject to those constraints since those constraints were on the group and not on the individual panel.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
height={500}
|
||||||
|
sandboxId="constraints-dockview"
|
||||||
|
react={DockviewConstraints}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## iFrames
|
||||||
|
|
||||||
|
iFrames required special attention because of a particular behaviour in how iFrames render:
|
||||||
|
|
||||||
|
> Re-parenting an iFrame will reload the contents of the iFrame or the rephrase this, moving an iFrame within the DOM will cause a reload of its contents.
|
||||||
|
|
||||||
|
You can find many examples of discussions on this. Two reputable forums for example are linked [here](https://bugzilla.mozilla.org/show_bug.cgi?id=254144) and [here](https://github.com/whatwg/html/issues/5484).
|
||||||
|
|
||||||
|
The problem with iFrames and `dockview` is that when you hide or move a panel that panels DOM element may be moved within the DOM or removed from the DOM completely.
|
||||||
|
If your panel contains an iFrame then that iFrame will reload after being re-positioned within the DOM tree and all state in that iFrame will most likely be lost.
|
||||||
|
|
||||||
|
`dockview` does not provide a built-in solution to this because it's too specific of a problem to include in the library.
|
||||||
|
However the below example does show an implementation of a higher-order component `HoistedDockviewPanel`that you could use to work around this problems and make iFrames behave in `dockview`.
|
||||||
|
|
||||||
|
What the higher-order component is doing is to hoist the panels contents into a DOM element that is always present and then `position: absolute` that element to match the dimensions of it's linked panel.
|
||||||
|
The visibility of these hoisted elements is then controlled through some exposed api methods to hide elements that shouldn't be currently shown.
|
||||||
|
|
||||||
|
You should open this example in CodeSandbox using the provided link to understand the code and make use of this implemention if required.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
sandboxId="iframe-dockview"
|
||||||
|
height={600}
|
||||||
|
react={DockviewWithIFrames}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
A simple example showing events fired by `dockviewz that can be interacted with.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer
|
||||||
|
height={600}
|
||||||
|
sandboxId="events-dockview"
|
||||||
|
react={EventsDockview}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Advanced Examples
|
||||||
|
|
||||||
|
### Nested Dockviews
|
||||||
|
|
||||||
|
You can safely create multiple dockview instances within one page and nest dockviews within other dockviews.
|
||||||
|
If you wish to interact with the drop event from one dockview instance in another dockview instance you can implement the `showDndOverlay` and `onDidDrop` props on `DockviewReact`.
|
||||||
|
|
||||||
|
<MultiFrameworkContainer sandboxId="nested-dockview" react={NestedDockview} />
|
||||||
|
|
||||||
|
### Window-like mananger with tabs
|
||||||
|
|
||||||
|
<DockviewNative2 />
|
120
packages/docs/versioned_docs/version-1.8.3/components/gridview.mdx
vendored
Normal file
120
packages/docs/versioned_docs/version-1.8.3/components/gridview.mdx
vendored
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
---
|
||||||
|
description: Gridview Documentation
|
||||||
|
---
|
||||||
|
|
||||||
|
import { SimpleGridview } from '@site/src/components/simpleGridview';
|
||||||
|
import { EventsGridview } from '@site/src/components/gridview/events';
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
|
||||||
|
# Gridview
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '300px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleGridview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## GridviewReact Component
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { ReactGridview } from 'dockview';
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Optional | Default | Description |
|
||||||
|
| ------------------- | ------------------------------------ | -------- | ---------------------- | ----------- |
|
||||||
|
| onReady | (event: SplitviewReadyEvent) => void | No | | |
|
||||||
|
| components | object | No | | |
|
||||||
|
| orientation | Orientation | Yes | Orientation.HORIZONTAL | |
|
||||||
|
| proportionalLayout | boolean | Yes | true | |
|
||||||
|
| hideBorders | boolean | Yes | false | |
|
||||||
|
| className | string | Yes | '' | |
|
||||||
|
| disableAutoResizing | boolean | Yes | false | > |
|
||||||
|
|
||||||
|
## Gridview API
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const MyComponent = (props: IGridviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.containerApi...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const onReady = (event: GridviewReadyEvent) => {
|
||||||
|
// event.api...
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ---------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
|
||||||
|
| height | `number` | Component pixel height |
|
||||||
|
| width | `number` | Component pixel width |
|
||||||
|
| minimumHeight | `number` | |
|
||||||
|
| maximumHeight | `number` | |
|
||||||
|
| maximumWidth | `number` | |
|
||||||
|
| maximumWidth | `number` | |
|
||||||
|
| length | `number` | Number of panels |
|
||||||
|
| panels | `ISplitviewPanel[]` | all panels |
|
||||||
|
| orientation | `Orientation` | |
|
||||||
|
| | | |
|
||||||
|
| onDidLayoutChange | `Event<void>` | Fires on layout change |
|
||||||
|
| onDidLayoutFromJSON | `Event<void>` | Fires of layout change caused by a fromJSON deserialization call |
|
||||||
|
| onDidAddPanel | `Event<IGridviewPanel>` | Fires when a view is added |
|
||||||
|
| onDidRemovePanel | `Event<IGridviewPanel>` | Fires when a view is removed |
|
||||||
|
| onDidActivePanelChange | `Event<IGridviewPanel \| undefined>` | Fires when the active group changes |
|
||||||
|
| | | |
|
||||||
|
| addPanel | `addPanel(options: AddComponentOptions): IGridviewPanel` | |
|
||||||
|
| removePanel | `(panel: IGridviewPanel, sizing?: Sizing): void` | |
|
||||||
|
| movePanel | `(panel: IGridviewPanel, options: {direction: Direction, refernece:string, size?: number}): void` | |
|
||||||
|
| getPanel | `(id: string) \| IGridviewPanel \| undefined` | |
|
||||||
|
| | | |
|
||||||
|
| updateOptions | `(options:SplitviewComponentUpdateOptions): void` | |
|
||||||
|
| focus | `(): void` | Focus the active panel, if exists |
|
||||||
|
| layout | `(width: number, height:number): void` | |
|
||||||
|
| fromJSON | `(data: SerializedGridview): void` | |
|
||||||
|
| toJSON | `(): SerializedGridview` | |
|
||||||
|
| clear | `(): void` | Clears the current layout |
|
||||||
|
|
||||||
|
## Gridview Panel API
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const MyComponent = (props: IGridviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.api...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ---------------------- | ----------------------------------------------------------- | ---------------- |
|
||||||
|
| id | `string` | Panel id |
|
||||||
|
| isFocused | `boolean` | Is panel focsed |
|
||||||
|
| isActive | `boolean` | Is panel active |
|
||||||
|
| isVisible | `boolean` | Is panel visible |
|
||||||
|
| width | `number` | Panel width |
|
||||||
|
| height | `number` | Panel height |
|
||||||
|
| | | |
|
||||||
|
| onDidDimensionsChange | `Event<PanelDimensionChangeEvent>` | |
|
||||||
|
| onDidFocusChange | `Event<FocusEvent>` | |
|
||||||
|
| onDidVisibilityChange | `Event<VisibilityEvent>` | |
|
||||||
|
| onDidActiveChange | `Event<ActiveEvent>` | |
|
||||||
|
| onDidConstraintsChange | `onDidConstraintsChange: Event<PanelConstraintChangeEvent>` | |
|
||||||
|
| | | |
|
||||||
|
| setVisible | `(isVisible: boolean): void` | |
|
||||||
|
| setActive | `(): void` | |
|
||||||
|
| setConstraints | `(value: PanelConstraintChangeEvent2): void;` | |
|
||||||
|
| setSize | `(event: SizeEvent): void` | |
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
`GridviewReact` exposes a number of events that the developer can listen to and below is a simple example with a log panel showing those events that occur.
|
||||||
|
|
||||||
|
<EventsGridview />
|
285
packages/docs/versioned_docs/version-1.8.3/components/paneview.mdx
vendored
Normal file
285
packages/docs/versioned_docs/version-1.8.3/components/paneview.mdx
vendored
Normal file
@ -0,0 +1,285 @@
|
|||||||
|
---
|
||||||
|
description: Paneview Documentation
|
||||||
|
---
|
||||||
|
|
||||||
|
import { SimplePaneview } from '@site/src/components/simplePaneview';
|
||||||
|
import { CustomHeaderPaneview } from '@site/src/components/paneview/customHeader';
|
||||||
|
import { DragAndDropPaneview } from '@site/src/components/paneview/dragAndDrop';
|
||||||
|
import { SideBySidePaneview } from '@site/src/components/paneview/sideBySide';
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
|
||||||
|
# Paneview
|
||||||
|
|
||||||
|
A paneview is a collapsed collection of vertically stacked panels and panel headers.
|
||||||
|
The panel header will always remain visible however the panel will only be visible when the panel is expanded.
|
||||||
|
|
||||||
|
:::info
|
||||||
|
|
||||||
|
Paneview panels can be re-ordered by dragging and dropping the panel headers.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Introduction
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '400px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimplePaneview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
```tsx title="Simple Paneview example"
|
||||||
|
import {
|
||||||
|
IPaneviewPanelProps,
|
||||||
|
PaneviewReact,
|
||||||
|
PaneviewReadyEvent,
|
||||||
|
} from 'dockview';
|
||||||
|
|
||||||
|
const components = {
|
||||||
|
default: (props: IPaneviewPanelProps<{ title: string }>) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
padding: '10px',
|
||||||
|
height: '100%',
|
||||||
|
backgroundColor: 'rgb(60,60,60)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{props.params.title}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
SimplePaneview = () => {
|
||||||
|
const onReady = (event: PaneviewReadyEvent) => {
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_1',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 1',
|
||||||
|
},
|
||||||
|
title: 'Panel 1',
|
||||||
|
});
|
||||||
|
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_2',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 2',
|
||||||
|
},
|
||||||
|
title: 'Panel 2',
|
||||||
|
});
|
||||||
|
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_3',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 3',
|
||||||
|
},
|
||||||
|
title: 'Panel 3',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PaneviewReact
|
||||||
|
components={components}
|
||||||
|
headerComponents={headerComponents}
|
||||||
|
onReady={onReady}
|
||||||
|
className="dockview-theme-abyss"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## PaneviewReact Component
|
||||||
|
|
||||||
|
You can create a Paneview through the use of the `ReactPaneview` component.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { ReactPaneview } from 'dockview';
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Optional | Default | Description |
|
||||||
|
| ------------------- | ------------------------------------ | -------- | ------- | ----------- |
|
||||||
|
| onReady | (event: SplitviewReadyEvent) => void | No | | |
|
||||||
|
| components | object | No | | |
|
||||||
|
| headerComponents | object | Yes | | |
|
||||||
|
| className | string | Yes | '' | |
|
||||||
|
| disableAutoResizing | boolean | Yes | false | |
|
||||||
|
| disableDnd | boolean | Yes | false | |
|
||||||
|
| onDidDrop | Event | Yes | | |
|
||||||
|
|
||||||
|
## Paneview API
|
||||||
|
|
||||||
|
The Paneview API is exposed both at the `onReady` event and on each panel through `props.containerApi`.
|
||||||
|
Through this API you can control general features of the component and access all added panels.
|
||||||
|
|
||||||
|
```tsx title="Paneview API via Panel component"
|
||||||
|
const MyComponent = (props: IGridviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.containerApi...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx title="Paneview API via the onReady callback"
|
||||||
|
const onReady = (event: GridviewReadyEvent) => {
|
||||||
|
// event.api...
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
||||||
|
| height | `number` | Component pixel height |
|
||||||
|
| width | `number` | Component pixel width |
|
||||||
|
| minimumSize | `number` | The sum of the `minimumSize` property for each panel |
|
||||||
|
| maximumSize | `number` | The sum of the `maximumSize` property for each panel |
|
||||||
|
| length | `number` | Number of panels |
|
||||||
|
| panels | `IPaneviewPanel[]` | All panels |
|
||||||
|
| | | |
|
||||||
|
| onDidLayoutChange | `Event<void>` | Fires on layout change |
|
||||||
|
| onDidLayoutFromJSON | `Event<void>` | Fires of layout change caused by a fromJSON deserialization call |
|
||||||
|
| onDidAddView | `Event<IPaneviewPanel>` | Fires when a view is added |
|
||||||
|
| onDidRemoveView | `Event<IPaneviewPanel>` | Fires when a view is removed |
|
||||||
|
| onDidDrop | `Event<PaneviewDropEvent` | Fires on an external drop event (See <Link to="./paneview/#drag-and-drop">Drag and Drop</Link>) |
|
||||||
|
| | | |
|
||||||
|
| addPanel | `addPanel(options: AddPaneviewComponentOptions): IPaneviewPanel` | |
|
||||||
|
| removePanel | `(panel: IPaneviewPanel): void` | |
|
||||||
|
| movePanel | `(from: number, to: number): void` | |
|
||||||
|
| getPanel | `(id:string): IPaneviewPanel \| undefined` | |
|
||||||
|
| | | |
|
||||||
|
| focus | `(): void` | Focus the active panel, if exists |
|
||||||
|
| layout | `(width: number, height:number): void` | |
|
||||||
|
| fromJSON | `(data: SerializedPaneview): void` | |
|
||||||
|
| toJSON | `(): SerializedPaneview` | |
|
||||||
|
| clear | `(): void` | Clears the current layout |
|
||||||
|
|
||||||
|
## Paneview Panel API
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const MyComponent = (props: IGridviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.api...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ---------------------- | ----------------------------------------------------------- | ---------------- |
|
||||||
|
| id | `string` | Panel id |
|
||||||
|
| isFocused | `boolean` | Is panel focsed |
|
||||||
|
| isActive | `boolean` | Is panel active |
|
||||||
|
| isVisible | `boolean` | Is panel visible |
|
||||||
|
| width | `number` | Panel width |
|
||||||
|
| height | `number` | Panel height |
|
||||||
|
| | |
|
||||||
|
| onDidDimensionsChange | `Event<PanelDimensionChangeEvent>` | |
|
||||||
|
| onDidFocusChange | `Event<FocusEvent>` | |
|
||||||
|
| onDidVisibilityChange | `Event<VisibilityEvent>` | |
|
||||||
|
| onDidActiveChange | `Event<ActiveEvent>` | |
|
||||||
|
| onDidConstraintsChange | `onDidConstraintsChange: Event<PanelConstraintChangeEvent>` | |
|
||||||
|
| | |
|
||||||
|
| setVisible | `(isVisible: boolean): void` | |
|
||||||
|
| setActive | `(): void` | |
|
||||||
|
| setConstraints | `(value: PanelConstraintChangeEvent2): void;` | |
|
||||||
|
| setSize | `(event: SizeEvent): void` | |
|
||||||
|
|
||||||
|
## Advanced Features
|
||||||
|
|
||||||
|
### Custom Header
|
||||||
|
|
||||||
|
You can provide a custom component to render an alternative header.
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '400px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CustomHeaderPaneview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
You can provide a `headerComponent` option when creating a panel to tell the library to use a custom header component.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const onReady = (event: PaneviewReadyEvent) => {
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_1',
|
||||||
|
component: 'default',
|
||||||
|
headerComponent: 'myHeaderComponent',
|
||||||
|
params: {
|
||||||
|
valueA: 'A',
|
||||||
|
},
|
||||||
|
title: 'Panel 1',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
This header must be defined in the collection of components provided to the `headerComponents` props for `ReactPaneivew`
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { IPaneviewPanelProps } from 'dockview';
|
||||||
|
|
||||||
|
const MyHeaderComponent = (props: IPaneviewPanelProps<{ title: string }>) => {
|
||||||
|
const [expanded, setExpanded] = React.useState<boolean>(
|
||||||
|
props.api.isExpanded
|
||||||
|
);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const disposable = props.api.onDidExpansionChange((event) => {
|
||||||
|
setExpanded(event.isExpanded);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
disposable.dispose();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onClick = () => {
|
||||||
|
props.api.setExpanded(!expanded);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
padding: '10px',
|
||||||
|
height: '100%',
|
||||||
|
backgroundColor: 'rgb(60,60,60)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
onClick={onClick}
|
||||||
|
className={expanded ? 'expanded' : 'collapsed'}
|
||||||
|
/>
|
||||||
|
<span>{props.params.title}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const headerComponents = { myHeaderComponent: MyHeaderComponent };
|
||||||
|
```
|
||||||
|
|
||||||
|
### Drag And Drop
|
||||||
|
|
||||||
|
If you provide the `PaneviewReact` component with the prop `onDidDrop` you will be able to interact with custom drop events.
|
||||||
|
|
||||||
|
<DragAndDropPaneview />
|
||||||
|
|
||||||
|
### Interactions
|
||||||
|
|
||||||
|
You can safely create multiple paneview instances within one page. They will not interact with each other by default.
|
||||||
|
|
||||||
|
If you wish to interact with the drop event from one paneview instance in another paneview instance you can implement the `showDndOverlay` and `onDidDrop` props on `PaneviewReact`.
|
||||||
|
|
||||||
|
As an example see how dragging a header from one control to another will only trigger an interactable event for the developer if the checkbox is enabled.
|
||||||
|
|
||||||
|
<SideBySidePaneview />
|
246
packages/docs/versioned_docs/version-1.8.3/components/splitview.mdx
vendored
Normal file
246
packages/docs/versioned_docs/version-1.8.3/components/splitview.mdx
vendored
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
---
|
||||||
|
description: Splitview Documentation
|
||||||
|
---
|
||||||
|
|
||||||
|
import { SimpleSplitview } from '@site/src/components/simpleSplitview';
|
||||||
|
import { SplitviewExample1 } from '@site/src/components/splitview/active';
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
|
||||||
|
# Splitview
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
A Splitview is a collection of resizable horizontally or vertically stacked panels.
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '100px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleSplitview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
```tsx title="Simple Splitview example"
|
||||||
|
import {
|
||||||
|
ISplitviewPanelProps,
|
||||||
|
Orientation,
|
||||||
|
SplitviewReact,
|
||||||
|
SplitviewReadyEvent,
|
||||||
|
} from 'dockview';
|
||||||
|
|
||||||
|
const components = {
|
||||||
|
default: (props: ISplitviewPanelProps<{ title: string }>) => {
|
||||||
|
return <div style={{ padding: '20px' }}>{props.params.title}</div>;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SimpleSplitview = () => {
|
||||||
|
const onReady = (event: SplitviewReadyEvent) => {
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_1',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 1',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_2',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 2',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_3',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 3',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SplitviewReact
|
||||||
|
components={components}
|
||||||
|
onReady={onReady}
|
||||||
|
orientation={Orientation.HORIZONTAL}
|
||||||
|
className="dockview-theme-abyss"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## SplitviewReact Component
|
||||||
|
|
||||||
|
You can create a Splitview through the use of the `ReactSplitview` component.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { ReactSplitview } from 'dockview';
|
||||||
|
```
|
||||||
|
|
||||||
|
Using the `onReady` prop you can access to the component `api` and add panels either through deserialization or the individual addition of panels.
|
||||||
|
|
||||||
|
| Property | Type | Optional | Default | Description |
|
||||||
|
| ------------------- | -------------------------------------- | -------- | ------------------------ | ------------------------------- |
|
||||||
|
| onReady | `(event: SplitviewReadyEvent) => void` | No | | Function |
|
||||||
|
| components | `Record<string, ISplitviewPanelProps>` | No | | Panel renderers |
|
||||||
|
| orientation | `Orientation` | Yes | `Orientation.HORIZONTAL` | Orientation of the Splitview |
|
||||||
|
| proportionalLayout | `boolean` | Yes | `true` | |
|
||||||
|
| hideBorders | `boolean` | Yes | `false` | Hide the borders between panels |
|
||||||
|
| className | `string` | Yes | `''` | Attaches a classname |
|
||||||
|
| disableAutoResizing | `boolean` | Yes | `false` | |
|
||||||
|
|
||||||
|
## Splitview API
|
||||||
|
|
||||||
|
The Splitview API is exposed both at the `onReady` event and on each panel through `props.containerApi`.
|
||||||
|
Through this API you can control general features of the component and access all added panels.
|
||||||
|
|
||||||
|
```tsx title="Splitview API via Panel component"
|
||||||
|
const MyComponent = (props: ISplitviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.containerApi...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx title="Splitview API via the onReady callback"
|
||||||
|
const onReady = (event: SplitviewReadyEvent) => {
|
||||||
|
// event.api...
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------- |
|
||||||
|
| height | `number` | Component pixel height |
|
||||||
|
| width | `number` | Component pixel width |
|
||||||
|
| minimumSize | `number` | The sum of the `minimumSize` property for each panel |
|
||||||
|
| maximumSize | `number` | The sum of the `maximumSize` property for each panel |
|
||||||
|
| length | `number` | Number of panels |
|
||||||
|
| panels | `ISplitviewPanel[]` | All panels |
|
||||||
|
| | | |
|
||||||
|
| onDidLayoutChange | `Event<void>` | Fires on layout change |
|
||||||
|
| onDidLayoutFromJSON | `Event<void>` | Fires of layout change caused by a fromJSON deserialization call |
|
||||||
|
| onDidAddView | `Event<IView>` | Fires when a view is added |
|
||||||
|
| onDidRemoveView | `Event<IView>` | Fires when a view is removed |
|
||||||
|
| | | |
|
||||||
|
| addPanel | `addPanel(options: AddSplitviewComponentOptions): ISplitviewPanel` | |
|
||||||
|
| removePanel | `(panel: ISplitviewPanel, sizing?: Sizing): void` | |
|
||||||
|
| getPanel | `(id:string): ISplitviewPanel \| undefined` | |
|
||||||
|
| movePanel | `(from: number, to: number): void` | |
|
||||||
|
| | |
|
||||||
|
| updateOptions | `(options: SplitviewComponentUpdateOptions): void` | |
|
||||||
|
| focus | `(): void` | Focus the active panel, if exists |
|
||||||
|
| layout | `(width: number, height:number): void` | |
|
||||||
|
| fromJSON | `(data: SerializedSplitview): void` | |
|
||||||
|
| toJSON | `(): SerializedSplitview` | |
|
||||||
|
| clear | `(): void` | Clears the current layout |
|
||||||
|
|
||||||
|
## Splitview Panel API
|
||||||
|
|
||||||
|
The Splitview panel API is exposed on each panel containing actions and variables specific to that panel.
|
||||||
|
|
||||||
|
```tsx title="Splitview panel API via Panel component"
|
||||||
|
const MyComponent = (props: ISplitviewPanelProps<{ title: string }>) => {
|
||||||
|
// props.api...
|
||||||
|
|
||||||
|
return <div>{`My first panel has the title: ${props.params.title}`}</div>;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
| Property | Type | Description |
|
||||||
|
| ---------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| id | `string` | Panel id |
|
||||||
|
| isFocused | `boolean` | Is panel focsed |
|
||||||
|
| isActive | `boolean` | Is panel active |
|
||||||
|
| isVisible | `boolean` | Is panel visible |
|
||||||
|
| width | `number` | Panel width |
|
||||||
|
| height | `number` | Panel height |
|
||||||
|
| | | |
|
||||||
|
| onDidDimensionsChange | `Event<PanelDimensionChangeEvent>` | Fires when panel dimensions change |
|
||||||
|
| onDidFocusChange | `Event<FocusEvent>` | Fire when panel is focused and blurred |
|
||||||
|
| onDidVisibilityChange | `Event<VisibilityEvent>` | Fires when the panels visiblity property is changed (see <Link to="./splitview/#visibility">Panel Visibility</Link>) |
|
||||||
|
| onDidActiveChange | `Event<ActiveEvent>` | Fires when the panels active property is changed (see <Link to="./splitview/#active">Active Panel</Link>) |
|
||||||
|
| onDidConstraintsChange | `onDidConstraintsChange: Event<PanelConstraintChangeEvent>` | Fires when the panels size contrainsts change (see <Link to="./splitview/#contraints">Panel Constraints</Link>) |
|
||||||
|
| | | |
|
||||||
|
| setVisible | `(isVisible: boolean): void` | |
|
||||||
|
| setActive | `(): void` | |
|
||||||
|
| | | |
|
||||||
|
| setConstraints | `(value: PanelConstraintChangeEvent2): void;` | |
|
||||||
|
| setSize | `(event: PanelSizeEvent): void` | |
|
||||||
|
|
||||||
|
## Advanced Features
|
||||||
|
|
||||||
|
Listed below are some functionalities avalaible through both the panel and component APIs. The live demo shows examples of these in real-time.
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '200px',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SplitviewExample1 />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
### Visibility
|
||||||
|
|
||||||
|
A panels visibility can be controlled and monitored through the following code.
|
||||||
|
A panel with visibility set to `false` will remain as a part of the components list of panels but will not be rendered.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const disposable = props.api.onDidVisibilityChange(({ isVisible }) => {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.setVisible(true);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Active
|
||||||
|
|
||||||
|
Only one panel in the `splitview` can be the active panel at any one time.
|
||||||
|
Setting a panel as active will set all the others as inactive.
|
||||||
|
A focused panel is always the active panel but an active panel is not always focused.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const disposable = props.api.onDidActiveChange(({ isActive }) => {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.setActive();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Contraints
|
||||||
|
|
||||||
|
When adding a panel you can specify pixel size contraints
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
event.api.addPanel({
|
||||||
|
id: 'panel_3',
|
||||||
|
component: 'default',
|
||||||
|
minimumSize: 100,
|
||||||
|
maximumSize: 1000,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
These contraints can be updated throughout the lifecycle of the `splitview` using the panel API
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
props.api.onDidConstraintsChange(({ maximumSize, minimumSize }) => {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.setConstraints({
|
||||||
|
maximumSize: 200,
|
||||||
|
minimumSize: 400,
|
||||||
|
});
|
||||||
|
```
|
52
packages/docs/versioned_docs/version-1.8.3/contributing.mdx
vendored
Normal file
52
packages/docs/versioned_docs/version-1.8.3/contributing.mdx
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 3
|
||||||
|
description: Contributing
|
||||||
|
---
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
# Project description
|
||||||
|
|
||||||
|
Dockview is a layout manager library designed to provide a complete layouting solution.
|
||||||
|
It is written in plain TypeScript and can be used without any framework although
|
||||||
|
an extensive React wrapper has always and will always be provided for those using the React framework.
|
||||||
|
|
||||||
|
The project is hosted on GitHub and developed within a Monorepo powered by [Lerna](https://github.com/lerna/lerna).
|
||||||
|
It is developed using the `yarn` package manager since at the time of creation `yarn` was far superior when it came to managing monorepos.
|
||||||
|
The Monorepo contains three packages:
|
||||||
|
|
||||||
|
#### packages/dockview-core
|
||||||
|
|
||||||
|
The core project is entirely written in plain TypeScript without any frameworks or dependencies and it's source-code can be found
|
||||||
|
within the `dockview-core` package which is also published to npm.
|
||||||
|
|
||||||
|
#### packages/dockview
|
||||||
|
|
||||||
|
A complete collection of React components for use through the React framework to use dockview seamlessly
|
||||||
|
and is published to npm. It depends explicitly on `dockview-core` so there is no need to additionally install `dockview-core`.
|
||||||
|
|
||||||
|
> Dockview was originally a React-only library which is why the React version maintains the name `dockview` after
|
||||||
|
> splitting the core logic into a seperate package named `dockview-core`.
|
||||||
|
|
||||||
|
#### packages/docs
|
||||||
|
|
||||||
|
This package contains the code for this documentation website and examples hosted through **CodeSandbox**. It is **not** a published package on npm.
|
||||||
|
|
||||||
|
# Run the project locally
|
||||||
|
|
||||||
|
1. After you have cloned the project from GitHub run `yarn` at the root of the project which will install all project dependencies.
|
||||||
|
2. In order build `packages/dockview-core` then `packages/dockview`.
|
||||||
|
3. Run the docs website through `npm run start` in the `packages/docs` directory and go to _http://localhost:3000_ which
|
||||||
|
will now be running the local copy of `dockview` that you have just built.
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
All examples can be found under [**packages/docs/sandboxes**](https://github.com/mathuo/dockview/tree/master/packages/docs/sandboxes).
|
||||||
|
Each example is an independently runnable example through **CodeSandbox**.
|
||||||
|
Through the documentation you will see links to runnable **CodeSandbox** examples.
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
#### Are there any plans to publish wrapper libraries for other frameworks such as Angular and Vue?
|
||||||
|
|
||||||
|
Currently no but this is open for contributors to try.
|
91
packages/docs/versioned_docs/version-1.8.3/index.mdx
vendored
Normal file
91
packages/docs/versioned_docs/version-1.8.3/index.mdx
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 0
|
||||||
|
description: A zero dependency layout manager supporting ReactJS and Vanilla TypeScript
|
||||||
|
---
|
||||||
|
|
||||||
|
import { SimpleSplitview } from '@site/src/components/simpleSplitview';
|
||||||
|
import { SimpleGridview } from '@site/src/components/simpleGridview';
|
||||||
|
import { SimplePaneview } from '@site/src/components/simplePaneview';
|
||||||
|
import SimpleDockview from '@site/sandboxes/simple-dockview/src/app';
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
|
||||||
|
# Introduction
|
||||||
|
|
||||||
|
**dockview** is a zero dependency layout manager that supports tab, grids and splitviews.
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
`dockview` has a peer dependency on `react >= 16.8.0` and `react-dom >= 16.8.0`. To install `dockview` you can run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm install dockview
|
||||||
|
```
|
||||||
|
|
||||||
|
You must also import the dockview stylesheet found under [`dockview/dict/styles/dockview.css`](https://unpkg.com/browse/dockview@latest/dist/styles/dockview.css),
|
||||||
|
depending on your solution this might be:
|
||||||
|
|
||||||
|
```css
|
||||||
|
@import './node_modules/dockview/dist/styles/dockview.css';
|
||||||
|
```
|
||||||
|
|
||||||
|
There are 4 components you may want to use:
|
||||||
|
|
||||||
|
<Link to="./components/dockview">
|
||||||
|
<h2>Dockview</h2>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '300px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleDockview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Link to="./components/splitview">
|
||||||
|
<h2>Splitview</h2>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '100px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleSplitview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Link to="./components/gridview">
|
||||||
|
<h2>Gridview</h2>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '300px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleGridview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Link to="./components/paneview">
|
||||||
|
<h2>Paneview</h2>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '300px',
|
||||||
|
backgroundColor: 'rgb(30,30,30)',
|
||||||
|
color: 'white',
|
||||||
|
margin: '20px 0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimplePaneview />
|
||||||
|
</div>
|
80
packages/docs/versioned_docs/version-1.8.3/theme.mdx
vendored
Normal file
80
packages/docs/versioned_docs/version-1.8.3/theme.mdx
vendored
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 1
|
||||||
|
description: Theming Dockview Components
|
||||||
|
---
|
||||||
|
|
||||||
|
# Theme
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
`dockview` requires some CSS to work correctly.
|
||||||
|
The CSS is exported as one file under [`dockview/dict/styles/dockview.css`](https://unpkg.com/browse/dockview@latest/dist/styles/dockview.css)
|
||||||
|
and should be imported at some point in your application
|
||||||
|
|
||||||
|
```css title="Example import with .css file"
|
||||||
|
@import './node_modules/dockview/dist/styles/dockview.css';
|
||||||
|
```
|
||||||
|
|
||||||
|
## Provided themes
|
||||||
|
|
||||||
|
`dockview` comes with a number of themes which are all CSS classes and can be found [here](https://github.com/mathuo/dockview/blob/master/packages/dockview-core/src/theme.scss).
|
||||||
|
To use a `dockview` theme the CSS must encapsulate the component. The current list of themes is:
|
||||||
|
|
||||||
|
- `dockview-theme-dark`
|
||||||
|
- `dockview-theme-light`
|
||||||
|
- `dockview-theme-vs`
|
||||||
|
- `dockview-theme-abyss`
|
||||||
|
- `dockview-theme-dracula`
|
||||||
|
- `dockview-theme-replit`
|
||||||
|
|
||||||
|
## Customizing Theme
|
||||||
|
|
||||||
|
`dockview` supports theming through the use of css properties.
|
||||||
|
You can view the built-in themes at [`dockview/src/theme.scss`](https://github.com/mathuo/dockview/blob/master/packages/dockview/src/theme.scss)
|
||||||
|
and are free to build your own themes based on these css properties.
|
||||||
|
|
||||||
|
| CSS Property | Description |
|
||||||
|
| ---------------------------------------------------- | ----------- |
|
||||||
|
| --dv-paneview-active-outline-color | |
|
||||||
|
| --dv-tabs-and-actions-container-font-size | |
|
||||||
|
| --dv-tabs-and-actions-container-height | |
|
||||||
|
| --dv-tab-close-icon | |
|
||||||
|
| --dv-drag-over-background-color | |
|
||||||
|
| --dv-drag-over-border-color | |
|
||||||
|
| --dv-tabs-container-scrollbar-color | |
|
||||||
|
| | |
|
||||||
|
| --dv-group-view-background-color | |
|
||||||
|
| | |
|
||||||
|
| --dv-tabs-and-actions-container-background-color | |
|
||||||
|
| | |
|
||||||
|
| --dv-activegroup-visiblepanel-tab-background-color | |
|
||||||
|
| --dv-activegroup-hiddenpanel-tab-background-color | |
|
||||||
|
| --dv-inactivegroup-visiblepanel-tab-background-color | |
|
||||||
|
| --dv-inactivegroup-hiddenpanel-tab-background-color | |
|
||||||
|
| --dv-tab-divider-color | |
|
||||||
|
| | |
|
||||||
|
| --dv-activegroup-visiblepanel-tab-color | |
|
||||||
|
| --dv-activegroup-hiddenpanel-tab-color | |
|
||||||
|
| --dv-inactivegroup-visiblepanel-tab-color | |
|
||||||
|
| --dv-inactivegroup-hiddenpanel-tab-color | |
|
||||||
|
| | |
|
||||||
|
| --dv-separator-border | |
|
||||||
|
| --dv-paneview-header-border-color | |
|
||||||
|
|
||||||
|
You can further customise the theme through adjusting class properties but this is up you.
|
||||||
|
For example if you wanted to add a bottom border to the tab container for an active group in the `DockviewReact` component you could write:
|
||||||
|
|
||||||
|
```css title="Additional CSS to show a bottom border on active groups"
|
||||||
|
.groupview {
|
||||||
|
&.active-group {
|
||||||
|
> .tabs-and-actions-container {
|
||||||
|
border-bottom: 2px solid var(--dv-activegroup-visiblepanel-tab-background-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.inactive-group {
|
||||||
|
> .tabs-and-actions-container {
|
||||||
|
border-bottom: 2px solid var(--dv-inactivegroup-visiblepanel-tab-background-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"tutorialSidebar": [
|
||||||
|
{
|
||||||
|
"type": "autogenerated",
|
||||||
|
"dirName": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
[
|
[
|
||||||
|
"1.8.3",
|
||||||
"1.8.2",
|
"1.8.2",
|
||||||
"1.7.6"
|
"1.7.6"
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user