{"version":3,"file":"utils.js","sources":["../../../../../../packages/components/table-v2/src/utils.ts"],"sourcesContent":["import { h, isVNode } from 'vue'\nimport { addUnit, isArray, isFunction } from '@element-plus/utils'\n\nimport type { CSSProperties, Component, Slot } from 'vue'\n\nconst sumReducer = (sum: number, num: number) => sum + num\n\nexport const sum = (listLike: number | number[]) => {\n return isArray(listLike) ? listLike.reduce(sumReducer, 0) : listLike\n}\n\nexport const tryCall = (\n fLike: T,\n params: T extends (...args: infer K) => unknown ? K : any,\n defaultRet = {}\n) => {\n return isFunction(fLike) ? fLike(params) : fLike ?? defaultRet\n}\n\nexport const enforceUnit = (style: CSSProperties) => {\n ;(['width', 'maxWidth', 'minWidth', 'height'] as const).forEach((key) => {\n style[key] = addUnit(style[key])\n })\n\n return style\n}\n\nexport const componentToSlot = (\n ComponentLike: JSX.Element | ((props: T) => Component) | undefined\n) =>\n isVNode(ComponentLike)\n ? (props: T) => h(ComponentLike, props)\n : (ComponentLike as Slot)\n"],"names":["isArray","isFunction","style","addUnit","isVNode","h"],"mappings":";;;;;;;;;AAEA,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,CAAC;AACjC,MAAC,GAAG,GAAG,CAAC,QAAQ,KAAK;AACjC,EAAE,OAAOA,cAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;AACvE,EAAE;AACU,MAAC,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,GAAG,EAAE,KAAK;AAC3D,EAAE,OAAOC,iBAAU,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,UAAU,CAAC;AAChF,EAAE;AACU,MAAC,WAAW,GAAG,CAACC,OAAK,KAAK;AACtC,EAAE,CAAC;AACH,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK;AAC/D,IAAIA,OAAK,CAAC,GAAG,CAAC,GAAGC,aAAO,CAACD,OAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,GAAG,CAAC,CAAC;AACL,EAAE,OAAOA,OAAK,CAAC;AACf,EAAE;AACU,MAAC,eAAe,GAAG,CAAC,aAAa,KAAKE,WAAO,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,KAAKC,KAAC,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG;;;;;;;"}