@tetrascience-npm/tetrascience-react-ui 0.5.0-beta.71.1 → 0.5.0-beta.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"PlateMapEditor.js","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapEditor.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { plateOptionsFromCsvTriage } from \"./csvPlateTriage\";\nimport { PlateMapActionsMenu } from \"./PlateMapActionsMenu\";\nimport { PlateMapPlateSelector } from \"./PlateMapPlateSelector\";\nimport { PlatePaintGrid } from \"./PlatePaintGrid\";\nimport { resolveDimensions, allPositions } from \"./wellGrid\";\nimport { WellManifestTable } from \"./WellManifestTable\";\nimport { WellMetadataForm } from \"./WellMetadataForm\";\n\nimport type { PlateMapActionsMenuProps } from \"./PlateMapActionsMenu\";\nimport type { PlateMapPlateSelectorVariant } from \"./PlateMapPlateSelector\";\nimport type { WellShape } from \"./PlatePaintGrid\";\nimport type {\n PlateFormat,\n PlateMapCsvTriage,\n PlateMapGroupOption,\n PlateMapPlateOption,\n WellColumn,\n WellField,\n WellId,\n WellRecord,\n} from \"./types\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport { Card, CardAction, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport { Separator } from \"@/components/ui/separator\";\nimport { cn } from \"@/lib/utils\";\n\nconst PLATE_WELL_KEY_SEPARATOR = \"::\";\nconst DEFAULT_PLATE_BARCODE_FIELD = \"plateBarcode\";\nconst DEFAULT_PLATE_BARCODE_HEADER = \"Plate Barcode\";\n\nexport function getPlateMapScopedWellId(plateBarcode: string, wellId: WellId): WellId {\n return `${plateBarcode}${PLATE_WELL_KEY_SEPARATOR}${wellId}`;\n}\n\nfunction wellIdFromPlateWellKey(plateId: string, key: WellId): WellId | undefined {\n const prefix = `${plateId}${PLATE_WELL_KEY_SEPARATOR}`;\n return key.startsWith(prefix) ? key.slice(prefix.length) : undefined;\n}\n\nexport interface PlateMapEditorProps<T extends WellRecord = WellRecord> extends Omit<\n PlateMapActionsMenuProps,\n \"hasEntries\" | \"className\"\n> {\n format: PlateFormat;\n rows?: number;\n columns?: number;\n values: Map<WellId, T>;\n onChange: (next: Map<WellId, T>) => void;\n selection: Set<WellId>;\n onSelectionChange: (next: Set<WellId>) => void;\n\n fields: WellField<T>[];\n tableColumns: WellColumn<T>[];\n\n /** Resolves the SVG fill color for a well. */\n colorForWell: (well: T | undefined, wellId: WellId) => string;\n /** Builds an empty record when a well is freshly created. */\n emptyEntry: (wellId: WellId) => T;\n /**\n * Merges the staged form record onto an existing well record on Apply.\n * Defaults to a shallow merge (form keys overwrite existing keys when set).\n */\n mergeOnApply?: (existing: T | undefined, staged: Partial<T>, wellId: WellId) => T;\n /** Filter for the manifest's \"hide empty\" mode. */\n isPopulated?: (row: T) => boolean;\n /** Select field cycled when double-clicking a single well, e.g. role painting. */\n cycleFieldOnWellDoubleClick?: keyof T & string;\n\n /** Optional header title (e.g. plate set name). */\n title?: string;\n /** Optional badges shown in the header next to the title. */\n badges?: React.ReactNode;\n /** Optional banner (e.g. import/error alert) shown above the layout. */\n banner?: React.ReactNode;\n /** Legend block rendered under the form column. */\n legend?: React.ReactNode;\n /** Form helper slot rendered between fields and the action row. */\n formExtras?: React.ReactNode;\n /**\n * Fully replaces the left column. When set, the built-in `WellMetadataForm`\n * is omitted — use this for alternative workflows like a drag-and-drop\n * source palette. The legend slot still renders beneath the replacement.\n */\n formSlot?: React.ReactNode;\n /** Footer actions (e.g. Save, Back). */\n footer?: React.ReactNode;\n /** Title for the plate grid panel. */\n plateTitle?: React.ReactNode;\n /** Optional controls shown next to the built-in actions menu. */\n plateToolbar?: React.ReactNode;\n /** User-provided plates available for this editor. Barcodes are never generated by the editor. */\n plates?: PlateMapPlateOption[];\n activePlateId?: string;\n onPlateChange?: (plateId: string) => void;\n /** Opens the host app's manual barcode entry flow for creating a plate. */\n onAddPlate?: () => void;\n /** Removes a plate (typically when using `plateSelectorVariant=\"tabs\"`). */\n onRemovePlate?: (plateId: string) => void;\n addPlateLabel?: string;\n removePlateLabel?: string;\n plateSelectorLabel?: string;\n /** Layout of the plate selector. Defaults to `\"dropdown\"`. */\n plateSelectorVariant?: PlateMapPlateSelectorVariant;\n /** Row field used to stamp the active user-provided barcode onto edited wells. Defaults to `plateBarcode`. */\n plateBarcodeField?: keyof T & string;\n /** Header for the automatic manifest barcode column. */\n plateBarcodeColumnHeader?: string;\n /** Hide the automatic manifest barcode column when plate-scoped editing is active. */\n hidePlateBarcodeColumn?: boolean;\n /** Optional grouped well shortcuts rendered under the grid. */\n groups?: PlateMapGroupOption[];\n activeGroupId?: string;\n onGroupClick?: (group: PlateMapGroupOption) => void;\n /** Custom hover summary for the strip above the grid. */\n renderHoverSummary?: (well: T | undefined, wellId: WellId) => React.ReactNode;\n /** Fixed well size. When unset, the grid grows with the available width. */\n cellSize?: number;\n /** Fill color for empty wells. Pass `null` to delegate empty wells to `colorForWell`. */\n emptyWellFillColor?: string | null;\n /** Well shape forwarded to `PlatePaintGrid`. Defaults to `\"rect\"`. */\n wellShape?: WellShape;\n /** When true, wraps the grid in a card-like plate frame (rounded + border + soft shadow). */\n framedPlate?: boolean;\n /**\n * Forwarded to `PlatePaintGrid`. Render-prop that places a node inside each\n * absolute-positioned well cell — used to wire drop targets without binding\n * the kit to a specific DnD library.\n */\n wrapWell?: (wellId: WellId, cellSize: number) => React.ReactNode;\n /** Wells to highlight (e.g. when hovering a legend item externally). */\n highlightedWellIds?: ReadonlySet<WellId>;\n /** Fires whenever the currently hovered well changes (null on leave). */\n onHoveredWellChange?: (wellId: WellId | null) => void;\n /** Enables the filter popover on the manifest table. */\n manifestFilterable?: boolean;\n /** Enables the group-by selector on the manifest table. */\n manifestGroupable?: boolean;\n autoScaleGrid?: boolean;\n minCellSize?: number;\n maxCellSize?: number;\n\n className?: string;\n}\n\nfunction defaultMerge<T extends WellRecord>(existing: T | undefined, staged: Partial<T>): T {\n return { ...(existing ?? ({} as T)), ...staged };\n}\n\nfunction mergePlateOptions(\n importedPlates: PlateMapPlateOption[],\n providedPlates: PlateMapPlateOption[] | undefined,\n): PlateMapPlateOption[] {\n const merged = new Map<string, PlateMapPlateOption>();\n importedPlates.forEach((plate) => merged.set(plate.id, plate));\n (providedPlates ?? []).forEach((plate) => merged.set(plate.id, plate));\n return [...merged.values()];\n}\n\nfunction resolveActivePlate(\n plates: PlateMapPlateOption[],\n selectedPlateId: string | undefined,\n): PlateMapPlateOption | undefined {\n const matchingPlate = plates.find((plate) => plate.id === selectedPlateId);\n if (matchingPlate) return matchingPlate;\n return selectedPlateId ? undefined : plates[0];\n}\n\nfunction buildScopedValues<T extends WellRecord>(values: Map<WellId, T>, plateKey: string | undefined) {\n if (!plateKey) return values;\n\n const next = new Map<WellId, T>();\n values.forEach((row, key) => {\n const wellId = wellIdFromPlateWellKey(plateKey, key);\n if (wellId) next.set(wellId, row);\n });\n return next;\n}\n\nfunction resolveImportedPlateSelection({\n importedPlates,\n selectedPlateId,\n isControlled,\n providedPlateCount,\n}: {\n importedPlates: PlateMapPlateOption[];\n selectedPlateId?: string;\n isControlled: boolean;\n providedPlateCount: number;\n}): string | null | undefined {\n const firstImportedPlateId = importedPlates[0]?.id;\n if (!firstImportedPlateId) return !isControlled && providedPlateCount === 0 ? null : undefined;\n return importedPlates.some((plate) => plate.id === selectedPlateId) ? undefined : firstImportedPlateId;\n}\n\nfunction shouldShowPlateSelector(plateCount: number, onAddPlate: PlateMapEditorProps[\"onAddPlate\"]): boolean {\n return plateCount > 0 || !!onAddPlate;\n}\n\nfunction canUpdatePlateSelection(isControlled: boolean, onPlateChange: PlateMapEditorProps[\"onPlateChange\"]): boolean {\n return !isControlled || !!onPlateChange;\n}\n\nfunction PlateMapEditorTitleBar({ title, badges }: { title?: string; badges?: React.ReactNode }) {\n if (!title && !badges) return null;\n\n return (\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n {title ? <h2 className=\"text-lg font-semibold\">{title}</h2> : <span />}\n {badges ? <div className=\"flex flex-wrap gap-2\">{badges}</div> : null}\n </div>\n );\n}\n\nfunction PlateMapEditorLegend({ legend }: { legend?: React.ReactNode }) {\n if (!legend) return null;\n\n return (\n <>\n <Separator />\n {legend}\n </>\n );\n}\n\nexport function PlateMapEditor<T extends WellRecord = WellRecord>({\n format,\n rows,\n columns,\n values,\n onChange,\n selection,\n onSelectionChange,\n fields,\n tableColumns,\n colorForWell,\n emptyEntry,\n mergeOnApply,\n isPopulated,\n cycleFieldOnWellDoubleClick,\n title,\n badges,\n banner,\n legend,\n formExtras,\n formSlot,\n footer,\n plateTitle = \"Plate\",\n plateToolbar,\n plates,\n activePlateId,\n onPlateChange,\n onAddPlate,\n onRemovePlate,\n addPlateLabel,\n removePlateLabel,\n plateSelectorLabel,\n plateSelectorVariant,\n plateBarcodeField,\n plateBarcodeColumnHeader = DEFAULT_PLATE_BARCODE_HEADER,\n hidePlateBarcodeColumn = false,\n groups,\n activeGroupId,\n onGroupClick,\n renderHoverSummary,\n cellSize,\n emptyWellFillColor,\n wellShape,\n framedPlate,\n wrapWell,\n highlightedWellIds,\n onHoveredWellChange,\n manifestFilterable,\n manifestGroupable,\n autoScaleGrid,\n minCellSize,\n maxCellSize,\n className,\n templates,\n templateId,\n onTemplateChange,\n onClearTemplate,\n onImportCsv,\n onExportCsv,\n onImportTemplate,\n onExportTemplate,\n csvAccept,\n templateAccept,\n label,\n align,\n side,\n importTemplateLabel,\n exportTemplateLabel,\n importCsvLabel,\n exportCsvLabel,\n clearLabel,\n}: PlateMapEditorProps<T>) {\n const dims = resolveDimensions(format, rows, columns);\n const [staged, setStaged] = React.useState<Partial<T>>({});\n const [hoverPos, setHoverPos] = React.useState<WellId | null>(null);\n const [flashWell, setFlashWell] = React.useState<{ wellId: WellId; key: number }>();\n const [csvPlates, setCsvPlates] = React.useState<PlateMapPlateOption[]>([]);\n const [internalActivePlateId, setInternalActivePlateId] = React.useState<string>();\n\n const merge = mergeOnApply ?? defaultMerge<T>;\n const availablePlates = React.useMemo(() => mergePlateOptions(csvPlates, plates), [csvPlates, plates]);\n const isPlateSelectionControlled = activePlateId !== undefined;\n const selectedPlateId = activePlateId ?? internalActivePlateId;\n const activePlate = React.useMemo(\n () => resolveActivePlate(availablePlates, selectedPlateId),\n [availablePlates, selectedPlateId],\n );\n const activePlateBarcode = activePlate?.barcode;\n const activePlateKey = activePlateBarcode;\n const isPlateScoped = !!activePlateKey;\n const barcodeField = (plateBarcodeField ?? DEFAULT_PLATE_BARCODE_FIELD) as keyof T & string;\n const previousActivePlateKey = React.useRef<string | undefined>(activePlateKey);\n\n const scopedValues = React.useMemo(() => buildScopedValues(values, activePlateKey), [activePlateKey, values]);\n\n const toStoredWellKey = React.useCallback(\n (wellId: WellId): WellId => {\n if (!isPlateScoped || !activePlateKey) return wellId;\n return getPlateMapScopedWellId(activePlateKey, wellId);\n },\n [activePlateKey, isPlateScoped],\n );\n\n const handlePlateChange = React.useCallback(\n (plateId: string) => {\n if (!isPlateSelectionControlled) setInternalActivePlateId(plateId);\n onPlateChange?.(plateId);\n },\n [isPlateSelectionControlled, onPlateChange],\n );\n\n const handleImportCsv = React.useCallback(\n async (file: File, triage?: PlateMapCsvTriage) => {\n if (triage) {\n const nextCsvPlates = plateOptionsFromCsvTriage(triage);\n setCsvPlates(nextCsvPlates);\n const nextSelection = resolveImportedPlateSelection({\n importedPlates: nextCsvPlates,\n selectedPlateId,\n isControlled: isPlateSelectionControlled,\n providedPlateCount: plates?.length ?? 0,\n });\n\n if (nextSelection !== undefined) {\n if (!isPlateSelectionControlled) setInternalActivePlateId(nextSelection ?? undefined);\n if (nextSelection) onPlateChange?.(nextSelection);\n }\n }\n\n await onImportCsv?.(file, triage);\n },\n [isPlateSelectionControlled, onImportCsv, onPlateChange, plates, selectedPlateId],\n );\n\n const stampActivePlateBarcode = React.useCallback(\n (row: T): T => {\n if (!isPlateScoped || !activePlateBarcode) return row;\n return { ...(row as Record<string, unknown>), [barcodeField]: activePlateBarcode } as T;\n },\n [activePlateBarcode, barcodeField, isPlateScoped],\n );\n\n const commitScopedValues = React.useCallback(\n (nextScopedValues: Map<WellId, T>) => {\n if (!isPlateScoped || !activePlateKey) {\n onChange(nextScopedValues);\n return;\n }\n\n const next = new Map(values);\n [...next.keys()].forEach((key) => {\n if (wellIdFromPlateWellKey(activePlateKey, key)) {\n next.delete(key);\n }\n });\n nextScopedValues.forEach((row, wellId) => {\n next.set(toStoredWellKey(wellId), stampActivePlateBarcode(row));\n });\n onChange(next);\n },\n [activePlateKey, isPlateScoped, onChange, stampActivePlateBarcode, toStoredWellKey, values],\n );\n\n React.useEffect(() => {\n if (previousActivePlateKey.current === activePlateKey) return;\n previousActivePlateKey.current = activePlateKey;\n setStaged({});\n setHoverPos(null);\n setFlashWell(undefined);\n if (selection.size > 0) onSelectionChange(new Set());\n }, [activePlateKey, onSelectionChange, selection.size]);\n\n const doubleClickCycleField = React.useMemo(() => {\n if (!cycleFieldOnWellDoubleClick) return;\n const field = fields.find((f) => f.key === cycleFieldOnWellDoubleClick);\n if (field?.kind !== \"select\" || !field.options?.length) return;\n return field;\n }, [cycleFieldOnWellDoubleClick, fields]);\n\n const applyStagedToSelection = () => {\n if (selection.size === 0) return;\n const next = new Map(scopedValues);\n selection.forEach((wellId) => {\n const existing = next.get(wellId);\n const base = existing ?? emptyEntry(wellId);\n const merged = stampActivePlateBarcode(merge(base, staged, wellId));\n next.set(wellId, merged);\n });\n commitScopedValues(next);\n };\n\n const clearWells = () => {\n if (selection.size === 0) return;\n const next = new Map(scopedValues);\n selection.forEach((wellId) => next.delete(wellId));\n commitScopedValues(next);\n };\n\n const cycleWellField = React.useCallback(\n (wellId: WellId) => {\n if (!doubleClickCycleField?.options?.length) return;\n\n const next = new Map(scopedValues);\n const existing = next.get(wellId);\n const currentValue = existing?.[doubleClickCycleField.key];\n const currentIndex = doubleClickCycleField.options.findIndex((opt) => opt.value === currentValue);\n const nextOption = doubleClickCycleField.options[(currentIndex + 1) % doubleClickCycleField.options.length];\n if (!nextOption) return;\n\n const base = existing ?? emptyEntry(wellId);\n next.set(wellId, stampActivePlateBarcode({ ...base, [doubleClickCycleField.key]: nextOption.value } as T));\n commitScopedValues(next);\n setFlashWell((current) => ({ wellId, key: (current?.key ?? 0) + 1 }));\n },\n [commitScopedValues, doubleClickCycleField, emptyEntry, scopedValues, stampActivePlateBarcode],\n );\n\n const selectAll = () => {\n onSelectionChange(new Set(allPositions(dims)));\n };\n const deselectAll = () => onSelectionChange(new Set());\n\n const hoverEntry = hoverPos ? scopedValues.get(hoverPos) : undefined;\n\n const hoverFields = hoverEntry\n ? (fields\n .map((f) => {\n const v = hoverEntry[f.key];\n if (v === undefined || v === null || v === \"\") return null;\n if (f.kind === \"select\") {\n const opt = (f.options ?? []).find((o) => o.value === v);\n return opt?.label ?? String(v);\n }\n if (f.kind === \"multiselect\") {\n const arr = Array.isArray(v) ? (v as string[]) : [];\n if (arr.length === 0) return null;\n return arr\n .map((item) => (f.options ?? []).find((o) => o.value === item)?.label ?? item)\n .join(\", \");\n }\n if (f.kind === \"boolean\") {\n return v ? f.label : null;\n }\n return String(v);\n })\n .filter(Boolean) as string[])\n : [];\n\n const hoverSummary = hoverPos\n ? (renderHoverSummary?.(hoverEntry, hoverPos) ?? [hoverPos, ...hoverFields].join(\" • \"))\n : \" \";\n const manifestColumns = React.useMemo(() => {\n if (!isPlateScoped || !activePlateBarcode || hidePlateBarcodeColumn) return tableColumns;\n const alreadyHasBarcodeColumn = tableColumns.some(\n (column) => column.field === barcodeField || column.id === barcodeField,\n );\n if (alreadyHasBarcodeColumn) return tableColumns;\n\n const barcodeColumn: WellColumn<T> = {\n id: barcodeField,\n header: plateBarcodeColumnHeader,\n minWidth: 150,\n render: ({ row }) => {\n const barcode = row[barcodeField] ?? activePlateBarcode;\n return <Badge variant=\"outline\">{String(barcode)}</Badge>;\n },\n };\n return [barcodeColumn, ...tableColumns];\n }, [activePlateBarcode, barcodeField, hidePlateBarcodeColumn, isPlateScoped, plateBarcodeColumnHeader, tableColumns]);\n const showPlateSelector = shouldShowPlateSelector(availablePlates.length, onAddPlate);\n const canChangePlate = canUpdatePlateSelection(isPlateSelectionControlled, onPlateChange);\n\n return (\n <div data-slot=\"plate-map-editor\" className={cn(\"flex flex-col gap-4\", className)}>\n <PlateMapEditorTitleBar title={title} badges={badges} />\n\n {banner}\n\n <div className=\"flex flex-wrap gap-3 md:flex-nowrap\">\n {/* Form column */}\n <Card className=\"flex w-full max-w-[360px] min-w-[300px] basis-[360px] flex-col\" size=\"sm\">\n <CardContent className=\"flex h-full flex-1 flex-col gap-3\">\n {formSlot ?? (\n <WellMetadataForm\n fields={fields}\n value={staged}\n onChange={setStaged}\n selectionSize={selection.size}\n onApply={applyStagedToSelection}\n onClear={clearWells}\n extras={formExtras}\n />\n )}\n <PlateMapEditorLegend legend={legend} />\n </CardContent>\n </Card>\n\n {/* Plate column */}\n <Card className=\"flex min-w-[360px] flex-1 flex-col\" size=\"sm\">\n <CardHeader className=\"border-b\">\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n <CardTitle className=\"min-w-0\">{plateTitle}</CardTitle>\n {showPlateSelector ? (\n <PlateMapPlateSelector\n plates={availablePlates}\n activePlateId={activePlate?.id}\n onPlateChange={canChangePlate ? handlePlateChange : undefined}\n onAddPlate={onAddPlate}\n onRemovePlate={onRemovePlate}\n addPlateLabel={addPlateLabel}\n removePlateLabel={removePlateLabel}\n label={plateSelectorLabel}\n variant={plateSelectorVariant}\n />\n ) : null}\n </div>\n <CardAction className=\"flex flex-wrap items-center gap-2\">\n <PlateMapActionsMenu\n templates={templates}\n templateId={templateId}\n onTemplateChange={onTemplateChange}\n onClearTemplate={onClearTemplate}\n hasEntries={values.size > 0}\n onImportCsv={onImportCsv ? handleImportCsv : undefined}\n onExportCsv={onExportCsv}\n onImportTemplate={onImportTemplate}\n onExportTemplate={onExportTemplate}\n csvAccept={csvAccept}\n templateAccept={templateAccept}\n label={label}\n align={align}\n side={side}\n importTemplateLabel={importTemplateLabel}\n exportTemplateLabel={exportTemplateLabel}\n importCsvLabel={importCsvLabel}\n exportCsvLabel={exportCsvLabel}\n clearLabel={clearLabel}\n />\n </CardAction>\n </CardHeader>\n <CardContent className=\"flex flex-col gap-1.5\">\n <div className=\"flex flex-wrap items-center justify-start gap-3\">\n {plateToolbar}\n <div className=\"flex items-center gap-2 text-xs\">\n <button\n type=\"button\"\n className=\"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline\"\n onClick={selectAll}\n >\n Select all\n </button>\n <span className=\"text-muted-foreground/60\">·</span>\n <button\n type=\"button\"\n className=\"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline\"\n onClick={deselectAll}\n >\n Deselect all\n </button>\n </div>\n </div>\n <div className=\"h-5 text-xs text-muted-foreground\">{hoverSummary}</div>\n <PlatePaintGrid\n format={format}\n rows={rows}\n columns={columns}\n values={scopedValues}\n selection={selection}\n onSelectionChange={onSelectionChange}\n colorForWell={colorForWell}\n emptyWellFillColor={emptyWellFillColor}\n wellShape={wellShape}\n framed={framedPlate}\n wrapWell={wrapWell}\n highlightedWellIds={highlightedWellIds}\n onWellHover={(wellId) => {\n setHoverPos(wellId);\n onHoveredWellChange?.(wellId);\n }}\n onWellDoubleClick={doubleClickCycleField ? cycleWellField : undefined}\n selectionFillMode={doubleClickCycleField ? \"well\" : \"selection\"}\n flashWellId={flashWell?.wellId}\n flashWellKey={flashWell?.key}\n cellSize={cellSize}\n autoScale={autoScaleGrid}\n minCellSize={minCellSize}\n maxCellSize={maxCellSize}\n />\n {groups && groups.length > 0 ? (\n <>\n <Separator className=\"mt-2\" />\n <div className=\"flex max-h-28 flex-wrap gap-3 overflow-y-auto pt-1\">\n {groups.map((group) => {\n const isActive = group.id === activeGroupId;\n const count = group.count ?? group.wellIds?.length;\n return (\n <button\n key={group.id}\n type=\"button\"\n disabled={group.disabled}\n onClick={() => onGroupClick?.(group)}\n className={cn(\n \"flex w-16 flex-col items-center gap-1 rounded-md px-1 py-1 text-center text-xs transition-colors\",\n \"text-muted-foreground hover:bg-muted/60\",\n isActive && \"bg-muted text-foreground ring-1 ring-primary/40\",\n group.disabled && \"pointer-events-none opacity-50\",\n )}\n title={group.label}\n >\n <span\n className=\"size-7 rounded-full border\"\n style={{\n backgroundColor: group.color,\n borderColor: group.borderColor,\n }}\n aria-hidden\n />\n <span className=\"w-full truncate text-foreground\">{group.label}</span>\n {count === undefined ? null : (\n <span className=\"text-[0.7rem] leading-none text-muted-foreground\">{count} wells</span>\n )}\n </button>\n );\n })}\n </div>\n </>\n ) : null}\n </CardContent>\n </Card>\n </div>\n\n <Card size=\"sm\">\n <CardHeader className=\"border-b\">\n <CardTitle>Sample manifest</CardTitle>\n </CardHeader>\n <CardContent>\n <WellManifestTable\n values={scopedValues}\n onChange={commitScopedValues}\n columns={manifestColumns}\n fields={fields}\n selection={selection}\n onSelectionChange={onSelectionChange}\n emptyEntry={emptyEntry}\n isPopulated={isPopulated}\n filterable={manifestFilterable}\n groupable={manifestGroupable}\n />\n </CardContent>\n </Card>\n\n {footer ? <div className=\"flex justify-end gap-2 pt-2\">{footer}</div> : null}\n </div>\n );\n}\n\nexport { Badge as PlateBadge };\n"],"names":["PLATE_WELL_KEY_SEPARATOR","DEFAULT_PLATE_BARCODE_FIELD","DEFAULT_PLATE_BARCODE_HEADER","getPlateMapScopedWellId","plateBarcode","wellId","wellIdFromPlateWellKey","plateId","key","prefix","defaultMerge","existing","staged","mergePlateOptions","importedPlates","providedPlates","merged","plate","resolveActivePlate","plates","selectedPlateId","matchingPlate","buildScopedValues","values","plateKey","next","row","resolveImportedPlateSelection","isControlled","providedPlateCount","firstImportedPlateId","shouldShowPlateSelector","plateCount","onAddPlate","canUpdatePlateSelection","onPlateChange","PlateMapEditorTitleBar","title","badges","jsxs","jsx","PlateMapEditorLegend","legend","Fragment","Separator","PlateMapEditor","format","rows","columns","onChange","selection","onSelectionChange","fields","tableColumns","colorForWell","emptyEntry","mergeOnApply","isPopulated","cycleFieldOnWellDoubleClick","banner","formExtras","formSlot","footer","plateTitle","plateToolbar","activePlateId","onRemovePlate","addPlateLabel","removePlateLabel","plateSelectorLabel","plateSelectorVariant","plateBarcodeField","plateBarcodeColumnHeader","hidePlateBarcodeColumn","groups","activeGroupId","onGroupClick","renderHoverSummary","cellSize","emptyWellFillColor","wellShape","framedPlate","wrapWell","highlightedWellIds","onHoveredWellChange","manifestFilterable","manifestGroupable","autoScaleGrid","minCellSize","maxCellSize","className","templates","templateId","onTemplateChange","onClearTemplate","onImportCsv","onExportCsv","onImportTemplate","onExportTemplate","csvAccept","templateAccept","label","align","side","importTemplateLabel","exportTemplateLabel","importCsvLabel","exportCsvLabel","clearLabel","dims","resolveDimensions","setStaged","React","hoverPos","setHoverPos","flashWell","setFlashWell","csvPlates","setCsvPlates","internalActivePlateId","setInternalActivePlateId","merge","availablePlates","isPlateSelectionControlled","activePlate","activePlateBarcode","activePlateKey","isPlateScoped","barcodeField","previousActivePlateKey","scopedValues","toStoredWellKey","handlePlateChange","handleImportCsv","file","triage","nextCsvPlates","plateOptionsFromCsvTriage","nextSelection","stampActivePlateBarcode","commitScopedValues","nextScopedValues","doubleClickCycleField","field","f","applyStagedToSelection","base","clearWells","cycleWellField","currentValue","currentIndex","opt","nextOption","current","selectAll","allPositions","deselectAll","hoverEntry","hoverFields","v","o","arr","item","hoverSummary","manifestColumns","column","barcode","Badge","showPlateSelector","canChangePlate","cn","Card","CardContent","WellMetadataForm","CardHeader","CardTitle","PlateMapPlateSelector","CardAction","PlateMapActionsMenu","PlatePaintGrid","group","isActive","count","WellManifestTable"],"mappings":";;;;;;;;;;;;;AA6BA,MAAMA,KAA2B,MAC3BC,KAA8B,gBAC9BC,KAA+B;AAE9B,SAASC,GAAwBC,GAAsBC,GAAwB;AACpF,SAAO,GAAGD,CAAY,GAAGJ,EAAwB,GAAGK,CAAM;AAC5D;AAEA,SAASC,GAAuBC,GAAiBC,GAAiC;AAChF,QAAM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;AAAA,MAAA,EACb,CACF;AAAA,IAAA,GACF;AAAA,IAECxB,IAAS,gBAAAtB,EAAC,OAAA,EAAI,WAAU,+BAA+B,aAAO,IAAS;AAAA,EAAA,GAC1E;AAEJ;"}
1
+ {"version":3,"file":"PlateMapEditor.js","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapEditor.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { plateOptionsFromCsvTriage } from \"./csvPlateTriage\";\nimport { PlateMapActionsMenu } from \"./PlateMapActionsMenu\";\nimport { PlateMapForm } from \"./PlateMapForm\";\nimport { PlateMapGrid } from \"./PlateMapGrid\";\nimport { PlateMapManifest } from \"./PlateMapManifest\";\nimport { PlateMapPlateSelector } from \"./PlateMapPlateSelector\";\n\nimport type { PlateMapActionsMenuProps } from \"./PlateMapActionsMenu\";\nimport type { PlateMapPlateSelectorVariant } from \"./PlateMapPlateSelector\";\nimport type { WellShape } from \"./PlatePaintGrid\";\nimport type {\n PlateFormat,\n PlateMapCsvTriage,\n PlateMapGroupOption,\n PlateMapPlateOption,\n WellColumn,\n WellField,\n WellId,\n WellRecord,\n} from \"./types\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport { Card, CardAction, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport { cn } from \"@/lib/utils\";\n\nconst PLATE_WELL_KEY_SEPARATOR = \"::\";\nconst DEFAULT_PLATE_BARCODE_FIELD = \"plateBarcode\";\nconst DEFAULT_PLATE_BARCODE_HEADER = \"Plate Barcode\";\n\nexport function getPlateMapScopedWellId(plateBarcode: string, wellId: WellId): WellId {\n return `${plateBarcode}${PLATE_WELL_KEY_SEPARATOR}${wellId}`;\n}\n\nfunction wellIdFromPlateWellKey(plateId: string, key: WellId): WellId | undefined {\n const prefix = `${plateId}${PLATE_WELL_KEY_SEPARATOR}`;\n return key.startsWith(prefix) ? key.slice(prefix.length) : undefined;\n}\n\nexport interface PlateMapEditorProps<T extends WellRecord = WellRecord> extends Omit<\n PlateMapActionsMenuProps,\n \"hasEntries\" | \"className\"\n> {\n format: PlateFormat;\n rows?: number;\n columns?: number;\n values: Map<WellId, T>;\n onChange: (next: Map<WellId, T>) => void;\n selection: Set<WellId>;\n onSelectionChange: (next: Set<WellId>) => void;\n\n fields: WellField<T>[];\n tableColumns: WellColumn<T>[];\n\n /** Resolves the SVG fill color for a well. */\n colorForWell: (well: T | undefined, wellId: WellId) => string;\n /** Builds an empty record when a well is freshly created. */\n emptyEntry: (wellId: WellId) => T;\n /**\n * Merges the staged form record onto an existing well record on Apply.\n * Defaults to a shallow merge (form keys overwrite existing keys when set).\n */\n mergeOnApply?: (existing: T | undefined, staged: Partial<T>, wellId: WellId) => T;\n /** Filter for the manifest's \"hide empty\" mode. */\n isPopulated?: (row: T) => boolean;\n /** Select field cycled when double-clicking a single well, e.g. role painting. */\n cycleFieldOnWellDoubleClick?: keyof T & string;\n\n /** Optional header title (e.g. plate set name). */\n title?: string;\n /** Optional badges shown in the header next to the title. */\n badges?: React.ReactNode;\n /** Optional banner (e.g. import/error alert) shown above the layout. */\n banner?: React.ReactNode;\n /** Legend block rendered under the form column. */\n legend?: React.ReactNode;\n /** Form helper slot rendered between fields and the action row. */\n formExtras?: React.ReactNode;\n /**\n * Fully replaces the left column. When set, the built-in `WellMetadataForm`\n * is omitted — use this for alternative workflows like a drag-and-drop\n * source palette. The legend slot still renders beneath the replacement.\n */\n formSlot?: React.ReactNode;\n /** Footer actions (e.g. Save, Back). */\n footer?: React.ReactNode;\n /** Title for the plate grid panel. */\n plateTitle?: React.ReactNode;\n /** Optional controls shown next to the built-in actions menu. */\n plateToolbar?: React.ReactNode;\n /** User-provided plates available for this editor. Barcodes are never generated by the editor. */\n plates?: PlateMapPlateOption[];\n activePlateId?: string;\n onPlateChange?: (plateId: string) => void;\n /** Opens the host app's manual barcode entry flow for creating a plate. */\n onAddPlate?: () => void;\n /** Removes a plate (typically when using `plateSelectorVariant=\"tabs\"`). */\n onRemovePlate?: (plateId: string) => void;\n addPlateLabel?: string;\n removePlateLabel?: string;\n plateSelectorLabel?: string;\n /** Layout of the plate selector. Defaults to `\"dropdown\"`. */\n plateSelectorVariant?: PlateMapPlateSelectorVariant;\n /** Row field used to stamp the active user-provided barcode onto edited wells. Defaults to `plateBarcode`. */\n plateBarcodeField?: keyof T & string;\n /** Header for the automatic manifest barcode column. */\n plateBarcodeColumnHeader?: string;\n /** Hide the automatic manifest barcode column when plate-scoped editing is active. */\n hidePlateBarcodeColumn?: boolean;\n /** Optional grouped well shortcuts rendered under the grid. */\n groups?: PlateMapGroupOption[];\n activeGroupId?: string;\n onGroupClick?: (group: PlateMapGroupOption) => void;\n /** Custom hover summary for the strip above the grid. */\n renderHoverSummary?: (well: T | undefined, wellId: WellId) => React.ReactNode;\n /** Fixed well size. When unset, the grid grows with the available width. */\n cellSize?: number;\n /** Fill color for empty wells. Pass `null` to delegate empty wells to `colorForWell`. */\n emptyWellFillColor?: string | null;\n /** Well shape forwarded to `PlatePaintGrid`. Defaults to `\"rect\"`. */\n wellShape?: WellShape;\n /** When true, wraps the grid in a card-like plate frame (rounded + border + soft shadow). */\n framedPlate?: boolean;\n /**\n * Forwarded to `PlatePaintGrid`. Render-prop that places a node inside each\n * absolute-positioned well cell — used to wire drop targets without binding\n * the kit to a specific DnD library.\n */\n wrapWell?: (wellId: WellId, cellSize: number) => React.ReactNode;\n /** Wells to highlight (e.g. when hovering a legend item externally). */\n highlightedWellIds?: ReadonlySet<WellId>;\n /** Fires whenever the currently hovered well changes (null on leave). */\n onHoveredWellChange?: (wellId: WellId | null) => void;\n /** Enables the filter popover on the manifest table. */\n manifestFilterable?: boolean;\n /** Enables the group-by selector on the manifest table. */\n manifestGroupable?: boolean;\n autoScaleGrid?: boolean;\n minCellSize?: number;\n maxCellSize?: number;\n\n className?: string;\n}\n\nfunction defaultMerge<T extends WellRecord>(existing: T | undefined, staged: Partial<T>): T {\n return { ...(existing ?? ({} as T)), ...staged };\n}\n\nfunction mergePlateOptions(\n importedPlates: PlateMapPlateOption[],\n providedPlates: PlateMapPlateOption[] | undefined,\n): PlateMapPlateOption[] {\n const merged = new Map<string, PlateMapPlateOption>();\n importedPlates.forEach((plate) => merged.set(plate.id, plate));\n (providedPlates ?? []).forEach((plate) => merged.set(plate.id, plate));\n return [...merged.values()];\n}\n\nfunction resolveActivePlate(\n plates: PlateMapPlateOption[],\n selectedPlateId: string | undefined,\n): PlateMapPlateOption | undefined {\n const matchingPlate = plates.find((plate) => plate.id === selectedPlateId);\n if (matchingPlate) return matchingPlate;\n return selectedPlateId ? undefined : plates[0];\n}\n\nfunction buildScopedValues<T extends WellRecord>(values: Map<WellId, T>, plateKey: string | undefined) {\n if (!plateKey) return values;\n\n const next = new Map<WellId, T>();\n values.forEach((row, key) => {\n const wellId = wellIdFromPlateWellKey(plateKey, key);\n if (wellId) next.set(wellId, row);\n });\n return next;\n}\n\nfunction resolveImportedPlateSelection({\n importedPlates,\n selectedPlateId,\n isControlled,\n providedPlateCount,\n}: {\n importedPlates: PlateMapPlateOption[];\n selectedPlateId?: string;\n isControlled: boolean;\n providedPlateCount: number;\n}): string | null | undefined {\n const firstImportedPlateId = importedPlates[0]?.id;\n if (!firstImportedPlateId) return !isControlled && providedPlateCount === 0 ? null : undefined;\n return importedPlates.some((plate) => plate.id === selectedPlateId) ? undefined : firstImportedPlateId;\n}\n\nfunction shouldShowPlateSelector(plateCount: number, onAddPlate: PlateMapEditorProps[\"onAddPlate\"]): boolean {\n return plateCount > 0 || !!onAddPlate;\n}\n\nfunction canUpdatePlateSelection(isControlled: boolean, onPlateChange: PlateMapEditorProps[\"onPlateChange\"]): boolean {\n return !isControlled || !!onPlateChange;\n}\n\nfunction PlateMapEditorTitleBar({ title, badges }: { title?: string; badges?: React.ReactNode }) {\n if (!title && !badges) return null;\n\n return (\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n {title ? <h2 className=\"text-lg font-semibold\">{title}</h2> : <span />}\n {badges ? <div className=\"flex flex-wrap gap-2\">{badges}</div> : null}\n </div>\n );\n}\n\nexport function PlateMapEditor<T extends WellRecord = WellRecord>({\n format,\n rows,\n columns,\n values,\n onChange,\n selection,\n onSelectionChange,\n fields,\n tableColumns,\n colorForWell,\n emptyEntry,\n mergeOnApply,\n isPopulated,\n cycleFieldOnWellDoubleClick,\n title,\n badges,\n banner,\n legend,\n formExtras,\n formSlot,\n footer,\n plateTitle = \"Plate\",\n plateToolbar,\n plates,\n activePlateId,\n onPlateChange,\n onAddPlate,\n onRemovePlate,\n addPlateLabel,\n removePlateLabel,\n plateSelectorLabel,\n plateSelectorVariant,\n plateBarcodeField,\n plateBarcodeColumnHeader = DEFAULT_PLATE_BARCODE_HEADER,\n hidePlateBarcodeColumn = false,\n groups,\n activeGroupId,\n onGroupClick,\n renderHoverSummary,\n cellSize,\n emptyWellFillColor,\n wellShape,\n framedPlate,\n wrapWell,\n highlightedWellIds,\n onHoveredWellChange,\n manifestFilterable,\n manifestGroupable,\n autoScaleGrid,\n minCellSize,\n maxCellSize,\n className,\n templates,\n templateId,\n onTemplateChange,\n onClearTemplate,\n onImportCsv,\n onExportCsv,\n onImportTemplate,\n onExportTemplate,\n csvAccept,\n templateAccept,\n label,\n align,\n side,\n importTemplateLabel,\n exportTemplateLabel,\n importCsvLabel,\n exportCsvLabel,\n clearLabel,\n}: PlateMapEditorProps<T>) {\n const [staged, setStaged] = React.useState<Partial<T>>({});\n const [hoverPos, setHoverPos] = React.useState<WellId | null>(null);\n const [flashWell, setFlashWell] = React.useState<{ wellId: WellId; key: number }>();\n const [csvPlates, setCsvPlates] = React.useState<PlateMapPlateOption[]>([]);\n const [internalActivePlateId, setInternalActivePlateId] = React.useState<string>();\n\n const merge = mergeOnApply ?? defaultMerge<T>;\n const availablePlates = React.useMemo(() => mergePlateOptions(csvPlates, plates), [csvPlates, plates]);\n const isPlateSelectionControlled = activePlateId !== undefined;\n const selectedPlateId = activePlateId ?? internalActivePlateId;\n const activePlate = React.useMemo(\n () => resolveActivePlate(availablePlates, selectedPlateId),\n [availablePlates, selectedPlateId],\n );\n const activePlateBarcode = activePlate?.barcode;\n const activePlateKey = activePlateBarcode;\n const isPlateScoped = !!activePlateKey;\n const barcodeField = (plateBarcodeField ?? DEFAULT_PLATE_BARCODE_FIELD) as keyof T & string;\n const previousActivePlateKey = React.useRef<string | undefined>(activePlateKey);\n\n const scopedValues = React.useMemo(() => buildScopedValues(values, activePlateKey), [activePlateKey, values]);\n\n const toStoredWellKey = React.useCallback(\n (wellId: WellId): WellId => {\n if (!isPlateScoped || !activePlateKey) return wellId;\n return getPlateMapScopedWellId(activePlateKey, wellId);\n },\n [activePlateKey, isPlateScoped],\n );\n\n const handlePlateChange = React.useCallback(\n (plateId: string) => {\n if (!isPlateSelectionControlled) setInternalActivePlateId(plateId);\n onPlateChange?.(plateId);\n },\n [isPlateSelectionControlled, onPlateChange],\n );\n\n const handleImportCsv = React.useCallback(\n async (file: File, triage?: PlateMapCsvTriage) => {\n if (triage) {\n const nextCsvPlates = plateOptionsFromCsvTriage(triage);\n setCsvPlates(nextCsvPlates);\n const nextSelection = resolveImportedPlateSelection({\n importedPlates: nextCsvPlates,\n selectedPlateId,\n isControlled: isPlateSelectionControlled,\n providedPlateCount: plates?.length ?? 0,\n });\n\n if (nextSelection !== undefined) {\n if (!isPlateSelectionControlled) setInternalActivePlateId(nextSelection ?? undefined);\n if (nextSelection) onPlateChange?.(nextSelection);\n }\n }\n\n await onImportCsv?.(file, triage);\n },\n [isPlateSelectionControlled, onImportCsv, onPlateChange, plates, selectedPlateId],\n );\n\n const stampActivePlateBarcode = React.useCallback(\n (row: T): T => {\n if (!isPlateScoped || !activePlateBarcode) return row;\n return { ...(row as Record<string, unknown>), [barcodeField]: activePlateBarcode } as T;\n },\n [activePlateBarcode, barcodeField, isPlateScoped],\n );\n\n const commitScopedValues = React.useCallback(\n (nextScopedValues: Map<WellId, T>) => {\n if (!isPlateScoped || !activePlateKey) {\n onChange(nextScopedValues);\n return;\n }\n\n const next = new Map(values);\n [...next.keys()].forEach((key) => {\n if (wellIdFromPlateWellKey(activePlateKey, key)) {\n next.delete(key);\n }\n });\n nextScopedValues.forEach((row, wellId) => {\n next.set(toStoredWellKey(wellId), stampActivePlateBarcode(row));\n });\n onChange(next);\n },\n [activePlateKey, isPlateScoped, onChange, stampActivePlateBarcode, toStoredWellKey, values],\n );\n\n React.useEffect(() => {\n if (previousActivePlateKey.current === activePlateKey) return;\n previousActivePlateKey.current = activePlateKey;\n setStaged({});\n setHoverPos(null);\n setFlashWell(undefined);\n if (selection.size > 0) onSelectionChange(new Set());\n }, [activePlateKey, onSelectionChange, selection.size]);\n\n const doubleClickCycleField = React.useMemo(() => {\n if (!cycleFieldOnWellDoubleClick) return;\n const field = fields.find((f) => f.key === cycleFieldOnWellDoubleClick);\n if (field?.kind !== \"select\" || !field.options?.length) return;\n return field;\n }, [cycleFieldOnWellDoubleClick, fields]);\n\n const applyStagedToSelection = () => {\n if (selection.size === 0) return;\n const next = new Map(scopedValues);\n selection.forEach((wellId) => {\n const existing = next.get(wellId);\n const base = existing ?? emptyEntry(wellId);\n const merged = stampActivePlateBarcode(merge(base, staged, wellId));\n next.set(wellId, merged);\n });\n commitScopedValues(next);\n };\n\n const clearWells = () => {\n if (selection.size === 0) return;\n const next = new Map(scopedValues);\n selection.forEach((wellId) => next.delete(wellId));\n commitScopedValues(next);\n };\n\n const cycleWellField = React.useCallback(\n (wellId: WellId) => {\n if (!doubleClickCycleField?.options?.length) return;\n\n const next = new Map(scopedValues);\n const existing = next.get(wellId);\n const currentValue = existing?.[doubleClickCycleField.key];\n const currentIndex = doubleClickCycleField.options.findIndex((opt) => opt.value === currentValue);\n const nextOption = doubleClickCycleField.options[(currentIndex + 1) % doubleClickCycleField.options.length];\n if (!nextOption) return;\n\n const base = existing ?? emptyEntry(wellId);\n next.set(wellId, stampActivePlateBarcode({ ...base, [doubleClickCycleField.key]: nextOption.value } as T));\n commitScopedValues(next);\n setFlashWell((current) => ({ wellId, key: (current?.key ?? 0) + 1 }));\n },\n [commitScopedValues, doubleClickCycleField, emptyEntry, scopedValues, stampActivePlateBarcode],\n );\n\n const manifestColumns = React.useMemo(() => {\n if (!isPlateScoped || !activePlateBarcode || hidePlateBarcodeColumn) return tableColumns;\n const alreadyHasBarcodeColumn = tableColumns.some(\n (column) => column.field === barcodeField || column.id === barcodeField,\n );\n if (alreadyHasBarcodeColumn) return tableColumns;\n\n const barcodeColumn: WellColumn<T> = {\n id: barcodeField,\n header: plateBarcodeColumnHeader,\n minWidth: 150,\n render: ({ row }) => {\n const barcode = row[barcodeField] ?? activePlateBarcode;\n return <Badge variant=\"outline\">{String(barcode)}</Badge>;\n },\n };\n return [barcodeColumn, ...tableColumns];\n }, [activePlateBarcode, barcodeField, hidePlateBarcodeColumn, isPlateScoped, plateBarcodeColumnHeader, tableColumns]);\n const showPlateSelector = shouldShowPlateSelector(availablePlates.length, onAddPlate);\n const canChangePlate = canUpdatePlateSelection(isPlateSelectionControlled, onPlateChange);\n\n return (\n <div data-slot=\"plate-map-editor\" className={cn(\"flex flex-col gap-4\", className)}>\n <PlateMapEditorTitleBar title={title} badges={badges} />\n\n {banner}\n\n <div className=\"flex flex-wrap gap-3 md:flex-nowrap\">\n {/* Form column */}\n <Card className=\"flex w-full max-w-[360px] min-w-[300px] basis-[360px] flex-col\" size=\"sm\">\n <CardContent className=\"flex h-full flex-1 flex-col gap-3\">\n <PlateMapForm\n fields={fields}\n value={staged}\n onChange={setStaged}\n selectionSize={selection.size}\n onApply={applyStagedToSelection}\n onClear={clearWells}\n extras={formExtras}\n legend={legend}\n formSlot={formSlot}\n />\n </CardContent>\n </Card>\n\n {/* Plate column */}\n <Card className=\"flex min-w-[360px] flex-1 flex-col\" size=\"sm\">\n <CardHeader className=\"border-b\">\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n <CardTitle className=\"min-w-0\">{plateTitle}</CardTitle>\n {showPlateSelector ? (\n <PlateMapPlateSelector\n plates={availablePlates}\n activePlateId={activePlate?.id}\n onPlateChange={canChangePlate ? handlePlateChange : undefined}\n onAddPlate={onAddPlate}\n onRemovePlate={onRemovePlate}\n addPlateLabel={addPlateLabel}\n removePlateLabel={removePlateLabel}\n label={plateSelectorLabel}\n variant={plateSelectorVariant}\n />\n ) : null}\n </div>\n <CardAction className=\"flex flex-wrap items-center gap-2\">\n <PlateMapActionsMenu\n templates={templates}\n templateId={templateId}\n onTemplateChange={onTemplateChange}\n onClearTemplate={onClearTemplate}\n hasEntries={values.size > 0}\n onImportCsv={onImportCsv ? handleImportCsv : undefined}\n onExportCsv={onExportCsv}\n onImportTemplate={onImportTemplate}\n onExportTemplate={onExportTemplate}\n csvAccept={csvAccept}\n templateAccept={templateAccept}\n label={label}\n align={align}\n side={side}\n importTemplateLabel={importTemplateLabel}\n exportTemplateLabel={exportTemplateLabel}\n importCsvLabel={importCsvLabel}\n exportCsvLabel={exportCsvLabel}\n clearLabel={clearLabel}\n />\n </CardAction>\n </CardHeader>\n <CardContent>\n <PlateMapGrid\n format={format}\n rows={rows}\n columns={columns}\n values={scopedValues}\n selection={selection}\n onSelectionChange={onSelectionChange}\n colorForWell={colorForWell}\n fields={fields}\n renderHoverSummary={renderHoverSummary}\n hoveredWellId={hoverPos}\n onHoveredWellChange={(wellId) => {\n setHoverPos(wellId);\n onHoveredWellChange?.(wellId);\n }}\n toolbar={plateToolbar}\n emptyWellFillColor={emptyWellFillColor}\n wellShape={wellShape}\n framed={framedPlate}\n wrapWell={wrapWell}\n highlightedWellIds={highlightedWellIds}\n onWellDoubleClick={doubleClickCycleField ? cycleWellField : undefined}\n selectionFillMode={doubleClickCycleField ? \"well\" : \"selection\"}\n flashWellId={flashWell?.wellId}\n flashWellKey={flashWell?.key}\n cellSize={cellSize}\n autoScale={autoScaleGrid}\n minCellSize={minCellSize}\n maxCellSize={maxCellSize}\n groups={groups}\n activeGroupId={activeGroupId}\n onGroupClick={onGroupClick}\n />\n </CardContent>\n </Card>\n </div>\n\n <Card size=\"sm\">\n <CardHeader className=\"border-b\">\n <CardTitle>Sample manifest</CardTitle>\n </CardHeader>\n <CardContent>\n <PlateMapManifest\n values={scopedValues}\n onChange={commitScopedValues}\n columns={manifestColumns}\n fields={fields}\n selection={selection}\n onSelectionChange={onSelectionChange}\n emptyEntry={emptyEntry}\n isPopulated={isPopulated}\n filterable={manifestFilterable}\n groupable={manifestGroupable}\n />\n </CardContent>\n </Card>\n\n {footer ? <div className=\"flex justify-end gap-2 pt-2\">{footer}</div> : null}\n </div>\n );\n}\n\nexport { Badge as PlateBadge };\n"],"names":["PLATE_WELL_KEY_SEPARATOR","DEFAULT_PLATE_BARCODE_FIELD","DEFAULT_PLATE_BARCODE_HEADER","getPlateMapScopedWellId","plateBarcode","wellId","wellIdFromPlateWellKey","plateId","key","prefix","defaultMerge","existing","staged","mergePlateOptions","importedPlates","providedPlates","merged","plate","resolveActivePlate","plates","selectedPlateId","matchingPlate","buildScopedValues","values","plateKey","next","row","resolveImportedPlateSelection","isControlled","providedPlateCount","firstImportedPlateId","shouldShowPlateSelector","plateCount","onAddPlate","canUpdatePlateSelection","onPlateChange","PlateMapEditorTitleBar","title","badges","jsxs","jsx","PlateMapEditor","format","rows","columns","onChange","selection","onSelectionChange","fields","tableColumns","colorForWell","emptyEntry","mergeOnApply","isPopulated","cycleFieldOnWellDoubleClick","banner","legend","formExtras","formSlot","footer","plateTitle","plateToolbar","activePlateId","onRemovePlate","addPlateLabel","removePlateLabel","plateSelectorLabel","plateSelectorVariant","plateBarcodeField","plateBarcodeColumnHeader","hidePlateBarcodeColumn","groups","activeGroupId","onGroupClick","renderHoverSummary","cellSize","emptyWellFillColor","wellShape","framedPlate","wrapWell","highlightedWellIds","onHoveredWellChange","manifestFilterable","manifestGroupable","autoScaleGrid","minCellSize","maxCellSize","className","templates","templateId","onTemplateChange","onClearTemplate","onImportCsv","onExportCsv","onImportTemplate","onExportTemplate","csvAccept","templateAccept","label","align","side","importTemplateLabel","exportTemplateLabel","importCsvLabel","exportCsvLabel","clearLabel","setStaged","React","hoverPos","setHoverPos","flashWell","setFlashWell","csvPlates","setCsvPlates","internalActivePlateId","setInternalActivePlateId","merge","availablePlates","isPlateSelectionControlled","activePlate","activePlateBarcode","activePlateKey","isPlateScoped","barcodeField","previousActivePlateKey","scopedValues","toStoredWellKey","handlePlateChange","handleImportCsv","file","triage","nextCsvPlates","plateOptionsFromCsvTriage","nextSelection","stampActivePlateBarcode","commitScopedValues","nextScopedValues","doubleClickCycleField","field","f","applyStagedToSelection","base","clearWells","cycleWellField","currentValue","currentIndex","opt","nextOption","current","manifestColumns","column","barcode","Badge","showPlateSelector","canChangePlate","cn","Card","CardContent","PlateMapForm","CardHeader","CardTitle","PlateMapPlateSelector","CardAction","PlateMapActionsMenu","PlateMapGrid","PlateMapManifest"],"mappings":";;;;;;;;;;;AA2BA,MAAMA,KAA2B,MAC3BC,KAA8B,gBAC9BC,KAA+B;AAE9B,SAASC,GAAwBC,GAAsBC,GAAwB;AACpF,SAAO,GAAGD,CAAY,GAAGJ,EAAwB,GAAGK,CAAM;AAC5D;AAEA,SAASC,GAAuBC,GAAiBC,GAAiC;AAChF,QAAMC,IAAS,GAAGF,CAAO,GAAGP,EAAwB;AACpD,SAAOQ,EAAI,WAAWC,CAAM,IAAID,EAAI,MAAMC,EAAO,MAAM,IAAI;AAC7D;AA2GA,SAASC,GAAmCC,GAAyBC,GAAuB;AAC1F,SAAO,EAAE,GAAID,KAAa,CAAA,GAAW,GAAGC,EAAA;AAC1C;AAEA,SAASC,GACPC,GACAC,GACuB;AACvB,QAAMC,wBAAa,IAAA;AACnB,SAAAF,EAAe,QAAQ,CAACG,MAAUD,EAAO,IAAIC,EAAM,IAAIA,CAAK,CAAC,IAC5DF,KAAkB,CAAA,GAAI,QAAQ,CAACE,MAAUD,EAAO,IAAIC,EAAM,IAAIA,CAAK,CAAC,GAC9D,CAAC,GAAGD,EAAO,QAAQ;AAC5B;AAEA,SAASE,GACPC,GACAC,GACiC;AACjC,QAAMC,IAAgBF,EAAO,KAAK,CAACF,MA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B,UAAA,gBAAAvH,EAACwH,GAAA,EAAU,6BAAe,EAAA,CAC5B;AAAA,wBACCH,GAAA,EACC,UAAA,gBAAArH;AAAA,QAAC6H;AAAA,QAAA;AAAA,UACC,QAAQxC;AAAA,UACR,UAAUU;AAAA,UACV,SAASc;AAAA,UACT,QAAArG;AAAA,UACA,WAAAF;AAAA,UACA,mBAAAC;AAAA,UACA,YAAAI;AAAA,UACA,aAAAE;AAAA,UACA,YAAY6B;AAAA,UACZ,WAAWC;AAAA,QAAA;AAAA,MAAA,EACb,CACF;AAAA,IAAA,GACF;AAAA,IAECxB,IAAS,gBAAAnB,EAAC,OAAA,EAAI,WAAU,+BAA+B,aAAO,IAAS;AAAA,EAAA,GAC1E;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./WellMetadataForm.cjs"),x=require("../../ui/separator.cjs"),j=require("../../../lib/utils.cjs");function f({fields:t,value:a,onChange:l,selectionSize:o,onApply:s,onClear:n,applyLabel:i,clearLabel:c,extras:u,legend:r,formSlot:m,className:p}){return e.jsxs("div",{"data-slot":"plate-map-form",className:j.cn("flex flex-col gap-3",p),children:[m??e.jsx(d.WellMetadataForm,{fields:t,value:a,onChange:l,selectionSize:o,onApply:s,onClear:n,applyLabel:i,clearLabel:c,extras:u}),r?e.jsxs(e.Fragment,{children:[e.jsx(x.Separator,{}),r]}):null]})}exports.PlateMapForm=f;
2
+ //# sourceMappingURL=PlateMapForm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlateMapForm.cjs","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapForm.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { WellMetadataForm } from \"./WellMetadataForm\";\n\nimport type { WellField, WellRecord } from \"./types\";\n\nimport { Separator } from \"@/components/ui/separator\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface PlateMapFormProps<T extends WellRecord = WellRecord> {\n fields: WellField<T>[];\n /** Staged values applied across the current selection on Apply. */\n value: Partial<T>;\n onChange: (next: Partial<T>) => void;\n selectionSize: number;\n onApply: () => void;\n onClear: () => void;\n applyLabel?: string;\n clearLabel?: string;\n /** Helper slot rendered between the fields and the action row. */\n extras?: React.ReactNode;\n /** Legend block rendered beneath the form, separated by a divider. */\n legend?: React.ReactNode;\n /**\n * Fully replaces the built-in `WellMetadataForm` — e.g. a drag-and-drop\n * source palette. The legend slot still renders beneath the replacement.\n */\n formSlot?: React.ReactNode;\n className?: string;\n}\n\n/**\n * Card-agnostic metadata form panel. Renders the staged-value form (or a\n * caller-supplied `formSlot`) plus an optional legend. Bring your own\n * container — drop it bare into a sidebar, wrap it in a `Card`, or stack it\n * above the grid.\n */\nexport function PlateMapForm<T extends WellRecord = WellRecord>({\n fields,\n value,\n onChange,\n selectionSize,\n onApply,\n onClear,\n applyLabel,\n clearLabel,\n extras,\n legend,\n formSlot,\n className,\n}: PlateMapFormProps<T>) {\n return (\n <div data-slot=\"plate-map-form\" className={cn(\"flex flex-col gap-3\", className)}>\n {formSlot ?? (\n <WellMetadataForm<T>\n fields={fields}\n value={value}\n onChange={onChange}\n selectionSize={selectionSize}\n onApply={onApply}\n onClear={onClear}\n applyLabel={applyLabel}\n clearLabel={clearLabel}\n extras={extras}\n />\n )}\n {legend ? (\n <>\n <Separator />\n {legend}\n </>\n ) : null}\n </div>\n );\n}\n"],"names":["PlateMapForm","fields","value","onChange","selectionSize","onApply","onClear","applyLabel","clearLabel","extras","legend","formSlot","className","jsxs","cn","jsx","WellMetadataForm","Fragment","Separator"],"mappings":"iOAqCO,SAASA,EAAgD,CAC9D,OAAAC,EACA,MAAAC,EACA,SAAAC,EACA,cAAAC,EACA,QAAAC,EACA,QAAAC,EACA,WAAAC,EACA,WAAAC,EACA,OAAAC,EACA,OAAAC,EACA,SAAAC,EACA,UAAAC,CACF,EAAyB,CACvB,OACEC,OAAC,OAAI,YAAU,iBAAiB,UAAWC,EAAAA,GAAG,sBAAuBF,CAAS,EAC3E,SAAA,CAAAD,GACCI,EAAAA,IAACC,EAAAA,iBAAA,CACC,OAAAf,EACA,MAAAC,EACA,SAAAC,EACA,cAAAC,EACA,QAAAC,EACA,QAAAC,EACA,WAAAC,EACA,WAAAC,EACA,OAAAC,CAAA,CAAA,EAGHC,EACCG,EAAAA,KAAAI,WAAA,CACE,SAAA,CAAAF,EAAAA,IAACG,EAAAA,UAAA,EAAU,EACVR,CAAA,CAAA,CACH,EACE,IAAA,EACN,CAEJ"}
@@ -0,0 +1,43 @@
1
+ import { jsxs as o, jsx as a, Fragment as d } from "react/jsx-runtime";
2
+ import { WellMetadataForm as u } from "./WellMetadataForm.js";
3
+ import { Separator as F } from "../../ui/separator.js";
4
+ import { cn as h } from "../../../lib/utils.js";
5
+ function N({
6
+ fields: t,
7
+ value: m,
8
+ onChange: l,
9
+ selectionSize: e,
10
+ onApply: p,
11
+ onClear: f,
12
+ applyLabel: i,
13
+ clearLabel: n,
14
+ extras: c,
15
+ legend: r,
16
+ formSlot: s,
17
+ className: x
18
+ }) {
19
+ return /* @__PURE__ */ o("div", { "data-slot": "plate-map-form", className: h("flex flex-col gap-3", x), children: [
20
+ s ?? /* @__PURE__ */ a(
21
+ u,
22
+ {
23
+ fields: t,
24
+ value: m,
25
+ onChange: l,
26
+ selectionSize: e,
27
+ onApply: p,
28
+ onClear: f,
29
+ applyLabel: i,
30
+ clearLabel: n,
31
+ extras: c
32
+ }
33
+ ),
34
+ r ? /* @__PURE__ */ o(d, { children: [
35
+ /* @__PURE__ */ a(F, {}),
36
+ r
37
+ ] }) : null
38
+ ] });
39
+ }
40
+ export {
41
+ N as PlateMapForm
42
+ };
43
+ //# sourceMappingURL=PlateMapForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlateMapForm.js","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapForm.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { WellMetadataForm } from \"./WellMetadataForm\";\n\nimport type { WellField, WellRecord } from \"./types\";\n\nimport { Separator } from \"@/components/ui/separator\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface PlateMapFormProps<T extends WellRecord = WellRecord> {\n fields: WellField<T>[];\n /** Staged values applied across the current selection on Apply. */\n value: Partial<T>;\n onChange: (next: Partial<T>) => void;\n selectionSize: number;\n onApply: () => void;\n onClear: () => void;\n applyLabel?: string;\n clearLabel?: string;\n /** Helper slot rendered between the fields and the action row. */\n extras?: React.ReactNode;\n /** Legend block rendered beneath the form, separated by a divider. */\n legend?: React.ReactNode;\n /**\n * Fully replaces the built-in `WellMetadataForm` — e.g. a drag-and-drop\n * source palette. The legend slot still renders beneath the replacement.\n */\n formSlot?: React.ReactNode;\n className?: string;\n}\n\n/**\n * Card-agnostic metadata form panel. Renders the staged-value form (or a\n * caller-supplied `formSlot`) plus an optional legend. Bring your own\n * container — drop it bare into a sidebar, wrap it in a `Card`, or stack it\n * above the grid.\n */\nexport function PlateMapForm<T extends WellRecord = WellRecord>({\n fields,\n value,\n onChange,\n selectionSize,\n onApply,\n onClear,\n applyLabel,\n clearLabel,\n extras,\n legend,\n formSlot,\n className,\n}: PlateMapFormProps<T>) {\n return (\n <div data-slot=\"plate-map-form\" className={cn(\"flex flex-col gap-3\", className)}>\n {formSlot ?? (\n <WellMetadataForm<T>\n fields={fields}\n value={value}\n onChange={onChange}\n selectionSize={selectionSize}\n onApply={onApply}\n onClear={onClear}\n applyLabel={applyLabel}\n clearLabel={clearLabel}\n extras={extras}\n />\n )}\n {legend ? (\n <>\n <Separator />\n {legend}\n </>\n ) : null}\n </div>\n );\n}\n"],"names":["PlateMapForm","fields","value","onChange","selectionSize","onApply","onClear","applyLabel","clearLabel","extras","legend","formSlot","className","jsxs","cn","jsx","WellMetadataForm","Fragment","Separator"],"mappings":";;;;AAqCO,SAASA,EAAgD;AAAA,EAC9D,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,GAAyB;AACvB,SACE,gBAAAC,EAAC,SAAI,aAAU,kBAAiB,WAAWC,EAAG,uBAAuBF,CAAS,GAC3E,UAAA;AAAA,IAAAD,KACC,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,QAAAf;AAAA,QACA,OAAAC;AAAA,QACA,UAAAC;AAAA,QACA,eAAAC;AAAA,QACA,SAAAC;AAAA,QACA,SAAAC;AAAA,QACA,YAAAC;AAAA,QACA,YAAAC;AAAA,QACA,QAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,IAGHC,IACC,gBAAAG,EAAAI,GAAA,EACE,UAAA;AAAA,MAAA,gBAAAF,EAACG,GAAA,EAAU;AAAA,MACVR;AAAA,IAAA,EAAA,CACH,IACE;AAAA,EAAA,GACN;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),X=require("react"),Y=require("./PlatePaintGrid.cjs"),h=require("./wellGrid.cjs"),Z=require("../../ui/separator.cjs"),j=require("../../../lib/utils.cjs");function $(l){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return s.default=l,Object.freeze(s)}const ee=$(X);function te(l,s){return s.map(t=>{const n=l[t.key];if(n==null||n==="")return null;if(t.kind==="select")return(t.options??[]).find(o=>o.value===n)?.label??String(n);if(t.kind==="multiselect"){const i=Array.isArray(n)?n:[];return i.length===0?null:i.map(o=>(t.options??[]).find(c=>c.value===o)?.label??o).join(", ")}return t.kind==="boolean"?n?t.label:null:String(n)}).filter(Boolean)}function ne({format:l,rows:s,columns:t,values:n,selection:i,onSelectionChange:o,colorForWell:c,fields:m,renderHoverSummary:y,onHoveredWellChange:g,hoveredWellId:x,toolbar:f,hideSelectionControls:N=!1,selectAllLabel:P="Select all",deselectAllLabel:w="Deselect all",emptyWellFillColor:S,wellShape:k,framed:q,wrapWell:C,highlightedWellIds:O,onWellDoubleClick:A,selectionFillMode:G,flashWellId:H,flashWellKey:D,cellSize:M,autoScale:R,minCellSize:F,maxCellSize:T,groups:d,activeGroupId:_,onGroupClick:z,className:B}){const E=h.resolveDimensions(l,s,t),[I,J]=ee.useState(null),p=x!==void 0,a=p?x:I,K=()=>o(new Set(h.allPositions(E))),L=()=>o(new Set),u=a?n.get(a):void 0,Q=u&&m?te(u,m):[],U=a?y?.(u,a)??[a,...Q].join(" • "):" ",v=!N,V=!!f||v;return e.jsxs("div",{"data-slot":"plate-map-grid",className:j.cn("flex flex-col gap-1.5",B),children:[V?e.jsxs("div",{className:"flex flex-wrap items-center justify-start gap-3",children:[f,v?e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("button",{type:"button",className:"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline",onClick:K,children:P}),e.jsx("span",{className:"text-muted-foreground/60",children:"·"}),e.jsx("button",{type:"button",className:"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline",onClick:L,children:w})]}):null]}):null,e.jsx("div",{className:"h-5 text-xs text-muted-foreground",children:U}),e.jsx(Y.PlatePaintGrid,{format:l,rows:s,columns:t,values:n,selection:i,onSelectionChange:o,colorForWell:c,emptyWellFillColor:S,wellShape:k,framed:q,wrapWell:C,highlightedWellIds:O,onWellHover:r=>{p||J(r),g?.(r)},onWellDoubleClick:A,selectionFillMode:G,flashWellId:H,flashWellKey:D,cellSize:M,autoScale:R,minCellSize:F,maxCellSize:T}),d&&d.length>0?e.jsxs(e.Fragment,{children:[e.jsx(Z.Separator,{className:"mt-2"}),e.jsx("div",{className:"flex max-h-28 flex-wrap gap-3 overflow-y-auto pt-1",children:d.map(r=>{const W=r.id===_,b=r.count??r.wellIds?.length;return e.jsxs("button",{type:"button",disabled:r.disabled,onClick:()=>z?.(r),className:j.cn("flex w-16 flex-col items-center gap-1 rounded-md px-1 py-1 text-center text-xs transition-colors","text-muted-foreground hover:bg-muted/60",W&&"bg-muted text-foreground ring-1 ring-primary/40",r.disabled&&"pointer-events-none opacity-50"),title:r.label,children:[e.jsx("span",{className:"size-7 rounded-full border",style:{backgroundColor:r.color,borderColor:r.borderColor},"aria-hidden":!0}),e.jsx("span",{className:"w-full truncate text-foreground",children:r.label}),b===void 0?null:e.jsxs("span",{className:"text-[0.7rem] leading-none text-muted-foreground",children:[b," wells"]})]},r.id)})})]}):null]})}exports.PlateMapGrid=ne;
2
+ //# sourceMappingURL=PlateMapGrid.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlateMapGrid.cjs","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapGrid.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { PlatePaintGrid } from \"./PlatePaintGrid\";\nimport { allPositions, resolveDimensions } from \"./wellGrid\";\n\nimport type { WellShape } from \"./PlatePaintGrid\";\nimport type { PlateFormat, PlateMapGroupOption, WellField, WellId, WellRecord } from \"./types\";\n\nimport { Separator } from \"@/components/ui/separator\";\nimport { cn } from \"@/lib/utils\";\n\nfunction formatHoverFields<T extends WellRecord>(entry: T, fields: WellField<T>[]): string[] {\n return fields\n .map((f) => {\n const v = entry[f.key];\n if (v === undefined || v === null || v === \"\") return null;\n if (f.kind === \"select\") {\n const opt = (f.options ?? []).find((o) => o.value === v);\n return opt?.label ?? String(v);\n }\n if (f.kind === \"multiselect\") {\n const arr = Array.isArray(v) ? (v as string[]) : [];\n if (arr.length === 0) return null;\n return arr.map((item) => (f.options ?? []).find((o) => o.value === item)?.label ?? item).join(\", \");\n }\n if (f.kind === \"boolean\") {\n return v ? f.label : null;\n }\n return String(v);\n })\n .filter(Boolean) as string[];\n}\n\nexport interface PlateMapGridProps<T extends WellRecord = WellRecord> {\n format: PlateFormat;\n rows?: number;\n columns?: number;\n values: Map<WellId, T>;\n selection: Set<WellId>;\n onSelectionChange: (next: Set<WellId>) => void;\n /** Resolves the SVG fill color for a well. */\n colorForWell: (well: T | undefined, wellId: WellId) => string;\n /** Field schema used to build the default hover summary string. */\n fields?: WellField<T>[];\n /** Custom hover summary for the strip above the grid. */\n renderHoverSummary?: (well: T | undefined, wellId: WellId) => React.ReactNode;\n /** Fires whenever the currently hovered well changes (null on leave). */\n onHoveredWellChange?: (wellId: WellId | null) => void;\n /**\n * Controlled hovered well id. When provided, the panel reflects this value\n * instead of tracking hover internally — useful for syncing the hover\n * summary with external state (e.g. resetting it on a plate switch).\n */\n hoveredWellId?: WellId | null;\n /** Controls rendered to the left of the built-in select/deselect links. */\n toolbar?: React.ReactNode;\n /** Hide the built-in \"Select all\" / \"Deselect all\" links. */\n hideSelectionControls?: boolean;\n selectAllLabel?: string;\n deselectAllLabel?: string;\n /** Fill color for empty wells. Pass `null` to delegate empty wells to `colorForWell`. */\n emptyWellFillColor?: string | null;\n /** Well shape forwarded to `PlatePaintGrid`. Defaults to `\"rect\"`. */\n wellShape?: WellShape;\n /** When true, wraps the grid in a card-like plate frame (rounded + border + soft shadow). */\n framed?: boolean;\n /** Render-prop that places a node inside each absolute-positioned well cell. */\n wrapWell?: (wellId: WellId, cellSize: number) => React.ReactNode;\n /** Wells to highlight (e.g. when hovering a legend item externally). */\n highlightedWellIds?: ReadonlySet<WellId>;\n onWellDoubleClick?: (wellId: WellId) => void;\n selectionFillMode?: \"selection\" | \"well\";\n flashWellId?: WellId;\n flashWellKey?: number;\n /** Fixed well size. When unset, the grid grows with the available width. */\n cellSize?: number;\n autoScale?: boolean;\n minCellSize?: number;\n maxCellSize?: number;\n /** Optional grouped well shortcuts rendered under the grid. */\n groups?: PlateMapGroupOption[];\n activeGroupId?: string;\n onGroupClick?: (group: PlateMapGroupOption) => void;\n className?: string;\n}\n\n/**\n * Card-agnostic plate grid panel. Renders the selection toolbar, hover\n * summary, the interactive `PlatePaintGrid`, and optional group shortcuts —\n * and owns the ephemeral hover state internally. The plate title, plate\n * selector, and actions menu are intentionally NOT part of this panel; compose\n * `PlateMapPlateSelector` and `PlateMapActionsMenu` around it for full layout\n * freedom.\n */\nexport function PlateMapGrid<T extends WellRecord = WellRecord>({\n format,\n rows,\n columns,\n values,\n selection,\n onSelectionChange,\n colorForWell,\n fields,\n renderHoverSummary,\n onHoveredWellChange,\n hoveredWellId,\n toolbar,\n hideSelectionControls = false,\n selectAllLabel = \"Select all\",\n deselectAllLabel = \"Deselect all\",\n emptyWellFillColor,\n wellShape,\n framed,\n wrapWell,\n highlightedWellIds,\n onWellDoubleClick,\n selectionFillMode,\n flashWellId,\n flashWellKey,\n cellSize,\n autoScale,\n minCellSize,\n maxCellSize,\n groups,\n activeGroupId,\n onGroupClick,\n className,\n}: PlateMapGridProps<T>) {\n const dims = resolveDimensions(format, rows, columns);\n const [internalHoverPos, setInternalHoverPos] = React.useState<WellId | null>(null);\n const isHoverControlled = hoveredWellId !== undefined;\n const hoverPos = isHoverControlled ? hoveredWellId : internalHoverPos;\n\n const selectAll = () => onSelectionChange(new Set(allPositions(dims)));\n const deselectAll = () => onSelectionChange(new Set());\n\n const hoverEntry = hoverPos ? values.get(hoverPos) : undefined;\n const hoverFields = hoverEntry && fields ? formatHoverFields(hoverEntry, fields) : [];\n const hoverSummary = hoverPos\n ? (renderHoverSummary?.(hoverEntry, hoverPos) ?? [hoverPos, ...hoverFields].join(\" • \"))\n : \" \";\n\n const showSelectionControls = !hideSelectionControls;\n const showToolbarRow = !!toolbar || showSelectionControls;\n\n return (\n <div data-slot=\"plate-map-grid\" className={cn(\"flex flex-col gap-1.5\", className)}>\n {showToolbarRow ? (\n <div className=\"flex flex-wrap items-center justify-start gap-3\">\n {toolbar}\n {showSelectionControls ? (\n <div className=\"flex items-center gap-2 text-xs\">\n <button\n type=\"button\"\n className=\"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline\"\n onClick={selectAll}\n >\n {selectAllLabel}\n </button>\n <span className=\"text-muted-foreground/60\">·</span>\n <button\n type=\"button\"\n className=\"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline\"\n onClick={deselectAll}\n >\n {deselectAllLabel}\n </button>\n </div>\n ) : null}\n </div>\n ) : null}\n <div className=\"h-5 text-xs text-muted-foreground\">{hoverSummary}</div>\n <PlatePaintGrid\n format={format}\n rows={rows}\n columns={columns}\n values={values}\n selection={selection}\n onSelectionChange={onSelectionChange}\n colorForWell={colorForWell}\n emptyWellFillColor={emptyWellFillColor}\n wellShape={wellShape}\n framed={framed}\n wrapWell={wrapWell}\n highlightedWellIds={highlightedWellIds}\n onWellHover={(wellId) => {\n if (!isHoverControlled) setInternalHoverPos(wellId);\n onHoveredWellChange?.(wellId);\n }}\n onWellDoubleClick={onWellDoubleClick}\n selectionFillMode={selectionFillMode}\n flashWellId={flashWellId}\n flashWellKey={flashWellKey}\n cellSize={cellSize}\n autoScale={autoScale}\n minCellSize={minCellSize}\n maxCellSize={maxCellSize}\n />\n {groups && groups.length > 0 ? (\n <>\n <Separator className=\"mt-2\" />\n <div className=\"flex max-h-28 flex-wrap gap-3 overflow-y-auto pt-1\">\n {groups.map((group) => {\n const isActive = group.id === activeGroupId;\n const count = group.count ?? group.wellIds?.length;\n return (\n <button\n key={group.id}\n type=\"button\"\n disabled={group.disabled}\n onClick={() => onGroupClick?.(group)}\n className={cn(\n \"flex w-16 flex-col items-center gap-1 rounded-md px-1 py-1 text-center text-xs transition-colors\",\n \"text-muted-foreground hover:bg-muted/60\",\n isActive && \"bg-muted text-foreground ring-1 ring-primary/40\",\n group.disabled && \"pointer-events-none opacity-50\",\n )}\n title={group.label}\n >\n <span\n className=\"size-7 rounded-full border\"\n style={{\n backgroundColor: group.color,\n borderColor: group.borderColor,\n }}\n aria-hidden\n />\n <span className=\"w-full truncate text-foreground\">{group.label}</span>\n {count === undefined ? null : (\n <span className=\"text-[0.7rem] leading-none text-muted-foreground\">{count} wells</span>\n )}\n </button>\n );\n })}\n </div>\n </>\n ) : null}\n </div>\n );\n}\n"],"names":["formatHoverFields","entry","fields","f","v","arr","item","o","PlateMapGrid","format","rows","columns","values","selection","onSelectionChange","colorForWell","renderHoverSummary","onHoveredWellChange","hoveredWellId","toolbar","hideSelectionControls","selectAllLabel","deselectAllLabel","emptyWellFillColor","wellShape","framed","wrapWell","highlightedWellIds","onWellDoubleClick","selectionFillMode","flashWellId","flashWellKey","cellSize","autoScale","minCellSize","maxCellSize","groups","activeGroupId","onGroupClick","className","dims","resolveDimensions","internalHoverPos","setInternalHoverPos","React","isHoverControlled","hoverPos","selectAll","allPositions","deselectAll","hoverEntry","hoverFields","hoverSummary","showSelectionControls","showToolbarRow","jsxs","cn","jsx","PlatePaintGrid","wellId","Fragment","Separator","group","isActive","count"],"mappings":"yiBAWA,SAASA,GAAwCC,EAAUC,EAAkC,CAC3F,OAAOA,EACJ,IAAKC,GAAM,CACV,MAAMC,EAAIH,EAAME,EAAE,GAAG,EACrB,GAAuBC,GAAM,MAAQA,IAAM,GAAI,OAAO,KACtD,GAAID,EAAE,OAAS,SAEb,OADaA,EAAE,SAAW,CAAA,GAAI,KAAM,GAAM,EAAE,QAAUC,CAAC,GAC3C,OAAS,OAAOA,CAAC,EAE/B,GAAID,EAAE,OAAS,cAAe,CAC5B,MAAME,EAAM,MAAM,QAAQD,CAAC,EAAKA,EAAiB,CAAA,EACjD,OAAIC,EAAI,SAAW,EAAU,KACtBA,EAAI,IAAKC,IAAUH,EAAE,SAAW,CAAA,GAAI,KAAMI,GAAMA,EAAE,QAAUD,CAAI,GAAG,OAASA,CAAI,EAAE,KAAK,IAAI,CACpG,CACA,OAAIH,EAAE,OAAS,UACNC,EAAID,EAAE,MAAQ,KAEhB,OAAOC,CAAC,CACjB,CAAC,EACA,OAAO,OAAO,CACnB,CA+DO,SAASI,GAAgD,CAC9D,OAAAC,EACA,KAAAC,EACA,QAAAC,EACA,OAAAC,EACA,U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AAA,EAEbL,EAAAA,IAAC,OAAA,CAAK,UAAU,kCAAmC,WAAM,MAAM,EAC9DO,IAAU,OAAY,KACrBT,EAAAA,KAAC,OAAA,CAAK,UAAU,mDAAoD,SAAA,CAAAS,EAAM,QAAA,CAAA,CAAM,CAAA,CAAA,EAtB7EF,EAAM,EAAA,CA0BjB,CAAC,CAAA,CACH,CAAA,CAAA,CACF,EACE,IAAA,EACN,CAEJ"}
@@ -0,0 +1,154 @@
1
+ import { jsxs as o, jsx as l, Fragment as Y } from "react/jsx-runtime";
2
+ import * as Z from "react";
3
+ import { PlatePaintGrid as _ } from "./PlatePaintGrid.js";
4
+ import { allPositions as $, resolveDimensions as ee } from "./wellGrid.js";
5
+ import { Separator as te } from "../../ui/separator.js";
6
+ import { cn as y } from "../../../lib/utils.js";
7
+ function ne(a, d) {
8
+ return d.map((n) => {
9
+ const t = a[n.key];
10
+ if (t == null || t === "") return null;
11
+ if (n.kind === "select")
12
+ return (n.options ?? []).find((r) => r.value === t)?.label ?? String(t);
13
+ if (n.kind === "multiselect") {
14
+ const i = Array.isArray(t) ? t : [];
15
+ return i.length === 0 ? null : i.map((r) => (n.options ?? []).find((c) => c.value === r)?.label ?? r).join(", ");
16
+ }
17
+ return n.kind === "boolean" ? t ? n.label : null : String(t);
18
+ }).filter(Boolean);
19
+ }
20
+ function ae({
21
+ format: a,
22
+ rows: d,
23
+ columns: n,
24
+ values: t,
25
+ selection: i,
26
+ onSelectionChange: r,
27
+ colorForWell: c,
28
+ fields: f,
29
+ renderHoverSummary: N,
30
+ onHoveredWellChange: g,
31
+ hoveredWellId: x,
32
+ toolbar: p,
33
+ hideSelectionControls: w = !1,
34
+ selectAllLabel: k = "Select all",
35
+ deselectAllLabel: P = "Deselect all",
36
+ emptyWellFillColor: S,
37
+ wellShape: C,
38
+ framed: j,
39
+ wrapWell: A,
40
+ highlightedWellIds: H,
41
+ onWellDoubleClick: F,
42
+ selectionFillMode: D,
43
+ flashWellId: G,
44
+ flashWellKey: R,
45
+ cellSize: z,
46
+ autoScale: B,
47
+ minCellSize: E,
48
+ maxCellSize: M,
49
+ groups: m,
50
+ activeGroupId: T,
51
+ onGroupClick: q,
52
+ className: I
53
+ }) {
54
+ const J = ee(a, d, n), [K, L] = Z.useState(null), v = x !== void 0, s = v ? x : K, O = () => r(new Set($(J))), Q = () => r(/* @__PURE__ */ new Set()), u = s ? t.get(s) : void 0, U = u && f ? ne(u, f) : [], V = s ? N?.(u, s) ?? [s, ...U].join(" • ") : " ", h = !w, W = !!p || h;
55
+ return /* @__PURE__ */ o("div", { "data-slot": "plate-map-grid", className: y("flex flex-col gap-1.5", I), children: [
56
+ W ? /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center justify-start gap-3", children: [
57
+ p,
58
+ h ? /* @__PURE__ */ o("div", { className: "flex items-center gap-2 text-xs", children: [
59
+ /* @__PURE__ */ l(
60
+ "button",
61
+ {
62
+ type: "button",
63
+ className: "font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline",
64
+ onClick: O,
65
+ children: k
66
+ }
67
+ ),
68
+ /* @__PURE__ */ l("span", { className: "text-muted-foreground/60", children: "·" }),
69
+ /* @__PURE__ */ l(
70
+ "button",
71
+ {
72
+ type: "button",
73
+ className: "font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline",
74
+ onClick: Q,
75
+ children: P
76
+ }
77
+ )
78
+ ] }) : null
79
+ ] }) : null,
80
+ /* @__PURE__ */ l("div", { className: "h-5 text-xs text-muted-foreground", children: V }),
81
+ /* @__PURE__ */ l(
82
+ _,
83
+ {
84
+ format: a,
85
+ rows: d,
86
+ columns: n,
87
+ values: t,
88
+ selection: i,
89
+ onSelectionChange: r,
90
+ colorForWell: c,
91
+ emptyWellFillColor: S,
92
+ wellShape: C,
93
+ framed: j,
94
+ wrapWell: A,
95
+ highlightedWellIds: H,
96
+ onWellHover: (e) => {
97
+ v || L(e), g?.(e);
98
+ },
99
+ onWellDoubleClick: F,
100
+ selectionFillMode: D,
101
+ flashWellId: G,
102
+ flashWellKey: R,
103
+ cellSize: z,
104
+ autoScale: B,
105
+ minCellSize: E,
106
+ maxCellSize: M
107
+ }
108
+ ),
109
+ m && m.length > 0 ? /* @__PURE__ */ o(Y, { children: [
110
+ /* @__PURE__ */ l(te, { className: "mt-2" }),
111
+ /* @__PURE__ */ l("div", { className: "flex max-h-28 flex-wrap gap-3 overflow-y-auto pt-1", children: m.map((e) => {
112
+ const X = e.id === T, b = e.count ?? e.wellIds?.length;
113
+ return /* @__PURE__ */ o(
114
+ "button",
115
+ {
116
+ type: "button",
117
+ disabled: e.disabled,
118
+ onClick: () => q?.(e),
119
+ className: y(
120
+ "flex w-16 flex-col items-center gap-1 rounded-md px-1 py-1 text-center text-xs transition-colors",
121
+ "text-muted-foreground hover:bg-muted/60",
122
+ X && "bg-muted text-foreground ring-1 ring-primary/40",
123
+ e.disabled && "pointer-events-none opacity-50"
124
+ ),
125
+ title: e.label,
126
+ children: [
127
+ /* @__PURE__ */ l(
128
+ "span",
129
+ {
130
+ className: "size-7 rounded-full border",
131
+ style: {
132
+ backgroundColor: e.color,
133
+ borderColor: e.borderColor
134
+ },
135
+ "aria-hidden": !0
136
+ }
137
+ ),
138
+ /* @__PURE__ */ l("span", { className: "w-full truncate text-foreground", children: e.label }),
139
+ b === void 0 ? null : /* @__PURE__ */ o("span", { className: "text-[0.7rem] leading-none text-muted-foreground", children: [
140
+ b,
141
+ " wells"
142
+ ] })
143
+ ]
144
+ },
145
+ e.id
146
+ );
147
+ }) })
148
+ ] }) : null
149
+ ] });
150
+ }
151
+ export {
152
+ ae as PlateMapGrid
153
+ };
154
+ //# sourceMappingURL=PlateMapGrid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlateMapGrid.js","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapGrid.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { PlatePaintGrid } from \"./PlatePaintGrid\";\nimport { allPositions, resolveDimensions } from \"./wellGrid\";\n\nimport type { WellShape } from \"./PlatePaintGrid\";\nimport type { PlateFormat, PlateMapGroupOption, WellField, WellId, WellRecord } from \"./types\";\n\nimport { Separator } from \"@/components/ui/separator\";\nimport { cn } from \"@/lib/utils\";\n\nfunction formatHoverFields<T extends WellRecord>(entry: T, fields: WellField<T>[]): string[] {\n return fields\n .map((f) => {\n const v = entry[f.key];\n if (v === undefined || v === null || v === \"\") return null;\n if (f.kind === \"select\") {\n const opt = (f.options ?? []).find((o) => o.value === v);\n return opt?.label ?? String(v);\n }\n if (f.kind === \"multiselect\") {\n const arr = Array.isArray(v) ? (v as string[]) : [];\n if (arr.length === 0) return null;\n return arr.map((item) => (f.options ?? []).find((o) => o.value === item)?.label ?? item).join(\", \");\n }\n if (f.kind === \"boolean\") {\n return v ? f.label : null;\n }\n return String(v);\n })\n .filter(Boolean) as string[];\n}\n\nexport interface PlateMapGridProps<T extends WellRecord = WellRecord> {\n format: PlateFormat;\n rows?: number;\n columns?: number;\n values: Map<WellId, T>;\n selection: Set<WellId>;\n onSelectionChange: (next: Set<WellId>) => void;\n /** Resolves the SVG fill color for a well. */\n colorForWell: (well: T | undefined, wellId: WellId) => string;\n /** Field schema used to build the default hover summary string. */\n fields?: WellField<T>[];\n /** Custom hover summary for the strip above the grid. */\n renderHoverSummary?: (well: T | undefined, wellId: WellId) => React.ReactNode;\n /** Fires whenever the currently hovered well changes (null on leave). */\n onHoveredWellChange?: (wellId: WellId | null) => void;\n /**\n * Controlled hovered well id. When provided, the panel reflects this value\n * instead of tracking hover internally — useful for syncing the hover\n * summary with external state (e.g. resetting it on a plate switch).\n */\n hoveredWellId?: WellId | null;\n /** Controls rendered to the left of the built-in select/deselect links. */\n toolbar?: React.ReactNode;\n /** Hide the built-in \"Select all\" / \"Deselect all\" links. */\n hideSelectionControls?: boolean;\n selectAllLabel?: string;\n deselectAllLabel?: string;\n /** Fill color for empty wells. Pass `null` to delegate empty wells to `colorForWell`. */\n emptyWellFillColor?: string | null;\n /** Well shape forwarded to `PlatePaintGrid`. Defaults to `\"rect\"`. */\n wellShape?: WellShape;\n /** When true, wraps the grid in a card-like plate frame (rounded + border + soft shadow). */\n framed?: boolean;\n /** Render-prop that places a node inside each absolute-positioned well cell. */\n wrapWell?: (wellId: WellId, cellSize: number) => React.ReactNode;\n /** Wells to highlight (e.g. when hovering a legend item externally). */\n highlightedWellIds?: ReadonlySet<WellId>;\n onWellDoubleClick?: (wellId: WellId) => void;\n selectionFillMode?: \"selection\" | \"well\";\n flashWellId?: WellId;\n flashWellKey?: number;\n /** Fixed well size. When unset, the grid grows with the available width. */\n cellSize?: number;\n autoScale?: boolean;\n minCellSize?: number;\n maxCellSize?: number;\n /** Optional grouped well shortcuts rendered under the grid. */\n groups?: PlateMapGroupOption[];\n activeGroupId?: string;\n onGroupClick?: (group: PlateMapGroupOption) => void;\n className?: string;\n}\n\n/**\n * Card-agnostic plate grid panel. Renders the selection toolbar, hover\n * summary, the interactive `PlatePaintGrid`, and optional group shortcuts —\n * and owns the ephemeral hover state internally. The plate title, plate\n * selector, and actions menu are intentionally NOT part of this panel; compose\n * `PlateMapPlateSelector` and `PlateMapActionsMenu` around it for full layout\n * freedom.\n */\nexport function PlateMapGrid<T extends WellRecord = WellRecord>({\n format,\n rows,\n columns,\n values,\n selection,\n onSelectionChange,\n colorForWell,\n fields,\n renderHoverSummary,\n onHoveredWellChange,\n hoveredWellId,\n toolbar,\n hideSelectionControls = false,\n selectAllLabel = \"Select all\",\n deselectAllLabel = \"Deselect all\",\n emptyWellFillColor,\n wellShape,\n framed,\n wrapWell,\n highlightedWellIds,\n onWellDoubleClick,\n selectionFillMode,\n flashWellId,\n flashWellKey,\n cellSize,\n autoScale,\n minCellSize,\n maxCellSize,\n groups,\n activeGroupId,\n onGroupClick,\n className,\n}: PlateMapGridProps<T>) {\n const dims = resolveDimensions(format, rows, columns);\n const [internalHoverPos, setInternalHoverPos] = React.useState<WellId | null>(null);\n const isHoverControlled = hoveredWellId !== undefined;\n const hoverPos = isHoverControlled ? hoveredWellId : internalHoverPos;\n\n const selectAll = () => onSelectionChange(new Set(allPositions(dims)));\n const deselectAll = () => onSelectionChange(new Set());\n\n const hoverEntry = hoverPos ? values.get(hoverPos) : undefined;\n const hoverFields = hoverEntry && fields ? formatHoverFields(hoverEntry, fields) : [];\n const hoverSummary = hoverPos\n ? (renderHoverSummary?.(hoverEntry, hoverPos) ?? [hoverPos, ...hoverFields].join(\" • \"))\n : \" \";\n\n const showSelectionControls = !hideSelectionControls;\n const showToolbarRow = !!toolbar || showSelectionControls;\n\n return (\n <div data-slot=\"plate-map-grid\" className={cn(\"flex flex-col gap-1.5\", className)}>\n {showToolbarRow ? (\n <div className=\"flex flex-wrap items-center justify-start gap-3\">\n {toolbar}\n {showSelectionControls ? (\n <div className=\"flex items-center gap-2 text-xs\">\n <button\n type=\"button\"\n className=\"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline\"\n onClick={selectAll}\n >\n {selectAllLabel}\n </button>\n <span className=\"text-muted-foreground/60\">·</span>\n <button\n type=\"button\"\n className=\"font-medium text-primary underline-offset-2 hover:text-primary/80 hover:underline\"\n onClick={deselectAll}\n >\n {deselectAllLabel}\n </button>\n </div>\n ) : null}\n </div>\n ) : null}\n <div className=\"h-5 text-xs text-muted-foreground\">{hoverSummary}</div>\n <PlatePaintGrid\n format={format}\n rows={rows}\n columns={columns}\n values={values}\n selection={selection}\n onSelectionChange={onSelectionChange}\n colorForWell={colorForWell}\n emptyWellFillColor={emptyWellFillColor}\n wellShape={wellShape}\n framed={framed}\n wrapWell={wrapWell}\n highlightedWellIds={highlightedWellIds}\n onWellHover={(wellId) => {\n if (!isHoverControlled) setInternalHoverPos(wellId);\n onHoveredWellChange?.(wellId);\n }}\n onWellDoubleClick={onWellDoubleClick}\n selectionFillMode={selectionFillMode}\n flashWellId={flashWellId}\n flashWellKey={flashWellKey}\n cellSize={cellSize}\n autoScale={autoScale}\n minCellSize={minCellSize}\n maxCellSize={maxCellSize}\n />\n {groups && groups.length > 0 ? (\n <>\n <Separator className=\"mt-2\" />\n <div className=\"flex max-h-28 flex-wrap gap-3 overflow-y-auto pt-1\">\n {groups.map((group) => {\n const isActive = group.id === activeGroupId;\n const count = group.count ?? group.wellIds?.length;\n return (\n <button\n key={group.id}\n type=\"button\"\n disabled={group.disabled}\n onClick={() => onGroupClick?.(group)}\n className={cn(\n \"flex w-16 flex-col items-center gap-1 rounded-md px-1 py-1 text-center text-xs transition-colors\",\n \"text-muted-foreground hover:bg-muted/60\",\n isActive && \"bg-muted text-foreground ring-1 ring-primary/40\",\n group.disabled && \"pointer-events-none opacity-50\",\n )}\n title={group.label}\n >\n <span\n className=\"size-7 rounded-full border\"\n style={{\n backgroundColor: group.color,\n borderColor: group.borderColor,\n }}\n aria-hidden\n />\n <span className=\"w-full truncate text-foreground\">{group.label}</span>\n {count === undefined ? null : (\n <span className=\"text-[0.7rem] leading-none text-muted-foreground\">{count} wells</span>\n )}\n </button>\n );\n })}\n </div>\n </>\n ) : null}\n </div>\n );\n}\n"],"names":["formatHoverFields","entry","fields","f","v","o","arr","item","PlateMapGrid","format","rows","columns","values","selection","onSelectionChange","colorForWell","renderHoverSummary","onHoveredWellChange","hoveredWellId","toolbar","hideSelectionControls","selectAllLabel","deselectAllLabel","emptyWellFillColor","wellShape","framed","wrapWell","highlightedWellIds","onWellDoubleClick","selectionFillMode","flashWellId","flashWellKey","cellSize","autoScale","minCellSize","maxCellSize","groups","activeGroupId","onGroupClick","className","dims","resolveDimensions","internalHoverPos","setInternalHoverPos","React","isHoverControlled","hoverPos","selectAll","allPositions","deselectAll","hoverEntry","hoverFields","hoverSummary","showSelectionControls","showToolbarRow","jsxs","cn","jsx","PlatePaintGrid","wellId","Fragment","Separator","group","isActive","count"],"mappings":";;;;;;AAWA,SAASA,GAAwCC,GAAUC,GAAkC;AAC3F,SAAOA,EACJ,IAAI,CAACC,MAAM;AACV,UAAMC,IAAIH,EAAME,EAAE,GAAG;AACrB,QAAuBC,KAAM,QAAQA,MAAM,GAAI,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,cAAA;AAAA,cAEb,gBAAAL,EAAC,QAAA,EAAK,WAAU,mCAAmC,YAAM,OAAM;AAAA,cAC9DO,MAAU,SAAY,OACrB,gBAAAT,EAAC,QAAA,EAAK,WAAU,oDAAoD,UAAA;AAAA,gBAAAS;AAAA,gBAAM;AAAA,cAAA,EAAA,CAAM;AAAA,YAAA;AAAA,UAAA;AAAA,UAtB7EF,EAAM;AAAA,QAAA;AAAA,MA0BjB,CAAC,EAAA,CACH;AAAA,IAAA,EAAA,CACF,IACE;AAAA,EAAA,GACN;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("./WellManifestTable.cjs"),p=require("../../../lib/utils.cjs");function b({values:t,onChange:l,columns:s,fields:n,selection:i,onSelectionChange:r,emptyEntry:u,isPopulated:c,filterable:o,groupable:f,pageSize:d,pageSizeOptions:m,title:a,className:x}){return e.jsxs("div",{"data-slot":"plate-map-manifest",className:p.cn("flex flex-col gap-3",x),children:[a?e.jsx("div",{className:"text-base leading-snug font-medium",children:a}):null,e.jsx(M.WellManifestTable,{values:t,onChange:l,columns:s,fields:n,selection:i,onSelectionChange:r,emptyEntry:u,isPopulated:c,filterable:o,groupable:f,pageSize:d,pageSizeOptions:m})]})}exports.PlateMapManifest=b;
2
+ //# sourceMappingURL=PlateMapManifest.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlateMapManifest.cjs","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapManifest.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { WellManifestTable } from \"./WellManifestTable\";\n\nimport type { WellColumn, WellField, WellId, WellRecord } from \"./types\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface PlateMapManifestProps<T extends WellRecord = WellRecord> {\n values: Map<WellId, T>;\n onChange: (next: Map<WellId, T>) => void;\n columns: WellColumn<T>[];\n fields?: WellField<T>[];\n selection?: Set<WellId>;\n onSelectionChange?: (next: Set<WellId>) => void;\n /** Builds an empty record when a manifest row is freshly created. */\n emptyEntry: (id: WellId) => T;\n /** Filter for the manifest's \"hide empty\" mode. */\n isPopulated?: (row: T) => boolean;\n /** Enables the filter popover on the manifest table. */\n filterable?: boolean;\n /** Enables the group-by selector on the manifest table. */\n groupable?: boolean;\n pageSize?: number;\n pageSizeOptions?: number[];\n /** Optional heading rendered above the table. Omit for a bare table. */\n title?: React.ReactNode;\n className?: string;\n}\n\n/**\n * Card-agnostic sample-manifest panel. A thin wrapper over `WellManifestTable`\n * with an optional heading and no width constraint of its own, so it can span\n * the full screen width or sit inside any container the caller chooses.\n */\nexport function PlateMapManifest<T extends WellRecord = WellRecord>({\n values,\n onChange,\n columns,\n fields,\n selection,\n onSelectionChange,\n emptyEntry,\n isPopulated,\n filterable,\n groupable,\n pageSize,\n pageSizeOptions,\n title,\n className,\n}: PlateMapManifestProps<T>) {\n return (\n <div data-slot=\"plate-map-manifest\" className={cn(\"flex flex-col gap-3\", className)}>\n {title ? <div className=\"text-base leading-snug font-medium\">{title}</div> : null}\n <WellManifestTable<T>\n values={values}\n onChange={onChange}\n columns={columns}\n fields={fields}\n selection={selection}\n onSelectionChange={onSelectionChange}\n emptyEntry={emptyEntry}\n isPopulated={isPopulated}\n filterable={filterable}\n groupable={groupable}\n pageSize={pageSize}\n pageSizeOptions={pageSizeOptions}\n />\n </div>\n );\n}\n"],"names":["PlateMapManifest","values","onChange","columns","fields","selection","onSelectionChange","emptyEntry","isPopulated","filterable","groupable","pageSize","pageSizeOptions","title","className","jsxs","cn","jsx","WellManifestTable"],"mappings":"8LAmCO,SAASA,EAAoD,CAClE,OAAAC,EACA,SAAAC,EACA,QAAAC,EACA,OAAAC,EACA,UAAAC,EACA,kBAAAC,EACA,WAAAC,EACA,YAAAC,EACA,WAAAC,EACA,UAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,MAAAC,EACA,UAAAC,CACF,EAA6B,CAC3B,OACEC,OAAC,OAAI,YAAU,qBAAqB,UAAWC,EAAAA,GAAG,sBAAuBF,CAAS,EAC/E,SAAA,CAAAD,EAAQI,EAAAA,IAAC,MAAA,CAAI,UAAU,qCAAsC,WAAM,EAAS,KAC7EA,EAAAA,IAACC,EAAAA,kBAAA,CACC,OAAAjB,EACA,SAAAC,EACA,QAAAC,EACA,OAAAC,EACA,UAAAC,EACA,kBAAAC,EACA,WAAAC,EACA,YAAAC,EACA,WAAAC,EACA,UAAAC,EACA,SAAAC,EACA,gBAAAC,CAAA,CAAA,CACF,EACF,CAEJ"}
@@ -0,0 +1,44 @@
1
+ import { jsxs as u, jsx as a } from "react/jsx-runtime";
2
+ import { WellManifestTable as g } from "./WellManifestTable.js";
3
+ import { cn as M } from "../../../lib/utils.js";
4
+ function v({
5
+ values: l,
6
+ onChange: t,
7
+ columns: n,
8
+ fields: s,
9
+ selection: i,
10
+ onSelectionChange: m,
11
+ emptyEntry: o,
12
+ isPopulated: r,
13
+ filterable: f,
14
+ groupable: p,
15
+ pageSize: c,
16
+ pageSizeOptions: d,
17
+ title: e,
18
+ className: x
19
+ }) {
20
+ return /* @__PURE__ */ u("div", { "data-slot": "plate-map-manifest", className: M("flex flex-col gap-3", x), children: [
21
+ e ? /* @__PURE__ */ a("div", { className: "text-base leading-snug font-medium", children: e }) : null,
22
+ /* @__PURE__ */ a(
23
+ g,
24
+ {
25
+ values: l,
26
+ onChange: t,
27
+ columns: n,
28
+ fields: s,
29
+ selection: i,
30
+ onSelectionChange: m,
31
+ emptyEntry: o,
32
+ isPopulated: r,
33
+ filterable: f,
34
+ groupable: p,
35
+ pageSize: c,
36
+ pageSizeOptions: d
37
+ }
38
+ )
39
+ ] });
40
+ }
41
+ export {
42
+ v as PlateMapManifest
43
+ };
44
+ //# sourceMappingURL=PlateMapManifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlateMapManifest.js","sources":["../../../../src/components/composed/PlateMapEditor/PlateMapManifest.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { WellManifestTable } from \"./WellManifestTable\";\n\nimport type { WellColumn, WellField, WellId, WellRecord } from \"./types\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface PlateMapManifestProps<T extends WellRecord = WellRecord> {\n values: Map<WellId, T>;\n onChange: (next: Map<WellId, T>) => void;\n columns: WellColumn<T>[];\n fields?: WellField<T>[];\n selection?: Set<WellId>;\n onSelectionChange?: (next: Set<WellId>) => void;\n /** Builds an empty record when a manifest row is freshly created. */\n emptyEntry: (id: WellId) => T;\n /** Filter for the manifest's \"hide empty\" mode. */\n isPopulated?: (row: T) => boolean;\n /** Enables the filter popover on the manifest table. */\n filterable?: boolean;\n /** Enables the group-by selector on the manifest table. */\n groupable?: boolean;\n pageSize?: number;\n pageSizeOptions?: number[];\n /** Optional heading rendered above the table. Omit for a bare table. */\n title?: React.ReactNode;\n className?: string;\n}\n\n/**\n * Card-agnostic sample-manifest panel. A thin wrapper over `WellManifestTable`\n * with an optional heading and no width constraint of its own, so it can span\n * the full screen width or sit inside any container the caller chooses.\n */\nexport function PlateMapManifest<T extends WellRecord = WellRecord>({\n values,\n onChange,\n columns,\n fields,\n selection,\n onSelectionChange,\n emptyEntry,\n isPopulated,\n filterable,\n groupable,\n pageSize,\n pageSizeOptions,\n title,\n className,\n}: PlateMapManifestProps<T>) {\n return (\n <div data-slot=\"plate-map-manifest\" className={cn(\"flex flex-col gap-3\", className)}>\n {title ? <div className=\"text-base leading-snug font-medium\">{title}</div> : null}\n <WellManifestTable<T>\n values={values}\n onChange={onChange}\n columns={columns}\n fields={fields}\n selection={selection}\n onSelectionChange={onSelectionChange}\n emptyEntry={emptyEntry}\n isPopulated={isPopulated}\n filterable={filterable}\n groupable={groupable}\n pageSize={pageSize}\n pageSizeOptions={pageSizeOptions}\n />\n </div>\n );\n}\n"],"names":["PlateMapManifest","values","onChange","columns","fields","selection","onSelectionChange","emptyEntry","isPopulated","filterable","groupable","pageSize","pageSizeOptions","title","className","jsxs","cn","jsx","WellManifestTable"],"mappings":";;;AAmCO,SAASA,EAAoD;AAAA,EAClE,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AACF,GAA6B;AAC3B,SACE,gBAAAC,EAAC,SAAI,aAAU,sBAAqB,WAAWC,EAAG,uBAAuBF,CAAS,GAC/E,UAAA;AAAA,IAAAD,IAAQ,gBAAAI,EAAC,OAAA,EAAI,WAAU,sCAAsC,aAAM,IAAS;AAAA,IAC7E,gBAAAA;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,QAAAjB;AAAA,QACA,UAAAC;AAAA,QACA,SAAAC;AAAA,QACA,QAAAC;AAAA,QACA,WAAAC;AAAA,QACA,mBAAAC;AAAA,QACA,YAAAC;AAAA,QACA,aAAAC;AAAA,QACA,YAAAC;AAAA,QACA,WAAAC;AAAA,QACA,UAAAC;AAAA,QACA,iBAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}