react-grid-layout 1.5.3 → 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.
Files changed (95) hide show
  1. package/README.md +1074 -432
  2. package/css/styles.css +6 -4
  3. package/dist/ResponsiveGridLayout-CH4s0tKj.d.ts +124 -0
  4. package/dist/ResponsiveGridLayout-D6lFRE3f.d.mts +124 -0
  5. package/dist/calculate-CwYDW8na.d.mts +168 -0
  6. package/dist/calculate-mgLpNJ5O.d.ts +168 -0
  7. package/dist/chunk-2KUHNJXF.mjs +90 -0
  8. package/dist/chunk-2KUHNJXF.mjs.map +1 -0
  9. package/dist/chunk-3WO4SAYB.js +868 -0
  10. package/dist/chunk-3WO4SAYB.js.map +1 -0
  11. package/dist/chunk-4HNUMWQK.mjs +822 -0
  12. package/dist/chunk-4HNUMWQK.mjs.map +1 -0
  13. package/dist/chunk-BFTKGAP3.js +1309 -0
  14. package/dist/chunk-BFTKGAP3.js.map +1 -0
  15. package/dist/chunk-F6NQPYKT.js +98 -0
  16. package/dist/chunk-F6NQPYKT.js.map +1 -0
  17. package/dist/chunk-H5KMDLY3.js +434 -0
  18. package/dist/chunk-H5KMDLY3.js.map +1 -0
  19. package/dist/chunk-PBQSHIID.js +4 -0
  20. package/dist/chunk-PBQSHIID.js.map +1 -0
  21. package/dist/chunk-R35HZZTA.mjs +1300 -0
  22. package/dist/chunk-R35HZZTA.mjs.map +1 -0
  23. package/dist/chunk-ZCXE6SR5.mjs +428 -0
  24. package/dist/chunk-ZCXE6SR5.mjs.map +1 -0
  25. package/dist/chunk-ZWN22PS2.mjs +3 -0
  26. package/dist/chunk-ZWN22PS2.mjs.map +1 -0
  27. package/dist/core.d.mts +33 -0
  28. package/dist/core.d.ts +33 -0
  29. package/dist/core.js +218 -0
  30. package/dist/core.js.map +1 -0
  31. package/dist/core.mjs +5 -0
  32. package/dist/core.mjs.map +1 -0
  33. package/dist/extras.d.mts +78 -0
  34. package/dist/extras.d.ts +78 -0
  35. package/dist/extras.js +91 -0
  36. package/dist/extras.js.map +1 -0
  37. package/dist/extras.mjs +89 -0
  38. package/dist/extras.mjs.map +1 -0
  39. package/dist/index.d.mts +7 -0
  40. package/dist/index.d.ts +7 -0
  41. package/dist/index.js +154 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/index.mjs +7 -0
  44. package/dist/index.mjs.map +1 -0
  45. package/dist/legacy.d.mts +163 -0
  46. package/dist/legacy.d.ts +163 -0
  47. package/dist/legacy.js +319 -0
  48. package/dist/legacy.js.map +1 -0
  49. package/dist/legacy.mjs +307 -0
  50. package/dist/legacy.mjs.map +1 -0
  51. package/dist/position-BmN1z36J.d.mts +319 -0
  52. package/dist/position-Dk2b4ZMS.d.ts +319 -0
  53. package/dist/react.d.mts +351 -0
  54. package/dist/react.d.ts +351 -0
  55. package/dist/react.js +96 -0
  56. package/dist/react.js.map +1 -0
  57. package/dist/react.mjs +7 -0
  58. package/dist/react.mjs.map +1 -0
  59. package/dist/responsive-C4L1ESlm.d.ts +145 -0
  60. package/dist/responsive-CJxefsYw.d.mts +145 -0
  61. package/dist/types-Cxf4nHNr.d.mts +375 -0
  62. package/dist/types-Cxf4nHNr.d.ts +375 -0
  63. package/index-dev.js +8 -0
  64. package/package.json +132 -40
  65. package/.babelrc.js +0 -22
  66. package/.browserslistrc +0 -3
  67. package/.eslintignore +0 -4
  68. package/.flowconfig +0 -20
  69. package/.prettierignore +0 -4
  70. package/.prettierrc +0 -17
  71. package/CHANGELOG.md +0 -985
  72. package/build/GridItem.js +0 -638
  73. package/build/ReactGridLayout.js +0 -741
  74. package/build/ReactGridLayoutPropTypes.js +0 -210
  75. package/build/ResponsiveReactGridLayout.js +0 -297
  76. package/build/calculateUtils.js +0 -165
  77. package/build/components/WidthProvider.js +0 -115
  78. package/build/fastRGLPropsEqual.js +0 -5
  79. package/build/responsiveUtils.js +0 -101
  80. package/build/utils.js +0 -842
  81. package/dist/react-grid-layout.min.js +0 -2
  82. package/dist/react-grid-layout.min.js.map +0 -1
  83. package/index.js.flow +0 -8
  84. package/ip_fetcher +0 -0
  85. package/ip_fetcher.c +0 -47
  86. package/lib/GridItem.jsx +0 -689
  87. package/lib/ReactGridLayout.jsx +0 -855
  88. package/lib/ReactGridLayoutPropTypes.js +0 -241
  89. package/lib/ResponsiveReactGridLayout.jsx +0 -349
  90. package/lib/calculateUtils.js +0 -169
  91. package/lib/components/WidthProvider.jsx +0 -110
  92. package/lib/fastRGLPropsEqual.js +0 -46
  93. package/lib/responsiveUtils.js +0 -118
  94. package/lib/utils.js +0 -995
  95. package/yarn-error.log +0 -7780
