Files
pstreact/node_modules/react-responsive-masonry/umd/react-responsive-masonry.min.js
2026-03-13 19:23:37 +03:00

6 lines
5.2 KiB
JavaScript

/*!
* react-responsive-masonry v2.7.1 - https://github.com/cedricdelpoux/react-responsive-masonry#readme
* MIT Licensed
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactResponsiveMasonry=e(require("react")):t.ReactResponsiveMasonry=e(t.React)}(window,(function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(e,n){e.exports=t},function(t,e,n){t.exports=n(2)},function(t,e,n){"use strict";n.r(e),n.d(e,"ResponsiveMasonry",(function(){return f}));var r=n(0),o=n.n(r);function i(){return(i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var s=function(t){var e,n;function r(){var e;return(e=t.call(this)||this).state={columns:[],childRefs:[],hasDistributed:!1},e}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,u(e,n);var s=r.prototype;return s.componentDidUpdate=function(){this.state.hasDistributed||this.props.sequential||this.distributeChildren()},r.getDerivedStateFromProps=function(t,e){var n=t.children,o=t.columnsCount,u=o!==e.columns.length;return e&&n===e.children&&!u?null:i({},r.getEqualCountColumns(n,o),{children:n,hasDistributed:!1})},s.shouldComponentUpdate=function(t){return t.children!==this.state.children||t.columnsCount!==this.props.columnsCount},s.distributeChildren=function(){var t=this,e=this.props,n=e.children,r=e.columnsCount,u=Array(r).fill(0);if(this.state.childRefs.every((function(t){return t.current.getBoundingClientRect().height}))){var s=Array.from({length:r},(function(){return[]})),c=0;o.a.Children.forEach(n,(function(e){if(e&&o.a.isValidElement(e)){var n=t.state.childRefs[c].current.getBoundingClientRect().height,r=u.indexOf(Math.min.apply(Math,u));u[r]+=n,s[r].push(e),c++}})),this.setState((function(t){return i({},t,{columns:s,hasDistributed:!0})}))}},r.getEqualCountColumns=function(t,e){var n=Array.from({length:e},(function(){return[]})),r=0,i=[];return o.a.Children.forEach(t,(function(t){if(t&&o.a.isValidElement(t)){var u=o.a.createRef();i.push(u),n[r%e].push(o.a.createElement("div",{style:{display:"flex",justifyContent:"stretch"},key:r,ref:u},t)),r++}})),{columns:n,childRefs:i}},s.renderColumns=function(){var t=this.props,e=t.gutter,n=t.itemTag,r=t.itemStyle;return this.state.columns.map((function(t,u){return o.a.createElement(n,{key:u,style:i({display:"flex",flexDirection:"column",justifyContent:"flex-start",alignContent:"stretch",flex:1,width:0,gap:e},r)},t.map((function(t){return t})))}))},s.render=function(){var t=this.props,e=t.gutter,n=t.className,r=t.style,u=t.containerTag;return o.a.createElement(u,{style:i({display:"flex",flexDirection:"row",justifyContent:"center",alignContent:"stretch",boxSizing:"border-box",width:"100%",gap:e},r),className:n},this.renderColumns())},r}(o.a.Component);s.defaultProps={columnsCount:3,gutter:"0",className:null,style:{},containerTag:"div",itemTag:"div",itemStyle:{},sequential:!1};var c=s,a="undefined"!=typeof window?r.useLayoutEffect:r.useEffect,l=function(){var t=function(){var t=Object(r.useState)(!1),e=t[0],n=t[1];return a((function(){n(!0)}),[]),e}(),e=Object(r.useState)("undefined"!=typeof window?window.innerWidth:0),n=e[0],o=e[1],i=Object(r.useCallback)((function(){t&&o(window.innerWidth)}),[t]);return a((function(){if(t)return window.addEventListener("resize",i),i(),function(){return window.removeEventListener("resize",i)}}),[t,i]),n},f=function(t){var e=t.columnsCountBreakPoints,n=void 0===e?{350:1,750:2,900:3}:e,i=t.gutterBreakPoints,u=void 0===i?{}:i,s=t.children,c=t.className,a=void 0===c?null:c,f=t.style,d=void 0===f?null:f,p=l(),h=Object(r.useCallback)((function(t,e){var n=Object.keys(t).sort((function(t,e){return t-e})),r=n.length>0?t[n[0]]:e;return n.forEach((function(e){e<p&&(r=t[e])})),r}),[p]),m=Object(r.useMemo)((function(){return h(n,1)}),[h,n]),y=Object(r.useMemo)((function(){return h(u,"10px")}),[h,u]);return o.a.createElement("div",{className:a,style:d},o.a.Children.map(s,(function(t,e){return o.a.cloneElement(t,{key:e,columnsCount:m,gutter:y})})))};e.default=c}]).default}));
//# sourceMappingURL=react-responsive-masonry.min.js.map