@zendeskgarden/react-grid 8.50.1 → 8.51.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 +58 -0
- package/dist/index.cjs.js +578 -30
- package/dist/index.esm.js +579 -34
- package/dist/typings/elements/pane/Pane.d.ts +16 -0
- package/dist/typings/elements/pane/PaneProvider.d.ts +22 -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/index.d.ts +3 -1
- package/dist/typings/styled/index.d.ts +3 -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 +16 -0
- package/dist/typings/types/index.d.ts +48 -1
- package/dist/typings/utils/usePaneContext.d.ts +17 -0
- package/dist/typings/utils/useSplitterContext.d.ts +27 -0
- package/package.json +6 -4
package/dist/index.esm.js
CHANGED
|
@@ -5,11 +5,54 @@
|
|
|
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 mergeRefs from 'react-merge-refs';
|
|
14
|
+
import { SplitterPosition, SplitterOrientation, useSplitter, SplitterType } from '@zendeskgarden/container-splitter';
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) {
|
|
17
|
+
var keys = Object.keys(object);
|
|
18
|
+
|
|
19
|
+
if (Object.getOwnPropertySymbols) {
|
|
20
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
21
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
22
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
23
|
+
})), keys.push.apply(keys, symbols);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return keys;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function _objectSpread2(target) {
|
|
30
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
31
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
32
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
33
|
+
_defineProperty(target, key, source[key]);
|
|
34
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
35
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _defineProperty(obj, key, value) {
|
|
43
|
+
if (key in obj) {
|
|
44
|
+
Object.defineProperty(obj, key, {
|
|
45
|
+
value: value,
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
obj[key] = value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
13
56
|
|
|
14
57
|
function _extends() {
|
|
15
58
|
_extends = Object.assign || function (target) {
|
|
@@ -65,6 +108,65 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
65
108
|
return target;
|
|
66
109
|
}
|
|
67
110
|
|
|
111
|
+
function _slicedToArray(arr, i) {
|
|
112
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function _arrayWithHoles(arr) {
|
|
116
|
+
if (Array.isArray(arr)) return arr;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function _iterableToArrayLimit(arr, i) {
|
|
120
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
121
|
+
|
|
122
|
+
if (_i == null) return;
|
|
123
|
+
var _arr = [];
|
|
124
|
+
var _n = true;
|
|
125
|
+
var _d = false;
|
|
126
|
+
|
|
127
|
+
var _s, _e;
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
131
|
+
_arr.push(_s.value);
|
|
132
|
+
|
|
133
|
+
if (i && _arr.length === i) break;
|
|
134
|
+
}
|
|
135
|
+
} catch (err) {
|
|
136
|
+
_d = true;
|
|
137
|
+
_e = err;
|
|
138
|
+
} finally {
|
|
139
|
+
try {
|
|
140
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
141
|
+
} finally {
|
|
142
|
+
if (_d) throw _e;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return _arr;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
150
|
+
if (!o) return;
|
|
151
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
152
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
153
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
154
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
155
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function _arrayLikeToArray(arr, len) {
|
|
159
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
160
|
+
|
|
161
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
162
|
+
|
|
163
|
+
return arr2;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function _nonIterableRest() {
|
|
167
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
168
|
+
}
|
|
169
|
+
|
|
68
170
|
var ALIGN_ITEMS = ['start', 'end', 'center', 'baseline', 'stretch'];
|
|
69
171
|
var ALIGN_SELF = ['auto'].concat(ALIGN_ITEMS);
|
|
70
172
|
var DIRECTION = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
@@ -72,9 +174,10 @@ var JUSTIFY_CONTENT = ['start', 'end', 'center', 'between', 'around'];
|
|
|
72
174
|
var TEXT_ALIGN = ['start', 'end', 'center', 'justify'];
|
|
73
175
|
var SPACE = [false, 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
74
176
|
var WRAP = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
177
|
+
var ORIENTATION = ['top', 'bottom', 'start', 'end'];
|
|
75
178
|
|
|
76
|
-
var COMPONENT_ID$
|
|
77
|
-
var colorStyles$
|
|
179
|
+
var COMPONENT_ID$5 = 'grid.col';
|
|
180
|
+
var colorStyles$3 = function colorStyles(props) {
|
|
78
181
|
var backgroundColor = getColor('primaryHue', 600, props.theme, 0.1);
|
|
79
182
|
return css(["background-clip:content-box;background-color:", ";"], backgroundColor);
|
|
80
183
|
};
|
|
@@ -119,22 +222,22 @@ var flexStyles$1 = function flexStyles(size, alignSelf, textAlign, offset, order
|
|
|
119
222
|
var mediaStyles$1 = function mediaStyles(minWidth, size, alignSelf, textAlign, offset, order, props) {
|
|
120
223
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles$1(size, alignSelf, textAlign, offset, order, props));
|
|
121
224
|
};
|
|
122
|
-
var sizeStyles$
|
|
225
|
+
var sizeStyles$3 = function sizeStyles(props) {
|
|
123
226
|
var padding = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
124
227
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
125
228
|
};
|
|
126
229
|
var StyledCol = styled.div.attrs({
|
|
127
|
-
'data-garden-id': COMPONENT_ID$
|
|
128
|
-
'data-garden-version': '8.
|
|
230
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
231
|
+
'data-garden-version': '8.51.0'
|
|
129
232
|
}).withConfig({
|
|
130
233
|
displayName: "StyledCol",
|
|
131
234
|
componentId: "sc-inuw62-0"
|
|
132
235
|
})(["box-sizing:border-box;width:100%;", ";", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
133
236
|
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
237
|
}, function (props) {
|
|
135
|
-
return sizeStyles$
|
|
238
|
+
return sizeStyles$3(props);
|
|
136
239
|
}, function (props) {
|
|
137
|
-
return props.debug && colorStyles$
|
|
240
|
+
return props.debug && colorStyles$3(props);
|
|
138
241
|
}, function (props) {
|
|
139
242
|
return mediaStyles$1(props.theme.breakpoints.xs, props.xs, props.alignSelfXs, props.textAlignXs, props.offsetXs, props.orderXs, props);
|
|
140
243
|
}, function (props) {
|
|
@@ -146,45 +249,45 @@ var StyledCol = styled.div.attrs({
|
|
|
146
249
|
}, function (props) {
|
|
147
250
|
return mediaStyles$1(props.theme.breakpoints.xl, props.xl, props.alignSelfXl, props.textAlignXl, props.offsetXl, props.orderXl, props);
|
|
148
251
|
}, function (props) {
|
|
149
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
252
|
+
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
150
253
|
});
|
|
151
254
|
StyledCol.defaultProps = {
|
|
152
255
|
columns: 12,
|
|
153
256
|
theme: DEFAULT_THEME
|
|
154
257
|
};
|
|
155
258
|
|
|
156
|
-
var COMPONENT_ID$
|
|
157
|
-
var colorStyles$
|
|
259
|
+
var COMPONENT_ID$4 = 'grid.grid';
|
|
260
|
+
var colorStyles$2 = function colorStyles(props) {
|
|
158
261
|
var borderColor = getColor(props.theme.palette.crimson, 400, props.theme, 0.5);
|
|
159
262
|
var borderWidth = math("".concat(props.theme.borderWidths.sm, " * 2"));
|
|
160
263
|
return css(["box-shadow:-", " 0 0 0 ", ",", " 0 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
161
264
|
};
|
|
162
|
-
var sizeStyles$
|
|
265
|
+
var sizeStyles$2 = function sizeStyles(props) {
|
|
163
266
|
var padding = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
164
267
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
165
268
|
};
|
|
166
269
|
var StyledGrid = styled.div.attrs({
|
|
167
|
-
'data-garden-id': COMPONENT_ID$
|
|
168
|
-
'data-garden-version': '8.
|
|
270
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
271
|
+
'data-garden-version': '8.51.0'
|
|
169
272
|
}).withConfig({
|
|
170
273
|
displayName: "StyledGrid",
|
|
171
274
|
componentId: "sc-oxgg5i-0"
|
|
172
275
|
})(["direction:", ";margin-right:auto;margin-left:auto;width:100%;box-sizing:border-box;", ";", ";", ";"], function (props) {
|
|
173
276
|
return props.theme.rtl && 'rtl';
|
|
174
277
|
}, function (props) {
|
|
175
|
-
return sizeStyles$
|
|
278
|
+
return sizeStyles$2(props);
|
|
176
279
|
}, function (props) {
|
|
177
|
-
return props.debug && colorStyles$
|
|
280
|
+
return props.debug && colorStyles$2(props);
|
|
178
281
|
}, function (props) {
|
|
179
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
282
|
+
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
180
283
|
});
|
|
181
284
|
StyledGrid.defaultProps = {
|
|
182
285
|
gutters: 'md',
|
|
183
286
|
theme: DEFAULT_THEME
|
|
184
287
|
};
|
|
185
288
|
|
|
186
|
-
var COMPONENT_ID = 'grid.row';
|
|
187
|
-
var colorStyles = function colorStyles(props) {
|
|
289
|
+
var COMPONENT_ID$3 = 'grid.row';
|
|
290
|
+
var colorStyles$1 = function colorStyles(props) {
|
|
188
291
|
var borderColor = getColor(props.theme.palette.mint, 600, props.theme, 0.5);
|
|
189
292
|
var borderWidth = props.theme.borderWidths.sm;
|
|
190
293
|
return css(["box-shadow:inset 0 ", " 0 0 ", ",inset 0 -", " 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
@@ -209,22 +312,22 @@ var flexStyles = function flexStyles(alignItems, justifyContent, wrap) {
|
|
|
209
312
|
var mediaStyles = function mediaStyles(minWidth, alignItems, justifyContent, wrap) {
|
|
210
313
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles(alignItems, justifyContent, wrap));
|
|
211
314
|
};
|
|
212
|
-
var sizeStyles = function sizeStyles(props) {
|
|
315
|
+
var sizeStyles$1 = function sizeStyles(props) {
|
|
213
316
|
var margin = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
214
317
|
return css(["margin-right:-", ";margin-left:-", ";"], margin, margin);
|
|
215
318
|
};
|
|
216
319
|
var StyledRow = styled.div.attrs({
|
|
217
|
-
'data-garden-id': COMPONENT_ID,
|
|
218
|
-
'data-garden-version': '8.
|
|
320
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
321
|
+
'data-garden-version': '8.51.0'
|
|
219
322
|
}).withConfig({
|
|
220
323
|
displayName: "StyledRow",
|
|
221
324
|
componentId: "sc-xjsdg1-0"
|
|
222
325
|
})(["display:flex;box-sizing:border-box;", " ", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
223
326
|
return flexStyles(props.alignItems, props.justifyContent, props.wrapAll);
|
|
224
327
|
}, function (props) {
|
|
225
|
-
return sizeStyles(props);
|
|
328
|
+
return sizeStyles$1(props);
|
|
226
329
|
}, function (props) {
|
|
227
|
-
return props.debug && colorStyles(props);
|
|
330
|
+
return props.debug && colorStyles$1(props);
|
|
228
331
|
}, function (props) {
|
|
229
332
|
return mediaStyles(props.theme.breakpoints.xs, props.alignItemsXs, props.justifyContentXs, props.wrapXs);
|
|
230
333
|
}, function (props) {
|
|
@@ -236,13 +339,120 @@ var StyledRow = styled.div.attrs({
|
|
|
236
339
|
}, function (props) {
|
|
237
340
|
return mediaStyles(props.theme.breakpoints.xl, props.alignItemsXl, props.justifyContentXl, props.wrapXl);
|
|
238
341
|
}, function (props) {
|
|
239
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
342
|
+
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
240
343
|
});
|
|
241
344
|
StyledRow.defaultProps = {
|
|
242
345
|
wrapAll: 'wrap',
|
|
243
346
|
theme: DEFAULT_THEME
|
|
244
347
|
};
|
|
245
348
|
|
|
349
|
+
var COMPONENT_ID$2 = 'pane';
|
|
350
|
+
var StyledPane = styled.div.attrs({
|
|
351
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
352
|
+
'data-garden-version': '8.51.0'
|
|
353
|
+
}).withConfig({
|
|
354
|
+
displayName: "StyledPane",
|
|
355
|
+
componentId: "sc-1ltjst7-0"
|
|
356
|
+
})(["position:relative;min-width:0;min-height:0;", ";"], function (props) {
|
|
357
|
+
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
358
|
+
});
|
|
359
|
+
StyledPane.defaultProps = {
|
|
360
|
+
theme: DEFAULT_THEME
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
var COMPONENT_ID$1 = 'pane.content';
|
|
364
|
+
var StyledPaneContent = styled.div.attrs({
|
|
365
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
366
|
+
'data-garden-version': '8.51.0'
|
|
367
|
+
}).withConfig({
|
|
368
|
+
displayName: "StyledPaneContent",
|
|
369
|
+
componentId: "sc-1b38mbh-0"
|
|
370
|
+
})(["height:100%;overflow:auto;", ";"], function (props) {
|
|
371
|
+
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
372
|
+
});
|
|
373
|
+
StyledPaneContent.defaultProps = {
|
|
374
|
+
theme: DEFAULT_THEME
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
var COMPONENT_ID = 'pane.splitter';
|
|
378
|
+
var colorStyles = function colorStyles(props) {
|
|
379
|
+
var color = getColor('neutralHue', 300, props.theme);
|
|
380
|
+
var hoverColor = getColor('primaryHue', 600, props.theme);
|
|
381
|
+
var activeColor = getColor('primaryHue', 800, props.theme);
|
|
382
|
+
var boxShadow = props.theme.shadows.md(rgba(hoverColor, 0.35));
|
|
383
|
+
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);
|
|
384
|
+
};
|
|
385
|
+
var sizeStyles = function sizeStyles(props) {
|
|
386
|
+
var size = math("".concat(props.theme.shadowWidths.md, " * 2"));
|
|
387
|
+
var offset = math("-".concat(size, " / 2"));
|
|
388
|
+
var cursor;
|
|
389
|
+
var top;
|
|
390
|
+
var right;
|
|
391
|
+
var left;
|
|
392
|
+
var bottom;
|
|
393
|
+
var width;
|
|
394
|
+
var height;
|
|
395
|
+
var separatorWidth;
|
|
396
|
+
var separatorHeight;
|
|
397
|
+
switch (props.orientation) {
|
|
398
|
+
case 'top':
|
|
399
|
+
cursor = 'row-resize';
|
|
400
|
+
top = offset;
|
|
401
|
+
width = '100%';
|
|
402
|
+
height = size;
|
|
403
|
+
separatorWidth = width;
|
|
404
|
+
separatorHeight = props.theme.borderWidths.sm;
|
|
405
|
+
break;
|
|
406
|
+
case 'end':
|
|
407
|
+
cursor = 'col-resize';
|
|
408
|
+
top = 0;
|
|
409
|
+
width = size;
|
|
410
|
+
height = '100%';
|
|
411
|
+
separatorWidth = props.theme.borderWidths.sm;
|
|
412
|
+
separatorHeight = height;
|
|
413
|
+
if (props.theme.rtl) {
|
|
414
|
+
left = offset;
|
|
415
|
+
} else {
|
|
416
|
+
right = offset;
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
case 'bottom':
|
|
420
|
+
cursor = 'row-resize';
|
|
421
|
+
bottom = offset;
|
|
422
|
+
width = '100%';
|
|
423
|
+
height = size;
|
|
424
|
+
separatorWidth = width;
|
|
425
|
+
separatorHeight = props.theme.borderWidths.sm;
|
|
426
|
+
break;
|
|
427
|
+
case 'start':
|
|
428
|
+
cursor = 'col-resize';
|
|
429
|
+
top = 0;
|
|
430
|
+
width = size;
|
|
431
|
+
height = '100%';
|
|
432
|
+
separatorWidth = props.theme.borderWidths.sm;
|
|
433
|
+
separatorHeight = height;
|
|
434
|
+
if (props.theme.rtl) {
|
|
435
|
+
right = offset;
|
|
436
|
+
} else {
|
|
437
|
+
left = offset;
|
|
438
|
+
}
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
return css(["display:flex;top:", ";right:", ";bottom:", ";left:", ";cursor:", ";width:", ";height:", ";&::before{transition:box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,width 0.25s ease-in-out,height 0.25s ease-in-out;margin:auto;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);
|
|
442
|
+
};
|
|
443
|
+
var StyledPaneSplitter = styled.div.attrs({
|
|
444
|
+
'data-garden-id': COMPONENT_ID,
|
|
445
|
+
'data-garden-version': '8.51.0'
|
|
446
|
+
}).withConfig({
|
|
447
|
+
displayName: "StyledPaneSplitter",
|
|
448
|
+
componentId: "sc-jylemn-0"
|
|
449
|
+
})(["position:absolute;z-index:1;", ";&:hover,&[data-garden-focus-visible]{z-index:2;}&:focus{outline:none;}&::before{display:block;content:'';}", ";", ";"], sizeStyles, colorStyles, function (props) {
|
|
450
|
+
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
451
|
+
});
|
|
452
|
+
StyledPaneSplitter.defaultProps = {
|
|
453
|
+
theme: DEFAULT_THEME
|
|
454
|
+
};
|
|
455
|
+
|
|
246
456
|
var GridContext = createContext({
|
|
247
457
|
gutters: 'md'
|
|
248
458
|
});
|
|
@@ -250,10 +460,10 @@ var useGridContext = function useGridContext() {
|
|
|
250
460
|
return useContext(GridContext);
|
|
251
461
|
};
|
|
252
462
|
|
|
253
|
-
var _excluded$
|
|
463
|
+
var _excluded$4 = ["size"];
|
|
254
464
|
var Col = React.forwardRef(function (_ref, ref) {
|
|
255
465
|
var size = _ref.size,
|
|
256
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
466
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
257
467
|
var _useGridContext = useGridContext(),
|
|
258
468
|
columns = _useGridContext.columns,
|
|
259
469
|
gutters = _useGridContext.gutters,
|
|
@@ -300,11 +510,11 @@ Col.propTypes = {
|
|
|
300
510
|
orderXl: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
301
511
|
};
|
|
302
512
|
|
|
303
|
-
var _excluded$
|
|
513
|
+
var _excluded$3 = ["columns", "debug"];
|
|
304
514
|
var Grid = React.forwardRef(function (_ref, ref) {
|
|
305
515
|
var columns = _ref.columns,
|
|
306
516
|
debug = _ref.debug,
|
|
307
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
517
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
308
518
|
var value = useMemo(function () {
|
|
309
519
|
return {
|
|
310
520
|
columns: columns,
|
|
@@ -330,10 +540,10 @@ Grid.defaultProps = {
|
|
|
330
540
|
gutters: 'md'
|
|
331
541
|
};
|
|
332
542
|
|
|
333
|
-
var _excluded = ["wrap"];
|
|
543
|
+
var _excluded$2 = ["wrap"];
|
|
334
544
|
var Row = React.forwardRef(function (_ref, ref) {
|
|
335
545
|
var wrap = _ref.wrap,
|
|
336
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
546
|
+
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
337
547
|
var _useGridContext = useGridContext(),
|
|
338
548
|
gutters = _useGridContext.gutters,
|
|
339
549
|
debug = _useGridContext.debug;
|
|
@@ -366,4 +576,339 @@ Row.propTypes = {
|
|
|
366
576
|
wrapXl: PropTypes.oneOf(WRAP)
|
|
367
577
|
};
|
|
368
578
|
|
|
369
|
-
|
|
579
|
+
var SplitterContext = createContext({
|
|
580
|
+
setRowValue: function setRowValue() {
|
|
581
|
+
return undefined;
|
|
582
|
+
},
|
|
583
|
+
setColumnValue: function setColumnValue() {
|
|
584
|
+
return undefined;
|
|
585
|
+
},
|
|
586
|
+
getColumnValue: function getColumnValue() {
|
|
587
|
+
return 0;
|
|
588
|
+
},
|
|
589
|
+
getRowValue: function getRowValue() {
|
|
590
|
+
return 0;
|
|
591
|
+
},
|
|
592
|
+
rowState: {},
|
|
593
|
+
columnState: {},
|
|
594
|
+
totalPanesHeight: 1,
|
|
595
|
+
totalPanesWidth: 1,
|
|
596
|
+
pixelsPerFr: {
|
|
597
|
+
rows: 0,
|
|
598
|
+
columns: 0
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
var useSplitterContext = function useSplitterContext() {
|
|
602
|
+
return useContext(SplitterContext);
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
var getPixelsPerFr = function getPixelsPerFr(totalFrs, totalDimension) {
|
|
606
|
+
return totalDimension / totalFrs;
|
|
607
|
+
};
|
|
608
|
+
var convertToPixels = function convertToPixels(values, pixelsPerFr) {
|
|
609
|
+
return Object.entries(values).reduce(function (prev, _ref) {
|
|
610
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
611
|
+
key = _ref2[0],
|
|
612
|
+
value = _ref2[1];
|
|
613
|
+
prev[key] = value * pixelsPerFr;
|
|
614
|
+
return prev;
|
|
615
|
+
}, {});
|
|
616
|
+
};
|
|
617
|
+
var PaneProvider = function PaneProvider(_ref3) {
|
|
618
|
+
var totalPanesWidth = _ref3.totalPanesWidth,
|
|
619
|
+
totalPanesHeight = _ref3.totalPanesHeight,
|
|
620
|
+
defaultRowValues = _ref3.defaultRowValues,
|
|
621
|
+
defaultColumnValues = _ref3.defaultColumnValues,
|
|
622
|
+
rowValues = _ref3.rowValues,
|
|
623
|
+
columnValues = _ref3.columnValues,
|
|
624
|
+
onChange = _ref3.onChange,
|
|
625
|
+
children = _ref3.children;
|
|
626
|
+
var isControlled = rowValues !== undefined && rowValues !== null && columnValues !== undefined && columnValues !== null;
|
|
627
|
+
var _useState = useState(defaultRowValues || {}),
|
|
628
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
629
|
+
rowState = _useState2[0],
|
|
630
|
+
setRowState = _useState2[1];
|
|
631
|
+
var _useState3 = useState(defaultColumnValues || {}),
|
|
632
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
633
|
+
columnState = _useState4[0],
|
|
634
|
+
setColumnState = _useState4[1];
|
|
635
|
+
var rowsTrack = isControlled ? rowValues : rowState;
|
|
636
|
+
var columnsTrack = isControlled ? columnValues : columnState;
|
|
637
|
+
var setRowsTrack = useCallback(function (values) {
|
|
638
|
+
if (onChange) {
|
|
639
|
+
return onChange(values(rowsTrack), columnsTrack);
|
|
640
|
+
}
|
|
641
|
+
return setRowState(values);
|
|
642
|
+
}, [onChange, setRowState, columnsTrack, rowsTrack]);
|
|
643
|
+
var setColumnsTrack = useCallback(function (values) {
|
|
644
|
+
if (onChange) {
|
|
645
|
+
return onChange(rowsTrack, values(columnsTrack));
|
|
646
|
+
}
|
|
647
|
+
return setColumnState(values);
|
|
648
|
+
}, [onChange, setColumnState, rowsTrack, columnsTrack]);
|
|
649
|
+
var totalFractions = useMemo(function () {
|
|
650
|
+
return {
|
|
651
|
+
rows: Object.values(rowsTrack).reduce(function (prev, value) {
|
|
652
|
+
return value + prev;
|
|
653
|
+
}, 0),
|
|
654
|
+
columns: Object.values(columnsTrack).reduce(function (prev, value) {
|
|
655
|
+
return value + prev;
|
|
656
|
+
}, 0)
|
|
657
|
+
};
|
|
658
|
+
}, [rowsTrack, columnsTrack]);
|
|
659
|
+
var pixelsPerFr = useMemo(function () {
|
|
660
|
+
return {
|
|
661
|
+
rows: getPixelsPerFr(totalFractions.rows, totalPanesHeight),
|
|
662
|
+
columns: getPixelsPerFr(totalFractions.columns, totalPanesWidth)
|
|
663
|
+
};
|
|
664
|
+
}, [totalFractions, totalPanesHeight, totalPanesWidth]);
|
|
665
|
+
var layoutStateInPixels = useMemo(function () {
|
|
666
|
+
return {
|
|
667
|
+
rows: convertToPixels(rowsTrack, pixelsPerFr.rows),
|
|
668
|
+
columns: convertToPixels(columnsTrack, pixelsPerFr.columns)
|
|
669
|
+
};
|
|
670
|
+
}, [rowsTrack, columnsTrack, pixelsPerFr]);
|
|
671
|
+
var layoutIndices = useMemo(function () {
|
|
672
|
+
var rowArray = Object.keys(rowsTrack);
|
|
673
|
+
var columnArray = Object.keys(columnsTrack);
|
|
674
|
+
var rows = rowArray.reduce(function (prev, key, index) {
|
|
675
|
+
prev[key] = index;
|
|
676
|
+
return prev;
|
|
677
|
+
}, {});
|
|
678
|
+
var columns = columnArray.reduce(function (prev, key, index) {
|
|
679
|
+
prev[key] = index;
|
|
680
|
+
return prev;
|
|
681
|
+
}, {});
|
|
682
|
+
return {
|
|
683
|
+
rows: rows,
|
|
684
|
+
columns: columns,
|
|
685
|
+
rowArray: rowArray,
|
|
686
|
+
columnArray: columnArray
|
|
687
|
+
};
|
|
688
|
+
}, [rowsTrack, columnsTrack]);
|
|
689
|
+
var setRowValue = useCallback(function (isTop, id, value) {
|
|
690
|
+
var rows = layoutIndices.rows,
|
|
691
|
+
rowArray = layoutIndices.rowArray;
|
|
692
|
+
var stealFromTraversal = isTop ? -1 : 1;
|
|
693
|
+
var addToTraversal = 0;
|
|
694
|
+
setRowsTrack(function (state) {
|
|
695
|
+
var oldValue = rowsTrack[id];
|
|
696
|
+
var stealFromIndex = rows[id] + stealFromTraversal;
|
|
697
|
+
var addToIndex = rows[id] + addToTraversal;
|
|
698
|
+
var stealFromKey = rowArray[stealFromIndex];
|
|
699
|
+
var addToKey = rowArray[addToIndex];
|
|
700
|
+
var difference = oldValue - value;
|
|
701
|
+
var nextState = _objectSpread2({}, state);
|
|
702
|
+
nextState[addToKey] = rowsTrack[addToKey] - difference;
|
|
703
|
+
nextState[stealFromKey] = rowsTrack[stealFromKey] + difference;
|
|
704
|
+
return nextState;
|
|
705
|
+
});
|
|
706
|
+
}, [layoutIndices, rowsTrack, setRowsTrack]);
|
|
707
|
+
var setColumnValue = useCallback(function (isStart, id, value) {
|
|
708
|
+
var columns = layoutIndices.columns,
|
|
709
|
+
columnArray = layoutIndices.columnArray;
|
|
710
|
+
var stealFromTraversal = isStart ? 0 : 1;
|
|
711
|
+
var addToTraversal = isStart ? -1 : 0;
|
|
712
|
+
setColumnsTrack(function (state) {
|
|
713
|
+
var stealFromIndex = columns[id] + stealFromTraversal;
|
|
714
|
+
var addToIndex = columns[id] + addToTraversal;
|
|
715
|
+
var oldValue = columnsTrack[id];
|
|
716
|
+
var stealFromKey = columnArray[stealFromIndex];
|
|
717
|
+
var addToKey = columnArray[addToIndex];
|
|
718
|
+
var difference = oldValue - value;
|
|
719
|
+
var nextState = _objectSpread2({}, state);
|
|
720
|
+
nextState[addToKey] = columnsTrack[addToKey] - difference;
|
|
721
|
+
nextState[stealFromKey] = columnsTrack[stealFromKey] + difference;
|
|
722
|
+
return nextState;
|
|
723
|
+
});
|
|
724
|
+
}, [layoutIndices, columnsTrack, setColumnsTrack]);
|
|
725
|
+
var getColumnValue = useCallback(function (splitterKey, isPixels) {
|
|
726
|
+
if (isPixels) {
|
|
727
|
+
return layoutStateInPixels.columns[splitterKey];
|
|
728
|
+
}
|
|
729
|
+
return columnsTrack[splitterKey];
|
|
730
|
+
}, [columnsTrack, layoutStateInPixels]);
|
|
731
|
+
var getRowValue = useCallback(function (splitterKey, isPixels) {
|
|
732
|
+
if (isPixels) {
|
|
733
|
+
return layoutStateInPixels.rows[splitterKey];
|
|
734
|
+
}
|
|
735
|
+
return rowsTrack[splitterKey];
|
|
736
|
+
}, [rowsTrack, layoutStateInPixels]);
|
|
737
|
+
var getGridTemplateColumns = useCallback(function (isPixels) {
|
|
738
|
+
var columnArray = layoutIndices.columnArray;
|
|
739
|
+
if (isPixels) {
|
|
740
|
+
return columnArray.map(function (col) {
|
|
741
|
+
return "".concat(layoutStateInPixels.columns[col], "px");
|
|
742
|
+
}).join(' ');
|
|
743
|
+
}
|
|
744
|
+
return columnArray.map(function (col) {
|
|
745
|
+
return "".concat(columnsTrack[col], "fr");
|
|
746
|
+
}).join(' ');
|
|
747
|
+
}, [layoutIndices, columnsTrack, layoutStateInPixels]);
|
|
748
|
+
var getGridTemplateRows = useCallback(function (isPixels) {
|
|
749
|
+
var rowArray = layoutIndices.rowArray;
|
|
750
|
+
if (isPixels) {
|
|
751
|
+
return rowArray.map(function (row) {
|
|
752
|
+
return "".concat(layoutStateInPixels.rows[row], "px");
|
|
753
|
+
}).join(' ');
|
|
754
|
+
}
|
|
755
|
+
return rowArray.map(function (row) {
|
|
756
|
+
return "".concat(rowsTrack[row], "fr");
|
|
757
|
+
}).join(' ');
|
|
758
|
+
}, [layoutIndices, rowsTrack, layoutStateInPixels]);
|
|
759
|
+
var splitterContext = useMemo(function () {
|
|
760
|
+
return {
|
|
761
|
+
columnState: columnState,
|
|
762
|
+
rowState: rowState,
|
|
763
|
+
setRowValue: setRowValue,
|
|
764
|
+
setColumnValue: setColumnValue,
|
|
765
|
+
getRowValue: getRowValue,
|
|
766
|
+
getColumnValue: getColumnValue,
|
|
767
|
+
totalPanesHeight: totalPanesHeight,
|
|
768
|
+
totalPanesWidth: totalPanesWidth,
|
|
769
|
+
pixelsPerFr: pixelsPerFr
|
|
770
|
+
};
|
|
771
|
+
}, [rowState, columnState, setRowValue, setColumnValue, getRowValue, getColumnValue, totalPanesHeight, totalPanesWidth, pixelsPerFr]);
|
|
772
|
+
return React.createElement(SplitterContext.Provider, {
|
|
773
|
+
value: splitterContext
|
|
774
|
+
}, children === null || children === void 0 ? void 0 : children({
|
|
775
|
+
getRowValue: getRowValue,
|
|
776
|
+
getColumnValue: getColumnValue,
|
|
777
|
+
getGridTemplateColumns: getGridTemplateColumns,
|
|
778
|
+
getGridTemplateRows: getGridTemplateRows
|
|
779
|
+
}));
|
|
780
|
+
};
|
|
781
|
+
PaneProvider.displayName = 'PaneProvider';
|
|
782
|
+
PaneProvider.propTypes = {
|
|
783
|
+
totalPanesWidth: PropTypes.number.isRequired,
|
|
784
|
+
totalPanesHeight: PropTypes.number.isRequired,
|
|
785
|
+
defaultRowValues: PropTypes.object,
|
|
786
|
+
defaultColumnValues: PropTypes.object,
|
|
787
|
+
rowValues: PropTypes.object,
|
|
788
|
+
columnValues: PropTypes.object,
|
|
789
|
+
onChange: PropTypes.func,
|
|
790
|
+
children: PropTypes.func
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
var PaneContext = createContext({
|
|
794
|
+
setId: function setId() {
|
|
795
|
+
return undefined;
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
var usePaneContext = function usePaneContext() {
|
|
799
|
+
return useContext(PaneContext);
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
var _excluded$1 = ["layoutKey", "min", "max", "orientation"];
|
|
803
|
+
var orientationToPosition = {
|
|
804
|
+
start: SplitterPosition.TRAILS,
|
|
805
|
+
end: SplitterPosition.TRAILS,
|
|
806
|
+
top: SplitterPosition.LEADS,
|
|
807
|
+
bottom: SplitterPosition.TRAILS
|
|
808
|
+
};
|
|
809
|
+
var paneToSplitterOrientation = {
|
|
810
|
+
start: SplitterOrientation.VERTICAL,
|
|
811
|
+
end: SplitterOrientation.VERTICAL,
|
|
812
|
+
top: SplitterOrientation.HORIZONTAL,
|
|
813
|
+
bottom: SplitterOrientation.HORIZONTAL
|
|
814
|
+
};
|
|
815
|
+
var orientationToDimension = {
|
|
816
|
+
start: 'columns',
|
|
817
|
+
end: 'columns',
|
|
818
|
+
top: 'rows',
|
|
819
|
+
bottom: 'rows'
|
|
820
|
+
};
|
|
821
|
+
var SplitterComponent = forwardRef(function (_ref, ref) {
|
|
822
|
+
var layoutKey = _ref.layoutKey,
|
|
823
|
+
min = _ref.min,
|
|
824
|
+
max = _ref.max,
|
|
825
|
+
orientation = _ref.orientation,
|
|
826
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
827
|
+
var splitterContext = useSplitterContext();
|
|
828
|
+
var paneContext = usePaneContext();
|
|
829
|
+
var themeContext = useContext(ThemeContext);
|
|
830
|
+
var position = orientationToPosition[orientation];
|
|
831
|
+
var isRow = orientationToDimension[orientation] === 'rows';
|
|
832
|
+
var splitterOrientation = paneToSplitterOrientation[orientation];
|
|
833
|
+
var pixelsPerFr = splitterContext.pixelsPerFr[orientationToDimension[orientation]];
|
|
834
|
+
var _useSplitter = useSplitter({
|
|
835
|
+
type: SplitterType.VARIABLE,
|
|
836
|
+
orientation: splitterOrientation,
|
|
837
|
+
position: position,
|
|
838
|
+
min: min * pixelsPerFr,
|
|
839
|
+
max: max * pixelsPerFr,
|
|
840
|
+
rtl: themeContext.rtl,
|
|
841
|
+
environment: window,
|
|
842
|
+
onChange: function onChange(valueNow) {
|
|
843
|
+
if (isRow) {
|
|
844
|
+
return splitterContext.setRowValue(orientation === 'top', layoutKey, valueNow / pixelsPerFr);
|
|
845
|
+
}
|
|
846
|
+
return splitterContext.setColumnValue(orientation === 'start', layoutKey, valueNow / pixelsPerFr);
|
|
847
|
+
},
|
|
848
|
+
valueNow: isRow ? splitterContext.getRowValue(layoutKey, true) : splitterContext.getColumnValue(layoutKey, true)
|
|
849
|
+
}),
|
|
850
|
+
getSeparatorProps = _useSplitter.getSeparatorProps,
|
|
851
|
+
getPrimaryPaneProps = _useSplitter.getPrimaryPaneProps;
|
|
852
|
+
useEffect(function () {
|
|
853
|
+
if (!paneContext.id) {
|
|
854
|
+
paneContext.setId(getPrimaryPaneProps().id);
|
|
855
|
+
}
|
|
856
|
+
}, [paneContext, getPrimaryPaneProps]);
|
|
857
|
+
var separatorProps = getSeparatorProps({
|
|
858
|
+
'aria-controls': paneContext.id
|
|
859
|
+
});
|
|
860
|
+
return React.createElement(StyledPaneSplitter, _extends({
|
|
861
|
+
orientation: orientation
|
|
862
|
+
}, separatorProps, props, {
|
|
863
|
+
ref: mergeRefs([separatorProps.ref, ref])
|
|
864
|
+
}));
|
|
865
|
+
});
|
|
866
|
+
SplitterComponent.displayName = 'Pane.Splitter';
|
|
867
|
+
SplitterComponent.propTypes = {
|
|
868
|
+
layoutKey: PropTypes.string.isRequired,
|
|
869
|
+
min: PropTypes.number.isRequired,
|
|
870
|
+
max: PropTypes.number.isRequired,
|
|
871
|
+
orientation: PropTypes.oneOf(ORIENTATION)
|
|
872
|
+
};
|
|
873
|
+
SplitterComponent.defaultProps = {
|
|
874
|
+
orientation: 'end'
|
|
875
|
+
};
|
|
876
|
+
var Splitter = SplitterComponent;
|
|
877
|
+
|
|
878
|
+
var ContentComponent = forwardRef(function (props, ref) {
|
|
879
|
+
return React.createElement(StyledPaneContent, _extends({
|
|
880
|
+
ref: ref
|
|
881
|
+
}, props));
|
|
882
|
+
});
|
|
883
|
+
ContentComponent.displayName = 'Pane.Content';
|
|
884
|
+
var Content = ContentComponent;
|
|
885
|
+
|
|
886
|
+
var _excluded = ["children"];
|
|
887
|
+
var PaneComponent = forwardRef(function (_ref, ref) {
|
|
888
|
+
var children = _ref.children,
|
|
889
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
890
|
+
var _useState = useState(),
|
|
891
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
892
|
+
paneId = _useState2[0],
|
|
893
|
+
setPaneId = _useState2[1];
|
|
894
|
+
var paneContext = useMemo(function () {
|
|
895
|
+
return {
|
|
896
|
+
id: paneId,
|
|
897
|
+
setId: function setId(id) {
|
|
898
|
+
return setPaneId(id);
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
}, [paneId]);
|
|
902
|
+
return React.createElement(PaneContext.Provider, {
|
|
903
|
+
value: paneContext
|
|
904
|
+
}, React.createElement(StyledPane, _extends({
|
|
905
|
+
id: paneId,
|
|
906
|
+
ref: ref
|
|
907
|
+
}, props), children));
|
|
908
|
+
});
|
|
909
|
+
PaneComponent.displayName = 'Pane';
|
|
910
|
+
var Pane = PaneComponent;
|
|
911
|
+
Pane.Content = Content;
|
|
912
|
+
Pane.Splitter = Splitter;
|
|
913
|
+
|
|
914
|
+
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 };
|