feat: export indexValue utils function
This commit is contained in:
parent
34600cc194
commit
cbecbdb8cf
|
@ -7,7 +7,8 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { get } from '@/drip-table/utils';
|
||||
import { indexValue } from '@/drip-table/utils';
|
||||
|
||||
import { DripTableComponentProps, DripTableComponentSchema } from '../component';
|
||||
|
||||
export interface DTCImageSchema extends DripTableComponentSchema {
|
||||
|
@ -31,7 +32,7 @@ export default class DTCImage<RecordType> extends React.PureComponent<DTCImagePr
|
|||
private get value() {
|
||||
const schema = this.props.schema;
|
||||
const dataIndex = schema.dataIndex;
|
||||
return get(this.props.data, dataIndex, '');
|
||||
return indexValue(this.props.data, dataIndex, '');
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { get } from '@/drip-table/utils';
|
||||
import { indexValue } from '@/drip-table/utils';
|
||||
|
||||
import { DripTableComponentProps, DripTableComponentSchema } from '../component';
|
||||
|
||||
export interface DTCTagSchema extends DripTableComponentSchema {
|
||||
|
@ -40,7 +41,7 @@ export default class DTCTag<RecordType> extends React.PureComponent<DTCTagProps<
|
|||
private get value() {
|
||||
const schema = this.props.schema;
|
||||
const dataIndex = schema.dataIndex;
|
||||
return get(this.props.data, dataIndex, '');
|
||||
return indexValue(this.props.data, dataIndex, '');
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @param defaultValue 默认值
|
||||
* @returns 值
|
||||
*/
|
||||
export const get = (data: unknown, indexes: string | string[], defaultValue: unknown = void 0) => {
|
||||
export const indexValue = (data: unknown, indexes: string | string[], defaultValue: unknown = void 0) => {
|
||||
if (typeof data !== 'object' || !data) {
|
||||
return void 0;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { VariableSizeGrid } from 'react-window';
|
||||
import ResizeObserver from 'rc-resize-observer';
|
||||
|
||||
import { indexValue } from '../utils';
|
||||
import { DripTableDriver, DripTableRecordTypeBase } from '../..';
|
||||
|
||||
import styles from './index.module.css';
|
||||
import { get } from '../utils';
|
||||
|
||||
// 根据size来控制行高
|
||||
const rowHeightMap = {
|
||||
|
@ -74,7 +75,7 @@ function VirtualTable<RecordType extends DripTableRecordTypeBase>(props: { drive
|
|||
const renderCell = ({ columnIndex, rowIndex, style }: { columnIndex: number; rowIndex: number; style: React.CSSProperties }) => {
|
||||
const columnItem = mergedColumns[columnIndex];
|
||||
const dataItem = rawData[rowIndex];
|
||||
const value = columnItem.dataIndex ? get(dataItem, columnItem.dataIndex) : dataItem;
|
||||
const value = columnItem.dataIndex ? indexValue(dataItem, columnItem.dataIndex) : dataItem;
|
||||
return (
|
||||
<div className={styles['virtual-table-cell']} style={style}>
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export * from './drip-table-provider';
|
||||
export * from './types';
|
||||
export { indexValue } from './drip-table/utils';
|
||||
export { default as builtInComponents } from './drip-table/components';
|
||||
export type { DripTableComponentProps, DripTableComponentSchema } from './drip-table/components';
|
||||
export type { DripTableProps } from './drip-table';
|
||||
|
|
Loading…
Reference in New Issue