@reltio/components 1.4.1909 → 1.4.1911
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/cjs/ProfileBand/ProfileBand.js +1 -1
- package/cjs/ProfileResizablePanes/ProfileResizablePanes.spec.js +113 -68
- package/cjs/ResizablePanes/ResizablePanes.d.ts +3 -2
- package/cjs/ResizablePanes/ResizablePanes.js +83 -16
- package/cjs/ResizablePanes/ResizablePanes.test.js +289 -0
- package/cjs/ResizablePanes/styles.d.ts +1 -1
- package/cjs/ResizablePanes/styles.js +47 -38
- package/cjs/SimpleMatchRulesBlock/SimpleMatchRulesBlock.js +1 -1
- package/cjs/SimpleMatchRulesBlock/SimpleMatchRulesBlock.test.js +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +2 -1
- package/cjs/test-utils/index.d.ts +1 -0
- package/cjs/test-utils/index.js +15 -1
- package/esm/ProfileBand/ProfileBand.js +1 -1
- package/esm/ProfileResizablePanes/ProfileResizablePanes.spec.js +113 -68
- package/esm/ResizablePanes/ResizablePanes.d.ts +3 -2
- package/esm/ResizablePanes/ResizablePanes.js +84 -17
- package/esm/ResizablePanes/ResizablePanes.test.js +284 -0
- package/esm/ResizablePanes/styles.d.ts +1 -1
- package/esm/ResizablePanes/styles.js +47 -38
- package/esm/SimpleMatchRulesBlock/SimpleMatchRulesBlock.js +1 -1
- package/esm/SimpleMatchRulesBlock/SimpleMatchRulesBlock.test.js +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/test-utils/index.d.ts +1 -0
- package/esm/test-utils/index.js +13 -0
- package/package.json +3 -3
- package/cjs/ResizablePanes/ResizablePanes.spec.js +0 -192
- package/esm/ResizablePanes/ResizablePanes.spec.js +0 -164
- /package/cjs/ResizablePanes/{ResizablePanes.spec.d.ts → ResizablePanes.test.d.ts} +0 -0
- /package/esm/ResizablePanes/{ResizablePanes.spec.d.ts → ResizablePanes.test.d.ts} +0 -0
|
@@ -56,7 +56,7 @@ var ProfileBand = function (_a) {
|
|
|
56
56
|
var isActive = (0, mdm_sdk_1.isActiveObject)(entity);
|
|
57
57
|
var entityUri = entity.uri;
|
|
58
58
|
var entityId = (0, mdm_sdk_1.getEntityId)(entity);
|
|
59
|
-
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.profileBandWrapper, className) },
|
|
59
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.profileBandWrapper, className), "data-reltio-id": 'reltio-profile-band' },
|
|
60
60
|
react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.profileBand, (_b = {},
|
|
61
61
|
_b[styles.inactive] = !isActive,
|
|
62
62
|
_b)), "data-entity-uri": entityUri },
|
|
@@ -99,11 +99,28 @@ var setUp = function (props) {
|
|
|
99
99
|
react_1.default.createElement(PaneStub, { key: 0, id: "content" }),
|
|
100
100
|
react_1.default.createElement(PaneStub, { key: 1, id: "rightPanel" })), { wrapper: Providers })), { user: user });
|
|
101
101
|
};
|
|
102
|
-
var getSplitPane1 = function (container) { return container.
|
|
103
|
-
var getSplitPane2 = function (container) { return container.
|
|
104
|
-
var getSplitPanesResizer = function (container) { return container.
|
|
105
|
-
var isResizingDisabled = function (container) {
|
|
102
|
+
var getSplitPane1 = function (container) { return container.querySelectorAll('[data-panel-id]')[0]; };
|
|
103
|
+
var getSplitPane2 = function (container) { return container.querySelectorAll('[data-panel-id]')[1]; };
|
|
104
|
+
var getSplitPanesResizer = function (container) { return container.querySelector('[data-resize-handle]'); };
|
|
105
|
+
var isResizingDisabled = function (container) {
|
|
106
|
+
return getSplitPanesResizer(container).getAttribute('data-panel-resize-handle-enabled') === 'false';
|
|
107
|
+
};
|
|
108
|
+
var checkPanelSize = function (panel, size) { return expect(panel.getAttribute('data-panel-size')).toBe(size); };
|
|
106
109
|
describe('ProfileResizablePanes tests', function () {
|
|
110
|
+
beforeAll(function () {
|
|
111
|
+
jest.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(1000);
|
|
112
|
+
jest.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
|
|
113
|
+
width: 1000,
|
|
114
|
+
height: 1000,
|
|
115
|
+
top: 0,
|
|
116
|
+
left: 0,
|
|
117
|
+
right: 1000,
|
|
118
|
+
bottom: 1000,
|
|
119
|
+
x: 0,
|
|
120
|
+
y: 0,
|
|
121
|
+
toJSON: function () { return ''; }
|
|
122
|
+
});
|
|
123
|
+
});
|
|
107
124
|
it('should render resizable panes with closed second pane (active is undefined)', function () {
|
|
108
125
|
var container = setUp().container;
|
|
109
126
|
expect(react_2.screen.getByTestId('content')).toBeInTheDocument();
|
|
@@ -111,10 +128,11 @@ describe('ProfileResizablePanes tests', function () {
|
|
|
111
128
|
expect(getSplitPane1(container)).toBeInTheDocument();
|
|
112
129
|
expect(getSplitPane2(container)).toBeInTheDocument();
|
|
113
130
|
expect(isResizingDisabled(container)).toBe(true);
|
|
114
|
-
|
|
131
|
+
checkPanelSize(getSplitPane1(container), '100.0');
|
|
132
|
+
checkPanelSize(getSplitPane2(container), '0.0');
|
|
115
133
|
expect(react_2.screen.getByRole('button', { name: 'Button 1' })).toBeInTheDocument();
|
|
116
134
|
expect(react_2.screen.getByRole('button', { name: 'Button 2' })).toBeInTheDocument();
|
|
117
|
-
expect(react_2.screen.getByRole('
|
|
135
|
+
expect(react_2.screen.getByRole('separator')).toBeInTheDocument();
|
|
118
136
|
});
|
|
119
137
|
it('should render resizable panes with open second pane', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
138
|
var _a, container, user, button2;
|
|
@@ -127,7 +145,8 @@ describe('ProfileResizablePanes tests', function () {
|
|
|
127
145
|
expect(getSplitPane1(container)).toBeInTheDocument();
|
|
128
146
|
expect(getSplitPane2(container)).toBeInTheDocument();
|
|
129
147
|
expect(isResizingDisabled(container)).toBe(true);
|
|
130
|
-
|
|
148
|
+
checkPanelSize(getSplitPane1(container), '100.0');
|
|
149
|
+
checkPanelSize(getSplitPane2(container), '0.0');
|
|
131
150
|
expect(react_2.screen.getByRole('button', { name: 'Button 1' })).toBeInTheDocument();
|
|
132
151
|
expect(react_2.screen.getByRole('button', { name: 'Button 2' })).toBeInTheDocument();
|
|
133
152
|
button2 = react_2.screen.getByRole('button', { name: 'Button 2' });
|
|
@@ -135,7 +154,8 @@ describe('ProfileResizablePanes tests', function () {
|
|
|
135
154
|
case 1:
|
|
136
155
|
_b.sent();
|
|
137
156
|
expect(isResizingDisabled(container)).toBe(false);
|
|
138
|
-
|
|
157
|
+
checkPanelSize(getSplitPane1(container), '52.0');
|
|
158
|
+
checkPanelSize(getSplitPane2(container), '48.0');
|
|
139
159
|
expect(react_2.screen.getByRole('button', { name: 'Button 1' })).toBeInTheDocument();
|
|
140
160
|
expect(react_2.screen.getByTestId('reltio-profile-right-side-button-2')).toBeInTheDocument();
|
|
141
161
|
return [2 /*return*/];
|
|
@@ -146,11 +166,11 @@ describe('ProfileResizablePanes tests', function () {
|
|
|
146
166
|
var container;
|
|
147
167
|
return __generator(this, function (_a) {
|
|
148
168
|
container = setUp(__assign(__assign({}, defaultProps), { disabled: true })).container;
|
|
149
|
-
|
|
169
|
+
checkPanelSize(getSplitPane2(container), '0.0');
|
|
150
170
|
expect(react_2.screen.getByRole('button', { name: 'Button 1' })).toBeInTheDocument();
|
|
151
171
|
expect(react_2.screen.getByRole('button', { name: 'Button 2' })).toBeInTheDocument();
|
|
152
172
|
expect(isResizingDisabled(container)).toBe(true);
|
|
153
|
-
|
|
173
|
+
checkPanelSize(getSplitPane2(container), '0.0');
|
|
154
174
|
expect(react_2.screen.getByRole('button', { name: 'Button 1' }).hasAttribute('disabled')).toBe(true);
|
|
155
175
|
expect(react_2.screen.getByRole('button', { name: 'Button 2' }).hasAttribute('disabled')).toBe(true);
|
|
156
176
|
return [2 /*return*/];
|
|
@@ -163,80 +183,105 @@ describe('ProfileResizablePanes tests', function () {
|
|
|
163
183
|
case 0:
|
|
164
184
|
_a = setUp(__assign(__assign({}, defaultProps), { perspectiveId: 'graph' })), container = _a.container, user = _a.user;
|
|
165
185
|
expect(isResizingDisabled(container)).toBe(false);
|
|
166
|
-
|
|
186
|
+
checkPanelSize(getSplitPane1(container), '68.0');
|
|
187
|
+
checkPanelSize(getSplitPane2(container), '32.0');
|
|
167
188
|
expect(react_2.screen.getByRole('button', { name: 'Button 1' })).toBeInTheDocument();
|
|
168
189
|
expect(react_2.screen.getByRole('button', { name: 'Button 2' })).toBeInTheDocument();
|
|
169
|
-
Divider = react_2.screen.getByRole('
|
|
190
|
+
Divider = react_2.screen.getByRole('separator');
|
|
170
191
|
expect(Divider).toBeInTheDocument();
|
|
171
192
|
// move mouse to an x-coordinate between MIN_R_PANE_SIZE and MAX_R_PANE_SIZE
|
|
172
|
-
return [4 /*yield*/, user.pointer(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
193
|
+
return [4 /*yield*/, user.pointer([
|
|
194
|
+
{
|
|
195
|
+
keys: '[MouseLeft>]',
|
|
196
|
+
target: Divider,
|
|
197
|
+
coords: {
|
|
198
|
+
x: 680,
|
|
199
|
+
y: 0
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
target: Divider,
|
|
204
|
+
coords: {
|
|
205
|
+
x: 500,
|
|
206
|
+
y: 20
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
keys: '[/MouseLeft]',
|
|
211
|
+
target: Divider,
|
|
212
|
+
coords: {
|
|
213
|
+
x: 500,
|
|
214
|
+
y: 20
|
|
215
|
+
}
|
|
178
216
|
}
|
|
179
|
-
|
|
217
|
+
])];
|
|
180
218
|
case 1:
|
|
181
219
|
// move mouse to an x-coordinate between MIN_R_PANE_SIZE and MAX_R_PANE_SIZE
|
|
182
220
|
_b.sent();
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
target: Divider,
|
|
186
|
-
coords: {
|
|
187
|
-
x: -500,
|
|
188
|
-
y: 20
|
|
189
|
-
}
|
|
190
|
-
})];
|
|
191
|
-
case 2:
|
|
192
|
-
_b.sent();
|
|
193
|
-
expect(getSplitPane2(container).style.width).toBe('500px');
|
|
221
|
+
checkPanelSize(getSplitPane1(container), '50.0');
|
|
222
|
+
checkPanelSize(getSplitPane2(container), '50.0');
|
|
194
223
|
// move mouse to a larger x-coordinate than MAX_R_PANE_SIZE
|
|
195
|
-
return [4 /*yield*/, user.pointer(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
224
|
+
return [4 /*yield*/, user.pointer([
|
|
225
|
+
{
|
|
226
|
+
keys: '[MouseLeft>]',
|
|
227
|
+
target: Divider,
|
|
228
|
+
coords: {
|
|
229
|
+
x: 500,
|
|
230
|
+
y: 0
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
target: Divider,
|
|
235
|
+
coords: {
|
|
236
|
+
x: 300,
|
|
237
|
+
y: 20
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
keys: '[/MouseLeft]',
|
|
242
|
+
target: Divider,
|
|
243
|
+
coords: {
|
|
244
|
+
x: 300,
|
|
245
|
+
y: 20
|
|
246
|
+
}
|
|
201
247
|
}
|
|
202
|
-
|
|
203
|
-
case
|
|
248
|
+
])];
|
|
249
|
+
case 2:
|
|
204
250
|
// move mouse to a larger x-coordinate than MAX_R_PANE_SIZE
|
|
205
251
|
_b.sent();
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
target: Divider,
|
|
209
|
-
coords: {
|
|
210
|
-
x: -650,
|
|
211
|
-
y: 0
|
|
212
|
-
}
|
|
213
|
-
})];
|
|
214
|
-
case 4:
|
|
215
|
-
_b.sent();
|
|
216
|
-
expect(getSplitPane2(container).style.width).toBe('640px');
|
|
252
|
+
checkPanelSize(getSplitPane1(container), '36.0');
|
|
253
|
+
checkPanelSize(getSplitPane2(container), '64.0');
|
|
217
254
|
// move mouse to a smaller x-coordinate than MIN_R_PANE_SIZE
|
|
218
|
-
return [4 /*yield*/, user.pointer(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
255
|
+
return [4 /*yield*/, user.pointer([
|
|
256
|
+
{
|
|
257
|
+
keys: '[MouseLeft>]',
|
|
258
|
+
target: Divider,
|
|
259
|
+
coords: {
|
|
260
|
+
x: 360,
|
|
261
|
+
y: 0
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
target: Divider,
|
|
266
|
+
coords: {
|
|
267
|
+
x: 690,
|
|
268
|
+
y: 20
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
keys: '[/MouseLeft]',
|
|
273
|
+
target: Divider,
|
|
274
|
+
coords: {
|
|
275
|
+
x: 690,
|
|
276
|
+
y: 20
|
|
277
|
+
}
|
|
224
278
|
}
|
|
225
|
-
|
|
226
|
-
case
|
|
279
|
+
])];
|
|
280
|
+
case 3:
|
|
227
281
|
// move mouse to a smaller x-coordinate than MIN_R_PANE_SIZE
|
|
228
282
|
_b.sent();
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
target: Divider,
|
|
232
|
-
coords: {
|
|
233
|
-
x: -310,
|
|
234
|
-
y: 0
|
|
235
|
-
}
|
|
236
|
-
})];
|
|
237
|
-
case 6:
|
|
238
|
-
_b.sent();
|
|
239
|
-
expect(getSplitPane2(container).style.width).toBe('320px');
|
|
283
|
+
checkPanelSize(getSplitPane1(container), '68.0');
|
|
284
|
+
checkPanelSize(getSplitPane2(container), '32.0');
|
|
240
285
|
return [2 /*return*/];
|
|
241
286
|
}
|
|
242
287
|
});
|
|
@@ -12,15 +12,16 @@ type Props = {
|
|
|
12
12
|
allowResize?: boolean;
|
|
13
13
|
primary?: 'first' | 'second';
|
|
14
14
|
minSize?: Size;
|
|
15
|
+
/** if you set the maxSize to negative value (e.g. -200), then the splitter stops 200px before the border (in other words it sets the minimal size of the 'resizable' pane in this case) */
|
|
15
16
|
maxSize?: Size;
|
|
16
|
-
defaultSize?: Size;
|
|
17
17
|
debounceInterval?: number;
|
|
18
|
+
/** Can be a positive or negative number (e.g., 250, -250), a percentage string (e.g., "50%"), or a string with pixels (e.g., "50px") */
|
|
18
19
|
size?: Size;
|
|
19
20
|
orientation?: 'vertical' | 'horizontal';
|
|
20
21
|
onChange?: ({ size, percentageSize, isMaxSize, isMinSize }: OnChange) => void;
|
|
21
22
|
};
|
|
22
23
|
export declare const ResizablePanes: {
|
|
23
|
-
({ className, children, orientation, primary,
|
|
24
|
+
({ className, children, orientation, primary, size, minSize, maxSize, allowResize, debounceInterval, onChange }: Props): JSX.Element;
|
|
24
25
|
displayName: string;
|
|
25
26
|
};
|
|
26
27
|
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -29,41 +40,97 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
40
|
exports.ResizablePanes = void 0;
|
|
30
41
|
var react_1 = __importStar(require("react"));
|
|
31
42
|
var classnames_1 = __importDefault(require("classnames"));
|
|
32
|
-
var
|
|
43
|
+
var react_resizable_panels_1 = require("react-resizable-panels");
|
|
33
44
|
var styles_1 = require("@mui/material/styles");
|
|
45
|
+
var react_resize_detector_1 = __importDefault(require("react-resize-detector"));
|
|
34
46
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
35
47
|
var styles_2 = require("./styles");
|
|
36
48
|
var HANDLE_CHANGE_DEBOUNCE_INTERVAL = 250;
|
|
37
49
|
var isHorizontal = function (orientation) { return orientation === 'horizontal'; };
|
|
50
|
+
var isEqualSize = function (a, b) { return a.toFixed(2) === b.toFixed(2); };
|
|
38
51
|
var ResizablePanes = function (_a) {
|
|
39
|
-
var
|
|
52
|
+
var _b;
|
|
53
|
+
var className = _a.className, children = _a.children, _c = _a.orientation, orientation = _c === void 0 ? 'vertical' : _c, _d = _a.primary, primary = _d === void 0 ? 'first' : _d, size = _a.size, minSize = _a.minSize, maxSize = _a.maxSize, allowResize = _a.allowResize, _e = _a.debounceInterval, debounceInterval = _e === void 0 ? HANDLE_CHANGE_DEBOUNCE_INTERVAL : _e, onChange = _a.onChange;
|
|
40
54
|
var styles = (0, styles_2.useStyles)();
|
|
41
55
|
var theme = (0, styles_1.useTheme)();
|
|
42
|
-
var
|
|
43
|
-
var
|
|
56
|
+
var panelRef = (0, react_1.useRef)();
|
|
57
|
+
var _f = (0, react_1.useState)(null), containerEl = _f[0], setContainerEl = _f[1];
|
|
58
|
+
var _g = (0, react_1.useState)(0), percentageMinSize = _g[0], setPercentageMinSize = _g[1];
|
|
59
|
+
var _h = (0, react_1.useState)(0), percentageMaxSize = _h[0], setPercentageMaxSize = _h[1];
|
|
60
|
+
var _j = (0, react_1.useState)(true), isPaneAnimationEnabled = _j[0], setIsPaneAnimationEnabled = _j[1];
|
|
44
61
|
var enableAnimation = (0, react_1.useCallback)(function () { return setIsPaneAnimationEnabled(true); }, []);
|
|
45
62
|
var disableAnimation = (0, react_1.useCallback)(function () { return setIsPaneAnimationEnabled(false); }, []);
|
|
46
|
-
var getContainerSize = function () { return (isHorizontal(orientation) ? containerEl === null || containerEl === void 0 ? void 0 : containerEl.clientHeight : containerEl === null || containerEl === void 0 ? void 0 : containerEl.clientWidth); };
|
|
63
|
+
var getContainerSize = (0, react_1.useCallback)(function () { return (isHorizontal(orientation) ? containerEl === null || containerEl === void 0 ? void 0 : containerEl.clientHeight : containerEl === null || containerEl === void 0 ? void 0 : containerEl.clientWidth); }, [containerEl, orientation]);
|
|
64
|
+
if (typeof size === 'number' && size < 0) {
|
|
65
|
+
size = (getContainerSize() || 0) + size;
|
|
66
|
+
}
|
|
67
|
+
var convertSize = (0, react_1.useCallback)(function (size) {
|
|
68
|
+
if (typeof size === 'string' && size.endsWith('%')) {
|
|
69
|
+
return +size.replace('%', '');
|
|
70
|
+
}
|
|
71
|
+
if (typeof size === 'string' && size.endsWith('px')) {
|
|
72
|
+
size = size.replace('px', '');
|
|
73
|
+
}
|
|
74
|
+
return isNaN(+size) ? null : (+size / getContainerSize()) * 100;
|
|
75
|
+
}, [getContainerSize]);
|
|
76
|
+
var convertMinMaxSize = (0, react_1.useCallback)(function (size, minMaxSize) {
|
|
77
|
+
if (size === 0 || size === 100)
|
|
78
|
+
return 0;
|
|
79
|
+
return convertSize(minMaxSize) || 0;
|
|
80
|
+
}, [convertSize]);
|
|
81
|
+
var actualizeSizes = (0, react_1.useCallback)(function () {
|
|
82
|
+
if (containerEl && panelRef.current) {
|
|
83
|
+
var convertedSize = convertSize(size);
|
|
84
|
+
if (convertedSize != null && !isNaN(convertedSize)) {
|
|
85
|
+
setPercentageMaxSize(convertMinMaxSize(convertedSize, maxSize));
|
|
86
|
+
setPercentageMinSize(convertMinMaxSize(convertedSize, minSize));
|
|
87
|
+
panelRef.current.resize(convertedSize);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, [convertSize, convertMinMaxSize, minSize, maxSize, size, containerEl]);
|
|
91
|
+
(0, react_1.useEffect)(function () {
|
|
92
|
+
actualizeSizes();
|
|
93
|
+
}, [actualizeSizes, percentageMaxSize, percentageMinSize]);
|
|
47
94
|
var handleChange = (0, react_1.useCallback)((0, mdm_sdk_1.debounce)(function (size) {
|
|
95
|
+
if (size === undefined)
|
|
96
|
+
return;
|
|
48
97
|
var containerSize = getContainerSize();
|
|
49
98
|
onChange({
|
|
50
|
-
percentageSize:
|
|
51
|
-
isMaxSize: +
|
|
52
|
-
|
|
53
|
-
|
|
99
|
+
percentageSize: size + '%',
|
|
100
|
+
isMaxSize: +percentageMaxSize > 0
|
|
101
|
+
? isEqualSize(size, percentageMaxSize)
|
|
102
|
+
: isEqualSize(size, 100 + percentageMaxSize),
|
|
103
|
+
isMinSize: isEqualSize(size, percentageMinSize),
|
|
104
|
+
size: Math.round((size * containerSize) / 100)
|
|
54
105
|
});
|
|
55
|
-
}, debounceInterval), [onChange,
|
|
106
|
+
}, debounceInterval), [onChange, percentageMaxSize, percentageMinSize, getContainerSize]);
|
|
107
|
+
var handleDragging = (0, react_1.useCallback)(function (isDragging) {
|
|
108
|
+
if (isDragging) {
|
|
109
|
+
// Why do we need handleChange() here?
|
|
110
|
+
// Case - user resized panels, and then immediately started resizing again.
|
|
111
|
+
// We need to prevent onChange calling with "previous" data (handleChange is debounced calling of onChange)
|
|
112
|
+
handleChange();
|
|
113
|
+
disableAnimation();
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
handleChange(panelRef.current.getSize());
|
|
117
|
+
enableAnimation();
|
|
118
|
+
}
|
|
119
|
+
}, [disableAnimation, enableAnimation, handleChange]);
|
|
56
120
|
var paneAnimationStyle = (0, react_1.useMemo)(function () { return ({
|
|
57
|
-
transition: theme.transitions.create(
|
|
121
|
+
transition: theme.transitions.create('flex', {
|
|
58
122
|
easing: theme.transitions.easing.sharp,
|
|
59
123
|
duration: theme.transitions.duration.leavingScreen
|
|
60
124
|
})
|
|
61
|
-
}); }, [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
125
|
+
}); }, [theme]);
|
|
126
|
+
var primaryPanelProps = __assign(__assign({ className: styles.panel, minSize: percentageMinSize }, (percentageMaxSize > 0 ? { maxSize: percentageMaxSize } : {})), { ref: panelRef, style: isPaneAnimationEnabled ? paneAnimationStyle : undefined });
|
|
127
|
+
var secondaryPanelProps = __assign({ className: styles.panel, style: isPaneAnimationEnabled ? paneAnimationStyle : undefined }, (percentageMaxSize < 0 ? { minSize: -percentageMaxSize } : {}));
|
|
65
128
|
return (react_1.default.createElement("div", { ref: setContainerEl, className: (0, classnames_1.default)(styles.container, className) },
|
|
66
|
-
react_1.default.createElement(
|
|
129
|
+
react_1.default.createElement(react_resize_detector_1.default, { handleHeight: isHorizontal(orientation), handleWidth: !isHorizontal(orientation), onResize: actualizeSizes, refreshMode: "debounce", refreshRate: 50 }),
|
|
130
|
+
react_1.default.createElement(react_resizable_panels_1.PanelGroup, { direction: isHorizontal(orientation) ? 'vertical' : 'horizontal' },
|
|
131
|
+
react_1.default.createElement(react_resizable_panels_1.Panel, __assign({}, (primary === 'first' ? primaryPanelProps : secondaryPanelProps)), children[0]),
|
|
132
|
+
react_1.default.createElement(react_resizable_panels_1.PanelResizeHandle, { className: (0, classnames_1.default)(styles.resizer, styles[orientation], (_b = {}, _b[styles.disabled] = !allowResize, _b)), disabled: !allowResize, hitAreaMargins: { coarse: 0, fine: 0 }, onDragging: handleDragging }),
|
|
133
|
+
react_1.default.createElement(react_resizable_panels_1.Panel, __assign({}, (primary === 'second' ? primaryPanelProps : secondaryPanelProps)), children[1]))));
|
|
67
134
|
};
|
|
68
135
|
exports.ResizablePanes = ResizablePanes;
|
|
69
136
|
exports.ResizablePanes.displayName = 'ResizablePanes';
|