1 line
6.1 KiB
JSON
1 line
6.1 KiB
JSON
|
{"ast":null,"code":"import { useMemo } from 'react';\nimport { devUseWarning } from '../../_util/warning';\nfunction getFilledItem(rowItem, rowRestCol, span) {\n let clone = rowItem;\n let exceed = false;\n if (span === undefined || span > rowRestCol) {\n clone = Object.assign(Object.assign({}, rowItem), {\n span: rowRestCol\n });\n exceed = span !== undefined;\n }\n return [clone, exceed];\n}\n// Calculate the sum of span in a row\nfunction getCalcRows(rowItems, mergedColumn) {\n const rows = [];\n let tmpRow = [];\n let rowRestCol = mergedColumn;\n let exceed = false;\n rowItems.filter(n => n).forEach((rowItem, index) => {\n const span = rowItem === null || rowItem === void 0 ? void 0 : rowItem.span;\n const mergedSpan = span || 1;\n // Additional handle last one\n if (index === rowItems.length - 1) {\n const [item, itemExceed] = getFilledItem(rowItem, rowRestCol, span);\n exceed = exceed || itemExceed;\n tmpRow.push(item);\n rows.push(tmpRow);\n return;\n }\n if (mergedSpan < rowRestCol) {\n rowRestCol -= mergedSpan;\n tmpRow.push(rowItem);\n } else {\n const [item, itemExceed] = getFilledItem(rowItem, rowRestCol, mergedSpan);\n exceed = exceed || itemExceed;\n tmpRow.push(item);\n rows.push(tmpRow);\n rowRestCol = mergedColumn;\n tmpRow = [];\n }\n });\n return [rows, exceed];\n}\nconst useRow = (mergedColumn, items) => {\n const [rows, exceed] = useMemo(() => getCalcRows(items, mergedColumn), [items, mergedColumn]);\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Descriptions');\n process.env.NODE_ENV !== \"production\" ? warning(!exceed, 'usage', 'Sum of column `span` in a line not match `column` of Descriptions.') : void 0;\n }\n return rows;\n};\nexport default useRow;","map":{"version":3,"names":["useMemo","devUseWarning","getFilledItem","rowItem","rowRestCol","span","clone","exceed","undefined","Object","assign","getCalcRows","rowItems","mergedColumn","rows","tmpRow","filter","n","forEach","index","mergedSpan","length","item","itemExceed","push","useRow","items","process","env","NODE_ENV","warning"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/descriptions/hooks/useRow.js"],"sourcesContent":["import { useMemo } from 'react';\nimport { devUseWarning } from '../../_util/warning';\nfunction getFilledItem(rowItem, rowRestCol, span) {\n let clone = rowItem;\n let exceed = false;\n if (span === undefined || span > rowRestCol) {\n clone = Object.assign(Object.assign({}, rowItem), {\n span: rowRestCol\n });\n exceed = span !== undefined;\n }\n return [clone, exceed];\n}\n// Calculate the sum of span in a row\nfunction getCalcRows(rowItems, mergedColumn) {\n const rows = [];\n let tmpRow = [];\n let rowRestCol = mergedColumn;\n let exceed = false;\n rowItems.filter(n => n).forEach((rowItem, index) => {\n const span = rowItem === null || rowItem === void 0 ? void 0 : rowItem.span;\n const mergedSpan = span || 1;\n // Additional handle last one\n if (index === rowItems.length - 1) {\n const [item, itemExceed] = getFilledItem(rowItem, rowRestCol, span);\n exceed = exceed || itemExceed;\n tmpRow.push(item);\n rows.push(tmpRow);\n return;\n }\n if (mergedSpan < rowRestCol) {\n rowRestCol -= mergedSpan;\n tmpRow.push(rowItem);\n } else {\n const [item, itemExceed] = getFilledItem(rowItem, rowRestCol, mergedSpan);\n exceed = exceed || itemExceed;\n tmpRow.push(item);\n rows.push(tmpRow);\n rowRestCol = mergedColumn;\n tmpRow = [];\n }\n });\n return [rows, exceed];\n}\nconst useRow = (mergedColumn, items) => {\n const [rows, exceed] = useMemo(() => getCalcRows(items, mergedColumn), [items, mergedColumn]);\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Descriptions');\n process.env.NODE_ENV !== \"production\" ? warning(!exceed, 'usage', 'Sum of column `span` in a line not match `col
|