Components

BasePropertyComponent

<BasePropertyComponent />

Type Definitions

object

# BasePropertyProps

Props which are passed to all your custom property components

Example

// AdminJSOptions
const AdminJS = require('adminjs')
const ResourceModel = require('./resource-model')
const AdminJSOptions = {
  resources: [{
    resource: ResourceModel
    options: {
      properties: {
        name: {
          components: {
            show: AdminJS.bundle('./my-react-component'),
          },
        },
      },
    },
  }],
}

// my-react-component.tsx
const MyReactComponent = (props: BasePropertyProps) => {
  const { record, property } = props
  const value = record.params[property.path] === 'foo' ? 'bar' : 'zoe'
  return (
    <PropertyInShow property={property}>
      {value}
    </PropertyInShow>
  )
}

Properties:
Name Type Attributes Description
property PropertyJSON

Property JSON representation

resource ResourceJSON

Resource JSON representation

record RecordJSON <optional>

Record JSON representation. Null for filter

onChange OnPropertyChange <optional>

callback function which should indicate change of the field value. You can use it, when overriding edit properties.

filter any <optional>

Filter object taken from the query params. It is used on the filter components.

where PropertyPlace

Where given property should be rendered. Either of 'show' | 'list' | 'edit' | 'filter'.

View Source adminjs/src/frontend/components/property-type/base-property-props.ts, line 8

object

# EditPropertyProps

Props which are passed to all your custom property components in show
Properties:
Name Type Description
onChange OnPropertyChange

callback function which should indicate change of the field value.

record RecordJSON

Record JSON representation. Null for filter

View Source adminjs/src/frontend/components/property-type/base-property-props.ts, line 69

object

# FilterPropertyProps

Props which are passed to all your custom property components in filter
Properties:
Name Type Description
filter any

Filter object taken from the query params. It is used on the filter components

onChange OnPropertyChange

callback function which should indicate change of the filter value.

record undefined

View Source adminjs/src/frontend/components/property-type/base-property-props.ts, line 58

# OnPropertyChange(propertyOrRecord, valueopt, selectedRecordopt)

Parameters:
Name Type Attributes Description
propertyOrRecord RecordJSON | string

property.path or updated RecordJSON object

value any <optional>

when propertyOrRecord is a property.path, here should be an updated value.

selectedRecord RecordJSON <optional>

In case of "reference" fields (with select), when they change they pass selected record object., This is mostly for an internal use - you probably wont have to use that.

View Source adminjs/src/frontend/components/property-type/base-property-props.ts, line 91

object

# ShowPropertyProps

Props which are passed to all your custom property components in show
Properties:
Name Type Description
property PropertyJSON

Property JSON representation

resource ResourceJSON

Resource JSON representation

record RecordJSON

Record JSON representation. Null for filter

View Source adminjs/src/frontend/components/property-type/base-property-props.ts, line 80