PromoCursed/node_modules/.cache/babel-loader/f01e56a3fe2853d1b369afd009fd26a816bc7a7b5af8e6158ab46fc8e97db60f.json

1 line
31 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nimport React, { useMemo, useRef, useState } from 'react';\nimport DownOutlined from \"@ant-design/icons/es/icons/DownOutlined\";\nimport classNames from 'classnames';\nimport omit from \"rc-util/es/omit\";\nimport { groupKeysMap } from '../_util/transKeys';\nimport Checkbox from '../checkbox';\nimport Dropdown from '../dropdown';\nimport DefaultListBody, { OmitProps } from './ListBody';\nimport Search from './search';\nconst defaultRender = () => null;\nfunction isRenderResultPlainObject(result) {\n return !!(result && ! /*#__PURE__*/React.isValidElement(result) && Object.prototype.toString.call(result) === '[object Object]');\n}\nfunction getEnabledItemKeys(items) {\n return items.filter(data => !data.disabled).map(data => data.key);\n}\nconst isValidIcon = icon => icon !== undefined;\nconst TransferList = props => {\n const {\n prefixCls,\n dataSource = [],\n titleText = '',\n checkedKeys,\n disabled,\n showSearch = false,\n style,\n searchPlaceholder,\n notFoundContent,\n selectAll,\n deselectAll,\n selectCurrent,\n selectInvert,\n removeAll,\n removeCurrent,\n showSelectAll = true,\n showRemove,\n pagination,\n direction,\n itemsUnit,\n itemUnit,\n selectAllLabel,\n selectionsIcon,\n footer,\n renderList,\n onItemSelectAll,\n onItemRemove,\n handleFilter,\n handleClear,\n filterOption,\n render = defaultRender\n } = props;\n const [filterValue, setFilterValue] = useState('');\n const listBodyRef = useRef({});\n const internalHandleFilter = e => {\n setFilterValue(e.target.value);\n handleFilter(e);\n };\n const internalHandleClear = () => {\n setFilterValue('');\n handleClear();\n };\n const matchFilter = (text, item) => {\n if (filterOption) {\n return filterOption(filterValue, item, direction);\n }\n return text.includes(filterValue);\n };\n const renderListBody = listProps => {\n let bodyContent = renderList ? renderList(Object.assign(Object.assign({}, listProps), {\n onItemSelect: (key, check) => listProps.onItemSelect(key, check)\n })) : null;\n const customize = !!bodyContent;\n if (!customize) {\n // @ts-ignore\n bodyContent = /*#__PURE__*/React.createElement(DefaultListBody, Object.assign({\n ref: listBodyRef\n }, listProps));\n }\n return {\n customize,\n bodyContent\n };\n };\n const renderItem = item => {\n const renderResult = render(item);\n const isRenderResultPlain = isRenderResultPlainObject(renderResult);\n return {\n item,\n renderedEl: isRenderResultPlain ? renderResult.label : renderResult,\n renderedText: isRenderResultPlain ? renderResult.value : renderResult\n };\n };\n const notFoundContentEle = useMemo(() => Array.isArray(notFoundContent) ? notFoundContent[direction === 'left' ? 0 : 1] : notFoundContent, [notFoundContent, direction]);\n const [filteredItems, filteredRenderItems] = useMemo(() => {\n const filterItems = [];\n const filterRenderItems = [];\n dataSource.forEach(item => {\n const renderedItem = renderItem(item);\n if (filterValue && !matchFilter(renderedItem.renderedText, item)) {\n return;\n }\n filterItems.push(item);\n filterRenderItems.push(renderedItem);\n });\n return [filterItems, filterRenderItems];\n }, [dataSource, filterValue]);\n const checkStatus = useMemo(() => {\n if (checkedKeys.length === 0) {\n return 'none';\n }\n const checkedKeysMap = groupKeysMap(checkedKeys);\n if (filteredItems.every(item => checkedKeysMap.has(item.key) || !!item.disabled)) {\n return 'all';\n }\n return 'part';\n }, [checkedKeys, filteredItems]);\n const listBody = useMemo(() => {\n const search = showSearch ? ( /*#__PURE__*/React.createElement(\"div\", {\n className: `${prefixCls}-body-search-wrapper`\n }, /*#__PURE__*/React.createElement(Search, {\n prefixCls: `${prefixCls}-search`,\n onChange: internalHandleFilter,\n handleCle