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