1 line
42 KiB
JSON
1 line
42 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport CaretDownOutlined from \"@ant-design/icons/es/icons/CaretDownOutlined\";\nimport CaretUpOutlined from \"@ant-design/icons/es/icons/CaretUpOutlined\";\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport Tooltip from '../../tooltip';\nimport { getColumnKey, getColumnPos, renderColumnTitle, safeColumnTitle } from '../util';\nconst ASCEND = 'ascend';\nconst DESCEND = 'descend';\nconst getMultiplePriority = column => {\n if (typeof column.sorter === 'object' && typeof column.sorter.multiple === 'number') {\n return column.sorter.multiple;\n }\n return false;\n};\nconst getSortFunction = sorter => {\n if (typeof sorter === 'function') {\n return sorter;\n }\n if (sorter && typeof sorter === 'object' && sorter.compare) {\n return sorter.compare;\n }\n return false;\n};\nconst nextSortDirection = (sortDirections, current) => {\n if (!current) {\n return sortDirections[0];\n }\n return sortDirections[sortDirections.indexOf(current) + 1];\n};\nconst collectSortStates = (columns, init, pos) => {\n let sortStates = [];\n const pushState = (column, columnPos) => {\n sortStates.push({\n column,\n key: getColumnKey(column, columnPos),\n multiplePriority: getMultiplePriority(column),\n sortOrder: column.sortOrder\n });\n };\n (columns || []).forEach((column, index) => {\n const columnPos = getColumnPos(index, pos);\n if (column.children) {\n if ('sortOrder' in column) {\n // Controlled\n pushState(column, columnPos);\n }\n sortStates = [].concat(_toConsumableArray(sortStates), _toConsumableArray(collectSortStates(column.children, init, columnPos)));\n } else if (column.sorter) {\n if ('sortOrder' in column) {\n // Controlled\n pushState(column, columnPos);\n } else if (init && column.defaultSortOrder) {\n // Default sorter\n sortStates.push({\n column,\n key: getColumnKey(column, columnPos),\n multiplePriority: getMultiplePriority(column),\n sortOrder: column.defaultSortOrder\n });\n }\n }\n });\n return sortStates;\n};\nconst injectSorter = (prefixCls, columns, sorterStates, triggerSorter, defaultSortDirections, tableLocale, tableShowSorterTooltip, pos) => {\n const finalColumns = (columns || []).map((column, index) => {\n const columnPos = getColumnPos(index, pos);\n let newColumn = column;\n if (newColumn.sorter) {\n const sortDirections = newColumn.sortDirections || defaultSortDirections;\n const showSorterTooltip = newColumn.showSorterTooltip === undefined ? tableShowSorterTooltip : newColumn.showSorterTooltip;\n const columnKey = getColumnKey(newColumn, columnPos);\n const sorterState = sorterStates.find(_ref => {\n let {\n key\n } = _ref;\n return key === columnKey;\n });\n const sortOrder = sorterState ? sorterState.sortOrder : null;\n const nextSortOrder = nextSortDirection(sortDirections, sortOrder);\n let sorter;\n if (column.sortIcon) {\n sorter = column.sortIcon({\n sortOrder\n });\n } else {\n const upNode = sortDirections.includes(ASCEND) && ( /*#__PURE__*/React.createElement(CaretUpOutlined, {\n className: classNames(`${prefixCls}-column-sorter-up`, {\n active: sortOrder === ASCEND\n })\n }));\n const downNode = sortDirections.includes(DESCEND) && ( /*#__PURE__*/React.createElement(CaretDownOutlined, {\n className: classNames(`${prefixCls}-column-sorter-down`, {\n active: sortOrder === DESCEND\n })\n }));\n sorter = /*#__PURE__*/React.createElement(\"span\", {\n className: classNames(`${prefixCls}-column-sorter`, {\n [`${prefixCls}-column-sorter-full`]: !!(upNode && downNode)\n })\n }, /*#__PURE__*/React.cre
|