Skip to content

Commit 89fe866

Browse files
committed
Merge branch 'master' of https://github.com/mathuo/dockview into 479-is-there-any-way-to-focus-the-panel-content
2 parents 5864000 + cb69d47 commit 89fe866

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1658
-828
lines changed

.github/workflows/codeql-analysis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ jobs:
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3434

3535
# Initializes the CodeQL tools for scanning.
3636
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@v1
37+
uses: github/codeql-action/init@v3
3838
with:
3939
languages: ${{ matrix.language }}
4040
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -45,7 +45,7 @@ jobs:
4545
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
4646
# If this step fails, then you should remove it and run the build manually (see below)
4747
- name: Autobuild
48-
uses: github/codeql-action/autobuild@v1
48+
uses: github/codeql-action/autobuild@v3
4949

5050
# ℹ️ Command-line programs to run using the OS shell.
5151
# 📚 https://git.io/JvXDl
@@ -59,4 +59,4 @@ jobs:
5959
# make release
6060

6161
- name: Perform CodeQL Analysis
62-
uses: github/codeql-action/analyze@v1
62+
uses: github/codeql-action/analyze@v3

.github/workflows/deploy-docs.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@ name: Deploy Docs
22

33
on:
44
workflow_dispatch:
5-
schedule:
6-
- cron: '0 3 * * *' # every day at 3 am UTC
75

86
jobs:
97
deploy-nightly-demo-app:
108
runs-on: ubuntu-latest
119
steps:
1210
- name: Checkout 🛎️
13-
uses: actions/checkout@v3
11+
uses: actions/checkout@v4
1412
- name: Use Node.js
15-
uses: actions/setup-node@v3
13+
uses: actions/setup-node@v4
1614
with:
17-
node-version: '18.x'
15+
node-version: '20.x'
1816

19-
- uses: actions/cache@v3
17+
- uses: actions/cache@v4
2018
with:
2119
path: ~/.npm
2220
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}

.github/workflows/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
# might be required for sonar to work correctly
1212
with:
1313
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
1414
- name: Use Node.js
15-
uses: actions/setup-node@v3
15+
uses: actions/setup-node@v4
1616
with:
17-
node-version: '18.x'
17+
node-version: '20.x'
1818

19-
- uses: actions/cache@v3
19+
- uses: actions/cache@v4
2020
with:
2121
path: ~/.npm
2222
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}

.github/workflows/publish.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
id-token: write
1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: actions/setup-node@v3
19+
- uses: actions/setup-node@v4
2020
with:
21-
node-version: '18.x'
21+
node-version: '20.x'
2222
registry-url: 'https://registry.npmjs.org'
2323

24-
- uses: actions/cache@v3
24+
- uses: actions/cache@v4
2525
with:
2626
path: ~/.npm
2727
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
@@ -44,12 +44,12 @@ jobs:
4444
id-token: write
4545
steps:
4646
- uses: actions/checkout@v4
47-
- uses: actions/setup-node@v3
47+
- uses: actions/setup-node@v4
4848
with:
49-
node-version: '18.x'
49+
node-version: '20.x'
5050
registry-url: 'https://registry.npmjs.org'
5151

52-
- uses: actions/cache@v3
52+
- uses: actions/cache@v4
5353
with:
5454
path: ~/.npm
5555
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}

