;
33 | }
34 | }
35 |
36 | let tab0 = {
37 | id: 'tab0', title: 'tab0',
38 | content: This tab will be added back to main panel every time you load layout.
39 | };
40 |
41 | class Demo extends React.Component {
42 | getRef = (r) => {
43 | this.dockLayout = r;
44 | };
45 |
46 | state = {saved: null};
47 |
48 | defaultLayout = {
49 | dockbox: {
50 | mode: 'horizontal',
51 | children: [
52 | {
53 | size: 200,
54 | tabs: [{id: 'tab1'}, {id: 'tab2'}],
55 | },
56 | {
57 | id: 'main-panel',
58 | size: 400,
59 | tabs: [{id: 'tab0'}, {id: 'jsxTab'}, {id: 'htmlTab'}],
60 | panelLock: {
61 | panelStyle: 'main'
62 | }
63 | },
64 | {
65 | size: 200,
66 | tabs: [{id: 'tab5'}, {id: 'tab6'}],
67 | },
68 | ]
69 | }
70 | };
71 |
72 | saveTab = (tabData) => {
73 | let {id, inputValue} = tabData;
74 | // add inputValue from saved data;
75 | if (id === 'tab0') {
76 | return null;
77 | }
78 | return {id, inputValue};
79 | };
80 | loadTab = (savedTab) => {
81 | let id = savedTab.id;
82 | switch (id) {
83 | case 'tab0':
84 | return tab0;
85 | case 'jsxTab':
86 | return jsxTab;
87 | case 'htmlTab':
88 | return htmlTab;
89 | default:
90 | return {id, title: id, content: InputTab.create, inputValue: savedTab.inputValue, group: 'allowWindow'};
91 | }
92 | };
93 |
94 | // add tab0 to the main panel
95 | afterPanelLoaded = (savedPanel, panelData) => {
96 | let id = savedPanel.id;
97 |
98 | if (id === 'main-panel') {
99 | panelData.panelLock = {
100 | panelStyle: 'main'
101 | };
102 | panelData.tabs.unshift({...tab0});
103 | }
104 | };
105 |
106 | render() {
107 | return (
108 |
109 |
112 |
113 |
117 |
121 |
122 |
123 | );
124 | }
125 | }
126 |
127 | createRoot(document.getElementById("app")).render();
128 |
--------------------------------------------------------------------------------
/example/adv-tab-update.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/adv-tab-update.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {htmlTab, jsxTab} from "./prism-tabs";
5 | import {DockLayout} from '../lib';
6 |
7 | let groups = {
8 | 'locked': {
9 | floatable: false,
10 | tabLocked: true
11 | }
12 | };
13 |
14 | function getTab(id, value) {
15 | return {
16 | id,
17 | content: (
18 |
19 |
It's easier to use React Context to update tab,
20 | but in some use cases you might need to directly update the tab.
21 | {
22 | id !== `tab${value}` ?
23 |
Only current active tab will be changed
24 | : null
25 | }
26 | value is {value}
27 |
28 | ),
29 | title: id,
30 | group: 'locked',
31 | }
32 | }
33 |
34 | class Demo extends React.Component {
35 | getRef = (r) => {
36 | this.dockLayout = r;
37 | };
38 |
39 | count = 4;
40 | addValue = () => {
41 | let panelData = this.dockLayout.find('my_panel');
42 | let tabId = panelData.activeId;
43 | // docklayout will find the same tab id and replace the previous tab
44 | this.dockLayout.updateTab(tabId, getTab(tabId, ++this.count));
45 | };
46 | addTab = () => {
47 | ++this.count;
48 | let newTab = getTab(`tab${this.count}`, this.count)
49 | this.dockLayout.dockMove(newTab, 'my_panel', 'middle');
50 | };
51 | defaultLayout = {
52 | dockbox: {
53 | mode: 'vertical',
54 | children: [
55 | {
56 | tabs: [
57 | {
58 | id: 'id2', title: 'change', content: (
59 |
60 |
Click here to change the other panel.
61 |
62 |
63 |
64 | )
65 | },
66 | jsxTab,
67 | htmlTab
68 | ],
69 | },
70 | {
71 | id: 'my_panel',
72 | tabs: [getTab('tab1', 1), getTab('tab2', 2), getTab('tab3', 3), getTab('tab4', 4)],
73 | },
74 | ]
75 | }
76 | };
77 |
78 | state = {saved: null};
79 |
80 | render() {
81 | return (
82 |
84 | );
85 | }
86 | }
87 |
88 | createRoot(document.getElementById("app")).render();
89 |
--------------------------------------------------------------------------------
/example/basic.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/basic.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {jsxTab, htmlTab} from './prism-tabs';
5 | import {DockLayout, DockContextType} from '../lib';
6 |
7 | let tab = {
8 | content: Tab Content
,
9 | closable: true,
10 | };
11 |
12 | let layout = {
13 | dockbox: {
14 | mode: 'horizontal',
15 | children: [
16 | {
17 | mode: 'vertical',
18 | size: 200,
19 | children: [
20 | {
21 | tabs: [{...tab, id: 't1', title: 'Tab 1'}, {...tab, id: 't2', title: 'Tab 2'}],
22 | },
23 | {
24 | tabs: [{
25 | ...tab, id: 't3', title: 'Min Size', content: (
26 |
27 |
This tab has a minimal size
28 | 150 x 150 px
29 |
30 | ), minWidth: 150, minHeight: 150,
31 | }, {...tab, id: 't4', title: 'Tab 4'}],
32 | },
33 | ]
34 | },
35 | {
36 | size: 1000,
37 | tabs: [
38 | {
39 | ...tab, id: 't5', title: 'basic demo', content: (
40 |
41 | This panel won't be removed from layout even when last Tab is closed
42 |
43 | ),
44 | },
45 | jsxTab,
46 | htmlTab,
47 | ],
48 | panelLock: {panelStyle: 'main'},
49 | },
50 | {
51 | size: 200,
52 | tabs: [{...tab, id: 't8', title: 'Tab 8'}],
53 | },
54 | ]
55 | },
56 | floatbox: {
57 | mode: 'float',
58 | children: [
59 | {
60 | tabs: [
61 | {...tab, id: 't9', title: 'Tab 9', content: Float
},
62 | {...tab, id: 't10', title: 'Tab 10'}
63 | ],
64 | x: 300, y: 150, w: 400, h: 300
65 | }
66 | ]
67 | }
68 | }
69 | ;
70 | if (window.innerWidth < 600) {
71 | // remove a column for mobile
72 | layout.dockbox.children.pop();
73 | }
74 |
75 | let count = 0;
76 |
77 | class Demo extends React.Component {
78 |
79 | onDragNewTab = (e) => {
80 | let content = `New Tab ${count++}`;
81 | DragStore.dragStart(DockContextType, {
82 | tab: {
83 | id: content,
84 | content: {content}
,
85 | title: content,
86 | closable: true,
87 | }
88 | }, e.nativeEvent);
89 | };
90 |
91 | render() {
92 | return (
93 |
94 | );
95 | }
96 | }
97 |
98 | createRoot(document.getElementById("app")).render();
99 |
--------------------------------------------------------------------------------
/example/controlled-layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/controlled-layout.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {htmlTab, jsxTab} from "./prism-tabs";
5 | import {DockLayout} from '../lib';
6 |
7 | let tab0 = {
8 | title: 'Controlled Layout',
9 | content: (
10 |
11 |
When you use layout instead of defaultLayout on <DockLayout>
12 |
DockLayout will work as a controlled component
13 |
14 | )
15 | };
16 |
17 | let box = {
18 | dockbox: {
19 | mode: 'horizontal',
20 | children: [
21 | {
22 | mode: 'vertical',
23 | children: [
24 | {
25 | tabs: [{id: 't0'}, htmlTab, jsxTab],
26 | },
27 | {
28 | tabs: [{id: 'protect1'}, {id: 't4'}, {id: 't5'}, {id: 't6'}],
29 | }
30 | ]
31 | },
32 | {
33 | tabs: [{id: 't7'}, {id: 't8'}, {id: 't9'}],
34 | },
35 | ]
36 | }
37 | };
38 |
39 | class Demo extends React.Component {
40 | state = {layout: box};
41 |
42 | loadTab = (data) => {
43 | let {id} = data;
44 | switch (id) {
45 | case 't0':
46 | return {...tab0, id};
47 | case 'protect1' :
48 | return {
49 | id, title: 'Protect',
50 | closable: true,
51 | content:
52 |
Removal of this tab will be rejected
53 | This is done in the onLayoutChange callback
54 |
55 | };
56 | case jsxTab.id:
57 | return jsxTab;
58 | case htmlTab.id:
59 | return htmlTab;
60 | }
61 |
62 | return {
63 | id, title: id,
64 | content: Tab Content
65 | };
66 | };
67 |
68 | onLayoutChange = (newLayout, currentTabId, direction) => {
69 | // control DockLayout from state
70 | console.log(currentTabId, newLayout, direction);
71 | if (currentTabId === 'protect1' && direction === 'remove') {
72 | alert('removal of this tab is rejected');
73 | } else {
74 | this.setState({layout: newLayout});
75 | }
76 | };
77 |
78 | render() {
79 | return (
80 |
82 | );
83 | }
84 | }
85 |
86 | createRoot(document.getElementById("app")).render();
87 |
--------------------------------------------------------------------------------
/example/dark-theme.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/dark-theme.jsx:
--------------------------------------------------------------------------------
1 | // The jsx is same as basic example.
2 | // Only difference is in the css, just use dist/rc-dock-dark.css for dark theme.
3 |
--------------------------------------------------------------------------------
/example/disable-dock.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/disable-dock.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {jsxTab, htmlTab} from './prism-tabs';
5 | import {DockLayout, DockContextType} from '../lib';
6 |
7 |
8 | let groups = {
9 | floatOnly: {
10 | floatable: true,
11 | disableDock: true,
12 | }
13 | };
14 |
15 | let layout = {
16 | dockbox: {
17 | mode: 'horizontal',
18 | children: [
19 | {
20 | tabs: [{id: 't1', title: 'Dock', content: Dock Content
}, jsxTab, htmlTab],
21 | }
22 | ]
23 | },
24 | floatbox: {
25 | mode: 'float',
26 | children: [
27 | {
28 | tabs: [
29 | {id: 't2', title: 'Float', content: Float Content
, group: 'floatOnly'},
30 | {id: 't3', title: 'Float', content: Float Content
, group: 'floatOnly'}
31 | ],
32 | x: 300, y: 150, w: 400, h: 300
33 | }
34 | ]
35 | }
36 | };
37 |
38 |
39 | class Demo extends React.Component {
40 |
41 | render() {
42 | return (
43 |
45 | );
46 | }
47 | }
48 |
49 | createRoot(document.getElementById("app")).render();
50 |
--------------------------------------------------------------------------------
/example/divider-box.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/divider-box.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {jsxTab, htmlTab} from './prism-tabs';
5 | import {DockLayout, DividerBox} from '../lib';
6 |
7 | let layoutLeft = {
8 | dockbox: {
9 | mode: 'vertical',
10 | children: [
11 | {
12 | tabs: [{id: 't1', title: 'Tool', content: Left Side Dock Layout
}],
13 | },
14 | {
15 | tabs: [{id: 't2', title: 'Tool', content: Left Side Dock Layout
}],
16 | }
17 | ]
18 | },
19 | };
20 |
21 |
22 | let layoutRight = {
23 | dockbox: {
24 | mode: 'horizontal',
25 | children: [
26 | {
27 | tabs: [{
28 | id: 't3',
29 | title: 'Dock',
30 | content: Right Side Dock Layout.
31 | }, jsxTab, htmlTab],
32 | }
33 | ]
34 | },
35 | };
36 |
37 |
38 | class Demo extends React.Component {
39 | render() {
40 | return (
41 |
42 |
43 |
44 | not DockLayout, only DividerBox
45 | You can use DividerBox for fixed Tool Panels
46 |
47 |
48 |
49 | );
50 | }
51 | }
52 |
53 | createRoot(document.getElementById("app")).render();
54 |
--------------------------------------------------------------------------------
/example/drag-new-tab.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/drag-new-tab.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {htmlTab, jsxTab} from "./prism-tabs";
5 | import {DockLayout, DragDropDiv} from '../lib';
6 |
7 | let tab = {
8 | title: 'Tab',
9 | content: Tab Content
10 | };
11 | let box = {
12 | dockbox: {
13 | mode: 'horizontal',
14 | children: [
15 | {
16 | mode: 'vertical',
17 | children: [
18 | {
19 | tabs: [jsxTab, htmlTab],
20 | },
21 | {
22 | tabs: [{...tab, id: 't4'}, {...tab, id: 't5'}, {...tab, id: 't6'}],
23 | }
24 | ]
25 | },
26 | {
27 | tabs: [{...tab, id: 't7'}, {...tab, id: 't8'}, {...tab, id: 't9'}]
28 | },
29 | ]
30 | }
31 | };
32 |
33 | class Demo extends React.Component {
34 | newTabId = 0;
35 | getRef = (r) => {
36 | this.dockLayout = r;
37 | };
38 | getButtonRef = (r) => {
39 | this.buttonRef = r;
40 | }
41 |
42 | onDragStart = (e) => {
43 | console.log(this.dockLayout, this.buttonRef)
44 | e.setData({
45 | tab: {...tab, id: `newTab-${++this.newTabId}`},
46 | panelSize: [400, 300]
47 | }, this.dockLayout.getDockId());
48 | e.startDrag(this.buttonRef.element, this.buttonRef.element);
49 | };
50 |
51 | render() {
52 | return (
53 |
54 |
56 |
57 |
58 |
61 |
62 |
63 |
64 | );
65 | }
66 | }
67 |
68 | createRoot(document.getElementById("app")).render();
69 |
--------------------------------------------------------------------------------
/example/drop-mode.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/drop-mode.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {htmlTab, jsxTab} from "./prism-tabs";
5 | import {DockLayout} from '../lib';
6 |
7 | let dropModeTab = {
8 | title: 'Drop Mode',
9 | content: (
10 |
11 |
When you set dropMode='edge' on <DockLayout>
12 |
The distance between mouse cursor and panel border is used to pick drop location.
13 |
14 | )
15 | };
16 |
17 | let tab = {
18 | title: 'Tab',
19 | content: Tab Content
20 | };
21 | let box = {
22 | dockbox: {
23 | mode: 'horizontal',
24 | children: [
25 | {
26 | mode: 'vertical',
27 | children: [
28 | {
29 | tabs: [{...dropModeTab, id: 't1'}, jsxTab, htmlTab],
30 | },
31 | {
32 | tabs: [{...tab, id: 't4'}, {...tab, id: 't5'}, {...tab, id: 't6'}],
33 | }
34 | ]
35 | },
36 | {
37 | tabs: [{...tab, id: 't7'}, {...tab, id: 't8'}, {...tab, id: 't9'}],
38 | panelLock: {panelStyle: 'main'},
39 | },
40 | ]
41 | }
42 | };
43 |
44 | class Demo extends React.Component {
45 | render() {
46 | return (
47 |
49 | );
50 | }
51 | }
52 |
53 | createRoot(document.getElementById("app")).render();
54 |
--------------------------------------------------------------------------------
/example/gesture.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/example/gesture.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {jsxTab} from "./prism-tabs";
5 | import {DragDropDiv, GestureState} from '../lib';
6 |
7 | class Demo extends React.PureComponent {
8 | state = {scale: 0, rotate: 0, dx: 0, dy: 0};
9 | getRef = (r) => {
10 | this._ref = r;
11 | };
12 |
13 | onGestureStart = (e) => {
14 | return true;
15 | };
16 | onGestureMove = (e) => {
17 | let {scale, rotate, dx, dy} = e;
18 | this.setState({scale, rotate, dx, dy});
19 | };
20 |
21 |
22 | render() {
23 | let {scale, rotate, dx, dy} = this.state;
24 | return (
25 |
26 |
27 |
28 | scale: {scale}
29 | rotate: {rotate}
30 | dx: {dx}
31 | dy: {dy}
32 |
33 | {jsxTab.content}
34 |
35 | );
36 | }
37 | }
38 |
39 | createRoot(document.getElementById("app")).render();
40 | console.log(Buffer.from("Hello World").toString('base64'));
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
91 |
92 |
93 |
94 |
95 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/example/index.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {Divider} from '../lib';
5 | // keep the above unused import so tools script can understand this jsx
6 |
7 | let demos = ['basic', 'dark-theme', 'panel-style', 'drop-mode', 'tab-update', 'save-layout', 'panel-extra'];
8 | let advance = ['new-window', 'adv-tab-update', 'adv-save-layout', 'controlled-layout', 'tab-cache', 'divider-box', 'drag-new-tab'];
9 |
10 | let defaultPage = window.location.hash.substr(1);
11 | if (!(demos.includes(defaultPage) || advance.includes(defaultPage))) {
12 | defaultPage = 'basic';
13 | }
14 |
15 | class App extends React.Component {
16 | state = {current: defaultPage};
17 |
18 | render() {
19 | let {current} = this.state;
20 | let demoPages = [];
21 | for (let page of demos) {
22 | let cls = '';
23 | if (page === current) {
24 | cls = 'current';
25 | }
26 | demoPages.push(
27 | this.setState({current: page})}>
28 | {page}
29 |
30 | )
31 | }
32 | let advancePages = [];
33 | for (let page of advance) {
34 | let cls = '';
35 | if (page === current) {
36 | cls = 'current';
37 | }
38 | advancePages.push(
39 | this.setState({current: page})}>
40 | {page}
41 |
42 | )
43 | }
44 | return (
45 |
65 | );
66 | }
67 | }
68 |
69 | createRoot(document.getElementById("app")).render();
70 |
--------------------------------------------------------------------------------
/example/new-window.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/new-window.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {htmlTab, jsxTab} from "./prism-tabs";
5 | import {DockLayout} from '../lib';
6 |
7 | let groups = {
8 | allowWindow: {
9 | floatable: true,
10 | newWindow: true,
11 | maximizable: true,
12 | }
13 | };
14 |
15 | let floatTab = {
16 | id: 'float',
17 | title: 'New Window',
18 | content: (
19 |
20 |
Right click on the max button ⇗
21 |
22 | ),
23 | group: 'allowWindow'
24 | };
25 |
26 |
27 | class Demo extends React.Component {
28 | mainTab = {
29 | id: 'main',
30 | title: 'Info',
31 | content: (
32 |
33 |
Although rc-dock supports new window, a lot of packages will have error when controlling components in popup
34 | window.
35 |
Please avoid complex mouse event handling and popup layers in the tab that allows popup window.
36 |
37 | )
38 | };
39 | layoutData = {
40 | dockbox: {
41 | mode: 'horizontal',
42 | children: [
43 | {
44 | mode: 'vertical',
45 | children: [
46 | {
47 | tabs: [this.mainTab, jsxTab, htmlTab],
48 | panelLock: {panelStyle: 'main'},
49 | }
50 | ]
51 | }
52 | ]
53 | },
54 | floatbox: {
55 | mode: 'float',
56 | children: [
57 | {
58 | tabs: [floatTab],
59 | x: 60, y: 60, w: 320, h: 300
60 | }
61 | ]
62 | }
63 | };
64 |
65 |
66 | render() {
67 | return (
68 |
70 | );
71 | }
72 | }
73 |
74 | createRoot(document.getElementById("app")).render();
75 |
--------------------------------------------------------------------------------
/example/panel-extra.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/example/panel-extra.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {htmlTab, jsxTab} from "./prism-tabs";
5 | import {DockLayout, DockContextType} from '../lib';
6 |
7 | let groups = {
8 | 'close-all': {
9 | floatable: true,
10 | closable: true,
11 | panelExtra: (panelData, context) => {
12 |
13 | let buttons = [];
14 | if (panelData.parent.mode !== 'window') {
15 | buttons.push(
16 | context.dockMove(panelData, null, 'maximize')}>
19 | {panelData.parent.mode === 'maximize' ? '▬' : '▣'}
20 |
21 | )
22 | buttons.push(
23 | context.dockMove(panelData, null, 'new-window')}>
25 | ⇪
26 |
27 | )
28 | }
29 | buttons.push(
30 | context.dockMove(panelData, null, 'remove')}>
32 | X
33 |
34 | )
35 | return {buttons}
36 | }
37 | }
38 | };
39 |
40 | let tab = {
41 | title: 'Tab',
42 | content: (
43 |
44 |
Custom component can be added to panel's title bar.
45 |
This panel has a custom maximize button and a close all button
46 |
),
47 | group: 'close-all'
48 | };
49 |
50 | let count = 0;
51 |
52 | function newTab() {
53 | return {
54 | id: `newtab${++count}`,
55 | title: 'New Tab',
56 | content: (
57 |
58 |
This panel has an 'add' button defined in panelLock
59 |
)
60 | };
61 | }
62 |
63 | let box = {
64 | dockbox: {
65 | mode: 'horizontal',
66 | children: [
67 | {
68 | mode: 'vertical',
69 | size: 500,
70 | children: [
71 | {
72 | tabs: [{...tab, id: 't1'}, {...jsxTab, group: 'close-all'}, {...htmlTab, group: 'close-all'}],
73 | },
74 | {
75 | tabs: [newTab(), newTab()],
76 | panelLock: {
77 | minWidth: 200,
78 | panelExtra: (panelData, context) => (
79 |
83 | )
84 | }
85 | },
86 | ]
87 | },
88 | {
89 | size: 300,
90 | tabs: [{...tab, id: 't5'}, {...tab, id: 't6'}],
91 | },
92 | ]
93 | }
94 | };
95 |
96 | class Demo extends React.Component {
97 | render() {
98 | return (
99 |
101 | );
102 | }
103 | }
104 |
105 | createRoot(document.getElementById("app")).render();
106 |
--------------------------------------------------------------------------------
/example/panel-style.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | rc-dock
7 |
8 |
9 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/example/panel-style.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import * as ReactDOM from 'react-dom';
3 | import { createRoot } from "react-dom/client";
4 | import {jsxTab, htmlTab} from './prism-tabs';
5 | import {DockLayout} from '../lib';
6 |
7 | let groups = {
8 | headless: {
9 | // the css class for this would be dock-panel-headless
10 | // this is a pre-defined style, defined here:
11 | // https://github.com/ticlo/rc-dock/blob/master/style/predefined-panels.less
12 | floatable: true,
13 | maximizable: true,
14 | },
15 | 'card custom': {
16 | // the css class for this would be dock-panel-custom
17 | // this is a custom panel style defined in panel-style.html
18 | floatable: true,
19 | maximizable: true,
20 | }
21 | };
22 |
23 | let defaultTab = {
24 | title: 'default-style',
25 | content: (
26 |
27 | Tabs from different style group can't be docked in same panel
28 |
29 | ),
30 | };
31 | let headlessTab = {
32 | title: 'headless',
33 | content: (
34 |
35 |
Hide border and header.
36 | Move mouse near top border to show header.
37 |
38 | ),
39 | // this is a pre-defined style, defined here:
40 | // https://github.com/ticlo/rc-dock/blob/master/style/predefined-panels.less
41 | group: 'headless'
42 | };
43 | let cardTab = {
44 | title: 'card-style',
45 | content: (
46 |
47 | card style
48 |
49 | ),
50 | // this is a pre-defined style, defined here:
51 | // https://github.com/ticlo/rc-dock/blob/master/style/predefined-panels.less
52 | group: 'card'
53 | };
54 | let customTab = {
55 | title: 'custom-style',
56 | content: (
57 |
58 | Custom style
59 |
60 | ),
61 | // you can mix predefined style with you own style
62 | // separate 2 styles with space
63 | // the panel class will contain both dock-style-car and dock-style-custom
64 | group: 'card custom'
65 | };
66 | let box = {
67 | dockbox: {
68 | mode: 'horizontal',
69 | children: [
70 | {
71 | mode: 'vertical',
72 | children: [
73 | {
74 | tabs: [
75 | {...defaultTab, id: 't7'},
76 | {
77 | ...defaultTab, id: 't8', title: (
78 |
79 |
80 |
81 | ), content: (
82 |
83 | Tab title can be any react component
84 |
85 | )
86 | },
87 | jsxTab,
88 | htmlTab
89 | ],
90 | },
91 | {
92 | tabs: [{...cardTab, id: 't9'}, {...cardTab, id: 't10'}, {...cardTab, id: 't11'}],
93 | },
94 |
95 | ]
96 | },
97 | {
98 | mode: 'vertical',
99 | children: [
100 | {
101 | tabs: [{...customTab, id: 't4'}, {...customTab, id: 't5'}, {...customTab, id: 't6'}],
102 | },
103 | {
104 | tabs: [{...headlessTab, id: 't1'}, {...headlessTab, id: 't2'}, {...headlessTab, id: 't3'}],
105 | },
106 |
107 | ]
108 | }
109 |
110 | ]
111 | }
112 | };
113 |
114 | class Demo extends React.Component {
115 | render() {
116 | return (
117 |
119 | );
120 | }
121 | }
122 |
123 | createRoot(document.getElementById("app")).render();
124 |
--------------------------------------------------------------------------------
/example/prism-coy.css:
--------------------------------------------------------------------------------
1 | /**
2 | * prism.js Coy theme for JavaScript, CoffeeScript, CSS and HTML
3 | * Based on https://github.com/tshedor/workshop-wp-theme (Example: http://workshop.kansan.com/category/sessions/basics or http://workshop.timshedor.com/category/sessions/basics);
4 | * @author Tim Shedor
5 | */
6 |
7 | code[class*="language-"],
8 | pre[class*="language-"] {
9 | color: black;
10 | background: none;
11 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
12 | font-size: 14px;
13 | text-align: left;
14 | white-space: pre;
15 | word-spacing: normal;
16 | word-break: normal;
17 | word-wrap: normal;
18 | line-height: 1.5;
19 |
20 | -moz-tab-size: 4;
21 | -o-tab-size: 4;
22 | tab-size: 4;
23 |
24 | -webkit-hyphens: none;
25 | -moz-hyphens: none;
26 | -ms-hyphens: none;
27 | hyphens: none;
28 | }
29 |
30 | .token.comment,
31 | .token.block-comment,
32 | .token.prolog,
33 | .token.doctype,
34 | .token.cdata {
35 | color: #7D8B99;
36 | }
37 |
38 | .token.punctuation {
39 | color: #5F6364;
40 | }
41 |
42 | .token.property,
43 | .token.tag,
44 | .token.boolean,
45 | .token.number,
46 | .token.function-name,
47 | .token.constant,
48 | .token.symbol,
49 | .token.deleted {
50 | color: #c92c2c;
51 | }
52 |
53 | .token.selector,
54 | .token.attr-name,
55 | .token.string,
56 | .token.char,
57 | .token.function,
58 | .token.builtin,
59 | .token.inserted {
60 | color: #2f9c0a;
61 | }
62 |
63 | .token.operator,
64 | .token.entity,
65 | .token.url,
66 | .token.variable {
67 | color: #a67f59;
68 | background: rgba(255, 255, 255, 0.5);
69 | }
70 |
71 | .token.atrule,
72 | .token.attr-value,
73 | .token.keyword,
74 | .token.class-name {
75 | color: #1990b8;
76 | }
77 |
78 | .token.regex,
79 | .token.important {
80 | color: #e90;
81 | }
82 |
83 | .language-css .token.string,
84 | .style .token.string {
85 | color: #a67f59;
86 | background: rgba(255, 255, 255, 0.5);
87 | }
88 |
89 | .token.important {
90 | font-weight: normal;
91 | }
92 |
93 | .token.bold {
94 | font-weight: bold;
95 | }
96 |
97 | .token.italic {
98 | font-style: italic;
99 | }
100 |
101 | .token.entity {
102 | cursor: help;
103 | }
104 |
105 | .namespace {
106 | opacity: .7;
107 | }
108 |
109 | @media screen and (max-width: 767px) {
110 | pre[class*="language-"]:before,
111 | pre[class*="language-"]:after {
112 | bottom: 14px;
113 | box-shadow: none;
114 | }
115 |
116 | }
117 |
118 | /* Plugin styles */
119 | .token.tab:not(:empty):before,
120 | .token.cr:before,
121 | .token.lf:before {
122 | color: #e0d7d1;
123 | }
124 |
125 | /* Plugin styles: Line Numbers */
126 | pre[class*="language-"].line-numbers.line-numbers {
127 | padding-left: 0;
128 | }
129 |
130 | pre[class*="language-"].line-numbers.line-numbers code {
131 | padding-left: 3.8em;
132 | }
133 |
134 | pre[class*="language-"].line-numbers.line-numbers .line-numbers-rows {
135 | left: 0;
136 | }
137 |
138 | /* Plugin styles: Line Highlight */
139 | pre[class*="language-"][data-line] {
140 | padding-top: 0;
141 | padding-bottom: 0;
142 | padding-left: 0;
143 | }
144 |
145 | pre[data-line] code {
146 | position: relative;
147 | padding-left: 4em;
148 | }
149 |
150 | pre .line-highlight {
151 | margin-top: 0;
152 | }
--------------------------------------------------------------------------------
/example/prism-tabs.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | let name = window.location.pathname.split('/').pop();
4 | name = name.substr(0, name.length - 5);
5 |
6 | export const jsxTab = {
7 | id: 'jsxTab',
8 | title: 'jsx',
9 | closable: true,
10 | content: