react-virtualized-auto-sizer
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -15,3 +15,3 @@ import { Component, HTMLAttributes, ReactElement } from "react"; | ||
tagName?: string; | ||
} & Omit<HTMLAttributes<HTMLDivElement>, "children">; | ||
} & Omit<HTMLAttributes<HTMLDivElement>, "children" | "onResize">; | ||
type State = { | ||
@@ -26,3 +26,3 @@ height: number; | ||
}; | ||
export class AutoSizer extends Component<Props, State> { | ||
declare class AutoSizer extends Component<Props, State> { | ||
static defaultProps: { | ||
@@ -29,0 +29,0 @@ onResize: () => void; |
@@ -210,16 +210,69 @@ var $8zHUo$react = require("react"); | ||
function $4fd1a97a17b80f9f$var$_defineProperty(obj, key, value) { | ||
key = $4fd1a97a17b80f9f$var$_toPropertyKey(key); | ||
if (key in obj) Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
else obj[key] = value; | ||
return obj; | ||
} | ||
function $4fd1a97a17b80f9f$var$_toPropertyKey(arg) { | ||
var key = $4fd1a97a17b80f9f$var$_toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function $4fd1a97a17b80f9f$var$_toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
class $4fd1a97a17b80f9f$export$9d94f4ee1d930ff extends (0, $8zHUo$react.Component) { | ||
static defaultProps = { | ||
onResize: ()=>{}, | ||
disableHeight: false, | ||
disableWidth: false, | ||
style: {} | ||
}; | ||
state = { | ||
height: this.props.defaultHeight || 0, | ||
width: this.props.defaultWidth || 0 | ||
}; | ||
_parentNode = null; | ||
_autoSizer = null; | ||
_detectElementResize = null; | ||
constructor(...args){ | ||
super(...args); | ||
$4fd1a97a17b80f9f$var$_defineProperty(this, "state", { | ||
height: this.props.defaultHeight || 0, | ||
width: this.props.defaultWidth || 0 | ||
}); | ||
$4fd1a97a17b80f9f$var$_defineProperty(this, "_parentNode", null); | ||
$4fd1a97a17b80f9f$var$_defineProperty(this, "_autoSizer", null); | ||
$4fd1a97a17b80f9f$var$_defineProperty(this, "_detectElementResize", null); | ||
$4fd1a97a17b80f9f$var$_defineProperty(this, "_onResize", ()=>{ | ||
const { disableHeight: disableHeight , disableWidth: disableWidth , onResize: onResize } = this.props; | ||
if (this._parentNode) { | ||
// Guard against AutoSizer component being removed from the DOM immediately after being added. | ||
// This can result in invalid style values which can result in NaN values if we don't handle them. | ||
// See issue #150 for more context. | ||
const rect = this._parentNode.getBoundingClientRect(); | ||
const height = rect.height || 0; | ||
const width = rect.width || 0; | ||
const style = window.getComputedStyle(this._parentNode) || {}; | ||
const paddingLeft = parseInt(style.paddingLeft, 10) || 0; | ||
const paddingRight = parseInt(style.paddingRight, 10) || 0; | ||
const paddingTop = parseInt(style.paddingTop, 10) || 0; | ||
const paddingBottom = parseInt(style.paddingBottom, 10) || 0; | ||
const newHeight = height - paddingTop - paddingBottom; | ||
const newWidth = width - paddingLeft - paddingRight; | ||
if (!disableHeight && this.state.height !== newHeight || !disableWidth && this.state.width !== newWidth) { | ||
this.setState({ | ||
height: height - paddingTop - paddingBottom, | ||
width: width - paddingLeft - paddingRight | ||
}); | ||
if (typeof onResize === "function") onResize({ | ||
height: height, | ||
width: width | ||
}); | ||
} | ||
} | ||
}); | ||
$4fd1a97a17b80f9f$var$_defineProperty(this, "_setRef", (autoSizer)=>{ | ||
this._autoSizer = autoSizer; | ||
}); | ||
} | ||
componentDidMount() { | ||
@@ -275,34 +328,9 @@ const { nonce: nonce } = this.props; | ||
} | ||
_onResize = ()=>{ | ||
const { disableHeight: disableHeight , disableWidth: disableWidth , onResize: onResize } = this.props; | ||
if (this._parentNode) { | ||
// Guard against AutoSizer component being removed from the DOM immediately after being added. | ||
// This can result in invalid style values which can result in NaN values if we don't handle them. | ||
// See issue #150 for more context. | ||
const rect = this._parentNode.getBoundingClientRect(); | ||
const height = rect.height || 0; | ||
const width = rect.width || 0; | ||
const style = window.getComputedStyle(this._parentNode) || {}; | ||
const paddingLeft = parseInt(style.paddingLeft, 10) || 0; | ||
const paddingRight = parseInt(style.paddingRight, 10) || 0; | ||
const paddingTop = parseInt(style.paddingTop, 10) || 0; | ||
const paddingBottom = parseInt(style.paddingBottom, 10) || 0; | ||
const newHeight = height - paddingTop - paddingBottom; | ||
const newWidth = width - paddingLeft - paddingRight; | ||
if (!disableHeight && this.state.height !== newHeight || !disableWidth && this.state.width !== newWidth) { | ||
this.setState({ | ||
height: height - paddingTop - paddingBottom, | ||
width: width - paddingLeft - paddingRight | ||
}); | ||
if (typeof onResize === "function") onResize({ | ||
height: height, | ||
width: width | ||
}); | ||
} | ||
} | ||
}; | ||
_setRef = (autoSizer)=>{ | ||
this._autoSizer = autoSizer; | ||
}; | ||
} | ||
$4fd1a97a17b80f9f$var$_defineProperty($4fd1a97a17b80f9f$export$9d94f4ee1d930ff, "defaultProps", { | ||
onResize: ()=>{}, | ||
disableHeight: false, | ||
disableWidth: false, | ||
style: {} | ||
}); | ||
@@ -309,0 +337,0 @@ |
@@ -200,16 +200,69 @@ import {createElement as $hgUW1$createElement, Component as $hgUW1$Component} from "react"; | ||
function $6e2bb92d9db3b0c8$var$_defineProperty(obj, key, value) { | ||
key = $6e2bb92d9db3b0c8$var$_toPropertyKey(key); | ||
if (key in obj) Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
else obj[key] = value; | ||
return obj; | ||
} | ||
function $6e2bb92d9db3b0c8$var$_toPropertyKey(arg) { | ||
var key = $6e2bb92d9db3b0c8$var$_toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function $6e2bb92d9db3b0c8$var$_toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
class $6e2bb92d9db3b0c8$export$9d94f4ee1d930ff extends (0, $hgUW1$Component) { | ||
static defaultProps = { | ||
onResize: ()=>{}, | ||
disableHeight: false, | ||
disableWidth: false, | ||
style: {} | ||
}; | ||
state = { | ||
height: this.props.defaultHeight || 0, | ||
width: this.props.defaultWidth || 0 | ||
}; | ||
_parentNode = null; | ||
_autoSizer = null; | ||
_detectElementResize = null; | ||
constructor(...args){ | ||
super(...args); | ||
$6e2bb92d9db3b0c8$var$_defineProperty(this, "state", { | ||
height: this.props.defaultHeight || 0, | ||
width: this.props.defaultWidth || 0 | ||
}); | ||
$6e2bb92d9db3b0c8$var$_defineProperty(this, "_parentNode", null); | ||
$6e2bb92d9db3b0c8$var$_defineProperty(this, "_autoSizer", null); | ||
$6e2bb92d9db3b0c8$var$_defineProperty(this, "_detectElementResize", null); | ||
$6e2bb92d9db3b0c8$var$_defineProperty(this, "_onResize", ()=>{ | ||
const { disableHeight: disableHeight , disableWidth: disableWidth , onResize: onResize } = this.props; | ||
if (this._parentNode) { | ||
// Guard against AutoSizer component being removed from the DOM immediately after being added. | ||
// This can result in invalid style values which can result in NaN values if we don't handle them. | ||
// See issue #150 for more context. | ||
const rect = this._parentNode.getBoundingClientRect(); | ||
const height = rect.height || 0; | ||
const width = rect.width || 0; | ||
const style = window.getComputedStyle(this._parentNode) || {}; | ||
const paddingLeft = parseInt(style.paddingLeft, 10) || 0; | ||
const paddingRight = parseInt(style.paddingRight, 10) || 0; | ||
const paddingTop = parseInt(style.paddingTop, 10) || 0; | ||
const paddingBottom = parseInt(style.paddingBottom, 10) || 0; | ||
const newHeight = height - paddingTop - paddingBottom; | ||
const newWidth = width - paddingLeft - paddingRight; | ||
if (!disableHeight && this.state.height !== newHeight || !disableWidth && this.state.width !== newWidth) { | ||
this.setState({ | ||
height: height - paddingTop - paddingBottom, | ||
width: width - paddingLeft - paddingRight | ||
}); | ||
if (typeof onResize === "function") onResize({ | ||
height: height, | ||
width: width | ||
}); | ||
} | ||
} | ||
}); | ||
$6e2bb92d9db3b0c8$var$_defineProperty(this, "_setRef", (autoSizer)=>{ | ||
this._autoSizer = autoSizer; | ||
}); | ||
} | ||
componentDidMount() { | ||
@@ -265,34 +318,9 @@ const { nonce: nonce } = this.props; | ||
} | ||
_onResize = ()=>{ | ||
const { disableHeight: disableHeight , disableWidth: disableWidth , onResize: onResize } = this.props; | ||
if (this._parentNode) { | ||
// Guard against AutoSizer component being removed from the DOM immediately after being added. | ||
// This can result in invalid style values which can result in NaN values if we don't handle them. | ||
// See issue #150 for more context. | ||
const rect = this._parentNode.getBoundingClientRect(); | ||
const height = rect.height || 0; | ||
const width = rect.width || 0; | ||
const style = window.getComputedStyle(this._parentNode) || {}; | ||
const paddingLeft = parseInt(style.paddingLeft, 10) || 0; | ||
const paddingRight = parseInt(style.paddingRight, 10) || 0; | ||
const paddingTop = parseInt(style.paddingTop, 10) || 0; | ||
const paddingBottom = parseInt(style.paddingBottom, 10) || 0; | ||
const newHeight = height - paddingTop - paddingBottom; | ||
const newWidth = width - paddingLeft - paddingRight; | ||
if (!disableHeight && this.state.height !== newHeight || !disableWidth && this.state.width !== newWidth) { | ||
this.setState({ | ||
height: height - paddingTop - paddingBottom, | ||
width: width - paddingLeft - paddingRight | ||
}); | ||
if (typeof onResize === "function") onResize({ | ||
height: height, | ||
width: width | ||
}); | ||
} | ||
} | ||
}; | ||
_setRef = (autoSizer)=>{ | ||
this._autoSizer = autoSizer; | ||
}; | ||
} | ||
$6e2bb92d9db3b0c8$var$_defineProperty($6e2bb92d9db3b0c8$export$9d94f4ee1d930ff, "defaultProps", { | ||
onResize: ()=>{}, | ||
disableHeight: false, | ||
disableWidth: false, | ||
style: {} | ||
}); | ||
@@ -299,0 +327,0 @@ |
{ | ||
"name": "react-virtualized-auto-sizer", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Standalone version of the AutoSizer component from react-virtualized", | ||
@@ -56,2 +56,5 @@ "author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)", | ||
"devDependencies": { | ||
"@babel/core": "^7.21.4", | ||
"@babel/helper-create-class-features-plugin": "^7.21.4", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@parcel/core": "^2.8.3", | ||
@@ -58,0 +61,0 @@ "@parcel/packager-ts": "^2.8.3", |
@@ -34,3 +34,3 @@ # react-virtualized-auto-sizer | ||
```jsx | ||
import { AutoSizer } from "react-virtualized-auto-sizer"; | ||
import AutoSizer from "react-virtualized-auto-sizer"; | ||
@@ -98,2 +98,2 @@ // UI | ||
To apply Content Security Policy, pass a `nonce` to `AutoSizer` and add a matching `nonce-source` to the `Content-Security-Policy` field in HTTP header. | ||
To apply Content Security Policy, pass a `nonce` to `AutoSizer` and add a matching `nonce-source` to the `Content-Security-Policy` field in HTTP header. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
100780
699
98
17