Blame view

天文台pc/tianwentai-ui/node_modules/@mui/material/ImageListItem/ImageListItem.js 6.11 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
  "use strict";
  'use client';
  
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = void 0;
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
  var _integerPropType = _interopRequireDefault(require("@mui/utils/integerPropType"));
  var _clsx = _interopRequireDefault(require("clsx"));
  var _propTypes = _interopRequireDefault(require("prop-types"));
  var React = _interopRequireWildcard(require("react"));
  var _reactIs = require("react-is");
  var _ImageListContext = _interopRequireDefault(require("../ImageList/ImageListContext"));
  var _zeroStyled = require("../zero-styled");
  var _DefaultPropsProvider = require("../DefaultPropsProvider");
  var _isMuiElement = _interopRequireDefault(require("../utils/isMuiElement"));
  var _imageListItemClasses = _interopRequireWildcard(require("./imageListItemClasses"));
  var _jsxRuntime = require("react/jsx-runtime");
  const useUtilityClasses = ownerState => {
    const {
      classes,
      variant
    } = ownerState;
    const slots = {
      root: ['root', variant],
      img: ['img']
    };
    return (0, _composeClasses.default)(slots, _imageListItemClasses.getImageListItemUtilityClass, classes);
  };
  const ImageListItemRoot = (0, _zeroStyled.styled)('li', {
    name: 'MuiImageListItem',
    slot: 'Root',
    overridesResolver: (props, styles) => {
      const {
        ownerState
      } = props;
      return [{
        [`& .${_imageListItemClasses.default.img}`]: styles.img
      }, styles.root, styles[ownerState.variant]];
    }
  })({
    display: 'block',
    position: 'relative',
    [`& .${_imageListItemClasses.default.img}`]: {
      objectFit: 'cover',
      width: '100%',
      height: '100%',
      display: 'block'
    },
    variants: [{
      props: {
        variant: 'standard'
      },
      style: {
        // For titlebar under list item
        display: 'flex',
        flexDirection: 'column'
      }
    }, {
      props: {
        variant: 'woven'
      },
      style: {
        height: '100%',
        alignSelf: 'center',
        '&:nth-of-type(even)': {
          height: '70%'
        }
      }
    }, {
      props: {
        variant: 'standard'
      },
      style: {
        [`& .${_imageListItemClasses.default.img}`]: {
          height: 'auto',
          flexGrow: 1
        }
      }
    }]
  });
  const ImageListItem = /*#__PURE__*/React.forwardRef(function ImageListItem(inProps, ref) {
    const props = (0, _DefaultPropsProvider.useDefaultProps)({
      props: inProps,
      name: 'MuiImageListItem'
    });
  
    // TODO: - Use jsdoc @default?: "cols rows default values are for docs only"
    const {
      children,
      className,
      cols = 1,
      component = 'li',
      rows = 1,
      style,
      ...other
    } = props;
    const {
      rowHeight = 'auto',
      gap,
      variant
    } = React.useContext(_ImageListContext.default);
    let height = 'auto';
    if (variant === 'woven') {
      height = undefined;
    } else if (rowHeight !== 'auto') {
      height = rowHeight * rows + gap * (rows - 1);
    }
    const ownerState = {
      ...props,
      cols,
      component,
      gap,
      rowHeight,
      rows,
      variant
    };
    const classes = useUtilityClasses(ownerState);
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageListItemRoot, {
      as: component,
      className: (0, _clsx.default)(classes.root, classes[variant], className),
      ref: ref,
      style: {
        height,
        gridColumnEnd: variant !== 'masonry' ? `span ${cols}` : undefined,
        gridRowEnd: variant !== 'masonry' ? `span ${rows}` : undefined,
        marginBottom: variant === 'masonry' ? gap : undefined,
        breakInside: variant === 'masonry' ? 'avoid' : undefined,
        ...style
      },
      ownerState: ownerState,
      ...other,
      children: React.Children.map(children, child => {
        if (! /*#__PURE__*/React.isValidElement(child)) {
          return null;
        }
        if (process.env.NODE_ENV !== 'production') {
          if ((0, _reactIs.isFragment)(child)) {
            console.error(["MUI: The ImageListItem component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
          }
        }
        if (child.type === 'img' || (0, _isMuiElement.default)(child, ['Image'])) {
          return /*#__PURE__*/React.cloneElement(child, {
            className: (0, _clsx.default)(classes.img, child.props.className)
          });
        }
        return child;
      })
    });
  });
  process.env.NODE_ENV !== "production" ? ImageListItem.propTypes /* remove-proptypes */ = {
    // ┌────────────────────────────── Warning ──────────────────────────────┐
    // │ These PropTypes are generated from the TypeScript type definitions. │
    // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │
    // └─────────────────────────────────────────────────────────────────────┘
    /**
     * The content of the component, normally an `<img>`.
     */
    children: _propTypes.default.node,
    /**
     * Override or extend the styles applied to the component.
     */
    classes: _propTypes.default.object,
    /**
     * @ignore
     */
    className: _propTypes.default.string,
    /**
     * Width of the item in number of grid columns.
     * @default 1
     */
    cols: _integerPropType.default,
    /**
     * The component used for the root node.
     * Either a string to use a HTML element or a component.
     */
    component: _propTypes.default.elementType,
    /**
     * Height of the item in number of grid rows.
     * @default 1
     */
    rows: _integerPropType.default,
    /**
     * @ignore
     */
    style: _propTypes.default.object,
    /**
     * The system prop that allows defining system overrides as well as additional CSS styles.
     */
    sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
  } : void 0;
  var _default = exports.default = ImageListItem;