{"version":3,"file":"BodyRow.cjs","sources":["../../../../../../../packages/vue-components/vc-table/src/Body/BodyRow.tsx"],"sourcesContent":["import type { MouseEventHandler } from '@antdv/types';\nimport type { CustomizeComponent, GetComponentProps, GetRowKey, Key } from '../interface';\nimport { classNames } from '@antdv/utils';\nimport { computed, defineComponent, shallowRef, watchEffect } from 'vue';\nimport Cell from '../Cell';\nimport { useInjectBody } from '../context/BodyContext';\nimport { useInjectTable } from '../context/TableContext';\nimport { getColumnsKey } from '../utils/valueUtil';\nimport ExpandedRow from './ExpandedRow';\n\nexport interface BodyRowProps<RecordType> {\n  record: RecordType;\n  index: number;\n  renderIndex: number;\n  recordKey: Key;\n  expandedKeys: Set<Key>;\n  rowComponent: CustomizeComponent;\n  cellComponent: CustomizeComponent;\n  customRow: GetComponentProps<RecordType>;\n  rowExpandable: (record: RecordType) => boolean;\n  indent?: number;\n  rowKey: Key;\n  getRowKey: GetRowKey<RecordType>;\n  childrenColumnName: string;\n}\n\nexport default defineComponent<BodyRowProps<unknown>>({\n  name: 'BodyRow',\n  inheritAttrs: false,\n  props: [\n    'record',\n    'index',\n    'renderIndex',\n    'recordKey',\n    'expandedKeys',\n    'rowComponent',\n    'cellComponent',\n    'customRow',\n    'rowExpandable',\n    'indent',\n    'rowKey',\n    'getRowKey',\n    'childrenColumnName',\n  ] as any,\n  setup(props, { attrs }) {\n    const tableContext = useInjectTable();\n    const bodyContext = useInjectBody();\n    const expandRended = shallowRef(false);\n\n    const expanded = computed(() => props.expandedKeys && props.expandedKeys.has(props.recordKey));\n\n    watchEffect(() => {\n      if (expanded.value)\n        expandRended.value = true;\n    });\n\n    const rowSupportExpand = computed(\n      () =>\n        bodyContext.expandableType === 'row'\n        && (!props.rowExpandable || props.rowExpandable(props.record)),\n    );\n    // Only when row is not expandable and `children` exist in record\n    const nestExpandable = computed(() => bodyContext.expandableType === 'nest');\n    const hasNestChildren = computed(\n      () => props.childrenColumnName && props.record && props.record[props.childrenColumnName],\n    );\n    const mergedExpandable = computed(() => rowSupportExpand.value || nestExpandable.value);\n\n    const onInternalTriggerExpand = (record, event) => {\n      bodyContext.onTriggerExpand(record, event);\n    };\n\n    // =========================== onRow ===========================\n    const additionalProps = computed<Record<string, any>>(\n      () => props.customRow?.(props.record, props.index) || {},\n    );\n\n    const onClick: MouseEventHandler = (event, ...args) => {\n      if (bodyContext.expandRowByClick && mergedExpandable.value)\n        onInternalTriggerExpand(props.record, event);\n\n      additionalProps.value?.onClick?.(event, ...args);\n    };\n\n    const computeRowClassName = computed(() => {\n      const { record, index, indent } = props;\n      const { rowClassName } = bodyContext;\n      if (typeof rowClassName === 'string')\n        return rowClassName;\n      else if (typeof rowClassName === 'function')\n        return rowClassName(record, index, indent);\n\n      return '';\n    });\n\n    const columnsKey = computed(() => getColumnsKey(bodyContext.flattenColumns));\n\n    return () => {\n      const { class: className, style } = attrs as any;\n      const {\n        record,\n        index,\n        rowKey,\n        indent = 0,\n        rowComponent: RowComponent,\n        cellComponent,\n      } = props;\n      const { prefixCls, fixedInfoList, transformCellText } = tableContext;\n      const {\n        flattenColumns,\n        expandedRowClassName,\n        indentSize,\n        expandIcon,\n        expandedRowRender,\n        expandIconColumnIndex,\n      } = bodyContext;\n      const baseRowNode = (\n        <RowComponent\n          {...additionalProps.value}\n          data-row-key={rowKey}\n          class={classNames(\n            className,\n            `${prefixCls}-row`,\n            `${prefixCls}-row-level-${indent}`,\n            computeRowClassName.value,\n            additionalProps.value.class,\n          )}\n          style={[style, additionalProps.value.style]}\n          onClick={onClick}\n        >\n          {flattenColumns.map((column, colIndex) => {\n            const { customRender, dataIndex, className: columnClassName } = column;\n\n            const key = columnsKey[colIndex];\n            const fixedInfo = fixedInfoList[colIndex];\n\n            let additionalCellProps;\n            if (column.customCell)\n              additionalCellProps = column.customCell(record, index, column);\n\n            // not use slot to fix https://github.com/vueComponent/ant-design-vue/issues/5295\n            const appendNode\n              = colIndex === (expandIconColumnIndex || 0) && nestExpandable.value\n                ? (\n                    <>\n                      <span\n                        style={{ paddingLeft: `${indentSize * indent}px` }}\n                        class={`${prefixCls}-row-indent indent-level-${indent}`}\n                      />\n                      {expandIcon({\n                        prefixCls,\n                        expanded: expanded.value,\n                        expandable: hasNestChildren.value,\n                        record,\n                        onExpand: onInternalTriggerExpand,\n                      })}\n                    </>\n                  )\n                : null;\n            return (\n              <Cell\n                cellType=\"body\"\n                class={columnClassName}\n                ellipsis={column.ellipsis}\n                align={column.align}\n                component={cellComponent}\n                prefixCls={prefixCls}\n                key={key}\n                record={record}\n                index={index}\n                renderIndex={props.renderIndex}\n                dataIndex={dataIndex}\n                customRender={customRender}\n                {...fixedInfo}\n                additionalProps={additionalCellProps}\n                column={column}\n                transformCellText={transformCellText}\n                appendNode={appendNode}\n              />\n            );\n          })}\n        </RowComponent>\n      );\n\n      // ======================== Expand Row =========================\n      let expandRowNode;\n      if (rowSupportExpand.value && (expandRended.value || expanded.value)) {\n        const expandContent = expandedRowRender({\n          record,\n          index,\n          indent: indent + 1,\n          expanded: expanded.value,\n        });\n        const computedExpandedRowClassName\n          = expandedRowClassName && expandedRowClassName(record, index, indent);\n        expandRowNode = (\n          <ExpandedRow\n            expanded={expanded.value}\n            class={classNames(\n              `${prefixCls}-expanded-row`,\n              `${prefixCls}-expanded-row-level-${indent + 1}`,\n              computedExpandedRowClassName,\n            )}\n            prefixCls={prefixCls}\n            component={RowComponent}\n            cellComponent={cellComponent}\n            colSpan={flattenColumns.length}\n            isEmpty={false}\n          >\n            {expandContent}\n          </ExpandedRow>\n        );\n      }\n\n      return (\n        <>\n          {baseRowNode}\n          {expandRowNode}\n        </>\n      );\n    };\n  },\n});\n"],"names":["defineComponent","name","inheritAttrs","props","setup","attrs","tableContext","useInjectTable","bodyContext","useInjectBody","expandRended","shallowRef","expanded","computed","expandedKeys","has","recordKey","watchEffect","value","rowSupportExpand","expandableType","rowExpandable","record","nestExpandable","hasNestChildren","childrenColumnName","mergedExpandable","onInternalTriggerExpand","event","onTriggerExpand","additionalProps","customRow","index","onClick","args","expandRowByClick","computeRowClassName","indent","rowClassName","columnsKey","getColumnsKey","flattenColumns","class","className","style","rowKey","rowComponent","RowComponent","cellComponent","prefixCls","fixedInfoList","transformCellText","expandedRowClassName","indentSize","expandIcon","expandedRowRender","expandIconColumnIndex","baseRowNode","_createVNode","classNames","default","map","column","colIndex","customRender","dataIndex","columnClassName","key","fixedInfo","additionalCellProps","customCell","appendNode","_Fragment","paddingLeft","expandable","onExpand","Cell","ellipsis","align","renderIndex","expandRowNode","expandContent","computedExpandedRowClassName","ExpandedRow","length"],"mappings":";;;;;;;;;;;;;AA0BA,8BAAsDA,mBAAA,CAAA;AAAA,EACpDC,IAAM,EAAA,SAAA;AAAA,EACNC,YAAc,EAAA,KAAA;AAAA,EACdC,KAAO,EAAA,CACL,QACA,EAAA,OAAA,EACA,eACA,WACA,EAAA,cAAA,EACA,cACA,EAAA,eAAA,EACA,WACA,EAAA,eAAA,EACA,QACA,EAAA,QAAA,EACA,aACA,oBAAoB,CAAA;AAAA,EAEtBC,MAAMD,KAAO,EAAA;AAAA,IAAEE,KAAAA;AAAAA,GAAS,EAAA;AACtB,IAAA,MAAMC,eAAeC,2BAAe,EAAA,CAAA;AACpC,IAAA,MAAMC,cAAcC,yBAAc,EAAA,CAAA;AAClC,IAAMC,MAAAA,YAAAA,GAAeC,eAAW,KAAK,CAAA,CAAA;AAErC,IAAMC,MAAAA,QAAAA,GAAWC,YAAS,CAAA,MAAMV,KAAMW,CAAAA,YAAAA,IAAgBX,MAAMW,YAAaC,CAAAA,GAAAA,CAAIZ,KAAMa,CAAAA,SAAS,CAAC,CAAA,CAAA;AAE7FC,IAAAA,eAAAA,CAAY,MAAM;AAChB,MAAA,IAAIL,QAASM,CAAAA,KAAAA;AACXR,QAAAA,YAAAA,CAAaQ,KAAQ,GAAA,IAAA,CAAA;AAAA,KACxB,CAAA,CAAA;AAED,IAAA,MAAMC,gBAAmBN,GAAAA,YAAAA,CACvB,MACEL,WAAAA,CAAYY,cAAmB,KAA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