PromoCursed/node_modules/.cache/babel-loader/5be7480059a73c30f152ea6ec3c28eea5729a7c62c89d07bdfe3b6f75d5c243f.json

1 line
66 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport { useCallback, useMemo } from 'react';\nimport DownOutlined from \"@ant-design/icons/es/icons/DownOutlined\";\nimport classNames from 'classnames';\nimport { INTERNAL_COL_DEFINE } from 'rc-table';\nimport { arrAdd, arrDel } from \"rc-tree/es/util\";\nimport { conductCheck } from \"rc-tree/es/utils/conductUtil\";\nimport { convertDataToEntities } from \"rc-tree/es/utils/treeUtil\";\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport useMultipleSelect from '../../_util/hooks/useMultipleSelect';\nimport { devUseWarning } from '../../_util/warning';\nimport Checkbox from '../../checkbox';\nimport Dropdown from '../../dropdown';\nimport Radio from '../../radio';\n// TODO: warning if use ajax!!!\nexport const SELECTION_COLUMN = {};\nexport const SELECTION_ALL = 'SELECT_ALL';\nexport const SELECTION_INVERT = 'SELECT_INVERT';\nexport const SELECTION_NONE = 'SELECT_NONE';\nconst EMPTY_LIST = [];\nconst flattenData = (childrenColumnName, data) => {\n let list = [];\n (data || []).forEach(record => {\n list.push(record);\n if (record && typeof record === 'object' && childrenColumnName in record) {\n list = [].concat(_toConsumableArray(list), _toConsumableArray(flattenData(childrenColumnName, record[childrenColumnName])));\n }\n });\n return list;\n};\nconst useSelection = (config, rowSelection) => {\n const {\n preserveSelectedRowKeys,\n selectedRowKeys,\n defaultSelectedRowKeys,\n getCheckboxProps,\n onChange: onSelectionChange,\n onSelect,\n onSelectAll,\n onSelectInvert,\n onSelectNone,\n onSelectMultiple,\n columnWidth: selectionColWidth,\n type: selectionType,\n selections,\n fixed,\n renderCell: customizeRenderCell,\n hideSelectAll,\n checkStrictly = true\n } = rowSelection || {};\n const {\n prefixCls,\n data,\n pageData,\n getRecordByKey,\n getRowKey,\n expandType,\n childrenColumnName,\n locale: tableLocale,\n getPopupContainer\n } = config;\n const warning = devUseWarning('Table');\n // ========================= MultipleSelect =========================\n const [multipleSelect, updatePrevSelectedIndex] = useMultipleSelect(item => item);\n // ========================= Keys =========================\n const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(selectedRowKeys || defaultSelectedRowKeys || EMPTY_LIST, {\n value: selectedRowKeys\n });\n // ======================== Caches ========================\n const preserveRecordsRef = React.useRef(new Map());\n const updatePreserveRecordsCache = useCallback(keys => {\n if (preserveSelectedRowKeys) {\n const newCache = new Map();\n // Keep key if mark as preserveSelectedRowKeys\n keys.forEach(key => {\n let record = getRecordByKey(key);\n if (!record && preserveRecordsRef.current.has(key)) {\n record = preserveRecordsRef.current.get(key);\n }\n newCache.set(key, record);\n });\n // Refresh to new cache\n preserveRecordsRef.current = newCache;\n }\n }, [getRecordByKey, preserveSelectedRowKeys]);\n // Update cache with selectedKeys\n React.useEffect(() => {\n updatePreserveRecordsCache(mergedSelectedKeys);\n }, [mergedSelectedKeys]);\n const {\n keyEntities\n } = useMemo(() => {\n if (checkStrictly) {\n return {\n keyEntities: null\n };\n }\n let convertData = data;\n if (preserveSelectedRowKeys) {\n const keysSet = new Set(data.map((record, index) => getRowKey(record, index)));\n // remove preserveRecords that duplicate data\n const preserveRecords = Array.from(preserveRecordsRef.current).reduce((total, _ref) => {\n let [key, value] = _ref;\n return keysSet.has(key) ? total : total.concat(value);\n }, []);\n convertData = [].concat(_toConsumableArray(convertData), _toConsumableArray(preserveRecords));\n }\n return convert