react-align 2.0.3 → 2.1.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.
@@ -1,640 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var React = require('react');
8
- var React__default = _interopDefault(React);
9
- var reactBeautifulDnd = require('react-beautiful-dnd');
10
- var glamor = require('glamor');
11
-
12
- var Context = /*#__PURE__*/React.createContext({
13
- editing: false,
14
- isDragging: false
15
- });
16
- var useAlignContext = function useAlignContext() {
17
- return React.useContext(Context);
18
- };
19
-
20
- function styleInject(css, ref) {
21
- if ( ref === void 0 ) ref = {};
22
- var insertAt = ref.insertAt;
23
-
24
- if (!css || typeof document === 'undefined') { return; }
25
-
26
- var head = document.head || document.getElementsByTagName('head')[0];
27
- var style = document.createElement('style');
28
- style.type = 'text/css';
29
-
30
- if (insertAt === 'top') {
31
- if (head.firstChild) {
32
- head.insertBefore(style, head.firstChild);
33
- } else {
34
- head.appendChild(style);
35
- }
36
- } else {
37
- head.appendChild(style);
38
- }
39
-
40
- if (style.styleSheet) {
41
- style.styleSheet.cssText = css;
42
- } else {
43
- style.appendChild(document.createTextNode(css));
44
- }
45
- }
46
-
47
- var css_248z = ".wrapper{height:100%}.section,.wrapper{display:flex;justify-content:space-between}.section{flex-direction:column}.area{border:1px solid transparent;border-radius:8px;box-sizing:border-box;display:flex;position:relative}.area-transition-in{transition:all .3s ease-in-out,min-height .5s ease-in-out .2s,min-width .5s ease-in-out .2s}.area-transition-out{transition:all .3s ease-in-out .4s,min-height .5s ease-in-out .2s,min-width .5s ease-in-out .2s}.item{border:1px solid transparent;border-radius:6px;box-sizing:border-box;margin:6px;min-height:40px;min-width:70px;position:relative}.stretch{flex:auto}.middle{flex-grow:0;flex:auto}.just-centered{justify-content:center}.just-end{justify-content:flex-end}.end{align-items:flex-end}.hide{display:none}.overlay{background:rgba(0,0,0,.6);bottom:0;box-sizing:border-box;left:0;position:absolute;right:0;top:0}.overlay-buttons{box-sizing:border-box;display:flex;justify-content:space-between;padding:6px}";
48
- styleInject(css_248z);
49
-
50
- var GridWrapper = function GridWrapper(_ref) {
51
- var className = _ref.className,
52
- editing = _ref.editing,
53
- vertical = _ref.vertical,
54
- stretch = _ref.stretch,
55
- style = _ref.style,
56
- editorStyle = _ref.editorStyle,
57
- children = _ref.children,
58
- onMove = _ref.onMove,
59
- onAlignChange = _ref.onAlignChange,
60
- onExtend = _ref.onExtend;
61
-
62
- var _useState = React.useState(false),
63
- isDragging = _useState[0],
64
- setDragging = _useState[1];
65
-
66
- var handleDragStart = React.useCallback(function () {
67
- setDragging(true);
68
- }, []);
69
- var handleDragEnd = React.useCallback(function (result, _provided) {
70
- setDragging(false);
71
- if (!result.destination || result.reason !== 'DROP' || result.destination.droppableId === result.source.droppableId && result.destination.index === result.source.index) return;
72
- onMove == null ? void 0 : onMove(result.draggableId, result.destination.droppableId, result.destination.index, result.source.droppableId, result.source.index);
73
- }, [onMove]);
74
- return React__default.createElement("div", {
75
- className: "wrapper " + className + " " + (vertical && 'vertical') + " " + (stretch && 'stretch'),
76
- style: editing ? editorStyle : style
77
- }, React__default.createElement(reactBeautifulDnd.DragDropContext, {
78
- onDragStart: handleDragStart,
79
- onDragEnd: handleDragEnd
80
- }, React__default.createElement(Context.Provider, {
81
- value: {
82
- editing: !!editing,
83
- onAlignChange: onAlignChange,
84
- onExtend: onExtend,
85
- isDragging: isDragging
86
- }
87
- }, children)));
88
- };
89
-
90
- function _extends() {
91
- _extends = Object.assign || function (target) {
92
- for (var i = 1; i < arguments.length; i++) {
93
- var source = arguments[i];
94
-
95
- for (var key in source) {
96
- if (Object.prototype.hasOwnProperty.call(source, key)) {
97
- target[key] = source[key];
98
- }
99
- }
100
- }
101
-
102
- return target;
103
- };
104
-
105
- return _extends.apply(this, arguments);
106
- }
107
-
108
- function _objectWithoutPropertiesLoose(source, excluded) {
109
- if (source == null) return {};
110
- var target = {};
111
- var sourceKeys = Object.keys(source);
112
- var key, i;
113
-
114
- for (i = 0; i < sourceKeys.length; i++) {
115
- key = sourceKeys[i];
116
- if (excluded.indexOf(key) >= 0) continue;
117
- target[key] = source[key];
118
- }
119
-
120
- return target;
121
- }
122
-
123
- var GridSection = function GridSection(_ref) {
124
- var className = _ref.className,
125
- horizontal = _ref.horizontal,
126
- stretch = _ref.stretch,
127
- fixedWidth = _ref.fixedWidth,
128
- fixedHeight = _ref.fixedHeight,
129
- style = _ref.style,
130
- editorStyle = _ref.editorStyle,
131
- children = _ref.children;
132
-
133
- var _useAlignContext = useAlignContext(),
134
- enabled = _useAlignContext.editing;
135
-
136
- return React__default.createElement("div", {
137
- className: "section " + className + " " + (horizontal ? 'horizontal' : '') + " " + (stretch ? 'stretch' : ''),
138
- style: _extends({}, enabled ? editorStyle : style, typeof fixedHeight === 'number' ? {
139
- height: fixedHeight + 'px'
140
- } : {}, typeof fixedWidth === 'number' ? {
141
- width: fixedWidth + 'px'
142
- } : {})
143
- }, children);
144
- };
145
-
146
- var _path;
147
-
148
- function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
149
-
150
- function SvgHorizontalExtend(props) {
151
- return /*#__PURE__*/React.createElement("svg", _extends$1({
152
- width: 24,
153
- height: 24,
154
- fill: "none",
155
- xmlns: "http://www.w3.org/2000/svg"
156
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
157
- d: "M1 20.25V3.75M23 20.25V3.75M12 12h8.5M17.5 9l3 3-3 3M12 12H4M7 15l-3-3 3-3",
158
- stroke: "currentColor",
159
- strokeWidth: 1.5,
160
- strokeLinecap: "round",
161
- strokeLinejoin: "round"
162
- })));
163
- }
164
-
165
- var _path$1, _rect;
166
-
167
- function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
168
-
169
- function SvgHorizontalNormal(props) {
170
- return /*#__PURE__*/React.createElement("svg", _extends$2({
171
- width: 24,
172
- height: 24,
173
- fill: "none",
174
- xmlns: "http://www.w3.org/2000/svg"
175
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
176
- d: "M1 12h5M3 9l3 3-3 3M23 12h-5M21 15l-3-3 3-3",
177
- stroke: "currentColor",
178
- strokeWidth: 1.5,
179
- strokeLinecap: "round",
180
- strokeLinejoin: "round"
181
- })), _rect || (_rect = /*#__PURE__*/React.createElement("rect", {
182
- x: 8.75,
183
- y: 2.75,
184
- width: 6.5,
185
- height: 18.5,
186
- rx: 1.25,
187
- stroke: "currentColor",
188
- strokeWidth: 1.5
189
- })));
190
- }
191
-
192
- var _path$2;
193
-
194
- function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
195
-
196
- function SvgVerticalExtend(props) {
197
- return /*#__PURE__*/React.createElement("svg", _extends$3({
198
- width: 24,
199
- height: 24,
200
- fill: "none",
201
- xmlns: "http://www.w3.org/2000/svg"
202
- }, props), _path$2 || (_path$2 = /*#__PURE__*/React.createElement("path", {
203
- d: "M3.75 1h16.5M3.75 23h16.5M12 12v8.5M15 17.5l-3 3-3-3M12 12V4M9 7l3-3 3 3",
204
- stroke: "currentColor",
205
- strokeWidth: 1.5,
206
- strokeLinecap: "round",
207
- strokeLinejoin: "round"
208
- })));
209
- }
210
-
211
- var _path$3, _rect$1;
212
-
213
- function _extends$4() { _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
214
-
215
- function SvgVerticalNormal(props) {
216
- return /*#__PURE__*/React.createElement("svg", _extends$4({
217
- width: 24,
218
- height: 24,
219
- fill: "none",
220
- xmlns: "http://www.w3.org/2000/svg"
221
- }, props), _path$3 || (_path$3 = /*#__PURE__*/React.createElement("path", {
222
- d: "M12 1v5M15 3l-3 3-3-3M12 23v-5M9 21l3-3 3 3",
223
- stroke: "currentColor",
224
- strokeWidth: 1.5,
225
- strokeLinecap: "round",
226
- strokeLinejoin: "round"
227
- })), _rect$1 || (_rect$1 = /*#__PURE__*/React.createElement("rect", {
228
- x: 21.25,
229
- y: 8.75,
230
- width: 6.5,
231
- height: 18.5,
232
- rx: 1.25,
233
- transform: "rotate(90 21.25 8.75)",
234
- stroke: "currentColor",
235
- strokeWidth: 1.5
236
- })));
237
- }
238
-
239
- var _path$4;
240
-
241
- function _extends$5() { _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
242
-
243
- function SvgMoveArrows(props) {
244
- return /*#__PURE__*/React.createElement("svg", _extends$5({
245
- width: 24,
246
- height: 24,
247
- fill: "none",
248
- xmlns: "http://www.w3.org/2000/svg"
249
- }, props), _path$4 || (_path$4 = /*#__PURE__*/React.createElement("path", {
250
- d: "M14.651 19.098L12 21.749l-2.652-2.651M12 15v6.75M9.348 4.902L12 2.25l2.651 2.652M12 9V2.25M4.902 14.65L2.25 12l2.652-2.652M9 12H2.25M19.098 9.348l2.652 2.651-2.652 2.652M15 12h6.75",
251
- stroke: "currentColor",
252
- strokeWidth: 1.5,
253
- strokeLinecap: "round",
254
- strokeLinejoin: "round"
255
- })));
256
- }
257
-
258
- var _rect$2, _path$5;
259
-
260
- function _extends$6() { _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
261
-
262
- function SvgAlignStart(props) {
263
- return /*#__PURE__*/React.createElement("svg", _extends$6({
264
- width: 24,
265
- height: 24,
266
- fill: "none",
267
- xmlns: "http://www.w3.org/2000/svg"
268
- }, props), _rect$2 || (_rect$2 = /*#__PURE__*/React.createElement("rect", {
269
- width: 24,
270
- height: 24,
271
- rx: 4,
272
- fill: "#000",
273
- fillOpacity: 0.5
274
- })), _path$5 || (_path$5 = /*#__PURE__*/React.createElement("path", {
275
- fillRule: "evenodd",
276
- clipRule: "evenodd",
277
- d: "M5 5h14v14H5V5zM4 4h16v16H4V4zm2 6a1 1 0 012 0v4a1 1 0 11-2 0v-4zm3 0a1 1 0 012 0v4a1 1 0 11-2 0v-4zm4-1a1 1 0 00-1 1v4a1 1 0 102 0v-4a1 1 0 00-1-1z",
278
- fill: "currentColor"
279
- })));
280
- }
281
-
282
- var _rect$3, _path$6;
283
-
284
- function _extends$7() { _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$7.apply(this, arguments); }
285
-
286
- function SvgAlignCenter(props) {
287
- return /*#__PURE__*/React.createElement("svg", _extends$7({
288
- width: 24,
289
- height: 24,
290
- fill: "none",
291
- xmlns: "http://www.w3.org/2000/svg"
292
- }, props), _rect$3 || (_rect$3 = /*#__PURE__*/React.createElement("rect", {
293
- width: 24,
294
- height: 24,
295
- rx: 4,
296
- fill: "#000",
297
- fillOpacity: 0.5
298
- })), _path$6 || (_path$6 = /*#__PURE__*/React.createElement("path", {
299
- fillRule: "evenodd",
300
- clipRule: "evenodd",
301
- d: "M19 19H5V5h14v14zm1 1H4V4h16v16zm-4-6a1 1 0 11-2 0v-4a1 1 0 112 0v4zm-3 0a1 1 0 11-2 0v-4a1 1 0 112 0v4zm-4 1a1 1 0 001-1v-4a1 1 0 10-2 0v4a1 1 0 001 1z",
302
- fill: "currentColor"
303
- })));
304
- }
305
-
306
- var _rect$4, _path$7;
307
-
308
- function _extends$8() { _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$8.apply(this, arguments); }
309
-
310
- function SvgAlignEnd(props) {
311
- return /*#__PURE__*/React.createElement("svg", _extends$8({
312
- width: 24,
313
- height: 24,
314
- fill: "none",
315
- xmlns: "http://www.w3.org/2000/svg"
316
- }, props), _rect$4 || (_rect$4 = /*#__PURE__*/React.createElement("rect", {
317
- width: 24,
318
- height: 24,
319
- rx: 4,
320
- fill: "#000",
321
- fillOpacity: 0.5
322
- })), _path$7 || (_path$7 = /*#__PURE__*/React.createElement("path", {
323
- fillRule: "evenodd",
324
- clipRule: "evenodd",
325
- d: "M19 19H5V5h14v14zm1 1H4V4h16v16zm-2-6a1 1 0 11-2 0v-4a1 1 0 112 0v4zm-3 0a1 1 0 11-2 0v-4a1 1 0 112 0v4zm-4 1a1 1 0 001-1v-4a1 1 0 10-2 0v4a1 1 0 001 1z",
326
- fill: "currentColor"
327
- })));
328
- }
329
-
330
- var _rect$5, _path$8;
331
-
332
- function _extends$9() { _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
333
-
334
- function SvgAlignStartV(props) {
335
- return /*#__PURE__*/React.createElement("svg", _extends$9({
336
- width: 24,
337
- height: 24,
338
- fill: "none",
339
- xmlns: "http://www.w3.org/2000/svg"
340
- }, props), _rect$5 || (_rect$5 = /*#__PURE__*/React.createElement("rect", {
341
- y: 24,
342
- width: 24,
343
- height: 24,
344
- rx: 4,
345
- transform: "rotate(-90 0 24)",
346
- fill: "#000",
347
- fillOpacity: 0.5
348
- })), _path$8 || (_path$8 = /*#__PURE__*/React.createElement("path", {
349
- fillRule: "evenodd",
350
- clipRule: "evenodd",
351
- d: "M19 5v14H5V5h14zm1-1v16H4V4h16zm-6 2a1 1 0 110 2h-4a1 1 0 110-2h4zm0 3a1 1 0 110 2h-4a1 1 0 110-2h4zm1 4a1 1 0 00-1-1h-4a1 1 0 100 2h4a1 1 0 001-1z",
352
- fill: "currentColor"
353
- })));
354
- }
355
-
356
- var _rect$6, _path$9;
357
-
358
- function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
359
-
360
- function SvgAlignCenterV(props) {
361
- return /*#__PURE__*/React.createElement("svg", _extends$a({
362
- width: 24,
363
- height: 24,
364
- fill: "none",
365
- xmlns: "http://www.w3.org/2000/svg"
366
- }, props), _rect$6 || (_rect$6 = /*#__PURE__*/React.createElement("rect", {
367
- y: 24,
368
- width: 24,
369
- height: 24,
370
- rx: 4,
371
- transform: "rotate(-90 0 24)",
372
- fill: "#000",
373
- fillOpacity: 0.5
374
- })), _path$9 || (_path$9 = /*#__PURE__*/React.createElement("path", {
375
- fillRule: "evenodd",
376
- clipRule: "evenodd",
377
- d: "M19 5v14H5V5h14zm1-1v16H4V4h16zm-6 4a1 1 0 110 2h-4a1 1 0 110-2h4zm0 3a1 1 0 110 2h-4a1 1 0 110-2h4zm1 4a1 1 0 00-1-1h-4a1 1 0 100 2h4a1 1 0 001-1z",
378
- fill: "currentColor"
379
- })));
380
- }
381
-
382
- var _rect$7, _path$a;
383
-
384
- function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
385
-
386
- function SvgAlignEndV(props) {
387
- return /*#__PURE__*/React.createElement("svg", _extends$b({
388
- width: 24,
389
- height: 24,
390
- fill: "none",
391
- xmlns: "http://www.w3.org/2000/svg"
392
- }, props), _rect$7 || (_rect$7 = /*#__PURE__*/React.createElement("rect", {
393
- y: 24,
394
- width: 24,
395
- height: 24,
396
- rx: 4,
397
- transform: "rotate(-90 0 24)",
398
- fill: "#000",
399
- fillOpacity: 0.5
400
- })), _path$a || (_path$a = /*#__PURE__*/React.createElement("path", {
401
- fillRule: "evenodd",
402
- clipRule: "evenodd",
403
- d: "M5 19V5h14v14H5zm-1 1V4h16v16H4zm6-2a1 1 0 110-2h4a1 1 0 110 2h-4zm0-3a1 1 0 110-2h4a1 1 0 110 2h-4zm-1-4a1 1 0 001 1h4a1 1 0 100-2h-4a1 1 0 00-1 1z",
404
- fill: "currentColor"
405
- })));
406
- }
407
-
408
- var Icons = {
409
- horizontalExtend: SvgHorizontalExtend,
410
- horizontalNormal: SvgHorizontalNormal,
411
- verticalExtend: SvgVerticalExtend,
412
- verticalNormal: SvgVerticalNormal,
413
- moveArrows: SvgMoveArrows,
414
- alignStart: SvgAlignStart,
415
- alignCenter: SvgAlignCenter,
416
- alignEnd: SvgAlignEnd,
417
- alignStartV: SvgAlignStartV,
418
- alignCenterV: SvgAlignCenterV,
419
- alignEndV: SvgAlignEndV
420
- };
421
-
422
- var IconStyles = function IconStyles(size) {
423
- return glamor.css({
424
- cursor: 'pointer',
425
- width: size || 24 + 'px',
426
- height: size || 24 + 'px',
427
- ' svg': {
428
- height: size || 24 + 'px',
429
- width: size || 24 + 'px'
430
- }
431
- });
432
- };
433
-
434
- var Icon = function Icon(_ref) {
435
- var className = _ref.className,
436
- name = _ref.name,
437
- size = _ref.size,
438
- style = _ref.style,
439
- onClick = _ref.onClick;
440
- var LocalIconComponent = Icons[name];
441
- return React__default.createElement(LocalIconComponent, Object.assign({
442
- className: className
443
- }, IconStyles(size), {
444
- style: style,
445
- onClick: onClick
446
- }));
447
- };
448
-
449
- var alignments = ['start', 'centered', 'end'];
450
- function GridArea(_ref) {
451
- var id = _ref.id,
452
- className = _ref.className,
453
- vertical = _ref.vertical,
454
- stretch = _ref.stretch,
455
- end = _ref.end,
456
- disabled = _ref.disabled,
457
- align = _ref.align,
458
- onAlignChange = _ref.onAlignChange,
459
- children = _ref.children,
460
- style = _ref.style,
461
- editorStyle = _ref.editorStyle,
462
- _ref$iconColor = _ref.iconColor,
463
- iconColor = _ref$iconColor === void 0 ? '#FFFFFF' : _ref$iconColor;
464
-
465
- var _useAlignContext = useAlignContext(),
466
- enabled = _useAlignContext.editing,
467
- onAlignChange2 = _useAlignContext.onAlignChange;
468
-
469
- var handleAlignChange = React.useCallback(function () {
470
- var a = alignments[(align ? alignments.indexOf(align) + 1 : 0) % alignments.length];
471
- onAlignChange == null ? void 0 : onAlignChange(a);
472
- onAlignChange2 == null ? void 0 : onAlignChange2(id, a);
473
- }, [align, onAlignChange, onAlignChange2, id]);
474
- var buttonStyle = React.useMemo(function () {
475
- return {
476
- position: 'absolute',
477
- left: vertical ? end ? 0 : undefined : '50%',
478
- right: vertical ? !end ? 0 : undefined : '50%',
479
- bottom: !vertical && !end ? 0 : vertical ? '50%' : undefined,
480
- top: vertical ? '50%' : end ? 0 : undefined,
481
- opacity: !disabled && enabled && align ? 1 : 0,
482
- pointerEvents: !disabled && enabled && align ? 'auto' : 'none',
483
- transition: 'all 0.5s ease-in-out'
484
- };
485
- }, [vertical, end, disabled, enabled, align]); // Rebuilds the GridItem children to receive their parent GridArea's 'end' and 'vertical' values.
486
- // Used to know where to align the overlay buttons (end) and how to extend the GridItems (vertical).
487
-
488
- var childrenWithParentProps = React.useMemo(function () {
489
- return React__default.Children.map(children, function (child) {
490
- return React__default.cloneElement(child, {
491
- end: end,
492
- vertical: vertical
493
- });
494
- });
495
- }, [children, end, vertical]);
496
- return React__default.createElement(reactBeautifulDnd.Droppable, {
497
- droppableId: id,
498
- direction: vertical ? 'vertical' : 'horizontal',
499
- isDropDisabled: disabled
500
- }, function (provided, snapshot) {
501
- return React__default.createElement("div", Object.assign({
502
- ref: provided.innerRef
503
- }, provided.droppableProps, {
504
- className: [className, 'area', stretch && 'stretch', end && 'end', align === 'centered' ? 'just-centered' : align === 'end' ? 'just-end' : 'start', enabled ? 'area-transition-in' : 'area-transition-out'].filter(Boolean).join(' '),
505
- style: _extends({
506
- flexDirection: vertical ? 'column' : 'row',
507
- minHeight: !React__default.Children.count(children) && !enabled ? '0px' : '26px',
508
- minWidth: !React__default.Children.count(children) && !enabled ? '0px' : '46px',
509
- opacity: snapshot.isDraggingOver ? 0.8 : 1
510
- }, enabled ? editorStyle : style)
511
- }), childrenWithParentProps, provided.placeholder, React__default.createElement("div", {
512
- style: buttonStyle
513
- }, React__default.createElement("div", {
514
- onClick: handleAlignChange,
515
- style: {
516
- cursor: 'pointer'
517
- }
518
- }, React__default.createElement(Icon, {
519
- name: align === 'centered' ? vertical ? 'alignCenterV' : 'alignCenter' : align === 'end' ? vertical ? 'alignEndV' : 'alignEnd' : vertical ? 'alignStartV' : 'alignStart',
520
- style: {
521
- color: iconColor
522
- }
523
- }))));
524
- });
525
- }
526
-
527
- function GridItem(_ref) {
528
- var className = _ref.className,
529
- children = _ref.children,
530
- id = _ref.id,
531
- index = _ref.index,
532
- _ref$extendable = _ref.extendable,
533
- extendable = _ref$extendable === void 0 ? false : _ref$extendable,
534
- _ref$extended = _ref.extended,
535
- extended = _ref$extended === void 0 ? false : _ref$extended,
536
- _ref$disabled = _ref.disabled,
537
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
538
- style = _ref.style,
539
- editorStyle = _ref.editorStyle,
540
- iconSize = _ref.iconSize,
541
- _ref$iconColor = _ref.iconColor,
542
- iconColor = _ref$iconColor === void 0 ? 'rgb(255, 255, 255)' : _ref$iconColor,
543
- props = _objectWithoutPropertiesLoose(_ref, ["className", "children", "id", "index", "extendable", "extended", "disabled", "style", "editorStyle", "iconSize", "iconColor"]);
544
-
545
- var end = props.end,
546
- vertical = props.vertical;
547
-
548
- var _useAlignContext = useAlignContext(),
549
- editing = _useAlignContext.editing,
550
- isDragging = _useAlignContext.isDragging,
551
- onExtend = _useAlignContext.onExtend;
552
-
553
- var _useState = React.useState(false),
554
- isHovered = _useState[0],
555
- setHovered = _useState[1];
556
-
557
- var handleExtend = React.useCallback(function () {
558
- if (!extendable) return;
559
- setHovered(false);
560
- onExtend == null ? void 0 : onExtend(id, !extended);
561
- }, [extendable, onExtend, extended, id]);
562
- var buttonStyles = React.useMemo(function () {
563
- return {
564
- alignItems: end ? 'end' : 'start',
565
- "float": end ? 'right' : 'left'
566
- };
567
- }, [end]);
568
- var ctx = React.useMemo(function () {
569
- return {
570
- id: id,
571
- editing: editing,
572
- isDragging: isDragging,
573
- isHovered: isHovered,
574
- extended: extended,
575
- extendable: extendable,
576
- disabled: disabled,
577
- index: index
578
- };
579
- }, [disabled, editing, extendable, extended, id, index, isDragging, isHovered]);
580
- return React__default.createElement(reactBeautifulDnd.Draggable, {
581
- draggableId: id,
582
- index: index,
583
- isDragDisabled: disabled
584
- }, function (provided, snapshot) {
585
- return React__default.createElement("div", Object.assign({
586
- ref: provided.innerRef
587
- }, provided.draggableProps, {
588
- className: className + " item",
589
- style: _extends({
590
- flex: extended && !snapshot.isDragging ? 'auto' : undefined,
591
- opacity: snapshot.isDragging ? 0.5 : 1
592
- }, editing ? editorStyle : style, provided.draggableProps.style),
593
- onMouseEnter: function onMouseEnter() {
594
- return setHovered(true);
595
- },
596
- onMouseLeave: function onMouseLeave() {
597
- return setHovered(false);
598
- }
599
- }), React__default.createElement("div", {
600
- style: {
601
- width: '100%',
602
- height: '100%',
603
- pointerEvents: editing ? 'none' : undefined
604
- }
605
- }, typeof children === 'function' ? children(ctx) : children), React__default.createElement("div", {
606
- className: "overlay",
607
- style: {
608
- display: !disabled && editing && isHovered && (snapshot.isDragging || !isDragging) ? 'block' : 'none'
609
- }
610
- }, React__default.createElement("div", {
611
- className: "overlay-buttons",
612
- style: buttonStyles
613
- }, React__default.createElement("div", Object.assign({}, provided.dragHandleProps), React__default.createElement(Icon, {
614
- name: "moveArrows",
615
- size: iconSize,
616
- style: {
617
- color: iconColor
618
- }
619
- })), extendable && React__default.createElement("div", {
620
- style: {
621
- cursor: 'pointer',
622
- marginLeft: '8px'
623
- },
624
- onClick: handleExtend
625
- }, React__default.createElement(Icon, {
626
- name: vertical ? 'verticalExtend' : 'horizontalExtend',
627
- size: iconSize,
628
- style: {
629
- color: iconColor
630
- }
631
- })))));
632
- });
633
- }
634
-
635
- exports.GridArea = GridArea;
636
- exports.GridItem = GridItem;
637
- exports.GridSection = GridSection;
638
- exports.GridWrapper = GridWrapper;
639
- exports.Icon = Icon;
640
- //# sourceMappingURL=react-align.cjs.development.js.map