Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: add options to kanban to support scan-only jobs
Brad Barbin510b72e8d99e
diff --git a/apps/erp/app/components/Form/Item.tsx b/apps/erp/app/components/Form/Item.tsxindex 6138154121..91784f41b2 100644--- a/apps/erp/app/components/Form/Item.tsx+++ b/apps/erp/app/components/Form/Item.tsx@@ -342,7 +342,6 @@ const Item = ({unitOfMeasureCode: "EA",defaultMethodType:props?.replenishmentSystem === "Buy" ? "Pick" : "Make",- active: true,unitCost: 0,lotSize: 0,tags: [],@@ -365,7 +364,6 @@ const Item = ({unitOfMeasureCode: "EA",replenishmentSystem: "Buy",defaultMethodType: "Buy",- active: true,unitCost: 0,tags: [],}}@@ -389,7 +387,6 @@ const Item = ({unitOfMeasureCode: "EA",replenishmentSystem: "Buy",defaultMethodType: "Buy",- active: true,unitCost: 0,tags: [],}}@@ -414,7 +411,6 @@ const Item = ({replenishmentSystem: props?.replenishmentSystem ?? "Buy",defaultMethodType:props?.replenishmentSystem === "Buy" ? "Pick" : "Make",- active: true,unitCost: 0,tags: [],}}diff --git a/apps/erp/app/components/Form/SequenceOrCustomId.tsx b/apps/erp/app/components/Form/SequenceOrCustomId.tsxindex 4f2a6d3d69..847365373d 100644--- a/apps/erp/app/components/Form/SequenceOrCustomId.tsx+++ b/apps/erp/app/components/Form/SequenceOrCustomId.tsx@@ -17,6 +17,7 @@ type SequenceOrCustomIdProps = InputProps & {name: string;label: string;table: string;+ placeholder?: string;isOptional?: boolean;helperText?: string;};@@ -24,55 +25,68 @@ type SequenceOrCustomIdProps = InputProps & {const SequenceOrCustomId = forwardRef<HTMLInputElement,SequenceOrCustomIdProps->(({ name, label, table, isOptional = false, helperText, ...rest }, ref) => {- const [isCustom, setIsCustom] = useState(false);- const { getInputProps, error } = useField(name);+>(+ (+ {+ name,+ label,+ table,+ isOptional = false,+ helperText,+ placeholder = "Next Sequence",+ ...rest+ },+ ref+ ) => {+ const { getInputProps, error } = useField(name);+ const [isCustom, setIsCustom] = useState(!!getInputProps()?.defaultValue);- return (- <FormControl isInvalid={!!error}>- {label && (- <FormLabel htmlFor={name} isOptional={isOptional}>- {label}- </FormLabel>- )}- <div className="flex flex-grow items-start min-w-0 relative">- {isCustom ? (- <Input- ref={ref}- {...getInputProps({- id: name,- placeholder: `Custom ${label}`,- ...rest,- })}- className="w-full"- />- ) : (- <Button- size="md"- variant="secondary"- className="flex-grow bg-muted text-muted-foreground justify-start pr-4 h-10 w-full hover:scale-100 focus-visible:scale-100"- >- Next Sequence- </Button>+ return (+ <FormControl isInvalid={!!error}>+ {label && (+ <FormLabel htmlFor={name} isOptional={isOptional}>+ {label}+ </FormLabel>)}- <IconButton- aria-label="Toggle"- className={cn(- "bg-card absolute right-0 top-0",- "flex-shrink-0 h-10 w-10 px-3 rounded-l-none before:rounded-l-none border-none -ml-px shadow-button-base"+ <div className="flex flex-grow items-start min-w-0 relative">+ {isCustom ? (+ <Input+ ref={ref}+ {...getInputProps({+ id: name,+ placeholder: `Custom ${label}`,+ ...rest,+ })}+ className="w-full"+ />+ ) : (+ <Button+ size="md"+ variant="secondary"+ className="flex-grow bg-muted text-muted-foreground justify-start pr-4 h-10 w-full hover:scale-100 focus-visible:scale-100"+ >+ {placeholder}+ </Button>)}- icon={isCustom ? <LuToggleLeft /> : <LuToggleRight />}- variant="secondary"- size="lg"- onClick={() => setIsCustom(!isCustom)}- />- </div>+ <IconButton+ aria-label="Toggle"+ className={cn(+ "bg-card absolute right-0 top-0",+ "flex-shrink-0 h-10 w-10 px-3 rounded-l-none before:rounded-l-none border-none -ml-px shadow-button-base"+ )}+ icon={isCustom ? <LuToggleLeft /> : <LuToggleRight />}+ variant="secondary"+ size="lg"+ onClick={() => setIsCustom(!isCustom)}+ />+ </div>- {helperText && <FormHelperText>{helperText}</FormHelperText>}- {error && <FormErrorMessage>{error}</FormErrorMessage>}- </FormControl>- );-});+ {helperText && <FormHelperText>{helperText}</FormHelperText>}+ {error && <FormErrorMessage>{error}</FormErrorMessage>}+ </FormControl>+ );+ }+);SequenceOrCustomId.displayName = "SequenceOrCustomId";diff --git a/apps/erp/app/modules/inventory/inventory.models.ts b/apps/erp/app/modules/inventory/inventory.models.tsindex d72aab1570..ea5873c875 100644--- a/apps/erp/app/modules/inventory/inventory.models.ts+++ b/apps/erp/app/modules/inventory/inventory.models.ts@@ -45,6 +45,12 @@ export const itemLedgerDocumentTypes = ["Direct Transfer",] as const;+export enum KanbanOutput {+ Label,+ QRCode,+ Link,+}+export const trackedEntityStatus = ["Available","Consumed",@@ -123,6 +129,8 @@ export const kanbanValidator = zitemId: z.string().min(1, { message: "Item is required" }),replenishmentSystem: z.enum(replenishmentSystemTypes).default("Buy"),autoRelease: zfd.checkbox(),+ autoStartJob: zfd.checkbox(),+ completedBarcodeOverride: zfd.text(z.string().optional()),quantity: zfd.numeric(z.number().int().min(1, { message: "Quantity must be at least 1" })),diff --git a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsxindex 87c3a21e5a..bd3bf7b8f9 100644--- a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx+++ b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx@@ -21,6 +21,7 @@ import {Item,Location,Number,+ SequenceOrCustomId,Shelf,Submit,Supplier,@@ -155,6 +156,14 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {const [locationId, setLocationId] = useState<string>(initialValues.locationId || "");++ const [autoRelease, setAutoRelease] = useState<boolean>(+ initialValues.autoRelease || false+ );+ const [autoStartJob, setAutoStartJob] = useState<boolean>(+ initialValues.autoStartJob || false+ );+const onLocationChange = (value: { value: string } | null) => {setLocationId(value?.value || "");setShelfId(null);@@ -278,15 +287,38 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {/>{selectedReplenishmentSystem === "Make" && (- <Boolean- name="autoRelease"- label="Auto Release"- description={- selectedReplenishmentSystem === "Make"- ? "Automatically release the job when the kanban is scanned."- : undefined- }- />+ <>+ <Boolean+ name="autoRelease"+ label="Auto Release"+ value={autoRelease}+ onChange={(value) => {+ setAutoRelease(value);+ if (!value) {+ setAutoStartJob(false);+ }+ }}+ description="Automatically release the job when the kanban is scanned"+ />+ <Boolean+ name="autoStartJob"+ label="Auto Start Job"+ value={autoStartJob}+ onChange={setAutoStartJob}+ isDisabled={!autoRelease}+ description={+ autoRelease+ ? "Automatically start the job when the kanban is scanned"+ : "Auto release must be enabled to start a job automatically"+ }+ />+ <SequenceOrCustomId+ name="completedBarcodeOverride"+ label="Completion Barcode"+ table="kanban"+ placeholder="Auto-generated QR Code"+ />+ </>)}</div></VStack>diff --git a/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsx b/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsxindex 0296b1e516..679c338e59 100644--- a/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsx+++ b/apps/erp/app/modules/inventory/ui/Kanbans/KanbansTable.tsx@@ -1,7 +1,8 @@import {+ Badge,Checkbox,Combobox,- Copy,+ copyToClipboard,DropdownMenuContent,DropdownMenuGroup,DropdownMenuItem,@@ -11,8 +12,8 @@ import {HoverCardContent,HoverCardTrigger,HStack,- IconButton,MenuItem,+ toast,Tooltip,TooltipContent,TooltipTrigger,@@ -20,7 +21,7 @@ import {} from "@carbon/react";import { Link } from "@remix-run/react";import type { ColumnDef } from "@tanstack/react-table";-import { memo, useCallback, useMemo } from "react";+import { memo, useCallback, useMemo, useState } from "react";import {LuCalendar,LuCheck,@@ -108,53 +109,202 @@ const KanbansTable = memo(({ data, count, locationId }: KanbansTableProps) => {id: "links",header: "",cell: ({ row }) => (- <HStack>- <Tooltip>- <TooltipTrigger>- <IconButton- aria-label="Labels"- variant="secondary"- icon={<LuTag />}- onClick={() => {- window.open(- path.to.file.kanbanLabelsPdf([row.original.id!]),- "_blank"- );- }}- />- </TooltipTrigger>- <TooltipContent>Print Label</TooltipContent>- </Tooltip>+ <VStack>+ <HStack>+ <Tooltip>+ <TooltipTrigger>+ <a+ href={path.to.file.kanbanLabelsPdf([row.original.id!])}+ target="_blank"+ rel="noreferrer"+ >+ <Badge+ variant="outline"+ className="flex flex-row items-center gap-1"+ >+ <LuTag />+ Create+ </Badge>+ </a>+ </TooltipTrigger>+ <TooltipContent>+ Label to create a{" "}+ {row.original.replenishmentSystem === "Make"+ ? "Job"+ : "Order"}{" "}+ for this kanban+ </TooltipContent>+ </Tooltip>- <HoverCard>- <HoverCardTrigger>- <IconButton- aria-label="QR Code"- variant="secondary"- icon={<LuQrCode />}- />- </HoverCardTrigger>- <HoverCardContent- align="center"- className="size-[236px] overflow-hidden z-[100] bg-white p-4"- >- <iframe- seamless- title={"Kanban QR Code"}- width="198"- height="198"- src={path.to.file.kanbanQrCode(row.original.id!)}- />- </HoverCardContent>- </HoverCard>- <Copy- text={`${- typeof window === "undefined" ? "" : window.location.origin- }${path.to.api.kanban(row.original.id!)}`}- icon={<LuLink />}- size="md"- />- </HStack>+ <Tooltip>+ <TooltipTrigger>+ <a+ href={path.to.file.kanbanLabelsPdf([row.original.id!])}+ target="_blank"+ rel="noreferrer"+ >+ <Badge+ variant="outline"+ className="flex flex-row items-center gap-1"+ >+ <LuTag />+ Start+ </Badge>+ </a>+ </TooltipTrigger>+ <TooltipContent>+ Label to start the next operation for this kanban+ </TooltipContent>+ </Tooltip>++ <Tooltip>+ <TooltipTrigger>+ <a+ href={path.to.file.kanbanLabelsPdf([row.original.id!])}+ target="_blank"+ rel="noreferrer"+ >+ <Badge+ variant="outline"+ className="flex flex-row items-center gap-1"+ >+ <LuTag />+ Complete+ </Badge>+ </a>+ </TooltipTrigger>+ <TooltipContent>+ Label to complete the current operation for this kanban+ </TooltipContent>+ </Tooltip>+ </HStack>+ {row.original.replenishmentSystem === "Make" && (+ <>+ <HStack>+ <HoverCard>+ <Tooltip>+ <TooltipTrigger>+ <HoverCardTrigger>+ <Badge+ variant="outline"+ className="flex flex-row items-center gap-1 cursor-pointer"+ >+ <LuQrCode />+ Create+ </Badge>+ </HoverCardTrigger>+ </TooltipTrigger>+ <TooltipContent>+ QR Code to create a{" "}+ {row.original.replenishmentSystem === "Make"+ ? "Job"+ : "Order"}{" "}+ for this kanban+ </TooltipContent>+ </Tooltip>+ <HoverCardContent+ align="center"+ className="size-[236px] overflow-hidden z-[100] bg-white p-4"+ >+ <iframe+ seamless+ title={"Kanban QR Code"}+ width="198"+ height="198"+ src={path.to.file.kanbanQrCode(row.original.id!)}+ />+ </HoverCardContent>+ </HoverCard>++ <HoverCard>+ <Tooltip>+ <TooltipTrigger>+ <HoverCardTrigger>+ <Badge+ variant="outline"+ className="flex flex-row items-center gap-1 cursor-pointer"+ >+ <LuQrCode />+ Start+ </Badge>+ </HoverCardTrigger>+ </TooltipTrigger>+ <TooltipContent>+ QR Code to start the next operation for this kanban+ </TooltipContent>+ </Tooltip>+ <HoverCardContent+ align="center"+ className="size-[236px] overflow-hidden z-[100] bg-white p-4"+ >+ <iframe+ seamless+ title={"Kanban QR Code"}+ width="198"+ height="198"+ src={path.to.file.kanbanQrCode(row.original.id!)}+ />+ </HoverCardContent>+ </HoverCard>++ <HoverCard>+ <Tooltip>+ <TooltipTrigger>+ <HoverCardTrigger>+ <Badge+ variant="outline"+ className="flex flex-row items-center gap-1 cursor-pointer"+ >+ <LuQrCode />+ Complete+ </Badge>+ </HoverCardTrigger>+ </TooltipTrigger>+ <TooltipContent>+ QR Code to complete the current operation for this+ kanban+ </TooltipContent>+ </Tooltip>+ <HoverCardContent+ align="center"+ className="size-[236px] overflow-hidden z-[100] bg-white p-4"+ >+ <iframe+ seamless+ title={"Kanban QR Code"}+ width="198"+ height="198"+ src={path.to.file.kanbanQrCode(row.original.id!)}+ />+ </HoverCardContent>+ </HoverCard>+ </HStack>+ <HStack>+ <CopyBadge+ text="Create"+ url={path.to.api.kanban(row.original.id!)}+ tooltip={`Copy link to create a ${+ row.original.replenishmentSystem === "Make"+ ? "Job"+ : "Order"+ } for this kanban`}+ />++ <CopyBadge+ text="Start"+ url={path.to.api.kanban(row.original.id!)}+ tooltip={`Copy link to start the next operation for this kanban`}+ />++ <CopyBadge+ text="Complete"+ url={path.to.api.kanban(row.original.id!)}+ tooltip={`Copy link to complete the current operation for this kanban`}+ />+ </HStack>+ </>+ )}+ </VStack>),},{@@ -219,7 +369,25 @@ const KanbansTable = memo(({ data, count, locationId }: KanbansTableProps) => {},{accessorKey: "autoRelease",- header: "Auto Release",+ header: "Release",+ cell: ({ row }) =>+ row.original.replenishmentSystem === "Make" ? (+ <Checkbox isChecked={row.original.autoRelease ?? false} />+ ) : null,+ meta: {+ icon: <LuCheck />,+ filter: {+ type: "static",+ options: [+ { value: "true", label: "Yes" },+ { value: "false", label: "No" },+ ],+ },+ },+ },+ {+ accessorKey: "autoStartJob",+ header: "Start",cell: ({ row }) =>row.original.replenishmentSystem === "Make" ? (<Checkbox isChecked={row.original.autoRelease ?? false} />@@ -388,3 +556,38 @@ export default KanbansTable;function getLocationPath(locationId: string) {return `${path.to.kanbans}?location=${locationId}`;}++function CopyBadge({+ text,+ url,+ tooltip,+}: {+ text: string;+ url: string;+ tooltip: string;+}) {+ const [isCopied, setIsCopied] = useState(false);++ const handleCopy = () => {+ copyToClipboard(url);+ setIsCopied(true);+ toast.success("Copied link to clipboard");+ setTimeout(() => setIsCopied(false), 1500);+ };++ return (+ <Tooltip>+ <TooltipTrigger>+ <Badge+ variant="outline"+ className="flex flex-row items-center gap-1 cursor-pointer"+ onClick={handleCopy}+ >+ {isCopied ? <LuCheck className="text-emerald-500" /> : <LuLink />}+ {text}+ </Badge>+ </TooltipTrigger>+ <TooltipContent>{tooltip}</TooltipContent>+ </Tooltip>+ );+}diff --git a/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsx b/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsxindex 3e9aee036d..e9b0fe942f 100644--- a/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsx+++ b/apps/erp/app/routes/x+/inventory+/kanbans.$id.tsx@@ -79,6 +79,8 @@ export default function EditKanbanRoute() {purchaseUnitOfMeasureCode: kanban?.purchaseUnitOfMeasureCode ?? "",conversionFactor: kanban?.conversionFactor ?? 1,autoRelease: kanban?.autoRelease ?? false,+ autoStartJob: kanban?.autoStartJob ?? false,+ completedBarcodeOverride: kanban?.completedBarcodeOverride ?? "",};return (diff --git a/apps/erp/app/routes/x+/inventory+/kanbans.new.tsx b/apps/erp/app/routes/x+/inventory+/kanbans.new.tsxindex 092d3d2e80..495ce07d2b 100644--- a/apps/erp/app/routes/x+/inventory+/kanbans.new.tsx+++ b/apps/erp/app/routes/x+/inventory+/kanbans.new.tsx@@ -33,6 +33,8 @@ export async function action({ request }: ActionFunctionArgs) {const { id, ...data } = validation.data;+ console.log({ data });+const createKanban = await upsertKanban(client, {...data,companyId,@@ -66,6 +68,8 @@ export default function NewKanbanRoute() {locationId,conversionFactor: 1,autoRelease: false,+ autoStartJob: false,+ completedBarcodeOverride: "",};return (diff --git a/packages/database/supabase/migrations/20251001001426_kanban-jobs.sql b/packages/database/supabase/migrations/20251001001426_kanban-jobs.sqlnew file mode 100644index 0000000000..dff6a9744a--- /dev/null+++ b/packages/database/supabase/migrations/20251001001426_kanban-jobs.sql@@ -0,0 +1,26 @@+ALTER TABLE "kanban" ADD COLUMN "autoStartJob" BOOLEAN NOT NULL DEFAULT FALSE;+ALTER TABLE "kanban" ADD COLUMN "completedBarcodeOverride" TEXT;+ALTER TABLE "kanban" ADD COLUMN "jobId" TEXT;+ALTER TABLE "kanban" ADD CONSTRAINT "kanban_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "job"("id") ON DELETE SET NULL ON UPDATE CASCADE;++DROP VIEW IF EXISTS "kanbans";+CREATE VIEW "kanbans" WITH(SECURITY_INVOKER=true) AS+SELECT+ k.*,+ i.name,+ i."readableIdWithRevision",+ j."jobId" as "jobReadableId",+ l.name as "locationName",+ s.name as "shelfName",+ su.name as "supplierName",+ CASE+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"+ ELSE i."thumbnailPath"+ END AS "thumbnailPath"+FROM "kanban" k+JOIN "item" i ON k."itemId" = i."id"+LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"+JOIN "location" l ON k."locationId" = l."id"+LEFT JOIN "shelf" s ON k."shelfId" = s."id"+LEFT JOIN "supplier" su ON k."supplierId" = su."id"+LEFT JOIN "job" j ON k."jobId" = j."id";\ No newline at end of filediff --git a/packages/form/src/components/Boolean.tsx b/packages/form/src/components/Boolean.tsxindex 7af1c18979..1564bfc47b 100644--- a/packages/form/src/components/Boolean.tsx+++ b/packages/form/src/components/Boolean.tsx@@ -6,13 +6,14 @@ import {HStack,Switch,} from "@carbon/react";-import { forwardRef } from "react";+import { forwardRef, useEffect } from "react";import { useControlField, useField } from "../hooks";type FormBooleanProps = {name: string;variant?: "large" | "small";label?: string;+ value?: boolean;helperText?: string;isDisabled?: boolean;description?: string | JSX.Element;@@ -29,6 +30,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(onChange,variant,isDisabled,+ value: controlledValue,...props},ref@@ -36,6 +38,11 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(const { getInputProps, error } = useField(name);const [value, setValue] = useControlField<boolean>(name);+ useEffect(() => {+ if (controlledValue !== null && controlledValue !== undefined)+ setValue(controlledValue);+ }, [controlledValue, setValue]);+return (<FormControl isInvalid={!!error} className="pt-2">{label && <FormLabel htmlFor={name}>{label}</FormLabel>}diff --git a/packages/react/src/CreateableCombobox.tsx b/packages/react/src/CreateableCombobox.tsxindex 5ed5b6cfb1..63969a022f 100644--- a/packages/react/src/CreateableCombobox.tsx+++ b/packages/react/src/CreateableCombobox.tsx@@ -229,85 +229,87 @@ function VirtualizedCommand({placeholder="Search..."className="h-9"/>- <div- ref={parentRef}- className="overflow-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent pt-1"- style={{- height: `${Math.min(filteredOptions.length, 6) * itemHeight + 4}px`,- }}- >- <CommandGroup+ <CommandGroup>+ <div+ ref={parentRef}+ className="overflow-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"style={{- height: `${virtualizer.getTotalSize()}px`,- width: "100%",- position: "relative",+ height: `${Math.min(filteredOptions.length, 6) * itemHeight + 4}px`,}}>- {items.map((virtualRow) => {- const item = filteredOptions[virtualRow.index];+ <div+ style={{+ height: `${virtualizer.getTotalSize()}px`,+ width: "100%",+ position: "relative",+ }}+ >+ {items.map((virtualRow) => {+ const item = filteredOptions[virtualRow.index];- const isSelected = !!selected?.includes(item.value);- const isCreateOption = item.value === "create";+ const isSelected = !!selected?.includes(item.value);+ const isCreateOption = item.value === "create";- return (- <CommandItem- key={item.value}- value={- typeof item.label === "string"- ? CSS.escape(item.label) + CSS.escape(item.helper ?? "")- : undefined- }- onSelect={() => {- if (isCreateOption) {- onCreateOption?.(search);- } else if (!isSelected) {- onChange?.(item.value);- setSearch("");+ return (+ <CommandItem+ key={item.value}+ value={+ typeof item.label === "string"+ ? CSS.escape(item.label) + CSS.escape(item.helper ?? "")+ : undefined}- setOpen(false);- }}- style={{- position: "absolute",- top: 0,- left: 0,- width: "100%",- height: `${itemHeight}px`,- transform: `translateY(${virtualRow.start}px)`,- }}- className="flex items-center justify-between min-w-0"- >- {isCreateOption ? (- <div className="flex items-center min-w-0 flex-1">- <span>Create</span>- <span className="ml-1 font-bold truncate">- {search.trim() === "" ? label : search}- </span>- </div>- ) : item.helper ? (- <div className="flex flex-col min-w-0 flex-1">- <p className="truncate">{item.label}</p>- <p className="text-xs text-muted-foreground truncate">- {item.helper}- </p>- </div>- ) : (- <span className="truncate flex-1">{item.label}</span>- )}- {!isCreateOption && (- <LuCheck- className={cn(- "ml-auto h-4 w-4 flex-shrink-0",- isSelected || item.value === value- ? "opacity-100"- : "opacity-0"- )}- />- )}- </CommandItem>- );- })}- </CommandGroup>- </div>+ onSelect={() => {+ if (isCreateOption) {+ onCreateOption?.(search);+ } else if (!isSelected) {+ onChange?.(item.value);+ setSearch("");+ }+ setOpen(false);+ }}+ style={{+ position: "absolute",+ top: 0,+ left: 0,+ width: "100%",+ height: `${itemHeight}px`,+ transform: `translateY(${virtualRow.start}px)`,+ }}+ className="flex items-center justify-between min-w-0"+ >+ {isCreateOption ? (+ <div className="flex items-center min-w-0 flex-1">+ <span>Create</span>+ <span className="ml-1 font-bold truncate">+ {search.trim() === "" ? label : search}+ </span>+ </div>+ ) : item.helper ? (+ <div className="flex flex-col min-w-0 flex-1">+ <p className="truncate">{item.label}</p>+ <p className="text-xs text-muted-foreground truncate">+ {item.helper}+ </p>+ </div>+ ) : (+ <span className="truncate flex-1">{item.label}</span>+ )}+ {!isCreateOption && (+ <LuCheck+ className={cn(+ "ml-auto h-4 w-4 flex-shrink-0",+ isSelected || item.value === value+ ? "opacity-100"+ : "opacity-0"+ )}+ />+ )}+ </CommandItem>+ );+ })}+ </div>+ </div>+ </CommandGroup></Command>);}