Some checks failed
CI/CD Pipeline - Xpeditis PreProd / Backend - Build & Test (push) Failing after 5m51s
CI/CD Pipeline - Xpeditis PreProd / Backend - Docker Build & Push (push) Has been skipped
CI/CD Pipeline - Xpeditis PreProd / Frontend - Build & Test (push) Successful in 10m57s
CI/CD Pipeline - Xpeditis PreProd / Frontend - Docker Build & Push (push) Failing after 12m28s
CI/CD Pipeline - Xpeditis PreProd / Deploy to PreProd Server (push) Has been skipped
CI/CD Pipeline - Xpeditis PreProd / Run Smoke Tests (push) Has been skipped
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
|
|
const Select = ({ children, value, onValueChange }: any) => {
|
|
return (
|
|
<div className="relative">
|
|
{React.Children.map(children, (child) =>
|
|
React.cloneElement(child, { value, onValueChange })
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const SelectTrigger = React.forwardRef<HTMLButtonElement, any>(
|
|
({ className, children, value, ...props }, ref) => {
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
className={`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${className || ''}`}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|
|
);
|
|
SelectTrigger.displayName = 'SelectTrigger';
|
|
|
|
const SelectValue = ({ placeholder }: any) => {
|
|
return <span>{placeholder}</span>;
|
|
};
|
|
|
|
const SelectContent = ({ children, value, onValueChange }: any) => {
|
|
return (
|
|
<div className="relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md">
|
|
{React.Children.map(children, (child) =>
|
|
React.cloneElement(child, { value, onValueChange })
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const SelectItem = React.forwardRef<HTMLDivElement, any>(
|
|
({ className, children, value: itemValue, onValueChange, ...props }, ref) => {
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
className={`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 px-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 ${className || ''}`}
|
|
onClick={() => onValueChange?.(itemValue)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
SelectItem.displayName = 'SelectItem';
|
|
|
|
export { Select, SelectTrigger, SelectValue, SelectContent, SelectItem };
|