@zendeskgarden/react-grid 8.57.1 → 8.59.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/dist/index.cjs.js +358 -568
- package/dist/index.esm.js +358 -568
- package/package.json +5 -5
package/dist/index.esm.js
CHANGED
|
@@ -16,179 +16,41 @@ import mergeRefs from 'react-merge-refs';
|
|
|
16
16
|
import { useSplitter } from '@zendeskgarden/container-splitter';
|
|
17
17
|
import { Tooltip } from '@zendeskgarden/react-tooltips';
|
|
18
18
|
|
|
19
|
-
function ownKeys(object, enumerableOnly) {
|
|
20
|
-
var keys = Object.keys(object);
|
|
21
|
-
|
|
22
|
-
if (Object.getOwnPropertySymbols) {
|
|
23
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
24
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
25
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
26
|
-
})), keys.push.apply(keys, symbols);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return keys;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function _objectSpread2(target) {
|
|
33
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
34
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
35
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
36
|
-
_defineProperty(target, key, source[key]);
|
|
37
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
38
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return target;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function _defineProperty(obj, key, value) {
|
|
46
|
-
if (key in obj) {
|
|
47
|
-
Object.defineProperty(obj, key, {
|
|
48
|
-
value: value,
|
|
49
|
-
enumerable: true,
|
|
50
|
-
configurable: true,
|
|
51
|
-
writable: true
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
obj[key] = value;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return obj;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
19
|
function _extends() {
|
|
61
20
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
62
21
|
for (var i = 1; i < arguments.length; i++) {
|
|
63
22
|
var source = arguments[i];
|
|
64
|
-
|
|
65
23
|
for (var key in source) {
|
|
66
24
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
67
25
|
target[key] = source[key];
|
|
68
26
|
}
|
|
69
27
|
}
|
|
70
28
|
}
|
|
71
|
-
|
|
72
29
|
return target;
|
|
73
30
|
};
|
|
74
31
|
return _extends.apply(this, arguments);
|
|
75
32
|
}
|
|
76
33
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return target;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function _objectWithoutProperties(source, excluded) {
|
|
93
|
-
if (source == null) return {};
|
|
94
|
-
|
|
95
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
96
|
-
|
|
97
|
-
var key, i;
|
|
98
|
-
|
|
99
|
-
if (Object.getOwnPropertySymbols) {
|
|
100
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
101
|
-
|
|
102
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
103
|
-
key = sourceSymbolKeys[i];
|
|
104
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
105
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
106
|
-
target[key] = source[key];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return target;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function _slicedToArray(arr, i) {
|
|
114
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function _arrayWithHoles(arr) {
|
|
118
|
-
if (Array.isArray(arr)) return arr;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function _iterableToArrayLimit(arr, i) {
|
|
122
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
123
|
-
|
|
124
|
-
if (_i == null) return;
|
|
125
|
-
var _arr = [];
|
|
126
|
-
var _n = true;
|
|
127
|
-
var _d = false;
|
|
128
|
-
|
|
129
|
-
var _s, _e;
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
133
|
-
_arr.push(_s.value);
|
|
134
|
-
|
|
135
|
-
if (i && _arr.length === i) break;
|
|
136
|
-
}
|
|
137
|
-
} catch (err) {
|
|
138
|
-
_d = true;
|
|
139
|
-
_e = err;
|
|
140
|
-
} finally {
|
|
141
|
-
try {
|
|
142
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
143
|
-
} finally {
|
|
144
|
-
if (_d) throw _e;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return _arr;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
152
|
-
if (!o) return;
|
|
153
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
154
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
155
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
156
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
157
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function _arrayLikeToArray(arr, len) {
|
|
161
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
162
|
-
|
|
163
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
164
|
-
|
|
165
|
-
return arr2;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function _nonIterableRest() {
|
|
169
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
var ALIGN_ITEMS = ['start', 'end', 'center', 'baseline', 'stretch'];
|
|
173
|
-
var ALIGN_SELF = ['auto'].concat(ALIGN_ITEMS);
|
|
174
|
-
var DIRECTION = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
175
|
-
var JUSTIFY_CONTENT = ['start', 'end', 'center', 'between', 'around'];
|
|
176
|
-
var TEXT_ALIGN = ['start', 'end', 'center', 'justify'];
|
|
177
|
-
var SPACE = [false, 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
178
|
-
var WRAP = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
179
|
-
var ORIENTATION = ['top', 'bottom', 'start', 'end'];
|
|
180
|
-
|
|
181
|
-
var COMPONENT_ID$6 = 'grid.col';
|
|
182
|
-
var colorStyles$4 = function colorStyles(props) {
|
|
183
|
-
var backgroundColor = getColor('primaryHue', 600, props.theme, 0.1);
|
|
34
|
+
const ALIGN_ITEMS = ['start', 'end', 'center', 'baseline', 'stretch'];
|
|
35
|
+
const ALIGN_SELF = ['auto', ...ALIGN_ITEMS];
|
|
36
|
+
const DIRECTION = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
37
|
+
const JUSTIFY_CONTENT = ['start', 'end', 'center', 'between', 'around'];
|
|
38
|
+
const TEXT_ALIGN = ['start', 'end', 'center', 'justify'];
|
|
39
|
+
const SPACE = [false, 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
40
|
+
const WRAP = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
41
|
+
const ORIENTATION = ['top', 'bottom', 'start', 'end'];
|
|
42
|
+
|
|
43
|
+
const COMPONENT_ID$6 = 'grid.col';
|
|
44
|
+
const colorStyles$4 = props => {
|
|
45
|
+
const backgroundColor = getColor('primaryHue', 600, props.theme, 0.1);
|
|
184
46
|
return css(["background-clip:content-box;background-color:", ";"], backgroundColor);
|
|
185
47
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
48
|
+
const flexStyles$1 = (size, alignSelf, textAlign, offset, order, props) => {
|
|
49
|
+
const margin = offset && `${math(`${offset} / ${props.columns} * 100`)}%`;
|
|
50
|
+
let flexBasis;
|
|
51
|
+
let flexGrow;
|
|
52
|
+
let maxWidth;
|
|
53
|
+
let width;
|
|
192
54
|
if (typeof size === 'boolean') {
|
|
193
55
|
flexBasis = 0;
|
|
194
56
|
flexGrow = 1;
|
|
@@ -199,11 +61,11 @@ var flexStyles$1 = function flexStyles(size, alignSelf, textAlign, offset, order
|
|
|
199
61
|
maxWidth = '100%';
|
|
200
62
|
width = 'auto';
|
|
201
63
|
} else if (size !== undefined) {
|
|
202
|
-
flexBasis =
|
|
64
|
+
flexBasis = `${math(`${size} / ${props.columns} * 100`)}%`;
|
|
203
65
|
flexGrow = 0;
|
|
204
66
|
maxWidth = flexBasis;
|
|
205
67
|
}
|
|
206
|
-
|
|
68
|
+
let horizontalAlign;
|
|
207
69
|
if (textAlign === 'start') {
|
|
208
70
|
horizontalAlign = props.theme.rtl ? 'right' : 'left';
|
|
209
71
|
} else if (textAlign === 'end') {
|
|
@@ -211,192 +73,144 @@ var flexStyles$1 = function flexStyles(size, alignSelf, textAlign, offset, order
|
|
|
211
73
|
} else {
|
|
212
74
|
horizontalAlign = textAlign;
|
|
213
75
|
}
|
|
214
|
-
|
|
76
|
+
let flexOrder;
|
|
215
77
|
if (order === 'first') {
|
|
216
78
|
flexOrder = -1;
|
|
217
79
|
} else if (order === 'last') {
|
|
218
|
-
flexOrder = math(
|
|
80
|
+
flexOrder = math(`${props.columns} + 1`);
|
|
219
81
|
} else {
|
|
220
82
|
flexOrder = order;
|
|
221
83
|
}
|
|
222
|
-
return css(["flex-basis:", ";flex-grow:", ";flex-shrink:", ";align-self:", ";order:", ";margin-", ":", ";width:", ";max-width:", ";text-align:", ";"], flexBasis, flexGrow, size && 0, alignSelf === 'start' || alignSelf === 'end' ?
|
|
84
|
+
return css(["flex-basis:", ";flex-grow:", ";flex-shrink:", ";align-self:", ";order:", ";margin-", ":", ";width:", ";max-width:", ";text-align:", ";"], flexBasis, flexGrow, size && 0, alignSelf === 'start' || alignSelf === 'end' ? `flex-${alignSelf}` : alignSelf, flexOrder, props.theme.rtl ? 'right' : 'left', margin, width, maxWidth, horizontalAlign);
|
|
223
85
|
};
|
|
224
|
-
|
|
86
|
+
const mediaStyles$1 = (minWidth, size, alignSelf, textAlign, offset, order, props) => {
|
|
225
87
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles$1(size, alignSelf, textAlign, offset, order, props));
|
|
226
88
|
};
|
|
227
|
-
|
|
228
|
-
|
|
89
|
+
const sizeStyles$4 = props => {
|
|
90
|
+
const padding = props.gutters ? math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
229
91
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
230
92
|
};
|
|
231
|
-
|
|
93
|
+
const StyledCol = styled.div.attrs({
|
|
232
94
|
'data-garden-id': COMPONENT_ID$6,
|
|
233
|
-
'data-garden-version': '8.
|
|
95
|
+
'data-garden-version': '8.59.0'
|
|
234
96
|
}).withConfig({
|
|
235
97
|
displayName: "StyledCol",
|
|
236
98
|
componentId: "sc-inuw62-0"
|
|
237
|
-
})(["box-sizing:border-box;width:100%;", ";", ";", ";", ";", ";", ";", ";", ";", ";"],
|
|
238
|
-
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);
|
|
239
|
-
}, function (props) {
|
|
240
|
-
return sizeStyles$4(props);
|
|
241
|
-
}, function (props) {
|
|
242
|
-
return props.debug && colorStyles$4(props);
|
|
243
|
-
}, function (props) {
|
|
244
|
-
return mediaStyles$1(props.theme.breakpoints.xs, props.xs, props.alignSelfXs, props.textAlignXs, props.offsetXs, props.orderXs, props);
|
|
245
|
-
}, function (props) {
|
|
246
|
-
return mediaStyles$1(props.theme.breakpoints.sm, props.sm, props.alignSelfSm, props.textAlignSm, props.offsetSm, props.orderSm, props);
|
|
247
|
-
}, function (props) {
|
|
248
|
-
return mediaStyles$1(props.theme.breakpoints.md, props.md, props.alignSelfMd, props.textAlignMd, props.offsetMd, props.orderMd, props);
|
|
249
|
-
}, function (props) {
|
|
250
|
-
return mediaStyles$1(props.theme.breakpoints.lg, props.lg, props.alignSelfLg, props.textAlignLg, props.offsetLg, props.orderLg, props);
|
|
251
|
-
}, function (props) {
|
|
252
|
-
return mediaStyles$1(props.theme.breakpoints.xl, props.xl, props.alignSelfXl, props.textAlignXl, props.offsetXl, props.orderXl, props);
|
|
253
|
-
}, function (props) {
|
|
254
|
-
return retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
255
|
-
});
|
|
99
|
+
})(["box-sizing:border-box;width:100%;", ";", ";", ";", ";", ";", ";", ";", ";", ";"], props => 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), props => sizeStyles$4(props), props => props.debug && colorStyles$4(props), props => mediaStyles$1(props.theme.breakpoints.xs, props.xs, props.alignSelfXs, props.textAlignXs, props.offsetXs, props.orderXs, props), props => mediaStyles$1(props.theme.breakpoints.sm, props.sm, props.alignSelfSm, props.textAlignSm, props.offsetSm, props.orderSm, props), props => mediaStyles$1(props.theme.breakpoints.md, props.md, props.alignSelfMd, props.textAlignMd, props.offsetMd, props.orderMd, props), props => mediaStyles$1(props.theme.breakpoints.lg, props.lg, props.alignSelfLg, props.textAlignLg, props.offsetLg, props.orderLg, props), props => mediaStyles$1(props.theme.breakpoints.xl, props.xl, props.alignSelfXl, props.textAlignXl, props.offsetXl, props.orderXl, props), props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
256
100
|
StyledCol.defaultProps = {
|
|
257
101
|
columns: 12,
|
|
258
102
|
theme: DEFAULT_THEME
|
|
259
103
|
};
|
|
260
104
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
105
|
+
const COMPONENT_ID$5 = 'grid.grid';
|
|
106
|
+
const colorStyles$3 = props => {
|
|
107
|
+
const borderColor = getColor(props.theme.palette.crimson, 400, props.theme, 0.5);
|
|
108
|
+
const borderWidth = math(`${props.theme.borderWidths.sm} * 2`);
|
|
265
109
|
return css(["box-shadow:-", " 0 0 0 ", ",", " 0 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
266
110
|
};
|
|
267
|
-
|
|
268
|
-
|
|
111
|
+
const sizeStyles$3 = props => {
|
|
112
|
+
const padding = props.gutters ? math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
269
113
|
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
270
114
|
};
|
|
271
|
-
|
|
115
|
+
const StyledGrid = styled.div.attrs({
|
|
272
116
|
'data-garden-id': COMPONENT_ID$5,
|
|
273
|
-
'data-garden-version': '8.
|
|
117
|
+
'data-garden-version': '8.59.0'
|
|
274
118
|
}).withConfig({
|
|
275
119
|
displayName: "StyledGrid",
|
|
276
120
|
componentId: "sc-oxgg5i-0"
|
|
277
|
-
})(["direction:", ";margin-right:auto;margin-left:auto;width:100%;box-sizing:border-box;", ";", ";", ";"],
|
|
278
|
-
return props.theme.rtl && 'rtl';
|
|
279
|
-
}, function (props) {
|
|
280
|
-
return sizeStyles$3(props);
|
|
281
|
-
}, function (props) {
|
|
282
|
-
return props.debug && colorStyles$3(props);
|
|
283
|
-
}, function (props) {
|
|
284
|
-
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
285
|
-
});
|
|
121
|
+
})(["direction:", ";margin-right:auto;margin-left:auto;width:100%;box-sizing:border-box;", ";", ";", ";"], props => props.theme.rtl && 'rtl', props => sizeStyles$3(props), props => props.debug && colorStyles$3(props), props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
286
122
|
StyledGrid.defaultProps = {
|
|
287
123
|
gutters: 'md',
|
|
288
124
|
theme: DEFAULT_THEME
|
|
289
125
|
};
|
|
290
126
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
127
|
+
const COMPONENT_ID$4 = 'grid.row';
|
|
128
|
+
const colorStyles$2 = props => {
|
|
129
|
+
const borderColor = getColor(props.theme.palette.mint, 600, props.theme, 0.5);
|
|
130
|
+
const borderWidth = props.theme.borderWidths.sm;
|
|
295
131
|
return css(["box-shadow:inset 0 ", " 0 0 ", ",inset 0 -", " 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
296
132
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
133
|
+
const flexStyles = (alignItems, justifyContent, wrap) => {
|
|
134
|
+
let flexAlignItems;
|
|
135
|
+
let flexJustifyContent;
|
|
300
136
|
if (alignItems === 'start' || alignItems === 'end') {
|
|
301
|
-
flexAlignItems =
|
|
137
|
+
flexAlignItems = `flex-${alignItems}`;
|
|
302
138
|
} else {
|
|
303
139
|
flexAlignItems = alignItems;
|
|
304
140
|
}
|
|
305
141
|
if (justifyContent === 'start' || justifyContent === 'end') {
|
|
306
|
-
flexJustifyContent =
|
|
142
|
+
flexJustifyContent = `flex-${justifyContent}`;
|
|
307
143
|
} else if (justifyContent === 'between' || justifyContent === 'around') {
|
|
308
|
-
flexJustifyContent =
|
|
144
|
+
flexJustifyContent = `space-${justifyContent}`;
|
|
309
145
|
} else {
|
|
310
146
|
flexJustifyContent = justifyContent;
|
|
311
147
|
}
|
|
312
148
|
return css(["flex-wrap:", ";align-items:", ";justify-content:", ";"], wrap, flexAlignItems, flexJustifyContent);
|
|
313
149
|
};
|
|
314
|
-
|
|
150
|
+
const mediaStyles = (minWidth, alignItems, justifyContent, wrap) => {
|
|
315
151
|
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles(alignItems, justifyContent, wrap));
|
|
316
152
|
};
|
|
317
|
-
|
|
318
|
-
|
|
153
|
+
const sizeStyles$2 = props => {
|
|
154
|
+
const margin = props.gutters ? math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
319
155
|
return css(["margin-right:-", ";margin-left:-", ";"], margin, margin);
|
|
320
156
|
};
|
|
321
|
-
|
|
157
|
+
const StyledRow = styled.div.attrs({
|
|
322
158
|
'data-garden-id': COMPONENT_ID$4,
|
|
323
|
-
'data-garden-version': '8.
|
|
159
|
+
'data-garden-version': '8.59.0'
|
|
324
160
|
}).withConfig({
|
|
325
161
|
displayName: "StyledRow",
|
|
326
162
|
componentId: "sc-xjsdg1-0"
|
|
327
|
-
})(["display:flex;box-sizing:border-box;", " ", ";", ";", ";", ";", ";", ";", ";", ";"],
|
|
328
|
-
return flexStyles(props.alignItems, props.justifyContent, props.wrapAll);
|
|
329
|
-
}, function (props) {
|
|
330
|
-
return sizeStyles$2(props);
|
|
331
|
-
}, function (props) {
|
|
332
|
-
return props.debug && colorStyles$2(props);
|
|
333
|
-
}, function (props) {
|
|
334
|
-
return mediaStyles(props.theme.breakpoints.xs, props.alignItemsXs, props.justifyContentXs, props.wrapXs);
|
|
335
|
-
}, function (props) {
|
|
336
|
-
return mediaStyles(props.theme.breakpoints.sm, props.alignItemsSm, props.justifyContentSm, props.wrapSm);
|
|
337
|
-
}, function (props) {
|
|
338
|
-
return mediaStyles(props.theme.breakpoints.md, props.alignItemsMd, props.justifyContentMd, props.wrapMd);
|
|
339
|
-
}, function (props) {
|
|
340
|
-
return mediaStyles(props.theme.breakpoints.lg, props.alignItemsLg, props.justifyContentLg, props.wrapLg);
|
|
341
|
-
}, function (props) {
|
|
342
|
-
return mediaStyles(props.theme.breakpoints.xl, props.alignItemsXl, props.justifyContentXl, props.wrapXl);
|
|
343
|
-
}, function (props) {
|
|
344
|
-
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
345
|
-
});
|
|
163
|
+
})(["display:flex;box-sizing:border-box;", " ", ";", ";", ";", ";", ";", ";", ";", ";"], props => flexStyles(props.alignItems, props.justifyContent, props.wrapAll), props => sizeStyles$2(props), props => props.debug && colorStyles$2(props), props => mediaStyles(props.theme.breakpoints.xs, props.alignItemsXs, props.justifyContentXs, props.wrapXs), props => mediaStyles(props.theme.breakpoints.sm, props.alignItemsSm, props.justifyContentSm, props.wrapSm), props => mediaStyles(props.theme.breakpoints.md, props.alignItemsMd, props.justifyContentMd, props.wrapMd), props => mediaStyles(props.theme.breakpoints.lg, props.alignItemsLg, props.justifyContentLg, props.wrapLg), props => mediaStyles(props.theme.breakpoints.xl, props.alignItemsXl, props.justifyContentXl, props.wrapXl), props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
346
164
|
StyledRow.defaultProps = {
|
|
347
165
|
wrapAll: 'wrap',
|
|
348
166
|
theme: DEFAULT_THEME
|
|
349
167
|
};
|
|
350
168
|
|
|
351
|
-
|
|
352
|
-
|
|
169
|
+
const COMPONENT_ID$3 = 'pane';
|
|
170
|
+
const StyledPane = styled.div.attrs({
|
|
353
171
|
'data-garden-id': COMPONENT_ID$3,
|
|
354
|
-
'data-garden-version': '8.
|
|
172
|
+
'data-garden-version': '8.59.0'
|
|
355
173
|
}).withConfig({
|
|
356
174
|
displayName: "StyledPane",
|
|
357
175
|
componentId: "sc-1ltjst7-0"
|
|
358
|
-
})(["position:relative;min-width:0;min-height:0;", ";"],
|
|
359
|
-
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
360
|
-
});
|
|
176
|
+
})(["position:relative;min-width:0;min-height:0;", ";"], props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
361
177
|
StyledPane.defaultProps = {
|
|
362
178
|
theme: DEFAULT_THEME
|
|
363
179
|
};
|
|
364
180
|
|
|
365
|
-
|
|
366
|
-
|
|
181
|
+
const COMPONENT_ID$2 = 'pane.content';
|
|
182
|
+
const StyledPaneContent = styled.div.attrs({
|
|
367
183
|
'data-garden-id': COMPONENT_ID$2,
|
|
368
|
-
'data-garden-version': '8.
|
|
184
|
+
'data-garden-version': '8.59.0'
|
|
369
185
|
}).withConfig({
|
|
370
186
|
displayName: "StyledPaneContent",
|
|
371
187
|
componentId: "sc-1b38mbh-0"
|
|
372
|
-
})(["height:100%;overflow:auto;", ";"],
|
|
373
|
-
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
374
|
-
});
|
|
188
|
+
})(["height:100%;overflow:auto;", ";"], props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
375
189
|
StyledPaneContent.defaultProps = {
|
|
376
190
|
theme: DEFAULT_THEME
|
|
377
191
|
};
|
|
378
192
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
193
|
+
const COMPONENT_ID$1 = 'pane.splitter';
|
|
194
|
+
const colorStyles$1 = props => {
|
|
195
|
+
const color = getColor('neutralHue', 300, props.theme);
|
|
196
|
+
const hoverColor = getColor('primaryHue', 600, props.theme);
|
|
197
|
+
const activeColor = getColor('primaryHue', 800, props.theme);
|
|
198
|
+
const boxShadow = props.theme.shadows.md(rgba(hoverColor, 0.35));
|
|
385
199
|
return css(["&::before{background-color:", ";}&:hover::before{background-color:", ";}&[data-garden-focus-visible]::before{box-shadow:", ";background-color:", ";}&:active::before{background-color:", ";}"], color, props.isHovered && hoverColor, boxShadow, hoverColor, props.isHovered && activeColor);
|
|
386
200
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
201
|
+
const sizeStyles$1 = props => {
|
|
202
|
+
const size = math(`${props.theme.shadowWidths.md} * 2`);
|
|
203
|
+
const separatorSize = math(`${props.theme.borderWidths.sm} * 2`);
|
|
204
|
+
const offset = math(`-${size} / 2`);
|
|
205
|
+
let cursor;
|
|
206
|
+
let top;
|
|
207
|
+
let right;
|
|
208
|
+
let left;
|
|
209
|
+
let bottom;
|
|
210
|
+
let width;
|
|
211
|
+
let height;
|
|
212
|
+
let separatorWidth;
|
|
213
|
+
let separatorHeight;
|
|
400
214
|
switch (props.orientation) {
|
|
401
215
|
case 'top':
|
|
402
216
|
cursor = 'row-resize';
|
|
@@ -442,25 +256,23 @@ var sizeStyles$1 = function sizeStyles(props) {
|
|
|
442
256
|
}
|
|
443
257
|
break;
|
|
444
258
|
}
|
|
445
|
-
|
|
259
|
+
const dimensionProperty = width === '100%' ? 'height' : 'width';
|
|
446
260
|
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, dimensionProperty, props.isHovered && separatorSize, dimensionProperty, separatorSize, props.theme.borderRadii.md);
|
|
447
261
|
};
|
|
448
|
-
|
|
262
|
+
const StyledPaneSplitter = styled.div.attrs({
|
|
449
263
|
'data-garden-id': COMPONENT_ID$1,
|
|
450
|
-
'data-garden-version': '8.
|
|
264
|
+
'data-garden-version': '8.59.0'
|
|
451
265
|
}).withConfig({
|
|
452
266
|
displayName: "StyledPaneSplitter",
|
|
453
267
|
componentId: "sc-jylemn-0"
|
|
454
|
-
})(["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$1,
|
|
455
|
-
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
456
|
-
});
|
|
268
|
+
})(["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$1, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
457
269
|
StyledPaneSplitter.defaultProps = {
|
|
458
270
|
theme: DEFAULT_THEME
|
|
459
271
|
};
|
|
460
272
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
273
|
+
const COMPONENT_ID = 'pane.splitter_button';
|
|
274
|
+
const transformStyles = props => {
|
|
275
|
+
let degrees = 0;
|
|
464
276
|
if (props.isRotated) {
|
|
465
277
|
degrees = props.theme.rtl ? -180 : 180;
|
|
466
278
|
}
|
|
@@ -473,21 +285,23 @@ var transformStyles = function transformStyles(props) {
|
|
|
473
285
|
}
|
|
474
286
|
return css(["& > svg{transform:rotate(", "deg);}"], degrees);
|
|
475
287
|
};
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
288
|
+
const colorStyles = _ref => {
|
|
289
|
+
let {
|
|
290
|
+
theme
|
|
291
|
+
} = _ref;
|
|
292
|
+
const boxShadow = theme.shadows.lg(`${theme.space.base}px`, `${theme.space.base * 2}px`, getColor('chromeHue', 600, theme, 0.15));
|
|
293
|
+
const focusBoxShadow = theme.shadows.md(getColor('primaryHue', 600, theme, 0.35));
|
|
480
294
|
return css(["box-shadow:", ";&[data-garden-focus-visible]{box-shadow:", ",", ";}"], boxShadow, focusBoxShadow, boxShadow);
|
|
481
295
|
};
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
if (props.splitterSize >= stripUnit(math(
|
|
296
|
+
const sizeStyles = props => {
|
|
297
|
+
const size = `${props.theme.space.base * 6}px`;
|
|
298
|
+
const display = props.splitterSize <= stripUnit(math(`${props.theme.shadowWidths.md} * 2 + ${size}`)) && 'none';
|
|
299
|
+
const isVertical = props.orientation === 'start' || props.orientation === 'end';
|
|
300
|
+
let top;
|
|
301
|
+
let left;
|
|
302
|
+
let right;
|
|
303
|
+
let bottom;
|
|
304
|
+
if (props.splitterSize >= stripUnit(math(`${size} * 3`))) {
|
|
491
305
|
if (props.placement === 'start') {
|
|
492
306
|
if (isVertical) {
|
|
493
307
|
top = size;
|
|
@@ -508,39 +322,37 @@ var sizeStyles = function sizeStyles(props) {
|
|
|
508
322
|
}
|
|
509
323
|
return css(["display:", ";top:", ";right:", ";bottom:", ";left:", ";width:", ";min-width:", ";height:", ";"], display, top, right, bottom, left, size, size, size);
|
|
510
324
|
};
|
|
511
|
-
|
|
325
|
+
const StyledPaneSplitterButton = styled(ChevronButton).attrs({
|
|
512
326
|
'data-garden-id': COMPONENT_ID,
|
|
513
|
-
'data-garden-version': '8.
|
|
327
|
+
'data-garden-version': '8.59.0',
|
|
514
328
|
isBasic: true,
|
|
515
329
|
isPill: true,
|
|
516
330
|
size: 'small'
|
|
517
331
|
}).withConfig({
|
|
518
332
|
displayName: "StyledPaneSplitterButton",
|
|
519
333
|
componentId: "sc-zh032e-0"
|
|
520
|
-
})(["position:absolute;transition: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, colorStyles,
|
|
521
|
-
return props.theme.colors.background;
|
|
522
|
-
}, function (props) {
|
|
523
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
524
|
-
});
|
|
334
|
+
})(["position:absolute;transition: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, colorStyles, props => props.theme.colors.background, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
525
335
|
StyledPaneSplitterButton.defaultProps = {
|
|
526
336
|
theme: DEFAULT_THEME
|
|
527
337
|
};
|
|
528
338
|
|
|
529
|
-
|
|
339
|
+
const GridContext = createContext({
|
|
530
340
|
gutters: 'md'
|
|
531
341
|
});
|
|
532
|
-
|
|
342
|
+
const useGridContext = () => {
|
|
533
343
|
return useContext(GridContext);
|
|
534
344
|
};
|
|
535
345
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
346
|
+
const Col = React.forwardRef((_ref, ref) => {
|
|
347
|
+
let {
|
|
348
|
+
size,
|
|
349
|
+
...props
|
|
350
|
+
} = _ref;
|
|
351
|
+
const {
|
|
352
|
+
columns,
|
|
353
|
+
gutters,
|
|
354
|
+
debug
|
|
355
|
+
} = useGridContext();
|
|
544
356
|
return React.createElement(StyledCol, _extends({
|
|
545
357
|
sizeAll: size,
|
|
546
358
|
columns: columns,
|
|
@@ -583,18 +395,17 @@ Col.propTypes = {
|
|
|
583
395
|
orderXl: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
584
396
|
};
|
|
585
397
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}, [columns, props.gutters, debug]);
|
|
398
|
+
const Grid = React.forwardRef((_ref, ref) => {
|
|
399
|
+
let {
|
|
400
|
+
columns,
|
|
401
|
+
debug,
|
|
402
|
+
...props
|
|
403
|
+
} = _ref;
|
|
404
|
+
const value = useMemo(() => ({
|
|
405
|
+
columns,
|
|
406
|
+
gutters: props.gutters,
|
|
407
|
+
debug
|
|
408
|
+
}), [columns, props.gutters, debug]);
|
|
598
409
|
return React.createElement(GridContext.Provider, {
|
|
599
410
|
value: value
|
|
600
411
|
}, React.createElement(StyledGrid, _extends({
|
|
@@ -613,13 +424,15 @@ Grid.defaultProps = {
|
|
|
613
424
|
gutters: 'md'
|
|
614
425
|
};
|
|
615
426
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
427
|
+
const Row = React.forwardRef((_ref, ref) => {
|
|
428
|
+
let {
|
|
429
|
+
wrap,
|
|
430
|
+
...props
|
|
431
|
+
} = _ref;
|
|
432
|
+
const {
|
|
433
|
+
gutters,
|
|
434
|
+
debug
|
|
435
|
+
} = useGridContext();
|
|
623
436
|
return React.createElement(StyledRow, _extends({
|
|
624
437
|
gutters: gutters,
|
|
625
438
|
debug: debug,
|
|
@@ -649,197 +462,184 @@ Row.propTypes = {
|
|
|
649
462
|
wrapXl: PropTypes.oneOf(WRAP)
|
|
650
463
|
};
|
|
651
464
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
465
|
+
const PaneProviderContext = createContext({});
|
|
466
|
+
const usePaneProviderContextData = providerId => {
|
|
467
|
+
const context = useContext(PaneProviderContext);
|
|
468
|
+
const id = providerId || context.providerId;
|
|
656
469
|
return id && context.contextData ? context.contextData[id] : undefined;
|
|
657
470
|
};
|
|
658
|
-
|
|
659
|
-
return useContext(PaneProviderContext);
|
|
660
|
-
};
|
|
471
|
+
const usePaneProviderContext = () => useContext(PaneProviderContext);
|
|
661
472
|
|
|
662
|
-
|
|
473
|
+
const getPixelsPerFr = (totalFrs, totalDimension) => {
|
|
663
474
|
return totalDimension / totalFrs;
|
|
664
475
|
};
|
|
665
|
-
|
|
666
|
-
return Object.entries(values).reduce(
|
|
667
|
-
|
|
668
|
-
key = _ref2[0],
|
|
669
|
-
value = _ref2[1];
|
|
476
|
+
const convertToPixels = (values, pixelsPerFr) => {
|
|
477
|
+
return Object.entries(values).reduce((prev, _ref) => {
|
|
478
|
+
let [key, value] = _ref;
|
|
670
479
|
prev[key] = value * pixelsPerFr;
|
|
671
480
|
return prev;
|
|
672
481
|
}, {});
|
|
673
482
|
};
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
setColumnState = _useState4[1];
|
|
693
|
-
var rowsTrack = isControlled ? rowValues : rowState;
|
|
694
|
-
var columnsTrack = isControlled ? columnValues : columnState;
|
|
695
|
-
var setRowsTrack = useCallback(function (values) {
|
|
483
|
+
const PaneProvider = _ref2 => {
|
|
484
|
+
let {
|
|
485
|
+
id,
|
|
486
|
+
totalPanesWidth,
|
|
487
|
+
totalPanesHeight,
|
|
488
|
+
defaultRowValues,
|
|
489
|
+
defaultColumnValues,
|
|
490
|
+
rowValues,
|
|
491
|
+
columnValues,
|
|
492
|
+
onChange,
|
|
493
|
+
children
|
|
494
|
+
} = _ref2;
|
|
495
|
+
const isControlled = rowValues !== undefined && rowValues !== null && columnValues !== undefined && columnValues !== null;
|
|
496
|
+
const [rowState, setRowState] = useState(defaultRowValues || {});
|
|
497
|
+
const [columnState, setColumnState] = useState(defaultColumnValues || {});
|
|
498
|
+
const rowsTrack = isControlled ? rowValues : rowState;
|
|
499
|
+
const columnsTrack = isControlled ? columnValues : columnState;
|
|
500
|
+
const setRowsTrack = useCallback(values => {
|
|
696
501
|
if (isControlled && onChange) {
|
|
697
502
|
return onChange(values(rowsTrack), columnsTrack);
|
|
698
503
|
}
|
|
699
504
|
return setRowState(values);
|
|
700
505
|
}, [isControlled, onChange, setRowState, columnsTrack, rowsTrack]);
|
|
701
|
-
|
|
506
|
+
const setColumnsTrack = useCallback(values => {
|
|
702
507
|
if (isControlled && onChange) {
|
|
703
508
|
return onChange(rowsTrack, values(columnsTrack));
|
|
704
509
|
}
|
|
705
510
|
return setColumnState(values);
|
|
706
511
|
}, [isControlled, onChange, setColumnState, rowsTrack, columnsTrack]);
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
var layoutStateInPixels = useMemo(function () {
|
|
724
|
-
return {
|
|
725
|
-
rows: convertToPixels(rowsTrack, pixelsPerFr.rows),
|
|
726
|
-
columns: convertToPixels(columnsTrack, pixelsPerFr.columns)
|
|
727
|
-
};
|
|
728
|
-
}, [rowsTrack, columnsTrack, pixelsPerFr]);
|
|
729
|
-
var layoutIndices = useMemo(function () {
|
|
730
|
-
var rowArray = Object.keys(rowsTrack);
|
|
731
|
-
var columnArray = Object.keys(columnsTrack);
|
|
732
|
-
var rows = rowArray.reduce(function (prev, key, index) {
|
|
512
|
+
const totalFractions = useMemo(() => ({
|
|
513
|
+
rows: Object.values(rowsTrack).reduce((prev, value) => value + prev, 0),
|
|
514
|
+
columns: Object.values(columnsTrack).reduce((prev, value) => value + prev, 0)
|
|
515
|
+
}), [rowsTrack, columnsTrack]);
|
|
516
|
+
const pixelsPerFr = useMemo(() => ({
|
|
517
|
+
rows: getPixelsPerFr(totalFractions.rows, totalPanesHeight),
|
|
518
|
+
columns: getPixelsPerFr(totalFractions.columns, totalPanesWidth)
|
|
519
|
+
}), [totalFractions, totalPanesHeight, totalPanesWidth]);
|
|
520
|
+
const layoutStateInPixels = useMemo(() => ({
|
|
521
|
+
rows: convertToPixels(rowsTrack, pixelsPerFr.rows),
|
|
522
|
+
columns: convertToPixels(columnsTrack, pixelsPerFr.columns)
|
|
523
|
+
}), [rowsTrack, columnsTrack, pixelsPerFr]);
|
|
524
|
+
const layoutIndices = useMemo(() => {
|
|
525
|
+
const rowArray = Object.keys(rowsTrack);
|
|
526
|
+
const columnArray = Object.keys(columnsTrack);
|
|
527
|
+
const rows = rowArray.reduce((prev, key, index) => {
|
|
733
528
|
prev[key] = index;
|
|
734
529
|
return prev;
|
|
735
530
|
}, {});
|
|
736
|
-
|
|
531
|
+
const columns = columnArray.reduce((prev, key, index) => {
|
|
737
532
|
prev[key] = index;
|
|
738
533
|
return prev;
|
|
739
534
|
}, {});
|
|
740
535
|
return {
|
|
741
|
-
rows
|
|
742
|
-
columns
|
|
743
|
-
rowArray
|
|
744
|
-
columnArray
|
|
536
|
+
rows,
|
|
537
|
+
columns,
|
|
538
|
+
rowArray,
|
|
539
|
+
columnArray
|
|
745
540
|
};
|
|
746
541
|
}, [rowsTrack, columnsTrack]);
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
542
|
+
const setRowValue = useCallback((isTop, splitterId, value) => {
|
|
543
|
+
const {
|
|
544
|
+
rows,
|
|
545
|
+
rowArray
|
|
546
|
+
} = layoutIndices;
|
|
547
|
+
const stealFromTraversal = isTop ? -1 : 1;
|
|
548
|
+
const addToTraversal = 0;
|
|
549
|
+
setRowsTrack(state => {
|
|
550
|
+
const oldValue = rowsTrack[splitterId];
|
|
551
|
+
const stealFromIndex = rows[splitterId] + stealFromTraversal;
|
|
552
|
+
const addToIndex = rows[splitterId] + addToTraversal;
|
|
553
|
+
const stealFromKey = rowArray[stealFromIndex];
|
|
554
|
+
const addToKey = rowArray[addToIndex];
|
|
555
|
+
const difference = oldValue - value;
|
|
556
|
+
const nextState = {
|
|
557
|
+
...state
|
|
558
|
+
};
|
|
760
559
|
nextState[addToKey] = rowsTrack[addToKey] - difference;
|
|
761
560
|
nextState[stealFromKey] = rowsTrack[stealFromKey] + difference;
|
|
762
561
|
return nextState;
|
|
763
562
|
});
|
|
764
563
|
}, [layoutIndices, rowsTrack, setRowsTrack]);
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
564
|
+
const setColumnValue = useCallback((isStart, splitterId, value) => {
|
|
565
|
+
const {
|
|
566
|
+
columns,
|
|
567
|
+
columnArray
|
|
568
|
+
} = layoutIndices;
|
|
569
|
+
const stealFromTraversal = isStart ? -1 : 1;
|
|
570
|
+
const addToTraversal = 0;
|
|
571
|
+
setColumnsTrack(state => {
|
|
572
|
+
const stealFromIndex = columns[splitterId] + stealFromTraversal;
|
|
573
|
+
const addToIndex = columns[splitterId] + addToTraversal;
|
|
574
|
+
const oldValue = columnsTrack[splitterId];
|
|
575
|
+
const stealFromKey = columnArray[stealFromIndex];
|
|
576
|
+
const addToKey = columnArray[addToIndex];
|
|
577
|
+
const difference = oldValue - value;
|
|
578
|
+
const nextState = {
|
|
579
|
+
...state
|
|
580
|
+
};
|
|
778
581
|
nextState[addToKey] = columnsTrack[addToKey] - difference;
|
|
779
582
|
nextState[stealFromKey] = columnsTrack[stealFromKey] + difference;
|
|
780
583
|
return nextState;
|
|
781
584
|
});
|
|
782
585
|
}, [layoutIndices, columnsTrack, setColumnsTrack]);
|
|
783
|
-
|
|
586
|
+
const getColumnValue = useCallback((splitterKey, isPixels) => {
|
|
784
587
|
if (isPixels) {
|
|
785
588
|
return layoutStateInPixels.columns[splitterKey];
|
|
786
589
|
}
|
|
787
590
|
return columnsTrack[splitterKey];
|
|
788
591
|
}, [columnsTrack, layoutStateInPixels]);
|
|
789
|
-
|
|
592
|
+
const getRowValue = useCallback((splitterKey, isPixels) => {
|
|
790
593
|
if (isPixels) {
|
|
791
594
|
return layoutStateInPixels.rows[splitterKey];
|
|
792
595
|
}
|
|
793
596
|
return rowsTrack[splitterKey];
|
|
794
597
|
}, [rowsTrack, layoutStateInPixels]);
|
|
795
|
-
|
|
796
|
-
|
|
598
|
+
const getGridTemplateColumns = useCallback(isPixels => {
|
|
599
|
+
const {
|
|
600
|
+
columnArray
|
|
601
|
+
} = layoutIndices;
|
|
797
602
|
if (isPixels) {
|
|
798
|
-
return columnArray.map(
|
|
799
|
-
return "".concat(layoutStateInPixels.columns[col], "px");
|
|
800
|
-
}).join(' ');
|
|
603
|
+
return columnArray.map(col => `${layoutStateInPixels.columns[col]}px`).join(' ');
|
|
801
604
|
}
|
|
802
|
-
return columnArray.map(
|
|
803
|
-
return "".concat(columnsTrack[col], "fr");
|
|
804
|
-
}).join(' ');
|
|
605
|
+
return columnArray.map(col => `${columnsTrack[col]}fr`).join(' ');
|
|
805
606
|
}, [layoutIndices, columnsTrack, layoutStateInPixels]);
|
|
806
|
-
|
|
807
|
-
|
|
607
|
+
const getGridTemplateRows = useCallback(isPixels => {
|
|
608
|
+
const {
|
|
609
|
+
rowArray
|
|
610
|
+
} = layoutIndices;
|
|
808
611
|
if (isPixels) {
|
|
809
|
-
return rowArray.map(
|
|
810
|
-
return "".concat(layoutStateInPixels.rows[row], "px");
|
|
811
|
-
}).join(' ');
|
|
612
|
+
return rowArray.map(row => `${layoutStateInPixels.rows[row]}px`).join(' ');
|
|
812
613
|
}
|
|
813
|
-
return rowArray.map(
|
|
814
|
-
return "".concat(rowsTrack[row], "fr");
|
|
815
|
-
}).join(' ');
|
|
614
|
+
return rowArray.map(row => `${rowsTrack[row]}fr`).join(' ');
|
|
816
615
|
}, [layoutIndices, rowsTrack, layoutStateInPixels]);
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
616
|
+
const providerId = useId(id);
|
|
617
|
+
const parentPaneProviderContext = usePaneProviderContext();
|
|
618
|
+
const paneProviderContext = useMemo(() => providerId ? {
|
|
619
|
+
providerId,
|
|
620
|
+
contextData: {
|
|
621
|
+
...parentPaneProviderContext.contextData,
|
|
622
|
+
[providerId]: {
|
|
623
|
+
columnState,
|
|
624
|
+
rowState,
|
|
625
|
+
setRowValue,
|
|
626
|
+
setColumnValue,
|
|
627
|
+
getRowValue,
|
|
628
|
+
getColumnValue,
|
|
629
|
+
totalPanesHeight,
|
|
630
|
+
totalPanesWidth,
|
|
631
|
+
pixelsPerFr
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
} : {}, [providerId, parentPaneProviderContext, rowState, columnState, setRowValue, setColumnValue, getRowValue, getColumnValue, totalPanesHeight, totalPanesWidth, pixelsPerFr]);
|
|
835
635
|
return React.createElement(PaneProviderContext.Provider, {
|
|
836
636
|
value: paneProviderContext
|
|
837
637
|
}, children === null || children === void 0 ? void 0 : children({
|
|
838
638
|
id: providerId,
|
|
839
|
-
getRowValue
|
|
840
|
-
getColumnValue
|
|
841
|
-
getGridTemplateColumns
|
|
842
|
-
getGridTemplateRows
|
|
639
|
+
getRowValue,
|
|
640
|
+
getColumnValue,
|
|
641
|
+
getGridTemplateColumns,
|
|
642
|
+
getGridTemplateRows
|
|
843
643
|
}));
|
|
844
644
|
};
|
|
845
645
|
PaneProvider.displayName = 'PaneProvider';
|
|
@@ -855,16 +655,14 @@ PaneProvider.propTypes = {
|
|
|
855
655
|
children: PropTypes.func
|
|
856
656
|
};
|
|
857
657
|
|
|
858
|
-
|
|
859
|
-
setId:
|
|
860
|
-
return undefined;
|
|
861
|
-
}
|
|
658
|
+
const PaneContext = createContext({
|
|
659
|
+
setId: () => undefined
|
|
862
660
|
});
|
|
863
|
-
|
|
661
|
+
const usePaneContext = () => {
|
|
864
662
|
return useContext(PaneContext);
|
|
865
663
|
};
|
|
866
664
|
|
|
867
|
-
|
|
665
|
+
const PaneSplitterContext = createContext({
|
|
868
666
|
orientation: 'start',
|
|
869
667
|
min: 0,
|
|
870
668
|
max: 0,
|
|
@@ -873,91 +671,92 @@ var PaneSplitterContext = createContext({
|
|
|
873
671
|
size: 0,
|
|
874
672
|
isRow: false
|
|
875
673
|
});
|
|
876
|
-
|
|
674
|
+
const usePaneSplitterContext = () => {
|
|
877
675
|
return useContext(PaneSplitterContext);
|
|
878
676
|
};
|
|
879
677
|
|
|
880
|
-
|
|
881
|
-
var paneToSplitterOrientation = {
|
|
678
|
+
const paneToSplitterOrientation = {
|
|
882
679
|
start: 'vertical',
|
|
883
680
|
end: 'vertical',
|
|
884
681
|
top: 'horizontal',
|
|
885
682
|
bottom: 'horizontal'
|
|
886
683
|
};
|
|
887
|
-
|
|
684
|
+
const orientationToDimension = {
|
|
888
685
|
start: 'columns',
|
|
889
686
|
end: 'columns',
|
|
890
687
|
top: 'rows',
|
|
891
688
|
bottom: 'rows'
|
|
892
689
|
};
|
|
893
|
-
|
|
690
|
+
const SplitterComponent = forwardRef((_ref, ref) => {
|
|
894
691
|
var _separatorRef$current, _separatorRef$current2;
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
692
|
+
let {
|
|
693
|
+
providerId,
|
|
694
|
+
layoutKey,
|
|
695
|
+
min,
|
|
696
|
+
max,
|
|
697
|
+
orientation,
|
|
698
|
+
onMouseDown,
|
|
699
|
+
onTouchStart,
|
|
700
|
+
onKeyDown,
|
|
701
|
+
onClick,
|
|
702
|
+
...props
|
|
703
|
+
} = _ref;
|
|
704
|
+
const paneProviderContext = usePaneProviderContextData(providerId);
|
|
705
|
+
const paneContext = usePaneContext();
|
|
706
|
+
const themeContext = useContext(ThemeContext);
|
|
707
|
+
const environment = useDocument(themeContext);
|
|
708
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
709
|
+
const isRow = orientationToDimension[orientation] === 'rows';
|
|
710
|
+
const separatorRef = useRef(null);
|
|
711
|
+
const splitterOrientation = paneToSplitterOrientation[orientation || 'end'];
|
|
712
|
+
const pixelsPerFr = paneProviderContext ? paneProviderContext.pixelsPerFr[orientationToDimension[orientation]] : 0;
|
|
713
|
+
const value = isRow ? paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getRowValue(layoutKey, true) : paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getColumnValue(layoutKey, true);
|
|
714
|
+
const valueInFr = isRow ? paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getRowValue(layoutKey) : paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.getColumnValue(layoutKey);
|
|
715
|
+
const {
|
|
716
|
+
getSeparatorProps,
|
|
717
|
+
getPrimaryPaneProps
|
|
718
|
+
} = useSplitter({
|
|
916
719
|
orientation: splitterOrientation,
|
|
917
720
|
isLeading: orientation === 'start' || orientation === 'top',
|
|
918
721
|
min: min * pixelsPerFr,
|
|
919
722
|
max: max * pixelsPerFr,
|
|
920
723
|
rtl: themeContext.rtl,
|
|
921
|
-
environment
|
|
922
|
-
onChange:
|
|
724
|
+
environment,
|
|
725
|
+
onChange: valueNow => {
|
|
923
726
|
if (isRow) {
|
|
924
727
|
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setRowValue(orientation === 'top', layoutKey, valueNow / pixelsPerFr);
|
|
925
728
|
}
|
|
926
729
|
return paneProviderContext === null || paneProviderContext === void 0 ? void 0 : paneProviderContext.setColumnValue(orientation === 'start', layoutKey, valueNow / pixelsPerFr);
|
|
927
730
|
},
|
|
928
731
|
valueNow: value,
|
|
929
|
-
separatorRef
|
|
930
|
-
})
|
|
931
|
-
|
|
932
|
-
getPrimaryPaneProps = _useSplitter.getPrimaryPaneProps;
|
|
933
|
-
useEffect(function () {
|
|
732
|
+
separatorRef
|
|
733
|
+
});
|
|
734
|
+
useEffect(() => {
|
|
934
735
|
if (!paneContext.id) {
|
|
935
736
|
paneContext.setId(getPrimaryPaneProps().id);
|
|
936
737
|
}
|
|
937
738
|
}, [paneContext, getPrimaryPaneProps]);
|
|
938
|
-
|
|
939
|
-
|
|
739
|
+
const ariaLabel = useText(SplitterComponent, props, 'aria-label', `${splitterOrientation} splitter`);
|
|
740
|
+
const separatorProps = getSeparatorProps({
|
|
940
741
|
'aria-controls': paneContext.id,
|
|
941
|
-
'aria-label': ariaLabel
|
|
742
|
+
'aria-label': ariaLabel,
|
|
743
|
+
onMouseDown,
|
|
744
|
+
onTouchStart,
|
|
745
|
+
onKeyDown,
|
|
746
|
+
onClick
|
|
942
747
|
});
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
return composeEventHandlers(props.onMouseOver, function (event) {
|
|
946
|
-
return setIsHovered(event.target === separatorRef.current);
|
|
947
|
-
});
|
|
948
|
-
}, [props.onMouseOver, separatorRef]);
|
|
748
|
+
const size = isRow ? (_separatorRef$current = separatorRef.current) === null || _separatorRef$current === void 0 ? void 0 : _separatorRef$current.clientWidth : (_separatorRef$current2 = separatorRef.current) === null || _separatorRef$current2 === void 0 ? void 0 : _separatorRef$current2.clientHeight;
|
|
749
|
+
const onMouseOver = useMemo(() => composeEventHandlers(props.onMouseOver, event => setIsHovered(event.target === separatorRef.current)), [props.onMouseOver, separatorRef]);
|
|
949
750
|
return React.createElement(PaneSplitterContext.Provider, {
|
|
950
|
-
value: useMemo(
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
};
|
|
960
|
-
}, [orientation, layoutKey, min, max, valueInFr, size, isRow])
|
|
751
|
+
value: useMemo(() => ({
|
|
752
|
+
orientation,
|
|
753
|
+
layoutKey,
|
|
754
|
+
min,
|
|
755
|
+
max,
|
|
756
|
+
valueNow: valueInFr,
|
|
757
|
+
size,
|
|
758
|
+
isRow
|
|
759
|
+
}), [orientation, layoutKey, min, max, valueInFr, size, isRow])
|
|
961
760
|
}, React.createElement(StyledPaneSplitter, _extends({
|
|
962
761
|
isHovered: isHovered,
|
|
963
762
|
orientation: orientation
|
|
@@ -976,33 +775,36 @@ SplitterComponent.propTypes = {
|
|
|
976
775
|
SplitterComponent.defaultProps = {
|
|
977
776
|
orientation: 'end'
|
|
978
777
|
};
|
|
979
|
-
|
|
778
|
+
const Splitter = SplitterComponent;
|
|
980
779
|
|
|
981
|
-
|
|
780
|
+
const ContentComponent = forwardRef((props, ref) => {
|
|
982
781
|
return React.createElement(StyledPaneContent, _extends({
|
|
983
782
|
ref: ref
|
|
984
783
|
}, props));
|
|
985
784
|
});
|
|
986
785
|
ContentComponent.displayName = 'Pane.Content';
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
786
|
+
const Content = ContentComponent;
|
|
787
|
+
|
|
788
|
+
const SplitterButtonComponent = forwardRef((props, ref) => {
|
|
789
|
+
const {
|
|
790
|
+
label,
|
|
791
|
+
placement: defaultPlacement
|
|
792
|
+
} = props;
|
|
793
|
+
const {
|
|
794
|
+
orientation,
|
|
795
|
+
layoutKey,
|
|
796
|
+
min,
|
|
797
|
+
max,
|
|
798
|
+
isRow,
|
|
799
|
+
valueNow,
|
|
800
|
+
size,
|
|
801
|
+
providerId
|
|
802
|
+
} = usePaneSplitterContext();
|
|
803
|
+
const paneProviderContext = usePaneProviderContextData(providerId);
|
|
804
|
+
const isTop = orientation === 'top';
|
|
805
|
+
const isStart = orientation === 'start';
|
|
806
|
+
const isMin = valueNow === min;
|
|
807
|
+
let placement = defaultPlacement;
|
|
1006
808
|
if (!defaultPlacement) {
|
|
1007
809
|
if (isRow) {
|
|
1008
810
|
placement = 'center';
|
|
@@ -1010,36 +812,30 @@ var SplitterButtonComponent = forwardRef(function (props, ref) {
|
|
|
1010
812
|
placement = 'start';
|
|
1011
813
|
}
|
|
1012
814
|
}
|
|
1013
|
-
|
|
815
|
+
const setValue = useCallback(value => {
|
|
1014
816
|
if (isRow) {
|
|
1015
817
|
paneProviderContext.setRowValue(isTop, layoutKey, value);
|
|
1016
818
|
} else {
|
|
1017
819
|
paneProviderContext.setColumnValue(isStart, layoutKey, value);
|
|
1018
820
|
}
|
|
1019
821
|
}, [isRow, isTop, isStart, layoutKey, paneProviderContext]);
|
|
1020
|
-
|
|
822
|
+
const onClick = composeEventHandlers(props.onClick, () => {
|
|
1021
823
|
if (isMin) {
|
|
1022
824
|
setValue(max);
|
|
1023
825
|
} else {
|
|
1024
826
|
setValue(min);
|
|
1025
827
|
}
|
|
1026
828
|
});
|
|
1027
|
-
|
|
1028
|
-
return event.stopPropagation();
|
|
1029
|
-
}
|
|
829
|
+
const onKeyDown = composeEventHandlers(props.onKeyDown, event => event.stopPropagation()
|
|
1030
830
|
);
|
|
1031
|
-
|
|
1032
|
-
return event.stopPropagation();
|
|
1033
|
-
}
|
|
831
|
+
const onMouseDown = composeEventHandlers(props.onMouseDown, event => event.stopPropagation()
|
|
1034
832
|
);
|
|
1035
833
|
return React.createElement(Tooltip, {
|
|
1036
834
|
content: label,
|
|
1037
835
|
style: {
|
|
1038
836
|
cursor: 'default'
|
|
1039
837
|
},
|
|
1040
|
-
onMouseDown:
|
|
1041
|
-
return e.stopPropagation();
|
|
1042
|
-
}
|
|
838
|
+
onMouseDown: e => e.stopPropagation()
|
|
1043
839
|
}, React.createElement(StyledPaneSplitterButton, _extends({
|
|
1044
840
|
"aria-label": label
|
|
1045
841
|
}, props, {
|
|
@@ -1054,24 +850,18 @@ var SplitterButtonComponent = forwardRef(function (props, ref) {
|
|
|
1054
850
|
})));
|
|
1055
851
|
});
|
|
1056
852
|
SplitterButtonComponent.displayName = 'Pane.SplitterButton';
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
id: paneId,
|
|
1070
|
-
setId: function setId(id) {
|
|
1071
|
-
return setPaneId(id);
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
}, [paneId]);
|
|
853
|
+
const SplitterButton = SplitterButtonComponent;
|
|
854
|
+
|
|
855
|
+
const PaneComponent = forwardRef((_ref, ref) => {
|
|
856
|
+
let {
|
|
857
|
+
children,
|
|
858
|
+
...props
|
|
859
|
+
} = _ref;
|
|
860
|
+
const [paneId, setPaneId] = useState();
|
|
861
|
+
const paneContext = useMemo(() => ({
|
|
862
|
+
id: paneId,
|
|
863
|
+
setId: id => setPaneId(id)
|
|
864
|
+
}), [paneId]);
|
|
1075
865
|
return React.createElement(PaneContext.Provider, {
|
|
1076
866
|
value: paneContext
|
|
1077
867
|
}, React.createElement(StyledPane, _extends({
|
|
@@ -1080,7 +870,7 @@ var PaneComponent = forwardRef(function (_ref, ref) {
|
|
|
1080
870
|
}, props), children));
|
|
1081
871
|
});
|
|
1082
872
|
PaneComponent.displayName = 'Pane';
|
|
1083
|
-
|
|
873
|
+
const Pane = PaneComponent;
|
|
1084
874
|
Pane.Content = Content;
|
|
1085
875
|
Pane.Splitter = Splitter;
|
|
1086
876
|
Pane.SplitterButton = SplitterButton;
|