Skip to content

Commit 1312140

Browse files
committed
cp dines
1 parent 2a8b28a commit 1312140

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

src/components/ResourcePicker.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,27 @@ export function ResourcePicker<T>({
328328
keyExtractor={config.getItemId}
329329
selectedIndex={selectedIndex}
330330
title={`${config.title.toLowerCase()}[${totalCount}]${config.mode === "multi" ? ` (${selectedIds.size} selected)` : ""}`}
331-
columns={config.columns}
331+
columns={
332+
config.mode === "multi"
333+
? [
334+
// Prepend checkbox column for multi-select mode
335+
createComponentColumn<T>(
336+
"_selection",
337+
"",
338+
(row) => {
339+
const isChecked = selectedIds.has(config.getItemId(row));
340+
return (
341+
<Text color={isChecked ? colors.success : colors.textDim}>
342+
{isChecked ? figures.checkboxOn : figures.checkboxOff}{" "}
343+
</Text>
344+
);
345+
},
346+
{ width: 3 },
347+
),
348+
...config.columns,
349+
]
350+
: config.columns
351+
}
332352
emptyState={
333353
<Text color={colors.textDim}>
334354
{figures.info} {config.emptyMessage || "No items found"}
@@ -356,13 +376,20 @@ export function ResourcePicker<T>({
356376
const id = config.getItemId(item);
357377
const label = config.getItemLabel(item);
358378
const status = config.getItemStatus?.(item);
379+
const isChecked = selectedIds.has(id);
359380

360381
return (
361382
<Box key={id}>
362383
<Text color={isHighlighted ? colors.primary : colors.textDim}>
363384
{isHighlighted ? figures.pointer : " "}
364385
</Text>
365386
<Text> </Text>
387+
{/* Show checkbox for multi-select mode */}
388+
{config.mode === "multi" && (
389+
<Text color={isChecked ? colors.success : colors.textDim}>
390+
{isChecked ? figures.checkboxOn : figures.checkboxOff}{" "}
391+
</Text>
392+
)}
366393
<Text
367394
color={colors.text}
368395
bold={isHighlighted}

0 commit comments

Comments
 (0)