@yorkjs/hive-ui 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorkjs/hive-ui",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -6,12 +6,10 @@ import { formatClassNames } from '../../util/function'
6
6
  import styles from './index.module.styl'
7
7
 
8
8
  export interface TableColumn<T extends object> {
9
- /** 列唯一标识 */
10
- key: string
9
+ /** 对应数据字段;同时作为列标识 */
10
+ dataIndex: keyof T
11
11
  /** 列标题,支持自定义节点 */
12
12
  title: React.ReactNode
13
- /** 对应数据字段;不传时仅通过 render 展示 */
14
- dataIndex?: keyof T
15
13
  /** 列宽度;数字按 PX 处理,字符串原样使用 */
16
14
  width?: number | string
17
15
  /**
@@ -20,7 +18,7 @@ export interface TableColumn<T extends object> {
20
18
  * @param record 当前行数据
21
19
  * @param index 当前行索引
22
20
  */
23
- render?: (value: T[keyof T] | undefined, record: T, index: number) => React.ReactNode
21
+ render?: (value: T[keyof T], record: T, index: number) => React.ReactNode
24
22
  }
25
23
 
26
24
  export interface TableProps<T extends object> {
@@ -118,7 +116,7 @@ function Table<T extends object>(props: TableProps<T>) {
118
116
  {
119
117
  columns.map(column => (
120
118
  <View
121
- key={column.key}
119
+ key={String(column.dataIndex)}
122
120
  className={styles['table-cell']}
123
121
  style={getCellStyle(column.width)}
124
122
  >
@@ -140,16 +138,14 @@ function Table<T extends object>(props: TableProps<T>) {
140
138
  >
141
139
  {
142
140
  columns.map(column => {
143
- const value = column.dataIndex != null
144
- ? record[column.dataIndex]
145
- : undefined
141
+ const value = record[column.dataIndex]
146
142
  const content = column.render
147
143
  ? column.render(value, record, rowIndex)
148
144
  : value
149
145
 
150
146
  return (
151
147
  <View
152
- key={`${currentRowKey}-${column.key}`}
148
+ key={`${currentRowKey}-${String(column.dataIndex)}`}
153
149
  className={styles['table-cell']}
154
150
  style={getCellStyle(column.width)}
155
151
  >