@zendeskgarden/react-grid 8.50.1 → 8.53.0
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/README.md +62 -0
- package/dist/index.cjs.js +716 -30
- package/dist/index.esm.js +717 -34
- package/dist/typings/elements/pane/Pane.d.ts +18 -0
- package/dist/typings/elements/pane/PaneProvider.d.ts +23 -0
- package/dist/typings/elements/pane/components/Content.d.ts +11 -0
- package/dist/typings/elements/pane/components/Splitter.d.ts +12 -0
- package/dist/typings/elements/pane/components/SplitterButton.d.ts +12 -0
- package/dist/typings/index.d.ts +3 -1
- package/dist/typings/styled/index.d.ts +4 -0
- package/dist/typings/styled/pane/StyledPane.d.ts +10 -0
- package/dist/typings/styled/pane/StyledPaneContent.d.ts +10 -0
- package/dist/typings/styled/pane/StyledPaneSplitter.d.ts +20 -0
- package/dist/typings/styled/pane/StyledPaneSplitterButton.d.ts +19 -0
- package/dist/typings/types/index.d.ts +61 -1
- package/dist/typings/utils/usePaneContext.d.ts +17 -0
- package/dist/typings/utils/usePaneProviderContext.d.ts +29 -0
- package/dist/typings/utils/usePaneSplitterContext.d.ts +23 -0
- package/package.json +10 -4
package/dist/index.esm.js
CHANGED
|
@@ -5,11 +5,57 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React, { createContext, useContext, useMemo } from 'react';
|
|
8
|
+
import React, { createContext, useContext, useMemo, useState, useCallback, forwardRef, useEffect } from 'react';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import styled, { css } from 'styled-components';
|
|
11
|
-
import { math } from 'polished';
|
|
10
|
+
import styled, { css, ThemeContext } from 'styled-components';
|
|
11
|
+
import { math, rgba } from 'polished';
|
|
12
12
|
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
13
|
+
import { ChevronButton } from '@zendeskgarden/react-buttons';
|
|
14
|
+
import { useId, composeEventHandlers } from '@zendeskgarden/container-utilities';
|
|
15
|
+
import mergeRefs from 'react-merge-refs';
|
|
16
|
+
import { SplitterPosition, SplitterOrientation, useSplitter, SplitterType } from '@zendeskgarden/container-splitter';
|
|
17
|
+
import { Tooltip } from '@zendeskgarden/react-tooltips';
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) {
|
|
20
|
+
var keys = Object.keys(object);
|
|
21
|
+
|
|
22
|
+
if (Object.getOwnPropertySymbols) {
|
|
23
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
24
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
25
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
26
|
+
})), keys.push.apply(keys, symbols);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return keys;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _objectSpread2(target) {
|
|
33
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
34
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
35
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
36
|
+
_defineProperty(target, key, source[key]);
|
|
37
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
38
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _defineProperty(obj, key, value) {
|
|
46
|
+
if (key in obj) {
|
|
47
|
+
Object.defineProperty(obj, key, {
|
|
48
|
+
value: value,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
obj[key] = value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
|
13
59
|
|
|
14
60
|
function _extends() {
|
|
15
61
|
_extends = Object.assign || function (target) {
|
|
@@ -65,6 +111,65 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
65
111
|
return target;
|
|
66
112
|
}
|
|
67
113
|
|
|
114
|
+
function _slicedToArray(arr, i) {
|
|
115
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function _arrayWithHoles(arr) {
|
|
119
|
+
if (Array.isArray(arr)) return arr;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function _iterableToArrayLimit(arr, i) {
|
|
123
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
124
|
+
|
|
125
|
+
if (_i == null) return;
|
|
126
|
+
var _arr = [];
|
|
127
|
+
var _n = true;
|
|
128
|
+
var _d = false;
|
|
129
|
+
|
|
130
|
+
var _s, _e;
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
134
|
+
_arr.push(_s.value);
|
|
135
|
+
|
|
136
|
+
if (i && _arr.length === i) break;
|
|
137
|
+
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
_d = true;
|
|
140
|
+
_e = err;
|
|
141
|
+
} finally {
|
|
142
|
+
try {
|
|
143
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
144
|
+
} finally {
|
|
145
|
+
if (_d) throw _e;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return _arr;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
153
|
+
if (!o) return;
|
|
154
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
155
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
156
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
157
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
158
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function _arrayLikeToArray(arr, len) {
|
|
162
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
163
|
+
|
|
164
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
165
|
+
|
|
166
|
+
return arr2;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function _nonIterableRest() {
|
|
170
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
171
|
+
}
|
|
172
|
+
|
|
68
173
|
var ALIGN_ITEMS = ['start', 'end', 'center', 'baseline', 'stretch'];
|
|
69
174
|
var ALIGN_SELF = ['auto'].concat(ALIGN_ITEMS);
|
|
70
175
|
var DIRECTION = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
@@ -72,9 +177,10 @@ var JUSTIFY_CONTENT = ['start', 'end', 'center', 'between', 'around'];
|
|
|
72
177
|
var TEXT_ALIGN = ['start', 'end', 'center', 'justify'];
|
|
73
178
|
var SPACE = [false, 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
74
179
|
var WRAP = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
180
|
+
var ORIENTATION = ['top', 'bottom', 'start', 'end'];
|
|
75
181
|
|
|
76
|
-
var COMPONENT_ID$
|
|
77
|
-
var colorStyles$
|
|
182
|
+
var COMPONENT_ID$6 = 'grid.col';
|
|
183
|
+
var colorStyles$3 = function colorStyles(props) {
|
|
78
184
|
var backgroundColor = getColor('primaryHue', 600, props.theme, 0.1);
|
|
79
185
|
return css(["background-clip:content-box;background-color:", ";"], backgroundColor);
|
|
80
186
|
};
|
|
@@ -119,22 +225,22 @@ var flexStyles$1 = function flexStyles(size, alignSelf, textAlign, offset, order
|
|
|
119
225
|
var mediaStyles$1 = function mediaStyles(minWidth, size, alignSelf, textAlign, offset, order, props) {
|
|
120
226
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles$1(size, alignSelf, textAlign, offset, order, props));
|
|
121
227
|
};
|
|
122
|
-
var sizeStyles$
|
|
228
|
+
var sizeStyles$4 = function sizeStyles(props) {
|
|
123
229
|
var padding = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
124
230
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
125
231
|
};
|
|
126
232
|
var StyledCol = styled.div.attrs({
|
|
127
|
-
'data-garden-id': COMPONENT_ID$
|
|
128
|
-
'data-garden-version': '8.
|
|
233
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
234
|
+
'data-garden-version': '8.53.0'
|
|
129
235
|
}).withConfig({
|
|
130
236
|
displayName: "StyledCol",
|
|
131
237
|
componentId: "sc-inuw62-0"
|
|
132
238
|
})(["box-sizing:border-box;width:100%;", ";", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
133
239
|
return flexStyles$1(!props.sizeAll && (props.xs || props.sm || props.md || props.lg || props.xl) ? undefined : props.sizeAll || false, props.alignSelf, props.textAlign, props.offset, props.order, props);
|
|
134
240
|
}, function (props) {
|
|
135
|
-
return sizeStyles$
|
|
241
|
+
return sizeStyles$4(props);
|
|
136
242
|
}, function (props) {
|
|
137
|
-
return props.debug && colorStyles$
|
|
243
|
+
return props.debug && colorStyles$3(props);
|
|
138
244
|
}, function (props) {
|
|
139
245
|
return mediaStyles$1(props.theme.breakpoints.xs, props.xs, props.alignSelfXs, props.textAlignXs, props.offsetXs, props.orderXs, props);
|
|
140
246
|
}, function (props) {
|
|
@@ -146,45 +252,45 @@ var StyledCol = styled.div.attrs({
|
|
|
146
252
|
}, function (props) {
|
|
147
253
|
return mediaStyles$1(props.theme.breakpoints.xl, props.xl, props.alignSelfXl, props.textAlignXl, props.offsetXl, props.orderXl, props);
|
|
148
254
|
}, function (props) {
|
|
149
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
255
|
+
return retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
150
256
|
});
|
|
151
257
|
StyledCol.defaultProps = {
|
|
152
258
|
columns: 12,
|
|
153
259
|
theme: DEFAULT_THEME
|
|
154
260
|
};
|
|
155
261
|
|
|
156
|
-
var COMPONENT_ID$
|
|
157
|
-
var colorStyles$
|
|
262
|
+
var COMPONENT_ID$5 = 'grid.grid';
|
|
263
|
+
var colorStyles$2 = function colorStyles(props) {
|
|
158
264
|
var borderColor = getColor(props.theme.palette.crimson, 400, props.theme, 0.5);
|
|
159
265
|
var borderWidth = math("".concat(props.theme.borderWidths.sm, " * 2"));
|
|
160
266
|
return css(["box-shadow:-", " 0 0 0 ", ",", " 0 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
161
267
|
};
|
|
162
|
-
var sizeStyles$
|
|
268
|
+
var sizeStyles$3 = function sizeStyles(props) {
|
|
163
269
|
var padding = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
164
270
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
165
271
|
};
|
|
166
272
|
var StyledGrid = styled.div.attrs({
|
|
167
|
-
'data-garden-id': COMPONENT_ID$
|
|
168
|
-
'data-garden-version': '8.
|
|
273
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
274
|
+
'data-garden-version': '8.53.0'
|
|
169
275
|
}).withConfig({
|
|
170
276
|
displayName: "StyledGrid",
|
|
171
277
|
componentId: "sc-oxgg5i-0"
|
|
172
278
|
})(["direction:", ";margin-right:auto;margin-left:auto;width:100%;box-sizing:border-box;", ";", ";", ";"], function (props) {
|
|
173
279
|
return props.theme.rtl && 'rtl';
|
|
174
280
|
}, function (props) {
|
|
175
|
-
return sizeStyles$
|
|
281
|
+
return sizeStyles$3(props);
|
|
176
282
|
}, function (props) {
|
|
177
|
-
return props.debug && colorStyles$
|
|
283
|
+
return props.debug && colorStyles$2(props);
|
|
178
284
|
}, function (props) {
|
|
179
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
285
|
+
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
180
286
|
});
|
|
181
287
|
StyledGrid.defaultProps = {
|
|
182
288
|
gutters: 'md',
|
|
183
289
|
theme: DEFAULT_THEME
|
|
184
290
|
};
|
|
185
291
|
|
|
186
|
-
var COMPONENT_ID = 'grid.row';
|
|
187
|
-
var colorStyles = function colorStyles(props) {
|
|
292
|
+
var COMPONENT_ID$4 = 'grid.row';
|
|
293
|
+
var colorStyles$1 = function colorStyles(props) {
|
|
188
294
|
var borderColor = getColor(props.theme.palette.mint, 600, props.theme, 0.5);
|
|
189
295
|
var borderWidth = props.theme.borderWidths.sm;
|
|
190
296
|
return css(["box-shadow:inset 0 ", " 0 0 ", ",inset 0 -", " 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
@@ -209,22 +315,22 @@ var flexStyles = function flexStyles(alignItems, justifyContent, wrap) {
|
|
|
209
315
|
var mediaStyles = function mediaStyles(minWidth, alignItems, justifyContent, wrap) {
|
|
210
316
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles(alignItems, justifyContent, wrap));
|
|
211
317
|
};
|
|
212
|
-
var sizeStyles = function sizeStyles(props) {
|
|
318
|
+
var sizeStyles$2 = function sizeStyles(props) {
|
|
213
319
|
var margin = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
214
320
|
return css(["margin-right:-", ";margin-left:-", ";"], margin, margin);
|
|
215
321
|
};
|
|
216
322
|
var StyledRow = styled.div.attrs({
|
|
217
|
-
'data-garden-id': COMPONENT_ID,
|
|
218
|
-
'data-garden-version': '8.
|
|
323
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
324
|
+
'data-garden-version': '8.53.0'
|
|
219
325
|
}).withConfig({
|
|
220
326
|
displayName: "StyledRow",
|
|
221
327
|
componentId: "sc-xjsdg1-0"
|
|
222
328
|
})(["display:flex;box-sizing:border-box;", " ", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
223
329
|
return flexStyles(props.alignItems, props.justifyContent, props.wrapAll);
|
|
224
330
|
}, function (props) {
|
|
225
|
-
return sizeStyles(props);
|
|
331
|
+
return sizeStyles$2(props);
|
|
226
332
|
}, function (props) {
|
|
227
|
-
return props.debug && colorStyles(props);
|
|
333
|
+
return props.debug && colorStyles$1(props);
|
|
228
334
|
}, function (props) {
|
|
229
335
|
return mediaStyles(props.theme.breakpoints.xs, props.alignItemsXs, props.justifyContentXs, props.wrapXs);
|
|
230
336
|
}, function (props) {
|
|
@@ -236,13 +342,179 @@ var StyledRow = styled.div.attrs({
|
|
|
236
342
|
}, function (props) {
|
|
237
343
|
return mediaStyles(props.theme.breakpoints.xl, props.alignItemsXl, props.justifyContentXl, props.wrapXl);
|
|
238
344
|
}, function (props) {
|
|
239
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
345
|
+
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
240
346
|
});
|
|
241
347
|
StyledRow.defaultProps = {
|
|
242
348
|
wrapAll: 'wrap',
|
|
243
349
|
theme: DEFAULT_THEME
|
|
244
350
|
};
|
|
245
351
|
|
|
352
|
+
var COMPONENT_ID$3 = 'pane';
|
|
353
|
+
var StyledPane = styled.div.attrs({
|
|
354
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
355
|
+
'data-garden-version': '8.53.0'
|
|
356
|
+
}).withConfig({
|
|
357
|
+
displayName: "StyledPane",
|
|
358
|
+
componentId: "sc-1ltjst7-0"
|
|
359
|
+
})(["position:relative;min-width:0;min-height:0;", ";"], function (props) {
|
|
360
|
+
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
361
|
+
});
|
|
362
|
+
StyledPane.defaultProps = {
|
|
363
|
+
theme: DEFAULT_THEME
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
var COMPONENT_ID$2 = 'pane.content';
|
|
367
|
+
var StyledPaneContent = styled.div.attrs({
|
|
368
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
369
|
+
'data-garden-version': '8.53.0'
|
|
370
|
+
}).withConfig({
|
|
371
|
+
displayName: "StyledPaneContent",
|
|
372
|
+
componentId: "sc-1b38mbh-0"
|
|
373
|
+
})(["height:100%;overflow:auto;", ";"], function (props) {
|
|
374
|
+
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
375
|
+
});
|
|
376
|
+
StyledPaneContent.defaultProps = {
|
|
377
|
+
theme: DEFAULT_THEME
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
var COMPONENT_ID$1 = 'pane.splitter';
|
|
381
|
+
var colorStyles = function colorStyles(props) {
|
|
382
|
+
var color = getColor('neutralHue', 300, props.theme);
|
|
383
|
+
var hoverColor = getColor('primaryHue', 600, props.theme);
|
|
384
|
+
var activeColor = getColor('primaryHue', 800, props.theme);
|
|
385
|
+
var boxShadow = props.theme.shadows.md(rgba(hoverColor, 0.35));
|
|
386
|
+
return css(["&::before{background-color:", ";}&:hover::before,&[data-garden-focus-visible]::before{background-color:", ";}&[data-garden-focus-visible]::before{box-shadow:", ";}&:active::before{background-color:", ";}"], color, hoverColor, boxShadow, activeColor);
|
|
387
|
+
};
|
|
388
|
+
var sizeStyles$1 = function sizeStyles(props) {
|
|
389
|
+
var size = math("".concat(props.theme.shadowWidths.md, " * 2"));
|
|
390
|
+
var offset = math("-".concat(size, " / 2"));
|
|
391
|
+
var cursor;
|
|
392
|
+
var top;
|
|
393
|
+
var right;
|
|
394
|
+
var left;
|
|
395
|
+
var bottom;
|
|
396
|
+
var width;
|
|
397
|
+
var height;
|
|
398
|
+
var separatorWidth;
|
|
399
|
+
var separatorHeight;
|
|
400
|
+
switch (props.orientation) {
|
|
401
|
+
case 'top':
|
|
402
|
+
cursor = 'row-resize';
|
|
403
|
+
top = offset;
|
|
404
|
+
width = '100%';
|
|
405
|
+
height = size;
|
|
406
|
+
separatorWidth = width;
|
|
407
|
+
separatorHeight = props.theme.borderWidths.sm;
|
|
408
|
+
break;
|
|
409
|
+
case 'end':
|
|
410
|
+
cursor = 'col-resize';
|
|
411
|
+
top = 0;
|
|
412
|
+
width = size;
|
|
413
|
+
height = '100%';
|
|
414
|
+
separatorWidth = props.theme.borderWidths.sm;
|
|
415
|
+
separatorHeight = height;
|
|
416
|
+
if (props.theme.rtl) {
|
|
417
|
+
left = offset;
|
|
418
|
+
} else {
|
|
419
|
+
right = offset;
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
case 'bottom':
|
|
423
|
+
cursor = 'row-resize';
|
|
424
|
+
bottom = offset;
|
|
425
|
+
width = '100%';
|
|
426
|
+
height = size;
|
|
427
|
+
separatorWidth = width;
|
|
428
|
+
separatorHeight = props.theme.borderWidths.sm;
|
|
429
|
+
break;
|
|
430
|
+
case 'start':
|
|
431
|
+
cursor = 'col-resize';
|
|
432
|
+
top = 0;
|
|
433
|
+
width = size;
|
|
434
|
+
height = '100%';
|
|
435
|
+
separatorWidth = props.theme.borderWidths.sm;
|
|
436
|
+
separatorHeight = height;
|
|
437
|
+
if (props.theme.rtl) {
|
|
438
|
+
right = offset;
|
|
439
|
+
} else {
|
|
440
|
+
left = offset;
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
return css(["top:", ";right:", ";bottom:", ";left:", ";cursor:", ";width:", ";height:", ";&::before{width:", ";height:", ";}&:hover::before,&[data-garden-focus-visible]::before,&:focus::before{", ":", ";}&[data-garden-focus-visible]::before{border-radius:", ";}"], top, right, bottom, left, cursor, width, height, separatorWidth, separatorHeight, width === '100%' ? 'height' : 'width', math("".concat(props.theme.borderWidths.sm, " * 2")), props.theme.borderRadii.md);
|
|
445
|
+
};
|
|
446
|
+
var StyledPaneSplitter = styled.div.attrs({
|
|
447
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
448
|
+
'data-garden-version': '8.53.0'
|
|
449
|
+
}).withConfig({
|
|
450
|
+
displayName: "StyledPaneSplitter",
|
|
451
|
+
componentId: "sc-jylemn-0"
|
|
452
|
+
})(["display:flex;position:absolute;align-items:center;justify-content:center;z-index:1;user-select:none;", ";&:focus{outline:none;}&::before{position:absolute;transition:box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out;z-index:-1;content:'';}", ";", ";"], sizeStyles$1, colorStyles, function (props) {
|
|
453
|
+
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
454
|
+
});
|
|
455
|
+
StyledPaneSplitter.defaultProps = {
|
|
456
|
+
theme: DEFAULT_THEME
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
var COMPONENT_ID = 'pane.splitter_button';
|
|
460
|
+
var transformStyles = function transformStyles(props) {
|
|
461
|
+
var degrees = 0;
|
|
462
|
+
if (props.isRotated) {
|
|
463
|
+
degrees = props.theme.rtl ? -180 : 180;
|
|
464
|
+
}
|
|
465
|
+
if (props.orientation === 'end') {
|
|
466
|
+
degrees += props.theme.rtl ? -90 : 90;
|
|
467
|
+
} else if (props.orientation === 'start') {
|
|
468
|
+
degrees += props.theme.rtl ? 90 : -90;
|
|
469
|
+
} else if (props.orientation === 'bottom') {
|
|
470
|
+
degrees += 180;
|
|
471
|
+
}
|
|
472
|
+
return css(["& > svg{transform:rotate(", "deg);}"], degrees);
|
|
473
|
+
};
|
|
474
|
+
var sizeStyles = function sizeStyles(props) {
|
|
475
|
+
var size = "".concat(props.theme.space.base * 6, "px");
|
|
476
|
+
var isVertical = props.orientation === 'start' || props.orientation === 'end';
|
|
477
|
+
var top;
|
|
478
|
+
var left;
|
|
479
|
+
var right;
|
|
480
|
+
var bottom;
|
|
481
|
+
if (props.placement === 'start') {
|
|
482
|
+
if (isVertical) {
|
|
483
|
+
top = size;
|
|
484
|
+
} else if (props.theme.rtl) {
|
|
485
|
+
right = size;
|
|
486
|
+
} else {
|
|
487
|
+
left = size;
|
|
488
|
+
}
|
|
489
|
+
} else if (props.placement === 'end') {
|
|
490
|
+
if (isVertical) {
|
|
491
|
+
bottom = size;
|
|
492
|
+
} else if (props.theme.rtl) {
|
|
493
|
+
left = size;
|
|
494
|
+
} else {
|
|
495
|
+
right = size;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return css(["top:", ";right:", ";bottom:", ";left:", ";width:", ";min-width:", ";height:", ";"], top, right, bottom, left, size, size, size);
|
|
499
|
+
};
|
|
500
|
+
var StyledPaneSplitterButton = styled(ChevronButton).attrs({
|
|
501
|
+
'data-garden-id': COMPONENT_ID,
|
|
502
|
+
'data-garden-version': '8.53.0',
|
|
503
|
+
isBasic: true,
|
|
504
|
+
isPill: true,
|
|
505
|
+
size: 'small'
|
|
506
|
+
}).withConfig({
|
|
507
|
+
displayName: "StyledPaneSplitterButton",
|
|
508
|
+
componentId: "sc-zh032e-0"
|
|
509
|
+
})(["position:absolute;transition:box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,opacity 0.25s ease-in-out 0.1s;opacity:0;&[data-garden-focus-visible],", ":hover &,", "[data-garden-focus-visible] &{opacity:1;}", ";", ";&::before{position:absolute;z-index:-1;background-color:", ";width:100%;height:100%;content:'';}", ";"], StyledPaneSplitter, StyledPaneSplitter, sizeStyles, transformStyles, function (props) {
|
|
510
|
+
return props.theme.colors.background;
|
|
511
|
+
}, function (props) {
|
|
512
|
+
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
513
|
+
});
|
|
514
|
+
StyledPaneSplitterButton.defaultProps = {
|
|
515
|
+
theme: DEFAULT_THEME
|
|
516
|
+
};
|
|
517
|
+
|
|
246
518
|
var GridContext = createContext({
|
|
247
519
|
gutters: 'md'
|
|
248
520
|
});
|
|
@@ -250,10 +522,10 @@ var useGridContext = function useGridContext() {
|
|
|
250
522
|
return useContext(GridContext);
|
|
251
523
|
};
|
|
252
524
|
|
|
253
|
-
var _excluded$
|
|
525
|
+
var _excluded$4 = ["size"];
|
|
254
526
|
var Col = React.forwardRef(function (_ref, ref) {
|
|
255
527
|
var size = _ref.size,
|
|
256
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
528
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
257
529
|
var _useGridContext = useGridContext(),
|
|
258
530
|
columns = _useGridContext.columns,
|
|
259
531
|
gutters = _useGridContext.gutters,
|
|
@@ -300,11 +572,11 @@ Col.propTypes = {
|
|
|
300
572
|
orderXl: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
301
573
|
};
|
|
302
574
|
|
|
303
|
-
var _excluded$
|
|
575
|
+
var _excluded$3 = ["columns", "debug"];
|
|
304
576
|
var Grid = React.forwardRef(function (_ref, ref) {
|
|
305
577
|
var columns = _ref.columns,
|
|
306
578
|
debug = _ref.debug,
|
|
307
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
579
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
308
580
|
var value = useMemo(function () {
|
|
309
581
|
return {
|
|
310
582
|
columns: columns,
|
|
@@ -330,10 +602,10 @@ Grid.defaultProps = {
|
|
|
330
602
|
gutters: 'md'
|
|
331
603
|
};
|
|
332
604
|
|
|
333
|
-
var _excluded = ["wrap"];
|
|
605
|
+
var _excluded$2 = ["wrap"];
|
|
334
606
|
var Row = React.forwardRef(function (_ref, ref) {
|
|
335
607
|
var wrap = _ref.wrap,
|
|
336
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
608
|
+
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
337
609
|
var _useGridContext = useGridContext(),
|
|
338
610
|
gutters = _useGridContext.gutters,
|
|
339
611
|
debug = _useGridContext.debug;
|
|
@@ -366,4 +638,415 @@ Row.propTypes = {
|
|
|
366
638
|
wrapXl: PropTypes.oneOf(WRAP)
|
|
367
639
|
};
|
|
368
640
|
|
|
369
|
-
|
|
641
|
+
var PaneProviderContext = createContext({});
|
|
642
|
+
var usePaneProviderContextData = function usePaneProviderContextData(providerId) {
|
|
643
|
+
var context = useContext(PaneProviderContext);
|
|
644
|
+
var id = providerId || context.providerId;
|
|
645
|
+
return id && context.contextData ? context.contextData[id] : undefined;
|
|
646
|
+
};
|
|
647
|
+
var usePaneProviderContext = function usePaneProviderContext() {
|
|
648
|
+
return useContext(PaneProviderContext);
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
var getPixelsPerFr = function getPixelsPerFr(totalFrs, totalDimension) {
|
|
652
|
+
return totalDimension / totalFrs;
|
|
653
|
+
};
|
|
654
|
+
var convertToPixels = function convertToPixels(values, pixelsPerFr) {
|
|
655
|
+
return Object.entries(values).reduce(function (prev, _ref) {
|
|
656
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
657
|
+
key = _ref2[0],
|
|
658
|
+
value = _ref2[1];
|
|
659
|
+
prev[key] = value * pixelsPerFr;
|
|
660
|
+
return prev;
|
|
661
|
+
}, {});
|
|
662
|
+
};
|
|
663
|
+
var PaneProvider = function PaneProvider(_ref3) {
|
|
664
|
+
var id = _ref3.id,
|
|
665
|
+
totalPanesWidth = _ref3.totalPanesWidth,
|
|
666
|
+
totalPanesHeight = _ref3.totalPanesHeight,
|
|
667
|
+
defaultRowValues = _ref3.defaultRowValues,
|
|
668
|
+
defaultColumnValues = _ref3.defaultColumnValues,
|
|
669
|
+
rowValues = _ref3.rowValues,
|
|
670
|
+
columnValues = _ref3.columnValues,
|
|
671
|
+
onChange = _ref3.onChange,
|
|
672
|
+
children = _ref3.children;
|
|
673
|
+
var isControlled = rowValues !== undefined && rowValues !== null && columnValues !== undefined && columnValues !== null;
|
|
674
|
+
var _useState = useState(defaultRowValues || {}),
|
|
675
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
676
|
+
rowState = _useState2[0],
|
|
677
|
+
setRowState = _useState2[1];
|
|
678
|
+
var _useState3 = useState(defaultColumnValues || {}),
|
|
679
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
680
|
+
columnState = _useState4[0],
|
|
681
|
+
setColumnState = _useState4[1];
|
|
682
|
+
var rowsTrack = isControlled ? rowValues : rowState;
|
|
683
|
+
var columnsTrack = isControlled ? columnValues : columnState;
|
|
684
|
+
var setRowsTrack = useCallback(function (values) {
|
|
685
|
+
if (isControlled && onChange) {
|
|
686
|
+
return onChange(values(rowsTrack), columnsTrack);
|
|
687
|
+
}
|
|
688
|
+
return setRowState(values);
|
|
689
|
+
}, [isControlled, onChange, setRowState, columnsTrack, rowsTrack]);
|
|
690
|
+
var setColumnsTrack = useCallback(function (values) {
|
|
691
|
+
if (isControlled && onChange) {
|
|
692
|
+
return onChange(rowsTrack, values(columnsTrack));
|
|
693
|
+
}
|
|
694
|
+
return setColumnState(values);
|
|
695
|
+
}, [isControlled, onChange, setColumnState, rowsTrack, columnsTrack]);
|
|
696
|
+
var totalFractions = useMemo(function () {
|
|
697
|
+
return {
|
|
698
|
+
rows: Object.values(rowsTrack).reduce(function (prev, value) {
|
|
699
|
+
return value + prev;
|
|
700
|
+
}, 0),
|
|
701
|
+
columns: Object.values(columnsTrack).reduce(function (prev, value) {
|
|
702
|
+
return value + prev;
|
|
703
|
+
}, 0)
|
|
704
|
+
};
|
|
705
|
+
}, [rowsTrack, columnsTrack]);
|
|
706
|
+
var pixelsPerFr = useMemo(function () {
|
|
707
|
+
return {
|
|
708
|
+
rows: getPixelsPerFr(totalFractions.rows, totalPanesHeight),
|
|
709
|
+
columns: getPixelsPerFr(totalFractions.columns, totalPanesWidth)
|
|
710
|
+
};
|
|
711
|
+
}, [totalFractions, totalPanesHeight, totalPanesWidth]);
|
|
712
|
+
var layoutStateInPixels = useMemo(function () {
|
|
713
|
+
return {
|
|
714
|
+
rows: convertToPixels(rowsTrack, pixelsPerFr.rows),
|
|
715
|
+
columns: convertToPixels(columnsTrack, pixelsPerFr.columns)
|
|
716
|
+
};
|
|
717
|
+
}, [rowsTrack, columnsTrack, pixelsPerFr]);
|
|
718
|
+
var layoutIndices = useMemo(function () {
|
|
719
|
+
var rowArray = Object.keys(rowsTrack);
|
|
720
|
+
var columnArray = Object.keys(columnsTrack);
|
|
721
|
+
var rows = rowArray.reduce(function (prev, key, index) {
|
|
722
|
+
prev[key] = index;
|
|
723
|
+
return prev;
|
|
724
|
+
}, {});
|
|
725
|
+
var columns = columnArray.reduce(function (prev, key, index) {
|
|
726
|
+
prev[key] = index;
|
|
727
|
+
return prev;
|
|
728
|
+
}, {});
|
|
729
|
+
return {
|
|
730
|
+
rows: rows,
|
|
731
|
+
columns: columns,
|
|
732
|
+
rowArray: rowArray,
|
|
733
|
+
columnArray: columnArray
|
|
734
|
+
};
|
|
735
|
+
}, [rowsTrack, columnsTrack]);
|
|
736
|
+
var setRowValue = useCallback(function (isTop, splitterId, value) {
|
|
737
|
+
var rows = layoutIndices.rows,
|
|
738
|
+
rowArray = layoutIndices.rowArray;
|
|
739
|
+
var stealFromTraversal = isTop ? -1 : 1;
|
|
740
|
+
var addToTraversal = 0;
|
|
741
|
+
setRowsTrack(function (state) {
|
|
742
|
+
var oldValue = rowsTrack[splitterId];
|
|
743
|
+
var stealFromIndex = rows[splitterId] + stealFromTraversal;
|
|
744
|
+
var addToIndex = rows[splitterId] + addToTraversal;
|
|
745
|
+
var stealFromKey = rowArray[stealFromIndex];
|
|
746
|
+
var addToKey = rowArray[addToIndex];
|
|
747
|
+
var difference = oldValue - value;
|
|
748
|
+
var nextState = _objectSpread2({}, state);
|
|
749
|
+
nextState[addToKey] = rowsTrack[addToKey] - difference;
|
|
750
|
+
nextState[stealFromKey] = rowsTrack[stealFromKey] + difference;
|
|
751
|
+
return nextState;
|
|
752
|
+
});
|
|
753
|
+
}, [layoutIndices, rowsTrack, setRowsTrack]);
|
|
754
|
+
var setColumnValue = useCallback(function (isStart, splitterId, value) {
|
|
755
|
+
var columns = layoutIndices.columns,
|
|
756
|
+
columnArray = layoutIndices.columnArray;
|
|
757
|
+
var stealFromTraversal = isStart ? -1 : 1;
|
|
758
|
+
var addToTraversal = 0;
|
|
759
|
+
setColumnsTrack(function (state) {
|
|
760
|
+
var stealFromIndex = columns[splitterId] + stealFromTraversal;
|
|
761
|
+
var addToIndex = columns[splitterId] + addToTraversal;
|
|
762
|
+
var oldValue = columnsTrack[splitterId];
|
|
763
|
+
var stealFromKey = columnArray[stealFromIndex];
|
|
764
|
+
var addToKey = columnArray[addToIndex];
|
|
765
|
+
var difference = oldValue - value;
|
|
766
|
+
var nextState = _objectSpread2({}, state);
|
|
767
|
+
nextState[addToKey] = columnsTrack[addToKey] - difference;
|
|
768
|
+
nextState[stealFromKey] = columnsTrack[stealFromKey] + difference;
|
|
769
|
+
return nextState;
|
|
770
|
+
});
|
|
771
|
+
}, [layoutIndices, columnsTrack, setColumnsTrack]);
|
|
772
|
+
var getColumnValue = useCallback(function (splitterKey, isPixels) {
|
|
773
|
+
if (isPixels) {
|
|
774
|
+
return layoutStateInPixels.columns[splitterKey];
|
|
775
|
+
}
|
|
776
|
+
return columnsTrack[splitterKey];
|
|
777
|
+
}, [columnsTrack, layoutStateInPixels]);
|
|
778
|
+
var getRowValue = useCallback(function (splitterKey, isPixels) {
|
|
779
|
+
if (isPixels) {
|
|
780
|
+
return layoutStateInPixels.rows[splitterKey];
|
|
781
|
+
}
|
|
782
|
+
return rowsTrack[splitterKey];
|
|
783
|
+
}, [rowsTrack, layoutStateInPixels]);
|
|
784
|
+
var getGridTemplateColumns = useCallback(function (isPixels) {
|
|
785
|
+
var columnArray = layoutIndices.columnArray;
|
|
786
|
+
if (isPixels) {
|
|
787
|
+
return columnArray.map(function (col) {
|
|
788
|
+
return "".concat(layoutStateInPixels.columns[col], "px");
|
|
789
|
+
}).join(' ');
|
|
790
|
+
}
|
|
791
|
+
return columnArray.map(function (col) {
|
|
792
|
+
return "".concat(columnsTrack[col], "fr");
|
|
793
|
+
}).join(' ');
|
|
794
|
+
}, [layoutIndices, columnsTrack, layoutStateInPixels]);
|
|
795
|
+
var getGridTemplateRows = useCallback(function (isPixels) {
|
|
796
|
+
var rowArray = layoutIndices.rowArray;
|
|
797
|
+
if (isPixels) {
|
|
798
|
+
return rowArray.map(function (row) {
|
|
799
|
+
return "".concat(layoutStateInPixels.rows[row], "px");
|
|
800
|
+
}).join(' ');
|
|
801
|
+
}
|
|
802
|
+
return rowArray.map(function (row) {
|
|
803
|
+
return "".concat(rowsTrack[row], "fr");
|
|
804
|
+
}).join(' ');
|
|
805
|
+
}, [layoutIndices, rowsTrack, layoutStateInPixels]);
|
|
806
|
+
var providerId = useId(id);
|
|
807
|
+
var parentPaneProviderContext = usePaneProviderContext();
|
|
808
|
+
var paneProviderContext = useMemo(function () {
|
|
809
|
+
return providerId ? {
|
|
810
|
+
providerId: providerId,
|
|
811
|
+
contextData: _objectSpread2(_objectSpread2({}, parentPaneProviderContext.contextData), {}, _defineProperty({}, providerId, {
|
|
812
|
+
columnState: columnState,
|
|
813
|
+
rowState: rowState,
|
|
814
|
+
setRowValue: setRowValue,
|
|
815
|
+
setColumnValue: setColumnValue,
|
|
816
|
+
getRowValue: getRowValue,
|
|
817
|
+
getColumnValue: getColumnValue,
|
|
818
|
+
totalPanesHeight: totalPanesHeight,
|
|
819
|
+
totalPanesWidth: totalPanesWidth,
|
|
820
|
+
pixelsPerFr: pixelsPerFr
|
|
821
|
+
}))
|
|
822
|
+
} : {};
|
|
823
|
+
}, [providerId, parentPaneProviderContext, rowState, columnState, setRowValue, setColumnValue, getRowValue, getColumnValue, totalPanesHeight, totalPanesWidth, pixelsPerFr]);
|
|
824
|
+
return React.createElement(PaneProviderContext.Provider, {
|
|
825
|
+
value: paneProviderContext
|
|
826
|
+
}, children === null || children === void 0 ? void 0 : children({
|
|
827
|
+
id: providerId,
|
|
828
|
+
getRowValue: getRowValue,
|
|
829
|
+
getColumnValue: getColumnValue,
|
|
830
|
+
getGridTemplateColumns: getGridTemplateColumns,
|
|
831
|
+
getGridTemplateRows: getGridTemplateRows
|
|
832
|
+
}));
|
|
833
|
+
};
|
|
834
|
+
PaneProvider.displayName = 'PaneProvider';
|
|
835
|
+
PaneProvider.propTypes = {
|
|
836
|
+
id: PropTypes.string,
|
|
837
|
+
totalPanesWidth: PropTypes.number.isRequired,
|
|
838
|
+
totalPanesHeight: PropTypes.number.isRequired,
|
|
839
|
+
defaultRowValues: PropTypes.object,
|
|
840
|
+
defaultColumnValues: PropTypes.object,
|
|
841
|
+
rowValues: PropTypes.object,
|
|
842
|
+
columnValues: PropTypes.object,
|
|
843
|
+
onChange: PropTypes.func,
|
|
844
|
+
children: PropTypes.func
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
var PaneContext = createContext({
|
|
848
|
+
setId: function setId() {
|
|
849
|
+
return undefined;
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
var usePaneContext = function usePaneContext() {
|
|
853
|
+
return useContext(PaneContext);
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
var PaneSplitterContext = createContext({
|
|
857
|
+
orientation: 'start',
|
|
858
|
+
min: 0,
|
|
859
|
+
max: 0,
|
|
860
|
+
layoutKey: '',
|
|
861
|
+
valueNow: 0,
|
|
862
|
+
isRow: false
|
|
863
|
+
});
|
|
864
|
+
var usePaneSplitterContext = function usePaneSplitterContext() {
|
|
865
|
+
return useContext(PaneSplitterContext);
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
var _excluded$1 = ["providerId", "layoutKey", "min", "max", "orientation"];
|
|
869
|
+
var orientationToPosition = {
|
|
870
|
+
start: SplitterPosition.LEADS,
|
|
871
|
+
end: SplitterPosition.TRAILS,
|
|
872
|
+
top: SplitterPosition.LEADS,
|
|
873
|
+
bottom: SplitterPosition.TRAILS
|
|
874
|
+
};
|
|
875
|
+
var paneToSplitterOrientation = {
|
|
876
|
+
start: SplitterOrientation.VERTICAL,
|
|
877
|
+
end: SplitterOrientation.VERTICAL,
|
|
878
|
+
top: SplitterOrientation.HORIZONTAL,
|
|
879
|
+
bottom: SplitterOrientation.HORIZONTAL
|
|
880
|
+
};
|
|
881
|
+
var orientationToDimension = {
|
|
882
|
+
start: 'columns',
|
|
883
|
+
end: 'columns',
|
|
884
|
+
top: 'rows',
|
|
885
|
+
bottom: 'rows'
|
|
886
|
+
};
|
|
887
|
+
var SplitterComponent = forwardRef(function (_ref, ref) {
|
|
888
|
+
var providerId = _ref.providerId,
|
|
889
|
+
layoutKey = _ref.layoutKey,
|
|
890
|
+
min = _ref.min,
|
|
891
|
+
max = _ref.max,
|
|
892
|
+
orientation = _ref.orientation,
|
|
893
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
894
|
+
var paneProviderContext = usePaneProviderContextData(providerId);
|
|
895
|
+
var paneContext = usePaneContext();
|
|
896
|
+
var themeContext = useContext(ThemeContext);
|
|
897
|
+
var position = orientationToPosition[orientation];
|
|
898
|
+
var isRow = orientationToDimension[orientation] === 'rows';
|
|
899
|
+
var splitterOrientation = paneToSplitterOrientation[orientation];
|
|
900
|
+
var pixelsPerFr = paneProviderContext ? paneProviderContext.pixelsPerFr[orientationToDimension[orientation]] : 0;
|
|
901
|
+
var value = isRow ? paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getRowValue(layoutKey, true) : paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getColumnValue(layoutKey, true);
|
|
902
|
+
var valueInFr = isRow ? paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getRowValue(layoutKey) : paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getColumnValue(layoutKey);
|
|
903
|
+
var _useSplitter = useSplitter({
|
|
904
|
+
type: SplitterType.VARIABLE,
|
|
905
|
+
orientation: splitterOrientation,
|
|
906
|
+
position: position,
|
|
907
|
+
min: min * pixelsPerFr,
|
|
908
|
+
max: max * pixelsPerFr,
|
|
909
|
+
rtl: themeContext.rtl,
|
|
910
|
+
environment: window,
|
|
911
|
+
onChange: function onChange(valueNow) {
|
|
912
|
+
if (isRow) {
|
|
913
|
+
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setRowValue(orientation === 'top', layoutKey, valueNow / pixelsPerFr);
|
|
914
|
+
}
|
|
915
|
+
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setColumnValue(orientation === 'start', layoutKey, valueNow / pixelsPerFr);
|
|
916
|
+
},
|
|
917
|
+
valueNow: value
|
|
918
|
+
}),
|
|
919
|
+
getSeparatorProps = _useSplitter.getSeparatorProps,
|
|
920
|
+
getPrimaryPaneProps = _useSplitter.getPrimaryPaneProps;
|
|
921
|
+
useEffect(function () {
|
|
922
|
+
if (!paneContext.id) {
|
|
923
|
+
paneContext.setId(getPrimaryPaneProps().id);
|
|
924
|
+
}
|
|
925
|
+
}, [paneContext, getPrimaryPaneProps]);
|
|
926
|
+
var separatorProps = getSeparatorProps({
|
|
927
|
+
'aria-controls': paneContext.id
|
|
928
|
+
});
|
|
929
|
+
return React.createElement(PaneSplitterContext.Provider, {
|
|
930
|
+
value: useMemo(function () {
|
|
931
|
+
return {
|
|
932
|
+
orientation: orientation,
|
|
933
|
+
layoutKey: layoutKey,
|
|
934
|
+
min: min,
|
|
935
|
+
max: max,
|
|
936
|
+
valueNow: valueInFr,
|
|
937
|
+
isRow: isRow
|
|
938
|
+
};
|
|
939
|
+
}, [orientation, layoutKey, min, max, valueInFr, isRow])
|
|
940
|
+
}, React.createElement(StyledPaneSplitter, _extends({
|
|
941
|
+
orientation: orientation
|
|
942
|
+
}, separatorProps, props, {
|
|
943
|
+
ref: mergeRefs([separatorProps.ref, ref])
|
|
944
|
+
})));
|
|
945
|
+
});
|
|
946
|
+
SplitterComponent.displayName = 'Pane.Splitter';
|
|
947
|
+
SplitterComponent.propTypes = {
|
|
948
|
+
layoutKey: PropTypes.string.isRequired,
|
|
949
|
+
min: PropTypes.number.isRequired,
|
|
950
|
+
max: PropTypes.number.isRequired,
|
|
951
|
+
orientation: PropTypes.oneOf(ORIENTATION)
|
|
952
|
+
};
|
|
953
|
+
SplitterComponent.defaultProps = {
|
|
954
|
+
orientation: 'end'
|
|
955
|
+
};
|
|
956
|
+
var Splitter = SplitterComponent;
|
|
957
|
+
|
|
958
|
+
var ContentComponent = forwardRef(function (props, ref) {
|
|
959
|
+
return React.createElement(StyledPaneContent, _extends({
|
|
960
|
+
ref: ref
|
|
961
|
+
}, props));
|
|
962
|
+
});
|
|
963
|
+
ContentComponent.displayName = 'Pane.Content';
|
|
964
|
+
var Content = ContentComponent;
|
|
965
|
+
|
|
966
|
+
var SplitterButtonComponent = forwardRef(function (props, ref) {
|
|
967
|
+
var label = props.label,
|
|
968
|
+
defaultPlacement = props.placement;
|
|
969
|
+
var _usePaneSplitterConte = usePaneSplitterContext(),
|
|
970
|
+
orientation = _usePaneSplitterConte.orientation,
|
|
971
|
+
layoutKey = _usePaneSplitterConte.layoutKey,
|
|
972
|
+
min = _usePaneSplitterConte.min,
|
|
973
|
+
max = _usePaneSplitterConte.max,
|
|
974
|
+
isRow = _usePaneSplitterConte.isRow,
|
|
975
|
+
valueNow = _usePaneSplitterConte.valueNow,
|
|
976
|
+
providerId = _usePaneSplitterConte.providerId;
|
|
977
|
+
var paneProviderContext = usePaneProviderContextData(providerId);
|
|
978
|
+
var isTop = orientation === 'top';
|
|
979
|
+
var isStart = orientation === 'start';
|
|
980
|
+
var isMin = valueNow === min;
|
|
981
|
+
var placement = defaultPlacement;
|
|
982
|
+
if (!defaultPlacement) {
|
|
983
|
+
if (isRow) {
|
|
984
|
+
placement = 'center';
|
|
985
|
+
} else {
|
|
986
|
+
placement = 'start';
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
var setValue = useCallback(function (value) {
|
|
990
|
+
if (isRow) {
|
|
991
|
+
paneProviderContext.setRowValue(isTop, layoutKey, value);
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
paneProviderContext.setColumnValue(isStart, layoutKey, value);
|
|
995
|
+
}, [isRow, isTop, isStart, layoutKey, paneProviderContext]);
|
|
996
|
+
var onClick = composeEventHandlers(props.onClick, function () {
|
|
997
|
+
if (isMin) {
|
|
998
|
+
setValue(max);
|
|
999
|
+
} else {
|
|
1000
|
+
setValue(min);
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
var onKeyDown = composeEventHandlers(props.onKeyDown, function (event) {
|
|
1004
|
+
return event.stopPropagation();
|
|
1005
|
+
}
|
|
1006
|
+
);
|
|
1007
|
+
return React.createElement(Tooltip, {
|
|
1008
|
+
content: label
|
|
1009
|
+
}, React.createElement(StyledPaneSplitterButton, _extends({
|
|
1010
|
+
"aria-label": label
|
|
1011
|
+
}, props, {
|
|
1012
|
+
placement: placement,
|
|
1013
|
+
orientation: orientation,
|
|
1014
|
+
isRotated: isMin,
|
|
1015
|
+
ref: ref,
|
|
1016
|
+
onClick: onClick,
|
|
1017
|
+
onKeyDown: onKeyDown
|
|
1018
|
+
})));
|
|
1019
|
+
});
|
|
1020
|
+
SplitterButtonComponent.displayName = 'Pane.SplitterButton';
|
|
1021
|
+
var SplitterButton = SplitterButtonComponent;
|
|
1022
|
+
|
|
1023
|
+
var _excluded = ["children"];
|
|
1024
|
+
var PaneComponent = forwardRef(function (_ref, ref) {
|
|
1025
|
+
var children = _ref.children,
|
|
1026
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
1027
|
+
var _useState = useState(),
|
|
1028
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1029
|
+
paneId = _useState2[0],
|
|
1030
|
+
setPaneId = _useState2[1];
|
|
1031
|
+
var paneContext = useMemo(function () {
|
|
1032
|
+
return {
|
|
1033
|
+
id: paneId,
|
|
1034
|
+
setId: function setId(id) {
|
|
1035
|
+
return setPaneId(id);
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
}, [paneId]);
|
|
1039
|
+
return React.createElement(PaneContext.Provider, {
|
|
1040
|
+
value: paneContext
|
|
1041
|
+
}, React.createElement(StyledPane, _extends({
|
|
1042
|
+
id: paneId,
|
|
1043
|
+
ref: ref
|
|
1044
|
+
}, props), children));
|
|
1045
|
+
});
|
|
1046
|
+
PaneComponent.displayName = 'Pane';
|
|
1047
|
+
var Pane = PaneComponent;
|
|
1048
|
+
Pane.Content = Content;
|
|
1049
|
+
Pane.Splitter = Splitter;
|
|
1050
|
+
Pane.SplitterButton = SplitterButton;
|
|
1051
|
+
|
|
1052
|
+
export { ALIGN_ITEMS as ARRAY_ALIGN_ITEMS, ALIGN_SELF as ARRAY_ALIGN_SELF, DIRECTION as ARRAY_DIRECTION, JUSTIFY_CONTENT as ARRAY_JUSTIFY_CONTENT, SPACE as ARRAY_SPACE, TEXT_ALIGN as ARRAY_TEXT_ALIGN, WRAP as ARRAY_WRAP, Col, Grid, Pane, PaneProvider, Row };
|