@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.
Files changed (50) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/ui/page-layout/calculate-layout-area-states.js +76 -37
  3. package/dist/cjs/ui/page-layout/chat-panel.js +6 -3
  4. package/dist/cjs/ui/page-layout/layout-area-sizing-context.js +2 -2
  5. package/dist/cjs/ui/page-layout/layout-area-sizing-provider.js +243 -247
  6. package/dist/cjs/ui/page-layout/layout-area-sizing-runtime.js +468 -0
  7. package/dist/cjs/ui/page-layout/main/main.js +1 -1
  8. package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.js +239 -99
  9. package/dist/cjs/ui/page-layout/panel-splitter/provider.js +3 -1
  10. package/dist/cjs/ui/page-layout/root.compiled.css +14 -3
  11. package/dist/cjs/ui/page-layout/root.js +43 -17
  12. package/dist/cjs/ui/page-layout/side-nav/side-nav.js +14 -3
  13. package/dist/cjs/ui/page-layout/use-css-layout-area-states.js +117 -0
  14. package/dist/cjs/ui/page-layout/use-layout-area-sizing.js +3 -1
  15. package/dist/es2019/ui/page-layout/calculate-layout-area-states.js +51 -17
  16. package/dist/es2019/ui/page-layout/chat-panel.js +29 -5
  17. package/dist/es2019/ui/page-layout/layout-area-sizing-context.js +2 -2
  18. package/dist/es2019/ui/page-layout/layout-area-sizing-provider.js +171 -241
  19. package/dist/es2019/ui/page-layout/layout-area-sizing-runtime.js +419 -0
  20. package/dist/es2019/ui/page-layout/main/main.js +2 -2
  21. package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.js +60 -10
  22. package/dist/es2019/ui/page-layout/panel-splitter/provider.js +3 -1
  23. package/dist/es2019/ui/page-layout/root.compiled.css +14 -3
  24. package/dist/es2019/ui/page-layout/root.js +30 -3
  25. package/dist/es2019/ui/page-layout/side-nav/side-nav.js +23 -3
  26. package/dist/es2019/ui/page-layout/use-css-layout-area-states.js +73 -0
  27. package/dist/es2019/ui/page-layout/use-layout-area-sizing.js +3 -1
  28. package/dist/esm/ui/page-layout/calculate-layout-area-states.js +75 -37
  29. package/dist/esm/ui/page-layout/chat-panel.js +7 -4
  30. package/dist/esm/ui/page-layout/layout-area-sizing-context.js +2 -2
  31. package/dist/esm/ui/page-layout/layout-area-sizing-provider.js +243 -248
  32. package/dist/esm/ui/page-layout/layout-area-sizing-runtime.js +459 -0
  33. package/dist/esm/ui/page-layout/main/main.js +2 -2
  34. package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.js +238 -98
  35. package/dist/esm/ui/page-layout/panel-splitter/provider.js +3 -1
  36. package/dist/esm/ui/page-layout/root.compiled.css +14 -3
  37. package/dist/esm/ui/page-layout/root.js +42 -16
  38. package/dist/esm/ui/page-layout/side-nav/side-nav.js +14 -3
  39. package/dist/esm/ui/page-layout/use-css-layout-area-states.js +110 -0
  40. package/dist/esm/ui/page-layout/use-layout-area-sizing.js +3 -1
  41. package/dist/types/ui/page-layout/calculate-layout-area-states.d.ts +7 -2
  42. package/dist/types/ui/page-layout/layout-area-sizing-context.d.ts +10 -3
  43. package/dist/types/ui/page-layout/layout-area-sizing-provider.d.ts +6 -0
  44. package/dist/types/ui/page-layout/layout-area-sizing-runtime.d.ts +8 -0
  45. package/dist/types/ui/page-layout/panel-splitter/panel-splitter-context.d.ts +4 -0
  46. package/dist/types/ui/page-layout/panel-splitter/provider.d.ts +1 -1
  47. package/dist/types/ui/page-layout/root.d.ts +2 -0
  48. package/dist/types/ui/page-layout/use-css-layout-area-states.d.ts +8 -0
  49. package/dist/types/ui/page-layout/use-layout-area-sizing.d.ts +2 -0
  50. package/package.json +12 -6
