af-react-grid
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -11,6 +11,6 @@ import t, { Children as s } from "react"; | ||
const n = ({className: s, type: i, style: r, index: o, onDrag: n, onStart: h, disabled: a, children: c}) => t.createElement(e, { | ||
onStart: h, | ||
const n = t.memo(({className: s, type: i, style: r, index: o, onDrag: n, onStart: a, disabled: h, children: c}) => t.createElement(e, { | ||
onStart: a, | ||
onDrag: n, | ||
disabled: a | ||
disabled: h | ||
}, t.createElement("div", { | ||
@@ -22,3 +22,3 @@ "data-resizer-index": o, | ||
children: c | ||
})); | ||
}))); | ||
@@ -36,3 +36,3 @@ n.propTypes = { | ||
const h = (t, s = Object.create(null)) => i => s[i] || (s[i] = t(i)), a = (t, s, i) => t > i ? i : t < s ? s : t, c = { | ||
const a = (t, s = Object.create(null)) => i => s[i] || (s[i] = t(i)), h = (t, s, i) => t > i ? i : t < s ? s : t, c = { | ||
row: { | ||
@@ -46,3 +46,3 @@ t: "react-rsz-grid-row", | ||
n: "maxWidth", | ||
h: [ "Left", "Right" ] | ||
a: [ "Left", "Right" ] | ||
}, | ||
@@ -57,3 +57,3 @@ col: { | ||
n: "maxHeight", | ||
h: [ "Top", "Bottom" ] | ||
a: [ "Top", "Bottom" ] | ||
} | ||
@@ -64,94 +64,95 @@ }; | ||
if (!t.isValidElement(s)) return s; | ||
const {type: i, props: e} = s, {resizerClassName: r, resizerChildren: o, type: h} = this.props; | ||
const {type: i, props: e} = s, {resizerClassName: r, resizerChildren: o, type: a} = this.props; | ||
if (i === n) return t.cloneElement(s, { | ||
index: this.a, | ||
index: this.h, | ||
onDrag: this.c, | ||
onStart: this.m, | ||
type: h, | ||
type: a, | ||
className: e.className || r | ||
}, e.children || o); | ||
const a = this.state[this.a], c = { | ||
style: e.style ? Object.assign({}, e.style, a) : a, | ||
ref: this.l(this.a++) | ||
const h = this.state[this.h], c = { | ||
style: e.style ? Object.assign({}, e.style, h) : h, | ||
ref: this.l(this.h++) | ||
}; | ||
return i === l && (c.resizerClassName = void 0 === e.resizerClassName ? r : e.resizerClassName, | ||
c.resizerChildren = void 0 === e.resizerChildren ? o : e.resizerChildren), t.cloneElement(s, c); | ||
return i === d && (void 0 === e.resizerClassName && (c.resizerClassName = r), void 0 === e.resizerChildren && (c.resizerChildren = o)), | ||
t.cloneElement(s, c); | ||
} | ||
class l extends t.Component { | ||
constructor(...t) { | ||
super(...t), this.state = {}, this.d = [], this.m = (t => { | ||
const s = this.p = +t.currentTarget.dataset.resizerIndex, i = this.d[s - 1], e = this.d[s]; | ||
if (this.f = !(!i || !e)) { | ||
const {s} = c[this.props.type]; | ||
this.g = t[s], this.u(i, 1), this.u(e, 2); | ||
const r = this._curD1 + this._curD2; | ||
this._maxD1 || (this._maxD1 = r - this._minD2), this._maxD2 || (this._maxD2 = r - this._minD1), | ||
this.D(); | ||
} else "production" !== process.env.NODE_ENV && console.warn("Resizer must be between other components. It is inactive during this drag."); | ||
}), this.c = (t => { | ||
if (this.f) { | ||
const {s, r: i} = c[this.props.type], e = t[s] - this.g; | ||
this.setState(t => this.y(t, i, e)); | ||
} | ||
}), this.l = h(t => s => { | ||
this.d[t] = r.findDOMNode(s); | ||
}), this.z = ((t, {type: s}) => { | ||
const {r: i, i: e} = c[s]; | ||
return this.d.reduce((s, r, o) => (s[o] = Object.assign({}, t[o], { | ||
[i]: r[e], | ||
flexBasis: "auto", | ||
boxSizing: "border-box" | ||
}), s), {}); | ||
}), this.D = (() => this.setState(this.z)); | ||
} | ||
u(t, s) { | ||
const {type: i} = this.props, {n: e, o: r, i: o, e: n, h} = c[i], a = getComputedStyle(t), m = (this["_curD" + s] = t[o]) - t[n] + h.reduce((t, s) => t + parseFloat(a[`padding${s}`]), 0); | ||
this["_minD" + s] = m + (parseFloat(a[r]) || 0), this["_maxD" + s] = parseFloat(a[e]) || 0; | ||
} | ||
y(t, s, i) { | ||
const e = this.p; | ||
return { | ||
[e - 1]: Object.assign({}, t[e - 1], { | ||
[s]: a(this._curD1 + i, this._minD1, this._maxD1) | ||
}), | ||
[e]: Object.assign({}, t[e], { | ||
[s]: a(this._curD2 - i, this._minD2, this._maxD2) | ||
}) | ||
}; | ||
} | ||
render() { | ||
const {type: i, className: e, children: r, style: n} = this.props; | ||
return this.a = 0, t.createElement("div", { | ||
style: n, | ||
className: o(e, c[i].t), | ||
children: s.map(r, m, this) | ||
}); | ||
} | ||
componentDidMount() { | ||
this._st = setTimeout(this.D, 50), window.addEventListener("resize", this.D); | ||
} | ||
componentDidUpdate() { | ||
const t = this.d.length - this.a; | ||
t && this.d.splice(this.a, t); | ||
} | ||
componentWillUnmount() { | ||
window.removeEventListener("resize", this.D), clearTimeout(this._st); | ||
} | ||
} | ||
const l = e => { | ||
var n, l; | ||
return l = n = class extends e { | ||
constructor(...t) { | ||
super(...t), this.state = {}, this.d = [], this.m = (t => { | ||
const s = this.p = +t.currentTarget.dataset.resizerIndex, i = this.d[s - 1], e = this.d[s]; | ||
if (this.f = !(!i || !e)) { | ||
const {s} = c[this.props.type]; | ||
this.u = t[s], this.g(i, 1), this.g(e, 2); | ||
const r = this._curD1 + this._curD2; | ||
this._maxD1 || (this._maxD1 = r - this._minD2), this._maxD2 || (this._maxD2 = r - this._minD1), | ||
this.D(); | ||
} else "production" !== process.env.NODE_ENV && console.warn("Resizer must be between other components. It is inactive during this drag."); | ||
}), this.c = (t => { | ||
if (this.f) { | ||
const {s, r: i} = c[this.props.type], e = t[s] - this.u; | ||
this.setState(t => this.y(t, i, e)); | ||
} | ||
}), this.l = a(t => s => { | ||
this.d[t] = r.findDOMNode(s); | ||
}), this.z = ((t, {type: s}) => { | ||
const {r: i, i: e} = c[s]; | ||
return this.d.reduce((s, r, o) => (s[o] = Object.assign({}, t[o], { | ||
[i]: r[e], | ||
flexBasis: "auto", | ||
boxSizing: "border-box" | ||
}), s), {}); | ||
}), this.D = (() => this.setState(this.z)); | ||
} | ||
g(t, s) { | ||
const {type: i} = this.props, {n: e, o: r, i: o, e: n, a} = c[i], h = getComputedStyle(t), m = (this["_curD" + s] = t[o]) - t[n] + a.reduce((t, s) => t + parseFloat(h[`padding${s}`]), 0); | ||
this["_minD" + s] = m + (parseFloat(h[r]) || 0), this["_maxD" + s] = parseFloat(h[e]) || 0; | ||
} | ||
y(t, s, i) { | ||
const e = this.p; | ||
return { | ||
[e - 1]: Object.assign({}, t[e - 1], { | ||
[s]: h(this._curD1 + i, this._minD1, this._maxD1) | ||
}), | ||
[e]: Object.assign({}, t[e], { | ||
[s]: h(this._curD2 - i, this._minD2, this._maxD2) | ||
}) | ||
}; | ||
} | ||
render() { | ||
const {type: i, className: e, children: r, style: n} = this.props; | ||
return this.h = 0, t.createElement("div", { | ||
style: n, | ||
className: o(e, c[i].t), | ||
children: s.map(r, m, this) | ||
}); | ||
} | ||
componentDidMount() { | ||
this._st = setTimeout(this.D, 50), window.addEventListener("resize", this.D); | ||
} | ||
componentDidUpdate() { | ||
const t = this.d.length - this.h; | ||
t && this.d.splice(this.h, t); | ||
} | ||
componentWillUnmount() { | ||
window.removeEventListener("resize", this.D), clearTimeout(this._st); | ||
} | ||
}, n.propTypes = { | ||
type: i.oneOf([ "row", "col" ]), | ||
className: i.string, | ||
style: i.object, | ||
children: (i, e) => { | ||
if (s.toArray(i[e]).some(s => t.isValidElement(s) && (s.type === t.Fragment || Array.isArray(s)))) throw new Error("Fragments and arrays are not allowed inside Container"); | ||
}, | ||
resizerChildren: i.node, | ||
resizerClassName: i.string | ||
}, n.defaultProps = { | ||
type: "row", | ||
resizerClassName: "react-rsz-grid-default-resizer" | ||
}, l; | ||
}, d = l(t.Component), p = l(t.PureComponent); | ||
l.propTypes = { | ||
type: i.oneOf([ "row", "col" ]), | ||
className: i.string, | ||
style: i.object, | ||
children: (i, e) => { | ||
if (s.toArray(i[e]).some(s => t.isValidElement(s) && (s.type === t.Fragment || Array.isArray(s)))) throw new Error("Fragments and arrays are not allowed inside Container"); | ||
}, | ||
resizerChildren: i.node, | ||
resizerClassName: i.string | ||
}, l.defaultProps = { | ||
type: "row", | ||
resizerClassName: "react-rsz-grid-default-resizer" | ||
}; | ||
export { l as Container, n as Resizer }; | ||
export { n as Resizer, d as Container, p as PureContainer }; |
@@ -11,11 +11,24 @@ "use strict"; | ||
var React = require("react"), React__default = _interopDefault(React), PropTypes = _interopDefault(require("prop-types")), reactDraggable = require("react-draggable"), ReactDOM = _interopDefault(require("react-dom")), cn = _interopDefault(require("classnames")); | ||
var React = require("react"), React__default = _interopDefault(React), PropTypes = _interopDefault(require("prop-types")), reactDraggable = require("react-draggable"), ReactDOM = _interopDefault(require("react-dom")), cn = _interopDefault(require("classnames")), Resizer = React__default.memo(function(e) { | ||
var t = e.className, r = e.type, n = e.style, i = e.index, a = e.onDrag, s = e.onStart, o = e.disabled, c = e.children; | ||
return React__default.createElement(reactDraggable.DraggableCore, { | ||
onStart: s, | ||
onDrag: a, | ||
disabled: o | ||
}, React__default.createElement("div", { | ||
"data-resizer-index": i, | ||
"data-resizer-type": r, | ||
className: t, | ||
style: n, | ||
children: c | ||
})); | ||
}); | ||
function _classCallCheck(e, r) { | ||
if (!(e instanceof r)) throw new TypeError("Cannot call a class as a function"); | ||
function _classCallCheck(e, t) { | ||
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _defineProperties(e, r) { | ||
for (var t = 0; t < r.length; t++) { | ||
var n = r[t]; | ||
function _defineProperties(e, t) { | ||
for (var r = 0; r < t.length; r++) { | ||
var n = t[r]; | ||
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), | ||
@@ -26,18 +39,18 @@ Object.defineProperty(e, n.key, n); | ||
function _createClass(e, r, t) { | ||
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), e; | ||
function _createClass(e, t, r) { | ||
return t && _defineProperties(e.prototype, t), r && _defineProperties(e, r), e; | ||
} | ||
function _defineProperty(e, r, t) { | ||
return r in e ? Object.defineProperty(e, r, { | ||
value: t, | ||
function _defineProperty(e, t, r) { | ||
return t in e ? Object.defineProperty(e, t, { | ||
value: r, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : e[r] = t, e; | ||
}) : e[t] = r, e; | ||
} | ||
function _inherits(e, r) { | ||
if ("function" != typeof r && null !== r) throw new TypeError("Super expression must either be null or a function"); | ||
e.prototype = Object.create(r && r.prototype, { | ||
function _inherits(e, t) { | ||
if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function"); | ||
e.prototype = Object.create(t && t.prototype, { | ||
constructor: { | ||
@@ -48,3 +61,3 @@ value: e, | ||
} | ||
}), r && _setPrototypeOf(e, r); | ||
}), t && _setPrototypeOf(e, t); | ||
} | ||
@@ -58,6 +71,6 @@ | ||
function _setPrototypeOf(e, r) { | ||
return (_setPrototypeOf = Object.setPrototypeOf || function(e, r) { | ||
return e.__proto__ = r, e; | ||
})(e, r); | ||
function _setPrototypeOf(e, t) { | ||
return (_setPrototypeOf = Object.setPrototypeOf || function(e, t) { | ||
return e.__proto__ = t, e; | ||
})(e, t); | ||
} | ||
@@ -70,21 +83,6 @@ | ||
function _possibleConstructorReturn(e, r) { | ||
return !r || "object" != typeof r && "function" != typeof r ? _assertThisInitialized(e) : r; | ||
function _possibleConstructorReturn(e, t) { | ||
return !t || "object" != typeof t && "function" != typeof t ? _assertThisInitialized(e) : t; | ||
} | ||
var Resizer = function(e) { | ||
var r = e.className, t = e.type, n = e.style, i = e.index, s = e.onDrag, a = e.onStart, o = e.disabled, c = e.children; | ||
return React__default.createElement(reactDraggable.DraggableCore, { | ||
onStart: a, | ||
onDrag: s, | ||
disabled: o | ||
}, React__default.createElement("div", { | ||
"data-resizer-index": i, | ||
"data-resizer-type": t, | ||
className: r, | ||
style: n, | ||
children: c | ||
})); | ||
}; | ||
Resizer.propTypes = { | ||
@@ -102,8 +100,8 @@ type: PropTypes.oneOf([ "row", "col" ]), | ||
var memoizeOneNumericArg = function(e) { | ||
var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : Object.create(null); | ||
return function(t) { | ||
return r[t] || (r[t] = e(t)); | ||
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : Object.create(null); | ||
return function(r) { | ||
return t[r] || (t[r] = e(r)); | ||
}; | ||
}, clamp = function(e, r, t) { | ||
return e > t ? t : e < r ? r : e; | ||
}, clamp = function(e, t, r) { | ||
return e > r ? r : e < t ? t : e; | ||
}, ByType = { | ||
@@ -134,113 +132,116 @@ row: { | ||
if (!React__default.isValidElement(e)) return e; | ||
var r = e.type, t = e.props, n = this.props, i = n.resizerClassName, s = n.resizerChildren, a = n.type; | ||
if (r === Resizer) return React__default.cloneElement(e, { | ||
var t = e.type, r = e.props, n = this.props, i = n.resizerClassName, a = n.resizerChildren, s = n.type; | ||
if (t === Resizer) return React__default.cloneElement(e, { | ||
index: this._refsArrIterator, | ||
onDrag: this.dragHandler, | ||
onStart: this.dragStartHandler, | ||
type: a, | ||
className: t.className || i | ||
}, t.children || s); | ||
type: s, | ||
className: r.className || i | ||
}, r.children || a); | ||
var o = this.state[this._refsArrIterator], c = { | ||
style: t.style ? Object.assign({}, t.style, o) : o, | ||
style: r.style ? Object.assign({}, r.style, o) : o, | ||
ref: this._getSaveRef(this._refsArrIterator++) | ||
}; | ||
return r === Container && (c.resizerClassName = void 0 === t.resizerClassName ? i : t.resizerClassName, | ||
c.resizerChildren = void 0 === t.resizerChildren ? s : t.resizerChildren), React__default.cloneElement(e, c); | ||
return t === Container && (void 0 === r.resizerClassName && (c.resizerClassName = i), | ||
void 0 === r.resizerChildren && (c.resizerChildren = a)), React__default.cloneElement(e, c); | ||
} | ||
var Container = function(e) { | ||
function r() { | ||
var e, t; | ||
_classCallCheck(this, r); | ||
for (var n = arguments.length, i = new Array(n), s = 0; s < n; s++) i[s] = arguments[s]; | ||
return (t = _possibleConstructorReturn(this, (e = _getPrototypeOf(r)).call.apply(e, [ this ].concat(i)))).state = {}, | ||
t.refsArr = [], t.dragStartHandler = function(e) { | ||
var r = t._curRszIndex = +e.currentTarget.dataset.resizerIndex, n = t.refsArr[r - 1], i = t.refsArr[r]; | ||
if (t._canDrag = !(!n || !i)) { | ||
var s = ByType[t.props.type].cursorPropName; | ||
t._initPtrPageDist = e[s], t._setInitialDimensionsCache(n, 1), t._setInitialDimensionsCache(i, 2); | ||
var a = t._curD1 + t._curD2; | ||
t._maxD1 || (t._maxD1 = a - t._minD2), t._maxD2 || (t._maxD2 = a - t._minD1), t.setExactDimensions(); | ||
} else "production" !== process.env.NODE_ENV && console.warn("Resizer must be between other components. It is inactive during this drag."); | ||
}, t.dragHandler = function(e) { | ||
if (t._canDrag) { | ||
var r = ByType[t.props.type], n = r.cursorPropName, i = r.cssSizeProp, s = e[n] - t._initPtrPageDist; | ||
t.setState(function(e) { | ||
return t._getChangedState(e, i, s); | ||
var getComponent = function(e) { | ||
var t, r; | ||
return r = t = function(t) { | ||
function r() { | ||
var e, t; | ||
_classCallCheck(this, r); | ||
for (var n = arguments.length, i = new Array(n), a = 0; a < n; a++) i[a] = arguments[a]; | ||
return (t = _possibleConstructorReturn(this, (e = _getPrototypeOf(r)).call.apply(e, [ this ].concat(i)))).state = {}, | ||
t.refsArr = [], t.dragStartHandler = function(e) { | ||
var r = t._curRszIndex = +e.currentTarget.dataset.resizerIndex, n = t.refsArr[r - 1], i = t.refsArr[r]; | ||
if (t._canDrag = !(!n || !i)) { | ||
var a = ByType[t.props.type].cursorPropName; | ||
t._initPtrPageDist = e[a], t._setInitialDimensionsCache(n, 1), t._setInitialDimensionsCache(i, 2); | ||
var s = t._curD1 + t._curD2; | ||
t._maxD1 || (t._maxD1 = s - t._minD2), t._maxD2 || (t._maxD2 = s - t._minD1), t.setExactDimensions(); | ||
} else "production" !== process.env.NODE_ENV && console.warn("Resizer must be between other components. It is inactive during this drag."); | ||
}, t.dragHandler = function(e) { | ||
if (t._canDrag) { | ||
var r = ByType[t.props.type], n = r.cursorPropName, i = r.cssSizeProp, a = e[n] - t._initPtrPageDist; | ||
t.setState(function(e) { | ||
return t._getChangedState(e, i, a); | ||
}); | ||
} | ||
}, t._getSaveRef = memoizeOneNumericArg(function(e) { | ||
return function(r) { | ||
t.refsArr[e] = ReactDOM.findDOMNode(r); | ||
}; | ||
}), t._dimensionsStateModifier = function(e, r) { | ||
var n = r.type, i = ByType[n], a = i.cssSizeProp, s = i.offsetDim; | ||
return t.refsArr.reduce(function(t, r, n) { | ||
var i; | ||
return t[n] = Object.assign({}, e[n], (_defineProperty(i = {}, a, r[s]), _defineProperty(i, "flexBasis", "auto"), | ||
_defineProperty(i, "boxSizing", "border-box"), i)), t; | ||
}, {}); | ||
}, t.setExactDimensions = function() { | ||
return t.setState(t._dimensionsStateModifier); | ||
}, t; | ||
} | ||
return _inherits(r, e), _createClass(r, [ { | ||
key: "_setInitialDimensionsCache", | ||
value: function(e, t) { | ||
var r = this.props.type, n = ByType[r], i = n.maxDim, a = n.minDim, s = n.offsetDim, o = n.clientDim, c = n.minProps, l = getComputedStyle(e), p = (this["_curD" + t] = e[s]) - e[o] + c.reduce(function(e, t) { | ||
return e + parseFloat(l["padding".concat(t)]); | ||
}, 0); | ||
this["_minD" + t] = p + (parseFloat(l[a]) || 0), this["_maxD" + t] = parseFloat(l[i]) || 0; | ||
} | ||
}, { | ||
key: "_getChangedState", | ||
value: function(e, t, r) { | ||
var n, i = this._curRszIndex; | ||
return _defineProperty(n = {}, i - 1, Object.assign({}, e[i - 1], _defineProperty({}, t, clamp(this._curD1 + r, this._minD1, this._maxD1)))), | ||
_defineProperty(n, i, Object.assign({}, e[i], _defineProperty({}, t, clamp(this._curD2 - r, this._minD2, this._maxD2)))), | ||
n; | ||
} | ||
}, { | ||
key: "render", | ||
value: function() { | ||
var e = this.props, t = e.type, r = e.className, n = e.children, i = e.style; | ||
return this._refsArrIterator = 0, React__default.createElement("div", { | ||
style: i, | ||
className: cn(r, ByType[t].colClassName), | ||
children: React.Children.map(n, childrenMapper, this) | ||
}); | ||
} | ||
}, t._getSaveRef = memoizeOneNumericArg(function(e) { | ||
return function(r) { | ||
t.refsArr[e] = ReactDOM.findDOMNode(r); | ||
}; | ||
}), t._dimensionsStateModifier = function(e, r) { | ||
var n = r.type, i = ByType[n], s = i.cssSizeProp, a = i.offsetDim; | ||
return t.refsArr.reduce(function(r, t, n) { | ||
var i; | ||
return r[n] = Object.assign({}, e[n], (_defineProperty(i = {}, s, t[a]), _defineProperty(i, "flexBasis", "auto"), | ||
_defineProperty(i, "boxSizing", "border-box"), i)), r; | ||
}, {}); | ||
}, t.setExactDimensions = function() { | ||
return t.setState(t._dimensionsStateModifier); | ||
}, t; | ||
} | ||
return _inherits(r, React__default.Component), _createClass(r, [ { | ||
key: "_setInitialDimensionsCache", | ||
value: function(e, r) { | ||
var t = this.props.type, n = ByType[t], i = n.maxDim, s = n.minDim, a = n.offsetDim, o = n.clientDim, c = n.minProps, l = getComputedStyle(e), p = (this["_curD" + r] = e[a]) - e[o] + c.reduce(function(e, r) { | ||
return e + parseFloat(l["padding".concat(r)]); | ||
}, 0); | ||
this["_minD" + r] = p + (parseFloat(l[s]) || 0), this["_maxD" + r] = parseFloat(l[i]) || 0; | ||
} | ||
}, { | ||
key: "_getChangedState", | ||
value: function(e, r, t) { | ||
var n, i = this._curRszIndex; | ||
return _defineProperty(n = {}, i - 1, Object.assign({}, e[i - 1], _defineProperty({}, r, clamp(this._curD1 + t, this._minD1, this._maxD1)))), | ||
_defineProperty(n, i, Object.assign({}, e[i], _defineProperty({}, r, clamp(this._curD2 - t, this._minD2, this._maxD2)))), | ||
n; | ||
} | ||
}, { | ||
key: "render", | ||
value: function() { | ||
var e = this.props, r = e.type, t = e.className, n = e.children, i = e.style; | ||
return this._refsArrIterator = 0, React__default.createElement("div", { | ||
style: i, | ||
className: cn(t, ByType[r].colClassName), | ||
children: React.Children.map(n, childrenMapper, this) | ||
}); | ||
} | ||
}, { | ||
key: "componentDidMount", | ||
value: function() { | ||
this._st = setTimeout(this.setExactDimensions, 50), window.addEventListener("resize", this.setExactDimensions); | ||
} | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function() { | ||
var e = this.refsArr.length - this._refsArrIterator; | ||
e && this.refsArr.splice(this._refsArrIterator, e); | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function() { | ||
window.removeEventListener("resize", this.setExactDimensions), clearTimeout(this._st); | ||
} | ||
} ]), r; | ||
}(); | ||
}, { | ||
key: "componentDidMount", | ||
value: function() { | ||
this._st = setTimeout(this.setExactDimensions, 50), window.addEventListener("resize", this.setExactDimensions); | ||
} | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function() { | ||
var e = this.refsArr.length - this._refsArrIterator; | ||
e && this.refsArr.splice(this._refsArrIterator, e); | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function() { | ||
window.removeEventListener("resize", this.setExactDimensions), clearTimeout(this._st); | ||
} | ||
} ]), r; | ||
}(), t.propTypes = { | ||
type: PropTypes.oneOf([ "row", "col" ]), | ||
className: PropTypes.string, | ||
style: PropTypes.object, | ||
children: function(e, t) { | ||
if (React.Children.toArray(e[t]).some(function(e) { | ||
return React__default.isValidElement(e) && (e.type === React__default.Fragment || Array.isArray(e)); | ||
})) throw new Error("Fragments and arrays are not allowed inside Container"); | ||
}, | ||
resizerChildren: PropTypes.node, | ||
resizerClassName: PropTypes.string | ||
}, t.defaultProps = { | ||
type: "row", | ||
resizerClassName: "react-rsz-grid-default-resizer" | ||
}, r; | ||
}, Container = getComponent(React__default.Component), PureContainer = getComponent(React__default.PureComponent); | ||
Container.propTypes = { | ||
type: PropTypes.oneOf([ "row", "col" ]), | ||
className: PropTypes.string, | ||
style: PropTypes.object, | ||
children: function(e, r) { | ||
if (React.Children.toArray(e[r]).some(function(e) { | ||
return React__default.isValidElement(e) && (e.type === React__default.Fragment || Array.isArray(e)); | ||
})) throw new Error("Fragments and arrays are not allowed inside Container"); | ||
}, | ||
resizerChildren: PropTypes.node, | ||
resizerClassName: PropTypes.string | ||
}, Container.defaultProps = { | ||
type: "row", | ||
resizerClassName: "react-rsz-grid-default-resizer" | ||
}, exports.Container = Container, exports.Resizer = Resizer; | ||
exports.Resizer = Resizer, exports.Container = Container, exports.PureContainer = PureContainer; |
import React from "react"; | ||
import Container from "Container"; | ||
import { Container } from "Container"; | ||
import Resizer from "Resizer"; | ||
@@ -5,0 +5,0 @@ |
{ | ||
"name": "af-react-grid", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"sideEffects": [ | ||
@@ -5,0 +5,0 @@ "*.css" |
@@ -98,3 +98,13 @@ import resolve from "rollup-plugin-node-resolve"; | ||
}), | ||
babel(), | ||
babel({ | ||
babelrc: false, | ||
externalHelpers: true, | ||
presets: [ "@babel/preset-react", "@babel/preset-env" ], | ||
plugins: [ | ||
"@babel/plugin-external-helpers", | ||
"@babel/plugin-proposal-do-expressions", | ||
[ "@babel/plugin-proposal-class-properties", { loose: true }], | ||
[ "@babel/plugin-proposal-object-rest-spread", { loose: true, useBuiltIns: true }] | ||
] | ||
}), | ||
terser({ | ||
@@ -101,0 +111,0 @@ ecma: 6, |
@@ -71,3 +71,3 @@ import React, { Children } from "react"; | ||
class Container extends React.PureComponent{ | ||
const getComponent = BaseClass => class extends BaseClass{ | ||
@@ -202,3 +202,3 @@ static propTypes = { | ||
this.refsArr[ index ] = ReactDOM.findDOMNode( node ); | ||
}) | ||
}); | ||
@@ -269,2 +269,3 @@ | ||
export default Container; | ||
export const Container = getComponent( React.Component ); | ||
export const PureContainer = getComponent( React.PureComponent ); |
import React from "react"; | ||
import Container from "../Container"; | ||
import {Container } from "../Container"; | ||
import renderer from "react-test-renderer"; | ||
@@ -4,0 +4,0 @@ import mockConsole from "jest-mock-console"; |
@@ -1,7 +0,2 @@ | ||
import Container from "./Container"; | ||
import Resizer from "./Resizer"; | ||
export { | ||
Container, | ||
Resizer | ||
} | ||
export { Resizer } from "./Resizer"; | ||
export { Container, PureContainer } from "./Container"; |
@@ -5,3 +5,3 @@ import React from "react"; | ||
const Resizer = React.memo(({ | ||
export const Resizer = React.memo(({ | ||
className, | ||
@@ -8,0 +8,0 @@ type, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
202485
26
1567
0