react-grid-layout 1.5.2 → 2.0.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 +1075 -432
- package/css/styles.css +6 -4
- package/dist/ResponsiveGridLayout-CH4s0tKj.d.ts +124 -0
- package/dist/ResponsiveGridLayout-D6lFRE3f.d.mts +124 -0
- package/dist/calculate-CwYDW8na.d.mts +168 -0
- package/dist/calculate-mgLpNJ5O.d.ts +168 -0
- package/dist/chunk-2KUHNJXF.mjs +90 -0
- package/dist/chunk-2KUHNJXF.mjs.map +1 -0
- package/dist/chunk-3WO4SAYB.js +868 -0
- package/dist/chunk-3WO4SAYB.js.map +1 -0
- package/dist/chunk-4HNUMWQK.mjs +822 -0
- package/dist/chunk-4HNUMWQK.mjs.map +1 -0
- package/dist/chunk-BFTKGAP3.js +1309 -0
- package/dist/chunk-BFTKGAP3.js.map +1 -0
- package/dist/chunk-F6NQPYKT.js +98 -0
- package/dist/chunk-F6NQPYKT.js.map +1 -0
- package/dist/chunk-H5KMDLY3.js +434 -0
- package/dist/chunk-H5KMDLY3.js.map +1 -0
- package/dist/chunk-PBQSHIID.js +4 -0
- package/dist/chunk-PBQSHIID.js.map +1 -0
- package/dist/chunk-R35HZZTA.mjs +1300 -0
- package/dist/chunk-R35HZZTA.mjs.map +1 -0
- package/dist/chunk-ZCXE6SR5.mjs +428 -0
- package/dist/chunk-ZCXE6SR5.mjs.map +1 -0
- package/dist/chunk-ZWN22PS2.mjs +3 -0
- package/dist/chunk-ZWN22PS2.mjs.map +1 -0
- package/dist/core.d.mts +33 -0
- package/dist/core.d.ts +33 -0
- package/dist/core.js +218 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +5 -0
- package/dist/core.mjs.map +1 -0
- package/dist/extras.d.mts +78 -0
- package/dist/extras.d.ts +78 -0
- package/dist/extras.js +91 -0
- package/dist/extras.js.map +1 -0
- package/dist/extras.mjs +89 -0
- package/dist/extras.mjs.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/legacy.d.mts +163 -0
- package/dist/legacy.d.ts +163 -0
- package/dist/legacy.js +319 -0
- package/dist/legacy.js.map +1 -0
- package/dist/legacy.mjs +307 -0
- package/dist/legacy.mjs.map +1 -0
- package/dist/position-BmN1z36J.d.mts +319 -0
- package/dist/position-Dk2b4ZMS.d.ts +319 -0
- package/dist/react.d.mts +351 -0
- package/dist/react.d.ts +351 -0
- package/dist/react.js +96 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +7 -0
- package/dist/react.mjs.map +1 -0
- package/dist/responsive-C4L1ESlm.d.ts +145 -0
- package/dist/responsive-CJxefsYw.d.mts +145 -0
- package/dist/types-Cxf4nHNr.d.mts +375 -0
- package/dist/types-Cxf4nHNr.d.ts +375 -0
- package/index-dev.js +8 -0
- package/package.json +132 -39
- package/.babelrc.js +0 -22
- package/.browserslistrc +0 -3
- package/.eslintignore +0 -4
- package/.flowconfig +0 -20
- package/.prettierignore +0 -4
- package/.prettierrc +0 -17
- package/CHANGELOG.md +0 -985
- package/build/GridItem.js +0 -640
- package/build/ReactGridLayout.js +0 -744
- package/build/ReactGridLayoutPropTypes.js +0 -210
- package/build/ResponsiveReactGridLayout.js +0 -294
- package/build/calculateUtils.js +0 -165
- package/build/components/WidthProvider.js +0 -111
- package/build/fastRGLPropsEqual.js +0 -5
- package/build/responsiveUtils.js +0 -101
- package/build/utils.js +0 -834
- package/dist/react-grid-layout.min.js +0 -2
- package/dist/react-grid-layout.min.js.map +0 -1
- package/index.js.flow +0 -8
- package/ip_fetcher +0 -0
- package/ip_fetcher.c +0 -47
- package/lib/GridItem.jsx +0 -689
- package/lib/ReactGridLayout.jsx +0 -855
- package/lib/ReactGridLayoutPropTypes.js +0 -241
- package/lib/ResponsiveReactGridLayout.jsx +0 -349
- package/lib/calculateUtils.js +0 -169
- package/lib/components/WidthProvider.jsx +0 -110
- package/lib/fastRGLPropsEqual.js +0 -46
- package/lib/responsiveUtils.js +0 -118
- package/lib/utils.js +0 -979
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = WidthProvideRGL;
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
|
10
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
16
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
-
/*:: import type { ReactRef } from "../ReactGridLayoutPropTypes";*/
|
|
18
|
-
/*:: type WPDefaultProps = {|
|
|
19
|
-
measureBeforeMount: boolean
|
|
20
|
-
|};*/
|
|
21
|
-
/*:: type WPProps = {|
|
|
22
|
-
className?: string,
|
|
23
|
-
style?: Object,
|
|
24
|
-
...WPDefaultProps
|
|
25
|
-
|};*/
|
|
26
|
-
// eslint-disable-next-line no-unused-vars
|
|
27
|
-
/*:: type WPState = {|
|
|
28
|
-
width: number
|
|
29
|
-
|};*/
|
|
30
|
-
/*:: type ComposedProps<Config> = {|
|
|
31
|
-
...Config,
|
|
32
|
-
measureBeforeMount?: boolean,
|
|
33
|
-
className?: string,
|
|
34
|
-
style?: Object,
|
|
35
|
-
width?: number
|
|
36
|
-
|};*/
|
|
37
|
-
const layoutClassName = "react-grid-layout";
|
|
38
|
-
|
|
39
|
-
/*
|
|
40
|
-
* A simple HOC that provides facility for listening to container resizes.
|
|
41
|
-
*
|
|
42
|
-
* The Flow type is pretty janky here. I can't just spread `WPProps` into this returned object - I wish I could - but it triggers
|
|
43
|
-
* a flow bug of some sort that causes it to stop typechecking.
|
|
44
|
-
*/
|
|
45
|
-
function WidthProvideRGL /*:: <Config>*/(ComposedComponent /*: React.AbstractComponent<Config>*/) /*: React.AbstractComponent<ComposedProps<Config>>*/{
|
|
46
|
-
var _WidthProvider;
|
|
47
|
-
return _WidthProvider = class WidthProvider extends React.Component
|
|
48
|
-
/*:: <
|
|
49
|
-
ComposedProps<Config>,
|
|
50
|
-
WPState
|
|
51
|
-
>*/
|
|
52
|
-
{
|
|
53
|
-
constructor() {
|
|
54
|
-
super(...arguments);
|
|
55
|
-
_defineProperty(this, "state", {
|
|
56
|
-
width: 1280
|
|
57
|
-
});
|
|
58
|
-
_defineProperty(this, "elementRef", /*#__PURE__*/React.createRef());
|
|
59
|
-
_defineProperty(this, "mounted", false);
|
|
60
|
-
_defineProperty(this, "resizeObserver", void 0);
|
|
61
|
-
}
|
|
62
|
-
componentDidMount() {
|
|
63
|
-
this.mounted = true;
|
|
64
|
-
this.resizeObserver = new _resizeObserverPolyfill.default(entries => {
|
|
65
|
-
const node = this.elementRef.current;
|
|
66
|
-
if (node instanceof HTMLElement) {
|
|
67
|
-
const width = entries[0].contentRect.width;
|
|
68
|
-
this.setState({
|
|
69
|
-
width
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const node = this.elementRef.current;
|
|
74
|
-
if (node instanceof HTMLElement) {
|
|
75
|
-
this.resizeObserver.observe(node);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
componentWillUnmount() {
|
|
79
|
-
this.mounted = false;
|
|
80
|
-
const node = this.elementRef.current;
|
|
81
|
-
if (node instanceof HTMLElement) {
|
|
82
|
-
this.resizeObserver.unobserve(node);
|
|
83
|
-
}
|
|
84
|
-
this.resizeObserver.disconnect();
|
|
85
|
-
}
|
|
86
|
-
render() {
|
|
87
|
-
const {
|
|
88
|
-
measureBeforeMount,
|
|
89
|
-
...rest
|
|
90
|
-
} = this.props;
|
|
91
|
-
if (measureBeforeMount && !this.mounted) {
|
|
92
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
-
className: (0, _clsx.default)(this.props.className, layoutClassName),
|
|
94
|
-
style: this.props.style
|
|
95
|
-
// $FlowIgnore ref types
|
|
96
|
-
,
|
|
97
|
-
ref: this.elementRef
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return /*#__PURE__*/React.createElement(ComposedComponent, _extends({
|
|
101
|
-
innerRef: this.elementRef
|
|
102
|
-
}, rest, this.state));
|
|
103
|
-
}
|
|
104
|
-
}, _defineProperty(_WidthProvider, "defaultProps", {
|
|
105
|
-
measureBeforeMount: false
|
|
106
|
-
}), _defineProperty(_WidthProvider, "propTypes", {
|
|
107
|
-
// If true, will not render children until mounted. Useful for getting the exact width before
|
|
108
|
-
// rendering, to prevent any unsightly resizing.
|
|
109
|
-
measureBeforeMount: _propTypes.default.bool
|
|
110
|
-
}), _WidthProvider;
|
|
111
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// this file was prevaled
|
|
2
|
-
module.exports = function fastRGLPropsEqual(a, b, isEqualImpl) {
|
|
3
|
-
if (a === b) return true;
|
|
4
|
-
return a.className === b.className && isEqualImpl(a.style, b.style) && a.width === b.width && a.autoSize === b.autoSize && a.cols === b.cols && a.draggableCancel === b.draggableCancel && a.draggableHandle === b.draggableHandle && isEqualImpl(a.verticalCompact, b.verticalCompact) && isEqualImpl(a.compactType, b.compactType) && isEqualImpl(a.layout, b.layout) && isEqualImpl(a.margin, b.margin) && isEqualImpl(a.containerPadding, b.containerPadding) && a.rowHeight === b.rowHeight && a.maxRows === b.maxRows && a.isBounded === b.isBounded && a.isDraggable === b.isDraggable && a.isResizable === b.isResizable && a.allowOverlap === b.allowOverlap && a.preventCollision === b.preventCollision && a.useCSSTransforms === b.useCSSTransforms && a.transformScale === b.transformScale && a.isDroppable === b.isDroppable && isEqualImpl(a.resizeHandles, b.resizeHandles) && isEqualImpl(a.resizeHandle, b.resizeHandle) && a.onLayoutChange === b.onLayoutChange && a.onDragStart === b.onDragStart && a.onDrag === b.onDrag && a.onDragStop === b.onDragStop && a.onResizeStart === b.onResizeStart && a.onResize === b.onResize && a.onResizeStop === b.onResizeStop && a.onDrop === b.onDrop && isEqualImpl(a.droppingItem, b.droppingItem) && isEqualImpl(a.innerRef, b.innerRef);
|
|
5
|
-
};
|
package/build/responsiveUtils.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout;
|
|
7
|
-
exports.getBreakpointFromWidth = getBreakpointFromWidth;
|
|
8
|
-
exports.getColsFromBreakpoint = getColsFromBreakpoint;
|
|
9
|
-
exports.sortBreakpoints = sortBreakpoints;
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
/*:: import type { CompactType, Layout } from "./utils";*/
|
|
12
|
-
/*:: export type Breakpoint = string;*/
|
|
13
|
-
/*:: export type DefaultBreakpoints = "lg" | "md" | "sm" | "xs" | "xxs";*/
|
|
14
|
-
/*:: export type ResponsiveLayout<T: Breakpoint> = {
|
|
15
|
-
+[breakpoint: T]: Layout
|
|
16
|
-
};*/
|
|
17
|
-
// + indicates read-only
|
|
18
|
-
/*:: export type Breakpoints<T: Breakpoint> = {
|
|
19
|
-
+[breakpoint: T]: number
|
|
20
|
-
};*/
|
|
21
|
-
/*:: export type OnLayoutChangeCallback = (
|
|
22
|
-
Layout,
|
|
23
|
-
{ [key: Breakpoint]: Layout }
|
|
24
|
-
) => void;*/
|
|
25
|
-
/**
|
|
26
|
-
* Given a width, find the highest breakpoint that matches is valid for it (width > breakpoint).
|
|
27
|
-
*
|
|
28
|
-
* @param {Object} breakpoints Breakpoints object (e.g. {lg: 1200, md: 960, ...})
|
|
29
|
-
* @param {Number} width Screen width.
|
|
30
|
-
* @return {String} Highest breakpoint that is less than width.
|
|
31
|
-
*/
|
|
32
|
-
function getBreakpointFromWidth(breakpoints /*: Breakpoints<Breakpoint>*/, width /*: number*/) /*: Breakpoint*/{
|
|
33
|
-
const sorted = sortBreakpoints(breakpoints);
|
|
34
|
-
let matching = sorted[0];
|
|
35
|
-
for (let i = 1, len = sorted.length; i < len; i++) {
|
|
36
|
-
const breakpointName = sorted[i];
|
|
37
|
-
if (width > breakpoints[breakpointName]) matching = breakpointName;
|
|
38
|
-
}
|
|
39
|
-
return matching;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Given a breakpoint, get the # of cols set for it.
|
|
44
|
-
* @param {String} breakpoint Breakpoint name.
|
|
45
|
-
* @param {Object} cols Map of breakpoints to cols.
|
|
46
|
-
* @return {Number} Number of cols.
|
|
47
|
-
*/
|
|
48
|
-
function getColsFromBreakpoint(breakpoint /*: Breakpoint*/, cols /*: Breakpoints<Breakpoint>*/) /*: number*/{
|
|
49
|
-
if (!cols[breakpoint]) {
|
|
50
|
-
throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint " + breakpoint + " is missing!");
|
|
51
|
-
}
|
|
52
|
-
return cols[breakpoint];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Given existing layouts and a new breakpoint, find or generate a new layout.
|
|
57
|
-
*
|
|
58
|
-
* This finds the layout above the new one and generates from it, if it exists.
|
|
59
|
-
*
|
|
60
|
-
* @param {Object} layouts Existing layouts.
|
|
61
|
-
* @param {Array} breakpoints All breakpoints.
|
|
62
|
-
* @param {String} breakpoint New breakpoint.
|
|
63
|
-
* @param {String} breakpoint Last breakpoint (for fallback).
|
|
64
|
-
* @param {Number} cols Column count at new breakpoint.
|
|
65
|
-
* @param {Boolean} verticalCompact Whether or not to compact the layout
|
|
66
|
-
* vertically.
|
|
67
|
-
* @return {Array} New layout.
|
|
68
|
-
*/
|
|
69
|
-
function findOrGenerateResponsiveLayout(layouts /*: ResponsiveLayout<Breakpoint>*/, breakpoints /*: Breakpoints<Breakpoint>*/, breakpoint /*: Breakpoint*/, lastBreakpoint /*: Breakpoint*/, cols /*: number*/, compactType /*: CompactType*/) /*: Layout*/{
|
|
70
|
-
// If it already exists, just return it.
|
|
71
|
-
if (layouts[breakpoint]) return (0, _utils.cloneLayout)(layouts[breakpoint]);
|
|
72
|
-
// Find or generate the next layout
|
|
73
|
-
let layout = layouts[lastBreakpoint];
|
|
74
|
-
const breakpointsSorted = sortBreakpoints(breakpoints);
|
|
75
|
-
const breakpointsAbove = breakpointsSorted.slice(breakpointsSorted.indexOf(breakpoint));
|
|
76
|
-
for (let i = 0, len = breakpointsAbove.length; i < len; i++) {
|
|
77
|
-
const b = breakpointsAbove[i];
|
|
78
|
-
if (layouts[b]) {
|
|
79
|
-
layout = layouts[b];
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
layout = (0, _utils.cloneLayout)(layout || []); // clone layout so we don't modify existing items
|
|
84
|
-
return (0, _utils.compact)((0, _utils.correctBounds)(layout, {
|
|
85
|
-
cols: cols
|
|
86
|
-
}), compactType, cols);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Given breakpoints, return an array of breakpoints sorted by width. This is usually
|
|
91
|
-
* e.g. ['xxs', 'xs', 'sm', ...]
|
|
92
|
-
*
|
|
93
|
-
* @param {Object} breakpoints Key/value pair of breakpoint names to widths.
|
|
94
|
-
* @return {Array} Sorted breakpoints.
|
|
95
|
-
*/
|
|
96
|
-
function sortBreakpoints(breakpoints /*: Breakpoints<Breakpoint>*/) /*: Array<Breakpoint>*/{
|
|
97
|
-
const keys /*: Array<string>*/ = Object.keys(breakpoints);
|
|
98
|
-
return keys.sort(function (a, b) {
|
|
99
|
-
return breakpoints[a] - breakpoints[b];
|
|
100
|
-
});
|
|
101
|
-
}
|