version 1.12.0

This commit is contained in:
Rene
2020-04-05 16:21:56 +02:00
parent 8a9f312f12
commit a01273a3d3
43 changed files with 3796 additions and 3155 deletions
@@ -42,6 +42,7 @@ class OverlayScrollbarsComponent extends Component {
}
componentDidMount() {
this._osInstance = OverlayScrollbars(this.osTarget(), this.props.options || {}, this.props.extensions);
mergeHostClassNames(this._osInstance, this.props.className);
}
componentWillUnmount() {
if (OverlayScrollbars.valid(this._osInstance)) {
@@ -52,11 +53,14 @@ class OverlayScrollbarsComponent extends Component {
componentDidUpdate(prevProps) {
if (OverlayScrollbars.valid(this._osInstance)) {
this._osInstance.options(this.props.options);
if (prevProps.className !== this.props.className) {
mergeHostClassNames(this._osInstance, this.props.className);
}
}
}
render() {
let _a = this.props, { options, extensions, children, className } = _a, divProps = __rest(_a, ["options", "extensions", "children", "className"]);
return (React.createElement("div", Object.assign({ className: `${className} os-host` }, divProps, { ref: this._osTargetRef }),
const _a = this.props, divProps = __rest(_a, ["options", "extensions", "children", "className"]);
return (React.createElement("div", Object.assign({ className: "os-host" }, divProps, { ref: this._osTargetRef }),
React.createElement("div", { className: "os-resize-observer-host" }),
React.createElement("div", { className: "os-padding" },
React.createElement("div", { className: "os-viewport" },
@@ -70,6 +74,16 @@ class OverlayScrollbarsComponent extends Component {
React.createElement("div", { className: "os-scrollbar-corner" })));
}
}
function mergeHostClassNames(osInstance, className) {
if (OverlayScrollbars.valid(osInstance)) {
const { host } = osInstance.getElements();
const regex = new RegExp(`(^os-host([-_].+|)$)|${osInstance.options().className.replace(/\s/g, "$|")}$`, 'g');
const osClassNames = host.className.split(' ')
.filter(name => name.match(regex))
.join(' ');
host.className = `${osClassNames} ${className || ''}`;
}
}
export { OverlayScrollbarsComponent };
//# sourceMappingURL=overlayscrollbars-react.esm.js.map