react-flickity-component
Advanced tools
Comparing version
@@ -1,7 +0,90 @@ | ||
import "react"; | ||
import "react-dom"; | ||
import { F as p } from "./index-48195875.mjs"; | ||
import o, { Component as y } from "react"; | ||
import { createPortal as h } from "react-dom"; | ||
import a from "imagesloaded"; | ||
import s from "prop-types"; | ||
const u = !!(typeof window < "u" && window.document && window.document.createElement); | ||
class r extends y { | ||
constructor(e) { | ||
super(e), this.state = { | ||
flickityReady: !1, | ||
flickityCreated: !1, | ||
cellCount: 0 | ||
}, this.carousel = null, this.flkty = null; | ||
} | ||
static getDerivedStateFromProps(e, t) { | ||
const i = o.Children.count(e.children); | ||
return i !== t.cellCount ? { flickityReady: !1, cellCount: i } : null; | ||
} | ||
componentDidUpdate(e, t) { | ||
const { | ||
children: i, | ||
options: { draggable: l, initialIndex: n }, | ||
reloadOnUpdate: c, | ||
disableImagesLoaded: d | ||
} = this.props, { flickityReady: f } = this.state; | ||
if (c || !t.flickityReady && f) { | ||
if (!this.flkty) | ||
return; | ||
const p = this.flkty.isActive; | ||
this.flkty.deactivate(), this.flkty.selectedIndex = n || 0, this.flkty.options.draggable = l === void 0 ? i ? i.length > 1 : !1 : l, p && this.flkty.activate(), !d && this.carousel && a(this.carousel, () => { | ||
this.flkty.reloadCells(); | ||
}); | ||
} else | ||
this.flkty.reloadCells(); | ||
} | ||
async componentDidMount() { | ||
if (!u) | ||
return null; | ||
const e = (await import("flickity")).default, { flickityRef: t, options: i } = this.props; | ||
this.flkty = new e(this.carousel, i), t && t(this.flkty), this.props.static ? this.setReady() : this.setState({ flickityCreated: !0 }); | ||
} | ||
setReady() { | ||
if (this.state.flickityReady) | ||
return; | ||
const e = () => this.setState({ flickityReady: !0 }); | ||
this.props.disableImagesLoaded ? e() : a(this.carousel, e); | ||
} | ||
renderPortal() { | ||
if (!this.carousel) | ||
return null; | ||
const e = this.carousel.querySelector(".flickity-slider"); | ||
if (e) { | ||
const t = h(this.props.children, e); | ||
return setTimeout(() => this.setReady(), 0), t; | ||
} | ||
} | ||
render() { | ||
return o.createElement( | ||
this.props.elementType, | ||
{ | ||
className: this.props.className, | ||
ref: (e) => { | ||
this.carousel = e; | ||
} | ||
}, | ||
this.props.static ? this.props.children : this.renderPortal() | ||
); | ||
} | ||
} | ||
r.propTypes = { | ||
children: s.array, | ||
className: s.string, | ||
disableImagesLoaded: s.bool, | ||
elementType: s.string, | ||
flickityRef: s.func, | ||
options: s.object, | ||
reloadOnUpdate: s.bool, | ||
static: s.bool | ||
}; | ||
r.defaultProps = { | ||
className: "", | ||
disableImagesLoaded: !1, | ||
elementType: "div", | ||
options: {}, | ||
reloadOnUpdate: !1, | ||
static: !1 | ||
}; | ||
export { | ||
p as default | ||
r as default | ||
}; | ||
//# sourceMappingURL=react-flickity-component.es.js.map |
{ | ||
"name": "react-flickity-component", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "react flickity component", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2
-50%0
-100%23717
-96.36%6
-40%100
-96.19%1
Infinity%