Skip to content

Commit

Permalink
feat: make datagridplugin and component support additional config
Browse files Browse the repository at this point in the history
  • Loading branch information
awesthouse committed Jan 10, 2024
1 parent 5a09fd8 commit 14cd2ce
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 345 deletions.
108 changes: 0 additions & 108 deletions packages/dm-core-plugins/src/data-grid/ColumnHeader/ColumnHeader.tsx

This file was deleted.

15 changes: 10 additions & 5 deletions packages/dm-core-plugins/src/data-grid/DataCell/DataCell.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React, { ChangeEvent } from 'react'
import * as Styled from '../styles'
import { Checkbox } from '@equinor/eds-core-react'
import { DataGridConfig } from '../types'

type DataCellProps = {
selected: boolean
rowIndex: number
attributeType: string
cellIndex?: number
value: string | number | boolean
config: DataGridConfig
data: any[]
rowIndex: number
selected: boolean
setData: (data: any[]) => void
attributeType: string
value: string | number | boolean
}

export function DataCell(props: DataCellProps) {
const { attributeType, data, setData, rowIndex, value, cellIndex } = props
const { attributeType, data, setData, rowIndex, value, cellIndex, config } =
props

function parseValue(event: ChangeEvent<HTMLInputElement>) {
const { value, checked } = event.target
Expand Down Expand Up @@ -47,12 +50,14 @@ export function DataCell(props: DataCellProps) {
<Checkbox
checked={value as boolean}
onChange={(event) => updateValue(event, rowIndex, cellIndex)}
readOnly={!config.editable}
/>
) : (
<Styled.Input
value={value as string}
onChange={(event) => updateValue(event, rowIndex, cellIndex)}
attributeType={attributeType}
readOnly={!config.editable}
/>
)}
</Styled.Cell>
Expand Down
Loading

0 comments on commit 14cd2ce

Please sign in to comment.