2dfd9218db22957ba454213e42813827.json 16 KB

1
  1. {"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport clsx from 'clsx';\nimport debounce from '../utils/debounce';\nimport withStyles from '../styles/withStyles';\nimport isMuiElement from '../utils/isMuiElement';\nexport var styles = {\n /* Styles applied to the root element. */\n root: {\n boxSizing: 'border-box',\n flexShrink: 0\n },\n\n /* Styles applied to the `div` element that wraps the children. */\n tile: {\n position: 'relative',\n display: 'block',\n // In case it's not rendered with a div.\n height: '100%',\n overflow: 'hidden'\n },\n\n /* Styles applied to an `img` element child, if needed to ensure it covers the tile. */\n imgFullHeight: {\n height: '100%',\n transform: 'translateX(-50%)',\n position: 'relative',\n left: '50%'\n },\n\n /* Styles applied to an `img` element child, if needed to ensure it covers the tile. */\n imgFullWidth: {\n width: '100%',\n position: 'relative',\n transform: 'translateY(-50%)',\n top: '50%'\n }\n};\n\nvar fit = function fit(imgEl, classes) {\n if (!imgEl || !imgEl.complete) {\n return;\n }\n\n if (imgEl.width / imgEl.height > imgEl.parentElement.offsetWidth / imgEl.parentElement.offsetHeight) {\n var _imgEl$classList, _imgEl$classList2;\n\n (_imgEl$classList = imgEl.classList).remove.apply(_imgEl$classList, _toConsumableArray(classes.imgFullWidth.split(' ')));\n\n (_imgEl$classList2 = imgEl.classList).add.apply(_imgEl$classList2, _toConsumableArray(classes.imgFullHeight.split(' ')));\n } else {\n var _imgEl$classList3, _imgEl$classList4;\n\n (_imgEl$classList3 = imgEl.classList).remove.apply(_imgEl$classList3, _toConsumableArray(classes.imgFullHeight.split(' ')));\n\n (_imgEl$classList4 = imgEl.classList).add.apply(_imgEl$classList4, _toConsumableArray(classes.imgFullWidth.split(' ')));\n }\n};\n\nfunction ensureImageCover(imgEl, classes) {\n if (!imgEl) {\n return;\n }\n\n if (imgEl.complete) {\n fit(imgEl, classes);\n } else {\n imgEl.addEventListener('load', function () {\n fit(imgEl, classes);\n });\n }\n}\n\nvar GridListTile = /*#__PURE__*/React.forwardRef(function GridListTile(props, ref) {\n // cols rows default values are for docs only\n var children = props.children,\n classes = props.classes,\n className = props.className,\n _props$cols = props.cols,\n cols = _props$cols === void 0 ? 1 : _props$cols,\n _props$component = props.component,\n Component = _props$component === void 0 ? 'li' : _props$component,\n _props$rows = props.rows,\n rows = _props$rows === void 0 ? 1 : _props$rows,\n other = _objectWithoutProperties(props, [\"children\", \"classes\", \"className\", \"cols\", \"component\", \"rows\"]);\n\n var imgRef = React.useRef(null);\n React.useEffect(function () {\n ensureImageCover(imgRef.current, classes);\n });\n React.useEffect(function () {\n var handleResize = debounce(function () {\n fit(imgRef.current, classes);\n });\n window.addEventListener('resize', handleResize);\n return function () {\n handleResize.clear();\n window.removeEventListener('resize', handleResize);\n };\n }, [classes]);\n return /*#__PURE__*/React.createElement(Component, _extends({\n className: clsx(classes.root, className),\n ref: ref\n }, other), /*#__PURE__*/React.createElement(\"div\", {\n className: classes.tile\n }, React.Children.map(children, function (child) {\n if (! /*#__PURE__*/React.isValidElement(child)) {\n return null;\n }\n\n if (child.type === 'img' || isMuiElement(child, ['Image'])) {\n return /*#__PURE__*/React.cloneElement(child, {\n ref: imgRef\n });\n }\n\n return child;\n })));\n});\nprocess.env.NODE_ENV !== \"production\" ? GridListTile.propTypes = {\n /**\n * Theoretically you can pass any node as children, but the main use case is to pass an img,\n * in which case GridListTile takes care of making the image \"cover\" available space\n * (similar to `background-size: cover` or to `object-fit: cover`).\n */\n children: PropTypes.node,\n\n /**\n * Override or extend the styles applied to the component.\n * See [CSS API](#css) below for more details.\n */\n classes: PropTypes.object.isRequired,\n\n /**\n * @ignore\n */\n className: PropTypes.string,\n\n /**\n * Width of the tile in number of grid cells.\n */\n cols: PropTypes.number,\n\n /**\n * The component used for the root node.\n * Either a string to use a HTML element or a component.\n */\n component: PropTypes\n /* @typescript-to-proptypes-ignore */\n .elementType,\n\n /**\n * Height of the tile in number of grid cells.\n */\n rows: PropTypes.number\n} : void 0;\nexport default withStyles(styles, {\n name: 'MuiGridListTile'\n})(GridListTile);","map":{"version":3,"sources":["/Users/holunyeung/Documents/GitHub/Photo_React/photo/node_modules/@material-ui/core/esm/GridListTile/GridListTile.js"],"names":["_extends","_objectWithoutProperties","_toConsumableArray","React","PropTypes","clsx","debounce","withStyles","isMuiElement","styles","root","boxSizing","flexShrink","tile","position","display","height","overflow","imgFullHeight","transform","left","imgFullWidth","width","top","fit","imgEl","classes","complete","parentElement","offsetWidth","offsetHeight","_imgEl$classList","_imgEl$classList2","classList","remove","apply","split","add","_imgEl$classList3","_imgEl$classList4","ensureImageCover","addEventListener","GridListTile","forwardRef","props","ref","children","className","_props$cols","cols","_props$component","component","Component","_props$rows","rows","other","imgRef","useRef","useEffect","current","handleResize","window","clear","removeEventListener","createElement","Children","map","child","isValidElement","type","cloneElement","process","env","NODE_ENV","propTypes","node","object","isRequired","string","number","elementType","name"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,oCAArB;AACA,OAAOC,wBAAP,MAAqC,oDAArC;AACA,OAAOC,kBAAP,MAA+B,8CAA/B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,OAAOC,QAAP,MAAqB,mBAArB;AACA,OAAOC,UAAP,MAAuB,sBAAvB;AACA,OAAOC,YAAP,MAAyB,uBAAzB;AACA,OAAO,IAAIC,MAAM,GAAG;AAClB;AACAC,EAAAA,IAAI,EAAE;AACJC,IAAAA,SAAS,EAAE,YADP;AAEJC,IAAAA,UAAU,EAAE;AAFR,GAFY;;AAOlB;AACAC,EAAAA,IAAI,EAAE;AACJC,IAAAA,QAAQ,EAAE,UADN;AAEJC,IAAAA,OAAO,EAAE,OAFL;AAGJ;AACAC,IAAAA,MAA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,EAAiB;AAC/C,QAAI,EAAE,aAAahE,KAAK,CAACiE,cAAN,CAAqBD,KAArB,CAAnB,EAAgD;AAC9C,aAAO,IAAP;AACD;;AAED,QAAIA,KAAK,CAACE,IAAN,KAAe,KAAf,IAAwB7D,YAAY,CAAC2D,KAAD,EAAQ,CAAC,OAAD,CAAR,CAAxC,EAA4D;AAC1D,aAAO,aAAahE,KAAK,CAACmE,YAAN,CAAmBH,KAAnB,EAA0B;AAC5CtB,QAAAA,GAAG,EAAEW;AADuC,OAA1B,CAApB;AAGD;;AAED,WAAOW,KAAP;AACD,GAZE,CAFqB,CAHJ,CAApB;AAkBD,CA7C+B,CAAhC;AA8CAI,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAAzB,GAAwC/B,YAAY,CAACgC,SAAb,GAAyB;AAC/D;;;;;AAKA5B,EAAAA,QAAQ,EAAE1C,SAAS,CAACuE,IAN2C;;AAQ/D;;;;AAIAjD,EAAAA,OAAO,EAAEtB,SAAS,CAACwE,MAAV,CAAiBC,UAZqC;;AAc/D;;;AAGA9B,EAAAA,SAAS,EAAE3C,SAAS,CAAC0E,MAjB0C;;AAmB/D;;;AAGA7B,EAAAA,IAAI,EAAE7C,SAAS,CAAC2E,MAtB+C;;AAwB/D;;;;AAIA5B,EAAAA,SAAS,EAAE/C;AACX;AADoB,GAEnB4E,WA9B8D;;AAgC/D;;;AAGA1B,EAAAA,IAAI,EAAElD,SAAS,CAAC2E;AAnC+C,CAAjE,GAoCI,KAAK,CApCT;AAqCA,eAAexE,UAAU,CAACE,MAAD,EAAS;AAChCwE,EAAAA,IAAI,EAAE;AAD0B,CAAT,CAAV,CAEZvC,YAFY,CAAf","sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport clsx from 'clsx';\nimport debounce from '../utils/debounce';\nimport withStyles from '../styles/withStyles';\nimport isMuiElement from '../utils/isMuiElement';\nexport var styles = {\n /* Styles applied to the root element. */\n root: {\n boxSizing: 'border-box',\n flexShrink: 0\n },\n\n /* Styles applied to the `div` element that wraps the children. */\n tile: {\n position: 'relative',\n display: 'block',\n // In case it's not rendered with a div.\n height: '100%',\n overflow: 'hidden'\n },\n\n /* Styles applied to an `img` element child, if needed to ensure it covers the tile. */\n imgFullHeight: {\n height: '100%',\n transform: 'translateX(-50%)',\n position: 'relative',\n left: '50%'\n },\n\n /* Styles applied to an `img` element child, if needed to ensure it covers the tile. */\n imgFullWidth: {\n width: '100%',\n position: 'relative',\n transform: 'translateY(-50%)',\n top: '50%'\n }\n};\n\nvar fit = function fit(imgEl, classes) {\n if (!imgEl || !imgEl.complete) {\n return;\n }\n\n if (imgEl.width / imgEl.height > imgEl.parentElement.offsetWidth / imgEl.parentElement.offsetHeight) {\n var _imgEl$classList, _imgEl$classList2;\n\n (_imgEl$classList = imgEl.classList).remove.apply(_imgEl$classList, _toConsumableArray(classes.imgFullWidth.split(' ')));\n\n (_imgEl$classList2 = imgEl.classList).add.apply(_imgEl$classList2, _toConsumableArray(classes.imgFullHeight.split(' ')));\n } else {\n var _imgEl$classList3, _imgEl$classList4;\n\n (_imgEl$classList3 = imgEl.classList).remove.apply(_imgEl$classList3, _toConsumableArray(classes.imgFullHeight.split(' ')));\n\n (_imgEl$classList4 = imgEl.classList).add.apply(_imgEl$classList4, _toConsumableArray(classes.imgFullWidth.split(' ')));\n }\n};\n\nfunction ensureImageCover(imgEl, classes) {\n if (!imgEl) {\n return;\n }\n\n if (imgEl.complete) {\n fit(imgEl, classes);\n } else {\n imgEl.addEventListener('load', function () {\n fit(imgEl, classes);\n });\n }\n}\n\nvar GridListTile = /*#__PURE__*/React.forwardRef(function GridListTile(props, ref) {\n // cols rows default values are for docs only\n var children = props.children,\n classes = props.classes,\n className = props.className,\n _props$cols = props.cols,\n cols = _props$cols === void 0 ? 1 : _props$cols,\n _props$component = props.component,\n Component = _props$component === void 0 ? 'li' : _props$component,\n _props$rows = props.rows,\n rows = _props$rows === void 0 ? 1 : _props$rows,\n other = _objectWithoutProperties(props, [\"children\", \"classes\", \"className\", \"cols\", \"component\", \"rows\"]);\n\n var imgRef = React.useRef(null);\n React.useEffect(function () {\n ensureImageCover(imgRef.current, classes);\n });\n React.useEffect(function () {\n var handleResize = debounce(function () {\n fit(imgRef.current, classes);\n });\n window.addEventListener('resize', handleResize);\n return function () {\n handleResize.clear();\n window.removeEventListener('resize', handleResize);\n };\n }, [classes]);\n return /*#__PURE__*/React.createElement(Component, _extends({\n className: clsx(classes.root, className),\n ref: ref\n }, other), /*#__PURE__*/React.createElement(\"div\", {\n className: classes.tile\n }, React.Children.map(children, function (child) {\n if (! /*#__PURE__*/React.isValidElement(child)) {\n return null;\n }\n\n if (child.type === 'img' || isMuiElement(child, ['Image'])) {\n return /*#__PURE__*/React.cloneElement(child, {\n ref: imgRef\n });\n }\n\n return child;\n })));\n});\nprocess.env.NODE_ENV !== \"production\" ? GridListTile.propTypes = {\n /**\n * Theoretically you can pass any node as children, but the main use case is to pass an img,\n * in which case GridListTile takes care of making the image \"cover\" available space\n * (similar to `background-size: cover` or to `object-fit: cover`).\n */\n children: PropTypes.node,\n\n /**\n * Override or extend the styles applied to the component.\n * See [CSS API](#css) below for more details.\n */\n classes: PropTypes.object.isRequired,\n\n /**\n * @ignore\n */\n className: PropTypes.string,\n\n /**\n * Width of the tile in number of grid cells.\n */\n cols: PropTypes.number,\n\n /**\n * The component used for the root node.\n * Either a string to use a HTML element or a component.\n */\n component: PropTypes\n /* @typescript-to-proptypes-ignore */\n .elementType,\n\n /**\n * Height of the tile in number of grid cells.\n */\n rows: PropTypes.number\n} : void 0;\nexport default withStyles(styles, {\n name: 'MuiGridListTile'\n})(GridListTile);"]},"metadata":{},"sourceType":"module"}