packages/dockview-core/src/__tests__/api/dockviewPanelApi.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('groupPanelApi', () => {
88
const accessor: Partial<DockviewComponent> = {
99
onDidAddPanel: jest.fn(),
1010
onDidRemovePanel: jest.fn(),
11-
options: {},
11+
options: { parentElement: document.createElement('div') },
1212
};
1313

1414
const panelMock = jest.fn<DockviewPanel, []>(() => {
@@ -44,7 +44,7 @@ describe('groupPanelApi', () => {
4444
const accessor: Partial<DockviewComponent> = {
4545
onDidAddPanel: jest.fn(),
4646
onDidRemovePanel: jest.fn(),
47-
options: {},
47+
options: { parentElement: document.createElement('div') },
4848
};
4949
const groupViewPanel = new DockviewGroupPanel(
5050
<DockviewComponent>accessor,
@@ -74,7 +74,7 @@ describe('groupPanelApi', () => {
7474
const accessor: Partial<DockviewComponent> = {
7575
onDidAddPanel: jest.fn(),
7676
onDidRemovePanel: jest.fn(),
77-
options: {},
77+
options: { parentElement: document.createElement('div') },
7878
};
7979
const groupViewPanel = new DockviewGroupPanel(
8080
<DockviewComponent>accessor,

packages/dockview-core/src/__tests__/dnd/droptarget.spec.ts

+59-29
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,37 @@ describe('droptarget', () => {
171171
createOffsetDragOverEvent({ clientX: 19, clientY: 0 })
172172
);
173173

174+
function check(
175+
element: HTMLElement,
176+
box: {
177+
left: string;
178+
top: string;
179+
width: string;
180+
height: string;
181+
}
182+
) {
183+
expect(element.style.top).toBe(box.top);
184+
expect(element.style.left).toBe(box.left);
185+
expect(element.style.width).toBe(box.width);
186+
expect(element.style.height).toBe(box.height);
187+
}
188+
174189
viewQuery = element.querySelectorAll(
175190
'.drop-target > .drop-target-dropzone > .drop-target-selection'
176191
);
177192
expect(viewQuery.length).toBe(1);
178193
expect(droptarget.state).toBe('left');
179-
expect(
180-
(
181-
element
182-
.getElementsByClassName('drop-target-selection')
183-
.item(0) as HTMLDivElement
184-
).style.transform
185-
).toBe('translateX(-25%) scaleX(0.5)');
194+
check(
195+
element
196+
.getElementsByClassName('drop-target-selection')
197+
.item(0) as HTMLDivElement,
198+
{
199+
top: '0px',
200+
left: '0px',
201+
width: '50%',
202+
height: '100%',
203+
}
204+
);
186205

187206
fireEvent(
188207
target,
@@ -194,13 +213,17 @@ describe('droptarget', () => {
194213
);
195214
expect(viewQuery.length).toBe(1);
196215
expect(droptarget.state).toBe('top');
197-
expect(
198-
(
199-
element
200-
.getElementsByClassName('drop-target-selection')
201-
.item(0) as HTMLDivElement
202-
).style.transform
203-
).toBe('translateY(-25%) scaleY(0.5)');
216+
check(
217+
element
218+
.getElementsByClassName('drop-target-selection')
219+
.item(0) as HTMLDivElement,
220+
{
221+
top: '0px',
222+
left: '0px',
223+
width: '100%',
224+
height: '50%',
225+
}
226+
);
204227

205228
fireEvent(
206229
target,
@@ -212,13 +235,17 @@ describe('droptarget', () => {
212235
);
213236
expect(viewQuery.length).toBe(1);
214237
expect(droptarget.state).toBe('bottom');
215-
expect(
216-
(
217-
element
218-
.getElementsByClassName('drop-target-selection')
219-
.item(0) as HTMLDivElement
220-
).style.transform
221-
).toBe('translateY(25%) scaleY(0.5)');
238+
check(
239+
element
240+
.getElementsByClassName('drop-target-selection')
241+
.item(0) as HTMLDivElement,
242+
{
243+
top: '50%',
244+
left: '0px',
245+
width: '100%',
246+
height: '50%',
247+
}
248+
);
222249

223250
fireEvent(
224251
target,
@@ -230,14 +257,17 @@ describe('droptarget', () => {
230257
);
231258
expect(viewQuery.length).toBe(1);
232259
expect(droptarget.state).toBe('right');
233-
expect(
234-
(
235-
element
236-
.getElementsByClassName('drop-target-selection')
237-
.item(0) as HTMLDivElement
238-
).style.transform
239-
).toBe('translateX(25%) scaleX(0.5)');
240-
260+
check(
261+
element
262+
.getElementsByClassName('drop-target-selection')
263+
.item(0) as HTMLDivElement,
264+
{
265+
top: '0px',
266+
left: '50%',
267+
width: '50%',
268+
height: '100%',
269+
}
270+
);
241271
fireEvent(
242272
target,
243273
createOffsetDragOverEvent({ clientX: 100, clientY: 50 })

packages/dockview-core/src/__tests__/dnd/groupDragHandler.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('groupDragHandler', () => {
1111
const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
1212
const partial: Partial<DockviewGroupPanel> = {
1313
id: 'test_group_id',
14-
api: { location: 'grid' } as any,
14+
api: { location: { type: 'grid' } } as any,
1515
};
1616
return partial as DockviewGroupPanel;
1717
});
@@ -53,7 +53,7 @@ describe('groupDragHandler', () => {
5353

5454
const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
5555
const partial: Partial<DockviewGroupPanel> = {
56-
api: { location: 'floating' } as any,
56+
api: { location: { type: 'floating' } } as any,
5757
};
5858
return partial as DockviewGroupPanel;
5959
});
@@ -85,7 +85,7 @@ describe('groupDragHandler', () => {
8585

8686
const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
8787
const partial: Partial<DockviewGroupPanel> = {
88-
api: { location: 'grid' } as any,
88+
api: { location: { type: 'grid' } } as any,
8989
};
9090
return partial as DockviewGroupPanel;
9191
});

packages/dockview-core/src/__tests__/dockview/components/panel/content.spec.ts

+23-16
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@ describe('contentContainer', () => {
6262

6363
const disposable = new CompositeDisposable();
6464

65-
const dockviewComponent = jest.fn<DockviewComponent, []>(() => {
66-
return {
67-
renderer: 'onlyWhenVisibile',
68-
overlayRenderContainer: new OverlayRenderContainer(
69-
document.createElement('div')
70-
),
71-
} as DockviewComponent;
72-
});
65+
const overlayRenderContainer = new OverlayRenderContainer(
66+
document.createElement('div')
67+
);
7368

74-
const cut = new ContentContainer(dockviewComponent(), jest.fn() as any);
69+
const cut = new ContentContainer(
70+
fromPartial<DockviewComponent>({
71+
renderer: 'onlyWhenVisibile',
72+
overlayRenderContainer,
73+
}),
74+
fromPartial<DockviewGroupPanelModel>({
75+
renderContainer: overlayRenderContainer,
76+
})
77+
);
7578

7679
disposable.addDisposables(
7780
cut.onDidFocus(() => {
@@ -84,12 +87,12 @@ describe('contentContainer', () => {
8487

8588
const contentRenderer = new TestContentRenderer('id-1');
8689

87-
const panel = {
90+
const panel = fromPartial<IDockviewPanel>({
8891
view: {
8992
content: contentRenderer,
90-
} as Partial<IDockviewPanelModel>,
93+
},
9194
api: { renderer: 'onlyWhenVisibile' },
92-
} as Partial<IDockviewPanel>;
95+
});
9396

9497
cut.openPanel(panel as IDockviewPanel);
9598

@@ -151,13 +154,17 @@ describe('contentContainer', () => {
151154
});
152155

153156
test("that panels renderered as 'onlyWhenVisibile' are removed when closed", () => {
157+
const overlayRenderContainer = fromPartial<OverlayRenderContainer>({
158+
detatch: jest.fn(),
159+
});
160+
154161
const cut = new ContentContainer(
155162
fromPartial<DockviewComponent>({
156-
overlayRenderContainer: {
157-
detatch: jest.fn(),
158-
},
163+
overlayRenderContainer,
159164
}),
160-
fromPartial<DockviewGroupPanelModel>({})
165+
fromPartial<DockviewGroupPanelModel>({
166+
renderContainer: overlayRenderContainer,
167+
})
161168
);
162169

163170
const panel1 = fromPartial<IDockviewPanel>({

0 commit comments

Comments
 (0)