@@ -1,115 +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
- const _excluded = ["measureBeforeMount"];
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- 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); }
14
- 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); }
15
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
16
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
17
- 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; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
19
- 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); }
20
- /*:: import type { ReactRef } from "../ReactGridLayoutPropTypes";*/
21
- /*:: type WPDefaultProps = {|
22
- measureBeforeMount: boolean
23
- |};*/
24
- /*:: type WPProps = {|
25
- className?: string,
26
- style?: Object,
27
- ...WPDefaultProps
28
- |};*/
29
- // eslint-disable-next-line no-unused-vars
30
- /*:: type WPState = {|
31
- width: number
32
- |};*/
33
- /*:: type ComposedProps<Config> = {|
34
- ...Config,
35
- measureBeforeMount?: boolean,
36
- className?: string,
37
- style?: Object,
38
- width?: number
39
- |};*/
40
- const layoutClassName = "react-grid-layout";
41
-
42
- /*
43
- * A simple HOC that provides facility for listening to container resizes.
44
- *
45
- * The Flow type is pretty janky here. I can't just spread `WPProps` into this returned object - I wish I could - but it triggers
46
- * a flow bug of some sort that causes it to stop typechecking.
47
- */
48
- function WidthProvideRGL /*:: <Config>*/(ComposedComponent /*: React.AbstractComponent<Config>*/) /*: React.AbstractComponent<ComposedProps<Config>>*/{
49
- var _WidthProvider;
50
- return _WidthProvider = class WidthProvider extends React.Component
51
- /*:: <
52
- ComposedProps<Config>,
53
- WPState
54
- >*/
55
- {
56
- constructor() {
57
- super(...arguments);
58
- _defineProperty(this, "state", {
59
- width: 1280
60
- });
61
- _defineProperty(this, "elementRef", /*#__PURE__*/React.createRef());
62
- _defineProperty(this, "mounted", false);
63
- _defineProperty(this, "resizeObserver", void 0);
64
- }
65
- componentDidMount() {
66
- this.mounted = true;
67
- this.resizeObserver = new _resizeObserverPolyfill.default(entries => {
68
- const node = this.elementRef.current;
69
- if (node instanceof HTMLElement) {
70
- const width = entries[0].contentRect.width;
71
- this.setState({
72
- width
73
- });
74
- }
75
- });
76
- const node = this.elementRef.current;
77
- if (node instanceof HTMLElement) {
78
- this.resizeObserver.observe(node);
79
- }
80
- }
81
- componentWillUnmount() {
82
- this.mounted = false;
83
- const node = this.elementRef.current;
84
- if (node instanceof HTMLElement) {
85
- this.resizeObserver.unobserve(node);
86
- }
87
- this.resizeObserver.disconnect();
88
- }
89
- render() {
90
- const _this$props = this.props,
91
- {
92
- measureBeforeMount
93
- } = _this$props,
94
- rest = _objectWithoutProperties(_this$props, _excluded);
95
- if (measureBeforeMount && !this.mounted) {
96
- return /*#__PURE__*/React.createElement("div", {
97
- className: (0, _clsx.default)(this.props.className, layoutClassName),
98
- style: this.props.style
99
- // $FlowIgnore ref types
100
- ,
101
- ref: this.elementRef
102
- });
103
- }
104
- return /*#__PURE__*/React.createElement(ComposedComponent, _extends({
105
- innerRef: this.elementRef
106
- }, rest, this.state));
107
- }
108
- }, _defineProperty(_WidthProvider, "defaultProps", {
109
- measureBeforeMount: false
110
- }), _defineProperty(_WidthProvider, "propTypes", {
111
- // If true, will not render children until mounted. Useful for getting the exact width before
112
- // rendering, to prevent any unsightly resizing.
113
- measureBeforeMount: _propTypes.default.bool
114
- }), _WidthProvider;
115
- }
@@ -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
- };
@@ -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
- }