@@ -0,0 +1,468 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.LayoutAreaSizingRuntime = LayoutAreaSizingRuntime;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _bindEventListener = require("bind-event-listener");
13
+ var _calculateLayoutAreaStates = require("./calculate-layout-area-states");
14
+ var _layoutAreaSizingContext = require("./layout-area-sizing-context");
15
+ var _layoutAreaStateContexts = require("./layout-area-state-contexts");
16
+ var _resolveLayoutWidth = require("./resolve-layout-width");
17
+ var _useOccupiedLayoutWidth = require("./use-occupied-layout-width");
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
19
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
20
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
21
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
22
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ var defaultMainMinWidth = 320;
25
+ function useStableAreaState(state) {
26
+ var _ref = state !== null && state !== void 0 ? state : {},
27
+ mode = _ref.mode,
28
+ width = _ref.width,
29
+ minWidth = _ref.minWidth;
30
+ return (0, _react.useMemo)(function () {
31
+ return mode !== undefined && width !== undefined && minWidth !== undefined ? {
32
+ mode: mode,
33
+ width: width,
34
+ minWidth: minWidth
35
+ } : undefined;
36
+ }, [mode, width, minWidth]);
37
+ }
38
+ function LayoutAreaSizingRuntime(_ref2) {
39
+ var children = _ref2.children,
40
+ layoutRef = _ref2.layoutRef,
41
+ onReady = _ref2.onReady,
42
+ onUpdate = _ref2.onUpdate;
43
+ var occupiedWidth = (0, _useOccupiedLayoutWidth.useOccupiedLayoutWidth)(layoutRef);
44
+ var _useState = (0, _react.useState)(null),
45
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
46
+ dimensions = _useState2[0],
47
+ setDimensions = _useState2[1];
48
+ var _useState3 = (0, _react.useState)(defaultMainMinWidth),
49
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
50
+ mainMinWidth = _useState4[0],
51
+ setMainMinWidth = _useState4[1];
52
+ var _useState5 = (0, _react.useState)({}),
53
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
54
+ areas = _useState6[0],
55
+ setAreas = _useState6[1];
56
+ var _useState7 = (0, _react.useState)(null),
57
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
58
+ resizeSession = _useState8[0],
59
+ setResizeSession = _useState8[1];
60
+ var areaStatesRef = _react.default.useRef({});
61
+ var configsRef = _react.default.useRef({});
62
+ var _useState9 = (0, _react.useState)(false),
63
+ _useState0 = (0, _slicedToArray2.default)(_useState9, 2),
64
+ hasInteraction = _useState0[0],
65
+ setHasInteraction = _useState0[1];
66
+ var adoptedConstraints = _react.default.useRef(null);
67
+ // Preserve the CSS handoff only while its available space is unchanged.
68
+ var isPreservingInitialLayout = !hasInteraction && (!adoptedConstraints.current || adoptedConstraints.current.occupiedWidth === occupiedWidth && adoptedConstraints.current.mainMinWidth === mainMinWidth);
69
+ var _useState1 = (0, _react.useState)({}),
70
+ _useState10 = (0, _slicedToArray2.default)(_useState1, 2),
71
+ initialStates = _useState10[0],
72
+ setInitialStates = _useState10[1];
73
+ var inputsRef = _react.default.useRef({
74
+ dimensions: dimensions,
75
+ occupiedWidth: occupiedWidth,
76
+ mainMinWidth: mainMinWidth,
77
+ areas: areas,
78
+ resizeSession: resizeSession
79
+ });
80
+ (0, _react.useEffect)(function () {
81
+ inputsRef.current = {
82
+ dimensions: dimensions,
83
+ occupiedWidth: occupiedWidth,
84
+ mainMinWidth: mainMinWidth,
85
+ areas: areas,
86
+ resizeSession: resizeSession
87
+ };
88
+ }, [dimensions, occupiedWidth, mainMinWidth, areas, resizeSession]);
89
+ (0, _react.useEffect)(function () {
90
+ if (adoptedConstraints.current && (adoptedConstraints.current.occupiedWidth !== occupiedWidth || adoptedConstraints.current.mainMinWidth !== mainMinWidth)) {
91
+ setHasInteraction(true);
92
+ }
93
+ setResizeSession(null);
94
+ }, [mainMinWidth, occupiedWidth]);
95
+ (0, _react.useEffect)(function () {
96
+ var root = layoutRef === null || layoutRef === void 0 ? void 0 : layoutRef.current;
97
+ var previous = null;
98
+ // Match the actual rem-based grid breakpoint, including browser font settings.
99
+ var inlineChatQuery = window.matchMedia('(min-width: 40rem)');
100
+ var inlineSideNavQuery = window.matchMedia('(min-width: 64rem)');
101
+ var updateDimensions = function updateDimensions(contentWidth) {
102
+ var _style$width, _style$paddingLeft, _style$paddingRight, _style$borderLeftWidt, _style$borderRightWid, _previous;
103
+ var style = root && contentWidth === undefined ? getComputedStyle(root) : null;
104
+ var computedWidth = Number.parseFloat((_style$width = style === null || style === void 0 ? void 0 : style.width) !== null && _style$width !== void 0 ? _style$width : '');
105
+ var padding = (parseFloat((_style$paddingLeft = style === null || style === void 0 ? void 0 : style.paddingLeft) !== null && _style$paddingLeft !== void 0 ? _style$paddingLeft : '') || 0) + (parseFloat((_style$paddingRight = style === null || style === void 0 ? void 0 : style.paddingRight) !== null && _style$paddingRight !== void 0 ? _style$paddingRight : '') || 0);
106
+ var border = (parseFloat((_style$borderLeftWidt = style === null || style === void 0 ? void 0 : style.borderLeftWidth) !== null && _style$borderLeftWidt !== void 0 ? _style$borderLeftWidt : '') || 0) + (parseFloat((_style$borderRightWid = style === null || style === void 0 ? void 0 : style.borderRightWidth) !== null && _style$borderRightWid !== void 0 ? _style$borderRightWid : '') || 0);
107
+ var layoutWidth = contentWidth !== null && contentWidth !== void 0 ? contentWidth : root ?
108
+ // Keep fractional CSS pixels, just as ResizeObserver does. Otherwise
109
+ // its initial delivery could be mistaken for a viewport resize.
110
+ Math.max(0, Number.isFinite(computedWidth) ? computedWidth - ((style === null || style === void 0 ? void 0 : style.boxSizing) === 'border-box' ? padding + border : 0) : root.clientWidth - padding) : window.innerWidth;
111
+ var next = {
112
+ viewportWidth: window.innerWidth,
113
+ layoutWidth: layoutWidth,
114
+ isChatPanelOverlay: !inlineChatQuery.matches,
115
+ isSideNavOverlay: !inlineSideNavQuery.matches
116
+ };
117
+ 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) {
118
+ return;
119
+ }
120
+ if (previous) {
121
+ setHasInteraction(true);
122
+ }
123
+ previous = next;
124
+ setDimensions(next);
125
+ setResizeSession(null);
126
+ };
127
+ updateDimensions();
128
+ var observer = new ResizeObserver(function (entries) {
129
+ var entry = entries.find(function (entry) {
130
+ return entry.target === root;
131
+ });
132
+ if (entry) {
133
+ updateDimensions(entry.contentRect.width);
134
+ }
135
+ });
136
+ if (root) {
137
+ observer.observe(root);
138
+ }
139
+ var unbindResize = (0, _bindEventListener.bind)(window, {
140
+ type: 'resize',
141
+ listener: function listener() {
142
+ return updateDimensions();
143
+ }
144
+ });
145
+ var unbindQuery = (0, _bindEventListener.bind)(inlineChatQuery, {
146
+ type: 'change',
147
+ listener: function listener() {
148
+ return updateDimensions();
149
+ }
150
+ });
151
+ var unbindSideNavQuery = (0, _bindEventListener.bind)(inlineSideNavQuery, {
152
+ type: 'change',
153
+ listener: function listener() {
154
+ return updateDimensions();
155
+ }
156
+ });
157
+ return function () {
158
+ observer.disconnect();
159
+ unbindResize();
160
+ unbindQuery();
161
+ unbindSideNavQuery();
162
+ };
163
+ }, [layoutRef]);
164
+ var registerArea = (0, _react.useCallback)(function (area, config) {
165
+ var previous = configsRef.current[area];
166
+ if (adoptedConstraints.current && (!previous || previous.isOpen !== config.isOpen || previous.requestedWidth !== config.requestedWidth || previous.minWidth !== config.minWidth || previous.maxWidth !== config.maxWidth || previous.defaultWidth !== config.defaultWidth || previous.compactDefaultWidth !== config.compactDefaultWidth)) {
167
+ setHasInteraction(true);
168
+ }
169
+ configsRef.current[area] = config;
170
+ setResizeSession(function (current) {
171
+ // A changed layout/configuration needs a fresh allocation. A controlled
172
+ // acknowledgement for the resized area keeps its siblings fixed.
173
+ return previous && (previous.isOpen === config.isOpen || area === 'side-nav' && !config.isOpen && (current === null || current === void 0 ? void 0 : current.area) !== 'side-nav') && 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.completedWidth === config.requestedWidth || area === 'side-nav' && !config.isOpen && (current === null || current === void 0 ? void 0 : current.area) !== 'side-nav') ? current : null;
174
+ });
175
+ setAreas(function (current) {
176
+ var existing = current[area];
177
+ return _objectSpread(_objectSpread({}, current), {}, (0, _defineProperty2.default)({}, area, _objectSpread(_objectSpread(_objectSpread({}, existing), config), {}, {
178
+ liveResize: config.isOpen ? existing === null || existing === void 0 ? void 0 : existing.liveResize : undefined
179
+ })));
180
+ });
181
+ }, []);
182
+ var unregisterArea = (0, _react.useCallback)(function (area) {
183
+ if (adoptedConstraints.current) {
184
+ setHasInteraction(true);
185
+ }
186
+ delete configsRef.current[area];
187
+ setResizeSession(null);
188
+ setAreas(function (current) {
189
+ if (!current[area]) {
190
+ return current;
191
+ }
192
+ // Closing uses isOpen: false and retains preferences. Unregistering means
193
+ // the owning component unmounted; a replacement must start with its own defaults.
194
+ var next = _objectSpread({}, current);
195
+ delete next[area];
196
+ return next;
197
+ });
198
+ }, []);
199
+ var captureSiblingWidths = (0, _react.useCallback)(function (area) {
200
+ var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inline';
201
+ var baselineWidths = {};
202
+ var overlayModes = {};
203
+ var _iterator = _createForOfIteratorHelper(['side-nav', 'panel', 'chat-panel']),
204
+ _step;
205
+ try {
206
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
207
+ var areaName = _step.value;
208
+ var state = areaStatesRef.current[areaName];
209
+ if (state) {
210
+ overlayModes[areaName] = state.mode;
211
+ }
212
+ if ((state === null || state === void 0 ? void 0 : state.mode) === 'inline') {
213
+ baselineWidths[areaName] = state.width;
214
+ }
215
+ }
216
+ } catch (err) {
217
+ _iterator.e(err);
218
+ } finally {
219
+ _iterator.f();
220
+ }
221
+ return {
222
+ area: area,
223
+ baselineWidths: baselineWidths,
224
+ overlayModes: mode === 'overlay' ? overlayModes : undefined
225
+ };
226
+ }, []);
227
+ var startResize = (0, _react.useCallback)(function (area, mode) {
228
+ setHasInteraction(true);
229
+ setResizeSession(captureSiblingWidths(area, mode));
230
+
231
+ // Start from the effective width, which may already be compressed below the preferred width.
232
+ // Reapplying the preferred width here would move the splitter away from the pointer.
233
+ var renderedState = areaStatesRef.current[area];
234
+ if ((renderedState === null || renderedState === void 0 ? void 0 : renderedState.mode) === mode) {
235
+ setAreas(function (current) {
236
+ var existing = current[area];
237
+ return existing ? _objectSpread(_objectSpread({}, current), {}, (0, _defineProperty2.default)({}, area, _objectSpread(_objectSpread({}, existing), {}, {
238
+ liveResize: {
239
+ mode: mode,
240
+ width: renderedState.width
241
+ }
242
+ }))) : current;
243
+ });
244
+ }
245
+ }, [captureSiblingWidths]);
246
+ var resize = (0, _react.useCallback)(function (area, mode, width) {
247
+ setAreas(function (current) {
248
+ var _existing$liveResize;
249
+ var existing = current[area];
250
+ if ((existing === null || existing === void 0 || (_existing$liveResize = existing.liveResize) === null || _existing$liveResize === void 0 ? void 0 : _existing$liveResize.mode) === mode && existing.liveResize.width === width) {
251
+ return current;
252
+ }
253
+ return existing ? _objectSpread(_objectSpread({}, current), {}, (0, _defineProperty2.default)({}, area, _objectSpread(_objectSpread({}, existing), {}, {
254
+ liveResize: {
255
+ mode: mode,
256
+ width: width
257
+ }
258
+ }))) : current;
259
+ });
260
+ }, []);
261
+ var completeResize = (0, _react.useCallback)(function (area, mode, width) {
262
+ setHasInteraction(true);
263
+ if (mode === 'overlay') {
264
+ var session = inputsRef.current.resizeSession;
265
+ setResizeSession(_objectSpread(_objectSpread({}, (session === null || session === void 0 ? void 0 : session.area) === area && session.overlayModes ? session : captureSiblingWidths(area, mode)), {}, {
266
+ completedWidth: width
267
+ }));
268
+ }
269
+ if (mode === 'inline') {
270
+ var _inputs$resizeSession, _inputs$areas$area;
271
+ var inputs = inputsRef.current;
272
+ var _session = ((_inputs$resizeSession = inputs.resizeSession) === null || _inputs$resizeSession === void 0 ? void 0 : _inputs$resizeSession.area) === area && (_inputs$areas$area = inputs.areas[area]) !== null && _inputs$areas$area !== void 0 && _inputs$areas$area.liveResize ? inputs.resizeSession : captureSiblingWidths(area);
273
+ var existing = inputs.areas[area];
274
+ if (inputs.dimensions && existing) {
275
+ // Keyboard completion has no preview; calculate it using the accepted
276
+ // request, not the parent's previous controlled width. Pointer completion
277
+ // keeps below-minimum cascade results even though its payload is clamped.
278
+ var completed = existing.liveResize ? areaStatesRef.current : (0, _calculateLayoutAreaStates.calculateLayoutAreaStates)(_objectSpread(_objectSpread({}, inputs.dimensions), {}, {
279
+ occupiedWidth: inputs.occupiedWidth,
280
+ mainMinWidth: inputs.mainMinWidth,
281
+ areas: _objectSpread(_objectSpread({}, inputs.areas), {}, (0, _defineProperty2.default)({}, area, _objectSpread(_objectSpread({}, existing), {}, {
282
+ liveResize: {
283
+ mode: mode,
284
+ width: width
285
+ }
286
+ }))),
287
+ resizeSession: _session
288
+ }));
289
+ var completedWidths = {};
290
+ var _iterator2 = _createForOfIteratorHelper(['side-nav', 'panel', 'chat-panel']),
291
+ _step2;
292
+ try {
293
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
294
+ var _completed$name;
295
+ var name = _step2.value;
296
+ if (((_completed$name = completed[name]) === null || _completed$name === void 0 ? void 0 : _completed$name.mode) === 'inline') {
297
+ completedWidths[name] = completed[name].width;
298
+ }
299
+ }
300
+ } catch (err) {
301
+ _iterator2.e(err);
302
+ } finally {
303
+ _iterator2.f();
304
+ }
305
+ setResizeSession(_objectSpread(_objectSpread({}, _session), {}, {
306
+ completedWidth: width,
307
+ completedWidths: completedWidths
308
+ }));
309
+ }
310
+ }
311
+ setAreas(function (current) {
312
+ var existing = current[area];
313
+ if (!existing) {
314
+ return current;
315
+ }
316
+ if (mode === 'overlay') {
317
+ return _objectSpread(_objectSpread({}, current), {}, (0, _defineProperty2.default)({}, area, _objectSpread(_objectSpread({}, existing), {}, {
318
+ liveResize: undefined,
319
+ preferredOverlayWidth: width
320
+ })));
321
+ }
322
+ return _objectSpread(_objectSpread({}, current), {}, (0, _defineProperty2.default)({}, area, _objectSpread(_objectSpread({}, existing), {}, {
323
+ liveResize: undefined,
324
+ preferredInlineWidth: width
325
+ })));
326
+ });
327
+ }, [captureSiblingWidths]);
328
+ (0, _react.useEffect)(function () {
329
+ // Loading the interaction engine is not a layout event. Adopt the CSS layout
330
+ // without changing widths or modes; subsequent changes to configuration or
331
+ // available space may redistribute it. Content stays mounted during the handoff.
332
+ var root = layoutRef === null || layoutRef === void 0 ? void 0 : layoutRef.current;
333
+ if (onUpdate && root && dimensions && isPreservingInitialLayout) {
334
+ var measured = {};
335
+ var selectors = {
336
+ 'side-nav': ':scope > nav[data-layout-slot]',
337
+ panel: '[data-layout-with-panel-slot]',
338
+ 'chat-panel': ':scope > [data-layout-chat-panel]'
339
+ };
340
+ var _iterator3 = _createForOfIteratorHelper(['side-nav', 'panel', 'chat-panel']),
341
+ _step3;
342
+ try {
343
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
344
+ var name = _step3.value;
345
+ var element = root.querySelector(selectors[name]);
346
+ var config = areas[name];
347
+ if (!element || !(config !== null && config !== void 0 && config.isOpen)) {
348
+ continue;
349
+ }
350
+ var style = getComputedStyle(element);
351
+ var mode = style.gridArea.split('/')[0].trim() === name ? 'inline' : 'overlay';
352
+ measured[name] = {
353
+ mode: mode,
354
+ width: element.getBoundingClientRect().width,
355
+ minWidth: (0, _resolveLayoutWidth.resolveLayoutWidth)(config.minWidth, dimensions.viewportWidth)
356
+ };
357
+ }
358
+ } catch (err) {
359
+ _iterator3.e(err);
360
+ } finally {
361
+ _iterator3.f();
362
+ }
363
+ setInitialStates(measured);
364
+ }
365
+ }, [areas, dimensions, isPreservingInitialLayout, layoutRef, onUpdate]);
366
+ var areaStates = (0, _react.useMemo)(function () {
367
+ var _initialStates$sideN, _initialStates$panel, _initialStates$chatP;
368
+ if (!dimensions) {
369
+ return {};
370
+ }
371
+ var allocated = (0, _calculateLayoutAreaStates.calculateLayoutAreaStates)(_objectSpread(_objectSpread({}, dimensions), {}, {
372
+ occupiedWidth: occupiedWidth,
373
+ mainMinWidth: mainMinWidth,
374
+ areas: areas,
375
+ resizeSession: resizeSession,
376
+ initialModes: onUpdate && layoutRef !== null && layoutRef !== void 0 && layoutRef.current && isPreservingInitialLayout ? {
377
+ 'side-nav': (_initialStates$sideN = initialStates['side-nav']) === null || _initialStates$sideN === void 0 ? void 0 : _initialStates$sideN.mode,
378
+ panel: (_initialStates$panel = initialStates.panel) === null || _initialStates$panel === void 0 ? void 0 : _initialStates$panel.mode,
379
+ 'chat-panel': (_initialStates$chatP = initialStates['chat-panel']) === null || _initialStates$chatP === void 0 ? void 0 : _initialStates$chatP.mode
380
+ } : undefined
381
+ }));
382
+ if (onUpdate && layoutRef !== null && layoutRef !== void 0 && layoutRef.current && isPreservingInitialLayout) {
383
+ var _iterator4 = _createForOfIteratorHelper(['side-nav', 'panel', 'chat-panel']),
384
+ _step4;
385
+ try {
386
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
387
+ var name = _step4.value;
388
+ if (initialStates[name] && allocated[name]) {
389
+ allocated[name] = _objectSpread(_objectSpread({}, allocated[name]), initialStates[name]);
390
+ } else {
391
+ delete allocated[name];
392
+ }
393
+ }
394
+ } catch (err) {
395
+ _iterator4.e(err);
396
+ } finally {
397
+ _iterator4.f();
398
+ }
399
+ }
400
+ return allocated;
401
+ }, [areas, mainMinWidth, resizeSession, dimensions, occupiedWidth, isPreservingInitialLayout, initialStates, layoutRef, onUpdate]);
402
+ (0, _react.useEffect)(function () {
403
+ var _areas$sideNav;
404
+ if (hasInteraction && (resizeSession === null || resizeSession === void 0 ? void 0 : resizeSession.area) !== 'side-nav' && (_areas$sideNav = areas['side-nav']) !== null && _areas$sideNav !== void 0 && _areas$sideNav.isOpen && !areaStates['side-nav'] && dimensions) {
405
+ var _areas$sideNav$onReq, _areas$sideNav2;
406
+ (_areas$sideNav$onReq = (_areas$sideNav2 = areas['side-nav']).onRequestClose) === null || _areas$sideNav$onReq === void 0 || _areas$sideNav$onReq.call(_areas$sideNav2);
407
+ }
408
+ }, [areaStates, areas, dimensions, hasInteraction, resizeSession]);
409
+ (0, _react.useEffect)(function () {
410
+ areaStatesRef.current = areaStates;
411
+ }, [areaStates]);
412
+
413
+ // Read bounds lazily: changing a sibling's capacity must not publish new render
414
+ // state or recreate drag listeners for a region whose own width did not change.
415
+ var getResizeBounds = (0, _react.useCallback)(function (area) {
416
+ var _areaStatesRef$curren;
417
+ var bounds = (_areaStatesRef$curren = areaStatesRef.current[area]) === null || _areaStatesRef$curren === void 0 ? void 0 : _areaStatesRef$curren.resizeBounds;
418
+ return bounds ? {
419
+ min: "".concat(bounds.min, "px"),
420
+ max: "".concat(bounds.max, "px")
421
+ } : undefined;
422
+ }, []);
423
+ var value = (0, _react.useMemo)(function () {
424
+ return {
425
+ getResizeBounds: getResizeBounds,
426
+ registerArea: registerArea,
427
+ unregisterArea: unregisterArea,
428
+ startResize: startResize,
429
+ resize: resize,
430
+ completeResize: completeResize,
431
+ setMainMinWidth: setMainMinWidth
432
+ };
433
+ }, [completeResize, getResizeBounds, registerArea, resize, startResize, unregisterArea]);
434
+ var sideNavState = useStableAreaState(areaStates['side-nav']);
435
+ var panelState = useStableAreaState(areaStates.panel);
436
+ var chatPanelState = useStableAreaState(areaStates['chat-panel']);
437
+ var SideNavStateProvider = _layoutAreaStateContexts.layoutAreaStateContexts['side-nav'].Provider;
438
+ var PanelStateProvider = _layoutAreaStateContexts.layoutAreaStateContexts.panel.Provider;
439
+ var ChatPanelStateProvider = _layoutAreaStateContexts.layoutAreaStateContexts['chat-panel'].Provider;
440
+ (0, _react.useEffect)(function () {
441
+ onReady === null || onReady === void 0 || onReady(value);
442
+ return function () {
443
+ return onReady === null || onReady === void 0 ? void 0 : onReady(null);
444
+ };
445
+ }, [onReady, value]);
446
+ (0, _react.useEffect)(function () {
447
+ if (!adoptedConstraints.current && (sideNavState || panelState || chatPanelState)) {
448
+ adoptedConstraints.current = {
449
+ occupiedWidth: occupiedWidth,
450
+ mainMinWidth: mainMinWidth
451
+ };
452
+ }
453
+ onUpdate === null || onUpdate === void 0 || onUpdate({
454
+ 'side-nav': sideNavState,
455
+ panel: panelState,
456
+ 'chat-panel': chatPanelState
457
+ });
458
+ }, [onUpdate, sideNavState, panelState, chatPanelState, occupiedWidth, mainMinWidth]);
459
+ return /*#__PURE__*/_react.default.createElement(_layoutAreaSizingContext.LayoutAreaSizingContext.Provider, {
460
+ value: value
461
+ }, /*#__PURE__*/_react.default.createElement(SideNavStateProvider, {
462
+ value: sideNavState
463
+ }, /*#__PURE__*/_react.default.createElement(PanelStateProvider, {
464
+ value: panelState
465
+ }, /*#__PURE__*/_react.default.createElement(ChatPanelStateProvider, {
466
+ value: chatPanelState
467
+ }, children))));
468
+ }
@@ -43,7 +43,7 @@ function Main(_ref) {
43
43
  return /*#__PURE__*/React.createElement(_react.Fragment, null, (0, _fg.fg)('platform-dst-chat-panel-layout') &&
44
44
  /*#__PURE__*/
45
45
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
46
- React.createElement("style", null, "#".concat(_root.gridRootId, " { ").concat(_constants.mainMinimumWidthVar, ": ").concat(minWidth, "px; }")), /*#__PURE__*/React.createElement("div", {
46
+ React.createElement("style", null, "#".concat(_root.gridRootId, ", #").concat(_root.gridRootFitId, " { ").concat(_constants.mainMinimumWidthVar, ": ").concat(minWidth, "px; }")), /*#__PURE__*/React.createElement("div", {
47
47
  id: id,
48
48
  "data-layout-slot": true,
49
49
  className: (0, _runtime.ax)([mainElementStyles.root, xcss]),