1- import { GridCell , GridPosition , LabwareKey } from './types' ;
1+ import { GridCell , GridPosition , LabwareKey , TecanLabwares } from './types' ;
22
33// Column constants
44export const COLUMN_LEFT_SPANNING = 0 ; // Left column that spans all three rows (mmPlate)
@@ -23,73 +23,73 @@ export const LABWARE_METADATA: Record<LabwareKey, LabwareMetadata> = {
2323 label : 'MM Plate' ,
2424 shortLabel : 'MM' ,
2525 color : LABWARE_COLOR_MM_PLATE ,
26- gridPosition : { row : 0 , column : 0 , alignment : 'center' } ,
26+ gridPosition : { row : 0 , column : 0 } ,
2727 } ,
2828 aPlate : {
2929 label : 'A Plate (200µl #1)' ,
3030 shortLabel : 'A' ,
3131 color : LABWARE_COLOR_STANDARD_PLATE ,
32- gridPosition : { row : 0 , column : 1 , alignment : 'start' } ,
32+ gridPosition : { row : 0 , column : 1 } ,
3333 } ,
3434 nemoDilution : {
3535 label : 'NeMo Dilution' ,
3636 shortLabel : 'NeMoDilution' ,
3737 color : LABWARE_COLOR_STANDARD_PLATE ,
38- gridPosition : { row : 0 , column : 2 , alignment : 'start' } ,
38+ gridPosition : { row : 0 , column : 2 } ,
3939 } ,
4040 destPcr : {
4141 label : 'Dest PCR' ,
4242 shortLabel : 'DestPCR' ,
4343 color : LABWARE_COLOR_STANDARD_PLATE ,
44- gridPosition : { row : 0 , column : 3 , alignment : 'start' } ,
44+ gridPosition : { row : 0 , column : 3 } ,
4545 } ,
4646 destPcr1 : {
4747 label : 'Dest PCR 1' ,
4848 shortLabel : 'DestPCR1' ,
4949 color : LABWARE_COLOR_STANDARD_PLATE ,
50- gridPosition : { row : 0 , column : COLUMN_RIGHT_SPANNING , alignment : 'start' } ,
50+ gridPosition : { row : 0 , column : COLUMN_RIGHT_SPANNING } ,
5151 } ,
5252 destPcr2 : {
5353 label : 'Dest PCR 2' ,
5454 shortLabel : 'DestPCR2' ,
5555 color : LABWARE_COLOR_STANDARD_PLATE ,
56- gridPosition : { row : 0 , column : COLUMN_RIGHT_SPANNING , alignment : 'start' } ,
56+ gridPosition : { row : 0 , column : COLUMN_RIGHT_SPANNING } ,
5757 } ,
5858 bPlate : {
5959 label : 'B Plate (200µl #2)' ,
6060 shortLabel : 'B' ,
6161 color : LABWARE_COLOR_STANDARD_PLATE ,
62- gridPosition : { row : 1 , column : 1 , alignment : 'center' } ,
62+ gridPosition : { row : 1 , column : 1 } ,
6363 } ,
6464 nemoDestPcr2 : {
6565 label : 'NeMo Dest PCR 2' ,
6666 shortLabel : 'DestPCR2' ,
6767 color : LABWARE_COLOR_STANDARD_PLATE ,
68- gridPosition : { row : 1 , column : 2 , alignment : 'center' } ,
68+ gridPosition : { row : 1 , column : 2 } ,
6969 } ,
7070 destLc : {
7171 label : 'Dest LC' ,
7272 shortLabel : 'DestLC' ,
7373 color : LABWARE_COLOR_STANDARD_PLATE ,
74- gridPosition : { row : 1 , column : 3 , alignment : 'center' } ,
74+ gridPosition : { row : 1 , column : 3 } ,
7575 } ,
7676 nemoWater : {
7777 label : 'NeMo Water' ,
7878 shortLabel : 'NeMoWasser' ,
7979 color : LABWARE_COLOR_STANDARD_PLATE ,
80- gridPosition : { row : 2 , column : 1 , alignment : 'end' } ,
80+ gridPosition : { row : 2 , column : 1 } ,
8181 } ,
8282 nemoDestTaqMan : {
8383 label : 'Dest TaqMan' ,
8484 shortLabel : 'Dest-TaqMan' ,
8585 color : LABWARE_COLOR_TAQMAN_DARK ,
86- gridPosition : { row : 2 , column : 2 , alignment : 'end' } ,
86+ gridPosition : { row : 2 , column : 2 } ,
8787 } ,
8888 fluidX : {
8989 label : 'FluidX' ,
9090 shortLabel : 'FluidX' ,
9191 color : LABWARE_COLOR_FLUIDX ,
92- gridPosition : { row : 2 , column : 3 , alignment : 'end' } ,
92+ gridPosition : { row : 2 , column : 3 } ,
9393 } ,
9494} ;
9595
@@ -112,3 +112,47 @@ export function isLeftColumn(key: LabwareKey) {
112112export function isRightColumn ( key : LabwareKey ) {
113113 return LABWARE_METADATA [ key ] . gridPosition . column === COLUMN_RIGHT_SPANNING ;
114114}
115+
116+ /**
117+ * Returns a map of column numbers to arrays of filled labware keys.
118+ * Used to determine which columns have content for dynamic grid sizing.
119+ */
120+ export function getFilledLabwaresByColumn (
121+ labwares : TecanLabwares ,
122+ ) : Record < number , Array < LabwareKey > > {
123+ const filledByColumn : Record < number , Array < LabwareKey > > = { } ;
124+
125+ ( Object . keys ( LABWARE_METADATA ) as Array < LabwareKey > ) . forEach ( ( key ) => {
126+ if ( labwares [ key ] ?. content ) {
127+ const { column } = LABWARE_METADATA [ key ] . gridPosition ;
128+ if ( ! filledByColumn [ column ] ) {
129+ filledByColumn [ column ] = [ ] ;
130+ }
131+ filledByColumn [ column ] ! . push ( key ) ;
132+ }
133+ } ) ;
134+
135+ return filledByColumn ;
136+ }
137+
138+ /**
139+ * Returns a map of row numbers to arrays of filled labware keys.
140+ * Used to determine which rows have content for dynamic grid sizing.
141+ */
142+ export function getFilledLabwaresByRow (
143+ labwares : TecanLabwares ,
144+ ) : Record < number , Array < LabwareKey > > {
145+ const filledByRow : Record < number , Array < LabwareKey > > = { } ;
146+
147+ ( Object . keys ( LABWARE_METADATA ) as Array < LabwareKey > ) . forEach ( ( key ) => {
148+ if ( labwares [ key ] ?. content ) {
149+ const { row } = LABWARE_METADATA [ key ] . gridPosition ;
150+ if ( ! filledByRow [ row ] ) {
151+ filledByRow [ row ] = [ ] ;
152+ }
153+ filledByRow [ row ] ! . push ( key ) ;
154+ }
155+ } ) ;
156+
157+ return filledByRow ;
158+ }
0 commit comments