@atlaskit/navigation-system 11.3.0 → 11.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/ui/page-layout/calculate-layout-area-states.js +76 -37
- package/dist/cjs/ui/page-layout/chat-panel.js +6 -3
- package/dist/cjs/ui/page-layout/layout-area-sizing-context.js +2 -2
- package/dist/cjs/ui/page-layout/layout-area-sizing-provider.js +243 -247
- package/dist/cjs/ui/page-layout/layout-area-sizing-runtime.js +468 -0
- package/dist/cjs/ui/page-layout/main/main.js +1 -1
- package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.js +239 -99
- package/dist/cjs/ui/page-layout/panel-splitter/provider.js +3 -1
- package/dist/cjs/ui/page-layout/root.compiled.css +14 -3
- package/dist/cjs/ui/page-layout/root.js +43 -17
- package/dist/cjs/ui/page-layout/side-nav/side-nav.js +14 -3
- package/dist/cjs/ui/page-layout/use-css-layout-area-states.js +117 -0
- package/dist/cjs/ui/page-layout/use-layout-area-sizing.js +3 -1
- package/dist/es2019/ui/page-layout/calculate-layout-area-states.js +51 -17
- package/dist/es2019/ui/page-layout/chat-panel.js +29 -5
- package/dist/es2019/ui/page-layout/layout-area-sizing-context.js +2 -2
- package/dist/es2019/ui/page-layout/layout-area-sizing-provider.js +171 -241
- package/dist/es2019/ui/page-layout/layout-area-sizing-runtime.js +419 -0
- package/dist/es2019/ui/page-layout/main/main.js +2 -2
- package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.js +60 -10
- package/dist/es2019/ui/page-layout/panel-splitter/provider.js +3 -1
- package/dist/es2019/ui/page-layout/root.compiled.css +14 -3
- package/dist/es2019/ui/page-layout/root.js +30 -3
- package/dist/es2019/ui/page-layout/side-nav/side-nav.js +23 -3
- package/dist/es2019/ui/page-layout/use-css-layout-area-states.js +73 -0
- package/dist/es2019/ui/page-layout/use-layout-area-sizing.js +3 -1
- package/dist/esm/ui/page-layout/calculate-layout-area-states.js +75 -37
- package/dist/esm/ui/page-layout/chat-panel.js +7 -4
- package/dist/esm/ui/page-layout/layout-area-sizing-context.js +2 -2
- package/dist/esm/ui/page-layout/layout-area-sizing-provider.js +243 -248
- package/dist/esm/ui/page-layout/layout-area-sizing-runtime.js +459 -0
- package/dist/esm/ui/page-layout/main/main.js +2 -2
- package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.js +238 -98
- package/dist/esm/ui/page-layout/panel-splitter/provider.js +3 -1
- package/dist/esm/ui/page-layout/root.compiled.css +14 -3
- package/dist/esm/ui/page-layout/root.js +42 -16
- package/dist/esm/ui/page-layout/side-nav/side-nav.js +14 -3
- package/dist/esm/ui/page-layout/use-css-layout-area-states.js +110 -0
- package/dist/esm/ui/page-layout/use-layout-area-sizing.js +3 -1
- package/dist/types/ui/page-layout/calculate-layout-area-states.d.ts +7 -2
- package/dist/types/ui/page-layout/layout-area-sizing-context.d.ts +10 -3
- package/dist/types/ui/page-layout/layout-area-sizing-provider.d.ts +6 -0
- package/dist/types/ui/page-layout/layout-area-sizing-runtime.d.ts +8 -0
- package/dist/types/ui/page-layout/panel-splitter/panel-splitter-context.d.ts +4 -0
- package/dist/types/ui/page-layout/panel-splitter/provider.d.ts +1 -1
- package/dist/types/ui/page-layout/root.d.ts +2 -0
- package/dist/types/ui/page-layout/use-css-layout-area-states.d.ts +8 -0
- package/dist/types/ui/page-layout/use-layout-area-sizing.d.ts +2 -0
- package/package.json +12 -6
|
@@ -1,279 +1,209 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { bind } from 'bind-event-listener';
|
|
3
|
-
import { calculateLayoutAreaStates } from './calculate-layout-area-states';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { bind, bindAll } from 'bind-event-listener';
|
|
4
3
|
import { LayoutAreaSizingContext } from './layout-area-sizing-context';
|
|
5
4
|
import { layoutAreaStateContexts } from './layout-area-state-contexts';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return useMemo(() => mode !== undefined && width !== undefined && minWidth !== undefined ? {
|
|
15
|
-
mode,
|
|
16
|
-
width,
|
|
17
|
-
minWidth
|
|
18
|
-
} : undefined, [mode, width, minWidth]);
|
|
19
|
-
}
|
|
5
|
+
import { useCssLayoutAreaStates } from './use-css-layout-area-states';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Stable, synchronous boundary for SSR content. The drag/cascade implementation
|
|
9
|
+
* is a sibling, not a replacement wrapper, so loading it cannot remount the app.
|
|
10
|
+
* CSS handles initial and responsive geometry; only splitter interaction requests
|
|
11
|
+
* the asynchronous chunk. The eager observer reads modes without changing widths.
|
|
12
|
+
*/
|
|
20
13
|
export function LayoutAreaSizingProvider({
|
|
21
14
|
children,
|
|
22
15
|
layoutRef
|
|
23
16
|
}) {
|
|
24
|
-
|
|
25
|
-
const [
|
|
26
|
-
const [
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
var _states$sideNav$mode, _states$sideNav, _states$chatPanel$mo, _states$chatPanel;
|
|
18
|
+
const [Runtime, setRuntime] = useState(null);
|
|
19
|
+
const [states, setStates] = useState({});
|
|
20
|
+
const actions = useRef(null);
|
|
21
|
+
const configs = useRef({});
|
|
22
|
+
const [lastOpenedOverlay, setLastOpenedOverlay] = useState(null);
|
|
23
|
+
const [configRevision, setConfigRevision] = useState(0);
|
|
24
|
+
const cssModes = useCssLayoutAreaStates(layoutRef, configRevision, Runtime === null);
|
|
25
|
+
const sideNavMode = (_states$sideNav$mode = (_states$sideNav = states['side-nav']) === null || _states$sideNav === void 0 ? void 0 : _states$sideNav.mode) !== null && _states$sideNav$mode !== void 0 ? _states$sideNav$mode : cssModes['side-nav'];
|
|
26
|
+
const chatPanelMode = (_states$chatPanel$mo = (_states$chatPanel = states['chat-panel']) === null || _states$chatPanel === void 0 ? void 0 : _states$chatPanel.mode) !== null && _states$chatPanel$mo !== void 0 ? _states$chatPanel$mo : cssModes['chat-panel'];
|
|
27
|
+
|
|
28
|
+
// Overlay dismissal is available before the sizing chunk loads. Keep the open
|
|
29
|
+
// order here too: replaying registrations into the runtime loses that order.
|
|
35
30
|
useEffect(() => {
|
|
36
|
-
const root = layoutRef === null || layoutRef === void 0 ? void 0 : layoutRef.current;
|
|
37
|
-
let previous = null;
|
|
38
|
-
// Match the actual rem-based grid breakpoint, including browser font settings.
|
|
39
31
|
const inlineChatQuery = window.matchMedia('(min-width: 40rem)');
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const next = {
|
|
46
|
-
viewportWidth: window.innerWidth,
|
|
47
|
-
layoutWidth,
|
|
48
|
-
isChatPanelOverlay: !inlineChatQuery.matches,
|
|
49
|
-
isSideNavOverlay: !inlineSideNavQuery.matches
|
|
50
|
-
};
|
|
51
|
-
if (((_previous = previous) === null || _previous === void 0 ? void 0 : _previous.viewportWidth) === next.viewportWidth && previous.layoutWidth === next.layoutWidth && previous.isChatPanelOverlay === next.isChatPanelOverlay && previous.isSideNavOverlay === next.isSideNavOverlay) {
|
|
32
|
+
const dismissOlderOverlay = () => {
|
|
33
|
+
var _olderOverlay$onReque;
|
|
34
|
+
const sideNav = configs.current['side-nav'];
|
|
35
|
+
const chatPanel = configs.current['chat-panel'];
|
|
36
|
+
if (!(sideNav !== null && sideNav !== void 0 && sideNav.isOpen) || !(chatPanel !== null && chatPanel !== void 0 && chatPanel.isOpen) || !lastOpenedOverlay) {
|
|
52
37
|
return;
|
|
53
38
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
updateDimensions();
|
|
59
|
-
const observer = new ResizeObserver(entries => {
|
|
60
|
-
const entry = entries.find(entry => entry.target === root);
|
|
61
|
-
if (entry) {
|
|
62
|
-
updateDimensions(entry.contentRect.width);
|
|
39
|
+
// Before allocation, CSS puts both areas in overlay below 40rem. Once
|
|
40
|
+
// sizing is active, also honour overlays caused by custom widths/slots.
|
|
41
|
+
if (inlineChatQuery.matches && (sideNavMode !== 'overlay' || chatPanelMode !== 'overlay')) {
|
|
42
|
+
return;
|
|
63
43
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
observer.observe(root);
|
|
67
|
-
}
|
|
68
|
-
const unbindResize = bind(window, {
|
|
69
|
-
type: 'resize',
|
|
70
|
-
listener: () => updateDimensions()
|
|
71
|
-
});
|
|
72
|
-
const unbindQuery = bind(inlineChatQuery, {
|
|
73
|
-
type: 'change',
|
|
74
|
-
listener: () => updateDimensions()
|
|
75
|
-
});
|
|
76
|
-
const unbindSideNavQuery = bind(inlineSideNavQuery, {
|
|
77
|
-
type: 'change',
|
|
78
|
-
listener: () => updateDimensions()
|
|
79
|
-
});
|
|
80
|
-
return () => {
|
|
81
|
-
observer.disconnect();
|
|
82
|
-
unbindResize();
|
|
83
|
-
unbindQuery();
|
|
84
|
-
unbindSideNavQuery();
|
|
44
|
+
const olderOverlay = lastOpenedOverlay === 'side-nav' ? chatPanel : sideNav;
|
|
45
|
+
(_olderOverlay$onReque = olderOverlay.onRequestClose) === null || _olderOverlay$onReque === void 0 ? void 0 : _olderOverlay$onReque.call(olderOverlay);
|
|
85
46
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
setResizeSession(current => {
|
|
91
|
-
// A changed layout/configuration needs a fresh allocation. A controlled
|
|
92
|
-
// acknowledgement for the resized area keeps its siblings fixed.
|
|
93
|
-
return (previous === null || previous === void 0 ? void 0 : previous.isOpen) === config.isOpen && previous.minWidth === config.minWidth && previous.maxWidth === config.maxWidth && previous.defaultWidth === config.defaultWidth && previous.compactDefaultWidth === config.compactDefaultWidth && (previous.requestedWidth === config.requestedWidth || (current === null || current === void 0 ? void 0 : current.area) === area) ? current : null;
|
|
94
|
-
});
|
|
95
|
-
// Allocate once per registration, outside the updater React may replay. Gaps are
|
|
96
|
-
// harmless: only relative ordering of closed-to-open transitions is significant.
|
|
97
|
-
const openedAt = ++openSequence.current;
|
|
98
|
-
setAreas(current => {
|
|
99
|
-
const existing = current[area];
|
|
100
|
-
return {
|
|
101
|
-
...current,
|
|
102
|
-
[area]: {
|
|
103
|
-
...existing,
|
|
104
|
-
...config,
|
|
105
|
-
liveResize: config.isOpen ? existing === null || existing === void 0 ? void 0 : existing.liveResize : undefined,
|
|
106
|
-
openedAt: config.isOpen && !(existing !== null && existing !== void 0 && existing.isOpen) ? openedAt : existing === null || existing === void 0 ? void 0 : existing.openedAt
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
}, []);
|
|
111
|
-
const unregisterArea = useCallback(area => {
|
|
112
|
-
delete configsRef.current[area];
|
|
113
|
-
setResizeSession(null);
|
|
114
|
-
setAreas(current => {
|
|
115
|
-
if (!current[area]) {
|
|
116
|
-
return current;
|
|
117
|
-
}
|
|
118
|
-
// Closing uses isOpen: false and retains preferences. Unregistering means
|
|
119
|
-
// the owning component unmounted; a replacement must start with its own defaults.
|
|
120
|
-
const next = {
|
|
121
|
-
...current
|
|
122
|
-
};
|
|
123
|
-
delete next[area];
|
|
124
|
-
return next;
|
|
47
|
+
dismissOlderOverlay();
|
|
48
|
+
return bind(inlineChatQuery, {
|
|
49
|
+
type: 'change',
|
|
50
|
+
listener: dismissOlderOverlay
|
|
125
51
|
});
|
|
126
|
-
}, []);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
52
|
+
}, [chatPanelMode, lastOpenedOverlay, sideNavMode]);
|
|
53
|
+
const mainMinWidth = useRef(320);
|
|
54
|
+
const loadRef = useRef(() => {});
|
|
55
|
+
const ready = useRef(false);
|
|
56
|
+
const waiting = useRef([]);
|
|
57
|
+
const pending = useRef([]);
|
|
58
|
+
const prepareResize = useCallback(() => {
|
|
59
|
+
if (ready.current) {
|
|
60
|
+
return Promise.resolve(true);
|
|
134
61
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
area,
|
|
139
|
-
baselineWidths
|
|
62
|
+
return new Promise(resolve => {
|
|
63
|
+
waiting.current.push(resolve);
|
|
64
|
+
loadRef.current();
|
|
140
65
|
});
|
|
141
66
|
}, []);
|
|
142
|
-
|
|
143
|
-
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const root = layoutRef === null || layoutRef === void 0 ? void 0 : layoutRef.current;
|
|
69
|
+
if (!root) {
|
|
144
70
|
return;
|
|
145
71
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
setAreas(current => {
|
|
153
|
-
const existing = current[area];
|
|
154
|
-
return existing ? {
|
|
155
|
-
...current,
|
|
156
|
-
[area]: {
|
|
157
|
-
...existing,
|
|
158
|
-
liveResize: {
|
|
159
|
-
mode,
|
|
160
|
-
width: renderedState.width
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
} : current;
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}, [freezeSiblingWidths]);
|
|
167
|
-
const resize = useCallback((area, mode, width) => {
|
|
168
|
-
setAreas(current => {
|
|
169
|
-
var _existing$liveResize;
|
|
170
|
-
const existing = current[area];
|
|
171
|
-
if ((existing === null || existing === void 0 ? void 0 : (_existing$liveResize = existing.liveResize) === null || _existing$liveResize === void 0 ? void 0 : _existing$liveResize.mode) === mode && existing.liveResize.width === width) {
|
|
172
|
-
return current;
|
|
72
|
+
let cancelled = false;
|
|
73
|
+
let loading = false;
|
|
74
|
+
const waitingForRuntime = waiting.current;
|
|
75
|
+
const load = () => {
|
|
76
|
+
if (loading) {
|
|
77
|
+
return;
|
|
173
78
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
width
|
|
181
|
-
}
|
|
79
|
+
loading = true;
|
|
80
|
+
void import( /* webpackChunkName: "@atlaskit-internal_navigation-layout-sizing" */'./layout-area-sizing-runtime').then(({
|
|
81
|
+
LayoutAreaSizingRuntime
|
|
82
|
+
}) => {
|
|
83
|
+
if (!cancelled) {
|
|
84
|
+
setRuntime(() => LayoutAreaSizingRuntime);
|
|
182
85
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (
|
|
194
|
-
|
|
86
|
+
}, () => {
|
|
87
|
+
loading = false;
|
|
88
|
+
pending.current = [];
|
|
89
|
+
for (const resolve of waitingForRuntime.splice(0)) {
|
|
90
|
+
resolve(false);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
loadRef.current = load;
|
|
95
|
+
const loadForSplitter = event => {
|
|
96
|
+
if (event.target instanceof Element && event.target.closest('[data-panel-splitter]')) {
|
|
97
|
+
load();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const unbindRoot = bindAll(root, [{
|
|
101
|
+
type: 'pointerover',
|
|
102
|
+
listener: loadForSplitter,
|
|
103
|
+
options: {
|
|
104
|
+
passive: true
|
|
195
105
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
};
|
|
106
|
+
}, {
|
|
107
|
+
type: 'focusin',
|
|
108
|
+
listener: loadForSplitter
|
|
109
|
+
}, {
|
|
110
|
+
type: 'pointerdown',
|
|
111
|
+
listener: loadForSplitter,
|
|
112
|
+
options: {
|
|
113
|
+
passive: true
|
|
205
114
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
115
|
+
}]);
|
|
116
|
+
return () => {
|
|
117
|
+
cancelled = true;
|
|
118
|
+
ready.current = false;
|
|
119
|
+
pending.current = [];
|
|
120
|
+
for (const resolve of waitingForRuntime.splice(0)) {
|
|
121
|
+
resolve(false);
|
|
122
|
+
}
|
|
123
|
+
loadRef.current = () => {};
|
|
124
|
+
unbindRoot();
|
|
125
|
+
};
|
|
126
|
+
}, [layoutRef]);
|
|
127
|
+
const onReady = useCallback(runtime => {
|
|
128
|
+
actions.current = runtime;
|
|
129
|
+
if (runtime) {
|
|
130
|
+
runtime.setMainMinWidth(mainMinWidth.current);
|
|
131
|
+
for (const area of ['side-nav', 'panel', 'chat-panel']) {
|
|
132
|
+
const config = configs.current[area];
|
|
133
|
+
if (config) {
|
|
134
|
+
runtime.registerArea(area, config);
|
|
212
135
|
}
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}, [freezeSiblingWidths]);
|
|
216
|
-
const areaStates = useMemo(() => dimensions === null ? {} : calculateLayoutAreaStates({
|
|
217
|
-
...dimensions,
|
|
218
|
-
occupiedWidth,
|
|
219
|
-
mainMinWidth,
|
|
220
|
-
areas,
|
|
221
|
-
resizeSession
|
|
222
|
-
}), [areas, mainMinWidth, resizeSession, dimensions, occupiedWidth]);
|
|
223
|
-
useEffect(() => {
|
|
224
|
-
areaStatesRef.current = areaStates;
|
|
225
|
-
}, [areaStates]);
|
|
226
|
-
useEffect(() => {
|
|
227
|
-
var _areaStates$sideNav, _areaStates$chatPane, _sideNav$openedAt, _chatPanel$openedAt;
|
|
228
|
-
if (((_areaStates$sideNav = areaStates['side-nav']) === null || _areaStates$sideNav === void 0 ? void 0 : _areaStates$sideNav.mode) !== 'overlay' || ((_areaStates$chatPane = areaStates['chat-panel']) === null || _areaStates$chatPane === void 0 ? void 0 : _areaStates$chatPane.mode) !== 'overlay') {
|
|
229
|
-
return;
|
|
136
|
+
}
|
|
230
137
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
138
|
+
}, []);
|
|
139
|
+
const onUpdate = useCallback(next => {
|
|
140
|
+
setStates(next);
|
|
141
|
+
const runtime = actions.current;
|
|
142
|
+
if (runtime && Object.values(next).some(Boolean)) {
|
|
143
|
+
ready.current = true;
|
|
144
|
+
for (const action of pending.current.splice(0)) {
|
|
145
|
+
action(runtime);
|
|
146
|
+
}
|
|
147
|
+
for (const resolve of waiting.current.splice(0)) {
|
|
148
|
+
resolve(true);
|
|
149
|
+
}
|
|
235
150
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
151
|
+
}, []);
|
|
152
|
+
const dispatch = useCallback(action => {
|
|
153
|
+
if (ready.current && actions.current) {
|
|
154
|
+
action(actions.current);
|
|
239
155
|
} else {
|
|
240
|
-
|
|
241
|
-
|
|
156
|
+
pending.current.push(action);
|
|
157
|
+
loadRef.current();
|
|
242
158
|
}
|
|
243
|
-
}, [areas, areaStates]);
|
|
244
|
-
|
|
245
|
-
// Read bounds lazily: changing a sibling's capacity must not publish new render
|
|
246
|
-
// state or recreate drag listeners for a region whose own width did not change.
|
|
247
|
-
const getResizeBounds = useCallback(area => {
|
|
248
|
-
var _areaStatesRef$curren;
|
|
249
|
-
const bounds = (_areaStatesRef$curren = areaStatesRef.current[area]) === null || _areaStatesRef$curren === void 0 ? void 0 : _areaStatesRef$curren.resizeBounds;
|
|
250
|
-
return bounds ? {
|
|
251
|
-
min: `${bounds.min}px`,
|
|
252
|
-
max: `${bounds.max}px`
|
|
253
|
-
} : undefined;
|
|
254
159
|
}, []);
|
|
255
160
|
const value = useMemo(() => ({
|
|
256
|
-
|
|
257
|
-
registerArea,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
161
|
+
prepareResize,
|
|
162
|
+
registerArea: (area, config) => {
|
|
163
|
+
var _configs$current$area, _actions$current;
|
|
164
|
+
if (area !== 'panel' && config.isOpen && !((_configs$current$area = configs.current[area]) !== null && _configs$current$area !== void 0 && _configs$current$area.isOpen)) {
|
|
165
|
+
setLastOpenedOverlay(area);
|
|
166
|
+
}
|
|
167
|
+
configs.current[area] = config;
|
|
168
|
+
setConfigRevision(revision => revision + 1);
|
|
169
|
+
(_actions$current = actions.current) === null || _actions$current === void 0 ? void 0 : _actions$current.registerArea(area, config);
|
|
170
|
+
},
|
|
171
|
+
unregisterArea: area => {
|
|
172
|
+
var _actions$current2;
|
|
173
|
+
delete configs.current[area];
|
|
174
|
+
setConfigRevision(revision => revision + 1);
|
|
175
|
+
(_actions$current2 = actions.current) === null || _actions$current2 === void 0 ? void 0 : _actions$current2.unregisterArea(area);
|
|
176
|
+
},
|
|
177
|
+
setMainMinWidth: width => {
|
|
178
|
+
var _actions$current3;
|
|
179
|
+
if (mainMinWidth.current !== width) {
|
|
180
|
+
setConfigRevision(revision => revision + 1);
|
|
181
|
+
}
|
|
182
|
+
mainMinWidth.current = width;
|
|
183
|
+
(_actions$current3 = actions.current) === null || _actions$current3 === void 0 ? void 0 : _actions$current3.setMainMinWidth(width);
|
|
184
|
+
},
|
|
185
|
+
getResizeBounds: area => {
|
|
186
|
+
var _actions$current4;
|
|
187
|
+
return (_actions$current4 = actions.current) === null || _actions$current4 === void 0 ? void 0 : _actions$current4.getResizeBounds(area);
|
|
188
|
+
},
|
|
189
|
+
startResize: (area, mode) => dispatch(runtime => runtime.startResize(area, mode)),
|
|
190
|
+
resize: (area, mode, width) => dispatch(runtime => runtime.resize(area, mode, width)),
|
|
191
|
+
completeResize: (area, mode, width) => dispatch(runtime => runtime.completeResize(area, mode, width))
|
|
192
|
+
}), [dispatch, prepareResize]);
|
|
267
193
|
const SideNavStateProvider = layoutAreaStateContexts['side-nav'].Provider;
|
|
268
194
|
const PanelStateProvider = layoutAreaStateContexts.panel.Provider;
|
|
269
195
|
const ChatPanelStateProvider = layoutAreaStateContexts['chat-panel'].Provider;
|
|
270
196
|
return /*#__PURE__*/React.createElement(LayoutAreaSizingContext.Provider, {
|
|
271
197
|
value: value
|
|
272
198
|
}, /*#__PURE__*/React.createElement(SideNavStateProvider, {
|
|
273
|
-
value:
|
|
199
|
+
value: states['side-nav']
|
|
274
200
|
}, /*#__PURE__*/React.createElement(PanelStateProvider, {
|
|
275
|
-
value:
|
|
201
|
+
value: states.panel
|
|
276
202
|
}, /*#__PURE__*/React.createElement(ChatPanelStateProvider, {
|
|
277
|
-
value:
|
|
278
|
-
}, children)))
|
|
203
|
+
value: states['chat-panel']
|
|
204
|
+
}, children))), Runtime && /*#__PURE__*/React.createElement(Runtime, {
|
|
205
|
+
layoutRef: layoutRef,
|
|
206
|
+
onReady: onReady,
|
|
207
|
+
onUpdate: onUpdate
|
|
208
|
+
}));
|
|
279
209
|
}
|