1 line
28 KiB
JSON
1 line
28 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport extendsObject from '../_util/extendsObject';\nimport { responsiveArray } from '../_util/responsiveObserver';\nimport { ConfigContext } from '../config-provider';\nimport DefaultRenderEmpty from '../config-provider/defaultRenderEmpty';\nimport useSize from '../config-provider/hooks/useSize';\nimport { Row } from '../grid';\nimport useBreakpoint from '../grid/hooks/useBreakpoint';\nimport Pagination from '../pagination';\nimport Spin from '../spin';\nimport { ListContext } from './context';\nimport Item from './Item';\nimport useStyle from './style';\nfunction List(_a) {\n var {\n pagination = false,\n prefixCls: customizePrefixCls,\n bordered = false,\n split = true,\n className,\n rootClassName,\n style,\n children,\n itemLayout,\n loadMore,\n grid,\n dataSource = [],\n size: customizeSize,\n header,\n footer,\n loading = false,\n rowKey,\n renderItem,\n locale\n } = _a,\n rest = __rest(_a, [\"pagination\", \"prefixCls\", \"bordered\", \"split\", \"className\", \"rootClassName\", \"style\", \"children\", \"itemLayout\", \"loadMore\", \"grid\", \"dataSource\", \"size\", \"header\", \"footer\", \"loading\", \"rowKey\", \"renderItem\", \"locale\"]);\n const paginationObj = pagination && typeof pagination === 'object' ? pagination : {};\n const [paginationCurrent, setPaginationCurrent] = React.useState(paginationObj.defaultCurrent || 1);\n const [paginationSize, setPaginationSize] = React.useState(paginationObj.defaultPageSize || 10);\n const {\n getPrefixCls,\n renderEmpty,\n direction,\n list\n } = React.useContext(ConfigContext);\n const defaultPaginationProps = {\n current: 1,\n total: 0\n };\n const triggerPaginationEvent = eventName => (page, pageSize) => {\n var _a;\n setPaginationCurrent(page);\n setPaginationSize(pageSize);\n if (pagination) {\n (_a = pagination === null || pagination === void 0 ? void 0 : pagination[eventName]) === null || _a === void 0 ? void 0 : _a.call(pagination, page, pageSize);\n }\n };\n const onPaginationChange = triggerPaginationEvent('onChange');\n const onPaginationShowSizeChange = triggerPaginationEvent('onShowSizeChange');\n const renderInnerItem = (item, index) => {\n if (!renderItem) return null;\n let key;\n if (typeof rowKey === 'function') {\n key = rowKey(item);\n } else if (rowKey) {\n key = item[rowKey];\n } else {\n key = item.key;\n }\n if (!key) {\n key = `list-item-${index}`;\n }\n return /*#__PURE__*/React.createElement(React.Fragment, {\n key: key\n }, renderItem(item, index));\n };\n const isSomethingAfterLastItem = () => !!(loadMore || pagination || footer);\n const prefixCls = getPrefixCls('list', customizePrefixCls);\n // Style\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n let loadingProp = loading;\n if (typeof loadingProp === 'boolean') {\n loadingProp = {\n spinning: loadingProp\n };\n }\n const isLoading = !!(loadingProp === null || loadingProp === void 0 ? void 0 : loadingProp.spinning);\n const mergedSize = useSize(customizeSize);\n // large => lg\n // small => sm\n let sizeCls = '';\n switch (mergedSize) {\n case 'large':\n sizeCls = 'lg';\n break;\n case 'small':\n sizeCls = 'sm';\n break;\n default:\n break;\n }\n const classString = classNames(
|