File tree Expand file tree Collapse file tree
DataDictionary/components/Table/components/BasicCell
components/TableCell/components/ChipCell Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { ColumnDef } from "@tanstack/react-table" ;
2+ import { GridTrackSize } from "../config/entities" ;
23
34/**
45 * Model of a value of a metadata class.
@@ -21,7 +22,7 @@ export interface Attribute {
2122/**
2223 * Model of attribute key types; used mostly when building data dictionary column definitions.
2324 */
24- export type AttributeValueTypes = string | boolean ;
25+ export type AttributeValueTypes < TValue = unknown > = TValue ;
2526
2627/**
2728 * Filterable metadata keys.
@@ -76,13 +77,17 @@ export interface DataDictionary {
7677 * Display model of a data dictionary column.
7778 */
7879export interface DataDictionaryColumnDef {
80+ attributeAccessorFnName ?: string ; // Name of accessor function to map to.
81+ attributeCellName ?: string ; // Name of cell renderer component to map to.
7982 attributeDisplayName : string ;
8083 attributeSlotName : string ;
8184 // Adding width here for now; possibly revisit separating column def and UI.
82- width : {
83- max : string ;
84- min : string ;
85- } ;
85+ width :
86+ | Omit < GridTrackSize , "GridTrackMinMax" >
87+ | {
88+ max : string ;
89+ min : string ;
90+ } ;
8691}
8792
8893/**
Original file line number Diff line number Diff line change 11import { Typography } from "@mui/material" ;
2- import React from "react" ;
2+ import { CellContext , RowData } from "@tanstack/react-table" ;
3+ import React , { ReactNode } from "react" ;
34import { TYPOGRAPHY_PROPS } from "../../../../../../styles/common/mui/typography" ;
4- import { BasicCellProps } from "./types" ;
55
6- export const BasicCell = ( { getValue } : BasicCellProps ) : JSX . Element => {
6+ export const BasicCell = < T extends RowData , TValue > ( {
7+ getValue,
8+ } : CellContext < T , TValue > ) : JSX . Element | null => {
9+ const value = getValue ( ) ;
10+ if ( value === undefined || value === null ) return null ;
711 return (
812 < Typography variant = { TYPOGRAPHY_PROPS . VARIANT . INHERIT } >
9- { getValue ( ) }
13+ { value as ReactNode }
1014 </ Typography >
1115 ) ;
1216} ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { RowData } from "@tanstack/react-table" ;
2+
3+ /**
4+ * Type guard to check if a row has a specific key.
5+ * Useful for generic accessor functions.
6+ * @param row - The row to check.
7+ * @param key - The key to check.
8+ * @returns True if the row has the specified key, false otherwise.
9+ */
10+ export function rowHasKey < T extends RowData , K extends PropertyKey , TValue > (
11+ row : T ,
12+ key : K
13+ ) : row is T & Record < K , TValue > {
14+ return row != null && typeof row === "object" && key in row ;
15+ }
Original file line number Diff line number Diff line change 1+ import { Chip } from "@mui/material" ;
2+ import { CellContext , RowData } from "@tanstack/react-table" ;
3+ import React from "react" ;
4+
5+ export const ChipCell = < T extends RowData , TValue > ( {
6+ getValue,
7+ } : CellContext < T , TValue > ) : JSX . Element | null => {
8+ const props = getValue ( ) ;
9+ if ( ! props ) return null ;
10+ return < Chip { ...props } /> ;
11+ } ;
Original file line number Diff line number Diff line change @@ -410,6 +410,14 @@ export const MuiChip = (theme: Theme): Components["MuiChip"] => {
410410 } ,
411411 label : {
412412 ...theme . typography [ TEXT_BODY_SMALL_400 ] ,
413+ variants : [
414+ {
415+ props : { variant : "status" } ,
416+ style : {
417+ ...theme . typography [ TEXT_BODY_SMALL_500 ] ,
418+ } ,
419+ } ,
420+ ] ,
413421 } ,
414422 } ,
415423 variants : [
@@ -489,13 +497,18 @@ export const MuiChip = (theme: Theme): Components["MuiChip"] => {
489497 {
490498 props : { variant : "status" } ,
491499 style : {
492- ...theme . typography [ TEXT_BODY_SMALL_500 ] ,
493500 boxShadow : `0 0 0 2px ${ PALETTE . COMMON_WHITE } ` ,
494501 height : 20 ,
495502 maxWidth : "fit-content" ,
496503 minWidth : 0 ,
497504 } ,
498505 } ,
506+ {
507+ props : { color : "default" , variant : "status" } ,
508+ style : {
509+ color : PALETTE . INK_LIGHT ,
510+ } ,
511+ } ,
499512 ] ,
500513 } ;
501514} ;
You can’t perform that action at this time.
0 commit comments