@zendeskgarden/react-grid 8.62.1 → 8.63.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
CHANGED
|
@@ -103,3 +103,8 @@ import { PaneProvider, Pane } from '@zendeskgarden/react-grid';
|
|
|
103
103
|
</PaneProvider>
|
|
104
104
|
</ThemeProvider>;
|
|
105
105
|
```
|
|
106
|
+
|
|
107
|
+
> the `Pane` component uses [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API)
|
|
108
|
+
> which is not available in node.js or other server side environments (if testing with Jest) - please
|
|
109
|
+
> make sure to polyfill as needed. Since the ref used internally is not created when server side rendering,
|
|
110
|
+
> the ResizeObserver API will not be invoked and should not pose an issue when doing so.
|
package/dist/index.cjs.js
CHANGED
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
10
|
var React = require('react');
|
|
13
11
|
var PropTypes = require('prop-types');
|
|
14
12
|
var styled = require('styled-components');
|
|
@@ -16,16 +14,18 @@ var polished = require('polished');
|
|
|
16
14
|
var reactTheming = require('@zendeskgarden/react-theming');
|
|
17
15
|
var reactButtons = require('@zendeskgarden/react-buttons');
|
|
18
16
|
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
17
|
+
var useResizeObserver = require('use-resize-observer');
|
|
19
18
|
var mergeRefs = require('react-merge-refs');
|
|
20
19
|
var containerSplitter = require('@zendeskgarden/container-splitter');
|
|
21
20
|
var reactTooltips = require('@zendeskgarden/react-tooltips');
|
|
22
21
|
|
|
23
|
-
function
|
|
22
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
23
|
|
|
25
|
-
var React__default = /*#__PURE__*/
|
|
26
|
-
var PropTypes__default = /*#__PURE__*/
|
|
27
|
-
var styled__default = /*#__PURE__*/
|
|
28
|
-
var
|
|
24
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
25
|
+
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
26
|
+
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
27
|
+
var useResizeObserver__default = /*#__PURE__*/_interopDefault(useResizeObserver);
|
|
28
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
|
|
29
29
|
|
|
30
30
|
function _extends() {
|
|
31
31
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -101,9 +101,9 @@ const sizeStyles$4 = props => {
|
|
|
101
101
|
const padding = props.gutters ? polished.math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
102
102
|
return styled.css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
103
103
|
};
|
|
104
|
-
const StyledCol = styled__default
|
|
104
|
+
const StyledCol = styled__default.default.div.attrs({
|
|
105
105
|
'data-garden-id': COMPONENT_ID$6,
|
|
106
|
-
'data-garden-version': '8.
|
|
106
|
+
'data-garden-version': '8.63.0'
|
|
107
107
|
}).withConfig({
|
|
108
108
|
displayName: "StyledCol",
|
|
109
109
|
componentId: "sc-inuw62-0"
|
|
@@ -123,9 +123,9 @@ const sizeStyles$3 = props => {
|
|
|
123
123
|
const padding = props.gutters ? polished.math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
124
124
|
return styled.css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
125
125
|
};
|
|
126
|
-
const StyledGrid = styled__default
|
|
126
|
+
const StyledGrid = styled__default.default.div.attrs({
|
|
127
127
|
'data-garden-id': COMPONENT_ID$5,
|
|
128
|
-
'data-garden-version': '8.
|
|
128
|
+
'data-garden-version': '8.63.0'
|
|
129
129
|
}).withConfig({
|
|
130
130
|
displayName: "StyledGrid",
|
|
131
131
|
componentId: "sc-oxgg5i-0"
|
|
@@ -165,9 +165,9 @@ const sizeStyles$2 = props => {
|
|
|
165
165
|
const margin = props.gutters ? polished.math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
166
166
|
return styled.css(["margin-right:-", ";margin-left:-", ";"], margin, margin);
|
|
167
167
|
};
|
|
168
|
-
const StyledRow = styled__default
|
|
168
|
+
const StyledRow = styled__default.default.div.attrs({
|
|
169
169
|
'data-garden-id': COMPONENT_ID$4,
|
|
170
|
-
'data-garden-version': '8.
|
|
170
|
+
'data-garden-version': '8.63.0'
|
|
171
171
|
}).withConfig({
|
|
172
172
|
displayName: "StyledRow",
|
|
173
173
|
componentId: "sc-xjsdg1-0"
|
|
@@ -178,9 +178,9 @@ StyledRow.defaultProps = {
|
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
const COMPONENT_ID$3 = 'pane';
|
|
181
|
-
const StyledPane = styled__default
|
|
181
|
+
const StyledPane = styled__default.default.div.attrs({
|
|
182
182
|
'data-garden-id': COMPONENT_ID$3,
|
|
183
|
-
'data-garden-version': '8.
|
|
183
|
+
'data-garden-version': '8.63.0'
|
|
184
184
|
}).withConfig({
|
|
185
185
|
displayName: "StyledPane",
|
|
186
186
|
componentId: "sc-1ltjst7-0"
|
|
@@ -190,13 +190,13 @@ StyledPane.defaultProps = {
|
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
const COMPONENT_ID$2 = 'pane.content';
|
|
193
|
-
const StyledPaneContent = styled__default
|
|
193
|
+
const StyledPaneContent = styled__default.default.div.attrs({
|
|
194
194
|
'data-garden-id': COMPONENT_ID$2,
|
|
195
|
-
'data-garden-version': '8.
|
|
195
|
+
'data-garden-version': '8.63.0'
|
|
196
196
|
}).withConfig({
|
|
197
197
|
displayName: "StyledPaneContent",
|
|
198
198
|
componentId: "sc-1b38mbh-0"
|
|
199
|
-
})(["height:100%;overflow:auto;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
199
|
+
})(["height:100%;overflow:auto;&[hidden]{display:none;}", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
200
200
|
StyledPaneContent.defaultProps = {
|
|
201
201
|
theme: reactTheming.DEFAULT_THEME
|
|
202
202
|
};
|
|
@@ -270,9 +270,9 @@ const sizeStyles$1 = props => {
|
|
|
270
270
|
const dimensionProperty = width === '100%' ? 'height' : 'width';
|
|
271
271
|
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, props.isFixed ? 'pointer' : cursor, width, height, separatorWidth, separatorHeight, dimensionProperty, props.isHovered && separatorSize, dimensionProperty, separatorSize, props.theme.borderRadii.md);
|
|
272
272
|
};
|
|
273
|
-
const StyledPaneSplitter = styled__default
|
|
273
|
+
const StyledPaneSplitter = styled__default.default.div.attrs({
|
|
274
274
|
'data-garden-id': COMPONENT_ID$1,
|
|
275
|
-
'data-garden-version': '8.
|
|
275
|
+
'data-garden-version': '8.63.0'
|
|
276
276
|
}).withConfig({
|
|
277
277
|
displayName: "StyledPaneSplitter",
|
|
278
278
|
componentId: "sc-jylemn-0"
|
|
@@ -333,9 +333,9 @@ const sizeStyles = props => {
|
|
|
333
333
|
}
|
|
334
334
|
return styled.css(["display:", ";top:", ";right:", ";bottom:", ";left:", ";width:", ";min-width:", ";height:", ";"], display, top, right, bottom, left, size, size, size);
|
|
335
335
|
};
|
|
336
|
-
const StyledPaneSplitterButton = styled__default
|
|
336
|
+
const StyledPaneSplitterButton = styled__default.default(reactButtons.ChevronButton).attrs({
|
|
337
337
|
'data-garden-id': COMPONENT_ID,
|
|
338
|
-
'data-garden-version': '8.
|
|
338
|
+
'data-garden-version': '8.63.0',
|
|
339
339
|
isBasic: true,
|
|
340
340
|
isPill: true,
|
|
341
341
|
size: 'small'
|
|
@@ -354,7 +354,7 @@ const useGridContext = () => {
|
|
|
354
354
|
return React.useContext(GridContext);
|
|
355
355
|
};
|
|
356
356
|
|
|
357
|
-
const Col = React__default
|
|
357
|
+
const Col = React__default.default.forwardRef((_ref, ref) => {
|
|
358
358
|
let {
|
|
359
359
|
size,
|
|
360
360
|
...props
|
|
@@ -364,7 +364,7 @@ const Col = React__default["default"].forwardRef((_ref, ref) => {
|
|
|
364
364
|
gutters,
|
|
365
365
|
debug
|
|
366
366
|
} = useGridContext();
|
|
367
|
-
return React__default
|
|
367
|
+
return React__default.default.createElement(StyledCol, _extends({
|
|
368
368
|
sizeAll: size,
|
|
369
369
|
columns: columns,
|
|
370
370
|
gutters: gutters,
|
|
@@ -374,39 +374,39 @@ const Col = React__default["default"].forwardRef((_ref, ref) => {
|
|
|
374
374
|
});
|
|
375
375
|
Col.displayName = 'Col';
|
|
376
376
|
Col.propTypes = {
|
|
377
|
-
size: PropTypes__default
|
|
378
|
-
xs: PropTypes__default
|
|
379
|
-
sm: PropTypes__default
|
|
380
|
-
md: PropTypes__default
|
|
381
|
-
lg: PropTypes__default
|
|
382
|
-
xl: PropTypes__default
|
|
383
|
-
alignSelf: PropTypes__default
|
|
384
|
-
alignSelfXs: PropTypes__default
|
|
385
|
-
alignSelfSm: PropTypes__default
|
|
386
|
-
alignSelfMd: PropTypes__default
|
|
387
|
-
alignSelfLg: PropTypes__default
|
|
388
|
-
alignSelfXl: PropTypes__default
|
|
389
|
-
textAlign: PropTypes__default
|
|
390
|
-
textAlignXs: PropTypes__default
|
|
391
|
-
textAlignSm: PropTypes__default
|
|
392
|
-
textAlignMd: PropTypes__default
|
|
393
|
-
textAlignLg: PropTypes__default
|
|
394
|
-
textAlignXl: PropTypes__default
|
|
395
|
-
offset: PropTypes__default
|
|
396
|
-
offsetXs: PropTypes__default
|
|
397
|
-
offsetSm: PropTypes__default
|
|
398
|
-
offsetMd: PropTypes__default
|
|
399
|
-
offsetLg: PropTypes__default
|
|
400
|
-
offsetXl: PropTypes__default
|
|
401
|
-
order: PropTypes__default
|
|
402
|
-
orderXs: PropTypes__default
|
|
403
|
-
orderSm: PropTypes__default
|
|
404
|
-
orderMd: PropTypes__default
|
|
405
|
-
orderLg: PropTypes__default
|
|
406
|
-
orderXl: PropTypes__default
|
|
377
|
+
size: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
378
|
+
xs: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string, PropTypes__default.default.bool]),
|
|
379
|
+
sm: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string, PropTypes__default.default.bool]),
|
|
380
|
+
md: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string, PropTypes__default.default.bool]),
|
|
381
|
+
lg: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string, PropTypes__default.default.bool]),
|
|
382
|
+
xl: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string, PropTypes__default.default.bool]),
|
|
383
|
+
alignSelf: PropTypes__default.default.oneOf(ALIGN_SELF),
|
|
384
|
+
alignSelfXs: PropTypes__default.default.oneOf(ALIGN_SELF),
|
|
385
|
+
alignSelfSm: PropTypes__default.default.oneOf(ALIGN_SELF),
|
|
386
|
+
alignSelfMd: PropTypes__default.default.oneOf(ALIGN_SELF),
|
|
387
|
+
alignSelfLg: PropTypes__default.default.oneOf(ALIGN_SELF),
|
|
388
|
+
alignSelfXl: PropTypes__default.default.oneOf(ALIGN_SELF),
|
|
389
|
+
textAlign: PropTypes__default.default.oneOf(TEXT_ALIGN),
|
|
390
|
+
textAlignXs: PropTypes__default.default.oneOf(TEXT_ALIGN),
|
|
391
|
+
textAlignSm: PropTypes__default.default.oneOf(TEXT_ALIGN),
|
|
392
|
+
textAlignMd: PropTypes__default.default.oneOf(TEXT_ALIGN),
|
|
393
|
+
textAlignLg: PropTypes__default.default.oneOf(TEXT_ALIGN),
|
|
394
|
+
textAlignXl: PropTypes__default.default.oneOf(TEXT_ALIGN),
|
|
395
|
+
offset: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
396
|
+
offsetXs: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
397
|
+
offsetSm: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
398
|
+
offsetMd: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
399
|
+
offsetLg: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
400
|
+
offsetXl: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
401
|
+
order: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
402
|
+
orderXs: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
403
|
+
orderSm: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
404
|
+
orderMd: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
405
|
+
orderLg: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
406
|
+
orderXl: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string])
|
|
407
407
|
};
|
|
408
408
|
|
|
409
|
-
const Grid = React__default
|
|
409
|
+
const Grid = React__default.default.forwardRef((_ref, ref) => {
|
|
410
410
|
let {
|
|
411
411
|
columns,
|
|
412
412
|
debug,
|
|
@@ -417,25 +417,25 @@ const Grid = React__default["default"].forwardRef((_ref, ref) => {
|
|
|
417
417
|
gutters: props.gutters,
|
|
418
418
|
debug
|
|
419
419
|
}), [columns, props.gutters, debug]);
|
|
420
|
-
return React__default
|
|
420
|
+
return React__default.default.createElement(GridContext.Provider, {
|
|
421
421
|
value: value
|
|
422
|
-
}, React__default
|
|
422
|
+
}, React__default.default.createElement(StyledGrid, _extends({
|
|
423
423
|
debug: debug,
|
|
424
424
|
ref: ref
|
|
425
425
|
}, props)));
|
|
426
426
|
});
|
|
427
427
|
Grid.displayName = 'Grid';
|
|
428
428
|
Grid.propTypes = {
|
|
429
|
-
columns: PropTypes__default
|
|
430
|
-
gutters: PropTypes__default
|
|
431
|
-
debug: PropTypes__default
|
|
429
|
+
columns: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
430
|
+
gutters: PropTypes__default.default.oneOf(SPACE),
|
|
431
|
+
debug: PropTypes__default.default.bool
|
|
432
432
|
};
|
|
433
433
|
Grid.defaultProps = {
|
|
434
434
|
columns: 12,
|
|
435
435
|
gutters: 'md'
|
|
436
436
|
};
|
|
437
437
|
|
|
438
|
-
const Row = React__default
|
|
438
|
+
const Row = React__default.default.forwardRef((_ref, ref) => {
|
|
439
439
|
let {
|
|
440
440
|
wrap,
|
|
441
441
|
...props
|
|
@@ -444,7 +444,7 @@ const Row = React__default["default"].forwardRef((_ref, ref) => {
|
|
|
444
444
|
gutters,
|
|
445
445
|
debug
|
|
446
446
|
} = useGridContext();
|
|
447
|
-
return React__default
|
|
447
|
+
return React__default.default.createElement(StyledRow, _extends({
|
|
448
448
|
gutters: gutters,
|
|
449
449
|
debug: debug,
|
|
450
450
|
wrapAll: wrap,
|
|
@@ -453,24 +453,24 @@ const Row = React__default["default"].forwardRef((_ref, ref) => {
|
|
|
453
453
|
});
|
|
454
454
|
Row.displayName = 'Row';
|
|
455
455
|
Row.propTypes = {
|
|
456
|
-
alignItems: PropTypes__default
|
|
457
|
-
alignItemsXs: PropTypes__default
|
|
458
|
-
alignItemsSm: PropTypes__default
|
|
459
|
-
alignItemsMd: PropTypes__default
|
|
460
|
-
alignItemsLg: PropTypes__default
|
|
461
|
-
alignItemsXl: PropTypes__default
|
|
462
|
-
justifyContent: PropTypes__default
|
|
463
|
-
justifyContentXs: PropTypes__default
|
|
464
|
-
justifyContentSm: PropTypes__default
|
|
465
|
-
justifyContentMd: PropTypes__default
|
|
466
|
-
justifyContentLg: PropTypes__default
|
|
467
|
-
justifyContentXl: PropTypes__default
|
|
468
|
-
wrap: PropTypes__default
|
|
469
|
-
wrapXs: PropTypes__default
|
|
470
|
-
wrapSm: PropTypes__default
|
|
471
|
-
wrapMd: PropTypes__default
|
|
472
|
-
wrapLg: PropTypes__default
|
|
473
|
-
wrapXl: PropTypes__default
|
|
456
|
+
alignItems: PropTypes__default.default.oneOf(ALIGN_ITEMS),
|
|
457
|
+
alignItemsXs: PropTypes__default.default.oneOf(ALIGN_ITEMS),
|
|
458
|
+
alignItemsSm: PropTypes__default.default.oneOf(ALIGN_ITEMS),
|
|
459
|
+
alignItemsMd: PropTypes__default.default.oneOf(ALIGN_ITEMS),
|
|
460
|
+
alignItemsLg: PropTypes__default.default.oneOf(ALIGN_ITEMS),
|
|
461
|
+
alignItemsXl: PropTypes__default.default.oneOf(ALIGN_ITEMS),
|
|
462
|
+
justifyContent: PropTypes__default.default.oneOf(JUSTIFY_CONTENT),
|
|
463
|
+
justifyContentXs: PropTypes__default.default.oneOf(JUSTIFY_CONTENT),
|
|
464
|
+
justifyContentSm: PropTypes__default.default.oneOf(JUSTIFY_CONTENT),
|
|
465
|
+
justifyContentMd: PropTypes__default.default.oneOf(JUSTIFY_CONTENT),
|
|
466
|
+
justifyContentLg: PropTypes__default.default.oneOf(JUSTIFY_CONTENT),
|
|
467
|
+
justifyContentXl: PropTypes__default.default.oneOf(JUSTIFY_CONTENT),
|
|
468
|
+
wrap: PropTypes__default.default.oneOf(WRAP),
|
|
469
|
+
wrapXs: PropTypes__default.default.oneOf(WRAP),
|
|
470
|
+
wrapSm: PropTypes__default.default.oneOf(WRAP),
|
|
471
|
+
wrapMd: PropTypes__default.default.oneOf(WRAP),
|
|
472
|
+
wrapLg: PropTypes__default.default.oneOf(WRAP),
|
|
473
|
+
wrapXl: PropTypes__default.default.oneOf(WRAP)
|
|
474
474
|
};
|
|
475
475
|
|
|
476
476
|
const PaneProviderContext = React.createContext({});
|
|
@@ -643,9 +643,9 @@ const PaneProvider = _ref2 => {
|
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
} : {}, [providerId, parentPaneProviderContext, rowState, columnState, setRowValue, setColumnValue, getRowValue, getColumnValue, totalPanesHeight, totalPanesWidth, pixelsPerFr]);
|
|
646
|
-
return React__default
|
|
646
|
+
return React__default.default.createElement(PaneProviderContext.Provider, {
|
|
647
647
|
value: paneProviderContext
|
|
648
|
-
}, children
|
|
648
|
+
}, children?.({
|
|
649
649
|
id: providerId,
|
|
650
650
|
getRowValue,
|
|
651
651
|
getColumnValue,
|
|
@@ -655,15 +655,15 @@ const PaneProvider = _ref2 => {
|
|
|
655
655
|
};
|
|
656
656
|
PaneProvider.displayName = 'PaneProvider';
|
|
657
657
|
PaneProvider.propTypes = {
|
|
658
|
-
id: PropTypes__default
|
|
659
|
-
totalPanesWidth: PropTypes__default
|
|
660
|
-
totalPanesHeight: PropTypes__default
|
|
661
|
-
defaultRowValues: PropTypes__default
|
|
662
|
-
defaultColumnValues: PropTypes__default
|
|
663
|
-
rowValues: PropTypes__default
|
|
664
|
-
columnValues: PropTypes__default
|
|
665
|
-
onChange: PropTypes__default
|
|
666
|
-
children: PropTypes__default
|
|
658
|
+
id: PropTypes__default.default.string,
|
|
659
|
+
totalPanesWidth: PropTypes__default.default.number.isRequired,
|
|
660
|
+
totalPanesHeight: PropTypes__default.default.number.isRequired,
|
|
661
|
+
defaultRowValues: PropTypes__default.default.object,
|
|
662
|
+
defaultColumnValues: PropTypes__default.default.object,
|
|
663
|
+
rowValues: PropTypes__default.default.object,
|
|
664
|
+
columnValues: PropTypes__default.default.object,
|
|
665
|
+
onChange: PropTypes__default.default.func,
|
|
666
|
+
children: PropTypes__default.default.func
|
|
667
667
|
};
|
|
668
668
|
|
|
669
669
|
const PaneContext = React.createContext({
|
|
@@ -699,7 +699,6 @@ const orientationToDimension = {
|
|
|
699
699
|
bottom: 'rows'
|
|
700
700
|
};
|
|
701
701
|
const SplitterComponent = React.forwardRef((_ref, ref) => {
|
|
702
|
-
var _separatorRef$current, _separatorRef$current2;
|
|
703
702
|
let {
|
|
704
703
|
providerId,
|
|
705
704
|
layoutKey,
|
|
@@ -722,8 +721,8 @@ const SplitterComponent = React.forwardRef((_ref, ref) => {
|
|
|
722
721
|
const separatorRef = React.useRef(null);
|
|
723
722
|
const splitterOrientation = paneToSplitterOrientation[orientation || 'end'];
|
|
724
723
|
const pixelsPerFr = paneProviderContext ? paneProviderContext.pixelsPerFr[orientationToDimension[orientation]] : 0;
|
|
725
|
-
const value = isRow ? paneProviderContext
|
|
726
|
-
const valueInFr = isRow ? paneProviderContext
|
|
724
|
+
const value = isRow ? paneProviderContext?.getRowValue(layoutKey, true) : paneProviderContext?.getColumnValue(layoutKey, true);
|
|
725
|
+
const valueInFr = isRow ? paneProviderContext?.getRowValue(layoutKey) : paneProviderContext?.getColumnValue(layoutKey);
|
|
727
726
|
const {
|
|
728
727
|
getSeparatorProps,
|
|
729
728
|
getPrimaryPaneProps
|
|
@@ -737,9 +736,9 @@ const SplitterComponent = React.forwardRef((_ref, ref) => {
|
|
|
737
736
|
environment,
|
|
738
737
|
onChange: valueNow => {
|
|
739
738
|
if (isRow) {
|
|
740
|
-
return paneProviderContext
|
|
739
|
+
return paneProviderContext?.setRowValue(orientation === 'top', layoutKey, valueNow / pixelsPerFr);
|
|
741
740
|
}
|
|
742
|
-
return paneProviderContext
|
|
741
|
+
return paneProviderContext?.setColumnValue(orientation === 'start', layoutKey, valueNow / pixelsPerFr);
|
|
743
742
|
},
|
|
744
743
|
valueNow: value,
|
|
745
744
|
separatorRef
|
|
@@ -758,9 +757,9 @@ const SplitterComponent = React.forwardRef((_ref, ref) => {
|
|
|
758
757
|
onKeyDown,
|
|
759
758
|
onClick
|
|
760
759
|
});
|
|
761
|
-
const size = isRow ?
|
|
760
|
+
const size = isRow ? separatorRef.current?.clientWidth : separatorRef.current?.clientHeight;
|
|
762
761
|
const onMouseOver = React.useMemo(() => containerUtilities.composeEventHandlers(props.onMouseOver, event => setIsHovered(event.target === separatorRef.current)), [props.onMouseOver, separatorRef]);
|
|
763
|
-
return React__default
|
|
762
|
+
return React__default.default.createElement(PaneSplitterContext.Provider, {
|
|
764
763
|
value: React.useMemo(() => ({
|
|
765
764
|
orientation,
|
|
766
765
|
layoutKey,
|
|
@@ -770,22 +769,22 @@ const SplitterComponent = React.forwardRef((_ref, ref) => {
|
|
|
770
769
|
size,
|
|
771
770
|
isRow
|
|
772
771
|
}), [orientation, layoutKey, min, max, valueInFr, size, isRow])
|
|
773
|
-
}, React__default
|
|
772
|
+
}, React__default.default.createElement(StyledPaneSplitter, _extends({
|
|
774
773
|
isHovered: isHovered,
|
|
775
774
|
isFixed: isFixed,
|
|
776
775
|
orientation: orientation
|
|
777
776
|
}, separatorProps, props, {
|
|
778
777
|
onMouseOver: onMouseOver,
|
|
779
|
-
ref: mergeRefs__default
|
|
778
|
+
ref: mergeRefs__default.default([separatorRef, ref])
|
|
780
779
|
})));
|
|
781
780
|
});
|
|
782
781
|
SplitterComponent.displayName = 'Pane.Splitter';
|
|
783
782
|
SplitterComponent.propTypes = {
|
|
784
|
-
layoutKey: PropTypes__default
|
|
785
|
-
min: PropTypes__default
|
|
786
|
-
max: PropTypes__default
|
|
787
|
-
orientation: PropTypes__default
|
|
788
|
-
isFixed: PropTypes__default
|
|
783
|
+
layoutKey: PropTypes__default.default.string.isRequired,
|
|
784
|
+
min: PropTypes__default.default.number.isRequired,
|
|
785
|
+
max: PropTypes__default.default.number.isRequired,
|
|
786
|
+
orientation: PropTypes__default.default.oneOf(ORIENTATION),
|
|
787
|
+
isFixed: PropTypes__default.default.bool
|
|
789
788
|
};
|
|
790
789
|
SplitterComponent.defaultProps = {
|
|
791
790
|
orientation: 'end'
|
|
@@ -793,7 +792,11 @@ SplitterComponent.defaultProps = {
|
|
|
793
792
|
const Splitter = SplitterComponent;
|
|
794
793
|
|
|
795
794
|
const ContentComponent = React.forwardRef((props, ref) => {
|
|
796
|
-
|
|
795
|
+
const {
|
|
796
|
+
isVisible
|
|
797
|
+
} = usePaneContext();
|
|
798
|
+
return React__default.default.createElement(StyledPaneContent, _extends({
|
|
799
|
+
hidden: !isVisible,
|
|
797
800
|
ref: ref
|
|
798
801
|
}, props));
|
|
799
802
|
});
|
|
@@ -845,13 +848,13 @@ const SplitterButtonComponent = React.forwardRef((props, ref) => {
|
|
|
845
848
|
);
|
|
846
849
|
const onMouseDown = containerUtilities.composeEventHandlers(props.onMouseDown, event => event.stopPropagation()
|
|
847
850
|
);
|
|
848
|
-
return React__default
|
|
851
|
+
return React__default.default.createElement(reactTooltips.Tooltip, {
|
|
849
852
|
content: label,
|
|
850
853
|
style: {
|
|
851
854
|
cursor: 'default'
|
|
852
855
|
},
|
|
853
856
|
onMouseDown: e => e.stopPropagation()
|
|
854
|
-
}, React__default
|
|
857
|
+
}, React__default.default.createElement(StyledPaneSplitterButton, _extends({
|
|
855
858
|
"aria-label": label
|
|
856
859
|
}, props, {
|
|
857
860
|
placement: placement,
|
|
@@ -873,15 +876,24 @@ const PaneComponent = React.forwardRef((_ref, ref) => {
|
|
|
873
876
|
...props
|
|
874
877
|
} = _ref;
|
|
875
878
|
const [paneId, setPaneId] = React.useState();
|
|
879
|
+
const observerRef = React.useRef(null);
|
|
880
|
+
const {
|
|
881
|
+
width = 0,
|
|
882
|
+
height = 0
|
|
883
|
+
} = useResizeObserver__default.default({
|
|
884
|
+
ref: observerRef
|
|
885
|
+
});
|
|
886
|
+
const isVisible = React.useMemo(() => observerRef.current ? width > 0 && height > 0 : true, [width, height]);
|
|
876
887
|
const paneContext = React.useMemo(() => ({
|
|
888
|
+
isVisible,
|
|
877
889
|
id: paneId,
|
|
878
890
|
setId: id => setPaneId(id)
|
|
879
|
-
}), [paneId]);
|
|
880
|
-
return React__default
|
|
891
|
+
}), [paneId, isVisible]);
|
|
892
|
+
return React__default.default.createElement(PaneContext.Provider, {
|
|
881
893
|
value: paneContext
|
|
882
|
-
}, React__default
|
|
894
|
+
}, React__default.default.createElement(StyledPane, _extends({
|
|
883
895
|
id: paneId,
|
|
884
|
-
ref: ref
|
|
896
|
+
ref: mergeRefs__default.default([ref, observerRef])
|
|
885
897
|
}, props), children));
|
|
886
898
|
});
|
|
887
899
|
PaneComponent.displayName = 'Pane';
|
package/dist/index.esm.js
CHANGED
|
@@ -12,6 +12,7 @@ import { math, rgba, stripUnit } from 'polished';
|
|
|
12
12
|
import { retrieveComponentStyles, DEFAULT_THEME, getColor, useDocument, useText } from '@zendeskgarden/react-theming';
|
|
13
13
|
import { ChevronButton } from '@zendeskgarden/react-buttons';
|
|
14
14
|
import { useId, composeEventHandlers } from '@zendeskgarden/container-utilities';
|
|
15
|
+
import useResizeObserver from 'use-resize-observer';
|
|
15
16
|
import mergeRefs from 'react-merge-refs';
|
|
16
17
|
import { useSplitter } from '@zendeskgarden/container-splitter';
|
|
17
18
|
import { Tooltip } from '@zendeskgarden/react-tooltips';
|
|
@@ -92,7 +93,7 @@ const sizeStyles$4 = props => {
|
|
|
92
93
|
};
|
|
93
94
|
const StyledCol = styled.div.attrs({
|
|
94
95
|
'data-garden-id': COMPONENT_ID$6,
|
|
95
|
-
'data-garden-version': '8.
|
|
96
|
+
'data-garden-version': '8.63.0'
|
|
96
97
|
}).withConfig({
|
|
97
98
|
displayName: "StyledCol",
|
|
98
99
|
componentId: "sc-inuw62-0"
|
|
@@ -114,7 +115,7 @@ const sizeStyles$3 = props => {
|
|
|
114
115
|
};
|
|
115
116
|
const StyledGrid = styled.div.attrs({
|
|
116
117
|
'data-garden-id': COMPONENT_ID$5,
|
|
117
|
-
'data-garden-version': '8.
|
|
118
|
+
'data-garden-version': '8.63.0'
|
|
118
119
|
}).withConfig({
|
|
119
120
|
displayName: "StyledGrid",
|
|
120
121
|
componentId: "sc-oxgg5i-0"
|
|
@@ -156,7 +157,7 @@ const sizeStyles$2 = props => {
|
|
|
156
157
|
};
|
|
157
158
|
const StyledRow = styled.div.attrs({
|
|
158
159
|
'data-garden-id': COMPONENT_ID$4,
|
|
159
|
-
'data-garden-version': '8.
|
|
160
|
+
'data-garden-version': '8.63.0'
|
|
160
161
|
}).withConfig({
|
|
161
162
|
displayName: "StyledRow",
|
|
162
163
|
componentId: "sc-xjsdg1-0"
|
|
@@ -169,7 +170,7 @@ StyledRow.defaultProps = {
|
|
|
169
170
|
const COMPONENT_ID$3 = 'pane';
|
|
170
171
|
const StyledPane = styled.div.attrs({
|
|
171
172
|
'data-garden-id': COMPONENT_ID$3,
|
|
172
|
-
'data-garden-version': '8.
|
|
173
|
+
'data-garden-version': '8.63.0'
|
|
173
174
|
}).withConfig({
|
|
174
175
|
displayName: "StyledPane",
|
|
175
176
|
componentId: "sc-1ltjst7-0"
|
|
@@ -181,11 +182,11 @@ StyledPane.defaultProps = {
|
|
|
181
182
|
const COMPONENT_ID$2 = 'pane.content';
|
|
182
183
|
const StyledPaneContent = styled.div.attrs({
|
|
183
184
|
'data-garden-id': COMPONENT_ID$2,
|
|
184
|
-
'data-garden-version': '8.
|
|
185
|
+
'data-garden-version': '8.63.0'
|
|
185
186
|
}).withConfig({
|
|
186
187
|
displayName: "StyledPaneContent",
|
|
187
188
|
componentId: "sc-1b38mbh-0"
|
|
188
|
-
})(["height:100%;overflow:auto;", ";"], props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
189
|
+
})(["height:100%;overflow:auto;&[hidden]{display:none;}", ";"], props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
189
190
|
StyledPaneContent.defaultProps = {
|
|
190
191
|
theme: DEFAULT_THEME
|
|
191
192
|
};
|
|
@@ -261,7 +262,7 @@ const sizeStyles$1 = props => {
|
|
|
261
262
|
};
|
|
262
263
|
const StyledPaneSplitter = styled.div.attrs({
|
|
263
264
|
'data-garden-id': COMPONENT_ID$1,
|
|
264
|
-
'data-garden-version': '8.
|
|
265
|
+
'data-garden-version': '8.63.0'
|
|
265
266
|
}).withConfig({
|
|
266
267
|
displayName: "StyledPaneSplitter",
|
|
267
268
|
componentId: "sc-jylemn-0"
|
|
@@ -324,7 +325,7 @@ const sizeStyles = props => {
|
|
|
324
325
|
};
|
|
325
326
|
const StyledPaneSplitterButton = styled(ChevronButton).attrs({
|
|
326
327
|
'data-garden-id': COMPONENT_ID,
|
|
327
|
-
'data-garden-version': '8.
|
|
328
|
+
'data-garden-version': '8.63.0',
|
|
328
329
|
isBasic: true,
|
|
329
330
|
isPill: true,
|
|
330
331
|
size: 'small'
|
|
@@ -634,7 +635,7 @@ const PaneProvider = _ref2 => {
|
|
|
634
635
|
} : {}, [providerId, parentPaneProviderContext, rowState, columnState, setRowValue, setColumnValue, getRowValue, getColumnValue, totalPanesHeight, totalPanesWidth, pixelsPerFr]);
|
|
635
636
|
return React.createElement(PaneProviderContext.Provider, {
|
|
636
637
|
value: paneProviderContext
|
|
637
|
-
}, children
|
|
638
|
+
}, children?.({
|
|
638
639
|
id: providerId,
|
|
639
640
|
getRowValue,
|
|
640
641
|
getColumnValue,
|
|
@@ -688,7 +689,6 @@ const orientationToDimension = {
|
|
|
688
689
|
bottom: 'rows'
|
|
689
690
|
};
|
|
690
691
|
const SplitterComponent = forwardRef((_ref, ref) => {
|
|
691
|
-
var _separatorRef$current, _separatorRef$current2;
|
|
692
692
|
let {
|
|
693
693
|
providerId,
|
|
694
694
|
layoutKey,
|
|
@@ -711,8 +711,8 @@ const SplitterComponent = forwardRef((_ref, ref) => {
|
|
|
711
711
|
const separatorRef = useRef(null);
|
|
712
712
|
const splitterOrientation = paneToSplitterOrientation[orientation || 'end'];
|
|
713
713
|
const pixelsPerFr = paneProviderContext ? paneProviderContext.pixelsPerFr[orientationToDimension[orientation]] : 0;
|
|
714
|
-
const value = isRow ? paneProviderContext
|
|
715
|
-
const valueInFr = isRow ? paneProviderContext
|
|
714
|
+
const value = isRow ? paneProviderContext?.getRowValue(layoutKey, true) : paneProviderContext?.getColumnValue(layoutKey, true);
|
|
715
|
+
const valueInFr = isRow ? paneProviderContext?.getRowValue(layoutKey) : paneProviderContext?.getColumnValue(layoutKey);
|
|
716
716
|
const {
|
|
717
717
|
getSeparatorProps,
|
|
718
718
|
getPrimaryPaneProps
|
|
@@ -726,9 +726,9 @@ const SplitterComponent = forwardRef((_ref, ref) => {
|
|
|
726
726
|
environment,
|
|
727
727
|
onChange: valueNow => {
|
|
728
728
|
if (isRow) {
|
|
729
|
-
return paneProviderContext
|
|
729
|
+
return paneProviderContext?.setRowValue(orientation === 'top', layoutKey, valueNow / pixelsPerFr);
|
|
730
730
|
}
|
|
731
|
-
return paneProviderContext
|
|
731
|
+
return paneProviderContext?.setColumnValue(orientation === 'start', layoutKey, valueNow / pixelsPerFr);
|
|
732
732
|
},
|
|
733
733
|
valueNow: value,
|
|
734
734
|
separatorRef
|
|
@@ -747,7 +747,7 @@ const SplitterComponent = forwardRef((_ref, ref) => {
|
|
|
747
747
|
onKeyDown,
|
|
748
748
|
onClick
|
|
749
749
|
});
|
|
750
|
-
const size = isRow ?
|
|
750
|
+
const size = isRow ? separatorRef.current?.clientWidth : separatorRef.current?.clientHeight;
|
|
751
751
|
const onMouseOver = useMemo(() => composeEventHandlers(props.onMouseOver, event => setIsHovered(event.target === separatorRef.current)), [props.onMouseOver, separatorRef]);
|
|
752
752
|
return React.createElement(PaneSplitterContext.Provider, {
|
|
753
753
|
value: useMemo(() => ({
|
|
@@ -782,7 +782,11 @@ SplitterComponent.defaultProps = {
|
|
|
782
782
|
const Splitter = SplitterComponent;
|
|
783
783
|
|
|
784
784
|
const ContentComponent = forwardRef((props, ref) => {
|
|
785
|
+
const {
|
|
786
|
+
isVisible
|
|
787
|
+
} = usePaneContext();
|
|
785
788
|
return React.createElement(StyledPaneContent, _extends({
|
|
789
|
+
hidden: !isVisible,
|
|
786
790
|
ref: ref
|
|
787
791
|
}, props));
|
|
788
792
|
});
|
|
@@ -862,15 +866,24 @@ const PaneComponent = forwardRef((_ref, ref) => {
|
|
|
862
866
|
...props
|
|
863
867
|
} = _ref;
|
|
864
868
|
const [paneId, setPaneId] = useState();
|
|
869
|
+
const observerRef = useRef(null);
|
|
870
|
+
const {
|
|
871
|
+
width = 0,
|
|
872
|
+
height = 0
|
|
873
|
+
} = useResizeObserver({
|
|
874
|
+
ref: observerRef
|
|
875
|
+
});
|
|
876
|
+
const isVisible = useMemo(() => observerRef.current ? width > 0 && height > 0 : true, [width, height]);
|
|
865
877
|
const paneContext = useMemo(() => ({
|
|
878
|
+
isVisible,
|
|
866
879
|
id: paneId,
|
|
867
880
|
setId: id => setPaneId(id)
|
|
868
|
-
}), [paneId]);
|
|
881
|
+
}), [paneId, isVisible]);
|
|
869
882
|
return React.createElement(PaneContext.Provider, {
|
|
870
883
|
value: paneContext
|
|
871
884
|
}, React.createElement(StyledPane, _extends({
|
|
872
885
|
id: paneId,
|
|
873
|
-
ref: ref
|
|
886
|
+
ref: mergeRefs([ref, observerRef])
|
|
874
887
|
}, props), children));
|
|
875
888
|
});
|
|
876
889
|
PaneComponent.displayName = 'Pane';
|
|
@@ -9,7 +9,7 @@ import { DefaultTheme } from 'styled-components';
|
|
|
9
9
|
import { ISplitterButtonProps, Orientation, PLACEMENT } from '../../types';
|
|
10
10
|
interface IStyledSplitterButtonProps extends ISplitterButtonProps {
|
|
11
11
|
orientation: Orientation;
|
|
12
|
-
placement: typeof PLACEMENT[number];
|
|
12
|
+
placement: (typeof PLACEMENT)[number];
|
|
13
13
|
isRotated: boolean;
|
|
14
14
|
splitterSize: number;
|
|
15
15
|
}
|
|
@@ -13,15 +13,15 @@ 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
15
|
export declare const PLACEMENT: readonly ["end", "start", "center"];
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
16
|
+
export type AlignItems = (typeof ALIGN_ITEMS)[number];
|
|
17
|
+
export type AlignSelf = (typeof ALIGN_SELF)[number];
|
|
18
|
+
export type Direction = (typeof DIRECTION)[number];
|
|
19
|
+
export type JustifyContent = (typeof JUSTIFY_CONTENT)[number];
|
|
20
|
+
export type TextAlign = (typeof TEXT_ALIGN)[number];
|
|
21
|
+
export type GridNumber = number | string;
|
|
22
|
+
export type Breakpoint = number | string | boolean;
|
|
23
|
+
export type Space = (typeof SPACE)[number];
|
|
24
|
+
export type Wrap = (typeof WRAP)[number];
|
|
25
25
|
export interface IColProps extends HTMLAttributes<HTMLDivElement> {
|
|
26
26
|
/** Sets the total number of grid `columns` that the column spans on all screen sizes */
|
|
27
27
|
size?: number | string;
|
|
@@ -154,7 +154,7 @@ export interface IRowProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
154
154
|
wrapXl?: Wrap;
|
|
155
155
|
}
|
|
156
156
|
export declare const ORIENTATION: readonly ["top", "bottom", "start", "end"];
|
|
157
|
-
export
|
|
157
|
+
export type Orientation = (typeof ORIENTATION)[number];
|
|
158
158
|
export interface IPaneProviderProps {
|
|
159
159
|
/** Identifies the pane provider */
|
|
160
160
|
id?: string;
|
|
@@ -210,7 +210,7 @@ export interface ISplitterProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
210
210
|
}
|
|
211
211
|
export interface ISplitterButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
212
212
|
/** Adjusts the placement of the splitter button. Assumes start when vertical and center when horizontal, by default. */
|
|
213
|
-
placement?: typeof PLACEMENT[number];
|
|
213
|
+
placement?: (typeof PLACEMENT)[number];
|
|
214
214
|
/** Renders the provided label text inside a tooltip */
|
|
215
215
|
label: string;
|
|
216
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-grid",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.63.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,11 +23,12 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@zendeskgarden/container-splitter": "^2.0.3",
|
|
25
25
|
"@zendeskgarden/container-utilities": "^1.0.0",
|
|
26
|
-
"@zendeskgarden/react-buttons": "^8.
|
|
27
|
-
"@zendeskgarden/react-tooltips": "^8.
|
|
26
|
+
"@zendeskgarden/react-buttons": "^8.63.0",
|
|
27
|
+
"@zendeskgarden/react-tooltips": "^8.63.0",
|
|
28
28
|
"polished": "^4.0.0",
|
|
29
29
|
"prop-types": "^15.5.7",
|
|
30
|
-
"react-merge-refs": "^1.1.0"
|
|
30
|
+
"react-merge-refs": "^1.1.0",
|
|
31
|
+
"use-resize-observer": "^9.1.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"@zendeskgarden/react-theming": "^8.1.0",
|
|
@@ -36,8 +37,7 @@
|
|
|
36
37
|
"styled-components": "^4.2.0 || ^5.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@zendeskgarden/react-theming": "^8.
|
|
40
|
-
"use-resize-observer": "9.1.0"
|
|
40
|
+
"@zendeskgarden/react-theming": "^8.63.0"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"components",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"zendeskgarden:src": "src/index.ts",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "4b8715305a769881b143c7195c5b31e687422926"
|
|
53
53
|
}
|