Skip to content

Commit

Permalink
fix(array-table): give toFieldProps an options
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Apr 25, 2021
1 parent 84c28f2 commit edf3cab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/antd/src/array-table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useState, useRef } from 'react'
import React, { Fragment, useState, useRef, useContext } from 'react'
import { Table, Pagination, Space, Select, Badge } from 'antd'
import { PaginationProps } from 'antd/lib/pagination'
import { TableProps, ColumnProps } from 'antd/lib/table'
Expand All @@ -11,6 +11,7 @@ import {
observer,
useFieldSchema,
RecursionField,
SchemaOptionsContext
} from '@formily/react'
import { FormPath, isArr, isBool } from '@formily/shared'
import { Schema } from '@formily/json-schema'
Expand Down Expand Up @@ -60,6 +61,7 @@ const isAdditionComponent = (schema: Schema) => {
const useArrayTableSources = () => {
const arrayField = useField()
const schema = useFieldSchema()
const options = useContext(SchemaOptionsContext)
const parseSources = (schema: Schema): ObservableColumnSource[] => {
if (
isColumnComponent(schema) ||
Expand All @@ -70,7 +72,7 @@ const useArrayTableSources = () => {
return []
const name = schema['x-component-props']?.['dataIndex'] || schema['name']
const field = arrayField.query(arrayField.address.concat(name)).take()
const fieldProps = field?.props || schema.toFieldProps()
const fieldProps = field?.props || schema.toFieldProps(options)
const columnProps =
field?.component?.[1] || schema['x-component-props'] || {}
const display = field?.display || schema['x-display']
Expand Down
6 changes: 4 additions & 2 deletions packages/next/src/array-table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useState, useRef } from 'react'
import React, { Fragment, useState, useRef, useContext } from 'react'
import { Table, Pagination, Select, Badge } from '@alifd/next'
import { PaginationProps } from '@alifd/next/lib/pagination'
import { TableProps, ColumnProps } from '@alifd/next/lib/table'
Expand All @@ -10,6 +10,7 @@ import {
observer,
useFieldSchema,
RecursionField,
SchemaOptionsContext,
} from '@formily/react'
import { FormPath, isArr, isBool } from '@formily/shared'
import { Schema } from '@formily/json-schema'
Expand Down Expand Up @@ -61,6 +62,7 @@ const isAdditionComponent = (schema: Schema) => {
const useArrayTableSources = () => {
const arrayField = useField()
const schema = useFieldSchema()
const options = useContext(SchemaOptionsContext)
const parseSources = (schema: Schema): ObservableColumnSource[] => {
if (
isColumnComponent(schema) ||
Expand All @@ -71,7 +73,7 @@ const useArrayTableSources = () => {
return []
const name = schema['x-component-props']?.['dataIndex'] || schema['name']
const field = arrayField.query(arrayField.address.concat(name)).take()
const fieldProps = field?.props || schema.toFieldProps()
const fieldProps = field?.props || schema.toFieldProps(options)
const columnProps =
field?.component?.[1] || schema['x-component-props'] || {}
const display = field?.display || schema['x-display']
Expand Down

0 comments on commit edf3cab

Please sign in to comment.