@zendeskgarden/react-grid 8.52.0 → 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 +6 -2
- package/dist/index.cjs.js +185 -41
- package/dist/index.esm.js +186 -42
- package/dist/typings/elements/pane/Pane.d.ts +2 -0
- package/dist/typings/elements/pane/components/SplitterButton.d.ts +12 -0
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/styled/index.d.ts +1 -0
- package/dist/typings/styled/pane/StyledPaneSplitter.d.ts +4 -0
- package/dist/typings/styled/pane/StyledPaneSplitterButton.d.ts +19 -0
- package/dist/typings/types/index.d.ts +8 -1
- package/dist/typings/utils/usePaneSplitterContext.d.ts +23 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -84,11 +84,15 @@ import { PaneProvider, Pane } from '@zendeskgarden/react-grid';
|
|
|
84
84
|
</Pane>
|
|
85
85
|
<Pane>
|
|
86
86
|
<Pane.Content>Pane 2</Pane.Content>
|
|
87
|
-
<Pane.Splitter layoutKey="row-1" min={0} max={2} orientation="bottom"
|
|
87
|
+
<Pane.Splitter layoutKey="row-1" min={0} max={2} orientation="bottom">
|
|
88
|
+
<Pane.SplitterButton label="toggle row-1" />
|
|
89
|
+
</Pane.Splitter>
|
|
88
90
|
</Pane>
|
|
89
91
|
<Pane>
|
|
90
92
|
<Pane.Content>Pane 3</Pane.Content>
|
|
91
|
-
<Pane.Splitter layoutKey="row-2" min={0} max={2} orientation="top"
|
|
93
|
+
<Pane.Splitter layoutKey="row-2" min={0} max={2} orientation="top">
|
|
94
|
+
<Pane.SplitterButton label="toggle row-2" placement="end" />
|
|
95
|
+
</Pane.Splitter>
|
|
92
96
|
</Pane>
|
|
93
97
|
<Pane>
|
|
94
98
|
<Pane.Content>Pane 4</Pane.Content>
|
package/dist/index.cjs.js
CHANGED
|
@@ -14,9 +14,11 @@ var PropTypes = require('prop-types');
|
|
|
14
14
|
var styled = require('styled-components');
|
|
15
15
|
var polished = require('polished');
|
|
16
16
|
var reactTheming = require('@zendeskgarden/react-theming');
|
|
17
|
+
var reactButtons = require('@zendeskgarden/react-buttons');
|
|
17
18
|
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
18
19
|
var mergeRefs = require('react-merge-refs');
|
|
19
20
|
var containerSplitter = require('@zendeskgarden/container-splitter');
|
|
21
|
+
var reactTooltips = require('@zendeskgarden/react-tooltips');
|
|
20
22
|
|
|
21
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
24
|
|
|
@@ -188,7 +190,7 @@ var SPACE = [false, 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
|
188
190
|
var WRAP = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
189
191
|
var ORIENTATION = ['top', 'bottom', 'start', 'end'];
|
|
190
192
|
|
|
191
|
-
var COMPONENT_ID$
|
|
193
|
+
var COMPONENT_ID$6 = 'grid.col';
|
|
192
194
|
var colorStyles$3 = function colorStyles(props) {
|
|
193
195
|
var backgroundColor = reactTheming.getColor('primaryHue', 600, props.theme, 0.1);
|
|
194
196
|
return styled.css(["background-clip:content-box;background-color:", ";"], backgroundColor);
|
|
@@ -234,20 +236,20 @@ var flexStyles$1 = function flexStyles(size, alignSelf, textAlign, offset, order
|
|
|
234
236
|
var mediaStyles$1 = function mediaStyles(minWidth, size, alignSelf, textAlign, offset, order, props) {
|
|
235
237
|
return styled.css(["@media (min-width:", "){", ";}"], minWidth, flexStyles$1(size, alignSelf, textAlign, offset, order, props));
|
|
236
238
|
};
|
|
237
|
-
var sizeStyles$
|
|
239
|
+
var sizeStyles$4 = function sizeStyles(props) {
|
|
238
240
|
var padding = props.gutters ? polished.math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
239
241
|
return styled.css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
240
242
|
};
|
|
241
243
|
var StyledCol = styled__default["default"].div.attrs({
|
|
242
|
-
'data-garden-id': COMPONENT_ID$
|
|
243
|
-
'data-garden-version': '8.
|
|
244
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
245
|
+
'data-garden-version': '8.53.0'
|
|
244
246
|
}).withConfig({
|
|
245
247
|
displayName: "StyledCol",
|
|
246
248
|
componentId: "sc-inuw62-0"
|
|
247
249
|
})(["box-sizing:border-box;width:100%;", ";", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
248
250
|
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);
|
|
249
251
|
}, function (props) {
|
|
250
|
-
return sizeStyles$
|
|
252
|
+
return sizeStyles$4(props);
|
|
251
253
|
}, function (props) {
|
|
252
254
|
return props.debug && colorStyles$3(props);
|
|
253
255
|
}, function (props) {
|
|
@@ -261,44 +263,44 @@ var StyledCol = styled__default["default"].div.attrs({
|
|
|
261
263
|
}, function (props) {
|
|
262
264
|
return mediaStyles$1(props.theme.breakpoints.xl, props.xl, props.alignSelfXl, props.textAlignXl, props.offsetXl, props.orderXl, props);
|
|
263
265
|
}, function (props) {
|
|
264
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
266
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
265
267
|
});
|
|
266
268
|
StyledCol.defaultProps = {
|
|
267
269
|
columns: 12,
|
|
268
270
|
theme: reactTheming.DEFAULT_THEME
|
|
269
271
|
};
|
|
270
272
|
|
|
271
|
-
var COMPONENT_ID$
|
|
273
|
+
var COMPONENT_ID$5 = 'grid.grid';
|
|
272
274
|
var colorStyles$2 = function colorStyles(props) {
|
|
273
275
|
var borderColor = reactTheming.getColor(props.theme.palette.crimson, 400, props.theme, 0.5);
|
|
274
276
|
var borderWidth = polished.math("".concat(props.theme.borderWidths.sm, " * 2"));
|
|
275
277
|
return styled.css(["box-shadow:-", " 0 0 0 ", ",", " 0 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
276
278
|
};
|
|
277
|
-
var sizeStyles$
|
|
279
|
+
var sizeStyles$3 = function sizeStyles(props) {
|
|
278
280
|
var padding = props.gutters ? polished.math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
279
281
|
return styled.css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
280
282
|
};
|
|
281
283
|
var StyledGrid = styled__default["default"].div.attrs({
|
|
282
|
-
'data-garden-id': COMPONENT_ID$
|
|
283
|
-
'data-garden-version': '8.
|
|
284
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
285
|
+
'data-garden-version': '8.53.0'
|
|
284
286
|
}).withConfig({
|
|
285
287
|
displayName: "StyledGrid",
|
|
286
288
|
componentId: "sc-oxgg5i-0"
|
|
287
289
|
})(["direction:", ";margin-right:auto;margin-left:auto;width:100%;box-sizing:border-box;", ";", ";", ";"], function (props) {
|
|
288
290
|
return props.theme.rtl && 'rtl';
|
|
289
291
|
}, function (props) {
|
|
290
|
-
return sizeStyles$
|
|
292
|
+
return sizeStyles$3(props);
|
|
291
293
|
}, function (props) {
|
|
292
294
|
return props.debug && colorStyles$2(props);
|
|
293
295
|
}, function (props) {
|
|
294
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
296
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
295
297
|
});
|
|
296
298
|
StyledGrid.defaultProps = {
|
|
297
299
|
gutters: 'md',
|
|
298
300
|
theme: reactTheming.DEFAULT_THEME
|
|
299
301
|
};
|
|
300
302
|
|
|
301
|
-
var COMPONENT_ID$
|
|
303
|
+
var COMPONENT_ID$4 = 'grid.row';
|
|
302
304
|
var colorStyles$1 = function colorStyles(props) {
|
|
303
305
|
var borderColor = reactTheming.getColor(props.theme.palette.mint, 600, props.theme, 0.5);
|
|
304
306
|
var borderWidth = props.theme.borderWidths.sm;
|
|
@@ -324,20 +326,20 @@ var flexStyles = function flexStyles(alignItems, justifyContent, wrap) {
|
|
|
324
326
|
var mediaStyles = function mediaStyles(minWidth, alignItems, justifyContent, wrap) {
|
|
325
327
|
return styled.css(["@media (min-width:", "){", ";}"], minWidth, flexStyles(alignItems, justifyContent, wrap));
|
|
326
328
|
};
|
|
327
|
-
var sizeStyles$
|
|
329
|
+
var sizeStyles$2 = function sizeStyles(props) {
|
|
328
330
|
var margin = props.gutters ? polished.math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
329
331
|
return styled.css(["margin-right:-", ";margin-left:-", ";"], margin, margin);
|
|
330
332
|
};
|
|
331
333
|
var StyledRow = styled__default["default"].div.attrs({
|
|
332
|
-
'data-garden-id': COMPONENT_ID$
|
|
333
|
-
'data-garden-version': '8.
|
|
334
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
335
|
+
'data-garden-version': '8.53.0'
|
|
334
336
|
}).withConfig({
|
|
335
337
|
displayName: "StyledRow",
|
|
336
338
|
componentId: "sc-xjsdg1-0"
|
|
337
339
|
})(["display:flex;box-sizing:border-box;", " ", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
338
340
|
return flexStyles(props.alignItems, props.justifyContent, props.wrapAll);
|
|
339
341
|
}, function (props) {
|
|
340
|
-
return sizeStyles$
|
|
342
|
+
return sizeStyles$2(props);
|
|
341
343
|
}, function (props) {
|
|
342
344
|
return props.debug && colorStyles$1(props);
|
|
343
345
|
}, function (props) {
|
|
@@ -351,42 +353,42 @@ var StyledRow = styled__default["default"].div.attrs({
|
|
|
351
353
|
}, function (props) {
|
|
352
354
|
return mediaStyles(props.theme.breakpoints.xl, props.alignItemsXl, props.justifyContentXl, props.wrapXl);
|
|
353
355
|
}, function (props) {
|
|
354
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
356
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
355
357
|
});
|
|
356
358
|
StyledRow.defaultProps = {
|
|
357
359
|
wrapAll: 'wrap',
|
|
358
360
|
theme: reactTheming.DEFAULT_THEME
|
|
359
361
|
};
|
|
360
362
|
|
|
361
|
-
var COMPONENT_ID$
|
|
363
|
+
var COMPONENT_ID$3 = 'pane';
|
|
362
364
|
var StyledPane = styled__default["default"].div.attrs({
|
|
363
|
-
'data-garden-id': COMPONENT_ID$
|
|
364
|
-
'data-garden-version': '8.
|
|
365
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
366
|
+
'data-garden-version': '8.53.0'
|
|
365
367
|
}).withConfig({
|
|
366
368
|
displayName: "StyledPane",
|
|
367
369
|
componentId: "sc-1ltjst7-0"
|
|
368
370
|
})(["position:relative;min-width:0;min-height:0;", ";"], function (props) {
|
|
369
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
371
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
370
372
|
});
|
|
371
373
|
StyledPane.defaultProps = {
|
|
372
374
|
theme: reactTheming.DEFAULT_THEME
|
|
373
375
|
};
|
|
374
376
|
|
|
375
|
-
var COMPONENT_ID$
|
|
377
|
+
var COMPONENT_ID$2 = 'pane.content';
|
|
376
378
|
var StyledPaneContent = styled__default["default"].div.attrs({
|
|
377
|
-
'data-garden-id': COMPONENT_ID$
|
|
378
|
-
'data-garden-version': '8.
|
|
379
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
380
|
+
'data-garden-version': '8.53.0'
|
|
379
381
|
}).withConfig({
|
|
380
382
|
displayName: "StyledPaneContent",
|
|
381
383
|
componentId: "sc-1b38mbh-0"
|
|
382
384
|
})(["height:100%;overflow:auto;", ";"], function (props) {
|
|
383
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
385
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
384
386
|
});
|
|
385
387
|
StyledPaneContent.defaultProps = {
|
|
386
388
|
theme: reactTheming.DEFAULT_THEME
|
|
387
389
|
};
|
|
388
390
|
|
|
389
|
-
var COMPONENT_ID = 'pane.splitter';
|
|
391
|
+
var COMPONENT_ID$1 = 'pane.splitter';
|
|
390
392
|
var colorStyles = function colorStyles(props) {
|
|
391
393
|
var color = reactTheming.getColor('neutralHue', 300, props.theme);
|
|
392
394
|
var hoverColor = reactTheming.getColor('primaryHue', 600, props.theme);
|
|
@@ -394,7 +396,7 @@ var colorStyles = function colorStyles(props) {
|
|
|
394
396
|
var boxShadow = props.theme.shadows.md(polished.rgba(hoverColor, 0.35));
|
|
395
397
|
return styled.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);
|
|
396
398
|
};
|
|
397
|
-
var sizeStyles = function sizeStyles(props) {
|
|
399
|
+
var sizeStyles$1 = function sizeStyles(props) {
|
|
398
400
|
var size = polished.math("".concat(props.theme.shadowWidths.md, " * 2"));
|
|
399
401
|
var offset = polished.math("-".concat(size, " / 2"));
|
|
400
402
|
var cursor;
|
|
@@ -450,21 +452,80 @@ var sizeStyles = function sizeStyles(props) {
|
|
|
450
452
|
}
|
|
451
453
|
break;
|
|
452
454
|
}
|
|
453
|
-
return styled.css(["
|
|
455
|
+
return styled.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', polished.math("".concat(props.theme.borderWidths.sm, " * 2")), props.theme.borderRadii.md);
|
|
454
456
|
};
|
|
455
457
|
var StyledPaneSplitter = styled__default["default"].div.attrs({
|
|
456
|
-
'data-garden-id': COMPONENT_ID,
|
|
457
|
-
'data-garden-version': '8.
|
|
458
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
459
|
+
'data-garden-version': '8.53.0'
|
|
458
460
|
}).withConfig({
|
|
459
461
|
displayName: "StyledPaneSplitter",
|
|
460
462
|
componentId: "sc-jylemn-0"
|
|
461
|
-
})(["position:absolute;z-index:1;user-select:none;", ";&:
|
|
462
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID, props);
|
|
463
|
+
})(["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) {
|
|
464
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
463
465
|
});
|
|
464
466
|
StyledPaneSplitter.defaultProps = {
|
|
465
467
|
theme: reactTheming.DEFAULT_THEME
|
|
466
468
|
};
|
|
467
469
|
|
|
470
|
+
var COMPONENT_ID = 'pane.splitter_button';
|
|
471
|
+
var transformStyles = function transformStyles(props) {
|
|
472
|
+
var degrees = 0;
|
|
473
|
+
if (props.isRotated) {
|
|
474
|
+
degrees = props.theme.rtl ? -180 : 180;
|
|
475
|
+
}
|
|
476
|
+
if (props.orientation === 'end') {
|
|
477
|
+
degrees += props.theme.rtl ? -90 : 90;
|
|
478
|
+
} else if (props.orientation === 'start') {
|
|
479
|
+
degrees += props.theme.rtl ? 90 : -90;
|
|
480
|
+
} else if (props.orientation === 'bottom') {
|
|
481
|
+
degrees += 180;
|
|
482
|
+
}
|
|
483
|
+
return styled.css(["& > svg{transform:rotate(", "deg);}"], degrees);
|
|
484
|
+
};
|
|
485
|
+
var sizeStyles = function sizeStyles(props) {
|
|
486
|
+
var size = "".concat(props.theme.space.base * 6, "px");
|
|
487
|
+
var isVertical = props.orientation === 'start' || props.orientation === 'end';
|
|
488
|
+
var top;
|
|
489
|
+
var left;
|
|
490
|
+
var right;
|
|
491
|
+
var bottom;
|
|
492
|
+
if (props.placement === 'start') {
|
|
493
|
+
if (isVertical) {
|
|
494
|
+
top = size;
|
|
495
|
+
} else if (props.theme.rtl) {
|
|
496
|
+
right = size;
|
|
497
|
+
} else {
|
|
498
|
+
left = size;
|
|
499
|
+
}
|
|
500
|
+
} else if (props.placement === 'end') {
|
|
501
|
+
if (isVertical) {
|
|
502
|
+
bottom = size;
|
|
503
|
+
} else if (props.theme.rtl) {
|
|
504
|
+
left = size;
|
|
505
|
+
} else {
|
|
506
|
+
right = size;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return styled.css(["top:", ";right:", ";bottom:", ";left:", ";width:", ";min-width:", ";height:", ";"], top, right, bottom, left, size, size, size);
|
|
510
|
+
};
|
|
511
|
+
var StyledPaneSplitterButton = styled__default["default"](reactButtons.ChevronButton).attrs({
|
|
512
|
+
'data-garden-id': COMPONENT_ID,
|
|
513
|
+
'data-garden-version': '8.53.0',
|
|
514
|
+
isBasic: true,
|
|
515
|
+
isPill: true,
|
|
516
|
+
size: 'small'
|
|
517
|
+
}).withConfig({
|
|
518
|
+
displayName: "StyledPaneSplitterButton",
|
|
519
|
+
componentId: "sc-zh032e-0"
|
|
520
|
+
})(["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) {
|
|
521
|
+
return props.theme.colors.background;
|
|
522
|
+
}, function (props) {
|
|
523
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID, props);
|
|
524
|
+
});
|
|
525
|
+
StyledPaneSplitterButton.defaultProps = {
|
|
526
|
+
theme: reactTheming.DEFAULT_THEME
|
|
527
|
+
};
|
|
528
|
+
|
|
468
529
|
var GridContext = React.createContext({
|
|
469
530
|
gutters: 'md'
|
|
470
531
|
});
|
|
@@ -704,8 +765,8 @@ var PaneProvider = function PaneProvider(_ref3) {
|
|
|
704
765
|
var setColumnValue = React.useCallback(function (isStart, splitterId, value) {
|
|
705
766
|
var columns = layoutIndices.columns,
|
|
706
767
|
columnArray = layoutIndices.columnArray;
|
|
707
|
-
var stealFromTraversal = isStart ?
|
|
708
|
-
var addToTraversal =
|
|
768
|
+
var stealFromTraversal = isStart ? -1 : 1;
|
|
769
|
+
var addToTraversal = 0;
|
|
709
770
|
setColumnsTrack(function (state) {
|
|
710
771
|
var stealFromIndex = columns[splitterId] + stealFromTraversal;
|
|
711
772
|
var addToIndex = columns[splitterId] + addToTraversal;
|
|
@@ -803,9 +864,21 @@ var usePaneContext = function usePaneContext() {
|
|
|
803
864
|
return React.useContext(PaneContext);
|
|
804
865
|
};
|
|
805
866
|
|
|
867
|
+
var PaneSplitterContext = React.createContext({
|
|
868
|
+
orientation: 'start',
|
|
869
|
+
min: 0,
|
|
870
|
+
max: 0,
|
|
871
|
+
layoutKey: '',
|
|
872
|
+
valueNow: 0,
|
|
873
|
+
isRow: false
|
|
874
|
+
});
|
|
875
|
+
var usePaneSplitterContext = function usePaneSplitterContext() {
|
|
876
|
+
return React.useContext(PaneSplitterContext);
|
|
877
|
+
};
|
|
878
|
+
|
|
806
879
|
var _excluded$1 = ["providerId", "layoutKey", "min", "max", "orientation"];
|
|
807
880
|
var orientationToPosition = {
|
|
808
|
-
start: containerSplitter.SplitterPosition.
|
|
881
|
+
start: containerSplitter.SplitterPosition.LEADS,
|
|
809
882
|
end: containerSplitter.SplitterPosition.TRAILS,
|
|
810
883
|
top: containerSplitter.SplitterPosition.LEADS,
|
|
811
884
|
bottom: containerSplitter.SplitterPosition.TRAILS
|
|
@@ -836,6 +909,8 @@ var SplitterComponent = React.forwardRef(function (_ref, ref) {
|
|
|
836
909
|
var isRow = orientationToDimension[orientation] === 'rows';
|
|
837
910
|
var splitterOrientation = paneToSplitterOrientation[orientation];
|
|
838
911
|
var pixelsPerFr = paneProviderContext ? paneProviderContext.pixelsPerFr[orientationToDimension[orientation]] : 0;
|
|
912
|
+
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);
|
|
913
|
+
var valueInFr = isRow ? paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getRowValue(layoutKey) : paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getColumnValue(layoutKey);
|
|
839
914
|
var _useSplitter = containerSplitter.useSplitter({
|
|
840
915
|
type: containerSplitter.SplitterType.VARIABLE,
|
|
841
916
|
orientation: splitterOrientation,
|
|
@@ -846,11 +921,11 @@ var SplitterComponent = React.forwardRef(function (_ref, ref) {
|
|
|
846
921
|
environment: window,
|
|
847
922
|
onChange: function onChange(valueNow) {
|
|
848
923
|
if (isRow) {
|
|
849
|
-
return paneProviderContext
|
|
924
|
+
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setRowValue(orientation === 'top', layoutKey, valueNow / pixelsPerFr);
|
|
850
925
|
}
|
|
851
|
-
return paneProviderContext
|
|
926
|
+
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setColumnValue(orientation === 'start', layoutKey, valueNow / pixelsPerFr);
|
|
852
927
|
},
|
|
853
|
-
valueNow:
|
|
928
|
+
valueNow: value
|
|
854
929
|
}),
|
|
855
930
|
getSeparatorProps = _useSplitter.getSeparatorProps,
|
|
856
931
|
getPrimaryPaneProps = _useSplitter.getPrimaryPaneProps;
|
|
@@ -862,11 +937,22 @@ var SplitterComponent = React.forwardRef(function (_ref, ref) {
|
|
|
862
937
|
var separatorProps = getSeparatorProps({
|
|
863
938
|
'aria-controls': paneContext.id
|
|
864
939
|
});
|
|
865
|
-
return React__default["default"].createElement(
|
|
940
|
+
return React__default["default"].createElement(PaneSplitterContext.Provider, {
|
|
941
|
+
value: React.useMemo(function () {
|
|
942
|
+
return {
|
|
943
|
+
orientation: orientation,
|
|
944
|
+
layoutKey: layoutKey,
|
|
945
|
+
min: min,
|
|
946
|
+
max: max,
|
|
947
|
+
valueNow: valueInFr,
|
|
948
|
+
isRow: isRow
|
|
949
|
+
};
|
|
950
|
+
}, [orientation, layoutKey, min, max, valueInFr, isRow])
|
|
951
|
+
}, React__default["default"].createElement(StyledPaneSplitter, _extends({
|
|
866
952
|
orientation: orientation
|
|
867
953
|
}, separatorProps, props, {
|
|
868
954
|
ref: mergeRefs__default["default"]([separatorProps.ref, ref])
|
|
869
|
-
}));
|
|
955
|
+
})));
|
|
870
956
|
});
|
|
871
957
|
SplitterComponent.displayName = 'Pane.Splitter';
|
|
872
958
|
SplitterComponent.propTypes = {
|
|
@@ -888,6 +974,63 @@ var ContentComponent = React.forwardRef(function (props, ref) {
|
|
|
888
974
|
ContentComponent.displayName = 'Pane.Content';
|
|
889
975
|
var Content = ContentComponent;
|
|
890
976
|
|
|
977
|
+
var SplitterButtonComponent = React.forwardRef(function (props, ref) {
|
|
978
|
+
var label = props.label,
|
|
979
|
+
defaultPlacement = props.placement;
|
|
980
|
+
var _usePaneSplitterConte = usePaneSplitterContext(),
|
|
981
|
+
orientation = _usePaneSplitterConte.orientation,
|
|
982
|
+
layoutKey = _usePaneSplitterConte.layoutKey,
|
|
983
|
+
min = _usePaneSplitterConte.min,
|
|
984
|
+
max = _usePaneSplitterConte.max,
|
|
985
|
+
isRow = _usePaneSplitterConte.isRow,
|
|
986
|
+
valueNow = _usePaneSplitterConte.valueNow,
|
|
987
|
+
providerId = _usePaneSplitterConte.providerId;
|
|
988
|
+
var paneProviderContext = usePaneProviderContextData(providerId);
|
|
989
|
+
var isTop = orientation === 'top';
|
|
990
|
+
var isStart = orientation === 'start';
|
|
991
|
+
var isMin = valueNow === min;
|
|
992
|
+
var placement = defaultPlacement;
|
|
993
|
+
if (!defaultPlacement) {
|
|
994
|
+
if (isRow) {
|
|
995
|
+
placement = 'center';
|
|
996
|
+
} else {
|
|
997
|
+
placement = 'start';
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
var setValue = React.useCallback(function (value) {
|
|
1001
|
+
if (isRow) {
|
|
1002
|
+
paneProviderContext.setRowValue(isTop, layoutKey, value);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
paneProviderContext.setColumnValue(isStart, layoutKey, value);
|
|
1006
|
+
}, [isRow, isTop, isStart, layoutKey, paneProviderContext]);
|
|
1007
|
+
var onClick = containerUtilities.composeEventHandlers(props.onClick, function () {
|
|
1008
|
+
if (isMin) {
|
|
1009
|
+
setValue(max);
|
|
1010
|
+
} else {
|
|
1011
|
+
setValue(min);
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
var onKeyDown = containerUtilities.composeEventHandlers(props.onKeyDown, function (event) {
|
|
1015
|
+
return event.stopPropagation();
|
|
1016
|
+
}
|
|
1017
|
+
);
|
|
1018
|
+
return React__default["default"].createElement(reactTooltips.Tooltip, {
|
|
1019
|
+
content: label
|
|
1020
|
+
}, React__default["default"].createElement(StyledPaneSplitterButton, _extends({
|
|
1021
|
+
"aria-label": label
|
|
1022
|
+
}, props, {
|
|
1023
|
+
placement: placement,
|
|
1024
|
+
orientation: orientation,
|
|
1025
|
+
isRotated: isMin,
|
|
1026
|
+
ref: ref,
|
|
1027
|
+
onClick: onClick,
|
|
1028
|
+
onKeyDown: onKeyDown
|
|
1029
|
+
})));
|
|
1030
|
+
});
|
|
1031
|
+
SplitterButtonComponent.displayName = 'Pane.SplitterButton';
|
|
1032
|
+
var SplitterButton = SplitterButtonComponent;
|
|
1033
|
+
|
|
891
1034
|
var _excluded = ["children"];
|
|
892
1035
|
var PaneComponent = React.forwardRef(function (_ref, ref) {
|
|
893
1036
|
var children = _ref.children,
|
|
@@ -915,6 +1058,7 @@ PaneComponent.displayName = 'Pane';
|
|
|
915
1058
|
var Pane = PaneComponent;
|
|
916
1059
|
Pane.Content = Content;
|
|
917
1060
|
Pane.Splitter = Splitter;
|
|
1061
|
+
Pane.SplitterButton = SplitterButton;
|
|
918
1062
|
|
|
919
1063
|
exports.ARRAY_ALIGN_ITEMS = ALIGN_ITEMS;
|
|
920
1064
|
exports.ARRAY_ALIGN_SELF = ALIGN_SELF;
|
package/dist/index.esm.js
CHANGED
|
@@ -10,9 +10,11 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
import styled, { css, ThemeContext } from 'styled-components';
|
|
11
11
|
import { math, rgba } from 'polished';
|
|
12
12
|
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
13
|
-
import {
|
|
13
|
+
import { ChevronButton } from '@zendeskgarden/react-buttons';
|
|
14
|
+
import { useId, composeEventHandlers } from '@zendeskgarden/container-utilities';
|
|
14
15
|
import mergeRefs from 'react-merge-refs';
|
|
15
16
|
import { SplitterPosition, SplitterOrientation, useSplitter, SplitterType } from '@zendeskgarden/container-splitter';
|
|
17
|
+
import { Tooltip } from '@zendeskgarden/react-tooltips';
|
|
16
18
|
|
|
17
19
|
function ownKeys(object, enumerableOnly) {
|
|
18
20
|
var keys = Object.keys(object);
|
|
@@ -177,7 +179,7 @@ var SPACE = [false, 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
|
177
179
|
var WRAP = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
178
180
|
var ORIENTATION = ['top', 'bottom', 'start', 'end'];
|
|
179
181
|
|
|
180
|
-
var COMPONENT_ID$
|
|
182
|
+
var COMPONENT_ID$6 = 'grid.col';
|
|
181
183
|
var colorStyles$3 = function colorStyles(props) {
|
|
182
184
|
var backgroundColor = getColor('primaryHue', 600, props.theme, 0.1);
|
|
183
185
|
return css(["background-clip:content-box;background-color:", ";"], backgroundColor);
|
|
@@ -223,20 +225,20 @@ var flexStyles$1 = function flexStyles(size, alignSelf, textAlign, offset, order
|
|
|
223
225
|
var mediaStyles$1 = function mediaStyles(minWidth, size, alignSelf, textAlign, offset, order, props) {
|
|
224
226
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles$1(size, alignSelf, textAlign, offset, order, props));
|
|
225
227
|
};
|
|
226
|
-
var sizeStyles$
|
|
228
|
+
var sizeStyles$4 = function sizeStyles(props) {
|
|
227
229
|
var padding = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
228
230
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
229
231
|
};
|
|
230
232
|
var StyledCol = styled.div.attrs({
|
|
231
|
-
'data-garden-id': COMPONENT_ID$
|
|
232
|
-
'data-garden-version': '8.
|
|
233
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
234
|
+
'data-garden-version': '8.53.0'
|
|
233
235
|
}).withConfig({
|
|
234
236
|
displayName: "StyledCol",
|
|
235
237
|
componentId: "sc-inuw62-0"
|
|
236
238
|
})(["box-sizing:border-box;width:100%;", ";", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
237
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);
|
|
238
240
|
}, function (props) {
|
|
239
|
-
return sizeStyles$
|
|
241
|
+
return sizeStyles$4(props);
|
|
240
242
|
}, function (props) {
|
|
241
243
|
return props.debug && colorStyles$3(props);
|
|
242
244
|
}, function (props) {
|
|
@@ -250,44 +252,44 @@ var StyledCol = styled.div.attrs({
|
|
|
250
252
|
}, function (props) {
|
|
251
253
|
return mediaStyles$1(props.theme.breakpoints.xl, props.xl, props.alignSelfXl, props.textAlignXl, props.offsetXl, props.orderXl, props);
|
|
252
254
|
}, function (props) {
|
|
253
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
255
|
+
return retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
254
256
|
});
|
|
255
257
|
StyledCol.defaultProps = {
|
|
256
258
|
columns: 12,
|
|
257
259
|
theme: DEFAULT_THEME
|
|
258
260
|
};
|
|
259
261
|
|
|
260
|
-
var COMPONENT_ID$
|
|
262
|
+
var COMPONENT_ID$5 = 'grid.grid';
|
|
261
263
|
var colorStyles$2 = function colorStyles(props) {
|
|
262
264
|
var borderColor = getColor(props.theme.palette.crimson, 400, props.theme, 0.5);
|
|
263
265
|
var borderWidth = math("".concat(props.theme.borderWidths.sm, " * 2"));
|
|
264
266
|
return css(["box-shadow:-", " 0 0 0 ", ",", " 0 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
265
267
|
};
|
|
266
|
-
var sizeStyles$
|
|
268
|
+
var sizeStyles$3 = function sizeStyles(props) {
|
|
267
269
|
var padding = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
268
270
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
269
271
|
};
|
|
270
272
|
var StyledGrid = styled.div.attrs({
|
|
271
|
-
'data-garden-id': COMPONENT_ID$
|
|
272
|
-
'data-garden-version': '8.
|
|
273
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
274
|
+
'data-garden-version': '8.53.0'
|
|
273
275
|
}).withConfig({
|
|
274
276
|
displayName: "StyledGrid",
|
|
275
277
|
componentId: "sc-oxgg5i-0"
|
|
276
278
|
})(["direction:", ";margin-right:auto;margin-left:auto;width:100%;box-sizing:border-box;", ";", ";", ";"], function (props) {
|
|
277
279
|
return props.theme.rtl && 'rtl';
|
|
278
280
|
}, function (props) {
|
|
279
|
-
return sizeStyles$
|
|
281
|
+
return sizeStyles$3(props);
|
|
280
282
|
}, function (props) {
|
|
281
283
|
return props.debug && colorStyles$2(props);
|
|
282
284
|
}, function (props) {
|
|
283
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
285
|
+
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
284
286
|
});
|
|
285
287
|
StyledGrid.defaultProps = {
|
|
286
288
|
gutters: 'md',
|
|
287
289
|
theme: DEFAULT_THEME
|
|
288
290
|
};
|
|
289
291
|
|
|
290
|
-
var COMPONENT_ID$
|
|
292
|
+
var COMPONENT_ID$4 = 'grid.row';
|
|
291
293
|
var colorStyles$1 = function colorStyles(props) {
|
|
292
294
|
var borderColor = getColor(props.theme.palette.mint, 600, props.theme, 0.5);
|
|
293
295
|
var borderWidth = props.theme.borderWidths.sm;
|
|
@@ -313,20 +315,20 @@ var flexStyles = function flexStyles(alignItems, justifyContent, wrap) {
|
|
|
313
315
|
var mediaStyles = function mediaStyles(minWidth, alignItems, justifyContent, wrap) {
|
|
314
316
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles(alignItems, justifyContent, wrap));
|
|
315
317
|
};
|
|
316
|
-
var sizeStyles$
|
|
318
|
+
var sizeStyles$2 = function sizeStyles(props) {
|
|
317
319
|
var margin = props.gutters ? math("".concat(props.theme.space[props.gutters], " / 2")) : 0;
|
|
318
320
|
return css(["margin-right:-", ";margin-left:-", ";"], margin, margin);
|
|
319
321
|
};
|
|
320
322
|
var StyledRow = styled.div.attrs({
|
|
321
|
-
'data-garden-id': COMPONENT_ID$
|
|
322
|
-
'data-garden-version': '8.
|
|
323
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
324
|
+
'data-garden-version': '8.53.0'
|
|
323
325
|
}).withConfig({
|
|
324
326
|
displayName: "StyledRow",
|
|
325
327
|
componentId: "sc-xjsdg1-0"
|
|
326
328
|
})(["display:flex;box-sizing:border-box;", " ", ";", ";", ";", ";", ";", ";", ";", ";"], function (props) {
|
|
327
329
|
return flexStyles(props.alignItems, props.justifyContent, props.wrapAll);
|
|
328
330
|
}, function (props) {
|
|
329
|
-
return sizeStyles$
|
|
331
|
+
return sizeStyles$2(props);
|
|
330
332
|
}, function (props) {
|
|
331
333
|
return props.debug && colorStyles$1(props);
|
|
332
334
|
}, function (props) {
|
|
@@ -340,42 +342,42 @@ var StyledRow = styled.div.attrs({
|
|
|
340
342
|
}, function (props) {
|
|
341
343
|
return mediaStyles(props.theme.breakpoints.xl, props.alignItemsXl, props.justifyContentXl, props.wrapXl);
|
|
342
344
|
}, function (props) {
|
|
343
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
345
|
+
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
344
346
|
});
|
|
345
347
|
StyledRow.defaultProps = {
|
|
346
348
|
wrapAll: 'wrap',
|
|
347
349
|
theme: DEFAULT_THEME
|
|
348
350
|
};
|
|
349
351
|
|
|
350
|
-
var COMPONENT_ID$
|
|
352
|
+
var COMPONENT_ID$3 = 'pane';
|
|
351
353
|
var StyledPane = styled.div.attrs({
|
|
352
|
-
'data-garden-id': COMPONENT_ID$
|
|
353
|
-
'data-garden-version': '8.
|
|
354
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
355
|
+
'data-garden-version': '8.53.0'
|
|
354
356
|
}).withConfig({
|
|
355
357
|
displayName: "StyledPane",
|
|
356
358
|
componentId: "sc-1ltjst7-0"
|
|
357
359
|
})(["position:relative;min-width:0;min-height:0;", ";"], function (props) {
|
|
358
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
360
|
+
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
359
361
|
});
|
|
360
362
|
StyledPane.defaultProps = {
|
|
361
363
|
theme: DEFAULT_THEME
|
|
362
364
|
};
|
|
363
365
|
|
|
364
|
-
var COMPONENT_ID$
|
|
366
|
+
var COMPONENT_ID$2 = 'pane.content';
|
|
365
367
|
var StyledPaneContent = styled.div.attrs({
|
|
366
|
-
'data-garden-id': COMPONENT_ID$
|
|
367
|
-
'data-garden-version': '8.
|
|
368
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
369
|
+
'data-garden-version': '8.53.0'
|
|
368
370
|
}).withConfig({
|
|
369
371
|
displayName: "StyledPaneContent",
|
|
370
372
|
componentId: "sc-1b38mbh-0"
|
|
371
373
|
})(["height:100%;overflow:auto;", ";"], function (props) {
|
|
372
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
374
|
+
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
373
375
|
});
|
|
374
376
|
StyledPaneContent.defaultProps = {
|
|
375
377
|
theme: DEFAULT_THEME
|
|
376
378
|
};
|
|
377
379
|
|
|
378
|
-
var COMPONENT_ID = 'pane.splitter';
|
|
380
|
+
var COMPONENT_ID$1 = 'pane.splitter';
|
|
379
381
|
var colorStyles = function colorStyles(props) {
|
|
380
382
|
var color = getColor('neutralHue', 300, props.theme);
|
|
381
383
|
var hoverColor = getColor('primaryHue', 600, props.theme);
|
|
@@ -383,7 +385,7 @@ var colorStyles = function colorStyles(props) {
|
|
|
383
385
|
var boxShadow = props.theme.shadows.md(rgba(hoverColor, 0.35));
|
|
384
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);
|
|
385
387
|
};
|
|
386
|
-
var sizeStyles = function sizeStyles(props) {
|
|
388
|
+
var sizeStyles$1 = function sizeStyles(props) {
|
|
387
389
|
var size = math("".concat(props.theme.shadowWidths.md, " * 2"));
|
|
388
390
|
var offset = math("-".concat(size, " / 2"));
|
|
389
391
|
var cursor;
|
|
@@ -439,21 +441,80 @@ var sizeStyles = function sizeStyles(props) {
|
|
|
439
441
|
}
|
|
440
442
|
break;
|
|
441
443
|
}
|
|
442
|
-
return css(["
|
|
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);
|
|
443
445
|
};
|
|
444
446
|
var StyledPaneSplitter = styled.div.attrs({
|
|
445
|
-
'data-garden-id': COMPONENT_ID,
|
|
446
|
-
'data-garden-version': '8.
|
|
447
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
448
|
+
'data-garden-version': '8.53.0'
|
|
447
449
|
}).withConfig({
|
|
448
450
|
displayName: "StyledPaneSplitter",
|
|
449
451
|
componentId: "sc-jylemn-0"
|
|
450
|
-
})(["position:absolute;z-index:1;user-select:none;", ";&:
|
|
451
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
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);
|
|
452
454
|
});
|
|
453
455
|
StyledPaneSplitter.defaultProps = {
|
|
454
456
|
theme: DEFAULT_THEME
|
|
455
457
|
};
|
|
456
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
|
+
|
|
457
518
|
var GridContext = createContext({
|
|
458
519
|
gutters: 'md'
|
|
459
520
|
});
|
|
@@ -693,8 +754,8 @@ var PaneProvider = function PaneProvider(_ref3) {
|
|
|
693
754
|
var setColumnValue = useCallback(function (isStart, splitterId, value) {
|
|
694
755
|
var columns = layoutIndices.columns,
|
|
695
756
|
columnArray = layoutIndices.columnArray;
|
|
696
|
-
var stealFromTraversal = isStart ?
|
|
697
|
-
var addToTraversal =
|
|
757
|
+
var stealFromTraversal = isStart ? -1 : 1;
|
|
758
|
+
var addToTraversal = 0;
|
|
698
759
|
setColumnsTrack(function (state) {
|
|
699
760
|
var stealFromIndex = columns[splitterId] + stealFromTraversal;
|
|
700
761
|
var addToIndex = columns[splitterId] + addToTraversal;
|
|
@@ -792,9 +853,21 @@ var usePaneContext = function usePaneContext() {
|
|
|
792
853
|
return useContext(PaneContext);
|
|
793
854
|
};
|
|
794
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
|
+
|
|
795
868
|
var _excluded$1 = ["providerId", "layoutKey", "min", "max", "orientation"];
|
|
796
869
|
var orientationToPosition = {
|
|
797
|
-
start: SplitterPosition.
|
|
870
|
+
start: SplitterPosition.LEADS,
|
|
798
871
|
end: SplitterPosition.TRAILS,
|
|
799
872
|
top: SplitterPosition.LEADS,
|
|
800
873
|
bottom: SplitterPosition.TRAILS
|
|
@@ -825,6 +898,8 @@ var SplitterComponent = forwardRef(function (_ref, ref) {
|
|
|
825
898
|
var isRow = orientationToDimension[orientation] === 'rows';
|
|
826
899
|
var splitterOrientation = paneToSplitterOrientation[orientation];
|
|
827
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);
|
|
828
903
|
var _useSplitter = useSplitter({
|
|
829
904
|
type: SplitterType.VARIABLE,
|
|
830
905
|
orientation: splitterOrientation,
|
|
@@ -835,11 +910,11 @@ var SplitterComponent = forwardRef(function (_ref, ref) {
|
|
|
835
910
|
environment: window,
|
|
836
911
|
onChange: function onChange(valueNow) {
|
|
837
912
|
if (isRow) {
|
|
838
|
-
return paneProviderContext
|
|
913
|
+
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setRowValue(orientation === 'top', layoutKey, valueNow / pixelsPerFr);
|
|
839
914
|
}
|
|
840
|
-
return paneProviderContext
|
|
915
|
+
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setColumnValue(orientation === 'start', layoutKey, valueNow / pixelsPerFr);
|
|
841
916
|
},
|
|
842
|
-
valueNow:
|
|
917
|
+
valueNow: value
|
|
843
918
|
}),
|
|
844
919
|
getSeparatorProps = _useSplitter.getSeparatorProps,
|
|
845
920
|
getPrimaryPaneProps = _useSplitter.getPrimaryPaneProps;
|
|
@@ -851,11 +926,22 @@ var SplitterComponent = forwardRef(function (_ref, ref) {
|
|
|
851
926
|
var separatorProps = getSeparatorProps({
|
|
852
927
|
'aria-controls': paneContext.id
|
|
853
928
|
});
|
|
854
|
-
return React.createElement(
|
|
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({
|
|
855
941
|
orientation: orientation
|
|
856
942
|
}, separatorProps, props, {
|
|
857
943
|
ref: mergeRefs([separatorProps.ref, ref])
|
|
858
|
-
}));
|
|
944
|
+
})));
|
|
859
945
|
});
|
|
860
946
|
SplitterComponent.displayName = 'Pane.Splitter';
|
|
861
947
|
SplitterComponent.propTypes = {
|
|
@@ -877,6 +963,63 @@ var ContentComponent = forwardRef(function (props, ref) {
|
|
|
877
963
|
ContentComponent.displayName = 'Pane.Content';
|
|
878
964
|
var Content = ContentComponent;
|
|
879
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
|
+
|
|
880
1023
|
var _excluded = ["children"];
|
|
881
1024
|
var PaneComponent = forwardRef(function (_ref, ref) {
|
|
882
1025
|
var children = _ref.children,
|
|
@@ -904,5 +1047,6 @@ PaneComponent.displayName = 'Pane';
|
|
|
904
1047
|
var Pane = PaneComponent;
|
|
905
1048
|
Pane.Content = Content;
|
|
906
1049
|
Pane.Splitter = Splitter;
|
|
1050
|
+
Pane.SplitterButton = SplitterButton;
|
|
907
1051
|
|
|
908
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 };
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { Splitter } from './components/Splitter';
|
|
9
9
|
import { Content } from './components/Content';
|
|
10
|
+
import { SplitterButton } from './components/SplitterButton';
|
|
10
11
|
/**
|
|
11
12
|
* @extends HTMLAttributes<HTMLDivElement>
|
|
12
13
|
*/
|
|
13
14
|
export declare const Pane: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>> & {
|
|
14
15
|
Content: typeof Content;
|
|
15
16
|
Splitter: typeof Splitter;
|
|
17
|
+
SplitterButton: typeof SplitterButton;
|
|
16
18
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ISplitterButtonProps } from '../../../types';
|
|
9
|
+
/**
|
|
10
|
+
* @extends ButtonHTMLAttributes<HTMLButtonElement>
|
|
11
|
+
*/
|
|
12
|
+
export declare const SplitterButton: React.ForwardRefExoticComponent<ISplitterButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export { Row } from './elements/Row';
|
|
|
10
10
|
export { PaneProvider } from './elements/pane/PaneProvider';
|
|
11
11
|
export { Pane } from './elements/pane/Pane';
|
|
12
12
|
export { ALIGN_ITEMS as ARRAY_ALIGN_ITEMS, ALIGN_SELF as ARRAY_ALIGN_SELF, DIRECTION as ARRAY_DIRECTION, JUSTIFY_CONTENT as ARRAY_JUSTIFY_CONTENT, TEXT_ALIGN as ARRAY_TEXT_ALIGN, SPACE as ARRAY_SPACE, WRAP as ARRAY_WRAP } from './types';
|
|
13
|
-
export type { IPaneProviderProps, ISplitterProps, IColProps, IGridProps, IRowProps, AlignItems as ALIGN_ITEMS, AlignSelf as ALIGN_SELF, Direction as DIRECTION, JustifyContent as JUSTIFY_CONTENT, TextAlign as TEXT_ALIGN, GridNumber as GRID_NUMBER, Breakpoint as BREAKPOINT, Space as SPACE, Wrap as WRAP } from './types';
|
|
13
|
+
export type { IPaneProviderProps, ISplitterProps, ISplitterButtonProps, IColProps, IGridProps, IRowProps, AlignItems as ALIGN_ITEMS, AlignSelf as ALIGN_SELF, Direction as DIRECTION, JustifyContent as JUSTIFY_CONTENT, TextAlign as TEXT_ALIGN, GridNumber as GRID_NUMBER, Breakpoint as BREAKPOINT, Space as SPACE, Wrap as WRAP } from './types';
|
|
@@ -9,6 +9,10 @@ import { Orientation } from '../../types';
|
|
|
9
9
|
interface IStyledPaneSplitterProps {
|
|
10
10
|
orientation: Orientation;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* 1. Elevated initial context to pickup full-width hover
|
|
14
|
+
* 2. Stack below splitter button.
|
|
15
|
+
*/
|
|
12
16
|
export declare const StyledPaneSplitter: import("styled-components").StyledComponent<"div", DefaultTheme, {
|
|
13
17
|
'data-garden-id': string;
|
|
14
18
|
'data-garden-version': string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
import { DefaultTheme } from 'styled-components';
|
|
9
|
+
import { ISplitterButtonProps, Orientation, PLACEMENT } from '../../types';
|
|
10
|
+
interface IStyledSplitterButtonProps extends ISplitterButtonProps {
|
|
11
|
+
orientation: Orientation;
|
|
12
|
+
placement: typeof PLACEMENT[number];
|
|
13
|
+
isRotated: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 1. Opaque "dish" behind transparent button
|
|
17
|
+
*/
|
|
18
|
+
export declare const StyledPaneSplitterButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@zendeskgarden/react-buttons").IIconButtonProps & import("react").RefAttributes<HTMLButtonElement>>, DefaultTheme, IStyledSplitterButtonProps, never>;
|
|
19
|
+
export {};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import { ReactNode, HTMLAttributes } from 'react';
|
|
7
|
+
import { ReactNode, HTMLAttributes, ButtonHTMLAttributes } from 'react';
|
|
8
8
|
export declare const ALIGN_ITEMS: readonly ["start", "end", "center", "baseline", "stretch"];
|
|
9
9
|
export declare const ALIGN_SELF: readonly ["auto", "start", "end", "center", "baseline", "stretch"];
|
|
10
10
|
export declare const DIRECTION: readonly ["row", "row-reverse", "column", "column-reverse"];
|
|
@@ -12,6 +12,7 @@ export declare const JUSTIFY_CONTENT: readonly ["start", "end", "center", "betwe
|
|
|
12
12
|
export declare const TEXT_ALIGN: readonly ["start", "end", "center", "justify"];
|
|
13
13
|
export declare const SPACE: readonly [false, "xxs", "xs", "sm", "md", "lg", "xl", "xxl"];
|
|
14
14
|
export declare const WRAP: readonly ["nowrap", "wrap", "wrap-reverse"];
|
|
15
|
+
export declare const PLACEMENT: readonly ["end", "start", "center"];
|
|
15
16
|
export declare type AlignItems = typeof ALIGN_ITEMS[number];
|
|
16
17
|
export declare type AlignSelf = typeof ALIGN_SELF[number];
|
|
17
18
|
export declare type Direction = typeof DIRECTION[number];
|
|
@@ -205,3 +206,9 @@ export interface ISplitterProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
205
206
|
/** Determines splitter orientation within a pane */
|
|
206
207
|
orientation?: Orientation;
|
|
207
208
|
}
|
|
209
|
+
export interface ISplitterButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
210
|
+
/** Adjusts the placement of the splitter button. Assumes start when vertical and center when horizontal, by default. */
|
|
211
|
+
placement?: typeof PLACEMENT[number];
|
|
212
|
+
/** Renders the provided label text inside a tooltip */
|
|
213
|
+
label: string;
|
|
214
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
import { ISplitterProps, Orientation } from '../types';
|
|
9
|
+
interface IPaneSplitterContext {
|
|
10
|
+
orientation?: Orientation;
|
|
11
|
+
min: ISplitterProps['min'];
|
|
12
|
+
max: ISplitterProps['max'];
|
|
13
|
+
layoutKey: ISplitterProps['layoutKey'];
|
|
14
|
+
valueNow?: number;
|
|
15
|
+
isRow: boolean;
|
|
16
|
+
providerId?: ISplitterProps['providerId'];
|
|
17
|
+
}
|
|
18
|
+
export declare const PaneSplitterContext: import("react").Context<IPaneSplitterContext>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve Pane Splitter component context
|
|
21
|
+
*/
|
|
22
|
+
declare const usePaneSplitterContext: () => IPaneSplitterContext;
|
|
23
|
+
export default usePaneSplitterContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-grid",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.53.0",
|
|
4
4
|
"description": "Components relating to layout grids in the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@zendeskgarden/container-splitter": "^0.2.3",
|
|
25
25
|
"@zendeskgarden/container-utilities": "^0.7.1",
|
|
26
|
+
"@zendeskgarden/react-buttons": "^8.53.0",
|
|
27
|
+
"@zendeskgarden/react-tooltips": "^8.53.0",
|
|
26
28
|
"polished": "^4.0.0",
|
|
27
29
|
"prop-types": "^15.5.7",
|
|
28
30
|
"react-merge-refs": "^1.1.0"
|
|
@@ -34,8 +36,8 @@
|
|
|
34
36
|
"styled-components": "^4.2.0 || ^5.0.0"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@zendeskgarden/react-theming": "^8.
|
|
38
|
-
"use-resize-observer": "
|
|
39
|
+
"@zendeskgarden/react-theming": "^8.53.0",
|
|
40
|
+
"use-resize-observer": "9.0.0"
|
|
39
41
|
},
|
|
40
42
|
"keywords": [
|
|
41
43
|
"components",
|
|
@@ -47,5 +49,5 @@
|
|
|
47
49
|
"access": "public"
|
|
48
50
|
},
|
|
49
51
|
"zendeskgarden:src": "src/index.ts",
|
|
50
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "0fb51e654b241d34d9f933593f8525846112ae15"
|
|
51
53
|
}
|